userflow.js-self-hosted 0.1.1002544 → 0.1.1002559

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/Icons.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";const t=0,c=10,r=2e3;function l(e){return 1234500+e}const n=[];function a(){const e={zIndex:0===n.length?l(100):n[n.length-1].zIndex+10};return n.push(e),e}function o(e){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}function s(){const[t,c]=e.useState(a);e.useEffect((()=>()=>o(t)),[t]);const r=e.useCallback((()=>{o(t),c(a())}),[t]);return{zIndex:t.zIndex,bringToFront:r}}const i=({children:t})=>{const{zIndex:c}=s();return e.createElement(w.Provider,{value:c},t)},w=e.createContext(void 0);function v(){return e.useContext(w)||l(100)}const g=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M0 304v-96c0-13.3 10.7-24 24-24h200V80.2c0-21.4 25.8-32.1 41-17L441 239c9.4 9.4 9.4 24.6 0 34L265 448.7c-15.1 15.1-41 4.4-41-17V328H24c-13.3 0-24-10.7-24-24z"})),m=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M272 480h-96c-13.3 0-24-10.7-24-24V256H48.2c-21.4 0-32.1-25.8-17-41L207 39c9.4-9.4 24.6-9.4 34 0l175.8 176c15.1 15.1 4.4 41-17 41H296v200c0 13.3-10.7 24-24 24z"})),h=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},e.createElement("path",{fill:"currentColor",d:"M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"})),d=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"})),u=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M107.515 150.971L8.485 250c-4.686 4.686-4.686 12.284 0 16.971L107.515 366c7.56 7.56 20.485 2.206 20.485-8.485v-71.03h308c6.627 0 12-5.373 12-12v-32c0-6.627-5.373-12-12-12H128v-71.03c0-10.69-12.926-16.044-20.485-8.484z"})),x=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M340.485 366l99.03-99.029c4.686-4.686 4.686-12.284 0-16.971l-99.03-99.029c-7.56-7.56-20.485-2.206-20.485 8.485v71.03H12c-6.627 0-12 5.373-12 12v32c0 6.627 5.373 12 12 12h308v71.03c0 10.689 12.926 16.043 20.485 8.484z"})),L=()=>e.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},e.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),p=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512"},e.createElement("path",{fill:"currentColor",d:"M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"})),f=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 480 512"},e.createElement("path",{fill:"currentColor",d:"M394.23 100.85c-11.19-7.09-26.03-3.8-33.12 7.41s-3.78 26.03 7.41 33.12C408.27 166.6 432 209.44 432 256s-23.73 89.41-63.48 114.62c-11.19 7.09-14.5 21.92-7.41 33.12 6.51 10.28 21.12 15.03 33.12 7.41C447.94 377.09 480 319.09 480 256s-32.06-121.09-85.77-155.15zm-56 78.28c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.37-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.87s-17.54-61.33-45.78-76.87zM231.81 64c-5.91 0-11.92 2.18-16.78 7.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c4.87 4.87 10.88 7.05 16.78 7.05 12.33 0 24.19-9.52 24.19-24.02V88.02C256 73.51 244.13 64 231.81 64zM208 366.05L145.94 304H48v-96h97.94L208 145.95v220.1z"})),E=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},e.createElement("path",{fill:"currentColor",d:"M231.81 64c-5.91 0-11.92 2.18-16.78 7.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c4.87 4.87 10.88 7.05 16.78 7.05 12.33 0 24.19-9.52 24.19-24.02V88.02C256 73.51 244.13 64 231.81 64zM208 366.05l-48-47.99L145.94 304H48v-96h97.94L160 193.94l48-47.99v220.1zM465.94 256l41.37-41.37c6.25-6.25 6.25-16.38 0-22.63L496 180.69c-6.25-6.25-16.38-6.25-22.63 0L432 222.06l-41.37-41.37c-6.25-6.25-16.38-6.25-22.63 0L356.69 192c-6.25 6.25-6.25 16.38 0 22.63L398.06 256l-41.37 41.37c-6.25 6.25-6.25 16.38 0 22.63L368 331.32c6.25 6.25 16.38 6.25 22.63 0L432 289.94l41.37 41.37c6.25 6.25 16.38 6.25 22.63 0L507.31 320c6.25-6.25 6.25-16.38 0-22.63L465.94 256z"}));export{g as A,c as C,u as L,r as N,L as S,p as T,E as V,h as a,f as b,d as c,x as d,v as e,m as f,i as g,t as h,s as u,l as w};
1
+ import{r as e}from"./vendor.react.js";import{c as t}from"./userflow.js";const r=0,c=10,l=2e3;function n(e){return t.baseZIndex+e}const a=[];function s(){const e={zIndex:0===a.length?n(100):a[a.length-1].zIndex+10};return a.push(e),e}function o(e){const t=a.indexOf(e);-1!==t&&a.splice(t,1)}function i(){const[t,r]=e.useState(s);e.useEffect((()=>()=>o(t)),[t]);const c=e.useCallback((()=>{o(t),r(s())}),[t]);return{zIndex:t.zIndex,bringToFront:c}}const w=({children:t})=>{const{zIndex:r}=i();return e.createElement(v.Provider,{value:r},t)},v=e.createContext(void 0);function m(){return e.useContext(v)||n(100)}const g=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M0 304v-96c0-13.3 10.7-24 24-24h200V80.2c0-21.4 25.8-32.1 41-17L441 239c9.4 9.4 9.4 24.6 0 34L265 448.7c-15.1 15.1-41 4.4-41-17V328H24c-13.3 0-24-10.7-24-24z"})),h=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M272 480h-96c-13.3 0-24-10.7-24-24V256H48.2c-21.4 0-32.1-25.8-17-41L207 39c9.4-9.4 24.6-9.4 34 0l175.8 176c15.1 15.1 4.4 41-17 41H296v200c0 13.3-10.7 24-24 24z"})),d=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},e.createElement("path",{fill:"currentColor",d:"M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"})),u=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"})),x=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M107.515 150.971L8.485 250c-4.686 4.686-4.686 12.284 0 16.971L107.515 366c7.56 7.56 20.485 2.206 20.485-8.485v-71.03h308c6.627 0 12-5.373 12-12v-32c0-6.627-5.373-12-12-12H128v-71.03c0-10.69-12.926-16.044-20.485-8.484z"})),L=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M340.485 366l99.03-99.029c4.686-4.686 4.686-12.284 0-16.971l-99.03-99.029c-7.56-7.56-20.485-2.206-20.485 8.485v71.03H12c-6.627 0-12 5.373-12 12v32c0 6.627 5.373 12 12 12h308v71.03c0 10.689 12.926 16.043 20.485 8.484z"})),p=()=>e.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},e.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),f=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512"},e.createElement("path",{fill:"currentColor",d:"M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"})),E=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 480 512"},e.createElement("path",{fill:"currentColor",d:"M394.23 100.85c-11.19-7.09-26.03-3.8-33.12 7.41s-3.78 26.03 7.41 33.12C408.27 166.6 432 209.44 432 256s-23.73 89.41-63.48 114.62c-11.19 7.09-14.5 21.92-7.41 33.12 6.51 10.28 21.12 15.03 33.12 7.41C447.94 377.09 480 319.09 480 256s-32.06-121.09-85.77-155.15zm-56 78.28c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.37-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.87s-17.54-61.33-45.78-76.87zM231.81 64c-5.91 0-11.92 2.18-16.78 7.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c4.87 4.87 10.88 7.05 16.78 7.05 12.33 0 24.19-9.52 24.19-24.02V88.02C256 73.51 244.13 64 231.81 64zM208 366.05L145.94 304H48v-96h97.94L208 145.95v220.1z"})),z=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},e.createElement("path",{fill:"currentColor",d:"M231.81 64c-5.91 0-11.92 2.18-16.78 7.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c4.87 4.87 10.88 7.05 16.78 7.05 12.33 0 24.19-9.52 24.19-24.02V88.02C256 73.51 244.13 64 231.81 64zM208 366.05l-48-47.99L145.94 304H48v-96h97.94L160 193.94l48-47.99v220.1zM465.94 256l41.37-41.37c6.25-6.25 6.25-16.38 0-22.63L496 180.69c-6.25-6.25-16.38-6.25-22.63 0L432 222.06l-41.37-41.37c-6.25-6.25-16.38-6.25-22.63 0L356.69 192c-6.25 6.25-6.25 16.38 0 22.63L398.06 256l-41.37 41.37c-6.25 6.25-6.25 16.38 0 22.63L368 331.32c6.25 6.25 16.38 6.25 22.63 0L432 289.94l41.37 41.37c6.25 6.25 16.38 6.25 22.63 0L507.31 320c6.25-6.25 6.25-16.38 0-22.63L465.94 256z"}));export{g as A,c as C,x as L,l as N,p as S,f as T,z as V,d as a,E as b,u as c,L as d,m as e,h as f,w as g,r as h,i as u,n as w};
@@ -1 +1 @@
1
- import{F as e,d as t,c as n,t as o,a as r,b as s,e as i,g as l,o as a,u as c,f as u}from"./userflow.js";import{i as f,a as d,b as m,p,c as h,s as w}from"./vendor.date-fns.js";class v extends Error{constructor(e,t){const n=`Unreachable case: ${e}`;super(t=t?`${t} (${n})`:n)}}const E=/(\\*)\{\{([a-zA-Z0-9_.]+)\}\}/g;function g(e,t){return(e||"").replace(E,((e,n,o)=>{const r=n.length;return r%2==0?"\\".repeat(r/2)+(t(o)||""):"\\".repeat((r-1)/2)+"{{"+o+"}}"}))}function y(e){let t=null;return n=>(t||(t=new Map,e.forEach((({name:e,value:n})=>t.set(e,Array.isArray(n)?n[0]:n)))),t.get(n)||null)}function b(e,t){const n=y(t);return g(e,(e=>n(e)))}function T(e,t){const n=S(e,t),o=e.nearSelector&&S(e.nearSelector,t);return e===n&&e.nearSelector===o?e:e.nearSelector===o?n:{...n,nearSelector:o}}function S(e,t){if(!e.text)return e;const n=b(e.text,t);return n===e.text?e:{...e,text:n}}function N(e){const t=function(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,n,o,r,,s,i]=t;return{scheme:n||"",domain:o||"",path:r||"",query:s||"",fragment:i||""}}(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:n,domain:o,path:r,query:s,fragment:i}=t;let l,a;l=n?L(n):"[a-z\\d]+",a=o?A(o,"[^/]","."):"[^/]*";let c,u,f;c=r?A(r,"[^?#]","/"):"/[^?#]*",s?(u="",new URLSearchParams(s).forEach(((e,t)=>{let n;n=""===e?"=?":"*"===e?"(=[^&#]*)?":"="+A(e,"[^#]"),u+="(?=.*[?&]"+L(t)+n+"([&#]|$))"})),u+="\\?[^#]*"):u="(\\?[^#]*)?",f=i?A(i,".","/"):"(#.*)?";return new RegExp("^"+l+"://"+a+"(:\\d+)?"+c+u+f+"$")}function A(e,t,n){return e=(e=L(e)).replace(/\\\*/g,t+"*"),n&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+n+"]+")),e}function L(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const x={[e.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const n=C(t),o=D(e.value,"00:00:00.000"),r=D(e.value,"23:59:59.999");return null!=n&&null!=o&&null!=r&&!f(n,o)&&!d(n,r)}},[e.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const n=C(t),o=D(e.value,"23:59:59.999");return null!=n&&null!=o&&d(n,o)}},[e.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const n=C(t),o=D(e.value,"00:00:00.000");return null!=n&&null!=o&&f(n,o)}},[e.AND]:{compare:()=>k("AND.compare")},[e.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(I(t))>=parseFloat(e.value)&&parseFloat(I(t))<=parseFloat(e.value2)},[e.CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&I(n).toLowerCase().includes(b(t.value||"",e).toLowerCase())},[e.EMPTY]:{compare:({value:e})=>null==e||""===e},[e.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&I(n).toLowerCase().endsWith(b(t.value||"",e).toLowerCase())},[e.EQ]:{compare:({sessionData:e,condition:t,value:n})=>b(t.value||"",e)===I(n)},[e.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return!(e.values||[]).some((e=>n.has(e)))}},[e.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return!(e.values||[]).every((e=>n.has(e)))}},[e.FALSE]:{compare:({value:e})=>"false"===I(e).toLowerCase()},[e.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))>parseFloat(e.value)},[e.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))>=parseFloat(e.value)},[e.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return(e.values||[]).every((e=>n.has(e)))}},[e.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return(e.values||[]).some((e=>n.has(e)))}},[e.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))<parseFloat(e.value)},[e.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))<=parseFloat(e.value)},[e.NE]:{compare:({sessionData:e,condition:t,value:n})=>b(t.value||"",e)!==I(n)},[e.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!n||!I(n).toLowerCase().includes(b(t.value||"",e).toLowerCase())},[e.NOT_EMPTY]:{compare:({value:e})=>null!=e&&""!==e},[e.NOT_REGEX]:{compare:({condition:e,value:t})=>!_(e,t)},[e.OR]:{compare:()=>k("OR.compare")},[e.REGEX]:{compare:({condition:e,value:t})=>_(e,t)},[e.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const n=C(t),o=M(e.value);return null!=n&&null!=o&&(!f(n,o)&&f(n,m(o,1)))}},[e.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const n=C(t),o=M(e.value);return null!=n&&null!=o&&d(n,o)}},[e.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const n=C(t),o=M(e.value);return null!=n&&null!=o&&f(n,o)}},[e.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&I(n).toLowerCase().startsWith(b(t.value||"",e).toLowerCase())},[e.TRUE]:{compare:({value:e})=>"true"===I(e).toLowerCase()},[e.URL]:{compare:({condition:e,value:t})=>{return!(!e.urlPattern||null==t)&&(n=e.urlPattern,o=I(t),(0!==n.includes.length||0!==n.excludes.length)&&(0===n.includes.length||n.includes.some((e=>{const t=N(e);return t&&o.match(t)})))&&!n.excludes.some((e=>{const t=N(e);return t&&o.match(t)})));var n,o}}};function k(e){throw new Error(`conditionOperators.${e} is not supported`)}function C(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=p(e);return h(t)?t:null}function D(e,t){if(!e)return null;const n=p(e+="T"+t+"Z");return h(n)?n:null}function M(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:w(Date.now(),t)}function _(e,t){if(!e.value)return!1;return new RegExp(e.value).test(I(t))}function I(e){return Array.isArray(e)?e[0]:null==e?"":e}function U(e){return Array.isArray(e)?e:""===e||null==e?[]:[e]}let R=window.MutationObserver;const O=window;if(O.Zone&&"function"==typeof O.Zone.__symbol__){const e=O.Zone.__symbol__("MutationObserver");e&&"string"==typeof e&&O.hasOwnProperty(e)&&"function"==typeof O[e]&&(R=O[e])}function F(e,t){const n=e.left,o=e.top,r=n+e.width,s=o+e.height,i=t.left,l=t.top;return function(e,t,n,o,r,s,i,l){const a=i<e,c=n<r,u=l<t,f=o<s;return f&&a?$(e,o,i,s):a&&u?$(e,t,i,l):u&&c?$(n,t,r,l):c&&f?$(n,o,r,s):a?e-i:c?r-n:u?t-l:f?s-o:0}(n,o,r,s,i,l,i+t.width,l+t.height)}function $(e,t,n,o){return Math.sqrt(Math.pow(n-e,2)+Math.pow(o-t,2))}function V(e){window.performance.mark&&window.performance.mark(e)}function B(e,t,n){window.performance.measure&&window.performance.measure(e,t,n)}function P(e){return W(),q(e)}let j;function q(e){return null==j&&(j=function(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&"1"!==e.zoom){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}()),1==j?e:e/j}function W(){j=null}function Y(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientWidth||window.innerWidth}function z(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientHeight||window.innerHeight}function G(e){return e?parseFloat(e.replace(/px$/,"")):0}const Z=new Set(["left","start","justify","justify-all"]);class X{constructor(e){this.ctx=e,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(e,t){const n=this.getRect(e),o=this.getRect(t),r=this.distBetween(e,t),s=ge(t)?100:50;if(r>s)return 0;const i=this.isLabelLike(e),l=this.isCloserToOtherInput(e,t),a=window.getComputedStyle(e).textAlign||"",c=n.top+n.height<=o.top,u=Math.abs(n.left-o.left)<25&&(!a||Z.has(a)),f=n.left+n.width<=o.left,d=Math.abs(n.top-o.top)<25,m=c&&u||f&&d,p=n.height>=z()/2,h=be(t);if(h&&n.top>=o.top+o.height)return 0;let w=1;const v=e.htmlFor;return v&&v===t.id&&(w+=Math.pow(1e3,4)),!h||p||l||(i&&m?w+=Math.pow(1e3,3):t===e&&this.hasPlaceholder(t)?w+=Math.pow(1e3,2):!i&&m&&(w+=Math.pow(1e3,1))),w+=s-r,w}getRect(e){let t=this.rectCache.get(e);return t||(t=Le(e),this.rectCache.set(e,t)),t}isLabelLike(e){let t=this.isLabelLikeCache.get(e);if(void 0===t){const n="a, button, h1, h2, h3, h4, h5, h6, input";t=!e.closest(n)&&!e.querySelector(n),this.isLabelLikeCache.set(e,t)}return t}hasPlaceholder(e){let t=this.hasPlaceholderCache.get(e);return void 0===t&&(t=!!fe(e),this.hasPlaceholderCache.set(e,t)),t}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(he())).filter((e=>Te(e,this.ctx)))),this.allInputs}distBetween(e,t){return Math.round(F(this.getRect(e),this.getRect(t)))}isCloserToOtherInput(e,t){let n=this.distBetween(e,t);for(let o of this.getAllInputs()){if(o===t)continue;if(this.distBetween(e,o)<n)return!0}return!1}}function H(e,n={}){const o=performance.now();let i;V("userflow:inferSelector:start"),t.groupCollapsed("inferSelector for",e,n);try{i=function(e,{elementType:n}={}){const o={minorVersion:K};let i=be(e);const l=function(e){let t=e.parentNode;for(;t&&"BODY"!==t.tagName&&!Ce(t);){if(ye(t))return t;t=t.parentNode}return null}(e);if(n!==r.INPUT||i)l&&(e=l,i=!0);else{if(!l)return t("not an input"),null;e=l,i=!0,t("use custom input parent",l)}const a=function(e){let t=[],n=e;for(;n;){let e=n.getRootNode();if(Ce(e)){const{host:o}=e;t.unshift(o.tagName.toLowerCase()),n=o;continue}const o=ke(n);if(!o)break;{let e=o.tagName.toLowerCase();const r=o.getAttribute("name");r?e+=`[name="${r}"]`:o.id&&!o.id.match(/\d$/)&&(e+="#"+o.id),t.unshift(e),n=o}}if(0===t.length)return;return t}(e);let c=null;i||(c=ue(e),c&&c.length>250&&(c=null));t("text is:"+c);let u=new Map,f=new Map;const d=new Map,m=new J(a,null,o),p=new J(a,c,o),h=(e,n,o,r,s)=>{if(r<0)return;let i=e.get(n);i||(i=[],e.set(n,i)),i.push({css:o,offset:r,complexity:s}),t(`use css=${o}, cardinality=${n}, offset=${r}`)},w=function(e){const t=new Map;t.set(null,0);let n=e.parentNode;for(;n&&"BODY"!==n.tagName&&!Ce(n);){for(const e of Q(n)){if(t.has(e))continue;const n=se(document.body,e);if(n){const o=n.length;t.set(e,o)}}n=n.parentNode}const o=20;return Array.from(t.entries()).sort((([,e],[,t])=>e-t)).slice(0,o).map((([e])=>e))}(e),v=[e.tagName.toLowerCase(),...Q(e)];t("shadowRootSelectors:",a),t("ancestorCssSelectors:",w),t("ownCssSelectors:",v);for(const r of v)for(const n of w){const o=n?`${n} ${r}`:r,s=n?2:1,i=m.query(o),l=Array.from(i),a=l.length;if(a>100){t(`cardinality too high css=${o}, cardinality=${a}`);continue}d.set(o,a);if(h(u,a,o,l.indexOf(e),s),c){const t=p.query(o),n=Array.from(t),r=n.indexOf(e);h(f,n.length,o,r,s)}}if(u.size>0||f.size>0){const r=e=>Array.from(e.entries()).map((([e,t])=>({cardinality:e,cssSelectors:t.sort(((e,t)=>{const n=d.get(e.css),o=d.get(t.css);return n!==o?n?o?n-o:-1:1:e.complexity!==t.complexity?t.complexity-e.complexity:e.css.localeCompare(t.css)})).map((({css:e,offset:t})=>({css:e,offset:t})))}))).sort(((e,t)=>e.cardinality-t.cardinality)),i={version:"v1",minorVersion:o.minorVersion,shadowRootSelectors:a,notextGroups:r(u),textGroups:r(f)},l={el:e,selector:{type:s.AUTO,autoData:JSON.stringify(i),text:c,elementType:n}};return t("inference result",l),l}return t("no selector inferred "),null}(e,n)}catch(l){console.error("Userflow findElement error:",l),i=null}return t("time",performance.now()-o),t.groupEnd(),V("userflow:inferSelector:end"),B("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),i}function Q(e){const t=[],r=e.tagName.toLowerCase();return n.inferenceAttributeNames.forEach((s=>{const i=e.getAttribute(s);if(!i)return;const l=n.inferenceAttributeFilters[s];if(!l||o(l,i))if("id"===s)t.push(`#${e.id}`);else{const e="name"===s||"placeholder"===s?r:"";t.push(`${e}[${s}="${i}"]`)}})),e.classList.forEach((e=>{o(n.inferenceClassNameFilters,e)&&t.push(`.${e.trim()}`)})),t}(window.userflow||{}).__inferSelector=H;class J{constructor(e,t,n){this.shadowRootSelectors=e,this.text=t,this.ctx=n,this.isVisibleCache=new Map,this.textCache=new Map}*query(e){const n=se(document.body,e,this.shadowRootSelectors);if(t("found",n),!n)return;const{text:o}=this;for(let r=0;r<n.length;r++){const e=n[r];if(o){let n=this.textCache.get(e);if(null==n&&(n=de(e,o),this.textCache.set(e,n)),!n){t("skip, text mismatch",e);continue}}let s=this.isVisibleCache.get(e);null==s&&(s=Te(e,this.ctx),this.isVisibleCache.set(e,s)),s?(t("yield",e),yield e):t("skip, not visible",e)}}}const K=4,ee=window.userflow||{};function te(e){const n=performance.now();let o;V("userflow:findAllElements:start"),t.groupCollapsed("findAllElements",e);try{if(e.type===s.MANUAL)o=function(e){const n={minorVersion:null==e.minorVersion?1:e.minorVersion};let{css:o,text:s,elementType:i,offset:l}=e;s=s&&me(s);const a="nearSelector"in e?e.nearSelector:null;t("findAllElementsManual",e),null!=l&&null!=a&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let c;if(s&&!o){if(c=[],n.minorVersion>=2)for(const e of Re())re(e,s,c);else re(document.body,s,c);t("els after traverseElementForText",c)}else if(o){if(n.minorVersion>=2){c=[];for(const e of Re()){const t=se(e,o);t&&t.length>0&&c.push(...t)}}else c=Array.from(se(document.body,o)||[]);t("els after safeQueryAll",c),s&&(c=function(e,t){const n=[];for(let o=e.length-1;o>=0;o--){const r=e[o];n.some((e=>e.contains(r)))||de(r,t)&&n.push(r)}return n.reverse()}(c,s),t("els after filterElementsByText",c))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),c=[];c.length>0&&(c=c.filter((e=>Te(e,n))),t("els after isVisible",c));c.length>0&&i===r.INPUT&&(c=function(e,n){const o=new Set,r=new X(n),s=he();for(const i of e){if(i.matches(s)){o.add(i);continue}let e=null,n=null;r.getAllInputs().forEach((o=>{const s=r.calcScore(i,o);t("input",s,o),0!==s&&(e&&n&&s<=n||(t("input is best so far"),e=o,n=s))})),e&&(t("best input was",e),o.add(e))}return Array.from(o)}(c,n),t("els after mapElementsToInputs",c));c.length>0&&(c.sort(((e,t)=>{const n=Le(e),o=Le(t);return n.top<o.top?-1:n.top>o.top?1:n.left-o.left})),t("els after sort",c));if(c.length>0)if(null!=l)c=c[l]?[c[l]]:[],t("els after offset",c);else if(null!=a){const e=te(a);let n=null,o=0;for(const t of c)for(const r of e){const e=F(Le(t),Le(r));(!n||e<o)&&(n=t,o=e)}c=n?[n]:[],t("els after nearSelector",c)}return c}(e);else if(e.autoData){const n=JSON.parse(e.autoData);let r;if("v1"!==n.version)throw new v(n.version,"Unknown autoData version: "+n.version);r=function(e,n){const{text:o,excludeText:r,precision:s}=e,i={minorVersion:n.minorVersion||0},l=null!=o&&!r,a=l?n.textGroups:n.notextGroups,c=Math.max(1,Math.min(a.length,Math.ceil((1-parseFloat(s||"1"))*a.length))),u=new J(n.shadowRootSelectors,l&&o||null,i);t("findElementAutoV1",{text:o,excludeText:r,precision:s,groups:a,groupCount:c});for(let f=0;f<c;f++){const e=a[f];let n=new Map,o=0,r=null;t.group(`group cardinality=${e.cardinality}`,e);try{for(let s=0;s<e.cssSelectors.length;s++){const{css:i,offset:l}=e.cssSelectors[s];t(`css=${i}, offset=${l}`);let a=u.query(i),c=null;for(let e=0;e<=l;e++){const e=a.next();if(e.done)break;c=e.value}if(!c)continue;const f=(n.get(c)||0)+1;if(n.set(c,f),t(`el with frequency=${f}`+(f>o&&c!==r?" NEW BEST":""),c),f>o&&(o=f,r=c,f>=Math.ceil(e.cssSelectors.length/2)))return t("early winner",r),r}}finally{t.groupEnd()}if(r)return t("winner",r),r}return t("element not found"),null}(e,n),o=r?[r]:[]}else o=[]}catch(i){console.error("Userflow findElement error:",i),o=[]}return t("time",performance.now()-n),t.groupEnd(),V("userflow:findAllElements:end"),B("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),o}function ne(e){return te(e)[0]||null}function oe(e,n){const o=performance.now();let r;V("userflow:elementMatchesSelector:start"),t.groupCollapsed("elementMatchesSelector",e,n);try{if(n.type===s.MANUAL)r=function(e,t){null!=t.offset&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet");"nearSelector"in t&&null!=t.nearSelector&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:n,text:o}=t;o=o&&me(o);let r=!1,s=e;for(;s&&"BODY"!==s.tagName;){if((!n||s.matches(n))&&(!o||de(s,o))){r=!0;break}s=s.parentElement}return r}(e,n);else{const t=ne(n);r=null!=t&&t.contains(e)}}catch(i){console.error("Userflow findElement error:",i),r=!1}return t(r?"match":"not match"),t("time",performance.now()-o),t.groupEnd(),V("userflow:elementMatchesSelector:end"),B("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),r}function re(e,t,n){if(De(e)){const{tagName:t}=e;if("SCRIPT"===t||"STYLE"===t)return!1}let o=!1;for(let r=0;r<e.children.length;r++)re(e.children[r],t,n)&&(o=!0);return!o&&De(e)&&de(e,t)&&(n.push(e),o=!0),o}function se(e,t,n){try{if(null==n)return e.querySelectorAll(t);return ie(t,n,0,e)}catch(o){return console.warn("Userflow.js: Invalid CSS selector: ",t),null}}function ie(e,t,n,o){if(n>=t.length)return Array.from(o.querySelectorAll(e));const r=t[n],s=o.querySelectorAll(r),i=[];return s.forEach((o=>{let r;if(o.shadowRoot)r=o.shadowRoot;else{if(!Me(o))return;let e=null;try{e=o.contentDocument}catch(s){}if(!e)return;r=e.body}i.push(...ie(e,t,n+1,r))})),i}const le={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},ae={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},ce={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function ue(e){let t=e.innerText;return void 0===t&&"SELECT"!==e.tagName&&(t=e.textContent),t=me(t),t||null}function fe(e){if(we(e)||ve(e)){const t=me(e.getAttribute("placeholder")),n=e.value||"";if(t&&!n)return t;const o=me(n);if(o&&function(e){if(ve(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return ce[t]}(e))return o}if(Ee(e)&&e.selectedIndex>=0){const t=me(e.options[e.selectedIndex].text);if(t)return t}return ue(e)}function de(e,t){const n=fe(e);return!!n&&function(e,t){const n=e.toLowerCase();if(t.toLowerCase()===n)return!0;return!1}(t,n)}function me(e){return e?e.length>250?null:e.replace(/^[\s\uFEFF\xA0*]+|[\s\uFEFF\xA0*]+$/g,"").replace(/\s+/g," "):null}function pe(e){for(const{cssSelector:o,getValue:r}of n.customInputs)if(e.matches(o)){if(!r)return fe(e)||"";try{return(r(e)||"").trim()}catch(t){return console.error(`Userflow.js: getValue function for custom input '${o}' failed:`,t),""}}return Ee(e)?-1==e.selectedIndex?"":e.options[e.selectedIndex].text:ge(e)?fe(e)||"":e.value}function he(){return"input, select, textarea, [contenteditable]"+n.customInputs.map((({cssSelector:e})=>`, ${e}`)).join("")}function we(e){if("INPUT"!==e.tagName)return!1;const t=e.getAttribute("type");return null==t||!0===le[(t||"").toLowerCase()]}function ve(e){return"TEXTAREA"===e.tagName}function Ee(e){return"SELECT"===e.tagName}function ge(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function ye(e){return!!ge(e)||!!n.customInputs.some((({cssSelector:t})=>e.matches(t)))}function be(e){return we(e)||function(e){if("INPUT"!==e.tagName)return!1;const t=(e.getAttribute("type")||"").toLowerCase();return!0===ae[t]}(e)||ve(e)||Ee(e)||ye(e)}function Te(e,n){const o=Le(e);let r=e,s=!0,i=!1,l=!1,a=!1,c=!1;for(;r;){const u=r===document.body,f="BODY"===r.tagName,d=window.getComputedStyle(r);let m=null;if(s){if(d.visibility&&"visible"!==d.visibility)return t("not visible because visibility is",d.visibility,e,{cur:r}),!1;s=!1}if("none"===d.display)return t("not visible because display is",d.display,e,{cur:r}),!1;if(null!=d.opacity&&parseFloat(d.opacity)<.01)return t("not visible because opacity is",d.opacity,e,{cur:r}),!1;if("absolute"===d.position?a=!0:"relative"!==d.position&&"fixed"!==d.position&&"sticky"!==d.position||(a=!1),n.minorVersion>=4&&!i&&!f&&(!c||"static"!==d.position)&&(Se(d.overflowX)||Se(d.overflowY))&&(m=m||Le(r),0===m.width||0===m.height))return t("not visible because width/height (v1.4 check) is",m.width,m.height,e,{cur:r}),!1;if(!l&&Ne(d.display)&&(n.minorVersion<1||f||"static"!==d.position)){const n=f||Se(d.overflow),s=n||Se(d.overflowX),i=n||Se(d.overflowY),{scrollLeft:c,scrollTop:u}=f?r.ownerDocument.documentElement:r,p=!f&&!a;if(s){if(m=m||Le(r),p&&0===m.width)return t("not visible because width is",m.width,e,{cur:r}),!1;const n=Math.round(m.left-c);if(Math.round(o.left)<n)return t("not visible because it's clipped left",e,{left:n,cur:r}),!1}if(i){if(m=m||Le(r),p&&0===m.height)return t("not visible because height is",m.height,e,{cur:r}),!1;const n=Math.round(m.top-u);if(Math.round(o.top)<n)return t("not visible because it's clipped top",e,{top:n,cur:r}),!1}(s||i)&&(l=!0)}if("fixed"===d.position&&(i=!0,l=!0),n.minorVersion>=3&&(r.scrollTop>0||r.scrollLeft>0)&&(l=!0),u)break;f?(r=ke(r),s=!0):r=r.parentElement,c=a}return!0}function Se(e){return"hidden"===e||"clip"===e||"scroll"===e||"auto"===e}function Ne(e){return!e||!e.includes("inline")&&"contents"!==e}function Ae(e){let t=e.parentNode,n=!1;for(;t&&"BODY"!==t.tagName;){Ce(t)&&(t=t.host);const o=window.getComputedStyle(t);if("absolute"===o.position?n=!0:"relative"!==o.position&&"fixed"!==o.position&&"sticky"!==o.position||(n=!1),!n&&Ne(o.display)&&(Se(o.overflow)||Se(o.overflowY)))return t;if("fixed"===o.position)return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function Le(e){if("HTML"===e.tagName){const t=ke(e);if(t)return Le(t)}let t=e.getBoundingClientRect(),n=e;for(;n&&(n=ke(n),n);){const e=n.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+e.left,right:t.right+e.left,top:t.top+e.top,bottom:t.bottom+e.top}}return t}const xe=new WeakSet;function ke(e){const t=e.ownerDocument?.defaultView;if(!t)return null;if(xe.has(t))return null;{const e=t.frameElement;return e||xe.add(t),e}}function Ce(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function De(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Me(e){return De(e)&&"IFRAME"===e.tagName}ee.__findElement=ne,ee.__findAllElements=te,ee.__elementMatchesSelector=oe,ee.__getElementText=fe,ee.__getInputValue=pe;const _e=new Set,Ie=new Map,Ue=new Set;function Re(){return $e(),_e}function Oe(e,t){$e();for(const o of _e)e(o);const n={setup:e,teardown:t};return Ue.add(n),()=>{Ue.delete(n);for(const e of _e)t(e)}}let Fe=!1;function $e(){Ve(),Fe||(t("roots started"),Fe=!0,Pe(document.body),window.setInterval(Ve,1e4))}function Ve(){for(const e of _e)Ce(e)&&(Be(e)||(t("roots clean before removeRoot",e),je(e)));t("roots clean finished, remaining=",_e.size)}function Be(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if(Ce(t)&&(t=t.host),De(t)&&"BODY"===t.tagName)return!0;t=t.parentNode}return!1}function Pe(e){if(!_e.has(e)){t("roots addRoot",e),_e.add(e),function(e){let t;const n=()=>{qe(e)},o=new R((()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));o.observe(e,{childList:!0,subtree:!0}),Ie.set(e,o)}(e),qe(e),function(e){const n=e.ownerDocument.defaultView;if(n.__userflowAttachShadowInstalled)return;n.__userflowAttachShadowInstalled=!0;const o=n.Element.prototype.attachShadow;null!=o&&(n.Element.prototype.attachShadow=function(e){const n=o.call(this,e);return this.shadowRoot&&(t("roots monitorShadowDom before addRoot",this,this.shadowRoot),Pe(this.shadowRoot)),n})}(e),function(e){const n=e=>{e.childNodes.forEach((e=>{De(e)&&e.shadowRoot&&(t("roots queryShadowDom before addRoot",e,e.shadowRoot),Pe(e.shadowRoot)),n(e)}))};n(e)}(e);for(const{setup:t}of Ue)t(e)}}function je(e){if(_e.has(e)){t("roots removeRoot",e),Ie.get(e)?.disconnect(),Ie.delete(e),_e.delete(e);for(const{teardown:t}of Ue)t(e)}}function qe(e){const t=De(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const n of t)Ye(n)}const We=new WeakSet;function Ye(e){if(We.has(e))return;if(e.closest("#userflow-ui"))return;e.addEventListener("load",ze);const n=e.contentWindow,o=e.contentDocument;if(!n||!o)return void We.add(e);const r=o.body;r&&(n.addEventListener("unload",Ge),t("roots setupFrame before addRoot",e,o,r),Pe(r))}function ze(e){const t=e.target;t&&Me(t)&&Ye(t)}function Ge(e){const n=e.currentTarget.document.body;t("roots onFrameUnload before removeRoot",n),je(n)}function Ze(e,t={}){let n,o;const r=()=>{o=void 0,e()},s=()=>{if(window.clearTimeout(n),null==o)o=Date.now();else if(Date.now()-o>1e3)return void r();n=window.setTimeout(r,50)},i=e=>{const t=e.target;if(!t||!Xe(t))return;const n=document.getElementById("userflow-ui");n&&n.contains(t)||s()},l=new R((e=>{(function(e){const t=document.getElementById("userflow-ui");for(const n of e){const{target:e}=n;if(Xe(e)&&(t&&t.contains(e)))return!0}return!1})(e)||s()})),a=Oe((e=>{l.observe(e,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),e.addEventListener("animationend",i),e.addEventListener("transitionend",i),t.observeInput&&(e.addEventListener("input",s),e.addEventListener("change",s))}),(e=>{e.removeEventListener("animationend",i),e.removeEventListener("transitionend",i),t.observeInput&&(e.removeEventListener("input",s),e.removeEventListener("change",s))}));return{disconnect:()=>{window.clearTimeout(n),l.disconnect(),a()}}}function Xe(e){return e.nodeType===Node.ELEMENT_NODE}const He={[i.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[i.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(e&&t.operator){const n=e.value.find((e=>e.name===t.attributeName)),r=n?n.value:null;o=x[t.operator].compare({sessionData:e.value,condition:t,value:r})}n(o)};o();const r=e.observe(o);return()=>{r()}}},[i.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const e=He[t.type];if(e.isExpensive&&e.isExpensive(t))return!0}return!1},track:({sessionData:t,condition:n,flipBackEvents:o,callback:r})=>{let s,i,l=null;const a=n.conditions.map((e=>{const t=He[e.type];return{condition:e,typeDef:t,expensive:!!t.isExpensive&&t.isExpensive(e),active:!1,isTrue:null}})),c=e=>{for(const n of a){const r=!o||!n.expensive||e;r&&!n.active?(n.active=!0,n.isTrue=!1,n.untrack=n.typeDef.track({sessionData:t,condition:n.condition,flipBackEvents:o,callback:(e,t={})=>{n.isTrue=e,window.clearTimeout(s),t.immediate?u({immediate:!0}):s=window.setTimeout(u,0)}})):!r&&n.active&&(n.untrack&&n.untrack(),n.active=!1,n.isTrue=null,n.untrack=void 0)}},u=(t={})=>{if(0===a.length)return void f(!1,t);let o,r;if(n.operator===e.AND){o=!0,r=!0;for(const e of a)!1===e.isTrue?(o=!1,e.expensive||(r=!1)):!1!==o&&null===e.isTrue&&(o=null)}else{o=!1,r=!0;for(const e of a)!0===e.isTrue?(o=!0,e.expensive||(r=!1)):!0!==o&&null===e.isTrue&&(o=null)}null!==o&&o!==l&&(l=o,f(o,t)),c(r)},f=(e,t)=>{if(e&&null!=n.waitTime&&"0"!=n.waitTime){if(!i){const e=1e3*parseFloat(n.waitTime);i=window.setTimeout((()=>{r(!0,{})}),e)}}else window.clearTimeout(i),i=void 0,r(e,t)};return c(!1),u(),()=>{window.clearTimeout(s),window.clearTimeout(i);for(const e of a)e.untrack&&e.untrack()}}},[i.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const n=function(e){switch(e){case u.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case u.DISABLED:return{kind:"observer",checkElement:e=>!!e&&e.disabled};case u.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case u.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case u.NOT_DISABLED:return{kind:"observer",checkElement:e=>!!e&&!e.disabled};case u.NOT_PRESENT:return{kind:"observer",checkElement:e=>!e};case u.PRESENT:return{kind:"observer",checkElement:e=>!!e}}}(t);switch(n.kind){case"observer":return function({sessionData:e,condition:t,callback:n},o){const r=()=>{if(!t.elementState)return void console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);if(!t.selector)return void console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);let r=!1;const s=te(T(t.selector,e.value));if(s.length>0){for(const e of s)if(o(e)){r=!0;break}}else o(null)&&(r=!0);n(r)};r();const s=e.observe(r),{disconnect:i}=Ze(r);return()=>{s(),i()}}(e,n.checkElement);case"event":return function({condition:e,flipBackEvents:t,callback:n},o,r){const{selector:s}=e;if(!s)return()=>{};let i;n(!r);const l=e=>{const o=e.target;o&&oe(o,s)&&(t?(n(r,{immediate:!0}),n(!r,{immediate:!0})):n(r))},a={capture:!0},c=Oe((e=>e.addEventListener(o,l,a)),(e=>e.removeEventListener(o,l,a)));return()=>{c(),window.clearTimeout(i)}}(e,n.eventName,n.valueWhenOccurred)}}},[i.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{let o,r=null;const s=()=>{if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);const s=te(T(t.selector,e.value));let i=null;for(const e of s){const t=pe(e);if(t){i=t;break}}i?i!=r&&(window.clearTimeout(o),o=window.setTimeout((()=>{n(!0)}),1e3)):(n(!1),window.clearTimeout(o)),r=i};s();const i=e.observe(s),{disconnect:l}=Ze(s,{observeInput:!0});return()=>{i(),l(),window.clearTimeout(o)}}},[i.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[i.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{if(!t.operator)return void console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);let o=!1;const r=x[t.operator],s=te(T(t.selector,e.value));if(s.length>0)for(const n of s){const s=pe(n);if(r.compare({sessionData:e.value,condition:t,value:s})){o=!0;break}}else r.compare({sessionData:e.value,condition:t,value:""})&&(o=!0);n(o)};o();const r=e.observe(o),{disconnect:s}=Ze(o,{observeInput:!0});return()=>{r(),s()}}},[i.PAGE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(t.operator){const n=l();o=x[t.operator].compare({sessionData:e.value,condition:t,value:n})}n(o)};let r=l();const s=()=>{const e=l();e!==r&&(r=e,o())};a(s),o();const i=e.observe(o);return()=>{i(),c(s)}}},[i.TIME]:{track:({condition:e,callback:t})=>{let n=null;const o=e.value?new Date(e.value):null,r=e.value2?new Date(e.value2):null,s=()=>{let e=!0;(o&&!isNaN(o.valueOf())&&Date.now()<o.valueOf()||r&&!isNaN(r.valueOf())&&Date.now()>=r.valueOf())&&(e=!1),e!==n&&(n=e,t(e))};s();const i=window.setInterval(s,1e4);return()=>{window.clearInterval(i)}}}};var Qe=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",conditionTypes:He});export{R as M,y as a,g as b,He as c,Y as d,q as e,Ce as f,z as g,W as h,b as i,De as j,ke as k,H as l,G as m,T as n,Oe as o,Ze as p,ne as q,Le as r,Ae as s,Me as t,Qe as u,P as z};
1
+ import{F as e,d as t,c as n,t as o,a as r,b as s,e as i,g as l,o as a,u as c,f as u}from"./userflow.js";import{i as f,a as d,b as m,p,c as h,s as w}from"./vendor.date-fns.js";class v extends Error{constructor(e,t){const n=`Unreachable case: ${e}`;super(t=t?`${t} (${n})`:n)}}const E=/(\\*)\{\{([a-zA-Z0-9_.]+)\}\}/g;function g(e,t){return(e||"").replace(E,((e,n,o)=>{const r=n.length;return r%2==0?"\\".repeat(r/2)+(t(o)||""):"\\".repeat((r-1)/2)+"{{"+o+"}}"}))}function y(e){let t=null;return n=>(t||(t=new Map,e.forEach((({name:e,value:n})=>t.set(e,Array.isArray(n)?n[0]:n)))),t.get(n)||null)}function b(e,t){const n=y(t);return g(e,(e=>n(e)))}function T(e,t){const n=S(e,t),o=e.nearSelector&&S(e.nearSelector,t);return e===n&&e.nearSelector===o?e:e.nearSelector===o?n:{...n,nearSelector:o}}function S(e,t){if(!e.text)return e;const n=b(e.text,t);return n===e.text?e:{...e,text:n}}function L(e){const t=function(e){const t=e.match(/^(([a-z\d]+):\/\/)?([^/?#]+)?(\/[^?#]*)?(\?([^#]*))?(#.*)?$/i);if(!t)return null;const[,,n,o,r,,s,i]=t;return{scheme:n||"",domain:o||"",path:r||"",query:s||"",fragment:i||""}}(e);if(!t)return console.error("Userflow: Invalid URL pattern:",e),null;const{scheme:n,domain:o,path:r,query:s,fragment:i}=t;let l,a;l=n?A(n):"[a-z\\d]+",a=o?N(o,"[^/]","."):"[^/]*";let c,u,f;c=r?N(r,"[^?#]","/"):"/[^?#]*",s?(u="",new URLSearchParams(s).forEach(((e,t)=>{let n;n=""===e?"=?":"*"===e?"(=[^&#]*)?":"="+N(e,"[^#]"),u+="(?=.*[?&]"+A(t)+n+"([&#]|$))"})),u+="\\?[^#]*"):u="(\\?[^#]*)?",f=i?N(i,".","/"):"(#.*)?";return new RegExp("^"+l+"://"+a+"(:\\d+)?"+c+u+f+"$")}function N(e,t,n){return e=(e=A(e)).replace(/\\\*/g,t+"*"),n&&(e=e.replace(/:[a-zA-Z0-9_]+/g,"[^"+n+"]+")),e}function A(e){return e.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}const x={[e.ABSOLUTE_EQ]:{compare:({condition:e,value:t})=>{const n=C(t),o=D(e.value,"00:00:00.000"),r=D(e.value,"23:59:59.999");return null!=n&&null!=o&&null!=r&&!f(n,o)&&!d(n,r)}},[e.ABSOLUTE_GT]:{compare:({condition:e,value:t})=>{const n=C(t),o=D(e.value,"23:59:59.999");return null!=n&&null!=o&&d(n,o)}},[e.ABSOLUTE_LT]:{compare:({condition:e,value:t})=>{const n=C(t),o=D(e.value,"00:00:00.000");return null!=n&&null!=o&&f(n,o)}},[e.AND]:{compare:()=>k("AND.compare")},[e.BETWEEN]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&!!e.value2&&parseFloat(I(t))>=parseFloat(e.value)&&parseFloat(I(t))<=parseFloat(e.value2)},[e.CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&I(n).toLowerCase().includes(b(t.value||"",e).toLowerCase())},[e.EMPTY]:{compare:({value:e})=>null==e||""===e},[e.ENDS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&I(n).toLowerCase().endsWith(b(t.value||"",e).toLowerCase())},[e.EQ]:{compare:({sessionData:e,condition:t,value:n})=>b(t.value||"",e)===I(n)},[e.EXCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return!(e.values||[]).some((e=>n.has(e)))}},[e.EXCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return!(e.values||[]).every((e=>n.has(e)))}},[e.FALSE]:{compare:({value:e})=>"false"===I(e).toLowerCase()},[e.GT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))>parseFloat(e.value)},[e.GTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))>=parseFloat(e.value)},[e.INCLUDES_ALL]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return(e.values||[]).every((e=>n.has(e)))}},[e.INCLUDES_ANY]:{compare:({condition:e,value:t})=>{const n=new Set(U(t));return(e.values||[]).some((e=>n.has(e)))}},[e.LT]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))<parseFloat(e.value)},[e.LTE]:{compare:({condition:e,value:t})=>!!t&&!!e.value&&parseFloat(I(t))<=parseFloat(e.value)},[e.NE]:{compare:({sessionData:e,condition:t,value:n})=>b(t.value||"",e)!==I(n)},[e.NOT_CONTAINS]:{compare:({sessionData:e,condition:t,value:n})=>!n||!I(n).toLowerCase().includes(b(t.value||"",e).toLowerCase())},[e.NOT_EMPTY]:{compare:({value:e})=>null!=e&&""!==e},[e.NOT_REGEX]:{compare:({condition:e,value:t})=>!_(e,t)},[e.OR]:{compare:()=>k("OR.compare")},[e.REGEX]:{compare:({condition:e,value:t})=>_(e,t)},[e.RELATIVE_EQ]:{compare:({condition:e,value:t})=>{const n=C(t),o=M(e.value);return null!=n&&null!=o&&(!f(n,o)&&f(n,m(o,1)))}},[e.RELATIVE_GT]:{compare:({condition:e,value:t})=>{const n=C(t),o=M(e.value);return null!=n&&null!=o&&d(n,o)}},[e.RELATIVE_LT]:{compare:({condition:e,value:t})=>{const n=C(t),o=M(e.value);return null!=n&&null!=o&&f(n,o)}},[e.STARTS_WITH]:{compare:({sessionData:e,condition:t,value:n})=>!!n&&I(n).toLowerCase().startsWith(b(t.value||"",e).toLowerCase())},[e.TRUE]:{compare:({value:e})=>"true"===I(e).toLowerCase()},[e.URL]:{compare:({condition:e,value:t})=>{return!(!e.urlPattern||null==t)&&(n=e.urlPattern,o=I(t),(0!==n.includes.length||0!==n.excludes.length)&&(0===n.includes.length||n.includes.some((e=>{const t=L(e);return t&&o.match(t)})))&&!n.excludes.some((e=>{const t=L(e);return t&&o.match(t)})));var n,o}}};function k(e){throw new Error(`conditionOperators.${e} is not supported`)}function C(e){if(Array.isArray(e)&&(e=e[0]),!e)return null;e.match(/(Z|((\+|-)\d\d:\d\d))$/i)||(e+="Z");const t=p(e);return h(t)?t:null}function D(e,t){if(!e)return null;const n=p(e+="T"+t+"Z");return h(n)?n:null}function M(e){if(!e)return null;const t=parseInt(e,10);return isNaN(t)?null:w(Date.now(),t)}function _(e,t){if(!e.value)return!1;return new RegExp(e.value).test(I(t))}function I(e){return Array.isArray(e)?e[0]:null==e?"":e}function U(e){return Array.isArray(e)?e:""===e||null==e?[]:[e]}let R=window.MutationObserver;const O=window;if(O.Zone&&"function"==typeof O.Zone.__symbol__){const e=O.Zone.__symbol__("MutationObserver");e&&"string"==typeof e&&O.hasOwnProperty(e)&&"function"==typeof O[e]&&(R=O[e])}function F(e,t){const n=e.left,o=e.top,r=n+e.width,s=o+e.height,i=t.left,l=t.top;return function(e,t,n,o,r,s,i,l){const a=i<e,c=n<r,u=l<t,f=o<s;return f&&a?$(e,o,i,s):a&&u?$(e,t,i,l):u&&c?$(n,t,r,l):c&&f?$(n,o,r,s):a?e-i:c?r-n:u?t-l:f?s-o:0}(n,o,r,s,i,l,i+t.width,l+t.height)}function $(e,t,n,o){return Math.sqrt(Math.pow(n-e,2)+Math.pow(o-t,2))}function V(e){window.performance.mark&&window.performance.mark(e)}function B(e,t,n){window.performance.measure&&window.performance.measure(e,t,n)}function P(e){return W(),q(e)}let j;function q(e){return null==j&&(j=function(){const e=window.getComputedStyle(window.document.body);if(e.zoom&&"1"!==e.zoom){const t=parseFloat(e.zoom);if(!isNaN(t))return t}return 1}()),1==j?e:e/j}function W(){j=null}function Y(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientWidth||window.innerWidth}function z(){return("BackCompat"==document.compatMode?document.body:document.documentElement).clientHeight||window.innerHeight}function G(e){return e?parseFloat(e.replace(/px$/,"")):0}const Z=new Set(["left","start","justify","justify-all"]);class X{constructor(e){this.ctx=e,this.rectCache=new Map,this.isLabelLikeCache=new Map,this.hasPlaceholderCache=new Map}calcScore(e,t){const n=this.getRect(e),o=this.getRect(t),r=this.distBetween(e,t),s=ge(t)?100:50;if(r>s)return 0;const i=this.isLabelLike(e),l=this.isCloserToOtherInput(e,t),a=window.getComputedStyle(e).textAlign||"",c=n.top+n.height<=o.top,u=Math.abs(n.left-o.left)<25&&(!a||Z.has(a)),f=n.left+n.width<=o.left,d=Math.abs(n.top-o.top)<25,m=c&&u||f&&d,p=n.height>=z()/2,h=be(t);if(h&&n.top>=o.top+o.height)return 0;let w=1;const v=e.htmlFor;return v&&v===t.id&&(w+=Math.pow(1e3,4)),!h||p||l||(i&&m?w+=Math.pow(1e3,3):t===e&&this.hasPlaceholder(t)?w+=Math.pow(1e3,2):!i&&m&&(w+=Math.pow(1e3,1))),w+=s-r,w}getRect(e){let t=this.rectCache.get(e);return t||(t=Ae(e),this.rectCache.set(e,t)),t}isLabelLike(e){let t=this.isLabelLikeCache.get(e);if(void 0===t){const n="a, button, h1, h2, h3, h4, h5, h6, input";t=!e.closest(n)&&!e.querySelector(n),this.isLabelLikeCache.set(e,t)}return t}hasPlaceholder(e){let t=this.hasPlaceholderCache.get(e);return void 0===t&&(t=!!fe(e),this.hasPlaceholderCache.set(e,t)),t}getAllInputs(){return this.allInputs||(this.allInputs=Array.from(document.querySelectorAll(he())).filter((e=>Te(e,this.ctx)))),this.allInputs}distBetween(e,t){return Math.round(F(this.getRect(e),this.getRect(t)))}isCloserToOtherInput(e,t){let n=this.distBetween(e,t);for(let o of this.getAllInputs()){if(o===t)continue;if(this.distBetween(e,o)<n)return!0}return!1}}function H(e,n={}){const o=performance.now();let i;V("userflow:inferSelector:start"),t.groupCollapsed("inferSelector for",e,n);try{i=function(e,{elementType:n}={}){const o={minorVersion:K};let i=be(e);const l=function(e){let t=e.parentNode;for(;t&&"BODY"!==t.tagName&&!Ce(t);){if(ye(t))return t;t=t.parentNode}return null}(e);if(n!==r.INPUT||i)l&&(e=l,i=!0);else{if(!l)return t("not an input"),null;e=l,i=!0,t("use custom input parent",l)}const a=function(e){let t=[],n=e;for(;n;){let e=n.getRootNode();if(Ce(e)){const{host:o}=e;t.unshift(o.tagName.toLowerCase()),n=o;continue}const o=ke(n);if(!o)break;{let e=o.tagName.toLowerCase();const r=o.getAttribute("name");r?e+=`[name="${r}"]`:o.id&&!o.id.match(/\d$/)&&(e+="#"+o.id),t.unshift(e),n=o}}if(0===t.length)return;return t}(e);let c=null;i||(c=ue(e),c&&c.length>250&&(c=null));t("text is:"+c);let u=new Map,f=new Map;const d=new Map,m=new J(a,null,o),p=new J(a,c,o),h=(e,n,o,r,s)=>{if(r<0)return;let i=e.get(n);i||(i=[],e.set(n,i)),i.push({css:o,offset:r,complexity:s}),t(`use css=${o}, cardinality=${n}, offset=${r}`)},w=function(e){const t=new Map;t.set(null,0);let n=e.parentNode;for(;n&&"BODY"!==n.tagName&&!Ce(n);){for(const e of Q(n)){if(t.has(e))continue;const n=se(document.body,e);if(n){const o=n.length;t.set(e,o)}}n=n.parentNode}const o=20;return Array.from(t.entries()).sort((([,e],[,t])=>e-t)).slice(0,o).map((([e])=>e))}(e),v=[e.tagName.toLowerCase(),...Q(e)];t("shadowRootSelectors:",a),t("ancestorCssSelectors:",w),t("ownCssSelectors:",v);for(const r of v)for(const n of w){const o=n?`${n} ${r}`:r,s=n?2:1,i=m.query(o),l=Array.from(i),a=l.length;if(a>100){t(`cardinality too high css=${o}, cardinality=${a}`);continue}d.set(o,a);if(h(u,a,o,l.indexOf(e),s),c){const t=p.query(o),n=Array.from(t),r=n.indexOf(e);h(f,n.length,o,r,s)}}if(u.size>0||f.size>0){const r=e=>Array.from(e.entries()).map((([e,t])=>({cardinality:e,cssSelectors:t.sort(((e,t)=>{const n=d.get(e.css),o=d.get(t.css);return n!==o?n?o?n-o:-1:1:e.complexity!==t.complexity?t.complexity-e.complexity:e.css.localeCompare(t.css)})).map((({css:e,offset:t})=>({css:e,offset:t})))}))).sort(((e,t)=>e.cardinality-t.cardinality)),i={version:"v1",minorVersion:o.minorVersion,shadowRootSelectors:a,notextGroups:r(u),textGroups:r(f)},l={el:e,selector:{type:s.AUTO,autoData:JSON.stringify(i),text:c,elementType:n}};return t("inference result",l),l}return t("no selector inferred "),null}(e,n)}catch(l){console.error("Userflow findElement error:",l),i=null}return t("time",performance.now()-o),t.groupEnd(),V("userflow:inferSelector:end"),B("userflow:inferSelector","userflow:inferSelector:start","userflow:inferSelector:end"),i}function Q(e){const t=[],r=e.tagName.toLowerCase();return n.inferenceAttributeNames.forEach((s=>{const i=e.getAttribute(s);if(!i)return;const l=n.inferenceAttributeFilters[s];if(!l||o(l,i))if("id"===s)t.push(`#${e.id}`);else{const e="name"===s||"placeholder"===s?r:"";t.push(`${e}[${s}="${i}"]`)}})),e.classList.forEach((e=>{o(n.inferenceClassNameFilters,e)&&t.push(`.${e.trim()}`)})),t}(window.userflow||{}).__inferSelector=H;class J{constructor(e,t,n){this.shadowRootSelectors=e,this.text=t,this.ctx=n,this.isVisibleCache=new Map,this.textCache=new Map}*query(e){const n=se(document.body,e,this.shadowRootSelectors);if(t("found",n),!n)return;const{text:o}=this;for(let r=0;r<n.length;r++){const e=n[r];if(o){let n=this.textCache.get(e);if(null==n&&(n=de(e,o),this.textCache.set(e,n)),!n){t("skip, text mismatch",e);continue}}let s=this.isVisibleCache.get(e);null==s&&(s=Te(e,this.ctx),this.isVisibleCache.set(e,s)),s?(t("yield",e),yield e):t("skip, not visible",e)}}}const K=4,ee=window.userflow||{};function te(e){const n=performance.now();let o;V("userflow:findAllElements:start"),t.groupCollapsed("findAllElements",e);try{if(e.type===s.MANUAL)o=function(e){const n={minorVersion:null==e.minorVersion?1:e.minorVersion};let{css:o,text:s,elementType:i,offset:l}=e;s=s&&me(s);const a="nearSelector"in e?e.nearSelector:null;t("findAllElementsManual",e),null!=l&&null!=a&&console.warn("Userflow.js: Both selector.offset and selector.nearSelector was set; ignoring nearSelector.");let c;if(s&&!o){if(c=[],n.minorVersion>=2)for(const e of Re())re(e,s,c);else re(document.body,s,c);t("els after traverseElementForText",c)}else if(o){if(n.minorVersion>=2){c=[];for(const e of Re()){const t=se(e,o);t&&t.length>0&&c.push(...t)}}else c=Array.from(se(document.body,o)||[]);t("els after safeQueryAll",c),s&&(c=function(e,t){const n=[];for(let o=e.length-1;o>=0;o--){const r=e[o];n.some((e=>e.contains(r)))||de(r,t)&&n.push(r)}return n.reverse()}(c,s),t("els after filterElementsByText",c))}else console.warn("Userflow.js: findAllElements() requires least one of `css` and `text` to be set."),c=[];c.length>0&&(c=c.filter((e=>Te(e,n))),t("els after isVisible",c));c.length>0&&i===r.INPUT&&(c=function(e,n){const o=new Set,r=new X(n),s=he();for(const i of e){if(i.matches(s)){o.add(i);continue}let e=null,n=null;r.getAllInputs().forEach((o=>{const s=r.calcScore(i,o);t("input",s,o),0!==s&&(e&&n&&s<=n||(t("input is best so far"),e=o,n=s))})),e&&(t("best input was",e),o.add(e))}return Array.from(o)}(c,n),t("els after mapElementsToInputs",c));c.length>0&&(c.sort(((e,t)=>{const n=Ae(e),o=Ae(t);return n.top<o.top?-1:n.top>o.top?1:n.left-o.left})),t("els after sort",c));if(c.length>0)if(null!=l)c=c[l]?[c[l]]:[],t("els after offset",c);else if(null!=a){const e=te(a);let n=null,o=0;for(const t of c)for(const r of e){const e=F(Ae(t),Ae(r));(!n||e<o)&&(n=t,o=e)}c=n?[n]:[],t("els after nearSelector",c)}return c}(e);else if(e.autoData){const n=JSON.parse(e.autoData);let r;if("v1"!==n.version)throw new v(n.version,"Unknown autoData version: "+n.version);r=function(e,n){const{text:o,excludeText:r,precision:s}=e,i={minorVersion:n.minorVersion||0},l=null!=o&&!r,a=l?n.textGroups:n.notextGroups,c=Math.max(1,Math.min(a.length,Math.ceil((1-parseFloat(s||"1"))*a.length))),u=new J(n.shadowRootSelectors,l&&o||null,i);t("findElementAutoV1",{text:o,excludeText:r,precision:s,groups:a,groupCount:c});for(let f=0;f<c;f++){const e=a[f];let n=new Map,o=0,r=null;t.group(`group cardinality=${e.cardinality}`,e);try{for(let s=0;s<e.cssSelectors.length;s++){const{css:i,offset:l}=e.cssSelectors[s];t(`css=${i}, offset=${l}`);let a=u.query(i),c=null;for(let e=0;e<=l;e++){const e=a.next();if(e.done)break;c=e.value}if(!c)continue;const f=(n.get(c)||0)+1;if(n.set(c,f),t(`el with frequency=${f}`+(f>o&&c!==r?" NEW BEST":""),c),f>o&&(o=f,r=c,f>=Math.ceil(e.cssSelectors.length/2)))return t("early winner",r),r}}finally{t.groupEnd()}if(r)return t("winner",r),r}return t("element not found"),null}(e,n),o=r?[r]:[]}else o=[]}catch(i){console.error("Userflow findElement error:",i),o=[]}return t("time",performance.now()-n),t.groupEnd(),V("userflow:findAllElements:end"),B("userflow:findAllElements","userflow:findAllElements:start","userflow:findAllElements:end"),o}function ne(e){return te(e)[0]||null}function oe(e,n){const o=performance.now();let r;V("userflow:elementMatchesSelector:start"),t.groupCollapsed("elementMatchesSelector",e,n);try{if(n.type===s.MANUAL)r=function(e,t){null!=t.offset&&console.warn("Userflow.js: selector.offset is not supported for elementMatchesSelector yet");"nearSelector"in t&&null!=t.nearSelector&&console.warn("Userflow.js: selector.nearSelector is not supported for elementMatchesSelector yet");let{css:n,text:o}=t;o=o&&me(o);let r=!1,s=e;for(;s&&"BODY"!==s.tagName;){if((!n||s.matches(n))&&(!o||de(s,o))){r=!0;break}s=s.parentElement}return r}(e,n);else{const t=ne(n);r=null!=t&&t.contains(e)}}catch(i){console.error("Userflow findElement error:",i),r=!1}return t(r?"match":"not match"),t("time",performance.now()-o),t.groupEnd(),V("userflow:elementMatchesSelector:end"),B("userflow:elementMatchesSelector","userflow:elementMatchesSelector:start","userflow:elementMatchesSelector:end"),r}function re(e,t,n){if(De(e)){const{tagName:t}=e;if("SCRIPT"===t||"STYLE"===t)return!1}let o=!1;for(let r=0;r<e.children.length;r++)re(e.children[r],t,n)&&(o=!0);return!o&&De(e)&&de(e,t)&&(n.push(e),o=!0),o}function se(e,t,n){try{if(null==n)return e.querySelectorAll(t);return ie(t,n,0,e)}catch(o){return console.warn("Userflow.js: Invalid CSS selector: ",t),null}}function ie(e,t,n,o){if(n>=t.length)return Array.from(o.querySelectorAll(e));const r=t[n],s=o.querySelectorAll(r),i=[];return s.forEach((o=>{let r;if(o.shadowRoot)r=o.shadowRoot;else{if(!Me(o))return;let e=null;try{e=o.contentDocument}catch(s){}if(!e)return;r=e.body}i.push(...ie(e,t,n+1,r))})),i}const le={email:!0,number:!0,password:!0,search:!0,tel:!0,text:!0,url:!0},ae={date:!0,"datetime-local":!0,month:!0,time:!0,week:!0},ce={button:!0,email:!0,reset:!0,search:!0,submit:!0,tel:!0,text:!0,url:!0};function ue(e){let t=e.innerText;return void 0===t&&"SELECT"!==e.tagName&&(t=e.textContent),t=me(t),t||null}function fe(e){if(we(e)||ve(e)){const t=me(e.getAttribute("placeholder")),n=e.value||"";if(t&&!n)return t;const o=me(n);if(o&&function(e){if(ve(e))return!0;const t=(e.getAttribute("type")||"").toLowerCase();return ce[t]}(e))return o}if(Ee(e)&&e.selectedIndex>=0){const t=me(e.options[e.selectedIndex].text);if(t)return t}return ue(e)}function de(e,t){const n=fe(e);return!!n&&function(e,t){const n=e.toLowerCase();if(t.toLowerCase()===n)return!0;return!1}(t,n)}function me(e){return e?e.length>250?null:e.replace(/^[\s\uFEFF\xA0*]+|[\s\uFEFF\xA0*]+$/g,"").replace(/\s+/g," "):null}function pe(e){for(const{cssSelector:o,getValue:r}of n.customInputs)if(e.matches(o)){if(!r)return fe(e)||"";try{return(r(e)||"").trim()}catch(t){return console.error(`Userflow.js: getValue function for custom input '${o}' failed:`,t),""}}return Ee(e)?-1==e.selectedIndex?"":e.options[e.selectedIndex].text:ge(e)?fe(e)||"":e.value}function he(){return"input, select, textarea, [contenteditable]"+n.customInputs.map((({cssSelector:e})=>`, ${e}`)).join("")}function we(e){if("INPUT"!==e.tagName)return!1;const t=e.getAttribute("type");return null==t||!0===le[(t||"").toLowerCase()]}function ve(e){return"TEXTAREA"===e.tagName}function Ee(e){return"SELECT"===e.tagName}function ge(e){return"hasAttribute"in e&&e.hasAttribute("contenteditable")}function ye(e){return!!ge(e)||!!n.customInputs.some((({cssSelector:t})=>e.matches(t)))}function be(e){return we(e)||function(e){if("INPUT"!==e.tagName)return!1;const t=(e.getAttribute("type")||"").toLowerCase();return!0===ae[t]}(e)||ve(e)||Ee(e)||ye(e)}function Te(e,n){const o=Ae(e);let r=e,s=!0,i=!1,l=!1,a=!1,c=!1;for(;r;){const u=r===document.body,f="BODY"===r.tagName,d=window.getComputedStyle(r);let m=null;if(s){if(d.visibility&&"visible"!==d.visibility)return t("not visible because visibility is",d.visibility,e,{cur:r}),!1;s=!1}if("none"===d.display)return t("not visible because display is",d.display,e,{cur:r}),!1;if(null!=d.opacity&&parseFloat(d.opacity)<.01)return t("not visible because opacity is",d.opacity,e,{cur:r}),!1;if("absolute"===d.position?a=!0:"relative"!==d.position&&"fixed"!==d.position&&"sticky"!==d.position||(a=!1),n.minorVersion>=4&&!i&&!f&&(!c||"static"!==d.position)&&(Se(d.overflowX)||Se(d.overflowY))&&(m=m||Ae(r),0===m.width||0===m.height))return t("not visible because width/height (v1.4 check) is",m.width,m.height,e,{cur:r}),!1;if(!l&&Le(d.display)&&(n.minorVersion<1||f||"static"!==d.position)){const n=f||Se(d.overflow),s=n||Se(d.overflowX),i=n||Se(d.overflowY),{scrollLeft:c,scrollTop:u}=f?r.ownerDocument.documentElement:r,p=!f&&!a;if(s){if(m=m||Ae(r),p&&0===m.width)return t("not visible because width is",m.width,e,{cur:r}),!1;const n=Math.round(m.left-c);if(Math.round(o.left)<n)return t("not visible because it's clipped left",e,{left:n,cur:r}),!1}if(i){if(m=m||Ae(r),p&&0===m.height)return t("not visible because height is",m.height,e,{cur:r}),!1;const n=Math.round(m.top-u);if(Math.round(o.top)<n)return t("not visible because it's clipped top",e,{top:n,cur:r}),!1}(s||i)&&(l=!0)}if("fixed"===d.position&&(i=!0,l=!0),n.minorVersion>=3&&(r.scrollTop>0||r.scrollLeft>0)&&(l=!0),u)break;f?(r=ke(r),s=!0):r=r.parentElement,c=a}return!0}function Se(e){return"hidden"===e||"clip"===e||"scroll"===e||"auto"===e}function Le(e){return!e||!e.includes("inline")&&"contents"!==e}function Ne(e){let t=e.parentNode,n=!1;for(;t&&"BODY"!==t.tagName;){Ce(t)&&(t=t.host);const o=window.getComputedStyle(t);if("absolute"===o.position?n=!0:"relative"!==o.position&&"fixed"!==o.position&&"sticky"!==o.position||(n=!1),!n&&Le(o.display)&&(Se(o.overflow)||Se(o.overflowY)))return t;if("fixed"===o.position)return e.ownerDocument.documentElement;t=t.parentNode}return e.ownerDocument.documentElement}function Ae(e){if("HTML"===e.tagName){const t=ke(e);if(t)return Ae(t)}let t=e.getBoundingClientRect(),n=e;for(;n&&(n=ke(n),n);){const e=n.getBoundingClientRect();t={width:t.width,height:t.height,left:t.left+e.left,right:t.right+e.left,top:t.top+e.top,bottom:t.bottom+e.top}}return t}const xe=new WeakSet;function ke(e){const t=e.ownerDocument?.defaultView;if(!t)return null;if(xe.has(t))return null;{const e=t.frameElement;return e||xe.add(t),e}}function Ce(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in e&&"mode"in e}function De(e){return"object"==typeof e&&null!=e&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function Me(e){return De(e)&&"IFRAME"===e.tagName}ee.__findElement=ne,ee.__findAllElements=te,ee.__elementMatchesSelector=oe,ee.__getElementText=fe,ee.__getInputValue=pe;const _e=new Set,Ie=new Map,Ue=new Set;function Re(){return $e(),_e}function Oe(e,t){$e();for(const o of _e)e(o);const n={setup:e,teardown:t};return Ue.add(n),()=>{Ue.delete(n);for(const e of _e)t(e)}}let Fe=!1;function $e(){Ve(),Fe||(t("roots started"),Fe=!0,Pe(document.body),window.setInterval(Ve,1e4))}function Ve(){for(const e of _e)Ce(e)&&(Be(e)||(t("roots clean before removeRoot",e),je(e)));t("roots clean finished, remaining=",_e.size)}function Be(e){if(!e.ownerDocument.defaultView)return!1;let t=e.host;for(;t;){if(Ce(t)&&(t=t.host),De(t)&&"BODY"===t.tagName)return!0;t=t.parentNode}return!1}function Pe(e){if(!_e.has(e)){t("roots addRoot",e),_e.add(e),function(e){let t;const n=()=>{qe(e)},o=new R((()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));o.observe(e,{childList:!0,subtree:!0}),Ie.set(e,o)}(e),qe(e),function(e){const n=e.ownerDocument.defaultView;if(n.__userflowAttachShadowInstalled)return;n.__userflowAttachShadowInstalled=!0;const o=n.Element.prototype.attachShadow;null!=o&&(n.Element.prototype.attachShadow=function(e){const n=o.call(this,e);return this.shadowRoot&&(t("roots monitorShadowDom before addRoot",this,this.shadowRoot),Pe(this.shadowRoot)),n})}(e),function(e){const n=e=>{e.childNodes.forEach((e=>{De(e)&&e.shadowRoot&&(t("roots queryShadowDom before addRoot",e,e.shadowRoot),Pe(e.shadowRoot)),n(e)}))};n(e)}(e);for(const{setup:t}of Ue)t(e)}}function je(e){if(_e.has(e)){t("roots removeRoot",e),Ie.get(e)?.disconnect(),Ie.delete(e),_e.delete(e);for(const{teardown:t}of Ue)t(e)}}function qe(e){const t=De(e)?e.ownerDocument.getElementsByTagName("iframe"):e.querySelectorAll("iframe");for(const n of t)Ye(n)}const We=new WeakSet;function Ye(e){if(We.has(e))return;if(e.closest("#userflow-ui"))return;e.addEventListener("load",ze);const n=e.contentWindow,o=e.contentDocument;if(!n||!o)return void We.add(e);const r=o.body;r&&(n.addEventListener("unload",Ge),t("roots setupFrame before addRoot",e,o,r),Pe(r))}function ze(e){const t=e.target;t&&Me(t)&&Ye(t)}function Ge(e){const n=e.currentTarget.document.body;t("roots onFrameUnload before removeRoot",n),je(n)}function Ze(e,t={}){let n,o;const r=()=>{o=void 0,e()},s=()=>{if(window.clearTimeout(n),null==o)o=Date.now();else if(Date.now()-o>1e3)return void r();n=window.setTimeout(r,50)},i=e=>{const t=e.target;if(!t||!Xe(t))return;const n=document.getElementById("userflow-ui");n&&n.contains(t)||s()},l=new R((e=>{(function(e){const t=document.getElementById("userflow-ui");for(const n of e){const{target:e}=n;if(Xe(e)&&(t&&t.contains(e)))return!0}return!1})(e)||s()})),a=Oe((e=>{l.observe(e,{attributes:!0,subtree:!0,childList:!0,characterData:!0}),e.addEventListener("animationend",i),e.addEventListener("transitionend",i),t.observeInput&&(e.addEventListener("input",s),e.addEventListener("keypress",s),e.addEventListener("change",s))}),(e=>{e.removeEventListener("animationend",i),e.removeEventListener("transitionend",i),t.observeInput&&(e.removeEventListener("input",s),e.removeEventListener("keypress",s),e.removeEventListener("change",s))}));return{disconnect:()=>{window.clearTimeout(n),l.disconnect(),a()}}}function Xe(e){return e.nodeType===Node.ELEMENT_NODE}const He={[i.ALWAYS_TRUE]:{track:({callback:e})=>(e(!0),()=>{})},[i.ATTRIBUTE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(e&&t.operator){const n=e.value.find((e=>e.name===t.attributeName)),r=n?n.value:null;o=x[t.operator].compare({sessionData:e.value,condition:t,value:r})}n(o)};o();const r=e.observe(o);return()=>{r()}}},[i.CLAUSE]:{isExpensive:e=>{for(const t of e.conditions){const e=He[t.type];if(e.isExpensive&&e.isExpensive(t))return!0}return!1},track:({sessionData:t,condition:n,flipBackEvents:o,callback:r})=>{let s,i,l=null;const a=n.conditions.map((e=>{const t=He[e.type];return{condition:e,typeDef:t,expensive:!!t.isExpensive&&t.isExpensive(e),active:!1,isTrue:null}})),c=e=>{for(const n of a){const r=!o||!n.expensive||e;r&&!n.active?(n.active=!0,n.isTrue=!1,n.untrack=n.typeDef.track({sessionData:t,condition:n.condition,flipBackEvents:o,callback:(e,t={})=>{n.isTrue=e,window.clearTimeout(s),t.immediate?u({immediate:!0}):s=window.setTimeout(u,0)}})):!r&&n.active&&(n.untrack&&n.untrack(),n.active=!1,n.isTrue=null,n.untrack=void 0)}},u=(t={})=>{if(0===a.length)return void f(!1,t);let o,r;if(n.operator===e.AND){o=!0,r=!0;for(const e of a)!1===e.isTrue?(o=!1,e.expensive||(r=!1)):!1!==o&&null===e.isTrue&&(o=null)}else{o=!1,r=!0;for(const e of a)!0===e.isTrue?(o=!0,e.expensive||(r=!1)):!0!==o&&null===e.isTrue&&(o=null)}null!==o&&o!==l&&(l=o,f(o,t)),c(r)},f=(e,t)=>{if(e&&null!=n.waitTime&&"0"!=n.waitTime){if(!i){const e=1e3*parseFloat(n.waitTime);i=window.setTimeout((()=>{r(!0,{})}),e)}}else window.clearTimeout(i),i=void 0,r(e,t)};return c(!1),u(),()=>{window.clearTimeout(s),window.clearTimeout(i);for(const e of a)e.untrack&&e.untrack()}}},[i.ELEMENT]:{isExpensive:()=>!0,track:e=>{const{elementState:t}=e.condition;if(!t)return()=>{};const n=function(e){switch(e){case u.CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!0};case u.DISABLED:return{kind:"observer",checkElement:e=>!!e&&e.disabled};case u.MOUSEDOWN:return{kind:"event",eventName:"mousedown",valueWhenOccurred:!0};case u.NOT_CLICK:return{kind:"event",eventName:"click",valueWhenOccurred:!1};case u.NOT_DISABLED:return{kind:"observer",checkElement:e=>!!e&&!e.disabled};case u.NOT_PRESENT:return{kind:"observer",checkElement:e=>!e};case u.PRESENT:return{kind:"observer",checkElement:e=>!!e}}}(t);switch(n.kind){case"observer":return function({sessionData:e,condition:t,callback:n},o){const r=()=>{if(!t.elementState)return void console.warn("Userflow.js: ELEMENT_STATE condition missing elementState",t);if(!t.selector)return void console.warn("Userflow.js: ELEMENT_STATE condition missing selector",t);let r=!1;const s=te(T(t.selector,e.value));if(s.length>0){for(const e of s)if(o(e)){r=!0;break}}else o(null)&&(r=!0);n(r)};r();const s=e.observe(r),{disconnect:i}=Ze(r);return()=>{s(),i()}}(e,n.checkElement);case"event":return function({condition:e,flipBackEvents:t,callback:n},o,r){const{selector:s}=e;if(!s)return()=>{};let i;n(!r);const l=e=>{const o=e.target;o&&oe(o,s)&&(t?(n(r,{immediate:!0}),n(!r,{immediate:!0})):n(r))},a={capture:!0},c=Oe((e=>e.addEventListener(o,l,a)),(e=>e.removeEventListener(o,l,a)));return()=>{c(),window.clearTimeout(i)}}(e,n.eventName,n.valueWhenOccurred)}}},[i.FILLED_IN_INPUT]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{let o,r=null;const s=()=>{if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);const s=te(T(t.selector,e.value));let i=null;for(const e of s){const t=pe(e);if(t){i=t;break}}i?i!=r&&(window.clearTimeout(o),o=window.setTimeout((()=>{n(!0)}),1e3)):(n(!1),window.clearTimeout(o)),r=i};s();const i=e.observe(s),{disconnect:l}=Ze(s,{observeInput:!0});return()=>{i(),l(),window.clearTimeout(o)}}},[i.FLOW]:{track:()=>(console.warn("Userflow.js: Flow conditions do not work client-side"),()=>{})},[i.INPUT_VALUE]:{isExpensive:()=>!0,track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{if(!t.operator)return void console.warn("Userflow.js: INPUT_VALUE condition missing operator",t);if(!t.selector)return void console.warn("Userflow.js: INPUT_VALUE condition missing selector",t);let o=!1;const r=x[t.operator],s=te(T(t.selector,e.value));if(s.length>0)for(const n of s){const s=pe(n);if(r.compare({sessionData:e.value,condition:t,value:s})){o=!0;break}}else r.compare({sessionData:e.value,condition:t,value:""})&&(o=!0);n(o)};o();const r=e.observe(o),{disconnect:s}=Ze(o,{observeInput:!0});return()=>{r(),s()}}},[i.PAGE]:{track:({sessionData:e,condition:t,callback:n})=>{const o=()=>{let o=!1;if(t.operator){const n=l();o=x[t.operator].compare({sessionData:e.value,condition:t,value:n})}n(o)};let r=l();const s=()=>{const e=l();e!==r&&(r=e,o())};a(s),o();const i=e.observe(o);return()=>{i(),c(s)}}},[i.TIME]:{track:({condition:e,callback:t})=>{let n=null;const o=e.value?new Date(e.value):null,r=e.value2?new Date(e.value2):null,s=()=>{let e=!0;(o&&!isNaN(o.valueOf())&&Date.now()<o.valueOf()||r&&!isNaN(r.valueOf())&&Date.now()>=r.valueOf())&&(e=!1),e!==n&&(n=e,t(e))};s();const i=window.setInterval(s,1e4);return()=>{window.clearInterval(i)}}}};var Qe=Object.freeze({__proto__:null,[Symbol.toStringTag]:"Module",conditionTypes:He});export{R as M,y as a,g as b,He as c,Y as d,q as e,Ce as f,z as g,W as h,b as i,De as j,ke as k,H as l,G as m,T as n,Oe as o,Ze as p,ne as q,Ae as r,Ne as s,Me as t,Qe as u,P as z};
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 7829bbe782644f861a0c241af6ca755d15f3a097
1
+ 495b181ca25e1fbbc219ac682a79456c095448bf
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1002544",
3
+ "version": "0.1.1002559",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/ui.js CHANGED
@@ -1 +1 @@
1
- import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{u as n,i as s,U as i}from"./client-context.js";import{_ as r,R as o,U as c}from"./userflow.js";import{I as a}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";const l=e.lazy((()=>r((()=>import("./ElementSelectionApp.js")),[new URL("ElementSelectionApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.is-hotkey.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),u=e.lazy((()=>r((()=>import("./FlowApp.js")),[new URL("FlowApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),m=e.lazy((()=>r((()=>import("./ChecklistApp.js")),[new URL("ChecklistApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()]))),d=e.lazy(o),p=e.lazy((()=>r((()=>import("./LauncherApp.js")),[new URL("LauncherApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),h=e.lazy((()=>r((()=>import("./NotificationsApp.js")),[new URL("NotificationsApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]))),E=e.lazy((()=>r((()=>import("./TrackerTestingApp.js")),[new URL("TrackerTestingApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),S=()=>{const t=n(),[s,i]=e.useState(t.getSessionStorageState()),[r,o]=e.useState((()=>f()?null:t.flowSession)),[c,a]=e.useState(t.checklistSession),[S,_]=e.useState(t.checklistExpanded),[v,k]=e.useState(t.resourceCenterSession),[b,y]=e.useState(t.resourceCenterOpen),[j,g]=e.useState(t.resourceCenterLauncherHidden),[w,A]=e.useState(t.resourceCenterEmbedsChecklist()),[C,L]=e.useState(t.launcherSessions),[T,I]=e.useState(t.activeLauncherFlowId),[O,x]=e.useState(t.notifications);e.useEffect((()=>{const e=()=>{i(t.getSessionStorageState()),o((e=>f()&&t.flowSession?.id!==e?.id?null:t.flowSession)),a(t.checklistSession),_(t.checklistExpanded),k(t.resourceCenterSession),y(t.resourceCenterOpen),g(t.resourceCenterLauncherHidden),A(t.resourceCenterEmbedsChecklist()),L(t.launcherSessions),I(t.activeLauncherFlowId),x(t.notifications)};t.on("uistatechange",e);const n=()=>{f()||o(t.flowSession)};return document.addEventListener("visibilitychange",n),()=>{t.off("uistatechange",e),document.removeEventListener("visibilitychange",n)}}),[t]);const z=!s.activeApp&&!!r;return e.useLayoutEffect((()=>{if(z)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}}),[t,z]),"elementSelection"===s.activeApp&&s.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(l,{state:s.elementSelection})):"trackerTesting"===s.activeApp&&s.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(E,{state:s.trackerTesting})):e.createElement(e.Fragment,null,r&&e.createElement(e.Suspense,{fallback:null},e.createElement(u,{key:r.id,session:r,checklistSession:c,resourceCenterEmbedsChecklist:w})),c&&!w&&(S||c.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(m,{key:c.id,session:c,checklistExpanded:S})),v&&(b||!j)&&e.createElement(e.Suspense,{fallback:null},e.createElement(d,{key:v.id,session:v,isOpen:b,flowSession:r,checklistSession:c})),!r&&e.createElement(e.Suspense,{fallback:null},C.map((t=>e.createElement(p,{key:t.flow.id,session:t,active:t.flow.id===T})))),O.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(h,{notifications:O})))};function f(){return"hidden"===document.visibilityState}const _=({client:t})=>e.createElement(a,{i18n:s},e.createElement(i.Provider,{value:t},e.createElement(S,null)));class v{constructor(e){this.client=e}mount(){if(this.container)throw new c("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),t.render(e.createElement(_,{client:this.client}),this.container)}unmount(){this.container&&(t.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{v as RealUI};
1
+ import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{u as n,i as s,U as i}from"./client-context.js";import{_ as r,R as o,U as c}from"./userflow.js";import{I as a}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";const l=e.lazy((()=>r((()=>import("./ElementSelectionApp.js")),[new URL("ElementSelectionApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.is-hotkey.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),u=e.lazy((()=>r((()=>import("./FlowApp.js")),[new URL("FlowApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),m=e.lazy((()=>r((()=>import("./ChecklistApp.js")),[new URL("ChecklistApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()]))),d=e.lazy(o),p=e.lazy((()=>r((()=>import("./LauncherApp.js")),[new URL("LauncherApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),h=e.lazy((()=>r((()=>import("./NotificationsApp.js")),[new URL("NotificationsApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]))),E=e.lazy((()=>r((()=>import("./TrackerTestingApp.js")),[new URL("TrackerTestingApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),S=()=>{const t=n(),[s,i]=e.useState(t.getSessionStorageState()),[r,o]=e.useState((()=>f()?null:t.flowSession)),[c,a]=e.useState(t.checklistSession),[S,_]=e.useState(t.checklistExpanded),[v,k]=e.useState(t.resourceCenterSession),[b,y]=e.useState(t.resourceCenterOpen),[j,g]=e.useState(t.resourceCenterLauncherHidden),[w,A]=e.useState(t.resourceCenterEmbedsChecklist()),[C,L]=e.useState(t.launcherSessions),[T,I]=e.useState(t.activeLauncherFlowId),[O,x]=e.useState(t.notifications);e.useEffect((()=>{const e=()=>{i(t.getSessionStorageState()),o((e=>f()&&t.flowSession?.id!==e?.id?null:t.flowSession)),a(t.checklistSession),_(t.checklistExpanded),k(t.resourceCenterSession),y(t.resourceCenterOpen),g(t.resourceCenterLauncherHidden),A(t.resourceCenterEmbedsChecklist()),L(t.launcherSessions),I(t.activeLauncherFlowId),x(t.notifications)};t.on("uistatechange",e);const n=()=>{f()||o(t.flowSession)};return document.addEventListener("visibilitychange",n),()=>{t.off("uistatechange",e),document.removeEventListener("visibilitychange",n)}}),[t]);const z=!s.activeApp&&!!r;return e.useLayoutEffect((()=>{if(z)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}}),[t,z]),"elementSelection"===s.activeApp&&s.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(l,{state:s.elementSelection})):"trackerTesting"===s.activeApp&&s.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(E,{state:s.trackerTesting})):e.createElement(e.Fragment,null,r&&e.createElement(e.Suspense,{fallback:null},e.createElement(u,{key:r.id,session:r,checklistSession:c,resourceCenterEmbedsChecklist:w})),c&&!w&&(S||c.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(m,{key:c.id,session:c,checklistExpanded:S})),v&&(b||!j)&&e.createElement(e.Suspense,{fallback:null},e.createElement(d,{key:v.id,session:v,isOpen:b,flowSession:r,checklistSession:c})),!r&&e.createElement(e.Suspense,{fallback:null},C.map((t=>e.createElement(p,{key:t.flow.id,session:t,active:t.flow.id===T})))),O.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(h,{notifications:O})))};function f(){return"hidden"===document.visibilityState}const _=({client:t})=>e.createElement(a,{i18n:s},e.createElement(i.Provider,{value:t},e.createElement(S,null)));class v{constructor(e){this.client=e}mount(){if(this.container)throw new c("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),t.render(e.createElement(_,{client:this.client}),this.container)}unmount(){this.container&&(t.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{v as RealUI};
package/userflow.js CHANGED
@@ -1 +1 @@
1
- import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}getItem(e){return e=this.formatKey(e),"undefined"==typeof window?null:window[this.type].getItem(e)}setItem(e,t){e=this.formatKey(e),"undefined"!=typeof window&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),"undefined"!=typeof window)return window[this.type].removeItem(e)}clear(){if("undefined"!=typeof window)return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function f(e,t,{toOrigin:s}={}){e.postMessage(t,s||"*")}function w(e,{fromWindow:t,fromOrigin:s}={}){const i=i=>{if(!i.isTrusted)return;if(t&&t!==i.source)return;if(s&&i.origin!==s)return;const o=i.data;o&&"object"==typeof o&&"string"==typeof o.kind&&o.kind.startsWith("userflow:")&&!0===e(o)&&n()};window.addEventListener("message",i);const n=()=>window.removeEventListener("message",i);return n}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const T=new Set;let p=!1;function S(e){return function(){if(p)return;p=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),C()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{C()}))}(),T.add(e),()=>{g(e)}}function g(e){T.delete(e)}function C(){T.forEach((e=>e()))}class I{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){f(window.opener,e,{toOrigin:"https://userflow.com"})}onBuilderMessage(e){return this.unregisterOnMessage=w(e,{fromOrigin:"https://userflow.com"}),!1}async captureScreenshot(e,t,s,i){f(window,{kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{w((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,y,R,O,v,N,_,b,D,F,M,P,B,x,H,G,W,$,V,j,K,z,Y,J,X,Q,Z,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,fe,we,Te,pe,Se,ge,Ce,Ie,me,ke,Ae,Ue,Le,ye,Re,Oe,ve,Ne,_e,be,De,Fe,Me,Pe;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(y=L||(L={})).ACTION="ACTION",y.DRAFT="DRAFT",y.LINK="LINK",y.LAUNCHER_SEEN="LAUNCHER_SEEN",y.RESOURCE_CENTER="RESOURCE_CENTER",y.USERFLOWJS="USERFLOWJS",(O=R||(R={})).STRING="STRING",O.BOOLEAN="BOOLEAN",O.NUMBER="NUMBER",O.DATETIME="DATETIME",O.LIST="LIST",O.RANDOM_AB="RANDOM_AB",O.RANDOM_NUMBER="RANDOM_NUMBER",(N=v||(v={})).FLOW="FLOW",N.CHECKLIST="CHECKLIST",N.LAUNCHER="LAUNCHER",N.RESOURCE_CENTER="RESOURCE_CENTER",(b=_||(_={})).ALWAYS_TRUE="ALWAYS_TRUE",b.ATTRIBUTE="ATTRIBUTE",b.CLAUSE="CLAUSE",b.ELEMENT="ELEMENT",b.FILLED_IN_INPUT="FILLED_IN_INPUT",b.FLOW="FLOW",b.INPUT_VALUE="INPUT_VALUE",b.PAGE="PAGE",b.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(D||(D={})),(F||(F={})).INPUT="INPUT",(P=M||(M={})).ABSOLUTE_EQ="ABSOLUTE_EQ",P.ABSOLUTE_GT="ABSOLUTE_GT",P.ABSOLUTE_LT="ABSOLUTE_LT",P.AND="AND",P.BETWEEN="BETWEEN",P.CONTAINS="CONTAINS",P.EMPTY="EMPTY",P.ENDS_WITH="ENDS_WITH",P.EQ="EQ",P.EXCLUDES_ALL="EXCLUDES_ALL",P.EXCLUDES_ANY="EXCLUDES_ANY",P.FALSE="FALSE",P.GT="GT",P.GTE="GTE",P.INCLUDES_ALL="INCLUDES_ALL",P.INCLUDES_ANY="INCLUDES_ANY",P.LT="LT",P.LTE="LTE",P.NE="NE",P.NOT_CONTAINS="NOT_CONTAINS",P.NOT_EMPTY="NOT_EMPTY",P.NOT_REGEX="NOT_REGEX",P.OR="OR",P.REGEX="REGEX",P.RELATIVE_EQ="RELATIVE_EQ",P.RELATIVE_GT="RELATIVE_GT",P.RELATIVE_LT="RELATIVE_LT",P.STARTS_WITH="STARTS_WITH",P.TRUE="TRUE",P.URL="URL",(x=B||(B={})).CLICK="CLICK",x.DISABLED="DISABLED",x.MOUSEDOWN="MOUSEDOWN",x.NOT_CLICK="NOT_CLICK",x.NOT_DISABLED="NOT_DISABLED",x.NOT_PRESENT="NOT_PRESENT",x.PRESENT="PRESENT",(G=H||(H={})).ASSET="ASSET",G.CARTOON="CARTOON",G.NONE="NONE",G.URL="URL",($=W||(W={})).INSIDE="INSIDE",$.OUTSIDE="OUTSIDE",(j=V||(V={})).TOP_LEFT="TOP_LEFT",j.TOP_CENTER="TOP_CENTER",j.TOP_RIGHT="TOP_RIGHT",j.BOTTOM_RIGHT="BOTTOM_RIGHT",j.BOTTOM_CENTER="BOTTOM_CENTER",j.BOTTOM_LEFT="BOTTOM_LEFT",j.CENTER="CENTER",(z=K||(K={})).GOOGLE="GOOGLE",z.STANDARD="STANDARD",(J=Y||(Y={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",J.DISMISS="DISMISS",(Q=X||(X={})).DISMISS="DISMISS",Q.NONE="NONE",(q=Z||(Z={})).DEFAULT="DEFAULT",q.PLAINTEXT="PLAINTEXT",(te=ee||(ee={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",te.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",te.NONE="NONE",(ie=se||(se={})).BUBBLE="BUBBLE",ie.END="END",ie.ERROR="ERROR",ie.FLAG="FLAG",(oe=ne||(ne={})).MANUAL="MANUAL",oe.NONE="NONE",oe.SYNTHETIC="SYNTHETIC",(ae=re||(re={})).BUBBLE="BUBBLE",ae.HIDDEN="HIDDEN",ae.MODAL="MODAL",ae.TOOLTIP="TOOLTIP",(le=ce||(ce={})).ABOVE="ABOVE",le.BELOW="BELOW",le.LEFT="LEFT",le.RIGHT="RIGHT",(he=de||(de={})).CLOSE_FLOW="CLOSE_FLOW",he.EVAL_JS="EVAL_JS",he.GO_TO_STEP="GO_TO_STEP",he.NAVIGATE="NAVIGATE",he.SNOOZE="SNOOZE",he.START_FLOW="START_FLOW",(Ee=ue||(ue={})).NEW_TAB="NEW_TAB",Ee.SAME_TAB="SAME_TAB",(we=fe||(fe={})).MULTILINE_TEXT="MULTILINE_TEXT",we.MULTIPLE_CHOICE="MULTIPLE_CHOICE",we.NPS="NPS",we.SCALE="SCALE",we.STARS="STARS",we.TEXT="TEXT",(pe=Te||(Te={})).ACTION="ACTION",pe.CHECKLIST="CHECKLIST",pe.CONTACT="CONTACT",pe.FLOWS="FLOWS",pe.KNOWLEDGE_BASE="KNOWLEDGE_BASE",pe.MESSAGE="MESSAGE",pe.SUBPAGE="SUBPAGE",(ge=Se||(Se={})).CRISP="CRISP",ge.CUSTOM="CUSTOM",ge.FRESHCHAT="FRESHCHAT",ge.HELPSCOUT="HELPSCOUT",ge.HUBSPOT="HUBSPOT",ge.INTERCOM="INTERCOM",ge.ZENDESK="ZENDESK",ge.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(Ie=Ce||(Ce={})).LAUNCHER_CLICK="LAUNCHER_CLICK",Ie.LAUNCHER_HOVER="LAUNCHER_HOVER",Ie.TARGET_CLICK="TARGET_CLICK",Ie.TARGET_HOVER="TARGET_HOVER",Ie.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",Ie.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(ke=me||(me={})).ACTIVATE="ACTIVATE",ke.DEACTIVATE="DEACTIVATE",ke.NEVER="NEVER",(Ue=Ae||(Ae={})).AUTO="AUTO",Ue.TOP="TOP",Ue.RIGHT="RIGHT",Ue.BOTTOM="BOTTOM",Ue.LEFT="LEFT",(ye=Le||(Le={})).START="START",ye.CENTER="CENTER",ye.END="END",(Oe=Re||(Re={})).PERCENT="PERCENT",Oe.PX="PX",(Ne=ve||(ve={})).BEACON="BEACON",Ne.BUTTON="BUTTON",Ne.HIDDEN="HIDDEN",Ne.ICON="ICON",(be=_e||(_e={})).LAUNCHER="LAUNCHER",be.TARGET="TARGET",(Fe=De||(De={})).ACTIVE="ACTIVE",Fe.COMPLETED="COMPLETED",Fe.ENDED="ENDED",Fe.NOT_SEEN="NOT_SEEN",(Pe=Me||(Me={})).HIGHLIGHT="HIGHLIGHT",Pe.MODAL="MODAL",Pe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const Be={customInputs:[],customNavigate:null,urlFilter:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")]};function xe(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function He(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function Ge(){let e=d();if(Be.urlFilter){if(e=Be.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}const We=(localStorage.getItem("debug")||"").split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),$e=je("log");let Ve;function je(e){return function(t,...s){if(We){const i=performance.now(),n=Ve?Math.round(i-Ve):0;Ve=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#4579E4;","","color:#4579E4;",...s)}}}$e.group=je("group"),$e.groupCollapsed=je("groupCollapsed"),$e.groupEnd=function(){We&&console.groupEnd()};const Ke=()=>n((()=>import("./ResourceCenterApp.js")),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);function ze(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class Ye{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const Je=import.meta.url;class Xe{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{$e(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}}));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),$e("constructor, build=1002544"),S(this.onUrlChange),this.setTargetEnv(new I),this.checkTestUserAtBoot(),this.toggleUI()}get socketStatus(){return this._socketStatus}destroy(){$e("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv()}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=c.getItem("userflowClientState");if(s)try{e=JSON.parse(s)}catch(t){console.error("Userflow.js: Parse ElementSelectionState error:",t)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null})}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&($e("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:(new Date).toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if($e("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?$e("init() ignoring new token since a test user has been identified"):(this.clientToken&&($e("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",$e("connecting to socket");let t="e.userflow.com";"js.getuserflow.com"===new URL(Je).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{$e("socket opened")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),$e("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1002544",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return $e("channel join payload",t),t}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout((()=>{this.hasDraftSession()?this.debounceInactiveDisconnect():($e("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,handlesRejection:s}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=window.setTimeout((()=>{this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}),50)),this.sendRaw(e,{handlesRejection:s})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel)throw Error("Userflow.js: send() should not be called if channel is not set");$e(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n="Userflow.js send got phx_error";console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(t=>{r();const s=`Userflow.js error reply (${t.code}): ${t.message}`;console.log(s,"\nClient message:",e,"\nError:",t),i(new o(s,t.code))}))}))}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){$e(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,resourceCenterSession:r}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void $e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):$e(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):$e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetChecklistSession":return o>t?void $e(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void $e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(r?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if($e("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)$e("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&($e("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){$e("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if($e("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)$e("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){$e("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once||i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return R.STRING;case"number":return R.NUMBER;case"boolean":return R.BOOLEAN;case"datetime":return R.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=R.STRING;break;case"boolean":n=R.BOOLEAN;break;case"integer":case"decimal":n=R.NUMBER;break;case"datetime":n=R.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){$e(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout((()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()}),0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&($e(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();this.clientContext&&e.pageUrl===this.clientContext.pageUrl||(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:Ge(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){$e("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach(((e,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),$e(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return $e("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),$e("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){this.checklistSession&&this.checklistExpandPending&&(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),this.resourceCenterSession&&!this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),c.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){this.resourceCenterSession&&this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),c.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:t}=this;return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?ze(t):0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===Te.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===v.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===v.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){$e("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){$e("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){$e("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===v.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setResourceCenterSession(e){const t=this.resourceCenterSession;this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===me.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&($e("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&($e("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.resourceCenterSession&&Ke();const{RealUI:t}=await e;return new t(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;$e("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new Ye([]),condition:e,callback:t=>{i.isTrue!==t&&($e("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&($e("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new Ye(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})}}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,$e("csp issue detected"),f(window,{kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new Xe;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>window.userflow.endAll(),async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&Be.customInputs.push({cssSelector:e})},registerCustomInput(e,t){Be.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){Be.customNavigate=e},setUrlFilter(e){Be.urlFilter=e},setInferenceAttributeNames(e){Be.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){Be.inferenceAttributeFilters[e]=xe(t)},setInferenceClassNameFilter(e){Be.inferenceClassNameFilters=xe(e)},setScrollPadding(e){Be.scrollPadding=e},setCustomScrollIntoView(e){Be.customScrollIntoView=e},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(t){e.pageTrackingDisabled=t},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;$e(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}$e("queue processed")}()}export{H as A,W as B,Se as C,ce as D,m as E,M as F,Ce as G,Ae as H,_e as I,Le as J,Re as K,ve as L,X as M,Ke as R,L as S,se as T,o as U,ne as V,n as _,F as a,D as b,Be as c,$e as d,_ as e,B as f,Ge as g,Te as h,ze as i,ee as j,Z as k,de as l,v as m,d as n,S as o,ue as p,fe as q,Ye as r,l as s,He as t,g as u,K as v,a as w,Y as x,re as y,V as z};export default window.userflow;
1
+ import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}getItem(e){return e=this.formatKey(e),"undefined"==typeof window?null:window[this.type].getItem(e)}setItem(e,t){e=this.formatKey(e),"undefined"!=typeof window&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),"undefined"!=typeof window)return window[this.type].removeItem(e)}clear(){if("undefined"!=typeof window)return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function f(e,t,{toOrigin:s}={}){e.postMessage(t,s||"*")}function w(e,{fromWindow:t,fromOrigin:s}={}){const i=i=>{if(!i.isTrusted)return;if(t&&t!==i.source)return;if(s&&i.origin!==s)return;const o=i.data;o&&"object"==typeof o&&"string"==typeof o.kind&&o.kind.startsWith("userflow:")&&!0===e(o)&&n()};window.addEventListener("message",i);const n=()=>window.removeEventListener("message",i);return n}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const T=new Set;let p=!1;function S(e){return function(){if(p)return;p=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),C()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{C()}))}(),T.add(e),()=>{g(e)}}function g(e){T.delete(e)}function C(){T.forEach((e=>e()))}class I{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){f(window.opener,e,{toOrigin:"https://userflow.com"})}onBuilderMessage(e){return this.unregisterOnMessage=w(e,{fromOrigin:"https://userflow.com"}),!1}async captureScreenshot(e,t,s,i){f(window,{kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{w((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,y,R,O,v,N,_,b,D,F,M,P,B,x,H,G,W,$,V,j,K,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,fe,we,Te,pe,Se,ge,Ce,Ie,me,ke,Ae,Ue,Le,ye,Re,Oe,ve,Ne,_e,be,De,Fe,Me,Pe;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(y=L||(L={})).ACTION="ACTION",y.DRAFT="DRAFT",y.LINK="LINK",y.LAUNCHER_SEEN="LAUNCHER_SEEN",y.RESOURCE_CENTER="RESOURCE_CENTER",y.USERFLOWJS="USERFLOWJS",(O=R||(R={})).STRING="STRING",O.BOOLEAN="BOOLEAN",O.NUMBER="NUMBER",O.DATETIME="DATETIME",O.LIST="LIST",O.RANDOM_AB="RANDOM_AB",O.RANDOM_NUMBER="RANDOM_NUMBER",(N=v||(v={})).FLOW="FLOW",N.CHECKLIST="CHECKLIST",N.LAUNCHER="LAUNCHER",N.RESOURCE_CENTER="RESOURCE_CENTER",(b=_||(_={})).ALWAYS_TRUE="ALWAYS_TRUE",b.ATTRIBUTE="ATTRIBUTE",b.CLAUSE="CLAUSE",b.ELEMENT="ELEMENT",b.FILLED_IN_INPUT="FILLED_IN_INPUT",b.FLOW="FLOW",b.INPUT_VALUE="INPUT_VALUE",b.PAGE="PAGE",b.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(D||(D={})),(F||(F={})).INPUT="INPUT",(P=M||(M={})).ABSOLUTE_EQ="ABSOLUTE_EQ",P.ABSOLUTE_GT="ABSOLUTE_GT",P.ABSOLUTE_LT="ABSOLUTE_LT",P.AND="AND",P.BETWEEN="BETWEEN",P.CONTAINS="CONTAINS",P.EMPTY="EMPTY",P.ENDS_WITH="ENDS_WITH",P.EQ="EQ",P.EXCLUDES_ALL="EXCLUDES_ALL",P.EXCLUDES_ANY="EXCLUDES_ANY",P.FALSE="FALSE",P.GT="GT",P.GTE="GTE",P.INCLUDES_ALL="INCLUDES_ALL",P.INCLUDES_ANY="INCLUDES_ANY",P.LT="LT",P.LTE="LTE",P.NE="NE",P.NOT_CONTAINS="NOT_CONTAINS",P.NOT_EMPTY="NOT_EMPTY",P.NOT_REGEX="NOT_REGEX",P.OR="OR",P.REGEX="REGEX",P.RELATIVE_EQ="RELATIVE_EQ",P.RELATIVE_GT="RELATIVE_GT",P.RELATIVE_LT="RELATIVE_LT",P.STARTS_WITH="STARTS_WITH",P.TRUE="TRUE",P.URL="URL",(x=B||(B={})).CLICK="CLICK",x.DISABLED="DISABLED",x.MOUSEDOWN="MOUSEDOWN",x.NOT_CLICK="NOT_CLICK",x.NOT_DISABLED="NOT_DISABLED",x.NOT_PRESENT="NOT_PRESENT",x.PRESENT="PRESENT",(G=H||(H={})).ASSET="ASSET",G.CARTOON="CARTOON",G.NONE="NONE",G.URL="URL",($=W||(W={})).INSIDE="INSIDE",$.OUTSIDE="OUTSIDE",(j=V||(V={})).TOP_LEFT="TOP_LEFT",j.TOP_CENTER="TOP_CENTER",j.TOP_RIGHT="TOP_RIGHT",j.BOTTOM_RIGHT="BOTTOM_RIGHT",j.BOTTOM_CENTER="BOTTOM_CENTER",j.BOTTOM_LEFT="BOTTOM_LEFT",j.CENTER="CENTER",(z=K||(K={})).GOOGLE="GOOGLE",z.STANDARD="STANDARD",(J=Y||(Y={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",J.DISMISS="DISMISS",(Z=X||(X={})).DISMISS="DISMISS",Z.NONE="NONE",(q=Q||(Q={})).DEFAULT="DEFAULT",q.PLAINTEXT="PLAINTEXT",(te=ee||(ee={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",te.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",te.NONE="NONE",(ie=se||(se={})).BUBBLE="BUBBLE",ie.END="END",ie.ERROR="ERROR",ie.FLAG="FLAG",(oe=ne||(ne={})).MANUAL="MANUAL",oe.NONE="NONE",oe.SYNTHETIC="SYNTHETIC",(ae=re||(re={})).BUBBLE="BUBBLE",ae.HIDDEN="HIDDEN",ae.MODAL="MODAL",ae.TOOLTIP="TOOLTIP",(le=ce||(ce={})).ABOVE="ABOVE",le.BELOW="BELOW",le.LEFT="LEFT",le.RIGHT="RIGHT",(he=de||(de={})).CLOSE_FLOW="CLOSE_FLOW",he.EVAL_JS="EVAL_JS",he.GO_TO_STEP="GO_TO_STEP",he.NAVIGATE="NAVIGATE",he.SNOOZE="SNOOZE",he.START_FLOW="START_FLOW",(Ee=ue||(ue={})).NEW_TAB="NEW_TAB",Ee.SAME_TAB="SAME_TAB",(we=fe||(fe={})).MULTILINE_TEXT="MULTILINE_TEXT",we.MULTIPLE_CHOICE="MULTIPLE_CHOICE",we.NPS="NPS",we.SCALE="SCALE",we.STARS="STARS",we.TEXT="TEXT",(pe=Te||(Te={})).ACTION="ACTION",pe.CHECKLIST="CHECKLIST",pe.CONTACT="CONTACT",pe.FLOWS="FLOWS",pe.KNOWLEDGE_BASE="KNOWLEDGE_BASE",pe.MESSAGE="MESSAGE",pe.SUBPAGE="SUBPAGE",(ge=Se||(Se={})).CRISP="CRISP",ge.CUSTOM="CUSTOM",ge.FRESHCHAT="FRESHCHAT",ge.HELPSCOUT="HELPSCOUT",ge.HUBSPOT="HUBSPOT",ge.INTERCOM="INTERCOM",ge.ZENDESK="ZENDESK",ge.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(Ie=Ce||(Ce={})).LAUNCHER_CLICK="LAUNCHER_CLICK",Ie.LAUNCHER_HOVER="LAUNCHER_HOVER",Ie.TARGET_CLICK="TARGET_CLICK",Ie.TARGET_HOVER="TARGET_HOVER",Ie.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",Ie.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(ke=me||(me={})).ACTIVATE="ACTIVATE",ke.DEACTIVATE="DEACTIVATE",ke.NEVER="NEVER",(Ue=Ae||(Ae={})).AUTO="AUTO",Ue.TOP="TOP",Ue.RIGHT="RIGHT",Ue.BOTTOM="BOTTOM",Ue.LEFT="LEFT",(ye=Le||(Le={})).START="START",ye.CENTER="CENTER",ye.END="END",(Oe=Re||(Re={})).PERCENT="PERCENT",Oe.PX="PX",(Ne=ve||(ve={})).BEACON="BEACON",Ne.BUTTON="BUTTON",Ne.HIDDEN="HIDDEN",Ne.ICON="ICON",(be=_e||(_e={})).LAUNCHER="LAUNCHER",be.TARGET="TARGET",(Fe=De||(De={})).ACTIVE="ACTIVE",Fe.COMPLETED="COMPLETED",Fe.ENDED="ENDED",Fe.NOT_SEEN="NOT_SEEN",(Pe=Me||(Me={})).HIGHLIGHT="HIGHLIGHT",Pe.MODAL="MODAL",Pe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const Be={customInputs:[],customNavigate:null,urlFilter:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500};function xe(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function He(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function Ge(){let e=d();if(Be.urlFilter){if(e=Be.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}const We=(localStorage.getItem("debug")||"").split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),$e=je("log");let Ve;function je(e){return function(t,...s){if(We){const i=performance.now(),n=Ve?Math.round(i-Ve):0;Ve=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#4579E4;","","color:#4579E4;",...s)}}}$e.group=je("group"),$e.groupCollapsed=je("groupCollapsed"),$e.groupEnd=function(){We&&console.groupEnd()};const Ke=()=>n((()=>import("./ResourceCenterApp.js")),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);function ze(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class Ye{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const Je=import.meta.url;class Xe{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{$e(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}}));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),$e("constructor, build=1002559"),S(this.onUrlChange),this.setTargetEnv(new I),this.checkTestUserAtBoot(),this.toggleUI()}get socketStatus(){return this._socketStatus}destroy(){$e("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv()}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=c.getItem("userflowClientState");if(s)try{e=JSON.parse(s)}catch(t){console.error("Userflow.js: Parse ElementSelectionState error:",t)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null})}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&($e("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:(new Date).toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if($e("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?$e("init() ignoring new token since a test user has been identified"):(this.clientToken&&($e("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",$e("connecting to socket");let t="e.userflow.com";"js.getuserflow.com"===new URL(Je).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{$e("socket opened")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),$e("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1002559",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return $e("channel join payload",t),t}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout((()=>{this.hasDraftSession()?this.debounceInactiveDisconnect():($e("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,handlesRejection:s}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=window.setTimeout((()=>{this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}),50)),this.sendRaw(e,{handlesRejection:s})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel)throw Error("Userflow.js: send() should not be called if channel is not set");$e(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n="Userflow.js send got phx_error";console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(t=>{r();const s=`Userflow.js error reply (${t.code}): ${t.message}`;console.log(s,"\nClient message:",e,"\nError:",t),i(new o(s,t.code))}))}))}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){$e(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,resourceCenterSession:r}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void $e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):$e(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):$e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetChecklistSession":return o>t?void $e(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void $e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(r?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if($e("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)$e("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&($e("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){$e("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if($e("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)$e("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){$e("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once||i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return R.STRING;case"number":return R.NUMBER;case"boolean":return R.BOOLEAN;case"datetime":return R.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=R.STRING;break;case"boolean":n=R.BOOLEAN;break;case"integer":case"decimal":n=R.NUMBER;break;case"datetime":n=R.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){$e(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout((()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()}),0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&($e(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();this.clientContext&&e.pageUrl===this.clientContext.pageUrl||(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:Ge(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){$e("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach(((e,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),$e(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return $e("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),$e("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){this.checklistSession&&this.checklistExpandPending&&(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),this.resourceCenterSession&&!this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),c.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){this.resourceCenterSession&&this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),c.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:t}=this;return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?ze(t):0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===Te.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===v.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===v.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){$e("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){$e("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){$e("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===v.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setResourceCenterSession(e){const t=this.resourceCenterSession;this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===me.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&($e("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&($e("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.resourceCenterSession&&Ke();const{RealUI:t}=await e;return new t(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;$e("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new Ye([]),condition:e,callback:t=>{i.isTrue!==t&&($e("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&($e("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new Ye(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})}}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,$e("csp issue detected"),f(window,{kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new Xe;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>window.userflow.endAll(),async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&Be.customInputs.push({cssSelector:e})},registerCustomInput(e,t){Be.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){Be.customNavigate=e},setUrlFilter(e){Be.urlFilter=e},setInferenceAttributeNames(e){Be.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){Be.inferenceAttributeFilters[e]=xe(t)},setInferenceClassNameFilter(e){Be.inferenceClassNameFilters=xe(e)},setScrollPadding(e){Be.scrollPadding=e},setCustomScrollIntoView(e){Be.customScrollIntoView=e},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(t){e.pageTrackingDisabled=t},setBaseZIndex(e){Be.baseZIndex=e},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;$e(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}$e("queue processed")}()}export{H as A,W as B,Se as C,ce as D,m as E,M as F,Ce as G,Ae as H,_e as I,Le as J,Re as K,ve as L,X as M,Ke as R,L as S,se as T,o as U,ne as V,n as _,F as a,D as b,Be as c,$e as d,_ as e,B as f,Ge as g,Te as h,ze as i,ee as j,Q as k,de as l,v as m,d as n,S as o,ue as p,fe as q,Ye as r,l as s,He as t,g as u,K as v,a as w,Y as x,re as y,V as z};export default window.userflow;