userflow.js-self-hosted 0.1.1026863 → 0.1.1026867

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,2 +1,2 @@
1
- import{r as n,R as a}from"./vendor.react.js";import{a1 as s,E as A}from"./userflow.js";import{u as D,i as v}from"./client-context.js";import{o as R}from"./vendor.obj-str.js";import{a as x,u as C,D as O}from"./stylesheets.js";import{U as $}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{S as P,R as z,B as U}from"./TreeDoc.js";import{g as W}from"./flow-condition-types.js";import{f as Y,w as H}from"./flow-host.styl.js";import{u as K,b as Z}from"./use-selector-element-monitoring.js";import{r as q}from"./vendor.react-dom.js";import{F as G}from"./Frame.js";import{z as i}from"./roots.js";import{u as J}from"./use-element-rect.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.js";import"./vendor.scheduler.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[d]="6844dfb6-39e6-47e1-8677-e75744ee7a36",r._sentryDebugIdIdentifier="sentry-dbid-6844dfb6-39e6-47e1-8677-e75744ee7a36")}catch{}})();const je=({session:r})=>{const d=D(),{version:c}=r,e=c.banner,y=x(c.theme),g=r.locale?r.locale.standardLocaleId:r.version.theme.languageId;n.useEffect(()=>{v.changeLanguage(g)},[g]);const t=n.useMemo(()=>document.createElement("div"),[]),[k,w]=n.useState(!1),{loaded:T}=C(window,Y,y),[I,h]=n.useState(!1),E=T&&I,[M,B]=n.useState(0),u=n.useCallback(()=>{h(!1),B(o=>o+1)},[]),f=![s.BODY_FIRST,s.BODY_LAST].includes(e.embedMode),[l,S]=n.useState(null),F=n.useCallback(({targetEl:o})=>{S(o)},[]),N=n.useCallback(()=>{f&&console.warn(`Userflow.js: Could not find embed element for banner "${r.flow.name||r.flow.id}"`),S(null)},[f,r.flow.name,r.flow.id]);K({selector:e.embedSelector,targetMoved:F,targetLost:N});const b=n.useCallback(()=>{t.parentElement?.removeChild(t),w(!1),u()},[t,u]);n.useLayoutEffect(()=>{let o=null,m=null;if(f){if(!l){b();return}(e.overlay||e.sticky)&&(e.embedMode===s.ELEMENT_BEFORE||e.embedMode===s.ELEMENT_AFTER?m=l.parentElement:m=l,window.getComputedStyle(m).position==="static"&&(o=m.style.position,m.style.position="relative"))}switch(e.embedMode){case s.BODY_FIRST:document.body.insertAdjacentElement("afterbegin",t);break;case s.BODY_LAST:document.body.insertAdjacentElement("beforeend",t);break;case s.ELEMENT_FIRST:l.insertAdjacentElement("afterbegin",t);break;case s.ELEMENT_LAST:l.insertAdjacentElement("beforeend",t);break;case s.ELEMENT_BEFORE:l.insertAdjacentElement("beforebegin",t);break;case s.ELEMENT_AFTER:l.insertAdjacentElement("afterend",t);break}return w(!0),u(),()=>{m&&o!=null&&(m.style.position=o)}},[b,t,f,l,e.overlay,e.sticky,e.embedMode,u]),n.useLayoutEffect(()=>b,[b]);const L=R({"userflowjs-banner":!0,[`userflowjs-banner--animate-${String(e.animate)}`]:!0,[`userflowjs-banner--embed-mode-${e.embedMode}`]:!0,[`userflowjs-banner--sticky-${String(e.sticky)}`]:!0,[`userflowjs-banner--overlay-${e.overlay}`]:!0});n.useLayoutEffect(()=>{t.className=L||""},[t,L]);const p=e.zIndex||H(0);n.useLayoutEffect(()=>{t.style.zIndex=p==null?"":String(p),t.style.position=E?"":"absolute",t.style.visibility=E?"":"hidden"},[t,p,E]);const{height:j,setEl:_}=J();return n.useLayoutEffect(()=>{t.style.setProperty("--userflowjs-banner-height",i(j+(e.marginTop||0)+(e.marginBottom||0))||"")},[t,j,e.marginTop,e.marginBottom]),k?q.createPortal(a.createElement(P.Provider,{value:r},a.createElement(G,{key:M,className:"userflowjs-banner-frame",style:{maxWidth:i(e.maxWidth),marginTop:i(e.marginTop),marginRight:i(e.marginRight),marginBottom:i(e.marginBottom),marginLeft:i(e.marginLeft),borderRadius:i(e.borderRadius)},stylesheet:Z,theme:y,onStylesheetsLoad:h,title:"Banner"},a.createElement("div",{ref:_,className:R({"userflowjs-banner-root":!0,[`userflowjs-banner-root--content-layout-${e.contentLayout}`]:!0,"userflowjs-theme-root":!0}),dir:v.dir()},a.createElement("div",{className:"userflowjs-banner-start-spacer"}),a.createElement("div",{className:"userflowjs-banner-inner",style:{maxWidth:i(e.maxContentWidth)}},a.createElement("div",{className:"userflowjs-banner-content"},a.createElement(z,{doc:e.content,lookupAttribute:W(r.data)})),e.buttons.length>0&&a.createElement("div",{className:"userflowjs-banner-buttons"},e.buttons.map(o=>a.createElement(U,{key:o.id,button:o})))),c.closeDisabled?a.createElement("div",{className:"userflowjs-banner-start-spacer"}):a.createElement("button",{"data-testid":"userflow-banner-dismiss",className:"userflowjs-banner-close",onClick:()=>d.endFlow(r,{endReason:A.USER_CLOSED})},a.createElement(O,{icon:$}))))),t):null};export{je as BannerApp,je as default};
1
+ import{r as n,R as a}from"./vendor.react.js";import{a1 as s,E as A}from"./userflow.js";import{u as D,i as v}from"./client-context.js";import{o as R}from"./vendor.obj-str.js";import{a as x,u as C,D as O}from"./stylesheets.js";import{V as $}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{S as P,R as z,B as W}from"./TreeDoc.js";import{g as Y}from"./flow-condition-types.js";import{f as U,w as H}from"./flow-host.styl.js";import{u as K,b as V}from"./use-selector-element-monitoring.js";import{r as Z}from"./vendor.react-dom.js";import{F as q}from"./Frame.js";import{z as i}from"./roots.js";import{u as G}from"./use-element-rect.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.js";import"./vendor.scheduler.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[d]="57b84869-c1d4-448b-95c1-e7a085067d8f",r._sentryDebugIdIdentifier="sentry-dbid-57b84869-c1d4-448b-95c1-e7a085067d8f")}catch{}})();const je=({session:r})=>{const d=D(),{version:c}=r,e=c.banner,y=x(c.theme),g=r.locale?r.locale.standardLocaleId:r.version.theme.languageId;n.useEffect(()=>{v.changeLanguage(g)},[g]);const t=n.useMemo(()=>document.createElement("div"),[]),[k,w]=n.useState(!1),{loaded:T}=C(window,U,y),[I,h]=n.useState(!1),E=T&&I,[M,B]=n.useState(0),u=n.useCallback(()=>{h(!1),B(o=>o+1)},[]),f=![s.BODY_FIRST,s.BODY_LAST].includes(e.embedMode),[l,S]=n.useState(null),F=n.useCallback(({targetEl:o})=>{S(o)},[]),N=n.useCallback(()=>{f&&console.warn(`Userflow.js: Could not find embed element for banner "${r.flow.name||r.flow.id}"`),S(null)},[f,r.flow.name,r.flow.id]);K({selector:e.embedSelector,targetMoved:F,targetLost:N});const b=n.useCallback(()=>{t.parentElement?.removeChild(t),w(!1),u()},[t,u]);n.useLayoutEffect(()=>{let o=null,m=null;if(f){if(!l){b();return}(e.overlay||e.sticky)&&(e.embedMode===s.ELEMENT_BEFORE||e.embedMode===s.ELEMENT_AFTER?m=l.parentElement:m=l,window.getComputedStyle(m).position==="static"&&(o=m.style.position,m.style.position="relative"))}switch(e.embedMode){case s.BODY_FIRST:document.body.insertAdjacentElement("afterbegin",t);break;case s.BODY_LAST:document.body.insertAdjacentElement("beforeend",t);break;case s.ELEMENT_FIRST:l.insertAdjacentElement("afterbegin",t);break;case s.ELEMENT_LAST:l.insertAdjacentElement("beforeend",t);break;case s.ELEMENT_BEFORE:l.insertAdjacentElement("beforebegin",t);break;case s.ELEMENT_AFTER:l.insertAdjacentElement("afterend",t);break}return w(!0),u(),()=>{m&&o!=null&&(m.style.position=o)}},[b,t,f,l,e.overlay,e.sticky,e.embedMode,u]),n.useLayoutEffect(()=>b,[b]);const L=R({"userflowjs-banner":!0,[`userflowjs-banner--animate-${String(e.animate)}`]:!0,[`userflowjs-banner--embed-mode-${e.embedMode}`]:!0,[`userflowjs-banner--sticky-${String(e.sticky)}`]:!0,[`userflowjs-banner--overlay-${e.overlay}`]:!0});n.useLayoutEffect(()=>{t.className=L||""},[t,L]);const p=e.zIndex||H(0);n.useLayoutEffect(()=>{t.style.zIndex=p==null?"":String(p),t.style.position=E?"":"absolute",t.style.visibility=E?"":"hidden"},[t,p,E]);const{height:j,setEl:_}=G();return n.useLayoutEffect(()=>{t.style.setProperty("--userflowjs-banner-height",i(j+(e.marginTop||0)+(e.marginBottom||0))||"")},[t,j,e.marginTop,e.marginBottom]),k?Z.createPortal(a.createElement(P.Provider,{value:r},a.createElement(q,{key:M,className:"userflowjs-banner-frame",style:{maxWidth:i(e.maxWidth),marginTop:i(e.marginTop),marginRight:i(e.marginRight),marginBottom:i(e.marginBottom),marginLeft:i(e.marginLeft),borderRadius:i(e.borderRadius)},stylesheet:V,theme:y,onStylesheetsLoad:h,title:"Banner"},a.createElement("div",{ref:_,className:R({"userflowjs-banner-root":!0,[`userflowjs-banner-root--content-layout-${e.contentLayout}`]:!0,"userflowjs-theme-root":!0}),dir:v.dir()},a.createElement("div",{className:"userflowjs-banner-start-spacer"}),a.createElement("div",{className:"userflowjs-banner-inner",style:{maxWidth:i(e.maxContentWidth)}},a.createElement("div",{className:"userflowjs-banner-content"},a.createElement(z,{doc:e.content,lookupAttribute:Y(r.data)})),e.buttons.length>0&&a.createElement("div",{className:"userflowjs-banner-buttons"},e.buttons.map(o=>a.createElement(W,{key:o.id,button:o})))),c.closeDisabled?a.createElement("div",{className:"userflowjs-banner-start-spacer"}):a.createElement("button",{"data-testid":"userflow-banner-dismiss",className:"userflowjs-banner-close",onClick:()=>d.endFlow(r,{endReason:A.USER_CLOSED})},a.createElement(O,{icon:$}))))),t):null};export{je as BannerApp,je as default};
2
2
  //# sourceMappingURL=BannerApp.js.map
package/ChecklistUI.js CHANGED
@@ -1,2 +1,2 @@
1
- import{R as e,r as l}from"./vendor.react.js";import{E as I,Z as _}from"./userflow.js";import{u as v}from"./client-context.js";import"./vendor.object-assign.js";import{u as T}from"./vendor.react-i18next.js";import{o as F}from"./vendor.obj-str.js";import{D as C}from"./stylesheets.js";import{b as P,p as L}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{h as M,a as x,r as B,R as $}from"./TreeDoc.js";import{g}from"./flow-condition-types.js";import{b as H,a0 as W}from"./vendor.fortawesome.pro-regular-svg-icons.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="3e221f55-19e8-4430-a2fe-f9ac66a33954",t._sentryDebugIdIdentifier="sentry-dbid-3e221f55-19e8-4430-a2fe-f9ac66a33954")}catch{}})();const Z=e.forwardRef(({elProps:t,onClick:s,onCheckmarkClick:n,completed:o,disabled:u,name:c,text:b,active:m,htmlAttributes:a,children:i},w)=>{const d=l.useRef(o);return e.createElement("button",{...t,ref:w,"data-testid":"bubble-task",tabIndex:s?0:-1,className:F({"userflowjs-bubble-task":!0,"userflowjs-bubble-task--completed":!!o,"userflowjs-bubble-task--just-completed":!d.current&&!!o,"userflowjs-bubble-task--disabled":!o&&!!u,"userflowjs-bubble-task--clickable":!!s,"userflowjs-bubble-task--active":!!m}),onClick:s,...a},e.createElement("div",{className:"userflowjs-bubble-task__checkmark",onClick:n},o&&e.createElement(C,{icon:P})),e.createElement("div",{className:"userflowjs-bubble-task__content"},e.createElement("div",{className:"userflowjs-bubble-task__name"},c),e.createElement("div",{className:"userflowjs-bubble-task__text"},b)),e.createElement("div",{className:"userflowjs-bubble-task__arrow"},!o&&e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(C,{icon:L}))),i)}),z=({task:t,previousTasksCompleted:s})=>{const n=v(),{session:o}=S(),u=o.version.checklist,[c,b]=l.useState(()=>n.taskIsUnacked(t.cvid));l.useEffect(()=>{if(!c)return;const d=window.setTimeout(()=>b(!1),500);return()=>window.clearTimeout(d)},[c]);const m=o.taskCompletions.some(({taskCvid:d})=>d===t.cvid),a=!c&&m;l.useEffect(()=>{a&&n.ackCompletedTask(t.cvid)},[n,a,t.cvid]);const i=u.completeInOrder&&!s,w=i||t.actions.length===0&&a?void 0:()=>{n.send({kind:"ClickChecklistTask",sessionId:o.id,taskCvid:t.cvid},{batch:!0}),t.actions.length>0&&(a||!t.completesOnClick)&&n.hideChecklist(),M(n,o,t.actions)};return e.createElement(Z,{onClick:w,name:e.createElement(x,{doc:t.name,lookupAttribute:g(o.data)}),text:e.createElement(x,{doc:t.text,lookupAttribute:g(o.data)}),completed:a,disabled:i})},G=({completedCount:t,taskCount:s})=>{const n=s===0?0:Math.min(100,Math.round(t/s*100));return e.createElement("div",{className:"userflowjs-bubble-checklist-progress"},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-bg"},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},n,"%")),e.createElement("div",{className:"userflowjs-bubble-checklist-progress-fill",style:{width:`${n}%`}},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},n,"%")))},D=5e3,J=({active:t,onComplete:s})=>{const n=l.useRef(null);return l.useEffect(()=>{if(!t||!n.current)return;n.current.style.width="0%",n.current.offsetWidth,n.current.style.transition=`width ${D}ms linear`,n.current.style.width="100%";const o=setTimeout(s,D);return()=>clearTimeout(o)},[t,s]),e.createElement("div",{className:"userflowjs-bubble-progress--default userflowjs-bubble-progress-container--checklist"},t&&e.createElement("div",{className:"userflowjs-bubble-progress-background--checklist"}),e.createElement("div",{className:"userflowjs-bubble-progress__fill userflowjs-bubble-progress-fill--checklist",ref:n}))},K=()=>{const{t}=T(),s=v(),n=S(),{session:o}=n,{version:u}=o,c=u.checklist,{dispatch:b}=U(),m=o.taskCompletions.length,a=c.tasks.length,i=m===a,w=l.useCallback(()=>{s.endFlow(o,{endReason:I.USER_CLOSED})},[s,o]);let d=!0,N=c.tasks,h=[],p=n.currentSectionName,y=!1;if(c.sectionsEnabled){let f=null;const k=Array.from(c.tasks).sort((r,E)=>r.sectionName.localeCompare(E.sectionName));for(const r of k)r.sectionName!==f&&(h.push(r.sectionName),f=r.sectionName);(!p||!h.includes(p))&&(p=h[0]),N=k.filter(r=>r.sectionName===p),y=N.some(r=>{const E=o.taskCompletions.some(({taskCvid:O})=>O===r.cvid);return r.blocksNextSection&&!E})}const j=p==null?-1:h.indexOf(p),R=f=>{const k=j+f;if(k>=0&&k<=h.length-1){const r=h[k];_.setItem("currentChecklistSectionName:"+o.id,r),b({kind:"setCurrentSection",sectionName:r})}};return e.createElement(e.Fragment,null,!B(c.content)&&e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement($,{doc:c.content,lookupAttribute:g(o.data)})),e.createElement(G,{completedCount:m,taskCount:a}),c.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-name"},p||"First section"),e.createElement("div",{className:"userflowjs-bubble-tasks"},N.map(f=>{const k=d;return o.taskCompletions.some(({taskCvid:E})=>E===f.cvid)||(d=!1),e.createElement(z,{key:f.id,task:f,previousTasksCompleted:k})})),c.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-buttons"},e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>R(-1),disabled:j<=0},e.createElement(C,{icon:H}),e.createElement("span",null,t("checklist.previousSection"))),e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>R(1),disabled:j>=h.length-1||y},e.createElement("span",null,t("checklist.nextSection")),e.createElement(C,{icon:W}))),e.createElement("div",{className:"userflowjs-bubble-dismiss-row userflowjs-bubble-dismiss-row--checklist"},u.closeDisabled?e.createElement("div",{className:"userflowjs-bubble-checklist-dismiss-button-placeholder"}):e.createElement("button",{className:F({"userflowjs-bubble-dismiss-button":!0,"userflowjs-bubble-dismiss-button--completed":i}),onClick:()=>i?w():b({kind:"showClose"})},t("checklistDismiss.button")),c.autoDismissEnabled&&e.createElement(J,{active:i,onComplete:w})))},Q=()=>{const{t}=T(),s=v(),{dispatch:n}=U(),{session:o}=S();return e.createElement("div",{role:"alert"},e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("p",null,e.createElement("b",null,t("checklistDismiss.title")))),e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>s.endFlow(o,{endReason:I.USER_CLOSED})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},t("checklistDismiss.yes"))),e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:()=>n({kind:"showFlow"})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},t("checklistDismiss.cancel")))))};function V(t){const s=t?.querySelector(".userflowjs-bubble-task--clickable:not(.userflowjs-bubble-task--completed)")||t?.querySelector(".userflowjs-bubble-task--clickable")||t?.querySelector('button:not([tabIndex="-1"])');s&&typeof s.focus=="function"&&s.focus()}const be=({session:t,initialAutoFocus:s})=>{const n=v(),o=l.useRef(null),[u,c]=l.useReducer(Y,void 0,()=>({...X,session:t,currentSectionName:_.getItem("currentChecklistSectionName:"+t.id),autoFocusRequested:!!s})),{session:b,contentType:m}=u;l.useEffect(()=>{b!==t&&c({kind:"updateSession",session:t})},[b,t]);const a=l.useMemo(()=>({dispatch:c}),[c]);return l.useEffect(()=>{if(!u.autoFocusRequested)return;const i=o.current;i&&V(i),c({kind:"autoFocused"})},[n,u.autoFocusRequested]),e.createElement(A.Provider,{value:a},e.createElement(q.Provider,{value:u},e.createElement("div",{ref:o},m==="close"?e.createElement(Q,null):e.createElement(K,null))))},X={contentType:"flow"};function Y(t,s){switch(s.kind){case"updateSession":return{...t,session:s.session};case"showFlow":return{...t,contentType:"flow",autoFocusRequested:!0};case"showClose":return{...t,contentType:"close",autoFocusRequested:!0};case"setCurrentSection":return{...t,currentSectionName:s.sectionName};case"autoFocused":return{...t,autoFocusRequested:!1}}}const A=l.createContext(null),q=l.createContext(null);function U(){return l.useContext(A)}function S(){return l.useContext(q)}export{be as C,V as f};
1
+ import{R as e,r as l}from"./vendor.react.js";import{E as I,Z as _}from"./userflow.js";import{u as v}from"./client-context.js";import"./vendor.object-assign.js";import{u as T}from"./vendor.react-i18next.js";import{o as F}from"./vendor.obj-str.js";import{D as C}from"./stylesheets.js";import{b as P,p as L}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{h as M,a as x,r as B,R as $}from"./TreeDoc.js";import{g}from"./flow-condition-types.js";import{b as H,a1 as W}from"./vendor.fortawesome.pro-regular-svg-icons.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="783e35a5-2f76-483d-875e-df962583d082",t._sentryDebugIdIdentifier="sentry-dbid-783e35a5-2f76-483d-875e-df962583d082")}catch{}})();const Z=e.forwardRef(({elProps:t,onClick:s,onCheckmarkClick:n,completed:o,disabled:u,name:c,text:b,active:m,htmlAttributes:a,children:i},w)=>{const d=l.useRef(o);return e.createElement("button",{...t,ref:w,"data-testid":"bubble-task",tabIndex:s?0:-1,className:F({"userflowjs-bubble-task":!0,"userflowjs-bubble-task--completed":!!o,"userflowjs-bubble-task--just-completed":!d.current&&!!o,"userflowjs-bubble-task--disabled":!o&&!!u,"userflowjs-bubble-task--clickable":!!s,"userflowjs-bubble-task--active":!!m}),onClick:s,...a},e.createElement("div",{className:"userflowjs-bubble-task__checkmark",onClick:n},o&&e.createElement(C,{icon:P})),e.createElement("div",{className:"userflowjs-bubble-task__content"},e.createElement("div",{className:"userflowjs-bubble-task__name"},c),e.createElement("div",{className:"userflowjs-bubble-task__text"},b)),e.createElement("div",{className:"userflowjs-bubble-task__arrow"},!o&&e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(C,{icon:L}))),i)}),z=({task:t,previousTasksCompleted:s})=>{const n=v(),{session:o}=S(),u=o.version.checklist,[c,b]=l.useState(()=>n.taskIsUnacked(t.cvid));l.useEffect(()=>{if(!c)return;const d=window.setTimeout(()=>b(!1),500);return()=>window.clearTimeout(d)},[c]);const m=o.taskCompletions.some(({taskCvid:d})=>d===t.cvid),a=!c&&m;l.useEffect(()=>{a&&n.ackCompletedTask(t.cvid)},[n,a,t.cvid]);const i=u.completeInOrder&&!s,w=i||t.actions.length===0&&a?void 0:()=>{n.send({kind:"ClickChecklistTask",sessionId:o.id,taskCvid:t.cvid},{batch:!0}),t.actions.length>0&&(a||!t.completesOnClick)&&n.hideChecklist(),M(n,o,t.actions)};return e.createElement(Z,{onClick:w,name:e.createElement(x,{doc:t.name,lookupAttribute:g(o.data)}),text:e.createElement(x,{doc:t.text,lookupAttribute:g(o.data)}),completed:a,disabled:i})},G=({completedCount:t,taskCount:s})=>{const n=s===0?0:Math.min(100,Math.round(t/s*100));return e.createElement("div",{className:"userflowjs-bubble-checklist-progress"},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-bg"},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},n,"%")),e.createElement("div",{className:"userflowjs-bubble-checklist-progress-fill",style:{width:`${n}%`}},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},n,"%")))},D=5e3,J=({active:t,onComplete:s})=>{const n=l.useRef(null);return l.useEffect(()=>{if(!t||!n.current)return;n.current.style.width="0%",n.current.offsetWidth,n.current.style.transition=`width ${D}ms linear`,n.current.style.width="100%";const o=setTimeout(s,D);return()=>clearTimeout(o)},[t,s]),e.createElement("div",{className:"userflowjs-bubble-progress--default userflowjs-bubble-progress-container--checklist"},t&&e.createElement("div",{className:"userflowjs-bubble-progress-background--checklist"}),e.createElement("div",{className:"userflowjs-bubble-progress__fill userflowjs-bubble-progress-fill--checklist",ref:n}))},K=()=>{const{t}=T(),s=v(),n=S(),{session:o}=n,{version:u}=o,c=u.checklist,{dispatch:b}=U(),m=o.taskCompletions.length,a=c.tasks.length,i=m===a,w=l.useCallback(()=>{s.endFlow(o,{endReason:I.USER_CLOSED})},[s,o]);let d=!0,N=c.tasks,h=[],p=n.currentSectionName,y=!1;if(c.sectionsEnabled){let f=null;const k=Array.from(c.tasks).sort((r,E)=>r.sectionName.localeCompare(E.sectionName));for(const r of k)r.sectionName!==f&&(h.push(r.sectionName),f=r.sectionName);(!p||!h.includes(p))&&(p=h[0]),N=k.filter(r=>r.sectionName===p),y=N.some(r=>{const E=o.taskCompletions.some(({taskCvid:O})=>O===r.cvid);return r.blocksNextSection&&!E})}const j=p==null?-1:h.indexOf(p),R=f=>{const k=j+f;if(k>=0&&k<=h.length-1){const r=h[k];_.setItem("currentChecklistSectionName:"+o.id,r),b({kind:"setCurrentSection",sectionName:r})}};return e.createElement(e.Fragment,null,!B(c.content)&&e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement($,{doc:c.content,lookupAttribute:g(o.data)})),e.createElement(G,{completedCount:m,taskCount:a}),c.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-name"},p||"First section"),e.createElement("div",{className:"userflowjs-bubble-tasks"},N.map(f=>{const k=d;return o.taskCompletions.some(({taskCvid:E})=>E===f.cvid)||(d=!1),e.createElement(z,{key:f.id,task:f,previousTasksCompleted:k})})),c.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-buttons"},e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>R(-1),disabled:j<=0},e.createElement(C,{icon:H}),e.createElement("span",null,t("checklist.previousSection"))),e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>R(1),disabled:j>=h.length-1||y},e.createElement("span",null,t("checklist.nextSection")),e.createElement(C,{icon:W}))),e.createElement("div",{className:"userflowjs-bubble-dismiss-row userflowjs-bubble-dismiss-row--checklist"},u.closeDisabled?e.createElement("div",{className:"userflowjs-bubble-checklist-dismiss-button-placeholder"}):e.createElement("button",{className:F({"userflowjs-bubble-dismiss-button":!0,"userflowjs-bubble-dismiss-button--completed":i}),onClick:()=>i?w():b({kind:"showClose"})},t("checklistDismiss.button")),c.autoDismissEnabled&&e.createElement(J,{active:i,onComplete:w})))},Q=()=>{const{t}=T(),s=v(),{dispatch:n}=U(),{session:o}=S();return e.createElement("div",{role:"alert"},e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("p",null,e.createElement("b",null,t("checklistDismiss.title")))),e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>s.endFlow(o,{endReason:I.USER_CLOSED})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},t("checklistDismiss.yes"))),e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:()=>n({kind:"showFlow"})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},t("checklistDismiss.cancel")))))};function V(t){const s=t?.querySelector(".userflowjs-bubble-task--clickable:not(.userflowjs-bubble-task--completed)")||t?.querySelector(".userflowjs-bubble-task--clickable")||t?.querySelector('button:not([tabIndex="-1"])');s&&typeof s.focus=="function"&&s.focus()}const be=({session:t,initialAutoFocus:s})=>{const n=v(),o=l.useRef(null),[u,c]=l.useReducer(Y,void 0,()=>({...X,session:t,currentSectionName:_.getItem("currentChecklistSectionName:"+t.id),autoFocusRequested:!!s})),{session:b,contentType:m}=u;l.useEffect(()=>{b!==t&&c({kind:"updateSession",session:t})},[b,t]);const a=l.useMemo(()=>({dispatch:c}),[c]);return l.useEffect(()=>{if(!u.autoFocusRequested)return;const i=o.current;i&&V(i),c({kind:"autoFocused"})},[n,u.autoFocusRequested]),e.createElement(A.Provider,{value:a},e.createElement(q.Provider,{value:u},e.createElement("div",{ref:o},m==="close"?e.createElement(Q,null):e.createElement(K,null))))},X={contentType:"flow"};function Y(t,s){switch(s.kind){case"updateSession":return{...t,session:s.session};case"showFlow":return{...t,contentType:"flow",autoFocusRequested:!0};case"showClose":return{...t,contentType:"close",autoFocusRequested:!0};case"setCurrentSection":return{...t,currentSectionName:s.sectionName};case"autoFocused":return{...t,autoFocusRequested:!1}}}const A=l.createContext(null),q=l.createContext(null);function U(){return l.useContext(A)}function S(){return l.useContext(q)}export{be as C,V as f};
2
2
  //# sourceMappingURL=ChecklistUI.js.map
package/DebuggerUI.js CHANGED
@@ -1,3 +1,3 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["flow-condition-types.js","userflow.js","vendor.object-assign.js","vendor.phoenix.js","vendor.uuid.js","vendor.date-fns.js","vendor.babel.runtime.js","roots.js"])))=>i.map(i=>d[i]);
2
- import{r as i,R as e}from"./vendor.react.js";import{r as ce}from"./vendor.react-dom.js";import{u as P,U as Pe}from"./client-context.js";import{d as te,w as B,x as A,y as D,z as O,k as m,C as ue,l as x,W as T,D as U,G as Re,H as Ue,_ as Ae,S as ke}from"./userflow.js";import{F as Me}from"./Frame.js";import{S as Ve}from"./logomark.js";import{e as ne,y as Be,z as k,A as re,B as He,k as qe,C as fe,D as F,E as Ge,F as Ee,G as he,H as We,I as ze,a as I,J as be,K as je,L as Ye,M as Xe,N as Ke,O as Ze,P as L,s as ve,p as M,Q as $e,R as Qe,S as Je,T as et,f as tt,U as nt,V as rt,W as K,X as st,Y as at,Z as ot,_ as lt}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{n as it,o as ct}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as u}from"./stylesheets.js";import{o as g}from"./vendor.obj-str.js";import"./vendor.object-assign.js";import{u as J,d as _e}from"./vendor.lodash.js";import{p as ut,f as se,d as dt}from"./vendor.date-fns.js";import{a as W}from"./react-hooks.js";import{P as we}from"./Popover.js";import{m as mt}from"./vendor.memoize-one.js";import{h as pt}from"./roots.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./iframe-reset.styl.js";import"./flow-condition-types.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="5f9d44d3-5c53-4339-900f-6e15985eefc9",t._sentryDebugIdIdentifier="sentry-dbid-5f9d44d3-5c53-4339-900f-6e15985eefc9")}catch{}})();const gt=new URL("debugger.css",import.meta.url).href,Ce=i.createContext(void 0),S=()=>i.useContext(Ce),ye=i.createContext(null),ae=()=>i.useContext(ye),Ne=i.createContext({debuggerClientConditions:new Map,meta:void 0,buildId:void 0}),V=()=>i.useContext(Ne),H={verifySetup:{name:"Verify setup",icon:k},checkAutoStart:{name:"Check auto-start",icon:Be},currentUser:{name:"Current user",icon:ne}},xe=i.createContext(void 0),ft=({children:t})=>{const n=P(),[s,r]=i.useState(n.getSessionStorageState().debuggerApp?.selectedTab??"verifySetup");return i.useEffect(()=>{n.setSessionStorageState(a=>!a.debuggerApp||!a.debuggerApp.x?a:{...a,debuggerApp:{...a.debuggerApp,selectedTab:s}}),te("Debugger Route changed to",s)},[s]),e.createElement(xe.Provider,{value:{debuggerRoute:s,setDebuggerRoute:r}},t)},oe=()=>{const t=i.useContext(xe);if(t===void 0)throw new Error("useDebuggerRouteHandler must be used within a DebuggerRouteProvider");return{debuggerRoute:t.debuggerRoute,setDebuggerRoute:t.setDebuggerRoute}},Et=t=>{const n=i.useRef(null),s=ae();return i.useEffect(()=>{const r=s?.current,a=o=>{n.current&&!n.current.contains(o.target)&&t(o)};return document.addEventListener("mousedown",a),r?.contentDocument?.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a),r?.contentDocument?.removeEventListener("mousedown",a)}},[t,s,n]),n},ht=()=>e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M18.4393 5.56066C18.158 5.27936 18 4.89782 18 4.5C18 4.10218 18.158 3.72064 18.4393 3.43934C18.7206 3.15804 19.1022 3 19.5 3C19.8978 3 20.2794 3.15804 20.5607 3.43934C20.842 3.72064 21 4.10218 21 4.5C21 4.89782 20.842 5.27936 20.5607 5.56066C20.2794 5.84196 19.8978 6 19.5 6C19.1022 6 18.7206 5.84196 18.4393 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 5.56066C3.15804 5.27936 3 4.89782 3 4.5C3 4.10218 3.15804 3.72064 3.43934 3.43934C3.72064 3.15804 4.10218 3 4.5 3C4.89782 3 5.27936 3.15804 5.56066 3.43934C5.84196 3.72064 6 4.10218 6 4.5C6 4.89782 5.84196 5.27936 5.56066 5.56066C5.27936 5.84196 4.89782 6 4.5 6C4.10218 6 3.72064 5.84196 3.43934 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 13.0607C10.658 12.7794 10.5 12.3978 10.5 12C10.5 11.6022 10.658 11.2206 10.9393 10.9393C11.2206 10.658 11.6022 10.5 12 10.5C12.3978 10.5 12.7794 10.658 13.0607 10.9393C13.342 11.2206 13.5 11.6022 13.5 12C13.5 12.3978 13.342 12.7794 13.0607 13.0607C12.7794 13.342 12.3978 13.5 12 13.5C11.6022 13.5 11.2206 13.342 10.9393 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 20.5607C3.15804 20.2794 3 19.8978 3 19.5C3 19.1022 3.15804 18.7206 3.43934 18.4393C3.72064 18.158 4.10218 18 4.5 18C4.89782 18 5.27936 18.158 5.56066 18.4393C5.84196 18.7206 6 19.1022 6 19.5C6 19.8978 5.84196 20.2794 5.56066 20.5607C5.27936 20.842 4.89782 21 4.5 21C4.10218 21 3.72064 20.842 3.43934 20.5607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 13.0607C3.15804 12.7794 3 12.3978 3 12C3 11.6022 3.15804 11.2206 3.43934 10.9393C3.72064 10.658 4.10218 10.5 4.5 10.5C4.89782 10.5 5.27936 10.658 5.56066 10.9393C5.84196 11.2206 6 11.6022 6 12C6 12.3978 5.84196 12.7794 5.56066 13.0607C5.27936 13.342 4.89782 13.5 4.5 13.5C4.10218 13.5 3.72064 13.342 3.43934 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 5.56066C10.658 5.27936 10.5 4.89782 10.5 4.5C10.5 4.10218 10.658 3.72064 10.9393 3.43934C11.2206 3.15804 11.6022 3 12 3C12.3978 3 12.7794 3.15804 13.0607 3.43934C13.342 3.72064 13.5 4.10218 13.5 4.5C13.5 4.89782 13.342 5.27936 13.0607 5.56066C12.7794 5.84196 12.3978 6 12 6C11.6022 6 11.2206 5.84196 10.9393 5.56066Z",fill:"#537388"})),bt={prefix:"far",iconName:"custom-hand-pointer-slash",icon:[641,512,[],"???","M185.554191,59.5126699 C189.248662,26.0794907 217.382589,0 251.429,0 C287.979,0 317.715,30.056 317.715,67 L317.715,140.634 C338.128,137.776 359.183,144.576 374.31,160.263 C401.503,147.416 434.689,154.593 454.182,179.361 C497.375,162.727 544,195.156 544,242 L544,326 C544,330.296189 543.590626,334.580726 542.780274,338.796073 L495.999,302.221942 L495.999,242 C495.999,216.84 459.428,216.879 459.428,242 C459.428,250.836 452.265,258 443.428,258 L439.435556,258 L420.622383,243.291649 C420.588346,242.865584 420.571,242.434817 420.571,242 L420.571,221 C420.571,197.943344 389.858993,196.049429 384.724023,215.225903 L269.713,125.308981 L269.713,67 C269.713,41.84 233.142,41.88 233.142,67 L233.142,96.717359 L185.554191,59.5126699 Z M162.172457,223.995642 L233.142,279.479508 L233.142,308.493 C233.142,324.063 213.106,330.402 204.111,317.776 L176.985,279.697 C162.585,259.485 133.185,282.08 147.591,302.303 L257.303,456.303 C260.737,461.122 266.231,464 272,464 L450.285,464 C455.041109,464 459.427079,462.119816 462.713129,458.957818 L500.616335,488.590478 C488.331086,503.061811 470.146238,512 450.286,512 L272,512 C250.741,512 230.632,501.59 218.209,484.154 L108.51,330.153 C87.267,300.334 93.705,258.796 123.06,237.001 C134.952446,228.171597 148.664261,223.998532 162.172457,223.995642 Z M272.143,309.970422 L306.143,336.551563 L306.143,400 C306.143,408.837 299.875,416 292.143,416 L286.143,416 C278.41,416 272.143,408.837 272.143,400 L272.143,309.970422 Z M347.571,368.939901 L381.571,395.521042 L381.571,400 C381.571,408.837 375.303,416 367.571,416 L361.571,416 C353.839,416 347.571,408.837 347.571,400 L347.571,368.939901 Z M633.994211,471.020009 C640.904211,476.540009 642.014211,486.610009 636.494211,493.510009 L626.494211,506 C620.964211,512.890009 610.904211,514.010009 604.004211,508.490009 L6.00421069,40.9800088 C-0.895789309,35.4600088 -2.01578931,25.3900088 3.51421069,18.4900088 L13.5142107,6 C19.0342107,-0.899991212 29.1042107,-2.00999121 36.0042107,3.51000879 L633.994211,471.020009 Z"]},vt={CLICK:Ee,DISABLED:F,MOUSEDOWN:Ge,NOT_CLICK:bt,NOT_DISABLED:k,NOT_PRESENT:fe,PRESENT:re},_t={COMPLETED:k,NOT_COMPLETED:F,NOT_SEEN:fe,ACTIVE:qe,NOT_ACTIVE:He,SEEN:re},wt={CLICK:"is clicked",DISABLED:"is disabled",MOUSEDOWN:"has mouse down on it",NOT_CLICK:"is not clicked",NOT_DISABLED:"is not disabled",NOT_PRESENT:"is not present",PRESENT:"is present"};function Ct(t){return wt[t]}const yt={COMPLETED:"completed",NOT_COMPLETED:"not completed",NOT_SEEN:"not seen",ACTIVE:"is currently active",NOT_ACTIVE:"is not currently active",SEEN:"seen"};function Nt(t){return yt[t]}function xt(t,n){let s=(n||"").toLowerCase();return(t.eventTimeOperator===D.RELATIVE_BETWEEN?t.eventRelativeValue2:t.eventRelativeValue)!==1&&(s+="s"),t.eventTimeOperator!==D.RELATIVE_GT&&(s+=" ago"),s}function St(t){return(t.eventFrequencyOperator===A.BETWEEN?t.eventFrequencyValue2:t.eventFrequencyValue)===1?"time":"times"}const Tt={CURRENT_USER:"by current user in any company",CURRENT_USER_CURRENT_GROUP:"by current user in current company",CURRENT_GROUP:"by any user in current company"};function Ot(t){return Tt[t]}function Dt(t){if(!t)return"";switch(t){case A.BETWEEN:return"between";case A.EQ:return"exactly";case A.GTE:return"at least";case A.LTE:return"at most"}}function It(t){if(!t)return"";switch(t){case D.ANY:return"at any point in time";case D.RELATIVE_BETWEEN:return"between";case D.RELATIVE_GT:return"in the last";case D.RELATIVE_LT:return"more than"}}const Ft={1:"Lowest",2:"Low",3:"Medium",4:"High",5:"Highest"};function Lt(t){return`${Ft[t]||String(t)} priority`}function ee(t,n){switch(t){case B.DAY:return n===1?"day":"days";case B.HOUR:return n===1?"hour":"hours";case B.MINUTE:return n===1?"minute":"minutes";case B.SECOND:return n===1?"second":"seconds"}}function de(t){switch(t){case"USER":return ne;case"GROUP":return ze;case"GROUP_MEMBERSHIP":return We;case"EVENT":return he}}function Pt(t){const n=t.split("/");if(n.length===1)return["USER",t];switch(n[0]){case"group":return["GROUP",n[1]];case"group_membership":return["GROUP_MEMBERSHIP",n[1]];case"event":return["EVENT",n[1]]}return console.warn("parseAttributeDefinitionFqn: Invalid attribute definition FQN",t),["USER",t]}const Rt={[O.BANNER]:"banner",[O.CHECKLIST]:"checklist",[O.FLOW]:"flow",[O.EMBED]:"embed",[O.LAUNCHER]:"launcher",[O.RESOURCE_CENTER]:"resource center",[O.WORKFLOW]:"action flows"};function Ut(t,{title:n,plural:s}={}){let r=Rt[t];return n&&(r=J(r)),s&&(r+="s"),r}const At="d MMM yyyy",kt=Intl.DateTimeFormat(Intl.DateTimeFormat().resolvedOptions().locale,{hour:"numeric"}).resolvedOptions().hourCycle==="h12";function me(t){if(t==null)return"";const n=kt?t.getMinutes()===0?"h aaa":"h:mm aaa":"HH:mm";return se(t,At+", "+n)}function Mt(t){if(!t)return null;const n=dt(t,"yyyy-MM-dd",new Date);return isNaN(n.valueOf())?null:n}function pe(t){if(!t)return null;const n=ut(t);return isNaN(n.valueOf())?null:n}var Se=(t=>(t.EVENT="EVENT",t.GROUP="GROUP",t.GROUP_MEMBERSHIP="GROUP_MEMBERSHIP",t.USER="USER",t))(Se||{});function ge(t){return({condition:n})=>{throw new Error(`conditionOperators.${n.operator}.${t} is not supported`)}}const Z={[m.ABSOLUTE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"on")," ",e.createElement("span",{className:"nowrap text-bold"},Q(t.value)))},[m.ABSOLUTE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"after")," ",e.createElement("span",{className:"nowrap text-bold"},Q(t.value)))},[m.ABSOLUTE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"before")," ",e.createElement("span",{className:"nowrap text-bold"},Q(t.value)))},[m.AND]:{Preview:ge("Preview")},[m.BETWEEN]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is between")," ",e.createElement("b",null,t.value)," ",e.createElement("span",{className:"text-secondary"},"and")," ",e.createElement("b",null,t.value2))},[m.CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"contains")," ",e.createElement("b",null,t.value))},[m.EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is empty")},[m.ENDS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"ends with")," ",e.createElement("b",null,t.value))},[m.EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is")," ",e.createElement("b",null,t.dataType===ue.FLOW&&t.value?e.createElement("span",null,t?.eventDisplayName??t.eventName):t.value))},[m.EXCLUDES_ALL]:{Preview:({condition:t})=>q(t,"does not include","all of")},[m.EXCLUDES_ANY]:{Preview:({condition:t})=>q(t,"does not include","at least one of")},[m.FALSE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is false")},[m.GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than")," ",e.createElement("b",null,t.value))},[m.GTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than or equal to")," ",e.createElement("b",null,t.value))},[m.INCLUDES_ALL]:{Preview:({condition:t})=>q(t,"includes","all of")},[m.INCLUDES_ANY]:{Preview:({condition:t})=>q(t,"includes","at least one of")},[m.LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than")," ",e.createElement("b",null,t.value))},[m.LTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than or equal to")," ",e.createElement("b",null,t.value))},[m.NE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is not")," ",e.createElement("b",null,t.dataType===ue.FLOW&&t.value?e.createElement("span",null," ",t?.eventDisplayName??t.eventName):t.value))},[m.NOT_CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not contain")," ",e.createElement("b",null,t.value))},[m.NOT_EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"has any value")},[m.NOT_REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",e.createElement("b",null,t.value))},[m.OR]:{Preview:ge("Preview")},[m.REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",e.createElement("b",null,t.value))},[m.RELATIVE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"exactly")," ",e.createElement("span",{className:"nowrap text-bold"},$(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[m.RELATIVE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"less than")," ",e.createElement("span",{className:"nowrap text-bold"},$(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[m.RELATIVE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"more than")," ",e.createElement("span",{className:"nowrap text-bold"},$(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[m.STARTS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"starts with")," ",e.createElement("b",null,t.value))},[m.TRUE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is true")},[m.URL]:{Preview:({condition:t})=>{const{urlPattern:n}=t;if(!n)return e.createElement("span",{className:"text-secondary"},"matches ...");const{includes:s,excludes:r}=n;return e.createElement(e.Fragment,null,s.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",s.map((a,o)=>e.createElement(e.Fragment,{key:o},o>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,a)))),s.length>0&&r.length>0&&e.createElement("span",{className:"text-secondary"}," and "),r.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",r.map((a,o)=>e.createElement(e.Fragment,{key:o},o>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,a)))))}}};function Vt(t){return parseInt(t,10)}function $(t){if(!t)return"days";const n=Vt(t);return isNaN(n)?"days":n+" "+(n===1?"day":"days")}function Q(t){if(!t)return"";const n=Mt(t);return n?se(n,"PP"):""}function q(t,n,s){const r=t.values||[];return e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},n+(r.length>1?" "+s:""))," ",r.map((a,o)=>e.createElement(e.Fragment,{key:o},o>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",{key:o},a))))}const le=t=>({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":t===!0,"userflow-debugger-condition__item__danger":t===!1,"userflow-debugger-condition__item__intermediate":t===null}),ie=t=>t===!0?I:t===!1?F:L,Te=(t,n)=>{const s=S();return i.useMemo(()=>{const o=(n?s?.hiddenCondition?.breakdown:s?.startCondition?.breakdown)?.find(l=>l.conditionId===t.id);return{classes:le(o?.match),icon:ie(o?.match)}},[t,s,n])},G=t=>{const{condition:n,isHideCond:s}=t,{classes:r,icon:a}=Te(n,s),o=n.type;if(o===x.CLAUSE)return e.createElement(Ht,{...t});const l=De[o];return e.createElement("div",{className:g(r)},e.createElement("span",{className:"d-flex gap-8 align-center userflow-debugger-condition__item__icon"},l.icon?e.createElement(u,{icon:l.icon({condition:n})}):null,e.createElement(l.Preview,{...t})),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:a}))},Bt=()=>{const t=S(),[n,s]=i.useState(!1),r=i.useMemo(()=>t?.hiddenCondition?.breakdown.find(o=>o.conditionId===t?.hiddenCondition?.condition.id),[t?.hiddenCondition]);return t?.hiddenCondition?.condition?e.createElement("div",{role:"button",className:g({"d-flex gap-8 flex-column margin-8":!0,"userflow-debugger-condition__clause":!0,"userflow-debugger-hide-condition__clause__success":r?.match===!0,"userflow-debugger-hide-condition__clause__danger":r?.match===!1,"userflow-debugger-hide-condition__clause__expanded":n}),onClick:a=>{s(!n),a.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between align-center"},e.createElement("span",null,"Termporarily hide flow"," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",n?"collapse":"expand")),e.createElement(u,{icon:M})),n&&e.createElement(G,{isRoot:!0,isHideCond:!0,condition:t?.hiddenCondition?.condition})):null},Ht=({condition:t,isRoot:n=!1,isHideCond:s=!1})=>{const[r,a]=i.useState(!1),{classes:o,icon:l}=Te(t,s);return n?e.createElement(e.Fragment,null,t.conditions.map((c,p)=>e.createElement(G,{isHideCond:s,key:p,condition:c}))):e.createElement("div",{role:"button",className:g({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__clause":r,...r?{"userflow-debugger-condition__item__success__expanded":o["userflow-debugger-condition__item__success"],"userflow-debugger-condition__item__danger__expanded":o["userflow-debugger-condition__item__danger"],"userflow-debugger-condition__item__intermediate__expanded":o["userflow-debugger-condition__item__intermediate"]}:o}),onClick:c=>{a(!r),c.stopPropagation()}},e.createElement("div",{className:"d-flex justify-space-between align-center w-full"},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:Qe})," ",e.createElement("strong",null,"Logic Group")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",r?"collapse":"expand")),!r&&e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:l})),r&&e.createElement(e.Fragment,null,t.conditions.map((c,p)=>e.createElement("div",{key:p,className:g({"userflow-debugger-condition__clause__operator__wrapper":!0})},p>0&&e.createElement("div",{className:g({"userflow-debugger-condition__clause__operator":!0})},e.createElement(Oe,{condition:t})),e.createElement(G,{isHideCond:s,condition:c})))))},Oe=({condition:t})=>{const n=t.operator;return n?e.createElement("span",{className:g({"userflow-debugger-condition__item__operator":!0,"userflow-debugger-condition__item__operator__and":n===m.AND,"userflow-debugger-condition__item__operator__or":n===m.OR})},n===m.AND&&"AND",n===m.OR&&"OR"):null},qt={[T.NONE]:F,[T.PENDING_SCHEDULE]:F,[T.SCHEDULED]:L,[T.FIRED]:I},Gt=e.memo(()=>{const t=S(),{waitTimer:n}=t||{},s=t?.startCondition?.condition.waitTime,{ref:r,hovered:a,eventHandlers:o}=W();return!s||!n||n===T.NONE?null:e.createElement("div",{ref:r,...o,className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":n===T.PENDING_SCHEDULE,"userflow-debugger-condition__item__intermediate":n===T.SCHEDULED,"userflow-debugger-condition__item__success":n===T.FIRED})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:Ze}),e.createElement("span",null,"Wait ",e.createElement("strong",null,s)," seconds")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:qt[n]}),e.createElement(z,{target:r,hovered:a&&n===T.PENDING_SCHEDULE},"Timer activates once all conditions are satisfied"))}),Wt=e.memo(()=>{const t=S(),[n,s]=i.useState(!1),{startFrequency:r,listFlowLatestVersion:a}=t||{startFrequency:{}};if(!r||!a?.startFrequency||a?.startFrequency===U.NEVER)return null;const{currentFlowIntervalThrottle:o,frequency:l,frequencyUsage:c}=r,p=ie(l),_=le(l);if(a.startFrequency===U.ONCE||a.startFrequency===U.ONCE_PER_GROUP)return e.createElement("div",{className:g(_)},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:be}),e.createElement("strong",null,"Once per user"," ",a.startFrequency===U.ONCE_PER_GROUP&&"per company")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:p}));if(a.startFrequency===U.ALWAYS&&a.startIntervalValue&&a.startIntervalUnit)return e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":o===!0,"userflow-debugger-condition__item__intermediate":o===!1})},e.createElement("span",null,"Every ",e.createElement("strong",null,a.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},ee(a.startIntervalUnit,a.startIntervalValue)," ","apart")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:o===!1?L:I}));if(a.startFrequency===U.MULTIPLE){const E=l===!0&&o===!0,h=l===!0&&o===!1,y=l===!1;return e.createElement("div",{className:g({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__clause":n,...n?{"userflow-debugger-condition-frequency__success__expanded":E,"userflow-debugger-condition-frequency__intermediate__expanded":h,"userflow-debugger-condition-frequency__danger__expanded":y}:{"userflow-debugger-condition-frequency__success":E,"userflow-debugger-condition-frequency__intermediate":h,"userflow-debugger-condition-frequency__danger":y}}),onClick:N=>{s(!n),N.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between"},e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement("strong",null,"Start multiple times")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to expand")),!n&&e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:E?I:h?L:F})),n&&e.createElement(e.Fragment,null,e.createElement("div",{className:g(_)},e.createElement("span",null,e.createElement("strong",null,a.startLimit)," ",e.createElement("span",{className:"userflow-debugger-info-text"},"(started ",c," times)")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:p})),a.startIntervalUnit&&a.startIntervalValue&&e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":o===!0,"userflow-debugger-condition__item__intermediate":o===!1})},e.createElement("span",null,e.createElement("strong",null,a.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},ee(a.startIntervalUnit,a.startIntervalValue)," ","apart")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:o===!1?L:I}))))}return null}),zt=()=>{const t=S(),{priority:n}=t||{};return n?.priority?e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__priority":!0})},e.createElement("span",null,e.createElement("strong",null,Lt(n?.priority))," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to learn more")),e.createElement("a",{href:"https://docs.userflow.com/docs/trouble/using-the-debugger#flow-trigger-precedence",target:"_blank",rel:"noreferrer noopener"},e.createElement(u,{icon:ve}))):null},jt=()=>{const t=S(),{startFrequency:n}=t||{},{onlyIfNotCompleted:s}=n||{};return s==null?null:e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":s===!0,"userflow-debugger-condition__item__danger":s===!1})},"Only if not completed",e.createElement(u,{icon:s===!0?I:F}))},Yt=()=>{const t=S(),{startFrequency:n}=t||{},{hovered:s,eventHandlers:r,ref:a}=W();return!n||n?.scopeByGroup===null||n.scopeByGroup===void 0||n.scopeByGroup===!0?null:e.createElement("div",{ref:a,...r,className:g({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":!0})},"Constrain to current company",e.createElement(u,{icon:ie(n.scopeByGroup)}),e.createElement(z,{target:a,hovered:s},"User is not associated with a company"))},Xt=()=>{const t=S(),{startFrequency:n,listFlowLatestVersion:s}=t||{},{anyFlowIntervalThrottle:r}=n||{},{throttleUnit:a,throttleValue:o}=s||{};return r===null||a===null||o===null||a===void 0||o===void 0?null:e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":r===!0,"userflow-debugger-condition__item__intermediate":r===!1})},e.createElement("span",null,"Atleast ",e.createElement("strong",null,s?.throttleValue)," ",ee(a,o)," after any flow"),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:r===!0?I:L}))},Kt=e.memo(()=>{const{hovered:t,eventHandlers:n,ref:s}=W(),r=S(),{snoozed:a}=r||{},o=i.useMemo(()=>{if(a?.until)return se(new Date(a.until),"MMM do, h:mm a")},[a?.until]);return a?e.createElement("div",{ref:s,...n,className:g({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__intermediate":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:$e}),e.createElement("span",null,"This flow is currently ",e.createElement("strong",null,"snoozed"))),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:L}),e.createElement(z,{target:s,hovered:t},"Snoozed until ",o)):null}),De={[x.PAGE]:{icon:()=>Ke,Preview:({condition:t})=>{const n=t.operator&&Z[t.operator];return e.createElement("span",null,"URL"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[x.ATTRIBUTE]:{icon:({condition:t})=>{if(!t||!t.attributeName)return de(Se.EVENT);const[n]=Pt(t.attributeName);return de(n)},Preview:({condition:t})=>{const n=t.operator&&Z[t.operator];return e.createElement("span",null,e.createElement("strong",null,t.attributeDisplayName?t.attributeDisplayName:"Attribute")," ",e.createElement("span",{className:"userflow-debugger-info-text"},n&&e.createElement(n.Preview,{condition:t})))}},[x.SEGMENT]:{icon:()=>Xe,Preview:({condition:t})=>{const{segment:n}=t;return e.createElement("span",null,e.createElement("strong",null,n?.subjectType===Ue.GROUP?"Company":"User")," ",e.createElement("span",{className:"text-secondary"},t.operator===m.FALSE?"is not in":"is in")," ",e.createElement("strong",null,n?.name||"Segment"))}},[x.ELEMENT]:{icon:({condition:t})=>t.elementState?vt[t.elementState]:Je,Preview:({condition:t})=>e.createElement("span",null,"Element"," ",t.elementState&&e.createElement("strong",null,Ct(t.elementState)))},[x.INPUT_VALUE]:{icon:()=>Ye,Preview:({condition:t})=>{const n=t.operator&&Z[t.operator];return e.createElement("span",null,"The value of input"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[x.FILLED_IN_INPUT]:{icon:()=>je,Preview:()=>e.createElement("span",null,"User fills an input")},[x.FLOW]:{icon:({condition:t})=>t.flowState?_t[t.flowState]:re,Preview:({condition:t})=>t.flow?.type===O.SITE?null:e.createElement("span",null,t.flow?e.createElement(e.Fragment,null,Ut(t.flow.type,{title:!0})," ",e.createElement("strong",null,t.flow.name)):"Flow/checklist"," ",t.flowState&&Nt(t.flowState))},[x.TIME]:{icon:()=>be,Preview:({condition:t})=>{const n=t.value?pe(t.value):null,s=n&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},me(n)),r=t.value2?pe(t.value2):null,a=r&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},me(r));return s&&a?e.createElement("span",null,"Current time is between ",s," and ",a):s?e.createElement(e.Fragment,null,"Current time is after ",s):a?e.createElement(e.Fragment,null,"Current time is before ",a):e.createElement(e.Fragment,null,"Current time is ...")}},[x.EVENT]:{icon:()=>he,Preview:({condition:t})=>{const{ref:n,hovered:s,eventHandlers:r}=W();return e.createElement("div",{ref:n,...r},e.createElement("strong",null,t.eventDisplayName?t.eventDisplayName:"Event")," ",e.createElement("span",{className:"userflow-debugger-info-text"},Dt(t.eventFrequencyOperator))," ",e.createElement("strong",null,t.eventFrequencyValue),t.eventFrequencyOperator===A.BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventFrequencyValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},St(t),","," ",It(t.eventTimeOperator)),t.eventTimeOperator!==D.ANY&&e.createElement(e.Fragment,null," ",e.createElement("strong",null,t.eventRelativeValue),t.eventTimeOperator===D.RELATIVE_BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventRelativeValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},xt(t,t.eventRelativeUnit))),t.eventActor&&t.eventActor!==Re.CURRENT_USER?e.createElement(e.Fragment,null," ",e.createElement("strong",null,Ot(t.eventActor))):"",t.whereCondition&&s&&e.createElement(z,{hovered:!0,target:n},"Where ",e.createElement("br",null),e.createElement(Ie,{condition:t.whereCondition})))}},[x.ALWAYS_TRUE]:{icon:()=>I,Preview:()=>e.createElement("span",null,"Water is wet")},[x.CHECKLIST_TASK_CLICKED]:{icon:()=>Ee,Preview:()=>e.createElement("span",null,"Task is clicked")}},Ie=t=>e.createElement("div",null,t.condition.conditions.map((n,s)=>e.createElement("div",{key:n.id}," ",s===0?null:e.createElement("span",{className:"userflow-debugger-info-text"},t.condition.operator?.toLowerCase())," ",n.type==="ATTRIBUTE"&&De.ATTRIBUTE.Preview({condition:n,isRoot:!0,isHideCond:!1}),n.type==="CLAUSE"&&e.createElement(e.Fragment,null,"(",e.createElement(Ie,{condition:n}),")")))),z=({hovered:t,children:n,target:s})=>{const r=ae();return t?e.createElement(we,{className:"userflow-debugger-popover",target:s.current,placement:"top",horizontalAlign:"center",verticalAlign:"center",document:r?.current?.contentDocument||void 0},n):null};class Zt extends e.PureComponent{constructor(n){super(n),this.rootRef=e.createRef(),this.optionsElRef=e.createRef(),this.input=null,this.popoverRef=e.createRef(),this.isMouseDown=!1,this.isCreateOpen=!1,this.setInput=s=>{this.input=s;const{inputRef:r}=this.props;r&&(typeof r=="function"?r(s):r.current=s)},this.onInputChange=s=>{s.stopPropagation();const{value:r}=s.target;r!==""&&this.openPopover();const a=this.memoizedFilterOptions(this.props.options,r);this.setState({inputValue:r,q:r,highlightedIndex:a.length>0?0:-1,createHighlighted:a.length===0}),r===""&&!this.props.noEmpty&&this.triggerOnChange(null),this.props.onSearchChange&&this.props.onSearchChange(r)},this.onPopoverPlacementChange=s=>this.setState({popoverPlacement:s}),this.onMouseDown=s=>{s.preventDefault(),this.isMouseDown=!0;const r=()=>{this.isMouseDown=!1,this.props.document?.removeEventListener("mouseup",r),document.body.removeEventListener("mouseup",r)};this.props.document?.addEventListener("mouseup",r),document.body.addEventListener("mouseup",r)},this.onFocus=s=>{this.input&&!this.props.noSearch&&this.input.select(),this.props.onFocus&&this.props.onFocus(s)},this.onBlur=s=>{this.isMouseDown||this.closePopover(),this.props.onBlur&&!this.isCreateOpen&&this.props.onBlur(s)},this.onClose=()=>{this.state.popoverOpen&&this.closePopover(),this.props.onClose&&this.props.onClose()},this.onTriggerClick=()=>{this.props.readOnly||this.props.disabled||(this.state.popoverOpen?this.closePopover():(this.input&&this.input.focus(),this.openPopover()))},this.onKeyDown=s=>{const{popoverOpen:r,highlightedIndex:a,createHighlighted:o}=this.state,l=this.getFilteredOptions(),c=l.length-1;switch(s.key){case"ArrowUp":s.preventDefault(),r&&(o?this.setState({highlightedIndex:c,createHighlighted:!1}):a>0&&this.setState({highlightedIndex:a-1}));break;case"ArrowDown":s.preventDefault(),r?this.props.onCreate&&(a===c||o)?this.setState({highlightedIndex:-1,createHighlighted:!0}):a<c&&this.setState({highlightedIndex:a+1}):this.props.noOpenOnDown||this.openPopover();break;case"Enter":if(r)if(s.preventDefault(),o&&!this.props.disableCreate)this.fireOnCreate();else{const p=l[a];p||!this.props.noEmpty?this.selectOption(p):!p&&this.props.hideOnEmpty&&this.props.onEnter&&this.props.onEnter()}else this.props.onEnter?this.props.onEnter():this.openPopover();break;case"Tab":r&&!this.props.ignoreTab&&this.selectOption(l[a]);break;case"Escape":r&&(s.preventDefault(),s.stopPropagation(),this.setState({popoverOpen:!1}));break}},this.selectOption=s=>{const r=s!==this.props.value;this.closePopover(),r&&this.triggerOnChange(s)},this.highlightOption=s=>{this.setState({highlightedIndex:s,createHighlighted:!1})},this.highlightCreate=()=>{this.setState({highlightedIndex:-1,createHighlighted:!0})},this.fireOnCreate=()=>{const{onCreate:s}=this.props;if(s){this.isCreateOpen=!0;const r={q:J(this.state.q),callback:a=>{this.isCreateOpen=!1,a!=null&&this.selectOption(a),this.input&&this.input.focus()}};s(r),this.closePopover()}},this.openPopover=()=>{if(!this.state.popoverOpen){const s=this.getFilteredOptions();let r=0,a=!1;if(s.length===0)r=-1,a=!0;else{const{value:o}=this.props,l=s.findIndex(c=>c===o);l!==-1&&(r=l)}this.setState({popoverOpen:!0,highlightedIndex:r,createHighlighted:a})}},this.memoizedFilterOptions=mt((s,r)=>(s=s||[],r?s.filter(a=>this.filter(a,r)):s)),this.state={inputValue:this.renderOptionText(n.value==null?null:n.value),q:"",popoverOpen:!1,popoverPlacement:null,highlightedIndex:-1,createHighlighted:!1}}componentDidUpdate(n,s){const{value:r}=this.props;if(r!==n.value){const a=this.renderOptionText(r??null);a!==this.state.inputValue&&this.setState({inputValue:a})}s.highlightedIndex!==this.state.highlightedIndex&&this.scrollHighlightedOptionIntoView()}render(){let n,s=!1;const{props:r}=this,a=this.state,o=a.popoverPlacement==="top"?"above":"below";if(a.popoverOpen&&this.rootRef.current){const c=this.getFilteredOptions();if(this.props.hideOnEmpty&&c.length===0)s=!0;else{let p;if(c.length>0){let _=null;p=c.reduce((E,h,y)=>{const N=this.getOptionGroup(h);N&&N!==_&&E.push(e.createElement("div",{key:"group:"+N,className:"combo-box__group-header"},N)),_=N;const d=["combo-box__option"];return y===a.highlightedIndex&&d.push("combo-box__option--highlighted"),this.props.optionClassName&&d.push(this.props.optionClassName),E.push(e.createElement($t,{key:this.getOptionKey(h,y),className:d.join(" "),option:h,idx:y,renderOptionText:r.renderOptionText,renderOptionItem:r.renderOptionItem,getOptionIcon:r.getOptionIcon,onClick:this.selectOption,onHover:this.highlightOption})),y<c.length-1&&r.hasSeparatorAfter&&r.hasSeparatorAfter(h)&&E.push(e.createElement("div",{key:"sep-"+y,className:"combo-box__option-sep"})),E},[])}else r.loading?p=e.createElement("div",{className:"combo-box__no-results"},"Loading..."):p=e.createElement("div",{className:"combo-box__no-results"},"No matching ",r.nounPlural||"items");n=e.createElement(we,{ref:this.popoverRef,className:"combo-box-popover"+(r.popoverNotch?"":` combo-box-popover--${o}`),noNotch:!r.popoverNotch,target:this.rootRef.current,forceDimension:!0,matchWidth:!0,minWidth:r.popoverMinWidth,onMouseDown:this.onMouseDown,onPlacementChange:this.onPopoverPlacementChange,document:r.document},e.createElement("div",{ref:this.optionsElRef,className:g({"combo-box__options":!0,"combo-box__options--with-create":!!r.onCreate})},p),r.onCreate&&e.createElement("div",{key:"create",className:g({"combo-box__option":!0,"combo-box__option--create":!0,"combo-box__option--highlighted":a.createHighlighted}),onClick:this.fireOnCreate,onMouseMove:this.highlightCreate},e.createElement("div",{className:"combo-box__create-icon"},e.createElement(u,{icon:et})),e.createElement("div",{className:"combo-box__create-text"},"Create"," ",a.q===""?"new"+(r.noun?` ${r.noun}`:""):e.createElement("b",null,J(a.inputValue)))))}}const l=["input-group","combo-box"];return a.popoverOpen&&!s&&(l.push("combo-box--open"),r.popoverNotch||l.push(`combo-box--with-popover-${o}`)),r.disabled&&l.push("input-group--disabled"),r.noSearch&&l.push("combo-box--no-search"),r.className&&l.push(r.className),e.createElement(e.Fragment,null,e.createElement("div",{className:l.join(" "),style:{width:r.width?r.width+"px":void 0},ref:this.rootRef,onClick:r.readOnly||r.disabled?void 0:()=>{this.input?.focus(),this.openPopover()}},r.childrenBefore,r.value&&r.getOptionIcon&&e.createElement("div",{className:"combobox__input-icon"},Le(r.value,r.getOptionIcon)),e.createElement("input",{type:"text",className:r.inputClassName,name:r.name,value:a.inputValue,onChange:this.onInputChange,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onMouseDown:this.openPopover,placeholder:r.placeholder,readOnly:r.readOnly||r.noSearch,disabled:r.disabled,autoComplete:"off",ref:this.setInput,...r.inputHtmlAttributes}),!r.noTrigger&&e.createElement("div",{"data-testid":r.triggerTestId||"combo-box-trigger",className:"input-group__append input-group__trigger",onClick:this.onTriggerClick,onMouseDown:this.onMouseDown},e.createElement(u,{icon:tt})),r.onClose&&e.createElement("div",{className:"input-group__append input-group__trigger",onClick:this.onClose},e.createElement(u,{icon:nt})),r.childrenAfter),n)}scrollHighlightedOptionIntoView(){const n=this.optionsElRef.current;if(this.state.popoverOpen&&n){const s=n.querySelector(".combo-box__option--highlighted");if(s){const r=n.getBoundingClientRect(),a=s.getBoundingClientRect();a.top<r.top?n.scrollTop+=a.top-r.top:a.bottom>r.bottom&&(n.scrollTop+=a.bottom-r.bottom)}}}triggerOnChange(n){const{onChange:s}=this.props;s&&s(n)}closePopover(){this.setState({popoverOpen:!1,inputValue:this.renderOptionText(this.props.value==null?null:this.props.value),q:""})}renderOptionText(n){return n==null?"":Fe(n,this.props.renderOptionText)}getFilteredOptions(){return this.memoizedFilterOptions(this.props.options,this.state.q)}filter(n,s){return this.props.filter?this.props.filter(n,s):this.renderOptionText(n).toLowerCase().includes(s.toLowerCase())}getOptionKey(n,s){return n&&n.id||s}getOptionGroup(n){return this.props.getOptionGroup?this.props.getOptionGroup(n):n&&n.group||null}}class $t extends e.PureComponent{constructor(){super(...arguments),this.state={isOptionDisabled:!1},this.onClick=()=>{this.state.isOptionDisabled||this.props.onClick(this.props.option)},this.onHover=()=>{this.state.isOptionDisabled||this.props.onHover(this.props.idx)}}componentDidMount(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}componentDidUpdate(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}render(){const{isOptionDisabled:n}=this.state,{props:s}=this;return e.createElement("div",{className:g({[s.className]:!0,"combo-box__option--disabled":n}),onClick:this.onClick,onMouseMove:this.onHover},Qt(s.option,s.renderOptionText,s.renderOptionItem,s.getOptionIcon))}}function Fe(t,n){return n?n(t):typeof t=="string"||typeof t=="number"?t:t?t.name:"?"}function Qt(t,n,s,r){if(s)return s(t);{let a=Fe(t,n);return r?e.createElement("div",{className:"d-flex align-flex-start"},e.createElement("div",{className:"combobox__option-icon"},Le(t,r)),e.createElement("div",{className:"flex-1"},a)):a}}function Le(t,n){const s=n(t);return Jt(s)?e.createElement(u,{icon:s}):s}function Jt(t){return pt(t)&&"iconName"in t}const en=({selectedFlow:t,setSelectedFlow:n,flows:s,debugAutoStartCondition:r})=>{const a=P(),o=ae();i.useEffect(()=>{if(!t)return;r(t.latestVersion);const c=()=>{r(t.latestVersion)};return a.on("private:checkSessionsAck",c),document.addEventListener("visibilitychange",c),()=>{a.off("private:checkSessionsAck",c),document.removeEventListener("visibilitychange",c)}},[t]);const l=i.useCallback(c=>{!c||t?.latestVersion?.id===c.latestVersion.id||n(c)},[t]);return e.createElement(e.Fragment,null,e.createElement("div",{className:"d-flex align-center justify-space-between"},e.createElement("div",{className:"d-flex justify-space-between align-center"},"Select Flow"),e.createElement(Zt,{className:"userflow-debugger__flow__selector",value:t,options:s,placeholder:"Select flow",document:o?.current?.contentDocument||void 0,onChange:l,renderOptionItem:c=>c.name})),e.createElement(tn,{selectedFlow:t,selectedFlowVersionsId:t?.latestVersion?.id}))},tn=({selectedFlowVersionsId:t,selectedFlow:n})=>{const s=P(),[r,a]=i.useState(!1),o=S(),l=o&&o?.activeFlow?.id===n?.id;return i.useEffect(()=>(a(!1),s.on("private:setFlowSession",c=>{a(c===t)}),()=>{s.off("private:setFlowSession",()=>a(!1))}),[t]),i.useEffect(()=>{l||a(!1)},[l]),o?.activeFlow===null?null:e.createElement(e.Fragment,null,o?.locale?.match===!1&&e.createElement("div",{className:g(le(!1))},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:F}),e.createElement("span",null,"The flow will not auto start ",e.createElement("br",null)," ",e.createElement("b",null,"User locale (",o?.locale?.code,") is not enabled.")))),r?e.createElement("div",{className:g({"d-flex align-center fade-in":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(u,{icon:M}),e.createElement("span",null,"This flow ",e.createElement("strong",null,"just")," started"))):null,l&&!r&&e.createElement("div",{className:g({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(u,{icon:M}),e.createElement("span",null,"This flow is currently active"))),!l&&o&&e.createElement("div",{className:g({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:M,size:16}),e.createElement("span",null,"Another flow is currently active"))))},nn=t=>{const[n,s]=i.useState(document.visibilityState==="visible"),r=i.useRef(t);return i.useEffect(()=>{r.current=t},[t]),i.useEffect(()=>{const a=()=>{const o=document.visibilityState==="visible";s(o),r.current?.(o)};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a)}},[]),n},rn=({close:t})=>{const n=P(),s=i.useRef(null),[r,a]=i.useState(!!n.clientToken),[o,l]=i.useState(()=>{const f=n.getSessionStorageState(),v=f?.debuggerApp?.x,C=f?.debuggerApp?.y||50;return{x:v??(document.body.clientWidth?Number(document.body.clientWidth)-450:50),y:C}}),[c,p]=i.useState(!1),_=i.useRef(null),{meta:E}=V(),{debuggerRoute:h}=oe(),[y,N]=i.useState(!1),d=i.useRef(null),w=i.useRef({mouseX:0,mouseY:0,elementX:0,elementY:0});i.useEffect(()=>{o&&n.setSessionStorageState(f=>({...f,debuggerApp:{...f.debuggerApp,x:o.x,y:o.y}}))},[o]),i.useEffect(()=>{if(!c)return;const f=C=>{const R=C.clientX-w.current.mouseX,j=C.clientY-w.current.mouseY,Y=Math.min(w.current.elementX+R,window.document.body.clientWidth-200),X=Math.max(w.current.elementY+j,0);d.current||(d.current=requestAnimationFrame(()=>{l({x:Y,y:X}),d.current=null}))},v=()=>{p(!1)};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",v),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",v),d.current&&(cancelAnimationFrame(d.current),d.current=null)}},[c,o]),i.useEffect(()=>{const f=()=>{l(C=>{const R=document.body.clientWidth-500,j=document.body.clientHeight-100,Y=Math.max(Math.min(C.x,R),0),X=Math.max(Math.min(C.y,j),0);return{x:Y,y:X}})},v=()=>{a(!!n.clientToken)};return window.addEventListener("resize",f),n.on("private:initialised",v),()=>{window.removeEventListener("resize",f),n.off("private:initialised",v)}},[]);const b=f=>{s.current&&(p(!0),f.preventDefault())};return e.createElement("div",{ref:s,style:{left:"0",top:"0",position:"absolute",willChange:"transform",transform:`translate3d(${o.x}px, ${o.y}px, 0)`,zIndex:1234620}},e.createElement("div",{onMouseDown:b,style:{height:"50px",cursor:"move",userSelect:"none",position:"absolute",width:"50px"}}),e.createElement(Me,{title:"Debugger",stylesheet:gt,style:{borderRadius:"8px",width:"400px",height:h==="checkAutoStart"?"600px":r?"500px":"400px"},elRef:_,onStylesheetsLoad:N},e.createElement(ye.Provider,{value:_},e.createElement("div",{className:"d-flex flex-column userflow-debugger-app",style:{visibility:y?"visible":"hidden"}},e.createElement("div",{className:"d-flex justify-space-between userflow-debugger-app__header"},e.createElement(ht,null),e.createElement("div",{className:"d-flex align-center userflow-debugger-app__title"},e.createElement(Ve,null),e.createElement("span",null,"Userflow debugger")),e.createElement("button",{role:"button",className:"userflow-debugger-app__close",onClick:()=>{n.getSessionStorageState().debuggerApp&&n.setSessionStorageState(f=>({...f,debuggerApp:null})),t()}},e.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M12.1836 4.49609L8.90234 7.77734L12.1562 11.0312C12.4297 11.2773 12.4297 11.6875 12.1562 11.9336C11.9102 12.207 11.5 12.207 11.2539 11.9336L7.97266 8.67969L4.71875 11.9336C4.47266 12.207 4.0625 12.207 3.81641 11.9336C3.54297 11.6875 3.54297 11.2773 3.81641 11.0039L7.07031 7.75L3.81641 4.49609C3.54297 4.25 3.54297 3.83984 3.81641 3.56641C4.0625 3.32031 4.47266 3.32031 4.74609 3.56641L8 6.84766L11.2539 3.59375C11.5 3.32031 11.9102 3.32031 12.1836 3.59375C12.4297 3.83984 12.4297 4.25 12.1836 4.49609Z",fill:"white"})))),e.createElement(sn,null),h==="verifySetup"&&e.createElement(an,null),E?.endUser?.debuggerEnabled&&h==="checkAutoStart"&&e.createElement(on,null),h==="currentUser"&&e.createElement(ln,null)))))},sn=()=>{const t=P(),{meta:n}=V(),[s,r]=i.useState(!1),{debuggerRoute:a,setDebuggerRoute:o}=oe(),l=t.isIdentified(),c=Et(()=>r(!1));return i.useEffect(()=>{n&&n?.endUser.debuggerEnabled===!1&&a==="checkAutoStart"&&o("verifySetup")},[n]),l?e.createElement("div",{ref:c},e.createElement("div",{className:"d-flex align-center justify-space-between userflow-debugger-menu",onClick:()=>r(!s)},e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-menu__title":!0,"userflow-debugger-menu__title--open":s})},e.createElement(u,{icon:H[a].icon}),e.createElement("span",null,H[a].name)),e.createElement("button",{className:"userflow-debugger-menu__toggle"},e.createElement(u,{icon:rt}))),s&&e.createElement("ul",{className:"userflow-debugger-menu__list"},Object.keys(H).map(p=>{if(!n?.endUser?.debuggerEnabled&&p==="checkAutoStart")return null;const _=H[p];return e.createElement("li",{key:p,className:"d-flex align-center userflow-debugger-app__item",onClick:()=>{o&&o(p),r(!1)}},e.createElement(u,{icon:_.icon}),_.name)}))):null},an=()=>{const{meta:t,buildId:n}=V(),s=P(),[r,a]=i.useState(!!s.clientToken),o=i.useMemo(()=>s.isIdentified(),[s,t]),{setDebuggerRoute:l}=oe();i.useEffect(()=>{const E=()=>{a(!!s.clientToken)};return s.on("private:initialised",E),()=>{s.off("private:initialised",E)}},[]);const c=i.useMemo(()=>{let E=K;const h={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return r?(E=k,h["userflow-debugger-installation__step__success"]=!0):(E=lt,h["userflow-debugger-installation__step__danger"]=!0),{icon:E,classes:h}},[r]),p=i.useMemo(()=>{let E=K;const h={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return!r&&!o&&(E=K,h["userflow-debugger-installation__step__failed"]=!0),r&&!o&&(E=M,h["userflow-debugger-installation__step__warning"]=!0),r&&o&&(E=k,h["userflow-debugger-installation__step__success"]=!0),{icon:E,classes:h}},[r,o]),_=()=>o?t?.endUser.debuggerEnabled?e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},t?.env.company.name),e.createElement("span",{className:"userflow-debugger-details"},t?.env.name)):e.createElement("div",{className:"userflow-debugger-details__access__denied"},"The"," ",e.createElement("button",{onClick:()=>l("currentUser")},"currently signed-in user")," ","does not have debugger access"):e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},"Unknown company"),e.createElement("span",{className:"userflow-debugger-details"},"Unknown environment"));return e.createElement("div",{className:"space-evenly userflow-debugger-app__content"},e.createElement("div",{className:"userflow-debugger-installation__steps"},e.createElement("div",{className:g({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__step":!0,"userflow-debugger-installation__step__success":!0})},e.createElement(u,{icon:k,size:32}),"Userflow ",e.createElement("br",null),"installed"),e.createElement("div",{className:g(c.classes)},e.createElement(u,{icon:c.icon,size:32}),"Userflow ",e.createElement("br",null)," ",r?"":"not"," initialized"),e.createElement("div",{className:g(p.classes)},e.createElement(u,{icon:p.icon,size:32}),"User ",e.createElement("br",null)," ",o&&r?"":"not"," ","identified")),!r&&!o&&e.createElement("div",{className:g({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__not__initialized":!0})},"Remember to initialize Userflow by calling",e.createElement("div",null,"userflow.init('YOUR_USERFLOW_TOKEN')")),r&&e.createElement("div",{className:"d-flex gap-8 flex-column userflow-debugger-details__wrapper"},e.createElement("div",{className:"userflow-debugger-details__env__details"},e.createElement("div",{className:"d-flex gap-8 flex-column justify-space-around"},e.createElement(u,{size:20,icon:st}),e.createElement(u,{size:20,icon:at})),e.createElement("div",{className:"d-flex flex-column align-flex-start gap-8"},_())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(u,{size:20,icon:ot}),e.createElement("span",{className:"userflow-debugger-details"},s.getInitToken())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(u,{size:20,icon:ne}),e.createElement("span",{className:"userflow-debugger-details"},o?s.getIdentifiedUser()?.externalId:"User not identified"))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))},on=()=>{const t=P(),{debuggerClientConditions:n}=V(),[s,r]=i.useState(void 0),[a,o]=i.useState([]),[l,c]=i.useState(),p=i.useMemo(()=>{if(l?.startCondition?.match===!1||l?.hiddenCondition?.match===!0||l?.locale?.match===!1)return!1;const d=l?.startFrequency;return!(d&&(d.onlyIfNotCompleted===!1||d.scopeByGroup===!1||d.frequency===!1))},[l]);i.useEffect(()=>{_()},[]),nn(d=>{d&&_()}),i.useEffect(()=>{s&&y(s.latestVersion)},[s]);const _=async()=>{N().then(d=>{if(d?.length&&(o(d),!s)){const w=t.getSessionStorageState()?.debuggerApp?.selectedFlowVersionId,b=d.find(f=>f.latestVersion.id===w);h(b??d[0])}})},E=_e(async d=>{const w=[];for(const[v,C]of n.entries())w.push({conditionId:v,isTrue:C.isTrue});const b={kind:"DebugFlowAutostartCondition",flowVersionId:d.id,clientConditions:w},f=await t.send(b);c({...f,listFlowLatestVersion:d}),f.latestVersion?.id&&d.id!==f.latestVersion?.id&&(N().then(v=>{if(!v)return;o(v);const C=v?.find(R=>R.latestVersion.id===f.latestVersion?.id);C&&h(C)}),E(f.latestVersion))},300),h=d=>{r(d);const w=t.getSessionStorageState().debuggerApp;w&&w?.x&&t.setSessionStorageState(b=>({...b,debuggerApp:{...w,selectedFlowVersionId:d.latestVersion.id}}))},y=async d=>{n.forEach(b=>{b.untrack?.()}),n.clear();const{conditionTypes:w}=await Ae(async()=>{const{conditionTypes:b}=await import("./flow-condition-types.js").then(f=>f.f);return{conditionTypes:b}},__vite__mapDeps([0,1,2,3,4,5,6,7]));for(const b of d.clientConditions){n.set(b.id,{condition:b,isTrue:null});const f=w[b.type];if(!f){console.error(`Unknown condition type ${b.type}`);continue}const v=n.get(b.id);v&&(v.untrack=f.track({sessionData:new ke([]),condition:b,callback:C=>{v.isTrue!==C&&(v.isTrue=C,E(d))}}))}},N=async()=>{try{return(await t.send({kind:"ListFlows",hasAutostartCondition:!0},{handlesRejection:!0})).flows?.filter(b=>b.type==="FLOW")}catch(d){d.code==="debugger_access_denied"&&te("Access defined for List Flows");return}};return e.createElement("div",{className:"userflow-debugger-app__content"},e.createElement(Ce.Provider,{value:l},e.createElement(en,{flows:a,selectedFlow:s,setSelectedFlow:h,debugAutoStartCondition:E}),e.createElement("div",{className:"d-flex flex-column gap-8 userflow-debugger-app__wrapper"},l?.startCondition?.condition&&e.createElement("div",null,e.createElement("div",{className:g({"d-flex gap-8 align-center":!0,"userflow-debugger-app__wrapper__passing":p,"userflow-debugger-app__wrapper__failed":!p})},e.createElement(u,{icon:p?it:ct}),e.createElement("strong",null,"Auto-start conditions")),e.createElement("span",null,"These are"," ",e.createElement(Oe,{condition:l.startCondition.condition}),e.createElement("b",null,"-conditions"),", meaning"," ",l.startCondition.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="AND"&&e.createElement(e.Fragment,null,"all conditions must pass for the flow to start."),l.startCondition?.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="OR"&&e.createElement(e.Fragment,null,"only one condition must pass for the flow to start."))),l?.startCondition?.condition&&e.createElement(G,{isRoot:!0,isHideCond:!1,condition:l.startCondition.condition}),e.createElement(Gt,null),e.createElement(Wt,null),e.createElement(jt,null),e.createElement(Xt,null),e.createElement(zt,null),e.createElement(Bt,null),e.createElement(Yt,null),e.createElement(Kt,null))))},ln=e.memo(()=>{const{meta:t,buildId:n}=V();if(!t)return null;const r="https://app.userflow.com/app/"+(t.env.primary?t.env.company.slug:`${t.env.company.slug}@${t.env.slug}`)+"/settings/debugger?external_id="+t.endUser.externalId;return e.createElement("div",{className:"d-flex flex-column space-evenly flex-1"},e.createElement("div",{className:"d-flex flex-column gap-8"},e.createElement("div",{className:"d-flex flex-column"},t.endUser.avatarUrl?e.createElement("img",{src:t.endUser.avatarUrl,className:"userflow-debugger-user__image"}):e.createElement("div",{className:"userflow-debugger-user__image"}),e.createElement("span",{className:"userflow-debugger-user__name"},t.endUser?.name||"Unknown name"),e.createElement("span",{className:"userflow-debugger-user__email"},t?.endUser?.email||"Unknown email address"),(!t.endUser.email||!t.endUser.name)&&e.createElement("span",{className:"userflow-debugger__external__id"},t.endUser.externalId)),!t.endUser.debuggerEnabled&&e.createElement(e.Fragment,null,e.createElement("div",{className:"userflow-debugger-user__info"},"This user doesn't have access to the Userflow debugger. You can grant access through the debugger settings in Userflow."),e.createElement("a",{className:"userflow-debugger-user__button",href:r,target:"_blank",rel:"noreferrer"},"Grant access in Userflow ",e.createElement(u,{icon:ve})))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))});class Un{constructor(n,s){this.client=n,this.buildId=s,this.debuggerClientConditions=new Map}mount(){if(this.container)throw new Error("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-debugger-ui",document.body.appendChild(this.container),ce.render(e.createElement(cn,{client:this.client,debuggerClientConditions:this.debuggerClientConditions,buildId:this.buildId,unmount:()=>this.unmount()}),this.container)}unmount(){this.container&&(ce.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),this.client.unMountDebugger(),delete this.container)}}const cn=({client:t,debuggerClientConditions:n,buildId:s,unmount:r})=>{const[a,o]=i.useState(void 0),l=_e(async()=>{try{const c=await t.send({kind:"GetCurrentEndUser"},{handlesRejection:!0});o(c)}catch(c){c.code==="debugger_access_denied"&&te("debugger access denied"),o(void 0)}},300);return i.useEffect(()=>(l(),document.addEventListener("visibilitychange",l),t.on("private:identified",l),()=>{document.removeEventListener("visibilitychange",l),t.off("private:identified",l)}),[]),e.createElement(Pe.Provider,{value:t},e.createElement(Ne.Provider,{value:{meta:a,debuggerClientConditions:n,buildId:s}},e.createElement(ft,null,e.createElement(rn,{close:r}))))};export{Un as DebuggerUI};
2
+ import{r as i,R as e}from"./vendor.react.js";import{r as ce}from"./vendor.react-dom.js";import{u as P,U as Pe}from"./client-context.js";import{d as te,w as B,x as A,y as D,z as O,k as d,C as ue,l as y,W as T,D as U,G as Re,H as Ue,_ as Ae,S as ke}from"./userflow.js";import{F as Me}from"./Frame.js";import{S as Ve}from"./logomark.js";import{e as ne,y as Be,z as k,A as re,B as He,k as qe,C as fe,D as F,E as Ge,F as Ee,G as he,H as We,I as ze,a as I,J as be,K as je,L as Ye,M as Xe,N as Ke,O as $e,P as Ze,Q as L,s as ve,p as M,R as Qe,S as Je,T as et,U as tt,f as nt,V as rt,W as st,X as $,Y as at,Z as ot,_ as lt,$ as it}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{n as ct,o as ut}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as u}from"./stylesheets.js";import{o as g}from"./vendor.obj-str.js";import"./vendor.object-assign.js";import{u as J,d as _e}from"./vendor.lodash.js";import{p as mt,f as se,d as dt}from"./vendor.date-fns.js";import{a as z}from"./react-hooks.js";import{P as we}from"./Popover.js";import{m as pt}from"./vendor.memoize-one.js";import{h as gt}from"./roots.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./iframe-reset.styl.js";import"./flow-condition-types.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="4b187082-d5a0-4977-a80f-b39b31249dbb",t._sentryDebugIdIdentifier="sentry-dbid-4b187082-d5a0-4977-a80f-b39b31249dbb")}catch{}})();const ft=new URL("debugger.css",import.meta.url).href,Ce=i.createContext(void 0),S=()=>i.useContext(Ce),ye=i.createContext(null),ae=()=>i.useContext(ye),Ne=i.createContext({debuggerClientConditions:new Map,meta:void 0,buildId:void 0}),V=()=>i.useContext(Ne),H={verifySetup:{name:"Verify setup",icon:k},checkAutoStart:{name:"Check auto-start",icon:Be},currentUser:{name:"Current user",icon:ne}},xe=i.createContext(void 0),Et=({children:t})=>{const n=P(),[s,r]=i.useState(n.getSessionStorageState().debuggerApp?.selectedTab??"verifySetup");return i.useEffect(()=>{n.setSessionStorageState(a=>!a.debuggerApp||!a.debuggerApp.x?a:{...a,debuggerApp:{...a.debuggerApp,selectedTab:s}}),te("Debugger Route changed to",s)},[s]),e.createElement(xe.Provider,{value:{debuggerRoute:s,setDebuggerRoute:r}},t)},oe=()=>{const t=i.useContext(xe);if(t===void 0)throw new Error("useDebuggerRouteHandler must be used within a DebuggerRouteProvider");return{debuggerRoute:t.debuggerRoute,setDebuggerRoute:t.setDebuggerRoute}},ht=t=>{const n=i.useRef(null),s=ae();return i.useEffect(()=>{const r=s?.current,a=o=>{n.current&&!n.current.contains(o.target)&&t(o)};return document.addEventListener("mousedown",a),r?.contentDocument?.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a),r?.contentDocument?.removeEventListener("mousedown",a)}},[t,s,n]),n},bt=()=>e.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M18.4393 5.56066C18.158 5.27936 18 4.89782 18 4.5C18 4.10218 18.158 3.72064 18.4393 3.43934C18.7206 3.15804 19.1022 3 19.5 3C19.8978 3 20.2794 3.15804 20.5607 3.43934C20.842 3.72064 21 4.10218 21 4.5C21 4.89782 20.842 5.27936 20.5607 5.56066C20.2794 5.84196 19.8978 6 19.5 6C19.1022 6 18.7206 5.84196 18.4393 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 5.56066C3.15804 5.27936 3 4.89782 3 4.5C3 4.10218 3.15804 3.72064 3.43934 3.43934C3.72064 3.15804 4.10218 3 4.5 3C4.89782 3 5.27936 3.15804 5.56066 3.43934C5.84196 3.72064 6 4.10218 6 4.5C6 4.89782 5.84196 5.27936 5.56066 5.56066C5.27936 5.84196 4.89782 6 4.5 6C4.10218 6 3.72064 5.84196 3.43934 5.56066Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 13.0607C10.658 12.7794 10.5 12.3978 10.5 12C10.5 11.6022 10.658 11.2206 10.9393 10.9393C11.2206 10.658 11.6022 10.5 12 10.5C12.3978 10.5 12.7794 10.658 13.0607 10.9393C13.342 11.2206 13.5 11.6022 13.5 12C13.5 12.3978 13.342 12.7794 13.0607 13.0607C12.7794 13.342 12.3978 13.5 12 13.5C11.6022 13.5 11.2206 13.342 10.9393 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 20.5607C3.15804 20.2794 3 19.8978 3 19.5C3 19.1022 3.15804 18.7206 3.43934 18.4393C3.72064 18.158 4.10218 18 4.5 18C4.89782 18 5.27936 18.158 5.56066 18.4393C5.84196 18.7206 6 19.1022 6 19.5C6 19.8978 5.84196 20.2794 5.56066 20.5607C5.27936 20.842 4.89782 21 4.5 21C4.10218 21 3.72064 20.842 3.43934 20.5607Z",fill:"#537388"}),e.createElement("path",{d:"M3.43934 13.0607C3.15804 12.7794 3 12.3978 3 12C3 11.6022 3.15804 11.2206 3.43934 10.9393C3.72064 10.658 4.10218 10.5 4.5 10.5C4.89782 10.5 5.27936 10.658 5.56066 10.9393C5.84196 11.2206 6 11.6022 6 12C6 12.3978 5.84196 12.7794 5.56066 13.0607C5.27936 13.342 4.89782 13.5 4.5 13.5C4.10218 13.5 3.72064 13.342 3.43934 13.0607Z",fill:"#537388"}),e.createElement("path",{d:"M10.9393 5.56066C10.658 5.27936 10.5 4.89782 10.5 4.5C10.5 4.10218 10.658 3.72064 10.9393 3.43934C11.2206 3.15804 11.6022 3 12 3C12.3978 3 12.7794 3.15804 13.0607 3.43934C13.342 3.72064 13.5 4.10218 13.5 4.5C13.5 4.89782 13.342 5.27936 13.0607 5.56066C12.7794 5.84196 12.3978 6 12 6C11.6022 6 11.2206 5.84196 10.9393 5.56066Z",fill:"#537388"})),vt={prefix:"far",iconName:"custom-hand-pointer-slash",icon:[641,512,[],"???","M185.554191,59.5126699 C189.248662,26.0794907 217.382589,0 251.429,0 C287.979,0 317.715,30.056 317.715,67 L317.715,140.634 C338.128,137.776 359.183,144.576 374.31,160.263 C401.503,147.416 434.689,154.593 454.182,179.361 C497.375,162.727 544,195.156 544,242 L544,326 C544,330.296189 543.590626,334.580726 542.780274,338.796073 L495.999,302.221942 L495.999,242 C495.999,216.84 459.428,216.879 459.428,242 C459.428,250.836 452.265,258 443.428,258 L439.435556,258 L420.622383,243.291649 C420.588346,242.865584 420.571,242.434817 420.571,242 L420.571,221 C420.571,197.943344 389.858993,196.049429 384.724023,215.225903 L269.713,125.308981 L269.713,67 C269.713,41.84 233.142,41.88 233.142,67 L233.142,96.717359 L185.554191,59.5126699 Z M162.172457,223.995642 L233.142,279.479508 L233.142,308.493 C233.142,324.063 213.106,330.402 204.111,317.776 L176.985,279.697 C162.585,259.485 133.185,282.08 147.591,302.303 L257.303,456.303 C260.737,461.122 266.231,464 272,464 L450.285,464 C455.041109,464 459.427079,462.119816 462.713129,458.957818 L500.616335,488.590478 C488.331086,503.061811 470.146238,512 450.286,512 L272,512 C250.741,512 230.632,501.59 218.209,484.154 L108.51,330.153 C87.267,300.334 93.705,258.796 123.06,237.001 C134.952446,228.171597 148.664261,223.998532 162.172457,223.995642 Z M272.143,309.970422 L306.143,336.551563 L306.143,400 C306.143,408.837 299.875,416 292.143,416 L286.143,416 C278.41,416 272.143,408.837 272.143,400 L272.143,309.970422 Z M347.571,368.939901 L381.571,395.521042 L381.571,400 C381.571,408.837 375.303,416 367.571,416 L361.571,416 C353.839,416 347.571,408.837 347.571,400 L347.571,368.939901 Z M633.994211,471.020009 C640.904211,476.540009 642.014211,486.610009 636.494211,493.510009 L626.494211,506 C620.964211,512.890009 610.904211,514.010009 604.004211,508.490009 L6.00421069,40.9800088 C-0.895789309,35.4600088 -2.01578931,25.3900088 3.51421069,18.4900088 L13.5142107,6 C19.0342107,-0.899991212 29.1042107,-2.00999121 36.0042107,3.51000879 L633.994211,471.020009 Z"]},_t={CLICK:Ee,DISABLED:F,MOUSEDOWN:Ge,NOT_CLICK:vt,NOT_DISABLED:k,NOT_PRESENT:fe,PRESENT:re},wt={COMPLETED:k,NOT_COMPLETED:F,NOT_SEEN:fe,ACTIVE:qe,NOT_ACTIVE:He,SEEN:re},Ct={CLICK:"is clicked",DISABLED:"is disabled",MOUSEDOWN:"has mouse down on it",NOT_CLICK:"is not clicked",NOT_DISABLED:"is not disabled",NOT_PRESENT:"is not present",PRESENT:"is present"};function yt(t){return Ct[t]}const Nt={COMPLETED:"completed",NOT_COMPLETED:"not completed",NOT_SEEN:"not seen",ACTIVE:"is currently active",NOT_ACTIVE:"is not currently active",SEEN:"seen"};function xt(t){return Nt[t]}function St(t,n){let s=(n||"").toLowerCase();return(t.eventTimeOperator===D.RELATIVE_BETWEEN?t.eventRelativeValue2:t.eventRelativeValue)!==1&&(s+="s"),t.eventTimeOperator!==D.RELATIVE_GT&&(s+=" ago"),s}function Tt(t){return(t.eventFrequencyOperator===A.BETWEEN?t.eventFrequencyValue2:t.eventFrequencyValue)===1?"time":"times"}const Ot={CURRENT_USER:"by current user in any company",CURRENT_USER_CURRENT_GROUP:"by current user in current company",CURRENT_GROUP:"by any user in current company"};function Dt(t){return Ot[t]}function It(t){if(!t)return"";switch(t){case A.BETWEEN:return"between";case A.EQ:return"exactly";case A.GTE:return"at least";case A.LTE:return"at most"}}function Ft(t){if(!t)return"";switch(t){case D.ANY:return"at any point in time";case D.RELATIVE_BETWEEN:return"between";case D.RELATIVE_GT:return"in the last";case D.RELATIVE_LT:return"more than"}}const Lt={1:"Lowest",2:"Low",3:"Medium",4:"High",5:"Highest"};function Pt(t){return`${Lt[t]||String(t)} priority`}function ee(t,n){switch(t){case B.DAY:return n===1?"day":"days";case B.HOUR:return n===1?"hour":"hours";case B.MINUTE:return n===1?"minute":"minutes";case B.SECOND:return n===1?"second":"seconds"}}function me(t){switch(t){case"USER":return ne;case"GROUP":return ze;case"GROUP_MEMBERSHIP":return We;case"EVENT":return he}}function Rt(t){const n=t.split("/");if(n.length===1)return["USER",t];switch(n[0]){case"group":return["GROUP",n[1]];case"group_membership":return["GROUP_MEMBERSHIP",n[1]];case"event":return["EVENT",n[1]]}return console.warn("parseAttributeDefinitionFqn: Invalid attribute definition FQN",t),["USER",t]}const Ut={[O.BANNER]:"banner",[O.CHECKLIST]:"checklist",[O.FLOW]:"flow",[O.EMBED]:"embed",[O.LAUNCHER]:"launcher",[O.RESOURCE_CENTER]:"resource center",[O.WORKFLOW]:"action flows"};function At(t,{title:n,plural:s}={}){let r=Ut[t];return n&&(r=J(r)),s&&(r+="s"),r}const kt="d MMM yyyy",Mt=Intl.DateTimeFormat(Intl.DateTimeFormat().resolvedOptions().locale,{hour:"numeric"}).resolvedOptions().hourCycle==="h12";function de(t){if(t==null)return"";const n=Mt?t.getMinutes()===0?"h aaa":"h:mm aaa":"HH:mm";return se(t,kt+", "+n)}function Vt(t){if(!t)return null;const n=dt(t,"yyyy-MM-dd",new Date);return isNaN(n.valueOf())?null:n}function pe(t){if(!t)return null;const n=mt(t);return isNaN(n.valueOf())?null:n}var Se=(t=>(t.EVENT="EVENT",t.GROUP="GROUP",t.GROUP_MEMBERSHIP="GROUP_MEMBERSHIP",t.USER="USER",t))(Se||{});function ge(t){return({condition:n})=>{throw new Error(`conditionOperators.${n.operator}.${t} is not supported`)}}const q={[d.ABSOLUTE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"on")," ",e.createElement("span",{className:"nowrap text-bold"},Q(t.value)))},[d.ABSOLUTE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"after")," ",e.createElement("span",{className:"nowrap text-bold"},Q(t.value)))},[d.ABSOLUTE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"before")," ",e.createElement("span",{className:"nowrap text-bold"},Q(t.value)))},[d.AND]:{Preview:ge("Preview")},[d.BETWEEN]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is between")," ",e.createElement("b",null,t.value)," ",e.createElement("span",{className:"text-secondary"},"and")," ",e.createElement("b",null,t.value2))},[d.CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"contains")," ",e.createElement("b",null,t.value))},[d.EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is empty")},[d.ENDS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"ends with")," ",e.createElement("b",null,t.value))},[d.EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is")," ",e.createElement("b",null,t.dataType===ue.FLOW&&t.value?e.createElement("span",null,t?.eventDisplayName??t.eventName):t.value))},[d.EXCLUDES_ALL]:{Preview:({condition:t})=>G(t,"does not include","all of")},[d.EXCLUDES_ANY]:{Preview:({condition:t})=>G(t,"does not include","at least one of")},[d.FALSE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is false")},[d.GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than")," ",e.createElement("b",null,t.value))},[d.GTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is greater than or equal to")," ",e.createElement("b",null,t.value))},[d.INCLUDES_ALL]:{Preview:({condition:t})=>G(t,"includes","all of")},[d.INCLUDES_ANY]:{Preview:({condition:t})=>G(t,"includes","at least one of")},[d.LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than")," ",e.createElement("b",null,t.value))},[d.LTE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is less than or equal to")," ",e.createElement("b",null,t.value))},[d.NE]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"is not")," ",e.createElement("b",null,t.dataType===ue.FLOW&&t.value?e.createElement("span",null," ",t?.eventDisplayName??t.eventName):t.value))},[d.NOT_CONTAINS]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not contain")," ",e.createElement("b",null,t.value))},[d.NOT_EMPTY]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"has any value")},[d.NOT_REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",e.createElement("b",null,t.value))},[d.OR]:{Preview:ge("Preview")},[d.REGEX]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",e.createElement("b",null,t.value))},[d.RELATIVE_EQ]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"exactly")," ",e.createElement("span",{className:"nowrap text-bold"},Z(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.RELATIVE_GT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"less than")," ",e.createElement("span",{className:"nowrap text-bold"},Z(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.RELATIVE_LT]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"more than")," ",e.createElement("span",{className:"nowrap text-bold"},Z(t.value))," ",e.createElement("span",{className:"text-secondary"},"ago"))},[d.STARTS_WITH]:{Preview:({condition:t})=>e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"starts with")," ",e.createElement("b",null,t.value))},[d.TRUE]:{Preview:()=>e.createElement("span",{className:"text-secondary"},"is true")},[d.URL]:{Preview:({condition:t})=>{const{urlPattern:n}=t;if(!n)return e.createElement("span",{className:"text-secondary"},"matches ...");const{includes:s,excludes:r}=n;return e.createElement(e.Fragment,null,s.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"matches")," ",s.map((a,o)=>e.createElement(e.Fragment,{key:o},o>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,a)))),s.length>0&&r.length>0&&e.createElement("span",{className:"text-secondary"}," and "),r.length>0&&e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},"does not match")," ",r.map((a,o)=>e.createElement(e.Fragment,{key:o},o>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",null,a)))))}}};function Bt(t){return parseInt(t,10)}function Z(t){if(!t)return"days";const n=Bt(t);return isNaN(n)?"days":n+" "+(n===1?"day":"days")}function Q(t){if(!t)return"";const n=Vt(t);return n?se(n,"PP"):""}function G(t,n,s){const r=t.values||[];return e.createElement(e.Fragment,null,e.createElement("span",{className:"text-secondary"},n+(r.length>1?" "+s:""))," ",r.map((a,o)=>e.createElement(e.Fragment,{key:o},o>0&&e.createElement("span",{className:"text-secondary"},", "),e.createElement("b",{key:o},a))))}const le=t=>({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":t===!0,"userflow-debugger-condition__item__danger":t===!1,"userflow-debugger-condition__item__intermediate":t===null}),ie=t=>t===!0?I:t===!1?F:L,Te=(t,n)=>{const s=S();return i.useMemo(()=>{const o=(n?s?.hiddenCondition?.breakdown:s?.startCondition?.breakdown)?.find(l=>l.conditionId===t.id);return{classes:le(o?.match),icon:ie(o?.match)}},[t,s,n])},W=t=>{const{condition:n,isHideCond:s}=t,{classes:r,icon:a}=Te(n,s),o=n.type;if(o===y.CLAUSE)return e.createElement(qt,{...t});const l=De[o];return e.createElement("div",{className:g(r)},e.createElement("span",{className:"d-flex gap-8 align-center userflow-debugger-condition__item__icon"},l.icon?e.createElement(u,{icon:l.icon({condition:n})}):null,e.createElement(l.Preview,{...t})),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:a}))},Ht=()=>{const t=S(),[n,s]=i.useState(!1),r=i.useMemo(()=>t?.hiddenCondition?.breakdown.find(o=>o.conditionId===t?.hiddenCondition?.condition.id),[t?.hiddenCondition]);return t?.hiddenCondition?.condition?e.createElement("div",{role:"button",className:g({"d-flex gap-8 flex-column margin-8":!0,"userflow-debugger-condition__clause":!0,"userflow-debugger-hide-condition__clause__success":r?.match===!0,"userflow-debugger-hide-condition__clause__danger":r?.match===!1,"userflow-debugger-hide-condition__clause__expanded":n}),onClick:a=>{s(!n),a.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between align-center"},e.createElement("span",null,"Termporarily hide flow"," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",n?"collapse":"expand")),e.createElement(u,{icon:M})),n&&e.createElement(W,{isRoot:!0,isHideCond:!0,condition:t?.hiddenCondition?.condition})):null},qt=({condition:t,isRoot:n=!1,isHideCond:s=!1})=>{const[r,a]=i.useState(!1),{classes:o,icon:l}=Te(t,s);return n?e.createElement(e.Fragment,null,t.conditions.map((c,p)=>e.createElement(W,{isHideCond:s,key:p,condition:c}))):e.createElement("div",{role:"button",className:g({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__clause":r,...r?{"userflow-debugger-condition__item__success__expanded":o["userflow-debugger-condition__item__success"],"userflow-debugger-condition__item__danger__expanded":o["userflow-debugger-condition__item__danger"],"userflow-debugger-condition__item__intermediate__expanded":o["userflow-debugger-condition__item__intermediate"]}:o}),onClick:c=>{a(!r),c.stopPropagation()}},e.createElement("div",{className:"d-flex justify-space-between align-center w-full"},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:Je})," ",e.createElement("strong",null,"Logic Group")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to ",r?"collapse":"expand")),!r&&e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:l})),r&&e.createElement(e.Fragment,null,t.conditions.map((c,p)=>e.createElement("div",{key:p,className:g({"userflow-debugger-condition__clause__operator__wrapper":!0})},p>0&&e.createElement("div",{className:g({"userflow-debugger-condition__clause__operator":!0})},e.createElement(Oe,{condition:t})),e.createElement(W,{isHideCond:s,condition:c})))))},Oe=({condition:t})=>{const n=t.operator;return n?e.createElement("span",{className:g({"userflow-debugger-condition__item__operator":!0,"userflow-debugger-condition__item__operator__and":n===d.AND,"userflow-debugger-condition__item__operator__or":n===d.OR})},n===d.AND&&"AND",n===d.OR&&"OR"):null},Gt={[T.NONE]:F,[T.PENDING_SCHEDULE]:F,[T.SCHEDULED]:L,[T.FIRED]:I},Wt=e.memo(()=>{const t=S(),{waitTimer:n}=t||{},s=t?.startCondition?.condition.waitTime,{ref:r,hovered:a,eventHandlers:o}=z();return!s||!n||n===T.NONE?null:e.createElement("div",{ref:r,...o,className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":n===T.PENDING_SCHEDULE,"userflow-debugger-condition__item__intermediate":n===T.SCHEDULED,"userflow-debugger-condition__item__success":n===T.FIRED})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:Ze}),e.createElement("span",null,"Wait ",e.createElement("strong",null,s)," seconds")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:Gt[n]}),e.createElement(j,{target:r,hovered:a&&n===T.PENDING_SCHEDULE},"Timer activates once all conditions are satisfied"))}),zt=e.memo(()=>{const t=S(),[n,s]=i.useState(!1),{startFrequency:r,listFlowLatestVersion:a}=t||{startFrequency:{}};if(!r||!a?.startFrequency||a?.startFrequency===U.NEVER)return null;const{currentFlowIntervalThrottle:o,frequency:l,frequencyUsage:c}=r,p=ie(l),_=le(l);if(a.startFrequency===U.ONCE||a.startFrequency===U.ONCE_PER_GROUP)return e.createElement("div",{className:g(_)},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:be}),e.createElement("strong",null,"Once per user"," ",a.startFrequency===U.ONCE_PER_GROUP&&"per company")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:p}));if(a.startFrequency===U.ALWAYS&&a.startIntervalValue&&a.startIntervalUnit)return e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":o===!0,"userflow-debugger-condition__item__intermediate":o===!1})},e.createElement("span",null,"Every ",e.createElement("strong",null,a.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},ee(a.startIntervalUnit,a.startIntervalValue)," ","apart")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:o===!1?L:I}));if(a.startFrequency===U.MULTIPLE){const E=l===!0&&o===!0,h=l===!0&&o===!1,N=l===!1;return e.createElement("div",{className:g({"d-flex flex-column gap-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__clause":n,...n?{"userflow-debugger-condition-frequency__success__expanded":E,"userflow-debugger-condition-frequency__intermediate__expanded":h,"userflow-debugger-condition-frequency__danger__expanded":N}:{"userflow-debugger-condition-frequency__success":E,"userflow-debugger-condition-frequency__intermediate":h,"userflow-debugger-condition-frequency__danger":N}}),onClick:x=>{s(!n),x.stopPropagation()}},e.createElement("div",{className:"d-flex gap-8 justify-space-between"},e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement("strong",null,"Start multiple times")," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to expand")),!n&&e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:E?I:h?L:F})),n&&e.createElement(e.Fragment,null,e.createElement("div",{className:g(_)},e.createElement("span",null,e.createElement("strong",null,a.startLimit)," ",e.createElement("span",{className:"userflow-debugger-info-text"},"(started ",c," times)")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:p})),a.startIntervalUnit&&a.startIntervalValue&&e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":o===!0,"userflow-debugger-condition__item__intermediate":o===!1})},e.createElement("span",null,e.createElement("strong",null,a.startIntervalValue)," ",e.createElement("span",{className:"userflow-debugger-info-text"},ee(a.startIntervalUnit,a.startIntervalValue)," ","apart")),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:o===!1?L:I}))))}return null}),jt=()=>{const t=S(),{priority:n}=t||{};return n?.priority?e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__priority":!0})},e.createElement("span",null,e.createElement("strong",null,Pt(n?.priority))," ",e.createElement("span",{className:"userflow-debugger-info-text"},"Click to learn more")),e.createElement("a",{href:"https://docs.userflow.com/docs/trouble/using-the-debugger#flow-trigger-precedence",target:"_blank",rel:"noreferrer noopener"},e.createElement(u,{icon:ve}))):null},Yt=()=>{const t=S(),{startFrequency:n}=t||{},{onlyIfNotCompleted:s}=n||{};return s==null?null:e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":s===!0,"userflow-debugger-condition__item__danger":s===!1})},"Only if not completed",e.createElement(u,{icon:s===!0?I:F}))},Xt=()=>{const t=S(),{startFrequency:n}=t||{},{hovered:s,eventHandlers:r,ref:a}=z();return!n||n?.scopeByGroup===null||n.scopeByGroup===void 0||n.scopeByGroup===!0?null:e.createElement("div",{ref:a,...r,className:g({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__danger":!0})},"Constrain to current company",e.createElement(u,{icon:ie(n.scopeByGroup)}),e.createElement(j,{target:a,hovered:s},"User is not associated with a company"))},Kt=()=>{const t=S(),{startFrequency:n,listFlowLatestVersion:s}=t||{},{anyFlowIntervalThrottle:r}=n||{},{throttleUnit:a,throttleValue:o}=s||{};return r===null||a===null||o===null||a===void 0||o===void 0?null:e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__success":r===!0,"userflow-debugger-condition__item__intermediate":r===!1})},e.createElement("span",null,"Atleast ",e.createElement("strong",null,s?.throttleValue)," ",ee(a,o)," after any flow"),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:r===!0?I:L}))},$t=e.memo(()=>{const{hovered:t,eventHandlers:n,ref:s}=z(),r=S(),{snoozed:a}=r||{},o=i.useMemo(()=>{if(a?.until)return se(new Date(a.until),"MMM do, h:mm a")},[a?.until]);return a?e.createElement("div",{ref:s,...n,className:g({"d-flex align-center margin-8":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__item__intermediate":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:Qe}),e.createElement("span",null,"This flow is currently ",e.createElement("strong",null,"snoozed"))),e.createElement(u,{dataAttrs:{"data-condition-status":"true"},icon:L}),e.createElement(j,{target:s,hovered:t},"Snoozed until ",o)):null}),De={[y.PAGE]:{icon:()=>$e,Preview:({condition:t})=>{const n=t.operator&&q[t.operator];return e.createElement("span",null,"URL"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[y.SCREEN]:{icon:()=>Ke,Preview:({condition:t})=>{const n=t.operator&&q[t.operator];return e.createElement("span",null,"Screen"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[y.ATTRIBUTE]:{icon:({condition:t})=>{if(!t||!t.attributeName)return me(Se.EVENT);const[n]=Rt(t.attributeName);return me(n)},Preview:({condition:t})=>{const n=t.operator&&q[t.operator];return e.createElement("span",null,e.createElement("strong",null,t.attributeDisplayName?t.attributeDisplayName:"Attribute")," ",e.createElement("span",{className:"userflow-debugger-info-text"},n&&e.createElement(n.Preview,{condition:t})))}},[y.SEGMENT]:{icon:()=>Xe,Preview:({condition:t})=>{const{segment:n}=t;return e.createElement("span",null,e.createElement("strong",null,n?.subjectType===Ue.GROUP?"Company":"User")," ",e.createElement("span",{className:"text-secondary"},t.operator===d.FALSE?"is not in":"is in")," ",e.createElement("strong",null,n?.name||"Segment"))}},[y.ELEMENT]:{icon:({condition:t})=>t.elementState?_t[t.elementState]:et,Preview:({condition:t})=>e.createElement("span",null,"Element"," ",t.elementState&&e.createElement("strong",null,yt(t.elementState)))},[y.INPUT_VALUE]:{icon:()=>Ye,Preview:({condition:t})=>{const n=t.operator&&q[t.operator];return e.createElement("span",null,"The value of input"," ",e.createElement("strong",null,n&&e.createElement(n.Preview,{condition:t})))}},[y.FILLED_IN_INPUT]:{icon:()=>je,Preview:()=>e.createElement("span",null,"User fills an input")},[y.FLOW]:{icon:({condition:t})=>t.flowState?wt[t.flowState]:re,Preview:({condition:t})=>t.flow?.type===O.SITE?null:e.createElement("span",null,t.flow?e.createElement(e.Fragment,null,At(t.flow.type,{title:!0})," ",e.createElement("strong",null,t.flow.name)):"Flow/checklist"," ",t.flowState&&xt(t.flowState))},[y.TIME]:{icon:()=>be,Preview:({condition:t})=>{const n=t.value?pe(t.value):null,s=n&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},de(n)),r=t.value2?pe(t.value2):null,a=r&&e.createElement("strong",{style:{whiteSpace:"nowrap"}},de(r));return s&&a?e.createElement("span",null,"Current time is between ",s," and ",a):s?e.createElement(e.Fragment,null,"Current time is after ",s):a?e.createElement(e.Fragment,null,"Current time is before ",a):e.createElement(e.Fragment,null,"Current time is ...")}},[y.EVENT]:{icon:()=>he,Preview:({condition:t})=>{const{ref:n,hovered:s,eventHandlers:r}=z();return e.createElement("div",{ref:n,...r},e.createElement("strong",null,t.eventDisplayName?t.eventDisplayName:"Event")," ",e.createElement("span",{className:"userflow-debugger-info-text"},It(t.eventFrequencyOperator))," ",e.createElement("strong",null,t.eventFrequencyValue),t.eventFrequencyOperator===A.BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventFrequencyValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},Tt(t),","," ",Ft(t.eventTimeOperator)),t.eventTimeOperator!==D.ANY&&e.createElement(e.Fragment,null," ",e.createElement("strong",null,t.eventRelativeValue),t.eventTimeOperator===D.RELATIVE_BETWEEN&&e.createElement(e.Fragment,null," ",e.createElement("span",{className:"userflow-debugger-info-text"},"and")," ",e.createElement("strong",null,t.eventRelativeValue2))," ",e.createElement("span",{className:"userflow-debugger-info-text"},St(t,t.eventRelativeUnit))),t.eventActor&&t.eventActor!==Re.CURRENT_USER?e.createElement(e.Fragment,null," ",e.createElement("strong",null,Dt(t.eventActor))):"",t.whereCondition&&s&&e.createElement(j,{hovered:!0,target:n},"Where ",e.createElement("br",null),e.createElement(Ie,{condition:t.whereCondition})))}},[y.ALWAYS_TRUE]:{icon:()=>I,Preview:()=>e.createElement("span",null,"Water is wet")},[y.CHECKLIST_TASK_CLICKED]:{icon:()=>Ee,Preview:()=>e.createElement("span",null,"Task is clicked")}},Ie=t=>e.createElement("div",null,t.condition.conditions.map((n,s)=>e.createElement("div",{key:n.id}," ",s===0?null:e.createElement("span",{className:"userflow-debugger-info-text"},t.condition.operator?.toLowerCase())," ",n.type==="ATTRIBUTE"&&De.ATTRIBUTE.Preview({condition:n,isRoot:!0,isHideCond:!1}),n.type==="CLAUSE"&&e.createElement(e.Fragment,null,"(",e.createElement(Ie,{condition:n}),")")))),j=({hovered:t,children:n,target:s})=>{const r=ae();return t?e.createElement(we,{className:"userflow-debugger-popover",target:s.current,placement:"top",horizontalAlign:"center",verticalAlign:"center",document:r?.current?.contentDocument||void 0},n):null};class Zt extends e.PureComponent{constructor(n){super(n),this.rootRef=e.createRef(),this.optionsElRef=e.createRef(),this.input=null,this.popoverRef=e.createRef(),this.isMouseDown=!1,this.isCreateOpen=!1,this.setInput=s=>{this.input=s;const{inputRef:r}=this.props;r&&(typeof r=="function"?r(s):r.current=s)},this.onInputChange=s=>{s.stopPropagation();const{value:r}=s.target;r!==""&&this.openPopover();const a=this.memoizedFilterOptions(this.props.options,r);this.setState({inputValue:r,q:r,highlightedIndex:a.length>0?0:-1,createHighlighted:a.length===0}),r===""&&!this.props.noEmpty&&this.triggerOnChange(null),this.props.onSearchChange&&this.props.onSearchChange(r)},this.onPopoverPlacementChange=s=>this.setState({popoverPlacement:s}),this.onMouseDown=s=>{s.preventDefault(),this.isMouseDown=!0;const r=()=>{this.isMouseDown=!1,this.props.document?.removeEventListener("mouseup",r),document.body.removeEventListener("mouseup",r)};this.props.document?.addEventListener("mouseup",r),document.body.addEventListener("mouseup",r)},this.onFocus=s=>{this.input&&!this.props.noSearch&&this.input.select(),this.props.onFocus&&this.props.onFocus(s)},this.onBlur=s=>{this.isMouseDown||this.closePopover(),this.props.onBlur&&!this.isCreateOpen&&this.props.onBlur(s)},this.onClose=()=>{this.state.popoverOpen&&this.closePopover(),this.props.onClose&&this.props.onClose()},this.onTriggerClick=()=>{this.props.readOnly||this.props.disabled||(this.state.popoverOpen?this.closePopover():(this.input&&this.input.focus(),this.openPopover()))},this.onKeyDown=s=>{const{popoverOpen:r,highlightedIndex:a,createHighlighted:o}=this.state,l=this.getFilteredOptions(),c=l.length-1;switch(s.key){case"ArrowUp":s.preventDefault(),r&&(o?this.setState({highlightedIndex:c,createHighlighted:!1}):a>0&&this.setState({highlightedIndex:a-1}));break;case"ArrowDown":s.preventDefault(),r?this.props.onCreate&&(a===c||o)?this.setState({highlightedIndex:-1,createHighlighted:!0}):a<c&&this.setState({highlightedIndex:a+1}):this.props.noOpenOnDown||this.openPopover();break;case"Enter":if(r)if(s.preventDefault(),o&&!this.props.disableCreate)this.fireOnCreate();else{const p=l[a];p||!this.props.noEmpty?this.selectOption(p):!p&&this.props.hideOnEmpty&&this.props.onEnter&&this.props.onEnter()}else this.props.onEnter?this.props.onEnter():this.openPopover();break;case"Tab":r&&!this.props.ignoreTab&&this.selectOption(l[a]);break;case"Escape":r&&(s.preventDefault(),s.stopPropagation(),this.setState({popoverOpen:!1}));break}},this.selectOption=s=>{const r=s!==this.props.value;this.closePopover(),r&&this.triggerOnChange(s)},this.highlightOption=s=>{this.setState({highlightedIndex:s,createHighlighted:!1})},this.highlightCreate=()=>{this.setState({highlightedIndex:-1,createHighlighted:!0})},this.fireOnCreate=()=>{const{onCreate:s}=this.props;if(s){this.isCreateOpen=!0;const r={q:J(this.state.q),callback:a=>{this.isCreateOpen=!1,a!=null&&this.selectOption(a),this.input&&this.input.focus()}};s(r),this.closePopover()}},this.openPopover=()=>{if(!this.state.popoverOpen){const s=this.getFilteredOptions();let r=0,a=!1;if(s.length===0)r=-1,a=!0;else{const{value:o}=this.props,l=s.findIndex(c=>c===o);l!==-1&&(r=l)}this.setState({popoverOpen:!0,highlightedIndex:r,createHighlighted:a})}},this.memoizedFilterOptions=pt((s,r)=>(s=s||[],r?s.filter(a=>this.filter(a,r)):s)),this.state={inputValue:this.renderOptionText(n.value==null?null:n.value),q:"",popoverOpen:!1,popoverPlacement:null,highlightedIndex:-1,createHighlighted:!1}}componentDidUpdate(n,s){const{value:r}=this.props;if(r!==n.value){const a=this.renderOptionText(r??null);a!==this.state.inputValue&&this.setState({inputValue:a})}s.highlightedIndex!==this.state.highlightedIndex&&this.scrollHighlightedOptionIntoView()}render(){let n,s=!1;const{props:r}=this,a=this.state,o=a.popoverPlacement==="top"?"above":"below";if(a.popoverOpen&&this.rootRef.current){const c=this.getFilteredOptions();if(this.props.hideOnEmpty&&c.length===0)s=!0;else{let p;if(c.length>0){let _=null;p=c.reduce((E,h,N)=>{const x=this.getOptionGroup(h);x&&x!==_&&E.push(e.createElement("div",{key:"group:"+x,className:"combo-box__group-header"},x)),_=x;const m=["combo-box__option"];return N===a.highlightedIndex&&m.push("combo-box__option--highlighted"),this.props.optionClassName&&m.push(this.props.optionClassName),E.push(e.createElement(Qt,{key:this.getOptionKey(h,N),className:m.join(" "),option:h,idx:N,renderOptionText:r.renderOptionText,renderOptionItem:r.renderOptionItem,getOptionIcon:r.getOptionIcon,onClick:this.selectOption,onHover:this.highlightOption})),N<c.length-1&&r.hasSeparatorAfter&&r.hasSeparatorAfter(h)&&E.push(e.createElement("div",{key:"sep-"+N,className:"combo-box__option-sep"})),E},[])}else r.loading?p=e.createElement("div",{className:"combo-box__no-results"},"Loading..."):p=e.createElement("div",{className:"combo-box__no-results"},"No matching ",r.nounPlural||"items");n=e.createElement(we,{ref:this.popoverRef,className:"combo-box-popover"+(r.popoverNotch?"":` combo-box-popover--${o}`),noNotch:!r.popoverNotch,target:this.rootRef.current,forceDimension:!0,matchWidth:!0,minWidth:r.popoverMinWidth,onMouseDown:this.onMouseDown,onPlacementChange:this.onPopoverPlacementChange,document:r.document},e.createElement("div",{ref:this.optionsElRef,className:g({"combo-box__options":!0,"combo-box__options--with-create":!!r.onCreate})},p),r.onCreate&&e.createElement("div",{key:"create",className:g({"combo-box__option":!0,"combo-box__option--create":!0,"combo-box__option--highlighted":a.createHighlighted}),onClick:this.fireOnCreate,onMouseMove:this.highlightCreate},e.createElement("div",{className:"combo-box__create-icon"},e.createElement(u,{icon:tt})),e.createElement("div",{className:"combo-box__create-text"},"Create"," ",a.q===""?"new"+(r.noun?` ${r.noun}`:""):e.createElement("b",null,J(a.inputValue)))))}}const l=["input-group","combo-box"];return a.popoverOpen&&!s&&(l.push("combo-box--open"),r.popoverNotch||l.push(`combo-box--with-popover-${o}`)),r.disabled&&l.push("input-group--disabled"),r.noSearch&&l.push("combo-box--no-search"),r.className&&l.push(r.className),e.createElement(e.Fragment,null,e.createElement("div",{className:l.join(" "),style:{width:r.width?r.width+"px":void 0},ref:this.rootRef,onClick:r.readOnly||r.disabled?void 0:()=>{this.input?.focus(),this.openPopover()}},r.childrenBefore,r.value&&r.getOptionIcon&&e.createElement("div",{className:"combobox__input-icon"},Le(r.value,r.getOptionIcon)),e.createElement("input",{type:"text",className:r.inputClassName,name:r.name,value:a.inputValue,onChange:this.onInputChange,onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onMouseDown:this.openPopover,placeholder:r.placeholder,readOnly:r.readOnly||r.noSearch,disabled:r.disabled,autoComplete:"off",ref:this.setInput,...r.inputHtmlAttributes}),!r.noTrigger&&e.createElement("div",{"data-testid":r.triggerTestId||"combo-box-trigger",className:"input-group__append input-group__trigger",onClick:this.onTriggerClick,onMouseDown:this.onMouseDown},e.createElement(u,{icon:nt})),r.onClose&&e.createElement("div",{className:"input-group__append input-group__trigger",onClick:this.onClose},e.createElement(u,{icon:rt})),r.childrenAfter),n)}scrollHighlightedOptionIntoView(){const n=this.optionsElRef.current;if(this.state.popoverOpen&&n){const s=n.querySelector(".combo-box__option--highlighted");if(s){const r=n.getBoundingClientRect(),a=s.getBoundingClientRect();a.top<r.top?n.scrollTop+=a.top-r.top:a.bottom>r.bottom&&(n.scrollTop+=a.bottom-r.bottom)}}}triggerOnChange(n){const{onChange:s}=this.props;s&&s(n)}closePopover(){this.setState({popoverOpen:!1,inputValue:this.renderOptionText(this.props.value==null?null:this.props.value),q:""})}renderOptionText(n){return n==null?"":Fe(n,this.props.renderOptionText)}getFilteredOptions(){return this.memoizedFilterOptions(this.props.options,this.state.q)}filter(n,s){return this.props.filter?this.props.filter(n,s):this.renderOptionText(n).toLowerCase().includes(s.toLowerCase())}getOptionKey(n,s){return n&&n.id||s}getOptionGroup(n){return this.props.getOptionGroup?this.props.getOptionGroup(n):n&&n.group||null}}class Qt extends e.PureComponent{constructor(){super(...arguments),this.state={isOptionDisabled:!1},this.onClick=()=>{this.state.isOptionDisabled||this.props.onClick(this.props.option)},this.onHover=()=>{this.state.isOptionDisabled||this.props.onHover(this.props.idx)}}componentDidMount(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}componentDidUpdate(){const n=this.props.option!==void 0&&typeof this.props.option=="object"&&this.props.option!==null&&"disabled"in this.props.option&&this.props.option.disabled===!0;this.setState({isOptionDisabled:n})}render(){const{isOptionDisabled:n}=this.state,{props:s}=this;return e.createElement("div",{className:g({[s.className]:!0,"combo-box__option--disabled":n}),onClick:this.onClick,onMouseMove:this.onHover},Jt(s.option,s.renderOptionText,s.renderOptionItem,s.getOptionIcon))}}function Fe(t,n){return n?n(t):typeof t=="string"||typeof t=="number"?t:t?t.name:"?"}function Jt(t,n,s,r){if(s)return s(t);{let a=Fe(t,n);return r?e.createElement("div",{className:"d-flex align-flex-start"},e.createElement("div",{className:"combobox__option-icon"},Le(t,r)),e.createElement("div",{className:"flex-1"},a)):a}}function Le(t,n){const s=n(t);return en(s)?e.createElement(u,{icon:s}):s}function en(t){return gt(t)&&"iconName"in t}const tn=({selectedFlow:t,setSelectedFlow:n,flows:s,debugAutoStartCondition:r})=>{const a=P(),o=ae();i.useEffect(()=>{if(!t)return;r(t.latestVersion);const c=()=>{r(t.latestVersion)};return a.on("private:checkSessionsAck",c),document.addEventListener("visibilitychange",c),()=>{a.off("private:checkSessionsAck",c),document.removeEventListener("visibilitychange",c)}},[t]);const l=i.useCallback(c=>{!c||t?.latestVersion?.id===c.latestVersion.id||n(c)},[t]);return e.createElement(e.Fragment,null,e.createElement("div",{className:"d-flex align-center justify-space-between"},e.createElement("div",{className:"d-flex justify-space-between align-center"},"Select Flow"),e.createElement(Zt,{className:"userflow-debugger__flow__selector",value:t,options:s,placeholder:"Select flow",document:o?.current?.contentDocument||void 0,onChange:l,renderOptionItem:c=>c.name})),e.createElement(nn,{selectedFlow:t,selectedFlowVersionsId:t?.latestVersion?.id}))},nn=({selectedFlowVersionsId:t,selectedFlow:n})=>{const s=P(),[r,a]=i.useState(!1),o=S(),l=o&&o?.activeFlow?.id===n?.id;return i.useEffect(()=>(a(!1),s.on("private:setFlowSession",c=>{a(c===t)}),()=>{s.off("private:setFlowSession",()=>a(!1))}),[t]),i.useEffect(()=>{l||a(!1)},[l]),o?.activeFlow===null?null:e.createElement(e.Fragment,null,o?.locale?.match===!1&&e.createElement("div",{className:g(le(!1))},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:F}),e.createElement("span",null,"The flow will not auto start ",e.createElement("br",null)," ",e.createElement("b",null,"User locale (",o?.locale?.code,") is not enabled.")))),r?e.createElement("div",{className:g({"d-flex align-center fade-in":!0,"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(u,{icon:M}),e.createElement("span",null,"This flow ",e.createElement("strong",null,"just")," started"))):null,l&&!r&&e.createElement("div",{className:g({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex align-center gap-8"},e.createElement(u,{icon:M}),e.createElement("span",null,"This flow is currently active"))),!l&&o&&e.createElement("div",{className:g({"userflow-debugger-condition__item":!0,"userflow-debugger-condition__flow__status":!0})},e.createElement("span",{className:"d-flex gap-8 align-center"},e.createElement(u,{icon:M,size:16}),e.createElement("span",null,"Another flow is currently active"))))},rn=t=>{const[n,s]=i.useState(document.visibilityState==="visible"),r=i.useRef(t);return i.useEffect(()=>{r.current=t},[t]),i.useEffect(()=>{const a=()=>{const o=document.visibilityState==="visible";s(o),r.current?.(o)};return document.addEventListener("visibilitychange",a),()=>{document.removeEventListener("visibilitychange",a)}},[]),n},sn=({close:t})=>{const n=P(),s=i.useRef(null),[r,a]=i.useState(!!n.clientToken),[o,l]=i.useState(()=>{const f=n.getSessionStorageState(),v=f?.debuggerApp?.x,C=f?.debuggerApp?.y||50;return{x:v??(document.body.clientWidth?Number(document.body.clientWidth)-450:50),y:C}}),[c,p]=i.useState(!1),_=i.useRef(null),{meta:E}=V(),{debuggerRoute:h}=oe(),[N,x]=i.useState(!1),m=i.useRef(null),w=i.useRef({mouseX:0,mouseY:0,elementX:0,elementY:0});i.useEffect(()=>{o&&n.setSessionStorageState(f=>({...f,debuggerApp:{...f.debuggerApp,x:o.x,y:o.y}}))},[o]),i.useEffect(()=>{if(!c)return;const f=C=>{const R=C.clientX-w.current.mouseX,Y=C.clientY-w.current.mouseY,X=Math.min(w.current.elementX+R,window.document.body.clientWidth-200),K=Math.max(w.current.elementY+Y,0);m.current||(m.current=requestAnimationFrame(()=>{l({x:X,y:K}),m.current=null}))},v=()=>{p(!1)};return document.addEventListener("mousemove",f),document.addEventListener("mouseup",v),()=>{document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",v),m.current&&(cancelAnimationFrame(m.current),m.current=null)}},[c,o]),i.useEffect(()=>{const f=()=>{l(C=>{const R=document.body.clientWidth-500,Y=document.body.clientHeight-100,X=Math.max(Math.min(C.x,R),0),K=Math.max(Math.min(C.y,Y),0);return{x:X,y:K}})},v=()=>{a(!!n.clientToken)};return window.addEventListener("resize",f),n.on("private:initialised",v),()=>{window.removeEventListener("resize",f),n.off("private:initialised",v)}},[]);const b=f=>{s.current&&(p(!0),f.preventDefault())};return e.createElement("div",{ref:s,style:{left:"0",top:"0",position:"absolute",willChange:"transform",transform:`translate3d(${o.x}px, ${o.y}px, 0)`,zIndex:1234620}},e.createElement("div",{onMouseDown:b,style:{height:"50px",cursor:"move",userSelect:"none",position:"absolute",width:"50px"}}),e.createElement(Me,{title:"Debugger",stylesheet:ft,style:{borderRadius:"8px",width:"400px",height:h==="checkAutoStart"?"600px":r?"500px":"400px"},elRef:_,onStylesheetsLoad:x},e.createElement(ye.Provider,{value:_},e.createElement("div",{className:"d-flex flex-column userflow-debugger-app",style:{visibility:N?"visible":"hidden"}},e.createElement("div",{className:"d-flex justify-space-between userflow-debugger-app__header"},e.createElement(bt,null),e.createElement("div",{className:"d-flex align-center userflow-debugger-app__title"},e.createElement(Ve,null),e.createElement("span",null,"Userflow debugger")),e.createElement("button",{role:"button",className:"userflow-debugger-app__close",onClick:()=>{n.getSessionStorageState().debuggerApp&&n.setSessionStorageState(f=>({...f,debuggerApp:null})),t()}},e.createElement("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e.createElement("path",{d:"M12.1836 4.49609L8.90234 7.77734L12.1562 11.0312C12.4297 11.2773 12.4297 11.6875 12.1562 11.9336C11.9102 12.207 11.5 12.207 11.2539 11.9336L7.97266 8.67969L4.71875 11.9336C4.47266 12.207 4.0625 12.207 3.81641 11.9336C3.54297 11.6875 3.54297 11.2773 3.81641 11.0039L7.07031 7.75L3.81641 4.49609C3.54297 4.25 3.54297 3.83984 3.81641 3.56641C4.0625 3.32031 4.47266 3.32031 4.74609 3.56641L8 6.84766L11.2539 3.59375C11.5 3.32031 11.9102 3.32031 12.1836 3.59375C12.4297 3.83984 12.4297 4.25 12.1836 4.49609Z",fill:"white"})))),e.createElement(an,null),h==="verifySetup"&&e.createElement(on,null),E?.endUser?.debuggerEnabled&&h==="checkAutoStart"&&e.createElement(ln,null),h==="currentUser"&&e.createElement(cn,null)))))},an=()=>{const t=P(),{meta:n}=V(),[s,r]=i.useState(!1),{debuggerRoute:a,setDebuggerRoute:o}=oe(),l=t.isIdentified(),c=ht(()=>r(!1));return i.useEffect(()=>{n&&n?.endUser.debuggerEnabled===!1&&a==="checkAutoStart"&&o("verifySetup")},[n]),l?e.createElement("div",{ref:c},e.createElement("div",{className:"d-flex align-center justify-space-between userflow-debugger-menu",onClick:()=>r(!s)},e.createElement("div",{className:g({"d-flex align-center":!0,"userflow-debugger-menu__title":!0,"userflow-debugger-menu__title--open":s})},e.createElement(u,{icon:H[a].icon}),e.createElement("span",null,H[a].name)),e.createElement("button",{className:"userflow-debugger-menu__toggle"},e.createElement(u,{icon:st}))),s&&e.createElement("ul",{className:"userflow-debugger-menu__list"},Object.keys(H).map(p=>{if(!n?.endUser?.debuggerEnabled&&p==="checkAutoStart")return null;const _=H[p];return e.createElement("li",{key:p,className:"d-flex align-center userflow-debugger-app__item",onClick:()=>{o&&o(p),r(!1)}},e.createElement(u,{icon:_.icon}),_.name)}))):null},on=()=>{const{meta:t,buildId:n}=V(),s=P(),[r,a]=i.useState(!!s.clientToken),o=i.useMemo(()=>s.isIdentified(),[s,t]),{setDebuggerRoute:l}=oe();i.useEffect(()=>{const E=()=>{a(!!s.clientToken)};return s.on("private:initialised",E),()=>{s.off("private:initialised",E)}},[]);const c=i.useMemo(()=>{let E=$;const h={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return r?(E=k,h["userflow-debugger-installation__step__success"]=!0):(E=it,h["userflow-debugger-installation__step__danger"]=!0),{icon:E,classes:h}},[r]),p=i.useMemo(()=>{let E=$;const h={"d-flex flex-column gap-8":!0,"userflow-debugger-installation__step":!0};return!r&&!o&&(E=$,h["userflow-debugger-installation__step__failed"]=!0),r&&!o&&(E=M,h["userflow-debugger-installation__step__warning"]=!0),r&&o&&(E=k,h["userflow-debugger-installation__step__success"]=!0),{icon:E,classes:h}},[r,o]),_=()=>o?t?.endUser.debuggerEnabled?e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},t?.env.company.name),e.createElement("span",{className:"userflow-debugger-details"},t?.env.name)):e.createElement("div",{className:"userflow-debugger-details__access__denied"},"The"," ",e.createElement("button",{onClick:()=>l("currentUser")},"currently signed-in user")," ","does not have debugger access"):e.createElement(e.Fragment,null,e.createElement("span",{className:"userflow-debugger-details"},"Unknown company"),e.createElement("span",{className:"userflow-debugger-details"},"Unknown environment"));return e.createElement("div",{className:"space-evenly userflow-debugger-app__content"},e.createElement("div",{className:"userflow-debugger-installation__steps"},e.createElement("div",{className:g({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__step":!0,"userflow-debugger-installation__step__success":!0})},e.createElement(u,{icon:k,size:32}),"Userflow ",e.createElement("br",null),"installed"),e.createElement("div",{className:g(c.classes)},e.createElement(u,{icon:c.icon,size:32}),"Userflow ",e.createElement("br",null)," ",r?"":"not"," initialized"),e.createElement("div",{className:g(p.classes)},e.createElement(u,{icon:p.icon,size:32}),"User ",e.createElement("br",null)," ",o&&r?"":"not"," ","identified")),!r&&!o&&e.createElement("div",{className:g({"d-flex gap-8 flex-column":!0,"userflow-debugger-installation__not__initialized":!0})},"Remember to initialize Userflow by calling",e.createElement("div",null,"userflow.init('YOUR_USERFLOW_TOKEN')")),r&&e.createElement("div",{className:"d-flex gap-8 flex-column userflow-debugger-details__wrapper"},e.createElement("div",{className:"userflow-debugger-details__env__details"},e.createElement("div",{className:"d-flex gap-8 flex-column justify-space-around"},e.createElement(u,{size:20,icon:at}),e.createElement(u,{size:20,icon:ot})),e.createElement("div",{className:"d-flex flex-column align-flex-start gap-8"},_())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(u,{size:20,icon:lt}),e.createElement("span",{className:"userflow-debugger-details"},s.getInitToken())),e.createElement("div",{className:"d-flex gap-8 align-center"},e.createElement(u,{size:20,icon:ne}),e.createElement("span",{className:"userflow-debugger-details"},o?s.getIdentifiedUser()?.externalId:"User not identified"))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))},ln=()=>{const t=P(),{debuggerClientConditions:n}=V(),[s,r]=i.useState(void 0),[a,o]=i.useState([]),[l,c]=i.useState(),p=i.useMemo(()=>{if(l?.startCondition?.match===!1||l?.hiddenCondition?.match===!0||l?.locale?.match===!1)return!1;const m=l?.startFrequency;return!(m&&(m.onlyIfNotCompleted===!1||m.scopeByGroup===!1||m.frequency===!1))},[l]);i.useEffect(()=>{_()},[]),rn(m=>{m&&_()}),i.useEffect(()=>{s&&N(s.latestVersion)},[s]);const _=async()=>{x().then(m=>{if(m?.length&&(o(m),!s)){const w=t.getSessionStorageState()?.debuggerApp?.selectedFlowVersionId,b=m.find(f=>f.latestVersion.id===w);h(b??m[0])}})},E=_e(async m=>{const w=[];for(const[v,C]of n.entries())w.push({conditionId:v,isTrue:C.isTrue});const b={kind:"DebugFlowAutostartCondition",flowVersionId:m.id,clientConditions:w},f=await t.send(b);c({...f,listFlowLatestVersion:m}),f.latestVersion?.id&&m.id!==f.latestVersion?.id&&(x().then(v=>{if(!v)return;o(v);const C=v?.find(R=>R.latestVersion.id===f.latestVersion?.id);C&&h(C)}),E(f.latestVersion))},300),h=m=>{r(m);const w=t.getSessionStorageState().debuggerApp;w&&w?.x&&t.setSessionStorageState(b=>({...b,debuggerApp:{...w,selectedFlowVersionId:m.latestVersion.id}}))},N=async m=>{n.forEach(b=>{b.untrack?.()}),n.clear();const{conditionTypes:w}=await Ae(async()=>{const{conditionTypes:b}=await import("./flow-condition-types.js").then(f=>f.f);return{conditionTypes:b}},__vite__mapDeps([0,1,2,3,4,5,6,7]));for(const b of m.clientConditions){n.set(b.id,{condition:b,isTrue:null});const f=w[b.type];if(!f){console.error(`Unknown condition type ${b.type}`);continue}const v=n.get(b.id);v&&(v.untrack=f.track({sessionData:new ke([]),condition:b,callback:C=>{v.isTrue!==C&&(v.isTrue=C,E(m))}}))}},x=async()=>{try{return(await t.send({kind:"ListFlows",hasAutostartCondition:!0},{handlesRejection:!0})).flows?.filter(b=>b.type==="FLOW")}catch(m){m.code==="debugger_access_denied"&&te("Access defined for List Flows");return}};return e.createElement("div",{className:"userflow-debugger-app__content"},e.createElement(Ce.Provider,{value:l},e.createElement(tn,{flows:a,selectedFlow:s,setSelectedFlow:h,debugAutoStartCondition:E}),e.createElement("div",{className:"d-flex flex-column gap-8 userflow-debugger-app__wrapper"},l?.startCondition?.condition&&e.createElement("div",null,e.createElement("div",{className:g({"d-flex gap-8 align-center":!0,"userflow-debugger-app__wrapper__passing":p,"userflow-debugger-app__wrapper__failed":!p})},e.createElement(u,{icon:p?ct:ut}),e.createElement("strong",null,"Auto-start conditions")),e.createElement("span",null,"These are"," ",e.createElement(Oe,{condition:l.startCondition.condition}),e.createElement("b",null,"-conditions"),", meaning"," ",l.startCondition.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="AND"&&e.createElement(e.Fragment,null,"all conditions must pass for the flow to start."),l.startCondition?.condition.type==="CLAUSE"&&l.startCondition.condition.operator==="OR"&&e.createElement(e.Fragment,null,"only one condition must pass for the flow to start."))),l?.startCondition?.condition&&e.createElement(W,{isRoot:!0,isHideCond:!1,condition:l.startCondition.condition}),e.createElement(Wt,null),e.createElement(zt,null),e.createElement(Yt,null),e.createElement(Kt,null),e.createElement(jt,null),e.createElement(Ht,null),e.createElement(Xt,null),e.createElement($t,null))))},cn=e.memo(()=>{const{meta:t,buildId:n}=V();if(!t)return null;const r="https://app.userflow.com/app/"+(t.env.primary?t.env.company.slug:`${t.env.company.slug}@${t.env.slug}`)+"/settings/debugger?external_id="+t.endUser.externalId;return e.createElement("div",{className:"d-flex flex-column space-evenly flex-1"},e.createElement("div",{className:"d-flex flex-column gap-8"},e.createElement("div",{className:"d-flex flex-column"},t.endUser.avatarUrl?e.createElement("img",{src:t.endUser.avatarUrl,className:"userflow-debugger-user__image"}):e.createElement("div",{className:"userflow-debugger-user__image"}),e.createElement("span",{className:"userflow-debugger-user__name"},t.endUser?.name||"Unknown name"),e.createElement("span",{className:"userflow-debugger-user__email"},t?.endUser?.email||"Unknown email address"),(!t.endUser.email||!t.endUser.name)&&e.createElement("span",{className:"userflow-debugger__external__id"},t.endUser.externalId)),!t.endUser.debuggerEnabled&&e.createElement(e.Fragment,null,e.createElement("div",{className:"userflow-debugger-user__info"},"This user doesn't have access to the Userflow debugger. You can grant access through the debugger settings in Userflow."),e.createElement("a",{className:"userflow-debugger-user__button",href:r,target:"_blank",rel:"noreferrer"},"Grant access in Userflow ",e.createElement(u,{icon:ve})))),e.createElement("div",{className:"userflow-debugger-installation__version"},e.createElement("a",{href:"https://docs.userflow.com/docs/dev/userflow-js-installation",target:"_blank",rel:"noreferrer"},"Visit the Userflow Developer Docs for help")," ",e.createElement("br",null),"Userflow.js version 0.1.",n))});class An{constructor(n,s){this.client=n,this.buildId=s,this.debuggerClientConditions=new Map}mount(){if(this.container)throw new Error("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-debugger-ui",document.body.appendChild(this.container),ce.render(e.createElement(un,{client:this.client,debuggerClientConditions:this.debuggerClientConditions,buildId:this.buildId,unmount:()=>this.unmount()}),this.container)}unmount(){this.container&&(ce.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),this.client.unMountDebugger(),delete this.container)}}const un=({client:t,debuggerClientConditions:n,buildId:s,unmount:r})=>{const[a,o]=i.useState(void 0),l=_e(async()=>{try{const c=await t.send({kind:"GetCurrentEndUser"},{handlesRejection:!0});o(c)}catch(c){c.code==="debugger_access_denied"&&te("debugger access denied"),o(void 0)}},300);return i.useEffect(()=>(l(),document.addEventListener("visibilitychange",l),t.on("private:identified",l),()=>{document.removeEventListener("visibilitychange",l),t.off("private:identified",l)}),[]),e.createElement(Pe.Provider,{value:t},e.createElement(Ne.Provider,{value:{meta:a,debuggerClientConditions:n,buildId:s}},e.createElement(Et,null,e.createElement(sn,{close:r}))))};export{An as DebuggerUI};
3
3
  //# sourceMappingURL=DebuggerUI.js.map
package/EmbedApp.js CHANGED
@@ -1,2 +1,2 @@
1
- import{r as o,R as l}from"./vendor.react.js";import{ad as m,E as U}from"./userflow.js";import{u as K,i as k}from"./client-context.js";import{o as M}from"./vendor.obj-str.js";import{a as P,u as Y,g as q,D as Z}from"./stylesheets.js";import{U as G}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{S as J}from"./TreeDoc.js";import{f as Q,w as V}from"./flow-host.styl.js";import{u as X,b as ee}from"./use-selector-element-monitoring.js";import{r as te}from"./vendor.react-dom.js";import{F as re}from"./Frame.js";import{z as d}from"./roots.js";import{u as ne}from"./use-element-rect.js";import{C as oe}from"./ChecklistUI.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-condition-types.js";import"./vendor.date-fns.js";import"./vendor.scheduler.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[a]="18f81bfe-2b1a-4e49-91a4-fe9507a11dd1",r._sentryDebugIdIdentifier="sentry-dbid-18f81bfe-2b1a-4e49-91a4-fe9507a11dd1")}catch{}})();const Me=({session:r,checklistSession:a})=>{const p=K(),{version:i}=r,t=i.embed,y=P(i.theme),L=r.locale?r.locale.standardLocaleId:r.version.theme.languageId,b=r.version.embed?.blocks||[],S=b.length===1&&b[0]?.type==="CHECKLIST";o.useEffect(()=>{k.changeLanguage(L)},[L]);const e=o.useRef(null);o.useLayoutEffect(()=>{e.current=document.createElement("div")},[]);const[N,v]=o.useState(!1),{loaded:D}=Y(window,Q,y),[F,I]=o.useState(!1),g=D&&F,[A,_]=o.useState(0),j=o.useCallback(()=>{I(!1),_(n=>n+1)},[]),E=![m.BODY_FIRST,m.BODY_LAST].includes(t.embedMode),[f,x]=o.useState(null),B=o.useCallback(({targetEl:n})=>{x(n)},[]),O=o.useCallback(()=>{E&&console.warn(`Userflow.js: Could not find embed element for banner "${r.flow.name||r.flow.id}"`),x(null)},[E,r.flow.name,r.flow.id]);X({selector:t.embedSelector,targetMoved:B,targetLost:O});const[T,$]=o.useState(!1),c=o.useCallback(()=>{const n=e.current;n&&n.parentElement&&(n.parentElement.removeChild(n),v(!1))},[e]),W=o.useCallback(()=>{r.kind==="embed"&&($(!0),p.endFlow(r,{endReason:U.USER_CLOSED}),c())},[c,r,p]);o.useLayoutEffect(()=>{try{if(S&&!a){c();return}if(!e.current?.parentElement){if(E&&!f){c();return}switch(t.embedMode){case m.BODY_FIRST:document.body.insertAdjacentElement("afterbegin",e.current);break;case m.BODY_LAST:document.body.insertAdjacentElement("beforeend",e.current);break;case m.ELEMENT_FIRST:f.insertAdjacentElement("afterbegin",e.current);break;case m.ELEMENT_LAST:f.insertAdjacentElement("beforeend",e.current);break;case m.ELEMENT_BEFORE:f.insertAdjacentElement("beforebegin",e.current);break;case m.ELEMENT_AFTER:f.insertAdjacentElement("afterend",e.current);break;default:document.body.insertAdjacentElement("afterbegin",e.current)}v(!0),j()}}catch(n){console.error("Error during element insertion:",n)}},[c,e,E,f,i.embed?.overlay,i.embed?.sticky,t.embedMode,j,a]);const h=n=>M({"userflowjs-embed":!0,[`userflowjs-embed--embed-mode-${t.embedMode}`]:!0,[`userflowjs-embed--animate-${String(t.animate)}`]:n&&t.animate});o.useLayoutEffect(()=>{e.current&&(e.current.className=h(!1))},[e,t.embedMode,t.animate]);const w=t.zIndex||V(0);o.useLayoutEffect(()=>{e.current&&(e.current.style.zIndex=w==null?"":String(w),e.current.style.position=g?"":"absolute",e.current.style.visibility=g?"":"hidden")},[e,w,g]);const{height:u,setEl:z}=ne();o.useLayoutEffect(()=>{e.current&&e.current.style.setProperty("--userflowjs-embed-height",u&&d(u+(t.marginTop||0)+(t.marginBottom||0))||"0px")},[e,u,t.marginTop,t.marginBottom]);const H=()=>{if(!r.version.embed?.blocks?.length)return null;const n=(s,C)=>l.createElement("div",{className:"userflowjs-embed-wrapper",key:C},l.createElement("div",{className:"userflowjs-bubble-toolbar"},r.draftMode&&l.createElement("div",{className:"userflowjs-bubble-draft"},"Preview"),!i.closeDisabled&&l.createElement("button",{"data-testid":"userflow-embed-dismiss",className:"userflowjs-bubble-toolbar-button",onClick:W,"aria-label":"Close embed"},l.createElement(Z,{icon:G}))),s);return b.map(s=>s.type==="CHECKLIST"?a?n(l.createElement("div",{style:{...q(y),paddingTop:i.closeDisabled?"0px":"32px"},className:"userflowjs-embedded-checklist"},l.createElement(oe,{session:a})),s.id):null:(console.warn(`Unknown embed block type: ${s.type}`),null))};return o.useLayoutEffect(()=>{const n=`userflow-${r.id}`;return e.current.id=n,()=>{T||document.getElementById(n)===e.current&&c()}},[e,r.id,c,T]),o.useLayoutEffect(()=>{const n=r.version.embed?.blocks?.length&&r.version.embed.blocks.some(s=>s.type==="CHECKLIST"?a:!1);u&&u>0&&n?(e.current.style.height=`${u}px`,e.current.className=h(t.animate)):(e.current.style.height="0px",e.current.className=h(!1))},[e,u,a,t.animate]),o.useEffect(()=>{if(!e.current)return;const n=new ResizeObserver(C=>{for(const R of C)R.contentRect&&!t.embedMode&&(e.current.style.height=`${R.contentRect.height}px`)}),s=e.current.querySelector("iframe");return s&&n.observe(s),()=>{n.disconnect()}},[e,t.embedMode]),!N||!b.length||S&&!a?null:te.createPortal(l.createElement(J.Provider,{value:r},l.createElement(re,{key:A,className:"userflowjs-embed-frame",style:{maxWidth:t.maxWidth?d(t.maxWidth):"100%",width:"100%",height:r.version.embed?.blocks?.length?"100%":"auto",minHeight:0,marginTop:d(t.marginTop),marginRight:d(t.marginRight),marginBottom:d(t.marginBottom),marginLeft:d(t.marginLeft),borderRadius:d(t.borderRadius)},stylesheet:ee,theme:y,onStylesheetsLoad:I,title:"Embedded Content"},l.createElement("div",{ref:z,className:M({"userflowjs-embed-root":!0,[`userflowjs-embed-root--content-layout-${t.contentLayout}`]:!0,"userflowjs-theme-root":!0,"userflowjs-embed-root-blocks":b.length>0}),dir:k.dir(),style:{width:"100%",maxWidth:t.maxContentWidth?d(t.maxContentWidth):"100%",margin:"0 auto"}},H()))),e.current)};export{Me as EmbedApp,Me as default};
1
+ import{r as o,R as l}from"./vendor.react.js";import{ad as m,E as K}from"./userflow.js";import{u as P,i as k}from"./client-context.js";import{o as M}from"./vendor.obj-str.js";import{a as U,u as Y,g as q,D as V}from"./stylesheets.js";import{V as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{S as G}from"./TreeDoc.js";import{f as J,w as Q}from"./flow-host.styl.js";import{u as X,b as ee}from"./use-selector-element-monitoring.js";import{r as te}from"./vendor.react-dom.js";import{F as re}from"./Frame.js";import{z as d}from"./roots.js";import{u as ne}from"./use-element-rect.js";import{C as oe}from"./ChecklistUI.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-condition-types.js";import"./vendor.date-fns.js";import"./vendor.scheduler.js";import"./iframe-reset.styl.js";import"./use-window-resize.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[a]="0bea9e88-765b-4566-80a8-a81f80743eeb",r._sentryDebugIdIdentifier="sentry-dbid-0bea9e88-765b-4566-80a8-a81f80743eeb")}catch{}})();const Me=({session:r,checklistSession:a})=>{const p=P(),{version:i}=r,t=i.embed,y=U(i.theme),L=r.locale?r.locale.standardLocaleId:r.version.theme.languageId,b=r.version.embed?.blocks||[],S=b.length===1&&b[0]?.type==="CHECKLIST";o.useEffect(()=>{k.changeLanguage(L)},[L]);const e=o.useRef(null);o.useLayoutEffect(()=>{e.current=document.createElement("div")},[]);const[N,v]=o.useState(!1),{loaded:D}=Y(window,J,y),[F,I]=o.useState(!1),g=D&&F,[A,_]=o.useState(0),j=o.useCallback(()=>{I(!1),_(n=>n+1)},[]),E=![m.BODY_FIRST,m.BODY_LAST].includes(t.embedMode),[f,x]=o.useState(null),B=o.useCallback(({targetEl:n})=>{x(n)},[]),O=o.useCallback(()=>{E&&console.warn(`Userflow.js: Could not find embed element for banner "${r.flow.name||r.flow.id}"`),x(null)},[E,r.flow.name,r.flow.id]);X({selector:t.embedSelector,targetMoved:B,targetLost:O});const[T,$]=o.useState(!1),c=o.useCallback(()=>{const n=e.current;n&&n.parentElement&&(n.parentElement.removeChild(n),v(!1))},[e]),W=o.useCallback(()=>{r.kind==="embed"&&($(!0),p.endFlow(r,{endReason:K.USER_CLOSED}),c())},[c,r,p]);o.useLayoutEffect(()=>{try{if(S&&!a){c();return}if(!e.current?.parentElement){if(E&&!f){c();return}switch(t.embedMode){case m.BODY_FIRST:document.body.insertAdjacentElement("afterbegin",e.current);break;case m.BODY_LAST:document.body.insertAdjacentElement("beforeend",e.current);break;case m.ELEMENT_FIRST:f.insertAdjacentElement("afterbegin",e.current);break;case m.ELEMENT_LAST:f.insertAdjacentElement("beforeend",e.current);break;case m.ELEMENT_BEFORE:f.insertAdjacentElement("beforebegin",e.current);break;case m.ELEMENT_AFTER:f.insertAdjacentElement("afterend",e.current);break;default:document.body.insertAdjacentElement("afterbegin",e.current)}v(!0),j()}}catch(n){console.error("Error during element insertion:",n)}},[c,e,E,f,i.embed?.overlay,i.embed?.sticky,t.embedMode,j,a]);const h=n=>M({"userflowjs-embed":!0,[`userflowjs-embed--embed-mode-${t.embedMode}`]:!0,[`userflowjs-embed--animate-${String(t.animate)}`]:n&&t.animate});o.useLayoutEffect(()=>{e.current&&(e.current.className=h(!1))},[e,t.embedMode,t.animate]);const w=t.zIndex||Q(0);o.useLayoutEffect(()=>{e.current&&(e.current.style.zIndex=w==null?"":String(w),e.current.style.position=g?"":"absolute",e.current.style.visibility=g?"":"hidden")},[e,w,g]);const{height:u,setEl:z}=ne();o.useLayoutEffect(()=>{e.current&&e.current.style.setProperty("--userflowjs-embed-height",u&&d(u+(t.marginTop||0)+(t.marginBottom||0))||"0px")},[e,u,t.marginTop,t.marginBottom]);const H=()=>{if(!r.version.embed?.blocks?.length)return null;const n=(s,C)=>l.createElement("div",{className:"userflowjs-embed-wrapper",key:C},l.createElement("div",{className:"userflowjs-bubble-toolbar"},r.draftMode&&l.createElement("div",{className:"userflowjs-bubble-draft"},"Preview"),!i.closeDisabled&&l.createElement("button",{"data-testid":"userflow-embed-dismiss",className:"userflowjs-bubble-toolbar-button",onClick:W,"aria-label":"Close embed"},l.createElement(V,{icon:Z}))),s);return b.map(s=>s.type==="CHECKLIST"?a?n(l.createElement("div",{style:{...q(y),paddingTop:i.closeDisabled?"0px":"32px"},className:"userflowjs-embedded-checklist"},l.createElement(oe,{session:a})),s.id):null:(console.warn(`Unknown embed block type: ${s.type}`),null))};return o.useLayoutEffect(()=>{const n=`userflow-${r.id}`;return e.current.id=n,()=>{T||document.getElementById(n)===e.current&&c()}},[e,r.id,c,T]),o.useLayoutEffect(()=>{const n=r.version.embed?.blocks?.length&&r.version.embed.blocks.some(s=>s.type==="CHECKLIST"?a:!1);u&&u>0&&n?(e.current.style.height=`${u}px`,e.current.className=h(t.animate)):(e.current.style.height="0px",e.current.className=h(!1))},[e,u,a,t.animate]),o.useEffect(()=>{if(!e.current)return;const n=new ResizeObserver(C=>{for(const R of C)R.contentRect&&!t.embedMode&&(e.current.style.height=`${R.contentRect.height}px`)}),s=e.current.querySelector("iframe");return s&&n.observe(s),()=>{n.disconnect()}},[e,t.embedMode]),!N||!b.length||S&&!a?null:te.createPortal(l.createElement(G.Provider,{value:r},l.createElement(re,{key:A,className:"userflowjs-embed-frame",style:{maxWidth:t.maxWidth?d(t.maxWidth):"100%",width:"100%",height:r.version.embed?.blocks?.length?"100%":"auto",minHeight:0,marginTop:d(t.marginTop),marginRight:d(t.marginRight),marginBottom:d(t.marginBottom),marginLeft:d(t.marginLeft),borderRadius:d(t.borderRadius)},stylesheet:ee,theme:y,onStylesheetsLoad:I,title:"Embedded Content"},l.createElement("div",{ref:z,className:M({"userflowjs-embed-root":!0,[`userflowjs-embed-root--content-layout-${t.contentLayout}`]:!0,"userflowjs-theme-root":!0,"userflowjs-embed-root-blocks":b.length>0}),dir:k.dir(),style:{width:"100%",maxWidth:t.maxContentWidth?d(t.maxContentWidth):"100%",margin:"0 auto"}},H()))),e.current)};export{Me as EmbedApp,Me as default};
2
2
  //# sourceMappingURL=EmbedApp.js.map
package/FlowChrome.js CHANGED
@@ -1,3 +1,3 @@
1
- import{a4 as ye,a5 as Le,a2 as ve,U as Be}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{R as p,r as s}from"./vendor.react.js";import{D as Dt,u as Me,g as ke}from"./stylesheets.js";import"./vendor.object-assign.js";import{u as de}from"./vendor.react-i18next.js";import{F as ie}from"./Frame.js";import{c as G,p as L,b as ft,r as Re,$ as O,B as je,a0 as f}from"./userflow.js";import{a as Pe,f as Oe}from"./flow-host.styl.js";import{u as Ne,b as xe}from"./use-selector-element-monitoring.js";import{u as Ie}from"./use-window-resize.js";import{S as _e}from"./logomark.js";import{o as $t}from"./vendor.obj-str.js";import{k as Xt,j as Ft,s as ct,t as He,u as De,l as ue,v as Ce,M as ce,w as Ct,p as Fe,q as Se,x as Ue,y as Ve}from"./roots.js";import{u as We}from"./use-confetti.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b389f06b-18c2-4b61-9df5-72a13686911e",e._sentryDebugIdIdentifier="sentry-dbid-b389f06b-18c2-4b61-9df5-72a13686911e")}catch{}})();const bo=({draftMode:e,muted:t,toggleMuted:o,close:w,minimize:E})=>{const{t:c}=de();return p.createElement("div",{className:"userflowjs-bubble-toolbar"},e&&p.createElement("div",{className:"userflowjs-bubble-draft"},typeof e=="string"?e:"Preview"),o&&p.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:o,"aria-label":t?"Unmute":"Mute"},t?p.createElement(Dt,{icon:ye}):p.createElement(Dt,{icon:Le})),E&&p.createElement("button",{"data-testid":"minimize-button",className:"userflowjs-bubble-toolbar-button",onClick:E,"aria-label":"Minimize checklist"},p.createElement(Dt,{icon:ve})),w&&p.createElement("button",{"data-testid":"close-button",className:"userflowjs-bubble-toolbar-button",onClick:w,"aria-label":c("menu.close")},p.createElement(Dt,{icon:Be})))},Ae=new URL("avatar-frame.css",import.meta.url).href;function ze(e,t){const o=window.Intercom;s.useEffect(()=>{if(!(!t||!e.autoHideIntercom||typeof o!="function"||G.autoHide3pDisabled)){try{o("update",{hide_default_launcher:!0})}catch(l){console.warn("Userflow.js: Error when hiding Intercom launcher",l)}return()=>{if(!G.autoHide3pDisabled)try{o("update",{hide_default_launcher:!1})}catch(l){console.warn("Userflow.js: Error when unhiding Intercom launcher",l)}}}},[o,e.autoHideIntercom,t]);const w=window.$crisp;s.useEffect(()=>{if(!(!t||!e.autoHideCrisp||!w||G.autoHide3pDisabled)){try{w.push(["do","chat:hide"])}catch(l){console.warn("Userflow.js: Error when hiding Crisp Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{w.push(["do","chat:show"])}catch(l){console.warn("Userflow.js: Error when unhiding Crisp Chat",l)}}}},[w,e.autoHideCrisp,t]);const E=window.HubSpotConversations;s.useEffect(()=>{if(!(!t||!e.autoHideHubspot||!E||G.autoHide3pDisabled)){try{E.widget.remove()}catch(l){console.warn("Userflow.js: Error when hiding HubSpot Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{E.widget.load()}catch(l){console.warn("Userflow.js: Error when unhiding HubSpot Chat",l)}}}},[E,e.autoHideHubspot,t]);const c=window.drift;s.useEffect(()=>{if(!(!t||!e.autoHideDrift||!c||G.autoHide3pDisabled)){try{c.api.widget.hide()}catch(l){console.warn("Userflow.js: Error when hiding Drift Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{c.api.widget.show()}catch(l){console.warn("Userflow.js: Error when unhiding Drift Chat",l)}}}},[c,e.autoHideDrift,t])}const Yt=16,Rt=20,mo=({company:e,theme:t,position:o,absoluteWidth:w,absoluteHeight:E,stepKey:c,stepAppearance:l,width:m,backgroundImageUrl:T,tooltipSelector:d,allowMissingTooltipTarget:y,tooltipPlacement:R,backdrop:H,tooltipTargetBlocked:A,backdropPadding:Q,zIndex:N,onTooltipTargetClick:v,onTooltipTargetMissingChange:D,onModalBackdropClick:J,onVisibleChange:tt,speaking:F,noIframe:j,MadeWithUserflow:i,minimizeOnAvatarClick:S,autoHide3pEnabled:M,bubbleFrameRootRef:B,frameWrapperHtmlAttributes:P,rootChildren:x,children:r,isModalAnnouncement:u,confettiEnabled:et})=>{const C=o||"absolute",U=R||null,$=Q||"0",ot=i||$e,nt=Pe(),dt=C==="fixed"?N??nt+1:1,K=dt-1,jt=dt-2,{i18n:Pt}=de(),it=Pt.dir(),bt=s.useRef(null),at=s.useRef(null),lt=s.useRef(null),[X,Ot]=s.useState(null),gt=s.useRef(null),wt=s.useRef(null),Tt=s.useRef(null),Et=s.useRef(null),yt=s.useRef(null),Lt=s.useRef(null),vt=s.useRef(null),Bt=s.useRef(null),mt=s.useRef(null);s.useLayoutEffect(()=>{const a=bt.current.style;a.animation="none",a.visibility="hidden",a.position="absolute",a.top="-99999px",a.left="-99999px"},[]);const{loaded:Nt}=Me(window,Oe,t),[xt,St]=s.useState(!1),[Ut,g]=s.useState(!1),n=Nt&&xt&&Ut;let[V,st]=s.useState(!1);l!==L.BUBBLE&&(S=!1,V=!1),s.useEffect(()=>{st(!1)},[c]);const k=s.useRef({appearance:null,width:null,theme:t,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}),[Y,_]=s.useState(null),Z=Y!=null&&n;s.useEffect(()=>{tt&&tt(Z)},[tt,Z]);const pt=s.useCallback(a=>{k.current.lastReportedTooltipTargetMissing!==a&&(k.current.lastReportedTooltipTargetMissing=a,D&&D(a))},[D]),z=s.useCallback(({forceAppearanceLayout:a,forceUpdatePosition:I}={})=>{const rt=bt.current,Ht=at.current,kt=lt.current,qt=wt.current,Jt=gt.current,Kt=Tt.current,Qt=Et.current,te=yt.current,ee=Lt.current,oe=vt.current,ae=Bt.current,le=mt.current;if(!rt||!Ht||!kt||!X||!qt||!Jt||!Kt||!Qt||!te||!ee||!oe||!ae||!le||!n)return;const h=k.current,{tooltipTargetParams:Wt}=h;Se();let W=l,se=!1;W===L.TOOLTIP&&!y&&!Wt&&(h.tooltipTargetMissing?(W=L.BUBBLE,se=!0):W=null);const re=W!==h.appearance,we=m!==h.width;if((a||re||we||t!==h.theme||H!=h.backdrop||$!=h.backdropPadding||U!==h.desiredTooltipPlacement)&&(h.appearance=W,h.width=m,h.theme=t,h.backdrop=H,h.backdropPadding=$,h.desiredTooltipPlacement=U,I=!0,Xe({layoutState:h,width:m,position:C,absoluteWidth:w,root:rt,bubble:Ht,bubbleFrameRoot:X,avatar:qt,avatarNotch:Jt,modalBackdrop:le,dir:it})),!j){const q=X.offsetHeight,At=Xt(),zt=Ft()<800?0:Yt,Te=t.avatarType===ft.NONE?0:W===L.BUBBLE?Rt+t.avatarSize:W===L.MODAL?t.avatarSize/2:0,ne=At-2*zt-Te,Gt=Math.min(q,ne);if(W&&Gt!==h.bubbleFrameHeight){if(h.bubbleFrameHeight=Gt,b(kt,"height",ct(Gt)),He(kt)&&kt.contentDocument){const Ee=kt.contentDocument.documentElement;Ee.style.overflowY=q<=ne?"hidden":"scroll"}I=!0}}if(I&&W){let q=re;if(W===L.TOOLTIP){const At=h.tooltipTargetParams&&h.tooltipTargetParams.targetEl,zt=h.prevTooltipTargetParams&&h.prevTooltipTargetParams.targetEl;At!==zt&&(q=!0)}h.prevTooltipTargetParams=h.tooltipTargetParams,Ye({layoutState:h,animateIn:q,position:C,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:U,root:rt,bubble:Ht,tooltipNotch:Kt,tooltipBackdrop:Qt,tooltipBlockTop:te,tooltipBlockRight:ee,tooltipBlockBottom:oe,tooltipBlockLeft:ae,dir:it})}if(W===L.TOOLTIP){const q=Wt&&Wt.targetEl;q&&h.stepKeyScrolledIntoView!==c&&h.targetScrolledIntoView!==q&&(h.stepKeyScrolledIntoView=c,h.targetScrolledIntoView=q,qe(q))}else h.stepKeyScrolledIntoView=void 0,h.targetScrolledIntoView=null;pt(se),_(W)},[n,X,c,l,m,t,C,w,E,y,U,H,$,j,pt,it]),Mt=s.useRef(z);Mt.current=z;const Zt=s.useRef(!1);s.useEffect(()=>{const a=()=>{Zt.current=!0};return window.addEventListener("pagehide",a),()=>window.removeEventListener("pagehide",a)},[]);const It=()=>{window.clearTimeout(k.current.tooltipTargetMissingTimeout),k.current.tooltipTargetMissingTimeout=void 0};s.useLayoutEffect(()=>It,[]);const _t=s.useRef(!1),be=()=>{const a=at.current;_t.current||!a||(Ve(a),_t.current=!0)},Vt=()=>{const a=at.current;!_t.current||!a||(Ue(a),_t.current=!1)};s.useLayoutEffect(()=>Vt,[]),s.useLayoutEffect(()=>{if(l!==L.MODAL||C!=="fixed")return;const a=mt.current,I=at.current;if(!a||!I)return;const rt=De(a,I);return()=>rt()},[l,C]);const me=s.useCallback(()=>{Vt();const a=k.current;if(a.tooltipTargetParams=null,y||(a.tooltipPlacement=null),l!==L.TOOLTIP){It(),a.tooltipTargetMissing=!1;return}if(!y&&!a.tooltipTargetMissingTimeout){a.tooltipTargetMissing=!1;const I=d&&!ue(d)&&d.type===Re.AUTO&&!d.autoData?1:parseFloat(t.tooltipMissingToleranceSeconds)*1e3;a.tooltipTargetMissingTimeout=window.setTimeout(()=>{if(!Zt.current){if(d&&!ue(d)){let rt=d.autoData;if(d.autoData)try{rt=JSON.parse(d.autoData)}catch{}console.warn(`Userflow.js: Tooltip target not found on page.
2
- `,{type:d.type,autoData:rt,excludeText:d.excludeText,precision:d.precision,text:d.text,css:d.css})}It(),a.tooltipTargetMissing=!0,Mt.current()}},I)}Mt.current()},[l,y,d,t.tooltipMissingToleranceSeconds]),pe=s.useCallback(a=>{const I=k.current;It(),Ce(a.targetEl)?be():Vt(),I.tooltipTargetParams&&I.tooltipTargetParams.targetEl!==a.targetEl&&(I.tooltipPlacement=null),I.tooltipTargetParams=a,z({forceUpdatePosition:!0})},[z]);Ne({selector:l===L.TOOLTIP&&d||null,targetMoved:pe,targetLost:me,onTargetClick:v});const he=s.useCallback(()=>z({forceAppearanceLayout:!0}),[z]);Ie(he),s.useEffect(()=>{if(!X||j||typeof ce!="function")return;let a;const I=new ce(()=>{a||(a=window.requestAnimationFrame(()=>{a=void 0,Mt.current()}))});return I.observe(X,{childList:!0,attributes:!0,subtree:!0}),()=>{I.disconnect(),a&&window.cancelAnimationFrame(a)}},[X,j]);const{startConfetti:ge}=We({stepType:l,theme:t,bubbleFrame:lt.current,isBubbleVisible:Z,confettiDelay:400,zIndex:jt});s.useEffect(()=>{Z&&et&&lt.current&&ge(!0)},[et,c,Z]),s.useLayoutEffect(()=>{Mt.current()}),s.useLayoutEffect(()=>{C==="absolute"&&z({forceAppearanceLayout:!0})},[C,w,E]);const ht=a=>{a.preventDefault(),a.stopPropagation()};return ze(t,!!M&&Y===L.BUBBLE),p.createElement("div",{ref:bt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:ke(t),dir:it},p.createElement("div",{className:"userflowjs-bubble",ref:at,style:{zIndex:dt}},p.createElement("div",{className:$t({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(t.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!S,"userflowjs-bubble-outline--minimized":V})},p.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...P},p.createElement(ie,{className:"userflowjs-bubble__frame",elRef:lt,stylesheet:xe,theme:t,onStylesheetsLoad:St,noIframe:j,title:l.toLowerCase()},p.createElement("div",{className:"userflowjs-bubble-frame-root",ref:a=>{B&&B(a),Ot(a)},style:T?{backgroundSize:"cover",backgroundImage:`url("${encodeURI(T)}")`}:void 0},r,e.flowBranding&&!u&&p.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},p.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},p.createElement(ot,{company:e},p.createElement(_e,null),p.createElement("div",null,"Made with Userflow"))))))),p.createElement("div",{ref:gt,className:"userflowjs-bubble__avatar-notch"})),p.createElement(ie,{className:$t({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!S,"userflowjs-bubble__avatar--speaking":!!F}),elRef:wt,stylesheet:Ae,theme:t,onStylesheetsLoad:g,noIframe:j,ariaHidden:!0,title:l.toLowerCase()},p.createElement("div",{className:$t({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!S}),onClick:S?()=>st(a=>!a):void 0},p.createElement(Ge,{theme:t}))),p.createElement("div",{ref:Tt,className:"userflowjs-bubble__tooltip-notch"})),p.createElement("div",{ref:Et,className:"userflowjs-tooltip-backdrop",onMouseDown:ht,style:{zIndex:K,pointerEvents:A?void 0:"none"}}),p.createElement("div",{ref:yt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Lt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:vt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:mt,className:"userflowjs-modal-backdrop",onMouseDown:ht,onClick:J,style:{zIndex:K}}),x&&x({visible:Z,bubbleFrame:lt.current}))},Ge=({theme:e})=>{const t="https://js.userflow.com/cartoon-avatars-no-bg/";let o;return e.avatarType===ft.ASSET&&e.avatarAsset?o=e.avatarAsset.assetUrl:e.avatarType===ft.CARTOON&&e.avatarName?o=t+e.avatarName+".svg?3":e.avatarType===ft.URL&&e.avatarUrl?o=e.avatarUrl:o=t+"none.svg",p.createElement("img",{src:o,alt:""})},$e=({company:e,children:t})=>p.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"},t);function Xe({layoutState:{appearance:e,theme:t,backdrop:o,tooltipTargetMissing:w},width:E,position:c,absoluteWidth:l,root:m,bubble:T,bubbleFrameRoot:d,avatar:y,avatarNotch:R,modalBackdrop:H,dir:A}){const Q=c==="absolute"?l||1024:ct(Ft()),{avatarSize:N,bubblePlacement:v}=t;let D=t.bubbleWidth,J=null,tt=null,F=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${e?.toLowerCase()}`,j="hidden",i=null,S=null,M=null,B=null,P="userflowjs-bubble__avatar-notch",x="hidden",r=null,u=null,et=null,C=null,U="userflowjs-modal-backdrop";switch((e===L.MODAL||!w&&e===L.BUBBLE&&o)&&(U+=" userflowjs-modal-backdrop--visible"),e){case L.BUBBLE:if(t.avatarType!==ft.NONE){j="",x="",v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.TOP_RIGHT?(J=N+Rt,i=0,r=-2*Rt,P+=" userflowjs-bubble__avatar-notch--top"):(tt=N+Rt,M=0,et=-2*Rt,P+=" userflowjs-bubble__avatar-notch--bottom");const ot=v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.BOTTOM_LEFT||v===O.BOTTOM_CENTER||v===O.CENTER;A==="ltr"&&ot||A==="rtl"&&!ot?(B=0,C=N,P+=" userflowjs-bubble__avatar-notch--left"):(S=0,u=N,P+=" userflowjs-bubble__avatar-notch--right")}break;case L.MODAL:D=t.modalWidth,t.avatarType!==ft.NONE&&(j="",B=`calc(50% - ${N/2}px)`,i=-N/2);break;case L.TOOLTIP:D=t.tooltipWidth;break}E!=null&&(D=E),D=Math.min(D,Q-2*Yt),m.classList.toggle("userflowjs-flow-chrome--position-absolute",c==="absolute"),m.classList.toggle("userflowjs-flow-chrome--position-relative",c==="relative"),m.classList.toggle("userflowjs-flow-chrome--position-fixed",c==="fixed"),m.classList.toggle("userflowjs-flow-chrome--appearance-modal",e===L.MODAL);const $=e!=null&&e!==L.HIDDEN;m.style.position="",m.style.top="",m.style.left="",m.style.visibility=$?"":"hidden",m.style.animation=$?"":"none",b(T,"width",ct(D)),b(T,"padding-top",J),b(T,"padding-bottom",tt),d.className=F,b(y,"width",ct(t.avatarSize)),b(y,"height",ct(t.avatarSize)),y.style.visibility=j,b(y,"top",i),b(y,"right",S),b(y,"bottom",M),b(y,"left",B),R.className=P,R.style.visibility=x,b(R,"top",r),b(R,"right",u),b(R,"bottom",et),b(R,"left",C),H.className=U}function Ye({layoutState:e,animateIn:t,position:o,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:c,root:l,bubble:m,tooltipNotch:T,tooltipBackdrop:d,tooltipBlockTop:y,tooltipBlockRight:R,tooltipBlockBottom:H,tooltipBlockLeft:A,dir:Q}){const{appearance:N,theme:v,tooltipTargetParams:D,backdrop:J,backdropPadding:tt}=e,{bubblePlacement:F}=v,j=Yt,i=v.tooltipNotchSize,S=10,{width:M,height:B}=m.getBoundingClientRect(),P=o==="absolute"?w||1024:ct(Ft()),x=o==="absolute"?E||768:ct(Xt());let r=0,u=0,et="userflowjs-bubble__tooltip-notch",C="hidden",U=null,$=null,ot=null,nt=null,dt="userflowjs-tooltip-backdrop",K=null,jt=null,Pt=null,it=null,bt=null,at=null,lt=null,X=null,Ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",gt=null,wt=null,Tt="userflowjs-tooltip-block userflowjs-tooltip-block--right",Et=null,yt=null,Lt="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",vt=null,Bt=null,mt="userflowjs-tooltip-block userflowjs-tooltip-block--left",Nt=null,xt=null;switch(N){case L.BUBBLE:{F===O.TOP_LEFT||F===O.BOTTOM_LEFT?r=v.bubbleX:F===O.TOP_CENTER||F===O.CENTER||F===O.BOTTOM_CENTER?r=(P-M)/2:r=P-M-v.bubbleX,F===O.TOP_LEFT||F===O.TOP_CENTER||F===O.TOP_RIGHT?u=v.bubbleY:F===O.CENTER?u=(x-B)/2:u=x-B-v.bubbleY,Q==="rtl"&&(r=P-r-M),r=Math.max(0,Math.min(P-M,r)),u=Math.max(0,Math.min(x-B,u));break}case L.MODAL:{let g=j;v.avatarType!==ft.NONE&&(g+=v.avatarSize/2),r=j+(P-j*2-M)/2,u=g+(x-g-j-B)/2;break}case L.TOOLTIP:{let g;if(D){let{targetRect:n,viewportClipRect:V}=D;if(o==="absolute"){const _=l.offsetParent.getBoundingClientRect();V={top:0,right:P,bottom:x,left:0},n={top:n.top-_.top,right:n.right-_.left,bottom:n.bottom-_.top,left:n.left-_.left,width:n.width,height:n.height}}let st=0;if(J){const{paddingTop:_,paddingRight:Z,paddingBottom:pt,paddingLeft:z}=Je(tt);n={top:n.top-_,right:n.right+Z,bottom:n.bottom+pt,left:n.left-z,width:n.width+z+Z,height:n.height+_+pt},st=Math.min(_,Z,pt,z)}const k=n,Y=v.backdropHighlightType==je.OUTSIDE?v.backdropHighlightSpread:0;if(J&&Y&&(n={top:n.top-Y,right:n.right+Y,bottom:n.bottom+Y,left:n.left-Y,width:n.width+2*Y,height:n.height+2*Y}),g=Ze({targetRect:n,bubbleWidth:M,bubbleHeight:B,containerWidth:P,containerHeight:x,viewportClipRect:V,tooltipNotchSize:i,currentTooltipPlacement:e.tooltipPlacement,desiredTooltipPlacement:c}),g===f.BELOW||g===f.ABOVE?(r=n.left+n.width/2-M/2,r=Math.max(j,Math.min(P-M-j,r)),nt=Math.max(S,Math.min(M-S-i*2,n.left+n.width/2-i-r)),g===f.BELOW?U=-i*2:ot=-i*2):g===f.RIGHT?(r=n.right+i,r=Math.max(r,V.left+i),r=Math.min(r,V.right+i),r=Math.max(r,i),r=Math.min(r,P-M)):(r=n.left-i-M,r=Math.max(r,V.left-M-i),r=Math.min(r,V.right-M-i),r=Math.max(r,0),r=Math.min(r,P-M-i)),g===f.LEFT||g===f.RIGHT?(u=n.top+n.height/2-B/2,u=Math.max(j,Math.min(x-B-j,u)),U=Math.max(S,Math.min(B-S-i*2,n.top+n.height/2-i-u)),g===f.LEFT?$=-i*2:nt=-i*2):g===f.BELOW?(u=n.bottom+i,u=Math.max(u,V.top+i),u=Math.min(u,V.bottom+i),u=Math.max(u,i),u=Math.min(u,x-B)):(u=n.top-i-B,u=Math.max(u,V.top-B-i),u=Math.min(u,V.bottom-B-i),u=Math.max(u,0),u=Math.min(u,x-B-i)),J){const _=window.getComputedStyle(D.targetEl);K=Math.max(0,k.top),jt=Math.max(0,P-k.right),Pt=Math.max(0,x-k.bottom),it=Math.max(0,k.left),bt=Math.max(0,Ct(_.borderTopLeftRadius)+st),at=Math.max(0,Ct(_.borderTopRightRadius)+st),lt=Math.max(0,Ct(_.borderBottomRightRadius)+st),X=Math.max(0,Ct(_.borderBottomLeftRadius)+st),gt=Math.max(0,k.right),wt=Math.max(0,k.top),Et=Math.max(0,k.right),yt=Math.max(0,k.bottom),vt=Math.max(0,k.left),Bt=Math.max(0,k.bottom),Nt=Math.max(0,k.left),xt=Math.max(0,k.top)}}else g=c||f.BELOW,(g===f.BELOW||g===f.ABOVE)&&(nt=M/2-i,g===f.BELOW?U=-i*2:ot=-i*2),(g===f.LEFT||g===f.RIGHT)&&(U=B/2-i,g===f.LEFT?$=-i*2:nt=-i*2);e.tooltipPlacement=g,et+=` userflowjs-bubble__tooltip-notch--${g.toLowerCase()}`,C="",J&&(dt+=" userflowjs-tooltip-backdrop--visible",Ot+=" userflowjs-tooltip-block--visible",Tt+=" userflowjs-tooltip-block--visible",Lt+=" userflowjs-tooltip-block--visible",mt+=" userflowjs-tooltip-block--visible");break}}m.style.transition="";let St=r,Ut=u;if(t&&(m.style.opacity="0",N===L.TOOLTIP))switch(e.tooltipPlacement){case f.BELOW:u+=24;break;case f.ABOVE:u-=24;break;case f.RIGHT:r+=24;break;case f.LEFT:r-=24;break}if(o!=="relative"&&fe(m,r,u),T.className=et,T.style.visibility=C,b(T,"top",U),b(T,"right",$),b(T,"bottom",ot),b(T,"left",nt),d.className=dt,b(d,"top",K),b(d,"right",jt),b(d,"bottom",Pt),b(d,"left",it),b(d,"border-top-left-radius",bt),b(d,"border-top-right-radius",at),b(d,"border-bottom-right-radius",lt),b(d,"border-bottom-left-radius",X),y.className=Ot,b(y,"width",gt),b(y,"height",wt),R.className=Tt,b(R,"left",Et),b(R,"height",yt),H.className=Lt,b(H,"left",vt),b(H,"top",Bt),A.className=mt,b(A,"width",Nt),b(A,"top",xt),t){m.offsetWidth;const g="opacity 250ms linear";N===L.TOOLTIP?m.style.transition=`${g}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:m.style.transition=g,m.style.opacity="1",o!=="relative"&&fe(m,St,Ut)}}function Ze({targetRect:e,bubbleWidth:t,bubbleHeight:o,containerWidth:w,containerHeight:E,viewportClipRect:c,tooltipNotchSize:l,currentTooltipPlacement:m,desiredTooltipPlacement:T}){if(e.bottom<=c.top)return o+l<=E-c.top?f.BELOW:f.ABOVE;if(e.top>=c.bottom)return o+l<=c.bottom?f.ABOVE:f.BELOW;if(e.right<=c.left)return t+l<=w-c.left?f.RIGHT:f.LEFT;if(e.left>=c.right)return t+l<=c.right?f.LEFT:f.RIGHT;const d=R=>{const H=e.left+e.width/2,A=H>=c.left&&H<=c.right,Q=e.top+e.height/2,N=Q>=c.top&&Q<=c.bottom;switch(R){case f.BELOW:return E-e.bottom>o+l&&A;case f.ABOVE:return e.top>o+l&&A;case f.RIGHT:return w-e.right>t+l&&N;case f.LEFT:return e.left>t+l&&N}};if(T&&d(T))return T;if(m&&d(m))return m;const y=[{placement:f.BELOW,dist:e.top},{placement:f.ABOVE,dist:E-e.bottom},{placement:f.RIGHT,dist:e.left},{placement:f.LEFT,dist:w-e.right}];y.sort((R,H)=>R.dist-H.dist);for(const{placement:R}of y)if(d(R))return R;return f.BELOW}function b(e,t,o){o==null?e.style.removeProperty(t):e.style.setProperty(t,typeof o=="number"?o+"px":o,"important")}function fe(e,t,o){t=Math.round(t),o=Math.round(o),e.style.transform=`translate3d(${t}px, ${o}px, 0px)`}function qe(e){if(G.customScrollIntoView){G.customScrollIntoView(e);return}const{scrollPadding:t}=G;if(t&&Fe(e)===document.scrollingElement){const o=t.top||0,w=t.right||0,E=t.bottom||0,c=t.left||0;let l=0,m=0;const T=e.getBoundingClientRect(),d=Ft(),y=Xt();if(T.top<o?l=T.top-o:T.bottom>y-E&&(l=T.bottom-y+E),T.left<c?m=T.left-c:T.right>d-w&&(m=T.right-d+w),l!=0||m!=0){window.scrollBy({top:l,left:m,behavior:"smooth"});return}}try{e.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),e.scrollIntoView()}}function Je(e){if(!e||e==="0")return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const t=e.trim().split(" ");if(t.length===1){const o=ut(t[0]);return{paddingTop:o,paddingRight:o,paddingBottom:o,paddingLeft:o}}else if(t.length===2){const o=ut(t[0]),w=ut(t[1]);return{paddingTop:o,paddingRight:w,paddingBottom:o,paddingLeft:w}}else return{paddingTop:ut(t[0]),paddingRight:ut(t[1]),paddingBottom:ut(t[2]),paddingLeft:ut(t[3])}}function ut(e){const t=parseInt(e,10);return isNaN(t)?0:t}export{bo as B,mo as F};
1
+ import{a5 as ye,a6 as Le,a3 as ve,V as Be}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{R as p,r as s}from"./vendor.react.js";import{D as Dt,u as Me,g as ke}from"./stylesheets.js";import"./vendor.object-assign.js";import{u as de}from"./vendor.react-i18next.js";import{F as ie}from"./Frame.js";import{c as G,p as L,b as ft,r as Re,$ as O,B as je,a0 as f}from"./userflow.js";import{a as Pe,f as Oe}from"./flow-host.styl.js";import{u as Ne,b as xe}from"./use-selector-element-monitoring.js";import{u as Ie}from"./use-window-resize.js";import{S as _e}from"./logomark.js";import{o as $t}from"./vendor.obj-str.js";import{k as Xt,j as Ft,s as ct,t as He,u as De,l as ue,v as Ce,M as ce,w as Ct,p as Fe,q as Se,x as Ve,y as Ue}from"./roots.js";import{u as We}from"./use-confetti.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},t=new Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="329bc59e-dea9-4c05-aa1c-6a567373436e",e._sentryDebugIdIdentifier="sentry-dbid-329bc59e-dea9-4c05-aa1c-6a567373436e")}catch{}})();const bo=({draftMode:e,muted:t,toggleMuted:o,close:w,minimize:E})=>{const{t:c}=de();return p.createElement("div",{className:"userflowjs-bubble-toolbar"},e&&p.createElement("div",{className:"userflowjs-bubble-draft"},typeof e=="string"?e:"Preview"),o&&p.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:o,"aria-label":t?"Unmute":"Mute"},t?p.createElement(Dt,{icon:ye}):p.createElement(Dt,{icon:Le})),E&&p.createElement("button",{"data-testid":"minimize-button",className:"userflowjs-bubble-toolbar-button",onClick:E,"aria-label":"Minimize checklist"},p.createElement(Dt,{icon:ve})),w&&p.createElement("button",{"data-testid":"close-button",className:"userflowjs-bubble-toolbar-button",onClick:w,"aria-label":c("menu.close")},p.createElement(Dt,{icon:Be})))},Ae=new URL("avatar-frame.css",import.meta.url).href;function ze(e,t){const o=window.Intercom;s.useEffect(()=>{if(!(!t||!e.autoHideIntercom||typeof o!="function"||G.autoHide3pDisabled)){try{o("update",{hide_default_launcher:!0})}catch(l){console.warn("Userflow.js: Error when hiding Intercom launcher",l)}return()=>{if(!G.autoHide3pDisabled)try{o("update",{hide_default_launcher:!1})}catch(l){console.warn("Userflow.js: Error when unhiding Intercom launcher",l)}}}},[o,e.autoHideIntercom,t]);const w=window.$crisp;s.useEffect(()=>{if(!(!t||!e.autoHideCrisp||!w||G.autoHide3pDisabled)){try{w.push(["do","chat:hide"])}catch(l){console.warn("Userflow.js: Error when hiding Crisp Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{w.push(["do","chat:show"])}catch(l){console.warn("Userflow.js: Error when unhiding Crisp Chat",l)}}}},[w,e.autoHideCrisp,t]);const E=window.HubSpotConversations;s.useEffect(()=>{if(!(!t||!e.autoHideHubspot||!E||G.autoHide3pDisabled)){try{E.widget.remove()}catch(l){console.warn("Userflow.js: Error when hiding HubSpot Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{E.widget.load()}catch(l){console.warn("Userflow.js: Error when unhiding HubSpot Chat",l)}}}},[E,e.autoHideHubspot,t]);const c=window.drift;s.useEffect(()=>{if(!(!t||!e.autoHideDrift||!c||G.autoHide3pDisabled)){try{c.api.widget.hide()}catch(l){console.warn("Userflow.js: Error when hiding Drift Chat",l)}return()=>{if(!G.autoHide3pDisabled)try{c.api.widget.show()}catch(l){console.warn("Userflow.js: Error when unhiding Drift Chat",l)}}}},[c,e.autoHideDrift,t])}const Yt=16,Rt=20,mo=({company:e,theme:t,position:o,absoluteWidth:w,absoluteHeight:E,stepKey:c,stepAppearance:l,width:m,backgroundImageUrl:T,tooltipSelector:d,allowMissingTooltipTarget:y,tooltipPlacement:R,backdrop:H,tooltipTargetBlocked:A,backdropPadding:Q,zIndex:N,onTooltipTargetClick:v,onTooltipTargetMissingChange:D,onModalBackdropClick:J,onVisibleChange:tt,speaking:F,noIframe:j,MadeWithUserflow:i,minimizeOnAvatarClick:S,autoHide3pEnabled:M,bubbleFrameRootRef:B,frameWrapperHtmlAttributes:P,rootChildren:x,children:r,isModalAnnouncement:u,confettiEnabled:et})=>{const C=o||"absolute",V=R||null,$=Q||"0",ot=i||$e,nt=Pe(),dt=C==="fixed"?N??nt+1:1,K=dt-1,jt=dt-2,{i18n:Pt}=de(),it=Pt.dir(),bt=s.useRef(null),at=s.useRef(null),lt=s.useRef(null),[X,Ot]=s.useState(null),gt=s.useRef(null),wt=s.useRef(null),Tt=s.useRef(null),Et=s.useRef(null),yt=s.useRef(null),Lt=s.useRef(null),vt=s.useRef(null),Bt=s.useRef(null),mt=s.useRef(null);s.useLayoutEffect(()=>{const a=bt.current.style;a.animation="none",a.visibility="hidden",a.position="absolute",a.top="-99999px",a.left="-99999px"},[]);const{loaded:Nt}=Me(window,Oe,t),[xt,St]=s.useState(!1),[Vt,g]=s.useState(!1),n=Nt&&xt&&Vt;let[U,st]=s.useState(!1);l!==L.BUBBLE&&(S=!1,U=!1),s.useEffect(()=>{st(!1)},[c]);const k=s.useRef({appearance:null,width:null,theme:t,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}),[Y,_]=s.useState(null),Z=Y!=null&&n;s.useEffect(()=>{tt&&tt(Z)},[tt,Z]);const pt=s.useCallback(a=>{k.current.lastReportedTooltipTargetMissing!==a&&(k.current.lastReportedTooltipTargetMissing=a,D&&D(a))},[D]),z=s.useCallback(({forceAppearanceLayout:a,forceUpdatePosition:I}={})=>{const rt=bt.current,Ht=at.current,kt=lt.current,qt=wt.current,Jt=gt.current,Kt=Tt.current,Qt=Et.current,te=yt.current,ee=Lt.current,oe=vt.current,ae=Bt.current,le=mt.current;if(!rt||!Ht||!kt||!X||!qt||!Jt||!Kt||!Qt||!te||!ee||!oe||!ae||!le||!n)return;const h=k.current,{tooltipTargetParams:Wt}=h;Se();let W=l,se=!1;W===L.TOOLTIP&&!y&&!Wt&&(h.tooltipTargetMissing?(W=L.BUBBLE,se=!0):W=null);const re=W!==h.appearance,we=m!==h.width;if((a||re||we||t!==h.theme||H!=h.backdrop||$!=h.backdropPadding||V!==h.desiredTooltipPlacement)&&(h.appearance=W,h.width=m,h.theme=t,h.backdrop=H,h.backdropPadding=$,h.desiredTooltipPlacement=V,I=!0,Xe({layoutState:h,width:m,position:C,absoluteWidth:w,root:rt,bubble:Ht,bubbleFrameRoot:X,avatar:qt,avatarNotch:Jt,modalBackdrop:le,dir:it})),!j){const q=X.offsetHeight,At=Xt(),zt=Ft()<800?0:Yt,Te=t.avatarType===ft.NONE?0:W===L.BUBBLE?Rt+t.avatarSize:W===L.MODAL?t.avatarSize/2:0,ne=At-2*zt-Te,Gt=Math.min(q,ne);if(W&&Gt!==h.bubbleFrameHeight){if(h.bubbleFrameHeight=Gt,b(kt,"height",ct(Gt)),He(kt)&&kt.contentDocument){const Ee=kt.contentDocument.documentElement;Ee.style.overflowY=q<=ne?"hidden":"scroll"}I=!0}}if(I&&W){let q=re;if(W===L.TOOLTIP){const At=h.tooltipTargetParams&&h.tooltipTargetParams.targetEl,zt=h.prevTooltipTargetParams&&h.prevTooltipTargetParams.targetEl;At!==zt&&(q=!0)}h.prevTooltipTargetParams=h.tooltipTargetParams,Ye({layoutState:h,animateIn:q,position:C,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:V,root:rt,bubble:Ht,tooltipNotch:Kt,tooltipBackdrop:Qt,tooltipBlockTop:te,tooltipBlockRight:ee,tooltipBlockBottom:oe,tooltipBlockLeft:ae,dir:it})}if(W===L.TOOLTIP){const q=Wt&&Wt.targetEl;q&&h.stepKeyScrolledIntoView!==c&&h.targetScrolledIntoView!==q&&(h.stepKeyScrolledIntoView=c,h.targetScrolledIntoView=q,qe(q))}else h.stepKeyScrolledIntoView=void 0,h.targetScrolledIntoView=null;pt(se),_(W)},[n,X,c,l,m,t,C,w,E,y,V,H,$,j,pt,it]),Mt=s.useRef(z);Mt.current=z;const Zt=s.useRef(!1);s.useEffect(()=>{const a=()=>{Zt.current=!0};return window.addEventListener("pagehide",a),()=>window.removeEventListener("pagehide",a)},[]);const It=()=>{window.clearTimeout(k.current.tooltipTargetMissingTimeout),k.current.tooltipTargetMissingTimeout=void 0};s.useLayoutEffect(()=>It,[]);const _t=s.useRef(!1),be=()=>{const a=at.current;_t.current||!a||(Ue(a),_t.current=!0)},Ut=()=>{const a=at.current;!_t.current||!a||(Ve(a),_t.current=!1)};s.useLayoutEffect(()=>Ut,[]),s.useLayoutEffect(()=>{if(l!==L.MODAL||C!=="fixed")return;const a=mt.current,I=at.current;if(!a||!I)return;const rt=De(a,I);return()=>rt()},[l,C]);const me=s.useCallback(()=>{Ut();const a=k.current;if(a.tooltipTargetParams=null,y||(a.tooltipPlacement=null),l!==L.TOOLTIP){It(),a.tooltipTargetMissing=!1;return}if(!y&&!a.tooltipTargetMissingTimeout){a.tooltipTargetMissing=!1;const I=d&&!ue(d)&&d.type===Re.AUTO&&!d.autoData?1:parseFloat(t.tooltipMissingToleranceSeconds)*1e3;a.tooltipTargetMissingTimeout=window.setTimeout(()=>{if(!Zt.current){if(d&&!ue(d)){let rt=d.autoData;if(d.autoData)try{rt=JSON.parse(d.autoData)}catch{}console.warn(`Userflow.js: Tooltip target not found on page.
2
+ `,{type:d.type,autoData:rt,excludeText:d.excludeText,precision:d.precision,text:d.text,css:d.css})}It(),a.tooltipTargetMissing=!0,Mt.current()}},I)}Mt.current()},[l,y,d,t.tooltipMissingToleranceSeconds]),pe=s.useCallback(a=>{const I=k.current;It(),Ce(a.targetEl)?be():Ut(),I.tooltipTargetParams&&I.tooltipTargetParams.targetEl!==a.targetEl&&(I.tooltipPlacement=null),I.tooltipTargetParams=a,z({forceUpdatePosition:!0})},[z]);Ne({selector:l===L.TOOLTIP&&d||null,targetMoved:pe,targetLost:me,onTargetClick:v});const he=s.useCallback(()=>z({forceAppearanceLayout:!0}),[z]);Ie(he),s.useEffect(()=>{if(!X||j||typeof ce!="function")return;let a;const I=new ce(()=>{a||(a=window.requestAnimationFrame(()=>{a=void 0,Mt.current()}))});return I.observe(X,{childList:!0,attributes:!0,subtree:!0}),()=>{I.disconnect(),a&&window.cancelAnimationFrame(a)}},[X,j]);const{startConfetti:ge}=We({stepType:l,theme:t,bubbleFrame:lt.current,isBubbleVisible:Z,confettiDelay:400,zIndex:jt});s.useEffect(()=>{Z&&et&&lt.current&&ge(!0)},[et,c,Z]),s.useLayoutEffect(()=>{Mt.current()}),s.useLayoutEffect(()=>{C==="absolute"&&z({forceAppearanceLayout:!0})},[C,w,E]);const ht=a=>{a.preventDefault(),a.stopPropagation()};return ze(t,!!M&&Y===L.BUBBLE),p.createElement("div",{ref:bt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:ke(t),dir:it},p.createElement("div",{className:"userflowjs-bubble",ref:at,style:{zIndex:dt}},p.createElement("div",{className:$t({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(t.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!S,"userflowjs-bubble-outline--minimized":U})},p.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...P},p.createElement(ie,{className:"userflowjs-bubble__frame",elRef:lt,stylesheet:xe,theme:t,onStylesheetsLoad:St,noIframe:j,title:l.toLowerCase()},p.createElement("div",{className:"userflowjs-bubble-frame-root",ref:a=>{B&&B(a),Ot(a)},style:T?{backgroundSize:"cover",backgroundImage:`url("${encodeURI(T)}")`}:void 0},r,e.flowBranding&&!u&&p.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},p.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},p.createElement(ot,{company:e},p.createElement(_e,null),p.createElement("div",null,"Made with Userflow"))))))),p.createElement("div",{ref:gt,className:"userflowjs-bubble__avatar-notch"})),p.createElement(ie,{className:$t({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!S,"userflowjs-bubble__avatar--speaking":!!F}),elRef:wt,stylesheet:Ae,theme:t,onStylesheetsLoad:g,noIframe:j,ariaHidden:!0,title:l.toLowerCase()},p.createElement("div",{className:$t({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!S}),onClick:S?()=>st(a=>!a):void 0},p.createElement(Ge,{theme:t}))),p.createElement("div",{ref:Tt,className:"userflowjs-bubble__tooltip-notch"})),p.createElement("div",{ref:Et,className:"userflowjs-tooltip-backdrop",onMouseDown:ht,style:{zIndex:K,pointerEvents:A?void 0:"none"}}),p.createElement("div",{ref:yt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Lt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:vt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:ht,style:{zIndex:K}}),p.createElement("div",{ref:mt,className:"userflowjs-modal-backdrop",onMouseDown:ht,onClick:J,style:{zIndex:K}}),x&&x({visible:Z,bubbleFrame:lt.current}))},Ge=({theme:e})=>{const t="https://js.userflow.com/cartoon-avatars-no-bg/";let o;return e.avatarType===ft.ASSET&&e.avatarAsset?o=e.avatarAsset.assetUrl:e.avatarType===ft.CARTOON&&e.avatarName?o=t+e.avatarName+".svg?3":e.avatarType===ft.URL&&e.avatarUrl?o=e.avatarUrl:o=t+"none.svg",p.createElement("img",{src:o,alt:""})},$e=({company:e,children:t})=>p.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"},t);function Xe({layoutState:{appearance:e,theme:t,backdrop:o,tooltipTargetMissing:w},width:E,position:c,absoluteWidth:l,root:m,bubble:T,bubbleFrameRoot:d,avatar:y,avatarNotch:R,modalBackdrop:H,dir:A}){const Q=c==="absolute"?l||1024:ct(Ft()),{avatarSize:N,bubblePlacement:v}=t;let D=t.bubbleWidth,J=null,tt=null,F=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${e?.toLowerCase()}`,j="hidden",i=null,S=null,M=null,B=null,P="userflowjs-bubble__avatar-notch",x="hidden",r=null,u=null,et=null,C=null,V="userflowjs-modal-backdrop";switch((e===L.MODAL||!w&&e===L.BUBBLE&&o)&&(V+=" userflowjs-modal-backdrop--visible"),e){case L.BUBBLE:if(t.avatarType!==ft.NONE){j="",x="",v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.TOP_RIGHT?(J=N+Rt,i=0,r=-2*Rt,P+=" userflowjs-bubble__avatar-notch--top"):(tt=N+Rt,M=0,et=-2*Rt,P+=" userflowjs-bubble__avatar-notch--bottom");const ot=v===O.TOP_LEFT||v===O.TOP_CENTER||v===O.BOTTOM_LEFT||v===O.BOTTOM_CENTER||v===O.CENTER;A==="ltr"&&ot||A==="rtl"&&!ot?(B=0,C=N,P+=" userflowjs-bubble__avatar-notch--left"):(S=0,u=N,P+=" userflowjs-bubble__avatar-notch--right")}break;case L.MODAL:D=t.modalWidth,t.avatarType!==ft.NONE&&(j="",B=`calc(50% - ${N/2}px)`,i=-N/2);break;case L.TOOLTIP:D=t.tooltipWidth;break}E!=null&&(D=E),D=Math.min(D,Q-2*Yt),m.classList.toggle("userflowjs-flow-chrome--position-absolute",c==="absolute"),m.classList.toggle("userflowjs-flow-chrome--position-relative",c==="relative"),m.classList.toggle("userflowjs-flow-chrome--position-fixed",c==="fixed"),m.classList.toggle("userflowjs-flow-chrome--appearance-modal",e===L.MODAL);const $=e!=null&&e!==L.HIDDEN;m.style.position="",m.style.top="",m.style.left="",m.style.visibility=$?"":"hidden",m.style.animation=$?"":"none",b(T,"width",ct(D)),b(T,"padding-top",J),b(T,"padding-bottom",tt),d.className=F,b(y,"width",ct(t.avatarSize)),b(y,"height",ct(t.avatarSize)),y.style.visibility=j,b(y,"top",i),b(y,"right",S),b(y,"bottom",M),b(y,"left",B),R.className=P,R.style.visibility=x,b(R,"top",r),b(R,"right",u),b(R,"bottom",et),b(R,"left",C),H.className=V}function Ye({layoutState:e,animateIn:t,position:o,absoluteWidth:w,absoluteHeight:E,desiredTooltipPlacement:c,root:l,bubble:m,tooltipNotch:T,tooltipBackdrop:d,tooltipBlockTop:y,tooltipBlockRight:R,tooltipBlockBottom:H,tooltipBlockLeft:A,dir:Q}){const{appearance:N,theme:v,tooltipTargetParams:D,backdrop:J,backdropPadding:tt}=e,{bubblePlacement:F}=v,j=Yt,i=v.tooltipNotchSize,S=10,{width:M,height:B}=m.getBoundingClientRect(),P=o==="absolute"?w||1024:ct(Ft()),x=o==="absolute"?E||768:ct(Xt());let r=0,u=0,et="userflowjs-bubble__tooltip-notch",C="hidden",V=null,$=null,ot=null,nt=null,dt="userflowjs-tooltip-backdrop",K=null,jt=null,Pt=null,it=null,bt=null,at=null,lt=null,X=null,Ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",gt=null,wt=null,Tt="userflowjs-tooltip-block userflowjs-tooltip-block--right",Et=null,yt=null,Lt="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",vt=null,Bt=null,mt="userflowjs-tooltip-block userflowjs-tooltip-block--left",Nt=null,xt=null;switch(N){case L.BUBBLE:{F===O.TOP_LEFT||F===O.BOTTOM_LEFT?r=v.bubbleX:F===O.TOP_CENTER||F===O.CENTER||F===O.BOTTOM_CENTER?r=(P-M)/2:r=P-M-v.bubbleX,F===O.TOP_LEFT||F===O.TOP_CENTER||F===O.TOP_RIGHT?u=v.bubbleY:F===O.CENTER?u=(x-B)/2:u=x-B-v.bubbleY,Q==="rtl"&&(r=P-r-M),r=Math.max(0,Math.min(P-M,r)),u=Math.max(0,Math.min(x-B,u));break}case L.MODAL:{let g=j;v.avatarType!==ft.NONE&&(g+=v.avatarSize/2),r=j+(P-j*2-M)/2,u=g+(x-g-j-B)/2;break}case L.TOOLTIP:{let g;if(D){let{targetRect:n,viewportClipRect:U}=D;if(o==="absolute"){const _=l.offsetParent.getBoundingClientRect();U={top:0,right:P,bottom:x,left:0},n={top:n.top-_.top,right:n.right-_.left,bottom:n.bottom-_.top,left:n.left-_.left,width:n.width,height:n.height}}let st=0;if(J){const{paddingTop:_,paddingRight:Z,paddingBottom:pt,paddingLeft:z}=Je(tt);n={top:n.top-_,right:n.right+Z,bottom:n.bottom+pt,left:n.left-z,width:n.width+z+Z,height:n.height+_+pt},st=Math.min(_,Z,pt,z)}const k=n,Y=v.backdropHighlightType==je.OUTSIDE?v.backdropHighlightSpread:0;if(J&&Y&&(n={top:n.top-Y,right:n.right+Y,bottom:n.bottom+Y,left:n.left-Y,width:n.width+2*Y,height:n.height+2*Y}),g=Ze({targetRect:n,bubbleWidth:M,bubbleHeight:B,containerWidth:P,containerHeight:x,viewportClipRect:U,tooltipNotchSize:i,currentTooltipPlacement:e.tooltipPlacement,desiredTooltipPlacement:c}),g===f.BELOW||g===f.ABOVE?(r=n.left+n.width/2-M/2,r=Math.max(j,Math.min(P-M-j,r)),nt=Math.max(S,Math.min(M-S-i*2,n.left+n.width/2-i-r)),g===f.BELOW?V=-i*2:ot=-i*2):g===f.RIGHT?(r=n.right+i,r=Math.max(r,U.left+i),r=Math.min(r,U.right+i),r=Math.max(r,i),r=Math.min(r,P-M)):(r=n.left-i-M,r=Math.max(r,U.left-M-i),r=Math.min(r,U.right-M-i),r=Math.max(r,0),r=Math.min(r,P-M-i)),g===f.LEFT||g===f.RIGHT?(u=n.top+n.height/2-B/2,u=Math.max(j,Math.min(x-B-j,u)),V=Math.max(S,Math.min(B-S-i*2,n.top+n.height/2-i-u)),g===f.LEFT?$=-i*2:nt=-i*2):g===f.BELOW?(u=n.bottom+i,u=Math.max(u,U.top+i),u=Math.min(u,U.bottom+i),u=Math.max(u,i),u=Math.min(u,x-B)):(u=n.top-i-B,u=Math.max(u,U.top-B-i),u=Math.min(u,U.bottom-B-i),u=Math.max(u,0),u=Math.min(u,x-B-i)),J){const _=window.getComputedStyle(D.targetEl);K=Math.max(0,k.top),jt=Math.max(0,P-k.right),Pt=Math.max(0,x-k.bottom),it=Math.max(0,k.left),bt=Math.max(0,Ct(_.borderTopLeftRadius)+st),at=Math.max(0,Ct(_.borderTopRightRadius)+st),lt=Math.max(0,Ct(_.borderBottomRightRadius)+st),X=Math.max(0,Ct(_.borderBottomLeftRadius)+st),gt=Math.max(0,k.right),wt=Math.max(0,k.top),Et=Math.max(0,k.right),yt=Math.max(0,k.bottom),vt=Math.max(0,k.left),Bt=Math.max(0,k.bottom),Nt=Math.max(0,k.left),xt=Math.max(0,k.top)}}else g=c||f.BELOW,(g===f.BELOW||g===f.ABOVE)&&(nt=M/2-i,g===f.BELOW?V=-i*2:ot=-i*2),(g===f.LEFT||g===f.RIGHT)&&(V=B/2-i,g===f.LEFT?$=-i*2:nt=-i*2);e.tooltipPlacement=g,et+=` userflowjs-bubble__tooltip-notch--${g.toLowerCase()}`,C="",J&&(dt+=" userflowjs-tooltip-backdrop--visible",Ot+=" userflowjs-tooltip-block--visible",Tt+=" userflowjs-tooltip-block--visible",Lt+=" userflowjs-tooltip-block--visible",mt+=" userflowjs-tooltip-block--visible");break}}m.style.transition="";let St=r,Vt=u;if(t&&(m.style.opacity="0",N===L.TOOLTIP))switch(e.tooltipPlacement){case f.BELOW:u+=24;break;case f.ABOVE:u-=24;break;case f.RIGHT:r+=24;break;case f.LEFT:r-=24;break}if(o!=="relative"&&fe(m,r,u),T.className=et,T.style.visibility=C,b(T,"top",V),b(T,"right",$),b(T,"bottom",ot),b(T,"left",nt),d.className=dt,b(d,"top",K),b(d,"right",jt),b(d,"bottom",Pt),b(d,"left",it),b(d,"border-top-left-radius",bt),b(d,"border-top-right-radius",at),b(d,"border-bottom-right-radius",lt),b(d,"border-bottom-left-radius",X),y.className=Ot,b(y,"width",gt),b(y,"height",wt),R.className=Tt,b(R,"left",Et),b(R,"height",yt),H.className=Lt,b(H,"left",vt),b(H,"top",Bt),A.className=mt,b(A,"width",Nt),b(A,"top",xt),t){m.offsetWidth;const g="opacity 250ms linear";N===L.TOOLTIP?m.style.transition=`${g}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:m.style.transition=g,m.style.opacity="1",o!=="relative"&&fe(m,St,Vt)}}function Ze({targetRect:e,bubbleWidth:t,bubbleHeight:o,containerWidth:w,containerHeight:E,viewportClipRect:c,tooltipNotchSize:l,currentTooltipPlacement:m,desiredTooltipPlacement:T}){if(e.bottom<=c.top)return o+l<=E-c.top?f.BELOW:f.ABOVE;if(e.top>=c.bottom)return o+l<=c.bottom?f.ABOVE:f.BELOW;if(e.right<=c.left)return t+l<=w-c.left?f.RIGHT:f.LEFT;if(e.left>=c.right)return t+l<=c.right?f.LEFT:f.RIGHT;const d=R=>{const H=e.left+e.width/2,A=H>=c.left&&H<=c.right,Q=e.top+e.height/2,N=Q>=c.top&&Q<=c.bottom;switch(R){case f.BELOW:return E-e.bottom>o+l&&A;case f.ABOVE:return e.top>o+l&&A;case f.RIGHT:return w-e.right>t+l&&N;case f.LEFT:return e.left>t+l&&N}};if(T&&d(T))return T;if(m&&d(m))return m;const y=[{placement:f.BELOW,dist:e.top},{placement:f.ABOVE,dist:E-e.bottom},{placement:f.RIGHT,dist:e.left},{placement:f.LEFT,dist:w-e.right}];y.sort((R,H)=>R.dist-H.dist);for(const{placement:R}of y)if(d(R))return R;return f.BELOW}function b(e,t,o){o==null?e.style.removeProperty(t):e.style.setProperty(t,typeof o=="number"?o+"px":o,"important")}function fe(e,t,o){t=Math.round(t),o=Math.round(o),e.style.transform=`translate3d(${t}px, ${o}px, 0px)`}function qe(e){if(G.customScrollIntoView){G.customScrollIntoView(e);return}const{scrollPadding:t}=G;if(t&&Fe(e)===document.scrollingElement){const o=t.top||0,w=t.right||0,E=t.bottom||0,c=t.left||0;let l=0,m=0;const T=e.getBoundingClientRect(),d=Ft(),y=Xt();if(T.top<o?l=T.top-o:T.bottom>y-E&&(l=T.bottom-y+E),T.left<c?m=T.left-c:T.right>d-w&&(m=T.right-d+w),l!=0||m!=0){window.scrollBy({top:l,left:m,behavior:"smooth"});return}}try{e.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),e.scrollIntoView()}}function Je(e){if(!e||e==="0")return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const t=e.trim().split(" ");if(t.length===1){const o=ut(t[0]);return{paddingTop:o,paddingRight:o,paddingBottom:o,paddingLeft:o}}else if(t.length===2){const o=ut(t[0]),w=ut(t[1]);return{paddingTop:o,paddingRight:w,paddingBottom:o,paddingLeft:w}}else return{paddingTop:ut(t[0]),paddingRight:ut(t[1]),paddingBottom:ut(t[2]),paddingLeft:ut(t[3])}}function ut(e){const t=parseInt(e,10);return isNaN(t)?0:t}export{bo as B,mo as F};
3
3
  //# sourceMappingURL=FlowChrome.js.map
@@ -1,2 +1,2 @@
1
- import{R as t}from"./vendor.react.js";import{u as i}from"./client-context.js";import{f as a,w as r,N as n}from"./flow-host.styl.js";import{u as l,D as m}from"./stylesheets.js";import{U as c}from"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./userflow.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-condition-types.js";import"./vendor.date-fns.js";import"./roots.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="815d10f4-d5e5-48c3-a124-0cfc92e56b00",e._sentryDebugIdIdentifier="sentry-dbid-815d10f4-d5e5-48c3-a124-0cfc92e56b00")}catch{}})();const T=({notifications:e})=>{const{loaded:s}=l(window,a);return s?t.createElement("div",{className:"userflowjs-notifications",style:{zIndex:r(n)}},e.map(o=>t.createElement(d,{key:o.id,notification:o}))):null},d=({notification:e})=>{const s=i();return t.createElement("div",{className:"userflowjs-notifications__toast"},t.createElement("div",{className:"userflowjs-notifications__toast-content"},t.createElement("span",{className:"userflowjs-notifications__toast-label"},e.label),e.message),t.createElement("div",{className:"userflowjs-notifications__toast-dismiss",onClick:()=>s.dismissNotification(e.id)},t.createElement(m,{icon:c})))};export{T as NotificationsApp,T as default};
1
+ import{R as t}from"./vendor.react.js";import{u as a}from"./client-context.js";import{f as i,w as r,N as n}from"./flow-host.styl.js";import{u as l,D as m}from"./stylesheets.js";import{V as c}from"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./vendor.react-i18next.js";import"./userflow.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./flow-condition-types.js";import"./vendor.date-fns.js";import"./roots.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="ea1afe53-dbbe-4811-bbc0-c47b210d6a14",e._sentryDebugIdIdentifier="sentry-dbid-ea1afe53-dbbe-4811-bbc0-c47b210d6a14")}catch{}})();const T=({notifications:e})=>{const{loaded:s}=l(window,i);return s?t.createElement("div",{className:"userflowjs-notifications",style:{zIndex:r(n)}},e.map(o=>t.createElement(d,{key:o.id,notification:o}))):null},d=({notification:e})=>{const s=a();return t.createElement("div",{className:"userflowjs-notifications__toast"},t.createElement("div",{className:"userflowjs-notifications__toast-content"},t.createElement("span",{className:"userflowjs-notifications__toast-label"},e.label),e.message),t.createElement("div",{className:"userflowjs-notifications__toast-dismiss",onClick:()=>s.dismissNotification(e.id)},t.createElement(m,{icon:c})))};export{T as NotificationsApp,T as default};
2
2
  //# sourceMappingURL=NotificationsApp.js.map