UNPKG

@sprig-technologies/sprig-browser

Version:

npm package for the sprig web sdk

1 lines 62 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./view-nTdAfzWs.cjs"),ee=require("./metricsReporter-sMSDDeJU.cjs"),le=require("./core-BwIy2OVb.cjs"),p=require("./videoPlayer-DfF4cwtT.cjs"),Ee=require("./debounce-DsC7462b.cjs"),Fe=({className:n,message:i,next:u,properties:t,questionId:r,type:s})=>{const{useMobileStyling:g,border:v,isLongFormSurvey:d,focusedQuestionId:y,useNewSurveyUI:o}=e.useConfig(x=>{var E;return{useMobileStyling:x.useMobileStyling,border:x.border,isLongFormSurvey:ee.isLongFormSurvey(x.studyType),focusedQuestionId:x.focusedQuestionId,useNewSurveyUI:!!((E=x.experimentFlags)!=null&&E["sdk-new-survey-ui"])}}),[b,m]=e.h(!1),[I,c]=e.h(""),[S,l]=e.h(!1),k=d&&y===r,_=t==null?void 0:t.collectName,R=(t==null?void 0:t.nameLabelText)||"Full Name",M=(t==null?void 0:t.consentText)||"I agree to the stated conditions",L=(t==null?void 0:t.submitButtonText)||"Submit",w=!!I.trim(),P=b&&(!_||w),G=(x,E=!1)=>{x.preventDefault(),x.stopPropagation();let D=null;if(!E){if(!P)return void l(!0);D={submitted:!0},_&&(D.name=I)}u({value:D,questionId:r,type:s},P)};return e.u("div",{className:e.cc(n,d&&!k&&"ul-card--unfocused","ul-card__consent-legal","fade-in-transition"),children:[e.u(p.Header,{isRequired:d&&(t==null?void 0:t.required),message:i,properties:{image:t.image,questionHtml:t.questionHtml,captionHtml:o?t.richTextBody:void 0,captionText:o?t.body:void 0}}),!o&&(t!=null&&t.richTextBody)?e.u(p.QuestionBodyWrapper,{children:e.u(p.Html,{className:"ul-rich-text-body",html:t.richTextBody,id:"ul-card__consent-legal-body-container"})}):null,e.u(p.MobileEmbedView,{embeddedType:"pdf",properties:t,children:e.u(p.QuestionBodyFooterContainer,{children:[e.u("div",{className:"sprig-stretch",children:[e.u(p.Option,{allowTextEntry:!1,border:v,error:S&&!b,id:"consent",isRadio:!1,isSelected:b,label:M,onUserInputChanged:({selected:x})=>{x!==b&&m(!b)},useMobileStyling:g}),_&&e.u("input",{"aria-label":R,"aria-placeholder":R,className:e.cc(e.getClasses("ul-consent-legal__name-input",g)),"data-gramm":"false",maxLength:250,name:"name",onBlur:x=>{x.currentTarget.style.borderColor=S&&!w?le.ERROR_BORDER_COLOR:le.DEFAULT_BORDER_COLOR},onFocus:x=>{x.currentTarget.style.borderColor=S&&!w?le.ERROR_BORDER_COLOR:v},onInput:x=>{x.preventDefault(),x.stopPropagation(),c(x.currentTarget.value)},placeholder:R,style:S&&!w?{borderColor:le.ERROR_BORDER_COLOR}:{},tabIndex:0,value:I})]}),e.u("div",{className:"ul-card__button-wrapper ul-card-vertical__button-wrapper",children:[e.u(p.Button,{className:P?"":"sprig-button-disabled",onClick:G,children:L}),t.required===!1&&!d&&e.u("button",{className:"ul-card-skip__button",onClick:x=>G(x,!0),children:e.getSkipButtonText(t)})]})]})})]},r)},ue=n=>i=>{i.pointerType!=="touch"&&n()},Qe=({activeValue:n,border:i,icon:u,isPressed:t,onSubmit:r,range:s,scaleLabelType:g,selectedValue:v,setSelectedValue:d,setActiveValue:y,setIsPressed:o,useMobileStyling:b,value:m,viewDocument:I})=>{const{isLongFormSurvey:c,enableCspTrustedTypes:S}=e.useConfig(x=>({isLongFormSurvey:ee.isLongFormSurvey(x.studyType),enableCspTrustedTypes:x.enableCspTrustedTypes})),l=`option-${m}`,k=g==="number",_=g==="star",R=g==="smiley",M=k&&m===n||m===v,[L,w]=(()=>{const x=_&&v!==null&&m<=v;return _&&m<=n||R&&m===n||x||m===n||m===v?[i,t||x||m===v?1:.3]:["",1]})(),P=e.F(()=>{const x=v===m,E={borderColor:M&&!b||x?L:"",fillOpacity:M?"":w,zIndex:M?3:"auto",color:x?"#fff":""};return k?{...E,backgroundColor:x?L:""}:{...E,color:_||R||x?L:""}},[M,L,w,v,m,k,_,R,b]),G=e.F(()=>le.getHtml((({icon:x,scaleLabelType:E,value:D,selectedValue:U})=>{if(E==="smiley"&&D===U){let T=0;return x.replace(/black/g,()=>++T==1?"black":"white")}return x})({icon:u,scaleLabelType:g,value:m,selectedValue:v}),S),[S,u,g,v,m]);return e.u("button",{"aria-label":k?void 0:String(m),className:(()=>{switch(g){case"star":return e.cc(e.getClasses("likert-star",b),e.getClasses(`likert-star-${m}`,b));case"smiley":return e.cc(e.getClasses("likert-smiley",b),e.getClasses(`likert-smiley-${m}`,b));default:return m===s?e.cc(e.getClasses("likert-number",b),e.getClasses(`likert-number-${m}`,b),e.getClasses("likert-last-option",b)):e.cc(e.getClasses("likert-number",b),e.getClasses(`likert-number-${m}`,b))}})(),dangerouslySetInnerHTML:{__html:G},id:l,onClick:x=>{c&&(x.preventDefault(),x.stopPropagation(),d(m)),r()},onKeyDown:x=>{var U,T;const E=I.querySelectorAll(`.likert-${g??"number"}`),D=m-1;x.key==="ArrowRight"?(U=E[D+1])==null||U.focus():x.key==="ArrowLeft"?(T=E[D-1])==null||T.focus():x.key!=="Enter"&&x.key!==" "||(c&&(x.preventDefault(),x.stopPropagation(),d(m)),r())},onPointerCancel:ue(()=>o(!1)),onPointerDown:ue(()=>{o(!0),y(m)}),onPointerEnter:ue(()=>y(m)),onPointerLeave:ue(()=>{y(-1),o(!1)}),onPointerUp:ue(()=>o(!1)),style:P,tabIndex:0})},Oe=({className:n,labels:i,message:u,next:t,properties:r,questionId:s,type:g})=>{const{border:v,useMobileStyling:d,viewDocument:y,isLongFormSurvey:o,focusedQuestionId:b,useNewSurveyUI:m}=e.useConfig(T=>{var B;return{border:T.border,useMobileStyling:T.useMobileStyling,viewDocument:T.viewDocument,isLongFormSurvey:ee.isLongFormSurvey(T.studyType),focusedQuestionId:T.focusedQuestionId,useNewSurveyUI:!!((B=T.experimentFlags)!=null&&B["sdk-new-survey-ui"])}}),[I,c]=e.h(-1),[S,l]=e.h(!1),[k,_]=e.h(null);e.p(()=>{c(-1),l(!1),_(null)},[s]);const R=o&&b===s,M=i&&i.left,L=i&&i.right;let w;const{range:P,scaleLabelType:G,ratingIcons:x}=r;P&&(w=Number(P));const E=w||5,D=T=>{var B,h;switch(G){case"star":return(B=x[0])==null?void 0:B.svg;case"smiley":return(h=x[T])==null?void 0:h.svg;default:return String(T+1)}},U=e.u(e.g,{children:[e.u("div",{"aria-label":`Rating (1 - ${E})`,className:"ul-card--likert__numbers",role:"radiogroup",children:[...Array(E)].map((T,B)=>{const h=B+1;return e.u(Qe,{activeValue:I,border:v,icon:D(B),isPressed:S,onSubmit:()=>t({value:h,questionId:s,type:g},!0),range:E,scaleLabelType:G,selectedValue:k,setActiveValue:c,setIsPressed:l,setSelectedValue:_,useMobileStyling:d,value:h,viewDocument:y},B)})}),e.u("div",{className:"ul-card--likert__labels",children:[e.u("span",{children:M}),e.u("span",{children:L})]})]});return e.u("form",{className:e.cc(n,"ul-card--likert","fade-in-transition",o&&!R&&"ul-card--unfocused"),children:[e.u(p.Header,{isRequired:o&&(r==null?void 0:r.required),message:u,properties:r}),e.u(p.MobileEmbedView,{properties:r,children:e.u(e.g,{children:[e.u(p.QuestionBodyWrapper,{children:m?e.u("div",{className:"ul-card--likert__scale",children:U}):U}),!r.required&&!o&&e.u(p.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-vertical-centered-container",children:e.u(p.Button,{onClick:T=>{T.preventDefault(),T.stopPropagation(),t({value:null,questionId:s,type:g},!0)},children:e.getButtonText(r)})})})]})})]},s)},Ue=({columns:n,onSelect:i,options:u,selectedOptions:t})=>{const r=e._([]),{border:s,useMobileStyling:g,cards:v,index:d}=e.useConfig(c=>({border:c.border,useMobileStyling:c.useMobileStyling,cards:c.cards,index:c.index})),y=u.findIndex(c=>t[c.id]===null),[o,b]=e.h(y),m=e.T((c,S)=>{var _;i(c,S);const l=o+1,k=u[l];if(k&&t[k.id]===null){b(l);const R=v[d];(R==null?void 0:R.groupId)!=null||((_=r.current[l])==null||_.scrollIntoView({block:"nearest",behavior:"smooth"}))}},[i,u,t,o,v,d]),I=e.T((c,S)=>{const l=o===c;return e.u(e.Accordion,{animate:!0,header:S.label,isOpen:l,onClick:()=>{var k;return b(l&&!((k=window.UserLeap)!=null&&k.isMobileSDK)?-1:c)},ref:k=>{k&&(r.current[c]=k)},showHeaderCheck:t[S.id]!==null,children:e.u("div",{style:{paddingTop:"12px"},children:n.map(k=>e.u(p.Option,{allowTextEntry:!1,ariaLabel:`${S.label}-${k.label}`,border:s,error:!1,id:`${S.id}-${k.value}`,isRadio:!0,isSelected:t[S.id]===k.value,label:k.label,onUserInputChanged:()=>m(S.id,k.value),useMobileStyling:g},k.label))})},S.id)},[s,n,o,m,t,g]);return e.u("div",{children:u.map((c,S)=>I(S,c))})},Ae=({columns:n,onSelect:i,options:u,selectedOptions:t})=>{const{border:r,useMobileStyling:s,isLongFormSurvey:g}=e.useConfig(c=>({border:c.border,useMobileStyling:c.useMobileStyling,isLongFormSurvey:ee.isLongFormSurvey(c.studyType)})),v=u.length,d=n.length,y=e._(null),[o,b]=e.h(!1),[m,I]=e.h(!1);return e.p(()=>{if(g)return;const c=y.current,S=new ResizeObserver(l=>{window.requestAnimationFrame(()=>{c&&(b(Math.round(l[0].contentRect.width)<c.scrollWidth),I(Math.round(l[0].contentRect.width)<c.scrollWidth))})});return c&&S.observe(c),()=>{c&&S.unobserve(c)}},[g]),e.u("div",{className:"ul-card--matrix_question_container",children:[e.u("div",{className:e.cc("ul-card--matrix_container",!g&&o&&"ul-matrix-scroll-gradient"),onScroll:g?void 0:()=>{const c=y.current;c&&b(c.clientWidth+Math.abs(c.scrollLeft)<c.scrollWidth)},ref:y,children:e.u("div",{className:e.cc(g&&"ul-card--matrix_grid_longform","ul-card--matrix_grid"),style:`--numColumns: ${d}; --numRows: ${v+1};`,children:[e.u("div",{className:"ul-matrix-header-row",children:[e.u("div",{})," ",n.map(c=>e.u("div",{className:"ul-matrix-column-label",children:c.label},c.label))]}),u.map(c=>e.u("div",{className:"ul-matrix-row",children:[e.u("div",{"aria-label":c.label,className:"ul-matrix-row-label",children:c.label}),e.u("div",{className:"ul-matrix-row-options",role:"radiogroup",children:n.map((S,l)=>{const k=l===d-1;return e.u("div",{className:e.cc("ul-matrix-option-wrapper",k&&"ul-matrix-last-option"),children:e.u(p.Option,{allowTextEntry:!1,ariaLabel:`${c.label}-${S.label}`,border:r,choiceStyle:{background:"transparent",border:"none",marginBottom:"0",padding:"0"},error:!1,id:`${c.id}-${S.value}`,isRadio:!0,isSelected:t[c.id]===S.value,onUserInputChanged:()=>i(c.id,S.value),useMobileStyling:s})},S.value)})})]},c.label))]})}),!g&&(o||m)&&e.u("button",{className:m&&!o?"ul-matrix-scroll-arrow left":"ul-matrix-scroll-arrow",onClick:m&&!o?c=>{c.preventDefault();const S=y.current;if(S){const l=getComputedStyle(S).direction==="rtl";S.scrollTo({left:l?S.scrollWidth-S.clientWidth:0,behavior:"smooth"})}}:c=>{c.preventDefault();const S=y.current;if(S){const l=getComputedStyle(S).direction==="rtl";S.scrollTo({left:l?S.clientWidth-S.scrollWidth:S.scrollWidth,behavior:"smooth"})}},children:m&&!o?e.u(He,{}):e.u($e,{})})]})},He=()=>e.u("svg",{fill:"currentColor",height:"32",transform:"matrix(-1,0,0,1,0,0)",version:"1.1",viewBox:"0 0 256 256",width:"32",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"})}),$e=()=>e.u("svg",{fill:"currentColor",height:"32",viewBox:"0 0 256 256",width:"32",xmlns:"http://www.w3.org/2000/svg",children:e.u("path",{d:"M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z"})}),Ve=({className:n,message:i,next:u,options:t,properties:r,questionId:s,type:g,showIndividualSubmit:v=!1,onSubmitButtonClick:d})=>{const{useMobileStyling:y,isLongFormSurvey:o,focusedQuestionId:b,setFocusedQuestionId:m,update:I}=e.useConfig(h=>({useMobileStyling:h.useMobileStyling,isLongFormSurvey:ee.isLongFormSurvey(h.studyType),focusedQuestionId:h.focusedQuestionId,setFocusedQuestionId:h.setFocusedQuestionId,update:h.update})),c=r.matrixColumn,S=r.required,l=o&&b===s,k=h=>Object.values(h).every(H=>H==null),_=h=>S&&k(h),R=h=>{if(h.preventDefault(),h.stopPropagation(),u({value:L,questionId:s,type:g},!0),d){const H=!k(L);d(H)}},M=t.reduce((h,H)=>(h[H.id]=null,h),{}),[L,w]=e.h(M),[P,G]=e.h(window.innerWidth),x=(h,H)=>{o&&u({value:{...L,[h]:H},questionId:s,type:g},!_({...L,[h]:H})),w(C=>({...C,[h]:H}))},E=r.displayMatrixAsAccordion||y,D=o&&!E&&e.shouldMatrixUseAccordionDueToSize(c.length,P),U=E||D,T=o&&!U,B=T&&e.shouldMatrixUseFillLayout(c.length,P);return e.p(()=>{if(!o)return;const h=Ee.debounce(()=>G(window.innerWidth),100);return window.addEventListener("resize",h),I(),()=>window.removeEventListener("resize",h)},[o,B,D,P,I]),e.u("form",{className:e.cc(n,!o&&"ul-card__matrix",T&&"ul-card--matrix-expandable",B&&"ul-card--matrix-expandable-fill","fade-in-transition",o&&!l&&"ul-card--unfocused"),id:"text-form",onClick:()=>{l&&m(s)},onSubmit:R,children:[e.u(p.Header,{isRequired:o&&(r==null?void 0:r.required),message:i,properties:r}),e.u(p.MobileEmbedView,{properties:r,children:[e.u(p.QuestionBodyWrapper,{children:[U?e.u(Ue,{columns:c,onSelect:x,options:t,selectedOptions:L}):e.u(Ae,{columns:c,onSelect:x,options:t,selectedOptions:L}),v&&e.u(p.LongformSubmitButton,{handleSubmit:R,isSubmitDisabled:_(L)})]}),!o&&e.u(p.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(p.Button,{disabled:_(L),children:e.getButtonText(r)})})})]})]},s)},we=({className:n,message:i,onSubmit:u,options:t=[],properties:r,questionId:s,type:g,showIndividualSubmit:v=!1,onSubmitButtonClick:d})=>{const{border:y,useMobileStyling:o,isLongFormSurvey:b,focusedQuestionId:m,setFocusedQuestionId:I}=e.useConfig(C=>({border:C.border,useMobileStyling:C.useMobileStyling,isLongFormSurvey:ee.isLongFormSurvey(C.studyType),focusedQuestionId:C.focusedQuestionId,setFocusedQuestionId:C.setFocusedQuestionId})),c=b&&m===s,S=t.reduce((C,A)=>(C[A.id]={isSelected:!1},C),{}),[l,k]=e.h(S),_=g==="multiplechoice",R=r.required,M=t.find(C=>{var A;return(A=C.optionProperties)==null?void 0:A.noneOfTheAbove}),L=C=>Object.entries(C).some(([A,F])=>{var ne;const K=t.find(te=>`${te.id}`===A),z=F.userText===void 0||F.userText.trim()==="";return((ne=K==null?void 0:K.optionProperties)==null?void 0:ne.allowsTextEntry)&&z&&F.isSelected}),w=C=>Object.values(C).filter(A=>A.isSelected).length,P=C=>{const{minSelect:A=0,maxSelect:F=1/0,maxSelectMode:K}=r,z=w(C);switch(K){case e.MaxSelectModes.Maximum:return z<=F;case e.MaxSelectModes.Range:return z===0||z>=A;default:return!0}},G=r.minSelect&&r.minSelect>0&&r.maxSelectMode===e.MaxSelectModes.Range&&w(l)<r.minSelect&&(R||w(l)>0),x=C=>L(C)||R&&!w(C)||!P(C),E=C=>P(C)&&!L(C)&&w(C)>0,D=Object.entries(l).some(([C,A])=>{var F,K;return A.isSelected&&((K=(F=t.find(z=>`${z.id}`===C))==null?void 0:F.optionProperties)==null?void 0:K.allowsTextEntry)}),U=v&&(!_||D),T=C=>{H(C.id,C.selected,C.userText,C.noneOfTheAbove),C.selected&&b&&!_&&!c&&I(s)},B=C=>{var A;return(r==null?void 0:r.maxSelectMode)!==e.MaxSelectModes.Unlimited&&w(l)===(r==null?void 0:r.maxSelect)&&!((A=l[C])!=null&&A.isSelected)},h=C=>{if(C.preventDefault(),C.stopPropagation(),u(l,!0),d){const A=E(l);d(A)}},H=(C,A,F,K)=>{const z=Object.assign({},l);if((_||K)&&A)for(const J of Object.values(z))J.isSelected=!1,delete J.userText;else M&&!K&&l[M.id].isSelected&&(z[M.id].isSelected=!1);z[C]={isSelected:A,userText:F};const ne=_&&Object.entries(z).some(([J,ie])=>{var oe,a;return ie.isSelected&&((a=(oe=t.find(N=>`${N.id}`===J))==null?void 0:oe.optionProperties)==null?void 0:a.allowsTextEntry)}),te=!x(z);if(b&&(u(z,te),_&&!ne&&te&&d)){const J=E(z);d(J)}k(z)};return e.u("form",{className:e.cc(n,"ul-card--multiple","fade-in-transition",b&&!c&&"ul-card--unfocused"),id:"text-form",onClick:g==="multipleselect"?()=>{b&&m!==s&&g==="multipleselect"&&I(s)}:void 0,onSubmit:h,children:[e.u(p.Header,{isRequired:b&&(r==null?void 0:r.required),message:i,properties:r}),e.u(p.MobileEmbedView,{properties:r,children:e.u(e.g,{children:[e.u(p.QuestionBodyWrapper,{children:[r.isDropdown?e.u(p.Select,{disabledOptions:t.filter(C=>B(C.id)),dropdownFooter:G?e.u("div",{className:"ul-card__min-select-counter",style:{marginLeft:"16px"},children:[w(l),"/",r.minSelect]}):void 0,isMultiSelect:!_,multiselectText:r.dropdownMultiselectedText??"choices selected",onChange:C=>{const A={...l};for(const F of t)C.includes(F)?A[F.id].isSelected=!0:A[F.id].isSelected=!1;b&&u(A,!x(A)),k(A)},options:t,placeholderText:r.dropdownPlaceholderText??(_?"Select choice":"Select choice(s)"),value:t.filter(C=>l[C.id].isSelected)}):e.u("div",{className:e.cc(e.getClasses("ul-card__choices",o)),role:_?"radiogroup":"group",children:[t.map(({id:C,label:A,value:F,optionProperties:K})=>{var J,ie;const z=`${C}`,{allowsTextEntry:ne,noneOfTheAbove:te}={allowsTextEntry:!1,noneOfTheAbove:!1,...K};return e.u(p.Option,{allowTextEntry:ne,border:y,disabled:B(z),error:L({[z]:l[z]}),id:z,isRadio:_,isSelected:!!((J=l[z])!=null&&J.isSelected),label:A,noneOfTheAbove:te,onUserInputChanged:T,promptText:(K==null?void 0:K.otherOptionPlaceholder)||"Please specify",text:(ie=l[C])==null?void 0:ie.userText,useMobileStyling:o,value:F},z)}),!!G&&e.u("div",{className:"ul-card__min-select-counter",children:[w(l),"/",r.minSelect]})]}),U&&e.u(p.LongformSubmitButton,{handleSubmit:h,isSubmitDisabled:x(l)})]}),!b&&e.u(p.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(p.Button,{disabled:x(l),onClick:h,children:e.getButtonText(r)})})})]})})]},s)},We=n=>{const{questionId:i,type:u,next:t,options:r}=n,{setFocusedQuestionId:s}=e.useConfig(g=>({setFocusedQuestionId:g.setFocusedQuestionId}));return e.u(we,{...n,onSubmit:(g,v)=>{var I;const d=Object.entries(g).find(([,c])=>c.isSelected)||[void 0,void 0],[y,o]=d,b=r.find(c=>`${c.id}`===y);!((I=b==null?void 0:b.optionProperties)!=null&&I.allowsTextEntry)||o!=null&&o.userText&&o.userText.trim()!==""||s(i);const m=o!=null&&o.userText?{[y]:{userText:o.userText}}:null;t({value:b&&y?{[y]:b.value}:{},secondaryValue:m,questionId:i,type:u},v)}})},Ge=n=>{const{questionId:i,type:u,next:t}=n;return e.u(we,{...n,onSubmit:(r,s)=>{const g=Object.entries(r).reduce((d,[y,o])=>(d[y]=o.isSelected,d),{}),v=Object.entries(r).reduce((d,[y,o])=>{if(!o.userText)return d;const b=d||{};return b[y]={userText:o.userText},b},null);t({value:g,secondaryValue:v,questionId:i,type:u},s)}})},ze=({className:n,labels:i,message:u,properties:t,next:r,questionId:s,type:g})=>{const[v,d]=e.h(null),{border:y,useMobileStyling:o,viewDocument:b,isLongFormSurvey:m,focusedQuestionId:I}=e.useConfig(k=>({border:k.border,useMobileStyling:k.useMobileStyling,viewDocument:k.viewDocument,isLongFormSurvey:ee.isLongFormSurvey(k.studyType),focusedQuestionId:k.focusedQuestionId})),c=m&&I===s,S=i&&i.left,l=i&&i.right;return e.u("form",{className:e.cc(n,"ul-card--nps","fade-in-transition",m&&!c&&"ul-card--unfocused"),children:[e.u(p.Header,{isRequired:m&&(t==null?void 0:t.required),message:u,properties:t}),e.u(p.MobileEmbedView,{properties:t,children:[e.u(p.QuestionBodyWrapper,{children:[e.u("div",{className:"ul-card--nps__numbers",children:[...Array(11)].map((k,_)=>e.u("button",{className:e.cc(e.getClasses("nps-number",o),e.getClasses(`nps-number-${_}`,o)),id:`option-${_}`,onClick:R=>{m&&(R.preventDefault(),R.stopPropagation(),d(_)),r({value:_,questionId:s,type:g},!0)},onKeyDown:R=>{var L,w;const M=b.querySelectorAll("button.nps-number");R.key==="ArrowRight"?(L=M[_+1])==null||L.focus():R.key==="ArrowLeft"?(w=M[_-1])==null||w.focus():R.key!=="Enter"&&R.key!==" "||(m&&(R.preventDefault(),R.stopPropagation(),d(_)),r({value:_,questionId:s,type:g},!0))},onPointerDown:R=>{R.currentTarget.style.zIndex="2",R.currentTarget.style.borderColor=y},onPointerLeave:R=>{R.currentTarget.style.zIndex="auto",R.currentTarget.style.borderColor=""},style:v===_?{backgroundColor:y,color:"#fff"}:void 0,tabIndex:0,children:_},_))}),e.u("div",{className:"ul-card--nps__labels",children:[e.u("span",{children:S}),e.u("span",{children:l})]})]}),!t.required&&!m&&e.u(p.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-vertical-centered-container",children:e.u(p.Button,{onClick:k=>{k.preventDefault(),k.stopPropagation(),r({value:null,questionId:s,type:g},!0)},children:e.getButtonText(t)})})})]})]},s)},je=n=>{const{className:i,message:u,next:t,properties:r,questionId:s,type:g,showIndividualSubmit:v=!1,onSubmitButtonClick:d}=n,y=g==="aidynamicfollowup"||g==="aidynamicstandalone",o=y?n.loading:void 0,{border:b,useMobileStyling:m,update:I,isLongFormSurvey:c,focusedQuestionId:S,setFocusedQuestionId:l,isPreview:k}=e.useConfig(T=>({border:T.border,useMobileStyling:T.useMobileStyling,update:T.update,isLongFormSurvey:ee.isLongFormSurvey(T.studyType),focusedQuestionId:T.focusedQuestionId,setFocusedQuestionId:T.setFocusedQuestionId,isPreview:T.isPreview})),[_,R]=e.h(""),M=e._(null),L=c&&S===s;e.p(()=>{var T,B;c&&!k&&(L?(T=M.current)==null||T.focus():(B=M.current)==null||B.blur())},[c,L,k]);const w=_.trim(),P=r.required===!0&&!w,G=p.useAutoSize(M,()=>I()),x=T=>{T.preventDefault(),T.stopPropagation();const B=w.length>0,h=!r.required||B;t({value:_,questionId:s,type:g},h),d&&d(B)},E=r&&r.openTextPlaceholder?r.openTextPlaceholder:"";if((o===e.DynamicQuestionLoadingStates.failure||o===void 0)&&y)return e.u(e.g,{});const D=o===e.DynamicQuestionLoadingStates.inFlight,U=D?"Preparing your next question":u;return e.u("form",{className:e.cc(i,"ul-card-text","fade-in-transition",c&&!L&&"ul-card--unfocused"),id:"text-form",onClick:()=>{c&&S!==s&&l(s)},children:[e.u(p.Header,{isRequired:c&&(r==null?void 0:r.required),message:U,properties:r}),e.u(p.MobileEmbedView,{properties:r,children:e.u("div",{className:"ul-card-text",children:e.u(p.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":E,className:e.cc(D&&"ul-card-text__input__loading",e.getClasses("ul-card-text__input",m)),"data-gramm":"false",disabled:D,maxLength:5e3,name:"text",onBlur:T=>{T.currentTarget.style.borderColor=le.DEFAULT_BORDER_COLOR},onChange:T=>{const{value:B}=T.currentTarget;if(G(),T.preventDefault(),T.stopPropagation(),R(B),c){const h=B.trim().length>0;t({value:B,questionId:s,type:g},h)}},onFocus:T=>{T.currentTarget.style.borderColor=b,l(s)},placeholder:E,ref:M,role:"textbox",tabIndex:0})}),r.footerHtml&&e.u(p.Html,{className:"footer",html:r.footerHtml}),v&&e.u(p.LongformSubmitButton,{handleSubmit:x,isSubmitDisabled:P}),e.u(p.QuestionBodyFooterContainer,{children:!c&&e.u(p.Button,{disabled:P||D,onClick:x,children:e.getButtonText(r)})})]})})})]},s)},he=1,Ne=2,Re=3,ce=n=>n.type==="av_permission",Se=n=>n.type==="screen_permission",Le=(n,i)=>n===void 0?he:n?((u,t)=>!(ce(t)?t.permissionDescriptors:[]).includes("camera")||u.getVideoTracks().length>0)(n,i)?Re:he:Ne,xe={avStream:null,currentPage:null,mediaRecordingUids:null,nextQuestion:()=>{},passthroughData:void 0,recordingMediaTypes:void 0,screenPermissionRequested:!1,type:void 0},se=e.create(n=>({...xe,reset:()=>{n(xe)},updatePage:i=>{n(i)}}));function be({currentPage:n,pages:i}){const{avStream:u,recordingMediaTypes:t,updatePage:r}=se.getState(),{recorderEventEmitter:s}=e.useConfig.getState();s.emit("av.permission",{"permission.descriptors":n.permissionDescriptors,"stream.ready":(g,v)=>{if(u===g)return;let d=n;if(g&&!n.permissionDescriptors.includes("camera")){const y=i.indexOf(n),o=v!=null&&v.active?y+2:y+1;v!=null&&v.active&&t&&s.emit("begin.recording",{"recording.media.types":t,"start.recording.callback":b=>r({mediaRecordingUids:b})}),d=i[o]}r({currentPage:d,avStream:g})}})}function ve({status:n}){const{nextQuestion:i,passthroughData:u,mediaRecordingUids:t,reset:r}=se.getState(),{recorderEventEmitter:s,handleUploadUpdate:g,index:v}=e.useConfig.getState(),d={value:{taskStatus:n},type:"recordedtask",questionId:(u==null?void 0:u.questionId)||1};u&&s.emit("finish.task",{"begin.callback":y=>{g({mediaRecordingUid:y,isSubmitted:!0,progressPct:0,isComplete:!1})},"progress.callback":(y,o)=>{g({mediaRecordingUid:y,progressPct:o.detail,isSubmitted:!1,isComplete:!1})},"upload.callback":y=>{y&&g({mediaRecordingUid:y,isComplete:!0,isSubmitted:!0,progressPct:100})},"passthrough.data":u,"current.index":v,"task.response":d,"task.complete.callback":y=>{d.value.taskDurationMillisecond=y,t&&(d.value.mediaRecordingUids=t),r(),i(d)}})}function ye({pages:n,setIsRequestingPermission:i}){const{recorderEventEmitter:u,eventEmitFn:t}=e.useConfig.getState(),{updatePage:r,currentPage:s,recordingMediaTypes:g,screenPermissionRequested:v}=se.getState();if(!s)return;const d=n.indexOf(s);switch(s.type){case"av_permission":{const y=v?d+2:d+1;return v&&g&&u.emit("begin.recording",{"recording.media.types":g,"start.recording.callback":o=>{r({mediaRecordingUids:o})}}),void r({currentPage:n[y]})}case"screen_permission":return void u.emit("screen.permission",{"screen.permission.requested":i,"stream.ready.callback":(y,o)=>{const b=o?n[d+1]:s;o&&g&&u.emit("begin.recording",{"recording.media.types":g,"start.recording.callback":m=>{r({captureStream:o,mediaRecordingUids:m})}}),r({currentPage:b,screenPermissionRequested:!0,captureStream:o})}});case"start_task":return t("recorded.task.start"),u.emit("recorded.task.start"),u.emit("start.task"),void r({currentPage:n[d+1],screenPermissionRequested:!0});case"complete_task":return}}const De="ul-permission-graphics-container",qe="ul-permission-body",Me=e.cc(De,"ul_recorded-task-inset-spacing"),pe=e.cc("ul-horizontal-button-container","ul-horizontal-button-container-left"),Pe=({richTextBody:n})=>e.u(p.Html,{className:"ul-rich-text-body",html:n,id:"ul-task-detail-container"}),me=({required:n,skipButtonText:i,bottom:u=!1})=>n?null:e.u(p.Button,{className:e.cc(u&&"ul-skip-button-below","ul-button-inactive"),onClick:ve.bind(null,{status:"abandoned"}),children:i||"Skip"}),fe=n=>{const{avStream:i,captureStream:u,recordingMediaTypes:t,updatePage:r}=se.getState(),s=(t==null?void 0:t.includes("audio"))||(t==null?void 0:t.includes("video"));e.p(()=>{const g=setInterval(()=>{s&&i&&!i.active?r({avStream:null,currentPage:n[0]}):u&&u.active||r({captureStream:void 0,currentPage:n[s?1:0]})},1e3);return()=>clearInterval(g)},[i,u,s,n,t,r])},Ze=({content:n,pages:i,required:u})=>{const{buttonText:t,skipButtonText:r,taskDetail:s}=n;return fe(i),e.u("div",{className:"ul-task-page",children:[s&&e.u(Pe,{richTextBody:s}),e.u("div",{className:pe,children:[e.u(p.Button,{onClick:ye.bind(null,{pages:i}),children:t}),e.u(me,{required:u,skipButtonText:r})]})]},"start-task")},Ye=({content:n,pages:i,properties:u})=>{const{buttonText:t,skipButtonText:r}=n;return fe(i),e.u("div",{className:"ul-task-page",children:[n.taskDetail&&e.u(Pe,{richTextBody:n.taskDetail}),e.u(p.MobileEmbedView,{properties:u,children:e.u("div",{className:pe,children:[e.u(p.Button,{className:"ul-complete-task-button",onClick:ve.bind(null,{status:"completed"}),children:t}),e.u(p.Button,{className:e.cc("ul-button-inactive"),onClick:ve.bind(null,{status:"given.up"}),children:r})]})})]},"complete-task")},Ke=({content:n,pages:i,required:u})=>{const{buttonText:t,skipButtonText:r}=n,[s]=e.useConfig(d=>[d.tabTitle]),[g,v]=e.h(!1);return e.u("div",{children:[e.u("div",{className:Me,children:[e.u("p",{style:{marginTop:"auto"},children:n.selectTabText}),e.u("div",{className:"ul-select-tab-container",children:e.u("p",{className:qe,children:s})})]}),e.u("div",{className:u?"":pe,children:[e.u(p.Button,{disabled:g,onClick:ye.bind(null,{pages:i,setIsRequestingPermission:v}),children:t}),e.u(me,{required:u,skipButtonText:r})]})]})},Xe=({content:n})=>e.u(p.Html,{className:e.cc(De,"ul_permission_svg_container","ul_recorded-task-inset-spacing","ul-center-horizontally"),html:n.svg},"ul-permission-request-graphic"),Je=({content:n,pages:i,required:u})=>{const{permissionDeniedHeadline:t,permissionDeniedBody:r,skipButtonText:s,tryAgainButtonText:g}=n,v=ce(i[0])?i[0]:null;return e.p(()=>{const d=setInterval(()=>{v!==null&&be({currentPage:v,pages:i})},1e3);return()=>clearInterval(d)},[v,i]),v?e.u("div",{children:[e.u("div",{className:Me,children:e.u("p",{className:"ul-av-permission-denied-paragraph",children:[e.u("span",{className:"ul-av-permission-denied-headline",children:t}),e.u("span",{className:qe,children:r})]})}),e.u("div",{className:pe,children:[e.u(p.Button,{onClick:be.bind(null,{currentPage:v,pages:i}),children:g}),e.u(me,{required:u,skipButtonText:s})]})]}):null},et=({stream:n})=>e.u("video",{autoPlay:!0,className:e.cc("ul_recorded-task-inset-spacing"),id:"ul-record-task-video-preview",muted:!0,ref:i=>{i&&(i.srcObject=n||null)}}),tt=({content:n,pages:i,required:u})=>{const{skipButtonText:t}=n,{avStream:r}=se.getState();return fe(i),e.u("div",{children:[e.u(et,{stream:r}),e.u("div",{className:"ul-vertical-button-container-center",children:[e.u(p.Button,{onClick:ye.bind(null,{pages:i}),children:n.buttonText}),e.u(me,{bottom:!0,required:u,skipButtonText:t})]})]})},rt=({properties:n})=>{const{pages:i,required:u}=n,{avStream:t,currentPage:r}=se.getState();if(r===void 0)return null;switch(r==null?void 0:r.type){case"av_permission":{const s=Le(t,r);return s===he?e.u(Xe,{content:r}):s===Ne?e.u(Je,{content:r,pages:i,required:u}):e.u(tt,{content:r,pages:i,required:u})}case"screen_permission":return e.u(Ke,{content:r,pages:i,required:u});case"start_task":return e.u(Ze,{content:r,pages:i,required:u});case"complete_task":return e.u(Ye,{content:r,pages:i,properties:n});default:return null}},nt=({className:n,properties:i,next:u,questionId:t})=>{const r=e.useConfig(),{surveyId:s,responseGroupUid:g,userId:v,update:d}=r,y=se(),{screenPermissionRequested:o}=y,b=se(l=>l.avStream);let m=se(l=>l.currentPage);m||(m=function({pages:l,userId:k,responseGroupUid:_,surveyId:R,questionId:M,next:L}){const{updatePage:w}=se.getState(),{eventEmitFn:P,recorderEventEmitter:G}=e.useConfig.getState(),x={questionId:M,surveyId:R,visitorId:k,responseGroupUid:_};let E=0;G.emit("recorded.task.permission.screen"),P("recorded.task.permission.screen"),G.emit("permission.status",{"permission.status.callback":(U,T,B,h)=>{const H=l[E],{type:C}=H,A=["screen"];if(ce(H)){const{permissionDescriptors:F}=H,K=F==null?void 0:F.includes("microphone"),z=F==null?void 0:F.includes("camera");K&&A.push("audio"),z&&A.push("video"),(U!=null&&U.active&&!z||U!=null&&U.active&&T)&&E++}Se(l[E])&&B&&(E++,G.emit("begin.recording",{"recording.media.types":A,"start.recording.callback":F=>w({mediaRecordingUids:F})})),w({currentPage:l[E],avStream:U,screenPermissionRequested:B,nextQuestion:L,type:C,passthroughData:x,recordingMediaTypes:A,captureStream:h})}});const D=l[E];return D.type==="av_permission"&&be({currentPage:D,pages:l}),D}({questionId:t,surveyId:s,next:l=>{u(l,!0)},pages:i.pages,responseGroupUid:g,userId:v}));let I=m.headline,c=m.captionText;const S=Le(b,m);return Se(m)&&o&&(I=m.permissionDeniedHeadline,c=m.permissionDeniedCaptionText),ce(m)&&S===Re&&(I=m.permissionGrantedHeadline,c=m.permissionGrantedCaptionText),e.p(()=>{d()},[d]),e.u("div",{className:e.cc(n,"ul-center-horizontally","fade-in-transition"),children:[e.u(p.Header,{isRequired:i==null?void 0:i.required,message:I,properties:{captionText:c}}),e.u(p.QuestionBodyWrapper,{children:e.u(rt,{properties:i})})]})},it=({richTextBody:n,plaintextBody:i})=>n?e.u(p.Html,{className:"ul-rich-text-body",html:n,id:"ul-card__text-url-body-container"}):i?e.u("div",{className:"ul-rich-text-body",id:"ul-card__text-url-body-container",children:(i?i.split(/\n\s*\n/g):[]).map((u,t)=>e.u("p",{children:u},t))}):null,st=({className:n,message:i,next:u,properties:t,questionId:r,type:s})=>{const{visitorAttributes:g,isLongFormSurvey:v,useNewSurveyUI:d}=e.useConfig(m=>{var I;return{visitorAttributes:m.visitorAttributes,isLongFormSurvey:ee.isLongFormSurvey(m.studyType),useNewSurveyUI:!!((I=m.experimentFlags)!=null&&I["sdk-new-survey-ui"])}}),y=(m,I=!1)=>{u({value:I?{skipped:!0}:void 0,questionId:r,type:s},!0)},o=p.getAttributedUrl(t&&t.buttonUrl,g),b=!d&&v&&t.promptActionType===e.PromptActionTypeEnum.NO_BUTTON;return e.u("div",{className:e.cc(n,"ul-card__text-url-prompt","fade-in-transition"),children:[e.u(p.Header,{isRequired:v&&(t==null?void 0:t.required),message:i,properties:{image:t.image,questionHtml:t.questionHtml,captionHtml:d?t.richTextBody:void 0,captionText:d?t.body:void 0}}),!d&&e.u(p.QuestionBodyWrapper,{children:e.u(it,{plaintextBody:t==null?void 0:t.body,richTextBody:t==null?void 0:t.richTextBody})}),e.u(p.MobileEmbedView,{properties:t,children:!b&&e.u(p.QuestionBodyFooterContainer,{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:o,id:"ul-card-text__button",onClick:y,onKeyPress:m=>{m.key!=="Enter"&&m.key!==" "||u({value:void 0,questionId:r,type:s},!0)},rel:"noreferrer",role:o?"link":"button",tabIndex:0,target:"_blank",children:e.getButtonText(t)}),t.required===!1&&e.u("button",{className:"ul-card-skip__button",onClick:m=>y(0,!0),children:e.getSkipButtonText(t)})]})})})]},r)},ot=({className:n,questionId:i})=>{const{border:u,destroy:t,endCard:r,forceBrandedLogo:s,quotaEndcardText:g,update:v}=e.useConfig(b=>({border:b.border,destroy:b.destroy,endCard:b.endCard,forceBrandedLogo:b.forceBrandedLogo,quotaEndcardText:b.quotaEndcardText,update:b.update}));e.p(()=>{setTimeout(()=>{t(le.APP_ID)},s?4e3:2e3)},[t,s]);const d=(g==null?void 0:g.subheader)??(r==null?void 0:r.subheader),y=d?e.u("p",{className:"ul-caption",children:d}):null,o=(g==null?void 0:g.headline)??(r==null?void 0:r.headline)??"";return e.p(()=>{v()},[v]),e.u("div",{className:e.cc(n,"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:u,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:u,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(p.Header,{message:o}),y]})})},i)},ae="ul-card-video__player_recorder",Ce="ul-video-btn",ge=0,Te=1,lt=({className:n,message:i,next:u,properties:t,questionId:r,type:s})=>{const{apiURL:g,envId:v,handleUploadUpdate:d,headers:y,responseGroupUid:o,surveyId:b,update:m,viewDocument:I,visitorId:c}=e.useConfig(h=>({apiURL:h.apiURL,envId:h.envId,handleUploadUpdate:h.handleUploadUpdate,headers:h.headers,responseGroupUid:h.responseGroupUid,surveyId:h.surveyId,update:h.update,viewDocument:h.viewDocument,visitorId:h.userId})),[S,l]=e.h(!1),[k,_]=e.h(null),[R,M]=e.h(null),[L,w]=e.h(ge),[P,G]=e.h(null),[x,E]=e.h(null),D=t&&t.videoUrl,U=e.T(h=>{h&&G(h)},[G]);e.p(()=>{const h=new ResizeObserver(()=>{setTimeout(m,0)});return x&&h.observe(x),P&&h.observe(P),()=>{h.disconnect()}},[m,x,P]);const T=(h,H)=>{h===p.RECORDER.UPLOAD_STARTED?(_(H[p.RECORDER.UPLOAD_ID]),M(H[p.RECORDER.MEDIA_RECORDING_UID]),l(!0)):h===p.RECORDER.DELETE?(_(null),M(null),l(!1)):h===p.RECORDER.UPLOAD_PROGRESS?isNaN(H[p.RECORDER.UPLOAD_PROGRESS_PCT])?d({mediaRecordingUid:H[p.RECORDER.MEDIA_RECORDING_UID],isComplete:!0}):d({mediaRecordingUid:H[p.RECORDER.MEDIA_RECORDING_UID],progressPct:H[p.RECORDER.UPLOAD_PROGRESS_PCT]}):h===p.RECORDER.UPLOAD_FINISHED&&d({mediaRecordingUid:H[p.RECORDER.MEDIA_RECORDING_UID],isComplete:!0})},B=h=>{h.preventDefault(),h.stopPropagation(),document.getElementById(ae)&&p.stopRecording(ae),k&&R?(d({mediaRecordingUid:R,isSubmitted:!0}),u({value:{mediaRecordingUid:R},questionId:r,type:s},!0)):u({value:null,questionId:r,type:s},!0)};return e.u("form",{className:e.cc(n,"ul-card--video","fade-in-transition"),id:"ul-video-interview-form",children:[e.u(p.Header,{isRequired:t==null?void 0:t.required,message:i,properties:t}),e.u(p.QuestionBodyWrapper,{children:[e.u("div",{id:"ul-question-player-container",ref:U,style:{display:L===ge?"":"none"},children:[e.u("div",{id:ae,ref:h=>{if(h&&h.children.length===0&&!t.hideRecordedPrompt){E(h);const H=p.videoPlayer(ae,{src:D,type:"application/x-mpegURL"},void 0,t.mediaType===p.RECORDER.MEDIA_TYPE_AUDIO,g,I);h.appendChild(H)}}}),e.u(p.MobileEmbedView,{properties:t,children:e.u("button",{className:`${Ce} ul-record-response-btn`,onClick:h=>{h.preventDefault(),h.stopPropagation(),document.getElementById(ae)&&p.pauseQuestionPlayer(ae),w(Te)}})})]}),e.u("div",{style:{display:L===Te?"block":"none"},children:[e.u("button",{className:`${Ce} ul-back-question-btn`,onClick:h=>{h.preventDefault(),h.stopPropagation(),w(ge)},style:{display:t.hideRecordedPrompt?"none":"block"}}),e.u("div",{id:"ul-recorder-player-container",ref:h=>{if(h&&h.children.length===0){E(h);const H=p.videoRecorderPlayer(ae,{surveyId:b,responseGroupUid:o,questionId:r,visitorId:c,envId:v},g,T,void 0,{...y,"x-ul-video-recorder-origin":"sdk"},t.mediaType===p.RECORDER.MEDIA_TYPE_AUDIO,I);h.appendChild(H)}}})]})]}),e.u(p.QuestionBodyFooterContainer,{children:[e.u(p.Button,{disabled:!S,onClick:B,children:e.getButtonText(t)}),e.u("button",{className:"ul-card-text__button ul-button-inactive ul-card-skip__button",id:"ul-card-video__skip_button",onClick:B,style:{display:t.required?"none":"block",...S?{display:"none"}:{}},children:e.getSkipButtonText(t)})]})]})},at=({className:n})=>{const{uploadProgress:i}=e.useConfig(s=>({uploadProgress:s.uploadProgress}));let u,t;Object.values(i).filter(s=>s.isSubmitted).length>1?(u="Your responses are processing",t="Please keep this tab open until your responses are fully processed."):(u="Your response is processing",t="Please keep this tab open until your response is fully processed.");const r=Math.round(Math.min(99,...Object.values(i).filter(s=>s.isSubmitted).map(s=>s.progressPct||0)));return e.u("div",{className:e.cc(n,"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(p.Header,{message:`${u} (${r}% complete)`}),e.u("p",{className:"ul-caption",children:t})]})},Be=e.F$1(void 0),ut=({value:n,children:i})=>e.u(Be.Provider,{value:n,children:i}),dt=({isRightLabel:n,isLeftLabel:i})=>n?e.MaxDiffChoice.RIGHT:i?e.MaxDiffChoice.LEFT:null,ct="Best",pt="Worst",mt=({enableCspTrustedTypes:n,ariaPressed:i,className:u,html:t,id:r,onClick:s})=>{const g=e.F(()=>le.getHtml(t,n),[n,t]);return e.u("span",{"aria-pressed":i,className:u,dangerouslySetInnerHTML:{__html:g},id:r,onClick:s,tabIndex:0,type:"button"})},ke=({border:n,choice:i,choiceStyle:u,enableCspTrustedTypes:t,id:r,isSelected:s,label:g,onSelect:v,smileySvg:d,useMobileStyling:y})=>{const o=i===e.MaxDiffChoice.LEFT,b=o?"good":"bad";return e.u("div",{className:"ul-card-maxdiff__option-control "+(d?"smiley":""),children:d?e.u(mt,{ariaPressed:s,className:s?`ul-card-maxdiff__option-btn ul-card-maxdiff__option-selected ${b}`:"ul-card-maxdiff__option-btn",enableCspTrustedTypes:t,html:d,id:`smiley-${b}-${r}`,onClick:v}):e.u(p.Option,{allowTextEntry:!1,ariaLabel:`${o?"best":"worst"}Label-${g}`,border:n,choiceStyle:u,error:!1,id:`${r}`,isRadio:!0,isSelected:s,onUserInputChanged:v,useMobileStyling:y})})},gt=({id:n,label:i,isLeftLabel:u,isRightLabel:t,useNewSurveyUI:r,border:s,choiceStyle:g,enableCspTrustedTypes:v,goodSmileySvg:d,badSmileySvg:y,handleSelect:o,useMobileStyling:b})=>{const m={border:s,choiceStyle:g,enableCspTrustedTypes:v,id:n,label:i,useMobileStyling:b},I=e.u(e.g,{children:[e.u(ke,{...m,choice:e.MaxDiffChoice.LEFT,isSelected:u,onSelect:o(n,e.MaxDiffChoice.LEFT),smileySvg:d}),e.u("div",{className:"ul-card-maxdiff__option-label",children:i}),e.u(ke,{...m,choice:e.MaxDiffChoice.RIGHT,isSelected:t,onSelect:o(n,e.MaxDiffChoice.RIGHT),smileySvg:y})]});return r?e.u("div",{className:"ul-card-maxdiff__option-row",children:I}):I},ht=({className:n,labels:i,message:u,properties:t,options:r,questionId:s,type:g,next:v})=>{var P,G,x,E;const[d,y]=e.h(r.map((D,U)=>({...D,label:D.label===""?`Item ${U+1}`:D.label,isRightLabel:!1,isLeftLabel:!1}))),o=(()=>{const D=e.q(Be);if(D===void 0)throw new Error("usePreviousResponses must be used within a PreviousResponsesProvider");return D})(),[b,m]=e.h(!1);e.p(()=>{const D=d.findIndex(F=>F.isRightLabel),U=d.findIndex(F=>F.isLeftLabel),T=D!==-1&&U!==-1;m(T);const B=!t.required||t.required&&T,h=d.map(F=>({id:F.id,option:F.label,selected:dt(F)})),H=Math.floor(s),C=Object.keys(o).filter(F=>F.startsWith(H.toString())).map(Number).sort((F,K)=>F-K).at(-1),A=[];if(typeof C=="number"){const F=o[C],K=JSON.parse(F);A.push(...K)}A.push(h),setTimeout(()=>{v({value:A,questionId:s,type:g},B,T),m(!1)},T?500:0)},[d]);const{border:I,useMobileStyling:c,enableCspTrustedTypes:S,useNewSurveyUI:l}=e.useConfig(D=>{var U;return{border:D.border,useMobileStyling:D.useMobileStyling,enableCspTrustedTypes:D.enableCspTrustedTypes,useNewSurveyUI:!!((U=D.experimentFlags)!=null&&U["sdk-new-survey-ui"])}}),k=l?{padding:"0",display:"flex",cursor:"pointer",width:"auto"}:{padding:"24px",display:"flex",cursor:"pointer",width:"auto"},_=(P=t.ratingIcons)==null?void 0:P[0].svg,R=(G=t.ratingIcons)==null?void 0:G[1].svg,M=(i==null?void 0:i.left)||((x=t==null?void 0:t.labels)==null?void 0:x.left)||ct,L=(i==null?void 0:i.right)||((E=t==null?void 0:t.labels)==null?void 0:E.right)||pt,w={border:I,choiceStyle:k,enableCspTrustedTypes:S,goodSmileySvg:R,badSmileySvg:_,handleSelect:(D,U)=>()=>{b||y(T=>((B,h,H)=>B.map(C=>C.id===h?{...C,isRightLabel:H===e.MaxDiffChoice.RIGHT,isLeftLabel:H===e.MaxDiffChoice.LEFT}:H===e.MaxDiffChoice.RIGHT&&C.isRightLabel||H===e.MaxDiffChoice.LEFT&&C.isLeftLabel?{...C,isRightLabel:!1,isLeftLabel:!1}:C))(T,D,U))},useMobileStyling:c,useNewSurveyUI:l};return e.u("form",{className:e.cc(n,"ul-card-maxdiff","fade-in-transition"),children:[e.u(p.Header,{isRequired:t==null?void 0:t.required,message:u,properties:t}),e.u(p.QuestionBodyWrapper,{children:e.u("div",{className:"ul-card--maxdiff__question-inner-container",children:[l?e.u("div",{className:"ul-card-maxdiff__labels-row",children:[e.u("div",{className:"ul-card-maxdiff__label",children:M}),e.u("div",{className:"ul-card-maxdiff__label",children:L})]}):e.u(e.g,{children:[e.u("div",{className:"ul-card-maxdiff__label",children:M}),e.u("div",{children:" "}),e.u("div",{className:"ul-card-maxdiff__label",children:L})]}),d.map(({id:D,label:U,isLeftLabel:T,isRightLabel:B})=>e.u(gt,{id:D,isLeftLabel:T,isRightLabel:B,label:U,...w},D))]})})]},s)},bt=({className:n,labels:i,message:u,next:t,properties:r,questionId:s,type:g,onSubmitButtonClick:v,options:d,showIndividualSubmit:y=!1})=>{const o=e._(null),b=e._(0),m=e._(0),I=e._(null),c=e._(!1),S=e._([]),[l,k]=e.h(()=>(r==null?void 0:r.required)===!0),[_,R]=e.h(!1),[M,L]=e.h(()=>d.map(f=>({...f,rank:null}))),w=e.F(()=>Array.from({length:d.length},(f,q)=>q+1),[d.length]),{isLongFormSurvey:P,focusedQuestionId:G,setFocusedQuestionId:x,useMobileStyling:E,isPreview:D,headers:U}=e.useConfig(f=>({useMobileStyling:f.useMobileStyling,isLongFormSurvey:ee.isLongFormSurvey(f.studyType),focusedQuestionId:f.focusedQuestionId,setFocusedQuestionId:f.setFocusedQuestionId,isPreview:f.isPreview,headers:f.headers})),T=(U==null?void 0:U["userleap-platform"])==="android",B=E&&!D&&!T,h=!B&&!T,H=P&&G===s,C=f=>{f.preventDefault(),J(M),v&&v(_)},A=(f,q)=>{L(V=>{const O=parseInt(q),Z=V.map(Y=>({...Y}));Z.some(Y=>Y.rank==null)&&Z.forEach((Y,re)=>Y.rank=re+1);const X=Z.findIndex(Y=>Y.id===f);if(X===-1)return V;const j=Z[X].rank;return O<j?Z.forEach(Y=>{Y.id!==f&&Y.rank>=O&&Y.rank<j&&(Y.rank=Y.rank+1)}):O>j&&Z.forEach(Y=>{Y.id!==f&&Y.rank>j&&Y.rank<=O&&(Y.rank=Y.rank-1)}),Z[X].rank=O,Z.sort((Y,re)=>Y.rank-re.rank),ie(Z),Z})},F=(f,q)=>{for(let V=0;V<S.current.length;V++){const O=S.current[V];if(!O||O===I.current)continue;const Z=O.getBoundingClientRect();if(f>=Z.left&&f<=Z.right&&q>=Z.top&&q<=Z.bottom)return{element:O,index:V}}return null},K=f=>q=>{if(!B)return;q.preventDefault(),q.stopPropagation(),c.current=!0,o.current=f;const V=q.touches[0];b.current=V.clientY,m.current=V.clientY;const O=q.currentTarget.closest(".ul-card-rank__option");O&&(I.current=O,O.classList.add("is-dragging"))},z=f=>{if(!B||!c.current||o.current===null)return;f.preventDefault(),f.stopPropagation();const q=f.touches[0];m.current=q.clientY;const V=m.current-b.current;I.current&&(I.current.style.transform=`translateY(${V}px)`,I.current.style.zIndex="1000"),S.current.forEach(Z=>{Z&&Z!==I.current&&Z.classList.remove("is-drop-target")});const O=F(q.clientX,q.clientY);O&&O.element.classList.add("is-drop-target")},ne=f=>{if(!B||!c.current||o.current===null)return;f.preventDefault(),f.stopPropagation();const q=f.changedTouches[0],V=F(q.clientX,q.clientY);I.current&&(I.current.style.transform="",I.current.style.zIndex="",I.current.classList.remove("is-dragging")),S.current.forEach(O=>{O&&O.classList.remove("is-drop-target")}),V&&V.index!==o.current&&te(o.current,V.index),o.current=null,I.current=null,c.current=!1},te=(f,q)=>{L(V=>{const O=V.map(X=>({...X})),[Z]=O.splice(f,1);return O.splice(q,0,Z),O.forEach((X,j)=>{X.rank=j+1}),ie(O),O})},J=f=>{const q={};f.reduce((V,O)=>(V[O.id]=O.rank,V),q),t({value:q,questionId:s,type:g},!0)},ie=f=>{k(!1),R(!0),P&&J(f)},{left:oe,right:a}=i,N=d.length,Q=f=>{f.preventDefault(),f.currentTarget.classList.add("is-drop-target")},W=f=>{f.currentTarget.classList.remove("is-drop-target")},$=f=>{o.current=null,f.currentTarget.classList.remove("is-dragging")};return e.u("form",{className:e.cc(n,"ul-card-rank","fade-in-transition",P&&!H&&"ul-card--unfocused"),onClick:P&&!H?()=>{x(s)}:void 0,onSubmit:C,children:[e.u(p.Header,{isRequired:r==null?void 0:r.required,message:u,properties:r}),e.u(p.MobileEmbedView,{properties:r,children:T?e.u(e.g,{children:[e.u(p.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 - ",oe]})}),e.u("ol",{className:"ul-card-rank__list",children:M.map(({id:f,label:q,rank:V})=>e.u("li",{className:"ul-card-rank__option",children:[e.u("select",{"aria-label":`Rank for ${q}`,className:e.cc("ul-card-rank__select",V==null&&"ul-card-rank__select--placeholder"),name:`rank[${f}]`,onChange:O=>A(f,O.currentTarget.value),value:V??"",children:[V==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),w.map(O=>e.u("option",{className:"ul-card-rank__select-option",value:O,children:O},`${O}-${s}`))]}),e.u("span",{children:q})]},f))}),e.u("div",{className:"ul-card-rank__labels",children:e.u("span",{children:[N," - ",a]})})]}),y&&e.u(p.LongformSubmitButton,{handleSubmit:C,isSubmitDisabled:l})]}),!P&&e.u(p.QuestionBodyFooterContainer,{children:e.u("div",{className:"ul-card__button-wrapper",children:e.u(p.Button,{disabled:l,children:e.getButtonText(r)})})})]}):e.u(e.g,{children:[e.u(p.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 - ",oe]})}),e.u("ol",{className:"ul-card-rank__list",onDragOver:T?void 0:f=>{f.preventDefault(),f.dataTransfer&&(f.dataTransfer.dropEffect="move")},children:M.map(({id:f,label:q,rank:V},O)=>{return e.u("li",{className:"ul-card-rank__option",draggable:!!h||void 0,onDragEnd:h?$:void 0,onDragEnter:h?Q:void 0,onDragLeave:h?W:void 0,onDragStart:h?(X=O,j=>{o.current=X,j.dataTransfer&&(j.dataTransfer.effectAllowed="move",j.dataTransfer.setData("text/plain",String(X)),j.currentTarget.classList.add("is-dragging"))}):void 0,onDrop:h?(Z=O,j=>{var re,de;j.preventDefault(),j.currentTarget.classList.remove("is-drop-target");const Y=o.current;o.current=null,(de=(re=j.currentTarget.closest(".ul-card-rank__list"))==null?void 0:re.querySelector(".is-dragging"))==null||de.classList.remove("is-dragging"),Y!=null&&Y!==Z&&te(Y,Z)}):void 0,ref:j=>S.current[O]=j,children:[e.u("select",{"aria-label":`Rank for ${q}`,className:e.cc("ul-card-rank__select",V==null&&"ul-card-rank__select--placeholder"),name:`rank[${f}]`,onChange:j=>A(f,j.currentTarget.value),value:V??"",children:[V==null&&e.u("option",{className:"ul-card-rank__select-option",disabled:!0,value:"",children:"-"}),w.map(j=>e.u("option",{className:"ul-card-rank__select-option",value:j,children:j},`${j}-${s}`))]}),e.u("span",{children:q}),!T&&e.u("button",{"aria-label":`Drag ${q} to reorder`,className:"ul-card-rank__drag-btn",onTouchEnd:B?ne:void 0,onTouchMove:B?z:void 0,onTouchStart:B?K(O):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