@sprig-technologies/sprig-browser 2.31.2 → 2.31.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core-DlBGQngD.js +12 -0
- package/dist/core-uZksLjLE.cjs +12 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +13 -19
- package/dist/core.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +13 -19
- package/dist/index.js +1 -1
- package/dist/{metricsReporter-D-m62w_D.js → metricsReporter-5CQW74cF.js} +1 -1
- package/dist/{metricsReporter-DaSVYNOK.cjs → metricsReporter-D-24kpOB.cjs} +1 -1
- package/dist/replay.cjs +1 -1
- package/dist/replay.js +1 -1
- package/dist/{view-D4GRlCAk.cjs → view-BDFXZqzu.cjs} +6 -6
- package/dist/{view-B4bFr3nV.js → view-Bn47QoHP.js} +3 -3
- package/package.json +1 -1
- package/dist/core-CZcCXjci.js +0 -12
- package/dist/core-D0ATZnzx.cjs +0 -12
package/dist/core-CZcCXjci.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
var Lt=Object.defineProperty,Ut=(e,t,n)=>t in e?Lt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t,n)=>(Ut(e,typeof t!="symbol"?t+"":t,n),n);import{h as C,s as Fe,d as u,S as w,l as R,i as _,v as Me,m as U,j as St,E as $,D as M,c as kt,r as j,k as It,n as Et,o as _t,p as xt,q as je,t as Ne,u as Rt,a as At,x as ye,b as Dt,y as ze}from"./metricsReporter-D-m62w_D.js";const Ot='.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}',We="360px",Pt="ul-app",Ct="#e6e6e6",Tt="#bd282a",Ft=500,Mt=1030,Be=()=>{try{return window.parent.Intercom}catch{return null}},jt=()=>{const e=Be();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)},Nt=()=>{const e=Be();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},zt=Object.freeze(Object.defineProperty({__proto__:null,disable:Nt,enable:jt},Symbol.toStringTag,{value:"Module"})),qe=[zt];class $e{static disable(){qe.forEach(t=>t.disable())}static enable(){qe.forEach(t=>t.enable())}}const Ve="ul-view-sdk-script",Wt=["ios","android"],T="visitors",F="environments";async function A(e,t){var n,o,r;const{shouldDropOnRateLimit:i,...s}=t;s.headers=Object.assign(C(window.UserLeap),s.headers);const a=await Fe(e,{...s,shouldDropOnRateLimit:i});if(a.ok){const c=(n=a.headers)==null?void 0:n.get("Authorization"),l=c?c.split(" "):void 0,d=l&&l.length===2?l[1]:void 0,p=(o=a.headers)==null?void 0:o.get("x-ul-visitor-id");d&&p&&(p!==window.UserLeap.visitorId||window.UserLeap.token!==d)&&(E("token",d),E("vid",p),u.emit(w.VisitorIDUpdated,{visitorId:p}),window.UserLeap.token=d,window.UserLeap.visitorId=p)}return(r=a.json)!=null&&r.logMessage&&console.warn(`[Sprig] ${a.json.logMessage}`),a}function E(e,t){const n=R.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[e]=t:r={[e]:t},o[window.UserLeap.envId]=r;try{R.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 x(e,t,n){const o=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(r=>{o.push(r),r===F?o.push(window.UserLeap.envId):r===T&&o.push(ve())}),n&&o.push(n),o.join("/")}const V=async(e,t)=>{var n,o,r;const{context:i,delay:s,forceBrandedLogo:a,endCard:c,isFeedback:l=!1,heatmap:d,locale:p,previewMode:g,productConfig:v,questions:m,responseGroupUid:h,surveyId:S,uuid:I,vid:b,sessionReplay:k,studyType:O}=e,L=C(window.UserLeap),Ae=re(L),ue=fe(L);if(_(`Attempting to display survey: ${S}`),k)if(_("Survey has replay attached"),Ae)u.emit(w.ReplayCapture,{responseGroupUid:h,hasQuestions:!!(m!=null&&m.length),surveyId:S,uploadId:k.uploadId,replayType:k.replayDurationType??"before",seconds:k.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:Me(),mediaType:"screen",questionId:1,responseGroupUid:h,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:h,surveyId:S,visitorId:b,replayParams:k,completeUploadHeaders:L,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:m.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:f,replayParams:me,responseGroupUid:ht,surveyId:bt}=d;await U.replay.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:300,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),U.replay.tryReplayAction(()=>{var Te;return(Te=U.replay)==null?void 0:Te.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:L,eventId:f,isHeatmap:!0,replayParams:me,responseGroupId:ht,surveyId:bt,triggerTimestamp:Date.now(),visitorId:b})},"Error in scheduling/capturing replay")}if(b==null||!(m!=null&&m.length))return _(`Not displaying survey: vid: ${b} / questions: ${m}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){_("Already displaying a survey");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(b!==window.UserLeap.visitorId&&I!==window.UserLeap.visitorId&&!window.previewMode){const f="Attempted to display survey to a different visitor";return _(f),window.UserLeap.reportError("DisplaySurvey",new Error(f)),{success:!1,message:f,surveyState:"no survey"}}_(`Showing survey: ${S}`),(n=U.replay)==null||n.RecordSurveyShown({id:S,userAgent:window.navigator.userAgent}),$e.disable(),u.emit(w.SurveyWillPresent,{name:w.SurveyWillPresent,"survey.id":S});let X,Z=document.createElement("div"),ee,P,te;const De=f=>{const{"view.version":me}=f;me!==L["x-ul-sdk-version"]&&Ge(),u.removeListener("verify.view.version",De)};u.on("verify.view.version",De),window.UserLeap.useMobileStyling=ue,St(L)?(X="ul-direct-embeded-frame",ee=document.head,P=window,te=!1,Ae&&(He(l),Z.id=X,window.UserLeap.container.appendChild(Z),Ke(),u.emit(w.SurveyLifeCycle,{state:"presented"}),u.emit(w.SurveyPresented,{name:w.SurveyPresented,"survey.id":S}))):{frameId:X,contentWinDocHead:ee,contentWindow:P,hasOverlay:te,iframe:Z}=Ht({productConfig:v,useMobileStyling:ue,surveyId:S,isFeedback:l}),window.UserLeap.frameId=X;const yt=f=>{u.once(w.CloseSurveyOnOverlayClick,f)},W={apiURL:window.UserLeap._API_URL,cards:m,configureExitOnOverlayClick:yt,context:i,endCard:c,envId:window.UserLeap.envId,eventEmitFn:u.emit.bind(u),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:a,frame:Z,headers:L,locale:p,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:R.getItem("sprig.previewKey"),previewMode:g,productConfig:{framePosition:v?.framePosition,desktopDisplay:v?.desktopDisplay,placement:v?.placement},responseGroupUid:h,startingQuestionIdx:(o=window.UserLeap.config)==null?void 0:o.startingQuestionIdx,studyType:O,styleNonce:window.UserLeap.styleNonce,surveyId:S,tabTitle:document.title,trackPageViewUrl:t,ulEvents:$,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:ue,userId:I,viewDocument:P?.document,viewWindow:P,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 vt=(l?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??v.customStyles;W.customStyles=vt,P&&(P.__cfg=W);function ft(){const f=document.createElement("script");return window.UserLeap.nonce&&f.setAttribute("nonce",window.UserLeap.nonce),f.id=Ve,f}const we=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:W.path,Oe=document.getElementById(Ve);Oe&&Oe.remove();const ge=ft(),Pe=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(W.installationMethod==="web-npm"||W.installationMethod==="web-npm-bundled"){const{default:f}=await import("./view-B4bFr3nV.js");f.configure(W),te&&window.UserLeap.container&&Pe()}else we&&(ge.src=we,te&&ge.addEventListener("load",()=>{window.UserLeap.container&&Pe()}),P?.addEventListener("error",f=>{f.target instanceof HTMLScriptElement&&f.target.src===we&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));ee?.appendChild(ge);const Ce={success:!0,surveyState:"ready",surveyId:S,responseGroupUid:h};return window.UserLeap.isMobileSDK&&s&&(Ce.delay=s),Ce};function fe(e){var t;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const n=((t=window.UserLeap.windowDimensions)==null?void 0:t.width)??document.body.clientWidth;return re(e)||n>10&&n<Ft}function re(e){return Wt.includes(e["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)",qt="rgba(0,0,0,0.9)",be="0px",He=(e,t)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container${e?" ul-container-feedback":""}`;const n=Xe();t&&n&&!window.UserLeap.useMobileStyling?n.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ge=(e,t)=>{var n;Kt();const o=window.UserLeap.container;if(o)try{(n=o.parentNode)==null||n.removeChild(o),window.UserLeap.container=null,E("trackStartUrl",null),u.emit(w.SurveyLifeCycle,{state:"dismissed"}),u.emit(w.SurveyClosed,{name:w.SurveyClosed,initiator:e,studyType:t})}catch(r){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+o),r instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",r)}},Ke=()=>{u.once(w.SurveyWillClose,({initiator:e,studyType:t})=>{u.removeAllListeners(w.CloseSurveyOnOverlayClick),Ge(e,t)})},$t=(e,t)=>{const n={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},o=t?e.overlayStyleMobile:e.overlayStyle;n["background-color"]=o==="light"?Bt:qt,t||(n.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,n)},Vt=(e,t,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({},t,window.UserLeap),{desktopDisplay:c}=t||{},l=c==="center-modal";l&&(a.framePosition="center");let d,p=!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)&&(p=!0);else{s.width=We,s.maxHeight=window.UserLeap.maxHeight||"66vh";const g=()=>{p=!0,d={margin:"auto",position:"static"}};if(o)l?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 p&&$t(a,n),Object.assign(e.style,s,d),p},Ht=({productConfig:e,useMobileStyling:t,surveyId:n,isFeedback:o})=>{var r,i;const s=he,a=o&&e.desktopDisplay==="slider";He(o,a),Gt();const c=document.createElement("iframe");c.id=s,c.setAttribute("title","Sprig User Feedback Dialog");const l=Vt(c,e,t,o);Ke();let d=!1;c.setHeight=m=>{(parseInt(c.style.height)!=m||!d)&&(d=!0,c.style.height=`${m}px`,u.emit(w.SurveyHeight,{name:w.SurveyHeight,contentFrameHeight:m}))};let p=!1;c.setWidth=m=>{(parseInt(c.style.width)!=m||!p)&&(p=!0,c.style.width=`${m}px`,u.emit(w.SurveyWidth,{name:w.SurveyWidth,contentFrameWidth:m}))},(r=window.UserLeap.container)==null||r.appendChild(c),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{u.emit(w.CloseSurveyOnOverlayClick)}),u.emit(w.SurveyLifeCycle,{state:"presented"}),u.emit(w.SurveyPresented,{name:w.SurveyPresented,"survey.id":n});const g=(i=c.contentWindow)==null?void 0:i.document;if(g&&(g.open("text/html","replace"),g.write("<!doctype html><head></head><body></body></html>"),g.close(),!t)){const m=g.body;m.style.display="flex",m.style.alignItems="center"}const v=g?.head;return{frameId:s,contentWinDocHead:v,contentWindow:c.contentWindow,hasOverlay:l,iframe:c}},Je={[w.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Gt=()=>{Object.entries(Je).forEach(([e,t])=>{u.on(e,t)})},Kt=()=>{Object.entries(Je).forEach(([e,t])=>{u.off(e,t)})},Jt=1,Qe=e=>e instanceof HTMLElement||e instanceof SVGElement,H=({document:e,elementId:t,styleString:n,nonce:o})=>{const r=e.getElementById(t);if(r){r.textContent=n;return}const i=e.createElement("style");o&&(i.nonce=o),i.textContent=n,i.id=t,e.head.appendChild(i)},Ye=e=>{const t=e.querySelector(".ul-card__container");let n=600,o=360;if(t){n=t.scrollHeight;const r=getComputedStyle(t),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 c=t.querySelector(".ul-card--matrix_grid");o=c?c.scrollWidth:t.scrollWidth;const l=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),d=parseFloat(r.marginLeft)+parseFloat(r.marginRight),p=parseFloat(r.borderLeftWidth)+parseFloat(r.borderRightWidth);o+=d+p+l}return[n+Jt,o]},Qt=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},Xe=()=>y,B=()=>document.getElementById("sprig-feedback-container"),Le=()=>document.getElementById("sprig-feedback-loading-animation"),Yt=()=>{if(Le())return;const e=document.createElement("div");return e.className="ul-loading-spinner-container",e.id="sprig-feedback-loading-animation",e.role="progressbar",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.setAttribute("aria-label","Processing..."),e.innerHTML=`
|
|
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
|
-
`,e},Ze=()=>!!document.getElementById(he);let et=!1,y=null,D=null,Ue=!1,G=null,K=null;const Xt=["bottom-left","bottom-right","center-left","center-right"],Zt=e=>{if(B()||!Xt.includes(e))return;const[t,n]=e.split("-"),o=document.createElement("div");o.id="sprig-feedback-container",o.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${t}`),document.body.appendChild(o)},ne=()=>{var e;const t=window.UserLeap.container;return((e=t?.parentElement)==null?void 0:e.id)==="sprig-feedback-loading-container"},tt=()=>document.getElementById("sprig-feedback-error-container"),rt=()=>{if(!y)return 0;const e=y?.clientWidth,t=window.getComputedStyle(y),n=parseInt(t.borderRightWidth||"0"),o=parseInt(t.borderLeftWidth||"0");return e+n+o},ie=e=>{const t=B();t&&(K!=null&&K.endsWith("right")?t.style.right=`${e}px`:K!=null&&K.endsWith("left")&&(t.style.left=`${e}px`))},Se=()=>{if(y&&(ne()||tt())){u.off(w.SurveyAppeared,J),ke();const e=rt();return ie(-e),!0}return!1},J=()=>{if(!y||!D)return;const e=Le();e&&e.remove(),y.style.height="auto",y.style.width="auto",D.disabled=!1,Ue=!1},ke=()=>{if(y&&!Le()){const e=Yt();e&&(y.style.height="300px",y.style.width="360px",y.appendChild(e))}},nt=()=>{!y||!D||(ie(0),D.disabled=!0,Ue=!0)},er=async e=>{const t=await A(x("1",[T],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:e}),method:"POST"});return t.ok?t.json:null},it=async(e,t,n)=>{const{buttonTheme:o,customStyles:r,eventId:i,placement:s,desktopDisplay:a,feedbackLabel:c,surveyUuid:l,surveyId:d}=e;window.UserLeap.feedbackCustomStyles=void 0;let p=B();if(p){if(!t&&i===G)return;p.remove(),u.off($.SURVEY_FADING_OUT,Se)}G=i,H({document,elementId:"sprig-feedback-style",styleString:Ot,nonce:window.UserLeap.styleNonce}),H({document,elementId:"ul-custom-style",styleString:r??"",nonce:window.UserLeap.styleNonce}),et=a==="center-modal",K=s;const[g,v]=s.split("-");Zt(s),p=B(),D=document.createElement("button");const m=document.createElement("div");m.className="sprig-feedback-button-label",m.innerText=c,D.appendChild(m),D.id="sprig-feedback-button",D.classList.add(`sprig-feedback-button-${v}`,`sprig-feedback-button-${g}`,`sprig-feedback-button-${o}`,"fade-in-transition"),u.on($.SURVEY_FADING_OUT,Se),D.addEventListener("click",async()=>{const I=document.getElementById("sprig-feedback-error-container");if(Ze()||tt()){if(Se()){u.emit(w.SurveyWillClose,{name:w.SurveyWillClose,initiator:M.FeedbackClosed,studyType:"feedbackButton"});const O=B();I&&O&&(O.remove(),G=null,y=null)}return}const b=C(window.UserLeap);if(!fe(b)&&!Ue&&nt(),t){y&&y.classList.add("sprig-feedback-loading-container-previews"),await V(t),J();return}const k=await er(l);if(k)u.once(w.SurveyAppeared,J),V({...k,studyType:"feedbackButton"},n);else if(y){const O=rr();y.appendChild(O),J(),y.style.height="300px",y.style.width="360px"}}),p?.appendChild(D),u.emit(w.FeedbackButtonLoaded,{name:w.FeedbackButtonLoaded,"survey.id":d});const{useMobileStyling:h,_config:{border:S}}=window.UserLeap;if(!et&&!h){const I=document.createElement("div");I.id="sprig-feedback-loading-container",I.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${v}`,I.style.setProperty("--feedback-border",S),y=I,ke(),p?.appendChild(I);const b=rt();ie(-b)}else ie(0);window.UserLeap._config.isOnQuestionsTab&&t&&!ne()&&y&&(nt(),ke(),y&&y.classList.add("sprig-feedback-loading-container-previews"),V(t),J())},tr=()=>{if(ne())return;const e=B();e&&(kt(G)||(e.remove(),G=null,y=null))},rr=()=>{const e=document.createElement("div");e.id="sprig-feedback-error-container",e.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
|
|
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 t=document.createElement("h3");return t.className="sprig-feedback-error-text",t.innerText="There was an error while loading the survey",e.appendChild(t),e},nr="!launch_darkly_";class ir{constructor(){q(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(t){try{return!t||typeof t!="object"||Array.isArray(t)?!1:(Object.keys(this._ldData).forEach(n=>{delete this._ldData[n]}),Object.keys(t).forEach(n=>this._ldData[`${nr}${n}`]=(t[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const Ie=new ir;Object.freeze(Ie);const or="!optimizely_experiments_";class sr{constructor(){q(this,"_optimizelyData",{})}setOptimizelyExperiment(t,n=!0){if(!t||typeof t!="object")return!1;const{experiments:o}=t;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(t){return this._optimizelyData[this.transformExperimentId(t)]}transformExperimentId(t){return or+t}getAndSetWebOptimizelyExperiments(){var t;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(t=window.optimizely.get("state"))==null?void 0:t.getExperimentStates({isActive:!0});if(n){const 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 sr;Object.freeze(oe);class ar{constructor(t,n){q(this,"paused"),q(this,"queue"),q(this,"ul"),this.ul=t,this.paused=!1,this.queue=[],this.flush(n)}flush(t){const n=t.length;if(n)for(let o=0;o<n;o++)this.push(t[o])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const t=this.queue.slice();this.empty(),this.flush(t)}push(t){if(this.paused)this.queue.push(t);else if(t instanceof Function)t();else{const n=Array.prototype.slice.call(t,1),o=t[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(t){if(this.paused){let n=()=>{};const o=new Promise(function(r){n=function(){r(t())}});return this.queue.push(n),o}else return t()}empty(){this.queue.length=0}}let ot,st;const Ee=e=>{let t=0,n=e.firstElementChild;for(;n;)t+=Ee(n),n.shadowRoot&&(t+=Ee(n.shadowRoot)),n=n.nextElementSibling,t++;return t},dr=()=>document.documentElement.innerHTML.length,at=()=>{ot.report(Ee(document.body)),st.report(dr())},lr=(e=10*1e3)=>{ot=j("sdk_dom_nodes_count"),st=j("sdk_page_html_characters"),at(),setInterval(at,e)},_e=(e,t)=>{const n=performance.now();document.hidden?setTimeout(()=>_e(e,t),e):setTimeout(()=>{const o=performance.now()-n;t.report(o/1e3),setTimeout(()=>_e(e,t),e)},0)},cr=(e=1e3)=>{const t=j("sdk_event_queue_latency_seconds");_e(e,t)};let se,ae,de,le,N={},dt;const ce=(e,t=1)=>{const{name:n}=e;N[n]=(N[n]||0)+t},lt=e=>{let t=1;return e.childNodes.forEach(n=>{t+=lt(n)}),t},ct=e=>{let t=0;return e.forEach(n=>{t+=lt(n)}),t},pr=e=>{switch(e.type){case"childList":ce(se,ct(e.addedNodes)),ce(ae,ct(e.removedNodes));return;case"attributes":ce(de);return;case"characterData":ce(le);return}},ur=e=>e.forEach(pr),wr=()=>{dt=new MutationObserver(ur),dt.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0})},gr=()=>{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={}},mr=(e=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"),wr(),setInterval(gr,e)},yr=({isWeb:e,reportingIntervalSeconds:t,thresholds:n,postMetrics:o})=>{It(n,(r,i)=>{var s,a;if((s=U.replay)!=null&&s.isReplayRecording()){const c=`Value: ${r} on ${i.metric} violated threshold of ${i.type} ${i.value}`;(a=U.replay)==null||a.disableRecording("Threshold violated",new Error(c),{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}),_t()}}),Et({reportingIntervalSeconds:t,postMetrics:o}),e&&(cr(),lr(),mr())},vr={test:"test"},fr=["popState","pushState","replaceState"],Q="!email",pt="pageUrl";function hr(e,t){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=e&&i.find(a=>a.id===e);return s?ye(s,window.location.href):t===window.location.href}function Y(e){var t;const{pageUrlEvents:n,interactiveEvents:o,dismissOnPageChange:r,platform:i}=window.UserLeap._config;if(i&&i!=="web")return;const s=z("trackStartUrl"),a=s?String(s):null;n&&mt(window.location.href),o&&(wt(),br()),Xe()&&tr(),At.getItem("sprig.isCapturingHeatmap")&&((t=U.replay)==null||t.checkPendingHeatmapsUrl()),!ne()&&r&&a&&a!==window.location.href&&e&&fr.includes(e.type)&&window.UserLeap("dismissActiveSurvey",M.PageChange)}const ut={capture:!0},br=()=>{const e=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(Qe(a.target))try{a.target.closest(i)&&window.UserLeap("track",o)}catch{}return!1}:a=>(Qe(a.target)&&a.target.innerText===s&&window.UserLeap("track",o),!1)}),t=n=>e.forEach(o=>o(n));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,ut)},wt=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,ut),delete window.UserLeap._config.interactiveEventsHandler};function Lr(){["hashchange","popstate"].forEach(e=>window.addEventListener(e,Y,!0))}function Ur(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,Y,!0)),window.UserLeap._config.interactiveEvents&&wt()}function Sr(e){const t=new URL(x("1",[F],"questions"));return Object.entries(e||{}).forEach(([n,o])=>{o&&t.searchParams.append(n,String(o))}),t.toString()}function z(e){const t=R.getItem("userleap.ids");if(t)try{const n=JSON.parse(t)[window.UserLeap.envId];return n&&n[e]||null}catch(n){n instanceof Error&&(n.stack=t,window.UserLeap.reportError("Failed to parse local storage credentials",n)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",n)}return null}function gt(){window.previewMode||(window.UserLeap.visitorId=Me(),_(`Generating new vid: ${window.UserLeap.visitorId}`),E("vid",window.UserLeap.visitorId),u.emit(w.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function mt(e,t,n,o){var r,i;try{if(e.endsWith("mock_snippet.html"))return;_(`Tracking page view: ${e}`);const s=window.UserLeap._config.pageUrlEvents;let a=!1;if(s&&s.length)for(let d=0;d<s.length&&(a=ye(s[d],e),!a);d++);if(!a)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const c={url:e};o&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",pt,t,c,n]);const l=(r=document?.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(i=U.replay)==null||i.RecordPageView({...l&&{description:l},url:e,referrer:document.referrer,pageTitle:document.title})}catch(s){s instanceof Error&&(s.stack=e,window.UserLeap.reportError("trackPageView",s)),console.warn("[Sprig] (ERR-428) Failed to track page view",s)}}function kr(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...n){const o=t.apply(this,n),r=new Event("pushState");return window.dispatchEvent(r),Y(r),o})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...n){const o=t.apply(this,n),r=new Event("replaceState");return window.dispatchEvent(r),Y(r),o})(e.replaceState)),Lr()}async function xe(e,t){const n=ve();e&&!t&&(window.UserLeap._config.mode=vr.test);const o=C(window.UserLeap),r=fe(o),i=await A(Sr({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:r,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:e?.surveyId,surveytemplateid:e?.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 ze(i.json.delay),i.json.isFeedback){const{feedbackLabel:s,productConfig:a,surveyUuid:c,feedbackCustomStyles:l}=i.json,{buttonTheme:d,placement:p,desktopDisplay:g}=a,v={customStyles:l,buttonTheme:d,desktopDisplay:g,eventId:0,feedbackLabel:s,placement:p,surveyUuid:c,surveyId:e?.surveyId};it(v,i.json)}else return V(i.json)}function Ir(e){let t=e.length;for(;t;){const n=Math.floor(Math.random()*t);t-=1;const o=e[t];e[t]=e[n],e[n]=o}}function Er(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:n,dismissOnPageChange:o}=e;t&&Ir(t),(t||n||o)&&(kr(),Y())}async function _r(e,t){var n,o;let r=!0;return t&&(n=e?.json)!=null&&n.surveyId&&(window.UserLeap.delayingSurvey=!0,r=await t(e.json.surveyId),window.UserLeap.delayingSurvey=!1,!r)?!1:((o=e?.json)!=null&&o.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await ze(e.json.delay),window.UserLeap.delayingSurvey=!1),r)}const xr=function(e){if(!window.UserLeap)return;const t=async(r={})=>{var i,s,a,c,l;const{userId:d,anonymousId:p,metadata:g={},properties:v,showSurveyCallback:m}=r;let{eventName:h}=r;if(window.UserLeap.debugMode&&h!==pt&&console.info("[DEBUG] Sprig track",r),e.mode==="test")return;const S=R.getItem("sprig.previewKey")??void 0;if(e.requireUserIdForTracking&&!window.UserLeap.userId&&!d){const L="[Sprig] - Skipping tracking without userId";return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}if(!h||h.trim().length===0){h=h?String(h):"";const L="[Sprig] - Invalid event name "+h;return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}const I=window.location.href;if(g.url||(g.url=I),E("trackStartUrl",I),(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())}(c=(a=window.UserLeap)==null?void 0:a._config)!=null&&c.launchDarklyEnabled&&(g.launchDarklyFlags=Ie.getAllLaunchDarklyVariations()),d&&(window.UserLeap.userId=d),p&&(window.UserLeap.partnerAnonymousId=p),v&&(g.eventProperties=v),(l=U.replay)==null||l.RecordEvent({name:h,url:g.url}),_(`Tracking event: ${h}`);const b=window.UserLeap.delayingSurvey||Ze()?await A(x("1",[T],"events/batch"),{body:JSON.stringify({events:[{event:h,metadata:g}],previewKey:S}),method:"POST",shouldDropOnRateLimit:!0}):await A(x("1",[T],"events"),{body:JSON.stringify({event:h,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),p&&E("aid",p);const k=b.json;k.invalidPreviewKey&&R.removeItem("sprig.previewKey");const O=g.trackPageView?g.url:void 0;return k!=null&&k.feedbackButton&&it(k.feedbackButton,void 0,O),await _r(b,m)?hr(k.eventId,I)?V(k,O):{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&&H({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),xe({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",M.Override),xe({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",M.Override),xe({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){u.emit(w.SurveyWillClose,{name:w.SurveyWillClose,initiator:r})},async setAttribute(r,i){if(!r||!i&&i!==0&&i!==!1){const s="[Sprig] - Disregarding empty attribute / value provided";return console.warn(s),{success:!1,message:s}}return this.setAttributes({[r]:i})},async setAttributes(r){if(r==null||Object.keys(r).length===0){const i="[Sprig] - Disregarding empty attributes provided";return console.warn(i),{success:!1,message:i}}return this.identifyAndSetAttributes({attributes:r})},async identifyAndSetAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",r),e.mode==="test")return;if(r===null||typeof r!="object"||!(r.userId||r.anonymousId||r.attributes)){const d="[Sprig] - Disregarding empty payload provided";return console.warn(d),{success:!1,message:d}}const{userId:i,anonymousId:s,attributes:a}=r;if(e.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 c={};i&&(c.userId=window.UserLeap.userId=i),s&&(c.partnerAnonymousId=window.UserLeap.partnerAnonymousId=s);let l;return a?(a.email&&!Object.prototype.hasOwnProperty.call(a,Q)&&(a[Q]=a.email,delete a.email),_(`Setting attributes: ${JSON.stringify(a)}`),l=await A(x("1",[F,T],"attributes"),{body:JSON.stringify(a),method:"PUT"}),!l.ok&&l.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",l.error),l.error&&window.UserLeap.reportError("identifyAndSetAttributes",l.error))):l=await A(x("1",[F,T]),{body:JSON.stringify(c),method:"PUT"}),a&&a[Q]&&(window.UserLeap.email=a[Q]),l.ok&&(i&&E("uid",i),s&&E("aid",s)),{success:!!l.ok}},async removeAttributes(r){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",r),e.mode==="test")return;if(r==null||r.length===0){const s="[Sprig] - Disregarding empty attributes provided";return console.warn(s),{success:!1,message:s}}if(e.requireUserIdForTracking&&!window.UserLeap.userId){const s="[Sprig] - Skipping tracking without userId";return console.warn(s),{success:!1,message:s}}const i=await A(x("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){u.on(w.SurveyLifeCycle,r)},async removeSurveyListener(r){u.removeListener(w.SurveyLifeCycle,r)},async addListener(r,i){u.on(r,i)},async removeListener(r,i){u.removeListener(r,i)},async removeAllListeners(){u.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||R.isStorageAvailable&&r&&R.setItem("sprig.previewKey",r)},async setUserId(r){var i;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(e.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const s=window.UserLeap.visitorId,a=await A(x("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 t({eventName:r,properties:i,metadata:s,showSurveyCallback:a})},async identifyAndTrack(r){return await t(r)},trackPageView(r,i=void 0,s=void 0,a=!0){mt(r,i,s,a)},applyFeedbackStyles({button:r="",view:i=""}){window.UserLeap.feedbackCustomStyles=i,document.getElementById("sprig-feedback-style")&&H({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 c=typeof r=="string"?parseInt(r,10):r,l=typeof i=="string"?parseInt(i,10):i;if(!isNaN(c)&&!isNaN(l)&&(window.UserLeap.windowDimensions={width:c,height:l}),!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(Ye(d.contentDocument)[0])+"px")),u.emit(w.SurveyDimensions,{name:w.SurveyDimensions,contentFrameWidth:d.clientWidth,contentFrameHeight:d.clientHeight}))},logoutUser(){var r;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),_(`Logging out user: ${window.UserLeap.userId} / vid: ${window.UserLeap.visitorId}`),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,R.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),gt(),(r=U.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){Ur(),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 c=typeof r=="string"?JSON.parse(r):r;oe.setOptimizelyExperiment(c,i)}catch(c){console.warn("[Sprig] Error with integrating Optimizely data"),c instanceof Error&&window.UserLeap.reportError("integrateOptimizely",c)}},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:c,variation:l})=>{const d={experiments:[{id:c.id,variation:l.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}Ie.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 Or(r)},_reportMetric(r,i){Dt(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 Rr(e){const t=C(window.UserLeap);document.addEventListener("securitypolicyviolation",je);const n=await Fe(x("1",[F],"config"),{headers:t});if(document.removeEventListener("securitypolicyviolation",je),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),Ne("Disabled: failed to fetch configuration"),e;const o=n.json;return o!=null&&o.disabled?(Ne(`Disabled: ${o.disabled}`),{disabled:o.disabled}):Object.assign({},o,e)}const Ar=e=>typeof e=="object"&&e&&"inner"in e&&!!e.inner&&typeof e.inner=="object";async function Dr(e,t,n={},o={}){var r,i;const s=window.__cfg&&window.__cfg.mode,a=ve(),c=window.UserLeap.envId,l=window.document.documentElement,d=Ar(t)?{inner:{message:(r=t.inner)==null?void 0:r.message,stack:(i=t.inner)==null?void 0:i.stack}}:{},p={mode:s,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:l.clientWidth,clientHeight:l.clientHeight,location:window.location.href,language:window.navigator.language,...n,...d},g={action:e,err:{message:t.message,stack:t.stack},meta:p,vid:a,envId:c,...o},v=await A(x("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(g),shouldDropOnRateLimit:!0});if(!v.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",t);else{const{presignedUrl:m}=v.json;Rt(m)}}async function Or(e){var t;if(!e)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(e)});if(o.ok){const r=await o.json();return(t=r?.upload)==null?void 0:t.url}else return null}catch(o){console.warn("[Sprig] Error with generating video upload url"),o instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",o)}}function Pr(e={}){const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=$,window.UserLeap("setPreviewKey",t);async function n(){var o;if(window.UserLeap.loaded)return;if(_("Loading sprig on page load"),window.UserLeap.reportError=Dr,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},e,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const 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 ar(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")):(R.removeItem("userleap.ids"),gt());const a=C(window.UserLeap),c=re(a),l=await Rr(e);yr({isWeb:!c,reportingIntervalSeconds:l.metricsReportingEnabled||l.mobileMetricsReportingEnabled?l.metricsReportingIntervalSeconds:0,thresholds:l.metricThresholds,postMetrics:async d=>{var p;await A(x("1",[F],"metrics"),{body:d,method:"POST",headers:{"x-ul-replay-enabled":`${!!((p=U.replay)!=null&&p.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),(o=U.replay)==null||o.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:l.maxReplayDurationSeconds,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:l.replaySettings}),xt(l.logBufferLimit,l.logLevel),xr(l),await Er(l),window.UserLeap._queue.unpause(),u.emit(w.SDKReady,{mobileMetricsReportingEnabled:!!l.mobileMetricsReportingEnabled,metricsReportingInterval:l.metricsReportingIntervalSeconds||0,metricsThresholds:l.metricThresholds||[],maxMobileReplayDurationSeconds:l.maxMobileReplayDurationSeconds,mobileReplaySettings:l.mobileReplaySettings}),u.emit(w.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=$}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,n){window.Sprig("setAttribute",t,n)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,n){window.Sprig("addListener",t,n)}removeListener(t,n){window.Sprig("removeListener",t,n)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(t){window.Sprig("setAttribute","!email",t)}setUserId(t){window.Sprig("setUserId",t)}setPartnerAnonymousId(t){window.Sprig("setPartnerAnonymousId",t)}track(t,n={},o={}){window.Sprig("track",t,n,o)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,n,o){window.Sprig("trackPageView",t,n,o)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,n){window.Sprig("setWindowDimensions",t,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const Re={configure:e=>{if(!e.envId&&!e.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(e.envId||(e.envId=e.environmentId??""),e.installationMethod="web-npm",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 t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,Pr(e),window.Sprig}},Cr={sprig:Re,SprigAPI:pe,configure:Re.configure};export{Pt as A,$e as C,We as D,Mt as E,pe as S,Ye as a,Tt as b,Cr as c,Ct as d,H as e,Qt as r,Re as s};
|
package/dist/core-D0ATZnzx.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";var at=Object.defineProperty;var dt=(e,t,n)=>t in e?at(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var F=(e,t,n)=>(dt(e,typeof t!="symbol"?t+"":t,n),n);const i=require("./metricsReporter-DaSVYNOK.cjs"),lt='.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}',Ce="360px",ct="ul-app",pt="#e6e6e6",ut="#bd282a",wt=500,gt=1030,Me=()=>{try{return window.parent.Intercom}catch{return null}},ft=()=>{const e=Me();e&&(e.ul_wasVisible&&e("update",{hide_default_launcher:!1}),delete e.ul_wasVisible)},mt=()=>{const e=Me();e&&(e.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),e.ul_wasVisible&&e("update",{hide_default_launcher:!0}))},yt=Object.freeze(Object.defineProperty({__proto__:null,disable:mt,enable:ft},Symbol.toStringTag,{value:"Module"})),_e=[yt];class Fe{static disable(){_e.forEach(t=>t.disable())}static enable(){_e.forEach(t=>t.enable())}}const Re="ul-view-sdk-script",vt=["ios","android"],D="visitors",O="environments";async function I(e,t){var o,a,d;const{shouldDropOnRateLimit:n,...s}=t;s.headers=Object.assign(i.getHttpHeaders(window.UserLeap),s.headers);const r=await i.sprigFetch(e,{...s,shouldDropOnRateLimit:n});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),i.eventEmitter.emit(i.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(e,t){const n=i.localStorageHelper.getItem("userleap.ids");let s={};if(n)try{s=JSON.parse(n)}catch(o){o instanceof Error&&(o.stack=n,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[e]=t:r={[e]:t},s[window.UserLeap.envId]=r;try{i.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 ge(){return window.previewMode?"0":window.UserLeap.visitorId??""}function U(e,t,n){const s=[window.UserLeap._API_URL,"sdk",e];return t&&t.forEach(r=>{s.push(r),r===O?s.push(window.UserLeap.envId):r===D&&s.push(ge())}),n&&s.push(n),s.join("/")}const V=async(e,t)=>{var Ee,Ue,ke;const{context:n,delay:s,forceBrandedLogo:r,endCard:o,isFeedback:a=!1,heatmap:d,locale:c,previewMode:p,productConfig:l,questions:u,responseGroupUid:m,surveyId:w,uuid:f,vid:L,sessionReplay:A,studyType:$}=e,v=i.getHttpHeaders(window.UserLeap),R=te(v),x=fe(v);if(i.info(`Attempting to display survey: ${w}`),A)if(i.info("Survey has replay attached"),R)i.eventEmitter.emit(i.SprigEvent.ReplayCapture,{responseGroupUid:m,hasQuestions:!!(u!=null&&u.length),surveyId:w,uploadId:A.uploadId,replayType:A.replayDurationType??"before",seconds:A.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:i.v4(),mediaType:"screen",questionId:1,responseGroupUid:m,surveyId:w,updatedAt:new Date().toISOString(),visitorId:window.UserLeap.visitorId,isReplay:!0}});else{if(!i.modules.replay)return window.UserLeap.reportError("displayQuestions",new Error("Replay module not registered")),{success:!1,message:"Replay module not registered",surveyState:"no survey"};i.modules.replay.scheduleOrCaptureReplay({responseGroupId:m,surveyId:w,visitorId:L,replayParams:A,completeUploadHeaders:v,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:u.length===0})}if(d){if(!i.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:y,replayParams:oe,responseGroupUid:ot,surveyId:st}=d;await i.modules.replay.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:300,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0}),i.modules.replay.tryReplayAction(()=>{var Ie;return(Ie=i.modules.replay)==null?void 0:Ie.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:v,eventId:y,isHeatmap:!0,replayParams:oe,responseGroupId:ot,surveyId:st,triggerTimestamp:Date.now(),visitorId:L})},"Error in scheduling/capturing replay")}if(L==null||!(u!=null&&u.length))return i.info(`Not displaying survey: vid: ${L} / questions: ${u}`),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){i.info("Already displaying a survey");const y="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(y),{success:!1,message:y,surveyState:"no survey"}}if(L!==window.UserLeap.visitorId&&f!==window.UserLeap.visitorId&&!window.previewMode){const y="Attempted to display survey to a different visitor";return i.info(y),window.UserLeap.reportError("DisplaySurvey",new Error(y)),{success:!1,message:y,surveyState:"no survey"}}i.info(`Showing survey: ${w}`),(Ee=i.modules.replay)==null||Ee.RecordSurveyShown({id:w,userAgent:window.navigator.userAgent}),Fe.disable(),i.eventEmitter.emit(i.SprigEvent.SurveyWillPresent,{name:i.SprigEvent.SurveyWillPresent,"survey.id":w});let k,b=document.createElement("div"),h,E,q;const he=y=>{const{"view.version":oe}=y;oe!==v["x-ul-sdk-version"]&&Ne(),i.eventEmitter.removeListener("verify.view.version",he)};i.eventEmitter.on("verify.view.version",he),window.UserLeap.useMobileStyling=x,i.shouldDirectEmbed(v)?(k="ul-direct-embeded-frame",h=document.head,E=window,q=!1,R&&(He(a),b.id=k,window.UserLeap.container.appendChild(b),Be(),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":w}))):{frameId:k,contentWinDocHead:h,contentWindow:E,hasOverlay:q,iframe:b}=Et({productConfig:l,useMobileStyling:x,surveyId:w,isFeedback:a}),window.UserLeap.frameId=k;const rt=y=>{i.eventEmitter.once(i.SprigEvent.CloseSurveyOnOverlayClick,y)},M={apiURL:window.UserLeap._API_URL,cards:u,configureExitOnOverlayClick:rt,context:n,endCard:o,envId:window.UserLeap.envId,eventEmitFn:i.eventEmitter.emit.bind(i.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:r,frame:b,headers:v,locale:c,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:i.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:m,startingQuestionIdx:(Ue=window.UserLeap.config)==null?void 0:Ue.startingQuestionIdx,studyType:$,styleNonce:window.UserLeap.styleNonce,surveyId:w,tabTitle:document.title,trackPageViewUrl:t,ulEvents:i.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:x,userId:f,viewDocument:E==null?void 0:E.document,viewWindow:E,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 it=(a?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??l.customStyles;M.customStyles=it,E&&(E.__cfg=M);function nt(){const y=document.createElement("script");return window.UserLeap.nonce&&y.setAttribute("nonce",window.UserLeap.nonce),y.id=Re,y}const ie=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:M.path,Se=document.getElementById(Re);Se&&Se.remove();const ne=nt(),Le=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(M.installationMethod==="web-npm"||M.installationMethod==="web-npm-bundled"){const{default:y}=await Promise.resolve().then(()=>require("./view-D4GRlCAk.cjs"));y.configure(M),q&&window.UserLeap.container&&Le()}else ie&&(ne.src=ie,q&&ne.addEventListener("load",()=>{window.UserLeap.container&&Le()}),E==null||E.addEventListener("error",y=>{y.target instanceof HTMLScriptElement&&y.target.src===ie&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));h==null||h.appendChild(ne);const be={success:!0,surveyState:"ready",surveyId:w,responseGroupUid:m};return window.UserLeap.isMobileSDK&&s&&(be.delay=s),be};function fe(e){var n;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((n=window.UserLeap.windowDimensions)==null?void 0:n.width)??document.body.clientWidth;return te(e)||t>10&&t<wt}function te(e){return vt.includes(e["userleap-platform"])}const me="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 ht="rgba(255,255,255, 0.95)",St="rgba(0,0,0,0.9)",se="0px",He=(e,t)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className=`ul-container${e?" ul-container-feedback":""}`;const n=je();t&&n&&!window.UserLeap.useMobileStyling?n.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Ne=(e,t)=>{var s;kt();const n=window.UserLeap.container;if(n)try{(s=n.parentNode)==null||s.removeChild(n),window.UserLeap.container=null,S("trackStartUrl",null),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"dismissed"}),i.eventEmitter.emit(i.SprigEvent.SurveyClosed,{name:i.SprigEvent.SurveyClosed,initiator:e,studyType:t})}catch(r){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${e} `+n),r instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",r)}},Be=()=>{i.eventEmitter.once(i.SprigEvent.SurveyWillClose,({initiator:e,studyType:t})=>{i.eventEmitter.removeAllListeners(i.SprigEvent.CloseSurveyOnOverlayClick),Ne(e,t)})},Lt=(e,t)=>{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=t?e.overlayStyleMobile:e.overlayStyle;s["background-color"]=r==="light"?ht:St,t||(s.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,s)},bt=(e,t,n,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({},t,window.UserLeap),{desktopDisplay:a}=t||{},d=a==="center-modal";d&&(o.framePosition="center");let c,p=!1;if(n)(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=Ce,r.maxHeight=window.UserLeap.maxHeight||"66vh";const m=()=>{p=!0,c={margin:"auto",position:"static"}};if(s)d?m():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":m();break}}return p&&Lt(o,n),Object.assign(e.style,r,c),p},Et=({productConfig:e,useMobileStyling:t,surveyId:n,isFeedback:s})=>{var m,w;const r=me,o=s&&e.desktopDisplay==="slider";He(s,o),Ut();const a=document.createElement("iframe");a.id=r,a.setAttribute("title","Sprig User Feedback Dialog");const d=bt(a,e,t,s);Be();let c=!1;a.setHeight=f=>{(parseInt(a.style.height)!=f||!c)&&(c=!0,a.style.height=`${f}px`,i.eventEmitter.emit(i.SprigEvent.SurveyHeight,{name:i.SprigEvent.SurveyHeight,contentFrameHeight:f}))};let p=!1;a.setWidth=f=>{(parseInt(a.style.width)!=f||!p)&&(p=!0,a.style.width=`${f}px`,i.eventEmitter.emit(i.SprigEvent.SurveyWidth,{name:i.SprigEvent.SurveyWidth,contentFrameWidth:f}))},(m=window.UserLeap.container)==null||m.appendChild(a),e&&(t?e.exitOnOverlayClickMobile:e.exitOnOverlayClick)&&window.UserLeap.container&&(window.UserLeap.container.onclick=()=>{i.eventEmitter.emit(i.SprigEvent.CloseSurveyOnOverlayClick)}),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":n});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(),!t)){const f=l.body;f.style.display="flex",f.style.alignItems="center"}const u=l==null?void 0:l.head;return{frameId:r,contentWinDocHead:u,contentWindow:a.contentWindow,hasOverlay:d,iframe:a}},Ve={[i.SprigEvent.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Ut=()=>{Object.entries(Ve).forEach(([e,t])=>{i.eventEmitter.on(e,t)})},kt=()=>{Object.entries(Ve).forEach(([e,t])=>{i.eventEmitter.off(e,t)})},It=1,Ae=e=>e instanceof HTMLElement||e instanceof SVGElement,j=({document:e,elementId:t,styleString:n,nonce:s})=>{const r=e.getElementById(t);if(r){r.textContent=n;return}const o=e.createElement("style");s&&(o.nonce=s),o.textContent=n,o.id=t,e.head.appendChild(o)},We=e=>{const t=e.querySelector(".ul-card__container");let n=600,s=360;if(t){n=t.scrollHeight;const r=getComputedStyle(t),o=parseFloat(r.marginTop)+parseFloat(r.marginBottom),a=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth),d=parseFloat(r.paddingTop)+parseFloat(r.paddingBottom);n+=o+a+d;const c=t.querySelector(".ul-card--matrix_grid");s=c?c.scrollWidth:t.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[n+It,s]},_t=e=>{const t=e.querySelector(".ul-card__container");t&&(t.scrollTop=0)},je=()=>g,H=()=>document.getElementById("sprig-feedback-container"),ye=()=>document.getElementById("sprig-feedback-loading-animation"),Rt=()=>{if(ye())return;const e=document.createElement("div");return e.className="ul-loading-spinner-container",e.id="sprig-feedback-loading-animation",e.role="progressbar",e.setAttribute("aria-live","polite"),e.setAttribute("aria-busy","true"),e.setAttribute("aria-label","Processing..."),e.innerHTML=`
|
|
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
|
-
`,e},ze=()=>!!document.getElementById(me);let De=!1,g=null,_=null,ve=!1,W=null,T=null;const At=["bottom-left","bottom-right","center-left","center-right"],Dt=e=>{if(H()||!At.includes(e))return;const[t,n]=e.split("-"),s=document.createElement("div");s.id="sprig-feedback-container",s.classList.add(`sprig-feedback-container-${n}`,`sprig-feedback-container-${t}`),document.body.appendChild(s)},re=()=>{var t;const e=window.UserLeap.container;return((t=e==null?void 0:e.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},$e=()=>document.getElementById("sprig-feedback-error-container"),qe=()=>{if(!g)return 0;const e=g==null?void 0:g.clientWidth,t=window.getComputedStyle(g),n=parseInt(t.borderRightWidth||"0"),s=parseInt(t.borderLeftWidth||"0");return e+n+s},J=e=>{const t=H();t&&(T!=null&&T.endsWith("right")?t.style.right=`${e}px`:T!=null&&T.endsWith("left")&&(t.style.left=`${e}px`))},ae=()=>{if(g&&(re()||$e())){i.eventEmitter.off(i.SprigEvent.SurveyAppeared,B),le();const e=qe();return J(-e),!0}return!1},B=()=>{if(!g||!_)return;const e=ye();e&&e.remove(),g.style.height="auto",g.style.width="auto",_.disabled=!1,ve=!1},le=()=>{if(!g)return;if(!ye()){const t=Rt();t&&(g.style.height="300px",g.style.width="360px",g.appendChild(t))}},Oe=()=>{!g||!_||(J(0),_.disabled=!0,ve=!0)},Ot=async e=>{const t=await I(U("1",[D],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:e}),method:"POST"});return t.ok?t.json:null},Ge=async(e,t,n)=>{const{buttonTheme:s,customStyles:r,eventId:o,placement:a,desktopDisplay:d,feedbackLabel:c,surveyUuid:p,surveyId:l}=e;window.UserLeap.feedbackCustomStyles=void 0;let u=H();if(u){if(!t&&o===W)return;u.remove(),i.eventEmitter.off(i.EVENTS.SURVEY_FADING_OUT,ae)}W=o,j({document,elementId:"sprig-feedback-style",styleString:lt,nonce:window.UserLeap.styleNonce}),j({document,elementId:"ul-custom-style",styleString:r??"",nonce:window.UserLeap.styleNonce}),De=d==="center-modal",T=a;const[w,f]=a.split("-");Dt(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-${f}`,`sprig-feedback-button-${w}`,`sprig-feedback-button-${s}`,"fade-in-transition"),i.eventEmitter.on(i.EVENTS.SURVEY_FADING_OUT,ae),_.addEventListener("click",async()=>{const v=document.getElementById("sprig-feedback-error-container");if(ze()||$e()){if(ae()){i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:i.DismissReason.FeedbackClosed,studyType:"feedbackButton"});const b=H();v&&b&&(b.remove(),W=null,g=null)}return}const R=i.getHttpHeaders(window.UserLeap);if(!fe(R)&&!ve&&Oe(),t){g&&g.classList.add("sprig-feedback-loading-container-previews"),await V(t),B();return}const k=await Ot(p);if(k)i.eventEmitter.once(i.SprigEvent.SurveyAppeared,B),V({...k,studyType:"feedbackButton"},n);else if(g){const b=Tt();g.appendChild(b),B(),g.style.height="300px",g.style.width="360px"}}),u==null||u.appendChild(_),i.eventEmitter.emit(i.SprigEvent.FeedbackButtonLoaded,{name:i.SprigEvent.FeedbackButtonLoaded,"survey.id":l});const{useMobileStyling:A,_config:{border:$}}=window.UserLeap;if(!De&&!A){const v=document.createElement("div");v.id="sprig-feedback-loading-container",v.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${f}`,v.style.setProperty("--feedback-border",$),g=v,le(),u==null||u.appendChild(v);const R=qe();J(-R)}else J(0);window.UserLeap._config.isOnQuestionsTab&&t&&!re()&&g&&(Oe(),le(),g&&g.classList.add("sprig-feedback-loading-container-previews"),V(t),B())},xt=()=>{if(re())return;const e=H();if(!e)return;i.checkUrlStillMatching(W)||(e.remove(),W=null,g=null)},Tt=()=>{const e=document.createElement("div");e.id="sprig-feedback-error-container",e.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none">
|
|
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 t=document.createElement("h3");return t.className="sprig-feedback-error-text",t.innerText="There was an error while loading the survey",e.appendChild(t),e},Pt="!launch_darkly_";class Ct{constructor(){F(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(t){try{return!t||typeof t!="object"||Array.isArray(t)?!1:(Object.keys(this._ldData).forEach(n=>{delete this._ldData[n]}),Object.keys(t).forEach(n=>this._ldData[`${Pt}${n}`]=(t[n]??0)+1),!0)}catch(n){return n instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",n),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}}const ce=new Ct;Object.freeze(ce);const Mt="!optimizely_experiments_";class Ft{constructor(){F(this,"_optimizelyData",{})}setOptimizelyExperiment(t,n=!0){if(!t||typeof t!="object")return!1;const{experiments:s}=t;try{return n&&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(t){return this._optimizelyData[this.transformExperimentId(t)]}transformExperimentId(t){return Mt+t}getAndSetWebOptimizelyExperiments(){var t;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const n=(t=window.optimizely.get("state"))==null?void 0:t.getExperimentStates({isActive:!0});if(n){const s=Object.keys(n).map(r=>{var o,a;return(o=n[r].variation)!=null&&o.name?{id:r,variation:(a=n[r].variation)==null?void 0:a.name}:{id:r,variation:"Original"}});return this.setOptimizelyExperiment({experiments:s},!1),!0}return!1}return!1}catch(n){return n instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",n),!1}}}const K=new Ft;Object.freeze(K);class Ht{constructor(t,n){F(this,"paused");F(this,"queue");F(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(n)}flush(t){const n=t.length;if(n)for(let s=0;s<n;s++)this.push(t[s])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const t=this.queue.slice();this.empty(),this.flush(t)}push(t){if(this.paused)this.queue.push(t);else if(t instanceof Function)t();else{const n=Array.prototype.slice.call(t,1),s=t[0],r=this.ul[s];r instanceof Function?r.apply(this.ul,n):s&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",s)}}perform(t){if(this.paused){let n=()=>{};const s=new Promise(function(r){n=function(){r(t())}});return this.queue.push(n),s}else return t()}empty(){this.queue.length=0}}let Ke,Je;const pe=e=>{let t=0,n=e.firstElementChild;for(;n;)t+=pe(n),n.shadowRoot&&(t+=pe(n.shadowRoot)),n=n.nextElementSibling,t++;return t},Nt=()=>document.documentElement.innerHTML.length,xe=()=>{Ke.report(pe(document.body)),Je.report(Nt())},Bt=(e=10*1e3)=>{Ke=i.registerMetric("sdk_dom_nodes_count"),Je=i.registerMetric("sdk_page_html_characters"),xe(),setInterval(xe,e)},ue=(e,t)=>{const n=performance.now();document.hidden?setTimeout(()=>ue(e,t),e):setTimeout(()=>{const s=performance.now()-n;t.report(s/1e3),setTimeout(()=>ue(e,t),e)},0)},Vt=(e=1e3)=>{const t=i.registerMetric("sdk_event_queue_latency_seconds");ue(e,t)};let Q,Y,X,Z,C={},Te;const G=(e,t=1)=>{const{name:n}=e;C[n]=(C[n]||0)+t},Qe=e=>{let t=1;return e.childNodes.forEach(n=>{t+=Qe(n)}),t},Pe=e=>{let t=0;return e.forEach(n=>{t+=Qe(n)}),t},Wt=e=>{switch(e.type){case"childList":G(Q,Pe(e.addedNodes)),G(Y,Pe(e.removedNodes));return;case"attributes":G(X);return;case"characterData":G(Z);return}},jt=e=>e.forEach(Wt),zt=()=>{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={}},qt=(e=1*1e3)=>{Q=i.registerMetric("sdk_mutations_nodes_added"),Y=i.registerMetric("sdk_mutations_nodes_removed"),X=i.registerMetric("sdk_mutations_attributes_changed"),Z=i.registerMetric("sdk_mutations_character_data"),zt(),setInterval($t,e)},Gt=({isWeb:e,reportingIntervalSeconds:t,thresholds:n,postMetrics:s})=>{i.registerThresholds(n,(r,o)=>{var a,d;if((a=i.modules.replay)!=null&&a.isReplayRecording()){const c=`Value: ${r} on ${o.metric} violated threshold of ${o.type} ${o.value}`;(d=i.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}),i.disableThresholdChecking()}}),i.initPerformanceReporting({reportingIntervalSeconds:t,postMetrics:s}),e&&(Vt(),Bt(),qt())},Kt={test:"test"},Jt=["popState","pushState","replaceState"],N="!email",Ye="pageUrl";function Qt(e,t){const{pageUrlEvents:n,interactiveEvents:s,dismissOnPageChange:r}=window.UserLeap._config;if(!r)return!0;const o=[];n&&n.length&&o.push(...n),s&&s.length&&o.push(...s);const a=e&&o.find(d=>d.id===e);return a?i.checkUrlMatch(a,window.location.href):t===window.location.href}function z(e){var d;const{pageUrlEvents:t,interactiveEvents:n,dismissOnPageChange:s,platform:r}=window.UserLeap._config;if(r&&r!=="web")return;const o=P("trackStartUrl"),a=o?String(o):null;t&&tt(window.location.href),n&&(Ze(),Yt()),je()&&xt(),i.sessionStorageHelper.getItem("sprig.isCapturingHeatmap")&&((d=i.modules.replay)==null||d.checkPendingHeatmapsUrl()),!re()&&s&&a&&a!==window.location.href&&e&&Jt.includes(e.type)&&window.UserLeap("dismissActiveSurvey",i.DismissReason.PageChange)}const Xe={capture:!0},Yt=()=>{const t=window.UserLeap._config.interactiveEvents.filter(s=>i.checkUrlMatch(s,window.location.href)).map(s=>{const{name:r,properties:o}=s,{selector:a,innerText:d}=o;return a?c=>{if(Ae(c.target))try{c.target.closest(a)&&window.UserLeap("track",r)}catch{}return!1}:c=>(Ae(c.target)&&c.target.innerText===d&&window.UserLeap("track",r),!1)}),n=s=>t.forEach(r=>r(s));window.UserLeap._config.interactiveEventsHandler=n,window.addEventListener("click",n,Xe)},Ze=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,Xe),delete window.UserLeap._config.interactiveEventsHandler};function Xt(){["hashchange","popstate"].forEach(e=>window.addEventListener(e,z,!0))}function Zt(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,z,!0)),window.UserLeap._config.interactiveEvents&&Ze()}function er(e){const t=new URL(U("1",[O],"questions"));return Object.entries(e||{}).forEach(([n,s])=>{s&&t.searchParams.append(n,String(s))}),t.toString()}function P(e){const t=i.localStorageHelper.getItem("userleap.ids");if(t)try{const s=JSON.parse(t)[window.UserLeap.envId];return s&&s[e]||null}catch(n){n instanceof Error&&(n.stack=t,window.UserLeap.reportError("Failed to parse local storage credentials",n)),console.warn("[Sprig] (ERR-427) Failed to lookup saved ids",n)}return null}function et(){window.previewMode||(window.UserLeap.visitorId=i.v4(),i.info(`Generating new vid: ${window.UserLeap.visitorId}`),S("vid",window.UserLeap.visitorId),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}))}function tt(e,t,n,s){var r,o;try{if(e.endsWith("mock_snippet.html"))return;i.info(`Tracking page view: ${e}`);const a=window.UserLeap._config.pageUrlEvents;let d=!1;if(a&&a.length)for(let l=0;l<a.length&&(d=i.checkUrlMatch(a[l],e),!d);l++);if(!d)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",e);const c={url:e};s&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",Ye,t,c,n]);const p=(r=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:r.getAttribute("content");(o=i.modules.replay)==null||o.RecordPageView({...p&&{description:p},url:e,referrer:document.referrer,pageTitle:document.title})}catch(a){a instanceof Error&&(a.stack=e,window.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function tr(){const e="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in e&&(e.pushState=(t=>function(...s){const r=t.apply(this,s),o=new Event("pushState");return window.dispatchEvent(o),z(o),r})(e.pushState)),"replaceState"in e&&(e.replaceState=(t=>function(...s){const r=t.apply(this,s),o=new Event("replaceState");return window.dispatchEvent(o),z(o),r})(e.replaceState)),Xt()}async function de(e,t){const n=ge();e&&!t&&(window.UserLeap._config.mode=Kt.test);const s=i.getHttpHeaders(window.UserLeap),r=fe(s),o=await I(er({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:r,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:e==null?void 0:e.surveyId,surveytemplateid:e==null?void 0:e.surveyTemplateId,vid:n}),{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 i.delay(o.json.delay),o.json.isFeedback){const{feedbackLabel:a,productConfig:d,surveyUuid:c,feedbackCustomStyles:p}=o.json,{buttonTheme:l,placement:u,desktopDisplay:m}=d,w={customStyles:p,buttonTheme:l,desktopDisplay:m,eventId:0,feedbackLabel:a,placement:u,surveyUuid:c,surveyId:e==null?void 0:e.surveyId};Ge(w,o.json)}else return V(o.json)}function rr(e){let t=e.length;for(;t;){const n=Math.floor(Math.random()*t);t-=1;const s=e[t];e[t]=e[n],e[n]=s}}function ir(e){if(!e)return;window.UserLeap._config=e,e.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:n,dismissOnPageChange:s}=e;t&&rr(t),(t||n||s)&&(tr(),z())}async function nr(e,t){var s,r;let n=!0;return t&&((s=e==null?void 0:e.json)!=null&&s.surveyId)&&(window.UserLeap.delayingSurvey=!0,n=await t(e.json.surveyId),window.UserLeap.delayingSurvey=!1,!n)?!1:((r=e==null?void 0:e.json)!=null&&r.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await i.delay(e.json.delay),window.UserLeap.delayingSurvey=!1),n)}const or=function(e){if(!window.UserLeap)return;const t=async(r={})=>{var v,R,x,k,b;const{userId:o,anonymousId:a,metadata:d={},properties:c,showSurveyCallback:p}=r;let{eventName:l}=r;if(window.UserLeap.debugMode&&l!==Ye&&console.info("[DEBUG] Sprig track",r),e.mode==="test")return;const u=i.localStorageHelper.getItem("sprig.previewKey")??void 0;if(e.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 m=window.location.href;if(d.url||(d.url=m),S("trackStartUrl",m),(R=(v=window.UserLeap)==null?void 0:v._config)!=null&&R.optimizelyEnabled){const h=i.getHttpHeaders(window.UserLeap);te(h)||K.getAndSetWebOptimizelyExperiments(),d.optimizelyExperiments=Object.assign({},K.getAllOptimizelyExperiments())}(k=(x=window.UserLeap)==null?void 0:x._config)!=null&&k.launchDarklyEnabled&&(d.launchDarklyFlags=ce.getAllLaunchDarklyVariations()),o&&(window.UserLeap.userId=o),a&&(window.UserLeap.partnerAnonymousId=a),c&&(d.eventProperties=c),(b=i.modules.replay)==null||b.RecordEvent({name:l,url:d.url}),i.info(`Tracking event: ${l}`);const w=window.UserLeap.delayingSurvey||ze()?await I(U("1",[D],"events/batch"),{body:JSON.stringify({events:[{event:l,metadata:d}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await I(U("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 f=w.json;f.invalidPreviewKey&&i.localStorageHelper.removeItem("sprig.previewKey");const L=d.trackPageView?d.url:void 0;return!!(f!=null&&f.feedbackButton)&&Ge(f.feedbackButton,void 0,L),await nr(w,p)?Qt(f.eventId,m)?V(f,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"}},n=(r,o)=>{var d;const a=(d=r==null?void 0:r.querySelector(`[id="${me}"]`))==null?void 0:d.contentDocument;a&&j({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",i.DismissReason.Override),de({surveyId:r},!0)},_previewSurvey(r){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),de({surveyTemplateId:r},!1)},_reviewSurvey(r){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),de({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=i.DismissReason.API){i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:r})},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),e.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(e.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,N)&&(d[N]=d.email,delete d.email),i.info(`Setting attributes: ${JSON.stringify(d)}`),p=await I(U("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 I(U("1",[O,D]),{body:JSON.stringify(c),method:"PUT"}),d&&d[N]&&(window.UserLeap.email=d[N]),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),e.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(e.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const o=await I(U("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){i.eventEmitter.on(i.SprigEvent.SurveyLifeCycle,r)},async removeSurveyListener(r){i.eventEmitter.removeListener(i.SprigEvent.SurveyLifeCycle,r)},async addListener(r,o){i.eventEmitter.on(r,o)},async removeListener(r,o){i.eventEmitter.removeListener(r,o)},async removeAllListeners(){i.eventEmitter.removeAllListeners()},setPreviewKey(r){!r||typeof r!="string"||i.localStorageHelper.isStorageAvailable&&r&&i.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(e.mode==="test"||r===window.UserLeap.userId)return;window.UserLeap.userId=r;const o=window.UserLeap.visitorId,a=await I(U("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=i.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 t({eventName:r,properties:o,metadata:a,showSurveyCallback:d})},async identifyAndTrack(r){return await t(r)},trackPageView(r,o=void 0,a=void 0,d=!0){tt(r,o,a,d)},applyFeedbackStyles({button:r="",view:o=""}){window.UserLeap.feedbackCustomStyles=o,document.getElementById("sprig-feedback-style")&&j({document,elementId:"ul-custom-style",styleString:r,nonce:window.UserLeap.styleNonce}),n(document.querySelector(".ul-container-feedback"),o)},applyStyles(r){window.UserLeap.customStyles=r,n(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(We(c.contentDocument)[0])+"px")),i.eventEmitter.emit(i.SprigEvent.SurveyDimensions,{name:i.SprigEvent.SurveyDimensions,contentFrameWidth:c.clientWidth,contentFrameHeight:c.clientHeight}))},logoutUser(){var r;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),i.info(`Logging out user: ${window.UserLeap.userId} / vid: ${window.UserLeap.visitorId}`),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,i.localStorageHelper.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),et(),(r=i.modules.replay)==null||r.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){Zt(),window.UserLeap("dismissActiveSurvey",i.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}ce.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(N,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){i.reportAndRegister(r,o)},async _completeSessionReplay({surveyId:r,responseGroupUuid:o,eventDigest:a}){var d;return i.modules.replay?(d=i.modules.replay)==null?void 0:d._completeSessionReplay({surveyId:r,responseGroupUuid:o,eventDigest:a,headers:i.getHttpHeaders(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)}};Object.assign(window.UserLeap,s)};async function sr(e){const t=i.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",i.cspViolationHandler);const n=await i.sprigFetch(U("1",[O],"config"),{headers:t});if(document.removeEventListener("securitypolicyviolation",i.cspViolationHandler),!n.ok)return n.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",n.error),n.error&&window.UserLeap.reportError("applyRemoteConfig",n.error)),i.killNetworkRequests("Disabled: failed to fetch configuration"),e;const s=n.json;return s!=null&&s.disabled?(i.killNetworkRequests(`Disabled: ${s.disabled}`),{disabled:s.disabled}):Object.assign({},s,e)}const ar=e=>typeof e=="object"&&e&&"inner"in e&&!!e.inner&&typeof e.inner=="object";async function dr(e,t,n={},s={}){var m,w;const r=window.__cfg&&window.__cfg.mode,o=ge(),a=window.UserLeap.envId,d=window.document.documentElement,c=ar(t)?{inner:{message:(m=t.inner)==null?void 0:m.message,stack:(w=t.inner)==null?void 0:w.stack}}:{},p={mode:r,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:d.clientWidth,clientHeight:d.clientHeight,location:window.location.href,language:window.navigator.language,...n,...c},l={action:e,err:{message:t.message,stack:t.stack},meta:p,vid:o,envId:a,...s},u=await I(U("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(l),shouldDropOnRateLimit:!0});if(!u.ok)console.warn("[Sprig] (ERR-444) Failed to report error to API",t);else{const{presignedUrl:f}=u.json;i.uploadLogfile(f)}}async function lr(e){var n;if(!e)return;const t=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const s=await fetch(t,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(s.ok){const r=await s.json();return(n=r==null?void 0:r.upload)==null?void 0:n.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(e={}){const t=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";window.UserLeap.UPDATES=i.EVENTS,window.UserLeap("setPreviewKey",t);async function n(){var p;if(window.UserLeap.loaded)return;if(i.info("Loading sprig on page load"),window.UserLeap.reportError=dr,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},e,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const l in window.UserLeap._config)window.UserLeap[l]=window.UserLeap._config[l];if(!window.UserLeap.envId)if(window.UserLeap.appId)window.UserLeap.envId=window.UserLeap.appId;else throw new Error("Missing Environment id");window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const s=window.UserLeap.sampleRate;if(s){let l=P("sampled");if(l===null&&(l=Math.random()<s,S("sampled",l)),!l)return}else P("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 Ht(window.UserLeap,[]),window.UserLeap._queue.pause();for(let l=0;l<r.length;l++)window.UserLeap._queue.push(r[l]);const o=P("token");o?(window.UserLeap.token=o,window.UserLeap.visitorId=P("vid"),window.UserLeap.userId=P("uid"),window.UserLeap.partnerAnonymousId=P("aid")):(i.localStorageHelper.removeItem("userleap.ids"),et());const a=i.getHttpHeaders(window.UserLeap),d=te(a),c=await sr(e);Gt({isWeb:!d,reportingIntervalSeconds:c.metricsReportingEnabled||c.mobileMetricsReportingEnabled?c.metricsReportingIntervalSeconds:0,thresholds:c.metricThresholds,postMetrics:async l=>{var u;await I(U("1",[O],"metrics"),{body:l,method:"POST",headers:{"x-ul-replay-enabled":`${!!((u=i.modules.replay)!=null&&u.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),(p=i.modules.replay)==null||p.initializeReplay({viewDocument:window.document,maxReplayDurationSeconds:c.maxReplayDurationSeconds,replayNonce:window.UserLeap.replayNonce,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:c.replaySettings}),i.configureLogger(c.logBufferLimit,c.logLevel),or(c),await ir(c),window.UserLeap._queue.unpause(),i.eventEmitter.emit(i.SprigEvent.SDKReady,{mobileMetricsReportingEnabled:!!c.mobileMetricsReportingEnabled,metricsReportingInterval:c.metricsReportingIntervalSeconds||0,metricsThresholds:c.metricThresholds||[],maxMobileReplayDurationSeconds:c.maxMobileReplayDurationSeconds,mobileReplaySettings:c.mobileReplaySettings}),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}document.readyState==="complete"?n():window.attachEvent?window.attachEvent("onload",n):window.addEventListener("load",()=>{n()},!1)}class ee{constructor(){this.UPDATES=i.EVENTS}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,n){window.Sprig("setAttribute",t,n)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,n){window.Sprig("addListener",t,n)}removeListener(t,n){window.Sprig("removeListener",t,n)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(t){window.Sprig("setAttribute","!email",t)}setUserId(t){window.Sprig("setUserId",t)}setPartnerAnonymousId(t){window.Sprig("setPartnerAnonymousId",t)}track(t,n={},s={}){window.Sprig("track",t,n,s)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,n,s){window.Sprig("trackPageView",t,n,s)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,n){window.Sprig("setWindowDimensions",t,n)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}}const we={configure:e=>{if(!e.envId&&!e.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(e.envId||(e.envId=e.environmentId??""),e.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(ee.prototype).map(n=>{n!=="constructor"&&(window.Sprig[n]=ee.prototype[n])});const t=window.Sprig;return t.appId=e.envId,t._queue=[],window.UserLeap=t,cr(e),window.Sprig}},pr={sprig:we,SprigAPI:ee,configure:we.configure};exports.APP_ID=ct;exports.ConflictingWidgets=Fe;exports.DEFAULT_BORDER_COLOR=pt;exports.DEFAULT_WIDTH=Ce;exports.EMBED_MOBILE_MAX_WIDTH=gt;exports.ERROR_BORDER_COLOR=ut;exports.SprigAPI=ee;exports.calculateFrameDimensions=We;exports.core=pr;exports.resetScrollPosition=_t;exports.setSurveyStyles=j;exports.sprig=we;
|