UNPKG

zipyai

Version:

SDK for zipy

1 lines 108 kB
import{record as e,EventType as t,pack as n,MouseInteractions as r}from"zipy-rrweb";import{v4 as o}from"uuid";import{strToU8 as i,zlibSync as s,strFromU8 as a}from"fflate";import c from"lz-string";var u,d,l;!function(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.ReplayerEvent=11]="ReplayerEvent",e[e.ConsoleInfo=50]="ConsoleInfo",e[e.ConsoleError=51]="ConsoleError",e[e.ConsoleWarning=52]="ConsoleWarning",e[e.ConsoleDebug=53]="ConsoleDebug",e[e.Error=70]="Error",e[e.RangeError=71]="RangeError",e[e.ReferenceError=72]="ReferenceError",e[e.TypeError=73]="TypeError",e[e.SyntaxError=74]="SyntaxError",e[e.URIError=75]="URIError",e[e.EvalError=76]="EvalError",e[e.UnhandledRejection=77]="UnhandledRejection",e[e.BROWSERDATA=100]="BROWSERDATA",e[e.NAVIGATION=101]="NAVIGATION",e[e.Online=102]="Online",e[e.Offline=103]="Offline",e[e.XHR=104]="XHR",e[e.WSOPEN=105]="WSOPEN",e[e.WSCLOSE=106]="WSCLOSE",e[e.WSMESSAGE=107]="WSMESSAGE",e[e.WSERROR=108]="WSERROR",e[e.Fonts=109]="Fonts",e[e.Link=110]="Link",e[e.Css=111]="Css",e[e.Image=112]="Image",e[e.Js=113]="Js",e[e.Media=114]="Media",e[e.ZipyLogMessage=115]="ZipyLogMessage",e[e.ZipyLogException=116]="ZipyLogException",e[e.ZipyLogFrontendError=117]="ZipyLogFrontendError",e[e.ZipyLogNetworkError=118]="ZipyLogNetworkError",e[e.Performance=119]="Performance",e[e.PerfNavigation=120]="PerfNavigation",e[e.OtherNetworkCall=121]="OtherNetworkCall",e[e.WebVitals=122]="WebVitals",e[e.NavigationStart=123]="NavigationStart",e[e.DEBUG_INFO=124]="DEBUG_INFO",e[e.CustomEvent=125]="CustomEvent",e[e.CpuUsage=126]="CpuUsage",e[e.MemoryUsage=127]="MemoryUsage"}(u||(u={})),function(e){e[e.MESSAGESEND=0]="MESSAGESEND",e[e.MESSAGERECEIVED=1]="MESSAGERECEIVED",e[e.SOCKETCLOSE=2]="SOCKETCLOSE",e[e.SOCKETERROR=3]="SOCKETERROR",e[e.SOCKETOPEN=4]="SOCKETOPEN"}(d||(d={})),function(e){e[e.ELEMENT=0]="ELEMENT",e[e.EVENT=1]="EVENT",e[e.FIRST_INPUT=2]="FIRST_INPUT",e[e.LARGEST_CONTENTFUL_PAINT=3]="LARGEST_CONTENTFUL_PAINT",e[e.LAYOUT_SHIFT=4]="LAYOUT_SHIFT",e[e.LONGTASK=5]="LONGTASK",e[e.MARK=6]="MARK",e[e.MEASURE=7]="MEASURE",e[e.NAVIGATION=8]="NAVIGATION",e[e.PAINT=9]="PAINT",e[e.RESOURCE=10]="RESOURCE"}(l||(l={}));var f,p,v,g="zipy",m="rrweb";!function(e){e[e.POSTENDUSERINFOANDGETUSERCONFIG=0]="POSTENDUSERINFOANDGETUSERCONFIG",e[e.POSTENDUSERINFO=1]="POSTENDUSERINFO",e[e.GETUSERCONFIG=2]="GETUSERCONFIG"}(f||(f={})),function(e){e[e.ANONYMS=0]="ANONYMS",e[e.IDENTIFIED=1]="IDENTIFIED"}(p||(p={})),function(e){e[e.NORECORDING=0]="NORECORDING",e[e.RECORDINGPENDING=1]="RECORDINGPENDING",e[e.RECORDINGSUCCESSFUL=2]="RECORDINGSUCCESSFUL"}(v||(v={}));var y,w,h,E,S="logEvent",I="exceptionEvent",z="errorEvent",C=1024,b="startIframeRecording",T="stopIframeRecording",k="iframeContentLoaded";(E=y||(y={})).DEBUG="1",E.WARNING="2",E.ERROR="3",E.LOG="4",function(e){e[e.BLOCKING=0]="BLOCKING",e[e.NON_BLOCKING=1]="NON_BLOCKING"}(w||(w={})),function(e){e.session_data="_zsession-data",e.total_data_sent="_ztotal-data-sent",e.enduser_last_activity_time="_zenduser-last-activity-time",e.last_activity_time="_zlast-activity-time",e.utms="_utms"}(h||(h={}));var R,N=/^(?!-)[A-Za-z0-9-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,6}$/,O=/^(https?|ftp):\/\/(([a-z\d]([a-z\d-]*[a-z\d])?\.)+[a-z]{2,}|localhost)(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?(\#[-a-z\d_]*)?$/i,P=499;!function(e){e[e.FCP=0]="FCP",e[e.FP=1]="FP",e[e.FID=2]="FID",e[e.CLS=3]="CLS",e[e.LCP=4]="LCP"}(R||(R={}));var U,D,x,L={"Content-Type":"application/json","Content-Encoding":"gzip"};!function(e){e.INIT="init",e.REINIT="reinit",e.PAGE_OUT="pageout"}(U||(U={})),function(e){e.PAGELOAD="pageload",e.VISIBLE="visibility visible",e.VISIBLEFOCUSED="visible and focused",e.HIDDEN="visibility hidden",e.IDENTIFY="identify",e.ANONYMIZE="anonymize",e.STREAMDATARECORDINGPAUSE="streamdata recording paused",e.STREAMDATAEXPIRE="streamdata session expired",e.FOCUS="focus",e.BLUR="blur",e.NA=""}(D||(D={})),function(e){e[e.IDLE=0]="IDLE",e[e.PENDING=1]="PENDING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED"}(x||(x={}));var A,F=["utm_source","utm_medium","utm_term","utm_content","utm_campaign"];!function(e){e[e.STOP=0]="STOP",e[e.START=1]="START"}(A||(A={}));var _={streamMgrUrl:"https://services.zipy.ai/sdk-session-manager/v2/enduser-info",registerSessionUrl:"https://services.zipy.ai/sdk-session-manager/v1/register-sdk-session",notifyUserURL:"https://services.zipy.ai/sdk-session-manager/v1/nu",sdkVersion:"1.0.51",errorUrl:"divolte.collector",streamMgrRetryCount:5,zipyDeploymentEnviornment:"Production",sdkLoopTime:1e3,perfLoopTime:5e3,ignoreEmptyErros:!0,ignoreLargeResponse:!0,debugLogs:!1,sessionLinkUrl:"https://app.zipy.ai",isNPM:!0,streamMgrRetryDelay:5e3,maxPayloadSize100KB:102400},M=!1;function q(e){M&&console.info(g,e)}function G(e){M&&console.debug(g,e)}function B(e){M&&console.log(g,e)}function J(e){M&&console.error(g,e)}function j(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Z(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return j(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?j(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},H.apply(null,arguments)}function K(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(K=function(){return!!e})()}function W(e,t){return W=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},W(e,t)}var V=new Map;function X(e){try{var t=window.localStorage.getItem(e);return q("inside zLocalStorageGetItem for key :"+e+" and value :"+t),!t&&(q("fetched value from hashmap :"+(t=V.get(e))),t)?(q("Going to update local storage:"),function(){try{q("inside localStorageUpdate function");for(var e,t=Z(V.entries());!(e=t()).done;){var n=e.value;window.localStorage.getItem(n[0])||(q("Going inside localStorageUpdate-2 for key :"+n[0]+" and value :"+n[1]),Y(n[0],n[1]))}}catch(e){J("inside updateLocalStorage catch block ${e.message}")}}(),t):t}catch(e){return void J("inside zLocalStorageGetItem catch block ${e.message}")}}function Y(e,t){try{q("inside zLocalStorageSetItem for key :"+e+" and value :"+t),V.set(e,t),window.localStorage.setItem(e,t)}catch(e){J("inside zLocalStorageSetItem catch block ${e.message}")}}function $(e){try{q("inside zLocalStorageRemoveItem for key :"+e),V.delete(e),window.localStorage.removeItem(e)}catch(e){J("inside zLocalStorageSetItem catch block ${e.message}")}}function Q(){try{for(var e=Object.keys(localStorage),t=0;t<e.length;t++)["zsession-blocked-info","session-data","zId","zenduser-info-temp","zenduser-info","last-activity-time","pack","zsdk-config","is-api-key-valid","zenduser-last-activity-time","ztotal-data-sent"].includes(e[t])&&(V.set(e[t],localStorage.getItem(e[t])),q("updated value in map is :"+V.get(e[t])))}catch(e){J("inside zLocalStorgeMapUpdate catch block ${e.message}")}}function ee(){var e=X("zsdk-config");if(e)try{return JSON.parse(e)}catch(e){return void J("Failed to parse sdk Config Data")}}function te(e){if(e)try{q("Updating zsession-blocked-info"+JSON.stringify(e)),Y("zsession-blocked-info",JSON.stringify(e))}catch(e){J("Failed to stringify zsession-blocked-info ")}}function ne(e){var t=Ge.getInstance(),n={isBlocked:!1,blockedEndTime:0,apiKey:e};try{t.sessionBlockInfo=n,q("Updating zsession-blocked-info"+JSON.stringify(n)),Y("zsession-blocked-info",JSON.stringify(n))}catch(e){J("Failed to stringify zsession-blocked-info ")}}function re(){var e=X("zsession-blocked-info"),t=Ge.getInstance();if(e)try{var n=JSON.parse(e);return t.sessionBlockInfo=n,n}catch(e){return void J("Failed to parse zsession-blocked-info")}}var oe=/*#__PURE__*/function(){function e(){this.rootDomain="",this.releaseVer="",this.recordOnlyIframe=!1,this.proxyURL="",this.rootDomain="",this.releaseVer="",this.recordOnlyIframe=!1,this.proxyURL=""}var t=e.prototype;return t.saveOptions=function(e){this.releaseVer=e.releaseVer?e.releaseVer:this.releaseVer,this.rootDomain=this.isValidRootDomain(e.rootDomain)?e.rootDomain:this.rootDomain,this.recordOnlyIframe="boolean"==typeof e.recordOnlyIframe?e.recordOnlyIframe:this.recordOnlyIframe,this.proxyURL=this.isValidProxyURL(e.proxyURL)?e.proxyURL:this.proxyURL},t.isValidRootDomain=function(e){return!(!e||!new RegExp(N).test(e))},t.isValidProxyURL=function(e){return!(!e||!new RegExp(O).test(e))},e.getInstance=function(){return this.instance||(this.instance=new e),this.instance},e}();function ie(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}oe.instance=void 0;var se=function e(t,n,r){try{return Promise.resolve(ie(function(){var o=oe.getInstance(),i=new URL(t+"/"+n.apiKey),s=new URL((o.proxyURL?o.proxyURL:i.origin)+i.pathname);return Promise.resolve(fetch(s.href,{method:"POST",headers:He(i.origin,o.proxyURL,{"Content-Type":"application/json"}),body:JSON.stringify(n)})).then(function(o){return o.ok?(G("Response status = "+o.status),!0):(G("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(J("Not able to send data after all retries"),!1))})},function(e){return J("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},ae=function e(t,n,r){try{return Promise.resolve(ie(function(){var o=$e(),i=oe.getInstance();return Promise.resolve(fetch(t,{method:"POST",headers:He(o.customEventUrl,i.proxyURL,L),body:JSON.stringify(n)})).then(function(o){return o.ok?(G("Response status = "+o.status),!0):(G("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(J("Not able to send data after all retries"),!1))})},function(e){return J("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},ce=function e(t,n,r,o,i){void 0===n&&(n=5),void 0===i&&(i={});try{return Promise.resolve(ie(function(){var s=oe.getInstance(),a=new URL(t),c=new URL((s.proxyURL?s.proxyURL:a.origin)+a.pathname);return null!=r&&Object.keys(r).forEach(function(e){return c.searchParams.append(e,r[e])}),Promise.resolve(fetch(c.href,{method:"POST",headers:He(a.origin,s.proxyURL,{"Content-Type":"application/json"}),body:JSON.stringify(o)})).then(function(s){return s.ok?(G("postDataOnServer :: Response status = "+s.status),Promise.resolve(s.json()).then(function(e){return G("postDataOnServer :: Response JSON = "+e),e})):404==s.status?(Y("is-api-key-valid","false"),me(!1),!1):(G("Error :: Response status = "+s.status),n>0?void setTimeout(function(){return ve+=_.streamMgrRetryDelay,e(t,n-1,r,o,i)},ve):(J("Not able to post enduser config after multiple retries"),!1))})},function(e){return J("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},ue=function e(t,n,r){try{return Promise.resolve(ie(function(){var o=$e(),i=oe.getInstance();return Promise.resolve(fetch(t,{method:"POST",headers:He(o.pagePerfUrl,i.proxyURL,L),body:JSON.stringify(n)})).then(function(o){return o.ok?(G("Response status = "+o.status),!0):(G("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(J("Not able to send data after all retries"),!1))})},function(e){return J("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},de=function e(t,n,r){try{return Promise.resolve(ie(function(){var o=$e(),i=oe.getInstance();return Promise.resolve(fetch(t,{method:"POST",headers:He(o.heatMapUrl,i.proxyURL,L),body:JSON.stringify(n)})).then(function(o){return o.ok?(G("Response status = "+o.status),!0):(G("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(J("Not able to send data after all retries"),!1))})},function(e){return J("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},le=function e(t,n,r){try{return Promise.resolve(ie(function(){var o=$e(),i=oe.getInstance();return Promise.resolve(fetch(t,{method:"POST",headers:He(o.perfUrl,i.proxyURL,L),body:JSON.stringify(n)})).then(function(o){return o.ok?(G("Response status = "+o.status),!0):(G("Error :: Response status = "+o.status),r>0?e(t,n,r-1):(J("Not able to send data after all retries"),!1))})},function(e){return J("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},fe=function t(n){var r=n.divolteUrl,o=n.divolteJson,i=n.failureRetryCount;try{return Promise.resolve(ie(function(){var n=JSON.stringify(o),s=$e(),a=oe.getInstance();return Promise.resolve(fetch(r,{method:"POST",headers:He(s.streamUrl,a.proxyURL,L),body:n})).then(function(s){return $e()&&$e().splitSessionSize>0&&(B("Request size "+(new TextEncoder).encode(n).byteLength),function(t){try{var n=JSON.parse(t).events,r=jt(n),o=Ge.getInstance(),i=X("ztotal-data-sent")?X("ztotal-data-sent"):"0",s=parseInt(i)+r;B("Current data size "+i),B("Merged data size "+s);var a=!0;o.isCheckoutFlowTriggered?a=!function(e){var t=Ge.getInstance(),n=Jt(e);if(n>=0)return t.isCheckoutFlowTriggered=!1,Y("ztotal-data-sent",jt(e.slice(n,e.length)).toString()),!0;var r=window.zEventsData||[],o=r.slice(e.length,r.length);return o&&o.length&&-1===Jt(o)&&(t.isCheckoutFlowTriggered=!1),!1}(n):s>$e().splitSessionSize&&!o.isCheckoutFlowTriggered&&function(){try{B("Trigger checkout flow triggered"),e.takeFullSnapshot(!0)}catch(e){J("Error in checking full snapshot. Error is - "+e.message)}}(),a&&Y("ztotal-data-sent",JSON.stringify(s))}catch(e){J("Error in checking data size. Error is - "+e.message)}}(o.parameters.eventData)),s.ok?(G("Response status = "+s.status),!0):(G("Error :: Response status = "+s.status),i>0?t({divolteUrl:r,divolteJson:o,failureRetryCount:i-1}):(J("Not able to send data after all retries"),!1))})},function(e){return J("Not able to get response from server with ERROR: "+e),!1}))}catch(e){return Promise.reject(e)}},pe=!0,ve=_.streamMgrRetryDelay;function ge(){return pe}function me(e){pe=e}function ye(){var e=X("zId");return e||(Y("zId",e=je()),e)}function we(){var e=X("zenduser-info");if(e)try{return JSON.parse(e)}catch(e){return void J("Failed to parse end user Info data")}}function he(){var e=X("zenduser-info-temp");if(e)try{return JSON.parse(e)}catch(e){return void J("Failed to parse end user Info data")}}function Ee(e){ye(),we()||q("Creating new enduser-info"+JSON.stringify(e));try{q("Updating enduser-info"+JSON.stringify(e)),Y("zenduser-info",JSON.stringify(e))}catch(e){J("Failed to stringify enduser-info ")}}function Se(e){ye(),we()||q("Creating new enduser-info-temp"+JSON.stringify(e));try{q("Updating enduser-info-temp"+JSON.stringify(e)),Y("zenduser-info-temp",JSON.stringify(e))}catch(e){J("Failed to stringify enduser-info-temp ")}}function Ie(){he()?(q("Removing zenduser-info-temp"),$("zenduser-info-temp")):q("zenduser temp Data dosen't exists")}function ze(){var e=we();return e?e.userType===p.IDENTIFIED:(q("zenduser-info doesn't exists"),!1)}function Ce(e,t){e.euId=0,e.euZName="",e.isBlocked=!1,e.zAnonymsUserInfo={euId:0,euZName:"",zId:null!=t?t:""}}function be(e,t){var n,r,o=ye();(null==e||null==(n=e.zAnonymsUserInfo)?void 0:n.zId)===o?(q("ZId match"),e.euId=e.zAnonymsUserInfo.euId,e.euZName=e.zAnonymsUserInfo.euZName):(q("ZId dosen't match Zid : "+o+" and Anonyms user Zid: "+(null==e||null==(r=e.zAnonymsUserInfo)?void 0:r.zId)),Ce(e,o)),t?Se(e):Ee(e)}function Te(){if(he())return q("Temp storage has some pending data to post"),!0;var e=we();if(!e)return q("zenduser Data dosen't exists"),!0;if(0===e.euId)return q("Euid value is 0, required to fetch data again"),!0;if(e.userType===p.ANONYMS){var t,n;if(null==e||null==(t=e.zExternalUserInfo)?void 0:t.externalId)return q("External User details exists, and userType is ANONYMS need to post data"),!0;var r=ye();if((null==(n=e.zAnonymsUserInfo)?void 0:n.zId)!==r)return q("ZId dosen't match Zid : "+r+" and Anonyms user Zid: "+e.zAnonymsUserInfo.zId),Ce(e,r),Ee(e),!0;q("ZId match No need to update for anonyms user")}return!1}var ke=function(e){try{var t,n,r=document.cookie,o=null==r?void 0:r.split(";"),i=!1;return o.forEach(function(r){var o=r.split("=");if(o[0].trim()===e){var s=o[1].split(",");s.length>1?(n=Oe(s),i=!0):t=o[1]?o[1]:""}}),i?n:t}catch(e){return void J("inside zGetCookie catch block")}},Re=function(e,t){var n=oe.getInstance(),r=new Date((new Date).valueOf()+216e5).toUTCString();document.cookie=e+"="+t+"; path=/; domain="+n.rootDomain+"; expires="+r+";"},Ne=function(e){var t=oe.getInstance(),n=new Date((new Date).valueOf()-1e3).toUTCString();document.cookie=e+'=""; path=/; domain='+t.rootDomain+"; expires="+n+";"},Oe=function(e){var t={};return e.forEach(function(e){var n=e.split("#");t[n[0]]=n[1]?n[1]:""}),t||{}},Pe=function(e){var t=ke(e+h.enduser_last_activity_time),n=ke(e+h.total_data_sent)?ke(e+h.total_data_sent):"0",r=ke(e+h.session_data),o=ke(e+h.last_activity_time),i=Ge.getInstance();try{if(o){(t||r||o)&&(i.isSessionExpired=!1);var s="0:"+je().replace("-",":");Y("ztotal-data-sent",n),Y("last-activity-time",o),Y("zenduser-last-activity-time",t),i.enduserLastActivityTime=t,i.lastActivityTime=o;var a=we()||{},c=re()||{},u=De()||{};a.isBlocked="true"===(null==r?void 0:r.isBlocked),a.euId=Number(null==r?void 0:r.euId),a.zAnonymsUserInfo.zId=(null==r?void 0:r.zId)||"",ze()||(a.zExternalUserInfo.externalId=(null==r?void 0:r.externalId)||""),c.isBlocked="true"===(null==r?void 0:r.isBlocked),u.dSession=s,u.sessionId=(null==r?void 0:r.sessionId)||"",u.sdkKey=(null==r?void 0:r.sdkKey)||"",Y("zId",(null==r?void 0:r.zId)||""),te(c),Y("zenduser-info",JSON.stringify(a)),Y("zenduser-info-temp",JSON.stringify(a)),Y("session-data",JSON.stringify(u))}}catch(e){return void J("inside zSetLocalStorageDataFromCookie catch block")}},Ue=function(e){var t=function(){try{var e=we(),t=re(),n=De()||{},r=X("zId"),o=X("last-activity-time"),i=X("ztotal-data-sent")?X("ztotal-data-sent"):"0",s=X("zenduser-last-activity-time");return{sessionId:null==n?void 0:n.sessionId,zId:r,euId:null==e?void 0:e.euId,isBlocked:null==t?void 0:t.isBlocked,sdkKey:null==n?void 0:n.sdkKey,lastActivityTime:o,totalDataSent:i,endUserLastActivityTime:s,externalId:(null==e?void 0:e.zExternalUserInfo.externalId)||""}}catch(e){return void J("inside zGetCookieDatafromLocalStorage catch block")}}();try{var n="sessionId#"+t.sessionId+",isBlocked#"+t.isBlocked+",sdkKey#"+e+",zId#"+t.zId+",euId#"+Number(t.euId)+",externalId#"+t.externalId;Re(e+h.session_data,n),Re(e+h.last_activity_time,t.lastActivityTime),Re(e+h.enduser_last_activity_time,t.endUserLastActivityTime),Re(e+h.total_data_sent,t.totalDataSent)}catch(e){return void J("inside zSetCookieDataFromLocalStorage catch block")}};function De(){var e=X("session-data");if(e)try{return JSON.parse(e)}catch(e){return void J("Failed to parse session data")}}function xe(e){var t=Ge.getInstance();if(t.isSessionExpired)return G("Session is already expired"),!0;var n=(De()||{}).sessionId,r=Number(X("last-activity-time"));return!n||r+e.sessionTimeout<=Date.now()?(q("Session is expired"),t.isSessionExpired=!0,!0):!function(e){var t=Le();return!(!t||t+e.sessionTimeout<=Date.now())}(e)&&(t.isSessionExpired=!0,!0)}function Le(){try{var e=Ge.getInstance().enduserLastActivityTime;if(!e){if(!(e=Number(X("zenduser-last-activity-time"))))return 0;e=Number(e)}return e}catch(e){return J("inside getZendUserActivityTime catch block"),0}}function Ae(){var e=X("pack");if(!e){var t=$e();Y("pack",e=t.pack?t.pack.toString():(!1).toString())}return"true"===e}function Fe(e){ne(e),Y("ztotal-data-sent","0"),$("zUTMParams"),function(e){var t={sessionId:"",dSession:"",isNewSession:!1,sdkKey:e};try{q("Updating session-data"+JSON.stringify(t)),Y("session-data",JSON.stringify(t))}catch(e){J("Failed to stringify zsession-blocked-info ")}}(e),Ne(e+h.utms)}function _e(e){var t=Ge.getInstance(),n=X("zId");n||Y("zId",n=je());var r=je(),o="0:"+je().replace("-",":");Fe(e);var i={sessionId:r,dSession:o,isNewSession:!0,sdkKey:e};Y("is-api-key-valid","true"),me(!0);try{q("Created new Session"+JSON.stringify(i)),t.sessionId=i.sessionId,t.apiKey=i.sdkKey,t.isNewSession=i.isNewSession,t.isSessionExpired=!1,t.lastActivityTime=Date.now(),t.enduserLastActivityTime=Date.now(),t.isCheckoutFlowTriggered=!1,Y("last-activity-time",t.lastActivityTime.toString()),Y("zenduser-last-activity-time",t.enduserLastActivityTime.toString()),Y("session-data",JSON.stringify(i)),Q()}catch(e){J("Failed to stringify session data")}}function Me(e){var t=De();return!!t&&e!==(null==t?void 0:t.sdkKey)&&(q("Sdk key is chnaged going to create session data"),!0)}function qe(){window.zEventsPerfData=[],window.zClickEventsData=[],window.zFetchTempData=[],window.zEventsData=[],window.zCustomEventData=[],window.zPagePerfData=[]}var Ge=/*#__PURE__*/function(){function e(){var e;this.sessionId="",this.isSessionExpired=!1,this.lastActivityTime=void 0,this.enduserLastActivityTime=void 0,this.sessionBlockInfo={isBlocked:!1,blockedEndTime:0,apiKey:""},this.apiKey="",this.isNewSession=!1,this.isCheckoutFlowTriggered=!1,this.sessionId=null==(e=De())?void 0:e.sessionId}return e.getInstance=function(){return this.instance||(this.instance=new e),this.instance},e}();function Be(){return Date.now()}function Je(e,t,n){var r={capture:!0,passive:!0};return n.addEventListener(e,t,r),function(){return n.removeEventListener(e,t,r)}}function je(){var e=Math.floor(Date.now()/1e3);return o()+"-"+e}function Ze(e){var t={externalId:"enduser_external_id",firstName:"eu_first_name",lastName:"eu_last_name",email:"eu_email",age:"eu_age",customerName:"eu_customer_name",avatar:"eu_avatar",phone:"eu_phone"};return e in t?t[e]:e}function He(e,t,n){var r=e.split("//")[1];return t&&(n["X-host"]=r),n}Ge.instance=void 0;var Ke,We={attributes:!0,childList:!0,characterData:!0,subtree:!0};!function(e){e[e.Progress=0]="Progress",e[e.Completed=1]="Completed",e[e.Failed=2]="Failed"}(Ke||(Ke={}));var Ve={domCapture:!0,consoleCapture:!0,networkCapture:!0,stackTraceCapture:!0,webSocketsCapture:!1,ipCapture:!0,inputMasking:!0,textMasking:!1,paid:!1,apiKey:"",streamUrl:"https://collector.zipy.ai",perfUrl:"https://perfcollector.zipy.ai",heatMapUrl:"https://heatmapcollector.zipy.ai",pagePerfUrl:"https://pageperfcollector.zipy.ai",customEventUrl:"https://customeventcollector.zipy.ai",maxBufferSize:5e6,compression:!0,compressionType:"gzip",timeFrequency:1e3,perfTimeFrequency:5e3,clickTimeFrequency:1e3,encodingType:"",sessionTimeout:18e5,failureRetryCount:5,bufferSizeFrequency:1048576,perfBufferSizeFrequency:1024,clickBufferSizeFrequency:1024,ignoreUrl:["google.com","zipy.ai","mixpanel","extreme-ip-lookup.com","hotjar","smartlook.com","newrelic.com","bugsnag","fullstory","sentry.io","google-analytics.com","bam.nr-data.net","wistia.com","amplitude.com","segment.io","pendo.io","raygun","smartlook.cloud","segment.com","visualstudio.com","stats.g.doubleclick.net","pagead2.googlesyndication.com","r.lr-in.com","clarity.ms","appcues.net","datadoghq.com"],ignoreError:["rrweb","zipy","Script error","pagead2.googlesyndication.com","adsbygoogle"],ignoreConsole:["{}"],isIgnoreUrlError:["google.com","zipy.ai","mixpanel","extreme-ip-lookup.com","hotjar","smartlook.com","newrelic.com","bugsnag","fullstory","sentry.io","google-analytics.com","bam.nr-data.net","wistia.com","amplitude.com","segment.io","pendo.io","raygun","smartlook.cloud","segment.com","visualstudio.com","stats.g.doubleclick.net","pagead2.googlesyndication.com","r.lr-in.com","clarity.ms","appcues.net","datadoghq.com"],isIgnoreConsoleError:["{}"],ip:"",pack:!0,blockClasses:"zipy-block",xhrReqPayloadCapture:!1,xhrRespPayloadCapture:!1,canvasCapture:!1,scrubbingKey:["password","secret","passwd","api_key","apikey","access_token","auth","credentials","mysql_pwd","stripetoken","cardnumber"],requestCapSize:1e6,responseCapSize:1e6,sizeExceededMessage:{message:"size too large",source:"zipy"},eventCountCapInSingleChunk:0,captureCustomZipyLogMessage:!1,captureCustomZipyLogError:!1,captureCustomZipyLogException:!1,startCaptureWithoutUserActivity:!1,consoleLogLevel:"3",recordCrossOriginIframes:!0,splitSessionSize:0,capturePerformance:!1,capturePagePerf:!1,captureClickEvents:!1,captureCustomEvents:!1,isApiIdentifierEnable:!1,apiUniqueIdentifier:[],ignoreUrlErrorCodes:{},ignoreUrlCodes:{},sessionStitching:!1,captureCancelledRequest:!1,clsEventCount:5,clsTimeout:3e4,xhrEventsTimeout:3e4,blockSelector:"",maxCustomEventProperties:10,maxCustomEventPayloadSize:524288,sanitizePayloadResponse:!0,captureUTM:!1,customRecording:!1,tabStateManagement:!1,captureCPU:!1,captureMemory:!1,cpuCapturingFrequency:15e3,memoryCapturingFrequency:15e3,liveAlerts:!1},Xe=function(e){try{var t=function(){return{requestUrl:n,requestMethod:r,headers:o,request:s,requestByteSize:i}},n="",r="GET",o={},i=0,s={},a=function(t,a){try{var c=function(){function t(){var t=e.length>1&&e[1];t&&(r=t.method||r,t.headers&&(o=nt(t.headers)),t.body&&(i=JSON.stringify(t.body,null,4).length,s=t.body))}q("Going to process fetch arguments.");var a=e.length>0&&e[0],c=function(){if(a){var e=function(){if("string"==typeof a)n=a;else{var e=function(){if(a instanceof URL)n=a.href;else{var e=function(){if(a instanceof Request){var e=a.clone();n=e.url,r=e.method,o=nt(Object.fromEntries(e.headers.entries()));var t=function(){if(window.TextDecoder&&e&&e.body){var t=e.body.getReader(),n=new TextDecoder("utf-8"),r="";return Promise.resolve(t.read().then(function e(o){var i=o.done,s=o.value,a=s?n.decode(s,{stream:!0}):"";return r+=a,i?r:t.read().then(e)})).then(function(e){s=e})}var o=function(t){s=e?t||"":t};return e?Promise.resolve(e.text()).then(o):o("")}();if(t&&t.then)return t.then(function(){})}}();if(e&&e.then)return e.then(function(){})}}();if(e&&e.then)return e.then(function(){})}}();if(e&&e.then)return e.then(function(){})}}();return c&&c.then?c.then(t):t()}()}catch(e){return a(e)}return c&&c.then?c.then(void 0,a):c}(0,function(e){J("Error processing fetch arguments: "+e.message)});return Promise.resolve(a&&a.then?a.then(t):t())}catch(e){return Promise.reject(e)}};function Ye(e){var t,n;return H({},e,{timestamp:e.eventType===u.XHR&&null!=e&&null!=(t=e.data)&&t.requestStartTime?null==e||null==(n=e.data)?void 0:n.requestStartTime:Be()})}function $e(){try{return window.sdkConfig?window.sdkConfig:Ve}catch(e){return J("Failed to parse end user Info data"),Ve}}function Qe(e){try{var t=$e();return t&&t.hasOwnProperty&&t.hasOwnProperty(e)?t[e]:null}catch(e){return J(e.message?JSON.stringify(e):e),null}}var et=function(e,t,n){return e&&e.constructor===String&&n.indexOf(e)===t},tt=function(e){return e&&e.constructor===String&&e.trim()};function nt(e){var t=rt();if(!e)return{};var n={};for(var r in e)t.includes(r)||(n[r]=e[r]);return n}function rt(){var e=Qe("headersToSanitize");return e&&e.length?e.split(","):[]}function ot(e){if(!Array.isArray(e))return[];for(var t,n=[],r=Z(e);!(t=r()).done;){var o=t.value;try{o&&"object"==typeof o&&JSON.stringify(o)?o.constructor.name.toLowerCase().includes("error")?n.push({message:o.message,name:o.name,stack:o.stack}):n.push(o):n.push(String(o))}catch(e){n.push("[console log value cannot be serialized]")}}return n}var it=[];try{it=Qe("scrubbingKey")||[]}catch(e){J("Error in obtaining scrubbing keys"),it=Ve.scrubbingKey}function st(e){try{var t=new URL(e);if(e){var n=new URLSearchParams(new URL(e).search);n.forEach(function(e,t){it.includes(t.toLowerCase())&&n.set(t,"xxx")}),t.search=n.toString()}return t.toString()}catch(t){return J("updateQueryStringFromRequestUrl: ERROR WHILE HIDING QUERY PARAM VALUE: "+t),e}}function at(e,t,n){n++;try{e&&"object"==typeof e&&n<=2&&Object.keys(e).forEach(function(r){it.includes(r.toLowerCase())&&(e[r]="xxx"),t.push(r);var o=e[r];"object"==typeof o&&at(o,t,n)})}catch(e){J("error while hiding the sensitive information: "+e)}return JSON.stringify(e)}function ct(e,t,n,r){var o=r?e.request:e.response,i=Qe(r?"xhrReqPayloadCapture":"xhrRespPayloadCapture"),s=function(t){try{r?(e.request=t,""!=e.request&&(e.requestByteSize=n)):(e.response=t,""!=e.response&&(e.responseByteSize=n))}catch(e){J("error while converting xhr data to string"+e)}};if(i){var a=Qe("responseCapSize")||1e6,c=Qe("requestCapSize")||1e6,u=r?c:a,d=Qe("sizeExceededMessage"),l=Qe("sanitizePayloadResponse");"string"==typeof o&&o.length>0?(n=n||o.length)<=u?l&&function(){try{s(at(JSON.parse(o),[],t))}catch(t){var e=it.some(function(e){return o.indexOf(e)>=0});s(o=r?e?"No request payload captured for this request as you may have some sensitive information in the payload.":o:e?"No response captured for this request as you may have some sensitive information in the payload.":o)}}():n>0&&s(JSON.stringify(d)):"object"==typeof o?(n=n||JSON.stringify(o,null,4).length)<=u?l&&s(at(o,[],t)):n>0&&s(d):o&&o.length>0&&((n=n||o.length)<=u?l&&s(at(o,[],t)):n>0&&s(JSON.stringify(d)))}else r?e.request="":e.response="";return e}function ut(e){if(!e)return!1;var t=e.toLowerCase(),n=Qe("ignoreError")||[];try{if(n.some(function(e){return t.includes(e.toLowerCase())}))return G("Ignoring error for data: "+e),!0}catch(e){J("Error in ignore errors. Error - "+e.message)}return!1}function dt(){try{return window.self!==window.top}catch(e){return!0}}function lt(e,t){if(e&&null!=e)try{var n="";n="string"!=typeof e?JSON.stringify(e):e;for(var r=u.RangeError;r<=u.EvalError;r++)if(-1!=n.search(u[r]))return r}catch(e){J(e)}return t}function ft(e){switch(e){case"link":case"css":return u.Link;case"img":case"image":return u.Image;case"script":return u.Js;case"fetch":case"beacon":case"xmlhttprequest":return u.XHR;case"other":return u.OtherNetworkCall;default:return 0}}var pt=["img","script","css","link","image","script"];function vt(e,t,n){try{var r=Qe("isIgnoreUrlError"),o=Qe("ignoreUrl"),i=Qe("ignoreUrlErrorCodes"),s=Qe("ignoreUrlCodes"),a=[],c={};n?(a=r,c=i||{}):(a=o,c=s||{});var u=function(e,n){return!!e.includes(n.toLowerCase())&&function(e){return!c.hasOwnProperty(e)||c[e].includes(t)}(n)},d=e.toLowerCase(),l=mt(d),f=d.indexOf("?"),p=d,v=l;return f>0&&(p=p.substring(0,f),v=mt(p)),a.some(function(e){return e.includes("?")?e.includes("{id}")?u(l,e):u(d,e):e.includes("{id}")?u(v,e):u(p,e)})}catch(t){J("Error in url decoding for url : "+e+" Error is - "+t)}return!1}function gt(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),{initiatorType:e.initiatorType,nextHopProtocol:e.nextHopProtocol,workerStart:e.workerStart,redirectStart:e.redirectStart,redirectEnd:e.redirectEnd,fetchStart:e.fetchStart,domainLookupStart:e.domainLookupStart,domainLookupEnd:e.domainLookupEnd,connectStart:e.connectStart,connectEnd:e.connectEnd,secureConnectionStart:e.secureConnectionStart,requestStart:e.requestStart,responseStart:e.responseStart,responseEnd:e.responseEnd,transferSize:e.transferSize,encodedBodySize:e.encodedBodySize||Number(t),decodedBodySize:e.decodedBodySize||Number(n),responseStatus:e.responseStatus,renderBlockingStatus:e.renderBlockingStatus,duration:e.duration,entryType:e.entryType,name:e.name,startTime:e.startTime}}function mt(e){try{var t=e.match(/\/\d+\//g);if(t)for(var n,r=Z(t);!(n=r()).done;)e=e.replace(n.value,"/{id}/")}catch(e){J("Error while masking numeric value.")}return e}function yt(e,t){if(!(e.indexOf("http://")>-1||e.indexOf("https://")>-1)){var n=e;e.startsWith("/")||(n="/"+e);var r=new URL(t);return r.pathname+r.search===n}return!1}function wt(){var e=window.navigator.userAgent;return/Mobi|Android/i.test(e)?"Mobile":/Tablet|iPad/i.test(e)?"Tablet":"Web"}function ht(e){try{return window.sessionStorage.getItem(e)||""}catch(e){return J("inside zSessionStorageGetItem catch block "+e.message),""}}function Et(e,t){try{window.sessionStorage.setItem(e,t)}catch(e){console.error("inside zSessionStorageSetItem catch block "+e.message)}}function St(e){if("online"!=(navigator.onLine?"online":"offline")){if(!window.iszInternetDisconnected)return window.iszInternetDisconnected=!0,G("handleConnectionChange :: send internet disconnected"),e(Ye({eventType:u.Offline,data:{status:"Offline",type:""},isError:!1}))}else var t=setInterval(function(){fetch("//google.com",{mode:"no-cors"}).then(function(){return window.iszInternetDisconnected&&(window.iszInternetDisconnected=!1,G("handleConnectionChange :: send internet connected"),e(Ye({eventType:u.Online,data:{status:"Online",type:""},isError:!1}))),clearInterval(t)}).catch(function(){window.iszInternetDisconnected||(window.iszInternetDisconnected=!0,G("handleConnectionChange :: send internet disconnected"),e(Ye({eventType:u.Offline,data:{status:"Offline",type:""},isError:!1})))})},5e3)}var It,zt=function(e){try{var t,n=function(n,r){try{var o="string"==typeof(i=e.data.response)?(t=1,e):"xmlHttpClient"===e.data.sourceLibrary?function(t){if("Blob"===(null==i||null==(t=i.constructor)?void 0:t.name))return Promise.resolve(new Response(i).text()).then(function(t){e.data.response=t});if(i instanceof ArrayBuffer){var n=new Uint8Array(i),r=btoa(String.fromCharCode.apply(String,n));e.data.response=r}else if(i instanceof Document){var o=(new XMLSerializer).serializeToString(i);e.data.response=o}else{if(!(i instanceof Object))throw new Error("Unsupported response type for XMLHttpRequest: "+typeof i);e.data.response=JSON.stringify(i)}}():function(){if("fetch"===e.data.sourceLibrary)return i instanceof Promise?Promise.resolve(i).then(function(t){e.data.response=t}):function(){if(i instanceof Response)return Promise.resolve(i.text()).then(function(t){e.data.response=t});throw new Error("Unsupported response type for fetch: "+typeof i)}();throw new Error("Unsupported source library: "+e.data.sourceLibrary)}()}catch(e){return r(e)}var i;return o&&o.then?o.then(void 0,r):o}(0,function(t){J("Error in resolving response. Error is - "+t.message),e.data.response=""});return Promise.resolve(n&&n.then?n.then(function(n){return t?n:e}):t?n:e)}catch(e){return Promise.reject(e)}},Ct=/*#__PURE__*/function(){function e(){this.dataSync=void 0,this.sdkTimer=void 0,this.eventListenersCallback=void 0,this.dataSync=x.IDLE,this.sdkTimer=A.START,this.eventListenersCallback=new Array}var t=e.prototype;return t.isDataProcessingDone=function(){var e=this;return new Promise(function(t,n){var r=setInterval(function(){e.dataSync!==x.PENDING&&(t(!0),clearInterval(r))},1)})},t.removeListeners=function(){this.eventListenersCallback.forEach(function(e){e()})},e.getInstance=function(){return this.instance||(this.instance=new e),this.instance},e}();function bt(e,t,n){if(!e.s){if(n instanceof Tt){if(!n.s)return void(n.o=bt.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(bt.bind(null,e,t),bt.bind(null,e,2));e.s=t,e.v=n;const r=e.o;r&&r(e)}}Ct.instance=void 0;var Tt=/*#__PURE__*/function(){function e(){}return e.prototype.then=function(t,n){var r=new e,o=this.s;if(o){var i=1&o?t:n;if(i){try{bt(r,1,i(this.v))}catch(e){bt(r,2,e)}return r}return this}return this.o=function(e){try{var o=e.v;1&e.s?bt(r,1,t?t(o):o):n?bt(r,1,n(o)):bt(r,2,o)}catch(e){bt(r,2,e)}},r},e}();function kt(e){return e instanceof Tt&&1&e.s}var Rt=function(){try{var e=Ct.getInstance(),t=$e(),n=window.zStop,r=Ge.getInstance();n&&n();var o=function(n,o){try{var i=function(){function n(){window.zEventsData=[]}var o=e.dataSync!==x.PENDING&&!xe(t)&&!window.iszInternetDisconnected&&window.zEventsData&&window.zEventsData.length>0&&window.zrrwebRecorderStatus!==v.RECORDINGPENDING,i=function(){if(o){var e,t=0,n=function(e,t,n){for(var r;;){var o=e();if(kt(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!kt(i)){r=1;break}i=i.s}if(t){var s=t();if(s&&s.then&&!kt(s)){r=2;break}}}var a=new Tt,c=bt.bind(null,a,2);return(0===r?o.then(d):1===r?i.then(u):s.then(l)).then(void 0,c),a;function u(r){i=r;do{if(t&&(s=t())&&s.then&&!kt(s))return void s.then(l).then(void 0,c);if(!(o=e())||kt(o)&&!o.v)return void bt(a,1,i);if(o.then)return void o.then(d).then(void 0,c);kt(i=n())&&(i=i.v)}while(!i||!i.then);i.then(u).then(void 0,c)}function d(e){e?(i=n())&&i.then?i.then(u).then(void 0,c):u(i):bt(a,1,i)}function l(){(o=e())?o.then?o.then(d).then(void 0,c):d(o):bt(a,1,i)}}(function(){return!e&&t<Lt},void 0,function(){return Promise.resolve(xt(r.apiKey)).then(function(n){n&&0!==window.zEventsData.length?t++:e=1})});if(n&&n.then)return n.then(function(){})}}();return i&&i.then?i.then(n):n()}()}catch(e){return o(e)}return i&&i.then?i.then(void 0,o):i}(0,function(e){J("Failed to send the pending rrweb events. Error - "+e.message)});return Promise.resolve(o&&o.then?o.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},Nt=function(e,t,n){void 0===t&&(t=0);try{var r={v:_.sdkVersion,e:"Production",o:t,ns:n};if(t==f.POSTENDUSERINFOANDGETUSERCONFIG||t==f.GETUSERCONFIG){var o=ee();window.sdkConfig=o||Ve}var i=re(),s=Ge.getInstance();if(i&&i.isBlocked)return q("Not going to call post end user info as session is already blocked"),Promise.resolve(window.sdkConfig);window.iszHandshakeDone=!1,window.zpendingOp=t,G("config.sdkversion"+_.sdkVersion);var a=he()||{zAnonymsUserInfo:{}},c={},u=p.ANONYMS;if(c.s_id=s.sessionId,c.enduser_details=he()||we()||{},a){var d,l=a.zExternalUserInfo||{};for(var v in l)c[Ze(v)]=l[v]?l[v]:"";c.enduser_zipy_id=null==(d=a.zAnonymsUserInfo)?void 0:d.zId,l.externalId&&(q("Get User info for user Type Identified "+l.externalId),u=p.IDENTIFIED)}return window.ztryForHandshake=!1,Promise.resolve(ce(_.streamMgrUrl+"/"+e,_.streamMgrRetryCount,r,c)).then(function(n){if(n)if((null==n?void 0:n.api_key)==e){var r=re(),o=De()||{},i=!(null==n||!n.is_blocked)&&(null==n?void 0:n.is_blocked);if(s.sessionId=o.sessionId,s.apiKey=o.sdkKey,s.isNewSession=o.isNewSession,s.isSessionExpired=!1,s.lastActivityTime=Date.now(),s.enduserLastActivityTime=Date.now(),s.sessionBlockInfo=r,r&&(r.isBlocked||function(e,t){var n,r=(null==e?void 0:e.blocked_till)>0?null==e?void 0:e.blocked_till:0,o=r>0?Be()+r:0,i=!(null==e||!e.is_blocked)&&(null==e?void 0:e.is_blocked);Ge.getInstance().sessionBlockInfo=n={isBlocked:i,apiKey:t,blockedEndTime:o},te(n)}(n,e)),i)return window.sdkConfig;if(t==f.POSTENDUSERINFOANDGETUSERCONFIG||t==f.GETUSERCONFIG){var c=qt(n);window.iszHandshakeDone=!0,q("sdkConfigResp"+JSON.stringify(c)),c&&(window.sdkConfig=c)}if(t==f.POSTENDUSERINFOANDGETUSERCONFIG||t==f.POSTENDUSERINFO){var d=n.enduser_info||{};q("Response object received for End User from stream manager: "+JSON.stringify(d)),d&&(q("Going to add enduser info after data parsing"),a.userType=u,a.euId=d.id?d.id:0,a.euZName=d.zipy_eu_name?d.zipy_eu_name:"",a.isBlocked=!!d.is_blocked&&d.is_blocked,u==p.ANONYMS&&(a.zAnonymsUserInfo.euId=a.euId,a.zAnonymsUserInfo.euZName=a.euZName,a.zExternalUserInfo={}),Ee(a),Ie())}}else J("Not able to get response from stream manager for sdk Key: "+e);else J("Not able to get response from stream manager ");return window.sdkConfig})}catch(e){return Promise.reject(e)}},Ot=function(e){try{var t,n=$e(),r=window.zCustomEventData||[],o=oe.getInstance(),i="";try{i=JSON.stringify(r)}catch(e){J("Failed to stringify zEvents")}var s=r.length,a=function(){if(2*i.length>=n.bufferSizeFrequency||window.customEventLastSynctime+n.timeFrequency<=Date.now()&&s>0){var a=r.slice(0,s),c=De()||{},d={key:e,s_id:c.sessionId,events:a,eventType:u.CustomEvent},l=(o.proxyURL?o.proxyURL:n.customEventUrl)+"/customevent";return ge()?(window.isDataSyncInProgress=!0,Promise.resolve(ae(l,d,n.failureRetryCount)).then(function(e){if(e)return window.customEventLastSynctime=Date.now(),function(e){window.zCustomEventData&&Array.isArray(window.zCustomEventData)?window.zCustomEventData.splice(0,e):window.zCustomEventData=[]}(s),window.isDataSyncInProgress=!1,t=!0;window.isDataSyncInProgress=!1})):(t=1,!1)}}();return Promise.resolve(a&&a.then?a.then(function(e){return!t||e}):!t||a)}catch(e){return Promise.reject(e)}},Pt=function(e){try{var t,n=$e(),r=window.zPagePerfData||[],o="",i=oe.getInstance();try{o=JSON.stringify(r)}catch(e){J("Failed to stringify zEvents")}var s=r.length,a=function(){if(2*o.length>=n.perfBufferSizeFrequency||window.pagePerfLastSynctime+n.perfTimeFrequency<=Date.now()&&s>0){var a,c,d=r.slice(0,s),l=De()||{},f=we()||{},p=X("zId"),v=null!=(a=f.zExternalUserInfo)&&a.externalId?null==(c=f.zExternalUserInfo)?void 0:c.externalId:"",g=/\((.*)\)/.exec((new Date).toString())[1],m=Ae(),y={key:e,sdk_ver:_.sdkVersion,src:"Frontend",s_id:l.sessionId,euz_id:p,eue_id:v,events:d,eu_info_id:f.euId,rel_ver:window.zRelVer,handshake_status:window.iszHandshakeDone,ip:n.ip,deviceName:wt()||"",userAgent:window.navigator.userAgent,timeZone:g,eventType:u.WebVitals,pack:m},w=(i.proxyURL?i.proxyURL:n.pagePerfUrl)+"/pageperf";return ge()?(window.isDataSyncInProgress=!0,Promise.resolve(ue(w,y,n.failureRetryCount)).then(function(e){if(e)return window.pagePerfLastSynctime=Date.now(),function(e){window.zPagePerfData&&Array.isArray(window.zPagePerfData)?window.zPagePerfData.splice(0,e):window.zPagePerfData=[]}(s),window.isDataSyncInProgress=!1,t=!0;window.isDataSyncInProgress=!1})):(t=1,!1)}}();return Promise.resolve(a&&a.then?a.then(function(e){return!t||e}):!t||a)}catch(e){return Promise.reject(e)}},Ut=function(e){try{var t,n=$e(),o=window.zClickEventsData||[],i=oe.getInstance(),s="";try{s=JSON.stringify(o)}catch(e){J("Failed to stringify zEvents")}var a=o.length,c=function(){if(2*s.length>=n.bufferSizeFrequency||window.clickLastSyncTime+n.timeFrequency<=Date.now()&&a>0){var c,u,d=o.slice(0,a),l=De()||{},f=we()||{},p=X("zId"),v=null!=(c=f.zExternalUserInfo)&&c.externalId?null==(u=f.zExternalUserInfo)?void 0:u.externalId:"",g=/\((.*)\)/.exec((new Date).toString())[1],m=Ae(),y={key:e,sdk_ver:_.sdkVersion,src:"Frontend",s_id:l.sessionId,euz_id:p,eue_id:v,events:d,eu_info_id:f.euId,rel_ver:i.releaseVer,handshake_status:window.iszHandshakeDone,ip:n.ip,deviceName:wt()||"",userAgent:window.navigator.userAgent,timeZone:g,eventType:r.Click,pack:m},w=(i.proxyURL?i.proxyURL:n.heatMapUrl)+"/heatmap";return ge()?(window.isDataSyncInProgress=!0,Promise.resolve(de(w,y,n.failureRetryCount)).then(function(e){if(e)return window.clickLastSyncTime=Date.now(),function(e){window.zClickEventsData&&Array.isArray(window.zClickEventsData)?window.zClickEventsData.splice(0,e):window.zClickEventsData=[]}(a),window.isDataSyncInProgress=!1,t=!0;window.isDataSyncInProgress=!1})):(t=1,!1)}}();return Promise.resolve(c&&c.then?c.then(function(e){return!t||e}):!t||c)}catch(e){return Promise.reject(e)}},Dt=function(e){try{var t,n=$e(),r=oe.getInstance();G("Data Length for direct streaming ");var o=window.zEventsPerfData||[],i=o.length,s=function(){if(2*o.length>=n.perfBufferSizeFrequency||window.perfLastSyncTime+n.perfTimeFrequency<=Date.now()&&i>0){var s,a,c=o.slice(0,i),u=De()||{},d=we()||{},l=X("zId"),f=null!=(s=d.zExternalUserInfo)&&s.externalId?null==(a=d.zExternalUserInfo)?void 0:a.externalId:"",p=/\((.*)\)/.exec((new Date).toString())[1],v={key:e,sdk_ver:_.sdkVersion,isNPM:_.isNPM,src:"Frontend",s_id:u.sessionId,euz_id:l,eue_id:f,events:c,eu_info_id:d.euId,rel_ver:r.releaseVer,handshake_status:window.iszHandshakeDone,ip:n.ip,deviceName:"",screenWidth:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,screenHeight:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,userAgent:window.navigator.userAgent,timeZone:p},g=(r.proxyURL?r.proxyURL:n.perfUrl)+"/perf";return ge()?(window.isDataSyncInProgress=!0,Promise.resolve(le(g,v,n.failureRetryCount)).then(function(e){if(e)return window.perfLastSyncTime=Date.now(),n=i,window.zEventsPerfData&&Array.isArray(window.zEventsPerfData)?window.zEventsPerfData.splice(0,n):window.zEventsPerfData=[],window.isDataSyncInProgress=!1,t=!0;var n;window.isDataSyncInProgress=!1})):(t=1,!1)}}();return Promise.resolve(s&&s.then?s.then(function(e){return!t||e}):!t||s)}catch(e){return Promise.reject(e)}},xt=function(e){try{var t=$e(),n=window.zEventsData||[],r=oe.getInstance(),o=Ge.getInstance(),i=Ct.getInstance();G("Data Length for direct streaming ");var s="";try{s=JSON.stringify(n)}catch(e){J("Failed to stringify zEvents")}var a=null!=t&&t.eventCountCapInSingleChunk?t.eventCountCapInSingleChunk:0,c=a>0&&n.length>a?a:n.length;if(window.lastSyncDataLength=c,q("Going to send data with chunk "+c+" total events count "+n.length+" chunk size "+a),2*s.length>=t.bufferSizeFrequency||window.lastSyncTime+t.timeFrequency<=Date.now()&&c>0){var u,d,l=n.slice(0,c),f=De()||{},p=we()||{},v=X("zId"),g=null!=(u=p.zExternalUserInfo)&&u.externalId?null==(d=p.zExternalUserInfo)?void 0:d.externalId:"",m=/\((.*)\)/.exec((new Date).toString())[1],y=Ae(),w={key:e,sdk_ver:_.sdkVersion,isNPM:_.isNPM,src:"Frontend",s_id:f.sessionId,euz_id:v,eue_id:g,events:l,eu_info_id:p.euId,rel_ver:r.releaseVer,handshake_status:window.iszHandshakeDone,ip:t.ip,deviceName:"",screenWidth:window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,screenHeight:window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,userAgent:window.navigator.userAgent,timeZone:m,pack:y},h="";try{h=JSON.stringify(w)}catch(e){J("Failed to stringify zipyDataJson")}var E={eventData:h};if(Gt())return function(){for(;window.zEventsData.length;)window.zEventsData.pop();window.zEventsData=[]}(),Promise.resolve(!0);var S={session_id:f.dSession,event_id:"AruZ~Em0WNlAnbyzVmwM~GR0cMb6Xl9r",is_new_party:f.isNewSession,is_new_session:f.isNewSession,client_timestamp_iso:(new Date).toISOString(),event_type:"MyEventRecord",parameters:E},I=(r.proxyURL?r.proxyURL:t.streamUrl)+"?p="+f.sessionId;return ge()?(window.isDataSyncInProgress=!0,i.dataSync=x.PENDING,Promise.resolve(fe({divolteUrl:I,divolteJson:S,failureRetryCount:t.failureRetryCount})).then(function(e){if(e){if(window.lastSyncTime=Date.now(),function(e){window.zEventsData&&Array.isArray(window.zEventsData)?window.zEventsData.splice(0,e):window.zEventsData=[]}(c),window.isDataSyncInProgress=!1,i.dataSync=x.SUCCESS,Y("last-activity-time",o.lastActivityTime.toString()),Y("zenduser-last-activity-time",o.enduserLastActivityTime.toString()),f.isNewSession){var t=De();if(t){t.isNewSession=!1,o.isNewSession=!1;try{Y("session-data",JSON.stringify(t))}catch(e){J("Failed to set session-data in localstorage")}}}return!0}return window.isDataSyncInProgress=!1,i.dataSync=x.FAILED,!1})):(Y("last-activity-time",o.lastActivityTime.toString()),Y("zenduser-last-activity-time",o.enduserLastActivityTime.toString()),i.dataSync=x.FAILED,Promise.resolve(!1))}return Promise.resolve(!1)}catch(e){return Promise.reject(e)}},Lt=5;function At(o,c){void 0===o&&(o=Ve.inputMasking);var d=oe.getInstance(),l=Ge.getInstance();G("Going to init rrweb Recorder"),window.zrrwebRecorderStatus=v.RECORDINGPENDING;var f,p=function(){};try{var g=$e();p=e({emit:function(e,o){if(!dt()||d.recordOnlyIframe){var c=-1;e.type!=t.IncrementalSnapshot?c=u.ReplayerEvent:(c=e.data.source?e.data.source:u.ReplayerEvent,(g.startCaptureWithoutUserActivity||c>=u.MouseInteraction&&c<=u.MediaInteraction)&&(window.zrrwebRecorderStatus=v.RECORDINGSUCCESSFUL,l.enduserLastActivityTime=Date.now()));try{var f=!1;window.reinitializationInProgress||(f=Ae());var p={data:f?n(e):JSON.stringify(e),time:e.timestamp,type:c,rrwebEvent:null==e?void 0:e.type,isError:!1,navigatedUrl:window.location.origin+window.location.pathname};if(o&&e.type==t.Meta?(l.isCheckoutFlowTriggered=!0,B("Checkout flow is triggered. Meta event expected type - "+t.Meta+" actual event "+e.type),p.isCheckout=o):o&&B("Full snapshot event. Expected event type - "+t.FullSnapshot+" Event type "+e.type),_t(p),t.IncrementalSnapshot&&c===u.MouseInteraction&&g.captureClickEvents){var m=e.data;if(m.type&&m.type===r.Click){var y=function(e){q("Heatmap: Pack event");try{var t=JSON.stringify(e),n=i(t),r=s(n);return a(r,!0)}catch(e){return q("Heatmap: Unable to pack the data"),""}}(m);!function(e){var t=$e(),n=Ct.getInstance();window.zrecordingPaused||Gt()&&!xe(t)||n.sdkTimer===A.STOP||ge()&&t.captureClickEvents&&window.zClickEventsData.push(e)}({data:y,time:e.timestamp,type:m.type,isError:!1})}}}catch(e){J("Failed to store rrweb recorder events")}}},recordCanvas:Qe("canvasCapture"),blockClass:(f=Qe("blockClasses"),f&&"string"==typeof f?new RegExp(f):f instanceof RegExp?f:/zipy-block/),blockSelector:Qe("blockSelector"),ignoreClass:"zipy-ignore",maskAllInputs:o,sampling:{mousemove:150,scroll:150,mouseInteraction:{MouseUp:!0,MouseDown:!0,Click:!0,ContextMenu:!1,DblClick:!0,Focus:!1,Blur:!1,TouchStart:!0,TouchEnd:!0}},userTriggeredOnInput:!0,recordCrossOriginIframes:!d.recordOnlyIframe,captureClickEvents:g.captureClickEvents||!1,maskAllText:g.textMasking})}catch(e){J(e)}return p}function Ft(e){var t=Ge.getInstance();return G("Going to init zipy Recorder"),function(e){void 0===e&&(e={});var t=e.emit;if(!t)return J("emit function is required to record data from zipy-event-recorder"),function(){};It=function(e){t(e)};try{var n=[],r=$e();return n.push(r.capturePagePerf?function(e){var t="",n=window.history.pushState,r=window.history.replaceState,o=Ge.getInstance();if(window.history.pushState=function(){n.apply(window.history,arguments),window.dispatchEvent(new Event("pushstate")),window.dispatchEvent(new Event("locationchange"))},window.history.replaceState=function(){r.apply(window.history,arguments),window.dispatchEvent(new Event("replacestate")),window.dispatchEvent(new Event("locationchange"))},window.PerformanceObserver&&"function"==typeof window.PerformanceObserver){var i=function(n){var r=n.loadTime,o=n.navigationType,i=n.isRouteChan