@sprig-technologies/sprig-browser 2.31.5 → 2.31.6

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.
@@ -1,12 +1,12 @@
1
- var Ut=Object.defineProperty,St=(t,e,n)=>e in t?Ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,q=(t,e,n)=>(St(t,typeof e!="symbol"?e+"":e,n),n);import{g as C,s as Me,e as p,S as u,l as x,v as je,m as U,b as P,h as It,E as V,D as M,c as kt,r as j,i as Et,j as _t,k as xt,n as Ne,o as ze,a as Dt,p as ye,d as At,q as We}from"./metricsReporter-FejRrxF4.js";const Rt='.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',Be="360px",Ot="ul-app",Pt="#e6e6e6",Ct="#bd282a",Tt=500,Ft=1030,qe=()=>{try{return window.parent.Intercom}catch{return null}},Mt=()=>{const t=qe();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)},jt=()=>{const t=qe();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},Nt=Object.freeze(Object.defineProperty({__proto__:null,disable:jt,enable:Mt},Symbol.toStringTag,{value:"Module"})),Ve=[Nt];class He{static disable(){Ve.forEach(e=>e.disable())}static enable(){Ve.forEach(e=>e.enable())}}const $e="ul-view-sdk-script",zt=["ios","android"],T="visitors",F="environments";async function D(t,e){var n,o,r;const{shouldDropOnRateLimit:i,...s}=e;s.headers=Object.assign(C(window.UserLeap),s.headers);const a=await Me(t,{...s,shouldDropOnRateLimit:i});if(a.ok){const l=(n=a.headers)==null?void 0:n.get("Authorization"),c=l?l.split(" "):void 0,d=c&&c.length===2?c[1]:void 0,w=(o=a.headers)==null?void 0:o.get("x-ul-visitor-id");d&&w&&(w!==window.UserLeap.visitorId||window.UserLeap.token!==d)&&(E("token",d),E("vid",w),p.emit(u.VisitorIDUpdated,{visitorId:w}),window.UserLeap.token=d,window.UserLeap.visitorId=w)}return(r=a.json)!=null&&r.logMessage&&console.warn(`[Sprig] ${a.json.logMessage}`),a}function E(t,e){const n=x.getItem("userleap.ids");let o={};if(n)try{o=JSON.parse(n)}catch(i){i instanceof Error&&(i.stack=n,window.UserLeap.reportError("Failed to parse local storage credentials",i)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",i)}let r=o[window.UserLeap.envId];r?r[t]=e:r={[t]:e},o[window.UserLeap.envId]=r;try{x.setItem("userleap.ids",JSON.stringify(o))}catch(i){i instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${i.message}`)}}function ve(){return window.previewMode?"0":window.UserLeap.visitorId??""}function _(t,e,n){const o=[window.UserLeap._API_URL,"sdk",t];return e&&e.forEach(r=>{o.push(r),r===F?o.push(window.UserLeap.envId):r===T&&o.push(ve())}),n&&o.push(n),o.join("/")}const H=async(t,e)=>{var n,o,r;const{context:i,delay:s,forceBrandedLogo:a,endCard:l,isFeedback:c=!1,heatmap:d,locale:w,previewMode:g,productConfig:h,questions:y,responseGroupUid:f,surveyId:S,uuid:k,vid:b,sessionReplay:I,studyType:R}=t,L=C(window.UserLeap),Re=re(L),ue=fe(L);if(I)if(Re)p.emit(u.ReplayCapture,{responseGroupUid:f,hasQuestions:!!(y!=null&&y.length),surveyId:S,uploadId:I.uploadId,replayType:I.replayDurationType??"before",seconds:I.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:je(),mediaType:"screen",questionId:1,responseGroupUid:f,surveyId:S,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!U.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};U.replay.scheduleOrCaptureReplay({responseGroupId:f,surveyId:S,visitorId:b,replayParams:I,completeUploadHeaders:L,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:y.length===0})}if(d){if(!U.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:v,replayParams:me,responseGroupUid:bt,surveyId:Lt}=d;await U.replay.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:300,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),U.replay.tryReplayAction(()=>{var Fe;return(Fe=U.replay)==null?void 0:Fe.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:L,eventId:v,isHeatmap:!0,replayParams:me,responseGroupId:bt,surveyId:Lt,triggerTimestamp:Date.now(),visitorId:b})},"Error in scheduling/capturing replay")}if(b==null||!(y!=null&&y.length))return P.info("CannotDisplaySurvey",{vid:b}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){P.info("AlreadyDisplayingSurvey");const v="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(v),{success:!1,message:v,surveyState:"no survey"}}if(b!==window.UserLeap.visitorId&&k!==window.UserLeap.visitorId&&!window.previewMode){const v="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(v)),{success:!1,message:v,surveyState:"no survey"}}P.info("ShowingSurvey",{surveyId:S}),(n=U.replay)==null||n.RecordSurveyShown({id:S,userAgent:window.navigator.userAgent}),He.disable(),p.emit(u.SurveyWillPresent,{name:u.SurveyWillPresent,"survey.id":S});let X,Z=document.createElement("div"),ee,O,te;const Oe=v=>{const{"view.version":me}=v;me!==L["x-ul-sdk-version"]&&Ke(),p.removeListener("verify.view.version",Oe)};p.on("verify.view.version",Oe),window.UserLeap.useMobileStyling=ue,It(L)?(X="ul-direct-embeded-frame",ee=document.head,O=window,te=!1,Re&&(Ge(S,c),Z.id=X,window.UserLeap.container.appendChild(Z),Je(),p.emit(u.SurveyLifeCycle,{state:"presented"}),p.emit(u.SurveyPresented,{name:u.SurveyPresented,"survey.id":S}))):{frameId:X,contentWinDocHead:ee,contentWindow:O,hasOverlay:te,iframe:Z}=Ht({productConfig:h,useMobileStyling:ue,surveyId:S,isFeedback:c}),window.UserLeap.frameId=X;const vt=v=>{p.once(u.CloseSurveyOnOverlayClick,v)},W={apiURL:window.UserLeap._API_URL,cards:y,configureExitOnOverlayClick:vt,context:i,endCard:l,envId:window.UserLeap.envId,eventEmitFn:p.emit.bind(p),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:a,frame:Z,headers:L,locale:w,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:x.getItem("sprig.previewKey"),previewMode:g,productConfig:{framePosition:h?.framePosition,desktopDisplay:h?.desktopDisplay,placement:h?.placement},responseGroupUid:f,startingQuestionIdx:(o=window.UserLeap.config)==null?void 0:o.startingQuestionIdx,studyType:R,styleNonce:window.UserLeap.styleNonce,surveyId:S,tabTitle:document.title,trackPageViewUrl:e,ulEvents:V,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:ue,userId:k,viewDocument:O?.document,viewWindow:O,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(r=window.UserLeap._config)!=null&&r.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const ft=(c?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??h.customStyles;W.customStyles=ft,O&&(O.__cfg=W);function ht(){const v=document.createElement("script");return window.UserLeap.nonce&&v.setAttribute("nonce",window.UserLeap.nonce),v.id=$e,v}const we=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:W.path,Pe=document.getElementById($e);Pe&&Pe.remove();const ge=ht(),Ce=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(W.installationMethod==="web-npm"||W.installationMethod==="web-npm-bundled"){const{default:v}=await import("./view-BJVMIleW.js");v.configure(W),te&&window.UserLeap.container&&Ce()}else we&&(ge.src=we,te&&ge.addEventListener("load",()=>{window.UserLeap.container&&Ce()}),O?.addEventListener("error",v=>{v.target instanceof HTMLScriptElement&&v.target.src===we&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));ee?.appendChild(ge);const Te={success:!0,surveyState:"ready",surveyId:S,responseGroupUid:f};return window.UserLeap.isMobileSDK&&s&&(Te.delay=s),Te};function fe(t){var e;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const n=((e=window.UserLeap.windowDimensions)==null?void 0:e.width)??document.body.clientWidth;return re(t)||n>10&&n<Tt}function re(t){return zt.includes(t["userleap-platform"])}const he="ul-frame";window.UserLeap&&window.Sprig&&(window.Sprig._gtm?window.Sprig=window.UserLeap:window.UserLeap=window.Sprig),window.UserLeap||(window.UserLeap=window.Sprig),window.Sprig||(window.Sprig=window.UserLeap);const Wt="rgba(255,255,255, 0.95)",Bt="rgba(0,0,0,0.9)",be="0px",Ge=(t,e,n)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container${e?" ul-container-feedback":""}`,t&&(window.UserLeap.container.dataset.studyId=t.toString());const o=Ze();n&&o&&!window.UserLeap.useMobileStyling?o.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ke=(t,e)=>{var n;Gt();const o=window.UserLeap.container;if(o)try{(n=o.parentNode)==null||n.removeChild(o),window.UserLeap.container=null,E("trackStartUrl",null),p.emit(u.SurveyLifeCycle,{state:"dismissed"}),p.emit(u.SurveyClosed,{name:u.SurveyClosed,initiator:t,"survey.id":parseInt(o.dataset.studyId),...e&&{studyType:e}})}catch(r){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} `+o),r instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",r)}},Je=()=>{p.once(u.SurveyWillClose,({initiator:t,studyType:e})=>{p.removeAllListeners(u.CloseSurveyOnOverlayClick),Ke(t,e)})},qt=(t,e)=>{const n={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},o=e?t.overlayStyleMobile:t.overlayStyle;n["background-color"]=o==="light"?Wt:Bt,e||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},Vt=(t,e,n,o)=>{var r,i;const s={position:"fixed",bottom:"0px",right:be,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%"},a=Object.assign({},e,window.UserLeap),{desktopDisplay:l}=e||{},c=l==="center-modal";c&&(a.framePosition="center");let d,w=!1;if(n)(r=window.UserLeap.windowDimensions)!=null&&r.width?s.width=`${window.UserLeap.windowDimensions.width}px`:s.width="100%",(i=window.UserLeap.windowDimensions)!=null&&i.height?s.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?s.maxHeight=window.UserLeap.maxHeight:s.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(a.overlayStyleMobile)&&(w=!0);else{s.width=Be,s.maxHeight=window.UserLeap.maxHeight||"66vh";const g=()=>{w=!0,d={margin:"auto",position:"static"}};if(o)c?g():d={position:"relative",height:"300px"};else switch(a.framePosition){case"bottomLeft":d={left:be};break;case"topLeft":d={left:be,top:0};break;case"topRight":d={top:0};break;case"center":g();break}}return w&&qt(a,n),Object.assign(t.style,s,d),w},Ht=({productConfig:t,useMobileStyling:e,surveyId:n,isFeedback:o})=>{var r,i;const s=he,a=o&&t.desktopDisplay==="slider";Ge(n,o,a),$t();const l=document.createElement("iframe");l.id=s,l.setAttribute("title","Sprig User Feedback Dialog");const c=Vt(l,t,e,o);Je();let d=!1;l.setHeight=y=>{(parseInt(l.style.height)!=y||!d)&&(d=!0,l.style.height=`${y}px`,p.emit(u.SurveyHeight,{name:u.SurveyHeight,contentFrameHeight:y,"survey.id":n}))};let w=!1;l.setWidth=y=>{(parseInt(l.style.width)!=y||!w)&&(w=!0,l.style.width=`${y}px`,p.emit(u.SurveyWidth,{name:u.SurveyWidth,contentFrameWidth:y,"survey.id":n}))},(r=window.UserLeap.container)==null||r.appendChild(l),t&&(e?t.exitOnOverlayClickMobile:t.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{p.emit(u.CloseSurveyOnOverlayClick)}),p.emit(u.SurveyLifeCycle,{state:"presented"}),p.emit(u.SurveyPresented,{name:u.SurveyPresented,"survey.id":n});const g=(i=l.contentWindow)==null?void 0:i.document;if(g&&(g.open("text/html","replace"),g.write("<!doctype html><head></head><body></body></html>"),g.close(),!e)){const y=g.body;y.style.display="flex",y.style.alignItems="center"}const h=g?.head;return{frameId:s,contentWinDocHead:h,contentWindow:l.contentWindow,hasOverlay:c,iframe:l}},Qe={[u.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},$t=()=>{Object.entries(Qe).forEach(([t,e])=>{p.on(t,e)})},Gt=()=>{Object.entries(Qe).forEach(([t,e])=>{p.off(t,e)})},Kt=1,Ye=t=>t instanceof HTMLElement||t instanceof SVGElement,$=({document:t,elementId:e,styleString:n,nonce:o})=>{const r=t.getElementById(e);if(r){r.textContent=n;return}const i=t.createElement("style");o&&(i.nonce=o),i.textContent=n,i.id=e,t.head.appendChild(i)},Xe=t=>{const e=t.querySelector(".ul-card__container");let n=600,o=360;if(e){n=e.scrollHeight;const r=getComputedStyle(e),i=parseFloat(r.marginTop)+parseFloat(r.marginBottom),s=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth),a=parseFloat(r.paddingTop)+parseFloat(r.paddingBottom);n+=i+s+a;const l=e.querySelector(".ul-card--matrix_grid");o=l?l.scrollWidth:e.scrollWidth;const c=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),d=parseFloat(r.marginLeft)+parseFloat(r.marginRight),w=parseFloat(r.borderLeftWidth)+parseFloat(r.borderRightWidth);o+=d+w+c}return[n+Kt,o]},Jt=t=>{const e=t.querySelector(".ul-card__container");e&&(e.scrollTop=0)},Ze=()=>m,B=()=>document.getElementById("sprig-feedback-container"),Le=()=>document.getElementById("sprig-feedback-loading-animation"),Qt=()=>{if(Le())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=`
1
+ var Ut=Object.defineProperty,St=(t,e,n)=>e in t?Ut(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,q=(t,e,n)=>(St(t,typeof e!="symbol"?e+"":e,n),n);import{g as C,s as Me,e as p,S as u,l as x,v as je,m as U,b as P,h as It,E as V,D as M,c as kt,r as j,i as Et,j as _t,k as xt,n as ze,o as We,a as Dt,p as ye,d as At,q as Be}from"./metricsReporter-DKI8BwWD.js";const Rt='.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',Ne="360px",Ot="ul-app",Pt="#e6e6e6",Ct="#bd282a",Tt=500,Ft=1030,qe=()=>{try{return window.parent.Intercom}catch{return null}},Mt=()=>{const t=qe();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)},jt=()=>{const t=qe();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},zt=Object.freeze(Object.defineProperty({__proto__:null,disable:jt,enable:Mt},Symbol.toStringTag,{value:"Module"})),Ve=[zt];class He{static disable(){Ve.forEach(e=>e.disable())}static enable(){Ve.forEach(e=>e.enable())}}const $e="ul-view-sdk-script",Wt=["ios","android"],T="visitors",F="environments";async function D(t,e){var n,o,r;const{shouldDropOnRateLimit:i,...s}=e;s.headers=Object.assign(C(window.UserLeap),s.headers);const a=await Me(t,{...s,shouldDropOnRateLimit:i});if(a.ok){const l=(n=a.headers)==null?void 0:n.get("Authorization"),c=l?l.split(" "):void 0,d=c&&c.length===2?c[1]:void 0,w=(o=a.headers)==null?void 0:o.get("x-ul-visitor-id");d&&w&&(w!==window.UserLeap.visitorId||window.UserLeap.token!==d)&&(E("token",d),E("vid",w),p.emit(u.VisitorIDUpdated,{visitorId:w}),window.UserLeap.token=d,window.UserLeap.visitorId=w)}return(r=a.json)!=null&&r.logMessage&&console.warn(`[Sprig] ${a.json.logMessage}`),a}function E(t,e){const n=x.getItem("userleap.ids");let o={};if(n)try{o=JSON.parse(n)}catch(i){i instanceof Error&&(i.stack=n,window.UserLeap.reportError("Failed to parse local storage credentials",i)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",i)}let r=o[window.UserLeap.envId];r?r[t]=e:r={[t]:e},o[window.UserLeap.envId]=r;try{x.setItem("userleap.ids",JSON.stringify(o))}catch(i){i instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${i.message}`)}}function ve(){return window.previewMode?"0":window.UserLeap.visitorId??""}function _(t,e,n){const o=[window.UserLeap._API_URL,"sdk",t];return e&&e.forEach(r=>{o.push(r),r===F?o.push(window.UserLeap.envId):r===T&&o.push(ve())}),n&&o.push(n),o.join("/")}const H=async(t,e)=>{var n,o,r;const{context:i,delay:s,forceBrandedLogo:a,endCard:l,isFeedback:c=!1,heatmap:d,locale:w,previewMode:g,productConfig:h,questions:y,responseGroupUid:f,surveyId:S,uuid:k,vid:b,sessionReplay:I,studyType:R}=t,L=C(window.UserLeap),Re=re(L),ue=fe(L);if(I)if(Re)p.emit(u.ReplayCapture,{responseGroupUid:f,hasQuestions:!!(y!=null&&y.length),surveyId:S,uploadId:I.uploadId,replayType:I.replayDurationType??"before",seconds:I.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:je(),mediaType:"screen",questionId:1,responseGroupUid:f,surveyId:S,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!U.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};U.replay.scheduleOrCaptureReplay({responseGroupId:f,surveyId:S,visitorId:b,replayParams:I,completeUploadHeaders:L,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:y.length===0})}if(d){if(!U.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:v,replayParams:me,responseGroupUid:bt,surveyId:Lt}=d;await U.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),U.replay.tryReplayAction(()=>{var Fe;return(Fe=U.replay)==null?void 0:Fe.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:L,eventId:v,isHeatmap:!0,replayParams:me,responseGroupId:bt,surveyId:Lt,triggerTimestamp:Date.now(),visitorId:b})},"Error in scheduling/capturing replay")}if(b==null||!(y!=null&&y.length))return P.info("CannotDisplaySurvey",{vid:b}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){P.info("AlreadyDisplayingSurvey");const v="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(v),{success:!1,message:v,surveyState:"no survey"}}if(b!==window.UserLeap.visitorId&&k!==window.UserLeap.visitorId&&!window.previewMode){const v="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(v)),{success:!1,message:v,surveyState:"no survey"}}P.info("ShowingSurvey",{surveyId:S}),(n=U.replay)==null||n.RecordSurveyShown({id:S,userAgent:window.navigator.userAgent}),He.disable(),p.emit(u.SurveyWillPresent,{name:u.SurveyWillPresent,"survey.id":S});let X,Z=document.createElement("div"),ee,O,te;const Oe=v=>{const{"view.version":me}=v;me!==L["x-ul-sdk-version"]&&Ke(),p.removeListener("verify.view.version",Oe)};p.on("verify.view.version",Oe),window.UserLeap.useMobileStyling=ue,It(L)?(X="ul-direct-embeded-frame",ee=document.head,O=window,te=!1,Re&&(Ge(S,c),Z.id=X,window.UserLeap.container.appendChild(Z),Je(),p.emit(u.SurveyLifeCycle,{state:"presented"}),p.emit(u.SurveyPresented,{name:u.SurveyPresented,"survey.id":S}))):{frameId:X,contentWinDocHead:ee,contentWindow:O,hasOverlay:te,iframe:Z}=Ht({productConfig:h,useMobileStyling:ue,surveyId:S,isFeedback:c}),window.UserLeap.frameId=X;const vt=v=>{p.once(u.CloseSurveyOnOverlayClick,v)},B={apiURL:window.UserLeap._API_URL,cards:y,configureExitOnOverlayClick:vt,context:i,endCard:l,envId:window.UserLeap.envId,eventEmitFn:p.emit.bind(p),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:a,frame:Z,headers:L,locale:w,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:x.getItem("sprig.previewKey"),previewMode:g,productConfig:{framePosition:h?.framePosition,desktopDisplay:h?.desktopDisplay,placement:h?.placement},responseGroupUid:f,startingQuestionIdx:(o=window.UserLeap.config)==null?void 0:o.startingQuestionIdx,studyType:R,styleNonce:window.UserLeap.styleNonce,surveyId:S,tabTitle:document.title,trackPageViewUrl:e,ulEvents:V,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:ue,userId:k,viewDocument:O?.document,viewWindow:O,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(r=window.UserLeap._config)!=null&&r.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const ft=(c?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??h.customStyles;B.customStyles=ft,O&&(O.__cfg=B);function ht(){const v=document.createElement("script");return window.UserLeap.nonce&&v.setAttribute("nonce",window.UserLeap.nonce),v.id=$e,v}const we=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:B.path,Pe=document.getElementById($e);Pe&&Pe.remove();const ge=ht(),Ce=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(B.installationMethod==="web-npm"||B.installationMethod==="web-npm-bundled"){const{default:v}=await import("./view-Cabe-ObF.js");v.configure(B),te&&window.UserLeap.container&&Ce()}else we&&(ge.src=we,te&&ge.addEventListener("load",()=>{window.UserLeap.container&&Ce()}),O?.addEventListener("error",v=>{v.target instanceof HTMLScriptElement&&v.target.src===we&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));ee?.appendChild(ge);const Te={success:!0,surveyState:"ready",surveyId:S,responseGroupUid:f};return window.UserLeap.isMobileSDK&&s&&(Te.delay=s),Te};function fe(t){var e;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const n=((e=window.UserLeap.windowDimensions)==null?void 0:e.width)??document.body.clientWidth;return re(t)||n>10&&n<Tt}function re(t){return Wt.includes(t["userleap-platform"])}const he="ul-frame";window.UserLeap&&window.Sprig&&(window.Sprig._gtm?window.Sprig=window.UserLeap:window.UserLeap=window.Sprig),window.UserLeap||(window.UserLeap=window.Sprig),window.Sprig||(window.Sprig=window.UserLeap);const Bt="rgba(255,255,255, 0.95)",Nt="rgba(0,0,0,0.9)",be="0px",Ge=(t,e,n)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container${e?" ul-container-feedback":""}`,t&&(window.UserLeap.container.dataset.studyId=t.toString());const o=Ze();n&&o&&!window.UserLeap.useMobileStyling?o.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ke=(t,e)=>{var n;Gt();const o=window.UserLeap.container;if(o)try{(n=o.parentNode)==null||n.removeChild(o),window.UserLeap.container=null,E("trackStartUrl",null),p.emit(u.SurveyLifeCycle,{state:"dismissed"}),p.emit(u.SurveyClosed,{name:u.SurveyClosed,initiator:t,"survey.id":parseInt(o.dataset.studyId),...e&&{studyType:e}})}catch(r){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} `+o),r instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",r)}},Je=()=>{p.once(u.SurveyWillClose,({initiator:t,studyType:e})=>{p.removeAllListeners(u.CloseSurveyOnOverlayClick),Ke(t,e)})},qt=(t,e)=>{const n={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},o=e?t.overlayStyleMobile:t.overlayStyle;n["background-color"]=o==="light"?Bt:Nt,e||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},Vt=(t,e,n,o)=>{var r,i;const s={position:"fixed",bottom:"0px",right:be,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%"},a=Object.assign({},e,window.UserLeap),{desktopDisplay:l}=e||{},c=l==="center-modal";c&&(a.framePosition="center");let d,w=!1;if(n)(r=window.UserLeap.windowDimensions)!=null&&r.width?s.width=`${window.UserLeap.windowDimensions.width}px`:s.width="100%",(i=window.UserLeap.windowDimensions)!=null&&i.height?s.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?s.maxHeight=window.UserLeap.maxHeight:s.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(a.overlayStyleMobile)&&(w=!0);else{s.width=Ne,s.maxHeight=window.UserLeap.maxHeight||"66vh";const g=()=>{w=!0,d={margin:"auto",position:"static"}};if(o)c?g():d={position:"relative",height:"300px"};else switch(a.framePosition){case"bottomLeft":d={left:be};break;case"topLeft":d={left:be,top:0};break;case"topRight":d={top:0};break;case"center":g();break}}return w&&qt(a,n),Object.assign(t.style,s,d),w},Ht=({productConfig:t,useMobileStyling:e,surveyId:n,isFeedback:o})=>{var r,i;const s=he,a=o&&t.desktopDisplay==="slider";Ge(n,o,a),$t();const l=document.createElement("iframe");l.id=s,l.setAttribute("title","Sprig User Feedback Dialog");const c=Vt(l,t,e,o);Je();let d=!1;l.setHeight=y=>{(parseInt(l.style.height)!=y||!d)&&(d=!0,l.style.height=`${y}px`,p.emit(u.SurveyHeight,{name:u.SurveyHeight,contentFrameHeight:y,"survey.id":n}))};let w=!1;l.setWidth=y=>{(parseInt(l.style.width)!=y||!w)&&(w=!0,l.style.width=`${y}px`,p.emit(u.SurveyWidth,{name:u.SurveyWidth,contentFrameWidth:y,"survey.id":n}))},(r=window.UserLeap.container)==null||r.appendChild(l),t&&(e?t.exitOnOverlayClickMobile:t.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{p.emit(u.CloseSurveyOnOverlayClick)}),p.emit(u.SurveyLifeCycle,{state:"presented"}),p.emit(u.SurveyPresented,{name:u.SurveyPresented,"survey.id":n});const g=(i=l.contentWindow)==null?void 0:i.document;if(g&&(g.open("text/html","replace"),g.write("<!doctype html><head></head><body></body></html>"),g.close(),!e)){const y=g.body;y.style.display="flex",y.style.alignItems="center"}const h=g?.head;return{frameId:s,contentWinDocHead:h,contentWindow:l.contentWindow,hasOverlay:c,iframe:l}},Qe={[u.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},$t=()=>{Object.entries(Qe).forEach(([t,e])=>{p.on(t,e)})},Gt=()=>{Object.entries(Qe).forEach(([t,e])=>{p.off(t,e)})},Kt=1,Ye=t=>t instanceof HTMLElement||t instanceof SVGElement,$=({document:t,elementId:e,styleString:n,nonce:o})=>{const r=t.getElementById(e);if(r){r.textContent=n;return}const i=t.createElement("style");o&&(i.nonce=o),i.textContent=n,i.id=e,t.head.appendChild(i)},Xe=t=>{const e=t.querySelector(".ul-card__container");let n=600,o=360;if(e){n=e.scrollHeight;const r=getComputedStyle(e),i=parseFloat(r.marginTop)+parseFloat(r.marginBottom),s=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth),a=parseFloat(r.paddingTop)+parseFloat(r.paddingBottom);n+=i+s+a;const l=e.querySelector(".ul-card--matrix_grid");o=l?l.scrollWidth:e.scrollWidth;const c=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),d=parseFloat(r.marginLeft)+parseFloat(r.marginRight),w=parseFloat(r.borderLeftWidth)+parseFloat(r.borderRightWidth);o+=d+w+c}return[n+Kt,o]},Jt=t=>{const e=t.querySelector(".ul-card__container");e&&(e.scrollTop=0)},Ze=()=>m,N=()=>document.getElementById("sprig-feedback-container"),Le=()=>document.getElementById("sprig-feedback-loading-animation"),Qt=()=>{if(Le())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=`
2
2
  <div class="ul-loading-spinner">
3
3
  <div class="first"></div>
4
4
  <div class="second"></div>
5
5
  <div class="third"></div>
6
6
  <div class="fourth"></div>
7
7
  </div>
8
- `,t},et=()=>!!document.getElementById(he);let tt=!1,m=null,A=null,Ue=!1,G=null,K=null;const Yt=["bottom-left","bottom-right","center-left","center-right"],Xt=t=>{if(B()||!Yt.includes(t))return;const[e,n]=t.split("-"),o=document.createElement("div");o.id="sprig-feedback-container",o.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${e}`),document.body.appendChild(o)},ne=()=>{var t;const e=window.UserLeap.container;return((t=e?.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},rt=()=>document.getElementById("sprig-feedback-error-container"),nt=()=>{if(!m)return 0;const t=m?.clientWidth,e=window.getComputedStyle(m),n=parseInt(e.borderRightWidth||"0"),o=parseInt(e.borderLeftWidth||"0");return t+n+o},ie=t=>{const e=B();e&&(K!=null&&K.endsWith("right")?e.style.right=`${t}px`:K!=null&&K.endsWith("left")&&(e.style.left=`${t}px`))},Se=()=>{if(m&&(ne()||rt())){p.off(u.SurveyAppeared,J),Ie();const t=nt();return ie(-t),!0}return!1},J=()=>{if(!m||!A)return;const t=Le();t&&t.remove(),m.style.height="auto",m.style.width="auto",A.disabled=!1,Ue=!1},Ie=()=>{if(m&&!Le()){const t=Qt();t&&(m.style.height="300px",m.style.width="360px",m.appendChild(t))}},it=()=>{!m||!A||(ie(0),A.disabled=!0,Ue=!0)},Zt=async t=>{const e=await D(_("1",[T],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:t}),method:"POST"});return e.ok?e.json:null},ot=async(t,e,n)=>{const{buttonTheme:o,customStyles:r,eventId:i,placement:s,desktopDisplay:a,feedbackLabel:l,surveyUuid:c,surveyId:d}=t;window.UserLeap.feedbackCustomStyles=void 0;let w=B();if(w){if(!e&&i===G)return;w.remove(),p.off(V.SURVEY_FADING_OUT,Se)}G=i,$({document,elementId:"sprig-feedback-style",styleString:Rt,nonce:window.UserLeap.styleNonce}),$({document,elementId:"ul-custom-style",styleString:r??"",nonce:window.UserLeap.styleNonce}),tt=a==="center-modal",K=s;const[g,h]=s.split("-");Xt(s),w=B(),A=document.createElement("button");const y=document.createElement("div");y.className="sprig-feedback-button-label",y.innerText=l,A.appendChild(y),A.id="sprig-feedback-button",A.classList.add(`sprig-feedback-button-${h}`,`sprig-feedback-button-${g}`,`sprig-feedback-button-${o}`,"fade-in-transition"),p.on(V.SURVEY_FADING_OUT,Se),A.addEventListener("click",async()=>{const k=document.getElementById("sprig-feedback-error-container");if(et()||rt()){if(Se()){p.emit(u.SurveyWillClose,{name:u.SurveyWillClose,initiator:M.FeedbackClosed,studyType:"feedbackButton","survey.id":d});const R=B();k&&R&&(R.remove(),G=null,m=null)}return}const b=C(window.UserLeap);if(!fe(b)&&!Ue&&it(),e){m&&m.classList.add("sprig-feedback-loading-container-previews"),await H(e),J();return}const I=await Zt(c);if(I)p.once(u.SurveyAppeared,J),H({...I,studyType:"feedbackButton"},n);else if(m){const R=tr();m.appendChild(R),J(),m.style.height="300px",m.style.width="360px"}}),w?.appendChild(A),p.emit(u.FeedbackButtonLoaded,{name:u.FeedbackButtonLoaded,"survey.id":d});const{useMobileStyling:f,_config:{border:S}}=window.UserLeap;if(!tt&&!f){const k=document.createElement("div");k.id="sprig-feedback-loading-container",k.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${h}`,k.style.setProperty("--feedback-border",S),m=k,Ie(),w?.appendChild(k);const b=nt();ie(-b)}else ie(0);window.UserLeap._config.isOnQuestionsTab&&e&&!ne()&&m&&(it(),Ie(),m&&m.classList.add("sprig-feedback-loading-container-previews"),H(e),J())},er=()=>{if(ne())return;const t=B();t&&(kt(G)||(t.remove(),G=null,m=null))},tr=()=>{const t=document.createElement("div");t.id="sprig-feedback-error-container",t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
8
+ `,t},et=()=>!!document.getElementById(he);let tt=!1,m=null,A=null,Ue=!1,G=null,K=null;const Yt=["bottom-left","bottom-right","center-left","center-right"],Xt=t=>{if(N()||!Yt.includes(t))return;const[e,n]=t.split("-"),o=document.createElement("div");o.id="sprig-feedback-container",o.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${e}`),document.body.appendChild(o)},ne=()=>{var t;const e=window.UserLeap.container;return((t=e?.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},rt=()=>document.getElementById("sprig-feedback-error-container"),nt=()=>{if(!m)return 0;const t=m?.clientWidth,e=window.getComputedStyle(m),n=parseInt(e.borderRightWidth||"0"),o=parseInt(e.borderLeftWidth||"0");return t+n+o},ie=t=>{const e=N();e&&(K!=null&&K.endsWith("right")?e.style.right=`${t}px`:K!=null&&K.endsWith("left")&&(e.style.left=`${t}px`))},Se=()=>{if(m&&(ne()||rt())){p.off(u.SurveyAppeared,J),Ie();const t=nt();return ie(-t),!0}return!1},J=()=>{if(!m||!A)return;const t=Le();t&&t.remove(),m.style.height="auto",m.style.width="auto",A.disabled=!1,Ue=!1},Ie=()=>{if(m&&!Le()){const t=Qt();t&&(m.style.height="300px",m.style.width="360px",m.appendChild(t))}},it=()=>{!m||!A||(ie(0),A.disabled=!0,Ue=!0)},Zt=async t=>{const e=await D(_("1",[T],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:t}),method:"POST"});return e.ok?e.json:null},ot=async(t,e,n)=>{const{buttonTheme:o,customStyles:r,eventId:i,placement:s,desktopDisplay:a,feedbackLabel:l,surveyUuid:c,surveyId:d}=t;window.UserLeap.feedbackCustomStyles=void 0;let w=N();if(w){if(!e&&i===G)return;w.remove(),p.off(V.SURVEY_FADING_OUT,Se)}G=i,$({document,elementId:"sprig-feedback-style",styleString:Rt,nonce:window.UserLeap.styleNonce}),$({document,elementId:"ul-custom-style",styleString:r??"",nonce:window.UserLeap.styleNonce}),tt=a==="center-modal",K=s;const[g,h]=s.split("-");Xt(s),w=N(),A=document.createElement("button");const y=document.createElement("div");y.className="sprig-feedback-button-label",y.innerText=l,A.appendChild(y),A.id="sprig-feedback-button",A.classList.add(`sprig-feedback-button-${h}`,`sprig-feedback-button-${g}`,`sprig-feedback-button-${o}`,"fade-in-transition"),p.on(V.SURVEY_FADING_OUT,Se),A.addEventListener("click",async()=>{const k=document.getElementById("sprig-feedback-error-container");if(et()||rt()){if(Se()){p.emit(u.SurveyWillClose,{name:u.SurveyWillClose,initiator:M.FeedbackClosed,studyType:"feedbackButton","survey.id":d});const R=N();k&&R&&(R.remove(),G=null,m=null)}return}const b=C(window.UserLeap);if(!fe(b)&&!Ue&&it(),e){m&&m.classList.add("sprig-feedback-loading-container-previews"),await H(e),J();return}const I=await Zt(c);if(I)p.once(u.SurveyAppeared,J),H({...I,studyType:"feedbackButton"},n);else if(m){const R=tr();m.appendChild(R),J(),m.style.height="300px",m.style.width="360px"}}),w?.appendChild(A),p.emit(u.FeedbackButtonLoaded,{name:u.FeedbackButtonLoaded,"survey.id":d});const{useMobileStyling:f,_config:{border:S}}=window.UserLeap;if(!tt&&!f){const k=document.createElement("div");k.id="sprig-feedback-loading-container",k.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${h}`,k.style.setProperty("--feedback-border",S),m=k,Ie(),w?.appendChild(k);const b=nt();ie(-b)}else ie(0);window.UserLeap._config.isOnQuestionsTab&&e&&!ne()&&m&&(it(),Ie(),m&&m.classList.add("sprig-feedback-loading-container-previews"),H(e),J())},er=()=>{if(ne())return;const t=N();t&&(kt(G)||(t.remove(),G=null,m=null))},tr=()=>{const t=document.createElement("div");t.id="sprig-feedback-error-container",t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
9
9
  <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
10
10
  <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
11
11
  <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
12
- </svg>`;const e=document.createElement("h3");return e.className="sprig-feedback-error-text",e.innerText="There was an error while loading the survey",t.appendChild(e),t},rr="!launch_darkly_";class nr{constructor(){q(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!e||typeof e!="object"||Array.isArray(e)?!1:(Object.keys(this._ldData).forEach(n=>{delete this._ldData[n]}),Object.keys(e).forEach(n=>this._ldData[`${rr}${n}`]=(e[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const ke=new nr;Object.freeze(ke);const ir="!optimizely_experiments_";class or{constructor(){q(this,"_optimizelyData",{})}setOptimizelyExperiment(e,n=!0){if(!e||typeof e!="object")return!1;const{experiments:o}=e;try{return n&&Object.keys(this._optimizelyData).map(r=>{delete this._optimizelyData[r]}),o&&o.map(r=>{const{id:i,variation:s}=r,a=this.transformExperimentId(i);s&&typeof s=="string"&&(this._optimizelyData[a]=s)}),!0}catch(r){return r instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",r),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return ir+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(n){const o=Object.keys(n).map(r=>{var i,s;return(i=n[r].variation)!=null&&i.name?{id:r,variation:(s=n[r].variation)==null?void 0:s.name}:{id:r,variation:"Original"}});return this.setOptimizelyExperiment({experiments:o},!1),!0}return!1}return!1}catch(n){return n instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",n),!1}}}const oe=new or;Object.freeze(oe);class sr{constructor(e,n){q(this,"paused"),q(this,"queue"),q(this,"ul"),this.ul=e,this.paused=!1,this.queue=[],this.flush(n)}flush(e){const n=e.length;if(n)for(let o=0;o<n;o++)this.push(e[o])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const e=this.queue.slice();this.empty(),this.flush(e)}push(e){if(this.paused)this.queue.push(e);else if(e instanceof Function)e();else{const n=Array.prototype.slice.call(e,1),o=e[0],r=this.ul[o];r instanceof Function?r.apply(this.ul,n):o&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",o)}}perform(e){if(this.paused){let n=()=>{};const o=new Promise(function(r){n=function(){r(e())}});return this.queue.push(n),o}else return e()}empty(){this.queue.length=0}}let st,at;const Ee=t=>{let e=0,n=t.firstElementChild;for(;n;)e+=Ee(n),n.shadowRoot&&(e+=Ee(n.shadowRoot)),n=n.nextElementSibling,e++;return e},ar=()=>document.documentElement.innerHTML.length,dt=()=>{st.report(Ee(document.body)),at.report(ar())},dr=(t=10*1e3)=>{st=j("sdk_dom_nodes_count"),at=j("sdk_page_html_characters"),dt(),setInterval(dt,t)},_e=(t,e)=>{const n=performance.now();document.hidden?setTimeout(()=>_e(t,e),t):setTimeout(()=>{const o=performance.now()-n;e.report(o/1e3),setTimeout(()=>_e(t,e),t)},0)},lr=(t=1e3)=>{const e=j("sdk_event_queue_latency_seconds");_e(t,e)};let se,ae,de,le,N={},lt;const ce=(t,e=1)=>{const{name:n}=t;N[n]=(N[n]||0)+e},ct=t=>{let e=1;return t.childNodes.forEach(n=>{e+=ct(n)}),e},pt=t=>{let e=0;return t.forEach(n=>{e+=ct(n)}),e},cr=t=>{switch(t.type){case"childList":ce(se,pt(t.addedNodes)),ce(ae,pt(t.removedNodes));return;case"attributes":ce(de);return;case"characterData":ce(le);return}},pr=t=>t.forEach(cr),ur=()=>{lt=new MutationObserver(pr),lt.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},wr=()=>{se.report(N[se.name]||0),ae.report(N[ae.name]||0),de.report(N[de.name]||0),le.report(N[le.name]||0),N={}},gr=(t=1*1e3)=>{se=j("sdk_mutations_nodes_added"),ae=j("sdk_mutations_nodes_removed"),de=j("sdk_mutations_attributes_changed"),le=j("sdk_mutations_character_data"),ur(),setInterval(wr,t)},mr=({isWeb:t,reportingIntervalSeconds:e,thresholds:n,postMetrics:o})=>{Et(n,(r,i)=>{var s,a;if((s=U.replay)!=null&&s.isReplayRecording()){const l=`Value: ${r} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(a=U.replay)==null||a.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}),xt()}}),_t({reportingIntervalSeconds:e,postMetrics:o}),t&&(lr(),dr(),gr())},yr={test:"test"},vr=["popState","pushState","replaceState"],Q="!email",ut="pageUrl";function fr(t,e){const{pageUrlEvents:n,interactiveEvents:o,dismissOnPageChange:r}=window.UserLeap._config;if(!r)return!0;const i=[];n&&n.length&&i.push(...n),o&&o.length&&i.push(...o);const s=t&&i.find(a=>a.id===t);return s?ye(s,window.location.href):e===window.location.href}let xe=window.location.href;function Y(t){var e;const{pageUrlEvents:n,interactiveEvents:o,dismissOnPageChange:r,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;xe!==window.location.href&&P.navigation("LocationChange",{from:xe,to:window.location.href}),xe=window.location.href;const s=z("trackStartUrl"),a=s?String(s):null;n&&yt(window.location.href),o&&(gt(),hr()),Ze()&&er(),Dt.getItem("sprig.isCapturingHeatmap")&&((e=U.replay)==null||e.checkPendingHeatmapsUrl()),!ne()&&r&&a&&a!==window.location.href&&t&&vr.includes(t.type)&&window.UserLeap("dismissActiveSurvey",M.PageChange)}const wt={capture:!0},hr=()=>{const t=window.UserLeap._config.interactiveEvents.filter(n=>ye(n,window.location.href)).map(n=>{const{name:o,properties:r}=n,{selector:i,innerText:s}=r;return i?a=>{if(Ye(a.target))try{a.target.closest(i)&&window.UserLeap("track",o)}catch{}return!1}:a=>(Ye(a.target)&&a.target.innerText===s&&window.UserLeap("track",o),!1)}),e=n=>t.forEach(o=>o(n));window.UserLeap._config.interactiveEventsHandler=e,window.addEventListener("click",e,wt)},gt=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,wt),delete window.UserLeap._config.interactiveEventsHandler};function br(){["hashchange","popstate"].forEach(t=>window.addEventListener(t,Y,!0))}function Lr(){["hashchange","popstate"].forEach(t=>window.removeEventListener(t,Y,!0)),window.UserLeap._config.interactiveEvents&&gt()}function Ur(t){const e=new URL(_("1",[F],"questions"));return Object.entries(t||{}).forEach(([n,o])=>{o&&e.searchParams.append(n,String(o))}),e.toString()}function z(t){const e=x.getItem("userleap.ids");if(e)try{const n=JSON.parse(e)[window.UserLeap.envId];return n&&n[t]||null}catch(n){n instanceof Error&&(n.stack=e,window.UserLeap.reportError("Failed to parse local storage credentials",n))}return null}function mt(){window.previewMode||(window.UserLeap.visitorId=je(),P.info("NewVid",{vid:window.UserLeap.visitorId}),E("vid",window.UserLeap.visitorId),p.emit(u.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function yt(t,e,n,o){var r,i;try{if(t.endsWith("mock_snippet.html"))return;P.info("PageView",{url:t});const s=window.UserLeap._config.pageUrlEvents;let a=!1;if(s&&s.length)for(let d=0;d<s.length&&(a=ye(s[d],t),!a);d++);if(!a)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const l={url:t};o&&(l.trackPageView=!0),window.UserLeap._queue.push(["track",ut,e,l,n]);const c=(r=document?.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(i=U.replay)==null||i.RecordPageView({...c&&{description:c},url:t,referrer:document.referrer,pageTitle:document.title})}catch(s){s instanceof Error&&(s.stack=t,window.UserLeap.reportError("trackPageView",s)),console.warn("[Sprig] (ERR-428) Failed to track page view",s)}}function Sr(){const t="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in t&&(t.pushState=(e=>function(...n){const o=e.apply(this,n),r=new Event("pushState");return window.dispatchEvent(r),Y(r),o})(t.pushState)),"replaceState"in t&&(t.replaceState=(e=>function(...n){const o=e.apply(this,n),r=new Event("replaceState");return window.dispatchEvent(r),Y(r),o})(t.replaceState)),br()}async function De(t,e){const n=ve();t&&!e&&(window.UserLeap._config.mode=yr.test);const o=C(window.UserLeap),r=fe(o),i=await D(Ur({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:r,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:t?.surveyId,surveytemplateid:t?.surveyTemplateId,vid:n}),{shouldDropOnRateLimit:!0});if(!i.ok)return i.reportError&&i.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",i.error),window.UserLeap.reportError("getQuestions",i.error)),{success:!1,surveyState:"no survey"};if(i.json.delay&&await We(i.json.delay),i.json.isFeedback){const{feedbackLabel:s,productConfig:a,surveyUuid:l,feedbackCustomStyles:c}=i.json,{buttonTheme:d,placement:w,desktopDisplay:g}=a,h={customStyles:c,buttonTheme:d,desktopDisplay:g,eventId:0,feedbackLabel:s,placement:w,surveyUuid:l,surveyId:t?.surveyId};ot(h,i.json)}else return H(i.json)}function Ir(t){let e=t.length;for(;e;){const n=Math.floor(Math.random()*e);e-=1;const o=t[e];t[e]=t[n],t[n]=o}}function kr(t){if(!t)return;window.UserLeap._config=t,t.mute&&window.UserLeap._queue.pause();const{interactiveEvents:e,pageUrlEvents:n,dismissOnPageChange:o}=t;e&&Ir(e),(e||n||o)&&(Sr(),Y())}async function Er(t,e){var n,o;let r=!0;return e&&(n=t?.json)!=null&&n.surveyId&&(window.UserLeap.delayingSurvey=!0,r=await e(t.json.surveyId),window.UserLeap.delayingSurvey=!1,!r)?!1:((o=t?.json)!=null&&o.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await We(t.json.delay),window.UserLeap.delayingSurvey=!1),r)}const _r=function(t){if(!window.UserLeap)return;const e=async(r={})=>{var i,s,a,l,c;const{userId:d,anonymousId:w,metadata:g={},properties:h,showSurveyCallback:y}=r;let{eventName:f}=r;if(window.UserLeap.debugMode&&f!==ut&&console.info("[DEBUG] Sprig track",r),t.mode==="test")return;const S=x.getItem("sprig.previewKey")??void 0;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!d){const L="[Sprig] - Skipping tracking without userId";return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}if(!f||f.trim().length===0){f=f?String(f):"";const L="[Sprig] - Invalid event name "+f;return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}const k=window.location.href;if(g.url||(g.url=k),E("trackStartUrl",k),(s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled){const L=C(window.UserLeap);re(L)||oe.getAndSetWebOptimizelyExperiments(),g.optimizelyExperiments=Object.assign({},oe.getAllOptimizelyExperiments())}(l=(a=window.UserLeap)==null?void 0:a._config)!=null&&l.launchDarklyEnabled&&(g.launchDarklyFlags=ke.getAllLaunchDarklyVariations()),d&&(window.UserLeap.userId=d),w&&(window.UserLeap.partnerAnonymousId=w),h&&(g.eventProperties=h),(c=U.replay)==null||c.RecordEvent({name:f,url:g.url}),P.info("TrackEvent",{eventName:f});const b=window.UserLeap.delayingSurvey||et()?await D(_("1",[T],"events/batch"),{body:JSON.stringify({events:[{event:f,metadata:g}],previewKey:S}),method:"POST",shouldDropOnRateLimit:!0}):await D(_("1",[T],"events"),{body:JSON.stringify({event:f,metadata:g,previewKey:S}),method:"POST",shouldDropOnRateLimit:!0});if(!b.ok){const L="[Sprig] (ERR-421) Failed to track event";return b.reportError&&(console.warn(L,b.error),b.error&&window.UserLeap.reportError("track",b.error)),{success:!1,message:L,error:b.error,surveyState:"no survey"}}d&&E("uid",d),w&&E("aid",w);const I=b.json;I.invalidPreviewKey&&x.removeItem("sprig.previewKey");const R=g.trackPageView?g.url:void 0;return I!=null&&I.feedbackButton&&ot(I.feedbackButton,void 0,R),await Er(b,y)?fr(I.eventId,k)?H(I,R):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},n=(r,i)=>{var s;const a=(s=r?.querySelector(`[id="${he}"]`))==null?void 0:s.contentDocument;a&&$({document:a,elementId:"ul-custom-style",styleString:i})},o={async displaySurvey(r){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",M.Override),De({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",M.Override),De({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",M.Override),De({surveyId:r},!1)},previewSurvey(r){o._previewSurvey(r)},reviewSurvey(r){o._reviewSurvey(r)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(r=M.API){window.UserLeap.container&&p.emit(u.SurveyWillClose,{name:u.SurveyWillClose,initiator:r,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)})},async setAttribute(r,i){if(!r||!i&&i!==0&&i!==!1){const s="[Sprig] - Disregarding empty attribute / value provided";return console.warn(s),{success:!1,message:s}}return this.setAttributes({[r]:i})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),t.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const d="[Sprig] - Disregarding empty payload provided";return console.warn(d),{success:!1,message:d}}const{userId:i,anonymousId:s,attributes:a}=r;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const d="[Sprig] - Skipping tracking without userId";return console.warn(d),{success:!1,message:d}}if(!a&&(!i||window.UserLeap.userId===i)&&(!s||window.UserLeap.partnerAnonymousId===s))return{success:!0};const l={};i&&(l.userId=window.UserLeap.userId=i),s&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s);let c;return a?(a.email&&!Object.prototype.hasOwnProperty.call(a,Q)&&(a[Q]=a.email,delete a.email),c=await D(_("1",[F,T],"attributes"),{body:JSON.stringify(a),method:"PUT"}),!c.ok&&c.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",c.error),c.error&&window.UserLeap.reportError("identifyAndSetAttributes",c.error))):c=await D(_("1",[F,T]),{body:JSON.stringify(l),method:"PUT"}),a&&a[Q]&&(window.UserLeap.email=a[Q]),c.ok&&(i&&E("uid",i),s&&E("aid",s)),{success:!!c.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),t.mode==="test")return;if(r==null||r.length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}if(t.requireUserIdForTracking&&!window.UserLeap.userId){const s="[Sprig] - Skipping tracking without userId";return console.warn(s),{success:!1,message:s}}const i=await D(_("1",[F,T],"attributes"),{body:JSON.stringify({delete:r}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&window.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(r){p.on(u.SurveyLifeCycle,r)},async removeSurveyListener(r){p.removeListener(u.SurveyLifeCycle,r)},async addListener(r,i){p.on(r,i)},async removeListener(r,i){p.removeListener(r,i)},async removeAllListeners(){p.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||x.isStorageAvailable&&r&&x.setItem("sprig.previewKey",r)},async setUserId(r){var i;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",r),r==null){const l=`[Sprig] - Invalid userId ${r}`;return console.warn(l),{success:!1,message:l}}if(t.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const s=window.UserLeap.visitorId,a=await D(_("1",[F,T]),{body:JSON.stringify({userId:r}),method:"PUT"});if(!a.ok){a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.error));return}s!==window.UserLeap.visitorId&&((i=U.replay)==null||i.clearUserReplayData()),E("uid",r)},async setPartnerAnonymousId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",r),r==null){const i=`[Sprig] - Invalid partnerAnonymousId ${r}`;return console.warn(i),{success:!1,message:i}}return window.UserLeap.partnerAnonymousId=r,E("aid",r),{success:!0}},async track(r,i,s={},a=void 0){return e({eventName:r,properties:i,metadata:s,showSurveyCallback:a})},async identifyAndTrack(r){return await e(r)},trackPageView(r,i=void 0,s=void 0,a=!0){yt(r,i,s,a)},applyFeedbackStyles({button:r="",view:i=""}){window.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&$({document,elementId:"ul-custom-style",styleString:r,nonce:window.UserLeap.styleNonce}),n(document.querySelector(".ul-container-feedback"),i)},applyStyles(r){window.UserLeap.customStyles=r,n(window.UserLeap.container,r)},setWindowDimensions(r,i){var s,a;const l=typeof r=="string"?parseInt(r,10):r,c=typeof i=="string"?parseInt(i,10):i;if(!isNaN(l)&&!isNaN(c)&&(window.UserLeap.windowDimensions={width:l,height:c}),!window.UserLeap.frameId)return;const d=document.getElementById(window.UserLeap.frameId);d&&(window.UserLeap.useMobileStyling&&((s=window.UserLeap.windowDimensions)!=null&&s.width&&(d.style.width=`${window.UserLeap.windowDimensions.width}px`),(a=window.UserLeap.windowDimensions)!=null&&a.height&&(d.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),d.contentDocument&&(d.style.height=String(Xe(d.contentDocument)[0])+"px")),p.emit(u.SurveyDimensions,{name:u.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},logoutUser(){var r;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),P.info("LogOut",{vid:window.UserLeap.visitorId,userId:window.UserLeap.userId}),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,x.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),mt(),(r=U.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){Lr(),window.UserLeap("dismissActiveSurvey",M.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(r,i=!0){var s,a;if(!((a=(s=window.UserLeap)==null?void 0:s._config)!=null&&a.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const l=typeof r=="string"?JSON.parse(r):r;oe.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}},integrateOptimizelyClient(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const a=({experiment:l,variation:c})=>{const d={experiments:[{id:l.id,variation:c.key}]};window.UserLeap("integrateOptimizely",d,!1)};r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",a)},importLaunchDarklyData(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}ke.setLDFlagsVariations(r)},setVisitorAttribute(r,i){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),o.setAttribute(r,i)},async setEmail(r){return o.setAttribute(Q,r)},async setVisitorEmail(r){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),o.setEmail(r)},async _generateVideoUploadUrl(r){return Ar(r)},_reportMetric(r,i){At(r,i)},async _completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:s}){var a;return U.replay?(a=U.replay)==null?void 0:a._completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:s,headers:C(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,o)};async function xr(t){const e=C(window.UserLeap);document.addEventListener("securitypolicyviolation",Ne);const n=await Me(_("1",[F],"config"),{headers:e});if(document.removeEventListener("securitypolicyviolation",Ne),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),ze("Disabled: failed to fetch configuration"),t;const o=n.json;return o!=null&&o.disabled?(ze(`Disabled: ${o.disabled}`),{disabled:o.disabled}):Object.assign({},o,t)}async function Dr(t,e,n={},o={}){const r=window.__cfg&&window.__cfg.mode,i=ve(),s=window.UserLeap.envId,a=window.document.documentElement,l={mode:r,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:a.clientWidth,clientHeight:a.clientHeight,location:window.location.href,language:window.navigator.language,...n},c={action:t,breadcrumbs:P.breadcrumbs,err:{message:e.message,stack:e.stack},meta:l,vid:i,envId:s,...o};(await D(_("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",e)}async function Ar(t){var e;if(!t)return;const n=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const o=await fetch(n,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(o.ok){const r=await o.json();return(e=r?.upload)==null?void 0:e.url}else return null}catch(o){console.warn("[Sprig] Error with generating video upload url"),o instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",o)}}function Rr(t={}){const e=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=V,window.UserLeap("setPreviewKey",e);async function n(){var o;if(window.UserLeap.loaded)return;if(window.UserLeap.reportError=Dr,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},t,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const d in window.UserLeap._config)window.UserLeap[d]=window.UserLeap._config[d];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const r=window.UserLeap.sampleRate;if(r){let d=z("sampled");if(d===null&&(d=Math.random()<r,E("sampled",d)),!d)return}else z("sampled")!==null&&E("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const i=[...window.UserLeap._queue];window.UserLeap._queue=new sr(window.UserLeap,[]),window.UserLeap._queue.pause();for(let d=0;d<i.length;d++)window.UserLeap._queue.push(i[d]);const s=z("token");s?(window.UserLeap.token=s,window.UserLeap.visitorId=z("vid"),window.UserLeap.userId=z("uid"),window.UserLeap.partnerAnonymousId=z("aid")):(x.removeItem("userleap.ids"),mt());const a=C(window.UserLeap),l=re(a),c=await xr(t);mr({isWeb:!l,reportingIntervalSeconds:c.metricsReportingEnabled||c.mobileMetricsReportingEnabled?c.metricsReportingIntervalSeconds:0,thresholds:c.metricThresholds,postMetrics:async d=>{var w;await D(_("1",[F],"metrics"),{body:d,method:"POST",headers:{"x-ul-replay-enabled":`${!!((w=U.replay)!=null&&w.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),await((o=U.replay)==null?void 0:o.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:c.maxReplayDurationSeconds,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:c.replaySettings})),_r(c),await kr(c),window.UserLeap._queue.unpause(),p.emit(u.SDKReady,{mobileMetricsReportingEnabled:!!c.mobileMetricsReportingEnabled,metricsReportingInterval:c.metricsReportingIntervalSeconds||0,metricsThresholds:c.metricThresholds||[],maxMobileReplayDurationSeconds:c.maxMobileReplayDurationSeconds,mobileReplaySettings:c.mobileReplaySettings}),p.emit(u.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class pe{constructor(){this.UPDATES=V}displaySurvey(e){window.Sprig("displaySurvey",e)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(e,n){window.Sprig("setAttribute",e,n)}setAttributes(e){window.Sprig("setAttributes",e)}identifyAndSetAttributes(e){window.Sprig("identifyAndSetAttributes",e)}removeAttributes(e){window.Sprig("removeAttributes",e)}addListener(e,n){window.Sprig("addListener",e,n)}removeListener(e,n){window.Sprig("removeListener",e,n)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(e){window.Sprig("setAttribute","!email",e)}setUserId(e){window.Sprig("setUserId",e)}setPartnerAnonymousId(e){window.Sprig("setPartnerAnonymousId",e)}track(e,n={},o={}){window.Sprig("track",e,n,o)}identifyAndTrack(e){window.Sprig("identifyAndTrack",e)}trackPageView(e,n,o){window.Sprig("trackPageView",e,n,o)}applyStyles(e){window.Sprig("applyStyles",e)}setWindowDimensions(e,n){window.Sprig("setWindowDimensions",e,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const Ae={configure:t=>{if(!t.envId&&!t.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(t.envId||(t.envId=t.environmentId??""),t.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(pe.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=pe.prototype[n])});const e=window.Sprig;return e.appId=t.envId,e._queue=[],window.UserLeap=e,Rr(t),window.Sprig}},Or={sprig:Ae,SprigAPI:pe,configure:Ae.configure};export{Ot as A,He as C,Be as D,Ft as E,pe as S,Xe as a,Ct as b,Or as c,Pt as d,$ as e,Jt as r,Ae as s};
12
+ </svg>`;const e=document.createElement("h3");return e.className="sprig-feedback-error-text",e.innerText="There was an error while loading the survey",t.appendChild(e),t},rr="!launch_darkly_";class nr{constructor(){q(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!e||typeof e!="object"||Array.isArray(e)?!1:(Object.keys(this._ldData).forEach(n=>{delete this._ldData[n]}),Object.keys(e).forEach(n=>this._ldData[`${rr}${n}`]=(e[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const ke=new nr;Object.freeze(ke);const ir="!optimizely_experiments_";class or{constructor(){q(this,"_optimizelyData",{})}setOptimizelyExperiment(e,n=!0){if(!e||typeof e!="object")return!1;const{experiments:o}=e;try{return n&&Object.keys(this._optimizelyData).map(r=>{delete this._optimizelyData[r]}),o&&o.map(r=>{const{id:i,variation:s}=r,a=this.transformExperimentId(i);s&&typeof s=="string"&&(this._optimizelyData[a]=s)}),!0}catch(r){return r instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",r),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return ir+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(n){const o=Object.keys(n).map(r=>{var i,s;return(i=n[r].variation)!=null&&i.name?{id:r,variation:(s=n[r].variation)==null?void 0:s.name}:{id:r,variation:"Original"}});return this.setOptimizelyExperiment({experiments:o},!1),!0}return!1}return!1}catch(n){return n instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",n),!1}}}const oe=new or;Object.freeze(oe);class sr{constructor(e,n){q(this,"paused"),q(this,"queue"),q(this,"ul"),this.ul=e,this.paused=!1,this.queue=[],this.flush(n)}flush(e){const n=e.length;if(n)for(let o=0;o<n;o++)this.push(e[o])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const e=this.queue.slice();this.empty(),this.flush(e)}push(e){if(this.paused)this.queue.push(e);else if(e instanceof Function)e();else{const n=Array.prototype.slice.call(e,1),o=e[0],r=this.ul[o];r instanceof Function?r.apply(this.ul,n):o&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",o)}}perform(e){if(this.paused){let n=()=>{};const o=new Promise(function(r){n=function(){r(e())}});return this.queue.push(n),o}else return e()}empty(){this.queue.length=0}}let st,at;const Ee=t=>{let e=0,n=t.firstElementChild;for(;n;)e+=Ee(n),n.shadowRoot&&(e+=Ee(n.shadowRoot)),n=n.nextElementSibling,e++;return e},ar=()=>document.documentElement.innerHTML.length,dt=()=>{st.report(Ee(document.body)),at.report(ar())},dr=(t=10*1e3)=>{st=j("sdk_dom_nodes_count"),at=j("sdk_page_html_characters"),dt(),setInterval(dt,t)},_e=(t,e)=>{const n=performance.now();document.hidden?setTimeout(()=>_e(t,e),t):setTimeout(()=>{const o=performance.now()-n;e.report(o/1e3),setTimeout(()=>_e(t,e),t)},0)},lr=(t=1e3)=>{const e=j("sdk_event_queue_latency_seconds");_e(t,e)};let se,ae,de,le,z={},lt;const ce=(t,e=1)=>{const{name:n}=t;z[n]=(z[n]||0)+e},ct=t=>{let e=1;return t.childNodes.forEach(n=>{e+=ct(n)}),e},pt=t=>{let e=0;return t.forEach(n=>{e+=ct(n)}),e},cr=t=>{switch(t.type){case"childList":ce(se,pt(t.addedNodes)),ce(ae,pt(t.removedNodes));return;case"attributes":ce(de);return;case"characterData":ce(le);return}},pr=t=>t.forEach(cr),ur=()=>{lt=new MutationObserver(pr),lt.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},wr=()=>{se.report(z[se.name]||0),ae.report(z[ae.name]||0),de.report(z[de.name]||0),le.report(z[le.name]||0),z={}},gr=(t=1*1e3)=>{se=j("sdk_mutations_nodes_added"),ae=j("sdk_mutations_nodes_removed"),de=j("sdk_mutations_attributes_changed"),le=j("sdk_mutations_character_data"),ur(),setInterval(wr,t)},mr=({isWeb:t,reportingIntervalSeconds:e,thresholds:n,postMetrics:o})=>{Et(n,(r,i)=>{var s,a;if((s=U.replay)!=null&&s.isReplayRecording()){const l=`Value: ${r} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(a=U.replay)==null||a.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}),xt()}}),_t({reportingIntervalSeconds:e,postMetrics:o}),t&&(lr(),dr(),gr())},yr={test:"test"},vr=["popState","pushState","replaceState"],Q="!email",ut="pageUrl";function fr(t,e){const{pageUrlEvents:n,interactiveEvents:o,dismissOnPageChange:r}=window.UserLeap._config;if(!r)return!0;const i=[];n&&n.length&&i.push(...n),o&&o.length&&i.push(...o);const s=t&&i.find(a=>a.id===t);return s?ye(s,window.location.href):e===window.location.href}let xe=window.location.href;function Y(t){var e;const{pageUrlEvents:n,interactiveEvents:o,dismissOnPageChange:r,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;xe!==window.location.href&&P.navigation("LocationChange",{from:xe,to:window.location.href}),xe=window.location.href;const s=W("trackStartUrl"),a=s?String(s):null;n&&yt(window.location.href),o&&(gt(),hr()),Ze()&&er(),Dt.getItem("sprig.isCapturingHeatmap")&&((e=U.replay)==null||e.checkPendingHeatmapsUrl()),!ne()&&r&&a&&a!==window.location.href&&t&&vr.includes(t.type)&&window.UserLeap("dismissActiveSurvey",M.PageChange)}const wt={capture:!0},hr=()=>{const t=window.UserLeap._config.interactiveEvents.filter(n=>ye(n,window.location.href)).map(n=>{const{name:o,properties:r}=n,{selector:i,innerText:s}=r;return i?a=>{if(Ye(a.target))try{a.target.closest(i)&&window.UserLeap("track",o)}catch{}return!1}:a=>(Ye(a.target)&&a.target.innerText===s&&window.UserLeap("track",o),!1)}),e=n=>t.forEach(o=>o(n));window.UserLeap._config.interactiveEventsHandler=e,window.addEventListener("click",e,wt)},gt=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,wt),delete window.UserLeap._config.interactiveEventsHandler};function br(){["hashchange","popstate"].forEach(t=>window.addEventListener(t,Y,!0))}function Lr(){["hashchange","popstate"].forEach(t=>window.removeEventListener(t,Y,!0)),window.UserLeap._config.interactiveEvents&&gt()}function Ur(t){const e=new URL(_("1",[F],"questions"));return Object.entries(t||{}).forEach(([n,o])=>{o&&e.searchParams.append(n,String(o))}),e.toString()}function W(t){const e=x.getItem("userleap.ids");if(e)try{const n=JSON.parse(e)[window.UserLeap.envId];return n&&n[t]||null}catch(n){n instanceof Error&&(n.stack=e,window.UserLeap.reportError("Failed to parse local storage credentials",n))}return null}function mt(){window.previewMode||(window.UserLeap.visitorId=je(),P.info("NewVid",{vid:window.UserLeap.visitorId}),E("vid",window.UserLeap.visitorId),p.emit(u.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function yt(t,e,n,o){var r,i;try{if(t.endsWith("mock_snippet.html"))return;P.info("PageView",{url:t});const s=window.UserLeap._config.pageUrlEvents;let a=!1;if(s&&s.length)for(let d=0;d<s.length&&(a=ye(s[d],t),!a);d++);if(!a)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const l={url:t};o&&(l.trackPageView=!0),window.UserLeap._queue.push(["track",ut,e,l,n]);const c=(r=document?.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(i=U.replay)==null||i.RecordPageView({...c&&{description:c},url:t,referrer:document.referrer,pageTitle:document.title})}catch(s){s instanceof Error&&(s.stack=t,window.UserLeap.reportError("trackPageView",s)),console.warn("[Sprig] (ERR-428) Failed to track page view",s)}}function Sr(){const t="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in t&&(t.pushState=(e=>function(...n){const o=e.apply(this,n),r=new Event("pushState");return window.dispatchEvent(r),Y(r),o})(t.pushState)),"replaceState"in t&&(t.replaceState=(e=>function(...n){const o=e.apply(this,n),r=new Event("replaceState");return window.dispatchEvent(r),Y(r),o})(t.replaceState)),br()}async function De(t,e){const n=ve();t&&!e&&(window.UserLeap._config.mode=yr.test);const o=C(window.UserLeap),r=fe(o),i=await D(Ur({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:r,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:t?.surveyId,surveytemplateid:t?.surveyTemplateId,vid:n}),{shouldDropOnRateLimit:!0});if(!i.ok)return i.reportError&&i.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",i.error),window.UserLeap.reportError("getQuestions",i.error)),{success:!1,surveyState:"no survey"};if(i.json.delay&&await Be(i.json.delay),i.json.isFeedback){const{feedbackLabel:s,productConfig:a,surveyUuid:l,feedbackCustomStyles:c}=i.json,{buttonTheme:d,placement:w,desktopDisplay:g}=a,h={customStyles:c,buttonTheme:d,desktopDisplay:g,eventId:0,feedbackLabel:s,placement:w,surveyUuid:l,surveyId:t?.surveyId};ot(h,i.json)}else return H(i.json)}function Ir(t){let e=t.length;for(;e;){const n=Math.floor(Math.random()*e);e-=1;const o=t[e];t[e]=t[n],t[n]=o}}function kr(t){if(!t)return;window.UserLeap._config=t,t.mute&&window.UserLeap._queue.pause();const{interactiveEvents:e,pageUrlEvents:n,dismissOnPageChange:o}=t;e&&Ir(e),(e||n||o)&&(Sr(),Y())}async function Er(t,e){var n,o;let r=!0;return e&&(n=t?.json)!=null&&n.surveyId&&(window.UserLeap.delayingSurvey=!0,r=await e(t.json.surveyId),window.UserLeap.delayingSurvey=!1,!r)?!1:((o=t?.json)!=null&&o.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await Be(t.json.delay),window.UserLeap.delayingSurvey=!1),r)}const _r=function(t){if(!window.UserLeap)return;const e=async(r={})=>{var i,s,a,l,c;const{userId:d,anonymousId:w,metadata:g={},properties:h,showSurveyCallback:y}=r;let{eventName:f}=r;if(window.UserLeap.debugMode&&f!==ut&&console.info("[DEBUG] Sprig track",r),t.mode==="test")return;const S=x.getItem("sprig.previewKey")??void 0;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!d){const L="[Sprig] - Skipping tracking without userId";return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}if(!f||f.trim().length===0){f=f?String(f):"";const L="[Sprig] - Invalid event name "+f;return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}const k=window.location.href;if(g.url||(g.url=k),E("trackStartUrl",k),(s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled){const L=C(window.UserLeap);re(L)||oe.getAndSetWebOptimizelyExperiments(),g.optimizelyExperiments=Object.assign({},oe.getAllOptimizelyExperiments())}(l=(a=window.UserLeap)==null?void 0:a._config)!=null&&l.launchDarklyEnabled&&(g.launchDarklyFlags=ke.getAllLaunchDarklyVariations()),d&&(window.UserLeap.userId=d),w&&(window.UserLeap.partnerAnonymousId=w),h&&(g.eventProperties=h),(c=U.replay)==null||c.RecordEvent({name:f,url:g.url}),P.info("TrackEvent",{eventName:f});const b=window.UserLeap.delayingSurvey||et()?await D(_("1",[T],"events/batch"),{body:JSON.stringify({events:[{event:f,metadata:g}],previewKey:S}),method:"POST",shouldDropOnRateLimit:!0}):await D(_("1",[T],"events"),{body:JSON.stringify({event:f,metadata:g,previewKey:S}),method:"POST",shouldDropOnRateLimit:!0});if(!b.ok){const L="[Sprig] (ERR-421) Failed to track event";return b.reportError&&(console.warn(L,b.error),b.error&&window.UserLeap.reportError("track",b.error)),{success:!1,message:L,error:b.error,surveyState:"no survey"}}d&&E("uid",d),w&&E("aid",w);const I=b.json;I.invalidPreviewKey&&x.removeItem("sprig.previewKey");const R=g.trackPageView?g.url:void 0;return I!=null&&I.feedbackButton&&ot(I.feedbackButton,void 0,R),await Er(b,y)?fr(I.eventId,k)?H(I,R):{success:!1,message:"Study should not be displayed after page navigation",surveyState:"no survey"}:{success:!1,message:"[Sprig] Callback returned false, aborting rendering of survey",surveyState:"no survey"}},n=(r,i)=>{var s;const a=(s=r?.querySelector(`[id="${he}"]`))==null?void 0:s.contentDocument;a&&$({document:a,elementId:"ul-custom-style",styleString:i})},o={async displaySurvey(r){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",M.Override),De({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",M.Override),De({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",M.Override),De({surveyId:r},!1)},previewSurvey(r){o._previewSurvey(r)},reviewSurvey(r){o._reviewSurvey(r)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(r=M.API){window.UserLeap.container&&p.emit(u.SurveyWillClose,{name:u.SurveyWillClose,initiator:r,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)})},async setAttribute(r,i){if(!r||!i&&i!==0&&i!==!1){const s="[Sprig] - Disregarding empty attribute / value provided";return console.warn(s),{success:!1,message:s}}return this.setAttributes({[r]:i})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),t.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const d="[Sprig] - Disregarding empty payload provided";return console.warn(d),{success:!1,message:d}}const{userId:i,anonymousId:s,attributes:a}=r;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!i){const d="[Sprig] - Skipping tracking without userId";return console.warn(d),{success:!1,message:d}}if(!a&&(!i||window.UserLeap.userId===i)&&(!s||window.UserLeap.partnerAnonymousId===s))return{success:!0};const l={};i&&(l.userId=window.UserLeap.userId=i),s&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s);let c;return a?(a.email&&!Object.prototype.hasOwnProperty.call(a,Q)&&(a[Q]=a.email,delete a.email),c=await D(_("1",[F,T],"attributes"),{body:JSON.stringify(a),method:"PUT"}),!c.ok&&c.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",c.error),c.error&&window.UserLeap.reportError("identifyAndSetAttributes",c.error))):c=await D(_("1",[F,T]),{body:JSON.stringify(l),method:"PUT"}),a&&a[Q]&&(window.UserLeap.email=a[Q]),c.ok&&(i&&E("uid",i),s&&E("aid",s)),{success:!!c.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),t.mode==="test")return;if(r==null||r.length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}if(t.requireUserIdForTracking&&!window.UserLeap.userId){const s="[Sprig] - Skipping tracking without userId";return console.warn(s),{success:!1,message:s}}const i=await D(_("1",[F,T],"attributes"),{body:JSON.stringify({delete:r}),method:"DELETE"});return!i.ok&&i.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",i.error),i.error&&window.UserLeap.reportError("removeAttributes",i.error)),{success:!!i.ok}},async addSurveyListener(r){p.on(u.SurveyLifeCycle,r)},async removeSurveyListener(r){p.removeListener(u.SurveyLifeCycle,r)},async addListener(r,i){p.on(r,i)},async removeListener(r,i){p.removeListener(r,i)},async removeAllListeners(){p.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||x.isStorageAvailable&&r&&x.setItem("sprig.previewKey",r)},async setUserId(r){var i;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",r),r==null){const l=`[Sprig] - Invalid userId ${r}`;return console.warn(l),{success:!1,message:l}}if(t.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const s=window.UserLeap.visitorId,a=await D(_("1",[F,T]),{body:JSON.stringify({userId:r}),method:"PUT"});if(!a.ok){a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.error));return}s!==window.UserLeap.visitorId&&((i=U.replay)==null||i.clearUserReplayData()),E("uid",r)},async setPartnerAnonymousId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",r),r==null){const i=`[Sprig] - Invalid partnerAnonymousId ${r}`;return console.warn(i),{success:!1,message:i}}return window.UserLeap.partnerAnonymousId=r,E("aid",r),{success:!0}},async track(r,i,s={},a=void 0){return e({eventName:r,properties:i,metadata:s,showSurveyCallback:a})},async identifyAndTrack(r){return await e(r)},trackPageView(r,i=void 0,s=void 0,a=!0){yt(r,i,s,a)},applyFeedbackStyles({button:r="",view:i=""}){window.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&$({document,elementId:"ul-custom-style",styleString:r,nonce:window.UserLeap.styleNonce}),n(document.querySelector(".ul-container-feedback"),i)},applyStyles(r){window.UserLeap.customStyles=r,n(window.UserLeap.container,r)},setWindowDimensions(r,i){var s,a;const l=typeof r=="string"?parseInt(r,10):r,c=typeof i=="string"?parseInt(i,10):i;if(!isNaN(l)&&!isNaN(c)&&(window.UserLeap.windowDimensions={width:l,height:c}),!window.UserLeap.frameId)return;const d=document.getElementById(window.UserLeap.frameId);d&&(window.UserLeap.useMobileStyling&&((s=window.UserLeap.windowDimensions)!=null&&s.width&&(d.style.width=`${window.UserLeap.windowDimensions.width}px`),(a=window.UserLeap.windowDimensions)!=null&&a.height&&(d.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),d.contentDocument&&(d.style.height=String(Xe(d.contentDocument)[0])+"px")),p.emit(u.SurveyDimensions,{name:u.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},logoutUser(){var r;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),P.info("LogOut",{vid:window.UserLeap.visitorId,userId:window.UserLeap.userId}),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,x.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),mt(),(r=U.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){Lr(),window.UserLeap("dismissActiveSurvey",M.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(r,i=!0){var s,a;if(!((a=(s=window.UserLeap)==null?void 0:s._config)!=null&&a.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const l=typeof r=="string"?JSON.parse(r):r;oe.setOptimizelyExperiment(l,i)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}},integrateOptimizelyClient(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const a=({experiment:l,variation:c})=>{const d={experiments:[{id:l.id,variation:c.key}]};window.UserLeap("integrateOptimizely",d,!1)};r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",a)},importLaunchDarklyData(r){var i,s;if(!((s=(i=window.UserLeap)==null?void 0:i._config)!=null&&s.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}ke.setLDFlagsVariations(r)},setVisitorAttribute(r,i){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),o.setAttribute(r,i)},async setEmail(r){return o.setAttribute(Q,r)},async setVisitorEmail(r){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),o.setEmail(r)},async _generateVideoUploadUrl(r){return Ar(r)},_reportMetric(r,i){At(r,i)},async _completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:s}){var a;return U.replay?(a=U.replay)==null?void 0:a._completeSessionReplay({surveyId:r,responseGroupUuid:i,eventDigest:s,headers:C(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,o)};async function xr(t){const e=C(window.UserLeap);document.addEventListener("securitypolicyviolation",ze);const n=await Me(_("1",[F],"config"),{headers:e});if(document.removeEventListener("securitypolicyviolation",ze),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),We("Disabled: failed to fetch configuration"),t;const o=n.json;return o!=null&&o.disabled?(We(`Disabled: ${o.disabled}`),{disabled:o.disabled}):Object.assign({},o,t)}async function Dr(t,e,n={},o={}){const r=window.__cfg&&window.__cfg.mode,i=ve(),s=window.UserLeap.envId,a=window.document.documentElement,l={mode:r,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:a.clientWidth,clientHeight:a.clientHeight,location:window.location.href,language:window.navigator.language,...n},c={action:t,breadcrumbs:P.breadcrumbs,err:{message:`${e?.name} - ${e?.message}`,stack:e?.stack},meta:l,vid:i,envId:s,...o};(await D(_("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",e)}async function Ar(t){var e;if(!t)return;const n=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const o=await fetch(n,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(o.ok){const r=await o.json();return(e=r?.upload)==null?void 0:e.url}else return null}catch(o){console.warn("[Sprig] Error with generating video upload url"),o instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",o)}}function Rr(t={}){const e=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=V,window.UserLeap("setPreviewKey",e);async function n(){var o;if(window.UserLeap.loaded)return;if(window.UserLeap.reportError=Dr,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},t,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const d in window.UserLeap._config)window.UserLeap[d]=window.UserLeap._config[d];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const r=window.UserLeap.sampleRate;if(r){let d=W("sampled");if(d===null&&(d=Math.random()<r,E("sampled",d)),!d)return}else W("sampled")!==null&&E("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const i=[...window.UserLeap._queue];window.UserLeap._queue=new sr(window.UserLeap,[]),window.UserLeap._queue.pause();for(let d=0;d<i.length;d++)window.UserLeap._queue.push(i[d]);const s=W("token");s?(window.UserLeap.token=s,window.UserLeap.visitorId=W("vid"),window.UserLeap.userId=W("uid"),window.UserLeap.partnerAnonymousId=W("aid")):(x.removeItem("userleap.ids"),mt());const a=C(window.UserLeap),l=re(a),c=await xr(t);mr({isWeb:!l,reportingIntervalSeconds:c.metricsReportingEnabled||c.mobileMetricsReportingEnabled?c.metricsReportingIntervalSeconds:0,thresholds:c.metricThresholds,postMetrics:async d=>{var w;await D(_("1",[F],"metrics"),{body:d,method:"POST",headers:{"x-ul-replay-enabled":`${!!((w=U.replay)!=null&&w.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),await((o=U.replay)==null?void 0:o.initializeReplay({maxReplayDurationSeconds:c.maxReplayDurationSeconds,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:c.replaySettings})),_r(c),await kr(c),window.UserLeap._queue.unpause(),p.emit(u.SDKReady,{mobileMetricsReportingEnabled:!!c.mobileMetricsReportingEnabled,metricsReportingInterval:c.metricsReportingIntervalSeconds||0,metricsThresholds:c.metricThresholds||[],maxMobileReplayDurationSeconds:c.maxMobileReplayDurationSeconds,mobileReplaySettings:c.mobileReplaySettings}),p.emit(u.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class pe{constructor(){this.UPDATES=V}displaySurvey(e){window.Sprig("displaySurvey",e)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(e,n){window.Sprig("setAttribute",e,n)}setAttributes(e){window.Sprig("setAttributes",e)}identifyAndSetAttributes(e){window.Sprig("identifyAndSetAttributes",e)}removeAttributes(e){window.Sprig("removeAttributes",e)}addListener(e,n){window.Sprig("addListener",e,n)}removeListener(e,n){window.Sprig("removeListener",e,n)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(e){window.Sprig("setAttribute","!email",e)}setUserId(e){window.Sprig("setUserId",e)}setPartnerAnonymousId(e){window.Sprig("setPartnerAnonymousId",e)}track(e,n={},o={}){window.Sprig("track",e,n,o)}identifyAndTrack(e){window.Sprig("identifyAndTrack",e)}trackPageView(e,n,o){window.Sprig("trackPageView",e,n,o)}applyStyles(e){window.Sprig("applyStyles",e)}setWindowDimensions(e,n){window.Sprig("setWindowDimensions",e,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const Ae={configure:t=>{if(!t.envId&&!t.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(t.envId||(t.envId=t.environmentId??""),t.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(pe.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=pe.prototype[n])});const e=window.Sprig;return e.appId=t.envId,e._queue=[],window.UserLeap=e,Rr(t),window.Sprig}},Or={sprig:Ae,SprigAPI:pe,configure:Ae.configure};export{Ot as A,He as C,Ne as D,Ft as E,pe as S,Xe as a,Ct as b,Or as c,Pt as d,$ as e,Jt as r,Ae as s};
@@ -0,0 +1,12 @@
1
+ "use strict";var dt=Object.defineProperty;var lt=(t,e,i)=>e in t?dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var F=(t,e,i)=>(lt(t,typeof e!="symbol"?e+"":e,i),i);const n=require("./metricsReporter-Bv4AKHDN.cjs"),ct='.ul-loading-spinner-container{font-size:1.8rem;flex-grow:1;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.ul-loading-spinner{display:inline-block;position:relative;width:6rem;height:6rem}.ul-loading-spinner div{box-sizing:border-box;display:block;position:absolute;width:80%;height:80%;margin:5px;border:5px solid #152e3e;border-radius:50%;animation:lds-ring 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:#152e3e transparent transparent transparent}.ul-loading-spinner .first{animation-delay:-.45s}.ul-loading-spinner .second{animation-delay:-.3s}.ul-loading-spinner .third{animation-delay:-.15s}@keyframes lds-ring{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fade-in-transition{animation:fadeIn .4s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}#sprig-feedback-button{border-left:0;border-radius:0 8px 8px 0;display:grid;padding:8px;text-align:center;transition:all ease-in-out 1s;z-index:inherit}#sprig-feedback-button:hover{cursor:pointer}.sprig-feedback-button-label{writing-mode:vertical-lr;text-orientation:sideways}.sprig-feedback-button-right{transform:rotate(180deg)}.sprig-feedback-button-bottom{align-self:flex-end;margin-bottom:20px}.sprig-feedback-button-light{background:#efefee;color:#000;border:1px solid #e2e3e1}.sprig-feedback-button-dark{background:#000;color:#fff;border:1px solid #000000}#sprig-feedback-container{display:flex;align-items:center;position:fixed;transition:right .2s linear,left .2s linear;z-index:2147483646}.sprig-feedback-container-left{flex-flow:row-reverse}.sprig-feedback-container-center{top:50%;transform:translateY(-50%)}.sprig-feedback-container-bottom{bottom:0%;margin-bottom:15px}.sprig-feedback-loading-container{align-items:center;background-color:#fff;border:2px solid var(--feedback-border);display:flex;max-height:90vh;max-width:90vw;min-width:0px}.sprig-feedback-loading-container-left{border-left:none;border-radius:0 8px 8px 0}.sprig-feedback-loading-container-right{border-right:none;border-radius:8px 0 0 8px}#sprig-feedback-error-container{margin:auto;text-align:center;width:360px}.sprig-feedback-error-text{font-weight:400;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol}#sprig-feedback-loading-container .ul-container{position:relative;max-height:inherit}#sprig-feedback-loading-animation{position:absolute}.sprig-feedback-loading-container-previews iframe{max-height:inherit!important}',Me="360px",pt="ul-app",ut="#e6e6e6",wt="#bd282a",gt=500,mt=1030,Fe=()=>{try{return window.parent.Intercom}catch{return null}},ft=()=>{const t=Fe();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)},yt=()=>{const t=Fe();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},vt=Object.freeze(Object.defineProperty({__proto__:null,disable:yt,enable:ft},Symbol.toStringTag,{value:"Module"})),Re=[vt];class He{static disable(){Re.forEach(e=>e.disable())}static enable(){Re.forEach(e=>e.enable())}}const Ae="ul-view-sdk-script",ht=["ios","android"],D="visitors",O="environments";async function k(t,e){var o,a,d;const{shouldDropOnRateLimit:i,...s}=e;s.headers=Object.assign(n.getHttpHeaders(window.UserLeap),s.headers);const r=await n.sprigFetch(t,{...s,shouldDropOnRateLimit:i});if(r.ok){const c=(o=r.headers)==null?void 0:o.get("Authorization"),p=c?c.split(" "):void 0,l=p&&p.length===2?p[1]:void 0,u=(a=r.headers)==null?void 0:a.get("x-ul-visitor-id");l&&u&&(u!==window.UserLeap.visitorId||window.UserLeap.token!==l)&&(S("token",l),S("vid",u),n.eventEmitter.emit(n.SprigEvent.VisitorIDUpdated,{visitorId:u}),window.UserLeap.token=l,window.UserLeap.visitorId=u)}return(d=r.json)!=null&&d.logMessage&&console.warn(`[Sprig] ${r.json.logMessage}`),r}function S(t,e){const i=n.localStorageHelper.getItem("userleap.ids");let s={};if(i)try{s=JSON.parse(i)}catch(o){o instanceof Error&&(o.stack=i,window.UserLeap.reportError("Failed to parse local storage credentials",o)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",o)}let r=s[window.UserLeap.envId];r?r[t]=e:r={[t]:e},s[window.UserLeap.envId]=r;try{n.localStorageHelper.setItem("userleap.ids",JSON.stringify(s))}catch(o){o instanceof Error&&console.warn(`[Sprig] (ERR-426) Unable to write to Local Storage:: ${o.message}`)}}function me(){return window.previewMode?"0":window.UserLeap.visitorId??""}function E(t,e,i){const s=[window.UserLeap._API_URL,"sdk",t];return e&&e.forEach(r=>{s.push(r),r===O?s.push(window.UserLeap.envId):r===D&&s.push(me())}),i&&s.push(i),s.join("/")}const B=async(t,e)=>{var Ee,Ie,ke;const{context:i,delay:s,forceBrandedLogo:r,endCard:o,isFeedback:a=!1,heatmap:d,locale:c,previewMode:p,productConfig:l,questions:u,responseGroupUid:y,surveyId:w,uuid:m,vid:L,sessionReplay:A,studyType:q}=t,v=n.getHttpHeaders(window.UserLeap),R=te(v),x=fe(v);if(A)if(R)n.eventEmitter.emit(n.SprigEvent.ReplayCapture,{responseGroupUid:y,hasQuestions:!!(u!=null&&u.length),surveyId:w,uploadId:A.uploadId,replayType:A.replayDurationType??"before",seconds:A.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:n.v4(),mediaType:"screen",questionId:1,responseGroupUid:y,surveyId:w,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!n.modules.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};n.modules.replay.scheduleOrCaptureReplay({responseGroupId:y,surveyId:w,visitorId:L,replayParams:A,completeUploadHeaders:v,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:u.length===0})}if(d){if(!n.modules.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};const{eventId:f,replayParams:oe,responseGroupUid:st,surveyId:at}=d;await n.modules.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),n.modules.replay.tryReplayAction(()=>{var _e;return(_e=n.modules.replay)==null?void 0:_e.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:v,eventId:f,isHeatmap:!0,replayParams:oe,responseGroupId:st,surveyId:at,triggerTimestamp:Date.now(),visitorId:L})},"Error in scheduling/capturing replay")}if(L==null||!(u!=null&&u.length))return n.breadcrumbsLogger.info("CannotDisplaySurvey",{vid:L}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){n.breadcrumbsLogger.info("AlreadyDisplayingSurvey");const f="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(f),{success:!1,message:f,surveyState:"no survey"}}if(L!==window.UserLeap.visitorId&&m!==window.UserLeap.visitorId&&!window.previewMode){const f="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(f)),{success:!1,message:f,surveyState:"no survey"}}n.breadcrumbsLogger.info("ShowingSurvey",{surveyId:w}),(Ee=n.modules.replay)==null||Ee.RecordSurveyShown({id:w,userAgent:window.navigator.userAgent}),He.disable(),n.eventEmitter.emit(n.SprigEvent.SurveyWillPresent,{name:n.SprigEvent.SurveyWillPresent,"survey.id":w});let I,b=document.createElement("div"),h,U,$;const Se=f=>{const{"view.version":oe}=f;oe!==v["x-ul-sdk-version"]&&Ne(),n.eventEmitter.removeListener("verify.view.version",Se)};n.eventEmitter.on("verify.view.version",Se),window.UserLeap.useMobileStyling=x,n.shouldDirectEmbed(v)?(I="ul-direct-embeded-frame",h=document.head,U=window,$=!1,R&&(Ve(w,a),b.id=I,window.UserLeap.container.appendChild(b),Be(),n.eventEmitter.emit(n.SprigEvent.SurveyLifeCycle,{state:"presented"}),n.eventEmitter.emit(n.SprigEvent.SurveyPresented,{name:n.SprigEvent.SurveyPresented,"survey.id":w}))):{frameId:I,contentWinDocHead:h,contentWindow:U,hasOverlay:$,iframe:b}=Et({productConfig:l,useMobileStyling:x,surveyId:w,isFeedback:a}),window.UserLeap.frameId=I;const it=f=>{n.eventEmitter.once(n.SprigEvent.CloseSurveyOnOverlayClick,f)},M={apiURL:window.UserLeap._API_URL,cards:u,configureExitOnOverlayClick:it,context:i,endCard:o,envId:window.UserLeap.envId,eventEmitFn:n.eventEmitter.emit.bind(n.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:r,frame:b,headers:v,locale:c,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:n.localStorageHelper.getItem("sprig.previewKey"),previewMode:p,productConfig:{framePosition:l==null?void 0:l.framePosition,desktopDisplay:l==null?void 0:l.desktopDisplay,placement:l==null?void 0:l.placement},responseGroupUid:y,startingQuestionIdx:(Ie=window.UserLeap.config)==null?void 0:Ie.startingQuestionIdx,studyType:q,styleNonce:window.UserLeap.styleNonce,surveyId:w,tabTitle:document.title,trackPageViewUrl:e,ulEvents:n.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:x,userId:m,viewDocument:U==null?void 0:U.document,viewWindow:U,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},...window.UserLeap._config};(ke=window.UserLeap._config)!=null&&ke.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const nt=(a?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??l.customStyles;M.customStyles=nt,U&&(U.__cfg=M);function ot(){const f=document.createElement("script");return window.UserLeap.nonce&&f.setAttribute("nonce",window.UserLeap.nonce),f.id=Ae,f}const ie=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:M.path,Le=document.getElementById(Ae);Le&&Le.remove();const ne=ot(),be=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(M.installationMethod==="web-npm"||M.installationMethod==="web-npm-bundled"){const{default:f}=await Promise.resolve().then(()=>require("./view-BXXr8-Xk.cjs"));f.configure(M),$&&window.UserLeap.container&&be()}else ie&&(ne.src=ie,$&&ne.addEventListener("load",()=>{window.UserLeap.container&&be()}),U==null||U.addEventListener("error",f=>{f.target instanceof HTMLScriptElement&&f.target.src===ie&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));h==null||h.appendChild(ne);const Ue={success:!0,surveyState:"ready",surveyId:w,responseGroupUid:y};return window.UserLeap.isMobileSDK&&s&&(Ue.delay=s),Ue};function fe(t){var i;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const e=((i=window.UserLeap.windowDimensions)==null?void 0:i.width)??document.body.clientWidth;return te(t)||e>10&&e<gt}function te(t){return ht.includes(t["userleap-platform"])}const ye="ul-frame";window.UserLeap&&window.Sprig&&(window.Sprig._gtm?window.Sprig=window.UserLeap:window.UserLeap=window.Sprig);window.UserLeap||(window.UserLeap=window.Sprig);window.Sprig||(window.Sprig=window.UserLeap);const St="rgba(255,255,255, 0.95)",Lt="rgba(0,0,0,0.9)",se="0px",Ve=(t,e,i)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container${e?" ul-container-feedback":""}`,t&&(window.UserLeap.container.dataset.studyId=t.toString());const s=je();i&&s&&!window.UserLeap.useMobileStyling?s.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ne=(t,e)=>{var s;kt();const i=window.UserLeap.container;if(i)try{(s=i.parentNode)==null||s.removeChild(i),window.UserLeap.container=null,S("trackStartUrl",null),n.eventEmitter.emit(n.SprigEvent.SurveyLifeCycle,{state:"dismissed"}),n.eventEmitter.emit(n.SprigEvent.SurveyClosed,{name:n.SprigEvent.SurveyClosed,initiator:t,"survey.id":parseInt(i.dataset.studyId),...e&&{studyType:e}})}catch(r){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} `+i),r instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",r)}},Be=()=>{n.eventEmitter.once(n.SprigEvent.SurveyWillClose,({initiator:t,studyType:e})=>{n.eventEmitter.removeAllListeners(n.SprigEvent.CloseSurveyOnOverlayClick),Ne(t,e)})},bt=(t,e)=>{const s={...{position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646}},r=e?t.overlayStyleMobile:t.overlayStyle;s["background-color"]=r==="light"?St:Lt,e||(s.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,s)},Ut=(t,e,i,s)=>{var l,u;const r={position:"fixed",bottom:"0px",right:se,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%"},o=Object.assign({},e,window.UserLeap),{desktopDisplay:a}=e||{},d=a==="center-modal";d&&(o.framePosition="center");let c,p=!1;if(i)(l=window.UserLeap.windowDimensions)!=null&&l.width?r.width=`${window.UserLeap.windowDimensions.width}px`:r.width="100%",(u=window.UserLeap.windowDimensions)!=null&&u.height?r.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`:window.UserLeap.maxHeight?r.maxHeight=window.UserLeap.maxHeight:r.maxHeight=`${document.body.clientHeight-20}px`,["light","dark"].includes(o.overlayStyleMobile)&&(p=!0);else{r.width=Me,r.maxHeight=window.UserLeap.maxHeight||"66vh";const y=()=>{p=!0,c={margin:"auto",position:"static"}};if(s)d?y():c={position:"relative",height:"300px"};else switch(o.framePosition){case"bottomLeft":c={left:se};break;case"topLeft":c={left:se,top:0};break;case"topRight":c={top:0};break;case"center":y();break}}return p&&bt(o,i),Object.assign(t.style,r,c),p},Et=({productConfig:t,useMobileStyling:e,surveyId:i,isFeedback:s})=>{var y,w;const r=ye,o=s&&t.desktopDisplay==="slider";Ve(i,s,o),It();const a=document.createElement("iframe");a.id=r,a.setAttribute("title","Sprig User Feedback Dialog");const d=Ut(a,t,e,s);Be();let c=!1;a.setHeight=m=>{(parseInt(a.style.height)!=m||!c)&&(c=!0,a.style.height=`${m}px`,n.eventEmitter.emit(n.SprigEvent.SurveyHeight,{name:n.SprigEvent.SurveyHeight,contentFrameHeight:m,"survey.id":i}))};let p=!1;a.setWidth=m=>{(parseInt(a.style.width)!=m||!p)&&(p=!0,a.style.width=`${m}px`,n.eventEmitter.emit(n.SprigEvent.SurveyWidth,{name:n.SprigEvent.SurveyWidth,contentFrameWidth:m,"survey.id":i}))},(y=window.UserLeap.container)==null||y.appendChild(a),t&&(e?t.exitOnOverlayClickMobile:t.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{n.eventEmitter.emit(n.SprigEvent.CloseSurveyOnOverlayClick)}),n.eventEmitter.emit(n.SprigEvent.SurveyLifeCycle,{state:"presented"}),n.eventEmitter.emit(n.SprigEvent.SurveyPresented,{name:n.SprigEvent.SurveyPresented,"survey.id":i});const l=(w=a.contentWindow)==null?void 0:w.document;if(l&&(l.open("text/html","replace"),l.write("<!doctype html><head></head><body></body></html>"),l.close(),!e)){const m=l.body;m.style.display="flex",m.style.alignItems="center"}const u=l==null?void 0:l.head;return{frameId:r,contentWinDocHead:u,contentWindow:a.contentWindow,hasOverlay:d,iframe:a}},We={[n.SprigEvent.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},It=()=>{Object.entries(We).forEach(([t,e])=>{n.eventEmitter.on(t,e)})},kt=()=>{Object.entries(We).forEach(([t,e])=>{n.eventEmitter.off(t,e)})},_t=1,De=t=>t instanceof HTMLElement||t instanceof SVGElement,z=({document:t,elementId:e,styleString:i,nonce:s})=>{const r=t.getElementById(e);if(r){r.textContent=i;return}const o=t.createElement("style");s&&(o.nonce=s),o.textContent=i,o.id=e,t.head.appendChild(o)},ze=t=>{const e=t.querySelector(".ul-card__container");let i=600,s=360;if(e){i=e.scrollHeight;const r=getComputedStyle(e),o=parseFloat(r.marginTop)+parseFloat(r.marginBottom),a=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth),d=parseFloat(r.paddingTop)+parseFloat(r.paddingBottom);i+=o+a+d;const c=e.querySelector(".ul-card--matrix_grid");s=c?c.scrollWidth:e.scrollWidth;const p=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),l=parseFloat(r.marginLeft)+parseFloat(r.marginRight),u=parseFloat(r.borderLeftWidth)+parseFloat(r.borderRightWidth);s+=l+u+p}return[i+_t,s]},Rt=t=>{const e=t.querySelector(".ul-card__container");e&&(e.scrollTop=0)},je=()=>g,H=()=>document.getElementById("sprig-feedback-container"),ve=()=>document.getElementById("sprig-feedback-loading-animation"),At=()=>{if(ve())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=`
2
+ <div class="ul-loading-spinner">
3
+ <div class="first"></div>
4
+ <div class="second"></div>
5
+ <div class="third"></div>
6
+ <div class="fourth"></div>
7
+ </div>
8
+ `,t},qe=()=>!!document.getElementById(ye);let Oe=!1,g=null,_=null,he=!1,W=null,P=null;const Dt=["bottom-left","bottom-right","center-left","center-right"],Ot=t=>{if(H()||!Dt.includes(t))return;const[e,i]=t.split("-"),s=document.createElement("div");s.id="sprig-feedback-container",s.classList.add(`sprig-feedback-container-${i}`,`sprig-feedback-container-${e}`),document.body.appendChild(s)},re=()=>{var e;const t=window.UserLeap.container;return((e=t==null?void 0:t.parentElement)==null?void 0:e.id)==="sprig-feedback-loading-container"},$e=()=>document.getElementById("sprig-feedback-error-container"),Ge=()=>{if(!g)return 0;const t=g==null?void 0:g.clientWidth,e=window.getComputedStyle(g),i=parseInt(e.borderRightWidth||"0"),s=parseInt(e.borderLeftWidth||"0");return t+i+s},J=t=>{const e=H();e&&(P!=null&&P.endsWith("right")?e.style.right=`${t}px`:P!=null&&P.endsWith("left")&&(e.style.left=`${t}px`))},ae=()=>{if(g&&(re()||$e())){n.eventEmitter.off(n.SprigEvent.SurveyAppeared,N),ce();const t=Ge();return J(-t),!0}return!1},N=()=>{if(!g||!_)return;const t=ve();t&&t.remove(),g.style.height="auto",g.style.width="auto",_.disabled=!1,he=!1},ce=()=>{if(!g)return;if(!ve()){const e=At();e&&(g.style.height="300px",g.style.width="360px",g.appendChild(e))}},xe=()=>{!g||!_||(J(0),_.disabled=!0,he=!0)},xt=async t=>{const e=await k(E("1",[D],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:t}),method:"POST"});return e.ok?e.json:null},Ke=async(t,e,i)=>{const{buttonTheme:s,customStyles:r,eventId:o,placement:a,desktopDisplay:d,feedbackLabel:c,surveyUuid:p,surveyId:l}=t;window.UserLeap.feedbackCustomStyles=void 0;let u=H();if(u){if(!e&&o===W)return;u.remove(),n.eventEmitter.off(n.EVENTS.SURVEY_FADING_OUT,ae)}W=o,z({document,elementId:"sprig-feedback-style",styleString:ct,nonce:window.UserLeap.styleNonce}),z({document,elementId:"ul-custom-style",styleString:r??"",nonce:window.UserLeap.styleNonce}),Oe=d==="center-modal",P=a;const[w,m]=a.split("-");Ot(a),u=H(),_=document.createElement("button");const L=document.createElement("div");L.className="sprig-feedback-button-label",L.innerText=c,_.appendChild(L),_.id="sprig-feedback-button",_.classList.add(`sprig-feedback-button-${m}`,`sprig-feedback-button-${w}`,`sprig-feedback-button-${s}`,"fade-in-transition"),n.eventEmitter.on(n.EVENTS.SURVEY_FADING_OUT,ae),_.addEventListener("click",async()=>{const v=document.getElementById("sprig-feedback-error-container");if(qe()||$e()){if(ae()){n.eventEmitter.emit(n.SprigEvent.SurveyWillClose,{name:n.SprigEvent.SurveyWillClose,initiator:n.DismissReason.FeedbackClosed,studyType:"feedbackButton","survey.id":l});const b=H();v&&b&&(b.remove(),W=null,g=null)}return}const R=n.getHttpHeaders(window.UserLeap);if(!fe(R)&&!he&&xe(),e){g&&g.classList.add("sprig-feedback-loading-container-previews"),await B(e),N();return}const I=await xt(p);if(I)n.eventEmitter.once(n.SprigEvent.SurveyAppeared,N),B({...I,studyType:"feedbackButton"},i);else if(g){const b=Tt();g.appendChild(b),N(),g.style.height="300px",g.style.width="360px"}}),u==null||u.appendChild(_),n.eventEmitter.emit(n.SprigEvent.FeedbackButtonLoaded,{name:n.SprigEvent.FeedbackButtonLoaded,"survey.id":l});const{useMobileStyling:A,_config:{border:q}}=window.UserLeap;if(!Oe&&!A){const v=document.createElement("div");v.id="sprig-feedback-loading-container",v.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${m}`,v.style.setProperty("--feedback-border",q),g=v,ce(),u==null||u.appendChild(v);const R=Ge();J(-R)}else J(0);window.UserLeap._config.isOnQuestionsTab&&e&&!re()&&g&&(xe(),ce(),g&&g.classList.add("sprig-feedback-loading-container-previews"),B(e),N())},Pt=()=>{if(re())return;const t=H();if(!t)return;n.checkUrlStillMatching(W)||(t.remove(),W=null,g=null)},Tt=()=>{const t=document.createElement("div");t.id="sprig-feedback-error-container",t.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
9
+ <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
10
+ <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
11
+ <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
12
+ </svg>`;const e=document.createElement("h3");return e.className="sprig-feedback-error-text",e.innerText="There was an error while loading the survey",t.appendChild(e),t},Ct="!launch_darkly_";class Mt{constructor(){F(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(e){try{return!e||typeof e!="object"||Array.isArray(e)?!1:(Object.keys(this._ldData).forEach(i=>{delete this._ldData[i]}),Object.keys(e).forEach(i=>this._ldData[`${Ct}${i}`]=(e[i]??0)+1),!0)}catch(i){return i instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",i),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const pe=new Mt;Object.freeze(pe);const Ft="!optimizely_experiments_";class Ht{constructor(){F(this,"_optimizelyData",{})}setOptimizelyExperiment(e,i=!0){if(!e||typeof e!="object")return!1;const{experiments:s}=e;try{return i&&Object.keys(this._optimizelyData).map(r=>{delete this._optimizelyData[r]}),s&&s.map(r=>{const{id:o,variation:a}=r,d=this.transformExperimentId(o);a&&typeof a=="string"&&(this._optimizelyData[d]=a)}),!0}catch(r){return r instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",r),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(e){return this._optimizelyData[this.transformExperimentId(e)]}transformExperimentId(e){return Ft+e}getAndSetWebOptimizelyExperiments(){var e;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const i=(e=window.optimizely.get("state"))==null?void 0:e.getExperimentStates({isActive:!0});if(i){const s=Object.keys(i).map(r=>{var o,a;return(o=i[r].variation)!=null&&o.name?{id:r,variation:(a=i[r].variation)==null?void 0:a.name}:{id:r,variation:"Original"}});return this.setOptimizelyExperiment({experiments:s},!1),!0}return!1}return!1}catch(i){return i instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",i),!1}}}const K=new Ht;Object.freeze(K);class Vt{constructor(e,i){F(this,"paused");F(this,"queue");F(this,"ul");this.ul=e,this.paused=!1,this.queue=[],this.flush(i)}flush(e){const i=e.length;if(i)for(let s=0;s<i;s++)this.push(e[s])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const e=this.queue.slice();this.empty(),this.flush(e)}push(e){if(this.paused)this.queue.push(e);else if(e instanceof Function)e();else{const i=Array.prototype.slice.call(e,1),s=e[0],r=this.ul[s];r instanceof Function?r.apply(this.ul,i):s&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",s)}}perform(e){if(this.paused){let i=()=>{};const s=new Promise(function(r){i=function(){r(e())}});return this.queue.push(i),s}else return e()}empty(){this.queue.length=0}}let Je,Qe;const ue=t=>{let e=0,i=t.firstElementChild;for(;i;)e+=ue(i),i.shadowRoot&&(e+=ue(i.shadowRoot)),i=i.nextElementSibling,e++;return e},Nt=()=>document.documentElement.innerHTML.length,Pe=()=>{Je.report(ue(document.body)),Qe.report(Nt())},Bt=(t=10*1e3)=>{Je=n.registerMetric("sdk_dom_nodes_count"),Qe=n.registerMetric("sdk_page_html_characters"),Pe(),setInterval(Pe,t)},we=(t,e)=>{const i=performance.now();document.hidden?setTimeout(()=>we(t,e),t):setTimeout(()=>{const s=performance.now()-i;e.report(s/1e3),setTimeout(()=>we(t,e),t)},0)},Wt=(t=1e3)=>{const e=n.registerMetric("sdk_event_queue_latency_seconds");we(t,e)};let Q,Y,X,Z,C={},Te;const G=(t,e=1)=>{const{name:i}=t;C[i]=(C[i]||0)+e},Ye=t=>{let e=1;return t.childNodes.forEach(i=>{e+=Ye(i)}),e},Ce=t=>{let e=0;return t.forEach(i=>{e+=Ye(i)}),e},zt=t=>{switch(t.type){case"childList":G(Q,Ce(t.addedNodes)),G(Y,Ce(t.removedNodes));return;case"attributes":G(X);return;case"characterData":G(Z);return}},jt=t=>t.forEach(zt),qt=()=>{Te=new MutationObserver(jt),Te.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},$t=()=>{Q.report(C[Q.name]||0),Y.report(C[Y.name]||0),X.report(C[X.name]||0),Z.report(C[Z.name]||0),C={}},Gt=(t=1*1e3)=>{Q=n.registerMetric("sdk_mutations_nodes_added"),Y=n.registerMetric("sdk_mutations_nodes_removed"),X=n.registerMetric("sdk_mutations_attributes_changed"),Z=n.registerMetric("sdk_mutations_character_data"),qt(),setInterval($t,t)},Kt=({isWeb:t,reportingIntervalSeconds:e,thresholds:i,postMetrics:s})=>{n.registerThresholds(i,(r,o)=>{var a,d;if((a=n.modules.replay)!=null&&a.isReplayRecording()){const c=`Value: ${r} on ${o.metric} violated threshold of ${o.type} ${o.value}`;(d=n.modules.replay)==null||d.disableRecording("Threshold violated",new Error(c),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:o.metric,type:o.type,value:o.value},{metricName:o.metric}),n.disableThresholdChecking()}}),n.initPerformanceReporting({reportingIntervalSeconds:e,postMetrics:s}),t&&(Wt(),Bt(),Gt())},Jt={test:"test"},Qt=["popState","pushState","replaceState"],V="!email",Xe="pageUrl";function Yt(t,e){const{pageUrlEvents:i,interactiveEvents:s,dismissOnPageChange:r}=window.UserLeap._config;if(!r)return!0;const o=[];i&&i.length&&o.push(...i),s&&s.length&&o.push(...s);const a=t&&o.find(d=>d.id===t);return a?n.checkUrlMatch(a,window.location.href):e===window.location.href}let de=window.location.href;function j(t){var d;const{pageUrlEvents:e,interactiveEvents:i,dismissOnPageChange:s,platform:r}=window.UserLeap._config;if(r&&r!=="web")return;de!==window.location.href&&n.breadcrumbsLogger.navigation("LocationChange",{from:de,to:window.location.href}),de=window.location.href;const o=T("trackStartUrl"),a=o?String(o):null;e&&rt(window.location.href),i&&(et(),Xt()),je()&&Pt(),n.sessionStorageHelper.getItem("sprig.isCapturingHeatmap")&&((d=n.modules.replay)==null||d.checkPendingHeatmapsUrl()),!re()&&s&&a&&a!==window.location.href&&t&&Qt.includes(t.type)&&window.UserLeap("dismissActiveSurvey",n.DismissReason.PageChange)}const Ze={capture:!0},Xt=()=>{const e=window.UserLeap._config.interactiveEvents.filter(s=>n.checkUrlMatch(s,window.location.href)).map(s=>{const{name:r,properties:o}=s,{selector:a,innerText:d}=o;return a?c=>{if(De(c.target))try{c.target.closest(a)&&window.UserLeap("track",r)}catch{}return!1}:c=>(De(c.target)&&c.target.innerText===d&&window.UserLeap("track",r),!1)}),i=s=>e.forEach(r=>r(s));window.UserLeap._config.interactiveEventsHandler=i,window.addEventListener("click",i,Ze)},et=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,Ze),delete window.UserLeap._config.interactiveEventsHandler};function Zt(){["hashchange","popstate"].forEach(t=>window.addEventListener(t,j,!0))}function er(){["hashchange","popstate"].forEach(t=>window.removeEventListener(t,j,!0)),window.UserLeap._config.interactiveEvents&&et()}function tr(t){const e=new URL(E("1",[O],"questions"));return Object.entries(t||{}).forEach(([i,s])=>{s&&e.searchParams.append(i,String(s))}),e.toString()}function T(t){const e=n.localStorageHelper.getItem("userleap.ids");if(e)try{const s=JSON.parse(e)[window.UserLeap.envId];return s&&s[t]||null}catch(i){i instanceof Error&&(i.stack=e,window.UserLeap.reportError("Failed to parse local storage credentials",i))}return null}function tt(){window.previewMode||(window.UserLeap.visitorId=n.v4(),n.breadcrumbsLogger.info("NewVid",{vid:window.UserLeap.visitorId}),S("vid",window.UserLeap.visitorId),n.eventEmitter.emit(n.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function rt(t,e,i,s){var r,o;try{if(t.endsWith("mock_snippet.html"))return;n.breadcrumbsLogger.info("PageView",{url:t});const a=window.UserLeap._config.pageUrlEvents;let d=!1;if(a&&a.length)for(let l=0;l<a.length&&(d=n.checkUrlMatch(a[l],t),!d);l++);if(!d)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const c={url:t};s&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",Xe,e,c,i]);const p=(r=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(o=n.modules.replay)==null||o.RecordPageView({...p&&{description:p},url:t,referrer:document.referrer,pageTitle:document.title})}catch(a){a instanceof Error&&(a.stack=t,window.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function rr(){const t="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in t&&(t.pushState=(e=>function(...s){const r=e.apply(this,s),o=new Event("pushState");return window.dispatchEvent(o),j(o),r})(t.pushState)),"replaceState"in t&&(t.replaceState=(e=>function(...s){const r=e.apply(this,s),o=new Event("replaceState");return window.dispatchEvent(o),j(o),r})(t.replaceState)),Zt()}async function le(t,e){const i=me();t&&!e&&(window.UserLeap._config.mode=Jt.test);const s=n.getHttpHeaders(window.UserLeap),r=fe(s),o=await k(tr({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:r,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:t==null?void 0:t.surveyId,surveytemplateid:t==null?void 0:t.surveyTemplateId,vid:i}),{shouldDropOnRateLimit:!0});if(!o.ok)return o.reportError&&o.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",o.error),window.UserLeap.reportError("getQuestions",o.error)),{success:!1,surveyState:"no survey"};if(o.json.delay&&await n.delay(o.json.delay),o.json.isFeedback){const{feedbackLabel:a,productConfig:d,surveyUuid:c,feedbackCustomStyles:p}=o.json,{buttonTheme:l,placement:u,desktopDisplay:y}=d,w={customStyles:p,buttonTheme:l,desktopDisplay:y,eventId:0,feedbackLabel:a,placement:u,surveyUuid:c,surveyId:t==null?void 0:t.surveyId};Ke(w,o.json)}else return B(o.json)}function ir(t){let e=t.length;for(;e;){const i=Math.floor(Math.random()*e);e-=1;const s=t[e];t[e]=t[i],t[i]=s}}function nr(t){if(!t)return;window.UserLeap._config=t,t.mute&&window.UserLeap._queue.pause();const{interactiveEvents:e,pageUrlEvents:i,dismissOnPageChange:s}=t;e&&ir(e),(e||i||s)&&(rr(),j())}async function or(t,e){var s,r;let i=!0;return e&&((s=t==null?void 0:t.json)!=null&&s.surveyId)&&(window.UserLeap.delayingSurvey=!0,i=await e(t.json.surveyId),window.UserLeap.delayingSurvey=!1,!i)?!1:((r=t==null?void 0:t.json)!=null&&r.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await n.delay(t.json.delay),window.UserLeap.delayingSurvey=!1),i)}const sr=function(t){if(!window.UserLeap)return;const e=async(r={})=>{var v,R,x,I,b;const{userId:o,anonymousId:a,metadata:d={},properties:c,showSurveyCallback:p}=r;let{eventName:l}=r;if(window.UserLeap.debugMode&&l!==Xe&&console.info("[DEBUG] Sprig track",r),t.mode==="test")return;const u=n.localStorageHelper.getItem("sprig.previewKey")??void 0;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!o){const h="[Sprig] - Skipping tracking without userId";return console.warn(h),{success:!1,message:h,surveyState:"no survey"}}if(!l||l.trim().length===0){l=l?String(l):"";const h="[Sprig] - Invalid event name "+l;return console.warn(h),{success:!1,message:h,surveyState:"no survey"}}const y=window.location.href;if(d.url||(d.url=y),S("trackStartUrl",y),(R=(v=window.UserLeap)==null?void 0:v._config)!=null&&R.optimizelyEnabled){const h=n.getHttpHeaders(window.UserLeap);te(h)||K.getAndSetWebOptimizelyExperiments(),d.optimizelyExperiments=Object.assign({},K.getAllOptimizelyExperiments())}(I=(x=window.UserLeap)==null?void 0:x._config)!=null&&I.launchDarklyEnabled&&(d.launchDarklyFlags=pe.getAllLaunchDarklyVariations()),o&&(window.UserLeap.userId=o),a&&(window.UserLeap.partnerAnonymousId=a),c&&(d.eventProperties=c),(b=n.modules.replay)==null||b.RecordEvent({name:l,url:d.url}),n.breadcrumbsLogger.info("TrackEvent",{eventName:l});const w=window.UserLeap.delayingSurvey||qe()?await k(E("1",[D],"events/batch"),{body:JSON.stringify({events:[{event:l,metadata:d}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await k(E("1",[D],"events"),{body:JSON.stringify({event:l,metadata:d,previewKey:u}),method:"POST",shouldDropOnRateLimit:!0});if(!w.ok){const h="[Sprig] (ERR-421) Failed to track event";return w.reportError&&(console.warn(h,w.error),w.error&&window.UserLeap.reportError("track",w.error)),{success:!1,message:h,error:w.error,surveyState:"no survey"}}o&&S("uid",o),a&&S("aid",a);const m=w.json;m.invalidPreviewKey&&n.localStorageHelper.removeItem("sprig.previewKey");const L=d.trackPageView?d.url:void 0;return!!(m!=null&&m.feedbackButton)&&Ke(m.feedbackButton,void 0,L),await or(w,p)?Yt(m.eventId,y)?B(m,L):{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"}},i=(r,o)=>{var d;const a=(d=r==null?void 0:r.querySelector(`[id="${ye}"]`))==null?void 0:d.contentDocument;a&&z({document:a,elementId:"ul-custom-style",styleString:o})},s={async displaySurvey(r){return console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",n.DismissReason.Override),le({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",n.DismissReason.Override),le({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",n.DismissReason.Override),le({surveyId:r},!1)},previewSurvey(r){s._previewSurvey(r)},reviewSurvey(r){s._reviewSurvey(r)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(r=n.DismissReason.API){window.UserLeap.container&&n.eventEmitter.emit(n.SprigEvent.SurveyWillClose,{name:n.SprigEvent.SurveyWillClose,initiator:r,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)})},async setAttribute(r,o){if(!r||!o&&o!==0&&o!==!1){const a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}return this.setAttributes({[r]:o})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const o="[Sprig] - Disregarding empty attributes provided";return console.warn(o),{success:!1,message:o}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),t.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const l="[Sprig] - Disregarding empty payload provided";return console.warn(l),{success:!1,message:l}}const{userId:o,anonymousId:a,attributes:d}=r;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!o){const l="[Sprig] - Skipping tracking without userId";return console.warn(l),{success:!1,message:l}}if(!d&&(!o||window.UserLeap.userId===o)&&(!a||window.UserLeap.partnerAnonymousId===a))return{success:!0};const c={};o&&(c.userId=window.UserLeap.userId=o),a&&(c.partnerAnonymousId=window.UserLeap.partnerAnonymousId=a);let p;return d?(d.email&&!Object.prototype.hasOwnProperty.call(d,V)&&(d[V]=d.email,delete d.email),p=await k(E("1",[O,D],"attributes"),{body:JSON.stringify(d),method:"PUT"}),!p.ok&&p.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",p.error),p.error&&window.UserLeap.reportError("identifyAndSetAttributes",p.error))):p=await k(E("1",[O,D]),{body:JSON.stringify(c),method:"PUT"}),d&&d[V]&&(window.UserLeap.email=d[V]),p.ok&&(o&&S("uid",o),a&&S("aid",a)),{success:!!p.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),t.mode==="test")return;if(r==null||r.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(t.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const o=await k(E("1",[O,D],"attributes"),{body:JSON.stringify({delete:r}),method:"DELETE"});return!o.ok&&o.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",o.error),o.error&&window.UserLeap.reportError("removeAttributes",o.error)),{success:!!o.ok}},async addSurveyListener(r){n.eventEmitter.on(n.SprigEvent.SurveyLifeCycle,r)},async removeSurveyListener(r){n.eventEmitter.removeListener(n.SprigEvent.SurveyLifeCycle,r)},async addListener(r,o){n.eventEmitter.on(r,o)},async removeListener(r,o){n.eventEmitter.removeListener(r,o)},async removeAllListeners(){n.eventEmitter.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||n.localStorageHelper.isStorageAvailable&&r&&n.localStorageHelper.setItem("sprig.previewKey",r)},async setUserId(r){var d;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",r),r==null){const c=`[Sprig] - Invalid userId ${r}`;return console.warn(c),{success:!1,message:c}}if(t.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const o=window.UserLeap.visitorId,a=await k(E("1",[O,D]),{body:JSON.stringify({userId:r}),method:"PUT"});if(!a.ok){a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.error));return}o!==window.UserLeap.visitorId&&((d=n.modules.replay)==null||d.clearUserReplayData()),S("uid",r)},async setPartnerAnonymousId(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",r),r==null){const o=`[Sprig] - Invalid partnerAnonymousId ${r}`;return console.warn(o),{success:!1,message:o}}return window.UserLeap.partnerAnonymousId=r,S("aid",r),{success:!0}},async track(r,o,a={},d=void 0){return e({eventName:r,properties:o,metadata:a,showSurveyCallback:d})},async identifyAndTrack(r){return await e(r)},trackPageView(r,o=void 0,a=void 0,d=!0){rt(r,o,a,d)},applyFeedbackStyles({button:r="",view:o=""}){window.UserLeap.feedbackCustomStyles=o,document.getElementById("sprig-feedback-style")&&z({document,elementId:"ul-custom-style",styleString:r,nonce:window.UserLeap.styleNonce}),i(document.querySelector(".ul-container-feedback"),o)},applyStyles(r){window.UserLeap.customStyles=r,i(window.UserLeap.container,r)},setWindowDimensions(r,o){var p,l;const a=typeof r=="string"?parseInt(r,10):r,d=typeof o=="string"?parseInt(o,10):o;if(!isNaN(a)&&!isNaN(d)&&(window.UserLeap.windowDimensions={width:a,height:d}),!window.UserLeap.frameId)return;const c=document.getElementById(window.UserLeap.frameId);c&&(window.UserLeap.useMobileStyling&&((p=window.UserLeap.windowDimensions)!=null&&p.width&&(c.style.width=`${window.UserLeap.windowDimensions.width}px`),(l=window.UserLeap.windowDimensions)!=null&&l.height&&(c.style.maxHeight=`${window.UserLeap.windowDimensions.height-20}px`),c.contentDocument&&(c.style.height=String(ze(c.contentDocument)[0])+"px")),n.eventEmitter.emit(n.SprigEvent.SurveyDimensions,{name:n.SprigEvent.SurveyDimensions,contentFrameWidth:c.clientWidth,contentFrameHeight:c.clientHeight,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},logoutUser(){var r;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),n.breadcrumbsLogger.info("LogOut",{vid:window.UserLeap.visitorId,userId:window.UserLeap.userId}),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,n.localStorageHelper.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),tt(),(r=n.modules.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){er(),window.UserLeap("dismissActiveSurvey",n.DismissReason.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(r,o=!0){var a,d;if(!((d=(a=window.UserLeap)==null?void 0:a._config)!=null&&d.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}try{const c=typeof r=="string"?JSON.parse(r):r;K.setOptimizelyExperiment(c,o)}catch(c){console.warn("[Sprig] Error with integrating Optimizely data"),c instanceof Error&&window.UserLeap.reportError("integrateOptimizely",c)}},integrateOptimizelyClient(r){var a,d;if(!((d=(a=window.UserLeap)==null?void 0:a._config)!=null&&d.optimizelyEnabled)){console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");return}const o=({experiment:c,variation:p})=>{const l={experiments:[{id:c.id,variation:p.key}]};window.UserLeap("integrateOptimizely",l,!1)};r.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",o)},importLaunchDarklyData(r){var o,a;if(!((a=(o=window.UserLeap)==null?void 0:o._config)!=null&&a.launchDarklyEnabled)){console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.");return}pe.setLDFlagsVariations(r)},setVisitorAttribute(r,o){return console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),s.setAttribute(r,o)},async setEmail(r){return s.setAttribute(V,r)},async setVisitorEmail(r){return console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),s.setEmail(r)},async _generateVideoUploadUrl(r){return lr(r)},_reportMetric(r,o){n.reportAndRegister(r,o)},async _completeSessionReplay({surveyId:r,responseGroupUuid:o,eventDigest:a}){var d;return n.modules.replay?(d=n.modules.replay)==null?void 0:d._completeSessionReplay({surveyId:r,responseGroupUuid:o,eventDigest:a,headers:n.getHttpHeaders(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,s)};async function ar(t){const e=n.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",n.cspViolationHandler);const i=await n.sprigFetch(E("1",[O],"config"),{headers:e});if(document.removeEventListener("securitypolicyviolation",n.cspViolationHandler),!i.ok)return i.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",i.error),i.error&&window.UserLeap.reportError("applyRemoteConfig",i.error)),n.killNetworkRequests("Disabled: failed to fetch configuration"),t;const s=i.json;return s!=null&&s.disabled?(n.killNetworkRequests(`Disabled: ${s.disabled}`),{disabled:s.disabled}):Object.assign({},s,t)}async function dr(t,e,i={},s={}){const r=window.__cfg&&window.__cfg.mode,o=me(),a=window.UserLeap.envId,d=window.document.documentElement,c={mode:r,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:window.navigator.language,...i},p={action:t,breadcrumbs:n.breadcrumbsLogger.breadcrumbs,err:{message:`${e==null?void 0:e.name} - ${e==null?void 0:e.message}`,stack:e==null?void 0:e.stack},meta:c,vid:o,envId:a,...s};(await k(E("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(p),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",e)}async function lr(t){var i;if(!t)return;const e=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const s=await fetch(e,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(s.ok){const r=await s.json();return(i=r==null?void 0:r.upload)==null?void 0:i.url}else return null}catch(s){console.warn("[Sprig] Error with generating video upload url"),s instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",s)}}function cr(t={}){const e=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=n.EVENTS,window.UserLeap("setPreviewKey",e);async function i(){var p;if(window.UserLeap.loaded)return;if(window.UserLeap.reportError=dr,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},t,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const l in window.UserLeap._config)window.UserLeap[l]=window.UserLeap._config[l];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const s=window.UserLeap.sampleRate;if(s){let l=T("sampled");if(l===null&&(l=Math.random()<s,S("sampled",l)),!l)return}else T("sampled")!==null&&S("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const r=[...window.UserLeap._queue];window.UserLeap._queue=new Vt(window.UserLeap,[]),window.UserLeap._queue.pause();for(let l=0;l<r.length;l++)window.UserLeap._queue.push(r[l]);const o=T("token");o?(window.UserLeap.token=o,window.UserLeap.visitorId=T("vid"),window.UserLeap.userId=T("uid"),window.UserLeap.partnerAnonymousId=T("aid")):(n.localStorageHelper.removeItem("userleap.ids"),tt());const a=n.getHttpHeaders(window.UserLeap),d=te(a),c=await ar(t);Kt({isWeb:!d,reportingIntervalSeconds:c.metricsReportingEnabled||c.mobileMetricsReportingEnabled?c.metricsReportingIntervalSeconds:0,thresholds:c.metricThresholds,postMetrics:async l=>{var u;await k(E("1",[O],"metrics"),{body:l,method:"POST",headers:{"x-ul-replay-enabled":`${!!((u=n.modules.replay)!=null&&u.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),await((p=n.modules.replay)==null?void 0:p.initializeReplay({maxReplayDurationSeconds:c.maxReplayDurationSeconds,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:c.replaySettings})),sr(c),await nr(c),window.UserLeap._queue.unpause(),n.eventEmitter.emit(n.SprigEvent.SDKReady,{mobileMetricsReportingEnabled:!!c.mobileMetricsReportingEnabled,metricsReportingInterval:c.metricsReportingIntervalSeconds||0,metricsThresholds:c.metricThresholds||[],maxMobileReplayDurationSeconds:c.maxMobileReplayDurationSeconds,mobileReplaySettings:c.mobileReplaySettings}),n.eventEmitter.emit(n.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?i():window.attachEvent?window.attachEvent("onload",i):window.addEventListener("load",()=>{i()},!1)}class ee{constructor(){this.UPDATES=n.EVENTS}displaySurvey(e){window.Sprig("displaySurvey",e)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(e,i){window.Sprig("setAttribute",e,i)}setAttributes(e){window.Sprig("setAttributes",e)}identifyAndSetAttributes(e){window.Sprig("identifyAndSetAttributes",e)}removeAttributes(e){window.Sprig("removeAttributes",e)}addListener(e,i){window.Sprig("addListener",e,i)}removeListener(e,i){window.Sprig("removeListener",e,i)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(e){window.Sprig("setAttribute","!email",e)}setUserId(e){window.Sprig("setUserId",e)}setPartnerAnonymousId(e){window.Sprig("setPartnerAnonymousId",e)}track(e,i={},s={}){window.Sprig("track",e,i,s)}identifyAndTrack(e){window.Sprig("identifyAndTrack",e)}trackPageView(e,i,s){window.Sprig("trackPageView",e,i,s)}applyStyles(e){window.Sprig("applyStyles",e)}setWindowDimensions(e,i){window.Sprig("setWindowDimensions",e,i)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const ge={configure:t=>{if(!t.envId&&!t.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(t.envId||(t.envId=t.environmentId??""),t.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(ee.prototype).map(i=>{i!=="constructor"&&(window.Sprig[i]=ee.prototype[i])});const e=window.Sprig;return e.appId=t.envId,e._queue=[],window.UserLeap=e,cr(t),window.Sprig}},pr={sprig:ge,SprigAPI:ee,configure:ge.configure};exports.APP_ID=pt;exports.ConflictingWidgets=He;exports.DEFAULT_BORDER_COLOR=ut;exports.DEFAULT_WIDTH=Me;exports.EMBED_MOBILE_MAX_WIDTH=mt;exports.ERROR_BORDER_COLOR=wt;exports.SprigAPI=ee;exports.calculateFrameDimensions=ze;exports.core=pr;exports.resetScrollPosition=Rt;exports.setSurveyStyles=z;exports.sprig=ge;
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./metricsReporter-BJNGF-rH.cjs"),e=require("./core-CwmkDlxK.cjs");exports.DismissReason=r.DismissReason;exports.SprigEvent=r.SprigEvent;exports.SprigAPI=e.SprigAPI;exports.default=e.core;exports.sprig=e.sprig;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./metricsReporter-Bv4AKHDN.cjs"),e=require("./core-D5rViL33.cjs");exports.DismissReason=r.DismissReason;exports.SprigEvent=r.SprigEvent;exports.SprigAPI=e.SprigAPI;exports.default=e.core;exports.sprig=e.sprig;