@sprig-technologies/sprig-bundled 1.1.3 → 1.1.5

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.
@@ -0,0 +1,31 @@
1
+ "use strict";var Ps=Object.defineProperty;var Bs=(e,t,r)=>t in e?Ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ee=(e,t,r)=>(Bs(e,typeof t!="symbol"?t+"":t,r),r);var Ws=Object.create,Jn=Object.defineProperty,Vs=Object.getOwnPropertyDescriptor,zs=Object.getOwnPropertyNames,Hs=Object.getPrototypeOf,Gs=Object.prototype.hasOwnProperty,bt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),js=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of zs(t))!Gs.call(e,i)&&i!==r&&Jn(e,i,{get:()=>t[i],enumerable:!(n=Vs(t,i))||n.enumerable});return e},Ks=(e,t,r)=>(r=e!=null?Ws(Hs(e)):{},js(!e||!e.__esModule?Jn(r,"default",{value:e,enumerable:!0}):r,e)),Zs=bt((e,t)=>{var r;typeof window<"u"?r=window:typeof global<"u"?r=global:typeof self<"u"?r=self:r={},t.exports=r}),Ys=bt((e,t)=>{t.exports=n;var r=Object.prototype.toString;function n(i){if(!i)return!1;var s=r.call(i);return s==="[object Function]"||typeof i=="function"&&s!=="[object RegExp]"||typeof window<"u"&&(i===window.setTimeout||i===window.alert||i===window.confirm||i===window.prompt)}}),$s=bt((e,t)=>{var r=function(i){return i.replace(/^\s+|\s+$/g,"")},n=function(i){return Object.prototype.toString.call(i)==="[object Array]"};t.exports=function(i){if(!i)return{};for(var s={},o=r(i).split(`
2
+ `),l=0;l<o.length;l++){var a=o[l],d=a.indexOf(":"),c=r(a.slice(0,d)).toLowerCase(),p=r(a.slice(d+1));typeof s[c]>"u"?s[c]=p:n(s[c])?s[c].push(p):s[c]=[s[c],p]}return s}}),qs=bt((e,t)=>{t.exports=n;var r=Object.prototype.hasOwnProperty;function n(){for(var i={},s=0;s<arguments.length;s++){var o=arguments[s];for(var l in o)r.call(o,l)&&(i[l]=o[l])}return i}}),Js=bt((e,t)=>{var r=Zs(),n=Ys(),i=$s(),s=qs();t.exports=d,t.exports.default=d,d.XMLHttpRequest=r.XMLHttpRequest||f,d.XDomainRequest="withCredentials"in new d.XMLHttpRequest?d.XMLHttpRequest:r.XDomainRequest,o(["get","put","post","patch","head","delete"],function(u){d[u==="delete"?"del":u]=function(h,g,I){return g=a(h,g,I),g.method=u.toUpperCase(),c(g)}});function o(u,h){for(var g=0;g<u.length;g++)h(u[g])}function l(u){for(var h in u)if(u.hasOwnProperty(h))return!1;return!0}function a(u,h,g){var I=u;return n(h)?(g=h,typeof u=="string"&&(I={uri:u})):I=s(h,{uri:u}),I.callback=g,I}function d(u,h,g){return h=a(u,h,g),c(h)}function c(u){if(typeof u.callback>"u")throw new Error("callback argument missing");var h=!1,g=function(b,B,Z){h||(h=!0,u.callback(b,B,Z))};function I(){w.readyState===4&&setTimeout(m,0)}function k(){var b=void 0;if(w.response?b=w.response:b=w.responseText||p(w),G)try{b=JSON.parse(b)}catch{}return b}function y(b){return clearTimeout(Q),b instanceof Error||(b=new Error(""+(b||"Unknown XMLHttpRequest Error"))),b.statusCode=0,g(b,pe)}function m(){if(!T){var b;clearTimeout(Q),u.useXDR&&w.status===void 0?b=200:b=w.status===1223?204:w.status;var B=pe,Z=null;return b!==0?(B={body:k(),statusCode:b,method:S,headers:{},url:A,rawRequest:w},w.getAllResponseHeaders&&(B.headers=i(w.getAllResponseHeaders()))):Z=new Error("Internal XMLHttpRequest Error"),g(Z,B,B.body)}}var w=u.xhr||null;w||(u.cors||u.useXDR?w=new d.XDomainRequest:w=new d.XMLHttpRequest);var R,T,A=w.url=u.uri||u.url,S=w.method=u.method||"GET",z=u.body||u.data,D=w.headers=u.headers||{},H=!!u.sync,G=!1,Q,pe={body:void 0,headers:{},statusCode:0,method:S,url:A,rawRequest:w};if("json"in u&&u.json!==!1&&(G=!0,D.accept||D.Accept||(D.Accept="application/json"),S!=="GET"&&S!=="HEAD"&&(D["content-type"]||D["Content-Type"]||(D["Content-Type"]="application/json"),z=JSON.stringify(u.json===!0?z:u.json))),w.onreadystatechange=I,w.onload=m,w.onerror=y,w.onprogress=function(){},w.onabort=function(){T=!0},w.ontimeout=y,w.open(S,A,!H,u.username,u.password),H||(w.withCredentials=!!u.withCredentials),!H&&u.timeout>0&&(Q=setTimeout(function(){if(!T){T=!0,w.abort("timeout");var b=new Error("XMLHttpRequest timeout");b.code="ETIMEDOUT",y(b)}},u.timeout)),w.setRequestHeader)for(R in D)D.hasOwnProperty(R)&&w.setRequestHeader(R,D[R]);else if(u.headers&&!l(u.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in u&&(w.responseType=u.responseType),"beforeSend"in u&&typeof u.beforeSend=="function"&&u.beforeSend(w),w.send(z||null),w}function p(u){try{if(u.responseType==="document")return u.responseXML;var h=u.responseXML&&u.responseXML.documentElement.nodeName==="parsererror";if(u.responseType===""&&!h)return u.responseXML}catch{}return null}function f(){}});function jr(e,t,...r){if(!e)throw new TypeError(Qn(t,r))}function Qn(e,t){let r=0;return e.replace(/%[os]/gu,()=>Xn(t[r++]))}function Xn(e){return typeof e!="object"||e===null?String(e):Object.prototype.toString.call(e)}var Qs;function Xs(e){try{let t=e instanceof Error?e:new Error(Xn(e));if(typeof dispatchEvent=="function"&&typeof ErrorEvent=="function")dispatchEvent(new ErrorEvent("error",{error:t,message:t.message}));else if(typeof process<"u"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)}catch{}}var Ie=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,eo,Pe=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{let r=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
3
+ `);console.warn(this.message,...e,r)}catch{}}},to=new Pe("W01","Unable to initialize event under dispatching."),ro=new Pe("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),no=new Pe("W03","Assigning any truthy value to 'returnValue' property has no effect."),io=new Pe("W04","Unable to preventDefault on non-cancelable events."),so=new Pe("W05","Unable to preventDefault inside passive event listener invocation."),oo=new Pe("W06","An event listener wasn't added because it has been added already: %o, %o"),ur=new Pe("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),sn=new Pe("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),Ue=class{static get NONE(){return on}static get CAPTURING_PHASE(){return an}static get AT_TARGET(){return ln}static get BUBBLING_PHASE(){return cn}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});let r=t??{};Sr.set(this,{type:String(e),bubbles:!!r.bubbles,cancelable:!!r.cancelable,composed:!!r.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return Y(this).type}get target(){return Y(this).target}get srcElement(){return Y(this).target}get currentTarget(){return Y(this).currentTarget}composedPath(){let e=Y(this).currentTarget;return e?[e]:[]}get NONE(){return on}get CAPTURING_PHASE(){return an}get AT_TARGET(){return ln}get BUBBLING_PHASE(){return cn}get eventPhase(){return Y(this).dispatchFlag?2:0}stopPropagation(){Y(this).stopPropagationFlag=!0}get cancelBubble(){return Y(this).stopPropagationFlag}set cancelBubble(e){e?Y(this).stopPropagationFlag=!0:ro.warn()}stopImmediatePropagation(){let e=Y(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return Y(this).bubbles}get cancelable(){return Y(this).cancelable}get returnValue(){return!Y(this).canceledFlag}set returnValue(e){e?no.warn():dn(Y(this))}preventDefault(){dn(Y(this))}get defaultPrevented(){return Y(this).canceledFlag}get composed(){return Y(this).composed}get isTrusted(){return!1}get timeStamp(){return Y(this).timeStamp}initEvent(e,t=!1,r=!1){let n=Y(this);if(n.dispatchFlag){to.warn();return}Sr.set(this,{...n,type:String(e),bubbles:!!t,cancelable:!!r,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},on=0,an=1,ln=2,cn=3,Sr=new WeakMap;function Y(e,t="this"){let r=Sr.get(e);return jr(r!=null,"'%s' must be an object that Event constructor created, but got another one: %o",t,e),r}function dn(e){if(e.inPassiveListenerFlag){so.warn();return}if(!e.cancelable){io.warn();return}e.canceledFlag=!0}Object.defineProperty(Ue,"NONE",{enumerable:!0});Object.defineProperty(Ue,"CAPTURING_PHASE",{enumerable:!0});Object.defineProperty(Ue,"AT_TARGET",{enumerable:!0});Object.defineProperty(Ue,"BUBBLING_PHASE",{enumerable:!0});var pr=Object.getOwnPropertyNames(Ue.prototype);for(let e=0;e<pr.length;++e)pr[e]!=="constructor"&&Object.defineProperty(Ue.prototype,pr[e],{enumerable:!0});typeof Ie<"u"&&typeof Ie.Event<"u"&&Object.setPrototypeOf(Ue.prototype,Ie.Event.prototype);function ao(e){return Ie.DOMException?new Ie.DOMException(e,"InvalidStateError"):(qe==null&&(qe=class ei extends Error{constructor(r){super(r),Error.captureStackTrace&&Error.captureStackTrace(this,ei)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(qe.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),pn(qe),pn(qe.prototype)),new qe(e))}var qe,un={INDEX_SIZE_ERR:1,DOMSTRING_SIZE_ERR:2,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,INVALID_CHARACTER_ERR:5,NO_DATA_ALLOWED_ERR:6,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INUSE_ATTRIBUTE_ERR:10,INVALID_STATE_ERR:11,SYNTAX_ERR:12,INVALID_MODIFICATION_ERR:13,NAMESPACE_ERR:14,INVALID_ACCESS_ERR:15,VALIDATION_ERR:16,TYPE_MISMATCH_ERR:17,SECURITY_ERR:18,NETWORK_ERR:19,ABORT_ERR:20,URL_MISMATCH_ERR:21,QUOTA_EXCEEDED_ERR:22,TIMEOUT_ERR:23,INVALID_NODE_TYPE_ERR:24,DATA_CLONE_ERR:25};function pn(e){let t=Object.keys(un);for(let r=0;r<t.length;++r){let n=t[r],i=un[n];Object.defineProperty(e,n,{get(){return i},configurable:!0,enumerable:!0})}}var er=class extends Ue{static wrap(e){return new(ri(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),ti.set(this,{original:e});let t=Object.keys(e);for(let r=0;r<t.length;++r){let n=t[r];n in this||Object.defineProperty(this,n,ni(e,n))}}stopPropagation(){super.stopPropagation();let{original:e}=_e(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;let{original:t}=_e(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();let{original:e}=_e(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;let{original:t}=_e(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();let{original:e}=_e(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){let{original:e}=_e(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},ti=new WeakMap;function _e(e){let t=ti.get(e);return jr(t!=null,"'this' is expected an Event object, but got",e),t}var Ft=new WeakMap;Ft.set(Object.prototype,er);typeof Ie<"u"&&typeof Ie.Event<"u"&&Ft.set(Ie.Event.prototype,er);function ri(e){let t=Object.getPrototypeOf(e);if(t==null)return er;let r=Ft.get(t);return r==null&&(r=lo(ri(t),t),Ft.set(t,r)),r}function lo(e,t){class r extends e{}let n=Object.keys(t);for(let i=0;i<n.length;++i)Object.defineProperty(r.prototype,n[i],ni(t,n[i]));return r}function ni(e,t){let r=Object.getOwnPropertyDescriptor(e,t);return{get(){let n=_e(this).original,i=n[t];return typeof i=="function"?i.bind(n):i},set(n){let i=_e(this).original;i[t]=n},configurable:r.configurable,enumerable:r.enumerable}}function co(e,t,r,n,i,s){return{callback:e,flags:(t?1:0)|(r?2:0)|(n?4:0),signal:i,signalListener:s}}function uo(e){e.flags|=8}function ii(e){return(e.flags&1)===1}function si(e){return(e.flags&2)===2}function oi(e){return(e.flags&4)===4}function po(e){return(e.flags&8)===8}function ho({callback:e},t,r){try{typeof e=="function"?e.call(t,r):typeof e.handleEvent=="function"&&e.handleEvent(r)}catch(n){Xs(n)}}function ai({listeners:e},t,r){for(let n=0;n<e.length;++n)if(e[n].callback===t&&ii(e[n])===r)return n;return-1}function fo(e,t,r,n,i,s){let o;s&&(o=li.bind(null,e,t,r),s.addEventListener("abort",o));let l=co(t,r,n,i,s,o);return e.cow?(e.cow=!1,e.listeners=[...e.listeners,l]):e.listeners.push(l),l}function li(e,t,r){let n=ai(e,t,r);return n!==-1?ci(e,n):!1}function ci(e,t,r=!1){let n=e.listeners[t];return uo(n),n.signal&&n.signal.removeEventListener("abort",n.signalListener),e.cow&&!r?(e.cow=!1,e.listeners=e.listeners.filter((i,s)=>s!==t),!1):(e.listeners.splice(t,1),!0)}function go(){return Object.create(null)}function mo(e,t){var r;return(r=e[t])!==null&&r!==void 0?r:e[t]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var tr=class{constructor(){di.set(this,go())}addEventListener(e,t,r){let n=hr(this),{callback:i,capture:s,once:o,passive:l,signal:a,type:d}=yo(e,t,r);if(i==null||a!=null&&a.aborted)return;let c=mo(n,d),p=ai(c,i,s);if(p!==-1){Io(c.listeners[p],l,o,a);return}fo(c,i,s,l,o,a)}removeEventListener(e,t,r){let n=hr(this),{callback:i,capture:s,type:o}=wo(e,t,r),l=n[o];i!=null&&l&&li(l,i,s)}dispatchEvent(e){let t=hr(this)[String(e.type)];if(t==null)return!0;let r=e instanceof Ue?e:er.wrap(e),n=Y(r,"event");if(n.dispatchFlag)throw ao("This event has been in dispatching.");if(n.dispatchFlag=!0,n.target=n.currentTarget=this,!n.stopPropagationFlag){let{cow:i,listeners:s}=t;t.cow=!0;for(let o=0;o<s.length;++o){let l=s[o];if(!po(l)&&(oi(l)&&ci(t,o,!i)&&(o-=1),n.inPassiveListenerFlag=si(l),ho(l,this,r),n.inPassiveListenerFlag=!1,n.stopImmediatePropagationFlag))break}i||(t.cow=!1)}return n.target=null,n.currentTarget=null,n.stopImmediatePropagationFlag=!1,n.stopPropagationFlag=!1,n.dispatchFlag=!1,!n.canceledFlag}},di=new WeakMap;function hr(e,t="this"){let r=di.get(e);return jr(r!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",t,e),r}function yo(e,t,r){var n;return ui(t),typeof r=="object"&&r!==null?{type:String(e),callback:t??void 0,capture:!!r.capture,passive:!!r.passive,once:!!r.once,signal:(n=r.signal)!==null&&n!==void 0?n:void 0}:{type:String(e),callback:t??void 0,capture:!!r,passive:!1,once:!1,signal:void 0}}function wo(e,t,r){return ui(t),typeof r=="object"&&r!==null?{type:String(e),callback:t??void 0,capture:!!r.capture}:{type:String(e),callback:t??void 0,capture:!!r}}function ui(e){if(!(typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.handleEvent=="function")){if(e==null||typeof e=="object"){sn.warn(e);return}throw new TypeError(Qn(sn.message,[e]))}}function Io(e,t,r,n){oo.warn(ii(e)?"capture":"bubble",e.callback),si(e)!==t&&ur.warn("passive"),oi(e)!==r&&ur.warn("once"),e.signal!==n&&ur.warn("signal")}var fr=Object.getOwnPropertyNames(tr.prototype);for(let e=0;e<fr.length;++e)fr[e]!=="constructor"&&Object.defineProperty(tr.prototype,fr[e],{enumerable:!0});typeof Ie<"u"&&typeof Ie.EventTarget<"u"&&Object.setPrototypeOf(tr.prototype,Ie.EventTarget.prototype);var vo=Ks(Js()),pi=30720,rr=512e3,nr=256,Cr=(e,{minChunkSize:t=nr,maxChunkSize:r=rr}={})=>e==null||typeof e=="number"&&e>=256&&e%256===0&&e>=t&&e<=r,kr=(e,{minChunkSize:t=nr,maxChunkSize:r=rr}={})=>new TypeError(`chunkSize ${e} must be a positive number in multiples of 256, between ${t} and ${r}`),bo=class{constructor(e,t={}){this.readableStream=e;var r,n,i;if(!Cr(t.defaultChunkSize,t))throw kr(t.defaultChunkSize,t);this.defaultChunkSize=(r=t.defaultChunkSize)!=null?r:pi,this.minChunkSize=(n=t.minChunkSize)!=null?n:nr,this.maxChunkSize=(i=t.maxChunkSize)!=null?i:rr}get chunkSize(){var e;return(e=this._chunkSize)!=null?e:this.defaultChunkSize}set chunkSize(e){if(!Cr(e,this))throw kr(e,this);this._chunkSize=e}get chunkByteSize(){return this.chunkSize*1024}async*[Symbol.asyncIterator](){let e,t=this.readableStream.getReader();try{for(;;){let{done:r,value:n}=await t.read();if(r){if(e){let s=e;e=void 0,yield s}break}let i=n instanceof Uint8Array?new Blob([n],{type:"application/octet-stream"}):n;for(e=e?new Blob([e,i]):i;e;)if(e.size===this.chunkByteSize){let s=e;e=void 0,yield s;break}else{if(e.size<this.chunkByteSize)break;{let s=e.slice(0,this.chunkByteSize);e=e.slice(this.chunkByteSize),yield s}}}}finally{if(e){let r=e;e=void 0,yield r}t.releaseLock();return}}},So=[200,201,202,204,308],hi=[408,502,503,504],fi=(e,t)=>!!e&&So.includes(e.statusCode),Co=(e,{retryCodes:t=hi})=>!e||t.includes(e.statusCode),ko=(e,t)=>t.attemptCount>=t.attempts||!(fi(e)||Co(e,t)),gi=class{static createUpload(e){return new gi(e)}constructor(e){this.endpoint=e.endpoint,this.file=e.file,this.headers=e.headers||{},this.method=e.method||"PUT",this.attempts=e.attempts||5,this.delayBeforeAttempt=e.delayBeforeAttempt||1,this.retryCodes=e.retryCodes||hi,this.dynamicChunkSize=e.dynamicChunkSize||!1,this.maxFileBytes=(e.maxFileSize||0)*1024,this.chunkCount=0,this.attemptCount=0,this.offline=!1,this._paused=!1,this.success=!1,this.nextChunkRangeStart=0,this.chunkedStreamIterable=new bo(this.file.stream(),{...e,defaultChunkSize:e.chunkSize}),this.chunkedStreamIterator=this.chunkedStreamIterable[Symbol.asyncIterator](),this.totalChunks=Math.ceil(this.file.size/this.chunkByteSize),this.eventTarget=new tr,this.validateOptions(),this.getEndpoint().then(()=>this.sendChunks()),typeof window<"u"&&(window.addEventListener("online",()=>{!this.offline||(this.offline=!1,this.dispatch("online"),this.sendChunks())}),window.addEventListener("offline",()=>{this.offline=!0,this.dispatch("offline")}))}get maxChunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.maxChunkSize)!=null?t:rr}get minChunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.minChunkSize)!=null?t:nr}get chunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.chunkSize)!=null?t:pi}set chunkSize(e){this.chunkedStreamIterable.chunkSize=e}get chunkByteSize(){return this.chunkedStreamIterable.chunkByteSize}get totalChunkSize(){return Math.ceil(this.file.size/this.chunkByteSize)}on(e,t){this.eventTarget.addEventListener(e,t)}once(e,t){this.eventTarget.addEventListener(e,t,{once:!0})}off(e,t){this.eventTarget.removeEventListener(e,t)}get paused(){return this._paused}abort(){var e;this.pause(),(e=this.currentXhr)==null||e.abort()}pause(){this._paused=!0}resume(){this._paused&&(this._paused=!1,this.sendChunks())}dispatch(e,t){let r=new CustomEvent(e,{detail:t});this.eventTarget.dispatchEvent(r)}validateOptions(){if(!this.endpoint||typeof this.endpoint!="function"&&typeof this.endpoint!="string")throw new TypeError("endpoint must be defined as a string or a function that returns a promise");if(!(this.file instanceof File))throw new TypeError("file must be a File object");if(this.headers&&typeof this.headers!="function"&&typeof this.headers!="object")throw new TypeError("headers must be null, an object, or a function that returns an object or a promise");if(!Cr(this.chunkSize,{maxChunkSize:this.maxChunkSize,minChunkSize:this.minChunkSize}))throw kr(this.chunkSize,{maxChunkSize:this.maxChunkSize,minChunkSize:this.minChunkSize});if(this.maxChunkSize&&(typeof this.maxChunkSize!="number"||this.maxChunkSize<256||this.maxChunkSize%256!==0||this.maxChunkSize<this.chunkSize||this.maxChunkSize<this.minChunkSize))throw new TypeError(`maxChunkSize must be a positive number in multiples of 256, and larger than or equal to both ${this.minChunkSize} and ${this.chunkSize}`);if(this.minChunkSize&&(typeof this.minChunkSize!="number"||this.minChunkSize<256||this.minChunkSize%256!==0||this.minChunkSize>this.chunkSize||this.minChunkSize>this.maxChunkSize))throw new TypeError(`minChunkSize must be a positive number in multiples of 256, and smaller than ${this.chunkSize} and ${this.maxChunkSize}`);if(this.maxFileBytes>0&&this.maxFileBytes<this.file.size)throw new Error(`file size exceeds maximum (${this.file.size} > ${this.maxFileBytes})`);if(this.attempts&&(typeof this.attempts!="number"||this.attempts<=0))throw new TypeError("retries must be a positive number");if(this.delayBeforeAttempt&&(typeof this.delayBeforeAttempt!="number"||this.delayBeforeAttempt<0))throw new TypeError("delayBeforeAttempt must be a positive number")}getEndpoint(){return typeof this.endpoint=="string"?(this.endpointValue=this.endpoint,Promise.resolve(this.endpoint)):this.endpoint(this.file).then(e=>(this.endpointValue=e,this.endpointValue))}xhrPromise(e){let t=r=>{r.upload.onprogress=n=>{var i;let s=this.totalChunks-this.chunkCount,o=(this.file.size-this.nextChunkRangeStart)/this.file.size/s,l=this.nextChunkRangeStart/this.file.size,a=n.loaded/((i=n.total)!=null?i:this.chunkByteSize)*o;this.dispatch("progress",Math.min((l+a)*100,100))}};return new Promise((r,n)=>{this.currentXhr=(0,vo.default)({...e,beforeSend:t},(i,s)=>(this.currentXhr=void 0,i?n(i):r(s)))})}async sendChunk(e){let t=this.nextChunkRangeStart,r=t+e.size-1,n={...await(typeof this.headers=="function"?this.headers():this.headers),"Content-Type":this.file.type,"Content-Range":`bytes ${t}-${r}/${this.file.size}`};return this.dispatch("attempt",{chunkNumber:this.chunkCount,totalChunks:this.totalChunks,chunkSize:this.chunkSize}),this.xhrPromise({headers:n,url:this.endpointValue,method:this.method,body:e})}async sendChunkWithRetries(e){let t=async(o,l)=>{var a;let d=(new Date().getTime()-this.lastChunkStart.getTime())/1e3;if(this.dispatch("chunkSuccess",{chunk:this.chunkCount,chunkSize:this.chunkSize,attempts:this.attemptCount,timeInterval:d,response:o}),this.attemptCount=0,this.chunkCount=((a=this.chunkCount)!=null?a:0)+1,this.nextChunkRangeStart=this.nextChunkRangeStart+this.chunkByteSize,this.dynamicChunkSize){let c=this.chunkSize;d<10?c=Math.min(this.chunkSize*2,this.maxChunkSize):d>30&&(c=Math.max(this.chunkSize/2,this.minChunkSize)),this.chunkSize=Math.ceil(c/256)*256;let p=(this.file.size-this.nextChunkRangeStart)/this.chunkByteSize;this.totalChunks=Math.ceil(this.chunkCount+p)}return!0},r=async(o,l)=>(this.dispatch("error",{message:`Server responded with ${o.statusCode}. Stopping upload.`,chunk:this.chunkCount,attempts:this.attemptCount}),!1),n=async(o,l)=>(this.dispatch("attemptFailure",{message:`An error occured uploading chunk ${this.chunkCount}. ${this.attempts-this.attemptCount} retries left.`,chunkNumber:this.chunkCount,attemptsLeft:this.attempts-this.attemptCount}),new Promise(a=>{setTimeout(async()=>{if(this._paused||this.offline){this.pendingChunk=e,a(!1);return}let d=await this.sendChunkWithRetries(e);a(d)},this.delayBeforeAttempt*1e3)})),i;try{this.attemptCount=this.attemptCount+1,this.lastChunkStart=new Date,i=await this.sendChunk(e)}catch{}let s={retryCodes:this.retryCodes,attemptCount:this.attemptCount,attempts:this.attempts};return fi(i)?t(i):ko(i,s)?r(i):n()}async sendChunks(){if(this.pendingChunk&&!(this._paused||this.offline)){let e=this.pendingChunk;this.pendingChunk=void 0;let t=await this.sendChunkWithRetries(e);this.success&&t&&this.dispatch("success")}for(;!(this.success||this._paused||this.offline);){let{value:e,done:t}=await this.chunkedStreamIterator.next(),r=!e&&t;if(e&&(r=await this.sendChunkWithRetries(e)),this.success=!!t,this.success&&r&&this.dispatch("success"),!r)return}}},Ao=gi.createUpload,q;(function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"})(q||(q={}));function Eo(e){return e.nodeType===e.ELEMENT_NODE}function dt(e){var t=e==null?void 0:e.host;return(t==null?void 0:t.shadowRoot)===e}function ut(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function Lo(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),e}function Ro(e){var t=e.cssText;if(t.split('"').length<3)return t;var r=["@import","url(".concat(JSON.stringify(e.href),")")];return e.layerName===""?r.push("layer"):e.layerName&&r.push("layer(".concat(e.layerName,")")),e.supportsText&&r.push("supports(".concat(e.supportsText,")")),e.media.length&&r.push(e.media.mediaText),r.join(" ")+";"}function Pt(e){try{var t=e.rules||e.cssRules;return t?Lo(Array.from(t).map(mi).join("")):null}catch{return null}}function mi(e){var t;if(Uo(e))try{t=Pt(e.styleSheet)||Ro(e)}catch{}return To(t||e.cssText)}function To(e){if(e.includes(":")){var t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}return e}function Uo(e){return"styleSheet"in e}var yi=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var r;if(!t)return-1;var n=(r=this.getMeta(t))===null||r===void 0?void 0:r.id;return n??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var r=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(i){return r.removeNodeFromMap(i)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,r){var n=r.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,r)},e.prototype.replace=function(t,r){var n=this.getNode(t);if(n){var i=this.nodeMetaMap.get(n);i&&this.nodeMetaMap.set(r,i)}this.idNodeMap.set(t,r)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function _o(){return new yi}function Kr(e){var t=e.element,r=e.maskInputOptions,n=e.tagName,i=e.type,s=e.value,o=e.maskInputFn,l=s||"",a=i&&je(i);return(r[n.toLowerCase()]||a&&r[a])&&(o?l=o(l,t):l="*".repeat(l.length)),l}function je(e){return e.toLowerCase()}var hn="__rrweb_original__";function Oo(e){var t=e.getContext("2d");if(!t)return!0;for(var r=50,n=0;n<e.width;n+=r)for(var i=0;i<e.height;i+=r){var s=t.getImageData,o=hn in s?s[hn]:s,l=new Uint32Array(o.call(t,n,i,Math.min(r,e.width-n),Math.min(r,e.height-i)).data.buffer);if(l.some(function(a){return a!==0}))return!1}return!0}function Zr(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?je(t):null}var Do=1,xo=new RegExp("[^a-z0-9-_:]"),gt=-2;function wi(){return Do++}function Mo(e){if(e instanceof HTMLFormElement)return"form";var t=je(e.tagName);return xo.test(t)?"div":t}function No(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var Je,fn,Fo=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Po=/^(?:[a-z+]+:)?\/\//i,Bo=/^www\..*/i,Wo=/^(data:)([^,]*),(.*)/i;function Bt(e,t){return(e||"").replace(Fo,function(r,n,i,s,o,l){var a=i||o||l,d=n||s||"";if(!a)return r;if(Po.test(a)||Bo.test(a)||Wo.test(a))return"url(".concat(d).concat(a).concat(d,")");if(a[0]==="/")return"url(".concat(d).concat(No(t)+a).concat(d,")");var c=t.split("/"),p=a.split("/");c.pop();for(var f=0,u=p;f<u.length;f++){var h=u[f];h!=="."&&(h===".."?c.pop():c.push(h))}return"url(".concat(d).concat(c.join("/")).concat(d,")")})}var Vo=/^[^ \t\n\r\u000c]+/,zo=/^[, \t\n\r\u000c]+/;function Ho(e,t){if(t.trim()==="")return t;var r=0;function n(d){var c,p=d.exec(t.substring(r));return p?(c=p[0],r+=c.length,c):""}for(var i=[];n(zo),!(r>=t.length);){var s=n(Vo);if(s.slice(-1)===",")s=Xe(e,s.substring(0,s.length-1)),i.push(s);else{var o="";s=Xe(e,s);for(var l=!1;;){var a=t.charAt(r);if(a===""){i.push((s+o).trim());break}else if(l)a===")"&&(l=!1);else if(a===","){r+=1,i.push((s+o).trim());break}else a==="("&&(l=!0);o+=a,r+=1}}}return i.join(", ")}function Xe(e,t){if(!t||t.trim()==="")return t;var r=e.createElement("a");return r.href=t,r.href}function Go(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function Yr(){var e=document.createElement("a");return e.href="",e.href}function Ii(e,t,r,n){return n&&(r==="src"||r==="href"&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n[0]!=="#"||r==="background"&&(t==="table"||t==="td"||t==="th")?Xe(e,n):r==="srcset"?Ho(e,n):r==="style"?Bt(n,Yr()):t==="object"&&r==="data"?Xe(e,n):n)}function vi(e,t,r){return(e==="video"||e==="audio")&&t==="autoplay"}function jo(e,t,r){try{if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var n=e.classList.length;n--;){var i=e.classList[n];if(t.test(i))return!0}if(r)return e.matches(r)}catch{}return!1}function Wt(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?Wt(e.parentNode,t,r):!1;for(var n=e.classList.length;n--;){var i=e.classList[n];if(t.test(i))return!0}return r?Wt(e.parentNode,t,r):!1}function bi(e,t,r){try{var n=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(n===null)return!1;if(typeof t=="string"){if(n.classList.contains(t)||n.closest(".".concat(t)))return!0}else if(Wt(n,t,!0))return!0;if(r&&(n.matches(r)||n.closest(r)))return!0}catch{}return!1}function Ko(e,t,r){var n=e.contentWindow;if(n){var i=!1,s;try{s=n.document.readyState}catch{return}if(s!=="complete"){var o=setTimeout(function(){i||(t(),i=!0)},r);e.addEventListener("load",function(){clearTimeout(o),i=!0,t()});return}var l="about:blank";if(n.location.href!==l||e.src===l||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function Zo(e,t,r){var n=!1,i;try{i=e.sheet}catch{return}if(!i){var s=setTimeout(function(){n||(t(),n=!0)},r);e.addEventListener("load",function(){clearTimeout(s),n=!0,t()})}}function Yo(e,t){var r=t.doc,n=t.mirror,i=t.blockClass,s=t.blockSelector,o=t.maskTextClass,l=t.maskTextSelector,a=t.inlineStylesheet,d=t.maskInputOptions,c=d===void 0?{}:d,p=t.maskTextFn,f=t.maskInputFn,u=t.dataURLOptions,h=u===void 0?{}:u,g=t.inlineImages,I=t.recordCanvas,k=t.keepIframeSrcFn,y=t.newlyAddedElement,m=y===void 0?!1:y,w=$o(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:q.Document,childNodes:[],compatMode:e.compatMode}:{type:q.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:q.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:w};case e.ELEMENT_NODE:return Jo(e,{doc:r,blockClass:i,blockSelector:s,inlineStylesheet:a,maskInputOptions:c,maskInputFn:f,dataURLOptions:h,inlineImages:g,recordCanvas:I,keepIframeSrcFn:k,newlyAddedElement:m,rootId:w});case e.TEXT_NODE:return qo(e,{maskTextClass:o,maskTextSelector:l,maskTextFn:p,rootId:w});case e.CDATA_SECTION_NODE:return{type:q.CDATA,textContent:"",rootId:w};case e.COMMENT_NODE:return{type:q.Comment,textContent:e.textContent||"",rootId:w};default:return!1}}function $o(e,t){if(t.hasNode(e)){var r=t.getId(e);return r===1?void 0:r}}function qo(e,t){var r,n=t.maskTextClass,i=t.maskTextSelector,s=t.maskTextFn,o=t.rootId,l=e.parentNode&&e.parentNode.tagName,a=e.textContent,d=l==="STYLE"?!0:void 0,c=l==="SCRIPT"?!0:void 0;if(d&&a){try{e.nextSibling||e.previousSibling||!((r=e.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(a=Pt(e.parentNode.sheet))}catch(p){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(p),e)}a=Bt(a,Yr())}return c&&(a="SCRIPT_PLACEHOLDER"),!d&&!c&&a&&bi(e,n,i)&&(a=s?s(a):a.replace(/[\S]/g,"*")),{type:q.Text,textContent:a||"",isStyle:d,rootId:o}}function Jo(e,t){for(var r=t.doc,n=t.blockClass,i=t.blockSelector,s=t.inlineStylesheet,o=t.maskInputOptions,l=o===void 0?{}:o,a=t.maskInputFn,d=t.dataURLOptions,c=d===void 0?{}:d,p=t.inlineImages,f=t.recordCanvas,u=t.keepIframeSrcFn,h=t.newlyAddedElement,g=h===void 0?!1:h,I=t.rootId,k=jo(e,n,i),y=Mo(e),m={},w=e.attributes.length,R=0;R<w;R++){var T=e.attributes[R];vi(y,T.name,T.value)||(m[T.name]=Ii(r,y,je(T.name),T.value))}if(y==="link"&&s){var A=Array.from(r.styleSheets).find(function(se){return se.href===e.href}),S=null;A&&(S=Pt(A)),S&&(delete m.rel,delete m.href,m._cssText=Bt(S,A.href))}if(y==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var S=Pt(e.sheet);S&&(m._cssText=Bt(S,Yr()))}if(y==="input"||y==="textarea"||y==="select"){var z=e.value,D=e.checked;if(m.type!=="radio"&&m.type!=="checkbox"&&m.type!=="submit"&&m.type!=="button"&&z){var H=Zr(e);m.value=Kr({element:e,type:H,tagName:y,value:z,maskInputOptions:l,maskInputFn:a})}else D&&(m.checked=D)}if(y==="option"&&(e.selected&&!l.select?m.selected=!0:delete m.selected),y==="canvas"&&f){if(e.__context==="2d")Oo(e)||(m.rr_dataURL=e.toDataURL(c.type,c.quality));else if(!("__context"in e)){var G=e.toDataURL(c.type,c.quality),Q=document.createElement("canvas");Q.width=e.width,Q.height=e.height;var pe=Q.toDataURL(c.type,c.quality);G!==pe&&(m.rr_dataURL=G)}}if(y==="img"&&p){Je||(Je=r.createElement("canvas"),fn=Je.getContext("2d"));var b=e,B=b.crossOrigin;b.crossOrigin="anonymous";var Z=function(){b.removeEventListener("load",Z);try{Je.width=b.naturalWidth,Je.height=b.naturalHeight,fn.drawImage(b,0,0),m.rr_dataURL=Je.toDataURL(c.type,c.quality)}catch(se){console.warn("Cannot inline img src=".concat(b.currentSrc,"! Error: ").concat(se))}B?m.crossOrigin=B:b.removeAttribute("crossorigin")};b.complete&&b.naturalWidth!==0?Z():b.addEventListener("load",Z)}if((y==="audio"||y==="video")&&(m.rr_mediaState=e.paused?"paused":"played",m.rr_mediaCurrentTime=e.currentTime),g||(e.scrollLeft&&(m.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(m.rr_scrollTop=e.scrollTop)),k){var ce=e.getBoundingClientRect(),ne=ce.width,ie=ce.height;m={class:m.class,rr_width:"".concat(ne,"px"),rr_height:"".concat(ie,"px")}}return y==="iframe"&&!u(m.src)&&(e.contentDocument||(m.rr_src=m.src),delete m.src),{type:q.Element,tagName:y,attributes:m,childNodes:[],isSVG:Go(e)||void 0,needBlock:k,rootId:I}}function P(e){return e==null?"":e.toLowerCase()}function Qo(e,t){if(t.comment&&e.type===q.Comment)return!0;if(e.type===q.Element){if(t.script&&(e.tagName==="script"||e.tagName==="link"&&(e.attributes.rel==="preload"||e.attributes.rel==="modulepreload")&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(P(e.attributes.name).match(/^msapplication-tile(image|color)$/)||P(e.attributes.name)==="application-name"||P(e.attributes.rel)==="icon"||P(e.attributes.rel)==="apple-touch-icon"||P(e.attributes.rel)==="shortcut icon")))return!0;if(e.tagName==="meta"){if(t.headMetaDescKeywords&&P(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(P(e.attributes.property).match(/^(og|twitter|fb):/)||P(e.attributes.name).match(/^(og|twitter):/)||P(e.attributes.name)==="pinterest"))return!0;if(t.headMetaRobots&&(P(e.attributes.name)==="robots"||P(e.attributes.name)==="googlebot"||P(e.attributes.name)==="bingbot"))return!0;if(t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0)return!0;if(t.headMetaAuthorship&&(P(e.attributes.name)==="author"||P(e.attributes.name)==="generator"||P(e.attributes.name)==="framework"||P(e.attributes.name)==="publisher"||P(e.attributes.name)==="progid"||P(e.attributes.property).match(/^article:/)||P(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&(P(e.attributes.name)==="google-site-verification"||P(e.attributes.name)==="yandex-verification"||P(e.attributes.name)==="csrf-token"||P(e.attributes.name)==="p:domain_verify"||P(e.attributes.name)==="verify-v1"||P(e.attributes.name)==="verification"||P(e.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function et(e,t){var r=t.doc,n=t.mirror,i=t.blockClass,s=t.blockSelector,o=t.maskTextClass,l=t.maskTextSelector,a=t.skipChild,d=a===void 0?!1:a,c=t.inlineStylesheet,p=c===void 0?!0:c,f=t.maskInputOptions,u=f===void 0?{}:f,h=t.maskTextFn,g=t.maskInputFn,I=t.slimDOMOptions,k=t.dataURLOptions,y=k===void 0?{}:k,m=t.inlineImages,w=m===void 0?!1:m,R=t.recordCanvas,T=R===void 0?!1:R,A=t.onSerialize,S=t.onIframeLoad,z=t.iframeLoadTimeout,D=z===void 0?5e3:z,H=t.onStylesheetLoad,G=t.stylesheetLoadTimeout,Q=G===void 0?5e3:G,pe=t.keepIframeSrcFn,b=pe===void 0?function(){return!1}:pe,B=t.newlyAddedElement,Z=B===void 0?!1:B,ce=t.preserveWhiteSpace,ne=ce===void 0?!0:ce,ie=Yo(e,{doc:r,mirror:n,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:g,dataURLOptions:y,inlineImages:w,recordCanvas:T,keepIframeSrcFn:b,newlyAddedElement:Z});if(!ie)return console.warn(e,"not serialized"),null;var se;n.hasNode(e)?se=n.getId(e):Qo(ie,I)||!ne&&ie.type===q.Text&&!ie.isStyle&&!ie.textContent.replace(/^\s+|\s+$/gm,"").length?se=gt:se=wi();var F=Object.assign(ie,{id:se});if(n.add(e,F),se===gt)return null;A&&A(e);var M=!d;if(F.type===q.Element){M=M&&!F.needBlock,delete F.needBlock;var Ee=e.shadowRoot;Ee&&ut(Ee)&&(F.isShadowHost=!0)}if((F.type===q.Document||F.type===q.Element)&&M){I.headWhitespace&&F.type===q.Element&&F.tagName==="head"&&(ne=!1);for(var $e={doc:r,mirror:n,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:d,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:g,slimDOMOptions:I,dataURLOptions:y,inlineImages:w,recordCanvas:T,preserveWhiteSpace:ne,onSerialize:A,onIframeLoad:S,iframeLoadTimeout:D,onStylesheetLoad:H,stylesheetLoadTimeout:Q,keepIframeSrcFn:b},he=0,be=Array.from(e.childNodes);he<be.length;he++){var Be=be[he],me=et(Be,$e);me&&F.childNodes.push(me)}if(Eo(e)&&e.shadowRoot)for(var C=0,de=Array.from(e.shadowRoot.childNodes);C<de.length;C++){var Be=de[C],me=et(Be,$e);me&&(ut(e.shadowRoot)&&(me.isShadow=!0),F.childNodes.push(me))}}return e.parentNode&&dt(e.parentNode)&&ut(e.parentNode)&&(F.isShadow=!0),F.type===q.Element&&F.tagName==="iframe"&&Ko(e,function(){var x=e.contentDocument;if(x&&S){var X=et(x,{doc:x,mirror:n,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:!1,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:g,slimDOMOptions:I,dataURLOptions:y,inlineImages:w,recordCanvas:T,preserveWhiteSpace:ne,onSerialize:A,onIframeLoad:S,iframeLoadTimeout:D,onStylesheetLoad:H,stylesheetLoadTimeout:Q,keepIframeSrcFn:b});X&&S(e,X)}},D),F.type===q.Element&&F.tagName==="link"&&F.attributes.rel==="stylesheet"&&Zo(e,function(){if(H){var x=et(e,{doc:r,mirror:n,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:!1,inlineStylesheet:p,maskInputOptions:u,maskTextFn:h,maskInputFn:g,slimDOMOptions:I,dataURLOptions:y,inlineImages:w,recordCanvas:T,preserveWhiteSpace:ne,onSerialize:A,onIframeLoad:S,iframeLoadTimeout:D,onStylesheetLoad:H,stylesheetLoadTimeout:Q,keepIframeSrcFn:b});x&&H(e,x)}},Q),F}function Xo(e,t){var r=t||{},n=r.mirror,i=n===void 0?new yi:n,s=r.blockClass,o=s===void 0?"rr-block":s,l=r.blockSelector,a=l===void 0?null:l,d=r.maskTextClass,c=d===void 0?"rr-mask":d,p=r.maskTextSelector,f=p===void 0?null:p,u=r.inlineStylesheet,h=u===void 0?!0:u,g=r.inlineImages,I=g===void 0?!1:g,k=r.recordCanvas,y=k===void 0?!1:k,m=r.maskAllInputs,w=m===void 0?!1:m,R=r.maskTextFn,T=r.maskInputFn,A=r.slimDOM,S=A===void 0?!1:A,z=r.dataURLOptions,D=r.preserveWhiteSpace,H=r.onSerialize,G=r.onIframeLoad,Q=r.iframeLoadTimeout,pe=r.onStylesheetLoad,b=r.stylesheetLoadTimeout,B=r.keepIframeSrcFn,Z=B===void 0?function(){return!1}:B,ce=w===!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}:w===!1?{password:!0}:w,ne=S===!0||S==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:S==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:S===!1?{}:S;return et(e,{doc:e,mirror:i,blockClass:o,blockSelector:a,maskTextClass:c,maskTextSelector:f,skipChild:!1,inlineStylesheet:h,maskInputOptions:ce,maskTextFn:R,maskInputFn:T,slimDOMOptions:ne,dataURLOptions:z,inlineImages:I,recordCanvas:y,preserveWhiteSpace:D,onSerialize:H,onIframeLoad:G,iframeLoadTimeout:Q,onStylesheetLoad:pe,stylesheetLoadTimeout:b,keepIframeSrcFn:Z,newlyAddedElement:!1})}function ae(e,t,r=document){const n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}const Qe=`Please stop import mirror directly. Instead of that,\r
4
+ now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
5
+ or you can use record.mirror to access the mirror instance during recording.`;let gn={map:{},getId(){return console.error(Qe),-1},getNode(){return console.error(Qe),null},removeNodeFromMap(){console.error(Qe)},has(){return console.error(Qe),!1},reset(){console.error(Qe)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(gn=new Proxy(gn,{get(e,t,r){return t==="map"&&console.error(Qe),Reflect.get(e,t,r)}}));function mt(e,t,r={}){let n=null,i=0;return function(...s){const o=Date.now();!i&&r.leading===!1&&(i=o);const l=t-(o-i),a=this;l<=0||l>t?(n&&(clearTimeout(n),n=null),i=o,e.apply(a,s)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{i=r.leading===!1?0:Date.now(),n=null,e.apply(a,s)},l))}}function ir(e,t,r,n,i=window){const s=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,n?r:{set(o){setTimeout(()=>{r.set.call(this,o)},0),s&&s.set&&s.set.call(this,o)}}),()=>ir(e,t,s||{},!0)}function St(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],i=r(n);return typeof i=="function"&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=i,()=>{e[t]=n}}catch{return()=>{}}}let Vt=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(Vt=()=>new Date().getTime());function Si(e){var t,r,n,i,s,o;const l=e.document;return{left:l.scrollingElement?l.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:(l==null?void 0:l.documentElement.scrollLeft)||((r=(t=l==null?void 0:l.body)===null||t===void 0?void 0:t.parentElement)===null||r===void 0?void 0:r.scrollLeft)||((n=l==null?void 0:l.body)===null||n===void 0?void 0:n.scrollLeft)||0,top:l.scrollingElement?l.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:(l==null?void 0:l.documentElement.scrollTop)||((s=(i=l==null?void 0:l.body)===null||i===void 0?void 0:i.parentElement)===null||s===void 0?void 0:s.scrollTop)||((o=l==null?void 0:l.body)===null||o===void 0?void 0:o.scrollTop)||0}}function Ci(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ki(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function le(e,t,r,n){if(!e)return!1;const i=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!i)return!1;try{if(typeof t=="string"){if(i.classList.contains(t)||n&&i.closest("."+t)!==null)return!0}else if(Wt(i,t,n))return!0}catch{}return!!(r&&(i.matches(r)||n&&i.closest(r)!==null))}function ea(e,t){return t.getId(e)!==-1}function gr(e,t){return t.getId(e)===gt}function Ai(e,t){if(dt(e))return!1;const r=t.getId(e);return t.has(r)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Ai(e.parentNode,t):!0:!0}function Ar(e){return!!e.changedTouches}function ta(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let r=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function Ei(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Li(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Er(e){return!!(e!=null&&e.shadowRoot)}class ra{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var r;return(r=this.styleIDMap.get(t))!==null&&r!==void 0?r:-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Ri(e){var t,r;let n=null;return((r=(t=e.getRootNode)===null||t===void 0?void 0:t.call(e))===null||r===void 0?void 0:r.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(n=e.getRootNode().host),n}function na(e){let t=e,r;for(;r=Ri(t);)t=r;return t}function ia(e){const t=e.ownerDocument;if(!t)return!1;const r=na(e);return t.contains(r)}function Ti(e){const t=e.ownerDocument;return t?t.contains(e)||ia(e):!1}var _=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(_||{}),O=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(O||{}),ue=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ue||{}),Le=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Le||{}),nt=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(nt||{});function mn(e){return"__ln"in e}class sa{constructor(){this.length=0,this.head=null,this.tail=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let n=0;n<t;n++)r=(r==null?void 0:r.next)||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&mn(t.previousSibling)){const n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&mn(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){const r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const yn=(e,t)=>`${e}@${t}`;class oa{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],r=new Set,n=new sa,i=a=>{let d=a,c=gt;for(;c===gt;)d=d&&d.nextSibling,c=d&&this.mirror.getId(d);return c},s=a=>{if(!a.parentNode||!Ti(a))return;const d=dt(a.parentNode)?this.mirror.getId(Ri(a)):this.mirror.getId(a.parentNode),c=i(a);if(d===-1||c===-1)return n.addNode(a);const p=et(a,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:f=>{Ei(f,this.mirror)&&this.iframeManager.addIframe(f),Li(f,this.mirror)&&this.stylesheetManager.trackLinkElement(f),Er(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,this.doc)},onIframeLoad:(f,u)=>{this.iframeManager.attachIframe(f,u),this.shadowDomManager.observeAttachShadow(f)},onStylesheetLoad:(f,u)=>{this.stylesheetManager.attachLinkElement(f,u)}});p&&(t.push({parentId:d,nextId:c,node:p}),r.add(p.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)wn(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||s(a);for(const a of this.addedSet)!In(this.droppedSet,a)&&!wn(this.removes,a,this.mirror)||In(this.movedSet,a)?s(a):this.droppedSet.add(a);let o=null;for(;n.length;){let a=null;if(o){const d=this.mirror.getId(o.value.parentNode),c=i(o.value);d!==-1&&c!==-1&&(a=o)}if(!a){let d=n.tail;for(;d;){const c=d;if(d=d.previous,c){const p=this.mirror.getId(c.value.parentNode);if(i(c.value)===-1)continue;if(p!==-1){a=c;break}else{const u=c.value;if(u.parentNode&&u.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const h=u.parentNode.host;if(this.mirror.getId(h)!==-1){a=c;break}}}}}}if(!a){for(;n.head;)n.removeNode(n.head.value);break}o=a.previous,n.removeNode(a.value),s(a.value)}const l={texts:this.texts.map(a=>({id:this.mirror.getId(a.node),value:a.value})).filter(a=>!r.has(a.id)).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>{const{attributes:d}=a;if(typeof d.style=="string"){const c=JSON.stringify(a.styleDiff),p=JSON.stringify(a._unchangedStyles);c.length<d.style.length&&(c+p).split("var(").length===d.style.split("var(").length&&(d.style=a.styleDiff)}return{id:this.mirror.getId(a.node),attributes:d}}).filter(a=>!r.has(a.id)).filter(a=>this.mirror.has(a.id)),removes:this.removes,adds:t};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(l))},this.processMutation=t=>{if(gr(t.target,this.mirror))return;let r;try{r=document.implementation.createHTMLDocument()}catch{r=this.doc}switch(t.type){case"characterData":{const n=t.target.textContent;!le(t.target,this.blockClass,this.blockSelector,!1)&&n!==t.oldValue&&this.texts.push({value:bi(t.target,this.maskTextClass,this.maskTextSelector)&&n?this.maskTextFn?this.maskTextFn(n):n.replace(/[\S]/g,"*"):n,node:t.target});break}case"attributes":{const n=t.target;let i=t.attributeName,s=t.target.getAttribute(i);if(i==="value"){const l=Zr(n);s=Kr({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:l,value:s,maskInputFn:this.maskInputFn})}if(le(t.target,this.blockClass,this.blockSelector,!1)||s===t.oldValue)return;let o=this.attributes.find(l=>l.node===t.target);if(n.tagName==="IFRAME"&&i==="src"&&!this.keepIframeSrcFn(s))if(!n.contentDocument)i="rr_src";else return;if(o||(o={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o)),i==="type"&&n.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&n.setAttribute("data-rr-is-password","true"),!vi(n.tagName,i)&&(o.attributes[i]=Ii(this.doc,je(n.tagName),je(i),s),i==="style")){const l=r.createElement("span");t.oldValue&&l.setAttribute("style",t.oldValue);for(const a of Array.from(n.style)){const d=n.style.getPropertyValue(a),c=n.style.getPropertyPriority(a);d!==l.style.getPropertyValue(a)||c!==l.style.getPropertyPriority(a)?c===""?o.styleDiff[a]=d:o.styleDiff[a]=[d,c]:o._unchangedStyles[a]=[d,c]}for(const a of Array.from(l.style))n.style.getPropertyValue(a)===""&&(o.styleDiff[a]=!1)}break}case"childList":{if(le(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(n=>this.genAdds(n,t.target)),t.removedNodes.forEach(n=>{const i=this.mirror.getId(n),s=dt(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);le(t.target,this.blockClass,this.blockSelector,!1)||gr(n,this.mirror)||!ea(n,this.mirror)||(this.addedSet.has(n)?(Lr(this.addedSet,n),this.droppedSet.add(n)):this.addedSet.has(t.target)&&i===-1||Ai(t.target,this.mirror)||(this.movedSet.has(n)&&this.movedMap[yn(i,s)]?Lr(this.movedSet,n):this.removes.push({parentId:s,id:i,isShadow:dt(t.target)&&ut(t.target)?!0:void 0})),this.mapRemoves.push(n))});break}}},this.genAdds=(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!(this.addedSet.has(t)||this.movedSet.has(t))){if(this.mirror.hasNode(t)){if(gr(t,this.mirror))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[yn(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);le(t,this.blockClass,this.blockSelector,!1)||(t.childNodes.forEach(n=>this.genAdds(n)),Er(t)&&t.shadowRoot.childNodes.forEach(n=>{this.processedNodeManager.add(n,this),this.genAdds(n,t)}))}}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Lr(e,t){e.delete(t),t.childNodes.forEach(r=>Lr(e,r))}function wn(e,t,r){return e.length===0?!1:Ui(e,t,r)}function Ui(e,t,r){const{parentNode:n}=t;if(!n)return!1;const i=r.getId(n);return e.some(s=>s.id===i)?!0:Ui(e,n,r)}function In(e,t){return e.size===0?!1:_i(e,t)}function _i(e,t){const{parentNode:r}=t;return r?e.has(r)?!0:_i(e,r):!1}let pt;function aa(e){pt=e}function la(){pt=void 0}const U=e=>pt?(...r)=>{try{return e(...r)}catch(n){if(pt&&pt(n)===!0)return;throw n}}:e,Ge=[];function Ct(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function Oi(e,t){var r,n;const i=new oa;Ge.push(i),i.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const o=(n=(r=window==null?void 0:window.Zone)===null||r===void 0?void 0:r.__symbol__)===null||n===void 0?void 0:n.call(r,"MutationObserver");o&&window[o]&&(s=window[o]);const l=new s(U(i.processMutations.bind(i)));return l.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l}function ca({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===!1)return()=>{};const i=typeof t.mousemove=="number"?t.mousemove:50,s=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let o=[],l;const a=mt(U(p=>{const f=Date.now()-l;e(o.map(u=>(u.timeOffset-=f,u)),p),o=[],l=null}),s),d=U(mt(U(p=>{const f=Ct(p),{clientX:u,clientY:h}=Ar(p)?p.changedTouches[0]:p;l||(l=Vt()),o.push({x:u,y:h,id:n.getId(f),timeOffset:Vt()-l}),a(typeof DragEvent<"u"&&p instanceof DragEvent?O.Drag:p instanceof MouseEvent?O.MouseMove:O.TouchMove)}),i,{trailing:!1})),c=[ae("mousemove",d,r),ae("touchmove",d,r),ae("drag",d,r)];return U(()=>{c.forEach(p=>p())})}function da({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:i,sampling:s}){if(s.mouseInteraction===!1)return()=>{};const o=s.mouseInteraction===!0||s.mouseInteraction===void 0?{}:s.mouseInteraction,l=[];let a=null;const d=c=>p=>{const f=Ct(p);if(le(f,n,i,!0))return;let u=null,h=c;if("pointerType"in p){switch(p.pointerType){case"mouse":u=Le.Mouse;break;case"touch":u=Le.Touch;break;case"pen":u=Le.Pen;break}u===Le.Touch?ue[c]===ue.MouseDown?h="TouchStart":ue[c]===ue.MouseUp&&(h="TouchEnd"):Le.Pen}else Ar(p)&&(u=Le.Touch);u!==null?(a=u,(h.startsWith("Touch")&&u===Le.Touch||h.startsWith("Mouse")&&u===Le.Mouse)&&(u=null)):ue[c]===ue.Click&&(u=a,a=null);const g=Ar(p)?p.changedTouches[0]:p;if(!g)return;const I=r.getId(f),{clientX:k,clientY:y}=g;U(e)(Object.assign({type:ue[h],id:I,x:k,y},u!==null&&{pointerType:u}))};return Object.keys(ue).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&o[c]!==!1).forEach(c=>{let p=je(c);const f=d(c);if(window.PointerEvent)switch(ue[c]){case ue.MouseDown:case ue.MouseUp:p=p.replace("mouse","pointer");break;case ue.TouchStart:case ue.TouchEnd:return}l.push(ae(p,f,t))}),U(()=>{l.forEach(c=>c())})}function Di({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:i,sampling:s}){const o=U(mt(U(l=>{const a=Ct(l);if(!a||le(a,n,i,!0))return;const d=r.getId(a);if(a===t&&t.defaultView){const c=Si(t.defaultView);e({id:d,x:c.left,y:c.top})}else e({id:d,x:a.scrollLeft,y:a.scrollTop})}),s.scroll||100));return ae("scroll",o,t)}function ua({viewportResizeCb:e},{win:t}){let r=-1,n=-1;const i=U(mt(U(()=>{const s=Ci(),o=ki();(r!==s||n!==o)&&(e({width:Number(o),height:Number(s)}),r=s,n=o)}),200));return ae("resize",i,t)}function vn(e,t){const r=Object.assign({},e);return t||delete r.userTriggered,r}const pa=["INPUT","TEXTAREA","SELECT"],bn=new WeakMap;function ha({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:i,ignoreClass:s,ignoreSelector:o,maskInputOptions:l,maskInputFn:a,sampling:d,userTriggeredOnInput:c}){function p(y){let m=Ct(y);const w=y.isTrusted,R=m&&m.tagName;if(m&&R==="OPTION"&&(m=m.parentElement),!m||!R||pa.indexOf(R)<0||le(m,n,i,!0)||m.classList.contains(s)||o&&m.matches(o))return;let T=m.value,A=!1;const S=Zr(m)||"";S==="radio"||S==="checkbox"?A=m.checked:(l[R.toLowerCase()]||l[S])&&(T=Kr({element:m,maskInputOptions:l,tagName:R,type:S,value:T,maskInputFn:a})),f(m,U(vn)({text:T,isChecked:A,userTriggered:w},c));const z=m.name;S==="radio"&&z&&A&&t.querySelectorAll(`input[type="radio"][name="${z}"]`).forEach(D=>{D!==m&&f(D,U(vn)({text:D.value,isChecked:!A,userTriggered:!1},c))})}function f(y,m){const w=bn.get(y);if(!w||w.text!==m.text||w.isChecked!==m.isChecked){bn.set(y,m);const R=r.getId(y);U(e)(Object.assign(Object.assign({},m),{id:R}))}}const h=(d.input==="last"?["change"]:["input","change"]).map(y=>ae(y,U(p),t)),g=t.defaultView;if(!g)return()=>{h.forEach(y=>y())};const I=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),k=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return I&&I.set&&h.push(...k.map(y=>ir(y[0],y[1],{set(){U(p)({target:this,isTrusted:!1})}},!1,g))),U(()=>{h.forEach(y=>y())})}function zt(e){const t=[];function r(n,i){if(Et("CSSGroupingRule")&&n.parentRule instanceof CSSGroupingRule||Et("CSSMediaRule")&&n.parentRule instanceof CSSMediaRule||Et("CSSSupportsRule")&&n.parentRule instanceof CSSSupportsRule||Et("CSSConditionRule")&&n.parentRule instanceof CSSConditionRule){const o=Array.from(n.parentRule.cssRules).indexOf(n);i.unshift(o)}else if(n.parentStyleSheet){const o=Array.from(n.parentStyleSheet.cssRules).indexOf(n);i.unshift(o)}return i}return r(e,t)}function Oe(e,t,r){let n,i;return e?(e.ownerNode?n=t.getId(e.ownerNode):i=r.getId(e),{styleId:i,id:n}):{}}function fa({styleSheetRuleCb:e,mirror:t,stylesheetManager:r},{win:n}){if(!n.CSSStyleSheet||!n.CSSStyleSheet.prototype)return()=>{};const i=n.CSSStyleSheet.prototype.insertRule;n.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:U((c,p,f)=>{const[u,h]=f,{id:g,styleId:I}=Oe(p,t,r.styleMirror);return(g&&g!==-1||I&&I!==-1)&&e({id:g,styleId:I,adds:[{rule:u,index:h}]}),c.apply(p,f)})});const s=n.CSSStyleSheet.prototype.deleteRule;n.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:U((c,p,f)=>{const[u]=f,{id:h,styleId:g}=Oe(p,t,r.styleMirror);return(h&&h!==-1||g&&g!==-1)&&e({id:h,styleId:g,removes:[{index:u}]}),c.apply(p,f)})});let o;n.CSSStyleSheet.prototype.replace&&(o=n.CSSStyleSheet.prototype.replace,n.CSSStyleSheet.prototype.replace=new Proxy(o,{apply:U((c,p,f)=>{const[u]=f,{id:h,styleId:g}=Oe(p,t,r.styleMirror);return(h&&h!==-1||g&&g!==-1)&&e({id:h,styleId:g,replace:u}),c.apply(p,f)})}));let l;n.CSSStyleSheet.prototype.replaceSync&&(l=n.CSSStyleSheet.prototype.replaceSync,n.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:U((c,p,f)=>{const[u]=f,{id:h,styleId:g}=Oe(p,t,r.styleMirror);return(h&&h!==-1||g&&g!==-1)&&e({id:h,styleId:g,replaceSync:u}),c.apply(p,f)})}));const a={};Lt("CSSGroupingRule")?a.CSSGroupingRule=n.CSSGroupingRule:(Lt("CSSMediaRule")&&(a.CSSMediaRule=n.CSSMediaRule),Lt("CSSConditionRule")&&(a.CSSConditionRule=n.CSSConditionRule),Lt("CSSSupportsRule")&&(a.CSSSupportsRule=n.CSSSupportsRule));const d={};return Object.entries(a).forEach(([c,p])=>{d[c]={insertRule:p.prototype.insertRule,deleteRule:p.prototype.deleteRule},p.prototype.insertRule=new Proxy(d[c].insertRule,{apply:U((f,u,h)=>{const[g,I]=h,{id:k,styleId:y}=Oe(u.parentStyleSheet,t,r.styleMirror);return(k&&k!==-1||y&&y!==-1)&&e({id:k,styleId:y,adds:[{rule:g,index:[...zt(u),I||0]}]}),f.apply(u,h)})}),p.prototype.deleteRule=new Proxy(d[c].deleteRule,{apply:U((f,u,h)=>{const[g]=h,{id:I,styleId:k}=Oe(u.parentStyleSheet,t,r.styleMirror);return(I&&I!==-1||k&&k!==-1)&&e({id:I,styleId:k,removes:[{index:[...zt(u),g]}]}),f.apply(u,h)})})}),U(()=>{n.CSSStyleSheet.prototype.insertRule=i,n.CSSStyleSheet.prototype.deleteRule=s,o&&(n.CSSStyleSheet.prototype.replace=o),l&&(n.CSSStyleSheet.prototype.replaceSync=l),Object.entries(a).forEach(([c,p])=>{p.prototype.insertRule=d[c].insertRule,p.prototype.deleteRule=d[c].deleteRule})})}function xi({mirror:e,stylesheetManager:t},r){var n,i,s;let o=null;r.nodeName==="#document"?o=e.getId(r):o=e.getId(r.host);const l=r.nodeName==="#document"?(n=r.defaultView)===null||n===void 0?void 0:n.Document:(s=(i=r.ownerDocument)===null||i===void 0?void 0:i.defaultView)===null||s===void 0?void 0:s.ShadowRoot,a=Object.getOwnPropertyDescriptor(l==null?void 0:l.prototype,"adoptedStyleSheets");return o===null||o===-1||!l||!a?()=>{}:(Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var d;return(d=a.get)===null||d===void 0?void 0:d.call(this)},set(d){var c;const p=(c=a.set)===null||c===void 0?void 0:c.call(this,d);if(o!==null&&o!==-1)try{t.adoptStyleSheets(d,o)}catch{}return p}}),U(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})}))}function ga({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:r,stylesheetManager:n},{win:i}){const s=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:U((l,a,d)=>{var c;const[p,f,u]=d;if(r.has(p))return s.apply(a,[p,f,u]);const{id:h,styleId:g}=Oe((c=a.parentRule)===null||c===void 0?void 0:c.parentStyleSheet,t,n.styleMirror);return(h&&h!==-1||g&&g!==-1)&&e({id:h,styleId:g,set:{property:p,value:f,priority:u},index:zt(a.parentRule)}),l.apply(a,d)})});const o=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(o,{apply:U((l,a,d)=>{var c;const[p]=d;if(r.has(p))return o.apply(a,[p]);const{id:f,styleId:u}=Oe((c=a.parentRule)===null||c===void 0?void 0:c.parentStyleSheet,t,n.styleMirror);return(f&&f!==-1||u&&u!==-1)&&e({id:f,styleId:u,remove:{property:p},index:zt(a.parentRule)}),l.apply(a,d)})}),U(()=>{i.CSSStyleDeclaration.prototype.setProperty=s,i.CSSStyleDeclaration.prototype.removeProperty=o})}function ma({mediaInteractionCb:e,blockClass:t,blockSelector:r,mirror:n,sampling:i,doc:s}){const o=U(a=>mt(U(d=>{const c=Ct(d);if(!c||le(c,t,r,!0))return;const{currentTime:p,volume:f,muted:u,playbackRate:h}=c;e({type:a,id:n.getId(c),currentTime:p,volume:f,muted:u,playbackRate:h})}),i.media||500)),l=[ae("play",o(0),s),ae("pause",o(1),s),ae("seeked",o(2),s),ae("volumechange",o(3),s),ae("ratechange",o(4),s)];return U(()=>{l.forEach(a=>a())})}function ya({fontCb:e,doc:t}){const r=t.defaultView;if(!r)return()=>{};const n=[],i=new WeakMap,s=r.FontFace;r.FontFace=function(a,d,c){const p=new s(a,d,c);return i.set(p,{family:a,buffer:typeof d!="string",descriptors:c,fontSource:typeof d=="string"?d:JSON.stringify(Array.from(new Uint8Array(d)))}),p};const o=St(t.fonts,"add",function(l){return function(a){return setTimeout(U(()=>{const d=i.get(a);d&&(e(d),i.delete(a))}),0),l.apply(this,[a])}});return n.push(()=>{r.FontFace=s}),n.push(o),U(()=>{n.forEach(l=>l())})}function wa(e){const{doc:t,mirror:r,blockClass:n,blockSelector:i,selectionCb:s}=e;let o=!0;const l=U(()=>{const a=t.getSelection();if(!a||o&&(a!=null&&a.isCollapsed))return;o=a.isCollapsed||!1;const d=[],c=a.rangeCount||0;for(let p=0;p<c;p++){const f=a.getRangeAt(p),{startContainer:u,startOffset:h,endContainer:g,endOffset:I}=f;le(u,n,i,!0)||le(g,n,i,!0)||d.push({start:r.getId(u),startOffset:h,end:r.getId(g),endOffset:I})}s({ranges:d})});return l(),ae("selectionchange",l)}function Ia(e,t){const{mutationCb:r,mousemoveCb:n,mouseInteractionCb:i,scrollCb:s,viewportResizeCb:o,inputCb:l,mediaInteractionCb:a,styleSheetRuleCb:d,styleDeclarationCb:c,canvasMutationCb:p,fontCb:f,selectionCb:u}=e;e.mutationCb=(...h)=>{t.mutation&&t.mutation(...h),r(...h)},e.mousemoveCb=(...h)=>{t.mousemove&&t.mousemove(...h),n(...h)},e.mouseInteractionCb=(...h)=>{t.mouseInteraction&&t.mouseInteraction(...h),i(...h)},e.scrollCb=(...h)=>{t.scroll&&t.scroll(...h),s(...h)},e.viewportResizeCb=(...h)=>{t.viewportResize&&t.viewportResize(...h),o(...h)},e.inputCb=(...h)=>{t.input&&t.input(...h),l(...h)},e.mediaInteractionCb=(...h)=>{t.mediaInteaction&&t.mediaInteaction(...h),a(...h)},e.styleSheetRuleCb=(...h)=>{t.styleSheetRule&&t.styleSheetRule(...h),d(...h)},e.styleDeclarationCb=(...h)=>{t.styleDeclaration&&t.styleDeclaration(...h),c(...h)},e.canvasMutationCb=(...h)=>{t.canvasMutation&&t.canvasMutation(...h),p(...h)},e.fontCb=(...h)=>{t.font&&t.font(...h),f(...h)},e.selectionCb=(...h)=>{t.selection&&t.selection(...h),u(...h)}}function va(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};Ia(e,t);const n=Oi(e,e.doc),i=ca(e),s=da(e),o=Di(e),l=ua(e,{win:r}),a=ha(e),d=ma(e),c=fa(e,{win:r}),p=xi(e,e.doc),f=ga(e,{win:r}),u=e.collectFonts?ya(e):()=>{},h=wa(e),g=[];for(const I of e.plugins)g.push(I.observer(I.callback,r,I.options));return U(()=>{Ge.forEach(I=>I.reset()),n.disconnect(),i(),s(),o(),l(),a(),d(),c(),p(),f(),u(),h(),g.forEach(I=>I())})}function Et(e){return typeof window[e]<"u"}function Lt(e){return!!(typeof window[e]<"u"&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class Sn{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,r,n,i){const s=n||this.getIdToRemoteIdMap(t),o=i||this.getRemoteIdToIdMap(t);let l=s.get(r);return l||(l=this.generateIdFn(),s.set(r,l),o.set(l,r)),l}getIds(t,r){const n=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return r.map(s=>this.getId(t,s,n,i))}getRemoteId(t,r,n){const i=n||this.getRemoteIdToIdMap(t);if(typeof r!="number")return r;const s=i.get(r);return s||-1}getRemoteIds(t,r){const n=this.getRemoteIdToIdMap(t);return r.map(i=>this.getRemoteId(t,i,n))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class ba{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Sn(wi),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Sn(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(n=this.loadListener)===null||n===void 0||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){const r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;const i=this.crossOriginIframeMap.get(t.source);if(!i)return;const s=this.transformCrossOriginEvent(i,r.data.event);s&&this.wrappedEmit(s,r.data.isCheckout)}transformCrossOriginEvent(t,r){var n;switch(r.type){case _.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);const i=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,i),this.patchRootIdOnNode(r.data.node,i),{timestamp:r.timestamp,type:_.IncrementalSnapshot,data:{source:O.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case _.Meta:case _.Load:case _.DomContentLoaded:return!1;case _.Plugin:return r;case _.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case _.IncrementalSnapshot:switch(r.data.source){case O.Mutation:return r.data.adds.forEach(i=>{this.replaceIds(i,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(i.node,t);const s=this.crossOriginIframeRootIdMap.get(t);s&&this.patchRootIdOnNode(i.node,s)}),r.data.removes.forEach(i=>{this.replaceIds(i,t,["parentId","id"])}),r.data.attributes.forEach(i=>{this.replaceIds(i,t,["id"])}),r.data.texts.forEach(i=>{this.replaceIds(i,t,["id"])}),r;case O.Drag:case O.TouchMove:case O.MouseMove:return r.data.positions.forEach(i=>{this.replaceIds(i,t,["id"])}),r;case O.ViewportResize:return!1;case O.MediaInteraction:case O.MouseInteraction:case O.Scroll:case O.CanvasMutation:case O.Input:return this.replaceIds(r.data,t,["id"]),r;case O.StyleSheetRule:case O.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case O.Font:return r;case O.Selection:return r.data.ranges.forEach(i=>{this.replaceIds(i,t,["start","end"])}),r;case O.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(n=r.data.styles)===null||n===void 0||n.forEach(i=>{this.replaceStyleIds(i,t,["styleId"])}),r}}}replace(t,r,n,i){for(const s of i)!Array.isArray(r[s])&&typeof r[s]!="number"||(Array.isArray(r[s])?r[s]=t.getIds(n,r[s]):r[s]=t.getId(n,r[s]));return r}replaceIds(t,r,n){return this.replace(this.crossOriginIframeMirror,t,r,n)}replaceStyleIds(t,r,n){return this.replace(this.crossOriginIframeStyleMirror,t,r,n)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(n=>{this.replaceIdOnNode(n,r)})}patchRootIdOnNode(t,r){t.type!==q.Document&&!t.rootId&&(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(n=>{this.patchRootIdOnNode(n,r)})}}class Sa{constructor(t){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,r){if(!ut(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const n=Oi(Object.assign(Object.assign({},this.bypassOptions),{doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t);this.restoreHandlers.push(()=>n.disconnect()),this.restoreHandlers.push(Di(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror}))),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),this.restoreHandlers.push(xi({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){!t.contentWindow||!t.contentDocument||this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,r){const n=this;this.restoreHandlers.push(St(t.prototype,"attachShadow",function(i){return function(s){const o=i.call(this,s);return this.shadowRoot&&Ti(this)&&n.addShadowRoot(this.shadowRoot,r),o}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}/*! *****************************************************************************
6
+ Copyright (c) Microsoft Corporation.
7
+
8
+ Permission to use, copy, modify, and/or distribute this software for any
9
+ purpose with or without fee is hereby granted.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17
+ PERFORMANCE OF THIS SOFTWARE.
18
+ ***************************************************************************** */function Ca(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function ka(e,t,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s)})}return new(r||(r=Promise))(function(s,o){function l(c){try{d(n.next(c))}catch(p){o(p)}}function a(c){try{d(n.throw(c))}catch(p){o(p)}}function d(c){c.done?s(c.value):i(c.value).then(l,a)}d((n=n.apply(e,[])).next())})}var tt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Aa=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(var Rt=0;Rt<tt.length;Rt++)Aa[tt.charCodeAt(Rt)]=Rt;var Ea=function(e){var t=new Uint8Array(e),r,n=t.length,i="";for(r=0;r<n;r+=3)i+=tt[t[r]>>2],i+=tt[(t[r]&3)<<4|t[r+1]>>4],i+=tt[(t[r+1]&15)<<2|t[r+2]>>6],i+=tt[t[r+2]&63];return n%3===2?i=i.substring(0,i.length-1)+"=":n%3===1&&(i=i.substring(0,i.length-2)+"=="),i};const Cn=new Map;function La(e,t){let r=Cn.get(e);return r||(r=new Map,Cn.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}const Mi=(e,t,r)=>{if(!e||!(Fi(e,t)||typeof e=="object"))return;const n=e.constructor.name,i=La(r,n);let s=i.indexOf(e);return s===-1&&(s=i.length,i.push(e)),s};function Ot(e,t,r){if(e instanceof Array)return e.map(n=>Ot(n,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer){const n=e.constructor.name,i=Ea(e);return{rr_type:n,base64:i}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Ot(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const n=e.constructor.name,{src:i}=e;return{rr_type:n,src:i}}else if(e instanceof HTMLCanvasElement){const n="HTMLImageElement",i=e.toDataURL();return{rr_type:n,src:i}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Ot(e.data,t,r),e.width,e.height]};if(Fi(e,t)||typeof e=="object"){const n=e.constructor.name,i=Mi(e,t,r);return{rr_type:n,index:i}}}}return e}const Ni=(e,t,r)=>[...e].map(n=>Ot(n,t,r)),Fi=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(i=>typeof t[i]=="function").find(i=>e instanceof t[i]);function Ra(e,t,r,n){const i=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of s)try{if(typeof t.CanvasRenderingContext2D.prototype[o]!="function")continue;const l=St(t.CanvasRenderingContext2D.prototype,o,function(a){return function(...d){return le(this.canvas,r,n,!0)||setTimeout(()=>{const c=Ni([...d],t,this);e(this.canvas,{type:nt["2D"],property:o,args:c})},0),a.apply(this,d)}});i.push(l)}catch{const a=ir(t.CanvasRenderingContext2D.prototype,o,{set(d){e(this.canvas,{type:nt["2D"],property:o,args:[d],setter:!0})}});i.push(a)}return()=>{i.forEach(o=>o())}}function Ta(e){return e==="experimental-webgl"?"webgl":e}function kn(e,t,r,n){const i=[];try{const s=St(e.HTMLCanvasElement.prototype,"getContext",function(o){return function(l,...a){if(!le(this,t,r,!0)){const d=Ta(l);if("__context"in this||(this.__context=d),n&&["webgl","webgl2"].includes(d))if(a[0]&&typeof a[0]=="object"){const c=a[0];c.preserveDrawingBuffer||(c.preserveDrawingBuffer=!0)}else a.splice(0,1,{preserveDrawingBuffer:!0})}return o.apply(this,[l,...a])}});i.push(s)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(s=>s())}}function An(e,t,r,n,i,s,o){const l=[],a=Object.getOwnPropertyNames(e);for(const d of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(d))try{if(typeof e[d]!="function")continue;const c=St(e,d,function(p){return function(...f){const u=p.apply(this,f);if(Mi(u,o,this),"tagName"in this.canvas&&!le(this.canvas,n,i,!0)){const h=Ni([...f],o,this),g={type:t,property:d,args:h};r(this.canvas,g)}return u}});l.push(c)}catch{const p=ir(e,d,{set(f){r(this.canvas,{type:t,property:d,args:[f],setter:!0})}});l.push(p)}return l}function Ua(e,t,r,n,i){const s=[];return s.push(...An(t.WebGLRenderingContext.prototype,nt.WebGL,e,r,n,i,t)),typeof t.WebGL2RenderingContext<"u"&&s.push(...An(t.WebGL2RenderingContext.prototype,nt.WebGL2,e,r,n,i,t)),()=>{s.forEach(o=>o())}}function _a(e,t){var r=atob(e);if(t){for(var n=new Uint8Array(r.length),i=0,s=r.length;i<s;++i)n[i]=r.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(n.buffer))}return r}function Oa(e,t,r){var n=t===void 0?null:t,i=r===void 0?!1:r,s=_a(e,i),o=s.indexOf(`
19
+ `,10)+1,l=s.substring(o)+(n?"//# sourceMappingURL="+n:""),a=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(a)}function Da(e,t,r){var n;return function(s){return n=n||Oa(e,t,r),new Worker(n,s)}}var xa=Da("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",null,!1);class Ma{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(a,d)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(a)||this.pendingCanvasMutations.set(a,[]),this.pendingCanvasMutations.get(a).push(d)};const{sampling:r="all",win:n,blockClass:i,blockSelector:s,recordCanvas:o,dataURLOptions:l}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,o&&r==="all"&&this.initCanvasMutationObserver(n,i,s),o&&typeof r=="number"&&this.initCanvasFPSObserver(r,n,i,s,{dataURLOptions:l})}initCanvasFPSObserver(t,r,n,i,s){const o=kn(r,n,i,!0),l=new Map,a=new xa;a.onmessage=h=>{const{id:g}=h.data;if(l.set(g,!1),!("base64"in h.data))return;const{base64:I,type:k,width:y,height:m}=h.data;this.mutationCb({id:g,type:nt["2D"],commands:[{property:"clearRect",args:[0,0,y,m]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:I}],type:k}]},0,0]}]})};const d=1e3/t;let c=0,p;const f=()=>{const h=[];return r.document.querySelectorAll("canvas").forEach(g=>{le(g,n,i,!0)||h.push(g)}),h},u=h=>{if(c&&h-c<d){p=requestAnimationFrame(u);return}c=h,f().forEach(g=>ka(this,void 0,void 0,function*(){var I;const k=this.mirror.getId(g);if(l.get(k))return;if(l.set(k,!0),["webgl","webgl2"].includes(g.__context)){const m=g.getContext(g.__context);((I=m==null?void 0:m.getContextAttributes())===null||I===void 0?void 0:I.preserveDrawingBuffer)===!1&&m.clear(m.COLOR_BUFFER_BIT)}const y=yield createImageBitmap(g);a.postMessage({id:k,bitmap:y,width:g.width,height:g.height,dataURLOptions:s.dataURLOptions},[y])})),p=requestAnimationFrame(u)};p=requestAnimationFrame(u),this.resetObservers=()=>{o(),cancelAnimationFrame(p)}}initCanvasMutationObserver(t,r,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=kn(t,r,n,!1),s=Ra(this.processMutation.bind(this),t,r,n),o=Ua(this.processMutation.bind(this),t,r,n,this.mirror);this.resetObservers=()=>{i(),s(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const n=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||r===-1)return;const i=n.map(o=>Ca(o,["type"])),{type:s}=n[0];this.mutationCb({id:r,type:s,commands:i}),this.pendingCanvasMutations.delete(t)}}class Na{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new ra,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const n={id:r,styleIds:[]},i=[];for(const s of t){let o;if(this.styleMirror.has(s))o=this.styleMirror.getId(s);else{o=this.styleMirror.add(s);const l=Array.from(s.rules||CSSRule);i.push({styleId:o,rules:l.map((a,d)=>({rule:mi(a),index:d}))})}n.styleIds.push(o)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Fa{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(t,r){const n=this.nodeMap.get(t);return n&&Array.from(n).some(i=>i!==r)}add(t,r){this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function $(e){return Object.assign(Object.assign({},e),{timestamp:Vt()})}let j,Dt,mr,Ht=!1;const ye=_o();function kt(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:n,blockClass:i="rr-block",blockSelector:s=null,ignoreClass:o="rr-ignore",ignoreSelector:l=null,maskTextClass:a="rr-mask",maskTextSelector:d=null,inlineStylesheet:c=!0,maskAllInputs:p,maskInputOptions:f,slimDOMOptions:u,maskInputFn:h,maskTextFn:g,hooks:I,packFn:k,sampling:y={},dataURLOptions:m={},mousemoveWait:w,recordCanvas:R=!1,recordCrossOriginIframes:T=!1,recordAfter:A=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:S=!1,collectFonts:z=!1,inlineImages:D=!1,plugins:H,keepIframeSrcFn:G=()=>!1,ignoreCSSAttributes:Q=new Set([]),errorHandler:pe}=e;aa(pe);const b=T?window.parent===window:!0;let B=!1;if(!b)try{window.parent.document&&(B=!1)}catch{B=!0}if(b&&!t)throw new Error("emit function is required");w!==void 0&&y.mousemove===void 0&&(y.mousemove=w),ye.reset();const Z=p===!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?f:{password:!0},ce=u===!0||u==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:u==="all",headMetaDescKeywords:u==="all"}:u||{};ta();let ne,ie=0;const se=C=>{for(const de of H||[])de.eventProcessor&&(C=de.eventProcessor(C));return k&&!B&&(C=k(C)),C};j=(C,de)=>{var x;if(!((x=Ge[0])===null||x===void 0)&&x.isFrozen()&&C.type!==_.FullSnapshot&&!(C.type===_.IncrementalSnapshot&&C.data.source===O.Mutation)&&Ge.forEach(X=>X.unfreeze()),b)t==null||t(se(C),de);else if(B){const X={type:"rrweb",event:se(C),origin:window.location.origin,isCheckout:de};window.parent.postMessage(X,"*")}if(C.type===_.FullSnapshot)ne=C,ie=0;else if(C.type===_.IncrementalSnapshot){if(C.data.source===O.Mutation&&C.data.isAttachIframe)return;ie++;const X=n&&ie>=n,We=r&&C.timestamp-ne.timestamp>r;(X||We)&&Dt(!0)}};const F=C=>{j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.Mutation},C)}))},M=C=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.Scroll},C)})),Ee=C=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.CanvasMutation},C)})),$e=C=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.AdoptedStyleSheet},C)})),he=new Na({mutationCb:F,adoptedStyleSheetCb:$e}),be=new ba({mirror:ye,mutationCb:F,stylesheetManager:he,recordCrossOriginIframes:T,wrappedEmit:j});for(const C of H||[])C.getMirror&&C.getMirror({nodeMirror:ye,crossOriginIframeMirror:be.crossOriginIframeMirror,crossOriginIframeStyleMirror:be.crossOriginIframeStyleMirror});const Be=new Fa;mr=new Ma({recordCanvas:R,mutationCb:Ee,win:window,blockClass:i,blockSelector:s,mirror:ye,sampling:y.canvas,dataURLOptions:m});const me=new Sa({mutationCb:F,scrollCb:M,bypassOptions:{blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:d,inlineStylesheet:c,maskInputOptions:Z,dataURLOptions:m,maskTextFn:g,maskInputFn:h,recordCanvas:R,inlineImages:D,sampling:y,slimDOMOptions:ce,iframeManager:be,stylesheetManager:he,canvasManager:mr,keepIframeSrcFn:G,processedNodeManager:Be},mirror:ye});Dt=(C=!1)=>{j($({type:_.Meta,data:{href:window.location.href,width:ki(),height:Ci()}}),C),he.reset(),me.init(),Ge.forEach(x=>x.lock());const de=Xo(document,{mirror:ye,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:d,inlineStylesheet:c,maskAllInputs:Z,maskTextFn:g,slimDOM:ce,dataURLOptions:m,recordCanvas:R,inlineImages:D,onSerialize:x=>{Ei(x,ye)&&be.addIframe(x),Li(x,ye)&&he.trackLinkElement(x),Er(x)&&me.addShadowRoot(x.shadowRoot,document)},onIframeLoad:(x,X)=>{be.attachIframe(x,X),me.observeAttachShadow(x)},onStylesheetLoad:(x,X)=>{he.attachLinkElement(x,X)},keepIframeSrcFn:G});if(!de)return console.warn("Failed to snapshot the document");j($({type:_.FullSnapshot,data:{node:de,initialOffset:Si(window)}}),C),Ge.forEach(x=>x.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&he.adoptStyleSheets(document.adoptedStyleSheets,ye.getId(document))};try{const C=[],de=X=>{var We;return U(va)({mutationCb:F,mousemoveCb:(W,dr)=>j($({type:_.IncrementalSnapshot,data:{source:dr,positions:W}})),mouseInteractionCb:W=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.MouseInteraction},W)})),scrollCb:M,viewportResizeCb:W=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.ViewportResize},W)})),inputCb:W=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.Input},W)})),mediaInteractionCb:W=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.MediaInteraction},W)})),styleSheetRuleCb:W=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.StyleSheetRule},W)})),styleDeclarationCb:W=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.StyleDeclaration},W)})),canvasMutationCb:Ee,fontCb:W=>j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.Font},W)})),selectionCb:W=>{j($({type:_.IncrementalSnapshot,data:Object.assign({source:O.Selection},W)}))},blockClass:i,ignoreClass:o,ignoreSelector:l,maskTextClass:a,maskTextSelector:d,maskInputOptions:Z,inlineStylesheet:c,sampling:y,recordCanvas:R,inlineImages:D,userTriggeredOnInput:S,collectFonts:z,doc:X,maskInputFn:h,maskTextFn:g,keepIframeSrcFn:G,blockSelector:s,slimDOMOptions:ce,dataURLOptions:m,mirror:ye,iframeManager:be,stylesheetManager:he,shadowDomManager:me,processedNodeManager:Be,canvasManager:mr,ignoreCSSAttributes:Q,plugins:((We=H==null?void 0:H.filter(W=>W.observer))===null||We===void 0?void 0:We.map(W=>({observer:W.observer,options:W.options,callback:dr=>j($({type:_.Plugin,data:{plugin:W.name,payload:dr}}))})))||[]},I)};be.addLoadListener(X=>{try{C.push(de(X.contentDocument))}catch(We){console.warn(We)}});const x=()=>{Dt(),C.push(de(document)),Ht=!0};return document.readyState==="interactive"||document.readyState==="complete"?x():(C.push(ae("DOMContentLoaded",()=>{j($({type:_.DomContentLoaded,data:{}})),A==="DOMContentLoaded"&&x()})),C.push(ae("load",()=>{j($({type:_.Load,data:{}})),A==="load"&&x()},window))),()=>{C.forEach(X=>X()),Be.destroy(),Ht=!1,la()}}catch(C){console.warn(C)}}kt.addCustomEvent=(e,t)=>{if(!Ht)throw new Error("please add custom event after start recording");j($({type:_.Custom,data:{tag:e,payload:t}}))};kt.freezePage=()=>{Ge.forEach(e=>e.freeze())};kt.takeFullSnapshot=e=>{if(!Ht)throw new Error("please take full snapshot after start recording");Dt(e)};kt.mirror=ye;var Re=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Re||{}),L=(e=>(e.ReplayCapture="replay.capture",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyClosed="survey.closed",e.SurveyDimensions="survey.dimensions",e.SurveyFadingOut="survey.fadingOut",e.SurveyHeight="survey.height",e.SurveyPresented="survey.presented",e.SurveyLifeCycle="survey.lifeCycle",e.SurveyWidth="survey.width",e.SurveyWillClose="survey.willClose",e.SurveyWillPresent="survey.will.present",e.CloseSurveyOnOverlayClick="close.survey.overlayClick",e.VisitorIDUpdated="visitor.id.updated",e.QuestionAnswered="question.answered",e))(L||{});const yt={FEEDBACK_BUTTON_LOADED:"feedback.button.loaded",SDK_READY:"sdk.ready",SURVEY_APPEARED:"survey.appeared",SURVEY_CLOSED:"survey.closed",SURVEY_DIMENSIONS:"survey.dimensions",SURVEY_FADING_OUT:"survey.fadingOut",SURVEY_HEIGHT:"survey.height",SURVEY_WIDTH:"survey.width",SURVEY_PRESENTED:"survey.presented",SURVEY_LIFE_CYCLE:"survey.lifeCycle",SURVEY_WILL_CLOSE:"survey.willClose",SURVEY_WILL_PRESENT:"survey.will.present",QUESTION_ANSWERED:"question.answered",REPLAY_CAPTURE:"replay.capture",CLOSE_SURVEY_ON_OVERLAY_CLICK:"close.survey.overlayClick",VISITOR_ID_UPDATED:"visitor.id.updated",DATA:{DISMISS_REASONS:{API:"api",CLOSED:"close.click",COMPLETE:"survey.completed",PAGE_CHANGE:"page.change",OVERRIDE:"override"},SURVEY_ID:"survey.id"}};let Tt;const Pa=new Uint8Array(16);function Ba(){if(!Tt&&(Tt=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Tt))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Tt(Pa)}const te=[];for(let e=0;e<256;++e)te.push((e+256).toString(16).slice(1));function Wa(e,t=0){return te[e[t+0]]+te[e[t+1]]+te[e[t+2]]+te[e[t+3]]+"-"+te[e[t+4]]+te[e[t+5]]+"-"+te[e[t+6]]+te[e[t+7]]+"-"+te[e[t+8]]+te[e[t+9]]+"-"+te[e[t+10]]+te[e[t+11]]+te[e[t+12]]+te[e[t+13]]+te[e[t+14]]+te[e[t+15]]}const Va=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),En={randomUUID:Va};function Ye(e,t,r){if(En.randomUUID&&!t&&!e)return En.randomUUID();e=e||{};const n=e.random||(e.rng||Ba)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Wa(n)}const za='.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',Pi="360px",Ha="ul-app",Ga="#e6e6e6",ja="#bd282a",Ka=500,Za=1030,Bi=()=>{try{return window.parent.Intercom}catch{return null}},Ya=()=>{const e=Bi();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)},$a=()=>{const e=Bi();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},qa=Object.freeze(Object.defineProperty({__proto__:null,disable:$a,enable:Ya},Symbol.toStringTag,{value:"Module"})),Ln=[qa];class Wi{static disable(){Ln.forEach(t=>t.disable())}static enable(){Ln.forEach(t=>t.enable())}}var Ja=class extends Error{constructor(e,t,r){super(`Possible EventEmitter memory leak detected. ${r} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=r,this.name="MaxListenersExceededWarning"}},Vi=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=Vi.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,r){this.emit(e,t,r)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const r=e.indexOf(t);return r>-1&&e.splice(r,1),[]}_wrapOnceListener(e,t){const r=(...n)=>(this.removeListener(e,r),t.apply(this,n));return Object.defineProperty(r,"name",{value:t.name}),r}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const r=this._getListeners(e);return r.forEach(n=>{n.apply(this,t)}),r.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const r=this._getListeners(e).concat(t);if(this.events.set(e,r),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const n=new Ja(this,e,this.listenerCount(e));console.warn(n)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const r=this._getListeners(e);if(r.length>0){const n=[t].concat(r);this.events.set(e,n)}else this.events.set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const r=this._getListeners(e);return r.length>0&&(this._removeListener(r,t),this.events.set(e,r),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},zi=Vi;zi.defaultMaxListeners=10;const E=new zi,Gt=async e=>{await new Promise(t=>{setTimeout(t,e)})},Hi=({"userleap-platform":e})=>e!=="web";class Gi{constructor(t){ee(this,"storage");ee(this,"tempStorage",{});ee(this,"isStorageAvailable");this.storage=window[t],this.isStorageAvailable=this.checkIfStorageAvailable()}checkIfStorageAvailable(){try{const t="__storage_test__";return this.storage.setItem(t,t),this.storage.removeItem(t),!0}catch{return!1}}setItem(t,r){this.isStorageAvailable?this.storage.setItem(t,r):this.tempStorage[t]=r}getItem(t){return this.isStorageAvailable?this.storage.getItem(t):this.tempStorage[t]}removeItem(t){this.isStorageAvailable?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable?this.storage.clear():this.tempStorage={}}}const re=new Gi("sessionStorage"),ke=new Gi("localStorage");class Qa{constructor(t){ee(this,"payload");ee(this,"promise");ee(this,"reject",()=>{});ee(this,"resolve",()=>{});this.payload=t,this.promise=new Promise((r,n)=>{this.reject=n,this.resolve=r})}resolveRequest(t){this.resolve(t)}}const J={replay:null},Xa=e=>{J.replay=e},el=()=>{const e=[];return J.replay&&e.push("replay"),e.join(",")},tl={RATELIMIT_RESET_DEFAULT:10};let ji=!1,Ki="",Ut=!1,Zi=!1,xt=[];const rl=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",Rn=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(Zi=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`))},Rr=(e="")=>{ji=!0,Ki=e};function Ke(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.31.1","x-ul-installation-method":rl(e),"sprig-modules":el()};if(t["x-ul-package-version"]="1.1.4",e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const r=JSON.parse(e.mobileHeadersJSON);Object.assign(t,r)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const Tn=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const r=new Qa(t);return xt.push(r),r.promise}},Te=async(e,t)=>{const{retries:r=0,shouldDropOnRateLimit:n=!1,shouldRetryRequest:i=!1,...s}=t,o={url:e,options:s,retries:r,shouldDropOnRateLimit:n};if(Ut&&!i)return Tn(o);const l={ok:!1,reportError:!1};if(ji)return console.info(`UserLeap - ${Ki}`),l;try{const a=await fetch(e,s);if(a.status===429)if(!Ut&&!n||i){Ut=!0;const c=a.headers.has("ratelimit-reset")?Number(a.headers.get("ratelimit-reset")):tl.RATELIMIT_RESET_DEFAULT;return await Gt(c*1e3),Te(e,{...s,shouldDropOnRateLimit:n,shouldRetryRequest:!0})}else return Tn(o);if(Ut=!1,xt.length&&(xt.map(d=>{const c=d.payload;Te(c.url,{...c.options,retries:c.retries,shouldDropOnRateLimit:c.shouldDropOnRateLimit}).then(p=>{d.resolveRequest(p)})}),xt=[]),a.ok){if(a.status===249)return Rr(),l;const d=await a.text();try{return d&&d!=="OK"&&(a.json=JSON.parse(d)),a}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${d}`)}}}return a}catch(a){const d=r+1;return d>5||Zi?{ok:!1,reportError:!1,error:a}:(await Gt(Math.pow(2,r)*1e3),Te(e,{...s,retries:d}))}},st={Error:1,Warn:2,Info:3,Debug:4};let Tr=1e3,jt=st.Debug,it=[];const nl=e=>{const t=Object.entries(st).find(r=>r[1]===e);return(t==null?void 0:t[0])??""},il=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),sl=(e,t)=>`${il(t)}:${e}`,ol=()=>{it=it.filter(e=>e.level<=jt)},al=()=>{it.length>Tr&&it.shift()},sr=(e,t)=>{e>jt||(it.push({level:e,line:sl(t,new Date)}),al())},wt=e=>{sr(st.Debug,e)},v=e=>{sr(st.Info,e)},Ur=e=>{sr(st.Warn,e)},Yi=e=>{sr(st.Error,e)},ll=()=>it.map(e=>e.line),cl=()=>new TextEncoder().encode(ll().join(`
20
+ `)),$i=async e=>{if(!e)return;const t=cl();return Te(e,{body:t,method:"PUT"})},dl=(e,t)=>{e!==void 0&&(Tr=e),t!==void 0&&(jt=t),wt(`Initializing logger with limit of ${Tr} lines and ${nl(jt)} level`),ol()},Un="ul-view-sdk-script",ul=["ios","android"],De="visitors",xe="environments";async function Se(e,t){var s,o,l;const{shouldDropOnRateLimit:r,...n}=t;n.headers=Object.assign(Ke(window.UserLeap),n.headers);const i=await Te(e,{...n,shouldDropOnRateLimit:r});if(i.ok){const a=(s=i.headers)==null?void 0:s.get("Authorization"),d=a?a.split(" "):void 0,c=d&&d.length===2?d[1]:void 0,p=(o=i.headers)==null?void 0:o.get("x-ul-visitor-id");c&&p&&(p!==window.UserLeap.visitorId||window.UserLeap.token!==c)&&(fe("token",c),fe("vid",p),E.emit(L.VisitorIDUpdated,{visitorId:p}),window.UserLeap.token=c,window.UserLeap.visitorId=p)}return(l=i.json)!=null&&l.logMessage&&console.warn(`[Sprig] ${i.json.logMessage}`),i}function fe(e,t){const r=ke.getItem("userleap.ids");let n={};if(r)try{n=JSON.parse(r)}catch(s){s instanceof Error&&(s.stack=r,window.UserLeap.reportError("Failed to parse local storage credentials",s)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",s)}let i=n[window.UserLeap.envId];i?i[e]=t:i={[e]:t},n[window.UserLeap.envId]=i;try{ke.setItem("userleap.ids",JSON.stringify(n))}catch(s){s instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${s.message}`)}}function $r(){return window.previewMode?"0":window.UserLeap.visitorId??""}function we(e,t,r){const n=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(i=>{n.push(i),i===xe?n.push(window.UserLeap.envId):i===De&&n.push($r())}),r&&n.push(r),n.join("/")}const ht=async(e,t)=>{var ie,se,F;const{context:r,delay:n,forceBrandedLogo:i,endCard:s,isFeedback:o=!1,heatmap:l,locale:a,previewMode:d,productConfig:c,questions:p,responseGroupUid:f,surveyId:u,uuid:h,vid:g,sessionReplay:I,studyType:k}=e,y=Ke(window.UserLeap),m=Jr(y),w=qr(y);if(v(`Attempting to display survey: ${u}`),I)if(v("Survey has replay attached"),m)E.emit(L.ReplayCapture,{responseGroupUid:f,hasQuestions:!!(p!=null&&p.length),surveyId:u,uploadId:I.uploadId,replayType:I.replayDurationType??"before",seconds:I.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:Ye(),mediaType:"screen",questionId:1,responseGroupUid:f,surveyId:u,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!J.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};J.replay.scheduleOrCaptureReplay({responseGroupId:f,surveyId:u,visitorId:g,replayParams:I,completeUploadHeaders:y,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:p.length===0})}if(l){if(!J.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:M,replayParams:Ee,responseGroupUid:$e,surveyId:he}=l;await J.replay.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:300,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),J.replay.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:y,eventId:M,isHeatmap:!0,replayParams:Ee,responseGroupId:$e,surveyId:he,triggerTimestamp:Date.now(),visitorId:g})}if(g==null||!(p!=null&&p.length))return v(`Not displaying survey: vid: ${g} / questions: ${p}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(pl(p))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){v("Already displaying a survey");const M="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(M),{success:!1,message:M,surveyState:"no survey"}}if(g!==window.UserLeap.visitorId&&h!==window.UserLeap.visitorId&&!window.previewMode){const M="Attempted to display survey to a different visitor";return v(M),window.UserLeap.reportError("DisplaySurvey",new Error(M)),{success:!1,message:M,surveyState:"no survey"}}v(`Showing survey: ${u}`),(ie=J.replay)==null||ie.RecordSurveyShown({id:u,userAgent:window.navigator.userAgent}),Wi.disable(),E.emit(L.SurveyWillPresent,{name:L.SurveyWillPresent,"survey.id":u});let R,T=document.createElement("div"),A,S,z;const D=M=>{const{"view.version":Ee}=M;Ee!==y["x-ul-sdk-version"]&&Ji(),E.removeListener("verify.view.version",D)};E.on("verify.view.version",D),window.UserLeap.useMobileStyling=w,Hi(y)?(R="ul-direct-embeded-frame",A=document.head,S=window,z=!1,m&&(qi(o),T.id=R,window.UserLeap.container.appendChild(T),Qi(),E.emit(L.SurveyLifeCycle,{state:"presented"}),E.emit(L.SurveyPresented,{name:L.SurveyPresented,"survey.id":u}))):{frameId:R,contentWinDocHead:A,contentWindow:S,hasOverlay:z,iframe:T}=yl({productConfig:c,useMobileStyling:w,surveyId:u,isFeedback:o}),window.UserLeap.frameId=R;const H=M=>{E.once(L.CloseSurveyOnOverlayClick,M)},G={apiURL:window.UserLeap._API_URL,cards:p,configureExitOnOverlayClick:H,context:r,endCard:s,envId:window.UserLeap.envId,eventEmitFn:E.emit.bind(E),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:i,frame:T,headers:y,locale:a,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:ke.getItem("sprig.previewKey"),previewMode:d,productConfig:{framePosition:c==null?void 0:c.framePosition,desktopDisplay:c==null?void 0:c.desktopDisplay,placement:c==null?void 0:c.placement},responseGroupUid:f,startingQuestionIdx:(se=window.UserLeap.config)==null?void 0:se.startingQuestionIdx,studyType:k,styleNonce:window.UserLeap.styleNonce,surveyId:u,tabTitle:document.title,trackPageViewUrl:t,ulEvents:yt,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:w,userId:h,viewDocument:S==null?void 0:S.document,viewWindow:S,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(F=window.UserLeap._config)!=null&&F.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const Q=(o?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??c.customStyles;G.customStyles=Q,S&&(S.__cfg=G);function pe(){const M=document.createElement("script");return window.UserLeap.nonce&&M.setAttribute("nonce",window.UserLeap.nonce),M.id=Un,M}const b=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:G.path,B=document.getElementById(Un);B&&B.remove();const Z=pe(),ce=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(G.installationMethod==="web-npm"||G.installationMethod==="web-npm-bundled"){const{default:M}=await Promise.resolve().then(()=>require("./view-FVRV2uPm.cjs"));M.configure(G),z&&window.UserLeap.container&&ce()}else b&&(Z.src=b,z&&Z.addEventListener("load",()=>{window.UserLeap.container&&ce()}),S==null||S.addEventListener("error",M=>{M.target instanceof HTMLScriptElement&&M.target.src===b&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));A==null||A.appendChild(Z);const ne={success:!0,surveyState:"ready",surveyId:u,responseGroupUid:f};return window.UserLeap.isMobileSDK&&n&&(ne.delay=n),ne};function qr(e){var r;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((r=window.UserLeap.windowDimensions)==null?void 0:r.width)??document.body.clientWidth;return Jr(e)||t>10&&t<Ka}function Jr(e){return ul.includes(e["userleap-platform"])}const pl=e=>e.some(t=>t.type==="videovoice"),Qr="ul-frame";window.UserLeap&&window.Sprig&&(window.Sprig._gtm?window.Sprig=window.UserLeap:window.UserLeap=window.Sprig);window.UserLeap||(window.UserLeap=window.Sprig);window.Sprig||(window.Sprig=window.UserLeap);const hl="rgba(255,255,255, 0.95)",fl="rgba(0,0,0,0.9)",yr="0px",qi=(e,t)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container ${e&&"ul-container-feedback"}`;const r=rs();t&&r&&!window.UserLeap.useMobileStyling?r.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ji=(e,t)=>{var n;Il();const r=window.UserLeap.container;if(r)try{(n=r.parentNode)==null||n.removeChild(r),window.UserLeap.container=null,fe("trackStartUrl",null),E.emit(L.SurveyLifeCycle,{state:"dismissed"}),E.emit(L.SurveyClosed,{name:L.SurveyClosed,initiator:e,studyType:t})}catch(i){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+r),i instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",i)}},Qi=()=>{E.once(L.SurveyWillClose,({initiator:e,studyType:t})=>{E.removeAllListeners(L.CloseSurveyOnOverlayClick),Ji(e,t)})},gl=(e,t)=>{const n={...{position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646}},i=t?e.overlayStyleMobile:e.overlayStyle;n["background-color"]=i==="light"?hl:fl,t||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},ml=(e,t,r,n)=>{var c,p;const i={position:"fixed",bottom:"0px",right:yr,border:0,backgroundColor:"rgba(0,0,0,0)",zIndex:2147483646,transition:"width 0.2s ease-in-out, height 0.2s ease-in-out",maxWidth:"100%"},s=Object.assign({},t,window.UserLeap),{desktopDisplay:o}=t||{},l=o==="center-modal";l&&(s.framePosition="center");let a,d=!1;if(r)(c=window.UserLeap.windowDimensions)!=null&&c.width?i.width=`${window.UserLeap.windowDimensions.width}px`:i.width="100%",(p=window.UserLeap.windowDimensions)!=null&&p.height?i.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?i.maxHeight=window.UserLeap.maxHeight:i.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(s.overlayStyleMobile)&&(d=!0);else{i.width=Pi,i.maxHeight=window.UserLeap.maxHeight||"66vh";const f=()=>{d=!0,a={margin:"auto",position:"static"}};if(n)l?f():a={position:"relative",height:"300px"};else switch(s.framePosition){case"bottomLeft":a={left:yr};break;case"topLeft":a={left:yr,top:0};break;case"topRight":a={top:0};break;case"center":f();break}}return d&&gl(s,r),Object.assign(e.style,i,a),d},yl=({productConfig:e,useMobileStyling:t,surveyId:r,isFeedback:n})=>{var f,u;const i=Qr,s=n&&e.desktopDisplay==="slider";qi(n,s),wl();const o=document.createElement("iframe");o.id=i,o.setAttribute("title","Sprig User Feedback Dialog");const l=ml(o,e,t,n);Qi();let a=!1;o.setHeight=h=>{(parseInt(o.style.height)!=h||!a)&&(a=!0,o.style.height=`${h}px`,E.emit(L.SurveyHeight,{name:L.SurveyHeight,contentFrameHeight:h}))};let d=!1;o.setWidth=h=>{(parseInt(o.style.width)!=h||!d)&&(d=!0,o.style.width=`${h}px`,E.emit(L.SurveyWidth,{name:L.SurveyWidth,contentFrameWidth:h}))},(f=window.UserLeap.container)==null||f.appendChild(o),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{E.emit(L.CloseSurveyOnOverlayClick)}),E.emit(L.SurveyLifeCycle,{state:"presented"}),E.emit(L.SurveyPresented,{name:L.SurveyPresented,"survey.id":r});const c=(u=o.contentWindow)==null?void 0:u.document;if(c&&(c.open("text/html","replace"),c.write("<!doctype html><head></head><body></body></html>"),c.close(),!t)){const h=c.body;h.style.display="flex",h.style.alignItems="center"}const p=c==null?void 0:c.head;return{frameId:i,contentWinDocHead:p,contentWindow:o.contentWindow,hasOverlay:l,iframe:o}},Xi={[L.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},wl=()=>{Object.entries(Xi).forEach(([e,t])=>{E.on(e,t)})},Il=()=>{Object.entries(Xi).forEach(([e,t])=>{E.off(e,t)})},_n=Object.freeze({contains:(e,t)=>t.includes(e),notContains:(e,t)=>!t.includes(e),exactly:(e,t)=>t===e,notExactly:(e,t)=>t!==e,startsWith:(e,t)=>t.startsWith(e),endsWith:(e,t)=>t.endsWith(e),regex:(e,t)=>new RegExp(e).test(t),legacy:(e,t)=>new RegExp(e,"i").test(t)});function or(e,t){const{matchType:r,pattern:n}=e,i=r?_n[r]:_n.legacy;let s=!1;try{s=i(n,t)}catch(o){const l=`[Sprig] (ERR-445) Failed to check url match with pattern ${n}`;o instanceof Error&&(console.warn(l,o),o.stack=JSON.stringify(e),window.UserLeap.reportError(l,o))}return s}const es=e=>{const{pageUrlEvents:t}=window.UserLeap._config,r=t==null?void 0:t.find(n=>n.id===e);return r?or(r,window.location.href):!1},vl=1,On=e=>e instanceof HTMLElement||e instanceof SVGElement,It=({document:e,elementId:t,styleString:r,nonce:n})=>{const i=e.getElementById(t);if(i){i.textContent=r;return}const s=e.createElement("style");n&&(s.nonce=n),s.textContent=r,s.id=t,e.head.appendChild(s)},ts=e=>{const t=e.querySelector(".ul-card__container");let r=600,n=360;if(t){r=t.scrollHeight;const i=getComputedStyle(t),s=parseFloat(i.marginTop)+parseFloat(i.marginBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),l=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom);r+=s+o+l;const a=t.querySelector(".ul-card--matrix_grid");n=a?a.scrollWidth:t.scrollWidth;const d=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),c=parseFloat(i.marginLeft)+parseFloat(i.marginRight),p=parseFloat(i.borderLeftWidth)+parseFloat(i.borderRightWidth);n+=c+p+d}return[r+vl,n]},bl=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},rs=()=>N,rt=()=>document.getElementById("sprig-feedback-container"),Xr=()=>document.getElementById("sprig-feedback-loading-animation"),Sl=()=>{if(Xr())return;const e=document.createElement("div");return e.className="ul-loading-spinner-container",e.id="sprig-feedback-loading-animation",e.role="progressbar",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.setAttribute("aria-label","Processing..."),e.innerHTML=`
21
+ <div class="ul-loading-spinner">
22
+ <div class="first"></div>
23
+ <div class="second"></div>
24
+ <div class="third"></div>
25
+ <div class="fourth"></div>
26
+ </div>
27
+ `,e},ns=()=>!!document.getElementById(Qr);let Dn=!1,N=null,Ce=null,en=!1,ft=null,Ve=null;const Cl=["bottom-left","bottom-right","center-left","center-right"],kl=e=>{if(rt()||!Cl.includes(e))return;const[t,r]=e.split("-"),n=document.createElement("div");n.id="sprig-feedback-container",n.classList.add(`sprig-feedback-container-${r}`,`sprig-feedback-container-${t}`),document.body.appendChild(n)},ar=()=>{var t;const e=window.UserLeap.container;return((t=e==null?void 0:e.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},is=()=>document.getElementById("sprig-feedback-error-container"),ss=()=>{if(!N)return 0;const e=N==null?void 0:N.clientWidth,t=window.getComputedStyle(N),r=parseInt(t.borderRightWidth||"0"),n=parseInt(t.borderLeftWidth||"0");return e+r+n},Kt=e=>{const t=rt();t&&(Ve!=null&&Ve.endsWith("right")?t.style.right=`${e}px`:Ve!=null&&Ve.endsWith("left")&&(t.style.left=`${e}px`))},wr=()=>{if(N&&(ar()||is())){E.off(L.SurveyAppeared,lt),_r();const e=ss();return Kt(-e),!0}return!1},lt=()=>{if(!N||!Ce)return;const e=Xr();e&&e.remove(),N.style.height="auto",N.style.width="auto",Ce.disabled=!1,en=!1},_r=()=>{if(!N)return;if(!Xr()){const t=Sl();t&&(N.style.height="300px",N.style.width="360px",N.appendChild(t))}},xn=()=>{!N||!Ce||(Kt(0),Ce.disabled=!0,en=!0)},Al=async e=>{const t=await Se(we("1",[De],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:e}),method:"POST"});return t.ok?t.json:null},os=async(e,t,r)=>{const{buttonTheme:n,customStyles:i,eventId:s,placement:o,desktopDisplay:l,feedbackLabel:a,surveyUuid:d,surveyId:c}=e;window.UserLeap.feedbackCustomStyles=void 0;let p=rt();if(p){if(!t&&s===ft)return;p.remove(),E.off(yt.SURVEY_FADING_OUT,wr)}ft=s,It({document,elementId:"sprig-feedback-style",styleString:za,nonce:window.UserLeap.styleNonce}),It({document,elementId:"ul-custom-style",styleString:i??"",nonce:window.UserLeap.styleNonce}),Dn=l==="center-modal",Ve=o;const[u,h]=o.split("-");kl(o),p=rt(),Ce=document.createElement("button");const g=document.createElement("div");g.className="sprig-feedback-button-label",g.innerText=a,Ce.appendChild(g),Ce.id="sprig-feedback-button",Ce.classList.add(`sprig-feedback-button-${h}`,`sprig-feedback-button-${u}`,`sprig-feedback-button-${n}`,"fade-in-transition"),E.on(yt.SURVEY_FADING_OUT,wr),Ce.addEventListener("click",async()=>{const y=document.getElementById("sprig-feedback-error-container");if(ns()||is()){if(wr()){E.emit(L.SurveyWillClose,{name:L.SurveyWillClose,initiator:Re.FeedbackClosed,studyType:"feedbackButton"});const T=rt();y&&T&&(T.remove(),ft=null,N=null)}return}const m=Ke(window.UserLeap);if(!qr(m)&&!en&&xn(),t){N&&N.classList.add("sprig-feedback-loading-container-previews"),await ht(t),lt();return}const R=await Al(d);if(R)E.once(L.SurveyAppeared,lt),ht({...R,studyType:"feedbackButton"},r);else if(N){const T=Ll();N.appendChild(T),lt(),N.style.height="300px",N.style.width="360px"}}),p==null||p.appendChild(Ce),E.emit(L.FeedbackButtonLoaded,{name:L.FeedbackButtonLoaded,"survey.id":c});const{useMobileStyling:I,_config:{border:k}}=window.UserLeap;if(!Dn&&!I){const y=document.createElement("div");y.id="sprig-feedback-loading-container",y.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${h}`,y.style.setProperty("--feedback-border",k),N=y,_r(),p==null||p.appendChild(y);const m=ss();Kt(-m)}else Kt(0);window.UserLeap._config.isOnQuestionsTab&&t&&!ar()&&N&&(xn(),_r(),N&&N.classList.add("sprig-feedback-loading-container-previews"),ht(t),lt())},El=()=>{if(ar())return;const e=rt();if(!e)return;es(ft)||(e.remove(),ft=null,N=null)},Ll=()=>{const e=document.createElement("div");e.id="sprig-feedback-error-container",e.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
28
+ <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
29
+ <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
30
+ <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
31
+ </svg>`;const t=document.createElement("h3");return t.className="sprig-feedback-error-text",t.innerText="There was an error while loading the survey",e.appendChild(t),e},Rl="!launch_darkly_";class Tl{constructor(){ee(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(t){try{return!t||typeof t!="object"||Array.isArray(t)?!1:(Object.keys(this._ldData).forEach(r=>{delete this._ldData[r]}),Object.keys(t).forEach(r=>this._ldData[`${Rl}${r}`]=(t[r]??0)+1),!0)}catch(r){return r instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",r),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const Or=new Tl;Object.freeze(Or);const Ul="!optimizely_experiments_";class _l{constructor(){ee(this,"_optimizelyData",{})}setOptimizelyExperiment(t,r=!0){if(!t||typeof t!="object")return!1;const{experiments:n}=t;try{return r&&Object.keys(this._optimizelyData).map(i=>{delete this._optimizelyData[i]}),n&&n.map(i=>{const{id:s,variation:o}=i,l=this.transformExperimentId(s);o&&typeof o=="string"&&(this._optimizelyData[l]=o)}),!0}catch(i){return i instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",i),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(t){return this._optimizelyData[this.transformExperimentId(t)]}transformExperimentId(t){return Ul+t}getAndSetWebOptimizelyExperiments(){var t;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const r=(t=window.optimizely.get("state"))==null?void 0:t.getExperimentStates({isActive:!0});if(r){const n=Object.keys(r).map(i=>{var s,o;return(s=r[i].variation)!=null&&s.name?{id:i,variation:(o=r[i].variation)==null?void 0:o.name}:{id:i,variation:"Original"}});return this.setOptimizelyExperiment({experiments:n},!1),!0}return!1}return!1}catch(r){return r instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",r),!1}}}const Mt=new _l;Object.freeze(Mt);class Ol{constructor(t,r){ee(this,"paused");ee(this,"queue");ee(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(r)}flush(t){const r=t.length;if(r)for(let n=0;n<r;n++)this.push(t[n])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const t=this.queue.slice();this.empty(),this.flush(t)}push(t){if(this.paused)this.queue.push(t);else if(t instanceof Function)t();else{const r=Array.prototype.slice.call(t,1),n=t[0],i=this.ul[n];i instanceof Function?i.apply(this.ul,r):n&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",n)}}perform(t){if(this.paused){let r=()=>{};const n=new Promise(function(i){r=function(){i(t())}});return this.queue.push(r),n}else return t()}empty(){this.queue.length=0}}let as=!0,tn=!1;const Dl=()=>as=!1,xl=()=>tn=!0,Ml=["sdk_event_queue_latency_seconds","sdk_replay_add_event_batch_seconds","sdk_replay_cleanup_seconds","sdk_replay_compression_seconds","sdk_replay_get_events_between_seconds","sdk_replay_snapshot_seconds","sdk_mutations_nodes_added","sdk_mutations_nodes_removed","sdk_mutations_attributes_changed","sdk_mutations_character_data","sdk_dom_nodes_count","sdk_page_html_characters"];let ct={},Dr;class Nl{constructor(t){ee(this,"_values",[]);ee(this,"_isWebMetric");this.name=t,this._isWebMetric=Ml.includes(this.name)}report(t){if(as&&this._values.push({time:Date.now(),value:t}),tn||!this._isWebMetric)return;const r=this.findExceededThreshold(t);r&&Dr&&Dr(t,r)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const r=ct[this.name];if(r)return r.find(n=>this.valueExceedsThreshold(t,n))}valueExceedsThreshold(t,r){return r.type==="max"?t>r.value:r.type==="min"?t<r.value:!1}}const Fl=(e,t)=>{ct={},tn=!1,e==null||e.forEach(r=>{var n;r.metric in ct||(ct[r.metric]=[]),(n=ct[r.metric])==null||n.push(r)}),Dr=t},At={},Ae=e=>{const t=new Nl(e);return At[e]=t,t},ls=(e,t)=>{let r=At[e];return r||(r=Ae(e)),r.report(t)},Pl=async e=>{const t=Object.values(At).map(r=>({name:r.name,values:r.collect()}));if(t.some(r=>r.values.length))try{await e(JSON.stringify(t))}catch(r){Ur(`Error posting metrics: ${r}`)}},Bl=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{Pl(t)},e*1e3):Dl()};let cs,ds;const xr=e=>{let t=0,r=e.firstElementChild;for(;r;)t+=xr(r),r.shadowRoot&&(t+=xr(r.shadowRoot)),r=r.nextElementSibling,t++;return t},Wl=()=>document.documentElement.innerHTML.length,Mn=()=>{cs.report(xr(document.body)),ds.report(Wl())},Vl=(e=10*1e3)=>{cs=Ae("sdk_dom_nodes_count"),ds=Ae("sdk_page_html_characters"),Mn(),setInterval(Mn,e)},Mr=(e,t)=>{const r=performance.now();document.hidden?setTimeout(()=>Mr(e,t),e):setTimeout(()=>{const n=performance.now()-r;t.report(n/1e3),setTimeout(()=>Mr(e,t),e)},0)},zl=(e=1e3)=>{const t=Ae("sdk_event_queue_latency_seconds");Mr(e,t)};let Zt,Yt,$t,qt,He={},Nn;const _t=(e,t=1)=>{const{name:r}=e;He[r]=(He[r]||0)+t},us=e=>{let t=1;return e.childNodes.forEach(r=>{t+=us(r)}),t},Fn=e=>{let t=0;return e.forEach(r=>{t+=us(r)}),t},Hl=e=>{switch(e.type){case"childList":_t(Zt,Fn(e.addedNodes)),_t(Yt,Fn(e.removedNodes));return;case"attributes":_t($t);return;case"characterData":_t(qt);return}},Gl=e=>e.forEach(Hl),jl=()=>{Nn=new MutationObserver(Gl),Nn.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},Kl=()=>{Zt.report(He[Zt.name]||0),Yt.report(He[Yt.name]||0),$t.report(He[$t.name]||0),qt.report(He[qt.name]||0),He={}},Zl=(e=1*1e3)=>{Zt=Ae("sdk_mutations_nodes_added"),Yt=Ae("sdk_mutations_nodes_removed"),$t=Ae("sdk_mutations_attributes_changed"),qt=Ae("sdk_mutations_character_data"),jl(),setInterval(Kl,e)},Yl=({webMetricsEnabled:e,reportingIntervalSeconds:t,thresholds:r,postMetrics:n})=>{Fl(r,(i,s)=>{var o,l;if((o=J.replay)!=null&&o.isReplayRecording()){const a=`Value: ${i} on ${s.metric} violated threshold of ${s.type} ${s.value}`;(l=J.replay)==null||l.disableRecording("Threshold violated",new Error(a),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:s.metric,type:s.type,value:s.value},{metricName:s.metric}),xl()}}),Bl({reportingIntervalSeconds:t,postMetrics:n}),e&&(zl(),Vl(),Zl())},$l={test:"test"},ql=["popState","pushState","replaceState"],ot="!email",ps="pageUrl";function Jl(e,t){const{pageUrlEvents:r,interactiveEvents:n,dismissOnPageChange:i}=window.UserLeap._config;if(!i)return!0;const s=[];r&&r.length&&s.push(...r),n&&n.length&&s.push(...n);const o=e&&s.find(l=>l.id===e);return o?or(o,window.location.href):t===window.location.href}function vt(e){var l;const{pageUrlEvents:t,interactiveEvents:r,dismissOnPageChange:n,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;const s=ze("trackStartUrl"),o=s?String(s):null;t&&ms(window.location.href),r&&(fs(),Ql()),rs()&&El(),re.getItem("sprig.isCapturingHeatmap")&&((l=J.replay)==null||l.checkPendingHeatmapsUrl()),!ar()&&n&&o&&o!==window.location.href&&e&&ql.includes(e.type)&&window.UserLeap("dismissActiveSurvey",Re.PageChange)}const hs={capture:!0},Ql=()=>{const t=window.UserLeap._config.interactiveEvents.filter(n=>or(n,window.location.href)).map(n=>{const{name:i,properties:s}=n,{selector:o,innerText:l}=s;return o?a=>{if(On(a.target))try{a.target.closest(o)&&window.UserLeap("track",i)}catch{}return!1}:a=>(On(a.target)&&a.target.innerText===l&&window.UserLeap("track",i),!1)}),r=n=>t.forEach(i=>i(n));window.UserLeap._config.interactiveEventsHandler=r,window.addEventListener("click",r,hs)},fs=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,hs),delete window.UserLeap._config.interactiveEventsHandler};function Xl(){["hashchange","popstate"].forEach(e=>window.addEventListener(e,vt,!0))}function ec(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,vt,!0)),window.UserLeap._config.interactiveEvents&&fs()}function tc(e){const t=new URL(we("1",[xe],"questions"));return Object.entries(e||{}).forEach(([r,n])=>{n&&t.searchParams.append(r,String(n))}),t.toString()}function ze(e){const t=ke.getItem("userleap.ids");if(t)try{const n=JSON.parse(t)[window.UserLeap.envId];return n&&n[e]||null}catch(r){r instanceof Error&&(r.stack=t,window.UserLeap.reportError("Failed to parse local storage credentials",r)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",r)}return null}function gs(){window.previewMode||(window.UserLeap.visitorId=Ye(),v(`Generating new vid: ${window.UserLeap.visitorId}`),fe("vid",window.UserLeap.visitorId),E.emit(L.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function ms(e,t,r,n){var i,s;try{if(e.endsWith("mock_snippet.html"))return;v(`Tracking page view: ${e}`);const o=window.UserLeap._config.pageUrlEvents;let l=!1;if(o&&o.length)for(let c=0;c<o.length&&(l=or(o[c],e),!l);c++);if(!l)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const a={url:e};n&&(a.trackPageView=!0),window.UserLeap._queue.push(["track",ps,t,a,r]);const d=(i=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:i.getAttribute("content");(s=J.replay)==null||s.RecordPageView({...d&&{description:d},url:e,referrer:document.referrer,pageTitle:document.title})}catch(o){o instanceof Error&&(o.stack=e,window.UserLeap.reportError("trackPageView",o)),console.warn("[Sprig] (ERR-428) Failed to track page view",o)}}function rc(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...n){const i=t.apply(this,n),s=new Event("pushState");return window.dispatchEvent(s),vt(s),i})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...n){const i=t.apply(this,n),s=new Event("replaceState");return window.dispatchEvent(s),vt(s),i})(e.replaceState)),Xl()}async function Ir(e,t){const r=$r();e&&!t&&(window.UserLeap._config.mode=$l.test);const n=Ke(window.UserLeap),i=qr(n),s=await Se(tc({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:i,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:e==null?void 0:e.surveyId,surveytemplateid:e==null?void 0:e.surveyTemplateId,vid:r}),{shouldDropOnRateLimit:!0});if(!s.ok)return s.reportError&&s.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",s.error),window.UserLeap.reportError("getQuestions",s.error)),{success:!1,surveyState:"no survey"};if(s.json.delay&&await Gt(s.json.delay),s.json.isFeedback){const{feedbackLabel:o,productConfig:l,surveyUuid:a,feedbackCustomStyles:d}=s.json,{buttonTheme:c,placement:p,desktopDisplay:f}=l,u={customStyles:d,buttonTheme:c,desktopDisplay:f,eventId:0,feedbackLabel:o,placement:p,surveyUuid:a,surveyId:e==null?void 0:e.surveyId};os(u,s.json)}else return ht(s.json)}function nc(e){let t=e.length;for(;t;){const r=Math.floor(Math.random()*t);t-=1;const n=e[t];e[t]=e[r],e[r]=n}}function ic(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:r,dismissOnPageChange:n}=e;t&&nc(t),(t||r||n)&&(rc(),vt())}async function sc(e,t){var n,i;let r=!0;return t&&((n=e==null?void 0:e.json)!=null&&n.surveyId)&&(window.UserLeap.delayingSurvey=!0,r=await t(e.json.surveyId),window.UserLeap.delayingSurvey=!1,!r)?!1:((i=e==null?void 0:e.json)!=null&&i.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await Gt(e.json.delay),window.UserLeap.delayingSurvey=!1),r)}const oc=function(e){if(!window.UserLeap)return;const t=async(i={})=>{var y,m,w,R,T;const{userId:s,anonymousId:o,metadata:l={},properties:a,showSurveyCallback:d}=i;let{eventName:c}=i;if(window.UserLeap.debugMode&&c!==ps&&console.info("[DEBUG] Sprig track",i),e.mode==="test")return;const p=ke.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!s){const A="[Sprig] - Skipping tracking without userId";return console.warn(A),{success:!1,message:A,surveyState:"no survey"}}if(!c||c.trim().length===0){c=c?String(c):"";const A="[Sprig] - Invalid event name "+c;return console.warn(A),{success:!1,message:A,surveyState:"no survey"}}const f=window.location.href;if(l.url||(l.url=f),fe("trackStartUrl",f),(m=(y=window.UserLeap)==null?void 0:y._config)!=null&&m.optimizelyEnabled){const A=Ke(window.UserLeap);Jr(A)||Mt.getAndSetWebOptimizelyExperiments(),l.optimizelyExperiments=Object.assign({},Mt.getAllOptimizelyExperiments())}(R=(w=window.UserLeap)==null?void 0:w._config)!=null&&R.launchDarklyEnabled&&(l.launchDarklyFlags=Or.getAllLaunchDarklyVariations()),s&&(window.UserLeap.userId=s),o&&(window.UserLeap.partnerAnonymousId=o),a&&(l.eventProperties=a),(T=J.replay)==null||T.RecordEvent({name:c,url:l.url}),v(`Tracking event: ${c}`);const u=window.UserLeap.delayingSurvey||ns()?await Se(we("1",[De],"events/batch"),{body:JSON.stringify({events:[{event:c,metadata:l}],previewKey:p}),method:"POST",shouldDropOnRateLimit:!0}):await Se(we("1",[De],"events"),{body:JSON.stringify({event:c,metadata:l,previewKey:p}),method:"POST",shouldDropOnRateLimit:!0});if(!u.ok){const A="[Sprig] (ERR-421) Failed to track event";return u.reportError&&(console.warn(A,u.error),u.error&&window.UserLeap.reportError("track",u.error)),{success:!1,message:A,error:u.error,surveyState:"no survey"}}s&&fe("uid",s),o&&fe("aid",o);const h=u.json;h.invalidPreviewKey&&ke.removeItem("sprig.previewKey");const g=l.trackPageView?l.url:void 0;return!!(h!=null&&h.feedbackButton)&&os(h.feedbackButton,void 0,g),await sc(u,d)?Jl(h.eventId,f)?ht(h,g):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},r=(i,s)=>{var l;const o=(l=i==null?void 0:i.querySelector(`[id="${Qr}"]`))==null?void 0:l.contentDocument;o&&It({document:o,elementId:"ul-custom-style",styleString:s})},n={async displaySurvey(i){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",Re.Override),Ir({surveyId:i},!0)},_previewSurvey(i){window.UserLeap("dismissActiveSurvey",Re.Override),Ir({surveyTemplateId:i},!1)},_reviewSurvey(i){window.UserLeap("dismissActiveSurvey",Re.Override),Ir({surveyId:i},!1)},previewSurvey(i){n._previewSurvey(i)},reviewSurvey(i){n._reviewSurvey(i)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(i=Re.API){E.emit(L.SurveyWillClose,{name:L.SurveyWillClose,initiator:i})},async setAttribute(i,s){if(!i||!s&&s!==0&&s!==!1){const o="[Sprig] - Disregarding empty attribute / value provided";return console.warn(o),{success:!1,message:o}}return this.setAttributes({[i]:s})},async setAttributes(i){if(i==null||Object.keys(i).length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}return this.identifyAndSetAttributes({attributes:i})},async identifyAndSetAttributes(i){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",i),e.mode==="test")return;if(i===null||typeof i!="object"||!(i.userId||i.anonymousId||i.attributes)){const c="[Sprig] - Disregarding empty payload provided";return console.warn(c),{success:!1,message:c}}const{userId:s,anonymousId:o,attributes:l}=i;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!s){const c="[Sprig] - Skipping tracking without userId";return console.warn(c),{success:!1,message:c}}if(!l&&(!s||window.UserLeap.userId===s)&&(!o||window.UserLeap.partnerAnonymousId===o))return{success:!0};const a={};s&&(a.userId=window.UserLeap.userId=s),o&&(a.partnerAnonymousId=window.UserLeap.partnerAnonymousId=o);let d;return l?(l.email&&!Object.prototype.hasOwnProperty.call(l,ot)&&(l[ot]=l.email,delete l.email),v(`Setting attributes: ${JSON.stringify(l)}`),d=await Se(we("1",[xe,De],"attributes"),{body:JSON.stringify(l),method:"PUT"}),!d.ok&&d.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",d.error),d.error&&window.UserLeap.reportError("identifyAndSetAttributes",d.error))):d=await Se(we("1",[xe,De]),{body:JSON.stringify(a),method:"PUT"}),l&&l[ot]&&(window.UserLeap.email=l[ot]),d.ok&&(s&&fe("uid",s),o&&fe("aid",o)),{success:!!d.ok}},async removeAttributes(i){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",i),e.mode==="test")return;if(i==null||i.length===0){const o="[Sprig] - Disregarding empty attributes provided";return console.warn(o),{success:!1,message:o}}if(e.requireUserIdForTracking&&!window.UserLeap.userId){const o="[Sprig] - Skipping tracking without userId";return console.warn(o),{success:!1,message:o}}const s=await Se(we("1",[xe,De],"attributes"),{body:JSON.stringify({delete:i}),method:"DELETE"});return!s.ok&&s.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",s.error),s.error&&window.UserLeap.reportError("removeAttributes",s.error)),{success:!!s.ok}},async addSurveyListener(i){E.on(L.SurveyLifeCycle,i)},async removeSurveyListener(i){E.removeListener(L.SurveyLifeCycle,i)},async addListener(i,s){E.on(i,s)},async removeListener(i,s){E.removeListener(i,s)},async removeAllListeners(){E.removeAllListeners()},setPreviewKey(i){!i||typeof i!="string"||ke.isStorageAvailable&&i&&ke.setItem("sprig.previewKey",i)},async setUserId(i){var l;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",i),i==null){const a=`[Sprig] - Invalid userId ${i}`;return console.warn(a),{success:!1,message:a}}if(e.mode==="test"||i===window.UserLeap.userId)return;window.UserLeap.userId=i;const s=window.UserLeap.visitorId,o=await Se(we("1",[xe,De]),{body:JSON.stringify({userId:i}),method:"PUT"});if(!o.ok){o.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",o.error),o.error&&window.UserLeap.reportError("setUserId",o.error));return}s!==window.UserLeap.visitorId&&((l=J.replay)==null||l.clearUserReplayData()),fe("uid",i)},async setPartnerAnonymousId(i){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",i),i==null){const s=`[Sprig] - Invalid partnerAnonymousId ${i}`;return console.warn(s),{success:!1,message:s}}return window.UserLeap.partnerAnonymousId=i,fe("aid",i),{success:!0}},async track(i,s,o={},l=void 0){return t({eventName:i,properties:s,metadata:o,showSurveyCallback:l})},async identifyAndTrack(i){return await t(i)},trackPageView(i,s=void 0,o=void 0,l=!0){ms(i,s,o,l)},applyFeedbackStyles({button:i="",view:s=""}){window.UserLeap.feedbackCustomStyles=s,document.getElementById("sprig-feedback-style")&&It({document,elementId:"ul-custom-style",styleString:i,nonce:window.UserLeap.styleNonce}),r(document.querySelector(".ul-container-feedback"),s)},applyStyles(i){window.UserLeap.customStyles=i,r(window.UserLeap.container,i)},setWindowDimensions(i,s){var d,c;const o=typeof i=="string"?parseInt(i,10):i,l=typeof s=="string"?parseInt(s,10):s;if(!isNaN(o)&&!isNaN(l)&&(window.UserLeap.windowDimensions={width:o,height:l}),!window.UserLeap.frameId)return;const a=document.getElementById(window.UserLeap.frameId);a&&(window.UserLeap.useMobileStyling&&((d=window.UserLeap.windowDimensions)!=null&&d.width&&(a.style.width=`${window.UserLeap.windowDimensions.width}px`),(c=window.UserLeap.windowDimensions)!=null&&c.height&&(a.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),a.contentDocument&&(a.style.height=String(ts(a.contentDocument)[0])+"px")),E.emit(L.SurveyDimensions,{name:L.SurveyDimensions,contentFrameWidth:a.clientWidth,contentFrameHeight:a.clientHeight}))},logoutUser(){var i;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),v(`Logging out user: ${window.UserLeap.userId} / vid: ${window.UserLeap.visitorId}`),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,ke.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),gs(),(i=J.replay)==null||i.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){ec(),window.UserLeap("dismissActiveSurvey",Re.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(i,s=!0){var o,l;if(!((l=(o=window.UserLeap)==null?void 0:o._config)!=null&&l.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const a=typeof i=="string"?JSON.parse(i):i;Mt.setOptimizelyExperiment(a,s)}catch(a){console.warn("[Sprig] Error with integrating Optimizely data"),a instanceof Error&&window.UserLeap.reportError("integrateOptimizely",a)}},integrateOptimizelyClient(i){var o,l;if(!((l=(o=window.UserLeap)==null?void 0:o._config)!=null&&l.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const s=({experiment:a,variation:d})=>{const c={experiments:[{id:a.id,variation:d.key}]};window.UserLeap("integrateOptimizely",c,!1)};i.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",s)},importLaunchDarklyData(i){var s,o;if(!((o=(s=window.UserLeap)==null?void 0:s._config)!=null&&o.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}Or.setLDFlagsVariations(i)},setVisitorAttribute(i,s){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),n.setAttribute(i,s)},async setEmail(i){return n.setAttribute(ot,i)},async setVisitorEmail(i){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),n.setEmail(i)},async _generateVideoUploadUrl(i){return dc(i)},_reportMetric(i,s){ls(i,s)},async _completeSessionReplay({surveyId:i,responseGroupUuid:s,eventDigest:o}){var l;return J.replay?(l=J.replay)==null?void 0:l._completeSessionReplay({surveyId:i,responseGroupUuid:s,eventDigest:o,headers:Ke(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,n)};async function ac(e){const t=Ke(window.UserLeap);document.addEventListener("securitypolicyviolation",Rn);const r=await Te(we("1",[xe],"config"),{headers:t});if(document.removeEventListener("securitypolicyviolation",Rn),!r.ok)return r.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",r.error),r.error&&window.UserLeap.reportError("applyRemoteConfig",r.error)),Rr("Disabled: failed to fetch configuration"),e;const n=r.json;return n!=null&&n.disabled?(Rr(`Disabled: ${n.disabled}`),{disabled:n.disabled}):Object.assign({},n,e)}const lc=e=>typeof e=="object"&&e&&"inner"in e&&!!e.inner&&typeof e.inner=="object";async function cc(e,t,r={},n={}){var f,u;const i=window.__cfg&&window.__cfg.mode,s=$r(),o=window.UserLeap.envId,l=window.document.documentElement,a=lc(t)?{inner:{message:(f=t.inner)==null?void 0:f.message,stack:(u=t.inner)==null?void 0:u.stack}}:{},d={mode:i,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:l.clientWidth,clientHeight:l.clientHeight,location:window.location.href,language:window.navigator.language,...r,...a},c={action:e,err:{message:t.message,stack:t.stack},meta:d,vid:s,envId:o,...n},p=await Se(we("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0});if(!p.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",t);else{const{presignedUrl:h}=p.json;$i(h)}}async function dc(e){var r;if(!e)return;const t=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const n=await fetch(t,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(n.ok){const i=await n.json();return(r=i==null?void 0:i.upload)==null?void 0:r.url}else return null}catch(n){console.warn("[Sprig] Error with generating video upload url"),n instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",n)}}function uc(e={}){const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=yt,window.UserLeap("setPreviewKey",t);async function r(){var l;if(window.UserLeap.loaded)return;if(v("Loading sprig on page load"),window.UserLeap.reportError=cc,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},e,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const a in window.UserLeap._config)window.UserLeap[a]=window.UserLeap._config[a];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const n=window.UserLeap.sampleRate;if(n){let a=ze("sampled");if(a===null&&(a=Math.random()<n,fe("sampled",a)),!a)return}else ze("sampled")!==null&&fe("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const i=[...window.UserLeap._queue];window.UserLeap._queue=new Ol(window.UserLeap,[]),window.UserLeap._queue.pause();for(let a=0;a<i.length;a++)window.UserLeap._queue.push(i[a]);const s=ze("token");s?(window.UserLeap.token=s,window.UserLeap.visitorId=ze("vid"),window.UserLeap.userId=ze("uid"),window.UserLeap.partnerAnonymousId=ze("aid")):(ke.removeItem("userleap.ids"),gs());const o=await ac(e);Yl({webMetricsEnabled:o.metricsReportingEnabled,reportingIntervalSeconds:o.metricsReportingEnabled||o.mobileMetricsReportingEnabled?o.metricsReportingIntervalSeconds:0,thresholds:o.metricThresholds,postMetrics:async a=>{var d;await Se(we("1",[xe],"metrics"),{body:a,method:"POST",headers:{"x-ul-replay-enabled":`${!!((d=J.replay)!=null&&d.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),(l=J.replay)==null||l.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:o.maxReplayDurationSeconds,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:o.replaySettings}),dl(o.logBufferLimit,o.logLevel),oc(o),await ic(o),window.UserLeap._queue.unpause(),E.emit(L.SDKReady,{mobileMetricsReportingEnabled:!!o.mobileMetricsReportingEnabled,metricsReportingInterval:o.metricsReportingIntervalSeconds||0,metricsThresholds:o.metricThresholds||[],maxMobileReplayDurationSeconds:o.maxMobileReplayDurationSeconds,mobileReplaySettings:o.mobileReplaySettings}),E.emit(L.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?r():window.attachEvent?window.attachEvent("onload",r):window.addEventListener("load",()=>{r()},!1)}class Jt{constructor(){ee(this,"UPDATES",yt)}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,r){window.Sprig("setAttribute",t,r)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,r){window.Sprig("addListener",t,r)}removeListener(t,r){window.Sprig("removeListener",t,r)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(t){window.Sprig("setAttribute","!email",t)}setUserId(t){window.Sprig("setUserId",t)}setPartnerAnonymousId(t){window.Sprig("setPartnerAnonymousId",t)}track(t,r={},n={}){window.Sprig("track",t,r,n)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,r,n){window.Sprig("trackPageView",t,r,n)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,r){window.Sprig("setWindowDimensions",t,r)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const Nr={configure:e=>{if(!e.envId&&!e.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(e.envId||(e.envId=e.environmentId??""),e.installationMethod="web-npm-bundled",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(Jt.prototype).map(r=>{r!=="constructor"&&(window.Sprig[r]=Jt.prototype[r])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,uc(e),window.Sprig}};Nr.configure;class pc{constructor(t){ee(this,"awaitingResolvers",[]);ee(this,"activeCount",0);this.capacity=t}async acquire(){if(this.activeCount<this.capacity){this.activeCount++;return}return new Promise(t=>{this.awaitingResolvers.push(t)})}release(){const t=this.awaitingResolvers.shift();t&&this.activeCount<=this.capacity?t():this.activeCount--}async execute(t){try{return await this.acquire(),await t()}finally{this.release()}}setLimit(t){this.capacity=t}}const ys=new pc(2),hc=e=>ys.setLimit(e),fc=async e=>ys.execute(async()=>{var n;v(`Beginning upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const t=await Te(e.uploadUrl,{body:e.data,method:"PUT"});v(`Completed upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const r=(n=t.headers)==null?void 0:n.get("ETag");if(!r)throw new Error(`Upload response did not include etag for upload ${e.uploadId}, part ${e.chunkIndex}`);return r}),ws=async({apiUrl:e,surveyId:t,uploadId:r,etags:n,headers:i,responseGroupUuid:s,replayDuration:o,eventDigest:l},a=!1)=>{var c;if(!a&&!r&&!n){v(`Cannot mark upload complete: isMobile: ${a} / uploadId: ${r} / etags: ${n}`);return}v(`Marking upload complete for survey: ${t}`);const d=await Te(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:n,uploadId:r,responseGroupUuid:s,surveyId:t,replayDuration:o,eventDigest:l,userAgent:(c=window==null?void 0:window.navigator)==null?void 0:c.userAgent}),headers:i,shouldRetryRequest:!0});return v(`Done marking upload complete for survey: ${t}`),d},Fr=(e,t)=>t.some(r=>e instanceof r);let Pn,Bn;function gc(){return Pn||(Pn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function mc(){return Bn||(Bn=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Pr=new WeakMap,vr=new WeakMap,lr=new WeakMap;function yc(e){const t=new Promise((r,n)=>{const i=()=>{r(Ne(e.result))},s=()=>{n(e.error)};e.onsuccess=i,e.onerror=s});return lr.set(t,e),t}function wc(e){if(Pr.has(e))return;const t=new Promise((r,n)=>{const i=()=>{r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError"))};e.oncomplete=i,e.onerror=s,e.onabort=s});Pr.set(e,t)}let Br={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return Pr.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return Ne(e[t])},set(e,t,r){return e[t]=r,!0},has(e,t){return e instanceof IDBTransaction&&(t==="done"||t==="store")?!0:t in e}};function Is(e){Br=e(Br)}function Ic(e){return mc().includes(e)?function(...t){return e.apply(Wr(this),t),Ne(this.request)}:function(...t){return Ne(e.apply(Wr(this),t))}}function vc(e){return typeof e=="function"?Ic(e):(e instanceof IDBTransaction&&wc(e),Fr(e,gc())?new Proxy(e,Br):e)}function Ne(e){if(e instanceof IDBRequest)return yc(e);if(vr.has(e))return vr.get(e);const t=vc(e);return t!==e&&(vr.set(e,t),lr.set(t,e)),t}const Wr=e=>lr.get(e);function bc(e,t,{blocked:r,upgrade:n,blocking:i,terminated:s}={}){const o=indexedDB.open(e,t),l=Ne(o);return n&&(o.onupgradeneeded=a=>{n(Ne(o.result),a.oldVersion,a.newVersion,Ne(o.transaction),a)}),r&&(o.onblocked=a=>r(a.oldVersion,a.newVersion,a)),l.then(a=>{s&&(a.onclose=()=>s()),i&&(a.onversionchange=d=>i(d.oldVersion,d.newVersion,d))}).catch(()=>{}),l}function vs(e,{blocked:t}={}){const r=indexedDB.deleteDatabase(e);return t&&(r.onblocked=n=>t(n.oldVersion,n)),Ne(r).then(()=>{})}const Sc=["get","getKey","getAll","getAllKeys","count"],Cc=["put","add","delete","clear"],br=new Map;function Wn(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t=="string"))return;if(br.get(t))return br.get(t);const r=t.replace(/FromIndex$/,""),n=t!==r,i=Cc.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||Sc.includes(r)))return;const s=async function(o,...l){const a=this.transaction(o,i?"readwrite":"readonly");let d=a.store;return n&&(d=d.index(l.shift())),(await Promise.all([d[r](...l),i&&a.done]))[0]};return br.set(t,s),s}Is(e=>({...e,get:(t,r,n)=>Wn(t,r)||e.get(t,r,n),has:(t,r)=>!!Wn(t,r)||e.has(t,r)}));const kc=["continue","continuePrimaryKey","advance"],Vn={},Vr=new WeakMap,bs=new WeakMap,Ac={get(e,t){if(!kc.includes(t))return e[t];let r=Vn[t];return r||(r=Vn[t]=function(...n){Vr.set(this,bs.get(this)[t](...n))}),r}};async function*Ec(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;t=t;const r=new Proxy(t,Ac);for(bs.set(r,t),lr.set(r,Wr(t));t;)yield r,t=await(Vr.get(r)||t.continue()),Vr.delete(r)}function zn(e,t){return t===Symbol.asyncIterator&&Fr(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&Fr(e,[IDBIndex,IDBObjectStore])}Is(e=>({...e,get(t,r,n){return zn(t,r)?Ec:e.get(t,r,n)},has(t,r){return zn(t,r)||e.has(t,r)}}));const Lc=e=>{if(e instanceof Attr)return null;let t=1;for(let r=e.previousSibling;r;r=r.previousSibling)r.nodeName===e.nodeName&&++t;return t},Ss=e=>{if(e===null)return"";const t=[];if(e instanceof Document)return"/";for(let r=e;r&&!(r instanceof Document)&&r!==null;r=r instanceof Attr?r.ownerElement:r.parentElement){const n=t[t.length]={name:void 0,position:null};switch(r.nodeType){case Node.TEXT_NODE:n.name="text()";break;case Node.ATTRIBUTE_NODE:n.name="@"+r.nodeName;break;case Node.PROCESSING_INSTRUCTION_NODE:n.name="processing-instruction()";break;case Node.COMMENT_NODE:n.name="comment()";break;case Node.ELEMENT_NODE:n.name=r.nodeName;break}n.position=Lc(r)}return"/"+t.reverse().map(r=>r.position!==null?`/${r.name}[${r.position}]`:`/${r.name}`).join("")},Me={capture:!0,passive:!0},Rc=["a","button","input","option","li","link"],Tc=["Escape","Enter","Backspace","F5","Tab"];let Qt=!1;const Uc=["label","type","role","title","placeholder","errormessage","valuetext","href"],Hn="aria-",_c=e=>{if(!e.tagName)return"No tagName";const t=e.getAttribute("type");return t?`${t} ${e.tagName.toLowerCase()}`:e.tagName.toLowerCase()},Gn=e=>{var n;if(((n=e.tagName)==null?void 0:n.toLowerCase())==="html")return{element:"html"};const t=e.textContent,r=t?{text:t}:{};r.element=_c(e);for(const i of e.attributes){let s=i.name;const o=i.value;s.startsWith(Hn)&&(s=s.substring(Hn.length)),Uc.includes(s)&&(r[s]=o)}return r},Oc=e=>{var i;if(!e)return{};const r={...Gn(e)},n=e.parentElement;if(n&&Rc.includes((i=n.tagName)==null?void 0:i.toLowerCase())){const s=Gn(n);Object.assign(r,s)}return r},Cs=(e,t)=>{var r;Kc({x:t.x,y:t.y,type:e,elementAttributes:Oc(t.target),windowHeight:window.innerHeight,windowWidth:window.innerWidth,...t.target instanceof HTMLElement?{rect:(r=t.target)==null?void 0:r.getBoundingClientRect(),xPath:Ss(t.target)}:{}})},Dc=e=>t=>Cs(e,t),ks=e=>{Tc.includes(e.key)&&Qc({key:e.key})},xc=()=>{window.performance.getEntriesByType("navigation").map(t=>t.type).includes("reload")&&qc({url:window.location.href,currentPageTitle:document.title})},Mc=()=>{window.performance.getEntriesByType("navigation").map(t=>t.type).includes("back_forward")&&Jc({curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title})},Nc=(e,t)=>{let r;return n=>{clearTimeout(r),r=window.setTimeout(()=>e(n),t)}},Fc=e=>{if(!(e.target instanceof HTMLElement||e.target instanceof Document))return;let t=e.target;"scrollTop"in t||(t=t.documentElement),Xc({xPath:Ss(t),x:t.scrollLeft,y:t.scrollTop,elementAttributes:{targetScrollWidth:t.scrollWidth,targetClientWidth:t.clientWidth,targetScrollHeight:t.scrollHeight,targetClientHeight:t.clientHeight}})},As=Nc(Fc,750),Es=Dc("left_click"),Ls=e=>{e.button===2&&Cs("right_click",e)},Pc=()=>{Qt||(window.addEventListener("click",Es,Me),window.addEventListener("mousedown",Ls,Me),window.addEventListener("keydown",ks,Me),window.addEventListener("scroll",As,Me),Qt=!0,xc(),Mc())},Bc=()=>{Qt&&(window.removeEventListener("click",Es,Me),window.removeEventListener("mousedown",Ls,Me),window.removeEventListener("keydown",ks,Me),window.removeEventListener("scroll",As,Me),Qt=!1)},Wc=3e4;let at=0;const K={isRecording:!1,scrollEventUuids:{},stopRecording:()=>{}},Vc=()=>{const e=re.getItem("sprig.sessionId");if(e)return v(`Found saved session id: ${e}`),re.removeItem("sprig.sessionId"),e;const t=Ye();return v(`Generating new uuid: ${t}`),t},oe=Vc(),zc=async e=>{var t;if((t=window.navigator.storage)!=null&&t.estimate){const{quota:r=0,usage:n=0}=await window.navigator.storage.estimate();return(r-n)/1024**3>=e}return!0},Rs=()=>{re.setItem("sprig.disableReplayRecording","disabled")},Ze=()=>!!re.getItem("sprig.disableReplayRecording");window.addEventListener("beforeunload",()=>{v(`Before page unload saving session id: ${oe}`),re.setItem("sprig.sessionId",oe)});const Hc=async()=>{const t=(await V.getPendingCaptures({isHeatmap:!0})).map(n=>({eventId:n.captureParams.eventId,uuid:n.uuid})),r=[];t.forEach(({eventId:n,uuid:i})=>{es(n)||r.push(i)}),r.length&&ge(()=>V.markPendingHeatmapsReady(r),"Error marking pending heatmaps ready")},Gc=e=>{if(e>1){at=0;return}const t=Date.now();if(!at){at=t;return}t-at>=Wc&&(at=0,ge(()=>V.markPendingHeatmapsReady(),"Error marking pending heatmaps ready"))},rn=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),ve=(e,t)=>{var r,n;if(K.isRecording)try{(n=(r=window.rrwebRecord)==null?void 0:r.addCustomEvent)==null||n.call(r,e,t)}catch(i){cr("Error recording custom event",i)}},jc=e=>{e.description&&(e.description=rn(e.description)),ve("Sprig_PageView",e)},Kc=e=>{var t;(t=e==null?void 0:e.elementAttributes)!=null&&t.text&&(e.elementAttributes.text=rn(e.elementAttributes.text)),ve("Sprig_Click",e)},Zc=e=>{ve("Sprig_TrackEvent",e)},Yc=e=>{ve("Sprig_ShowSurvey",e)},$c=e=>{ve("Sprig_SubmitSurvey",e)},qc=e=>{ve("Sprig_Refresh",e)},Jc=e=>{e.currentPageTitle&&(e.currentPageTitle=rn(e.currentPageTitle)),ve("Sprig_BackForward",e)},Qc=e=>{ve("Sprig_Keystroke",e)},Xc=async e=>{const{x:t,xPath:r,y:n}=e,i=K.scrollEventUuids[r];if(i)return ge(async()=>{var l,a,d,c;const s=await V.openDB(),o=await s.get("events",i);if(o!=null&&o.event){const p=JSON.parse(o.event),f=t>((a=(l=p.data)==null?void 0:l.payload)==null?void 0:a.x),u=n>((c=(d=p.data)==null?void 0:d.payload)==null?void 0:c.y);if(!(f||u))return null;f&&(p.data.payload.x=t),u&&(p.data.payload.y=n),p.data.payload.elementAttributes=e.elementAttributes,o.event=JSON.stringify(p),await s.put("events",o)}else ve("Sprig_Scroll",e)},"Error updating scroll event");ve("Sprig_Scroll",e)},ed=()=>K.isRecording,Ts=()=>{K.stopRecording&&(K.stopRecording(),K.stopRecording=void 0),K.isRecording=!1,["cleanupInterval","noopInterval","pendingCheckInterval"].forEach(e=>{K[e]&&(clearInterval(K[e]),K[e]=void 0)}),Bc()},td=["did not allow mutations","called in an invalid security context"],rd=e=>{if(!e)return!0;for(const t of td)if(e.toLowerCase().includes(t))return!1;return!0},nd=(e,t,{reportError:r=!0,extraInfo:n})=>{Ze()||t instanceof Error&&(Rs(),rd(t==null?void 0:t.message)&&(r&&window.UserLeap.reportError(e,t,n),V.clearAll()))},id=async(e,t,{reportError:r}={reportError:!0})=>{var i;let n;try{if(r&&((i=window.navigator.storage)!=null&&i.estimate)){const{quota:s=0,usage:o=0}=await window.navigator.storage.estimate();n={availableSpaceInMB:(s-o)/2**20,quota:s,usage:o}}}catch(s){window.UserLeap.reportError("Error getting storage estimate",s,{originalMessage:e,originalError:t})}nd(e,t,{reportError:r,extraInfo:n})},cr=(e,t,{reportError:r}={reportError:!0})=>(Ts(),Yi(`${e} - ${JSON.stringify(t)}`),id(e,t,{reportError:r})),ge=async(e,t)=>{try{await e()}catch(r){cr(t,r)}},sd=()=>{K.isRecording&&ge(()=>{var e,t;return(t=(e=window.rrwebRecord)==null?void 0:e.takeFullSnapshot)==null?void 0:t.call(e,!0)},"Error recording full snapshot")},od=async({surveyId:e,responseGroupUuid:t,eventDigest:r,headers:n})=>{if(!e||!t)return!1;const i=window.UserLeap._API_URL,s=await ws({surveyId:e,responseGroupUuid:t,eventDigest:r,apiUrl:i,headers:n},!0);return!(s!=null&&s.error)},jn=30,ad=1;vs("replayStorage").catch(console.error);vs("sprig.replay").catch(console.error);class ld{openDB(){return bc("sprigReplay",ad,{upgrade:(t,r,n)=>{if(n===0&&re.setItem("sprig.pendingCount","0"),!t.objectStoreNames.contains("events")){const i=t.createObjectStore("events",{keyPath:"uuid"});i.createIndex("sessionId","sessionId"),i.createIndex("timestamp","timestamp"),i.createIndex("[sessionId+timestamp]",["sessionId","timestamp"])}if(!t.objectStoreNames.contains("chunkUploads")){const i=t.createObjectStore("chunkUploads",{keyPath:"uuid"});i.createIndex("sessionId","sessionId"),i.createIndex("timestamp","timestamp"),i.createIndex("[sessionId+status]",["sessionId","status"]),i.createIndex("[uploadId+status]",["uploadId","status"]),i.createIndex("[sessionId+status+uploadId]",["sessionId","status","uploadId"])}if(!t.objectStoreNames.contains("pendingCaptures")){const i=t.createObjectStore("pendingCaptures",{keyPath:"uuid"});i.createIndex("sessionId","sessionId"),i.createIndex("timestamp","timestamp"),i.createIndex("[sessionId+targetTimestamp]",["sessionId","targetTimestamp"])}}}).catch(t=>(Yi(`Error opening replay storage: ${t.message}`),Rs(),Promise.reject(t)))}constructor(){this.openDB()}async bulkAdd(t,r){const n=(await this.openDB()).transaction(t,"readwrite");return Promise.all([...r.map(i=>n.store.add(i)),n.done])}async clearAll(){const t=(await this.openDB()).transaction(["events","chunkUploads","pendingCaptures"],"readwrite");return Promise.all([t.objectStore("events").clear(),t.objectStore("chunkUploads").clear(),t.objectStore("pendingCaptures").clear()])}async deleteBySessionId(t,r){const n=IDBKeyRange.only(r),i=(await this.openDB()).transaction(t,"readwrite");let o=await i.store.index("sessionId").openCursor(n);for(;o;)o.delete(),o=await o.continue();await i.done}async updatePartial(t,r,n){const s=(await this.openDB()).transaction(t,"readwrite"),o=await s.store.get(r);o&&await s.store.put({...o,...n}),await s.done}async deleteRowsBefore(t,r,n=()=>!0){const i=IDBKeyRange.upperBound(r,!0),s=(await this.openDB()).transaction(t,"readwrite");let l=await s.store.index("timestamp").openCursor(i);for(;l;)n(l.value)&&l.delete(),l=await l.continue();await s.done}async getEventsBetween(t,r=Date.now()){if(t>=r)return Promise.resolve([]);const n=IDBKeyRange.bound([oe,t],[oe,r],!1,!0);return(await this.openDB()).getAllFromIndex("events","[sessionId+timestamp]",n)}async updateEventsExpiredAt(t,r,n=jn){const i=new Date,s=i.setMinutes(i.getMinutes()+(n??jn)),o=(await this.openDB()).transaction("events","readwrite"),l=o.store.index("[sessionId+timestamp]"),a=IDBKeyRange.bound([oe,t],[oe,r],!1,!0);let d=await l.openCursor(a);for(;d;)d.update({...d.value,expiredAt:s}),d=await d.continue();await o.done}async deleteChunkUploads(t,r){const n=IDBKeyRange.only([r,t]),i=(await this.openDB()).transaction("chunkUploads","readwrite");let o=await i.store.index("[uploadId+status]").openCursor(n);for(;o;)o.delete(),o=await o.continue();await i.done}async getChunkUploadsByStatus({sessionId:t,status:r,uploadId:n}){const s=(await this.openDB()).transaction("chunkUploads","readonly"),o=n?s.store.index("[uploadId+status]"):s.store.index("[sessionId+status]"),l=n?IDBKeyRange.only([n,r]):IDBKeyRange.only([t,r]);return o.getAll(l)}async getPendingCaptures(t={}){return(await(await this.openDB()).getAllFromIndex("pendingCaptures","sessionId",oe)).filter(i=>!t.beforePresent||i.targetTimestamp<Date.now()).filter(i=>!t.isHeatmap||(i.captureParams.isHeatmap??!1))}async markPendingCaptureToCanUpload(t){const r=(await this.openDB()).transaction("pendingCaptures","readwrite");let i=await r.store.index("sessionId").openCursor(oe);for(;i;){const s=i.value;s.captureParams.responseGroupId===t&&i.update({...s,canUpload:!0}),i=await i.continue()}await r.done}async markPendingHeatmapsReady(t){if(parseInt(re.getItem("sprig.pendingCount")??"0")===0)return null;const n=Date.now(),i=(await this.openDB()).transaction("pendingCaptures","readwrite");let o=await i.store.index("sessionId").openCursor(oe);for(;o;){const l=o.value;l.captureParams.isHeatmap&&(!t||t.includes(l.uuid))&&o.update({...l,targetTimestamp:n,captureParams:{...l.captureParams,triggerTimestamp:n,replayParams:{...l.captureParams.replayParams,replayDurationSeconds:Math.floor((n-l.timestamp)/1e3)}}}),o=await o.continue()}await i.done}}const V=new ld;const Us=async(e,t)=>{const r=performance.now();let n;try{n=await e()}finally{const i=performance.now()-r;let s=At[t];s||(s=Ae(t)),s.report(i/1e3)}return n},_s=(e,t)=>{const r=performance.now();try{e()}finally{const n=performance.now()-r;let i=At[t];i||(i=Ae(t)),i.report(n/1e3)}};let Kn=1,zr=5e3,Nt=6e4;const Zn=1e3,cd=5,Os=30,Xt=Os+cd;let Yn=Date.now(),Fe,nn=!!re.getItem("sprig.isCapturingHeatmap"),Hr=!1,Gr=[];const dd=async({viewDocument:e,maxReplayDurationSeconds:t,replayNonce:r,maxInflightRequests:n=2,replaySettings:i,teardownAfter:s=!1})=>{Fe=re.getItem("sprig.pendingCount"),!K.isRecording&&(s&&re.setItem("sprig.teardownAfterCapture","true"),await ge(async()=>{if(Ze()){v("Not initializing replay because recording is disabled");return}if(!t){v("Not initializing replay because config didn't specify maxReplayDurationSeconds");return}if(i!=null&&i.minAvailableGb&&(Kn=i.minAvailableGb),!await zc(Kn)){Ur("Minimum storage not available");return}v("Initializing replay"),i!=null&&i.minDuration&&(zr=i.minDuration),i!=null&&i.batchDuration&&(Nt=i.batchDuration),hc(n),wd(),fd(t+Xt,30*60,t+Xt),gd();const o=window.rrwebRecord;if(!o){Ur("Record script failed to set global function");return}let l=!0,a=0;K.stopRecording=o({checkoutEveryNms:Os*1e3,sampling:{input:"last",scroll:250,media:800},emit:(d,c)=>{if(Ze())return;if(Yn=Date.now(),c&&d.type===_.Meta)a=performance.now();else if(c&&a&&d.type===_.FullSnapshot){const f=performance.now()-a;ls("sdk_replay_snapshot_seconds",f/1e3)}const p=l||!!c&&d.type===_.Meta;l=!1,ud({uuid:Ye(),event:JSON.stringify(d),isValidStart:p,timestamp:Date.now()})},...i}),K.isRecording=!!K.stopRecording,K.isRecording&&(K.noopInterval||(K.noopInterval=window.setInterval(()=>{Date.now()-Yn>Zn&&ve("Sprig_Noop",{})},Zn)),E.on("survey.complete",d=>{$c({id:d,userAgent:window.navigator.userAgent})}),Pc())},"Error initializing replay"))},ud=e=>{var t,r,n,i;if((t=e.event)!=null&&t.includes("Sprig_Scroll")){const s=(i=(n=(r=JSON.parse(e.event))==null?void 0:r.data)==null?void 0:n.payload)==null?void 0:i.xPath;if(!s)return;K.scrollEventUuids[s]=e.uuid}Gr.push(e),Hr||hd()},pd=async e=>{const t=e.map(r=>({...r,sessionId:r.sessionId??oe}));if(nn&&Gc(t.length),t.length!==0)return ge(()=>V.bulkAdd("events",t),"Error storing replay events")},hd=()=>{Hr=!0,setTimeout(async()=>{if(Ze())return;const e=Gr;Gr=[],Hr=!1,_s(async()=>{await pd(e)},"sdk_replay_add_event_batch_seconds")},500)},fd=(e,t,r)=>{K.cleanupInterval=window.setInterval(()=>{const n=Date.now();Ze()||(wt(`Performing periodic replay data cleanup / Event Seconds ${e} / Chunk Seconds ${t} / Pending Capture Seconds ${r}`),Us(()=>ge(async()=>{await Promise.all([V.deleteRowsBefore("events",n-e*1e3,i=>i.expiredAt===void 0||i.expiredAt<n-e*1e3),V.deleteRowsBefore("chunkUploads",n-t*1e3),V.deleteRowsBefore("pendingCaptures",n-r*1e3,i=>!i.canUpload)])},"Error deleting table rows"),"sdk_replay_cleanup_seconds"),v("Cleanup complete"))},3e4)},gd=()=>{K.pendingCheckInterval=window.setInterval(async()=>{ge(async()=>{const e=parseInt(Fe??"0");if(e===0)return;const t=await V.getPendingCaptures({beforePresent:!0}),r=await V.openDB();await Promise.all(t.map(async n=>(await r.delete("pendingCaptures",n.uuid),Ms(n.captureParams,n.canUpload)))),Fe=(e-t.length).toString(),re.setItem("sprig.pendingCount",Fe)},"Error initiating pending captures")},5e3)},md=async(e,t,r,n,i)=>{const s=Math.min(e+i,r),o=`from: ${new Date(e).toLocaleTimeString()} to ${new Date(s).toLocaleTimeString()}`;v(`Getting event batch ${o}`);const l=await Us(()=>V.getEventsBetween(e,s),"sdk_replay_get_events_between_seconds");if(!(l!=null&&l.length))return v(`No events found ${o}`),{validStartFound:n,events:[]};if(!n){v(`Searching for valid start in ${l.length} events ${o}`);let a=-1;if(l==null||l.forEach((c,p)=>{if(!c.isValidStart)return;const f=c.timestamp<=t;(a<0||f)&&(a=p)}),a<0)return v(`No valid start found in ${l.length} events ${o}`),{validStartFound:n,events:[]};const d=l[a].timestamp;return v(`Found valid start at: ${new Date(d).toLocaleTimeString()} in events ${o}`),{validStartFound:!0,events:l==null?void 0:l.slice(a)}}return{validStartFound:n,events:l}},yd=(e,t,r)=>{const n=e.length,i=t*1024*1024,s=Math.ceil(n/r),o=Math.max(i,s);v(`Total file bytes: ${n} / target chunk size: ${o}`);const l=[];let a=0;for(;a<n;)l.push(e.slice(a,a+o)),a+=o;return l},Ds=e=>Promise.all(e.map(async t=>{const r=await fc(t);return await V.updatePartial("chunkUploads",t.uuid,{data:null,etag:r,status:"UploadComplete"}),t.uploadId})),xs=async e=>{v(`Marking upload complete if finished: ${e}`);const t=await V.getChunkUploadsByStatus({status:"UploadComplete",uploadId:e});if(!(t!=null&&t.length)){v(`No finished chunks found for upload: ${e}`);return}const r=t.reduce((s,o)=>(s.find(l=>l.chunkIndex===o.chunkIndex)||s.push(o),s),[]);r.sort((s,o)=>s.chunkIndex-o.chunkIndex);const n=r.map(s=>({ETag:s.etag,PartNumber:s.chunkIndex})).filter(s=>s.ETag!==null),i=r[0];await ws({apiUrl:i.apiUrl,surveyId:i.surveyId,uploadId:e,responseGroupUuid:i.responseGroupId,etags:n,headers:i.completeUploadHeaders,replayDuration:i.replayDuration}),v(`Cleaning up chunks for ${e}`),await V.deleteChunkUploads("UploadComplete",e),v(`Done cleaning up chunks for ${e}`)},wd=async()=>{ge(async()=>{const e=await V.getChunkUploadsByStatus({sessionId:oe,status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await Ds(e);v(`Finished uploading unfinished chunks for ${t}`),t!=null&&t.length&&await Promise.all(t.map(r=>{if(r)return xs(r)}))},"Error uploading unfinished chunks")},Id=async(e,t)=>{await Ds(t),v(`Done uploading chunks for uploads: ${e.join(",")}`),await Promise.all(e.map(r=>xs(r)))},vd=e=>{let t=0;e.forEach(i=>{t+=i.length});const r=new Uint8Array(t);let n=0;return e.forEach(i=>{r.set(i,n),n+=i.length}),r},$n=async(e,t,r)=>{const n=new TextEncoder;let i=null,s=null,o=null,l=!1,a=!1,[d,c]=[0,0];const p=e-Xt*1e3,f=[];let u=[];v(`Getting events between ${new Date(e).toLocaleTimeString()} and ${new Date(t).toLocaleTimeString()}`),v(`Using batch duration: ${Nt}ms`);for(let g=p;g<t;g+=Nt){if({validStartFound:a,events:u}=await md(g,e,t,a,Nt),!(u!=null&&u.length)){v("No events found");continue}d===0&&(d=u[0].timestamp),c=u[u.length-1].timestamp,v(`Last event time in batch: ${new Date(c).toLocaleTimeString()}`);const I=`${l?",":"["}${u.map(y=>y.event).join(",")}`,k=n.encode(I);r&&s===null&&(wt("Attempting compression"),o=new window.CompressionStream("gzip"),s=o.writable.getWriter()),_s(()=>{r&&s?s.write(k):f.push(k)},"sdk_replay_compression_seconds"),l=!0}if(c-d<zr)return v(`Replay duration is shorter than minimum of ${zr}ms / Start:${d} / End:${c}`),null;const h=n.encode("]");return wt("Writing final close brace"),s&&o?(s.write(h),s.close(),i=new Uint8Array(await new Response(o.readable).arrayBuffer())):(f.push(h),i=vd(f)),v("Finished generating file data"),i},bd=async(e,t)=>{const r=window.CompressionStream!==void 0;let n=null;const i=t??Date.now(),s=i-e;try{n=await $n(s,i,r)}catch(o){o instanceof Error&&window.UserLeap.reportError("Error compressing replay",o),r&&ge(async()=>{await $n(s,i,!1)},"fileData fallback failed")}return n},qn=async e=>{const{surveyId:t,responseGroupId:r,visitorId:n,apiUrl:i,completeUploadHeaders:s,replayParams:o,triggerTimestamp:l}=e,a=await bd(o.replayDurationSeconds*1e3,l);if(a!=null&&a.length)v(`Found file data for survey: ${t}`);else{v(`File data is empty for survey: ${t}`);return}const d=yd(a,o.minimumChunkSizeMb,o.signedUrls.length);v(`Got ${d.length} chunks for survey: ${t}`);const c=await Promise.all(d.map(async(p,f)=>{const u=Ye(),h={apiUrl:i,chunkIndex:f+1,completeUploadHeaders:s,etag:null,responseGroupId:r,status:"ReadyForUpload",surveyId:t,timestamp:l,totalChunks:d.length,data:p,uploadId:o.uploadId,uploadUrl:o.signedUrls[f].url,uuid:u,visitorId:n};return v(`Recording chunk upload: ${JSON.stringify({index:h.chunkIndex,surveyId:h.surveyId,uploadId:h.uploadId,size:p.length,id:u},null,2)}`),await(await V.openDB()).add("chunkUploads",{...h,sessionId:h.sessionId??oe}),v(`Done creating chunk upload: ${u}`),h}));v(`All chunk records created. Beginning upload for survey: ${t}`),await Id([o.uploadId],c)},Ms=async(e,t)=>{if(v(`Attempting replay capture: ${JSON.stringify({isStandalone:e.isStandalone,duration:e.replayParams.replayDurationSeconds,type:e.replayParams.replayDurationType,responseGroupId:e.responseGroupId,surveyId:e.surveyId,triggerTimestamp:e.triggerTimestamp,visitorId:e.visitorId},null,2)}`),Ze())return v(`Replay recording is disabled: ${e.surveyId}`);v(`Replay recording enabled: ${e.surveyId}`);const{isHeatmap:r,isStandalone:n,replayParams:i,triggerTimestamp:s,responseGroupId:o}=e,l=async()=>{setTimeout(()=>E.removeListener(L.QuestionAnswered,l),0),ge(async()=>{i.replayDurationType==="before"?await qn(e):await V.markPendingCaptureToCanUpload(o)},"Error in schedule/capture callback")};ge(async()=>{if(i.replayDurationType==="after"||i.replayDurationType==="beforeAndAfter"){!n&&!r&&(v("Attaching QuestionAnswered listener for non-standalone replay"),E.on(L.QuestionAnswered,l)),v(`Scheduling capture for replay of type: ${i.replayDurationType}`),await Fs(e);return}if(n||r||t)v(`Proceeding to capture replay for survey: ${e.surveyId} / standalone? ${n} / canUpload? ${t}`),await qn(e),r&&Sd();else{const d=Xt+i.replayDurationSeconds,c=s-d*1e3,p=s;v(`Setting expiry minutes to ${i.expirationTimeLimitMinutes} for events from ${new Date(c).toLocaleTimeString()} to ${new Date(p).toLocaleTimeString()}`),await V.updateEventsExpiredAt(c,p,i.expirationTimeLimitMinutes),v("Attaching QuestionAnswered listener"),E.on(L.QuestionAnswered,l)}},"Error in scheduling/capturing replay")},Sd=async()=>{parseInt(Fe??"0")||(re.removeItem("sprig.isCapturingHeatmap"),nn=!1),re.getItem("sprig.teardownAfterCapture")&&(Ts(),Ns(),re.removeItem("sprig.teardownAfterCapture"))},Ns=()=>{if(Ze()){wt("Not clearing user data, replay is disabled");return}return Promise.all([V.deleteBySessionId("events",oe),V.deleteBySessionId("pendingCaptures",oe)]).catch(e=>{cr("Error clearing user replay data",e)})},Fs=async e=>{v(`Scheduling replay capture: ${JSON.stringify(e)}`);const{isHeatmap:t,surveyId:r}=e,n=await V.getPendingCaptures(),i=n==null?void 0:n.filter(a=>a.captureParams.surveyId===r);if(i!=null&&i.length){v(`Pending capture exists for survey: ${r}`);return}t&&(sd(),nn=!0,re.setItem("sprig.isCapturingHeatmap","true"));const s={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(s.replayParams.replayDurationSeconds*=2),s.replayParams.replayDurationType="before";const o=e.triggerTimestamp+e.replayParams.replayDurationSeconds*1e3;s.triggerTimestamp=o,Fe=(parseInt(Fe??"0")+1).toString(),re.setItem("sprig.pendingCount",Fe),await(await V.openDB()).add("pendingCaptures",{canUpload:!1,captureParams:s,sessionId:oe,targetTimestamp:o,timestamp:Date.now(),uuid:Ye()})},Cd=Object.freeze(Object.defineProperty({__proto__:null,RecordEvent:Zc,RecordPageView:jc,RecordSurveyShown:Yc,_completeSessionReplay:od,checkPendingHeatmapsUrl:Hc,clearUserReplayData:Ns,disableRecording:cr,initializeReplay:dd,isReplayRecording:ed,scheduleCapture:Fs,scheduleOrCaptureReplay:Ms},Symbol.toStringTag,{value:"Module"}));Xa(Cd);window.UpChunk={createUpload:Ao};window.rrwebRecord=kt;exports.APP_ID=Ha;exports.ConflictingWidgets=Wi;exports.DEFAULT_BORDER_COLOR=Ga;exports.DEFAULT_WIDTH=Pi;exports.DismissReason=Re;exports.EMBED_MOBILE_MAX_WIDTH=Za;exports.ERROR_BORDER_COLOR=ja;exports.SprigAPI=Jt;exports.SprigEvent=L;exports.calculateFrameDimensions=ts;exports.eventEmitter=E;exports.info=v;exports.resetScrollPosition=bl;exports.setSurveyStyles=It;exports.shouldDirectEmbed=Hi;exports.sprig=Nr;exports.sprigFetch=Te;exports.uploadLogfile=$i;exports.v4=Ye;