@sprig-technologies/sprig-browser 2.40.1 → 2.40.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./view-DAxlTNxd.cjs"),m=require("./getAttributedUrl-DuHEi0A7.cjs"),V=require("./core-oShYwNGS.cjs"),de=require("./metricsReporter-DC-3J5Sa.cjs"),Te=({properties:t,surveyVideoUrl:s,questionId:r})=>{const n=`ul-card-video__question_player-q${r}`,{apiURL:i,viewDocument:a}=e.useConfig(l=>({apiURL:l.apiURL,viewDocument:l.viewDocument}));return e.u("div",{id:n,ref:l=>{if(l&&l.children.length===0&&!t.properties.hideRecordedPrompt){const c=m.videoPlayer(n,{src:s,type:"application/x-mpegURL"},void 0,t.properties.mediaType===m.RECORDER.MEDIA_TYPE_AUDIO,i,a);l.appendChild(c)}}})},z=({isDisabled:t,onClick:s,children:r})=>e.u(m.Button,{className:"ul-card__button-checkmark",disabled:t,onClick:s,type:"button",children:[e.u("svg",{fill:"none",height:"10",viewBox:"0 0 13 10",width:"13",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M11.5 1.5L4.5 8.5L1 5",stroke:"#ffffff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})}),r||"Ok"]}),_e=({className:t,next:s,properties:r,questionId:n,type:i})=>{const{useMobileStyling:a,border:l}=e.useConfig(k=>({useMobileStyling:k.useMobileStyling,border:k.border})),[c,u]=e.h(!1),[h,g]=e.h(""),[o,d]=e.h(!1),f=r==null?void 0:r.collectName,C=(r==null?void 0:r.nameLabelText)||"Full Name",p=(r==null?void 0:r.consentText)||"I agree to the stated conditions",T=(r==null?void 0:r.submitButtonText)||"Submit",w=!!h.trim(),v=c&&(!f||w),_=(k,E=!1)=>{k.preventDefault(),k.stopPropagation();let I=null;if(!E){if(!v)return void d(!0);I={submitted:!0},f&&(I.name=h)}s({value:I,questionId:n,type:i},!!E||v)};return e.u("div",{className:e.cc(t,"ul-card__consent-legal","fade-in-transition"),children:e.u(m.MobileEmbedView,{embeddedType:"pdf",properties:r,children:e.u(m.QuestionBodyFooterContainer,{children:[e.u("div",{className:"sprig-stretch",children:[e.u(m.Option,{allowTextEntry:!1,border:l,error:o&&!c,id:"consent",isRadio:!1,isSelected:c,label:p,onUserInputChanged:({selected:k})=>{k!==c&&u(!c)},useMobileStyling:a}),f&&e.u("input",{"aria-label":C,"aria-placeholder":C,className:e.cc(e.getClasses("ul-consent-legal__name-input",a)),"data-gramm":"false",maxLength:250,name:"name",onBlur:k=>{k.currentTarget.style.borderColor=o&&!w?V.ERROR_BORDER_COLOR:V.DEFAULT_BORDER_COLOR},onFocus:k=>{k.currentTarget.style.borderColor=o&&!w?V.ERROR_BORDER_COLOR:l},onInput:k=>{k.preventDefault(),k.stopPropagation(),g(k.currentTarget.value)},placeholder:C,style:o&&!w?{borderColor:V.ERROR_BORDER_COLOR}:{},tabIndex:0,value:h})]}),e.u("div",{className:"ul-card__button-wrapper ul-card-vertical__button-wrapper",children:[e.u(z,{isDisabled:!v,onClick:k=>_(new SubmitEvent(k.type)),children:e.getButtonText({buttonText:T})}),r.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:k=>_(new SubmitEvent(k.type),!0),children:e.getSkipButtonText(r)})]})]})})},n)},Se=()=>{const{destroy:t,forceBrandedLogo:s}=e.useConfig(r=>({destroy:r.destroy,forceBrandedLogo:r.forceBrandedLogo}));return e.p(()=>{setTimeout(()=>{t(V.APP_ID)},s?4e3:2e3)},[t,s]),e.u("div",{className:"end-of-survey-text",children:"End of survey"})},Re=({activeValue:t,border:s,icon:r,enableCspTrustedTypes:n,isPressed:i,range:a,scaleLabelType:l,selectedValue:c,setSelectedValue:u,setActiveValue:h,setIsPressed:g,useMobileStyling:o,value:d,viewDocument:f})=>{const C=`option-${d}`,p=l==="number",T=l==="star",w=l==="smiley",v=p&&d===t||d===c,[_,k]=(()=>{const S=T&&c!==null&&d<=c;return T&&d<=t||w&&d===t||S||d===t||d===c?[s,i||S||d===c?1:.3]:["",1]})(),E=e.F(()=>{const S={borderColor:v?_:"",fillOpacity:v?"":k,zIndex:v?3:"auto",color:c===d?"#fff":""};return p?{...S,backgroundColor:c===d?_:""}:{...S,color:T||w||c===d?_:""}},[v,_,k,c,d,p,T,w]),I=e.F(()=>V.getHtml((({icon:S,scaleLabelType:y,value:R,selectedValue:b})=>{if(y==="smiley"&&R===b){let N=0;return S.replace(/black/g,()=>++N==1?"black":"white")}return S})({icon:r,scaleLabelType:l,value:d,selectedValue:c}),n),[n,r,l,c,d]);return e.u("button",{"aria-label":p?void 0:String(d),className:(()=>{switch(l){case"star":return e.cc(e.getClasses("likert-star",o),e.getClasses(`likert-star-${d}`,o));case"smiley":return e.cc(e.getClasses("likert-smiley",o),e.getClasses(`likert-smiley-${d}`,o));default:return d===a?e.cc(e.getClasses("likert-number",o),e.getClasses(`likert-number-${d}`,o),e.getClasses("likert-last-option",o)):e.cc(e.getClasses("likert-number",o),e.getClasses(`likert-number-${d}`,o))}})(),dangerouslySetInnerHTML:{__html:I},id:C,onClick:S=>{S.preventDefault(),S.stopPropagation(),u(d)},onKeyDown:S=>{var b,N;const y=f.querySelectorAll(`.likert-${l??"number"}`),R=d-1;S.key==="ArrowRight"?(b=y[R+1])==null||b.focus():S.key==="ArrowLeft"?(N=y[R-1])==null||N.focus():S.key!=="Enter"&&S.key!==" "||(S.preventDefault(),S.stopPropagation(),u(d))},onPointerDown:()=>g(!0),onPointerEnter:()=>h(d),onPointerLeave:()=>{h(-1),g(!1)},style:E,tabIndex:0})},Ne=({className:t,labels:s,next:r,properties:n,questionId:i,type:a})=>{const{border:l,useMobileStyling:c,viewDocument:u,enableCspTrustedTypes:h}=e.useConfig(y=>({border:y.border,useMobileStyling:y.useMobileStyling,viewDocument:y.viewDocument,enableCspTrustedTypes:y.enableCspTrustedTypes})),[g,o]=e.h(-1),[d,f]=e.h(!1),[C,p]=e.h(null),T=s&&s.left,w=s&&s.right;let v;const{range:_,scaleLabelType:k,ratingIcons:E}=n;_&&(v=Number(_));const I=v||5,S=y=>{var R,b;switch(k){case"star":return(R=E[0])==null?void 0:R.svg;case"smiley":return(b=E[y])==null?void 0:b.svg;default:return String(y+1)}};return e.u("form",{className:e.cc(t,"ul-card--likert","fade-in-transition"),children:e.u(m.MobileEmbedView,{properties:n,children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{"aria-label":`Rating (1 - ${I})`,className:"ul-card--likert__numbers",role:"radiogroup",children:[...Array(I)].map((y,R)=>{const b=R+1;return e.u(Re,{activeValue:g,border:l,enableCspTrustedTypes:h,icon:S(R),isPressed:d,range:I,scaleLabelType:k,selectedValue:C,setActiveValue:o,setIsPressed:f,setSelectedValue:p,useMobileStyling:c,value:b,viewDocument:u},R)})}),e.u("div",{className:"ul-card--likert__labels",children:[e.u("span",{children:T}),e.u("span",{children:w})]})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:C===null&&n.required,onClick:()=>r({value:C,questionId:i,type:a},!0),children:e.getButtonText(n)})})]})},i)},De=({columns:t,onSelect:s,options:r,selectedOptions:n})=>{const i=e._([]),{border:a,useMobileStyling:l}=e.useConfig(d=>({border:d.border,useMobileStyling:d.useMobileStyling})),c=r.findIndex(d=>n[d.id]===null),[u,h]=e.h(c),g=e.T((d,f)=>{s(d,f);const C=u+1,p=r[C];p&&n[p.id]===null&&h(C)},[s,r,n,u]),o=e.T((d,f)=>{const C=u===d;return e.u(e.Accordion,{animate:!0,header:f.label,isOpen:C,onClick:()=>{var p;return h(C&&!((p=window.UserLeap)!=null&&p.isMobileSDK)?-1:d)},ref:p=>{p&&(i.current[d]=p)},showHeaderCheck:n[f.id]!==null,children:e.u("div",{style:{paddingTop:"12px"},children:t.map(p=>e.u(m.Option,{allowTextEntry:!1,ariaLabel:`${f.label}-${p.label}`,border:a,error:!1,id:`${f.id}-${p.value}`,isRadio:!0,isSelected:n[f.id]===p.value,label:p.label,onUserInputChanged:()=>g(f.id,p.value),useMobileStyling:l},p.label))})},f.id)},[a,t,u,g,n,l]);return e.u("div",{children:r.map((d,f)=>o(f,d))})},Ie=({className:t,next:s,options:r,properties:n,questionId:i,type:a,onSubmitButtonClick:l})=>{const c=n.matrixColumn,u=n.required,h=C=>{C.preventDefault(),C.stopPropagation(),s({value:o,questionId:i,type:a},!0),l&&l()},g=r.reduce((C,p)=>(C[p.id]=null,C),{}),[o,d]=e.h(g);return e.u("form",{className:e.cc(t,"ul-card__matrix","fade-in-transition"),id:"text-form",onSubmit:h,children:e.u(m.MobileEmbedView,{properties:n,children:[e.u(m.QuestionBodyWrapper,{children:e.u(De,{columns:c,onSelect:(C,p)=>{d(T=>({...T,[C]:p}))},options:r,selectedOptions:o})}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:(f=o,u&&Object.values(f).every(C=>C==null)),onClick:()=>h(new SubmitEvent("submit")),children:e.getButtonText(n)})})]})},i);var f},pe=({className:t,onSubmit:s,options:r=[],properties:n,questionId:i,type:a,showIndividualSubmit:l=!1,onSubmitButtonClick:c})=>{const{border:u,useMobileStyling:h}=e.useConfig(b=>({border:b.border,useMobileStyling:b.useMobileStyling})),g=r.reduce((b,N)=>(b[N.id]={isSelected:!1},b),{}),[o,d]=e.h(g),f=a==="multiplechoice",C=n.required,p=r.find(b=>{var N;return(N=b.optionProperties)==null?void 0:N.noneOfTheAbove}),T=b=>Object.entries(b).some(([N,O])=>{var $;const A=r.find(j=>`${j.id}`===N),U=O.userText===void 0||O.userText.trim()==="";return(($=A==null?void 0:A.optionProperties)==null?void 0:$.allowsTextEntry)&&U&&O.isSelected}),w=b=>Object.values(b).filter(N=>N.isSelected).length,v=n.minSelect&&n.minSelect>0&&n.maxSelectMode===m.MaxSelectModes.Range&&w(o)<n.minSelect&&(C||w(o)>0),_=b=>T(b)||C&&!w(b)||!(N=>{const{minSelect:O=0,maxSelect:A=1/0,maxSelectMode:U}=n,$=w(N);switch(U){case m.MaxSelectModes.Maximum:return $<=A;case m.MaxSelectModes.Range:return $===0||$>=O;default:return!0}})(b),k=Object.entries(o).some(([b,N])=>{var O,A;return N.isSelected&&((A=(O=r.find(U=>`${U.id}`===b))==null?void 0:O.optionProperties)==null?void 0:A.allowsTextEntry)}),E=l&&(!f||k),I=b=>{R(b.id,b.selected,b.userText,b.noneOfTheAbove)},S=b=>{var N;return(n==null?void 0:n.maxSelectMode)!==m.MaxSelectModes.Unlimited&&w(o)===(n==null?void 0:n.maxSelect)&&!((N=o[b])!=null&&N.isSelected)},y=()=>{s(o,!0),c&&c()},R=(b,N,O,A)=>{const U=Object.assign({},o);if((f||A)&&N)for(const $ of Object.values(U))$.isSelected=!1,delete $.userText;else p&&!A&&o[p.id].isSelected&&(U[p.id].isSelected=!1);U[b]={isSelected:N,userText:O},d(U)};return e.u("form",{className:e.cc(t,"ul-card--multiple","fade-in-transition"),id:"text-form",onSubmit:y,children:e.u(m.MobileEmbedView,{properties:n,children:[e.u(m.QuestionBodyWrapper,{children:[n.isDropdown?e.u(m.Select,{disabledOptions:r.filter(b=>S(b.id)),dropdownFooter:v?e.u("div",{className:"ul-card__min-select-counter",style:{marginLeft:"16px"},children:[w(o),"/",n.minSelect]}):void 0,isMultiSelect:!f,multiselectText:n.dropdownMultiselectedText??"choices selected",onChange:b=>{const N={...o};for(const O of r)b.includes(O)?N[O.id].isSelected=!0:N[O.id].isSelected=!1;d(N)},options:r,placeholderText:n.dropdownPlaceholderText??(f?"Select choice":"Select choice(s)"),value:r.filter(b=>o[b.id].isSelected)}):e.u("div",{className:e.cc(e.getClasses("ul-card__choices",h)),role:f?"radiogroup":"group",children:[r.map(({id:b,label:N,value:O,optionProperties:A})=>{var Q,Z;const U=`${b}`,{allowsTextEntry:$,noneOfTheAbove:j}={allowsTextEntry:!1,noneOfTheAbove:!1,...A};return e.u(m.Option,{allowTextEntry:$,border:u,disabled:S(U),error:(F=o,T(F)),id:U,isRadio:f,isSelected:!!((Q=o[U])!=null&&Q.isSelected),label:N,noneOfTheAbove:j,onUserInputChanged:I,promptText:"Please specify",text:(Z=o[b])==null?void 0:Z.userText,useMobileStyling:h,value:O},U);var F}),!!v&&e.u("div",{className:"ul-card__min-select-counter",children:[w(o),"/",n.minSelect]})]}),E&&e.u(m.LongformSubmitButton,{handleSubmit:y,isSubmitDisabled:_(o)})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:_(o),onClick:y,children:e.getButtonText(n)})})]})},i)},we=t=>{const{questionId:s,type:r,next:n,options:i}=t;return e.u(pe,{...t,onSubmit:(a,l)=>{const c=Object.entries(a).find(([,d])=>d.isSelected)||[void 0,void 0],[u,h]=c,g=i.find(d=>`${d.id}`===u),o=h!=null&&h.userText?{[u]:{userText:h.userText}}:null;n({value:g&&u?{[u]:g.value}:{},secondaryValue:o,questionId:s,type:r},l)}})},Ee=t=>{const{questionId:s,type:r,next:n}=t;return e.u(pe,{...t,onSubmit:(i,a)=>{const l=Object.entries(i).reduce((u,[h,g])=>(u[h]=g.isSelected,u),{}),c=Object.entries(i).reduce((u,[h,g])=>{if(!g.userText)return u;const o=u||{};return o[h]={userText:g.userText},o},null);n({value:l,secondaryValue:c,questionId:s,type:r},a)}})},Pe=({className:t,labels:s,properties:r,next:n,questionId:i,type:a})=>{const[l,c]=e.h(null),{border:u,useMobileStyling:h,viewDocument:g}=e.useConfig(f=>({border:f.border,useMobileStyling:f.useMobileStyling,viewDocument:f.viewDocument})),o=s&&s.left,d=s&&s.right;return e.u("form",{className:e.cc(t,"ul-card--nps","fade-in-transition"),children:e.u(m.MobileEmbedView,{properties:r,children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--nps__numbers",children:[...Array(11)].map((f,C)=>e.u("button",{className:e.cc(e.getClasses("nps-number",h),e.getClasses(`nps-number-${C}`,h)),id:`option-${C}`,onClick:p=>{p.preventDefault(),p.stopPropagation(),c(C)},onKeyDown:p=>{var w,v;const T=g.querySelectorAll("button.nps-number");p.key==="ArrowRight"?(w=T[C+1])==null||w.focus():p.key==="ArrowLeft"?(v=T[C-1])==null||v.focus():p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),c(C))},onPointerDown:p=>{p.currentTarget.style.zIndex="2",p.currentTarget.style.borderColor=u},onPointerLeave:p=>{p.currentTarget.style.zIndex="auto",p.currentTarget.style.borderColor=V.DEFAULT_BORDER_COLOR},style:l===C?{backgroundColor:u,color:"#fff"}:void 0,tabIndex:0,children:C},C))}),e.u("div",{className:"ul-card--nps__labels",children:[e.u("span",{children:o}),e.u("span",{children:d})]})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:l===null&&r.required,onClick:()=>n({value:l,questionId:i,type:a},!0),children:e.getButtonText(r)})})]})},i)},qe=({className:t,next:s,properties:r,questionId:n,type:i,onSubmitButtonClick:a})=>{const{border:l,useMobileStyling:c,update:u}=e.useConfig(T=>({border:T.border,useMobileStyling:T.useMobileStyling,update:T.update})),[h,g]=e.h(""),o=e._(null),d=h.trim(),f=r.required===!0&&!d,C=m.useAutoSize(o,()=>u()),p=r&&r.openTextPlaceholder?r.openTextPlaceholder:"";return e.u("form",{className:e.cc(t,"ul-card-text","fade-in-transition"),id:"text-form",children:e.u(m.MobileEmbedView,{properties:r,children:e.u("div",{className:"ul-card-text",children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card-text__container",children:e.u("textarea",{"aria-describedby":"ul-caption","aria-labelledby":"ul-question","aria-multiline":"true","aria-placeholder":p,className:e.cc(e.getClasses("ul-card-text__input",c)),"data-gramm":"false",maxLength:5e3,name:"text",onBlur:T=>{T.currentTarget.style.borderColor=V.DEFAULT_BORDER_COLOR},onChange:T=>{const{value:w}=T.currentTarget;C(),T.preventDefault(),T.stopPropagation(),g(w)},onFocus:T=>{T.currentTarget.style.borderColor=l},placeholder:p,ref:o,role:"textbox",tabIndex:0})}),r.footerHtml&&e.u(m.Html,{className:"footer",html:r.footerHtml})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:f,onClick:T=>{T.preventDefault(),T.stopPropagation();const w=r.required!==!0||d.length>0;s({value:h,questionId:n,type:i},w),a&&a()},children:e.getButtonText(r)})})]})})},n)},Be=({className:t,labels:s,next:r,properties:n,questionId:i,type:a,onSubmitButtonClick:l,options:c})=>{const u=e._(null),h=e._(0),g=e._(0),o=e._(null),d=e._(!1),f=e._([]),[C,p]=e.h(()=>(n==null?void 0:n.required)===!0),[T,w]=e.h(()=>c.map(x=>({...x,rank:null}))),v=e.F(()=>Array.from({length:c.length},(x,P)=>P+1),[c.length]),{useMobileStyling:_,isPreview:k,headers:E}=e.useConfig(x=>({useMobileStyling:x.useMobileStyling,isPreview:x.isPreview,headers:x.headers})),I=(E==null?void 0:E["userleap-platform"])==="android",S=_&&!k&&!I,y=!S&&!I,R=(x,P)=>{w(q=>{const D=parseInt(P),M=q.map(B=>({...B}));M.some(B=>B.rank==null)&&M.forEach((B,W)=>B.rank=W+1);const H=M.findIndex(B=>B.id===x);if(H===-1)return q;const L=M[H].rank;return D<L?M.forEach(B=>{B.id!==x&&B.rank>=D&&B.rank<L&&(B.rank=B.rank+1)}):D>L&&M.forEach(B=>{B.id!==x&&B.rank>L&&B.rank<=D&&(B.rank=B.rank-1)}),M[H].rank=D,M.sort((B,W)=>B.rank-W.rank),j(),M})},b=(x,P)=>{for(let q=0;q<f.current.length;q++){const D=f.current[q];if(!D||D===o.current)continue;const M=D.getBoundingClientRect();if(x>=M.left&&x<=M.right&&P>=M.top&&P<=M.bottom)return{element:D,index:q}}return null},N=x=>P=>{if(!S)return;P.preventDefault(),P.stopPropagation(),d.current=!0,u.current=x;const q=P.touches[0];h.current=q.clientY,g.current=q.clientY;const D=P.currentTarget.closest(".ul-card-rank__option");D&&(o.current=D,D.classList.add("is-dragging"))},O=x=>{if(!S||!d.current||u.current===null)return;x.preventDefault(),x.stopPropagation();const P=x.touches[0];g.current=P.clientY;const q=g.current-h.current;o.current&&(o.current.style.transform=`translateY(${q}px)`,o.current.style.zIndex="1000"),f.current.forEach(M=>{M&&M!==o.current&&M.classList.remove("is-drop-target")});const D=b(P.clientX,P.clientY);D&&D.element.classList.add("is-drop-target")},A=x=>{if(!S||!d.current||u.current===null)return;x.preventDefault(),x.stopPropagation();const P=x.changedTouches[0],q=b(P.clientX,P.clientY);o.current&&(o.current.style.transform="",o.current.style.zIndex="",o.current.classList.remove("is-dragging")),f.current.forEach(D=>{D&&D.classList.remove("is-drop-target")}),q&&q.index!==u.current&&U(u.current,q.index),u.current=null,o.current=null,d.current=!1},U=(x,P)=>{w(q=>{const D=q.map(H=>({...H})),[M]=D.splice(x,1);return D.splice(P,0,M),D.forEach((H,L)=>{H.rank=L+1}),j(),D})},$=x=>{const P={};x.reduce((q,D)=>(q[D.id]=D.rank,q),P),r({value:P,questionId:i,type:a},!0)},j=()=>{p(!1)},{left:F,right:Q}=s,Z=c.length,K=x=>{x.preventDefault(),x.currentTarget.classList.add("is-drop-target")},ke=x=>{x.currentTarget.classList.remove("is-drop-target")},xe=x=>{u.current=null,x.currentTarget.classList.remove("is-dragging")};return e.u("form",{className:e.cc(t,"ul-card-rank","fade-in-transition"),onSubmit:x=>{x.preventDefault(),$(T),l&&l()},children:e.u(m.MobileEmbedView,{properties:n,children:I?e.u(m.QuestionBodyWrapper,{children:e.u("div",{className:"ul-card--rank__question-inner-container",children:[e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:["1 - ",F]})}),e.u("ol",{className:"ul-card-rank__list",children:T.map(({id:x,label:P,rank:q})=>e.u("li",{className:"ul-card-rank__option",children:[e.u("select",{"aria-label":`Rank for ${P}`,className:e.cc("ul-card-rank__select",q==null&&"ul-card-rank__select--placeholder"),name:`rank[${x}]`,onChange:D=>R(x,D.currentTarget.value),value:q??"",children:[q==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),v.map(D=>e.u("option",{className:"ul-card-rank__select-option",value:D,children:D},`${D}-${i}`))]}),e.u("span",{children:P})]},x))}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[Z," - ",Q]})})]})}):e.u(e.g,{children:[e.u(m.QuestionBodyWrapper,{children:e.u("div",{className:"ul-card--rank__question-inner-container",children:[e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:["1 - ",F]})}),e.u("ol",{className:"ul-card-rank__list",onDragOver:I?void 0:x=>{x.preventDefault(),x.dataTransfer&&(x.dataTransfer.dropEffect="move")},children:T.map(({id:x,label:P,rank:q},D)=>{return e.u("li",{className:"ul-card-rank__option",draggable:!!y||void 0,onDragEnd:y?xe:void 0,onDragEnter:y?K:void 0,onDragLeave:y?ke:void 0,onDragStart:y?(H=D,L=>{u.current=H,L.dataTransfer&&(L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",String(H)),L.currentTarget.classList.add("is-dragging"))}):void 0,onDrop:y?(M=D,L=>{var W,ae;L.preventDefault(),L.currentTarget.classList.remove("is-drop-target");const B=u.current;u.current=null,(ae=(W=L.currentTarget.closest(".ul-card-rank__list"))==null?void 0:W.querySelector(".is-dragging"))==null||ae.classList.remove("is-dragging"),B!=null&&B!==M&&U(B,M)}):void 0,ref:L=>f.current[D]=L,children:[e.u("select",{"aria-label":`Rank for ${P}`,className:e.cc("ul-card-rank__select",q==null&&"ul-card-rank__select--placeholder"),name:`rank[${x}]`,onChange:L=>R(x,L.currentTarget.value),value:q??"",children:[q==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),v.map(L=>e.u("option",{className:"ul-card-rank__select-option",value:L,children:L},L))]}),e.u("span",{children:P}),!I&&e.u("button",{"aria-label":`Drag ${P} to reorder`,className:"ul-card-rank__drag-btn",onTouchEnd:S?A:void 0,onTouchMove:S?O:void 0,onTouchStart:S?N(D):void 0,title:"Drag to reorder",type:"button",children:e.u("svg",{fill:"none",height:"17",viewBox:"0 0 16 17",width:"16",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M5.75 11.625C6.37132 11.625 6.875 12.1287 6.875 12.75C6.875 13.3713 6.37132 13.875 5.75 13.875C5.12868 13.875 4.625 13.3713 4.625 12.75C4.625 12.1287 5.12868 11.625 5.75 11.625ZM10.25 11.625C10.8713 11.625 11.375 12.1287 11.375 12.75C11.375 13.3713 10.8713 13.875 10.25 13.875C9.62868 13.875 9.125 13.3713 9.125 12.75C9.125 12.1287 9.62868 11.625 10.25 11.625ZM5.75 7.375C6.37132 7.375 6.875 7.87868 6.875 8.5C6.875 9.12132 6.37132 9.625 5.75 9.625C5.12868 9.625 4.625 9.12132 4.625 8.5C4.625 7.87868 5.12868 7.375 5.75 7.375ZM10.25 7.375C10.8713 7.375 11.375 7.87868 11.375 8.5C11.375 9.12132 10.8713 9.625 10.25 9.625C9.62868 9.625 9.125 9.12132 9.125 8.5C9.125 7.87868 9.62868 7.375 10.25 7.375ZM5.75 3.125C6.37132 3.125 6.875 3.62868 6.875 4.25C6.875 4.87132 6.37132 5.375 5.75 5.375C5.12868 5.375 4.625 4.87132 4.625 4.25C4.625 3.62868 5.12868 3.125 5.75 3.125ZM10.25 3.125C10.8713 3.125 11.375 3.62868 11.375 4.25C11.375 4.87132 10.8713 5.375 10.25 5.375C9.62868 5.375 9.125 4.87132 9.125 4.25C9.125 3.62868 9.62868 3.125 10.25 3.125Z",fill:"currentColor"})})})]},x);var M,H})}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[Z," - ",Q]})})]})}),e.u(m.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(m.Button,{disabled:C,children:e.getButtonText(n)})})})]})})},i)},te=1,me=2,he=3,X=t=>t.type==="av_permission",oe=t=>t.type==="screen_permission",ge=(t,s)=>t===void 0?te:t?((r,n)=>!(X(n)?n.permissionDescriptors:[]).includes("camera")||r.getVideoTracks().length>0)(t,s)?he:te:me,le={avStream:null,currentPage:null,mediaRecordingUids:null,nextQuestion:()=>{},passthroughData:void 0,recordingMediaTypes:void 0,screenPermissionRequested:!1,type:void 0},G=e.create(t=>({...le,reset:()=>{t(le)},updatePage:s=>{t(s)}}));function re({currentPage:t,pages:s}){const{avStream:r,recordingMediaTypes:n,updatePage:i}=G.getState(),{recorderEventEmitter:a}=e.useConfig.getState();a.emit("av.permission",{"permission.descriptors":t.permissionDescriptors,"stream.ready":(l,c)=>{if(r===l)return;let u=t;if(l&&!t.permissionDescriptors.includes("camera")){const h=s.indexOf(t),g=c!=null&&c.active?h+2:h+1;c!=null&&c.active&&n&&a.emit("begin.recording",{"recording.media.types":n,"start.recording.callback":o=>i({mediaRecordingUids:o})}),u=s[g]}i({currentPage:u,avStream:l})}})}function ne({status:t}){const{nextQuestion:s,passthroughData:r,mediaRecordingUids:n,reset:i}=G.getState(),{recorderEventEmitter:a,handleUploadUpdate:l,index:c}=e.useConfig.getState(),u={value:{taskStatus:t},type:"recordedtask",questionId:(r==null?void 0:r.questionId)||1};r&&a.emit("finish.task",{"begin.callback":h=>{l({mediaRecordingUid:h,isSubmitted:!0,progressPct:0,isComplete:!1})},"progress.callback":(h,g)=>{l({mediaRecordingUid:h,progressPct:g.detail,isSubmitted:!1,isComplete:!1})},"upload.callback":h=>{h&&l({mediaRecordingUid:h,isComplete:!0,isSubmitted:!0,progressPct:100})},"passthrough.data":r,"current.index":c,"task.response":u,"task.complete.callback":h=>{u.value.taskDurationMillisecond=h,n&&(u.value.mediaRecordingUids=n),i(),s(u)}})}function se({pages:t,setIsRequestingPermission:s}){const{recorderEventEmitter:r,eventEmitFn:n}=e.useConfig.getState(),{updatePage:i,currentPage:a,recordingMediaTypes:l,screenPermissionRequested:c}=G.getState();if(!a)return;const u=t.indexOf(a);switch(a.type){case"av_permission":{const h=c?u+2:u+1;return c&&l&&r.emit("begin.recording",{"recording.media.types":l,"start.recording.callback":g=>{i({mediaRecordingUids:g})}}),void i({currentPage:t[h]})}case"screen_permission":return void r.emit("screen.permission",{"screen.permission.requested":s,"stream.ready.callback":(h,g)=>{const o=g?t[u+1]:a;g&&l&&r.emit("begin.recording",{"recording.media.types":l,"start.recording.callback":d=>{i({captureStream:g,mediaRecordingUids:d})}}),i({currentPage:o,screenPermissionRequested:!0,captureStream:g})}});case"start_task":return n("recorded.task.start"),r.emit("recorded.task.start"),r.emit("start.task"),void i({currentPage:t[u+1],screenPermissionRequested:!0});case"complete_task":return}}const ve="ul-permission-graphics-container",be="ul-permission-body",ye=e.cc(ve,"ul_recorded-task-inset-spacing"),J=e.cc("ul-horizontal-button-container","ul-horizontal-button-container-left"),fe=({richTextBody:t})=>e.u(m.Html,{className:"ul-rich-text-body",html:t,id:"ul-task-detail-container"}),ee=({required:t,skipButtonText:s,bottom:r=!1})=>t?null:e.u(m.Button,{className:e.cc(r&&"ul-skip-button-below","ul-button-inactive"),onClick:ne.bind(null,{status:"abandoned"}),children:s||"Skip"}),ie=t=>{const{avStream:s,captureStream:r,recordingMediaTypes:n,updatePage:i}=G.getState(),a=(n==null?void 0:n.includes("audio"))||(n==null?void 0:n.includes("video"));e.p(()=>{const l=setInterval(()=>{a&&s&&!s.active?i({avStream:null,currentPage:t[0]}):r&&r.active||i({captureStream:void 0,currentPage:t[a?1:0]})},1e3);return()=>clearInterval(l)},[s,r,a,t,n,i])},Me=({content:t,pages:s,required:r})=>{const{buttonText:n,skipButtonText:i,taskDetail:a}=t;return ie(s),e.u("div",{className:"ul-task-page",children:[a&&e.u(fe,{richTextBody:a}),e.u("div",{className:J,children:[e.u(m.Button,{onClick:se.bind(null,{pages:s}),children:n}),e.u(ee,{required:r,skipButtonText:i})]})]},"start-task")},Le=({content:t,pages:s,properties:r})=>{const{buttonText:n,skipButtonText:i}=t;return ie(s),e.u("div",{className:"ul-task-page",children:[t.taskDetail&&e.u(fe,{richTextBody:t.taskDetail}),e.u(m.MobileEmbedView,{properties:r,children:e.u("div",{className:J,children:[e.u(m.Button,{className:"ul-complete-task-button",onClick:ne.bind(null,{status:"completed"}),children:n}),e.u(m.Button,{className:e.cc("ul-button-inactive"),onClick:ne.bind(null,{status:"given.up"}),children:i})]})})]},"complete-task")},Oe=({content:t,pages:s,required:r})=>{const{buttonText:n,skipButtonText:i}=t,[a]=e.useConfig(u=>[u.tabTitle]),[l,c]=e.h(!1);return e.u("div",{children:[e.u("div",{className:ye,children:[e.u("p",{style:{marginTop:"auto"},children:t.selectTabText}),e.u("div",{className:"ul-select-tab-container",children:e.u("p",{className:be,children:a})})]}),e.u("div",{className:r?"":J,children:[e.u(m.Button,{disabled:l,onClick:se.bind(null,{pages:s,setIsRequestingPermission:c}),children:n}),e.u(ee,{required:r,skipButtonText:i})]})]})},Ue=({content:t})=>e.u(m.Html,{className:e.cc(ve,"ul_permission_svg_container","ul_recorded-task-inset-spacing","ul-center-horizontally"),html:t.svg},"ul-permission-request-graphic"),Ae=({content:t,pages:s,required:r})=>{const{permissionDeniedHeadline:n,permissionDeniedBody:i,skipButtonText:a,tryAgainButtonText:l}=t,c=X(s[0])?s[0]:null;return e.p(()=>{const u=setInterval(()=>{c!==null&&re({currentPage:c,pages:s})},1e3);return()=>clearInterval(u)},[c,s]),c?e.u("div",{children:[e.u("div",{className:ye,children:e.u("p",{className:"ul-av-permission-denied-paragraph",children:[e.u("span",{className:"ul-av-permission-denied-headline",children:n}),e.u("span",{className:be,children:i})]})}),e.u("div",{className:J,children:[e.u(m.Button,{onClick:re.bind(null,{currentPage:c,pages:s}),children:l}),e.u(ee,{required:r,skipButtonText:a})]})]}):null},$e=({stream:t})=>e.u("video",{autoPlay:!0,className:e.cc("ul_recorded-task-inset-spacing"),id:"ul-record-task-video-preview",muted:!0,ref:s=>{s&&(s.srcObject=t||null)}}),Qe=({content:t,pages:s,required:r})=>{const{skipButtonText:n}=t,{avStream:i}=G.getState();return ie(s),e.u("div",{children:[e.u($e,{stream:i}),e.u("div",{className:"ul-vertical-button-container-center",children:[e.u(m.Button,{onClick:se.bind(null,{pages:s}),children:t.buttonText}),e.u(ee,{bottom:!0,required:r,skipButtonText:n})]})]})},He=({properties:t})=>{const{pages:s,required:r}=t,{avStream:n,currentPage:i}=G.getState();if(i===void 0)return null;switch(i==null?void 0:i.type){case"av_permission":{const a=ge(n,i);return a===te?e.u(Ue,{content:i}):a===me?e.u(Ae,{content:i,pages:s,required:r}):e.u(Qe,{content:i,pages:s,required:r})}case"screen_permission":return e.u(Oe,{content:i,pages:s,required:r});case"start_task":return e.u(Me,{content:i,pages:s,required:r});case"complete_task":return e.u(Le,{content:i,pages:s,properties:t});default:return null}},Fe=({className:t,properties:s,next:r,questionId:n})=>{const i=e.useConfig(),{surveyId:a,responseGroupUid:l,userId:c}=i,u=G(),{screenPermissionRequested:h}=u,g=G(p=>p.avStream);let o=G(p=>p.currentPage);o||(o=function({pages:p,userId:T,responseGroupUid:w,surveyId:v,questionId:_,next:k}){const{updatePage:E}=G.getState(),{eventEmitFn:I,recorderEventEmitter:S}=e.useConfig.getState(),y={questionId:_,surveyId:v,visitorId:T,responseGroupUid:w};let R=0;S.emit("recorded.task.permission.screen"),I("recorded.task.permission.screen"),S.emit("permission.status",{"permission.status.callback":(N,O,A,U)=>{const $=p[R],{type:j}=$,F=["screen"];if(X($)){const{permissionDescriptors:Q}=$,Z=Q==null?void 0:Q.includes("microphone"),K=Q==null?void 0:Q.includes("camera");Z&&F.push("audio"),K&&F.push("video"),(N!=null&&N.active&&!K||N!=null&&N.active&&O)&&R++}oe(p[R])&&A&&(R++,S.emit("begin.recording",{"recording.media.types":F,"start.recording.callback":Q=>E({mediaRecordingUids:Q})})),E({currentPage:p[R],avStream:N,screenPermissionRequested:A,nextQuestion:k,type:j,passthroughData:y,recordingMediaTypes:F,captureStream:U})}});const b=p[R];return b.type==="av_permission"&&re({currentPage:b,pages:p}),b}({questionId:n,surveyId:a,next:p=>{r(p,!0)},pages:s.pages,responseGroupUid:l,userId:c}));let d=o.headline,f=o.captionText;const C=ge(g,o);return oe(o)&&h&&(d=o.permissionDeniedHeadline,f=o.permissionDeniedCaptionText),X(o)&&C===he&&(d=o.permissionGrantedHeadline,f=o.permissionGrantedCaptionText),e.u("div",{className:e.cc(t,"ul-center-horizontally","fade-in-transition"),children:[e.u(m.Header,{isRequired:s==null?void 0:s.required,message:d,properties:{captionText:f}}),e.u(m.QuestionBodyWrapper,{children:e.u(He,{properties:s})})]})},Ve=({className:t,next:s,properties:r,questionId:n,type:i})=>{const{visitorAttributes:a,isLongFormSurvey:l}=e.useConfig(g=>({visitorAttributes:g.visitorAttributes,isLongFormSurvey:de.isLongFormSurvey(g.studyType)})),c=(g,o=!1)=>{s({value:o?{skipped:!0}:void 0,questionId:n,type:i},!0)},u=m.getAttributedUrl(r&&r.buttonUrl,a),h=l&&r.promptActionType===m.PromptActionTypeEnum.NO_BUTTON;return e.u("div",{className:e.cc(t,"ul-card__text-url-prompt","fade-in-transition"),children:e.u(m.MobileEmbedView,{properties:r,children:!h&&e.u("div",{children:e.u("div",{className:"ul-card-button-group",children:[e.u("a",{className:"ul-card-text__button ul-card__text-url-prompt-button",href:u,id:"ul-card-text__button",onClick:c,onKeyPress:g=>{g.key!=="Enter"&&g.key!==" "||s({value:void 0,questionId:n,type:i},!0)},rel:"noreferrer",role:u?"link":"button",tabIndex:0,target:"_blank",children:e.getButtonText(r)}),r.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:g=>c(0,!0),children:e.getSkipButtonText(r)})]})})})},n)},Ge=({className:t,questionId:s})=>{const{border:r,destroy:n,endCard:i,forceBrandedLogo:a}=e.useConfig(u=>({border:u.border,destroy:u.destroy,endCard:u.endCard,forceBrandedLogo:u.forceBrandedLogo}));e.p(()=>{setTimeout(()=>{n(V.APP_ID)},a?4e3:2e3)},[n,a]);const l=i&&i.subheader?e.u("p",{className:"ul-caption",children:i.subheader}):null,c=i&&i.headline?i.headline:"";return e.u("div",{className:e.cc(t,"ul-card--thanks","fade-in-transition"),children:e.u("div",{children:e.u("div",{className:"ul-card--thanks-content",children:[e.u("div",{className:"ul-thanks-check",children:e.u("svg",{"aria-labelledby":"title",fill:"none",height:"99",viewBox:"0 0 81 99",width:"81",xmlns:"http://www.w3.org/2000/svg",children:[e.u("path",{clipRule:"evenodd",d:"M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z",fill:r,fillRule:"evenodd"}),e.u("path",{clipRule:"evenodd",d:"M55.025 22.9046C55.6299 23.4705 55.6616 24.4198 55.0956 25.0247C54.8724 25.2634 54.6109 25.5285 54.3157 25.8277C52.2547 27.9168 48.5549 31.667 44.8135 39.6658C43.2818 42.9406 42.0864 45.8386 41.0823 48.2729C40.6539 49.3116 40.2603 50.2659 39.8902 51.129C39.287 52.5359 38.7248 53.7508 38.1744 54.625C37.8997 55.0613 37.5806 55.4905 37.2017 55.8245C36.8201 56.1607 36.2613 56.5 35.5457 56.5C34.6742 56.5 34.0892 55.9692 33.7774 55.6083C33.4502 55.2296 33.1752 54.7511 32.9396 54.301C32.7305 53.9013 32.5088 53.4367 32.2797 52.9565C32.2429 52.8794 32.2059 52.8019 32.1688 52.7243C31.8942 52.1499 31.5959 51.534 31.2537 50.8868C29.8886 48.305 27.8539 45.2878 24.2343 43.1382C23.522 42.7152 23.2875 41.7949 23.7105 41.0826C24.1335 40.3703 25.0539 40.1358 25.7662 40.5588C30.0556 43.1062 32.4149 46.6647 33.9058 49.4845C34.2776 50.1876 34.5973 50.8487 34.8753 51.4302C34.9147 51.5124 34.9529 51.5926 34.9902 51.6707C35.2222 52.1567 35.4164 52.5637 35.5978 52.9102C35.6151 52.9434 35.6321 52.9754 35.6485 53.0061C36.0565 52.3531 36.5341 51.3434 37.133 49.9468C37.4781 49.1418 37.8572 48.2229 38.2761 47.2074C39.2886 44.7532 40.5339 41.7347 42.0961 38.3948C46.0591 29.9221 50.0641 25.8648 52.1535 23.7482C52.4423 23.4556 52.6944 23.2002 52.9048 22.9753C53.4708 22.3703 54.42 22.3387 55.025 22.9046ZM35.1994 53.5892C35.1994 53.5892 35.2 53.5888 35.2012 53.5879C35.2 53.5889 35.1994 53.5893 35.1994 53.5892ZM36.0666 53.6682C36.0732 53.674 36.0765 53.6775 36.0765 53.6777C36.0765 53.678 36.0732 53.6751 36.0666 53.6682Z",fill:r,fillRule:"evenodd"}),e.u("path",{d:"M69.5 97C69.5 98.1046 56.2924 99 40 99C23.7076 99 10.5 98.1046 10.5 97C10.5 95.8954 23.7076 95 40 95C56.2924 95 69.5 95.8954 69.5 97Z",fill:"black",fillOpacity:"0.2"})]})}),e.u(m.Header,{message:c}),l]})})},s)},je=()=>e.u("div",{className:"thinking-dots-container",children:e.u("div",{className:"thinking-dot"})}),Ze=({className:t})=>{const{uploadProgress:s}=e.useConfig(a=>({uploadProgress:a.uploadProgress}));let r,n;Object.values(s).filter(a=>a.isSubmitted).length>1?(r="Your responses are processing",n="Please keep this tab open until your responses are fully processed."):(r="Your response is processing",n="Please keep this tab open until your response is fully processed.");const i=Math.round(Math.min(99,...Object.values(s).filter(a=>a.isSubmitted).map(a=>a.progressPct||0)));return e.u("div",{className:e.cc(t,"ul-card--uploading","fade-in-transition"),children:[e.u("div",{"aria-busy":"true","aria-label":"Processing...","aria-live":"polite",className:"ul-loading-spinner-container",role:"progressbar",children:e.u("div",{className:"ul-loading-spinner",children:[e.u("div",{className:"first"}),e.u("div",{className:"second"}),e.u("div",{className:"third"}),e.u("div",{className:"fourth"})]})}),e.u(m.Header,{message:`${r} (${i}% complete)`}),e.u("p",{className:"ul-caption",children:n})]})},ue=0,ce=1,ze=({className:t,next:s,properties:r,questionId:n,type:i})=>{const a=`ul-card-video__player_recorder-q${n}`,{apiURL:l,envId:c,handleUploadUpdate:u,headers:h,responseGroupUid:g,surveyId:o,viewDocument:d,visitorId:f}=e.useConfig(y=>({apiURL:y.apiURL,envId:y.envId,handleUploadUpdate:y.handleUploadUpdate,headers:y.headers,responseGroupUid:y.responseGroupUid,surveyId:y.surveyId,viewDocument:y.viewDocument,visitorId:y.userId})),[C,p]=e.h(!1),[T,w]=e.h(null),[v,_]=e.h(null),[k,E]=e.h(ue),I=(y,R)=>{y===m.RECORDER.UPLOAD_STARTED?(w(R[m.RECORDER.UPLOAD_ID]),_(R[m.RECORDER.MEDIA_RECORDING_UID]),p(!0)):y===m.RECORDER.DELETE?(w(null),_(null),p(!1)):y===m.RECORDER.UPLOAD_PROGRESS?isNaN(R[m.RECORDER.UPLOAD_PROGRESS_PCT])?u({mediaRecordingUid:R[m.RECORDER.MEDIA_RECORDING_UID],isComplete:!0}):u({mediaRecordingUid:R[m.RECORDER.MEDIA_RECORDING_UID],progressPct:R[m.RECORDER.UPLOAD_PROGRESS_PCT]}):y===m.RECORDER.UPLOAD_FINISHED&&u({mediaRecordingUid:R[m.RECORDER.MEDIA_RECORDING_UID],isComplete:!0})},S=y=>{y.preventDefault(),y.stopPropagation(),document.getElementById(a)&&m.stopRecording(a),T&&v?(u({mediaRecordingUid:v,isSubmitted:!0}),s({value:{mediaRecordingUid:v},questionId:n,type:i},!0)):s({value:null,questionId:n,type:i},!0)};return e.u("form",{className:e.cc(t,"ul-card--video","fade-in-transition"),id:"ul-video-interview-form",children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{id:"ul-question-player-container",style:{display:k===ue?"":"none"},children:e.u(m.MobileEmbedView,{properties:r,children:e.u("button",{className:"ul-video-btn ul-record-response-btn",onClick:y=>{y.preventDefault(),y.stopPropagation(),document.getElementById(a)&&m.pauseQuestionPlayer(a),E(ce)}})})}),e.u("div",{style:{display:k===ce?"block":"none"},children:e.u("div",{id:"ul-recorder-player-container",ref:y=>{if(y&&y.children.length===0){const R=m.videoRecorderPlayer(a,{surveyId:o,responseGroupUid:g,questionId:n,visitorId:f,envId:c},l,I,void 0,{...h,"x-ul-video-recorder-origin":"sdk"},r.mediaType===m.RECORDER.MEDIA_TYPE_AUDIO,d);y.appendChild(R)}}})})]}),e.u(m.QuestionBodyFooterContainer,{children:[e.u(z,{isDisabled:!!r.required&&!C,onClick:S,children:e.getButtonText(r)}),e.u("button",{className:"ul-card-text__button ul-button-inactive ul-card-skip__button",id:"ul-card-video__skip_button",onClick:S,style:{...r.required?{display:"none"}:{},...C?{display:"none"}:{}},children:e.getSkipButtonText(r)})]})]})},Ce=t=>t.type==="thanks"||t.type==="uploading",We=({card:t,avatars:s,isThinking:r,isCurrentQuestion:n,currentQuestionBubbleRef:i})=>{const a=(l=>"properties"in l.props&&l.props.properties&&"questionHtml"in l.props.properties&&l.props.properties.questionHtml?{content:l.props.properties.questionHtml,isHtml:!0}:"message"in l.props?{content:l.props.message,isHtml:!1}:{content:"Question",isHtml:!1})(t);return e.u(Y,{avatars:s,isLeft:!0,message:{id:`question-${t.name}`,type:"question",content:a.content},ref:n?i:null,children:r?e.u(je,{}):e.u(e.g,{children:[a.isHtml?e.u(m.Html,{className:"chat-message-text",html:a.content}):e.u("div",{className:"chat-message-text",children:a.content}),t.type==="videovoice"&&e.u(Te,{properties:t.props,questionId:t.name,surveyVideoUrl:t.props.properties.videoUrl})]})})},Ye=({card:t,avatars:s})=>{const r=(n=>{if(!("properties"in n.props)||!n.props.properties||typeof n.props.properties!="object")return null;const i=n.props.properties,a=[{key:"captionHtml",isHtml:!0},{key:"captionText",isHtml:!1},{key:"richTextBody",isHtml:!0},{key:"body",isHtml:!1}];for(const{key:l,isHtml:c}of a){const u=i[l];if(typeof u!="string")continue;const h=u.trim();if(h){if(c&&!h.replaceAll(/<[^>]*>/g,"").trim())continue;return{content:h,isHtml:c}}}return null})(t);return r?e.u(Y,{avatars:s,hideAvatar:!0,isLeft:!0,message:{id:`caption-${t.name}`,type:"question",content:r.content},children:r.isHtml?e.u(m.Html,{className:"chat-message-text",html:r.content}):e.u("div",{className:"chat-message-text",children:r.content})}):null},Ke=({card:t,userResponse:s,avatars:r})=>{const n=((i,a)=>{if(i.type==="open"&&a&&typeof a=="object"&&"value"in a)return a.value})(t,s);return e.u("div",{className:"chat-bubble-container chat-right",children:[e.u("div",{className:"chat-bubble chat-bubble-right chat-bubble-text-only",children:e.u("div",{className:"chat-message-text",children:n||e.u("div",{className:"chat-message-no-response",children:"No response"})})}),e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${r.respondentAvatar["1x"]} 1x, ${r.respondentAvatar["2x"]} 2x`})]})},Xe=({card:t,avatars:s,isCurrentQuestion:r,currentQuestionBubbleRef:n})=>{const{endCard:i}=e.useConfig(a=>({endCard:a.endCard}));return e.u(e.g,{children:[e.u(Y,{avatars:s,isLeft:!0,message:{id:`thanks-${t.name}`,type:"question",content:(i==null?void 0:i.headline)??"Great! Thank you for your participation."},ref:r?n:null}),(i==null?void 0:i.subheader)&&e.u(Y,{avatars:s,hideAvatar:!0,isLeft:!0,message:{id:`caption-${t.name}`,type:"question",content:i.subheader}}),e.u(Se,{})]})},Je=({card:t,cardIndex:s,index:r,avatars:n,cardResponses:i,questionThinkingStates:a,startingQuestionIdx:l,currentQuestionBubbleRef:c,handleCardResponse:u})=>{const h=s===r,g=s<r,o=Ce(t);if(o)return e.u(Xe,{avatars:n,card:t,currentQuestionBubbleRef:c,isCurrentQuestion:h});const d=`${t.name}`,f=i.get(d),C=t.type==="open",p=a.get(d),T=s>(l??0)&&t.type!=="thanks"&&t.type!=="uploading"&&(p===!0||p===void 0);return e.u(e.wn.Fragment,{children:[e.u(We,{avatars:n,card:t,currentQuestionBubbleRef:c,isCurrentQuestion:h,isThinking:T}),!T&&e.u(Ye,{avatars:n,card:t}),g&&C?e.u(Ke,{avatars:n,card:t,userResponse:f}):(!g||!C)&&!T&&e.u(Y,{avatars:n,isLeft:!1,message:{id:`card-${t.name}`,type:"card",content:""},children:e.u("div",{className:"chat-card-container",children:e.u(tt,{card:t,className:o?"chat-thanks-card":"chat-card",isAnswered:g,next:h?u:()=>{}})})})]},`question-card-${t.name}`)},Y=e.wn.forwardRef(({message:t,isLeft:s=!1,children:r,avatars:n,hideAvatar:i=!1},a)=>{const l=s?"chat-bubble-left":"chat-bubble-right";return e.u("div",{className:`chat-bubble-container ${s?"chat-left":"chat-right"}${s&&i?" chat-no-avatar":""}`,ref:a,children:[s&&!i&&e.u("img",{alt:"AI Avatar",className:"chat-avatar chat-avatar-left",srcSet:`${n.agentAvatar["1x"]} 1x, ${n.agentAvatar["2x"]} 2x`}),e.u("div",{className:`chat-bubble ${l}`,children:r||e.u("div",{className:"chat-message-text",children:t.content})}),!s&&!i&&e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${n.respondentAvatar["1x"]} 1x, ${n.respondentAvatar["2x"]} 2x`})]})});Y.displayName="ChatBubble";const et=()=>{const t=e.useConfig(r=>r.close),s=e.F(()=>()=>t(V.APP_ID),[t]);return e.u("div",{"aria-label":"Close button",className:"conversational-close-btn",onClick:s,onKeyPress:r=>{r.key==="Enter"&&s()},role:"button",tabIndex:0,children:e.u("svg",{fill:"none",height:"16px",viewBox:"0 0 13 13",width:"16px",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M2.54964 1.78369L1.78369 2.54964L5.73405 6.5L1.78369 10.4504L2.54964 11.2163L6.5 7.26595L10.4504 11.2163L11.2163 10.4504L7.26595 6.5L11.2163 2.54964L10.4504 1.78369L6.5 5.73405L2.54964 1.78369Z",fill:"#262136"})})})},tt=({card:t,next:s,className:r="",isAnswered:n=!1})=>{const i={className:n?`${r} answered-card`:r,next:n?()=>{}:s,questionId:t.name,type:t.type,isAnswered:n};switch(t.type){case"consentlegal":return e.u(_e,{...i,...t.props});case"likert":return e.u(Ne,{...i,...t.props});case"matrix":return e.u(Ie,{...i,...t.props});case"multiplechoice":return e.u(we,{...i,...t.props});case"multipleselect":return e.u(Ee,{...i,...t.props});case"nps":return e.u(Pe,{...i,...t.props});case"open":return e.u(qe,{...i,...t.props});case"rankorder":return e.u(Be,{...i,...t.props});case"recordedtask":return e.u(Fe,{...i,...t.props});case"texturlprompt":return e.u(Ve,{...i,...t.props});case"thanks":return e.u(Ge,{...i,...t.props});case"uploading":return e.u(Ze,{...i,...t.props});case"videovoice":return e.u(ze,{...i,...t.props});default:return null}};exports.default=({cards:t,next:s,previousResponses:r})=>{const{cardResponses:n,setCardResponse:i}=(()=>{const[v,_]=e.h(new Map);return{cardResponses:v,setCardResponse:e.T((k,E)=>{_(I=>new Map(I).set(k,E))},[])}})(),{index:a,isLongFormSurvey:l,avatars:c,startingQuestionIdx:u,viewDocument:h}=e.useConfig(v=>({index:v.index,isLongFormSurvey:de.isLongFormSurvey(v.studyType),avatars:v.avatars,startingQuestionIdx:v.startingQuestionIdx,viewDocument:v.viewDocument})),{currentQuestionBubbleRef:g,scrollToCurrentQuestion:o}=(({viewDocument:v})=>{const _=e._(null),k=e.T(()=>{const E=v.querySelector(".ul-card-main-content");if(_.current&&E&&E instanceof HTMLElement){const I=_.current.offsetTop-E.offsetTop-16;E.scrollTo({top:Math.max(0,I),behavior:"smooth"})}},[]);return{currentQuestionBubbleRef:_,scrollToCurrentQuestion:k}})({viewDocument:h}),d=((v,_,k)=>{const[E,I]=e.h(new Map);return e.p(()=>{if(v.length>0&&_<v.length){const S=v[_],y=`${S.name}`;if(_<=(k??0)||Ce(S))return void I(b=>new Map(b).set(y,!1));I(b=>new Map(b).set(y,!0));const R=setTimeout(()=>{I(b=>new Map(b).set(y,!1))},1e3);return()=>clearTimeout(R)}},[_,v,k]),E})(t,a,u),f=((v,_)=>{const[k,E]=e.h(new Set([0]));return e.p(()=>{E(I=>new Set(I).add(v))},[v]),e.p(()=>{const I=_??0;I>0&&E(S=>{const y=new Set(S);for(let R=0;R<=I;R++)y.add(R);return y})},[_]),k})(a,u),C=e.F(()=>({...r,...e.buildReadableResponseMap(t.map((v,_)=>{var k,E;return{...v,value:_<a?((k=n.get(`${v.name}`))==null?void 0:k.value)??null:null,secondaryValue:_<a?((E=n.get(`${v.name}`))==null?void 0:E.secondaryValue)??null:null}}))}),[r,n,t,a]),p=e.pipeReadableResponsesIntoCards(t,C);e.p(()=>{requestAnimationFrame(()=>{o()})},[a,o,d]);const T=e.T((v,_)=>{if(!_)return;const k=p[a];if(!k)return;const E=`${k.name}`;i(E,v);const I={...v,questionText:e.getProcessedQuestionText(k)};s([I])},[p,a,s,i]),w=p.map((v,_)=>({card:v,cardIndex:_})).filter(({cardIndex:v})=>f.has(v));return e.u("div",{className:"conversational-ui ul-conversational-ui","data-testid":"ui-container",children:[!l&&e.u(et,{}),e.u("div",{className:"chat-container",children:e.u("div",{className:"chat-messages",children:w.map(({card:v,cardIndex:_})=>e.u(Je,{avatars:c,card:v,cardIndex:_,cardResponses:n,currentQuestionBubbleRef:g,handleCardResponse:T,index:a,questionThinkingStates:d,startingQuestionIdx:u},`question-card-${v.name}`))})})]})};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./view-BGzeHt4l.cjs"),m=require("./getAttributedUrl-CJJ96Ihj.cjs"),V=require("./core-Br8FqGd4.cjs"),de=require("./metricsReporter-Dc4CZlRc.cjs"),Te=({properties:t,surveyVideoUrl:s,questionId:r})=>{const n=`ul-card-video__question_player-q${r}`,{apiURL:i,viewDocument:a}=e.useConfig(l=>({apiURL:l.apiURL,viewDocument:l.viewDocument}));return e.u("div",{id:n,ref:l=>{if(l&&l.children.length===0&&!t.properties.hideRecordedPrompt){const c=m.videoPlayer(n,{src:s,type:"application/x-mpegURL"},void 0,t.properties.mediaType===m.RECORDER.MEDIA_TYPE_AUDIO,i,a);l.appendChild(c)}}})},z=({isDisabled:t,onClick:s,children:r})=>e.u(m.Button,{className:"ul-card__button-checkmark",disabled:t,onClick:s,type:"button",children:[e.u("svg",{fill:"none",height:"10",viewBox:"0 0 13 10",width:"13",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M11.5 1.5L4.5 8.5L1 5",stroke:"#ffffff",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})}),r||"Ok"]}),_e=({className:t,next:s,properties:r,questionId:n,type:i})=>{const{useMobileStyling:a,border:l}=e.useConfig(b=>({useMobileStyling:b.useMobileStyling,border:b.border})),[c,u]=e.h(!1),[h,g]=e.h(""),[o,d]=e.h(!1),f=r==null?void 0:r.collectName,x=(r==null?void 0:r.nameLabelText)||"Full Name",p=(r==null?void 0:r.consentText)||"I agree to the stated conditions",_=(r==null?void 0:r.submitButtonText)||"Submit",I=!!h.trim(),q=c&&(!f||I),C=(b,w=!1)=>{b.preventDefault(),b.stopPropagation();let D=null;if(!w){if(!q)return void d(!0);D={submitted:!0},f&&(D.name=h)}s({value:D,questionId:n,type:i},!!w||q)};return e.u("div",{className:e.cc(t,"ul-card__consent-legal","fade-in-transition"),children:e.u(m.MobileEmbedView,{embeddedType:"pdf",properties:r,children:e.u(m.QuestionBodyFooterContainer,{children:[e.u("div",{className:"sprig-stretch",children:[e.u(m.Option,{allowTextEntry:!1,border:l,error:o&&!c,id:"consent",isRadio:!1,isSelected:c,label:p,onUserInputChanged:({selected:b})=>{b!==c&&u(!c)},useMobileStyling:a}),f&&e.u("input",{"aria-label":x,"aria-placeholder":x,className:e.cc(e.getClasses("ul-consent-legal__name-input",a)),"data-gramm":"false",maxLength:250,name:"name",onBlur:b=>{b.currentTarget.style.borderColor=o&&!I?V.ERROR_BORDER_COLOR:V.DEFAULT_BORDER_COLOR},onFocus:b=>{b.currentTarget.style.borderColor=o&&!I?V.ERROR_BORDER_COLOR:l},onInput:b=>{b.preventDefault(),b.stopPropagation(),g(b.currentTarget.value)},placeholder:x,style:o&&!I?{borderColor:V.ERROR_BORDER_COLOR}:{},tabIndex:0,value:h})]}),e.u("div",{className:"ul-card__button-wrapper ul-card-vertical__button-wrapper",children:[e.u(z,{isDisabled:!q,onClick:b=>C(new SubmitEvent(b.type)),children:e.getButtonText({buttonText:_})}),r.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:b=>C(new SubmitEvent(b.type),!0),children:e.getSkipButtonText(r)})]})]})})},n)},Se=()=>{const{destroy:t,forceBrandedLogo:s}=e.useConfig(r=>({destroy:r.destroy,forceBrandedLogo:r.forceBrandedLogo}));return e.p(()=>{setTimeout(()=>{t(V.APP_ID)},s?4e3:2e3)},[t,s]),e.u("div",{className:"end-of-survey-text",children:"End of survey"})},Re=({activeValue:t,border:s,icon:r,enableCspTrustedTypes:n,isPressed:i,range:a,scaleLabelType:l,selectedValue:c,setSelectedValue:u,setActiveValue:h,setIsPressed:g,useMobileStyling:o,value:d,viewDocument:f})=>{const x=`option-${d}`,p=l==="number",_=l==="star",I=l==="smiley",q=p&&d===t||d===c,[C,b]=(()=>{const k=_&&c!==null&&d<=c;return _&&d<=t||I&&d===t||k||d===t||d===c?[s,i||k||d===c?1:.3]:["",1]})(),w=e.F(()=>{const k={borderColor:q?C:"",fillOpacity:q?"":b,zIndex:q?3:"auto",color:c===d?"#fff":""};return p?{...k,backgroundColor:c===d?C:""}:{...k,color:_||I||c===d?C:""}},[q,C,b,c,d,p,_,I]),D=e.F(()=>V.getHtml((({icon:k,scaleLabelType:y,value:R,selectedValue:v})=>{if(y==="smiley"&&R===v){let S=0;return k.replace(/black/g,()=>++S==1?"black":"white")}return k})({icon:r,scaleLabelType:l,value:d,selectedValue:c}),n),[n,r,l,c,d]);return e.u("button",{"aria-label":p?void 0:String(d),className:(()=>{switch(l){case"star":return e.cc(e.getClasses("likert-star",o),e.getClasses(`likert-star-${d}`,o));case"smiley":return e.cc(e.getClasses("likert-smiley",o),e.getClasses(`likert-smiley-${d}`,o));default:return d===a?e.cc(e.getClasses("likert-number",o),e.getClasses(`likert-number-${d}`,o),e.getClasses("likert-last-option",o)):e.cc(e.getClasses("likert-number",o),e.getClasses(`likert-number-${d}`,o))}})(),dangerouslySetInnerHTML:{__html:D},id:x,onClick:k=>{k.preventDefault(),k.stopPropagation(),u(d)},onKeyDown:k=>{var v,S;const y=f.querySelectorAll(`.likert-${l??"number"}`),R=d-1;k.key==="ArrowRight"?(v=y[R+1])==null||v.focus():k.key==="ArrowLeft"?(S=y[R-1])==null||S.focus():k.key!=="Enter"&&k.key!==" "||(k.preventDefault(),k.stopPropagation(),u(d))},onPointerDown:()=>g(!0),onPointerEnter:()=>h(d),onPointerLeave:()=>{h(-1),g(!1)},style:w,tabIndex:0})},Ne=({className:t,labels:s,next:r,properties:n,questionId:i,type:a})=>{const{border:l,useMobileStyling:c,viewDocument:u,enableCspTrustedTypes:h}=e.useConfig(y=>({border:y.border,useMobileStyling:y.useMobileStyling,viewDocument:y.viewDocument,enableCspTrustedTypes:y.enableCspTrustedTypes})),[g,o]=e.h(-1),[d,f]=e.h(!1),[x,p]=e.h(null),_=s&&s.left,I=s&&s.right;let q;const{range:C,scaleLabelType:b,ratingIcons:w}=n;C&&(q=Number(C));const D=q||5,k=y=>{var R,v;switch(b){case"star":return(R=w[0])==null?void 0:R.svg;case"smiley":return(v=w[y])==null?void 0:v.svg;default:return String(y+1)}};return e.u("form",{className:e.cc(t,"ul-card--likert","fade-in-transition"),children:e.u(m.MobileEmbedView,{properties:n,children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{"aria-label":`Rating (1 - ${D})`,className:"ul-card--likert__numbers",role:"radiogroup",children:[...Array(D)].map((y,R)=>{const v=R+1;return e.u(Re,{activeValue:g,border:l,enableCspTrustedTypes:h,icon:k(R),isPressed:d,range:D,scaleLabelType:b,selectedValue:x,setActiveValue:o,setIsPressed:f,setSelectedValue:p,useMobileStyling:c,value:v,viewDocument:u},R)})}),e.u("div",{className:"ul-card--likert__labels",children:[e.u("span",{children:_}),e.u("span",{children:I})]})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:x===null&&n.required,onClick:()=>r({value:x,questionId:i,type:a},!0),children:e.getButtonText(n)})})]})},i)},De=({columns:t,onSelect:s,options:r,selectedOptions:n})=>{const i=e._([]),{border:a,useMobileStyling:l}=e.useConfig(d=>({border:d.border,useMobileStyling:d.useMobileStyling})),c=r.findIndex(d=>n[d.id]===null),[u,h]=e.h(c),g=e.T((d,f)=>{s(d,f);const x=u+1,p=r[x];p&&n[p.id]===null&&h(x)},[s,r,n,u]),o=e.T((d,f)=>{const x=u===d;return e.u(e.Accordion,{animate:!0,header:f.label,isOpen:x,onClick:()=>{var p;return h(x&&!((p=window.UserLeap)!=null&&p.isMobileSDK)?-1:d)},ref:p=>{p&&(i.current[d]=p)},showHeaderCheck:n[f.id]!==null,children:e.u("div",{style:{paddingTop:"12px"},children:t.map(p=>e.u(m.Option,{allowTextEntry:!1,ariaLabel:`${f.label}-${p.label}`,border:a,error:!1,id:`${f.id}-${p.value}`,isRadio:!0,isSelected:n[f.id]===p.value,label:p.label,onUserInputChanged:()=>g(f.id,p.value),useMobileStyling:l},p.label))})},f.id)},[a,t,u,g,n,l]);return e.u("div",{children:r.map((d,f)=>o(f,d))})},Ie=({className:t,next:s,options:r,properties:n,questionId:i,type:a,onSubmitButtonClick:l})=>{const c=n.matrixColumn,u=n.required,h=x=>{x.preventDefault(),x.stopPropagation(),s({value:o,questionId:i,type:a},!0),l&&l()},g=r.reduce((x,p)=>(x[p.id]=null,x),{}),[o,d]=e.h(g);return e.u("form",{className:e.cc(t,"ul-card__matrix","fade-in-transition"),id:"text-form",onSubmit:h,children:e.u(m.MobileEmbedView,{properties:n,children:[e.u(m.QuestionBodyWrapper,{children:e.u(De,{columns:c,onSelect:(x,p)=>{d(_=>({..._,[x]:p}))},options:r,selectedOptions:o})}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:(f=o,u&&Object.values(f).every(x=>x==null)),onClick:()=>h(new SubmitEvent("submit")),children:e.getButtonText(n)})})]})},i);var f},pe=({className:t,onSubmit:s,options:r=[],properties:n,questionId:i,type:a,showIndividualSubmit:l=!1,onSubmitButtonClick:c})=>{const{border:u,useMobileStyling:h}=e.useConfig(v=>({border:v.border,useMobileStyling:v.useMobileStyling})),g=r.reduce((v,S)=>(v[S.id]={isSelected:!1},v),{}),[o,d]=e.h(g),f=a==="multiplechoice",x=n.required,p=r.find(v=>{var S;return(S=v.optionProperties)==null?void 0:S.noneOfTheAbove}),_=v=>Object.entries(v).some(([S,O])=>{var $;const A=r.find(j=>`${j.id}`===S),U=O.userText===void 0||O.userText.trim()==="";return(($=A==null?void 0:A.optionProperties)==null?void 0:$.allowsTextEntry)&&U&&O.isSelected}),I=v=>Object.values(v).filter(S=>S.isSelected).length,q=n.minSelect&&n.minSelect>0&&n.maxSelectMode===m.MaxSelectModes.Range&&I(o)<n.minSelect&&(x||I(o)>0),C=v=>_(v)||x&&!I(v)||!(S=>{const{minSelect:O=0,maxSelect:A=1/0,maxSelectMode:U}=n,$=I(S);switch(U){case m.MaxSelectModes.Maximum:return $<=A;case m.MaxSelectModes.Range:return $===0||$>=O;default:return!0}})(v),b=Object.entries(o).some(([v,S])=>{var O,A;return S.isSelected&&((A=(O=r.find(U=>`${U.id}`===v))==null?void 0:O.optionProperties)==null?void 0:A.allowsTextEntry)}),w=l&&(!f||b),D=v=>{R(v.id,v.selected,v.userText,v.noneOfTheAbove)},k=v=>{var S;return(n==null?void 0:n.maxSelectMode)!==m.MaxSelectModes.Unlimited&&I(o)===(n==null?void 0:n.maxSelect)&&!((S=o[v])!=null&&S.isSelected)},y=()=>{s(o,!0),c&&c()},R=(v,S,O,A)=>{const U=Object.assign({},o);if((f||A)&&S)for(const $ of Object.values(U))$.isSelected=!1,delete $.userText;else p&&!A&&o[p.id].isSelected&&(U[p.id].isSelected=!1);U[v]={isSelected:S,userText:O},d(U)};return e.u("form",{className:e.cc(t,"ul-card--multiple","fade-in-transition"),id:"text-form",onSubmit:y,children:e.u(m.MobileEmbedView,{properties:n,children:[e.u(m.QuestionBodyWrapper,{children:[n.isDropdown?e.u(m.Select,{disabledOptions:r.filter(v=>k(v.id)),dropdownFooter:q?e.u("div",{className:"ul-card__min-select-counter",style:{marginLeft:"16px"},children:[I(o),"/",n.minSelect]}):void 0,isMultiSelect:!f,multiselectText:n.dropdownMultiselectedText??"choices selected",onChange:v=>{const S={...o};for(const O of r)v.includes(O)?S[O.id].isSelected=!0:S[O.id].isSelected=!1;d(S)},options:r,placeholderText:n.dropdownPlaceholderText??(f?"Select choice":"Select choice(s)"),value:r.filter(v=>o[v.id].isSelected)}):e.u("div",{className:e.cc(e.getClasses("ul-card__choices",h)),role:f?"radiogroup":"group",children:[r.map(({id:v,label:S,value:O,optionProperties:A})=>{var Q,Z;const U=`${v}`,{allowsTextEntry:$,noneOfTheAbove:j}={allowsTextEntry:!1,noneOfTheAbove:!1,...A};return e.u(m.Option,{allowTextEntry:$,border:u,disabled:k(U),error:(F=o,_(F)),id:U,isRadio:f,isSelected:!!((Q=o[U])!=null&&Q.isSelected),label:S,noneOfTheAbove:j,onUserInputChanged:D,promptText:"Please specify",text:(Z=o[v])==null?void 0:Z.userText,useMobileStyling:h,value:O},U);var F}),!!q&&e.u("div",{className:"ul-card__min-select-counter",children:[I(o),"/",n.minSelect]})]}),w&&e.u(m.LongformSubmitButton,{handleSubmit:y,isSubmitDisabled:C(o)})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:C(o),onClick:y,children:e.getButtonText(n)})})]})},i)},we=t=>{const{questionId:s,type:r,next:n,options:i}=t;return e.u(pe,{...t,onSubmit:(a,l)=>{const c=Object.entries(a).find(([,d])=>d.isSelected)||[void 0,void 0],[u,h]=c,g=i.find(d=>`${d.id}`===u),o=h!=null&&h.userText?{[u]:{userText:h.userText}}:null;n({value:g&&u?{[u]:g.value}:{},secondaryValue:o,questionId:s,type:r},l)}})},Ee=t=>{const{questionId:s,type:r,next:n}=t;return e.u(pe,{...t,onSubmit:(i,a)=>{const l=Object.entries(i).reduce((u,[h,g])=>(u[h]=g.isSelected,u),{}),c=Object.entries(i).reduce((u,[h,g])=>{if(!g.userText)return u;const o=u||{};return o[h]={userText:g.userText},o},null);n({value:l,secondaryValue:c,questionId:s,type:r},a)}})},Pe=({className:t,labels:s,properties:r,next:n,questionId:i,type:a})=>{const[l,c]=e.h(null),{border:u,useMobileStyling:h,viewDocument:g}=e.useConfig(f=>({border:f.border,useMobileStyling:f.useMobileStyling,viewDocument:f.viewDocument})),o=s&&s.left,d=s&&s.right;return e.u("form",{className:e.cc(t,"ul-card--nps","fade-in-transition"),children:e.u(m.MobileEmbedView,{properties:r,children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--nps__numbers",children:[...Array(11)].map((f,x)=>e.u("button",{className:e.cc(e.getClasses("nps-number",h),e.getClasses(`nps-number-${x}`,h)),id:`option-${x}`,onClick:p=>{p.preventDefault(),p.stopPropagation(),c(x)},onKeyDown:p=>{var I,q;const _=g.querySelectorAll("button.nps-number");p.key==="ArrowRight"?(I=_[x+1])==null||I.focus():p.key==="ArrowLeft"?(q=_[x-1])==null||q.focus():p.key!=="Enter"&&p.key!==" "||(p.preventDefault(),p.stopPropagation(),c(x))},onPointerDown:p=>{p.currentTarget.style.zIndex="2",p.currentTarget.style.borderColor=u},onPointerLeave:p=>{p.currentTarget.style.zIndex="auto",p.currentTarget.style.borderColor=V.DEFAULT_BORDER_COLOR},style:l===x?{backgroundColor:u,color:"#fff"}:void 0,tabIndex:0,children:x},x))}),e.u("div",{className:"ul-card--nps__labels",children:[e.u("span",{children:o}),e.u("span",{children:d})]})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:l===null&&r.required,onClick:()=>n({value:l,questionId:i,type:a},!0),children:e.getButtonText(r)})})]})},i)},qe=({className:t,next:s,properties:r,questionId:n,type:i,onSubmitButtonClick:a})=>{const{border:l,useMobileStyling:c,update:u}=e.useConfig(_=>({border:_.border,useMobileStyling:_.useMobileStyling,update:_.update})),[h,g]=e.h(""),o=e._(null),d=h.trim(),f=r.required===!0&&!d,x=m.useAutoSize(o,()=>u()),p=r&&r.openTextPlaceholder?r.openTextPlaceholder:"";return e.u("form",{className:e.cc(t,"ul-card-text","fade-in-transition"),id:"text-form",children:e.u(m.MobileEmbedView,{properties:r,children:e.u("div",{className:"ul-card-text",children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card-text__container",children:e.u("textarea",{"aria-describedby":"ul-caption","aria-labelledby":"ul-question","aria-multiline":"true","aria-placeholder":p,className:e.cc(e.getClasses("ul-card-text__input",c)),"data-gramm":"false",maxLength:5e3,name:"text",onBlur:_=>{_.currentTarget.style.borderColor=V.DEFAULT_BORDER_COLOR},onChange:_=>{const{value:I}=_.currentTarget;x(),_.preventDefault(),_.stopPropagation(),g(I)},onFocus:_=>{_.currentTarget.style.borderColor=l},placeholder:p,ref:o,role:"textbox",tabIndex:0})}),r.footerHtml&&e.u(m.Html,{className:"footer",html:r.footerHtml})]}),e.u(m.QuestionBodyFooterContainer,{children:e.u(z,{isDisabled:f,onClick:_=>{_.preventDefault(),_.stopPropagation();const I=r.required!==!0||d.length>0;s({value:h,questionId:n,type:i},I),a&&a()},children:e.getButtonText(r)})})]})})},n)},Be=({className:t,labels:s,next:r,properties:n,questionId:i,type:a,onSubmitButtonClick:l,options:c})=>{const u=e._(null),h=e._(0),g=e._(0),o=e._(null),d=e._(!1),f=e._([]),[x,p]=e.h(()=>(n==null?void 0:n.required)===!0),[_,I]=e.h(()=>c.map(T=>({...T,rank:null}))),q=e.F(()=>Array.from({length:c.length},(T,E)=>E+1),[c.length]),{useMobileStyling:C,isPreview:b,headers:w}=e.useConfig(T=>({useMobileStyling:T.useMobileStyling,isPreview:T.isPreview,headers:T.headers})),D=(w==null?void 0:w["userleap-platform"])==="android",k=C&&!b&&!D,y=!k&&!D,R=(T,E)=>{I(P=>{const N=parseInt(E),M=P.map(B=>({...B}));M.some(B=>B.rank==null)&&M.forEach((B,W)=>B.rank=W+1);const H=M.findIndex(B=>B.id===T);if(H===-1)return P;const L=M[H].rank;return N<L?M.forEach(B=>{B.id!==T&&B.rank>=N&&B.rank<L&&(B.rank=B.rank+1)}):N>L&&M.forEach(B=>{B.id!==T&&B.rank>L&&B.rank<=N&&(B.rank=B.rank-1)}),M[H].rank=N,M.sort((B,W)=>B.rank-W.rank),j(),M})},v=(T,E)=>{for(let P=0;P<f.current.length;P++){const N=f.current[P];if(!N||N===o.current)continue;const M=N.getBoundingClientRect();if(T>=M.left&&T<=M.right&&E>=M.top&&E<=M.bottom)return{element:N,index:P}}return null},S=T=>E=>{if(!k)return;E.preventDefault(),E.stopPropagation(),d.current=!0,u.current=T;const P=E.touches[0];h.current=P.clientY,g.current=P.clientY;const N=E.currentTarget.closest(".ul-card-rank__option");N&&(o.current=N,N.classList.add("is-dragging"))},O=T=>{if(!k||!d.current||u.current===null)return;T.preventDefault(),T.stopPropagation();const E=T.touches[0];g.current=E.clientY;const P=g.current-h.current;o.current&&(o.current.style.transform=`translateY(${P}px)`,o.current.style.zIndex="1000"),f.current.forEach(M=>{M&&M!==o.current&&M.classList.remove("is-drop-target")});const N=v(E.clientX,E.clientY);N&&N.element.classList.add("is-drop-target")},A=T=>{if(!k||!d.current||u.current===null)return;T.preventDefault(),T.stopPropagation();const E=T.changedTouches[0],P=v(E.clientX,E.clientY);o.current&&(o.current.style.transform="",o.current.style.zIndex="",o.current.classList.remove("is-dragging")),f.current.forEach(N=>{N&&N.classList.remove("is-drop-target")}),P&&P.index!==u.current&&U(u.current,P.index),u.current=null,o.current=null,d.current=!1},U=(T,E)=>{I(P=>{const N=P.map(H=>({...H})),[M]=N.splice(T,1);return N.splice(E,0,M),N.forEach((H,L)=>{H.rank=L+1}),j(),N})},$=T=>{const E={};T.reduce((P,N)=>(P[N.id]=N.rank,P),E),r({value:E,questionId:i,type:a},!0)},j=()=>{p(!1)},{left:F,right:Q}=s,Z=c.length,K=T=>{T.preventDefault(),T.currentTarget.classList.add("is-drop-target")},ke=T=>{T.currentTarget.classList.remove("is-drop-target")},xe=T=>{u.current=null,T.currentTarget.classList.remove("is-dragging")};return e.u("form",{className:e.cc(t,"ul-card-rank","fade-in-transition"),onSubmit:T=>{T.preventDefault(),$(_),l&&l()},children:e.u(m.MobileEmbedView,{properties:n,children:D?e.u(m.QuestionBodyWrapper,{children:e.u("div",{className:"ul-card--rank__question-inner-container",children:[e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:["1 - ",F]})}),e.u("ol",{className:"ul-card-rank__list",children:_.map(({id:T,label:E,rank:P})=>e.u("li",{className:"ul-card-rank__option",children:[e.u("select",{"aria-label":`Rank for ${E}`,className:e.cc("ul-card-rank__select",P==null&&"ul-card-rank__select--placeholder"),name:`rank[${T}]`,onChange:N=>R(T,N.currentTarget.value),value:P??"",children:[P==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),q.map(N=>e.u("option",{className:"ul-card-rank__select-option",value:N,children:N},`${N}-${i}`))]}),e.u("span",{children:E})]},T))}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[Z," - ",Q]})})]})}):e.u(e.g,{children:[e.u(m.QuestionBodyWrapper,{children:e.u("div",{className:"ul-card--rank__question-inner-container",children:[e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:["1 - ",F]})}),e.u("ol",{className:"ul-card-rank__list",onDragOver:D?void 0:T=>{T.preventDefault(),T.dataTransfer&&(T.dataTransfer.dropEffect="move")},children:_.map(({id:T,label:E,rank:P},N)=>{return e.u("li",{className:"ul-card-rank__option",draggable:!!y||void 0,onDragEnd:y?xe:void 0,onDragEnter:y?K:void 0,onDragLeave:y?ke:void 0,onDragStart:y?(H=N,L=>{u.current=H,L.dataTransfer&&(L.dataTransfer.effectAllowed="move",L.dataTransfer.setData("text/plain",String(H)),L.currentTarget.classList.add("is-dragging"))}):void 0,onDrop:y?(M=N,L=>{var W,ae;L.preventDefault(),L.currentTarget.classList.remove("is-drop-target");const B=u.current;u.current=null,(ae=(W=L.currentTarget.closest(".ul-card-rank__list"))==null?void 0:W.querySelector(".is-dragging"))==null||ae.classList.remove("is-dragging"),B!=null&&B!==M&&U(B,M)}):void 0,ref:L=>f.current[N]=L,children:[e.u("select",{"aria-label":`Rank for ${E}`,className:e.cc("ul-card-rank__select",P==null&&"ul-card-rank__select--placeholder"),name:`rank[${T}]`,onChange:L=>R(T,L.currentTarget.value),value:P??"",children:[P==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),q.map(L=>e.u("option",{className:"ul-card-rank__select-option",value:L,children:L},L))]}),e.u("span",{children:E}),!D&&e.u("button",{"aria-label":`Drag ${E} to reorder`,className:"ul-card-rank__drag-btn",onTouchEnd:k?A:void 0,onTouchMove:k?O:void 0,onTouchStart:k?S(N):void 0,title:"Drag to reorder",type:"button",children:e.u("svg",{fill:"none",height:"17",viewBox:"0 0 16 17",width:"16",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M5.75 11.625C6.37132 11.625 6.875 12.1287 6.875 12.75C6.875 13.3713 6.37132 13.875 5.75 13.875C5.12868 13.875 4.625 13.3713 4.625 12.75C4.625 12.1287 5.12868 11.625 5.75 11.625ZM10.25 11.625C10.8713 11.625 11.375 12.1287 11.375 12.75C11.375 13.3713 10.8713 13.875 10.25 13.875C9.62868 13.875 9.125 13.3713 9.125 12.75C9.125 12.1287 9.62868 11.625 10.25 11.625ZM5.75 7.375C6.37132 7.375 6.875 7.87868 6.875 8.5C6.875 9.12132 6.37132 9.625 5.75 9.625C5.12868 9.625 4.625 9.12132 4.625 8.5C4.625 7.87868 5.12868 7.375 5.75 7.375ZM10.25 7.375C10.8713 7.375 11.375 7.87868 11.375 8.5C11.375 9.12132 10.8713 9.625 10.25 9.625C9.62868 9.625 9.125 9.12132 9.125 8.5C9.125 7.87868 9.62868 7.375 10.25 7.375ZM5.75 3.125C6.37132 3.125 6.875 3.62868 6.875 4.25C6.875 4.87132 6.37132 5.375 5.75 5.375C5.12868 5.375 4.625 4.87132 4.625 4.25C4.625 3.62868 5.12868 3.125 5.75 3.125ZM10.25 3.125C10.8713 3.125 11.375 3.62868 11.375 4.25C11.375 4.87132 10.8713 5.375 10.25 5.375C9.62868 5.375 9.125 4.87132 9.125 4.25C9.125 3.62868 9.62868 3.125 10.25 3.125Z",fill:"currentColor"})})})]},T);var M,H})}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[Z," - ",Q]})})]})}),e.u(m.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(m.Button,{disabled:x,children:e.getButtonText(n)})})})]})})},i)},te=1,me=2,he=3,X=t=>t.type==="av_permission",oe=t=>t.type==="screen_permission",ge=(t,s)=>t===void 0?te:t?((r,n)=>!(X(n)?n.permissionDescriptors:[]).includes("camera")||r.getVideoTracks().length>0)(t,s)?he:te:me,le={avStream:null,currentPage:null,mediaRecordingUids:null,nextQuestion:()=>{},passthroughData:void 0,recordingMediaTypes:void 0,screenPermissionRequested:!1,type:void 0},G=e.create(t=>({...le,reset:()=>{t(le)},updatePage:s=>{t(s)}}));function re({currentPage:t,pages:s}){const{avStream:r,recordingMediaTypes:n,updatePage:i}=G.getState(),{recorderEventEmitter:a}=e.useConfig.getState();a.emit("av.permission",{"permission.descriptors":t.permissionDescriptors,"stream.ready":(l,c)=>{if(r===l)return;let u=t;if(l&&!t.permissionDescriptors.includes("camera")){const h=s.indexOf(t),g=c!=null&&c.active?h+2:h+1;c!=null&&c.active&&n&&a.emit("begin.recording",{"recording.media.types":n,"start.recording.callback":o=>i({mediaRecordingUids:o})}),u=s[g]}i({currentPage:u,avStream:l})}})}function ne({status:t}){const{nextQuestion:s,passthroughData:r,mediaRecordingUids:n,reset:i}=G.getState(),{recorderEventEmitter:a,handleUploadUpdate:l,index:c}=e.useConfig.getState(),u={value:{taskStatus:t},type:"recordedtask",questionId:(r==null?void 0:r.questionId)||1};r&&a.emit("finish.task",{"begin.callback":h=>{l({mediaRecordingUid:h,isSubmitted:!0,progressPct:0,isComplete:!1})},"progress.callback":(h,g)=>{l({mediaRecordingUid:h,progressPct:g.detail,isSubmitted:!1,isComplete:!1})},"upload.callback":h=>{h&&l({mediaRecordingUid:h,isComplete:!0,isSubmitted:!0,progressPct:100})},"passthrough.data":r,"current.index":c,"task.response":u,"task.complete.callback":h=>{u.value.taskDurationMillisecond=h,n&&(u.value.mediaRecordingUids=n),i(),s(u)}})}function se({pages:t,setIsRequestingPermission:s}){const{recorderEventEmitter:r,eventEmitFn:n}=e.useConfig.getState(),{updatePage:i,currentPage:a,recordingMediaTypes:l,screenPermissionRequested:c}=G.getState();if(!a)return;const u=t.indexOf(a);switch(a.type){case"av_permission":{const h=c?u+2:u+1;return c&&l&&r.emit("begin.recording",{"recording.media.types":l,"start.recording.callback":g=>{i({mediaRecordingUids:g})}}),void i({currentPage:t[h]})}case"screen_permission":return void r.emit("screen.permission",{"screen.permission.requested":s,"stream.ready.callback":(h,g)=>{const o=g?t[u+1]:a;g&&l&&r.emit("begin.recording",{"recording.media.types":l,"start.recording.callback":d=>{i({captureStream:g,mediaRecordingUids:d})}}),i({currentPage:o,screenPermissionRequested:!0,captureStream:g})}});case"start_task":return n("recorded.task.start"),r.emit("recorded.task.start"),r.emit("start.task"),void i({currentPage:t[u+1],screenPermissionRequested:!0});case"complete_task":return}}const ve="ul-permission-graphics-container",be="ul-permission-body",ye=e.cc(ve,"ul_recorded-task-inset-spacing"),J=e.cc("ul-horizontal-button-container","ul-horizontal-button-container-left"),fe=({richTextBody:t})=>e.u(m.Html,{className:"ul-rich-text-body",html:t,id:"ul-task-detail-container"}),ee=({required:t,skipButtonText:s,bottom:r=!1})=>t?null:e.u(m.Button,{className:e.cc(r&&"ul-skip-button-below","ul-button-inactive"),onClick:ne.bind(null,{status:"abandoned"}),children:s||"Skip"}),ie=t=>{const{avStream:s,captureStream:r,recordingMediaTypes:n,updatePage:i}=G.getState(),a=(n==null?void 0:n.includes("audio"))||(n==null?void 0:n.includes("video"));e.p(()=>{const l=setInterval(()=>{a&&s&&!s.active?i({avStream:null,currentPage:t[0]}):r&&r.active||i({captureStream:void 0,currentPage:t[a?1:0]})},1e3);return()=>clearInterval(l)},[s,r,a,t,n,i])},Me=({content:t,pages:s,required:r})=>{const{buttonText:n,skipButtonText:i,taskDetail:a}=t;return ie(s),e.u("div",{className:"ul-task-page",children:[a&&e.u(fe,{richTextBody:a}),e.u("div",{className:J,children:[e.u(m.Button,{onClick:se.bind(null,{pages:s}),children:n}),e.u(ee,{required:r,skipButtonText:i})]})]},"start-task")},Le=({content:t,pages:s,properties:r})=>{const{buttonText:n,skipButtonText:i}=t;return ie(s),e.u("div",{className:"ul-task-page",children:[t.taskDetail&&e.u(fe,{richTextBody:t.taskDetail}),e.u(m.MobileEmbedView,{properties:r,children:e.u("div",{className:J,children:[e.u(m.Button,{className:"ul-complete-task-button",onClick:ne.bind(null,{status:"completed"}),children:n}),e.u(m.Button,{className:e.cc("ul-button-inactive"),onClick:ne.bind(null,{status:"given.up"}),children:i})]})})]},"complete-task")},Oe=({content:t,pages:s,required:r})=>{const{buttonText:n,skipButtonText:i}=t,[a]=e.useConfig(u=>[u.tabTitle]),[l,c]=e.h(!1);return e.u("div",{children:[e.u("div",{className:ye,children:[e.u("p",{style:{marginTop:"auto"},children:t.selectTabText}),e.u("div",{className:"ul-select-tab-container",children:e.u("p",{className:be,children:a})})]}),e.u("div",{className:r?"":J,children:[e.u(m.Button,{disabled:l,onClick:se.bind(null,{pages:s,setIsRequestingPermission:c}),children:n}),e.u(ee,{required:r,skipButtonText:i})]})]})},Ue=({content:t})=>e.u(m.Html,{className:e.cc(ve,"ul_permission_svg_container","ul_recorded-task-inset-spacing","ul-center-horizontally"),html:t.svg},"ul-permission-request-graphic"),Ae=({content:t,pages:s,required:r})=>{const{permissionDeniedHeadline:n,permissionDeniedBody:i,skipButtonText:a,tryAgainButtonText:l}=t,c=X(s[0])?s[0]:null;return e.p(()=>{const u=setInterval(()=>{c!==null&&re({currentPage:c,pages:s})},1e3);return()=>clearInterval(u)},[c,s]),c?e.u("div",{children:[e.u("div",{className:ye,children:e.u("p",{className:"ul-av-permission-denied-paragraph",children:[e.u("span",{className:"ul-av-permission-denied-headline",children:n}),e.u("span",{className:be,children:i})]})}),e.u("div",{className:J,children:[e.u(m.Button,{onClick:re.bind(null,{currentPage:c,pages:s}),children:l}),e.u(ee,{required:r,skipButtonText:a})]})]}):null},$e=({stream:t})=>e.u("video",{autoPlay:!0,className:e.cc("ul_recorded-task-inset-spacing"),id:"ul-record-task-video-preview",muted:!0,ref:s=>{s&&(s.srcObject=t||null)}}),Qe=({content:t,pages:s,required:r})=>{const{skipButtonText:n}=t,{avStream:i}=G.getState();return ie(s),e.u("div",{children:[e.u($e,{stream:i}),e.u("div",{className:"ul-vertical-button-container-center",children:[e.u(m.Button,{onClick:se.bind(null,{pages:s}),children:t.buttonText}),e.u(ee,{bottom:!0,required:r,skipButtonText:n})]})]})},He=({properties:t})=>{const{pages:s,required:r}=t,{avStream:n,currentPage:i}=G.getState();if(i===void 0)return null;switch(i==null?void 0:i.type){case"av_permission":{const a=ge(n,i);return a===te?e.u(Ue,{content:i}):a===me?e.u(Ae,{content:i,pages:s,required:r}):e.u(Qe,{content:i,pages:s,required:r})}case"screen_permission":return e.u(Oe,{content:i,pages:s,required:r});case"start_task":return e.u(Me,{content:i,pages:s,required:r});case"complete_task":return e.u(Le,{content:i,pages:s,properties:t});default:return null}},Fe=({className:t,properties:s,next:r,questionId:n})=>{const i=e.useConfig(),{surveyId:a,responseGroupUid:l,userId:c}=i,u=G(),{screenPermissionRequested:h}=u,g=G(p=>p.avStream);let o=G(p=>p.currentPage);o||(o=function({pages:p,userId:_,responseGroupUid:I,surveyId:q,questionId:C,next:b}){const{updatePage:w}=G.getState(),{eventEmitFn:D,recorderEventEmitter:k}=e.useConfig.getState(),y={questionId:C,surveyId:q,visitorId:_,responseGroupUid:I};let R=0;k.emit("recorded.task.permission.screen"),D("recorded.task.permission.screen"),k.emit("permission.status",{"permission.status.callback":(S,O,A,U)=>{const $=p[R],{type:j}=$,F=["screen"];if(X($)){const{permissionDescriptors:Q}=$,Z=Q==null?void 0:Q.includes("microphone"),K=Q==null?void 0:Q.includes("camera");Z&&F.push("audio"),K&&F.push("video"),(S!=null&&S.active&&!K||S!=null&&S.active&&O)&&R++}oe(p[R])&&A&&(R++,k.emit("begin.recording",{"recording.media.types":F,"start.recording.callback":Q=>w({mediaRecordingUids:Q})})),w({currentPage:p[R],avStream:S,screenPermissionRequested:A,nextQuestion:b,type:j,passthroughData:y,recordingMediaTypes:F,captureStream:U})}});const v=p[R];return v.type==="av_permission"&&re({currentPage:v,pages:p}),v}({questionId:n,surveyId:a,next:p=>{r(p,!0)},pages:s.pages,responseGroupUid:l,userId:c}));let d=o.headline,f=o.captionText;const x=ge(g,o);return oe(o)&&h&&(d=o.permissionDeniedHeadline,f=o.permissionDeniedCaptionText),X(o)&&x===he&&(d=o.permissionGrantedHeadline,f=o.permissionGrantedCaptionText),e.u("div",{className:e.cc(t,"ul-center-horizontally","fade-in-transition"),children:[e.u(m.Header,{isRequired:s==null?void 0:s.required,message:d,properties:{captionText:f}}),e.u(m.QuestionBodyWrapper,{children:e.u(He,{properties:s})})]})},Ve=({className:t,next:s,properties:r,questionId:n,type:i})=>{const{visitorAttributes:a,isLongFormSurvey:l}=e.useConfig(g=>({visitorAttributes:g.visitorAttributes,isLongFormSurvey:de.isLongFormSurvey(g.studyType)})),c=(g,o=!1)=>{s({value:o?{skipped:!0}:void 0,questionId:n,type:i},!0)},u=m.getAttributedUrl(r&&r.buttonUrl,a),h=l&&r.promptActionType===m.PromptActionTypeEnum.NO_BUTTON;return e.u("div",{className:e.cc(t,"ul-card__text-url-prompt","fade-in-transition"),children:e.u(m.MobileEmbedView,{properties:r,children:!h&&e.u("div",{children:e.u("div",{className:"ul-card-button-group",children:[e.u("a",{className:"ul-card-text__button ul-card__text-url-prompt-button",href:u,id:"ul-card-text__button",onClick:c,onKeyPress:g=>{g.key!=="Enter"&&g.key!==" "||s({value:void 0,questionId:n,type:i},!0)},rel:"noreferrer",role:u?"link":"button",tabIndex:0,target:"_blank",children:e.getButtonText(r)}),r.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:g=>c(0,!0),children:e.getSkipButtonText(r)})]})})})},n)},Ge=({className:t,questionId:s})=>{const{border:r,destroy:n,endCard:i,forceBrandedLogo:a}=e.useConfig(u=>({border:u.border,destroy:u.destroy,endCard:u.endCard,forceBrandedLogo:u.forceBrandedLogo}));e.p(()=>{setTimeout(()=>{n(V.APP_ID)},a?4e3:2e3)},[n,a]);const l=i&&i.subheader?e.u("p",{className:"ul-caption",children:i.subheader}):null,c=i&&i.headline?i.headline:"";return e.u("div",{className:e.cc(t,"ul-card--thanks","fade-in-transition"),children:e.u("div",{children:e.u("div",{className:"ul-card--thanks-content",children:[e.u("div",{className:"ul-thanks-check",children:e.u("svg",{"aria-labelledby":"title",fill:"none",height:"99",viewBox:"0 0 81 99",width:"81",xmlns:"http://www.w3.org/2000/svg",children:[e.u("path",{clipRule:"evenodd",d:"M40.5 77C60.9345 77 77.5 60.4345 77.5 40C77.5 19.5655 60.9345 3 40.5 3C20.0655 3 3.5 19.5655 3.5 40C3.5 60.4345 20.0655 77 40.5 77ZM80.5 40C80.5 62.0914 62.5914 80 40.5 80C18.4086 80 0.5 62.0914 0.5 40C0.5 17.9086 18.4086 0 40.5 0C62.5914 0 80.5 17.9086 80.5 40Z",fill:r,fillRule:"evenodd"}),e.u("path",{clipRule:"evenodd",d:"M55.025 22.9046C55.6299 23.4705 55.6616 24.4198 55.0956 25.0247C54.8724 25.2634 54.6109 25.5285 54.3157 25.8277C52.2547 27.9168 48.5549 31.667 44.8135 39.6658C43.2818 42.9406 42.0864 45.8386 41.0823 48.2729C40.6539 49.3116 40.2603 50.2659 39.8902 51.129C39.287 52.5359 38.7248 53.7508 38.1744 54.625C37.8997 55.0613 37.5806 55.4905 37.2017 55.8245C36.8201 56.1607 36.2613 56.5 35.5457 56.5C34.6742 56.5 34.0892 55.9692 33.7774 55.6083C33.4502 55.2296 33.1752 54.7511 32.9396 54.301C32.7305 53.9013 32.5088 53.4367 32.2797 52.9565C32.2429 52.8794 32.2059 52.8019 32.1688 52.7243C31.8942 52.1499 31.5959 51.534 31.2537 50.8868C29.8886 48.305 27.8539 45.2878 24.2343 43.1382C23.522 42.7152 23.2875 41.7949 23.7105 41.0826C24.1335 40.3703 25.0539 40.1358 25.7662 40.5588C30.0556 43.1062 32.4149 46.6647 33.9058 49.4845C34.2776 50.1876 34.5973 50.8487 34.8753 51.4302C34.9147 51.5124 34.9529 51.5926 34.9902 51.6707C35.2222 52.1567 35.4164 52.5637 35.5978 52.9102C35.6151 52.9434 35.6321 52.9754 35.6485 53.0061C36.0565 52.3531 36.5341 51.3434 37.133 49.9468C37.4781 49.1418 37.8572 48.2229 38.2761 47.2074C39.2886 44.7532 40.5339 41.7347 42.0961 38.3948C46.0591 29.9221 50.0641 25.8648 52.1535 23.7482C52.4423 23.4556 52.6944 23.2002 52.9048 22.9753C53.4708 22.3703 54.42 22.3387 55.025 22.9046ZM35.1994 53.5892C35.1994 53.5892 35.2 53.5888 35.2012 53.5879C35.2 53.5889 35.1994 53.5893 35.1994 53.5892ZM36.0666 53.6682C36.0732 53.674 36.0765 53.6775 36.0765 53.6777C36.0765 53.678 36.0732 53.6751 36.0666 53.6682Z",fill:r,fillRule:"evenodd"}),e.u("path",{d:"M69.5 97C69.5 98.1046 56.2924 99 40 99C23.7076 99 10.5 98.1046 10.5 97C10.5 95.8954 23.7076 95 40 95C56.2924 95 69.5 95.8954 69.5 97Z",fill:"black",fillOpacity:"0.2"})]})}),e.u(m.Header,{message:c}),l]})})},s)},je=()=>e.u("div",{className:"thinking-dots-container",children:e.u("div",{className:"thinking-dot"})}),Ze=({className:t})=>{const{uploadProgress:s}=e.useConfig(a=>({uploadProgress:a.uploadProgress}));let r,n;Object.values(s).filter(a=>a.isSubmitted).length>1?(r="Your responses are processing",n="Please keep this tab open until your responses are fully processed."):(r="Your response is processing",n="Please keep this tab open until your response is fully processed.");const i=Math.round(Math.min(99,...Object.values(s).filter(a=>a.isSubmitted).map(a=>a.progressPct||0)));return e.u("div",{className:e.cc(t,"ul-card--uploading","fade-in-transition"),children:[e.u("div",{"aria-busy":"true","aria-label":"Processing...","aria-live":"polite",className:"ul-loading-spinner-container",role:"progressbar",children:e.u("div",{className:"ul-loading-spinner",children:[e.u("div",{className:"first"}),e.u("div",{className:"second"}),e.u("div",{className:"third"}),e.u("div",{className:"fourth"})]})}),e.u(m.Header,{message:`${r} (${i}% complete)`}),e.u("p",{className:"ul-caption",children:n})]})},ue=0,ce=1,ze=({className:t,next:s,properties:r,questionId:n,type:i})=>{const a=`ul-card-video__player_recorder-q${n}`,{apiURL:l,envId:c,handleUploadUpdate:u,headers:h,responseGroupUid:g,surveyId:o,viewDocument:d,visitorId:f}=e.useConfig(y=>({apiURL:y.apiURL,envId:y.envId,handleUploadUpdate:y.handleUploadUpdate,headers:y.headers,responseGroupUid:y.responseGroupUid,surveyId:y.surveyId,viewDocument:y.viewDocument,visitorId:y.userId})),[x,p]=e.h(!1),[_,I]=e.h(null),[q,C]=e.h(null),[b,w]=e.h(ue),D=(y,R)=>{y===m.RECORDER.UPLOAD_STARTED?(I(R[m.RECORDER.UPLOAD_ID]),C(R[m.RECORDER.MEDIA_RECORDING_UID]),p(!0)):y===m.RECORDER.DELETE?(I(null),C(null),p(!1)):y===m.RECORDER.UPLOAD_PROGRESS?isNaN(R[m.RECORDER.UPLOAD_PROGRESS_PCT])?u({mediaRecordingUid:R[m.RECORDER.MEDIA_RECORDING_UID],isComplete:!0}):u({mediaRecordingUid:R[m.RECORDER.MEDIA_RECORDING_UID],progressPct:R[m.RECORDER.UPLOAD_PROGRESS_PCT]}):y===m.RECORDER.UPLOAD_FINISHED&&u({mediaRecordingUid:R[m.RECORDER.MEDIA_RECORDING_UID],isComplete:!0})},k=y=>{y.preventDefault(),y.stopPropagation(),document.getElementById(a)&&m.stopRecording(a),_&&q?(u({mediaRecordingUid:q,isSubmitted:!0}),s({value:{mediaRecordingUid:q},questionId:n,type:i},!0)):s({value:null,questionId:n,type:i},!0)};return e.u("form",{className:e.cc(t,"ul-card--video","fade-in-transition"),id:"ul-video-interview-form",children:[e.u(m.QuestionBodyWrapper,{children:[e.u("div",{id:"ul-question-player-container",style:{display:b===ue?"":"none"},children:e.u(m.MobileEmbedView,{properties:r,children:e.u("button",{className:"ul-video-btn ul-record-response-btn",onClick:y=>{y.preventDefault(),y.stopPropagation(),document.getElementById(a)&&m.pauseQuestionPlayer(a),w(ce)}})})}),e.u("div",{style:{display:b===ce?"block":"none"},children:e.u("div",{id:"ul-recorder-player-container",ref:y=>{if(y&&y.children.length===0){const R=m.videoRecorderPlayer(a,{surveyId:o,responseGroupUid:g,questionId:n,visitorId:f,envId:c},l,D,void 0,{...h,"x-ul-video-recorder-origin":"sdk"},r.mediaType===m.RECORDER.MEDIA_TYPE_AUDIO,d);y.appendChild(R)}}})})]}),e.u(m.QuestionBodyFooterContainer,{children:[e.u(z,{isDisabled:!!r.required&&!x,onClick:k,children:e.getButtonText(r)}),e.u("button",{className:"ul-card-text__button ul-button-inactive ul-card-skip__button",id:"ul-card-video__skip_button",onClick:k,style:{...r.required?{display:"none"}:{},...x?{display:"none"}:{}},children:e.getSkipButtonText(r)})]})]})},Ce=t=>t.type==="thanks"||t.type==="uploading",We=({card:t,avatars:s,isThinking:r,isCurrentQuestion:n,currentQuestionBubbleRef:i})=>{const a=(l=>"properties"in l.props&&l.props.properties&&"questionHtml"in l.props.properties&&l.props.properties.questionHtml?{content:l.props.properties.questionHtml,isHtml:!0}:"message"in l.props?{content:l.props.message,isHtml:!1}:{content:"Question",isHtml:!1})(t);return e.u(Y,{avatars:s,isLeft:!0,message:{id:`question-${t.name}`,type:"question",content:a.content},ref:n?i:null,children:r?e.u(je,{}):e.u(e.g,{children:[a.isHtml?e.u(m.Html,{className:"chat-message-text",html:a.content}):e.u("div",{className:"chat-message-text",children:a.content}),t.type==="videovoice"&&e.u(Te,{properties:t.props,questionId:t.name,surveyVideoUrl:t.props.properties.videoUrl})]})})},Ye=({card:t,avatars:s})=>{const r=(n=>{if(!("properties"in n.props)||!n.props.properties||typeof n.props.properties!="object")return null;const i=n.props.properties,a=[{key:"captionHtml",isHtml:!0},{key:"captionText",isHtml:!1},{key:"richTextBody",isHtml:!0},{key:"body",isHtml:!1}];for(const{key:l,isHtml:c}of a){const u=i[l];if(typeof u!="string")continue;const h=u.trim();if(h){if(c&&!h.replaceAll(/<[^>]*>/g,"").trim())continue;return{content:h,isHtml:c}}}return null})(t);return r?e.u(Y,{avatars:s,hideAvatar:!0,isLeft:!0,message:{id:`caption-${t.name}`,type:"question",content:r.content},children:r.isHtml?e.u(m.Html,{className:"chat-message-text",html:r.content}):e.u("div",{className:"chat-message-text",children:r.content})}):null},Ke=({card:t,userResponse:s,avatars:r})=>{const n=((i,a)=>{if(i.type==="open"&&a&&typeof a=="object"&&"value"in a)return a.value})(t,s);return e.u("div",{className:"chat-bubble-container chat-right",children:[e.u("div",{className:"chat-bubble chat-bubble-right chat-bubble-text-only",children:e.u("div",{className:"chat-message-text",children:n||e.u("div",{className:"chat-message-no-response",children:"No response"})})}),e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${r.respondentAvatar["1x"]} 1x, ${r.respondentAvatar["2x"]} 2x`})]})},Xe=({card:t,avatars:s,isCurrentQuestion:r,currentQuestionBubbleRef:n})=>{const{endCard:i}=e.useConfig(a=>({endCard:a.endCard}));return e.u(e.g,{children:[e.u(Y,{avatars:s,isLeft:!0,message:{id:`thanks-${t.name}`,type:"question",content:(i==null?void 0:i.headline)??"Great! Thank you for your participation."},ref:r?n:null}),(i==null?void 0:i.subheader)&&e.u(Y,{avatars:s,hideAvatar:!0,isLeft:!0,message:{id:`caption-${t.name}`,type:"question",content:i.subheader}}),e.u(Se,{})]})},Je=({card:t,cardIndex:s,index:r,avatars:n,cardResponses:i,questionThinkingStates:a,startingQuestionIdx:l,currentQuestionBubbleRef:c,handleCardResponse:u})=>{const h=s===r,g=s<r,o=Ce(t);if(o)return e.u(Xe,{avatars:n,card:t,currentQuestionBubbleRef:c,isCurrentQuestion:h});const d=`${t.name}`,f=i.get(d),x=t.type==="open",p=a.get(d),_=s>(l??0)&&t.type!=="thanks"&&t.type!=="uploading"&&(p===!0||p===void 0);return e.u(e.wn.Fragment,{children:[e.u(We,{avatars:n,card:t,currentQuestionBubbleRef:c,isCurrentQuestion:h,isThinking:_}),!_&&e.u(Ye,{avatars:n,card:t}),g&&x?e.u(Ke,{avatars:n,card:t,userResponse:f}):(!g||!x)&&!_&&e.u(Y,{avatars:n,isLeft:!1,message:{id:`card-${t.name}`,type:"card",content:""},children:e.u("div",{className:"chat-card-container",children:e.u(tt,{card:t,className:o?"chat-thanks-card":"chat-card",isAnswered:g,next:h?u:()=>{}})})})]},`question-card-${t.name}`)},Y=e.wn.forwardRef(({message:t,isLeft:s=!1,children:r,avatars:n,hideAvatar:i=!1},a)=>{const l=s?"chat-bubble-left":"chat-bubble-right";return e.u("div",{className:`chat-bubble-container ${s?"chat-left":"chat-right"}${s&&i?" chat-no-avatar":""}`,ref:a,children:[s&&!i&&e.u("img",{alt:"AI Avatar",className:"chat-avatar chat-avatar-left",srcSet:`${n.agentAvatar["1x"]} 1x, ${n.agentAvatar["2x"]} 2x`}),e.u("div",{className:`chat-bubble ${l}`,children:r||e.u("div",{className:"chat-message-text",children:t.content})}),!s&&!i&&e.u("img",{alt:"User Avatar",className:"chat-avatar chat-avatar-right",srcSet:`${n.respondentAvatar["1x"]} 1x, ${n.respondentAvatar["2x"]} 2x`})]})});Y.displayName="ChatBubble";const et=()=>{const t=e.useConfig(r=>r.close),s=e.F(()=>()=>t(V.APP_ID),[t]);return e.u("div",{"aria-label":"Close button",className:"conversational-close-btn",onClick:s,onKeyPress:r=>{r.key==="Enter"&&s()},role:"button",tabIndex:0,children:e.u("svg",{fill:"none",height:"16px",viewBox:"0 0 13 13",width:"16px",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M2.54964 1.78369L1.78369 2.54964L5.73405 6.5L1.78369 10.4504L2.54964 11.2163L6.5 7.26595L10.4504 11.2163L11.2163 10.4504L7.26595 6.5L11.2163 2.54964L10.4504 1.78369L6.5 5.73405L2.54964 1.78369Z",fill:"#262136"})})})},tt=({card:t,next:s,className:r="",isAnswered:n=!1})=>{const i={className:n?`${r} answered-card`:r,next:n?()=>{}:s,questionId:t.name,type:t.type,isAnswered:n};switch(t.type){case"consentlegal":return e.u(_e,{...i,...t.props});case"likert":return e.u(Ne,{...i,...t.props});case"matrix":return e.u(Ie,{...i,...t.props});case"multiplechoice":return e.u(we,{...i,...t.props});case"multipleselect":return e.u(Ee,{...i,...t.props});case"nps":return e.u(Pe,{...i,...t.props});case"open":return e.u(qe,{...i,...t.props});case"rankorder":return e.u(Be,{...i,...t.props});case"recordedtask":return e.u(Fe,{...i,...t.props});case"texturlprompt":return e.u(Ve,{...i,...t.props});case"thanks":return e.u(Ge,{...i,...t.props});case"uploading":return e.u(Ze,{...i,...t.props});case"videovoice":return e.u(ze,{...i,...t.props});default:return null}};exports.default=({cards:t,next:s,previousResponses:r})=>{const{cardResponses:n,setCardResponse:i}=(()=>{const[C,b]=e.h(new Map);return{cardResponses:C,setCardResponse:e.T((w,D)=>{b(k=>new Map(k).set(w,D))},[])}})(),{index:a,isLongFormSurvey:l,avatars:c,startingQuestionIdx:u,viewDocument:h,update:g}=e.useConfig(C=>({index:C.index,isLongFormSurvey:de.isLongFormSurvey(C.studyType),avatars:C.avatars,startingQuestionIdx:C.startingQuestionIdx,viewDocument:C.viewDocument,update:C.update})),{currentQuestionBubbleRef:o,scrollToCurrentQuestion:d}=(({viewDocument:C})=>{const b=e._(null),w=e.T(()=>{const D=C.querySelector(".ul-card-main-content");if(b.current&&D&&D instanceof HTMLElement){const k=b.current.offsetTop-D.offsetTop-16;D.scrollTo({top:Math.max(0,k),behavior:"smooth"})}},[]);return{currentQuestionBubbleRef:b,scrollToCurrentQuestion:w}})({viewDocument:h}),f=((C,b,w)=>{const[D,k]=e.h(new Map);return e.p(()=>{if(C.length>0&&b<C.length){const y=C[b],R=`${y.name}`;if(b<=(w??0)||Ce(y))return void k(S=>new Map(S).set(R,!1));k(S=>new Map(S).set(R,!0));const v=setTimeout(()=>{k(S=>new Map(S).set(R,!1))},1e3);return()=>clearTimeout(v)}},[b,C,w]),D})(t,a,u),x=((C,b)=>{const[w,D]=e.h(new Set([0]));return e.p(()=>{D(k=>new Set(k).add(C))},[C]),e.p(()=>{const k=b??0;k>0&&D(y=>{const R=new Set(y);for(let v=0;v<=k;v++)R.add(v);return R})},[b]),w})(a,u),p=e.F(()=>({...r,...e.buildReadableResponseMap(t.map((C,b)=>{var w,D;return{...C,value:b<a?((w=n.get(`${C.name}`))==null?void 0:w.value)??null:null,secondaryValue:b<a?((D=n.get(`${C.name}`))==null?void 0:D.secondaryValue)??null:null}}))}),[r,n,t,a]),_=e.pipeReadableResponsesIntoCards(t,p);e.p(()=>{requestAnimationFrame(()=>{d()}),g()},[a,d,f,g]);const I=e.T((C,b)=>{if(!b)return;const w=_[a];if(!w)return;const D=`${w.name}`;i(D,C);const k={...C,questionText:e.getProcessedQuestionText(w)};s([k])},[_,a,s,i]),q=_.map((C,b)=>({card:C,cardIndex:b})).filter(({cardIndex:C})=>x.has(C));return e.u("div",{className:"conversational-ui ul-conversational-ui","data-testid":"ui-container",children:[!l&&e.u(et,{}),e.u("div",{className:"chat-container",children:e.u("div",{className:"chat-messages",children:q.map(({card:C,cardIndex:b})=>e.u(Je,{avatars:c,card:C,cardIndex:b,cardResponses:n,currentQuestionBubbleRef:o,handleCardResponse:I,index:a,questionThinkingStates:f,startingQuestionIdx:u},`question-card-${C.name}`))})})]})};
@@ -1,4 +1,4 @@
1
- "use strict";var vt=Object.defineProperty;var ft=(r,t,o)=>t in r?vt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var q=(r,t,o)=>ft(r,typeof t!="symbol"?t+"":t,o);const i=require("./metricsReporter-DC-3J5Sa.cjs"),qe=()=>{try{return window.parent.Intercom}catch{return null}},Fe=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const r=qe();r&&(r.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),r.ul_wasVisible&&r("update",{hide_default_launcher:!0}))},enable:()=>{const r=qe();r&&(r.ul_wasVisible&&r("update",{hide_default_launcher:!1}),delete r.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class Qe{static disable(){Fe.forEach(t=>t.disable())}static enable(){Fe.forEach(t=>t.enable())}}const Ve="ul-view-sdk-script",ht=new Set(["ios","android"]),T="visitors",C="environments";async function D(r,t){var n,a,s;const{shouldDropOnRateLimit:o,...d}=t;d.headers=Object.assign(i.getHttpHeaders(window.UserLeap),d.headers);const e=await i.sprigFetch(r,{...d,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=(a=e.headers)==null?void 0:a.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(r,t){const o=i.localStorageHelper.getItemObject("userleap.ids");let d=o[window.UserLeap.envId];d?d[r]=t:d={[r]:t},o[window.UserLeap.envId]=d,i.localStorageHelper.setItemObject("userleap.ids",o)}function ke(){return window.previewMode?"0":window.UserLeap.visitorId??""}function R(r,t,o){const d=[window.UserLeap._API_URL,"sdk",r];return t&&t.forEach(e=>{d.push(e),e===C?d.push(window.UserLeap.envId):e===T&&d.push(ke())}),o&&d.push(o),d.join("/")}const $=async(r,t,o)=>{var Ce,Pe,He,Me;const{context:d,delay:e,avatars:n,forceBrandedLogo:a,endCard:s,isFeedback:l=!1,heatmap:c,locale:p,layout:u,previewMode:y,productConfig:w,questions:g,responseGroupUid:v,surveyId:m,uuid:f,vid:U,sessionReplay:b,studyType:E,surveyVisitorAttributes:P}=r,h=i.getHttpHeaders(window.UserLeap),H=Q(h),_=pe(h);if(b)if(H)i.eventEmitter.emit(i.SprigEvent.ReplayCapture,{responseGroupUid:v,hasQuestions:!!(g!=null&&g.length),surveyId:m,uploadId:b.uploadId,replayType:b.replayDurationType??"before",seconds:b.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:U,replayParams:b,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:L,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:L,isHeatmap:!0,replayParams:j,responseGroupId:ge,surveyId:me,triggerTimestamp:Date.now(),visitorId:U})},"Error in scheduling/capturing replay")}if(U==null||!(g!=null&&g.length))return i.breadcrumbsLogger.info("CannotDisplaySurvey",{vid:U}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){i.breadcrumbsLogger.info("AlreadyDisplayingSurvey");const L="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}if(U!==window.UserLeap.visitorId&&f!==window.UserLeap.visitorId&&!window.previewMode){const L="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(L)),{success:!1,message:L,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=L=>{const{"view.version":j}=L;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 L=i.getHttpHeaders(window.UserLeap),j=Q(L),ge=window.UserLeap.forceDirectEmbed,me=L["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 W={apiURL:window.UserLeap._API_URL,avatars:n,cards:g,configureExitOnOverlayClick:L=>{i.eventEmitter.once(i.SprigEvent.CloseSurveyOnOverlayClick,L)},context:d,endCard:s,envId:window.UserLeap.envId,eventEmitFn:i.eventEmitter.emit.bind(i.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:a,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:t,ulEvents:i.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:_,userId:f,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;W.customStyles=yt,k&&(k.__cfg=W);const ue=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:W.path,Ae=document.getElementById(Ve);Ae&&Ae.remove();const we=function(){const L=document.createElement("script");return L.setAttribute("type","module"),window.UserLeap.nonce&&L.setAttribute("nonce",window.UserLeap.nonce),L.id=Ve,L}(),Oe=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(W.installationMethod==="web-npm"||W.installationMethod==="web-npm-bundled"){const{default:L}=await Promise.resolve().then(()=>require("./view-DAxlTNxd.cjs")).then(j=>j.view);L.configure(W),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",L=>{L.target instanceof HTMLScriptElement&&L.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(r){var o;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((o=window.UserLeap.windowDimensions)==null?void 0:o.width)??document.body.clientWidth;return Q(r)||t>10&&t<500}function Q(r){return ht.has(r["userleap-platform"])}const We=new WeakMap,St=(r,t)=>{try{return(d=>{var a,s;const e=We.get(d);if(e)return e;if(!((a=d.trustedTypes)!=null&&a.createPolicy))throw new Error("Trusted types not supported");const n=(s=d.trustedTypes)==null?void 0:s.createPolicy("sprig-sdk",{createHTML:l=>l,createScript:l=>l,createScriptURL:l=>l});return We.set(d,n),n})(t).createHTML(r)}catch(o){return console.warn("Could not create TrustedHTML object",o),r}},ce=(r,t,o=window)=>{var d;return t&&((d=o.trustedTypes)!=null&&d.createPolicy)?St(r,o):r},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=(r,t,o)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container"+(t?" ul-container-feedback":""),r&&(window.UserLeap.container.dataset.studyId=r.toString());const d=rt();o&&d&&!window.UserLeap.useMobileStyling?d.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Xe=(r,t)=>{var d;Et();const o=window.UserLeap.container;if(o)try{(d=o.parentNode)==null||d.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:r,"survey.id":parseInt(o.dataset.studyId),...t&&{studyType:t}})}catch(e){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${r} `+o),e instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",e)}},Ze=()=>{i.eventEmitter.once(i.SprigEvent.SurveyWillClose,({initiator:r,studyType:t})=>{i.eventEmitter.removeAllListeners(i.SprigEvent.CloseSurveyOnOverlayClick),Xe(r,t)})},bt=(r,t,o,d)=>{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({},t,window.UserLeap),{desktopDisplay:a}=t||{},s=a==="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(d)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(r.style,e,l),c},Lt=({productConfig:r,useMobileStyling:t,surveyId:o,isFeedback:d,enableCspTrustedTypes:e})=>{var w,g;const n=Re,a=d&&r.desktopDisplay==="slider";Ye(o,d,a),Ut();const s=document.createElement("iframe");s.id=n,s.setAttribute("title","Sprig User Feedback Dialog");const l=bt(s,r,t,d);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),r&&(t?r.exitOnOverlayClickMobile:r.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(),!t)){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(([r,t])=>{i.eventEmitter.on(r,t)})},Et=()=>{Object.entries(et).forEach(([r,t])=>{i.eventEmitter.off(r,t)})},A=r=>!!r&&r.nodeType===Node.ELEMENT_NODE,Be=r=>r instanceof HTMLElement||r instanceof SVGElement,Y=({document:r,elementId:t,styleString:o,nonce:d})=>{const e=r.getElementById(t);if(e)return void(e.textContent=o);const n=r.createElement("style");d&&(n.nonce=d),n.textContent=o,n.id=t,r.head.appendChild(n)},ze=(r,t)=>{const o=t.querySelector(r);if(!A(o))return 0;const d=getComputedStyle(o);return parseFloat(d.paddingLeft)+parseFloat(d.paddingRight)+(parseFloat(d.marginLeft)+parseFloat(d.marginRight))+(parseFloat(d.borderLeftWidth)+parseFloat(d.borderRightWidth))},tt=(r,t,o)=>{const d=r.querySelector(".ul-card__container"),e=r.querySelector(".ul-app");let n=600,a=360;if(A(d)&&A(e)){const s=d.querySelector(".ul-card--matrix_grid"),l=!s&&t&&o;try{l&&(e.style.width="360px"),n=d.scrollHeight,n+=(u=>{const y=u.querySelector(".sprig-question-body"),w=u.querySelector(".ul-card"),g=u.querySelector(".ul-card-main-content"),v=u.querySelector(".ul-footer"),m=u.querySelector(".sprig-container");let f=0;return A(w)&&(f+=w.scrollHeight-w.clientHeight),A(g)&&(f+=g.scrollHeight-g.clientHeight),A(y)&&(f+=y.scrollHeight-y.clientHeight),A(v)&&A(m)&&m.clientHeight===0&&(f+=v.clientHeight),f})(r);const c=getComputedStyle(d),p=parseFloat(c.marginTop)+parseFloat(c.marginBottom);n+=p+(parseFloat(c.borderTopWidth)+parseFloat(c.borderBottomWidth)),s&&(a=s.scrollWidth,a+=ze(".ul-card__container",r),a+=ze(".sprig-question-body",r))}finally{l&&e.style.removeProperty("width")}}return[n+2,a]},rt=()=>S,B=()=>document.getElementById("sprig-feedback-container"),Se=()=>document.getElementById("sprig-feedback-loading-animation"),it=()=>!!document.getElementById(Re);let Ne=!1,S=null,x=null,_e=!1,G=null,F=null;const It=["bottom-left","bottom-right","center-left","center-right"],re=()=>{var t;const r=window.UserLeap.container;return((t=r==null?void 0:r.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},nt=()=>document.getElementById("sprig-feedback-error-container"),ot=()=>{if(!S)return 0;const r=S==null?void 0:S.clientWidth,t=window.getComputedStyle(S);return r+parseInt(t.borderRightWidth||"0")+parseInt(t.borderLeftWidth||"0")},ie=r=>{const t=B();t&&(F!=null&&F.endsWith("right")?t.style.right=`${r}px`:F!=null&&F.endsWith("left")&&(t.style.left=`${r}px`))},ve=()=>{if(S&&(re()||nt())){i.eventEmitter.off(i.SprigEvent.SurveyAppeared,N),be();const r=ot();return ie(-r),!0}return!1},N=()=>{if(!S||!x)return;const r=Se();r&&r.remove(),S.style.height="auto",S.style.width="auto",x.disabled=!1,_e=!1},be=()=>{if(S&&!Se()){const r=(()=>{var o;if(Se())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=ce(`
1
+ "use strict";var vt=Object.defineProperty;var ft=(r,t,o)=>t in r?vt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var q=(r,t,o)=>ft(r,typeof t!="symbol"?t+"":t,o);const i=require("./metricsReporter-Dc4CZlRc.cjs"),qe=()=>{try{return window.parent.Intercom}catch{return null}},Fe=[Object.freeze(Object.defineProperty({__proto__:null,disable:()=>{const r=qe();r&&(r.ul_wasVisible=!!document.querySelector("iframe.intercom-launcher-frame"),r.ul_wasVisible&&r("update",{hide_default_launcher:!0}))},enable:()=>{const r=qe();r&&(r.ul_wasVisible&&r("update",{hide_default_launcher:!1}),delete r.ul_wasVisible)}},Symbol.toStringTag,{value:"Module"}))];class Qe{static disable(){Fe.forEach(t=>t.disable())}static enable(){Fe.forEach(t=>t.enable())}}const Ve="ul-view-sdk-script",ht=new Set(["ios","android"]),T="visitors",C="environments";async function D(r,t){var n,a,s;const{shouldDropOnRateLimit:o,...d}=t;d.headers=Object.assign(i.getHttpHeaders(window.UserLeap),d.headers);const e=await i.sprigFetch(r,{...d,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=(a=e.headers)==null?void 0:a.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(r,t){const o=i.localStorageHelper.getItemObject("userleap.ids");let d=o[window.UserLeap.envId];d?d[r]=t:d={[r]:t},o[window.UserLeap.envId]=d,i.localStorageHelper.setItemObject("userleap.ids",o)}function ke(){return window.previewMode?"0":window.UserLeap.visitorId??""}function R(r,t,o){const d=[window.UserLeap._API_URL,"sdk",r];return t&&t.forEach(e=>{d.push(e),e===C?d.push(window.UserLeap.envId):e===T&&d.push(ke())}),o&&d.push(o),d.join("/")}const $=async(r,t,o)=>{var Ce,Pe,He,Me;const{context:d,delay:e,avatars:n,forceBrandedLogo:a,endCard:s,isFeedback:l=!1,heatmap:c,locale:p,layout:u,previewMode:y,productConfig:w,questions:g,responseGroupUid:v,surveyId:m,uuid:f,vid:U,sessionReplay:b,studyType:E,surveyVisitorAttributes:P}=r,h=i.getHttpHeaders(window.UserLeap),H=Q(h),_=pe(h);if(b)if(H)i.eventEmitter.emit(i.SprigEvent.ReplayCapture,{responseGroupUid:v,hasQuestions:!!(g!=null&&g.length),surveyId:m,uploadId:b.uploadId,replayType:b.replayDurationType??"before",seconds:b.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:U,replayParams:b,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:L,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:L,isHeatmap:!0,replayParams:j,responseGroupId:ge,surveyId:me,triggerTimestamp:Date.now(),visitorId:U})},"Error in scheduling/capturing replay")}if(U==null||!(g!=null&&g.length))return i.breadcrumbsLogger.info("CannotDisplaySurvey",{vid:U}),{success:!1,message:"[Sprig] no survey found",surveyState:"no survey"};if(window.UserLeap.container){i.breadcrumbsLogger.info("AlreadyDisplayingSurvey");const L="[Sprig] (ERR-409) Found an existing Survey container, aborting rendering of this survey";return console.warn(L),{success:!1,message:L,surveyState:"no survey"}}if(U!==window.UserLeap.visitorId&&f!==window.UserLeap.visitorId&&!window.previewMode){const L="Attempted to display survey to a different visitor";return window.UserLeap.reportError("DisplaySurvey",new Error(L)),{success:!1,message:L,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=L=>{const{"view.version":j}=L;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 L=i.getHttpHeaders(window.UserLeap),j=Q(L),ge=window.UserLeap.forceDirectEmbed,me=L["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 W={apiURL:window.UserLeap._API_URL,avatars:n,cards:g,configureExitOnOverlayClick:L=>{i.eventEmitter.once(i.SprigEvent.CloseSurveyOnOverlayClick,L)},context:d,endCard:s,envId:window.UserLeap.envId,eventEmitFn:i.eventEmitter.emit.bind(i.eventEmitter),fontFamily:window.UserLeap.fontFamily,fontFamilyURL:window.UserLeap.fontFamilyURL,forceBrandedLogo:a,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:t,ulEvents:i.EVENTS,upchunkLibraryURL:window.UserLeap.upchunkLibraryURL,useMobileStyling:_,userId:f,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;W.customStyles=yt,k&&(k.__cfg=W);const ue=window.UserLeap.viewSDKURL?window.UserLeap.viewSDKURL:W.path,Ae=document.getElementById(Ve);Ae&&Ae.remove();const we=function(){const L=document.createElement("script");return window.UserLeap.isMobileSDK||L.setAttribute("type","module"),window.UserLeap.nonce&&L.setAttribute("nonce",window.UserLeap.nonce),L.id=Ve,L}(),Oe=()=>{window.UserLeap.container&&Object.assign(window.UserLeap.container.style,{display:"flex"})};if(W.installationMethod==="web-npm"||W.installationMethod==="web-npm-bundled"){const{default:L}=await Promise.resolve().then(()=>require("./view-BGzeHt4l.cjs")).then(j=>j.view);L.configure(W),X&&window.UserLeap.container&&Oe()}else ue&&(we.src=`${ue}${window.UserLeap.isMobileSDK?"":`?t=${Date.now()}`}`,X&&we.addEventListener("load",()=>{window.UserLeap.container&&Oe()}),k==null||k.addEventListener("error",L=>{L.target instanceof HTMLScriptElement&&L.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(r){var o;if(window.UserLeap.useMobileStyling!==void 0)return window.UserLeap.useMobileStyling;const t=((o=window.UserLeap.windowDimensions)==null?void 0:o.width)??document.body.clientWidth;return Q(r)||t>10&&t<500}function Q(r){return ht.has(r["userleap-platform"])}const We=new WeakMap,St=(r,t)=>{try{return(d=>{var a,s;const e=We.get(d);if(e)return e;if(!((a=d.trustedTypes)!=null&&a.createPolicy))throw new Error("Trusted types not supported");const n=(s=d.trustedTypes)==null?void 0:s.createPolicy("sprig-sdk",{createHTML:l=>l,createScript:l=>l,createScriptURL:l=>l});return We.set(d,n),n})(t).createHTML(r)}catch(o){return console.warn("Could not create TrustedHTML object",o),r}},ce=(r,t,o=window)=>{var d;return t&&((d=o.trustedTypes)!=null&&d.createPolicy)?St(r,o):r},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=(r,t,o)=>{window.UserLeap.container=document.createElement("div"),window.UserLeap.container.className="ul-container"+(t?" ul-container-feedback":""),r&&(window.UserLeap.container.dataset.studyId=r.toString());const d=rt();o&&d&&!window.UserLeap.useMobileStyling?d.appendChild(window.UserLeap.container):document.body.appendChild(window.UserLeap.container)},Xe=(r,t)=>{var d;Et();const o=window.UserLeap.container;if(o)try{(d=o.parentNode)==null||d.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:r,"survey.id":parseInt(o.dataset.studyId),...t&&{studyType:t}})}catch(e){console.warn(`[Sprig] (ERR-412) Error removing UserLeap container by ${r} `+o),e instanceof Error&&window.UserLeap.reportError("dismissActiveSurvey",e)}},Ze=()=>{i.eventEmitter.once(i.SprigEvent.SurveyWillClose,({initiator:r,studyType:t})=>{i.eventEmitter.removeAllListeners(i.SprigEvent.CloseSurveyOnOverlayClick),Xe(r,t)})},bt=(r,t,o,d)=>{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({},t,window.UserLeap),{desktopDisplay:a}=t||{},s=a==="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(d)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(r.style,e,l),c},Lt=({productConfig:r,useMobileStyling:t,surveyId:o,isFeedback:d,enableCspTrustedTypes:e})=>{var w,g;const n=Re,a=d&&r.desktopDisplay==="slider";Ye(o,d,a),Ut();const s=document.createElement("iframe");s.id=n,s.setAttribute("title","Sprig User Feedback Dialog");const l=bt(s,r,t,d);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),r&&(t?r.exitOnOverlayClickMobile:r.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(),!t)){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(([r,t])=>{i.eventEmitter.on(r,t)})},Et=()=>{Object.entries(et).forEach(([r,t])=>{i.eventEmitter.off(r,t)})},A=r=>!!r&&r.nodeType===Node.ELEMENT_NODE,Be=r=>r instanceof HTMLElement||r instanceof SVGElement,Y=({document:r,elementId:t,styleString:o,nonce:d})=>{const e=r.getElementById(t);if(e)return void(e.textContent=o);const n=r.createElement("style");d&&(n.nonce=d),n.textContent=o,n.id=t,r.head.appendChild(n)},ze=(r,t)=>{const o=t.querySelector(r);if(!A(o))return 0;const d=getComputedStyle(o);return parseFloat(d.paddingLeft)+parseFloat(d.paddingRight)+(parseFloat(d.marginLeft)+parseFloat(d.marginRight))+(parseFloat(d.borderLeftWidth)+parseFloat(d.borderRightWidth))},tt=(r,t,o)=>{const d=r.querySelector(".ul-card__container"),e=r.querySelector(".ul-app");let n=600,a=360;if(A(d)&&A(e)){const s=d.querySelector(".ul-card--matrix_grid"),l=!s&&t&&o;try{l&&(e.style.width="360px"),n=d.scrollHeight,n+=(u=>{const y=u.querySelector(".sprig-question-body"),w=u.querySelector(".ul-card"),g=u.querySelector(".ul-card-main-content"),v=u.querySelector(".ul-footer"),m=u.querySelector(".sprig-container");let f=0;return A(w)&&(f+=w.scrollHeight-w.clientHeight),A(g)&&(f+=g.scrollHeight-g.clientHeight),A(y)&&(f+=y.scrollHeight-y.clientHeight),A(v)&&A(m)&&m.clientHeight===0&&(f+=v.clientHeight),f})(r);const c=getComputedStyle(d),p=parseFloat(c.marginTop)+parseFloat(c.marginBottom);n+=p+(parseFloat(c.borderTopWidth)+parseFloat(c.borderBottomWidth)),s&&(a=s.scrollWidth,a+=ze(".ul-card__container",r),a+=ze(".sprig-question-body",r))}finally{l&&e.style.removeProperty("width")}}return[n+2,a]},rt=()=>S,B=()=>document.getElementById("sprig-feedback-container"),Se=()=>document.getElementById("sprig-feedback-loading-animation"),it=()=>!!document.getElementById(Re);let Ne=!1,S=null,x=null,_e=!1,G=null,F=null;const It=["bottom-left","bottom-right","center-left","center-right"],re=()=>{var t;const r=window.UserLeap.container;return((t=r==null?void 0:r.parentElement)==null?void 0:t.id)==="sprig-feedback-loading-container"},nt=()=>document.getElementById("sprig-feedback-error-container"),ot=()=>{if(!S)return 0;const r=S==null?void 0:S.clientWidth,t=window.getComputedStyle(S);return r+parseInt(t.borderRightWidth||"0")+parseInt(t.borderLeftWidth||"0")},ie=r=>{const t=B();t&&(F!=null&&F.endsWith("right")?t.style.right=`${r}px`:F!=null&&F.endsWith("left")&&(t.style.left=`${r}px`))},ve=()=>{if(S&&(re()||nt())){i.eventEmitter.off(i.SprigEvent.SurveyAppeared,N),be();const r=ot();return ie(-r),!0}return!1},N=()=>{if(!S||!x)return;const r=Se();r&&r.remove(),S.style.height="auto",S.style.width="auto",x.disabled=!1,_e=!1},be=()=>{if(S&&!Se()){const r=(()=>{var o;if(Se())return;const t=document.createElement("div");return t.className="ul-loading-spinner-container",t.id="sprig-feedback-loading-animation",t.role="progressbar",t.setAttribute("aria-live","polite"),t.setAttribute("aria-busy","true"),t.setAttribute("aria-label","Processing..."),t.innerHTML=ce(`
2
2
  <div class="ul-loading-spinner">
3
3
  <div class="first"></div>
4
4
  <div class="second"></div>
@@ -9,4 +9,4 @@
9
9
  <circle cx="20" cy="20" r="14.5" stroke="#B0B5B7" stroke-width="3"/>
10
10
  <path d="M20 12L20 21.6" stroke="#B0B5B7" stroke-width="3" stroke-linecap="round"/>
11
11
  <circle cx="19.9984" cy="27.6" r="1.6" fill="#B0B5B7"/>
12
- </svg>`,(o=window.UserLeap._config)==null?void 0:o.enableCspTrustedTypes);const t=document.createElement("h3");return t.className="sprig-feedback-error-text",t.innerText="There was an error while loading the survey",r.appendChild(t),r},Le=new class{constructor(){q(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(r){try{return!(!r||typeof r!="object"||Array.isArray(r))&&(Object.keys(this._ldData).forEach(t=>{delete this._ldData[t]}),Object.keys(r).forEach(t=>this._ldData[`!launch_darkly_${t}`]=(r[t]??0)+1),!0)}catch(t){return t instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",t),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(Le);const te=new class{constructor(){q(this,"_optimizelyData",{})}setOptimizelyExperiment(r,t=!0){if(!r||typeof r!="object")return!1;const{experiments:o}=r;try{return t&&Object.keys(this._optimizelyData).map(d=>{delete this._optimizelyData[d]}),o&&o.map(d=>{const{id:e,variation:n}=d,a=this.transformExperimentId(e);n&&typeof n=="string"&&(this._optimizelyData[a]=n)}),!0}catch(d){return d instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",d),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(r){return this._optimizelyData[this.transformExperimentId(r)]}transformExperimentId(r){return"!optimizely_experiments_"+r}getAndSetWebOptimizelyExperiments(){var r;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const t=(r=window.optimizely.get("state"))==null?void 0:r.getExperimentStates({isActive:!0});if(t){const o=Object.keys(t).map(d=>{var e,n;return(e=t[d].variation)!=null&&e.name?{id:d,variation:(n=t[d].variation)==null?void 0:n.name}:{id:d,variation:"Original"}});return this.setOptimizelyExperiment({experiments:o},!1),!0}return!1}return!1}catch(t){return t instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",t),!1}}};Object.freeze(te);class Rt{constructor(t,o){q(this,"paused");q(this,"queue");q(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(o)}flush(t){const o=t.length;if(o)for(let d=0;d<o;d++)this.push(t[d])}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 o=Array.prototype.slice.call(t,1),d=t[0],e=this.ul[d];e instanceof Function?e.apply(this.ul,o):d&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",d)}}perform(t){if(this.paused){let o=()=>{};const d=new Promise(function(e){o=function(){e(t())}});return this.queue.push(o),d}return t()}empty(){this.queue.length=0}}let at,dt;const Ue=r=>{let t=0,o=r.firstElementChild;for(;o;)t+=Ue(o),o.shadowRoot&&(t+=Ue(o.shadowRoot)),o=o.nextElementSibling,t++;return t},Ge=()=>{at.report(Ue(document.body)),dt.report(document.documentElement.innerHTML.toString().length)},Ee=(r,t)=>{const o=performance.now();document.hidden?setTimeout(()=>Ee(r,t),r):setTimeout(()=>{const d=performance.now()-o;t.report(d/1e3),setTimeout(()=>Ee(r,t),r)},0)};let ne,oe,se,ae,Ke,V={};const ee=(r,t=1)=>{const{name:o}=r;V[o]=(V[o]||0)+t},lt=r=>{let t=1;return r.childNodes.forEach(o=>{t+=lt(o)}),t},Je=r=>{let t=0;return r.forEach(o=>{t+=lt(o)}),t},_t=r=>{switch(r.type){case"childList":return ee(ne,Je(r.addedNodes)),void ee(oe,Je(r.removedNodes));case"attributes":return void ee(se);case"characterData":return void ee(ae)}},Dt=r=>r.forEach(_t),xt=()=>{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={}},At=(r=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(Dt),Ke.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(xt,r)},Ot=({isWeb:r,reportingIntervalSeconds:t,thresholds:o,postMetrics:d})=>{i.registerThresholds(o,(e,n)=>{var a,s;if((a=i.modules.replay)!=null&&a.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:t,postMetrics:d}),r&&(((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)})(),At())},Tt="test",Ct=["popState","pushState","replaceState"];let De,K;const de={},z="!email",pt="pageUrl";let fe=window.location.href;function J(r){var s,l;const{pageUrlEvents:t,interactiveEvents:o,dismissOnPageChange:d,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,a=n?String(n):null;t&&mt(window.location.href),o&&(ut(),Pt()),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()&&d&&a&&a!==window.location.href&&r&&Ct.includes(r.type)&&window.UserLeap("dismissActiveSurvey",i.DismissReason.PageChange)}const ct={capture:!0},Pt=()=>{const r=window.UserLeap._config.interactiveEvents.filter(o=>i.checkUrlMatch(o,window.location.href)).map(o=>{const{name:d,properties:e}=o,{selector:n,innerText:a}=e;return n?s=>{if(Be(s.target))try{s.target.closest(n)&&window.UserLeap("track",d)}catch{}return!1}:s=>(Be(s.target)&&s.target.innerText===a&&window.UserLeap("track",d),!1)}),t=o=>r.forEach(d=>d(o));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,ct)},ut=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,ct),delete window.UserLeap._config.interactiveEventsHandler};function wt(){const r=i.localStorageHelper.getItemObject("userleap.ids");return r&&r[window.UserLeap.envId]||{}}function gt(){if(window.previewMode)return;const r=i.localStorageHelper.getItemObject("sprig.anon.env.vid.map")||{},t=r[window.UserLeap.envId];window.UserLeap.visitorId=t||i.v4(),i.breadcrumbsLogger.info("NewVid",{vid:window.UserLeap.visitorId}),I("vid",window.UserLeap.visitorId),t||(r[window.UserLeap.envId]=window.UserLeap.visitorId,i.localStorageHelper.setItemObject("sprig.anon.env.vid.map",r)),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}function mt(r,t,o,d){var e,n;try{if(r.endsWith("mock_snippet.html"))return;i.breadcrumbsLogger.info("PageView",{url:r});const a=(e=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:e.getAttribute("content");(n=i.modules.replay)==null||n.RecordPageView({...a&&{description:a},url:r,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],r),!l);p++);if(!l)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",r);const c={url:r};d&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",pt,t,c,o])}catch(a){a instanceof Error&&(a.stack=r,window.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function Ht(){const r="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in r&&(r.pushState=(t=>function(...o){const d=t.apply(this,o),e=new Event("pushState");return window.dispatchEvent(e),J(e),d})(r.pushState)),"replaceState"in r&&(r.replaceState=(t=>function(...o){const d=t.apply(this,o),e=new Event("replaceState");return window.dispatchEvent(e),J(e),d})(r.replaceState)),["hashchange","popstate"].forEach(t=>window.addEventListener(t,J,!0))}async function he(r,t){const o=ke();r&&!t&&(window.UserLeap._config.mode=Tt);const d=pe(i.getHttpHeaders(window.UserLeap)),e=await D(function(n){const a=new URL(R("1",[C],"questions"));return Object.entries(n||{}).forEach(([s,l])=>{l&&a.searchParams.append(s,String(l))}),a.toString()}({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:d,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:r==null?void 0:r.surveyId,surveytemplateid:r==null?void 0:r.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:a,surveyUuid:s,feedbackCustomStyles:l}=e.json,{buttonTheme:c,placement:p,desktopDisplay:u}=a;st({customStyles:l,buttonTheme:c,desktopDisplay:u,eventId:0,feedbackLabel:n,placement:p,surveyUuid:s,surveyId:r==null?void 0:r.surveyId},e.json)}}function Mt(r){if(!r)return;window.UserLeap._config=r,r.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:o,dismissOnPageChange:d}=r;t&&function(e){let n=e.length;for(;n;){const a=Math.floor(Math.random()*n);n-=1;const s=e[n];e[n]=e[a],e[a]=s}}(t),(t||o||d)&&(Ht(),J())}const jt=function(r){if(!window.UserLeap)return;const t=async(e={})=>{var f,U,b,E,P;const{userId:n,anonymousId:a,metadata:s={},properties:l,showSurveyCallback:c}=e;let{eventName:p}=e;if(window.UserLeap.debugMode&&p!==pt&&console.info("[DEBUG] Sprig track",e),r.mode==="test")return;const u=i.localStorageHelper.getItem("sprig.previewKey")??void 0;if(r.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),(U=(f=window.UserLeap)==null?void 0:f._config)!=null&&U.optimizelyEnabled&&(Q(i.getHttpHeaders(window.UserLeap))||te.getAndSetWebOptimizelyExperiments(),s.optimizelyExperiments=Object.assign({},te.getAllOptimizelyExperiments())),(E=(b=window.UserLeap)==null?void 0:b._config)!=null&&E.launchDarklyEnabled&&(s.launchDarklyFlags=Le.getAllLaunchDarklyVariations()),n&&(window.UserLeap.userId=n),a&&(window.UserLeap.partnerAnonymousId=a),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 D(R("1",[T],"events/batch"),{body:JSON.stringify({events:[{event:p,metadata:s}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await D(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),a&&I("aid",a);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 a=(s=e==null?void 0:e.querySelector(`[id="${Re}"]`))==null?void 0:s.contentDocument;a&&Y({document:a,elementId:"ul-custom-style",styleString:n})},d={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){d._previewSurvey(e)},reviewSurvey(e){d._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 a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}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),r.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:a,attributes:s}=e;if(r.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||a&&window.UserLeap.partnerAnonymousId!==a))return{success:!0};const l={};let c;return n&&(l.userId=window.UserLeap.userId=n),a&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=a),s&&Object.keys(s).length>0?(c=await D(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 D(R("1",[C,T]),{body:JSON.stringify(l),method:"PUT"}),s&&s[z]&&(window.UserLeap.email=s[z]),c.ok&&(n&&I("uid",n),a&&I("aid",a)),{success:!!c.ok}},async removeAttributes(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",e),r.mode==="test")return;if(e==null||e.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(r.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const n=await D(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(r.mode==="test"||e===window.UserLeap.userId)return;window.UserLeap.userId=e;const n=window.UserLeap.visitorId,a=await D(R("1",[C,T]),{body:JSON.stringify({userId:e}),method:"PUT"});a.ok?(n!==window.UserLeap.visitorId&&((s=i.modules.replay)==null||s.clearUserReplayData()),I("uid",e)):a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.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,a={},s=void 0)=>t({eventName:e,properties:n,metadata:a,showSurveyCallback:s}),identifyAndTrack:async e=>await t(e),trackPageView(e,n=void 0,a=void 0,s=!0){K=e,mt(e,n,a,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 a=typeof e=="string"?parseInt(e,10):e,s=typeof n=="string"?parseInt(n,10):n;isNaN(a)||isNaN(s)||(window.UserLeap.windowDimensions={width:a,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 a,s;if((s=(a=window.UserLeap)==null?void 0:a._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,a;if(!((a=(n=window.UserLeap)==null?void 0:n._config)!=null&&a.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,a;(a=(n=window.UserLeap)==null?void 0:n._config)!=null&&a.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"),d.setAttribute(e,n)),setEmail:async e=>d.setAttribute(z,e),setVisitorEmail:async e=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),d.setEmail(e)),_generateVideoUploadUrl:async e=>async function(n){var s;if(!n)return;const a=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const l=await fetch(a,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(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:a})=>{var s;return i.modules.replay?(s=i.modules.replay)==null?void 0:s._completeSessionReplay({surveyId:e,responseGroupUuid:n,eventDigest:a,headers:i.getHttpHeaders(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)},pauseReplayRecording(){var e,n,a,s;(n=(e=i.modules.replay)==null?void 0:e.isReplayPaused)!=null&&n.call(e)||((s=(a=i.modules.replay)==null?void 0:a.recordReplayPaused)==null||s.call(a))},resumeReplayRecording(){var e,n,a,s,l,c;(n=(e=i.modules.replay)==null?void 0:e.isReplayPaused)!=null&&n.call(e)&&((s=(a=i.modules.replay)==null?void 0:a.recordReplayResumed)==null||s.call(a),(c=(l=i.modules.replay)==null?void 0:l.recordFullSnapshot)==null||c.call(l))}};Object.assign(window.UserLeap,d)};async function qt(r,t,o={},d={}){const e=window.__cfg&&window.__cfg.mode,n=ke(),a=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:r,breadcrumbs:i.breadcrumbsLogger.breadcrumbs,err:{message:`${t==null?void 0:t.name} - ${t==null?void 0:t.message}`,stack:t==null?void 0:t.stack},meta:l,vid:n,envId:a,...d};(await D(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",t)}function Ft(r={}){var d;(d=window.SprigLoggerCallback)==null||d.call(window,"Initializing Sprig");const t=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=qt,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},r,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&&(r.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 a=e.sampled;if(n){if(a===null&&(a=Math.random()<n,I("sampled",a)),!a)return}else a!==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 Rt(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 f=i.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",i.cspViolationHandler);const U=await i.sprigFetch(R("1",[C],"config"),{headers:f});if(document.removeEventListener("securitypolicyviolation",i.cspViolationHandler),!U.ok)return(E=window.SprigLoggerCallback)==null||E.call(window,"Sprig config fetch failed"),U.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",U.error),U.error&&window.UserLeap.reportError("applyRemoteConfig",U.error)),i.killNetworkRequests("Disabled: failed to fetch configuration"),m;const b=U.json;return b!=null&&b.disabled?((P=window.SprigLoggerCallback)==null||P.call(window,"Sprig config fetch disabled"),i.killNetworkRequests(`Disabled: ${b.disabled}`),{disabled:b.disabled}):Object.assign({},b,m)}(r);if((w=window.SprigLoggerCallback)==null||w.call(window,"Sprig fetched config"),Ot({isWeb:!c,reportingIntervalSeconds:p.metricsReportingEnabled||p.mobileMetricsReportingEnabled?p.metricsReportingIntervalSeconds:0,thresholds:p.metricThresholds,postMetrics:async m=>{var f;await D(R("1",[C],"metrics"),{body:m,method:"POST",headers:{"x-ul-replay-enabled":`${!!((f=i.modules.replay)!=null&&f.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),!c){const m=p.alwaysOnReplay?{userAgent:window.navigator.userAgent,surveyId:p.alwaysOnReplay.surveyId,responseGroupUuid:p.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.40.1",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}jt(p),await Mt(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",t),document.readyState==="complete"?o():window.attachEvent?window.attachEvent("onload",o):window.addEventListener("load",()=>{o()},!1)}class le{constructor(){q(this,"UPDATES",i.EVENTS)}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,o){window.Sprig("setAttribute",t,o)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,o){window.Sprig("addListener",t,o)}removeListener(t,o){window.Sprig("removeListener",t,o)}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,o={},d={}){window.Sprig("track",t,o,d)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,o,d){window.Sprig("trackPageView",t,o,d)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,o){window.Sprig("setWindowDimensions",t,o)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}pauseReplayRecording(){window.Sprig("pauseReplayRecording")}resumeReplayRecording(){window.Sprig("resumeReplayRecording")}}const Ie={configure:r=>{if(!r.envId&&!r.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(r.envId||(r.envId=r.environmentId??""),r.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 t=window.Sprig;return t.appId=r.envId,t._queue=[],window.UserLeap=t,Ft(r),window.Sprig}},Vt={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=Vt,exports.getHtml=ce,exports.isHTMLElement=A,exports.resetScrollPosition=r=>{const t=r.querySelector(".ul-card__container");t&&(t.scrollTop=0)},exports.setSurveyStyles=Y,exports.sprig=Ie;
12
+ </svg>`,(o=window.UserLeap._config)==null?void 0:o.enableCspTrustedTypes);const t=document.createElement("h3");return t.className="sprig-feedback-error-text",t.innerText="There was an error while loading the survey",r.appendChild(t),r},Le=new class{constructor(){q(this,"_ldData",{})}getAllLaunchDarklyVariations(){return this._ldData}setLDFlagsVariations(r){try{return!(!r||typeof r!="object"||Array.isArray(r))&&(Object.keys(this._ldData).forEach(t=>{delete this._ldData[t]}),Object.keys(r).forEach(t=>this._ldData[`!launch_darkly_${t}`]=(r[t]??0)+1),!0)}catch(t){return t instanceof Error&&window.UserLeap.reportError("setAllLDFlagsVariations",t),console.warn("[Sprig] An issue had occured when setting LaunchDarkly flags and variations."),!1}}};Object.freeze(Le);const te=new class{constructor(){q(this,"_optimizelyData",{})}setOptimizelyExperiment(r,t=!0){if(!r||typeof r!="object")return!1;const{experiments:o}=r;try{return t&&Object.keys(this._optimizelyData).map(d=>{delete this._optimizelyData[d]}),o&&o.map(d=>{const{id:e,variation:n}=d,a=this.transformExperimentId(e);n&&typeof n=="string"&&(this._optimizelyData[a]=n)}),!0}catch(d){return d instanceof Error&&window.UserLeap.reportError("setOptimizelyExperiment",d),!1}}getAllOptimizelyExperiments(){return this._optimizelyData}getOptimizelyVariationName(r){return this._optimizelyData[this.transformExperimentId(r)]}transformExperimentId(r){return"!optimizely_experiments_"+r}getAndSetWebOptimizelyExperiments(){var r;try{if(window&&window.optimizely&&typeof window.optimizely.get=="function"){const t=(r=window.optimizely.get("state"))==null?void 0:r.getExperimentStates({isActive:!0});if(t){const o=Object.keys(t).map(d=>{var e,n;return(e=t[d].variation)!=null&&e.name?{id:d,variation:(n=t[d].variation)==null?void 0:n.name}:{id:d,variation:"Original"}});return this.setOptimizelyExperiment({experiments:o},!1),!0}return!1}return!1}catch(t){return t instanceof Error&&window.UserLeap.reportError("getAndSetWebOptimizely",t),!1}}};Object.freeze(te);class Rt{constructor(t,o){q(this,"paused");q(this,"queue");q(this,"ul");this.ul=t,this.paused=!1,this.queue=[],this.flush(o)}flush(t){const o=t.length;if(o)for(let d=0;d<o;d++)this.push(t[d])}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 o=Array.prototype.slice.call(t,1),d=t[0],e=this.ul[d];e instanceof Function?e.apply(this.ul,o):d&&console.warn("[Sprig] (ERR-100) No valid UserLeap action called",d)}}perform(t){if(this.paused){let o=()=>{};const d=new Promise(function(e){o=function(){e(t())}});return this.queue.push(o),d}return t()}empty(){this.queue.length=0}}let at,dt;const Ue=r=>{let t=0,o=r.firstElementChild;for(;o;)t+=Ue(o),o.shadowRoot&&(t+=Ue(o.shadowRoot)),o=o.nextElementSibling,t++;return t},Ge=()=>{at.report(Ue(document.body)),dt.report(document.documentElement.innerHTML.toString().length)},Ee=(r,t)=>{const o=performance.now();document.hidden?setTimeout(()=>Ee(r,t),r):setTimeout(()=>{const d=performance.now()-o;t.report(d/1e3),setTimeout(()=>Ee(r,t),r)},0)};let ne,oe,se,ae,Ke,V={};const ee=(r,t=1)=>{const{name:o}=r;V[o]=(V[o]||0)+t},lt=r=>{let t=1;return r.childNodes.forEach(o=>{t+=lt(o)}),t},Je=r=>{let t=0;return r.forEach(o=>{t+=lt(o)}),t},_t=r=>{switch(r.type){case"childList":return ee(ne,Je(r.addedNodes)),void ee(oe,Je(r.removedNodes));case"attributes":return void ee(se);case"characterData":return void ee(ae)}},Dt=r=>r.forEach(_t),xt=()=>{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={}},At=(r=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(Dt),Ke.observe(document,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),setInterval(xt,r)},Ot=({isWeb:r,reportingIntervalSeconds:t,thresholds:o,postMetrics:d})=>{i.registerThresholds(o,(e,n)=>{var a,s;if((a=i.modules.replay)!=null&&a.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:t,postMetrics:d}),r&&(((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)})(),At())},Tt="test",Ct=["popState","pushState","replaceState"];let De,K;const de={},z="!email",pt="pageUrl";let fe=window.location.href;function J(r){var s,l;const{pageUrlEvents:t,interactiveEvents:o,dismissOnPageChange:d,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,a=n?String(n):null;t&&mt(window.location.href),o&&(ut(),Pt()),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()&&d&&a&&a!==window.location.href&&r&&Ct.includes(r.type)&&window.UserLeap("dismissActiveSurvey",i.DismissReason.PageChange)}const ct={capture:!0},Pt=()=>{const r=window.UserLeap._config.interactiveEvents.filter(o=>i.checkUrlMatch(o,window.location.href)).map(o=>{const{name:d,properties:e}=o,{selector:n,innerText:a}=e;return n?s=>{if(Be(s.target))try{s.target.closest(n)&&window.UserLeap("track",d)}catch{}return!1}:s=>(Be(s.target)&&s.target.innerText===a&&window.UserLeap("track",d),!1)}),t=o=>r.forEach(d=>d(o));window.UserLeap._config.interactiveEventsHandler=t,window.addEventListener("click",t,ct)},ut=()=>{window.UserLeap._config.interactiveEventsHandler&&window.removeEventListener("click",window.UserLeap._config.interactiveEventsHandler,ct),delete window.UserLeap._config.interactiveEventsHandler};function wt(){const r=i.localStorageHelper.getItemObject("userleap.ids");return r&&r[window.UserLeap.envId]||{}}function gt(){if(window.previewMode)return;const r=i.localStorageHelper.getItemObject("sprig.anon.env.vid.map")||{},t=r[window.UserLeap.envId];window.UserLeap.visitorId=t||i.v4(),i.breadcrumbsLogger.info("NewVid",{vid:window.UserLeap.visitorId}),I("vid",window.UserLeap.visitorId),t||(r[window.UserLeap.envId]=window.UserLeap.visitorId,i.localStorageHelper.setItemObject("sprig.anon.env.vid.map",r)),i.eventEmitter.emit(i.SprigEvent.VisitorIDUpdated,{visitorId:window.UserLeap.visitorId})}function mt(r,t,o,d){var e,n;try{if(r.endsWith("mock_snippet.html"))return;i.breadcrumbsLogger.info("PageView",{url:r});const a=(e=document==null?void 0:document.querySelector('meta[name="description"]'))==null?void 0:e.getAttribute("content");(n=i.modules.replay)==null||n.RecordPageView({...a&&{description:a},url:r,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],r),!l);p++);if(!l)return;window.UserLeap.debugMode&&console.info("[DEBUG] Sprig trackPageView",r);const c={url:r};d&&(c.trackPageView=!0),window.UserLeap._queue.push(["track",pt,t,c,o])}catch(a){a instanceof Error&&(a.stack=r,window.UserLeap.reportError("trackPageView",a)),console.warn("[Sprig] (ERR-428) Failed to track page view",a)}}function Ht(){const r="Backbone"in window&&window.Backbone&&window.Backbone.history?window.Backbone.history:window.history;"pushState"in r&&(r.pushState=(t=>function(...o){const d=t.apply(this,o),e=new Event("pushState");return window.dispatchEvent(e),J(e),d})(r.pushState)),"replaceState"in r&&(r.replaceState=(t=>function(...o){const d=t.apply(this,o),e=new Event("replaceState");return window.dispatchEvent(e),J(e),d})(r.replaceState)),["hashchange","popstate"].forEach(t=>window.addEventListener(t,J,!0))}async function he(r,t){const o=ke();r&&!t&&(window.UserLeap._config.mode=Tt);const d=pe(i.getHttpHeaders(window.UserLeap)),e=await D(function(n){const a=new URL(R("1",[C],"questions"));return Object.entries(n||{}).forEach(([s,l])=>{l&&a.searchParams.append(s,String(l))}),a.toString()}({desktopDisplay:window.UserLeap._config.desktopDisplay,isMobile:d,previewLanguage:window.UserLeap._config.previewLanguage,surveyid:r==null?void 0:r.surveyId,surveytemplateid:r==null?void 0:r.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:a,surveyUuid:s,feedbackCustomStyles:l}=e.json,{buttonTheme:c,placement:p,desktopDisplay:u}=a;st({customStyles:l,buttonTheme:c,desktopDisplay:u,eventId:0,feedbackLabel:n,placement:p,surveyUuid:s,surveyId:r==null?void 0:r.surveyId},e.json)}}function Mt(r){if(!r)return;window.UserLeap._config=r,r.mute&&window.UserLeap._queue.pause();const{interactiveEvents:t,pageUrlEvents:o,dismissOnPageChange:d}=r;t&&function(e){let n=e.length;for(;n;){const a=Math.floor(Math.random()*n);n-=1;const s=e[n];e[n]=e[a],e[a]=s}}(t),(t||o||d)&&(Ht(),J())}const jt=function(r){if(!window.UserLeap)return;const t=async(e={})=>{var f,U,b,E,P;const{userId:n,anonymousId:a,metadata:s={},properties:l,showSurveyCallback:c}=e;let{eventName:p}=e;if(window.UserLeap.debugMode&&p!==pt&&console.info("[DEBUG] Sprig track",e),r.mode==="test")return;const u=i.localStorageHelper.getItem("sprig.previewKey")??void 0;if(r.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),(U=(f=window.UserLeap)==null?void 0:f._config)!=null&&U.optimizelyEnabled&&(Q(i.getHttpHeaders(window.UserLeap))||te.getAndSetWebOptimizelyExperiments(),s.optimizelyExperiments=Object.assign({},te.getAllOptimizelyExperiments())),(E=(b=window.UserLeap)==null?void 0:b._config)!=null&&E.launchDarklyEnabled&&(s.launchDarklyFlags=Le.getAllLaunchDarklyVariations()),n&&(window.UserLeap.userId=n),a&&(window.UserLeap.partnerAnonymousId=a),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 D(R("1",[T],"events/batch"),{body:JSON.stringify({events:[{event:p,metadata:s}],previewKey:u}),method:"POST",shouldDropOnRateLimit:!0}):await D(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),a&&I("aid",a);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 a=(s=e==null?void 0:e.querySelector(`[id="${Re}"]`))==null?void 0:s.contentDocument;a&&Y({document:a,elementId:"ul-custom-style",styleString:n})},d={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){d._previewSurvey(e)},reviewSurvey(e){d._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 a="[Sprig] - Disregarding empty attribute / value provided";return console.warn(a),{success:!1,message:a}}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),r.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:a,attributes:s}=e;if(r.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||a&&window.UserLeap.partnerAnonymousId!==a))return{success:!0};const l={};let c;return n&&(l.userId=window.UserLeap.userId=n),a&&(l.partnerAnonymousId=window.UserLeap.partnerAnonymousId=a),s&&Object.keys(s).length>0?(c=await D(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 D(R("1",[C,T]),{body:JSON.stringify(l),method:"PUT"}),s&&s[z]&&(window.UserLeap.email=s[z]),c.ok&&(n&&I("uid",n),a&&I("aid",a)),{success:!!c.ok}},async removeAttributes(e){if(window.UserLeap.debugMode&&console.info("[DEBUG] Sprig removeAttributes",e),r.mode==="test")return;if(e==null||e.length===0){const a="[Sprig] - Disregarding empty attributes provided";return console.warn(a),{success:!1,message:a}}if(r.requireUserIdForTracking&&!window.UserLeap.userId){const a="[Sprig] - Skipping tracking without userId";return console.warn(a),{success:!1,message:a}}const n=await D(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(r.mode==="test"||e===window.UserLeap.userId)return;window.UserLeap.userId=e;const n=window.UserLeap.visitorId,a=await D(R("1",[C,T]),{body:JSON.stringify({userId:e}),method:"PUT"});a.ok?(n!==window.UserLeap.visitorId&&((s=i.modules.replay)==null||s.clearUserReplayData()),I("uid",e)):a.reportError&&(console.warn("[Sprig] (ERR-420) Failed to set user id",a.error),a.error&&window.UserLeap.reportError("setUserId",a.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,a={},s=void 0)=>t({eventName:e,properties:n,metadata:a,showSurveyCallback:s}),identifyAndTrack:async e=>await t(e),trackPageView(e,n=void 0,a=void 0,s=!0){K=e,mt(e,n,a,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 a=typeof e=="string"?parseInt(e,10):e,s=typeof n=="string"?parseInt(n,10):n;isNaN(a)||isNaN(s)||(window.UserLeap.windowDimensions={width:a,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 a,s;if((s=(a=window.UserLeap)==null?void 0:a._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,a;if(!((a=(n=window.UserLeap)==null?void 0:n._config)!=null&&a.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,a;(a=(n=window.UserLeap)==null?void 0:n._config)!=null&&a.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"),d.setAttribute(e,n)),setEmail:async e=>d.setAttribute(z,e),setVisitorEmail:async e=>(console.warn("[Sprig] setVisitorEmail is deprecated. Please use setEmail"),d.setEmail(e)),_generateVideoUploadUrl:async e=>async function(n){var s;if(!n)return;const a=`${window.UserLeap._API_URL}/2/environments/integrations/upload`;try{const l=await fetch(a,{method:"POST",cache:"no-cache",headers:{"Content-Type":"application/json"},body:JSON.stringify(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:a})=>{var s;return i.modules.replay?(s=i.modules.replay)==null?void 0:s._completeSessionReplay({surveyId:e,responseGroupUuid:n,eventDigest:a,headers:i.getHttpHeaders(window.UserLeap)}):(window.UserLeap.reportError("_completeSessionReplay",new Error("Replay module not registered")),!1)},pauseReplayRecording(){var e,n,a,s;(n=(e=i.modules.replay)==null?void 0:e.isReplayPaused)!=null&&n.call(e)||((s=(a=i.modules.replay)==null?void 0:a.recordReplayPaused)==null||s.call(a))},resumeReplayRecording(){var e,n,a,s,l,c;(n=(e=i.modules.replay)==null?void 0:e.isReplayPaused)!=null&&n.call(e)&&((s=(a=i.modules.replay)==null?void 0:a.recordReplayResumed)==null||s.call(a),(c=(l=i.modules.replay)==null?void 0:l.recordFullSnapshot)==null||c.call(l))}};Object.assign(window.UserLeap,d)};async function qt(r,t,o={},d={}){const e=window.__cfg&&window.__cfg.mode,n=ke(),a=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:r,breadcrumbs:i.breadcrumbsLogger.breadcrumbs,err:{message:`${t==null?void 0:t.name} - ${t==null?void 0:t.message}`,stack:t==null?void 0:t.stack},meta:l,vid:n,envId:a,...d};(await D(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",t)}function Ft(r={}){var d;(d=window.SprigLoggerCallback)==null||d.call(window,"Initializing Sprig");const t=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=qt,window.UserLeap.loaded=!0,window.UserLeap._config=Object.assign({},r,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&&(r.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 a=e.sampled;if(n){if(a===null&&(a=Math.random()<n,I("sampled",a)),!a)return}else a!==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 Rt(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 f=i.getHttpHeaders(window.UserLeap);document.addEventListener("securitypolicyviolation",i.cspViolationHandler);const U=await i.sprigFetch(R("1",[C],"config"),{headers:f});if(document.removeEventListener("securitypolicyviolation",i.cspViolationHandler),!U.ok)return(E=window.SprigLoggerCallback)==null||E.call(window,"Sprig config fetch failed"),U.reportError&&(console.warn("[Sprig] (ERR-422) Failed to load configuration",U.error),U.error&&window.UserLeap.reportError("applyRemoteConfig",U.error)),i.killNetworkRequests("Disabled: failed to fetch configuration"),m;const b=U.json;return b!=null&&b.disabled?((P=window.SprigLoggerCallback)==null||P.call(window,"Sprig config fetch disabled"),i.killNetworkRequests(`Disabled: ${b.disabled}`),{disabled:b.disabled}):Object.assign({},b,m)}(r);if((w=window.SprigLoggerCallback)==null||w.call(window,"Sprig fetched config"),Ot({isWeb:!c,reportingIntervalSeconds:p.metricsReportingEnabled||p.mobileMetricsReportingEnabled?p.metricsReportingIntervalSeconds:0,thresholds:p.metricThresholds,postMetrics:async m=>{var f;await D(R("1",[C],"metrics"),{body:m,method:"POST",headers:{"x-ul-replay-enabled":`${!!((f=i.modules.replay)!=null&&f.isReplayRecording())}`},shouldDropOnRateLimit:!0})}}),!c){const m=p.alwaysOnReplay?{userAgent:window.navigator.userAgent,surveyId:p.alwaysOnReplay.surveyId,responseGroupUuid:p.alwaysOnReplay.responseGroupUuid,sdkVersion:"2.40.2",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}jt(p),await Mt(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",t),document.readyState==="complete"?o():window.attachEvent?window.attachEvent("onload",o):window.addEventListener("load",()=>{o()},!1)}class le{constructor(){q(this,"UPDATES",i.EVENTS)}displaySurvey(t){window.Sprig("displaySurvey",t)}mute(){window.Sprig("mute")}unmute(){window.Sprig("unmute")}dismissActiveSurvey(){window.Sprig("dismissActiveSurvey")}setAttribute(t,o){window.Sprig("setAttribute",t,o)}setAttributes(t){window.Sprig("setAttributes",t)}identifyAndSetAttributes(t){window.Sprig("identifyAndSetAttributes",t)}removeAttributes(t){window.Sprig("removeAttributes",t)}addListener(t,o){window.Sprig("addListener",t,o)}removeListener(t,o){window.Sprig("removeListener",t,o)}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,o={},d={}){window.Sprig("track",t,o,d)}identifyAndTrack(t){window.Sprig("identifyAndTrack",t)}trackPageView(t,o,d){window.Sprig("trackPageView",t,o,d)}applyStyles(t){window.Sprig("applyStyles",t)}setWindowDimensions(t,o){window.Sprig("setWindowDimensions",t,o)}logoutUser(){window.Sprig("logoutUser")}teardown(){window.Sprig("teardown")}pauseReplayRecording(){window.Sprig("pauseReplayRecording")}resumeReplayRecording(){window.Sprig("resumeReplayRecording")}}const Ie={configure:r=>{if(!r.envId&&!r.environmentId)throw new Error("Initialization Error: Sprig configure requires an environmentId");if(r.envId||(r.envId=r.environmentId??""),r.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 t=window.Sprig;return t.appId=r.envId,t._queue=[],window.UserLeap=t,Ft(r),window.Sprig}},Vt={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=Vt,exports.getHtml=ce,exports.isHTMLElement=A,exports.resetScrollPosition=r=>{const t=r.querySelector(".ul-card__container");t&&(t.scrollTop=0)},exports.setSurveyStyles=Y,exports.sprig=Ie;