UNPKG

@flows/react

Version:

Flows React SDK – Build native product growth experiences, your way

350 lines (315 loc) 42.3 kB
"use client" "use strict";var ue=Object.defineProperty,$o=Object.defineProperties,Zo=Object.getOwnPropertyDescriptor,qo=Object.getOwnPropertyDescriptors,Jo=Object.getOwnPropertyNames,ce=Object.getOwnPropertySymbols;var Be=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable;var et=(e,t,o)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,b=(e,t)=>{for(var o in t||(t={}))Be.call(t,o)&&et(e,o,t[o]);if(ce)for(var o of ce(t))tt.call(t,o)&&et(e,o,t[o]);return e},h=(e,t)=>$o(e,qo(t));var ot=(e,t)=>{var o={};for(var r in e)Be.call(e,r)&&t.indexOf(r)<0&&(o[r]=e[r]);if(e!=null&&ce)for(var r of ce(e))t.indexOf(r)<0&&tt.call(e,r)&&(o[r]=e[r]);return o};var m=(e,t)=>()=>(e&&(t=e(e=0)),t);var rt=(e,t)=>{for(var o in t)ue(e,o,{get:t[o],enumerable:!0})},Xo=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Jo(t))!Be.call(e,n)&&n!==o&&ue(e,n,{get:()=>t[n],enumerable:!(r=Zo(t,n))||r.enumerable});return e};var Yo=e=>Xo(ue({},"__esModule",{value:!0}),e);var nt,de,st=m(()=>{"use strict";nt=(e,{body:t,method:o,version:r})=>fetch(e,{method:o,headers:{"Content-Type":"application/json","x-flows-version":r},body:t?JSON.stringify(t):void 0}).then(async n=>{var i;let s=await n.text(),f=s?JSON.parse(s):void 0;if(!n.ok){let c=f;throw new Error((i=c==null?void 0:c.message)!=null?i:n.statusText)}return f}),de=(e,t)=>({getBlocks:o=>nt(`${e}/v2/sdk/blocks`,{method:"POST",body:o,version:t}),sendEvent:o=>nt(`${e}/v2/sdk/events`,{method:"POST",body:o,version:t})})});var jo,Qo,Se,Te,I,fe=m(()=>{"use strict";jo="#22262d",Qo="#fff",Se="%cFlows%c",Te=`color:${Qo};background:${jo};padding:2px 4px;border-radius:4px`,I={error:(e,...t)=>{console.error(`${Se} ${e}`,Te,"",...t)},warn:(e,...t)=>{console.warn(`${Se} ${e}`,Te,"",...t)},info:(e,...t)=>{console.info(`${Se} ${e}`,Te,"",...t)}}});var ge,it,at,lt,me,pt=m(()=>{"use strict";fe();ge=(e,t)=>{let o=new Set([...t.exitedBlockIds,...t.updatedBlocks.map(r=>r.id)]);return[...e.filter(r=>!o.has(r.id)),...t.updatedBlocks]},it=(e,t)=>{e.slottable&&!e.slotId&&(t==="component"&&I.error(`Encountered workflow block "${e.componentType}" that is slottable but has no slotId`),t==="tour-component"&&I.error(`Encountered tour block "${e.componentType}" that is slottable but has no slotId`))},at=e=>{e.forEach(t=>{var o;it(t,"component"),(o=t.tourBlocks)==null||o.forEach(r=>{it(r,"tour-component")})})},lt=({component:e,type:t})=>{t==="tour-component"&&I.error(`Tour Component not found for tour block "${e}"`),t==="component"&&I.error(`Component not found for workflow block "${e}"`)},me=e=>e.type==="tour-component"&&e.tourBlockId?e.tourBlockId:e.id});var ne,ct=m(()=>{"use strict";ne=(e,t)=>{let o="",r=0;for(;r<e.length;){let n=e.indexOf("{{",r);if(n===-1){o+=e.slice(r);break}o+=e.slice(r,n);let s=e.indexOf("}}",n+2);if(s===-1){o+=e.slice(n);break}let i=e.slice(n+2,s).trim(),c=i.indexOf("|"),l=(c===-1?i:i.slice(0,c)).trim(),p=c===-1?void 0:i.slice(c+1).trim(),g=e.slice(n,s+2);if(!l){o+=g,r=s+2;continue}let a=t[l];if(typeof a=="string"||typeof a=="number"||typeof a=="boolean"){o+=a.toString(),r=s+2;continue}o+=p!=null?p:"",r=s+2}return o}});var se,ie,ut,Me,dt,ft=m(()=>{"use strict";se=require("es-toolkit/compat"),ie=require("es-toolkit");ct();ut=({propMeta:e,userProperties:t})=>{let o=e.value,r={label:ne(o.label,t),openInNew:o.openInNew};return o.url!==void 0&&(r.url=ne(o.url,t)),r},Me=e=>{var p,g;let{block:t,exitNodeCb:o,removeBlock:r,setStateMemory:n}=e,s=({properties:a,parentKey:u})=>{var v;let d=b({},a);return delete d.f__exit_nodes,(v=a.f__exit_nodes)==null||v.forEach(w=>{let P=()=>o({key:[u,w].filter(T=>T!==void 0).join("."),blockId:t.id});d[w]=P}),Object.entries(a).forEach(([w,P])=>{Array.isArray(P)&&(d[w]=P.map((T,N)=>typeof T=="object"?s({properties:T,parentKey:[u,w,N].filter(_=>_!==void 0).join(".")}):T))}),d},f=s({properties:t.data}),i=({value:a,parentKey:u})=>typeof a=="string"?ne(a,e.userProperties):Array.isArray(a)?a.map((d,v)=>d&&typeof d=="object"?(0,ie.mapValues)(d,(w,P)=>{let T=[u,v,P].join(".");return i({value:w,parentKey:T})}):d):a,c=(0,ie.mapValues)(f,(a,u)=>i({value:a,parentKey:u}));for(let a of(p=t.propertyMeta)!=null?p:[]){if(a.type==="state-memory"){let u={value:a.value,setValue:d=>{n({key:a.key,value:d,blockId:t.id})},triggers:(g=a.triggers)!=null?g:[]};(0,se.set)(c,a.key,u)}if(a.type==="block-state"){let u=Me(h(b({},e),{block:a.value}));(0,se.set)(c,a.key,u)}if(a.type==="action"){let u=ut({propMeta:a,userProperties:e.userProperties}),d=a.value.exitNode;d&&(u.callAction=()=>(t.exitNodes.includes(d)&&r(t.id),o({key:d,blockId:t.id}))),(0,se.set)(c,a.key,u)}}let l=t.exitNodes.reduce((a,u)=>{let d=()=>(r(t.id),o({key:u,blockId:t.id}));return a[u]=d,a},{});return b(b({__flows:{id:t.id,key:t.key,workflowId:t.workflowId}},c),l)},dt=({tourSteps:e,tourStep:t,currentIndex:o,userProperties:r,handleCancel:n,handleContinue:s,handlePrevious:f})=>{var a;let i=o===0,c=u=>typeof u=="string"?ne(u,r):Array.isArray(u)?u.map(d=>d&&typeof d=="object"?(0,ie.mapValues)(d,c):d):u,l=(0,ie.mapValues)(t.data,c);for(let u of(a=t.propertyMeta)!=null?a:[])if(u.type==="action"){let d=ut({propMeta:u,userProperties:r});u.value.exitNode&&(d.callAction=async()=>{u.value.exitNode==="continue"&&s(),u.value.exitNode==="previous"&&f(),u.value.exitNode==="cancel"&&n()}),(0,se.set)(l,u.key,d)}let p=e.filter(u=>u.type==="tour-component"),g=p.findIndex(u=>u.id===t.id);return h(b({__flows:{id:t.id,key:t.key,workflowId:t.workflowId,tourVisibleStepCount:p.length,tourVisibleStepIndex:g}},l),{continue:s,previous:i?void 0:f,cancel:n})}});var er,gt,mt,Ee,Ne,Ie,bt,Ae,yt,kt,vt,be,wt,ht=m(()=>{"use strict";er=/^https?:\/\/localhost/,gt=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,mt=e=>(!!e).toString(),Ee="flows-debug-enabled",Ne="flows-debug-position",Ie=[{value:"top-left",label:"Top Left"},{value:"top-right",label:"Top Right"},{value:"bottom-left",label:"Bottom Left"},{value:"bottom-right",label:"Bottom Right"}],bt=()=>{let e=localStorage.getItem(Ne);return Ie.some(t=>t.value===e)?e:"bottom-right"},Ae={organizationId:{true:"Organization ID is valid.",false:"Organization ID is not valid."},userId:{true:"User ID is set.",false:"User ID is not set."},environment:{true:"Environment is set.",false:"Environment is not set."},apiError:{true:"API responded successfully.",false:"API returned an error. Check the browser console for details."},title:{user:"User Information","sdk-setup":"SDK Setup",blocks:"Blocks",pathname:"Pathname",settings:"Settings"}},yt=e=>{if(typeof e!="undefined")return e;let t=sessionStorage.getItem(Ee);return t?t==="true":er.test(window.location.origin)},kt=e=>`https://app.flows.sh/org/${e}`,vt="https://flows.sh/docs/sdk-overview#debug-mode",be=()=>{if(typeof window=="undefined")return!1;let e=navigator.userAgent.includes("Mac"),t=/(?:iphone|ipad|ipod)/i.test(navigator.userAgent);return e||t},wt=e=>(be()?e.metaKey:e.ctrlKey)&&e.shiftKey&&e.altKey&&e.key.toLowerCase()==="f"});var xt,Pt=m(()=>{"use strict";xt=e=>{var t;if(!(!e||e==="disabled"))return e==="automatic"?(t=navigator.languages.at(0))!=null?t:navigator.language:e}});var Re,Le,De,Fe,Ue,Ke,Ge,Oe,Ve,Ct=m(()=>{"use strict";Re=(e,t)=>t?Array.isArray(t)?t.some(o=>Re(e,o)):typeof e!="string"?!1:new RegExp(t).test(e):!0,Le=(e,t)=>t===void 0?!0:Array.isArray(t)?t.some(o=>Le(e,o)):e===t,De=(e,t)=>t===void 0?!0:Array.isArray(t)?t.every(o=>De(e,o)):e!==t,Fe=(e,t)=>t?Array.isArray(t)?t.some(o=>Fe(e,o)):typeof e!="string"?!1:e.includes(t):!0,Ue=(e,t)=>t?Array.isArray(t)?t.every(o=>Ue(e,o)):typeof e!="string"?!1:!e.includes(t):!0,Ke=(e,t)=>t?Array.isArray(t)?t.some(o=>Ke(e,o)):typeof e!="string"?!1:e.startsWith(t):!0,Ge=(e,t)=>t?Array.isArray(t)?t.some(o=>Ge(e,o)):typeof e!="string"?!1:e.endsWith(t):!0,Oe=(e,t)=>t?Array.isArray(t)?t.every(o=>Oe(e,o)):typeof e!="string"?!1:!e.startsWith(t):!0,Ve=(e,t)=>t?Array.isArray(t)?t.every(o=>Ve(e,o)):typeof e!="string"?!1:!e.endsWith(t):!0});var Bt=m(()=>{"use strict";Ct()});var V,ye,St,Tt,Mt=m(()=>{"use strict";Bt();V=({operator:e,pathname:t,value:o})=>e==="eq"?Le(t,o):e==="ne"?De(t,o):e==="contains"?Fe(t,o):e==="notContains"?Ue(t,o):e==="startsWith"?Ke(t,o):e==="endsWith"?Ge(t,o):e==="notStartsWith"?Oe(t,o):e==="notEndsWith"?Ve(t,o):e==="regex"?Re(t,o):!0,ye=({eventTarget:e,value:t})=>t?Array.from(document.querySelectorAll(t)).some(o=>o.contains(e)):!1,St=e=>typeof e!="string"?!1:e.trim()?!!document.querySelector(e):!0,Tt=e=>typeof e!="string"?!1:e.trim()?!document.querySelector(e):!0});var ze=m(()=>{"use strict";Mt()});var z,Et=m(()=>{"use strict";z=()=>window.location.pathname+window.location.search});var Nt,It=m(()=>{"use strict";fe();ze();Nt=(e,t)=>{var n;let o=e.tour_trigger;return((n=e.currentTourIndex)!=null?n:0)>0||!o?!0:o.$and?o.$and.every(s=>{let f=s.type;if(f==="navigation"){if(!s.operator)return!0;let i=s.values;return i!=null&&i.every(c=>!c)?!0:V({operator:s.operator,pathname:t.pathname,value:i})}if(f==="dom-element"){let i=s.value;return typeof i!="string"?!1:i?!!document.querySelector(i):!0}if(f==="not-dom-element"){let i=s.value;return typeof i!="string"?!1:i?!document.querySelector(i):!0}if(f==="click"){let i=s.value;if(typeof i!="string")return!1;if(!i)return!0;if(!t.event||!(t.event instanceof MouseEvent))return!1;let c=t.event.target;return!c||!(c instanceof Element)?!1:ye({eventTarget:c,value:i})}return I.error(`Aborting tour start due to an unrecognized tour trigger type: ${f}. Try updating the SDK or changing the tour trigger configuration.`),!1}):(I.error("Aborting tour start due to an unsupported tour trigger format. Try updating the SDK or changing the tour trigger configuration."),!1)}});var He,At=m(()=>{"use strict";He=(e,t)=>new Proxy(e,{get(o,r,n){return r==="props"&&t(e.id),Reflect.get(o,r,n)}})});var Rt=m(()=>{"use strict"});var Lt=m(()=>{"use strict"});var Dt=m(()=>{"use strict"});var Ft=m(()=>{"use strict"});var Ut=m(()=>{"use strict"});var Kt=m(()=>{"use strict"});var Gt=m(()=>{"use strict";At();Rt();Lt();Dt();Ft();Ut();Kt()});function tr(e){return typeof e=="object"&&e!==null&&"exitedBlockIds"in e&&"updatedBlocks"in e}var Ot,Vt=m(()=>{"use strict";Ot=e=>{let t=e.data;if(typeof t!="string")return null;try{let o=JSON.parse(t);if(tr(o))return{type:"block-updates",exitedBlockIds:o.exitedBlockIds,updatedBlocks:o.updatedBlocks}}catch(o){}return null}});var E=m(()=>{"use strict";st();pt();ft();ht();Pt();fe();ze();Et();It();Gt();Vt()});var ke,zt,We,U,Q=m(()=>{"use strict";ke=require("react"),zt=()=>{},We=(0,ke.createContext)({blocks:[],components:{},tourComponents:{},runningTours:[],userProperties:{},removeBlock:zt,updateBlock:zt}),U=()=>(0,ke.useContext)(We)});var K,_t,or,rr,Ht,H,Wt,ee=m(()=>{"use strict";"use client";E();K=require("react"),_t=require("react/jsx-runtime"),or=200,rr=()=>{let[e,t]=(0,K.useState)(),o=(0,K.useRef)(e);return(0,K.useEffect)(()=>{o.current=e},[e]),(0,K.useEffect)(()=>{let r=window.setInterval(()=>{let n=z();o.current!==n&&t(n)},or);return()=>{clearInterval(r)}}),e},Ht=(0,K.createContext)(void 0),H=()=>{if((0,K.useContext)(Ht)!==void 0)return z()},Wt=({children:e})=>{let t=rr();return(0,_t.jsx)(Ht.Provider,{value:t,children:e})}});var qt,Jt,Zt=m(()=>{qt="@flows/react",Jt="1.20.1"});var $,ae=m(()=>{"use strict";Zt();$=`${qt}@${Jt}`});var mo,go=m(()=>{mo=`:root { --flows-debug-bg-default: #ffffff; --flows-debug-bg-subtle: #f9fafc; --flows-debug-bg-hover: #ebeef3; --flows-debug-fg-default: #15181c; --flows-debug-fg-subtle: #6b727b; --flows-debug-border: 1px solid #d9dde2; --flows-debug-fg-success: #188635; --flows-debug-fg-error: #cf2320; --flows-debug-overlay: hsla(0, 0%, 100%, 0.2); --flows-debug-overlay-hover: hsla(0, 0%, 100%, 0.3); --flows-debug-small-shadow: 0px 0px 1px rgba(0, 0, 0, 0.06), 0px 4px 4px -1px rgba(0, 0, 0, 0.02); --flows-debug-shadow: 0px 3px 8px rgba(0, 0, 0, 0.07), 0px 2px 5px rgba(0, 0, 0, 0.07), 0px 1px 1px rgba(0, 0, 0, 0.07); --flows-debug-system-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; --flows-debug-mono-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; } .dark { --flows-debug-bg-default: #15181c; --flows-debug-bg-subtle: #22262d; --flows-debug-bg-hover: #2b313a; --flows-debug-fg-default: #f9fafc; --flows-debug-fg-subtle: #8b929b; --flows-debug-border: 1px solid #353c46; --flows-debug-fg-success: #33a449; --flows-debug-fg-error: #ea6369; --flows-debug-overlay: hsla(0, 0%, 100%, 0.1); --flows-debug-overlay-hover: hsla(0, 0%, 100%, 0.2); --flows-debug-small-shadow: 0px 4px 4px -1px rgba(0, 0, 0, 0.06), 0px 1px 1px 0px rgba(0, 0, 0, 0.12); --flows-debug-shadow: 0px 3px 8px rgba(0, 0, 0, 0.188), 0px 2px 5px rgba(0, 0, 0, 0.188), 0px 1px 1px rgba(0, 0, 0, 0.188); } @keyframes flows-debug-fadeIn { from { opacity: 0; scale: 0.5; } 80% { opacity: 1; scale: 1.2; } to { scale: 1; } } .flows-debug { position: fixed; z-index: 10000; color: var(--flows-debug-fg-default); } :where(.flows-debug) hr { border-top: var(--flows-debug-border); } :where(.flows-debug) a { color: inherit; text-decoration: none; } :where(.flows-debug) p { margin: 0; } .flows-debug-btn { border: none; background: transparent; cursor: pointer; padding: 0; color: var(--flows-debug-fg-default); } .flows-debug-top-left { top: 16px; left: 16px; } .flows-debug-bottom-right { bottom: 16px; right: 16px; } .flows-debug-bottom-left { bottom: 16px; left: 16px; } .flows-debug-top-right { top: 16px; right: 16px; } .flows-debug-menu { background: var(--flows-debug-bg-default); display: flex; align-items: center; justify-content: center; height: 36px; width: 36px; border-radius: 99px; margin: 0; cursor: pointer; border: var(--flows-debug-border); box-shadow: var(--flows-debug-small-shadow); animation: flows-debug-fadeIn 120ms ease-out; } .flows-debug-menu-inset { color: var(--flows-debug-fg-default); transition: background 120ms ease-in-out; padding: 7px; border-radius: 99px; display: flex; } .flows-debug-menu:hover .flows-debug-menu-inset { background: var(--flows-debug-bg-hover); } .flows-debug-menu-error { background: var(--flows-debug-fg-error) !important; } .flows-debug-menu-inset-error { background: var(--flows-debug-overlay) !important; color: var(--flows-debug-bg-default) !important; &:hover { background: var(--flows-debug-overlay-hover) !important; } } .flows-debug-popover { position: absolute; margin-top: 8px; margin-bottom: 8px; background: var(--flows-debug-bg-default); border: var(--flows-debug-border); border-radius: 8px; box-shadow: var(--flows-debug-shadow); font-size: 13px; font-family: var(--flows-debug-system-font); } .flows-debug-popover-wide { width: 360px; } .flows-debug-popover-narrow { width: 260px; } .flows-debug-top-right .flows-debug-popover { right: 0; top: 100%; } .flows-debug-bottom-right .flows-debug-popover { right: 0; bottom: 100%; } .flows-debug-top-left .flows-debug-popover { left: 0; top: 100%; } .flows-debug-bottom-left .flows-debug-popover { left: 0; bottom: 100%; } .flows-debug-section-header { display: flex; gap: 4px; align-items: center; border-bottom: var(--flows-debug-border); padding: 12px 16px 12px 8px; } .flows-debug-section-label { font-weight: 600; } .flows-debug-section-content { padding: 16px; } .flows-debug-code-block { padding: 8px; border-radius: 4px; background: var(--flows-debug-bg-subtle); font-size: 12px; font-family: var(--flows-debug-mono-font); overflow-x: auto; max-height: 480px; border: var(--flows-debug-border); scrollbar-width: thin; scrollbar-color: var(--flows-debug-fg-subtle) transparent; } .flows-debug-inline-code { font-family: var(--flows-debug-mono-font); font-size: 12px; } .flows-debug-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 6px; border-radius: 6px; transition: background 120ms ease-in-out; } .flows-debug-item-interactive { cursor: pointer; &:hover { background: var(--flows-debug-bg-hover); } } .flows-debug-item-info { font-size: 12px; color: var(--flows-debug-fg-subtle); margin-top: 2px; } .flows-debug-item-label { font-weight: 600; } .flows-debug-item-secondary { color: var(--flows-debug-fg-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .flows-debug-item-list { display: flex; flex-direction: column; padding: 6px; } .flows-debug-info-line { margin-bottom: 4px; } .flows-debug-button-secondary { font-weight: 600; padding: 4px 8px; border-radius: 6px; color: var(--flows-debug-fg-default); background-color: var(--flows-debug-bg-subtle); border: var(--flows-debug-border); cursor: pointer; transition: all 80ms ease-in-out; flex-shrink: 0; &:hover { background-color: var(--flows-debug-bg-hover); } &:active { background-color: var(--flows-debug-bg-default); } } .flows-debug-section-close { padding: 4px; border-radius: 6px; width: 24px; height: 24px; &:hover { background-color: var(--flows-debug-bg-hover); } } .flows-debug-select-wrap { position: relative; svg { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; } } .flows-debug-select { all: unset; border-radius: 6px; color: var(--flows-debug-fg-default); background-color: var(--flows-debug-bg-subtle); border: var(--flows-debug-border); padding: 4px 8px; padding-right: 28px; cursor: pointer; transition: all 80ms ease-in-out; &:focus { outline: none; } &:hover { background-color: var(--flows-debug-bg-hover); } } .flows-debug-shortcut-list { display: flex; gap: 4px; } .flows-debug-shortcut { display: flex; align-items: center; font-size: 12px; color: var(--flows-debug-fg-default); background-color: var(--flows-debug-bg-subtle); min-width: 20px; height: 20px; padding: 0 4px; border-radius: 4px; justify-content: center; border: var(--flows-debug-border); } .flows-debug-validation-item { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; &:last-child { margin-bottom: 0; } } .flows-debug-validation-valid { color: var(--flows-debug-fg-success); flex-shrink: 0; } .flows-debug-validation-invalid { color: var(--flows-debug-fg-error); flex-shrink: 0; } .flows-debug-print-button { margin-top: 8px; } `});var Je,bo,yo=m(()=>{"use strict";Je=require("react/jsx-runtime"),bo=e=>(0,Je.jsx)("svg",h(b({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 40 40"},e),{children:(0,Je.jsx)("path",{d:"M38.02 12.24C36.7 10 34.87 8.22 32.56 6.94C30.38 5.74 27.83 5.08 25 5H16C12.97 5 9.76 5.66 7.45 6.94C5.14 8.22 3.3 10 1.99 12.23C0.67 14.46 0 17.08 0 20.02C0 22.96 0.67 25.53 1.99 27.76C3.3 29.99 5.15 31.78 7.47 33.05C9.8 34.33 12.94 35 16 35H25C27.81 34.94 30.4 34.26 32.6 33.05C34.91 31.77 36.74 29.99 38.04 27.76C39.34 25.52 40 22.92 40 20.01C40 17.1 39.33 14.48 38.02 12.24ZM30.3 19.89L27.37 22.82C26.63 23.56 25.62 24 24.58 24H19.95C18.9 24 17.9 24.39 17.16 25.13L16.12 26C13.19 28.46 8.72 26.37 8.72 22.55C8.72 21.65 9.08 20.79 9.71 20.16L12.64 17.23C13.38 16.49 14.4 16 15.45 16H20.08C21.13 16 22.12 15.66 22.86 14.92L23.79 14.09C26.65 11.53 31.2 13.5 31.29 17.34V17.5C31.29 18.4 30.94 19.26 30.3 19.89Z"})}))});var G,ko,vo=m(()=>{"use strict";G=require("react/jsx-runtime"),ko=({userProperties:e,userId:t})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)("p",{className:"flows-debug-info-line",children:[(0,G.jsx)("strong",{children:"User ID:"})," ",(0,G.jsx)("code",{className:"flows-debug-inline-code",children:t})]}),(0,G.jsx)("p",{className:"flows-debug-info-line",children:(0,G.jsx)("strong",{children:"User properties:"})}),(0,G.jsx)("pre",{className:"flows-debug-code-block",children:JSON.stringify(e!=null?e:{},null,2)})]})});var A,wo,ho=m(()=>{"use strict";A=require("react/jsx-runtime"),wo=({organizationId:e,environment:t,statusItems:o})=>(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)("p",{className:"flows-debug-info-line",children:[(0,A.jsx)("strong",{children:"Organization ID:"})," ",(0,A.jsx)("code",{className:"flows-debug-inline-code",children:e||(0,A.jsx)("span",{className:"flows-debug-validation-invalid",children:"Not set"})})]}),(0,A.jsxs)("p",{className:"flows-debug-info-line",children:[(0,A.jsx)("strong",{children:"Environment:"})," ",(0,A.jsx)("code",{className:"flows-debug-inline-code",children:t||(0,A.jsx)("span",{className:"flows-debug-validation-invalid",children:"Not set"})})]}),(0,A.jsx)("p",{className:"flows-debug-info-line",children:(0,A.jsx)("strong",{children:"Validation:"})}),o]})});var O,xo,Po=m(()=>{"use strict";O=require("react/jsx-runtime"),xo=({blocks:e})=>(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)("p",{className:"flows-debug-info-line",children:[(0,O.jsx)("strong",{children:"Loaded blocks:"})," ",e.length]}),(0,O.jsx)("p",{className:"flows-debug-info-line",children:(0,O.jsx)("strong",{children:"Blocks JSON:"})}),(0,O.jsx)("pre",{className:"flows-debug-code-block",children:JSON.stringify(e,null,2)}),(0,O.jsx)("button",{className:"flows-debug-btn flows-debug-button-secondary flows-debug-print-button",onClick:()=>{console.log(e)},type:"button",children:"Print to console"})]})});var pe,oe,Co=m(()=>{"use strict";pe=require("react/jsx-runtime"),oe=({label:e,secondary:t,onClick:o})=>(0,pe.jsxs)("button",{className:"flows-debug-btn flows-debug-item flows-debug-item-interactive",onClick:o,type:"button",children:[(0,pe.jsx)("span",{className:"flows-debug-item-label",children:e}),t?(0,pe.jsx)("span",{className:"flows-debug-item-secondary",children:t}):null]})});var R,Bo,So=m(()=>{"use strict";E();Co();ae();R=require("react/jsx-runtime"),Bo=({userId:e,setPanelPage:t,sdkSetupValid:o,blocks:r,pathname:n,organizationId:s})=>(0,R.jsxs)("div",{className:"flows-debug-popover-narrow",children:[(0,R.jsxs)("div",{className:"flows-debug-item-list",children:[(0,R.jsx)(oe,{label:"User",secondary:e?(0,R.jsx)("code",{className:"flows-debug-inline-code",children:e}):"Not set",onClick:()=>{t("user")}}),(0,R.jsx)(oe,{label:"SDK setup",secondary:o?"Valid":(0,R.jsx)("span",{className:"flows-debug-validation-invalid",children:"Error"}),onClick:()=>{t("sdk-setup")}}),(0,R.jsx)(oe,{label:"Blocks",secondary:`${r.length} loaded`,onClick:()=>{t("blocks")}}),(0,R.jsx)(oe,{label:"Pathname",secondary:n,onClick:()=>{t("pathname")}})]}),(0,R.jsx)("hr",{}),(0,R.jsxs)("div",{className:"flows-debug-item-list",children:[(0,R.jsx)(oe,{label:"Settings",secondary:$,onClick:()=>{t("settings")}}),(0,R.jsx)("a",{href:kt(s),target:"_blank",rel:"noopener noreferrer",className:"flows-debug-item flows-debug-item-interactive flows-debug-item-label",children:"Open Flows dashboard"})]})]})});function To(e){return(0,Xe.jsx)("svg",h(b({fill:"currentColor",height:16,width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Xe.jsx)("path",{d:"M12.78 5.22a.749.749 0 0 1 0 1.06l-4.25 4.25a.749.749 0 0 1-1.06 0L3.22 6.28a.749.749 0 1 1 1.06-1.06L8 8.939l3.72-3.719a.749.749 0 0 1 1.06 0Z"})}))}var Xe,Mo=m(()=>{"use strict";Xe=require("react/jsx-runtime")});var y,Eo,No=m(()=>{"use strict";E();Mo();ae();y=require("react/jsx-runtime"),Eo=({position:e,onPositionChange:t})=>(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)("div",{className:"flows-debug-item",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("label",{className:"flows-debug-item-label",htmlFor:"debug-panel-position",children:"Position"}),(0,y.jsx)("p",{className:"flows-debug-item-info",children:"Sets the position of the debug panel on the screen."})]}),(0,y.jsxs)("div",{className:"flows-debug-select-wrap",children:[(0,y.jsx)("select",{className:"flows-debug-select",value:e,id:"debug-panel-position",onChange:r=>{let n=r.target.value;t(n)},children:Ie.map(r=>(0,y.jsx)("option",{value:r.value,children:r.label},r.value))}),(0,y.jsx)(To,{})]})]}),(0,y.jsxs)("div",{className:"flows-debug-item",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("p",{className:"flows-debug-item-label",children:"Debug panel shortcut"}),(0,y.jsx)("p",{className:"flows-debug-item-info",children:"Used to toggle the panel visibility even when debug mode is not active."})]}),(0,y.jsxs)("div",{className:"flows-debug-shortcut-list",children:[(0,y.jsx)("p",{className:"flows-debug-shortcut",children:be()?"Cmd":"Ctrl"}),(0,y.jsx)("p",{className:"flows-debug-shortcut",children:be()?"Option":"Alt"}),(0,y.jsx)("p",{className:"flows-debug-shortcut",children:"Shift"}),(0,y.jsx)("p",{className:"flows-debug-shortcut",children:"F"})]})]}),(0,y.jsxs)("div",{className:"flows-debug-item",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("p",{className:"flows-debug-item-label",children:"Docs"}),(0,y.jsx)("p",{className:"flows-debug-item-info",children:"Learn more about the debug panel and its features."})]}),(0,y.jsx)("a",{className:"flows-debug-button-secondary",href:vt,target:"_blank",rel:"noopener noreferrer",children:"Open docs"})]}),(0,y.jsxs)("div",{className:"flows-debug-item",children:[(0,y.jsxs)("div",{children:[(0,y.jsx)("p",{className:"flows-debug-item-label",children:"SDK version"}),(0,y.jsx)("p",{className:"flows-debug-item-info",children:"Make sure to keep your SDK up to date for the best experience."})]}),(0,y.jsx)("p",{children:$})]})]})});var Ye,Io,Ao=m(()=>{"use strict";Ye=require("react/jsx-runtime"),Io=e=>(0,Ye.jsx)("svg",h(b({fill:"currentColor",height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Ye.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12.03 5.22032C12.1705 5.36094 12.2494 5.55157 12.2494 5.75032C12.2494 5.94907 12.1705 6.13969 12.03 6.28032L7.53003 10.7803C7.38941 10.9208 7.19878 10.9997 7.00003 10.9997C6.80128 10.9997 6.61066 10.9208 6.47003 10.7803L4.22003 8.53032C4.14634 8.46165 4.08724 8.37885 4.04625 8.28685C4.00526 8.19486 3.98322 8.09554 3.98144 7.99484C3.97966 7.89414 3.99819 7.79411 4.03591 7.70072C4.07363 7.60733 4.12977 7.5225 4.20099 7.45128C4.27221 7.38006 4.35705 7.32391 4.45043 7.28619C4.54382 7.24847 4.64385 7.22995 4.74455 7.23172C4.84526 7.2335 4.94457 7.25554 5.03657 7.29654C5.12857 7.33753 5.21137 7.39663 5.28003 7.47032L7.00003 9.19032L10.97 5.22032C11.1107 5.07987 11.3013 5.00098 11.5 5.00098C11.6988 5.00098 11.8894 5.07987 12.03 5.22032Z"})}))});function Ro(e){return(0,je.jsx)("svg",h(b({height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg",fill:"currentColor"},e),{children:(0,je.jsx)("path",{d:"M3.72 3.72a.75.75 0 0 1 1.06 0L8 6.94l3.22-3.22a.749.749 0 0 1 1.275.326.749.749 0 0 1-.215.734L9.06 8l3.22 3.22a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215L8 9.06l-3.22 3.22a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L6.94 8 3.72 4.78a.75.75 0 0 1 0-1.06Z"})}))}var je,Lo=m(()=>{"use strict";je=require("react/jsx-runtime")});function Do(e){return(0,Qe.jsx)("svg",h(b({height:16,viewBox:"0 0 16 16",width:16,xmlns:"http://www.w3.org/2000/svg"},e),{children:(0,Qe.jsx)("path",{d:"M7.78 12.53a.75.75 0 0 1-1.06 0L2.47 8.28a.75.75 0 0 1 0-1.06l4.25-4.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042L4.81 7h7.44a.75.75 0 0 1 0 1.5H4.81l2.97 2.97a.75.75 0 0 1 0 1.06Z",fill:"currentColor"})}))}var Qe,Fo=m(()=>{"use strict";Qe=require("react/jsx-runtime")});var q,Uo,Ko=m(()=>{"use strict";Fo();q=require("react/jsx-runtime"),Uo=({label:e,children:t,onClose:o})=>(0,q.jsxs)("div",{className:"flows-debug-popover-wide",children:[(0,q.jsxs)("div",{className:"flows-debug-section-header",children:[(0,q.jsx)("button",{className:"flows-debug-btn flows-debug-section-close",onClick:o,type:"button",children:(0,q.jsx)(Do,{})}),(0,q.jsx)("p",{className:"flows-debug-section-label",children:e})]}),(0,q.jsx)("div",{className:"flows-debug-section-content",children:t})]})});var W,Go,Oo=m(()=>{"use strict";W=require("react/jsx-runtime"),Go=({pathname:e})=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)("p",{className:"flows-debug-info-line",children:(0,W.jsx)("strong",{children:"Pathname:"})}),(0,W.jsx)("p",{className:"flows-debug-code-block flows-debug-info-line",children:e}),(0,W.jsx)("p",{className:"flows-debug-info-line",children:"This pathname is used when evaluating page targeting conditions."})]})});var Vo={};rt(Vo,{default:()=>lr});var re,Pe,x,ir,ar,lr,zo=m(()=>{"use strict";re=require("react");E();go();Pe=require("clsx");Q();ee();yo();vo();ho();Po();So();No();Ao();Lo();Ko();Oo();x=require("react/jsx-runtime"),ir=({forceOpen:e,blocksError:t,wsError:o,environment:r,organizationId:n,userId:s,userProperties:f})=>{let[i,c]=(0,re.useState)(e),l=()=>{c(M=>!M)},[p,g]=(0,re.useState)(),a=()=>{g(void 0)},[u,d]=(0,re.useState)(bt()),v=(0,re.useCallback)(M=>{d(M),localStorage.setItem(Ne,M)},[]),w=H(),{blocks:P}=U(),T=[{key:"organizationId",valid:n&&gt.test(n)},{key:"userId",valid:!!s},{key:"environment",valid:!!r},{key:"apiError",valid:!t&&!o}],N=T.every(M=>M.valid),_=p==="user"?(0,x.jsx)(ko,{userProperties:f,userId:s}):p==="sdk-setup"?(0,x.jsx)(wo,{organizationId:n,environment:r,statusItems:T.map(M=>{let k=M.valid?(0,x.jsx)(Io,{className:"flows-debug-validation-valid"}):(0,x.jsx)(Ro,{className:"flows-debug-validation-invalid"}),B=Ae[M.key][mt(M.valid)];return(0,x.jsxs)("div",{className:"flows-debug-validation-item",children:[k," ",(0,x.jsx)("p",{children:B})]},M.key)})}):p==="blocks"?(0,x.jsx)(xo,{blocks:P}):p==="pathname"?(0,x.jsx)(Go,{pathname:w}):p==="settings"?(0,x.jsx)(Eo,{position:u,onPositionChange:v}):(0,x.jsx)(Bo,{pathname:w,userId:s,setPanelPage:g,sdkSetupValid:N,blocks:P,organizationId:n});return(0,x.jsxs)("div",{className:(0,Pe.clsx)("flows-debug",`flows-debug-${u}`),children:[(0,x.jsx)("button",{className:(0,Pe.clsx)("flows-debug-btn","flows-debug-menu",!N&&"flows-debug-menu-error"),type:"button",onClick:l,children:(0,x.jsx)("div",{className:(0,Pe.clsx)("flows-debug-menu-inset",!N&&"flows-debug-menu-inset-error"),children:(0,x.jsx)(bo,{})})}),i?(0,x.jsx)("div",{className:"flows-debug-popover",children:(0,x.jsx)(ar,{page:p,onClose:a,children:_})}):null,(0,x.jsx)("style",{children:mo})]})},ar=({children:e,page:t,onClose:o})=>t?(0,x.jsx)(Uo,{label:Ae.title[t],onClose:o,children:e}):e,lr=ir});var br={};rt(br,{FlowsProvider:()=>_o,FlowsSlot:()=>nr,resetAllWorkflowsProgress:()=>fr,resetWorkflowProgress:()=>gr,startWorkflow:()=>mr,useCurrentFloatingBlocks:()=>ve,useCurrentSlotBlocks:()=>we});module.exports=Yo(br);E();E();var te=require("react");Q();ee();E();E();var j={};ae();var D=async e=>{let{apiUrl:t,environment:o,organizationId:r,userId:n}=j;!t||!o||!r||!n||await de(t,$).sendEvent(h(b({},e),{environment:o,organizationId:r,userId:n}))},Xt=new Set,_e=async e=>{Xt.has(e)||(Xt.add(e),await D({name:"block-activated",blockId:e}))};var $e=({block:e,removeBlock:t,updateBlock:o,userProperties:r})=>{if(!e.componentType)return[];let s=Me({block:e,userProperties:r,removeBlock:t,exitNodeCb:({key:i,blockId:c})=>D({name:"transition",blockId:c,propertyKey:i}),setStateMemory:async({blockId:i,key:c,value:l})=>{o(i,p=>{var g;return h(b({},p),{propertyMeta:(g=p.propertyMeta)==null?void 0:g.map(a=>a.type==="state-memory"&&a.key===c?h(b({},a),{value:l}):a)})}),await D({name:"set-state-memory",blockId:i,propertyKey:c,properties:{value:l}})}}),f={id:e.id,type:"component",component:e.componentType,props:s};return He(f,_e)},Ze=({tour:e,userProperties:t})=>{var s;let o=e.activeStep;if(!(o!=null&&o.componentType))return[];let r=dt({tourSteps:(s=e.block.tourBlocks)!=null?s:[],tourStep:o,currentIndex:e.currentBlockIndex,userProperties:t,handleCancel:e.cancel,handleContinue:e.continue,handlePrevious:e.previous}),n={id:o.id,tourBlockId:e.block.id,type:"tour-component",component:o.componentType,props:r};return He(n,_e)};var qe=e=>e==null?void 0:e.slotId;var jt=()=>{let{blocks:e}=U(),t=H();return(0,te.useMemo)(()=>e.filter(o=>V({pathname:t,operator:o.page_targeting_operator,value:o.page_targeting_values})),[e,t])},Qt=()=>{let{runningTours:e}=U(),t=H();return(0,te.useMemo)(()=>e.filter(o=>{let r=o.activeStep;return r&&V({pathname:t,operator:r.page_targeting_operator,value:r.page_targeting_values})}),[t,e])},ve=()=>{let e=jt(),t=Qt(),{removeBlock:o,updateBlock:r,userProperties:n}=U(),s=(0,te.useMemo)(()=>e.filter(i=>!i.slottable).flatMap(i=>$e({block:i,removeBlock:o,updateBlock:r,userProperties:n})),[o,n,r,e]),f=(0,te.useMemo)(()=>t.filter(i=>{let c=i.activeStep;return c&&!c.slottable}).flatMap(i=>Ze({tour:i,userProperties:n})),[n,t]);return[...s,...f]},eo=e=>"type"in e,Yt=e=>{var t,o,r;return eo(e)?(t=e.slotIndex)!=null?t:0:(r=(o=e.activeStep)==null?void 0:o.slotIndex)!=null?r:0},we=e=>{let t=jt(),o=Qt(),{removeBlock:r,updateBlock:n,userProperties:s}=U();return(0,te.useMemo)(()=>{let i=t.filter(l=>l.slottable&&qe(l)===e),c=o.filter(l=>{var p;return((p=l.activeStep)==null?void 0:p.slottable)&&qe(l.activeStep)===e});return[...i,...c].sort((l,p)=>Yt(l)-Yt(p)).flatMap(l=>eo(l)?$e({block:l,removeBlock:r,updateBlock:n,userProperties:s}):Ze({tour:l,userProperties:s}))},[r,e,s,n,t,o])};var to=require("react");E();Q();var oo=require("react/jsx-runtime"),he=({block:e})=>{let{components:t,tourComponents:o}=U(),r=(()=>{if(e.type==="component")return t[e.component];if(e.type==="tour-component")return o[e.component]})();return(0,to.useEffect)(()=>{r||lt({component:e.component,type:e.type})},[r,e.component,e.type]),r?(0,oo.jsx)(r,b({},e.props)):null};var ro=require("react/jsx-runtime"),nr=({id:e,placeholder:t})=>{let o=we(e);return o.length?o.map(r=>(0,ro.jsx)(he,{block:r},me(r))):t!=null?t:null};var Wo=require("react");Q();var L=require("react");E();var no=require("es-toolkit");ee();var so=({blocks:e,removeBlock:t})=>{let[o,r]=(0,L.useState)([]),n=(0,L.useRef)(o);n.current=o;let s=H();(0,L.useEffect)(()=>{r(c=>{let l=new Set(e.filter(p=>p.type==="tour").map(p=>p.id));return c.filter(p=>l.has(p.blockId))})},[e]);let f=(0,L.useCallback)(c=>{let l=e.filter(g=>g.type==="tour"),p=new Set(n.current.map(g=>g.blockId));l.forEach(g=>{p.has(g.id)||!Nt(g,c)||r(u=>{var v;let d={blockId:g.id,currentBlockIndex:(v=g.currentTourIndex)!=null?v:0};return[...u,d]})})},[e]);return(0,L.useEffect)(()=>{s&&f({pathname:s})},[s,f]),(0,L.useEffect)(()=>{let c=(0,no.debounce)(()=>{f({pathname:z()})},32),l=new MutationObserver(c);return l.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),c(),()=>{l.disconnect()}},[f]),(0,L.useEffect)(()=>{let c=l=>{f({pathname:z(),event:l})};return document.addEventListener("click",c),()=>{document.removeEventListener("click",c)}},[f]),(0,L.useMemo)(()=>{let c=(p,g)=>{r(a=>a.map(u=>u.blockId===p?g(u):u))},l=(p,g)=>{c(p,a=>h(b({},a),{currentBlockIndex:g}))};return o.map(({blockId:p,currentBlockIndex:g})=>{var N,_,M;let a=e.find(k=>k.id===p);if(!a)return;let u=(N=a.tourBlocks)==null?void 0:N[g],d=g===((M=(_=a.tourBlocks)==null?void 0:_.length)!=null?M:0)-1,v=k=>{D({name:"tour-update",blockId:p,properties:{currentTourIndex:k}})};return{block:a,currentBlockIndex:g,activeStep:u,continue:()=>{if(d)t(p),D({name:"transition",propertyKey:"complete",blockId:p});else{let k=g+1;v(k),setTimeout(()=>{l(p,k)},0)}},previous:()=>{var B;let k=g===0?g:g-1;for(;k>0&&a.tourBlocks&&!((B=a.tourBlocks.at(k))!=null&&B.componentType);)k-=1;v(k),setTimeout(()=>{l(p,k)},0)},cancel:()=>{t(p),D({name:"transition",blockId:p,propertyKey:"cancel"})}}}).filter(p=>!!p)},[e,t,o])};var C=require("react");E();ae();var S=require("react"),io=({url:e,onMessage:t,onOpen:o})=>{let[r,n]=(0,S.useState)(),[s,f]=(0,S.useState)(!1),i=(0,S.useRef)(void 0),[c,l]=(0,S.useState)(0),p=(0,S.useRef)(o);(0,S.useEffect)(()=>{p.current=o},[o]);let g=(0,S.useRef)(t);(0,S.useEffect)(()=>{g.current=t},[t]);let a=(0,S.useCallback)(d=>{g.current(d)},[]),u=(0,S.useCallback)(()=>{if(i.current&&(i.current(),i.current=void 0),!e)return;let d=new WebSocket(e);f(!1),n(d);let v=()=>{var N;(N=p.current)==null||N.call(p),l(0)},w=()=>{n(void 0),l(N=>N+1)},P=()=>{f(!0)};d.addEventListener("open",v),d.addEventListener("close",w),d.addEventListener("error",P),d.addEventListener("message",a);let T=()=>{d.removeEventListener("open",v),d.removeEventListener("close",w),d.removeEventListener("error",P),d.removeEventListener("message",a),d.readyState===WebSocket.CONNECTING?d.addEventListener("open",()=>{d.close()}):d.close(),n(void 0)};return i.current=T,T},[a,e]);return(0,S.useEffect)(()=>{let d=u();return()=>{d==null||d()}},[u]),(0,S.useEffect)(()=>{if(r)return;let d=setTimeout(()=>{u()},Math.min(1e3*4**c,12e4));return()=>{clearTimeout(d)}},[c,r,u]),(0,S.useEffect)(()=>()=>{i.current&&i.current()},[]),{error:s}};var ao=({apiUrl:e,environment:t,organizationId:o,userId:r,userProperties:n,language:s})=>{let[f,i]=(0,C.useState)(null),[c,l]=(0,C.useState)(!1),p=(0,C.useMemo)(()=>f!=null?f:[],[f]),[g,a]=(0,C.useState)(!1),u=(0,C.useRef)([]),d=(0,C.useMemo)(()=>({environment:t,organizationId:o,userId:r}),[t,o,r]),v=(0,C.useRef)(n);(0,C.useEffect)(()=>{v.current=n},[n]);let w=(0,C.useCallback)(()=>{l(!1),de(e,$).getBlocks(h(b({},d),{language:xt(s),userProperties:v.current})).then(k=>{var B;i(u.current.reduce(ge,k.blocks)),u.current.length=0,setTimeout(()=>{if(u.current.length){let F=[...u.current];u.current.length=0,i(Y=>F.reduce(ge,Y!=null?Y:[]))}},0),(B=k.meta)!=null&&B.usage_limited&&a(!0)}).catch(k=>{l(!0),I.error("Failed to load blocks",k)})},[e,s,d]),P=(0,C.useMemo)(()=>g?void 0:`${e.replace("https://","wss://").replace("http://","ws://")}/ws/sdk/block-updates?${new URLSearchParams(d).toString()}`,[e,d,g]),T=(0,C.useCallback)(k=>{let B=Ot(k);B&&B.type==="block-updates"&&i(F=>F?ge(F,B):(u.current.push(B),F))},[]),{error:N}=io({url:P,onMessage:T,onOpen:w});(0,C.useEffect)(()=>{at(p)},[p]);let _=(0,C.useCallback)(k=>{i(B=>B&&B.filter(F=>F.id!==k))},[]),M=(0,C.useCallback)((k,B)=>{i(F=>F&&F.map(Y=>Y.id===k?B(Y):Y))},[]);return{blocks:p,error:c,wsError:N,removeBlock:_,updateBlock:M}};ee();var Z=require("react");E();var lo=require("react"),po=require("es-toolkit");Q();ee();var co=()=>{let{runningTours:e}=U(),t=H(),[o]=(0,lo.useState)(new Map),r=(0,Z.useMemo)(()=>e.filter(n=>{var s;return!!((s=n.activeStep)!=null&&s.tourWait)}),[e]);return(0,Z.useEffect)(()=>{r.forEach(n=>{var f,i,c;let s=(f=n.activeStep)==null?void 0:f.tourWait;(s==null?void 0:s.interaction)==="navigation"&&V({pathname:t,operator:(i=s.page)==null?void 0:i.operator,value:(c=s.page)==null?void 0:c.value})&&n.continue()})},[t,r]),(0,Z.useEffect)(()=>{let n=s=>{let f=s.target;if(!f||!(f instanceof Element))return;let i=z();r.forEach(c=>{var p,g,a;let l=(p=c.activeStep)==null?void 0:p.tourWait;if((l==null?void 0:l.interaction)==="click"){let u=V({pathname:i,operator:(g=l.page)==null?void 0:g.operator,value:(a=l.page)==null?void 0:a.value});ye({eventTarget:f,value:l.element})&&u&&c.continue()}})};return addEventListener("click",n),()=>{removeEventListener("click",n)}},[t,r]),(0,Z.useEffect)(()=>{let s=(0,po.debounce)(()=>{let i=z();r.forEach(c=>{var g,a,u,d,v;let l=(g=c.activeStep)==null?void 0:g.tourWait,p=l==null?void 0:l.element;if((l==null?void 0:l.interaction)==="dom-element"){let w=V({pathname:i,operator:(a=l.page)==null?void 0:a.operator,value:(u=l.page)==null?void 0:u.value});St(p)&&w&&c.continue()}if((l==null?void 0:l.interaction)==="not-dom-element"){let w=V({pathname:i,operator:(d=l.page)==null?void 0:d.operator,value:(v=l.page)==null?void 0:v.value});Tt(p)&&w&&c.continue()}})},32),f=new MutationObserver(s);return f.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),s(),()=>{f.disconnect(),s.cancel()}},[t,r]),(0,Z.useEffect)(()=>{e.forEach(n=>{let s=n.activeStep,f=o.get(n.block.id);f&&f.stepId!==(s==null?void 0:s.id)&&(clearTimeout(f.timeoutId),o.delete(n.block.id))})},[e,o]),(0,Z.useEffect)(()=>{r.forEach(n=>{let s=n.activeStep,f=s==null?void 0:s.tourWait;if(s&&(f==null?void 0:f.interaction)==="delay"&&f.ms!==void 0&&!o.has(n.block.id)){let i=window.setTimeout(()=>{n.continue(),o.delete(n.block.id)},f.ms);o.set(n.block.id,{timeoutId:i,stepId:s.id})}})},[r,o]),null};E();var le=require("react/jsx-runtime"),uo=()=>{let e=ve();return(0,le.jsx)(le.Fragment,{children:e.map(t=>(0,le.jsx)(he,{block:t},me(t)))})};var J=require("react");E();E();var fo=require("react"),xe=class extends fo.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0}}componentDidCatch(t,o){I.error("ErrorBoundary caught an error:",t,o)}render(){return this.state.hasError?this.props.fallback:this.props.children}};var Ce=require("react/jsx-runtime"),pr=(0,J.lazy)(()=>Promise.resolve().then(()=>(zo(),Vo))),Ho=e=>{let[t,o]=(0,J.useState)(!0);return(0,J.useEffect)(()=>{o(!1)},[]),t?null:(0,Ce.jsx)(cr,b({},e))},cr=r=>{var n=r,{enabled:e,onDebugKeydown:t}=n,o=ot(n,["enabled","onDebugKeydown"]);let[s,f]=(0,J.useState)({enabled:yt(e),forceOpen:!1});return(0,J.useEffect)(()=>{let i=c=>{(t!=null?t:wt)(c)&&f(p=>{let g=!p.enabled;return sessionStorage.setItem(Ee,String(g)),g?I.info("Debug mode enabled"):I.info("Debug mode disabled"),{enabled:g,forceOpen:g}})};return addEventListener("keydown",i),()=>{removeEventListener("keydown",i)}},[t]),s.enabled?(0,Ce.jsx)(xe,{children:(0,Ce.jsx)(pr,b({forceOpen:s.forceOpen},o))}):null};var X=require("react/jsx-runtime"),_o=e=>ur(e)?(0,X.jsx)(Wt,{children:(0,X.jsx)(dr,b({},e))}):e.children,ur=e=>typeof e.userId=="string",dr=({children:e,apiUrl:t="https://api.flows-cloud.com",environment:o,organizationId:r,userId:n,components:s,tourComponents:f,userProperties:i={},language:c,debug:l,onDebugShortcut:p,LinkComponent:g})=>{j.apiUrl=t,j.environment=o,j.organizationId=r,j.userId=n;let{blocks:a,error:u,wsError:d,removeBlock:v,updateBlock:w}=ao({apiUrl:t,environment:o,organizationId:r,userId:n,userProperties:i,language:c}),P=so({blocks:a,removeBlock:v});return(0,Wo.useEffect)(()=>{window.__flows_LinkComponent=g},[g]),(0,X.jsxs)(We.Provider,{value:{userProperties:i,blocks:a,components:s,runningTours:P,tourComponents:f,removeBlock:v,updateBlock:w},children:[e,(0,X.jsx)(uo,{}),(0,X.jsx)(co,{}),(0,X.jsx)(Ho,{enabled:l,blocksError:u,wsError:d,environment:o,organizationId:r,userId:n,userProperties:i,onDebugKeydown:p})]})};var fr=()=>D({name:"reset-progress"}),gr=e=>D({name:"reset-progress",workflowId:e}),mr=e=>D({name:"workflow-start",blockKey:e});