@sprig-technologies/sprig-bundled 2.44.0 → 2.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{conversational-ui-EBO_5YT4.cjs → conversational-ui-5FRYaGa1.cjs} +2 -2
- package/dist/{conversational-ui-BDY1U1pN.js → conversational-ui-D0rSLvkp.js} +340 -344
- package/dist/conversational-v2-styles-BuQiqTAN.js +4 -0
- package/dist/conversational-v2-styles-C-AtgFtc.cjs +1 -0
- package/dist/getAttributedUrl-DCoAixJz.cjs +12 -0
- package/dist/getAttributedUrl-Dq1b-gQL.js +193 -0
- package/dist/index-BH4S1tUz.js +723 -0
- package/dist/{index-B0e_zgRQ.cjs → index-BzAnV7nc.cjs} +2 -2
- package/dist/{index-BUTuSSuP.js → index-Czvv7meW.js} +3 -3
- package/dist/index-zTKRoMdd.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +22 -8
- package/dist/index.js +1 -1
- package/dist/{view-DcerBHpf.js → view-Cu4weTLz.js} +766 -757
- package/dist/view-K_OZdlXf.cjs +1 -0
- package/package.json +1 -1
- package/dist/conversational-v2-styles-BTm-8rVB.cjs +0 -1
- package/dist/conversational-v2-styles-Bj3dBWvf.js +0 -4
- package/dist/getAttributedUrl-8t2IIhOk.js +0 -193
- package/dist/getAttributedUrl-M03Qw_Lk.cjs +0 -12
- package/dist/index-BLbkNfGp.cjs +0 -1
- package/dist/index-D2wwf1iZ.js +0 -717
- package/dist/view-0ocXtsSZ.cjs +0 -1
|
@@ -52,7 +52,7 @@ https://www.w3ctech.com/topic/2226`));let a=t(...i);return a.postcssPlugin=e,a.p
|
|
|
52
52
|
https://evilmartians.com/chronicles/postcss-8-plugin-migration`),process.env.LANG&&process.env.LANG.startsWith("cn")&&console.warn(e+`: 里面 postcss.plugin 被弃用. 迁移指南:
|
|
53
53
|
https://www.w3ctech.com/topic/2226`));let a=t(...i);return a.postcssPlugin=e,a.postcssVersion=new ai().version,a}return Object.defineProperty(n,"postcss",{get:()=>(r||(r=n()),r)}),n.process=function(i,a,o){return X([n(o)]).process(i,a)},n},X.stringify=cf,X.parse=mf,X.fromJSON=uf,X.list=ff,X.comment=e=>new Ia(e),X.atRule=e=>new Ca(e),X.decl=e=>new va(e),X.rule=e=>new ka(e),X.root=e=>new Ea(e),X.document=e=>new Sa(e),X.CssSyntaxError=of,X.Declaration=va,X.Container=lf,X.Processor=ai,X.Document=Sa,X.Comment=Ia,X.Warning=df,X.AtRule=Ca,X.Result=pf,X.Input=hf,X.Rule=ka,X.Root=Ea,X.Node=gf,af.registerPostcss(X);var yf=X;X.default=X;const ce=Bh(yf);ce.stringify,ce.fromJSON,ce.plugin,ce.parse,ce.list,ce.document,ce.comment,ce.atRule,ce.rule,ce.decl,ce.root,ce.CssSyntaxError,ce.Declaration,ce.Container,ce.Processor,ce.Document,ce.Comment,ce.Warning,ce.AtRule,ce.Result,ce.Input,ce.Rule,ce.Root,ce.Node;class Qi{constructor(...t){Re(this,"parentElement",null),Re(this,"parentNode",null),Re(this,"ownerDocument"),Re(this,"firstChild",null),Re(this,"lastChild",null),Re(this,"previousSibling",null),Re(this,"nextSibling",null),Re(this,"ELEMENT_NODE",1),Re(this,"TEXT_NODE",3),Re(this,"nodeType"),Re(this,"nodeName"),Re(this,"RRNodeType")}get childNodes(){const t=[];let r=this.firstChild;for(;r;)t.push(r),r=r.nextSibling;return t}contains(t){if(!(t instanceof Qi)||t.ownerDocument!==this.ownerDocument)return!1;if(t===this)return!0;for(;t.parentNode;){if(t.parentNode===this)return!0;t=t.parentNode}return!1}appendChild(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(t,r){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}const xa={Node:["childNodes","parentNode","parentElement","textContent"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},Ta={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},jr={};function eo(e){if(jr[e])return jr[e];const t=globalThis[e],r=t.prototype,s=e in xa?xa[e]:void 0,n=!!(s&&s.every(o=>{var l,c;return!!((c=(l=Object.getOwnPropertyDescriptor(r,o))==null?void 0:l.get)!=null&&c.toString().includes("[native code]"))})),i=e in Ta?Ta[e]:void 0,a=!!(i&&i.every(o=>{var l;return typeof r[o]=="function"&&((l=r[o])==null?void 0:l.toString().includes("[native code]"))}));if(n&&a)return jr[e]=t.prototype,t.prototype;try{const o=document.createElement("iframe");document.body.appendChild(o);const l=o.contentWindow;if(!l)return t.prototype;const c=l[e].prototype;return document.body.removeChild(o),c?jr[e]=c:r}catch{return r}}const pn={};function rt(e,t,r){var s;const n=`${e}.${String(r)}`;if(pn[n])return pn[n].call(t);const i=eo(e),a=(s=Object.getOwnPropertyDescriptor(i,r))==null?void 0:s.get;return a?(pn[n]=a,a.call(t)):t[r]}const hn={};function Ra(e,t,r){const s=`${e}.${String(r)}`;if(hn[s])return hn[s].bind(t);const n=eo(e)[r];return typeof n!="function"?t[r]:(hn[s]=n,n.bind(t))}function Fc(){return eo("MutationObserver").constructor}const V={childNodes:function(e){return rt("Node",e,"childNodes")},parentNode:function(e){return rt("Node",e,"parentNode")},parentElement:function(e){return rt("Node",e,"parentElement")},textContent:function(e){return rt("Node",e,"textContent")},contains:function(e,t){return Ra("Node",e,"contains")(t)},getRootNode:function(e){return Ra("Node",e,"getRootNode")()},host:function(e){return e&&"host"in e?rt("ShadowRoot",e,"host"):null},styleSheets:function(e){return e.styleSheets},shadowRoot:function(e){return e&&"shadowRoot"in e?rt("Element",e,"shadowRoot"):null},querySelector:function(e,t){return rt("Element",e,"querySelector")(t)},querySelectorAll:function(e,t){return rt("Element",e,"querySelectorAll")(t)},mutationObserver:Fc};function ve(e,t,r=document){const s={capture:!0,passive:!0};return r.addEventListener(e,t,s),()=>r.removeEventListener(e,t,s)}const Ct=`Please stop import mirror directly. Instead of that,\r
|
|
54
54
|
now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
|
|
55
|
-
or you can use record.mirror to access the mirror instance during recording.`;let La={map:{},getId:()=>(console.error(Ct),-1),getNode:()=>(console.error(Ct),null),removeNodeFromMap(){console.error(Ct)},has:()=>(console.error(Ct),!1),reset(){console.error(Ct)}};function $t(e,t,r={}){let s=null,n=0;return function(...i){const a=Date.now();n||r.leading!==!1||(n=a);const o=t-(a-n),l=this;o<=0||o>t?(s&&(clearTimeout(s),s=null),n=a,e.apply(l,i)):s||r.trailing===!1||(s=setTimeout(()=>{n=r.leading===!1?0:Date.now(),s=null,e.apply(l,i)},o))}}function Ys(e,t,r,s,n=window){const i=n.Object.getOwnPropertyDescriptor(e,t);return n.Object.defineProperty(e,t,s?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),i&&i.set&&i.set.call(this,a)}}),()=>Ys(e,t,i||{},!0)}function Mt(e,t,r){try{if(!(t in e))return()=>{};const s=e[t],n=r(s);return typeof n=="function"&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__rrweb_original__:{enumerable:!1,value:s}})),e[t]=n,()=>{e[t]=s}}catch{return()=>{}}}typeof window<"u"&&window.Proxy&&window.Reflect&&(La=new Proxy(La,{get:(e,t,r)=>(t==="map"&&console.error(Ct),Reflect.get(e,t,r))}));let bs=Date.now;function Bc(e){var t,r,s,n;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:i.documentElement.scrollLeft||(i==null?void 0:i.body)&&((t=V.parentElement(i.body))==null?void 0:t.scrollLeft)||((r=i==null?void 0:i.body)==null?void 0:r.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:(i==null?void 0:i.documentElement.scrollTop)||(i==null?void 0:i.body)&&((s=V.parentElement(i.body))==null?void 0:s.scrollTop)||((n=i==null?void 0:i.body)==null?void 0:n.scrollTop)||0}}function zc(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function jc(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Wc(e){return e?e.nodeType===e.ELEMENT_NODE?e:V.parentElement(e):null}function Se(e,t,r,s){if(!e)return!1;const n=Wc(e);if(!n)return!1;try{if(typeof t=="string"){if(n.classList.contains(t)||s&&n.closest("."+t)!==null)return!0}else if(ws(n,t,s))return!0}catch{}return!!(r&&(n.matches(r)||s&&n.closest(r)!==null))}function mn(e,t,r){return!(e.tagName!=="TITLE"||!r.headTitleMutations)||t.getId(e)===-2}function Vc(e,t){if(Xt(e))return!1;const r=t.getId(e);if(!t.has(r))return!0;const s=V.parentNode(e);return(!s||s.nodeType!==e.DOCUMENT_NODE)&&(!s||Vc(s,t))}function li(e){return!!e.changedTouches}function Hc(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Gc(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function ci(e){return!!e&&(e instanceof Qi&&"shadowRoot"in e?!!e.shadowRoot:!!V.shadowRoot(e))}/[1-9][0-9]{12}/.test(Date.now().toString())||(bs=()=>new Date().getTime());class wf{constructor(){x(this,"id",1),x(this,"styleIDMap",new WeakMap),x(this,"idStyleMap",new Map)}getId(t){return this.styleIDMap.get(t)??-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let s;return s=r===void 0?this.id++:r,this.styleIDMap.set(t,s),this.idStyleMap.set(s,t),s}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 $c(e){var t;let r=null;return"getRootNode"in e&&((t=V.getRootNode(e))==null?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&V.host(V.getRootNode(e))&&(r=V.host(V.getRootNode(e))),r}function bf(e){const t=e.ownerDocument;if(!t)return!1;const r=function(s){let n,i=s;for(;n=$c(i);)i=n;return i}(e);return V.contains(t,r)}function Yc(e){const t=e.ownerDocument;return!!t&&(V.contains(t,e)||bf(e))}var Y=(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))(Y||{}),G=(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[e.CustomElement=16]="CustomElement",e))(G||{}),Ce=(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))(Ce||{}),$e=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))($e||{}),kt=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(kt||{}),Et=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(Et||{});function Oa(e){return"__ln"in e}class vf{constructor(){x(this,"length",0),x(this,"head",null),x(this,"tail",null)}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let s=0;s<t;s++)r=(r==null?void 0:r.next)||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&Oa(t.previousSibling)){const s=t.previousSibling.__ln.next;r.next=s,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,s&&(s.previous=r)}else if(t.nextSibling&&Oa(t.nextSibling)&&t.nextSibling.__ln.previous){const s=t.nextSibling.__ln.previous;r.previous=s,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,s&&(s.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){const r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const Aa=(e,t)=>`${e}@${t}`;class Sf{constructor(){x(this,"frozen",!1),x(this,"locked",!1),x(this,"texts",[]),x(this,"attributes",[]),x(this,"attributeMap",new WeakMap),x(this,"removes",[]),x(this,"mapRemoves",[]),x(this,"movedMap",{}),x(this,"addedSet",new Set),x(this,"movedSet",new Set),x(this,"droppedSet",new Set),x(this,"mutationCb"),x(this,"blockClass"),x(this,"blockSelector"),x(this,"maskTextClass"),x(this,"maskTextSelector"),x(this,"inlineStylesheet"),x(this,"maskInputOptions"),x(this,"maskTextFn"),x(this,"maskInputFn"),x(this,"keepIframeSrcFn"),x(this,"recordCanvas"),x(this,"inlineImages"),x(this,"slimDOMOptions"),x(this,"dataURLOptions"),x(this,"doc"),x(this,"mirror"),x(this,"iframeManager"),x(this,"stylesheetManager"),x(this,"shadowDomManager"),x(this,"canvasManager"),x(this,"processedNodeManager"),x(this,"unattachedDoc"),x(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit()}),x(this,"emit",()=>{if(this.frozen||this.locked)return;const t=[],r=new Set,s=new vf,n=l=>{let c=l,u=-2;for(;u===-2;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},i=l=>{const c=V.parentNode(l);if(!c||!Yc(l)||c.tagName==="TEXTAREA")return;const u=Xt(c)?this.mirror.getId($c(l)):this.mirror.getId(c),d=n(l);if(u===-1||d===-1)return s.addNode(l);const h=xt(l,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:f=>{Hc(f,this.mirror)&&this.iframeManager.addIframe(f),Gc(f,this.mirror)&&this.stylesheetManager.trackLinkElement(f),ci(l)&&this.shadowDomManager.addShadowRoot(V.shadowRoot(l),this.doc)},onIframeLoad:(f,w)=>{this.iframeManager.attachIframe(f,w),this.shadowDomManager.observeAttachShadow(f)},onStylesheetLoad:(f,w)=>{this.stylesheetManager.attachLinkElement(f,w)}});h&&(t.push({parentId:u,nextId:d,node:h}),r.add(h.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const l of this.movedSet)Ma(this.removes,l,this.mirror)&&!this.movedSet.has(V.parentNode(l))||i(l);for(const l of this.addedSet)Ua(this.droppedSet,l)||Ma(this.removes,l,this.mirror)?Ua(this.movedSet,l)?i(l):this.droppedSet.add(l):i(l);let a=null;for(;s.length;){let l=null;if(a){const c=this.mirror.getId(V.parentNode(a.value)),u=n(a.value);c!==-1&&u!==-1&&(l=a)}if(!l){let c=s.tail;for(;c;){const u=c;if(c=c.previous,u){const d=this.mirror.getId(V.parentNode(u.value));if(n(u.value)===-1)continue;if(d!==-1){l=u;break}{const h=u.value,f=V.parentNode(h);if(f&&f.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const w=V.host(f);if(this.mirror.getId(w)!==-1){l=u;break}}}}}}if(!l){for(;s.head;)s.removeNode(s.head.value);break}a=l.previous,s.removeNode(l.value),i(l.value)}const o={texts:this.texts.map(l=>{const c=l.node,u=V.parentNode(c);return u&&u.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(u),{id:this.mirror.getId(c),value:l.value}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),attributes:this.attributes.map(l=>{const{attributes:c}=l;if(typeof c.style=="string"){const u=JSON.stringify(l.styleDiff),d=JSON.stringify(l._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=l.styleDiff)}return{id:this.mirror.getId(l.node),attributes:c}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),removes:this.removes,adds:t};(o.texts.length||o.attributes.length||o.removes.length||o.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(o))}),x(this,"genTextAreaValueMutation",t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r)),r.attributes.value=Array.from(V.childNodes(t),s=>V.textContent(s)||"").join("")}),x(this,"processMutation",t=>{if(!mn(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case"characterData":{const r=V.textContent(t.target);Se(t.target,this.blockClass,this.blockSelector,!1)||r===t.oldValue||this.texts.push({value:Ul(t.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,Wc(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let s=t.attributeName,n=t.target.getAttribute(s);if(s==="value"){const a=Pi(r);n=Di({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:a,value:n,maskInputFn:this.maskInputFn})}if(Se(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let i=this.attributeMap.get(t.target);if(r.tagName==="IFRAME"&&s==="src"&&!this.keepIframeSrcFn(n)){if(r.contentDocument)return;s="rr_src"}if(i||(i={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(t.target,i)),s==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Ml(r.tagName,s))if(i.attributes[s]=Al(this.doc,ft(r.tagName),ft(s),n),s==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const a=this.unattachedDoc.createElement("span");t.oldValue&&a.setAttribute("style",t.oldValue);for(const o of Array.from(r.style)){const l=r.style.getPropertyValue(o),c=r.style.getPropertyPriority(o);l!==a.style.getPropertyValue(o)||c!==a.style.getPropertyPriority(o)?i.styleDiff[o]=c===""?l:[l,c]:i._unchangedStyles[o]=[l,c]}for(const o of Array.from(a.style))r.style.getPropertyValue(o)===""&&(i.styleDiff[o]=!1)}else s==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?i.attributes.rr_open_mode="modal":i.attributes.rr_open_mode="non-modal");break}case"childList":if(Se(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA")return void this.genTextAreaValueMutation(t.target);t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const s=this.mirror.getId(r),n=Xt(t.target)?this.mirror.getId(V.host(t.target)):this.mirror.getId(t.target);Se(t.target,this.blockClass,this.blockSelector,!1)||mn(r,this.mirror,this.slimDOMOptions)||!function(i,a){return a.getId(i)!==-1}(r,this.mirror)||(this.addedSet.has(r)?(ui(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&s===-1||Vc(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[Aa(s,n)]?ui(this.movedSet,r):this.removes.push({parentId:n,id:s,isShadow:!(!Xt(t.target)||!Zt(t.target))||void 0})),this.mapRemoves.push(r))})}}),x(this,"genAdds",(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!this.addedSet.has(t)&&!this.movedSet.has(t)){if(this.mirror.hasNode(t)){if(mn(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);let s=null;r&&this.mirror.hasNode(r)&&(s=this.mirror.getId(r)),s&&s!==-1&&(this.movedMap[Aa(this.mirror.getId(t),s)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);Se(t,this.blockClass,this.blockSelector,!1)||(V.childNodes(t).forEach(s=>this.genAdds(s)),ci(t)&&V.childNodes(V.shadowRoot(t)).forEach(s=>{this.processedNodeManager.add(s,this),this.genAdds(s,t)}))}})}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function ui(e,t){e.delete(t),V.childNodes(t).forEach(r=>ui(e,r))}function Ma(e,t,r){return e.length!==0&&function(s,n,i){let a=V.parentNode(n);for(;a;){const o=i.getId(a);if(s.some(l=>l.id===o))return!0;a=V.parentNode(a)}return!1}(e,t,r)}function Ua(e,t){return e.size!==0&&qc(e,t)}function qc(e,t){const r=V.parentNode(t);return!!r&&(!!e.has(r)||qc(e,r))}let Qt;const $=e=>Qt?(...t)=>{try{return e(...t)}catch(r){if(Qt&&Qt(r)===!0)return;throw r}}:e,mt=[];function er(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 Jc(e,t){const r=new Sf;mt.push(r),r.init(e);const s=new(Fc())($(r.processMutations.bind(r)));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function If({mouseInteractionCb:e,doc:t,mirror:r,blockClass:s,blockSelector:n,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const a=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,o=[];let l=null;return Object.keys(Ce).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&a[c]!==!1).forEach(c=>{let u=ft(c);const d=(h=>f=>{const w=er(f);if(Se(w,s,n,!0))return;let p=null,C=h;if("pointerType"in f){switch(f.pointerType){case"mouse":p=$e.Mouse;break;case"touch":p=$e.Touch;break;case"pen":p=$e.Pen}p===$e.Touch?Ce[h]===Ce.MouseDown?C="TouchStart":Ce[h]===Ce.MouseUp&&(C="TouchEnd"):$e.Pen}else li(f)&&(p=$e.Touch);p!==null?(l=p,(C.startsWith("Touch")&&p===$e.Touch||C.startsWith("Mouse")&&p===$e.Mouse)&&(p=null)):Ce[h]===Ce.Click&&(p=l,l=null);const m=li(f)?f.changedTouches[0]:f;if(!m)return;const g=r.getId(w),{clientX:v,clientY:I}=m;$(e)({type:Ce[C],id:g,x:v,y:I,...p!==null&&{pointerType:p}})})(c);if(window.PointerEvent)switch(Ce[c]){case Ce.MouseDown:case Ce.MouseUp:u=u.replace("mouse","pointer");break;case Ce.TouchStart:case Ce.TouchEnd:return}o.push(ve(u,d,t))}),$(()=>{o.forEach(c=>c())})}function Kc({scrollCb:e,doc:t,mirror:r,blockClass:s,blockSelector:n,sampling:i}){return ve("scroll",$($t($(a=>{const o=er(a);if(!o||Se(o,s,n,!0))return;const l=r.getId(o);if(o===t&&t.defaultView){const c=Bc(t.defaultView);e({id:l,x:c.left,y:c.top})}else e({id:l,x:o.scrollLeft,y:o.scrollTop})}),i.scroll||100)),t)}const Cf=["INPUT","TEXTAREA","SELECT"],Da=new WeakMap;function Wr(e){return function(t,r){if(Vr("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Vr("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Vr("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Vr("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const s=Array.from(t.parentRule.cssRules).indexOf(t);r.unshift(s)}else if(t.parentStyleSheet){const s=Array.from(t.parentStyleSheet.cssRules).indexOf(t);r.unshift(s)}return r}(e,[])}function st(e,t,r){let s,n;return e?(e.ownerNode?s=t.getId(e.ownerNode):n=r.getId(e),{styleId:n,id:s}):{}}function Xc({mirror:e,stylesheetManager:t},r){var s,n,i;let a=null;a=r.nodeName==="#document"?e.getId(r):e.getId(V.host(r));const o=r.nodeName==="#document"?(s=r.defaultView)==null?void 0:s.Document:(i=(n=r.ownerDocument)==null?void 0:n.defaultView)==null?void 0:i.ShadowRoot,l=o!=null&&o.prototype?Object.getOwnPropertyDescriptor(o==null?void 0:o.prototype,"adoptedStyleSheets"):void 0;return a!==null&&a!==-1&&o&&l?(Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var c;return(c=l.get)==null?void 0:c.call(this)},set(c){var u;const d=(u=l.set)==null?void 0:u.call(this,c);if(a!==null&&a!==-1)try{t.adoptStyleSheets(c,a)}catch{}return d}}),$(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function kf(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};let s;(function(m,g){const{mutationCb:v,mousemoveCb:I,mouseInteractionCb:O,scrollCb:E,viewportResizeCb:A,inputCb:M,mediaInteractionCb:k,styleSheetRuleCb:T,styleDeclarationCb:R,canvasMutationCb:S,fontCb:P,selectionCb:D,customElementCb:b}=m;m.mutationCb=(...y)=>{g.mutation&&g.mutation(...y),v(...y)},m.mousemoveCb=(...y)=>{g.mousemove&&g.mousemove(...y),I(...y)},m.mouseInteractionCb=(...y)=>{g.mouseInteraction&&g.mouseInteraction(...y),O(...y)},m.scrollCb=(...y)=>{g.scroll&&g.scroll(...y),E(...y)},m.viewportResizeCb=(...y)=>{g.viewportResize&&g.viewportResize(...y),A(...y)},m.inputCb=(...y)=>{g.input&&g.input(...y),M(...y)},m.mediaInteractionCb=(...y)=>{g.mediaInteaction&&g.mediaInteaction(...y),k(...y)},m.styleSheetRuleCb=(...y)=>{g.styleSheetRule&&g.styleSheetRule(...y),T(...y)},m.styleDeclarationCb=(...y)=>{g.styleDeclaration&&g.styleDeclaration(...y),R(...y)},m.canvasMutationCb=(...y)=>{g.canvasMutation&&g.canvasMutation(...y),S(...y)},m.fontCb=(...y)=>{g.font&&g.font(...y),P(...y)},m.selectionCb=(...y)=>{g.selection&&g.selection(...y),D(...y)},m.customElementCb=(...y)=>{g.customElement&&g.customElement(...y),b(...y)}})(e,t),e.recordDOM&&(s=Jc(e,e.doc));const n=function({mousemoveCb:m,sampling:g,doc:v,mirror:I}){if(g.mousemove===!1)return()=>{};const O=typeof g.mousemove=="number"?g.mousemove:50,E=typeof g.mousemoveCallback=="number"?g.mousemoveCallback:500;let A,M=[];const k=$t($(S=>{const P=Date.now()-A;m(M.map(D=>(D.timeOffset-=P,D)),S),M=[],A=null}),E),T=$($t($(S=>{const P=er(S),{clientX:D,clientY:b}=li(S)?S.changedTouches[0]:S;A||(A=bs()),M.push({x:D,y:b,id:I.getId(P),timeOffset:bs()-A}),k(typeof DragEvent<"u"&&S instanceof DragEvent?G.Drag:S instanceof MouseEvent?G.MouseMove:G.TouchMove)}),O,{trailing:!1})),R=[ve("mousemove",T,v),ve("touchmove",T,v),ve("drag",T,v)];return $(()=>{R.forEach(S=>S())})}(e),i=If(e),a=Kc(e),o=function({viewportResizeCb:m},{win:g}){let v=-1,I=-1;return ve("resize",$($t($(()=>{const O=zc(),E=jc();v===O&&I===E||(m({width:Number(E),height:Number(O)}),v=O,I=E)}),200)),g)}(e,{win:r}),l=function({inputCb:m,doc:g,mirror:v,blockClass:I,blockSelector:O,ignoreClass:E,ignoreSelector:A,maskInputOptions:M,maskInputFn:k,sampling:T,userTriggeredOnInput:R}){function S(F){let j=er(F);const L=F.isTrusted,N=j&&j.tagName;if(j&&N==="OPTION"&&(j=V.parentElement(j)),!j||!N||Cf.indexOf(N)<0||Se(j,I,O,!0)||j.classList.contains(E)||A&&j.matches(A))return;let ee=j.value,q=!1;const me=Pi(j)||"";me==="radio"||me==="checkbox"?q=j.checked:(M[N.toLowerCase()]||M[me])&&(ee=Di({element:j,maskInputOptions:M,tagName:N,type:me,value:ee,maskInputFn:k})),P(j,R?{text:ee,isChecked:q,userTriggered:L}:{text:ee,isChecked:q});const Ne=j.name;me==="radio"&&Ne&&q&&g.querySelectorAll(`input[type="radio"][name="${Ne}"]`).forEach(we=>{if(we!==j){const H=we.value;P(we,R?{text:H,isChecked:!q,userTriggered:!1}:{text:H,isChecked:!q})}})}function P(F,j){const L=Da.get(F);if(!L||L.text!==j.text||L.isChecked!==j.isChecked){Da.set(F,j);const N=v.getId(F);$(m)({...j,id:N})}}const D=(T.input==="last"?["change"]:["input","change"]).map(F=>ve(F,$(S),g)),b=g.defaultView;if(!b)return()=>{D.forEach(F=>F())};const y=b.Object.getOwnPropertyDescriptor(b.HTMLInputElement.prototype,"value"),U=[[b.HTMLInputElement.prototype,"value"],[b.HTMLInputElement.prototype,"checked"],[b.HTMLSelectElement.prototype,"value"],[b.HTMLTextAreaElement.prototype,"value"],[b.HTMLSelectElement.prototype,"selectedIndex"],[b.HTMLOptionElement.prototype,"selected"]];return y&&y.set&&D.push(...U.map(F=>Ys(F[0],F[1],{set(){$(S)({target:this,isTrusted:!1})}},!1,b))),$(()=>{D.forEach(F=>F())})}(e),c=function({mediaInteractionCb:m,blockClass:g,blockSelector:v,mirror:I,sampling:O,doc:E}){const A=$(k=>$t($(T=>{const R=er(T);if(!R||Se(R,g,v,!0))return;const{currentTime:S,volume:P,muted:D,playbackRate:b,loop:y}=R;m({type:k,id:I.getId(R),currentTime:S,volume:P,muted:D,playbackRate:b,loop:y})}),O.media||500)),M=[ve("play",A(Et.Play),E),ve("pause",A(Et.Pause),E),ve("seeked",A(Et.Seeked),E),ve("volumechange",A(Et.VolumeChange),E),ve("ratechange",A(Et.RateChange),E)];return $(()=>{M.forEach(k=>k())})}(e);let u=()=>{},d=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:m,mirror:g,stylesheetManager:v},{win:I}){if(!I.CSSStyleSheet||!I.CSSStyleSheet.prototype)return()=>{};const O=I.CSSStyleSheet.prototype.insertRule;I.CSSStyleSheet.prototype.insertRule=new Proxy(O,{apply:$((R,S,P)=>{const[D,b]=P,{id:y,styleId:U}=st(S,g,v.styleMirror);return(y&&y!==-1||U&&U!==-1)&&m({id:y,styleId:U,adds:[{rule:D,index:b}]}),R.apply(S,P)})}),I.CSSStyleSheet.prototype.addRule=function(R,S,P=this.cssRules.length){const D=`${R} { ${S} }`;return I.CSSStyleSheet.prototype.insertRule.apply(this,[D,P])};const E=I.CSSStyleSheet.prototype.deleteRule;let A,M;I.CSSStyleSheet.prototype.deleteRule=new Proxy(E,{apply:$((R,S,P)=>{const[D]=P,{id:b,styleId:y}=st(S,g,v.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,removes:[{index:D}]}),R.apply(S,P)})}),I.CSSStyleSheet.prototype.removeRule=function(R){return I.CSSStyleSheet.prototype.deleteRule.apply(this,[R])},I.CSSStyleSheet.prototype.replace&&(A=I.CSSStyleSheet.prototype.replace,I.CSSStyleSheet.prototype.replace=new Proxy(A,{apply:$((R,S,P)=>{const[D]=P,{id:b,styleId:y}=st(S,g,v.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,replace:D}),R.apply(S,P)})})),I.CSSStyleSheet.prototype.replaceSync&&(M=I.CSSStyleSheet.prototype.replaceSync,I.CSSStyleSheet.prototype.replaceSync=new Proxy(M,{apply:$((R,S,P)=>{const[D]=P,{id:b,styleId:y}=st(S,g,v.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,replaceSync:D}),R.apply(S,P)})}));const k={};Hr("CSSGroupingRule")?k.CSSGroupingRule=I.CSSGroupingRule:(Hr("CSSMediaRule")&&(k.CSSMediaRule=I.CSSMediaRule),Hr("CSSConditionRule")&&(k.CSSConditionRule=I.CSSConditionRule),Hr("CSSSupportsRule")&&(k.CSSSupportsRule=I.CSSSupportsRule));const T={};return Object.entries(k).forEach(([R,S])=>{T[R]={insertRule:S.prototype.insertRule,deleteRule:S.prototype.deleteRule},S.prototype.insertRule=new Proxy(T[R].insertRule,{apply:$((P,D,b)=>{const[y,U]=b,{id:F,styleId:j}=st(D.parentStyleSheet,g,v.styleMirror);return(F&&F!==-1||j&&j!==-1)&&m({id:F,styleId:j,adds:[{rule:y,index:[...Wr(D),U||0]}]}),P.apply(D,b)})}),S.prototype.deleteRule=new Proxy(T[R].deleteRule,{apply:$((P,D,b)=>{const[y]=b,{id:U,styleId:F}=st(D.parentStyleSheet,g,v.styleMirror);return(U&&U!==-1||F&&F!==-1)&&m({id:U,styleId:F,removes:[{index:[...Wr(D),y]}]}),P.apply(D,b)})})}),$(()=>{I.CSSStyleSheet.prototype.insertRule=O,I.CSSStyleSheet.prototype.deleteRule=E,A&&(I.CSSStyleSheet.prototype.replace=A),M&&(I.CSSStyleSheet.prototype.replaceSync=M),Object.entries(k).forEach(([R,S])=>{S.prototype.insertRule=T[R].insertRule,S.prototype.deleteRule=T[R].deleteRule})})}(e,{win:r}),d=Xc(e,e.doc),h=function({styleDeclarationCb:m,mirror:g,ignoreCSSAttributes:v,stylesheetManager:I},{win:O}){const E=O.CSSStyleDeclaration.prototype.setProperty;O.CSSStyleDeclaration.prototype.setProperty=new Proxy(E,{apply:$((M,k,T)=>{var R;const[S,P,D]=T;if(v.has(S))return E.apply(k,[S,P,D]);const{id:b,styleId:y}=st((R=k.parentRule)==null?void 0:R.parentStyleSheet,g,I.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,set:{property:S,value:P,priority:D},index:Wr(k.parentRule)}),M.apply(k,T)})});const A=O.CSSStyleDeclaration.prototype.removeProperty;return O.CSSStyleDeclaration.prototype.removeProperty=new Proxy(A,{apply:$((M,k,T)=>{var R;const[S]=T;if(v.has(S))return A.apply(k,[S]);const{id:P,styleId:D}=st((R=k.parentRule)==null?void 0:R.parentStyleSheet,g,I.styleMirror);return(P&&P!==-1||D&&D!==-1)&&m({id:P,styleId:D,remove:{property:S},index:Wr(k.parentRule)}),M.apply(k,T)})}),$(()=>{O.CSSStyleDeclaration.prototype.setProperty=E,O.CSSStyleDeclaration.prototype.removeProperty=A})}(e,{win:r}),e.collectFonts&&(f=function({fontCb:m,doc:g}){const v=g.defaultView;if(!v)return()=>{};const I=[],O=new WeakMap,E=v.FontFace;v.FontFace=function(M,k,T){const R=new E(M,k,T);return O.set(R,{family:M,buffer:typeof k!="string",descriptors:T,fontSource:typeof k=="string"?k:JSON.stringify(Array.from(new Uint8Array(k)))}),R};const A=Mt(g.fonts,"add",function(M){return function(k){return setTimeout($(()=>{const T=O.get(k);T&&(m(T),O.delete(k))}),0),M.apply(this,[k])}});return I.push(()=>{v.FontFace=E}),I.push(A),$(()=>{I.forEach(M=>M())})}(e)));const w=function(m){const{doc:g,mirror:v,blockClass:I,blockSelector:O,selectionCb:E}=m;let A=!0;const M=$(()=>{const k=g.getSelection();if(!k||A&&(k!=null&&k.isCollapsed))return;A=k.isCollapsed||!1;const T=[],R=k.rangeCount||0;for(let S=0;S<R;S++){const P=k.getRangeAt(S),{startContainer:D,startOffset:b,endContainer:y,endOffset:U}=P;Se(D,I,O,!0)||Se(y,I,O,!0)||T.push({start:v.getId(D),startOffset:b,end:v.getId(y),endOffset:U})}E({ranges:T})});return M(),ve("selectionchange",M)}(e),p=function({doc:m,customElementCb:g}){const v=m.defaultView;return v&&v.customElements?Mt(v.customElements,"define",function(I){return function(O,E,A){try{g({define:{name:O}})}catch{console.warn(`Custom element callback failed for ${O}`)}return I.apply(this,[O,E,A])}}):()=>{}}(e),C=[];for(const m of e.plugins)C.push(m.observer(m.callback,r,m.options));return $(()=>{mt.forEach(m=>m.reset()),s==null||s.disconnect(),n(),i(),a(),o(),l(),c(),u(),d(),h(),f(),w(),p(),C.forEach(m=>m())})}function Vr(e){return window[e]!==void 0}function Hr(e){return!!(window[e]!==void 0&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class Pa{constructor(t){x(this,"iframeIdToRemoteIdMap",new WeakMap),x(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}getId(t,r,s,n){const i=s||this.getIdToRemoteIdMap(t),a=n||this.getRemoteIdToIdMap(t);let o=i.get(r);return o||(o=this.generateIdFn(),i.set(r,o),a.set(o,r)),o}getIds(t,r){const s=this.getIdToRemoteIdMap(t),n=this.getRemoteIdToIdMap(t);return r.map(i=>this.getId(t,i,s,n))}getRemoteId(t,r,s){const n=s||this.getRemoteIdToIdMap(t);return typeof r!="number"?r:n.get(r)||-1}getRemoteIds(t,r){const s=this.getRemoteIdToIdMap(t);return r.map(n=>this.getRemoteId(t,n,s))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class Ef{constructor(t){x(this,"iframes",new WeakMap),x(this,"crossOriginIframeMap",new WeakMap),x(this,"crossOriginIframeMirror",new Pa(Ol)),x(this,"crossOriginIframeStyleMirror"),x(this,"crossOriginIframeRootIdMap",new WeakMap),x(this,"mirror"),x(this,"mutationCb"),x(this,"wrappedEmit"),x(this,"loadListener"),x(this,"stylesheetManager"),x(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Pa(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var s,n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((s=t.contentWindow)==null||s.addEventListener("message",this.handleMessage.bind(this))),(n=this.loadListener)==null||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){const r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;const s=this.crossOriginIframeMap.get(t.source);if(!s)return;const n=this.transformCrossOriginEvent(s,r.data.event);n&&this.wrappedEmit(n,r.data.isCheckout)}transformCrossOriginEvent(t,r){var s;switch(r.type){case Y.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);const n=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,n),this.patchRootIdOnNode(r.data.node,n),{timestamp:r.timestamp,type:Y.IncrementalSnapshot,data:{source:G.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Y.Meta:case Y.Load:case Y.DomContentLoaded:return!1;case Y.Plugin:return r;case Y.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case Y.IncrementalSnapshot:switch(r.data.source){case G.Mutation:return r.data.adds.forEach(n=>{this.replaceIds(n,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(n.node,t);const i=this.crossOriginIframeRootIdMap.get(t);i&&this.patchRootIdOnNode(n.node,i)}),r.data.removes.forEach(n=>{this.replaceIds(n,t,["parentId","id"])}),r.data.attributes.forEach(n=>{this.replaceIds(n,t,["id"])}),r.data.texts.forEach(n=>{this.replaceIds(n,t,["id"])}),r;case G.Drag:case G.TouchMove:case G.MouseMove:return r.data.positions.forEach(n=>{this.replaceIds(n,t,["id"])}),r;case G.ViewportResize:return!1;case G.MediaInteraction:case G.MouseInteraction:case G.Scroll:case G.CanvasMutation:case G.Input:return this.replaceIds(r.data,t,["id"]),r;case G.StyleSheetRule:case G.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case G.Font:return r;case G.Selection:return r.data.ranges.forEach(n=>{this.replaceIds(n,t,["start","end"])}),r;case G.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(s=r.data.styles)==null||s.forEach(n=>{this.replaceStyleIds(n,t,["styleId"])}),r}}return!1}replace(t,r,s,n){for(const i of n)(Array.isArray(r[i])||typeof r[i]=="number")&&(Array.isArray(r[i])?r[i]=t.getIds(s,r[i]):r[i]=t.getId(s,r[i]));return r}replaceIds(t,r,s){return this.replace(this.crossOriginIframeMirror,t,r,s)}replaceStyleIds(t,r,s){return this.replace(this.crossOriginIframeStyleMirror,t,r,s)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(s=>{this.replaceIdOnNode(s,r)})}patchRootIdOnNode(t,r){t.type===fe.Document||t.rootId||(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(s=>{this.patchRootIdOnNode(s,r)})}}class xf{constructor(t){x(this,"shadowDoms",new WeakSet),x(this,"mutationCb"),x(this,"scrollCb"),x(this,"bypassOptions"),x(this,"mirror"),x(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,r){if(!Zt(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const s=Jc({...this.bypassOptions,doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},t);this.restoreHandlers.push(()=>s.disconnect()),this.restoreHandlers.push(Kc({...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(V.host(t))),this.restoreHandlers.push(Xc({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){t.contentWindow&&t.contentDocument&&this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,r){const s=this;this.restoreHandlers.push(Mt(t.prototype,"attachShadow",function(n){return function(i){const a=n.call(this,i),o=V.shadowRoot(this);return o&&Yc(this)&&s.addShadowRoot(o,r),a}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}for(var Yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tf=typeof Uint8Array>"u"?[]:new Uint8Array(256),Gr=0;Gr<64;Gr++)Tf[Yt.charCodeAt(Gr)]=Gr;const _a=new Map,Zc=(e,t,r)=>{if(!e||!eu(e,t)&&typeof e!="object")return;const s=function(i,a){let o=_a.get(i);return o||(o=new Map,_a.set(i,o)),o.has(a)||o.set(a,[]),o.get(a)}(r,e.constructor.name);let n=s.indexOf(e);return n===-1&&(n=s.length,s.push(e)),n};function ls(e,t,r){if(e instanceof Array)return e.map(s=>ls(s,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:function(s){var n,i=new Uint8Array(s),a=i.length,o="";for(n=0;n<a;n+=3)o+=Yt[i[n]>>2],o+=Yt[(3&i[n])<<4|i[n+1]>>4],o+=Yt[(15&i[n+1])<<2|i[n+2]>>6],o+=Yt[63&i[n+2]];return a%3==2?o=o.substring(0,o.length-1)+"=":a%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[ls(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const s=e.constructor.name,{src:n}=e;return{rr_type:s,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[ls(e.data,t,r),e.width,e.height]}:eu(e,t)||typeof e=="object"?{rr_type:e.constructor.name,index:Zc(e,t,r)}:e}const Qc=(e,t,r)=>e.map(s=>ls(s,t,r)),eu=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(s=>typeof t[s]=="function").find(s=>e instanceof t[s]);function Na(e,t,r,s){const n=[];try{const i=Mt(e.HTMLCanvasElement.prototype,"getContext",function(a){return function(o,...l){if(!Se(this,t,r,!0)){const c=function(u){return u==="experimental-webgl"?"webgl":u}(o);if("__context"in this||(this.__context=c),s&&["webgl","webgl2"].includes(c))if(l[0]&&typeof l[0]=="object"){const u=l[0];u.preserveDrawingBuffer||(u.preserveDrawingBuffer=!0)}else l.splice(0,1,{preserveDrawingBuffer:!0})}return a.apply(this,[o,...l])}});n.push(i)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(i=>i())}}function Fa(e,t,r,s,n,i){const a=[],o=Object.getOwnPropertyNames(e);for(const l of o)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if(typeof e[l]!="function")continue;const c=Mt(e,l,function(u){return function(...d){const h=u.apply(this,d);if(Zc(h,i,this),"tagName"in this.canvas&&!Se(this.canvas,s,n,!0)){const f=Qc(d,i,this),w={type:t,property:l,args:f};r(this.canvas,w)}return h}});a.push(c)}catch{const c=Ys(e,l,{set(u){r(this.canvas,{type:t,property:l,args:[u],setter:!0})}});a.push(c)}return a}const tu="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",Ba=typeof window<"u"&&window.Blob&&new Blob([(za=tu,Uint8Array.from(atob(za),e=>e.charCodeAt(0)))],{type:"text/javascript;charset=utf-8"});var za;function Rf(e){let t;try{if(t=Ba&&(window.URL||window.webkitURL).createObjectURL(Ba),!t)throw"";const r=new Worker(t,{name:e==null?void 0:e.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;base64,"+tu,{name:e==null?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}class Lf{constructor(t){x(this,"pendingCanvasMutations",new Map),x(this,"rafStamps",{latestId:0,invokeId:null}),x(this,"mirror"),x(this,"mutationCb"),x(this,"resetObservers"),x(this,"frozen",!1),x(this,"locked",!1),x(this,"processMutation",(l,c)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(l)||this.pendingCanvasMutations.set(l,[]),this.pendingCanvasMutations.get(l).push(c)});const{sampling:r="all",win:s,blockClass:n,blockSelector:i,recordCanvas:a,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(s,n,i),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,s,n,i,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,s,n,i){const a=Na(r,s,n,!0),o=new Map,l=new Rf;l.onmessage=f=>{const{id:w}=f.data;if(o.set(w,!1),!("base64"in f.data))return;const{base64:p,type:C,width:m,height:g}=f.data;this.mutationCb({id:w,type:kt["2D"],commands:[{property:"clearRect",args:[0,0,m,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:p}],type:C}]},0,0]}]})};const c=1e3/t;let u,d=0;const h=f=>{d&&f-d<c||(d=f,(()=>{const w=[];return r.document.querySelectorAll("canvas").forEach(p=>{Se(p,s,n,!0)||w.push(p)}),w})().forEach(async w=>{var p;const C=this.mirror.getId(w);if(o.get(C)||w.width===0||w.height===0)return;if(o.set(C,!0),["webgl","webgl2"].includes(w.__context)){const g=w.getContext(w.__context);((p=g==null?void 0:g.getContextAttributes())==null?void 0:p.preserveDrawingBuffer)===!1&&g.clear(g.COLOR_BUFFER_BIT)}const m=await createImageBitmap(w);l.postMessage({id:C,bitmap:m,width:w.width,height:w.height,dataURLOptions:i.dataURLOptions},[m])})),u=requestAnimationFrame(h)};u=requestAnimationFrame(h),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,s){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const n=Na(t,r,s,!1),i=function(o,l,c,u){const d=[],h=Object.getOwnPropertyNames(l.CanvasRenderingContext2D.prototype);for(const f of h)try{if(typeof l.CanvasRenderingContext2D.prototype[f]!="function")continue;const w=Mt(l.CanvasRenderingContext2D.prototype,f,function(p){return function(...C){return Se(this.canvas,c,u,!0)||setTimeout(()=>{const m=Qc(C,l,this);o(this.canvas,{type:kt["2D"],property:f,args:m})},0),p.apply(this,C)}});d.push(w)}catch{const w=Ys(l.CanvasRenderingContext2D.prototype,f,{set(p){o(this.canvas,{type:kt["2D"],property:f,args:[p],setter:!0})}});d.push(w)}return()=>{d.forEach(f=>f())}}(this.processMutation.bind(this),t,r,s),a=function(o,l,c,u){const d=[];return d.push(...Fa(l.WebGLRenderingContext.prototype,kt.WebGL,o,c,u,l)),l.WebGL2RenderingContext!==void 0&&d.push(...Fa(l.WebGL2RenderingContext.prototype,kt.WebGL2,o,c,u,l)),()=>{d.forEach(h=>h())}}(this.processMutation.bind(this),t,r,s);this.resetObservers=()=>{n(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const s=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,s)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const s=this.pendingCanvasMutations.get(t);if(!s||r===-1)return;const n=s.map(a=>{const{type:o,...l}=a;return l}),{type:i}=s[0];this.mutationCb({id:r,type:i,commands:n}),this.pendingCanvasMutations.delete(t)}}class Of{constructor(t){x(this,"trackedLinkElements",new WeakSet),x(this,"mutationCb"),x(this,"adoptedStyleSheetCb"),x(this,"styleMirror",new wf),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const s={id:r,styleIds:[]},n=[];for(const i of t){let a;this.styleMirror.has(i)?a=this.styleMirror.getId(i):(a=this.styleMirror.add(i),n.push({styleId:a,rules:Array.from(i.rules||CSSRule,(o,l)=>({rule:Rl(o,i.href),index:l}))})),s.styleIds.push(a)}n.length>0&&(s.styles=n),this.adoptedStyleSheetCb(s)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Af{constructor(){x(this,"nodeMap",new WeakMap),x(this,"active",!1)}inOtherBuffer(t,r){const s=this.nodeMap.get(t);return s&&Array.from(s).some(n=>n!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}}let ue,cs,fn,vs=!1;try{if(Array.from([1],e=>2*e)[0]!==2){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=((Eo=e.contentWindow)==null?void 0:Eo.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}const Oe=new Ll;function qt(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:s,blockClass:n="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",ignoreSelector:o=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:f,maskInputFn:w,maskTextFn:p,hooks:C,packFn:m,sampling:g={},dataURLOptions:v={},mousemoveWait:I,recordDOM:O=!0,recordCanvas:E=!1,recordCrossOriginIframes:A=!1,recordAfter:M=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:k=!1,collectFonts:T=!1,inlineImages:R=!1,plugins:S,keepIframeSrcFn:P=()=>!1,ignoreCSSAttributes:D=new Set([]),errorHandler:b}=e;Qt=b;const y=!A||window.parent===window;let U=!1;if(!y)try{window.parent.document&&(U=!1)}catch{U=!0}if(y&&!t)throw new Error("emit function is required");if(!y&&!U)return()=>{};I!==void 0&&g.mousemove===void 0&&(g.mousemove=I),Oe.reset();const F=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},j=f===!0||f==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:f==="all",headMetaDescKeywords:f==="all",headTitleMutations:f==="all"}:f||{};let L;(function(W=window){"NodeList"in W&&!W.NodeList.prototype.forEach&&(W.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in W&&!W.DOMTokenList.prototype.forEach&&(W.DOMTokenList.prototype.forEach=Array.prototype.forEach)})();let N=0;const ee=W=>{for(const Ie of S||[])Ie.eventProcessor&&(W=Ie.eventProcessor(W));return m&&!U&&(W=m(W)),W};ue=(W,Ie)=>{var ne;const ae=W;if(ae.timestamp=bs(),!((ne=mt[0])!=null&&ne.isFrozen())||ae.type===Y.FullSnapshot||ae.type===Y.IncrementalSnapshot&&ae.data.source===G.Mutation||mt.forEach(Te=>Te.unfreeze()),y)t==null||t(ee(ae),Ie);else if(U){const Te={type:"rrweb",event:ee(ae),origin:window.location.origin,isCheckout:Ie};window.parent.postMessage(Te,"*")}if(ae.type===Y.FullSnapshot)L=ae,N=0;else if(ae.type===Y.IncrementalSnapshot){if(ae.data.source===G.Mutation&&ae.data.isAttachIframe)return;N++;const Te=s&&N>=s,J=r&&ae.timestamp-L.timestamp>r;(Te||J)&&cs(!0)}};const q=W=>{ue({type:Y.IncrementalSnapshot,data:{source:G.Mutation,...W}})},me=W=>ue({type:Y.IncrementalSnapshot,data:{source:G.Scroll,...W}}),Ne=W=>ue({type:Y.IncrementalSnapshot,data:{source:G.CanvasMutation,...W}}),we=new Of({mutationCb:q,adoptedStyleSheetCb:W=>ue({type:Y.IncrementalSnapshot,data:{source:G.AdoptedStyleSheet,...W}})}),H=new Ef({mirror:Oe,mutationCb:q,stylesheetManager:we,recordCrossOriginIframes:A,wrappedEmit:ue});for(const W of S||[])W.getMirror&&W.getMirror({nodeMirror:Oe,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});const Le=new Af;fn=new Lf({recordCanvas:E,mutationCb:Ne,win:window,blockClass:n,blockSelector:i,mirror:Oe,sampling:g.canvas,dataURLOptions:v});const et=new xf({mutationCb:q,scrollCb:me,bypassOptions:{blockClass:n,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:F,dataURLOptions:v,maskTextFn:p,maskInputFn:w,recordCanvas:E,inlineImages:R,sampling:g,slimDOMOptions:j,iframeManager:H,stylesheetManager:we,canvasManager:fn,keepIframeSrcFn:P,processedNodeManager:Le},mirror:Oe});cs=(W=!1)=>{if(!O)return;ue({type:Y.Meta,data:{href:window.location.href,width:jc(),height:zc()}},W),we.reset(),et.init(),mt.forEach(ne=>ne.lock());const Ie=function(ne,ae){const{mirror:Te=new Ll,blockClass:J="rr-block",blockSelector:_t=null,maskTextClass:ld="rr-mask",maskTextSelector:cd=null,inlineStylesheet:ud=!0,inlineImages:dd=!1,recordCanvas:pd=!1,maskAllInputs:Ks=!1,maskTextFn:hd,maskInputFn:md,slimDOM:Nt=!1,dataURLOptions:fd,preserveWhiteSpace:gd,onSerialize:yd,onIframeLoad:wd,iframeLoadTimeout:bd,onStylesheetLoad:vd,stylesheetLoadTimeout:Sd,keepIframeSrcFn:Id=()=>!1}=ae||{};return xt(ne,{doc:ne,mirror:Te,blockClass:J,blockSelector:_t,maskTextClass:ld,maskTextSelector:cd,skipChild:!1,inlineStylesheet:ud,maskInputOptions:Ks===!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}:Ks===!1?{password:!0}:Ks,maskTextFn:hd,maskInputFn:md,slimDOMOptions:Nt===!0||Nt==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:Nt==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:Nt===!1?{}:Nt,dataURLOptions:fd,inlineImages:dd,recordCanvas:pd,preserveWhiteSpace:gd,onSerialize:yd,onIframeLoad:wd,iframeLoadTimeout:bd,onStylesheetLoad:vd,stylesheetLoadTimeout:Sd,keepIframeSrcFn:Id,newlyAddedElement:!1})}(document,{mirror:Oe,blockClass:n,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskAllInputs:F,maskTextFn:p,maskInputFn:w,slimDOM:j,dataURLOptions:v,recordCanvas:E,inlineImages:R,onSerialize:ne=>{Hc(ne,Oe)&&H.addIframe(ne),Gc(ne,Oe)&&we.trackLinkElement(ne),ci(ne)&&et.addShadowRoot(V.shadowRoot(ne),document)},onIframeLoad:(ne,ae)=>{H.attachIframe(ne,ae),et.observeAttachShadow(ne)},onStylesheetLoad:(ne,ae)=>{we.attachLinkElement(ne,ae)},keepIframeSrcFn:P});if(!Ie)return console.warn("Failed to snapshot the document");ue({type:Y.FullSnapshot,data:{node:Ie,initialOffset:Bc(window)}},W),mt.forEach(ne=>ne.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&we.adoptStyleSheets(document.adoptedStyleSheets,Oe.getId(document))};try{const W=[],Ie=ae=>{var Te;return $(kf)({mutationCb:q,mousemoveCb:(J,_t)=>ue({type:Y.IncrementalSnapshot,data:{source:_t,positions:J}}),mouseInteractionCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.MouseInteraction,...J}}),scrollCb:me,viewportResizeCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.ViewportResize,...J}}),inputCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.Input,...J}}),mediaInteractionCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.MediaInteraction,...J}}),styleSheetRuleCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.StyleSheetRule,...J}}),styleDeclarationCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.StyleDeclaration,...J}}),canvasMutationCb:Ne,fontCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.Font,...J}}),selectionCb:J=>{ue({type:Y.IncrementalSnapshot,data:{source:G.Selection,...J}})},customElementCb:J=>{ue({type:Y.IncrementalSnapshot,data:{source:G.CustomElement,...J}})},blockClass:n,ignoreClass:a,ignoreSelector:o,maskTextClass:l,maskTextSelector:c,maskInputOptions:F,inlineStylesheet:u,sampling:g,recordDOM:O,recordCanvas:E,inlineImages:R,userTriggeredOnInput:k,collectFonts:T,doc:ae,maskInputFn:w,maskTextFn:p,keepIframeSrcFn:P,blockSelector:i,slimDOMOptions:j,dataURLOptions:v,mirror:Oe,iframeManager:H,stylesheetManager:we,shadowDomManager:et,processedNodeManager:Le,canvasManager:fn,ignoreCSSAttributes:D,plugins:((Te=S==null?void 0:S.filter(J=>J.observer))==null?void 0:Te.map(J=>({observer:J.observer,options:J.options,callback:_t=>ue({type:Y.Plugin,data:{plugin:J.name,payload:_t}})})))||[]},C)};H.addLoadListener(ae=>{try{W.push(Ie(ae.contentDocument))}catch(Te){console.warn(Te)}});const ne=()=>{cs(),W.push(Ie(document)),vs=!0};return document.readyState==="interactive"||document.readyState==="complete"?ne():(W.push(ve("DOMContentLoaded",()=>{ue({type:Y.DomContentLoaded,data:{}}),M==="DOMContentLoaded"&&ne()})),W.push(ve("load",()=>{ue({type:Y.Load,data:{}}),M==="load"&&ne()},window))),()=>{W.forEach(ae=>ae()),Le.destroy(),vs=!1,Qt=void 0}}catch(W){console.warn(W)}}var ja,It;qt.addCustomEvent=(e,t)=>{if(!vs)throw new Error("please add custom event after start recording");ue({type:Y.Custom,data:{tag:e,payload:t}})},qt.freezePage=()=>{mt.forEach(e=>e.freeze())},qt.takeFullSnapshot=e=>{if(!vs)throw new Error("please take full snapshot after start recording");cs(e)},qt.mirror=Oe,(It=ja||(ja={}))[It.NotStarted=0]="NotStarted",It[It.Running=1]="Running",It[It.Stopped=2]="Stopped";var Ae=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Ae||{}),B=(e=>(e.ReplayCapture="replay.capture",e.ReplayPaused="replay.paused",e.ReplayResumed="replay.resumed",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyCloseRequested="survey.closeRequested",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))(B||{});const hr={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 $r;const Mf=new Uint8Array(16);function Uf(){if(!$r&&($r=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!$r))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $r(Mf)}const ge=[];for(let e=0;e<256;++e)ge.push((e+256).toString(16).slice(1));const Wa={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function bt(e,t,r){if(Wa.randomUUID&&!e)return Wa.randomUUID();const s=(e=e||{}).random||(e.rng||Uf)();return s[6]=15&s[6]|64,s[8]=63&s[8]|128,function(n,i=0){return ge[n[i+0]]+ge[n[i+1]]+ge[n[i+2]]+ge[n[i+3]]+"-"+ge[n[i+4]]+ge[n[i+5]]+"-"+ge[n[i+6]]+ge[n[i+7]]+"-"+ge[n[i+8]]+ge[n[i+9]]+"-"+ge[n[i+10]]+ge[n[i+11]]+ge[n[i+12]]+ge[n[i+13]]+ge[n[i+14]]+ge[n[i+15]]}(s)}const _=new class{constructor(){de(this,"breadcrumbs",[])}getTimeStamp(){return new Date().toISOString()}addBreadcrumb(e){this.breadcrumbs.push(e),this.breadcrumbs.length>300&&this.breadcrumbs.shift()}debug(e,t="debug"){this.addBreadcrumb({category:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"debug"})}error(e,t={}){this.addBreadcrumb({category:"error",data:t,level:"error",message:e,timestamp:this.getTimeStamp(),type:"error"})}http(e,t){this.addBreadcrumb({category:"xhr",data:t,message:e,timestamp:this.getTimeStamp(),type:"http"})}info(e,t={}){this.addBreadcrumb({category:"info",data:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"info"})}navigation(e,t){this.addBreadcrumb({category:"navigation",data:t,message:e,timestamp:this.getTimeStamp(),type:"navigation"})}},Va=()=>{try{return window.parent.Intercom}catch{return null}},Ha=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const e=Va();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},enable:()=>{const e=Va();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class ru{static disable(){Ha.forEach(t=>t.disable())}static enable(){Ha.forEach(t=>t.enable())}}var Df=class extends Error{constructor(e,t,r){super(`Possible EventEmitter memory leak detected. ${r} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=r,this.name="MaxListenersExceededWarning"}},su=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=su.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,r){this.emit(e,t,r)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const r=e.indexOf(t);return r>-1&&e.splice(r,1),[]}_wrapOnceListener(e,t){const r=(...s)=>(this.removeListener(e,r),t.apply(this,s));return Object.defineProperty(r,"name",{value:t.name}),r}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const r=this._getListeners(e);return r.forEach(s=>{s.apply(this,t)}),r.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const r=this._getListeners(e).concat(t);if(this.events.set(e,r),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const s=new Df(this,e,this.listenerCount(e));console.warn(s)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const r=this._getListeners(e);if(r.length>0){const s=[t].concat(r);this.events.set(e,s)}else this.events.set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const r=this._getListeners(e);return r.length>0&&(this._removeListener(r,t),this.events.set(e,r),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},nu=su;nu.defaultMaxListeners=10;const z=new nu,Ss=async e=>{await new Promise(t=>{setTimeout(t,e)})},to=({"userleap-platform":e})=>{var t;return((t=window.UserLeap)==null?void 0:t.forceDirectEmbed)||e!=="web"};class iu{constructor(t){de(this,"storage");de(this,"tempStorage",{});de(this,"isStorageAvailable");try{this.storage=window[t];const r="__storage_test__";this.storage.setItem(r,r),this.storage.removeItem(r),this.isStorageAvailable=!0}catch{this.isStorageAvailable=!1}}setItem(t,r){this.isStorageAvailable&&this.storage?this.storage.setItem(t,r):this.tempStorage[t]=r}setItemObject(t,r){try{this.setItem(t,JSON.stringify(r))}catch(s){s instanceof Error&&(s.stack=t+": "+r,window.UserLeap.reportError("Failed to save to local storage",s))}}getItem(t){return this.isStorageAvailable&&this.storage?this.storage.getItem(t):this.tempStorage[t]}getItemObject(t){const r=this.getItem(t);if(r)try{return JSON.parse(r)}catch(s){s instanceof Error&&(s.stack=t+": "+r,window.UserLeap.reportError("Failed to parse local storage",s))}return{}}removeItem(t){this.isStorageAvailable&&this.storage?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable&&this.storage?this.storage.clear():this.tempStorage={}}}const Q=new iu("sessionStorage"),ut=new iu("localStorage");class Pf{constructor(t){de(this,"payload");de(this,"promise");de(this,"reject",()=>{});de(this,"resolve",()=>{});this.payload=t,this.promise=new Promise((r,s)=>{this.reject=s,this.resolve=r})}resolveRequest(t){this.resolve(t)}}const re={replay:null},_f=()=>{const e=[];return re.replay&&e.push("replay"),e.join(",")},Nf=10;let ou=!1,au="",Yr=!1,lu=!1,us=[];const Ff=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",Ga=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(lu=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`))},di=(e="")=>{ou=!0,au=e};function De(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.44.0","x-ul-installation-method":Ff(e),"sprig-modules":_f(),"x-ul-package-version":"2.44.0"};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const r=JSON.parse(e.mobileHeadersJSON);Object.assign(t,r)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const $a=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const r=new Pf(t);return us.push(r),r.promise}},He=async(e,t)=>{const{retries:r=0,shouldDropOnRateLimit:s=!1,shouldRetryRequest:n=!1,...i}=t,a={url:e,options:i,retries:r,shouldDropOnRateLimit:s};if(Yr&&!n)return $a(a);const o={ok:!1,reportError:!1};if(ou)return console.info(`UserLeap - ${au}`),o;try{const l=await fetch(e,i);if(l.status===429){if(!Yr&&!s||n){Yr=!0;const c=l.headers.has("ratelimit-reset")?Number(l.headers.get("ratelimit-reset")):Nf;return await Ss(1e3*c),He(e,{...i,shouldDropOnRateLimit:s,shouldRetryRequest:!0})}return $a(a)}if(Yr=!1,us.length&&(us.map(c=>{const u=c.payload;He(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(d=>{c.resolveRequest(d)})}),us=[]),l.ok){if(l.status===249)return di(),o;const c=await l.text();try{return c&&c!=="OK"&&(l.json=JSON.parse(c)),l}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${c}`)}}}return l}catch(l){const c=r+1;return c>5||lu?{ok:!1,reportError:!1,error:l}:(await Ss(1e3*Math.pow(2,r)),He(e,{...i,retries:c}))}},Ya="ul-view-sdk-script",Bf=new Set(["ios","android"]),it="visitors",ot="environments";async function ze(e,t){var i,a,o;const{shouldDropOnRateLimit:r,...s}=t;s.headers=Object.assign(De(window.UserLeap),s.headers);const n=await He(e,{...s,shouldDropOnRateLimit:r});if(n.ok){const l=(i=n.headers)==null?void 0:i.get("Authorization"),c=l?l.split(" "):void 0,u=c&&c.length===2?c[1]:void 0,d=(a=n.headers)==null?void 0:a.get("x-ul-visitor-id");if(window.UserLeap.userId&&d===window.UserLeap.visitorId){const h=ut.getItemObject("sprig.anon.env.vid.map");h&&h[window.UserLeap.envId]===d&&(delete h[window.UserLeap.envId],ut.setItemObject("sprig.anon.env.vid.map",h))}u&&d&&(d!==window.UserLeap.visitorId||window.UserLeap.token!==u)&&(ke("token",u),ke("vid",d),z.emit(B.VisitorIDUpdated,{visitorId:d}),window.UserLeap.token=u,window.UserLeap.visitorId=d)}return(o=n.json)!=null&&o.logMessage&&console.warn(`[Sprig] ${n.json.logMessage}`),n}function ke(e,t){const r=ut.getItemObject("userleap.ids");let s=r[window.UserLeap.envId];s?s[e]=t:s={[e]:t},r[window.UserLeap.envId]=s,ut.setItemObject("userleap.ids",r)}function ro(){return window.previewMode?"0":window.UserLeap.visitorId??""}function Me(e,t,r){const s=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(n=>{s.push(n),n===ot?s.push(window.UserLeap.envId):n===it&&s.push(ro())}),r&&s.push(r),s.join("/")}const tr=async(e,t,r)=>{var q,me,Ne,we;const{context:s,delay:n,avatars:i,experimentFlags:a,forceBrandedLogo:o,endCard:l,isFeedback:c=!1,heatmap:u,locale:d,layout:h,previewMode:f,productConfig:w,questions:p,responseGroupUid:C,surveyId:m,uuid:g,vid:v,sessionReplay:I,studyType:O,surveyVisitorAttributes:E}=e,A=De(window.UserLeap),M=mr(A),k=qs(A);if(I)if(M)z.emit(B.ReplayCapture,{responseGroupUid:C,hasQuestions:!!(p!=null&&p.length),surveyId:m,uploadId:I.uploadId,replayType:I.replayDurationType??"before",seconds:I.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:bt(),mediaType:"screen",questionId:1,responseGroupUid:C,surveyId:m,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!re.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};re.replay.scheduleOrCaptureReplay({responseGroupId:C,surveyId:m,visitorId:v,replayParams:I,completeUploadHeaders:A,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:p.length===0})}if(u){if(!re.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:H,replayParams:Le,responseGroupUid:et,surveyId:W}=u;await re.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0,apiUrl:window.UserLeap._API_URL,replaySettings:r}),re.replay.tryReplayAction(()=>{var Ie;return(Ie=re.replay)==null?void 0:Ie.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:A,eventId:H,isHeatmap:!0,replayParams:Le,responseGroupId:et,surveyId:W,triggerTimestamp:Date.now(),visitorId:v})},"Error in scheduling/capturing replay")}if(v==null||!(p!=null&&p.length))return _.info("CannotDisplaySurvey",{vid:v}),{success:!1,message:"[Sprig] no survey found",surveyState:window.UserLeap.container?"previous survey ready":"no survey"};if(zf(p))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){_.info("AlreadyDisplayingSurvey");const H="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(H),{success:!1,message:H,surveyState:"previous survey ready"}}if(v!==window.UserLeap.visitorId&&g!==window.UserLeap.visitorId&&!window.previewMode){const H="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(H)),{success:!1,message:H,surveyState:"no survey"}}_.info("ShowingSurvey",{surveyId:m}),(q=re.replay)==null||q.RecordSurveyShown({id:m,userAgent:window.navigator.userAgent}),ru.disable(),z.emit(B.SurveyWillPresent,{name:B.SurveyWillPresent,"survey.id":m,layout:h});let T,R,S,P,D=document.createElement("div");const b=H=>{const{"view.version":Le}=H;Le!==A["x-ul-sdk-version"]&&uu(),z.removeListener("verify.view.version",b)};z.on("verify.view.version",b),window.UserLeap.useMobileStyling=k,to(A)?(T="ul-direct-embeded-frame",R=document.head,S=window,P=!1,(()=>{const H=De(window.UserLeap),Le=mr(H),et=window.UserLeap.forceDirectEmbed,W=H["userleap-platform"]==="web";return Le||et&&W})()&&(cu(m,c),D.id=T,window.UserLeap.container.appendChild(D),du(),z.emit(B.SurveyLifeCycle,{state:"presented"}),z.emit(B.SurveyPresented,{name:B.SurveyPresented,"survey.id":m}))):{frameId:T,contentWinDocHead:R,contentWindow:S,hasOverlay:P,iframe:D}=Vf({productConfig:w,useMobileStyling:k,surveyId:m,isFeedback:c,enableCspTrustedTypes:(me=window.UserLeap._config)==null?void 0:me.enableCspTrustedTypes}),window.UserLeap.frameId=T;const y={apiURL:window.UserLeap._API_URL,avatars:i,cards:p,configureExitOnOverlayClick:H=>{z.once(B.CloseSurveyOnOverlayClick,H)},context:s,endCard:l,envId:window.UserLeap.envId,eventEmitFn:z.emit.bind(z),experimentFlags:a,fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:o,frame:D,headers:A,layout:h,locale:d,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:Q.getItem("sprig.previewKey"),previewMode:f||!!window.previewMode,productConfig:{framePosition:w==null?void 0:w.framePosition,desktopDisplay:w==null?void 0:w.desktopDisplay,placement:w==null?void 0:w.placement},responseGroupUid:C,startingQuestionIdx:(Ne=window.UserLeap.config)==null?void 0:Ne.startingQuestionIdx,studyType:O,styleNonce:window.UserLeap.styleNonce,surveyId:m,tabTitle:document.title,trackPageViewUrl:t,ulEvents:hr,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:k,userId:g,viewDocument:S==null?void 0:S.document,viewWindow:S,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},surveyVisitorAttributes:E||{},...window.UserLeap._config};(we=window.UserLeap._config)!=null&&we.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const U=(c?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??w.customStyles;y.customStyles=U,S&&(S.__cfg=y);const F=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:y.path,j=document.getElementById(Ya);j&&j.remove();const L=function(){const H=document.createElement("script");return window.UserLeap.isMobileSDK||H.setAttribute("type","module"),window.UserLeap.nonce&&H.setAttribute("nonce",window.UserLeap.nonce),H.id=Ya,H}(),N=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(y.installationMethod==="web-npm"||y.installationMethod==="web-npm-bundled"){const{default:H}=await Promise.resolve().then(()=>require("./view-0ocXtsSZ.cjs")).then(Le=>Le.view);H.configure(y),P&&window.UserLeap.container&&N()}else F&&(L.src=`${F}${window.UserLeap.isMobileSDK?"":`?t=${Date.now()}`}`,P&&L.addEventListener("load",()=>{window.UserLeap.container&&N()}),S==null||S.addEventListener("error",H=>{H.target instanceof HTMLScriptElement&&H.target.src===F&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));R==null||R.appendChild(L);const ee={success:!0,surveyState:"ready",surveyId:m,responseGroupUid:C};return window.UserLeap.isMobileSDK&&n&&(ee.delay=n),ee};function qs(e){var r;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((r=window.UserLeap.windowDimensions)==null?void 0:r.width)??document.body.clientWidth;return mr(e)||t>10&&t<500}function mr(e){return Bf.has(e["userleap-platform"])}const zf=e=>e.some(t=>t.type==="videovoice"),qa=new WeakMap,jf=(e,t)=>{try{return(s=>{var a,o;const n=qa.get(s);if(n)return n;if(!((a=s.trustedTypes)!=null&&a.createPolicy))throw new Error("Trusted types not supported");const i=(o=s.trustedTypes)==null?void 0:o.createPolicy("sprig-sdk",{createHTML:l=>l,createScript:l=>l,createScriptURL:l=>l});return qa.set(s,i),i})(t).createHTML(e)}catch(r){return console.warn("Could not create TrustedHTML object",r),e}},Js=(e,t,r=window)=>{var s;return t&&((s=r.trustedTypes)!=null&&s.createPolicy)?jf(e,r):e},so="ul-frame";globalThis.UserLeap&&globalThis.Sprig&&(globalThis.Sprig._gtm?globalThis.Sprig=globalThis.UserLeap:globalThis.UserLeap=globalThis.Sprig),globalThis.UserLeap||(globalThis.UserLeap=globalThis.Sprig),globalThis.Sprig||(globalThis.Sprig=globalThis.UserLeap);const gn="0px",cu=(e,t,r)=>{globalThis.UserLeap.container=document.createElement("div"),globalThis.UserLeap.container.className="ul-container"+(t?" ul-container-feedback":""),e&&(globalThis.UserLeap.container.dataset.studyId=e.toString());const s=fu();r&&s&&!globalThis.UserLeap.useMobileStyling?s.appendChild(globalThis.UserLeap.container):document.body.appendChild(globalThis.UserLeap.container)},uu=(e,t)=>{var s;Gf();const r=globalThis.UserLeap.container;if(r)try{(s=r.parentNode)==null||s.removeChild(r),globalThis.UserLeap.container=null,ke("trackStartUrl",null),z.emit(B.SurveyLifeCycle,{state:"dismissed"}),z.emit(B.SurveyClosed,{name:B.SurveyClosed,initiator:e,"survey.id":parseInt(r.dataset.studyId),...t&&{studyType:t}})}catch(n){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+r),n instanceof Error&&globalThis.UserLeap.reportError("dismissActiveSurvey",n)}},du=()=>{z.once(B.SurveyWillClose,({initiator:e,studyType:t})=>{z.removeAllListeners(B.CloseSurveyOnOverlayClick),uu(e,t)})},Wf=(e,t,r,s)=>{var u,d;const n={position:"fixed",bottom:"0px",right:gn,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%"},i=Object.assign({},t,globalThis.UserLeap),{desktopDisplay:a}=t||{},o=a==="center-modal";let l;o&&(i.framePosition="center");let c=!1;if(r)(u=globalThis.UserLeap.windowDimensions)!=null&&u.width?n.width=`${globalThis.UserLeap.windowDimensions.width}px`:n.width="100%",(d=globalThis.UserLeap.windowDimensions)!=null&&d.height?n.maxHeight=globalThis.UserLeap.windowDimensions.height-20+"px":globalThis.UserLeap.maxHeight?n.maxHeight=globalThis.UserLeap.maxHeight:n.maxHeight=document.body.clientHeight-20+"px",["light","dark"].includes(i.overlayStyleMobile)&&(c=!0);else{n.width="360px",n.maxHeight=globalThis.UserLeap.maxHeight||"66vh";const h=()=>{c=!0,l={margin:"auto",position:"static"}};if(s)o?h():l={position:"relative",height:"300px"};else switch(i.framePosition){case"bottomLeft":l={left:gn};break;case"topLeft":l={left:gn,top:0};break;case"topRight":l={top:0};break;case"center":h()}}return c&&((h,f)=>{const w={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},p=f?h.overlayStyleMobile:h.overlayStyle;w["background-color"]=p==="light"?"rgba(255,255,255, 0.95)":"rgba(0,0,0,0.9)",f||(w.margin="auto"),globalThis.UserLeap.container&&Object.assign(globalThis.UserLeap.container.style,w)})(i,r),Object.assign(e.style,n,l),c},Vf=({productConfig:e,useMobileStyling:t,surveyId:r,isFeedback:s,enableCspTrustedTypes:n})=>{var f,w;const i=so,a=s&&e.desktopDisplay==="slider";cu(r,s,a),Hf();const o=document.createElement("iframe");o.id=i,o.setAttribute("title","Sprig User Feedback Dialog");const l=Wf(o,e,t,s);du();let c=!1;o.setHeight=p=>{parseInt(o.style.height)==p&&c||(c=!0,o.style.height=`${p}px`,z.emit(B.SurveyHeight,{name:B.SurveyHeight,contentFrameHeight:p,"survey.id":r}))};let u=!1;o.setWidth=p=>{parseInt(o.style.width)==p&&u||(u=!0,o.style.width=`${p}px`,z.emit(B.SurveyWidth,{name:B.SurveyWidth,contentFrameWidth:p,"survey.id":r}))},(f=globalThis.UserLeap.container)==null||f.appendChild(o),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&globalThis.UserLeap.container&&(globalThis.UserLeap.container.onclick=()=>{z.emit(B.CloseSurveyOnOverlayClick)}),z.emit(B.SurveyLifeCycle,{state:"presented"}),z.emit(B.SurveyPresented,{name:B.SurveyPresented,"survey.id":r});const d=(w=o.contentWindow)==null?void 0:w.document;if(d&&(d.open("text/html","replace"),d.write(Js("<!doctype html><head></head><body></body></html>",n,o.contentWindow)),d.close(),!t)){const p=d.body;p.style.display="flex",p.style.alignItems="center"}const h=d==null?void 0:d.head;return{frameId:i,contentWinDocHead:h,contentWindow:o.contentWindow,hasOverlay:l,iframe:o}},pu={[B.SurveyFadingOut]:()=>{globalThis.UserLeap.container&&Object.assign(globalThis.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Hf=()=>{Object.entries(pu).forEach(([e,t])=>{z.on(e,t)})},Gf=()=>{Object.entries(pu).forEach(([e,t])=>{z.off(e,t)})},Ja=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 no(e,t){const{matchType:r,pattern:s}=e,n=r?Ja[r]:Ja.legacy;let i=!1;try{i=n(s,t)}catch(a){const o=`[Sprig] (ERR-445) Failed to check url match with pattern ${s}`;a instanceof Error&&(console.warn(o,a),a.stack=JSON.stringify(e),window.UserLeap.reportError(o,a))}return i}const hu=e=>{const{pageUrlEvents:t}=window.UserLeap._config,r=t==null?void 0:t.find(s=>s.id===e);return!!r&&no(r,window.location.href)},qe=e=>!!e&&e.nodeType===Node.ELEMENT_NODE,Ka=e=>e instanceof HTMLElement||e instanceof SVGElement,fr=({document:e,elementId:t,styleString:r,nonce:s})=>{const n=e.getElementById(t);if(n)return void(n.textContent=r);const i=e.createElement("style");s&&(i.nonce=s),i.textContent=r,i.id=t,e.head.appendChild(i)},Xa=(e,t)=>{const r=t.querySelector(e);if(!qe(r))return 0;const s=getComputedStyle(r);return parseFloat(s.paddingLeft)+parseFloat(s.paddingRight)+(parseFloat(s.marginLeft)+parseFloat(s.marginRight))+(parseFloat(s.borderLeftWidth)+parseFloat(s.borderRightWidth))},mu=(e,t,r)=>{const s=e.querySelector(".ul-card__container"),n=e.querySelector(".ul-app");let i=600,a=360;if(qe(s)&&qe(n)){const o=s.querySelector(".ul-card--matrix_grid"),l=!o&&t&&r;try{l&&(n.style.width="360px"),i=s.scrollHeight,i+=(d=>{const h=d.querySelector(".sprig-question-body"),f=d.querySelector(".ul-card"),w=d.querySelector(".ul-card-main-content"),p=d.querySelector(".ul-footer"),C=d.querySelector(".sprig-container");let m=0;return qe(f)&&(m+=f.scrollHeight-f.clientHeight),qe(w)&&(m+=w.scrollHeight-w.clientHeight),qe(h)&&(m+=h.scrollHeight-h.clientHeight),qe(p)&&qe(C)&&C.clientHeight===0&&(m+=p.clientHeight),m})(e);const c=getComputedStyle(s),u=parseFloat(c.marginTop)+parseFloat(c.marginBottom);i+=u+(parseFloat(c.borderTopWidth)+parseFloat(c.borderBottomWidth)),o&&(a=o.scrollWidth,a+=Xa(".ul-card__container",e),a+=Xa(".sprig-question-body",e))}finally{l&&n.style.removeProperty("width")}}return[i+2,a]},fu=()=>Z,Lt=()=>document.getElementById("sprig-feedback-container"),pi=()=>document.getElementById("sprig-feedback-loading-animation"),gu=()=>!!document.getElementById(so);let Za=!1,Z=null,je=null,io=!1,rr=null,pt=null;const $f=["bottom-left","bottom-right","center-left","center-right"],Is=()=>{var t;const e=window.UserLeap.container;return((t=e==null?void 0:e.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},yu=()=>document.getElementById("sprig-feedback-error-container"),wu=()=>{if(!Z)return 0;const e=Z==null?void 0:Z.clientWidth,t=window.getComputedStyle(Z);return e+parseInt(t.borderRightWidth||"0")+parseInt(t.borderLeftWidth||"0")},Cs=e=>{const t=Lt();t&&(pt!=null&&pt.endsWith("right")?t.style.right=`${e}px`:pt!=null&&pt.endsWith("left")&&(t.style.left=`${e}px`))},yn=()=>{if(Z&&(Is()||yu())){z.off(B.SurveyAppeared,Jt),hi();const e=wu();return Cs(-e),!0}return!1},Jt=()=>{if(!Z||!je)return;const e=pi();e&&e.remove(),Z.style.height="auto",Z.style.width="auto",je.disabled=!1,io=!1},hi=()=>{if(Z&&!pi()){const e=(()=>{var r;if(pi())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=Js(`
|
|
55
|
+
or you can use record.mirror to access the mirror instance during recording.`;let La={map:{},getId:()=>(console.error(Ct),-1),getNode:()=>(console.error(Ct),null),removeNodeFromMap(){console.error(Ct)},has:()=>(console.error(Ct),!1),reset(){console.error(Ct)}};function $t(e,t,r={}){let s=null,n=0;return function(...i){const a=Date.now();n||r.leading!==!1||(n=a);const o=t-(a-n),l=this;o<=0||o>t?(s&&(clearTimeout(s),s=null),n=a,e.apply(l,i)):s||r.trailing===!1||(s=setTimeout(()=>{n=r.leading===!1?0:Date.now(),s=null,e.apply(l,i)},o))}}function Ys(e,t,r,s,n=window){const i=n.Object.getOwnPropertyDescriptor(e,t);return n.Object.defineProperty(e,t,s?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),i&&i.set&&i.set.call(this,a)}}),()=>Ys(e,t,i||{},!0)}function Mt(e,t,r){try{if(!(t in e))return()=>{};const s=e[t],n=r(s);return typeof n=="function"&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__rrweb_original__:{enumerable:!1,value:s}})),e[t]=n,()=>{e[t]=s}}catch{return()=>{}}}typeof window<"u"&&window.Proxy&&window.Reflect&&(La=new Proxy(La,{get:(e,t,r)=>(t==="map"&&console.error(Ct),Reflect.get(e,t,r))}));let bs=Date.now;function Bc(e){var t,r,s,n;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:i.documentElement.scrollLeft||(i==null?void 0:i.body)&&((t=V.parentElement(i.body))==null?void 0:t.scrollLeft)||((r=i==null?void 0:i.body)==null?void 0:r.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:(i==null?void 0:i.documentElement.scrollTop)||(i==null?void 0:i.body)&&((s=V.parentElement(i.body))==null?void 0:s.scrollTop)||((n=i==null?void 0:i.body)==null?void 0:n.scrollTop)||0}}function zc(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function jc(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Wc(e){return e?e.nodeType===e.ELEMENT_NODE?e:V.parentElement(e):null}function Se(e,t,r,s){if(!e)return!1;const n=Wc(e);if(!n)return!1;try{if(typeof t=="string"){if(n.classList.contains(t)||s&&n.closest("."+t)!==null)return!0}else if(ws(n,t,s))return!0}catch{}return!!(r&&(n.matches(r)||s&&n.closest(r)!==null))}function mn(e,t,r){return!(e.tagName!=="TITLE"||!r.headTitleMutations)||t.getId(e)===-2}function Vc(e,t){if(Xt(e))return!1;const r=t.getId(e);if(!t.has(r))return!0;const s=V.parentNode(e);return(!s||s.nodeType!==e.DOCUMENT_NODE)&&(!s||Vc(s,t))}function li(e){return!!e.changedTouches}function Hc(e,t){return!!(e.nodeName==="IFRAME"&&t.getMeta(e))}function Gc(e,t){return!!(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function ci(e){return!!e&&(e instanceof Qi&&"shadowRoot"in e?!!e.shadowRoot:!!V.shadowRoot(e))}/[1-9][0-9]{12}/.test(Date.now().toString())||(bs=()=>new Date().getTime());class wf{constructor(){x(this,"id",1),x(this,"styleIDMap",new WeakMap),x(this,"idStyleMap",new Map)}getId(t){return this.styleIDMap.get(t)??-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let s;return s=r===void 0?this.id++:r,this.styleIDMap.set(t,s),this.idStyleMap.set(s,t),s}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 $c(e){var t;let r=null;return"getRootNode"in e&&((t=V.getRootNode(e))==null?void 0:t.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&V.host(V.getRootNode(e))&&(r=V.host(V.getRootNode(e))),r}function bf(e){const t=e.ownerDocument;if(!t)return!1;const r=function(s){let n,i=s;for(;n=$c(i);)i=n;return i}(e);return V.contains(t,r)}function Yc(e){const t=e.ownerDocument;return!!t&&(V.contains(t,e)||bf(e))}var Y=(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))(Y||{}),G=(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[e.CustomElement=16]="CustomElement",e))(G||{}),Ce=(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))(Ce||{}),$e=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))($e||{}),kt=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(kt||{}),Et=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(Et||{});function Oa(e){return"__ln"in e}class vf{constructor(){x(this,"length",0),x(this,"head",null),x(this,"tail",null)}get(t){if(t>=this.length)throw new Error("Position outside of list range");let r=this.head;for(let s=0;s<t;s++)r=(r==null?void 0:r.next)||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&Oa(t.previousSibling)){const s=t.previousSibling.__ln.next;r.next=s,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,s&&(s.previous=r)}else if(t.nextSibling&&Oa(t.nextSibling)&&t.nextSibling.__ln.previous){const s=t.nextSibling.__ln.previous;r.previous=s,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,s&&(s.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){const r=t.__ln;this.head&&(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const Aa=(e,t)=>`${e}@${t}`;class Sf{constructor(){x(this,"frozen",!1),x(this,"locked",!1),x(this,"texts",[]),x(this,"attributes",[]),x(this,"attributeMap",new WeakMap),x(this,"removes",[]),x(this,"mapRemoves",[]),x(this,"movedMap",{}),x(this,"addedSet",new Set),x(this,"movedSet",new Set),x(this,"droppedSet",new Set),x(this,"mutationCb"),x(this,"blockClass"),x(this,"blockSelector"),x(this,"maskTextClass"),x(this,"maskTextSelector"),x(this,"inlineStylesheet"),x(this,"maskInputOptions"),x(this,"maskTextFn"),x(this,"maskInputFn"),x(this,"keepIframeSrcFn"),x(this,"recordCanvas"),x(this,"inlineImages"),x(this,"slimDOMOptions"),x(this,"dataURLOptions"),x(this,"doc"),x(this,"mirror"),x(this,"iframeManager"),x(this,"stylesheetManager"),x(this,"shadowDomManager"),x(this,"canvasManager"),x(this,"processedNodeManager"),x(this,"unattachedDoc"),x(this,"processMutations",t=>{t.forEach(this.processMutation),this.emit()}),x(this,"emit",()=>{if(this.frozen||this.locked)return;const t=[],r=new Set,s=new vf,n=l=>{let c=l,u=-2;for(;u===-2;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},i=l=>{const c=V.parentNode(l);if(!c||!Yc(l)||c.tagName==="TEXTAREA")return;const u=Xt(c)?this.mirror.getId($c(l)):this.mirror.getId(c),d=n(l);if(u===-1||d===-1)return s.addNode(l);const h=xt(l,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:f=>{Hc(f,this.mirror)&&this.iframeManager.addIframe(f),Gc(f,this.mirror)&&this.stylesheetManager.trackLinkElement(f),ci(l)&&this.shadowDomManager.addShadowRoot(V.shadowRoot(l),this.doc)},onIframeLoad:(f,w)=>{this.iframeManager.attachIframe(f,w),this.shadowDomManager.observeAttachShadow(f)},onStylesheetLoad:(f,w)=>{this.stylesheetManager.attachLinkElement(f,w)}});h&&(t.push({parentId:u,nextId:d,node:h}),r.add(h.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const l of this.movedSet)Ma(this.removes,l,this.mirror)&&!this.movedSet.has(V.parentNode(l))||i(l);for(const l of this.addedSet)Ua(this.droppedSet,l)||Ma(this.removes,l,this.mirror)?Ua(this.movedSet,l)?i(l):this.droppedSet.add(l):i(l);let a=null;for(;s.length;){let l=null;if(a){const c=this.mirror.getId(V.parentNode(a.value)),u=n(a.value);c!==-1&&u!==-1&&(l=a)}if(!l){let c=s.tail;for(;c;){const u=c;if(c=c.previous,u){const d=this.mirror.getId(V.parentNode(u.value));if(n(u.value)===-1)continue;if(d!==-1){l=u;break}{const h=u.value,f=V.parentNode(h);if(f&&f.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const w=V.host(f);if(this.mirror.getId(w)!==-1){l=u;break}}}}}}if(!l){for(;s.head;)s.removeNode(s.head.value);break}a=l.previous,s.removeNode(l.value),i(l.value)}const o={texts:this.texts.map(l=>{const c=l.node,u=V.parentNode(c);return u&&u.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(u),{id:this.mirror.getId(c),value:l.value}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),attributes:this.attributes.map(l=>{const{attributes:c}=l;if(typeof c.style=="string"){const u=JSON.stringify(l.styleDiff),d=JSON.stringify(l._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=l.styleDiff)}return{id:this.mirror.getId(l.node),attributes:c}}).filter(l=>!r.has(l.id)).filter(l=>this.mirror.has(l.id)),removes:this.removes,adds:t};(o.texts.length||o.attributes.length||o.removes.length||o.adds.length)&&(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(o))}),x(this,"genTextAreaValueMutation",t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r)),r.attributes.value=Array.from(V.childNodes(t),s=>V.textContent(s)||"").join("")}),x(this,"processMutation",t=>{if(!mn(t.target,this.mirror,this.slimDOMOptions))switch(t.type){case"characterData":{const r=V.textContent(t.target);Se(t.target,this.blockClass,this.blockSelector,!1)||r===t.oldValue||this.texts.push({value:Ul(t.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,Wc(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let s=t.attributeName,n=t.target.getAttribute(s);if(s==="value"){const a=Pi(r);n=Di({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:a,value:n,maskInputFn:this.maskInputFn})}if(Se(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let i=this.attributeMap.get(t.target);if(r.tagName==="IFRAME"&&s==="src"&&!this.keepIframeSrcFn(n)){if(r.contentDocument)return;s="rr_src"}if(i||(i={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(t.target,i)),s==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!Ml(r.tagName,s))if(i.attributes[s]=Al(this.doc,ft(r.tagName),ft(s),n),s==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const a=this.unattachedDoc.createElement("span");t.oldValue&&a.setAttribute("style",t.oldValue);for(const o of Array.from(r.style)){const l=r.style.getPropertyValue(o),c=r.style.getPropertyPriority(o);l!==a.style.getPropertyValue(o)||c!==a.style.getPropertyPriority(o)?i.styleDiff[o]=c===""?l:[l,c]:i._unchangedStyles[o]=[l,c]}for(const o of Array.from(a.style))r.style.getPropertyValue(o)===""&&(i.styleDiff[o]=!1)}else s==="open"&&r.tagName==="DIALOG"&&(r.matches("dialog:modal")?i.attributes.rr_open_mode="modal":i.attributes.rr_open_mode="non-modal");break}case"childList":if(Se(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA")return void this.genTextAreaValueMutation(t.target);t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const s=this.mirror.getId(r),n=Xt(t.target)?this.mirror.getId(V.host(t.target)):this.mirror.getId(t.target);Se(t.target,this.blockClass,this.blockSelector,!1)||mn(r,this.mirror,this.slimDOMOptions)||!function(i,a){return a.getId(i)!==-1}(r,this.mirror)||(this.addedSet.has(r)?(ui(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&s===-1||Vc(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[Aa(s,n)]?ui(this.movedSet,r):this.removes.push({parentId:n,id:s,isShadow:!(!Xt(t.target)||!Zt(t.target))||void 0})),this.mapRemoves.push(r))})}}),x(this,"genAdds",(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!this.addedSet.has(t)&&!this.movedSet.has(t)){if(this.mirror.hasNode(t)){if(mn(t,this.mirror,this.slimDOMOptions))return;this.movedSet.add(t);let s=null;r&&this.mirror.hasNode(r)&&(s=this.mirror.getId(r)),s&&s!==-1&&(this.movedMap[Aa(this.mirror.getId(t),s)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);Se(t,this.blockClass,this.blockSelector,!1)||(V.childNodes(t).forEach(s=>this.genAdds(s)),ci(t)&&V.childNodes(V.shadowRoot(t)).forEach(s=>{this.processedNodeManager.add(s,this),this.genAdds(s,t)}))}})}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(r=>{this[r]=t[r]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function ui(e,t){e.delete(t),V.childNodes(t).forEach(r=>ui(e,r))}function Ma(e,t,r){return e.length!==0&&function(s,n,i){let a=V.parentNode(n);for(;a;){const o=i.getId(a);if(s.some(l=>l.id===o))return!0;a=V.parentNode(a)}return!1}(e,t,r)}function Ua(e,t){return e.size!==0&&qc(e,t)}function qc(e,t){const r=V.parentNode(t);return!!r&&(!!e.has(r)||qc(e,r))}let Qt;const $=e=>Qt?(...t)=>{try{return e(...t)}catch(r){if(Qt&&Qt(r)===!0)return;throw r}}:e,mt=[];function er(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 Jc(e,t){const r=new Sf;mt.push(r),r.init(e);const s=new(Fc())($(r.processMutations.bind(r)));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function If({mouseInteractionCb:e,doc:t,mirror:r,blockClass:s,blockSelector:n,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const a=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,o=[];let l=null;return Object.keys(Ce).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&a[c]!==!1).forEach(c=>{let u=ft(c);const d=(h=>f=>{const w=er(f);if(Se(w,s,n,!0))return;let p=null,C=h;if("pointerType"in f){switch(f.pointerType){case"mouse":p=$e.Mouse;break;case"touch":p=$e.Touch;break;case"pen":p=$e.Pen}p===$e.Touch?Ce[h]===Ce.MouseDown?C="TouchStart":Ce[h]===Ce.MouseUp&&(C="TouchEnd"):$e.Pen}else li(f)&&(p=$e.Touch);p!==null?(l=p,(C.startsWith("Touch")&&p===$e.Touch||C.startsWith("Mouse")&&p===$e.Mouse)&&(p=null)):Ce[h]===Ce.Click&&(p=l,l=null);const m=li(f)?f.changedTouches[0]:f;if(!m)return;const g=r.getId(w),{clientX:v,clientY:I}=m;$(e)({type:Ce[C],id:g,x:v,y:I,...p!==null&&{pointerType:p}})})(c);if(window.PointerEvent)switch(Ce[c]){case Ce.MouseDown:case Ce.MouseUp:u=u.replace("mouse","pointer");break;case Ce.TouchStart:case Ce.TouchEnd:return}o.push(ve(u,d,t))}),$(()=>{o.forEach(c=>c())})}function Kc({scrollCb:e,doc:t,mirror:r,blockClass:s,blockSelector:n,sampling:i}){return ve("scroll",$($t($(a=>{const o=er(a);if(!o||Se(o,s,n,!0))return;const l=r.getId(o);if(o===t&&t.defaultView){const c=Bc(t.defaultView);e({id:l,x:c.left,y:c.top})}else e({id:l,x:o.scrollLeft,y:o.scrollTop})}),i.scroll||100)),t)}const Cf=["INPUT","TEXTAREA","SELECT"],Da=new WeakMap;function Wr(e){return function(t,r){if(Vr("CSSGroupingRule")&&t.parentRule instanceof CSSGroupingRule||Vr("CSSMediaRule")&&t.parentRule instanceof CSSMediaRule||Vr("CSSSupportsRule")&&t.parentRule instanceof CSSSupportsRule||Vr("CSSConditionRule")&&t.parentRule instanceof CSSConditionRule){const s=Array.from(t.parentRule.cssRules).indexOf(t);r.unshift(s)}else if(t.parentStyleSheet){const s=Array.from(t.parentStyleSheet.cssRules).indexOf(t);r.unshift(s)}return r}(e,[])}function st(e,t,r){let s,n;return e?(e.ownerNode?s=t.getId(e.ownerNode):n=r.getId(e),{styleId:n,id:s}):{}}function Xc({mirror:e,stylesheetManager:t},r){var s,n,i;let a=null;a=r.nodeName==="#document"?e.getId(r):e.getId(V.host(r));const o=r.nodeName==="#document"?(s=r.defaultView)==null?void 0:s.Document:(i=(n=r.ownerDocument)==null?void 0:n.defaultView)==null?void 0:i.ShadowRoot,l=o!=null&&o.prototype?Object.getOwnPropertyDescriptor(o==null?void 0:o.prototype,"adoptedStyleSheets"):void 0;return a!==null&&a!==-1&&o&&l?(Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var c;return(c=l.get)==null?void 0:c.call(this)},set(c){var u;const d=(u=l.set)==null?void 0:u.call(this,c);if(a!==null&&a!==-1)try{t.adoptStyleSheets(c,a)}catch{}return d}}),$(()=>{Object.defineProperty(r,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function kf(e,t={}){const r=e.doc.defaultView;if(!r)return()=>{};let s;(function(m,g){const{mutationCb:v,mousemoveCb:I,mouseInteractionCb:O,scrollCb:E,viewportResizeCb:A,inputCb:M,mediaInteractionCb:k,styleSheetRuleCb:T,styleDeclarationCb:R,canvasMutationCb:S,fontCb:P,selectionCb:D,customElementCb:b}=m;m.mutationCb=(...y)=>{g.mutation&&g.mutation(...y),v(...y)},m.mousemoveCb=(...y)=>{g.mousemove&&g.mousemove(...y),I(...y)},m.mouseInteractionCb=(...y)=>{g.mouseInteraction&&g.mouseInteraction(...y),O(...y)},m.scrollCb=(...y)=>{g.scroll&&g.scroll(...y),E(...y)},m.viewportResizeCb=(...y)=>{g.viewportResize&&g.viewportResize(...y),A(...y)},m.inputCb=(...y)=>{g.input&&g.input(...y),M(...y)},m.mediaInteractionCb=(...y)=>{g.mediaInteaction&&g.mediaInteaction(...y),k(...y)},m.styleSheetRuleCb=(...y)=>{g.styleSheetRule&&g.styleSheetRule(...y),T(...y)},m.styleDeclarationCb=(...y)=>{g.styleDeclaration&&g.styleDeclaration(...y),R(...y)},m.canvasMutationCb=(...y)=>{g.canvasMutation&&g.canvasMutation(...y),S(...y)},m.fontCb=(...y)=>{g.font&&g.font(...y),P(...y)},m.selectionCb=(...y)=>{g.selection&&g.selection(...y),D(...y)},m.customElementCb=(...y)=>{g.customElement&&g.customElement(...y),b(...y)}})(e,t),e.recordDOM&&(s=Jc(e,e.doc));const n=function({mousemoveCb:m,sampling:g,doc:v,mirror:I}){if(g.mousemove===!1)return()=>{};const O=typeof g.mousemove=="number"?g.mousemove:50,E=typeof g.mousemoveCallback=="number"?g.mousemoveCallback:500;let A,M=[];const k=$t($(S=>{const P=Date.now()-A;m(M.map(D=>(D.timeOffset-=P,D)),S),M=[],A=null}),E),T=$($t($(S=>{const P=er(S),{clientX:D,clientY:b}=li(S)?S.changedTouches[0]:S;A||(A=bs()),M.push({x:D,y:b,id:I.getId(P),timeOffset:bs()-A}),k(typeof DragEvent<"u"&&S instanceof DragEvent?G.Drag:S instanceof MouseEvent?G.MouseMove:G.TouchMove)}),O,{trailing:!1})),R=[ve("mousemove",T,v),ve("touchmove",T,v),ve("drag",T,v)];return $(()=>{R.forEach(S=>S())})}(e),i=If(e),a=Kc(e),o=function({viewportResizeCb:m},{win:g}){let v=-1,I=-1;return ve("resize",$($t($(()=>{const O=zc(),E=jc();v===O&&I===E||(m({width:Number(E),height:Number(O)}),v=O,I=E)}),200)),g)}(e,{win:r}),l=function({inputCb:m,doc:g,mirror:v,blockClass:I,blockSelector:O,ignoreClass:E,ignoreSelector:A,maskInputOptions:M,maskInputFn:k,sampling:T,userTriggeredOnInput:R}){function S(F){let j=er(F);const L=F.isTrusted,N=j&&j.tagName;if(j&&N==="OPTION"&&(j=V.parentElement(j)),!j||!N||Cf.indexOf(N)<0||Se(j,I,O,!0)||j.classList.contains(E)||A&&j.matches(A))return;let ee=j.value,q=!1;const me=Pi(j)||"";me==="radio"||me==="checkbox"?q=j.checked:(M[N.toLowerCase()]||M[me])&&(ee=Di({element:j,maskInputOptions:M,tagName:N,type:me,value:ee,maskInputFn:k})),P(j,R?{text:ee,isChecked:q,userTriggered:L}:{text:ee,isChecked:q});const Ne=j.name;me==="radio"&&Ne&&q&&g.querySelectorAll(`input[type="radio"][name="${Ne}"]`).forEach(we=>{if(we!==j){const H=we.value;P(we,R?{text:H,isChecked:!q,userTriggered:!1}:{text:H,isChecked:!q})}})}function P(F,j){const L=Da.get(F);if(!L||L.text!==j.text||L.isChecked!==j.isChecked){Da.set(F,j);const N=v.getId(F);$(m)({...j,id:N})}}const D=(T.input==="last"?["change"]:["input","change"]).map(F=>ve(F,$(S),g)),b=g.defaultView;if(!b)return()=>{D.forEach(F=>F())};const y=b.Object.getOwnPropertyDescriptor(b.HTMLInputElement.prototype,"value"),U=[[b.HTMLInputElement.prototype,"value"],[b.HTMLInputElement.prototype,"checked"],[b.HTMLSelectElement.prototype,"value"],[b.HTMLTextAreaElement.prototype,"value"],[b.HTMLSelectElement.prototype,"selectedIndex"],[b.HTMLOptionElement.prototype,"selected"]];return y&&y.set&&D.push(...U.map(F=>Ys(F[0],F[1],{set(){$(S)({target:this,isTrusted:!1})}},!1,b))),$(()=>{D.forEach(F=>F())})}(e),c=function({mediaInteractionCb:m,blockClass:g,blockSelector:v,mirror:I,sampling:O,doc:E}){const A=$(k=>$t($(T=>{const R=er(T);if(!R||Se(R,g,v,!0))return;const{currentTime:S,volume:P,muted:D,playbackRate:b,loop:y}=R;m({type:k,id:I.getId(R),currentTime:S,volume:P,muted:D,playbackRate:b,loop:y})}),O.media||500)),M=[ve("play",A(Et.Play),E),ve("pause",A(Et.Pause),E),ve("seeked",A(Et.Seeked),E),ve("volumechange",A(Et.VolumeChange),E),ve("ratechange",A(Et.RateChange),E)];return $(()=>{M.forEach(k=>k())})}(e);let u=()=>{},d=()=>{},h=()=>{},f=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:m,mirror:g,stylesheetManager:v},{win:I}){if(!I.CSSStyleSheet||!I.CSSStyleSheet.prototype)return()=>{};const O=I.CSSStyleSheet.prototype.insertRule;I.CSSStyleSheet.prototype.insertRule=new Proxy(O,{apply:$((R,S,P)=>{const[D,b]=P,{id:y,styleId:U}=st(S,g,v.styleMirror);return(y&&y!==-1||U&&U!==-1)&&m({id:y,styleId:U,adds:[{rule:D,index:b}]}),R.apply(S,P)})}),I.CSSStyleSheet.prototype.addRule=function(R,S,P=this.cssRules.length){const D=`${R} { ${S} }`;return I.CSSStyleSheet.prototype.insertRule.apply(this,[D,P])};const E=I.CSSStyleSheet.prototype.deleteRule;let A,M;I.CSSStyleSheet.prototype.deleteRule=new Proxy(E,{apply:$((R,S,P)=>{const[D]=P,{id:b,styleId:y}=st(S,g,v.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,removes:[{index:D}]}),R.apply(S,P)})}),I.CSSStyleSheet.prototype.removeRule=function(R){return I.CSSStyleSheet.prototype.deleteRule.apply(this,[R])},I.CSSStyleSheet.prototype.replace&&(A=I.CSSStyleSheet.prototype.replace,I.CSSStyleSheet.prototype.replace=new Proxy(A,{apply:$((R,S,P)=>{const[D]=P,{id:b,styleId:y}=st(S,g,v.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,replace:D}),R.apply(S,P)})})),I.CSSStyleSheet.prototype.replaceSync&&(M=I.CSSStyleSheet.prototype.replaceSync,I.CSSStyleSheet.prototype.replaceSync=new Proxy(M,{apply:$((R,S,P)=>{const[D]=P,{id:b,styleId:y}=st(S,g,v.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,replaceSync:D}),R.apply(S,P)})}));const k={};Hr("CSSGroupingRule")?k.CSSGroupingRule=I.CSSGroupingRule:(Hr("CSSMediaRule")&&(k.CSSMediaRule=I.CSSMediaRule),Hr("CSSConditionRule")&&(k.CSSConditionRule=I.CSSConditionRule),Hr("CSSSupportsRule")&&(k.CSSSupportsRule=I.CSSSupportsRule));const T={};return Object.entries(k).forEach(([R,S])=>{T[R]={insertRule:S.prototype.insertRule,deleteRule:S.prototype.deleteRule},S.prototype.insertRule=new Proxy(T[R].insertRule,{apply:$((P,D,b)=>{const[y,U]=b,{id:F,styleId:j}=st(D.parentStyleSheet,g,v.styleMirror);return(F&&F!==-1||j&&j!==-1)&&m({id:F,styleId:j,adds:[{rule:y,index:[...Wr(D),U||0]}]}),P.apply(D,b)})}),S.prototype.deleteRule=new Proxy(T[R].deleteRule,{apply:$((P,D,b)=>{const[y]=b,{id:U,styleId:F}=st(D.parentStyleSheet,g,v.styleMirror);return(U&&U!==-1||F&&F!==-1)&&m({id:U,styleId:F,removes:[{index:[...Wr(D),y]}]}),P.apply(D,b)})})}),$(()=>{I.CSSStyleSheet.prototype.insertRule=O,I.CSSStyleSheet.prototype.deleteRule=E,A&&(I.CSSStyleSheet.prototype.replace=A),M&&(I.CSSStyleSheet.prototype.replaceSync=M),Object.entries(k).forEach(([R,S])=>{S.prototype.insertRule=T[R].insertRule,S.prototype.deleteRule=T[R].deleteRule})})}(e,{win:r}),d=Xc(e,e.doc),h=function({styleDeclarationCb:m,mirror:g,ignoreCSSAttributes:v,stylesheetManager:I},{win:O}){const E=O.CSSStyleDeclaration.prototype.setProperty;O.CSSStyleDeclaration.prototype.setProperty=new Proxy(E,{apply:$((M,k,T)=>{var R;const[S,P,D]=T;if(v.has(S))return E.apply(k,[S,P,D]);const{id:b,styleId:y}=st((R=k.parentRule)==null?void 0:R.parentStyleSheet,g,I.styleMirror);return(b&&b!==-1||y&&y!==-1)&&m({id:b,styleId:y,set:{property:S,value:P,priority:D},index:Wr(k.parentRule)}),M.apply(k,T)})});const A=O.CSSStyleDeclaration.prototype.removeProperty;return O.CSSStyleDeclaration.prototype.removeProperty=new Proxy(A,{apply:$((M,k,T)=>{var R;const[S]=T;if(v.has(S))return A.apply(k,[S]);const{id:P,styleId:D}=st((R=k.parentRule)==null?void 0:R.parentStyleSheet,g,I.styleMirror);return(P&&P!==-1||D&&D!==-1)&&m({id:P,styleId:D,remove:{property:S},index:Wr(k.parentRule)}),M.apply(k,T)})}),$(()=>{O.CSSStyleDeclaration.prototype.setProperty=E,O.CSSStyleDeclaration.prototype.removeProperty=A})}(e,{win:r}),e.collectFonts&&(f=function({fontCb:m,doc:g}){const v=g.defaultView;if(!v)return()=>{};const I=[],O=new WeakMap,E=v.FontFace;v.FontFace=function(M,k,T){const R=new E(M,k,T);return O.set(R,{family:M,buffer:typeof k!="string",descriptors:T,fontSource:typeof k=="string"?k:JSON.stringify(Array.from(new Uint8Array(k)))}),R};const A=Mt(g.fonts,"add",function(M){return function(k){return setTimeout($(()=>{const T=O.get(k);T&&(m(T),O.delete(k))}),0),M.apply(this,[k])}});return I.push(()=>{v.FontFace=E}),I.push(A),$(()=>{I.forEach(M=>M())})}(e)));const w=function(m){const{doc:g,mirror:v,blockClass:I,blockSelector:O,selectionCb:E}=m;let A=!0;const M=$(()=>{const k=g.getSelection();if(!k||A&&(k!=null&&k.isCollapsed))return;A=k.isCollapsed||!1;const T=[],R=k.rangeCount||0;for(let S=0;S<R;S++){const P=k.getRangeAt(S),{startContainer:D,startOffset:b,endContainer:y,endOffset:U}=P;Se(D,I,O,!0)||Se(y,I,O,!0)||T.push({start:v.getId(D),startOffset:b,end:v.getId(y),endOffset:U})}E({ranges:T})});return M(),ve("selectionchange",M)}(e),p=function({doc:m,customElementCb:g}){const v=m.defaultView;return v&&v.customElements?Mt(v.customElements,"define",function(I){return function(O,E,A){try{g({define:{name:O}})}catch{console.warn(`Custom element callback failed for ${O}`)}return I.apply(this,[O,E,A])}}):()=>{}}(e),C=[];for(const m of e.plugins)C.push(m.observer(m.callback,r,m.options));return $(()=>{mt.forEach(m=>m.reset()),s==null||s.disconnect(),n(),i(),a(),o(),l(),c(),u(),d(),h(),f(),w(),p(),C.forEach(m=>m())})}function Vr(e){return window[e]!==void 0}function Hr(e){return!!(window[e]!==void 0&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class Pa{constructor(t){x(this,"iframeIdToRemoteIdMap",new WeakMap),x(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=t}getId(t,r,s,n){const i=s||this.getIdToRemoteIdMap(t),a=n||this.getRemoteIdToIdMap(t);let o=i.get(r);return o||(o=this.generateIdFn(),i.set(r,o),a.set(o,r)),o}getIds(t,r){const s=this.getIdToRemoteIdMap(t),n=this.getRemoteIdToIdMap(t);return r.map(i=>this.getId(t,i,s,n))}getRemoteId(t,r,s){const n=s||this.getRemoteIdToIdMap(t);return typeof r!="number"?r:n.get(r)||-1}getRemoteIds(t,r){const s=this.getRemoteIdToIdMap(t);return r.map(n=>this.getRemoteId(t,n,s))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let r=this.iframeIdToRemoteIdMap.get(t);return r||(r=new Map,this.iframeIdToRemoteIdMap.set(t,r)),r}getRemoteIdToIdMap(t){let r=this.iframeRemoteIdToIdMap.get(t);return r||(r=new Map,this.iframeRemoteIdToIdMap.set(t,r)),r}}class Ef{constructor(t){x(this,"iframes",new WeakMap),x(this,"crossOriginIframeMap",new WeakMap),x(this,"crossOriginIframeMirror",new Pa(Ol)),x(this,"crossOriginIframeStyleMirror"),x(this,"crossOriginIframeRootIdMap",new WeakMap),x(this,"mirror"),x(this,"mutationCb"),x(this,"wrappedEmit"),x(this,"loadListener"),x(this,"stylesheetManager"),x(this,"recordCrossOriginIframes"),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Pa(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,r){var s,n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:r}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes&&((s=t.contentWindow)==null||s.addEventListener("message",this.handleMessage.bind(this))),(n=this.loadListener)==null||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){const r=t;if(r.data.type!=="rrweb"||r.origin!==r.data.origin||!t.source)return;const s=this.crossOriginIframeMap.get(t.source);if(!s)return;const n=this.transformCrossOriginEvent(s,r.data.event);n&&this.wrappedEmit(n,r.data.isCheckout)}transformCrossOriginEvent(t,r){var s;switch(r.type){case Y.FullSnapshot:{this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(r.data.node,t);const n=r.data.node.id;return this.crossOriginIframeRootIdMap.set(t,n),this.patchRootIdOnNode(r.data.node,n),{timestamp:r.timestamp,type:Y.IncrementalSnapshot,data:{source:G.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:r.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case Y.Meta:case Y.Load:case Y.DomContentLoaded:return!1;case Y.Plugin:return r;case Y.Custom:return this.replaceIds(r.data.payload,t,["id","parentId","previousId","nextId"]),r;case Y.IncrementalSnapshot:switch(r.data.source){case G.Mutation:return r.data.adds.forEach(n=>{this.replaceIds(n,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(n.node,t);const i=this.crossOriginIframeRootIdMap.get(t);i&&this.patchRootIdOnNode(n.node,i)}),r.data.removes.forEach(n=>{this.replaceIds(n,t,["parentId","id"])}),r.data.attributes.forEach(n=>{this.replaceIds(n,t,["id"])}),r.data.texts.forEach(n=>{this.replaceIds(n,t,["id"])}),r;case G.Drag:case G.TouchMove:case G.MouseMove:return r.data.positions.forEach(n=>{this.replaceIds(n,t,["id"])}),r;case G.ViewportResize:return!1;case G.MediaInteraction:case G.MouseInteraction:case G.Scroll:case G.CanvasMutation:case G.Input:return this.replaceIds(r.data,t,["id"]),r;case G.StyleSheetRule:case G.StyleDeclaration:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleId"]),r;case G.Font:return r;case G.Selection:return r.data.ranges.forEach(n=>{this.replaceIds(n,t,["start","end"])}),r;case G.AdoptedStyleSheet:return this.replaceIds(r.data,t,["id"]),this.replaceStyleIds(r.data,t,["styleIds"]),(s=r.data.styles)==null||s.forEach(n=>{this.replaceStyleIds(n,t,["styleId"])}),r}}return!1}replace(t,r,s,n){for(const i of n)(Array.isArray(r[i])||typeof r[i]=="number")&&(Array.isArray(r[i])?r[i]=t.getIds(s,r[i]):r[i]=t.getId(s,r[i]));return r}replaceIds(t,r,s){return this.replace(this.crossOriginIframeMirror,t,r,s)}replaceStyleIds(t,r,s){return this.replace(this.crossOriginIframeStyleMirror,t,r,s)}replaceIdOnNode(t,r){this.replaceIds(t,r,["id","rootId"]),"childNodes"in t&&t.childNodes.forEach(s=>{this.replaceIdOnNode(s,r)})}patchRootIdOnNode(t,r){t.type===fe.Document||t.rootId||(t.rootId=r),"childNodes"in t&&t.childNodes.forEach(s=>{this.patchRootIdOnNode(s,r)})}}class xf{constructor(t){x(this,"shadowDoms",new WeakSet),x(this,"mutationCb"),x(this,"scrollCb"),x(this,"bypassOptions"),x(this,"mirror"),x(this,"restoreHandlers",[]),this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(t,r){if(!Zt(t)||this.shadowDoms.has(t))return;this.shadowDoms.add(t);const s=Jc({...this.bypassOptions,doc:r,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},t);this.restoreHandlers.push(()=>s.disconnect()),this.restoreHandlers.push(Kc({...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(V.host(t))),this.restoreHandlers.push(Xc({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t))},0)}observeAttachShadow(t){t.contentWindow&&t.contentDocument&&this.patchAttachShadow(t.contentWindow.Element,t.contentDocument)}patchAttachShadow(t,r){const s=this;this.restoreHandlers.push(Mt(t.prototype,"attachShadow",function(n){return function(i){const a=n.call(this,i),o=V.shadowRoot(this);return o&&Yc(this)&&s.addShadowRoot(o,r),a}}))}reset(){this.restoreHandlers.forEach(t=>{try{t()}catch{}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}for(var Yt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Tf=typeof Uint8Array>"u"?[]:new Uint8Array(256),Gr=0;Gr<64;Gr++)Tf[Yt.charCodeAt(Gr)]=Gr;const _a=new Map,Zc=(e,t,r)=>{if(!e||!eu(e,t)&&typeof e!="object")return;const s=function(i,a){let o=_a.get(i);return o||(o=new Map,_a.set(i,o)),o.has(a)||o.set(a,[]),o.get(a)}(r,e.constructor.name);let n=s.indexOf(e);return n===-1&&(n=s.length,s.push(e)),n};function ls(e,t,r){if(e instanceof Array)return e.map(s=>ls(s,t,r));if(e===null)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray)return{rr_type:e.constructor.name,args:[Object.values(e)]};if(e instanceof ArrayBuffer)return{rr_type:e.constructor.name,base64:function(s){var n,i=new Uint8Array(s),a=i.length,o="";for(n=0;n<a;n+=3)o+=Yt[i[n]>>2],o+=Yt[(3&i[n])<<4|i[n+1]>>4],o+=Yt[(15&i[n+1])<<2|i[n+2]>>6],o+=Yt[63&i[n+2]];return a%3==2?o=o.substring(0,o.length-1)+"=":a%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e)};if(e instanceof DataView)return{rr_type:e.constructor.name,args:[ls(e.buffer,t,r),e.byteOffset,e.byteLength]};if(e instanceof HTMLImageElement){const s=e.constructor.name,{src:n}=e;return{rr_type:s,src:n}}return e instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:e.toDataURL()}:e instanceof ImageData?{rr_type:e.constructor.name,args:[ls(e.data,t,r),e.width,e.height]}:eu(e,t)||typeof e=="object"?{rr_type:e.constructor.name,index:Zc(e,t,r)}:e}const Qc=(e,t,r)=>e.map(s=>ls(s,t,r)),eu=(e,t)=>!!["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(s=>typeof t[s]=="function").find(s=>e instanceof t[s]);function Na(e,t,r,s){const n=[];try{const i=Mt(e.HTMLCanvasElement.prototype,"getContext",function(a){return function(o,...l){if(!Se(this,t,r,!0)){const c=function(u){return u==="experimental-webgl"?"webgl":u}(o);if("__context"in this||(this.__context=c),s&&["webgl","webgl2"].includes(c))if(l[0]&&typeof l[0]=="object"){const u=l[0];u.preserveDrawingBuffer||(u.preserveDrawingBuffer=!0)}else l.splice(0,1,{preserveDrawingBuffer:!0})}return a.apply(this,[o,...l])}});n.push(i)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{n.forEach(i=>i())}}function Fa(e,t,r,s,n,i){const a=[],o=Object.getOwnPropertyNames(e);for(const l of o)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(l))try{if(typeof e[l]!="function")continue;const c=Mt(e,l,function(u){return function(...d){const h=u.apply(this,d);if(Zc(h,i,this),"tagName"in this.canvas&&!Se(this.canvas,s,n,!0)){const f=Qc(d,i,this),w={type:t,property:l,args:f};r(this.canvas,w)}return h}});a.push(c)}catch{const c=Ys(e,l,{set(u){r(this.canvas,{type:t,property:l,args:[u],setter:!0})}});a.push(c)}return a}const tu="KGZ1bmN0aW9uKCkgewogICJ1c2Ugc3RyaWN0IjsKICB2YXIgY2hhcnMgPSAiQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyI7CiAgdmFyIGxvb2t1cCA9IHR5cGVvZiBVaW50OEFycmF5ID09PSAidW5kZWZpbmVkIiA/IFtdIDogbmV3IFVpbnQ4QXJyYXkoMjU2KTsKICBmb3IgKHZhciBpID0gMDsgaSA8IGNoYXJzLmxlbmd0aDsgaSsrKSB7CiAgICBsb29rdXBbY2hhcnMuY2hhckNvZGVBdChpKV0gPSBpOwogIH0KICB2YXIgZW5jb2RlID0gZnVuY3Rpb24oYXJyYXlidWZmZXIpIHsKICAgIHZhciBieXRlcyA9IG5ldyBVaW50OEFycmF5KGFycmF5YnVmZmVyKSwgaTIsIGxlbiA9IGJ5dGVzLmxlbmd0aCwgYmFzZTY0ID0gIiI7CiAgICBmb3IgKGkyID0gMDsgaTIgPCBsZW47IGkyICs9IDMpIHsKICAgICAgYmFzZTY0ICs9IGNoYXJzW2J5dGVzW2kyXSA+PiAyXTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMl0gJiAzKSA8PCA0IHwgYnl0ZXNbaTIgKyAxXSA+PiA0XTsKICAgICAgYmFzZTY0ICs9IGNoYXJzWyhieXRlc1tpMiArIDFdICYgMTUpIDw8IDIgfCBieXRlc1tpMiArIDJdID4+IDZdOwogICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaTIgKyAyXSAmIDYzXTsKICAgIH0KICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgIj0iOwogICAgfSBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgIj09IjsKICAgIH0KICAgIHJldHVybiBiYXNlNjQ7CiAgfTsKICBjb25zdCBsYXN0QmxvYk1hcCA9IC8qIEBfX1BVUkVfXyAqLyBuZXcgTWFwKCk7CiAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gLyogQF9fUFVSRV9fICovIG5ldyBNYXAoKTsKICBhc3luYyBmdW5jdGlvbiBnZXRUcmFuc3BhcmVudEJsb2JGb3Iod2lkdGgsIGhlaWdodCwgZGF0YVVSTE9wdGlvbnMpIHsKICAgIGNvbnN0IGlkID0gYCR7d2lkdGh9LSR7aGVpZ2h0fWA7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBpZiAodHJhbnNwYXJlbnRCbG9iTWFwLmhhcyhpZCkpIHJldHVybiB0cmFuc3BhcmVudEJsb2JNYXAuZ2V0KGlkKTsKICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsKICAgICAgb2Zmc2NyZWVuLmdldENvbnRleHQoIjJkIik7CiAgICAgIGNvbnN0IGJsb2IgPSBhd2FpdCBvZmZzY3JlZW4uY29udmVydFRvQmxvYihkYXRhVVJMT3B0aW9ucyk7CiAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0gYXdhaXQgYmxvYi5hcnJheUJ1ZmZlcigpOwogICAgICBjb25zdCBiYXNlNjQgPSBlbmNvZGUoYXJyYXlCdWZmZXIpOwogICAgICB0cmFuc3BhcmVudEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICByZXR1cm4gYmFzZTY0OwogICAgfSBlbHNlIHsKICAgICAgcmV0dXJuICIiOwogICAgfQogIH0KICBjb25zdCB3b3JrZXIgPSBzZWxmOwogIHdvcmtlci5vbm1lc3NhZ2UgPSBhc3luYyBmdW5jdGlvbihlKSB7CiAgICBpZiAoIk9mZnNjcmVlbkNhbnZhcyIgaW4gZ2xvYmFsVGhpcykgewogICAgICBjb25zdCB7IGlkLCBiaXRtYXAsIHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zIH0gPSBlLmRhdGE7CiAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKAogICAgICAgIHdpZHRoLAogICAgICAgIGhlaWdodCwKICAgICAgICBkYXRhVVJMT3B0aW9ucwogICAgICApOwogICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOwogICAgICBjb25zdCBjdHggPSBvZmZzY3JlZW4uZ2V0Q29udGV4dCgiMmQiKTsKICAgICAgY3R4LmRyYXdJbWFnZShiaXRtYXAsIDAsIDApOwogICAgICBiaXRtYXAuY2xvc2UoKTsKICAgICAgY29uc3QgYmxvYiA9IGF3YWl0IG9mZnNjcmVlbi5jb252ZXJ0VG9CbG9iKGRhdGFVUkxPcHRpb25zKTsKICAgICAgY29uc3QgdHlwZSA9IGJsb2IudHlwZTsKICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSBhd2FpdCBibG9iLmFycmF5QnVmZmVyKCk7CiAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7CiAgICAgIGlmICghbGFzdEJsb2JNYXAuaGFzKGlkKSAmJiBhd2FpdCB0cmFuc3BhcmVudEJhc2U2NCA9PT0gYmFzZTY0KSB7CiAgICAgICAgbGFzdEJsb2JNYXAuc2V0KGlkLCBiYXNlNjQpOwogICAgICAgIHJldHVybiB3b3JrZXIucG9zdE1lc3NhZ2UoeyBpZCB9KTsKICAgICAgfQogICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KSByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7CiAgICAgIHdvcmtlci5wb3N0TWVzc2FnZSh7CiAgICAgICAgaWQsCiAgICAgICAgdHlwZSwKICAgICAgICBiYXNlNjQsCiAgICAgICAgd2lkdGgsCiAgICAgICAgaGVpZ2h0CiAgICAgIH0pOwogICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7CiAgICB9IGVsc2UgewogICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsKICAgIH0KICB9Owp9KSgpOwovLyMgc291cmNlTWFwcGluZ1VSTD1pbWFnZS1iaXRtYXAtZGF0YS11cmwtd29ya2VyLUlKcEM3Z19iLmpzLm1hcAo=",Ba=typeof window<"u"&&window.Blob&&new Blob([(za=tu,Uint8Array.from(atob(za),e=>e.charCodeAt(0)))],{type:"text/javascript;charset=utf-8"});var za;function Rf(e){let t;try{if(t=Ba&&(window.URL||window.webkitURL).createObjectURL(Ba),!t)throw"";const r=new Worker(t,{name:e==null?void 0:e.name});return r.addEventListener("error",()=>{(window.URL||window.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;base64,"+tu,{name:e==null?void 0:e.name})}finally{t&&(window.URL||window.webkitURL).revokeObjectURL(t)}}class Lf{constructor(t){x(this,"pendingCanvasMutations",new Map),x(this,"rafStamps",{latestId:0,invokeId:null}),x(this,"mirror"),x(this,"mutationCb"),x(this,"resetObservers"),x(this,"frozen",!1),x(this,"locked",!1),x(this,"processMutation",(l,c)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(l)||this.pendingCanvasMutations.set(l,[]),this.pendingCanvasMutations.get(l).push(c)});const{sampling:r="all",win:s,blockClass:n,blockSelector:i,recordCanvas:a,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,a&&r==="all"&&this.initCanvasMutationObserver(s,n,i),a&&typeof r=="number"&&this.initCanvasFPSObserver(r,s,n,i,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,r,s,n,i){const a=Na(r,s,n,!0),o=new Map,l=new Rf;l.onmessage=f=>{const{id:w}=f.data;if(o.set(w,!1),!("base64"in f.data))return;const{base64:p,type:C,width:m,height:g}=f.data;this.mutationCb({id:w,type:kt["2D"],commands:[{property:"clearRect",args:[0,0,m,g]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:p}],type:C}]},0,0]}]})};const c=1e3/t;let u,d=0;const h=f=>{d&&f-d<c||(d=f,(()=>{const w=[];return r.document.querySelectorAll("canvas").forEach(p=>{Se(p,s,n,!0)||w.push(p)}),w})().forEach(async w=>{var p;const C=this.mirror.getId(w);if(o.get(C)||w.width===0||w.height===0)return;if(o.set(C,!0),["webgl","webgl2"].includes(w.__context)){const g=w.getContext(w.__context);((p=g==null?void 0:g.getContextAttributes())==null?void 0:p.preserveDrawingBuffer)===!1&&g.clear(g.COLOR_BUFFER_BIT)}const m=await createImageBitmap(w);l.postMessage({id:C,bitmap:m,width:w.width,height:w.height,dataURLOptions:i.dataURLOptions},[m])})),u=requestAnimationFrame(h)};u=requestAnimationFrame(h),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(t,r,s){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const n=Na(t,r,s,!1),i=function(o,l,c,u){const d=[],h=Object.getOwnPropertyNames(l.CanvasRenderingContext2D.prototype);for(const f of h)try{if(typeof l.CanvasRenderingContext2D.prototype[f]!="function")continue;const w=Mt(l.CanvasRenderingContext2D.prototype,f,function(p){return function(...C){return Se(this.canvas,c,u,!0)||setTimeout(()=>{const m=Qc(C,l,this);o(this.canvas,{type:kt["2D"],property:f,args:m})},0),p.apply(this,C)}});d.push(w)}catch{const w=Ys(l.CanvasRenderingContext2D.prototype,f,{set(p){o(this.canvas,{type:kt["2D"],property:f,args:[p],setter:!0})}});d.push(w)}return()=>{d.forEach(f=>f())}}(this.processMutation.bind(this),t,r,s),a=function(o,l,c,u){const d=[];return d.push(...Fa(l.WebGLRenderingContext.prototype,kt.WebGL,o,c,u,l)),l.WebGL2RenderingContext!==void 0&&d.push(...Fa(l.WebGL2RenderingContext.prototype,kt.WebGL2,o,c,u,l)),()=>{d.forEach(h=>h())}}(this.processMutation.bind(this),t,r,s);this.resetObservers=()=>{n(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const s=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,s)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const s=this.pendingCanvasMutations.get(t);if(!s||r===-1)return;const n=s.map(a=>{const{type:o,...l}=a;return l}),{type:i}=s[0];this.mutationCb({id:r,type:i,commands:n}),this.pendingCanvasMutations.delete(t)}}class Of{constructor(t){x(this,"trackedLinkElements",new WeakSet),x(this,"mutationCb"),x(this,"adoptedStyleSheetCb"),x(this,"styleMirror",new wf),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const s={id:r,styleIds:[]},n=[];for(const i of t){let a;this.styleMirror.has(i)?a=this.styleMirror.getId(i):(a=this.styleMirror.add(i),n.push({styleId:a,rules:Array.from(i.rules||CSSRule,(o,l)=>({rule:Rl(o,i.href),index:l}))})),s.styleIds.push(a)}n.length>0&&(s.styles=n),this.adoptedStyleSheetCb(s)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Af{constructor(){x(this,"nodeMap",new WeakMap),x(this,"active",!1)}inOtherBuffer(t,r){const s=this.nodeMap.get(t);return s&&Array.from(s).some(n=>n!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}}let ue,cs,fn,vs=!1;try{if(Array.from([1],e=>2*e)[0]!==2){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=((Eo=e.contentWindow)==null?void 0:Eo.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}const Oe=new Ll;function qt(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:s,blockClass:n="rr-block",blockSelector:i=null,ignoreClass:a="rr-ignore",ignoreSelector:o=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:f,maskInputFn:w,maskTextFn:p,hooks:C,packFn:m,sampling:g={},dataURLOptions:v={},mousemoveWait:I,recordDOM:O=!0,recordCanvas:E=!1,recordCrossOriginIframes:A=!1,recordAfter:M=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:k=!1,collectFonts:T=!1,inlineImages:R=!1,plugins:S,keepIframeSrcFn:P=()=>!1,ignoreCSSAttributes:D=new Set([]),errorHandler:b}=e;Qt=b;const y=!A||window.parent===window;let U=!1;if(!y)try{window.parent.document&&(U=!1)}catch{U=!0}if(y&&!t)throw new Error("emit function is required");if(!y&&!U)return()=>{};I!==void 0&&g.mousemove===void 0&&(g.mousemove=I),Oe.reset();const F=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},j=f===!0||f==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:f==="all",headMetaDescKeywords:f==="all",headTitleMutations:f==="all"}:f||{};let L;(function(W=window){"NodeList"in W&&!W.NodeList.prototype.forEach&&(W.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in W&&!W.DOMTokenList.prototype.forEach&&(W.DOMTokenList.prototype.forEach=Array.prototype.forEach)})();let N=0;const ee=W=>{for(const Ie of S||[])Ie.eventProcessor&&(W=Ie.eventProcessor(W));return m&&!U&&(W=m(W)),W};ue=(W,Ie)=>{var ne;const ae=W;if(ae.timestamp=bs(),!((ne=mt[0])!=null&&ne.isFrozen())||ae.type===Y.FullSnapshot||ae.type===Y.IncrementalSnapshot&&ae.data.source===G.Mutation||mt.forEach(Te=>Te.unfreeze()),y)t==null||t(ee(ae),Ie);else if(U){const Te={type:"rrweb",event:ee(ae),origin:window.location.origin,isCheckout:Ie};window.parent.postMessage(Te,"*")}if(ae.type===Y.FullSnapshot)L=ae,N=0;else if(ae.type===Y.IncrementalSnapshot){if(ae.data.source===G.Mutation&&ae.data.isAttachIframe)return;N++;const Te=s&&N>=s,J=r&&ae.timestamp-L.timestamp>r;(Te||J)&&cs(!0)}};const q=W=>{ue({type:Y.IncrementalSnapshot,data:{source:G.Mutation,...W}})},me=W=>ue({type:Y.IncrementalSnapshot,data:{source:G.Scroll,...W}}),Ne=W=>ue({type:Y.IncrementalSnapshot,data:{source:G.CanvasMutation,...W}}),we=new Of({mutationCb:q,adoptedStyleSheetCb:W=>ue({type:Y.IncrementalSnapshot,data:{source:G.AdoptedStyleSheet,...W}})}),H=new Ef({mirror:Oe,mutationCb:q,stylesheetManager:we,recordCrossOriginIframes:A,wrappedEmit:ue});for(const W of S||[])W.getMirror&&W.getMirror({nodeMirror:Oe,crossOriginIframeMirror:H.crossOriginIframeMirror,crossOriginIframeStyleMirror:H.crossOriginIframeStyleMirror});const Le=new Af;fn=new Lf({recordCanvas:E,mutationCb:Ne,win:window,blockClass:n,blockSelector:i,mirror:Oe,sampling:g.canvas,dataURLOptions:v});const et=new xf({mutationCb:q,scrollCb:me,bypassOptions:{blockClass:n,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskInputOptions:F,dataURLOptions:v,maskTextFn:p,maskInputFn:w,recordCanvas:E,inlineImages:R,sampling:g,slimDOMOptions:j,iframeManager:H,stylesheetManager:we,canvasManager:fn,keepIframeSrcFn:P,processedNodeManager:Le},mirror:Oe});cs=(W=!1)=>{if(!O)return;ue({type:Y.Meta,data:{href:window.location.href,width:jc(),height:zc()}},W),we.reset(),et.init(),mt.forEach(ne=>ne.lock());const Ie=function(ne,ae){const{mirror:Te=new Ll,blockClass:J="rr-block",blockSelector:_t=null,maskTextClass:ld="rr-mask",maskTextSelector:cd=null,inlineStylesheet:ud=!0,inlineImages:dd=!1,recordCanvas:pd=!1,maskAllInputs:Ks=!1,maskTextFn:hd,maskInputFn:md,slimDOM:Nt=!1,dataURLOptions:fd,preserveWhiteSpace:gd,onSerialize:yd,onIframeLoad:wd,iframeLoadTimeout:bd,onStylesheetLoad:vd,stylesheetLoadTimeout:Sd,keepIframeSrcFn:Id=()=>!1}=ae||{};return xt(ne,{doc:ne,mirror:Te,blockClass:J,blockSelector:_t,maskTextClass:ld,maskTextSelector:cd,skipChild:!1,inlineStylesheet:ud,maskInputOptions:Ks===!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}:Ks===!1?{password:!0}:Ks,maskTextFn:hd,maskInputFn:md,slimDOMOptions:Nt===!0||Nt==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:Nt==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:Nt===!1?{}:Nt,dataURLOptions:fd,inlineImages:dd,recordCanvas:pd,preserveWhiteSpace:gd,onSerialize:yd,onIframeLoad:wd,iframeLoadTimeout:bd,onStylesheetLoad:vd,stylesheetLoadTimeout:Sd,keepIframeSrcFn:Id,newlyAddedElement:!1})}(document,{mirror:Oe,blockClass:n,blockSelector:i,maskTextClass:l,maskTextSelector:c,inlineStylesheet:u,maskAllInputs:F,maskTextFn:p,maskInputFn:w,slimDOM:j,dataURLOptions:v,recordCanvas:E,inlineImages:R,onSerialize:ne=>{Hc(ne,Oe)&&H.addIframe(ne),Gc(ne,Oe)&&we.trackLinkElement(ne),ci(ne)&&et.addShadowRoot(V.shadowRoot(ne),document)},onIframeLoad:(ne,ae)=>{H.attachIframe(ne,ae),et.observeAttachShadow(ne)},onStylesheetLoad:(ne,ae)=>{we.attachLinkElement(ne,ae)},keepIframeSrcFn:P});if(!Ie)return console.warn("Failed to snapshot the document");ue({type:Y.FullSnapshot,data:{node:Ie,initialOffset:Bc(window)}},W),mt.forEach(ne=>ne.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&we.adoptStyleSheets(document.adoptedStyleSheets,Oe.getId(document))};try{const W=[],Ie=ae=>{var Te;return $(kf)({mutationCb:q,mousemoveCb:(J,_t)=>ue({type:Y.IncrementalSnapshot,data:{source:_t,positions:J}}),mouseInteractionCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.MouseInteraction,...J}}),scrollCb:me,viewportResizeCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.ViewportResize,...J}}),inputCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.Input,...J}}),mediaInteractionCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.MediaInteraction,...J}}),styleSheetRuleCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.StyleSheetRule,...J}}),styleDeclarationCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.StyleDeclaration,...J}}),canvasMutationCb:Ne,fontCb:J=>ue({type:Y.IncrementalSnapshot,data:{source:G.Font,...J}}),selectionCb:J=>{ue({type:Y.IncrementalSnapshot,data:{source:G.Selection,...J}})},customElementCb:J=>{ue({type:Y.IncrementalSnapshot,data:{source:G.CustomElement,...J}})},blockClass:n,ignoreClass:a,ignoreSelector:o,maskTextClass:l,maskTextSelector:c,maskInputOptions:F,inlineStylesheet:u,sampling:g,recordDOM:O,recordCanvas:E,inlineImages:R,userTriggeredOnInput:k,collectFonts:T,doc:ae,maskInputFn:w,maskTextFn:p,keepIframeSrcFn:P,blockSelector:i,slimDOMOptions:j,dataURLOptions:v,mirror:Oe,iframeManager:H,stylesheetManager:we,shadowDomManager:et,processedNodeManager:Le,canvasManager:fn,ignoreCSSAttributes:D,plugins:((Te=S==null?void 0:S.filter(J=>J.observer))==null?void 0:Te.map(J=>({observer:J.observer,options:J.options,callback:_t=>ue({type:Y.Plugin,data:{plugin:J.name,payload:_t}})})))||[]},C)};H.addLoadListener(ae=>{try{W.push(Ie(ae.contentDocument))}catch(Te){console.warn(Te)}});const ne=()=>{cs(),W.push(Ie(document)),vs=!0};return document.readyState==="interactive"||document.readyState==="complete"?ne():(W.push(ve("DOMContentLoaded",()=>{ue({type:Y.DomContentLoaded,data:{}}),M==="DOMContentLoaded"&&ne()})),W.push(ve("load",()=>{ue({type:Y.Load,data:{}}),M==="load"&&ne()},window))),()=>{W.forEach(ae=>ae()),Le.destroy(),vs=!1,Qt=void 0}}catch(W){console.warn(W)}}var ja,It;qt.addCustomEvent=(e,t)=>{if(!vs)throw new Error("please add custom event after start recording");ue({type:Y.Custom,data:{tag:e,payload:t}})},qt.freezePage=()=>{mt.forEach(e=>e.freeze())},qt.takeFullSnapshot=e=>{if(!vs)throw new Error("please take full snapshot after start recording");cs(e)},qt.mirror=Oe,(It=ja||(ja={}))[It.NotStarted=0]="NotStarted",It[It.Running=1]="Running",It[It.Stopped=2]="Stopped";var Ae=(e=>(e.Closed="close.click",e.Complete="survey.completed",e.FeedbackClosed="feedback.closed",e.PageChange="page.change",e.API="api",e.Override="override",e))(Ae||{}),B=(e=>(e.ReplayCapture="replay.capture",e.ReplayPaused="replay.paused",e.ReplayResumed="replay.resumed",e.FeedbackButtonLoaded="feedback.button.loaded",e.SDKReady="sdk.ready",e.SurveyAppeared="survey.appeared",e.SurveyCloseRequested="survey.closeRequested",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))(B||{});const hr={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 $r;const Mf=new Uint8Array(16);function Uf(){if(!$r&&($r=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!$r))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return $r(Mf)}const ge=[];for(let e=0;e<256;++e)ge.push((e+256).toString(16).slice(1));const Wa={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function bt(e,t,r){if(Wa.randomUUID&&!e)return Wa.randomUUID();const s=(e=e||{}).random||(e.rng||Uf)();return s[6]=15&s[6]|64,s[8]=63&s[8]|128,function(n,i=0){return ge[n[i+0]]+ge[n[i+1]]+ge[n[i+2]]+ge[n[i+3]]+"-"+ge[n[i+4]]+ge[n[i+5]]+"-"+ge[n[i+6]]+ge[n[i+7]]+"-"+ge[n[i+8]]+ge[n[i+9]]+"-"+ge[n[i+10]]+ge[n[i+11]]+ge[n[i+12]]+ge[n[i+13]]+ge[n[i+14]]+ge[n[i+15]]}(s)}const _=new class{constructor(){de(this,"breadcrumbs",[])}getTimeStamp(){return new Date().toISOString()}addBreadcrumb(e){this.breadcrumbs.push(e),this.breadcrumbs.length>300&&this.breadcrumbs.shift()}debug(e,t="debug"){this.addBreadcrumb({category:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"debug"})}error(e,t={}){this.addBreadcrumb({category:"error",data:t,level:"error",message:e,timestamp:this.getTimeStamp(),type:"error"})}http(e,t){this.addBreadcrumb({category:"xhr",data:t,message:e,timestamp:this.getTimeStamp(),type:"http"})}info(e,t={}){this.addBreadcrumb({category:"info",data:t,level:"info",message:e,timestamp:this.getTimeStamp(),type:"info"})}navigation(e,t){this.addBreadcrumb({category:"navigation",data:t,message:e,timestamp:this.getTimeStamp(),type:"navigation"})}},Va=()=>{try{return window.parent.Intercom}catch{return null}},Ha=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const e=Va();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},enable:()=>{const e=Va();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class ru{static disable(){Ha.forEach(t=>t.disable())}static enable(){Ha.forEach(t=>t.enable())}}var Df=class extends Error{constructor(e,t,r){super(`Possible EventEmitter memory leak detected. ${r} ${t.toString()} listeners added. Use emitter.setMaxListeners() to increase limit`),this.emitter=e,this.type=t,this.count=r,this.name="MaxListenersExceededWarning"}},su=class{static listenerCount(e,t){return e.listenerCount(t)}constructor(){this.events=new Map,this.maxListeners=su.defaultMaxListeners,this.hasWarnedAboutPotentialMemoryLeak=!1}_emitInternalEvent(e,t,r){this.emit(e,t,r)}_getListeners(e){return Array.prototype.concat.apply([],this.events.get(e))||[]}_removeListener(e,t){const r=e.indexOf(t);return r>-1&&e.splice(r,1),[]}_wrapOnceListener(e,t){const r=(...s)=>(this.removeListener(e,r),t.apply(this,s));return Object.defineProperty(r,"name",{value:t.name}),r}setMaxListeners(e){return this.maxListeners=e,this}getMaxListeners(){return this.maxListeners}eventNames(){return Array.from(this.events.keys())}emit(e,...t){const r=this._getListeners(e);return r.forEach(s=>{s.apply(this,t)}),r.length>0}addListener(e,t){this._emitInternalEvent("newListener",e,t);const r=this._getListeners(e).concat(t);if(this.events.set(e,r),this.maxListeners>0&&this.listenerCount(e)>this.maxListeners&&!this.hasWarnedAboutPotentialMemoryLeak){this.hasWarnedAboutPotentialMemoryLeak=!0;const s=new Df(this,e,this.listenerCount(e));console.warn(s)}return this}on(e,t){return this.addListener(e,t)}once(e,t){return this.addListener(e,this._wrapOnceListener(e,t))}prependListener(e,t){const r=this._getListeners(e);if(r.length>0){const s=[t].concat(r);this.events.set(e,s)}else this.events.set(e,r.concat(t));return this}prependOnceListener(e,t){return this.prependListener(e,this._wrapOnceListener(e,t))}removeListener(e,t){const r=this._getListeners(e);return r.length>0&&(this._removeListener(r,t),this.events.set(e,r),this._emitInternalEvent("removeListener",e,t)),this}off(e,t){return this.removeListener(e,t)}removeAllListeners(e){return e?this.events.delete(e):this.events.clear(),this}listeners(e){return Array.from(this._getListeners(e))}listenerCount(e){return this._getListeners(e).length}rawListeners(e){return this.listeners(e)}},nu=su;nu.defaultMaxListeners=10;const z=new nu,Ss=async e=>{await new Promise(t=>{setTimeout(t,e)})},to=({"userleap-platform":e})=>{var t;return((t=window.UserLeap)==null?void 0:t.forceDirectEmbed)||e!=="web"};class iu{constructor(t){de(this,"storage");de(this,"tempStorage",{});de(this,"isStorageAvailable");try{this.storage=window[t];const r="__storage_test__";this.storage.setItem(r,r),this.storage.removeItem(r),this.isStorageAvailable=!0}catch{this.isStorageAvailable=!1}}setItem(t,r){this.isStorageAvailable&&this.storage?this.storage.setItem(t,r):this.tempStorage[t]=r}setItemObject(t,r){try{this.setItem(t,JSON.stringify(r))}catch(s){s instanceof Error&&(s.stack=t+": "+r,window.UserLeap.reportError("Failed to save to local storage",s))}}getItem(t){return this.isStorageAvailable&&this.storage?this.storage.getItem(t):this.tempStorage[t]}getItemObject(t){const r=this.getItem(t);if(r)try{return JSON.parse(r)}catch(s){s instanceof Error&&(s.stack=t+": "+r,window.UserLeap.reportError("Failed to parse local storage",s))}return{}}removeItem(t){this.isStorageAvailable&&this.storage?this.storage.removeItem(t):delete this.tempStorage[t]}clear(){this.isStorageAvailable&&this.storage?this.storage.clear():this.tempStorage={}}}const Q=new iu("sessionStorage"),ut=new iu("localStorage");class Pf{constructor(t){de(this,"payload");de(this,"promise");de(this,"reject",()=>{});de(this,"resolve",()=>{});this.payload=t,this.promise=new Promise((r,s)=>{this.reject=s,this.resolve=r})}resolveRequest(t){this.resolve(t)}}const re={replay:null},_f=()=>{const e=[];return re.replay&&e.push("replay"),e.join(",")},Nf=10;let ou=!1,au="",Yr=!1,lu=!1,us=[];const Ff=e=>e._config&&e._config.installationMethod?e._config.installationMethod:e._gtm?"web-gtm":e._segment?"web-segment":"web-snippet",Ga=e=>{var t;(t=e==null?void 0:e.blockedURI)!=null&&t.includes(window.UserLeap._API_URL)&&(lu=!0,console.warn(`[Sprig] ${e.blockedURI} is blocked by Content-Security-Policy`))},di=(e="")=>{ou=!0,au=e};function De(e={}){const t={"Content-Type":"application/json","userleap-platform":"web","x-ul-sdk-version":"2.45.0","x-ul-installation-method":Ff(e),"sprig-modules":_f(),"x-ul-package-version":"2.45.0"};if(e.envId&&(t["x-ul-environment-id"]=e.envId),e.token&&(t.Authorization="Bearer "+e.token),e.userId&&(t["x-ul-user-id"]=e.userId),e.visitorId&&(t["x-ul-visitor-id"]=e.visitorId),e.partnerAnonymousId&&(t["x-ul-anonymous-id"]=e.partnerAnonymousId),e.mobileHeadersJSON){const r=JSON.parse(e.mobileHeadersJSON);Object.assign(t,r)}return e.locale&&(t["accept-language"]=e.locale),window.previewMode&&(t["x-ul-preview-mode"]="1"),t}const $a=async({shouldDropOnRateLimit:e,...t})=>{if(e)return{status:429};{const r=new Pf(t);return us.push(r),r.promise}},He=async(e,t)=>{const{retries:r=0,shouldDropOnRateLimit:s=!1,shouldRetryRequest:n=!1,...i}=t,a={url:e,options:i,retries:r,shouldDropOnRateLimit:s};if(Yr&&!n)return $a(a);const o={ok:!1,reportError:!1};if(ou)return console.info(`UserLeap - ${au}`),o;try{const l=await fetch(e,i);if(l.status===429){if(!Yr&&!s||n){Yr=!0;const c=l.headers.has("ratelimit-reset")?Number(l.headers.get("ratelimit-reset")):Nf;return await Ss(1e3*c),He(e,{...i,shouldDropOnRateLimit:s,shouldRetryRequest:!0})}return $a(a)}if(Yr=!1,us.length&&(us.map(c=>{const u=c.payload;He(u.url,{...u.options,retries:u.retries,shouldDropOnRateLimit:u.shouldDropOnRateLimit}).then(d=>{c.resolveRequest(d)})}),us=[]),l.ok){if(l.status===249)return di(),o;const c=await l.text();try{return c&&c!=="OK"&&(l.json=JSON.parse(c)),l}catch{return{ok:!1,reportError:!1,error:new Error(`failed parsing response json for ${e} - ${c}`)}}}return l}catch(l){const c=r+1;return c>5||lu?{ok:!1,reportError:!1,error:l}:(await Ss(1e3*Math.pow(2,r)),He(e,{...i,retries:c}))}},Ya="ul-view-sdk-script",Bf=new Set(["ios","android"]),it="visitors",ot="environments";async function ze(e,t){var i,a,o;const{shouldDropOnRateLimit:r,...s}=t;s.headers=Object.assign(De(window.UserLeap),s.headers);const n=await He(e,{...s,shouldDropOnRateLimit:r});if(n.ok){const l=(i=n.headers)==null?void 0:i.get("Authorization"),c=l?l.split(" "):void 0,u=c&&c.length===2?c[1]:void 0,d=(a=n.headers)==null?void 0:a.get("x-ul-visitor-id");if(window.UserLeap.userId&&d===window.UserLeap.visitorId){const h=ut.getItemObject("sprig.anon.env.vid.map");h&&h[window.UserLeap.envId]===d&&(delete h[window.UserLeap.envId],ut.setItemObject("sprig.anon.env.vid.map",h))}u&&d&&(d!==window.UserLeap.visitorId||window.UserLeap.token!==u)&&(ke("token",u),ke("vid",d),z.emit(B.VisitorIDUpdated,{visitorId:d}),window.UserLeap.token=u,window.UserLeap.visitorId=d)}return(o=n.json)!=null&&o.logMessage&&console.warn(`[Sprig] ${n.json.logMessage}`),n}function ke(e,t){const r=ut.getItemObject("userleap.ids");let s=r[window.UserLeap.envId];s?s[e]=t:s={[e]:t},r[window.UserLeap.envId]=s,ut.setItemObject("userleap.ids",r)}function ro(){return window.previewMode?"0":window.UserLeap.visitorId??""}function Me(e,t,r){const s=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(n=>{s.push(n),n===ot?s.push(window.UserLeap.envId):n===it&&s.push(ro())}),r&&s.push(r),s.join("/")}const tr=async(e,t,r)=>{var q,me,Ne,we;const{context:s,delay:n,avatars:i,experimentFlags:a,forceBrandedLogo:o,endCard:l,isFeedback:c=!1,heatmap:u,locale:d,layout:h,previewMode:f,productConfig:w,questions:p,responseGroupUid:C,surveyId:m,uuid:g,vid:v,sessionReplay:I,studyType:O,surveyVisitorAttributes:E}=e,A=De(window.UserLeap),M=mr(A),k=qs(A);if(I)if(M)z.emit(B.ReplayCapture,{responseGroupUid:C,hasQuestions:!!(p!=null&&p.length),surveyId:m,uploadId:I.uploadId,replayType:I.replayDurationType??"before",seconds:I.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:bt(),mediaType:"screen",questionId:1,responseGroupUid:C,surveyId:m,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!re.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};re.replay.scheduleOrCaptureReplay({responseGroupId:C,surveyId:m,visitorId:v,replayParams:I,completeUploadHeaders:A,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:p.length===0})}if(u){if(!re.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:H,replayParams:Le,responseGroupUid:et,surveyId:W}=u;await re.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0,apiUrl:window.UserLeap._API_URL,replaySettings:r}),re.replay.tryReplayAction(()=>{var Ie;return(Ie=re.replay)==null?void 0:Ie.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:A,eventId:H,isHeatmap:!0,replayParams:Le,responseGroupId:et,surveyId:W,triggerTimestamp:Date.now(),visitorId:v})},"Error in scheduling/capturing replay")}if(v==null||!(p!=null&&p.length))return _.info("CannotDisplaySurvey",{vid:v}),{success:!1,message:"[Sprig] no survey found",surveyState:window.UserLeap.container?"previous survey ready":"no survey"};if(zf(p))return{success:!1,message:"[Sprig] bundled version does not support video voice",surveyState:"no survey"};if(window.UserLeap.container){_.info("AlreadyDisplayingSurvey");const H="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(H),{success:!1,message:H,surveyState:"previous survey ready"}}if(v!==window.UserLeap.visitorId&&g!==window.UserLeap.visitorId&&!window.previewMode){const H="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(H)),{success:!1,message:H,surveyState:"no survey"}}_.info("ShowingSurvey",{surveyId:m}),(q=re.replay)==null||q.RecordSurveyShown({id:m,userAgent:window.navigator.userAgent}),ru.disable(),z.emit(B.SurveyWillPresent,{name:B.SurveyWillPresent,"survey.id":m,layout:h});let T,R,S,P,D=document.createElement("div");const b=H=>{const{"view.version":Le}=H;Le!==A["x-ul-sdk-version"]&&uu(),z.removeListener("verify.view.version",b)};z.on("verify.view.version",b),window.UserLeap.useMobileStyling=k,to(A)?(T="ul-direct-embeded-frame",R=document.head,S=window,P=!1,(()=>{const H=De(window.UserLeap),Le=mr(H),et=window.UserLeap.forceDirectEmbed,W=H["userleap-platform"]==="web";return Le||et&&W})()&&(cu(m,c),D.id=T,window.UserLeap.container.appendChild(D),du(),z.emit(B.SurveyLifeCycle,{state:"presented"}),z.emit(B.SurveyPresented,{name:B.SurveyPresented,"survey.id":m}))):{frameId:T,contentWinDocHead:R,contentWindow:S,hasOverlay:P,iframe:D}=Vf({productConfig:w,useMobileStyling:k,surveyId:m,isFeedback:c,enableCspTrustedTypes:(me=window.UserLeap._config)==null?void 0:me.enableCspTrustedTypes}),window.UserLeap.frameId=T;const y={apiURL:window.UserLeap._API_URL,avatars:i,cards:p,configureExitOnOverlayClick:H=>{z.once(B.CloseSurveyOnOverlayClick,H)},context:s,endCard:l,envId:window.UserLeap.envId,eventEmitFn:z.emit.bind(z),experimentFlags:a,fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:o,frame:D,headers:A,layout:h,locale:d,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:Q.getItem("sprig.previewKey"),previewMode:f||!!window.previewMode,productConfig:{framePosition:w==null?void 0:w.framePosition,desktopDisplay:w==null?void 0:w.desktopDisplay,placement:w==null?void 0:w.placement},responseGroupUid:C,startingQuestionIdx:(Ne=window.UserLeap.config)==null?void 0:Ne.startingQuestionIdx,studyType:O,styleNonce:window.UserLeap.styleNonce,surveyId:m,tabTitle:document.title,trackPageViewUrl:t,ulEvents:hr,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:k,userId:g,viewDocument:S==null?void 0:S.document,viewWindow:S,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},surveyVisitorAttributes:E||{},...window.UserLeap._config};(we=window.UserLeap._config)!=null&&we.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const U=(c?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??w.customStyles;y.customStyles=U,S&&(S.__cfg=y);const F=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:y.path,j=document.getElementById(Ya);j&&j.remove();const L=function(){const H=document.createElement("script");return window.UserLeap.isMobileSDK||H.setAttribute("type","module"),window.UserLeap.nonce&&H.setAttribute("nonce",window.UserLeap.nonce),H.id=Ya,H}(),N=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(y.installationMethod==="web-npm"||y.installationMethod==="web-npm-bundled"){const{default:H}=await Promise.resolve().then(()=>require("./view-K_OZdlXf.cjs")).then(Le=>Le.view);H.configure(y),P&&window.UserLeap.container&&N()}else F&&(L.src=`${F}${window.UserLeap.isMobileSDK?"":`?t=${Date.now()}`}`,P&&L.addEventListener("load",()=>{window.UserLeap.container&&N()}),S==null||S.addEventListener("error",H=>{H.target instanceof HTMLScriptElement&&H.target.src===F&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));R==null||R.appendChild(L);const ee={success:!0,surveyState:"ready",surveyId:m,responseGroupUid:C};return window.UserLeap.isMobileSDK&&n&&(ee.delay=n),ee};function qs(e){var r;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((r=window.UserLeap.windowDimensions)==null?void 0:r.width)??document.body.clientWidth;return mr(e)||t>10&&t<500}function mr(e){return Bf.has(e["userleap-platform"])}const zf=e=>e.some(t=>t.type==="videovoice"),qa=new WeakMap,jf=(e,t)=>{try{return(s=>{var a,o;const n=qa.get(s);if(n)return n;if(!((a=s.trustedTypes)!=null&&a.createPolicy))throw new Error("Trusted types not supported");const i=(o=s.trustedTypes)==null?void 0:o.createPolicy("sprig-sdk",{createHTML:l=>l,createScript:l=>l,createScriptURL:l=>l});return qa.set(s,i),i})(t).createHTML(e)}catch(r){return console.warn("Could not create TrustedHTML object",r),e}},Js=(e,t,r=window)=>{var s;return t&&((s=r.trustedTypes)!=null&&s.createPolicy)?jf(e,r):e},so="ul-frame";globalThis.UserLeap&&globalThis.Sprig&&(globalThis.Sprig._gtm?globalThis.Sprig=globalThis.UserLeap:globalThis.UserLeap=globalThis.Sprig),globalThis.UserLeap||(globalThis.UserLeap=globalThis.Sprig),globalThis.Sprig||(globalThis.Sprig=globalThis.UserLeap);const gn="0px",cu=(e,t,r)=>{globalThis.UserLeap.container=document.createElement("div"),globalThis.UserLeap.container.className="ul-container"+(t?" ul-container-feedback":""),e&&(globalThis.UserLeap.container.dataset.studyId=e.toString());const s=fu();r&&s&&!globalThis.UserLeap.useMobileStyling?s.appendChild(globalThis.UserLeap.container):document.body.appendChild(globalThis.UserLeap.container)},uu=(e,t)=>{var s;Gf();const r=globalThis.UserLeap.container;if(r)try{(s=r.parentNode)==null||s.removeChild(r),globalThis.UserLeap.container=null,ke("trackStartUrl",null),z.emit(B.SurveyLifeCycle,{state:"dismissed"}),z.emit(B.SurveyClosed,{name:B.SurveyClosed,initiator:e,"survey.id":parseInt(r.dataset.studyId),...t&&{studyType:t}})}catch(n){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+r),n instanceof Error&&globalThis.UserLeap.reportError("dismissActiveSurvey",n)}},du=()=>{z.once(B.SurveyWillClose,({initiator:e,studyType:t})=>{z.removeAllListeners(B.CloseSurveyOnOverlayClick),uu(e,t)})},Wf=(e,t,r,s)=>{var u,d;const n={position:"fixed",bottom:"0px",right:gn,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%"},i=Object.assign({},t,globalThis.UserLeap),{desktopDisplay:a}=t||{},o=a==="center-modal";let l;o&&(i.framePosition="center");let c=!1;if(r)(u=globalThis.UserLeap.windowDimensions)!=null&&u.width?n.width=`${globalThis.UserLeap.windowDimensions.width}px`:n.width="100%",(d=globalThis.UserLeap.windowDimensions)!=null&&d.height?n.maxHeight=globalThis.UserLeap.windowDimensions.height-20+"px":globalThis.UserLeap.maxHeight?n.maxHeight=globalThis.UserLeap.maxHeight:n.maxHeight=document.body.clientHeight-20+"px",["light","dark"].includes(i.overlayStyleMobile)&&(c=!0);else{n.width="360px",n.maxHeight=globalThis.UserLeap.maxHeight||"66vh";const h=()=>{c=!0,l={margin:"auto",position:"static"}};if(s)o?h():l={position:"relative",height:"300px"};else switch(i.framePosition){case"bottomLeft":l={left:gn};break;case"topLeft":l={left:gn,top:0};break;case"topRight":l={top:0};break;case"center":h()}}return c&&((h,f)=>{const w={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},p=f?h.overlayStyleMobile:h.overlayStyle;w["background-color"]=p==="light"?"rgba(255,255,255, 0.95)":"rgba(0,0,0,0.9)",f||(w.margin="auto"),globalThis.UserLeap.container&&Object.assign(globalThis.UserLeap.container.style,w)})(i,r),Object.assign(e.style,n,l),c},Vf=({productConfig:e,useMobileStyling:t,surveyId:r,isFeedback:s,enableCspTrustedTypes:n})=>{var f,w;const i=so,a=s&&e.desktopDisplay==="slider";cu(r,s,a),Hf();const o=document.createElement("iframe");o.id=i,o.setAttribute("title","Sprig User Feedback Dialog");const l=Wf(o,e,t,s);du();let c=!1;o.setHeight=p=>{parseInt(o.style.height)==p&&c||(c=!0,o.style.height=`${p}px`,z.emit(B.SurveyHeight,{name:B.SurveyHeight,contentFrameHeight:p,"survey.id":r}))};let u=!1;o.setWidth=p=>{parseInt(o.style.width)==p&&u||(u=!0,o.style.width=`${p}px`,z.emit(B.SurveyWidth,{name:B.SurveyWidth,contentFrameWidth:p,"survey.id":r}))},(f=globalThis.UserLeap.container)==null||f.appendChild(o),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&globalThis.UserLeap.container&&(globalThis.UserLeap.container.onclick=()=>{z.emit(B.CloseSurveyOnOverlayClick)}),z.emit(B.SurveyLifeCycle,{state:"presented"}),z.emit(B.SurveyPresented,{name:B.SurveyPresented,"survey.id":r});const d=(w=o.contentWindow)==null?void 0:w.document;if(d&&(d.open("text/html","replace"),d.write(Js("<!doctype html><head></head><body></body></html>",n,o.contentWindow)),d.close(),!t)){const p=d.body;p.style.display="flex",p.style.alignItems="center"}const h=d==null?void 0:d.head;return{frameId:i,contentWinDocHead:h,contentWindow:o.contentWindow,hasOverlay:l,iframe:o}},pu={[B.SurveyFadingOut]:()=>{globalThis.UserLeap.container&&Object.assign(globalThis.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Hf=()=>{Object.entries(pu).forEach(([e,t])=>{z.on(e,t)})},Gf=()=>{Object.entries(pu).forEach(([e,t])=>{z.off(e,t)})},Ja=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 no(e,t){const{matchType:r,pattern:s}=e,n=r?Ja[r]:Ja.legacy;let i=!1;try{i=n(s,t)}catch(a){const o=`[Sprig] (ERR-445) Failed to check url match with pattern ${s}`;a instanceof Error&&(console.warn(o,a),a.stack=JSON.stringify(e),window.UserLeap.reportError(o,a))}return i}const hu=e=>{const{pageUrlEvents:t}=window.UserLeap._config,r=t==null?void 0:t.find(s=>s.id===e);return!!r&&no(r,window.location.href)},qe=e=>!!e&&e.nodeType===Node.ELEMENT_NODE,Ka=e=>e instanceof HTMLElement||e instanceof SVGElement,fr=({document:e,elementId:t,styleString:r,nonce:s})=>{const n=e.getElementById(t);if(n)return void(n.textContent=r);const i=e.createElement("style");s&&(i.nonce=s),i.textContent=r,i.id=t,e.head.appendChild(i)},Xa=(e,t)=>{const r=t.querySelector(e);if(!qe(r))return 0;const s=getComputedStyle(r);return parseFloat(s.paddingLeft)+parseFloat(s.paddingRight)+(parseFloat(s.marginLeft)+parseFloat(s.marginRight))+(parseFloat(s.borderLeftWidth)+parseFloat(s.borderRightWidth))},mu=(e,t,r)=>{const s=e.querySelector(".ul-card__container"),n=e.querySelector(".ul-app");let i=600,a=360;if(qe(s)&&qe(n)){const o=s.querySelector(".ul-card--matrix_grid"),l=!o&&t&&r;try{l&&(n.style.width="360px"),i=s.scrollHeight,i+=(d=>{const h=d.querySelector(".sprig-question-body"),f=d.querySelector(".ul-card"),w=d.querySelector(".ul-card-main-content"),p=d.querySelector(".ul-footer"),C=d.querySelector(".sprig-container");let m=0;return qe(f)&&(m+=f.scrollHeight-f.clientHeight),qe(w)&&(m+=w.scrollHeight-w.clientHeight),qe(h)&&(m+=h.scrollHeight-h.clientHeight),qe(p)&&qe(C)&&C.clientHeight===0&&(m+=p.clientHeight),m})(e);const c=getComputedStyle(s),u=parseFloat(c.marginTop)+parseFloat(c.marginBottom);i+=u+(parseFloat(c.borderTopWidth)+parseFloat(c.borderBottomWidth)),o&&(a=o.scrollWidth,a+=Xa(".ul-card__container",e),a+=Xa(".sprig-question-body",e))}finally{l&&n.style.removeProperty("width")}}return[i+2,a]},fu=()=>Z,Lt=()=>document.getElementById("sprig-feedback-container"),pi=()=>document.getElementById("sprig-feedback-loading-animation"),gu=()=>!!document.getElementById(so);let Za=!1,Z=null,je=null,io=!1,rr=null,pt=null;const $f=["bottom-left","bottom-right","center-left","center-right"],Is=()=>{var t;const e=window.UserLeap.container;return((t=e==null?void 0:e.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},yu=()=>document.getElementById("sprig-feedback-error-container"),wu=()=>{if(!Z)return 0;const e=Z==null?void 0:Z.clientWidth,t=window.getComputedStyle(Z);return e+parseInt(t.borderRightWidth||"0")+parseInt(t.borderLeftWidth||"0")},Cs=e=>{const t=Lt();t&&(pt!=null&&pt.endsWith("right")?t.style.right=`${e}px`:pt!=null&&pt.endsWith("left")&&(t.style.left=`${e}px`))},yn=()=>{if(Z&&(Is()||yu())){z.off(B.SurveyAppeared,Jt),hi();const e=wu();return Cs(-e),!0}return!1},Jt=()=>{if(!Z||!je)return;const e=pi();e&&e.remove(),Z.style.height="auto",Z.style.width="auto",je.disabled=!1,io=!1},hi=()=>{if(Z&&!pi()){const e=(()=>{var r;if(pi())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=Js(`
|
|
56
56
|
<div class="ul-loading-spinner">
|
|
57
57
|
<div class="first"></div>
|
|
58
58
|
<div class="second"></div>
|
|
@@ -63,4 +63,4 @@ or you can use record.mirror to access the mirror instance during recording.`;le
|
|
|
63
63
|
<circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
|
|
64
64
|
<path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
|
|
65
65
|
<circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
|
|
66
|
-
</svg>`,(r=window.UserLeap._config)==null?void 0:r.enableCspTrustedTypes);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},mi=new class{constructor(){de(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!(!e||typeof e!="object"||Array.isArray(e))&&(Object.keys(this._ldData).forEach(t=>{delete this._ldData[t]}),Object.keys(e).forEach(t=>this._ldData[`!launch_darkly_${t}`]=(e[t]??0)+1),!0)}catch(t){return t instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",t),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(mi);const ds=new class{constructor(){de(this,"_optimizelyData",{})}setOptimizelyExperiment(e,t=!0){if(!e||typeof e!="object")return!1;const{experiments:r}=e;try{return t&&Object.keys(this._optimizelyData).map(s=>{delete this._optimizelyData[s]}),r&&r.map(s=>{const{id:n,variation:i}=s,a=this.transformExperimentId(n);i&&typeof i=="string"&&(this._optimizelyData[a]=i)}),!0}catch(s){return s instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",s),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return"!optimizely_experiments_"+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const t=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(t){const r=Object.keys(t).map(s=>{var n,i;return(n=t[s].variation)!=null&&n.name?{id:s,variation:(i=t[s].variation)==null?void 0:i.name}:{id:s,variation:"Original"}});return this.setOptimizelyExperiment({experiments:r},!1),!0}return!1}return!1}catch(t){return t instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",t),!1}}};Object.freeze(ds);class qf{constructor(t,r){de(this,"paused");de(this,"queue");de(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(r)}flush(t){const r=t.length;if(r)for(let s=0;s<r;s++)this.push(t[s])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const t=this.queue.slice();this.empty(),this.flush(t)}push(t){if(this.paused)this.queue.push(t);else if(t instanceof Function)t();else{const r=Array.prototype.slice.call(t,1),s=t[0],n=this.ul[s];n instanceof Function?n.apply(this.ul,r):s&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",s)}}perform(t){if(this.paused){let r=()=>{};const s=new Promise(function(n){r=function(){n(t())}});return this.queue.push(r),s}return t()}empty(){this.queue.length=0}}let vu=!0,fi=!1;const Jf=["sdk_event_queue_latency_seconds","sdk_replay_add_event_batch_seconds","sdk_replay_cleanup_seconds","sdk_replay_compression_seconds","sdk_replay_get_events_between_seconds","sdk_replay_snapshot_seconds","sdk_mutations_nodes_added","sdk_mutations_nodes_removed","sdk_mutations_attributes_changed","sdk_mutations_character_data","sdk_dom_nodes_count","sdk_page_html_characters"];let gi,Kt={};class Kf{constructor(t){de(this,"_values",[]);de(this,"_isWebMetric");this.name=t,this._isWebMetric=Jf.includes(this.name)}report(t){if(vu&&this._values.push({time:Date.now(),value:t}),fi||!this._isWebMetric)return;const r=this.findExceededThreshold(t);r&&gi&&gi(t,r)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const r=Kt[this.name];if(r)return r.find(s=>this.valueExceedsThreshold(t,s))}valueExceedsThreshold(t,r){return r.type==="max"?t>r.value:r.type==="min"&&t<r.value}}const br={},Ve=e=>{const t=new Kf(e);return br[e]=t,t},Su=(e,t)=>{let r=br[e];return r||(r=Ve(e)),r.report(t)},Xf=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{(async r=>{const s=Object.values(br).map(n=>({name:n.name,values:n.collect()}));if(s.some(n=>n.values.length))try{await r(JSON.stringify(s))}catch(n){n instanceof Error&&_.error("MetricsErr",{error:{message:n.message,name:n.name}})}})(t)},1e3*e):vu=!1};let Iu,Cu;const yi=e=>{let t=0,r=e.firstElementChild;for(;r;)t+=yi(r),r.shadowRoot&&(t+=yi(r.shadowRoot)),r=r.nextElementSibling,t++;return t},el=()=>{Iu.report(yi(document.body)),Cu.report(document.documentElement.innerHTML.toString().length)},wi=(e,t)=>{const r=performance.now();document.hidden?setTimeout(()=>wi(e,t),e):setTimeout(()=>{const s=performance.now()-r;t.report(s/1e3),setTimeout(()=>wi(e,t),e)},0)};let ks,Es,xs,Ts,tl,ht={};const qr=(e,t=1)=>{const{name:r}=e;ht[r]=(ht[r]||0)+t},ku=e=>{let t=1;return e.childNodes.forEach(r=>{t+=ku(r)}),t},rl=e=>{let t=0;return e.forEach(r=>{t+=ku(r)}),t},Zf=e=>{switch(e.type){case"childList":return qr(ks,rl(e.addedNodes)),void qr(Es,rl(e.removedNodes));case"attributes":return void qr(xs);case"characterData":return void qr(Ts)}},Qf=e=>e.forEach(Zf),eg=()=>{ks.report(ht[ks.name]||0),Es.report(ht[Es.name]||0),xs.report(ht[xs.name]||0),Ts.report(ht[Ts.name]||0),ht={}},tg=(e=1e3)=>{ks=Ve("sdk_mutations_nodes_added"),Es=Ve("sdk_mutations_nodes_removed"),xs=Ve("sdk_mutations_attributes_changed"),Ts=Ve("sdk_mutations_character_data"),tl=new MutationObserver(Qf),tl.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(eg,e)},rg=({isWeb:e,reportingIntervalSeconds:t,thresholds:r,postMetrics:s})=>{((n,i)=>{Kt={},fi=!1,n==null||n.forEach(a=>{var o;a.metric in Kt||(Kt[a.metric]=[]),(o=Kt[a.metric])==null||o.push(a)}),gi=i})(r,(n,i)=>{var a,o;if((a=re.replay)!=null&&a.isReplayRecording()){const l=`Value: ${n} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(o=re.replay)==null||o.disableRecording("Threshold violated",new Error(l),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:i.metric,type:i.type,value:i.value},{metricName:i.metric}),fi=!0}}),Xf({reportingIntervalSeconds:t,postMetrics:s}),e&&(((n=1e3)=>{const i=Ve("sdk_event_queue_latency_seconds");wi(n,i)})(),((n=1e4)=>{Iu=Ve("sdk_dom_nodes_count"),Cu=Ve("sdk_page_html_characters"),el(),setInterval(el,n)})(),tg())},sg="test",ng=["popState","pushState","replaceState"];let oo,sr;const Rs={},Vt="!email",Eu="pageUrl";var dl;let wn=((dl=globalThis.location)==null?void 0:dl.href)||"";function nr(e){var o,l;const{pageUrlEvents:t,interactiveEvents:r,dismissOnPageChange:s,platform:n}=globalThis.UserLeap._config;if(n&&n!=="web")return;wn!==globalThis.location.href&&_.navigation("LocationChange",{from:wn,to:globalThis.location.href}),wn=globalThis.location.href;const i=Ru().trackStartUrl,a=i?String(i):null;t&&Ou(globalThis.location.href),r&&(Tu(),ig()),fu()&&(()=>{if(Is())return;const c=Lt();c&&(hu(rr)||(c.remove(),rr=null,Z=null))})(),Q.getItem("sprig.isCapturingHeatmap")&&((l=(o=re.replay)==null?void 0:o.checkPendingHeatmapsUrl())==null||l.then(c=>{var u;c&&((u=re.replay)==null||u.uploadReadyPendingCaptures(!0))})),!Is()&&s&&a&&a!==globalThis.location.href&&e&&ng.includes(e.type)&&globalThis.UserLeap("dismissActiveSurvey",Ae.PageChange)}const xu={capture:!0},ig=()=>{const e=globalThis.UserLeap._config.interactiveEvents.filter(r=>no(r,globalThis.location.href)).map(r=>{const{name:s,properties:n}=r,{selector:i,innerText:a}=n;return i?o=>{if(Ka(o.target))try{o.target.closest(i)&&globalThis.UserLeap("track",s)}catch{}return!1}:o=>(Ka(o.target)&&o.target.innerText===a&&globalThis.UserLeap("track",s),!1)}),t=r=>e.forEach(s=>s(r));globalThis.UserLeap._config.interactiveEventsHandler=t,globalThis.addEventListener("click",t,xu)},Tu=()=>{globalThis.UserLeap._config.interactiveEventsHandler&&globalThis.removeEventListener("click",globalThis.UserLeap._config.interactiveEventsHandler,xu),delete globalThis.UserLeap._config.interactiveEventsHandler};function Ru(){const e=ut.getItemObject("userleap.ids");return(e==null?void 0:e[globalThis.UserLeap.envId])||{}}function Lu(){if(globalThis.previewMode)return;const e=ut.getItemObject("sprig.anon.env.vid.map")||{},t=e[globalThis.UserLeap.envId];globalThis.UserLeap.visitorId=t||bt(),_.info("NewVid",{vid:globalThis.UserLeap.visitorId}),ke("vid",globalThis.UserLeap.visitorId),t||(e[globalThis.UserLeap.envId]=globalThis.UserLeap.visitorId,ut.setItemObject("sprig.anon.env.vid.map",e)),z.emit(B.VisitorIDUpdated,{visitorId:globalThis.UserLeap.visitorId})}function Ou(e,t,r,s){var n,i;try{if(e.endsWith("mock_snippet.html"))return;_.info("PageView",{url:e});const a=(n=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:n.getAttribute("content");(i=re.replay)==null||i.RecordPageView({...a&&{description:a},url:e,referrer:document.referrer,pageTitle:document.title});const o=globalThis.UserLeap._config.pageUrlEvents;let l=!1;if(o&&o.length)for(let u=0;u<o.length&&(l=no(o[u],e),!l);u++);if(!l)return;globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const c={url:e};s&&(c.trackPageView=!0),globalThis.UserLeap._queue.push(["track",Eu,t,c,r])}catch(a){a instanceof Error&&(a.stack=e,globalThis.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function og(){var t;const e=((t=globalThis.Backbone)==null?void 0:t.history)||globalThis.history;"pushState"in e&&(e.pushState=(r=>function(...s){const n=r.apply(this,s),i=new Event("pushState");return globalThis.dispatchEvent(i),nr(i),n})(e.pushState)),"replaceState"in e&&(e.replaceState=(r=>function(...s){const n=r.apply(this,s),i=new Event("replaceState");return globalThis.dispatchEvent(i),nr(i),n})(e.replaceState)),["hashchange","popstate"].forEach(r=>globalThis.addEventListener(r,nr,!0))}async function bn(e,t){const r=ro();e&&!t&&(globalThis.UserLeap._config.mode=sg);const s=qs(De(globalThis.UserLeap)),n=await ze(function(i){const a=new URL(Me("1",[ot],"questions"));return Object.entries(i||{}).forEach(([o,l])=>{l&&a.searchParams.append(o,String(l))}),a.toString()}({desktopDisplay:globalThis.UserLeap._config.desktopDisplay,isMobile:s,previewLanguage:globalThis.UserLeap._config.previewLanguage,surveyid:e==null?void 0:e.surveyId,surveytemplateid:e==null?void 0:e.surveyTemplateId,vid:r}),{shouldDropOnRateLimit:!0});if(!n.ok)return n.reportError&&n.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",n.error),globalThis.UserLeap.reportError("getQuestions",n.error)),{success:!1,surveyState:"no survey"};if(n.json.delay&&await Ss(n.json.delay),!n.json.isFeedback)return tr(n.json,sr,oo);{const{feedbackLabel:i,productConfig:a,surveyUuid:o,feedbackCustomStyles:l}=n.json,{buttonTheme:c,placement:u,desktopDisplay:d}=a;bu({customStyles:l,buttonTheme:c,desktopDisplay:d,eventId:0,feedbackLabel:i,placement:u,surveyUuid:o,surveyId:e==null?void 0:e.surveyId},n.json)}}function ag(e){if(!e)return;globalThis.UserLeap._config=e,e.mute&&globalThis.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:r,dismissOnPageChange:s}=e;t&&function(n){let i=n.length;for(;i;){const a=Math.floor(Math.random()*i);i-=1;const o=n[i];n[i]=n[a],n[a]=o}}(t),(t||r||s)&&(og(),nr())}const lg=function(e){if(!globalThis.UserLeap)return;const t=async(n={})=>{var m,g,v,I,O;const{userId:i,anonymousId:a,metadata:o={},properties:l,showSurveyCallback:c}=n;let{eventName:u}=n;if(globalThis.UserLeap.debugMode&&u!==Eu&&console.info("[DEBUG] Sprig track",n),e.mode==="test")return;const d=Q.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!globalThis.UserLeap.userId&&!i){const E="[Sprig] - Skipping tracking without userId";return console.warn(E),{success:!1,message:E,surveyState:"no survey"}}if(!u||u.trim().length===0){u=u?String(u):"";const E="[Sprig] - Invalid event name "+u;return console.warn(E),{success:!1,message:E,surveyState:"no survey"}}const h=sr??globalThis.location.href;o.url||(o.url=h),ke("trackStartUrl",h),(g=(m=globalThis.UserLeap)==null?void 0:m._config)!=null&&g.optimizelyEnabled&&(mr(De(globalThis.UserLeap))||ds.getAndSetWebOptimizelyExperiments(),o.optimizelyExperiments=Object.assign({},ds.getAllOptimizelyExperiments())),(I=(v=globalThis.UserLeap)==null?void 0:v._config)!=null&&I.launchDarklyEnabled&&(o.launchDarklyFlags=mi.getAllLaunchDarklyVariations()),i&&(globalThis.UserLeap.userId=i),a&&(globalThis.UserLeap.partnerAnonymousId=a),l&&(o.eventProperties=l),(O=re.replay)==null||O.RecordEvent({name:u,url:o.url}),_.info("TrackEvent",{eventName:u});const f=globalThis.UserLeap.delayingSurvey||gu()?await ze(Me("1",[it],"events/batch"),{body:JSON.stringify({events:[{event:u,metadata:o}],previewKey:d}),method:"POST",shouldDropOnRateLimit:!0}):await ze(Me("1",[it],"events"),{body:JSON.stringify({event:u,metadata:o,previewKey:d}),method:"POST",shouldDropOnRateLimit:!0});if(!f.ok){const E="[Sprig] (ERR-421) Failed to track event";return f.reportError&&(console.warn(E,f.error),f.error&&globalThis.UserLeap.reportError("track",f.error)),{success:!1,message:E,error:f.error,surveyState:"no survey"}}i&&ke("uid",i),a&&ke("aid",a);const w=f.json;w.invalidPreviewKey&&Q.removeItem("sprig.previewKey");const p=o.trackPageView?o.url:void 0;return w!=null&&w.feedbackButton&&bu(w.feedbackButton,void 0,p),await async function(E,A){var k,T;let M=!0;return!(A&&((k=E==null?void 0:E.json)!=null&&k.surveyId)&&(globalThis.UserLeap.delayingSurvey=!0,M=await A(E.json.surveyId),globalThis.UserLeap.delayingSurvey=!1,!M))&&((T=E==null?void 0:E.json)!=null&&T.delay&&!globalThis.UserLeap.isMobileSDK&&(globalThis.UserLeap.delayingSurvey=!0,await Ss(E.json.delay),globalThis.UserLeap.delayingSurvey=!1),M)}(f,c)?function(E){if(!globalThis.UserLeap._config.dismissOnPageChange)return!0;const A=new URL(E),M=new URL(sr??globalThis.location.href);return A.hostname===M.hostname&&A.pathname===M.pathname}(h)?tr(w,p,oo):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},r=(n,i)=>{var o;const a=(o=n==null?void 0:n.querySelector(`[id="${so}"]`))==null?void 0:o.contentDocument;a&&fr({document:a,elementId:"ul-custom-style",styleString:i})},s={displaySurvey:async n=>(console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),globalThis.UserLeap("dismissActiveSurvey",Ae.Override),bn({surveyId:n},!0)),_previewSurvey(n){globalThis.UserLeap("dismissActiveSurvey",Ae.Override),bn({surveyTemplateId:n},!1)},_reviewSurvey(n){globalThis.UserLeap("dismissActiveSurvey",Ae.Override),bn({surveyId:n},!1)},previewSurvey(n){s._previewSurvey(n)},reviewSurvey(n){s._reviewSurvey(n)},mute(){globalThis.UserLeap._queue.pause()},unmute(){globalThis.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(n=Ae.API){globalThis.UserLeap.container&&(n===Ae.Closed&&globalThis.Sprig.trackHistory&&globalThis.Sprig.trackHistory({event:"closed"}),z.emit(B.SurveyCloseRequested,{name:B.SurveyCloseRequested,initiator:n,"survey.id":parseInt(globalThis.UserLeap.container.dataset.studyId)}),z.emit(B.SurveyWillClose,{name:B.SurveyWillClose,initiator:n,"survey.id":parseInt(globalThis.UserLeap.container.dataset.studyId)}))},async setAttribute(n,i){if(!n||!i&&i!==0&&i!==!1){const a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}return this.setAttributes({[n]:i})},async setAttributes(n){if(n==null||Object.keys(n).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:n})},async identifyAndSetAttributes(n){if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",n),e.mode==="test")return;if(n===null||typeof n!="object"||!(n.userId||n.anonymousId||n.attributes)){const u="[Sprig] - Disregarding empty payload provided";return console.warn(u),{success:!1,message:u}}const{userId:i,anonymousId:a,attributes:o}=n;if(e.requireUserIdForTracking&&!globalThis.UserLeap.userId&&!i){const u="[Sprig] - Skipping tracking without userId";return console.warn(u),{success:!1,message:u}}if(o){o.email&&!o[Vt]&&(o[Vt]=o.email,delete o.email);const u=Object.keys(o);for(const d of u)o[d]===Rs[d]&&delete o[d]}if(!(o&&Object.keys(o).length!==0||i&&globalThis.UserLeap.userId!==i||a&&globalThis.UserLeap.partnerAnonymousId!==a))return{success:!0};const l={};let c;return i&&(l.userId=globalThis.UserLeap.userId=i),a&&(l.partnerAnonymousId=globalThis.UserLeap.partnerAnonymousId=a),o&&Object.keys(o).length>0?(c=await ze(Me("1",[ot,it],"attributes"),{body:JSON.stringify(o),method:"PUT"}),c.ok?Object.assign(Rs,o):c.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",c.error),c.error&&globalThis.UserLeap.reportError("identifyAndSetAttributes",c.error))):c=await ze(Me("1",[ot,it]),{body:JSON.stringify(l),method:"PUT"}),o&&o[Vt]&&(globalThis.UserLeap.email=o[Vt]),c.ok&&(i&&ke("uid",i),a&&ke("aid",a)),{success:!!c.ok}},async removeAttributes(n){if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",n),e.mode==="test")return;if(n==null||n.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(e.requireUserIdForTracking&&!globalThis.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const i=await ze(Me("1",[ot,it],"attributes"),{body:JSON.stringify({delete:n}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&globalThis.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(n){z.on(B.SurveyLifeCycle,n)},async removeSurveyListener(n){z.removeListener(B.SurveyLifeCycle,n)},async addListener(n,i){z.on(n,i)},async removeListener(n,i){z.removeListener(n,i)},async removeAllListeners(){z.removeAllListeners()},setPreviewKey(n){n&&typeof n=="string"&&Q.isStorageAvailable&&n&&Q.setItem("sprig.previewKey",n)},async setUserId(n){var o;if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",n),n==null){const l=`[Sprig] - Invalid userId ${n}`;return console.warn(l),{success:!1,message:l}}if(e.mode==="test"||n===globalThis.UserLeap.userId)return;globalThis.UserLeap.userId=n;const i=globalThis.UserLeap.visitorId,a=await ze(Me("1",[ot,it]),{body:JSON.stringify({userId:n}),method:"PUT"});a.ok?(i!==globalThis.UserLeap.visitorId&&((o=re.replay)==null||o.clearUserReplayData()),ke("uid",n)):a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&globalThis.UserLeap.reportError("setUserId",a.error))},async setPartnerAnonymousId(n){if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",n),n==null){const i=`[Sprig] - Invalid partnerAnonymousId ${n}`;return console.warn(i),{success:!1,message:i}}return globalThis.UserLeap.partnerAnonymousId=n,ke("aid",n),{success:!0}},track:async(n,i,a={},o=void 0)=>t({eventName:n,properties:i,metadata:a,showSurveyCallback:o}),identifyAndTrack:async n=>await t(n),trackPageView(n,i=void 0,a=void 0,o=!0){sr=n,Ou(n,i,a,o)},applyFeedbackStyles({button:n="",view:i=""}){globalThis.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&fr({document,elementId:"ul-custom-style",styleString:n,nonce:globalThis.UserLeap.styleNonce}),r(document.querySelector(".ul-container-feedback"),i)},applyStyles(n){globalThis.UserLeap.customStyles=n,r(globalThis.UserLeap.container,n)},setWindowDimensions(n,i){var h,f;const a=typeof n=="string"?parseInt(n,10):n,o=typeof i=="string"?parseInt(i,10):i;isNaN(a)||isNaN(o)||(globalThis.UserLeap.windowDimensions={width:a,height:o});const l=De(globalThis.UserLeap),c=qs(l),u=l["userleap-platform"]==="web";if(!globalThis.UserLeap.frameId)return;const d=document.getElementById(globalThis.UserLeap.frameId);d&&(globalThis.UserLeap.useMobileStyling&&((h=globalThis.UserLeap.windowDimensions)!=null&&h.width&&(d.style.width=`${globalThis.UserLeap.windowDimensions.width}px`),(f=globalThis.UserLeap.windowDimensions)!=null&&f.height&&(d.style.maxHeight=globalThis.UserLeap.windowDimensions.height-20+"px"),d.contentDocument&&(d.style.height=String(mu(d.contentDocument,u&&!c,to(l))[0])+"px")),z.emit(B.SurveyDimensions,{name:B.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight,"survey.id":parseInt(globalThis.UserLeap.container.dataset.studyId)}))},logoutUser(){var n;globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),_.info("LogOut",{vid:globalThis.UserLeap.visitorId,userId:globalThis.UserLeap.userId}),globalThis.UserLeap.visitorId=null,globalThis.UserLeap.userId=null,globalThis.UserLeap.partnerAnonymousId=null,globalThis.UserLeap.token=null,globalThis.UserLeap.email=null,ut.removeItem("userleap.ids"),globalThis.UserLeap._queue.isPaused()&&globalThis.UserLeap._queue.empty(),Lu(),(n=re.replay)==null||n.clearUserReplayData(),globalThis.UserLeap._queue.unpause()},teardown(){["hashchange","popstate"].forEach(n=>globalThis.removeEventListener(n,nr,!0)),globalThis.UserLeap._config.interactiveEvents&&Tu(),globalThis.UserLeap("dismissActiveSurvey",Ae.API),delete globalThis.UserLeap,delete globalThis.Sprig,delete globalThis._Sprig},integrateOptimizely(n,i=!0){var a,o;if((o=(a=globalThis.UserLeap)==null?void 0:a._config)!=null&&o.optimizelyEnabled)try{const l=typeof n=="string"?JSON.parse(n):n;ds.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&globalThis.UserLeap.reportError("integrateOptimizely",l)}else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.")},integrateOptimizelyClient(n){var i,a;if(!((a=(i=globalThis.UserLeap)==null?void 0:i._config)!=null&&a.optimizelyEnabled))return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");n.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",({experiment:o,variation:l})=>{const c={experiments:[{id:o.id,variation:l.key}]};globalThis.UserLeap("integrateOptimizely",c,!1)})},importLaunchDarklyData(n){var i,a;(a=(i=globalThis.UserLeap)==null?void 0:i._config)!=null&&a.launchDarklyEnabled?mi.setLDFlagsVariations(n):console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.")},setVisitorAttribute:(n,i)=>(console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),s.setAttribute(n,i)),setEmail:async n=>s.setAttribute(Vt,n),setVisitorEmail:async n=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),s.setEmail(n)),_generateVideoUploadUrl:async n=>async function(i){var o;if(!i)return;const a=`${globalThis.UserLeap._API_URL}/2/environments/integrations/upload`;try{const l=await fetch(a,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(l.ok){const c=await l.json();return(o=c==null?void 0:c.upload)==null?void 0:o.url}return null}catch(l){console.warn("[Sprig] Error with generating video upload url"),l instanceof Error&&globalThis.UserLeap.reportError("generateVideoUploadUrl",l)}}(n),_reportMetric(n,i){Su(n,i)},_completeSessionReplay:async({surveyId:n,responseGroupUuid:i,eventDigest:a})=>{var o;return re.replay?(o=re.replay)==null?void 0:o._completeSessionReplay({surveyId:n,responseGroupUuid:i,eventDigest:a,headers:De(globalThis.UserLeap)}):(globalThis.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)},pauseReplayRecording(){var n,i,a,o;(i=(n=re.replay)==null?void 0:n.isReplayPaused)!=null&&i.call(n)||((o=(a=re.replay)==null?void 0:a.recordReplayPaused)==null||o.call(a))},resumeReplayRecording(){var n,i,a,o,l,c;(i=(n=re.replay)==null?void 0:n.isReplayPaused)!=null&&i.call(n)&&((o=(a=re.replay)==null?void 0:a.recordReplayResumed)==null||o.call(a),(c=(l=re.replay)==null?void 0:l.recordFullSnapshot)==null||c.call(l))}};Object.assign(globalThis.UserLeap,s)};async function cg(e,t,r={},s={}){var u;const n=(u=globalThis.__cfg)==null?void 0:u.mode,i=ro(),a=globalThis.UserLeap.envId,o=globalThis.document.documentElement,l={mode:n,screenWidth:globalThis.screen.width,screenHeight:globalThis.screen.height,clientWidth:o.clientWidth,clientHeight:o.clientHeight,location:sr??globalThis.location.href,language:globalThis.navigator.language,...r},c={action:e,breadcrumbs:_.breadcrumbs,err:{message:`${t==null?void 0:t.name} - ${t==null?void 0:t.message}`,stack:t==null?void 0:t.stack},meta:l,vid:i,envId:a,...s};(await ze(Me("1",null,"errors"),{method:"POST",headers:{"x-ul-error":globalThis.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",t)}function ug(e={}){var s;(s=globalThis.SprigLoggerCallback)==null||s.call(globalThis,"Initializing Sprig");const t=new URLSearchParams(globalThis.location.search).get("sprigPreviewKey")??"";async function r(){var d,h,f,w,p;if(globalThis.UserLeap.loaded)return;if((d=globalThis.SprigLoggerCallback)==null||d.call(globalThis,"Loading Sprig"),globalThis.UserLeap.reportError=cg,globalThis.UserLeap.loaded=!0,globalThis.UserLeap._config=Object.assign({},e,globalThis.UserLeap.config),globalThis.UserLeap.delayingSurvey=!1,globalThis.UserLeap._config&&typeof globalThis.UserLeap._config=="object")for(const C in globalThis.UserLeap._config)globalThis.UserLeap[C]=globalThis.UserLeap._config[C];if(globalThis.Sprig.outstandingTransactionLimit!==void 0&&(e.outstandingTransactionLimit=globalThis.Sprig.outstandingTransactionLimit),!globalThis.UserLeap.envId){if(!globalThis.UserLeap.appId)throw new Error("Missing Environment id");globalThis.UserLeap.envId=globalThis.UserLeap.appId}globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const n=Ru(),i=globalThis.UserLeap.sampleRate;let a=n.sampled;if(i){if(a===null&&(a=Math.random()<i,ke("sampled",a)),!a)return}else a!==null&&ke("sampled",null);globalThis.UserLeap._API_URL||(globalThis.UserLeap._API_URL="https://api.sprig.com");const o=[...globalThis.UserLeap._queue];globalThis.UserLeap._queue=new qf(globalThis.UserLeap,[]),globalThis.UserLeap._queue.pause();for(let C=0;C<o.length;C++)globalThis.UserLeap._queue.push(o[C]);const l=n.token;l?(globalThis.UserLeap.token=l,globalThis.UserLeap.visitorId=n.vid??null,globalThis.UserLeap.userId=n.uid??null,globalThis.UserLeap.partnerAnonymousId=n.aid??null):Lu();const c=mr(De(globalThis.UserLeap));(h=globalThis.SprigLoggerCallback)==null||h.call(globalThis,"Sprig fetching config");const u=await async function(C){var I,O;const m=De(globalThis.UserLeap);document.addEventListener("securitypolicyviolation",Ga);const g=await He(Me("1",[ot],"config"),{headers:m});if(document.removeEventListener("securitypolicyviolation",Ga),!g.ok)return(I=globalThis.SprigLoggerCallback)==null||I.call(globalThis,"Sprig config fetch failed"),g.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",g.error),g.error&&globalThis.UserLeap.reportError("applyRemoteConfig",g.error)),di("Disabled: failed to fetch configuration"),C;const v=g.json;return v!=null&&v.disabled?((O=globalThis.SprigLoggerCallback)==null||O.call(globalThis,"Sprig config fetch disabled"),di(`Disabled: ${v.disabled}`),{disabled:v.disabled}):Object.assign({},v,C)}(e);if((f=globalThis.SprigLoggerCallback)==null||f.call(globalThis,"Sprig fetched config"),rg({isWeb:!c,reportingIntervalSeconds:u.metricsReportingEnabled||u.mobileMetricsReportingEnabled?u.metricsReportingIntervalSeconds:0,thresholds:u.metricThresholds,postMetrics:async C=>{var m;await ze(Me("1",[ot],"metrics"),{body:C,method:"POST",headers:{"x-ul-replay-enabled":`${!!((m=re.replay)!=null&&m.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),!c){const C=u.alwaysOnReplay?{userAgent:globalThis.navigator.userAgent,surveyId:u.alwaysOnReplay.surveyId,responseGroupUuid:u.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.44.0",maxDurationSeconds:u.alwaysOnReplay.maxDurationSeconds}:void 0;await((w=re.replay)==null?void 0:w.initializeReplay({maxReplayDurationSeconds:u.maxReplayDurationSeconds,maxInflightRequests:globalThis.UserLeap.maxInflightReplayRequests??2,replaySettings:u.replaySettings,apiUrl:globalThis.UserLeap._API_URL,alwaysOnConfig:C})),oo=u.replaySettings}lg(u),await ag(u),globalThis.UserLeap._queue.unpause(),(p=globalThis.SprigLoggerCallback)==null||p.call(globalThis,"SdkReady"),z.emit(B.SDKReady,{mobileMetricsReportingEnabled:!!u.mobileMetricsReportingEnabled,metricsReportingInterval:u.metricsReportingIntervalSeconds||0,metricsThresholds:u.metricThresholds||[],maxMobileReplayDurationSeconds:u.maxMobileReplayDurationSeconds,mobileReplaySettings:u.mobileReplaySettings}),z.emit(B.VisitorIDUpdated,{visitorId:globalThis.UserLeap.visitorId}),z.on(B.VisitorIDUpdated,()=>{for(const C in Rs)delete Rs[C]})}globalThis.UserLeap.UPDATES=hr,globalThis.UserLeap("setPreviewKey",t),document.readyState==="complete"?r():globalThis.attachEvent?globalThis.attachEvent("onload",r):globalThis.addEventListener("load",()=>{r()},!1)}class Ls{constructor(){de(this,"UPDATES",hr)}displaySurvey(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"displaySurvey",t)}mute(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"mute")}unmute(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"unmute")}dismissActiveSurvey(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"dismissActiveSurvey")}setAttribute(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"setAttribute",t,r)}setAttributes(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setAttributes",t)}identifyAndSetAttributes(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"identifyAndSetAttributes",t)}removeAttributes(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"removeAttributes",t)}addListener(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"addListener",t,r)}removeListener(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"removeListener",t,r)}removeAllListeners(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"removeAllListeners")}setEmail(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setAttribute","!email",t)}setUserId(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setUserId",t)}setPartnerAnonymousId(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setPartnerAnonymousId",t)}track(t,r={},s={}){var n;(n=globalThis.Sprig)==null||n.call(globalThis,"track",t,r,s)}identifyAndTrack(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"identifyAndTrack",t)}trackPageView(t,r,s){var n;(n=globalThis.Sprig)==null||n.call(globalThis,"trackPageView",t,r,s)}applyStyles(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"applyStyles",t)}setWindowDimensions(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"setWindowDimensions",t,r)}logoutUser(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"logoutUser")}teardown(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"teardown")}pauseReplayRecording(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"pauseReplayRecording")}resumeReplayRecording(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"resumeReplayRecording")}}const dg={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",globalThis.Sprig)return globalThis.Sprig;globalThis.Sprig=function(){var r;(r=globalThis.Sprig)==null||r._queue.push(arguments)},Object.getOwnPropertyNames(Ls.prototype).map(r=>{r!=="constructor"&&(globalThis.Sprig[r]=Ls.prototype[r])});const t=globalThis.Sprig;return t.appId=e.envId,t._queue=[],globalThis.UserLeap=t,ug(e),globalThis.Sprig}},pg=new Ls;var at=(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))(at||{}),Ye=(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[e.CustomElement=16]="CustomElement",e))(Ye||{});const bi=(e,t)=>t.some(r=>e instanceof r);let sl,nl;const vi=new WeakMap,vn=new WeakMap,Os=new WeakMap;let Si={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return vi.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return lt(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&(t==="done"||t==="store")||t in e};function Au(e){Si=e(Si)}function hg(e){return(nl||(nl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Ii(this),t),lt(this.request)}:function(...t){return lt(e.apply(Ii(this),t))}}function mg(e){return typeof e=="function"?hg(e):(e instanceof IDBTransaction&&function(t){if(vi.has(t))return;const r=new Promise((s,n)=>{const i=()=>{n(t.error||new DOMException("AbortError","AbortError"))};t.oncomplete=()=>{s()},t.onerror=i,t.onabort=i});vi.set(t,r)}(e),bi(e,sl||(sl=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Si):e)}function lt(e){if(e instanceof IDBRequest)return function(r){const s=new Promise((n,i)=>{r.onsuccess=()=>{n(lt(r.result))},r.onerror=()=>{i(r.error)}});return Os.set(s,r),s}(e);if(vn.has(e))return vn.get(e);const t=mg(e);return t!==e&&(vn.set(e,t),Os.set(t,e)),t}const Ii=e=>Os.get(e);function Ci(e,{blocked:t}={}){const r=indexedDB.deleteDatabase(e);return t&&(r.onblocked=s=>t(s.oldVersion,s)),lt(r).then(()=>{})}const fg=["get","getKey","getAll","getAllKeys","count"],gg=["put","add","delete","clear"],Sn=new Map;function il(e,t){if(!(e instanceof IDBDatabase)||t in e||typeof t!="string")return;if(Sn.get(t))return Sn.get(t);const r=t.replace(/FromIndex$/,""),s=t!==r,n=gg.includes(r);if(!(r in(s?IDBIndex:IDBObjectStore).prototype)||!n&&!fg.includes(r))return;const i=async function(a,...o){const l=this.transaction(a,n?"readwrite":"readonly");let c=l.store;return s&&(c=c.index(o.shift())),(await Promise.all([c[r](...o),n&&l.done]))[0]};return Sn.set(t,i),i}Au(e=>({...e,get:(t,r,s)=>il(t,r)||e.get(t,r,s),has:(t,r)=>!!il(t,r)||e.has(t,r)}));const yg=["continue","continuePrimaryKey","advance"],ol={},ki=new WeakMap,Mu=new WeakMap,wg={get(e,t){if(!yg.includes(t))return e[t];let r=ol[t];return r||(r=ol[t]=function(...s){ki.set(this,Mu.get(this)[t](...s))}),r}};async function*bg(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const r=new Proxy(t,wg);for(Mu.set(r,t),Os.set(r,Ii(t));t;)yield r,t=await(ki.get(r)||t.continue()),ki.delete(r)}function al(e,t){return t===Symbol.asyncIterator&&bi(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&bi(e,[IDBIndex,IDBObjectStore])}Au(e=>({...e,get:(t,r,s)=>al(t,r)?bg:e.get(t,r,s),has:(t,r)=>al(t,r)||e.has(t,r)}));const vg="sprigReplayIframeLoaded",Sg="sprigReplayIframeSettings",Ig="sprigReplayIframeTakeFullSnapshot",Cg="sprigReplayTeardown",ao=[],Uu=new class{constructor(e){de(this,"awaitingResolvers",[]);de(this,"activeCount",0);this.capacity=e}async acquire(){if(!(this.activeCount<this.capacity))return new Promise(e=>{this.awaitingResolvers.push(e)});this.activeCount++}release(){const e=this.awaitingResolvers.shift();e&&this.activeCount<=this.capacity?e():this.activeCount--}async execute(e){try{return await this.acquire(),await e()}finally{this.release()}}setLimit(e){this.capacity=e}}(2),Du=async({apiUrl:e,surveyId:t,uploadId:r,etags:s,headers:n,responseGroupUuid:i,replayDuration:a,eventDigest:o},l=!1)=>{var u;if(!l&&!r&&!s)return void _.error("UploadErr",{isMobile:l,uploadId:r,etags:s});_.info("MarkUploadComplete",{surveyId:t});const c=await He(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:s,uploadId:r,responseGroupUuid:i,surveyId:t,replayDuration:a,eventDigest:o,userAgent:(u=window==null?void 0:window.navigator)==null?void 0:u.userAgent}),headers:n,shouldRetryRequest:!0});return _.info("MarkUploadDone",{surveyId:t}),c},kg=e=>{if(e instanceof Attr)return null;let t=1;for(let r=e.previousSibling;r;r=r.previousSibling)r.nodeName===e.nodeName&&++t;return t},Pu=e=>{if(e===null)return"";const t=[];if(e instanceof Document)return"/";for(let r=e;r&&!(r instanceof Document)&&r!==null;r=r instanceof Attr?r.ownerElement:r.parentElement){const s=t[t.length]={name:void 0,position:null};switch(r.nodeType){case Node.TEXT_NODE:s.name="text()";break;case Node.ATTRIBUTE_NODE:s.name="@"+r.nodeName;break;case Node.PROCESSING_INSTRUCTION_NODE:s.name="processing-instruction()";break;case Node.COMMENT_NODE:s.name="comment()";break;case Node.ELEMENT_NODE:s.name=r.nodeName}s.position=kg(r)}return"/"+t.reverse().map(r=>r.position!==null?`/${r.name}[${r.position}]`:`/${r.name}`).join("")},lo=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),_u=(e,t)=>{let r;return s=>{clearTimeout(r),r=window.setTimeout(()=>e(s),t)}},We={capture:!0,passive:!0},Eg=["a","button","input","option","li","link"],xg=["Escape","Enter","Backspace","F5","Tab"];let As=!1,xe=null,ps=null;const ll=e=>{var r;if(((r=e.tagName)==null?void 0:r.toLowerCase())==="html")return{element:"html"};const t={};return t.element=(s=>{if(!s.tagName)return"No tagName";const n=s.getAttribute("type");return n?`${n} ${s.tagName.toLowerCase()}`:s.tagName.toLowerCase()})(e),t},Tg=e=>{var s;if(!e)return{};const t={...ll(e)},r=e.parentElement;if(r&&Eg.includes((s=r.tagName)==null?void 0:s.toLowerCase())){const n=ll(r);Object.assign(t,n)}return t},Nu=(e,t)=>{var n,i;let r=t.target;var s;t.target===((n=window.document)==null?void 0:n.body)&&window.Sprig.pointerDownTarget&&(r=window.Sprig.pointerDownTarget),s={x:t.x,y:t.y,type:e,elementAttributes:Tg(r),windowHeight:window.innerHeight,windowWidth:window.innerWidth,...r instanceof HTMLElement||r instanceof SVGElement||r instanceof MathMLElement?{rect:r==null?void 0:r.getBoundingClientRect(),xPath:Pu(r)}:{}},(i=s==null?void 0:s.elementAttributes)!=null&&i.text&&(s.elementAttributes.text=lo(s.elementAttributes.text)),xe==null||xe("Sprig_Click",s)},Fu=e=>{var t;xg.includes(e.key)&&(t={key:e.key},xe==null||xe("Sprig_Keystroke",t))},Rg=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("reload")&&(e={url:window.location.href,currentPageTitle:document.title},xe==null||xe("Sprig_Refresh",e))},Lg=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("back_forward")&&((e={curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title}).currentPageTitle&&(e.currentPageTitle=lo(e.currentPageTitle)),xe==null||xe("Sprig_BackForward",e))},Bu=_u(e=>{if(!(e.target instanceof HTMLElement||e.target instanceof Document))return;let t=e.target;"scrollTop"in t||(t=t.documentElement),ps==null||ps({xPath:Pu(t),x:t.scrollLeft,y:t.scrollTop,elementAttributes:{targetScrollWidth:t.scrollWidth,targetClientWidth:t.clientWidth,targetScrollHeight:t.scrollHeight,targetClientHeight:t.clientHeight}})},750),zu=(cl="left_click",e=>Nu(cl,e));var cl;const ju=e=>{e.button===2&&Nu("right_click",e)},Wu=e=>{window.Sprig&&(window.Sprig.pointerDownTarget=e.target)},pe={isRecording:!1,scrollEventUuids:{},stopRecording:()=>{}},Vu=()=>globalThis.indexedDB&&globalThis.IDBKeyRange&&globalThis.CompressionStream,be=(()=>{const e=Q.getItem("sprig.sessionId");if(e)return _.info("SessionIDFound",{savedSessionId:e}),Q.removeItem("sprig.sessionId"),e;const t=bt();return _.info("GeneratedSessionID",{uuid:t}),t})(),Ei=()=>{Q.setItem("sprig.disableReplayRecording","disabled")},Ge=()=>!!Q.getItem("sprig.disableReplayRecording"),Ms=()=>!!Q.getItem("sprig.isReplayPaused");var pl;(pl=globalThis.addEventListener)==null||pl.call(globalThis,"beforeunload",()=>{_.info("BeforeUnload",{sessionId:be}),Q.setItem("sprig.sessionId",be)});const Je=(e,t)=>{var r,s;if(!Ge()&&pe.isRecording&&!Ms())try{(s=(r=globalThis.rrwebRecord)==null?void 0:r.addCustomEvent)==null||s.call(r,e,t)}catch(n){vr("Error recording custom event",n)}},Og=async e=>{const{x:t,xPath:r,y:s}=e,n=pe.scrollEventUuids[r];if(n)return Ee(async()=>{var o,l,c,u;const i=await se.openDB(),a=await i.get("events",n);if(a!=null&&a.event){const d=JSON.parse(a.event),h=t>((l=(o=d.data)==null?void 0:o.payload)==null?void 0:l.x),f=s>((u=(c=d.data)==null?void 0:c.payload)==null?void 0:u.y);if(!h&&!f)return null;h&&(d.data.payload.x=t),f&&(d.data.payload.y=s),d.data.payload.elementAttributes=e.elementAttributes,a.event=JSON.stringify(d),await i.put("events",a)}else Je("Sprig_Scroll",e)},"Error updating scroll event");Je("Sprig_Scroll",e)},Hu=()=>{pe.stopRecording&&(pe.stopRecording(),pe.stopRecording=void 0),pe.isRecording=!1,["cleanupInterval","inactivityInterval","pendingCheckInterval"].forEach(e=>{pe[e]&&(clearInterval(pe[e]),pe[e]=void 0)}),As&&(window.removeEventListener("click",zu,We),window.removeEventListener("pointerdown",Wu,We),window.removeEventListener("mousedown",ju,We),window.removeEventListener("keydown",Fu,We),window.removeEventListener("scroll",Bu,We),As=!1),ao.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:Cg},{targetOrigin:e.origin})})},Ag=["did not allow mutations","called in an invalid security context"],Mg=(e,t,{reportError:r=!0,extraInfo:s={}})=>{if(!Ge()&&t instanceof Error){if(Ei(),t.name==="VersionError")return _.error("VersionErr",{message:e}),void se.deleteDB();(n=>{if(!n)return!0;for(const i of Ag)if(n.toLowerCase().includes(i))return!1;return!0})(t==null?void 0:t.message)&&(r&&globalThis.UserLeap.reportError(e,t,s),se.clearAll())}},vr=(e,t,{reportError:r}={reportError:!0})=>{Hu(),_.error("ReplayErr",{code:t.code,name:t.name}),Mg(e,t,{reportError:r})},Ee=async(e,t)=>{try{return await e()}catch(r){vr(t,r)}},xi=()=>{pe.isRecording&&(Ee(()=>{var e,t;return(t=(e=globalThis.rrwebRecord)==null?void 0:e.takeFullSnapshot)==null?void 0:t.call(e,!0)},"Error recording full snapshot"),ao.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:Ig},{targetOrigin:e.origin})}))};let In=0;(async()=>Vu()&&Promise.allSettled([Ci("replayStorage"),Ci("sprig.replay")]))();const se=new class{constructor(){de(this,"wrapTransactionWithCounter",e=>{var s,n;const t=(n=(s=window.Sprig)==null?void 0:s._config)==null?void 0:n.outstandingTransactionLimit,r=t===void 0?100:t;if(r&&In>r){const i="Too many outstanding transactions";vr(i,new Error(i),{reportError:!1})}In++,e.done.finally(()=>{In--})});de(this,"getTransaction",async e=>{const t=(await this.openDB()).transaction(e,"readwrite");return this.wrapTransactionWithCounter(t),t})}openDB(){return function(e,t,{blocked:r,upgrade:s,blocking:n,terminated:i}={}){const a=indexedDB.open(e,t),o=lt(a);return s&&(a.onupgradeneeded=l=>{s(lt(a.result),l.oldVersion,l.newVersion,lt(a.transaction),l)}),r&&(a.onblocked=l=>r(l.oldVersion,l.newVersion,l)),o.then(l=>{i&&(l.onclose=()=>i()),n&&(l.onversionchange=c=>n(c.oldVersion,c.newVersion,c))}).catch(()=>{}),o}("sprigReplay",1,{upgrade:(e,t,r)=>{if(r===0&&Q.setItem("sprig.pendingCount","0"),!e.objectStoreNames.contains("events")){const s=e.createObjectStore("events",{keyPath:"uuid"});s.createIndex("sessionId","sessionId"),s.createIndex("timestamp","timestamp"),s.createIndex("[sessionId+timestamp]",["sessionId","timestamp"])}if(!e.objectStoreNames.contains("chunkUploads")){const s=e.createObjectStore("chunkUploads",{keyPath:"uuid"});s.createIndex("sessionId","sessionId"),s.createIndex("timestamp","timestamp"),s.createIndex("[sessionId+status]",["sessionId","status"]),s.createIndex("[uploadId+status]",["uploadId","status"]),s.createIndex("[sessionId+status+uploadId]",["sessionId","status","uploadId"])}if(!e.objectStoreNames.contains("pendingCaptures")){const s=e.createObjectStore("pendingCaptures",{keyPath:"uuid"});s.createIndex("sessionId","sessionId"),s.createIndex("timestamp","timestamp"),s.createIndex("[sessionId+targetTimestamp]",["sessionId","targetTimestamp"])}}})}async deleteDB(){try{await Ci("sprigReplay")}catch{}}async bulkAdd(e,t){const r=await this.getTransaction(e);return Promise.all([...t.map(s=>r.store.add(s)),r.done])}async clearAll(){const e=(await this.openDB()).transaction(["events","chunkUploads","pendingCaptures"],"readwrite");return this.wrapTransactionWithCounter(e),Promise.all([e.objectStore("events").clear(),e.objectStore("chunkUploads").clear(),e.objectStore("pendingCaptures").clear()])}async deleteBySessionId(e,t){const r=IDBKeyRange.only(t),s=await this.getTransaction(e),n=s.store.index("sessionId");for await(const i of n.iterate(r))await i.delete();await s.done}async updatePartial(e,t,r){const s=await this.getTransaction(e),n=await s.store.get(t);n&&await s.store.put({...n,...r}),await s.done}async deleteRowsBefore(e,t,r=()=>!0){const s=IDBKeyRange.upperBound(t,!0),n=await this.getTransaction(e),i=n.store.index("timestamp");for await(const a of i.iterate(s))r(a.value)&&await a.delete();await n.done}async getEventsBetween(e,t=Date.now()){if(e>=t)return Promise.resolve([]);const r=IDBKeyRange.bound([be,e],[be,t],!1,!0);return(await this.openDB()).getAllFromIndex("events","[sessionId+timestamp]",r)}async updateEventsExpiredAt(e,t,r=30){const s=new Date,n=s.setMinutes(s.getMinutes()+(r??30)),i=await this.getTransaction("events"),a=i.store.index("[sessionId+timestamp]"),o=IDBKeyRange.bound([be,e],[be,t],!1,!0);for await(const l of a.iterate(o))await l.update({...l.value,expiredAt:n});await i.done}async deleteChunkUploads(e,t){const r=IDBKeyRange.only([t,e]),s=await this.getTransaction("chunkUploads");let i=await s.store.index("[uploadId+status]").openCursor(r);for(;i;)i.delete(),i=await i.continue();await s.done}async getChunkUploadsByStatus({sessionId:e,status:t,uploadId:r}){const s=(await this.openDB()).transaction("chunkUploads","readonly");this.wrapTransactionWithCounter(s);const n=r?s.store.index("[uploadId+status]"):s.store.index("[sessionId+status]"),i=r?IDBKeyRange.only([r,t]):IDBKeyRange.only([e,t]);return n.getAll(i)}async getPendingCaptures(e={}){return(await(await this.openDB()).getAllFromIndex("pendingCaptures","sessionId",be)).filter(r=>!e.beforePresent||r.targetTimestamp<Date.now()).filter(r=>!e.isBeforeType||r.captureParams.replayParams.replayDurationType==="before").filter(r=>!e.isHeatmap||(r.captureParams.isHeatmap??!1))}async tryAddPendingCaptureForSurvey(e){const{surveyId:t,record:r}=e,s=(await this.openDB()).transaction("pendingCaptures","readwrite");this.wrapTransactionWithCounter(s);const n=s.store.index("sessionId"),i=await n.getAll(be),a=!!r.captureParams.isHeatmap;return i.some(o=>o.captureParams.surveyId===t&&!!o.captureParams.isHeatmap===a)?(await s.done,{added:!1}):(await s.store.add(r),await s.done,{added:!0})}async markPendingCaptureToCanUpload(e){const t=await this.getTransaction("pendingCaptures"),r=t.store.index("sessionId");for await(const s of r.iterate(be)){const n=s.value;n.captureParams.responseGroupId===e&&await s.update({...n,canUpload:!0})}await t.done}async markPendingHeatmapsReady(e){if(parseInt(Q.getItem("sprig.pendingCount")??"0")===0)return null;const t=Date.now(),r=await this.getTransaction("pendingCaptures"),s=r.store.index("sessionId");for await(const n of s.iterate(be)){const i=n.value;!i.captureParams.isHeatmap||e&&!e.includes(i.uuid)||await n.update({...i,targetTimestamp:t,captureParams:{...i.captureParams,triggerTimestamp:t,replayParams:{...i.captureParams.replayParams,replayDurationSeconds:Math.floor((t-i.timestamp)/1e3)}}})}await r.done}},Qe=[];let Sr,Gu,gt=[],Dt=!1,Ut=0,hs=!1,$u=!1;const co=[];let Us,Yu,ms,qu,Cn=!1;const Pt=()=>hs&&!Dt&&Date.now()<=Us,Ug=({apiUrl:e,config:t,triggerSnapshot:r,forceInit:s=!1})=>{hs&&!s||(Q.isStorageAvailable?(gt=[],co.splice(0),Qe.splice(0),Ut=0,ms=r,Gu=e,Sr={responseGroupUuid:t.responseGroupUuid,surveyId:t.surveyId,userAgent:t.userAgent,sdkVersion:t.sdkVersion},Yu=t.maxDurationSeconds,Ng(),hs||(qu=globalThis.setInterval(_g,500)),hs=!0):Dt=!0)},Dg=[Ye.Drag,Ye.Input,Ye.MediaInteraction,Ye.MouseInteraction,Ye.MouseMove,Ye.Scroll,Ye.Selection,Ye.TouchMove],Pg=e=>e.type===at.Custom||e.type===at.IncrementalSnapshot&&Dg.includes(e.data.source),uo=e=>e.some(Pg),_g=async()=>{if(!Pt())return void globalThis.clearInterval(qu);if(Ju(),!uo(Qe))return;const e=Qe[0].timestamp;Date.now()-e>35e3&&(ms==null||ms())},Ju=async()=>{if(gt.length||Cn)return;Cn=!0;const e=await Bg();if(!e)return void(Dt=!0);co.splice(0,e.length).forEach(t=>t(e.shift())),e.forEach(t=>gt.push(t)),Cn=!1},Ng=()=>{const e=Q.getItem("sprig.alwayson.info");if(e){_.info("Read stored session state",e);const t=JSON.parse(e);Dt=t.disabled,Sr=t.metadata,gt=t.uploadUrls,Ut=t.currentIndex,Us=t.expirationTimestamp,t.pendingEventTimestamp&&(_.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`),Fg(t.pendingEventTimestamp))}else Us=1e3*Yu+Date.now()},Fg=async e=>{const t=Date.now(),r=(await se.getEventsBetween(e,t)).map(n=>JSON.parse(n.event));if(!uo(r))return;Qu(r);const s=await Zu();s&&await Xu(s,r)},Ku=async(e,t)=>{try{const r=await e();if(!r.ok)throw new Error(`Error ${t}`);return r}catch{Dt=!0}},Xu=async(e,t)=>{if(!Pt()||!e)return;const r=await(async s=>{const n=new TextEncoder,i=new CompressionStream("gzip"),a=i.writable.getWriter(),o=n.encode(JSON.stringify(s));return a.write(o),a.close(),new Uint8Array(await new Response(i.readable).arrayBuffer())})(t);_.info("Uploading always-on events with presigned url"),await Ku(()=>He(e,{body:r,method:"PUT"}),"uploading always-on with presigned url")},Bg=async()=>{if(!Pt())return;const{surveyId:e,responseGroupUuid:t}=Sr,r={responseGroupUuid:t,surveyId:e,index:Ut+1};_.info("Fetching always-on upload urls",r);const s=await Ku(()=>He(`${Gu}/sdk/1/replayUrls`,{method:"POST",body:JSON.stringify(r),headers:De(globalThis.UserLeap)}),"fetching always-on signed urls");if(!s)return;const n=s.json.signedUrls;return _.info("Fetched more always-on upload urls",{body:r,urls:n}),n},Zu=async()=>{if(gt.length)return gt.shift();const e=new Promise(t=>{co.push(t)});return Ju(),e},Qu=e=>{var n,i,a;const t=e.length?e[e.length-1].timestamp:Date.now(),r=Ut,s=((i=(n=globalThis.UserLeap)==null?void 0:n.config)==null?void 0:i.customMetadata)??((a=globalThis.__cfg)==null?void 0:a.customMetadata);Ut++,e.push({timestamp:t,type:at.Custom,data:{tag:"Sprig_Meta",payload:{...Sr,index:r,visitorId:globalThis.UserLeap.visitorId??"",timestamp:t,customMetadata:s}}})},zg=(e,t)=>{Pt()&&!$u&&(e||Qe.length)&&(e&&Qe.length&&(async()=>{const r=Qe.splice(0);if(!uo(r))return;_.info("Capturing always-on event array to upload"),Qu(r);const s=await Zu();s&&await Xu(s,r)})(),Qe.push(t))};var hl;(hl=globalThis.addEventListener)==null||hl.call(globalThis,"beforeunload",async()=>{$u=!0,Pt()&&(_.info("Always On handle page unload"),(()=>{let e;Qe.length&&(e=Qe[0].timestamp);const t={disabled:Dt,metadata:Sr,uploadUrls:gt,currentIndex:Ut,pendingEventTimestamp:e,expirationTimestamp:Us};_.info("Storing session state on unload",t),Q.setItem("sprig.alwayson.info",JSON.stringify(t))})())});const ed=async(e,t)=>{const r=performance.now();let s;try{s=await e()}finally{const n=performance.now()-r;let i=br[t];i||(i=Ve(t)),i.report(n/1e3)}return s},td=(e,t)=>{const r=performance.now();try{e()}finally{const s=performance.now()-r;let n=br[t];n||(n=Ve(t)),n.report(s/1e3)}};let rd=5e3,Ti=6e4,Ri=0,ct,Li=!1,Oi=[];const jg=e=>{var t,r,s,n;if((t=e.event)!=null&&t.includes("Sprig_Scroll")){const i=(n=(s=(r=JSON.parse(e.event))==null?void 0:r.data)==null?void 0:s.payload)==null?void 0:n.xPath;if(!i)return;pe.scrollEventUuids[i]=e.uuid}Oi.push(e),Li||Wg()},Wg=()=>{Li=!0,setTimeout(async()=>{if(Ge()||Ms())return;const e=Oi;Oi=[],Li=!1,td(async()=>{await(async t=>{const r=t.map(s=>({...s,sessionId:s.sessionId??be}));if(r.length!==0)return Ee(()=>se.bulkAdd("events",r),"Error storing replay events")})(e)},"sdk_replay_add_event_batch_seconds")},500)},Vg=(e,t,r)=>{pe.cleanupInterval=window.setInterval(()=>{const s=Date.now();ed(()=>Ee(async()=>{Ge()||await Promise.all([se.deleteRowsBefore("events",s-1e3*e,n=>n.expiredAt===void 0||n.expiredAt<s-1e3*e),se.deleteRowsBefore("chunkUploads",s-1e3*t),se.deleteRowsBefore("pendingCaptures",s-1e3*r,n=>!n.canUpload)])},"Error deleting table rows"),"sdk_replay_cleanup_seconds"),_.debug("CleanupComplete")},3e4)},Hg=()=>{pe.pendingCheckInterval=window.setInterval(async()=>{Ee(async()=>{await Ai()},"Error initiating pending captures")},5e3)};let kn=!1;const Ai=async(e=!1)=>{if(!kn)try{kn=!0;const t=parseInt(ct??"0");if(t===0)return;const r=await se.getPendingCaptures({beforePresent:!0,isBeforeType:e}),s=await se.openDB();await Promise.all(r.map(async n=>(await s.delete("pendingCaptures",n.uuid),id(n.captureParams,n.canUpload)))),ct=(t-r.length).toString(),Q.setItem("sprig.pendingCount",ct)}finally{kn=!1}},Gg=async(e,t,r,s,n)=>{const i=Math.min(e+n,r),a=await ed(()=>se.getEventsBetween(e,i),"sdk_replay_get_events_between_seconds");if(!(a!=null&&a.length))return _.debug("NoEventsFound"),{validStartFound:s,events:[]};if(!s){_.debug("ValidStartSearch");let o=-1;return a==null||a.forEach((l,c)=>{if(!l.isValidStart)return;const u=l.timestamp<=t;(o<0||u)&&(o=c)}),o<0?(_.debug("ValidStartNotFound"),{validStartFound:s,events:[]}):{validStartFound:!0,events:a==null?void 0:a.slice(o)}}return{validStartFound:s,events:a}},sd=e=>Promise.all(e.map(async t=>{const r=await(async s=>Uu.execute(async()=>{var a;_.info("UploadChunkStart",{chunkIndex:s.chunkIndex,surveyId:s.surveyId});const n=await He(s.uploadUrl,{body:s.data,method:"PUT"});_.http("UploadChunkEnd",{url:s.uploadUrl,method:"PUT",status_code:n.status,reason:n.statusText??"OK",chunkIndex:s.chunkIndex,surveyId:s.surveyId});const i=(a=n.headers)==null?void 0:a.get("ETag");if(!i)throw new Error(`Upload response did not include etag for upload ${s.uploadId}, part ${s.chunkIndex}`);return i}))(t);return await se.updatePartial("chunkUploads",t.uuid,{data:null,etag:r,status:"UploadComplete"}),t.uploadId})),nd=async e=>{const t=await se.getChunkUploadsByStatus({status:"UploadComplete",uploadId:e});if(!(t!=null&&t.length))return void _.info("NoChunksForUpload",{uploadId:e});const r=t.reduce((i,a)=>(i.find(o=>o.chunkIndex===a.chunkIndex)||i.push(a),i),[]);r.sort((i,a)=>i.chunkIndex-a.chunkIndex);const s=r.map(i=>({ETag:i.etag,PartNumber:i.chunkIndex})).filter(i=>i.ETag!==null),n=r[0];await Du({apiUrl:n.apiUrl,surveyId:n.surveyId,uploadId:e,responseGroupUuid:n.responseGroupId,etags:s,headers:n.completeUploadHeaders,replayDuration:n.replayDuration}),await se.deleteChunkUploads("UploadComplete",e)},$g=()=>{Ee(async()=>{const e=await se.getChunkUploadsByStatus({sessionId:be,status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await sd(e);t!=null&&t.length&&await Promise.all(t.map(r=>{if(r)return nd(r)}))},"Error uploading unfinished chunks")},Yg=async(e,t)=>{const r=t??Date.now();return(async(s,n)=>{const i=new TextEncoder;let a=null;const o=new CompressionStream("gzip"),l=o.writable.getWriter();let c=!1,u=!1,[d,h]=[0,0],f=[];for(let p=s-35e3;p<n;p+=Ti){if({validStartFound:u,events:f}=await Gg(p,s,n,u,Ti),!(f!=null&&f.length)){_.debug("NoEventsFound");continue}d===0&&(d=f[0].timestamp),h=f[f.length-1].timestamp;const C=f.map(v=>v.event);C.push(`{"timestamp":${n}}`);const m=`${c?",":"["}${C}`,g=i.encode(m);td(()=>{l.write(g)},"sdk_replay_compression_seconds"),c=!0}if(h-d<rd)return _.debug("ReplayTooShort"),null;const w=i.encode("]");return l.write(w),l.close(),a=new Uint8Array(await new Response(o.readable).arrayBuffer()),a})(r-e,r)},ul=async e=>{const{surveyId:t,responseGroupId:r,visitorId:s,apiUrl:n,completeUploadHeaders:i,replayParams:a,triggerTimestamp:o}=e,l=await Yg(1e3*a.replayDurationSeconds,o);if(!(l!=null&&l.length))return void _.info("FileDataEmpty",{surveyId:t});const c=((d,h,f)=>{const w=d.length,p=1024*h*1024,C=Math.ceil(w/f),m=Math.max(p,C),g=[];let v=0;for(;v<w;)g.push(d.slice(v,v+m)),v+=m;return g})(l,a.minimumChunkSizeMb,a.signedUrls.length),u=await Promise.all(c.map(async(d,h)=>{const f=bt(),w={apiUrl:n,chunkIndex:h+1,completeUploadHeaders:i,etag:null,responseGroupId:r,status:"ReadyForUpload",surveyId:t,timestamp:o,totalChunks:c.length,data:d,uploadId:a.uploadId,uploadUrl:a.signedUrls[h].url,uuid:f,visitorId:s};return await(await se.openDB()).add("chunkUploads",{...w,sessionId:w.sessionId??be}),w}));await(async(d,h)=>{await sd(h),await Promise.all(d.map(f=>nd(f)))})([a.uploadId],u)},id=async(e,t)=>{if(Ge())return _.debug("ReplayDisabled-ScheduleOrCapture");const{isHeatmap:r,isStandalone:s,replayParams:n,triggerTimestamp:i,responseGroupId:a}=e,o=async()=>{setTimeout(()=>z.removeListener(B.QuestionAnswered,o),0),Ee(async()=>{n.replayDurationType==="before"?await ul(e):await se.markPendingCaptureToCanUpload(a)},"Error in schedule/capture callback")};Ee(async()=>{if(n.replayDurationType==="after"||n.replayDurationType==="beforeAndAfter")return!s&&!r&&z.on(B.QuestionAnswered,o),void await ad(e);if(s||r||t)await ul(e),r&&qg();else{const l=35+n.replayDurationSeconds,c=i-1e3*l,u=i;await se.updateEventsExpiredAt(c,u,n.expirationTimeLimitMinutes),z.on(B.QuestionAnswered,o)}},"Error in scheduling/capturing replay")},qg=async()=>{parseInt(ct??"0")||Q.removeItem("sprig.isCapturingHeatmap"),Q.getItem("sprig.teardownAfterCapture")&&(Hu(),od(),Q.removeItem("sprig.teardownAfterCapture"))},od=async()=>Ge()?_.debug("ReplayDisabled-ClearData"):Promise.all([se.deleteBySessionId("events",be),se.deleteBySessionId("pendingCaptures",be)]).catch(e=>{vr("Error clearing user replay data",e)}),ad=async e=>{if(Ge())return;const{isHeatmap:t,surveyId:r}=e,s={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(s.replayParams.replayDurationSeconds*=2),s.replayParams.replayDurationType="before";const n=e.triggerTimestamp+1e3*e.replayParams.replayDurationSeconds;s.triggerTimestamp=n;const i={canUpload:!1,captureParams:s,sessionId:be,targetTimestamp:n,timestamp:Date.now(),uuid:bt()},{added:a}=await se.tryAddPendingCaptureForSurvey({surveyId:r,record:i});a?(ct=(parseInt(ct??"0")+1).toString(),Q.setItem("sprig.pendingCount",ct),t&&(xi(),Q.setItem("sprig.isCapturingHeatmap","true"),Ri=Date.now(),pe.inactivityInterval||(pe.inactivityInterval=window.setInterval(()=>{var o;o=Ri,Date.now()-o>=3e4&&Ee(()=>se.markPendingHeatmapsReady(),"Error in heatmap inactivity")},1e3)))):_.info("PendingCaptureExists",{surveyId:r})},Jg=Object.freeze(Object.defineProperty({__proto__:null,RecordEvent:e=>{Je("Sprig_TrackEvent",e)},RecordPageView:e=>{e.description&&(e.description=lo(e.description)),Je("Sprig_PageView",e)},RecordSurveyShown:e=>{Je("Sprig_ShowSurvey",e)},_completeSessionReplay:async({surveyId:e,responseGroupUuid:t,eventDigest:r,headers:s})=>{if(!e||!t)return!1;const n=globalThis.UserLeap._API_URL,i=await Du({surveyId:e,responseGroupUuid:t,eventDigest:r,apiUrl:n,headers:s},!0);return!(i!=null&&i.error)},checkPendingHeatmapsUrl:()=>Ge()?_.debug("ReplayDisabled-PendingHeatmaps"):Ee(async()=>{const e=(await se.getPendingCaptures({isHeatmap:!0})).map(t=>({eventId:t.captureParams.eventId,uuid:t.uuid})).filter(({eventId:t})=>!hu(t)).map(({uuid:t})=>t);return _.info("PendingHeatmapsToComplete",{count:e.length}),e.length&&(await se.markPendingHeatmapsReady(e),_.info("MarkedPendingHeatmapsReady")),e.length},"Error marking pending heatmaps ready"),clearUserReplayData:od,disableRecording:vr,initializeReplay:async({maxReplayDurationSeconds:e,maxInflightRequests:t=2,replaySettings:r,teardownAfter:s=!1,apiUrl:n,alwaysOnConfig:i})=>{if(i&&Ug({apiUrl:n,config:i,triggerSnapshot:()=>{xi()}}),ct=Q.getItem("sprig.pendingCount"),pe.isRecording)return;if(s&&Q.setItem("sprig.teardownAfterCapture","true"),Ge())return _.debug("ReplayDisabled");if(await(async()=>{var l;if(!Vu())return!0;if((l=globalThis.navigator.storage)!=null&&l.estimate)try{const{quota:c=0,usage:u=0}=await globalThis.navigator.storage.estimate(),d=(c-u)/1024**3;return _.info("Storage",{availableGb:d}),d<.5}catch{return!0}return!1})())return _.debug("IDBNotSupported"),Ei();try{const l=await se.openDB();_.info("DBVersion",{version:l.version})}catch(l){return _.error("ReplayOpenErr",{name:l.name}),l.name==="VersionError"&&se.deleteDB(),Ei()}Ee(async()=>{await Ai(!0)},"Error uploading ready pending captures");const a=Pt()?30:0,o=Math.max(e??0,a);if(!o)return _.debug("MissingDuration");_.debug("ReplayInit"),await Ee(async()=>{var l;r!=null&&r.minDuration&&(rd=r.minDuration),r!=null&&r.batchDuration&&(Ti=r.batchDuration),l=t,Uu.setLimit(l),$g(),Vg(o+35,1800,o+35),Hg();const c=window.UserLeap.replayLibraryURL??"https://cdn.sprig.com/dependencies/record.min.js",u=window.rrwebRecord;if(!u)return _.error("RecordScriptFailed");let d=!0,h=0;const f={checkoutEveryNms:3e4,sampling:{input:"last",scroll:250,media:800},...r,mutationQueueEnabled:r==null?void 0:r.enableMutationQueue};var w,p;pe.stopRecording=u({emit:(C,m)=>{if(C.type===at.Custom&&(Ri=Date.now()),Ge()||Ms())return;if(m&&C.type===at.Meta)h=performance.now();else if(m&&h&&C.type===at.FullSnapshot){const v=performance.now()-h;Su("sdk_replay_snapshot_seconds",v/1e3)}const g=d||!!m&&C.type===at.Meta;d=!1,zg(g,C),jg({uuid:bt(),event:JSON.stringify(C),isValidStart:g,timestamp:Date.now()})},...f}),pe.isRecording=!!pe.stopRecording,pe.isRecording&&(((C,m)=>{window.addEventListener("message",g=>{var v;g.data.type===vg&&(ao.push({source:g.source,origin:g.origin}),(v=g.source)==null||v.postMessage({type:Sg,settings:C,replayLibraryUrl:m},{targetOrigin:g.origin}))})})(f,c),z.on("survey.complete",C=>{var m;m={id:C,userAgent:window.navigator.userAgent},Je("Sprig_SubmitSurvey",m)}),w=Je,p=Og,As||(xe=w,ps=p,window.addEventListener("click",zu,We),window.addEventListener("pointerdown",Wu,We),window.addEventListener("mousedown",ju,We),window.addEventListener("keydown",Fu,We),window.addEventListener("scroll",Bu,We),As=!0,Rg(),Lg()))},"Error initializing replay")},isReplayPaused:Ms,isReplayRecording:()=>pe.isRecording,recordFullSnapshot:xi,recordReplayPaused:()=>{Je("Sprig_ReplayPaused",{timestamp:Date.now()}),Q.setItem("sprig.isReplayPaused","true")},recordReplayResumed:()=>{Q.removeItem("sprig.isReplayPaused"),Je("Sprig_ReplayResumed",{timestamp:Date.now()})},scheduleCapture:ad,scheduleOrCaptureReplay:id,tryReplayAction:Ee,uploadReadyPendingCaptures:Ai},Symbol.toStringTag,{value:"Module"}));(e=>{re.replay=e})(Jg),window.UpChunk={createUpload:Yd},window.rrwebRecord=qt,exports.APP_ID="ul-app",exports.ConflictingWidgets=ru,exports.DEFAULT_BORDER_COLOR="#e6e6e6",exports.DEFAULT_WIDTH_PX=360,exports.DismissReason=Ae,exports.EMBED_MOBILE_MAX_WIDTH=1030,exports.ERROR_BORDER_COLOR="#bd282a",exports.Sprig=pg,exports.SprigAPI=Ls,exports.SprigEvent=B,exports.breadcrumbsLogger=_,exports.calculateFrameDimensions=mu,exports.debounce=_u,exports.eventEmitter=z,exports.getHtml=Js,exports.groupCards=(e,t)=>{const r=[e[t]],s=e[t].groupId;return s?e.slice(t).reduce((n,i)=>(i.groupId===s&&n.push(i),n),[]):r},exports.isHTMLElement=qe,exports.isLongFormSurvey=e=>e==="longFormSurvey",exports.resetScrollPosition=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},exports.setSurveyStyles=fr,exports.shouldDirectEmbed=to,exports.sprig=dg,exports.sprigFetch=He,exports.v4=bt;
|
|
66
|
+
</svg>`,(r=window.UserLeap._config)==null?void 0:r.enableCspTrustedTypes);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},mi=new class{constructor(){de(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!(!e||typeof e!="object"||Array.isArray(e))&&(Object.keys(this._ldData).forEach(t=>{delete this._ldData[t]}),Object.keys(e).forEach(t=>this._ldData[`!launch_darkly_${t}`]=(e[t]??0)+1),!0)}catch(t){return t instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",t),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(mi);const ds=new class{constructor(){de(this,"_optimizelyData",{})}setOptimizelyExperiment(e,t=!0){if(!e||typeof e!="object")return!1;const{experiments:r}=e;try{return t&&Object.keys(this._optimizelyData).map(s=>{delete this._optimizelyData[s]}),r&&r.map(s=>{const{id:n,variation:i}=s,a=this.transformExperimentId(n);i&&typeof i=="string"&&(this._optimizelyData[a]=i)}),!0}catch(s){return s instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",s),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return"!optimizely_experiments_"+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const t=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(t){const r=Object.keys(t).map(s=>{var n,i;return(n=t[s].variation)!=null&&n.name?{id:s,variation:(i=t[s].variation)==null?void 0:i.name}:{id:s,variation:"Original"}});return this.setOptimizelyExperiment({experiments:r},!1),!0}return!1}return!1}catch(t){return t instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",t),!1}}};Object.freeze(ds);class qf{constructor(t,r){de(this,"paused");de(this,"queue");de(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(r)}flush(t){const r=t.length;if(r)for(let s=0;s<r;s++)this.push(t[s])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const t=this.queue.slice();this.empty(),this.flush(t)}push(t){if(this.paused)this.queue.push(t);else if(t instanceof Function)t();else{const r=Array.prototype.slice.call(t,1),s=t[0],n=this.ul[s];n instanceof Function?n.apply(this.ul,r):s&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",s)}}perform(t){if(this.paused){let r=()=>{};const s=new Promise(function(n){r=function(){n(t())}});return this.queue.push(r),s}return t()}empty(){this.queue.length=0}}let vu=!0,fi=!1;const Jf=["sdk_event_queue_latency_seconds","sdk_replay_add_event_batch_seconds","sdk_replay_cleanup_seconds","sdk_replay_compression_seconds","sdk_replay_get_events_between_seconds","sdk_replay_snapshot_seconds","sdk_mutations_nodes_added","sdk_mutations_nodes_removed","sdk_mutations_attributes_changed","sdk_mutations_character_data","sdk_dom_nodes_count","sdk_page_html_characters"];let gi,Kt={};class Kf{constructor(t){de(this,"_values",[]);de(this,"_isWebMetric");this.name=t,this._isWebMetric=Jf.includes(this.name)}report(t){if(vu&&this._values.push({time:Date.now(),value:t}),fi||!this._isWebMetric)return;const r=this.findExceededThreshold(t);r&&gi&&gi(t,r)}collect(){const t=this._values;return this._values=[],t}findExceededThreshold(t){const r=Kt[this.name];if(r)return r.find(s=>this.valueExceedsThreshold(t,s))}valueExceedsThreshold(t,r){return r.type==="max"?t>r.value:r.type==="min"&&t<r.value}}const br={},Ve=e=>{const t=new Kf(e);return br[e]=t,t},Su=(e,t)=>{let r=br[e];return r||(r=Ve(e)),r.report(t)},Xf=({reportingIntervalSeconds:e,postMetrics:t})=>{e?setInterval(()=>{(async r=>{const s=Object.values(br).map(n=>({name:n.name,values:n.collect()}));if(s.some(n=>n.values.length))try{await r(JSON.stringify(s))}catch(n){n instanceof Error&&_.error("MetricsErr",{error:{message:n.message,name:n.name}})}})(t)},1e3*e):vu=!1};let Iu,Cu;const yi=e=>{let t=0,r=e.firstElementChild;for(;r;)t+=yi(r),r.shadowRoot&&(t+=yi(r.shadowRoot)),r=r.nextElementSibling,t++;return t},el=()=>{Iu.report(yi(document.body)),Cu.report(document.documentElement.innerHTML.toString().length)},wi=(e,t)=>{const r=performance.now();document.hidden?setTimeout(()=>wi(e,t),e):setTimeout(()=>{const s=performance.now()-r;t.report(s/1e3),setTimeout(()=>wi(e,t),e)},0)};let ks,Es,xs,Ts,tl,ht={};const qr=(e,t=1)=>{const{name:r}=e;ht[r]=(ht[r]||0)+t},ku=e=>{let t=1;return e.childNodes.forEach(r=>{t+=ku(r)}),t},rl=e=>{let t=0;return e.forEach(r=>{t+=ku(r)}),t},Zf=e=>{switch(e.type){case"childList":return qr(ks,rl(e.addedNodes)),void qr(Es,rl(e.removedNodes));case"attributes":return void qr(xs);case"characterData":return void qr(Ts)}},Qf=e=>e.forEach(Zf),eg=()=>{ks.report(ht[ks.name]||0),Es.report(ht[Es.name]||0),xs.report(ht[xs.name]||0),Ts.report(ht[Ts.name]||0),ht={}},tg=(e=1e3)=>{ks=Ve("sdk_mutations_nodes_added"),Es=Ve("sdk_mutations_nodes_removed"),xs=Ve("sdk_mutations_attributes_changed"),Ts=Ve("sdk_mutations_character_data"),tl=new MutationObserver(Qf),tl.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(eg,e)},rg=({isWeb:e,reportingIntervalSeconds:t,thresholds:r,postMetrics:s})=>{((n,i)=>{Kt={},fi=!1,n==null||n.forEach(a=>{var o;a.metric in Kt||(Kt[a.metric]=[]),(o=Kt[a.metric])==null||o.push(a)}),gi=i})(r,(n,i)=>{var a,o;if((a=re.replay)!=null&&a.isReplayRecording()){const l=`Value: ${n} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(o=re.replay)==null||o.disableRecording("Threshold violated",new Error(l),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:i.metric,type:i.type,value:i.value},{metricName:i.metric}),fi=!0}}),Xf({reportingIntervalSeconds:t,postMetrics:s}),e&&(((n=1e3)=>{const i=Ve("sdk_event_queue_latency_seconds");wi(n,i)})(),((n=1e4)=>{Iu=Ve("sdk_dom_nodes_count"),Cu=Ve("sdk_page_html_characters"),el(),setInterval(el,n)})(),tg())},sg="test",ng=["popState","pushState","replaceState"];let oo,sr;const Rs={},Vt="!email",Eu="pageUrl";var dl;let wn=((dl=globalThis.location)==null?void 0:dl.href)||"";function nr(e){var o,l;const{pageUrlEvents:t,interactiveEvents:r,dismissOnPageChange:s,platform:n}=globalThis.UserLeap._config;if(n&&n!=="web")return;wn!==globalThis.location.href&&_.navigation("LocationChange",{from:wn,to:globalThis.location.href}),wn=globalThis.location.href;const i=Ru().trackStartUrl,a=i?String(i):null;t&&Ou(globalThis.location.href),r&&(Tu(),ig()),fu()&&(()=>{if(Is())return;const c=Lt();c&&(hu(rr)||(c.remove(),rr=null,Z=null))})(),Q.getItem("sprig.isCapturingHeatmap")&&((l=(o=re.replay)==null?void 0:o.checkPendingHeatmapsUrl())==null||l.then(c=>{var u;c&&((u=re.replay)==null||u.uploadReadyPendingCaptures(!0))})),!Is()&&s&&a&&a!==globalThis.location.href&&e&&ng.includes(e.type)&&globalThis.UserLeap("dismissActiveSurvey",Ae.PageChange)}const xu={capture:!0},ig=()=>{const e=globalThis.UserLeap._config.interactiveEvents.filter(r=>no(r,globalThis.location.href)).map(r=>{const{name:s,properties:n}=r,{selector:i,innerText:a}=n;return i?o=>{if(Ka(o.target))try{o.target.closest(i)&&globalThis.UserLeap("track",s)}catch{}return!1}:o=>(Ka(o.target)&&o.target.innerText===a&&globalThis.UserLeap("track",s),!1)}),t=r=>e.forEach(s=>s(r));globalThis.UserLeap._config.interactiveEventsHandler=t,globalThis.addEventListener("click",t,xu)},Tu=()=>{globalThis.UserLeap._config.interactiveEventsHandler&&globalThis.removeEventListener("click",globalThis.UserLeap._config.interactiveEventsHandler,xu),delete globalThis.UserLeap._config.interactiveEventsHandler};function Ru(){const e=ut.getItemObject("userleap.ids");return(e==null?void 0:e[globalThis.UserLeap.envId])||{}}function Lu(){if(globalThis.previewMode)return;const e=ut.getItemObject("sprig.anon.env.vid.map")||{},t=e[globalThis.UserLeap.envId];globalThis.UserLeap.visitorId=t||bt(),_.info("NewVid",{vid:globalThis.UserLeap.visitorId}),ke("vid",globalThis.UserLeap.visitorId),t||(e[globalThis.UserLeap.envId]=globalThis.UserLeap.visitorId,ut.setItemObject("sprig.anon.env.vid.map",e)),z.emit(B.VisitorIDUpdated,{visitorId:globalThis.UserLeap.visitorId})}function Ou(e,t,r,s){var n,i;try{if(e.endsWith("mock_snippet.html"))return;_.info("PageView",{url:e});const a=(n=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:n.getAttribute("content");(i=re.replay)==null||i.RecordPageView({...a&&{description:a},url:e,referrer:document.referrer,pageTitle:document.title});const o=globalThis.UserLeap._config.pageUrlEvents;let l=!1;if(o&&o.length)for(let u=0;u<o.length&&(l=no(o[u],e),!l);u++);if(!l)return;globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const c={url:e};s&&(c.trackPageView=!0),globalThis.UserLeap._queue.push(["track",Eu,t,c,r])}catch(a){a instanceof Error&&(a.stack=e,globalThis.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function og(){var t;const e=((t=globalThis.Backbone)==null?void 0:t.history)||globalThis.history;"pushState"in e&&(e.pushState=(r=>function(...s){const n=r.apply(this,s),i=new Event("pushState");return globalThis.dispatchEvent(i),nr(i),n})(e.pushState)),"replaceState"in e&&(e.replaceState=(r=>function(...s){const n=r.apply(this,s),i=new Event("replaceState");return globalThis.dispatchEvent(i),nr(i),n})(e.replaceState)),["hashchange","popstate"].forEach(r=>globalThis.addEventListener(r,nr,!0))}async function bn(e,t){const r=ro();e&&!t&&(globalThis.UserLeap._config.mode=sg);const s=qs(De(globalThis.UserLeap)),n=await ze(function(i){const a=new URL(Me("1",[ot],"questions"));return Object.entries(i||{}).forEach(([o,l])=>{l&&a.searchParams.append(o,String(l))}),a.toString()}({desktopDisplay:globalThis.UserLeap._config.desktopDisplay,isMobile:s,previewLanguage:globalThis.UserLeap._config.previewLanguage,surveyid:e==null?void 0:e.surveyId,surveytemplateid:e==null?void 0:e.surveyTemplateId,vid:r}),{shouldDropOnRateLimit:!0});if(!n.ok)return n.reportError&&n.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",n.error),globalThis.UserLeap.reportError("getQuestions",n.error)),{success:!1,surveyState:"no survey"};if(n.json.delay&&await Ss(n.json.delay),!n.json.isFeedback)return tr(n.json,sr,oo);{const{feedbackLabel:i,productConfig:a,surveyUuid:o,feedbackCustomStyles:l}=n.json,{buttonTheme:c,placement:u,desktopDisplay:d}=a;bu({customStyles:l,buttonTheme:c,desktopDisplay:d,eventId:0,feedbackLabel:i,placement:u,surveyUuid:o,surveyId:e==null?void 0:e.surveyId},n.json)}}function ag(e){if(!e)return;globalThis.UserLeap._config=e,e.mute&&globalThis.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:r,dismissOnPageChange:s}=e;t&&function(n){let i=n.length;for(;i;){const a=Math.floor(Math.random()*i);i-=1;const o=n[i];n[i]=n[a],n[a]=o}}(t),(t||r||s)&&(og(),nr())}const lg=function(e){if(!globalThis.UserLeap)return;const t=async(n={})=>{var m,g,v,I,O;const{userId:i,anonymousId:a,metadata:o={},properties:l,showSurveyCallback:c}=n;let{eventName:u}=n;if(globalThis.UserLeap.debugMode&&u!==Eu&&console.info("[DEBUG] Sprig track",n),e.mode==="test")return;const d=Q.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!globalThis.UserLeap.userId&&!i){const E="[Sprig] - Skipping tracking without userId";return console.warn(E),{success:!1,message:E,surveyState:"no survey"}}if(!u||u.trim().length===0){u=u?String(u):"";const E="[Sprig] - Invalid event name "+u;return console.warn(E),{success:!1,message:E,surveyState:"no survey"}}const h=sr??globalThis.location.href;o.url||(o.url=h),ke("trackStartUrl",h),(g=(m=globalThis.UserLeap)==null?void 0:m._config)!=null&&g.optimizelyEnabled&&(mr(De(globalThis.UserLeap))||ds.getAndSetWebOptimizelyExperiments(),o.optimizelyExperiments=Object.assign({},ds.getAllOptimizelyExperiments())),(I=(v=globalThis.UserLeap)==null?void 0:v._config)!=null&&I.launchDarklyEnabled&&(o.launchDarklyFlags=mi.getAllLaunchDarklyVariations()),i&&(globalThis.UserLeap.userId=i),a&&(globalThis.UserLeap.partnerAnonymousId=a),l&&(o.eventProperties=l),(O=re.replay)==null||O.RecordEvent({name:u,url:o.url}),_.info("TrackEvent",{eventName:u});const f=globalThis.UserLeap.delayingSurvey||gu()?await ze(Me("1",[it],"events/batch"),{body:JSON.stringify({events:[{event:u,metadata:o}],previewKey:d}),method:"POST",shouldDropOnRateLimit:!0}):await ze(Me("1",[it],"events"),{body:JSON.stringify({event:u,metadata:o,previewKey:d}),method:"POST",shouldDropOnRateLimit:!0});if(!f.ok){const E="[Sprig] (ERR-421) Failed to track event";return f.reportError&&(console.warn(E,f.error),f.error&&globalThis.UserLeap.reportError("track",f.error)),{success:!1,message:E,error:f.error,surveyState:"no survey"}}i&&ke("uid",i),a&&ke("aid",a);const w=f.json;w.invalidPreviewKey&&Q.removeItem("sprig.previewKey");const p=o.trackPageView?o.url:void 0;return w!=null&&w.feedbackButton&&bu(w.feedbackButton,void 0,p),await async function(E,A){var k,T;let M=!0;return!(A&&((k=E==null?void 0:E.json)!=null&&k.surveyId)&&(globalThis.UserLeap.delayingSurvey=!0,M=await A(E.json.surveyId),globalThis.UserLeap.delayingSurvey=!1,!M))&&((T=E==null?void 0:E.json)!=null&&T.delay&&!globalThis.UserLeap.isMobileSDK&&(globalThis.UserLeap.delayingSurvey=!0,await Ss(E.json.delay),globalThis.UserLeap.delayingSurvey=!1),M)}(f,c)?function(E){if(!globalThis.UserLeap._config.dismissOnPageChange)return!0;const A=new URL(E),M=new URL(sr??globalThis.location.href);return A.hostname===M.hostname&&A.pathname===M.pathname}(h)?tr(w,p,oo):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},r=(n,i)=>{var o;const a=(o=n==null?void 0:n.querySelector(`[id="${so}"]`))==null?void 0:o.contentDocument;a&&fr({document:a,elementId:"ul-custom-style",styleString:i})},s={displaySurvey:async n=>(console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),globalThis.UserLeap("dismissActiveSurvey",Ae.Override),bn({surveyId:n},!0)),_previewSurvey(n){globalThis.UserLeap("dismissActiveSurvey",Ae.Override),bn({surveyTemplateId:n},!1)},_reviewSurvey(n){globalThis.UserLeap("dismissActiveSurvey",Ae.Override),bn({surveyId:n},!1)},previewSurvey(n){s._previewSurvey(n)},reviewSurvey(n){s._reviewSurvey(n)},mute(){globalThis.UserLeap._queue.pause()},unmute(){globalThis.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(n=Ae.API){globalThis.UserLeap.container&&(n===Ae.Closed&&globalThis.Sprig.trackHistory&&globalThis.Sprig.trackHistory({event:"closed"}),z.emit(B.SurveyCloseRequested,{name:B.SurveyCloseRequested,initiator:n,"survey.id":parseInt(globalThis.UserLeap.container.dataset.studyId)}),z.emit(B.SurveyWillClose,{name:B.SurveyWillClose,initiator:n,"survey.id":parseInt(globalThis.UserLeap.container.dataset.studyId)}))},async setAttribute(n,i){if(!n||!i&&i!==0&&i!==!1){const a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}return this.setAttributes({[n]:i})},async setAttributes(n){if(n==null||Object.keys(n).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:n})},async identifyAndSetAttributes(n){if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",n),e.mode==="test")return;if(n===null||typeof n!="object"||!(n.userId||n.anonymousId||n.attributes)){const u="[Sprig] - Disregarding empty payload provided";return console.warn(u),{success:!1,message:u}}const{userId:i,anonymousId:a,attributes:o}=n;if(e.requireUserIdForTracking&&!globalThis.UserLeap.userId&&!i){const u="[Sprig] - Skipping tracking without userId";return console.warn(u),{success:!1,message:u}}if(o){o.email&&!o[Vt]&&(o[Vt]=o.email,delete o.email);const u=Object.keys(o);for(const d of u)o[d]===Rs[d]&&delete o[d]}if(!(o&&Object.keys(o).length!==0||i&&globalThis.UserLeap.userId!==i||a&&globalThis.UserLeap.partnerAnonymousId!==a))return{success:!0};const l={};let c;return i&&(l.userId=globalThis.UserLeap.userId=i),a&&(l.partnerAnonymousId=globalThis.UserLeap.partnerAnonymousId=a),o&&Object.keys(o).length>0?(c=await ze(Me("1",[ot,it],"attributes"),{body:JSON.stringify(o),method:"PUT"}),c.ok?Object.assign(Rs,o):c.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",c.error),c.error&&globalThis.UserLeap.reportError("identifyAndSetAttributes",c.error))):c=await ze(Me("1",[ot,it]),{body:JSON.stringify(l),method:"PUT"}),o&&o[Vt]&&(globalThis.UserLeap.email=o[Vt]),c.ok&&(i&&ke("uid",i),a&&ke("aid",a)),{success:!!c.ok}},async removeAttributes(n){if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",n),e.mode==="test")return;if(n==null||n.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(e.requireUserIdForTracking&&!globalThis.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const i=await ze(Me("1",[ot,it],"attributes"),{body:JSON.stringify({delete:n}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&globalThis.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(n){z.on(B.SurveyLifeCycle,n)},async removeSurveyListener(n){z.removeListener(B.SurveyLifeCycle,n)},async addListener(n,i){z.on(n,i)},async removeListener(n,i){z.removeListener(n,i)},async removeAllListeners(){z.removeAllListeners()},setPreviewKey(n){n&&typeof n=="string"&&Q.isStorageAvailable&&n&&Q.setItem("sprig.previewKey",n)},async setUserId(n){var o;if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",n),n==null){const l=`[Sprig] - Invalid userId ${n}`;return console.warn(l),{success:!1,message:l}}if(e.mode==="test"||n===globalThis.UserLeap.userId)return;globalThis.UserLeap.userId=n;const i=globalThis.UserLeap.visitorId,a=await ze(Me("1",[ot,it]),{body:JSON.stringify({userId:n}),method:"PUT"});a.ok?(i!==globalThis.UserLeap.visitorId&&((o=re.replay)==null||o.clearUserReplayData()),ke("uid",n)):a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&globalThis.UserLeap.reportError("setUserId",a.error))},async setPartnerAnonymousId(n){if(globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",n),n==null){const i=`[Sprig] - Invalid partnerAnonymousId ${n}`;return console.warn(i),{success:!1,message:i}}return globalThis.UserLeap.partnerAnonymousId=n,ke("aid",n),{success:!0}},track:async(n,i,a={},o=void 0)=>t({eventName:n,properties:i,metadata:a,showSurveyCallback:o}),identifyAndTrack:async n=>await t(n),trackPageView(n,i=void 0,a=void 0,o=!0){sr=n,Ou(n,i,a,o)},applyFeedbackStyles({button:n="",view:i=""}){globalThis.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&fr({document,elementId:"ul-custom-style",styleString:n,nonce:globalThis.UserLeap.styleNonce}),r(document.querySelector(".ul-container-feedback"),i)},applyStyles(n){globalThis.UserLeap.customStyles=n,r(globalThis.UserLeap.container,n)},setWindowDimensions(n,i){var h,f;const a=typeof n=="string"?parseInt(n,10):n,o=typeof i=="string"?parseInt(i,10):i;isNaN(a)||isNaN(o)||(globalThis.UserLeap.windowDimensions={width:a,height:o});const l=De(globalThis.UserLeap),c=qs(l),u=l["userleap-platform"]==="web";if(!globalThis.UserLeap.frameId)return;const d=document.getElementById(globalThis.UserLeap.frameId);d&&(globalThis.UserLeap.useMobileStyling&&((h=globalThis.UserLeap.windowDimensions)!=null&&h.width&&(d.style.width=`${globalThis.UserLeap.windowDimensions.width}px`),(f=globalThis.UserLeap.windowDimensions)!=null&&f.height&&(d.style.maxHeight=globalThis.UserLeap.windowDimensions.height-20+"px"),d.contentDocument&&(d.style.height=String(mu(d.contentDocument,u&&!c,to(l))[0])+"px")),z.emit(B.SurveyDimensions,{name:B.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight,"survey.id":parseInt(globalThis.UserLeap.container.dataset.studyId)}))},logoutUser(){var n;globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),_.info("LogOut",{vid:globalThis.UserLeap.visitorId,userId:globalThis.UserLeap.userId}),globalThis.UserLeap.visitorId=null,globalThis.UserLeap.userId=null,globalThis.UserLeap.partnerAnonymousId=null,globalThis.UserLeap.token=null,globalThis.UserLeap.email=null,ut.removeItem("userleap.ids"),globalThis.UserLeap._queue.isPaused()&&globalThis.UserLeap._queue.empty(),Lu(),(n=re.replay)==null||n.clearUserReplayData(),globalThis.UserLeap._queue.unpause()},teardown(){["hashchange","popstate"].forEach(n=>globalThis.removeEventListener(n,nr,!0)),globalThis.UserLeap._config.interactiveEvents&&Tu(),globalThis.UserLeap("dismissActiveSurvey",Ae.API),delete globalThis.UserLeap,delete globalThis.Sprig,delete globalThis._Sprig},integrateOptimizely(n,i=!0){var a,o;if((o=(a=globalThis.UserLeap)==null?void 0:a._config)!=null&&o.optimizelyEnabled)try{const l=typeof n=="string"?JSON.parse(n):n;ds.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&globalThis.UserLeap.reportError("integrateOptimizely",l)}else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.")},integrateOptimizelyClient(n){var i,a;if(!((a=(i=globalThis.UserLeap)==null?void 0:i._config)!=null&&a.optimizelyEnabled))return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");n.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",({experiment:o,variation:l})=>{const c={experiments:[{id:o.id,variation:l.key}]};globalThis.UserLeap("integrateOptimizely",c,!1)})},importLaunchDarklyData(n){var i,a;(a=(i=globalThis.UserLeap)==null?void 0:i._config)!=null&&a.launchDarklyEnabled?mi.setLDFlagsVariations(n):console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.")},setVisitorAttribute:(n,i)=>(console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),s.setAttribute(n,i)),setEmail:async n=>s.setAttribute(Vt,n),setVisitorEmail:async n=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),s.setEmail(n)),_generateVideoUploadUrl:async n=>async function(i){var o;if(!i)return;const a=`${globalThis.UserLeap._API_URL}/2/environments/integrations/upload`;try{const l=await fetch(a,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(l.ok){const c=await l.json();return(o=c==null?void 0:c.upload)==null?void 0:o.url}return null}catch(l){console.warn("[Sprig] Error with generating video upload url"),l instanceof Error&&globalThis.UserLeap.reportError("generateVideoUploadUrl",l)}}(n),_reportMetric(n,i){Su(n,i)},_completeSessionReplay:async({surveyId:n,responseGroupUuid:i,eventDigest:a})=>{var o;return re.replay?(o=re.replay)==null?void 0:o._completeSessionReplay({surveyId:n,responseGroupUuid:i,eventDigest:a,headers:De(globalThis.UserLeap)}):(globalThis.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)},pauseReplayRecording(){var n,i,a,o;(i=(n=re.replay)==null?void 0:n.isReplayPaused)!=null&&i.call(n)||((o=(a=re.replay)==null?void 0:a.recordReplayPaused)==null||o.call(a))},resumeReplayRecording(){var n,i,a,o,l,c;(i=(n=re.replay)==null?void 0:n.isReplayPaused)!=null&&i.call(n)&&((o=(a=re.replay)==null?void 0:a.recordReplayResumed)==null||o.call(a),(c=(l=re.replay)==null?void 0:l.recordFullSnapshot)==null||c.call(l))}};Object.assign(globalThis.UserLeap,s)};async function cg(e,t,r={},s={}){var u;const n=(u=globalThis.__cfg)==null?void 0:u.mode,i=ro(),a=globalThis.UserLeap.envId,o=globalThis.document.documentElement,l={mode:n,screenWidth:globalThis.screen.width,screenHeight:globalThis.screen.height,clientWidth:o.clientWidth,clientHeight:o.clientHeight,location:sr??globalThis.location.href,language:globalThis.navigator.language,...r},c={action:e,breadcrumbs:_.breadcrumbs,err:{message:`${t==null?void 0:t.name} - ${t==null?void 0:t.message}`,stack:t==null?void 0:t.stack},meta:l,vid:i,envId:a,...s};(await ze(Me("1",null,"errors"),{method:"POST",headers:{"x-ul-error":globalThis.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",t)}function ug(e={}){var s;(s=globalThis.SprigLoggerCallback)==null||s.call(globalThis,"Initializing Sprig");const t=new URLSearchParams(globalThis.location.search).get("sprigPreviewKey")??"";async function r(){var d,h,f,w,p;if(globalThis.UserLeap.loaded)return;if((d=globalThis.SprigLoggerCallback)==null||d.call(globalThis,"Loading Sprig"),globalThis.UserLeap.reportError=cg,globalThis.UserLeap.loaded=!0,globalThis.UserLeap._config=Object.assign({},e,globalThis.UserLeap.config),globalThis.UserLeap.delayingSurvey=!1,globalThis.UserLeap._config&&typeof globalThis.UserLeap._config=="object")for(const C in globalThis.UserLeap._config)globalThis.UserLeap[C]=globalThis.UserLeap._config[C];if(globalThis.Sprig.outstandingTransactionLimit!==void 0&&(e.outstandingTransactionLimit=globalThis.Sprig.outstandingTransactionLimit),!globalThis.UserLeap.envId){if(!globalThis.UserLeap.appId)throw new Error("Missing Environment id");globalThis.UserLeap.envId=globalThis.UserLeap.appId}globalThis.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const n=Ru(),i=globalThis.UserLeap.sampleRate;let a=n.sampled;if(i){if(a===null&&(a=Math.random()<i,ke("sampled",a)),!a)return}else a!==null&&ke("sampled",null);globalThis.UserLeap._API_URL||(globalThis.UserLeap._API_URL="https://api.sprig.com");const o=[...globalThis.UserLeap._queue];globalThis.UserLeap._queue=new qf(globalThis.UserLeap,[]),globalThis.UserLeap._queue.pause();for(let C=0;C<o.length;C++)globalThis.UserLeap._queue.push(o[C]);const l=n.token;l?(globalThis.UserLeap.token=l,globalThis.UserLeap.visitorId=n.vid??null,globalThis.UserLeap.userId=n.uid??null,globalThis.UserLeap.partnerAnonymousId=n.aid??null):Lu();const c=mr(De(globalThis.UserLeap));(h=globalThis.SprigLoggerCallback)==null||h.call(globalThis,"Sprig fetching config");const u=await async function(C){var I,O;const m=De(globalThis.UserLeap);document.addEventListener("securitypolicyviolation",Ga);const g=await He(Me("1",[ot],"config"),{headers:m});if(document.removeEventListener("securitypolicyviolation",Ga),!g.ok)return(I=globalThis.SprigLoggerCallback)==null||I.call(globalThis,"Sprig config fetch failed"),g.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",g.error),g.error&&globalThis.UserLeap.reportError("applyRemoteConfig",g.error)),di("Disabled: failed to fetch configuration"),C;const v=g.json;return v!=null&&v.disabled?((O=globalThis.SprigLoggerCallback)==null||O.call(globalThis,"Sprig config fetch disabled"),di(`Disabled: ${v.disabled}`),{disabled:v.disabled}):Object.assign({},v,C)}(e);if((f=globalThis.SprigLoggerCallback)==null||f.call(globalThis,"Sprig fetched config"),rg({isWeb:!c,reportingIntervalSeconds:u.metricsReportingEnabled||u.mobileMetricsReportingEnabled?u.metricsReportingIntervalSeconds:0,thresholds:u.metricThresholds,postMetrics:async C=>{var m;await ze(Me("1",[ot],"metrics"),{body:C,method:"POST",headers:{"x-ul-replay-enabled":`${!!((m=re.replay)!=null&&m.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),!c){const C=u.alwaysOnReplay?{userAgent:globalThis.navigator.userAgent,surveyId:u.alwaysOnReplay.surveyId,responseGroupUuid:u.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.45.0",maxDurationSeconds:u.alwaysOnReplay.maxDurationSeconds}:void 0;await((w=re.replay)==null?void 0:w.initializeReplay({maxReplayDurationSeconds:u.maxReplayDurationSeconds,maxInflightRequests:globalThis.UserLeap.maxInflightReplayRequests??2,replaySettings:u.replaySettings,apiUrl:globalThis.UserLeap._API_URL,alwaysOnConfig:C})),oo=u.replaySettings}lg(u),await ag(u),globalThis.UserLeap._queue.unpause(),(p=globalThis.SprigLoggerCallback)==null||p.call(globalThis,"SdkReady"),z.emit(B.SDKReady,{mobileMetricsReportingEnabled:!!u.mobileMetricsReportingEnabled,metricsReportingInterval:u.metricsReportingIntervalSeconds||0,metricsThresholds:u.metricThresholds||[],maxMobileReplayDurationSeconds:u.maxMobileReplayDurationSeconds,mobileReplaySettings:u.mobileReplaySettings}),z.emit(B.VisitorIDUpdated,{visitorId:globalThis.UserLeap.visitorId}),z.on(B.VisitorIDUpdated,()=>{for(const C in Rs)delete Rs[C]})}globalThis.UserLeap.UPDATES=hr,globalThis.UserLeap("setPreviewKey",t),document.readyState==="complete"?r():globalThis.attachEvent?globalThis.attachEvent("onload",r):globalThis.addEventListener("load",()=>{r()},!1)}class Ls{constructor(){de(this,"UPDATES",hr)}displaySurvey(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"displaySurvey",t)}mute(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"mute")}unmute(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"unmute")}dismissActiveSurvey(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"dismissActiveSurvey")}setAttribute(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"setAttribute",t,r)}setAttributes(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setAttributes",t)}identifyAndSetAttributes(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"identifyAndSetAttributes",t)}removeAttributes(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"removeAttributes",t)}addListener(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"addListener",t,r)}removeListener(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"removeListener",t,r)}removeAllListeners(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"removeAllListeners")}setEmail(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setAttribute","!email",t)}setUserId(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setUserId",t)}setPartnerAnonymousId(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"setPartnerAnonymousId",t)}track(t,r={},s={}){var n;(n=globalThis.Sprig)==null||n.call(globalThis,"track",t,r,s)}identifyAndTrack(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"identifyAndTrack",t)}trackPageView(t,r,s){var n;(n=globalThis.Sprig)==null||n.call(globalThis,"trackPageView",t,r,s)}applyStyles(t){var r;(r=globalThis.Sprig)==null||r.call(globalThis,"applyStyles",t)}setWindowDimensions(t,r){var s;(s=globalThis.Sprig)==null||s.call(globalThis,"setWindowDimensions",t,r)}logoutUser(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"logoutUser")}teardown(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"teardown")}pauseReplayRecording(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"pauseReplayRecording")}resumeReplayRecording(){var t;(t=globalThis.Sprig)==null||t.call(globalThis,"resumeReplayRecording")}}const dg={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",globalThis.Sprig)return globalThis.Sprig;globalThis.Sprig=function(){var r;(r=globalThis.Sprig)==null||r._queue.push(arguments)},Object.getOwnPropertyNames(Ls.prototype).map(r=>{r!=="constructor"&&(globalThis.Sprig[r]=Ls.prototype[r])});const t=globalThis.Sprig;return t.appId=e.envId,t._queue=[],globalThis.UserLeap=t,ug(e),globalThis.Sprig}},pg=new Ls;var at=(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))(at||{}),Ye=(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[e.CustomElement=16]="CustomElement",e))(Ye||{});const bi=(e,t)=>t.some(r=>e instanceof r);let sl,nl;const vi=new WeakMap,vn=new WeakMap,Os=new WeakMap;let Si={get(e,t,r){if(e instanceof IDBTransaction){if(t==="done")return vi.get(e);if(t==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return lt(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&(t==="done"||t==="store")||t in e};function Au(e){Si=e(Si)}function hg(e){return(nl||(nl=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Ii(this),t),lt(this.request)}:function(...t){return lt(e.apply(Ii(this),t))}}function mg(e){return typeof e=="function"?hg(e):(e instanceof IDBTransaction&&function(t){if(vi.has(t))return;const r=new Promise((s,n)=>{const i=()=>{n(t.error||new DOMException("AbortError","AbortError"))};t.oncomplete=()=>{s()},t.onerror=i,t.onabort=i});vi.set(t,r)}(e),bi(e,sl||(sl=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Si):e)}function lt(e){if(e instanceof IDBRequest)return function(r){const s=new Promise((n,i)=>{r.onsuccess=()=>{n(lt(r.result))},r.onerror=()=>{i(r.error)}});return Os.set(s,r),s}(e);if(vn.has(e))return vn.get(e);const t=mg(e);return t!==e&&(vn.set(e,t),Os.set(t,e)),t}const Ii=e=>Os.get(e);function Ci(e,{blocked:t}={}){const r=indexedDB.deleteDatabase(e);return t&&(r.onblocked=s=>t(s.oldVersion,s)),lt(r).then(()=>{})}const fg=["get","getKey","getAll","getAllKeys","count"],gg=["put","add","delete","clear"],Sn=new Map;function il(e,t){if(!(e instanceof IDBDatabase)||t in e||typeof t!="string")return;if(Sn.get(t))return Sn.get(t);const r=t.replace(/FromIndex$/,""),s=t!==r,n=gg.includes(r);if(!(r in(s?IDBIndex:IDBObjectStore).prototype)||!n&&!fg.includes(r))return;const i=async function(a,...o){const l=this.transaction(a,n?"readwrite":"readonly");let c=l.store;return s&&(c=c.index(o.shift())),(await Promise.all([c[r](...o),n&&l.done]))[0]};return Sn.set(t,i),i}Au(e=>({...e,get:(t,r,s)=>il(t,r)||e.get(t,r,s),has:(t,r)=>!!il(t,r)||e.has(t,r)}));const yg=["continue","continuePrimaryKey","advance"],ol={},ki=new WeakMap,Mu=new WeakMap,wg={get(e,t){if(!yg.includes(t))return e[t];let r=ol[t];return r||(r=ol[t]=function(...s){ki.set(this,Mu.get(this)[t](...s))}),r}};async function*bg(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const r=new Proxy(t,wg);for(Mu.set(r,t),Os.set(r,Ii(t));t;)yield r,t=await(ki.get(r)||t.continue()),ki.delete(r)}function al(e,t){return t===Symbol.asyncIterator&&bi(e,[IDBIndex,IDBObjectStore,IDBCursor])||t==="iterate"&&bi(e,[IDBIndex,IDBObjectStore])}Au(e=>({...e,get:(t,r,s)=>al(t,r)?bg:e.get(t,r,s),has:(t,r)=>al(t,r)||e.has(t,r)}));const vg="sprigReplayIframeLoaded",Sg="sprigReplayIframeSettings",Ig="sprigReplayIframeTakeFullSnapshot",Cg="sprigReplayTeardown",ao=[],Uu=new class{constructor(e){de(this,"awaitingResolvers",[]);de(this,"activeCount",0);this.capacity=e}async acquire(){if(!(this.activeCount<this.capacity))return new Promise(e=>{this.awaitingResolvers.push(e)});this.activeCount++}release(){const e=this.awaitingResolvers.shift();e&&this.activeCount<=this.capacity?e():this.activeCount--}async execute(e){try{return await this.acquire(),await e()}finally{this.release()}}setLimit(e){this.capacity=e}}(2),Du=async({apiUrl:e,surveyId:t,uploadId:r,etags:s,headers:n,responseGroupUuid:i,replayDuration:a,eventDigest:o},l=!1)=>{var u;if(!l&&!r&&!s)return void _.error("UploadErr",{isMobile:l,uploadId:r,etags:s});_.info("MarkUploadComplete",{surveyId:t});const c=await He(`${e}/sdk/1/completeSessionReplay`,{method:"POST",body:JSON.stringify({etags:s,uploadId:r,responseGroupUuid:i,surveyId:t,replayDuration:a,eventDigest:o,userAgent:(u=window==null?void 0:window.navigator)==null?void 0:u.userAgent}),headers:n,shouldRetryRequest:!0});return _.info("MarkUploadDone",{surveyId:t}),c},kg=e=>{if(e instanceof Attr)return null;let t=1;for(let r=e.previousSibling;r;r=r.previousSibling)r.nodeName===e.nodeName&&++t;return t},Pu=e=>{if(e===null)return"";const t=[];if(e instanceof Document)return"/";for(let r=e;r&&!(r instanceof Document)&&r!==null;r=r instanceof Attr?r.ownerElement:r.parentElement){const s=t[t.length]={name:void 0,position:null};switch(r.nodeType){case Node.TEXT_NODE:s.name="text()";break;case Node.ATTRIBUTE_NODE:s.name="@"+r.nodeName;break;case Node.PROCESSING_INSTRUCTION_NODE:s.name="processing-instruction()";break;case Node.COMMENT_NODE:s.name="comment()";break;case Node.ELEMENT_NODE:s.name=r.nodeName}s.position=kg(r)}return"/"+t.reverse().map(r=>r.position!==null?`/${r.name}[${r.position}]`:`/${r.name}`).join("")},lo=e=>e&&e.trim().substring(0,500).replace(/\s\s+/g," ").replace(/\r?\n|\r/g," ").substring(0,250),_u=(e,t)=>{let r;return s=>{clearTimeout(r),r=window.setTimeout(()=>e(s),t)}},We={capture:!0,passive:!0},Eg=["a","button","input","option","li","link"],xg=["Escape","Enter","Backspace","F5","Tab"];let As=!1,xe=null,ps=null;const ll=e=>{var r;if(((r=e.tagName)==null?void 0:r.toLowerCase())==="html")return{element:"html"};const t={};return t.element=(s=>{if(!s.tagName)return"No tagName";const n=s.getAttribute("type");return n?`${n} ${s.tagName.toLowerCase()}`:s.tagName.toLowerCase()})(e),t},Tg=e=>{var s;if(!e)return{};const t={...ll(e)},r=e.parentElement;if(r&&Eg.includes((s=r.tagName)==null?void 0:s.toLowerCase())){const n=ll(r);Object.assign(t,n)}return t},Nu=(e,t)=>{var n,i;let r=t.target;var s;t.target===((n=window.document)==null?void 0:n.body)&&window.Sprig.pointerDownTarget&&(r=window.Sprig.pointerDownTarget),s={x:t.x,y:t.y,type:e,elementAttributes:Tg(r),windowHeight:window.innerHeight,windowWidth:window.innerWidth,...r instanceof HTMLElement||r instanceof SVGElement||r instanceof MathMLElement?{rect:r==null?void 0:r.getBoundingClientRect(),xPath:Pu(r)}:{}},(i=s==null?void 0:s.elementAttributes)!=null&&i.text&&(s.elementAttributes.text=lo(s.elementAttributes.text)),xe==null||xe("Sprig_Click",s)},Fu=e=>{var t;xg.includes(e.key)&&(t={key:e.key},xe==null||xe("Sprig_Keystroke",t))},Rg=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("reload")&&(e={url:window.location.href,currentPageTitle:document.title},xe==null||xe("Sprig_Refresh",e))},Lg=()=>{var e;window.performance.getEntriesByType("navigation").map(t=>t.type).includes("back_forward")&&((e={curUrl:window.location.href,fromUrl:document.referrer,currentPageTitle:document.title}).currentPageTitle&&(e.currentPageTitle=lo(e.currentPageTitle)),xe==null||xe("Sprig_BackForward",e))},Bu=_u(e=>{if(!(e.target instanceof HTMLElement||e.target instanceof Document))return;let t=e.target;"scrollTop"in t||(t=t.documentElement),ps==null||ps({xPath:Pu(t),x:t.scrollLeft,y:t.scrollTop,elementAttributes:{targetScrollWidth:t.scrollWidth,targetClientWidth:t.clientWidth,targetScrollHeight:t.scrollHeight,targetClientHeight:t.clientHeight}})},750),zu=(cl="left_click",e=>Nu(cl,e));var cl;const ju=e=>{e.button===2&&Nu("right_click",e)},Wu=e=>{window.Sprig&&(window.Sprig.pointerDownTarget=e.target)},pe={isRecording:!1,scrollEventUuids:{},stopRecording:()=>{}},Vu=()=>globalThis.indexedDB&&globalThis.IDBKeyRange&&globalThis.CompressionStream,be=(()=>{const e=Q.getItem("sprig.sessionId");if(e)return _.info("SessionIDFound",{savedSessionId:e}),Q.removeItem("sprig.sessionId"),e;const t=bt();return _.info("GeneratedSessionID",{uuid:t}),t})(),Ei=()=>{Q.setItem("sprig.disableReplayRecording","disabled")},Ge=()=>!!Q.getItem("sprig.disableReplayRecording"),Ms=()=>!!Q.getItem("sprig.isReplayPaused");var pl;(pl=globalThis.addEventListener)==null||pl.call(globalThis,"beforeunload",()=>{_.info("BeforeUnload",{sessionId:be}),Q.setItem("sprig.sessionId",be)});const Je=(e,t)=>{var r,s;if(!Ge()&&pe.isRecording&&!Ms())try{(s=(r=globalThis.rrwebRecord)==null?void 0:r.addCustomEvent)==null||s.call(r,e,t)}catch(n){vr("Error recording custom event",n)}},Og=async e=>{const{x:t,xPath:r,y:s}=e,n=pe.scrollEventUuids[r];if(n)return Ee(async()=>{var o,l,c,u;const i=await se.openDB(),a=await i.get("events",n);if(a!=null&&a.event){const d=JSON.parse(a.event),h=t>((l=(o=d.data)==null?void 0:o.payload)==null?void 0:l.x),f=s>((u=(c=d.data)==null?void 0:c.payload)==null?void 0:u.y);if(!h&&!f)return null;h&&(d.data.payload.x=t),f&&(d.data.payload.y=s),d.data.payload.elementAttributes=e.elementAttributes,a.event=JSON.stringify(d),await i.put("events",a)}else Je("Sprig_Scroll",e)},"Error updating scroll event");Je("Sprig_Scroll",e)},Hu=()=>{pe.stopRecording&&(pe.stopRecording(),pe.stopRecording=void 0),pe.isRecording=!1,["cleanupInterval","inactivityInterval","pendingCheckInterval"].forEach(e=>{pe[e]&&(clearInterval(pe[e]),pe[e]=void 0)}),As&&(window.removeEventListener("click",zu,We),window.removeEventListener("pointerdown",Wu,We),window.removeEventListener("mousedown",ju,We),window.removeEventListener("keydown",Fu,We),window.removeEventListener("scroll",Bu,We),As=!1),ao.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:Cg},{targetOrigin:e.origin})})},Ag=["did not allow mutations","called in an invalid security context"],Mg=(e,t,{reportError:r=!0,extraInfo:s={}})=>{if(!Ge()&&t instanceof Error){if(Ei(),t.name==="VersionError")return _.error("VersionErr",{message:e}),void se.deleteDB();(n=>{if(!n)return!0;for(const i of Ag)if(n.toLowerCase().includes(i))return!1;return!0})(t==null?void 0:t.message)&&(r&&globalThis.UserLeap.reportError(e,t,s),se.clearAll())}},vr=(e,t,{reportError:r}={reportError:!0})=>{Hu(),_.error("ReplayErr",{code:t.code,name:t.name}),Mg(e,t,{reportError:r})},Ee=async(e,t)=>{try{return await e()}catch(r){vr(t,r)}},xi=()=>{pe.isRecording&&(Ee(()=>{var e,t;return(t=(e=globalThis.rrwebRecord)==null?void 0:e.takeFullSnapshot)==null?void 0:t.call(e,!0)},"Error recording full snapshot"),ao.forEach(e=>{var t;(t=e.source)==null||t.postMessage({type:Ig},{targetOrigin:e.origin})}))};let In=0;(async()=>Vu()&&Promise.allSettled([Ci("replayStorage"),Ci("sprig.replay")]))();const se=new class{constructor(){de(this,"wrapTransactionWithCounter",e=>{var s,n;const t=(n=(s=window.Sprig)==null?void 0:s._config)==null?void 0:n.outstandingTransactionLimit,r=t===void 0?100:t;if(r&&In>r){const i="Too many outstanding transactions";vr(i,new Error(i),{reportError:!1})}In++,e.done.finally(()=>{In--})});de(this,"getTransaction",async e=>{const t=(await this.openDB()).transaction(e,"readwrite");return this.wrapTransactionWithCounter(t),t})}openDB(){return function(e,t,{blocked:r,upgrade:s,blocking:n,terminated:i}={}){const a=indexedDB.open(e,t),o=lt(a);return s&&(a.onupgradeneeded=l=>{s(lt(a.result),l.oldVersion,l.newVersion,lt(a.transaction),l)}),r&&(a.onblocked=l=>r(l.oldVersion,l.newVersion,l)),o.then(l=>{i&&(l.onclose=()=>i()),n&&(l.onversionchange=c=>n(c.oldVersion,c.newVersion,c))}).catch(()=>{}),o}("sprigReplay",1,{upgrade:(e,t,r)=>{if(r===0&&Q.setItem("sprig.pendingCount","0"),!e.objectStoreNames.contains("events")){const s=e.createObjectStore("events",{keyPath:"uuid"});s.createIndex("sessionId","sessionId"),s.createIndex("timestamp","timestamp"),s.createIndex("[sessionId+timestamp]",["sessionId","timestamp"])}if(!e.objectStoreNames.contains("chunkUploads")){const s=e.createObjectStore("chunkUploads",{keyPath:"uuid"});s.createIndex("sessionId","sessionId"),s.createIndex("timestamp","timestamp"),s.createIndex("[sessionId+status]",["sessionId","status"]),s.createIndex("[uploadId+status]",["uploadId","status"]),s.createIndex("[sessionId+status+uploadId]",["sessionId","status","uploadId"])}if(!e.objectStoreNames.contains("pendingCaptures")){const s=e.createObjectStore("pendingCaptures",{keyPath:"uuid"});s.createIndex("sessionId","sessionId"),s.createIndex("timestamp","timestamp"),s.createIndex("[sessionId+targetTimestamp]",["sessionId","targetTimestamp"])}}})}async deleteDB(){try{await Ci("sprigReplay")}catch{}}async bulkAdd(e,t){const r=await this.getTransaction(e);return Promise.all([...t.map(s=>r.store.add(s)),r.done])}async clearAll(){const e=(await this.openDB()).transaction(["events","chunkUploads","pendingCaptures"],"readwrite");return this.wrapTransactionWithCounter(e),Promise.all([e.objectStore("events").clear(),e.objectStore("chunkUploads").clear(),e.objectStore("pendingCaptures").clear()])}async deleteBySessionId(e,t){const r=IDBKeyRange.only(t),s=await this.getTransaction(e),n=s.store.index("sessionId");for await(const i of n.iterate(r))await i.delete();await s.done}async updatePartial(e,t,r){const s=await this.getTransaction(e),n=await s.store.get(t);n&&await s.store.put({...n,...r}),await s.done}async deleteRowsBefore(e,t,r=()=>!0){const s=IDBKeyRange.upperBound(t,!0),n=await this.getTransaction(e),i=n.store.index("timestamp");for await(const a of i.iterate(s))r(a.value)&&await a.delete();await n.done}async getEventsBetween(e,t=Date.now()){if(e>=t)return Promise.resolve([]);const r=IDBKeyRange.bound([be,e],[be,t],!1,!0);return(await this.openDB()).getAllFromIndex("events","[sessionId+timestamp]",r)}async updateEventsExpiredAt(e,t,r=30){const s=new Date,n=s.setMinutes(s.getMinutes()+(r??30)),i=await this.getTransaction("events"),a=i.store.index("[sessionId+timestamp]"),o=IDBKeyRange.bound([be,e],[be,t],!1,!0);for await(const l of a.iterate(o))await l.update({...l.value,expiredAt:n});await i.done}async deleteChunkUploads(e,t){const r=IDBKeyRange.only([t,e]),s=await this.getTransaction("chunkUploads");let i=await s.store.index("[uploadId+status]").openCursor(r);for(;i;)i.delete(),i=await i.continue();await s.done}async getChunkUploadsByStatus({sessionId:e,status:t,uploadId:r}){const s=(await this.openDB()).transaction("chunkUploads","readonly");this.wrapTransactionWithCounter(s);const n=r?s.store.index("[uploadId+status]"):s.store.index("[sessionId+status]"),i=r?IDBKeyRange.only([r,t]):IDBKeyRange.only([e,t]);return n.getAll(i)}async getPendingCaptures(e={}){return(await(await this.openDB()).getAllFromIndex("pendingCaptures","sessionId",be)).filter(r=>!e.beforePresent||r.targetTimestamp<Date.now()).filter(r=>!e.isBeforeType||r.captureParams.replayParams.replayDurationType==="before").filter(r=>!e.isHeatmap||(r.captureParams.isHeatmap??!1))}async tryAddPendingCaptureForSurvey(e){const{surveyId:t,record:r}=e,s=(await this.openDB()).transaction("pendingCaptures","readwrite");this.wrapTransactionWithCounter(s);const n=s.store.index("sessionId"),i=await n.getAll(be),a=!!r.captureParams.isHeatmap;return i.some(o=>o.captureParams.surveyId===t&&!!o.captureParams.isHeatmap===a)?(await s.done,{added:!1}):(await s.store.add(r),await s.done,{added:!0})}async markPendingCaptureToCanUpload(e){const t=await this.getTransaction("pendingCaptures"),r=t.store.index("sessionId");for await(const s of r.iterate(be)){const n=s.value;n.captureParams.responseGroupId===e&&await s.update({...n,canUpload:!0})}await t.done}async markPendingHeatmapsReady(e){if(parseInt(Q.getItem("sprig.pendingCount")??"0")===0)return null;const t=Date.now(),r=await this.getTransaction("pendingCaptures"),s=r.store.index("sessionId");for await(const n of s.iterate(be)){const i=n.value;!i.captureParams.isHeatmap||e&&!e.includes(i.uuid)||await n.update({...i,targetTimestamp:t,captureParams:{...i.captureParams,triggerTimestamp:t,replayParams:{...i.captureParams.replayParams,replayDurationSeconds:Math.floor((t-i.timestamp)/1e3)}}})}await r.done}},Qe=[];let Sr,Gu,gt=[],Dt=!1,Ut=0,hs=!1,$u=!1;const co=[];let Us,Yu,ms,qu,Cn=!1;const Pt=()=>hs&&!Dt&&Date.now()<=Us,Ug=({apiUrl:e,config:t,triggerSnapshot:r,forceInit:s=!1})=>{hs&&!s||(Q.isStorageAvailable?(gt=[],co.splice(0),Qe.splice(0),Ut=0,ms=r,Gu=e,Sr={responseGroupUuid:t.responseGroupUuid,surveyId:t.surveyId,userAgent:t.userAgent,sdkVersion:t.sdkVersion},Yu=t.maxDurationSeconds,Ng(),hs||(qu=globalThis.setInterval(_g,500)),hs=!0):Dt=!0)},Dg=[Ye.Drag,Ye.Input,Ye.MediaInteraction,Ye.MouseInteraction,Ye.MouseMove,Ye.Scroll,Ye.Selection,Ye.TouchMove],Pg=e=>e.type===at.Custom||e.type===at.IncrementalSnapshot&&Dg.includes(e.data.source),uo=e=>e.some(Pg),_g=async()=>{if(!Pt())return void globalThis.clearInterval(qu);if(Ju(),!uo(Qe))return;const e=Qe[0].timestamp;Date.now()-e>35e3&&(ms==null||ms())},Ju=async()=>{if(gt.length||Cn)return;Cn=!0;const e=await Bg();if(!e)return void(Dt=!0);co.splice(0,e.length).forEach(t=>t(e.shift())),e.forEach(t=>gt.push(t)),Cn=!1},Ng=()=>{const e=Q.getItem("sprig.alwayson.info");if(e){_.info("Read stored session state",e);const t=JSON.parse(e);Dt=t.disabled,Sr=t.metadata,gt=t.uploadUrls,Ut=t.currentIndex,Us=t.expirationTimestamp,t.pendingEventTimestamp&&(_.info(`Uploading with pending timestamp: ${t.pendingEventTimestamp}`),Fg(t.pendingEventTimestamp))}else Us=1e3*Yu+Date.now()},Fg=async e=>{const t=Date.now(),r=(await se.getEventsBetween(e,t)).map(n=>JSON.parse(n.event));if(!uo(r))return;Qu(r);const s=await Zu();s&&await Xu(s,r)},Ku=async(e,t)=>{try{const r=await e();if(!r.ok)throw new Error(`Error ${t}`);return r}catch{Dt=!0}},Xu=async(e,t)=>{if(!Pt()||!e)return;const r=await(async s=>{const n=new TextEncoder,i=new CompressionStream("gzip"),a=i.writable.getWriter(),o=n.encode(JSON.stringify(s));return a.write(o),a.close(),new Uint8Array(await new Response(i.readable).arrayBuffer())})(t);_.info("Uploading always-on events with presigned url"),await Ku(()=>He(e,{body:r,method:"PUT"}),"uploading always-on with presigned url")},Bg=async()=>{if(!Pt())return;const{surveyId:e,responseGroupUuid:t}=Sr,r={responseGroupUuid:t,surveyId:e,index:Ut+1};_.info("Fetching always-on upload urls",r);const s=await Ku(()=>He(`${Gu}/sdk/1/replayUrls`,{method:"POST",body:JSON.stringify(r),headers:De(globalThis.UserLeap)}),"fetching always-on signed urls");if(!s)return;const n=s.json.signedUrls;return _.info("Fetched more always-on upload urls",{body:r,urls:n}),n},Zu=async()=>{if(gt.length)return gt.shift();const e=new Promise(t=>{co.push(t)});return Ju(),e},Qu=e=>{var n,i,a;const t=e.length?e[e.length-1].timestamp:Date.now(),r=Ut,s=((i=(n=globalThis.UserLeap)==null?void 0:n.config)==null?void 0:i.customMetadata)??((a=globalThis.__cfg)==null?void 0:a.customMetadata);Ut++,e.push({timestamp:t,type:at.Custom,data:{tag:"Sprig_Meta",payload:{...Sr,index:r,visitorId:globalThis.UserLeap.visitorId??"",timestamp:t,customMetadata:s}}})},zg=(e,t)=>{Pt()&&!$u&&(e||Qe.length)&&(e&&Qe.length&&(async()=>{const r=Qe.splice(0);if(!uo(r))return;_.info("Capturing always-on event array to upload"),Qu(r);const s=await Zu();s&&await Xu(s,r)})(),Qe.push(t))};var hl;(hl=globalThis.addEventListener)==null||hl.call(globalThis,"beforeunload",async()=>{$u=!0,Pt()&&(_.info("Always On handle page unload"),(()=>{let e;Qe.length&&(e=Qe[0].timestamp);const t={disabled:Dt,metadata:Sr,uploadUrls:gt,currentIndex:Ut,pendingEventTimestamp:e,expirationTimestamp:Us};_.info("Storing session state on unload",t),Q.setItem("sprig.alwayson.info",JSON.stringify(t))})())});const ed=async(e,t)=>{const r=performance.now();let s;try{s=await e()}finally{const n=performance.now()-r;let i=br[t];i||(i=Ve(t)),i.report(n/1e3)}return s},td=(e,t)=>{const r=performance.now();try{e()}finally{const s=performance.now()-r;let n=br[t];n||(n=Ve(t)),n.report(s/1e3)}};let rd=5e3,Ti=6e4,Ri=0,ct,Li=!1,Oi=[];const jg=e=>{var t,r,s,n;if((t=e.event)!=null&&t.includes("Sprig_Scroll")){const i=(n=(s=(r=JSON.parse(e.event))==null?void 0:r.data)==null?void 0:s.payload)==null?void 0:n.xPath;if(!i)return;pe.scrollEventUuids[i]=e.uuid}Oi.push(e),Li||Wg()},Wg=()=>{Li=!0,setTimeout(async()=>{if(Ge()||Ms())return;const e=Oi;Oi=[],Li=!1,td(async()=>{await(async t=>{const r=t.map(s=>({...s,sessionId:s.sessionId??be}));if(r.length!==0)return Ee(()=>se.bulkAdd("events",r),"Error storing replay events")})(e)},"sdk_replay_add_event_batch_seconds")},500)},Vg=(e,t,r)=>{pe.cleanupInterval=window.setInterval(()=>{const s=Date.now();ed(()=>Ee(async()=>{Ge()||await Promise.all([se.deleteRowsBefore("events",s-1e3*e,n=>n.expiredAt===void 0||n.expiredAt<s-1e3*e),se.deleteRowsBefore("chunkUploads",s-1e3*t),se.deleteRowsBefore("pendingCaptures",s-1e3*r,n=>!n.canUpload)])},"Error deleting table rows"),"sdk_replay_cleanup_seconds"),_.debug("CleanupComplete")},3e4)},Hg=()=>{pe.pendingCheckInterval=window.setInterval(async()=>{Ee(async()=>{await Ai()},"Error initiating pending captures")},5e3)};let kn=!1;const Ai=async(e=!1)=>{if(!kn)try{kn=!0;const t=parseInt(ct??"0");if(t===0)return;const r=await se.getPendingCaptures({beforePresent:!0,isBeforeType:e}),s=await se.openDB();await Promise.all(r.map(async n=>(await s.delete("pendingCaptures",n.uuid),id(n.captureParams,n.canUpload)))),ct=(t-r.length).toString(),Q.setItem("sprig.pendingCount",ct)}finally{kn=!1}},Gg=async(e,t,r,s,n)=>{const i=Math.min(e+n,r),a=await ed(()=>se.getEventsBetween(e,i),"sdk_replay_get_events_between_seconds");if(!(a!=null&&a.length))return _.debug("NoEventsFound"),{validStartFound:s,events:[]};if(!s){_.debug("ValidStartSearch");let o=-1;return a==null||a.forEach((l,c)=>{if(!l.isValidStart)return;const u=l.timestamp<=t;(o<0||u)&&(o=c)}),o<0?(_.debug("ValidStartNotFound"),{validStartFound:s,events:[]}):{validStartFound:!0,events:a==null?void 0:a.slice(o)}}return{validStartFound:s,events:a}},sd=e=>Promise.all(e.map(async t=>{const r=await(async s=>Uu.execute(async()=>{var a;_.info("UploadChunkStart",{chunkIndex:s.chunkIndex,surveyId:s.surveyId});const n=await He(s.uploadUrl,{body:s.data,method:"PUT"});_.http("UploadChunkEnd",{url:s.uploadUrl,method:"PUT",status_code:n.status,reason:n.statusText??"OK",chunkIndex:s.chunkIndex,surveyId:s.surveyId});const i=(a=n.headers)==null?void 0:a.get("ETag");if(!i)throw new Error(`Upload response did not include etag for upload ${s.uploadId}, part ${s.chunkIndex}`);return i}))(t);return await se.updatePartial("chunkUploads",t.uuid,{data:null,etag:r,status:"UploadComplete"}),t.uploadId})),nd=async e=>{const t=await se.getChunkUploadsByStatus({status:"UploadComplete",uploadId:e});if(!(t!=null&&t.length))return void _.info("NoChunksForUpload",{uploadId:e});const r=t.reduce((i,a)=>(i.find(o=>o.chunkIndex===a.chunkIndex)||i.push(a),i),[]);r.sort((i,a)=>i.chunkIndex-a.chunkIndex);const s=r.map(i=>({ETag:i.etag,PartNumber:i.chunkIndex})).filter(i=>i.ETag!==null),n=r[0];await Du({apiUrl:n.apiUrl,surveyId:n.surveyId,uploadId:e,responseGroupUuid:n.responseGroupId,etags:s,headers:n.completeUploadHeaders,replayDuration:n.replayDuration}),await se.deleteChunkUploads("UploadComplete",e)},$g=()=>{Ee(async()=>{const e=await se.getChunkUploadsByStatus({sessionId:be,status:"ReadyForUpload"});if(!(e!=null&&e.length))return;const t=await sd(e);t!=null&&t.length&&await Promise.all(t.map(r=>{if(r)return nd(r)}))},"Error uploading unfinished chunks")},Yg=async(e,t)=>{const r=t??Date.now();return(async(s,n)=>{const i=new TextEncoder;let a=null;const o=new CompressionStream("gzip"),l=o.writable.getWriter();let c=!1,u=!1,[d,h]=[0,0],f=[];for(let p=s-35e3;p<n;p+=Ti){if({validStartFound:u,events:f}=await Gg(p,s,n,u,Ti),!(f!=null&&f.length)){_.debug("NoEventsFound");continue}d===0&&(d=f[0].timestamp),h=f[f.length-1].timestamp;const C=f.map(v=>v.event);C.push(`{"timestamp":${n}}`);const m=`${c?",":"["}${C}`,g=i.encode(m);td(()=>{l.write(g)},"sdk_replay_compression_seconds"),c=!0}if(h-d<rd)return _.debug("ReplayTooShort"),null;const w=i.encode("]");return l.write(w),l.close(),a=new Uint8Array(await new Response(o.readable).arrayBuffer()),a})(r-e,r)},ul=async e=>{const{surveyId:t,responseGroupId:r,visitorId:s,apiUrl:n,completeUploadHeaders:i,replayParams:a,triggerTimestamp:o}=e,l=await Yg(1e3*a.replayDurationSeconds,o);if(!(l!=null&&l.length))return void _.info("FileDataEmpty",{surveyId:t});const c=((d,h,f)=>{const w=d.length,p=1024*h*1024,C=Math.ceil(w/f),m=Math.max(p,C),g=[];let v=0;for(;v<w;)g.push(d.slice(v,v+m)),v+=m;return g})(l,a.minimumChunkSizeMb,a.signedUrls.length),u=await Promise.all(c.map(async(d,h)=>{const f=bt(),w={apiUrl:n,chunkIndex:h+1,completeUploadHeaders:i,etag:null,responseGroupId:r,status:"ReadyForUpload",surveyId:t,timestamp:o,totalChunks:c.length,data:d,uploadId:a.uploadId,uploadUrl:a.signedUrls[h].url,uuid:f,visitorId:s};return await(await se.openDB()).add("chunkUploads",{...w,sessionId:w.sessionId??be}),w}));await(async(d,h)=>{await sd(h),await Promise.all(d.map(f=>nd(f)))})([a.uploadId],u)},id=async(e,t)=>{if(Ge())return _.debug("ReplayDisabled-ScheduleOrCapture");const{isHeatmap:r,isStandalone:s,replayParams:n,triggerTimestamp:i,responseGroupId:a}=e,o=async()=>{setTimeout(()=>z.removeListener(B.QuestionAnswered,o),0),Ee(async()=>{n.replayDurationType==="before"?await ul(e):await se.markPendingCaptureToCanUpload(a)},"Error in schedule/capture callback")};Ee(async()=>{if(n.replayDurationType==="after"||n.replayDurationType==="beforeAndAfter")return!s&&!r&&z.on(B.QuestionAnswered,o),void await ad(e);if(s||r||t)await ul(e),r&&qg();else{const l=35+n.replayDurationSeconds,c=i-1e3*l,u=i;await se.updateEventsExpiredAt(c,u,n.expirationTimeLimitMinutes),z.on(B.QuestionAnswered,o)}},"Error in scheduling/capturing replay")},qg=async()=>{parseInt(ct??"0")||Q.removeItem("sprig.isCapturingHeatmap"),Q.getItem("sprig.teardownAfterCapture")&&(Hu(),od(),Q.removeItem("sprig.teardownAfterCapture"))},od=async()=>Ge()?_.debug("ReplayDisabled-ClearData"):Promise.all([se.deleteBySessionId("events",be),se.deleteBySessionId("pendingCaptures",be)]).catch(e=>{vr("Error clearing user replay data",e)}),ad=async e=>{if(Ge())return;const{isHeatmap:t,surveyId:r}=e,s={...e,replayParams:{...e.replayParams}};e.replayParams.replayDurationType==="beforeAndAfter"&&(s.replayParams.replayDurationSeconds*=2),s.replayParams.replayDurationType="before";const n=e.triggerTimestamp+1e3*e.replayParams.replayDurationSeconds;s.triggerTimestamp=n;const i={canUpload:!1,captureParams:s,sessionId:be,targetTimestamp:n,timestamp:Date.now(),uuid:bt()},{added:a}=await se.tryAddPendingCaptureForSurvey({surveyId:r,record:i});a?(ct=(parseInt(ct??"0")+1).toString(),Q.setItem("sprig.pendingCount",ct),t&&(xi(),Q.setItem("sprig.isCapturingHeatmap","true"),Ri=Date.now(),pe.inactivityInterval||(pe.inactivityInterval=window.setInterval(()=>{var o;o=Ri,Date.now()-o>=3e4&&Ee(()=>se.markPendingHeatmapsReady(),"Error in heatmap inactivity")},1e3)))):_.info("PendingCaptureExists",{surveyId:r})},Jg=Object.freeze(Object.defineProperty({__proto__:null,RecordEvent:e=>{Je("Sprig_TrackEvent",e)},RecordPageView:e=>{e.description&&(e.description=lo(e.description)),Je("Sprig_PageView",e)},RecordSurveyShown:e=>{Je("Sprig_ShowSurvey",e)},_completeSessionReplay:async({surveyId:e,responseGroupUuid:t,eventDigest:r,headers:s})=>{if(!e||!t)return!1;const n=globalThis.UserLeap._API_URL,i=await Du({surveyId:e,responseGroupUuid:t,eventDigest:r,apiUrl:n,headers:s},!0);return!(i!=null&&i.error)},checkPendingHeatmapsUrl:()=>Ge()?_.debug("ReplayDisabled-PendingHeatmaps"):Ee(async()=>{const e=(await se.getPendingCaptures({isHeatmap:!0})).map(t=>({eventId:t.captureParams.eventId,uuid:t.uuid})).filter(({eventId:t})=>!hu(t)).map(({uuid:t})=>t);return _.info("PendingHeatmapsToComplete",{count:e.length}),e.length&&(await se.markPendingHeatmapsReady(e),_.info("MarkedPendingHeatmapsReady")),e.length},"Error marking pending heatmaps ready"),clearUserReplayData:od,disableRecording:vr,initializeReplay:async({maxReplayDurationSeconds:e,maxInflightRequests:t=2,replaySettings:r,teardownAfter:s=!1,apiUrl:n,alwaysOnConfig:i})=>{if(i&&Ug({apiUrl:n,config:i,triggerSnapshot:()=>{xi()}}),ct=Q.getItem("sprig.pendingCount"),pe.isRecording)return;if(s&&Q.setItem("sprig.teardownAfterCapture","true"),Ge())return _.debug("ReplayDisabled");if(await(async()=>{var l;if(!Vu())return!0;if((l=globalThis.navigator.storage)!=null&&l.estimate)try{const{quota:c=0,usage:u=0}=await globalThis.navigator.storage.estimate(),d=(c-u)/1024**3;return _.info("Storage",{availableGb:d}),d<.5}catch{return!0}return!1})())return _.debug("IDBNotSupported"),Ei();try{const l=await se.openDB();_.info("DBVersion",{version:l.version})}catch(l){return _.error("ReplayOpenErr",{name:l.name}),l.name==="VersionError"&&se.deleteDB(),Ei()}Ee(async()=>{await Ai(!0)},"Error uploading ready pending captures");const a=Pt()?30:0,o=Math.max(e??0,a);if(!o)return _.debug("MissingDuration");_.debug("ReplayInit"),await Ee(async()=>{var l;r!=null&&r.minDuration&&(rd=r.minDuration),r!=null&&r.batchDuration&&(Ti=r.batchDuration),l=t,Uu.setLimit(l),$g(),Vg(o+35,1800,o+35),Hg();const c=window.UserLeap.replayLibraryURL??"https://cdn.sprig.com/dependencies/record.min.js",u=window.rrwebRecord;if(!u)return _.error("RecordScriptFailed");let d=!0,h=0;const f={checkoutEveryNms:3e4,sampling:{input:"last",scroll:250,media:800},...r,mutationQueueEnabled:r==null?void 0:r.enableMutationQueue};var w,p;pe.stopRecording=u({emit:(C,m)=>{if(C.type===at.Custom&&(Ri=Date.now()),Ge()||Ms())return;if(m&&C.type===at.Meta)h=performance.now();else if(m&&h&&C.type===at.FullSnapshot){const v=performance.now()-h;Su("sdk_replay_snapshot_seconds",v/1e3)}const g=d||!!m&&C.type===at.Meta;d=!1,zg(g,C),jg({uuid:bt(),event:JSON.stringify(C),isValidStart:g,timestamp:Date.now()})},...f}),pe.isRecording=!!pe.stopRecording,pe.isRecording&&(((C,m)=>{window.addEventListener("message",g=>{var v;g.data.type===vg&&(ao.push({source:g.source,origin:g.origin}),(v=g.source)==null||v.postMessage({type:Sg,settings:C,replayLibraryUrl:m},{targetOrigin:g.origin}))})})(f,c),z.on("survey.complete",C=>{var m;m={id:C,userAgent:window.navigator.userAgent},Je("Sprig_SubmitSurvey",m)}),w=Je,p=Og,As||(xe=w,ps=p,window.addEventListener("click",zu,We),window.addEventListener("pointerdown",Wu,We),window.addEventListener("mousedown",ju,We),window.addEventListener("keydown",Fu,We),window.addEventListener("scroll",Bu,We),As=!0,Rg(),Lg()))},"Error initializing replay")},isReplayPaused:Ms,isReplayRecording:()=>pe.isRecording,recordFullSnapshot:xi,recordReplayPaused:()=>{Je("Sprig_ReplayPaused",{timestamp:Date.now()}),Q.setItem("sprig.isReplayPaused","true")},recordReplayResumed:()=>{Q.removeItem("sprig.isReplayPaused"),Je("Sprig_ReplayResumed",{timestamp:Date.now()})},scheduleCapture:ad,scheduleOrCaptureReplay:id,tryReplayAction:Ee,uploadReadyPendingCaptures:Ai},Symbol.toStringTag,{value:"Module"}));(e=>{re.replay=e})(Jg),window.UpChunk={createUpload:Yd},window.rrwebRecord=qt,exports.APP_ID="ul-app",exports.ConflictingWidgets=ru,exports.DEFAULT_BORDER_COLOR="#e6e6e6",exports.DEFAULT_WIDTH_PX=360,exports.DismissReason=Ae,exports.EMBED_MOBILE_MAX_WIDTH=1030,exports.ERROR_BORDER_COLOR="#bd282a",exports.Sprig=pg,exports.SprigAPI=Ls,exports.SprigEvent=B,exports.breadcrumbsLogger=_,exports.calculateFrameDimensions=mu,exports.debounce=_u,exports.eventEmitter=z,exports.getHtml=Js,exports.groupCards=(e,t)=>{const r=[e[t]],s=e[t].groupId;return s?e.slice(t).reduce((n,i)=>(i.groupId===s&&n.push(i),n),[]):r},exports.isHTMLElement=qe,exports.isLongFormSurvey=e=>e==="longFormSurvey",exports.resetScrollPosition=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},exports.setSurveyStyles=fr,exports.shouldDirectEmbed=to,exports.sprig=dg,exports.sprigFetch=He,exports.v4=bt;
|