userflow.js-self-hosted 0.1.1008420 → 0.1.1008494

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/BuilderBar.js CHANGED
@@ -1,2 +1,2 @@
1
- import{R as e,r as t}from"./vendor.react.js";import{u as I,F as v}from"./use-window-resize.js";import{S as F}from"./logomark.js";import{o as L}from"./vendor.obj-str.js";import{f as k,a as B}from"./vendor.fortawesome.pro-light-svg-icons.js";import{m as b}from"./userflow.js";import{a as D,D as N}from"./stylesheets.js";import"./vendor.html-parse-stringify2.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[n]="154a4719-afc9-4bf7-ad8c-db42f702d609",r._sentryDebugIdIdentifier="sentry-dbid-154a4719-afc9-4bf7-ad8c-db42f702d609")}catch{}})();const _=new URL("builder-ui-host.css",import.meta.url).href,P=new URL("builder-ui-frame.css",import.meta.url).href,p="builderBarPos",O=e.forwardRef(({onReadyChange:r,children:n,buttons:m},y)=>{const{loaded:h}=D(window,_),[E,S]=t.useState(!1),o=h&&E,u=t.useRef(!1);t.useEffect(()=>{o&&!u.current&&r&&(u.current=!0,r(!0))},[o,r]);const i=t.useRef(null),[s,g]=t.useState(null),[l,w]=t.useState(()=>b.getItem(p)==="top"?"top":"bottom"),R=t.useCallback(a=>{w(a),b.setItem(p,a)},[]),d=t.useRef(0),f=t.useCallback(()=>{const a=i.current;if(!a||!s||!o)return;const c=s.clientHeight;c!==d.current&&(d.current=c,a.style.setProperty("height",c+"px","important"))},[o,s]);return t.useLayoutEffect(()=>{f()}),I(f),t.useImperativeHandle(y,()=>({getFrame:()=>i.current,getRootEl:()=>s}),[s]),e.createElement(e.Fragment,null,e.createElement(v,{className:L({"userflowjs-builder-bar":!0,"userflowjs-builder-bar--top":l==="top"}),style:{visibility:o?void 0:"hidden",animation:o?void 0:"none"},elRef:i,stylesheet:P,onStylesheetsLoad:S,title:"Builder bar"},o&&e.createElement("div",{className:"root",ref:g},e.createElement("div",{className:"logomark"},e.createElement(F,null)),e.createElement("div",{className:"main"},n),e.createElement("div",{className:"buttons"},m,e.createElement("button",{key:l,className:"btn btn--square btn--plain-on-dark",onClick:()=>R(l==="top"?"bottom":"top")},e.createElement(N,{icon:l==="top"?k:B,size:20}))))))});export{O as B};
1
+ import{R as e,r as t}from"./vendor.react.js";import{u as I,F as v}from"./use-window-resize.js";import{S as F}from"./logomark.js";import{o as L}from"./vendor.obj-str.js";import{f as k,a as B}from"./vendor.fortawesome.pro-light-svg-icons.js";import{n as b}from"./userflow.js";import{a as D,D as N}from"./stylesheets.js";import"./vendor.html-parse-stringify2.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[n]="18709ad3-5fe6-4c9a-bccb-9b4727f2164e",r._sentryDebugIdIdentifier="sentry-dbid-18709ad3-5fe6-4c9a-bccb-9b4727f2164e")}catch{}})();const _=new URL("builder-ui-host.css",import.meta.url).href,P=new URL("builder-ui-frame.css",import.meta.url).href,p="builderBarPos",O=e.forwardRef(({onReadyChange:r,children:n,buttons:u},y)=>{const{loaded:h}=D(window,_),[E,S]=t.useState(!1),o=h&&E,m=t.useRef(!1);t.useEffect(()=>{o&&!m.current&&r&&(m.current=!0,r(!0))},[o,r]);const i=t.useRef(null),[s,g]=t.useState(null),[l,w]=t.useState(()=>b.getItem(p)==="top"?"top":"bottom"),R=t.useCallback(a=>{w(a),b.setItem(p,a)},[]),f=t.useRef(0),d=t.useCallback(()=>{const a=i.current;if(!a||!s||!o)return;const c=s.clientHeight;c!==f.current&&(f.current=c,a.style.setProperty("height",c+"px","important"))},[o,s]);return t.useLayoutEffect(()=>{d()}),I(d),t.useImperativeHandle(y,()=>({getFrame:()=>i.current,getRootEl:()=>s}),[s]),e.createElement(e.Fragment,null,e.createElement(v,{className:L({"userflowjs-builder-bar":!0,"userflowjs-builder-bar--top":l==="top"}),style:{visibility:o?void 0:"hidden",animation:o?void 0:"none"},elRef:i,stylesheet:P,onStylesheetsLoad:S,title:"Builder bar"},o&&e.createElement("div",{className:"root",ref:g},e.createElement("div",{className:"logomark"},e.createElement(F,null)),e.createElement("div",{className:"main"},n),e.createElement("div",{className:"buttons"},u,e.createElement("button",{key:l,className:"btn btn--square btn--plain-on-dark",onClick:()=>R(l==="top"?"bottom":"top")},e.createElement(N,{icon:l==="top"?k:B,size:20}))))))});export{O as B};
2
2
  //# sourceMappingURL=BuilderBar.js.map
package/ChecklistApp.js CHANGED
@@ -1,2 +1,2 @@
1
- import{r as s,R as c}from"./vendor.react.js";import{q as b,p as R,o as F,g as B}from"./userflow.js";import{F as _}from"./FlowChrome.js";import{i as N,u as C}from"./client-context.js";import{f as D,w as P,C as j,S as U}from"./flow-host.styl.js";import{a as A,D as H,u as I}from"./stylesheets.js";import{F as O}from"./use-window-resize.js";import{o as Z}from"./vendor.obj-str.js";import{z}from"./flow-condition-types.js";import{l as W}from"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.html-parse-stringify2.js";import{u as X}from"./vendor.react-i18next.js";import{C as M}from"./ChecklistUI.js";import{B as Y}from"./BubbleToolbar.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./bubble-frame.styl.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./logomark.js";import"./use-selector-element-monitoring.js";import"./vendor.i18next.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="9c76d2d4-d224-495f-ba12-03d9eda06ed6",t._sentryDebugIdIdentifier="sentry-dbid-9c76d2d4-d224-495f-ba12-03d9eda06ed6")}catch{}})();const G=new URL("checklist-launcher-frame.css",import.meta.url).href,K=({position:t,theme:e,onClick:l,onVisibleChange:o,buttonRef:a,text:u,uncompletedCount:r})=>{const d=t||"absolute",{i18n:n}=X(),m=n.dir(),{loaded:i}=A(window,D,e),[h,k]=s.useState(!1),f=i&&h;s.useEffect(()=>{o&&o(f)},[o,f]);const w=s.useRef(null),L=s.useRef(0),[v,S]=s.useState(null);s.useLayoutEffect(()=>{const E=w.current;if(!E||!v)return;const y=v.clientWidth;y!==L.current&&(L.current=y,E.style.setProperty("width",z(y)+"px","important"),E.style.setProperty("height",e.checklistLauncherHeight+"px","important"))});const p=e.checklistLauncherPlacement,x=p===b.TOP_LEFT||p===b.TOP_RIGHT,g=p===b.TOP_LEFT||p===b.BOTTOM_LEFT,T={zIndex:d==="fixed"?e.checklistZIndex!=null?e.checklistZIndex:P(j):1,top:x?e.checklistLauncherY+"px":void 0,bottom:x?void 0:e.checklistLauncherY+"px",[m==="ltr"?"left":"right"]:g?e.checklistLauncherX+"px":void 0,[m==="ltr"?"right":"left"]:g?void 0:e.checklistLauncherX+"px",height:e.checklistLauncherHeight+"px",borderRadius:e.checklistLauncherBorderRadius+"px",position:f?void 0:"absolute",visibility:f?void 0:"hidden",animation:f?void 0:"none"};return c.createElement(O,{elRef:w,testId:"checklist-launcher-app",className:Z({"userflowjs-checklist-launcher":!0,[`userflowjs-checklist-launcher--position-${d}`]:!0}),style:T,stylesheet:G,theme:e,onStylesheetsLoad:k,title:"Checklist launcher"},c.createElement("button",{ref:a,className:"userflowjs-checklist-launcher-frame-root",onClick:l},c.createElement("div",{ref:S,className:"userflowjs-checklist-launcher-content"},c.createElement("div",{className:"userflowjs-checklist-launcher-text"},u||"Get Started"),c.createElement("div",{"data-testid":"checklist-launcher-uncompleted-count",className:"userflowjs-checklist-launcher-uncompleted-count"},r===0?c.createElement(H,{icon:W}):r,c.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")))))},xe=({session:t,checklistExpanded:e})=>{const{version:l}=t,o=l.checklist,a=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;s.useEffect(()=>{N.changeLanguage(a)},[a]);const[u,r]=s.useState(!1);return e?c.createElement(q,{session:t,initialAutoFocus:u,setInitialAutoFocus:r}):o.launcherEnabled?c.createElement(V,{session:t,initialAutoFocus:u,setInitialAutoFocus:r}):null},q=({session:t,initialAutoFocus:e,setInitialAutoFocus:l})=>{const o=C(),[a,u]=s.useState(null),{version:r}=t,d=r.checklist,n=I(r.theme),m=s.useMemo(()=>({...n,avatarType:R.NONE,bubblePlacement:n.checklistPlacement,bubbleX:n.checklistX,bubbleY:n.checklistY,bubbleWidth:n.checklistWidth}),[n]);return s.useEffect(()=>{const i=a?.ownerDocument.defaultView;if(!i)return;const h=k=>{k.key==="Escape"&&(l(!0),o.hideChecklist())};return i.addEventListener("keydown",h),()=>i.removeEventListener("keydown",h)},[a,l,o]),c.createElement(U,null,c.createElement(_,{company:t.flow.company,theme:m,position:"fixed",stepAppearance:F.BUBBLE,zIndex:n.checklistZIndex,autoHide3pEnabled:!0,backgroundImageUrl:d.backgroundAsset&&d.backgroundAsset.assetUrl,bubbleFrameRootRef:u},c.createElement("div",{role:"dialog","aria-label":"Checklist"},c.createElement(M,{session:t,initialAutoFocus:e}),c.createElement(Y,{draftMode:t.draftMode,minimize:i=>{l(i.detail===0),o.hideChecklist()}}))))},V=({session:t,initialAutoFocus:e,setInitialAutoFocus:l})=>{const o=C(),[a,u]=s.useState(!1),[r,d]=s.useState(null),{version:n}=t,m=n.checklist,i=I(n.theme);return s.useEffect(()=>{!a||!r||!e||r.focus()},[o,r,a,e]),c.createElement(K,{position:"fixed",theme:i,onClick:h=>{l(h.detail===0),o.showChecklist()},onVisibleChange:u,buttonRef:d,text:m.launcherText,uncompletedCount:B(t)})};export{xe as ChecklistApp,xe as default};
1
+ import{r as s,R as c}from"./vendor.react.js";import{q as k,p as R,k as F,g as B}from"./userflow.js";import{F as _}from"./FlowChrome.js";import{i as N,u as C}from"./client-context.js";import{f as D,w as P,C as j,S as U}from"./flow-host.styl.js";import{a as A,D as H,u as I}from"./stylesheets.js";import{F as O}from"./use-window-resize.js";import{o as Z}from"./vendor.obj-str.js";import{z}from"./flow-condition-types.js";import{l as W}from"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.html-parse-stringify2.js";import{u as X}from"./vendor.react-i18next.js";import{C as M}from"./ChecklistUI.js";import{B as Y}from"./BubbleToolbar.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./bubble-frame.styl.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./logomark.js";import"./use-selector-element-monitoring.js";import"./vendor.i18next.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="3970f19f-809c-4d08-9df4-c2c9fa7abc83",t._sentryDebugIdIdentifier="sentry-dbid-3970f19f-809c-4d08-9df4-c2c9fa7abc83")}catch{}})();const G=new URL("checklist-launcher-frame.css",import.meta.url).href,K=({position:t,theme:e,onClick:l,onVisibleChange:r,buttonRef:a,text:u,uncompletedCount:o})=>{const d=t||"absolute",{i18n:n}=X(),m=n.dir(),{loaded:i}=A(window,D,e),[h,b]=s.useState(!1),f=i&&h;s.useEffect(()=>{r&&r(f)},[r,f]);const w=s.useRef(null),L=s.useRef(0),[v,S]=s.useState(null);s.useLayoutEffect(()=>{const E=w.current;if(!E||!v)return;const y=v.clientWidth;y!==L.current&&(L.current=y,E.style.setProperty("width",z(y)+"px","important"),E.style.setProperty("height",e.checklistLauncherHeight+"px","important"))});const p=e.checklistLauncherPlacement,x=p===k.TOP_LEFT||p===k.TOP_RIGHT,g=p===k.TOP_LEFT||p===k.BOTTOM_LEFT,T={zIndex:d==="fixed"?e.checklistZIndex!=null?e.checklistZIndex:P(j):1,top:x?e.checklistLauncherY+"px":void 0,bottom:x?void 0:e.checklistLauncherY+"px",[m==="ltr"?"left":"right"]:g?e.checklistLauncherX+"px":void 0,[m==="ltr"?"right":"left"]:g?void 0:e.checklistLauncherX+"px",height:e.checklistLauncherHeight+"px",borderRadius:e.checklistLauncherBorderRadius+"px",position:f?void 0:"absolute",visibility:f?void 0:"hidden",animation:f?void 0:"none"};return c.createElement(O,{elRef:w,testId:"checklist-launcher-app",className:Z({"userflowjs-checklist-launcher":!0,[`userflowjs-checklist-launcher--position-${d}`]:!0}),style:T,stylesheet:G,theme:e,onStylesheetsLoad:b,title:"Checklist launcher"},c.createElement("button",{ref:a,className:"userflowjs-checklist-launcher-frame-root",onClick:l},c.createElement("div",{ref:S,className:"userflowjs-checklist-launcher-content"},c.createElement("div",{className:"userflowjs-checklist-launcher-text"},u||"Get Started"),c.createElement("div",{"data-testid":"checklist-launcher-uncompleted-count",className:"userflowjs-checklist-launcher-uncompleted-count"},o===0?c.createElement(H,{icon:W}):o,c.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")))))},xe=({session:t,checklistExpanded:e})=>{const{version:l}=t,r=l.checklist,a=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;s.useEffect(()=>{N.changeLanguage(a)},[a]);const[u,o]=s.useState(!1);return e?c.createElement(q,{session:t,initialAutoFocus:u,setInitialAutoFocus:o}):r.launcherEnabled?c.createElement(V,{session:t,initialAutoFocus:u,setInitialAutoFocus:o}):null},q=({session:t,initialAutoFocus:e,setInitialAutoFocus:l})=>{const r=C(),[a,u]=s.useState(null),{version:o}=t,d=o.checklist,n=I(o.theme),m=s.useMemo(()=>({...n,avatarType:R.NONE,bubblePlacement:n.checklistPlacement,bubbleX:n.checklistX,bubbleY:n.checklistY,bubbleWidth:n.checklistWidth}),[n]);return s.useEffect(()=>{const i=a?.ownerDocument.defaultView;if(!i)return;const h=b=>{b.key==="Escape"&&(l(!0),r.hideChecklist())};return i.addEventListener("keydown",h),()=>i.removeEventListener("keydown",h)},[a,l,r]),c.createElement(U,null,c.createElement(_,{company:t.flow.company,theme:m,position:"fixed",stepAppearance:F.BUBBLE,zIndex:n.checklistZIndex,autoHide3pEnabled:!0,backgroundImageUrl:d.backgroundAsset&&d.backgroundAsset.assetUrl,bubbleFrameRootRef:u},c.createElement("div",{role:"dialog","aria-label":"Checklist"},c.createElement(M,{session:t,initialAutoFocus:e}),c.createElement(Y,{draftMode:t.draftMode,minimize:i=>{l(i.detail===0),r.hideChecklist()}}))))},V=({session:t,initialAutoFocus:e,setInitialAutoFocus:l})=>{const r=C(),[a,u]=s.useState(!1),[o,d]=s.useState(null),{version:n}=t,m=n.checklist,i=I(n.theme);return s.useEffect(()=>{!a||!o||!e||o.focus()},[r,o,a,e]),c.createElement(K,{position:"fixed",theme:i,onClick:h=>{l(h.detail===0),r.showChecklist()},onVisibleChange:u,buttonRef:d,text:m.launcherText,uncompletedCount:B(t)})};export{xe as ChecklistApp,xe as default};
2
2
  //# sourceMappingURL=ChecklistApp.js.map
package/ChecklistUI.js CHANGED
@@ -1,2 +1,2 @@
1
- import{R as e,r as a}from"./vendor.react.js";import{E as R,m as I}from"./userflow.js";import{u as v}from"./client-context.js";import"./vendor.html-parse-stringify2.js";import{u as D}from"./vendor.react-i18next.js";import{o as F}from"./vendor.obj-str.js";import{D as C}from"./stylesheets.js";import{a as P,b as U}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{h as L,a as y,r as O,R as B}from"./bubble-frame.styl.js";import{b as j}from"./flow-condition-types.js";import{b as M,e as H}from"./vendor.fortawesome.pro-regular-svg-icons.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]="cd8723a2-c7f1-44b2-a5bc-ce84210de4db",t._sentryDebugIdIdentifier="sentry-dbid-cd8723a2-c7f1-44b2-a5bc-ce84210de4db")}catch{}})();const $=e.forwardRef(({elProps:t,onClick:n,onCheckmarkClick:o,completed:s,disabled:i,name:c,text:b,active:d,htmlAttributes:r,children:u},w)=>{const m=a.useRef(s);return e.createElement("button",{...t,ref:w,"data-testid":"bubble-task",tabIndex:n?0:-1,className:F({"userflowjs-bubble-task":!0,"userflowjs-bubble-task--completed":!!s,"userflowjs-bubble-task--just-completed":!m.current&&!!s,"userflowjs-bubble-task--disabled":!s&&!!i,"userflowjs-bubble-task--clickable":!!n,"userflowjs-bubble-task--active":!!d}),onClick:n,...r},e.createElement("div",{className:"userflowjs-bubble-task__checkmark",onClick:o},s&&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"},!s&&e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(C,{icon:U}))),u)}),z=({task:t,previousTasksCompleted:n})=>{const o=v(),{session:s}=S(),i=s.version.checklist,[c,b]=a.useState(()=>o.taskIsUnacked(t.cvid));a.useEffect(()=>{if(!c)return;const m=window.setTimeout(()=>b(!1),500);return()=>window.clearTimeout(m)},[c]);const d=s.taskCompletions.some(({taskCvid:m})=>m===t.cvid),r=!c&&d;a.useEffect(()=>{r&&o.ackCompletedTask(t.cvid)},[o,r,t.cvid]);const u=i.completeInOrder&&!n,w=u||t.actions.length===0&&r?void 0:()=>{o.send({kind:"ClickChecklistTask",sessionId:s.id,taskCvid:t.cvid},{batch:!0}),t.actions.length>0&&(r||!t.completesOnClick)&&o.hideChecklist(),L(o,s,t.actions)};return e.createElement($,{onClick:w,name:e.createElement(y,{doc:t.name,lookupAttribute:j(s.data)}),text:e.createElement(y,{doc:t.text,lookupAttribute:j(s.data)}),completed:r,disabled:u})},G=({completedCount:t,taskCount:n})=>{const o=n===0?0:Math.min(100,Math.round(t/n*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"},o,"%")),e.createElement("div",{className:"userflowjs-bubble-checklist-progress-fill",style:{width:`${o}%`}},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},o,"%")))},J=()=>{const{t}=D(),n=v(),o=S(),{session:s}=o,{version:i}=s,c=i.checklist,{dispatch:b}=q(),d=s.taskCompletions.length,r=c.tasks.length,u=d===r;let w=!0,m=c.tasks,h=[],p=o.currentSectionName,g=!1;if(c.sectionsEnabled){let f=null;const k=Array.from(c.tasks).sort((l,E)=>l.sectionName.localeCompare(E.sectionName));for(const l of k)l.sectionName!==f&&(h.push(l.sectionName),f=l.sectionName);(!p||!h.includes(p))&&(p=h[0]),m=k.filter(l=>l.sectionName===p),g=m.some(l=>{const E=s.taskCompletions.some(({taskCvid:A})=>A===l.cvid);return l.blocksNextSection&&!E})}const N=p==null?-1:h.indexOf(p),x=f=>{const k=N+f;if(k>=0&&k<=h.length-1){const l=h[k];I.setItem("currentChecklistSectionName:"+s.id,l),b({kind:"setCurrentSection",sectionName:l})}};return e.createElement(e.Fragment,null,!O(c.content)&&e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement(B,{doc:c.content,lookupAttribute:j(s.data)})),e.createElement(G,{completedCount:d,taskCount:r}),c.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-name"},p||"First section"),e.createElement("div",{className:"userflowjs-bubble-tasks"},m.map(f=>{const k=w;return s.taskCompletions.some(({taskCvid:E})=>E===f.cvid)||(w=!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:()=>x(-1),disabled:N<=0},e.createElement(C,{icon:M}),e.createElement("span",null,t("checklist.previousSection"))),e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>x(1),disabled:N>=h.length-1||g},e.createElement("span",null,t("checklist.nextSection")),e.createElement(C,{icon:H}))),!i.closeDisabled&&e.createElement("div",{className:"userflowjs-bubble-dismiss-row"},e.createElement("button",{className:F({"userflowjs-bubble-dismiss-button":!0,"userflowjs-bubble-dismiss-button--completed":u}),onClick:()=>u?n.endFlow(s,{endReason:R.USER_CLOSED}):b({kind:"showClose"})},t("checklistDismiss.button"))))},K=()=>{const{t}=D(),n=v(),{dispatch:o}=q(),{session:s}=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:()=>n.endFlow(s,{endReason:R.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:()=>o({kind:"showFlow"})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},t("checklistDismiss.cancel")))))};function Q(t){const n=t?.querySelector(".userflowjs-bubble-task--clickable:not(.userflowjs-bubble-task--completed)")||t?.querySelector(".userflowjs-bubble-task--clickable")||t?.querySelector('button:not([tabIndex="-1"])');n&&typeof n.focus=="function"&&n.focus()}const re=({session:t,initialAutoFocus:n})=>{const o=v(),s=a.useRef(null),[i,c]=a.useReducer(W,void 0,()=>({...V,session:t,currentSectionName:I.getItem("currentChecklistSectionName:"+t.id),autoFocusRequested:!!n})),{session:b,contentType:d}=i;a.useEffect(()=>{b!==t&&c({kind:"updateSession",session:t})},[b,t]);const r=a.useMemo(()=>({dispatch:c}),[c]);return a.useEffect(()=>{if(!i.autoFocusRequested)return;const u=s.current;u&&Q(u),c({kind:"autoFocused"})},[o,i.autoFocusRequested]),e.createElement(T.Provider,{value:r},e.createElement(_.Provider,{value:i},e.createElement("div",{ref:s},d==="close"?e.createElement(K,null):e.createElement(J,null))))},V={contentType:"flow"};function W(t,n){switch(n.kind){case"updateSession":return{...t,session:n.session};case"showFlow":return{...t,contentType:"flow",autoFocusRequested:!0};case"showClose":return{...t,contentType:"close",autoFocusRequested:!0};case"setCurrentSection":return{...t,currentSectionName:n.sectionName};case"autoFocused":return{...t,autoFocusRequested:!1}}}const T=a.createContext(null),_=a.createContext(null);function q(){return a.useContext(T)}function S(){return a.useContext(_)}export{re as C,Q as f};
1
+ import{R as e,r as a}from"./vendor.react.js";import{E as R,n as I}from"./userflow.js";import{u as v}from"./client-context.js";import"./vendor.html-parse-stringify2.js";import{u as D}from"./vendor.react-i18next.js";import{o as F}from"./vendor.obj-str.js";import{D as C}from"./stylesheets.js";import{a as P,b as U}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{h as L,a as y,r as O,R as B}from"./bubble-frame.styl.js";import{b as j}from"./flow-condition-types.js";import{b as M,e as H}from"./vendor.fortawesome.pro-regular-svg-icons.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]="09f7d271-82d2-4012-a80a-99a753a66933",t._sentryDebugIdIdentifier="sentry-dbid-09f7d271-82d2-4012-a80a-99a753a66933")}catch{}})();const $=e.forwardRef(({elProps:t,onClick:n,onCheckmarkClick:o,completed:s,disabled:i,name:c,text:b,active:d,htmlAttributes:r,children:u},w)=>{const m=a.useRef(s);return e.createElement("button",{...t,ref:w,"data-testid":"bubble-task",tabIndex:n?0:-1,className:F({"userflowjs-bubble-task":!0,"userflowjs-bubble-task--completed":!!s,"userflowjs-bubble-task--just-completed":!m.current&&!!s,"userflowjs-bubble-task--disabled":!s&&!!i,"userflowjs-bubble-task--clickable":!!n,"userflowjs-bubble-task--active":!!d}),onClick:n,...r},e.createElement("div",{className:"userflowjs-bubble-task__checkmark",onClick:o},s&&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"},!s&&e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(C,{icon:U}))),u)}),z=({task:t,previousTasksCompleted:n})=>{const o=v(),{session:s}=S(),i=s.version.checklist,[c,b]=a.useState(()=>o.taskIsUnacked(t.cvid));a.useEffect(()=>{if(!c)return;const m=window.setTimeout(()=>b(!1),500);return()=>window.clearTimeout(m)},[c]);const d=s.taskCompletions.some(({taskCvid:m})=>m===t.cvid),r=!c&&d;a.useEffect(()=>{r&&o.ackCompletedTask(t.cvid)},[o,r,t.cvid]);const u=i.completeInOrder&&!n,w=u||t.actions.length===0&&r?void 0:()=>{o.send({kind:"ClickChecklistTask",sessionId:s.id,taskCvid:t.cvid},{batch:!0}),t.actions.length>0&&(r||!t.completesOnClick)&&o.hideChecklist(),L(o,s,t.actions)};return e.createElement($,{onClick:w,name:e.createElement(y,{doc:t.name,lookupAttribute:j(s.data)}),text:e.createElement(y,{doc:t.text,lookupAttribute:j(s.data)}),completed:r,disabled:u})},G=({completedCount:t,taskCount:n})=>{const o=n===0?0:Math.min(100,Math.round(t/n*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"},o,"%")),e.createElement("div",{className:"userflowjs-bubble-checklist-progress-fill",style:{width:`${o}%`}},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},o,"%")))},J=()=>{const{t}=D(),n=v(),o=S(),{session:s}=o,{version:i}=s,c=i.checklist,{dispatch:b}=q(),d=s.taskCompletions.length,r=c.tasks.length,u=d===r;let w=!0,m=c.tasks,h=[],p=o.currentSectionName,g=!1;if(c.sectionsEnabled){let f=null;const k=Array.from(c.tasks).sort((l,E)=>l.sectionName.localeCompare(E.sectionName));for(const l of k)l.sectionName!==f&&(h.push(l.sectionName),f=l.sectionName);(!p||!h.includes(p))&&(p=h[0]),m=k.filter(l=>l.sectionName===p),g=m.some(l=>{const E=s.taskCompletions.some(({taskCvid:A})=>A===l.cvid);return l.blocksNextSection&&!E})}const N=p==null?-1:h.indexOf(p),x=f=>{const k=N+f;if(k>=0&&k<=h.length-1){const l=h[k];I.setItem("currentChecklistSectionName:"+s.id,l),b({kind:"setCurrentSection",sectionName:l})}};return e.createElement(e.Fragment,null,!O(c.content)&&e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement(B,{doc:c.content,lookupAttribute:j(s.data)})),e.createElement(G,{completedCount:d,taskCount:r}),c.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-name"},p||"First section"),e.createElement("div",{className:"userflowjs-bubble-tasks"},m.map(f=>{const k=w;return s.taskCompletions.some(({taskCvid:E})=>E===f.cvid)||(w=!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:()=>x(-1),disabled:N<=0},e.createElement(C,{icon:M}),e.createElement("span",null,t("checklist.previousSection"))),e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>x(1),disabled:N>=h.length-1||g},e.createElement("span",null,t("checklist.nextSection")),e.createElement(C,{icon:H}))),!i.closeDisabled&&e.createElement("div",{className:"userflowjs-bubble-dismiss-row"},e.createElement("button",{className:F({"userflowjs-bubble-dismiss-button":!0,"userflowjs-bubble-dismiss-button--completed":u}),onClick:()=>u?n.endFlow(s,{endReason:R.USER_CLOSED}):b({kind:"showClose"})},t("checklistDismiss.button"))))},K=()=>{const{t}=D(),n=v(),{dispatch:o}=q(),{session:s}=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:()=>n.endFlow(s,{endReason:R.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:()=>o({kind:"showFlow"})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},t("checklistDismiss.cancel")))))};function Q(t){const n=t?.querySelector(".userflowjs-bubble-task--clickable:not(.userflowjs-bubble-task--completed)")||t?.querySelector(".userflowjs-bubble-task--clickable")||t?.querySelector('button:not([tabIndex="-1"])');n&&typeof n.focus=="function"&&n.focus()}const re=({session:t,initialAutoFocus:n})=>{const o=v(),s=a.useRef(null),[i,c]=a.useReducer(W,void 0,()=>({...V,session:t,currentSectionName:I.getItem("currentChecklistSectionName:"+t.id),autoFocusRequested:!!n})),{session:b,contentType:d}=i;a.useEffect(()=>{b!==t&&c({kind:"updateSession",session:t})},[b,t]);const r=a.useMemo(()=>({dispatch:c}),[c]);return a.useEffect(()=>{if(!i.autoFocusRequested)return;const u=s.current;u&&Q(u),c({kind:"autoFocused"})},[o,i.autoFocusRequested]),e.createElement(T.Provider,{value:r},e.createElement(_.Provider,{value:i},e.createElement("div",{ref:s},d==="close"?e.createElement(K,null):e.createElement(J,null))))},V={contentType:"flow"};function W(t,n){switch(n.kind){case"updateSession":return{...t,session:n.session};case"showFlow":return{...t,contentType:"flow",autoFocusRequested:!0};case"showClose":return{...t,contentType:"close",autoFocusRequested:!0};case"setCurrentSection":return{...t,currentSectionName:n.sectionName};case"autoFocused":return{...t,autoFocusRequested:!1}}}const T=a.createContext(null),_=a.createContext(null);function q(){return a.useContext(T)}function S(){return a.useContext(_)}export{re as C,Q as f};
2
2
  //# sourceMappingURL=ChecklistUI.js.map
package/FlowApp.js CHANGED
@@ -1,6 +1,6 @@
1
- import{R as o,r as f}from"./vendor.react.js";import{E as k,V as L,k as ce,l as ue,T as O,m as F,n as de,o as R,p as pe,M as fe,U as Y}from"./userflow.js";import"./vendor.html-parse-stringify2.js";import{u as x}from"./vendor.react-i18next.js";import{B as G}from"./BubbleToolbar.js";import{m as me,d as Q,R as be,i as Ee,g as ge,u as we,c as H,h as he,S as Te}from"./bubble-frame.styl.js";import{b as X,z as ve,a as Se,l as K,r as ye}from"./flow-condition-types.js";import{u as I,i as ke}from"./client-context.js";import{F as De}from"./FlowChrome.js";import{u as Ne,r as Re}from"./use-selector-element-monitoring.js";import{a as Z,S as Ie}from"./flow-host.styl.js";import{f as Me}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Ae,u as Be}from"./stylesheets.js";import{T as Fe}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.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]="921c317b-9c8a-4614-a1d0-b2c0eb2239f9",e._sentryDebugIdIdentifier="sentry-dbid-921c317b-9c8a-4614-a1d0-b2c0eb2239f9")}catch{}})();const Ce=()=>{const{t:e}=x(),s=I(),{dispatch:t,restart:n}=A(),{session:a,step:d}=y(),l="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return o.createElement("div",{role:"dialog","aria-modal":M(d)?"true":void 0,"aria-label":"Guide menu"},o.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),o.createElement("button",{className:l,onClick:()=>s.endFlow(a,{endReason:k.USER_CLOSED})},e("menu.close")),a.version.restartEnabled&&o.createElement("button",{className:l,onClick:n},e("menu.restart")),o.createElement("button",{className:l,onClick:()=>t({kind:"showFlow"})},e("menu.back")))},W=({progress:e,type:s,position:t,totalSteps:n})=>{const{t:a}=x(),d=parseFloat(e||"0"),l={width:`${d*100}%`},c=s==="DEFAULT"?"TOP":t,u=`userflowjs-bubble-progress-${s||"DEFAULT"}`,m=c==="BOTTOM"?" userflowjs-bubble-progress-bottom":"",i=["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW"].includes(s)?`userflowjs-bubble-progress-CHAINED ${s==="CHAINED_SQUARED"?"userflowjs-bubble-progress-CHAINED_SQUARED":s==="CHAINED_ROUNDED"?"userflowjs-bubble-progress-CHAINED_ROUNDED":s==="DOTTED"?"userflowjs-bubble-progress-DOTTED":"userflowjs-bubble-progress-NARROW"}${m}`:`${u}${m}`,r=s==="NUMBERED"?3:n||0,E=Math.min(Math.floor(d*r),r);return o.createElement("div",null,["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED"].includes(s)&&o.createElement("div",{className:i},Array.from({length:3}).map((b,w)=>o.createElement("div",{key:w,className:`rounded ${w<Math.floor(d*3)?"completed":""}`}))),s==="NARROW"&&o.createElement("div",{className:i},o.createElement("div",{className:"linear-progress-bar"},o.createElement("div",{className:"linear-progress-fill",style:l}))),s==="NUMBERED"&&o.createElement("div",{className:i},o.createElement("span",{className:"numbered-progress"},a("of",{replace:{range:r,selected:E}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&o.createElement("div",{className:`${i} ${c==="BOTTOM"?"bottom":""}`},o.createElement("div",{className:"userflowjs-bubble-progress__fill",style:l})))};var J=(e=>(e.BOTTOM="BOTTOM",e.TOP="TOP",e))(J||{});const Le=({theme:e})=>{const s=I(),{session:t,step:n,muted:a,shouldLabelDialog:d}=y(),{version:l}=t,{dispatch:c}=A(),u=l.steps[0],m=u&&u.id===n.id,i=m&&n.progress==="1",r=f.useMemo(()=>n.content&&me(Q(n.content),{buttons:n.buttons,questions:n.questions}),[n.content,n.buttons,n.questions]),E=l.steps.findIndex(h=>h.id===n.id),b=l.steps.length,w=b>0?((E+1)/b).toString():"0";return o.createElement("div",{key:n.id,role:"alertdialog","aria-modal":M(n)?"true":void 0,"aria-label":d?"Guide":void 0},!i&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&o.createElement(W,{progress:w,type:e.progressBarType,totalSteps:l.steps.length}),o.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},o.createElement(be,{doc:r,lookupAttribute:X(t.data),buttons:n.buttons,questions:n.questions})),o.createElement(G,{draftMode:t.draftMode,muted:a,toggleMuted:e.voiceType!==L.NONE?()=>c({kind:"toggleMuted"}):void 0,close:l.closeDisabled?void 0:()=>e.flowXButtonBehavior===ce.DISMISS||m?s.endFlow(t,{endReason:k.USER_CLOSED}):c({kind:"showMenu"})}),!i&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&o.createElement(W,{progress:w,type:e.progressBarType,position:J.BOTTOM,totalSteps:l.steps.length}))};function Oe(e,s){if(!e)return"";typeof e=="string"&&(e=Q(e));const t=[],n=/[.!?;,]$/;function a(){const c=(t[t.length-1]||"").trim();c&&!c.match(n)&&t.push(".")}function d(c){if(Ee(c)){if(c.text&&!c.silent){const u=c.text.split(`
2
- `);u.forEach((m,i)=>{t.push(m),i<u.length-1&&(a(),t.push(`
3
- `))})}return}switch(c.type){case"attribute":{const u=ge(c,s);u&&t.push(u);break}default:l(c.children),["link"].includes(c.type)||(a(),t.push(`
1
+ import{R as o,r as f}from"./vendor.react.js";import{E as D,k as N,V as L,l as ce,m as ue,T as O,n as F,o as de,p as pe,M as fe,U as Y}from"./userflow.js";import"./vendor.html-parse-stringify2.js";import{u as x}from"./vendor.react-i18next.js";import{B as G}from"./BubbleToolbar.js";import{m as me,d as Q,R as be,i as Ee,g as ge,u as we,c as V,h as he,S as Te}from"./bubble-frame.styl.js";import{b as X,z as ve,a as Se,l as K,r as ye}from"./flow-condition-types.js";import{u as R,i as ke}from"./client-context.js";import{F as De}from"./FlowChrome.js";import{u as Ne,r as Ie}from"./use-selector-element-monitoring.js";import{a as Z,S as Re}from"./flow-host.styl.js";import{f as Me}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Ae,u as Be}from"./stylesheets.js";import{T as Fe}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.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]="c11334ca-820d-4b5c-88b9-7391e5684a74",e._sentryDebugIdIdentifier="sentry-dbid-c11334ca-820d-4b5c-88b9-7391e5684a74")}catch{}})();const Ce=()=>{const{t:e}=x(),s=R(),{dispatch:t,restart:n}=A(),{session:l,step:d}=k(),a="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return o.createElement("div",{role:"dialog","aria-modal":M(d)?"true":void 0,"aria-label":"Guide menu"},o.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),o.createElement("button",{className:a,onClick:()=>s.endFlow(l,{endReason:D.USER_CLOSED})},e("menu.close")),l.version.restartEnabled&&o.createElement("button",{className:a,onClick:n},e("menu.restart")),o.createElement("button",{className:a,onClick:()=>t({kind:"showFlow"})},e("menu.back")))},W=({progress:e,type:s,position:t,totalSteps:n})=>{const{t:l}=x(),d=parseFloat(e||"0"),a={width:`${d*100}%`},c=s==="DEFAULT"?"TOP":t,u=`userflowjs-bubble-progress-${s||"DEFAULT"}`,m=c==="BOTTOM"?" userflowjs-bubble-progress-bottom":"",i=["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW"].includes(s)?`userflowjs-bubble-progress-CHAINED ${s==="CHAINED_SQUARED"?"userflowjs-bubble-progress-CHAINED_SQUARED":s==="CHAINED_ROUNDED"?"userflowjs-bubble-progress-CHAINED_ROUNDED":s==="DOTTED"?"userflowjs-bubble-progress-DOTTED":"userflowjs-bubble-progress-NARROW"}${m}`:`${u}${m}`,r=n||0,b=Math.min(r,Math.max(1,Math.floor(d*r)));return o.createElement("div",null,["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED"].includes(s)&&o.createElement("div",{className:i},Array.from({length:3}).map((E,g)=>o.createElement("div",{key:g,className:`rounded ${g<Math.floor(d*3)?"completed":""}`}))),s==="NARROW"&&o.createElement("div",{className:i},o.createElement("div",{className:"linear-progress-bar"},o.createElement("div",{className:"linear-progress-fill",style:a}))),s==="NUMBERED"&&o.createElement("div",{className:i},o.createElement("span",{className:"numbered-progress"},l("of",{replace:{range:r,selected:b}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&o.createElement("div",{className:`${i} ${c==="BOTTOM"?"bottom":""}`},o.createElement("div",{className:"userflowjs-bubble-progress__fill",style:a})))};var J=(e=>(e.BOTTOM="BOTTOM",e.TOP="TOP",e))(J||{});const Le=({theme:e})=>{const s=R(),{session:t,step:n,muted:l,shouldLabelDialog:d}=k(),{version:a}=t,{dispatch:c}=A(),u=a.steps[0],m=u&&u.id===n.id,i=m&&n.progress==="1",r=f.useMemo(()=>n.content&&me(Q(n.content),{buttons:n.buttons,questions:n.questions}),[n.content,n.buttons,n.questions]),b=a.steps.filter(v=>v.appearance!==N.HIDDEN),E=b.findIndex(v=>v.id===n.id),g=b.length,h=g>0?((E+1)/g).toString():"0";return o.createElement("div",{key:n.id,role:"alertdialog","aria-modal":M(n)?"true":void 0,"aria-label":d?"Guide":void 0},!i&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&o.createElement(W,{progress:h,type:e.progressBarType,totalSteps:g}),o.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},o.createElement(be,{doc:r,lookupAttribute:X(t.data),buttons:n.buttons,questions:n.questions})),o.createElement(G,{draftMode:t.draftMode,muted:l,toggleMuted:e.voiceType!==L.NONE?()=>c({kind:"toggleMuted"}):void 0,close:a.closeDisabled?void 0:()=>e.flowXButtonBehavior===ce.DISMISS||m?s.endFlow(t,{endReason:D.USER_CLOSED}):c({kind:"showMenu"})}),!i&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&o.createElement(W,{progress:h,type:e.progressBarType,position:J.BOTTOM,totalSteps:g}))};function Oe(e,s){if(!e)return"";typeof e=="string"&&(e=Q(e));const t=[],n=/[.!?;,]$/;function l(){const c=(t[t.length-1]||"").trim();c&&!c.match(n)&&t.push(".")}function d(c){if(Ee(c)){if(c.text&&!c.silent){const u=c.text.split(`
2
+ `);u.forEach((m,i)=>{t.push(m),i<u.length-1&&(l(),t.push(`
3
+ `))})}return}switch(c.type){case"attribute":{const u=ge(c,s);u&&t.push(u);break}default:a(c.children),["link"].includes(c.type)||(l(),t.push(`
4
4
 
5
- `));break}}function l(c){c.forEach(u=>d(u))}return l(e.children),t.join("").trim().replace(new RegExp(" ","g")," ").replace(new RegExp("\b","g"),"")}const _e=({bubbleFrame:e,theme:s})=>{const t=I(),{dispatch:n}=A(),{muted:a,session:d,step:l}=y(),c=t.getAudio();f.useEffect(()=>{const r=()=>{n({kind:"speechPlaying"})},E=()=>{n({kind:"speechStopped"})};return c.addEventListener("playing",r),c.addEventListener("ended",E),c.addEventListener("pause",E),()=>{c.removeEventListener("playing",r),c.removeEventListener("ended",E),c.removeEventListener("pause",E),c.pause(),c.src="",n({kind:"speechStopped"})}},[n,c]),f.useEffect(()=>{if(t.audioReady)return;const r=e&&Pe(e)?e.contentWindow:null,E=()=>{window.removeEventListener("mousedown",b),r&&r.removeEventListener("mousedown",b)},b=()=>{E(),t.playAudio(null)};return window.addEventListener("mousedown",b),r&&r.addEventListener("mousedown",b),E},[e,t]);const u=f.useRef(d),m=f.useRef(s),i=f.useRef(l);return f.useEffect(()=>{u.current=d,m.current=s,i.current=l},[d,s,l]),f.useEffect(()=>{if(!t.audioReady||a){t.pauseAudio();return}let r=!1;return(async()=>{if(await new Promise(w=>setTimeout(w,1)),r)return;const b=await xe(t,u.current,m.current,i.current);r||b&&t.playAudio(b)})(),()=>{r=!0}},[a,t,l.id,s.voiceType,s.syntheticVoice]),null};async function xe(e,s,t,n){if(t.voiceType===L.SYNTHETIC&&typeof t.syntheticVoice=="string"&&n.content){e.ensureIdentified();const a=X(s.data),d=Oe(n.content,a);return e.getStepSpeech(t.syntheticVoice,d)}else if(t.voiceType===L.MANUAL&&n.speechAsset)return n.speechAsset.assetUrl;return null}function Pe(e){return e.tagName==="IFRAME"}const je="userflowjs-out-of-viewport-pointer--visible",Ue="userflowjs-out-of-viewport-pointer--visible-up",qe="userflowjs-out-of-viewport-pointer--visible-down",Ve=o.forwardRef((e,s)=>{const t=Z();return o.createElement("div",{ref:s,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:t+2}},o.createElement(Ae,{icon:Me}))});function He({subjectPosition:e,pointerRef:s,viewportClipRect:t}){const n=s.current;if(!n)return null;const a=n.getBoundingClientRect(),d=ve(Se());let l=e.direction,c,u;return l==null?null:(l==="down"&&t.bottom<a.height/2?l="up":l==="up"&&t.top>d&&(l="down"),c=e.left+e.width/2-a.width/2,u=l==="down"?t.bottom-a.height:t.top,{direction:l,left:c,top:u})}function $(e,s){const t=e.current;t&&(t.classList.toggle(je,s!=null),s&&(t.style.left=s.left+"px",t.style.top=s.top+"px",t.classList.toggle(Ue,s.direction==="up"),t.classList.toggle(qe,s.direction==="down")))}const We="userflowjs-fixed-widget--visible",$e=({theme:e})=>{const{step:s}=y();return o.createElement(o.Fragment,null,s.beacons.map(t=>o.createElement(ze,{key:t.id,beacon:t,theme:e})))},ze=({beacon:e,theme:s})=>{const{session:t}=y(),n=Z(),a=f.useRef(null),d=f.useRef(null),l=we(e.hiddenCondition),c=f.useMemo(()=>K(e.selector,t.data),[e.selector,t.data]),u=f.useCallback(({targetRect:i,clipEl:r,viewportClipRect:E})=>{const b=Ye({beacon:e,beaconRef:a,clipEl:r,viewportClipRect:E,targetRect:i,theme:s}),w=b&&He({subjectPosition:b.pointerSubjectPosition,pointerRef:d,viewportClipRect:E});Re(()=>{z(a,b),$(d,w)})},[e]),m=f.useCallback(()=>{z(a,null),$(d,null)},[]);return Ne({selector:l?null:c,targetMoved:u,targetLost:m}),o.createElement(o.Fragment,null,o.createElement("div",{ref:a,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},o.createElement("div",{className:"userflowjs-beacon__ring"}),o.createElement("div",{className:"userflowjs-beacon__ring"})),o.createElement(Ve,{ref:d}))};function Ye({beacon:e,beaconRef:s,clipEl:t,viewportClipRect:n,targetRect:a,theme:d}){if(!s.current||a.width===0||a.height===0)return null;const c=d.beaconSize,u=d.beaconSize,m=ye(t);let i=0,r=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=a.left;break;case"top":case"center":case"bottom":i=a.left+a.width/2;break;default:i=a.left+a.width;break}switch(e.placement){case"left":case"center":case"right":r=a.top+a.height/2;break;case"bottom-left":case"bottom":case"bottom-right":r=a.top+a.height;break;default:r=a.top;break}i-=c/2,r-=u/2,i+=e.offsetX,r+=e.offsetY,i=Math.max(i,m.left-(t===document.documentElement?0:t.scrollLeft)),r=Math.max(r,m.top-(t===document.documentElement?0:t.scrollTop));const E=i+c,b=r+u,w=Math.min(32,.5*u);let h;b<n.top+w?h="up":r>n.bottom-w?h="down":h=null;const D=h==null;return{top:r,right:E,bottom:b,left:i,width:c,height:u,pointerSubjectPosition:{direction:h,left:i,width:c},visible:D}}function z(e,s){const t=e.current;t&&(t.classList.toggle(We,s!=null),s&&(t.style.transform=`translate3d(${s.left}px, ${s.top}px, 0)`,t.style.visibility=s.visible?"visible":"hidden"))}const Ge=()=>{const{t:e}=x(),s=I(),{restart:t}=A(),{session:n,step:a}=y(),d=a.theme||n.version.theme,l=a.selector,c=!l||l.type===ue.AUTO&&!l.autoData,u=()=>s.endFlow(n,{endReason:k.USER_CLOSED});return o.createElement(o.Fragment,null,o.createElement(G,{draftMode:n.draftMode,close:u}),n.draftMode&&c?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",o.createElement("b",null,"Step ",a.idx+1)," of"," ",o.createElement("b",null,n.flow.name),".")):n.draftMode&&d.tooltipMissingBehavior===O.END?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("p",null,o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",a.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found within"," ",d.tooltipMissingToleranceSeconds," ",parseFloat(d.tooltipMissingToleranceSeconds)===1?"second":"seconds","."),o.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),o.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,"Read more in our"," ",o.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):o.createElement(o.Fragment,null,o.createElement("div",{className:"userflowjs-bubble-content"},n.draftMode&&o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",a.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,o.createElement("b",null,e("tooltipTargetMissing.line1"))),o.createElement("p",null,e("tooltipTargetMissing.line2"))),o.createElement("div",{className:"userflowjs-bubble-buttons"},o.createElement(H,{appearance:"primary",onClick:t,text:e("menu.restart")}),o.createElement(H,{appearance:"default",onClick:u,text:e("menu.close")}))))},C="flowsMuted",Dt=({session:e,checklistSession:s,resourceCenterEmbedsChecklist:t})=>{const n=I(),[a,d]=f.useState(!1),[l,c]=f.useState(null),[u,m]=f.useReducer(Ke,void 0,()=>{const p=e,g=_(p);return{...Xe,session:p,step:g,muted:!!F.getItem(C),autoFocusRequested:te(g)}}),{session:i,step:r,speechPlaying:E,contentType:b}=u,{version:w}=i,h=M(r);let D=0;r.questions.some(p=>p.type===de.NPS)&&(D=420);const T=Be(r.theme||w.theme),v=f.useMemo(()=>{let p=T.bubbleY;const g=s?.version.theme;return!t&&s&&g&&s.version.checklist?.launcherEnabled&&r.appearance===R.BUBBLE&&g.checklistLauncherPlacement===T.bubblePlacement&&(T.avatarType===pe.NONE||g.checklistLauncherX<T.bubbleX+T.avatarSize)&&(p=Math.max(T.bubbleY,g.checklistLauncherY+g.checklistLauncherHeight+T.bubbleY)),{...T,bubbleWidth:Math.max(T.bubbleWidth,D),bubbleY:p}},[t,s,r.appearance,T,D]);f.useEffect(()=>{i!==e&&m({kind:"updateSession",session:e});const p=g=>{g.session.id===i.id&&m({kind:"goToStep",stepId:g.step.id})};return n.on("gotostep",p),()=>{n.off("gotostep",p)}},[n,i,e]);const se=f.useMemo(()=>({dispatch:m,restart:()=>{n.goToStep(i,ee(i)),m({kind:"showFlow"})}}),[n,m,i]),re=f.useMemo(()=>r.selector&&K(r.selector,i.data),[r.selector,i.data]),le=f.useCallback(()=>{he(n,i,r.actions)},[n,i,r.actions]);f.useEffect(()=>{u.muted?F.setItem(C,"true"):F.removeItem(C)},[u.muted]);const P=i.locale?i.locale.standardLocaleId:v.languageId;f.useEffect(()=>{ke.changeLanguage(P)},[P]);const[j,ae]=f.useState(!1),ie=f.useCallback(p=>{ae(p),p&&n.send({kind:"ReportTooltipTargetMissing",sessionId:i.id,stepId:r.id}),p&&v.tooltipMissingBehavior===O.END&&!i.draftMode&&n.endFlow(i,{endReason:k.TOOLTIP_TARGET_MISSING})},[n,i,r.id,v.tooltipMissingBehavior]);return f.useEffect(()=>{if(!a||!u.autoFocusRequested)return;!n.originalActiveElement&&n.originalActiveElement!==l?.ownerDocument.defaultView?.frameElement&&(n.originalActiveElement=document.activeElement);let p=l?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(p&&p.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const g=l?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");g&&(p=g)}p&&typeof p.focus=="function"&&p.focus({preventScroll:!0}),m({kind:"autoFocused"})},[n,l,a,u.autoFocusRequested]),f.useEffect(()=>{const p=l?.ownerDocument.defaultView;if(!p)return;const g=()=>{m({kind:"focusOut"}),delete n.originalActiveElement},S=()=>{m({kind:"focusIn"})};return window.addEventListener("focusin",g),p.addEventListener("focusin",S),()=>{window.removeEventListener("focusin",g),p.removeEventListener("focusin",S)}},[l,n]),f.useEffect(()=>{if(!h||!l)return;const p=l.ownerDocument.defaultView,g=p?p.document:document,S=N=>{if(N.key==="Escape"&&!w.closeDisabled)n.endFlow(i,{endReason:k.USER_CLOSED});else if(N.key==="Tab"){const B=l.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),U=B[0],q=B[B.length-1],V=g.activeElement;N.shiftKey?V===U&&(N.preventDefault(),q.focus()):V===q&&(N.preventDefault(),U.focus())}};return window.addEventListener("keydown",S),p?.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S),p?.removeEventListener("keydown",S)}},[h,n,i,l,w.closeDisabled]),f.useEffect(()=>{if(u.scrollToTopRequested){if(l?.ownerDocument.defaultView?.frameElement){const p=l?.ownerDocument.body;p&&(p.scrollTop=0)}m({kind:"scrolledToTop"})}},[u.scrollToTopRequested,l]),o.createElement(ne.Provider,{value:se},o.createElement(oe.Provider,{value:u},o.createElement(Te.Provider,{value:i},o.createElement(Ie,null,o.createElement(De,{company:i.flow.company,theme:v,position:"fixed",stepKey:r.crossVersionId,stepAppearance:r.appearance,width:r.width,backgroundImageUrl:b==="flow"&&!j&&r.backgroundAsset?r.backgroundAsset.assetUrl:null,tooltipSelector:re,tooltipPlacement:r.tooltipPlacement,backdrop:r.backdrop,tooltipTargetBlocked:r.tooltipTargetBlocked,backdropPadding:r.backdropPadding,onTooltipTargetClick:le,onTooltipTargetMissingChange:ie,onModalBackdropClick:r.appearance===R.MODAL&&v.modalBackdropOnclick===fe.DISMISS&&!w.closeDisabled?()=>n.endFlow(i,{endReason:k.USER_CLOSED}):void 0,speaking:E,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:d,bubbleFrameRootRef:c,rootChildren:p=>o.createElement(Qe,{...p,theme:v})},b==="menu"?o.createElement(Ce,null):j&&v.tooltipMissingBehavior!==O.BUBBLE?o.createElement(Ge,null):o.createElement(Le,{theme:v}))))))},Qe=({visible:e,bubbleFrame:s,theme:t})=>{const n=y(),{step:a}=n,d=n.session.currentStep&&n.session.currentStep.id,[l,c]=f.useState(!1),u=f.useRef(d);return f.useEffect(()=>{e?c(!0):u.current!==d&&c(!1),u.current=d},[d,e]),o.createElement(o.Fragment,null,(e||l)&&n.contentType==="flow"&&o.createElement(o.Fragment,null,o.createElement(_e,{bubbleFrame:s,theme:t}),o.createElement($e,{theme:t})),a.triggers.map(m=>o.createElement(Fe,{key:m.id,trigger:m})))},Xe={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Ke(e,s){switch(s.kind){case"updateSession":{let t;return s.session.id===e.session.id?t=s.session.version.steps.find(({crossVersionId:n})=>n===e.step.crossVersionId)||_(s.session):t=_(s.session),{...e,session:s.session,step:t}}case"goToStep":{const t=e.session.version.steps.find(n=>n.id===s.stepId);return t?{...e,step:t,contentType:"flow",autoFocusRequested:e.hasFocus||te(t),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function _(e){const{currentStep:s}=e,{steps:t}=e.version;if(s){const n=t.find(({crossVersionId:a})=>a===s.crossVersionId);if(!n)throw new Y("Session points to an unknown step: "+s.crossVersionId);return n}else return ee(e)}function ee(e){const s=e.version.steps[0];if(!s)throw new Y("Session has no current step and its version has no start step");return s}function te(e){return M(e)}function M(e){return e.appearance===R.MODAL||e.appearance===R.BUBBLE&&e.backdrop||e.appearance===R.TOOLTIP&&e.tooltipTargetBlocked}const ne=f.createContext(null),oe=f.createContext(null);function A(){return f.useContext(ne)}function y(){return f.useContext(oe)}export{Dt as FlowApp,oe as FlowStateContext,Dt as default,Xe as initialFlowState,M as isStepModal,A as useFlowDispatch,y as useFlowState};
5
+ `));break}}function a(c){c.forEach(u=>d(u))}return a(e.children),t.join("").trim().replace(new RegExp(" ","g")," ").replace(new RegExp("\b","g"),"")}const _e=({bubbleFrame:e,theme:s})=>{const t=R(),{dispatch:n}=A(),{muted:l,session:d,step:a}=k(),c=t.getAudio();f.useEffect(()=>{const r=()=>{n({kind:"speechPlaying"})},b=()=>{n({kind:"speechStopped"})};return c.addEventListener("playing",r),c.addEventListener("ended",b),c.addEventListener("pause",b),()=>{c.removeEventListener("playing",r),c.removeEventListener("ended",b),c.removeEventListener("pause",b),c.pause(),c.src="",n({kind:"speechStopped"})}},[n,c]),f.useEffect(()=>{if(t.audioReady)return;const r=e&&Pe(e)?e.contentWindow:null,b=()=>{window.removeEventListener("mousedown",E),r&&r.removeEventListener("mousedown",E)},E=()=>{b(),t.playAudio(null)};return window.addEventListener("mousedown",E),r&&r.addEventListener("mousedown",E),b},[e,t]);const u=f.useRef(d),m=f.useRef(s),i=f.useRef(a);return f.useEffect(()=>{u.current=d,m.current=s,i.current=a},[d,s,a]),f.useEffect(()=>{if(!t.audioReady||l){t.pauseAudio();return}let r=!1;return(async()=>{if(await new Promise(g=>setTimeout(g,1)),r)return;const E=await xe(t,u.current,m.current,i.current);r||E&&t.playAudio(E)})(),()=>{r=!0}},[l,t,a.id,s.voiceType,s.syntheticVoice]),null};async function xe(e,s,t,n){if(t.voiceType===L.SYNTHETIC&&typeof t.syntheticVoice=="string"&&n.content){e.ensureIdentified();const l=X(s.data),d=Oe(n.content,l);return e.getStepSpeech(t.syntheticVoice,d)}else if(t.voiceType===L.MANUAL&&n.speechAsset)return n.speechAsset.assetUrl;return null}function Pe(e){return e.tagName==="IFRAME"}const je="userflowjs-out-of-viewport-pointer--visible",Ue="userflowjs-out-of-viewport-pointer--visible-up",qe="userflowjs-out-of-viewport-pointer--visible-down",He=o.forwardRef((e,s)=>{const t=Z();return o.createElement("div",{ref:s,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:t+2}},o.createElement(Ae,{icon:Me}))});function Ve({subjectPosition:e,pointerRef:s,viewportClipRect:t}){const n=s.current;if(!n)return null;const l=n.getBoundingClientRect(),d=ve(Se());let a=e.direction,c,u;return a==null?null:(a==="down"&&t.bottom<l.height/2?a="up":a==="up"&&t.top>d&&(a="down"),c=e.left+e.width/2-l.width/2,u=a==="down"?t.bottom-l.height:t.top,{direction:a,left:c,top:u})}function $(e,s){const t=e.current;t&&(t.classList.toggle(je,s!=null),s&&(t.style.left=s.left+"px",t.style.top=s.top+"px",t.classList.toggle(Ue,s.direction==="up"),t.classList.toggle(qe,s.direction==="down")))}const We="userflowjs-fixed-widget--visible",$e=({theme:e})=>{const{step:s}=k();return o.createElement(o.Fragment,null,s.beacons.map(t=>o.createElement(ze,{key:t.id,beacon:t,theme:e})))},ze=({beacon:e,theme:s})=>{const{session:t}=k(),n=Z(),l=f.useRef(null),d=f.useRef(null),a=we(e.hiddenCondition),c=f.useMemo(()=>K(e.selector,t.data),[e.selector,t.data]),u=f.useCallback(({targetRect:i,clipEl:r,viewportClipRect:b})=>{const E=Ye({beacon:e,beaconRef:l,clipEl:r,viewportClipRect:b,targetRect:i,theme:s}),g=E&&Ve({subjectPosition:E.pointerSubjectPosition,pointerRef:d,viewportClipRect:b});Ie(()=>{z(l,E),$(d,g)})},[e]),m=f.useCallback(()=>{z(l,null),$(d,null)},[]);return Ne({selector:a?null:c,targetMoved:u,targetLost:m}),o.createElement(o.Fragment,null,o.createElement("div",{ref:l,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},o.createElement("div",{className:"userflowjs-beacon__ring"}),o.createElement("div",{className:"userflowjs-beacon__ring"})),o.createElement(He,{ref:d}))};function Ye({beacon:e,beaconRef:s,clipEl:t,viewportClipRect:n,targetRect:l,theme:d}){if(!s.current||l.width===0||l.height===0)return null;const c=d.beaconSize,u=d.beaconSize,m=ye(t);let i=0,r=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=l.left;break;case"top":case"center":case"bottom":i=l.left+l.width/2;break;default:i=l.left+l.width;break}switch(e.placement){case"left":case"center":case"right":r=l.top+l.height/2;break;case"bottom-left":case"bottom":case"bottom-right":r=l.top+l.height;break;default:r=l.top;break}i-=c/2,r-=u/2,i+=e.offsetX,r+=e.offsetY,i=Math.max(i,m.left-(t===document.documentElement?0:t.scrollLeft)),r=Math.max(r,m.top-(t===document.documentElement?0:t.scrollTop));const b=i+c,E=r+u,g=Math.min(32,.5*u);let h;E<n.top+g?h="up":r>n.bottom-g?h="down":h=null;const v=h==null;return{top:r,right:b,bottom:E,left:i,width:c,height:u,pointerSubjectPosition:{direction:h,left:i,width:c},visible:v}}function z(e,s){const t=e.current;t&&(t.classList.toggle(We,s!=null),s&&(t.style.transform=`translate3d(${s.left}px, ${s.top}px, 0)`,t.style.visibility=s.visible?"visible":"hidden"))}const Ge=()=>{const{t:e}=x(),s=R(),{restart:t}=A(),{session:n,step:l}=k(),d=l.theme||n.version.theme,a=l.selector,c=!a||a.type===ue.AUTO&&!a.autoData,u=()=>s.endFlow(n,{endReason:D.USER_CLOSED});return o.createElement(o.Fragment,null,o.createElement(G,{draftMode:n.draftMode,close:u}),n.draftMode&&c?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name),".")):n.draftMode&&d.tooltipMissingBehavior===O.END?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("p",null,o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found within"," ",d.tooltipMissingToleranceSeconds," ",parseFloat(d.tooltipMissingToleranceSeconds)===1?"second":"seconds","."),o.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),o.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,"Read more in our"," ",o.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):o.createElement(o.Fragment,null,o.createElement("div",{className:"userflowjs-bubble-content"},n.draftMode&&o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,o.createElement("b",null,e("tooltipTargetMissing.line1"))),o.createElement("p",null,e("tooltipTargetMissing.line2"))),o.createElement("div",{className:"userflowjs-bubble-buttons"},o.createElement(V,{appearance:"primary",onClick:t,text:e("menu.restart")}),o.createElement(V,{appearance:"default",onClick:u,text:e("menu.close")}))))},C="flowsMuted",Dt=({session:e,checklistSession:s,resourceCenterEmbedsChecklist:t})=>{const n=R(),[l,d]=f.useState(!1),[a,c]=f.useState(null),[u,m]=f.useReducer(Ke,void 0,()=>{const p=e,w=_(p);return{...Xe,session:p,step:w,muted:!!F.getItem(C),autoFocusRequested:te(w)}}),{session:i,step:r,speechPlaying:b,contentType:E}=u,{version:g}=i,h=M(r);let v=0;r.questions.some(p=>p.type===de.NPS)&&(v=420);const T=Be(r.theme||g.theme),S=f.useMemo(()=>{let p=T.bubbleY;const w=s?.version.theme;return!t&&s&&w&&s.version.checklist?.launcherEnabled&&r.appearance===N.BUBBLE&&w.checklistLauncherPlacement===T.bubblePlacement&&(T.avatarType===pe.NONE||w.checklistLauncherX<T.bubbleX+T.avatarSize)&&(p=Math.max(T.bubbleY,w.checklistLauncherY+w.checklistLauncherHeight+T.bubbleY)),{...T,bubbleWidth:Math.max(T.bubbleWidth,v),bubbleY:p}},[t,s,r.appearance,T,v]);f.useEffect(()=>{i!==e&&m({kind:"updateSession",session:e});const p=w=>{w.session.id===i.id&&m({kind:"goToStep",stepId:w.step.id})};return n.on("gotostep",p),()=>{n.off("gotostep",p)}},[n,i,e]);const se=f.useMemo(()=>({dispatch:m,restart:()=>{n.goToStep(i,ee(i)),m({kind:"showFlow"})}}),[n,m,i]),re=f.useMemo(()=>r.selector&&K(r.selector,i.data),[r.selector,i.data]),le=f.useCallback(()=>{he(n,i,r.actions)},[n,i,r.actions]);f.useEffect(()=>{u.muted?F.setItem(C,"true"):F.removeItem(C)},[u.muted]);const P=i.locale?i.locale.standardLocaleId:S.languageId;f.useEffect(()=>{ke.changeLanguage(P)},[P]);const[j,ae]=f.useState(!1),ie=f.useCallback(p=>{ae(p),p&&n.send({kind:"ReportTooltipTargetMissing",sessionId:i.id,stepId:r.id}),p&&S.tooltipMissingBehavior===O.END&&!i.draftMode&&n.endFlow(i,{endReason:D.TOOLTIP_TARGET_MISSING})},[n,i,r.id,S.tooltipMissingBehavior]);return f.useEffect(()=>{if(!l||!u.autoFocusRequested)return;!n.originalActiveElement&&n.originalActiveElement!==a?.ownerDocument.defaultView?.frameElement&&(n.originalActiveElement=document.activeElement);let p=a?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(p&&p.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const w=a?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");w&&(p=w)}p&&typeof p.focus=="function"&&p.focus({preventScroll:!0}),m({kind:"autoFocused"})},[n,a,l,u.autoFocusRequested]),f.useEffect(()=>{const p=a?.ownerDocument.defaultView;if(!p)return;const w=()=>{m({kind:"focusOut"}),delete n.originalActiveElement},y=()=>{m({kind:"focusIn"})};return window.addEventListener("focusin",w),p.addEventListener("focusin",y),()=>{window.removeEventListener("focusin",w),p.removeEventListener("focusin",y)}},[a,n]),f.useEffect(()=>{if(!h||!a)return;const p=a.ownerDocument.defaultView,w=p?p.document:document,y=I=>{if(I.key==="Escape"&&!g.closeDisabled)n.endFlow(i,{endReason:D.USER_CLOSED});else if(I.key==="Tab"){const B=a.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),U=B[0],q=B[B.length-1],H=w.activeElement;I.shiftKey?H===U&&(I.preventDefault(),q.focus()):H===q&&(I.preventDefault(),U.focus())}};return window.addEventListener("keydown",y),p?.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y),p?.removeEventListener("keydown",y)}},[h,n,i,a,g.closeDisabled]),f.useEffect(()=>{if(u.scrollToTopRequested){if(a?.ownerDocument.defaultView?.frameElement){const p=a?.ownerDocument.body;p&&(p.scrollTop=0)}m({kind:"scrolledToTop"})}},[u.scrollToTopRequested,a]),o.createElement(ne.Provider,{value:se},o.createElement(oe.Provider,{value:u},o.createElement(Te.Provider,{value:i},o.createElement(Re,null,o.createElement(De,{company:i.flow.company,theme:S,position:"fixed",stepKey:r.crossVersionId,stepAppearance:r.appearance,width:r.width,backgroundImageUrl:E==="flow"&&!j&&r.backgroundAsset?r.backgroundAsset.assetUrl:null,tooltipSelector:re,tooltipPlacement:r.tooltipPlacement,backdrop:r.backdrop,tooltipTargetBlocked:r.tooltipTargetBlocked,backdropPadding:r.backdropPadding,onTooltipTargetClick:le,onTooltipTargetMissingChange:ie,onModalBackdropClick:r.appearance===N.MODAL&&S.modalBackdropOnclick===fe.DISMISS&&!g.closeDisabled?()=>n.endFlow(i,{endReason:D.USER_CLOSED}):void 0,speaking:b,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:d,bubbleFrameRootRef:c,rootChildren:p=>o.createElement(Qe,{...p,theme:S})},E==="menu"?o.createElement(Ce,null):j&&S.tooltipMissingBehavior!==O.BUBBLE?o.createElement(Ge,null):o.createElement(Le,{theme:S}))))))},Qe=({visible:e,bubbleFrame:s,theme:t})=>{const n=k(),{step:l}=n,d=n.session.currentStep&&n.session.currentStep.id,[a,c]=f.useState(!1),u=f.useRef(d);return f.useEffect(()=>{e?c(!0):u.current!==d&&c(!1),u.current=d},[d,e]),o.createElement(o.Fragment,null,(e||a)&&n.contentType==="flow"&&o.createElement(o.Fragment,null,o.createElement(_e,{bubbleFrame:s,theme:t}),o.createElement($e,{theme:t})),l.triggers.map(m=>o.createElement(Fe,{key:m.id,trigger:m})))},Xe={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Ke(e,s){switch(s.kind){case"updateSession":{let t;return s.session.id===e.session.id?t=s.session.version.steps.find(({crossVersionId:n})=>n===e.step.crossVersionId)||_(s.session):t=_(s.session),{...e,session:s.session,step:t}}case"goToStep":{const t=e.session.version.steps.find(n=>n.id===s.stepId);return t?{...e,step:t,contentType:"flow",autoFocusRequested:e.hasFocus||te(t),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function _(e){const{currentStep:s}=e,{steps:t}=e.version;if(s){const n=t.find(({crossVersionId:l})=>l===s.crossVersionId);if(!n)throw new Y("Session points to an unknown step: "+s.crossVersionId);return n}else return ee(e)}function ee(e){const s=e.version.steps[0];if(!s)throw new Y("Session has no current step and its version has no start step");return s}function te(e){return M(e)}function M(e){return e.appearance===N.MODAL||e.appearance===N.BUBBLE&&e.backdrop||e.appearance===N.TOOLTIP&&e.tooltipTargetBlocked}const ne=f.createContext(null),oe=f.createContext(null);function A(){return f.useContext(ne)}function k(){return f.useContext(oe)}export{Dt as FlowApp,oe as FlowStateContext,Dt as default,Xe as initialFlowState,M as isStepModal,A as useFlowDispatch,k as useFlowState};
6
6
  //# sourceMappingURL=FlowApp.js.map
package/FlowChrome.js CHANGED
@@ -1,3 +1,3 @@
1
- import{r as u,R as w}from"./vendor.react.js";import{u as de,F as oe}from"./use-window-resize.js";import{c as A,o as y,p as it,l as me,q as j,y as be,x as c}from"./userflow.js";import{a as pe,f as he}from"./flow-host.styl.js";import{b as ge}from"./bubble-frame.styl.js";import{S as we}from"./logomark.js";import{o as Vt}from"./vendor.obj-str.js";import{u as Te}from"./use-selector-element-monitoring.js";import{a as Wt,g as Dt,c as rt,m as Ee,d as ae,M as le,k as Ht,n as ye,h as Le}from"./flow-condition-types.js";import{a as ve,g as Be}from"./stylesheets.js";import"./vendor.html-parse-stringify2.js";import{u as Me}from"./vendor.react-i18next.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]="695e5e40-b779-47f6-889b-768af9c6f032",e._sentryDebugIdIdentifier="sentry-dbid-695e5e40-b779-47f6-889b-768af9c6f032")}catch{}})();const Re=new URL("avatar-frame.css",import.meta.url).href;function ke(e,t){const o=window.Intercom;u.useEffect(()=>{if(!(!t||!e.autoHideIntercom||typeof o!="function"||A.autoHide3pDisabled)){try{o("update",{hide_default_launcher:!0})}catch(l){console.warn("Userflow.js: Error when hiding Intercom launcher",l)}return()=>{if(!A.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 T=window.$crisp;u.useEffect(()=>{if(!(!t||!e.autoHideCrisp||!T||A.autoHide3pDisabled)){try{T.push(["do","chat:hide"])}catch(l){console.warn("Userflow.js: Error when hiding Crisp Chat",l)}return()=>{if(!A.autoHide3pDisabled)try{T.push(["do","chat:show"])}catch(l){console.warn("Userflow.js: Error when unhiding Crisp Chat",l)}}}},[T,e.autoHideCrisp,t]);const M=window.HubSpotConversations;u.useEffect(()=>{if(!(!t||!e.autoHideHubspot||!M||A.autoHide3pDisabled)){try{M.widget.remove()}catch(l){console.warn("Userflow.js: Error when hiding HubSpot Chat",l)}return()=>{if(!A.autoHide3pDisabled)try{M.widget.load()}catch(l){console.warn("Userflow.js: Error when unhiding HubSpot Chat",l)}}}},[M,e.autoHideHubspot,t]);const m=window.drift;u.useEffect(()=>{if(!(!t||!e.autoHideDrift||!m||A.autoHide3pDisabled)){try{m.api.widget.hide()}catch(l){console.warn("Userflow.js: Error when hiding Drift Chat",l)}return()=>{if(!A.autoHide3pDisabled)try{m.api.widget.show()}catch(l){console.warn("Userflow.js: Error when unhiding Drift Chat",l)}}}},[m,e.autoHideDrift,t])}const At=16,Mt=20,Ye=({company:e,theme:t,position:o,absoluteWidth:T,absoluteHeight:M,stepKey:m,stepAppearance:l,width:b,backgroundImageUrl:g,tooltipSelector:f,allowMissingTooltipTarget:E,tooltipPlacement:k,backdrop:_,tooltipTargetBlocked:W,backdropPadding:Q,zIndex:N,onTooltipTargetClick:L,onTooltipTargetMissingChange:H,onModalBackdropClick:Z,onVisibleChange:tt,speaking:D,noIframe:P,MadeWithUserflow:n,minimizeOnAvatarClick:F,autoHide3pEnabled:R,bubbleFrameRootRef:v,frameWrapperHtmlAttributes:O,rootChildren:x,children:r})=>{const s=o||"absolute",z=k||null,q=Q||"0",G=n||Oe,et=pe(),J=s==="fixed"?N??et+1:1,U=J-1,{i18n:Rt}=Me(),at=Rt.dir(),nt=u.useRef(null),mt=u.useRef(null),ut=u.useRef(null),[$,kt]=u.useState(null),bt=u.useRef(null),pt=u.useRef(null),ht=u.useRef(null),gt=u.useRef(null),wt=u.useRef(null),Tt=u.useRef(null),Et=u.useRef(null),yt=u.useRef(null),Lt=u.useRef(null);u.useLayoutEffect(()=>{const i=nt.current.style;i.animation="none",i.visibility="hidden",i.position="absolute",i.top="-99999px",i.left="-99999px"},[]);const{loaded:Pt}=ve(window,he,t),[Ot,jt]=u.useState(!1),[Nt,xt]=u.useState(!1),vt=Pt&&Ot&&Nt;let[It,h]=u.useState(!1);l!==y.BUBBLE&&(F=!1,It=!1),u.useEffect(()=>{h(!1)},[m]);const a=u.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}),[C,lt]=u.useState(null),I=C!=null&&vt;u.useEffect(()=>{tt&&tt(I)},[tt,I]);const Y=u.useCallback(i=>{a.current.lastReportedTooltipTargetMissing!==i&&(a.current.lastReportedTooltipTargetMissing=i,H&&H(i))},[H]),B=u.useCallback(({forceAppearanceLayout:i,forceUpdatePosition:S}={})=>{const dt=nt.current,_t=mt.current,Bt=ut.current,zt=pt.current,Gt=bt.current,$t=ht.current,Yt=gt.current,Xt=wt.current,Zt=Tt.current,qt=Et.current,Jt=yt.current,Kt=Lt.current;if(!dt||!_t||!Bt||!$||!zt||!Gt||!$t||!Yt||!Xt||!Zt||!qt||!Jt||!Kt||!vt)return;const p=a.current,{tooltipTargetParams:Ft}=p;Le();let V=l,Qt=!1;V===y.TOOLTIP&&!E&&!Ft&&(p.tooltipTargetMissing?(V=y.BUBBLE,Qt=!0):V=null);const te=V!==p.appearance,ue=b!==p.width;if((i||te||ue||t!==p.theme||_!=p.backdrop||q!=p.backdropPadding||z!==p.desiredTooltipPlacement)&&(p.appearance=V,p.width=b,p.theme=t,p.backdrop=_,p.backdropPadding=q,p.desiredTooltipPlacement=z,S=!0,je({layoutState:p,width:b,position:s,absoluteWidth:T,root:dt,bubble:_t,bubbleFrameRoot:$,avatar:zt,avatarNotch:Gt,modalBackdrop:Kt,dir:at})),!P){const X=$.offsetHeight,Ct=Wt(),St=Dt()<800?0:At,ce=t.avatarType===it.NONE?0:V===y.BUBBLE?Mt+t.avatarSize:V===y.MODAL?t.avatarSize/2:0,ee=Ct-2*St-ce,Ut=Math.min(X,ee);if(V&&Ut!==p.bubbleFrameHeight){if(p.bubbleFrameHeight=Ut,d(Bt,"height",rt(Ut)),Ee(Bt)&&Bt.contentDocument){const fe=Bt.contentDocument.documentElement;fe.style.overflowY=X<=ee?"hidden":"scroll"}S=!0}}if(S&&V){let X=te;if(V===y.TOOLTIP){const Ct=p.tooltipTargetParams&&p.tooltipTargetParams.targetEl,St=p.prevTooltipTargetParams&&p.prevTooltipTargetParams.targetEl;Ct!==St&&(X=!0)}p.prevTooltipTargetParams=p.tooltipTargetParams,Ne({layoutState:p,animateIn:X,position:s,absoluteWidth:T,absoluteHeight:M,desiredTooltipPlacement:z,root:dt,bubble:_t,tooltipNotch:$t,tooltipBackdrop:Yt,tooltipBlockTop:Xt,tooltipBlockRight:Zt,tooltipBlockBottom:qt,tooltipBlockLeft:Jt,dir:at})}if(V===y.TOOLTIP){const X=Ft&&Ft.targetEl;X&&p.stepKeyScrolledIntoView!==m&&p.targetScrolledIntoView!==X&&(p.stepKeyScrolledIntoView=m,p.targetScrolledIntoView=X,Ie(X))}else p.stepKeyScrolledIntoView=void 0,p.targetScrolledIntoView=null;Y(Qt),lt(V)},[vt,$,m,l,b,t,s,T,M,E,z,_,q,P,Y,at]),K=u.useRef(B);K.current=B;const ct=u.useRef(!1);u.useEffect(()=>{const i=()=>{ct.current=!0};return window.addEventListener("pagehide",i),()=>window.removeEventListener("pagehide",i)},[]);const ot=()=>{window.clearTimeout(a.current.tooltipTargetMissingTimeout),a.current.tooltipTargetMissingTimeout=void 0};u.useEffect(()=>ot,[]);const re=u.useCallback(()=>{const i=a.current;if(i.tooltipTargetParams=null,E||(i.tooltipPlacement=null),l!==y.TOOLTIP){ot(),i.tooltipTargetMissing=!1;return}if(!E&&!i.tooltipTargetMissingTimeout){i.tooltipTargetMissing=!1;const S=f&&!ae(f)&&f.type===me.AUTO&&!f.autoData?1:parseFloat(t.tooltipMissingToleranceSeconds)*1e3;i.tooltipTargetMissingTimeout=window.setTimeout(()=>{if(!ct.current){if(f&&!ae(f)){let dt=f.autoData;if(f.autoData)try{dt=JSON.parse(f.autoData)}catch{}console.warn(`Userflow.js: Tooltip target not found on page.
2
- `,{type:f.type,autoData:dt,excludeText:f.excludeText,precision:f.precision,text:f.text,css:f.css})}ot(),i.tooltipTargetMissing=!0,K.current()}},S)}K.current()},[l,E,f,t.tooltipMissingToleranceSeconds]),ie=u.useCallback(i=>{const S=a.current;ot(),S.tooltipTargetParams&&S.tooltipTargetParams.targetEl!==i.targetEl&&(S.tooltipPlacement=null),S.tooltipTargetParams=i,B({forceUpdatePosition:!0})},[B]);Te({selector:l===y.TOOLTIP&&f||null,targetMoved:ie,targetLost:re,onTargetClick:L});const ne=u.useCallback(()=>B({forceAppearanceLayout:!0}),[B]);de(ne),u.useEffect(()=>{if(!$||P||typeof le!="function")return;let i;const S=new le(()=>{i||(i=window.requestAnimationFrame(()=>{i=void 0,K.current()}))});return S.observe($,{childList:!0,attributes:!0,subtree:!0}),()=>{S.disconnect(),i&&window.cancelAnimationFrame(i)}},[$,P]),u.useLayoutEffect(()=>{K.current()}),u.useLayoutEffect(()=>{s==="absolute"&&B({forceAppearanceLayout:!0})},[s,T,M]);const ft=i=>{i.preventDefault(),i.stopPropagation()};return ke(t,!!R&&C===y.BUBBLE),w.createElement("div",{ref:nt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:Be(t),dir:at},w.createElement("div",{className:"userflowjs-bubble",ref:mt,style:{zIndex:J}},w.createElement("div",{className:Vt({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(t.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!F,"userflowjs-bubble-outline--minimized":It})},w.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...O},w.createElement(oe,{className:"userflowjs-bubble__frame",elRef:ut,stylesheet:ge,theme:t,onStylesheetsLoad:jt,noIframe:P,title:l.toLowerCase()},w.createElement("div",{className:"userflowjs-bubble-frame-root",ref:i=>{v&&v(i),kt(i)},style:g?{backgroundImage:`url("${encodeURI(g)}")`}:void 0},r,e.flowBranding&&w.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},w.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},w.createElement(G,{company:e},w.createElement(we,null),w.createElement("div",null,"Made with Userflow"))))))),w.createElement("div",{ref:bt,className:"userflowjs-bubble__avatar-notch"})),w.createElement(oe,{className:Vt({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!F,"userflowjs-bubble__avatar--speaking":!!D}),elRef:pt,stylesheet:Re,theme:t,onStylesheetsLoad:xt,noIframe:P,ariaHidden:!0,title:l.toLowerCase()},w.createElement("div",{className:Vt({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!F}),onClick:F?()=>h(i=>!i):void 0},w.createElement(Pe,{theme:t}))),w.createElement("div",{ref:ht,className:"userflowjs-bubble__tooltip-notch"})),w.createElement("div",{ref:gt,className:"userflowjs-tooltip-backdrop",onMouseDown:ft,style:{zIndex:U,pointerEvents:W?void 0:"none"}}),w.createElement("div",{ref:wt,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:Tt,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:Et,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:yt,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:Lt,className:"userflowjs-modal-backdrop",onMouseDown:ft,onClick:Z,style:{zIndex:U}}),x&&x({visible:I,bubbleFrame:ut.current}))},Pe=({theme:e})=>{const t="https://js.userflow.com/cartoon-avatars-no-bg/";let o;return e.avatarType===it.ASSET&&e.avatarAsset?o=e.avatarAsset.assetUrl:e.avatarType===it.CARTOON&&e.avatarName?o=t+e.avatarName+".svg?3":e.avatarType===it.URL&&e.avatarUrl?o=e.avatarUrl:o=t+"none.svg",w.createElement("img",{src:o,alt:""})},Oe=({company:e,children:t})=>w.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 je({layoutState:{appearance:e,theme:t,backdrop:o,tooltipTargetMissing:T},width:M,position:m,absoluteWidth:l,root:b,bubble:g,bubbleFrameRoot:f,avatar:E,avatarNotch:k,modalBackdrop:_,dir:W}){const Q=m==="absolute"?l||1024:rt(Dt()),{avatarSize:N,bubblePlacement:L}=t;let H=t.bubbleWidth,Z=null,tt=null,D=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${e?.toLowerCase()}`,P="hidden",n=null,F=null,R=null,v=null,O="userflowjs-bubble__avatar-notch",x="hidden",r=null,s=null,z=null,q=null,G="userflowjs-modal-backdrop";switch((e===y.MODAL||!T&&e===y.BUBBLE&&o)&&(G+=" userflowjs-modal-backdrop--visible"),e){case y.BUBBLE:if(t.avatarType!==it.NONE){P="",x="",L===j.TOP_LEFT||L===j.TOP_CENTER||L===j.TOP_RIGHT?(Z=N+Mt,n=0,r=-2*Mt,O+=" userflowjs-bubble__avatar-notch--top"):(tt=N+Mt,R=0,z=-2*Mt,O+=" userflowjs-bubble__avatar-notch--bottom");const J=L===j.TOP_LEFT||L===j.TOP_CENTER||L===j.BOTTOM_LEFT||L===j.BOTTOM_CENTER||L===j.CENTER;W==="ltr"&&J||W==="rtl"&&!J?(v=0,q=N,O+=" userflowjs-bubble__avatar-notch--left"):(F=0,s=N,O+=" userflowjs-bubble__avatar-notch--right")}break;case y.MODAL:H=t.modalWidth,t.avatarType!==it.NONE&&(P="",v=`calc(50% - ${N/2}px)`,n=-N/2);break;case y.TOOLTIP:H=t.tooltipWidth;break}M!=null&&(H=M),H=Math.min(H,Q-2*At),b.classList.toggle("userflowjs-flow-chrome--position-absolute",m==="absolute"),b.classList.toggle("userflowjs-flow-chrome--position-relative",m==="relative"),b.classList.toggle("userflowjs-flow-chrome--position-fixed",m==="fixed"),b.classList.toggle("userflowjs-flow-chrome--appearance-modal",e===y.MODAL);const et=e!=null&&e!==y.HIDDEN;b.style.position="",b.style.top="",b.style.left="",b.style.visibility=et?"":"hidden",b.style.animation=et?"":"none",d(g,"width",rt(H)),d(g,"padding-top",Z),d(g,"padding-bottom",tt),f.className=D,d(E,"width",rt(t.avatarSize)),d(E,"height",rt(t.avatarSize)),E.style.visibility=P,d(E,"top",n),d(E,"right",F),d(E,"bottom",R),d(E,"left",v),k.className=O,k.style.visibility=x,d(k,"top",r),d(k,"right",s),d(k,"bottom",z),d(k,"left",q),_.className=G}function Ne({layoutState:e,animateIn:t,position:o,absoluteWidth:T,absoluteHeight:M,desiredTooltipPlacement:m,root:l,bubble:b,tooltipNotch:g,tooltipBackdrop:f,tooltipBlockTop:E,tooltipBlockRight:k,tooltipBlockBottom:_,tooltipBlockLeft:W,dir:Q}){const{appearance:N,theme:L,tooltipTargetParams:H,backdrop:Z,backdropPadding:tt}=e,{bubblePlacement:D}=L,P=At,n=L.tooltipNotchSize,F=10,{width:R,height:v}=b.getBoundingClientRect(),O=o==="absolute"?T||1024:rt(Dt()),x=o==="absolute"?M||768:rt(Wt());let r=0,s=0,z="userflowjs-bubble__tooltip-notch",q="hidden",G=null,et=null,J=null,U=null,Rt="userflowjs-tooltip-backdrop",at=null,nt=null,mt=null,ut=null,$=null,kt=null,bt=null,pt=null,ht="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",Pt=null,Ot=null,jt="userflowjs-tooltip-block userflowjs-tooltip-block--left",Nt=null,xt=null;switch(N){case y.BUBBLE:{D===j.TOP_LEFT||D===j.BOTTOM_LEFT?r=L.bubbleX:D===j.TOP_CENTER||D===j.CENTER||D===j.BOTTOM_CENTER?r=(O-R)/2:r=O-R-L.bubbleX,D===j.TOP_LEFT||D===j.TOP_CENTER||D===j.TOP_RIGHT?s=L.bubbleY:D===j.CENTER?s=(x-v)/2:s=x-v-L.bubbleY,Q==="rtl"&&(r=O-r-R),r=Math.max(0,Math.min(O-R,r)),s=Math.max(0,Math.min(x-v,s));break}case y.MODAL:{let h=P;L.avatarType!==it.NONE&&(h+=L.avatarSize/2),r=P+(O-P*2-R)/2,s=h+(x-h-P-v)/2;break}case y.TOOLTIP:{let h;if(H){let{targetRect:a,viewportClipRect:C}=H;if(o==="absolute"){const B=l.offsetParent.getBoundingClientRect();C={top:0,right:O,bottom:x,left:0},a={top:a.top-B.top,right:a.right-B.left,bottom:a.bottom-B.top,left:a.left-B.left,width:a.width,height:a.height}}let lt=0;if(Z){const{paddingTop:B,paddingRight:K,paddingBottom:ct,paddingLeft:ot}=_e(tt);a={top:a.top-B,right:a.right+K,bottom:a.bottom+ct,left:a.left-ot,width:a.width+ot+K,height:a.height+B+ct},lt=Math.min(B,K,ct,ot)}const I=a,Y=L.backdropHighlightType==be.OUTSIDE?L.backdropHighlightSpread:0;if(Z&&Y&&(a={top:a.top-Y,right:a.right+Y,bottom:a.bottom+Y,left:a.left-Y,width:a.width+2*Y,height:a.height+2*Y}),h=xe({targetRect:a,bubbleWidth:R,bubbleHeight:v,containerWidth:O,containerHeight:x,viewportClipRect:C,tooltipNotchSize:n,currentTooltipPlacement:e.tooltipPlacement,desiredTooltipPlacement:m}),h===c.BELOW||h===c.ABOVE?(r=a.left+a.width/2-R/2,r=Math.max(P,Math.min(O-R-P,r)),U=Math.max(F,Math.min(R-F-n*2,a.left+a.width/2-n-r)),h===c.BELOW?G=-n*2:J=-n*2):h===c.RIGHT?(r=a.right+n,r=Math.max(r,C.left+n),r=Math.min(r,C.right+n),r=Math.max(r,n),r=Math.min(r,O-R)):(r=a.left-n-R,r=Math.max(r,C.left-R-n),r=Math.min(r,C.right-R-n),r=Math.max(r,0),r=Math.min(r,O-R-n)),h===c.LEFT||h===c.RIGHT?(s=a.top+a.height/2-v/2,s=Math.max(P,Math.min(x-v-P,s)),G=Math.max(F,Math.min(v-F-n*2,a.top+a.height/2-n-s)),h===c.LEFT?et=-n*2:U=-n*2):h===c.BELOW?(s=a.bottom+n,s=Math.max(s,C.top+n),s=Math.min(s,C.bottom+n),s=Math.max(s,n),s=Math.min(s,x-v)):(s=a.top-n-v,s=Math.max(s,C.top-v-n),s=Math.min(s,C.bottom-v-n),s=Math.max(s,0),s=Math.min(s,x-v-n)),Z){const B=window.getComputedStyle(H.targetEl);at=Math.max(0,I.top),nt=Math.max(0,O-I.right),mt=Math.max(0,x-I.bottom),ut=Math.max(0,I.left),$=Math.max(0,Ht(B.borderTopLeftRadius)+lt),kt=Math.max(0,Ht(B.borderTopRightRadius)+lt),bt=Math.max(0,Ht(B.borderBottomRightRadius)+lt),pt=Math.max(0,Ht(B.borderBottomLeftRadius)+lt),gt=Math.max(0,I.right),wt=Math.max(0,I.top),Et=Math.max(0,I.right),yt=Math.max(0,I.bottom),Pt=Math.max(0,I.left),Ot=Math.max(0,I.bottom),Nt=Math.max(0,I.left),xt=Math.max(0,I.top)}}else h=m||c.BELOW,(h===c.BELOW||h===c.ABOVE)&&(U=R/2-n,h===c.BELOW?G=-n*2:J=-n*2),(h===c.LEFT||h===c.RIGHT)&&(G=v/2-n,h===c.LEFT?et=-n*2:U=-n*2);e.tooltipPlacement=h,z+=` userflowjs-bubble__tooltip-notch--${h.toLowerCase()}`,q="",Z&&(Rt+=" userflowjs-tooltip-backdrop--visible",ht+=" userflowjs-tooltip-block--visible",Tt+=" userflowjs-tooltip-block--visible",Lt+=" userflowjs-tooltip-block--visible",jt+=" userflowjs-tooltip-block--visible");break}}b.style.transition="";let vt=r,It=s;if(t&&(b.style.opacity="0",N===y.TOOLTIP))switch(e.tooltipPlacement){case c.BELOW:s+=24;break;case c.ABOVE:s-=24;break;case c.RIGHT:r+=24;break;case c.LEFT:r-=24;break}if(o!=="relative"&&se(b,r,s),g.className=z,g.style.visibility=q,d(g,"top",G),d(g,"right",et),d(g,"bottom",J),d(g,"left",U),f.className=Rt,d(f,"top",at),d(f,"right",nt),d(f,"bottom",mt),d(f,"left",ut),d(f,"border-top-left-radius",$),d(f,"border-top-right-radius",kt),d(f,"border-bottom-right-radius",bt),d(f,"border-bottom-left-radius",pt),E.className=ht,d(E,"width",gt),d(E,"height",wt),k.className=Tt,d(k,"left",Et),d(k,"height",yt),_.className=Lt,d(_,"left",Pt),d(_,"top",Ot),W.className=jt,d(W,"width",Nt),d(W,"top",xt),t){b.offsetWidth;const h="opacity 250ms linear";N===y.TOOLTIP?b.style.transition=`${h}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:b.style.transition=h,b.style.opacity="1",o!=="relative"&&se(b,vt,It)}}function xe({targetRect:e,bubbleWidth:t,bubbleHeight:o,containerWidth:T,containerHeight:M,viewportClipRect:m,tooltipNotchSize:l,currentTooltipPlacement:b,desiredTooltipPlacement:g}){if(e.bottom<=m.top)return o+l<=M-m.top?c.BELOW:c.ABOVE;if(e.top>=m.bottom)return o+l<=m.bottom?c.ABOVE:c.BELOW;if(e.right<=m.left)return t+l<=T-m.left?c.RIGHT:c.LEFT;if(e.left>=m.right)return t+l<=m.right?c.LEFT:c.RIGHT;const f=k=>{const _=e.left+e.width/2,W=_>=m.left&&_<=m.right,Q=e.top+e.height/2,N=Q>=m.top&&Q<=m.bottom;switch(k){case c.BELOW:return M-e.bottom>o+l&&W;case c.ABOVE:return e.top>o+l&&W;case c.RIGHT:return T-e.right>t+l&&N;case c.LEFT:return e.left>t+l&&N}};if(g&&f(g))return g;if(b&&f(b))return b;const E=[{placement:c.BELOW,dist:e.top},{placement:c.ABOVE,dist:M-e.bottom},{placement:c.RIGHT,dist:e.left},{placement:c.LEFT,dist:T-e.right}];E.sort((k,_)=>k.dist-_.dist);for(const{placement:k}of E)if(f(k))return k;return c.BELOW}function d(e,t,o){o==null?e.style.removeProperty(t):e.style.setProperty(t,typeof o=="number"?o+"px":o,"important")}function se(e,t,o){t=Math.round(t),o=Math.round(o),e.style.transform=`translate3d(${t}px, ${o}px, 0px)`}function Ie(e){if(A.customScrollIntoView){A.customScrollIntoView(e);return}const{scrollPadding:t}=A;if(t&&ye(e)===document.scrollingElement){const o=t.top||0,T=t.right||0,M=t.bottom||0,m=t.left||0;let l=0,b=0;const g=e.getBoundingClientRect(),f=Dt(),E=Wt();if(g.top<o?l=g.top-o:g.bottom>E-M&&(l=g.bottom-E+M),g.left<m?b=g.left-m:g.right>f-T&&(b=g.right-f+T),l!=0||b!=0){window.scrollBy({top:l,left:b,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 _e(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=st(t[0]);return{paddingTop:o,paddingRight:o,paddingBottom:o,paddingLeft:o}}else if(t.length===2){const o=st(t[0]),T=st(t[1]);return{paddingTop:o,paddingRight:T,paddingBottom:o,paddingLeft:T}}else return{paddingTop:st(t[0]),paddingRight:st(t[1]),paddingBottom:st(t[2]),paddingLeft:st(t[3])}}function st(e){const t=parseInt(e,10);return isNaN(t)?0:t}export{Ye as F};
1
+ import{r as u,R as w}from"./vendor.react.js";import{u as de,F as oe}from"./use-window-resize.js";import{c as A,k as y,p as it,m as me,q as j,y as be,x as c}from"./userflow.js";import{a as pe,f as he}from"./flow-host.styl.js";import{b as ge}from"./bubble-frame.styl.js";import{S as we}from"./logomark.js";import{o as Vt}from"./vendor.obj-str.js";import{u as Te}from"./use-selector-element-monitoring.js";import{a as Wt,g as Dt,c as rt,m as Ee,d as ae,M as le,k as Ht,n as ye,h as Le}from"./flow-condition-types.js";import{a as ve,g as Be}from"./stylesheets.js";import"./vendor.html-parse-stringify2.js";import{u as Me}from"./vendor.react-i18next.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]="4bb7430a-6398-4d99-a0a0-290019647db2",e._sentryDebugIdIdentifier="sentry-dbid-4bb7430a-6398-4d99-a0a0-290019647db2")}catch{}})();const ke=new URL("avatar-frame.css",import.meta.url).href;function Re(e,t){const o=window.Intercom;u.useEffect(()=>{if(!(!t||!e.autoHideIntercom||typeof o!="function"||A.autoHide3pDisabled)){try{o("update",{hide_default_launcher:!0})}catch(l){console.warn("Userflow.js: Error when hiding Intercom launcher",l)}return()=>{if(!A.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 T=window.$crisp;u.useEffect(()=>{if(!(!t||!e.autoHideCrisp||!T||A.autoHide3pDisabled)){try{T.push(["do","chat:hide"])}catch(l){console.warn("Userflow.js: Error when hiding Crisp Chat",l)}return()=>{if(!A.autoHide3pDisabled)try{T.push(["do","chat:show"])}catch(l){console.warn("Userflow.js: Error when unhiding Crisp Chat",l)}}}},[T,e.autoHideCrisp,t]);const M=window.HubSpotConversations;u.useEffect(()=>{if(!(!t||!e.autoHideHubspot||!M||A.autoHide3pDisabled)){try{M.widget.remove()}catch(l){console.warn("Userflow.js: Error when hiding HubSpot Chat",l)}return()=>{if(!A.autoHide3pDisabled)try{M.widget.load()}catch(l){console.warn("Userflow.js: Error when unhiding HubSpot Chat",l)}}}},[M,e.autoHideHubspot,t]);const m=window.drift;u.useEffect(()=>{if(!(!t||!e.autoHideDrift||!m||A.autoHide3pDisabled)){try{m.api.widget.hide()}catch(l){console.warn("Userflow.js: Error when hiding Drift Chat",l)}return()=>{if(!A.autoHide3pDisabled)try{m.api.widget.show()}catch(l){console.warn("Userflow.js: Error when unhiding Drift Chat",l)}}}},[m,e.autoHideDrift,t])}const At=16,Mt=20,Ye=({company:e,theme:t,position:o,absoluteWidth:T,absoluteHeight:M,stepKey:m,stepAppearance:l,width:b,backgroundImageUrl:g,tooltipSelector:f,allowMissingTooltipTarget:E,tooltipPlacement:R,backdrop:_,tooltipTargetBlocked:W,backdropPadding:Q,zIndex:N,onTooltipTargetClick:L,onTooltipTargetMissingChange:H,onModalBackdropClick:Z,onVisibleChange:tt,speaking:D,noIframe:P,MadeWithUserflow:n,minimizeOnAvatarClick:F,autoHide3pEnabled:k,bubbleFrameRootRef:v,frameWrapperHtmlAttributes:O,rootChildren:x,children:r})=>{const s=o||"absolute",z=R||null,q=Q||"0",G=n||Oe,et=pe(),J=s==="fixed"?N??et+1:1,U=J-1,{i18n:kt}=Me(),at=kt.dir(),nt=u.useRef(null),mt=u.useRef(null),ut=u.useRef(null),[$,Rt]=u.useState(null),bt=u.useRef(null),pt=u.useRef(null),ht=u.useRef(null),gt=u.useRef(null),wt=u.useRef(null),Tt=u.useRef(null),Et=u.useRef(null),yt=u.useRef(null),Lt=u.useRef(null);u.useLayoutEffect(()=>{const i=nt.current.style;i.animation="none",i.visibility="hidden",i.position="absolute",i.top="-99999px",i.left="-99999px"},[]);const{loaded:Pt}=ve(window,he,t),[Ot,jt]=u.useState(!1),[Nt,xt]=u.useState(!1),vt=Pt&&Ot&&Nt;let[It,h]=u.useState(!1);l!==y.BUBBLE&&(F=!1,It=!1),u.useEffect(()=>{h(!1)},[m]);const a=u.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}),[C,lt]=u.useState(null),I=C!=null&&vt;u.useEffect(()=>{tt&&tt(I)},[tt,I]);const Y=u.useCallback(i=>{a.current.lastReportedTooltipTargetMissing!==i&&(a.current.lastReportedTooltipTargetMissing=i,H&&H(i))},[H]),B=u.useCallback(({forceAppearanceLayout:i,forceUpdatePosition:S}={})=>{const dt=nt.current,_t=mt.current,Bt=ut.current,zt=pt.current,Gt=bt.current,$t=ht.current,Yt=gt.current,Xt=wt.current,Zt=Tt.current,qt=Et.current,Jt=yt.current,Kt=Lt.current;if(!dt||!_t||!Bt||!$||!zt||!Gt||!$t||!Yt||!Xt||!Zt||!qt||!Jt||!Kt||!vt)return;const p=a.current,{tooltipTargetParams:Ft}=p;Le();let V=l,Qt=!1;V===y.TOOLTIP&&!E&&!Ft&&(p.tooltipTargetMissing?(V=y.BUBBLE,Qt=!0):V=null);const te=V!==p.appearance,ue=b!==p.width;if((i||te||ue||t!==p.theme||_!=p.backdrop||q!=p.backdropPadding||z!==p.desiredTooltipPlacement)&&(p.appearance=V,p.width=b,p.theme=t,p.backdrop=_,p.backdropPadding=q,p.desiredTooltipPlacement=z,S=!0,je({layoutState:p,width:b,position:s,absoluteWidth:T,root:dt,bubble:_t,bubbleFrameRoot:$,avatar:zt,avatarNotch:Gt,modalBackdrop:Kt,dir:at})),!P){const X=$.offsetHeight,Ct=Wt(),St=Dt()<800?0:At,ce=t.avatarType===it.NONE?0:V===y.BUBBLE?Mt+t.avatarSize:V===y.MODAL?t.avatarSize/2:0,ee=Ct-2*St-ce,Ut=Math.min(X,ee);if(V&&Ut!==p.bubbleFrameHeight){if(p.bubbleFrameHeight=Ut,d(Bt,"height",rt(Ut)),Ee(Bt)&&Bt.contentDocument){const fe=Bt.contentDocument.documentElement;fe.style.overflowY=X<=ee?"hidden":"scroll"}S=!0}}if(S&&V){let X=te;if(V===y.TOOLTIP){const Ct=p.tooltipTargetParams&&p.tooltipTargetParams.targetEl,St=p.prevTooltipTargetParams&&p.prevTooltipTargetParams.targetEl;Ct!==St&&(X=!0)}p.prevTooltipTargetParams=p.tooltipTargetParams,Ne({layoutState:p,animateIn:X,position:s,absoluteWidth:T,absoluteHeight:M,desiredTooltipPlacement:z,root:dt,bubble:_t,tooltipNotch:$t,tooltipBackdrop:Yt,tooltipBlockTop:Xt,tooltipBlockRight:Zt,tooltipBlockBottom:qt,tooltipBlockLeft:Jt,dir:at})}if(V===y.TOOLTIP){const X=Ft&&Ft.targetEl;X&&p.stepKeyScrolledIntoView!==m&&p.targetScrolledIntoView!==X&&(p.stepKeyScrolledIntoView=m,p.targetScrolledIntoView=X,Ie(X))}else p.stepKeyScrolledIntoView=void 0,p.targetScrolledIntoView=null;Y(Qt),lt(V)},[vt,$,m,l,b,t,s,T,M,E,z,_,q,P,Y,at]),K=u.useRef(B);K.current=B;const ct=u.useRef(!1);u.useEffect(()=>{const i=()=>{ct.current=!0};return window.addEventListener("pagehide",i),()=>window.removeEventListener("pagehide",i)},[]);const ot=()=>{window.clearTimeout(a.current.tooltipTargetMissingTimeout),a.current.tooltipTargetMissingTimeout=void 0};u.useEffect(()=>ot,[]);const re=u.useCallback(()=>{const i=a.current;if(i.tooltipTargetParams=null,E||(i.tooltipPlacement=null),l!==y.TOOLTIP){ot(),i.tooltipTargetMissing=!1;return}if(!E&&!i.tooltipTargetMissingTimeout){i.tooltipTargetMissing=!1;const S=f&&!ae(f)&&f.type===me.AUTO&&!f.autoData?1:parseFloat(t.tooltipMissingToleranceSeconds)*1e3;i.tooltipTargetMissingTimeout=window.setTimeout(()=>{if(!ct.current){if(f&&!ae(f)){let dt=f.autoData;if(f.autoData)try{dt=JSON.parse(f.autoData)}catch{}console.warn(`Userflow.js: Tooltip target not found on page.
2
+ `,{type:f.type,autoData:dt,excludeText:f.excludeText,precision:f.precision,text:f.text,css:f.css})}ot(),i.tooltipTargetMissing=!0,K.current()}},S)}K.current()},[l,E,f,t.tooltipMissingToleranceSeconds]),ie=u.useCallback(i=>{const S=a.current;ot(),S.tooltipTargetParams&&S.tooltipTargetParams.targetEl!==i.targetEl&&(S.tooltipPlacement=null),S.tooltipTargetParams=i,B({forceUpdatePosition:!0})},[B]);Te({selector:l===y.TOOLTIP&&f||null,targetMoved:ie,targetLost:re,onTargetClick:L});const ne=u.useCallback(()=>B({forceAppearanceLayout:!0}),[B]);de(ne),u.useEffect(()=>{if(!$||P||typeof le!="function")return;let i;const S=new le(()=>{i||(i=window.requestAnimationFrame(()=>{i=void 0,K.current()}))});return S.observe($,{childList:!0,attributes:!0,subtree:!0}),()=>{S.disconnect(),i&&window.cancelAnimationFrame(i)}},[$,P]),u.useLayoutEffect(()=>{K.current()}),u.useLayoutEffect(()=>{s==="absolute"&&B({forceAppearanceLayout:!0})},[s,T,M]);const ft=i=>{i.preventDefault(),i.stopPropagation()};return Re(t,!!k&&C===y.BUBBLE),w.createElement("div",{ref:nt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:Be(t),dir:at},w.createElement("div",{className:"userflowjs-bubble",ref:mt,style:{zIndex:J}},w.createElement("div",{className:Vt({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(t.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!F,"userflowjs-bubble-outline--minimized":It})},w.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...O},w.createElement(oe,{className:"userflowjs-bubble__frame",elRef:ut,stylesheet:ge,theme:t,onStylesheetsLoad:jt,noIframe:P,title:l.toLowerCase()},w.createElement("div",{className:"userflowjs-bubble-frame-root",ref:i=>{v&&v(i),Rt(i)},style:g?{backgroundImage:`url("${encodeURI(g)}")`}:void 0},r,e.flowBranding&&w.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},w.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},w.createElement(G,{company:e},w.createElement(we,null),w.createElement("div",null,"Made with Userflow"))))))),w.createElement("div",{ref:bt,className:"userflowjs-bubble__avatar-notch"})),w.createElement(oe,{className:Vt({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!F,"userflowjs-bubble__avatar--speaking":!!D}),elRef:pt,stylesheet:ke,theme:t,onStylesheetsLoad:xt,noIframe:P,ariaHidden:!0,title:l.toLowerCase()},w.createElement("div",{className:Vt({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!F}),onClick:F?()=>h(i=>!i):void 0},w.createElement(Pe,{theme:t}))),w.createElement("div",{ref:ht,className:"userflowjs-bubble__tooltip-notch"})),w.createElement("div",{ref:gt,className:"userflowjs-tooltip-backdrop",onMouseDown:ft,style:{zIndex:U,pointerEvents:W?void 0:"none"}}),w.createElement("div",{ref:wt,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:Tt,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:Et,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:yt,className:"userflowjs-tooltip-block",onMouseDown:ft,style:{zIndex:U}}),w.createElement("div",{ref:Lt,className:"userflowjs-modal-backdrop",onMouseDown:ft,onClick:Z,style:{zIndex:U}}),x&&x({visible:I,bubbleFrame:ut.current}))},Pe=({theme:e})=>{const t="https://js.userflow.com/cartoon-avatars-no-bg/";let o;return e.avatarType===it.ASSET&&e.avatarAsset?o=e.avatarAsset.assetUrl:e.avatarType===it.CARTOON&&e.avatarName?o=t+e.avatarName+".svg?3":e.avatarType===it.URL&&e.avatarUrl?o=e.avatarUrl:o=t+"none.svg",w.createElement("img",{src:o,alt:""})},Oe=({company:e,children:t})=>w.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 je({layoutState:{appearance:e,theme:t,backdrop:o,tooltipTargetMissing:T},width:M,position:m,absoluteWidth:l,root:b,bubble:g,bubbleFrameRoot:f,avatar:E,avatarNotch:R,modalBackdrop:_,dir:W}){const Q=m==="absolute"?l||1024:rt(Dt()),{avatarSize:N,bubblePlacement:L}=t;let H=t.bubbleWidth,Z=null,tt=null,D=`userflowjs-bubble-frame-root userflowjs-bubble-frame-root--appearance-${e?.toLowerCase()}`,P="hidden",n=null,F=null,k=null,v=null,O="userflowjs-bubble__avatar-notch",x="hidden",r=null,s=null,z=null,q=null,G="userflowjs-modal-backdrop";switch((e===y.MODAL||!T&&e===y.BUBBLE&&o)&&(G+=" userflowjs-modal-backdrop--visible"),e){case y.BUBBLE:if(t.avatarType!==it.NONE){P="",x="",L===j.TOP_LEFT||L===j.TOP_CENTER||L===j.TOP_RIGHT?(Z=N+Mt,n=0,r=-2*Mt,O+=" userflowjs-bubble__avatar-notch--top"):(tt=N+Mt,k=0,z=-2*Mt,O+=" userflowjs-bubble__avatar-notch--bottom");const J=L===j.TOP_LEFT||L===j.TOP_CENTER||L===j.BOTTOM_LEFT||L===j.BOTTOM_CENTER||L===j.CENTER;W==="ltr"&&J||W==="rtl"&&!J?(v=0,q=N,O+=" userflowjs-bubble__avatar-notch--left"):(F=0,s=N,O+=" userflowjs-bubble__avatar-notch--right")}break;case y.MODAL:H=t.modalWidth,t.avatarType!==it.NONE&&(P="",v=`calc(50% - ${N/2}px)`,n=-N/2);break;case y.TOOLTIP:H=t.tooltipWidth;break}M!=null&&(H=M),H=Math.min(H,Q-2*At),b.classList.toggle("userflowjs-flow-chrome--position-absolute",m==="absolute"),b.classList.toggle("userflowjs-flow-chrome--position-relative",m==="relative"),b.classList.toggle("userflowjs-flow-chrome--position-fixed",m==="fixed"),b.classList.toggle("userflowjs-flow-chrome--appearance-modal",e===y.MODAL);const et=e!=null&&e!==y.HIDDEN;b.style.position="",b.style.top="",b.style.left="",b.style.visibility=et?"":"hidden",b.style.animation=et?"":"none",d(g,"width",rt(H)),d(g,"padding-top",Z),d(g,"padding-bottom",tt),f.className=D,d(E,"width",rt(t.avatarSize)),d(E,"height",rt(t.avatarSize)),E.style.visibility=P,d(E,"top",n),d(E,"right",F),d(E,"bottom",k),d(E,"left",v),R.className=O,R.style.visibility=x,d(R,"top",r),d(R,"right",s),d(R,"bottom",z),d(R,"left",q),_.className=G}function Ne({layoutState:e,animateIn:t,position:o,absoluteWidth:T,absoluteHeight:M,desiredTooltipPlacement:m,root:l,bubble:b,tooltipNotch:g,tooltipBackdrop:f,tooltipBlockTop:E,tooltipBlockRight:R,tooltipBlockBottom:_,tooltipBlockLeft:W,dir:Q}){const{appearance:N,theme:L,tooltipTargetParams:H,backdrop:Z,backdropPadding:tt}=e,{bubblePlacement:D}=L,P=At,n=L.tooltipNotchSize,F=10,{width:k,height:v}=b.getBoundingClientRect(),O=o==="absolute"?T||1024:rt(Dt()),x=o==="absolute"?M||768:rt(Wt());let r=0,s=0,z="userflowjs-bubble__tooltip-notch",q="hidden",G=null,et=null,J=null,U=null,kt="userflowjs-tooltip-backdrop",at=null,nt=null,mt=null,ut=null,$=null,Rt=null,bt=null,pt=null,ht="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",Pt=null,Ot=null,jt="userflowjs-tooltip-block userflowjs-tooltip-block--left",Nt=null,xt=null;switch(N){case y.BUBBLE:{D===j.TOP_LEFT||D===j.BOTTOM_LEFT?r=L.bubbleX:D===j.TOP_CENTER||D===j.CENTER||D===j.BOTTOM_CENTER?r=(O-k)/2:r=O-k-L.bubbleX,D===j.TOP_LEFT||D===j.TOP_CENTER||D===j.TOP_RIGHT?s=L.bubbleY:D===j.CENTER?s=(x-v)/2:s=x-v-L.bubbleY,Q==="rtl"&&(r=O-r-k),r=Math.max(0,Math.min(O-k,r)),s=Math.max(0,Math.min(x-v,s));break}case y.MODAL:{let h=P;L.avatarType!==it.NONE&&(h+=L.avatarSize/2),r=P+(O-P*2-k)/2,s=h+(x-h-P-v)/2;break}case y.TOOLTIP:{let h;if(H){let{targetRect:a,viewportClipRect:C}=H;if(o==="absolute"){const B=l.offsetParent.getBoundingClientRect();C={top:0,right:O,bottom:x,left:0},a={top:a.top-B.top,right:a.right-B.left,bottom:a.bottom-B.top,left:a.left-B.left,width:a.width,height:a.height}}let lt=0;if(Z){const{paddingTop:B,paddingRight:K,paddingBottom:ct,paddingLeft:ot}=_e(tt);a={top:a.top-B,right:a.right+K,bottom:a.bottom+ct,left:a.left-ot,width:a.width+ot+K,height:a.height+B+ct},lt=Math.min(B,K,ct,ot)}const I=a,Y=L.backdropHighlightType==be.OUTSIDE?L.backdropHighlightSpread:0;if(Z&&Y&&(a={top:a.top-Y,right:a.right+Y,bottom:a.bottom+Y,left:a.left-Y,width:a.width+2*Y,height:a.height+2*Y}),h=xe({targetRect:a,bubbleWidth:k,bubbleHeight:v,containerWidth:O,containerHeight:x,viewportClipRect:C,tooltipNotchSize:n,currentTooltipPlacement:e.tooltipPlacement,desiredTooltipPlacement:m}),h===c.BELOW||h===c.ABOVE?(r=a.left+a.width/2-k/2,r=Math.max(P,Math.min(O-k-P,r)),U=Math.max(F,Math.min(k-F-n*2,a.left+a.width/2-n-r)),h===c.BELOW?G=-n*2:J=-n*2):h===c.RIGHT?(r=a.right+n,r=Math.max(r,C.left+n),r=Math.min(r,C.right+n),r=Math.max(r,n),r=Math.min(r,O-k)):(r=a.left-n-k,r=Math.max(r,C.left-k-n),r=Math.min(r,C.right-k-n),r=Math.max(r,0),r=Math.min(r,O-k-n)),h===c.LEFT||h===c.RIGHT?(s=a.top+a.height/2-v/2,s=Math.max(P,Math.min(x-v-P,s)),G=Math.max(F,Math.min(v-F-n*2,a.top+a.height/2-n-s)),h===c.LEFT?et=-n*2:U=-n*2):h===c.BELOW?(s=a.bottom+n,s=Math.max(s,C.top+n),s=Math.min(s,C.bottom+n),s=Math.max(s,n),s=Math.min(s,x-v)):(s=a.top-n-v,s=Math.max(s,C.top-v-n),s=Math.min(s,C.bottom-v-n),s=Math.max(s,0),s=Math.min(s,x-v-n)),Z){const B=window.getComputedStyle(H.targetEl);at=Math.max(0,I.top),nt=Math.max(0,O-I.right),mt=Math.max(0,x-I.bottom),ut=Math.max(0,I.left),$=Math.max(0,Ht(B.borderTopLeftRadius)+lt),Rt=Math.max(0,Ht(B.borderTopRightRadius)+lt),bt=Math.max(0,Ht(B.borderBottomRightRadius)+lt),pt=Math.max(0,Ht(B.borderBottomLeftRadius)+lt),gt=Math.max(0,I.right),wt=Math.max(0,I.top),Et=Math.max(0,I.right),yt=Math.max(0,I.bottom),Pt=Math.max(0,I.left),Ot=Math.max(0,I.bottom),Nt=Math.max(0,I.left),xt=Math.max(0,I.top)}}else h=m||c.BELOW,(h===c.BELOW||h===c.ABOVE)&&(U=k/2-n,h===c.BELOW?G=-n*2:J=-n*2),(h===c.LEFT||h===c.RIGHT)&&(G=v/2-n,h===c.LEFT?et=-n*2:U=-n*2);e.tooltipPlacement=h,z+=` userflowjs-bubble__tooltip-notch--${h.toLowerCase()}`,q="",Z&&(kt+=" userflowjs-tooltip-backdrop--visible",ht+=" userflowjs-tooltip-block--visible",Tt+=" userflowjs-tooltip-block--visible",Lt+=" userflowjs-tooltip-block--visible",jt+=" userflowjs-tooltip-block--visible");break}}b.style.transition="";let vt=r,It=s;if(t&&(b.style.opacity="0",N===y.TOOLTIP))switch(e.tooltipPlacement){case c.BELOW:s+=24;break;case c.ABOVE:s-=24;break;case c.RIGHT:r+=24;break;case c.LEFT:r-=24;break}if(o!=="relative"&&se(b,r,s),g.className=z,g.style.visibility=q,d(g,"top",G),d(g,"right",et),d(g,"bottom",J),d(g,"left",U),f.className=kt,d(f,"top",at),d(f,"right",nt),d(f,"bottom",mt),d(f,"left",ut),d(f,"border-top-left-radius",$),d(f,"border-top-right-radius",Rt),d(f,"border-bottom-right-radius",bt),d(f,"border-bottom-left-radius",pt),E.className=ht,d(E,"width",gt),d(E,"height",wt),R.className=Tt,d(R,"left",Et),d(R,"height",yt),_.className=Lt,d(_,"left",Pt),d(_,"top",Ot),W.className=jt,d(W,"width",Nt),d(W,"top",xt),t){b.offsetWidth;const h="opacity 250ms linear";N===y.TOOLTIP?b.style.transition=`${h}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:b.style.transition=h,b.style.opacity="1",o!=="relative"&&se(b,vt,It)}}function xe({targetRect:e,bubbleWidth:t,bubbleHeight:o,containerWidth:T,containerHeight:M,viewportClipRect:m,tooltipNotchSize:l,currentTooltipPlacement:b,desiredTooltipPlacement:g}){if(e.bottom<=m.top)return o+l<=M-m.top?c.BELOW:c.ABOVE;if(e.top>=m.bottom)return o+l<=m.bottom?c.ABOVE:c.BELOW;if(e.right<=m.left)return t+l<=T-m.left?c.RIGHT:c.LEFT;if(e.left>=m.right)return t+l<=m.right?c.LEFT:c.RIGHT;const f=R=>{const _=e.left+e.width/2,W=_>=m.left&&_<=m.right,Q=e.top+e.height/2,N=Q>=m.top&&Q<=m.bottom;switch(R){case c.BELOW:return M-e.bottom>o+l&&W;case c.ABOVE:return e.top>o+l&&W;case c.RIGHT:return T-e.right>t+l&&N;case c.LEFT:return e.left>t+l&&N}};if(g&&f(g))return g;if(b&&f(b))return b;const E=[{placement:c.BELOW,dist:e.top},{placement:c.ABOVE,dist:M-e.bottom},{placement:c.RIGHT,dist:e.left},{placement:c.LEFT,dist:T-e.right}];E.sort((R,_)=>R.dist-_.dist);for(const{placement:R}of E)if(f(R))return R;return c.BELOW}function d(e,t,o){o==null?e.style.removeProperty(t):e.style.setProperty(t,typeof o=="number"?o+"px":o,"important")}function se(e,t,o){t=Math.round(t),o=Math.round(o),e.style.transform=`translate3d(${t}px, ${o}px, 0px)`}function Ie(e){if(A.customScrollIntoView){A.customScrollIntoView(e);return}const{scrollPadding:t}=A;if(t&&ye(e)===document.scrollingElement){const o=t.top||0,T=t.right||0,M=t.bottom||0,m=t.left||0;let l=0,b=0;const g=e.getBoundingClientRect(),f=Dt(),E=Wt();if(g.top<o?l=g.top-o:g.bottom>E-M&&(l=g.bottom-E+M),g.left<m?b=g.left-m:g.right>f-T&&(b=g.right-f+T),l!=0||b!=0){window.scrollBy({top:l,left:b,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 _e(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=st(t[0]);return{paddingTop:o,paddingRight:o,paddingBottom:o,paddingLeft:o}}else if(t.length===2){const o=st(t[0]),T=st(t[1]);return{paddingTop:o,paddingRight:T,paddingBottom:o,paddingLeft:T}}else return{paddingTop:st(t[0]),paddingRight:st(t[1]),paddingBottom:st(t[2]),paddingLeft:st(t[3])}}function st(e){const t=parseInt(e,10);return isNaN(t)?0:t}export{Ye as F};
3
3
  //# sourceMappingURL=FlowChrome.js.map
package/LauncherApp.js CHANGED
@@ -1,2 +1,2 @@
1
- import{R as i,r as u}from"./vendor.react.js";import{L as R,r as l,s as a,o as te,t as re,v as p,w as K,x as N}from"./userflow.js";import{u as ne,r as oe}from"./use-selector-element-monitoring.js";import{m as ae,d as ce,S as se,R as le,h as ie}from"./bubble-frame.styl.js";import{u as ue,i as de}from"./client-context.js";import{o as U}from"./vendor.obj-str.js";import{a as fe,b as he,g as Ee,D as Te,u as me}from"./stylesheets.js";import{w as pe,f as be,L as ge,S as Ce}from"./flow-host.styl.js";import"./vendor.html-parse-stringify2.js";import{F as Le}from"./FlowChrome.js";import{B as Re}from"./BubbleToolbar.js";import{b as we,r as V}from"./flow-condition-types.js";import{T as Ae}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./vendor.i18next.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";import"./vendor.date-fns.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},c=new Error().stack;c&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[c]="68a9899e-00a2-40e1-a6b3-4dc6a32ccdbb",t._sentryDebugIdIdentifier="sentry-dbid-68a9899e-00a2-40e1-a6b3-4dc6a32ccdbb")}catch{}})();const ve=i.forwardRef(({appearance:t,icon:c,buttonText:d,theme:T,noAnimation:E,noFixed:w,onClick:e,onMouseEnter:s,onMouseLeave:o,noPointerEvents:n,zIndex:m},r)=>{const{loaded:C}=fe(window,be,T),k=T&&t===R.BUTTON?T:null,{loaded:H}=he(window,k),I={"userflowjs-launcher":!0,"userflowjs-launcher--activate-on-click":!!e,"userflowjs-fixed-widget":!w},f={ref:r,style:{...Ee(T),zIndex:m||pe(ge),pointerEvents:n?"none":void 0},onClick:e,onMouseEnter:s,onMouseLeave:o};if(!C||!H)return null;switch(t){case R.BEACON:return i.createElement("div",{className:U({...I,"userflowjs-beacon":!0,"userflowjs-beacon--pulse":!E,"userflowjs-beacon--pulse-still":!!E}),...f},i.createElement("div",{className:"userflowjs-beacon__ring"}),i.createElement("div",{className:"userflowjs-beacon__ring"}));case R.BUTTON:return i.createElement("div",{className:U({...I,"userflowjs-launcher--button":!0}),...f},d);case R.HIDDEN:return null;case R.ICON:return i.createElement("div",{className:U({...I,"userflowjs-launcher--icon":!0}),...f},i.createElement(Te,{icon:c||"solid/info-circle",size:T.launcherIconSize}))}}),Ie="userflowjs-fixed-widget--visible",rt=({session:t,active:c})=>{const d=ue(),{version:T}=t,E=t.id,w=t.flow.id,e=t.version.launcher,[s,o]=u.useState(null),n=me(T.theme),m=t.locale?t.locale.standardLocaleId:n.languageId;u.useEffect(()=>{de.changeLanguage(m)},[m]);const{activateOn:r}=e,C=e.activeWhileTooltipHover||e.buttons.length>0,k=e.hiddenWhileActive&&r!==l.LAUNCHER_HOVER,H=!c||!k,I=r===l.LAUNCHER_CLICK||r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK||C,f=u.useRef({}),A=u.useCallback(()=>{let h=null;const{targetEl:b,clipEl:g,viewportClipRect:F}=f.current,S=s;S&&(b&&g&&F&&(h=ke({targetEl:b,subjectEl:S,clipEl:g,viewportClipRect:F,position:e.targetPosition,subjectAnchor:e.appearance===R.BEACON?"center":"side"})),oe(()=>{Oe(S,h)}));let M;e.appearance===R.HIDDEN?M=!!b:M=!!h,M&&!f.current.seenTriggered&&!E&&(f.current.seenTriggered=!0,d.launcherSeen(w))},[s,e,d,E,w]);u.useLayoutEffect(()=>{A()},[A]);const _=u.useRef(!1),y=u.useRef(!1),P=u.useRef(!1),x=u.useRef(),W=()=>{_.current=!0,v()},z=()=>{_.current=!1,v()},Z=()=>{y.current=!0,v()},$=()=>{y.current=!1,v()},X=()=>{P.current=!0,v()},q=()=>{P.current=!1,v()},v=()=>{O();const h=250;x.current=window.setTimeout(()=>B.current(),h)},O=u.useCallback(()=>{window.clearTimeout(x.current)},[]),G=()=>{if(r===l.LAUNCHER_CLICK||r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK)return;const h=r===l.LAUNCHER_HOVER||r===l.LAUNCHER_TARGET_HOVER,b=r===l.TARGET_HOVER||r===l.LAUNCHER_TARGET_HOVER;_.current&&(!k||!c)&&h||y.current&&b||P.current&&C?D():L()},B=u.useRef(G);B.current=G;const D=()=>{c||(O(),e.tooltipEnabled?d.activateLauncher(t):(d.activateLauncher(t),d.deactivateLauncher(t)),ie(d,t,e.actions))},L=u.useCallback(()=>{c&&(O(),d.deactivateLauncher(t))},[c,d,t,O]),j=()=>{c?L():D()},J=u.useCallback(({targetEl:h,clipEl:b,viewportClipRect:g})=>{f.current.targetEl=h,f.current.clipEl=b,f.current.viewportClipRect=g,A()},[A]),Q=u.useCallback(()=>{f.current.targetEl=void 0,f.current.clipEl=void 0,A(),L()},[A,L]);ne({selector:e.targetSelector,targetMoved:J,targetLost:Q,onTargetMouseEnter:Z,onTargetMouseLeave:$,onTargetClick:r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK?j:void 0}),u.useEffect(()=>{if(!c)return;const h=b=>{const g=b.target;s&&s.contains(g)||(r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK)&&f.current.targetEl&&f.current.targetEl.contains(g)||L()};return window.addEventListener("click",h,{capture:!0}),()=>window.removeEventListener("click",h,{capture:!0})},[c,r,s,L]);const Y=Ne(e.tooltipPosition.side===a.AUTO?e.targetPosition:e.tooltipPosition),ee=u.useMemo(()=>e.content&&ae(ce(e.content),{buttons:e.buttons}),[e.content,e.buttons]);return i.createElement(se.Provider,{value:t},H&&i.createElement(ve,{ref:o,appearance:e.appearance,icon:e.icon,buttonText:e.buttonText,theme:n,onClick:r===l.LAUNCHER_CLICK||r===l.LAUNCHER_TARGET_CLICK?j:void 0,onMouseEnter:W,onMouseLeave:z,noPointerEvents:r===l.TARGET_HOVER,zIndex:e.zIndex}),c&&i.createElement(Ce,null,i.createElement(Le,{company:t.flow.company,theme:n,position:"fixed",stepAppearance:te.TOOLTIP,width:e.tooltipWidth,tooltipSelector:e.tooltipAnchor===re.TARGET?f.current.targetEl:s,tooltipPlacement:Y,frameWrapperHtmlAttributes:{onMouseEnter:X,onMouseLeave:q},rootChildren:()=>i.createElement(i.Fragment,null,e.triggers.map(h=>i.createElement(Ae,{key:h.id,trigger:h})))},i.createElement(Re,{draftMode:t.draftMode,close:I?L:void 0}),i.createElement("div",{className:"userflowjs-bubble-content"},i.createElement(le,{doc:ee,lookupAttribute:we(t.data),buttons:e.buttons})))))};function ke({targetEl:t,subjectEl:c,clipEl:d,viewportClipRect:T,position:E,subjectAnchor:w}){const e=V(t);if(e.width===0||e.height===0)return null;const s=c.getBoundingClientRect();let o=0,n=0,{side:m,align:r}=E;switch(m===a.AUTO&&(m=a.TOP,r=p.END),m){case a.TOP:n=e.top;break;case a.BOTTOM:n=e.bottom;break;case a.LEFT:o=e.left;break;case a.RIGHT:o=e.right;break}switch(m){case a.TOP:case a.BOTTOM:switch(r){case p.START:o=e.left;break;case p.CENTER:o=e.left+e.width/2;break;case p.END:o=e.right;break}break;case a.LEFT:case a.RIGHT:switch(r){case p.START:n=e.top;break;case p.CENTER:n=e.top+e.height/2;break;case p.END:n=e.bottom;break}break}switch(E.xUnit===K.PERCENT?o+=E.xOffset/100*e.width:o+=E.xOffset,E.yUnit===K.PERCENT?n+=E.yOffset/100*e.height:n+=E.yOffset,w){case"center":o-=s.width/2,n-=s.height/2;break;case"side":switch(m){case a.TOP:n-=s.height;break;case a.LEFT:o-=s.width;break}switch(m){case a.TOP:case a.BOTTOM:switch(r){case p.CENTER:o-=s.width/2;break;case p.END:o-=s.width;break}break;case a.LEFT:case a.RIGHT:switch(r){case p.CENTER:n-=s.height/2;break;case p.END:n-=s.height;break}break}}if(o+s.width<T.left||o>T.right||n+s.height<T.top||n>T.bottom)return null;const C=V(d);return o=Math.max(o,C.left-d.scrollLeft),n=Math.max(n,C.top-d.scrollTop),o=Math.round(o),n=Math.round(n),{left:o,top:n}}function Oe(t,c){t.classList.toggle(Ie,c!=null),c&&(t.style.transform=`translate3d(${c.left}px, ${c.top}px, 0)`)}function Ne(t){switch(t.side){case a.AUTO:return null;case a.TOP:return N.ABOVE;case a.BOTTOM:return N.BELOW;case a.LEFT:return N.LEFT;case a.RIGHT:return N.RIGHT}}export{rt as LauncherApp,rt as default};
1
+ import{R as i,r as u}from"./vendor.react.js";import{L as R,r as l,s as a,k as te,t as re,v as p,w as K,x as N}from"./userflow.js";import{u as ne,r as oe}from"./use-selector-element-monitoring.js";import{m as ae,d as ce,S as se,R as le,h as ie}from"./bubble-frame.styl.js";import{u as ue,i as fe}from"./client-context.js";import{o as U}from"./vendor.obj-str.js";import{a as de,b as he,g as Ee,D as Te,u as me}from"./stylesheets.js";import{w as pe,f as be,L as ge,S as Ce}from"./flow-host.styl.js";import"./vendor.html-parse-stringify2.js";import{F as Le}from"./FlowChrome.js";import{B as Re}from"./BubbleToolbar.js";import{b as we,r as V}from"./flow-condition-types.js";import{T as Ae}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./vendor.i18next.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";import"./vendor.date-fns.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},c=new Error().stack;c&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[c]="689f8161-ebb6-47ba-8f74-4f17464d19b7",t._sentryDebugIdIdentifier="sentry-dbid-689f8161-ebb6-47ba-8f74-4f17464d19b7")}catch{}})();const ve=i.forwardRef(({appearance:t,icon:c,buttonText:f,theme:T,noAnimation:E,noFixed:w,onClick:e,onMouseEnter:s,onMouseLeave:o,noPointerEvents:n,zIndex:m},r)=>{const{loaded:C}=de(window,be,T),k=T&&t===R.BUTTON?T:null,{loaded:H}=he(window,k),I={"userflowjs-launcher":!0,"userflowjs-launcher--activate-on-click":!!e,"userflowjs-fixed-widget":!w},d={ref:r,style:{...Ee(T),zIndex:m||pe(ge),pointerEvents:n?"none":void 0},onClick:e,onMouseEnter:s,onMouseLeave:o};if(!C||!H)return null;switch(t){case R.BEACON:return i.createElement("div",{className:U({...I,"userflowjs-beacon":!0,"userflowjs-beacon--pulse":!E,"userflowjs-beacon--pulse-still":!!E}),...d},i.createElement("div",{className:"userflowjs-beacon__ring"}),i.createElement("div",{className:"userflowjs-beacon__ring"}));case R.BUTTON:return i.createElement("div",{className:U({...I,"userflowjs-launcher--button":!0}),...d},f);case R.HIDDEN:return null;case R.ICON:return i.createElement("div",{className:U({...I,"userflowjs-launcher--icon":!0}),...d},i.createElement(Te,{icon:c||"solid/info-circle",size:T.launcherIconSize}))}}),Ie="userflowjs-fixed-widget--visible",rt=({session:t,active:c})=>{const f=ue(),{version:T}=t,E=t.id,w=t.flow.id,e=t.version.launcher,[s,o]=u.useState(null),n=me(T.theme),m=t.locale?t.locale.standardLocaleId:n.languageId;u.useEffect(()=>{fe.changeLanguage(m)},[m]);const{activateOn:r}=e,C=e.activeWhileTooltipHover||e.buttons.length>0,k=e.hiddenWhileActive&&r!==l.LAUNCHER_HOVER,H=!c||!k,I=r===l.LAUNCHER_CLICK||r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK||C,d=u.useRef({}),A=u.useCallback(()=>{let h=null;const{targetEl:b,clipEl:g,viewportClipRect:F}=d.current,S=s;S&&(b&&g&&F&&(h=ke({targetEl:b,subjectEl:S,clipEl:g,viewportClipRect:F,position:e.targetPosition,subjectAnchor:e.appearance===R.BEACON?"center":"side"})),oe(()=>{Oe(S,h)}));let M;e.appearance===R.HIDDEN?M=!!b:M=!!h,M&&!d.current.seenTriggered&&!E&&(d.current.seenTriggered=!0,f.launcherSeen(w))},[s,e,f,E,w]);u.useLayoutEffect(()=>{A()},[A]);const _=u.useRef(!1),y=u.useRef(!1),P=u.useRef(!1),x=u.useRef(),W=()=>{_.current=!0,v()},z=()=>{_.current=!1,v()},Z=()=>{y.current=!0,v()},$=()=>{y.current=!1,v()},X=()=>{P.current=!0,v()},q=()=>{P.current=!1,v()},v=()=>{O();const h=250;x.current=window.setTimeout(()=>B.current(),h)},O=u.useCallback(()=>{window.clearTimeout(x.current)},[]),G=()=>{if(r===l.LAUNCHER_CLICK||r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK)return;const h=r===l.LAUNCHER_HOVER||r===l.LAUNCHER_TARGET_HOVER,b=r===l.TARGET_HOVER||r===l.LAUNCHER_TARGET_HOVER;_.current&&(!k||!c)&&h||y.current&&b||P.current&&C?D():L()},B=u.useRef(G);B.current=G;const D=()=>{c||(O(),e.tooltipEnabled?f.activateLauncher(t):(f.activateLauncher(t),f.deactivateLauncher(t)),ie(f,t,e.actions))},L=u.useCallback(()=>{c&&(O(),f.deactivateLauncher(t))},[c,f,t,O]),j=()=>{c?L():D()},J=u.useCallback(({targetEl:h,clipEl:b,viewportClipRect:g})=>{d.current.targetEl=h,d.current.clipEl=b,d.current.viewportClipRect=g,A()},[A]),Q=u.useCallback(()=>{d.current.targetEl=void 0,d.current.clipEl=void 0,A(),L()},[A,L]);ne({selector:e.targetSelector,targetMoved:J,targetLost:Q,onTargetMouseEnter:Z,onTargetMouseLeave:$,onTargetClick:r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK?j:void 0}),u.useEffect(()=>{if(!c)return;const h=b=>{const g=b.target;s&&s.contains(g)||(r===l.TARGET_CLICK||r===l.LAUNCHER_TARGET_CLICK)&&d.current.targetEl&&d.current.targetEl.contains(g)||L()};return window.addEventListener("click",h,{capture:!0}),()=>window.removeEventListener("click",h,{capture:!0})},[c,r,s,L]);const Y=Ne(e.tooltipPosition.side===a.AUTO?e.targetPosition:e.tooltipPosition),ee=u.useMemo(()=>e.content&&ae(ce(e.content),{buttons:e.buttons}),[e.content,e.buttons]);return i.createElement(se.Provider,{value:t},H&&i.createElement(ve,{ref:o,appearance:e.appearance,icon:e.icon,buttonText:e.buttonText,theme:n,onClick:r===l.LAUNCHER_CLICK||r===l.LAUNCHER_TARGET_CLICK?j:void 0,onMouseEnter:W,onMouseLeave:z,noPointerEvents:r===l.TARGET_HOVER,zIndex:e.zIndex}),c&&i.createElement(Ce,null,i.createElement(Le,{company:t.flow.company,theme:n,position:"fixed",stepAppearance:te.TOOLTIP,width:e.tooltipWidth,tooltipSelector:e.tooltipAnchor===re.TARGET?d.current.targetEl:s,tooltipPlacement:Y,frameWrapperHtmlAttributes:{onMouseEnter:X,onMouseLeave:q},rootChildren:()=>i.createElement(i.Fragment,null,e.triggers.map(h=>i.createElement(Ae,{key:h.id,trigger:h})))},i.createElement(Re,{draftMode:t.draftMode,close:I?L:void 0}),i.createElement("div",{className:"userflowjs-bubble-content"},i.createElement(le,{doc:ee,lookupAttribute:we(t.data),buttons:e.buttons})))))};function ke({targetEl:t,subjectEl:c,clipEl:f,viewportClipRect:T,position:E,subjectAnchor:w}){const e=V(t);if(e.width===0||e.height===0)return null;const s=c.getBoundingClientRect();let o=0,n=0,{side:m,align:r}=E;switch(m===a.AUTO&&(m=a.TOP,r=p.END),m){case a.TOP:n=e.top;break;case a.BOTTOM:n=e.bottom;break;case a.LEFT:o=e.left;break;case a.RIGHT:o=e.right;break}switch(m){case a.TOP:case a.BOTTOM:switch(r){case p.START:o=e.left;break;case p.CENTER:o=e.left+e.width/2;break;case p.END:o=e.right;break}break;case a.LEFT:case a.RIGHT:switch(r){case p.START:n=e.top;break;case p.CENTER:n=e.top+e.height/2;break;case p.END:n=e.bottom;break}break}switch(E.xUnit===K.PERCENT?o+=E.xOffset/100*e.width:o+=E.xOffset,E.yUnit===K.PERCENT?n+=E.yOffset/100*e.height:n+=E.yOffset,w){case"center":o-=s.width/2,n-=s.height/2;break;case"side":switch(m){case a.TOP:n-=s.height;break;case a.LEFT:o-=s.width;break}switch(m){case a.TOP:case a.BOTTOM:switch(r){case p.CENTER:o-=s.width/2;break;case p.END:o-=s.width;break}break;case a.LEFT:case a.RIGHT:switch(r){case p.CENTER:n-=s.height/2;break;case p.END:n-=s.height;break}break}}if(o+s.width<T.left||o>T.right||n+s.height<T.top||n>T.bottom)return null;const C=V(f);return o=Math.max(o,C.left-f.scrollLeft),n=Math.max(n,C.top-f.scrollTop),o=Math.round(o),n=Math.round(n),{left:o,top:n}}function Oe(t,c){t.classList.toggle(Ie,c!=null),c&&(t.style.transform=`translate3d(${c.left}px, ${c.top}px, 0)`)}function Ne(t){switch(t.side){case a.AUTO:return null;case a.TOP:return N.ABOVE;case a.BOTTOM:return N.BELOW;case a.LEFT:return N.LEFT;case a.RIGHT:return N.RIGHT}}export{rt as LauncherApp,rt as default};
2
2
  //# sourceMappingURL=LauncherApp.js.map
@@ -1,4 +1,4 @@
1
- import{R as t,r as v}from"./vendor.react.js";import{s as Re,b as Fe,t as ge,u as ve}from"./flow-condition-types.js";import{c as $e,D as J}from"./stylesheets.js";import"./vendor.html-parse-stringify2.js";import{o as $}from"./vendor.obj-str.js";import{c as ae,z as De,D as Le,F as A,G as Ee,S as we,E as re,H as j,U as Pe,n as _,I as Oe}from"./userflow.js";import{a as K}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as Ue}from"./vendor.react-i18next.js";import{u as ye}from"./client-context.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="60ef009c-969c-48a8-9a00-14e8194ecee9",e._sentryDebugIdIdentifier="sentry-dbid-60ef009c-969c-48a8-9a00-14e8194ecee9")}catch{}})();const Me=t.createContext(null);function le(){const e=v.useContext(Me);if(!e)throw new Error("useSession: Session was not set");return e}function Be(){const e=le();if(e.kind!=="flow")throw new Error("useFlowSession: Wrong session kind");return e}function We(e){const r=v.useRef(e),n=v.useRef(e);return e!==n.current&&JSON.stringify(e)!==JSON.stringify(n.current)&&(r.current=e),n.current=e,r.current}function he(e){const r=le(),[n,i]=v.useState(!1),s=$e(r.data),l=We(e);return v.useLayoutEffect(()=>{if(l)return Re[l.type].track({sessionData:s,condition:l,callback:b=>{i(b)}})},[s,l]),l==null?!1:n}const ze=({appearance:e,hidden:r,disabled:n,onMouseDown:i,onClick:s,text:l,active:a,children:u})=>t.createElement("button",{className:$({[dt(e)]:!0,"userflowjs-bubble-button--hidden":!!r,"userflowjs-bubble-button--active":!!a}),onMouseDown:i,onClick:s,disabled:n},u||t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l));function Ge(e){const r=Le(),n=new URL(e,r).toString();r!==n&&(ae.customNavigate?ae.customNavigate(e):window.setTimeout(()=>{De(e)},0))}async function ne(e,r,n){const{steps:i}=r.version;switch(n.type){case A.CLOSE_FLOW:switch(r.kind){case"launcher":await e.dismissLauncher(r,{endReason:re.ACTION});break;case"banner":case"flow":case"checklist":await e.endFlow(r,{endReason:re.ACTION});break}return;case A.EVAL_JS:if(ae.evalJsDisabled){console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');return}try{const s=ge(n.code||"",r.data);new Function(`"use strict";
1
+ import{R as t,r as v}from"./vendor.react.js";import{s as Re,b as Fe,t as ge,u as ve}from"./flow-condition-types.js";import{c as $e,D as J}from"./stylesheets.js";import"./vendor.html-parse-stringify2.js";import{o as $}from"./vendor.obj-str.js";import{c as ae,z as De,D as Le,F as A,G as Ee,S as we,E as re,H as j,U as Pe,o as _,I as Oe}from"./userflow.js";import{a as K}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as Ue}from"./vendor.react-i18next.js";import{u as ye}from"./client-context.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="63df8eaf-5a47-4c21-a345-6c38ee22473b",e._sentryDebugIdIdentifier="sentry-dbid-63df8eaf-5a47-4c21-a345-6c38ee22473b")}catch{}})();const Me=t.createContext(null);function le(){const e=v.useContext(Me);if(!e)throw new Error("useSession: Session was not set");return e}function Be(){const e=le();if(e.kind!=="flow")throw new Error("useFlowSession: Wrong session kind");return e}function We(e){const r=v.useRef(e),n=v.useRef(e);return e!==n.current&&JSON.stringify(e)!==JSON.stringify(n.current)&&(r.current=e),n.current=e,r.current}function he(e){const r=le(),[n,i]=v.useState(!1),s=$e(r.data),l=We(e);return v.useLayoutEffect(()=>{if(l)return Re[l.type].track({sessionData:s,condition:l,callback:b=>{i(b)}})},[s,l]),l==null?!1:n}const ze=({appearance:e,hidden:r,disabled:n,onMouseDown:i,onClick:s,text:l,active:a,children:u})=>t.createElement("button",{className:$({[dt(e)]:!0,"userflowjs-bubble-button--hidden":!!r,"userflowjs-bubble-button--active":!!a}),onMouseDown:i,onClick:s,disabled:n},u||t.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},l));function Ge(e){const r=Le(),n=new URL(e,r).toString();r!==n&&(ae.customNavigate?ae.customNavigate(e):window.setTimeout(()=>{De(e)},0))}async function ne(e,r,n){const{steps:i}=r.version;switch(n.type){case A.CLOSE_FLOW:switch(r.kind){case"launcher":await e.dismissLauncher(r,{endReason:re.ACTION});break;case"banner":case"flow":case"checklist":await e.endFlow(r,{endReason:re.ACTION});break}return;case A.EVAL_JS:if(ae.evalJsDisabled){console.error('Userflow.js: Blocked "Evaluate JavaScript" action from running, since userflow.disableEvalJs() has been called.');return}try{const s=ge(n.code||"",r.data);new Function(`"use strict";
2
2
  `+s)()}catch(s){console.error(`Userflow.js: Evaluate JavaScript action failed.
3
3
 
4
4
  Error:
@@ -1,2 +1,2 @@
1
- import{N as w,I as c,c as O,O as be,j as Me,l as pe,P as tt,Q as x,W as ne,X as nt,Y as rt,Z as C}from"./userflow.js";import"./vendor.html-parse-stringify2.js";import{i as j,a as re,b as ot,p as ke,c as Ue,s as st}from"./vendor.date-fns.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]="d618fa48-bd97-48f2-98f1-bfefa4ee4ccc",e._sentryDebugIdIdentifier="sentry-dbid-d618fa48-bd97-48f2-98f1-bfefa4ee4ccc")}catch{}})();class it extends Error{constructor(t,n){const r=`Unreachable case: ${t}`;n?n=`${n} (${r})`:n=r,super(n)}}const lt=/(\\*)\{\{([a-zA-Z0-9_.\\/]+)\}\}/g;function at(e,t){return(e||"").replace(lt,(n,r,o)=>{const s=r.length;return s%2===0?"\\".repeat(s/2)+(t(o)||""):"\\".repeat((s-1)/2)+"{{"+o+"}}"})}function ct(e){let t=null;return n=>(t||(t=new Map,e.forEach(({name:r,value:o})=>t.set(r,Array.isArray(o)?o[0]:o))),t.get(n)||null)}function D(e,t){const n=ct(t);return at(e,r=>n(r))}function ie(e,t){const n=Se(e,t),r=e.nearSelector&&Se(e.nearSelector,t);return e===n&&e.nearSelector===r?e:e.nearSelector===r?n:{...n,nearSelector:r}}function Se(e,t){if(!e.text)return e;const n=D(e.text,t);return n===e.text?e:{...e,text:n}}function ut(e,t){return e.includes.length===0&&e.excludes.length===0?!1:(e.includes.length===0||e.includes.some(n=>{const r=Ae(n);return r&&t.match(r)}))&&!e.excludes.some(n=>{const r=Ae(n);return r&&t.match(r)})}function ft(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,n,r,o,,s,l]=t;return{scheme:n||"",domain:r||"",path:o||"",query:s||"",fragment:l||""}}function Ae(e){const t=ft(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:n,domain:r,path:o,query:s,fragment:l}=t;let i;n?i=le(n):i="[a-z\\d]+";let u;r?u=z(r,"[^/]","."):u="[^/]*";const a="(:\\d+)?";let m;o?m=z(o,"[^?#]","/"):m="/[^?#]*";let f;s?(f="",new URLSearchParams(s).forEach((h,E)=>{let T;h===""?T="=?":h==="*"?T="(=[^&#]*)?":(h=h.split(/\*/g).map(g=>encodeURI(g)).join("*"),T="="+z(h,"[^#]")),f+="(?=.*[?&]"+le(E)+T+"([&#]|$))"}),f+="\\?[^#]*"):f="(\\?[^#]*)?";let p;return l?p=z(l,".","/"):p="(#.*)?",new RegExp("^"+i+"://"+u+a+m+f+p+"$")}function z(e,t,n){return e=le(e),e=e.replace(/\\\*/g,t+"*"),n&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+n+"]+")),e}function le(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const oe={[w.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const n=k(t),r=X(e.value,"00:00:00.000"),o=X(e.value,"23:59:59.999");return n!=null&&r!=null&&o!=null&&!j(n,r)&&!re(n,o)}},[w.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const n=k(t),r=X(e.value,"23:59:59.999");return n!=null&&r!=null&&re(n,r)}},[w.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const n=k(t),r=X(e.value,"00:00:00.000");return n!=null&&r!=null&&j(n,r)}},[w.AND]:{compare:()=>Le("AND.compare")},[w.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(A(t))>=parseFloat(e.value)&&parseFloat(A(t))<=parseFloat(e.value2)},[w.CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&A(n).toLowerCase().includes(D(t.value||"",e).toLowerCase())},[w.EMPTY]:{compare:({value:e})=>e==null||e===""||Array.isArray(e)&&e.length===0},[w.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&A(n).toLowerCase().endsWith(D(t.value||"",e).toLowerCase())},[w.EQ]:{compare:({sessionData:e,condition:t,value:n})=>D(t.value||"",e)===A(n)},[w.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return!(e.values||[]).some(r=>n.has(r))}},[w.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return!(e.values||[]).every(r=>n.has(r))}},[w.FALSE]:{compare:({value:e})=>A(e).toLowerCase()==="false"},[w.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))>parseFloat(e.value)},[w.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))>=parseFloat(e.value)},[w.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return(e.values||[]).every(r=>n.has(r))}},[w.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return(e.values||[]).some(r=>n.has(r))}},[w.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))<parseFloat(e.value)},[w.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))<=parseFloat(e.value)},[w.NE]:{compare:({sessionData:e,condition:t,value:n})=>D(t.value||"",e)!==A(n)},[w.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!n||!A(n).toLowerCase().includes(D(t.value||"",e).toLowerCase())},[w.NOT_EMPTY]:{compare:({value:e})=>e!=null&&e!==""&&(!Array.isArray(e)||e.length>0)},[w.NOT_REGEX]:{compare:({condition:e,value:t})=>!xe(e,t)},[w.OR]:{compare:()=>Le("OR.compare")},[w.REGEX]:{compare:({condition:e,value:t})=>xe(e,t)},[w.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const n=k(t),r=se(e.value);return n==null||r==null?!1:!j(n,r)&&j(n,ot(r,1))}},[w.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const n=k(t),r=se(e.value);return n==null||r==null?!1:re(n,r)}},[w.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const n=k(t),r=se(e.value);return n==null||r==null?!1:j(n,r)}},[w.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&A(n).toLowerCase().startsWith(D(t.value||"",e).toLowerCase())},[w.TRUE]:{compare:({value:e})=>A(e).toLowerCase()==="true"},[w.URL]:{compare:({condition:e,value:t})=>e.urlPattern&&t!=null?ut(e.urlPattern,A(t)):!1}};function Le(e){throw new Error(`conditionOperators.${e} is not supported`)}function k(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=ke(e);return Ue(t)?t:null}function X(e,t){if(!e)return null;e+="T"+t+"Z";const n=ke(e);return Ue(n)?n:null}function se(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:st(Date.now(),t)}function xe(e,t){return e.value?new RegExp(e.value).test(A(t)):!1}function A(e){return Array.isArray(e)?e[0]:e??""}function Z(e){return Array.isArray(e)?e:e===""||e==null?[]:[e]}let he=window.MutationObserver;const U=window;if(U.Zone&&typeof U.Zone.__symbol__=="function"){const e=U.Zone.__symbol__("MutationObserver");e&&typeof e=="string"&&U.hasOwnProperty(e)&&typeof U[e]=="function"&&(he=U[e])}function Oe(e,t){const n=e.left,r=e.top,o=n+e.width,s=r+e.height,l=t.left,i=t.top,u=l+t.width,a=i+t.height;return dt(n,r,o,s,l,i,u,a)}function dt(e,t,n,r,o,s,l,i){const u=l<e,a=n<o,m=i<t,f=r<s;return f&&u?Q(e,r,l,s):u&&m?Q(e,t,l,i):m&&a?Q(n,t,o,i):a&&f?Q(n,r,o,s):u?e-l:a?o-n:m?t-i:f?s-r:0}function Q(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}function V(e){window.performance.mark&&window.performance.mark(e)}function we(e,t,n){window.performance.measure&&window.performance.measure(e,t,n)}function mt(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&e.zoom!=="1"){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}function tn(e){return ht(),pt(e)}let q;function pt(e){return q==null&&(q=mt()),q==1?e:e/q}function ht(){q=null}function nn(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientWidth||window.innerWidth}function wt(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientHeight||window.innerHeight}function rn(e){return e?parseFloat(e.replace(/px$/,"")):0}function on(e){return e==null?void 0:e+"px"}const Et=50,gt=100,Ne=25,Tt=new Set(["left","start","justify","justify-all"]);class vt{constructor(t){this.ctx=t,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(t,n){const r=this.getRect(t),o=this.getRect(n),s=this.distBetween(t,n),l=Te(n)?gt:Et;if(s>l)return 0;const i=this.isLabelLike(t),u=this.isCloserToOtherInput(t,n),a=window.getComputedStyle(t).textAlign||"",m=r.top+r.height<=o.top,f=Math.abs(r.left-o.left)<Ne&&(!a||Tt.has(a)),p=r.left+r.width<=o.left,d=Math.abs(r.top-o.top)<Ne,h=m&&f||p&&d,E=r.height>=wt()/2,T=Ge(n);if(T&&r.top>=o.top+o.height)return 0;let g=1;const S=t.htmlFor;return S&&S===n.id&&(g+=Math.pow(1e3,4)),T&&!E&&!u&&(i&&h?g+=Math.pow(1e3,3):n===t&&this.hasPlaceholder(n)?g+=Math.pow(1e3,2):!i&&h&&(g+=Math.pow(1e3,1))),g+=l-s,g}getRect(t){let n=this.rectCache.get(t);return n||(n=N(t),this.rectCache.set(t,n)),n}isLabelLike(t){let n=this.isLabelLikeCache.get(t);if(n===void 0){const r="a, button, h1, h2, h3, h4, h5, h6, input";n=!t.closest(r)&&!t.querySelector(r),this.isLabelLikeCache.set(t,n)}return n}hasPlaceholder(t){let n=this.hasPlaceholderCache.get(t);return n===void 0&&(n=!!G(t),this.hasPlaceholderCache.set(t,n)),n}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(We())).filter(t=>ve(t,this.ctx))),this.allInputs}distBetween(t,n){return Math.round(Oe(this.getRect(t),this.getRect(n)))}isCloserToOtherInput(t,n){let r=this.distBetween(t,n);for(let o of this.getAllInputs()){if(o===n)continue;if(this.distBetween(t,o)<r)return!0}return!1}}function yt(e,t={}){const n=performance.now();V("userflow:inferSelector:start"),c.groupCollapsed("inferSelector for",e,t);let r;try{r=St(e,t)}catch(o){console.error("Userflow findElement error:",o),r=null}return c("time",performance.now()-n),c.groupEnd(),V("userflow:inferSelector:end"),we("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),r}function Fe(e){const t=[],n=e.tagName.toLowerCase();return O.inferenceAttributeNames.forEach(r=>{const o=e.getAttribute(r);if(!o)return;const s=O.inferenceAttributeFilters[r];if(!(s&&!be(s,o)))if(r==="id")t.push(`#${o}`);else{const l=r==="name"||r==="placeholder"?n:"";t.push(`${l}[${r}="${o}"]`)}}),e.classList.forEach(r=>{be(O.inferenceClassNameFilters,r)&&(r=r.replace(/:/g,"\\:").trim(),t.push(`.${r}`))}),t}const bt=window.userflow||{};bt.__inferSelector=yt;function St(e,{elementType:t}={}){const n={minorVersion:Nt};let r=Ge(e);const o=Ft(e);if(t===Me.INPUT&&!r)if(o)e=o,r=!0,c("use custom input parent",o);else return c("not an input"),null;else o&&(e=o,r=!0);const s=At(e);let l=null;r||(l=$e(e),l&&l.length>250&&(l=null)),c("text is:"+l);let i=new Map,u=new Map;const a=new Map,m=new ae(s,null,n),f=new ae(s,l,n),p=(E,T,g,S,b)=>{if(S<0)return;let v=E.get(T);v||(v=[],E.set(T,v)),v.push({css:g,offset:S,complexity:b}),c(`use css=${g}, cardinality=${T}, offset=${S}`)},d=Lt(e),h=[e.tagName.toLowerCase(),...Fe(e)];c("shadowRootSelectors:",s),c("ancestorCssSelectors:",d),c("ownCssSelectors:",h);for(const E of h)for(const T of d){const g=T?`${T} ${E}`:E,S=T?2:1,b=m.query(g),v=Array.from(b),y=v.length;if(y>100){c(`cardinality too high css=${g}, cardinality=${y}`);continue}a.set(g,y);const L=v.indexOf(e);if(p(i,y,g,L,S),l){const W=f.query(g),M=Array.from(W),Ke=M.indexOf(e),et=M.length;p(u,et,g,Ke,S)}}if(i.size>0||u.size>0){const E=S=>Array.from(S.entries()).map(([b,v])=>({cardinality:b,cssSelectors:v.sort((y,L)=>{const W=a.get(y.css),M=a.get(L.css);return W!==M?W?M?W-M:-1:1:y.complexity!==L.complexity?L.complexity-y.complexity:y.css.localeCompare(L.css)}).map(({css:y,offset:L})=>({css:y,offset:L}))})).sort((b,v)=>b.cardinality-v.cardinality),T={version:"v1",minorVersion:n.minorVersion,shadowRootSelectors:s,notextGroups:E(i),textGroups:E(u)},g={el:e,selector:{type:pe.AUTO,autoData:JSON.stringify(T),text:l,elementType:t}};return c("inference result",g),g}return c("no selector inferred "),null}function At(e){let t=[],n=e;for(;n;){let r=n.getRootNode();if($(r)){const{host:s}=r;t.unshift(s.tagName.toLowerCase()),n=s;continue}const o=K(n);if(o){let s=o.tagName.toLowerCase();const l=o.getAttribute("name");l?s+=`[name="${l}"]`:o.id&&!o.id.match(/\d$/)&&(s+="#"+o.id),t.unshift(s),n=o;continue}break}if(t.length!==0)return t}function Lt(e){const t=new Map;t.set(null,0);let n=e.parentNode;for(;n&&!(n.tagName==="BODY"||$(n));){for(const o of Fe(n)){if(t.has(o))continue;const s=J(document.body,o);if(s){const l=s.length;t.set(o,l)}}n=n.parentNode}return Array.from(t.entries()).sort(([,o],[,s])=>o-s).slice(0,20).map(([o])=>o)}function xt(e,t){const{text:n,excludeText:r,precision:o}=e,s={minorVersion:t.minorVersion||0},l=n!=null&&!r,i=l?t.textGroups:t.notextGroups,u=Math.max(1,Math.min(i.length,Math.ceil((1-parseFloat(o||"1"))*i.length))),a=new ae(t.shadowRootSelectors,l&&n||null,s);c("findElementAutoV1",{text:n,excludeText:r,precision:o,groups:i,groupCount:u});for(let m=0;m<u;m++){const f=i[m];let p=new Map,d=0,h=null;c.group(`group cardinality=${f.cardinality}`,f);try{for(let E=0;E<f.cssSelectors.length;E++){const{css:T,offset:g}=f.cssSelectors[E];c(`css=${T}, offset=${g}`);let S=a.query(T),b=null;for(let y=0;y<=g;y++){const L=S.next();if(L.done)break;b=L.value}if(!b)continue;const v=(p.get(b)||0)+1;if(p.set(b,v),c(`el with frequency=${v}`+(v>d&&b!==h?" NEW BEST":""),b),v>d&&(d=v,h=b,v>=Math.ceil(f.cssSelectors.length/2)))return c("early winner",h),h}}finally{c.groupEnd()}if(h)return c("winner",h),h}return c("element not found"),null}class ae{constructor(t,n,r){this.shadowRootSelectors=t,this.text=n,this.ctx=r,this.isVisibleCache=new Map,this.textCache=new Map}*query(t){const n=J(document.body,t,this.shadowRootSelectors);if(c("found",n),!n)return;const{text:r}=this;for(let o=0;o<n.length;o++){const s=n[o];if(r){let i=this.textCache.get(s);if(i==null&&(i=te(s,r),this.textCache.set(s,i)),!i){c("skip, text mismatch",s);continue}}let l=this.isVisibleCache.get(s);if(l==null&&(l=ve(s,this.ctx),this.isVisibleCache.set(s,l)),!l){c("skip, not visible",s);continue}c("yield",s),yield s}}}const Nt=5,Y=window.userflow||{};function B(e){const t=performance.now();V("userflow:findAllElements:start"),c.groupCollapsed("findAllElements",e);let n;try{if(e.type===pe.MANUAL)n=It(e);else if(e.autoData){const r=JSON.parse(e.autoData);let o;if(r.version==="v1")o=xt(e,r);else throw new it(r.version,"Unknown autoData version: "+r.version);n=o?[o]:[]}else n=[]}catch(r){console.error("Userflow findElement error:",r),n=[]}return c("time",performance.now()-t),c.groupEnd(),V("userflow:findAllElements:end"),we("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),n}function It(e){const t={minorVersion:e.minorVersion==null?1:e.minorVersion};let{css:n,text:r,elementType:o,offset:s}=e;r=r&&F(r);const l="nearSelector"in e?e.nearSelector:null;c("findAllElementsManual",e),s!=null&&l!=null&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let i;if(r&&!n){if(i=[],t.minorVersion>=2)for(const u of Ce())ce(u,r,i);else ce(document.body,r,i);c("els after traverseElementForText",i)}else if(n){if(t.minorVersion>=2){i=[];for(const u of Ce()){const a=J(u,n);a&&a.length>0&&i.push(...a)}}else i=Array.from(J(document.body,n)||[]);c("els after safeQueryAll",i),r&&(i=Dt(i,r),c("els after filterElementsByText",i))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),i=[];if(i.length>0&&(i=i.filter(u=>ve(u,t)),c("els after isVisible",i)),i.length>0&&o===Me.INPUT&&(i=Ut(i,t),c("els after mapElementsToInputs",i)),i.length>0&&(i.sort((u,a)=>{const m=N(u),f=N(a);return m.top<f.top?-1:m.top>f.top?1:m.left-f.left}),c("els after sort",i)),i.length>0){if(s!=null)i=i[s]?[i[s]]:[],c("els after offset",i);else if(l!=null){const u=B(l);let a=null,m=0;for(const f of i)for(const p of u){const d=Oe(N(f),N(p));(!a||d<m)&&(a=f,m=d)}i=a?[a]:[],c("els after nearSelector",i)}}return i}function Ve(e){return B(e)[0]||null}function Be(e,t){const n=performance.now();V("userflow:elementMatchesSelector:start"),c.groupCollapsed("elementMatchesSelector",e,t);let r;try{if(t.type===pe.MANUAL)r=Ct(e,t);else{const o=Ve(t);r=o!=null&&o.contains(e)}}catch(o){console.error("Userflow findElement error:",o),r=!1}return c(r?"match":"not match"),c("time",performance.now()-n),c.groupEnd(),V("userflow:elementMatchesSelector:end"),we("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),r}function Ct(e,t){t.offset!=null&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet"),"nearSelector"in t&&t.nearSelector!=null&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:n,text:r}=t;r=r&&F(r);let o=!1,s=e;for(;s&&s.tagName!=="BODY";){if((!n||s.matches(n))&&(!r||te(s,r))){o=!0;break}s=s.parentElement}return o}function ce(e,t,n){if(P(e)){const{tagName:o}=e;if(o==="SCRIPT"||o==="STYLE")return!1}let r=!1;for(let o=0;o<e.children.length;o++)ce(e.children[o],t,n)&&(r=!0);return!r&&P(e)&&te(e,t)&&(n.push(e),r=!0),r}function J(e,t,n){try{return n==null?e.querySelectorAll(t):Pe(t,n,0,e)}catch{return console.info("Userflow.js: Invalid CSS selector: ",t),null}}function Pe(e,t,n,r){if(n>=t.length)return Array.from(r.querySelectorAll(e));const o=t[n],s=r.querySelectorAll(o),l=[];return s.forEach(i=>{let u;if(i.shadowRoot)u=i.shadowRoot;else{if(!He(i))return;let a=null;try{a=i.contentDocument}catch{}if(!a)return;u=a.body}l.push(...Pe(e,t,n+1,u))}),l}function Dt(e,t){const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];n.some(s=>s.contains(o))||te(o,t)&&n.push(o)}return n.reverse()}const _t={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},Rt={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},Mt={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function $e(e){let t=e.innerText;return t===void 0&&e.tagName!=="SELECT"&&(t=e.textContent),t=F(t),t||null}function G(e){if(je(e)||Ee(e)){const t=F(e.getAttribute("placeholder")),n=e.value||"";if(t&&!n)return t;const r=F(n);if(r&&Vt(e))return r}if(ge(e)&&e.selectedIndex>=0){const t=F(e.options[e.selectedIndex].text);if(t)return t}return $e(e)}function te(e,t){const n=G(e);return n?kt(t,n):!1}function kt(e,t){const n=e.toLowerCase();return t.toLowerCase()===n}function F(e){return!e||e.length>250?null:e.replace(/^[\s\uFEFF\xA0\u200B*]+|[\s\uFEFF\xA0\u200B*]+$/g,"").replace(/\s+/g," ")}function ue(e){for(const{cssSelector:t,getValue:n}of O.customInputs)if(e.matches(t))if(n)try{return(n(e)||"").trim()}catch(r){return console.error(`Userflow.js: getValue function for custom input '${t}' failed:`,r),""}else return G(e)||"";return ge(e)?e.selectedIndex==-1?"":e.options[e.selectedIndex].text:Te(e)?G(e)||"":e.value}function We(){return"input, select, textarea, [contenteditable]"+O.customInputs.map(({cssSelector:e})=>`, ${e}`).join("")}function Ut(e,t){const n=new Set,r=new vt(t),o=We();for(const s of e){if(s.matches(o)){n.add(s);continue}let l=null,i=null;r.getAllInputs().forEach(u=>{const a=r.calcScore(s,u);c("input",a,u),a!==0&&(l&&i&&a<=i||(c("input is best so far"),l=u,i=a))}),l&&(c("best input was",l),n.add(l))}return Array.from(n)}function je(e){if(e.tagName!=="INPUT")return!1;const t=e.getAttribute("type");return t==null?!0:_t[(t||"").toLowerCase()]===!0}function Ee(e){return e.tagName==="TEXTAREA"}function Ot(e){if(e.tagName!=="INPUT")return!1;const t=(e.getAttribute("type")||"").toLowerCase();return Rt[t]===!0}function ge(e){return e.tagName==="SELECT"}function Te(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function qe(e){return!!(Te(e)||O.customInputs.some(({cssSelector:t})=>e.matches(t)))}function Ft(e){let t=e.parentNode;for(;t&&!(t.tagName==="BODY"||$(t));){if(qe(t))return t;t=t.parentNode}return null}function Ge(e){return je(e)||Ot(e)||Ee(e)||ge(e)||qe(e)}function Vt(e){if(Ee(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return Mt[t]}function ve(e,t){const n=N(e);let r=e,o=!0,s=!1,l=!1,i=!1,u=!1;for(;r;){const a=r===document.body,m=r.tagName==="BODY",f=window.getComputedStyle(r);let p=null;if(o){if(f.visibility&&f.visibility!=="visible")return c("not visible because visibility is",f.visibility,e,{cur:r}),!1;o=!1}if(f.display==="none")return c("not visible because display is",f.display,e,{cur:r}),!1;if(f.opacity!=null&&parseFloat(f.opacity)<.01)return c("not visible because opacity is",f.opacity,e,{cur:r}),!1;if(f.position==="absolute"?i=!0:(f.position==="relative"||f.position==="fixed"||f.position==="sticky")&&(i=!1),t.minorVersion>=4&&!s&&!m&&!(u&&f.position==="static")&&(_(f.overflowX)||_(f.overflowY))&&(p=p||N(r),p.width===0||p.height===0))return c("not visible because width/height (v1.4 check) is",p.width,p.height,e,{cur:r}),!1;if(!l&&Ye(f.display)&&(t.minorVersion<1||m||f.position!=="static")){const d=m||_(f.overflow),h=d||_(f.overflowX),E=d||_(f.overflowY),{scrollLeft:T,scrollTop:g}=m?r.ownerDocument.documentElement:r,S=!m&&!i;if(h){if(p=p||N(r),S&&p.width===0)return c("not visible because width is",p.width,e,{cur:r}),!1;const b=t.minorVersion>=5?n.width/2:0,v=Math.round(n.left+b),y=Math.round(p.left-T);if(v<y)return c("not visible because it's clipped left",e,{elX:v,curLeft:y,cur:r}),!1}if(E){if(p=p||N(r),S&&p.height===0)return c("not visible because height is",p.height,e,{cur:r}),!1;const b=t.minorVersion>=5?n.height/2:0,v=Math.round(n.top+b),y=Math.round(p.top-g);if(v<y)return c("not visible because it's clipped top",e,{elY:v,curTop:y,cur:r}),!1}(h||E)&&(l=!0)}if(f.position==="fixed"&&(s=!0,l=!0),t.minorVersion>=3&&(r.scrollTop>0||r.scrollLeft>0)&&(l=!0),a)break;m?(r=K(r),o=!0):r=r.parentElement,u=i}return!0}function _(e){return e==="hidden"||e==="clip"||e==="scroll"||e==="auto"}function Ye(e){return!e||!e.includes("inline")&&e!=="contents"}function sn(e){let t=e.parentNode,n=!1;for(;t&&t.tagName!=="BODY";){$(t)&&(t=t.host);const r=window.getComputedStyle(t);if(r.position==="absolute"?n=!0:(r.position==="relative"||r.position==="fixed"||r.position==="sticky")&&(n=!1),!n&&Ye(r.display)&&(_(r.overflow)||_(r.overflowY)))return t;if(r.position==="fixed")return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function N(e){if(e.tagName==="HTML"){const r=K(e);if(r)return N(r)}let t=e.getBoundingClientRect(),n=e;for(;n&&(n=K(n),!!n);){const r=n.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+r.left,right:t.right+r.left,top:t.top+r.top,bottom:t.bottom+r.top}}return t}const Ie=new WeakSet;function K(e){const t=e.ownerDocument?.defaultView;if(!t||Ie.has(t))return null;{const n=t.frameElement;return n||Ie.add(t),n}}function $(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function P(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function He(e){return P(e)&&e.tagName==="IFRAME"}Y.__findElement=Ve;Y.__findAllElements=B;Y.__elementMatchesSelector=Be;Y.__getElementText=G;Y.__getInputValue=ue;const I=new Set,fe=new Map,ee=new Set;function Ce(){return Xe(),I}function ze(e,t){Xe();for(const r of I)e(r);const n={setup:e,teardown:t};return ee.add(n),()=>{ee.delete(n);for(const r of I)t(r)}}let De=!1,R=null;function Xe(){if(_e(),!De){c("roots started"),De=!0,R=document.body,H(R);for(const e of tt)document.addEventListener(e,Bt);window.setInterval(_e,10*1e3)}}function Bt(){R&&!document.contains(R)&&(c("roots detected new Turbo body"),ye(R),R=document.body,H(R))}function _e(){for(const e of I)$(e)&&(Pt(e)||(c("roots clean before removeRoot",e),ye(e)));c("roots clean finished, remaining=",I.size)}function Pt(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if($(t)&&(t=t.host),P(t)&&t.tagName==="BODY")return!0;t=t.parentNode}return!1}function H(e){if(!I.has(e)){c("roots addRoot",e),I.add(e),$t(e),Ze(e),qt(e),Gt(e);for(const{setup:t}of ee)t(e)}}function ye(e){if(I.has(e)){c("roots removeRoot",e),fe.get(e)?.disconnect(),fe.delete(e),I.delete(e);for(const{teardown:t}of ee)t(e)}}function $t(e){let t;const n=()=>{Ze(e)},r=new he(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});r.observe(e,{childList:!0,subtree:!0}),fe.set(e,r)}function Ze(e){const t=P(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const n of t)Qe(n)}const Re=new WeakSet;function Qe(e){if(Re.has(e)||e.closest("#userflow-ui"))return;e.addEventListener("load",Wt);const t=e.contentWindow,n=e.contentDocument;if(!t||!n){Re.add(e);return}const r=n.body;r&&(t.addEventListener("pagehide",jt),c("roots setupFrame before addRoot",e,n,r),H(r))}function Wt(e){const t=e.target;t&&He(t)&&Qe(t)}function jt(e){const t=e.currentTarget.document.body;c("roots onFrameUnload before removeRoot",t),ye(t)}function qt(e){const t=e.ownerDocument.defaultView;if(t.__userflowAttachShadowInstalled)return;t.__userflowAttachShadowInstalled=!0;const n=t.Element.prototype.attachShadow;n!=null&&(t.Element.prototype.attachShadow=function(r){const o=n.call(this,r);return this.shadowRoot&&(c("roots monitorShadowDom before addRoot",this,this.shadowRoot),H(this.shadowRoot)),o})}function Gt(e){const t=n=>{n.childNodes.forEach(r=>{P(r)&&r.shadowRoot&&(c("roots queryShadowDom before addRoot",r,r.shadowRoot),H(r.shadowRoot)),t(r)})};t(e)}const Yt=50,Ht=1e3;function de(e,t={}){let n,r;const o=()=>{r=void 0,e()},s=()=>{if(window.clearTimeout(n),r==null)r=Date.now();else if(Date.now()-r>Ht){o();return}n=window.setTimeout(o,Yt)},l=a=>{const m=a.target;if(!m||!Je(m))return;const f=document.getElementById("userflow-ui");f&&f.contains(m)||s()},i=new he(a=>{zt(a)||s()}),u=ze(a=>{i.observe(a,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),a.addEventListener("animationend",l),a.addEventListener("transitionend",l),t.observeInput&&(a.addEventListener("input",s),a.addEventListener("keypress",s),a.addEventListener("change",s))},a=>{a.removeEventListener("animationend",l),a.removeEventListener("transitionend",l),t.observeInput&&(a.removeEventListener("input",s),a.removeEventListener("keypress",s),a.removeEventListener("change",s))});return{disconnect:()=>{window.clearTimeout(n),i.disconnect(),u()}}}function zt(e){const t=document.getElementById("userflow-ui");for(const n of e){const{target:r}=n;if(Je(r)&&t&&t.contains(r))return!0}return!1}function Je(e){return e.nodeType===Node.ELEMENT_NODE}const me={[x.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[x.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:n})=>{const r=()=>{let s=!1;if(e&&t.operator){const l=e.value.find(a=>a.name===t.attributeName),i=l?l.value:null;s=oe[t.operator].compare({sessionData:e.value,condition:t,value:i})}n(s)};r();const o=e.observe(r);return()=>{o()}}},[x.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const n=me[t.type];if(n.isExpensive&&n.isExpensive(t))return!0}return!1},track:({sessionData:e,condition:t,flipBackEvents:n,callback:r,description:o})=>{let s,l,i=null;const u=t.conditions.map(p=>{const d=me[p.type];return{condition:p,typeDef:d,expensive:!!d.isExpensive&&d.isExpensive(p),active:!1,isTrue:null}}),a=p=>{for(const d of u){const h=!n||!d.expensive||p;h&&!d.active?(d.active=!0,d.isTrue=!1,d.untrack=d.typeDef.track({sessionData:e,condition:d.condition,flipBackEvents:n,callback:(E,T={})=>{d.isTrue=E,window.clearTimeout(s),T.immediate?m({immediate:!0}):s=window.setTimeout(m,0)},description:o})):!h&&d.active&&(d.untrack&&d.untrack(),d.active=!1,d.isTrue=null,d.untrack=void 0)}},m=(p={})=>{if(u.length===0){f(!1,p);return}let d,h;if(t.operator===w.AND){d=!0,h=!0;for(const E of u)E.isTrue===!1?(d=!1,E.expensive||(h=!1)):d!==!1&&E.isTrue===null&&(d=null)}else{d=!1,h=!0;for(const E of u)E.isTrue===!0?(d=!0,E.expensive||(h=!1)):d!==!0&&E.isTrue===null&&(d=null)}d!==null&&d!==i&&(i=d,f(d,p)),a(h)},f=(p,d)=>{if(!p||t.waitTime==null||t.waitTime=="0")window.clearTimeout(l),l=void 0,r(p,d);else if(!l){const h=parseFloat(t.waitTime)*1e3;l=window.setTimeout(()=>{r(!0,{})},h)}};return a(!1),m(),()=>{window.clearTimeout(s),window.clearTimeout(l);for(const p of u)p.untrack&&p.untrack()}}},[x.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const n=Xt(t);switch(n.kind){case"observer":return Zt(e,n.checkElement);case"event":return Qt(e,n.eventName,n.valueWhenOccurred)}}},[x.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{let r=null,o;const s=()=>{if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}const u=B(ie(t.selector,e.value));let a=null;for(const m of u){const f=ue(m);if(f){a=f;break}}a?a!=r&&(window.clearTimeout(o),o=window.setTimeout(()=>{n(!0)},1e3)):(n(!1),window.clearTimeout(o)),r=a};s();const l=e.observe(s),{disconnect:i}=de(s,{observeInput:!0});return()=>{l(),i(),window.clearTimeout(o)}}},[x.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[x.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{const r=()=>{if(!t.operator){console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);return}if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}let l=!1;const i=oe[t.operator],u=B(ie(t.selector,e.value));if(u.length>0)for(const a of u){const m=ue(a);if(i.compare({sessionData:e.value,condition:t,value:m})){l=!0;break}}else i.compare({sessionData:e.value,condition:t,value:""})&&(l=!0);n(l)};r();const o=e.observe(r),{disconnect:s}=de(r,{observeInput:!0});return()=>{o(),s()}}},[x.PAGE]:{track:({sessionData:e,condition:t,callback:n})=>{const r=()=>{let i=!1;if(t.operator){const u=ne();i=oe[t.operator].compare({sessionData:e.value,condition:t,value:u})}n(i)};let o=ne();const s=()=>{const i=ne();i!==o&&(o=i,r())};nt(s),r();const l=e.observe(r);return()=>{l(),rt(s)}}},[x.SEGMENT]:{track:({description:e,callback:t})=>(console.error("Userflow.js: Segment conditions are not supported in "+(e||"unknown content item")+"."),t(!1),()=>{})},[x.TIME]:{track:({condition:e,callback:t})=>{let n=null;const r=e.value?new Date(e.value):null,o=e.value2?new Date(e.value2):null,s=()=>{let i=!0;(r&&!isNaN(r.valueOf())&&Date.now()<r.valueOf()||o&&!isNaN(o.valueOf())&&Date.now()>=o.valueOf())&&(i=!1),i!==n&&(n=i,t(i))};s();const l=window.setInterval(s,10*1e3);return()=>{window.clearInterval(l)}}}};function Xt(e){switch(e){case C.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case C.DISABLED:return{kind:"observer",checkElement:t=>!!t&&t.disabled};case C.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case C.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case C.NOT_DISABLED:return{kind:"observer",checkElement:t=>!!t&&!t.disabled};case C.NOT_PRESENT:return{kind:"observer",checkElement:t=>!t};case C.PRESENT:return{kind:"observer",checkElement:t=>!!t}}}function Zt({sessionData:e,condition:t,callback:n},r){const o=()=>{if(!t.elementState){console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);return}if(!t.selector){console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);return}let i=!1;const u=B(ie(t.selector,e.value));if(u.length>0){for(const a of u)if(r(a)){i=!0;break}}else r(null)&&(i=!0);n(i)};o();const s=e.observe(o),{disconnect:l}=de(o);return()=>{s(),l()}}function Qt({condition:e,flipBackEvents:t,callback:n},r,o){const{selector:s}=e;if(!s)return()=>{};n(!o);let l;const i=m=>{const f=m.target;f&&Be(f,s)&&(t?(n(o,{immediate:!0}),n(!o,{immediate:!0})):n(o))},u={capture:!0},a=ze(m=>m.addEventListener(r,i,u),m=>m.removeEventListener(r,i,u));return()=>{a(),window.clearTimeout(l)}}const ln=Object.freeze(Object.defineProperty({__proto__:null,conditionTypes:me},Symbol.toStringTag,{value:"Module"}));export{he as M,it as U,wt as a,ct as b,pt as c,P as d,K as e,on as f,nn as g,ht as h,$ as i,yt as j,rn as k,ie as l,He as m,sn as n,ze as o,de as p,Ve as q,N as r,me as s,D as t,at as u,ln as v,tn as z};
1
+ import{N as w,I as c,c as O,O as ye,j as Me,m as pe,P as tt,Q as x,W as ne,X as nt,Y as rt,Z as C}from"./userflow.js";import"./vendor.html-parse-stringify2.js";import{i as j,a as re,b as ot,p as ke,c as Ue,s as st}from"./vendor.date-fns.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]="e2ef0441-ea29-46a7-bb47-e9b06b29048b",e._sentryDebugIdIdentifier="sentry-dbid-e2ef0441-ea29-46a7-bb47-e9b06b29048b")}catch{}})();class it extends Error{constructor(t,n){const r=`Unreachable case: ${t}`;n?n=`${n} (${r})`:n=r,super(n)}}const lt=/(\\*)\{\{([a-zA-Z0-9_.\\/]+)\}\}/g;function at(e,t){return(e||"").replace(lt,(n,r,o)=>{const s=r.length;return s%2===0?"\\".repeat(s/2)+(t(o)||""):"\\".repeat((s-1)/2)+"{{"+o+"}}"})}function ct(e){let t=null;return n=>(t||(t=new Map,e.forEach(({name:r,value:o})=>t.set(r,Array.isArray(o)?o[0]:o))),t.get(n)||null)}function D(e,t){const n=ct(t);return at(e,r=>n(r))}function ie(e,t){const n=Se(e,t),r=e.nearSelector&&Se(e.nearSelector,t);return e===n&&e.nearSelector===r?e:e.nearSelector===r?n:{...n,nearSelector:r}}function Se(e,t){if(!e.text)return e;const n=D(e.text,t);return n===e.text?e:{...e,text:n}}function ut(e,t){return e.includes.length===0&&e.excludes.length===0?!1:(e.includes.length===0||e.includes.some(n=>{const r=Ae(n);return r&&t.match(r)}))&&!e.excludes.some(n=>{const r=Ae(n);return r&&t.match(r)})}function ft(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,n,r,o,,s,l]=t;return{scheme:n||"",domain:r||"",path:o||"",query:s||"",fragment:l||""}}function Ae(e){const t=ft(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:n,domain:r,path:o,query:s,fragment:l}=t;let i;n?i=le(n):i="[a-z\\d]+";let u;r?u=z(r,"[^/]","."):u="[^/]*";const a="(:\\d+)?";let m;o?m=z(o,"[^?#]","/"):m="/[^?#]*";let f;s?(f="",new URLSearchParams(s).forEach((h,E)=>{let T;h===""?T="=?":h==="*"?T="(=[^&#]*)?":(h=h.split(/\*/g).map(g=>encodeURI(g)).join("*"),T="="+z(h,"[^#]")),f+="(?=.*[?&]"+le(E)+T+"([&#]|$))"}),f+="\\?[^#]*"):f="(\\?[^#]*)?";let p;return l?p=z(l,".","/"):p="(#.*)?",new RegExp("^"+i+"://"+u+a+m+f+p+"$")}function z(e,t,n){return e=le(e),e=e.replace(/\\\*/g,t+"*"),n&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+n+"]+")),e}function le(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const oe={[w.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const n=k(t),r=X(e.value,"00:00:00.000"),o=X(e.value,"23:59:59.999");return n!=null&&r!=null&&o!=null&&!j(n,r)&&!re(n,o)}},[w.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const n=k(t),r=X(e.value,"23:59:59.999");return n!=null&&r!=null&&re(n,r)}},[w.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const n=k(t),r=X(e.value,"00:00:00.000");return n!=null&&r!=null&&j(n,r)}},[w.AND]:{compare:()=>Le("AND.compare")},[w.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(A(t))>=parseFloat(e.value)&&parseFloat(A(t))<=parseFloat(e.value2)},[w.CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&A(n).toLowerCase().includes(D(t.value||"",e).toLowerCase())},[w.EMPTY]:{compare:({value:e})=>e==null||e===""||Array.isArray(e)&&e.length===0},[w.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&A(n).toLowerCase().endsWith(D(t.value||"",e).toLowerCase())},[w.EQ]:{compare:({sessionData:e,condition:t,value:n})=>D(t.value||"",e)===A(n)},[w.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return!(e.values||[]).some(r=>n.has(r))}},[w.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return!(e.values||[]).every(r=>n.has(r))}},[w.FALSE]:{compare:({value:e})=>A(e).toLowerCase()==="false"},[w.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))>parseFloat(e.value)},[w.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))>=parseFloat(e.value)},[w.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return(e.values||[]).every(r=>n.has(r))}},[w.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(Z(t));return(e.values||[]).some(r=>n.has(r))}},[w.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))<parseFloat(e.value)},[w.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(A(t))<=parseFloat(e.value)},[w.NE]:{compare:({sessionData:e,condition:t,value:n})=>D(t.value||"",e)!==A(n)},[w.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!n||!A(n).toLowerCase().includes(D(t.value||"",e).toLowerCase())},[w.NOT_EMPTY]:{compare:({value:e})=>e!=null&&e!==""&&(!Array.isArray(e)||e.length>0)},[w.NOT_REGEX]:{compare:({condition:e,value:t})=>!xe(e,t)},[w.OR]:{compare:()=>Le("OR.compare")},[w.REGEX]:{compare:({condition:e,value:t})=>xe(e,t)},[w.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const n=k(t),r=se(e.value);return n==null||r==null?!1:!j(n,r)&&j(n,ot(r,1))}},[w.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const n=k(t),r=se(e.value);return n==null||r==null?!1:re(n,r)}},[w.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const n=k(t),r=se(e.value);return n==null||r==null?!1:j(n,r)}},[w.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&A(n).toLowerCase().startsWith(D(t.value||"",e).toLowerCase())},[w.TRUE]:{compare:({value:e})=>A(e).toLowerCase()==="true"},[w.URL]:{compare:({condition:e,value:t})=>e.urlPattern&&t!=null?ut(e.urlPattern,A(t)):!1}};function Le(e){throw new Error(`conditionOperators.${e} is not supported`)}function k(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=ke(e);return Ue(t)?t:null}function X(e,t){if(!e)return null;e+="T"+t+"Z";const n=ke(e);return Ue(n)?n:null}function se(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:st(Date.now(),t)}function xe(e,t){return e.value?new RegExp(e.value).test(A(t)):!1}function A(e){return Array.isArray(e)?e[0]:e??""}function Z(e){return Array.isArray(e)?e:e===""||e==null?[]:[e]}let he=window.MutationObserver;const U=window;if(U.Zone&&typeof U.Zone.__symbol__=="function"){const e=U.Zone.__symbol__("MutationObserver");e&&typeof e=="string"&&U.hasOwnProperty(e)&&typeof U[e]=="function"&&(he=U[e])}function Oe(e,t){const n=e.left,r=e.top,o=n+e.width,s=r+e.height,l=t.left,i=t.top,u=l+t.width,a=i+t.height;return dt(n,r,o,s,l,i,u,a)}function dt(e,t,n,r,o,s,l,i){const u=l<e,a=n<o,m=i<t,f=r<s;return f&&u?Q(e,r,l,s):u&&m?Q(e,t,l,i):m&&a?Q(n,t,o,i):a&&f?Q(n,r,o,s):u?e-l:a?o-n:m?t-i:f?s-r:0}function Q(e,t,n,r){return Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2))}function V(e){window.performance.mark&&window.performance.mark(e)}function we(e,t,n){window.performance.measure&&window.performance.measure(e,t,n)}function mt(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&e.zoom!=="1"){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}function tn(e){return ht(),pt(e)}let q;function pt(e){return q==null&&(q=mt()),q==1?e:e/q}function ht(){q=null}function nn(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientWidth||window.innerWidth}function wt(){return(document.compatMode=="BackCompat"?document.body:document.documentElement).clientHeight||window.innerHeight}function rn(e){return e?parseFloat(e.replace(/px$/,"")):0}function on(e){return e==null?void 0:e+"px"}const Et=50,gt=100,Ne=25,Tt=new Set(["left","start","justify","justify-all"]);class vt{constructor(t){this.ctx=t,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(t,n){const r=this.getRect(t),o=this.getRect(n),s=this.distBetween(t,n),l=Te(n)?gt:Et;if(s>l)return 0;const i=this.isLabelLike(t),u=this.isCloserToOtherInput(t,n),a=window.getComputedStyle(t).textAlign||"",m=r.top+r.height<=o.top,f=Math.abs(r.left-o.left)<Ne&&(!a||Tt.has(a)),p=r.left+r.width<=o.left,d=Math.abs(r.top-o.top)<Ne,h=m&&f||p&&d,E=r.height>=wt()/2,T=Ge(n);if(T&&r.top>=o.top+o.height)return 0;let g=1;const S=t.htmlFor;return S&&S===n.id&&(g+=Math.pow(1e3,4)),T&&!E&&!u&&(i&&h?g+=Math.pow(1e3,3):n===t&&this.hasPlaceholder(n)?g+=Math.pow(1e3,2):!i&&h&&(g+=Math.pow(1e3,1))),g+=l-s,g}getRect(t){let n=this.rectCache.get(t);return n||(n=N(t),this.rectCache.set(t,n)),n}isLabelLike(t){let n=this.isLabelLikeCache.get(t);if(n===void 0){const r="a, button, h1, h2, h3, h4, h5, h6, input";n=!t.closest(r)&&!t.querySelector(r),this.isLabelLikeCache.set(t,n)}return n}hasPlaceholder(t){let n=this.hasPlaceholderCache.get(t);return n===void 0&&(n=!!G(t),this.hasPlaceholderCache.set(t,n)),n}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(We())).filter(t=>ve(t,this.ctx))),this.allInputs}distBetween(t,n){return Math.round(Oe(this.getRect(t),this.getRect(n)))}isCloserToOtherInput(t,n){let r=this.distBetween(t,n);for(let o of this.getAllInputs()){if(o===n)continue;if(this.distBetween(t,o)<r)return!0}return!1}}function bt(e,t={}){const n=performance.now();V("userflow:inferSelector:start"),c.groupCollapsed("inferSelector for",e,t);let r;try{r=St(e,t)}catch(o){console.error("Userflow findElement error:",o),r=null}return c("time",performance.now()-n),c.groupEnd(),V("userflow:inferSelector:end"),we("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),r}function Fe(e){const t=[],n=e.tagName.toLowerCase();return O.inferenceAttributeNames.forEach(r=>{const o=e.getAttribute(r);if(!o)return;const s=O.inferenceAttributeFilters[r];if(!(s&&!ye(s,o)))if(r==="id")t.push(`#${o}`);else{const l=r==="name"||r==="placeholder"?n:"";t.push(`${l}[${r}="${o}"]`)}}),e.classList.forEach(r=>{ye(O.inferenceClassNameFilters,r)&&(r=r.replace(/:/g,"\\:").trim(),t.push(`.${r}`))}),t}const yt=window.userflow||{};yt.__inferSelector=bt;function St(e,{elementType:t}={}){const n={minorVersion:Nt};let r=Ge(e);const o=Ft(e);if(t===Me.INPUT&&!r)if(o)e=o,r=!0,c("use custom input parent",o);else return c("not an input"),null;else o&&(e=o,r=!0);const s=At(e);let l=null;r||(l=$e(e),l&&l.length>250&&(l=null)),c("text is:"+l);let i=new Map,u=new Map;const a=new Map,m=new ae(s,null,n),f=new ae(s,l,n),p=(E,T,g,S,y)=>{if(S<0)return;let v=E.get(T);v||(v=[],E.set(T,v)),v.push({css:g,offset:S,complexity:y}),c(`use css=${g}, cardinality=${T}, offset=${S}`)},d=Lt(e),h=[e.tagName.toLowerCase(),...Fe(e)];c("shadowRootSelectors:",s),c("ancestorCssSelectors:",d),c("ownCssSelectors:",h);for(const E of h)for(const T of d){const g=T?`${T} ${E}`:E,S=T?2:1,y=m.query(g),v=Array.from(y),b=v.length;if(b>100){c(`cardinality too high css=${g}, cardinality=${b}`);continue}a.set(g,b);const L=v.indexOf(e);if(p(i,b,g,L,S),l){const W=f.query(g),M=Array.from(W),Ke=M.indexOf(e),et=M.length;p(u,et,g,Ke,S)}}if(i.size>0||u.size>0){const E=S=>Array.from(S.entries()).map(([y,v])=>({cardinality:y,cssSelectors:v.sort((b,L)=>{const W=a.get(b.css),M=a.get(L.css);return W!==M?W?M?W-M:-1:1:b.complexity!==L.complexity?L.complexity-b.complexity:b.css.localeCompare(L.css)}).map(({css:b,offset:L})=>({css:b,offset:L}))})).sort((y,v)=>y.cardinality-v.cardinality),T={version:"v1",minorVersion:n.minorVersion,shadowRootSelectors:s,notextGroups:E(i),textGroups:E(u)},g={el:e,selector:{type:pe.AUTO,autoData:JSON.stringify(T),text:l,elementType:t}};return c("inference result",g),g}return c("no selector inferred "),null}function At(e){let t=[],n=e;for(;n;){let r=n.getRootNode();if($(r)){const{host:s}=r;t.unshift(s.tagName.toLowerCase()),n=s;continue}const o=K(n);if(o){let s=o.tagName.toLowerCase();const l=o.getAttribute("name");l?s+=`[name="${l}"]`:o.id&&!o.id.match(/\d$/)&&(s+="#"+o.id),t.unshift(s),n=o;continue}break}if(t.length!==0)return t}function Lt(e){const t=new Map;t.set(null,0);let n=e.parentNode;for(;n&&!(n.tagName==="BODY"||$(n));){for(const o of Fe(n)){if(t.has(o))continue;const s=J(document.body,o);if(s){const l=s.length;t.set(o,l)}}n=n.parentNode}return Array.from(t.entries()).sort(([,o],[,s])=>o-s).slice(0,20).map(([o])=>o)}function xt(e,t){const{text:n,excludeText:r,precision:o}=e,s={minorVersion:t.minorVersion||0},l=n!=null&&!r,i=l?t.textGroups:t.notextGroups,u=Math.max(1,Math.min(i.length,Math.ceil((1-parseFloat(o||"1"))*i.length))),a=new ae(t.shadowRootSelectors,l&&n||null,s);c("findElementAutoV1",{text:n,excludeText:r,precision:o,groups:i,groupCount:u});for(let m=0;m<u;m++){const f=i[m];let p=new Map,d=0,h=null;c.group(`group cardinality=${f.cardinality}`,f);try{for(let E=0;E<f.cssSelectors.length;E++){const{css:T,offset:g}=f.cssSelectors[E];c(`css=${T}, offset=${g}`);let S=a.query(T),y=null;for(let b=0;b<=g;b++){const L=S.next();if(L.done)break;y=L.value}if(!y)continue;const v=(p.get(y)||0)+1;if(p.set(y,v),c(`el with frequency=${v}`+(v>d&&y!==h?" NEW BEST":""),y),v>d&&(d=v,h=y,v>=Math.ceil(f.cssSelectors.length/2)))return c("early winner",h),h}}finally{c.groupEnd()}if(h)return c("winner",h),h}return c("element not found"),null}class ae{constructor(t,n,r){this.shadowRootSelectors=t,this.text=n,this.ctx=r,this.isVisibleCache=new Map,this.textCache=new Map}*query(t){const n=J(document.body,t,this.shadowRootSelectors);if(c("found",n),!n)return;const{text:r}=this;for(let o=0;o<n.length;o++){const s=n[o];if(r){let i=this.textCache.get(s);if(i==null&&(i=te(s,r),this.textCache.set(s,i)),!i){c("skip, text mismatch",s);continue}}let l=this.isVisibleCache.get(s);if(l==null&&(l=ve(s,this.ctx),this.isVisibleCache.set(s,l)),!l){c("skip, not visible",s);continue}c("yield",s),yield s}}}const Nt=5,Y=window.userflow||{};function B(e){const t=performance.now();V("userflow:findAllElements:start"),c.groupCollapsed("findAllElements",e);let n;try{if(e.type===pe.MANUAL)n=It(e);else if(e.autoData){const r=JSON.parse(e.autoData);let o;if(r.version==="v1")o=xt(e,r);else throw new it(r.version,"Unknown autoData version: "+r.version);n=o?[o]:[]}else n=[]}catch(r){console.error("Userflow findElement error:",r),n=[]}return c("time",performance.now()-t),c.groupEnd(),V("userflow:findAllElements:end"),we("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),n}function It(e){const t={minorVersion:e.minorVersion==null?1:e.minorVersion};let{css:n,text:r,elementType:o,offset:s}=e;r=r&&F(r);const l="nearSelector"in e?e.nearSelector:null;c("findAllElementsManual",e),s!=null&&l!=null&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let i;if(r&&!n){if(i=[],t.minorVersion>=2)for(const u of Ce())ce(u,r,i);else ce(document.body,r,i);c("els after traverseElementForText",i)}else if(n){if(t.minorVersion>=2){i=[];for(const u of Ce()){const a=J(u,n);a&&a.length>0&&i.push(...a)}}else i=Array.from(J(document.body,n)||[]);c("els after safeQueryAll",i),r&&(i=Dt(i,r),c("els after filterElementsByText",i))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),i=[];if(i.length>0&&(i=i.filter(u=>ve(u,t)),c("els after isVisible",i)),i.length>0&&o===Me.INPUT&&(i=Ut(i,t),c("els after mapElementsToInputs",i)),i.length>0&&(i.sort((u,a)=>{const m=N(u),f=N(a);return m.top<f.top?-1:m.top>f.top?1:m.left-f.left}),c("els after sort",i)),i.length>0){if(s!=null)i=i[s]?[i[s]]:[],c("els after offset",i);else if(l!=null){const u=B(l);let a=null,m=0;for(const f of i)for(const p of u){const d=Oe(N(f),N(p));(!a||d<m)&&(a=f,m=d)}i=a?[a]:[],c("els after nearSelector",i)}}return i}function Ve(e){return B(e)[0]||null}function Be(e,t){const n=performance.now();V("userflow:elementMatchesSelector:start"),c.groupCollapsed("elementMatchesSelector",e,t);let r;try{if(t.type===pe.MANUAL)r=Ct(e,t);else{const o=Ve(t);r=o!=null&&o.contains(e)}}catch(o){console.error("Userflow findElement error:",o),r=!1}return c(r?"match":"not match"),c("time",performance.now()-n),c.groupEnd(),V("userflow:elementMatchesSelector:end"),we("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),r}function Ct(e,t){t.offset!=null&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet"),"nearSelector"in t&&t.nearSelector!=null&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:n,text:r}=t;r=r&&F(r);let o=!1,s=e;for(;s&&s.tagName!=="BODY";){if((!n||s.matches(n))&&(!r||te(s,r))){o=!0;break}s=s.parentElement}return o}function ce(e,t,n){if(P(e)){const{tagName:o}=e;if(o==="SCRIPT"||o==="STYLE")return!1}let r=!1;for(let o=0;o<e.children.length;o++)ce(e.children[o],t,n)&&(r=!0);return!r&&P(e)&&te(e,t)&&(n.push(e),r=!0),r}function J(e,t,n){try{return n==null?e.querySelectorAll(t):Pe(t,n,0,e)}catch{return console.info("Userflow.js: Invalid CSS selector: ",t),null}}function Pe(e,t,n,r){if(n>=t.length)return Array.from(r.querySelectorAll(e));const o=t[n],s=r.querySelectorAll(o),l=[];return s.forEach(i=>{let u;if(i.shadowRoot)u=i.shadowRoot;else{if(!He(i))return;let a=null;try{a=i.contentDocument}catch{}if(!a)return;u=a.body}l.push(...Pe(e,t,n+1,u))}),l}function Dt(e,t){const n=[];for(let r=e.length-1;r>=0;r--){const o=e[r];n.some(s=>s.contains(o))||te(o,t)&&n.push(o)}return n.reverse()}const _t={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},Rt={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},Mt={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function $e(e){let t=e.innerText;return t===void 0&&e.tagName!=="SELECT"&&(t=e.textContent),t=F(t),t||null}function G(e){if(je(e)||Ee(e)){const t=F(e.getAttribute("placeholder")),n=e.value||"";if(t&&!n)return t;const r=F(n);if(r&&Vt(e))return r}if(ge(e)&&e.selectedIndex>=0){const t=F(e.options[e.selectedIndex].text);if(t)return t}return $e(e)}function te(e,t){const n=G(e);return n?kt(t,n):!1}function kt(e,t){const n=e.toLowerCase();return t.toLowerCase()===n}function F(e){return!e||e.length>250?null:e.replace(/^[\s\uFEFF\xA0\u200B*]+|[\s\uFEFF\xA0\u200B*]+$/g,"").replace(/\s+/g," ")}function ue(e){for(const{cssSelector:t,getValue:n}of O.customInputs)if(e.matches(t))if(n)try{return(n(e)||"").trim()}catch(r){return console.error(`Userflow.js: getValue function for custom input '${t}' failed:`,r),""}else return G(e)||"";return ge(e)?e.selectedIndex==-1?"":e.options[e.selectedIndex].text:Te(e)?G(e)||"":e.value}function We(){return"input, select, textarea, [contenteditable]"+O.customInputs.map(({cssSelector:e})=>`, ${e}`).join("")}function Ut(e,t){const n=new Set,r=new vt(t),o=We();for(const s of e){if(s.matches(o)){n.add(s);continue}let l=null,i=null;r.getAllInputs().forEach(u=>{const a=r.calcScore(s,u);c("input",a,u),a!==0&&(l&&i&&a<=i||(c("input is best so far"),l=u,i=a))}),l&&(c("best input was",l),n.add(l))}return Array.from(n)}function je(e){if(e.tagName!=="INPUT")return!1;const t=e.getAttribute("type");return t==null?!0:_t[(t||"").toLowerCase()]===!0}function Ee(e){return e.tagName==="TEXTAREA"}function Ot(e){if(e.tagName!=="INPUT")return!1;const t=(e.getAttribute("type")||"").toLowerCase();return Rt[t]===!0}function ge(e){return e.tagName==="SELECT"}function Te(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function qe(e){return!!(Te(e)||O.customInputs.some(({cssSelector:t})=>e.matches(t)))}function Ft(e){let t=e.parentNode;for(;t&&!(t.tagName==="BODY"||$(t));){if(qe(t))return t;t=t.parentNode}return null}function Ge(e){return je(e)||Ot(e)||Ee(e)||ge(e)||qe(e)}function Vt(e){if(Ee(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return Mt[t]}function ve(e,t){const n=N(e);let r=e,o=!0,s=!1,l=!1,i=!1,u=!1;for(;r;){const a=r===document.body,m=r.tagName==="BODY",f=window.getComputedStyle(r);let p=null;if(o){if(f.visibility&&f.visibility!=="visible")return c("not visible because visibility is",f.visibility,e,{cur:r}),!1;o=!1}if(f.display==="none")return c("not visible because display is",f.display,e,{cur:r}),!1;if(f.opacity!=null&&parseFloat(f.opacity)<.01)return c("not visible because opacity is",f.opacity,e,{cur:r}),!1;if(f.position==="absolute"?i=!0:(f.position==="relative"||f.position==="fixed"||f.position==="sticky")&&(i=!1),t.minorVersion>=4&&!s&&!m&&!(u&&f.position==="static")&&(_(f.overflowX)||_(f.overflowY))&&(p=p||N(r),p.width===0||p.height===0))return c("not visible because width/height (v1.4 check) is",p.width,p.height,e,{cur:r}),!1;if(!l&&Ye(f.display)&&(t.minorVersion<1||m||f.position!=="static")){const d=m||_(f.overflow),h=d||_(f.overflowX),E=d||_(f.overflowY),{scrollLeft:T,scrollTop:g}=m?r.ownerDocument.documentElement:r,S=!m&&!i;if(h){if(p=p||N(r),S&&p.width===0)return c("not visible because width is",p.width,e,{cur:r}),!1;const y=t.minorVersion>=5?n.width/2:0,v=Math.round(n.left+y),b=Math.round(p.left-T);if(v<b)return c("not visible because it's clipped left",e,{elX:v,curLeft:b,cur:r}),!1}if(E){if(p=p||N(r),S&&p.height===0)return c("not visible because height is",p.height,e,{cur:r}),!1;const y=t.minorVersion>=5?n.height/2:0,v=Math.round(n.top+y),b=Math.round(p.top-g);if(v<b)return c("not visible because it's clipped top",e,{elY:v,curTop:b,cur:r}),!1}(h||E)&&(l=!0)}if(f.position==="fixed"&&(s=!0,l=!0),t.minorVersion>=3&&(r.scrollTop>0||r.scrollLeft>0)&&(l=!0),a)break;m?(r=K(r),o=!0):r=r.parentElement,u=i}return!0}function _(e){return e==="hidden"||e==="clip"||e==="scroll"||e==="auto"}function Ye(e){return!e||!e.includes("inline")&&e!=="contents"}function sn(e){let t=e.parentNode,n=!1;for(;t&&t.tagName!=="BODY";){$(t)&&(t=t.host);const r=window.getComputedStyle(t);if(r.position==="absolute"?n=!0:(r.position==="relative"||r.position==="fixed"||r.position==="sticky")&&(n=!1),!n&&Ye(r.display)&&(_(r.overflow)||_(r.overflowY)))return t;if(r.position==="fixed")return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function N(e){if(e.tagName==="HTML"){const r=K(e);if(r)return N(r)}let t=e.getBoundingClientRect(),n=e;for(;n&&(n=K(n),!!n);){const r=n.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+r.left,right:t.right+r.left,top:t.top+r.top,bottom:t.bottom+r.top}}return t}const Ie=new WeakSet;function K(e){const t=e.ownerDocument?.defaultView;if(!t||Ie.has(t))return null;{const n=t.frameElement;return n||Ie.add(t),n}}function $(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function P(e){return typeof e=="object"&&e!=null&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function He(e){return P(e)&&e.tagName==="IFRAME"}Y.__findElement=Ve;Y.__findAllElements=B;Y.__elementMatchesSelector=Be;Y.__getElementText=G;Y.__getInputValue=ue;const I=new Set,fe=new Map,ee=new Set;function Ce(){return Xe(),I}function ze(e,t){Xe();for(const r of I)e(r);const n={setup:e,teardown:t};return ee.add(n),()=>{ee.delete(n);for(const r of I)t(r)}}let De=!1,R=null;function Xe(){if(_e(),!De){c("roots started"),De=!0,R=document.body,H(R);for(const e of tt)document.addEventListener(e,Bt);window.setInterval(_e,10*1e3)}}function Bt(){R&&!document.contains(R)&&(c("roots detected new Turbo body"),be(R),R=document.body,H(R))}function _e(){for(const e of I)$(e)&&(Pt(e)||(c("roots clean before removeRoot",e),be(e)));c("roots clean finished, remaining=",I.size)}function Pt(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if($(t)&&(t=t.host),P(t)&&t.tagName==="BODY")return!0;t=t.parentNode}return!1}function H(e){if(!I.has(e)){c("roots addRoot",e),I.add(e),$t(e),Ze(e),qt(e),Gt(e);for(const{setup:t}of ee)t(e)}}function be(e){if(I.has(e)){c("roots removeRoot",e),fe.get(e)?.disconnect(),fe.delete(e),I.delete(e);for(const{teardown:t}of ee)t(e)}}function $t(e){let t;const n=()=>{Ze(e)},r=new he(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});r.observe(e,{childList:!0,subtree:!0}),fe.set(e,r)}function Ze(e){const t=P(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const n of t)Qe(n)}const Re=new WeakSet;function Qe(e){if(Re.has(e)||e.closest("#userflow-ui"))return;e.addEventListener("load",Wt);const t=e.contentWindow,n=e.contentDocument;if(!t||!n){Re.add(e);return}const r=n.body;r&&(t.addEventListener("pagehide",jt),c("roots setupFrame before addRoot",e,n,r),H(r))}function Wt(e){const t=e.target;t&&He(t)&&Qe(t)}function jt(e){const t=e.currentTarget.document.body;c("roots onFrameUnload before removeRoot",t),be(t)}function qt(e){const t=e.ownerDocument.defaultView;if(t.__userflowAttachShadowInstalled)return;t.__userflowAttachShadowInstalled=!0;const n=t.Element.prototype.attachShadow;n!=null&&(t.Element.prototype.attachShadow=function(r){const o=n.call(this,r);return this.shadowRoot&&(c("roots monitorShadowDom before addRoot",this,this.shadowRoot),H(this.shadowRoot)),o})}function Gt(e){const t=n=>{n.childNodes.forEach(r=>{P(r)&&r.shadowRoot&&(c("roots queryShadowDom before addRoot",r,r.shadowRoot),H(r.shadowRoot)),t(r)})};t(e)}const Yt=50,Ht=1e3;function de(e,t={}){let n,r;const o=()=>{r=void 0,e()},s=()=>{if(window.clearTimeout(n),r==null)r=Date.now();else if(Date.now()-r>Ht){o();return}n=window.setTimeout(o,Yt)},l=a=>{const m=a.target;if(!m||!Je(m))return;const f=document.getElementById("userflow-ui");f&&f.contains(m)||s()},i=new he(a=>{zt(a)||s()}),u=ze(a=>{i.observe(a,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),a.addEventListener("animationend",l),a.addEventListener("transitionend",l),t.observeInput&&(a.addEventListener("input",s),a.addEventListener("keypress",s),a.addEventListener("change",s))},a=>{a.removeEventListener("animationend",l),a.removeEventListener("transitionend",l),t.observeInput&&(a.removeEventListener("input",s),a.removeEventListener("keypress",s),a.removeEventListener("change",s))});return{disconnect:()=>{window.clearTimeout(n),i.disconnect(),u()}}}function zt(e){const t=document.getElementById("userflow-ui");for(const n of e){const{target:r}=n;if(Je(r)&&t&&t.contains(r))return!0}return!1}function Je(e){return e.nodeType===Node.ELEMENT_NODE}const me={[x.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[x.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:n})=>{const r=()=>{let s=!1;if(e&&t.operator){const l=e.value.find(a=>a.name===t.attributeName),i=l?l.value:null;s=oe[t.operator].compare({sessionData:e.value,condition:t,value:i})}n(s)};r();const o=e.observe(r);return()=>{o()}}},[x.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const n=me[t.type];if(n.isExpensive&&n.isExpensive(t))return!0}return!1},track:({sessionData:e,condition:t,flipBackEvents:n,callback:r,description:o})=>{let s,l,i=null;const u=t.conditions.map(p=>{const d=me[p.type];return{condition:p,typeDef:d,expensive:!!d.isExpensive&&d.isExpensive(p),active:!1,isTrue:null}}),a=p=>{for(const d of u){const h=!n||!d.expensive||p;h&&!d.active?(d.active=!0,d.isTrue=!1,d.untrack=d.typeDef.track({sessionData:e,condition:d.condition,flipBackEvents:n,callback:(E,T={})=>{d.isTrue=E,window.clearTimeout(s),T.immediate?m({immediate:!0}):s=window.setTimeout(m,0)},description:o})):!h&&d.active&&(d.untrack&&d.untrack(),d.active=!1,d.isTrue=null,d.untrack=void 0)}},m=(p={})=>{if(u.length===0){f(!1,p);return}let d,h;if(t.operator===w.AND){d=!0,h=!0;for(const E of u)E.isTrue===!1?(d=!1,E.expensive||(h=!1)):d!==!1&&E.isTrue===null&&(d=null)}else{d=!1,h=!0;for(const E of u)E.isTrue===!0?(d=!0,E.expensive||(h=!1)):d!==!0&&E.isTrue===null&&(d=null)}d!==null&&d!==i&&(i=d,f(d,p)),a(h)},f=(p,d)=>{if(!p||t.waitTime==null||t.waitTime=="0")window.clearTimeout(l),l=void 0,r(p,d);else if(!l){const h=parseFloat(t.waitTime)*1e3;l=window.setTimeout(()=>{r(!0,{})},h)}};return a(!1),m(),()=>{window.clearTimeout(s),window.clearTimeout(l);for(const p of u)p.untrack&&p.untrack()}}},[x.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const n=Xt(t);switch(n.kind){case"observer":return Zt(e,n.checkElement);case"event":return Qt(e,n.eventName,n.valueWhenOccurred)}}},[x.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{let r=null,o;const s=()=>{if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}const u=B(ie(t.selector,e.value));let a=null;for(const m of u){const f=ue(m);if(f){a=f;break}}a?a!=r&&(window.clearTimeout(o),o=window.setTimeout(()=>{n(!0)},1e3)):(n(!1),window.clearTimeout(o)),r=a};s();const l=e.observe(s),{disconnect:i}=de(s,{observeInput:!0});return()=>{l(),i(),window.clearTimeout(o)}}},[x.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[x.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{const r=()=>{if(!t.operator){console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);return}if(!t.selector){console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);return}let l=!1;const i=oe[t.operator],u=B(ie(t.selector,e.value));if(u.length>0)for(const a of u){const m=ue(a);if(i.compare({sessionData:e.value,condition:t,value:m})){l=!0;break}}else i.compare({sessionData:e.value,condition:t,value:""})&&(l=!0);n(l)};r();const o=e.observe(r),{disconnect:s}=de(r,{observeInput:!0});return()=>{o(),s()}}},[x.PAGE]:{track:({sessionData:e,condition:t,callback:n})=>{const r=()=>{let i=!1;if(t.operator){const u=ne();i=oe[t.operator].compare({sessionData:e.value,condition:t,value:u})}n(i)};let o=ne();const s=()=>{const i=ne();i!==o&&(o=i,r())};nt(s),r();const l=e.observe(r);return()=>{l(),rt(s)}}},[x.SEGMENT]:{track:({description:e,callback:t})=>(console.error("Userflow.js: Segment conditions are not supported in "+(e||"unknown content item")+"."),t(!1),()=>{})},[x.TIME]:{track:({condition:e,callback:t})=>{let n=null;const r=e.value?new Date(e.value):null,o=e.value2?new Date(e.value2):null,s=()=>{let i=!0;(r&&!isNaN(r.valueOf())&&Date.now()<r.valueOf()||o&&!isNaN(o.valueOf())&&Date.now()>=o.valueOf())&&(i=!1),i!==n&&(n=i,t(i))};s();const l=window.setInterval(s,10*1e3);return()=>{window.clearInterval(l)}}}};function Xt(e){switch(e){case C.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case C.DISABLED:return{kind:"observer",checkElement:t=>!!t&&t.disabled};case C.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case C.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case C.NOT_DISABLED:return{kind:"observer",checkElement:t=>!!t&&!t.disabled};case C.NOT_PRESENT:return{kind:"observer",checkElement:t=>!t};case C.PRESENT:return{kind:"observer",checkElement:t=>!!t}}}function Zt({sessionData:e,condition:t,callback:n},r){const o=()=>{if(!t.elementState){console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);return}if(!t.selector){console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);return}let i=!1;const u=B(ie(t.selector,e.value));if(u.length>0){for(const a of u)if(r(a)){i=!0;break}}else r(null)&&(i=!0);n(i)};o();const s=e.observe(o),{disconnect:l}=de(o);return()=>{s(),l()}}function Qt({condition:e,flipBackEvents:t,callback:n},r,o){const{selector:s}=e;if(!s)return()=>{};n(!o);let l;const i=m=>{const f=m.target;f&&Be(f,s)&&(t?(n(o,{immediate:!0}),n(!o,{immediate:!0})):n(o))},u={capture:!0},a=ze(m=>m.addEventListener(r,i,u),m=>m.removeEventListener(r,i,u));return()=>{a(),window.clearTimeout(l)}}const ln=Object.freeze(Object.defineProperty({__proto__:null,conditionTypes:me},Symbol.toStringTag,{value:"Module"}));export{he as M,it as U,wt as a,ct as b,pt as c,P as d,K as e,on as f,nn as g,ht as h,$ as i,bt as j,rn as k,ie as l,He as m,sn as n,ze as o,de as p,Ve as q,N as r,me as s,D as t,at as u,ln as v,tn as z};
2
2
  //# sourceMappingURL=flow-condition-types.js.map
package/hash.txt CHANGED
@@ -1 +1 @@
1
- db9384a8147e8d958480b6a0b14c84f26750b8ef
1
+ a32c128629d7eda5ffa9979f0ee960b724660026
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1008420",
3
+ "version": "0.1.1008494",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/userflow.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterApp.js","vendor.react.js","vendor.html-parse-stringify2.js","vendor.object-assign.js","client-context.js","vendor.i18next.js","vendor.react-i18next.js","vendor.babel.runtime.js","flow-host.styl.js","bubble-frame.styl.js","flow-condition-types.js","vendor.date-fns.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.obj-str.js","use-window-resize.js","vendor.react-dom.js","vendor.scheduler.js","logomark.js","ChecklistUI.js","BubbleToolbar.js","use-element-rect.js","BannerApp.js","use-selector-element-monitoring.js","vendor.phoenix.js","vendor.uuid.js","ui.js"])))=>i.map(i=>d[i]);
2
- import"./vendor.html-parse-stringify2.js";import{S as K}from"./vendor.phoenix.js";import{v as j}from"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="535ed01f-d848-4ea5-9eab-b49d6f889a49",t._sentryDebugIdIdentifier="sentry-dbid-535ed01f-d848-4ea5-9eab-b49d6f889a49")}catch{}})();const z="modulepreload",Y=function(t){return"https://js.userflow.com/es2020/"+t},v={},w=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(s.map(c=>{if(c=Y(c),c in v)return;v[c]=!0;const h=c.endsWith(".css"),T=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${T}`))return;const E=document.createElement("link");if(E.rel=h?"stylesheet":z,h||(E.as="script"),E.crossOrigin="",E.href=c,u&&E.setAttribute("nonce",u),document.head.appendChild(E),h)return new Promise((F,V)=>{E.addEventListener("load",F),E.addEventListener("error",()=>V(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return n.then(a=>{for(const u of a||[])u.status==="rejected"&&r(u.reason);return e().catch(r)})};class l extends Error{constructor(e,s,i){super(e),Object.setPrototypeOf(this,l.prototype),this.name="UserflowError",this.code=s,this.humanMessage=i}}class B{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,s){e=this.formatKey(e);{if(!this.isSupported())return;window[this.type].setItem(e,s)}}removeItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].removeItem(e):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const g=new B("localStorage"),f=new B("sessionStorage");function je(t){window.location.href=t}function P(){return window.location.href}function U(t){window.postMessage(t,window.origin)}function x(t){const e=i=>{if(i.source!==window||i.origin!==window.origin)return;const n=i.data;!n||typeof n!="object"||typeof n.kind!="string"||!n.kind.startsWith("userflow:")||t(n)===!0&&s()};window.addEventListener("message",e);const s=()=>window.removeEventListener("message",e);return s}function J(t){return new Promise(e=>{x(s=>{const i=t(s);return i?(e(i),!0):!1})})}const A=new Set;let _=!1;function X(t){return Z(),A.add(t),()=>{H(t)}}function H(t){A.delete(t)}function I(){A.forEach(t=>t())}function Z(){if(_)return;_=!0;const{history:t}=window,e=s=>{const i=t[s];t[s]=(...n)=>{const r=i.apply(t,n);return I(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{I()}),window.addEventListener("userflow:replacestate",()=>{I()})):(e("pushState"),e("replaceState")),window.addEventListener("popstate",()=>{I()})}class q{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){U({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=x(e),!1}async captureScreenshot(e,s,i,n){return U({kind:"userflow:crxScreenshot",x:e,y:s,width:i,height:n,devicePixelRatio:window.devicePixelRatio}),(await J(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var C=(t=>(t.ACTION="ACTION",t.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",t.REPLACED="REPLACED",t.SNOOZED="SNOOZED",t.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",t.USERFLOWJS="USERFLOWJS",t.USER_CLOSED="USER_CLOSED",t))(C||{}),m=(t=>(t.ACTION="ACTION",t.DRAFT="DRAFT",t.LINK="LINK",t.LAUNCHER_SEEN="LAUNCHER_SEEN",t.RESOURCE_CENTER="RESOURCE_CENTER",t.USERFLOWJS="USERFLOWJS",t))(m||{}),Q=(t=>(t.LIKE="LIKE",t.DISLIKE="DISLIKE",t))(Q||{}),S=(t=>(t.STRING="STRING",t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.DATETIME="DATETIME",t.LIST="LIST",t.RANDOM_AB="RANDOM_AB",t.RANDOM_NUMBER="RANDOM_NUMBER",t))(S||{}),k=(t=>(t.FLOW="FLOW",t.BANNER="BANNER",t.CHECKLIST="CHECKLIST",t.LAUNCHER="LAUNCHER",t.RESOURCE_CENTER="RESOURCE_CENTER",t))(k||{}),ee=(t=>(t.ALWAYS_TRUE="ALWAYS_TRUE",t.ATTRIBUTE="ATTRIBUTE",t.CLAUSE="CLAUSE",t.ELEMENT="ELEMENT",t.FILLED_IN_INPUT="FILLED_IN_INPUT",t.FLOW="FLOW",t.INPUT_VALUE="INPUT_VALUE",t.PAGE="PAGE",t.SEGMENT="SEGMENT",t.TIME="TIME",t))(ee||{}),te=(t=>(t.AUTO="AUTO",t.MANUAL="MANUAL",t))(te||{}),se=(t=>(t.INPUT="INPUT",t))(se||{}),ie=(t=>(t.ABSOLUTE_EQ="ABSOLUTE_EQ",t.ABSOLUTE_GT="ABSOLUTE_GT",t.ABSOLUTE_LT="ABSOLUTE_LT",t.AND="AND",t.BETWEEN="BETWEEN",t.CONTAINS="CONTAINS",t.EMPTY="EMPTY",t.ENDS_WITH="ENDS_WITH",t.EQ="EQ",t.EXCLUDES_ALL="EXCLUDES_ALL",t.EXCLUDES_ANY="EXCLUDES_ANY",t.FALSE="FALSE",t.GT="GT",t.GTE="GTE",t.INCLUDES_ALL="INCLUDES_ALL",t.INCLUDES_ANY="INCLUDES_ANY",t.LT="LT",t.LTE="LTE",t.NE="NE",t.NOT_CONTAINS="NOT_CONTAINS",t.NOT_EMPTY="NOT_EMPTY",t.NOT_REGEX="NOT_REGEX",t.OR="OR",t.REGEX="REGEX",t.RELATIVE_EQ="RELATIVE_EQ",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t.STARTS_WITH="STARTS_WITH",t.TRUE="TRUE",t.URL="URL",t))(ie||{}),ne=(t=>(t.CLICK="CLICK",t.DISABLED="DISABLED",t.MOUSEDOWN="MOUSEDOWN",t.NOT_CLICK="NOT_CLICK",t.NOT_DISABLED="NOT_DISABLED",t.NOT_PRESENT="NOT_PRESENT",t.PRESENT="PRESENT",t))(ne||{}),re=(t=>(t.ASSET="ASSET",t.CARTOON="CARTOON",t.NONE="NONE",t.URL="URL",t))(re||{}),oe=(t=>(t.INSIDE="INSIDE",t.OUTSIDE="OUTSIDE",t))(oe||{}),ae=(t=>(t.TOP_LEFT="TOP_LEFT",t.TOP_CENTER="TOP_CENTER",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_RIGHT="BOTTOM_RIGHT",t.BOTTOM_CENTER="BOTTOM_CENTER",t.BOTTOM_LEFT="BOTTOM_LEFT",t.CENTER="CENTER",t))(ae||{}),ce=(t=>(t.GOOGLE="GOOGLE",t.STANDARD="STANDARD",t))(ce||{}),le=(t=>(t.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",t.DISMISS="DISMISS",t))(le||{}),ue=(t=>(t.DISMISS="DISMISS",t.NONE="NONE",t))(ue||{}),he=(t=>(t.DEFAULT="DEFAULT",t.PLAINTEXT="PLAINTEXT",t.CUSTOM="CUSTOM",t))(he||{}),de=(t=>(t.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",t.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",t.NONE="NONE",t))(de||{}),fe=(t=>(t.BUBBLE="BUBBLE",t.END="END",t.ERROR="ERROR",t.FLAG="FLAG",t))(fe||{}),Ee=(t=>(t.MANUAL="MANUAL",t.NONE="NONE",t.SYNTHETIC="SYNTHETIC",t))(Ee||{}),Se=(t=>(t.BUBBLE="BUBBLE",t.HIDDEN="HIDDEN",t.MODAL="MODAL",t.TOOLTIP="TOOLTIP",t))(Se||{}),Te=(t=>(t.ABOVE="ABOVE",t.BELOW="BELOW",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Te||{}),we=(t=>(t.CLOSE_FLOW="CLOSE_FLOW",t.EVAL_JS="EVAL_JS",t.GO_TO_STEP="GO_TO_STEP",t.NAVIGATE="NAVIGATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.SNOOZE="SNOOZE",t.START_FLOW="START_FLOW",t))(we||{}),ge=(t=>(t.NEW_TAB="NEW_TAB",t.SAME_TAB="SAME_TAB",t))(ge||{}),Ie=(t=>(t.SET="SET",t.SET_DATETIME="SET_DATETIME",t.SET_DATETIME_ONCE="SET_DATETIME_ONCE",t.SET_ONCE="SET_ONCE",t.ADD="ADD",t.SUBTRACT="SUBTRACT",t.APPEND="APPEND",t.PREPEND="PREPEND",t.REMOVE="REMOVE",t.UNSET="UNSET",t))(Ie||{}),Ce=(t=>(t.MULTILINE_TEXT="MULTILINE_TEXT",t.MULTIPLE_CHOICE="MULTIPLE_CHOICE",t.NPS="NPS",t.SCALE="SCALE",t.STARS="STARS",t.TEXT="TEXT",t))(Ce||{}),L=(t=>(t.ACTION="ACTION",t.ANNOUNCEMENTS="ANNOUNCEMENTS",t.ASSISTANT="ASSISTANT",t.CHECKLIST="CHECKLIST",t.CONTACT="CONTACT",t.DIVIDER="DIVIDER",t.FLOWS="FLOWS",t.KNOWLEDGE_BASE="KNOWLEDGE_BASE",t.MESSAGE="MESSAGE",t.SUBPAGE="SUBPAGE",t))(L||{}),ke=(t=>(t.CRISP="CRISP",t.CUSTOM="CUSTOM",t.FRESHCHAT="FRESHCHAT",t.HELPSCOUT="HELPSCOUT",t.HUBSPOT="HUBSPOT",t.INTERCOM="INTERCOM",t.ZENDESK="ZENDESK",t.ZENDESK_MESSENGER="ZENDESK_MESSENGER",t))(ke||{}),me=(t=>(t.BUTTON="BUTTON",t.INPUT="INPUT",t))(me||{}),pe=(t=>(t.EMAIL="EMAIL",t.PHONE="PHONE",t.CHAT="CHAT",t))(pe||{}),Ue=(t=>(t.SILENT="SILENT",t.BADGE="BADGE",t.POPOUT="POPOUT",t))(Ue||{}),Le=(t=>(t.LAUNCHER_CLICK="LAUNCHER_CLICK",t.LAUNCHER_HOVER="LAUNCHER_HOVER",t.TARGET_CLICK="TARGET_CLICK",t.TARGET_HOVER="TARGET_HOVER",t.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",t.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",t))(Le||{}),G=(t=>(t.ACTIVATE="ACTIVATE",t.DEACTIVATE="DEACTIVATE",t.NEVER="NEVER",t))(G||{}),Ae=(t=>(t.AUTO="AUTO",t.TOP="TOP",t.RIGHT="RIGHT",t.BOTTOM="BOTTOM",t.LEFT="LEFT",t))(Ae||{}),Ne=(t=>(t.START="START",t.CENTER="CENTER",t.END="END",t))(Ne||{}),ve=(t=>(t.PERCENT="PERCENT",t.PX="PX",t))(ve||{}),_e=(t=>(t.BEACON="BEACON",t.BUTTON="BUTTON",t.HIDDEN="HIDDEN",t.ICON="ICON",t))(_e||{}),Re=(t=>(t.LAUNCHER="LAUNCHER",t.TARGET="TARGET",t))(Re||{}),ye=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(ye||{}),Oe=(t=>(t.NONE="NONE",t.LIKE="LIKE",t.SCALE="SCALE",t))(Oe||{});function be(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[t=>!t.match(/\d$/)],"data-id":[t=>!t.match(/\d$/)]},inferenceClassNameFilters:[t=>!t.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const d=be();function R(t){return Array.isArray(t)||(t=t?[t]:[]),t=t.map(e=>typeof e=="string"?new RegExp(e):e),t}function ze(t,e){return t.every(s=>typeof s=="function"?s(e):s instanceof RegExp?s.test(e):!0)}function De(){let t=P();if(d.urlFilter){if(t=d.urlFilter(t),typeof t!="string")throw new l("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(t)}catch(e){throw new l(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
2
+ import"./vendor.html-parse-stringify2.js";import{S as K}from"./vendor.phoenix.js";import{v as j}from"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4b9ab4f1-fdd7-4380-aeb6-f2720eaf2113",t._sentryDebugIdIdentifier="sentry-dbid-4b9ab4f1-fdd7-4380-aeb6-f2720eaf2113")}catch{}})();const z="modulepreload",Y=function(t){return"https://js.userflow.com/es2020/"+t},v={},w=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(s.map(c=>{if(c=Y(c),c in v)return;v[c]=!0;const h=c.endsWith(".css"),T=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${T}`))return;const E=document.createElement("link");if(E.rel=h?"stylesheet":z,h||(E.as="script"),E.crossOrigin="",E.href=c,u&&E.setAttribute("nonce",u),document.head.appendChild(E),h)return new Promise((F,V)=>{E.addEventListener("load",F),E.addEventListener("error",()=>V(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return n.then(a=>{for(const u of a||[])u.status==="rejected"&&r(u.reason);return e().catch(r)})};class l extends Error{constructor(e,s,i){super(e),Object.setPrototypeOf(this,l.prototype),this.name="UserflowError",this.code=s,this.humanMessage=i}}class B{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,s){e=this.formatKey(e);{if(!this.isSupported())return;window[this.type].setItem(e,s)}}removeItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].removeItem(e):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const g=new B("localStorage"),f=new B("sessionStorage");function je(t){window.location.href=t}function P(){return window.location.href}function U(t){window.postMessage(t,window.origin)}function x(t){const e=i=>{if(i.source!==window||i.origin!==window.origin)return;const n=i.data;!n||typeof n!="object"||typeof n.kind!="string"||!n.kind.startsWith("userflow:")||t(n)===!0&&s()};window.addEventListener("message",e);const s=()=>window.removeEventListener("message",e);return s}function J(t){return new Promise(e=>{x(s=>{const i=t(s);return i?(e(i),!0):!1})})}const A=new Set;let _=!1;function X(t){return Z(),A.add(t),()=>{H(t)}}function H(t){A.delete(t)}function I(){A.forEach(t=>t())}function Z(){if(_)return;_=!0;const{history:t}=window,e=s=>{const i=t[s];t[s]=(...n)=>{const r=i.apply(t,n);return I(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{I()}),window.addEventListener("userflow:replacestate",()=>{I()})):(e("pushState"),e("replaceState")),window.addEventListener("popstate",()=>{I()})}class q{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){U({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=x(e),!1}async captureScreenshot(e,s,i,n){return U({kind:"userflow:crxScreenshot",x:e,y:s,width:i,height:n,devicePixelRatio:window.devicePixelRatio}),(await J(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var C=(t=>(t.ACTION="ACTION",t.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",t.REPLACED="REPLACED",t.SNOOZED="SNOOZED",t.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",t.USERFLOWJS="USERFLOWJS",t.USER_CLOSED="USER_CLOSED",t))(C||{}),m=(t=>(t.ACTION="ACTION",t.DRAFT="DRAFT",t.LINK="LINK",t.LAUNCHER_SEEN="LAUNCHER_SEEN",t.RESOURCE_CENTER="RESOURCE_CENTER",t.USERFLOWJS="USERFLOWJS",t))(m||{}),Q=(t=>(t.LIKE="LIKE",t.DISLIKE="DISLIKE",t))(Q||{}),S=(t=>(t.STRING="STRING",t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.DATETIME="DATETIME",t.LIST="LIST",t.RANDOM_AB="RANDOM_AB",t.RANDOM_NUMBER="RANDOM_NUMBER",t))(S||{}),k=(t=>(t.FLOW="FLOW",t.BANNER="BANNER",t.CHECKLIST="CHECKLIST",t.LAUNCHER="LAUNCHER",t.RESOURCE_CENTER="RESOURCE_CENTER",t))(k||{}),ee=(t=>(t.ALWAYS_TRUE="ALWAYS_TRUE",t.ATTRIBUTE="ATTRIBUTE",t.CLAUSE="CLAUSE",t.ELEMENT="ELEMENT",t.FILLED_IN_INPUT="FILLED_IN_INPUT",t.FLOW="FLOW",t.INPUT_VALUE="INPUT_VALUE",t.PAGE="PAGE",t.SEGMENT="SEGMENT",t.TIME="TIME",t))(ee||{}),te=(t=>(t.AUTO="AUTO",t.MANUAL="MANUAL",t))(te||{}),se=(t=>(t.INPUT="INPUT",t))(se||{}),ie=(t=>(t.ABSOLUTE_EQ="ABSOLUTE_EQ",t.ABSOLUTE_GT="ABSOLUTE_GT",t.ABSOLUTE_LT="ABSOLUTE_LT",t.AND="AND",t.BETWEEN="BETWEEN",t.CONTAINS="CONTAINS",t.EMPTY="EMPTY",t.ENDS_WITH="ENDS_WITH",t.EQ="EQ",t.EXCLUDES_ALL="EXCLUDES_ALL",t.EXCLUDES_ANY="EXCLUDES_ANY",t.FALSE="FALSE",t.GT="GT",t.GTE="GTE",t.INCLUDES_ALL="INCLUDES_ALL",t.INCLUDES_ANY="INCLUDES_ANY",t.LT="LT",t.LTE="LTE",t.NE="NE",t.NOT_CONTAINS="NOT_CONTAINS",t.NOT_EMPTY="NOT_EMPTY",t.NOT_REGEX="NOT_REGEX",t.OR="OR",t.REGEX="REGEX",t.RELATIVE_EQ="RELATIVE_EQ",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t.STARTS_WITH="STARTS_WITH",t.TRUE="TRUE",t.URL="URL",t))(ie||{}),ne=(t=>(t.CLICK="CLICK",t.DISABLED="DISABLED",t.MOUSEDOWN="MOUSEDOWN",t.NOT_CLICK="NOT_CLICK",t.NOT_DISABLED="NOT_DISABLED",t.NOT_PRESENT="NOT_PRESENT",t.PRESENT="PRESENT",t))(ne||{}),re=(t=>(t.ASSET="ASSET",t.CARTOON="CARTOON",t.NONE="NONE",t.URL="URL",t))(re||{}),oe=(t=>(t.INSIDE="INSIDE",t.OUTSIDE="OUTSIDE",t))(oe||{}),ae=(t=>(t.TOP_LEFT="TOP_LEFT",t.TOP_CENTER="TOP_CENTER",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_RIGHT="BOTTOM_RIGHT",t.BOTTOM_CENTER="BOTTOM_CENTER",t.BOTTOM_LEFT="BOTTOM_LEFT",t.CENTER="CENTER",t))(ae||{}),ce=(t=>(t.GOOGLE="GOOGLE",t.STANDARD="STANDARD",t))(ce||{}),le=(t=>(t.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",t.DISMISS="DISMISS",t))(le||{}),ue=(t=>(t.DISMISS="DISMISS",t.NONE="NONE",t))(ue||{}),he=(t=>(t.DEFAULT="DEFAULT",t.PLAINTEXT="PLAINTEXT",t.CUSTOM="CUSTOM",t))(he||{}),de=(t=>(t.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",t.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",t.NONE="NONE",t))(de||{}),fe=(t=>(t.BUBBLE="BUBBLE",t.END="END",t.ERROR="ERROR",t.FLAG="FLAG",t))(fe||{}),Ee=(t=>(t.MANUAL="MANUAL",t.NONE="NONE",t.SYNTHETIC="SYNTHETIC",t))(Ee||{}),Se=(t=>(t.BUBBLE="BUBBLE",t.HIDDEN="HIDDEN",t.MODAL="MODAL",t.TOOLTIP="TOOLTIP",t))(Se||{}),Te=(t=>(t.ABOVE="ABOVE",t.BELOW="BELOW",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Te||{}),we=(t=>(t.CLOSE_FLOW="CLOSE_FLOW",t.EVAL_JS="EVAL_JS",t.GO_TO_STEP="GO_TO_STEP",t.NAVIGATE="NAVIGATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.SNOOZE="SNOOZE",t.START_FLOW="START_FLOW",t))(we||{}),ge=(t=>(t.NEW_TAB="NEW_TAB",t.SAME_TAB="SAME_TAB",t))(ge||{}),Ie=(t=>(t.SET="SET",t.SET_DATETIME="SET_DATETIME",t.SET_DATETIME_ONCE="SET_DATETIME_ONCE",t.SET_ONCE="SET_ONCE",t.ADD="ADD",t.SUBTRACT="SUBTRACT",t.APPEND="APPEND",t.PREPEND="PREPEND",t.REMOVE="REMOVE",t.UNSET="UNSET",t))(Ie||{}),Ce=(t=>(t.MULTILINE_TEXT="MULTILINE_TEXT",t.MULTIPLE_CHOICE="MULTIPLE_CHOICE",t.NPS="NPS",t.SCALE="SCALE",t.STARS="STARS",t.TEXT="TEXT",t))(Ce||{}),L=(t=>(t.ACTION="ACTION",t.ANNOUNCEMENTS="ANNOUNCEMENTS",t.ASSISTANT="ASSISTANT",t.CHECKLIST="CHECKLIST",t.CONTACT="CONTACT",t.DIVIDER="DIVIDER",t.FLOWS="FLOWS",t.KNOWLEDGE_BASE="KNOWLEDGE_BASE",t.MESSAGE="MESSAGE",t.SUBPAGE="SUBPAGE",t))(L||{}),ke=(t=>(t.CRISP="CRISP",t.CUSTOM="CUSTOM",t.FRESHCHAT="FRESHCHAT",t.HELPSCOUT="HELPSCOUT",t.HUBSPOT="HUBSPOT",t.INTERCOM="INTERCOM",t.ZENDESK="ZENDESK",t.ZENDESK_MESSENGER="ZENDESK_MESSENGER",t))(ke||{}),me=(t=>(t.BUTTON="BUTTON",t.INPUT="INPUT",t))(me||{}),pe=(t=>(t.EMAIL="EMAIL",t.PHONE="PHONE",t.CHAT="CHAT",t))(pe||{}),Ue=(t=>(t.SILENT="SILENT",t.BADGE="BADGE",t.POPOUT="POPOUT",t))(Ue||{}),Le=(t=>(t.LAUNCHER_CLICK="LAUNCHER_CLICK",t.LAUNCHER_HOVER="LAUNCHER_HOVER",t.TARGET_CLICK="TARGET_CLICK",t.TARGET_HOVER="TARGET_HOVER",t.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",t.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",t))(Le||{}),G=(t=>(t.ACTIVATE="ACTIVATE",t.DEACTIVATE="DEACTIVATE",t.NEVER="NEVER",t))(G||{}),Ae=(t=>(t.AUTO="AUTO",t.TOP="TOP",t.RIGHT="RIGHT",t.BOTTOM="BOTTOM",t.LEFT="LEFT",t))(Ae||{}),Ne=(t=>(t.START="START",t.CENTER="CENTER",t.END="END",t))(Ne||{}),ve=(t=>(t.PERCENT="PERCENT",t.PX="PX",t))(ve||{}),_e=(t=>(t.BEACON="BEACON",t.BUTTON="BUTTON",t.HIDDEN="HIDDEN",t.ICON="ICON",t))(_e||{}),Re=(t=>(t.LAUNCHER="LAUNCHER",t.TARGET="TARGET",t))(Re||{}),ye=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(ye||{}),Oe=(t=>(t.NONE="NONE",t.LIKE="LIKE",t.SCALE="SCALE",t))(Oe||{});function be(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[t=>!t.match(/\d$/)],"data-id":[t=>!t.match(/\d$/)]},inferenceClassNameFilters:[t=>!t.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const d=be();function R(t){return Array.isArray(t)||(t=t?[t]:[]),t=t.map(e=>typeof e=="string"?new RegExp(e):e),t}function ze(t,e){return t.every(s=>typeof s=="function"?s(e):s instanceof RegExp?s.test(e):!0)}function De(){let t=P();if(d.urlFilter){if(t=d.urlFilter(t),typeof t!="string")throw new l("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(t)}catch(e){throw new l(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
3
3
  Returned URL: `+t+`
4
- Error message: `+e.message)}}return t}let W="";try{W=localStorage.getItem("debug")||""}catch{}const $=W.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=N("log");o.group=N("group");o.groupCollapsed=N("groupCollapsed");o.groupEnd=function(){$&&console.groupEnd()};let p;function N(t){return function(e,...s){if($){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const Me=()=>w(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));function Be(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class y{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const O=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Pe=()=>w(()=>import("./BannerApp.js"),__vite__mapDeps([23,1,2,3,4,5,6,7,15,12,13,14,10,11,9,8,24,17,18,16,22,25,26])),b="1008420",xe=import.meta.url,D=50,He=5*60*1e3,M="userflowClientState";class Ge{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),D))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+b),X(this.onUrlChange),this.setTargetEnv(new q),this.checkTestUserAtBoot(),this.toggleUI();for(const e of O)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),H(this.onUrlChange),this.destroyTargetEnv();for(const e of O)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new l("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(M,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(M);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(xe).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new K(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected")}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
4
+ Error message: `+e.message)}}return t}let W="";try{W=localStorage.getItem("debug")||""}catch{}const $=W.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=N("log");o.group=N("group");o.groupCollapsed=N("groupCollapsed");o.groupEnd=function(){$&&console.groupEnd()};let p;function N(t){return function(e,...s){if($){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const Me=()=>w(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]));function Be(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class y{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const O=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],Pe=()=>w(()=>import("./BannerApp.js"),__vite__mapDeps([23,1,2,3,4,5,6,7,15,12,13,14,10,11,9,8,24,17,18,16,22,25,26])),b="1008494",xe=import.meta.url,D=50,He=5*60*1e3,M="userflowClientState";class Ge{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),D))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+b),X(this.onUrlChange),this.setTargetEnv(new q),this.checkTestUserAtBoot(),this.toggleUI();for(const e of O)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),H(this.onUrlChange),this.destroyTargetEnv();for(const e of O)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new l("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(M,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(M);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(xe).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new K(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected")}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
5
5
  Details:
6
6
  `+i.details.map(n=>(n.path?`${n.path}: `:"")+n.message):""))})}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const s={protocolVersion:2,userflowClientBuild:b,signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map(i=>({flowId:i.flow.id})),trackers:Array.from(this.trackers.values()).map(i=>({flowId:i.tracker.flowId})),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map(i=>({conditionId:i.condition.id,isTrue:i.isTrue})),previewFlowId:f.getItem("previewFlowId"),clientContext:e};return o("channel join payload",s),s}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout(()=>{if(this.hasDraftSession()||this.assistantMessageInProgress){this.debounceInactiveDisconnect();return}o("disconnecting from socket due to inactivity"),this.disconnect()},He)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some(e=>e.draftMode)}async send(e,{batch:s,endBatch:i,handlesRejection:n}={}){return(!this.inBatch||!["ToggleClientCondition","UpdateClientContext"].includes(e.kind))&&this.checkPushRateLimit(),this.ensureConnected(),s&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),i?this.endBatch():this.endBatchTimeout=window.setTimeout(()=>{this.endBatch()},D)),this.sendRaw(e,{handlesRejection:n})}async sendRaw(e,{handlesRejection:s}={}){return new Promise((i,n)=>{if(!this.channel){const c=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(s)throw Error(c);console.log(c,`
7
7
  Client message:`,e);return}o(`push ${e.kind} message`,e);const r=this.clientClock,a=()=>{this.serverClock=r,this.channel?.off("phx_error",u)},u=this.channel.on("phx_error",c=>{a();const h=`Userflow.js send ${e.kind} got phx_error`;this._socketStatus==="connected"&&console.log(h,`
@@ -14,5 +14,5 @@ Error:`,c),s&&n(new l(h,c.code,c.message))})})}endBatch(){this.inBatch=!1,this.s
14
14
  - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.
15
15
  - The user legitimately being very active, in which case you can just ignore this error.
16
16
 
17
- If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:u,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:h}=e,T=this.launcherSessions.findIndex(E=>E.flow.id===h.flow.id);T===-1?this.launcherSessions=[...this.launcherSessions,h]:this.launcherSessions=[...this.launcherSessions.slice(0,T),h,...this.launcherSessions.slice(T+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const h=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,h)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":u?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!g.isSupported())throw new l("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=g.getItem(i);n||(n="anon-"+j(),g.setItem(i,n)),await this.identify(n,e,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(e={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,s={},{signature:i,membership:n}={}){if(o("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=i||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(n)},{batch:!0})}async updateGroup(e={},s={}){o("updateGroup");const i=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:i,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(e==null)return{};if(typeof e!="object")throw new l("Userflow: 'attributes' must be an object.");const s={};for(const i in e){if(!e.hasOwnProperty(i))continue;if(i==="traits"){const r=e[i];Object.assign(s,this.extractLegacyTraits(r));continue}let n=e[i];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n==null||Array.isArray(n))s[i]=this.normalizeAttributeLiteralOrList(i,n);else{if(typeof n!="object"||n==null)throw new l(`Userflow: Invalid value for '${i}' attribute.`);if("set"in n)s[i]={set:this.normalizeAttributeLiteralOrList(i,n.set),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("set_once"in n||"setOnce"in n)s[i]={setOnce:this.normalizeAttributeLiteralOrList(i,n.set_once??n.setOnce),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("add"in n){const r=n.add;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'add' value for '${i}' attribute. Must be a number or string.`);s[i]={add:r}}else if("subtract"in n){const r=n.subtract;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'subtract' value for '${i}' attribute. Must be a number or string.`);s[i]={subtract:r}}else if("append"in n)s[i]={append:this.normalizeAttributeLiteralOrList(i,n.append)};else if("prepend"in n)s[i]={prepend:this.normalizeAttributeLiteralOrList(i,n.prepend)};else if("remove"in n)s[i]={remove:this.normalizeAttributeLiteralOrList(i,n.remove)};else throw new l(`Userflow: Invalid value for '${i}' attribute.`)}}return s}normalizeAttributeLiteralOrList(e,s){return Array.isArray(s)?s.map(i=>this.normalizeAttributeLiteral(e,i)):this.normalizeAttributeLiteral(e,s)}normalizeAttributeLiteral(e,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new l(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new l(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const s=[];for(const i in e)e.hasOwnProperty(i)&&s.push({name:i,value:e[i]});e=s}return e.reduce((s,{name:i,value:n,dataType:r})=>{if(typeof i!="string"||i.length>100||!i.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",i),s;if(typeof n!="string")if(typeof n=="boolean")r||(r="boolean"),n=n?"true":"false";else if(typeof n=="number")r||(r=Number.isInteger(n)?"integer":"decimal"),n=String(n);else return this.warn(`userflow.identify: The value of trait '${i}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,n),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${i}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[i]={set:n,dataType:a},s},{})}async track(e,s={},{userOnly:i}={}){o(`track '${e}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!i,name:e,attributes:this.normalizeEventAttributes(s)},{batch:!0})}normalizeEventAttributes(e){const s=this.normalizeAttributes(e);for(const i in s){if(!s.hasOwnProperty(i))continue;const n=s[i];if(!(n==null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||Array.isArray(n)||"set"in n))throw new l(`Userflow: Invalid value for '${i}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(P()),s=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:m.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();(!this.clientContext||e.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:De(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return this.externalId!=null}on(e,s){let i=this.listeners.get(e);i||(i=new Set,this.listeners.set(e,i)),i.add(s)}off(e,s){const i=this.listeners.get(e);i&&i.delete(s)}emit(e,...s){const i=this.listeners.get(e);i&&Array.from(i).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach((e,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,g.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0)}async startFlow({flowId:e,stepCvid:s,startReason:i,once:n,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:C.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const u={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(u,{batch:r})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===L.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Be(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===L.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:u}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,u),this.checklistSession?.id===e.id&&this.setChecklistSession(null,u),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===k.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===k.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:e.id,endReason:s};await this.send(a,{batch:i})}async goToStep(e,s){o("goToStep",e.id,s.name||s.id),this.ensureIdentified();const i=this.send({kind:"GoToStep",sessionId:e.id,stepId:s.id});e.currentStep=s,this.emit("gotostep",{session:e,step:s}),await i}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===k.CHECKLIST&&this.endFlow(e,{endReason:C.USERFLOWJS})}setFlowSession(e,s=this.clientClock){const i=this.flowSession;this.flowSession=e,this.flowSessionClock=s,e&&!i&&(this.hideChecklist(),this.closeResourceCenter()),e==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,s=this.clientClock){const i=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=s,e===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==i?.id&&(this.checklistExpanded=!!f.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const s=this.resourceCenterSession;e=typeof e=="function"?e(this.resourceCenterSession):e,this.resourceCenterSession=e,e===null&&(this.resourceCenterOpen=!1),s&&s.id!==e?.id&&f.removeItem(`resourceCenterOpen:${s.id}`),e&&e.id!==s?.id&&(this.resourceCenterOpen=!!f.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:m.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const s=this.activeLauncherFlowId&&this.launcherSessions.find(i=>i.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:s}=e.version;e.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===G.DEACTIVATE?this.dismissLauncher(e,{endReason:C.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=w(()=>import("./ui.js"),__vite__mapDeps([27,1,2,3,17,18,4,5,6,7,25,26]));this.bannerSession&&Pe(),this.resourceCenterSession&&Me();const{RealUI:s}=await e;return new s(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;o("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:s}=await w(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.v);return{conditionTypes:r}},__vite__mapDeps([10,2,11])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new y([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await w(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(h=>h.v);return{conditionTypes:c}},__vite__mapDeps([10,2,11])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,u=i[a.type];n.untrack&&n.untrack(),n.untrack=u.track({sessionData:new y(r.data),condition:a,flipBackEvents:!0,callback:c=>{const h=n.isTrue;n.isTrue=c,!h&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),U({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const s=this.getAudio();e&&(s.src=e);const i=s.play();this.audioReady=!0,i&&i.catch(n=>{n.name})}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:s})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,s,i){const r={id:++this.notificationIdCounter,label:e,message:s,type:i};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter(s=>s.id!==e),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const t=Object.assign(window.userflow||{},We());window.userflow=t,window.studio1=t,$e()}function We(){const t=new Ge;return{_stubbed:!1,init(e){t.init(e)},identify(e,s={},i={}){return t.identify(e,s,i)},identifyAnonymous(e={},s={}){return t.identifyAnonymous(e,s)},isIdentified(){return t.isIdentified()},updateUser(e,s={}){return t.updateUser(e,s)},group(e,s={},i={}){return t.group(e,s,i)},updateGroup(e,s={}){return t.updateGroup(e,s)},track(e,s={},i={}){return t.track(e,s,i)},start(e,{once:s}={}){return t.startFlow({flowId:e,startReason:m.USERFLOWJS,once:s})},startFlow(e){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},startWalk(e){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},endAll(){return t.endAllFlows()},endChecklist(){return t.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){t.openResourceCenter()},closeResourceCenter(){t.closeResourceCenter()},toggleResourceCenter(){t.toggleResourceCenter()},setResourceCenterLauncherHidden(e){t.setResourceCenterLauncherHidden(e)},getResourceCenterState(){return t.getResourceCenterState()},setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){t.reset()},remount(){t.remount()},on(e,s){t.on(e,s)},off(e,s){t.off(e,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&d.customInputs.push({cssSelector:e})},registerCustomInput(e,s){d.customInputs.push({cssSelector:e,getValue:s})},setCustomNavigate(e){d.customNavigate=e},setUrlFilter(e){d.urlFilter=e},setLinkUrlDecorator(e){d.linkUrlDecorator=e,t.emit("uistatechange")},setInferenceAttributeNames(e){d.inferenceAttributeNames=e},setInferenceAttributeFilter(e,s){d.inferenceAttributeFilters[e]=R(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=R(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},_getInitToken(){return t.getInitToken()},_getIdentifiedUser(){return t.getIdentifiedUser()}}}function $e(){const t=window.userflow,e=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!e||e.length===0)){o(`processing ${e.length} items in the queue`);for(const[s,i,n]of e){if(typeof t[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=t[s](...n);i&&r&&typeof r.then=="function"&&r.then(i.resolve,i.reject)}o("queue processed")}}var Ye=window.userflow;export{Oe as $,Ue as A,Pe as B,ke as C,P as D,C as E,we as F,ge as G,Ie as H,o as I,y as J,ce as K,_e as L,ue as M,ie as N,ze as O,O as P,ee as Q,Me as R,m as S,fe as T,l as U,Ee as V,De as W,X,H as Y,ne as Z,w as _,L as a,Q as a0,de as b,d as c,he as d,Ye as default,me as e,k as f,Be as g,pe as h,ye as i,se as j,le as k,te as l,g as m,Ce as n,Se as o,re as p,ae as q,Le as r,Ae as s,Re as t,f as u,Ne as v,ve as w,Te as x,oe as y,je as z};
17
+ If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:u,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:h}=e,T=this.launcherSessions.findIndex(E=>E.flow.id===h.flow.id);T===-1?this.launcherSessions=[...this.launcherSessions,h]:this.launcherSessions=[...this.launcherSessions.slice(0,T),h,...this.launcherSessions.slice(T+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const h=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,h)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":u?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!g.isSupported())throw new l("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=g.getItem(i);n||(n="anon-"+j(),g.setItem(i,n)),await this.identify(n,e,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(e={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,s={},{signature:i,membership:n}={}){if(o("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=i||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(n)},{batch:!0})}async updateGroup(e={},s={}){o("updateGroup");const i=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:i,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(e==null)return{};if(typeof e!="object")throw new l("Userflow: 'attributes' must be an object.");const s={};for(const i in e){if(!e.hasOwnProperty(i))continue;if(i==="traits"){const r=e[i];Object.assign(s,this.extractLegacyTraits(r));continue}let n=e[i];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n==null||Array.isArray(n))s[i]=this.normalizeAttributeLiteralOrList(i,n);else{if(typeof n!="object"||n==null)throw new l(`Userflow: Invalid value for '${i}' attribute.`);if("set"in n)s[i]={set:this.normalizeAttributeLiteralOrList(i,n.set),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("set_once"in n||"setOnce"in n)s[i]={setOnce:this.normalizeAttributeLiteralOrList(i,n.set_once??n.setOnce),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("add"in n){const r=n.add;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'add' value for '${i}' attribute. Must be a number or string.`);s[i]={add:r}}else if("subtract"in n){const r=n.subtract;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'subtract' value for '${i}' attribute. Must be a number or string.`);s[i]={subtract:r}}else if("append"in n)s[i]={append:this.normalizeAttributeLiteralOrList(i,n.append)};else if("prepend"in n)s[i]={prepend:this.normalizeAttributeLiteralOrList(i,n.prepend)};else if("remove"in n)s[i]={remove:this.normalizeAttributeLiteralOrList(i,n.remove)};else throw new l(`Userflow: Invalid value for '${i}' attribute.`)}}return s}normalizeAttributeLiteralOrList(e,s){return Array.isArray(s)?s.map(i=>this.normalizeAttributeLiteral(e,i)):this.normalizeAttributeLiteral(e,s)}normalizeAttributeLiteral(e,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new l(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new l(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const s=[];for(const i in e)e.hasOwnProperty(i)&&s.push({name:i,value:e[i]});e=s}return e.reduce((s,{name:i,value:n,dataType:r})=>{if(typeof i!="string"||i.length>100||!i.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",i),s;if(typeof n!="string")if(typeof n=="boolean")r||(r="boolean"),n=n?"true":"false";else if(typeof n=="number")r||(r=Number.isInteger(n)?"integer":"decimal"),n=String(n);else return this.warn(`userflow.identify: The value of trait '${i}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,n),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${i}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[i]={set:n,dataType:a},s},{})}async track(e,s={},{userOnly:i}={}){o(`track '${e}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!i,name:e,attributes:this.normalizeEventAttributes(s)},{batch:!0})}normalizeEventAttributes(e){const s=this.normalizeAttributes(e);for(const i in s){if(!s.hasOwnProperty(i))continue;const n=s[i];if(!(n==null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||Array.isArray(n)||"set"in n))throw new l(`Userflow: Invalid value for '${i}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(P()),s=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:m.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();(!this.clientContext||e.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:De(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return this.externalId!=null}on(e,s){let i=this.listeners.get(e);i||(i=new Set,this.listeners.set(e,i)),i.add(s)}off(e,s){const i=this.listeners.get(e);i&&i.delete(s)}emit(e,...s){const i=this.listeners.get(e);i&&Array.from(i).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach((e,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,g.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0)}async startFlow({flowId:e,stepCvid:s,startReason:i,once:n,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:C.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const u={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(u,{batch:r})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===L.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Be(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===L.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:u}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,u),this.checklistSession?.id===e.id&&this.setChecklistSession(null,u),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===k.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===k.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:e.id,endReason:s};await this.send(a,{batch:i})}async goToStep(e,s){o("goToStep",e.id,s.name||s.id),this.ensureIdentified();const i=this.send({kind:"GoToStep",sessionId:e.id,stepId:s.id});e.currentStep=s,this.emit("gotostep",{session:e,step:s}),await i}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===k.CHECKLIST&&this.endFlow(e,{endReason:C.USERFLOWJS})}setFlowSession(e,s=this.clientClock){const i=this.flowSession;this.flowSession=e,this.flowSessionClock=s,e&&!i&&(this.hideChecklist(),this.closeResourceCenter()),e==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,s=this.clientClock){const i=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=s,e===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==i?.id&&(this.checklistExpanded=!!f.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const s=this.resourceCenterSession;e=typeof e=="function"?e(this.resourceCenterSession):e,this.resourceCenterSession=e,e===null&&(this.resourceCenterOpen=!1),s&&s.id!==e?.id&&f.removeItem(`resourceCenterOpen:${s.id}`),e&&e.id!==s?.id&&(this.resourceCenterOpen=!!f.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:m.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const s=this.activeLauncherFlowId&&this.launcherSessions.find(i=>i.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:s}=e.version;e.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===G.DEACTIVATE?this.dismissLauncher(e,{endReason:C.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=w(()=>import("./ui.js"),__vite__mapDeps([27,1,2,3,17,18,4,5,6,7,25,26]));this.bannerSession&&Pe(),this.resourceCenterSession&&Me();const{RealUI:s}=await e;return new s(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;o("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:s}=await w(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.v);return{conditionTypes:r}},__vite__mapDeps([10,2,11])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new y([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await w(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(h=>h.v);return{conditionTypes:c}},__vite__mapDeps([10,2,11])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,u=i[a.type];n.untrack&&n.untrack(),n.untrack=u.track({sessionData:new y(r.data),condition:a,flipBackEvents:!0,callback:c=>{const h=n.isTrue;n.isTrue=c,!h&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),U({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const s=this.getAudio();e&&(s.src=e);const i=s.play();this.audioReady=!0,i&&i.catch(n=>{n.name})}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:s})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,s,i){const r={id:++this.notificationIdCounter,label:e,message:s,type:i};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter(s=>s.id!==e),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const t=Object.assign(window.userflow||{},We());window.userflow=t,window.studio1=t,$e()}function We(){const t=new Ge;return{_stubbed:!1,init(e){t.init(e)},identify(e,s={},i={}){return t.identify(e,s,i)},identifyAnonymous(e={},s={}){return t.identifyAnonymous(e,s)},isIdentified(){return t.isIdentified()},updateUser(e,s={}){return t.updateUser(e,s)},group(e,s={},i={}){return t.group(e,s,i)},updateGroup(e,s={}){return t.updateGroup(e,s)},track(e,s={},i={}){return t.track(e,s,i)},start(e,{once:s}={}){return t.startFlow({flowId:e,startReason:m.USERFLOWJS,once:s})},startFlow(e){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},startWalk(e){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},endAll(){return t.endAllFlows()},endChecklist(){return t.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){t.openResourceCenter()},closeResourceCenter(){t.closeResourceCenter()},toggleResourceCenter(){t.toggleResourceCenter()},setResourceCenterLauncherHidden(e){t.setResourceCenterLauncherHidden(e)},getResourceCenterState(){return t.getResourceCenterState()},setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){t.reset()},remount(){t.remount()},on(e,s){t.on(e,s)},off(e,s){t.off(e,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&d.customInputs.push({cssSelector:e})},registerCustomInput(e,s){d.customInputs.push({cssSelector:e,getValue:s})},setCustomNavigate(e){d.customNavigate=e},setUrlFilter(e){d.urlFilter=e},setLinkUrlDecorator(e){d.linkUrlDecorator=e,t.emit("uistatechange")},setInferenceAttributeNames(e){d.inferenceAttributeNames=e},setInferenceAttributeFilter(e,s){d.inferenceAttributeFilters[e]=R(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=R(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},_getInitToken(){return t.getInitToken()},_getIdentifiedUser(){return t.getIdentifiedUser()}}}function $e(){const t=window.userflow,e=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!e||e.length===0)){o(`processing ${e.length} items in the queue`);for(const[s,i,n]of e){if(typeof t[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=t[s](...n);i&&r&&typeof r.then=="function"&&r.then(i.resolve,i.reject)}o("queue processed")}}var Ye=window.userflow;export{Oe as $,Ue as A,Pe as B,ke as C,P as D,C as E,we as F,ge as G,Ie as H,o as I,y as J,ce as K,_e as L,ue as M,ie as N,ze as O,O as P,ee as Q,Me as R,m as S,fe as T,l as U,Ee as V,De as W,X,H as Y,ne as Z,w as _,L as a,Q as a0,de as b,d as c,he as d,Ye as default,me as e,k as f,Be as g,pe as h,ye as i,se as j,Se as k,le as l,te as m,g as n,Ce as o,re as p,ae as q,Le as r,Ae as s,Re as t,f as u,Ne as v,ve as w,Te as x,oe as y,je as z};
18
18
  //# sourceMappingURL=userflow.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[d]="d4d28c7d-78ec-4433-9b29-f5a6fd84c70b",e._sentryDebugIdIdentifier="sentry-dbid-d4d28c7d-78ec-4433-9b29-f5a6fd84c70b")}catch{}})();var f=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};f.SENTRY_RELEASE={id:"7ebad4a0e80a78c7fbba97aaa3421944613f1f74"};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}export{t as g};
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new Error().stack;d&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[d]="c9e4a16b-a703-4aae-8d07-ed10b3deb8a4",e._sentryDebugIdIdentifier="sentry-dbid-c9e4a16b-a703-4aae-8d07-ed10b3deb8a4")}catch{}})();var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};a.SENTRY_RELEASE={id:"bc97134d4f7f040adb7d5647d12d10a1770dbe6a"};function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}export{t as g};
2
2
  //# sourceMappingURL=vendor.html-parse-stringify2.js.map