userflow.js-self-hosted 0.1.1003417 → 0.1.1003443

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/FlowChrome.js CHANGED
@@ -1 +1 @@
1
- import{r as t}from"./vendor.react.js";import{u as e,F as o,S as a}from"./logomark.js";import{c as l,H as r,A as i,b as n,I as s,B as c,J as u}from"./userflow.js";import{f as d,b as p}from"./BubbleToolbar.js";import{o as m}from"./vendor.obj-str.js";import{p as f,j as h,q as b,s as g,r as w,h as T,e as E,a as v,g as M,t as L,M as y,m as k}from"./flow-condition-types.js";import{a as j,g as R}from"./stylesheets.js";import{e as B}from"./Icons.js";import{u as O}from"./vendor.react-i18next.js";var P=new URL("avatar-frame.css",import.meta.url).href;let x=!1;const I=[];let N,_=[];function H(t){_.push(t)}function C(){I.forEach((t=>t())),_.length>0&&(_.forEach((t=>t())),_=[]),S()}function S(){x&&(N=window.requestAnimationFrame(C))}function D(){}function U({selector:e,targetMoved:o,targetLost:a,onTargetClick:l,onTargetMouseEnter:r,onTargetMouseLeave:i}){const n=t.useRef(o),s=t.useRef(a),c=t.useRef(l),u=t.useRef(r),d=t.useRef(i);t.useLayoutEffect((()=>{n.current=o,s.current=a,c.current=l,u.current=r,d.current=i})),t.useLayoutEffect((()=>{let t=null,o=null,a=null,l=!1;const r=()=>{t=null,o=null,a=null,s.current()};if(!e)return void r();const i=()=>{if(!a||!t)return;const e=w(t);var l,i;o&&(i=e,(l=o).left===i.left&&l.top===i.top&&l.width===i.width&&l.height===i.height)||(o=e,0===e.width&&0===e.height?r():n.current({targetEl:t,targetRect:o,clipEl:a,viewportClipRect:F(a)}))};let p=!1;const m=()=>{var t;p||(p=!0,t=i,I.push(t),1===I.length&&(x=!0,S(),window.addEventListener("scroll",D)))},T=()=>{p&&(p=!1,function(t){const e=I.indexOf(t);e>=0&&(I.splice(e,1),0===I.length&&(x=!1,window.cancelAnimationFrame(N),window.removeEventListener("scroll",D)))}(i))},E=()=>{c.current&&c.current()},v=()=>{u.current&&u.current()},M=()=>{d.current&&d.current()},L=()=>{const o=t;t=h(e)?e:b(e),l&&t===o||(o&&(o.removeEventListener("click",E),o.removeEventListener("mouseenter",v),o.removeEventListener("mouseleave",M)),t?(m(),t.addEventListener("click",E),t.addEventListener("mouseenter",v),t.addEventListener("mouseleave",M),a=g(t)):(T(),r())),l=!0};L();const y=f(L);return()=>{y.disconnect(),T(),t&&(t.removeEventListener("click",E),t.removeEventListener("mouseenter",v),t.removeEventListener("mouseleave",M))}}),[e])}function F(t){T();const e=E(v()),o=E(M());if(t&&t!==document.documentElement){const a=w(t);return{top:Math.max(0,a.top),right:Math.min(o,a.right),bottom:Math.min(e,a.bottom),left:Math.max(0,a.left)}}return{top:0,right:o,bottom:e,left:0}}const A=({company:f,theme:b,position:w,absoluteWidth:x,absoluteHeight:I,stepKey:N,stepAppearance:_,width:H,backgroundImageUrl:C,tooltipSelector:S,allowMissingTooltipTarget:D,tooltipPlacement:F,backdrop:A,tooltipTargetBlocked:K,backdropPadding:q,zIndex:Y,onTooltipTargetClick:J,onTooltipTargetMissingChange:X,onModalBackdropClick:Q,onVisibleChange:Z,speaking:tt,noIframe:et,MadeWithUserflow:ot,minimizeOnAvatarClick:at,autoHide3pEnabled:lt,bubbleFrameRootRef:rt,frameWrapperHtmlAttributes:it,rootChildren:nt,children:st})=>{const ct=w||"absolute",ut=F||null,dt=q||"0",pt=ot||z,mt=B(),ft="fixed"===ct?null!=Y?Y:mt+1:1,ht=ft-1,{i18n:bt}=O(),gt=bt.dir(),wt=t.useRef(null),Tt=t.useRef(null),Et=t.useRef(null),[vt,Mt]=t.useState(null),Lt=t.useRef(null),yt=t.useRef(null),kt=t.useRef(null),jt=t.useRef(null),Rt=t.useRef(null),Bt=t.useRef(null),Ot=t.useRef(null),Pt=t.useRef(null),xt=t.useRef(null);t.useLayoutEffect((()=>{const t=wt.current.style;t.animation="none",t.visibility="hidden",t.position="absolute",t.top="-99999px",t.left="-99999px"}),[]);const{loaded:It}=j(window,d,b),[Nt,_t]=t.useState(!1),[Ht,Ct]=t.useState(!1),St=It&&Nt&&Ht;let[Dt,Ut]=t.useState(!1);_!==r.BUBBLE&&(at=!1,Dt=!1),t.useEffect((()=>{Ut(!1)}),[N]);const Ft=t.useRef({appearance:null,width:null,theme:b,bubbleFrameHeight:0,backdrop:!1,backdropPadding:"0",prevTooltipTargetParams:null,tooltipTargetParams:null,desiredTooltipPlacement:null,tooltipPlacement:null,lastReportedTooltipTargetMissing:!1,tooltipTargetMissing:!1,tooltipTargetMissingTimeout:void 0,stepKeyScrolledIntoView:void 0,targetScrolledIntoView:null}),[At,Wt]=t.useState(null),zt=null!=At&&St;t.useEffect((()=>{Z&&Z(zt)}),[Z,zt]);const Vt=t.useCallback((t=>{Ft.current.lastReportedTooltipTargetMissing!==t&&(Ft.current.lastReportedTooltipTargetMissing=t,X&&X(t))}),[X]),Gt=t.useCallback((({forceAppearanceLayout:t,forceUpdatePosition:e}={})=>{const o=wt.current,a=Tt.current,n=Et.current,d=yt.current,p=Lt.current,m=kt.current,f=jt.current,h=Rt.current,w=Bt.current,y=Ot.current,j=Pt.current,R=xt.current;if(!(o&&a&&n&&vt&&d&&p&&m&&f&&h&&w&&y&&j&&R))return;if(!St)return;const B=Ft.current,{tooltipTargetParams:O}=B;T();let P=_,C=!1;P!==r.TOOLTIP||D||O||(B.tooltipTargetMissing?(P=r.BUBBLE,C=!0):P=null);const S=P!==B.appearance,U=H!==B.width;if((t||S||U||b!==B.theme||A!=B.backdrop||dt!=B.backdropPadding||ut!==B.desiredTooltipPlacement)&&(B.appearance=P,B.width=H,B.theme=b,B.backdrop=A,B.backdropPadding=dt,B.desiredTooltipPlacement=ut,e=!0,function({layoutState:{appearance:t,theme:e,backdrop:o,tooltipTargetMissing:a},width:l,position:n,absoluteWidth:c,root:u,bubble:d,bubbleFrameRoot:p,avatar:m,avatarNotch:f,modalBackdrop:h,dir:b}){const g="absolute"===n?c||1024:E(M()),{avatarSize:w,bubblePlacement:T}=e;let v=e.bubbleWidth,L=null,y=null,k=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${t?.toLowerCase()}`,j="hidden",R=null,B=null,O=null,P=null,x="userflowjs-bubble__avatar-notch",I="hidden",N=null,_=null,H=null,C=null,S="userflowjs-modal-backdrop";(t===r.MODAL||!a&&t===r.BUBBLE&&o)&&(S+=" userflowjs-modal-backdrop--visible");switch(t){case r.BUBBLE:if(e.avatarType!==i.NONE){j="",I="",T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.TOP_RIGHT?(L=w+20,R=0,N=-40,x+=" userflowjs-bubble__avatar-notch--top"):(y=w+20,O=0,H=-40,x+=" userflowjs-bubble__avatar-notch--bottom");const t=T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.BOTTOM_LEFT||T===s.BOTTOM_CENTER||T===s.CENTER;"ltr"===b&&t||"rtl"===b&&!t?(P=0,C=w,x+=" userflowjs-bubble__avatar-notch--left"):(B=0,_=w,x+=" userflowjs-bubble__avatar-notch--right")}break;case r.MODAL:v=e.modalWidth,e.avatarType!==i.NONE&&(j="",P=`calc(50% - ${w/2}px)`,R=-w/2);break;case r.TOOLTIP:v=e.tooltipWidth}null!=l&&(v=l);v=Math.min(v,g),u.classList.toggle("userflowjs-flow-chrome--position-absolute","absolute"===n),u.classList.toggle("userflowjs-flow-chrome--position-relative","relative"===n),u.classList.toggle("userflowjs-flow-chrome--position-fixed","fixed"===n),u.classList.toggle("userflowjs-flow-chrome--appearance-modal",t===r.MODAL);const D=null!=t&&t!==r.HIDDEN;u.style.position="",u.style.top="",u.style.left="",u.style.visibility=D?"":"hidden",u.style.animation=D?"":"none",V(d,"width",E(v)),V(d,"padding-top",L),V(d,"padding-bottom",y),p.className=k,V(m,"width",E(e.avatarSize)),V(m,"height",E(e.avatarSize)),m.style.visibility=j,V(m,"top",R),V(m,"right",B),V(m,"bottom",O),V(m,"left",P),f.className=x,f.style.visibility=I,V(f,"top",N),V(f,"right",_),V(f,"bottom",H),V(f,"left",C),h.className=S}({layoutState:B,width:H,position:ct,absoluteWidth:x,root:o,bubble:a,bubbleFrameRoot:vt,avatar:d,avatarNotch:p,modalBackdrop:R,dir:gt})),!et){const t=vt.offsetHeight,o=v()-2*(M()<800?0:16)-(P===r.BUBBLE&&b.avatarType!==i.NONE?20+b.avatarSize:0),a=Math.min(t,o);if(P&&a!==B.bubbleFrameHeight){if(B.bubbleFrameHeight=a,V(n,"height",E(a)),L(n)&&n.contentDocument){n.contentDocument.documentElement.style.overflowY=t<=o?"hidden":"scroll"}e=!0}}if(e&&P){let t=S;if(P===r.TOOLTIP){(B.tooltipTargetParams&&B.tooltipTargetParams.targetEl)!==(B.prevTooltipTargetParams&&B.prevTooltipTargetParams.targetEl)&&(t=!0)}B.prevTooltipTargetParams=B.tooltipTargetParams,function({layoutState:t,animateIn:e,position:o,absoluteWidth:a,absoluteHeight:l,desiredTooltipPlacement:i,root:n,bubble:d,tooltipNotch:p,tooltipBackdrop:m,tooltipBlockTop:f,tooltipBlockRight:h,tooltipBlockBottom:b,tooltipBlockLeft:g,dir:w}){const{appearance:T,theme:L,tooltipTargetParams:y,backdrop:j,backdropPadding:R}=t,{bubblePlacement:B}=L,O=16,P=L.tooltipNotchSize,x=10,{width:I,height:N}=d.getBoundingClientRect(),_="absolute"===o?a||1024:E(M()),H="absolute"===o?l||768:E(v());let C=0,S=0,D="userflowjs-bubble__tooltip-notch",U="hidden",F=null,A=null,W=null,z=null,K="userflowjs-tooltip-backdrop",q=null,Y=null,J=null,X=null,Q=null,Z=null,tt=null,et=null,ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",at=null,lt=null,rt="userflowjs-tooltip-block userflowjs-tooltip-block--right",it=null,nt=null,st="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",ct=null,ut=null,dt="userflowjs-tooltip-block userflowjs-tooltip-block--left",pt=null,mt=null;switch(T){case r.BUBBLE:C=B===s.TOP_LEFT||B===s.BOTTOM_LEFT?L.bubbleX:B===s.TOP_CENTER||B===s.CENTER||B===s.BOTTOM_CENTER?(_-I)/2:_-I-L.bubbleX,S=B===s.TOP_LEFT||B===s.TOP_CENTER||B===s.TOP_RIGHT?L.bubbleY:B===s.CENTER?(H-N)/2:H-N-L.bubbleY,"rtl"===w&&(C=_-C-I),C=Math.max(0,Math.min(_-I,C)),S=Math.max(0,Math.min(H-N,S));break;case r.MODAL:C=O+(_-2*O-I)/2,S=O+(H-2*O-N)/2;break;case r.TOOLTIP:{let e;if(y){let{targetRect:a,viewportClipRect:l}=y;if("absolute"===o){const t=n.offsetParent.getBoundingClientRect();l={top:0,right:_,bottom:H,left:0},a={top:a.top-t.top,right:a.right-t.left,bottom:a.bottom-t.top,left:a.left-t.left,width:a.width,height:a.height}}let r=0;if(j){const{paddingTop:t,paddingRight:e,paddingBottom:o,paddingLeft:l}=function(t){if(!t||"0"===t)return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const e=t.trim().split(" ");if(1===e.length){const t=$(e[0]);return{paddingTop:t,paddingRight:t,paddingBottom:t,paddingLeft:t}}if(2===e.length){const t=$(e[0]),o=$(e[1]);return{paddingTop:t,paddingRight:o,paddingBottom:t,paddingLeft:o}}return{paddingTop:$(e[0]),paddingRight:$(e[1]),paddingBottom:$(e[2]),paddingLeft:$(e[3])}}(R);a={top:a.top-t,right:a.right+e,bottom:a.bottom+o,left:a.left-l,width:a.width+l+e,height:a.height+t+o},r=Math.min(t,e,o,l)}const s=a,d=L.backdropHighlightType==c.OUTSIDE?L.backdropHighlightSpread:0;if(j&&d&&(a={top:a.top-d,right:a.right+d,bottom:a.bottom+d,left:a.left-d,width:a.width+2*d,height:a.height+2*d}),e=function({targetRect:t,bubbleWidth:e,bubbleHeight:o,containerWidth:a,containerHeight:l,viewportClipRect:r,tooltipNotchSize:i,currentTooltipPlacement:n,desiredTooltipPlacement:s}){if(t.bottom<=r.top)return o+i<=l-r.top?u.BELOW:u.ABOVE;if(t.top>=r.bottom)return o+i<=r.bottom?u.ABOVE:u.BELOW;if(t.right<=r.left)return e+i<=a-r.left?u.RIGHT:u.LEFT;if(t.left>=r.right)return e+i<=r.right?u.LEFT:u.RIGHT;const c=n=>{const s=t.left+t.width/2,c=s>=r.left&&s<=r.right,d=t.top+t.height/2,p=d>=r.top&&d<=r.bottom;switch(n){case u.BELOW:return l-t.bottom>o+i&&c;case u.ABOVE:return t.top>o+i&&c;case u.RIGHT:return a-t.right>e+i&&p;case u.LEFT:return t.left>e+i&&p}};if(s&&c(s))return s;if(n&&c(n))return n;const d=[{placement:u.BELOW,dist:t.top},{placement:u.ABOVE,dist:l-t.bottom},{placement:u.RIGHT,dist:t.left},{placement:u.LEFT,dist:a-t.right}];d.sort(((t,e)=>t.dist-e.dist));for(const{placement:u}of d)if(c(u))return u;return u.BELOW}({targetRect:a,bubbleWidth:I,bubbleHeight:N,containerWidth:_,containerHeight:H,viewportClipRect:l,tooltipNotchSize:P,currentTooltipPlacement:t.tooltipPlacement,desiredTooltipPlacement:i}),e===u.BELOW||e===u.ABOVE?(C=a.left+a.width/2-I/2,C=Math.max(O,Math.min(_-I-O,C)),z=Math.max(x,Math.min(I-x-2*P,a.left+a.width/2-P-C)),e===u.BELOW?F=2*-P:W=2*-P):e===u.RIGHT?(C=a.right+P,C=Math.max(C,l.left+P),C=Math.min(C,l.right+P),C=Math.max(C,P),C=Math.min(C,_-I)):(C=a.left-P-I,C=Math.max(C,l.left-I-P),C=Math.min(C,l.right-I-P),C=Math.max(C,0),C=Math.min(C,_-I-P)),e===u.LEFT||e===u.RIGHT?(S=a.top+a.height/2-N/2,S=Math.max(O,Math.min(H-N-O,S)),F=Math.max(x,Math.min(N-x-2*P,a.top+a.height/2-P-S)),e===u.LEFT?A=2*-P:z=2*-P):e===u.BELOW?(S=a.bottom+P,S=Math.max(S,l.top+P),S=Math.min(S,l.bottom+P),S=Math.max(S,P),S=Math.min(S,H-N)):(S=a.top-P-N,S=Math.max(S,l.top-N-P),S=Math.min(S,l.bottom-N-P),S=Math.max(S,0),S=Math.min(S,H-N-P)),j){const t=window.getComputedStyle(y.targetEl);q=Math.max(0,s.top),Y=Math.max(0,_-s.right),J=Math.max(0,H-s.bottom),X=Math.max(0,s.left),Q=Math.max(0,k(t.borderTopLeftRadius)+r),Z=Math.max(0,k(t.borderTopRightRadius)+r),tt=Math.max(0,k(t.borderBottomRightRadius)+r),et=Math.max(0,k(t.borderBottomLeftRadius)+r),at=Math.max(0,s.right),lt=Math.max(0,s.top),it=Math.max(0,s.right),nt=Math.max(0,s.bottom),ct=Math.max(0,s.left),ut=Math.max(0,s.bottom),pt=Math.max(0,s.left),mt=Math.max(0,s.top)}}else e=i||u.BELOW,e!==u.BELOW&&e!==u.ABOVE||(z=I/2-P,e===u.BELOW?F=2*-P:W=2*-P),e!==u.LEFT&&e!==u.RIGHT||(F=N/2-P,e===u.LEFT?A=2*-P:z=2*-P);t.tooltipPlacement=e,D+=` userflowjs-bubble__tooltip-notch--${e.toLowerCase()}`,U="",j&&(K+=" userflowjs-tooltip-backdrop--visible",ot+=" userflowjs-tooltip-block--visible",rt+=" userflowjs-tooltip-block--visible",st+=" userflowjs-tooltip-block--visible",dt+=" userflowjs-tooltip-block--visible");break}}d.style.transition="";let ft=C,ht=S;if(e&&(d.style.opacity="0",T===r.TOOLTIP)){const e=24;switch(t.tooltipPlacement){case u.BELOW:S+=e;break;case u.ABOVE:S-=e;break;case u.RIGHT:C+=e;break;case u.LEFT:C-=e}}"relative"!==o&&G(d,C,S);if(p.className=D,p.style.visibility=U,V(p,"top",F),V(p,"right",A),V(p,"bottom",W),V(p,"left",z),m.className=K,V(m,"top",q),V(m,"right",Y),V(m,"bottom",J),V(m,"left",X),V(m,"border-top-left-radius",Q),V(m,"border-top-right-radius",Z),V(m,"border-bottom-right-radius",tt),V(m,"border-bottom-left-radius",et),f.className=ot,V(f,"width",at),V(f,"height",lt),h.className=rt,V(h,"left",it),V(h,"height",nt),b.className=st,V(b,"left",ct),V(b,"top",ut),g.className=dt,V(g,"width",pt),V(g,"top",mt),e){d.offsetWidth;const t="opacity 250ms linear";T===r.TOOLTIP?d.style.transition=`${t}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:d.style.transition=t,d.style.opacity="1","relative"!==o&&G(d,ft,ht)}}({layoutState:B,animateIn:t,position:ct,absoluteWidth:x,absoluteHeight:I,desiredTooltipPlacement:ut,root:o,bubble:a,tooltipNotch:m,tooltipBackdrop:f,tooltipBlockTop:h,tooltipBlockRight:w,tooltipBlockBottom:y,tooltipBlockLeft:j,dir:gt})}if(P===r.TOOLTIP){const t=O&&O.targetEl;t&&B.stepKeyScrolledIntoView!==N&&B.targetScrolledIntoView!==t&&(B.stepKeyScrolledIntoView=N,B.targetScrolledIntoView=t,function(t){if(l.customScrollIntoView)return void l.customScrollIntoView(t);const{scrollPadding:e}=l;if(e&&g(t)===document.scrollingElement){const o=e.top||0,a=e.right||0,l=e.bottom||0,r=e.left||0;let i=0,n=0;const s=t.getBoundingClientRect(),c=M(),u=v();if(s.top<o?i=s.top-o:s.bottom>u-l&&(i=s.bottom-u+l),s.left<r?n=s.left-r:s.right>c-a&&(n=s.right-c+a),0!=i||0!=n)return void window.scrollBy({top:i,left:n,behavior:"smooth"})}try{t.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),t.scrollIntoView()}}(t))}else B.stepKeyScrolledIntoView=void 0,B.targetScrolledIntoView=null;Vt(C),Wt(P)}),[St,vt,N,_,H,b,ct,x,I,D,ut,A,dt,et,Vt,gt]),$t=t.useRef(Gt);$t.current=Gt;const Kt=t.useRef(!1);t.useEffect((()=>{const t=()=>{Kt.current=!0};return window.addEventListener("pagehide",t),()=>window.removeEventListener("pagehide",t)}),[]);const qt=()=>{window.clearTimeout(Ft.current.tooltipTargetMissingTimeout),Ft.current.tooltipTargetMissingTimeout=void 0};t.useEffect((()=>qt),[]);const Yt=t.useCallback((()=>{const t=Ft.current;if(t.tooltipTargetParams=null,D||(t.tooltipPlacement=null),_!==r.TOOLTIP)return qt(),void(t.tooltipTargetMissing=!1);if(!D&&!t.tooltipTargetMissingTimeout){t.tooltipTargetMissing=!1;const e=!S||h(S)||S.type!==n.AUTO||S.autoData?1e3*parseFloat(b.tooltipMissingToleranceSeconds):1;t.tooltipTargetMissingTimeout=window.setTimeout((()=>{if(!Kt.current){if(S&&!h(S)){let t=S.autoData;if(S.autoData)try{t=JSON.parse(S.autoData)}catch(e){}console.warn("Userflow.js: Tooltip target not found on page.\n",{type:S.type,autoData:t,excludeText:S.excludeText,precision:S.precision,text:S.text,css:S.css})}qt(),t.tooltipTargetMissing=!0,$t.current()}}),e)}$t.current()}),[_,D,S,b.tooltipMissingToleranceSeconds]),Jt=t.useCallback((t=>{const e=Ft.current;qt(),e.tooltipTargetParams&&e.tooltipTargetParams.targetEl!==t.targetEl&&(e.tooltipPlacement=null),e.tooltipTargetParams=t,Gt({forceUpdatePosition:!0})}),[Gt]);U({selector:_===r.TOOLTIP&&S||null,targetMoved:Jt,targetLost:Yt,onTargetClick:J});const Xt=t.useCallback((()=>Gt({forceAppearanceLayout:!0})),[Gt]);e(Xt),t.useEffect((()=>{if(!vt||et||"function"!=typeof y)return;let t;const e=new y((()=>{t||(t=window.requestAnimationFrame((()=>{t=void 0,$t.current()})))}));return e.observe(vt,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect(),t&&window.cancelAnimationFrame(t)}}),[vt,et]),t.useLayoutEffect((()=>{$t.current()})),t.useLayoutEffect((()=>{"absolute"===ct&&Gt({forceAppearanceLayout:!0})}),[ct,x,I]);const Qt=t=>{t.preventDefault(),t.stopPropagation()};return function(e,o){const a=window.Intercom;t.useEffect((()=>{if(o&&e.autoHideIntercom&&"function"==typeof a&&!l.autoHide3pDisabled){try{a("update",{hide_default_launcher:!0})}catch(t){console.warn("Userflow.js: Error when hiding Intercom launcher",t)}return()=>{if(!l.autoHide3pDisabled)try{a("update",{hide_default_launcher:!1})}catch(t){console.warn("Userflow.js: Error when unhiding Intercom launcher",t)}}}}),[a,e.autoHideIntercom,o]);const r=window.$crisp;t.useEffect((()=>{if(o&&e.autoHideCrisp&&r&&!l.autoHide3pDisabled){try{r.push(["do","chat:hide"])}catch(t){console.warn("Userflow.js: Error when hiding Crisp Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{r.push(["do","chat:show"])}catch(t){console.warn("Userflow.js: Error when unhiding Crisp Chat",t)}}}}),[r,e.autoHideCrisp,o]);const i=window.HubSpotConversations;t.useEffect((()=>{if(o&&e.autoHideHubspot&&i&&!l.autoHide3pDisabled){try{i.widget.remove()}catch(t){console.warn("Userflow.js: Error when hiding HubSpot Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{i.widget.load()}catch(t){console.warn("Userflow.js: Error when unhiding HubSpot Chat",t)}}}}),[i,e.autoHideHubspot,o]);const n=window.drift;t.useEffect((()=>{if(o&&e.autoHideDrift&&n&&!l.autoHide3pDisabled){try{n.api.widget.hide()}catch(t){console.warn("Userflow.js: Error when hiding Drift Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{n.api.widget.show()}catch(t){console.warn("Userflow.js: Error when unhiding Drift Chat",t)}}}}),[n,e.autoHideDrift,o])}(b,!!lt&&At===r.BUBBLE),t.createElement("div",{ref:wt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:R(b),dir:gt},t.createElement("div",{className:"userflowjs-bubble",ref:Tt,style:{zIndex:ft}},t.createElement("div",{className:m({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(b.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!at,"userflowjs-bubble-outline--minimized":Dt})},t.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...it},t.createElement(o,{className:"userflowjs-bubble__frame",elRef:Et,stylesheet:p,theme:b,onStylesheetsLoad:_t,noIframe:et},t.createElement("div",{className:"userflowjs-bubble-frame-root",ref:t=>{rt&&rt(t),Mt(t)},style:C?{backgroundImage:`url("${encodeURI(C)}")`}:void 0},st,f.flowBranding&&t.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},t.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},t.createElement(pt,{company:f},t.createElement(a,null),t.createElement("div",null,"Made with Userflow"))))))),t.createElement("div",{ref:Lt,className:"userflowjs-bubble__avatar-notch"})),t.createElement(o,{className:m({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!at,"userflowjs-bubble__avatar--speaking":!!tt}),elRef:yt,stylesheet:P,theme:b,onStylesheetsLoad:Ct,noIframe:et,ariaHidden:!0},t.createElement("div",{className:m({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!at}),onClick:at?()=>Ut((t=>!t)):void 0},t.createElement(W,{theme:b}))),t.createElement("div",{ref:kt,className:"userflowjs-bubble__tooltip-notch"})),t.createElement("div",{ref:jt,className:"userflowjs-tooltip-backdrop",onMouseDown:Qt,style:{zIndex:ht,pointerEvents:K?void 0:"none"}}),t.createElement("div",{ref:Rt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:Ot,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:Pt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:xt,className:"userflowjs-modal-backdrop",onMouseDown:Qt,onClick:Q,style:{zIndex:ht}}),nt&&nt({visible:zt,bubbleFrame:Et.current}))},W=({theme:e})=>{const o="https://js.userflow.com/cartoon-avatars-no-bg/";let a;return a=e.avatarType===i.ASSET&&e.avatarAsset?e.avatarAsset.assetUrl:e.avatarType===i.CARTOON&&e.avatarName?o+e.avatarName+".svg?3":e.avatarType===i.URL&&e.avatarUrl?e.avatarUrl:o+"none.svg",t.createElement("img",{src:a,alt:""})},z=({company:e,children:o})=>t.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+e.slug,target:"_blank",rel:"noopener noreferrer"},o);function V(t,e,o){null==o?t.style.removeProperty(e):t.style.setProperty(e,"number"==typeof o?o+"px":o,"important")}function G(t,e,o){e=Math.round(e),o=Math.round(o),t.style.transform=`translate3d(${e}px, ${o}px, 0px)`}function $(t){const e=parseInt(t,10);return isNaN(e)?0:e}export{A as F,H as r,U as u};
1
+ import{r as t}from"./vendor.react.js";import{u as e,F as o,S as a}from"./logomark.js";import{c as l,H as r,A as i,b as n,I as s,B as c,J as u}from"./userflow.js";import{f as d,b as p}from"./BubbleToolbar.js";import{o as m}from"./vendor.obj-str.js";import{p as f,j as h,q as b,s as g,r as w,h as T,e as E,a as v,g as M,t as L,M as y,m as k}from"./flow-condition-types.js";import{a as j,g as R}from"./stylesheets.js";import{e as B}from"./Icons.js";import{u as O}from"./vendor.react-i18next.js";var P=new URL("avatar-frame.css",import.meta.url).href;let x=!1;const I=[];let N,_=[];function H(t){_.push(t)}function C(){I.forEach((t=>t())),_.length>0&&(_.forEach((t=>t())),_=[]),S()}function S(){x&&(N=window.requestAnimationFrame(C))}function D(){}function U({selector:e,targetMoved:o,targetLost:a,onTargetClick:l,onTargetMouseEnter:r,onTargetMouseLeave:i}){const n=t.useRef(o),s=t.useRef(a),c=t.useRef(l),u=t.useRef(r),d=t.useRef(i);t.useLayoutEffect((()=>{n.current=o,s.current=a,c.current=l,u.current=r,d.current=i})),t.useLayoutEffect((()=>{let t=null,o=null,a=null,l=!1;const r=()=>{t=null,o=null,a=null,s.current()};if(!e)return void r();const i=()=>{if(!a||!t)return;const e=w(t);var l,i;o&&(i=e,(l=o).left===i.left&&l.top===i.top&&l.width===i.width&&l.height===i.height)||(o=e,0===e.width&&0===e.height?r():n.current({targetEl:t,targetRect:o,clipEl:a,viewportClipRect:F(a)}))};let p=!1;const m=()=>{var t;p||(p=!0,t=i,I.push(t),1===I.length&&(x=!0,S(),window.addEventListener("scroll",D)))},T=()=>{p&&(p=!1,function(t){const e=I.indexOf(t);e>=0&&(I.splice(e,1),0===I.length&&(x=!1,window.cancelAnimationFrame(N),window.removeEventListener("scroll",D)))}(i))},E=()=>{c.current&&c.current()},v=()=>{u.current&&u.current()},M=()=>{d.current&&d.current()},L=()=>{const o=t;t=h(e)?e:b(e),l&&t===o||(o&&(o.removeEventListener("click",E),o.removeEventListener("mouseenter",v),o.removeEventListener("mouseleave",M)),t?(m(),t.addEventListener("click",E),t.addEventListener("mouseenter",v),t.addEventListener("mouseleave",M),a=g(t)):(T(),r())),l=!0};L();const y=f(L);return()=>{y.disconnect(),T(),t&&(t.removeEventListener("click",E),t.removeEventListener("mouseenter",v),t.removeEventListener("mouseleave",M))}}),[e])}function F(t){T();const e=E(v()),o=E(M());if(t&&t!==document.documentElement){const a=w(t);return{top:Math.max(0,a.top),right:Math.min(o,a.right),bottom:Math.min(e,a.bottom),left:Math.max(0,a.left)}}return{top:0,right:o,bottom:e,left:0}}const A=({company:f,theme:b,position:w,absoluteWidth:x,absoluteHeight:I,stepKey:N,stepAppearance:_,width:H,backgroundImageUrl:C,tooltipSelector:S,allowMissingTooltipTarget:D,tooltipPlacement:F,backdrop:A,tooltipTargetBlocked:K,backdropPadding:q,zIndex:Y,onTooltipTargetClick:J,onTooltipTargetMissingChange:X,onModalBackdropClick:Q,onVisibleChange:Z,speaking:tt,noIframe:et,MadeWithUserflow:ot,minimizeOnAvatarClick:at,autoHide3pEnabled:lt,bubbleFrameRootRef:rt,frameWrapperHtmlAttributes:it,rootChildren:nt,children:st})=>{const ct=w||"absolute",ut=F||null,dt=q||"0",pt=ot||z,mt=B(),ft="fixed"===ct?null!=Y?Y:mt+1:1,ht=ft-1,{i18n:bt}=O(),gt=bt.dir(),wt=t.useRef(null),Tt=t.useRef(null),Et=t.useRef(null),[vt,Mt]=t.useState(null),Lt=t.useRef(null),yt=t.useRef(null),kt=t.useRef(null),jt=t.useRef(null),Rt=t.useRef(null),Bt=t.useRef(null),Ot=t.useRef(null),Pt=t.useRef(null),xt=t.useRef(null);t.useLayoutEffect((()=>{const t=wt.current.style;t.animation="none",t.visibility="hidden",t.position="absolute",t.top="-99999px",t.left="-99999px"}),[]);const{loaded:It}=j(window,d,b),[Nt,_t]=t.useState(!1),[Ht,Ct]=t.useState(!1),St=It&&Nt&&Ht;let[Dt,Ut]=t.useState(!1);_!==r.BUBBLE&&(at=!1,Dt=!1),t.useEffect((()=>{Ut(!1)}),[N]);const Ft=t.useRef({appearance:null,width:null,theme:b,bubbleFrameHeight:0,backdrop:!1,backdropPadding:"0",prevTooltipTargetParams:null,tooltipTargetParams:null,desiredTooltipPlacement:null,tooltipPlacement:null,lastReportedTooltipTargetMissing:!1,tooltipTargetMissing:!1,tooltipTargetMissingTimeout:void 0,stepKeyScrolledIntoView:void 0,targetScrolledIntoView:null}),[At,Wt]=t.useState(null),zt=null!=At&&St;t.useEffect((()=>{Z&&Z(zt)}),[Z,zt]);const Vt=t.useCallback((t=>{Ft.current.lastReportedTooltipTargetMissing!==t&&(Ft.current.lastReportedTooltipTargetMissing=t,X&&X(t))}),[X]),Gt=t.useCallback((({forceAppearanceLayout:t,forceUpdatePosition:e}={})=>{const o=wt.current,a=Tt.current,n=Et.current,d=yt.current,p=Lt.current,m=kt.current,f=jt.current,h=Rt.current,w=Bt.current,y=Ot.current,j=Pt.current,R=xt.current;if(!(o&&a&&n&&vt&&d&&p&&m&&f&&h&&w&&y&&j&&R))return;if(!St)return;const B=Ft.current,{tooltipTargetParams:O}=B;T();let P=_,C=!1;P!==r.TOOLTIP||D||O||(B.tooltipTargetMissing?(P=r.BUBBLE,C=!0):P=null);const S=P!==B.appearance,U=H!==B.width;if((t||S||U||b!==B.theme||A!=B.backdrop||dt!=B.backdropPadding||ut!==B.desiredTooltipPlacement)&&(B.appearance=P,B.width=H,B.theme=b,B.backdrop=A,B.backdropPadding=dt,B.desiredTooltipPlacement=ut,e=!0,function({layoutState:{appearance:t,theme:e,backdrop:o,tooltipTargetMissing:a},width:l,position:n,absoluteWidth:c,root:u,bubble:d,bubbleFrameRoot:p,avatar:m,avatarNotch:f,modalBackdrop:h,dir:b}){const g="absolute"===n?c||1024:E(M()),{avatarSize:w,bubblePlacement:T}=e;let v=e.bubbleWidth,L=null,y=null,k=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${t?.toLowerCase()}`,j="hidden",R=null,B=null,O=null,P=null,x="userflowjs-bubble__avatar-notch",I="hidden",N=null,_=null,H=null,C=null,S="userflowjs-modal-backdrop";(t===r.MODAL||!a&&t===r.BUBBLE&&o)&&(S+=" userflowjs-modal-backdrop--visible");switch(t){case r.BUBBLE:if(e.avatarType!==i.NONE){j="",I="",T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.TOP_RIGHT?(L=w+20,R=0,N=-40,x+=" userflowjs-bubble__avatar-notch--top"):(y=w+20,O=0,H=-40,x+=" userflowjs-bubble__avatar-notch--bottom");const t=T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.BOTTOM_LEFT||T===s.BOTTOM_CENTER||T===s.CENTER;"ltr"===b&&t||"rtl"===b&&!t?(P=0,C=w,x+=" userflowjs-bubble__avatar-notch--left"):(B=0,_=w,x+=" userflowjs-bubble__avatar-notch--right")}break;case r.MODAL:v=e.modalWidth,e.avatarType!==i.NONE&&(j="",P=`calc(50% - ${w/2}px)`,R=-w/2);break;case r.TOOLTIP:v=e.tooltipWidth}null!=l&&(v=l);v=Math.min(v,g-32),u.classList.toggle("userflowjs-flow-chrome--position-absolute","absolute"===n),u.classList.toggle("userflowjs-flow-chrome--position-relative","relative"===n),u.classList.toggle("userflowjs-flow-chrome--position-fixed","fixed"===n),u.classList.toggle("userflowjs-flow-chrome--appearance-modal",t===r.MODAL);const D=null!=t&&t!==r.HIDDEN;u.style.position="",u.style.top="",u.style.left="",u.style.visibility=D?"":"hidden",u.style.animation=D?"":"none",V(d,"width",E(v)),V(d,"padding-top",L),V(d,"padding-bottom",y),p.className=k,V(m,"width",E(e.avatarSize)),V(m,"height",E(e.avatarSize)),m.style.visibility=j,V(m,"top",R),V(m,"right",B),V(m,"bottom",O),V(m,"left",P),f.className=x,f.style.visibility=I,V(f,"top",N),V(f,"right",_),V(f,"bottom",H),V(f,"left",C),h.className=S}({layoutState:B,width:H,position:ct,absoluteWidth:x,root:o,bubble:a,bubbleFrameRoot:vt,avatar:d,avatarNotch:p,modalBackdrop:R,dir:gt})),!et){const t=vt.offsetHeight,o=v()-2*(M()<800?0:16)-(P===r.BUBBLE&&b.avatarType!==i.NONE?20+b.avatarSize:0),a=Math.min(t,o);if(P&&a!==B.bubbleFrameHeight){if(B.bubbleFrameHeight=a,V(n,"height",E(a)),L(n)&&n.contentDocument){n.contentDocument.documentElement.style.overflowY=t<=o?"hidden":"scroll"}e=!0}}if(e&&P){let t=S;if(P===r.TOOLTIP){(B.tooltipTargetParams&&B.tooltipTargetParams.targetEl)!==(B.prevTooltipTargetParams&&B.prevTooltipTargetParams.targetEl)&&(t=!0)}B.prevTooltipTargetParams=B.tooltipTargetParams,function({layoutState:t,animateIn:e,position:o,absoluteWidth:a,absoluteHeight:l,desiredTooltipPlacement:i,root:n,bubble:d,tooltipNotch:p,tooltipBackdrop:m,tooltipBlockTop:f,tooltipBlockRight:h,tooltipBlockBottom:b,tooltipBlockLeft:g,dir:w}){const{appearance:T,theme:L,tooltipTargetParams:y,backdrop:j,backdropPadding:R}=t,{bubblePlacement:B}=L,O=16,P=L.tooltipNotchSize,x=10,{width:I,height:N}=d.getBoundingClientRect(),_="absolute"===o?a||1024:E(M()),H="absolute"===o?l||768:E(v());let C=0,S=0,D="userflowjs-bubble__tooltip-notch",U="hidden",F=null,A=null,W=null,z=null,K="userflowjs-tooltip-backdrop",q=null,Y=null,J=null,X=null,Q=null,Z=null,tt=null,et=null,ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",at=null,lt=null,rt="userflowjs-tooltip-block userflowjs-tooltip-block--right",it=null,nt=null,st="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",ct=null,ut=null,dt="userflowjs-tooltip-block userflowjs-tooltip-block--left",pt=null,mt=null;switch(T){case r.BUBBLE:C=B===s.TOP_LEFT||B===s.BOTTOM_LEFT?L.bubbleX:B===s.TOP_CENTER||B===s.CENTER||B===s.BOTTOM_CENTER?(_-I)/2:_-I-L.bubbleX,S=B===s.TOP_LEFT||B===s.TOP_CENTER||B===s.TOP_RIGHT?L.bubbleY:B===s.CENTER?(H-N)/2:H-N-L.bubbleY,"rtl"===w&&(C=_-C-I),C=Math.max(0,Math.min(_-I,C)),S=Math.max(0,Math.min(H-N,S));break;case r.MODAL:C=O+(_-2*O-I)/2,S=O+(H-2*O-N)/2;break;case r.TOOLTIP:{let e;if(y){let{targetRect:a,viewportClipRect:l}=y;if("absolute"===o){const t=n.offsetParent.getBoundingClientRect();l={top:0,right:_,bottom:H,left:0},a={top:a.top-t.top,right:a.right-t.left,bottom:a.bottom-t.top,left:a.left-t.left,width:a.width,height:a.height}}let r=0;if(j){const{paddingTop:t,paddingRight:e,paddingBottom:o,paddingLeft:l}=function(t){if(!t||"0"===t)return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const e=t.trim().split(" ");if(1===e.length){const t=$(e[0]);return{paddingTop:t,paddingRight:t,paddingBottom:t,paddingLeft:t}}if(2===e.length){const t=$(e[0]),o=$(e[1]);return{paddingTop:t,paddingRight:o,paddingBottom:t,paddingLeft:o}}return{paddingTop:$(e[0]),paddingRight:$(e[1]),paddingBottom:$(e[2]),paddingLeft:$(e[3])}}(R);a={top:a.top-t,right:a.right+e,bottom:a.bottom+o,left:a.left-l,width:a.width+l+e,height:a.height+t+o},r=Math.min(t,e,o,l)}const s=a,d=L.backdropHighlightType==c.OUTSIDE?L.backdropHighlightSpread:0;if(j&&d&&(a={top:a.top-d,right:a.right+d,bottom:a.bottom+d,left:a.left-d,width:a.width+2*d,height:a.height+2*d}),e=function({targetRect:t,bubbleWidth:e,bubbleHeight:o,containerWidth:a,containerHeight:l,viewportClipRect:r,tooltipNotchSize:i,currentTooltipPlacement:n,desiredTooltipPlacement:s}){if(t.bottom<=r.top)return o+i<=l-r.top?u.BELOW:u.ABOVE;if(t.top>=r.bottom)return o+i<=r.bottom?u.ABOVE:u.BELOW;if(t.right<=r.left)return e+i<=a-r.left?u.RIGHT:u.LEFT;if(t.left>=r.right)return e+i<=r.right?u.LEFT:u.RIGHT;const c=n=>{const s=t.left+t.width/2,c=s>=r.left&&s<=r.right,d=t.top+t.height/2,p=d>=r.top&&d<=r.bottom;switch(n){case u.BELOW:return l-t.bottom>o+i&&c;case u.ABOVE:return t.top>o+i&&c;case u.RIGHT:return a-t.right>e+i&&p;case u.LEFT:return t.left>e+i&&p}};if(s&&c(s))return s;if(n&&c(n))return n;const d=[{placement:u.BELOW,dist:t.top},{placement:u.ABOVE,dist:l-t.bottom},{placement:u.RIGHT,dist:t.left},{placement:u.LEFT,dist:a-t.right}];d.sort(((t,e)=>t.dist-e.dist));for(const{placement:u}of d)if(c(u))return u;return u.BELOW}({targetRect:a,bubbleWidth:I,bubbleHeight:N,containerWidth:_,containerHeight:H,viewportClipRect:l,tooltipNotchSize:P,currentTooltipPlacement:t.tooltipPlacement,desiredTooltipPlacement:i}),e===u.BELOW||e===u.ABOVE?(C=a.left+a.width/2-I/2,C=Math.max(O,Math.min(_-I-O,C)),z=Math.max(x,Math.min(I-x-2*P,a.left+a.width/2-P-C)),e===u.BELOW?F=2*-P:W=2*-P):e===u.RIGHT?(C=a.right+P,C=Math.max(C,l.left+P),C=Math.min(C,l.right+P),C=Math.max(C,P),C=Math.min(C,_-I)):(C=a.left-P-I,C=Math.max(C,l.left-I-P),C=Math.min(C,l.right-I-P),C=Math.max(C,0),C=Math.min(C,_-I-P)),e===u.LEFT||e===u.RIGHT?(S=a.top+a.height/2-N/2,S=Math.max(O,Math.min(H-N-O,S)),F=Math.max(x,Math.min(N-x-2*P,a.top+a.height/2-P-S)),e===u.LEFT?A=2*-P:z=2*-P):e===u.BELOW?(S=a.bottom+P,S=Math.max(S,l.top+P),S=Math.min(S,l.bottom+P),S=Math.max(S,P),S=Math.min(S,H-N)):(S=a.top-P-N,S=Math.max(S,l.top-N-P),S=Math.min(S,l.bottom-N-P),S=Math.max(S,0),S=Math.min(S,H-N-P)),j){const t=window.getComputedStyle(y.targetEl);q=Math.max(0,s.top),Y=Math.max(0,_-s.right),J=Math.max(0,H-s.bottom),X=Math.max(0,s.left),Q=Math.max(0,k(t.borderTopLeftRadius)+r),Z=Math.max(0,k(t.borderTopRightRadius)+r),tt=Math.max(0,k(t.borderBottomRightRadius)+r),et=Math.max(0,k(t.borderBottomLeftRadius)+r),at=Math.max(0,s.right),lt=Math.max(0,s.top),it=Math.max(0,s.right),nt=Math.max(0,s.bottom),ct=Math.max(0,s.left),ut=Math.max(0,s.bottom),pt=Math.max(0,s.left),mt=Math.max(0,s.top)}}else e=i||u.BELOW,e!==u.BELOW&&e!==u.ABOVE||(z=I/2-P,e===u.BELOW?F=2*-P:W=2*-P),e!==u.LEFT&&e!==u.RIGHT||(F=N/2-P,e===u.LEFT?A=2*-P:z=2*-P);t.tooltipPlacement=e,D+=` userflowjs-bubble__tooltip-notch--${e.toLowerCase()}`,U="",j&&(K+=" userflowjs-tooltip-backdrop--visible",ot+=" userflowjs-tooltip-block--visible",rt+=" userflowjs-tooltip-block--visible",st+=" userflowjs-tooltip-block--visible",dt+=" userflowjs-tooltip-block--visible");break}}d.style.transition="";let ft=C,ht=S;if(e&&(d.style.opacity="0",T===r.TOOLTIP)){const e=24;switch(t.tooltipPlacement){case u.BELOW:S+=e;break;case u.ABOVE:S-=e;break;case u.RIGHT:C+=e;break;case u.LEFT:C-=e}}"relative"!==o&&G(d,C,S);if(p.className=D,p.style.visibility=U,V(p,"top",F),V(p,"right",A),V(p,"bottom",W),V(p,"left",z),m.className=K,V(m,"top",q),V(m,"right",Y),V(m,"bottom",J),V(m,"left",X),V(m,"border-top-left-radius",Q),V(m,"border-top-right-radius",Z),V(m,"border-bottom-right-radius",tt),V(m,"border-bottom-left-radius",et),f.className=ot,V(f,"width",at),V(f,"height",lt),h.className=rt,V(h,"left",it),V(h,"height",nt),b.className=st,V(b,"left",ct),V(b,"top",ut),g.className=dt,V(g,"width",pt),V(g,"top",mt),e){d.offsetWidth;const t="opacity 250ms linear";T===r.TOOLTIP?d.style.transition=`${t}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:d.style.transition=t,d.style.opacity="1","relative"!==o&&G(d,ft,ht)}}({layoutState:B,animateIn:t,position:ct,absoluteWidth:x,absoluteHeight:I,desiredTooltipPlacement:ut,root:o,bubble:a,tooltipNotch:m,tooltipBackdrop:f,tooltipBlockTop:h,tooltipBlockRight:w,tooltipBlockBottom:y,tooltipBlockLeft:j,dir:gt})}if(P===r.TOOLTIP){const t=O&&O.targetEl;t&&B.stepKeyScrolledIntoView!==N&&B.targetScrolledIntoView!==t&&(B.stepKeyScrolledIntoView=N,B.targetScrolledIntoView=t,function(t){if(l.customScrollIntoView)return void l.customScrollIntoView(t);const{scrollPadding:e}=l;if(e&&g(t)===document.scrollingElement){const o=e.top||0,a=e.right||0,l=e.bottom||0,r=e.left||0;let i=0,n=0;const s=t.getBoundingClientRect(),c=M(),u=v();if(s.top<o?i=s.top-o:s.bottom>u-l&&(i=s.bottom-u+l),s.left<r?n=s.left-r:s.right>c-a&&(n=s.right-c+a),0!=i||0!=n)return void window.scrollBy({top:i,left:n,behavior:"smooth"})}try{t.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),t.scrollIntoView()}}(t))}else B.stepKeyScrolledIntoView=void 0,B.targetScrolledIntoView=null;Vt(C),Wt(P)}),[St,vt,N,_,H,b,ct,x,I,D,ut,A,dt,et,Vt,gt]),$t=t.useRef(Gt);$t.current=Gt;const Kt=t.useRef(!1);t.useEffect((()=>{const t=()=>{Kt.current=!0};return window.addEventListener("pagehide",t),()=>window.removeEventListener("pagehide",t)}),[]);const qt=()=>{window.clearTimeout(Ft.current.tooltipTargetMissingTimeout),Ft.current.tooltipTargetMissingTimeout=void 0};t.useEffect((()=>qt),[]);const Yt=t.useCallback((()=>{const t=Ft.current;if(t.tooltipTargetParams=null,D||(t.tooltipPlacement=null),_!==r.TOOLTIP)return qt(),void(t.tooltipTargetMissing=!1);if(!D&&!t.tooltipTargetMissingTimeout){t.tooltipTargetMissing=!1;const e=!S||h(S)||S.type!==n.AUTO||S.autoData?1e3*parseFloat(b.tooltipMissingToleranceSeconds):1;t.tooltipTargetMissingTimeout=window.setTimeout((()=>{if(!Kt.current){if(S&&!h(S)){let t=S.autoData;if(S.autoData)try{t=JSON.parse(S.autoData)}catch(e){}console.warn("Userflow.js: Tooltip target not found on page.\n",{type:S.type,autoData:t,excludeText:S.excludeText,precision:S.precision,text:S.text,css:S.css})}qt(),t.tooltipTargetMissing=!0,$t.current()}}),e)}$t.current()}),[_,D,S,b.tooltipMissingToleranceSeconds]),Jt=t.useCallback((t=>{const e=Ft.current;qt(),e.tooltipTargetParams&&e.tooltipTargetParams.targetEl!==t.targetEl&&(e.tooltipPlacement=null),e.tooltipTargetParams=t,Gt({forceUpdatePosition:!0})}),[Gt]);U({selector:_===r.TOOLTIP&&S||null,targetMoved:Jt,targetLost:Yt,onTargetClick:J});const Xt=t.useCallback((()=>Gt({forceAppearanceLayout:!0})),[Gt]);e(Xt),t.useEffect((()=>{if(!vt||et||"function"!=typeof y)return;let t;const e=new y((()=>{t||(t=window.requestAnimationFrame((()=>{t=void 0,$t.current()})))}));return e.observe(vt,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect(),t&&window.cancelAnimationFrame(t)}}),[vt,et]),t.useLayoutEffect((()=>{$t.current()})),t.useLayoutEffect((()=>{"absolute"===ct&&Gt({forceAppearanceLayout:!0})}),[ct,x,I]);const Qt=t=>{t.preventDefault(),t.stopPropagation()};return function(e,o){const a=window.Intercom;t.useEffect((()=>{if(o&&e.autoHideIntercom&&"function"==typeof a&&!l.autoHide3pDisabled){try{a("update",{hide_default_launcher:!0})}catch(t){console.warn("Userflow.js: Error when hiding Intercom launcher",t)}return()=>{if(!l.autoHide3pDisabled)try{a("update",{hide_default_launcher:!1})}catch(t){console.warn("Userflow.js: Error when unhiding Intercom launcher",t)}}}}),[a,e.autoHideIntercom,o]);const r=window.$crisp;t.useEffect((()=>{if(o&&e.autoHideCrisp&&r&&!l.autoHide3pDisabled){try{r.push(["do","chat:hide"])}catch(t){console.warn("Userflow.js: Error when hiding Crisp Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{r.push(["do","chat:show"])}catch(t){console.warn("Userflow.js: Error when unhiding Crisp Chat",t)}}}}),[r,e.autoHideCrisp,o]);const i=window.HubSpotConversations;t.useEffect((()=>{if(o&&e.autoHideHubspot&&i&&!l.autoHide3pDisabled){try{i.widget.remove()}catch(t){console.warn("Userflow.js: Error when hiding HubSpot Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{i.widget.load()}catch(t){console.warn("Userflow.js: Error when unhiding HubSpot Chat",t)}}}}),[i,e.autoHideHubspot,o]);const n=window.drift;t.useEffect((()=>{if(o&&e.autoHideDrift&&n&&!l.autoHide3pDisabled){try{n.api.widget.hide()}catch(t){console.warn("Userflow.js: Error when hiding Drift Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{n.api.widget.show()}catch(t){console.warn("Userflow.js: Error when unhiding Drift Chat",t)}}}}),[n,e.autoHideDrift,o])}(b,!!lt&&At===r.BUBBLE),t.createElement("div",{ref:wt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:R(b),dir:gt},t.createElement("div",{className:"userflowjs-bubble",ref:Tt,style:{zIndex:ft}},t.createElement("div",{className:m({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(b.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!at,"userflowjs-bubble-outline--minimized":Dt})},t.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...it},t.createElement(o,{className:"userflowjs-bubble__frame",elRef:Et,stylesheet:p,theme:b,onStylesheetsLoad:_t,noIframe:et},t.createElement("div",{className:"userflowjs-bubble-frame-root",ref:t=>{rt&&rt(t),Mt(t)},style:C?{backgroundImage:`url("${encodeURI(C)}")`}:void 0},st,f.flowBranding&&t.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},t.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},t.createElement(pt,{company:f},t.createElement(a,null),t.createElement("div",null,"Made with Userflow"))))))),t.createElement("div",{ref:Lt,className:"userflowjs-bubble__avatar-notch"})),t.createElement(o,{className:m({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!at,"userflowjs-bubble__avatar--speaking":!!tt}),elRef:yt,stylesheet:P,theme:b,onStylesheetsLoad:Ct,noIframe:et,ariaHidden:!0},t.createElement("div",{className:m({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!at}),onClick:at?()=>Ut((t=>!t)):void 0},t.createElement(W,{theme:b}))),t.createElement("div",{ref:kt,className:"userflowjs-bubble__tooltip-notch"})),t.createElement("div",{ref:jt,className:"userflowjs-tooltip-backdrop",onMouseDown:Qt,style:{zIndex:ht,pointerEvents:K?void 0:"none"}}),t.createElement("div",{ref:Rt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:Ot,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:Pt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ht}}),t.createElement("div",{ref:xt,className:"userflowjs-modal-backdrop",onMouseDown:Qt,onClick:Q,style:{zIndex:ht}}),nt&&nt({visible:zt,bubbleFrame:Et.current}))},W=({theme:e})=>{const o="https://js.userflow.com/cartoon-avatars-no-bg/";let a;return a=e.avatarType===i.ASSET&&e.avatarAsset?e.avatarAsset.assetUrl:e.avatarType===i.CARTOON&&e.avatarName?o+e.avatarName+".svg?3":e.avatarType===i.URL&&e.avatarUrl?e.avatarUrl:o+"none.svg",t.createElement("img",{src:a,alt:""})},z=({company:e,children:o})=>t.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+e.slug,target:"_blank",rel:"noopener noreferrer"},o);function V(t,e,o){null==o?t.style.removeProperty(e):t.style.setProperty(e,"number"==typeof o?o+"px":o,"important")}function G(t,e,o){e=Math.round(e),o=Math.round(o),t.style.transform=`translate3d(${e}px, ${o}px, 0px)`}function $(t){const e=parseInt(t,10);return isNaN(e)?0:e}export{A as F,H as r,U as u};
@@ -1 +1 @@
1
- import{h as e,C as t,i as r,j as s,c as n,k as o,l as c,E as a,m as l,n as i,p as u,S as d,_ as m}from"./userflow.js";import{r as f}from"./vendor.react.js";import{u as w,i as h}from"./client-context.js";import{u as b,w as E,C as k}from"./Icons.js";import{b as p,h as v,s as g,B as C,R as j,a as S,n as y,f as N}from"./BubbleToolbar.js";import{M as _,g as I,a as x,b as T}from"./flow-condition-types.js";import{u as R,a as A,g as B}from"./stylesheets.js";import{u as L,F as M,S as H}from"./logomark.js";import{o as P}from"./vendor.obj-str.js";import{D as W}from"./DynamicIcon.js";import{f as F,C as O}from"./ChecklistUI.js";import{f as $,a as U,b as D,c as z,d as q,e as K,g as V,h as G,i as Q,j as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as J}from"./vendor.fortawesome.react-fontawesome.js";import{u as X}from"./vendor.react-i18next.js";function Y(t){return t!==e.ACTION&&t!==e.ASSISTANT&&t!==e.CONTACT&&t!==e.FLOWS&&t!==e.KNOWLEDGE_BASE&&t!==e.SUBPAGE}const ee=window,te={[t.CRISP]:{configure:({onShow:e,onHide:t})=>{!function(){if(re)return;re=!0,ee.$crisp||(ee.$crisp=[]);ee.$crisp.push(["do","chat:hide"])}();let r=!1,s=!1;const n=()=>{r||s?(ee.$crisp.push(["do","chat:show"]),e()):(ee.$crisp.push(["do","chat:hide"]),t())},o=()=>{r=!0,n()};ee.$crisp.push(["on","chat:opened",o]);const c=()=>{r=!1,n()};ee.$crisp.push(["on","chat:closed",c]);const a=()=>{s=!0,n()};ee.$crisp.push(["on","message:received",a]);const l=window.setInterval((()=>{const e=(()=>{const e=document.getElementById("crisp-chatbox");if(!e||"block"!==window.getComputedStyle(e).display)return!1;const t=e.querySelector('[data-id="new_messages"]');return!(!t||"block"!==window.getComputedStyle(t).display)})();e!==s&&(s=e,n())}),200);return()=>{ee.$crisp.push(["off","chat:opened",o]),ee.$crisp.push(["off","chat:closed",c]),ee.$crisp.push(["off","message:received",a]),window.clearInterval(l)}},show:()=>{ee.$crisp.push(["do","chat:show"]),ee.$crisp.push(["do","chat:open"])},hide:()=>{ee.$crisp.push(["do","chat:hide"]),ee.$crisp.push(["do","chat:close"])}},[t.CUSTOM]:{configure:()=>()=>{},show:({block:e})=>{try{new Function('"use strict";\n'+e.chatCode)()}catch(t){console.error(`Userflow.js: Showing custom chat provider failed. Code: ${e.chatCode}`,t)}},hide:()=>{}},[t.FRESHCHAT]:{configure:({onShow:e,onHide:t})=>{if(!ee.fcWidget)throw new Error("Freshchat is not installed");let r=!1,s=!1;const n=()=>{r||s?e():t()},o=()=>{r=!0,n()};ee.fcWidget.on("widget:opened",o);const c=()=>{r=!1,n()};ee.fcWidget.on("widget:closed",c);const a=()=>{const e=!!document.querySelector("#fc_frame.h-open-notify");e!==s&&(s=e,n())},l=window.setInterval(a,200);return ee.fcWidget.on("unreadCount:notify",a),()=>{ee.fcWidget.off("widget:opened",o),ee.fcWidget.off("widget:closed",c),ee.fcWidget.off("unreadCount:notify",a),window.clearInterval(l)}},show:()=>{ee.fcWidget.open()},hide:()=>{ee.fcWidget.close()}},[t.HELPSCOUT]:{configure:({onShow:e,onHide:t})=>{if(!ee.Beacon)throw new Error("Help Scout is not installed");!function(){if(se)return;se=!0,oe()}();let r=!1,s=!1;const n=()=>{r||s?(ne(),e()):(oe(),t())},o=()=>{r=!0,n()};ee.Beacon("on","open",o),ee.Beacon("info")?.status.isOpened&&o();const c=()=>{r=!1,n()};ee.Beacon("on","close",c);const a=window.setInterval((()=>{const e=!!document.querySelector(".BeaconNotificationsFrame");e!==s&&(s=e,n())}),200);return()=>{ee.Beacon("off","open",o),ee.Beacon("off","close",c),window.clearInterval(a)}},show:()=>{ne(),ee.Beacon("open")},hide:()=>{oe(),ee.Beacon("close")}},[t.HUBSPOT]:{configure:({onShow:e,onHide:t})=>{const r=()=>{const r=document.getElementById("hubspot-messages-iframe-container");if(!ee.HubSpotConversations||!r)return;window.clearInterval(n),function(){if(ce)return;ce=!0,ae?le():ie()}();let o=!1,c=!1;const a=()=>{o||c?(le(),e()):(ie(),t())},l=()=>{const e=!!document.querySelector("#hubspot-messages-iframe-container .hs-shadow-container.active");e!==o&&(o=e,a())},i=new _(l);i.observe(r,{attributes:!0,subtree:!0,attributeFilter:["class"]}),l();const u=({unreadCount:e})=>{const t=e>0;t!==c&&(c=t,a())};ee.HubSpotConversations.on("unreadConversationCountChanged",u),s=()=>{i.disconnect(),ee.HubSpotConversations.off("unreadConversationCountChanged",u)}};let s=()=>{window.clearInterval(n)};const n=window.setInterval(r,100);return r(),()=>{s()}},show:()=>{le(),ee.HubSpotConversations.widget.open()},hide:()=>{ie(),ee.HubSpotConversations.widget.close()}},[t.INTERCOM]:{configure:({onShow:e,onHide:t})=>{if(!ee.Intercom)throw new Error("Intercom is not installed");return function(){if(ue)return;ue=!0,we();let e=!1,t=!1;const r=()=>{fe();for(const e of de)e()},s=()=>{we();for(const e of me)e()},n=()=>{e||t?r():s()};ee.Intercom("onShow",(()=>{e=!0,n()})),ee.Intercom("onHide",(()=>{e=!1,n()}));const o=()=>{const e=!!document.querySelector('iframe[name="intercom-borderless-frame"], iframe[name="intercom-notifications-frame"]');t!==e&&(t=e,n())};ee.Intercom("onUnreadCountChange",(()=>{o()})),window.setInterval(o,200)}(),de.add(e),me.add(t),()=>{de.delete(e),me.delete(t)}},show:()=>{fe(),ee.Intercom("show")},hide:()=>{we(),ee.Intercom("hide")}},[t.ZENDESK]:{configure:({onShow:e,onHide:t})=>{if(!ee.zE)throw new Error("Zendesk is not installed");!function(){if(he)return;he=!0,ee.zE("webWidget","hide"),ee.zE("webWidget","close"),ee.zE("webWidget:on","open",(()=>{for(const e of be)e()})),ee.zE("webWidget:on","close",(()=>{for(const e of Ee)e()})),ee.zE("webWidget:on","chat:unreadMessages",(e=>{for(const t of ke)t(e)}))}();let r=!1,s=!1;const n=()=>{r||s?(ee.zE("webWidget","show"),e()):(ee.zE("webWidget","hide"),t())},o=()=>{r=!0,s=!1,n()};be.add(o);const c=()=>{r=!1,s=!1,n()};Ee.add(c);const a=e=>{const t=e>0;t!==s&&(s=t,n())};return ke.add(a),()=>{be.delete(o),Ee.delete(c),ke.delete(a)}},show:()=>{ee.zE("webWidget","show"),ee.zE("webWidget","open")},hide:()=>{ee.zE("webWidget","hide"),ee.zE("webWidget","close")}},[t.ZENDESK_MESSENGER]:{configure:({onShow:e,onHide:t})=>{if(!ee.zE)throw new Error("Zendesk is not installed");let r=!1;const s=window.setInterval((()=>{const s=(()=>{const e=document.querySelector('iframe[title="Messaging window"]');return!!e?.parentElement&&"0px"!==window.getComputedStyle(e.parentElement).height})();s!==r&&(r=s,r?e():t())}),200);return()=>{window.clearInterval(s)}},show:()=>{ee.zE("messenger","open")},hide:()=>{ee.zE("messenger","close")}}};let re=!1;let se=!1;function ne(){ee.Beacon("config",{display:{style:"icon"}})}function oe(){ee.Beacon("config",{display:{style:"manual"}})}let ce=!1,ae=!1;function le(){ae=!0;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","visible","important")}function ie(){ae=!1;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","hidden","important")}let ue=!1,de=new Set,me=new Set;function fe(){ee.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function we(){ee.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let he=!1,be=new Set,Ee=new Set,ke=new Set;const pe=e=>f.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},e),f.createElement("path",{fill:"currentColor",d:"M24.049 79.74h36.003c8.185 0 15.985-6.621 17.43-14.814l6.091-34.556h3.997c8.149 0 13.645 6.63 12.2 14.815l-7.051 40C91.274 93.363 83.474 100 75.288 100h-40c-8.185 0-13.645-6.667-12.2-14.815l.96-5.444Z"}),f.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12.437 69.63h40c8.148 0 15.978-6.637 17.422-14.815l7.052-40C78.355 6.63 72.896 0 64.711 0h-40C16.533 0 8.726 6.63 7.281 14.815l-7.052 40C-1.215 62.963 4.252 69.63 12.437 69.63Zm33.628-33.798c3.756-2.064 8.725-4.795 9.907-11.844C57.385 15.458 50.065 8.983 42.168 9c-7.452 0-12.771 3.195-17.508 8.892-.858 1.034-.884 2.45-.053 3.212l3.472 3.196c.847.767 2.25.589 3.176-.406 2.842-3.068 4.869-4.83 8.51-4.83 2.864 0 6.077 1.934 5.59 4.847-.37 2.223-2.292 3.334-5.4 5.001l-.28.151c-3.582 1.92-8.134 4.362-9.124 10.247l-.16.956c-.055.28-.05.571.014.85.065.278.188.538.362.76.173.222.391.4.639.522.247.121.518.183.79.18h6.744a2.709 2.709 0 0 0 1.712-.688c.481-.426.81-1.01.934-1.657l.095-.556c.266-1.582 2.101-2.59 4.384-3.845ZM32.837 59c3.552 0 6.955-3.034 7.58-6.769.63-3.729-1.742-6.763-5.293-6.763-3.552 0-6.934 3.028-7.58 6.763C26.9 55.966 29.286 59 32.837 59Z"})),ve=({center:e,fadeIn:t})=>{const r=12;return f.createElement("div",{className:P({"userflowjs-spinner":!0,"userflowjs-spinner--center":!!e,"userflowjs-spinner--fade-in":!!t})},f.createElement("svg",{viewBox:"0 0 24 24",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},f.createElement("circle",{className:"userflowjs-spinner__bg",fill:"none",cx:r,cy:r,r:10,style:{strokeWidth:"4px"}}),f.createElement("circle",{className:"userflowjs-spinner__fill",fill:"none",cx:r,cy:r,r:10,transform:"translate(12, 12) rotate(-90) translate(-12, -12)",style:{strokeWidth:"4px",strokeDasharray:20*Math.PI*.25+"px, 1000"}})))};function ge(e){const t=w(),[r,s]=f.useState(!0),[n,o]=f.useState(!1),[c,a]=f.useState(null),[l,i]=f.useState(null),[u,d]=f.useState(null),m=f.useRef(0),h=f.useRef(null),b=f.useRef((()=>{}));return f.useEffect((()=>{const r=JSON.stringify(e);if(r===h.current)return;h.current=r;const n=++m.current;let c,l;let u=!1;b.current=async(e,r)=>{if(!u){u=!0,o(!0);try{const s=e(c,l);l=s;const i=await t.send(s,{handlesRejection:!0});if(n!==m.current)return;c=r(c,i),a(c),d(null)}catch(s){if(n!==m.current)return;d(s)}finally{u=!1,o(!1)}}},(async()=>{s(!0);try{l=e;const r=await t.send(e,{handlesRejection:!0});if(n!==m.current)return;c=r,a(c),i(e),d(null)}catch(r){if(n!==m.current)return;d(r)}finally{s(!1)}})()}),[t,e]),{loading:r,loadingMore:n,data:c,messageForData:l,error:u,loadMore:b.current}}function Ce(e,t){const[r,s]=f.useState(e),n=f.useRef(void 0),o=f.useCallback((e=>{window.clearTimeout(n.current),s(e),t(e)}),[t]),c=f.useCallback((e=>{window.clearTimeout(n.current),s(e),n.current=window.setTimeout((()=>{t(e)}),200)}),[t]);return f.useEffect((()=>()=>{window.clearTimeout(n.current)}),[]),[r,c,o]}const je=({textareaRef:e,value:t,onChange:r,onBlur:s,onKeyDown:n,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:i,mirrorClassName:u,textareaClassName:d,children:m})=>{let w=t||c||"";return(""===w||w.endsWith("\n"))&&(w+=" "),i=i||"growing-textarea",u=u||i+"__mirror",f.createElement("div",{className:i},f.createElement("div",{className:u+" "+(d||"")},w),f.createElement("textarea",{ref:e,value:t,onChange:e=>r&&r(e.target.value),onBlur:s,onKeyDown:n,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:d}),m)},Se=({textareaRef:e,value:t,onChange:r,onSubmit:s,placeholder:n,readOnly:o})=>{const c=()=>{s&&s()};return f.createElement("div",{className:"userflowjs-assistant-chat-input"},f.createElement(je,{textareaRef:e,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:n,readOnly:o,value:t||"",onChange:r,onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||(e.preventDefault(),c())}}),f.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>c()},f.createElement(J,{icon:$})))};const ye=async()=>(await m((()=>import("./ResourceCenterAssistantChat.js")),[new URL("ResourceCenterAssistantChat.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.dompurify.js",import.meta.url).toString(),new URL("vendor.marked.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()])).ResourceCenterAssistantChat,Ne=({session:l,isOpen:i,flowSession:u,checklistSession:d})=>{const m=w(),{t:v}=X(),{company:g}=l.flow,{version:C}=l,j=C.resourceCenter,S=R(C.theme),y=l.locale?l.locale.standardLocaleId:l.version.theme.languageId;f.useEffect((()=>{h.changeLanguage(y)}),[y]);const{loaded:T}=A(window,N,S),[O,$]=f.useState(!1),K=T&&O,[V,G]=f.useState(I()),[Q,Z]=f.useState(x()),J=f.useCallback((()=>{G(I()),Z(x())}),[]);L(J);const{zIndex:ee,bringToFront:re}=b(),se=f.useRef(null),[ne,oe]=f.useState(null),[ce,ae]=f.useState(null),[le,ie]=f.useState(null),ue=f.useRef(null),[de,me]=f.useState(null),[fe,we]=f.useState(null),[he,be]=f.useState(null),[Ee,ke]=f.useState(0),[ve,ge]=f.useState(0),Ce=f.useCallback((()=>{ce&&ke(ce.offsetWidth),ge((le?.offsetHeight||0)+(de?.offsetHeight||0)+(fe?.offsetHeight||0)+(he?.offsetHeight||0))}),[ce,le,de,fe,he]);f.useLayoutEffect((()=>{if(!ne||"function"!=typeof _)return;const e=new _((()=>{Ce()}));return e.observe(ne,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect()}}),[ne,Ce]),f.useLayoutEffect((()=>{Ce()}));const[je,Se]=f.useState(!1),ye=f.useRef(),Ne=f.useCallback((()=>{Se(!0),window.clearTimeout(ye.current),ye.current=window.setTimeout((()=>{Se(!1)}),S.resourceCenterTransitionDuration)}),[S.resourceCenterTransitionDuration]);f.useEffect((()=>()=>{window.clearTimeout(ye.current)}),[]);const xe=f.useCallback((()=>{re(),Ne(),m.openResourceCenter()}),[re,m,Ne]),Te=f.useCallback((()=>{Ne(),m.closeResourceCenter()}),[m,Ne]),[Me,He]=f.useState(!1);f.useEffect((()=>{if(Me){if(!("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0))if(i){const e='button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea';let t=de?.querySelector(".userflowjs-assistant-chat-input textarea")||de?.querySelector(e)||le?.querySelector(e);if(t){const e=t.closest&&t.closest(".userflowjs-resource-center-checklist")||null;e?F(e):t.focus({preventScroll:!0})}}else ce?.focus({preventScroll:!0});He(!1)}}),[Me,i,de,le,ce]),f.useEffect((()=>{const e=ne?.ownerDocument.defaultView;if(!i||!e)return;const t=e=>{"Escape"===e.key&&(Te(),He(!0))};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}),[i,ne,He,Te]);const[We,Ue]=f.useState((()=>function(e,t){if(!t)return null;const r=JSON.parse(t);let s;r.blockCvid&&(s=e.version.resourceCenter?.blocks.find((e=>e.cvid===r.blockCvid)));if(!s&&"search"!==r.kind)return null;return{kind:r.kind,block:s}}(l,r.getItem(`resourceCenterRoute:v1:${l.id}`)))),De=f.useCallback(((e,t)=>{Ue(e);const s=function(e){if(!e)return null;let t;"block"in e&&null!=e.block&&(t=e.block.cvid);return JSON.stringify({kind:e.kind,blockCvid:t})}(e);s?r.setItem(`resourceCenterRoute:v1:${l.id}`,s):r.removeItem(`resourceCenterRoute:v1:${l.id}`),0===t?.detail&&He(!0)}),[l.id]),ze=f.useMemo((()=>j.blocks.filter((t=>!(t.type===e.CHECKLIST&&!d)&&(!t.hiddenWhenFlowsActive||!t.hiddenWhenFlowsActive.some((e=>e===u?.flow.id||e===d?.flow.id)))))),[j,u,d]),qe=f.useMemo((()=>_e(ze)),[ze]),Ke=f.useMemo((()=>d&&j.blocks.some((t=>t.type===e.CHECKLIST))?s(d):0),[j,d]),Ve=f.useMemo((()=>j.blocks.find((t=>t.type===e.CONTACT&&t.chatEnabled&&t.chatProvider))),[j]),[Ge,Qe]=f.useState(!1),Ze=f.useCallback((()=>{m.closeResourceCenter(),Ve&&Ve.chatProvider!==t.CUSTOM&&Qe(!0)}),[m,Ve]),Je=f.useCallback((()=>{Qe(!1)}),[]),Xe=f.useCallback((()=>{if(Ve)try{te[Ve.chatProvider].hide({block:Ve}),Je()}catch(e){console.error(`Userflow.js: Error when hiding ${Ve.chatProvider}:`,e)}}),[Ve,Je]);f.useEffect((()=>{if(!Ve)return;n.autoHide3pDisabled=!0;const e=te[Ve.chatProvider];try{const t=e.configure({block:Ve,onShow:Ze,onHide:Je});return()=>{t()}}catch(t){return void console.error(`Userflow.js: Error when configuring ${Ve.chatProvider}:`,t)}}),[Ve,Ze,Je]),f.useEffect((()=>{i&&Xe()}),[Xe,i]);const Ye=!!We&&("search"===We.kind||"flows"===We.kind||"knowledgeBase"===We.kind),et="assistant"===We?.kind,tt=Math.min(et?S.resourceCenterFullWidth:S.resourceCenterWidth,V-2*S.resourceCenterPaddingX),rt={zIndex:null!=S.resourceCenterZIndex?S.resourceCenterZIndex:i?ee:E(k),width:(i?tt:Ee)+"px",height:i?Math.min(Ye?540:et?720:ve,Q-2*S.resourceCenterPaddingY)+"px":void 0,position:K?void 0:"absolute",visibility:K&&!Ge?void 0:"hidden"},st=S.resourceCenterDisplayChecklistProgress&&d&&Ke>0?f.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},Ke,f.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let nt="",ot="";return S.resourceCenterLauncherTextMode===o.CHECKLIST_OVERRIDE&&d&&Ke>0?nt=d.version.checklist?.launcherText||"Get Started":S.resourceCenterLauncherTextMode!==o.NONE&&(ot=j.buttonText),f.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center userflowjs-theme-root",style:B(S),dir:h.dir()},f.createElement(M,{elRef:se,className:P({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--fixed":!0,[`userflowjs-resource-center-frame--placement-${S.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame--animating":je,"userflowjs-resource-center-frame--open":i,"userflowjs-resource-center-frame--closed":!i}),style:{...rt},stylesheet:p,theme:S,onStylesheetsLoad:$},K&&f.createElement(f.Fragment,null,f.createElement("div",{ref:oe,className:P({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${S.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":je,"userflowjs-resource-center-frame-root--open":i,"userflowjs-resource-center-frame-root--closed":!i}),role:i?"dialog":void 0,"aria-label":i?j.headerText:void 0},f.createElement("div",{className:"userflowjs-resource-center-launcher-container"},f.createElement("button",{ref:ae,className:"userflowjs-resource-center-launcher-button",onClick:()=>{xe(),He(!0)},"aria-label":`Open ${j.headerText}`},st,nt&&f.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},nt),(st||nt)&&f.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),ot&&f.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ot),f.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},S.resourceCenterLauncherIconType===c.PLAINTEXT?"?":f.createElement(pe,null)))),f.createElement("div",{ref:ue,className:"userflowjs-resource-center-body",style:{width:tt+"px"}},f.createElement("div",{ref:me,className:P({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":"assistant"!==We?.kind,"userflowjs-resource-center-body-content--same-background":S.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":g.resourceCenterBranding})},i&&f.createElement(f.Fragment,null,We?"search"===We.kind?f.createElement(Re,{session:l,navigate:De}):"email"===We.kind?f.createElement(Ae,{block:We.block,session:l}):"phone"===We.kind?f.createElement(Be,{block:We.block,session:l}):"flows"===We.kind?f.createElement(Le,{block:We.block,initialQ:We.initialQ,session:l,navigate:De}):"knowledgeBase"===We.kind?f.createElement(Pe,{block:We.block,initialQ:We.initialQ,session:l,bodyRef:ue}):"subpage"===We.kind?f.createElement(Fe,{block:We.block,session:l}):"assistant"===We.kind?f.createElement(Oe,{block:We.block,initialUserContent:We.initialUserContent,session:l,navigate:De}):null:f.createElement(f.Fragment,null,ze.map(((e,t)=>{const r=Ie[e.type],s=ze[t+1];return r?f.createElement(f.Fragment,{key:e.id},f.createElement(r.View,{session:l,flowSession:u,checklistSession:d,block:e,navigate:De,onChatShow:Ze}),s&&(n=e.type,o=s.type,Y(n)||Y(o))&&f.createElement("div",{className:"userflowjs-resource-center-divider"})):null;var n,o})))))),g.resourceCenterBranding&&f.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},f.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:we},f.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+g.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},f.createElement(H,null),f.createElement("div",null,"Made with Userflow")))),l.draftMode&&f.createElement("div",{className:"userflowjs-resource-center-preview"},f.createElement("div",{ref:be,className:"userflowjs-resource-center-preview-content"},f.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),f.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{m.endFlow(l,{endReason:a.USER_CLOSED})}},f.createElement(W,{icon:U})))),f.createElement("div",{className:"userflowjs-resource-center-header",style:{width:tt+"px"}},f.createElement("div",{ref:ie,className:"userflowjs-resource-center-header-content"},null==We?f.createElement("div",{className:"userflowjs-resource-center-header-text"},j.headerText):f.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:e=>De(null,e)},f.createElement("div",{className:"userflowjs-rtl-mirrored"},f.createElement(W,{icon:D})),f.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},v("resource_center.back"))),f.createElement("div",{className:"flex-1"}),qe.length>0&&f.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let e={kind:"search"};if(1===qe.length){const t=qe[0],r=Ie[t.type];r.routeTo&&(e=r.routeTo({block:t}))}"search"===We?.kind?De(null):($e(m,l,null,"Search icon"),De(e))},"aria-label":"Search"},f.createElement(W,{icon:z})),f.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:e=>{Te(),0===e.detail&&He(!0)},"aria-label":`Close ${j.headerText}`},f.createElement(W,{icon:q}))))))))};function _e(e){return e.filter((e=>{const t=Ie[e.type];return t.isSearchable?t.isSearchable(e):!!t.search}))}const Ie={[e.ACTION]:{View:e=>{const{block:t,session:r,flowSession:s,checklistSession:n}=e,o=w(),[c,a]=f.useState(!1),i=s?.id,u=n?.id;return f.useEffect((()=>{a(!1)}),[i,u]),f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c?void 0:()=>{$e(o,r,t);const e=t.actions.find((e=>e.type===l.START_FLOW));if(e){e.otherFlow?.id!==n?.flow.id&&a(!0)}else o.closeResourceCenter();v(o,r,t.actions)},disabled:c},f.createElement(xe,{...e}),f.createElement(Te,{...e}),c&&f.createElement(ve,null))}},[e.ASSISTANT]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w(),[o,c]=f.useState("");return t.assistantAppearance===i.INPUT?f.createElement("div",{className:"userflowjs-resource-center-assistant-block"},f.createElement(Se,{value:o,onChange:c,placeholder:g(t.name,{lookupAttribute:T(r.data)}),onSubmit:()=>{$e(n,r,t),s({kind:"assistant",block:t,initialUserContent:o})}})):f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{$e(n,r,t),s({kind:"assistant",block:t,initialUserContent:""})}},f.createElement(xe,{...e}),f.createElement(Te,{...e}))}},[e.CHECKLIST]:{View:({checklistSession:e})=>f.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},f.createElement(O,{session:e}),f.createElement(C,{draftMode:!!e.draftMode&&"CHECKLIST PREVIEW"}))},[e.CONTACT]:{View:e=>{const{block:t,session:r,navigate:s,onChatShow:n}=e,o=w(),c=[];return t.emailEnabled&&c.push({icon:G,label:"Email",isRoute:!0,onClick:e=>{$e(o,r,t,"Email"),s({kind:"email",block:t},e)}}),t.phoneEnabled&&c.push({icon:Q,label:"Phone",isRoute:!0,onClick:e=>{$e(o,r,t,"Phone"),s({kind:"phone",block:t},e)}}),t.chatEnabled&&c.push({icon:Z,label:"Live-chat",isRoute:!1,onClick:()=>{if($e(o,r,t,"Chat"),t.chatProvider){const r=te[t.chatProvider];try{r.show({block:t})}catch(e){console.error(`Userflow.js: Error when showing ${t.chatProvider}:`,e)}n()}else r.draftMode&&window.alert("You have not selected a chat provider. Go to the resource center builder in Userflow. Click the Contact block. Pick a chat provider in the side panel.")}}),f.createElement("div",{className:P({"userflowjs-resource-center-block":!0,"userflowjs-resource-center-block--clickable":1===c.length}),onClick:1===c.length?c[0].onClick:void 0},1===c.length&&f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:c[0].icon})),f.createElement(Te,{...e}),c.length>1&&c.map((({icon:e,label:t,onClick:r},s)=>f.createElement("button",{key:s,className:"userflowjs-resource-center-icon-button",onClick:r,"aria-label":t},f.createElement(W,{icon:e})))),1===c.length&&c[0].isRoute&&f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))}},[e.FLOWS]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w();return f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{$e(n,r,t),s({kind:"flows",block:t},e)}},f.createElement(xe,{...e}),f.createElement(Te,{...e}),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))},routeTo:({block:e,initialQ:t})=>({kind:"flows",block:e,initialQ:t}),isSearchable:e=>!!e.searchEnabled,search:async({client:e,session:t,block:r,q:s})=>{const{flows:n}=await e.send({kind:"ListResourceCenterBlockFlows",sessionId:t.id,blockCvid:r.cvid},{handlesRejection:!0}),o=Me(n,s),c=o.slice(0,5);return{block:r,truncated:c.length===o.length,results:c.map((e=>({kind:"flow",flow:e})))}}},[e.KNOWLEDGE_BASE]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w();return f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{$e(n,r,t),s({kind:"knowledgeBase",block:t},e)}},f.createElement(xe,{...e}),f.createElement(Te,{...e}),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))},routeTo:({block:e,initialQ:t})=>({kind:"knowledgeBase",block:e,initialQ:t}),search:async({client:e,session:t,block:r,q:s})=>{const{truncated:n,articles:o}=await e.send({kind:"SearchKnowledgeBase",sessionId:t.id,blockCvid:r.cvid,q:s,offset:0,limit:5},{handlesRejection:!0});return{block:r,truncated:n,results:o.map((e=>({kind:"article",article:e})))}}},[e.MESSAGE]:{View:({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-block"},f.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},f.createElement(j,{doc:e.content,lookupAttribute:T(t.data)})))},[e.SUBPAGE]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w();return f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{$e(n,r,t),s({kind:"subpage",block:t},e)}},f.createElement(xe,{...e}),f.createElement(Te,{...e}),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))}}},xe=({block:e})=>e.icon?f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:e.icon,size:16})):null,Te=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-block-text"},f.createElement(S,{doc:e.name,lookupAttribute:T(t.data)}));const Re=({session:e,navigate:t})=>{const r=w(),s=e.version.resourceCenter.blocks,n=_e(s),{t:o}=X(),c=f.useRef(null),[a,l]=f.useState(""),[i,u]=Ce(a,l),[d,m]=f.useState(null);return f.useEffect((()=>{if(""===a.trim())return void m(null);let t=!1;return(async()=>{m(null);const n=await Promise.all(s.map((async t=>{const{search:s}=Ie[t.type];if(!s)return null;try{return await s({client:r,session:e,block:t,q:a})}catch(n){return console.error(`Userflow.js: Global search failed for ${t.type} block=`,t,"error=",n),null}})));t||m(n.filter((e=>null!=e&&e.results.length>0)))})(),()=>{t=!0}}),[r,e,s,a]),f.useEffect((()=>{c.current?.focus({preventScroll:!0})}),[]),f.createElement(f.Fragment,null,f.createElement("div",{className:"userflowjs-resource-center-list-route-search"},f.createElement("input",{ref:c,className:"userflowjs-text-input",type:"text",value:i,onChange:e=>u(e.target.value),placeholder:o("resource_center.search_placeholder")})),""===a.trim()?f.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},o("resource_center.search_in")," ",n.map(((t,r)=>f.createElement(f.Fragment,{key:t.cvid},r>0&&(r===n.length-1?` ${o("and")} `:", "),f.createElement("b",null,f.createElement(S,{doc:t.name,lookupAttribute:T(e.data)}))))),"."):d?0===d.length?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},o("resource_center.no_results_found")):d.map((({block:s,truncated:n,results:c},l)=>{const i=Ie[s.type],u=i.routeTo&&i.routeTo({block:s,initialQ:a});return f.createElement(f.Fragment,{key:s.cvid},l>0&&f.createElement("div",{className:"userflowjs-resource-center-divider"}),f.createElement("div",{className:"userflowjs-resource-center-label"},f.createElement(S,{doc:s.name,lookupAttribute:T(e.data)})),c.map(((r,n)=>"flow"===r.kind?f.createElement(He,{key:r.flow.id,block:s,session:e,flow:r.flow,navigate:t}):"article"===r.kind?f.createElement(We,{key:n,block:s,session:e,article:r.article}):null)),!n&&u&&f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:n=>{$e(r,e,s),t(u,n)}},f.createElement("div",{className:"userflowjs-resource-center-block-text"},o("more"),":"," ",f.createElement(S,{doc:s.name,lookupAttribute:T(e.data)})),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K}))))})):f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,null)))},Ae=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},f.createElement(j,{doc:e.emailContent,lookupAttribute:T(t.data)})),Be=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},f.createElement(j,{doc:e.phoneContent,lookupAttribute:T(t.data)})),Le=({block:e,initialQ:t,session:r,navigate:s})=>{const{t:n}=X(),o=f.useRef(null),[c,a]=f.useState(t||""),[l,i]=Ce(c,a),{data:u,error:d}=ge({kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:e.cvid}),m=u?.flows,w=f.useMemo((()=>m?Me(m,c):null),[m,c]);return f.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]),f.createElement(f.Fragment,null,f.createElement("div",{className:"userflowjs-resource-center-list-route-header"},f.createElement("div",{className:"userflowjs-resource-center-list-route-title"},f.createElement(S,{doc:e.name,lookupAttribute:T(r.data)}))),e.searchEnabled&&f.createElement("div",{className:"userflowjs-resource-center-list-route-search"},f.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:n("resource_center.search_placeholder")})),d?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},n("resource_center.generic_error")):w?0===w.length?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},n("resource_center.no_results_found")):w.map((t=>f.createElement(He,{key:t.id,block:e,session:r,flow:t,navigate:s}))):f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,{fadeIn:!0})))};function Me(e,t){const r=t.toLowerCase().trim();return""===r?e:e.filter((e=>e.name.toLowerCase().includes(r)))}const He=({block:e,session:t,flow:r,navigate:s})=>{const n=w(),[o,c]=f.useState(!1);return f.useEffect((()=>{if(!o||r.type!==u.CHECKLIST)return;const e=()=>{n.checklistSession?.flow.id===r.id&&(t(),s(null))},t=()=>{n.off("checklistChanged",e)};return n.on("checklistChanged",e),t}),[n,o,r.type,r.id,s]),f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if($e(n,t,e,r.name),n.checklistSession?.flow.id===r.id)return void s(null);n.startFlow({flowId:r.id,startReason:d.RESOURCE_CENTER,replaceCurrent:!0}),c(!0);const o=g(r.url,{lookupAttribute:T(t.data)});o&&y(o)},disabled:o},f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:r.type===u.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),f.createElement("div",{className:"userflowjs-resource-center-block-text"},r.name),o&&f.createElement(ve,null))},Pe=({block:e,initialQ:t,session:r,bodyRef:s})=>{const{t:n}=X(),o=f.useRef(null),[c,a]=f.useState(t||""),[l,i]=Ce(c,a),{loading:u,loadingMore:d,data:m,messageForData:w,error:h,loadMore:b}=ge({kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:e.cvid,q:c,offset:0}),E=m?.truncated,k=f.useCallback((()=>{b(((e,t)=>({...t,offset:e.articles.length})),((e,t)=>({...t,articles:[...e.articles,...t.articles]})))}),[b]);f.useEffect((()=>{const e=s.current;if(!e||u||d||E)return;const t=()=>{e.scrollHeight-e.clientHeight-e.scrollTop>400||k()};return e.addEventListener("scroll",t),()=>{e.removeEventListener("scroll",t)}}),[s,u,d,E,k]),f.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]);let p=e.knowledgeBaseUrl||"";return p.match(/^https?:\/\//)||(p=`http://${p}`),f.createElement(f.Fragment,null,f.createElement("div",{className:"userflowjs-resource-center-list-route-header"},f.createElement("div",{className:"userflowjs-resource-center-list-route-title"},f.createElement(S,{doc:e.name,lookupAttribute:T(r.data)})),f.createElement("a",{className:"userflowjs-resource-center-icon-button",href:p,target:"_blank",rel:"noopener noreferrer"},f.createElement(W,{icon:V}))),f.createElement("div",{className:"userflowjs-resource-center-list-route-search"},f.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:n("resource_center.search_placeholder")})),h?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},"quota_exceeded"===h.code?"Sorry, this company has reached its max number of searches. Consider asking Userflow to be moved to a dedicated search engine for a higher quota.":n("resource_center.generic_error")):u||!m?f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,null)):0===m.articles.length?""===w?.q?null:f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},n("resource_center.no_results_found")):f.createElement(f.Fragment,null,""===w?.q&&f.createElement("div",{className:"userflowjs-resource-center-label"},n("resource_center.suggested_articles")),m.articles.map(((t,s)=>f.createElement(We,{key:s,block:e,session:r,article:t}))),d&&f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,null))))},We=({block:e,article:t,session:r})=>{const s=w();return f.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{$e(s,r,e,t.title)},href:t.url,target:"_blank",rel:"noopener noreferrer"},f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:"regular/file-alt",size:16})),f.createElement("div",{className:"userflowjs-resource-center-block-text"},f.createElement("span",{dangerouslySetInnerHTML:{__html:t.htmlTitle}}),f.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:t.htmlSnippet}})))},Fe=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},f.createElement(j,{doc:e.content,lookupAttribute:T(t.data)})),Oe=({block:e,initialUserContent:t,session:s,navigate:n})=>{const o=e.assistantFlowId,c=w(),[a,l]=f.useState(null),[i,u]=f.useState(null),[d,m]=f.useState(null),[h]=f.useState(t);return f.useEffect((()=>{t&&n({kind:"assistant",block:e,initialUserContent:""})}),[t,e,n]),f.useEffect((()=>{let e=!1;return(async()=>{try{const t=r.getItem("assistantConversationId:"+o),[s,n]=await Promise.all([ye(),c.send({kind:"GetAssistant",assistantFlowId:o,conversationId:t},{handlesRejection:!0,endBatch:!0})]);if(e)return;l((()=>s)),u(n)}catch(t){console.error("Resource center assistant route failed to load:",t),m(t.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{e=!0}}),[c,o]),d?f.createElement("div",{className:"userflowjs-assistant-chat"},f.createElement("div",{className:"userflowjs-assistant-chat__content"},f.createElement("div",{className:"userflowjs-assistant-chat__error"},d))):a&&i?f.createElement(a,{block:e,session:s,assistantReply:i,initialUserContent:h}):f.createElement(ve,{center:!0,fadeIn:!0})};function $e(e,t,r,s){e.send({kind:"ClickResourceCenter",sessionId:t.id,description:r?g(r.name,{lookupAttribute:T(t.data)})+(s?` - ${s}`:""):s},{batch:!0})}var Ue=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",ResourceCenterApp:Ne,default:Ne});export{Se as A,je as G,Ue as R};
1
+ import{h as e,C as t,i as r,j as s,c as n,k as o,l as c,E as a,m as l,n as i,p as u,S as d,_ as m}from"./userflow.js";import{r as f}from"./vendor.react.js";import{u as w,i as h}from"./client-context.js";import{u as b,w as E,C as k}from"./Icons.js";import{b as p,h as v,s as g,B as C,R as j,a as S,n as y,f as N}from"./BubbleToolbar.js";import{M as _,g as I,a as x,b as T}from"./flow-condition-types.js";import{u as R,a as A,g as B}from"./stylesheets.js";import{u as L,F as M,S as H}from"./logomark.js";import{o as P}from"./vendor.obj-str.js";import{D as W}from"./DynamicIcon.js";import{f as F,C as O}from"./ChecklistUI.js";import{f as $,a as U,b as D,c as z,d as q,e as K,g as V,h as G,i as Q,j as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as J}from"./vendor.fortawesome.react-fontawesome.js";import{u as X}from"./vendor.react-i18next.js";function Y(t){return t!==e.ACTION&&t!==e.ASSISTANT&&t!==e.CONTACT&&t!==e.FLOWS&&t!==e.KNOWLEDGE_BASE&&t!==e.SUBPAGE}const ee=window,te={[t.CRISP]:{configure:({onShow:e,onHide:t})=>{!function(){if(re)return;re=!0,ee.$crisp||(ee.$crisp=[]);ee.$crisp.push(["do","chat:hide"])}();let r=!1,s=!1;const n=()=>{r||s?(ee.$crisp.push(["do","chat:show"]),e()):(ee.$crisp.push(["do","chat:hide"]),t())},o=()=>{r=!0,n()};ee.$crisp.push(["on","chat:opened",o]);const c=()=>{r=!1,n()};ee.$crisp.push(["on","chat:closed",c]);const a=()=>{s=!0,n()};ee.$crisp.push(["on","message:received",a]);const l=window.setInterval((()=>{const e=(()=>{const e=document.getElementById("crisp-chatbox");if(!e||"block"!==window.getComputedStyle(e).display)return!1;const t=e.querySelector('[data-id="new_messages"]');return!(!t||"block"!==window.getComputedStyle(t).display)})();e!==s&&(s=e,n())}),200);return()=>{ee.$crisp.push(["off","chat:opened",o]),ee.$crisp.push(["off","chat:closed",c]),ee.$crisp.push(["off","message:received",a]),window.clearInterval(l)}},show:()=>{ee.$crisp.push(["do","chat:show"]),ee.$crisp.push(["do","chat:open"])},hide:()=>{ee.$crisp.push(["do","chat:hide"]),ee.$crisp.push(["do","chat:close"])}},[t.CUSTOM]:{configure:()=>()=>{},show:({block:e})=>{try{new Function('"use strict";\n'+e.chatCode)()}catch(t){console.error(`Userflow.js: Showing custom chat provider failed. Code: ${e.chatCode}`,t)}},hide:()=>{}},[t.FRESHCHAT]:{configure:({onShow:e,onHide:t})=>{if(!ee.fcWidget)throw new Error("Freshchat is not installed");let r=!1,s=!1;const n=()=>{r||s?e():t()},o=()=>{r=!0,n()};ee.fcWidget.on("widget:opened",o);const c=()=>{r=!1,n()};ee.fcWidget.on("widget:closed",c);const a=()=>{const e=!!document.querySelector("#fc_frame.h-open-notify");e!==s&&(s=e,n())},l=window.setInterval(a,200);return ee.fcWidget.on("unreadCount:notify",a),()=>{ee.fcWidget.off("widget:opened",o),ee.fcWidget.off("widget:closed",c),ee.fcWidget.off("unreadCount:notify",a),window.clearInterval(l)}},show:()=>{ee.fcWidget.open()},hide:()=>{ee.fcWidget.close()}},[t.HELPSCOUT]:{configure:({onShow:e,onHide:t})=>{if(!ee.Beacon)throw new Error("Help Scout is not installed");!function(){if(se)return;se=!0,oe()}();let r=!1,s=!1;const n=()=>{r||s?(ne(),e()):(oe(),t())},o=()=>{r=!0,n()};ee.Beacon("on","open",o),ee.Beacon("info")?.status.isOpened&&o();const c=()=>{r=!1,n()};ee.Beacon("on","close",c);const a=window.setInterval((()=>{const e=!!document.querySelector(".BeaconNotificationsFrame");e!==s&&(s=e,n())}),200);return()=>{ee.Beacon("off","open",o),ee.Beacon("off","close",c),window.clearInterval(a)}},show:()=>{ne(),ee.Beacon("open")},hide:()=>{oe(),ee.Beacon("close")}},[t.HUBSPOT]:{configure:({onShow:e,onHide:t})=>{const r=()=>{const r=document.getElementById("hubspot-messages-iframe-container");if(!ee.HubSpotConversations||!r)return;window.clearInterval(n),function(){if(ce)return;ce=!0,ae?le():ie()}();let o=!1,c=!1;const a=()=>{o||c?(le(),e()):(ie(),t())},l=()=>{const e=!!document.querySelector("#hubspot-messages-iframe-container .hs-shadow-container.active");e!==o&&(o=e,a())},i=new _(l);i.observe(r,{attributes:!0,subtree:!0,attributeFilter:["class"]}),l();const u=({unreadCount:e})=>{const t=e>0;t!==c&&(c=t,a())};ee.HubSpotConversations.on("unreadConversationCountChanged",u),s=()=>{i.disconnect(),ee.HubSpotConversations.off("unreadConversationCountChanged",u)}};let s=()=>{window.clearInterval(n)};const n=window.setInterval(r,100);return r(),()=>{s()}},show:()=>{le(),ee.HubSpotConversations.widget.open()},hide:()=>{ie(),ee.HubSpotConversations.widget.close()}},[t.INTERCOM]:{configure:({onShow:e,onHide:t})=>{if(!ee.Intercom)throw new Error("Intercom is not installed");return function(){if(ue)return;ue=!0,we();let e=!1,t=!1;const r=()=>{fe();for(const e of de)e()},s=()=>{we();for(const e of me)e()},n=()=>{e||t?r():s()};ee.Intercom("onShow",(()=>{e=!0,n()})),ee.Intercom("onHide",(()=>{e=!1,n()}));const o=()=>{const e=!!document.querySelector('iframe[name="intercom-borderless-frame"], iframe[name="intercom-notifications-frame"]');t!==e&&(t=e,n())};ee.Intercom("onUnreadCountChange",(()=>{o()})),window.setInterval(o,200)}(),de.add(e),me.add(t),()=>{de.delete(e),me.delete(t)}},show:()=>{fe(),ee.Intercom("show")},hide:()=>{we(),ee.Intercom("hide")}},[t.ZENDESK]:{configure:({onShow:e,onHide:t})=>{if(!ee.zE)throw new Error("Zendesk is not installed");!function(){if(he)return;he=!0,ee.zE("webWidget","hide"),ee.zE("webWidget","close"),ee.zE("webWidget:on","open",(()=>{for(const e of be)e()})),ee.zE("webWidget:on","close",(()=>{for(const e of Ee)e()})),ee.zE("webWidget:on","chat:unreadMessages",(e=>{for(const t of ke)t(e)}))}();let r=!1,s=!1;const n=()=>{r||s?(ee.zE("webWidget","show"),e()):(ee.zE("webWidget","hide"),t())},o=()=>{r=!0,s=!1,n()};be.add(o);const c=()=>{r=!1,s=!1,n()};Ee.add(c);const a=e=>{const t=e>0;t!==s&&(s=t,n())};return ke.add(a),()=>{be.delete(o),Ee.delete(c),ke.delete(a)}},show:()=>{ee.zE("webWidget","show"),ee.zE("webWidget","open")},hide:()=>{ee.zE("webWidget","hide"),ee.zE("webWidget","close")}},[t.ZENDESK_MESSENGER]:{configure:({onShow:e,onHide:t})=>{if(!ee.zE)throw new Error("Zendesk is not installed");let r=!1;const s=window.setInterval((()=>{const s=(()=>{const e=document.querySelector('iframe[title="Messaging window"]');return!!e?.parentElement&&"0px"!==window.getComputedStyle(e.parentElement).height})();s!==r&&(r=s,r?e():t())}),200);return()=>{window.clearInterval(s)}},show:()=>{ee.zE("messenger","open")},hide:()=>{ee.zE("messenger","close")}}};let re=!1;let se=!1;function ne(){ee.Beacon("config",{display:{style:"icon"}})}function oe(){ee.Beacon("config",{display:{style:"manual"}})}let ce=!1,ae=!1;function le(){ae=!0;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","visible","important")}function ie(){ae=!1;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","hidden","important")}let ue=!1,de=new Set,me=new Set;function fe(){ee.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function we(){ee.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let he=!1,be=new Set,Ee=new Set,ke=new Set;const pe=e=>f.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},e),f.createElement("path",{fill:"currentColor",d:"M24.049 79.74h36.003c8.185 0 15.985-6.621 17.43-14.814l6.091-34.556h3.997c8.149 0 13.645 6.63 12.2 14.815l-7.051 40C91.274 93.363 83.474 100 75.288 100h-40c-8.185 0-13.645-6.667-12.2-14.815l.96-5.444Z"}),f.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12.437 69.63h40c8.148 0 15.978-6.637 17.422-14.815l7.052-40C78.355 6.63 72.896 0 64.711 0h-40C16.533 0 8.726 6.63 7.281 14.815l-7.052 40C-1.215 62.963 4.252 69.63 12.437 69.63Zm33.628-33.798c3.756-2.064 8.725-4.795 9.907-11.844C57.385 15.458 50.065 8.983 42.168 9c-7.452 0-12.771 3.195-17.508 8.892-.858 1.034-.884 2.45-.053 3.212l3.472 3.196c.847.767 2.25.589 3.176-.406 2.842-3.068 4.869-4.83 8.51-4.83 2.864 0 6.077 1.934 5.59 4.847-.37 2.223-2.292 3.334-5.4 5.001l-.28.151c-3.582 1.92-8.134 4.362-9.124 10.247l-.16.956c-.055.28-.05.571.014.85.065.278.188.538.362.76.173.222.391.4.639.522.247.121.518.183.79.18h6.744a2.709 2.709 0 0 0 1.712-.688c.481-.426.81-1.01.934-1.657l.095-.556c.266-1.582 2.101-2.59 4.384-3.845ZM32.837 59c3.552 0 6.955-3.034 7.58-6.769.63-3.729-1.742-6.763-5.293-6.763-3.552 0-6.934 3.028-7.58 6.763C26.9 55.966 29.286 59 32.837 59Z"})),ve=({center:e,fadeIn:t})=>{const r=12;return f.createElement("div",{className:P({"userflowjs-spinner":!0,"userflowjs-spinner--center":!!e,"userflowjs-spinner--fade-in":!!t})},f.createElement("svg",{viewBox:"0 0 24 24",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},f.createElement("circle",{className:"userflowjs-spinner__bg",fill:"none",cx:r,cy:r,r:10,style:{strokeWidth:"4px"}}),f.createElement("circle",{className:"userflowjs-spinner__fill",fill:"none",cx:r,cy:r,r:10,transform:"translate(12, 12) rotate(-90) translate(-12, -12)",style:{strokeWidth:"4px",strokeDasharray:20*Math.PI*.25+"px, 1000"}})))};function ge(e){const t=w(),[r,s]=f.useState(!0),[n,o]=f.useState(!1),[c,a]=f.useState(null),[l,i]=f.useState(null),[u,d]=f.useState(null),m=f.useRef(0),h=f.useRef(null),b=f.useRef((()=>{}));return f.useEffect((()=>{const r=JSON.stringify(e);if(r===h.current)return;h.current=r;const n=++m.current;let c,l;let u=!1;b.current=async(e,r)=>{if(!u){u=!0,o(!0);try{const s=e(c,l);l=s;const i=await t.send(s,{handlesRejection:!0});if(n!==m.current)return;c=r(c,i),a(c),d(null)}catch(s){if(n!==m.current)return;d(s)}finally{u=!1,o(!1)}}},(async()=>{s(!0);try{l=e;const r=await t.send(e,{handlesRejection:!0});if(n!==m.current)return;c=r,a(c),i(e),d(null)}catch(r){if(n!==m.current)return;d(r)}finally{s(!1)}})()}),[t,e]),{loading:r,loadingMore:n,data:c,messageForData:l,error:u,loadMore:b.current}}function Ce(e,t){const[r,s]=f.useState(e),n=f.useRef(void 0),o=f.useCallback((e=>{window.clearTimeout(n.current),s(e),t(e)}),[t]),c=f.useCallback((e=>{window.clearTimeout(n.current),s(e),n.current=window.setTimeout((()=>{t(e)}),200)}),[t]);return f.useEffect((()=>()=>{window.clearTimeout(n.current)}),[]),[r,c,o]}const je=({textareaRef:e,value:t,onChange:r,onBlur:s,onKeyDown:n,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:i,mirrorClassName:u,textareaClassName:d,children:m})=>{let w=t||c||"";return(""===w||w.endsWith("\n"))&&(w+=" "),i=i||"growing-textarea",u=u||i+"__mirror",f.createElement("div",{className:i},f.createElement("div",{className:u+" "+(d||"")},w),f.createElement("textarea",{ref:e,value:t,onChange:e=>r&&r(e.target.value),onBlur:s,onKeyDown:n,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:d}),m)},Se=({textareaRef:e,value:t,onChange:r,onSubmit:s,placeholder:n,readOnly:o})=>{const c=()=>{s&&s()};return f.createElement("div",{className:"userflowjs-assistant-chat-input"},f.createElement(je,{textareaRef:e,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:n,readOnly:o,value:t||"",onChange:r,onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||(e.preventDefault(),c())}}),f.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>c()},f.createElement(J,{icon:$})))};const ye=async()=>(await m((()=>import("./ResourceCenterAssistantChat.js")),[new URL("ResourceCenterAssistantChat.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.dompurify.js",import.meta.url).toString(),new URL("vendor.marked.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()])).ResourceCenterAssistantChat,Ne=({session:l,isOpen:i,flowSession:u,checklistSession:d})=>{const m=w(),{t:v}=X(),{company:g}=l.flow,{version:C}=l,j=C.resourceCenter,S=R(C.theme),y=l.locale?l.locale.standardLocaleId:l.version.theme.languageId;f.useEffect((()=>{h.changeLanguage(y)}),[y]);const{loaded:T}=A(window,N,S),[O,$]=f.useState(!1),K=T&&O,[V,G]=f.useState(I()),[Q,Z]=f.useState(x()),J=f.useCallback((()=>{G(I()),Z(x())}),[]);L(J);const{zIndex:ee,bringToFront:re}=b(),se=f.useRef(null),[ne,oe]=f.useState(null),[ce,ae]=f.useState(null),[le,ie]=f.useState(null),ue=f.useRef(null),[de,me]=f.useState(null),[fe,we]=f.useState(null),[he,be]=f.useState(null),[Ee,ke]=f.useState(0),[ve,ge]=f.useState(0),Ce=f.useCallback((()=>{ce&&ke(ce.offsetWidth),ge((le?.offsetHeight||0)+(de?.offsetHeight||0)+(fe?.offsetHeight||0)+(he?.offsetHeight||0))}),[ce,le,de,fe,he]);f.useLayoutEffect((()=>{if(!ne||"function"!=typeof _)return;const e=new _((()=>{Ce()}));return e.observe(ne,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect()}}),[ne,Ce]),f.useLayoutEffect((()=>{Ce()}));const[je,Se]=f.useState(!1),ye=f.useRef(),Ne=f.useCallback((()=>{Se(!0),window.clearTimeout(ye.current),ye.current=window.setTimeout((()=>{Se(!1)}),S.resourceCenterTransitionDuration)}),[S.resourceCenterTransitionDuration]);f.useEffect((()=>()=>{window.clearTimeout(ye.current)}),[]);const xe=f.useCallback((()=>{re(),Ne(),m.openResourceCenter()}),[re,m,Ne]),Te=f.useCallback((()=>{Ne(),m.closeResourceCenter()}),[m,Ne]),[Me,He]=f.useState(!1);f.useEffect((()=>{if(Me){if(!("ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0))if(i){const e='button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea';let t=de?.querySelector(".userflowjs-assistant-chat-input textarea")||de?.querySelector(e)||le?.querySelector(e);if(t){const e=t.closest&&t.closest(".userflowjs-resource-center-checklist")||null;e?F(e):t.focus({preventScroll:!0})}}else ce?.focus({preventScroll:!0});He(!1)}}),[Me,i,de,le,ce]),f.useEffect((()=>{const e=ne?.ownerDocument.defaultView;if(!i||!e)return;const t=e=>{"Escape"===e.key&&(Te(),He(!0))};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}),[i,ne,He,Te]);const[We,Ue]=f.useState((()=>function(e,t){if(!t)return null;const r=JSON.parse(t);let s;r.blockCvid&&(s=e.version.resourceCenter?.blocks.find((e=>e.cvid===r.blockCvid)));if(!s&&"search"!==r.kind)return null;return{kind:r.kind,block:s}}(l,r.getItem(`resourceCenterRoute:v1:${l.id}`)))),De=f.useCallback(((e,t)=>{Ue(e);const s=function(e){if(!e)return null;let t;"block"in e&&null!=e.block&&(t=e.block.cvid);return JSON.stringify({kind:e.kind,blockCvid:t})}(e);s?r.setItem(`resourceCenterRoute:v1:${l.id}`,s):r.removeItem(`resourceCenterRoute:v1:${l.id}`),0===t?.detail&&He(!0)}),[l.id]),ze=f.useMemo((()=>j.blocks.filter((t=>!(t.type===e.CHECKLIST&&!d)&&(!t.hiddenWhenFlowsActive||!t.hiddenWhenFlowsActive.some((e=>e===u?.flow.id||e===d?.flow.id)))))),[j,u,d]),qe=f.useMemo((()=>_e(ze)),[ze]),Ke=f.useMemo((()=>d&&j.blocks.some((t=>t.type===e.CHECKLIST))?s(d):0),[j,d]),Ve=f.useMemo((()=>j.blocks.find((t=>t.type===e.CONTACT&&t.chatEnabled&&t.chatProvider))),[j]),[Ge,Qe]=f.useState(!1),Ze=f.useCallback((()=>{m.closeResourceCenter(),Ve&&Ve.chatProvider!==t.CUSTOM&&Qe(!0)}),[m,Ve]),Je=f.useCallback((()=>{Qe(!1)}),[]),Xe=f.useCallback((()=>{if(Ve)try{te[Ve.chatProvider].hide({block:Ve}),Je()}catch(e){console.error(`Userflow.js: Error when hiding ${Ve.chatProvider}:`,e)}}),[Ve,Je]);f.useEffect((()=>{if(!Ve)return;n.autoHide3pDisabled=!0;const e=te[Ve.chatProvider];try{const t=e.configure({block:Ve,onShow:Ze,onHide:Je});return()=>{t()}}catch(t){return void console.error(`Userflow.js: Error when configuring ${Ve.chatProvider}:`,t)}}),[Ve,Ze,Je]),f.useEffect((()=>{i&&Xe()}),[Xe,i]);const Ye=!!We&&("search"===We.kind||"flows"===We.kind||"knowledgeBase"===We.kind),et="assistant"===We?.kind,tt=Math.min(et?S.resourceCenterFullWidth:S.resourceCenterWidth,V-2*S.resourceCenterPaddingX),rt={zIndex:null!=S.resourceCenterZIndex?S.resourceCenterZIndex:i?ee:E(k),width:(i?tt:Ee)+"px",height:i?Math.min(Ye?540:et?720:ve,Q-2*S.resourceCenterPaddingY)+"px":void 0,position:K?void 0:"absolute",visibility:K&&!Ge?void 0:"hidden"},st=S.resourceCenterDisplayChecklistProgress&&d&&Ke>0?f.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},Ke,f.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let nt="",ot="";return S.resourceCenterLauncherTextMode===o.CHECKLIST_OVERRIDE&&d&&Ke>0?nt=d.version.checklist?.launcherText||"Get Started":S.resourceCenterLauncherTextMode!==o.NONE&&(ot=j.buttonText),f.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center userflowjs-theme-root",style:B(S),dir:h.dir()},f.createElement(M,{elRef:se,className:P({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--fixed":!0,[`userflowjs-resource-center-frame--placement-${S.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame--animating":je,"userflowjs-resource-center-frame--open":i,"userflowjs-resource-center-frame--closed":!i}),style:{...rt},stylesheet:p,theme:S,onStylesheetsLoad:$},K&&f.createElement(f.Fragment,null,f.createElement("div",{ref:oe,className:P({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${S.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":je,"userflowjs-resource-center-frame-root--open":i,"userflowjs-resource-center-frame-root--closed":!i}),role:i?"dialog":void 0,"aria-label":i?j.headerText:void 0},f.createElement("div",{className:"userflowjs-resource-center-launcher-container"},f.createElement("button",{ref:ae,className:"userflowjs-resource-center-launcher-button",onClick:()=>{xe(),He(!0)},"aria-label":`Open ${j.headerText}`},st,nt&&f.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},nt),(st||nt)&&f.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),ot&&f.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ot),f.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},S.resourceCenterLauncherIconType===c.PLAINTEXT?"?":f.createElement(pe,null)))),f.createElement("div",{ref:ue,className:"userflowjs-resource-center-body",style:{width:tt+"px"}},f.createElement("div",{ref:me,className:P({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":"assistant"!==We?.kind,"userflowjs-resource-center-body-content--same-background":S.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":g.resourceCenterBranding})},i&&f.createElement(f.Fragment,null,We?"search"===We.kind?f.createElement(Re,{session:l,navigate:De}):"email"===We.kind?f.createElement(Ae,{block:We.block,session:l}):"phone"===We.kind?f.createElement(Be,{block:We.block,session:l}):"flows"===We.kind?f.createElement(Le,{block:We.block,initialQ:We.initialQ,session:l,navigate:De}):"knowledgeBase"===We.kind?f.createElement(Pe,{block:We.block,initialQ:We.initialQ,session:l,bodyRef:ue}):"subpage"===We.kind?f.createElement(Fe,{block:We.block,session:l}):"assistant"===We.kind?f.createElement(Oe,{block:We.block,initialUserContent:We.initialUserContent,session:l,navigate:De}):null:f.createElement(f.Fragment,null,ze.map(((e,t)=>{const r=Ie[e.type],s=ze[t+1];return r?f.createElement(f.Fragment,{key:e.id},f.createElement(r.View,{session:l,flowSession:u,checklistSession:d,block:e,navigate:De,onChatShow:Ze}),s&&(n=e.type,o=s.type,Y(n)||Y(o))&&f.createElement("div",{className:"userflowjs-resource-center-divider"})):null;var n,o})))))),g.resourceCenterBranding&&f.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},f.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:we},f.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+g.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},f.createElement(H,null),f.createElement("div",null,"Made with Userflow")))),l.draftMode&&f.createElement("div",{className:"userflowjs-resource-center-preview"},f.createElement("div",{ref:be,className:"userflowjs-resource-center-preview-content"},f.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),f.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{m.endFlow(l,{endReason:a.USER_CLOSED})}},f.createElement(W,{icon:U})))),f.createElement("div",{className:"userflowjs-resource-center-header",style:{width:tt+"px"}},f.createElement("div",{ref:ie,className:"userflowjs-resource-center-header-content"},null==We?f.createElement("div",{className:"userflowjs-resource-center-header-text"},j.headerText):f.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:e=>De(null,e)},f.createElement("div",{className:"userflowjs-rtl-mirrored"},f.createElement(W,{icon:D})),f.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},v("resource_center.back"))),f.createElement("div",{className:"flex-1"}),qe.length>0&&f.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let e={kind:"search"};if(1===qe.length){const t=qe[0],r=Ie[t.type];r.routeTo&&(e=r.routeTo({block:t}))}"search"===We?.kind?De(null):($e(m,l,null,"Search icon"),De(e))},"aria-label":"Search"},f.createElement(W,{icon:z})),f.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:e=>{Te(),0===e.detail&&He(!0)},"aria-label":`Close ${j.headerText}`},f.createElement(W,{icon:q}))))))))};function _e(e){return e.filter((e=>{const t=Ie[e.type];return t.isSearchable?t.isSearchable(e):!!t.search}))}const Ie={[e.ACTION]:{View:e=>{const{block:t,session:r,flowSession:s,checklistSession:n}=e,o=w(),[c,a]=f.useState(!1),i=s?.id,u=n?.id;return f.useEffect((()=>{a(!1)}),[i,u]),f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c?void 0:()=>{$e(o,r,t);const e=t.actions.find((e=>e.type===l.START_FLOW));if(e){e.otherFlow?.id!==n?.flow.id&&a(!0)}else o.closeResourceCenter();v(o,r,t.actions)},disabled:c},f.createElement(xe,{...e}),f.createElement(Te,{...e}),c&&f.createElement(ve,null))}},[e.ASSISTANT]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w(),[o,c]=f.useState("");return t.assistantAppearance===i.INPUT?f.createElement("div",{className:"userflowjs-resource-center-assistant-block"},f.createElement(Se,{value:o,onChange:c,placeholder:g(t.name,{lookupAttribute:T(r.data)}),onSubmit:()=>{$e(n,r,t),s({kind:"assistant",block:t,initialUserContent:o})}})):f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{$e(n,r,t),s({kind:"assistant",block:t,initialUserContent:""})}},f.createElement(xe,{...e}),f.createElement(Te,{...e}))}},[e.CHECKLIST]:{View:({checklistSession:e})=>f.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},f.createElement(O,{session:e}),f.createElement(C,{draftMode:!!e.draftMode&&"CHECKLIST PREVIEW"}))},[e.CONTACT]:{View:e=>{const{block:t,session:r,navigate:s,onChatShow:n}=e,o=w(),c=[];return t.emailEnabled&&c.push({icon:G,label:"Email",isRoute:!0,onClick:e=>{$e(o,r,t,"Email"),s({kind:"email",block:t},e)}}),t.phoneEnabled&&c.push({icon:Q,label:"Phone",isRoute:!0,onClick:e=>{$e(o,r,t,"Phone"),s({kind:"phone",block:t},e)}}),t.chatEnabled&&c.push({icon:Z,label:"Live-chat",isRoute:!1,onClick:()=>{if($e(o,r,t,"Chat"),t.chatProvider){const r=te[t.chatProvider];try{r.show({block:t})}catch(e){console.error(`Userflow.js: Error when showing ${t.chatProvider}:`,e)}n()}else r.draftMode&&window.alert("You have not selected a chat provider. Go to the resource center builder in Userflow. Click the Contact block. Pick a chat provider in the side panel.")}}),f.createElement("div",{className:P({"userflowjs-resource-center-block":!0,"userflowjs-resource-center-block--clickable":1===c.length}),onClick:1===c.length?c[0].onClick:void 0},1===c.length&&f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:c[0].icon})),f.createElement(Te,{...e}),c.length>1&&c.map((({icon:e,label:t,onClick:r},s)=>f.createElement("button",{key:s,className:"userflowjs-resource-center-icon-button",onClick:r,"aria-label":t},f.createElement(W,{icon:e})))),1===c.length&&c[0].isRoute&&f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))}},[e.FLOWS]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w();return f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{$e(n,r,t),s({kind:"flows",block:t},e)}},f.createElement(xe,{...e}),f.createElement(Te,{...e}),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))},routeTo:({block:e,initialQ:t})=>({kind:"flows",block:e,initialQ:t}),isSearchable:e=>!!e.searchEnabled,search:async({client:e,session:t,block:r,q:s})=>{const{flows:n}=await e.send({kind:"ListResourceCenterBlockFlows",sessionId:t.id,blockCvid:r.cvid},{handlesRejection:!0}),o=Me(n,s),c=o.slice(0,5);return{block:r,truncated:c.length===o.length,results:c.map((e=>({kind:"flow",flow:e})))}}},[e.KNOWLEDGE_BASE]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w();return f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{$e(n,r,t),s({kind:"knowledgeBase",block:t},e)}},f.createElement(xe,{...e}),f.createElement(Te,{...e}),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))},routeTo:({block:e,initialQ:t})=>({kind:"knowledgeBase",block:e,initialQ:t}),search:async({client:e,session:t,block:r,q:s})=>{const{truncated:n,articles:o}=await e.send({kind:"SearchKnowledgeBase",sessionId:t.id,blockCvid:r.cvid,q:s,offset:0,limit:5},{handlesRejection:!0});return{block:r,truncated:n,results:o.map((e=>({kind:"article",article:e})))}}},[e.MESSAGE]:{View:({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-block"},f.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},f.createElement(j,{doc:e.content,lookupAttribute:T(t.data)})))},[e.SUBPAGE]:{View:e=>{const{block:t,session:r,navigate:s}=e,n=w();return f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{$e(n,r,t),s({kind:"subpage",block:t},e)}},f.createElement(xe,{...e}),f.createElement(Te,{...e}),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K})))}}},xe=({block:e})=>e.icon?f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:e.icon,size:16})):null,Te=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-block-text"},f.createElement(S,{doc:e.name,lookupAttribute:T(t.data)}));const Re=({session:e,navigate:t})=>{const r=w(),s=e.version.resourceCenter.blocks,n=_e(s),{t:o}=X(),c=f.useRef(null),[a,l]=f.useState(""),[i,u]=Ce(a,l),[d,m]=f.useState(null);return f.useEffect((()=>{if(""===a.trim())return void m(null);let t=!1;return(async()=>{m(null);const n=await Promise.all(s.map((async t=>{const{search:s}=Ie[t.type];if(!s)return null;try{return await s({client:r,session:e,block:t,q:a})}catch(n){return console.error(`Userflow.js: Global search failed for ${t.type} block=`,t,"error=",n),null}})));t||m(n.filter((e=>null!=e&&e.results.length>0)))})(),()=>{t=!0}}),[r,e,s,a]),f.useEffect((()=>{c.current?.focus({preventScroll:!0})}),[]),f.createElement(f.Fragment,null,f.createElement("div",{className:"userflowjs-resource-center-list-route-search"},f.createElement("input",{ref:c,className:"userflowjs-text-input",type:"text",value:i,onChange:e=>u(e.target.value),placeholder:o("resource_center.search_placeholder")})),""===a.trim()?f.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},o("resource_center.search_in")," ",n.map(((t,r)=>f.createElement(f.Fragment,{key:t.cvid},r>0&&(r===n.length-1?` ${o("and")} `:", "),f.createElement("b",null,f.createElement(S,{doc:t.name,lookupAttribute:T(e.data)}))))),"."):d?0===d.length?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},o("resource_center.no_results_found")):d.map((({block:s,truncated:n,results:c},l)=>{const i=Ie[s.type],u=i.routeTo&&i.routeTo({block:s,initialQ:a});return f.createElement(f.Fragment,{key:s.cvid},l>0&&f.createElement("div",{className:"userflowjs-resource-center-divider"}),f.createElement("div",{className:"userflowjs-resource-center-label"},f.createElement(S,{doc:s.name,lookupAttribute:T(e.data)})),c.map(((r,n)=>"flow"===r.kind?f.createElement(He,{key:r.flow.id,block:s,session:e,flow:r.flow,navigate:t}):"article"===r.kind?f.createElement(We,{key:n,block:s,session:e,article:r.article}):null)),!n&&u&&f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:n=>{$e(r,e,s),t(u,n)}},f.createElement("div",{className:"userflowjs-resource-center-block-text"},o("more"),":"," ",f.createElement(S,{doc:s.name,lookupAttribute:T(e.data)})),f.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},f.createElement(W,{icon:K}))))})):f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,null)))},Ae=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},f.createElement(j,{doc:e.emailContent,lookupAttribute:T(t.data)})),Be=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},f.createElement(j,{doc:e.phoneContent,lookupAttribute:T(t.data)})),Le=({block:e,initialQ:t,session:r,navigate:s})=>{const{t:n}=X(),o=f.useRef(null),[c,a]=f.useState(t||""),[l,i]=Ce(c,a),{data:u,error:d}=ge({kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:e.cvid}),m=u?.flows,w=f.useMemo((()=>m?Me(m,c):null),[m,c]);return f.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]),f.createElement(f.Fragment,null,f.createElement("div",{className:"userflowjs-resource-center-list-route-header"},f.createElement("div",{className:"userflowjs-resource-center-list-route-title"},f.createElement(S,{doc:e.name,lookupAttribute:T(r.data)}))),e.searchEnabled&&f.createElement("div",{className:"userflowjs-resource-center-list-route-search"},f.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:n("resource_center.search_placeholder")})),d?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},n("resource_center.generic_error")):w?0===w.length?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},n("resource_center.no_results_found")):w.map((t=>f.createElement(He,{key:t.id,block:e,session:r,flow:t,navigate:s}))):f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,{fadeIn:!0})))};function Me(e,t){const r=t.toLowerCase().trim();return""===r?e:e.filter((e=>e.name.toLowerCase().includes(r)))}const He=({block:e,session:t,flow:r,navigate:s})=>{const n=w(),[o,c]=f.useState(!1);return f.useEffect((()=>{if(!o||r.type!==u.CHECKLIST)return;const e=()=>{n.checklistSession?.flow.id===r.id&&(t(),s(null))},t=()=>{n.off("checklistChanged",e)};return n.on("checklistChanged",e),t}),[n,o,r.type,r.id,s]),f.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if($e(n,t,e,r.name),n.checklistSession?.flow.id===r.id)return void s(null);n.startFlow({flowId:r.id,startReason:d.RESOURCE_CENTER,replaceCurrent:!0}),c(!0);const o=g(r.url,{lookupAttribute:T(t.data)});o&&y(o)},disabled:o},f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:r.type===u.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),f.createElement("div",{className:"userflowjs-resource-center-block-text"},r.name),o&&f.createElement(ve,null))},Pe=({block:e,initialQ:t,session:r,bodyRef:s})=>{const{t:n}=X(),o=f.useRef(null),[c,a]=f.useState(t||""),[l,i]=Ce(c,a),{loading:u,loadingMore:d,data:m,messageForData:w,error:h,loadMore:b}=ge({kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:e.cvid,q:c,offset:0}),E=m?.truncated,k=f.useCallback((()=>{b(((e,t)=>({...t,offset:e.articles.length})),((e,t)=>({...t,articles:[...e.articles,...t.articles]})))}),[b]);f.useEffect((()=>{const e=s.current;if(!e||u||d||E)return;const t=()=>{e.scrollHeight-e.clientHeight-e.scrollTop>400||k()};return e.addEventListener("scroll",t),()=>{e.removeEventListener("scroll",t)}}),[s,u,d,E,k]),f.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]);let p=e.knowledgeBaseUrl||"";return p.match(/^https?:\/\//)||(p=`http://${p}`),f.createElement(f.Fragment,null,f.createElement("div",{className:"userflowjs-resource-center-list-route-header"},f.createElement("div",{className:"userflowjs-resource-center-list-route-title"},f.createElement(S,{doc:e.name,lookupAttribute:T(r.data)})),f.createElement("a",{className:"userflowjs-resource-center-icon-button",href:p,target:"_blank",rel:"noopener noreferrer"},f.createElement(W,{icon:V}))),f.createElement("div",{className:"userflowjs-resource-center-list-route-search"},f.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:n("resource_center.search_placeholder")})),h?f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},"quota_exceeded"===h.code?"Sorry, this company has reached its max number of searches. Consider asking Userflow to be moved to a dedicated search engine for a higher quota.":h.humanMessage||n("resource_center.generic_error")):u||!m?f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,null)):0===m.articles.length?""===w?.q?null:f.createElement("div",{className:"userflowjs-resource-center-list-route-error"},n("resource_center.no_results_found")):f.createElement(f.Fragment,null,""===w?.q&&f.createElement("div",{className:"userflowjs-resource-center-label"},n("resource_center.suggested_articles")),m.articles.map(((t,s)=>f.createElement(We,{key:s,block:e,session:r,article:t}))),d&&f.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},f.createElement(ve,null))))},We=({block:e,article:t,session:r})=>{const s=w();return f.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{$e(s,r,e,t.title)},href:t.url,target:"_blank",rel:"noopener noreferrer"},f.createElement("div",{className:"userflowjs-resource-center-block-icon"},f.createElement(W,{icon:"regular/file-alt",size:16})),f.createElement("div",{className:"userflowjs-resource-center-block-text"},f.createElement("span",{dangerouslySetInnerHTML:{__html:t.htmlTitle}}),f.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:t.htmlSnippet}})))},Fe=({block:e,session:t})=>f.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},f.createElement(j,{doc:e.content,lookupAttribute:T(t.data)})),Oe=({block:e,initialUserContent:t,session:s,navigate:n})=>{const o=e.assistantFlowId,c=w(),[a,l]=f.useState(null),[i,u]=f.useState(null),[d,m]=f.useState(null),[h]=f.useState(t);return f.useEffect((()=>{t&&n({kind:"assistant",block:e,initialUserContent:""})}),[t,e,n]),f.useEffect((()=>{let e=!1;return(async()=>{try{const t=r.getItem("assistantConversationId:"+o),[s,n]=await Promise.all([ye(),c.send({kind:"GetAssistant",assistantFlowId:o,conversationId:t},{handlesRejection:!0,endBatch:!0})]);if(e)return;l((()=>s)),u(n)}catch(t){console.error("Resource center assistant route failed to load:",t),m(t.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{e=!0}}),[c,o]),d?f.createElement("div",{className:"userflowjs-assistant-chat"},f.createElement("div",{className:"userflowjs-assistant-chat__content"},f.createElement("div",{className:"userflowjs-assistant-chat__error"},d))):a&&i?f.createElement(a,{block:e,session:s,assistantReply:i,initialUserContent:h}):f.createElement(ve,{center:!0,fadeIn:!0})};function $e(e,t,r,s){e.send({kind:"ClickResourceCenter",sessionId:t.id,description:r?g(r.name,{lookupAttribute:T(t.data)})+(s?` - ${s}`:""):s},{batch:!0})}var Ue=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",ResourceCenterApp:Ne,default:Ne});export{Se as A,je as G,Ue as R};
@@ -196,6 +196,7 @@
196
196
  color: #f4f8fb;
197
197
  }
198
198
  .btn--plain,
199
+ .btn--plain-secondary,
199
200
  .btn--plain-on-dark,
200
201
  .btn--plain-blue,
201
202
  .btn--plain-danger,
@@ -209,6 +210,7 @@
209
210
  min-width: 0;
210
211
  }
211
212
  .btn--plain:not(.btn--round):not(.btn--square),
213
+ .btn--plain-secondary:not(.btn--round):not(.btn--square),
212
214
  .btn--plain-on-dark:not(.btn--round):not(.btn--square),
213
215
  .btn--plain-blue:not(.btn--round):not(.btn--square),
214
216
  .btn--plain-danger:not(.btn--round):not(.btn--square),
@@ -216,6 +218,7 @@
216
218
  border-radius: 0.25em;
217
219
  }
218
220
  .btn--plain:not(.btn--round):not(.btn--square):focus-visible,
221
+ .btn--plain-secondary:not(.btn--round):not(.btn--square):focus-visible,
219
222
  .btn--plain-on-dark:not(.btn--round):not(.btn--square):focus-visible,
220
223
  .btn--plain-blue:not(.btn--round):not(.btn--square):focus-visible,
221
224
  .btn--plain-danger:not(.btn--round):not(.btn--square):focus-visible,
@@ -223,11 +226,13 @@
223
226
  box-shadow: 0 0 0 1px #fff, 0 0 0 4px rgba(47,105,238,0.35);
224
227
  }
225
228
  .btn--plain.btn--round:focus-visible.btn--focus-inset,
229
+ .btn--plain-secondary.btn--round:focus-visible.btn--focus-inset,
226
230
  .btn--plain-on-dark.btn--round:focus-visible.btn--focus-inset,
227
231
  .btn--plain-blue.btn--round:focus-visible.btn--focus-inset,
228
232
  .btn--plain-danger.btn--round:focus-visible.btn--focus-inset,
229
233
  .btn--plain-danger-alt.btn--round:focus-visible.btn--focus-inset,
230
234
  .btn--plain.btn--square:focus-visible.btn--focus-inset,
235
+ .btn--plain-secondary.btn--square:focus-visible.btn--focus-inset,
231
236
  .btn--plain-on-dark.btn--square:focus-visible.btn--focus-inset,
232
237
  .btn--plain-blue.btn--square:focus-visible.btn--focus-inset,
233
238
  .btn--plain-danger.btn--square:focus-visible.btn--focus-inset,
@@ -235,11 +240,13 @@
235
240
  box-shadow: inset 0 0 0 3px rgba(47,105,238,0.35);
236
241
  }
237
242
  .btn--plain.btn--round:focus-visible:not(.btn--focus-inset),
243
+ .btn--plain-secondary.btn--round:focus-visible:not(.btn--focus-inset),
238
244
  .btn--plain-on-dark.btn--round:focus-visible:not(.btn--focus-inset),
239
245
  .btn--plain-blue.btn--round:focus-visible:not(.btn--focus-inset),
240
246
  .btn--plain-danger.btn--round:focus-visible:not(.btn--focus-inset),
241
247
  .btn--plain-danger-alt.btn--round:focus-visible:not(.btn--focus-inset),
242
248
  .btn--plain.btn--square:focus-visible:not(.btn--focus-inset),
249
+ .btn--plain-secondary.btn--square:focus-visible:not(.btn--focus-inset),
243
250
  .btn--plain-on-dark.btn--square:focus-visible:not(.btn--focus-inset),
244
251
  .btn--plain-blue.btn--square:focus-visible:not(.btn--focus-inset),
245
252
  .btn--plain-danger.btn--square:focus-visible:not(.btn--focus-inset),
@@ -247,11 +254,13 @@
247
254
  box-shadow: 0 0 0 1px #fff, 0 0 0 4px rgba(47,105,238,0.35);
248
255
  }
249
256
  .btn--plain:hover:not(:disabled),
257
+ .btn--plain-secondary:hover:not(:disabled),
250
258
  .btn--plain-on-dark:hover:not(:disabled),
251
259
  .btn--plain-blue:hover:not(:disabled),
252
260
  .btn--plain-danger:hover:not(:disabled),
253
261
  .btn--plain-danger-alt:hover:not(:disabled),
254
262
  .btn--plain:focus-visible,
263
+ .btn--plain-secondary:focus-visible,
255
264
  .btn--plain-on-dark:focus-visible,
256
265
  .btn--plain-blue:focus-visible,
257
266
  .btn--plain-danger:focus-visible,
@@ -259,6 +268,7 @@
259
268
  background-color: rgba(26,87,230,0.1);
260
269
  }
261
270
  .btn--plain.btn--popover-open,
271
+ .btn--plain-secondary.btn--popover-open,
262
272
  .btn--plain-on-dark.btn--popover-open,
263
273
  .btn--plain-blue.btn--popover-open,
264
274
  .btn--plain-danger.btn--popover-open,
@@ -266,17 +276,22 @@
266
276
  background-color: rgba(26,87,230,0.1) !important;
267
277
  }
268
278
  .btn--plain:disabled,
279
+ .btn--plain-secondary:disabled,
269
280
  .btn--plain-on-dark:disabled,
270
281
  .btn--plain-blue:disabled,
271
282
  .btn--plain-danger:disabled,
272
283
  .btn--plain-danger-alt:disabled,
273
284
  .btn--plain.disabled,
285
+ .btn--plain-secondary.disabled,
274
286
  .btn--plain-on-dark.disabled,
275
287
  .btn--plain-blue.disabled,
276
288
  .btn--plain-danger.disabled,
277
289
  .btn--plain-danger-alt.disabled {
278
290
  color: #c3d5e0;
279
291
  }
292
+ .btn--plain-secondary {
293
+ color: #537388;
294
+ }
280
295
  .btn--plain-on-dark {
281
296
  color: #fff;
282
297
  }
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 6bbe7f23ab3a37d9a51409543cd309cba2638d8b
1
+ d4b01f8818dd94ba72f665d5a2052c006505ed6e
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1003417",
3
+ "version": "0.1.1003443",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/userflow.js CHANGED
@@ -1 +1 @@
1
- import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t,s){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t,this.humanMessage=s}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}getItem(e){return e=this.formatKey(e),"undefined"==typeof window?null:window[this.type].getItem(e)}setItem(e,t){e=this.formatKey(e),"undefined"!=typeof window&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),"undefined"!=typeof window)return window[this.type].removeItem(e)}clear(){if("undefined"!=typeof window)return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function f(e,t,{toOrigin:s}={}){e.postMessage(t,s||"*")}function T(e,{fromWindow:t,fromOrigin:s}={}){const i=i=>{if(!i.isTrusted)return;if(t&&t!==i.source)return;if(s&&i.origin!==s)return;const o=i.data;o&&"object"==typeof o&&"string"==typeof o.kind&&o.kind.startsWith("userflow:")&&!0===e(o)&&n()};window.addEventListener("message",i);const n=()=>window.removeEventListener("message",i);return n}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const w=new Set;let S=!1;function g(e){return function(){if(S)return;S=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),I()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{I()}))}(),w.add(e),()=>{p(e)}}function p(e){w.delete(e)}function I(){w.forEach((e=>e()))}class C{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){f(window.opener,e,{toOrigin:"https://userflow.com"})}onBuilderMessage(e){return this.unregisterOnMessage=T(e,{fromOrigin:"https://userflow.com"}),!1}async captureScreenshot(e,t,s,i){f(window,{kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{T((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,R,y,O,v,N,_,b,D,F,M,B,P,x,H,G,W,$,V,j,K,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,fe,Te,we,Se,ge,pe,Ie,Ce,me,ke,Ae,Ue,Le,Re,ye,Oe,ve,Ne,_e,be,De,Fe,Me,Be,Pe,xe,He,Ge,We,$e;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(R=L||(L={})).ACTION="ACTION",R.DRAFT="DRAFT",R.LINK="LINK",R.LAUNCHER_SEEN="LAUNCHER_SEEN",R.RESOURCE_CENTER="RESOURCE_CENTER",R.USERFLOWJS="USERFLOWJS",(O=y||(y={})).LIKE="LIKE",O.DISLIKE="DISLIKE",(N=v||(v={})).STRING="STRING",N.BOOLEAN="BOOLEAN",N.NUMBER="NUMBER",N.DATETIME="DATETIME",N.LIST="LIST",N.RANDOM_AB="RANDOM_AB",N.RANDOM_NUMBER="RANDOM_NUMBER",(b=_||(_={})).FLOW="FLOW",b.CHECKLIST="CHECKLIST",b.LAUNCHER="LAUNCHER",b.RESOURCE_CENTER="RESOURCE_CENTER",(F=D||(D={})).ALWAYS_TRUE="ALWAYS_TRUE",F.ATTRIBUTE="ATTRIBUTE",F.CLAUSE="CLAUSE",F.ELEMENT="ELEMENT",F.FILLED_IN_INPUT="FILLED_IN_INPUT",F.FLOW="FLOW",F.INPUT_VALUE="INPUT_VALUE",F.PAGE="PAGE",F.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(M||(M={})),(B||(B={})).INPUT="INPUT",(x=P||(P={})).ABSOLUTE_EQ="ABSOLUTE_EQ",x.ABSOLUTE_GT="ABSOLUTE_GT",x.ABSOLUTE_LT="ABSOLUTE_LT",x.AND="AND",x.BETWEEN="BETWEEN",x.CONTAINS="CONTAINS",x.EMPTY="EMPTY",x.ENDS_WITH="ENDS_WITH",x.EQ="EQ",x.EXCLUDES_ALL="EXCLUDES_ALL",x.EXCLUDES_ANY="EXCLUDES_ANY",x.FALSE="FALSE",x.GT="GT",x.GTE="GTE",x.INCLUDES_ALL="INCLUDES_ALL",x.INCLUDES_ANY="INCLUDES_ANY",x.LT="LT",x.LTE="LTE",x.NE="NE",x.NOT_CONTAINS="NOT_CONTAINS",x.NOT_EMPTY="NOT_EMPTY",x.NOT_REGEX="NOT_REGEX",x.OR="OR",x.REGEX="REGEX",x.RELATIVE_EQ="RELATIVE_EQ",x.RELATIVE_GT="RELATIVE_GT",x.RELATIVE_LT="RELATIVE_LT",x.STARTS_WITH="STARTS_WITH",x.TRUE="TRUE",x.URL="URL",(G=H||(H={})).CLICK="CLICK",G.DISABLED="DISABLED",G.MOUSEDOWN="MOUSEDOWN",G.NOT_CLICK="NOT_CLICK",G.NOT_DISABLED="NOT_DISABLED",G.NOT_PRESENT="NOT_PRESENT",G.PRESENT="PRESENT",($=W||(W={})).ASSET="ASSET",$.CARTOON="CARTOON",$.NONE="NONE",$.URL="URL",(j=V||(V={})).INSIDE="INSIDE",j.OUTSIDE="OUTSIDE",(z=K||(K={})).TOP_LEFT="TOP_LEFT",z.TOP_CENTER="TOP_CENTER",z.TOP_RIGHT="TOP_RIGHT",z.BOTTOM_RIGHT="BOTTOM_RIGHT",z.BOTTOM_CENTER="BOTTOM_CENTER",z.BOTTOM_LEFT="BOTTOM_LEFT",z.CENTER="CENTER",(J=Y||(Y={})).GOOGLE="GOOGLE",J.STANDARD="STANDARD",(Z=X||(X={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",Z.DISMISS="DISMISS",(q=Q||(Q={})).DISMISS="DISMISS",q.NONE="NONE",(te=ee||(ee={})).DEFAULT="DEFAULT",te.PLAINTEXT="PLAINTEXT",(ie=se||(se={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",ie.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",ie.NONE="NONE",(oe=ne||(ne={})).BUBBLE="BUBBLE",oe.END="END",oe.ERROR="ERROR",oe.FLAG="FLAG",(ae=re||(re={})).MANUAL="MANUAL",ae.NONE="NONE",ae.SYNTHETIC="SYNTHETIC",(le=ce||(ce={})).BUBBLE="BUBBLE",le.HIDDEN="HIDDEN",le.MODAL="MODAL",le.TOOLTIP="TOOLTIP",(he=de||(de={})).ABOVE="ABOVE",he.BELOW="BELOW",he.LEFT="LEFT",he.RIGHT="RIGHT",(Ee=ue||(ue={})).CLOSE_FLOW="CLOSE_FLOW",Ee.EVAL_JS="EVAL_JS",Ee.GO_TO_STEP="GO_TO_STEP",Ee.NAVIGATE="NAVIGATE",Ee.SET_ATTRIBUTE="SET_ATTRIBUTE",Ee.SNOOZE="SNOOZE",Ee.START_FLOW="START_FLOW",(Te=fe||(fe={})).NEW_TAB="NEW_TAB",Te.SAME_TAB="SAME_TAB",(Se=we||(we={})).SET="SET",Se.SET_ONCE="SET_ONCE",Se.ADD="ADD",Se.SUBTRACT="SUBTRACT",Se.UNSET="UNSET",(pe=ge||(ge={})).MULTILINE_TEXT="MULTILINE_TEXT",pe.MULTIPLE_CHOICE="MULTIPLE_CHOICE",pe.NPS="NPS",pe.SCALE="SCALE",pe.STARS="STARS",pe.TEXT="TEXT",(Ce=Ie||(Ie={})).ACTION="ACTION",Ce.ASSISTANT="ASSISTANT",Ce.CHECKLIST="CHECKLIST",Ce.CONTACT="CONTACT",Ce.FLOWS="FLOWS",Ce.KNOWLEDGE_BASE="KNOWLEDGE_BASE",Ce.MESSAGE="MESSAGE",Ce.SUBPAGE="SUBPAGE",(ke=me||(me={})).CRISP="CRISP",ke.CUSTOM="CUSTOM",ke.FRESHCHAT="FRESHCHAT",ke.HELPSCOUT="HELPSCOUT",ke.HUBSPOT="HUBSPOT",ke.INTERCOM="INTERCOM",ke.ZENDESK="ZENDESK",ke.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(Ue=Ae||(Ae={})).BUTTON="BUTTON",Ue.INPUT="INPUT",(Re=Le||(Le={})).LAUNCHER_CLICK="LAUNCHER_CLICK",Re.LAUNCHER_HOVER="LAUNCHER_HOVER",Re.TARGET_CLICK="TARGET_CLICK",Re.TARGET_HOVER="TARGET_HOVER",Re.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",Re.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(Oe=ye||(ye={})).ACTIVATE="ACTIVATE",Oe.DEACTIVATE="DEACTIVATE",Oe.NEVER="NEVER",(Ne=ve||(ve={})).AUTO="AUTO",Ne.TOP="TOP",Ne.RIGHT="RIGHT",Ne.BOTTOM="BOTTOM",Ne.LEFT="LEFT",(be=_e||(_e={})).START="START",be.CENTER="CENTER",be.END="END",(Fe=De||(De={})).PERCENT="PERCENT",Fe.PX="PX",(Be=Me||(Me={})).BEACON="BEACON",Be.BUTTON="BUTTON",Be.HIDDEN="HIDDEN",Be.ICON="ICON",(xe=Pe||(Pe={})).LAUNCHER="LAUNCHER",xe.TARGET="TARGET",(Ge=He||(He={})).ACTIVE="ACTIVE",Ge.COMPLETED="COMPLETED",Ge.ENDED="ENDED",Ge.NOT_SEEN="NOT_SEEN",($e=We||(We={})).HIGHLIGHT="HIGHLIGHT",$e.MODAL="MODAL",$e.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const Ve={customInputs:[],customNavigate:null,urlFilter:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500};function je(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function Ke(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function ze(){let e=d();if(Ve.urlFilter){if(e=Ve.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}const Ye=(localStorage.getItem("debug")||"").split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),Je=Ze("log");let Xe;function Ze(e){return function(t,...s){if(Ye){const i=performance.now(),n=Xe?Math.round(i-Xe):0;Xe=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}Je.group=Ze("group"),Je.groupCollapsed=Ze("groupCollapsed"),Je.groupEnd=function(){Ye&&console.groupEnd()};const Qe=()=>n((()=>import("./ResourceCenterApp.js").then((function(e){return e.R}))),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()]);function qe(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class et{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const tt=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],st=import.meta.url;class it{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{Je(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}}));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{this.ui?.container&&!document.contains(this.ui.container)&&(Je("remounting UI because container was missing"),this.remount())},Je("constructor, build=1003417"),g(this.onUrlChange),this.setTargetEnv(new C),this.checkTestUserAtBoot(),this.toggleUI();for(const e of tt)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){Je("destroy"),this.reset(),p(this.onUrlChange),this.destroyTargetEnv();for(const e of tt)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=c.getItem("userflowClientState");if(s)try{e=JSON.parse(s)}catch(t){console.error("Userflow.js: Parse ElementSelectionState error:",t)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null})}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(Je("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:(new Date).toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if(Je("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?Je("init() ignoring new token since a test user has been identified"):(this.clientToken&&(Je("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",Je("connecting to socket");let t="e.userflow.com";"js.getuserflow.com"===new URL(st).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{Je("socket opened")})),this.socket.onClose((()=>{this.emit("private:disconnect")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),Je("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1003417",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return Je("channel join payload",t),t}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout((()=>{this.hasDraftSession()||this.assistantMessageInProgress?this.debounceInactiveDisconnect():(Je("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,endBatch:s,handlesRejection:i}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),s?this.endBatch():this.endBatchTimeout=window.setTimeout((()=>{this.endBatch()}),50)),this.sendRaw(e,{handlesRejection:i})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel){const s=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(t)throw Error(s);return void console.log(s,"\nClient message:",e)}Je(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n=`Userflow.js send ${e.kind} got phx_error`;console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(t=>{r();const s=`Userflow.js error reply (${t.code}): ${t.message}`;console.log(s,"\nClient message:",e,"\nError:",t),i(new o(s,t.code,t.message))}))}))}endBatch(){this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){Je(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,resourceCenterSession:r}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"AssistantMessageEventWrapper":return void this.emit("private:assistantMessageEvent",e);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void Je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):Je(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):Je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetChecklistSession":return o>t?void Je(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void Je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(r?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if(Je("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)Je("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(Je("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){Je("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if(Je("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)Je("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){Je("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once??i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return v.STRING;case"number":return v.NUMBER;case"boolean":return v.BOOLEAN;case"datetime":return v.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=v.STRING;break;case"boolean":n=v.BOOLEAN;break;case"integer":case"decimal":n=v.NUMBER;break;case"datetime":n=v.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){Je(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout((()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()}),0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&(Je(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();this.clientContext&&e.pageUrl===this.clientContext.pageUrl||(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:ze(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){Je("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach(((e,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),Je(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return Je("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),Je("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){this.checklistSession&&this.checklistExpandPending&&(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),this.resourceCenterSession&&!this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),c.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){this.resourceCenterSession&&this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),c.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:t}=this;return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?qe(t):0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===Ie.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===_.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===_.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){Je("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){Je("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){Je("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===_.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setResourceCenterSession(e){const t=this.resourceCenterSession;this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===ye.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(Je("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(Je("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.resourceCenterSession&&Qe();const{RealUI:t}=await e;return new t(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;Je("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new et([]),condition:e,callback:t=>{i.isTrue!==t&&(Je("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&(Je("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new et(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})}}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,Je("csp issue detected"),f(window,{kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new it;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>window.userflow.endAll(),async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&Ve.customInputs.push({cssSelector:e})},registerCustomInput(e,t){Ve.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){Ve.customNavigate=e},setUrlFilter(e){Ve.urlFilter=e},setInferenceAttributeNames(e){Ve.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){Ve.inferenceAttributeFilters[e]=je(t)},setInferenceClassNameFilter(e){Ve.inferenceClassNameFilters=je(e)},setScrollPadding(e){Ve.scrollPadding=e},setCustomScrollIntoView(e){Ve.customScrollIntoView=e},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(t){e.pageTrackingDisabled=t},setBaseZIndex(e){Ve.baseZIndex=e},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;Je(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}Je("queue processed")}()}export{W as A,V as B,me as C,X as D,m as E,P as F,ne as G,ce as H,K as I,de as J,Le as K,Me as L,Q as M,ve as N,Pe as O,_e as P,De as Q,Qe as R,L as S,tt as T,o as U,re as V,y as W,n as _,B as a,M as b,Ve as c,Je as d,D as e,H as f,ze as g,Ie as h,c as i,qe as j,se as k,ee as l,ue as m,Ae as n,g as o,_ as p,d as q,fe as r,l as s,Ke as t,p as u,we as v,ge as w,et as x,Y as y,a as z};export default window.userflow;
1
+ import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t,s){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t,this.humanMessage=s}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}getItem(e){return e=this.formatKey(e),"undefined"==typeof window?null:window[this.type].getItem(e)}setItem(e,t){e=this.formatKey(e),"undefined"!=typeof window&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),"undefined"!=typeof window)return window[this.type].removeItem(e)}clear(){if("undefined"!=typeof window)return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function f(e,t,{toOrigin:s}={}){e.postMessage(t,s||"*")}function T(e,{fromWindow:t,fromOrigin:s}={}){const i=i=>{if(!i.isTrusted)return;if(t&&t!==i.source)return;if(s&&i.origin!==s)return;const o=i.data;o&&"object"==typeof o&&"string"==typeof o.kind&&o.kind.startsWith("userflow:")&&!0===e(o)&&n()};window.addEventListener("message",i);const n=()=>window.removeEventListener("message",i);return n}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const w=new Set;let S=!1;function g(e){return function(){if(S)return;S=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),I()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{I()}))}(),w.add(e),()=>{p(e)}}function p(e){w.delete(e)}function I(){w.forEach((e=>e()))}class C{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){f(window.opener,e,{toOrigin:"https://userflow.com"})}onBuilderMessage(e){return this.unregisterOnMessage=T(e,{fromOrigin:"https://userflow.com"}),!1}async captureScreenshot(e,t,s,i){f(window,{kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{T((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,R,y,O,v,N,_,b,D,F,M,B,P,x,H,G,W,$,V,j,K,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,fe,Te,we,Se,ge,pe,Ie,Ce,me,ke,Ae,Ue,Le,Re,ye,Oe,ve,Ne,_e,be,De,Fe,Me,Be,Pe,xe,He,Ge,We,$e;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(R=L||(L={})).ACTION="ACTION",R.DRAFT="DRAFT",R.LINK="LINK",R.LAUNCHER_SEEN="LAUNCHER_SEEN",R.RESOURCE_CENTER="RESOURCE_CENTER",R.USERFLOWJS="USERFLOWJS",(O=y||(y={})).LIKE="LIKE",O.DISLIKE="DISLIKE",(N=v||(v={})).STRING="STRING",N.BOOLEAN="BOOLEAN",N.NUMBER="NUMBER",N.DATETIME="DATETIME",N.LIST="LIST",N.RANDOM_AB="RANDOM_AB",N.RANDOM_NUMBER="RANDOM_NUMBER",(b=_||(_={})).FLOW="FLOW",b.CHECKLIST="CHECKLIST",b.LAUNCHER="LAUNCHER",b.RESOURCE_CENTER="RESOURCE_CENTER",(F=D||(D={})).ALWAYS_TRUE="ALWAYS_TRUE",F.ATTRIBUTE="ATTRIBUTE",F.CLAUSE="CLAUSE",F.ELEMENT="ELEMENT",F.FILLED_IN_INPUT="FILLED_IN_INPUT",F.FLOW="FLOW",F.INPUT_VALUE="INPUT_VALUE",F.PAGE="PAGE",F.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(M||(M={})),(B||(B={})).INPUT="INPUT",(x=P||(P={})).ABSOLUTE_EQ="ABSOLUTE_EQ",x.ABSOLUTE_GT="ABSOLUTE_GT",x.ABSOLUTE_LT="ABSOLUTE_LT",x.AND="AND",x.BETWEEN="BETWEEN",x.CONTAINS="CONTAINS",x.EMPTY="EMPTY",x.ENDS_WITH="ENDS_WITH",x.EQ="EQ",x.EXCLUDES_ALL="EXCLUDES_ALL",x.EXCLUDES_ANY="EXCLUDES_ANY",x.FALSE="FALSE",x.GT="GT",x.GTE="GTE",x.INCLUDES_ALL="INCLUDES_ALL",x.INCLUDES_ANY="INCLUDES_ANY",x.LT="LT",x.LTE="LTE",x.NE="NE",x.NOT_CONTAINS="NOT_CONTAINS",x.NOT_EMPTY="NOT_EMPTY",x.NOT_REGEX="NOT_REGEX",x.OR="OR",x.REGEX="REGEX",x.RELATIVE_EQ="RELATIVE_EQ",x.RELATIVE_GT="RELATIVE_GT",x.RELATIVE_LT="RELATIVE_LT",x.STARTS_WITH="STARTS_WITH",x.TRUE="TRUE",x.URL="URL",(G=H||(H={})).CLICK="CLICK",G.DISABLED="DISABLED",G.MOUSEDOWN="MOUSEDOWN",G.NOT_CLICK="NOT_CLICK",G.NOT_DISABLED="NOT_DISABLED",G.NOT_PRESENT="NOT_PRESENT",G.PRESENT="PRESENT",($=W||(W={})).ASSET="ASSET",$.CARTOON="CARTOON",$.NONE="NONE",$.URL="URL",(j=V||(V={})).INSIDE="INSIDE",j.OUTSIDE="OUTSIDE",(z=K||(K={})).TOP_LEFT="TOP_LEFT",z.TOP_CENTER="TOP_CENTER",z.TOP_RIGHT="TOP_RIGHT",z.BOTTOM_RIGHT="BOTTOM_RIGHT",z.BOTTOM_CENTER="BOTTOM_CENTER",z.BOTTOM_LEFT="BOTTOM_LEFT",z.CENTER="CENTER",(J=Y||(Y={})).GOOGLE="GOOGLE",J.STANDARD="STANDARD",(Z=X||(X={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",Z.DISMISS="DISMISS",(q=Q||(Q={})).DISMISS="DISMISS",q.NONE="NONE",(te=ee||(ee={})).DEFAULT="DEFAULT",te.PLAINTEXT="PLAINTEXT",(ie=se||(se={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",ie.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",ie.NONE="NONE",(oe=ne||(ne={})).BUBBLE="BUBBLE",oe.END="END",oe.ERROR="ERROR",oe.FLAG="FLAG",(ae=re||(re={})).MANUAL="MANUAL",ae.NONE="NONE",ae.SYNTHETIC="SYNTHETIC",(le=ce||(ce={})).BUBBLE="BUBBLE",le.HIDDEN="HIDDEN",le.MODAL="MODAL",le.TOOLTIP="TOOLTIP",(he=de||(de={})).ABOVE="ABOVE",he.BELOW="BELOW",he.LEFT="LEFT",he.RIGHT="RIGHT",(Ee=ue||(ue={})).CLOSE_FLOW="CLOSE_FLOW",Ee.EVAL_JS="EVAL_JS",Ee.GO_TO_STEP="GO_TO_STEP",Ee.NAVIGATE="NAVIGATE",Ee.SET_ATTRIBUTE="SET_ATTRIBUTE",Ee.SNOOZE="SNOOZE",Ee.START_FLOW="START_FLOW",(Te=fe||(fe={})).NEW_TAB="NEW_TAB",Te.SAME_TAB="SAME_TAB",(Se=we||(we={})).SET="SET",Se.SET_ONCE="SET_ONCE",Se.ADD="ADD",Se.SUBTRACT="SUBTRACT",Se.UNSET="UNSET",(pe=ge||(ge={})).MULTILINE_TEXT="MULTILINE_TEXT",pe.MULTIPLE_CHOICE="MULTIPLE_CHOICE",pe.NPS="NPS",pe.SCALE="SCALE",pe.STARS="STARS",pe.TEXT="TEXT",(Ce=Ie||(Ie={})).ACTION="ACTION",Ce.ASSISTANT="ASSISTANT",Ce.CHECKLIST="CHECKLIST",Ce.CONTACT="CONTACT",Ce.FLOWS="FLOWS",Ce.KNOWLEDGE_BASE="KNOWLEDGE_BASE",Ce.MESSAGE="MESSAGE",Ce.SUBPAGE="SUBPAGE",(ke=me||(me={})).CRISP="CRISP",ke.CUSTOM="CUSTOM",ke.FRESHCHAT="FRESHCHAT",ke.HELPSCOUT="HELPSCOUT",ke.HUBSPOT="HUBSPOT",ke.INTERCOM="INTERCOM",ke.ZENDESK="ZENDESK",ke.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(Ue=Ae||(Ae={})).BUTTON="BUTTON",Ue.INPUT="INPUT",(Re=Le||(Le={})).LAUNCHER_CLICK="LAUNCHER_CLICK",Re.LAUNCHER_HOVER="LAUNCHER_HOVER",Re.TARGET_CLICK="TARGET_CLICK",Re.TARGET_HOVER="TARGET_HOVER",Re.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",Re.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(Oe=ye||(ye={})).ACTIVATE="ACTIVATE",Oe.DEACTIVATE="DEACTIVATE",Oe.NEVER="NEVER",(Ne=ve||(ve={})).AUTO="AUTO",Ne.TOP="TOP",Ne.RIGHT="RIGHT",Ne.BOTTOM="BOTTOM",Ne.LEFT="LEFT",(be=_e||(_e={})).START="START",be.CENTER="CENTER",be.END="END",(Fe=De||(De={})).PERCENT="PERCENT",Fe.PX="PX",(Be=Me||(Me={})).BEACON="BEACON",Be.BUTTON="BUTTON",Be.HIDDEN="HIDDEN",Be.ICON="ICON",(xe=Pe||(Pe={})).LAUNCHER="LAUNCHER",xe.TARGET="TARGET",(Ge=He||(He={})).ACTIVE="ACTIVE",Ge.COMPLETED="COMPLETED",Ge.ENDED="ENDED",Ge.NOT_SEEN="NOT_SEEN",($e=We||(We={})).HIGHLIGHT="HIGHLIGHT",$e.MODAL="MODAL",$e.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const Ve={customInputs:[],customNavigate:null,urlFilter:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500};function je(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function Ke(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function ze(){let e=d();if(Ve.urlFilter){if(e=Ve.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}const Ye=(localStorage.getItem("debug")||"").split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),Je=Ze("log");let Xe;function Ze(e){return function(t,...s){if(Ye){const i=performance.now(),n=Xe?Math.round(i-Xe):0;Xe=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}Je.group=Ze("group"),Je.groupCollapsed=Ze("groupCollapsed"),Je.groupEnd=function(){Ye&&console.groupEnd()};const Qe=()=>n((()=>import("./ResourceCenterApp.js").then((function(e){return e.R}))),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()]);function qe(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class et{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const tt=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],st=import.meta.url;class it{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{Je(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}}));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{this.ui?.container&&!document.contains(this.ui.container)&&(Je("remounting UI because container was missing"),this.remount())},Je("constructor, build=1003443"),g(this.onUrlChange),this.setTargetEnv(new C),this.checkTestUserAtBoot(),this.toggleUI();for(const e of tt)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){Je("destroy"),this.reset(),p(this.onUrlChange),this.destroyTargetEnv();for(const e of tt)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=c.getItem("userflowClientState");if(s)try{e=JSON.parse(s)}catch(t){console.error("Userflow.js: Parse ElementSelectionState error:",t)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null})}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(Je("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:(new Date).toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if(Je("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?Je("init() ignoring new token since a test user has been identified"):(this.clientToken&&(Je("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",Je("connecting to socket");let t="e.userflow.com";"js.getuserflow.com"===new URL(st).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{Je("socket opened")})),this.socket.onClose((()=>{this.emit("private:disconnect")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),Je("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1003443",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return Je("channel join payload",t),t}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout((()=>{this.hasDraftSession()||this.assistantMessageInProgress?this.debounceInactiveDisconnect():(Je("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,endBatch:s,handlesRejection:i}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),s?this.endBatch():this.endBatchTimeout=window.setTimeout((()=>{this.endBatch()}),50)),this.sendRaw(e,{handlesRejection:i})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel){const s=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(t)throw Error(s);return void console.log(s,"\nClient message:",e)}Je(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n=`Userflow.js send ${e.kind} got phx_error`;console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(t=>{r();const s=`Userflow.js error reply (${t.code}): ${t.message}`;console.log(s,"\nClient message:",e,"\nError:",t),i(new o(s,t.code,t.message))}))}))}endBatch(){this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){Je(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,resourceCenterSession:r}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"AssistantMessageEventWrapper":return void this.emit("private:assistantMessageEvent",e);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void Je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):Je(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):Je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetChecklistSession":return o>t?void Je(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void Je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(r?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if(Je("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)Je("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(Je("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){Je("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if(Je("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)Je("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){Je("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once??i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return v.STRING;case"number":return v.NUMBER;case"boolean":return v.BOOLEAN;case"datetime":return v.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=v.STRING;break;case"boolean":n=v.BOOLEAN;break;case"integer":case"decimal":n=v.NUMBER;break;case"datetime":n=v.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){Je(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout((()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()}),0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&(Je(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();this.clientContext&&e.pageUrl===this.clientContext.pageUrl||(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:ze(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){Je("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach(((e,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),Je(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return Je("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),Je("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){this.checklistSession&&this.checklistExpandPending&&(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),this.resourceCenterSession&&!this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),c.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){this.resourceCenterSession&&this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),c.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:t}=this;return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?qe(t):0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===Ie.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===_.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===_.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){Je("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){Je("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){Je("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===_.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setResourceCenterSession(e){const t=this.resourceCenterSession;this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===ye.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(Je("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(Je("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.resourceCenterSession&&Qe();const{RealUI:t}=await e;return new t(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;Je("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new et([]),condition:e,callback:t=>{i.isTrue!==t&&(Je("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&(Je("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new et(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})}}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,Je("csp issue detected"),f(window,{kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new it;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>window.userflow.endAll(),async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&Ve.customInputs.push({cssSelector:e})},registerCustomInput(e,t){Ve.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){Ve.customNavigate=e},setUrlFilter(e){Ve.urlFilter=e},setInferenceAttributeNames(e){Ve.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){Ve.inferenceAttributeFilters[e]=je(t)},setInferenceClassNameFilter(e){Ve.inferenceClassNameFilters=je(e)},setScrollPadding(e){Ve.scrollPadding=e},setCustomScrollIntoView(e){Ve.customScrollIntoView=e},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(t){e.pageTrackingDisabled=t},setBaseZIndex(e){Ve.baseZIndex=e},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;Je(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}Je("queue processed")}()}export{W as A,V as B,me as C,X as D,m as E,P as F,ne as G,ce as H,K as I,de as J,Le as K,Me as L,Q as M,ve as N,Pe as O,_e as P,De as Q,Qe as R,L as S,tt as T,o as U,re as V,y as W,n as _,B as a,M as b,Ve as c,Je as d,D as e,H as f,ze as g,Ie as h,c as i,qe as j,se as k,ee as l,ue as m,Ae as n,g as o,_ as p,d as q,fe as r,l as s,Ke as t,p as u,we as v,ge as w,et as x,Y as y,a as z};export default window.userflow;