@sprig-technologies/sprig-browser 2.39.3 → 2.39.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ "use strict";var vt=Object.defineProperty;var ft=(t,r,o)=>r in t?vt(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var q=(t,r,o)=>ft(t,typeof r!="symbol"?r+"":r,o);const i=require("./metricsReporter-DOjBAl52.cjs"),qe=()=>{try{return window.parent.Intercom}catch{return null}},Fe=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const t=qe();t&&(t.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),t.ul_wasVisible&&t("update",{hide_default_launcher:!0}))},enable:()=>{const t=qe();t&&(t.ul_wasVisible&&t("update",{hide_default_launcher:!1}),delete t.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class Qe{static disable(){Fe.forEach(r=>r.disable())}static enable(){Fe.forEach(r=>r.enable())}}const Ve="ul-view-sdk-script",ht=new Set(["ios","android"]),T="visitors",C="environments";async function x(t,r){var n,d,s;const{shouldDropOnRateLimit:o,...a}=r;a.headers=Object.assign(i.getHttpHeaders(window.UserLeap),a.headers);const e=await i.sprigFetch(t,{...a,shouldDropOnRateLimit:o});if(e.ok){const l=(n=e.headers)==null?void 0:n.get("Authorization"),c=l?l.split(" "):void 0,p=c&&c.length===2?c[1]:void 0,u=(d=e.headers)==null?void 0:d.get("x-ul-visitor-id");if(window.UserLeap.userId&&u===window.UserLeap.visitorId){const y=i.localStorageHelper.getItemObject("sprig.anon.env.vid.map");y&&y[window.UserLeap.envId]===u&&(delete y[window.UserLeap.envId],i.localStorageHelper.setItemObject("sprig.anon.env.vid.map",y))}p&&u&&(u!==window.UserLeap.visitorId||window.UserLeap.token!==p)&&(I("token",p),I("vid",u),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:u}),window.UserLeap.token=p,window.UserLeap.visitorId=u)}return(s=e.json)!=null&&s.logMessage&&console.warn(`[Sprig] ${e.json.logMessage}`),e}function I(t,r){const o=i.localStorageHelper.getItemObject("userleap.ids");let a=o[window.UserLeap.envId];a?a[t]=r:a={[t]:r},o[window.UserLeap.envId]=a,i.localStorageHelper.setItemObject("userleap.ids",o)}function ke(){return window.previewMode?"0":window.UserLeap.visitorId??""}function R(t,r,o){const a=[window.UserLeap._API_URL,"sdk",t];return r&&r.forEach(e=>{a.push(e),e===C?a.push(window.UserLeap.envId):e===T&&a.push(ke())}),o&&a.push(o),a.join("/")}const $=async(t,r,o)=>{var Ce,Pe,He,Me;const{context:a,delay:e,avatars:n,forceBrandedLogo:d,endCard:s,isFeedback:l=!1,heatmap:c,locale:p,layout:u,previewMode:y,productConfig:w,questions:g,responseGroupUid:v,surveyId:m,uuid:b,vid:f,sessionReplay:L,studyType:E,surveyVisitorAttributes:P}=t,h=i.getHttpHeaders(window.UserLeap),H=Q(h),_=pe(h);if(L)if(H)i.eventEmitter.emit(i.SprigEvent.ReplayCapture,{responseGroupUid:v,hasQuestions:!!(g!=null&&g.length),surveyId:m,uploadId:L.uploadId,replayType:L.replayDurationType??"before",seconds:L.replayDurationSeconds,generateVideoUploadUrlPayload:{mediaRecordingUid:i.v4(),mediaType:"screen",questionId:1,responseGroupUid:v,surveyId:m,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:v,surveyId:m,visitorId:f,replayParams:L,completeUploadHeaders:h,apiUrl:window.UserLeap._API_URL,triggerTimestamp:Date.now(),isStandalone:g.length===0})}if(c){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:U,replayParams:j,responseGroupUid:ge,surveyId:me}=c;await i.modules.replay.initializeReplay({maxReplayDurationSeconds:300,maxInflightRequests:window.UserLeap.maxInflightReplayRequests,teardownAfter:!0,apiUrl:window.UserLeap._API_URL,replaySettings:o}),i.modules.replay.tryReplayAction(()=>{var je;return(je=i.modules.replay)==null?void 0:je.scheduleCapture({apiUrl:window.UserLeap._API_URL,completeUploadHeaders:h,eventId:U,isHeatmap:!0,replayParams:j,responseGroupId:ge,surveyId:me,triggerTimestamp:Date.now(),visitorId:f})},"Error in scheduling/capturing replay")}if(f==null||!(g!=null&&g.length))return i.breadcrumbsLogger.info("CannotDisplaySurvey",{vid:f}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){i.breadcrumbsLogger.info("AlreadyDisplayingSurvey");const U="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(U),{success:!1,message:U,surveyState:"no survey"}}if(f!==window.UserLeap.visitorId&&b!==window.UserLeap.visitorId&&!window.previewMode){const U="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(U)),{success:!1,message:U,surveyState:"no survey"}}i.breadcrumbsLogger.info("ShowingSurvey",{surveyId:m}),(Ce=i.modules.replay)==null||Ce.RecordSurveyShown({id:m,userAgent:window.navigator.userAgent}),Qe.disable(),i.eventEmitter.emit(i.SprigEvent.SurveyWillPresent,{name:i.SprigEvent.SurveyWillPresent,"survey.id":m,layout:u});let M,O,k,X,Z=document.createElement("div");const xe=U=>{const{"view.version":j}=U;j!==h["x-ul-sdk-version"]&&Xe(),i.eventEmitter.removeListener("verify.view.version",xe)};i.eventEmitter.on("verify.view.version",xe),window.UserLeap.useMobileStyling=_,i.shouldDirectEmbed(h)?(M="ul-direct-embeded-frame",O=document.head,k=window,X=!1,(()=>{const U=i.getHttpHeaders(window.UserLeap),j=Q(U),ge=window.UserLeap.forceDirectEmbed,me=U["userleap-platform"]==="web";return j||ge&&me})()&&(Ye(m,l),Z.id=M,window.UserLeap.container.appendChild(Z),Ze(),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"presented"}),i.eventEmitter.emit(i.SprigEvent.SurveyPresented,{name:i.SprigEvent.SurveyPresented,"survey.id":m}))):{frameId:M,contentWinDocHead:O,contentWindow:k,hasOverlay:X,iframe:Z}=Lt({productConfig:w,useMobileStyling:_,surveyId:m,isFeedback:l,enableCspTrustedTypes:(Pe=window.UserLeap._config)==null?void 0:Pe.enableCspTrustedTypes}),window.UserLeap.frameId=M;const N={apiURL:window.UserLeap._API_URL,avatars:n,cards:g,configureExitOnOverlayClick:U=>{i.eventEmitter.once(i.SprigEvent.CloseSurveyOnOverlayClick,U)},context:a,endCard:s,envId:window.UserLeap.envId,eventEmitFn:i.eventEmitter.emit.bind(i.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:d,frame:Z,headers:h,layout:u,locale:p,mobileSDKVersion:window.UserLeap.mobileSDKVersion,previewKey:i.localStorageHelper.getItem("sprig.previewKey"),previewMode:y,productConfig:{framePosition:w==null?void 0:w.framePosition,desktopDisplay:w==null?void 0:w.desktopDisplay,placement:w==null?void 0:w.placement},responseGroupUid:v,startingQuestionIdx:(He=window.UserLeap.config)==null?void 0:He.startingQuestionIdx,studyType:E,styleNonce:window.UserLeap.styleNonce,surveyId:m,tabTitle:document.title,trackPageViewUrl:r,ulEvents:i.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:_,userId:b,viewDocument:k==null?void 0:k.document,viewWindow:k,visitorAttributes:{externalUserId:window.UserLeap.userId,email:window.UserLeap.email},surveyVisitorAttributes:P||{},...window.UserLeap._config};(Me=window.UserLeap._config)!=null&&Me.startingQuestionIdx&&(window.UserLeap._config={...window.UserLeap._config,startingQuestionIdx:null});const yt=(l?window.UserLeap.feedbackCustomStyles:window.UserLeap.customStyles)??w.customStyles;N.customStyles=yt,k&&(k.__cfg=N);const ue=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:N.path,Ae=document.getElementById(Ve);Ae&&Ae.remove();const we=function(){const U=document.createElement("script");return U.setAttribute("type","module"),window.UserLeap.nonce&&U.setAttribute("nonce",window.UserLeap.nonce),U.id=Ve,U}(),Oe=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(N.installationMethod==="web-npm"||N.installationMethod==="web-npm-bundled"){const{default:U}=await Promise.resolve().then(()=>require("./view-BE-QqXV6.cjs")).then(j=>j.view);U.configure(N),X&&window.UserLeap.container&&Oe()}else ue&&(we.src=`${ue}?t=${Date.now()}`,X&&we.addEventListener("load",()=>{window.UserLeap.container&&Oe()}),k==null||k.addEventListener("error",U=>{U.target instanceof HTMLScriptElement&&U.target.src===ue&&window.UserLeap.reportError("loadFrameScript",new Error("Frame script failed to load"))},{capture:!0,once:!0}));O==null||O.appendChild(we);const Te={success:!0,surveyState:"ready",surveyId:m,responseGroupUid:v};return window.UserLeap.isMobileSDK&&e&&(Te.delay=e),Te};function pe(t){var o;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const r=((o=window.UserLeap.windowDimensions)==null?void 0:o.width)??document.body.clientWidth;return Q(t)||r>10&&r<500}function Q(t){return ht.has(t["userleap-platform"])}const Ne=new WeakMap,St=(t,r)=>{try{return(a=>{var d,s;const e=Ne.get(a);if(e)return e;if(!((d=a.trustedTypes)!=null&&d.createPolicy))throw new Error("Trusted types not supported");const n=(s=a.trustedTypes)==null?void 0:s.createPolicy("sprig-sdk",{createHTML:l=>l,createScript:l=>l,createScriptURL:l=>l});return Ne.set(a,n),n})(r).createHTML(t)}catch(o){return console.warn("Could not create TrustedHTML object",o),t}},ce=(t,r,o=window)=>{var a;return r&&((a=o.trustedTypes)!=null&&a.createPolicy)?St(t,o):t},Re="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 ye="0px",Ye=(t,r,o)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container"+(r?" ul-container-feedback":""),t&&(window.UserLeap.container.dataset.studyId=t.toString());const a=rt();o&&a&&!window.UserLeap.useMobileStyling?a.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Xe=(t,r)=>{var a;Et();const o=window.UserLeap.container;if(o)try{(a=o.parentNode)==null||a.removeChild(o),window.UserLeap.container=null,I("trackStartUrl",null),i.eventEmitter.emit(i.SprigEvent.SurveyLifeCycle,{state:"dismissed"}),i.eventEmitter.emit(i.SprigEvent.SurveyClosed,{name:i.SprigEvent.SurveyClosed,initiator:t,"survey.id":parseInt(o.dataset.studyId),...r&&{studyType:r}})}catch(e){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${t} `+o),e instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",e)}},Ze=()=>{i.eventEmitter.once(i.SprigEvent.SurveyWillClose,({initiator:t,studyType:r})=>{i.eventEmitter.removeAllListeners(i.SprigEvent.CloseSurveyOnOverlayClick),Xe(t,r)})},bt=(t,r,o,a)=>{var p,u;const e={position:"fixed",bottom:"0px",right:ye,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%"},n=Object.assign({},r,window.UserLeap),{desktopDisplay:d}=r||{},s=d==="center-modal";let l;s&&(n.framePosition="center");let c=!1;if(o)(p=window.UserLeap.windowDimensions)!=null&&p.width?e.width=`${window.UserLeap.windowDimensions.width}px`:e.width="100%",(u=window.UserLeap.windowDimensions)!=null&&u.height?e.maxHeight=window.UserLeap.windowDimensions.height-20+"px":window.UserLeap.maxHeight?e.maxHeight=window.UserLeap.maxHeight:e.maxHeight=document.body.clientHeight-20+"px",["light","dark"].includes(n.overlayStyleMobile)&&(c=!0);else{e.width="360px",e.maxHeight=window.UserLeap.maxHeight||"66vh";const y=()=>{c=!0,l={margin:"auto",position:"static"}};if(a)s?y():l={position:"relative",height:"300px"};else switch(n.framePosition){case"bottomLeft":l={left:ye};break;case"topLeft":l={left:ye,top:0};break;case"topRight":l={top:0};break;case"center":y()}}return c&&((y,w)=>{const g={position:"fixed",overflow:"auto",top:"0px",left:"0px",display:"none",height:"100%",width:"100%",transition:"background-color 0.3s ease-out",zIndex:2147483646},v=w?y.overlayStyleMobile:y.overlayStyle;g["background-color"]=v==="light"?"rgba(255,255,255, 0.95)":"rgba(0,0,0,0.9)",w||(g.margin="auto"),window.UserLeap.container&&Object.assign(window.UserLeap.container.style,g)})(n,o),Object.assign(t.style,e,l),c},Lt=({productConfig:t,useMobileStyling:r,surveyId:o,isFeedback:a,enableCspTrustedTypes:e})=>{var w,g;const n=Re,d=a&&t.desktopDisplay==="slider";Ye(o,a,d),Ut();const s=document.createElement("iframe");s.id=n,s.setAttribute("title","Sprig User Feedback Dialog");const l=bt(s,t,r,a);Ze();let c=!1;s.setHeight=v=>{parseInt(s.style.height)==v&&c||(c=!0,s.style.height=`${v}px`,i.eventEmitter.emit(i.SprigEvent.SurveyHeight,{name:i.SprigEvent.SurveyHeight,contentFrameHeight:v,"survey.id":o}))};let p=!1;s.setWidth=v=>{parseInt(s.style.width)==v&&p||(p=!0,s.style.width=`${v}px`,i.eventEmitter.emit(i.SprigEvent.SurveyWidth,{name:i.SprigEvent.SurveyWidth,contentFrameWidth:v,"survey.id":o}))},(w=window.UserLeap.container)==null||w.appendChild(s),t&&(r?t.exitOnOverlayClickMobile:t.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":o});const u=(g=s.contentWindow)==null?void 0:g.document;if(u&&(u.open("text/html","replace"),u.write(ce("<!doctype html><head></head><body></body></html>",e,s.contentWindow)),u.close(),!r)){const v=u.body;v.style.display="flex",v.style.alignItems="center"}const y=u==null?void 0:u.head;return{frameId:n,contentWinDocHead:y,contentWindow:s.contentWindow,hasOverlay:l,iframe:s}},et={[i.SprigEvent.SurveyFadingOut]:()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{"background-color":"rgba(0,0,0,0)"})}},Ut=()=>{Object.entries(et).forEach(([t,r])=>{i.eventEmitter.on(t,r)})},Et=()=>{Object.entries(et).forEach(([t,r])=>{i.eventEmitter.off(t,r)})},D=t=>!!t&&t.nodeType===Node.ELEMENT_NODE,Be=t=>t instanceof HTMLElement||t instanceof SVGElement,Y=({document:t,elementId:r,styleString:o,nonce:a})=>{const e=t.getElementById(r);if(e)return void(e.textContent=o);const n=t.createElement("style");a&&(n.nonce=a),n.textContent=o,n.id=r,t.head.appendChild(n)},It=(t,r)=>{const o=r.querySelector(".sprig-question-body");if(!D(o))return t;const a=o.scrollHeight;return a<100?t:t-(a-100)},ze=(t,r)=>{const o=r.querySelector(t);if(!D(o))return 0;const a=getComputedStyle(o);return parseFloat(a.paddingLeft)+parseFloat(a.paddingRight)+(parseFloat(a.marginLeft)+parseFloat(a.marginRight))+(parseFloat(a.borderLeftWidth)+parseFloat(a.borderRightWidth))},tt=(t,r,o)=>{const a=t.querySelector(".ul-card__container"),e=t.querySelector(".ul-app");let n=600,d=360,s=0;if(D(a)&&D(e)){const l=a.querySelector(".ul-card--matrix_grid"),c=!l&&r&&o;try{c&&(e.style.width="360px"),n=a.clientHeight,n+=(y=>{const w=y.querySelector(".sprig-question-body"),g=y.querySelector(".ul-card"),v=y.querySelector(".ul-card-main-content"),m=y.querySelector(".ul-footer"),b=y.querySelector(".sprig-container");let f=0;return D(g)&&(f+=g.scrollHeight-g.clientHeight),D(v)&&(f+=v.scrollHeight-v.clientHeight),D(w)&&(f+=w.scrollHeight-w.clientHeight),D(m)&&D(b)&&b.clientHeight===0&&(f+=m.clientHeight),f})(t);const p=getComputedStyle(a);s=n;const u=parseFloat(p.marginTop)+parseFloat(p.marginBottom);n+=u+(parseFloat(p.borderTopWidth)+parseFloat(p.borderBottomWidth)),l&&(d=l.scrollWidth,d+=ze(".ul-card__container",t),d+=ze(".sprig-question-body",t))}finally{c&&e.style.removeProperty("width")}}return[n+1,d,It(s,t)]},rt=()=>S,B=()=>document.getElementById("sprig-feedback-container"),Se=()=>document.getElementById("sprig-feedback-loading-animation"),it=()=>!!document.getElementById(Re);let We=!1,S=null,A=null,_e=!1,G=null,F=null;const kt=["bottom-left","bottom-right","center-left","center-right"],re=()=>{var r;const t=window.UserLeap.container;return((r=t==null?void 0:t.parentElement)==null?void 0:r.id)==="sprig-feedback-loading-container"},nt=()=>document.getElementById("sprig-feedback-error-container"),ot=()=>{if(!S)return 0;const t=S==null?void 0:S.clientWidth,r=window.getComputedStyle(S);return t+parseInt(r.borderRightWidth||"0")+parseInt(r.borderLeftWidth||"0")},ie=t=>{const r=B();r&&(F!=null&&F.endsWith("right")?r.style.right=`${t}px`:F!=null&&F.endsWith("left")&&(r.style.left=`${t}px`))},ve=()=>{if(S&&(re()||nt())){i.eventEmitter.off(i.SprigEvent.SurveyAppeared,W),be();const t=ot();return ie(-t),!0}return!1},W=()=>{if(!S||!A)return;const t=Se();t&&t.remove(),S.style.height="auto",S.style.width="auto",A.disabled=!1,_e=!1},be=()=>{if(S&&!Se()){const t=(()=>{var o;if(Se())return;const r=document.createElement("div");return r.className="ul-loading-spinner-container",r.id="sprig-feedback-loading-animation",r.role="progressbar",r.setAttribute("aria-live","polite"),r.setAttribute("aria-busy","true"),r.setAttribute("aria-label","Processing..."),r.innerHTML=ce(`
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
+ `,(o=window.UserLeap._config)==null?void 0:o.enableCspTrustedTypes),r})();t&&(S.style.height="300px",S.style.width="360px",S.appendChild(t))}},$e=()=>{S&&A&&(ie(0),A.disabled=!0,_e=!0)},st=async(t,r,o)=>{const{buttonTheme:a,customStyles:e,eventId:n,placement:d,desktopDisplay:s,feedbackLabel:l,surveyUuid:c,surveyId:p}=t;window.UserLeap.feedbackCustomStyles=void 0;let u=B();if(u){if(!r&&n===G)return;u.remove(),i.eventEmitter.off(i.EVENTS.SURVEY_FADING_OUT,ve)}G=n,Y({document,elementId:"sprig-feedback-style",styleString:'.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}',nonce:window.UserLeap.styleNonce}),Y({document,elementId:"ul-custom-style",styleString:e??"",nonce:window.UserLeap.styleNonce}),We=s==="center-modal",F=d;const[y,w]=d.split("-");(b=>{if(B()||!kt.includes(b))return;const[f,L]=b.split("-"),E=document.createElement("div");E.id="sprig-feedback-container",E.classList.add(`sprig-feedback-container-${L}`,`sprig-feedback-container-${f}`),document.body.appendChild(E)})(d),u=B(),A=document.createElement("button");const g=document.createElement("div");g.className="sprig-feedback-button-label",g.innerText=l,A.appendChild(g),A.id="sprig-feedback-button",A.classList.add(`sprig-feedback-button-${w}`,`sprig-feedback-button-${y}`,`sprig-feedback-button-${a}`,"fade-in-transition"),i.eventEmitter.on(i.EVENTS.SURVEY_FADING_OUT,ve),A.addEventListener("click",async()=>{const b=document.getElementById("sprig-feedback-error-container");if(it()||nt()){if(ve()){i.eventEmitter.emit(i.SprigEvent.SurveyCloseRequested,{name:i.SprigEvent.SurveyCloseRequested,initiator:i.DismissReason.FeedbackClosed,studyType:"feedbackButton","survey.id":p}),i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:i.DismissReason.FeedbackClosed,studyType:"feedbackButton","survey.id":p});const L=B();b&&L&&(L.remove(),G=null,S=null)}return}if(pe(i.getHttpHeaders(window.UserLeap))||_e||$e(),r)return S&&S.classList.add("sprig-feedback-loading-container-previews"),await $(r),void W();const f=await(async L=>{const E=await x(R("1",[T],"startFeedbackStudy"),{body:JSON.stringify({surveyUuid:L}),method:"POST"});return E.ok?E.json:null})(c);if(f)i.eventEmitter.once(i.SprigEvent.SurveyAppeared,W),$({...f,studyType:"feedbackButton"},o);else if(S){const L=Rt();S.appendChild(L),W(),S.style.height="300px",S.style.width="360px"}}),u==null||u.appendChild(A),i.eventEmitter.emit(i.SprigEvent.FeedbackButtonLoaded,{name:i.SprigEvent.FeedbackButtonLoaded,"survey.id":p});const{useMobileStyling:v,_config:{border:m}}=window.UserLeap;if(We||v)ie(0);else{const b=document.createElement("div");b.id="sprig-feedback-loading-container",b.className=`sprig-feedback-loading-container sprig-feedback-loading-container-${w}`,b.style.setProperty("--feedback-border",m),S=b,be(),u==null||u.appendChild(b);const f=ot();ie(-f)}window.UserLeap._config.isOnQuestionsTab&&r&&!re()&&S&&($e(),be(),S&&S.classList.add("sprig-feedback-loading-container-previews"),$(r),W())},Rt=()=>{var o;const t=document.createElement("div");t.id="sprig-feedback-error-container",t.innerHTML=ce(`<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>`,(o=window.UserLeap._config)==null?void 0:o.enableCspTrustedTypes);const r=document.createElement("h3");return r.className="sprig-feedback-error-text",r.innerText="There was an error while loading the survey",t.appendChild(r),t},Le=new class{constructor(){q(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(t){try{return!(!t||typeof t!="object"||Array.isArray(t))&&(Object.keys(this._ldData).forEach(r=>{delete this._ldData[r]}),Object.keys(t).forEach(r=>this._ldData[`!launch_darkly_${r}`]=(t[r]??0)+1),!0)}catch(r){return r instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",r),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(Le);const te=new class{constructor(){q(this,"_optimizelyData",{})}setOptimizelyExperiment(t,r=!0){if(!t||typeof t!="object")return!1;const{experiments:o}=t;try{return r&&Object.keys(this._optimizelyData).map(a=>{delete this._optimizelyData[a]}),o&&o.map(a=>{const{id:e,variation:n}=a,d=this.transformExperimentId(e);n&&typeof n=="string"&&(this._optimizelyData[d]=n)}),!0}catch(a){return a instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",a),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(t){return this._optimizelyData[this.transformExperimentId(t)]}transformExperimentId(t){return"!optimizely_experiments_"+t}getAndSetWebOptimizelyExperiments(){var t;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const r=(t=window.optimizely.get("state"))==null?void 0:t.getExperimentStates({isActive:!0});if(r){const o=Object.keys(r).map(a=>{var e,n;return(e=r[a].variation)!=null&&e.name?{id:a,variation:(n=r[a].variation)==null?void 0:n.name}:{id:a,variation:"Original"}});return this.setOptimizelyExperiment({experiments:o},!1),!0}return!1}return!1}catch(r){return r instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",r),!1}}};Object.freeze(te);class _t{constructor(r,o){q(this,"paused");q(this,"queue");q(this,"ul");this.ul=r,this.paused=!1,this.queue=[],this.flush(o)}flush(r){const o=r.length;if(o)for(let a=0;a<o;a++)this.push(r[a])}isPaused(){return this.paused}pause(){this.paused=!0}unpause(){this.paused=!1;const r=this.queue.slice();this.empty(),this.flush(r)}push(r){if(this.paused)this.queue.push(r);else if(r instanceof Function)r();else{const o=Array.prototype.slice.call(r,1),a=r[0],e=this.ul[a];e instanceof Function?e.apply(this.ul,o):a&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",a)}}perform(r){if(this.paused){let o=()=>{};const a=new Promise(function(e){o=function(){e(r())}});return this.queue.push(o),a}return r()}empty(){this.queue.length=0}}let at,dt;const Ue=t=>{let r=0,o=t.firstElementChild;for(;o;)r+=Ue(o),o.shadowRoot&&(r+=Ue(o.shadowRoot)),o=o.nextElementSibling,r++;return r},Ge=()=>{at.report(Ue(document.body)),dt.report(document.documentElement.innerHTML.toString().length)},Ee=(t,r)=>{const o=performance.now();document.hidden?setTimeout(()=>Ee(t,r),t):setTimeout(()=>{const a=performance.now()-o;r.report(a/1e3),setTimeout(()=>Ee(t,r),t)},0)};let ne,oe,se,ae,Ke,V={};const ee=(t,r=1)=>{const{name:o}=t;V[o]=(V[o]||0)+r},lt=t=>{let r=1;return t.childNodes.forEach(o=>{r+=lt(o)}),r},Je=t=>{let r=0;return t.forEach(o=>{r+=lt(o)}),r},Dt=t=>{switch(t.type){case"childList":return ee(ne,Je(t.addedNodes)),void ee(oe,Je(t.removedNodes));case"attributes":return void ee(se);case"characterData":return void ee(ae)}},xt=t=>t.forEach(Dt),At=()=>{ne.report(V[ne.name]||0),oe.report(V[oe.name]||0),se.report(V[se.name]||0),ae.report(V[ae.name]||0),V={}},Ot=(t=1e3)=>{ne=i.registerMetric("sdk_mutations_nodes_added"),oe=i.registerMetric("sdk_mutations_nodes_removed"),se=i.registerMetric("sdk_mutations_attributes_changed"),ae=i.registerMetric("sdk_mutations_character_data"),Ke=new MutationObserver(xt),Ke.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(At,t)},Tt=({isWeb:t,reportingIntervalSeconds:r,thresholds:o,postMetrics:a})=>{i.registerThresholds(o,(e,n)=>{var d,s;if((d=i.modules.replay)!=null&&d.isReplayRecording()){const l=`Value: ${e} on ${n.metric} violated threshold of ${n.type} ${n.value}`;(s=i.modules.replay)==null||s.disableRecording("Threshold violated",new Error(l),{reportError:!1}),window.UserLeap.reportError("Sdk Performance Metric threshold violated",new Error("Sdk Performance Metric threshold violated"),{metricName:n.metric,type:n.type,value:n.value},{metricName:n.metric}),i.disableThresholdChecking()}}),i.initPerformanceReporting({reportingIntervalSeconds:r,postMetrics:a}),t&&(((e=1e3)=>{const n=i.registerMetric("sdk_event_queue_latency_seconds");Ee(e,n)})(),((e=1e4)=>{at=i.registerMetric("sdk_dom_nodes_count"),dt=i.registerMetric("sdk_page_html_characters"),Ge(),setInterval(Ge,e)})(),Ot())},Ct="test",Pt=["popState","pushState","replaceState"];let De,K;const de={},z="!email",pt="pageUrl";let fe=window.location.href;function J(t){var s,l;const{pageUrlEvents:r,interactiveEvents:o,dismissOnPageChange:a,platform:e}=window.UserLeap._config;if(e&&e!=="web")return;fe!==window.location.href&&i.breadcrumbsLogger.navigation("LocationChange",{from:fe,to:window.location.href}),fe=window.location.href;const n=wt().trackStartUrl,d=n?String(n):null;r&&mt(window.location.href),o&&(ut(),Ht()),rt()&&(()=>{if(re())return;const c=B();c&&(i.checkUrlStillMatching(G)||(c.remove(),G=null,S=null))})(),i.sessionStorageHelper.getItem("sprig.isCapturingHeatmap")&&((l=(s=i.modules.replay)==null?void 0:s.checkPendingHeatmapsUrl())==null||l.then(c=>{var p;c&&((p=i.modules.replay)==null||p.uploadReadyPendingCaptures(!0))})),!re()&&a&&d&&d!==window.location.href&&t&&Pt.includes(t.type)&&window.UserLeap("dismissActiveSurvey",i.DismissReason.PageChange)}const ct={capture:!0},Ht=()=>{const t=window.UserLeap._config.interactiveEvents.filter(o=>i.checkUrlMatch(o,window.location.href)).map(o=>{const{name:a,properties:e}=o,{selector:n,innerText:d}=e;return n?s=>{if(Be(s.target))try{s.target.closest(n)&&window.UserLeap("track",a)}catch{}return!1}:s=>(Be(s.target)&&s.target.innerText===d&&window.UserLeap("track",a),!1)}),r=o=>t.forEach(a=>a(o));window.UserLeap._config.interactiveEventsHandler=r,window.addEventListener("click",r,ct)},ut=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,ct),delete window.UserLeap._config.interactiveEventsHandler};function wt(){const t=i.localStorageHelper.getItemObject("userleap.ids");return t&&t[window.UserLeap.envId]||{}}function gt(){if(window.previewMode)return;const t=i.localStorageHelper.getItemObject("sprig.anon.env.vid.map")||{},r=t[window.UserLeap.envId];window.UserLeap.visitorId=r||i.v4(),i.breadcrumbsLogger.info("NewVid",{vid:window.UserLeap.visitorId}),I("vid",window.UserLeap.visitorId),r||(t[window.UserLeap.envId]=window.UserLeap.visitorId,i.localStorageHelper.setItemObject("sprig.anon.env.vid.map",t)),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}function mt(t,r,o,a){var e,n;try{if(t.endsWith("mock_snippet.html"))return;i.breadcrumbsLogger.info("PageView",{url:t});const d=(e=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:e.getAttribute("content");(n=i.modules.replay)==null||n.RecordPageView({...d&&{description:d},url:t,referrer:document.referrer,pageTitle:document.title});const s=window.UserLeap._config.pageUrlEvents;let l=!1;if(s&&s.length)for(let p=0;p<s.length&&(l=i.checkUrlMatch(s[p],t),!l);p++);if(!l)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",t);const c={url:t};a&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",pt,r,c,o])}catch(d){d instanceof Error&&(d.stack=t,window.UserLeap.reportError("trackPageView",d)),console.warn("[Sprig] (ERR-428) Failed to track page view",d)}}function Mt(){const t="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in t&&(t.pushState=(r=>function(...o){const a=r.apply(this,o),e=new Event("pushState");return window.dispatchEvent(e),J(e),a})(t.pushState)),"replaceState"in t&&(t.replaceState=(r=>function(...o){const a=r.apply(this,o),e=new Event("replaceState");return window.dispatchEvent(e),J(e),a})(t.replaceState)),["hashchange","popstate"].forEach(r=>window.addEventListener(r,J,!0))}async function he(t,r){const o=ke();t&&!r&&(window.UserLeap._config.mode=Ct);const a=pe(i.getHttpHeaders(window.UserLeap)),e=await x(function(n){const d=new URL(R("1",[C],"questions"));return Object.entries(n||{}).forEach(([s,l])=>{l&&d.searchParams.append(s,String(l))}),d.toString()}({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:a,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:t==null?void 0:t.surveyId,surveytemplateid:t==null?void 0:t.surveyTemplateId,vid:o}),{shouldDropOnRateLimit:!0});if(!e.ok)return e.reportError&&e.error&&(console.warn("[Sprig] (ERR-414) Failed to request questions from the server",e.error),window.UserLeap.reportError("getQuestions",e.error)),{success:!1,surveyState:"no survey"};if(e.json.delay&&await i.delay(e.json.delay),!e.json.isFeedback)return $(e.json,K,De);{const{feedbackLabel:n,productConfig:d,surveyUuid:s,feedbackCustomStyles:l}=e.json,{buttonTheme:c,placement:p,desktopDisplay:u}=d;st({customStyles:l,buttonTheme:c,desktopDisplay:u,eventId:0,feedbackLabel:n,placement:p,surveyUuid:s,surveyId:t==null?void 0:t.surveyId},e.json)}}function jt(t){if(!t)return;window.UserLeap._config=t,t.mute&&window.UserLeap._queue.pause();const{interactiveEvents:r,pageUrlEvents:o,dismissOnPageChange:a}=t;r&&function(e){let n=e.length;for(;n;){const d=Math.floor(Math.random()*n);n-=1;const s=e[n];e[n]=e[d],e[d]=s}}(r),(r||o||a)&&(Mt(),J())}const qt=function(t){if(!window.UserLeap)return;const r=async(e={})=>{var b,f,L,E,P;const{userId:n,anonymousId:d,metadata:s={},properties:l,showSurveyCallback:c}=e;let{eventName:p}=e;if(window.UserLeap.debugMode&&p!==pt&&console.info("[DEBUG] Sprig track",e),t.mode==="test")return;const u=i.localStorageHelper.getItem("sprig.previewKey")??void 0;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!n){const h="[Sprig] - Skipping tracking without userId";return console.warn(h),{success:!1,message:h,surveyState:"no survey"}}if(!p||p.trim().length===0){p=p?String(p):"";const h="[Sprig] - Invalid event name "+p;return console.warn(h),{success:!1,message:h,surveyState:"no survey"}}const y=K??window.location.href;s.url||(s.url=y),I("trackStartUrl",y),(f=(b=window.UserLeap)==null?void 0:b._config)!=null&&f.optimizelyEnabled&&(Q(i.getHttpHeaders(window.UserLeap))||te.getAndSetWebOptimizelyExperiments(),s.optimizelyExperiments=Object.assign({},te.getAllOptimizelyExperiments())),(E=(L=window.UserLeap)==null?void 0:L._config)!=null&&E.launchDarklyEnabled&&(s.launchDarklyFlags=Le.getAllLaunchDarklyVariations()),n&&(window.UserLeap.userId=n),d&&(window.UserLeap.partnerAnonymousId=d),l&&(s.eventProperties=l),(P=i.modules.replay)==null||P.RecordEvent({name:p,url:s.url}),i.breadcrumbsLogger.info("TrackEvent",{eventName:p});const w=window.UserLeap.delayingSurvey||it()?await x(R("1",[T],"events/batch"),{body:JSON.stringify({events:[{event:p,metadata:s}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await x(R("1",[T],"events"),{body:JSON.stringify({event:p,metadata:s,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"}}n&&I("uid",n),d&&I("aid",d);const g=w.json;g.invalidPreviewKey&&i.localStorageHelper.removeItem("sprig.previewKey");const v=s.trackPageView?s.url:void 0;return g!=null&&g.feedbackButton&&st(g.feedbackButton,void 0,v),await async function(h,H){var M,O;let _=!0;return!(H&&((M=h==null?void 0:h.json)!=null&&M.surveyId)&&(window.UserLeap.delayingSurvey=!0,_=await H(h.json.surveyId),window.UserLeap.delayingSurvey=!1,!_))&&((O=h==null?void 0:h.json)!=null&&O.delay&&!window.UserLeap.isMobileSDK&&(window.UserLeap.delayingSurvey=!0,await i.delay(h.json.delay),window.UserLeap.delayingSurvey=!1),_)}(w,c)?function(h){if(!window.UserLeap._config.dismissOnPageChange)return!0;const H=new URL(h),_=new URL(K??window.location.href);return H.hostname===_.hostname&&H.pathname===_.pathname}(y)?$(g,v,De):{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"}},o=(e,n)=>{var s;const d=(s=e==null?void 0:e.querySelector(`[id="${Re}"]`))==null?void 0:s.contentDocument;d&&Y({document:d,elementId:"ul-custom-style",styleString:n})},a={displaySurvey:async e=>(console.warn("[Sprig] displaySurvey should only be used to debug your studies; not intended for production usage."),window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),he({surveyId:e},!0)),_previewSurvey(e){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),he({surveyTemplateId:e},!1)},_reviewSurvey(e){window.UserLeap("dismissActiveSurvey",i.DismissReason.Override),he({surveyId:e},!1)},previewSurvey(e){a._previewSurvey(e)},reviewSurvey(e){a._reviewSurvey(e)},mute(){window.UserLeap._queue.pause()},unmute(){window.UserLeap._queue.unpause()},setVisitorToken(){console.warn("[Sprig] setVisitorToken is deprecated.")},dismissActiveSurvey(e=i.DismissReason.API){window.UserLeap.container&&(e===i.DismissReason.Closed&&window.Sprig.trackHistory&&window.Sprig.trackHistory({event:"closed"}),i.eventEmitter.emit(i.SprigEvent.SurveyCloseRequested,{name:i.SprigEvent.SurveyCloseRequested,initiator:e,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}),i.eventEmitter.emit(i.SprigEvent.SurveyWillClose,{name:i.SprigEvent.SurveyWillClose,initiator:e,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},async setAttribute(e,n){if(!e||!n&&n!==0&&n!==!1){const d="[Sprig] - Disregarding empty attribute / value provided";return console.warn(d),{success:!1,message:d}}return this.setAttributes({[e]:n})},async setAttributes(e){if(e==null||Object.keys(e).length===0){const n="[Sprig] - Disregarding empty attributes provided";return console.warn(n),{success:!1,message:n}}return this.identifyAndSetAttributes({attributes:e})},async identifyAndSetAttributes(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig identifyAndSetAttributes",e),t.mode==="test")return;if(e===null||typeof e!="object"||!(e.userId||e.anonymousId||e.attributes)){const p="[Sprig] - Disregarding empty payload provided";return console.warn(p),{success:!1,message:p}}const{userId:n,anonymousId:d,attributes:s}=e;if(t.requireUserIdForTracking&&!window.UserLeap.userId&&!n){const p="[Sprig] - Skipping tracking without userId";return console.warn(p),{success:!1,message:p}}if(s){s.email&&!s[z]&&(s[z]=s.email,delete s.email);const p=Object.keys(s);for(const u of p)s[u]===de[u]&&delete s[u]}if(!(s&&Object.keys(s).length!==0||n&&window.UserLeap.userId!==n||d&&window.UserLeap.partnerAnonymousId!==d))return{success:!0};const l={};let c;return n&&(l.userId=window.UserLeap.userId=n),d&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=d),s&&Object.keys(s).length>0?(c=await x(R("1",[C,T],"attributes"),{body:JSON.stringify(s),method:"PUT"}),c.ok?Object.assign(de,s):c.reportError&&(console.warn("[Sprig] (ERR-432) identifyAndSetAttributes failed",c.error),c.error&&window.UserLeap.reportError("identifyAndSetAttributes",c.error))):c=await x(R("1",[C,T]),{body:JSON.stringify(l),method:"PUT"}),s&&s[z]&&(window.UserLeap.email=s[z]),c.ok&&(n&&I("uid",n),d&&I("aid",d)),{success:!!c.ok}},async removeAttributes(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",e),t.mode==="test")return;if(e==null||e.length===0){const d="[Sprig] - Disregarding empty attributes provided";return console.warn(d),{success:!1,message:d}}if(t.requireUserIdForTracking&&!window.UserLeap.userId){const d="[Sprig] - Skipping tracking without userId";return console.warn(d),{success:!1,message:d}}const n=await x(R("1",[C,T],"attributes"),{body:JSON.stringify({delete:e}),method:"DELETE"});return!n.ok&&n.reportError&&(console.warn("[Sprig] (ERR-433) Remove attributes failed",n.error),n.error&&window.UserLeap.reportError("removeAttributes",n.error)),{success:!!n.ok}},async addSurveyListener(e){i.eventEmitter.on(i.SprigEvent.SurveyLifeCycle,e)},async removeSurveyListener(e){i.eventEmitter.removeListener(i.SprigEvent.SurveyLifeCycle,e)},async addListener(e,n){i.eventEmitter.on(e,n)},async removeListener(e,n){i.eventEmitter.removeListener(e,n)},async removeAllListeners(){i.eventEmitter.removeAllListeners()},setPreviewKey(e){e&&typeof e=="string"&&i.localStorageHelper.isStorageAvailable&&e&&i.localStorageHelper.setItem("sprig.previewKey",e)},async setUserId(e){var s;if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setUserId",e),e==null){const l=`[Sprig] - Invalid userId ${e}`;return console.warn(l),{success:!1,message:l}}if(t.mode==="test"||e===window.UserLeap.userId)return;window.UserLeap.userId=e;const n=window.UserLeap.visitorId,d=await x(R("1",[C,T]),{body:JSON.stringify({userId:e}),method:"PUT"});d.ok?(n!==window.UserLeap.visitorId&&((s=i.modules.replay)==null||s.clearUserReplayData()),I("uid",e)):d.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",d.error),d.error&&window.UserLeap.reportError("setUserId",d.error))},async setPartnerAnonymousId(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig setPartnerAnonymousId",e),e==null){const n=`[Sprig] - Invalid partnerAnonymousId ${e}`;return console.warn(n),{success:!1,message:n}}return window.UserLeap.partnerAnonymousId=e,I("aid",e),{success:!0}},track:async(e,n,d={},s=void 0)=>r({eventName:e,properties:n,metadata:d,showSurveyCallback:s}),identifyAndTrack:async e=>await r(e),trackPageView(e,n=void 0,d=void 0,s=!0){K=e,mt(e,n,d,s)},applyFeedbackStyles({button:e="",view:n=""}){window.UserLeap.feedbackCustomStyles=n,document.getElementById("sprig-feedback-style")&&Y({document,elementId:"ul-custom-style",styleString:e,nonce:window.UserLeap.styleNonce}),o(document.querySelector(".ul-container-feedback"),n)},applyStyles(e){window.UserLeap.customStyles=e,o(window.UserLeap.container,e)},setWindowDimensions(e,n){var y,w;const d=typeof e=="string"?parseInt(e,10):e,s=typeof n=="string"?parseInt(n,10):n;isNaN(d)||isNaN(s)||(window.UserLeap.windowDimensions={width:d,height:s});const l=i.getHttpHeaders(window.UserLeap),c=pe(l),p=l["userleap-platform"]==="web";if(!window.UserLeap.frameId)return;const u=document.getElementById(window.UserLeap.frameId);u&&(window.UserLeap.useMobileStyling&&((y=window.UserLeap.windowDimensions)!=null&&y.width&&(u.style.width=`${window.UserLeap.windowDimensions.width}px`),(w=window.UserLeap.windowDimensions)!=null&&w.height&&(u.style.maxHeight=window.UserLeap.windowDimensions.height-20+"px"),u.contentDocument&&(u.style.height=String(tt(u.contentDocument,p&&!c,i.shouldDirectEmbed(l))[0])+"px")),i.eventEmitter.emit(i.SprigEvent.SurveyDimensions,{name:i.SprigEvent.SurveyDimensions,contentFrameWidth:u.clientWidth,contentFrameHeight:u.clientHeight,"survey.id":parseInt(window.UserLeap.container.dataset.studyId)}))},logoutUser(){var e;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig logout"),i.breadcrumbsLogger.info("LogOut",{vid:window.UserLeap.visitorId,userId:window.UserLeap.userId}),window.UserLeap.visitorId=null,window.UserLeap.userId=null,window.UserLeap.partnerAnonymousId=null,window.UserLeap.token=null,window.UserLeap.email=null,i.localStorageHelper.removeItem("userleap.ids"),window.UserLeap._queue.isPaused()&&window.UserLeap._queue.empty(),gt(),(e=i.modules.replay)==null||e.clearUserReplayData(),window.UserLeap._queue.unpause()},teardown(){["hashchange","popstate"].forEach(e=>window.removeEventListener(e,J,!0)),window.UserLeap._config.interactiveEvents&&ut(),window.UserLeap("dismissActiveSurvey",i.DismissReason.API),delete window.UserLeap,delete window.Sprig,delete window._Sprig},integrateOptimizely(e,n=!0){var d,s;if((s=(d=window.UserLeap)==null?void 0:d._config)!=null&&s.optimizelyEnabled)try{const l=typeof e=="string"?JSON.parse(e):e;te.setOptimizelyExperiment(l,n)}catch(l){console.warn("[Sprig] Error with integrating Optimizely data"),l instanceof Error&&window.UserLeap.reportError("integrateOptimizely",l)}else console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.")},integrateOptimizelyClient(e){var n,d;if(!((d=(n=window.UserLeap)==null?void 0:n._config)!=null&&d.optimizelyEnabled))return void console.warn("[SPRIG] Optimizely integration is currently not enabled for your product.");e.notificationCenter.addNotificationListener("ACTIVATE:experiment, user_id,attributes, variation, event",({experiment:s,variation:l})=>{const c={experiments:[{id:s.id,variation:l.key}]};window.UserLeap("integrateOptimizely",c,!1)})},importLaunchDarklyData(e){var n,d;(d=(n=window.UserLeap)==null?void 0:n._config)!=null&&d.launchDarklyEnabled?Le.setLDFlagsVariations(e):console.warn("[SPRIG] LaunchDarkly integration is currently not enabled for your product.")},setVisitorAttribute:(e,n)=>(console.warn("[Sprig] setVisitorAttribute is deprecated. Please use setAttribute"),a.setAttribute(e,n)),setEmail:async e=>a.setAttribute(z,e),setVisitorEmail:async e=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),a.setEmail(e)),_generateVideoUploadUrl:async e=>async function(n){var s;if(!n)return;const d=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const l=await fetch(d,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(l.ok){const c=await l.json();return(s=c==null?void 0:c.upload)==null?void 0:s.url}return null}catch(l){console.warn("[Sprig] Error with generating video upload url"),l instanceof Error&&window.UserLeap.reportError("generateVideoUploadUrl",l)}}(e),_reportMetric(e,n){i.reportAndRegister(e,n)},_completeSessionReplay:async({surveyId:e,responseGroupUuid:n,eventDigest:d})=>{var s;return i.modules.replay?(s=i.modules.replay)==null?void 0:s._completeSessionReplay({surveyId:e,responseGroupUuid:n,eventDigest:d,headers:i.getHttpHeaders(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)},pauseReplayRecording(){var e,n,d,s;(n=(e=i.modules.replay)==null?void 0:e.isReplayPaused)!=null&&n.call(e)||((s=(d=i.modules.replay)==null?void 0:d.recordReplayPaused)==null||s.call(d))},resumeReplayRecording(){var e,n,d,s,l,c;(n=(e=i.modules.replay)==null?void 0:e.isReplayPaused)!=null&&n.call(e)&&((s=(d=i.modules.replay)==null?void 0:d.recordReplayResumed)==null||s.call(d),(c=(l=i.modules.replay)==null?void 0:l.recordFullSnapshot)==null||c.call(l))}};Object.assign(window.UserLeap,a)};async function Ft(t,r,o={},a={}){const e=window.__cfg&&window.__cfg.mode,n=ke(),d=window.UserLeap.envId,s=window.document.documentElement,l={mode:e,screenWidth:window.screen.width,screenHeight:window.screen.height,clientWidth:s.clientWidth,clientHeight:s.clientHeight,location:K??window.location.href,language:window.navigator.language,...o},c={action:t,breadcrumbs:i.breadcrumbsLogger.breadcrumbs,err:{message:`${r==null?void 0:r.name} - ${r==null?void 0:r.message}`,stack:r==null?void 0:r.stack},meta:l,vid:n,envId:d,...a};(await x(R("1",null,"errors"),{method:"POST",headers:{"x-ul-error":window.btoa(`userleap-${Date.now()}-error`)},body:JSON.stringify(c),shouldDropOnRateLimit:!0})).ok||console.warn("[Sprig] (ERR-444) Failed to report error to API",r)}function Vt(t={}){var a;(a=window.SprigLoggerCallback)==null||a.call(window,"Initializing Sprig");const r=new URLSearchParams(window.location.search).get("sprigPreviewKey")??"";async function o(){var u,y,w,g,v;if(window.UserLeap.loaded)return;if((u=window.SprigLoggerCallback)==null||u.call(window,"Loading Sprig"),window.UserLeap.reportError=Ft,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},t,window.UserLeap.config),window.UserLeap.delayingSurvey=!1,window.UserLeap._config&&typeof window.UserLeap._config=="object")for(const m in window.UserLeap._config)window.UserLeap[m]=window.UserLeap._config[m];if(window.Sprig.outstandingTransactionLimit!==void 0&&(t.outstandingTransactionLimit=window.Sprig.outstandingTransactionLimit),!window.UserLeap.envId){if(!window.UserLeap.appId)throw new Error("Missing Environment id");window.UserLeap.envId=window.UserLeap.appId}window.UserLeap.debugMode&&console.info("[DEBUG] Sprig debug mode enabled");const e=wt(),n=window.UserLeap.sampleRate;let d=e.sampled;if(n){if(d===null&&(d=Math.random()<n,I("sampled",d)),!d)return}else d!==null&&I("sampled",null);window.UserLeap._API_URL||(window.UserLeap._API_URL="https://api.sprig.com");const s=[...window.UserLeap._queue];window.UserLeap._queue=new _t(window.UserLeap,[]),window.UserLeap._queue.pause();for(let m=0;m<s.length;m++)window.UserLeap._queue.push(s[m]);const l=e.token;l?(window.UserLeap.token=l,window.UserLeap.visitorId=e.vid??null,window.UserLeap.userId=e.uid??null,window.UserLeap.partnerAnonymousId=e.aid??null):gt();const c=Q(i.getHttpHeaders(window.UserLeap));(y=window.SprigLoggerCallback)==null||y.call(window,"Sprig fetching config");const p=await async function(m){var E,P;const b=i.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",i.cspViolationHandler);const f=await i.sprigFetch(R("1",[C],"config"),{headers:b});if(document.removeEventListener("securitypolicyviolation",i.cspViolationHandler),!f.ok)return(E=window.SprigLoggerCallback)==null||E.call(window,"Sprig config fetch failed"),f.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",f.error),f.error&&window.UserLeap.reportError("applyRemoteConfig",f.error)),i.killNetworkRequests("Disabled: failed to fetch configuration"),m;const L=f.json;return L!=null&&L.disabled?((P=window.SprigLoggerCallback)==null||P.call(window,"Sprig config fetch disabled"),i.killNetworkRequests(`Disabled: ${L.disabled}`),{disabled:L.disabled}):Object.assign({},L,m)}(t);if((w=window.SprigLoggerCallback)==null||w.call(window,"Sprig fetched config"),Tt({isWeb:!c,reportingIntervalSeconds:p.metricsReportingEnabled||p.mobileMetricsReportingEnabled?p.metricsReportingIntervalSeconds:0,thresholds:p.metricThresholds,postMetrics:async m=>{var b;await x(R("1",[C],"metrics"),{body:m,method:"POST",headers:{"x-ul-replay-enabled":`${!!((b=i.modules.replay)!=null&&b.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),!c){const m=p.alwaysOnReplay?{userAgent:window.navigator.userAgent,surveyId:p.alwaysOnReplay.surveyId,responseGroupUuid:p.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.39.4",maxDurationSeconds:p.alwaysOnReplay.maxDurationSeconds}:void 0;await((g=i.modules.replay)==null?void 0:g.initializeReplay({maxReplayDurationSeconds:p.maxReplayDurationSeconds,maxInflightRequests:window.UserLeap.maxInflightReplayRequests??2,replaySettings:p.replaySettings,apiUrl:window.UserLeap._API_URL,alwaysOnConfig:m})),De=p.replaySettings}qt(p),await jt(p),window.UserLeap._queue.unpause(),(v=window.SprigLoggerCallback)==null||v.call(window,"SdkReady"),i.eventEmitter.emit(i.SprigEvent.SDKReady,{mobileMetricsReportingEnabled:!!p.mobileMetricsReportingEnabled,metricsReportingInterval:p.metricsReportingIntervalSeconds||0,metricsThresholds:p.metricThresholds||[],maxMobileReplayDurationSeconds:p.maxMobileReplayDurationSeconds,mobileReplaySettings:p.mobileReplaySettings}),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId}),i.eventEmitter.on(i.SprigEvent.VisitorIDUpdated,()=>{for(const m in de)delete de[m]})}window.UserLeap.UPDATES=i.EVENTS,window.UserLeap("setPreviewKey",r),document.readyState==="complete"?o():window.attachEvent?window.attachEvent("onload",o):window.addEventListener("load",()=>{o()},!1)}class le{constructor(){q(this,"UPDATES",i.EVENTS)}displaySurvey(r){window.Sprig("displaySurvey",r)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(r,o){window.Sprig("setAttribute",r,o)}setAttributes(r){window.Sprig("setAttributes",r)}identifyAndSetAttributes(r){window.Sprig("identifyAndSetAttributes",r)}removeAttributes(r){window.Sprig("removeAttributes",r)}addListener(r,o){window.Sprig("addListener",r,o)}removeListener(r,o){window.Sprig("removeListener",r,o)}removeAllListeners(){window.Sprig("removeAllListeners")}setEmail(r){window.Sprig("setAttribute","!email",r)}setUserId(r){window.Sprig("setUserId",r)}setPartnerAnonymousId(r){window.Sprig("setPartnerAnonymousId",r)}track(r,o={},a={}){window.Sprig("track",r,o,a)}identifyAndTrack(r){window.Sprig("identifyAndTrack",r)}trackPageView(r,o,a){window.Sprig("trackPageView",r,o,a)}applyStyles(r){window.Sprig("applyStyles",r)}setWindowDimensions(r,o){window.Sprig("setWindowDimensions",r,o)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}pauseReplayRecording(){window.Sprig("pauseReplayRecording")}resumeReplayRecording(){window.Sprig("resumeReplayRecording")}}const Ie={configure:t=>{if(!t.envId&&!t.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(t.envId||(t.envId=t.environmentId??""),t.installationMethod="web-npm",window.Sprig)return window.Sprig;window.Sprig=function(){window.Sprig._queue.push(arguments)},Object.getOwnPropertyNames(le.prototype).map(o=>{o!=="constructor"&&(window.Sprig[o]=le.prototype[o])});const r=window.Sprig;return r.appId=t.envId,r._queue=[],window.UserLeap=r,Vt(t),window.Sprig}},Nt={sprig:Ie,SprigAPI:le,configure:Ie.configure};exports.APP_ID="ul-app",exports.ConflictingWidgets=Qe,exports.DEFAULT_BORDER_COLOR="#e6e6e6",exports.DEFAULT_WIDTH_PX=360,exports.EMBED_MOBILE_MAX_WIDTH=1030,exports.ERROR_BORDER_COLOR="#bd282a",exports.SprigAPI=le,exports.calculateFrameDimensions=tt,exports.core=Nt,exports.getHtml=ce,exports.isHTMLElement=D,exports.resetScrollPosition=t=>{const r=t.querySelector(".ul-card__container");r&&(r.scrollTop=0)},exports.setSurveyStyles=Y,exports.sprig=Ie;
package/dist/core.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./metricsReporter-CXdAqZlB.cjs"),e=require("./core-D7GY8Q1p.cjs");exports.DismissReason=i.DismissReason,exports.SprigEvent=i.SprigEvent,exports.SprigAPI=e.SprigAPI,exports.default=e.core,exports.sprig=e.sprig;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./metricsReporter-DOjBAl52.cjs"),e=require("./core-DGzfRh0z.cjs");exports.DismissReason=i.DismissReason,exports.SprigEvent=i.SprigEvent,exports.SprigAPI=e.SprigAPI,exports.default=e.core,exports.sprig=e.sprig;
package/dist/core.d.ts CHANGED
@@ -1691,6 +1691,7 @@ interface AppProductConfig {
1691
1691
  placement?: FeedbackPlacement;
1692
1692
  }
1693
1693
  interface Config extends MobileReplayConfig {
1694
+ addResponseGroupMeta?: () => Promise<JSONObject>;
1694
1695
  allResponses: unknown[];
1695
1696
  answers?: Answer[];
1696
1697
  apiURL: string;
@@ -1711,6 +1712,7 @@ interface Config extends MobileReplayConfig {
1711
1712
  customMetadata?: Record<string, unknown>;
1712
1713
  customStyles?: string;
1713
1714
  dismissOnPageChange: boolean;
1715
+ enableCspTrustedTypes?: boolean;
1714
1716
  forceBrandedLogo?: boolean;
1715
1717
  endCard?: {
1716
1718
  headline: string;
@@ -1789,6 +1791,7 @@ interface Config extends MobileReplayConfig {
1789
1791
  startingQuestionIdx?: number | null;
1790
1792
  styleNonce?: string;
1791
1793
  studyType?: StudyType;
1794
+ surveyVisitorAttributes: Record<string, unknown>;
1792
1795
  surveyId: number;
1793
1796
  tabTitle: string;
1794
1797
  trackPageViewUrl?: string;
@@ -1806,6 +1809,11 @@ interface Config extends MobileReplayConfig {
1806
1809
  externalUserId?: string;
1807
1810
  };
1808
1811
  }
1812
+ type JSONPrimitive = string | number | boolean | null;
1813
+ type JSONValue = JSONPrimitive | JSONValue[] | {
1814
+ [key: string]: JSONValue;
1815
+ };
1816
+ type JSONObject = Record<string, JSONValue>;
1809
1817
 
1810
1818
  interface Experiment {
1811
1819
  id: string;
@@ -2108,6 +2116,14 @@ declare global {
2108
2116
  // common types
2109
2117
  /** @example "123e4567-e89b-12d3-a456-426614174000" */
2110
2118
  type UUID = string;
2119
+
2120
+ interface Document {
2121
+ write(...text: Array<string | TrustedHTML>): void;
2122
+ }
2123
+
2124
+ interface Element {
2125
+ innerHTML: string | TrustedHTML;
2126
+ }
2111
2127
  }
2112
2128
 
2113
2129
  declare class SprigAPI {
package/dist/core.js CHANGED
@@ -1,5 +1,5 @@
1
- import { D as r, S as e } from "./metricsReporter-1Oozsgva.js";
2
- import { S as o, c as p, s as t } from "./core-fXpU4mUJ.js";
1
+ import { D as r, S as e } from "./metricsReporter-Chz3rKxD.js";
2
+ import { S as o, c as p, s as t } from "./core-BAdMqSxY.js";
3
3
  export {
4
4
  r as DismissReason,
5
5
  o as SprigAPI,