userflow.js-self-hosted 0.1.1005270 → 0.1.1005315

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/BannerApp.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{I as t,E as s}from"./userflow.js";import{u as o,i as r}from"./client-context.js";import{o as n}from"./vendor.obj-str.js";import{u as a,a as l,D as i}from"./stylesheets.js";import{a as m}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{S as d,b as c,R as u,B as f}from"./bubble-frame.styl.js";import{f as b,b as E}from"./flow-condition-types.js";import{w as j,f as p}from"./flow-host.styl.js";import{u as g}from"./use-selector-element-monitoring.js";import{r as w}from"./vendor.react-dom.js";import{F as y}from"./use-window-resize.js";import{u as v}from"./use-element-rect.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.js";import"./vendor.scheduler.js";const h=({session:h})=>{const L=o(),{version:S}=h,T=S.banner,k=a(S.theme),N=h.locale?h.locale.standardLocaleId:h.version.theme.languageId;e.useEffect((()=>{r.changeLanguage(N)}),[N]);const M=e.useMemo((()=>document.createElement("div")),[]),[R,x]=e.useState(!1),{loaded:A}=l(window,p,k),[B,_]=e.useState(!1),C=A&&B,[F,I]=e.useState(0),D=e.useCallback((()=>{_(!1),I((e=>e+1))}),[]),O=![t.BODY_FIRST,t.BODY_LAST].includes(T.embedMode),[$,W]=e.useState(null),Y=e.useCallback((({targetEl:e})=>{W(e)}),[]),z=e.useCallback((()=>{O&&console.warn(`Userflow.js: Could not find embed element for banner "${h.flow.name||h.flow.id}"`),W(null)}),[O,h.flow.name,h.flow.id]);g({selector:T.embedSelector,targetMoved:Y,targetLost:z});const P=e.useCallback((()=>{M.parentElement?.removeChild(M),x(!1),D()}),[M,D]);e.useLayoutEffect((()=>{let e=null,s=null;if(O){if(!$)return void P();if(T.overlay||T.sticky){s=T.embedMode===t.ELEMENT_BEFORE||T.embedMode===t.ELEMENT_AFTER?$.parentElement:$;"static"===window.getComputedStyle(s).position&&(e=s.style.position,s.style.position="relative")}}switch(T.embedMode){case t.BODY_FIRST:document.body.insertAdjacentElement("afterbegin",M);break;case t.BODY_LAST:document.body.insertAdjacentElement("beforeend",M);break;case t.ELEMENT_FIRST:$.insertAdjacentElement("afterbegin",M);break;case t.ELEMENT_LAST:$.insertAdjacentElement("beforeend",M);break;case t.ELEMENT_BEFORE:$.insertAdjacentElement("beforebegin",M);break;case t.ELEMENT_AFTER:$.insertAdjacentElement("afterend",M)}return x(!0),D(),()=>{s&&null!=e&&(s.style.position=e)}}),[P,M,O,$,T.overlay,T.sticky,T.embedMode,D]),e.useLayoutEffect((()=>P),[P]);const U=n({"userflowjs-banner":!0,[`userflowjs-banner--animate-${String(T.animate)}`]:!0,[`userflowjs-banner--embed-mode-${T.embedMode}`]:!0,[`userflowjs-banner--sticky-${String(T.sticky)}`]:!0,[`userflowjs-banner--overlay-${T.overlay}`]:!0});e.useLayoutEffect((()=>{M.className=U||""}),[M,U]);const q=T.zIndex||j(0);e.useLayoutEffect((()=>{M.style.zIndex=null==q?"":String(q),M.style.position=C?"":"absolute",M.style.visibility=C?"":"hidden"}),[M,q,C]);const{height:G,setEl:H}=v();return e.useLayoutEffect((()=>{M.style.setProperty("--userflowjs-banner-height",b(G+(T.marginTop||0)+(T.marginBottom||0))||"")}),[M,G,T.marginTop,T.marginBottom]),R?w.createPortal(e.createElement(d.Provider,{value:h},e.createElement(y,{key:F,className:"userflowjs-banner-frame",style:{maxWidth:b(T.maxWidth),marginTop:b(T.marginTop),marginRight:b(T.marginRight),marginBottom:b(T.marginBottom),marginLeft:b(T.marginLeft),borderRadius:b(T.borderRadius)},stylesheet:c,theme:k,onStylesheetsLoad:_},e.createElement("div",{ref:H,className:n({"userflowjs-banner-root":!0,[`userflowjs-banner-root--content-layout-${T.contentLayout}`]:!0,"userflowjs-theme-root":!0}),dir:r.dir()},e.createElement("div",{className:"userflowjs-banner-start-spacer"}),e.createElement("div",{className:"userflowjs-banner-inner",style:{maxWidth:b(T.maxContentWidth)}},e.createElement("div",{className:"userflowjs-banner-content"},e.createElement(u,{doc:T.content,lookupAttribute:E(h.data)})),T.buttons.length>0&&e.createElement("div",{className:"userflowjs-banner-buttons"},T.buttons.map((t=>e.createElement(f,{key:t.id,button:t}))))),S.closeDisabled?e.createElement("div",{className:"userflowjs-banner-start-spacer"}):e.createElement("button",{"data-testid":"userflow-banner-dismiss",className:"userflowjs-banner-close",onClick:()=>L.endFlow(h,{endReason:s.USER_CLOSED})},e.createElement(i,{icon:m}))))),M):null};export default h;export{h as BannerApp};
1
+ import{r as e}from"./vendor.react.js";import{I as t,E as s}from"./userflow.js";import{u as o,i as r}from"./client-context.js";import{o as n}from"./vendor.obj-str.js";import{u as a,a as l,D as i}from"./stylesheets.js";import{a as m}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{S as d,b as c,R as u,B as f}from"./bubble-frame.styl.js";import{f as b,b as E}from"./flow-condition-types.js";import{w as j,f as p}from"./flow-host.styl.js";import{u as g}from"./use-selector-element-monitoring.js";import{r as w}from"./vendor.react-dom.js";import{F as y}from"./use-window-resize.js";import{u as v}from"./use-element-rect.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.js";import"./vendor.scheduler.js";const h=({session:h})=>{const L=o(),{version:S}=h,T=S.banner,k=a(S.theme),N=h.locale?h.locale.standardLocaleId:h.version.theme.languageId;e.useEffect((()=>{r.changeLanguage(N)}),[N]);const M=e.useMemo((()=>document.createElement("div")),[]),[R,x]=e.useState(!1),{loaded:A}=l(window,p,k),[B,_]=e.useState(!1),C=A&&B,[F,I]=e.useState(0),D=e.useCallback((()=>{_(!1),I((e=>e+1))}),[]),O=![t.BODY_FIRST,t.BODY_LAST].includes(T.embedMode),[$,W]=e.useState(null),Y=e.useCallback((({targetEl:e})=>{W(e)}),[]),z=e.useCallback((()=>{O&&console.warn(`Userflow.js: Could not find embed element for banner "${h.flow.name||h.flow.id}"`),W(null)}),[O,h.flow.name,h.flow.id]);g({selector:T.embedSelector,targetMoved:Y,targetLost:z});const P=e.useCallback((()=>{M.parentElement?.removeChild(M),x(!1),D()}),[M,D]);e.useLayoutEffect((()=>{let e=null,s=null;if(O){if(!$)return void P();if(T.overlay||T.sticky){s=T.embedMode===t.ELEMENT_BEFORE||T.embedMode===t.ELEMENT_AFTER?$.parentElement:$;"static"===window.getComputedStyle(s).position&&(e=s.style.position,s.style.position="relative")}}switch(T.embedMode){case t.BODY_FIRST:document.body.insertAdjacentElement("afterbegin",M);break;case t.BODY_LAST:document.body.insertAdjacentElement("beforeend",M);break;case t.ELEMENT_FIRST:$.insertAdjacentElement("afterbegin",M);break;case t.ELEMENT_LAST:$.insertAdjacentElement("beforeend",M);break;case t.ELEMENT_BEFORE:$.insertAdjacentElement("beforebegin",M);break;case t.ELEMENT_AFTER:$.insertAdjacentElement("afterend",M)}return x(!0),D(),()=>{s&&null!=e&&(s.style.position=e)}}),[P,M,O,$,T.overlay,T.sticky,T.embedMode,D]),e.useLayoutEffect((()=>P),[P]);const U=n({"userflowjs-banner":!0,[`userflowjs-banner--animate-${String(T.animate)}`]:!0,[`userflowjs-banner--embed-mode-${T.embedMode}`]:!0,[`userflowjs-banner--sticky-${String(T.sticky)}`]:!0,[`userflowjs-banner--overlay-${T.overlay}`]:!0});e.useLayoutEffect((()=>{M.className=U||""}),[M,U]);const q=T.zIndex||j(0);e.useLayoutEffect((()=>{M.style.zIndex=null==q?"":String(q),M.style.position=C?"":"absolute",M.style.visibility=C?"":"hidden"}),[M,q,C]);const{height:G,setEl:H}=v();return e.useLayoutEffect((()=>{M.style.setProperty("--userflowjs-banner-height",b(G+(T.marginTop||0)+(T.marginBottom||0))||"")}),[M,G,T.marginTop,T.marginBottom]),R?w.createPortal(e.createElement(d.Provider,{value:h},e.createElement(y,{key:F,className:"userflowjs-banner-frame",style:{maxWidth:b(T.maxWidth),marginTop:b(T.marginTop),marginRight:b(T.marginRight),marginBottom:b(T.marginBottom),marginLeft:b(T.marginLeft),borderRadius:b(T.borderRadius)},stylesheet:c,theme:k,onStylesheetsLoad:_,title:"Banner"},e.createElement("div",{ref:H,className:n({"userflowjs-banner-root":!0,[`userflowjs-banner-root--content-layout-${T.contentLayout}`]:!0,"userflowjs-theme-root":!0}),dir:r.dir()},e.createElement("div",{className:"userflowjs-banner-start-spacer"}),e.createElement("div",{className:"userflowjs-banner-inner",style:{maxWidth:b(T.maxContentWidth)}},e.createElement("div",{className:"userflowjs-banner-content"},e.createElement(u,{doc:T.content,lookupAttribute:E(h.data)})),T.buttons.length>0&&e.createElement("div",{className:"userflowjs-banner-buttons"},T.buttons.map((t=>e.createElement(f,{key:t.id,button:t}))))),S.closeDisabled?e.createElement("div",{className:"userflowjs-banner-start-spacer"}):e.createElement("button",{"data-testid":"userflow-banner-dismiss",className:"userflowjs-banner-close",onClick:()=>L.endFlow(h,{endReason:s.USER_CLOSED})},e.createElement(i,{icon:m}))))),M):null};export default h;export{h as BannerApp};
package/BuilderBar.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{u as t,F as r}from"./use-window-resize.js";import{S as s}from"./logomark.js";import{o}from"./vendor.obj-str.js";import{f as a,a as n}from"./vendor.fortawesome.pro-light-svg-icons.js";import{H as l}from"./userflow.js";import{a as i,D as m}from"./stylesheets.js";var u=new URL("builder-ui-host.css",import.meta.url).href,c=new URL("builder-ui-frame.css",import.meta.url).href;const d=e.forwardRef((({onReadyChange:d,children:f,buttons:p},b)=>{const{loaded:h}=i(window,u),[v,E]=e.useState(!1),g=h&&v,w=e.useRef(!1);e.useEffect((()=>{g&&!w.current&&d&&(w.current=!0,d(!0))}),[g,d]);const j=e.useRef(null),[y,R]=e.useState(null),[k,N]=e.useState((()=>"top"===l.getItem("builderBarPos")?"top":"bottom")),S=e.useCallback((e=>{N(e),l.setItem("builderBarPos",e)}),[]),C=e.useRef(0),L=e.useCallback((()=>{const e=j.current;if(!e||!y||!g)return;const t=y.clientHeight;t!==C.current&&(C.current=t,e.style.setProperty("height",t+"px","important"))}),[g,y]);return e.useLayoutEffect((()=>{L()})),t(L),e.useImperativeHandle(b,(()=>({getFrame:()=>j.current,getRootEl:()=>y})),[y]),e.createElement(e.Fragment,null,e.createElement(r,{className:o({"userflowjs-builder-bar":!0,"userflowjs-builder-bar--top":"top"===k}),style:{visibility:g?void 0:"hidden",animation:g?void 0:"none"},elRef:j,stylesheet:c,onStylesheetsLoad:E},g&&e.createElement("div",{className:"root",ref:R},e.createElement("div",{className:"logomark"},e.createElement(s,null)),e.createElement("div",{className:"main"},f),e.createElement("div",{className:"buttons"},p,e.createElement("button",{key:k,className:"btn btn--square btn--plain-on-dark",onClick:()=>S("top"===k?"bottom":"top")},e.createElement(m,{icon:"top"===k?a:n,size:20}))))))}));export{d as B};
1
+ import{r as e}from"./vendor.react.js";import{u as t,F as r}from"./use-window-resize.js";import{S as s}from"./logomark.js";import{o}from"./vendor.obj-str.js";import{f as a,a as n}from"./vendor.fortawesome.pro-light-svg-icons.js";import{H as l}from"./userflow.js";import{a as i,D as m}from"./stylesheets.js";var u=new URL("builder-ui-host.css",import.meta.url).href,c=new URL("builder-ui-frame.css",import.meta.url).href;const d=e.forwardRef((({onReadyChange:d,children:f,buttons:p},b)=>{const{loaded:h}=i(window,u),[v,E]=e.useState(!1),g=h&&v,w=e.useRef(!1);e.useEffect((()=>{g&&!w.current&&d&&(w.current=!0,d(!0))}),[g,d]);const j=e.useRef(null),[y,R]=e.useState(null),[k,N]=e.useState((()=>"top"===l.getItem("builderBarPos")?"top":"bottom")),S=e.useCallback((e=>{N(e),l.setItem("builderBarPos",e)}),[]),B=e.useRef(0),C=e.useCallback((()=>{const e=j.current;if(!e||!y||!g)return;const t=y.clientHeight;t!==B.current&&(B.current=t,e.style.setProperty("height",t+"px","important"))}),[g,y]);return e.useLayoutEffect((()=>{C()})),t(C),e.useImperativeHandle(b,(()=>({getFrame:()=>j.current,getRootEl:()=>y})),[y]),e.createElement(e.Fragment,null,e.createElement(r,{className:o({"userflowjs-builder-bar":!0,"userflowjs-builder-bar--top":"top"===k}),style:{visibility:g?void 0:"hidden",animation:g?void 0:"none"},elRef:j,stylesheet:c,onStylesheetsLoad:E,title:"Builder bar"},g&&e.createElement("div",{className:"root",ref:R},e.createElement("div",{className:"logomark"},e.createElement(s,null)),e.createElement("div",{className:"main"},f),e.createElement("div",{className:"buttons"},p,e.createElement("button",{key:k,className:"btn btn--square btn--plain-on-dark",onClick:()=>S("top"===k?"bottom":"top")},e.createElement(m,{icon:"top"===k?a:n,size:20}))))))}));export{d as B};
package/ChecklistApp.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{N as t,D as s,L as o,j as i}from"./userflow.js";import{F as n}from"./FlowChrome.js";import{i as r,u as c}from"./client-context.js";import{f as l,w as a,C as u,S as m}from"./flow-host.styl.js";import{a as d,D as h,u as p}from"./stylesheets.js";import{F as f}from"./use-window-resize.js";import{o as k}from"./vendor.obj-str.js";import{z as b}from"./flow-condition-types.js";import{C as v}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{u as j}from"./vendor.react-i18next.js";import{C as E}from"./ChecklistUI.js";import{B as x}from"./BubbleToolbar.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./bubble-frame.styl.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./logomark.js";import"./use-selector-element-monitoring.js";import"./vendor.i18next.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.js";var w=new URL("checklist-launcher-frame.css",import.meta.url).href;const g=({position:s,theme:o,onClick:i,onVisibleChange:n,buttonRef:r,text:c,uncompletedCount:m})=>{const p=s||"absolute",{i18n:E}=j(),x=E.dir(),{loaded:g}=d(window,l,o),[y,L]=e.useState(!1),C=g&&y;e.useEffect((()=>{n&&n(C)}),[n,C]);const F=e.useRef(null),I=e.useRef(0),[A,T]=e.useState(null);e.useLayoutEffect((()=>{const e=F.current;if(!e||!A)return;const t=A.clientWidth;t!==I.current&&(I.current=t,e.style.setProperty("width",b(t)+"px","important"),e.style.setProperty("height",o.checklistLauncherHeight+"px","important"))}));const R=o.checklistLauncherPlacement,N=R===t.TOP_LEFT||R===t.TOP_RIGHT,S=R===t.TOP_LEFT||R===t.BOTTOM_LEFT,P={zIndex:"fixed"===p?null!=o.checklistZIndex?o.checklistZIndex:a(u):1,top:N?o.checklistLauncherY+"px":void 0,bottom:N?void 0:o.checklistLauncherY+"px",["ltr"===x?"left":"right"]:S?o.checklistLauncherX+"px":void 0,["ltr"===x?"right":"left"]:S?void 0:o.checklistLauncherX+"px",height:o.checklistLauncherHeight+"px",borderRadius:o.checklistLauncherBorderRadius+"px",position:C?void 0:"absolute",visibility:C?void 0:"hidden",animation:C?void 0:"none"};return e.createElement(f,{elRef:F,testId:"checklist-launcher-app",className:k({"userflowjs-checklist-launcher":!0,[`userflowjs-checklist-launcher--position-${p}`]:!0}),style:P,stylesheet:w,theme:o,onStylesheetsLoad:L},e.createElement("button",{ref:r,className:"userflowjs-checklist-launcher-frame-root",onClick:i},e.createElement("div",{ref:T,className:"userflowjs-checklist-launcher-content"},e.createElement("div",{className:"userflowjs-checklist-launcher-text"},c||"Get Started"),e.createElement("div",{"data-testid":"checklist-launcher-uncompleted-count",className:"userflowjs-checklist-launcher-uncompleted-count"},0===m?e.createElement(h,{icon:v}):m,e.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")))))},y=({session:t,checklistExpanded:s})=>{const{version:o}=t,i=o.checklist,n=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;e.useEffect((()=>{r.changeLanguage(n)}),[n]);const[c,l]=e.useState(!1);return s?e.createElement(L,{session:t,initialAutoFocus:c,setInitialAutoFocus:l}):i.launcherEnabled?e.createElement(C,{session:t,initialAutoFocus:c,setInitialAutoFocus:l}):null},L=({session:t,initialAutoFocus:i,setInitialAutoFocus:r})=>{const l=c(),[a,u]=e.useState(null),{version:d}=t,h=d.checklist,f=p(d.theme),k=e.useMemo((()=>({...f,avatarType:s.NONE,bubblePlacement:f.checklistPlacement,bubbleX:f.checklistX,bubbleY:f.checklistY,bubbleWidth:f.checklistWidth})),[f]);return e.useEffect((()=>{const e=a?.ownerDocument.defaultView;if(!e)return;const t=e=>{"Escape"===e.key&&(r(!0),l.hideChecklist())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}),[a,r,l]),e.createElement(m,null,e.createElement(n,{company:t.flow.company,theme:k,position:"fixed",stepAppearance:o.BUBBLE,zIndex:f.checklistZIndex,autoHide3pEnabled:!0,backgroundImageUrl:h.backgroundAsset&&h.backgroundAsset.assetUrl,bubbleFrameRootRef:u},e.createElement("div",{role:"dialog","aria-label":"Checklist"},e.createElement(E,{session:t,initialAutoFocus:i}),e.createElement(x,{draftMode:t.draftMode,minimize:e=>{r(0===e.detail),l.hideChecklist()}}))))},C=({session:t,initialAutoFocus:s,setInitialAutoFocus:o})=>{const n=c(),[r,l]=e.useState(!1),[a,u]=e.useState(null),{version:m}=t,d=m.checklist,h=p(m.theme);return e.useEffect((()=>{r&&a&&s&&a.focus()}),[n,a,r,s]),e.createElement(g,{position:"fixed",theme:h,onClick:e=>{o(0===e.detail),n.showChecklist()},onVisibleChange:l,buttonRef:u,text:d.launcherText,uncompletedCount:i(t)})};export default y;export{y as ChecklistApp};
1
+ import{r as e}from"./vendor.react.js";import{N as t,D as s,L as o,j as i}from"./userflow.js";import{F as n}from"./FlowChrome.js";import{i as r,u as c}from"./client-context.js";import{f as l,w as a,C as u,S as m}from"./flow-host.styl.js";import{a as d,D as h,u as p}from"./stylesheets.js";import{F as f}from"./use-window-resize.js";import{o as k}from"./vendor.obj-str.js";import{z as b}from"./flow-condition-types.js";import{C as v}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{u as j}from"./vendor.react-i18next.js";import{C as E}from"./ChecklistUI.js";import{B as x}from"./BubbleToolbar.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./bubble-frame.styl.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./logomark.js";import"./use-selector-element-monitoring.js";import"./vendor.i18next.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.js";var w=new URL("checklist-launcher-frame.css",import.meta.url).href;const g=({position:s,theme:o,onClick:i,onVisibleChange:n,buttonRef:r,text:c,uncompletedCount:m})=>{const p=s||"absolute",{i18n:E}=j(),x=E.dir(),{loaded:g}=d(window,l,o),[y,L]=e.useState(!1),C=g&&y;e.useEffect((()=>{n&&n(C)}),[n,C]);const F=e.useRef(null),I=e.useRef(0),[A,T]=e.useState(null);e.useLayoutEffect((()=>{const e=F.current;if(!e||!A)return;const t=A.clientWidth;t!==I.current&&(I.current=t,e.style.setProperty("width",b(t)+"px","important"),e.style.setProperty("height",o.checklistLauncherHeight+"px","important"))}));const R=o.checklistLauncherPlacement,N=R===t.TOP_LEFT||R===t.TOP_RIGHT,S=R===t.TOP_LEFT||R===t.BOTTOM_LEFT,P={zIndex:"fixed"===p?null!=o.checklistZIndex?o.checklistZIndex:a(u):1,top:N?o.checklistLauncherY+"px":void 0,bottom:N?void 0:o.checklistLauncherY+"px",["ltr"===x?"left":"right"]:S?o.checklistLauncherX+"px":void 0,["ltr"===x?"right":"left"]:S?void 0:o.checklistLauncherX+"px",height:o.checklistLauncherHeight+"px",borderRadius:o.checklistLauncherBorderRadius+"px",position:C?void 0:"absolute",visibility:C?void 0:"hidden",animation:C?void 0:"none"};return e.createElement(f,{elRef:F,testId:"checklist-launcher-app",className:k({"userflowjs-checklist-launcher":!0,[`userflowjs-checklist-launcher--position-${p}`]:!0}),style:P,stylesheet:w,theme:o,onStylesheetsLoad:L,title:"Checklist launcher"},e.createElement("button",{ref:r,className:"userflowjs-checklist-launcher-frame-root",onClick:i},e.createElement("div",{ref:T,className:"userflowjs-checklist-launcher-content"},e.createElement("div",{className:"userflowjs-checklist-launcher-text"},c||"Get Started"),e.createElement("div",{"data-testid":"checklist-launcher-uncompleted-count",className:"userflowjs-checklist-launcher-uncompleted-count"},0===m?e.createElement(h,{icon:v}):m,e.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")))))},y=({session:t,checklistExpanded:s})=>{const{version:o}=t,i=o.checklist,n=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;e.useEffect((()=>{r.changeLanguage(n)}),[n]);const[c,l]=e.useState(!1);return s?e.createElement(L,{session:t,initialAutoFocus:c,setInitialAutoFocus:l}):i.launcherEnabled?e.createElement(C,{session:t,initialAutoFocus:c,setInitialAutoFocus:l}):null},L=({session:t,initialAutoFocus:i,setInitialAutoFocus:r})=>{const l=c(),[a,u]=e.useState(null),{version:d}=t,h=d.checklist,f=p(d.theme),k=e.useMemo((()=>({...f,avatarType:s.NONE,bubblePlacement:f.checklistPlacement,bubbleX:f.checklistX,bubbleY:f.checklistY,bubbleWidth:f.checklistWidth})),[f]);return e.useEffect((()=>{const e=a?.ownerDocument.defaultView;if(!e)return;const t=e=>{"Escape"===e.key&&(r(!0),l.hideChecklist())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}),[a,r,l]),e.createElement(m,null,e.createElement(n,{company:t.flow.company,theme:k,position:"fixed",stepAppearance:o.BUBBLE,zIndex:f.checklistZIndex,autoHide3pEnabled:!0,backgroundImageUrl:h.backgroundAsset&&h.backgroundAsset.assetUrl,bubbleFrameRootRef:u},e.createElement("div",{role:"dialog","aria-label":"Checklist"},e.createElement(E,{session:t,initialAutoFocus:i}),e.createElement(x,{draftMode:t.draftMode,minimize:e=>{r(0===e.detail),l.hideChecklist()}}))))},C=({session:t,initialAutoFocus:s,setInitialAutoFocus:o})=>{const n=c(),[r,l]=e.useState(!1),[a,u]=e.useState(null),{version:m}=t,d=m.checklist,h=p(m.theme);return e.useEffect((()=>{r&&a&&s&&a.focus()}),[n,a,r,s]),e.createElement(g,{position:"fixed",theme:h,onClick:e=>{o(0===e.detail),n.showChecklist()},onVisibleChange:l,buttonRef:u,text:d.launcherText,uncompletedCount:i(t)})};export default y;export{y as ChecklistApp};
package/FlowChrome.js CHANGED
@@ -1 +1 @@
1
- import{r as t}from"./vendor.react.js";import{u as e,F as o}from"./use-window-resize.js";import{c as a,L as l,D as r,b as i,N as s,z as n,O as c}from"./userflow.js";import{a as u,f as d}from"./flow-host.styl.js";import{b as p}from"./bubble-frame.styl.js";import{S as m}from"./logomark.js";import{o as b}from"./vendor.obj-str.js";import{u as f}from"./use-selector-element-monitoring.js";import{k as h,a as g,g as w,l as T,u as E,e as v,M as y,s as M,j as L}from"./flow-condition-types.js";import{a as j,g as k}from"./stylesheets.js";import{u as B}from"./vendor.react-i18next.js";var O=new URL("avatar-frame.css",import.meta.url).href;const R=({company:R,theme:H,position:C,absoluteWidth:S,absoluteHeight:D,stepKey:U,stepAppearance:F,width:W,backgroundImageUrl:z,tooltipSelector:A,allowMissingTooltipTarget:V,tooltipPlacement:G,backdrop:$,tooltipTargetBlocked:K,backdropPadding:Y,zIndex:X,onTooltipTargetClick:q,onTooltipTargetMissingChange:J,onModalBackdropClick:Q,onVisibleChange:Z,speaking:tt,noIframe:et,MadeWithUserflow:ot,minimizeOnAvatarClick:at,autoHide3pEnabled:lt,bubbleFrameRootRef:rt,frameWrapperHtmlAttributes:it,rootChildren:st,children:nt})=>{const ct=C||"absolute",ut=G||null,dt=Y||"0",pt=ot||N,mt=u(),bt="fixed"===ct?null!=X?X:mt+1:1,ft=bt-1,{i18n:ht}=B(),gt=ht.dir(),wt=t.useRef(null),Tt=t.useRef(null),Et=t.useRef(null),[vt,yt]=t.useState(null),Mt=t.useRef(null),Lt=t.useRef(null),jt=t.useRef(null),kt=t.useRef(null),Bt=t.useRef(null),Ot=t.useRef(null),Rt=t.useRef(null),Pt=t.useRef(null),Nt=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:xt}=j(window,d,H),[It,_t]=t.useState(!1),[Ht,Ct]=t.useState(!1),St=xt&&It&&Ht;let[Dt,Ut]=t.useState(!1);F!==l.BUBBLE&&(at=!1,Dt=!1),t.useEffect((()=>{Ut(!1)}),[U]);const Ft=t.useRef({appearance:null,width:null,theme:H,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}),[Wt,zt]=t.useState(null),At=null!=Wt&&St;t.useEffect((()=>{Z&&Z(At)}),[Z,At]);const Vt=t.useCallback((t=>{Ft.current.lastReportedTooltipTargetMissing!==t&&(Ft.current.lastReportedTooltipTargetMissing=t,J&&J(t))}),[J]),Gt=t.useCallback((({forceAppearanceLayout:t,forceUpdatePosition:e}={})=>{const o=wt.current,i=Tt.current,u=Et.current,d=Lt.current,p=Mt.current,m=jt.current,b=kt.current,f=Bt.current,v=Ot.current,y=Rt.current,j=Pt.current,k=Nt.current;if(!(o&&i&&u&&vt&&d&&p&&m&&b&&f&&v&&y&&j&&k))return;if(!St)return;const B=Ft.current,{tooltipTargetParams:O}=B;h();let R=F,P=!1;R!==l.TOOLTIP||V||O||(B.tooltipTargetMissing?(R=l.BUBBLE,P=!0):R=null);const N=R!==B.appearance,C=W!==B.width;if((t||N||C||H!==B.theme||$!=B.backdrop||dt!=B.backdropPadding||ut!==B.desiredTooltipPlacement)&&(B.appearance=R,B.width=W,B.theme=H,B.backdrop=$,B.backdropPadding=dt,B.desiredTooltipPlacement=ut,e=!0,function({layoutState:{appearance:t,theme:e,backdrop:o,tooltipTargetMissing:a},width:i,position:n,absoluteWidth:c,root:u,bubble:d,bubbleFrameRoot:p,avatar:m,avatarNotch:b,modalBackdrop:f,dir:h}){const g="absolute"===n?c||1024:T(w()),{avatarSize:E,bubblePlacement:v}=e;let y=e.bubbleWidth,M=null,L=null,j=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${t?.toLowerCase()}`,k="hidden",B=null,O=null,R=null,P=null,N="userflowjs-bubble__avatar-notch",I="hidden",_=null,H=null,C=null,S=null,D="userflowjs-modal-backdrop";(t===l.MODAL||!a&&t===l.BUBBLE&&o)&&(D+=" userflowjs-modal-backdrop--visible");switch(t){case l.BUBBLE:if(e.avatarType!==r.NONE){k="",I="",v===s.TOP_LEFT||v===s.TOP_CENTER||v===s.TOP_RIGHT?(M=E+20,B=0,_=-40,N+=" userflowjs-bubble__avatar-notch--top"):(L=E+20,R=0,C=-40,N+=" userflowjs-bubble__avatar-notch--bottom");const t=v===s.TOP_LEFT||v===s.TOP_CENTER||v===s.BOTTOM_LEFT||v===s.BOTTOM_CENTER||v===s.CENTER;"ltr"===h&&t||"rtl"===h&&!t?(P=0,S=E,N+=" userflowjs-bubble__avatar-notch--left"):(O=0,H=E,N+=" userflowjs-bubble__avatar-notch--right")}break;case l.MODAL:y=e.modalWidth,e.avatarType!==r.NONE&&(k="",P=`calc(50% - ${E/2}px)`,B=-E/2);break;case l.TOOLTIP:y=e.tooltipWidth}null!=i&&(y=i);y=Math.min(y,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===l.MODAL);const U=null!=t&&t!==l.HIDDEN;u.style.position="",u.style.top="",u.style.left="",u.style.visibility=U?"":"hidden",u.style.animation=U?"":"none",x(d,"width",T(y)),x(d,"padding-top",M),x(d,"padding-bottom",L),p.className=j,x(m,"width",T(e.avatarSize)),x(m,"height",T(e.avatarSize)),m.style.visibility=k,x(m,"top",B),x(m,"right",O),x(m,"bottom",R),x(m,"left",P),b.className=N,b.style.visibility=I,x(b,"top",_),x(b,"right",H),x(b,"bottom",C),x(b,"left",S),f.className=D}({layoutState:B,width:W,position:ct,absoluteWidth:S,root:o,bubble:i,bubbleFrameRoot:vt,avatar:d,avatarNotch:p,modalBackdrop:k,dir:gt})),!et){const t=vt.offsetHeight,o=g()-2*(w()<800?0:16)-(H.avatarType===r.NONE?0:R===l.BUBBLE?20+H.avatarSize:R===l.MODAL?H.avatarSize/2:0),a=Math.min(t,o);if(R&&a!==B.bubbleFrameHeight){if(B.bubbleFrameHeight=a,x(u,"height",T(a)),E(u)&&u.contentDocument){u.contentDocument.documentElement.style.overflowY=t<=o?"hidden":"scroll"}e=!0}}if(e&&R){let t=N;if(R===l.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:i,desiredTooltipPlacement:u,root:d,bubble:p,tooltipNotch:m,tooltipBackdrop:b,tooltipBlockTop:f,tooltipBlockRight:h,tooltipBlockBottom:E,tooltipBlockLeft:v,dir:y}){const{appearance:L,theme:j,tooltipTargetParams:k,backdrop:B,backdropPadding:O}=t,{bubblePlacement:R}=j,P=16,N=j.tooltipNotchSize,H=10,{width:C,height:S}=p.getBoundingClientRect(),D="absolute"===o?a||1024:T(w()),U="absolute"===o?i||768:T(g());let F=0,W=0,z="userflowjs-bubble__tooltip-notch",A="hidden",V=null,G=null,$=null,K=null,Y="userflowjs-tooltip-backdrop",X=null,q=null,J=null,Q=null,Z=null,tt=null,et=null,ot=null,at="userflowjs-tooltip-block userflowjs-tooltip-block--top",lt=null,rt=null,it="userflowjs-tooltip-block userflowjs-tooltip-block--right",st=null,nt=null,ct="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",ut=null,dt=null,pt="userflowjs-tooltip-block userflowjs-tooltip-block--left",mt=null,bt=null;switch(L){case l.BUBBLE:F=R===s.TOP_LEFT||R===s.BOTTOM_LEFT?j.bubbleX:R===s.TOP_CENTER||R===s.CENTER||R===s.BOTTOM_CENTER?(D-C)/2:D-C-j.bubbleX,W=R===s.TOP_LEFT||R===s.TOP_CENTER||R===s.TOP_RIGHT?j.bubbleY:R===s.CENTER?(U-S)/2:U-S-j.bubbleY,"rtl"===y&&(F=D-F-C),F=Math.max(0,Math.min(D-C,F)),W=Math.max(0,Math.min(U-S,W));break;case l.MODAL:{let t=P;j.avatarType!==r.NONE&&(t+=j.avatarSize/2),F=P+(D-2*P-C)/2,W=t+(U-t-P-S)/2;break}case l.TOOLTIP:{let e;if(k){let{targetRect:a,viewportClipRect:l}=k;if("absolute"===o){const t=d.offsetParent.getBoundingClientRect();l={top:0,right:D,bottom:U,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(B){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])}}(O);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 i=a,s=j.backdropHighlightType==n.OUTSIDE?j.backdropHighlightSpread:0;if(B&&s&&(a={top:a.top-s,right:a.right+s,bottom:a.bottom+s,left:a.left-s,width:a.width+2*s,height:a.height+2*s}),e=function({targetRect:t,bubbleWidth:e,bubbleHeight:o,containerWidth:a,containerHeight:l,viewportClipRect:r,tooltipNotchSize:i,currentTooltipPlacement:s,desiredTooltipPlacement:n}){if(t.bottom<=r.top)return o+i<=l-r.top?c.BELOW:c.ABOVE;if(t.top>=r.bottom)return o+i<=r.bottom?c.ABOVE:c.BELOW;if(t.right<=r.left)return e+i<=a-r.left?c.RIGHT:c.LEFT;if(t.left>=r.right)return e+i<=r.right?c.LEFT:c.RIGHT;const u=s=>{const n=t.left+t.width/2,u=n>=r.left&&n<=r.right,d=t.top+t.height/2,p=d>=r.top&&d<=r.bottom;switch(s){case c.BELOW:return l-t.bottom>o+i&&u;case c.ABOVE:return t.top>o+i&&u;case c.RIGHT:return a-t.right>e+i&&p;case c.LEFT:return t.left>e+i&&p}};if(n&&u(n))return n;if(s&&u(s))return s;const d=[{placement:c.BELOW,dist:t.top},{placement:c.ABOVE,dist:l-t.bottom},{placement:c.RIGHT,dist:t.left},{placement:c.LEFT,dist:a-t.right}];d.sort(((t,e)=>t.dist-e.dist));for(const{placement:c}of d)if(u(c))return c;return c.BELOW}({targetRect:a,bubbleWidth:C,bubbleHeight:S,containerWidth:D,containerHeight:U,viewportClipRect:l,tooltipNotchSize:N,currentTooltipPlacement:t.tooltipPlacement,desiredTooltipPlacement:u}),e===c.BELOW||e===c.ABOVE?(F=a.left+a.width/2-C/2,F=Math.max(P,Math.min(D-C-P,F)),K=Math.max(H,Math.min(C-H-2*N,a.left+a.width/2-N-F)),e===c.BELOW?V=2*-N:$=2*-N):e===c.RIGHT?(F=a.right+N,F=Math.max(F,l.left+N),F=Math.min(F,l.right+N),F=Math.max(F,N),F=Math.min(F,D-C)):(F=a.left-N-C,F=Math.max(F,l.left-C-N),F=Math.min(F,l.right-C-N),F=Math.max(F,0),F=Math.min(F,D-C-N)),e===c.LEFT||e===c.RIGHT?(W=a.top+a.height/2-S/2,W=Math.max(P,Math.min(U-S-P,W)),V=Math.max(H,Math.min(S-H-2*N,a.top+a.height/2-N-W)),e===c.LEFT?G=2*-N:K=2*-N):e===c.BELOW?(W=a.bottom+N,W=Math.max(W,l.top+N),W=Math.min(W,l.bottom+N),W=Math.max(W,N),W=Math.min(W,U-S)):(W=a.top-N-S,W=Math.max(W,l.top-S-N),W=Math.min(W,l.bottom-S-N),W=Math.max(W,0),W=Math.min(W,U-S-N)),B){const t=window.getComputedStyle(k.targetEl);X=Math.max(0,i.top),q=Math.max(0,D-i.right),J=Math.max(0,U-i.bottom),Q=Math.max(0,i.left),Z=Math.max(0,M(t.borderTopLeftRadius)+r),tt=Math.max(0,M(t.borderTopRightRadius)+r),et=Math.max(0,M(t.borderBottomRightRadius)+r),ot=Math.max(0,M(t.borderBottomLeftRadius)+r),lt=Math.max(0,i.right),rt=Math.max(0,i.top),st=Math.max(0,i.right),nt=Math.max(0,i.bottom),ut=Math.max(0,i.left),dt=Math.max(0,i.bottom),mt=Math.max(0,i.left),bt=Math.max(0,i.top)}}else e=u||c.BELOW,e!==c.BELOW&&e!==c.ABOVE||(K=C/2-N,e===c.BELOW?V=2*-N:$=2*-N),e!==c.LEFT&&e!==c.RIGHT||(V=S/2-N,e===c.LEFT?G=2*-N:K=2*-N);t.tooltipPlacement=e,z+=` userflowjs-bubble__tooltip-notch--${e.toLowerCase()}`,A="",B&&(Y+=" userflowjs-tooltip-backdrop--visible",at+=" userflowjs-tooltip-block--visible",it+=" userflowjs-tooltip-block--visible",ct+=" userflowjs-tooltip-block--visible",pt+=" userflowjs-tooltip-block--visible");break}}p.style.transition="";let ft=F,ht=W;if(e&&(p.style.opacity="0",L===l.TOOLTIP)){const e=24;switch(t.tooltipPlacement){case c.BELOW:W+=e;break;case c.ABOVE:W-=e;break;case c.RIGHT:F+=e;break;case c.LEFT:F-=e}}"relative"!==o&&I(p,F,W);if(m.className=z,m.style.visibility=A,x(m,"top",V),x(m,"right",G),x(m,"bottom",$),x(m,"left",K),b.className=Y,x(b,"top",X),x(b,"right",q),x(b,"bottom",J),x(b,"left",Q),x(b,"border-top-left-radius",Z),x(b,"border-top-right-radius",tt),x(b,"border-bottom-right-radius",et),x(b,"border-bottom-left-radius",ot),f.className=at,x(f,"width",lt),x(f,"height",rt),h.className=it,x(h,"left",st),x(h,"height",nt),E.className=ct,x(E,"left",ut),x(E,"top",dt),v.className=pt,x(v,"width",mt),x(v,"top",bt),e){p.offsetWidth;const t="opacity 250ms linear";L===l.TOOLTIP?p.style.transition=`${t}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:p.style.transition=t,p.style.opacity="1","relative"!==o&&I(p,ft,ht)}}({layoutState:B,animateIn:t,position:ct,absoluteWidth:S,absoluteHeight:D,desiredTooltipPlacement:ut,root:o,bubble:i,tooltipNotch:m,tooltipBackdrop:b,tooltipBlockTop:f,tooltipBlockRight:v,tooltipBlockBottom:y,tooltipBlockLeft:j,dir:gt})}if(R===l.TOOLTIP){const t=O&&O.targetEl;t&&B.stepKeyScrolledIntoView!==U&&B.targetScrolledIntoView!==t&&(B.stepKeyScrolledIntoView=U,B.targetScrolledIntoView=t,function(t){if(a.customScrollIntoView)return void a.customScrollIntoView(t);const{scrollPadding:e}=a;if(e&&L(t)===document.scrollingElement){const o=e.top||0,a=e.right||0,l=e.bottom||0,r=e.left||0;let i=0,s=0;const n=t.getBoundingClientRect(),c=w(),u=g();if(n.top<o?i=n.top-o:n.bottom>u-l&&(i=n.bottom-u+l),n.left<r?s=n.left-r:n.right>c-a&&(s=n.right-c+a),0!=i||0!=s)return void window.scrollBy({top:i,left:s,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(P),zt(R)}),[St,vt,U,F,W,H,ct,S,D,V,ut,$,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 Yt=()=>{window.clearTimeout(Ft.current.tooltipTargetMissingTimeout),Ft.current.tooltipTargetMissingTimeout=void 0};t.useEffect((()=>Yt),[]);const Xt=t.useCallback((()=>{const t=Ft.current;if(t.tooltipTargetParams=null,V||(t.tooltipPlacement=null),F!==l.TOOLTIP)return Yt(),void(t.tooltipTargetMissing=!1);if(!V&&!t.tooltipTargetMissingTimeout){t.tooltipTargetMissing=!1;const e=!A||v(A)||A.type!==i.AUTO||A.autoData?1e3*parseFloat(H.tooltipMissingToleranceSeconds):1;t.tooltipTargetMissingTimeout=window.setTimeout((()=>{if(!Kt.current){if(A&&!v(A)){let t=A.autoData;if(A.autoData)try{t=JSON.parse(A.autoData)}catch(e){}console.warn("Userflow.js: Tooltip target not found on page.\n",{type:A.type,autoData:t,excludeText:A.excludeText,precision:A.precision,text:A.text,css:A.css})}Yt(),t.tooltipTargetMissing=!0,$t.current()}}),e)}$t.current()}),[F,V,A,H.tooltipMissingToleranceSeconds]),qt=t.useCallback((t=>{const e=Ft.current;Yt(),e.tooltipTargetParams&&e.tooltipTargetParams.targetEl!==t.targetEl&&(e.tooltipPlacement=null),e.tooltipTargetParams=t,Gt({forceUpdatePosition:!0})}),[Gt]);f({selector:F===l.TOOLTIP&&A||null,targetMoved:qt,targetLost:Xt,onTargetClick:q});const Jt=t.useCallback((()=>Gt({forceAppearanceLayout:!0})),[Gt]);e(Jt),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,S,D]);const Qt=t=>{t.preventDefault(),t.stopPropagation()};return function(e,o){const l=window.Intercom;t.useEffect((()=>{if(o&&e.autoHideIntercom&&"function"==typeof l&&!a.autoHide3pDisabled){try{l("update",{hide_default_launcher:!0})}catch(t){console.warn("Userflow.js: Error when hiding Intercom launcher",t)}return()=>{if(!a.autoHide3pDisabled)try{l("update",{hide_default_launcher:!1})}catch(t){console.warn("Userflow.js: Error when unhiding Intercom launcher",t)}}}}),[l,e.autoHideIntercom,o]);const r=window.$crisp;t.useEffect((()=>{if(o&&e.autoHideCrisp&&r&&!a.autoHide3pDisabled){try{r.push(["do","chat:hide"])}catch(t){console.warn("Userflow.js: Error when hiding Crisp Chat",t)}return()=>{if(!a.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&&!a.autoHide3pDisabled){try{i.widget.remove()}catch(t){console.warn("Userflow.js: Error when hiding HubSpot Chat",t)}return()=>{if(!a.autoHide3pDisabled)try{i.widget.load()}catch(t){console.warn("Userflow.js: Error when unhiding HubSpot Chat",t)}}}}),[i,e.autoHideHubspot,o]);const s=window.drift;t.useEffect((()=>{if(o&&e.autoHideDrift&&s&&!a.autoHide3pDisabled){try{s.api.widget.hide()}catch(t){console.warn("Userflow.js: Error when hiding Drift Chat",t)}return()=>{if(!a.autoHide3pDisabled)try{s.api.widget.show()}catch(t){console.warn("Userflow.js: Error when unhiding Drift Chat",t)}}}}),[s,e.autoHideDrift,o])}(H,!!lt&&Wt===l.BUBBLE),t.createElement("div",{ref:wt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:k(H),dir:gt},t.createElement("div",{className:"userflowjs-bubble",ref:Tt,style:{zIndex:bt}},t.createElement("div",{className:b({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(H.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:H,onStylesheetsLoad:_t,noIframe:et},t.createElement("div",{className:"userflowjs-bubble-frame-root",ref:t=>{rt&&rt(t),yt(t)},style:z?{backgroundImage:`url("${encodeURI(z)}")`}:void 0},nt,R.flowBranding&&t.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},t.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},t.createElement(pt,{company:R},t.createElement(m,null),t.createElement("div",null,"Made with Userflow"))))))),t.createElement("div",{ref:Mt,className:"userflowjs-bubble__avatar-notch"})),t.createElement(o,{className:b({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!at,"userflowjs-bubble__avatar--speaking":!!tt}),elRef:Lt,stylesheet:O,theme:H,onStylesheetsLoad:Ct,noIframe:et,ariaHidden:!0},t.createElement("div",{className:b({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!at}),onClick:at?()=>Ut((t=>!t)):void 0},t.createElement(P,{theme:H}))),t.createElement("div",{ref:jt,className:"userflowjs-bubble__tooltip-notch"})),t.createElement("div",{ref:kt,className:"userflowjs-tooltip-backdrop",onMouseDown:Qt,style:{zIndex:ft,pointerEvents:K?void 0:"none"}}),t.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Ot,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Rt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Pt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Nt,className:"userflowjs-modal-backdrop",onMouseDown:Qt,onClick:Q,style:{zIndex:ft}}),st&&st({visible:At,bubbleFrame:Et.current}))},P=({theme:e})=>{const o="https://js.userflow.com/cartoon-avatars-no-bg/";let a;return a=e.avatarType===r.ASSET&&e.avatarAsset?e.avatarAsset.assetUrl:e.avatarType===r.CARTOON&&e.avatarName?o+e.avatarName+".svg?3":e.avatarType===r.URL&&e.avatarUrl?e.avatarUrl:o+"none.svg",t.createElement("img",{src:a,alt:""})},N=({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 x(t,e,o){null==o?t.style.removeProperty(e):t.style.setProperty(e,"number"==typeof o?o+"px":o,"important")}function I(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{R as F};
1
+ import{r as t}from"./vendor.react.js";import{u as e,F as o}from"./use-window-resize.js";import{c as a,L as l,D as r,b as i,N as s,z as n,O as c}from"./userflow.js";import{a as u,f as d}from"./flow-host.styl.js";import{b as p}from"./bubble-frame.styl.js";import{S as m}from"./logomark.js";import{o as b}from"./vendor.obj-str.js";import{u as f}from"./use-selector-element-monitoring.js";import{k as h,a as g,g as w,l as T,u as E,e as v,M as y,s as M,j as L}from"./flow-condition-types.js";import{a as j,g as k}from"./stylesheets.js";import{u as B}from"./vendor.react-i18next.js";var O=new URL("avatar-frame.css",import.meta.url).href;const R=({company:R,theme:H,position:C,absoluteWidth:S,absoluteHeight:D,stepKey:U,stepAppearance:F,width:W,backgroundImageUrl:z,tooltipSelector:A,allowMissingTooltipTarget:V,tooltipPlacement:G,backdrop:$,tooltipTargetBlocked:K,backdropPadding:Y,zIndex:X,onTooltipTargetClick:q,onTooltipTargetMissingChange:J,onModalBackdropClick:Q,onVisibleChange:Z,speaking:tt,noIframe:et,MadeWithUserflow:ot,minimizeOnAvatarClick:at,autoHide3pEnabled:lt,bubbleFrameRootRef:rt,frameWrapperHtmlAttributes:it,rootChildren:st,children:nt})=>{const ct=C||"absolute",ut=G||null,dt=Y||"0",pt=ot||N,mt=u(),bt="fixed"===ct?null!=X?X:mt+1:1,ft=bt-1,{i18n:ht}=B(),gt=ht.dir(),wt=t.useRef(null),Tt=t.useRef(null),Et=t.useRef(null),[vt,yt]=t.useState(null),Mt=t.useRef(null),Lt=t.useRef(null),jt=t.useRef(null),kt=t.useRef(null),Bt=t.useRef(null),Ot=t.useRef(null),Rt=t.useRef(null),Pt=t.useRef(null),Nt=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:xt}=j(window,d,H),[It,_t]=t.useState(!1),[Ht,Ct]=t.useState(!1),St=xt&&It&&Ht;let[Dt,Ut]=t.useState(!1);F!==l.BUBBLE&&(at=!1,Dt=!1),t.useEffect((()=>{Ut(!1)}),[U]);const Ft=t.useRef({appearance:null,width:null,theme:H,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}),[Wt,zt]=t.useState(null),At=null!=Wt&&St;t.useEffect((()=>{Z&&Z(At)}),[Z,At]);const Vt=t.useCallback((t=>{Ft.current.lastReportedTooltipTargetMissing!==t&&(Ft.current.lastReportedTooltipTargetMissing=t,J&&J(t))}),[J]),Gt=t.useCallback((({forceAppearanceLayout:t,forceUpdatePosition:e}={})=>{const o=wt.current,i=Tt.current,u=Et.current,d=Lt.current,p=Mt.current,m=jt.current,b=kt.current,f=Bt.current,v=Ot.current,y=Rt.current,j=Pt.current,k=Nt.current;if(!(o&&i&&u&&vt&&d&&p&&m&&b&&f&&v&&y&&j&&k))return;if(!St)return;const B=Ft.current,{tooltipTargetParams:O}=B;h();let R=F,P=!1;R!==l.TOOLTIP||V||O||(B.tooltipTargetMissing?(R=l.BUBBLE,P=!0):R=null);const N=R!==B.appearance,C=W!==B.width;if((t||N||C||H!==B.theme||$!=B.backdrop||dt!=B.backdropPadding||ut!==B.desiredTooltipPlacement)&&(B.appearance=R,B.width=W,B.theme=H,B.backdrop=$,B.backdropPadding=dt,B.desiredTooltipPlacement=ut,e=!0,function({layoutState:{appearance:t,theme:e,backdrop:o,tooltipTargetMissing:a},width:i,position:n,absoluteWidth:c,root:u,bubble:d,bubbleFrameRoot:p,avatar:m,avatarNotch:b,modalBackdrop:f,dir:h}){const g="absolute"===n?c||1024:T(w()),{avatarSize:E,bubblePlacement:v}=e;let y=e.bubbleWidth,M=null,L=null,j=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${t?.toLowerCase()}`,k="hidden",B=null,O=null,R=null,P=null,N="userflowjs-bubble__avatar-notch",I="hidden",_=null,H=null,C=null,S=null,D="userflowjs-modal-backdrop";(t===l.MODAL||!a&&t===l.BUBBLE&&o)&&(D+=" userflowjs-modal-backdrop--visible");switch(t){case l.BUBBLE:if(e.avatarType!==r.NONE){k="",I="",v===s.TOP_LEFT||v===s.TOP_CENTER||v===s.TOP_RIGHT?(M=E+20,B=0,_=-40,N+=" userflowjs-bubble__avatar-notch--top"):(L=E+20,R=0,C=-40,N+=" userflowjs-bubble__avatar-notch--bottom");const t=v===s.TOP_LEFT||v===s.TOP_CENTER||v===s.BOTTOM_LEFT||v===s.BOTTOM_CENTER||v===s.CENTER;"ltr"===h&&t||"rtl"===h&&!t?(P=0,S=E,N+=" userflowjs-bubble__avatar-notch--left"):(O=0,H=E,N+=" userflowjs-bubble__avatar-notch--right")}break;case l.MODAL:y=e.modalWidth,e.avatarType!==r.NONE&&(k="",P=`calc(50% - ${E/2}px)`,B=-E/2);break;case l.TOOLTIP:y=e.tooltipWidth}null!=i&&(y=i);y=Math.min(y,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===l.MODAL);const U=null!=t&&t!==l.HIDDEN;u.style.position="",u.style.top="",u.style.left="",u.style.visibility=U?"":"hidden",u.style.animation=U?"":"none",x(d,"width",T(y)),x(d,"padding-top",M),x(d,"padding-bottom",L),p.className=j,x(m,"width",T(e.avatarSize)),x(m,"height",T(e.avatarSize)),m.style.visibility=k,x(m,"top",B),x(m,"right",O),x(m,"bottom",R),x(m,"left",P),b.className=N,b.style.visibility=I,x(b,"top",_),x(b,"right",H),x(b,"bottom",C),x(b,"left",S),f.className=D}({layoutState:B,width:W,position:ct,absoluteWidth:S,root:o,bubble:i,bubbleFrameRoot:vt,avatar:d,avatarNotch:p,modalBackdrop:k,dir:gt})),!et){const t=vt.offsetHeight,o=g()-2*(w()<800?0:16)-(H.avatarType===r.NONE?0:R===l.BUBBLE?20+H.avatarSize:R===l.MODAL?H.avatarSize/2:0),a=Math.min(t,o);if(R&&a!==B.bubbleFrameHeight){if(B.bubbleFrameHeight=a,x(u,"height",T(a)),E(u)&&u.contentDocument){u.contentDocument.documentElement.style.overflowY=t<=o?"hidden":"scroll"}e=!0}}if(e&&R){let t=N;if(R===l.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:i,desiredTooltipPlacement:u,root:d,bubble:p,tooltipNotch:m,tooltipBackdrop:b,tooltipBlockTop:f,tooltipBlockRight:h,tooltipBlockBottom:E,tooltipBlockLeft:v,dir:y}){const{appearance:L,theme:j,tooltipTargetParams:k,backdrop:B,backdropPadding:O}=t,{bubblePlacement:R}=j,P=16,N=j.tooltipNotchSize,H=10,{width:C,height:S}=p.getBoundingClientRect(),D="absolute"===o?a||1024:T(w()),U="absolute"===o?i||768:T(g());let F=0,W=0,z="userflowjs-bubble__tooltip-notch",A="hidden",V=null,G=null,$=null,K=null,Y="userflowjs-tooltip-backdrop",X=null,q=null,J=null,Q=null,Z=null,tt=null,et=null,ot=null,at="userflowjs-tooltip-block userflowjs-tooltip-block--top",lt=null,rt=null,it="userflowjs-tooltip-block userflowjs-tooltip-block--right",st=null,nt=null,ct="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",ut=null,dt=null,pt="userflowjs-tooltip-block userflowjs-tooltip-block--left",mt=null,bt=null;switch(L){case l.BUBBLE:F=R===s.TOP_LEFT||R===s.BOTTOM_LEFT?j.bubbleX:R===s.TOP_CENTER||R===s.CENTER||R===s.BOTTOM_CENTER?(D-C)/2:D-C-j.bubbleX,W=R===s.TOP_LEFT||R===s.TOP_CENTER||R===s.TOP_RIGHT?j.bubbleY:R===s.CENTER?(U-S)/2:U-S-j.bubbleY,"rtl"===y&&(F=D-F-C),F=Math.max(0,Math.min(D-C,F)),W=Math.max(0,Math.min(U-S,W));break;case l.MODAL:{let t=P;j.avatarType!==r.NONE&&(t+=j.avatarSize/2),F=P+(D-2*P-C)/2,W=t+(U-t-P-S)/2;break}case l.TOOLTIP:{let e;if(k){let{targetRect:a,viewportClipRect:l}=k;if("absolute"===o){const t=d.offsetParent.getBoundingClientRect();l={top:0,right:D,bottom:U,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(B){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])}}(O);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 i=a,s=j.backdropHighlightType==n.OUTSIDE?j.backdropHighlightSpread:0;if(B&&s&&(a={top:a.top-s,right:a.right+s,bottom:a.bottom+s,left:a.left-s,width:a.width+2*s,height:a.height+2*s}),e=function({targetRect:t,bubbleWidth:e,bubbleHeight:o,containerWidth:a,containerHeight:l,viewportClipRect:r,tooltipNotchSize:i,currentTooltipPlacement:s,desiredTooltipPlacement:n}){if(t.bottom<=r.top)return o+i<=l-r.top?c.BELOW:c.ABOVE;if(t.top>=r.bottom)return o+i<=r.bottom?c.ABOVE:c.BELOW;if(t.right<=r.left)return e+i<=a-r.left?c.RIGHT:c.LEFT;if(t.left>=r.right)return e+i<=r.right?c.LEFT:c.RIGHT;const u=s=>{const n=t.left+t.width/2,u=n>=r.left&&n<=r.right,d=t.top+t.height/2,p=d>=r.top&&d<=r.bottom;switch(s){case c.BELOW:return l-t.bottom>o+i&&u;case c.ABOVE:return t.top>o+i&&u;case c.RIGHT:return a-t.right>e+i&&p;case c.LEFT:return t.left>e+i&&p}};if(n&&u(n))return n;if(s&&u(s))return s;const d=[{placement:c.BELOW,dist:t.top},{placement:c.ABOVE,dist:l-t.bottom},{placement:c.RIGHT,dist:t.left},{placement:c.LEFT,dist:a-t.right}];d.sort(((t,e)=>t.dist-e.dist));for(const{placement:c}of d)if(u(c))return c;return c.BELOW}({targetRect:a,bubbleWidth:C,bubbleHeight:S,containerWidth:D,containerHeight:U,viewportClipRect:l,tooltipNotchSize:N,currentTooltipPlacement:t.tooltipPlacement,desiredTooltipPlacement:u}),e===c.BELOW||e===c.ABOVE?(F=a.left+a.width/2-C/2,F=Math.max(P,Math.min(D-C-P,F)),K=Math.max(H,Math.min(C-H-2*N,a.left+a.width/2-N-F)),e===c.BELOW?V=2*-N:$=2*-N):e===c.RIGHT?(F=a.right+N,F=Math.max(F,l.left+N),F=Math.min(F,l.right+N),F=Math.max(F,N),F=Math.min(F,D-C)):(F=a.left-N-C,F=Math.max(F,l.left-C-N),F=Math.min(F,l.right-C-N),F=Math.max(F,0),F=Math.min(F,D-C-N)),e===c.LEFT||e===c.RIGHT?(W=a.top+a.height/2-S/2,W=Math.max(P,Math.min(U-S-P,W)),V=Math.max(H,Math.min(S-H-2*N,a.top+a.height/2-N-W)),e===c.LEFT?G=2*-N:K=2*-N):e===c.BELOW?(W=a.bottom+N,W=Math.max(W,l.top+N),W=Math.min(W,l.bottom+N),W=Math.max(W,N),W=Math.min(W,U-S)):(W=a.top-N-S,W=Math.max(W,l.top-S-N),W=Math.min(W,l.bottom-S-N),W=Math.max(W,0),W=Math.min(W,U-S-N)),B){const t=window.getComputedStyle(k.targetEl);X=Math.max(0,i.top),q=Math.max(0,D-i.right),J=Math.max(0,U-i.bottom),Q=Math.max(0,i.left),Z=Math.max(0,M(t.borderTopLeftRadius)+r),tt=Math.max(0,M(t.borderTopRightRadius)+r),et=Math.max(0,M(t.borderBottomRightRadius)+r),ot=Math.max(0,M(t.borderBottomLeftRadius)+r),lt=Math.max(0,i.right),rt=Math.max(0,i.top),st=Math.max(0,i.right),nt=Math.max(0,i.bottom),ut=Math.max(0,i.left),dt=Math.max(0,i.bottom),mt=Math.max(0,i.left),bt=Math.max(0,i.top)}}else e=u||c.BELOW,e!==c.BELOW&&e!==c.ABOVE||(K=C/2-N,e===c.BELOW?V=2*-N:$=2*-N),e!==c.LEFT&&e!==c.RIGHT||(V=S/2-N,e===c.LEFT?G=2*-N:K=2*-N);t.tooltipPlacement=e,z+=` userflowjs-bubble__tooltip-notch--${e.toLowerCase()}`,A="",B&&(Y+=" userflowjs-tooltip-backdrop--visible",at+=" userflowjs-tooltip-block--visible",it+=" userflowjs-tooltip-block--visible",ct+=" userflowjs-tooltip-block--visible",pt+=" userflowjs-tooltip-block--visible");break}}p.style.transition="";let ft=F,ht=W;if(e&&(p.style.opacity="0",L===l.TOOLTIP)){const e=24;switch(t.tooltipPlacement){case c.BELOW:W+=e;break;case c.ABOVE:W-=e;break;case c.RIGHT:F+=e;break;case c.LEFT:F-=e}}"relative"!==o&&I(p,F,W);if(m.className=z,m.style.visibility=A,x(m,"top",V),x(m,"right",G),x(m,"bottom",$),x(m,"left",K),b.className=Y,x(b,"top",X),x(b,"right",q),x(b,"bottom",J),x(b,"left",Q),x(b,"border-top-left-radius",Z),x(b,"border-top-right-radius",tt),x(b,"border-bottom-right-radius",et),x(b,"border-bottom-left-radius",ot),f.className=at,x(f,"width",lt),x(f,"height",rt),h.className=it,x(h,"left",st),x(h,"height",nt),E.className=ct,x(E,"left",ut),x(E,"top",dt),v.className=pt,x(v,"width",mt),x(v,"top",bt),e){p.offsetWidth;const t="opacity 250ms linear";L===l.TOOLTIP?p.style.transition=`${t}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:p.style.transition=t,p.style.opacity="1","relative"!==o&&I(p,ft,ht)}}({layoutState:B,animateIn:t,position:ct,absoluteWidth:S,absoluteHeight:D,desiredTooltipPlacement:ut,root:o,bubble:i,tooltipNotch:m,tooltipBackdrop:b,tooltipBlockTop:f,tooltipBlockRight:v,tooltipBlockBottom:y,tooltipBlockLeft:j,dir:gt})}if(R===l.TOOLTIP){const t=O&&O.targetEl;t&&B.stepKeyScrolledIntoView!==U&&B.targetScrolledIntoView!==t&&(B.stepKeyScrolledIntoView=U,B.targetScrolledIntoView=t,function(t){if(a.customScrollIntoView)return void a.customScrollIntoView(t);const{scrollPadding:e}=a;if(e&&L(t)===document.scrollingElement){const o=e.top||0,a=e.right||0,l=e.bottom||0,r=e.left||0;let i=0,s=0;const n=t.getBoundingClientRect(),c=w(),u=g();if(n.top<o?i=n.top-o:n.bottom>u-l&&(i=n.bottom-u+l),n.left<r?s=n.left-r:n.right>c-a&&(s=n.right-c+a),0!=i||0!=s)return void window.scrollBy({top:i,left:s,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(P),zt(R)}),[St,vt,U,F,W,H,ct,S,D,V,ut,$,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 Yt=()=>{window.clearTimeout(Ft.current.tooltipTargetMissingTimeout),Ft.current.tooltipTargetMissingTimeout=void 0};t.useEffect((()=>Yt),[]);const Xt=t.useCallback((()=>{const t=Ft.current;if(t.tooltipTargetParams=null,V||(t.tooltipPlacement=null),F!==l.TOOLTIP)return Yt(),void(t.tooltipTargetMissing=!1);if(!V&&!t.tooltipTargetMissingTimeout){t.tooltipTargetMissing=!1;const e=!A||v(A)||A.type!==i.AUTO||A.autoData?1e3*parseFloat(H.tooltipMissingToleranceSeconds):1;t.tooltipTargetMissingTimeout=window.setTimeout((()=>{if(!Kt.current){if(A&&!v(A)){let t=A.autoData;if(A.autoData)try{t=JSON.parse(A.autoData)}catch(e){}console.warn("Userflow.js: Tooltip target not found on page.\n",{type:A.type,autoData:t,excludeText:A.excludeText,precision:A.precision,text:A.text,css:A.css})}Yt(),t.tooltipTargetMissing=!0,$t.current()}}),e)}$t.current()}),[F,V,A,H.tooltipMissingToleranceSeconds]),qt=t.useCallback((t=>{const e=Ft.current;Yt(),e.tooltipTargetParams&&e.tooltipTargetParams.targetEl!==t.targetEl&&(e.tooltipPlacement=null),e.tooltipTargetParams=t,Gt({forceUpdatePosition:!0})}),[Gt]);f({selector:F===l.TOOLTIP&&A||null,targetMoved:qt,targetLost:Xt,onTargetClick:q});const Jt=t.useCallback((()=>Gt({forceAppearanceLayout:!0})),[Gt]);e(Jt),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,S,D]);const Qt=t=>{t.preventDefault(),t.stopPropagation()};return function(e,o){const l=window.Intercom;t.useEffect((()=>{if(o&&e.autoHideIntercom&&"function"==typeof l&&!a.autoHide3pDisabled){try{l("update",{hide_default_launcher:!0})}catch(t){console.warn("Userflow.js: Error when hiding Intercom launcher",t)}return()=>{if(!a.autoHide3pDisabled)try{l("update",{hide_default_launcher:!1})}catch(t){console.warn("Userflow.js: Error when unhiding Intercom launcher",t)}}}}),[l,e.autoHideIntercom,o]);const r=window.$crisp;t.useEffect((()=>{if(o&&e.autoHideCrisp&&r&&!a.autoHide3pDisabled){try{r.push(["do","chat:hide"])}catch(t){console.warn("Userflow.js: Error when hiding Crisp Chat",t)}return()=>{if(!a.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&&!a.autoHide3pDisabled){try{i.widget.remove()}catch(t){console.warn("Userflow.js: Error when hiding HubSpot Chat",t)}return()=>{if(!a.autoHide3pDisabled)try{i.widget.load()}catch(t){console.warn("Userflow.js: Error when unhiding HubSpot Chat",t)}}}}),[i,e.autoHideHubspot,o]);const s=window.drift;t.useEffect((()=>{if(o&&e.autoHideDrift&&s&&!a.autoHide3pDisabled){try{s.api.widget.hide()}catch(t){console.warn("Userflow.js: Error when hiding Drift Chat",t)}return()=>{if(!a.autoHide3pDisabled)try{s.api.widget.show()}catch(t){console.warn("Userflow.js: Error when unhiding Drift Chat",t)}}}}),[s,e.autoHideDrift,o])}(H,!!lt&&Wt===l.BUBBLE),t.createElement("div",{ref:wt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:k(H),dir:gt},t.createElement("div",{className:"userflowjs-bubble",ref:Tt,style:{zIndex:bt}},t.createElement("div",{className:b({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(H.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:H,onStylesheetsLoad:_t,noIframe:et,title:F.toLowerCase()},t.createElement("div",{className:"userflowjs-bubble-frame-root",ref:t=>{rt&&rt(t),yt(t)},style:z?{backgroundImage:`url("${encodeURI(z)}")`}:void 0},nt,R.flowBranding&&t.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},t.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},t.createElement(pt,{company:R},t.createElement(m,null),t.createElement("div",null,"Made with Userflow"))))))),t.createElement("div",{ref:Mt,className:"userflowjs-bubble__avatar-notch"})),t.createElement(o,{className:b({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!at,"userflowjs-bubble__avatar--speaking":!!tt}),elRef:Lt,stylesheet:O,theme:H,onStylesheetsLoad:Ct,noIframe:et,ariaHidden:!0,title:F.toLowerCase()},t.createElement("div",{className:b({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!at}),onClick:at?()=>Ut((t=>!t)):void 0},t.createElement(P,{theme:H}))),t.createElement("div",{ref:jt,className:"userflowjs-bubble__tooltip-notch"})),t.createElement("div",{ref:kt,className:"userflowjs-tooltip-backdrop",onMouseDown:Qt,style:{zIndex:ft,pointerEvents:K?void 0:"none"}}),t.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Ot,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Rt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Pt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:ft}}),t.createElement("div",{ref:Nt,className:"userflowjs-modal-backdrop",onMouseDown:Qt,onClick:Q,style:{zIndex:ft}}),st&&st({visible:At,bubbleFrame:Et.current}))},P=({theme:e})=>{const o="https://js.userflow.com/cartoon-avatars-no-bg/";let a;return a=e.avatarType===r.ASSET&&e.avatarAsset?e.avatarAsset.assetUrl:e.avatarType===r.CARTOON&&e.avatarName?o+e.avatarName+".svg?3":e.avatarType===r.URL&&e.avatarUrl?e.avatarUrl:o+"none.svg",t.createElement("img",{src:a,alt:""})},N=({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 x(t,e,o){null==o?t.style.removeProperty(e):t.style.setProperty(e,"number"==typeof o?o+"px":o,"important")}function I(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{R as F};
@@ -1 +1 @@
1
- import{h as e,C as t,c as n,i as r,j as s,k as o,l as c,E as a,m as l,n as i,p as u,S as d,A as m,q as f,_ as w}from"./userflow.js";import{r as h}from"./vendor.react.js";import{u as b,i as E}from"./client-context.js";import{u as k,w as v,f as p,C as g}from"./flow-host.styl.js";import{S as C,b as j,R as N,h as S,s as y,a as I,n as _}from"./bubble-frame.styl.js";import{M as x,g as T,a as M,b as R}from"./flow-condition-types.js";import{D as A,u as L,a as B,g as H}from"./stylesheets.js";import{u as O,F}from"./use-window-resize.js";import{o as P}from"./vendor.obj-str.js";import{S as D}from"./logomark.js";import{f as U,C as W}from"./ChecklistUI.js";import{f as $,a as z,b as q,c as V,d as K,e as G,g as Q,h as Z,i as J,j as Y,k as X}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{B as ee}from"./BubbleToolbar.js";import{u as te}from"./use-element-rect.js";import{u as ne}from"./vendor.react-i18next.js";function re(t){return t!==e.ACTION&&t!==e.ANNOUNCEMENTS&&t!==e.ASSISTANT&&t!==e.CONTACT&&t!==e.FLOWS&&t!==e.KNOWLEDGE_BASE&&t!==e.SUBPAGE}const se=window,oe={[t.CRISP]:{configure:({onShow:e,onHide:t})=>{!function(){if(ce)return;ce=!0,se.$crisp||(se.$crisp=[]);se.$crisp.push(["do","chat:hide"])}();let n=!1,r=!1;const s=()=>{n||r?(se.$crisp.push(["do","chat:show"]),e()):(se.$crisp.push(["do","chat:hide"]),t())},o=()=>{n=!0,s()};se.$crisp.push(["on","chat:opened",o]);const c=()=>{n=!1,s()};se.$crisp.push(["on","chat:closed",c]);const a=()=>{r=!0,s()};se.$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!==r&&(r=e,s())}),200);return()=>{se.$crisp.push(["off","chat:opened",o]),se.$crisp.push(["off","chat:closed",c]),se.$crisp.push(["off","message:received",a]),window.clearInterval(l)}},show:()=>{se.$crisp.push(["do","chat:show"]),se.$crisp.push(["do","chat:open"])},hide:()=>{se.$crisp.push(["do","chat:hide"]),se.$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(!se.fcWidget)throw new Error("Freshchat is not installed");let n=!1,r=!1;const s=()=>{n||r?e():t()},o=()=>{n=!0,s()};se.fcWidget.on("widget:opened",o);const c=()=>{n=!1,s()};se.fcWidget.on("widget:closed",c);const a=()=>{const e=!!document.querySelector("#fc_frame.h-open-notify");e!==r&&(r=e,s())},l=window.setInterval(a,200);return se.fcWidget.on("unreadCount:notify",a),()=>{se.fcWidget.off("widget:opened",o),se.fcWidget.off("widget:closed",c),se.fcWidget.off("unreadCount:notify",a),window.clearInterval(l)}},show:()=>{se.fcWidget.open()},hide:()=>{se.fcWidget.close()}},[t.HELPSCOUT]:{configure:({onShow:e,onHide:t})=>{if(!se.Beacon)throw new Error("Help Scout is not installed");!function(){if(ae)return;ae=!0,ie()}();let n=!1,r=!1;const s=()=>{n||r?(le(),e()):(ie(),t())},o=()=>{n=!0,s()};se.Beacon("on","open",o),se.Beacon("info")?.status.isOpened&&o();const c=()=>{n=!1,s()};se.Beacon("on","close",c);const a=window.setInterval((()=>{const e=!!document.querySelector(".BeaconNotificationsFrame");e!==r&&(r=e,s())}),200);return()=>{se.Beacon("off","open",o),se.Beacon("off","close",c),window.clearInterval(a)}},show:()=>{le(),se.Beacon("open")},hide:()=>{ie(),se.Beacon("close")}},[t.HUBSPOT]:{configure:({onShow:e,onHide:t})=>{const n=()=>{const n=document.getElementById("hubspot-messages-iframe-container");if(!se.HubSpotConversations||!n)return;window.clearInterval(s),function(){if(ue)return;ue=!0,de?me():fe()}();let o=!1,c=!1;const a=()=>{o||c?(me(),e()):(fe(),t())},l=()=>{const e=!!document.querySelector("#hubspot-messages-iframe-container .hs-shadow-container.active");e!==o&&(o=e,a())},i=new x(l);i.observe(n,{attributes:!0,subtree:!0,attributeFilter:["class"]}),l();const u=({unreadCount:e})=>{const t=e>0;t!==c&&(c=t,a())};se.HubSpotConversations.on("unreadConversationCountChanged",u),r=()=>{i.disconnect(),se.HubSpotConversations.off("unreadConversationCountChanged",u)}};let r=()=>{window.clearInterval(s)};const s=window.setInterval(n,100);return n(),()=>{r()}},show:()=>{me(),se.HubSpotConversations.widget.open()},hide:()=>{fe(),se.HubSpotConversations.widget.close()}},[t.INTERCOM]:{configure:({onShow:e,onHide:t})=>{if(!se.Intercom)throw new Error("Intercom is not installed");return function(){if(we)return;we=!0,ke();let e=!1,t=!1;const n=()=>{Ee();for(const e of he)e()},r=()=>{ke();for(const e of be)e()},s=()=>{e||t?n():r()};se.Intercom("onShow",(()=>{e=!0,s()})),se.Intercom("onHide",(()=>{e=!1,s()}));const o=()=>{const e=!!document.querySelector('iframe[name="intercom-borderless-frame"], iframe[name="intercom-notifications-frame"]');t!==e&&(t=e,s())};se.Intercom("onUnreadCountChange",(()=>{o()})),window.setInterval(o,200)}(),he.add(e),be.add(t),()=>{he.delete(e),be.delete(t)}},show:()=>{Ee(),se.Intercom("show")},hide:()=>{ke(),se.Intercom("hide")}},[t.ZENDESK]:{configure:({onShow:e,onHide:t})=>{if(!se.zE)throw new Error("Zendesk is not installed");!function(){if(ve)return;ve=!0,se.zE("webWidget","hide"),se.zE("webWidget","close"),se.zE("webWidget:on","open",(()=>{for(const e of pe)e()})),se.zE("webWidget:on","close",(()=>{for(const e of ge)e()})),se.zE("webWidget:on","chat:unreadMessages",(e=>{for(const t of Ce)t(e)}))}();let n=!1,r=!1;const s=()=>{n||r?(se.zE("webWidget","show"),e()):(se.zE("webWidget","hide"),t())},o=()=>{n=!0,r=!1,s()};pe.add(o);const c=()=>{n=!1,r=!1,s()};ge.add(c);const a=e=>{const t=e>0;t!==r&&(r=t,s())};return Ce.add(a),()=>{pe.delete(o),ge.delete(c),Ce.delete(a)}},show:()=>{se.zE("webWidget","show"),se.zE("webWidget","open")},hide:()=>{se.zE("webWidget","hide"),se.zE("webWidget","close")}},[t.ZENDESK_MESSENGER]:{configure:({onShow:e,onHide:t})=>{if(!se.zE)throw new Error("Zendesk is not installed");let n=!1;const r=window.setInterval((()=>{const r=(()=>{const e=document.querySelector('iframe[title="Messaging window"]');return!!e&&"0px"!==window.getComputedStyle(e).height})();r!==n&&(n=r,n?e():t())}),200);return()=>{window.clearInterval(r)}},show:()=>{se.zE("messenger","open")},hide:()=>{se.zE("messenger","close")}}};let ce=!1;let ae=!1;function le(){se.Beacon("config",{display:{style:"icon"}})}function ie(){se.Beacon("config",{display:{style:"manual"}})}let ue=!1,de=!1;function me(){de=!0;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","visible","important")}function fe(){de=!1;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","hidden","important")}let we=!1,he=new Set,be=new Set;function Ee(){se.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function ke(){se.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let ve=!1,pe=new Set,ge=new Set,Ce=new Set;const je=e=>h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},e),h.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"}),h.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"})),Ne=({center:e,fadeIn:t})=>{const n=12;return h.createElement("div",{className:P({"userflowjs-spinner":!0,"userflowjs-spinner--center":!!e,"userflowjs-spinner--fade-in":!!t})},h.createElement("svg",{viewBox:"0 0 24 24",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},h.createElement("circle",{className:"userflowjs-spinner__bg",fill:"none",cx:n,cy:n,r:10,style:{strokeWidth:"4px"}}),h.createElement("circle",{className:"userflowjs-spinner__fill",fill:"none",cx:n,cy:n,r:10,transform:"translate(12, 12) rotate(-90) translate(-12, -12)",style:{strokeWidth:"4px",strokeDasharray:20*Math.PI*.25+"px, 1000"}})))};function Se({message:e,skip:t}){const n=b(),[r,s]=h.useState(!0),[o,c]=h.useState(!1),[a,l]=h.useState(null),[i,u]=h.useState(null),[d,m]=h.useState(null),f=h.useRef(0),w=h.useRef(null),E=h.useRef((()=>{}));return h.useEffect((()=>{if(t)return;const r=JSON.stringify(e);if(r===w.current)return;w.current=r;const o=++f.current;let a,i;let d=!1;E.current=async(e,t)=>{if(!d){d=!0,c(!0);try{const r=e(a,i);i=r;const s=await n.send(r,{handlesRejection:!0});if(o!==f.current)return;a=t(a,s),l(a),m(null)}catch(r){if(o!==f.current)return;m(r)}finally{d=!1,c(!1)}}},(async()=>{s(!0);try{i=e;const t=await n.send(e,{handlesRejection:!0});if(o!==f.current)return;a=t,l(a),u(e),m(null)}catch(t){if(o!==f.current)return;m(t)}finally{s(!1)}})()}),[t,n,e]),{loading:r,loadingMore:o,data:a,messageForData:i,error:d,loadMore:E.current}}function ye(e,t){const[n,r]=h.useState(e),s=h.useRef(void 0),o=h.useCallback((e=>{window.clearTimeout(s.current),r(e),t(e)}),[t]),c=h.useCallback((e=>{window.clearTimeout(s.current),r(e),s.current=window.setTimeout((()=>{t(e)}),200)}),[t]);return h.useEffect((()=>()=>{window.clearTimeout(s.current)}),[]),[n,c,o]}const Ie=({textareaRef:e,value:t,onChange:n,onBlur:r,onKeyDown:s,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:i,mirrorClassName:u,textareaClassName:d,children:m})=>{let f=t||c||"";return(""===f||f.endsWith("\n"))&&(f+=" "),i=i||"growing-textarea",u=u||i+"__mirror",h.createElement("div",{className:i},h.createElement("div",{className:u+" "+(d||"")},f),h.createElement("textarea",{ref:e,value:t,onChange:e=>n&&n(e.target.value),onBlur:r,onKeyDown:s,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:d}),m)},_e=({textareaRef:e,value:t,onChange:n,onSubmit:r,placeholder:s,readOnly:o})=>{const c=()=>{r&&r()};return h.createElement("div",{className:"userflowjs-assistant-chat-input"},h.createElement(Ie,{textareaRef:e,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:s,readOnly:o,value:t||"",onChange:n,onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||(e.preventDefault(),c())}}),h.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>c()},h.createElement(A,{icon:$})))};function xe(e){return n.linkUrlDecorator?n.linkUrlDecorator(e):e}const Te=async()=>(await w((()=>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("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("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.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("bubble-frame.styl.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.fortawesome.pro-solid-svg-icons.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("flow-host.styl.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString()])).ResourceCenterAssistantChat,Me=({session:l,isOpen:i,flowSession:u,checklistSession:d})=>{const m=b(),{t:f}=ne(),{company:w}=l.flow,{version:N}=l,S=N.resourceCenter,y=L(N.theme),I=l.locale?l.locale.standardLocaleId:l.version.theme.languageId;h.useEffect((()=>{E.changeLanguage(I)}),[I]);const{loaded:_}=B(window,p,y),[R,W]=h.useState(!1),$=_&&R,[G,Q]=h.useState(T()),[Z,J]=h.useState(M()),Y=h.useCallback((()=>{Q(T()),J(M())}),[]);O(Y);const{zIndex:X,bringToFront:ee}=k(),[te,se]=h.useState(null),[ce,ae]=h.useState(null),[le,ie]=h.useState(null),ue=h.useRef(null),[de,me]=h.useState(null),[fe,we]=h.useState(null),[he,be]=h.useState(null),[Ee,ke]=h.useState(0),[ve,pe]=h.useState(0),ge=h.useCallback((()=>{ce&&ke(Math.round(ce.offsetWidth)),pe(Math.round((le?.offsetHeight||0)+(de?.offsetHeight||0)+(fe?.offsetHeight||0)+(he?.offsetHeight||0)))}),[ce,le,de,fe,he]);h.useLayoutEffect((()=>{if(!te||"function"!=typeof x)return;const e=new x((()=>{ge()}));return e.observe(te,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect()}}),[te,ge]),h.useLayoutEffect((()=>{ge()}));const[Ce,Ne]=h.useState(!1),Se=h.useRef(),ye=h.useCallback((()=>{Ne(!0),window.clearTimeout(Se.current),Se.current=window.setTimeout((()=>{Ne(!1)}),y.resourceCenterTransitionDuration)}),[y.resourceCenterTransitionDuration]);h.useEffect((()=>()=>{window.clearTimeout(Se.current)}),[]);const Ie=h.useCallback((()=>{ee(),ye(),m.openResourceCenter()}),[ee,m,ye]),_e=h.useCallback((()=>{ye(),m.closeResourceCenter()}),[m,ye]),[xe,Te]=h.useState(!1);h.useEffect((()=>{if(xe){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?U(e):t.focus({preventScroll:!0})}}else ce?.focus({preventScroll:!0});Te(!1)}}),[xe,i,de,le,ce]),h.useEffect((()=>{const e=te?.ownerDocument.defaultView;if(!i||!e)return;const t=e=>{"Escape"===e.key&&(_e(),Te(!0))};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}),[i,te,Te,_e]);const[Me,Ae]=h.useState((()=>function(e,t){if(!t)return null;const n=JSON.parse(t);let r;n.blockCvid&&(r=e.version.resourceCenter?.blocks.find((e=>e.cvid===n.blockCvid)));if(!r&&"search"!==n.kind)return null;const s={kind:n.kind,block:r};switch(s.kind){case"announcementShow":s.announcementId=n.announcementId}return s}(l,r.getItem(`resourceCenterRoute:v1:${l.id}`)))),Oe=h.useCallback(((e,t)=>{Ae(e);const n=function(e){if(!e)return null;let t;"block"in e&&null!=e.block&&(t=e.block.cvid);const n={kind:e.kind,blockCvid:t};switch(e.kind){case"announcementShow":n.announcementId=e.announcementId}return JSON.stringify(n)}(e);n?r.setItem(`resourceCenterRoute:v1:${l.id}`,n):r.removeItem(`resourceCenterRoute:v1:${l.id}`),0===t?.detail&&Te(!0)}),[l.id]);h.useEffect((()=>{if(!l.draftMode)return;if(!Me||!("block"in Me)||!Me.block)return;const e=S.blocks.find((e=>e.cvid===Me.block.cvid));e?JSON.stringify(e)!==JSON.stringify(Me.block)&&Ae({...Me,block:e}):Ae(null),Me.block}),[l.draftMode,S,Me]);const Fe=h.useMemo((()=>S.blocks.filter((t=>!(t.type===e.CHECKLIST&&!d)&&((t.type!==e.DIVIDER||!y.resourceCenterAutoDividers)&&(!t.hiddenWhenFlowsActive||!t.hiddenWhenFlowsActive.some((e=>e===u?.flow.id||e===d?.flow.id))))))),[S,u,d,y.resourceCenterAutoDividers]),$e=h.useMemo((()=>Be(Fe)),[Fe]),ze=h.useMemo((()=>d&&S.blocks.some((t=>t.type===e.CHECKLIST))?s(d):0),[S,d]),Ve=h.useMemo((()=>S.blocks.find((t=>t.type===e.CONTACT&&t.chatEnabled&&t.chatProvider))),[S]),[Qe,Ze]=h.useState(!1),Je=h.useCallback((()=>{m.closeResourceCenter(),Ve&&Ve.chatProvider!==t.CUSTOM&&Ze(!0)}),[m,Ve]),Ye=h.useCallback((()=>{Ze(!1)}),[]),Xe=h.useCallback((()=>{if(Ve)try{oe[Ve.chatProvider].hide({block:Ve}),Ye()}catch(e){console.error(`Userflow.js: Error when hiding ${Ve.chatProvider}:`,e)}}),[Ve,Ye]);h.useEffect((()=>{if(!Ve)return;n.autoHide3pDisabled=!0;const e=oe[Ve.chatProvider];try{const t=e.configure({block:Ve,onShow:Je,onHide:Ye});return()=>{t()}}catch(t){return void console.error(`Userflow.js: Error when configuring ${Ve.chatProvider}:`,t)}}),[Ve,Je,Ye]),h.useEffect((()=>{i&&Xe()}),[Xe,i]);const nt=h.useMemo((()=>S.blocks.find((t=>t.type===e.ANNOUNCEMENTS))),[S]),rt=!!Me&&("search"===Me.kind||"flows"===Me.kind||"knowledgeBase"===Me.kind),st="assistant"===Me?.kind||"announcementList"===Me?.kind||"announcementShow"===Me?.kind,ot=Math.min(st?y.resourceCenterFullWidth:y.resourceCenterWidth,G-2*y.resourceCenterPaddingX),ct={zIndex:null!=y.resourceCenterZIndex?y.resourceCenterZIndex:i?X:v(g),position:$?void 0:"absolute",visibility:$&&!Qe?void 0:"hidden"},at={width:(i?ot:Ee)+"px",height:i?Math.min(rt?540:st?720:ve,Z-2*y.resourceCenterPaddingY,null==y.resourceCenterMaxHeight?Number.MAX_VALUE:y.resourceCenterMaxHeight)+"px":void 0},[lt,it]=h.useState(!1),ut=()=>{Ie(),Te(!0)},dt=y.resourceCenterDisplayChecklistProgress&&d&&ze>0?h.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},ze,h.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let mt="",ft="";return y.resourceCenterLauncherTextMode===o.CHECKLIST_OVERRIDE&&d&&ze>0?mt=d.version.checklist?.launcherText||"Get Started":y.resourceCenterLauncherTextMode!==o.NONE&&(ft=S.buttonText),h.createElement(C.Provider,{value:l},h.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center-app userflowjs-theme-root",style:H(y),dir:E.dir()},h.createElement("div",{className:P({"userflowjs-resource-center":!0,"userflowjs-resource-center--fixed":!0,[`userflowjs-resource-center--placement-${y.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0}),style:ct},h.createElement("div",{className:"userflowjs-resource-center-frame-wrapper",onMouseEnter:()=>it(!0),onMouseLeave:()=>it(!1)},h.createElement(F,{className:P({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--animating":Ce,"userflowjs-resource-center-frame--open":i,"userflowjs-resource-center-frame--closed":!i}),style:at,stylesheet:j,theme:y,onStylesheetsLoad:W},$&&h.createElement(h.Fragment,null,h.createElement("div",{ref:se,className:P({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${y.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":Ce,"userflowjs-resource-center-frame-root--open":i,"userflowjs-resource-center-frame-root--closed":!i}),role:i?"dialog":void 0,"aria-label":i?S.headerText:void 0},h.createElement("div",{className:"userflowjs-resource-center-launcher-container"},h.createElement("button",{ref:ae,className:P({"userflowjs-resource-center-launcher-button":!0,"userflowjs-resource-center-launcher-button--hover":lt}),onClick:ut,"aria-label":`Open ${S.headerText}`},dt,mt&&h.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},mt),(dt||mt)&&h.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),ft&&h.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ft),h.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},y.resourceCenterLauncherIconType===c.PLAINTEXT?"?":h.createElement(je,null)))),h.createElement("div",{ref:ue,className:"userflowjs-resource-center-body",style:{width:ot+"px"}},h.createElement("div",{ref:me,className:P({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":"assistant"!==Me?.kind,"userflowjs-resource-center-body-content--same-background":y.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":w.resourceCenterBranding})},i&&h.createElement(h.Fragment,null,Me?"search"===Me.kind?h.createElement(Pe,{session:l,navigate:Oe}):"email"===Me.kind?h.createElement(De,{block:Me.block,session:l}):"phone"===Me.kind?h.createElement(Ue,{block:Me.block,session:l}):"flows"===Me.kind?h.createElement(We,{block:Me.block,initialQ:Me.initialQ,session:l,navigate:Oe}):"knowledgeBase"===Me.kind?h.createElement(qe,{block:Me.block,initialQ:Me.initialQ,session:l,bodyRef:ue}):"subpage"===Me.kind?h.createElement(Ke,{block:Me.block,session:l}):"announcementList"===Me.kind||"announcementShow"===Me.kind?h.createElement(Ge,{bodyRef:ue,session:l,route:Me,navigate:Oe}):"assistant"===Me.kind?h.createElement(et,{block:Me.block,initialUserContent:Me.initialUserContent,session:l,navigate:Oe,chatBlock:Ve,onChatShow:Je}):null:h.createElement(h.Fragment,null,Fe.map(((e,t)=>{const n=He[e.type],r=Fe[t+1];return n?h.createElement(h.Fragment,{key:e.id},h.createElement(n.View,{session:l,flowSession:u,checklistSession:d,block:e,navigate:Oe,onChatShow:Je}),r&&function(e,t,n){return!!e.resourceCenterAutoDividers&&(re(t)||re(n))}(y,e.type,r.type)&&h.createElement("div",{className:"userflowjs-resource-center-divider"})):null})))))),w.resourceCenterBranding&&h.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},h.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:we},h.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+w.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},h.createElement(D,null),h.createElement("div",null,"Made with Userflow")))),l.draftMode&&h.createElement("div",{className:"userflowjs-resource-center-preview"},h.createElement("div",{ref:be,className:"userflowjs-resource-center-preview-content"},h.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),h.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{m.endFlow(l,{endReason:a.USER_CLOSED})}},h.createElement(A,{icon:z})))),h.createElement("div",{className:"userflowjs-resource-center-header",style:{width:ot+"px"}},h.createElement("div",{ref:ie,className:"userflowjs-resource-center-header-content"},null==Me?h.createElement("div",{className:"userflowjs-resource-center-header-text"},S.headerText):h.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:e=>Oe("announcementShow"===Me?.kind?{kind:"announcementList",block:Me.block}:null,e)},h.createElement("div",{className:"userflowjs-rtl-mirrored"},h.createElement(A,{icon:q})),h.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},f("resource_center.back"))),h.createElement("div",{className:"flex-1"}),$e.length>0&&h.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let e={kind:"search"};if(1===$e.length){const t=$e[0],n=He[t.type];n.routeTo&&(e=n.routeTo({block:t}))}"search"===Me?.kind?Oe(null):(tt(m,l,null,"Search icon"),Oe(e))},"aria-label":"Search"},h.createElement(A,{icon:V})),h.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:e=>{_e(),0===e.detail&&Te(!0)},"aria-label":`Close ${S.headerText}`},h.createElement(A,{icon:K}))))))),!i&&!u&&nt&&nt.unreadAnnouncementCount>0&&h.createElement(Re,{theme:y,count:nt.unreadAnnouncementCount,onClick:ut})),!i&&!u&&nt?.popoutAnnouncement&&h.createElement(Le,{session:l,open:Ie,navigate:Oe,theme:y,block:nt}))))},Re=({theme:e,count:t,onClick:n})=>{const[r,s]=h.useState(!1);return h.createElement(F,{className:P({"userflowjs-resource-center-launcher-unread-badge":!0}),noScroll:!0,style:{position:r?void 0:"absolute",visibility:r?void 0:"hidden"},stylesheet:j,theme:e,onStylesheetsLoad:s},h.createElement(Ae,{count:t,onClick:n}))},Ae=({count:e,onClick:t})=>{let n=null;return e>9&&(e=9,n=h.createElement("span",{className:"userflowjs-unread-badge-plus"},"+")),h.createElement("div",{className:P({"userflowjs-unread-badge":!0,"userflowjs-unread-badge--clickable":!!t}),onClick:t},h.createElement("span",null,e),n)},Le=({session:e,open:t,navigate:n,theme:r,block:s})=>{const o=s.popoutAnnouncement,c=b(),[a,l]=h.useState(!1),{height:i,setEl:u}=te(),d=h.useMemo((()=>CSS.supports("height: 100dvh")?"dvh":"vh"),[]);return h.createElement("div",{className:"userflowjs-resource-center-popout"},h.createElement(F,{className:P({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${i}px, 100${d} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - 20px)`,position:a?void 0:"absolute",visibility:a?void 0:"hidden"},stylesheet:j,theme:r,onStylesheetsLoad:l},h.createElement("div",{ref:u,className:"userflowjs-resource-center-popout-frame-root"},h.createElement("h2",{className:"userflowjs-announcement-title"},h.createElement("span",{className:"userflowjs-unread-dot"}),h.createElement("span",null,o.title)),h.createElement("div",{className:"userflowjs-announcement-time"},h.createElement("div",{className:"userflowjs-announcement-time-text"},rt(o.time))),h.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},h.createElement(N,{doc:o.content,buttons:o.buttons})),o.moreEnabled&&h.createElement("div",{className:"userflowjs-announcement-more"},h.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>{Je(c,o),tt(c,e,s,o.title),n({kind:"announcementShow",block:s,announcementId:o.id}),t()}},h.createElement("div",null,(o.moreEnabled?o.moreButtonText:null)||"Read more"),h.createElement("span",{className:"userflowjs-rtl-mirrored"},h.createElement(A,{icon:G})))),h.createElement("div",{className:"userflowjs-bubble-toolbar"},h.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:()=>{Je(c,o)},"aria-label":"Dismiss announcement"},h.createElement(A,{icon:z}))))),h.createElement("div",{className:"userflowjs-resource-center-popout-notch"}))};function Be(e){return e.filter((e=>{const t=He[e.type];return t.isSearchable?t.isSearchable(e):!!t.search}))}const He={[e.ACTION]:{View:e=>{const{block:t,session:n,flowSession:r,checklistSession:s}=e,o=b(),[c,a]=h.useState(!1),i=r?.id,u=s?.id;return h.useEffect((()=>{a(!1)}),[i,u]),h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c?void 0:()=>{tt(o,n,t);const e=t.actions.find((e=>e.type===l.START_FLOW));if(e){e.otherFlow?.id!==s?.flow.id&&a(!0)}else o.closeResourceCenter();S(o,n,t.actions)},disabled:c},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),c&&h.createElement(Ne,null))}},[e.ANNOUNCEMENTS]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"announcementList",block:t},e)}},t.unreadAnnouncementCount>0?h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(Ae,{count:t.unreadAnnouncementCount})):h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))}},[e.ASSISTANT]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b(),[o,c]=h.useState("");return t.assistantAppearance===i.INPUT?h.createElement("div",{className:"userflowjs-resource-center-assistant-block"},h.createElement(_e,{value:o,onChange:c,placeholder:y(t.name,{lookupAttribute:R(n.data)}),onSubmit:()=>{tt(s,n,t),r({kind:"assistant",block:t,initialUserContent:o})}})):h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{tt(s,n,t),r({kind:"assistant",block:t,initialUserContent:""})}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}))}},[e.CHECKLIST]:{View:({checklistSession:e})=>h.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},h.createElement(W,{session:e}),h.createElement(ee,{draftMode:!!e.draftMode&&"CHECKLIST PREVIEW"}))},[e.CONTACT]:{View:e=>{const{block:t,session:n,navigate:r,onChatShow:s}=e,o=b(),c=[];return t.emailEnabled&&c.push({icon:J,label:"Email",isRoute:!0,onClick:e=>{tt(o,n,t,"Email"),r({kind:"email",block:t},e)}}),t.phoneEnabled&&c.push({icon:Y,label:"Phone",isRoute:!0,onClick:e=>{tt(o,n,t,"Phone"),r({kind:"phone",block:t},e)}}),t.chatEnabled&&c.push({icon:X,label:"Live-chat",isRoute:!1,onClick:()=>{tt(o,n,t,"Chat"),st(n,t,s)}}),h.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&&h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:c[0].icon})),h.createElement(Fe,{...e}),c.length>1&&c.map((({icon:e,label:t,onClick:n},r)=>h.createElement("button",{key:r,className:"userflowjs-resource-center-icon-button",onClick:n,"aria-label":t},h.createElement(A,{icon:e})))),1===c.length&&c[0].isRoute&&h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))}},[e.DIVIDER]:{View:()=>h.createElement("div",{className:"userflowjs-resource-center-divider"})},[e.FLOWS]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"flows",block:t},e)}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))},routeTo:({block:e,initialQ:t})=>({kind:"flows",block:e,initialQ:t}),isSearchable:e=>!!e.searchEnabled,search:async({client:e,session:t,block:n,q:r})=>{const{flows:s}=await e.send({kind:"ListResourceCenterBlockFlows",sessionId:t.id,blockCvid:n.cvid},{handlesRejection:!0}),o=$e(s,r),c=o.slice(0,5);return{block:n,truncated:c.length===o.length,results:c.map((e=>({kind:"flow",flow:e})))}}},[e.KNOWLEDGE_BASE]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"knowledgeBase",block:t},e)}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))},routeTo:({block:e,initialQ:t})=>({kind:"knowledgeBase",block:e,initialQ:t}),search:async({client:e,session:t,block:n,q:r})=>{const{truncated:s,articles:o}=await e.send({kind:"SearchKnowledgeBase",sessionId:t.id,blockCvid:n.cvid,q:r,offset:0,limit:5},{handlesRejection:!0});return{block:n,truncated:s,results:o.map((e=>({kind:"article",article:e})))}}},[e.MESSAGE]:{View:({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-block"},h.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},h.createElement(N,{doc:e.content,lookupAttribute:R(t.data)})))},[e.SUBPAGE]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"subpage",block:t},e)}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))}}},Oe=({block:e})=>e.icon?h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:e.icon,size:16})):null,Fe=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-block-text"},h.createElement(I,{doc:e.name,lookupAttribute:R(t.data)}));const Pe=({session:e,navigate:t})=>{const n=b(),r=e.version.resourceCenter.blocks,s=Be(r),{t:o}=ne(),c=h.useRef(null),[a,l]=h.useState(""),[i,u]=ye(a,l),[d,m]=h.useState(null);return h.useEffect((()=>{if(""===a.trim())return void m(null);let t=!1;return(async()=>{m(null);const s=await Promise.all(r.map((async t=>{const{search:r}=He[t.type];if(!r)return null;try{return await r({client:n,session:e,block:t,q:a})}catch(s){return console.error(`Userflow.js: Global search failed for ${t.type} block=`,t,"error=",s),null}})));t||m(s.filter((e=>null!=e&&e.results.length>0)))})(),()=>{t=!0}}),[n,e,r,a]),h.useEffect((()=>{c.current?.focus({preventScroll:!0})}),[]),h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-search"},h.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()?h.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},o("resource_center.search_in")," ",s.map(((t,n)=>h.createElement(h.Fragment,{key:t.cvid},n>0&&(n===s.length-1?` ${o("and")} `:", "),h.createElement("b",null,h.createElement(I,{doc:t.name,lookupAttribute:R(e.data)}))))),"."):d?0===d.length?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},o("resource_center.no_results_found")):d.map((({block:r,truncated:s,results:c},l)=>{const i=He[r.type],u=i.routeTo&&i.routeTo({block:r,initialQ:a});return h.createElement(h.Fragment,{key:r.cvid},l>0&&h.createElement("div",{className:"userflowjs-resource-center-divider"}),h.createElement("div",{className:"userflowjs-resource-center-label"},h.createElement(I,{doc:r.name,lookupAttribute:R(e.data)})),c.map(((n,s)=>"flow"===n.kind?h.createElement(ze,{key:n.flow.id,block:r,session:e,flow:n.flow,navigate:t}):"article"===n.kind?h.createElement(Ve,{key:s,block:r,session:e,article:n.article}):null)),!s&&u&&h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:s=>{tt(n,e,r),t(u,s)}},h.createElement("div",{className:"userflowjs-resource-center-block-text"},o("more"),":"," ",h.createElement(I,{doc:r.name,lookupAttribute:R(e.data)})),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q}))))})):h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)))},De=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},h.createElement(N,{doc:e.emailContent,lookupAttribute:R(t.data)})),Ue=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},h.createElement(N,{doc:e.phoneContent,lookupAttribute:R(t.data)})),We=({block:e,initialQ:t,session:n,navigate:r})=>{const{t:s}=ne(),o=h.useRef(null),[c,a]=h.useState(t||""),[l,i]=ye(c,a),{data:u,error:d}=Se({message:{kind:"ListResourceCenterBlockFlows",sessionId:n.id,blockCvid:e.cvid}}),m=u?.flows,f=h.useMemo((()=>m?$e(m,c):null),[m,c]);return h.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]),h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-header"},h.createElement("div",{className:"userflowjs-resource-center-list-route-title"},h.createElement(I,{doc:e.name,lookupAttribute:R(n.data)}))),e.searchEnabled&&h.createElement("div",{className:"userflowjs-resource-center-list-route-search"},h.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:s("resource_center.search_placeholder")})),d?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s("resource_center.generic_error")):f?0===f.length?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s("resource_center.no_results_found")):f.map((t=>h.createElement(ze,{key:t.id,block:e,session:n,flow:t,navigate:r}))):h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,{fadeIn:!0})))};function $e(e,t){const n=t.toLowerCase().trim();return""===n?e:e.filter((e=>e.name.toLowerCase().includes(n)))}const ze=({block:e,session:t,flow:n,navigate:r})=>{const s=b(),[o,c]=h.useState(!1);return h.useEffect((()=>{if(!o||n.type!==u.CHECKLIST)return;const e=()=>{s.checklistSession?.flow.id===n.id&&(t(),r(null))},t=()=>{s.off("checklistChanged",e)};return s.on("checklistChanged",e),t}),[s,o,n.type,n.id,r]),h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if(tt(s,t,e,n.name),s.checklistSession?.flow.id===n.id)return void r(null);s.startFlow({flowId:n.id,startReason:d.RESOURCE_CENTER,replaceCurrent:!0}),c(!0);const o=y(n.url,{lookupAttribute:R(t.data)});o&&_(o)},disabled:o},h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:n.type===u.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),h.createElement("div",{className:"userflowjs-resource-center-block-text"},n.name),o&&h.createElement(Ne,null))},qe=({block:e,initialQ:t,session:n,bodyRef:r})=>{const{t:s}=ne(),o=h.useRef(null),[c,a]=h.useState(t||""),[l,i]=ye(c,a),{loading:u,loadingMore:d,data:m,messageForData:f,error:w,loadMore:b}=Se({message:{kind:"SearchKnowledgeBase",sessionId:n.id,blockCvid:e.cvid,q:c,offset:0}});nt({bodyRef:r,loading:u,loadingMore:d,truncated:m?.truncated,loadMoreHelper:h.useCallback((()=>{b(((e,t)=>({...t,offset:e.articles.length})),((e,t)=>({...t,articles:[...e.articles,...t.articles]})))}),[b])}),h.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]);let E=e.knowledgeBaseUrl||"";return E.match(/^https?:\/\//)||(E=`http://${E}`),E=xe(E),h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-header"},h.createElement("div",{className:"userflowjs-resource-center-list-route-title"},h.createElement(I,{doc:e.name,lookupAttribute:R(n.data)})),h.createElement("a",{className:"userflowjs-resource-center-icon-button",href:E,target:"_blank",rel:"noopener noreferrer"},h.createElement(A,{icon:Z}))),h.createElement("div",{className:"userflowjs-resource-center-list-route-search"},h.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:s("resource_center.search_placeholder")})),w?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},"quota_exceeded"===w.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.":w.humanMessage||s("resource_center.generic_error")):u||!m?h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)):0===m.articles.length?""===f?.q?null:h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s("resource_center.no_results_found")):h.createElement(h.Fragment,null,""===f?.q&&h.createElement("div",{className:"userflowjs-resource-center-label"},s("resource_center.suggested_articles")),m.articles.map(((t,r)=>h.createElement(Ve,{key:r,block:e,session:n,article:t}))),d&&h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null))))},Ve=({block:e,article:t,session:n})=>{const r=b();return h.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{tt(r,n,e,t.title)},href:xe(t.url),target:"_blank",rel:"noopener noreferrer"},h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:"regular/file-alt",size:16})),h.createElement("div",{className:"userflowjs-resource-center-block-text"},h.createElement("span",{dangerouslySetInnerHTML:{__html:t.htmlTitle}}),h.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:t.htmlSnippet}})))},Ke=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},h.createElement(N,{doc:e.content,lookupAttribute:R(t.data)})),Ge=({bodyRef:e,session:t,route:n,navigate:r})=>{const s=b(),o=Se({message:{kind:"ListAnnouncements",beforeAnnouncementId:null},skip:"announcementList"!==n?.kind}),{loading:c,loadingMore:a,data:l,loadMore:i}=o,u=l?.truncated,d=h.useCallback((()=>{i(((e,t)=>e.announcements.length>0?{...t,beforeAnnouncementId:e.announcements[e.announcements.length-1].id}:t),((e,t)=>({...t,announcements:[...e.announcements,...t.announcements]})))}),[i]);nt({bodyRef:e,loading:c,loadingMore:a,truncated:u,loadMoreHelper:d});const[m,f]=h.useState(void 0);return h.useLayoutEffect((()=>{e.current&&null!=m&&"announcementList"===n?.kind&&(e.current.scrollTop=m)}),[e,m,n?.kind]),"announcementList"===n?.kind?h.createElement(Qe,{bodyRef:e,session:t,block:n.block,onMoreClick:o=>{f(e.current?.scrollTop),tt(s,t,n.block,o.title),r({kind:"announcementShow",block:n.block,announcementId:o.id})},...o}):"announcementShow"===n?.kind?h.createElement(Xe,{block:n.block,announcementId:n.announcementId}):null},Qe=({bodyRef:e,block:t,session:n,onMoreClick:r,error:s,loading:o,loadingMore:c,data:a})=>{const{t:l}=ne(),[i,u]=h.useMemo((()=>{const e=[],t=[];if(a){let n=-1;for(const r of a.announcements)n++,n<a.pageSize&&!r.seen&&r.level!==m.SILENT?e.push(r):t.push(r)}return[e,t]}),[a]),d=i.length;return h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-header"},h.createElement("div",{className:"userflowjs-resource-center-list-route-title"},h.createElement(I,{doc:t.name,lookupAttribute:R(n.data)}))),s?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s.humanMessage||l("resource_center.generic_error")):o||!a?h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)):0===a.announcements.length?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},E.exists("resource_center.no_announcements",{fallbackLng:[]})?l("resource_center.no_announcements"):l("resource_center.no_results_found")):h.createElement(h.Fragment,null,d>0&&h.createElement("div",{className:"userflowjs-announcement-unread-header"},l("resource_center.unread",{count:d})),i.map(((t,n)=>h.createElement(Ye,{key:n,bodyRef:e,onMoreClick:()=>r(t),announcement:t}))),i.length>0&&u.length>0&&h.createElement("div",{className:"userflowjs-announcement-seen-divider"}),u.map(((t,n)=>h.createElement(Ye,{key:n,bodyRef:e,onMoreClick:()=>r(t),announcement:t}))),c&&h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null))))},Ze=new Set;function Je(t,n){Ze.has(n.id)||(Ze.add(n.id),t.setResourceCenterSession((t=>t?{...t,version:{...t.version,resourceCenter:{...t.version.resourceCenter,blocks:t.version.resourceCenter.blocks.map((t=>t.type===e.ANNOUNCEMENTS?{...t,unreadAnnouncementCount:t.unreadAnnouncementCount-1,popoutAnnouncement:t.popoutAnnouncement?.id===n.id?null:t.popoutAnnouncement}:t))}}}:null)),t.toggleUI(),t.send({kind:"MarkAnnouncementSeen",announcementId:n.id,versionId:n.versionId}))}const Ye=({bodyRef:e,onMoreClick:t,announcement:n})=>{const r=b(),s=h.useRef(null),o=h.useRef(!1);return h.useEffect((()=>{if(o.current||n.seen)return;const t=new IntersectionObserver((e=>{const t=e[0];t&&t.isIntersecting&&(Je(r,n),o.current=!0,c())}),{root:e.current,threshold:1}),c=()=>{t.disconnect()};return t.observe(s.current),c}),[e,r,n]),h.createElement("div",{className:"userflowjs-announcement-list-item"},h.createElement("div",{className:"userflowjs-announcement-time-divider"},h.createElement("div",{className:"userflowjs-announcement-time-divider-line"}),h.createElement("div",{className:"userflowjs-announcement-time-text"},rt(n.time)),h.createElement("div",{className:"userflowjs-announcement-time-divider-line"})),h.createElement("h2",{ref:s,className:"userflowjs-announcement-title"},!n.seen&&n.level!==m.SILENT&&h.createElement("span",{className:"userflowjs-unread-dot"}),h.createElement("span",null,n.title)),h.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},h.createElement(N,{doc:n.content,buttons:n.buttons})),h.createElement("div",{className:"userflowjs-announcement-more"},n.moreEnabled&&h.createElement("button",{className:"userflowjs-tertiary-button",onClick:t},h.createElement("div",null,n.moreButtonText||"Read more"),h.createElement("span",{className:"userflowjs-rtl-mirrored"},h.createElement(A,{icon:G})))))},Xe=({announcementId:e})=>{const t=b(),{t:n}=ne(),{loading:r,data:s,error:o}=Se({message:{kind:"GetAnnouncement",announcementId:e}}),c=s?.announcement;return h.useEffect((()=>{c&&!c.seen&&Je(t,c)}),[t,c]),h.createElement(h.Fragment,null,o?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},o.humanMessage||n("resource_center.generic_error")):r||!c?h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)):h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-announcement-show"},h.createElement("h2",{className:"userflowjs-announcement-title"},c?.title),h.createElement("div",{className:"userflowjs-announcement-time"},h.createElement("div",{className:"userflowjs-announcement-time-text"},rt(c.time))),h.createElement("div",{className:"userflowjs-bubble-content"},h.createElement(N,{doc:c.content,buttons:c.buttons}),c.moreEnabled&&h.createElement(N,{doc:c.moreContent,buttons:c.moreButtons})))))},et=({block:t,initialUserContent:n,session:s,navigate:o,onChatShow:c})=>{const a=t.assistantFlowId,l=b(),[i,u]=h.useState(null),[d,m]=h.useState(null),[w,E]=h.useState(null),[k]=h.useState(n);h.useEffect((()=>{n&&o({kind:"assistant",block:t,initialUserContent:""})}),[n,t,o]),h.useEffect((()=>{let e=!1;return(async()=>{try{const t=r.getItem("assistantConversationId:"+a),[n,s]=await Promise.all([Te(),l.send({kind:"GetAssistant",assistantFlowId:a,conversationId:t},{handlesRejection:!0,endBatch:!0})]);if(e)return;u((()=>n)),m(s)}catch(t){console.error("Resource center assistant route failed to load:",t),E(t.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{e=!0}}),[l,a]);const v=h.useMemo((()=>{if(!t.assistantContactEnabled)return;const n=s.version.resourceCenter?.blocks.find((t=>t.type===e.CONTACT));return n?()=>{switch(tt(l,s,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case f.EMAIL:o({kind:"email",block:n});break;case f.PHONE:o({kind:"phone",block:n});break;default:o(null),st(s,n,c)}}:void 0}),[l,s,t,c,o]);return w?h.createElement("div",{className:"userflowjs-assistant-chat"},h.createElement("div",{className:"userflowjs-assistant-chat__content"},h.createElement("div",{className:"userflowjs-assistant-chat__error"},w))):i&&d?h.createElement(i,{block:t,session:s,assistantReply:d,initialUserContent:k,onContactClick:v,contactButtonText:t.assistantContactButtonText||void 0}):h.createElement(Ne,{center:!0,fadeIn:!0})};function tt(e,t,n,r){e.send({kind:"ClickResourceCenter",sessionId:t.id,description:n?y(n.name,{lookupAttribute:R(t.data)})+(r?` - ${r}`:""):r},{batch:!0})}function nt({bodyRef:e,loading:t,loadingMore:n,truncated:r,loadMoreHelper:s}){h.useEffect((()=>{const o=e.current;if(!o||t||n||r)return;const c=()=>{o.scrollHeight-o.clientHeight-o.scrollTop>400||s()};return o.addEventListener("scroll",c),()=>{o.removeEventListener("scroll",c)}}),[e,t,n,r,s])}function rt(e){const t=e?new Date(e):new Date;let n=new Intl.DateTimeFormat(E.language,{weekday:"long",day:"numeric",month:"short",year:t.getFullYear()===(new Date).getFullYear()?void 0:"numeric"}).format(t);return n.substring(0,1).toUpperCase()+n.substring(1)}function st(e,t,n){if(t.chatProvider){const e=oe[t.chatProvider];try{e.show({block:t})}catch(r){console.error(`Userflow.js: Error when showing ${t.chatProvider}:`,r)}n()}else e.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.")}var ot=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",ResourceCenterApp:Me,default:Me});export{_e as A,Ie as G,ot as R,xe as d};
1
+ import{h as e,C as t,c as n,i as r,j as s,k as o,l as c,E as a,m as l,n as i,p as u,S as d,A as m,q as f,_ as w}from"./userflow.js";import{r as h}from"./vendor.react.js";import{u as b,i as E}from"./client-context.js";import{u as k,w as v,f as p,C as g}from"./flow-host.styl.js";import{S as C,b as j,R as N,h as S,s as y,a as I,n as _}from"./bubble-frame.styl.js";import{M as x,g as T,a as R,b as M}from"./flow-condition-types.js";import{D as A,u as L,a as B,g as H}from"./stylesheets.js";import{u as O,F}from"./use-window-resize.js";import{o as P}from"./vendor.obj-str.js";import{S as D}from"./logomark.js";import{f as U,C as W}from"./ChecklistUI.js";import{f as $,a as z,b as q,c as V,d as K,e as G,g as Q,h as Z,i as J,j as Y,k as X}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{B as ee}from"./BubbleToolbar.js";import{u as te}from"./use-element-rect.js";import{u as ne}from"./vendor.react-i18next.js";function re(t){return t!==e.ACTION&&t!==e.ANNOUNCEMENTS&&t!==e.ASSISTANT&&t!==e.CONTACT&&t!==e.FLOWS&&t!==e.KNOWLEDGE_BASE&&t!==e.SUBPAGE}const se=window,oe={[t.CRISP]:{configure:({onShow:e,onHide:t})=>{!function(){if(ce)return;ce=!0,se.$crisp||(se.$crisp=[]);se.$crisp.push(["do","chat:hide"])}();let n=!1,r=!1;const s=()=>{n||r?(se.$crisp.push(["do","chat:show"]),e()):(se.$crisp.push(["do","chat:hide"]),t())},o=()=>{n=!0,s()};se.$crisp.push(["on","chat:opened",o]);const c=()=>{n=!1,s()};se.$crisp.push(["on","chat:closed",c]);const a=()=>{r=!0,s()};se.$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!==r&&(r=e,s())}),200);return()=>{se.$crisp.push(["off","chat:opened",o]),se.$crisp.push(["off","chat:closed",c]),se.$crisp.push(["off","message:received",a]),window.clearInterval(l)}},show:()=>{se.$crisp.push(["do","chat:show"]),se.$crisp.push(["do","chat:open"])},hide:()=>{se.$crisp.push(["do","chat:hide"]),se.$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(!se.fcWidget)throw new Error("Freshchat is not installed");let n=!1,r=!1;const s=()=>{n||r?e():t()},o=()=>{n=!0,s()};se.fcWidget.on("widget:opened",o);const c=()=>{n=!1,s()};se.fcWidget.on("widget:closed",c);const a=()=>{const e=!!document.querySelector("#fc_frame.h-open-notify");e!==r&&(r=e,s())},l=window.setInterval(a,200);return se.fcWidget.on("unreadCount:notify",a),()=>{se.fcWidget.off("widget:opened",o),se.fcWidget.off("widget:closed",c),se.fcWidget.off("unreadCount:notify",a),window.clearInterval(l)}},show:()=>{se.fcWidget.open()},hide:()=>{se.fcWidget.close()}},[t.HELPSCOUT]:{configure:({onShow:e,onHide:t})=>{if(!se.Beacon)throw new Error("Help Scout is not installed");!function(){if(ae)return;ae=!0,ie()}();let n=!1,r=!1;const s=()=>{n||r?(le(),e()):(ie(),t())},o=()=>{n=!0,s()};se.Beacon("on","open",o),se.Beacon("info")?.status.isOpened&&o();const c=()=>{n=!1,s()};se.Beacon("on","close",c);const a=window.setInterval((()=>{const e=!!document.querySelector(".BeaconNotificationsFrame");e!==r&&(r=e,s())}),200);return()=>{se.Beacon("off","open",o),se.Beacon("off","close",c),window.clearInterval(a)}},show:()=>{le(),se.Beacon("open")},hide:()=>{ie(),se.Beacon("close")}},[t.HUBSPOT]:{configure:({onShow:e,onHide:t})=>{const n=()=>{const n=document.getElementById("hubspot-messages-iframe-container");if(!se.HubSpotConversations||!n)return;window.clearInterval(s),function(){if(ue)return;ue=!0,de?me():fe()}();let o=!1,c=!1;const a=()=>{o||c?(me(),e()):(fe(),t())},l=()=>{const e=!!document.querySelector("#hubspot-messages-iframe-container .hs-shadow-container.active");e!==o&&(o=e,a())},i=new x(l);i.observe(n,{attributes:!0,subtree:!0,attributeFilter:["class"]}),l();const u=({unreadCount:e})=>{const t=e>0;t!==c&&(c=t,a())};se.HubSpotConversations.on("unreadConversationCountChanged",u),r=()=>{i.disconnect(),se.HubSpotConversations.off("unreadConversationCountChanged",u)}};let r=()=>{window.clearInterval(s)};const s=window.setInterval(n,100);return n(),()=>{r()}},show:()=>{me(),se.HubSpotConversations.widget.open()},hide:()=>{fe(),se.HubSpotConversations.widget.close()}},[t.INTERCOM]:{configure:({onShow:e,onHide:t})=>{if(!se.Intercom)throw new Error("Intercom is not installed");return function(){if(we)return;we=!0,ke();let e=!1,t=!1;const n=()=>{Ee();for(const e of he)e()},r=()=>{ke();for(const e of be)e()},s=()=>{e||t?n():r()};se.Intercom("onShow",(()=>{e=!0,s()})),se.Intercom("onHide",(()=>{e=!1,s()}));const o=()=>{const e=!!document.querySelector('iframe[name="intercom-borderless-frame"], iframe[name="intercom-notifications-frame"]');t!==e&&(t=e,s())};se.Intercom("onUnreadCountChange",(()=>{o()})),window.setInterval(o,200)}(),he.add(e),be.add(t),()=>{he.delete(e),be.delete(t)}},show:()=>{Ee(),se.Intercom("show")},hide:()=>{ke(),se.Intercom("hide")}},[t.ZENDESK]:{configure:({onShow:e,onHide:t})=>{if(!se.zE)throw new Error("Zendesk is not installed");!function(){if(ve)return;ve=!0,se.zE("webWidget","hide"),se.zE("webWidget","close"),se.zE("webWidget:on","open",(()=>{for(const e of pe)e()})),se.zE("webWidget:on","close",(()=>{for(const e of ge)e()})),se.zE("webWidget:on","chat:unreadMessages",(e=>{for(const t of Ce)t(e)}))}();let n=!1,r=!1;const s=()=>{n||r?(se.zE("webWidget","show"),e()):(se.zE("webWidget","hide"),t())},o=()=>{n=!0,r=!1,s()};pe.add(o);const c=()=>{n=!1,r=!1,s()};ge.add(c);const a=e=>{const t=e>0;t!==r&&(r=t,s())};return Ce.add(a),()=>{pe.delete(o),ge.delete(c),Ce.delete(a)}},show:()=>{se.zE("webWidget","show"),se.zE("webWidget","open")},hide:()=>{se.zE("webWidget","hide"),se.zE("webWidget","close")}},[t.ZENDESK_MESSENGER]:{configure:({onShow:e,onHide:t})=>{if(!se.zE)throw new Error("Zendesk is not installed");let n=!1;const r=window.setInterval((()=>{const r=(()=>{const e=document.querySelector('iframe[title="Messaging window"]');return!!e&&"0px"!==window.getComputedStyle(e).height})();r!==n&&(n=r,n?e():t())}),200);return()=>{window.clearInterval(r)}},show:()=>{se.zE("messenger","open")},hide:()=>{se.zE("messenger","close")}}};let ce=!1;let ae=!1;function le(){se.Beacon("config",{display:{style:"icon"}})}function ie(){se.Beacon("config",{display:{style:"manual"}})}let ue=!1,de=!1;function me(){de=!0;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","visible","important")}function fe(){de=!1;document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","hidden","important")}let we=!1,he=new Set,be=new Set;function Ee(){se.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function ke(){se.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let ve=!1,pe=new Set,ge=new Set,Ce=new Set;const je=e=>h.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},e),h.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"}),h.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"})),Ne=({center:e,fadeIn:t})=>{const n=12;return h.createElement("div",{className:P({"userflowjs-spinner":!0,"userflowjs-spinner--center":!!e,"userflowjs-spinner--fade-in":!!t})},h.createElement("svg",{viewBox:"0 0 24 24",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},h.createElement("circle",{className:"userflowjs-spinner__bg",fill:"none",cx:n,cy:n,r:10,style:{strokeWidth:"4px"}}),h.createElement("circle",{className:"userflowjs-spinner__fill",fill:"none",cx:n,cy:n,r:10,transform:"translate(12, 12) rotate(-90) translate(-12, -12)",style:{strokeWidth:"4px",strokeDasharray:20*Math.PI*.25+"px, 1000"}})))};function Se({message:e,skip:t}){const n=b(),[r,s]=h.useState(!0),[o,c]=h.useState(!1),[a,l]=h.useState(null),[i,u]=h.useState(null),[d,m]=h.useState(null),f=h.useRef(0),w=h.useRef(null),E=h.useRef((()=>{}));return h.useEffect((()=>{if(t)return;const r=JSON.stringify(e);if(r===w.current)return;w.current=r;const o=++f.current;let a,i;let d=!1;E.current=async(e,t)=>{if(!d){d=!0,c(!0);try{const r=e(a,i);i=r;const s=await n.send(r,{handlesRejection:!0});if(o!==f.current)return;a=t(a,s),l(a),m(null)}catch(r){if(o!==f.current)return;m(r)}finally{d=!1,c(!1)}}},(async()=>{s(!0);try{i=e;const t=await n.send(e,{handlesRejection:!0});if(o!==f.current)return;a=t,l(a),u(e),m(null)}catch(t){if(o!==f.current)return;m(t)}finally{s(!1)}})()}),[t,n,e]),{loading:r,loadingMore:o,data:a,messageForData:i,error:d,loadMore:E.current}}function ye(e,t){const[n,r]=h.useState(e),s=h.useRef(void 0),o=h.useCallback((e=>{window.clearTimeout(s.current),r(e),t(e)}),[t]),c=h.useCallback((e=>{window.clearTimeout(s.current),r(e),s.current=window.setTimeout((()=>{t(e)}),200)}),[t]);return h.useEffect((()=>()=>{window.clearTimeout(s.current)}),[]),[n,c,o]}const Ie=({textareaRef:e,value:t,onChange:n,onBlur:r,onKeyDown:s,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:i,mirrorClassName:u,textareaClassName:d,children:m})=>{let f=t||c||"";return(""===f||f.endsWith("\n"))&&(f+=" "),i=i||"growing-textarea",u=u||i+"__mirror",h.createElement("div",{className:i},h.createElement("div",{className:u+" "+(d||"")},f),h.createElement("textarea",{ref:e,value:t,onChange:e=>n&&n(e.target.value),onBlur:r,onKeyDown:s,onMouseDown:o,placeholder:c,disabled:a,readOnly:l,className:d}),m)},_e=({textareaRef:e,value:t,onChange:n,onSubmit:r,placeholder:s,readOnly:o})=>{const c=()=>{r&&r()};return h.createElement("div",{className:"userflowjs-assistant-chat-input"},h.createElement(Ie,{textareaRef:e,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:s,readOnly:o,value:t||"",onChange:n,onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||(e.preventDefault(),c())}}),h.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>c()},h.createElement(A,{icon:$})))};function xe(e){return n.linkUrlDecorator?n.linkUrlDecorator(e):e}const Te=async()=>(await w((()=>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("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("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.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("bubble-frame.styl.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.fortawesome.pro-solid-svg-icons.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("flow-host.styl.js",import.meta.url).toString(),new URL("use-window-resize.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString()])).ResourceCenterAssistantChat,Re=({session:l,isOpen:i,flowSession:u,checklistSession:d})=>{const m=b(),{t:f}=ne(),{company:w}=l.flow,{version:N}=l,S=N.resourceCenter,y=L(N.theme),I=l.locale?l.locale.standardLocaleId:l.version.theme.languageId;h.useEffect((()=>{E.changeLanguage(I)}),[I]);const{loaded:_}=B(window,p,y),[M,W]=h.useState(!1),$=_&&M,[G,Q]=h.useState(T()),[Z,J]=h.useState(R()),Y=h.useCallback((()=>{Q(T()),J(R())}),[]);O(Y);const{zIndex:X,bringToFront:ee}=k(),[te,se]=h.useState(null),[ce,ae]=h.useState(null),[le,ie]=h.useState(null),ue=h.useRef(null),[de,me]=h.useState(null),[fe,we]=h.useState(null),[he,be]=h.useState(null),[Ee,ke]=h.useState(0),[ve,pe]=h.useState(0),ge=h.useCallback((()=>{ce&&ke(Math.round(ce.offsetWidth)),pe(Math.round((le?.offsetHeight||0)+(de?.offsetHeight||0)+(fe?.offsetHeight||0)+(he?.offsetHeight||0)))}),[ce,le,de,fe,he]);h.useLayoutEffect((()=>{if(!te||"function"!=typeof x)return;const e=new x((()=>{ge()}));return e.observe(te,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect()}}),[te,ge]),h.useLayoutEffect((()=>{ge()}));const[Ce,Ne]=h.useState(!1),Se=h.useRef(),ye=h.useCallback((()=>{Ne(!0),window.clearTimeout(Se.current),Se.current=window.setTimeout((()=>{Ne(!1)}),y.resourceCenterTransitionDuration)}),[y.resourceCenterTransitionDuration]);h.useEffect((()=>()=>{window.clearTimeout(Se.current)}),[]);const Ie=h.useCallback((()=>{ee(),ye(),m.openResourceCenter()}),[ee,m,ye]),_e=h.useCallback((()=>{ye(),m.closeResourceCenter()}),[m,ye]),[xe,Te]=h.useState(!1);h.useEffect((()=>{if(xe){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?U(e):t.focus({preventScroll:!0})}}else ce?.focus({preventScroll:!0});Te(!1)}}),[xe,i,de,le,ce]),h.useEffect((()=>{const e=te?.ownerDocument.defaultView;if(!i||!e)return;const t=e=>{"Escape"===e.key&&(_e(),Te(!0))};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}),[i,te,Te,_e]);const[Re,Ae]=h.useState((()=>function(e,t){if(!t)return null;const n=JSON.parse(t);let r;n.blockCvid&&(r=e.version.resourceCenter?.blocks.find((e=>e.cvid===n.blockCvid)));if(!r&&"search"!==n.kind)return null;const s={kind:n.kind,block:r};switch(s.kind){case"announcementShow":s.announcementId=n.announcementId}return s}(l,r.getItem(`resourceCenterRoute:v1:${l.id}`)))),Oe=h.useCallback(((e,t)=>{Ae(e);const n=function(e){if(!e)return null;let t;"block"in e&&null!=e.block&&(t=e.block.cvid);const n={kind:e.kind,blockCvid:t};switch(e.kind){case"announcementShow":n.announcementId=e.announcementId}return JSON.stringify(n)}(e);n?r.setItem(`resourceCenterRoute:v1:${l.id}`,n):r.removeItem(`resourceCenterRoute:v1:${l.id}`),0===t?.detail&&Te(!0)}),[l.id]);h.useEffect((()=>{if(!l.draftMode)return;if(!Re||!("block"in Re)||!Re.block)return;const e=S.blocks.find((e=>e.cvid===Re.block.cvid));e?JSON.stringify(e)!==JSON.stringify(Re.block)&&Ae({...Re,block:e}):Ae(null),Re.block}),[l.draftMode,S,Re]);const Fe=h.useMemo((()=>S.blocks.filter((t=>!(t.type===e.CHECKLIST&&!d)&&((t.type!==e.DIVIDER||!y.resourceCenterAutoDividers)&&(!t.hiddenWhenFlowsActive||!t.hiddenWhenFlowsActive.some((e=>e===u?.flow.id||e===d?.flow.id))))))),[S,u,d,y.resourceCenterAutoDividers]),$e=h.useMemo((()=>Be(Fe)),[Fe]),ze=h.useMemo((()=>d&&S.blocks.some((t=>t.type===e.CHECKLIST))?s(d):0),[S,d]),Ve=h.useMemo((()=>S.blocks.find((t=>t.type===e.CONTACT&&t.chatEnabled&&t.chatProvider))),[S]),[Qe,Ze]=h.useState(!1),Je=h.useCallback((()=>{m.closeResourceCenter(),Ve&&Ve.chatProvider!==t.CUSTOM&&Ze(!0)}),[m,Ve]),Ye=h.useCallback((()=>{Ze(!1)}),[]),Xe=h.useCallback((()=>{if(Ve)try{oe[Ve.chatProvider].hide({block:Ve}),Ye()}catch(e){console.error(`Userflow.js: Error when hiding ${Ve.chatProvider}:`,e)}}),[Ve,Ye]);h.useEffect((()=>{if(!Ve)return;n.autoHide3pDisabled=!0;const e=oe[Ve.chatProvider];try{const t=e.configure({block:Ve,onShow:Je,onHide:Ye});return()=>{t()}}catch(t){return void console.error(`Userflow.js: Error when configuring ${Ve.chatProvider}:`,t)}}),[Ve,Je,Ye]),h.useEffect((()=>{i&&Xe()}),[Xe,i]);const nt=h.useMemo((()=>S.blocks.find((t=>t.type===e.ANNOUNCEMENTS))),[S]),rt=!!Re&&("search"===Re.kind||"flows"===Re.kind||"knowledgeBase"===Re.kind),st="assistant"===Re?.kind||"announcementList"===Re?.kind||"announcementShow"===Re?.kind,ot=Math.min(st?y.resourceCenterFullWidth:y.resourceCenterWidth,G-2*y.resourceCenterPaddingX),ct={zIndex:null!=y.resourceCenterZIndex?y.resourceCenterZIndex:i?X:v(g),position:$?void 0:"absolute",visibility:$&&!Qe?void 0:"hidden"},at={width:(i?ot:Ee)+"px",height:i?Math.min(rt?540:st?720:ve,Z-2*y.resourceCenterPaddingY,null==y.resourceCenterMaxHeight?Number.MAX_VALUE:y.resourceCenterMaxHeight)+"px":void 0},[lt,it]=h.useState(!1),ut=()=>{Ie(),Te(!0)},dt=y.resourceCenterDisplayChecklistProgress&&d&&ze>0?h.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},ze,h.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let mt="",ft="";return y.resourceCenterLauncherTextMode===o.CHECKLIST_OVERRIDE&&d&&ze>0?mt=d.version.checklist?.launcherText||"Get Started":y.resourceCenterLauncherTextMode!==o.NONE&&(ft=S.buttonText),h.createElement(C.Provider,{value:l},h.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center-app userflowjs-theme-root",style:H(y),dir:E.dir()},h.createElement("div",{className:P({"userflowjs-resource-center":!0,"userflowjs-resource-center--fixed":!0,[`userflowjs-resource-center--placement-${y.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0}),style:ct},h.createElement("div",{className:"userflowjs-resource-center-frame-wrapper",onMouseEnter:()=>it(!0),onMouseLeave:()=>it(!1)},h.createElement(F,{className:P({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--animating":Ce,"userflowjs-resource-center-frame--open":i,"userflowjs-resource-center-frame--closed":!i}),style:at,stylesheet:j,theme:y,onStylesheetsLoad:W,title:"Resource center"},$&&h.createElement(h.Fragment,null,h.createElement("div",{ref:se,className:P({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${y.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":Ce,"userflowjs-resource-center-frame-root--open":i,"userflowjs-resource-center-frame-root--closed":!i}),role:i?"dialog":void 0,"aria-label":i?S.headerText:void 0},h.createElement("div",{className:"userflowjs-resource-center-launcher-container"},h.createElement("button",{ref:ae,className:P({"userflowjs-resource-center-launcher-button":!0,"userflowjs-resource-center-launcher-button--hover":lt}),onClick:ut,"aria-label":`Open ${S.headerText}`},dt,mt&&h.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},mt),(dt||mt)&&h.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),ft&&h.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ft),h.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},y.resourceCenterLauncherIconType===c.PLAINTEXT?"?":h.createElement(je,null)))),h.createElement("div",{ref:ue,className:"userflowjs-resource-center-body",style:{width:ot+"px"}},h.createElement("div",{ref:me,className:P({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":"assistant"!==Re?.kind,"userflowjs-resource-center-body-content--same-background":y.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":w.resourceCenterBranding})},i&&h.createElement(h.Fragment,null,Re?"search"===Re.kind?h.createElement(Pe,{session:l,navigate:Oe}):"email"===Re.kind?h.createElement(De,{block:Re.block,session:l}):"phone"===Re.kind?h.createElement(Ue,{block:Re.block,session:l}):"flows"===Re.kind?h.createElement(We,{block:Re.block,initialQ:Re.initialQ,session:l,navigate:Oe}):"knowledgeBase"===Re.kind?h.createElement(qe,{block:Re.block,initialQ:Re.initialQ,session:l,bodyRef:ue}):"subpage"===Re.kind?h.createElement(Ke,{block:Re.block,session:l}):"announcementList"===Re.kind||"announcementShow"===Re.kind?h.createElement(Ge,{bodyRef:ue,session:l,route:Re,navigate:Oe}):"assistant"===Re.kind?h.createElement(et,{block:Re.block,initialUserContent:Re.initialUserContent,session:l,navigate:Oe,chatBlock:Ve,onChatShow:Je}):null:h.createElement(h.Fragment,null,Fe.map(((e,t)=>{const n=He[e.type],r=Fe[t+1];return n?h.createElement(h.Fragment,{key:e.id},h.createElement(n.View,{session:l,flowSession:u,checklistSession:d,block:e,navigate:Oe,onChatShow:Je}),r&&function(e,t,n){return!!e.resourceCenterAutoDividers&&(re(t)||re(n))}(y,e.type,r.type)&&h.createElement("div",{className:"userflowjs-resource-center-divider"})):null})))))),w.resourceCenterBranding&&h.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},h.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:we},h.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+w.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},h.createElement(D,null),h.createElement("div",null,"Made with Userflow")))),l.draftMode&&h.createElement("div",{className:"userflowjs-resource-center-preview"},h.createElement("div",{ref:be,className:"userflowjs-resource-center-preview-content"},h.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),h.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{m.endFlow(l,{endReason:a.USER_CLOSED})}},h.createElement(A,{icon:z})))),h.createElement("div",{className:"userflowjs-resource-center-header",style:{width:ot+"px"}},h.createElement("div",{ref:ie,className:"userflowjs-resource-center-header-content"},null==Re?h.createElement("div",{className:"userflowjs-resource-center-header-text"},S.headerText):h.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:e=>Oe("announcementShow"===Re?.kind?{kind:"announcementList",block:Re.block}:null,e)},h.createElement("div",{className:"userflowjs-rtl-mirrored"},h.createElement(A,{icon:q})),h.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},f("resource_center.back"))),h.createElement("div",{className:"flex-1"}),$e.length>0&&h.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let e={kind:"search"};if(1===$e.length){const t=$e[0],n=He[t.type];n.routeTo&&(e=n.routeTo({block:t}))}"search"===Re?.kind?Oe(null):(tt(m,l,null,"Search icon"),Oe(e))},"aria-label":"Search"},h.createElement(A,{icon:V})),h.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:e=>{_e(),0===e.detail&&Te(!0)},"aria-label":`Close ${S.headerText}`},h.createElement(A,{icon:K}))))))),!i&&!u&&nt&&nt.unreadAnnouncementCount>0&&h.createElement(Me,{theme:y,count:nt.unreadAnnouncementCount,onClick:ut})),!i&&!u&&nt?.popoutAnnouncement&&h.createElement(Le,{session:l,open:Ie,navigate:Oe,theme:y,block:nt}))))},Me=({theme:e,count:t,onClick:n})=>{const[r,s]=h.useState(!1);return h.createElement(F,{className:P({"userflowjs-resource-center-launcher-unread-badge":!0}),noScroll:!0,style:{position:r?void 0:"absolute",visibility:r?void 0:"hidden"},stylesheet:j,theme:e,onStylesheetsLoad:s,title:"Resource center unread badge"},h.createElement(Ae,{count:t,onClick:n}))},Ae=({count:e,onClick:t})=>{let n=null;return e>9&&(e=9,n=h.createElement("span",{className:"userflowjs-unread-badge-plus"},"+")),h.createElement("div",{className:P({"userflowjs-unread-badge":!0,"userflowjs-unread-badge--clickable":!!t}),onClick:t},h.createElement("span",null,e),n)},Le=({session:e,open:t,navigate:n,theme:r,block:s})=>{const o=s.popoutAnnouncement,c=b(),[a,l]=h.useState(!1),{height:i,setEl:u}=te(),d=h.useMemo((()=>CSS.supports("height: 100dvh")?"dvh":"vh"),[]);return h.createElement("div",{className:"userflowjs-resource-center-popout"},h.createElement(F,{className:P({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${i}px, 100${d} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - 20px)`,position:a?void 0:"absolute",visibility:a?void 0:"hidden"},stylesheet:j,theme:r,onStylesheetsLoad:l,title:"Resource center popout"},h.createElement("div",{ref:u,className:"userflowjs-resource-center-popout-frame-root"},h.createElement("h2",{className:"userflowjs-announcement-title"},h.createElement("span",{className:"userflowjs-unread-dot"}),h.createElement("span",null,o.title)),h.createElement("div",{className:"userflowjs-announcement-time"},h.createElement("div",{className:"userflowjs-announcement-time-text"},rt(o.time))),h.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},h.createElement(N,{doc:o.content,buttons:o.buttons})),o.moreEnabled&&h.createElement("div",{className:"userflowjs-announcement-more"},h.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>{Je(c,o),tt(c,e,s,o.title),n({kind:"announcementShow",block:s,announcementId:o.id}),t()}},h.createElement("div",null,(o.moreEnabled?o.moreButtonText:null)||"Read more"),h.createElement("span",{className:"userflowjs-rtl-mirrored"},h.createElement(A,{icon:G})))),h.createElement("div",{className:"userflowjs-bubble-toolbar"},h.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:()=>{Je(c,o)},"aria-label":"Dismiss announcement"},h.createElement(A,{icon:z}))))),h.createElement("div",{className:"userflowjs-resource-center-popout-notch"}))};function Be(e){return e.filter((e=>{const t=He[e.type];return t.isSearchable?t.isSearchable(e):!!t.search}))}const He={[e.ACTION]:{View:e=>{const{block:t,session:n,flowSession:r,checklistSession:s}=e,o=b(),[c,a]=h.useState(!1),i=r?.id,u=s?.id;return h.useEffect((()=>{a(!1)}),[i,u]),h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:c?void 0:()=>{tt(o,n,t);const e=t.actions.find((e=>e.type===l.START_FLOW));if(e){e.otherFlow?.id!==s?.flow.id&&a(!0)}else o.closeResourceCenter();S(o,n,t.actions)},disabled:c},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),c&&h.createElement(Ne,null))}},[e.ANNOUNCEMENTS]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"announcementList",block:t},e)}},t.unreadAnnouncementCount>0?h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(Ae,{count:t.unreadAnnouncementCount})):h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))}},[e.ASSISTANT]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b(),[o,c]=h.useState("");return t.assistantAppearance===i.INPUT?h.createElement("div",{className:"userflowjs-resource-center-assistant-block"},h.createElement(_e,{value:o,onChange:c,placeholder:y(t.name,{lookupAttribute:M(n.data)}),onSubmit:()=>{tt(s,n,t),r({kind:"assistant",block:t,initialUserContent:o})}})):h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{tt(s,n,t),r({kind:"assistant",block:t,initialUserContent:""})}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}))}},[e.CHECKLIST]:{View:({checklistSession:e})=>h.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},h.createElement(W,{session:e}),h.createElement(ee,{draftMode:!!e.draftMode&&"CHECKLIST PREVIEW"}))},[e.CONTACT]:{View:e=>{const{block:t,session:n,navigate:r,onChatShow:s}=e,o=b(),c=[];return t.emailEnabled&&c.push({icon:J,label:"Email",isRoute:!0,onClick:e=>{tt(o,n,t,"Email"),r({kind:"email",block:t},e)}}),t.phoneEnabled&&c.push({icon:Y,label:"Phone",isRoute:!0,onClick:e=>{tt(o,n,t,"Phone"),r({kind:"phone",block:t},e)}}),t.chatEnabled&&c.push({icon:X,label:"Live-chat",isRoute:!1,onClick:()=>{tt(o,n,t,"Chat"),st(n,t,s)}}),h.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&&h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:c[0].icon})),h.createElement(Fe,{...e}),c.length>1&&c.map((({icon:e,label:t,onClick:n},r)=>h.createElement("button",{key:r,className:"userflowjs-resource-center-icon-button",onClick:n,"aria-label":t},h.createElement(A,{icon:e})))),1===c.length&&c[0].isRoute&&h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))}},[e.DIVIDER]:{View:()=>h.createElement("div",{className:"userflowjs-resource-center-divider"})},[e.FLOWS]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"flows",block:t},e)}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))},routeTo:({block:e,initialQ:t})=>({kind:"flows",block:e,initialQ:t}),isSearchable:e=>!!e.searchEnabled,search:async({client:e,session:t,block:n,q:r})=>{const{flows:s}=await e.send({kind:"ListResourceCenterBlockFlows",sessionId:t.id,blockCvid:n.cvid},{handlesRejection:!0}),o=$e(s,r),c=o.slice(0,5);return{block:n,truncated:c.length===o.length,results:c.map((e=>({kind:"flow",flow:e})))}}},[e.KNOWLEDGE_BASE]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"knowledgeBase",block:t},e)}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))},routeTo:({block:e,initialQ:t})=>({kind:"knowledgeBase",block:e,initialQ:t}),search:async({client:e,session:t,block:n,q:r})=>{const{truncated:s,articles:o}=await e.send({kind:"SearchKnowledgeBase",sessionId:t.id,blockCvid:n.cvid,q:r,offset:0,limit:5},{handlesRejection:!0});return{block:n,truncated:s,results:o.map((e=>({kind:"article",article:e})))}}},[e.MESSAGE]:{View:({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-block"},h.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},h.createElement(N,{doc:e.content,lookupAttribute:M(t.data)})))},[e.SUBPAGE]:{View:e=>{const{block:t,session:n,navigate:r}=e,s=b();return h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:e=>{tt(s,n,t),r({kind:"subpage",block:t},e)}},h.createElement(Oe,{...e}),h.createElement(Fe,{...e}),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q})))}}},Oe=({block:e})=>e.icon?h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:e.icon,size:16})):null,Fe=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-block-text"},h.createElement(I,{doc:e.name,lookupAttribute:M(t.data)}));const Pe=({session:e,navigate:t})=>{const n=b(),r=e.version.resourceCenter.blocks,s=Be(r),{t:o}=ne(),c=h.useRef(null),[a,l]=h.useState(""),[i,u]=ye(a,l),[d,m]=h.useState(null);return h.useEffect((()=>{if(""===a.trim())return void m(null);let t=!1;return(async()=>{m(null);const s=await Promise.all(r.map((async t=>{const{search:r}=He[t.type];if(!r)return null;try{return await r({client:n,session:e,block:t,q:a})}catch(s){return console.error(`Userflow.js: Global search failed for ${t.type} block=`,t,"error=",s),null}})));t||m(s.filter((e=>null!=e&&e.results.length>0)))})(),()=>{t=!0}}),[n,e,r,a]),h.useEffect((()=>{c.current?.focus({preventScroll:!0})}),[]),h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-search"},h.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()?h.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},o("resource_center.search_in")," ",s.map(((t,n)=>h.createElement(h.Fragment,{key:t.cvid},n>0&&(n===s.length-1?` ${o("and")} `:", "),h.createElement("b",null,h.createElement(I,{doc:t.name,lookupAttribute:M(e.data)}))))),"."):d?0===d.length?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},o("resource_center.no_results_found")):d.map((({block:r,truncated:s,results:c},l)=>{const i=He[r.type],u=i.routeTo&&i.routeTo({block:r,initialQ:a});return h.createElement(h.Fragment,{key:r.cvid},l>0&&h.createElement("div",{className:"userflowjs-resource-center-divider"}),h.createElement("div",{className:"userflowjs-resource-center-label"},h.createElement(I,{doc:r.name,lookupAttribute:M(e.data)})),c.map(((n,s)=>"flow"===n.kind?h.createElement(ze,{key:n.flow.id,block:r,session:e,flow:n.flow,navigate:t}):"article"===n.kind?h.createElement(Ve,{key:s,block:r,session:e,article:n.article}):null)),!s&&u&&h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:s=>{tt(n,e,r),t(u,s)}},h.createElement("div",{className:"userflowjs-resource-center-block-text"},o("more"),":"," ",h.createElement(I,{doc:r.name,lookupAttribute:M(e.data)})),h.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},h.createElement(A,{icon:Q}))))})):h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)))},De=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},h.createElement(N,{doc:e.emailContent,lookupAttribute:M(t.data)})),Ue=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},h.createElement(N,{doc:e.phoneContent,lookupAttribute:M(t.data)})),We=({block:e,initialQ:t,session:n,navigate:r})=>{const{t:s}=ne(),o=h.useRef(null),[c,a]=h.useState(t||""),[l,i]=ye(c,a),{data:u,error:d}=Se({message:{kind:"ListResourceCenterBlockFlows",sessionId:n.id,blockCvid:e.cvid}}),m=u?.flows,f=h.useMemo((()=>m?$e(m,c):null),[m,c]);return h.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]),h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-header"},h.createElement("div",{className:"userflowjs-resource-center-list-route-title"},h.createElement(I,{doc:e.name,lookupAttribute:M(n.data)}))),e.searchEnabled&&h.createElement("div",{className:"userflowjs-resource-center-list-route-search"},h.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:s("resource_center.search_placeholder")})),d?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s("resource_center.generic_error")):f?0===f.length?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s("resource_center.no_results_found")):f.map((t=>h.createElement(ze,{key:t.id,block:e,session:n,flow:t,navigate:r}))):h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,{fadeIn:!0})))};function $e(e,t){const n=t.toLowerCase().trim();return""===n?e:e.filter((e=>e.name.toLowerCase().includes(n)))}const ze=({block:e,session:t,flow:n,navigate:r})=>{const s=b(),[o,c]=h.useState(!1);return h.useEffect((()=>{if(!o||n.type!==u.CHECKLIST)return;const e=()=>{s.checklistSession?.flow.id===n.id&&(t(),r(null))},t=()=>{s.off("checklistChanged",e)};return s.on("checklistChanged",e),t}),[s,o,n.type,n.id,r]),h.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if(tt(s,t,e,n.name),s.checklistSession?.flow.id===n.id)return void r(null);s.startFlow({flowId:n.id,startReason:d.RESOURCE_CENTER,replaceCurrent:!0}),c(!0);const o=y(n.url,{lookupAttribute:M(t.data)});o&&_(o)},disabled:o},h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:n.type===u.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),h.createElement("div",{className:"userflowjs-resource-center-block-text"},n.name),o&&h.createElement(Ne,null))},qe=({block:e,initialQ:t,session:n,bodyRef:r})=>{const{t:s}=ne(),o=h.useRef(null),[c,a]=h.useState(t||""),[l,i]=ye(c,a),{loading:u,loadingMore:d,data:m,messageForData:f,error:w,loadMore:b}=Se({message:{kind:"SearchKnowledgeBase",sessionId:n.id,blockCvid:e.cvid,q:c,offset:0}});nt({bodyRef:r,loading:u,loadingMore:d,truncated:m?.truncated,loadMoreHelper:h.useCallback((()=>{b(((e,t)=>({...t,offset:e.articles.length})),((e,t)=>({...t,articles:[...e.articles,...t.articles]})))}),[b])}),h.useEffect((()=>{o.current?.focus({preventScroll:!0})}),[]);let E=e.knowledgeBaseUrl||"";return E.match(/^https?:\/\//)||(E=`http://${E}`),E=xe(E),h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-header"},h.createElement("div",{className:"userflowjs-resource-center-list-route-title"},h.createElement(I,{doc:e.name,lookupAttribute:M(n.data)})),h.createElement("a",{className:"userflowjs-resource-center-icon-button",href:E,target:"_blank",rel:"noopener noreferrer"},h.createElement(A,{icon:Z}))),h.createElement("div",{className:"userflowjs-resource-center-list-route-search"},h.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:l,onChange:e=>i(e.target.value),placeholder:s("resource_center.search_placeholder")})),w?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},"quota_exceeded"===w.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.":w.humanMessage||s("resource_center.generic_error")):u||!m?h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)):0===m.articles.length?""===f?.q?null:h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s("resource_center.no_results_found")):h.createElement(h.Fragment,null,""===f?.q&&h.createElement("div",{className:"userflowjs-resource-center-label"},s("resource_center.suggested_articles")),m.articles.map(((t,r)=>h.createElement(Ve,{key:r,block:e,session:n,article:t}))),d&&h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null))))},Ve=({block:e,article:t,session:n})=>{const r=b();return h.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{tt(r,n,e,t.title)},href:xe(t.url),target:"_blank",rel:"noopener noreferrer"},h.createElement("div",{className:"userflowjs-resource-center-block-icon"},h.createElement(A,{icon:"regular/file-alt",size:16})),h.createElement("div",{className:"userflowjs-resource-center-block-text"},h.createElement("span",{dangerouslySetInnerHTML:{__html:t.htmlTitle}}),h.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:t.htmlSnippet}})))},Ke=({block:e,session:t})=>h.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},h.createElement(N,{doc:e.content,lookupAttribute:M(t.data)})),Ge=({bodyRef:e,session:t,route:n,navigate:r})=>{const s=b(),o=Se({message:{kind:"ListAnnouncements",beforeAnnouncementId:null},skip:"announcementList"!==n?.kind}),{loading:c,loadingMore:a,data:l,loadMore:i}=o,u=l?.truncated,d=h.useCallback((()=>{i(((e,t)=>e.announcements.length>0?{...t,beforeAnnouncementId:e.announcements[e.announcements.length-1].id}:t),((e,t)=>({...t,announcements:[...e.announcements,...t.announcements]})))}),[i]);nt({bodyRef:e,loading:c,loadingMore:a,truncated:u,loadMoreHelper:d});const[m,f]=h.useState(void 0);return h.useLayoutEffect((()=>{e.current&&null!=m&&"announcementList"===n?.kind&&(e.current.scrollTop=m)}),[e,m,n?.kind]),"announcementList"===n?.kind?h.createElement(Qe,{bodyRef:e,session:t,block:n.block,onMoreClick:o=>{f(e.current?.scrollTop),tt(s,t,n.block,o.title),r({kind:"announcementShow",block:n.block,announcementId:o.id})},...o}):"announcementShow"===n?.kind?h.createElement(Xe,{block:n.block,announcementId:n.announcementId}):null},Qe=({bodyRef:e,block:t,session:n,onMoreClick:r,error:s,loading:o,loadingMore:c,data:a})=>{const{t:l}=ne(),[i,u]=h.useMemo((()=>{const e=[],t=[];if(a){let n=-1;for(const r of a.announcements)n++,n<a.pageSize&&!r.seen&&r.level!==m.SILENT?e.push(r):t.push(r)}return[e,t]}),[a]),d=i.length;return h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-resource-center-list-route-header"},h.createElement("div",{className:"userflowjs-resource-center-list-route-title"},h.createElement(I,{doc:t.name,lookupAttribute:M(n.data)}))),s?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},s.humanMessage||l("resource_center.generic_error")):o||!a?h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)):0===a.announcements.length?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},E.exists("resource_center.no_announcements",{fallbackLng:[]})?l("resource_center.no_announcements"):l("resource_center.no_results_found")):h.createElement(h.Fragment,null,d>0&&h.createElement("div",{className:"userflowjs-announcement-unread-header"},l("resource_center.unread",{count:d})),i.map(((t,n)=>h.createElement(Ye,{key:n,bodyRef:e,onMoreClick:()=>r(t),announcement:t}))),i.length>0&&u.length>0&&h.createElement("div",{className:"userflowjs-announcement-seen-divider"}),u.map(((t,n)=>h.createElement(Ye,{key:n,bodyRef:e,onMoreClick:()=>r(t),announcement:t}))),c&&h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null))))},Ze=new Set;function Je(t,n){Ze.has(n.id)||(Ze.add(n.id),t.setResourceCenterSession((t=>t?{...t,version:{...t.version,resourceCenter:{...t.version.resourceCenter,blocks:t.version.resourceCenter.blocks.map((t=>t.type===e.ANNOUNCEMENTS?{...t,unreadAnnouncementCount:t.unreadAnnouncementCount-1,popoutAnnouncement:t.popoutAnnouncement?.id===n.id?null:t.popoutAnnouncement}:t))}}}:null)),t.toggleUI(),t.send({kind:"MarkAnnouncementSeen",announcementId:n.id,versionId:n.versionId}))}const Ye=({bodyRef:e,onMoreClick:t,announcement:n})=>{const r=b(),s=h.useRef(null),o=h.useRef(!1);return h.useEffect((()=>{if(o.current||n.seen)return;const t=new IntersectionObserver((e=>{const t=e[0];t&&t.isIntersecting&&(Je(r,n),o.current=!0,c())}),{root:e.current,threshold:1}),c=()=>{t.disconnect()};return t.observe(s.current),c}),[e,r,n]),h.createElement("div",{className:"userflowjs-announcement-list-item"},h.createElement("div",{className:"userflowjs-announcement-time-divider"},h.createElement("div",{className:"userflowjs-announcement-time-divider-line"}),h.createElement("div",{className:"userflowjs-announcement-time-text"},rt(n.time)),h.createElement("div",{className:"userflowjs-announcement-time-divider-line"})),h.createElement("h2",{ref:s,className:"userflowjs-announcement-title"},!n.seen&&n.level!==m.SILENT&&h.createElement("span",{className:"userflowjs-unread-dot"}),h.createElement("span",null,n.title)),h.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},h.createElement(N,{doc:n.content,buttons:n.buttons})),h.createElement("div",{className:"userflowjs-announcement-more"},n.moreEnabled&&h.createElement("button",{className:"userflowjs-tertiary-button",onClick:t},h.createElement("div",null,n.moreButtonText||"Read more"),h.createElement("span",{className:"userflowjs-rtl-mirrored"},h.createElement(A,{icon:G})))))},Xe=({announcementId:e})=>{const t=b(),{t:n}=ne(),{loading:r,data:s,error:o}=Se({message:{kind:"GetAnnouncement",announcementId:e}}),c=s?.announcement;return h.useEffect((()=>{c&&!c.seen&&Je(t,c)}),[t,c]),h.createElement(h.Fragment,null,o?h.createElement("div",{className:"userflowjs-resource-center-list-route-error"},o.humanMessage||n("resource_center.generic_error")):r||!c?h.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},h.createElement(Ne,null)):h.createElement(h.Fragment,null,h.createElement("div",{className:"userflowjs-announcement-show"},h.createElement("h2",{className:"userflowjs-announcement-title"},c?.title),h.createElement("div",{className:"userflowjs-announcement-time"},h.createElement("div",{className:"userflowjs-announcement-time-text"},rt(c.time))),h.createElement("div",{className:"userflowjs-bubble-content"},h.createElement(N,{doc:c.content,buttons:c.buttons}),c.moreEnabled&&h.createElement(N,{doc:c.moreContent,buttons:c.moreButtons})))))},et=({block:t,initialUserContent:n,session:s,navigate:o,onChatShow:c})=>{const a=t.assistantFlowId,l=b(),[i,u]=h.useState(null),[d,m]=h.useState(null),[w,E]=h.useState(null),[k]=h.useState(n);h.useEffect((()=>{n&&o({kind:"assistant",block:t,initialUserContent:""})}),[n,t,o]),h.useEffect((()=>{let e=!1;return(async()=>{try{const t=r.getItem("assistantConversationId:"+a),[n,s]=await Promise.all([Te(),l.send({kind:"GetAssistant",assistantFlowId:a,conversationId:t},{handlesRejection:!0,endBatch:!0})]);if(e)return;u((()=>n)),m(s)}catch(t){console.error("Resource center assistant route failed to load:",t),E(t.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{e=!0}}),[l,a]);const v=h.useMemo((()=>{if(!t.assistantContactEnabled)return;const n=s.version.resourceCenter?.blocks.find((t=>t.type===e.CONTACT));return n?()=>{switch(tt(l,s,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case f.EMAIL:o({kind:"email",block:n});break;case f.PHONE:o({kind:"phone",block:n});break;default:o(null),st(s,n,c)}}:void 0}),[l,s,t,c,o]);return w?h.createElement("div",{className:"userflowjs-assistant-chat"},h.createElement("div",{className:"userflowjs-assistant-chat__content"},h.createElement("div",{className:"userflowjs-assistant-chat__error"},w))):i&&d?h.createElement(i,{block:t,session:s,assistantReply:d,initialUserContent:k,onContactClick:v,contactButtonText:t.assistantContactButtonText||void 0}):h.createElement(Ne,{center:!0,fadeIn:!0})};function tt(e,t,n,r){e.send({kind:"ClickResourceCenter",sessionId:t.id,description:n?y(n.name,{lookupAttribute:M(t.data)})+(r?` - ${r}`:""):r},{batch:!0})}function nt({bodyRef:e,loading:t,loadingMore:n,truncated:r,loadMoreHelper:s}){h.useEffect((()=>{const o=e.current;if(!o||t||n||r)return;const c=()=>{o.scrollHeight-o.clientHeight-o.scrollTop>400||s()};return o.addEventListener("scroll",c),()=>{o.removeEventListener("scroll",c)}}),[e,t,n,r,s])}function rt(e){const t=e?new Date(e):new Date;let n=new Intl.DateTimeFormat(E.language,{weekday:"long",day:"numeric",month:"short",year:t.getFullYear()===(new Date).getFullYear()?void 0:"numeric"}).format(t);return n.substring(0,1).toUpperCase()+n.substring(1)}function st(e,t,n){if(t.chatProvider){const e=oe[t.chatProvider];try{e.show({block:t})}catch(r){console.error(`Userflow.js: Error when showing ${t.chatProvider}:`,r)}n()}else e.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.")}var ot=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",ResourceCenterApp:Re,default:Re});export{_e as A,Ie as G,ot as R,xe as d};
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{c as t,b as n,i as r,d as l}from"./flow-condition-types.js";import{b as a,D as o}from"./stylesheets.js";import{o as i}from"./vendor.obj-str.js";import{c as s,s as u,r as c,m as d,v as m,S as b,E as p,w as h,U as f,x as w,d as g}from"./userflow.js";import{f as v}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as E}from"./vendor.react-i18next.js";import{u as y}from"./client-context.js";const k=e.createContext(null);function _(){const t=e.useContext(k);if(!t)throw new Error("useSession: Session was not set");return t}function x(n){const r=_(),[l,o]=e.useState(!1),i=a(r.data),s=function(t){const n=e.useRef(t),r=e.useRef(t);return t!==r.current&&JSON.stringify(t)!==JSON.stringify(r.current)&&(n.current=t),r.current=t,n.current}(n);return e.useLayoutEffect((()=>{if(s){return t[s.type].track({sessionData:i,condition:s,callback:e=>{o(e)}})}}),[i,s]),null!=s&&l}const j=({appearance:t,hidden:n,disabled:r,onMouseDown:l,onClick:a,text:o,active:s,children:u})=>e.createElement("button",{className:i({[se(t)]:!0,"userflowjs-bubble-button--hidden":!!n,"userflowjs-bubble-button--active":!!s}),onMouseDown:l,onClick:a,disabled:r},u||e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},o));function q(e){const t=c();t!==new URL(e,t).toString()&&(s.customNavigate?s.customNavigate(e):window.setTimeout((()=>{u(e)}),0))}async function S(e,t,l){const{steps:a}=t.version;switch(l.type){case d.CLOSE_FLOW:switch(t.kind){case"launcher":await e.dismissLauncher(t,{endReason:p.ACTION});break;case"banner":case"flow":case"checklist":await e.endFlow(t,{endReason:p.ACTION})}return;case d.EVAL_JS:if(s.evalJsDisabled)return void console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');try{const e=r(l.code||"",t.data);new Function('"use strict";\n'+e)()}catch(o){console.error(`Userflow.js: Evaluate JavaScript action failed.\n\nError:\n${o.stack||o.message||o}\n\nCode:\n${l.code}`)}return;case d.GO_TO_STEP:{if("flow"!==t.kind)return;const n=a.find((({crossVersionId:e})=>e===l.stepCvid));if(!n)throw new f("Action points to unknown step: "+l.stepCvid);return void(await e.goToStep(t,n))}case d.NAVIGATE:{if(!l.url)return void console.warn("Userflow.js: NAVIGATE action is missing url property");const e=M(l.url,{lookupAttribute:n(t.data)});return void(l.navigateTarget===m.NEW_TAB?window.open(e):q(e))}case d.SET_ATTRIBUTE:{let t;const n=l.attributeValue||"";switch(l.attributeOperation){case h.SET:t={set:n};break;case h.SET_DATETIME:t={set:(new Date).toISOString()};break;case h.SET_DATETIME_ONCE:t={set_once:(new Date).toISOString()};break;case h.SET_ONCE:t={set_once:n};break;case h.ADD:t={add:n};break;case h.SUBTRACT:t={subtract:n};break;case h.APPEND:t={append:n};break;case h.PREPEND:t={prepend:n};break;case h.REMOVE:t={remove:n};break;case h.UNSET:t={set:null};break;default:return}const r=l.attributeFqn||"",a=r.split("/");return void(1===a.length?e.updateUser({[r]:t}):"group"===a[0]?e.updateGroup({[a[1]]:t}):"group_membership"===a[0]&&e.updateGroup({},{membership:{[a[1]]:t}}))}case d.SNOOZE:return void("flow"===t.kind&&l.timeValue&&l.timeUnit&&(e.endFlow(t,{endReason:p.SNOOZED,batch:!0}),t.draftMode?window.alert(`In preview mode, flows can't be snoozed.\n\nBut if this flow was running in published mode, the flow would now be snoozed for ${l.timeValue} ${l.timeUnit.toLowerCase()+(1===l.timeValue?"":"s")}.`):e.send({kind:"Snooze",flowId:t.flow.id,timeValue:l.timeValue,timeUnit:l.timeUnit},{batch:!0})));case d.START_FLOW:return"launcher"===t.kind&&e.deactivateLauncher(t),void(l.otherFlow?await e.startFlow({flowId:l.otherFlow.id,stepCvid:l.otherFlowStepCvid,startReason:t.draftMode?b.DRAFT:b.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow"))}}async function N(e,t,n){const r=[],l=[],a=[];for(const o of n)o.type===d.NAVIGATE?o.navigateTarget===m.NEW_TAB?r.push(o):a.push(o):l.push(o);for(const o of r)S(e,t,o);await Promise.all(l.map((n=>S(e,t,n))));for(const o of a)S(e,t,o)}const T=({button:t})=>{const n=y(),l=_(),a=x(t.disabledCondition),o=x(t.hiddenCondition);return e.createElement(j,{appearance:t.appearance,hidden:o,disabled:a,onClick:()=>N(n,l,t.actions),text:r(t.text,l.data)})},C=()=>e.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},e.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),A=({type:t,required:n,placeholder:r,buttonText:l,options:a,otherOption:s,multipleSelection:u,shuffleOptions:c,labelLeft:d,labelCenter:m,labelRight:b,minValue:p,maxValue:h,onSubmit:f,inert:g})=>{const{t:y}=E(),k=e.useRef(null),[_,x]=e.useState(""),[j,q]=e.useState(new Set),[S,N]=e.useState(),[T,A]=e.useState(),[P,L]=e.useState(!1),[$,R]=e.useState(!1),[M,O]=e.useState(null),F=e.useMemo((()=>a&&(c?[...a].sort((()=>Math.random()-.5)):a)),[a,c]),U=e=>{if(!g&&f){if(n&&""===_&&[w.MULTILINE_TEXT,w.TEXT].includes(t))return O(y("question.requiredError")),void D();R(!0),O(null),f({...e,onCancel:()=>{R(!1)},onError:e=>{R(!1),O(e||"Sorry, something went wrong saving your answer. Please try again.")}})}},D=e.useCallback((()=>{!g&&k.current&&k.current.focus()}),[g]),[B,W]=e.useState(!1);e.useEffect((()=>{B&&(D(),W(!1))}),[D,B]);const V=e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>U({answer:{kind:"text",value:_}}),tabIndex:g?-1:void 0,disabled:$},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l||y("question.submit"))));let J=null,K=0;if(t===w.NPS)d=d||y("question.npsLabelLeft"),b=b||y("question.npsLabelRight"),J=[0,1,2,3,4,5,6,7,8,9,10],K=J.length;else if([w.SCALE,w.STARS].includes(t)){h=null!=h?h:5,J=[];for(let e=p=null!=p?p:1;e<=h;e++)J.push(e);K=J.length}else t===w.MULTIPLE_CHOICE&&(K=(F?F.length:0)+(s&&!P?1:0));const[z,G]=e.useState(-1),H=-1===z?-1:Math.min(z,K-1),X=e=>{if(!e.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let t=null;if("ArrowRight"===e.key||"ArrowDown"===e.key?t=1:"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(t=-1),null!=t){e.preventDefault();const n=e.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let r=H+t;r<0?r=n.length-1:r>n.length-1&&(r=0),G(r),n[r].focus()}};let Q,Z=null,Y=null;if(J&&(d||m||b)){const t=[];d&&t.push(J[0],d),b&&t.push(J[J.length-1],b),Z=e.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},t.join(", ")),Y=e.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},e.createElement("div",{className:"userflowjs-bubble-question__scale-label"},d),m&&e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},m),e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},b))}switch(t){case w.MULTILINE_TEXT:Q=e.createElement(e.Fragment,null,e.createElement("textarea",{ref:k,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:_,onChange:e=>x(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&U({answer:{kind:"text",value:_}})},placeholder:r||y("question.placeholder"),readOnly:g||$,tabIndex:g?-1:void 0,rows:3,"aria-required":n?"true":void 0,"aria-invalid":null!=M?"true":void 0}),V);break;case w.MULTIPLE_CHOICE:{const t=()=>{_&&U({answer:{kind:"text",value:_},animationPromise:I()})},n=(F?.length||0)+(s?1:0),a=Math.max(0,Math.min(n,null==p?1:p)),c=Math.max(0,Math.min(n,null==h?n:h)),d=()=>{const e=(F||[]).filter(((e,t)=>j.has(t))).map((e=>e.value));s&&P&&""!==_&&e.push(_),a!==c||e.length===a?e.length<a?O(y("question.multiple_selection_too_few",{count:a})):e.length>c?O(y("question.multiple_selection_too_many",{count:c})):U({answer:{kind:"list",values:e}}):O(y("question.multiple_selection_wrong",{count:a}))};Q=e.createElement(e.Fragment,null,u&&e.createElement("div",{className:i({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!M})},y("question.multiple_selection_hint",{replace:{selected:j.size+(s&&P&&""!==_?1:0),range:a===c?a:`${a}-${c}`}}),M&&e.createElement(e.Fragment,null,". ",e.createElement("span",{role:"alert"},M))),e.createElement("div",{className:i({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!u,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!u}),role:u?"group":"radiogroup",tabIndex:g||-1!==H?-1:0,onKeyDown:X},F?.map((({value:t,label:n},r)=>e.createElement("button",{key:r,className:i({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":u?j.has(r):$&&!P&&_==t}),onClick:$?void 0:()=>{if(u){O(null);const e=new Set(j);j.has(r)?e.delete(r):e.add(r),q(e)}else L(!1),x(t),U({answer:{kind:"text",value:t},animationPromise:I()})},disabled:$,tabIndex:g||r!==H?-1:0,role:u?"checkbox":"radio","aria-label":n||t,"aria-checked":!P&&_==t},u?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(o,{icon:v}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},n||t)))),s&&(P?e.createElement("div",{className:i({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":u?""!=_:$})},u?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{x(""),L(!1)}},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(o,{icon:v}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("input",{ref:k,className:"userflowjs-bubble-question__multiple-choice-option-input",value:_,onChange:e=>x(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key?"Escape"===e.key&&(e.stopPropagation(),x(""),L(!1)):u?d():t()},onBlur:()=>{""===_&&L(!1)},placeholder:r||y("question.placeholder"),readOnly:g||$,tabIndex:g?-1:void 0}),!u&&e.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>t(),disabled:$,"aria-label":y("question.submit")},e.createElement(o,{icon:v}))):e.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:$?void 0:()=>{O(null),L(!0),W(!0)},disabled:$,tabIndex:g||F?.length!==H?-1:0,role:"radio","aria-label":y("question.other"),"aria-checked":"false"},u?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(o,{icon:v}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},y("question.other"))))),u&&e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:d,tabIndex:g?-1:void 0,disabled:$},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l||y("question.submit")))));break}case w.NPS:case w.SCALE:Q=e.createElement(e.Fragment,null,Z,e.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:g||-1!==H?-1:0,onKeyDown:X},J?.map(((t,n)=>e.createElement("button",{className:i({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":$&&S==t}),key:t,tabIndex:g||n!==H?-1:0,onClick:()=>{N(t),U({answer:{kind:"number",value:t},animationPromise:I()})},disabled:$,role:"radio","aria-checked":S==t},t)))),Y);break;case w.STARS:Q=e.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},Z,e.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:g||-1!==H?-1:0,onKeyDown:X},J?.map(((t,n)=>e.createElement("button",{className:i({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!$&&null!=T&&T>=t,"userflowjs-bubble-question__star--selected":$&&null!=S&&S>=t,"userflowjs-bubble-question__star--not-selected":$&&null!=S&&S<t}),key:t,tabIndex:g||n!==H?-1:0,onClick:()=>{N(t),U({answer:{kind:"number",value:t},animationPromise:I()})},onMouseOver:()=>A(t),onMouseLeave:()=>A(null),disabled:$,role:"radio","aria-checked":S==t,"aria-label":String(t)},e.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},e.createElement(C,null)),e.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},t))))),Y);break;case w.TEXT:Q=e.createElement(e.Fragment,null,e.createElement("input",{ref:k,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:_,onChange:e=>x(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||U({answer:{kind:"text",value:_}})},placeholder:r||y("question.placeholder"),readOnly:g||$,tabIndex:g?-1:void 0,"aria-required":n?"true":void 0,"aria-invalid":null!=M?"true":void 0}),V)}return e.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:g?"none":void 0}},M&&!(t===w.MULTIPLE_CHOICE&&u)&&e.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},M),Q)};function I(){return new Promise((e=>window.setTimeout(e,250)))}const P=({question:t})=>{const n=y(),r=function(){const e=_();if("flow"!==e.kind)throw new Error("useFlowSession: Wrong session kind");return e}();return e.createElement(A,{type:t.type,required:!!t.required,placeholder:t.placeholder||"",buttonText:t.buttonText||"",options:t.options,otherOption:t.otherOption,multipleSelection:t.multipleSelection,shuffleOptions:t.shuffleOptions,labelLeft:t.labelLeft||"",labelCenter:t.labelCenter||"",labelRight:t.labelRight||"",minValue:t.minValue,maxValue:t.maxValue,onSubmit:async e=>{g("answerQuestion",r.id,t.cvid,e);const{answer:l}=e;try{await Promise.all([await n.send({kind:"AnswerQuestion",sessionId:r.id,questionName:t.name,questionCvid:t.cvid,textAnswer:"text"==l.kind?l.value:null,numberAnswer:"number"==l.kind?String(l.value):null,listAnswer:"list"==l.kind?l.values:null}),e.animationPromise])}catch(o){return console.log("Userflow.js: Error when answering question:",o),void e.onError()}const{bindAttributeFqn:a}=t;if(a&&n.flowSession?.id===r.id){let e;switch(l.kind){case"text":e={name:a,value:l.value};break;case"number":e={name:a,value:String(l.value)};break;case"list":e={name:a,value:l.values}}n.optimisticClockUIUpdate((()=>{n.setFlowSession({...r,data:[...r.data.filter((e=>e.name!==a)),e]})}))}N(n,r,t.actions)}})},L=({text:t})=>{if(!t)return null;const n=t.split(/\n/);return 1===n.length?e.createElement(e.Fragment,null,n[0]):e.createElement(e.Fragment,null,n.map(((t,n)=>e.createElement(e.Fragment,{key:n},n>0&&e.createElement("br",null),t))))};function $(e=""){return{type:"paragraph",children:[{text:e}]}}function R(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse rich content doc: "+e)}if("rich2"===n.type)return n;throw new Error("Could not recognize rich content doc: "+e)}return function(e=""){return{type:"rich2",children:[$(e)]}}()}function M(e,{lookupAttribute:t}){if(!e)return"";"string"==typeof e&&(e=function(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse plaintext doc: "+e)}if("plaintext2"===n.type)return n;throw new Error("Could not recognize plaintext doc: "+e)}return function(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}()}(e));const n=[];function r(e){e&&e.forEach((e=>e&&function(e){if(le(e))e.text&&n.push(e.text);else switch(e.type){case"attribute":{const r=te(e,t);r&&n.push(r);break}default:r(e.children)}}(e)))}return r(e.children),n.join("")}function O(e){let t=!0;if(!e)return!0;"string"==typeof e&&(e=R(e));const n=new Set(["attribute","button","image","question","video"]);return ae(e,(e=>{le(e)?""!==e.text&&(t=!1):"type"in e&&n.has(e.type)&&(t=!1)})),t}const F=e.memo((({doc:t,...n})=>t?("string"==typeof t&&(t=R(t)),e.createElement(U,{parent:t,...n})):null)),U=({parent:t,...n})=>e.createElement(e.Fragment,null,t.children.map(((r,l)=>le(r)?e.createElement(D,{key:l,node:r}):e.createElement(W,{key:l,node:r,parent:t,...n})))),D=({node:t})=>t.text?e.createElement(B,{node:t},e.createElement(L,{text:t.text})):null,B=({node:t,children:n})=>(t.color&&"string"==typeof t.color&&(n=e.createElement("span",{style:{color:t.color}},n)),t.bold&&(n=e.createElement("b",null,n)),t.italic&&(n=e.createElement("i",null,n)),t.underline&&(n=e.createElement("u",null,n)),t.strikeThrough&&(n=e.createElement("s",null,n)),t.code&&(n=e.createElement("code",null,n)),t.small&&(n=e.createElement("small",null,n)),t.sup&&(n=e.createElement("sup",null,n)),n),W=({node:t,parent:n,...r})=>{const{lookupAttribute:l}=r,a=e.createElement(U,{parent:t,...r});switch(t.type){case"attribute":return e.createElement(V,{node:t,...r});case"button":return e.createElement(J,{node:t,...r});case"button-group":return e.createElement("div",{className:"userflowjs-bubble-buttons",style:{justifyContent:t.align}},a);case"column":return e.createElement("div",{style:Y(t,n)},a);case"column-group":return e.createElement("div",{className:"p-like",style:Z(t)},a);case"container":return e.createElement("div",{className:"p-like"+(t.className?` ${t.className}`:""),style:ee(t)},a);case"image":return e.createElement(z,{node:t,...r});case"link":return e.createElement("a",{href:M(t.href,{lookupAttribute:l}),target:"same"===t.target?"_top":"_blank",rel:"noopener noreferrer"},a);case"paragraph":return e.createElement("p",{className:X(t)},a);case"heading1":return e.createElement("h1",{className:X(t)},a);case"heading2":return e.createElement("h2",{className:X(t)},a);case"question":return e.createElement(K,{node:t,...r});case"quote":return e.createElement("blockquote",null,a);case"code-block":return e.createElement("pre",null,e.createElement("code",null,a));case"ordered-list":return e.createElement("ol",null,a);case"unordered-list":return e.createElement("ul",null,a);case"list-item":return e.createElement("li",null,a);case"video":return e.createElement(G,{node:t,...r});default:return e.createElement("div",null,a)}},V=({node:t,lookupAttribute:n})=>{let r=te(t,n);return e.createElement(B,{node:t},r)},J=({node:t,buttons:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement(T,{key:r.id,button:r}):null},K=({node:t,questions:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement(P,{key:r.id,question:r}):null},z=({node:t,lookupAttribute:n})=>{const{src:r,widthMode:a,displayWidth:o,width:i,height:s,marginTop:u,marginRight:c,marginBottom:d,marginLeft:m,align:b,hasLink:p,href:h}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:f,blockStyle:w}=Q({widthMode:a,displayWidth:o,width:i,height:s,marginTop:u,marginRight:c,marginBottom:d,marginLeft:m,align:b});let g=e.createElement("img",{src:l(r,(e=>encodeURIComponent((n?n(e):"")||""))),style:{...w,objectFit:"contain"},alt:""});return p&&h&&(g=e.createElement("a",{href:M(h,{lookupAttribute:n}),target:"same"===t.target?"_top":"_blank",rel:"noopener noreferrer",style:w},g)),e.createElement("div",{className:"p-like"},e.createElement("div",{style:f},g))},G=({node:t,lookupAttribute:n})=>{const{url:r,widthMode:l,displayWidth:a,width:o,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:b,blockStyle:p}=Q({widthMode:l,displayWidth:a,width:o,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m});return e.createElement("div",{className:"p-like"},e.createElement("div",{style:b},e.createElement("div",{style:p},e.createElement(H,{element:t,noFocus:!0,lookupAttribute:n}))))},H=({element:{embedType:t,url:n,src:r,autoPlay:a,controls:o,loop:i,muted:s},noFocus:u,forceMuted:c,lookupAttribute:d})=>{if(!n)return null;const m={width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block"},tabIndex:u?-1:void 0};if("video"===t)return e.createElement("video",{key:n+";"+String(a)+";"+String(o)+";"+String(i)+";"+String(s),src:n,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!a,controls:!1!==o,loop:i,muted:c||s});if(r){let t;try{t=new URL(r)}catch(w){return null}return c&&(t.searchParams.has("autoplay")||t.searchParams.has("autoPlay"))&&(t.searchParams.set("mute","1"),t.searchParams.set("muted","1"),t.searchParams.set("volume","0")),e.createElement("iframe",{src:t.toString(),...m})}let b=function(e,{iframeFallback:t}={}){let n;try{n=new URL(e)}catch(w){return{kind:"invalid"}}const{hostname:r,pathname:l,searchParams:a}=n;if(r.match(/^(www\.)?(use)?loom\.com$/)){const e=l.match(/^\/share\/([a-z0-9]+)$/i);if(e){const[,t]=e;return{kind:"ok",videoProvider:"loom",videoId:t,searchParams:a}}}if(e.startsWith("raw:")){return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:a}}if(e.startsWith("iframe:")){return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:a}}if(["youtube.com","www.youtube.com"].includes(r)){const e=a.get("v");if(e)return a.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:e,searchParams:a}}if("youtu.be"===r){const e=l.match(/^\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"youtube",videoId:t,searchParams:a}}}if("vimeo.com"===r){const e=l.match(/^\/(\d+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:a}}}if("player.vimeo.com"===r){const e=l.match(/^\/video\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:a}}}if(r.match(/^[^.]+\.wistia.com$/)){const e=l.match(/^\/medias\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"wistia",videoId:t,searchParams:a}}}return t?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:a}:{kind:"invalid"}}(n,{iframeFallback:!0});if("invalid"===b.kind)return null;const{videoProvider:p,videoId:h,searchParams:f}=b;switch(a=a||f.has("autoplay")||f.has("autoPlay"),p){case"iframe":return e.createElement("iframe",{src:l(h,(e=>encodeURIComponent((d?d(e):"")||""))),scrolling:f.get("scrolling")||void 0,...m});case"loom":return e.createElement("iframe",{src:`https://www.loom.com/embed/${h}?${f.toString()}`,...m});case"raw":return e.createElement("video",{src:h,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:f.has("autoplay"),muted:c||f.has("muted")});case"youtube":return c&&a&&f.set("mute","1"),e.createElement("iframe",{src:`https://www.youtube.com/embed/${h}?${f.toString()}`,...m});case"vimeo":return c&&a&&f.set("muted","1"),e.createElement("iframe",{src:`https://player.vimeo.com/video/${h}?${f.toString()}`,...m});case"wistia":return f.set("videoFoam","true"),c&&a&&f.set("volume","0"),e.createElement(e.Fragment,null,e.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${h}?${f.toString()}`,...m}))}};function X(e){return"right"===e.align?"userflowjs-text-align-end":"center"===e.align?"userflowjs-text-align-center":"justify"===e.align?"userflowjs-text-align-justify":""}function Q({widthMode:e,displayWidth:t,width:n,height:r,marginTop:l,marginRight:a,marginBottom:o,marginLeft:i,align:s}){const u={position:"relative"};"number"!=typeof t&&(t=100,e="percent"),"center"===s?(u.marginLeft="auto",u.marginRight="auto"):"right"===s&&(u.marginLeft="auto");let c=0;if(null!=l&&"number"==typeof l&&(u.marginTop=`${l}px`),null!=a&&"number"==typeof a&&(u.marginRight=`${a}px`,c+=a),null!=o&&"number"==typeof o&&(u.marginBottom=`${o}px`),null!=i&&"number"==typeof i&&(u.marginLeft=`${i}px`,c+=i),"number"!=typeof t||"number"!=typeof n||"number"!=typeof r)u.width="100px",u.height="100px";else if("px"===e){const e=10,l=Math.max(e,t);u.width=`${l}px`,u.height=l/(n/r)+"px"}else{const e=Math.max(0,Math.min(100,t));u.width=`calc(${e}% - ${c}px)`,u.height="0",u.paddingBottom=`calc((${e}% - ${c}px) / (${n} / ${r})`}return{wrapperStyle:u,blockStyle:{position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"}}}function Z(e){return{display:"flex",alignItems:"stretch",marginRight:`-${null==e.spacing?16:e.spacing}px`}}function Y(e,t){const n="fill"===e.widthMode||null==e.displayWidth;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:n?void 0:"px"===e.widthMode?`${e.displayWidth||50}px`:"percent"===e.widthMode?`${e.displayWidth||50}%`:void 0,flex:n?"1 0 0":void 0,marginRight:`${null==t.spacing?16:t.spacing}px`,marginBottom:"0"}}function ee(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:"px"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}px`:"percent"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}%`:void 0,minHeight:"px"===e.heightMode?`${e.displayHeight||50}px`:void 0,flex:"fill"===e.heightMode?"1 0 0":void 0,marginTop:null!=e.marginTop?`${e.marginTop}px`:void 0,marginRight:null!=e.marginRight?`${e.marginRight}px`:"fill"!==e.widthMode&&"center"===e.align?"auto":void 0,marginBottom:null!=e.marginBottom?`${e.marginBottom}px`:void 0,marginLeft:null!=e.marginLeft?`${e.marginLeft}px`:"fill"===e.widthMode||"center"!==e.align&&"right"!==e.align?void 0:"auto"}}function te(e,t){if(!t)return null;const n=e.attributeName;if("string"==typeof n){const r=t(n)||e.fallback;if("string"==typeof r)return r}return null}function ne(e){return Array.isArray(e.children)&&void 0===e.addMark}function re(e,t,n="type"){return ne(e)&&e[n]===t}function le(e){return"string"==typeof e.text}function ae(e,t){function n(e){e&&e.forEach(((e,r)=>e&&function(e,r){t(e,r),ne(e)&&n(e.children)}(e,r)))}n(Array.isArray(e)?e:e.children)}const oe=e.memo((({doc:t,lookupAttribute:n})=>t?e.createElement(e.Fragment,null,M(t,{lookupAttribute:n})):null));function ie(e,{buttons:t,questions:n}){const r=new Set,l=new Set;if(ae(e,(e=>{re(e,"button")&&r.add(e.cvid),re(e,"question")&&l.add(e.cvid)})),n){const t=n.filter((e=>!l.has(e.cvid)));t.length>0&&(e={...e,children:[...e.children,...t.map((e=>({type:"question",cvid:e.cvid,children:[{text:""}]})))]})}if(t){const n=t.filter((e=>!r.has(e.cvid)));n.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:n.map((e=>({type:"button",cvid:e.cvid,children:[{text:""}]})))}]})}return e}function se(e){return"userflowjs-bubble-button "+("primary"===(e=e||"default")||"PRIMARY"===e||"default"===e||"DEFAULT"===e||"banner-primary"===e||"banner-secondary"===e?`userflowjs-bubble-button--${e.toLowerCase()}`:e)}var ue=new URL("bubble-frame.css",import.meta.url).href;export{T as B,F as R,k as S,oe as a,ue as b,j as c,R as d,_ as e,te as g,N as h,le as i,ie as m,q as n,O as r,M as s,x as u};
1
+ import{r as e}from"./vendor.react.js";import{c as t,b as n,i as r,d as l}from"./flow-condition-types.js";import{b as a,D as o}from"./stylesheets.js";import{o as i}from"./vendor.obj-str.js";import{c as s,s as u,r as c,m as d,v as m,S as b,E as p,w as h,U as f,x as w,d as g}from"./userflow.js";import{f as v}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as E}from"./vendor.react-i18next.js";import{u as y}from"./client-context.js";const k=e.createContext(null);function _(){const t=e.useContext(k);if(!t)throw new Error("useSession: Session was not set");return t}function x(n){const r=_(),[l,o]=e.useState(!1),i=a(r.data),s=function(t){const n=e.useRef(t),r=e.useRef(t);return t!==r.current&&JSON.stringify(t)!==JSON.stringify(r.current)&&(n.current=t),r.current=t,n.current}(n);return e.useLayoutEffect((()=>{if(s){return t[s.type].track({sessionData:i,condition:s,callback:e=>{o(e)}})}}),[i,s]),null!=s&&l}const j=({appearance:t,hidden:n,disabled:r,onMouseDown:l,onClick:a,text:o,active:s,children:u})=>e.createElement("button",{className:i({[se(t)]:!0,"userflowjs-bubble-button--hidden":!!n,"userflowjs-bubble-button--active":!!s}),onMouseDown:l,onClick:a,disabled:r},u||e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},o));function q(e){const t=c();t!==new URL(e,t).toString()&&(s.customNavigate?s.customNavigate(e):window.setTimeout((()=>{u(e)}),0))}async function S(e,t,l){const{steps:a}=t.version;switch(l.type){case d.CLOSE_FLOW:switch(t.kind){case"launcher":await e.dismissLauncher(t,{endReason:p.ACTION});break;case"banner":case"flow":case"checklist":await e.endFlow(t,{endReason:p.ACTION})}return;case d.EVAL_JS:if(s.evalJsDisabled)return void console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');try{const e=r(l.code||"",t.data);new Function('"use strict";\n'+e)()}catch(o){console.error(`Userflow.js: Evaluate JavaScript action failed.\n\nError:\n${o.stack||o.message||o}\n\nCode:\n${l.code}`)}return;case d.GO_TO_STEP:{if("flow"!==t.kind)return;const n=a.find((({crossVersionId:e})=>e===l.stepCvid));if(!n)throw new f("Action points to unknown step: "+l.stepCvid);return void(await e.goToStep(t,n))}case d.NAVIGATE:{if(!l.url)return void console.warn("Userflow.js: NAVIGATE action is missing url property");const e=M(l.url,{lookupAttribute:n(t.data)});return void(l.navigateTarget===m.NEW_TAB?window.open(e):q(e))}case d.SET_ATTRIBUTE:{let t;const n=l.attributeValue||"";switch(l.attributeOperation){case h.SET:t={set:n};break;case h.SET_DATETIME:t={set:(new Date).toISOString()};break;case h.SET_DATETIME_ONCE:t={set_once:(new Date).toISOString()};break;case h.SET_ONCE:t={set_once:n};break;case h.ADD:t={add:n};break;case h.SUBTRACT:t={subtract:n};break;case h.APPEND:t={append:n};break;case h.PREPEND:t={prepend:n};break;case h.REMOVE:t={remove:n};break;case h.UNSET:t={set:null};break;default:return}const r=l.attributeFqn||"",a=r.split("/");return void(1===a.length?e.updateUser({[r]:t}):"group"===a[0]?e.updateGroup({[a[1]]:t}):"group_membership"===a[0]&&e.updateGroup({},{membership:{[a[1]]:t}}))}case d.SNOOZE:return void("flow"===t.kind&&l.timeValue&&l.timeUnit&&(e.endFlow(t,{endReason:p.SNOOZED,batch:!0}),t.draftMode?window.alert(`In preview mode, flows can't be snoozed.\n\nBut if this flow was running in published mode, the flow would now be snoozed for ${l.timeValue} ${l.timeUnit.toLowerCase()+(1===l.timeValue?"":"s")}.`):e.send({kind:"Snooze",flowId:t.flow.id,timeValue:l.timeValue,timeUnit:l.timeUnit},{batch:!0})));case d.START_FLOW:return"launcher"===t.kind&&e.deactivateLauncher(t),void(l.otherFlow?await e.startFlow({flowId:l.otherFlow.id,stepCvid:l.otherFlowStepCvid,startReason:t.draftMode?b.DRAFT:b.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow"))}}async function N(e,t,n){const r=[],l=[],a=[];for(const o of n)o.type===d.NAVIGATE?o.navigateTarget===m.NEW_TAB?r.push(o):a.push(o):l.push(o);for(const o of r)S(e,t,o);await Promise.all(l.map((n=>S(e,t,n))));for(const o of a)S(e,t,o)}const T=({button:t})=>{const n=y(),l=_(),a=x(t.disabledCondition),o=x(t.hiddenCondition);return e.createElement(j,{appearance:t.appearance,hidden:o,disabled:a,onClick:()=>N(n,l,t.actions),text:r(t.text,l.data)})},C=()=>e.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},e.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),A=({type:t,required:n,placeholder:r,buttonText:l,options:a,otherOption:s,multipleSelection:u,shuffleOptions:c,labelLeft:d,labelCenter:m,labelRight:b,minValue:p,maxValue:h,onSubmit:f,inert:g})=>{const{t:y}=E(),k=e.useRef(null),[_,x]=e.useState(""),[j,q]=e.useState(new Set),[S,N]=e.useState(),[T,A]=e.useState(),[P,L]=e.useState(!1),[$,R]=e.useState(!1),[M,O]=e.useState(null),F=e.useMemo((()=>a&&(c?[...a].sort((()=>Math.random()-.5)):a)),[a,c]),U=e=>{if(!g&&f){if(n&&""===_&&[w.MULTILINE_TEXT,w.TEXT].includes(t))return O(y("question.requiredError")),void D();R(!0),O(null),f({...e,onCancel:()=>{R(!1)},onError:e=>{R(!1),O(e||"Sorry, something went wrong saving your answer. Please try again.")}})}},D=e.useCallback((()=>{!g&&k.current&&k.current.focus()}),[g]),[B,W]=e.useState(!1);e.useEffect((()=>{B&&(D(),W(!1))}),[D,B]);const V=e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>U({answer:{kind:"text",value:_}}),tabIndex:g?-1:void 0,disabled:$},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l||y("question.submit"))));let J=null,K=0;if(t===w.NPS)d=d||y("question.npsLabelLeft"),b=b||y("question.npsLabelRight"),J=[0,1,2,3,4,5,6,7,8,9,10],K=J.length;else if([w.SCALE,w.STARS].includes(t)){h=null!=h?h:5,J=[];for(let e=p=null!=p?p:1;e<=h;e++)J.push(e);K=J.length}else t===w.MULTIPLE_CHOICE&&(K=(F?F.length:0)+(s&&!P?1:0));const[z,G]=e.useState(-1),H=-1===z?-1:Math.min(z,K-1),X=e=>{if(!e.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let t=null;if("ArrowRight"===e.key||"ArrowDown"===e.key?t=1:"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(t=-1),null!=t){e.preventDefault();const n=e.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let r=H+t;r<0?r=n.length-1:r>n.length-1&&(r=0),G(r),n[r].focus()}};let Q,Z=null,Y=null;if(J&&(d||m||b)){const t=[];d&&t.push(J[0],d),b&&t.push(J[J.length-1],b),Z=e.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},t.join(", ")),Y=e.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},e.createElement("div",{className:"userflowjs-bubble-question__scale-label"},d),m&&e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},m),e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},b))}switch(t){case w.MULTILINE_TEXT:Q=e.createElement(e.Fragment,null,e.createElement("textarea",{ref:k,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:_,onChange:e=>x(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&U({answer:{kind:"text",value:_}})},placeholder:r||y("question.placeholder"),readOnly:g||$,tabIndex:g?-1:void 0,rows:3,"aria-required":n?"true":void 0,"aria-invalid":null!=M?"true":void 0}),V);break;case w.MULTIPLE_CHOICE:{const t=()=>{_&&U({answer:{kind:"text",value:_},animationPromise:I()})},n=(F?.length||0)+(s?1:0),a=Math.max(0,Math.min(n,null==p?1:p)),c=Math.max(0,Math.min(n,null==h?n:h)),d=()=>{const e=(F||[]).filter(((e,t)=>j.has(t))).map((e=>e.value));s&&P&&""!==_&&e.push(_),a!==c||e.length===a?e.length<a?O(y("question.multiple_selection_too_few",{count:a})):e.length>c?O(y("question.multiple_selection_too_many",{count:c})):U({answer:{kind:"list",values:e}}):O(y("question.multiple_selection_wrong",{count:a}))};Q=e.createElement(e.Fragment,null,u&&e.createElement("div",{className:i({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!M})},y("question.multiple_selection_hint",{replace:{selected:j.size+(s&&P&&""!==_?1:0),range:a===c?a:`${a}-${c}`}}),M&&e.createElement(e.Fragment,null,". ",e.createElement("span",{role:"alert"},M))),e.createElement("div",{className:i({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!u,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!u}),role:u?"group":"radiogroup",tabIndex:g||-1!==H?-1:0,onKeyDown:X},F?.map((({value:t,label:n},r)=>e.createElement("button",{key:r,className:i({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":u?j.has(r):$&&!P&&_==t}),onClick:$?void 0:()=>{if(u){O(null);const e=new Set(j);j.has(r)?e.delete(r):e.add(r),q(e)}else L(!1),x(t),U({answer:{kind:"text",value:t},animationPromise:I()})},disabled:$,tabIndex:g||r!==H?-1:0,role:u?"checkbox":"radio","aria-label":n||t,"aria-checked":!P&&_==t},u?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(o,{icon:v}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},n||t)))),s&&(P?e.createElement("div",{className:i({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":u?""!=_:$})},u?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{x(""),L(!1)}},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(o,{icon:v}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("input",{ref:k,className:"userflowjs-bubble-question__multiple-choice-option-input",value:_,onChange:e=>x(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key?"Escape"===e.key&&(e.stopPropagation(),x(""),L(!1)):u?d():t()},onBlur:()=>{""===_&&L(!1)},placeholder:r||y("question.placeholder"),readOnly:g||$,tabIndex:g?-1:void 0}),!u&&e.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>t(),disabled:$,"aria-label":y("question.submit")},e.createElement(o,{icon:v}))):e.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:$?void 0:()=>{O(null),L(!0),W(!0)},disabled:$,tabIndex:g||F?.length!==H?-1:0,role:"radio","aria-label":y("question.other"),"aria-checked":"false"},u?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(o,{icon:v}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},y("question.other"))))),u&&e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:d,tabIndex:g?-1:void 0,disabled:$},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l||y("question.submit")))));break}case w.NPS:case w.SCALE:Q=e.createElement(e.Fragment,null,Z,e.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:g||-1!==H?-1:0,onKeyDown:X},J?.map(((t,n)=>e.createElement("button",{className:i({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":$&&S==t}),key:t,tabIndex:g||n!==H?-1:0,onClick:()=>{N(t),U({answer:{kind:"number",value:t},animationPromise:I()})},disabled:$,role:"radio","aria-checked":S==t},t)))),Y);break;case w.STARS:Q=e.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},Z,e.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:g||-1!==H?-1:0,onKeyDown:X},J?.map(((t,n)=>e.createElement("button",{className:i({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!$&&null!=T&&T>=t,"userflowjs-bubble-question__star--selected":$&&null!=S&&S>=t,"userflowjs-bubble-question__star--not-selected":$&&null!=S&&S<t}),key:t,tabIndex:g||n!==H?-1:0,onClick:()=>{N(t),U({answer:{kind:"number",value:t},animationPromise:I()})},onMouseOver:()=>A(t),onMouseLeave:()=>A(null),disabled:$,role:"radio","aria-checked":S==t,"aria-label":String(t)},e.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},e.createElement(C,null)),e.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},t))))),Y);break;case w.TEXT:Q=e.createElement(e.Fragment,null,e.createElement("input",{ref:k,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:_,onChange:e=>x(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||U({answer:{kind:"text",value:_}})},placeholder:r||y("question.placeholder"),readOnly:g||$,tabIndex:g?-1:void 0,"aria-required":n?"true":void 0,"aria-invalid":null!=M?"true":void 0}),V)}return e.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:g?"none":void 0}},M&&!(t===w.MULTIPLE_CHOICE&&u)&&e.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},M),Q)};function I(){return new Promise((e=>window.setTimeout(e,250)))}const P=({question:t})=>{const n=y(),r=function(){const e=_();if("flow"!==e.kind)throw new Error("useFlowSession: Wrong session kind");return e}();return e.createElement(A,{type:t.type,required:!!t.required,placeholder:t.placeholder||"",buttonText:t.buttonText||"",options:t.options,otherOption:t.otherOption,multipleSelection:t.multipleSelection,shuffleOptions:t.shuffleOptions,labelLeft:t.labelLeft||"",labelCenter:t.labelCenter||"",labelRight:t.labelRight||"",minValue:t.minValue,maxValue:t.maxValue,onSubmit:async e=>{g("answerQuestion",r.id,t.cvid,e);const{answer:l}=e;try{await Promise.all([await n.send({kind:"AnswerQuestion",sessionId:r.id,questionName:t.name,questionCvid:t.cvid,textAnswer:"text"==l.kind?l.value:null,numberAnswer:"number"==l.kind?String(l.value):null,listAnswer:"list"==l.kind?l.values:null}),e.animationPromise])}catch(o){return console.log("Userflow.js: Error when answering question:",o),void e.onError()}const{bindAttributeFqn:a}=t;if(a&&n.flowSession?.id===r.id){let e;switch(l.kind){case"text":e={name:a,value:l.value};break;case"number":e={name:a,value:String(l.value)};break;case"list":e={name:a,value:l.values}}n.optimisticClockUIUpdate((()=>{n.setFlowSession({...r,data:[...r.data.filter((e=>e.name!==a)),e]})}))}N(n,r,t.actions)}})},L=({text:t})=>{if(!t)return null;const n=t.split(/\n/);return 1===n.length?e.createElement(e.Fragment,null,n[0]):e.createElement(e.Fragment,null,n.map(((t,n)=>e.createElement(e.Fragment,{key:n},n>0&&e.createElement("br",null),t))))};function $(e=""){return{type:"paragraph",children:[{text:e}]}}function R(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse rich content doc: "+e)}if("rich2"===n.type)return n;throw new Error("Could not recognize rich content doc: "+e)}return function(e=""){return{type:"rich2",children:[$(e)]}}()}function M(e,{lookupAttribute:t}){if(!e)return"";"string"==typeof e&&(e=function(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse plaintext doc: "+e)}if("plaintext2"===n.type)return n;throw new Error("Could not recognize plaintext doc: "+e)}return function(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}()}(e));const n=[];function r(e){e&&e.forEach((e=>e&&function(e){if(le(e))e.text&&n.push(e.text);else switch(e.type){case"attribute":{const r=te(e,t);r&&n.push(r);break}default:r(e.children)}}(e)))}return r(e.children),n.join("")}function O(e){let t=!0;if(!e)return!0;"string"==typeof e&&(e=R(e));const n=new Set(["attribute","button","image","question","video"]);return ae(e,(e=>{le(e)?""!==e.text&&(t=!1):"type"in e&&n.has(e.type)&&(t=!1)})),t}const F=e.memo((({doc:t,...n})=>t?("string"==typeof t&&(t=R(t)),e.createElement(U,{parent:t,...n})):null)),U=({parent:t,...n})=>e.createElement(e.Fragment,null,t.children.map(((r,l)=>le(r)?e.createElement(D,{key:l,node:r}):e.createElement(W,{key:l,node:r,parent:t,...n})))),D=({node:t})=>t.text?e.createElement(B,{node:t},e.createElement(L,{text:t.text})):null,B=({node:t,children:n})=>(t.color&&"string"==typeof t.color&&(n=e.createElement("span",{style:{color:t.color}},n)),t.bold&&(n=e.createElement("b",null,n)),t.italic&&(n=e.createElement("i",null,n)),t.underline&&(n=e.createElement("u",null,n)),t.strikeThrough&&(n=e.createElement("s",null,n)),t.code&&(n=e.createElement("code",null,n)),t.small&&(n=e.createElement("small",null,n)),t.sup&&(n=e.createElement("sup",null,n)),n),W=({node:t,parent:n,...r})=>{const{lookupAttribute:l}=r,a=e.createElement(U,{parent:t,...r});switch(t.type){case"attribute":return e.createElement(V,{node:t,...r});case"button":return e.createElement(J,{node:t,...r});case"button-group":return e.createElement("div",{className:"userflowjs-bubble-buttons",style:{justifyContent:t.align}},a);case"column":return e.createElement("div",{style:Y(t,n)},a);case"column-group":return e.createElement("div",{className:"p-like",style:Z(t)},a);case"container":return e.createElement("div",{className:"p-like"+(t.className?` ${t.className}`:""),style:ee(t)},a);case"image":return e.createElement(z,{node:t,...r});case"link":return e.createElement("a",{href:M(t.href,{lookupAttribute:l}),target:"same"===t.target?"_top":"_blank",rel:"noopener noreferrer"},a);case"paragraph":return e.createElement("p",{className:X(t)},a);case"heading1":return e.createElement("h1",{className:X(t)},a);case"heading2":return e.createElement("h2",{className:X(t)},a);case"question":return e.createElement(K,{node:t,...r});case"quote":return e.createElement("blockquote",null,a);case"code-block":return e.createElement("pre",null,e.createElement("code",null,a));case"ordered-list":return e.createElement("ol",null,a);case"unordered-list":return e.createElement("ul",null,a);case"list-item":return e.createElement("li",null,a);case"video":return e.createElement(G,{node:t,...r});default:return e.createElement("div",null,a)}},V=({node:t,lookupAttribute:n})=>{let r=te(t,n);return e.createElement(B,{node:t},r)},J=({node:t,buttons:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement(T,{key:r.id,button:r}):null},K=({node:t,questions:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement(P,{key:r.id,question:r}):null},z=({node:t,lookupAttribute:n})=>{const{src:r,widthMode:a,displayWidth:o,width:i,height:s,marginTop:u,marginRight:c,marginBottom:d,marginLeft:m,align:b,hasLink:p,href:h}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:f,blockStyle:w}=Q({widthMode:a,displayWidth:o,width:i,height:s,marginTop:u,marginRight:c,marginBottom:d,marginLeft:m,align:b});let g=e.createElement("img",{src:l(r,(e=>encodeURIComponent((n?n(e):"")||""))),style:{...w,objectFit:"contain"},alt:""});return p&&h&&(g=e.createElement("a",{href:M(h,{lookupAttribute:n}),target:"same"===t.target?"_top":"_blank",rel:"noopener noreferrer",style:w},g)),e.createElement("div",{className:"p-like"},e.createElement("div",{style:f},g))},G=({node:t,lookupAttribute:n})=>{const{url:r,widthMode:l,displayWidth:a,width:o,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:b,blockStyle:p}=Q({widthMode:l,displayWidth:a,width:o,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m});return e.createElement("div",{className:"p-like"},e.createElement("div",{style:b},e.createElement("div",{style:p},e.createElement(H,{element:t,noFocus:!0,lookupAttribute:n}))))},H=({element:{embedType:t,url:n,src:r,autoPlay:a,controls:o,loop:i,muted:s},noFocus:u,forceMuted:c,lookupAttribute:d})=>{if(!n)return null;const m={width:"100%",height:"100%",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block",border:"none"},tabIndex:u?-1:void 0};if("video"===t)return e.createElement("video",{key:n+";"+String(a)+";"+String(o)+";"+String(i)+";"+String(s),src:n,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!a,controls:!1!==o,loop:i,muted:c||s});if(r){let t;try{t=new URL(r)}catch(w){return null}return c&&(t.searchParams.has("autoplay")||t.searchParams.has("autoPlay"))&&(t.searchParams.set("mute","1"),t.searchParams.set("muted","1"),t.searchParams.set("volume","0")),e.createElement("iframe",{src:t.toString(),...m})}let b=function(e,{iframeFallback:t}={}){let n;try{n=new URL(e)}catch(w){return{kind:"invalid"}}const{hostname:r,pathname:l,searchParams:a}=n;if(r.match(/^(www\.)?(use)?loom\.com$/)){const e=l.match(/^\/share\/([a-z0-9]+)$/i);if(e){const[,t]=e;return{kind:"ok",videoProvider:"loom",videoId:t,searchParams:a}}}if(e.startsWith("raw:")){return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:a}}if(e.startsWith("iframe:")){return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:a}}if(["youtube.com","www.youtube.com"].includes(r)){const e=a.get("v");if(e)return a.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:e,searchParams:a}}if("youtu.be"===r){const e=l.match(/^\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"youtube",videoId:t,searchParams:a}}}if("vimeo.com"===r){const e=l.match(/^\/(\d+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:a}}}if("player.vimeo.com"===r){const e=l.match(/^\/video\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:a}}}if(r.match(/^[^.]+\.wistia.com$/)){const e=l.match(/^\/medias\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"wistia",videoId:t,searchParams:a}}}return t?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:a}:{kind:"invalid"}}(n,{iframeFallback:!0});if("invalid"===b.kind)return null;const{videoProvider:p,videoId:h,searchParams:f}=b;switch(a=a||f.has("autoplay")||f.has("autoPlay"),p){case"iframe":return e.createElement("iframe",{src:l(h,(e=>encodeURIComponent((d?d(e):"")||""))),scrolling:f.get("scrolling")||void 0,...m});case"loom":return e.createElement("iframe",{src:`https://www.loom.com/embed/${h}?${f.toString()}`,...m});case"raw":return e.createElement("video",{src:h,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:f.has("autoplay"),muted:c||f.has("muted")});case"youtube":return c&&a&&f.set("mute","1"),e.createElement("iframe",{src:`https://www.youtube.com/embed/${h}?${f.toString()}`,...m});case"vimeo":return c&&a&&f.set("muted","1"),e.createElement("iframe",{src:`https://player.vimeo.com/video/${h}?${f.toString()}`,...m});case"wistia":return f.set("videoFoam","true"),c&&a&&f.set("volume","0"),e.createElement(e.Fragment,null,e.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${h}?${f.toString()}`,...m}))}};function X(e){return"right"===e.align?"userflowjs-text-align-end":"center"===e.align?"userflowjs-text-align-center":"justify"===e.align?"userflowjs-text-align-justify":""}function Q({widthMode:e,displayWidth:t,width:n,height:r,marginTop:l,marginRight:a,marginBottom:o,marginLeft:i,align:s}){const u={position:"relative"};"number"!=typeof t&&(t=100,e="percent"),"center"===s?(u.marginLeft="auto",u.marginRight="auto"):"right"===s&&(u.marginLeft="auto");let c=0;if(null!=l&&"number"==typeof l&&(u.marginTop=`${l}px`),null!=a&&"number"==typeof a&&(u.marginRight=`${a}px`,c+=a),null!=o&&"number"==typeof o&&(u.marginBottom=`${o}px`),null!=i&&"number"==typeof i&&(u.marginLeft=`${i}px`,c+=i),"number"!=typeof t||"number"!=typeof n||"number"!=typeof r)u.width="100px",u.height="100px";else if("px"===e){const e=10,l=Math.max(e,t);u.width=`${l}px`,u.height=l/(n/r)+"px"}else{const e=Math.max(0,Math.min(100,t));u.width=`calc(${e}% - ${c}px)`,u.height="0",u.paddingBottom=`calc((${e}% - ${c}px) / (${n} / ${r})`}return{wrapperStyle:u,blockStyle:{position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"}}}function Z(e){return{display:"flex",alignItems:"stretch",marginRight:`-${null==e.spacing?16:e.spacing}px`}}function Y(e,t){const n="fill"===e.widthMode||null==e.displayWidth;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:n?void 0:"px"===e.widthMode?`${e.displayWidth||50}px`:"percent"===e.widthMode?`${e.displayWidth||50}%`:void 0,flex:n?"1 0 0":void 0,marginRight:`${null==t.spacing?16:t.spacing}px`,marginBottom:"0"}}function ee(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:"px"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}px`:"percent"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}%`:void 0,minHeight:"px"===e.heightMode?`${e.displayHeight||50}px`:void 0,flex:"fill"===e.heightMode?"1 0 0":void 0,marginTop:null!=e.marginTop?`${e.marginTop}px`:void 0,marginRight:null!=e.marginRight?`${e.marginRight}px`:"fill"!==e.widthMode&&"center"===e.align?"auto":void 0,marginBottom:null!=e.marginBottom?`${e.marginBottom}px`:void 0,marginLeft:null!=e.marginLeft?`${e.marginLeft}px`:"fill"===e.widthMode||"center"!==e.align&&"right"!==e.align?void 0:"auto"}}function te(e,t){if(!t)return null;const n=e.attributeName;if("string"==typeof n){const r=t(n)||e.fallback;if("string"==typeof r)return r}return null}function ne(e){return Array.isArray(e.children)&&void 0===e.addMark}function re(e,t,n="type"){return ne(e)&&e[n]===t}function le(e){return"string"==typeof e.text}function ae(e,t){function n(e){e&&e.forEach(((e,r)=>e&&function(e,r){t(e,r),ne(e)&&n(e.children)}(e,r)))}n(Array.isArray(e)?e:e.children)}const oe=e.memo((({doc:t,lookupAttribute:n})=>t?e.createElement(e.Fragment,null,M(t,{lookupAttribute:n})):null));function ie(e,{buttons:t,questions:n}){const r=new Set,l=new Set;if(ae(e,(e=>{re(e,"button")&&r.add(e.cvid),re(e,"question")&&l.add(e.cvid)})),n){const t=n.filter((e=>!l.has(e.cvid)));t.length>0&&(e={...e,children:[...e.children,...t.map((e=>({type:"question",cvid:e.cvid,children:[{text:""}]})))]})}if(t){const n=t.filter((e=>!r.has(e.cvid)));n.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:n.map((e=>({type:"button",cvid:e.cvid,children:[{text:""}]})))}]})}return e}function se(e){return"userflowjs-bubble-button "+("primary"===(e=e||"default")||"PRIMARY"===e||"default"===e||"DEFAULT"===e||"banner-primary"===e||"banner-secondary"===e?`userflowjs-bubble-button--${e.toLowerCase()}`:e)}var ue=new URL("bubble-frame.css",import.meta.url).href;export{T as B,F as R,k as S,oe as a,ue as b,j as c,R as d,_ as e,te as g,N as h,le as i,ie as m,q as n,O as r,M as s,x as u};
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 5a7324bd1dea355ded810beb47bbcce07d30ece6
1
+ 98fd9244e235ba8478bd3088dbea7bae6464a075
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1005270",
3
+ "version": "0.1.1005315",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{g as s,a,c as o,d as r}from"./stylesheets.js";import{a as n,i as d}from"./client-context.js";var l=new URL("iframe-reset.css",import.meta.url).href;const i=({testId:t,className:n,style:d,elRef:i,stylesheet:f,theme:u,onStylesheetsLoad:y,noIframe:w,noScroll:v,ariaHidden:E,children:h})=>{w=w||!1;const[p,N]=e.useState(null),S=u&&"userflowjs-theme-root",R=u&&s(u),{loaded:I}=a(p,w?null:l),{loaded:L}=a(p,f,u),{loaded:b}=o(p,u),j=u&&r(u),{loaded:H}=a(p,j,u,{uninstallOnUnmount:!0});return e.useEffect((()=>{y&&I&&L&&b&&H&&y(!0)}),[y,I,L,b,H]),w?e.createElement(m,{testId:t,className:n,style:d,rootClassName:S,rootStyle:R,elRef:i,onWinReady:N,noScroll:v,ariaHidden:E},h):e.createElement(c,{testId:t,className:n,style:d,rootClassName:S,rootStyle:R,elRef:i,onWinReady:N,noScroll:v,ariaHidden:E},h)},c=({testId:s,className:a,style:o,rootClassName:r,rootStyle:l,elRef:i,onWinReady:c,noScroll:m,ariaHidden:f,children:u})=>{const y=n(),[w,v]=e.useState(null);e.useLayoutEffect((()=>{if(!w)return;const{documentElement:e,body:t}=w.document;e.dir=d.dir();const s=r&&r.split(" ");if(s&&t.classList.add(...s),l)for(const a in l)t.style.setProperty(a,l[a]);return t.style.overflow=m?"hidden":"",()=>{s&&t.classList.remove(...s)}}),[w,r,l,m]);const E=y?.logrocketAppId;e.useRef(!1),e.useEffect((()=>{}),[w,E]);return e.createElement("iframe",{ref:e=>{if(!e)return;i&&(i.current=e);const t=e.contentWindow;if(!t||t===w)return;const s=e=>{v(e),c(e)};"complete"===t.document.readyState?s(t):t.addEventListener("load",(()=>{s(t)}))},"data-testid":s,role:"presentation","aria-hidden":f?"true":void 0,tabIndex:f?-1:void 0,className:a,style:o,frameBorder:0,bis_size:"{}"},w&&t.createPortal(u,w.document.body))},m=({testId:t,className:s,style:a,rootClassName:o,rootStyle:r,elRef:n,onWinReady:l,ariaHidden:i,children:c})=>(e.useEffect((()=>{l(window)}),[l]),e.createElement("div",{ref:n,"data-testid":t,"aria-hidden":i?"true":void 0,tabIndex:i?-1:void 0,dir:d.dir(),className:s,style:a},e.createElement("div",{className:o,style:r},c)));function f(t){e.useLayoutEffect((()=>{let e;const s=()=>{window.cancelAnimationFrame(e),e=window.requestAnimationFrame(t)};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),window.cancelAnimationFrame(e)}}),[t])}export{i as F,f as u};
1
+ import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{g as s,a as o,c as a,d as r}from"./stylesheets.js";import{a as n,i as l}from"./client-context.js";var d=new URL("iframe-reset.css",import.meta.url).href;const i=({testId:t,className:n,style:l,elRef:i,stylesheet:f,theme:u,onStylesheetsLoad:y,noIframe:w,noScroll:v,ariaHidden:E,title:h,children:p})=>{w=w||!1;const[N,S]=e.useState(null),R=u&&"userflowjs-theme-root",I=u&&s(u),{loaded:L}=o(N,w?null:d),{loaded:b}=o(N,f,u),{loaded:j}=a(N,u),H=u&&r(u),{loaded:W}=o(N,H,u,{uninstallOnUnmount:!0});return e.useEffect((()=>{y&&L&&b&&j&&W&&y(!0)}),[y,L,b,j,W]),w?e.createElement(m,{testId:t,className:n,style:l,rootClassName:R,rootStyle:I,elRef:i,onWinReady:S,noScroll:v,ariaHidden:E},p):e.createElement(c,{testId:t,className:n,style:l,rootClassName:R,rootStyle:I,elRef:i,onWinReady:S,noScroll:v,ariaHidden:E,title:h},p)},c=({testId:s,className:o,style:a,rootClassName:r,rootStyle:d,elRef:i,onWinReady:c,noScroll:m,ariaHidden:f,title:u,children:y})=>{const w=n(),[v,E]=e.useState(null);e.useLayoutEffect((()=>{if(!v)return;const{documentElement:e,body:t}=v.document;e.dir=l.dir();const s=r&&r.split(" ");if(s&&t.classList.add(...s),d)for(const o in d)t.style.setProperty(o,d[o]);return t.style.overflow=m?"hidden":"",()=>{s&&t.classList.remove(...s)}}),[v,r,d,m]);const h=w?.logrocketAppId;e.useRef(!1),e.useEffect((()=>{}),[v,h]);return e.createElement("iframe",{ref:e=>{if(!e)return;i&&(i.current=e);const t=e.contentWindow;if(!t||t===v)return;const s=e=>{E(e),c(e)};"complete"===t.document.readyState?s(t):t.addEventListener("load",(()=>{s(t)}))},"data-testid":s,role:"presentation","aria-hidden":f?"true":void 0,title:u,tabIndex:f?-1:void 0,className:o,style:{...a,border:"none"},bis_size:"{}"},v&&t.createPortal(y,v.document.body))},m=({testId:t,className:s,style:o,rootClassName:a,rootStyle:r,elRef:n,onWinReady:d,ariaHidden:i,children:c})=>(e.useEffect((()=>{d(window)}),[d]),e.createElement("div",{ref:n,"data-testid":t,"aria-hidden":i?"true":void 0,tabIndex:i?-1:void 0,dir:l.dir(),className:s,style:o},e.createElement("div",{className:a,style:r},c)));function f(t){e.useLayoutEffect((()=>{let e;const s=()=>{window.cancelAnimationFrame(e),e=window.requestAnimationFrame(t)};return window.addEventListener("resize",s),()=>{window.removeEventListener("resize",s),window.cancelAnimationFrame(e)}}),[t])}export{i as F,f as u};
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}`}isSupported(){if("undefined"==typeof window)return!1;try{return null!=window[this.type]}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,t){e=this.formatKey(e),this.isSupported()&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),this.isSupported())return window[this.type].removeItem(e)}clear(){if(this.isSupported())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 T(e){window.postMessage(e,window.origin)}function S(e){const t=t=>{if(t.source!==window||t.origin!==window.origin)return;const i=t.data;i&&"object"==typeof i&&"string"==typeof i.kind&&i.kind.startsWith("userflow:")&&!0===e(i)&&s()};window.addEventListener("message",t);const s=()=>window.removeEventListener("message",t);return s}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const f=new Set;let w=!1;function p(e){return function(){if(w)return;w=!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()}))}(),f.add(e),()=>{g(e)}}function g(e){f.delete(e)}function I(){f.forEach((e=>e()))}class C{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){T({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=S(e),!1}async captureScreenshot(e,t,s,i){T({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=>{S((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,R,N,v,O,y,_,b,D,M,F,B,P,x,H,G,W,$,V,K,j,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,Te,Se,fe,we,pe,ge,Ie,Ce,me,ke,Ae,Ue,Le,Re,Ne,ve,Oe,ye,_e,be,De,Me,Fe,Be,Pe,xe,He,Ge,We,$e,Ve,Ke,je,ze,Ye,Je,Xe,Ze,Qe,qe;(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",(v=N||(N={})).LIKE="LIKE",v.DISLIKE="DISLIKE",(y=O||(O={})).STRING="STRING",y.BOOLEAN="BOOLEAN",y.NUMBER="NUMBER",y.DATETIME="DATETIME",y.LIST="LIST",y.RANDOM_AB="RANDOM_AB",y.RANDOM_NUMBER="RANDOM_NUMBER",(b=_||(_={})).FLOW="FLOW",b.BANNER="BANNER",b.CHECKLIST="CHECKLIST",b.LAUNCHER="LAUNCHER",b.RESOURCE_CENTER="RESOURCE_CENTER",(M=D||(D={})).ALWAYS_TRUE="ALWAYS_TRUE",M.ATTRIBUTE="ATTRIBUTE",M.CLAUSE="CLAUSE",M.ELEMENT="ELEMENT",M.FILLED_IN_INPUT="FILLED_IN_INPUT",M.FLOW="FLOW",M.INPUT_VALUE="INPUT_VALUE",M.PAGE="PAGE",M.SEGMENT="SEGMENT",M.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(F||(F={})),(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",(K=V||(V={})).INSIDE="INSIDE",K.OUTSIDE="OUTSIDE",(z=j||(j={})).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",(Se=Te||(Te={})).NEW_TAB="NEW_TAB",Se.SAME_TAB="SAME_TAB",(we=fe||(fe={})).SET="SET",we.SET_DATETIME="SET_DATETIME",we.SET_DATETIME_ONCE="SET_DATETIME_ONCE",we.SET_ONCE="SET_ONCE",we.ADD="ADD",we.SUBTRACT="SUBTRACT",we.APPEND="APPEND",we.PREPEND="PREPEND",we.REMOVE="REMOVE",we.UNSET="UNSET",(ge=pe||(pe={})).MULTILINE_TEXT="MULTILINE_TEXT",ge.MULTIPLE_CHOICE="MULTIPLE_CHOICE",ge.NPS="NPS",ge.SCALE="SCALE",ge.STARS="STARS",ge.TEXT="TEXT",(Ce=Ie||(Ie={})).ACTION="ACTION",Ce.ANNOUNCEMENTS="ANNOUNCEMENTS",Ce.ASSISTANT="ASSISTANT",Ce.CHECKLIST="CHECKLIST",Ce.CONTACT="CONTACT",Ce.DIVIDER="DIVIDER",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={})).EMAIL="EMAIL",Re.PHONE="PHONE",Re.CHAT="CHAT",(ve=Ne||(Ne={})).SILENT="SILENT",ve.BADGE="BADGE",ve.POPOUT="POPOUT",(ye=Oe||(Oe={})).LAUNCHER_CLICK="LAUNCHER_CLICK",ye.LAUNCHER_HOVER="LAUNCHER_HOVER",ye.TARGET_CLICK="TARGET_CLICK",ye.TARGET_HOVER="TARGET_HOVER",ye.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",ye.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(be=_e||(_e={})).ACTIVATE="ACTIVATE",be.DEACTIVATE="DEACTIVATE",be.NEVER="NEVER",(Me=De||(De={})).AUTO="AUTO",Me.TOP="TOP",Me.RIGHT="RIGHT",Me.BOTTOM="BOTTOM",Me.LEFT="LEFT",(Be=Fe||(Fe={})).START="START",Be.CENTER="CENTER",Be.END="END",(xe=Pe||(Pe={})).PERCENT="PERCENT",xe.PX="PX",(Ge=He||(He={})).BEACON="BEACON",Ge.BUTTON="BUTTON",Ge.HIDDEN="HIDDEN",Ge.ICON="ICON",($e=We||(We={})).LAUNCHER="LAUNCHER",$e.TARGET="TARGET",(Ke=Ve||(Ve={})).BODY_FIRST="BODY_FIRST",Ke.BODY_LAST="BODY_LAST",Ke.ELEMENT_FIRST="ELEMENT_FIRST",Ke.ELEMENT_LAST="ELEMENT_LAST",Ke.ELEMENT_BEFORE="ELEMENT_BEFORE",Ke.ELEMENT_AFTER="ELEMENT_AFTER",(ze=je||(je={})).START="START",ze.CENTER="CENTER",ze.SPACE_BETWEEN="SPACE_BETWEEN",(Je=Ye||(Ye={})).NONE="NONE",Je.LIKE="LIKE",Je.SCALE="SCALE",(Ze=Xe||(Xe={})).ACTIVE="ACTIVE",Ze.COMPLETED="COMPLETED",Ze.ENDED="ENDED",Ze.NOT_SEEN="NOT_SEEN",(qe=Qe||(Qe={})).HIGHLIGHT="HIGHLIGHT",qe.MODAL="MODAL",qe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const et={customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator: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,evalJsDisabled:!1};function tt(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function st(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function it(){let e=d();if(et.urlFilter){if(e=et.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}let nt="";try{nt=localStorage.getItem("debug")||""}catch(ft){}const ot=nt.split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),rt=ct("log");let at;function ct(e){return function(t,...s){if(ot){const i=performance.now(),n=at?Math.round(i-at):0;at=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}rt.group=ct("group"),rt.groupCollapsed=ct("groupCollapsed"),rt.groupEnd=function(){ot&&console.groupEnd()};const lt=()=>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("flow-host.styl.js",import.meta.url).toString(),new URL("bubble-frame.styl.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.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("use-window-resize.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("logomark.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString()]);function dt(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class ht{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 ut=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Et=()=>n((()=>import("./BannerApp.js")),[new URL("BannerApp.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.obj-str.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.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("bubble-frame.styl.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("use-selector-element-monitoring.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("use-window-resize.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]),Tt=import.meta.url;class St{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.bannerSession=null,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=>{rt(`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,isTargetTab:!0,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}),this.setSessionStorageState((e=>({...e,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0}))),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void(e.testStartCondition?this.setSessionStorageState((t=>({...t,activeApp:"startConditionTesting",testStartConditionToken:e.token}))):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}),this.setSessionStorageState((e=>({...e,isTargetTab:!0}))),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)&&(rt("remounting UI because container was missing"),this.remount())},rt("constructor, build=1005270"),p(this.onUrlChange),this.setTargetEnv(new C),this.checkTestUserAtBoot(),this.toggleUI();for(const e of ut)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){rt("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv();for(const e of ut)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 t=c.getItem("userflowClientState");if(t)try{e=JSON.parse(t)}catch(ft){console.error("Userflow.js: Parse ElementSelectionState error:",ft)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(rt("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(rt("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?rt("init() ignoring new token since a test user has been identified"):(this.clientToken&&(rt("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",rt("connecting to socket");let t=et.serverEndpoint||"e.userflow.com";"js.getuserflow.com"===new URL(Tt).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((()=>{rt("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),rt("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:"1005270",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.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 rt("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():(rt("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.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)}rt(`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`;"connected"===this._socketStatus&&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",(s=>{r();const n=`Userflow.js error reply (${s.code}): ${s.message}`;console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n,s.code,s.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){rt(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,bannerSession:r,resourceCenterSession:a}=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 rt(`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"SetBannerSession":return this.setBannerSession(e.session),void this.toggleUI();case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):rt(`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()):rt(`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"TestStartConditionSuccess":return void this.emit("private:testStartConditionSuccess");case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetBannerSession":return void(r?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI()));case"UnsetChecklistSession":return o>t?void rt(`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 rt(`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(a?.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(rt("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)rt("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&&(rt("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={}){if(!a.isSupported())throw new o("userflow.identifyAnonymous() is not supported when localStorage access is denied.");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={}){rt("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if(rt("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)rt("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={}){rt("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 O.STRING;case"number":return O.NUMBER;case"boolean":return O.BOOLEAN;case"datetime":return O.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=O.STRING;break;case"boolean":n=O.BOOLEAN;break;case"integer":case"decimal":n=O.NUMBER;break;case"datetime":n=O.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}={}){rt(`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&&(rt(`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:it(),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(){rt("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),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,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0)}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}),rt(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return rt("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(),rt("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,s=this.resourceCenterSession.version.resourceCenter?.blocks.find((e=>e.type===Ie.ANNOUNCEMENTS));return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?dt(t):0,unreadAnnouncementCount:s?.unreadAnnouncementCount||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.bannerSession?.id===e.id&&this.setBannerSession(null),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){rt("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(){rt("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){rt("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")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const t=this.resourceCenterSession;e="function"==typeof e?e(this.resourceCenterSession):e,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===_e.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(){const e=this.getSessionStorageState();this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),e.isTargetTab&&this.monitorTitle(),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.bannerSession||!!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&&(rt("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(rt("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.bannerSession&&Et(),this.resourceCenterSession&&lt();const{RealUI:t}=await e;return new t(this)}catch(ft){throw this.reportCspIssue(),ft}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;rt("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.v}))),[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 ht([]),condition:e,callback:t=>{i.isTrue!==t&&(rt("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&&(rt("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.v}))),[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 ht(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})},description:`event tracker ${o.flowId}`}),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"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const t=new MutationObserver((()=>{this.fixTitle()}));t.observe(e,{childList:!0}),this.titleObserver=t}}fixTitle(){const e=document.title,t="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==t&&(document.title=t)}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,rt("csp issue detected"),T({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 St;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&&et.customInputs.push({cssSelector:e})},registerCustomInput(e,t){et.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){et.customNavigate=e},setUrlFilter(e){et.urlFilter=e},setLinkUrlDecorator(t){et.linkUrlDecorator=t,e.emit("uistatechange")},setInferenceAttributeNames(e){et.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){et.inferenceAttributeFilters[e]=tt(t)},setInferenceClassNameFilter(e){et.inferenceClassNameFilters=tt(e)},setScrollPadding(e){et.scrollPadding=e},setCustomScrollIntoView(e){et.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){et.baseZIndex=e},setServerEndpoint(e){et.serverEndpoint=e},disableEvalJs(){et.evalJsDisabled=!0},_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;rt(`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)}rt("queue processed")}()}export{Ye as $,Ne as A,Et as B,me as C,W as D,m as E,P as F,Y as G,a as H,Ve as I,X as J,ne as K,ce as L,Q as M,j as N,de as O,He as P,Oe as Q,lt as R,L as S,ut as T,o as U,re as V,De as W,We as X,Fe as Y,Pe as Z,n as _,B as a,N as a0,F as b,et as c,rt as d,D as e,H as f,it as g,Ie as h,c as i,dt as j,se as k,ee as l,ue as m,Ae as n,p as o,_ as p,Le as q,d as r,l as s,st as t,g as u,Te as v,fe as w,pe as x,ht as y,V 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}`}isSupported(){if("undefined"==typeof window)return!1;try{return null!=window[this.type]}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,t){e=this.formatKey(e),this.isSupported()&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),this.isSupported())return window[this.type].removeItem(e)}clear(){if(this.isSupported())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 T(e){window.postMessage(e,window.origin)}function S(e){const t=t=>{if(t.source!==window||t.origin!==window.origin)return;const i=t.data;i&&"object"==typeof i&&"string"==typeof i.kind&&i.kind.startsWith("userflow:")&&!0===e(i)&&s()};window.addEventListener("message",t);const s=()=>window.removeEventListener("message",t);return s}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const f=new Set;let w=!1;function p(e){return function(){if(w)return;w=!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()}))}(),f.add(e),()=>{g(e)}}function g(e){f.delete(e)}function I(){f.forEach((e=>e()))}class C{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){T({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=S(e),!1}async captureScreenshot(e,t,s,i){T({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=>{S((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,R,N,v,O,y,_,b,D,M,F,B,P,x,H,G,W,$,V,K,j,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,Te,Se,fe,we,pe,ge,Ie,Ce,me,ke,Ae,Ue,Le,Re,Ne,ve,Oe,ye,_e,be,De,Me,Fe,Be,Pe,xe,He,Ge,We,$e,Ve,Ke,je,ze,Ye,Je,Xe,Ze,Qe,qe;(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",(v=N||(N={})).LIKE="LIKE",v.DISLIKE="DISLIKE",(y=O||(O={})).STRING="STRING",y.BOOLEAN="BOOLEAN",y.NUMBER="NUMBER",y.DATETIME="DATETIME",y.LIST="LIST",y.RANDOM_AB="RANDOM_AB",y.RANDOM_NUMBER="RANDOM_NUMBER",(b=_||(_={})).FLOW="FLOW",b.BANNER="BANNER",b.CHECKLIST="CHECKLIST",b.LAUNCHER="LAUNCHER",b.RESOURCE_CENTER="RESOURCE_CENTER",(M=D||(D={})).ALWAYS_TRUE="ALWAYS_TRUE",M.ATTRIBUTE="ATTRIBUTE",M.CLAUSE="CLAUSE",M.ELEMENT="ELEMENT",M.FILLED_IN_INPUT="FILLED_IN_INPUT",M.FLOW="FLOW",M.INPUT_VALUE="INPUT_VALUE",M.PAGE="PAGE",M.SEGMENT="SEGMENT",M.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(F||(F={})),(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",(K=V||(V={})).INSIDE="INSIDE",K.OUTSIDE="OUTSIDE",(z=j||(j={})).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",(Se=Te||(Te={})).NEW_TAB="NEW_TAB",Se.SAME_TAB="SAME_TAB",(we=fe||(fe={})).SET="SET",we.SET_DATETIME="SET_DATETIME",we.SET_DATETIME_ONCE="SET_DATETIME_ONCE",we.SET_ONCE="SET_ONCE",we.ADD="ADD",we.SUBTRACT="SUBTRACT",we.APPEND="APPEND",we.PREPEND="PREPEND",we.REMOVE="REMOVE",we.UNSET="UNSET",(ge=pe||(pe={})).MULTILINE_TEXT="MULTILINE_TEXT",ge.MULTIPLE_CHOICE="MULTIPLE_CHOICE",ge.NPS="NPS",ge.SCALE="SCALE",ge.STARS="STARS",ge.TEXT="TEXT",(Ce=Ie||(Ie={})).ACTION="ACTION",Ce.ANNOUNCEMENTS="ANNOUNCEMENTS",Ce.ASSISTANT="ASSISTANT",Ce.CHECKLIST="CHECKLIST",Ce.CONTACT="CONTACT",Ce.DIVIDER="DIVIDER",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={})).EMAIL="EMAIL",Re.PHONE="PHONE",Re.CHAT="CHAT",(ve=Ne||(Ne={})).SILENT="SILENT",ve.BADGE="BADGE",ve.POPOUT="POPOUT",(ye=Oe||(Oe={})).LAUNCHER_CLICK="LAUNCHER_CLICK",ye.LAUNCHER_HOVER="LAUNCHER_HOVER",ye.TARGET_CLICK="TARGET_CLICK",ye.TARGET_HOVER="TARGET_HOVER",ye.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",ye.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(be=_e||(_e={})).ACTIVATE="ACTIVATE",be.DEACTIVATE="DEACTIVATE",be.NEVER="NEVER",(Me=De||(De={})).AUTO="AUTO",Me.TOP="TOP",Me.RIGHT="RIGHT",Me.BOTTOM="BOTTOM",Me.LEFT="LEFT",(Be=Fe||(Fe={})).START="START",Be.CENTER="CENTER",Be.END="END",(xe=Pe||(Pe={})).PERCENT="PERCENT",xe.PX="PX",(Ge=He||(He={})).BEACON="BEACON",Ge.BUTTON="BUTTON",Ge.HIDDEN="HIDDEN",Ge.ICON="ICON",($e=We||(We={})).LAUNCHER="LAUNCHER",$e.TARGET="TARGET",(Ke=Ve||(Ve={})).BODY_FIRST="BODY_FIRST",Ke.BODY_LAST="BODY_LAST",Ke.ELEMENT_FIRST="ELEMENT_FIRST",Ke.ELEMENT_LAST="ELEMENT_LAST",Ke.ELEMENT_BEFORE="ELEMENT_BEFORE",Ke.ELEMENT_AFTER="ELEMENT_AFTER",(ze=je||(je={})).START="START",ze.CENTER="CENTER",ze.SPACE_BETWEEN="SPACE_BETWEEN",(Je=Ye||(Ye={})).NONE="NONE",Je.LIKE="LIKE",Je.SCALE="SCALE",(Ze=Xe||(Xe={})).ACTIVE="ACTIVE",Ze.COMPLETED="COMPLETED",Ze.ENDED="ENDED",Ze.NOT_SEEN="NOT_SEEN",(qe=Qe||(Qe={})).HIGHLIGHT="HIGHLIGHT",qe.MODAL="MODAL",qe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const et={customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator: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,evalJsDisabled:!1};function tt(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function st(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function it(){let e=d();if(et.urlFilter){if(e=et.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}let nt="";try{nt=localStorage.getItem("debug")||""}catch(ft){}const ot=nt.split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),rt=ct("log");let at;function ct(e){return function(t,...s){if(ot){const i=performance.now(),n=at?Math.round(i-at):0;at=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}rt.group=ct("group"),rt.groupCollapsed=ct("groupCollapsed"),rt.groupEnd=function(){ot&&console.groupEnd()};const lt=()=>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("flow-host.styl.js",import.meta.url).toString(),new URL("bubble-frame.styl.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.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("use-window-resize.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("logomark.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString()]);function dt(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class ht{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 ut=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Et=()=>n((()=>import("./BannerApp.js")),[new URL("BannerApp.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.obj-str.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.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("bubble-frame.styl.js",import.meta.url).toString(),new URL("flow-host.styl.js",import.meta.url).toString(),new URL("use-selector-element-monitoring.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("use-window-resize.js",import.meta.url).toString(),new URL("use-element-rect.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]),Tt=import.meta.url;class St{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.bannerSession=null,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=>{rt(`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,isTargetTab:!0,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}),this.setSessionStorageState((e=>({...e,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0}))),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void(e.testStartCondition?this.setSessionStorageState((t=>({...t,activeApp:"startConditionTesting",testStartConditionToken:e.token}))):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}),this.setSessionStorageState((e=>({...e,isTargetTab:!0}))),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)&&(rt("remounting UI because container was missing"),this.remount())},rt("constructor, build=1005315"),p(this.onUrlChange),this.setTargetEnv(new C),this.checkTestUserAtBoot(),this.toggleUI();for(const e of ut)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){rt("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv();for(const e of ut)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 t=c.getItem("userflowClientState");if(t)try{e=JSON.parse(t)}catch(ft){console.error("Userflow.js: Parse ElementSelectionState error:",ft)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(rt("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(rt("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?rt("init() ignoring new token since a test user has been identified"):(this.clientToken&&(rt("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",rt("connecting to socket");let t=et.serverEndpoint||"e.userflow.com";"js.getuserflow.com"===new URL(Tt).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((()=>{rt("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),rt("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:"1005315",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.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 rt("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():(rt("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.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)}rt(`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`;"connected"===this._socketStatus&&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",(s=>{r();const n=`Userflow.js error reply (${s.code}): ${s.message}`;console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n,s.code,s.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){rt(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,bannerSession:r,resourceCenterSession:a}=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 rt(`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"SetBannerSession":return this.setBannerSession(e.session),void this.toggleUI();case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):rt(`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()):rt(`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"TestStartConditionSuccess":return void this.emit("private:testStartConditionSuccess");case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetBannerSession":return void(r?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI()));case"UnsetChecklistSession":return o>t?void rt(`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 rt(`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(a?.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(rt("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)rt("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&&(rt("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={}){if(!a.isSupported())throw new o("userflow.identifyAnonymous() is not supported when localStorage access is denied.");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={}){rt("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if(rt("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)rt("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={}){rt("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 O.STRING;case"number":return O.NUMBER;case"boolean":return O.BOOLEAN;case"datetime":return O.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=O.STRING;break;case"boolean":n=O.BOOLEAN;break;case"integer":case"decimal":n=O.NUMBER;break;case"datetime":n=O.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}={}){rt(`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&&(rt(`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:it(),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(){rt("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),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,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0)}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}),rt(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return rt("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(),rt("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,s=this.resourceCenterSession.version.resourceCenter?.blocks.find((e=>e.type===Ie.ANNOUNCEMENTS));return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?dt(t):0,unreadAnnouncementCount:s?.unreadAnnouncementCount||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.bannerSession?.id===e.id&&this.setBannerSession(null),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){rt("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(){rt("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){rt("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")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const t=this.resourceCenterSession;e="function"==typeof e?e(this.resourceCenterSession):e,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===_e.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(){const e=this.getSessionStorageState();this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),e.isTargetTab&&this.monitorTitle(),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.bannerSession||!!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&&(rt("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(rt("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.bannerSession&&Et(),this.resourceCenterSession&&lt();const{RealUI:t}=await e;return new t(this)}catch(ft){throw this.reportCspIssue(),ft}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;rt("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.v}))),[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 ht([]),condition:e,callback:t=>{i.isTrue!==t&&(rt("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&&(rt("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.v}))),[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 ht(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})},description:`event tracker ${o.flowId}`}),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"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const t=new MutationObserver((()=>{this.fixTitle()}));t.observe(e,{childList:!0}),this.titleObserver=t}}fixTitle(){const e=document.title,t="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==t&&(document.title=t)}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,rt("csp issue detected"),T({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 St;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&&et.customInputs.push({cssSelector:e})},registerCustomInput(e,t){et.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){et.customNavigate=e},setUrlFilter(e){et.urlFilter=e},setLinkUrlDecorator(t){et.linkUrlDecorator=t,e.emit("uistatechange")},setInferenceAttributeNames(e){et.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){et.inferenceAttributeFilters[e]=tt(t)},setInferenceClassNameFilter(e){et.inferenceClassNameFilters=tt(e)},setScrollPadding(e){et.scrollPadding=e},setCustomScrollIntoView(e){et.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){et.baseZIndex=e},setServerEndpoint(e){et.serverEndpoint=e},disableEvalJs(){et.evalJsDisabled=!0},_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;rt(`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)}rt("queue processed")}()}export{Ye as $,Ne as A,Et as B,me as C,W as D,m as E,P as F,Y as G,a as H,Ve as I,X as J,ne as K,ce as L,Q as M,j as N,de as O,He as P,Oe as Q,lt as R,L as S,ut as T,o as U,re as V,De as W,We as X,Fe as Y,Pe as Z,n as _,B as a,N as a0,F as b,et as c,rt as d,D as e,H as f,it as g,Ie as h,c as i,dt as j,se as k,ee as l,ue as m,Ae as n,p as o,_ as p,Le as q,d as r,l as s,st as t,g as u,Te as v,fe as w,pe as x,ht as y,V as z};export default window.userflow;