@sprig-technologies/sprig-bundled 1.1.3 → 1.1.4

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,37 @@
1
+ var vl=Object.defineProperty,wl=(e,t,n)=>t in e?vl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ee=(e,t,n)=>(wl(e,typeof t!="symbol"?t+"":t,n),n),bl=Object.create,ms=Object.defineProperty,Il=Object.getOwnPropertyDescriptor,gs=Object.getOwnPropertyNames,Sl=Object.getPrototypeOf,Cl=Object.prototype.hasOwnProperty,Gt=(e,t)=>function(){return t||(0,e[gs(e)[0]])((t={exports:{}}).exports,t),t.exports},kl=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of gs(t))!Cl.call(e,i)&&i!==n&&ms(e,i,{get:()=>t[i],enumerable:!(r=Il(t,i))||r.enumerable});return e},Al=(e,t,n)=>(n=e!=null?bl(Sl(e)):{},kl(t||!e||!e.__esModule?ms(n,"default",{value:e,enumerable:!0}):n,e)),El=Gt({"node_modules/global/window.js"(e,t){var n;typeof window<"u"?n=window:typeof global<"u"?n=global:typeof self<"u"?n=self:n={},t.exports=n}}),_l=Gt({"node_modules/is-function/index.js"(e,t){t.exports=r;var n=Object.prototype.toString;function r(i){if(!i)return!1;var s=n.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)}}}),Ll=Gt({"node_modules/parse-headers/parse-headers.js"(e,t){var n=function(i){return i.replace(/^\s+|\s+$/g,"")},r=function(i){return Object.prototype.toString.call(i)==="[object Array]"};t.exports=function(i){if(!i)return{};for(var s={},o=n(i).split(`
2
+ `),l=0;l<o.length;l++){var a=o[l],c=a.indexOf(":"),u=n(a.slice(0,c)).toLowerCase(),d=n(a.slice(c+1));typeof s[u]>"u"?s[u]=d:r(s[u])?s[u].push(d):s[u]=[s[u],d]}return s}}}),xl=Gt({"node_modules/xtend/immutable.js"(e,t){t.exports=r;var n=Object.prototype.hasOwnProperty;function r(){for(var i={},s=0;s<arguments.length;s++){var o=arguments[s];for(var l in o)n.call(o,l)&&(i[l]=o[l])}return i}}}),Tl=Gt({"node_modules/xhr/index.js"(e,t){var n=El(),r=_l(),i=Ll(),s=xl();t.exports=c,t.exports.default=c,c.XMLHttpRequest=n.XMLHttpRequest||h,c.XDomainRequest="withCredentials"in new c.XMLHttpRequest?c.XMLHttpRequest:n.XDomainRequest,o(["get","put","post","patch","head","delete"],function(p){c[p==="delete"?"del":p]=function(m,g,y){return g=a(m,g,y),g.method=p.toUpperCase(),u(g)}});function o(p,m){for(var g=0;g<p.length;g++)m(p[g])}function l(p){for(var m in p)if(p.hasOwnProperty(m))return!1;return!0}function a(p,m,g){var y=p;return r(m)?(g=m,typeof p=="string"&&(y={uri:p})):y=s(m,{uri:p}),y.callback=g,y}function c(p,m,g){return m=a(p,m,g),u(m)}function u(p){if(typeof p.callback>"u")throw new Error("callback argument missing");var m=!1,g=function(L,U,V){m||(m=!0,p.callback(L,U,V))};function y(){w.readyState===4&&setTimeout(b,0)}function v(){var L=void 0;if(w.response?L=w.response:L=w.responseText||d(w),K)try{L=JSON.parse(L)}catch{}return L}function f(L){return clearTimeout(F),L instanceof Error||(L=new Error(""+(L||"Unknown XMLHttpRequest Error"))),L.statusCode=0,g(L,P)}function b(){if(!I){var L;clearTimeout(F),p.useXDR&&w.status===void 0?L=200:L=w.status===1223?204:w.status;var U=P,V=null;return L!==0?(U={body:v(),statusCode:L,method:E,headers:{},url:S,rawRequest:w},w.getAllResponseHeaders&&(U.headers=i(w.getAllResponseHeaders()))):V=new Error("Internal XMLHttpRequest Error"),g(V,U,U.body)}}var w=p.xhr||null;w||(p.cors||p.useXDR?w=new c.XDomainRequest:w=new c.XMLHttpRequest);var k,I,S=w.url=p.uri||p.url,E=w.method=p.method||"GET",C=p.body||p.data,x=w.headers=p.headers||{},R=!!p.sync,K=!1,F,P={body:void 0,headers:{},statusCode:0,method:E,url:S,rawRequest:w};if("json"in p&&p.json!==!1&&(K=!0,x.accept||x.Accept||(x.Accept="application/json"),E!=="GET"&&E!=="HEAD"&&(x["content-type"]||x["Content-Type"]||(x["Content-Type"]="application/json"),C=JSON.stringify(p.json===!0?C:p.json))),w.onreadystatechange=y,w.onload=b,w.onerror=f,w.onprogress=function(){},w.onabort=function(){I=!0},w.ontimeout=f,w.open(E,S,!R,p.username,p.password),R||(w.withCredentials=!!p.withCredentials),!R&&p.timeout>0&&(F=setTimeout(function(){if(!I){I=!0,w.abort("timeout");var L=new Error("XMLHttpRequest timeout");L.code="ETIMEDOUT",f(L)}},p.timeout)),w.setRequestHeader)for(k in x)x.hasOwnProperty(k)&&w.setRequestHeader(k,x[k]);else if(p.headers&&!l(p.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in p&&(w.responseType=p.responseType),"beforeSend"in p&&typeof p.beforeSend=="function"&&p.beforeSend(w),w.send(C||null),w}function d(p){try{if(p.responseType==="document")return p.responseXML;var m=p.responseXML&&p.responseXML.documentElement.nodeName==="parsererror";if(p.responseType===""&&!m)return p.responseXML}catch{}return null}function h(){}}});function Mr(e,t,...n){if(!e)throw new TypeError(fs(t,n))}function fs(e,t){let n=0;return e.replace(/%[os]/gu,()=>ys(t[n++]))}function ys(e){return typeof e!="object"||e===null?String(e):Object.prototype.toString.call(e)}var _h;function Rl(e){try{const t=e instanceof Error?e:new Error(ys(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 _e=typeof window<"u"?window:typeof self<"u"?self:typeof global<"u"?global:typeof globalThis<"u"?globalThis:void 0,Lh,$e=class{constructor(e,t){this.code=e,this.message=t}warn(...e){var t;try{const n=((t=new Error().stack)!==null&&t!==void 0?t:"").replace(/^(?:.+?\n){2}/gu,`
3
+ `);console.warn(this.message,...e,n)}catch{}}},Ol=new $e("W01","Unable to initialize event under dispatching."),Ul=new $e("W02","Assigning any falsy value to 'cancelBubble' property has no effect."),Ml=new $e("W03","Assigning any truthy value to 'returnValue' property has no effect."),Dl=new $e("W04","Unable to preventDefault on non-cancelable events."),Nl=new $e("W05","Unable to preventDefault inside passive event listener invocation."),Pl=new $e("W06","An event listener wasn't added because it has been added already: %o, %o"),Dr=new $e("W07","The %o option value was abandoned because the event listener wasn't added as duplicated."),vs=new $e("W08","The 'callback' argument must be a function or an object that has 'handleEvent' method: %o"),Ne=class{static get NONE(){return ws}static get CAPTURING_PHASE(){return bs}static get AT_TARGET(){return Is}static get BUBBLING_PHASE(){return Ss}constructor(e,t){Object.defineProperty(this,"isTrusted",{value:!1,enumerable:!0});const n=t??{};Nr.set(this,{type:String(e),bubbles:!!n.bubbles,cancelable:!!n.cancelable,composed:!!n.composed,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1,inPassiveListenerFlag:!1,dispatchFlag:!1,timeStamp:Date.now()})}get type(){return te(this).type}get target(){return te(this).target}get srcElement(){return te(this).target}get currentTarget(){return te(this).currentTarget}composedPath(){const e=te(this).currentTarget;return e?[e]:[]}get NONE(){return ws}get CAPTURING_PHASE(){return bs}get AT_TARGET(){return Is}get BUBBLING_PHASE(){return Ss}get eventPhase(){return te(this).dispatchFlag?2:0}stopPropagation(){te(this).stopPropagationFlag=!0}get cancelBubble(){return te(this).stopPropagationFlag}set cancelBubble(e){e?te(this).stopPropagationFlag=!0:Ul.warn()}stopImmediatePropagation(){const e=te(this);e.stopPropagationFlag=e.stopImmediatePropagationFlag=!0}get bubbles(){return te(this).bubbles}get cancelable(){return te(this).cancelable}get returnValue(){return!te(this).canceledFlag}set returnValue(e){e?Ml.warn():Cs(te(this))}preventDefault(){Cs(te(this))}get defaultPrevented(){return te(this).canceledFlag}get composed(){return te(this).composed}get isTrusted(){return!1}get timeStamp(){return te(this).timeStamp}initEvent(e,t=!1,n=!1){const r=te(this);if(r.dispatchFlag){Ol.warn();return}Nr.set(this,{...r,type:String(e),bubbles:!!t,cancelable:!!n,target:null,currentTarget:null,stopPropagationFlag:!1,stopImmediatePropagationFlag:!1,canceledFlag:!1})}},ws=0,bs=1,Is=2,Ss=3,Nr=new WeakMap;function te(e,t="this"){const n=Nr.get(e);return Mr(n!=null,"'%s' must be an object that Event constructor created, but got another one: %o",t,e),n}function Cs(e){if(e.inPassiveListenerFlag){Nl.warn();return}if(!e.cancelable){Dl.warn();return}e.canceledFlag=!0}Object.defineProperty(Ne,"NONE",{enumerable:!0}),Object.defineProperty(Ne,"CAPTURING_PHASE",{enumerable:!0}),Object.defineProperty(Ne,"AT_TARGET",{enumerable:!0}),Object.defineProperty(Ne,"BUBBLING_PHASE",{enumerable:!0});var Pr=Object.getOwnPropertyNames(Ne.prototype);for(let e=0;e<Pr.length;++e)Pr[e]!=="constructor"&&Object.defineProperty(Ne.prototype,Pr[e],{enumerable:!0});typeof _e<"u"&&typeof _e.Event<"u"&&Object.setPrototypeOf(Ne.prototype,_e.Event.prototype);function Fl(e){return _e.DOMException?new _e.DOMException(e,"InvalidStateError"):(kt==null&&(kt=class yl extends Error{constructor(n){super(n),Error.captureStackTrace&&Error.captureStackTrace(this,yl)}get code(){return 11}get name(){return"InvalidStateError"}},Object.defineProperties(kt.prototype,{code:{enumerable:!0},name:{enumerable:!0}}),As(kt),As(kt.prototype)),new kt(e))}var kt,ks={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 As(e){const t=Object.keys(ks);for(let n=0;n<t.length;++n){const r=t[n],i=ks[r];Object.defineProperty(e,r,{get(){return i},configurable:!0,enumerable:!0})}}var Tn=class extends Ne{static wrap(e){return new(_s(e))(e)}constructor(e){super(e.type,{bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}),e.cancelBubble&&super.stopPropagation(),e.defaultPrevented&&super.preventDefault(),Es.set(this,{original:e});const t=Object.keys(e);for(let n=0;n<t.length;++n){const r=t[n];r in this||Object.defineProperty(this,r,Ls(e,r))}}stopPropagation(){super.stopPropagation();const{original:e}=He(this);"stopPropagation"in e&&e.stopPropagation()}get cancelBubble(){return super.cancelBubble}set cancelBubble(e){super.cancelBubble=e;const{original:t}=He(this);"cancelBubble"in t&&(t.cancelBubble=e)}stopImmediatePropagation(){super.stopImmediatePropagation();const{original:e}=He(this);"stopImmediatePropagation"in e&&e.stopImmediatePropagation()}get returnValue(){return super.returnValue}set returnValue(e){super.returnValue=e;const{original:t}=He(this);"returnValue"in t&&(t.returnValue=e)}preventDefault(){super.preventDefault();const{original:e}=He(this);"preventDefault"in e&&e.preventDefault()}get timeStamp(){const{original:e}=He(this);return"timeStamp"in e?e.timeStamp:super.timeStamp}},Es=new WeakMap;function He(e){const t=Es.get(e);return Mr(t!=null,"'this' is expected an Event object, but got",e),t}var Rn=new WeakMap;Rn.set(Object.prototype,Tn),typeof _e<"u"&&typeof _e.Event<"u"&&Rn.set(_e.Event.prototype,Tn);function _s(e){const t=Object.getPrototypeOf(e);if(t==null)return Tn;let n=Rn.get(t);return n==null&&(n=Bl(_s(t),t),Rn.set(t,n)),n}function Bl(e,t){class n extends e{}const r=Object.keys(t);for(let i=0;i<r.length;++i)Object.defineProperty(n.prototype,r[i],Ls(t,r[i]));return n}function Ls(e,t){const n=Object.getOwnPropertyDescriptor(e,t);return{get(){const r=He(this).original,i=r[t];return typeof i=="function"?i.bind(r):i},set(r){const i=He(this).original;i[t]=r},configurable:n.configurable,enumerable:n.enumerable}}function jl(e,t,n,r,i,s){return{callback:e,flags:(t?1:0)|(n?2:0)|(r?4:0),signal:i,signalListener:s}}function Kl(e){e.flags|=8}function xs(e){return(e.flags&1)===1}function Ts(e){return(e.flags&2)===2}function Rs(e){return(e.flags&4)===4}function Wl(e){return(e.flags&8)===8}function zl({callback:e},t,n){try{typeof e=="function"?e.call(t,n):typeof e.handleEvent=="function"&&e.handleEvent(n)}catch(r){Rl(r)}}function Os({listeners:e},t,n){for(let r=0;r<e.length;++r)if(e[r].callback===t&&xs(e[r])===n)return r;return-1}function Vl(e,t,n,r,i,s){let o;s&&(o=Us.bind(null,e,t,n),s.addEventListener("abort",o));const l=jl(t,n,r,i,s,o);return e.cow?(e.cow=!1,e.listeners=[...e.listeners,l]):e.listeners.push(l),l}function Us(e,t,n){const r=Os(e,t,n);return r!==-1?Ms(e,r):!1}function Ms(e,t,n=!1){const r=e.listeners[t];return Kl(r),r.signal&&r.signal.removeEventListener("abort",r.signalListener),e.cow&&!n?(e.cow=!1,e.listeners=e.listeners.filter((i,s)=>s!==t),!1):(e.listeners.splice(t,1),!0)}function Gl(){return Object.create(null)}function ql(e,t){var n;return(n=e[t])!==null&&n!==void 0?n:e[t]={attrCallback:void 0,attrListener:void 0,cow:!1,listeners:[]}}var On=class{constructor(){Ds.set(this,Gl())}addEventListener(e,t,n){const r=Fr(this),{callback:i,capture:s,once:o,passive:l,signal:a,type:c}=Zl(e,t,n);if(i==null||a!=null&&a.aborted)return;const u=ql(r,c),d=Os(u,i,s);if(d!==-1){Hl(u.listeners[d],l,o,a);return}Vl(u,i,s,l,o,a)}removeEventListener(e,t,n){const r=Fr(this),{callback:i,capture:s,type:o}=$l(e,t,n),l=r[o];i!=null&&l&&Us(l,i,s)}dispatchEvent(e){const t=Fr(this)[String(e.type)];if(t==null)return!0;const n=e instanceof Ne?e:Tn.wrap(e),r=te(n,"event");if(r.dispatchFlag)throw Fl("This event has been in dispatching.");if(r.dispatchFlag=!0,r.target=r.currentTarget=this,!r.stopPropagationFlag){const{cow:i,listeners:s}=t;t.cow=!0;for(let o=0;o<s.length;++o){const l=s[o];if(!Wl(l)&&(Rs(l)&&Ms(t,o,!i)&&(o-=1),r.inPassiveListenerFlag=Ts(l),zl(l,this,n),r.inPassiveListenerFlag=!1,r.stopImmediatePropagationFlag))break}i||(t.cow=!1)}return r.target=null,r.currentTarget=null,r.stopImmediatePropagationFlag=!1,r.stopPropagationFlag=!1,r.dispatchFlag=!1,!r.canceledFlag}},Ds=new WeakMap;function Fr(e,t="this"){const n=Ds.get(e);return Mr(n!=null,"'%s' must be an object that EventTarget constructor created, but got another one: %o",t,e),n}function Zl(e,t,n){var r;return Ns(t),typeof n=="object"&&n!==null?{type:String(e),callback:t??void 0,capture:!!n.capture,passive:!!n.passive,once:!!n.once,signal:(r=n.signal)!==null&&r!==void 0?r:void 0}:{type:String(e),callback:t??void 0,capture:!!n,passive:!1,once:!1,signal:void 0}}function $l(e,t,n){return Ns(t),typeof n=="object"&&n!==null?{type:String(e),callback:t??void 0,capture:!!n.capture}:{type:String(e),callback:t??void 0,capture:!!n}}function Ns(e){if(!(typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.handleEvent=="function")){if(e==null||typeof e=="object"){vs.warn(e);return}throw new TypeError(fs(vs.message,[e]))}}function Hl(e,t,n,r){Pl.warn(xs(e)?"capture":"bubble",e.callback),Ts(e)!==t&&Dr.warn("passive"),Rs(e)!==n&&Dr.warn("once"),e.signal!==r&&Dr.warn("signal")}var Br=Object.getOwnPropertyNames(On.prototype);for(let e=0;e<Br.length;++e)Br[e]!=="constructor"&&Object.defineProperty(On.prototype,Br[e],{enumerable:!0});typeof _e<"u"&&typeof _e.EventTarget<"u"&&Object.setPrototypeOf(On.prototype,_e.EventTarget.prototype);var Yl=Al(Tl()),Ps=30720,Un=512e3,Mn=256,jr=(e,{minChunkSize:t=Mn,maxChunkSize:n=Un}={})=>e==null||typeof e=="number"&&e>=256&&e%256===0&&e>=t&&e<=n,Kr=(e,{minChunkSize:t=Mn,maxChunkSize:n=Un}={})=>new TypeError(`chunkSize ${e} must be a positive number in multiples of 256, between ${t} and ${n}`),Jl=class{constructor(e,t={}){this.readableStream=e;var n,r,i;if(!jr(t.defaultChunkSize,t))throw Kr(t.defaultChunkSize,t);this.defaultChunkSize=(n=t.defaultChunkSize)!=null?n:Ps,this.minChunkSize=(r=t.minChunkSize)!=null?r:Mn,this.maxChunkSize=(i=t.maxChunkSize)!=null?i:Un}get chunkSize(){var e;return(e=this._chunkSize)!=null?e:this.defaultChunkSize}set chunkSize(e){if(!jr(e,this))throw Kr(e,this);this._chunkSize=e}get chunkByteSize(){return this.chunkSize*1024}async*[Symbol.asyncIterator](){let e;const t=this.readableStream.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n){if(e){const s=e;e=void 0,yield s}break}const i=r instanceof Uint8Array?new Blob([r],{type:"application/octet-stream"}):r;for(e=e?new Blob([e,i]):i;e;)if(e.size===this.chunkByteSize){const s=e;e=void 0,yield s;break}else{if(e.size<this.chunkByteSize)break;{const s=e.slice(0,this.chunkByteSize);e=e.slice(this.chunkByteSize),yield s}}}}finally{if(e){const n=e;e=void 0,yield n}t.releaseLock();return}}},Ql=[200,201,202,204,308],Fs=[408,502,503,504],Xl=[308],Bs=(e,t)=>!!e&&Ql.includes(e.statusCode),ec=(e,{retryCodes:t=Fs})=>!e||t.includes(e.statusCode),tc=(e,t)=>t.attemptCount>=t.attempts||!(Bs(e)||ec(e,t)),nc=(e,t)=>{if(!e||!Xl.includes(e.statusCode)||!e.headers.range)return!1;const n=e.headers.range.match(/bytes=(\d+)-(\d+)/);return n?parseInt(n[2],10)!==t.currentChunkEndByte:!1},js=class{static createUpload(e){return new js(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||Fs,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 Jl(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 On,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:Un}get minChunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.minChunkSize)!=null?t:Mn}get chunkSize(){var e,t;return(t=(e=this.chunkedStreamIterable)==null?void 0:e.chunkSize)!=null?t:Ps}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){const n=new CustomEvent(e,{detail:t});this.eventTarget.dispatchEvent(n)}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(!jr(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){const t=n=>{n.upload.onprogress=r=>{var i;const s=this.totalChunks-this.chunkCount,o=(this.file.size-this.nextChunkRangeStart)/this.file.size/s,l=this.nextChunkRangeStart/this.file.size,a=r.loaded/((i=r.total)!=null?i:this.chunkByteSize)*o;this.dispatch("progress",Math.min((l+a)*100,100))}};return new Promise((n,r)=>{this.currentXhr=(0,Yl.default)({...e,beforeSend:t},(i,s)=>(this.currentXhr=void 0,i?r(i):n(s)))})}async sendChunk(e){const t=this.nextChunkRangeStart,n=t+e.size-1,r={...await(typeof this.headers=="function"?this.headers():this.headers),"Content-Type":this.file.type,"Content-Range":`bytes ${t}-${n}/${this.file.size}`};return this.dispatch("attempt",{chunkNumber:this.chunkCount,totalChunks:this.totalChunks,chunkSize:this.chunkSize}),this.xhrPromise({headers:r,url:this.endpointValue,method:this.method,body:e})}async sendChunkWithRetries(e){const t=async(o,l)=>{var a;const c=(new Date().getTime()-this.lastChunkStart.getTime())/1e3;if(this.dispatch("chunkSuccess",{chunk:this.chunkCount,chunkSize:this.chunkSize,attempts:this.attemptCount,timeInterval:c,response:o}),this.attemptCount=0,this.chunkCount=((a=this.chunkCount)!=null?a:0)+1,this.nextChunkRangeStart=this.nextChunkRangeStart+this.chunkByteSize,this.dynamicChunkSize){let u=this.chunkSize;c<10?u=Math.min(this.chunkSize*2,this.maxChunkSize):c>30&&(u=Math.max(this.chunkSize/2,this.minChunkSize)),this.chunkSize=Math.ceil(u/256)*256;const d=(this.file.size-this.nextChunkRangeStart)/this.chunkByteSize;this.totalChunks=Math.ceil(this.chunkCount+d)}return!0},n=async(o,l)=>(this.dispatch("error",{message:`Server responded with ${o.statusCode}. Stopping upload.`,chunk:this.chunkCount,attempts:this.attemptCount,response:o}),!1),r=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,response:o}),new Promise(a=>{setTimeout(async()=>{if(this._paused||this.offline){this.pendingChunk=e,a(!1);return}const c=await this.sendChunkWithRetries(e);a(c)},this.delayBeforeAttempt*1e3)}));let i;try{this.attemptCount=this.attemptCount+1,this.lastChunkStart=new Date,i=await this.sendChunk(e)}catch{}const s={retryCodes:this.retryCodes,attemptCount:this.attemptCount,attempts:this.attempts,currentChunkEndByte:this.nextChunkRangeStart+e.size-1};return nc(i,s)?r(i):Bs(i)?t(i):tc(i,s)?n(i):r(i)}async sendChunks(){if(this.pendingChunk&&!(this._paused||this.offline)){const e=this.pendingChunk;this.pendingChunk=void 0;const t=await this.sendChunkWithRetries(e);this.success&&t&&this.dispatch("success")}for(;!(this.success||this._paused||this.offline);){const{value:e,done:t}=await this.chunkedStreamIterator.next();let n=!e&&t;if(e&&(n=await this.sendChunkWithRetries(e)),this.success=!!t,this.success&&n&&this.dispatch("success"),!n)return}}};function rc(e){return js.createUpload(e)}var ie;(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"})(ie||(ie={}));function ic(e){return e.nodeType===e.ELEMENT_NODE}function qt(e){var t=e?.host;return t?.shadowRoot===e}function Zt(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function sc(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 oc(e){var t=e.cssText;if(t.split('"').length<3)return t;var n=["@import","url(".concat(JSON.stringify(e.href),")")];return e.layerName===""?n.push("layer"):e.layerName&&n.push("layer(".concat(e.layerName,")")),e.supportsText&&n.push("supports(".concat(e.supportsText,")")),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}function Dn(e){try{var t=e.rules||e.cssRules;return t?sc(Array.from(t).map(Ks).join("")):null}catch{return null}}function Ks(e){var t;if(lc(e))try{t=Dn(e.styleSheet)||oc(e)}catch{}return ac(t||e.cssText)}function ac(e){if(e.includes(":")){var t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}return e}function lc(e){return"styleSheet"in e}var Ws=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var n;if(!t)return-1;var r=(n=this.getMeta(t))===null||n===void 0?void 0:n.id;return r??-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 n=this,r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(function(i){return n.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,n){var r=n.id;this.idNodeMap.set(r,t),this.nodeMetaMap.set(t,n)},e.prototype.replace=function(t,n){var r=this.getNode(t);if(r){var i=this.nodeMetaMap.get(r);i&&this.nodeMetaMap.set(n,i)}this.idNodeMap.set(t,n)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function cc(){return new Ws}function Wr(e){var t=e.element,n=e.maskInputOptions,r=e.tagName,i=e.type,s=e.value,o=e.maskInputFn,l=s||"",a=i&&lt(i);return(n[r.toLowerCase()]||a&&n[a])&&(o?l=o(l,t):l="*".repeat(l.length)),l}function lt(e){return e.toLowerCase()}var zs="__rrweb_original__";function uc(e){var t=e.getContext("2d");if(!t)return!0;for(var n=50,r=0;r<e.width;r+=n)for(var i=0;i<e.height;i+=n){var s=t.getImageData,o=zs in s?s[zs]:s,l=new Uint32Array(o.call(t,r,i,Math.min(n,e.width-r),Math.min(n,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?lt(t):null}var dc=1,pc=new RegExp("[^a-z0-9-_:]"),$t=-2;function Vs(){return dc++}function hc(e){if(e instanceof HTMLFormElement)return"form";var t=lt(e.tagName);return pc.test(t)?"div":t}function mc(e){var t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}var At,Gs,gc=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,fc=/^(?:[a-z+]+:)?\/\//i,yc=/^www\..*/i,vc=/^(data:)([^,]*),(.*)/i;function Nn(e,t){return(e||"").replace(gc,function(n,r,i,s,o,l){var a=i||o||l,c=r||s||"";if(!a)return n;if(fc.test(a)||yc.test(a)||vc.test(a))return"url(".concat(c).concat(a).concat(c,")");if(a[0]==="/")return"url(".concat(c).concat(mc(t)+a).concat(c,")");var u=t.split("/"),d=a.split("/");u.pop();for(var h=0,p=d;h<p.length;h++){var m=p[h];m!=="."&&(m===".."?u.pop():u.push(m))}return"url(".concat(c).concat(u.join("/")).concat(c,")")})}var wc=/^[^ \t\n\r\u000c]+/,bc=/^[, \t\n\r\u000c]+/;function Ic(e,t){if(t.trim()==="")return t;var n=0;function r(c){var u,d=c.exec(t.substring(n));return d?(u=d[0],n+=u.length,u):""}for(var i=[];r(bc),!(n>=t.length);){var s=r(wc);if(s.slice(-1)===",")s=Pn(e,s.substring(0,s.length-1)),i.push(s);else{var o="";s=Pn(e,s);for(var l=!1;;){var a=t.charAt(n);if(a===""){i.push((s+o).trim());break}else if(l)a===")"&&(l=!1);else if(a===","){n+=1,i.push((s+o).trim());break}else a==="("&&(l=!0);o+=a,n+=1}}}return i.join(", ")}function Pn(e,t){if(!t||t.trim()==="")return t;var n=e.createElement("a");return n.href=t,n.href}function Sc(e){return!!(e.tagName==="svg"||e.ownerSVGElement)}function Vr(){var e=document.createElement("a");return e.href="",e.href}function qs(e,t,n,r){return r&&(n==="src"||n==="href"&&!(t==="use"&&r[0]==="#")||n==="xlink:href"&&r[0]!=="#"||n==="background"&&(t==="table"||t==="td"||t==="th")?Pn(e,r):n==="srcset"?Ic(e,r):n==="style"?Nn(r,Vr()):t==="object"&&n==="data"?Pn(e,r):r)}function Zs(e,t,n){return(e==="video"||e==="audio")&&t==="autoplay"}function Cc(e,t,n){try{if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}if(n)return e.matches(n)}catch{}return!1}function Fn(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return n?Fn(e.parentNode,t,n):!1;for(var r=e.classList.length;r--;){var i=e.classList[r];if(t.test(i))return!0}return n?Fn(e.parentNode,t,n):!1}function $s(e,t,n){try{var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(r===null)return!1;if(typeof t=="string"){if(r.classList.contains(t)||r.closest(".".concat(t)))return!0}else if(Fn(r,t,!0))return!0;if(n&&(r.matches(n)||r.closest(n)))return!0}catch{}return!1}function kc(e,t,n){var r=e.contentWindow;if(r){var i=!1,s;try{s=r.document.readyState}catch{return}if(s!=="complete"){var o=setTimeout(function(){i||(t(),i=!0)},n);e.addEventListener("load",function(){clearTimeout(o),i=!0,t()});return}var l="about:blank";if(r.location.href!==l||e.src===l||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}}function Ac(e,t,n){var r=!1,i;try{i=e.sheet}catch{return}if(!i){var s=setTimeout(function(){r||(t(),r=!0)},n);e.addEventListener("load",function(){clearTimeout(s),r=!0,t()})}}function Ec(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,s=t.blockSelector,o=t.maskTextClass,l=t.maskTextSelector,a=t.inlineStylesheet,c=t.maskInputOptions,u=c===void 0?{}:c,d=t.maskTextFn,h=t.maskInputFn,p=t.dataURLOptions,m=p===void 0?{}:p,g=t.inlineImages,y=t.recordCanvas,v=t.keepIframeSrcFn,f=t.newlyAddedElement,b=f===void 0?!1:f,w=_c(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:ie.Document,childNodes:[],compatMode:e.compatMode}:{type:ie.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:ie.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:w};case e.ELEMENT_NODE:return xc(e,{doc:n,blockClass:i,blockSelector:s,inlineStylesheet:a,maskInputOptions:u,maskInputFn:h,dataURLOptions:m,inlineImages:g,recordCanvas:y,keepIframeSrcFn:v,newlyAddedElement:b,rootId:w});case e.TEXT_NODE:return Lc(e,{maskTextClass:o,maskTextSelector:l,maskTextFn:d,rootId:w});case e.CDATA_SECTION_NODE:return{type:ie.CDATA,textContent:"",rootId:w};case e.COMMENT_NODE:return{type:ie.Comment,textContent:e.textContent||"",rootId:w};default:return!1}}function _c(e,t){if(t.hasNode(e)){var n=t.getId(e);return n===1?void 0:n}}function Lc(e,t){var n,r=t.maskTextClass,i=t.maskTextSelector,s=t.maskTextFn,o=t.rootId,l=e.parentNode&&e.parentNode.tagName,a=e.textContent,c=l==="STYLE"?!0:void 0,u=l==="SCRIPT"?!0:void 0;if(c&&a){try{e.nextSibling||e.previousSibling||!((n=e.parentNode.sheet)===null||n===void 0)&&n.cssRules&&(a=Dn(e.parentNode.sheet))}catch(d){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(d),e)}a=Nn(a,Vr())}return u&&(a="SCRIPT_PLACEHOLDER"),!c&&!u&&a&&$s(e,r,i)&&(a=s?s(a):a.replace(/[\S]/g,"*")),{type:ie.Text,textContent:a||"",isStyle:c,rootId:o}}function xc(e,t){for(var n=t.doc,r=t.blockClass,i=t.blockSelector,s=t.inlineStylesheet,o=t.maskInputOptions,l=o===void 0?{}:o,a=t.maskInputFn,c=t.dataURLOptions,u=c===void 0?{}:c,d=t.inlineImages,h=t.recordCanvas,p=t.keepIframeSrcFn,m=t.newlyAddedElement,g=m===void 0?!1:m,y=t.rootId,v=Cc(e,r,i),f=hc(e),b={},w=e.attributes.length,k=0;k<w;k++){var I=e.attributes[k];Zs(f,I.name,I.value)||(b[I.name]=qs(n,f,lt(I.name),I.value))}if(f==="link"&&s){var S=Array.from(n.styleSheets).find(function(ke){return ke.href===e.href}),E=null;S&&(E=Dn(S)),E&&(delete b.rel,delete b.href,b._cssText=Nn(E,S.href))}if(f==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){var E=Dn(e.sheet);E&&(b._cssText=Nn(E,Vr()))}if(f==="input"||f==="textarea"||f==="select"){var C=e.value,x=e.checked;if(b.type!=="radio"&&b.type!=="checkbox"&&b.type!=="submit"&&b.type!=="button"&&C){var R=zr(e);b.value=Wr({element:e,type:R,tagName:f,value:C,maskInputOptions:l,maskInputFn:a})}else x&&(b.checked=x)}if(f==="option"&&(e.selected&&!l.select?b.selected=!0:delete b.selected),f==="canvas"&&h){if(e.__context==="2d")uc(e)||(b.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){var K=e.toDataURL(u.type,u.quality),F=document.createElement("canvas");F.width=e.width,F.height=e.height;var P=F.toDataURL(u.type,u.quality);K!==P&&(b.rr_dataURL=K)}}if(f==="img"&&d){At||(At=n.createElement("canvas"),Gs=At.getContext("2d"));var L=e,U=L.crossOrigin;L.crossOrigin="anonymous";var V=function(){L.removeEventListener("load",V);try{At.width=L.naturalWidth,At.height=L.naturalHeight,Gs.drawImage(L,0,0),b.rr_dataURL=At.toDataURL(u.type,u.quality)}catch(ke){console.warn("Cannot inline img src=".concat(L.currentSrc,"! Error: ").concat(ke))}U?b.crossOrigin=U:L.removeAttribute("crossorigin")};L.complete&&L.naturalWidth!==0?V():L.addEventListener("load",V)}if((f==="audio"||f==="video")&&(b.rr_mediaState=e.paused?"paused":"played",b.rr_mediaCurrentTime=e.currentTime),g||(e.scrollLeft&&(b.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(b.rr_scrollTop=e.scrollTop)),v){var re=e.getBoundingClientRect(),ae=re.width,ue=re.height;b={class:b.class,rr_width:"".concat(ae,"px"),rr_height:"".concat(ue,"px")}}return f==="iframe"&&!p(b.src)&&(e.contentDocument||(b.rr_src=b.src),delete b.src),{type:ie.Element,tagName:f,attributes:b,childNodes:[],isSVG:Sc(e)||void 0,needBlock:v,rootId:y}}function Z(e){return e==null?"":e.toLowerCase()}function Tc(e,t){return!!(t.comment&&e.type===ie.Comment||e.type===ie.Element&&(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"))||t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(Z(e.attributes.name).match(/^msapplication-tile(image|color)$/)||Z(e.attributes.name)==="application-name"||Z(e.attributes.rel)==="icon"||Z(e.attributes.rel)==="apple-touch-icon"||Z(e.attributes.rel)==="shortcut icon"))||e.tagName==="meta"&&(t.headMetaDescKeywords&&Z(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(Z(e.attributes.property).match(/^(og|twitter|fb):/)||Z(e.attributes.name).match(/^(og|twitter):/)||Z(e.attributes.name)==="pinterest")||t.headMetaRobots&&(Z(e.attributes.name)==="robots"||Z(e.attributes.name)==="googlebot"||Z(e.attributes.name)==="bingbot")||t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0||t.headMetaAuthorship&&(Z(e.attributes.name)==="author"||Z(e.attributes.name)==="generator"||Z(e.attributes.name)==="framework"||Z(e.attributes.name)==="publisher"||Z(e.attributes.name)==="progid"||Z(e.attributes.property).match(/^article:/)||Z(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(Z(e.attributes.name)==="google-site-verification"||Z(e.attributes.name)==="yandex-verification"||Z(e.attributes.name)==="csrf-token"||Z(e.attributes.name)==="p:domain_verify"||Z(e.attributes.name)==="verify-v1"||Z(e.attributes.name)==="verification"||Z(e.attributes.name)==="shopify-checkout-api-token"))))}function Et(e,t){var n=t.doc,r=t.mirror,i=t.blockClass,s=t.blockSelector,o=t.maskTextClass,l=t.maskTextSelector,a=t.skipChild,c=a===void 0?!1:a,u=t.inlineStylesheet,d=u===void 0?!0:u,h=t.maskInputOptions,p=h===void 0?{}:h,m=t.maskTextFn,g=t.maskInputFn,y=t.slimDOMOptions,v=t.dataURLOptions,f=v===void 0?{}:v,b=t.inlineImages,w=b===void 0?!1:b,k=t.recordCanvas,I=k===void 0?!1:k,S=t.onSerialize,E=t.onIframeLoad,C=t.iframeLoadTimeout,x=C===void 0?5e3:C,R=t.onStylesheetLoad,K=t.stylesheetLoadTimeout,F=K===void 0?5e3:K,P=t.keepIframeSrcFn,L=P===void 0?function(){return!1}:P,U=t.newlyAddedElement,V=U===void 0?!1:U,re=t.preserveWhiteSpace,ae=re===void 0?!0:re,ue=Ec(e,{doc:n,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:g,dataURLOptions:f,inlineImages:w,recordCanvas:I,keepIframeSrcFn:L,newlyAddedElement:V});if(!ue)return console.warn(e,"not serialized"),null;var ke;r.hasNode(e)?ke=r.getId(e):Tc(ue,y)||!ae&&ue.type===ie.Text&&!ue.isStyle&&!ue.textContent.replace(/^\s+|\s+$/gm,"").length?ke=$t:ke=Vs();var J=Object.assign(ue,{id:ke});if(r.add(e,J),ke===$t)return null;S&&S(e);var Ct=!c;if(J.type===ie.Element){Ct=Ct&&!J.needBlock,delete J.needBlock;var Vt=e.shadowRoot;Vt&&Zt(Vt)&&(J.isShadowHost=!0)}if((J.type===ie.Document||J.type===ie.Element)&&Ct){y.headWhitespace&&J.type===ie.Element&&J.tagName==="head"&&(ae=!1);for(var xn={doc:n,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:c,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:g,slimDOMOptions:y,dataURLOptions:f,inlineImages:w,recordCanvas:I,preserveWhiteSpace:ae,onSerialize:S,onIframeLoad:E,iframeLoadTimeout:x,onStylesheetLoad:R,stylesheetLoadTimeout:F,keepIframeSrcFn:L},Ae=0,Re=Array.from(e.childNodes);Ae<Re.length;Ae++){var ot=Re[Ae],Ee=Et(ot,xn);Ee&&J.childNodes.push(Ee)}if(ic(e)&&e.shadowRoot)for(var M=0,ve=Array.from(e.shadowRoot.childNodes);M<ve.length;M++){var ot=ve[M],Ee=Et(ot,xn);Ee&&(Zt(e.shadowRoot)&&(Ee.isShadow=!0),J.childNodes.push(Ee))}}return e.parentNode&&qt(e.parentNode)&&Zt(e.parentNode)&&(J.isShadow=!0),J.type===ie.Element&&J.tagName==="iframe"&&kc(e,function(){var G=e.contentDocument;if(G&&E){var le=Et(G,{doc:G,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:g,slimDOMOptions:y,dataURLOptions:f,inlineImages:w,recordCanvas:I,preserveWhiteSpace:ae,onSerialize:S,onIframeLoad:E,iframeLoadTimeout:x,onStylesheetLoad:R,stylesheetLoadTimeout:F,keepIframeSrcFn:L});le&&E(e,le)}},x),J.type===ie.Element&&J.tagName==="link"&&J.attributes.rel==="stylesheet"&&Ac(e,function(){if(R){var G=Et(e,{doc:n,mirror:r,blockClass:i,blockSelector:s,maskTextClass:o,maskTextSelector:l,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:g,slimDOMOptions:y,dataURLOptions:f,inlineImages:w,recordCanvas:I,preserveWhiteSpace:ae,onSerialize:S,onIframeLoad:E,iframeLoadTimeout:x,onStylesheetLoad:R,stylesheetLoadTimeout:F,keepIframeSrcFn:L});G&&R(e,G)}},F),J}function Rc(e,t){var n=t||{},r=n.mirror,i=r===void 0?new Ws:r,s=n.blockClass,o=s===void 0?"rr-block":s,l=n.blockSelector,a=l===void 0?null:l,c=n.maskTextClass,u=c===void 0?"rr-mask":c,d=n.maskTextSelector,h=d===void 0?null:d,p=n.inlineStylesheet,m=p===void 0?!0:p,g=n.inlineImages,y=g===void 0?!1:g,v=n.recordCanvas,f=v===void 0?!1:v,b=n.maskAllInputs,w=b===void 0?!1:b,k=n.maskTextFn,I=n.maskInputFn,S=n.slimDOM,E=S===void 0?!1:S,C=n.dataURLOptions,x=n.preserveWhiteSpace,R=n.onSerialize,K=n.onIframeLoad,F=n.iframeLoadTimeout,P=n.onStylesheetLoad,L=n.stylesheetLoadTimeout,U=n.keepIframeSrcFn,V=U===void 0?function(){return!1}:U,re=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,ae=E===!0||E==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:E==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:E===!1?{}:E;return Et(e,{doc:e,mirror:i,blockClass:o,blockSelector:a,maskTextClass:u,maskTextSelector:h,skipChild:!1,inlineStylesheet:m,maskInputOptions:re,maskTextFn:k,maskInputFn:I,slimDOMOptions:ae,dataURLOptions:C,inlineImages:y,recordCanvas:f,preserveWhiteSpace:x,onSerialize:R,onIframeLoad:K,iframeLoadTimeout:F,onStylesheetLoad:P,stylesheetLoadTimeout:L,keepIframeSrcFn:V,newlyAddedElement:!1})}function he(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const _t=`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 Hs={map:{},getId(){return console.error(_t),-1},getNode(){return console.error(_t),null},removeNodeFromMap(){console.error(_t)},has(){return console.error(_t),!1},reset(){console.error(_t)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(Hs=new Proxy(Hs,{get(e,t,n){return t==="map"&&console.error(_t),Reflect.get(e,t,n)}}));function Ht(e,t,n={}){let r=null,i=0;return function(...s){const o=Date.now();!i&&n.leading===!1&&(i=o);const l=t-(o-i),a=this;l<=0||l>t?(r&&(clearTimeout(r),r=null),i=o,e.apply(a,s)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{i=n.leading===!1?0:Date.now(),r=null,e.apply(a,s)},l))}}function Bn(e,t,n,r,i=window){const s=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(o){setTimeout(()=>{n.set.call(this,o)},0),s&&s.set&&s.set.call(this,o)}}),()=>Bn(e,t,s||{},!0)}function Yt(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],i=n(r);return typeof i=="function"&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch{return()=>{}}}let jn=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(jn=()=>new Date().getTime());function Ys(e){var t,n,r,i,s,o;const l=e.document;return{left:l.scrollingElement?l.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:l?.documentElement.scrollLeft||((n=(t=l?.body)===null||t===void 0?void 0:t.parentElement)===null||n===void 0?void 0:n.scrollLeft)||((r=l?.body)===null||r===void 0?void 0:r.scrollLeft)||0,top:l.scrollingElement?l.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:l?.documentElement.scrollTop||((s=(i=l?.body)===null||i===void 0?void 0:i.parentElement)===null||s===void 0?void 0:s.scrollTop)||((o=l?.body)===null||o===void 0?void 0:o.scrollTop)||0}}function Js(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Qs(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function me(e,t,n,r){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)||r&&i.closest("."+t)!==null)return!0}else if(Fn(i,t,r))return!0}catch{}return!!(n&&(i.matches(n)||r&&i.closest(n)!==null))}function Oc(e,t){return t.getId(e)!==-1}function Gr(e,t){return t.getId(e)===$t}function Xs(e,t){if(qt(e))return!1;const n=t.getId(e);return t.has(n)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Xs(e.parentNode,t):!0:!0}function qr(e){return!!e.changedTouches}function Uc(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 n=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===n)return!0;while(n=n&&n.parentNode);return!1})}function eo(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function to(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Zr(e){return!!(e!=null&&e.shadowRoot)}class Mc{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var n;return(n=this.styleIDMap.get(t))!==null&&n!==void 0?n:-1}has(t){return this.styleIDMap.has(t)}add(t,n){if(this.has(t))return this.getId(t);let r;return n===void 0?r=this.id++:r=n,this.styleIDMap.set(t,r),this.idStyleMap.set(r,t),r}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 no(e){var t,n;let r=null;return((n=(t=e.getRootNode)===null||t===void 0?void 0:t.call(e))===null||n===void 0?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function Dc(e){let t=e,n;for(;n=no(t);)t=n;return t}function Nc(e){const t=e.ownerDocument;if(!t)return!1;const n=Dc(e);return t.contains(n)}function ro(e){const t=e.ownerDocument;return t?t.contains(e)||Nc(e):!1}var W=(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))(W||{}),z=(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))(z||{}),we=(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))(we||{}),Pe=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Pe||{}),Lt=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Lt||{});function io(e){return"__ln"in e}class Pc{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 n=this.head;for(let r=0;r<t;r++)n=n?.next||null;return n}addNode(t){const n={value:t,previous:null,next:null};if(t.__ln=n,t.previousSibling&&io(t.previousSibling)){const r=t.previousSibling.__ln.next;n.next=r,n.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=n,r&&(r.previous=n)}else if(t.nextSibling&&io(t.nextSibling)&&t.nextSibling.__ln.previous){const r=t.nextSibling.__ln.previous;n.previous=r,n.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=n,r&&(r.next=n)}else this.head&&(this.head.previous=n),n.next=this.head,this.head=n;n.next===null&&(this.tail=n),this.length++}removeNode(t){const n=t.__ln;this.head&&(n.previous?(n.previous.next=n.next,n.next?n.next.previous=n.previous:this.tail=n.previous):(this.head=n.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const so=(e,t)=>`${e}@${t}`;class Fc{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=[],n=new Set,r=new Pc,i=a=>{let c=a,u=$t;for(;u===$t;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},s=a=>{if(!a.parentNode||!ro(a))return;const c=qt(a.parentNode)?this.mirror.getId(no(a)):this.mirror.getId(a.parentNode),u=i(a);if(c===-1||u===-1)return r.addNode(a);const d=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:h=>{eo(h,this.mirror)&&this.iframeManager.addIframe(h),to(h,this.mirror)&&this.stylesheetManager.trackLinkElement(h),Zr(a)&&this.shadowDomManager.addShadowRoot(a.shadowRoot,this.doc)},onIframeLoad:(h,p)=>{this.iframeManager.attachIframe(h,p),this.shadowDomManager.observeAttachShadow(h)},onStylesheetLoad:(h,p)=>{this.stylesheetManager.attachLinkElement(h,p)}});d&&(t.push({parentId:c,nextId:u,node:d}),n.add(d.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const a of this.movedSet)oo(this.removes,a,this.mirror)&&!this.movedSet.has(a.parentNode)||s(a);for(const a of this.addedSet)!lo(this.droppedSet,a)&&!oo(this.removes,a,this.mirror)||lo(this.movedSet,a)?s(a):this.droppedSet.add(a);let o=null;for(;r.length;){let a=null;if(o){const c=this.mirror.getId(o.value.parentNode),u=i(o.value);c!==-1&&u!==-1&&(a=o)}if(!a){let c=r.tail;for(;c;){const u=c;if(c=c.previous,u){const d=this.mirror.getId(u.value.parentNode);if(i(u.value)===-1)continue;if(d!==-1){a=u;break}else{const h=u.value;if(h.parentNode&&h.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const p=h.parentNode.host;if(this.mirror.getId(p)!==-1){a=u;break}}}}}}if(!a){for(;r.head;)r.removeNode(r.head.value);break}o=a.previous,r.removeNode(a.value),s(a.value)}const l={texts:this.texts.map(a=>({id:this.mirror.getId(a.node),value:a.value})).filter(a=>!n.has(a.id)).filter(a=>this.mirror.has(a.id)),attributes:this.attributes.map(a=>{const{attributes:c}=a;if(typeof c.style=="string"){const u=JSON.stringify(a.styleDiff),d=JSON.stringify(a._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=a.styleDiff)}return{id:this.mirror.getId(a.node),attributes:c}}).filter(a=>!n.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 n;try{n=document.implementation.createHTMLDocument()}catch{n=this.doc}switch(t.type){case"characterData":{const r=t.target.textContent;!me(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:$s(t.target,this.maskTextClass,this.maskTextSelector)&&r?this.maskTextFn?this.maskTextFn(r):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let i=t.attributeName,s=t.target.getAttribute(i);if(i==="value"){const l=zr(r);s=Wr({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:l,value:s,maskInputFn:this.maskInputFn})}if(me(t.target,this.blockClass,this.blockSelector,!1)||s===t.oldValue)return;let o=this.attributes.find(l=>l.node===t.target);if(r.tagName==="IFRAME"&&i==="src"&&!this.keepIframeSrcFn(s))if(!r.contentDocument)i="rr_src";else return;if(o||(o={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o)),i==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Zs(r.tagName,i)&&(o.attributes[i]=qs(this.doc,lt(r.tagName),lt(i),s),i==="style")){const l=n.createElement("span");t.oldValue&&l.setAttribute("style",t.oldValue);for(const a of Array.from(r.style)){const c=r.style.getPropertyValue(a),u=r.style.getPropertyPriority(a);c!==l.style.getPropertyValue(a)||u!==l.style.getPropertyPriority(a)?u===""?o.styleDiff[a]=c:o.styleDiff[a]=[c,u]:o._unchangedStyles[a]=[c,u]}for(const a of Array.from(l.style))r.style.getPropertyValue(a)===""&&(o.styleDiff[a]=!1)}break}case"childList":{if(me(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const i=this.mirror.getId(r),s=qt(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);me(t.target,this.blockClass,this.blockSelector,!1)||Gr(r,this.mirror)||!Oc(r,this.mirror)||(this.addedSet.has(r)?($r(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&i===-1||Xs(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[so(i,s)]?$r(this.movedSet,r):this.removes.push({parentId:s,id:i,isShadow:qt(t.target)&&Zt(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(t,n)=>{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 r=null;n&&this.mirror.hasNode(n)&&(r=this.mirror.getId(n)),r&&r!==-1&&(this.movedMap[so(this.mirror.getId(t),r)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);me(t,this.blockClass,this.blockSelector,!1)||(t.childNodes.forEach(r=>this.genAdds(r)),Zr(t)&&t.shadowRoot.childNodes.forEach(r=>{this.processedNodeManager.add(r,this),this.genAdds(r,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(n=>{this[n]=t[n]})}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 $r(e,t){e.delete(t),t.childNodes.forEach(n=>$r(e,n))}function oo(e,t,n){return e.length===0?!1:ao(e,t,n)}function ao(e,t,n){const{parentNode:r}=t;if(!r)return!1;const i=n.getId(r);return e.some(s=>s.id===i)?!0:ao(e,r,n)}function lo(e,t){return e.size===0?!1:co(e,t)}function co(e,t){const{parentNode:n}=t;return n?e.has(n)?!0:co(e,n):!1}let Jt;function Bc(e){Jt=e}function jc(){Jt=void 0}const B=e=>Jt?(...t)=>{try{return e(...t)}catch(n){if(Jt&&Jt(n)===!0)return;throw n}}:e,ct=[];function Qt(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 uo(e,t){var n,r;const i=new Fc;ct.push(i),i.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const o=(r=(n=window?.Zone)===null||n===void 0?void 0:n.__symbol__)===null||r===void 0?void 0:r.call(n,"MutationObserver");o&&window[o]&&(s=window[o]);const l=new s(B(i.processMutations.bind(i)));return l.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l}function Kc({mousemoveCb:e,sampling:t,doc:n,mirror:r}){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=Ht(B(d=>{const h=Date.now()-l;e(o.map(p=>(p.timeOffset-=h,p)),d),o=[],l=null}),s),c=B(Ht(B(d=>{const h=Qt(d),{clientX:p,clientY:m}=qr(d)?d.changedTouches[0]:d;l||(l=jn()),o.push({x:p,y:m,id:r.getId(h),timeOffset:jn()-l}),a(typeof DragEvent<"u"&&d instanceof DragEvent?z.Drag:d instanceof MouseEvent?z.MouseMove:z.TouchMove)}),i,{trailing:!1})),u=[he("mousemove",c,n),he("touchmove",c,n),he("drag",c,n)];return B(()=>{u.forEach(d=>d())})}function Wc({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,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 c=u=>d=>{const h=Qt(d);if(me(h,r,i,!0))return;let p=null,m=u;if("pointerType"in d){switch(d.pointerType){case"mouse":p=Pe.Mouse;break;case"touch":p=Pe.Touch;break;case"pen":p=Pe.Pen;break}p===Pe.Touch?we[u]===we.MouseDown?m="TouchStart":we[u]===we.MouseUp&&(m="TouchEnd"):Pe.Pen}else qr(d)&&(p=Pe.Touch);p!==null?(a=p,(m.startsWith("Touch")&&p===Pe.Touch||m.startsWith("Mouse")&&p===Pe.Mouse)&&(p=null)):we[u]===we.Click&&(p=a,a=null);const g=qr(d)?d.changedTouches[0]:d;if(!g)return;const y=n.getId(h),{clientX:v,clientY:f}=g;B(e)(Object.assign({type:we[m],id:y,x:v,y:f},p!==null&&{pointerType:p}))};return Object.keys(we).filter(u=>Number.isNaN(Number(u))&&!u.endsWith("_Departed")&&o[u]!==!1).forEach(u=>{let d=lt(u);const h=c(u);if(window.PointerEvent)switch(we[u]){case we.MouseDown:case we.MouseUp:d=d.replace("mouse","pointer");break;case we.TouchStart:case we.TouchEnd:return}l.push(he(d,h,t))}),B(()=>{l.forEach(u=>u())})}function po({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:s}){const o=B(Ht(B(l=>{const a=Qt(l);if(!a||me(a,r,i,!0))return;const c=n.getId(a);if(a===t&&t.defaultView){const u=Ys(t.defaultView);e({id:c,x:u.left,y:u.top})}else e({id:c,x:a.scrollLeft,y:a.scrollTop})}),s.scroll||100));return he("scroll",o,t)}function zc({viewportResizeCb:e},{win:t}){let n=-1,r=-1;const i=B(Ht(B(()=>{const s=Js(),o=Qs();(n!==s||r!==o)&&(e({width:Number(o),height:Number(s)}),n=s,r=o)}),200));return he("resize",i,t)}function ho(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const Vc=["INPUT","TEXTAREA","SELECT"],mo=new WeakMap;function Gc({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:s,ignoreSelector:o,maskInputOptions:l,maskInputFn:a,sampling:c,userTriggeredOnInput:u}){function d(v){let f=Qt(v);const b=v.isTrusted,w=f&&f.tagName;if(f&&w==="OPTION"&&(f=f.parentElement),!f||!w||Vc.indexOf(w)<0||me(f,r,i,!0)||f.classList.contains(s)||o&&f.matches(o))return;let k=f.value,I=!1;const S=zr(f)||"";S==="radio"||S==="checkbox"?I=f.checked:(l[w.toLowerCase()]||l[S])&&(k=Wr({element:f,maskInputOptions:l,tagName:w,type:S,value:k,maskInputFn:a})),h(f,B(ho)({text:k,isChecked:I,userTriggered:b},u));const E=f.name;S==="radio"&&E&&I&&t.querySelectorAll(`input[type="radio"][name="${E}"]`).forEach(C=>{C!==f&&h(C,B(ho)({text:C.value,isChecked:!I,userTriggered:!1},u))})}function h(v,f){const b=mo.get(v);if(!b||b.text!==f.text||b.isChecked!==f.isChecked){mo.set(v,f);const w=n.getId(v);B(e)(Object.assign(Object.assign({},f),{id:w}))}}const p=(c.input==="last"?["change"]:["input","change"]).map(v=>he(v,B(d),t)),m=t.defaultView;if(!m)return()=>{p.forEach(v=>v())};const g=m.Object.getOwnPropertyDescriptor(m.HTMLInputElement.prototype,"value"),y=[[m.HTMLInputElement.prototype,"value"],[m.HTMLInputElement.prototype,"checked"],[m.HTMLSelectElement.prototype,"value"],[m.HTMLTextAreaElement.prototype,"value"],[m.HTMLSelectElement.prototype,"selectedIndex"],[m.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&p.push(...y.map(v=>Bn(v[0],v[1],{set(){B(d)({target:this,isTrusted:!1})}},!1,m))),B(()=>{p.forEach(v=>v())})}function Kn(e){const t=[];function n(r,i){if(Wn("CSSGroupingRule")&&r.parentRule instanceof CSSGroupingRule||Wn("CSSMediaRule")&&r.parentRule instanceof CSSMediaRule||Wn("CSSSupportsRule")&&r.parentRule instanceof CSSSupportsRule||Wn("CSSConditionRule")&&r.parentRule instanceof CSSConditionRule){const s=Array.from(r.parentRule.cssRules).indexOf(r);i.unshift(s)}else if(r.parentStyleSheet){const s=Array.from(r.parentStyleSheet.cssRules).indexOf(r);i.unshift(s)}return i}return n(e,t)}function Ye(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function qc({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const i=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:B((u,d,h)=>{const[p,m]=h,{id:g,styleId:y}=Ye(d,t,n.styleMirror);return(g&&g!==-1||y&&y!==-1)&&e({id:g,styleId:y,adds:[{rule:p,index:m}]}),u.apply(d,h)})});const s=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:B((u,d,h)=>{const[p]=h,{id:m,styleId:g}=Ye(d,t,n.styleMirror);return(m&&m!==-1||g&&g!==-1)&&e({id:m,styleId:g,removes:[{index:p}]}),u.apply(d,h)})});let o;r.CSSStyleSheet.prototype.replace&&(o=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(o,{apply:B((u,d,h)=>{const[p]=h,{id:m,styleId:g}=Ye(d,t,n.styleMirror);return(m&&m!==-1||g&&g!==-1)&&e({id:m,styleId:g,replace:p}),u.apply(d,h)})}));let l;r.CSSStyleSheet.prototype.replaceSync&&(l=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(l,{apply:B((u,d,h)=>{const[p]=h,{id:m,styleId:g}=Ye(d,t,n.styleMirror);return(m&&m!==-1||g&&g!==-1)&&e({id:m,styleId:g,replaceSync:p}),u.apply(d,h)})}));const a={};zn("CSSGroupingRule")?a.CSSGroupingRule=r.CSSGroupingRule:(zn("CSSMediaRule")&&(a.CSSMediaRule=r.CSSMediaRule),zn("CSSConditionRule")&&(a.CSSConditionRule=r.CSSConditionRule),zn("CSSSupportsRule")&&(a.CSSSupportsRule=r.CSSSupportsRule));const c={};return Object.entries(a).forEach(([u,d])=>{c[u]={insertRule:d.prototype.insertRule,deleteRule:d.prototype.deleteRule},d.prototype.insertRule=new Proxy(c[u].insertRule,{apply:B((h,p,m)=>{const[g,y]=m,{id:v,styleId:f}=Ye(p.parentStyleSheet,t,n.styleMirror);return(v&&v!==-1||f&&f!==-1)&&e({id:v,styleId:f,adds:[{rule:g,index:[...Kn(p),y||0]}]}),h.apply(p,m)})}),d.prototype.deleteRule=new Proxy(c[u].deleteRule,{apply:B((h,p,m)=>{const[g]=m,{id:y,styleId:v}=Ye(p.parentStyleSheet,t,n.styleMirror);return(y&&y!==-1||v&&v!==-1)&&e({id:y,styleId:v,removes:[{index:[...Kn(p),g]}]}),h.apply(p,m)})})}),B(()=>{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=s,o&&(r.CSSStyleSheet.prototype.replace=o),l&&(r.CSSStyleSheet.prototype.replaceSync=l),Object.entries(a).forEach(([u,d])=>{d.prototype.insertRule=c[u].insertRule,d.prototype.deleteRule=c[u].deleteRule})})}function go({mirror:e,stylesheetManager:t},n){var r,i,s;let o=null;n.nodeName==="#document"?o=e.getId(n):o=e.getId(n.host);const l=n.nodeName==="#document"?(r=n.defaultView)===null||r===void 0?void 0:r.Document:(s=(i=n.ownerDocument)===null||i===void 0?void 0:i.defaultView)===null||s===void 0?void 0:s.ShadowRoot,a=Object.getOwnPropertyDescriptor(l?.prototype,"adoptedStyleSheets");return o===null||o===-1||!l||!a?()=>{}:(Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get(){var c;return(c=a.get)===null||c===void 0?void 0:c.call(this)},set(c){var u;const d=(u=a.set)===null||u===void 0?void 0:u.call(this,c);if(o!==null&&o!==-1)try{t.adoptStyleSheets(c,o)}catch{}return d}}),B(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:a.configurable,enumerable:a.enumerable,get:a.get,set:a.set})}))}function Zc({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){const s=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:B((l,a,c)=>{var u;const[d,h,p]=c;if(n.has(d))return s.apply(a,[d,h,p]);const{id:m,styleId:g}=Ye((u=a.parentRule)===null||u===void 0?void 0:u.parentStyleSheet,t,r.styleMirror);return(m&&m!==-1||g&&g!==-1)&&e({id:m,styleId:g,set:{property:d,value:h,priority:p},index:Kn(a.parentRule)}),l.apply(a,c)})});const o=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(o,{apply:B((l,a,c)=>{var u;const[d]=c;if(n.has(d))return o.apply(a,[d]);const{id:h,styleId:p}=Ye((u=a.parentRule)===null||u===void 0?void 0:u.parentStyleSheet,t,r.styleMirror);return(h&&h!==-1||p&&p!==-1)&&e({id:h,styleId:p,remove:{property:d},index:Kn(a.parentRule)}),l.apply(a,c)})}),B(()=>{i.CSSStyleDeclaration.prototype.setProperty=s,i.CSSStyleDeclaration.prototype.removeProperty=o})}function $c({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i,doc:s}){const o=B(a=>Ht(B(c=>{const u=Qt(c);if(!u||me(u,t,n,!0))return;const{currentTime:d,volume:h,muted:p,playbackRate:m}=u;e({type:a,id:r.getId(u),currentTime:d,volume:h,muted:p,playbackRate:m})}),i.media||500)),l=[he("play",o(0),s),he("pause",o(1),s),he("seeked",o(2),s),he("volumechange",o(3),s),he("ratechange",o(4),s)];return B(()=>{l.forEach(a=>a())})}function Hc({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],i=new WeakMap,s=n.FontFace;n.FontFace=function(l,a,c){const u=new s(l,a,c);return i.set(u,{family:l,buffer:typeof a!="string",descriptors:c,fontSource:typeof a=="string"?a:JSON.stringify(Array.from(new Uint8Array(a)))}),u};const o=Yt(t.fonts,"add",function(l){return function(a){return setTimeout(B(()=>{const c=i.get(a);c&&(e(c),i.delete(a))}),0),l.apply(this,[a])}});return r.push(()=>{n.FontFace=s}),r.push(o),B(()=>{r.forEach(l=>l())})}function Yc(e){const{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:s}=e;let o=!0;const l=B(()=>{const a=t.getSelection();if(!a||o&&a!=null&&a.isCollapsed)return;o=a.isCollapsed||!1;const c=[],u=a.rangeCount||0;for(let d=0;d<u;d++){const h=a.getRangeAt(d),{startContainer:p,startOffset:m,endContainer:g,endOffset:y}=h;me(p,r,i,!0)||me(g,r,i,!0)||c.push({start:n.getId(p),startOffset:m,end:n.getId(g),endOffset:y})}s({ranges:c})});return l(),he("selectionchange",l)}function Jc(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:s,viewportResizeCb:o,inputCb:l,mediaInteractionCb:a,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p}=e;e.mutationCb=(...m)=>{t.mutation&&t.mutation(...m),n(...m)},e.mousemoveCb=(...m)=>{t.mousemove&&t.mousemove(...m),r(...m)},e.mouseInteractionCb=(...m)=>{t.mouseInteraction&&t.mouseInteraction(...m),i(...m)},e.scrollCb=(...m)=>{t.scroll&&t.scroll(...m),s(...m)},e.viewportResizeCb=(...m)=>{t.viewportResize&&t.viewportResize(...m),o(...m)},e.inputCb=(...m)=>{t.input&&t.input(...m),l(...m)},e.mediaInteractionCb=(...m)=>{t.mediaInteaction&&t.mediaInteaction(...m),a(...m)},e.styleSheetRuleCb=(...m)=>{t.styleSheetRule&&t.styleSheetRule(...m),c(...m)},e.styleDeclarationCb=(...m)=>{t.styleDeclaration&&t.styleDeclaration(...m),u(...m)},e.canvasMutationCb=(...m)=>{t.canvasMutation&&t.canvasMutation(...m),d(...m)},e.fontCb=(...m)=>{t.font&&t.font(...m),h(...m)},e.selectionCb=(...m)=>{t.selection&&t.selection(...m),p(...m)}}function Qc(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};Jc(e,t);const r=uo(e,e.doc),i=Kc(e),s=Wc(e),o=po(e),l=zc(e,{win:n}),a=Gc(e),c=$c(e),u=qc(e,{win:n}),d=go(e,e.doc),h=Zc(e,{win:n}),p=e.collectFonts?Hc(e):()=>{},m=Yc(e),g=[];for(const y of e.plugins)g.push(y.observer(y.callback,n,y.options));return B(()=>{ct.forEach(y=>y.reset()),r.disconnect(),i(),s(),o(),l(),a(),c(),u(),d(),h(),p(),m(),g.forEach(y=>y())})}function Wn(e){return typeof window[e]<"u"}function zn(e){return!!(typeof window[e]<"u"&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class fo{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,n,r,i){const s=r||this.getIdToRemoteIdMap(t),o=i||this.getRemoteIdToIdMap(t);let l=s.get(n);return l||(l=this.generateIdFn(),s.set(n,l),o.set(l,n)),l}getIds(t,n){const r=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return n.map(s=>this.getId(t,s,r,i))}getRemoteId(t,n,r){const i=r||this.getRemoteIdToIdMap(t);return typeof n!="number"?n:i.get(n)||-1}getRemoteIds(t,n){const r=this.getRemoteIdToIdMap(t);return n.map(i=>this.getRemoteId(t,i,r))}reset(t){if(!t){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let n=this.iframeIdToRemoteIdMap.get(t);return n||(n=new Map,this.iframeIdToRemoteIdMap.set(t,n)),n}getRemoteIdToIdMap(t){let n=this.iframeRemoteIdToIdMap.get(t);return n||(n=new Map,this.iframeRemoteIdToIdMap.set(t,n)),n}}class Xc{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new fo(Vs),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new fo(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,n){var r;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:n}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),(r=this.loadListener)===null||r===void 0||r.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 n=t;if(n.data.type!=="rrweb"||n.origin!==n.data.origin||!t.source)return;const r=this.crossOriginIframeMap.get(t.source);if(!r)return;const i=this.transformCrossOriginEvent(r,n.data.event);i&&this.wrappedEmit(i,n.data.isCheckout)}transformCrossOriginEvent(t,n){var r;switch(n.type){case W.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(n.data.node,t);const i=n.data.node.id;return this.crossOriginIframeRootIdMap.set(t,i),this.patchRootIdOnNode(n.data.node,i),{timestamp:n.timestamp,type:W.IncrementalSnapshot,data:{source:z.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:n.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case W.Meta:case W.Load:case W.DomContentLoaded:return!1;case W.Plugin:return n;case W.Custom:return this.replaceIds(n.data.payload,t,["id","parentId","previousId","nextId"]),n;case W.IncrementalSnapshot:switch(n.data.source){case z.Mutation:return n.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)}),n.data.removes.forEach(i=>{this.replaceIds(i,t,["parentId","id"])}),n.data.attributes.forEach(i=>{this.replaceIds(i,t,["id"])}),n.data.texts.forEach(i=>{this.replaceIds(i,t,["id"])}),n;case z.Drag:case z.TouchMove:case z.MouseMove:return n.data.positions.forEach(i=>{this.replaceIds(i,t,["id"])}),n;case z.ViewportResize:return!1;case z.MediaInteraction:case z.MouseInteraction:case z.Scroll:case z.CanvasMutation:case z.Input:return this.replaceIds(n.data,t,["id"]),n;case z.StyleSheetRule:case z.StyleDeclaration:return this.replaceIds(n.data,t,["id"]),this.replaceStyleIds(n.data,t,["styleId"]),n;case z.Font:return n;case z.Selection:return n.data.ranges.forEach(i=>{this.replaceIds(i,t,["start","end"])}),n;case z.AdoptedStyleSheet:return this.replaceIds(n.data,t,["id"]),this.replaceStyleIds(n.data,t,["styleIds"]),(r=n.data.styles)===null||r===void 0||r.forEach(i=>{this.replaceStyleIds(i,t,["styleId"])}),n}}}replace(t,n,r,i){for(const s of i)!Array.isArray(n[s])&&typeof n[s]!="number"||(Array.isArray(n[s])?n[s]=t.getIds(r,n[s]):n[s]=t.getId(r,n[s]));return n}replaceIds(t,n,r){return this.replace(this.crossOriginIframeMirror,t,n,r)}replaceStyleIds(t,n,r){return this.replace(this.crossOriginIframeStyleMirror,t,n,r)}replaceIdOnNode(t,n){this.replaceIds(t,n,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(r=>{this.replaceIdOnNode(r,n)})}patchRootIdOnNode(t,n){t.type!==ie.Document&&!t.rootId&&(t.rootId=n),"childNodes"in t&&t.childNodes.forEach(r=>{this.patchRootIdOnNode(r,n)})}}class eu{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,n){if(!Zt(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const r=uo(Object.assign(Object.assign({},this.bypassOptions),{doc:n,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t);this.restoreHandlers.push(()=>r.disconnect()),this.restoreHandlers.push(po(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(go({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){!t.contentWindow||!t.contentDocument||this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,n){const r=this;this.restoreHandlers.push(Yt(t.prototype,"attachShadow",function(i){return function(s){const o=i.call(this,s);return this.shadowRoot&&ro(this)&&r.addShadowRoot(this.shadowRoot,n),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 tu(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function nu(e,t,n,r){function i(s){return s instanceof n?s:new n(function(o){o(s)})}return new(n||(n=Promise))(function(s,o){function l(u){try{c(r.next(u))}catch(d){o(d)}}function a(u){try{c(r.throw(u))}catch(d){o(d)}}function c(u){u.done?s(u.value):i(u.value).then(l,a)}c((r=r.apply(e,t||[])).next())})}for(var xt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ru=typeof Uint8Array>"u"?[]:new Uint8Array(256),Vn=0;Vn<xt.length;Vn++)ru[xt.charCodeAt(Vn)]=Vn;var iu=function(e){var t=new Uint8Array(e),n,r=t.length,i="";for(n=0;n<r;n+=3)i+=xt[t[n]>>2],i+=xt[(t[n]&3)<<4|t[n+1]>>4],i+=xt[(t[n+1]&15)<<2|t[n+2]>>6],i+=xt[t[n+2]&63];return r%3===2?i=i.substring(0,i.length-1)+"=":r%3===1&&(i=i.substring(0,i.length-2)+"=="),i};const yo=new Map;function su(e,t){let n=yo.get(e);return n||(n=new Map,yo.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}const vo=(e,t,n)=>{if(!e||!(bo(e,t)||typeof e=="object"))return;const r=e.constructor.name,i=su(n,r);let s=i.indexOf(e);return s===-1&&(s=i.length,i.push(e)),s};function Gn(e,t,n){if(e instanceof Array)return e.map(r=>Gn(r,t,n));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 r=e.constructor.name,i=iu(e);return{rr_type:r,base64:i}}else{if(e instanceof DataView)return{rr_type:e.constructor.name,args:[Gn(e.buffer,t,n),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const r=e.constructor.name,{src:i}=e;return{rr_type:r,src:i}}else if(e instanceof HTMLCanvasElement){const r="HTMLImageElement",i=e.toDataURL();return{rr_type:r,src:i}}else{if(e instanceof ImageData)return{rr_type:e.constructor.name,args:[Gn(e.data,t,n),e.width,e.height]};if(bo(e,t)||typeof e=="object"){const r=e.constructor.name,i=vo(e,t,n);return{rr_type:r,index:i}}}}return e}const wo=(e,t,n)=>[...e].map(r=>Gn(r,t,n)),bo=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(n=>typeof t[n]=="function").find(n=>e instanceof t[n]);function ou(e,t,n,r){const i=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const o of s)try{if(typeof t.CanvasRenderingContext2D.prototype[o]!="function")continue;const l=Yt(t.CanvasRenderingContext2D.prototype,o,function(a){return function(...c){return me(this.canvas,n,r,!0)||setTimeout(()=>{const u=wo([...c],t,this);e(this.canvas,{type:Lt["2D"],property:o,args:u})},0),a.apply(this,c)}});i.push(l)}catch{const l=Bn(t.CanvasRenderingContext2D.prototype,o,{set(a){e(this.canvas,{type:Lt["2D"],property:o,args:[a],setter:!0})}});i.push(l)}return()=>{i.forEach(o=>o())}}function au(e){return e==="experimental-webgl"?"webgl":e}function Io(e,t,n,r){const i=[];try{const s=Yt(e.HTMLCanvasElement.prototype,"getContext",function(o){return function(l,...a){if(!me(this,t,n,!0)){const c=au(l);if("__context"in this||(this.__context=c),r&&["webgl","webgl2"].includes(c))if(a[0]&&typeof a[0]=="object"){const u=a[0];u.preserveDrawingBuffer||(u.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 So(e,t,n,r,i,s,o){const l=[],a=Object.getOwnPropertyNames(e);for(const c of a)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(c))try{if(typeof e[c]!="function")continue;const u=Yt(e,c,function(d){return function(...h){const p=d.apply(this,h);if(vo(p,o,this),"tagName"in this.canvas&&!me(this.canvas,r,i,!0)){const m=wo([...h],o,this),g={type:t,property:c,args:m};n(this.canvas,g)}return p}});l.push(u)}catch{const u=Bn(e,c,{set(d){n(this.canvas,{type:t,property:c,args:[d],setter:!0})}});l.push(u)}return l}function lu(e,t,n,r,i){const s=[];return s.push(...So(t.WebGLRenderingContext.prototype,Lt.WebGL,e,n,r,i,t)),typeof t.WebGL2RenderingContext<"u"&&s.push(...So(t.WebGL2RenderingContext.prototype,Lt.WebGL2,e,n,r,i,t)),()=>{s.forEach(o=>o())}}function cu(e,t){var n=atob(e);if(t){for(var r=new Uint8Array(n.length),i=0,s=n.length;i<s;++i)r[i]=n.charCodeAt(i);return String.fromCharCode.apply(null,new Uint16Array(r.buffer))}return n}function uu(e,t,n){var r=t===void 0?null:t,i=n===void 0?!1:n,s=cu(e,i),o=s.indexOf(`
19
+ `,10)+1,l=s.substring(o)+(r?"//# sourceMappingURL="+r:""),a=new Blob([l],{type:"application/javascript"});return URL.createObjectURL(a)}function du(e,t,n){var r;return function(i){return r=r||uu(e,t,n),new Worker(r,i)}}var pu=du("Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",null,!1);class hu{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,c)=>{(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(c)};const{sampling:n="all",win:r,blockClass:i,blockSelector:s,recordCanvas:o,dataURLOptions:l}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,o&&n==="all"&&this.initCanvasMutationObserver(r,i,s),o&&typeof n=="number"&&this.initCanvasFPSObserver(n,r,i,s,{dataURLOptions:l})}initCanvasFPSObserver(t,n,r,i,s){const o=Io(n,r,i,!0),l=new Map,a=new pu;a.onmessage=m=>{const{id:g}=m.data;if(l.set(g,!1),!("base64"in m.data))return;const{base64:y,type:v,width:f,height:b}=m.data;this.mutationCb({id:g,type:Lt["2D"],commands:[{property:"clearRect",args:[0,0,f,b]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:y}],type:v}]},0,0]}]})};const c=1e3/t;let u=0,d;const h=()=>{const m=[];return n.document.querySelectorAll("canvas").forEach(g=>{me(g,r,i,!0)||m.push(g)}),m},p=m=>{if(u&&m-u<c){d=requestAnimationFrame(p);return}u=m,h().forEach(g=>nu(this,void 0,void 0,function*(){var y;const v=this.mirror.getId(g);if(l.get(v))return;if(l.set(v,!0),["webgl","webgl2"].includes(g.__context)){const b=g.getContext(g.__context);((y=b?.getContextAttributes())===null||y===void 0?void 0:y.preserveDrawingBuffer)===!1&&b.clear(b.COLOR_BUFFER_BIT)}const f=yield createImageBitmap(g);a.postMessage({id:v,bitmap:f,width:g.width,height:g.height,dataURLOptions:s.dataURLOptions},[f])})),d=requestAnimationFrame(p)};d=requestAnimationFrame(p),this.resetObservers=()=>{o(),cancelAnimationFrame(d)}}initCanvasMutationObserver(t,n,r){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=Io(t,n,r,!1),s=ou(this.processMutation.bind(this),t,n,r),o=lu(this.processMutation.bind(this),t,n,r,this.mirror);this.resetObservers=()=>{i(),s(),o()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=n=>{this.rafStamps.latestId=n,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,n)=>{const r=this.mirror.getId(n);this.flushPendingCanvasMutationFor(n,r)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,n){if(this.frozen||this.locked)return;const r=this.pendingCanvasMutations.get(t);if(!r||n===-1)return;const i=r.map(o=>tu(o,["type"])),{type:s}=r[0];this.mutationCb({id:n,type:s,commands:i}),this.pendingCanvasMutations.delete(t)}}class mu{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new Mc,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,n){"_cssText"in n.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:n.id,attributes:n.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,n){if(t.length===0)return;const r={id:n,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,c)=>({rule:Ks(a),index:c}))})}r.styleIds.push(o)}i.length>0&&(r.styles=i),this.adoptedStyleSheetCb(r)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class gu{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame(()=>{this.clear(),this.loop&&this.periodicallyClear()})}inOtherBuffer(t,n){const r=this.nodeMap.get(t);return r&&Array.from(r).some(i=>i!==n)}add(t,n){this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(n))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}function se(e){return Object.assign(Object.assign({},e),{timestamp:jn()})}let X,qn,Hr,Zn=!1;const Le=cc();function Xt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i="rr-block",blockSelector:s=null,ignoreClass:o="rr-ignore",ignoreSelector:l=null,maskTextClass:a="rr-mask",maskTextSelector:c=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:p,maskInputFn:m,maskTextFn:g,hooks:y,packFn:v,sampling:f={},dataURLOptions:b={},mousemoveWait:w,recordCanvas:k=!1,recordCrossOriginIframes:I=!1,recordAfter:S=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:E=!1,collectFonts:C=!1,inlineImages:x=!1,plugins:R,keepIframeSrcFn:K=()=>!1,ignoreCSSAttributes:F=new Set([]),errorHandler:P}=e;Bc(P);const L=I?window.parent===window:!0;let U=!1;if(!L)try{window.parent.document&&(U=!1)}catch{U=!0}if(L&&!t)throw new Error("emit function is required");w!==void 0&&f.mousemove===void 0&&(f.mousemove=w),Le.reset();const V=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:h!==void 0?h:{password:!0},re=p===!0||p==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:p==="all",headMetaDescKeywords:p==="all"}:p||{};Uc();let ae,ue=0;const ke=M=>{for(const ve of R||[])ve.eventProcessor&&(M=ve.eventProcessor(M));return v&&!U&&(M=v(M)),M};X=(M,ve)=>{var G;if(!((G=ct[0])===null||G===void 0)&&G.isFrozen()&&M.type!==W.FullSnapshot&&!(M.type===W.IncrementalSnapshot&&M.data.source===z.Mutation)&&ct.forEach(le=>le.unfreeze()),L)t?.(ke(M),ve);else if(U){const le={type:"rrweb",event:ke(M),origin:window.location.origin,isCheckout:ve};window.parent.postMessage(le,"*")}if(M.type===W.FullSnapshot)ae=M,ue=0;else if(M.type===W.IncrementalSnapshot){if(M.data.source===z.Mutation&&M.data.isAttachIframe)return;ue++;const le=r&&ue>=r,at=n&&M.timestamp-ae.timestamp>n;(le||at)&&qn(!0)}};const J=M=>{X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.Mutation},M)}))},Ct=M=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.Scroll},M)})),Vt=M=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.CanvasMutation},M)})),xn=M=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.AdoptedStyleSheet},M)})),Ae=new mu({mutationCb:J,adoptedStyleSheetCb:xn}),Re=new Xc({mirror:Le,mutationCb:J,stylesheetManager:Ae,recordCrossOriginIframes:I,wrappedEmit:X});for(const M of R||[])M.getMirror&&M.getMirror({nodeMirror:Le,crossOriginIframeMirror:Re.crossOriginIframeMirror,crossOriginIframeStyleMirror:Re.crossOriginIframeStyleMirror});const ot=new gu;Hr=new hu({recordCanvas:k,mutationCb:Vt,win:window,blockClass:i,blockSelector:s,mirror:Le,sampling:f.canvas,dataURLOptions:b});const Ee=new eu({mutationCb:J,scrollCb:Ct,bypassOptions:{blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:V,dataURLOptions:b,maskTextFn:g,maskInputFn:m,recordCanvas:k,inlineImages:x,sampling:f,slimDOMOptions:re,iframeManager:Re,stylesheetManager:Ae,canvasManager:Hr,keepIframeSrcFn:K,processedNodeManager:ot},mirror:Le});qn=(M=!1)=>{X(se({type:W.Meta,data:{href:window.location.href,width:Qs(),height:Js()}}),M),Ae.reset(),Ee.init(),ct.forEach(G=>G.lock());const ve=Rc(document,{mirror:Le,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:u,maskAllInputs:V,maskTextFn:g,slimDOM:re,dataURLOptions:b,recordCanvas:k,inlineImages:x,onSerialize:G=>{eo(G,Le)&&Re.addIframe(G),to(G,Le)&&Ae.trackLinkElement(G),Zr(G)&&Ee.addShadowRoot(G.shadowRoot,document)},onIframeLoad:(G,le)=>{Re.attachIframe(G,le),Ee.observeAttachShadow(G)},onStylesheetLoad:(G,le)=>{Ae.attachLinkElement(G,le)},keepIframeSrcFn:K});if(!ve)return console.warn("Failed to snapshot the document");X(se({type:W.FullSnapshot,data:{node:ve,initialOffset:Ys(window)}}),M),ct.forEach(G=>G.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&Ae.adoptStyleSheets(document.adoptedStyleSheets,Le.getId(document))};try{const M=[],ve=le=>{var at;return B(Qc)({mutationCb:J,mousemoveCb:(Q,Ur)=>X(se({type:W.IncrementalSnapshot,data:{source:Ur,positions:Q}})),mouseInteractionCb:Q=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.MouseInteraction},Q)})),scrollCb:Ct,viewportResizeCb:Q=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.ViewportResize},Q)})),inputCb:Q=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.Input},Q)})),mediaInteractionCb:Q=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.MediaInteraction},Q)})),styleSheetRuleCb:Q=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.StyleSheetRule},Q)})),styleDeclarationCb:Q=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.StyleDeclaration},Q)})),canvasMutationCb:Vt,fontCb:Q=>X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.Font},Q)})),selectionCb:Q=>{X(se({type:W.IncrementalSnapshot,data:Object.assign({source:z.Selection},Q)}))},blockClass:i,ignoreClass:o,ignoreSelector:l,maskTextClass:a,maskTextSelector:c,maskInputOptions:V,inlineStylesheet:u,sampling:f,recordCanvas:k,inlineImages:x,userTriggeredOnInput:E,collectFonts:C,doc:le,maskInputFn:m,maskTextFn:g,keepIframeSrcFn:K,blockSelector:s,slimDOMOptions:re,dataURLOptions:b,mirror:Le,iframeManager:Re,stylesheetManager:Ae,shadowDomManager:Ee,processedNodeManager:ot,canvasManager:Hr,ignoreCSSAttributes:F,plugins:((at=R?.filter(Q=>Q.observer))===null||at===void 0?void 0:at.map(Q=>({observer:Q.observer,options:Q.options,callback:Ur=>X(se({type:W.Plugin,data:{plugin:Q.name,payload:Ur}}))})))||[]},y)};Re.addLoadListener(le=>{try{M.push(ve(le.contentDocument))}catch(at){console.warn(at)}});const G=()=>{qn(),M.push(ve(document)),Zn=!0};return document.readyState==="interactive"||document.readyState==="complete"?G():(M.push(he("DOMContentLoaded",()=>{X(se({type:W.DomContentLoaded,data:{}})),S==="DOMContentLoaded"&&G()})),M.push(he("load",()=>{X(se({type:W.Load,data:{}})),S==="load"&&G()},window))),()=>{M.forEach(le=>le()),ot.destroy(),Zn=!1,jc()}}catch(M){console.warn(M)}}Xt.addCustomEvent=(e,t)=>{if(!Zn)throw new Error("please add custom event after start recording");X(se({type:W.Custom,data:{tag:e,payload:t}}))},Xt.freezePage=()=>{ct.forEach(e=>e.freeze())},Xt.takeFullSnapshot=e=>{if(!Zn)throw new Error("please take full snapshot after start recording");qn(e)},Xt.mirror=Le;var Fe=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Fe||{}),D=(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))(D||{});const en={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 $n;const fu=new Uint8Array(16);function yu(){if(!$n&&($n=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!$n))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $n(fu)}const ce=[];for(let e=0;e<256;++e)ce.push((e+256).toString(16).slice(1));function vu(e,t=0){return ce[e[t+0]]+ce[e[t+1]]+ce[e[t+2]]+ce[e[t+3]]+"-"+ce[e[t+4]]+ce[e[t+5]]+"-"+ce[e[t+6]]+ce[e[t+7]]+"-"+ce[e[t+8]]+ce[e[t+9]]+"-"+ce[e[t+10]]+ce[e[t+11]]+ce[e[t+12]]+ce[e[t+13]]+ce[e[t+14]]+ce[e[t+15]]}const wu=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Co={randomUUID:wu};function ut(e,t,n){if(Co.randomUUID&&!t&&!e)return Co.randomUUID();e=e||{};const r=e.random||(e.rng||yu)();if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){n=n||0;for(let i=0;i<16;++i)t[n+i]=r[i];return t}return vu(r)}const bu='.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}',ko="360px",Iu="ul-app",Su="#e6e6e6",Cu="#bd282a",ku=500,Au=1030,Ao=()=>{try{return window.parent.Intercom}catch{return null}},Eu=()=>{const e=Ao();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)},_u=()=>{const e=Ao();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},Lu=Object.freeze(Object.defineProperty({__proto__:null,disable:_u,enable:Eu},Symbol.toStringTag,{value:"Module"})),Eo=[Lu];class _o{static disable(){Eo.forEach(t=>t.disable())}static enable(){Eo.forEach(t=>t.enable())}}var xu=class extends Error{constructor(e,t,n){super(`Possible EventEmitter memory leak detected. ${n} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=n,this.name="MaxListenersExceededWarning"}},Lo=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=Lo.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,n){this.emit(e,t,n)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const n=e.indexOf(t);return n>-1&&e.splice(n,1),[]}_wrapOnceListener(e,t){const n=(...r)=>(this.removeListener(e,n),t.apply(this,r));return Object.defineProperty(n,"name",{value:t.name}),n}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const n=this._getListeners(e);return n.forEach(r=>{r.apply(this,t)}),n.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const n=this._getListeners(e).concat(t);if(this.events.set(e,n),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const r=new xu(this,e,this.listenerCount(e));console.warn(r)}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 n=this._getListeners(e);if(n.length>0){const r=[t].concat(n);this.events.set(e,r)}else this.events.set(e,n.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const n=this._getListeners(e);return n.length>0&&(this._removeListener(n,t),this.events.set(e,n),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)}},xo=Lo;xo.defaultMaxListeners=10;const N=new xo,Hn=e=>new Promise(t=>{setTimeout(()=>{t()},e)}),To=({"userleap-platform":e})=>e!=="web";class Ro{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,n){this.isStorageAvailable?this.storage.setItem(t,n):this.tempStorage[t]=n}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 Je=new Ro("sessionStorage"),be=new Ro("localStorage");class Tu{constructor(t){ee(this,"payload"),ee(this,"promise"),ee(this,"reject",()=>{}),ee(this,"resolve",()=>{}),this.payload=t,this.promise=new Promise((n,r)=>{this.reject=r,this.resolve=n})}resolveRequest(t){this.resolve(t)}}const Ru={RATELIMIT_RESET_DEFAULT:10};let Oo=!1,Uo="",Yn=!1,Mo=!1,Jn=[];const Ou=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",Yr=e=>{var t;(t=e?.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(Mo=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`),document.removeEventListener("securitypolicyviolation",Yr))},Jr=(e="")=>{Oo=!0,Uo=e};function dt(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.28.0","x-ul-installation-method":Ou(e)};if(t["x-ul-package-version"]="1.1.3",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 n=JSON.parse(e.mobileHeadersJSON);Object.assign(t,n)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const Do=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const n=new Tu(t);return Jn.push(n),n.promise}},Be=async(e,t)=>{const{retries:n=0,shouldDropOnRateLimit:r=!1,shouldRetryRequest:i=!1,...s}=t,o={url:e,options:s,retries:n,shouldDropOnRateLimit:r};if(Yn&&!i)return Do(o);const l={ok:!1,reportError:!1};if(Oo)return console.info(`UserLeap - ${Uo}`),l;try{const a=await fetch(e,s);if(a.status===429)if(!Yn&&!r||i){Yn=!0;const c=a.headers.has("ratelimit-reset")?Number(a.headers.get("ratelimit-reset")):Ru.RATELIMIT_RESET_DEFAULT;return await Hn(c*1e3),Be(e,{...s,shouldDropOnRateLimit:r,shouldRetryRequest:!0})}else return Do(o);if(Yn=!1,Jn.length&&(Jn.map(c=>{const u=c.payload;Be(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(d=>{c.resolveRequest(d)})}),Jn=[]),a.ok){if(a.status===249)return Jr(),l;const c=await a.text();try{return c&&c!=="OK"&&(a.json=JSON.parse(c)),a}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${c}`)}}}return a}catch(a){const c=n+1;return c>5||Mo?{ok:!1,reportError:!1,error:a}:(await Hn(Math.pow(2,n)*1e3),Be(e,{...s,retries:c}))}},Tt={Error:1,Warn:2,Info:3,Debug:4};let Qr=1e3,Qn=Tt.Debug,Rt=[];const Uu=e=>{const t=Object.entries(Tt).find(n=>n[1]===e);return t?.[0]??""},Mu=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}),Du=(e,t)=>`${Mu(t)}:${e}`,Nu=()=>{Rt=Rt.filter(e=>e.level<=Qn)},Pu=()=>{Rt.length>Qr&&Rt.shift()},Xn=(e,t)=>{e>Qn||(Rt.push({level:e,line:Du(t,new Date)}),Pu())},tn=e=>{Xn(Tt.Debug,e)},_=e=>{Xn(Tt.Info,e)},Xr=e=>{Xn(Tt.Warn,e)},No=e=>{Xn(Tt.Error,e)},Fu=()=>Rt.map(e=>e.line),Bu=()=>new TextEncoder().encode(Fu().join(`
20
+ `)),Po=async e=>{if(!e)return;const t=Bu();return Be(e,{body:t,method:"PUT"})},ju=(e,t)=>{e!==void 0&&(Qr=e),t!==void 0&&(Qn=t),tn(`Initializing logger with limit of ${Qr} lines and ${Uu(Qn)} level`),Nu()};class Ku{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 Fo=new Ku(2),Wu=e=>Fo.setLimit(e),zu=async e=>Fo.execute(async()=>{var t;_(`Beginning upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const n=await Be(e.uploadUrl,{body:e.data,method:"PUT"});_(`Completed upload of chunk ${e.chunkIndex} for survey: ${e.surveyId}`);const r=(t=n.headers)==null?void 0:t.get("ETag");if(!r)throw new Error(`Upload response did not include etag for upload ${e.uploadId}, part ${e.chunkIndex}`);return r}),Bo=async({apiUrl:e,surveyId:t,uploadId:n,etags:r,headers:i,responseGroupUuid:s,replayDuration:o,eventDigest:l},a=!1)=>{var c;if(!a&&!n&&!r){_(`Cannot mark upload complete: isMobile: ${a} / uploadId: ${n} / etags: ${r}`);return}_(`Marking upload complete for survey: ${t}`);const u=await Be(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:r,uploadId:n,responseGroupUuid:s,surveyId:t,replayDuration:o,eventDigest:l,userAgent:(c=window?.navigator)==null?void 0:c.userAgent}),headers:i,shouldRetryRequest:!0});return _(`Done marking upload complete for survey: ${t}`),u},H=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,ne=Object.keys,de=Array.isArray;function ge(e,t){return typeof t!="object"||ne(t).forEach(function(n){e[n]=t[n]}),e}typeof Promise>"u"||H.Promise||(H.Promise=Promise);const nn=Object.getPrototypeOf,Vu={}.hasOwnProperty;function Ie(e,t){return Vu.call(e,t)}function Ot(e,t){typeof t=="function"&&(t=t(nn(e))),(typeof Reflect>"u"?ne:Reflect.ownKeys)(t).forEach(n=>{je(e,n,t[n])})}const jo=Object.defineProperty;function je(e,t,n,r){jo(e,t,ge(n&&Ie(n,"get")&&typeof n.get=="function"?{get:n.get,set:n.set,configurable:!0}:{value:n,configurable:!0,writable:!0},r))}function Ut(e){return{from:function(t){return e.prototype=Object.create(t.prototype),je(e.prototype,"constructor",e),{extend:Ot.bind(null,e.prototype)}}}}const Gu=Object.getOwnPropertyDescriptor;function ei(e,t){let n;return Gu(e,t)||(n=nn(e))&&ei(n,t)}const qu=[].slice;function er(e,t,n){return qu.call(e,t,n)}function Ko(e,t){return t(e)}function rn(e){if(!e)throw new Error("Assertion Failed")}function Wo(e){H.setImmediate?setImmediate(e):setTimeout(e,0)}function zo(e,t){return e.reduce((n,r,i)=>{var s=t(r,i);return s&&(n[s[0]]=s[1]),n},{})}function Ke(e,t){if(typeof t=="string"&&Ie(e,t))return e[t];if(!t)return e;if(typeof t!="string"){for(var n=[],r=0,i=t.length;r<i;++r){var s=Ke(e,t[r]);n.push(s)}return n}var o=t.indexOf(".");if(o!==-1){var l=e[t.substr(0,o)];return l==null?void 0:Ke(l,t.substr(o+1))}}function xe(e,t,n){if(e&&t!==void 0&&(!("isFrozen"in Object)||!Object.isFrozen(e)))if(typeof t!="string"&&"length"in t){rn(typeof n!="string"&&"length"in n);for(var r=0,i=t.length;r<i;++r)xe(e,t[r],n[r])}else{var s=t.indexOf(".");if(s!==-1){var o=t.substr(0,s),l=t.substr(s+1);if(l==="")n===void 0?de(e)&&!isNaN(parseInt(o))?e.splice(o,1):delete e[o]:e[o]=n;else{var a=e[o];a&&Ie(e,o)||(a=e[o]={}),xe(a,l,n)}}else n===void 0?de(e)&&!isNaN(parseInt(t))?e.splice(t,1):delete e[t]:e[t]=n}}function Vo(e){var t={};for(var n in e)Ie(e,n)&&(t[n]=e[n]);return t}const Zu=[].concat;function Go(e){return Zu.apply([],e)}const qo="BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Go([8,16,32,64].map(e=>["Int","Uint","Float"].map(t=>t+e+"Array")))).filter(e=>H[e]),$u=qo.map(e=>H[e]);zo(qo,e=>[e,!0]);let Qe=null;function sn(e){Qe=typeof WeakMap<"u"&&new WeakMap;const t=ti(e);return Qe=null,t}function ti(e){if(!e||typeof e!="object")return e;let t=Qe&&Qe.get(e);if(t)return t;if(de(e)){t=[],Qe&&Qe.set(e,t);for(var n=0,r=e.length;n<r;++n)t.push(ti(e[n]))}else if($u.indexOf(e.constructor)>=0)t=e;else{const s=nn(e);for(var i in t=s===Object.prototype?{}:Object.create(s),Qe&&Qe.set(e,t),e)Ie(e,i)&&(t[i]=ti(e[i]))}return t}const{toString:Hu}={};function ni(e){return Hu.call(e).slice(8,-1)}const ri=typeof Symbol<"u"?Symbol.iterator:"@@iterator",Yu=typeof ri=="symbol"?function(e){var t;return e!=null&&(t=e[ri])&&t.apply(e)}:function(){return null},Mt={};function We(e){var t,n,r,i;if(arguments.length===1){if(de(e))return e.slice();if(this===Mt&&typeof e=="string")return[e];if(i=Yu(e)){for(n=[];!(r=i.next()).done;)n.push(r.value);return n}if(e==null)return[e];if(typeof(t=e.length)=="number"){for(n=new Array(t);t--;)n[t]=e[t];return n}return[e]}for(t=arguments.length,n=new Array(t);t--;)n[t]=arguments[t];return n}const ii=typeof Symbol<"u"?e=>e[Symbol.toStringTag]==="AsyncFunction":()=>!1;var Oe=typeof location<"u"&&/^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);function Zo(e,t){Oe=e,$o=t}var $o=()=>!0;const Ju=!new Error("").stack;function pt(){if(Ju)try{throw pt.arguments,new Error}catch(e){return e}return new Error}function si(e,t){var n=e.stack;return n?(t=t||0,n.indexOf(e.name)===0&&(t+=(e.name+e.message).split(`
21
+ `).length),n.split(`
22
+ `).slice(t).filter($o).map(r=>`
23
+ `+r).join("")):""}var Ho=["Unknown","Constraint","Data","TransactionInactive","ReadOnly","Version","NotFound","InvalidState","InvalidAccess","Abort","Timeout","QuotaExceeded","Syntax","DataClone"],oi=["Modify","Bulk","OpenFailed","VersionChange","Schema","Upgrade","InvalidTable","MissingAPI","NoSuchDatabase","InvalidArgument","SubTransaction","Unsupported","Internal","DatabaseClosed","PrematureCommit","ForeignAwait"].concat(Ho),Qu={VersionChanged:"Database version changed by other database connection",DatabaseClosed:"Database has been closed",Abort:"Transaction aborted",TransactionInactive:"Transaction has already completed or failed",MissingAPI:"IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"};function Dt(e,t){this._e=pt(),this.name=e,this.message=t}function Yo(e,t){return e+". Errors: "+Object.keys(t).map(n=>t[n].toString()).filter((n,r,i)=>i.indexOf(n)===r).join(`
24
+ `)}function tr(e,t,n,r){this._e=pt(),this.failures=t,this.failedKeys=r,this.successCount=n,this.message=Yo(e,t)}function on(e,t){this._e=pt(),this.name="BulkError",this.failures=Object.keys(t).map(n=>t[n]),this.failuresByPos=t,this.message=Yo(e,t)}Ut(Dt).from(Error).extend({stack:{get:function(){return this._stack||(this._stack=this.name+": "+this.message+si(this._e,2))}},toString:function(){return this.name+": "+this.message}}),Ut(tr).from(Dt),Ut(on).from(Dt);var ai=oi.reduce((e,t)=>(e[t]=t+"Error",e),{});const Xu=Dt;var O=oi.reduce((e,t)=>{var n=t+"Error";function r(i,s){this._e=pt(),this.name=n,i?typeof i=="string"?(this.message=`${i}${s?`
25
+ `+s:""}`,this.inner=s||null):typeof i=="object"&&(this.message=`${i.name} ${i.message}`,this.inner=i):(this.message=Qu[t]||n,this.inner=null)}return Ut(r).from(Xu),e[t]=r,e},{});O.Syntax=SyntaxError,O.Type=TypeError,O.Range=RangeError;var Jo=Ho.reduce((e,t)=>(e[t+"Error"]=O[t],e),{}),nr=oi.reduce((e,t)=>(["Syntax","Type","Range"].indexOf(t)===-1&&(e[t+"Error"]=O[t]),e),{});function q(){}function an(e){return e}function ed(e,t){return e==null||e===an?t:function(n){return t(e(n))}}function ht(e,t){return function(){e.apply(this,arguments),t.apply(this,arguments)}}function td(e,t){return e===q?t:function(){var n=e.apply(this,arguments);n!==void 0&&(arguments[0]=n);var r=this.onsuccess,i=this.onerror;this.onsuccess=null,this.onerror=null;var s=t.apply(this,arguments);return r&&(this.onsuccess=this.onsuccess?ht(r,this.onsuccess):r),i&&(this.onerror=this.onerror?ht(i,this.onerror):i),s!==void 0?s:n}}function nd(e,t){return e===q?t:function(){e.apply(this,arguments);var n=this.onsuccess,r=this.onerror;this.onsuccess=this.onerror=null,t.apply(this,arguments),n&&(this.onsuccess=this.onsuccess?ht(n,this.onsuccess):n),r&&(this.onerror=this.onerror?ht(r,this.onerror):r)}}function rd(e,t){return e===q?t:function(n){var r=e.apply(this,arguments);ge(n,r);var i=this.onsuccess,s=this.onerror;this.onsuccess=null,this.onerror=null;var o=t.apply(this,arguments);return i&&(this.onsuccess=this.onsuccess?ht(i,this.onsuccess):i),s&&(this.onerror=this.onerror?ht(s,this.onerror):s),r===void 0?o===void 0?void 0:o:ge(r,o)}}function id(e,t){return e===q?t:function(){return t.apply(this,arguments)!==!1&&e.apply(this,arguments)}}function li(e,t){return e===q?t:function(){var n=e.apply(this,arguments);if(n&&typeof n.then=="function"){for(var r=this,i=arguments.length,s=new Array(i);i--;)s[i]=arguments[i];return n.then(function(){return t.apply(r,s)})}return t.apply(this,arguments)}}nr.ModifyError=tr,nr.DexieError=Dt,nr.BulkError=on;var ln={};const Qo=100,[ci,rr,ui]=typeof Promise>"u"?[]:(()=>{let e=Promise.resolve();if(typeof crypto>"u"||!crypto.subtle)return[e,nn(e),e];const t=crypto.subtle.digest("SHA-512",new Uint8Array([0]));return[t,nn(t),e]})(),Xo=rr&&rr.then,ir=ci&&ci.constructor,di=!!ui;var pi=!1,sd=ui?()=>{ui.then(lr)}:H.setImmediate?setImmediate.bind(null,lr):H.MutationObserver?()=>{var e=document.createElement("div");new MutationObserver(()=>{lr(),e=null}).observe(e,{attributes:!0}),e.setAttribute("i","1")}:()=>{setTimeout(lr,0)},cn=function(e,t){un.push([e,t]),sr&&(sd(),sr=!1)},hi=!0,sr=!0,mt=[],or=[],mi=null,gi=an,Nt={id:"global",global:!0,ref:0,unhandleds:[],onunhandled:ca,pgp:!1,env:{},finalize:function(){this.unhandleds.forEach(e=>{try{ca(e[0],e[1])}catch{}})}},T=Nt,un=[],gt=0,ar=[];function A(e){if(typeof this!="object")throw new TypeError("Promises must be constructed via new");this._listeners=[],this.onuncatched=q,this._lib=!1;var t=this._PSD=T;if(Oe&&(this._stackHolder=pt(),this._prev=null,this._numPrev=0),typeof e!="function"){if(e!==ln)throw new TypeError("Not a function");return this._state=arguments[1],this._value=arguments[2],void(this._state===!1&&yi(this,this._value))}this._state=null,this._value=null,++t.ref,ta(this,e)}const fi={get:function(){var e=T,t=dr;function n(r,i){var s=!e.global&&(e!==T||t!==dr);const o=s&&!ze();var l=new A((a,c)=>{vi(this,new ea(hr(r,e,s,o),hr(i,e,s,o),a,c,e))});return Oe&&ia(l,this),l}return n.prototype=ln,n},set:function(e){je(this,"then",e&&e.prototype===ln?fi:{get:function(){return e},set:fi.set})}};function ea(e,t,n,r,i){this.onFulfilled=typeof e=="function"?e:null,this.onRejected=typeof t=="function"?t:null,this.resolve=n,this.reject=r,this.psd=i}function ta(e,t){try{t(n=>{if(e._state===null){if(n===e)throw new TypeError("A promise cannot be resolved with itself.");var r=e._lib&&dn();n&&typeof n.then=="function"?ta(e,(i,s)=>{n instanceof A?n._then(i,s):n.then(i,s)}):(e._state=!0,e._value=n,na(e)),r&&pn()}},yi.bind(null,e))}catch(n){yi(e,n)}}function yi(e,t){if(or.push(t),e._state===null){var n=e._lib&&dn();t=gi(t),e._state=!1,e._value=t,Oe&&t!==null&&typeof t=="object"&&!t._promise&&function(r,i,s){try{r.apply(null,s)}catch(o){i&&i(o)}}(()=>{var r=ei(t,"stack");t._promise=e,je(t,"stack",{get:()=>pi?r&&(r.get?r.get.apply(t):r.value):e.stack})}),function(r){mt.some(i=>i._value===r._value)||mt.push(r)}(e),na(e),n&&pn()}}function na(e){var t=e._listeners;e._listeners=[];for(var n=0,r=t.length;n<r;++n)vi(e,t[n]);var i=e._PSD;--i.ref||i.finalize(),gt===0&&(++gt,cn(()=>{--gt==0&&wi()},[]))}function vi(e,t){if(e._state!==null){var n=e._state?t.onFulfilled:t.onRejected;if(n===null)return(e._state?t.resolve:t.reject)(e._value);++t.psd.ref,++gt,cn(od,[n,e,t])}else e._listeners.push(t)}function od(e,t,n){try{mi=t;var r,i=t._value;t._state?r=e(i):(or.length&&(or=[]),r=e(i),or.indexOf(i)===-1&&function(s){for(var o=mt.length;o;)if(mt[--o]._value===s._value)return void mt.splice(o,1)}(t)),n.resolve(r)}catch(s){n.reject(s)}finally{mi=null,--gt==0&&wi(),--n.psd.ref||n.psd.finalize()}}function ra(e,t,n){if(t.length===n)return t;var r="";if(e._state===!1){var i,s,o=e._value;o!=null?(i=o.name||"Error",s=o.message||o,r=si(o,0)):(i=o,s=""),t.push(i+(s?": "+s:"")+r)}return Oe&&((r=si(e._stackHolder,2))&&t.indexOf(r)===-1&&t.push(r),e._prev&&ra(e._prev,t,n)),t}function ia(e,t){var n=t?t._numPrev+1:0;n<100&&(e._prev=t,e._numPrev=n)}function lr(){dn()&&pn()}function dn(){var e=hi;return hi=!1,sr=!1,e}function pn(){var e,t,n;do for(;un.length>0;)for(e=un,un=[],n=e.length,t=0;t<n;++t){var r=e[t];r[0].apply(null,r[1])}while(un.length>0);hi=!0,sr=!0}function wi(){var e=mt;mt=[],e.forEach(r=>{r._PSD.onunhandled.call(null,r._value,r)});for(var t=ar.slice(0),n=t.length;n;)t[--n]()}function cr(e){return new A(ln,!1,e)}function Y(e,t){var n=T;return function(){var r=dn(),i=T;try{return et(n,!0),e.apply(this,arguments)}catch(s){t&&t(s)}finally{et(i,!1),r&&pn()}}}Ot(A.prototype,{then:fi,_then:function(e,t){vi(this,new ea(null,null,e,t,T))},catch:function(e){if(arguments.length===1)return this.then(null,e);var t=arguments[0],n=arguments[1];return typeof t=="function"?this.then(null,r=>r instanceof t?n(r):cr(r)):this.then(null,r=>r&&r.name===t?n(r):cr(r))},finally:function(e){return this.then(t=>(e(),t),t=>(e(),cr(t)))},stack:{get:function(){if(this._stack)return this._stack;try{pi=!0;var e=ra(this,[],20).join(`
26
+ From previous: `);return this._state!==null&&(this._stack=e),e}finally{pi=!1}}},timeout:function(e,t){return e<1/0?new A((n,r)=>{var i=setTimeout(()=>r(new O.Timeout(t)),e);this.then(n,r).finally(clearTimeout.bind(null,i))}):this}}),typeof Symbol<"u"&&Symbol.toStringTag&&je(A.prototype,Symbol.toStringTag,"Dexie.Promise"),Nt.env=sa(),Ot(A,{all:function(){var e=We.apply(null,arguments).map(pr);return new A(function(t,n){e.length===0&&t([]);var r=e.length;e.forEach((i,s)=>A.resolve(i).then(o=>{e[s]=o,--r||t(e)},n))})},resolve:e=>{if(e instanceof A)return e;if(e&&typeof e.then=="function")return new A((n,r)=>{e.then(n,r)});var t=new A(ln,!0,e);return ia(t,mi),t},reject:cr,race:function(){var e=We.apply(null,arguments).map(pr);return new A((t,n)=>{e.map(r=>A.resolve(r).then(t,n))})},PSD:{get:()=>T,set:e=>T=e},totalEchoes:{get:()=>dr},newPSD:Xe,usePSD:Ft,scheduler:{get:()=>cn,set:e=>{cn=e}},rejectionMapper:{get:()=>gi,set:e=>{gi=e}},follow:(e,t)=>new A((n,r)=>Xe((i,s)=>{var o=T;o.unhandleds=[],o.onunhandled=s,o.finalize=ht(function(){(function(l){function a(){l(),ar.splice(ar.indexOf(a),1)}ar.push(a),++gt,cn(()=>{--gt==0&&wi()},[])})(()=>{this.unhandleds.length===0?i():s(this.unhandleds[0])})},o.finalize),e()},t,n,r))}),ir&&(ir.allSettled&&je(A,"allSettled",function(){const e=We.apply(null,arguments).map(pr);return new A(t=>{e.length===0&&t([]);let n=e.length;const r=new Array(n);e.forEach((i,s)=>A.resolve(i).then(o=>r[s]={status:"fulfilled",value:o},o=>r[s]={status:"rejected",reason:o}).then(()=>--n||t(r)))})}),ir.any&&typeof AggregateError<"u"&&je(A,"any",function(){const e=We.apply(null,arguments).map(pr);return new A((t,n)=>{e.length===0&&n(new AggregateError([]));let r=e.length;const i=new Array(r);e.forEach((s,o)=>A.resolve(s).then(l=>t(l),l=>{i[o]=l,--r||n(new AggregateError(i))}))})}));const pe={awaits:0,echoes:0,id:0};var ad=0,ur=[],bi=0,dr=0,ld=0;function Xe(e,t,n,r){var i=T,s=Object.create(i);s.parent=i,s.ref=0,s.global=!1,s.id=++ld;var o=Nt.env;s.env=di?{Promise:A,PromiseProp:{value:A,configurable:!0,writable:!0},all:A.all,race:A.race,allSettled:A.allSettled,any:A.any,resolve:A.resolve,reject:A.reject,nthen:aa(o.nthen,s),gthen:aa(o.gthen,s)}:{},t&&ge(s,t),++i.ref,s.finalize=function(){--this.parent.ref||this.parent.finalize()};var l=Ft(s,e,n,r);return s.ref===0&&s.finalize(),l}function Pt(){return pe.id||(pe.id=++ad),++pe.awaits,pe.echoes+=Qo,pe.id}function ze(){return!!pe.awaits&&(--pe.awaits==0&&(pe.id=0),pe.echoes=pe.awaits*Qo,!0)}function pr(e){return pe.echoes&&e&&e.constructor===ir?(Pt(),e.then(t=>(ze(),t),t=>(ze(),oe(t)))):e}function cd(e){++dr,pe.echoes&&--pe.echoes!=0||(pe.echoes=pe.id=0),ur.push(T),et(e,!0)}function ud(){var e=ur[ur.length-1];ur.pop(),et(e,!1)}function et(e,t){var n=T;if((t?!pe.echoes||bi++&&e===T:!bi||--bi&&e===T)||oa(t?cd.bind(null,e):ud),e!==T&&(T=e,n===Nt&&(Nt.env=sa()),di)){var r=Nt.env.Promise,i=e.env;rr.then=i.nthen,r.prototype.then=i.gthen,(n.global||e.global)&&(Object.defineProperty(H,"Promise",i.PromiseProp),r.all=i.all,r.race=i.race,r.resolve=i.resolve,r.reject=i.reject,i.allSettled&&(r.allSettled=i.allSettled),i.any&&(r.any=i.any))}}function sa(){var e=H.Promise;return di?{Promise:e,PromiseProp:Object.getOwnPropertyDescriptor(H,"Promise"),all:e.all,race:e.race,allSettled:e.allSettled,any:e.any,resolve:e.resolve,reject:e.reject,nthen:rr.then,gthen:e.prototype.then}:{}}function Ft(e,t,n,r,i){var s=T;try{return et(e,!0),t(n,r,i)}finally{et(s,!1)}}function oa(e){Xo.call(ci,e)}function hr(e,t,n,r){return typeof e!="function"?e:function(){var i=T;n&&Pt(),et(t,!0);try{return e.apply(this,arguments)}finally{et(i,!1),r&&oa(ze)}}}function aa(e,t){return function(n,r){return e.call(this,hr(n,t),hr(r,t))}}(""+Xo).indexOf("[native code]")===-1&&(Pt=ze=q);const la="unhandledrejection";function ca(e,t){var n;try{n=t.onuncatched(e)}catch{}if(n!==!1)try{var r,i={promise:t,reason:e};if(H.document&&document.createEvent?((r=document.createEvent("Event")).initEvent(la,!0,!0),ge(r,i)):H.CustomEvent&&ge(r=new CustomEvent(la,{detail:i}),i),r&&H.dispatchEvent&&(dispatchEvent(r),!H.PromiseRejectionEvent&&H.onunhandledrejection))try{H.onunhandledrejection(r)}catch{}Oe&&r&&!r.defaultPrevented&&console.warn(`Unhandled rejection: ${e.stack||e}`)}catch{}}var oe=A.reject;function Ii(e,t,n,r){if(e.idbdb&&(e._state.openComplete||T.letThrough||e._vip)){var i=e._createTransaction(t,n,e._dbSchema);try{i.create(),e._state.PR1398_maxLoop=3}catch(s){return s.name===ai.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>Ii(e,t,n,r))):oe(s)}return i._promise(t,(s,o)=>Xe(()=>(T.trans=i,r(s,o,i)))).then(s=>i._completion.then(()=>s))}if(e._state.openComplete)return oe(new O.DatabaseClosed(e._state.dbOpenError));if(!e._state.isBeingOpened){if(!e._options.autoOpen)return oe(new O.DatabaseClosed);e.open().catch(q)}return e._state.dbReadyPromise.then(()=>Ii(e,t,n,r))}const ua="3.2.7",ft="\uFFFF",Si=-1/0,Ve="Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.",da="String expected.",hn=[],mr=typeof navigator<"u"&&/(MSIE|Trident|Edge)/.test(navigator.userAgent),dd=mr,pd=mr,pa=e=>!/(dexie\.js|dexie\.min\.js)/.test(e),gr="__dbnames",Ci="readonly",ki="readwrite";function yt(e,t){return e?t?function(){return e.apply(this,arguments)&&t.apply(this,arguments)}:e:t}const ha={type:3,lower:-1/0,lowerOpen:!1,upper:[[]],upperOpen:!1};function fr(e){return typeof e!="string"||/\./.test(e)?t=>t:t=>(t[e]===void 0&&e in t&&delete(t=sn(t))[e],t)}class hd{_trans(t,n,r){const i=this._tx||T.trans,s=this.name;function o(a,c,u){if(!u.schema[s])throw new O.NotFound("Table "+s+" not part of transaction");return n(u.idbtrans,u)}const l=dn();try{return i&&i.db===this.db?i===T.trans?i._promise(t,o,r):Xe(()=>i._promise(t,o,r),{trans:i,transless:T.transless||T}):Ii(this.db,t,[this.name],o)}finally{l&&pn()}}get(t,n){return t&&t.constructor===Object?this.where(t).first(n):this._trans("readonly",r=>this.core.get({trans:r,key:t}).then(i=>this.hook.reading.fire(i))).then(n)}where(t){if(typeof t=="string")return new this.db.WhereClause(this,t);if(de(t))return new this.db.WhereClause(this,`[${t.join("+")}]`);const n=ne(t);if(n.length===1)return this.where(n[0]).equals(t[n[0]]);const r=this.schema.indexes.concat(this.schema.primKey).filter(c=>{if(c.compound&&n.every(u=>c.keyPath.indexOf(u)>=0)){for(let u=0;u<n.length;++u)if(n.indexOf(c.keyPath[u])===-1)return!1;return!0}return!1}).sort((c,u)=>c.keyPath.length-u.keyPath.length)[0];if(r&&this.db._maxKey!==ft){const c=r.keyPath.slice(0,n.length);return this.where(c).equals(c.map(u=>t[u]))}!r&&Oe&&console.warn(`The query ${JSON.stringify(t)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);const{idxByName:i}=this.schema,s=this.db._deps.indexedDB;function o(c,u){try{return s.cmp(c,u)===0}catch{return!1}}const[l,a]=n.reduce(([c,u],d)=>{const h=i[d],p=t[d];return[c||h,c||!h?yt(u,h&&h.multi?m=>{const g=Ke(m,d);return de(g)&&g.some(y=>o(p,y))}:m=>o(p,Ke(m,d))):u]},[null,null]);return l?this.where(l.name).equals(t[l.keyPath]).filter(a):r?this.filter(a):this.where(n).equals("")}filter(t){return this.toCollection().and(t)}count(t){return this.toCollection().count(t)}offset(t){return this.toCollection().offset(t)}limit(t){return this.toCollection().limit(t)}each(t){return this.toCollection().each(t)}toArray(t){return this.toCollection().toArray(t)}toCollection(){return new this.db.Collection(new this.db.WhereClause(this))}orderBy(t){return new this.db.Collection(new this.db.WhereClause(this,de(t)?`[${t.join("+")}]`:t))}reverse(){return this.toCollection().reverse()}mapToClass(t){this.schema.mappedClass=t;const n=r=>{if(!r)return r;const i=Object.create(t.prototype);for(var s in r)if(Ie(r,s))try{i[s]=r[s]}catch{}return i};return this.schema.readHook&&this.hook.reading.unsubscribe(this.schema.readHook),this.schema.readHook=n,this.hook("reading",n),t}defineClass(){return this.mapToClass(function(t){ge(this,t)})}add(t,n){const{auto:r,keyPath:i}=this.schema.primKey;let s=t;return i&&r&&(s=fr(i)(t)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"add",keys:n!=null?[n]:null,values:[s]})).then(o=>o.numFailures?A.reject(o.failures[0]):o.lastResult).then(o=>{if(i)try{xe(t,i,o)}catch{}return o})}update(t,n){if(typeof t!="object"||de(t))return this.where(":id").equals(t).modify(n);{const r=Ke(t,this.schema.primKey.keyPath);if(r===void 0)return oe(new O.InvalidArgument("Given object does not contain its primary key"));try{typeof n!="function"?ne(n).forEach(i=>{xe(t,i,n[i])}):n(t,{value:t,primKey:r})}catch{}return this.where(":id").equals(r).modify(n)}}put(t,n){const{auto:r,keyPath:i}=this.schema.primKey;let s=t;return i&&r&&(s=fr(i)(t)),this._trans("readwrite",o=>this.core.mutate({trans:o,type:"put",values:[s],keys:n!=null?[n]:null})).then(o=>o.numFailures?A.reject(o.failures[0]):o.lastResult).then(o=>{if(i)try{xe(t,i,o)}catch{}return o})}delete(t){return this._trans("readwrite",n=>this.core.mutate({trans:n,type:"delete",keys:[t]})).then(n=>n.numFailures?A.reject(n.failures[0]):void 0)}clear(){return this._trans("readwrite",t=>this.core.mutate({trans:t,type:"deleteRange",range:ha})).then(t=>t.numFailures?A.reject(t.failures[0]):void 0)}bulkGet(t){return this._trans("readonly",n=>this.core.getMany({keys:t,trans:n}).then(r=>r.map(i=>this.hook.reading.fire(i))))}bulkAdd(t,n,r){const i=Array.isArray(n)?n:void 0,s=(r=r||(i?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:l,keyPath:a}=this.schema.primKey;if(a&&i)throw new O.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new O.InvalidArgument("Arguments objects and keys must have the same length");const c=t.length;let u=a&&l?t.map(fr(a)):t;return this.core.mutate({trans:o,type:"add",keys:i,values:u,wantResults:s}).then(({numFailures:d,results:h,lastResult:p,failures:m})=>{if(d===0)return s?h:p;throw new on(`${this.name}.bulkAdd(): ${d} of ${c} operations failed`,m)})})}bulkPut(t,n,r){const i=Array.isArray(n)?n:void 0,s=(r=r||(i?void 0:n))?r.allKeys:void 0;return this._trans("readwrite",o=>{const{auto:l,keyPath:a}=this.schema.primKey;if(a&&i)throw new O.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");if(i&&i.length!==t.length)throw new O.InvalidArgument("Arguments objects and keys must have the same length");const c=t.length;let u=a&&l?t.map(fr(a)):t;return this.core.mutate({trans:o,type:"put",keys:i,values:u,wantResults:s}).then(({numFailures:d,results:h,lastResult:p,failures:m})=>{if(d===0)return s?h:p;throw new on(`${this.name}.bulkPut(): ${d} of ${c} operations failed`,m)})})}bulkDelete(t){const n=t.length;return this._trans("readwrite",r=>this.core.mutate({trans:r,type:"delete",keys:t})).then(({numFailures:r,lastResult:i,failures:s})=>{if(r===0)return i;throw new on(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`,s)})}}function mn(e){var t={},n=function(o,l){if(l){for(var a=arguments.length,c=new Array(a-1);--a;)c[a-1]=arguments[a];return t[o].subscribe.apply(null,c),e}if(typeof o=="string")return t[o]};n.addEventType=s;for(var r=1,i=arguments.length;r<i;++r)s(arguments[r]);return n;function s(o,l,a){if(typeof o!="object"){var c;l||(l=id),a||(a=q);var u={subscribers:[],fire:a,subscribe:function(d){u.subscribers.indexOf(d)===-1&&(u.subscribers.push(d),u.fire=l(u.fire,d))},unsubscribe:function(d){u.subscribers=u.subscribers.filter(function(h){return h!==d}),u.fire=u.subscribers.reduce(l,a)}};return t[o]=n[o]=u,u}ne(c=o).forEach(function(d){var h=c[d];if(de(h))s(d,c[d][0],c[d][1]);else{if(h!=="asap")throw new O.InvalidArgument("Invalid event config");var p=s(d,an,function(){for(var m=arguments.length,g=new Array(m);m--;)g[m]=arguments[m];p.subscribers.forEach(function(y){Wo(function(){y.apply(null,g)})})})}})}}function gn(e,t){return Ut(t).from({prototype:e}),t}function Bt(e,t){return!(e.filter||e.algorithm||e.or)&&(t?e.justLimit:!e.replayFilter)}function Ai(e,t){e.filter=yt(e.filter,t)}function Ei(e,t,n){var r=e.replayFilter;e.replayFilter=r?()=>yt(r(),t()):t,e.justLimit=n&&!r}function yr(e,t){if(e.isPrimKey)return t.primaryKey;const n=t.getIndexByKeyPath(e.index);if(!n)throw new O.Schema("KeyPath "+e.index+" on object store "+t.name+" is not indexed");return n}function ma(e,t,n){const r=yr(e,t.schema);return t.openCursor({trans:n,values:!e.keysOnly,reverse:e.dir==="prev",unique:!!e.unique,query:{index:r,range:e.range}})}function vr(e,t,n,r){const i=e.replayFilter?yt(e.filter,e.replayFilter()):e.filter;if(e.or){const s={},o=(l,a,c)=>{if(!i||i(a,c,h=>a.stop(h),h=>a.fail(h))){var u=a.primaryKey,d=""+u;d==="[object ArrayBuffer]"&&(d=""+new Uint8Array(u)),Ie(s,d)||(s[d]=!0,t(l,a,c))}};return Promise.all([e.or._iterate(o,n),ga(ma(e,r,n),e.algorithm,o,!e.keysOnly&&e.valueMapper)])}return ga(ma(e,r,n),yt(e.algorithm,i),t,!e.keysOnly&&e.valueMapper)}function ga(e,t,n,r){var i=Y(r?(s,o,l)=>n(r(s),o,l):n);return e.then(s=>{if(s)return s.start(()=>{var o=()=>s.continue();t&&!t(s,l=>o=l,l=>{s.stop(l),o=q},l=>{s.fail(l),o=q})||i(s.value,s,l=>o=l),o()})})}function fe(e,t){try{const n=fa(e),r=fa(t);if(n!==r)return n==="Array"?1:r==="Array"?-1:n==="binary"?1:r==="binary"?-1:n==="string"?1:r==="string"?-1:n==="Date"?1:r!=="Date"?NaN:-1;switch(n){case"number":case"Date":case"string":return e>t?1:e<t?-1:0;case"binary":return function(i,s){const o=i.length,l=s.length,a=o<l?o:l;for(let c=0;c<a;++c)if(i[c]!==s[c])return i[c]<s[c]?-1:1;return o===l?0:o<l?-1:1}(ya(e),ya(t));case"Array":return function(i,s){const o=i.length,l=s.length,a=o<l?o:l;for(let c=0;c<a;++c){const u=fe(i[c],s[c]);if(u!==0)return u}return o===l?0:o<l?-1:1}(e,t)}}catch{}return NaN}function fa(e){const t=typeof e;if(t!=="object")return t;if(ArrayBuffer.isView(e))return"binary";const n=ni(e);return n==="ArrayBuffer"?"binary":n}function ya(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}class md{_read(t,n){var r=this._ctx;return r.error?r.table._trans(null,oe.bind(null,r.error)):r.table._trans("readonly",t).then(n)}_write(t){var n=this._ctx;return n.error?n.table._trans(null,oe.bind(null,n.error)):n.table._trans("readwrite",t,"locked")}_addAlgorithm(t){var n=this._ctx;n.algorithm=yt(n.algorithm,t)}_iterate(t,n){return vr(this._ctx,t,n,this._ctx.table.core)}clone(t){var n=Object.create(this.constructor.prototype),r=Object.create(this._ctx);return t&&ge(r,t),n._ctx=r,n}raw(){return this._ctx.valueMapper=null,this}each(t){var n=this._ctx;return this._read(r=>vr(n,t,r,n.table.core))}count(t){return this._read(n=>{const r=this._ctx,i=r.table.core;if(Bt(r,!0))return i.count({trans:n,query:{index:yr(r,i.schema),range:r.range}}).then(o=>Math.min(o,r.limit));var s=0;return vr(r,()=>(++s,!1),n,i).then(()=>s)}).then(t)}sortBy(t,n){const r=t.split(".").reverse(),i=r[0],s=r.length-1;function o(c,u){return u?o(c[r[u]],u-1):c[i]}var l=this._ctx.dir==="next"?1:-1;function a(c,u){var d=o(c,s),h=o(u,s);return d<h?-l:d>h?l:0}return this.toArray(function(c){return c.sort(a)}).then(n)}toArray(t){return this._read(n=>{var r=this._ctx;if(r.dir==="next"&&Bt(r,!0)&&r.limit>0){const{valueMapper:i}=r,s=yr(r,r.table.core.schema);return r.table.core.query({trans:n,limit:r.limit,values:!0,query:{index:s,range:r.range}}).then(({result:o})=>i?o.map(i):o)}{const i=[];return vr(r,s=>i.push(s),n,r.table.core).then(()=>i)}},t)}offset(t){var n=this._ctx;return t<=0||(n.offset+=t,Bt(n)?Ei(n,()=>{var r=t;return(i,s)=>r===0||(r===1?(--r,!1):(s(()=>{i.advance(r),r=0}),!1))}):Ei(n,()=>{var r=t;return()=>--r<0})),this}limit(t){return this._ctx.limit=Math.min(this._ctx.limit,t),Ei(this._ctx,()=>{var n=t;return function(r,i,s){return--n<=0&&i(s),n>=0}},!0),this}until(t,n){return Ai(this._ctx,function(r,i,s){return!t(r.value)||(i(s),n)}),this}first(t){return this.limit(1).toArray(function(n){return n[0]}).then(t)}last(t){return this.reverse().first(t)}filter(t){var n,r;return Ai(this._ctx,function(i){return t(i.value)}),n=this._ctx,r=t,n.isMatch=yt(n.isMatch,r),this}and(t){return this.filter(t)}or(t){return new this.db.WhereClause(this._ctx.table,t,this)}reverse(){return this._ctx.dir=this._ctx.dir==="prev"?"next":"prev",this._ondirectionchange&&this._ondirectionchange(this._ctx.dir),this}desc(){return this.reverse()}eachKey(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,i){t(i.key,i)})}eachUniqueKey(t){return this._ctx.unique="unique",this.eachKey(t)}eachPrimaryKey(t){var n=this._ctx;return n.keysOnly=!n.isMatch,this.each(function(r,i){t(i.primaryKey,i)})}keys(t){var n=this._ctx;n.keysOnly=!n.isMatch;var r=[];return this.each(function(i,s){r.push(s.key)}).then(function(){return r}).then(t)}primaryKeys(t){var n=this._ctx;if(n.dir==="next"&&Bt(n,!0)&&n.limit>0)return this._read(i=>{var s=yr(n,n.table.core.schema);return n.table.core.query({trans:i,values:!1,limit:n.limit,query:{index:s,range:n.range}})}).then(({result:i})=>i).then(t);n.keysOnly=!n.isMatch;var r=[];return this.each(function(i,s){r.push(s.primaryKey)}).then(function(){return r}).then(t)}uniqueKeys(t){return this._ctx.unique="unique",this.keys(t)}firstKey(t){return this.limit(1).keys(function(n){return n[0]}).then(t)}lastKey(t){return this.reverse().firstKey(t)}distinct(){var t=this._ctx,n=t.index&&t.table.schema.idxByName[t.index];if(!n||!n.multi)return this;var r={};return Ai(this._ctx,function(i){var s=i.primaryKey.toString(),o=Ie(r,s);return r[s]=!0,!o}),this}modify(t){var n=this._ctx;return this._write(r=>{var i;if(typeof t=="function")i=t;else{var s=ne(t),o=s.length;i=function(g){for(var y=!1,v=0;v<o;++v){var f=s[v],b=t[f];Ke(g,f)!==b&&(xe(g,f,b),y=!0)}return y}}const l=n.table.core,{outbound:a,extractKey:c}=l.schema.primaryKey,u=this.db._options.modifyChunkSize||200,d=[];let h=0;const p=[],m=(g,y)=>{const{failures:v,numFailures:f}=y;h+=g-f;for(let b of ne(v))d.push(v[b])};return this.clone().primaryKeys().then(g=>{const y=v=>{const f=Math.min(u,g.length-v);return l.getMany({trans:r,keys:g.slice(v,v+f),cache:"immutable"}).then(b=>{const w=[],k=[],I=a?[]:null,S=[];for(let C=0;C<f;++C){const x=b[C],R={value:sn(x),primKey:g[v+C]};i.call(R,R.value,R)!==!1&&(R.value==null?S.push(g[v+C]):a||fe(c(x),c(R.value))===0?(k.push(R.value),a&&I.push(g[v+C])):(S.push(g[v+C]),w.push(R.value)))}const E=Bt(n)&&n.limit===1/0&&(typeof t!="function"||t===_i)&&{index:n.index,range:n.range};return Promise.resolve(w.length>0&&l.mutate({trans:r,type:"add",values:w}).then(C=>{for(let x in C.failures)S.splice(parseInt(x),1);m(w.length,C)})).then(()=>(k.length>0||E&&typeof t=="object")&&l.mutate({trans:r,type:"put",keys:I,values:k,criteria:E,changeSpec:typeof t!="function"&&t}).then(C=>m(k.length,C))).then(()=>(S.length>0||E&&t===_i)&&l.mutate({trans:r,type:"delete",keys:S,criteria:E}).then(C=>m(S.length,C))).then(()=>g.length>v+f&&y(v+u))})};return y(0).then(()=>{if(d.length>0)throw new tr("Error modifying one or more objects",d,h,p);return g.length})})})}delete(){var t=this._ctx,n=t.range;return Bt(t)&&(t.isPrimKey&&!pd||n.type===3)?this._write(r=>{const{primaryKey:i}=t.table.core.schema,s=n;return t.table.core.count({trans:r,query:{index:i,range:s}}).then(o=>t.table.core.mutate({trans:r,type:"deleteRange",range:s}).then(({failures:l,lastResult:a,results:c,numFailures:u})=>{if(u)throw new tr("Could not delete some values",Object.keys(l).map(d=>l[d]),o-u);return o-u}))}):this.modify(_i)}}const _i=(e,t)=>t.value=null;function gd(e,t){return e<t?-1:e===t?0:1}function fd(e,t){return e>t?-1:e===t?0:1}function Se(e,t,n){var r=e instanceof wa?new e.Collection(e):e;return r._ctx.error=n?new n(t):new TypeError(t),r}function jt(e){return new e.Collection(e,()=>va("")).limit(0)}function yd(e,t,n,r,i,s){for(var o=Math.min(e.length,r.length),l=-1,a=0;a<o;++a){var c=t[a];if(c!==r[a])return i(e[a],n[a])<0?e.substr(0,a)+n[a]+n.substr(a+1):i(e[a],r[a])<0?e.substr(0,a)+r[a]+n.substr(a+1):l>=0?e.substr(0,l)+t[l]+n.substr(l+1):null;i(e[a],c)<0&&(l=a)}return o<r.length&&s==="next"?e+n.substr(e.length):o<e.length&&s==="prev"?e.substr(0,n.length):l<0?null:e.substr(0,l)+r[l]+n.substr(l+1)}function wr(e,t,n,r){var i,s,o,l,a,c,u,d=n.length;if(!n.every(g=>typeof g=="string"))return Se(e,da);function h(g){i=function(v){return v==="next"?f=>f.toUpperCase():f=>f.toLowerCase()}(g),s=function(v){return v==="next"?f=>f.toLowerCase():f=>f.toUpperCase()}(g),o=g==="next"?gd:fd;var y=n.map(function(v){return{lower:s(v),upper:i(v)}}).sort(function(v,f){return o(v.lower,f.lower)});l=y.map(function(v){return v.upper}),a=y.map(function(v){return v.lower}),c=g,u=g==="next"?"":r}h("next");var p=new e.Collection(e,()=>tt(l[0],a[d-1]+r));p._ondirectionchange=function(g){h(g)};var m=0;return p._addAlgorithm(function(g,y,v){var f=g.key;if(typeof f!="string")return!1;var b=s(f);if(t(b,a,m))return!0;for(var w=null,k=m;k<d;++k){var I=yd(f,b,l[k],a[k],o,c);I===null&&w===null?m=k+1:(w===null||o(w,I)>0)&&(w=I)}return y(w!==null?function(){g.continue(w+u)}:v),!1}),p}function tt(e,t,n,r){return{type:2,lower:e,upper:t,lowerOpen:n,upperOpen:r}}function va(e){return{type:1,lower:e,upper:e}}class wa{get Collection(){return this._ctx.table.db.Collection}between(t,n,r,i){r=r!==!1,i=i===!0;try{return this._cmp(t,n)>0||this._cmp(t,n)===0&&(r||i)&&(!r||!i)?jt(this):new this.Collection(this,()=>tt(t,n,!r,!i))}catch{return Se(this,Ve)}}equals(t){return t==null?Se(this,Ve):new this.Collection(this,()=>va(t))}above(t){return t==null?Se(this,Ve):new this.Collection(this,()=>tt(t,void 0,!0))}aboveOrEqual(t){return t==null?Se(this,Ve):new this.Collection(this,()=>tt(t,void 0,!1))}below(t){return t==null?Se(this,Ve):new this.Collection(this,()=>tt(void 0,t,!1,!0))}belowOrEqual(t){return t==null?Se(this,Ve):new this.Collection(this,()=>tt(void 0,t))}startsWith(t){return typeof t!="string"?Se(this,da):this.between(t,t+ft,!0,!0)}startsWithIgnoreCase(t){return t===""?this.startsWith(t):wr(this,(n,r)=>n.indexOf(r[0])===0,[t],ft)}equalsIgnoreCase(t){return wr(this,(n,r)=>n===r[0],[t],"")}anyOfIgnoreCase(){var t=We.apply(Mt,arguments);return t.length===0?jt(this):wr(this,(n,r)=>r.indexOf(n)!==-1,t,"")}startsWithAnyOfIgnoreCase(){var t=We.apply(Mt,arguments);return t.length===0?jt(this):wr(this,(n,r)=>r.some(i=>n.indexOf(i)===0),t,ft)}anyOf(){const t=We.apply(Mt,arguments);let n=this._cmp;try{t.sort(n)}catch{return Se(this,Ve)}if(t.length===0)return jt(this);const r=new this.Collection(this,()=>tt(t[0],t[t.length-1]));r._ondirectionchange=s=>{n=s==="next"?this._ascending:this._descending,t.sort(n)};let i=0;return r._addAlgorithm((s,o,l)=>{const a=s.key;for(;n(a,t[i])>0;)if(++i,i===t.length)return o(l),!1;return n(a,t[i])===0||(o(()=>{s.continue(t[i])}),!1)}),r}notEqual(t){return this.inAnyRange([[Si,t],[t,this.db._maxKey]],{includeLowers:!1,includeUppers:!1})}noneOf(){const t=We.apply(Mt,arguments);if(t.length===0)return new this.Collection(this);try{t.sort(this._ascending)}catch{return Se(this,Ve)}const n=t.reduce((r,i)=>r?r.concat([[r[r.length-1][1],i]]):[[Si,i]],null);return n.push([t[t.length-1],this.db._maxKey]),this.inAnyRange(n,{includeLowers:!1,includeUppers:!1})}inAnyRange(t,n){const r=this._cmp,i=this._ascending,s=this._descending,o=this._min,l=this._max;if(t.length===0)return jt(this);if(!t.every(f=>f[0]!==void 0&&f[1]!==void 0&&i(f[0],f[1])<=0))return Se(this,"First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower",O.InvalidArgument);const a=!n||n.includeLowers!==!1,c=n&&n.includeUppers===!0;let u,d=i;function h(f,b){return d(f[0],b[0])}try{u=t.reduce(function(f,b){let w=0,k=f.length;for(;w<k;++w){const I=f[w];if(r(b[0],I[1])<0&&r(b[1],I[0])>0){I[0]=o(I[0],b[0]),I[1]=l(I[1],b[1]);break}}return w===k&&f.push(b),f},[]),u.sort(h)}catch{return Se(this,Ve)}let p=0;const m=c?f=>i(f,u[p][1])>0:f=>i(f,u[p][1])>=0,g=a?f=>s(f,u[p][0])>0:f=>s(f,u[p][0])>=0;let y=m;const v=new this.Collection(this,()=>tt(u[0][0],u[u.length-1][1],!a,!c));return v._ondirectionchange=f=>{f==="next"?(y=m,d=i):(y=g,d=s),u.sort(h)},v._addAlgorithm((f,b,w)=>{for(var k=f.key;y(k);)if(++p,p===u.length)return b(w),!1;return!!function(I){return!m(I)&&!g(I)}(k)||(this._cmp(k,u[p][1])===0||this._cmp(k,u[p][0])===0||b(()=>{d===i?f.continue(u[p][0]):f.continue(u[p][1])}),!1)}),v}startsWithAnyOf(){const t=We.apply(Mt,arguments);return t.every(n=>typeof n=="string")?t.length===0?jt(this):this.inAnyRange(t.map(n=>[n,n+ft])):Se(this,"startsWithAnyOf() only works with strings")}}function Ue(e){return Y(function(t){return fn(t),e(t.target.error),!1})}function fn(e){e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault()}const yn="storagemutated",nt="x-storagemutated-1",rt=mn(null,yn);class vd{_lock(){return rn(!T.global),++this._reculock,this._reculock!==1||T.global||(T.lockOwnerFor=this),this}_unlock(){if(rn(!T.global),--this._reculock==0)for(T.global||(T.lockOwnerFor=null);this._blockedFuncs.length>0&&!this._locked();){var t=this._blockedFuncs.shift();try{Ft(t[1],t[0])}catch{}}return this}_locked(){return this._reculock&&T.lockOwnerFor!==this}create(t){if(!this.mode)return this;const n=this.db.idbdb,r=this.db._state.dbOpenError;if(rn(!this.idbtrans),!t&&!n)switch(r&&r.name){case"DatabaseClosedError":throw new O.DatabaseClosed(r);case"MissingAPIError":throw new O.MissingAPI(r.message,r);default:throw new O.OpenFailed(r)}if(!this.active)throw new O.TransactionInactive;return rn(this._completion._state===null),(t=this.idbtrans=t||(this.db.core?this.db.core.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}):n.transaction(this.storeNames,this.mode,{durability:this.chromeTransactionDurability}))).onerror=Y(i=>{fn(i),this._reject(t.error)}),t.onabort=Y(i=>{fn(i),this.active&&this._reject(new O.Abort(t.error)),this.active=!1,this.on("abort").fire(i)}),t.oncomplete=Y(()=>{this.active=!1,this._resolve(),"mutatedParts"in t&&rt.storagemutated.fire(t.mutatedParts)}),this}_promise(t,n,r){if(t==="readwrite"&&this.mode!=="readwrite")return oe(new O.ReadOnly("Transaction is readonly"));if(!this.active)return oe(new O.TransactionInactive);if(this._locked())return new A((s,o)=>{this._blockedFuncs.push([()=>{this._promise(t,n,r).then(s,o)},T])});if(r)return Xe(()=>{var s=new A((o,l)=>{this._lock();const a=n(o,l,this);a&&a.then&&a.then(o,l)});return s.finally(()=>this._unlock()),s._lib=!0,s});var i=new A((s,o)=>{var l=n(s,o,this);l&&l.then&&l.then(s,o)});return i._lib=!0,i}_root(){return this.parent?this.parent._root():this}waitFor(t){var n=this._root();const r=A.resolve(t);if(n._waitingFor)n._waitingFor=n._waitingFor.then(()=>r);else{n._waitingFor=r,n._waitingQueue=[];var i=n.idbtrans.objectStore(n.storeNames[0]);(function o(){for(++n._spinCount;n._waitingQueue.length;)n._waitingQueue.shift()();n._waitingFor&&(i.get(-1/0).onsuccess=o)})()}var s=n._waitingFor;return new A((o,l)=>{r.then(a=>n._waitingQueue.push(Y(o.bind(null,a))),a=>n._waitingQueue.push(Y(l.bind(null,a)))).finally(()=>{n._waitingFor===s&&(n._waitingFor=null)})})}abort(){this.active&&(this.active=!1,this.idbtrans&&this.idbtrans.abort(),this._reject(new O.Abort))}table(t){const n=this._memoizedTables||(this._memoizedTables={});if(Ie(n,t))return n[t];const r=this.schema[t];if(!r)throw new O.NotFound("Table "+t+" not part of transaction");const i=new this.db.Table(t,r,this);return i.core=this.db.core.table(t),n[t]=i,i}}function Li(e,t,n,r,i,s,o){return{name:e,keyPath:t,unique:n,multi:r,auto:i,compound:s,src:(n&&!o?"&":"")+(r?"*":"")+(i?"++":"")+ba(t)}}function ba(e){return typeof e=="string"?e:e?"["+[].join.call(e,"+")+"]":""}function Ia(e,t,n){return{name:e,primKey:t,indexes:n,mappedClass:null,idxByName:zo(n,r=>[r.name,r])}}let vn=e=>{try{return e.only([[]]),vn=()=>[[]],[[]]}catch{return vn=()=>ft,ft}};function xi(e){return e==null?()=>{}:typeof e=="string"?function(t){return t.split(".").length===1?n=>n[t]:n=>Ke(n,t)}(e):t=>Ke(t,e)}function Sa(e){return[].slice.call(e)}let wd=0;function wn(e){return e==null?":id":typeof e=="string"?e:`[${e.join("+")}]`}function bd(e,t,n){function r(a){if(a.type===3)return null;if(a.type===4)throw new Error("Cannot convert never type to IDBKeyRange");const{lower:c,upper:u,lowerOpen:d,upperOpen:h}=a;return c===void 0?u===void 0?null:t.upperBound(u,!!h):u===void 0?t.lowerBound(c,!!d):t.bound(c,u,!!d,!!h)}const{schema:i,hasGetAll:s}=function(a,c){const u=Sa(a.objectStoreNames);return{schema:{name:a.name,tables:u.map(d=>c.objectStore(d)).map(d=>{const{keyPath:h,autoIncrement:p}=d,m=de(h),g=h==null,y={},v={name:d.name,primaryKey:{name:null,isPrimaryKey:!0,outbound:g,compound:m,keyPath:h,autoIncrement:p,unique:!0,extractKey:xi(h)},indexes:Sa(d.indexNames).map(f=>d.index(f)).map(f=>{const{name:b,unique:w,multiEntry:k,keyPath:I}=f,S={name:b,compound:de(I),keyPath:I,unique:w,multiEntry:k,extractKey:xi(I)};return y[wn(I)]=S,S}),getIndexByKeyPath:f=>y[wn(f)]};return y[":id"]=v.primaryKey,h!=null&&(y[wn(h)]=v.primaryKey),v})},hasGetAll:u.length>0&&"getAll"in c.objectStore(u[0])&&!(typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604)}}(e,n),o=i.tables.map(a=>function(c){const u=c.name;return{name:u,schema:c,mutate:function({trans:d,type:h,keys:p,values:m,range:g}){return new Promise((y,v)=>{y=Y(y);const f=d.objectStore(u),b=f.keyPath==null,w=h==="put"||h==="add";if(!w&&h!=="delete"&&h!=="deleteRange")throw new Error("Invalid operation type: "+h);const{length:k}=p||m||{length:1};if(p&&m&&p.length!==m.length)throw new Error("Given keys array must have same length as given values array.");if(k===0)return y({numFailures:0,failures:{},results:[],lastResult:void 0});let I;const S=[],E=[];let C=0;const x=K=>{++C,fn(K)};if(h==="deleteRange"){if(g.type===4)return y({numFailures:C,failures:E,results:[],lastResult:void 0});g.type===3?S.push(I=f.clear()):S.push(I=f.delete(r(g)))}else{const[K,F]=w?b?[m,p]:[m,null]:[p,null];if(w)for(let P=0;P<k;++P)S.push(I=F&&F[P]!==void 0?f[h](K[P],F[P]):f[h](K[P])),I.onerror=x;else for(let P=0;P<k;++P)S.push(I=f[h](K[P])),I.onerror=x}const R=K=>{const F=K.target.result;S.forEach((P,L)=>P.error!=null&&(E[L]=P.error)),y({numFailures:C,failures:E,results:h==="delete"?p:S.map(P=>P.result),lastResult:F})};I.onerror=K=>{x(K),R(K)},I.onsuccess=R})},getMany:({trans:d,keys:h})=>new Promise((p,m)=>{p=Y(p);const g=d.objectStore(u),y=h.length,v=new Array(y);let f,b=0,w=0;const k=S=>{const E=S.target;v[E._pos]=E.result,++w===b&&p(v)},I=Ue(m);for(let S=0;S<y;++S)h[S]!=null&&(f=g.get(h[S]),f._pos=S,f.onsuccess=k,f.onerror=I,++b);b===0&&p(v)}),get:({trans:d,key:h})=>new Promise((p,m)=>{p=Y(p);const g=d.objectStore(u).get(h);g.onsuccess=y=>p(y.target.result),g.onerror=Ue(m)}),query:function(d){return h=>new Promise((p,m)=>{p=Y(p);const{trans:g,values:y,limit:v,query:f}=h,b=v===1/0?void 0:v,{index:w,range:k}=f,I=g.objectStore(u),S=w.isPrimaryKey?I:I.index(w.name),E=r(k);if(v===0)return p({result:[]});if(d){const C=y?S.getAll(E,b):S.getAllKeys(E,b);C.onsuccess=x=>p({result:x.target.result}),C.onerror=Ue(m)}else{let C=0;const x=y||!("openKeyCursor"in S)?S.openCursor(E):S.openKeyCursor(E),R=[];x.onsuccess=K=>{const F=x.result;return F?(R.push(y?F.value:F.primaryKey),++C===v?p({result:R}):void F.continue()):p({result:R})},x.onerror=Ue(m)}})}(s),openCursor:function({trans:d,values:h,query:p,reverse:m,unique:g}){return new Promise((y,v)=>{y=Y(y);const{index:f,range:b}=p,w=d.objectStore(u),k=f.isPrimaryKey?w:w.index(f.name),I=m?g?"prevunique":"prev":g?"nextunique":"next",S=h||!("openKeyCursor"in k)?k.openCursor(r(b),I):k.openKeyCursor(r(b),I);S.onerror=Ue(v),S.onsuccess=Y(E=>{const C=S.result;if(!C)return void y(null);C.___id=++wd,C.done=!1;const x=C.continue.bind(C);let R=C.continuePrimaryKey;R&&(R=R.bind(C));const K=C.advance.bind(C),F=()=>{throw new Error("Cursor not stopped")};C.trans=d,C.stop=C.continue=C.continuePrimaryKey=C.advance=()=>{throw new Error("Cursor not started")},C.fail=Y(v),C.next=function(){let P=1;return this.start(()=>P--?this.continue():this.stop()).then(()=>this)},C.start=P=>{const L=new Promise((V,re)=>{V=Y(V),S.onerror=Ue(re),C.fail=re,C.stop=ae=>{C.stop=C.continue=C.continuePrimaryKey=C.advance=F,V(ae)}}),U=()=>{if(S.result)try{P()}catch(V){C.fail(V)}else C.done=!0,C.start=()=>{throw new Error("Cursor behind last entry")},C.stop()};return S.onsuccess=Y(V=>{S.onsuccess=U,U()}),C.continue=x,C.continuePrimaryKey=R,C.advance=K,U(),L},y(C)},v)})},count({query:d,trans:h}){const{index:p,range:m}=d;return new Promise((g,y)=>{const v=h.objectStore(u),f=p.isPrimaryKey?v:v.index(p.name),b=r(m),w=b?f.count(b):f.count();w.onsuccess=Y(k=>g(k.target.result)),w.onerror=Ue(y)})}}}(a)),l={};return o.forEach(a=>l[a.name]=a),{stack:"dbcore",transaction:e.transaction.bind(e),table(a){if(!l[a])throw new Error(`Table '${a}' not found`);return l[a]},MIN_KEY:-1/0,MAX_KEY:vn(t),schema:i}}function Ti({_novip:e},t){const n=t.db,r=function(i,s,{IDBKeyRange:o,indexedDB:l},a){return{dbcore:function(c,u){return u.reduce((d,{create:h})=>({...d,...h(d)}),c)}(bd(s,o,a),i.dbcore)}}(e._middlewares,n,e._deps,t);e.core=r.dbcore,e.tables.forEach(i=>{const s=i.name;e.core.schema.tables.some(o=>o.name===s)&&(i.core=e.core.table(s),e[s]instanceof e.Table&&(e[s].core=i.core))})}function br({_novip:e},t,n,r){n.forEach(i=>{const s=r[i];t.forEach(o=>{const l=ei(o,i);(!l||"value"in l&&l.value===void 0)&&(o===e.Transaction.prototype||o instanceof e.Transaction?je(o,i,{get(){return this.table(i)},set(a){jo(this,i,{value:a,writable:!0,configurable:!0,enumerable:!0})}}):o[i]=new e.Table(i,s))})})}function Ri({_novip:e},t){t.forEach(n=>{for(let r in n)n[r]instanceof e.Table&&delete n[r]})}function Id(e,t){return e._cfg.version-t._cfg.version}function Sd(e,t,n,r){const i=e._dbSchema,s=e._createTransaction("readwrite",e._storeNames,i);s.create(n),s._completion.catch(r);const o=s._reject.bind(s),l=T.transless||T;Xe(()=>{T.trans=s,T.transless=l,t===0?(ne(i).forEach(a=>{Oi(n,a,i[a].primKey,i[a].indexes)}),Ti(e,n),A.follow(()=>e.on.populate.fire(s)).catch(o)):function({_novip:a},c,u,d){const h=[],p=a._versions;let m=a._dbSchema=Mi(a,a.idbdb,d),g=!1;const y=p.filter(f=>f._cfg.version>=c);function v(){return h.length?A.resolve(h.shift()(u.idbtrans)).then(v):A.resolve()}return y.forEach(f=>{h.push(()=>{const b=m,w=f._cfg.dbschema;Di(a,b,d),Di(a,w,d),m=a._dbSchema=w;const k=Ca(b,w);k.add.forEach(S=>{Oi(d,S[0],S[1].primKey,S[1].indexes)}),k.change.forEach(S=>{if(S.recreate)throw new O.Upgrade("Not yet support for changing primary key");{const E=d.objectStore(S.name);S.add.forEach(C=>Ui(E,C)),S.change.forEach(C=>{E.deleteIndex(C.name),Ui(E,C)}),S.del.forEach(C=>E.deleteIndex(C))}});const I=f._cfg.contentUpgrade;if(I&&f._cfg.version>c){Ti(a,d),u._memoizedTables={},g=!0;let S=Vo(w);k.del.forEach(R=>{S[R]=b[R]}),Ri(a,[a.Transaction.prototype]),br(a,[a.Transaction.prototype],ne(S),S),u.schema=S;const E=ii(I);let C;E&&Pt();const x=A.follow(()=>{if(C=I(u),C&&E){var R=ze.bind(null,null);C.then(R,R)}});return C&&typeof C.then=="function"?A.resolve(C):x.then(()=>C)}}),h.push(b=>{(!g||!dd)&&function(w,k){[].slice.call(k.db.objectStoreNames).forEach(I=>w[I]==null&&k.db.deleteObjectStore(I))}(f._cfg.dbschema,b),Ri(a,[a.Transaction.prototype]),br(a,[a.Transaction.prototype],a._storeNames,a._dbSchema),u.schema=a._dbSchema})}),v().then(()=>{var f,b;b=d,ne(f=m).forEach(w=>{b.db.objectStoreNames.contains(w)||Oi(b,w,f[w].primKey,f[w].indexes)})})}(e,t,s,n).catch(o)})}function Ca(e,t){const n={del:[],add:[],change:[]};let r;for(r in e)t[r]||n.del.push(r);for(r in t){const i=e[r],s=t[r];if(i){const o={name:r,def:s,recreate:!1,del:[],add:[],change:[]};if(""+(i.primKey.keyPath||"")!=""+(s.primKey.keyPath||"")||i.primKey.auto!==s.primKey.auto&&!mr)o.recreate=!0,n.change.push(o);else{const l=i.idxByName,a=s.idxByName;let c;for(c in l)a[c]||o.del.push(c);for(c in a){const u=l[c],d=a[c];u?u.src!==d.src&&o.change.push(d):o.add.push(d)}(o.del.length>0||o.add.length>0||o.change.length>0)&&n.change.push(o)}}else n.add.push([r,s])}return n}function Oi(e,t,n,r){const i=e.db.createObjectStore(t,n.keyPath?{keyPath:n.keyPath,autoIncrement:n.auto}:{autoIncrement:n.auto});return r.forEach(s=>Ui(i,s)),i}function Ui(e,t){e.createIndex(t.name,t.keyPath,{unique:t.unique,multiEntry:t.multi})}function Mi(e,t,n){const r={};return er(t.objectStoreNames,0).forEach(i=>{const s=n.objectStore(i);let o=s.keyPath;const l=Li(ba(o),o||"",!1,!1,!!s.autoIncrement,o&&typeof o!="string",!0),a=[];for(let u=0;u<s.indexNames.length;++u){const d=s.index(s.indexNames[u]);o=d.keyPath;var c=Li(d.name,o,!!d.unique,!!d.multiEntry,!1,o&&typeof o!="string",!1);a.push(c)}r[i]=Ia(i,l,a)}),r}function Di({_novip:e},t,n){const r=n.db.objectStoreNames;for(let i=0;i<r.length;++i){const s=r[i],o=n.objectStore(s);e._hasGetAll="getAll"in o;for(let l=0;l<o.indexNames.length;++l){const a=o.indexNames[l],c=o.index(a).keyPath,u=typeof c=="string"?c:"["+er(c).join("+")+"]";if(t[s]){const d=t[s].idxByName[u];d&&(d.name=a,delete t[s].idxByName[u],t[s].idxByName[a]=d)}}}typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&!/(Chrome\/|Edge\/)/.test(navigator.userAgent)&&H.WorkerGlobalScope&&H instanceof H.WorkerGlobalScope&&[].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1]<604&&(e._hasGetAll=!1)}class Cd{_parseStoresSpec(t,n){ne(t).forEach(r=>{if(t[r]!==null){var i=t[r].split(",").map((o,l)=>{const a=(o=o.trim()).replace(/([&*]|\+\+)/g,""),c=/^\[/.test(a)?a.match(/^\[(.*)\]$/)[1].split("+"):a;return Li(a,c||null,/\&/.test(o),/\*/.test(o),/\+\+/.test(o),de(c),l===0)}),s=i.shift();if(s.multi)throw new O.Schema("Primary key cannot be multi-valued");i.forEach(o=>{if(o.auto)throw new O.Schema("Only primary key can be marked as autoIncrement (++)");if(!o.keyPath)throw new O.Schema("Index must have a name and cannot be an empty string")}),n[r]=Ia(r,s,i)}})}stores(t){const n=this.db;this._cfg.storesSource=this._cfg.storesSource?ge(this._cfg.storesSource,t):t;const r=n._versions,i={};let s={};return r.forEach(o=>{ge(i,o._cfg.storesSource),s=o._cfg.dbschema={},o._parseStoresSpec(i,s)}),n._dbSchema=s,Ri(n,[n._allTables,n,n.Transaction.prototype]),br(n,[n._allTables,n,n.Transaction.prototype,this._cfg.tables],ne(s),s),n._storeNames=ne(s),this}upgrade(t){return this._cfg.contentUpgrade=li(this._cfg.contentUpgrade||q,t),this}}function Ni(e,t){let n=e._dbNamesDB;return n||(n=e._dbNamesDB=new St(gr,{addons:[],indexedDB:e,IDBKeyRange:t}),n.version(1).stores({dbnames:"name"})),n.table("dbnames")}function Pi(e){return e&&typeof e.databases=="function"}function Fi(e){return Xe(function(){return T.letThrough=!0,e()})}function kd(){var e;return!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent)&&indexedDB.databases?new Promise(function(t){var n=function(){return indexedDB.databases().finally(t)};e=setInterval(n,100),n()}).finally(function(){return clearInterval(e)}):Promise.resolve()}function Ad(e){const t=e._state,{indexedDB:n}=e._deps;if(t.isBeingOpened||e.idbdb)return t.dbReadyPromise.then(()=>t.dbOpenError?oe(t.dbOpenError):e);Oe&&(t.openCanceller._stackHolder=pt()),t.isBeingOpened=!0,t.dbOpenError=null,t.openComplete=!1;const r=t.openCanceller;function i(){if(t.openCanceller!==r)throw new O.DatabaseClosed("db.open() was cancelled")}let s=t.dbReadyResolve,o=null,l=!1;const a=()=>new A((c,u)=>{if(i(),!n)throw new O.MissingAPI;const d=e.name,h=t.autoSchema?n.open(d):n.open(d,Math.round(10*e.verno));if(!h)throw new O.MissingAPI;h.onerror=Ue(u),h.onblocked=Y(e._fireOnBlocked),h.onupgradeneeded=Y(p=>{if(o=h.transaction,t.autoSchema&&!e._options.allowEmptyDB){h.onerror=fn,o.abort(),h.result.close();const g=n.deleteDatabase(d);g.onsuccess=g.onerror=Y(()=>{u(new O.NoSuchDatabase(`Database ${d} doesnt exist`))})}else{o.onerror=Ue(u);var m=p.oldVersion>Math.pow(2,62)?0:p.oldVersion;l=m<1,e._novip.idbdb=h.result,Sd(e,m/10,o,u)}},u),h.onsuccess=Y(()=>{o=null;const p=e._novip.idbdb=h.result,m=er(p.objectStoreNames);if(m.length>0)try{const y=p.transaction((g=m).length===1?g[0]:g,"readonly");t.autoSchema?function({_novip:v},f,b){v.verno=f.version/10;const w=v._dbSchema=Mi(0,f,b);v._storeNames=er(f.objectStoreNames,0),br(v,[v._allTables],ne(w),w)}(e,p,y):(Di(e,e._dbSchema,y),function(v,f){const b=Ca(Mi(0,v.idbdb,f),v._dbSchema);return!(b.add.length||b.change.some(w=>w.add.length||w.change.length))}(e,y)||console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")),Ti(e,y)}catch{}var g;hn.push(e),p.onversionchange=Y(y=>{t.vcFired=!0,e.on("versionchange").fire(y)}),p.onclose=Y(y=>{e.on("close").fire(y)}),l&&function({indexedDB:y,IDBKeyRange:v},f){!Pi(y)&&f!==gr&&Ni(y,v).put({name:f}).catch(q)}(e._deps,d),c()},u)}).catch(c=>c&&c.name==="UnknownError"&&t.PR1398_maxLoop>0?(t.PR1398_maxLoop--,console.warn("Dexie: Workaround for Chrome UnknownError on open()"),a()):A.reject(c));return A.race([r,(typeof navigator>"u"?A.resolve():kd()).then(a)]).then(()=>(i(),t.onReadyBeingFired=[],A.resolve(Fi(()=>e.on.ready.fire(e.vip))).then(function c(){if(t.onReadyBeingFired.length>0){let u=t.onReadyBeingFired.reduce(li,q);return t.onReadyBeingFired=[],A.resolve(Fi(()=>u(e.vip))).then(c)}}))).finally(()=>{t.onReadyBeingFired=null,t.isBeingOpened=!1}).then(()=>e).catch(c=>{t.dbOpenError=c;try{o&&o.abort()}catch{}return r===t.openCanceller&&e._close(),oe(c)}).finally(()=>{t.openComplete=!0,s()})}function Bi(e){var t=s=>e.next(s),n=i(t),r=i(s=>e.throw(s));function i(s){return o=>{var l=s(o),a=l.value;return l.done?a:a&&typeof a.then=="function"?a.then(n,r):de(a)?Promise.all(a).then(n,r):n(a)}}return i(t)()}function Ed(e,t,n){var r=arguments.length;if(r<2)throw new O.InvalidArgument("Too few arguments");for(var i=new Array(r-1);--r;)i[r-1]=arguments[r];return n=i.pop(),[e,Go(i),n]}function ka(e,t,n,r,i){return A.resolve().then(()=>{const s=T.transless||T,o=e._createTransaction(t,n,e._dbSchema,r),l={trans:o,transless:s};if(r)o.idbtrans=r.idbtrans;else try{o.create(),e._state.PR1398_maxLoop=3}catch(d){return d.name===ai.InvalidState&&e.isOpen()&&--e._state.PR1398_maxLoop>0?(console.warn("Dexie: Need to reopen db"),e._close(),e.open().then(()=>ka(e,t,n,null,i))):oe(d)}const a=ii(i);let c;a&&Pt();const u=A.follow(()=>{if(c=i.call(o,o),c)if(a){var d=ze.bind(null,null);c.then(d,d)}else typeof c.next=="function"&&typeof c.throw=="function"&&(c=Bi(c))},l);return(c&&typeof c.then=="function"?A.resolve(c).then(d=>o.active?d:oe(new O.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))):u.then(()=>c)).then(d=>(r&&o._resolve(),o._completion.then(()=>d))).catch(d=>(o._reject(d),oe(d)))})}function Ir(e,t,n){const r=de(e)?e.slice():[e];for(let i=0;i<n;++i)r.push(t);return r}const _d={stack:"dbcore",name:"VirtualIndexMiddleware",level:1,create:function(e){return{...e,table(t){const n=e.table(t),{schema:r}=n,i={},s=[];function o(c,u,d){const h=wn(c),p=i[h]=i[h]||[],m=c==null?0:typeof c=="string"?1:c.length,g=u>0,y={...d,isVirtual:g,keyTail:u,keyLength:m,extractKey:xi(c),unique:!g&&d.unique};return p.push(y),y.isPrimaryKey||s.push(y),m>1&&o(m===2?c[0]:c.slice(0,m-1),u+1,d),p.sort((v,f)=>v.keyTail-f.keyTail),y}const l=o(r.primaryKey.keyPath,0,r.primaryKey);i[":id"]=[l];for(const c of r.indexes)o(c.keyPath,0,c);function a(c){const u=c.query.index;return u.isVirtual?{...c,query:{index:u,range:(d=c.query.range,h=u.keyTail,{type:d.type===1?2:d.type,lower:Ir(d.lower,d.lowerOpen?e.MAX_KEY:e.MIN_KEY,h),lowerOpen:!0,upper:Ir(d.upper,d.upperOpen?e.MIN_KEY:e.MAX_KEY,h),upperOpen:!0})}}:c;var d,h}return{...n,schema:{...r,primaryKey:l,indexes:s,getIndexByKeyPath:function(c){const u=i[wn(c)];return u&&u[0]}},count:c=>n.count(a(c)),query:c=>n.query(a(c)),openCursor(c){const{keyTail:u,isVirtual:d,keyLength:h}=c.query.index;return d?n.openCursor(a(c)).then(p=>p&&function(m){return Object.create(m,{continue:{value:function(g){g!=null?m.continue(Ir(g,c.reverse?e.MAX_KEY:e.MIN_KEY,u)):c.unique?m.continue(m.key.slice(0,h).concat(c.reverse?e.MIN_KEY:e.MAX_KEY,u)):m.continue()}},continuePrimaryKey:{value(g,y){m.continuePrimaryKey(Ir(g,e.MAX_KEY,u),y)}},primaryKey:{get:()=>m.primaryKey},key:{get(){const g=m.key;return h===1?g[0]:g.slice(0,h)}},value:{get:()=>m.value}})}(p)):n.openCursor(c)}}}}}};function ji(e,t,n,r){return n=n||{},r=r||"",ne(e).forEach(i=>{if(Ie(t,i)){var s=e[i],o=t[i];if(typeof s=="object"&&typeof o=="object"&&s&&o){const l=ni(s);l!==ni(o)?n[r+i]=t[i]:l==="Object"?ji(s,o,n,r+i+"."):s!==o&&(n[r+i]=t[i])}else s!==o&&(n[r+i]=t[i])}else n[r+i]=void 0}),ne(t).forEach(i=>{Ie(e,i)||(n[r+i]=t[i])}),n}const Ld={stack:"dbcore",name:"HooksMiddleware",level:2,create:e=>({...e,table(t){const n=e.table(t),{primaryKey:r}=n.schema;return{...n,mutate(i){const s=T.trans,{deleting:o,creating:l,updating:a}=s.table(t).hook;switch(i.type){case"add":if(l.fire===q)break;return s._promise("readwrite",()=>c(i),!0);case"put":if(l.fire===q&&a.fire===q)break;return s._promise("readwrite",()=>c(i),!0);case"delete":if(o.fire===q)break;return s._promise("readwrite",()=>c(i),!0);case"deleteRange":if(o.fire===q)break;return s._promise("readwrite",()=>function(d){return u(d.trans,d.range,1e4)}(i),!0)}return n.mutate(i);function c(d){const h=T.trans,p=d.keys||function(m,g){return g.type==="delete"?g.keys:g.keys||g.values.map(m.extractKey)}(r,d);if(!p)throw new Error("Keys missing");return(d=d.type==="add"||d.type==="put"?{...d,keys:p}:{...d}).type!=="delete"&&(d.values=[...d.values]),d.keys&&(d.keys=[...d.keys]),function(m,g,y){return g.type==="add"?Promise.resolve([]):m.getMany({trans:g.trans,keys:y,cache:"immutable"})}(n,d,p).then(m=>{const g=p.map((y,v)=>{const f=m[v],b={onerror:null,onsuccess:null};if(d.type==="delete")o.fire.call(b,y,f,h);else if(d.type==="add"||f===void 0){const w=l.fire.call(b,y,d.values[v],h);y==null&&w!=null&&(y=w,d.keys[v]=y,r.outbound||xe(d.values[v],r.keyPath,y))}else{const w=ji(f,d.values[v]),k=a.fire.call(b,w,y,f,h);if(k){const I=d.values[v];Object.keys(k).forEach(S=>{Ie(I,S)?I[S]=k[S]:xe(I,S,k[S])})}}return b});return n.mutate(d).then(({failures:y,results:v,numFailures:f,lastResult:b})=>{for(let w=0;w<p.length;++w){const k=v?v[w]:p[w],I=g[w];k==null?I.onerror&&I.onerror(y[w]):I.onsuccess&&I.onsuccess(d.type==="put"&&m[w]?d.values[w]:k)}return{failures:y,results:v,numFailures:f,lastResult:b}}).catch(y=>(g.forEach(v=>v.onerror&&v.onerror(y)),Promise.reject(y)))})}function u(d,h,p){return n.query({trans:d,values:!1,query:{index:r,range:h},limit:p}).then(({result:m})=>c({type:"delete",keys:m,trans:d}).then(g=>g.numFailures>0?Promise.reject(g.failures[0]):m.length<p?{failures:[],numFailures:0,lastResult:void 0}:u(d,{...h,lower:m[m.length-1],lowerOpen:!0},p)))}}}}})};function Aa(e,t,n){try{if(!t||t.keys.length<e.length)return null;const r=[];for(let i=0,s=0;i<t.keys.length&&s<e.length;++i)fe(t.keys[i],e[s])===0&&(r.push(n?sn(t.values[i]):t.values[i]),++s);return r.length===e.length?r:null}catch{return null}}const xd={stack:"dbcore",level:-1,create:e=>({table:t=>{const n=e.table(t);return{...n,getMany:r=>{if(!r.cache)return n.getMany(r);const i=Aa(r.keys,r.trans._cache,r.cache==="clone");return i?A.resolve(i):n.getMany(r).then(s=>(r.trans._cache={keys:r.keys,values:r.cache==="clone"?sn(s):s},s))},mutate:r=>(r.type!=="add"&&(r.trans._cache=null),n.mutate(r))}}})};function Ki(e){return!("from"in e)}const Ge=function(e,t){if(!this){const n=new Ge;return e&&"d"in e&&ge(n,e),n}ge(this,arguments.length?{d:1,from:e,to:arguments.length>1?t:e}:{d:0})};function bn(e,t,n){const r=fe(t,n);if(isNaN(r))return;if(r>0)throw RangeError();if(Ki(e))return ge(e,{from:t,to:n,d:1});const i=e.l,s=e.r;if(fe(n,e.from)<0)return i?bn(i,t,n):e.l={from:t,to:n,d:1,l:null,r:null},Ea(e);if(fe(t,e.to)>0)return s?bn(s,t,n):e.r={from:t,to:n,d:1,l:null,r:null},Ea(e);fe(t,e.from)<0&&(e.from=t,e.l=null,e.d=s?s.d+1:1),fe(n,e.to)>0&&(e.to=n,e.r=null,e.d=e.l?e.l.d+1:1);const o=!e.r;i&&!e.l&&Sr(e,i),s&&o&&Sr(e,s)}function Sr(e,t){Ki(t)||function n(r,{from:i,to:s,l:o,r:l}){bn(r,i,s),o&&n(r,o),l&&n(r,l)}(e,t)}function Td(e,t){const n=Wi(t);let r=n.next();if(r.done)return!1;let i=r.value;const s=Wi(e);let o=s.next(i.from),l=o.value;for(;!r.done&&!o.done;){if(fe(l.from,i.to)<=0&&fe(l.to,i.from)>=0)return!0;fe(i.from,l.from)<0?i=(r=n.next(l.from)).value:l=(o=s.next(i.from)).value}return!1}function Wi(e){let t=Ki(e)?null:{s:0,n:e};return{next(n){const r=arguments.length>0;for(;t;)switch(t.s){case 0:if(t.s=1,r)for(;t.n.l&&fe(n,t.n.from)<0;)t={up:t,n:t.n.l,s:1};else for(;t.n.l;)t={up:t,n:t.n.l,s:1};case 1:if(t.s=2,!r||fe(n,t.n.to)<=0)return{value:t.n,done:!1};case 2:if(t.n.r){t.s=3,t={up:t,n:t.n.r,s:0};continue}case 3:t=t.up}return{done:!0}}}}function Ea(e){var t,n;const r=(((t=e.r)===null||t===void 0?void 0:t.d)||0)-(((n=e.l)===null||n===void 0?void 0:n.d)||0),i=r>1?"r":r<-1?"l":"";if(i){const s=i==="r"?"l":"r",o={...e},l=e[i];e.from=l.from,e.to=l.to,e[i]=l[i],o[i]=l[s],e[s]=o,o.d=_a(o)}e.d=_a(e)}function _a({r:e,l:t}){return(e?t?Math.max(e.d,t.d):e.d:t?t.d:0)+1}Ot(Ge.prototype,{add(e){return Sr(this,e),this},addKey(e){return bn(this,e,e),this},addKeys(e){return e.forEach(t=>bn(this,t,t)),this},[ri](){return Wi(this)}});const Rd={stack:"dbcore",level:0,create:e=>{const t=e.schema.name,n=new Ge(e.MIN_KEY,e.MAX_KEY);return{...e,table:r=>{const i=e.table(r),{schema:s}=i,{primaryKey:o}=s,{extractKey:l,outbound:a}=o,c={...i,mutate:h=>{const p=h.trans,m=p.mutatedParts||(p.mutatedParts={}),g=I=>{const S=`idb://${t}/${r}/${I}`;return m[S]||(m[S]=new Ge)},y=g(""),v=g(":dels"),{type:f}=h;let[b,w]=h.type==="deleteRange"?[h.range]:h.type==="delete"?[h.keys]:h.values.length<50?[[],h.values]:[];const k=h.trans._cache;return i.mutate(h).then(I=>{if(de(b)){f!=="delete"&&(b=I.results),y.addKeys(b);const S=Aa(b,k);S||f==="add"||v.addKeys(b),(S||w)&&function(E,C,x,R){function K(F){const P=E(F.name||"");function L(V){return V!=null?F.extractKey(V):null}const U=V=>F.multiEntry&&de(V)?V.forEach(re=>P.addKey(re)):P.addKey(V);(x||R).forEach((V,re)=>{const ae=x&&L(x[re]),ue=R&&L(R[re]);fe(ae,ue)!==0&&(ae!=null&&U(ae),ue!=null&&U(ue))})}C.indexes.forEach(K)}(g,s,S,w)}else if(b){const S={from:b.lower,to:b.upper};v.add(S),y.add(S)}else y.add(n),v.add(n),s.indexes.forEach(S=>g(S.name).add(n));return I})}},u=({query:{index:h,range:p}})=>{var m,g;return[h,new Ge((m=p.lower)!==null&&m!==void 0?m:e.MIN_KEY,(g=p.upper)!==null&&g!==void 0?g:e.MAX_KEY)]},d={get:h=>[o,new Ge(h.key)],getMany:h=>[o,new Ge().addKeys(h.keys)],count:u,query:u,openCursor:u};return ne(d).forEach(h=>{c[h]=function(p){const{subscr:m}=T;if(m){const g=w=>{const k=`idb://${t}/${r}/${w}`;return m[k]||(m[k]=new Ge)},y=g(""),v=g(":dels"),[f,b]=d[h](p);if(g(f.name||"").add(b),!f.isPrimaryKey){if(h!=="count"){const w=h==="query"&&a&&p.values&&i.query({...p,values:!1});return i[h].apply(this,arguments).then(k=>{if(h==="query"){if(a&&p.values)return w.then(({result:S})=>(y.addKeys(S),k));const I=p.values?k.result.map(l):k.result;p.values?y.addKeys(I):v.addKeys(I)}else if(h==="openCursor"){const I=k,S=p.values;return I&&Object.create(I,{key:{get:()=>(v.addKey(I.primaryKey),I.key)},primaryKey:{get(){const E=I.primaryKey;return v.addKey(E),E}},value:{get:()=>(S&&y.addKey(I.primaryKey),I.value)}})}return k})}v.add(n)}}return i[h].apply(this,arguments)}}),c}}}};class St{constructor(t,n){this._middlewares={},this.verno=0;const r=St.dependencies;this._options=n={addons:St.addons,autoOpen:!0,indexedDB:r.indexedDB,IDBKeyRange:r.IDBKeyRange,...n},this._deps={indexedDB:n.indexedDB,IDBKeyRange:n.IDBKeyRange};const{addons:i}=n;this._dbSchema={},this._versions=[],this._storeNames=[],this._allTables={},this.idbdb=null,this._novip=this;const s={dbOpenError:null,isBeingOpened:!1,onReadyBeingFired:null,openComplete:!1,dbReadyResolve:q,dbReadyPromise:null,cancelOpen:q,openCanceller:null,autoSchema:!0,PR1398_maxLoop:3};var o;s.dbReadyPromise=new A(l=>{s.dbReadyResolve=l}),s.openCanceller=new A((l,a)=>{s.cancelOpen=a}),this._state=s,this.name=t,this.on=mn(this,"populate","blocked","versionchange","close",{ready:[li,q]}),this.on.ready.subscribe=Ko(this.on.ready.subscribe,l=>(a,c)=>{St.vip(()=>{const u=this._state;if(u.openComplete)u.dbOpenError||A.resolve().then(a),c&&l(a);else if(u.onReadyBeingFired)u.onReadyBeingFired.push(a),c&&l(a);else{l(a);const d=this;c||l(function h(){d.on.ready.unsubscribe(a),d.on.ready.unsubscribe(h)})}})}),this.Collection=(o=this,gn(md.prototype,function(l,a){this.db=o;let c=ha,u=null;if(a)try{c=a()}catch(m){u=m}const d=l._ctx,h=d.table,p=h.hook.reading.fire;this._ctx={table:h,index:d.index,isPrimKey:!d.index||h.schema.primKey.keyPath&&d.index===h.schema.primKey.name,range:c,keysOnly:!1,dir:"next",unique:"",algorithm:null,filter:null,replayFilter:null,justLimit:!0,isMatch:null,offset:0,limit:1/0,error:u,or:d.or,valueMapper:p!==an?p:null}})),this.Table=function(l){return gn(hd.prototype,function(a,c,u){this.db=l,this._tx=u,this.name=a,this.schema=c,this.hook=l._allTables[a]?l._allTables[a].hook:mn(null,{creating:[td,q],reading:[ed,an],updating:[rd,q],deleting:[nd,q]})})}(this),this.Transaction=function(l){return gn(vd.prototype,function(a,c,u,d,h){this.db=l,this.mode=a,this.storeNames=c,this.schema=u,this.chromeTransactionDurability=d,this.idbtrans=null,this.on=mn(this,"complete","error","abort"),this.parent=h||null,this.active=!0,this._reculock=0,this._blockedFuncs=[],this._resolve=null,this._reject=null,this._waitingFor=null,this._waitingQueue=null,this._spinCount=0,this._completion=new A((p,m)=>{this._resolve=p,this._reject=m}),this._completion.then(()=>{this.active=!1,this.on.complete.fire()},p=>{var m=this.active;return this.active=!1,this.on.error.fire(p),this.parent?this.parent._reject(p):m&&this.idbtrans&&this.idbtrans.abort(),oe(p)})})}(this),this.Version=function(l){return gn(Cd.prototype,function(a){this.db=l,this._cfg={version:a,storesSource:null,dbschema:{},tables:{},contentUpgrade:null}})}(this),this.WhereClause=function(l){return gn(wa.prototype,function(a,c,u){this.db=l,this._ctx={table:a,index:c===":id"?null:c,or:u};const d=l._deps.indexedDB;if(!d)throw new O.MissingAPI;this._cmp=this._ascending=d.cmp.bind(d),this._descending=(h,p)=>d.cmp(p,h),this._max=(h,p)=>d.cmp(h,p)>0?h:p,this._min=(h,p)=>d.cmp(h,p)<0?h:p,this._IDBKeyRange=l._deps.IDBKeyRange})}(this),this.on("versionchange",l=>{l.newVersion>0?console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`):console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`),this.close()}),this.on("blocked",l=>{!l.newVersion||l.newVersion<l.oldVersion?console.warn(`Dexie.delete('${this.name}') was blocked`):console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${l.oldVersion/10}`)}),this._maxKey=vn(n.IDBKeyRange),this._createTransaction=(l,a,c,u)=>new this.Transaction(l,a,c,this._options.chromeTransactionDurability,u),this._fireOnBlocked=l=>{this.on("blocked").fire(l),hn.filter(a=>a.name===this.name&&a!==this&&!a._state.vcFired).map(a=>a.on("versionchange").fire(l))},this.use(_d),this.use(Ld),this.use(Rd),this.use(xd),this.vip=Object.create(this,{_vip:{value:!0}}),i.forEach(l=>l(this))}version(t){if(isNaN(t)||t<.1)throw new O.Type("Given version is not a positive number");if(t=Math.round(10*t)/10,this.idbdb||this._state.isBeingOpened)throw new O.Schema("Cannot add version when database is open");this.verno=Math.max(this.verno,t);const n=this._versions;var r=n.filter(i=>i._cfg.version===t)[0];return r||(r=new this.Version(t),n.push(r),n.sort(Id),r.stores({}),this._state.autoSchema=!1,r)}_whenReady(t){return this.idbdb&&(this._state.openComplete||T.letThrough||this._vip)?t():new A((n,r)=>{if(this._state.openComplete)return r(new O.DatabaseClosed(this._state.dbOpenError));if(!this._state.isBeingOpened){if(!this._options.autoOpen)return void r(new O.DatabaseClosed);this.open().catch(q)}this._state.dbReadyPromise.then(n,r)}).then(t)}use({stack:t,create:n,level:r,name:i}){i&&this.unuse({stack:t,name:i});const s=this._middlewares[t]||(this._middlewares[t]=[]);return s.push({stack:t,create:n,level:r??10,name:i}),s.sort((o,l)=>o.level-l.level),this}unuse({stack:t,name:n,create:r}){return t&&this._middlewares[t]&&(this._middlewares[t]=this._middlewares[t].filter(i=>r?i.create!==r:!!n&&i.name!==n)),this}open(){return Ad(this)}_close(){const t=this._state,n=hn.indexOf(this);if(n>=0&&hn.splice(n,1),this.idbdb){try{this.idbdb.close()}catch{}this._novip.idbdb=null}t.dbReadyPromise=new A(r=>{t.dbReadyResolve=r}),t.openCanceller=new A((r,i)=>{t.cancelOpen=i})}close(){this._close();const t=this._state;this._options.autoOpen=!1,t.dbOpenError=new O.DatabaseClosed,t.isBeingOpened&&t.cancelOpen(t.dbOpenError)}delete(){const t=arguments.length>0,n=this._state;return new A((r,i)=>{const s=()=>{this.close();var o=this._deps.indexedDB.deleteDatabase(this.name);o.onsuccess=Y(()=>{(function({indexedDB:l,IDBKeyRange:a},c){!Pi(l)&&c!==gr&&Ni(l,a).delete(c).catch(q)})(this._deps,this.name),r()}),o.onerror=Ue(i),o.onblocked=this._fireOnBlocked};if(t)throw new O.InvalidArgument("Arguments not allowed in db.delete()");n.isBeingOpened?n.dbReadyPromise.then(s):s()})}backendDB(){return this.idbdb}isOpen(){return this.idbdb!==null}hasBeenClosed(){const t=this._state.dbOpenError;return t&&t.name==="DatabaseClosed"}hasFailed(){return this._state.dbOpenError!==null}dynamicallyOpened(){return this._state.autoSchema}get tables(){return ne(this._allTables).map(t=>this._allTables[t])}transaction(){const t=Ed.apply(this,arguments);return this._transaction.apply(this,t)}_transaction(t,n,r){let i=T.trans;i&&i.db===this&&t.indexOf("!")===-1||(i=null);const s=t.indexOf("?")!==-1;let o,l;t=t.replace("!","").replace("?","");try{if(l=n.map(c=>{var u=c instanceof this.Table?c.name:c;if(typeof u!="string")throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");return u}),t=="r"||t===Ci)o=Ci;else{if(t!="rw"&&t!=ki)throw new O.InvalidArgument("Invalid transaction mode: "+t);o=ki}if(i){if(i.mode===Ci&&o===ki){if(!s)throw new O.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");i=null}i&&l.forEach(c=>{if(i&&i.storeNames.indexOf(c)===-1){if(!s)throw new O.SubTransaction("Table "+c+" not included in parent transaction.");i=null}}),s&&i&&!i.active&&(i=null)}}catch(c){return i?i._promise(null,(u,d)=>{d(c)}):oe(c)}const a=ka.bind(null,this,o,l,i,r);return i?i._promise(o,a,"lock"):T.trans?Ft(T.transless,()=>this._whenReady(a)):this._whenReady(a)}table(t){if(!Ie(this._allTables,t))throw new O.InvalidTable(`Table ${t} does not exist`);return this._allTables[t]}}const Od=typeof Symbol<"u"&&"observable"in Symbol?Symbol.observable:"@@observable";class Ud{constructor(t){this._subscribe=t}subscribe(t,n,r){return this._subscribe(t&&typeof t!="function"?t:{next:t,error:n,complete:r})}[Od](){return this}}function La(e,t){return ne(t).forEach(n=>{Sr(e[n]||(e[n]=new Ge),t[n])}),e}function Md(e){let t,n=!1;const r=new Ud(i=>{const s=ii(e);let o=!1,l={},a={};const c={get closed(){return o},unsubscribe:()=>{o=!0,rt.storagemutated.unsubscribe(p)}};i.start&&i.start(c);let u=!1,d=!1;function h(){return ne(a).some(g=>l[g]&&Td(l[g],a[g]))}const p=g=>{La(l,g),h()&&m()},m=()=>{if(u||o)return;l={};const g={},y=function(v){s&&Pt();const f=()=>Xe(e,{subscr:v,trans:null}),b=T.trans?Ft(T.transless,f):f();return s&&b.then(ze,ze),b}(g);d||(rt(yn,p),d=!0),u=!0,Promise.resolve(y).then(v=>{n=!0,t=v,u=!1,o||(h()?m():(l={},a=g,i.next&&i.next(v)))},v=>{u=!1,n=!1,i.error&&i.error(v),c.unsubscribe()})};return m(),c});return r.hasValue=()=>n,r.getValue=()=>t,r}let zi;try{zi={indexedDB:H.indexedDB||H.mozIndexedDB||H.webkitIndexedDB||H.msIndexedDB,IDBKeyRange:H.IDBKeyRange||H.webkitIDBKeyRange}}catch{zi={indexedDB:null,IDBKeyRange:null}}const vt=St;function Cr(e){let t=qe;try{qe=!0,rt.storagemutated.fire(e)}finally{qe=t}}Ot(vt,{...nr,delete:e=>new vt(e,{addons:[]}).delete(),exists:e=>new vt(e,{addons:[]}).open().then(t=>(t.close(),!0)).catch("NoSuchDatabaseError",()=>!1),getDatabaseNames(e){try{return function({indexedDB:t,IDBKeyRange:n}){return Pi(t)?Promise.resolve(t.databases()).then(r=>r.map(i=>i.name).filter(i=>i!==gr)):Ni(t,n).toCollection().primaryKeys()}(vt.dependencies).then(e)}catch{return oe(new O.MissingAPI)}},defineClass:()=>function(e){ge(this,e)},ignoreTransaction:e=>T.trans?Ft(T.transless,e):e(),vip:Fi,async:function(e){return function(){try{var t=Bi(e.apply(this,arguments));return t&&typeof t.then=="function"?t:A.resolve(t)}catch(n){return oe(n)}}},spawn:function(e,t,n){try{var r=Bi(e.apply(n,t||[]));return r&&typeof r.then=="function"?r:A.resolve(r)}catch(i){return oe(i)}},currentTransaction:{get:()=>T.trans||null},waitFor:function(e,t){const n=A.resolve(typeof e=="function"?vt.ignoreTransaction(e):e).timeout(t||6e4);return T.trans?T.trans.waitFor(n):n},Promise:A,debug:{get:()=>Oe,set:e=>{Zo(e,e==="dexie"?()=>!0:pa)}},derive:Ut,extend:ge,props:Ot,override:Ko,Events:mn,on:rt,liveQuery:Md,extendObservabilitySet:La,getByKeyPath:Ke,setByKeyPath:xe,delByKeyPath:function(e,t){typeof t=="string"?xe(e,t,void 0):"length"in t&&[].map.call(t,function(n){xe(e,n,void 0)})},shallowClone:Vo,deepClone:sn,getObjectDiff:ji,cmp:fe,asap:Wo,minKey:Si,addons:[],connections:hn,errnames:ai,dependencies:zi,semVer:ua,version:ua.split(".").map(e=>parseInt(e)).reduce((e,t,n)=>e+t/Math.pow(10,2*n))}),vt.maxKey=vn(vt.dependencies.IDBKeyRange),typeof dispatchEvent<"u"&&typeof addEventListener<"u"&&(rt(yn,e=>{if(!qe){let t;mr?(t=document.createEvent("CustomEvent"),t.initCustomEvent(nt,!0,!0,e)):t=new CustomEvent(nt,{detail:e}),qe=!0,dispatchEvent(t),qe=!1}}),addEventListener(nt,({detail:e})=>{qe||Cr(e)}));let qe=!1;if(typeof BroadcastChannel<"u"){const e=new BroadcastChannel(nt);typeof e.unref=="function"&&e.unref(),rt(yn,t=>{qe||e.postMessage(t)}),e.onmessage=t=>{t.data&&Cr(t.data)}}else if(typeof self<"u"&&typeof navigator<"u"){rt(yn,t=>{try{qe||(typeof localStorage<"u"&&localStorage.setItem(nt,JSON.stringify({trig:Math.random(),changedParts:t})),typeof self.clients=="object"&&[...self.clients.matchAll({includeUncontrolled:!0})].forEach(n=>n.postMessage({type:nt,changedParts:t})))}catch{}}),typeof addEventListener<"u"&&addEventListener("storage",t=>{if(t.key===nt){const n=JSON.parse(t.newValue);n&&Cr(n.changedParts)}});const e=self.document&&navigator.serviceWorker;e&&e.addEventListener("message",function({data:t}){t&&t.type===nt&&Cr(t.changedParts)})}A.rejectionMapper=function(e,t){if(!e||e instanceof Dt||e instanceof TypeError||e instanceof SyntaxError||!e.name||!Jo[e.name])return e;var n=new Jo[e.name](t||e.message,e);return"stack"in e&&je(n,"stack",{get:function(){return this.inner.stack}}),n},Zo(Oe,pa);let xa=!0,Vi=!1;const Dd=()=>xa=!1,Nd=()=>Vi=!0,Pd=["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"];let In={},Gi;class Fd{constructor(t){ee(this,"_values",[]),ee(this,"_isWebMetric"),this.name=t,this._isWebMetric=Pd.includes(this.name)}report(t){if(xa&&this._values.push({time:Date.now(),value:t}),Vi||!this._isWebMetric)return;const n=this.findExceededThreshold(t);n&&Gi&&Gi(t,n)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const n=In[this.name];if(n)return n.find(r=>this.valueExceedsThreshold(t,r))}valueExceedsThreshold(t,n){return n.type==="max"?t>n.value:n.type==="min"?t<n.value:!1}}const Bd=(e,t)=>{In={},Vi=!1,e?.forEach(n=>{var r;n.metric in In||(In[n.metric]=[]),(r=In[n.metric])==null||r.push(n)}),Gi=t},Sn={},kr=e=>{const t=new Fd(e);return Sn[e]=t,t},Ta=(e,t)=>{let n=Sn[e];return n||(n=kr(e)),n.report(t)},jd=async e=>{const t=Object.values(Sn).map(n=>({name:n.name,values:n.collect()}));if(t.some(n=>n.values.length))try{await e(JSON.stringify(t))}catch(n){Xr(`Error posting metrics: ${n}`)}},Kd=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{jd(t)},e*1e3):Dd()},Ra=async(e,t)=>{const n=performance.now();try{await e()}finally{const r=performance.now()-n;let i=Sn[t];i||(i=kr(t)),i.report(r/1e3)}},Oa=(e,t)=>{const n=performance.now();try{e()}finally{const r=performance.now()-n;let i=Sn[t];i||(i=kr(t)),i.report(r/1e3)}},Wd=30,Ua=()=>{Je.setItem("sprig.disableReplayRecording","disabled")},wt=()=>!!Je.getItem("sprig.disableReplayRecording"),zd=["did not allow mutations","called in an invalid security context"],Vd=e=>{if(!e)return!0;for(const t of zd)if(e.toLowerCase().includes(t))return!1;return!0},Gd=(e,t,{reportError:n=!0,extraInfo:r})=>{wt()||t instanceof Error&&(Ua(),Vd(t?.message)&&(n&&window.UserLeap.reportError(e,t,r),$d()))},qd=async(e,t,{reportError:n}={reportError:!0})=>{var r;let i;try{if(n&&(r=window.navigator.storage)!=null&&r.estimate){const{quota:s,usage:o}=await window.navigator.storage.estimate();i={availableSpaceInMB:s&&o?(s-o)/(1024*1024):void 0,quota:s,usage:o}}}catch(s){window.UserLeap.reportError("Error getting storage estimate",s,{originalMessage:e,originalError:t})}Gd(e,t,{reportError:n,extraInfo:i})},Zd=()=>{const e=Je.getItem("sprig.sessionId");if(e)return _(`Found saved session id: ${e}`),Je.removeItem("sprig.sessionId"),e;const t=ut();return _(`Generating new uuid: ${t}`),t},ye=Zd();window.addEventListener("beforeunload",()=>{_(`Before page unload saving session id: ${ye}`),Je.setItem("sprig.sessionId",ye)});const $d=async()=>{j.transaction("rw",j.events,j.chunkUploads,j.pendingCaptures,()=>{j.events.clear(),j.chunkUploads.clear(),j.pendingCaptures.clear()}).catch(()=>{})},qi=(e,t,n=()=>!0)=>j.table(t).where("timestamp").below(e).and(n).delete(),Hd=async(e,t)=>{let n=[];return await Ra(async()=>{n=await j.events.where("[sessionId+timestamp]").between([ye,e],[ye,t??Date.now()]).toArray()},"sdk_replay_get_events_between_seconds"),n},Yd=(e,t,n)=>{const r=new Date,i=r.setMinutes(r.getMinutes()+(n??Wd));return j.events.where("[sessionId+timestamp]").between([ye,e],[ye,t]).modify({expiredAt:i})},Jd=e=>j.chunkUploads.add({...e,sessionId:e.sessionId??ye}),Qd=(e,t)=>j.chunkUploads.update(e,{data:null,etag:t,status:"UploadComplete"}),Xd=({status:e,uploadId:t})=>t?j.chunkUploads.where({uploadId:t,status:e}).toArray():j.chunkUploads.where({sessionId:ye,status:e}).toArray(),ep=e=>j.chunkUploads.where({uploadId:e,status:"UploadComplete"}).toArray(),tp=e=>j.chunkUploads.where({uploadId:e,status:"UploadComplete"}).delete(),np=e=>j.pendingCaptures.add({...e,sessionId:e.sessionId??ye,canUpload:!1}),rp=()=>j.pendingCaptures.where("sessionId").equals(ye).and(e=>e.targetTimestamp<Date.now()).toArray(),ip=()=>j.pendingCaptures.where("sessionId").equals(ye).toArray(),sp=e=>j.pendingCaptures.where("sessionId").equals(ye).and(t=>t.captureParams.responseGroupId===e).modify({canUpload:!0}),op=async e=>{var t;if((t=window.navigator.storage)!=null&&t.estimate){const{quota:n,usage:r}=await window.navigator.storage.estimate();if(n&&r&&(n-r)/1073741824<e)return!1}return!0};class ap extends St{constructor(){super("replayStorage",{autoOpen:!1}),ee(this,"events"),ee(this,"chunkUploads"),ee(this,"pendingCaptures")}}const j=new ap;j.version(1).stores({events:"uuid, timestamp, [sessionId+timestamp]",chunkUploads:"uuid, timestamp, [sessionId+status], [uploadId+status], [sessionId+status+uploadId]",pendingCaptures:"uuid, timestamp, [sessionId+targetTimestamp]"}),j.open().catch(e=>{No(`Error opening replay storage: ${JSON.stringify(e)}`),Ua()});let Ma=1,Zi=5e3,Ar=6e4;const lp=5,Da=1e3,Na=30,Er=Na+lp,cp="sprig.pendingCount";let $i,Hi,Pa,Fa=Date.now(),_r=!1,Lr;const up=async(e,t,n,r=2,i)=>{await Kt(async()=>{if(wt()){_("Not initializing replay because recording is disabled");return}if(!t){_("Not initializing replay because config didn't specify maxReplayDurationSeconds");return}if(i!=null&&i.minAvailableGb&&(Ma=i.minAvailableGb),!await op(Ma)){Xr("Minimum storage not available");return}_("Initializing replay"),i!=null&&i.minDuration&&(Zi=i.minDuration),i!=null&&i.batchDuration&&(Ar=i.batchDuration),Wu(r),vp(),mp(t+Er,30*60,t+Er),gp();const s=window.rrwebRecord;if(!s){Xr("Record script failed to set global function");return}let o=!0,l=0;Lr=s({checkoutEveryNms:Na*1e3,sampling:{input:"last",scroll:250,media:800},emit:(a,c)=>{if(wt())return;if(Fa=Date.now(),c&&a.type===W.Meta)l=performance.now();else if(c&&l&&a.type===W.FullSnapshot){const d=performance.now()-l;Ta("sdk_replay_snapshot_seconds",d/1e3)}const u=o||!!c;o=!1,dp({uuid:ut(),event:JSON.stringify(a),isValidStart:u,timestamp:Date.now()})},...i}),_r=!0,Hi||(Hi=window.setInterval(()=>{Date.now()-Fa>Da&&Ze("Sprig_Noop",{})},Da)),N.on("survey.complete",a=>{Ap({id:a,userAgent:window.navigator.userAgent})})},"Error initializing replay")};let Yi=!1,Ji=[];const dp=e=>{Ji.push(e),Yi||hp()},pp=e=>{const t=e.map(n=>({...n,sessionId:n.sessionId??ye}));if(t.length!==0)return j.transaction("rw",j.events,()=>{j.events.bulkAdd(t)}).catch(n=>{Wt("Error storing replay events",n)})},hp=()=>{Yi=!0,setTimeout(async()=>{if(wt())return;const e=Ji;Ji=[],Yi=!1,Oa(async()=>{await pp(e)},"sdk_replay_add_event_batch_seconds")},500)},mp=(e=6*60,t=30*60,n=4*60)=>{$i=window.setInterval(()=>{const r=Date.now();wt()||(tn(`Performing periodic replay data cleanup / Event Seconds ${e} / Chunk Seconds ${t} / Pending Capture Seconds ${n}`),Ra(()=>j.transaction("rw!",j.events,j.chunkUploads,j.pendingCaptures,()=>{qi(r-e*1e3,"events",i=>i.expiredAt===void 0||i.expiredAt<r-e*1e3),qi(r-t*1e3,"chunkUploads"),qi(r-n*1e3,"pendingCaptures",i=>i.canUpload===void 0||i.canUpload===!1)}).catch(i=>{clearInterval($i),Wt("Error deleting table rows",i)}),"sdk_replay_cleanup_seconds"),_("Cleanup complete"))},30*1e3)},gp=(e=5)=>{Pa=window.setInterval(async()=>{Kt(async()=>{const t=parseInt(bt??"0");if(t===0)return;const n=await rp();n!=null&&n.length&&(await Promise.all(n.map(async r=>(await j.pendingCaptures.delete(r.uuid),za(r.captureParams,r.canUpload)))),bt=(t-n.length).toString(),Je.setItem(cp,bt))},"Error initiating pending captures")},e*1e3)},fp=async(e,t,n,r,i)=>{const s=Math.min(e+i,n),o=`from: ${new Date(e).toLocaleTimeString()} to ${new Date(s).toLocaleTimeString()}`;_(`Getting event batch ${o}`);const l=await Hd(e,s);if(!(l!=null&&l.length))return _(`No events found ${o}`),{validStartFound:r,events:[]};if(!r){_(`Searching for valid start in ${l.length} events ${o}`);let a=-1;if(l?.forEach((u,d)=>{if(!u.isValidStart)return;const h=u.timestamp<=t;(a<0||h)&&(a=d)}),a<0)return _(`No valid start found in ${l.length} events ${o}`),{validStartFound:r,events:[]};const c=l[a].timestamp;return _(`Found valid start at: ${new Date(c).toLocaleTimeString()} in events ${o}`),{validStartFound:!0,events:l?.slice(a)}}return{validStartFound:r,events:l}},yp=(e,t,n)=>{const r=e.length,i=t*1024*1024,s=Math.ceil(r/n),o=Math.max(i,s);_(`Total file bytes: ${r} / target chunk size: ${o}`);const l=[];let a=0;for(;a<r;)l.push(e.slice(a,a+o)),a+=o;return l},Ba=e=>Promise.all(e.map(async t=>{const n=await zu(t);return await Qd(t.uuid,n),t.uploadId})),ja=async e=>{_(`Marking upload complete if finished: ${e}`);const t=await ep(e);if(!(t!=null&&t.length)){_(`No finished chunks found for upload: ${e}`);return}const n=t.reduce((s,o)=>(s.find(l=>l.chunkIndex===o.chunkIndex)||s.push(o),s),[]);n.sort((s,o)=>s.chunkIndex-o.chunkIndex);const r=n.map(s=>({ETag:s.etag,PartNumber:s.chunkIndex})).filter(s=>s.ETag!==null),i=n[0];await Bo({apiUrl:i.apiUrl,surveyId:i.surveyId,uploadId:e,responseGroupUuid:i.responseGroupId,etags:r,headers:i.completeUploadHeaders,replayDuration:i.replayDuration}),_(`Cleaning up chunks for ${e}`),await tp(e),_(`Done cleaning up chunks for ${e}`)},vp=async()=>{Kt(async()=>{const e=await Xd({status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await Ba(e);_(`Finished uploading unfinished chunks for ${t}`),t!=null&&t.length&&await Promise.all(t.map(n=>{if(n)return ja(n)}))},"Error uploading unfinished chunks")},wp=async(e,t)=>{await Ba(t),_(`Done uploading chunks for uploads: ${e.join(",")}`),await Promise.all(e.map(n=>ja(n)))},bp=e=>{let t=0;e.forEach(i=>{t+=i.length});const n=new Uint8Array(t);let r=0;return e.forEach(i=>{n.set(i,r),r+=i.length}),n},Ka=async(e,t,n)=>{const r=new TextEncoder;let i=null,s=null,o=null,l=!1,a=!1,[c,u]=[0,0];const d=e-Er*1e3,h=[];let p=[];_(`Getting events between ${new Date(e).toLocaleTimeString()} and ${new Date(t).toLocaleTimeString()}`),_(`Using batch duration: ${Ar}ms`);for(let g=d;g<t;g+=Ar){if({validStartFound:a,events:p}=await fp(g,e,t,a,Ar),!(p!=null&&p.length)){_("No events found");continue}c===0&&(c=p[0].timestamp),u=p[p.length-1].timestamp,_(`Last event time in batch: ${new Date(u).toLocaleTimeString()}`);const y=`${l?",":"["}${p.map(f=>f.event).join(",")}`,v=r.encode(y);n&&s===null&&(tn("Attempting compression"),o=new window.CompressionStream("gzip"),s=o.writable.getWriter()),Oa(()=>{n&&s?s.write(v):h.push(v)},"sdk_replay_compression_seconds"),l=!0}if(u-c<Zi)return _(`Replay duration is shorter than minimum of ${Zi}ms / Start:${c} / End:${u}`),null;const m=r.encode("]");return tn("Writing final close brace"),s&&o?(s.write(m),s.close(),i=new Uint8Array(await new Response(o.readable).arrayBuffer())):(h.push(m),i=bp(h)),_("Finished generating file data"),i},Ip=async(e,t)=>{const n=window.CompressionStream!==void 0;let r=null;const i=t??Date.now(),s=i-e;try{r=await Ka(s,i,n)}catch(o){o instanceof Error&&window.UserLeap.reportError("Error compressing replay",o),n&&Kt(async()=>{await Ka(s,i,!1)},"fileData fallback failed")}return r},Wa=async e=>{const{surveyId:t,responseGroupId:n,visitorId:r,apiUrl:i,completeUploadHeaders:s,replayParams:o,triggerTimestamp:l}=e,a=await Ip(o.replayDurationSeconds*1e3,l);if(a!=null&&a.length)_(`Found file data for survey: ${t}`);else{_(`File data is empty for survey: ${t}`);return}const c=yp(a,o.minimumChunkSizeMb,o.signedUrls.length);_(`Got ${c.length} chunks for survey: ${t}`);const u=await Promise.all(c.map(async(d,h)=>{const p=ut(),m={apiUrl:i,chunkIndex:h+1,completeUploadHeaders:s,etag:null,responseGroupId:n,status:"ReadyForUpload",surveyId:t,timestamp:l,totalChunks:c.length,data:d,uploadId:o.uploadId,uploadUrl:o.signedUrls[h].url,uuid:p,visitorId:r};return _(`Recording chunk upload: ${JSON.stringify({index:m.chunkIndex,surveyId:m.surveyId,uploadId:m.uploadId,size:d.length,id:p},null,2)}`),await Jd(m),_(`Done creating chunk upload: ${p}`),m}));_(`All chunk records created. Beginning upload for survey: ${t}`),await wp([o.uploadId],u)},za=async(e,t)=>{if(_(`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)}`),wt()){_(`Replay recording is disabled: ${e.surveyId}`);return}_(`Replay recording enabled: ${e.surveyId}`);const{isStandalone:n,replayParams:r,triggerTimestamp:i,responseGroupId:s}=e,o=async()=>{setTimeout(()=>N.removeListener(D.QuestionAnswered,o),0),Kt(async()=>{r.replayDurationType==="before"?await Wa(e):await sp(s)},"Error in schedule/capture callback")};Kt(async()=>{if(r.replayDurationType==="after"||r.replayDurationType==="beforeAndAfter"){n||(_("Attaching QuestionAnswered listener for non-standalone replay"),N.on(D.QuestionAnswered,o)),_(`Scheduling capture for replay of type: ${r.replayDurationType}`),await Sp(e);return}if(n||t)_(`Proceeding to capture replay for survey: ${e.surveyId} / standalone? ${n} / canUpload? ${t}`),await Wa(e);else{const l=Er+r.replayDurationSeconds,a=i-l*1e3,c=i;_(`Setting expiry minutes to ${r.expirationTimeLimitMinutes} for events from ${new Date(a).toLocaleTimeString()} to ${new Date(c).toLocaleTimeString()}`),await Yd(a,c,r.expirationTimeLimitMinutes),_("Attaching QuestionAnswered listener"),N.on(D.QuestionAnswered,o)}},"Error in scheduling/capturing replay")},Va=()=>{if(wt()){tn("Not clearing user data, replay is disabled");return}return j.transaction("rw",j.events,j.pendingCaptures,()=>{j.events.where("sessionId").equals(ye).delete(),j.pendingCaptures.where("sessionId").equals(ye).delete()}).catch(e=>{Wt("Error clearing session event data",e)})};let bt=Je.getItem("sprig.pendingCount");const Sp=async e=>{_(`Scheduling replay capture: ${JSON.stringify(e)}`);const{surveyId:t}=e,n=await ip(),r=n?.filter(o=>o.captureParams.surveyId===t);if(r!=null&&r.length){_(`Pending capture exists for survey: ${t}`);return}const i={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(i.replayParams.replayDurationSeconds*=2),i.replayParams.replayDurationType="before";const s=e.triggerTimestamp+e.replayParams.replayDurationSeconds*1e3;return i.triggerTimestamp=s,bt=bt?(parseInt(bt)+1).toString():"1",Je.setItem("sprig.pendingCount",bt),np({uuid:ut(),targetTimestamp:s,timestamp:Date.now(),captureParams:i})},Ze=(e,t)=>{var n,r;if(_r)try{(r=(n=window.rrwebRecord)==null?void 0:n.addCustomEvent)==null||r.call(n,e,t)}catch(i){Wt("Error recording custom event",i)}},Kt=async(e,t)=>{try{await e()}catch(n){Wt(t,n)}},Ga=e=>{e.description&&(e.description=Qi(e.description)),Ze("Sprig_PageView",e)},Cp=e=>{Ze("Sprig_TrackEvent",e)},kp=e=>{Ze("Sprig_ShowSurvey",e)},Ap=e=>{Ze("Sprig_SubmitSurvey",e)},Ep=e=>{var t;(t=e?.elementAttributes)!=null&&t.text&&(e.elementAttributes.text=Qi(e.elementAttributes.text)),Ze("Sprig_Click",e)},_p=e=>{Ze("Sprig_Refresh",e)},Lp=e=>{e.currentPageTitle&&(e.currentPageTitle=Qi(e.currentPageTitle)),Ze("Sprig_BackForward",e)},xp=e=>{Ze("Sprig_Keystroke",e)},Wt=(e,t,{reportError:n}={reportError:!0})=>(Lr&&(Lr(),Lr=void 0),_r=!1,[$i,Hi,Pa].forEach(r=>{r&&clearInterval(r)}),No(`${e} - ${JSON.stringify(t)}`),qd(e,t,{reportError:n})),qa=()=>_r,Qi=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),Za="ul-view-sdk-script",Tp=["ios","android"],it="visitors",st="environments",$a=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 xr(e,t){const{matchType:n,pattern:r}=e,i=n?$a[n]:$a.legacy;let s=!1;try{s=i(r,t)}catch(o){const l=`[Sprig] (ERR-445) Failed to check url match with pattern ${r}`;o instanceof Error&&(console.warn(l,o),o.stack=JSON.stringify(e),window.UserLeap.reportError(l,o))}return s}async function Me(e,t){var n,r,i;const{shouldDropOnRateLimit:s,...o}=t;o.headers=Object.assign(dt(window.UserLeap),o.headers);const l=await Be(e,{...o,shouldDropOnRateLimit:s});if(l.ok){const a=(n=l.headers)==null?void 0:n.get("Authorization"),c=a?a.split(" "):void 0,u=c&&c.length===2?c[1]:void 0,d=(r=l.headers)==null?void 0:r.get("x-ul-visitor-id");u&&d&&(d!==window.UserLeap.visitorId||window.UserLeap.token!==u)&&(Ce("token",u),Ce("vid",d),N.emit(D.VisitorIDUpdated,{visitorId:d}),window.UserLeap.token=u,window.UserLeap.visitorId=d)}return(i=l.json)!=null&&i.logMessage&&console.warn(`[Sprig] ${l.json.logMessage}`),l}function Ce(e,t){const n=be.getItem("userleap.ids");let r={};if(n)try{r=JSON.parse(n)}catch(s){s instanceof Error&&(s.stack=n,window.UserLeap.reportError("Failed to parse local storage credentials",s)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",s)}let i=r[window.UserLeap.envId];i?i[e]=t:i={[e]:t},r[window.UserLeap.envId]=i;try{be.setItem("userleap.ids",JSON.stringify(r))}catch(s){s instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${s.message}`)}}function Xi(){return window.previewMode?"0":window.UserLeap.visitorId??""}function Te(e,t,n){const r=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(i=>{r.push(i),i===st?r.push(window.UserLeap.envId):i===it&&r.push(Xi())}),n&&r.push(n),r.join("/")}const Cn=async e=>{var t,n;const{context:r,forceBrandedLogo:i,endCard:s,isFeedback:o=!1,locale:l,productConfig:a,questions:c,responseGroupUid:u,surveyId:d,uuid:h,vid:p,sessionReplay:m,studyType:g}=e,y=dt(window.UserLeap),v=ts(y),f=es(y);if(_(`Attempting to display survey: ${d}`),m&&(_("Survey has replay attached"),v?N.emit(D.ReplayCapture,{responseGroupUid:u,hasQuestions:!!(c!=null&&c.length),surveyId:d,uploadId:m.uploadId,replayType:m.replayDurationType??"before",seconds:m.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:ut(),mediaType:"screen",questionId:1,responseGroupUid:u,surveyId:d,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}}):za({responseGroupId:u,surveyId:d,visitorId:p,replayParams:m,completeUploadHeaders:y,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:c.length===0})),p==null||!(c!=null&&c.length))return _(`Not displaying survey: vid: ${p} / questions: ${c}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(Rp(c))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){_("Already displaying a survey");const U="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(U),{success:!1,message:U,surveyState:"no survey"}}if(p!==window.UserLeap.visitorId&&h!==window.UserLeap.visitorId&&!window.previewMode){const U="Attempted to display survey to a different visitor";return _(U),window.UserLeap.reportError("DisplaySurvey",new Error(U)),{success:!1,message:U,surveyState:"no survey"}}_(`Showing survey: ${d}`),kp({id:d,userAgent:window.navigator.userAgent}),_o.disable(),N.emit(D.SurveyWillPresent,{name:D.SurveyWillPresent,"survey.id":d});let b,w=document.createElement("div"),k,I,S;const E=U=>{const{"view.version":V}=U;V!==y["x-ul-sdk-version"]&&Ja(),N.removeListener("verify.view.version",E)};N.on("verify.view.version",E),window.UserLeap.useMobileStyling=f,To(y)?(b="ul-direct-embeded-frame",k=document.head,I=window,S=!1,v&&(Ya(),w.id=b,window.UserLeap.container.appendChild(w),Qa(),N.emit(D.SurveyLifeCycle,{state:"presented"}),N.emit(D.SurveyPresented,{name:D.SurveyPresented,"survey.id":d}))):{frameId:b,contentWinDocHead:k,contentWindow:I,hasOverlay:S,iframe:w}=Np({productConfig:a,useMobileStyling:f,surveyId:d,isFeedback:o}),window.UserLeap.frameId=b;const C=U=>{N.once(D.CloseSurveyOnOverlayClick,U)},x={apiURL:window.UserLeap._API_URL,cards:c,configureExitOnOverlayClick:C,context:r,endCard:s,envId:window.UserLeap.envId,eventEmitFn:N.emit.bind(N),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:i,frame:w,headers:y,locale:l,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:be.getItem("sprig.previewKey"),productConfig:{framePosition:a?.framePosition,desktopDisplay:a?.desktopDisplay,placement:a?.placement},responseGroupUid:u,startingQuestionIdx:(t=window.UserLeap.config)==null?void 0:t.startingQuestionIdx,studyType:g,styleNonce:window.UserLeap.styleNonce,surveyId:d,tabTitle:document.title,ulEvents:en,useMobileStyling:f,userId:h,viewDocument:I?.document,viewWindow:I,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(n=window.UserLeap._config)!=null&&n.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null}),window.UserLeap.customStyles&&(x.customStyles=window.UserLeap.customStyles),I&&(I.__cfg=x);function R(){const U=document.createElement("script");return window.UserLeap.nonce&&U.setAttribute("nonce",window.UserLeap.nonce),U.id=Za,U}const K=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:x.path,F=document.getElementById(Za);F&&F.remove();const P=R(),L=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(x.installationMethod==="web-npm"||x.installationMethod==="web-npm-bundled"){const{default:U}=await import("./view-BLX4LEzJ.js");U.configure(x),S&&window.UserLeap.container&&L()}else K&&(P.src=K,S&&P.addEventListener("load",()=>{window.UserLeap.container&&L()}),I?.addEventListener("error",U=>{U.target instanceof HTMLScriptElement&&U.target.src===K&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));return k?.appendChild(P),{success:!0,surveyState:"ready",surveyId:d,responseGroupUid:u}};function es(e){var t;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const n=((t=window.UserLeap.windowDimensions)==null?void 0:t.width)??document.body.clientWidth;return ts(e)||n>10&&n<ku}function ts(e){return Tp.includes(e["userleap-platform"])}const Rp=e=>e.some(t=>t.type==="videovoice"),Ha="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 Op="rgba(255,255,255, 0.95)",Up="rgba(0,0,0,0.9)",ns="0px",Ya=e=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container";const t=el();e&&t&&!window.UserLeap.useMobileStyling?t.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ja=(e,t)=>{var n;Fp();const r=window.UserLeap.container;if(r)try{(n=r.parentNode)==null||n.removeChild(r),window.UserLeap.container=null,Ce("trackStartUrl",null),N.emit(D.SurveyLifeCycle,{state:"dismissed"}),N.emit(D.SurveyClosed,{name:D.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)}},Qa=()=>{N.once(D.SurveyWillClose,({initiator:e,studyType:t})=>{N.removeAllListeners(D.CloseSurveyOnOverlayClick),Ja(e,t)})},Mp=(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},r=t?e.overlayStyleMobile:e.overlayStyle;n["background-color"]=r==="light"?Op:Up,t||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},Dp=(e,t,n,r)=>{var i,s;const o={position:"fixed",bottom:"0px",right:ns,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%"},l=Object.assign({},t,window.UserLeap),{desktopDisplay:a}=t||{},c=a==="center-modal";c&&(l.framePosition="center");let u,d=!1;if(n)(i=window.UserLeap.windowDimensions)!=null&&i.width?o.width=`${window.UserLeap.windowDimensions.width}px`:o.width="100%",(s=window.UserLeap.windowDimensions)!=null&&s.height?o.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?o.maxHeight=window.UserLeap.maxHeight:o.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(l.overlayStyleMobile)&&(d=!0);else{o.width=ko,o.maxHeight=window.UserLeap.maxHeight||"66vh";const h=()=>{d=!0,u={margin:"auto",position:"static"}};if(r)c?h():u={position:"relative",height:"300px"};else switch(l.framePosition){case"bottomLeft":u={left:ns};break;case"topLeft":u={left:ns,top:0};break;case"topRight":u={top:0};break;case"center":h();break}}return d&&Mp(l,n),Object.assign(e.style,o,u),d},Np=({productConfig:e,useMobileStyling:t,surveyId:n,isFeedback:r})=>{var i,s;const o=Ha,l=r&&e.desktopDisplay==="slider";Ya(l),Pp();const a=document.createElement("iframe");a.id=o,a.setAttribute("title","Sprig User Feedback Dialog");const c=Dp(a,e,t,r);Qa(),a.setHeight=p=>{parseInt(a.style.height)!=p&&(a.style.height=`${p}px`,N.emit(D.SurveyHeight,{name:D.SurveyHeight,contentFrameHeight:p}))};let u=!1;a.setWidth=p=>{(parseInt(a.style.width)!=p||!u)&&(u=!0,a.style.width=`${p}px`,N.emit(D.SurveyWidth,{name:D.SurveyWidth,contentFrameWidth:p}))},(i=window.UserLeap.container)==null||i.appendChild(a),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{N.emit(D.CloseSurveyOnOverlayClick)}),N.emit(D.SurveyLifeCycle,{state:"presented"}),N.emit(D.SurveyPresented,{name:D.SurveyPresented,"survey.id":n});const d=(s=a.contentWindow)==null?void 0:s.document;if(d&&(d.open("text/html","replace"),d.write("<!doctype html><head></head><body></body></html>"),d.close(),!t)){const p=d.body;p.style.display="flex",p.style.alignItems="center"}const h=d?.head;return{frameId:o,contentWinDocHead:h,contentWindow:a.contentWindow,hasOverlay:c,iframe:a}},Xa={[D.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Pp=()=>{Object.entries(Xa).forEach(([e,t])=>{N.on(e,t)})},Fp=()=>{Object.entries(Xa).forEach(([e,t])=>{N.off(e,t)})},el=()=>$,zt=()=>document.getElementById("sprig-feedback-container"),rs=()=>document.getElementById("sprig-feedback-loading-animation"),Bp=()=>{if(rs())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=`
27
+ <div class="ul-loading-spinner">
28
+ <div class="first"></div>
29
+ <div class="second"></div>
30
+ <div class="third"></div>
31
+ <div class="fourth"></div>
32
+ </div>
33
+ `,e},tl=()=>!!document.getElementById(Ha);let is=!1,$=null,De=null,ss=!1,kn=null,An=null;const jp=["bottom-left","bottom-right","center-left","center-right"],Kp=e=>{if(zt()||!jp.includes(e))return;const[t,n]=e.split("-"),r=document.createElement("div");r.id="sprig-feedback-container",r.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${t}`),document.body.appendChild(r)},Tr=()=>{var e;const t=window.UserLeap.container;return((e=t?.parentElement)==null?void 0:e.id)==="sprig-feedback-loading-container"},nl=()=>document.getElementById("sprig-feedback-error-container"),rl=()=>{if(!$)return 0;const e=$?.clientWidth,t=window.getComputedStyle($),n=parseInt(t.borderRightWidth||"0"),r=parseInt(t.borderLeftWidth||"0");return e+n+r},Rr=e=>{const t=zt();t&&(An!=null&&An.endsWith("right")?t.style.right=`${e}px`:An!=null&&An.endsWith("left")&&(t.style.left=`${e}px`))},os=()=>{if($&&(Tr()||nl())){N.off(D.SurveyAppeared,En),as();const e=rl();return Rr(-e),!0}return!1},En=()=>{if(!$||!De)return;const e=rs();e&&e.remove(),$.style.height="auto",$.style.width="auto",De.disabled=!1,ss=!1},as=()=>{if($&&!rs()){const e=Bp();e&&($.style.height="300px",$.style.width="360px",$.appendChild(e))}},il=()=>{!$||!De||(Rr(0),De.disabled=!0,ss=!0)},Wp=async e=>{const t=await Me(Te("1",[it],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:e}),method:"POST"});return t.ok?t.json:null},sl=async(e,t)=>{const{buttonTheme:n,eventId:r,placement:i,desktopDisplay:s,feedbackLabel:o,surveyUuid:l,surveyId:a}=e;let c=zt();if(c){if(!t&&r===kn)return;c.remove(),N.off(en.SURVEY_FADING_OUT,os)}if(kn=r,!document.getElementById("sprig-feedback-style")){const{head:g}=document,y=document.createElement("style");y.id="sprig-feedback-style",y.textContent=bu,y.nonce=window.UserLeap.styleNonce,g.appendChild(y)}is=s==="center-modal",An=i;const[u,d]=i.split("-");Kp(i),c=zt(),De=document.createElement("button");const h=document.createElement("div");h.className="sprig-feedback-button-label",h.innerText=o,De.appendChild(h),De.id="sprig-feedback-button",De.classList.add(`sprig-feedback-button-${d}`,`sprig-feedback-button-${u}`,`sprig-feedback-button-${n}`,"fade-in-transition"),N.on(en.SURVEY_FADING_OUT,os),De.addEventListener("click",async()=>{const g=document.getElementById("sprig-feedback-error-container");if(tl()||nl()){if(os()){N.emit(D.SurveyWillClose,{name:D.SurveyWillClose,initiator:Fe.FeedbackClosed,studyType:"feedbackButton"});const f=zt();g&&f&&(f.remove(),kn=null,$=null)}return}const y=dt(window.UserLeap);if(!es(y)&&!ss&&il(),t){$&&$.classList.add("sprig-feedback-loading-container-previews"),await Cn(t),En();return}const v=await Wp(l);if(v)N.once(D.SurveyAppeared,En),Cn({...v,studyType:"feedbackButton"});else if($){const f=Vp();$.appendChild(f),En(),$.style.height="300px",$.style.width="360px"}}),c?.appendChild(De),N.emit(D.FeedbackButtonLoaded,{name:D.FeedbackButtonLoaded,"survey.id":a});const{useMobileStyling:p,_config:{border:m}}=window.UserLeap;if(!is&&!p){const g=document.createElement("div");g.id="sprig-feedback-loading-container",g.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${d}`,g.style.setProperty("--feedback-border",m),$=g,as(),c?.appendChild(g);const y=rl();Rr(-y)}else is&&Rr(0);window.UserLeap._config.isOnQuestionsTab&&t&&!Tr()&&$&&(il(),as(),$&&$.classList.add("sprig-feedback-loading-container-previews"),Cn(t),En())},zp=e=>{if(Tr())return;const t=zt();if(!t)return;const{pageUrlEvents:n}=window.UserLeap._config,r=n?.find(i=>i.id===kn);r&&(xr(r,e)||(t.remove(),kn=null,$=null))},Vp=()=>{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">
34
+ <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
35
+ <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
36
+ <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
37
+ </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},Gp="!launch_darkly_";class qp{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(n=>{delete this._ldData[n]}),Object.keys(t).forEach(n=>this._ldData[`${Gp}${n}`]=(t[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const ls=new qp;Object.freeze(ls);const Zp="!optimizely_experiments_";class $p{constructor(){ee(this,"_optimizelyData",{})}setOptimizelyExperiment(t,n=!0){if(!t||typeof t!="object")return!1;const{experiments:r}=t;try{return n&&Object.keys(this._optimizelyData).map(i=>{delete this._optimizelyData[i]}),r&&r.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 Zp+t}getAndSetWebOptimizelyExperiments(){var t;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(t=window.optimizely.get("state"))==null?void 0:t.getExperimentStates({isActive:!0});if(n){const r=Object.keys(n).map(i=>{var s,o;return(s=n[i].variation)!=null&&s.name?{id:i,variation:(o=n[i].variation)==null?void 0:o.name}:{id:i,variation:"Original"}});return this.setOptimizelyExperiment({experiments:r},!1),!0}return!1}return!1}catch(n){return n instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",n),!1}}}const Or=new $p;Object.freeze(Or);class Hp{constructor(t,n){ee(this,"paused"),ee(this,"queue"),ee(this,"ul"),this.ul=t,this.paused=!1,this.queue=[],this.flush(n)}flush(t){const n=t.length;if(n)for(let r=0;r<n;r++)this.push(t[r])}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 n=Array.prototype.slice.call(t,1),r=t[0],i=this.ul[r];i instanceof Function?i.apply(this.ul,n):r&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",r)}}perform(t){if(this.paused){let n=()=>{};const r=new Promise(function(i){n=function(){i(t())}});return this.queue.push(n),r}else return t()}empty(){this.queue.length=0}}const Yp=1,ol=e=>e instanceof HTMLElement||e instanceof SVGElement,al=(e,t,n)=>{const r=e.createElement("style");n&&(r.nonce=n),r.textContent=t,r.id="ul-custom-style",e.head.appendChild(r)},ll=e=>{const t=e.querySelector(".ul-card__container");let n=600,r=360;if(t){n=t.scrollHeight;const i=getComputedStyle(t),s=parseFloat(i.marginTop)+parseFloat(i.marginBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth);n+=s+o;const l=t.querySelector(".ul-card--matrix_grid");r=l?l.scrollWidth:t.scrollWidth;const a=parseFloat(i.paddingLeft)+parseFloat(i.paddingRight),c=parseFloat(i.marginLeft)+parseFloat(i.marginRight),u=parseFloat(i.borderLeftWidth)+parseFloat(i.borderRightWidth);r+=c+u+a}return[n+Yp,r]},Jp=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},cs=(e,t)=>{const n=performance.now();document.hidden?setTimeout(()=>cs(e,t),e):setTimeout(()=>{const r=performance.now()-n;t.report(r/1e3),setTimeout(()=>cs(e,t),e)},0)},Qp=(e=1e3)=>{const t=kr("sdk_event_queue_latency_seconds");cs(e,t)},Xp=({webMetricsEnabled:e,reportingIntervalSeconds:t,thresholds:n,postMetrics:r})=>{Bd(n,(i,s)=>{if(qa()){const o=`Value: ${i} on ${s.metric} violated threshold of ${s.type} ${s.value}`;Wt("Threshold violated",new Error(o),{reportError:!1}),Nd()}}),Kd({reportingIntervalSeconds:t,postMetrics:r}),e&&Qp()},us={capture:!0},eh=["a","button","input","option","li","link"],th=["Escape","Enter","Backspace","F5","Tab"],nh=["label","type","role","title","placeholder","errormessage","valuetext","href"],cl="aria-",rh=e=>{if(!e.tagName)return"No tagName";const t=e.getAttribute("type");return t?`${t} ${e.tagName.toLowerCase()}`:e.tagName.toLowerCase()},ul=e=>{var t;if(((t=e.tagName)==null?void 0:t.toLowerCase())==="html")return{element:"html"};const n=e.textContent,r=n?{text:n}:{};r.element=rh(e);for(const i of e.attributes){let s=i.name;const o=i.value;s.startsWith(cl)&&(s=s.substring(cl.length)),nh.includes(s)&&(r[s]=o)}return r},ih=e=>{var t;if(!e)return{};const n={...ul(e)},r=e.parentElement;if(r&&eh.includes((t=r.tagName)==null?void 0:t.toLowerCase())){const i=ul(r);Object.assign(n,i)}return n},dl=(e,t)=>{Ep({x:t.x,y:t.y,type:e,elementAttributes:ih(t.target)})},sh=e=>t=>dl(e,t),oh=e=>{th.includes(e.key)&&xp({key:e.key})},ah=()=>{window.performance.getEntriesByType("navigation").map(e=>e.type).includes("reload")&&_p({url:window.location.href,currentPageTitle:document.title})},lh=()=>{window.performance.getEntriesByType("navigation").map(e=>e.type).includes("back_forward")&&Lp({curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title})},ch=()=>{window.addEventListener("click",sh("left_click"),us),window.addEventListener("mousedown",e=>{e.button===2&&dl("right_click",e)},us),window.addEventListener("keydown",oh,us),ah(),lh()},uh={test:"test"},dh=["popState","pushState","replaceState"],_n="!email",ds="pageUrl";function ph(e,t){const{pageUrlEvents:n,interactiveEvents:r,dismissOnPageChange:i}=window.UserLeap._config;if(!i)return!0;const s=[];n&&n.length&&s.push(...n),r&&r.length&&s.push(...r);const o=e&&s.find(l=>l.id===e);return o?xr(o,window.location.href):t===window.location.href}function Ln(e){const{pageUrlEvents:t,interactiveEvents:n,dismissOnPageChange:r,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;const s=It("trackStartUrl"),o=s?String(s):null;t&&gl(window.location.href),n&&(hl(),hh()),el()&&zp(window.location.href),!Tr()&&r&&o&&o!==window.location.href&&e&&dh.includes(e.type)&&window.UserLeap("dismissActiveSurvey",Fe.PageChange)}const pl={capture:!0},hh=()=>{const e=window.UserLeap._config.interactiveEvents.filter(n=>xr(n,window.location.href)).map(n=>{const{name:r,properties:i}=n,{selector:s,innerText:o}=i;return s?l=>{if(ol(l.target))try{l.target.closest(s)&&window.UserLeap("track",r)}catch{}return!1}:l=>(ol(l.target)&&l.target.innerText===o&&window.UserLeap("track",r),!1)}),t=n=>e.forEach(r=>r(n));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,pl)},hl=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,pl),delete window.UserLeap._config.interactiveEventsHandler};function mh(){["hashchange","popstate"].forEach(e=>window.addEventListener(e,Ln,!0))}function gh(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,Ln,!0)),window.UserLeap._config.interactiveEvents&&hl()}function fh(e,t){let n=Te("1",[st],"questions?");return e!=null&&(n+=`&vid=${e}`),t&&(t.surveyId&&(n+=`&surveyid=${t.surveyId}`),t.surveyTemplateId&&(n+=`&surveytemplateid=${t.surveyTemplateId}`),t.previewLanguage&&(n+=`&previewLanguage=${encodeURIComponent(t.previewLanguage)}`),t.useMobileStyling&&(n+=`&isMobile=${t.useMobileStyling}`)),n}function It(e){const t=be.getItem("userleap.ids");if(t)try{const n=JSON.parse(t)[window.UserLeap.envId];return n&&n[e]||null}catch(n){n instanceof Error&&(n.stack=t,window.UserLeap.reportError("Failed to parse local storage credentials",n)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",n)}return null}function ml(){window.previewMode||(window.UserLeap.visitorId=ut(),_(`Generating new vid: ${window.UserLeap.visitorId}`),Ce("vid",window.UserLeap.visitorId),N.emit(D.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function gl(e,t,n){var r;if(e.endsWith("mock_snippet.html"))return;_(`Tracking page view: ${e}`);const i=window.UserLeap._config.pageUrlEvents;let s=!1;if(i&&i.length)for(let d=0;d<i.length&&(s=xr(i[d],e),!s);d++);if(!s)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const o=10,l=1;let a=[];const c={viewedAt:Date.now(),location:e},u=be.getItem("userleap.pageviews");try{if(a=u?JSON.parse(u):[],Array.isArray(a)||(a=[]),a.length>0){const d=a[a.length-1],h=(Date.now()-d.viewedAt)/1e3;if(d.location!=e&&h>l){const p=(r=document?.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");Ga({...p&&{description:p},url:e,referrer:document.referrer,pageTitle:document.title})}(d.location!=e&&h>l||h>o)&&(window.UserLeap._queue.push(["track",ds,t,{url:e},n]),a.push(c))}else window.UserLeap._queue.push(["track",ds,t,{url:e},n]),a.push(c),Ga({url:e});a.length>5&&a.splice(0,a.length-5),be.setItem("userleap.pageviews",JSON.stringify(a))}catch(d){d instanceof Error&&window.UserLeap.reportError("trackPageView",d,{pageViewsStorage:u}),console.warn("[Sprig] (ERR-425) Failed to update page views in local storage")}}function yh(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...n){const r=t.apply(this,n),i=new Event("pushState");return window.dispatchEvent(i),Ln(i),r})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...n){const r=t.apply(this,n),i=new Event("replaceState");return window.dispatchEvent(i),Ln(i),r})(e.replaceState)),mh()}async function ps(e,t){const n=Xi();e&&!t&&(window.UserLeap._config.mode=uh.test);const r=dt(window.UserLeap),i=es(r),s=await Me(fh(n,{...e,previewLanguage:window.UserLeap._config.previewLanguage,useMobileStyling:i}),{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 Hn(s.json.delay),s.json.isFeedback){const{feedbackLabel:o,productConfig:l,surveyUuid:a}=s.json,{buttonTheme:c,placement:u,desktopDisplay:d}=l,h={buttonTheme:c,desktopDisplay:d,eventId:0,feedbackLabel:o,placement:u,surveyUuid:a,surveyId:e?.surveyId};sl(h,s.json)}else return Cn(s.json)}function vh(e){let t=e.length;for(;t;){const n=Math.floor(Math.random()*t);t-=1;const r=e[t];e[t]=e[n],e[n]=r}}function wh(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:n,dismissOnPageChange:r}=e;t&&vh(t),(t||n||r)&&(yh(),Ln())}async function bh(e,t){var n,r;let i=!0;return t&&(n=e?.json)!=null&&n.surveyId&&(window.UserLeap.delayingSurvey=!0,i=await t(e.json.surveyId),window.UserLeap.delayingSurvey=!1,!i)?!1:((r=e?.json)!=null&&r.delay&&(window.UserLeap.delayingSurvey=!0,await Hn(e.json.delay),window.UserLeap.delayingSurvey=!1),i)}const Ih=function(e){if(!window.UserLeap)return;const t=async(r={})=>{var i,s,o,l;const{userId:a,anonymousId:c,metadata:u={},properties:d,showSurveyCallback:h}=r;let{eventName:p}=r;if(window.UserLeap.debugMode&&p!==ds&&console.info("[DEBUG] Sprig track",r),e.mode==="test")return;const m=be.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!a){const f="[Sprig] - Skipping tracking without userId";return console.warn(f),{success:!1,message:f,surveyState:"no survey"}}if(!p||p.trim().length===0){p=p?String(p):"";const f="[Sprig] - Invalid event name "+p;return console.warn(f),{success:!1,message:f,surveyState:"no survey"}}const g=window.location.href;if(u.url||(u.url=g),Ce("trackStartUrl",g),(s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled){const f=dt(window.UserLeap);ts(f)||Or.getAndSetWebOptimizelyExperiments(),u.optimizelyExperiments=Object.assign({},Or.getAllOptimizelyExperiments())}(l=(o=window.UserLeap)==null?void 0:o._config)!=null&&l.launchDarklyEnabled&&(u.launchDarklyFlags=ls.getAllLaunchDarklyVariations()),a&&(window.UserLeap.userId=a),c&&(window.UserLeap.partnerAnonymousId=c),d&&(u.eventProperties=d),Cp({name:p,url:u.url}),_(`Tracking event: ${p}`);const y=window.UserLeap.delayingSurvey||tl()?await Me(Te("1",[it],"events/batch"),{body:JSON.stringify({events:[{event:p,metadata:u}],previewKey:m}),method:"POST",shouldDropOnRateLimit:!0}):await Me(Te("1",[it],"events"),{body:JSON.stringify({event:p,metadata:u,previewKey:m}),method:"POST",shouldDropOnRateLimit:!0});if(!y.ok){const f="[Sprig] (ERR-421) Failed to track event";return y.reportError&&(console.warn(f,y.error),y.error&&window.UserLeap.reportError("track",y.error)),{success:!1,message:f,error:y.error,surveyState:"no survey"}}a&&Ce("uid",a),c&&Ce("aid",c);const v=y.json;return v.invalidPreviewKey&&be.removeItem("sprig.previewKey"),v!=null&&v.feedbackButton&&sl(v.feedbackButton),await bh(y,h)?ph(v.eventId,g)?Cn(v):{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"}},n={async displaySurvey(r){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",Fe.Override),ps({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",Fe.Override),ps({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",Fe.Override),ps({surveyId:r},!1)},previewSurvey(r){n._previewSurvey(r)},reviewSurvey(r){n._reviewSurvey(r)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(r=Fe.API){N.emit(D.SurveyWillClose,{name:D.SurveyWillClose,initiator:r})},async setAttribute(r,i){if(!r||!i&&i!==0&&i!==!1){const s="[Sprig] - Disregarding empty attribute / value provided";return console.warn(s),{success:!1,message:s}}return this.setAttributes({[r]:i})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),e.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const c="[Sprig] - Disregarding empty payload provided";return console.warn(c),{success:!1,message:c}}const{userId:i,anonymousId:s,attributes:o}=r;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const c="[Sprig] - Skipping tracking without userId";return console.warn(c),{success:!1,message:c}}if(!o&&(!i||window.UserLeap.userId===i)&&(!s||window.UserLeap.partnerAnonymousId===s))return{success:!0};const l={};i&&(l.userId=window.UserLeap.userId=i),s&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s);let a;return o?(o.email&&!Object.prototype.hasOwnProperty.call(o,_n)&&(o[_n]=o.email,delete o.email),_(`Setting attributes: ${JSON.stringify(o)}`),a=await Me(Te("1",[st,it],"attributes"),{body:JSON.stringify(o),method:"PUT"}),!a.ok&&a.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",a.error),a.error&&window.UserLeap.reportError("identifyAndSetAttributes",a.error))):a=await Me(Te("1",[st,it]),{body:JSON.stringify(l),method:"PUT"}),o&&o[_n]&&(window.UserLeap.email=o[_n]),a.ok&&(i&&Ce("uid",i),s&&Ce("aid",s)),{success:!!a.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),e.mode==="test")return;if(r==null||r.length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}if(e.requireUserIdForTracking&&!window.UserLeap.userId){const s="[Sprig] - Skipping tracking without userId";return console.warn(s),{success:!1,message:s}}const i=await Me(Te("1",[st,it],"attributes"),{body:JSON.stringify({delete:r}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&window.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(r){N.on(D.SurveyLifeCycle,r)},async removeSurveyListener(r){N.removeListener(D.SurveyLifeCycle,r)},async addListener(r,i){N.on(r,i)},async removeListener(r,i){N.removeListener(r,i)},async removeAllListeners(){N.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||be.isStorageAvailable&&r&&be.setItem("sprig.previewKey",r)},async setUserId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",r),r==null){const o=`[Sprig] - Invalid userId ${r}`;return console.warn(o),{success:!1,message:o}}if(e.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const i=window.UserLeap.visitorId,s=await Me(Te("1",[st,it]),{body:JSON.stringify({userId:r}),method:"PUT"});if(!s.ok){s.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",s.error),s.error&&window.UserLeap.reportError("setUserId",s.error));return}i!==window.UserLeap.visitorId&&Va(),Ce("uid",r)},async setPartnerAnonymousId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",r),r==null){const i=`[Sprig] - Invalid partnerAnonymousId ${r}`;return console.warn(i),{success:!1,message:i}}return window.UserLeap.partnerAnonymousId=r,Ce("aid",r),{success:!0}},async track(r,i,s={},o=void 0){return t({eventName:r,properties:i,metadata:s,showSurveyCallback:o})},async identifyAndTrack(r){return await t(r)},trackPageView(r,i=void 0,s=void 0){gl(r,i,s)},applyStyles(r){if(window.UserLeap.customStyles=r,window.UserLeap.container){const i=window.UserLeap.container.children[0].contentDocument;if(i){const s=i.getElementById("ul-custom-style");s?s.textContent=r:al(i,r,window.UserLeap.styleNonce)}}},setWindowDimensions(r,i){var s,o;const l=typeof r=="string"?parseInt(r,10):r,a=typeof i=="string"?parseInt(i,10):i;if(!isNaN(l)&&!isNaN(a)&&(window.UserLeap.windowDimensions={width:l,height:a}),!window.UserLeap.frameId)return;const c=document.getElementById(window.UserLeap.frameId);c&&(window.UserLeap.useMobileStyling&&((s=window.UserLeap.windowDimensions)!=null&&s.width&&(c.style.width=`${window.UserLeap.windowDimensions.width}px`),(o=window.UserLeap.windowDimensions)!=null&&o.height&&(c.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),c.contentDocument&&(c.style.height=String(ll(c.contentDocument)[0])+"px")),N.emit(D.SurveyDimensions,{name:D.SurveyDimensions,contentFrameWidth:c.clientWidth,contentFrameHeight:c.clientHeight}))},logoutUser(){window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),_(`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,be.removeItem("userleap.ids"),be.removeItem("userleap.pageviews"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),ml(),Va(),window.UserLeap._queue.unpause()},teardown(){gh(),window.UserLeap("dismissActiveSurvey",Fe.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(r,i=!0){var s,o;if(!((o=(s=window.UserLeap)==null?void 0:s._config)!=null&&o.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const l=typeof r=="string"?JSON.parse(r):r;Or.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}},integrateOptimizelyClient(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const o=({experiment:l,variation:a})=>{const c={experiments:[{id:l.id,variation:a.key}]};window.UserLeap("integrateOptimizely",c,!1)};r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",o)},importLaunchDarklyData(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}ls.setLDFlagsVariations(r)},setVisitorAttribute(r,i){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),n.setAttribute(r,i)},async setEmail(r){return n.setAttribute(_n,r)},async setVisitorEmail(r){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),n.setEmail(r)},async _generateVideoUploadUrl(r){return Ah(r)},_reportMetric(r,i){Ta(r,i)},async _completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:s}){if(!r||!i)return!1;const o=window.UserLeap._API_URL;try{const l=await Bo({surveyId:r,responseGroupUuid:i,eventDigest:s,apiUrl:o,headers:dt(window.UserLeap)},!0);return!(l!=null&&l.error)}catch(l){return console.warn("[Sprig] Error with completing session replay"),l instanceof Error&&window.UserLeap.reportError("completeSessionReplay",l),!1}}};Object.assign(window.UserLeap,n)};async function Sh(e){const t=dt(window.UserLeap);document.addEventListener("securitypolicyviolation",Yr);const n=await Be(Te("1",[st],"config"),{headers:t}),r="TypeError";if(window.UserLeap.error=n.error,!n.ok&&n.error&&n.error.name===r?(window.UserLeap._API_URL="https://api.sprig.com",window.UserLeap.reportError("sprigDomainRequest",n.error)):document.removeEventListener("securitypolicyviolation",Yr),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),Jr("Disabled: failed to fetch configuration"),e;const i=n.json;return i!=null&&i.disabled?(Jr(`Disabled: ${i.disabled}`),{disabled:i.disabled}):Object.assign({},i,e)}const Ch=e=>typeof e=="object"&&e&&"inner"in e&&!!e.inner&&typeof e.inner=="object";async function kh(e,t,n={}){var r,i;const s=window.__cfg&&window.__cfg.mode,o=Xi(),l=window.UserLeap.envId,a=window.document.documentElement,c=Ch(t)?{inner:{message:(r=t.inner)==null?void 0:r.message,stack:(i=t.inner)==null?void 0:i.stack}}:{},u={mode:s,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:a.clientWidth,clientHeight:a.clientHeight,location:window.location.href,language:window.navigator.language,...n,...c},d={action:e,err:{message:t.message,stack:t.stack},meta:u,vid:o,envId:l},h=await Me(Te("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(d),shouldDropOnRateLimit:!0});if(!h.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",t);else{const{presignedUrl:p}=h.json;Po(p)}}async function Ah(e){var t;if(!e)return;const n=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const r=await fetch(n,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.ok){const i=await r.json();return(t=i?.upload)==null?void 0:t.url}else return null}catch(r){console.warn("[Sprig] Error with generating video upload url"),r instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",r)}}function Eh(e={}){const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=en,window.UserLeap("setPreviewKey",t);async function n(){if(window.UserLeap.loaded)return;if(_("Loading sprig on page load"),window.UserLeap.reportError=kh,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 l in window.UserLeap._config)window.UserLeap[l]=window.UserLeap._config[l];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 r=window.UserLeap.sampleRate;if(r){let l=It("sampled");if(l===null&&(l=Math.random()<r,Ce("sampled",l)),!l)return}else It("sampled")!==null&&Ce("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const i=[...window.UserLeap._queue];window.UserLeap._queue=new Hp(window.UserLeap,[]),window.UserLeap._queue.pause();for(let l=0;l<i.length;l++)window.UserLeap._queue.push(i[l]);const s=It("token");s?(window.UserLeap.token=s,window.UserLeap.visitorId=It("vid"),window.UserLeap.userId=It("uid"),window.UserLeap.partnerAnonymousId=It("aid")):(be.removeItem("userleap.ids"),ml());const o=await Sh(e);Xp({webMetricsEnabled:o.metricsReportingEnabled,reportingIntervalSeconds:o.metricsReportingEnabled||o.mobileMetricsReportingEnabled?o.metricsReportingIntervalSeconds:0,thresholds:o.metricThresholds,postMetrics:async l=>{await Me(Te("1",[st],"metrics"),{body:l,method:"POST",headers:{"x-ul-replay-enabled":`${qa()}`},shouldDropOnRateLimit:!0})}}),up(window.document,o.maxReplayDurationSeconds,window.UserLeap.replayNonce,window.UserLeap.maxInflightReplayRequests,o.replaySettings).then(()=>{ch()}),ju(o.logBufferLimit,o.logLevel),Ih(o),await wh(o),window.UserLeap._queue.unpause(),N.emit(D.SDKReady,{mobileMetricsReportingEnabled:!!o.mobileMetricsReportingEnabled,metricsReportingInterval:o.metricsReportingIntervalSeconds||0,metricsThresholds:o.metricThresholds||[],maxMobileReplayDurationSeconds:o.maxMobileReplayDurationSeconds,mobileReplaySettings:o.mobileReplaySettings}),N.emit(D.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class hs{constructor(){ee(this,"UPDATES",en)}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,n){window.Sprig("setAttribute",t,n)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,n){window.Sprig("addListener",t,n)}removeListener(t,n){window.Sprig("removeListener",t,n)}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,n={},r={}){window.Sprig("track",t,n,r)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,n,r){window.Sprig("trackPageView",t,n,r)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,n){window.Sprig("setWindowDimensions",t,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const fl={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(hs.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=hs.prototype[n])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,Eh(e),window.Sprig}};fl.configure,window.UpChunk={createUpload:rc},window.rrwebRecord=Xt;export{Iu as A,_o as C,Fe as D,Au as E,D as S,Be as a,ko as b,ll as c,Cu as d,N as e,Su as f,hs as g,fl as h,_ as i,al as o,Jp as r,To as s,Po as u,ut as v};