userflow.js-self-hosted 0.1.1012652 → 0.1.1012662

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/BuilderBar.js CHANGED
@@ -1,2 +1,2 @@
1
- import{R as e,r as t}from"./vendor.react.js";import{F as I}from"./Frame.js";import{S as v}from"./logomark.js";import{o as F}from"./vendor.obj-str.js";import{f as L,a as k}from"./vendor.fortawesome.pro-light-svg-icons.js";import{G as b}from"./userflow.js";import{a as B,D}from"./stylesheets.js";import{u as N}from"./use-window-resize.js";import"./vendor.core-js.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[n]="cf68ad38-d2c0-4c27-af0c-259ab1714a72",r._sentryDebugIdIdentifier="sentry-dbid-cf68ad38-d2c0-4c27-af0c-259ab1714a72")}catch{}})();const _=new URL("builder-ui-host.css",import.meta.url).href,P=new URL("builder-ui-frame.css",import.meta.url).href,p="builderBarPos",O=e.forwardRef(({onReadyChange:r,children:n,buttons:m},y)=>{const{loaded:h}=B(window,_),[E,S]=t.useState(!1),o=h&&E,u=t.useRef(!1);t.useEffect(()=>{o&&!u.current&&r&&(u.current=!0,r(!0))},[o,r]);const i=t.useRef(null),[s,g]=t.useState(null),[l,w]=t.useState(()=>b.getItem(p)==="top"?"top":"bottom"),R=t.useCallback(a=>{w(a),b.setItem(p,a)},[]),f=t.useRef(0),d=t.useCallback(()=>{const a=i.current;if(!a||!s||!o)return;const c=s.clientHeight;c!==f.current&&(f.current=c,a.style.setProperty("height",c+"px","important"))},[o,s]);return t.useLayoutEffect(()=>{d()}),N(d),t.useImperativeHandle(y,()=>({getFrame:()=>i.current,getRootEl:()=>s}),[s]),e.createElement(e.Fragment,null,e.createElement(I,{className:F({"userflowjs-builder-bar":!0,"userflowjs-builder-bar--top":l==="top"}),style:{visibility:o?void 0:"hidden",animation:o?void 0:"none"},elRef:i,stylesheet:P,onStylesheetsLoad:S,title:"Builder bar"},o&&e.createElement("div",{className:"root",ref:g},e.createElement("div",{className:"logomark"},e.createElement(v,null)),e.createElement("div",{className:"main"},n),e.createElement("div",{className:"buttons"},m,e.createElement("button",{key:l,className:"btn btn--square btn--plain-on-dark",onClick:()=>R(l==="top"?"bottom":"top")},e.createElement(D,{icon:l==="top"?L:k,size:20}))))))});export{O as B};
1
+ import{R as e,r as t}from"./vendor.react.js";import{F as I}from"./Frame.js";import{S as v}from"./logomark.js";import{o as F}from"./vendor.obj-str.js";import{f as L,a as k}from"./vendor.fortawesome.pro-light-svg-icons.js";import{G as b}from"./userflow.js";import{a as B,D}from"./stylesheets.js";import{u as N}from"./use-window-resize.js";import"./vendor.core-js.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[n]="b7bda0bf-f3d4-41db-a416-71d58c9c0826",r._sentryDebugIdIdentifier="sentry-dbid-b7bda0bf-f3d4-41db-a416-71d58c9c0826")}catch{}})();const _=new URL("builder-ui-host.css",import.meta.url).href,P=new URL("builder-ui-frame.css",import.meta.url).href,p="builderBarPos",O=e.forwardRef(({onReadyChange:r,children:n,buttons:m},y)=>{const{loaded:h}=B(window,_),[E,S]=t.useState(!1),o=h&&E,u=t.useRef(!1);t.useEffect(()=>{o&&!u.current&&r&&(u.current=!0,r(!0))},[o,r]);const i=t.useRef(null),[s,g]=t.useState(null),[l,w]=t.useState(()=>b.getItem(p)==="top"?"top":"bottom"),R=t.useCallback(a=>{w(a),b.setItem(p,a)},[]),d=t.useRef(0),f=t.useCallback(()=>{const a=i.current;if(!a||!s||!o)return;const c=s.clientHeight;c!==d.current&&(d.current=c,a.style.setProperty("height",c+"px","important"))},[o,s]);return t.useLayoutEffect(()=>{f()}),N(f),t.useImperativeHandle(y,()=>({getFrame:()=>i.current,getRootEl:()=>s}),[s]),e.createElement(e.Fragment,null,e.createElement(I,{className:F({"userflowjs-builder-bar":!0,"userflowjs-builder-bar--top":l==="top"}),style:{visibility:o?void 0:"hidden",animation:o?void 0:"none"},elRef:i,stylesheet:P,onStylesheetsLoad:S,title:"Builder bar"},o&&e.createElement("div",{className:"root",ref:g},e.createElement("div",{className:"logomark"},e.createElement(v,null)),e.createElement("div",{className:"main"},n),e.createElement("div",{className:"buttons"},m,e.createElement("button",{key:l,className:"btn btn--square btn--plain-on-dark",onClick:()=>R(l==="top"?"bottom":"top")},e.createElement(D,{icon:l==="top"?L:k,size:20}))))))});export{O as B};
2
2
  //# sourceMappingURL=BuilderBar.js.map
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterAssistantChat.js","vendor.react.js","vendor.core-js.js","vendor.object-assign.js","userflow.js","vendor.phoenix.js","vendor.uuid.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.dompurify.js","vendor.marked.js","vendor.obj-str.js","use-selector-element-monitoring.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.react-dom.js","vendor.scheduler.js","flow-host.styl.js","Frame.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","use-element-rect.js","vendor.bignumber.js.js"])))=>i.map(i=>d[i]);
2
- import{k as N,C as W,l as Ce,u as le,m as qt,n as tt,o as nt,E as Kt,p as Y,q as Qt,r as Zt,s as Gt,a as rt,t as st,v as Jt,w as ot,_ as Xt}from"./userflow.js";import{r as l,R as e}from"./vendor.react.js";import{u as T,i as ue}from"./client-context.js";import{f as Yt,u as en,w as tn,C as nn}from"./flow-host.styl.js";import{S as rn,b as Be,R as $,h as sn,s as De,a as q,n as on}from"./use-selector-element-monitoring.js";import{g as R}from"./flow-condition-types.js";import{D as S,u as Fe,a as cn,g as gt}from"./stylesheets.js";import{F as He}from"./Frame.js";import{o as H}from"./vendor.obj-str.js";import{M as ke,d as ct,e as at}from"./roots.js";import{u as an}from"./use-window-resize.js";import{S as ln}from"./logomark.js";import"./vendor.core-js.js";import{f as un,C as dn}from"./ChecklistUI.js";import{I as mn,J as Pe,K as fn,L as hn,M as wn,N as Ct,O as Z,z as En,P as bn,Q as pn,R as vn}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as gn,B as Cn}from"./FlowChrome.js";import{u as kn}from"./use-element-rect.js";import{B as jn}from"./vendor.bignumber.js.js";import{u as G}from"./vendor.react-i18next.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="3019e220-c5f0-4624-9fa6-0f8c247d36fa",t._sentryDebugIdIdentifier="sentry-dbid-3019e220-c5f0-4624-9fa6-0f8c247d36fa")}catch{}})();function Nn(t,n,r){return t.resourceCenterAutoDividers?lt(n)||lt(r):!1}function lt(t){return t!==N.ACTION&&t!==N.ANNOUNCEMENTS&&t!==N.ASSISTANT&&t!==N.CONTACT&&t!==N.FLOWS&&t!==N.KNOWLEDGE_BASE&&t!==N.SUBPAGE}const d=window,je={[W.CRISP]:{configure:({onShow:t,onHide:n})=>{yn();let r=!1,s=!1;const c=()=>{r||s?(d.$crisp.push(["do","chat:show"]),t()):(d.$crisp.push(["do","chat:hide"]),n())},a=()=>{r=!0,c()};d.$crisp.push(["on","chat:opened",a]);const o=()=>{r=!1,c()};d.$crisp.push(["on","chat:closed",o]);const i=()=>{s=!0,c()};d.$crisp.push(["on","message:received",i]);const m=()=>{const E=document.getElementById("crisp-chatbox");if(!E||window.getComputedStyle(E).display!=="block")return!1;const h=E.querySelector('[data-id="new_messages"]');return!(!h||window.getComputedStyle(h).display!=="block")},u=()=>{const E=m();E!==s&&(s=E,c())},g=window.setInterval(u,200);return()=>{d.$crisp.push(["off","chat:opened",a]),d.$crisp.push(["off","chat:closed",o]),d.$crisp.push(["off","message:received",i]),window.clearInterval(g)}},show:()=>{d.$crisp.push(["do","chat:show"]),d.$crisp.push(["do","chat:open"])},hide:()=>{d.$crisp.push(["do","chat:hide"]),d.$crisp.push(["do","chat:close"])}},[W.CUSTOM]:{configure:()=>()=>{},show:({block:t})=>{try{new Function(`"use strict";
3
- `+t.chatCode)()}catch(n){console.error(`Userflow.js: Showing custom chat provider failed. Code: ${t.chatCode}`,n)}},hide:()=>{}},[W.FRESHCHAT]:{configure:({onShow:t,onHide:n})=>{if(!d.fcWidget)throw new Error("Freshchat is not installed");let r=!1,s=!1;const c=()=>{r||s?t():n()},a=()=>{r=!0,c()};d.fcWidget.on("widget:opened",a);const o=()=>{r=!1,c()};d.fcWidget.on("widget:closed",o);const i=()=>{const u=!!document.querySelector("#fc_frame.h-open-notify");u!==s&&(s=u,c())},m=window.setInterval(i,200);return d.fcWidget.on("unreadCount:notify",i),()=>{d.fcWidget.off("widget:opened",a),d.fcWidget.off("widget:closed",o),d.fcWidget.off("unreadCount:notify",i),window.clearInterval(m)}},show:()=>{d.fcWidget.open()},hide:()=>{d.fcWidget.close()}},[W.HELPSCOUT]:{configure:({onShow:t,onHide:n})=>{if(!d.Beacon)throw new Error("Help Scout is not installed");Sn();let r=!1,s=!1;const c=()=>{r||s?(dt(),t()):(Ne(),n())},a=()=>{r=!0,c()};d.Beacon("on","open",a),d.Beacon("info")?.status.isOpened&&a();const o=()=>{r=!1,c()};d.Beacon("on","close",o);const i=()=>{const u=!!document.querySelector(".BeaconNotificationsFrame");u!==s&&(s=u,c())},m=window.setInterval(i,200);return()=>{d.Beacon("off","open",a),d.Beacon("off","close",o),window.clearInterval(m)}},show:()=>{dt(),d.Beacon("open")},hide:()=>{Ne(),d.Beacon("close")}},[W.HUBSPOT]:{configure:({onShow:t,onHide:n})=>{const r=()=>{const a=document.getElementById("hubspot-messages-iframe-container");if(!d.HubSpotConversations||!a)return;window.clearInterval(c),In();let o=!1,i=!1;const m=()=>{o||i?(ye(),t()):(Se(),n())},u=()=>{const h=!!document.querySelector("#hubspot-messages-iframe-container .hs-shadow-container.active");h!==o&&(o=h,m())},g=new ke(u);g.observe(a,{attributes:!0,subtree:!0,attributeFilter:["class"]}),u();const E=({unreadCount:h})=>{const f=h>0;f!==i&&(i=f,m())};d.HubSpotConversations.on("unreadConversationCountChanged",E),s=()=>{g.disconnect(),d.HubSpotConversations.off("unreadConversationCountChanged",E)}};let s=()=>{window.clearInterval(c)};const c=window.setInterval(r,100);return r(),()=>{s()}},show:()=>{ye(),d.HubSpotConversations.widget.open()},hide:()=>{Se(),d.HubSpotConversations.widget.close()}},[W.INTERCOM]:{configure:({onShow:t,onHide:n})=>{if(!d.Intercom)throw new Error("Intercom is not installed");return An(),Ie.add(t),Ae.add(n),()=>{Ie.delete(t),Ae.delete(n)}},show:()=>{kt(),d.Intercom("show")},hide:()=>{Re(),d.Intercom("hide")}},[W.ZENDESK]:{configure:({onShow:t,onHide:n})=>{if(!d.zE)throw new Error("Zendesk is not installed");Rn();let r=!1,s=!1;const c=()=>{r||s?(d.zE("webWidget","show"),t()):(d.zE("webWidget","hide"),n())},a=()=>{r=!0,s=!1,c()};Te.add(a);const o=()=>{r=!1,s=!1,c()};Le.add(o);const i=m=>{const u=m>0;u!==s&&(s=u,c())};return _e.add(i),()=>{Te.delete(a),Le.delete(o),_e.delete(i)}},show:()=>{d.zE("webWidget","show"),d.zE("webWidget","open")},hide:()=>{d.zE("webWidget","hide"),d.zE("webWidget","close")}},[W.ZENDESK_MESSENGER]:{configure:({onShow:t,onHide:n})=>{if(!d.zE)throw new Error("Zendesk is not installed");const r=()=>{t()},s=()=>{n()};return xe.add(r),Me.add(s),Tn(),()=>{xe.delete(r),Me.delete(s)}},show:()=>{d.zE("messenger","open")},hide:()=>{d.zE("messenger","close")}}};let ut=!1;function yn(){ut||(ut=!0,d.$crisp||(d.$crisp=[]),d.$crisp.push(["do","chat:hide"]))}let it=!1;function Sn(){it||(it=!0,Ne())}function dt(){d.Beacon("config",{display:{style:"icon"}})}function Ne(){d.Beacon("config",{display:{style:"manual"}})}let mt=!1,Ue=!1;function In(){mt||(mt=!0,Ue?ye():Se())}function ye(){Ue=!0,document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","visible","important")}function Se(){Ue=!1,document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","hidden","important")}let ft=!1,Ie=new Set,Ae=new Set;function An(){if(ft)return;ft=!0,Re();let t=!1,n=!1;const r=()=>{kt();for(const o of Ie)o()},s=()=>{Re();for(const o of Ae)o()},c=()=>{t||n?r():s()};d.Intercom("onShow",()=>{t=!0,c()}),d.Intercom("onHide",()=>{t=!1,c()});const a=()=>{const o=!!document.querySelector('iframe[name="intercom-borderless-frame"], iframe[name="intercom-notifications-frame"]');n!==o&&(n=o,c())};d.Intercom("onUnreadCountChange",()=>{a()}),window.setInterval(a,200)}function kt(){d.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function Re(){d.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let ht=!1,Te=new Set,Le=new Set,_e=new Set;function Rn(){ht||(ht=!0,d.zE("webWidget","hide"),d.zE("webWidget","close"),d.zE("webWidget:on","open",()=>{for(const t of Te)t()}),d.zE("webWidget:on","close",()=>{for(const t of Le)t()}),d.zE("webWidget:on","chat:unreadMessages",t=>{for(const n of _e)n(t)}))}let wt=!1,xe=new Set,Me=new Set;function Tn(){wt||(wt=!0,d.zE("messenger:on","open",function(){for(const t of xe)t()}),d.zE("messenger:on","close",function(){for(const t of Me)t()}))}const Ln=t=>l.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},t),l.createElement("path",{fill:"currentColor",d:"M24.049 79.74h36.003c8.185 0 15.985-6.621 17.43-14.814l6.091-34.556h3.997c8.149 0 13.645 6.63 12.2 14.815l-7.051 40C91.274 93.363 83.474 100 75.288 100h-40c-8.185 0-13.645-6.667-12.2-14.815l.96-5.444Z"}),l.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12.437 69.63h40c8.148 0 15.978-6.637 17.422-14.815l7.052-40C78.355 6.63 72.896 0 64.711 0h-40C16.533 0 8.726 6.63 7.281 14.815l-7.052 40C-1.215 62.963 4.252 69.63 12.437 69.63Zm33.628-33.798c3.756-2.064 8.725-4.795 9.907-11.844C57.385 15.458 50.065 8.983 42.168 9c-7.452 0-12.771 3.195-17.508 8.892-.858 1.034-.884 2.45-.053 3.212l3.472 3.196c.847.767 2.25.589 3.176-.406 2.842-3.068 4.869-4.83 8.51-4.83 2.864 0 6.077 1.934 5.59 4.847-.37 2.223-2.292 3.334-5.4 5.001l-.28.151c-3.582 1.92-8.134 4.362-9.124 10.247l-.16.956c-.055.28-.05.571.014.85.065.278.188.538.362.76.173.222.391.4.639.522.247.121.518.183.79.18h6.744a2.709 2.709 0 0 0 1.712-.688c.481-.426.81-1.01.934-1.657l.095-.556c.266-1.582 2.101-2.59 4.384-3.845ZM32.837 59c3.552 0 6.955-3.034 7.58-6.769.63-3.729-1.742-6.763-5.293-6.763-3.552 0-6.934 3.028-7.58 6.763C26.9 55.966 29.286 59 32.837 59Z"})),P=({center:t,fadeIn:n})=>e.createElement("div",{className:H({"userflowjs-spinner":!0,"userflowjs-spinner--center":!!t,"userflowjs-spinner--fade-in":!!n})},e.createElement("svg",{viewBox:"0 0 24 24",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},e.createElement("circle",{className:"userflowjs-spinner__bg",fill:"none",cx:12,cy:12,r:10,style:{strokeWidth:"4px"}}),e.createElement("circle",{className:"userflowjs-spinner__fill",fill:"none",cx:12,cy:12,r:10,transform:"translate(12, 12) rotate(-90) translate(-12, -12)",style:{strokeWidth:"4px",strokeDasharray:10*2*Math.PI*.25+"px, 1000"}})));function ie({message:t,skip:n}){const r=T(),[s,c]=l.useState(!0),[a,o]=l.useState(!1),[i,m]=l.useState(null),[u,g]=l.useState(null),[E,h]=l.useState(null),f=l.useRef(0),b=l.useRef(null),v=l.useRef(()=>{});return l.useEffect(()=>{if(n)return;const C=JSON.stringify(t);if(C===b.current)return;b.current=C;const I=++f.current;let j,k;const _=async()=>{c(!0);try{k=t;const L=await r.send(t,{handlesRejection:!0});if(I!==f.current)return;j=L,m(j),g(t),h(null)}catch(L){if(I!==f.current)return;h(L)}finally{c(!1)}};let U=!1;v.current=async(L,J)=>{if(!U){U=!0,o(!0);try{const M=L(j,k);k=M;const te=await r.send(M,{handlesRejection:!0});if(I!==f.current)return;j=J(j,te),m(j),h(null)}catch(M){if(I!==f.current)return;h(M)}finally{U=!1,o(!1)}}},_()},[n,r,t]),{loading:s,loadingMore:a,data:i,messageForData:u,error:E,loadMore:v.current}}const _n=200;function We(t,n){const[r,s]=l.useState(t),c=l.useRef(void 0),a=l.useCallback(i=>{window.clearTimeout(c.current),s(i),n(i)},[n]),o=l.useCallback(i=>{window.clearTimeout(c.current),s(i),c.current=window.setTimeout(()=>{n(i)},_n)},[n]);return l.useEffect(()=>()=>{window.clearTimeout(c.current)},[]),[r,o,a]}const xn=({textareaRef:t,value:n,onChange:r,onBlur:s,onKeyDown:c,onMouseDown:a,placeholder:o,disabled:i,readOnly:m,className:u,mirrorClassName:g,textareaClassName:E,children:h})=>{let f=n||o||"";(f===""||f.endsWith(`
4
- `))&&(f+=" "),u=u||"growing-textarea",g=g||u+"__mirror";const[b,v]=l.useState(!1);return e.createElement("div",{className:u},e.createElement("div",{className:g+" "+(E||"")},f),e.createElement("textarea",{ref:t,value:n,onChange:C=>r&&r(C.target.value),onBlur:s,onKeyDown:C=>{if(C.key==="Enter"&&b){C.preventDefault();return}c&&c(C)},onMouseDown:a,placeholder:o,disabled:i,readOnly:m,className:E,onCompositionStart:()=>v(!0),onCompositionEnd:()=>v(!1)}),h)},Mn=({textareaRef:t,value:n,onChange:r,onSubmit:s,placeholder:c,readOnly:a})=>{const o=()=>{s&&s()};return e.createElement("div",{className:"userflowjs-assistant-chat-input"},e.createElement(xn,{textareaRef:t,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:c,readOnly:a,value:n||"",onChange:r,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),o())}}),e.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>o()},e.createElement(S,{icon:mn})))};function Bn(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function jt(t){return Ce.linkUrlDecorator?Ce.linkUrlDecorator(t):t}const Et=5,Dn=async()=>(await Xt(async()=>{const{ResourceCenterAssistantChat:t}=await import("./ResourceCenterAssistantChat.js");return{ResourceCenterAssistantChat:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]))).ResourceCenterAssistantChat,bt=({session:t,isOpen:n,flowSession:r,checklistSession:s})=>{const c=T(),{t:a}=G(),{company:o}=t.flow,{version:i}=t,m=i.resourceCenter,u=Fe(i.theme),g=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;l.useEffect(()=>{ue.changeLanguage(g)},[g]);const{loaded:E}=cn(window,Yt,u),[h,f]=l.useState(!1),b=E&&h,[v,C]=l.useState(ct()),[I,j]=l.useState(at()),k=l.useCallback(()=>{C(ct()),j(at())},[]);an(k);const{zIndex:_,bringToFront:U}=en(),[L,J]=l.useState(null),[M,te]=l.useState(null),[z,Lt]=l.useState(null),de=l.useRef(null),[X,_t]=l.useState(null),[$e,xt]=l.useState(null),[ze,Mt]=l.useState(null),[Bt,Dt]=l.useState(0),[Ft,Ht]=l.useState(0),me=l.useCallback(()=>{M&&Dt(Math.round(M.offsetWidth)),Ht(Math.round((z?.offsetHeight||0)+(X?.offsetHeight||0)+($e?.offsetHeight||0)+(ze?.offsetHeight||0)))},[M,z,X,$e,ze]);l.useLayoutEffect(()=>{if(!L||typeof ke!="function")return;const w=new ke(()=>{me()});return w.observe(L,{childList:!0,attributes:!0,subtree:!0}),()=>{w.disconnect()}},[L,me]),l.useLayoutEffect(()=>{me()});const[Ve,qe]=l.useState(!1),fe=l.useRef(),ne=l.useCallback(()=>{qe(!0),window.clearTimeout(fe.current),fe.current=window.setTimeout(()=>{qe(!1)},u.resourceCenterTransitionDuration)},[u.resourceCenterTransitionDuration]);l.useEffect(()=>()=>{window.clearTimeout(fe.current)},[]);const re=l.useCallback(()=>{U(),ne(),c.openResourceCenter()},[U,c,ne]),he=l.useCallback(()=>{ne(),c.closeResourceCenter()},[c,ne]),[Ke,K]=l.useState(!1);l.useEffect(()=>{if(Ke){if(!Bn())if(n){const w='button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea';let y=X?.querySelector(".userflowjs-assistant-chat-input textarea")||X?.querySelector(w)||z?.querySelector(w);if(y){const B=y.closest&&y.closest(".userflowjs-resource-center-checklist")||null;B?un(B):y.focus({preventScroll:!0})}}else M?.focus({preventScroll:!0});K(!1)}},[Ke,n,X,z,M]),l.useEffect(()=>{const w=L?.ownerDocument.defaultView;if(!n||!w)return;const y=B=>{B.key==="Escape"&&(he(),K(!0))};return w.addEventListener("keydown",y),()=>w.removeEventListener("keydown",y)},[n,L,K,he]);const[p,we]=l.useState(()=>Un(t,le.getItem(`resourceCenterRoute:v1:${t.id}`))),D=l.useCallback((w,y)=>{we(w);const B=Pn(w);B?le.setItem(`resourceCenterRoute:v1:${t.id}`,B):le.removeItem(`resourceCenterRoute:v1:${t.id}`),y?.detail===0&&K(!0)},[t.id]);l.useEffect(()=>{if(!t.draftMode||!p||!("block"in p)||!p.block)return;const w=m.blocks.find(y=>y.cvid===p.block.cvid);w?JSON.stringify(w)!==JSON.stringify(p.block)&&we({...p,block:w}):we(null),p.block},[t.draftMode,m,p]);const se=l.useMemo(()=>m.blocks.filter(w=>!(w.type===N.CHECKLIST&&!s||w.type===N.DIVIDER&&u.resourceCenterAutoDividers||w.hiddenWhenFlowsActive&&w.hiddenWhenFlowsActive.some(y=>y===r?.flow.id||y===s?.flow.id))),[m,r,s,u.resourceCenterAutoDividers]),Ee=l.useMemo(()=>yt(se),[se]),be=l.useMemo(()=>!s||!m.blocks.some(w=>w.type===N.CHECKLIST)?0:qt(s),[m,s]),x=l.useMemo(()=>m.blocks.find(w=>w.type===N.CONTACT&&w.chatEnabled&&w.chatProvider),[m]),[Pt,Qe]=l.useState(!1),oe=l.useCallback(()=>{c.closeResourceCenter(),x&&x.chatProvider!==W.CUSTOM&&Qe(!0)},[c,x]),ce=l.useCallback(()=>{Qe(!1)},[]),Ze=l.useCallback(()=>{if(x)try{je[x.chatProvider].hide({block:x}),ce()}catch(w){console.error(`Userflow.js: Error when hiding ${x.chatProvider}:`,w)}},[x,ce]);l.useEffect(()=>{if(!x)return;Ce.autoHide3pDisabled=!0;const w=je[x.chatProvider];try{const y=w.configure({block:x,onShow:oe,onHide:ce});return()=>{y()}}catch(y){console.error(`Userflow.js: Error when configuring ${x.chatProvider}:`,y);return}},[x,oe,ce]),l.useEffect(()=>{n&&Ze()},[Ze,n]);const F=l.useMemo(()=>m.blocks.find(w=>w.type===N.ANNOUNCEMENTS),[m]),Ut=!!p&&(p.kind==="search"||p.kind==="flows"||p.kind==="knowledgeBase"),Ge=p?.kind==="assistant"||p?.kind==="announcementList"||p?.kind==="announcementShow",pe=Math.min(Ge?u.resourceCenterFullWidth:u.resourceCenterWidth,v-2*u.resourceCenterPaddingX),Wt=540,Ot=720,$t={zIndex:u.resourceCenterZIndex!=null?u.resourceCenterZIndex:n?_:tn(nn),position:b?void 0:"absolute",visibility:b&&!Pt?void 0:"hidden"},zt={width:(n?pe:Bt)+"px",height:n?Math.min(Ut?Wt:Ge?Ot:Ft,I-2*u.resourceCenterPaddingY,u.resourceCenterMaxHeight==null?Number.MAX_VALUE:u.resourceCenterMaxHeight)+"px":void 0},[Vt,Je]=l.useState(!1),Xe=()=>{re(),K(!0)},Ye=u.resourceCenterDisplayChecklistProgress&&s&&be>0?e.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},be,e.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let ae="",ve="";return u.resourceCenterLauncherTextMode===tt.CHECKLIST_OVERRIDE&&s&&be>0?ae=s.version.checklist?.launcherText||"Get Started":u.resourceCenterLauncherTextMode!==tt.NONE&&(ve=m.buttonText),e.createElement(rn.Provider,{value:t},e.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center-app userflowjs-theme-root",style:gt(u),dir:ue.dir()},e.createElement("div",{className:H({"userflowjs-resource-center":!0,"userflowjs-resource-center--fixed":!0,[`userflowjs-resource-center--placement-${u.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0}),style:$t},e.createElement("div",{className:"userflowjs-resource-center-frame-wrapper",onMouseEnter:()=>Je(!0),onMouseLeave:()=>Je(!1)},e.createElement(He,{className:H({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--animating":Ve,"userflowjs-resource-center-frame--open":n,"userflowjs-resource-center-frame--closed":!n}),style:zt,stylesheet:Be,theme:u,onStylesheetsLoad:f,title:"Resource center"},b&&e.createElement(e.Fragment,null,e.createElement("div",{ref:J,className:H({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${u.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":Ve,"userflowjs-resource-center-frame-root--open":n,"userflowjs-resource-center-frame-root--closed":!n}),role:n?"dialog":void 0,"aria-label":n?m.headerText:void 0},e.createElement("div",{className:"userflowjs-resource-center-launcher-container"},e.createElement("button",{ref:te,className:H({"userflowjs-resource-center-launcher-button":!0,"userflowjs-resource-center-launcher-button--hover":Vt}),onClick:Xe,"aria-label":`Open ${m.headerText}`},Ye,ae&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ae),(Ye||ae)&&e.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),ve&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ve),e.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},u.resourceCenterLauncherIconType===nt.PLAINTEXT?"?":u.resourceCenterLauncherIconType===nt.DEFAULT?e.createElement(Ln,null):u.rcIconAsset&&u.rcIconAsset.assetUrl?e.createElement("img",{src:u.rcIconAsset.assetUrl,className:"company-icon",style:{height:`${u.rcIconSize}px`,width:`${u.rcIconSize}px`}}):e.createElement("span",null)))),e.createElement("div",{ref:de,className:"userflowjs-resource-center-body",style:{width:pe+"px"}},e.createElement("div",{ref:_t,className:H({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":p?.kind!=="assistant","userflowjs-resource-center-body-content--same-background":u.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":o.resourceCenterBranding})},n&&e.createElement(e.Fragment,null,p?p.kind==="search"?e.createElement(Wn,{session:t,navigate:D}):p.kind==="email"?e.createElement(On,{block:p.block,session:t}):p.kind==="phone"?e.createElement($n,{block:p.block,session:t}):p.kind==="flows"?e.createElement(zn,{block:p.block,initialQ:p.initialQ,session:t,navigate:D}):p.kind==="knowledgeBase"?e.createElement(Vn,{block:p.block,initialQ:p.initialQ,session:t,bodyRef:de}):p.kind==="subpage"?e.createElement(qn,{block:p.block,session:t}):p.kind==="announcementList"||p.kind==="announcementShow"?e.createElement(Kn,{bodyRef:de,session:t,route:p,navigate:D}):p.kind==="assistant"?e.createElement(Gn,{block:p.block,initialUserContent:p.initialUserContent,session:t,navigate:D,chatBlock:x,onChatShow:oe}):null:e.createElement(e.Fragment,null,se.map((w,y)=>{const B=ee[w.type],et=se[y+1];return B?e.createElement(e.Fragment,{key:w.id},e.createElement(B.View,{session:t,flowSession:r,checklistSession:s,block:w,navigate:D,onChatShow:oe}),et&&Nn(u,w.type,et.type)&&e.createElement("div",{className:"userflowjs-resource-center-divider"})):null}))))),o.resourceCenterBranding&&e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:xt},e.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+o.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},e.createElement(ln,null),e.createElement("div",null,"Made with Userflow")))),t.draftMode&&e.createElement("div",{className:"userflowjs-resource-center-preview"},e.createElement("div",{ref:Mt,className:"userflowjs-resource-center-preview-content"},e.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),e.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{c.endFlow(t,{endReason:Kt.USER_CLOSED})}},e.createElement(S,{icon:Pe})))),e.createElement("div",{className:"userflowjs-resource-center-header",style:{width:pe+"px"}},e.createElement("div",{ref:Lt,className:"userflowjs-resource-center-header-content"},p==null?e.createElement("div",{className:"userflowjs-resource-center-header-text"},m.headerText):e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:w=>D(p?.kind==="announcementShow"?{kind:"announcementList",block:p.block}:null,w)},e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(S,{icon:fn})),e.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},a("resource_center.back"))),e.createElement("div",{className:"flex-1"}),Ee.length>0&&e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let w={kind:"search"};if(Ee.length===1){const y=Ee[0],B=ee[y.type];B.routeTo&&(w=B.routeTo({block:y}))}p?.kind==="search"?D(null):(A(c,t,null,"Search icon"),D(w))},"aria-label":"Search"},e.createElement(S,{icon:hn})),e.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:w=>{he(),w.detail===0&&K(!0)},"aria-label":`Close ${m.headerText}`},e.createElement(S,{icon:wn}))))))),!n&&!r&&F&&F.unreadAnnouncementCount>0&&e.createElement(Fn,{theme:u,count:F.unreadAnnouncementCount,onClick:Xe})),!n&&!r&&F?.popoutAnnouncement&&e.createElement(pt,{session:t,open:re,navigate:D,block:F}),!n&&!r&&F?.boosterAnnouncement&&F?.boosterAnnouncement.level===Y.MODAL&&e.createElement(Hn,{session:t,open:re,navigate:D,block:F}),!n&&!r&&F?.boosterAnnouncement&&F?.boosterAnnouncement.level===Y.TOAST&&e.createElement(pt,{session:t,open:re,navigate:D,block:F,rcPlacement:u.resourceCenterPlacement}))))},Fn=({theme:t,count:n,onClick:r})=>{const[s,c]=l.useState(!1);return e.createElement(He,{className:H({"userflowjs-resource-center-launcher-unread-badge":!0}),noScroll:!0,style:{position:s?void 0:"absolute",visibility:s?void 0:"hidden"},stylesheet:Be,theme:t,onStylesheetsLoad:c,title:"Resource center unread badge"},e.createElement(Nt,{count:n,onClick:r}))},Nt=({count:t,onClick:n})=>{let r=null;return t>9&&(t=9,r=e.createElement("span",{className:"userflowjs-unread-badge-plus"},"+")),e.createElement("div",{className:H({"userflowjs-unread-badge":!0,"userflowjs-unread-badge--clickable":!!n}),onClick:n},e.createElement("span",null,t),r)},pt=({session:t,open:n,navigate:r,block:s,rcPlacement:c})=>{const a=l.useRef(null),o=s.popoutAnnouncement??s.boosterAnnouncement,i=Fe(o.theme),m=i.toastPlacement,u=!!s.boosterAnnouncement,g=m===c;let E=null,h=null;o&&(E=o.toastAutoDismiss??i.toastAutoDismiss,h=o.toastWidth?o.toastWidth:i.toastWidth);const f=T(),[b,v]=l.useState(!1),{height:C,setEl:I}=kn();l.useEffect(()=>{const L=a.current;if(!L||E===null)return;const J=Date.now(),M=()=>{const z=1-(Date.now()-J)/(new jn(E||0).toNumber()*1e3);z<=0?(L.style.width="0%",o&&O(f,o)):(L.style.width=`${z*100}%`,requestAnimationFrame(M))};return requestAnimationFrame(M),()=>{L&&(L.style.width="0%")}},[a.current,E,f,o,O]);const j=()=>{o&&O(f,o)},k=20,_=l.useMemo(()=>CSS.supports("height: 100dvh")?"dvh":"vh",[]),U=()=>{u&&o&&(O(f,o),A(f,t,s,o.title),r({kind:"announcementShow",block:s,announcementId:o.id}),n())};return o?e.createElement("div",{className:H({"userflowjs-resource-center-popout":!u,"userflowjs-resource-center-toast":u,[`userflowjs-resource-center-toast--${m?.toLowerCase().replace(/_/g,"-")}`]:!g&&!!m&&u}),style:gt(i)},e.createElement(He,{className:H({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${C}px, 100${_} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - ${k}px)`,position:b?void 0:"absolute",visibility:b?void 0:"hidden",...h&&u?{width:h}:{}},stylesheet:Be,theme:i,onStylesheetsLoad:v,title:"Resource center popout"},u&&e.createElement("div",{className:"userflowjs-bubble-progress--default"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",ref:a})),e.createElement("div",{ref:I,className:"userflowjs-resource-center-popout-frame-root",style:{cursor:u?"pointer":"auto",padding:u&&i.toastPadding||void 0}},e.createElement("div",{onClick:U},e.createElement("h2",{className:"userflowjs-announcement-title"},e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,o.title)),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},Oe(o.time))),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement($,{doc:o.content,buttons:o.buttons,lookupAttribute:R(o.data)})),!u&&e.createElement(e.Fragment,null,o.moreEnabled&&e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>{O(f,o),A(f,t,s,o.title),r({kind:"announcementShow",block:s,announcementId:o.id}),n()}},e.createElement("div",null,(o.moreEnabled?o.moreButtonText:null)||"Read more"),!u&&e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(S,{icon:Ct})))))),u&&o.moreEnabled&&e.createElement("div",{onClick:U,className:"userflowjs-announcement-more--toast"},(o.moreEnabled?o.moreButtonText:null)||"Read more"),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:j,"aria-label":"Dismiss announcement"},e.createElement(S,{icon:Pe}))))),!u&&e.createElement("div",{className:"userflowjs-resource-center-popout-notch"})):null},Hn=({session:t,open:n,navigate:r,block:s})=>{const c=s.boosterAnnouncement,a=T(),o=Fe(c.theme),i=()=>{O(a,c)};return e.createElement(gn,{company:t.flow.company,theme:o,position:"fixed",width:c.modalWidth,stepAppearance:Qt.MODAL,zIndex:o.checklistZIndex,autoHide3pEnabled:!0,onModalBackdropClick:i,noIframe:!0,isModalAnnouncement:!0},e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement("h1",null,c.title),e.createElement($,{doc:c.content,buttons:c.buttons,lookupAttribute:R(c.data)})),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:i,"aria-label":"Dismiss announcement"},e.createElement(S,{icon:Pe}))),c.moreEnabled&&e.createElement("div",{className:"userflowjs-announcement-more--modal"},e.createElement("button",{className:"userflowjs-bubble-button--primary",onClick:()=>{O(a,c),A(a,t,s,c.title),r({kind:"announcementShow",block:s,announcementId:c.id}),n()}},e.createElement("div",null,(c.moreEnabled?c.moreButtonText:null)||"Read more"))))};function yt(t){return t.filter(n=>{const r=ee[n.type];return r.isSearchable?r.isSearchable(n):!!r.search})}const ee={[N.ACTION]:{View:t=>{const{block:n,session:r,flowSession:s,checklistSession:c}=t,a=T(),[o,i]=l.useState(!1),m=s?.id,u=c?.id;return l.useEffect(()=>{i(!1)},[m,u]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:o?void 0:()=>{A(a,r,n);const g=n.actions.find(E=>E.type===Zt.START_FLOW);g?g.otherFlow?.id!==c?.flow.id&&i(!0):a.closeResourceCenter(),sn(a,r,n.actions)},disabled:o},e.createElement(Q,{...t}),e.createElement(V,{...t}),o&&e.createElement(P,null))}},[N.ANNOUNCEMENTS]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=T();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"announcementList",block:n},a)}},n.unreadAnnouncementCount>0?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(Nt,{count:n.unreadAnnouncementCount})):e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(S,{icon:Z})))}},[N.ASSISTANT]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=T(),[a,o]=l.useState("");return n.assistantAppearance===Gt.INPUT?e.createElement("div",{className:"userflowjs-resource-center-assistant-block"},e.createElement(Mn,{value:a,onChange:o,placeholder:De(n.name,{lookupAttribute:R(r.data)}),onSubmit:()=>{A(c,r,n),s({kind:"assistant",block:n,initialUserContent:a})}})):e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{A(c,r,n),s({kind:"assistant",block:n,initialUserContent:""})}},e.createElement(Q,{...t}),e.createElement(V,{...t}))}},[N.CHECKLIST]:{View:({checklistSession:t})=>e.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},e.createElement(dn,{session:t}),e.createElement(Cn,{draftMode:t.draftMode?"CHECKLIST PREVIEW":!1}))},[N.CONTACT]:{View:t=>{const{block:n,session:r,navigate:s,onChatShow:c}=t,a=T(),o=[];return n.emailEnabled&&o.push({icon:bn,label:"Email",isRoute:!0,onClick:i=>{A(a,r,n,"Email"),s({kind:"email",block:n},i)}}),n.phoneEnabled&&o.push({icon:pn,label:"Phone",isRoute:!0,onClick:i=>{A(a,r,n,"Phone"),s({kind:"phone",block:n},i)}}),n.chatEnabled&&o.push({icon:vn,label:"Live-chat",isRoute:!1,onClick:()=>{A(a,r,n,"Chat"),Tt(r,n,c)}}),e.createElement("div",{className:H({"userflowjs-resource-center-block":!0,"userflowjs-resource-center-block--clickable":o.length===1}),onClick:o.length===1?o[0].onClick:void 0},o.length===1&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(S,{icon:o[0].icon})),e.createElement(V,{...t}),o.length>1&&o.map(({icon:i,label:m,onClick:u},g)=>e.createElement("button",{key:g,className:"userflowjs-resource-center-icon-button",onClick:u,"aria-label":m},e.createElement(S,{icon:i}))),o.length===1&&o[0].isRoute&&e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(S,{icon:Z})))}},[N.DIVIDER]:{View:()=>e.createElement("div",{className:"userflowjs-resource-center-divider"})},[N.FLOWS]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=T();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"flows",block:n},a)}},e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(S,{icon:Z})))},routeTo:({block:t,initialQ:n})=>({kind:"flows",block:t,initialQ:n}),isSearchable:t=>!!t.searchEnabled,search:async({client:t,session:n,block:r,q:s})=>{const{flows:c}=await t.send({kind:"ListResourceCenterBlockFlows",sessionId:n.id,blockCvid:r.cvid},{handlesRejection:!0}),a=St(c,s),o=a.slice(0,Et);return{block:r,truncated:o.length===a.length,results:o.map(i=>({kind:"flow",flow:i}))}}},[N.KNOWLEDGE_BASE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=T();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"knowledgeBase",block:n},a)}},e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(S,{icon:Z})))},routeTo:({block:t,initialQ:n})=>({kind:"knowledgeBase",block:t,initialQ:n}),search:async({client:t,session:n,block:r,q:s})=>{const{truncated:c,articles:a}=await t.send({kind:"SearchKnowledgeBase",sessionId:n.id,blockCvid:r.cvid,q:s,offset:0,limit:Et},{handlesRejection:!0});return{block:r,truncated:c,results:a.map(o=>({kind:"article",article:o}))}}},[N.MESSAGE]:{View:({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-block"},e.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},e.createElement($,{doc:t.content,lookupAttribute:R(n.data)})))},[N.SUBPAGE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=T();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"subpage",block:n},a)}},e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(S,{icon:Z})))}}},Q=({block:t})=>t.icon?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(S,{icon:t.icon,size:16})):null,V=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement(q,{doc:t.name,lookupAttribute:R(n.data)}));function Pn(t){if(!t)return null;let n;"block"in t&&t.block!=null&&(n=t.block.cvid);const r={kind:t.kind,blockCvid:n};switch(t.kind){case"announcementShow":r.announcementId=t.announcementId;break}return JSON.stringify(r)}function Un(t,n){if(!n)return null;const r=JSON.parse(n);let s;if(r.blockCvid&&(s=t.version.resourceCenter?.blocks.find(a=>a.cvid===r.blockCvid)),!s&&r.kind!=="search")return null;const c={kind:r.kind,block:s};switch(c.kind){case"announcementShow":c.announcementId=r.announcementId;break}return c}const Wn=({session:t,navigate:n})=>{const r=T(),s=t.version.resourceCenter.blocks,c=yt(s),{t:a}=G(),o=l.useRef(null),[i,m]=l.useState(""),[u,g]=We(i,m),[E,h]=l.useState(null);return l.useEffect(()=>{if(i.trim()===""){h(null);return}let f=!1;return(async()=>{h(null);const v=await Promise.all(s.map(async C=>{const{search:I}=ee[C.type];if(!I)return null;try{return await I({client:r,session:t,block:C,q:i})}catch(j){return console.error(`Userflow.js: Global search failed for ${C.type} block=`,C,"error=",j),null}}));f||h(v.filter(C=>C!=null&&C.results.length>0))})(),()=>{f=!0}},[r,t,s,i]),l.useEffect(()=>{o.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:u,onChange:f=>g(f.target.value),placeholder:a("resource_center.search_placeholder")})),i.trim()===""?e.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},a("resource_center.search_in")," ",c.map((f,b)=>e.createElement(e.Fragment,{key:f.cvid},b>0&&(b===c.length-1?` ${a("and")} `:", "),e.createElement("b",null,e.createElement(q,{doc:f.name,lookupAttribute:R(t.data)})))),"."):E?E.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},a("resource_center.no_results_found")):E.map(({block:f,truncated:b,results:v},C)=>{const I=ee[f.type],j=I.routeTo&&I.routeTo({block:f,initialQ:i});return e.createElement(e.Fragment,{key:f.cvid},C>0&&e.createElement("div",{className:"userflowjs-resource-center-divider"}),e.createElement("div",{className:"userflowjs-resource-center-label"},e.createElement(q,{doc:f.name,lookupAttribute:R(t.data)})),v.map((k,_)=>k.kind==="flow"?e.createElement(It,{key:k.flow.id,block:f,session:t,flow:k.flow,navigate:n}):k.kind==="article"?e.createElement(At,{key:_,block:f,session:t,article:k.article}):null),!b&&j&&e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:k=>{A(r,t,f),n(j,k)}},e.createElement("div",{className:"userflowjs-resource-center-block-text"},a("more"),":"," ",e.createElement(q,{doc:f.name,lookupAttribute:R(t.data)})),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(S,{icon:Z}))))}):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)))},On=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.emailContent,lookupAttribute:R(n.data)})),$n=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.phoneContent,lookupAttribute:R(n.data)})),zn=({block:t,initialQ:n,session:r,navigate:s})=>{const{t:c}=G(),a=l.useRef(null),[o,i]=l.useState(n||""),[m,u]=We(o,i),{data:g,error:E}=ie({message:{kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:t.cvid}}),h=g?.flows,f=l.useMemo(()=>h?St(h,o):null,[h,o]);return l.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(q,{doc:t.name,lookupAttribute:R(r.data)}))),t.searchEnabled&&e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:a,className:"userflowjs-text-input",type:"text",value:m,onChange:b=>u(b.target.value),placeholder:c("resource_center.search_placeholder")})),E?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.generic_error")):f?f.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):f.map(b=>e.createElement(It,{key:b.id,block:t,session:r,flow:b,navigate:s})):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,{fadeIn:!0})))};function St(t,n){const r=n.toLowerCase().trim();return r===""?t:t.filter(s=>s.name.toLowerCase().includes(r))}const It=({block:t,session:n,flow:r,navigate:s})=>{const c=T(),[a,o]=l.useState(!1);return l.useEffect(()=>{if(!a||r.type!==rt.CHECKLIST)return;const i=()=>{c.checklistSession?.flow.id===r.id&&(m(),s(null))},m=()=>{c.off("checklistChanged",i)};return c.on("checklistChanged",i),m},[c,a,r.type,r.id,s]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if(A(c,n,t,r.name),c.checklistSession?.flow.id===r.id){s(null);return}c.startFlow({flowId:r.id,startReason:n.draftMode?st.DRAFT:st.RESOURCE_CENTER,replaceCurrent:!0}),o(!0);const i=De(r.url,{lookupAttribute:R(n.data)});i&&on(i)},disabled:a},r.iconSetting!==Jt.HIDE&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},r.icon?e.createElement(S,{icon:r.icon,size:16}):e.createElement(S,{icon:r.type===rt.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),n.draftMode&&!r.published&&e.createElement("div",{className:"userflowjs-resource-center-code-block"},e.createElement("div",{title:"Unpublished. Preview only"},e.createElement("code",null,"P"))),e.createElement("div",{className:"userflowjs-resource-center-block-text"},r.name),a&&e.createElement(P,null))},Vn=({block:t,initialQ:n,session:r,bodyRef:s})=>{const{t:c}=G(),a=l.useRef(null),[o,i]=l.useState(n||""),[m,u]=We(o,i),{loading:g,loadingMore:E,data:h,messageForData:f,error:b,loadMore:v}=ie({message:{kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:t.cvid,q:o,offset:0}}),C=h?.truncated,I=l.useCallback(()=>{v((k,_)=>({..._,offset:k.articles.length}),(k,_)=>({..._,articles:[...k.articles,..._.articles]}))},[v]);Rt({bodyRef:s,loading:g,loadingMore:E,truncated:C,loadMoreHelper:I}),l.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]);let j=t.knowledgeBaseUrl||"";return j.match(/^https?:\/\//)||(j=`http://${j}`),j=jt(j),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(q,{doc:t.name,lookupAttribute:R(r.data)})),e.createElement("a",{className:"userflowjs-resource-center-icon-button",href:j,target:"_blank",rel:"noopener noreferrer"},e.createElement(S,{icon:En}))),e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:a,className:"userflowjs-text-input",type:"text",value:m,onChange:k=>u(k.target.value),placeholder:c("resource_center.search_placeholder")})),b?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},b.code==="quota_exceeded"?"Sorry, this company has reached its max number of searches. Consider asking Userflow to be moved to a dedicated search engine for a higher quota.":b.humanMessage||c("resource_center.generic_error")):g||!h?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)):h.articles.length===0?f?.q===""?null:e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):e.createElement(e.Fragment,null,f?.q===""&&e.createElement("div",{className:"userflowjs-resource-center-label"},c("resource_center.suggested_articles")),h.articles.map((k,_)=>e.createElement(At,{key:_,block:t,session:r,article:k})),E&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null))))},At=({block:t,article:n,session:r})=>{const s=T();return e.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{A(s,r,t,n.title)},href:jt(n.url),target:"_blank",rel:"noopener noreferrer"},e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(S,{icon:"regular/file-alt",size:16})),e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement("span",{dangerouslySetInnerHTML:{__html:n.htmlTitle}}),e.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:n.htmlSnippet}})))},qn=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.content,lookupAttribute:R(n.data)})),Kn=({bodyRef:t,session:n,route:r,navigate:s})=>{const c=T(),a=ie({message:{kind:"ListAnnouncements",beforeAnnouncementId:null},skip:r?.kind!=="announcementList"}),{loading:o,loadingMore:i,data:m,loadMore:u}=a,g=m?.truncated,E=l.useCallback(()=>{u((b,v)=>b.announcements.length>0?{...v,beforeAnnouncementId:b.announcements[b.announcements.length-1].id}:v,(b,v)=>({...v,announcements:[...b.announcements,...v.announcements]}))},[u]);Rt({bodyRef:t,loading:o,loadingMore:i,truncated:g,loadMoreHelper:E});const[h,f]=l.useState(void 0);return l.useLayoutEffect(()=>{t.current&&h!=null&&r?.kind==="announcementList"&&(t.current.scrollTop=h)},[t,h,r?.kind]),r?.kind==="announcementList"?e.createElement(Qn,{bodyRef:t,session:n,block:r.block,onMoreClick:b=>{f(t.current?.scrollTop),A(c,n,r.block,b.title),s({kind:"announcementShow",block:r.block,announcementId:b.id})},...a}):r?.kind==="announcementShow"?e.createElement(Zn,{block:r.block,announcementId:r.announcementId}):null},Qn=({bodyRef:t,block:n,session:r,onMoreClick:s,error:c,loading:a,loadingMore:o,data:i})=>{const{t:m}=G(),[u,g]=l.useMemo(()=>{const h=[],f=[];if(i){let b=-1;for(const v of i.announcements)b++,b<i.pageSize&&!v.seen&&v.level!==Y.SILENT?h.push(v):f.push(v)}return[h,f]},[i]),E=u.length;return e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(q,{doc:n.name,lookupAttribute:R(r.data)}))),c?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c.humanMessage||m("resource_center.generic_error")):a||!i?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)):i.announcements.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},ue.exists("resource_center.no_announcements",{fallbackLng:[]})?m("resource_center.no_announcements"):m("resource_center.no_results_found")):e.createElement(e.Fragment,null,E>0&&e.createElement("div",{className:"userflowjs-announcement-unread-header"},m("resource_center.unread",{count:E})),u.map((h,f)=>e.createElement(vt,{key:f,bodyRef:t,onMoreClick:()=>s(h),announcement:h})),u.length>0&&g.length>0&&e.createElement("div",{className:"userflowjs-announcement-seen-divider"}),g.map((h,f)=>e.createElement(vt,{key:f,bodyRef:t,onMoreClick:()=>s(h),announcement:h})),o&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null))))},ge=new Set;function O(t,n){if(!(ge.has(n.id)&&n.seen)&&(ge.add(n.id),t.setResourceCenterSession(r=>r?{...r,version:{...r.version,resourceCenter:{...r.version.resourceCenter,blocks:r.version.resourceCenter.blocks.map(s=>s.type===N.ANNOUNCEMENTS?{...s,unreadAnnouncementCount:n.level===Y.SILENT?s.unreadAnnouncementCount:s.unreadAnnouncementCount-1,popoutAnnouncement:s.popoutAnnouncement?.id===n.id?null:s.popoutAnnouncement,boosterAnnouncement:s.boosterAnnouncement?.id===n.id?null:s.boosterAnnouncement}:s)}}}:null),t.toggleUI(),ge.has(n.id))){t.send({kind:"MarkAnnouncementSeen",announcementId:n.id,versionId:n.versionId});return}}const vt=({bodyRef:t,onMoreClick:n,announcement:r})=>{const s=T(),c=l.useRef(null),a=l.useRef(!1);return l.useEffect(()=>{if(a.current||r.seen)return;const o=new IntersectionObserver(m=>{const u=m[0];u&&u.isIntersecting&&(O(s,r),a.current=!0,i())},{root:t.current,threshold:1}),i=()=>{o.disconnect()};return o.observe(c.current),i},[t,s,r]),e.createElement("div",{className:"userflowjs-announcement-list-item"},e.createElement("div",{className:"userflowjs-announcement-time-divider"},e.createElement("div",{className:"userflowjs-announcement-time-divider-line"}),e.createElement("div",{className:"userflowjs-announcement-time-text"},Oe(r.time)),e.createElement("div",{className:"userflowjs-announcement-time-divider-line"})),e.createElement("h2",{ref:c,className:"userflowjs-announcement-title"},!r.seen&&r.level!==Y.SILENT&&e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,r.title)),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement($,{doc:r.content,buttons:r.buttons,lookupAttribute:R(r.data)})),e.createElement("div",{className:"userflowjs-announcement-more"},r.moreEnabled&&e.createElement("button",{className:"userflowjs-tertiary-button",onClick:n},e.createElement("div",null,r.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(S,{icon:Ct})))))},Zn=({announcementId:t})=>{const n=T(),{t:r}=G(),{loading:s,data:c,error:a}=ie({message:{kind:"GetAnnouncement",announcementId:t}}),o=c?.announcement;return l.useEffect(()=>{!o||o.seen||O(n,o)},[n,o]),e.createElement(e.Fragment,null,a?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},a.humanMessage||r("resource_center.generic_error")):s||!o?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-announcement-show"},e.createElement("h2",{className:"userflowjs-announcement-title"},o?.title),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},Oe(o.time))),e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement($,{doc:o.content,buttons:o.buttons,lookupAttribute:R(o.data)}),o.moreEnabled&&e.createElement($,{doc:o.moreContent,buttons:o.moreButtons,lookupAttribute:R(o.data)})))))},Gn=({block:t,initialUserContent:n,session:r,navigate:s,onChatShow:c})=>{const a=t.assistantFlowId,o=T(),[i,m]=l.useState(null),[u,g]=l.useState(null),[E,h]=l.useState(null),[f]=l.useState(n);l.useEffect(()=>{n&&s({kind:"assistant",block:t,initialUserContent:""})},[n,t,s]),l.useEffect(()=>{let v=!1;return(async()=>{try{const I=le.getItem("assistantConversationId:"+a),[j,k]=await Promise.all([Dn(),o.send({kind:"GetAssistant",assistantFlowId:a,conversationId:I},{handlesRejection:!0,endBatch:!0})]);if(v)return;m(()=>j),g(k)}catch(I){console.error("Resource center assistant route failed to load:",I),h(I.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{v=!0}},[o,a]);const b=l.useMemo(()=>{if(!t.assistantContactEnabled)return;const v=r.version.resourceCenter?.blocks.find(C=>C.type===N.CONTACT);if(v)return()=>{switch(A(o,r,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case ot.EMAIL:s({kind:"email",block:v});break;case ot.PHONE:s({kind:"phone",block:v});break;default:s(null),Tt(r,v,c);break}}},[o,r,t,c,s]);return E?e.createElement("div",{className:"userflowjs-assistant-chat"},e.createElement("div",{className:"userflowjs-assistant-chat__content"},e.createElement("div",{className:"userflowjs-assistant-chat__error"},E))):!i||!u?e.createElement(P,{center:!0,fadeIn:!0}):e.createElement(i,{block:t,session:r,assistantReply:u,initialUserContent:f,onContactClick:b,contactButtonText:t.assistantContactButtonText||void 0})};function A(t,n,r,s){t.send({kind:"ClickResourceCenter",sessionId:n.id,description:r?De(r.name,{lookupAttribute:R(n.data)})+(s?` - ${s}`:""):s},{batch:!0})}function Rt({bodyRef:t,loading:n,loadingMore:r,truncated:s,loadMoreHelper:c}){l.useEffect(()=>{const a=t.current;if(!a||n||r||s)return;const o=()=>{a.scrollHeight-a.clientHeight-a.scrollTop>400||c()};return a.addEventListener("scroll",o),()=>{a.removeEventListener("scroll",o)}},[t,n,r,s,c])}function Oe(t){const n=t?new Date(t):new Date;let r=new Intl.DateTimeFormat(ue.language,{weekday:"long",day:"numeric",month:"short",year:n.getFullYear()===new Date().getFullYear()?void 0:"numeric"}).format(n);return r.substring(0,1).toUpperCase()+r.substring(1)}function Tt(t,n,r){if(n.chatProvider){const s=je[n.chatProvider];try{s.show({block:n})}catch(c){console.error(`Userflow.js: Error when showing ${n.chatProvider}:`,c)}r()}else t.draftMode&&window.alert("You have not selected a chat provider. Go to the resource center builder in Userflow. Click the Contact block. Pick a chat provider in the side panel.")}const Er=Object.freeze(Object.defineProperty({__proto__:null,ResourceCenterApp:bt,default:bt},Symbol.toStringTag,{value:"Module"}));export{Mn as A,xn as G,Er as R,jt as d};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterAssistantChat.js","vendor.react.js","vendor.core-js.js","vendor.object-assign.js","userflow.js","vendor.phoenix.js","vendor.uuid.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.dompurify.js","vendor.marked.js","vendor.obj-str.js","use-selector-element-monitoring.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.react-dom.js","vendor.scheduler.js","flow-host.styl.js","Frame.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","vendor.memoize-one.js","vendor.bignumber.js.js","use-element-rect.js"])))=>i.map(i=>d[i]);
2
+ import{k as j,C as U,l as Ce,u as le,m as Qt,n as tt,o as nt,E as Zt,p as Y,q as Gt,r as Jt,s as Xt,a as rt,t as st,v as Yt,w as ot,_ as en}from"./userflow.js";import{r as l,R as e}from"./vendor.react.js";import{u as _,i as ie}from"./client-context.js";import{f as tn,u as nn,w as rn,C as sn}from"./flow-host.styl.js";import{S as on,b as Me,R as z,h as cn,s as Fe,a as q,n as an}from"./use-selector-element-monitoring.js";import{g as R}from"./flow-condition-types.js";import{D as I,u as De,a as ln,g as Ct}from"./stylesheets.js";import{F as $e}from"./Frame.js";import{o as $}from"./vendor.obj-str.js";import{M as ke,d as ct,e as at}from"./roots.js";import{u as un}from"./use-window-resize.js";import{S as dn}from"./logomark.js";import"./vendor.core-js.js";import{f as mn,C as fn}from"./ChecklistUI.js";import{I as hn,J as Pe,K as wn,L as En,M as pn,N as kt,O as Z,z as bn,P as gn,Q as vn,R as Cn}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as kn,B as Nn}from"./FlowChrome.js";import{m as lt}from"./vendor.memoize-one.js";import{B as Nt}from"./vendor.bignumber.js.js";import{u as jn}from"./use-element-rect.js";import{u as G}from"./vendor.react-i18next.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="eb5f5a25-cd3e-4af1-be3c-1f2cc41a5f3d",t._sentryDebugIdIdentifier="sentry-dbid-eb5f5a25-cd3e-4af1-be3c-1f2cc41a5f3d")}catch{}})();function yn(t,n,r){return t.resourceCenterAutoDividers?it(n)||it(r):!1}function it(t){return t!==j.ACTION&&t!==j.ANNOUNCEMENTS&&t!==j.ASSISTANT&&t!==j.CONTACT&&t!==j.FLOWS&&t!==j.KNOWLEDGE_BASE&&t!==j.SUBPAGE}const m=window,Ne={[U.CRISP]:{configure:({onShow:t,onHide:n})=>{Sn();let r=!1,s=!1;const c=()=>{r||s?(m.$crisp.push(["do","chat:show"]),t()):(m.$crisp.push(["do","chat:hide"]),n())},a=()=>{r=!0,c()};m.$crisp.push(["on","chat:opened",a]);const o=()=>{r=!1,c()};m.$crisp.push(["on","chat:closed",o]);const u=()=>{s=!0,c()};m.$crisp.push(["on","message:received",u]);const d=()=>{const E=document.getElementById("crisp-chatbox");if(!E||window.getComputedStyle(E).display!=="block")return!1;const f=E.querySelector('[data-id="new_messages"]');return!(!f||window.getComputedStyle(f).display!=="block")},i=()=>{const E=d();E!==s&&(s=E,c())},g=window.setInterval(i,200);return()=>{m.$crisp.push(["off","chat:opened",a]),m.$crisp.push(["off","chat:closed",o]),m.$crisp.push(["off","message:received",u]),window.clearInterval(g)}},show:()=>{m.$crisp.push(["do","chat:show"]),m.$crisp.push(["do","chat:open"])},hide:()=>{m.$crisp.push(["do","chat:hide"]),m.$crisp.push(["do","chat:close"])}},[U.CUSTOM]:{configure:()=>()=>{},show:({block:t})=>{try{new Function(`"use strict";
3
+ `+t.chatCode)()}catch(n){console.error(`Userflow.js: Showing custom chat provider failed. Code: ${t.chatCode}`,n)}},hide:()=>{}},[U.FRESHCHAT]:{configure:({onShow:t,onHide:n})=>{if(!m.fcWidget)throw new Error("Freshchat is not installed");let r=!1,s=!1;const c=()=>{r||s?t():n()},a=()=>{r=!0,c()};m.fcWidget.on("widget:opened",a);const o=()=>{r=!1,c()};m.fcWidget.on("widget:closed",o);const u=()=>{const i=!!document.querySelector("#fc_frame.h-open-notify");i!==s&&(s=i,c())},d=window.setInterval(u,200);return m.fcWidget.on("unreadCount:notify",u),()=>{m.fcWidget.off("widget:opened",a),m.fcWidget.off("widget:closed",o),m.fcWidget.off("unreadCount:notify",u),window.clearInterval(d)}},show:()=>{m.fcWidget.open()},hide:()=>{m.fcWidget.close()}},[U.HELPSCOUT]:{configure:({onShow:t,onHide:n})=>{if(!m.Beacon)throw new Error("Help Scout is not installed");In();let r=!1,s=!1;const c=()=>{r||s?(mt(),t()):(je(),n())},a=()=>{r=!0,c()};m.Beacon("on","open",a),m.Beacon("info")?.status.isOpened&&a();const o=()=>{r=!1,c()};m.Beacon("on","close",o);const u=()=>{const i=!!document.querySelector(".BeaconNotificationsFrame");i!==s&&(s=i,c())},d=window.setInterval(u,200);return()=>{m.Beacon("off","open",a),m.Beacon("off","close",o),window.clearInterval(d)}},show:()=>{mt(),m.Beacon("open")},hide:()=>{je(),m.Beacon("close")}},[U.HUBSPOT]:{configure:({onShow:t,onHide:n})=>{const r=()=>{const a=document.getElementById("hubspot-messages-iframe-container");if(!m.HubSpotConversations||!a)return;window.clearInterval(c),An();let o=!1,u=!1;const d=()=>{o||u?(ye(),t()):(Se(),n())},i=()=>{const f=!!document.querySelector("#hubspot-messages-iframe-container .hs-shadow-container.active");f!==o&&(o=f,d())},g=new ke(i);g.observe(a,{attributes:!0,subtree:!0,attributeFilter:["class"]}),i();const E=({unreadCount:f})=>{const h=f>0;h!==u&&(u=h,d())};m.HubSpotConversations.on("unreadConversationCountChanged",E),s=()=>{g.disconnect(),m.HubSpotConversations.off("unreadConversationCountChanged",E)}};let s=()=>{window.clearInterval(c)};const c=window.setInterval(r,100);return r(),()=>{s()}},show:()=>{ye(),m.HubSpotConversations.widget.open()},hide:()=>{Se(),m.HubSpotConversations.widget.close()}},[U.INTERCOM]:{configure:({onShow:t,onHide:n})=>{if(!m.Intercom)throw new Error("Intercom is not installed");return Rn(),Ie.add(t),Ae.add(n),()=>{Ie.delete(t),Ae.delete(n)}},show:()=>{jt(),m.Intercom("show")},hide:()=>{Re(),m.Intercom("hide")}},[U.ZENDESK]:{configure:({onShow:t,onHide:n})=>{if(!m.zE)throw new Error("Zendesk is not installed");_n();let r=!1,s=!1;const c=()=>{r||s?(m.zE("webWidget","show"),t()):(m.zE("webWidget","hide"),n())},a=()=>{r=!0,s=!1,c()};_e.add(a);const o=()=>{r=!1,s=!1,c()};Te.add(o);const u=d=>{const i=d>0;i!==s&&(s=i,c())};return xe.add(u),()=>{_e.delete(a),Te.delete(o),xe.delete(u)}},show:()=>{m.zE("webWidget","show"),m.zE("webWidget","open")},hide:()=>{m.zE("webWidget","hide"),m.zE("webWidget","close")}},[U.ZENDESK_MESSENGER]:{configure:({onShow:t,onHide:n})=>{if(!m.zE)throw new Error("Zendesk is not installed");const r=()=>{t()},s=()=>{n()};return Le.add(r),Be.add(s),Tn(),()=>{Le.delete(r),Be.delete(s)}},show:()=>{m.zE("messenger","open")},hide:()=>{m.zE("messenger","close")}}};let ut=!1;function Sn(){ut||(ut=!0,m.$crisp||(m.$crisp=[]),m.$crisp.push(["do","chat:hide"]))}let dt=!1;function In(){dt||(dt=!0,je())}function mt(){m.Beacon("config",{display:{style:"icon"}})}function je(){m.Beacon("config",{display:{style:"manual"}})}let ft=!1,He=!1;function An(){ft||(ft=!0,He?ye():Se())}function ye(){He=!0,document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","visible","important")}function Se(){He=!1,document.getElementById("hubspot-messages-iframe-container")?.style.setProperty("visibility","hidden","important")}let ht=!1,Ie=new Set,Ae=new Set;function Rn(){if(ht)return;ht=!0,Re();let t=!1,n=!1;const r=()=>{jt();for(const o of Ie)o()},s=()=>{Re();for(const o of Ae)o()},c=()=>{t||n?r():s()};m.Intercom("onShow",()=>{t=!0,c()}),m.Intercom("onHide",()=>{t=!1,c()});const a=()=>{const o=!!document.querySelector('iframe[name="intercom-borderless-frame"], iframe[name="intercom-notifications-frame"]');n!==o&&(n=o,c())};m.Intercom("onUnreadCountChange",()=>{a()}),window.setInterval(a,200)}function jt(){m.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function Re(){m.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let wt=!1,_e=new Set,Te=new Set,xe=new Set;function _n(){wt||(wt=!0,m.zE("webWidget","hide"),m.zE("webWidget","close"),m.zE("webWidget:on","open",()=>{for(const t of _e)t()}),m.zE("webWidget:on","close",()=>{for(const t of Te)t()}),m.zE("webWidget:on","chat:unreadMessages",t=>{for(const n of xe)n(t)}))}let Et=!1,Le=new Set,Be=new Set;function Tn(){Et||(Et=!0,m.zE("messenger:on","open",function(){for(const t of Le)t()}),m.zE("messenger:on","close",function(){for(const t of Be)t()}))}const xn=t=>l.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100"},t),l.createElement("path",{fill:"currentColor",d:"M24.049 79.74h36.003c8.185 0 15.985-6.621 17.43-14.814l6.091-34.556h3.997c8.149 0 13.645 6.63 12.2 14.815l-7.051 40C91.274 93.363 83.474 100 75.288 100h-40c-8.185 0-13.645-6.667-12.2-14.815l.96-5.444Z"}),l.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12.437 69.63h40c8.148 0 15.978-6.637 17.422-14.815l7.052-40C78.355 6.63 72.896 0 64.711 0h-40C16.533 0 8.726 6.63 7.281 14.815l-7.052 40C-1.215 62.963 4.252 69.63 12.437 69.63Zm33.628-33.798c3.756-2.064 8.725-4.795 9.907-11.844C57.385 15.458 50.065 8.983 42.168 9c-7.452 0-12.771 3.195-17.508 8.892-.858 1.034-.884 2.45-.053 3.212l3.472 3.196c.847.767 2.25.589 3.176-.406 2.842-3.068 4.869-4.83 8.51-4.83 2.864 0 6.077 1.934 5.59 4.847-.37 2.223-2.292 3.334-5.4 5.001l-.28.151c-3.582 1.92-8.134 4.362-9.124 10.247l-.16.956c-.055.28-.05.571.014.85.065.278.188.538.362.76.173.222.391.4.639.522.247.121.518.183.79.18h6.744a2.709 2.709 0 0 0 1.712-.688c.481-.426.81-1.01.934-1.657l.095-.556c.266-1.582 2.101-2.59 4.384-3.845ZM32.837 59c3.552 0 6.955-3.034 7.58-6.769.63-3.729-1.742-6.763-5.293-6.763-3.552 0-6.934 3.028-7.58 6.763C26.9 55.966 29.286 59 32.837 59Z"})),P=({center:t,fadeIn:n})=>e.createElement("div",{className:$({"userflowjs-spinner":!0,"userflowjs-spinner--center":!!t,"userflowjs-spinner--fade-in":!!n})},e.createElement("svg",{viewBox:"0 0 24 24",version:"1.1",xmlns:"http://www.w3.org/2000/svg"},e.createElement("circle",{className:"userflowjs-spinner__bg",fill:"none",cx:12,cy:12,r:10,style:{strokeWidth:"4px"}}),e.createElement("circle",{className:"userflowjs-spinner__fill",fill:"none",cx:12,cy:12,r:10,transform:"translate(12, 12) rotate(-90) translate(-12, -12)",style:{strokeWidth:"4px",strokeDasharray:10*2*Math.PI*.25+"px, 1000"}})));function ue({message:t,skip:n}){const r=_(),[s,c]=l.useState(!0),[a,o]=l.useState(!1),[u,d]=l.useState(null),[i,g]=l.useState(null),[E,f]=l.useState(null),h=l.useRef(0),w=l.useRef(null),v=l.useRef(()=>{});return l.useEffect(()=>{if(n)return;const N=JSON.stringify(t);if(N===w.current)return;w.current=N;const y=++h.current;let k,C;const x=async()=>{c(!0);try{C=t;const T=await r.send(t,{handlesRejection:!0});if(y!==h.current)return;k=T,d(k),g(t),f(null)}catch(T){if(y!==h.current)return;f(T)}finally{c(!1)}};let H=!1;v.current=async(T,J)=>{if(!H){H=!0,o(!0);try{const B=T(k,C);C=B;const te=await r.send(B,{handlesRejection:!0});if(y!==h.current)return;k=J(k,te),d(k),f(null)}catch(B){if(y!==h.current)return;f(B)}finally{H=!1,o(!1)}}},x()},[n,r,t]),{loading:s,loadingMore:a,data:u,messageForData:i,error:E,loadMore:v.current}}const Ln=200;function Ue(t,n){const[r,s]=l.useState(t),c=l.useRef(void 0),a=l.useCallback(u=>{window.clearTimeout(c.current),s(u),n(u)},[n]),o=l.useCallback(u=>{window.clearTimeout(c.current),s(u),c.current=window.setTimeout(()=>{n(u)},Ln)},[n]);return l.useEffect(()=>()=>{window.clearTimeout(c.current)},[]),[r,o,a]}const Bn={xs:[16,3],sm:[24,4],md32:[32,4],md:[40,4],lg:[56,4]};class Mn extends e.PureComponent{constructor(){super(...arguments),this.memoizedBgStyle=lt(n=>({strokeWidth:`${n}px`})),this.memoizedFillStyle=lt((n,r,s)=>({strokeWidth:`${n}px`,strokeDasharray:r*2*Math.PI*new Nt(s).toNumber()+"px, 1000"}))}render(){const{props:n}=this,{size:r,indeterminate:s,className:c,center:a,right:o,color:u}=this.props,d=["progress-spinner"];r&&d.push(`progress-spinner--${r}`),s&&d.push("progress-spinner--indeterminate"),c&&d.push(c);const i=s?.25:n.progress||0,[g,E]=Bn[r||"md"],f=g/2,h=(g-E)/2;let w=e.createElement("div",{className:d.join(" ")},e.createElement("svg",{viewBox:`0 0 ${g} ${g}`,version:"1.1",xmlns:"http://www.w3.org/2000/svg"},e.createElement("circle",{className:"progress-spinner__bg",fill:"none",cx:f,cy:f,r:h,style:this.memoizedBgStyle(E)}),e.createElement("circle",{className:u==="purple"?"progress-spinner__fill-purple":"progress-spinner__fill",fill:"none",cx:f,cy:f,r:h,transform:`translate(${f}, ${f}) rotate(-90) translate(-${f}, -${f})`,style:this.memoizedFillStyle(E,h,i)})));return a?w=e.createElement("div",{className:"progress-spinner-center-aligner"},w):o&&(w=e.createElement("div",{className:"progress-spinner-right-aligner"},w)),w}}const Fn=({textareaRef:t,value:n,onChange:r,onBlur:s,onKeyDown:c,onMouseDown:a,placeholder:o,disabled:u,readOnly:d,className:i,mirrorClassName:g,textareaClassName:E,icon:f,onIconClick:h,loading:w=!1,children:v})=>{let N=n||o||"";(N===""||N.endsWith(`
4
+ `))&&(N+=" "),i=i||"growing-textarea",g=g||i+"__mirror";const[y,k]=l.useState(!1);return e.createElement("div",{className:i},e.createElement("div",{className:g+" "+(E||"")},N),e.createElement("div",{className:`${i}__wrapper ${w?`${i}__loading`:""}`},e.createElement("textarea",{ref:t,value:n,onChange:C=>r&&r(C.target.value),onBlur:s,onKeyDown:C=>{if(C.key==="Enter"&&y){C.preventDefault();return}c&&c(C)},onMouseDown:a,placeholder:o,disabled:u||w,readOnly:d,className:`${E||""} ${f?`${i}__textarea-with-icon`:""} ${w?`${i}__textarea-loading`:""}`,onCompositionStart:()=>k(!0),onCompositionEnd:()=>k(!1)}),f&&!w&&e.createElement("div",{className:`${i}__icon`},e.createElement("button",{className:"btn btn--plain-blue btn--square btn--md32",onClick:h},e.createElement("span",null,e.createElement(I,{icon:f})))),w&&e.createElement("div",{className:`${i}__loader`},e.createElement(Mn,{indeterminate:!0,size:"xs",color:"purple"}))),v)},Dn=({textareaRef:t,value:n,onChange:r,onSubmit:s,placeholder:c,readOnly:a})=>{const o=()=>{s&&s()};return e.createElement("div",{className:"userflowjs-assistant-chat-input"},e.createElement(Fn,{textareaRef:t,className:"userflowjs-growing-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea userflowjs-assistant-chat-input__textarea",placeholder:c,readOnly:a,value:n||"",onChange:r,onKeyDown:u=>{!u.shiftKey&&u.key==="Enter"&&(u.preventDefault(),o())}}),e.createElement("button",{"data-testid":"assistant-chat-input-submit",className:"userflowjs-assistant-chat-input__submit",onClick:()=>o()},e.createElement(I,{icon:hn})))};function $n(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function yt(t){return Ce.linkUrlDecorator?Ce.linkUrlDecorator(t):t}const pt=5,Pn=async()=>(await en(async()=>{const{ResourceCenterAssistantChat:t}=await import("./ResourceCenterAssistantChat.js");return{ResourceCenterAssistantChat:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]))).ResourceCenterAssistantChat,bt=({session:t,isOpen:n,flowSession:r,checklistSession:s})=>{const c=_(),{t:a}=G(),{company:o}=t.flow,{version:u}=t,d=u.resourceCenter,i=De(u.theme),g=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;l.useEffect(()=>{ie.changeLanguage(g)},[g]);const{loaded:E}=ln(window,tn,i),[f,h]=l.useState(!1),w=E&&f,[v,N]=l.useState(ct()),[y,k]=l.useState(at()),C=l.useCallback(()=>{N(ct()),k(at())},[]);un(C);const{zIndex:x,bringToFront:H}=nn(),[T,J]=l.useState(null),[B,te]=l.useState(null),[O,Lt]=l.useState(null),de=l.useRef(null),[X,Bt]=l.useState(null),[ze,Mt]=l.useState(null),[Oe,Ft]=l.useState(null),[Dt,$t]=l.useState(0),[Pt,Ht]=l.useState(0),me=l.useCallback(()=>{B&&$t(Math.round(B.offsetWidth)),Ht(Math.round((O?.offsetHeight||0)+(X?.offsetHeight||0)+(ze?.offsetHeight||0)+(Oe?.offsetHeight||0)))},[B,O,X,ze,Oe]);l.useLayoutEffect(()=>{if(!T||typeof ke!="function")return;const p=new ke(()=>{me()});return p.observe(T,{childList:!0,attributes:!0,subtree:!0}),()=>{p.disconnect()}},[T,me]),l.useLayoutEffect(()=>{me()});const[Ve,qe]=l.useState(!1),fe=l.useRef(),ne=l.useCallback(()=>{qe(!0),window.clearTimeout(fe.current),fe.current=window.setTimeout(()=>{qe(!1)},i.resourceCenterTransitionDuration)},[i.resourceCenterTransitionDuration]);l.useEffect(()=>()=>{window.clearTimeout(fe.current)},[]);const re=l.useCallback(()=>{H(),ne(),c.openResourceCenter()},[H,c,ne]),he=l.useCallback(()=>{ne(),c.closeResourceCenter()},[c,ne]),[Ke,K]=l.useState(!1);l.useEffect(()=>{if(Ke){if(!$n())if(n){const p='button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea';let S=X?.querySelector(".userflowjs-assistant-chat-input textarea")||X?.querySelector(p)||O?.querySelector(p);if(S){const M=S.closest&&S.closest(".userflowjs-resource-center-checklist")||null;M?mn(M):S.focus({preventScroll:!0})}}else B?.focus({preventScroll:!0});K(!1)}},[Ke,n,X,O,B]),l.useEffect(()=>{const p=T?.ownerDocument.defaultView;if(!n||!p)return;const S=M=>{M.key==="Escape"&&(he(),K(!0))};return p.addEventListener("keydown",S),()=>p.removeEventListener("keydown",S)},[n,T,K,he]);const[b,we]=l.useState(()=>zn(t,le.getItem(`resourceCenterRoute:v1:${t.id}`))),F=l.useCallback((p,S)=>{we(p);const M=Wn(p);M?le.setItem(`resourceCenterRoute:v1:${t.id}`,M):le.removeItem(`resourceCenterRoute:v1:${t.id}`),S?.detail===0&&K(!0)},[t.id]);l.useEffect(()=>{if(!t.draftMode||!b||!("block"in b)||!b.block)return;const p=d.blocks.find(S=>S.cvid===b.block.cvid);p?JSON.stringify(p)!==JSON.stringify(b.block)&&we({...b,block:p}):we(null),b.block},[t.draftMode,d,b]);const se=l.useMemo(()=>d.blocks.filter(p=>!(p.type===j.CHECKLIST&&!s||p.type===j.DIVIDER&&i.resourceCenterAutoDividers||p.hiddenWhenFlowsActive&&p.hiddenWhenFlowsActive.some(S=>S===r?.flow.id||S===s?.flow.id))),[d,r,s,i.resourceCenterAutoDividers]),Ee=l.useMemo(()=>It(se),[se]),pe=l.useMemo(()=>!s||!d.blocks.some(p=>p.type===j.CHECKLIST)?0:Qt(s),[d,s]),L=l.useMemo(()=>d.blocks.find(p=>p.type===j.CONTACT&&p.chatEnabled&&p.chatProvider),[d]),[Ut,Qe]=l.useState(!1),oe=l.useCallback(()=>{c.closeResourceCenter(),L&&L.chatProvider!==U.CUSTOM&&Qe(!0)},[c,L]),ce=l.useCallback(()=>{Qe(!1)},[]),Ze=l.useCallback(()=>{if(L)try{Ne[L.chatProvider].hide({block:L}),ce()}catch(p){console.error(`Userflow.js: Error when hiding ${L.chatProvider}:`,p)}},[L,ce]);l.useEffect(()=>{if(!L)return;Ce.autoHide3pDisabled=!0;const p=Ne[L.chatProvider];try{const S=p.configure({block:L,onShow:oe,onHide:ce});return()=>{S()}}catch(S){console.error(`Userflow.js: Error when configuring ${L.chatProvider}:`,S);return}},[L,oe,ce]),l.useEffect(()=>{n&&Ze()},[Ze,n]);const D=l.useMemo(()=>d.blocks.find(p=>p.type===j.ANNOUNCEMENTS),[d]),Wt=!!b&&(b.kind==="search"||b.kind==="flows"||b.kind==="knowledgeBase"),Ge=b?.kind==="assistant"||b?.kind==="announcementList"||b?.kind==="announcementShow",be=Math.min(Ge?i.resourceCenterFullWidth:i.resourceCenterWidth,v-2*i.resourceCenterPaddingX),zt=540,Ot=720,Vt={zIndex:i.resourceCenterZIndex!=null?i.resourceCenterZIndex:n?x:rn(sn),position:w?void 0:"absolute",visibility:w&&!Ut?void 0:"hidden"},qt={width:(n?be:Dt)+"px",height:n?Math.min(Wt?zt:Ge?Ot:Pt,y-2*i.resourceCenterPaddingY,i.resourceCenterMaxHeight==null?Number.MAX_VALUE:i.resourceCenterMaxHeight)+"px":void 0},[Kt,Je]=l.useState(!1),Xe=()=>{re(),K(!0)},Ye=i.resourceCenterDisplayChecklistProgress&&s&&pe>0?e.createElement("div",{"data-testid":"resource-center-launcher-badge",className:"userflowjs-resource-center-launcher-badge"},pe,e.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")):null;let ae="",ge="";return i.resourceCenterLauncherTextMode===tt.CHECKLIST_OVERRIDE&&s&&pe>0?ae=s.version.checklist?.launcherText||"Get Started":i.resourceCenterLauncherTextMode!==tt.NONE&&(ge=d.buttonText),e.createElement(on.Provider,{value:t},e.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center-app userflowjs-theme-root",style:Ct(i),dir:ie.dir()},e.createElement("div",{className:$({"userflowjs-resource-center":!0,"userflowjs-resource-center--fixed":!0,[`userflowjs-resource-center--placement-${i.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0}),style:Vt},e.createElement("div",{className:"userflowjs-resource-center-frame-wrapper",onMouseEnter:()=>Je(!0),onMouseLeave:()=>Je(!1)},e.createElement($e,{className:$({"userflowjs-resource-center-frame":!0,"userflowjs-resource-center-frame--animating":Ve,"userflowjs-resource-center-frame--open":n,"userflowjs-resource-center-frame--closed":!n}),style:qt,stylesheet:Me,theme:i,onStylesheetsLoad:h,title:"Resource center"},w&&e.createElement(e.Fragment,null,e.createElement("div",{ref:J,className:$({"userflowjs-resource-center-frame-root":!0,[`userflowjs-resource-center-frame-root--placement-${i.resourceCenterPlacement.toLowerCase().replace(/_/g,"-")}`]:!0,"userflowjs-resource-center-frame-root--animating":Ve,"userflowjs-resource-center-frame-root--open":n,"userflowjs-resource-center-frame-root--closed":!n}),role:n?"dialog":void 0,"aria-label":n?d.headerText:void 0},e.createElement("div",{className:"userflowjs-resource-center-launcher-container"},e.createElement("button",{ref:te,className:$({"userflowjs-resource-center-launcher-button":!0,"userflowjs-resource-center-launcher-button--hover":Kt}),onClick:Xe,"aria-label":`Open ${d.headerText}`},Ye,ae&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ae),(Ye||ae)&&e.createElement("div",{className:"userflowjs-resource-center-launcher-divider"}),ge&&e.createElement("div",{"data-testid":"resource-center-launcher-text",className:"userflowjs-resource-center-launcher-text"},ge),e.createElement("div",{className:"userflowjs-resource-center-launcher-icon"},i.resourceCenterLauncherIconType===nt.PLAINTEXT?"?":i.resourceCenterLauncherIconType===nt.DEFAULT?e.createElement(xn,null):i.rcIconAsset&&i.rcIconAsset.assetUrl?e.createElement("img",{src:i.rcIconAsset.assetUrl,className:"company-icon",style:{height:`${i.rcIconSize}px`,width:`${i.rcIconSize}px`}}):e.createElement("span",null)))),e.createElement("div",{ref:de,className:"userflowjs-resource-center-body",style:{width:be+"px"}},e.createElement("div",{ref:Bt,className:$({"userflowjs-resource-center-body-content":!0,"userflowjs-resource-center-body-content--padding":b?.kind!=="assistant","userflowjs-resource-center-body-content--same-background":i.sameBackground,"userflowjs-resource-center-body-content--with-made-with-userflow":o.resourceCenterBranding})},n&&e.createElement(e.Fragment,null,b?b.kind==="search"?e.createElement(On,{session:t,navigate:F}):b.kind==="email"?e.createElement(Vn,{block:b.block,session:t}):b.kind==="phone"?e.createElement(qn,{block:b.block,session:t}):b.kind==="flows"?e.createElement(Kn,{block:b.block,initialQ:b.initialQ,session:t,navigate:F}):b.kind==="knowledgeBase"?e.createElement(Qn,{block:b.block,initialQ:b.initialQ,session:t,bodyRef:de}):b.kind==="subpage"?e.createElement(Zn,{block:b.block,session:t}):b.kind==="announcementList"||b.kind==="announcementShow"?e.createElement(Gn,{bodyRef:de,session:t,route:b,navigate:F}):b.kind==="assistant"?e.createElement(Yn,{block:b.block,initialUserContent:b.initialUserContent,session:t,navigate:F,chatBlock:L,onChatShow:oe}):null:e.createElement(e.Fragment,null,se.map((p,S)=>{const M=ee[p.type],et=se[S+1];return M?e.createElement(e.Fragment,{key:p.id},e.createElement(M.View,{session:t,flowSession:r,checklistSession:s,block:p,navigate:F,onChatShow:oe}),et&&yn(i,p.type,et.type)&&e.createElement("div",{className:"userflowjs-resource-center-divider"})):null}))))),o.resourceCenterBranding&&e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow"},e.createElement("div",{className:"userflowjs-resource-center-made-with-userflow-content",ref:Mt},e.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+o.slug+"&utm_content=resource-center",target:"_blank",rel:"noopener noreferrer"},e.createElement(dn,null),e.createElement("div",null,"Made with Userflow")))),t.draftMode&&e.createElement("div",{className:"userflowjs-resource-center-preview"},e.createElement("div",{ref:Ft,className:"userflowjs-resource-center-preview-content"},e.createElement("div",{className:"userflowjs-resource-center-preview-text"},"Preview"),e.createElement("button",{className:"userflowjs-resource-center-preview-button",onClick:()=>{c.endFlow(t,{endReason:Zt.USER_CLOSED})}},e.createElement(I,{icon:Pe})))),e.createElement("div",{className:"userflowjs-resource-center-header",style:{width:be+"px"}},e.createElement("div",{ref:Lt,className:"userflowjs-resource-center-header-content"},b==null?e.createElement("div",{className:"userflowjs-resource-center-header-text"},d.headerText):e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:p=>F(b?.kind==="announcementShow"?{kind:"announcementList",block:b.block}:null,p)},e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(I,{icon:wn})),e.createElement("div",{className:"userflowjs-resource-center-icon-button__text"},a("resource_center.back"))),e.createElement("div",{className:"flex-1"}),Ee.length>0&&e.createElement("button",{className:"userflowjs-resource-center-icon-button",onClick:()=>{let p={kind:"search"};if(Ee.length===1){const S=Ee[0],M=ee[S.type];M.routeTo&&(p=M.routeTo({block:S}))}b?.kind==="search"?F(null):(A(c,t,null,"Search icon"),F(p))},"aria-label":"Search"},e.createElement(I,{icon:En})),e.createElement("button",{className:"userflowjs-resource-center-icon-button userflowjs-resource-center-close-button",onClick:p=>{he(),p.detail===0&&K(!0)},"aria-label":`Close ${d.headerText}`},e.createElement(I,{icon:pn}))))))),!n&&!r&&D&&D.unreadAnnouncementCount>0&&e.createElement(Hn,{theme:i,count:D.unreadAnnouncementCount,onClick:Xe})),!n&&!r&&D?.popoutAnnouncement&&e.createElement(gt,{session:t,open:re,navigate:F,block:D}),!n&&!r&&D?.boosterAnnouncement&&D?.boosterAnnouncement.level===Y.MODAL&&e.createElement(Un,{session:t,open:re,navigate:F,block:D}),!n&&!r&&D?.boosterAnnouncement&&D?.boosterAnnouncement.level===Y.TOAST&&e.createElement(gt,{session:t,open:re,navigate:F,block:D,rcPlacement:i.resourceCenterPlacement}))))},Hn=({theme:t,count:n,onClick:r})=>{const[s,c]=l.useState(!1);return e.createElement($e,{className:$({"userflowjs-resource-center-launcher-unread-badge":!0}),noScroll:!0,style:{position:s?void 0:"absolute",visibility:s?void 0:"hidden"},stylesheet:Me,theme:t,onStylesheetsLoad:c,title:"Resource center unread badge"},e.createElement(St,{count:n,onClick:r}))},St=({count:t,onClick:n})=>{let r=null;return t>9&&(t=9,r=e.createElement("span",{className:"userflowjs-unread-badge-plus"},"+")),e.createElement("div",{className:$({"userflowjs-unread-badge":!0,"userflowjs-unread-badge--clickable":!!n}),onClick:n},e.createElement("span",null,t),r)},gt=({session:t,open:n,navigate:r,block:s,rcPlacement:c})=>{const a=l.useRef(null),o=s.popoutAnnouncement??s.boosterAnnouncement,u=De(o.theme),d=u.toastPlacement,i=!!s.boosterAnnouncement,g=d===c;let E=null,f=null;o&&(E=o.toastAutoDismiss??u.toastAutoDismiss,f=o.toastWidth?o.toastWidth:u.toastWidth);const h=_(),[w,v]=l.useState(!1),{height:N,setEl:y}=jn();l.useEffect(()=>{const T=a.current;if(!T||E===null)return;const J=Date.now(),B=()=>{const O=1-(Date.now()-J)/(new Nt(E||0).toNumber()*1e3);O<=0?(T.style.width="0%",o&&W(h,o)):(T.style.width=`${O*100}%`,requestAnimationFrame(B))};return requestAnimationFrame(B),()=>{T&&(T.style.width="0%")}},[a.current,E,h,o,W]);const k=()=>{o&&W(h,o)},C=20,x=l.useMemo(()=>CSS.supports("height: 100dvh")?"dvh":"vh",[]),H=()=>{i&&o&&(W(h,o),A(h,t,s,o.title),r({kind:"announcementShow",block:s,announcementId:o.id}),n())};return o?e.createElement("div",{className:$({"userflowjs-resource-center-popout":!i,"userflowjs-resource-center-toast":i,[`userflowjs-resource-center-toast--${d?.toLowerCase().replace(/_/g,"-")}`]:!g&&!!d&&i}),style:Ct(u)},e.createElement($e,{className:$({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${N}px, 100${x} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - ${C}px)`,position:w?void 0:"absolute",visibility:w?void 0:"hidden",...f&&i?{width:f}:{}},stylesheet:Me,theme:u,onStylesheetsLoad:v,title:"Resource center popout"},i&&e.createElement("div",{className:"userflowjs-bubble-progress--default"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",ref:a})),e.createElement("div",{ref:y,className:"userflowjs-resource-center-popout-frame-root",style:{cursor:i?"pointer":"auto",padding:i&&u.toastPadding||void 0}},e.createElement("div",{onClick:H},e.createElement("h2",{className:"userflowjs-announcement-title"},e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,o.title)),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},We(o.time))),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement(z,{doc:o.content,buttons:o.buttons,lookupAttribute:R(o.data)})),!i&&e.createElement(e.Fragment,null,o.moreEnabled&&e.createElement("div",{className:"userflowjs-announcement-more"},e.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>{W(h,o),A(h,t,s,o.title),r({kind:"announcementShow",block:s,announcementId:o.id}),n()}},e.createElement("div",null,(o.moreEnabled?o.moreButtonText:null)||"Read more"),!i&&e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(I,{icon:kt})))))),i&&o.moreEnabled&&e.createElement("div",{onClick:H,className:"userflowjs-announcement-more--toast"},(o.moreEnabled?o.moreButtonText:null)||"Read more"),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:k,"aria-label":"Dismiss announcement"},e.createElement(I,{icon:Pe}))))),!i&&e.createElement("div",{className:"userflowjs-resource-center-popout-notch"})):null},Un=({session:t,open:n,navigate:r,block:s})=>{const c=s.boosterAnnouncement,a=_(),o=De(c.theme),u=()=>{W(a,c)};return e.createElement(kn,{company:t.flow.company,theme:o,position:"fixed",width:c.modalWidth,stepAppearance:Gt.MODAL,zIndex:o.checklistZIndex,autoHide3pEnabled:!0,onModalBackdropClick:u,noIframe:!0,isModalAnnouncement:!0},e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement("h1",null,c.title),e.createElement(z,{doc:c.content,buttons:c.buttons,lookupAttribute:R(c.data)})),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:u,"aria-label":"Dismiss announcement"},e.createElement(I,{icon:Pe}))),c.moreEnabled&&e.createElement("div",{className:"userflowjs-announcement-more--modal"},e.createElement("button",{className:"userflowjs-bubble-button--primary",onClick:()=>{W(a,c),A(a,t,s,c.title),r({kind:"announcementShow",block:s,announcementId:c.id}),n()}},e.createElement("div",null,(c.moreEnabled?c.moreButtonText:null)||"Read more"))))};function It(t){return t.filter(n=>{const r=ee[n.type];return r.isSearchable?r.isSearchable(n):!!r.search})}const ee={[j.ACTION]:{View:t=>{const{block:n,session:r,flowSession:s,checklistSession:c}=t,a=_(),[o,u]=l.useState(!1),d=s?.id,i=c?.id;return l.useEffect(()=>{u(!1)},[d,i]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:o?void 0:()=>{A(a,r,n);const g=n.actions.find(E=>E.type===Jt.START_FLOW);g?g.otherFlow?.id!==c?.flow.id&&u(!0):a.closeResourceCenter(),cn(a,r,n.actions)},disabled:o},e.createElement(Q,{...t}),e.createElement(V,{...t}),o&&e.createElement(P,null))}},[j.ANNOUNCEMENTS]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=_();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"announcementList",block:n},a)}},n.unreadAnnouncementCount>0?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(St,{count:n.unreadAnnouncementCount})):e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(I,{icon:Z})))}},[j.ASSISTANT]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=_(),[a,o]=l.useState("");return n.assistantAppearance===Xt.INPUT?e.createElement("div",{className:"userflowjs-resource-center-assistant-block"},e.createElement(Dn,{value:a,onChange:o,placeholder:Fe(n.name,{lookupAttribute:R(r.data)}),onSubmit:()=>{A(c,r,n),s({kind:"assistant",block:n,initialUserContent:a})}})):e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{A(c,r,n),s({kind:"assistant",block:n,initialUserContent:""})}},e.createElement(Q,{...t}),e.createElement(V,{...t}))}},[j.CHECKLIST]:{View:({checklistSession:t})=>e.createElement("div",{"data-testid":"resource-center-checklist",className:"userflowjs-resource-center-checklist"},e.createElement(fn,{session:t}),e.createElement(Nn,{draftMode:t.draftMode?"CHECKLIST PREVIEW":!1}))},[j.CONTACT]:{View:t=>{const{block:n,session:r,navigate:s,onChatShow:c}=t,a=_(),o=[];return n.emailEnabled&&o.push({icon:gn,label:"Email",isRoute:!0,onClick:u=>{A(a,r,n,"Email"),s({kind:"email",block:n},u)}}),n.phoneEnabled&&o.push({icon:vn,label:"Phone",isRoute:!0,onClick:u=>{A(a,r,n,"Phone"),s({kind:"phone",block:n},u)}}),n.chatEnabled&&o.push({icon:Cn,label:"Live-chat",isRoute:!1,onClick:()=>{A(a,r,n,"Chat"),xt(r,n,c)}}),e.createElement("div",{className:$({"userflowjs-resource-center-block":!0,"userflowjs-resource-center-block--clickable":o.length===1}),onClick:o.length===1?o[0].onClick:void 0},o.length===1&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(I,{icon:o[0].icon})),e.createElement(V,{...t}),o.length>1&&o.map(({icon:u,label:d,onClick:i},g)=>e.createElement("button",{key:g,className:"userflowjs-resource-center-icon-button",onClick:i,"aria-label":d},e.createElement(I,{icon:u}))),o.length===1&&o[0].isRoute&&e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(I,{icon:Z})))}},[j.DIVIDER]:{View:()=>e.createElement("div",{className:"userflowjs-resource-center-divider"})},[j.FLOWS]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=_();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"flows",block:n},a)}},e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(I,{icon:Z})))},routeTo:({block:t,initialQ:n})=>({kind:"flows",block:t,initialQ:n}),isSearchable:t=>!!t.searchEnabled,search:async({client:t,session:n,block:r,q:s})=>{const{flows:c}=await t.send({kind:"ListResourceCenterBlockFlows",sessionId:n.id,blockCvid:r.cvid},{handlesRejection:!0}),a=At(c,s),o=a.slice(0,pt);return{block:r,truncated:o.length===a.length,results:o.map(u=>({kind:"flow",flow:u}))}}},[j.KNOWLEDGE_BASE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=_();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"knowledgeBase",block:n},a)}},e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(I,{icon:Z})))},routeTo:({block:t,initialQ:n})=>({kind:"knowledgeBase",block:t,initialQ:n}),search:async({client:t,session:n,block:r,q:s})=>{const{truncated:c,articles:a}=await t.send({kind:"SearchKnowledgeBase",sessionId:n.id,blockCvid:r.cvid,q:s,offset:0,limit:pt},{handlesRejection:!0});return{block:r,truncated:c,results:a.map(o=>({kind:"article",article:o}))}}},[j.MESSAGE]:{View:({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-block"},e.createElement("div",{className:"userflowjs-resource-center-block-text userflowjs-bubble-content"},e.createElement(z,{doc:t.content,lookupAttribute:R(n.data)})))},[j.SUBPAGE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=_();return e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:a=>{A(c,r,n),s({kind:"subpage",block:n},a)}},e.createElement(Q,{...t}),e.createElement(V,{...t}),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(I,{icon:Z})))}}},Q=({block:t})=>t.icon?e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(I,{icon:t.icon,size:16})):null,V=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement(q,{doc:t.name,lookupAttribute:R(n.data)}));function Wn(t){if(!t)return null;let n;"block"in t&&t.block!=null&&(n=t.block.cvid);const r={kind:t.kind,blockCvid:n};switch(t.kind){case"announcementShow":r.announcementId=t.announcementId;break}return JSON.stringify(r)}function zn(t,n){if(!n)return null;const r=JSON.parse(n);let s;if(r.blockCvid&&(s=t.version.resourceCenter?.blocks.find(a=>a.cvid===r.blockCvid)),!s&&r.kind!=="search")return null;const c={kind:r.kind,block:s};switch(c.kind){case"announcementShow":c.announcementId=r.announcementId;break}return c}const On=({session:t,navigate:n})=>{const r=_(),s=t.version.resourceCenter.blocks,c=It(s),{t:a}=G(),o=l.useRef(null),[u,d]=l.useState(""),[i,g]=Ue(u,d),[E,f]=l.useState(null);return l.useEffect(()=>{if(u.trim()===""){f(null);return}let h=!1;return(async()=>{f(null);const v=await Promise.all(s.map(async N=>{const{search:y}=ee[N.type];if(!y)return null;try{return await y({client:r,session:t,block:N,q:u})}catch(k){return console.error(`Userflow.js: Global search failed for ${N.type} block=`,N,"error=",k),null}}));h||f(v.filter(N=>N!=null&&N.results.length>0))})(),()=>{h=!0}},[r,t,s,u]),l.useEffect(()=>{o.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:o,className:"userflowjs-text-input",type:"text",value:i,onChange:h=>g(h.target.value),placeholder:a("resource_center.search_placeholder")})),u.trim()===""?e.createElement("div",{"data-testid":"resource-center-empty-query",className:"userflowjs-resource-center-list-route-error"},a("resource_center.search_in")," ",c.map((h,w)=>e.createElement(e.Fragment,{key:h.cvid},w>0&&(w===c.length-1?` ${a("and")} `:", "),e.createElement("b",null,e.createElement(q,{doc:h.name,lookupAttribute:R(t.data)})))),"."):E?E.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},a("resource_center.no_results_found")):E.map(({block:h,truncated:w,results:v},N)=>{const y=ee[h.type],k=y.routeTo&&y.routeTo({block:h,initialQ:u});return e.createElement(e.Fragment,{key:h.cvid},N>0&&e.createElement("div",{className:"userflowjs-resource-center-divider"}),e.createElement("div",{className:"userflowjs-resource-center-label"},e.createElement(q,{doc:h.name,lookupAttribute:R(t.data)})),v.map((C,x)=>C.kind==="flow"?e.createElement(Rt,{key:C.flow.id,block:h,session:t,flow:C.flow,navigate:n}):C.kind==="article"?e.createElement(_t,{key:x,block:h,session:t,article:C.article}):null),!w&&k&&e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:C=>{A(r,t,h),n(k,C)}},e.createElement("div",{className:"userflowjs-resource-center-block-text"},a("more"),":"," ",e.createElement(q,{doc:h.name,lookupAttribute:R(t.data)})),e.createElement("div",{className:"userflowjs-resource-center-block-nav-icon"},e.createElement(I,{icon:Z}))))}):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)))},Vn=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(z,{doc:t.emailContent,lookupAttribute:R(n.data)})),qn=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(z,{doc:t.phoneContent,lookupAttribute:R(n.data)})),Kn=({block:t,initialQ:n,session:r,navigate:s})=>{const{t:c}=G(),a=l.useRef(null),[o,u]=l.useState(n||""),[d,i]=Ue(o,u),{data:g,error:E}=ue({message:{kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:t.cvid}}),f=g?.flows,h=l.useMemo(()=>f?At(f,o):null,[f,o]);return l.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(q,{doc:t.name,lookupAttribute:R(r.data)}))),t.searchEnabled&&e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:a,className:"userflowjs-text-input",type:"text",value:d,onChange:w=>i(w.target.value),placeholder:c("resource_center.search_placeholder")})),E?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.generic_error")):h?h.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):h.map(w=>e.createElement(Rt,{key:w.id,block:t,session:r,flow:w,navigate:s})):e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,{fadeIn:!0})))};function At(t,n){const r=n.toLowerCase().trim();return r===""?t:t.filter(s=>s.name.toLowerCase().includes(r))}const Rt=({block:t,session:n,flow:r,navigate:s})=>{const c=_(),[a,o]=l.useState(!1);return l.useEffect(()=>{if(!a||r.type!==rt.CHECKLIST)return;const u=()=>{c.checklistSession?.flow.id===r.id&&(d(),s(null))},d=()=>{c.off("checklistChanged",u)};return c.on("checklistChanged",u),d},[c,a,r.type,r.id,s]),e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{if(A(c,n,t,r.name),c.checklistSession?.flow.id===r.id){s(null);return}c.startFlow({flowId:r.id,startReason:n.draftMode?st.DRAFT:st.RESOURCE_CENTER,replaceCurrent:!0}),o(!0);const u=Fe(r.url,{lookupAttribute:R(n.data)});u&&an(u)},disabled:a},r.iconSetting!==Yt.HIDE&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},r.icon?e.createElement(I,{icon:r.icon,size:16}):e.createElement(I,{icon:r.type===rt.CHECKLIST?"regular/tasks":"regular/shoe-prints",size:16})),n.draftMode&&!r.published&&e.createElement("div",{className:"userflowjs-resource-center-code-block"},e.createElement("div",{title:"Unpublished. Preview only"},e.createElement("code",null,"P"))),e.createElement("div",{className:"userflowjs-resource-center-block-text"},r.name),a&&e.createElement(P,null))},Qn=({block:t,initialQ:n,session:r,bodyRef:s})=>{const{t:c}=G(),a=l.useRef(null),[o,u]=l.useState(n||""),[d,i]=Ue(o,u),{loading:g,loadingMore:E,data:f,messageForData:h,error:w,loadMore:v}=ue({message:{kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:t.cvid,q:o,offset:0}}),N=f?.truncated,y=l.useCallback(()=>{v((C,x)=>({...x,offset:C.articles.length}),(C,x)=>({...x,articles:[...C.articles,...x.articles]}))},[v]);Tt({bodyRef:s,loading:g,loadingMore:E,truncated:N,loadMoreHelper:y}),l.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]);let k=t.knowledgeBaseUrl||"";return k.match(/^https?:\/\//)||(k=`http://${k}`),k=yt(k),e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(q,{doc:t.name,lookupAttribute:R(r.data)})),e.createElement("a",{className:"userflowjs-resource-center-icon-button",href:k,target:"_blank",rel:"noopener noreferrer"},e.createElement(I,{icon:bn}))),e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:a,className:"userflowjs-text-input",type:"text",value:d,onChange:C=>i(C.target.value),placeholder:c("resource_center.search_placeholder")})),w?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},w.code==="quota_exceeded"?"Sorry, this company has reached its max number of searches. Consider asking Userflow to be moved to a dedicated search engine for a higher quota.":w.humanMessage||c("resource_center.generic_error")):g||!f?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)):f.articles.length===0?h?.q===""?null:e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c("resource_center.no_results_found")):e.createElement(e.Fragment,null,h?.q===""&&e.createElement("div",{className:"userflowjs-resource-center-label"},c("resource_center.suggested_articles")),f.articles.map((C,x)=>e.createElement(_t,{key:x,block:t,session:r,article:C})),E&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null))))},_t=({block:t,article:n,session:r})=>{const s=_();return e.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{A(s,r,t,n.title)},href:yt(n.url),target:"_blank",rel:"noopener noreferrer"},e.createElement("div",{className:"userflowjs-resource-center-block-icon"},e.createElement(I,{icon:"regular/file-alt",size:16})),e.createElement("div",{className:"userflowjs-resource-center-block-text"},e.createElement("span",{dangerouslySetInnerHTML:{__html:n.htmlTitle}}),e.createElement("div",{className:"userflowjs-resource-center-block-subtext",dangerouslySetInnerHTML:{__html:n.htmlSnippet}})))},Zn=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement(z,{doc:t.content,lookupAttribute:R(n.data)})),Gn=({bodyRef:t,session:n,route:r,navigate:s})=>{const c=_(),a=ue({message:{kind:"ListAnnouncements",beforeAnnouncementId:null},skip:r?.kind!=="announcementList"}),{loading:o,loadingMore:u,data:d,loadMore:i}=a,g=d?.truncated,E=l.useCallback(()=>{i((w,v)=>w.announcements.length>0?{...v,beforeAnnouncementId:w.announcements[w.announcements.length-1].id}:v,(w,v)=>({...v,announcements:[...w.announcements,...v.announcements]}))},[i]);Tt({bodyRef:t,loading:o,loadingMore:u,truncated:g,loadMoreHelper:E});const[f,h]=l.useState(void 0);return l.useLayoutEffect(()=>{t.current&&f!=null&&r?.kind==="announcementList"&&(t.current.scrollTop=f)},[t,f,r?.kind]),r?.kind==="announcementList"?e.createElement(Jn,{bodyRef:t,session:n,block:r.block,onMoreClick:w=>{h(t.current?.scrollTop),A(c,n,r.block,w.title),s({kind:"announcementShow",block:r.block,announcementId:w.id})},...a}):r?.kind==="announcementShow"?e.createElement(Xn,{block:r.block,announcementId:r.announcementId}):null},Jn=({bodyRef:t,block:n,session:r,onMoreClick:s,error:c,loading:a,loadingMore:o,data:u})=>{const{t:d}=G(),[i,g]=l.useMemo(()=>{const f=[],h=[];if(u){let w=-1;for(const v of u.announcements)w++,w<u.pageSize&&!v.seen&&v.level!==Y.SILENT?f.push(v):h.push(v)}return[f,h]},[u]),E=i.length;return e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-resource-center-list-route-header"},e.createElement("div",{className:"userflowjs-resource-center-list-route-title"},e.createElement(q,{doc:n.name,lookupAttribute:R(r.data)}))),c?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},c.humanMessage||d("resource_center.generic_error")):a||!u?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)):u.announcements.length===0?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},ie.exists("resource_center.no_announcements",{fallbackLng:[]})?d("resource_center.no_announcements"):d("resource_center.no_results_found")):e.createElement(e.Fragment,null,E>0&&e.createElement("div",{className:"userflowjs-announcement-unread-header"},d("resource_center.unread",{count:E})),i.map((f,h)=>e.createElement(vt,{key:h,bodyRef:t,onMoreClick:()=>s(f),announcement:f})),i.length>0&&g.length>0&&e.createElement("div",{className:"userflowjs-announcement-seen-divider"}),g.map((f,h)=>e.createElement(vt,{key:h,bodyRef:t,onMoreClick:()=>s(f),announcement:f})),o&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null))))},ve=new Set;function W(t,n){if(!(ve.has(n.id)&&n.seen)&&(ve.add(n.id),t.setResourceCenterSession(r=>r?{...r,version:{...r.version,resourceCenter:{...r.version.resourceCenter,blocks:r.version.resourceCenter.blocks.map(s=>s.type===j.ANNOUNCEMENTS?{...s,unreadAnnouncementCount:n.level===Y.SILENT?s.unreadAnnouncementCount:s.unreadAnnouncementCount-1,popoutAnnouncement:s.popoutAnnouncement?.id===n.id?null:s.popoutAnnouncement,boosterAnnouncement:s.boosterAnnouncement?.id===n.id?null:s.boosterAnnouncement}:s)}}}:null),t.toggleUI(),ve.has(n.id))){t.send({kind:"MarkAnnouncementSeen",announcementId:n.id,versionId:n.versionId});return}}const vt=({bodyRef:t,onMoreClick:n,announcement:r})=>{const s=_(),c=l.useRef(null),a=l.useRef(!1);return l.useEffect(()=>{if(a.current||r.seen)return;const o=new IntersectionObserver(d=>{const i=d[0];i&&i.isIntersecting&&(W(s,r),a.current=!0,u())},{root:t.current,threshold:1}),u=()=>{o.disconnect()};return o.observe(c.current),u},[t,s,r]),e.createElement("div",{className:"userflowjs-announcement-list-item"},e.createElement("div",{className:"userflowjs-announcement-time-divider"},e.createElement("div",{className:"userflowjs-announcement-time-divider-line"}),e.createElement("div",{className:"userflowjs-announcement-time-text"},We(r.time)),e.createElement("div",{className:"userflowjs-announcement-time-divider-line"})),e.createElement("h2",{ref:c,className:"userflowjs-announcement-title"},!r.seen&&r.level!==Y.SILENT&&e.createElement("span",{className:"userflowjs-unread-dot"}),e.createElement("span",null,r.title)),e.createElement("div",{className:"userflowjs-announcement-content userflowjs-bubble-content"},e.createElement(z,{doc:r.content,buttons:r.buttons,lookupAttribute:R(r.data)})),e.createElement("div",{className:"userflowjs-announcement-more"},r.moreEnabled&&e.createElement("button",{className:"userflowjs-tertiary-button",onClick:n},e.createElement("div",null,r.moreButtonText||"Read more"),e.createElement("span",{className:"userflowjs-rtl-mirrored"},e.createElement(I,{icon:kt})))))},Xn=({announcementId:t})=>{const n=_(),{t:r}=G(),{loading:s,data:c,error:a}=ue({message:{kind:"GetAnnouncement",announcementId:t}}),o=c?.announcement;return l.useEffect(()=>{!o||o.seen||W(n,o)},[n,o]),e.createElement(e.Fragment,null,a?e.createElement("div",{className:"userflowjs-resource-center-list-route-error"},a.humanMessage||r("resource_center.generic_error")):s||!o?e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null)):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-announcement-show"},e.createElement("h2",{className:"userflowjs-announcement-title"},o?.title),e.createElement("div",{className:"userflowjs-announcement-time"},e.createElement("div",{className:"userflowjs-announcement-time-text"},We(o.time))),e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement(z,{doc:o.content,buttons:o.buttons,lookupAttribute:R(o.data)}),o.moreEnabled&&e.createElement(z,{doc:o.moreContent,buttons:o.moreButtons,lookupAttribute:R(o.data)})))))},Yn=({block:t,initialUserContent:n,session:r,navigate:s,onChatShow:c})=>{const a=t.assistantFlowId,o=_(),[u,d]=l.useState(null),[i,g]=l.useState(null),[E,f]=l.useState(null),[h]=l.useState(n);l.useEffect(()=>{n&&s({kind:"assistant",block:t,initialUserContent:""})},[n,t,s]),l.useEffect(()=>{let v=!1;return(async()=>{try{const y=le.getItem("assistantConversationId:"+a),[k,C]=await Promise.all([Pn(),o.send({kind:"GetAssistant",assistantFlowId:a,conversationId:y},{handlesRejection:!0,endBatch:!0})]);if(v)return;d(()=>k),g(C)}catch(y){console.error("Resource center assistant route failed to load:",y),f(y.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{v=!0}},[o,a]);const w=l.useMemo(()=>{if(!t.assistantContactEnabled)return;const v=r.version.resourceCenter?.blocks.find(N=>N.type===j.CONTACT);if(v)return()=>{switch(A(o,r,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case ot.EMAIL:s({kind:"email",block:v});break;case ot.PHONE:s({kind:"phone",block:v});break;default:s(null),xt(r,v,c);break}}},[o,r,t,c,s]);return E?e.createElement("div",{className:"userflowjs-assistant-chat"},e.createElement("div",{className:"userflowjs-assistant-chat__content"},e.createElement("div",{className:"userflowjs-assistant-chat__error"},E))):!u||!i?e.createElement(P,{center:!0,fadeIn:!0}):e.createElement(u,{block:t,session:r,assistantReply:i,initialUserContent:h,onContactClick:w,contactButtonText:t.assistantContactButtonText||void 0})};function A(t,n,r,s){t.send({kind:"ClickResourceCenter",sessionId:n.id,description:r?Fe(r.name,{lookupAttribute:R(n.data)})+(s?` - ${s}`:""):s},{batch:!0})}function Tt({bodyRef:t,loading:n,loadingMore:r,truncated:s,loadMoreHelper:c}){l.useEffect(()=>{const a=t.current;if(!a||n||r||s)return;const o=()=>{a.scrollHeight-a.clientHeight-a.scrollTop>400||c()};return a.addEventListener("scroll",o),()=>{a.removeEventListener("scroll",o)}},[t,n,r,s,c])}function We(t){const n=t?new Date(t):new Date;let r=new Intl.DateTimeFormat(ie.language,{weekday:"long",day:"numeric",month:"short",year:n.getFullYear()===new Date().getFullYear()?void 0:"numeric"}).format(n);return r.substring(0,1).toUpperCase()+r.substring(1)}function xt(t,n,r){if(n.chatProvider){const s=Ne[n.chatProvider];try{s.show({block:n})}catch(c){console.error(`Userflow.js: Error when showing ${n.chatProvider}:`,c)}r()}else t.draftMode&&window.alert("You have not selected a chat provider. Go to the resource center builder in Userflow. Click the Contact block. Pick a chat provider in the side panel.")}const vr=Object.freeze(Object.defineProperty({__proto__:null,ResourceCenterApp:bt,default:bt},Symbol.toStringTag,{value:"Module"}));export{Dn as A,Fn as G,vr as R,yt as d};
5
5
  //# sourceMappingURL=ResourceCenterApp.js.map
@@ -1,5 +1,5 @@
1
- import{r as u,R as n}from"./vendor.react.js";import{ab as _,ac as y,u as Y}from"./userflow.js";import{u as be}from"./client-context.js";import{a4 as q,a5 as Q,a6 as Ee,a7 as P,a8 as $,a9 as V,aa as X,ab as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{p as _e}from"./vendor.dompurify.js";import{m as ke}from"./vendor.marked.js";import{o as F}from"./vendor.obj-str.js";import{A as we,d as Ie,G as Se}from"./ResourceCenterApp.js";import{f as je,R as Ce}from"./use-selector-element-monitoring.js";import{D as W}from"./stylesheets.js";import{U as ae}from"./roots.js";import{r as ee}from"./vendor.react-dom.js";import"./vendor.core-js.js";import{g as Me}from"./flow-condition-types.js";import{u as ve}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./flow-host.styl.js";import"./Frame.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./FlowChrome.js";import"./use-element-rect.js";import"./vendor.bignumber.js.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4c2bc53e-9b20-440e-a04d-dcab1e51ea4e",t._sentryDebugIdIdentifier="sentry-dbid-4c2bc53e-9b20-440e-a04d-dcab1e51ea4e")}catch{}})();function Re(t){const e=Intl.Segmenter;return e?/(\p{Emoji_Presentation}|\p{Extended_Pictographic})(\p{Emoji_Modifier_Base}?\p{Emoji_Modifier}?|\uFE0F\u200D(\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?\uFE0F\u200D)*\p{Emoji_Presentation}|\uFE0F\u200D\p{Extended_Pictographic})/u.test(t)&&[...new e().segment(t)].length===1:!1}const te=[];function Ne({assistant:t,lookupAttribute:e,initialConversationId:a,initialHistory:c,initialUserContent:m,onConversationIdChange:f,submitMessage:h,submitRating:l,submitFeedback:g,InsideMessage:r,onContactClick:p,contactButtonText:i}){const[o,d]=u.useState(null),[S,w]=u.useState(()=>c?c.map(s=>({...s,assistantHtml:x(B(s.assistantContent),!1)})):te),[D,M]=u.useState(""),j=u.useRef(null),k=u.useRef(null),E=u.useRef(!0),I=u.useRef(a||null),[ce,le]=u.useState(I.current),H=u.useCallback(s=>{I.current=s,le(s),f&&f(s)},[f]),T=u.useCallback(()=>{o?.focus({preventScroll:!0})},[o]);u.useEffect(()=>{T()},[T]),u.useLayoutEffect(()=>{const s=k.current;s&&(s.scrollTop=Math.ceil(s.scrollHeight-s.clientHeight))},[]);const K=u.useCallback(()=>{const s=k.current;s&&(E.current=!0,typeof s.scrollTo=="function"&&s.scrollTo({top:Math.ceil(s.scrollHeight-s.clientHeight),behavior:"smooth"}))},[]),G=u.useRef(0);u.useLayoutEffect(()=>{const s=k.current;s&&s.scrollHeight!==G.current&&(G.current=s.scrollHeight,E.current&&K())},[S,K]);const N=u.useCallback(()=>{j.current&&j.current()},[]);u.useEffect(()=>()=>{N()},[N]);const O=(s,R)=>{w(C=>C.map(v=>{if(s===v.id){const b=R(v);return{...v,...b}}else return v}))},L=s=>{w(R=>R.map((C,v)=>{if(v===R.length-1){const b=s(C);return{...C,...b}}else return C}))},U=u.useCallback(async s=>{if(s=s.trim(),s==="")return;N(),w(b=>[...b,{id:null,userContent:s,assistantContent:"",assistantHtml:x("","enter"),enterAnimation:!0,sources:[],completed:!1,rating:null,scaleRating:null,scaleMax:null,feedbackSubmitted:!1}]),M(""),K();let R=!1;const C=()=>{R=!0,j.current=null},v=h({conversationId:I.current,userContent:s,callback:b=>{if(R){console.log("Userflow.js AssistantChat got message after being done",b);return}switch(b.kind){case"conversation_created":H(b.conversationId);break;case"message_created":L(()=>({id:b.messageId,warning:b.warning}));break;case"assistant_content_delta":L(A=>{const he=b.delta,J=A.assistantContent+he,ge=B(J),pe=x(ge);return{assistantContent:J,assistantHtml:pe}});break;case"done":C(),L(A=>({assistantHtml:x(A.assistantContent,"exit"),completed:!0,sources:b.sources}));break;case"error":C(),L(A=>({failed:!0,error:b.message,assistantHtml:x(B(A.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",b)}}});j.current=()=>{C(),v.abort(),L(b=>({assistantHtml:x(B(b.assistantContent),!1)}))}},[N,K,h,H]),z=u.useRef(!1);u.useEffect(()=>{z.current||(z.current=!0,m&&U(m))},[U,m]);const ie=u.useCallback(()=>{N(),H(null),w(te),T()},[N,T,H]),[ue,fe]=u.useState(!0),de=u.useCallback(()=>{const s=k.current;s&&fe(s.scrollTop===0)},[]),me=u.useCallback(()=>{const s=k.current;s&&(E.current=Math.ceil(s.scrollHeight-s.clientHeight)==Math.ceil(s.scrollTop))},[]);return{assistant:t,lookupAttribute:e,history:S,setInput:d,contentElRef:k,scrolledToTop:ue,userContent:D,setUserContent:M,onSubmitMessage:U,supportsFeedback:!!l&&!!g,onSubmitRating:s=>{if(l){switch(s.ratingMode){case _.LIKE:O(s.messageId,()=>({rating:s.rating}));break;case _.SCALE:O(s.messageId,()=>({scaleRating:s.scaleRating,scaleMax:s.scaleMax}));break;default:throw new ae(s)}l(s)}},onSubmitFeedback:s=>{g&&(O(s.messageId,()=>({feedbackSubmitted:!0})),g(s))},InsideMessage:r,onContactClick:p,contactButtonText:i,reset:ie,onContentScroll:de,onContentWheel:me,conversationId:ce}}const xe=({assistant:t,lookupAttribute:e,history:a,setInput:c,contentElRef:m,scrolledToTop:f,userContent:h,setUserContent:l,onSubmitMessage:g,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,onContactClick:d,contactButtonText:S,reset:w,onContentScroll:D,onContentWheel:M,conversationId:j})=>{const k=a.some(E=>E.completed||E.failed);return n.createElement("div",{className:"userflowjs-assistant-chat"},n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})}),n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})},n.createElement(n.Fragment,null,n.createElement("h2",{className:"userflowjs-assistant-chat__title"},t.title),n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:w},t.resetText))),n.createElement("div",{ref:m,className:"userflowjs-assistant-chat__content",onScroll:D,onWheel:M},!je(t.intro)&&n.createElement("div",{className:"userflowjs-assistant-chat__intro"},n.createElement(Ce,{doc:t.intro,lookupAttribute:e})),a.map((E,I)=>n.createElement(Le,{key:I,assistant:t,message:E,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,conversationId:j,isLast:I===a.length-1}))),n.createElement("div",{className:"userflowjs-assistant-chat__prompt"},n.createElement(we,{textareaRef:c,placeholder:(a.length===0?t.promptEmptyPlaceholder:t.promptNonemptyPlaceholder)||"",value:h,onChange:l,onSubmit:()=>g(h)})),k&&d&&n.createElement("div",{className:"userflowjs-assistant-chat__contact"},n.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>d()},S)))},Le=({assistant:t,message:e,supportsFeedback:a,onSubmitRating:c,onSubmitFeedback:m,InsideMessage:f,conversationId:h,isLast:l})=>n.createElement("div",{className:"userflowjs-assistant-chat__message"},f&&n.createElement(f,{message:e}),n.createElement("div",{className:F({"userflowjs-assistant-chat__user-content":!0,"userflowjs-assistant-chat__user-content--enter":!!e.enterAnimation}),"data-assistant-conversation-id":h,"data-assistant-message-id":e.id},n.createElement("div",{style:{whiteSpace:"pre-wrap"}},e.userContent)),e.warning&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},"Warning: ",e.warning),n.createElement("div",{className:"userflowjs-assistant-chat__assistant-content"},n.createElement("div",null,n.createElement(ye,{html:e.assistantHtml})),e.error&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},e.error)),e.sources&&e.sources.length>0&&n.createElement("div",{className:"userflowjs-assistant-chat__sources"},n.createElement("div",{className:"userflowjs-assistant-chat__sources-title"},t.sourcesText),e.sources.map((g,r)=>n.createElement("a",{key:r,className:"userflowjs-assistant-chat__source",href:Ie(g.url),target:"_blank",rel:"noreferrer noopener"},g.title))),a&&e.completed&&e.id&&(t.ratingMode===_.LIKE||t.ratingMode===_.SCALE&&l)&&n.createElement(Ae,{assistant:t,message:e,onSubmitRating:c,onSubmitFeedback:m})),Ae=({assistant:t,message:e,onSubmitRating:a,onSubmitFeedback:c})=>{const m=u.useRef(null),[f,h]=u.useState(""),l=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:_.LIKE,messageId:o,rating:i})}),m.current?.focus({preventScroll:!0}))},g=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:_.SCALE,messageId:o,scaleRating:i,scaleMax:t.scaleMax})}),m.current?.focus({preventScroll:!0}))},r=()=>{e.id&&(c({messageId:e.id,feedback:f.trim()}),h(""))},p=t.ratingMode===_.LIKE?n.createElement("button",{className:"userflowjs-assistant-chat__rating-option",disabled:!0},n.createElement(W,{icon:e.rating==y.DISLIKE?q:Q})):e.scaleRating&&e.scaleMax&&n.createElement("button",{className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--scale":!0}),disabled:!0},oe(t,e.scaleRating,e.scaleMax));return n.createElement("div",{className:`userflowjs-assistant-chat__rating userflowjs-assistant-chat__rating--${t.ratingMode}`},t.ratingMode===_.SCALE&&n.createElement("div",{className:"userflowjs-assistant-chat__rating-question"},t.scaleQuestion),e.feedbackSubmitted?n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks"},p,n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks-message"},t.feedbackThanksText)):(t.ratingMode===_.LIKE?e.rating:e.scaleRating)?n.createElement(Se,{textareaRef:m,className:"userflowjs-growing-textarea userflowjs-assistant-chat__feedback-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea",placeholder:(t.ratingMode===_.LIKE?e.rating===y.LIKE?t.feedbackLikePlaceholder:t.feedbackDislikePlaceholder:t.scaleFeedbackPlaceholder)||"",value:f,onChange:h,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),r())}},p,n.createElement("button",{className:"userflowjs-assistant-chat__feedback-submit",onClick:()=>r()},n.createElement(W,{icon:Ee}))):n.createElement("div",{className:"userflowjs-assistant-chat__rating-options"},t.ratingMode===_.LIKE?[y.LIKE,y.DISLIKE].map(i=>(!e.rating||e.rating===i)&&n.createElement("button",{key:i,className:"userflowjs-assistant-chat__rating-option",onClick:e.rating?void 0:()=>l(i),disabled:!!e.rating,"data-testid":`assistant-chat-rating-${i}`},n.createElement(W,{icon:i==y.DISLIKE?q:Q}))):Fe(t).map(({value:i,label:o})=>n.createElement("button",{key:i,className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--large-scale":Re(o||"")}),onClick:e.scaleRating?void 0:()=>g(i),disabled:!!e.scaleRating,"data-testid":`assistant-chat-rating-${i}`},o))))};function B(t){let e=t;const a=f=>(f=f.replace(/\s*[*_`]*$/,""),f=f.replace(/(^|\n)\s*(\d+\.?|-|=)$/,""),f);e=a(e),e=e.replace(/\[([^\]\n]*)(\](\([^)\n]*)?)?$/,"$1"),e=a(e);const c=Array.from(e.matchAll(/\n( *)```/g));if(c.length%2===1){const f=c[c.length-1][1];e+=`
1
+ import{r as u,R as n}from"./vendor.react.js";import{ab as _,ac as y,u as Y}from"./userflow.js";import{u as be}from"./client-context.js";import{a4 as q,a5 as Q,a6 as Ee,a7 as P,a8 as $,a9 as V,aa as X,ab as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{p as _e}from"./vendor.dompurify.js";import{m as ke}from"./vendor.marked.js";import{o as F}from"./vendor.obj-str.js";import{A as we,d as Ie,G as Se}from"./ResourceCenterApp.js";import{f as je,R as Ce}from"./use-selector-element-monitoring.js";import{D as W}from"./stylesheets.js";import{U as ae}from"./roots.js";import{r as ee}from"./vendor.react-dom.js";import"./vendor.core-js.js";import{g as Me}from"./flow-condition-types.js";import{u as ve}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.babel.runtime.js";import"./flow-host.styl.js";import"./Frame.js";import"./use-window-resize.js";import"./logomark.js";import"./ChecklistUI.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./FlowChrome.js";import"./vendor.memoize-one.js";import"./vendor.bignumber.js.js";import"./use-element-rect.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="be285c70-8957-4c5b-ae7c-21135477e4b1",t._sentryDebugIdIdentifier="sentry-dbid-be285c70-8957-4c5b-ae7c-21135477e4b1")}catch{}})();function Re(t){const e=Intl.Segmenter;return e?/(\p{Emoji_Presentation}|\p{Extended_Pictographic})(\p{Emoji_Modifier_Base}?\p{Emoji_Modifier}?|\uFE0F\u200D(\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?\uFE0F\u200D)*\p{Emoji_Presentation}|\uFE0F\u200D\p{Extended_Pictographic})/u.test(t)&&[...new e().segment(t)].length===1:!1}const te=[];function Ne({assistant:t,lookupAttribute:e,initialConversationId:a,initialHistory:c,initialUserContent:m,onConversationIdChange:f,submitMessage:h,submitRating:l,submitFeedback:g,InsideMessage:r,onContactClick:p,contactButtonText:i}){const[o,d]=u.useState(null),[S,w]=u.useState(()=>c?c.map(s=>({...s,assistantHtml:x(B(s.assistantContent),!1)})):te),[D,M]=u.useState(""),j=u.useRef(null),k=u.useRef(null),E=u.useRef(!0),I=u.useRef(a||null),[ce,le]=u.useState(I.current),H=u.useCallback(s=>{I.current=s,le(s),f&&f(s)},[f]),T=u.useCallback(()=>{o?.focus({preventScroll:!0})},[o]);u.useEffect(()=>{T()},[T]),u.useLayoutEffect(()=>{const s=k.current;s&&(s.scrollTop=Math.ceil(s.scrollHeight-s.clientHeight))},[]);const K=u.useCallback(()=>{const s=k.current;s&&(E.current=!0,typeof s.scrollTo=="function"&&s.scrollTo({top:Math.ceil(s.scrollHeight-s.clientHeight),behavior:"smooth"}))},[]),G=u.useRef(0);u.useLayoutEffect(()=>{const s=k.current;s&&s.scrollHeight!==G.current&&(G.current=s.scrollHeight,E.current&&K())},[S,K]);const N=u.useCallback(()=>{j.current&&j.current()},[]);u.useEffect(()=>()=>{N()},[N]);const O=(s,R)=>{w(C=>C.map(v=>{if(s===v.id){const b=R(v);return{...v,...b}}else return v}))},L=s=>{w(R=>R.map((C,v)=>{if(v===R.length-1){const b=s(C);return{...C,...b}}else return C}))},U=u.useCallback(async s=>{if(s=s.trim(),s==="")return;N(),w(b=>[...b,{id:null,userContent:s,assistantContent:"",assistantHtml:x("","enter"),enterAnimation:!0,sources:[],completed:!1,rating:null,scaleRating:null,scaleMax:null,feedbackSubmitted:!1}]),M(""),K();let R=!1;const C=()=>{R=!0,j.current=null},v=h({conversationId:I.current,userContent:s,callback:b=>{if(R){console.log("Userflow.js AssistantChat got message after being done",b);return}switch(b.kind){case"conversation_created":H(b.conversationId);break;case"message_created":L(()=>({id:b.messageId,warning:b.warning}));break;case"assistant_content_delta":L(A=>{const he=b.delta,J=A.assistantContent+he,ge=B(J),pe=x(ge);return{assistantContent:J,assistantHtml:pe}});break;case"done":C(),L(A=>({assistantHtml:x(A.assistantContent,"exit"),completed:!0,sources:b.sources}));break;case"error":C(),L(A=>({failed:!0,error:b.message,assistantHtml:x(B(A.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",b)}}});j.current=()=>{C(),v.abort(),L(b=>({assistantHtml:x(B(b.assistantContent),!1)}))}},[N,K,h,H]),z=u.useRef(!1);u.useEffect(()=>{z.current||(z.current=!0,m&&U(m))},[U,m]);const ie=u.useCallback(()=>{N(),H(null),w(te),T()},[N,T,H]),[ue,fe]=u.useState(!0),de=u.useCallback(()=>{const s=k.current;s&&fe(s.scrollTop===0)},[]),me=u.useCallback(()=>{const s=k.current;s&&(E.current=Math.ceil(s.scrollHeight-s.clientHeight)==Math.ceil(s.scrollTop))},[]);return{assistant:t,lookupAttribute:e,history:S,setInput:d,contentElRef:k,scrolledToTop:ue,userContent:D,setUserContent:M,onSubmitMessage:U,supportsFeedback:!!l&&!!g,onSubmitRating:s=>{if(l){switch(s.ratingMode){case _.LIKE:O(s.messageId,()=>({rating:s.rating}));break;case _.SCALE:O(s.messageId,()=>({scaleRating:s.scaleRating,scaleMax:s.scaleMax}));break;default:throw new ae(s)}l(s)}},onSubmitFeedback:s=>{g&&(O(s.messageId,()=>({feedbackSubmitted:!0})),g(s))},InsideMessage:r,onContactClick:p,contactButtonText:i,reset:ie,onContentScroll:de,onContentWheel:me,conversationId:ce}}const xe=({assistant:t,lookupAttribute:e,history:a,setInput:c,contentElRef:m,scrolledToTop:f,userContent:h,setUserContent:l,onSubmitMessage:g,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,onContactClick:d,contactButtonText:S,reset:w,onContentScroll:D,onContentWheel:M,conversationId:j})=>{const k=a.some(E=>E.completed||E.failed);return n.createElement("div",{className:"userflowjs-assistant-chat"},n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})}),n.createElement("div",{className:F({"userflowjs-assistant-chat__header":!0,"userflowjs-assistant-chat__header--content-scrolled":!f})},n.createElement(n.Fragment,null,n.createElement("h2",{className:"userflowjs-assistant-chat__title"},t.title),n.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:w},t.resetText))),n.createElement("div",{ref:m,className:"userflowjs-assistant-chat__content",onScroll:D,onWheel:M},!je(t.intro)&&n.createElement("div",{className:"userflowjs-assistant-chat__intro"},n.createElement(Ce,{doc:t.intro,lookupAttribute:e})),a.map((E,I)=>n.createElement(Le,{key:I,assistant:t,message:E,supportsFeedback:r,onSubmitRating:p,onSubmitFeedback:i,InsideMessage:o,conversationId:j,isLast:I===a.length-1}))),n.createElement("div",{className:"userflowjs-assistant-chat__prompt"},n.createElement(we,{textareaRef:c,placeholder:(a.length===0?t.promptEmptyPlaceholder:t.promptNonemptyPlaceholder)||"",value:h,onChange:l,onSubmit:()=>g(h)})),k&&d&&n.createElement("div",{className:"userflowjs-assistant-chat__contact"},n.createElement("button",{className:"userflowjs-tertiary-button",onClick:()=>d()},S)))},Le=({assistant:t,message:e,supportsFeedback:a,onSubmitRating:c,onSubmitFeedback:m,InsideMessage:f,conversationId:h,isLast:l})=>n.createElement("div",{className:"userflowjs-assistant-chat__message"},f&&n.createElement(f,{message:e}),n.createElement("div",{className:F({"userflowjs-assistant-chat__user-content":!0,"userflowjs-assistant-chat__user-content--enter":!!e.enterAnimation}),"data-assistant-conversation-id":h,"data-assistant-message-id":e.id},n.createElement("div",{style:{whiteSpace:"pre-wrap"}},e.userContent)),e.warning&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},"Warning: ",e.warning),n.createElement("div",{className:"userflowjs-assistant-chat__assistant-content"},n.createElement("div",null,n.createElement(ye,{html:e.assistantHtml})),e.error&&n.createElement("div",{className:"userflowjs-assistant-chat__error"},e.error)),e.sources&&e.sources.length>0&&n.createElement("div",{className:"userflowjs-assistant-chat__sources"},n.createElement("div",{className:"userflowjs-assistant-chat__sources-title"},t.sourcesText),e.sources.map((g,r)=>n.createElement("a",{key:r,className:"userflowjs-assistant-chat__source",href:Ie(g.url),target:"_blank",rel:"noreferrer noopener"},g.title))),a&&e.completed&&e.id&&(t.ratingMode===_.LIKE||t.ratingMode===_.SCALE&&l)&&n.createElement(Ae,{assistant:t,message:e,onSubmitRating:c,onSubmitFeedback:m})),Ae=({assistant:t,message:e,onSubmitRating:a,onSubmitFeedback:c})=>{const m=u.useRef(null),[f,h]=u.useState(""),l=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:_.LIKE,messageId:o,rating:i})}),m.current?.focus({preventScroll:!0}))},g=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:_.SCALE,messageId:o,scaleRating:i,scaleMax:t.scaleMax})}),m.current?.focus({preventScroll:!0}))},r=()=>{e.id&&(c({messageId:e.id,feedback:f.trim()}),h(""))},p=t.ratingMode===_.LIKE?n.createElement("button",{className:"userflowjs-assistant-chat__rating-option",disabled:!0},n.createElement(W,{icon:e.rating==y.DISLIKE?q:Q})):e.scaleRating&&e.scaleMax&&n.createElement("button",{className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--scale":!0}),disabled:!0},oe(t,e.scaleRating,e.scaleMax));return n.createElement("div",{className:`userflowjs-assistant-chat__rating userflowjs-assistant-chat__rating--${t.ratingMode}`},t.ratingMode===_.SCALE&&n.createElement("div",{className:"userflowjs-assistant-chat__rating-question"},t.scaleQuestion),e.feedbackSubmitted?n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks"},p,n.createElement("div",{className:"userflowjs-assistant-chat__rating-thanks-message"},t.feedbackThanksText)):(t.ratingMode===_.LIKE?e.rating:e.scaleRating)?n.createElement(Se,{textareaRef:m,className:"userflowjs-growing-textarea userflowjs-assistant-chat__feedback-textarea",mirrorClassName:"userflowjs-growing-textarea__mirror",textareaClassName:"userflowjs-textarea",placeholder:(t.ratingMode===_.LIKE?e.rating===y.LIKE?t.feedbackLikePlaceholder:t.feedbackDislikePlaceholder:t.scaleFeedbackPlaceholder)||"",value:f,onChange:h,onKeyDown:i=>{!i.shiftKey&&i.key==="Enter"&&(i.preventDefault(),r())}},p,n.createElement("button",{className:"userflowjs-assistant-chat__feedback-submit",onClick:()=>r()},n.createElement(W,{icon:Ee}))):n.createElement("div",{className:"userflowjs-assistant-chat__rating-options"},t.ratingMode===_.LIKE?[y.LIKE,y.DISLIKE].map(i=>(!e.rating||e.rating===i)&&n.createElement("button",{key:i,className:"userflowjs-assistant-chat__rating-option",onClick:e.rating?void 0:()=>l(i),disabled:!!e.rating,"data-testid":`assistant-chat-rating-${i}`},n.createElement(W,{icon:i==y.DISLIKE?q:Q}))):Fe(t).map(({value:i,label:o})=>n.createElement("button",{key:i,className:F({"userflowjs-assistant-chat__rating-option":!0,"userflowjs-assistant-chat__rating-option--large-scale":Re(o||"")}),onClick:e.scaleRating?void 0:()=>g(i),disabled:!!e.scaleRating,"data-testid":`assistant-chat-rating-${i}`},o))))};function B(t){let e=t;const a=f=>(f=f.replace(/\s*[*_`]*$/,""),f=f.replace(/(^|\n)\s*(\d+\.?|-|=)$/,""),f);e=a(e),e=e.replace(/\[([^\]\n]*)(\](\([^)\n]*)?)?$/,"$1"),e=a(e);const c=Array.from(e.matchAll(/\n( *)```/g));if(c.length%2===1){const f=c[c.length-1][1];e+=`
2
2
  `+f+"```"}else{let f=0;for(let r=e.length-1;r>=0;r--)if(e[r]===`
3
3
  `&&e[r-1]===`
4
- `){f=r;break}const h=[];let l=!1;const g=r=>r==null||r.match(/\W/);for(let r=f;r<e.length;r++){const p=e[r],i=p+e[r+1],o=i+e[r+2];let d=null;!l&&o==="***"||!l&&o==="___"&&(g(e[r-1])||g(e[r+3]))?d=o:!l&&i==="**"||!l&&i==="__"&&(g(e[r-1])||g(e[r+2]))?d=i:(!l&&p==="*"||!l&&p==="_"&&(g(e[r-1])||g(e[r+1]))||p==="`")&&(d=p),d!=null&&(e.slice(f,r+d.length).match(/\[[^\]\n]*\]\([^)\n]*$/)||(h[h.length-1]===d?(d==="`"&&(l=!1),h.pop()):(d==="`"&&(l=!0),h.push(d))),r+=d.length-1)}e+=h.reverse().join("")}return e}function x(t,e){t=t.trim(),e!==!1&&(t=t.replace(/(\n *```)?$/," {{USERFLOWCHATBRAIN}}$1"));let a=_e.sanitize(ke.parse(t));if(e!==!1){let c="userflowjs-assistant-brain";e&&(c+=` userflowjs-assistant-brain--${e}`),a=a.replace("{{USERFLOWCHATBRAIN}}",`<span class="${c}"><span></span><span></span><span></span><span></span></span>`)}return a=a.replace(/<a href=/g,'<a target="_blank" rel="noopener noreferrer" href='),a}const ye=({html:t})=>u.useMemo(()=>{if(!t)return null;const a=new DOMParser().parseFromString(t,"text/html");return re(a.body)},[t]);function re(t,e){if(t instanceof Element){if(t.tagName==="BODY")return n.createElement(n.Fragment,{key:e},se(t));{if(["script","style"].includes(t.tagName))return null;const a={key:e};for(const c of t.attributes){let m=c.name;m.startsWith("on")||(m==="class"&&(m="className"),a[m]=c.value)}return n.createElement(t.tagName.toLowerCase(),a,se(t))}}else return t instanceof Text?t.textContent:null}function se(t){const e=[];let a=0;for(const c of t.childNodes)e.push(re(c,a)),a++;return e}function Fe(t){let e=[];const a=t.scaleMax||5;for(let c=1;c<=a;c++)e.push({value:c,label:oe(t,c,a)});return e}function oe(t,e,a){if(t.scaleLabels)return t.scaleLabels[e-1]||e;{const c=ne[a]&&ne[a][e];return c?n.createElement(W,{icon:c,size:24}):e}}const ne={2:{1:P,2:$},3:{1:P,2:V,3:$},4:{1:X,2:P,3:$,4:Z},5:{1:X,2:P,3:V,4:$,5:Z}},ht=({block:t,session:e,assistantReply:a,initialUserContent:c,onContactClick:m,contactButtonText:f})=>{const h=t.assistantFlowId,l=be(),{t:g}=ve(),r=g("assistant.generic_error"),p=g("assistant.disconnected_error"),i=Ne(u.useMemo(()=>({assistant:a.assistant,lookupAttribute:Me(e.data),initialConversationId:a.conversationId,initialHistory:a.history,initialUserContent:c,onConversationIdChange:o=>{const d="assistantConversationId:"+h;o?Y.setItem(d,o):Y.removeItem(d)},submitMessage:({conversationId:o,userContent:d,callback:S})=>{l.assistantMessageInProgress=!0;const w=l.nextRef();l.send({kind:"SubmitAssistantMessage",ref:w,assistantFlowId:h,conversationId:o,userContent:d},{handlesRejection:!0}).catch(E=>{S({kind:"error",message:E.humanMessage||r})});const M=()=>{l.assistantMessageInProgress=void 0,l.off("private:assistantMessageEvent",j),l.off("private:disconnect",k)},j=E=>{if(E.ref!==w)return;const{event:I}=E;S(I),(I.kind=="done"||I.kind=="error")&&M()},k=()=>{S({kind:"error",message:p}),M()};return l.on("private:assistantMessageEvent",j),l.on("private:disconnect",k),{abort:()=>{l.send({kind:"AbortAssistantMessage"}),M()}}},submitRating:o=>{switch(o.ratingMode){case _.LIKE:l.send({kind:"SubmitAssistantRating",messageId:o.messageId,rating:o.rating});break;case _.SCALE:l.send({kind:"SubmitAssistantScaleRating",messageId:o.messageId,scaleRating:o.scaleRating,scaleMax:o.scaleMax});break;default:throw new ae(o)}},submitFeedback:o=>{l.send({kind:"SubmitAssistantFeedback",messageId:o.messageId,feedback:o.feedback})},onContactClick:m,contactButtonText:f}),[a,h,l,c,e.data,m,f,r,p]));return n.createElement(n.Fragment,null,n.createElement(xe,{...i}))};export{ht as ResourceCenterAssistantChat};
4
+ `){f=r;break}const h=[];let l=!1;const g=r=>r==null||r.match(/\W/);for(let r=f;r<e.length;r++){const p=e[r],i=p+e[r+1],o=i+e[r+2];let d=null;!l&&o==="***"||!l&&o==="___"&&(g(e[r-1])||g(e[r+3]))?d=o:!l&&i==="**"||!l&&i==="__"&&(g(e[r-1])||g(e[r+2]))?d=i:(!l&&p==="*"||!l&&p==="_"&&(g(e[r-1])||g(e[r+1]))||p==="`")&&(d=p),d!=null&&(e.slice(f,r+d.length).match(/\[[^\]\n]*\]\([^)\n]*$/)||(h[h.length-1]===d?(d==="`"&&(l=!1),h.pop()):(d==="`"&&(l=!0),h.push(d))),r+=d.length-1)}e+=h.reverse().join("")}return e}function x(t,e){t=t.trim(),e!==!1&&(t=t.replace(/(\n *```)?$/," {{USERFLOWCHATBRAIN}}$1"));let a=_e.sanitize(ke.parse(t));if(e!==!1){let c="userflowjs-assistant-brain";e&&(c+=` userflowjs-assistant-brain--${e}`),a=a.replace("{{USERFLOWCHATBRAIN}}",`<span class="${c}"><span></span><span></span><span></span><span></span></span>`)}return a=a.replace(/<a href=/g,'<a target="_blank" rel="noopener noreferrer" href='),a}const ye=({html:t})=>u.useMemo(()=>{if(!t)return null;const a=new DOMParser().parseFromString(t,"text/html");return re(a.body)},[t]);function re(t,e){if(t instanceof Element){if(t.tagName==="BODY")return n.createElement(n.Fragment,{key:e},se(t));{if(["script","style"].includes(t.tagName))return null;const a={key:e};for(const c of t.attributes){let m=c.name;m.startsWith("on")||(m==="class"&&(m="className"),a[m]=c.value)}return n.createElement(t.tagName.toLowerCase(),a,se(t))}}else return t instanceof Text?t.textContent:null}function se(t){const e=[];let a=0;for(const c of t.childNodes)e.push(re(c,a)),a++;return e}function Fe(t){let e=[];const a=t.scaleMax||5;for(let c=1;c<=a;c++)e.push({value:c,label:oe(t,c,a)});return e}function oe(t,e,a){if(t.scaleLabels)return t.scaleLabels[e-1]||e;{const c=ne[a]&&ne[a][e];return c?n.createElement(W,{icon:c,size:24}):e}}const ne={2:{1:P,2:$},3:{1:P,2:V,3:$},4:{1:X,2:P,3:$,4:Z},5:{1:X,2:P,3:V,4:$,5:Z}},gt=({block:t,session:e,assistantReply:a,initialUserContent:c,onContactClick:m,contactButtonText:f})=>{const h=t.assistantFlowId,l=be(),{t:g}=ve(),r=g("assistant.generic_error"),p=g("assistant.disconnected_error"),i=Ne(u.useMemo(()=>({assistant:a.assistant,lookupAttribute:Me(e.data),initialConversationId:a.conversationId,initialHistory:a.history,initialUserContent:c,onConversationIdChange:o=>{const d="assistantConversationId:"+h;o?Y.setItem(d,o):Y.removeItem(d)},submitMessage:({conversationId:o,userContent:d,callback:S})=>{l.assistantMessageInProgress=!0;const w=l.nextRef();l.send({kind:"SubmitAssistantMessage",ref:w,assistantFlowId:h,conversationId:o,userContent:d},{handlesRejection:!0}).catch(E=>{S({kind:"error",message:E.humanMessage||r})});const M=()=>{l.assistantMessageInProgress=void 0,l.off("private:assistantMessageEvent",j),l.off("private:disconnect",k)},j=E=>{if(E.ref!==w)return;const{event:I}=E;S(I),(I.kind=="done"||I.kind=="error")&&M()},k=()=>{S({kind:"error",message:p}),M()};return l.on("private:assistantMessageEvent",j),l.on("private:disconnect",k),{abort:()=>{l.send({kind:"AbortAssistantMessage"}),M()}}},submitRating:o=>{switch(o.ratingMode){case _.LIKE:l.send({kind:"SubmitAssistantRating",messageId:o.messageId,rating:o.rating});break;case _.SCALE:l.send({kind:"SubmitAssistantScaleRating",messageId:o.messageId,scaleRating:o.scaleRating,scaleMax:o.scaleMax});break;default:throw new ae(o)}},submitFeedback:o=>{l.send({kind:"SubmitAssistantFeedback",messageId:o.messageId,feedback:o.feedback})},onContactClick:m,contactButtonText:f}),[a,h,l,c,e.data,m,f,r,p]));return n.createElement(n.Fragment,null,n.createElement(xe,{...i}))};export{gt as ResourceCenterAssistantChat};
5
5
  //# sourceMappingURL=ResourceCenterAssistantChat.js.map
@@ -612,6 +612,10 @@ input[type="radio"]:checked:after {
612
612
  stroke: #1a57e6;
613
613
  transition: stroke-dasharray 300ms;
614
614
  }
615
+ .progress-spinner__fill-purple {
616
+ stroke: #865add;
617
+ transition: stroke-dasharray 300ms;
618
+ }
615
619
  .progress-spinner--indeterminate {
616
620
  animation: progress-spinner-indeterminate-spin 1000ms linear infinite;
617
621
  }
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 85c797ff2718b27d52ca3926b5c46f6c4242e36c
1
+ bfe051ad7c2cd8cfe2f7ee1f86823b68a5c88525
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1012652",
3
+ "version": "0.1.1012662",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/userflow.js CHANGED
@@ -1,9 +1,9 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterApp.js","vendor.react.js","vendor.core-js.js","vendor.object-assign.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","flow-host.styl.js","use-selector-element-monitoring.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.obj-str.js","Frame.js","vendor.react-dom.js","vendor.scheduler.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","use-element-rect.js","vendor.bignumber.js.js","BannerApp.js","vendor.phoenix.js","vendor.uuid.js","implicit-tracking.js","DebuggerUI.js","vendor.lodash.js","vendor.fortawesome.react-fontawesome.js","vendor.fortawesome.fontawesome-svg-core.js","vendor.react-day-picker.js","vendor.memoize-one.js","ui.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ResourceCenterApp.js","vendor.react.js","vendor.core-js.js","vendor.object-assign.js","client-context.js","vendor.i18next.js","vendor.babel.runtime.js","vendor.react-i18next.js","flow-host.styl.js","use-selector-element-monitoring.js","flow-condition-types.js","vendor.date-fns.js","roots.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","vendor.obj-str.js","Frame.js","vendor.react-dom.js","vendor.scheduler.js","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","vendor.memoize-one.js","vendor.bignumber.js.js","use-element-rect.js","BannerApp.js","vendor.phoenix.js","vendor.uuid.js","implicit-tracking.js","DebuggerUI.js","vendor.lodash.js","vendor.fortawesome.react-fontawesome.js","vendor.fortawesome.fontawesome-svg-core.js","vendor.react-day-picker.js","ui.js"])))=>i.map(i=>d[i]);
2
2
  import"./vendor.core-js.js";import{S as j}from"./vendor.phoenix.js";import{v as U}from"./vendor.uuid.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="e0faa25b-2abc-4d44-af22-1bddaaf4d6c8",t._sentryDebugIdIdentifier="sentry-dbid-e0faa25b-2abc-4d44-af22-1bddaaf4d6c8")}catch{}})();const Y="modulepreload",z=function(t){return new URL("./",import.meta.url).toString()+t},v={},g=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),h=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(s.map(c=>{if(c=z(c),c in v)return;v[c]=!0;const u=c.endsWith(".css"),T=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${T}`))return;const E=document.createElement("link");if(E.rel=u?"stylesheet":Y,u||(E.as="script"),E.crossOrigin="",E.href=c,h&&E.setAttribute("nonce",h),document.head.appendChild(E),u)return new Promise(($,F)=>{E.addEventListener("load",$),E.addEventListener("error",()=>F(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=a,window.dispatchEvent(h),!h.defaultPrevented)throw a}return n.then(a=>{for(const h of a||[])h.status==="rejected"&&r(h.reason);return e().catch(r)})};class l extends Error{constructor(e,s,i){super(e),Object.setPrototypeOf(this,l.prototype),this.name="UserflowError",this.code=s,this.humanMessage=i}}class B{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}isSupported(){if(typeof window>"u")return!1;try{return window[this.type]!=null}catch{return!1}}getItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].getItem(e):null}setItem(e,s){e=this.formatKey(e);{if(!this.isSupported())return;window[this.type].setItem(e,s)}}removeItem(e){return e=this.formatKey(e),this.isSupported()?window[this.type].removeItem(e):void 0}clear(){return this.isSupported()?window[this.type].clear():void 0}}const I=new B("localStorage"),f=new B("sessionStorage");function it(t){window.location.href=t}function x(){return window.location.href}function N(t){window.postMessage(t,window.origin)}function H(t){const e=i=>{if(i.source!==window||i.origin!==window.origin)return;const n=i.data;!n||typeof n!="object"||typeof n.kind!="string"||!n.kind.startsWith("userflow:")||t(n)===!0&&s()};window.addEventListener("message",e);const s=()=>window.removeEventListener("message",e);return s}function J(t){return new Promise(e=>{H(s=>{const i=t(s);return i?(e(i),!0):!1})})}const A=new Set;let O=!1;function Q(t){return X(),A.add(t),()=>{G(t)}}function G(t){A.delete(t)}function w(){A.forEach(t=>t())}function X(){if(O)return;O=!0;const{history:t}=window,e=s=>{const i=t[s];t[s]=(...n)=>{const r=i.apply(t,n);return w(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{w()}),window.addEventListener("userflow:replacestate",()=>{w()})):(e("pushState"),e("replaceState")),window.addEventListener("popstate",()=>{w()})}class Z{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){N({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=H(e),!1}async captureScreenshot(e,s,i,n){return N({kind:"userflow:crxScreenshot",x:e,y:s,width:i,height:n,devicePixelRatio:window.devicePixelRatio}),(await J(a=>a.kind==="userflow:crxScreenshotResult"?a:null)).imageDataUrl}}var C=(t=>(t.ACTION="ACTION",t.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",t.REPLACED="REPLACED",t.SNOOZED="SNOOZED",t.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",t.USERFLOWJS="USERFLOWJS",t.USER_CLOSED="USER_CLOSED",t))(C||{}),q=(t=>(t.SECOND="SECOND",t.MINUTE="MINUTE",t.HOUR="HOUR",t.DAY="DAY",t))(q||{}),m=(t=>(t.ACTION="ACTION",t.DRAFT="DRAFT",t.LINK="LINK",t.LAUNCHER_SEEN="LAUNCHER_SEEN",t.RESOURCE_CENTER="RESOURCE_CENTER",t.USERFLOWJS="USERFLOWJS",t))(m||{}),ee=(t=>(t.LIKE="LIKE",t.DISLIKE="DISLIKE",t))(ee||{}),S=(t=>(t.STRING="STRING",t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.DATETIME="DATETIME",t.LIST="LIST",t.RANDOM_AB="RANDOM_AB",t.RANDOM_NUMBER="RANDOM_NUMBER",t.CHECKLIST_TASK="CHECKLIST_TASK",t.FLOW="FLOW",t.FLOW_SESSION="FLOW_SESSION",t.FLOW_STEP="FLOW_STEP",t.FLOW_VERSION="FLOW_VERSION",t))(S||{}),k=(t=>(t.FLOW="FLOW",t.BANNER="BANNER",t.EMBED="EMBED",t.CHECKLIST="CHECKLIST",t.LAUNCHER="LAUNCHER",t.RESOURCE_CENTER="RESOURCE_CENTER",t))(k||{}),te=(t=>(t.ALWAYS_TRUE="ALWAYS_TRUE",t.ATTRIBUTE="ATTRIBUTE",t.CHECKLIST_TASK_CLICKED="CHECKLIST_TASK_CLICKED",t.CLAUSE="CLAUSE",t.ELEMENT="ELEMENT",t.EVENT="EVENT",t.FILLED_IN_INPUT="FILLED_IN_INPUT",t.FLOW="FLOW",t.INPUT_VALUE="INPUT_VALUE",t.PAGE="PAGE",t.SEGMENT="SEGMENT",t.TIME="TIME",t))(te||{}),se=(t=>(t.AUTO="AUTO",t.MANUAL="MANUAL",t))(se||{}),ie=(t=>(t.INPUT="INPUT",t))(ie||{}),ne=(t=>(t.ABSOLUTE_EQ="ABSOLUTE_EQ",t.ABSOLUTE_GT="ABSOLUTE_GT",t.ABSOLUTE_LT="ABSOLUTE_LT",t.AND="AND",t.BETWEEN="BETWEEN",t.CONTAINS="CONTAINS",t.EMPTY="EMPTY",t.ENDS_WITH="ENDS_WITH",t.EQ="EQ",t.EXCLUDES_ALL="EXCLUDES_ALL",t.EXCLUDES_ANY="EXCLUDES_ANY",t.FALSE="FALSE",t.GT="GT",t.GTE="GTE",t.INCLUDES_ALL="INCLUDES_ALL",t.INCLUDES_ANY="INCLUDES_ANY",t.LT="LT",t.LTE="LTE",t.NE="NE",t.NOT_CONTAINS="NOT_CONTAINS",t.NOT_EMPTY="NOT_EMPTY",t.NOT_REGEX="NOT_REGEX",t.OR="OR",t.REGEX="REGEX",t.RELATIVE_EQ="RELATIVE_EQ",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t.STARTS_WITH="STARTS_WITH",t.TRUE="TRUE",t.URL="URL",t))(ne||{}),re=(t=>(t.CLICK="CLICK",t.DISABLED="DISABLED",t.MOUSEDOWN="MOUSEDOWN",t.NOT_CLICK="NOT_CLICK",t.NOT_DISABLED="NOT_DISABLED",t.NOT_PRESENT="NOT_PRESENT",t.PRESENT="PRESENT",t))(re||{}),oe=(t=>(t.END_USER="END_USER",t.GROUP="GROUP",t))(oe||{}),ae=(t=>(t.BETWEEN="BETWEEN",t.EQ="EQ",t.GTE="GTE",t.LTE="LTE",t))(ae||{}),ce=(t=>(t.ANY="ANY",t.RELATIVE_BETWEEN="RELATIVE_BETWEEN",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t))(ce||{}),ue=(t=>(t.CURRENT_USER="CURRENT_USER",t.CURRENT_USER_CURRENT_GROUP="CURRENT_USER_CURRENT_GROUP",t.CURRENT_GROUP="CURRENT_GROUP",t))(ue||{}),le=(t=>(t.ASSET="ASSET",t.CARTOON="CARTOON",t.NONE="NONE",t.URL="URL",t))(le||{}),he=(t=>(t.INSIDE="INSIDE",t.OUTSIDE="OUTSIDE",t))(he||{}),de=(t=>(t.TOP_LEFT="TOP_LEFT",t.TOP_CENTER="TOP_CENTER",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_RIGHT="BOTTOM_RIGHT",t.BOTTOM_CENTER="BOTTOM_CENTER",t.BOTTOM_LEFT="BOTTOM_LEFT",t.CENTER="CENTER",t))(de||{}),fe=(t=>(t.GOOGLE="GOOGLE",t.STANDARD="STANDARD",t))(fe||{}),Ee=(t=>(t.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",t.DISMISS="DISMISS",t))(Ee||{}),Se=(t=>(t.DISMISS="DISMISS",t.NONE="NONE",t))(Se||{}),Te=(t=>(t.DEFAULT="DEFAULT",t.NARROW="NARROW",t.CHAINED_SQUARED="CHAINED_SQUARED",t.CHAINED_ROUNDED="CHAINED_ROUNDED",t.DOTTED="DOTTED",t.NUMBERED="NUMBERED",t))(Te||{}),ge=(t=>(t.TOP="TOP",t.BOTTOM="BOTTOM",t))(ge||{}),Ie=(t=>(t.DEFAULT="DEFAULT",t.PLAINTEXT="PLAINTEXT",t.CUSTOM="CUSTOM",t))(Ie||{}),we=(t=>(t.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",t.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",t.NONE="NONE",t))(we||{}),Ce=(t=>(t.BUBBLE="BUBBLE",t.END="END",t.ERROR="ERROR",t.FLAG="FLAG",t))(Ce||{}),ke=(t=>(t.MANUAL="MANUAL",t.NONE="NONE",t.SYNTHETIC="SYNTHETIC",t))(ke||{}),me=(t=>(t.BUBBLE="BUBBLE",t.HIDDEN="HIDDEN",t.MODAL="MODAL",t.TOOLTIP="TOOLTIP",t))(me||{}),Ue=(t=>(t.ABOVE="ABOVE",t.BELOW="BELOW",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(Ue||{}),pe=(t=>(t.CLOSE_FLOW="CLOSE_FLOW",t.EVAL_JS="EVAL_JS",t.GO_TO_STEP="GO_TO_STEP",t.NAVIGATE="NAVIGATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.SNOOZE="SNOOZE",t.START_FLOW="START_FLOW",t.TRACK_BUTTON_EVENT="TRACK_BUTTON_EVENT",t))(pe||{}),Le=(t=>(t.NEW_TAB="NEW_TAB",t.SAME_TAB="SAME_TAB",t))(Le||{}),Ne=(t=>(t.SET="SET",t.SET_DATETIME="SET_DATETIME",t.SET_DATETIME_ONCE="SET_DATETIME_ONCE",t.SET_ONCE="SET_ONCE",t.ADD="ADD",t.SUBTRACT="SUBTRACT",t.APPEND="APPEND",t.PREPEND="PREPEND",t.REMOVE="REMOVE",t.UNSET="UNSET",t))(Ne||{}),_e=(t=>(t.MULTILINE_TEXT="MULTILINE_TEXT",t.MULTIPLE_CHOICE="MULTIPLE_CHOICE",t.NPS="NPS",t.SCALE="SCALE",t.STARS="STARS",t.TEXT="TEXT",t))(_e||{}),_=(t=>(t.ACTION="ACTION",t.ANNOUNCEMENTS="ANNOUNCEMENTS",t.ASSISTANT="ASSISTANT",t.CHECKLIST="CHECKLIST",t.CONTACT="CONTACT",t.DIVIDER="DIVIDER",t.FLOWS="FLOWS",t.KNOWLEDGE_BASE="KNOWLEDGE_BASE",t.MESSAGE="MESSAGE",t.SUBPAGE="SUBPAGE",t))(_||{}),Ae=(t=>(t.CRISP="CRISP",t.CUSTOM="CUSTOM",t.FRESHCHAT="FRESHCHAT",t.HELPSCOUT="HELPSCOUT",t.HUBSPOT="HUBSPOT",t.INTERCOM="INTERCOM",t.ZENDESK="ZENDESK",t.ZENDESK_MESSENGER="ZENDESK_MESSENGER",t))(Ae||{}),Re=(t=>(t.BUTTON="BUTTON",t.INPUT="INPUT",t))(Re||{}),ve=(t=>(t.EMAIL="EMAIL",t.PHONE="PHONE",t.CHAT="CHAT",t))(ve||{}),Oe=(t=>(t.SILENT="SILENT",t.BADGE="BADGE",t.POPOUT="POPOUT",t.MODAL="MODAL",t.TOAST="TOAST",t))(Oe||{}),be=(t=>(t.LAUNCHER_CLICK="LAUNCHER_CLICK",t.LAUNCHER_HOVER="LAUNCHER_HOVER",t.TARGET_CLICK="TARGET_CLICK",t.TARGET_HOVER="TARGET_HOVER",t.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",t.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",t))(be||{}),W=(t=>(t.ACTIVATE="ACTIVATE",t.DEACTIVATE="DEACTIVATE",t.NEVER="NEVER",t))(W||{}),De=(t=>(t.AUTO="AUTO",t.TOP="TOP",t.RIGHT="RIGHT",t.BOTTOM="BOTTOM",t.LEFT="LEFT",t))(De||{}),ye=(t=>(t.START="START",t.CENTER="CENTER",t.END="END",t))(ye||{}),Me=(t=>(t.PERCENT="PERCENT",t.PX="PX",t))(Me||{}),Pe=(t=>(t.BEACON="BEACON",t.BUTTON="BUTTON",t.HIDDEN="HIDDEN",t.ICON="ICON",t))(Pe||{}),Be=(t=>(t.LAUNCHER="LAUNCHER",t.TARGET="TARGET",t))(Be||{}),xe=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(xe||{}),He=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(He||{}),Ge=(t=>(t.ALWAYS="ALWAYS",t.MULTIPLE="MULTIPLE",t.NEVER="NEVER",t.ONCE="ONCE",t.ONCE_PER_GROUP="ONCE_PER_GROUP",t))(Ge||{}),We=(t=>(t.NONE="NONE",t.PENDING_SCHEDULE="PENDING_SCHEDULE",t.SCHEDULED="SCHEDULED",t.FIRED="FIRED",t))(We||{}),Ve=(t=>(t.NONE="NONE",t.LIKE="LIKE",t.SCALE="SCALE",t))(Ve||{}),Ke=(t=>(t.HIDE="HIDE",t.BLOCK="BLOCK",t.OTHERS="OTHERS",t))(Ke||{});function $e(){return{customInputs:[],customNavigate:null,urlFilter:null,linkUrlDecorator:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[t=>!t.match(/\d$/)],"data-id":[t=>!t.match(/\d$/)]},inferenceClassNameFilters:[t=>!t.startsWith("css-")],baseZIndex:1234500,evalJsDisabled:!1}}const d=$e();function b(t){return Array.isArray(t)||(t=t?[t]:[]),t=t.map(e=>typeof e=="string"?new RegExp(e):e),t}function nt(t,e){return t.every(s=>typeof s=="function"?s(e):s instanceof RegExp?s.test(e):!0)}function Fe(){let t=x();if(d.urlFilter){if(t=d.urlFilter(t),typeof t!="string")throw new l("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(t)}catch(e){throw new l(`Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.
3
3
  Returned URL: `+t+`
4
- Error message: `+e.message)}}return t}let V="";try{V=localStorage.getItem("debug")||""}catch{}const K=V.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=R("log");o.group=R("group");o.groupCollapsed=R("groupCollapsed");o.groupEnd=function(){K&&console.groupEnd()};let p;function R(t){return function(e,...s){if(K){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const je=()=>g(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]));function Ye(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class D{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const y=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],ze=()=>g(()=>import("./BannerApp.js"),__vite__mapDeps([26,1,2,3,4,5,6,7,16,13,14,15,10,11,12,9,8,18,19,17,24,20,27,28])),L="1012652",Je=import.meta.url,M=50,Qe=5*60*1e3,P="userflowClientState";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.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],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.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTrackingQueue=[],this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),M))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+L),Q(this.onUrlChange),this.setTargetEnv(new Z),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const e of y)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),G(this.onUrlChange),this.destroyTargetEnv();for(const e of y)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new l("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(P,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(P);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(Je).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new j(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.flushImplicitTrackingQueue(),this.featureFlagEnabled("cff_implicit_events")===!0&&this.startImplicitTracking()}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
4
+ Error message: `+e.message)}}return t}let V="";try{V=localStorage.getItem("debug")||""}catch{}const K=V.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=R("log");o.group=R("group");o.groupCollapsed=R("groupCollapsed");o.groupEnd=function(){K&&console.groupEnd()};let p;function R(t){return function(e,...s){if(K){const i=performance.now(),n=p?Math.round(i-p):0;p=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const je=()=>g(()=>import("./ResourceCenterApp.js").then(t=>t.R),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]));function Ye(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class D{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const y=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],ze=()=>g(()=>import("./BannerApp.js"),__vite__mapDeps([27,1,2,3,4,5,6,7,16,13,14,15,10,11,12,9,8,18,19,17,26,20,28,29])),L="1012662",Je=import.meta.url,M=50,Qe=5*60*1e3,P="userflowClientState";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.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.bannerSession=null,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.embedSessions=[],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.debuggerUI=null,this.debuggerMountInProgress=!1,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.implicitTrackingQueue=[],this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{o(`builder ${e.kind} message received`,e);const s="idempotencyKey"in e&&typeof e.idempotencyKey=="string"?e.idempotencyKey:null;if(s&&this.idempotencyKeysSeen.has(s))return;const i=()=>{s&&this.idempotencyKeysSeen.add(s)};switch(e.kind){case"userflow:selectElement":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}}));return}case"userflow:selectElementCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,elementSelection:null}));return}case"userflow:startFlowWithToken":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0,activeApp:null,testStartConditionToken:void 0})),f.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),e.testStartCondition?this.setSessionStorageState(n=>({...n,activeApp:"startConditionTesting",testStartConditionToken:e.token})):this.onceIdentified(()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const n=()=>{const r=this.resourceCenterSession;r&&r.draftMode&&r.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",n))};this.on("resourceCenterChanged",n),n()}});return}case"userflow:testTracker":{i(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),this.setSessionStorageState(n=>({...n,isTargetTab:!0})),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),this.setSessionStorageState(n=>({...n,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}}));return}case"userflow:testTrackerCancel":{this.setSessionStorageState(n=>({...n,activeApp:null,trackerTesting:null}));return}}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout(()=>this.flushUrlChange(),M))},this.onUserActivity=()=>this.ensureConnected(),this.remountIfNecessary=()=>{!this.ui?.container||document.contains(this.ui.container)||(o("remounting UI because container was missing"),this.remount())},o("constructor, build="+L),Q(this.onUrlChange),this.setTargetEnv(new Z),this.checkTestUserAtBoot(),this.toggleUI(),this.checkDebuggerSession();for(const e of y)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),G(this.onUrlChange),this.destroyTargetEnv();for(const e of y)document.removeEventListener(e,this.remountIfNecessary)}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new l("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const s=e(this.getSessionStorageState());f.setItem(P,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(P);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e,this.emit("private:initialised")}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(Je).hostname==="js.getuserflow.com"&&e==="e.userflow.com"&&(e="e.getuserflow.com");const s="wss://"+e+"/end-users/"+this.clientToken+"/socket";this.socket=new j(s,{reconnectAfterMs:i=>[100,500,1e3,5e3][i-1]||1e4,timeout:20*1e3}),this.socket.connect(),this.socket.onOpen(()=>{o("socket opened")}),this.socket.onClose(()=>{this.emit("private:disconnect")}),this.socket.onError(i=>{console.log("Userflow.js socket error",i),this.reportCspIssue()}),this.channel=this.socket.channel(`end_users:${this.externalId}`,()=>this.makeChannelJoinPayload()),this.channel.join().receive("ok",i=>{this.logrocketAppId=i.logrocketAppId,this.featureFlags=new Set(i.featureFlags),o("channel joined"),this._socketStatus!=="connected"&&(this._socketStatus="connected"),this.flushImplicitTrackingQueue(),this.featureFlagEnabled("cff_implicit_events")===!0&&this.startImplicitTracking()}).receive("error",i=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(i.code)?(console.error(`Userflow.js resetting due to: [${i.code}] ${i.message}`),this.reset(),this.clientToken=null):i.code==="invalid_protocol_version"?(console.error(`Userflow.js destroying due to: [${i.code}] ${i.message}`),this.destroy()):console.log("Userflow.js channel join error",i)}),this.channel.on("server_message",i=>this.handleServerMessage(i)),this.channel.on("server_error",i=>{console.log(`Userflow.js server error (${i.code}): ${i.message}`+(i.details&&i.details.length>0?`
5
5
  Details:
6
- `+i.details.map(n=>(n.path?`${n.path}: `:"")+n.message):""))}),this.channel.onClose(()=>{this.flushImplicitTrackingQueue(),this.implicitTracking?.stop()})}async startImplicitTracking(){await g(()=>import("./implicit-tracking.js"),__vite__mapDeps([29,12,2,28,27])).then(e=>this.implicitTracking=new e.ImplicitTracking(this)).catch(e=>o(`Implicit tracking failed to load ${e}`)),this.implicitTracking.start()}flushImplicitTrackingQueue(){this.featureFlagEnabled("cff_implicit_events")===!0&&this.implicitTrackingQueue.forEach(e=>{this.trackRawEvent({name:"page_viewed",attributes:e})}),this.implicitTrackingQueue=[]}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const s={protocolVersion:2,userflowClientBuild:L,signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map(i=>({flowId:i.flow.id})),trackers:Array.from(this.trackers.values()).map(i=>({flowId:i.tracker.flowId})),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map(i=>({conditionId:i.condition.id,isTrue:i.isTrue})),previewFlowId:f.getItem("previewFlowId"),clientContext:e};return o("channel join payload",s),s}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout(()=>{if(this.hasDraftSession()||this.assistantMessageInProgress){this.debounceInactiveDisconnect();return}o("disconnecting from socket due to inactivity"),this.disconnect()},Qe)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some(e=>e.draftMode)}async send(e,{batch:s,endBatch:i,handlesRejection:n}={}){return(!this.inBatch||!["ToggleClientCondition","UpdateClientContext"].includes(e.kind))&&this.checkPushRateLimit(),this.ensureConnected(),s&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),i?this.endBatch():this.endBatchTimeout=window.setTimeout(()=>{this.endBatch()},M)),this.sendRaw(e,{handlesRejection:n})}async sendRaw(e,{handlesRejection:s}={}){return new Promise((i,n)=>{if(!this.channel){const c=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(s)throw Error(c);console.log(c,`
6
+ `+i.details.map(n=>(n.path?`${n.path}: `:"")+n.message):""))}),this.channel.onClose(()=>{this.flushImplicitTrackingQueue(),this.implicitTracking?.stop()})}async startImplicitTracking(){await g(()=>import("./implicit-tracking.js"),__vite__mapDeps([30,12,2,29,28])).then(e=>this.implicitTracking=new e.ImplicitTracking(this)).catch(e=>o(`Implicit tracking failed to load ${e}`)),this.implicitTracking.start()}flushImplicitTrackingQueue(){this.featureFlagEnabled("cff_implicit_events")===!0&&this.implicitTrackingQueue.forEach(e=>{this.trackRawEvent({name:"page_viewed",attributes:e})}),this.implicitTrackingQueue=[]}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const s={protocolVersion:2,userflowClientBuild:L,signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,bannerSessionId:this.bannerSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map(i=>({flowId:i.flow.id})),trackers:Array.from(this.trackers.values()).map(i=>({flowId:i.tracker.flowId})),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map(i=>({conditionId:i.condition.id,isTrue:i.isTrue})),previewFlowId:f.getItem("previewFlowId"),clientContext:e};return o("channel join payload",s),s}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout(()=>{if(this.hasDraftSession()||this.assistantMessageInProgress){this.debounceInactiveDisconnect();return}o("disconnecting from socket due to inactivity"),this.disconnect()},Qe)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.bannerSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some(e=>e.draftMode)}async send(e,{batch:s,endBatch:i,handlesRejection:n}={}){return(!this.inBatch||!["ToggleClientCondition","UpdateClientContext"].includes(e.kind))&&this.checkPushRateLimit(),this.ensureConnected(),s&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),i?this.endBatch():this.endBatchTimeout=window.setTimeout(()=>{this.endBatch()},M)),this.sendRaw(e,{handlesRejection:n})}async sendRaw(e,{handlesRejection:s}={}){return new Promise((i,n)=>{if(!this.channel){const c=`Userflow.js: send() should not be called if channel is not set. Message kind=${e.kind}`;if(s)throw Error(c);console.log(c,`
7
7
  Client message:`,e);return}o(`push ${e.kind} message`,e);const r=this.clientClock,a=()=>{this.serverClock=r,this.channel?.off("phx_error",h)},h=this.channel.on("phx_error",c=>{a();const u=`Userflow.js send ${e.kind} got phx_error`;this._socketStatus==="connected"&&console.log(u,`
8
8
  Client message:`,e,`
9
9
  Error:`,c),s&&n(new l(u))});this.channel.push("client_message",e).receive("ok",c=>{a(),i(c)}).receive("error",c=>{a();const u=`Userflow.js error reply (${c.code}): ${c.message}`;console.log(u,`
@@ -14,5 +14,5 @@ Error:`,c),s&&n(new l(u,c.code,c.message))})})}endBatch(){this.inBatch=!1,this.s
14
14
  - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.
15
15
  - The user legitimately being very active, in which case you can just ignore this error.
16
16
 
17
- If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:h,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":this.emit("private:checkSessionsAck");return;case"ServerDebug":return;case"AddLauncher":{const{session:u}=e,T=this.launcherSessions.findIndex(E=>E.flow.id===u.flow.id);T===-1?this.launcherSessions=[...this.launcherSessions,u]:this.launcherSessions=[...this.launcherSessions.slice(0,T),u,...this.launcherSessions.slice(T+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.emit("private:setFlowSession",e.session.version.id),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const u=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,u)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":h?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;case"AddEmbed":{const u=this.embedSessions?.findIndex(T=>T.flow.id===e.session.flow.id);u!==void 0&&u>=0?this.embedSessions=[...this.embedSessions?.slice(0,u)||[],e.session,...this.embedSessions?.slice(u+1)||[]]:this.embedSessions=[...this.embedSessions||[],e.session],this.emit("uistatechange");break}case"RemoveEmbed":{this.embedSessions=(this.embedSessions||[]).filter(u=>u.flow.id!==e.flowId),this.emit("uistatechange");break}default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!I.isSupported())throw new l("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=I.getItem(i);n||(n="anon-"+U(),I.setItem(i,n)),await this.identify(n,e,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(e={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,s={},{signature:i,membership:n}={}){if(o("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=i||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(n)},{batch:!0})}async updateGroup(e={},s={}){o("updateGroup");const i=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:i,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(e==null)return{};if(typeof e!="object")throw new l("Userflow: 'attributes' must be an object.");const s={};for(const i in e){if(!e.hasOwnProperty(i))continue;if(i==="traits"){const r=e[i];Object.assign(s,this.extractLegacyTraits(r));continue}let n=e[i];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n==null||Array.isArray(n))s[i]=this.normalizeAttributeLiteralOrList(i,n);else{if(typeof n!="object"||n==null)throw new l(`Userflow: Invalid value for '${i}' attribute.`);if("set"in n)s[i]={set:this.normalizeAttributeLiteralOrList(i,n.set),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("set_once"in n||"setOnce"in n)s[i]={setOnce:this.normalizeAttributeLiteralOrList(i,n.set_once??n.setOnce),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("add"in n){const r=n.add;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'add' value for '${i}' attribute. Must be a number or string.`);s[i]={add:r}}else if("subtract"in n){const r=n.subtract;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'subtract' value for '${i}' attribute. Must be a number or string.`);s[i]={subtract:r}}else if("append"in n)s[i]={append:this.normalizeAttributeLiteralOrList(i,n.append)};else if("prepend"in n)s[i]={prepend:this.normalizeAttributeLiteralOrList(i,n.prepend)};else if("remove"in n)s[i]={remove:this.normalizeAttributeLiteralOrList(i,n.remove)};else throw new l(`Userflow: Invalid value for '${i}' attribute.`)}}return s}normalizeAttributeLiteralOrList(e,s){return Array.isArray(s)?s.map(i=>this.normalizeAttributeLiteral(e,i)):this.normalizeAttributeLiteral(e,s)}normalizeAttributeLiteral(e,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new l(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new l(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const s=[];for(const i in e)e.hasOwnProperty(i)&&s.push({name:i,value:e[i]});e=s}return e.reduce((s,{name:i,value:n,dataType:r})=>{if(typeof i!="string"||i.length>100||!i.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",i),s;if(typeof n!="string")if(typeof n=="boolean")r||(r="boolean"),n=n?"true":"false";else if(typeof n=="number")r||(r=Number.isInteger(n)?"integer":"decimal"),n=String(n);else return this.warn(`userflow.identify: The value of trait '${i}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,n),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${i}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[i]={set:n,dataType:a},s},{})}async track(e,s={},{userOnly:i}={}){o(`track '${e}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!i,name:e,attributes:this.normalizeEventAttributes(s)},{batch:!0})}async trackRawEvent(e){const{name:s,attributes:i}=e;o(`track raw event '${s}'`,i),this.ensureIdentified(),await this.send({kind:"TrackRawEvent",name:s,attributes:this.normalizeEventAttributes(i)},{batch:!0})}normalizeEventAttributes(e){const s=this.normalizeAttributes(e);for(const i in s){if(!s.hasOwnProperty(i))continue;const n=s[i];if(!(n==null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||Array.isArray(n)||"set"in n))throw new l(`Userflow: Invalid value for '${i}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(x()),s=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:m.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();(!this.clientContext||e.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{}),typeof this.featureFlags>"u"&&this.implicitTrackingQueue.push({id:U(),page_title:document.title,...this.buildClientContext()}),this.featureFlagEnabled("cff_implicit_events")===!0&&this.trackRawEvent({name:"page_viewed",attributes:{id:U(),page_title:document.title}})}buildClientContext(){return{pageUrl:Fe(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return this.externalId!=null}on(e,s){let i=this.listeners.get(e);i||(i=new Set,this.listeners.set(e,i)),i.add(s)}off(e,s){const i=this.listeners.get(e);i&&i.delete(s)}emit(e,...s){const i=this.listeners.get(e);i&&Array.from(i).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach((e,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,I.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0),this.flushImplicitTrackingQueue()}async startFlow({flowId:e,stepCvid:s,startReason:i,once:n,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:C.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const h={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(h,{batch:r})}async trackButtonEvent(e,s,i,n){const r={kind:"TrackButtonEvent",eventName:e,stepCvid:i,sessionId:n,token:s};await this.send(r,{batch:!0})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===_.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Ye(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===_.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:h}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,h),this.checklistSession?.id===e.id&&this.setChecklistSession(null,h),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===k.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===k.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:e.id,endReason:s};await this.send(a,{batch:i})}async goToStep(e,s){o("goToStep",e.id,s.name||s.id),this.ensureIdentified();const i=this.send({kind:"GoToStep",sessionId:e.id,stepId:s.id});e.currentStep=s,this.emit("gotostep",{session:e,step:s}),await i}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===k.CHECKLIST&&this.endFlow(e,{endReason:C.USERFLOWJS})}setFlowSession(e,s=this.clientClock){const i=this.flowSession;this.flowSession=e,this.flowSessionClock=s,e&&!i&&(this.hideChecklist(),this.closeResourceCenter()),e==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,s=this.clientClock){const i=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=s,e===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==i?.id&&(this.checklistExpanded=!!f.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const s=this.resourceCenterSession;e=typeof e=="function"?e(this.resourceCenterSession):e,this.resourceCenterSession=e,e===null&&(this.resourceCenterOpen=!1),s&&s.id!==e?.id&&f.removeItem(`resourceCenterOpen:${s.id}`),e&&e.id!==s?.id&&(this.resourceCenterOpen=!!f.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:m.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const s=this.activeLauncherFlowId&&this.launcherSessions.find(i=>i.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:s}=e.version;e.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===W.DEACTIVATE?this.dismissLauncher(e,{endReason:C.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}checkDebuggerSession(){if(this.debuggerUI)return;const e=this.sessionStorageState?.debuggerApp;e&&e?.x&&e?.y&&this.mountDebugger()}async mountDebugger(){if(!this.debuggerMountInProgress){if(this.debuggerUI){this.debuggerUI.unmount();return}this.debuggerMountInProgress=!0;try{const{DebuggerUI:e}=await g(async()=>{const{DebuggerUI:s}=await import("./DebuggerUI.js");return{DebuggerUI:s}},__vite__mapDeps([30,1,2,3,18,19,4,5,6,7,17,13,14,15,10,11,12,21,16,31,32,33,34,35,27,28]));this.debuggerUI=new e(this,L),this.debuggerUI.mount()}catch(e){console.error("Userflow: Failed to mount debugger UI",e)}finally{this.debuggerMountInProgress=!1}}}unMountDebugger(){this.debuggerUI=null}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=g(()=>import("./ui.js"),__vite__mapDeps([36,1,2,3,18,19,4,5,6,7,27,28]));this.bannerSession&&ze(),this.resourceCenterSession&&je();const{RealUI:s}=await e;return new s(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;o("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:s}=await g(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([10,2,11,6,12])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new D([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await g(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(u=>u.f);return{conditionTypes:c}},__vite__mapDeps([10,2,11,6,12])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,h=i[a.type];n.untrack&&n.untrack(),n.untrack=h.track({sessionData:new D(r.data),condition:a,flipBackEvents:!0,callback:c=>{const u=n.isTrue;n.isTrue=c,!u&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),N({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const s=this.getAudio();e&&(s.src=e);const i=s.play();this.audioReady=!0,i&&i.catch(n=>{n.name})}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:s})).url}featureFlagEnabled(e){return this.featureFlags?this.featureFlags.has(e):!1}showNotification(e,s,i){const r={id:++this.notificationIdCounter,label:e,message:s,type:i};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter(s=>s.id!==e),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const t=Object.assign(window.userflow||{},Ze());window.userflow=t,window.studio1=t,qe()}function Ze(){const t=new Xe;return{_stubbed:!1,init(e){t.init(e)},identify(e,s={},i={}){return t.identify(e,s,i)},identifyAnonymous(e={},s={}){return t.identifyAnonymous(e,s)},isIdentified(){return t.isIdentified()},updateUser(e,s={}){return t.updateUser(e,s)},group(e,s={},i={}){return t.group(e,s,i)},updateGroup(e,s={}){return t.updateGroup(e,s)},track(e,s={},i={}){return t.track(e,s,i)},start(e,{once:s}={}){return t.startFlow({flowId:e,startReason:m.USERFLOWJS,once:s})},startFlow(e){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},startWalk(e){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},endAll(){return t.endAllFlows()},endChecklist(){return t.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){t.openResourceCenter()},closeResourceCenter(){t.closeResourceCenter()},toggleResourceCenter(){t.toggleResourceCenter()},setResourceCenterLauncherHidden(e){t.setResourceCenterLauncherHidden(e)},getResourceCenterState(){return t.getResourceCenterState()},setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){t.reset()},remount(){t.remount()},on(e,s){t.on(e,s)},off(e,s){t.off(e,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&d.customInputs.push({cssSelector:e})},registerCustomInput(e,s){d.customInputs.push({cssSelector:e,getValue:s})},setCustomNavigate(e){d.customNavigate=e},setUrlFilter(e){d.urlFilter=e},setLinkUrlDecorator(e){d.linkUrlDecorator=e,t.emit("uistatechange")},setInferenceAttributeNames(e){d.inferenceAttributeNames=e},setInferenceAttributeFilter(e,s){d.inferenceAttributeFilters[e]=b(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=b(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},debugger(){return t.mountDebugger()}}}function qe(){const t=window.userflow,e=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!e||e.length===0)){o(`processing ${e.length} items in the queue`);for(const[s,i,n]of e){if(typeof t[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=t[s](...n);i&&r&&typeof r.then=="function"&&r.then(i.resolve,i.reject)}o("queue processed")}}var rt=window.userflow;export{he as $,S as A,ze as B,Ae as C,Ee as D,C as E,se as F,I as G,_e as H,le as I,de as J,He as K,Pe as L,Se as M,be as N,De as O,Te as P,Be as Q,je as R,oe as S,Ce as T,l as U,ke as V,We as W,ye as X,Me as Y,Ue as Z,g as _,k as a,it as a0,x as a1,Le as a2,Ne as a3,fe as a4,Fe as a5,Q as a6,G as a7,re as a8,nt as a9,y as aa,Ve as ab,ee as ac,ce as b,ae as c,o as d,rt as default,q as e,ne as f,Ge as g,te as h,ue as i,D as j,_ as k,d as l,Ye as m,we as n,Ie as o,Oe as p,me as q,pe as r,Re as s,m as t,f as u,Ke as v,ve as w,xe as x,ie as y,ge as z};
17
+ If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:h,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":this.emit("private:checkSessionsAck");return;case"ServerDebug":return;case"AddLauncher":{const{session:u}=e,T=this.launcherSessions.findIndex(E=>E.flow.id===u.flow.id);T===-1?this.launcherSessions=[...this.launcherSessions,u]:this.launcherSessions=[...this.launcherSessions.slice(0,T),u,...this.launcherSessions.slice(T+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.emit("private:setFlowSession",e.session.version.id),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const u=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,u)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":h?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;case"AddEmbed":{const u=this.embedSessions?.findIndex(T=>T.flow.id===e.session.flow.id);u!==void 0&&u>=0?this.embedSessions=[...this.embedSessions?.slice(0,u)||[],e.session,...this.embedSessions?.slice(u+1)||[]]:this.embedSessions=[...this.embedSessions||[],e.session],this.emit("uistatechange");break}case"RemoveEmbed":{this.embedSessions=(this.embedSessions||[]).filter(u=>u.flow.id!==e.flowId),this.emit("uistatechange");break}default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!I.isSupported())throw new l("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=I.getItem(i);n||(n="anon-"+U(),I.setItem(i,n)),await this.identify(n,e,s)}getInitToken(){return this.clientToken}getIdentifiedUser(){return{externalId:this.externalId}}async updateUser(e={},s={}){o("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,s={},{signature:i,membership:n}={}){if(o("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId){o("group() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=i||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(s),membershipAttributes:this.normalizeAttributes(n)},{batch:!0})}async updateGroup(e={},s={}){o("updateGroup");const i=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:i,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(s.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(e==null)return{};if(typeof e!="object")throw new l("Userflow: 'attributes' must be an object.");const s={};for(const i in e){if(!e.hasOwnProperty(i))continue;if(i==="traits"){const r=e[i];Object.assign(s,this.extractLegacyTraits(r));continue}let n=e[i];if(typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n==null||Array.isArray(n))s[i]=this.normalizeAttributeLiteralOrList(i,n);else{if(typeof n!="object"||n==null)throw new l(`Userflow: Invalid value for '${i}' attribute.`);if("set"in n)s[i]={set:this.normalizeAttributeLiteralOrList(i,n.set),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("set_once"in n||"setOnce"in n)s[i]={setOnce:this.normalizeAttributeLiteralOrList(i,n.set_once??n.setOnce),dataType:this.normalizeDataType(i,n.data_type||n.dataType)};else if("add"in n){const r=n.add;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'add' value for '${i}' attribute. Must be a number or string.`);s[i]={add:r}}else if("subtract"in n){const r=n.subtract;if(typeof r!="string"&&typeof r!="number")throw new l(`Userflow: Invalid 'subtract' value for '${i}' attribute. Must be a number or string.`);s[i]={subtract:r}}else if("append"in n)s[i]={append:this.normalizeAttributeLiteralOrList(i,n.append)};else if("prepend"in n)s[i]={prepend:this.normalizeAttributeLiteralOrList(i,n.prepend)};else if("remove"in n)s[i]={remove:this.normalizeAttributeLiteralOrList(i,n.remove)};else throw new l(`Userflow: Invalid value for '${i}' attribute.`)}}return s}normalizeAttributeLiteralOrList(e,s){return Array.isArray(s)?s.map(i=>this.normalizeAttributeLiteral(e,i)):this.normalizeAttributeLiteral(e,s)}normalizeAttributeLiteral(e,s){if(s==null)return null;if(typeof s=="string"||typeof s=="number"||typeof s=="boolean")return s;throw new l(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,s){if(!s)return null;switch(s){case"string":return S.STRING;case"number":return S.NUMBER;case"boolean":return S.BOOLEAN;case"datetime":return S.DATETIME}throw new l(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const s=[];for(const i in e)e.hasOwnProperty(i)&&s.push({name:i,value:e[i]});e=s}return e.reduce((s,{name:i,value:n,dataType:r})=>{if(typeof i!="string"||i.length>100||!i.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",i),s;if(typeof n!="string")if(typeof n=="boolean")r||(r="boolean"),n=n?"true":"false";else if(typeof n=="number")r||(r=Number.isInteger(n)?"integer":"decimal"),n=String(n);else return this.warn(`userflow.identify: The value of trait '${i}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,n),s;let a=null;if(r)switch(r){case"string":a=S.STRING;break;case"boolean":a=S.BOOLEAN;break;case"integer":a=S.NUMBER;break;case"decimal":a=S.NUMBER;break;case"datetime":a=S.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${i}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,r),s}return s[i]={set:n,dataType:a},s},{})}async track(e,s={},{userOnly:i}={}){o(`track '${e}'`,s),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!i,name:e,attributes:this.normalizeEventAttributes(s)},{batch:!0})}async trackRawEvent(e){const{name:s,attributes:i}=e;o(`track raw event '${s}'`,i),this.ensureIdentified(),await this.send({kind:"TrackRawEvent",name:s,attributes:this.normalizeEventAttributes(i)},{batch:!0})}normalizeEventAttributes(e){const s=this.normalizeAttributes(e);for(const i in s){if(!s.hasOwnProperty(i))continue;const n=s[i];if(!(n==null||typeof n=="string"||typeof n=="boolean"||typeof n=="number"||Array.isArray(n)||"set"in n))throw new l(`Userflow: Invalid value for '${i}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return s}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout(()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()},0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(x()),s=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");s&&(o(`url contained flow ${s}`),this.startFlow({flowId:s,startReason:m.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();(!this.clientContext||e.pageUrl!==this.clientContext.pageUrl)&&(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{}),typeof this.featureFlags>"u"&&this.implicitTrackingQueue.push({id:U(),page_title:document.title,...this.buildClientContext()}),this.featureFlagEnabled("cff_implicit_events")===!0&&this.trackRawEvent({name:"page_viewed",attributes:{id:U(),page_title:document.title}})}buildClientContext(){return{pageUrl:Fe(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return this.externalId!=null}on(e,s){let i=this.listeners.get(e);i||(i=new Set,this.listeners.set(e,i)),i.add(s)}off(e,s){const i=this.listeners.get(e);i&&i.delete(s)}emit(e,...s){const i=this.listeners.get(e);i&&Array.from(i).forEach(r=>r(...s))}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){o("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setBannerSession(null),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach((e,s)=>{this.untrackClientCondition(s)}),this.firstIdentifyCallback=null,this.testUserIdentified=!1,I.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1,this.titleMonitored=void 0,this.titleObserver&&(this.titleObserver.disconnect(),this.titleObserver=void 0),this.flushImplicitTrackingQueue()}async startFlow({flowId:e,stepCvid:s,startReason:i,once:n,batch:r,replaceCurrent:a}){if(this.ensureIdentified(),a&&this.flowSession&&this.endFlow(this.flowSession,{endReason:C.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const h={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(h,{batch:r})}async trackButtonEvent(e,s,i,n){const r={kind:"TrackButtonEvent",eventName:e,stepCvid:i,sessionId:n,token:s};await this.send(r,{batch:!0})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===_.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Ye(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===_.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:h}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,h),this.checklistSession?.id===e.id&&this.setChecklistSession(null,h),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===k.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===k.FLOW&&this.emit("flowEnded",{flow:r,endReason:s});const a={kind:"EndFlow",sessionId:e.id,endReason:s};await this.send(a,{batch:i})}async goToStep(e,s){o("goToStep",e.id,s.name||s.id),this.ensureIdentified();const i=this.send({kind:"GoToStep",sessionId:e.id,stepId:s.id});e.currentStep=s,this.emit("gotostep",{session:e,step:s}),await i}async endAllFlows(){o("endAllFlows"),this.optimisticClockUIUpdate(()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)}),await this.send({kind:"EndAllFlows"})}async endChecklist(){o("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===k.CHECKLIST&&this.endFlow(e,{endReason:C.USERFLOWJS})}setFlowSession(e,s=this.clientClock){const i=this.flowSession;this.flowSession=e,this.flowSessionClock=s,e&&!i&&(this.hideChecklist(),this.closeResourceCenter()),e==null&&this.originalActiveElement&&(typeof this.originalActiveElement.focus=="function"&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,s=this.clientClock){const i=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=s,e===null&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==i?.id&&(this.checklistExpanded=!!f.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setBannerSession(e){this.bannerSession=e}setResourceCenterSession(e){const s=this.resourceCenterSession;e=typeof e=="function"?e(this.resourceCenterSession):e,this.resourceCenterSession=e,e===null&&(this.resourceCenterOpen=!1),s&&s.id!==e?.id&&f.removeItem(`resourceCenterOpen:${s.id}`),e&&e.id!==s?.id&&(this.resourceCenterOpen=!!f.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:m.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const s=this.activeLauncherFlowId&&this.launcherSessions.find(i=>i.flow.id===this.activeLauncherFlowId);s&&this.deactivateLauncher(s),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:s}=e.version;e.flow.id===this.activeLauncherFlowId&&(s?.dismissOn===W.DEACTIVATE?this.dismissLauncher(e,{endReason:C.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}checkDebuggerSession(){if(this.debuggerUI)return;const e=this.sessionStorageState?.debuggerApp;e&&e?.x&&e?.y&&this.mountDebugger()}async mountDebugger(){if(!this.debuggerMountInProgress){if(this.debuggerUI){this.debuggerUI.unmount();return}this.debuggerMountInProgress=!0;try{const{DebuggerUI:e}=await g(async()=>{const{DebuggerUI:s}=await import("./DebuggerUI.js");return{DebuggerUI:s}},__vite__mapDeps([31,1,2,3,18,19,4,5,6,7,17,13,14,15,10,11,12,21,16,32,33,34,35,24,28,29]));this.debuggerUI=new e(this,L),this.debuggerUI.mount()}catch(e){console.error("Userflow: Failed to mount debugger UI",e)}finally{this.debuggerMountInProgress=!1}}}unMountDebugger(){this.debuggerUI=null}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=g(()=>import("./ui.js"),__vite__mapDeps([36,1,2,3,18,19,4,5,6,7,28,29]));this.bannerSession&&ze(),this.resourceCenterSession&&je();const{RealUI:s}=await e;return new s(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;o("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:s}=await g(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([10,2,11,6,12])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new D([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await g(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(u=>u.f);return{conditionTypes:c}},__vite__mapDeps([10,2,11,6,12])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,h=i[a.type];n.untrack&&n.untrack(),n.untrack=h.track({sessionData:new D(r.data),condition:a,flipBackEvents:!0,callback:c=>{const u=n.isTrue;n.isTrue=c,!u&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),N({kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const s=this.getAudio();e&&(s.src=e);const i=s.play();this.audioReady=!0,i&&i.catch(n=>{n.name})}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,s){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:s})).url}featureFlagEnabled(e){return this.featureFlags?this.featureFlags.has(e):!1}showNotification(e,s,i){const r={id:++this.notificationIdCounter,label:e,message:s,type:i};this.notifications=[...this.notifications,r],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter(s=>s.id!==e),this.toggleUI()}warn(...e){console.warn(...e)}nextRef(){return this.refCounter++}}if(typeof window.userflow>"u"||window.userflow._stubbed){const t=Object.assign(window.userflow||{},Ze());window.userflow=t,window.studio1=t,qe()}function Ze(){const t=new Xe;return{_stubbed:!1,init(e){t.init(e)},identify(e,s={},i={}){return t.identify(e,s,i)},identifyAnonymous(e={},s={}){return t.identifyAnonymous(e,s)},isIdentified(){return t.isIdentified()},updateUser(e,s={}){return t.updateUser(e,s)},group(e,s={},i={}){return t.group(e,s,i)},updateGroup(e,s={}){return t.updateGroup(e,s)},track(e,s={},i={}){return t.track(e,s,i)},start(e,{once:s}={}){return t.startFlow({flowId:e,startReason:m.USERFLOWJS,once:s})},startFlow(e){return console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},startWalk(e){return console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)},endAll(){return t.endAllFlows()},endChecklist(){return t.endChecklist()},endAllFlows(){"Userflow.js: userflow.endAllFlows() has been deprecated. Use userflow.endAll() instead.";return window.userflow.endAll()},async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){t.openResourceCenter()},closeResourceCenter(){t.closeResourceCenter()},toggleResourceCenter(){t.toggleResourceCenter()},setResourceCenterLauncherHidden(e){t.setResourceCenterLauncherHidden(e)},getResourceCenterState(){return t.getResourceCenterState()},setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){t.reset()},remount(){t.remount()},on(e,s){t.on(e,s)},off(e,s){t.off(e,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&d.customInputs.push({cssSelector:e})},registerCustomInput(e,s){d.customInputs.push({cssSelector:e,getValue:s})},setCustomNavigate(e){d.customNavigate=e},setUrlFilter(e){d.urlFilter=e},setLinkUrlDecorator(e){d.linkUrlDecorator=e,t.emit("uistatechange")},setInferenceAttributeNames(e){d.inferenceAttributeNames=e},setInferenceAttributeFilter(e,s){d.inferenceAttributeFilters[e]=b(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=b(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},debugger(){return t.mountDebugger()}}}function qe(){const t=window.userflow,e=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!(!e||e.length===0)){o(`processing ${e.length} items in the queue`);for(const[s,i,n]of e){if(typeof t[s]!="function"){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const r=t[s](...n);i&&r&&typeof r.then=="function"&&r.then(i.resolve,i.reject)}o("queue processed")}}var rt=window.userflow;export{he as $,S as A,ze as B,Ae as C,Ee as D,C as E,se as F,I as G,_e as H,le as I,de as J,He as K,Pe as L,Se as M,be as N,De as O,Te as P,Be as Q,je as R,oe as S,Ce as T,l as U,ke as V,We as W,ye as X,Me as Y,Ue as Z,g as _,k as a,it as a0,x as a1,Le as a2,Ne as a3,fe as a4,Fe as a5,Q as a6,G as a7,re as a8,nt as a9,y as aa,Ve as ab,ee as ac,ce as b,ae as c,o as d,rt as default,q as e,ne as f,Ge as g,te as h,ue as i,D as j,_ as k,d as l,Ye as m,we as n,Ie as o,Oe as p,me as q,pe as r,Re as s,m as t,f as u,Ke as v,ve as w,xe as x,ie as y,ge as z};
18
18
  //# sourceMappingURL=userflow.js.map
package/vendor.core-js.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="88c6c411-ddbd-4b29-98b0-812d9c2de7ca",r._sentryDebugIdIdentifier="sentry-dbid-88c6c411-ddbd-4b29-98b0-812d9c2de7ca")}catch{}})();var Ze=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};Ze.SENTRY_RELEASE={id:"090c606b41b6403372c002bf000d443369946065"};var F=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var P=function(r){return r&&r.Math===Math&&r},f=P(typeof globalThis=="object"&&globalThis)||P(typeof window=="object"&&window)||P(typeof self=="object"&&self)||P(typeof F=="object"&&F)||P(typeof F=="object"&&F)||function(){return this}()||Function("return this")(),gr={},h=function(r){try{return!!r()}catch{return!0}},Qe=h,g=!Qe(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),rt=h,Or=!rt(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")}),et=Or,B=Function.prototype.call,O=et?B.bind(B):function(){return B.apply(B,arguments)},fe={},se={}.propertyIsEnumerable,ye=Object.getOwnPropertyDescriptor,tt=ye&&!se.call({1:2},1);fe.f=tt?function(e){var t=ye(this,e);return!!t&&t.enumerable}:se;var de=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}},$e=Or,pe=Function.prototype,sr=pe.call,nt=$e&&pe.bind.bind(sr,sr),b=$e?nt:function(r){return function(){return sr.apply(r,arguments)}},be=b,at=be({}.toString),ot=be("".slice),q=function(r){return ot(at(r),8,-1)},it=b,vt=h,ut=q,H=Object,ct=it("".split),lt=vt(function(){return!H("z").propertyIsEnumerable(0)})?function(r){return ut(r)==="String"?ct(r,""):H(r)}:H,Sr=function(r){return r==null},ft=Sr,st=TypeError,he=function(r){if(ft(r))throw new st("Can't call method on "+r);return r},yt=lt,dt=he,Er=function(r){return yt(dt(r))},X=typeof document=="object"&&document.all,d=typeof X>"u"&&X!==void 0?function(r){return typeof r=="function"||r===X}:function(r){return typeof r=="function"},$t=d,_=function(r){return typeof r=="object"?r!==null:$t(r)},Z=f,pt=d,bt=function(r){return pt(r)?r:void 0},ge=function(r,e){return arguments.length<2?bt(Z[r]):Z[r]&&Z[r][e]},ht=b,Oe=ht({}.isPrototypeOf),gt=f,_r=gt.navigator,Dr=_r&&_r.userAgent,Se=Dr?String(Dr):"",Ee=f,Q=Se,Mr=Ee.process,Ar=Ee.Deno,Fr=Mr&&Mr.versions||Ar&&Ar.version,Br=Fr&&Fr.v8,$,W;Br&&($=Br.split("."),W=$[0]>0&&$[0]<4?1:+($[0]+$[1]));!W&&Q&&($=Q.match(/Edge\/(\d+)/),(!$||$[1]>=74)&&($=Q.match(/Chrome\/(\d+)/),$&&(W=+$[1])));var Te=W,Lr=Te,Ot=h,St=f,Et=St.String,we=!!Object.getOwnPropertySymbols&&!Ot(function(){var r=Symbol("symbol detection");return!Et(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Lr&&Lr<41}),Tt=we,Ie=Tt&&!Symbol.sham&&typeof Symbol.iterator=="symbol",wt=ge,It=d,mt=Oe,Rt=Ie,Pt=Object,me=Rt?function(r){return typeof r=="symbol"}:function(r){var e=wt("Symbol");return It(e)&&mt(e.prototype,Pt(r))},Ct=String,Tr=function(r){try{return Ct(r)}catch{return"Object"}},jt=d,Nt=Tr,_t=TypeError,D=function(r){if(jt(r))return r;throw new _t(Nt(r)+" is not a function")},Dt=D,Mt=Sr,wr=function(r,e){var t=r[e];return Mt(t)?void 0:Dt(t)},rr=O,er=d,tr=_,At=TypeError,Ft=function(r,e){var t,n;if(e==="string"&&er(t=r.toString)&&!tr(n=rr(t,r))||er(t=r.valueOf)&&!tr(n=rr(t,r))||e!=="string"&&er(t=r.toString)&&!tr(n=rr(t,r)))return n;throw new At("Can't convert object to primitive value")},Re={exports:{}},Ur=f,Bt=Object.defineProperty,Ir=function(r,e){try{Bt(Ur,r,{value:e,configurable:!0,writable:!0})}catch{Ur[r]=e}return e},Lt=f,Ut=Ir,Gr="__core-js_shared__",xr=Re.exports=Lt[Gr]||Ut(Gr,{});(xr.versions||(xr.versions=[])).push({version:"3.39.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"});var mr=Re.exports,Kr=mr,Pe=function(r,e){return Kr[r]||(Kr[r]=e||{})},Gt=he,xt=Object,Kt=function(r){return xt(Gt(r))},Vt=b,kt=Kt,Wt=Vt({}.hasOwnProperty),S=Object.hasOwn||function(e,t){return Wt(kt(e),t)},zt=b,Yt=0,qt=Math.random(),Jt=zt(1 .toString),Ce=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Jt(++Yt+qt,36)},Ht=f,Xt=Pe,Vr=S,Zt=Ce,Qt=we,rn=Ie,m=Ht.Symbol,nr=Xt("wks"),en=rn?m.for||m:m&&m.withoutSetter||Zt,E=function(r){return Vr(nr,r)||(nr[r]=Qt&&Vr(m,r)?m[r]:en("Symbol."+r)),nr[r]},tn=O,kr=_,Wr=me,nn=wr,an=Ft,on=E,vn=TypeError,un=on("toPrimitive"),cn=function(r,e){if(!kr(r)||Wr(r))return r;var t=nn(r,un),n;if(t){if(e===void 0&&(e="default"),n=tn(t,r,e),!kr(n)||Wr(n))return n;throw new vn("Can't convert object to primitive value")}return e===void 0&&(e="number"),an(r,e)},ln=cn,fn=me,je=function(r){var e=ln(r,"string");return fn(e)?e:e+""},sn=f,zr=_,yr=sn.document,yn=zr(yr)&&zr(yr.createElement),dn=function(r){return yn?yr.createElement(r):{}},$n=g,pn=h,bn=dn,Ne=!$n&&!pn(function(){return Object.defineProperty(bn("div"),"a",{get:function(){return 7}}).a!==7}),hn=g,gn=O,On=fe,Sn=de,En=Er,Tn=je,wn=S,In=Ne,Yr=Object.getOwnPropertyDescriptor;gr.f=hn?Yr:function(e,t){if(e=En(e),t=Tn(t),In)try{return Yr(e,t)}catch{}if(wn(e,t))return Sn(!gn(On.f,e,t),e[t])};var J={},mn=g,Rn=h,Pn=mn&&Rn(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),Cn=_,jn=String,Nn=TypeError,M=function(r){if(Cn(r))return r;throw new Nn(jn(r)+" is not an object")},_n=g,Dn=Ne,Mn=Pn,L=M,qr=je,An=TypeError,ar=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,or="enumerable",ir="configurable",vr="writable";J.f=_n?Mn?function(e,t,n){if(L(e),t=qr(t),L(n),typeof e=="function"&&t==="prototype"&&"value"in n&&vr in n&&!n[vr]){var a=Fn(e,t);a&&a[vr]&&(e[t]=n.value,n={configurable:ir in n?n[ir]:a[ir],enumerable:or in n?n[or]:a[or],writable:!1})}return ar(e,t,n)}:ar:function(e,t,n){if(L(e),t=qr(t),L(n),Dn)try{return ar(e,t,n)}catch{}if("get"in n||"set"in n)throw new An("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Bn=g,Ln=J,Un=de,_e=Bn?function(r,e,t){return Ln.f(r,e,Un(1,t))}:function(r,e,t){return r[e]=t,r},De={exports:{}},dr=g,Gn=S,Me=Function.prototype,xn=dr&&Object.getOwnPropertyDescriptor,Rr=Gn(Me,"name"),Kn=Rr&&function(){}.name==="something",Vn=Rr&&(!dr||dr&&xn(Me,"name").configurable),kn={EXISTS:Rr,PROPER:Kn,CONFIGURABLE:Vn},Wn=b,zn=d,$r=mr,Yn=Wn(Function.toString);zn($r.inspectSource)||($r.inspectSource=function(r){return Yn(r)});var Ae=$r.inspectSource,qn=f,Jn=d,Jr=qn.WeakMap,Hn=Jn(Jr)&&/native code/.test(String(Jr)),Xn=Pe,Zn=Ce,Hr=Xn("keys"),Qn=function(r){return Hr[r]||(Hr[r]=Zn(r))},Fe={},ra=Hn,Be=f,ea=_,ta=_e,ur=S,cr=mr,na=Qn,aa=Fe,Xr="Object already initialized",pr=Be.TypeError,oa=Be.WeakMap,z,N,Y,ia=function(r){return Y(r)?N(r):z(r,{})},va=function(r){return function(e){var t;if(!ea(e)||(t=N(e)).type!==r)throw new pr("Incompatible receiver, "+r+" required");return t}};if(ra||cr.state){var p=cr.state||(cr.state=new oa);p.get=p.get,p.has=p.has,p.set=p.set,z=function(r,e){if(p.has(r))throw new pr(Xr);return e.facade=r,p.set(r,e),e},N=function(r){return p.get(r)||{}},Y=function(r){return p.has(r)}}else{var I=na("state");aa[I]=!0,z=function(r,e){if(ur(r,I))throw new pr(Xr);return e.facade=r,ta(r,I,e),e},N=function(r){return ur(r,I)?r[I]:{}},Y=function(r){return ur(r,I)}}var ua={set:z,get:N,has:Y,enforce:ia,getterFor:va},Pr=b,ca=h,la=d,U=S,br=g,fa=kn.CONFIGURABLE,sa=Ae,Le=ua,ya=Le.enforce,da=Le.get,Zr=String,K=Object.defineProperty,$a=Pr("".slice),pa=Pr("".replace),ba=Pr([].join),ha=br&&!ca(function(){return K(function(){},"length",{value:8}).length!==8}),ga=String(String).split("String"),Oa=De.exports=function(r,e,t){$a(Zr(e),0,7)==="Symbol("&&(e="["+pa(Zr(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!U(r,"name")||fa&&r.name!==e)&&(br?K(r,"name",{value:e,configurable:!0}):r.name=e),ha&&t&&U(t,"arity")&&r.length!==t.arity&&K(r,"length",{value:t.arity});try{t&&U(t,"constructor")&&t.constructor?br&&K(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch{}var n=ya(r);return U(n,"source")||(n.source=ba(ga,typeof e=="string"?e:"")),r};Function.prototype.toString=Oa(function(){return la(this)&&da(this).source||sa(this)},"toString");var Sa=De.exports,Ea=d,Ta=J,wa=Sa,Ia=Ir,ma=function(r,e,t,n){n||(n={});var a=n.enumerable,o=n.name!==void 0?n.name:e;if(Ea(t)&&wa(t,o,n),n.global)a?r[e]=t:Ia(e,t);else{try{n.unsafe?r[e]&&(a=!0):delete r[e]}catch{}a?r[e]=t:Ta.f(r,e,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return r},Ue={},Ra=Math.ceil,Pa=Math.floor,Ca=Math.trunc||function(e){var t=+e;return(t>0?Pa:Ra)(t)},ja=Ca,Ge=function(r){var e=+r;return e!==e||e===0?0:ja(e)},Na=Ge,_a=Math.max,Da=Math.min,Ma=function(r,e){var t=Na(r);return t<0?_a(t+e,0):Da(t,e)},Aa=Ge,Fa=Math.min,Ba=function(r){var e=Aa(r);return e>0?Fa(e,9007199254740991):0},La=Ba,xe=function(r){return La(r.length)},Ua=Er,Ga=Ma,xa=xe,Qr=function(r){return function(e,t,n){var a=Ua(e),o=xa(a);if(o===0)return!r&&-1;var i=Ga(n,o),v;if(r&&t!==t){for(;o>i;)if(v=a[i++],v!==v)return!0}else for(;o>i;i++)if((r||i in a)&&a[i]===t)return r||i||0;return!r&&-1}},Ka={includes:Qr(!0),indexOf:Qr(!1)},Va=b,lr=S,ka=Er,Wa=Ka.indexOf,za=Fe,re=Va([].push),Ya=function(r,e){var t=ka(r),n=0,a=[],o;for(o in t)!lr(za,o)&&lr(t,o)&&re(a,o);for(;e.length>n;)lr(t,o=e[n++])&&(~Wa(a,o)||re(a,o));return a},qa=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ja=Ya,Ha=qa,Xa=Ha.concat("length","prototype");Ue.f=Object.getOwnPropertyNames||function(e){return Ja(e,Xa)};var Ke={};Ke.f=Object.getOwnPropertySymbols;var Za=ge,Qa=b,ro=Ue,eo=Ke,to=M,no=Qa([].concat),ao=Za("Reflect","ownKeys")||function(e){var t=ro.f(to(e)),n=eo.f;return n?no(t,n(e)):t},ee=S,oo=ao,io=gr,vo=J,uo=function(r,e,t){for(var n=oo(e),a=vo.f,o=io.f,i=0;i<n.length;i++){var v=n[i];!ee(r,v)&&!(t&&ee(t,v))&&a(r,v,o(e,v))}},co=h,lo=d,fo=/#|\.prototype\./,A=function(r,e){var t=yo[so(r)];return t===po?!0:t===$o?!1:lo(e)?co(e):!!e},so=A.normalize=function(r){return String(r).replace(fo,".").toLowerCase()},yo=A.data={},$o=A.NATIVE="N",po=A.POLYFILL="P",Ve=A,G=f,bo=gr.f,ho=_e,go=ma,Oo=Ir,So=uo,Eo=Ve,To=function(r,e){var t=r.target,n=r.global,a=r.stat,o,i,v,u,c,s;if(n?i=G:a?i=G[t]||Oo(t,{}):i=G[t]&&G[t].prototype,i)for(v in e){if(c=e[v],r.dontCallGetSet?(s=bo(i,v),u=s&&s.value):u=i[v],o=Eo(n?v:t+(a?".":"#")+v,r.forced),!o&&u!==void 0){if(typeof c==typeof u)continue;So(c,u)}(r.sham||u&&u.sham)&&ho(c,"sham",!0),go(i,v,c,r)}},ke={},te=D,wo=TypeError,Io=function(r){var e,t;this.promise=new r(function(n,a){if(e!==void 0||t!==void 0)throw new wo("Bad Promise constructor");e=n,t=a}),this.resolve=te(e),this.reject=te(t)};ke.f=function(r){return new Io(r)};var mo=function(r){try{return{error:!1,value:r()}}catch(e){return{error:!0,value:e}}},Ro=q,Po=b,Co=function(r){if(Ro(r)==="Function")return Po(r)},ne=Co,jo=D,No=Or,_o=ne(ne.bind),Do=function(r,e){return jo(r),e===void 0?r:No?_o(r,e):function(){return r.apply(e,arguments)}},We={},Mo=E,Ao=We,Fo=Mo("iterator"),Bo=Array.prototype,Lo=function(r){return r!==void 0&&(Ao.Array===r||Bo[Fo]===r)},Uo=E,Go=Uo("toStringTag"),ze={};ze[Go]="z";var xo=String(ze)==="[object z]",Ko=xo,Vo=d,V=q,ko=E,Wo=ko("toStringTag"),zo=Object,Yo=V(function(){return arguments}())==="Arguments",qo=function(r,e){try{return r[e]}catch{}},Jo=Ko?V:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=qo(e=zo(r),Wo))=="string"?t:Yo?V(e):(n=V(e))==="Object"&&Vo(e.callee)?"Arguments":n},Ho=Jo,ae=wr,Xo=Sr,Zo=We,Qo=E,ri=Qo("iterator"),Ye=function(r){if(!Xo(r))return ae(r,ri)||ae(r,"@@iterator")||Zo[Ho(r)]},ei=O,ti=D,ni=M,ai=Tr,oi=Ye,ii=TypeError,vi=function(r,e){var t=arguments.length<2?oi(r):e;if(ti(t))return ni(ei(t,r));throw new ii(ai(r)+" is not iterable")},ui=O,oe=M,ci=wr,li=function(r,e,t){var n,a;oe(r);try{if(n=ci(r,"return"),!n){if(e==="throw")throw t;return t}n=ui(n,r)}catch(o){a=!0,n=o}if(e==="throw")throw t;if(a)throw n;return oe(n),t},fi=Do,si=O,yi=M,di=Tr,$i=Lo,pi=xe,ie=Oe,bi=vi,hi=Ye,ve=li,gi=TypeError,k=function(r,e){this.stopped=r,this.result=e},ue=k.prototype,Oi=function(r,e,t){var n=t&&t.that,a=!!(t&&t.AS_ENTRIES),o=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=fi(e,n),c,s,T,R,l,w,Cr,jr=function(y){return c&&ve(c,"normal",y),new k(!0,y)},Nr=function(y){return a?(yi(y),v?u(y[0],y[1],jr):u(y[0],y[1])):v?u(y,jr):u(y)};if(o)c=r.iterator;else if(i)c=r;else{if(s=hi(r),!s)throw new gi(di(r)+" is not iterable");if($i(s)){for(T=0,R=pi(r);R>T;T++)if(l=Nr(r[T]),l&&ie(ue,l))return l;return new k(!1)}c=bi(r,s)}for(w=o?r.next:c.next;!(Cr=si(w,c)).done;){try{l=Nr(Cr.value)}catch(y){ve(c,"throw",y)}if(typeof l=="object"&&l&&ie(ue,l))return l}return new k(!1)},Si=f,qe=Si.Promise,Ei=E,Je=Ei("iterator"),He=!1;try{var Ti=0,ce={next:function(){return{done:!!Ti++}},return:function(){He=!0}};ce[Je]=function(){return this},Array.from(ce,function(){throw 2})}catch{}var wi=function(r,e){try{if(!e&&!He)return!1}catch{return!1}var t=!1;try{var n={};n[Je]=function(){return{next:function(){return{done:t=!0}}}},r(n)}catch{}return t},C=f,Ii=Se,mi=q,x=function(r){return Ii.slice(0,r.length)===r},Ri=function(){return x("Bun/")?"BUN":x("Cloudflare-Workers")?"CLOUDFLARE":x("Deno/")?"DENO":x("Node.js/")?"NODE":C.Bun&&typeof Bun.version=="string"?"BUN":C.Deno&&typeof Deno.version=="object"?"DENO":mi(C.process)==="process"?"NODE":C.window&&C.document?"BROWSER":"REST"}(),Pi=f,j=qe,Ci=d,ji=Ve,Ni=Ae,_i=E,le=Ri,fr=Te;j&&j.prototype;var Di=_i("species"),hr=!1,Xe=Ci(Pi.PromiseRejectionEvent),Mi=ji("Promise",function(){var r=Ni(j),e=r!==String(j);if(!e&&fr===66)return!0;if(!fr||fr<51||!/native code/.test(r)){var t=new j(function(o){o(1)}),n=function(o){o(function(){},function(){})},a=t.constructor={};if(a[Di]=n,hr=t.then(function(){})instanceof n,!hr)return!0}return!e&&(le==="BROWSER"||le==="DENO")&&!Xe}),Ai={CONSTRUCTOR:Mi,REJECTION_EVENT:Xe,SUBCLASSING:hr},Fi=qe,Bi=wi,Li=Ai.CONSTRUCTOR,Ui=Li||!Bi(function(r){Fi.all(r).then(void 0,function(){})}),Gi=To,xi=O,Ki=D,Vi=ke,ki=mo,Wi=Oi,zi=Ui;Gi({target:"Promise",stat:!0,forced:zi},{allSettled:function(e){var t=this,n=Vi.f(t),a=n.resolve,o=n.reject,i=ki(function(){var v=Ki(t.resolve),u=[],c=0,s=1;Wi(e,function(T){var R=c++,l=!1;s++,xi(v,t,T).then(function(w){l||(l=!0,u[R]={status:"fulfilled",value:w},--s||a(u))},function(w){l||(l=!0,u[R]={status:"rejected",reason:w},--s||a(u))})}),--s||a(u)});return i.error&&o(i.value),n.promise}});export{F as c,Yi as g};
1
+ (function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[e]="7cc66c5b-1b1f-4ed1-bf6f-d4aca1684bd0",r._sentryDebugIdIdentifier="sentry-dbid-7cc66c5b-1b1f-4ed1-bf6f-d4aca1684bd0")}catch{}})();var Ze=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};Ze.SENTRY_RELEASE={id:"0718bebb4b71e806df6a062c79c1cd879589723d"};var F=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Yi(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var P=function(r){return r&&r.Math===Math&&r},f=P(typeof globalThis=="object"&&globalThis)||P(typeof window=="object"&&window)||P(typeof self=="object"&&self)||P(typeof F=="object"&&F)||P(typeof F=="object"&&F)||function(){return this}()||Function("return this")(),gr={},h=function(r){try{return!!r()}catch{return!0}},Qe=h,g=!Qe(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),rt=h,Or=!rt(function(){var r=function(){}.bind();return typeof r!="function"||r.hasOwnProperty("prototype")}),et=Or,B=Function.prototype.call,O=et?B.bind(B):function(){return B.apply(B,arguments)},fe={},se={}.propertyIsEnumerable,ye=Object.getOwnPropertyDescriptor,tt=ye&&!se.call({1:2},1);fe.f=tt?function(e){var t=ye(this,e);return!!t&&t.enumerable}:se;var de=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}},$e=Or,be=Function.prototype,sr=be.call,nt=$e&&be.bind.bind(sr,sr),p=$e?nt:function(r){return function(){return sr.apply(r,arguments)}},pe=p,at=pe({}.toString),ot=pe("".slice),q=function(r){return ot(at(r),8,-1)},it=p,vt=h,ut=q,H=Object,ct=it("".split),lt=vt(function(){return!H("z").propertyIsEnumerable(0)})?function(r){return ut(r)==="String"?ct(r,""):H(r)}:H,Sr=function(r){return r==null},ft=Sr,st=TypeError,he=function(r){if(ft(r))throw new st("Can't call method on "+r);return r},yt=lt,dt=he,Er=function(r){return yt(dt(r))},X=typeof document=="object"&&document.all,d=typeof X>"u"&&X!==void 0?function(r){return typeof r=="function"||r===X}:function(r){return typeof r=="function"},$t=d,_=function(r){return typeof r=="object"?r!==null:$t(r)},Z=f,bt=d,pt=function(r){return bt(r)?r:void 0},ge=function(r,e){return arguments.length<2?pt(Z[r]):Z[r]&&Z[r][e]},ht=p,Oe=ht({}.isPrototypeOf),gt=f,_r=gt.navigator,Dr=_r&&_r.userAgent,Se=Dr?String(Dr):"",Ee=f,Q=Se,Mr=Ee.process,Ar=Ee.Deno,Fr=Mr&&Mr.versions||Ar&&Ar.version,Br=Fr&&Fr.v8,$,W;Br&&($=Br.split("."),W=$[0]>0&&$[0]<4?1:+($[0]+$[1]));!W&&Q&&($=Q.match(/Edge\/(\d+)/),(!$||$[1]>=74)&&($=Q.match(/Chrome\/(\d+)/),$&&(W=+$[1])));var Te=W,Lr=Te,Ot=h,St=f,Et=St.String,we=!!Object.getOwnPropertySymbols&&!Ot(function(){var r=Symbol("symbol detection");return!Et(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&Lr&&Lr<41}),Tt=we,Ie=Tt&&!Symbol.sham&&typeof Symbol.iterator=="symbol",wt=ge,It=d,mt=Oe,Rt=Ie,Pt=Object,me=Rt?function(r){return typeof r=="symbol"}:function(r){var e=wt("Symbol");return It(e)&&mt(e.prototype,Pt(r))},Ct=String,Tr=function(r){try{return Ct(r)}catch{return"Object"}},jt=d,Nt=Tr,_t=TypeError,D=function(r){if(jt(r))return r;throw new _t(Nt(r)+" is not a function")},Dt=D,Mt=Sr,wr=function(r,e){var t=r[e];return Mt(t)?void 0:Dt(t)},rr=O,er=d,tr=_,At=TypeError,Ft=function(r,e){var t,n;if(e==="string"&&er(t=r.toString)&&!tr(n=rr(t,r))||er(t=r.valueOf)&&!tr(n=rr(t,r))||e!=="string"&&er(t=r.toString)&&!tr(n=rr(t,r)))return n;throw new At("Can't convert object to primitive value")},Re={exports:{}},Ur=f,Bt=Object.defineProperty,Ir=function(r,e){try{Bt(Ur,r,{value:e,configurable:!0,writable:!0})}catch{Ur[r]=e}return e},Lt=f,Ut=Ir,Gr="__core-js_shared__",xr=Re.exports=Lt[Gr]||Ut(Gr,{});(xr.versions||(xr.versions=[])).push({version:"3.39.0",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.39.0/LICENSE",source:"https://github.com/zloirock/core-js"});var mr=Re.exports,Kr=mr,Pe=function(r,e){return Kr[r]||(Kr[r]=e||{})},Gt=he,xt=Object,Kt=function(r){return xt(Gt(r))},Vt=p,kt=Kt,Wt=Vt({}.hasOwnProperty),S=Object.hasOwn||function(e,t){return Wt(kt(e),t)},zt=p,Yt=0,qt=Math.random(),Jt=zt(1 .toString),Ce=function(r){return"Symbol("+(r===void 0?"":r)+")_"+Jt(++Yt+qt,36)},Ht=f,Xt=Pe,Vr=S,Zt=Ce,Qt=we,rn=Ie,m=Ht.Symbol,nr=Xt("wks"),en=rn?m.for||m:m&&m.withoutSetter||Zt,E=function(r){return Vr(nr,r)||(nr[r]=Qt&&Vr(m,r)?m[r]:en("Symbol."+r)),nr[r]},tn=O,kr=_,Wr=me,nn=wr,an=Ft,on=E,vn=TypeError,un=on("toPrimitive"),cn=function(r,e){if(!kr(r)||Wr(r))return r;var t=nn(r,un),n;if(t){if(e===void 0&&(e="default"),n=tn(t,r,e),!kr(n)||Wr(n))return n;throw new vn("Can't convert object to primitive value")}return e===void 0&&(e="number"),an(r,e)},ln=cn,fn=me,je=function(r){var e=ln(r,"string");return fn(e)?e:e+""},sn=f,zr=_,yr=sn.document,yn=zr(yr)&&zr(yr.createElement),dn=function(r){return yn?yr.createElement(r):{}},$n=g,bn=h,pn=dn,Ne=!$n&&!bn(function(){return Object.defineProperty(pn("div"),"a",{get:function(){return 7}}).a!==7}),hn=g,gn=O,On=fe,Sn=de,En=Er,Tn=je,wn=S,In=Ne,Yr=Object.getOwnPropertyDescriptor;gr.f=hn?Yr:function(e,t){if(e=En(e),t=Tn(t),In)try{return Yr(e,t)}catch{}if(wn(e,t))return Sn(!gn(On.f,e,t),e[t])};var J={},mn=g,Rn=h,Pn=mn&&Rn(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),Cn=_,jn=String,Nn=TypeError,M=function(r){if(Cn(r))return r;throw new Nn(jn(r)+" is not an object")},_n=g,Dn=Ne,Mn=Pn,L=M,qr=je,An=TypeError,ar=Object.defineProperty,Fn=Object.getOwnPropertyDescriptor,or="enumerable",ir="configurable",vr="writable";J.f=_n?Mn?function(e,t,n){if(L(e),t=qr(t),L(n),typeof e=="function"&&t==="prototype"&&"value"in n&&vr in n&&!n[vr]){var a=Fn(e,t);a&&a[vr]&&(e[t]=n.value,n={configurable:ir in n?n[ir]:a[ir],enumerable:or in n?n[or]:a[or],writable:!1})}return ar(e,t,n)}:ar:function(e,t,n){if(L(e),t=qr(t),L(n),Dn)try{return ar(e,t,n)}catch{}if("get"in n||"set"in n)throw new An("Accessors not supported");return"value"in n&&(e[t]=n.value),e};var Bn=g,Ln=J,Un=de,_e=Bn?function(r,e,t){return Ln.f(r,e,Un(1,t))}:function(r,e,t){return r[e]=t,r},De={exports:{}},dr=g,Gn=S,Me=Function.prototype,xn=dr&&Object.getOwnPropertyDescriptor,Rr=Gn(Me,"name"),Kn=Rr&&function(){}.name==="something",Vn=Rr&&(!dr||dr&&xn(Me,"name").configurable),kn={EXISTS:Rr,PROPER:Kn,CONFIGURABLE:Vn},Wn=p,zn=d,$r=mr,Yn=Wn(Function.toString);zn($r.inspectSource)||($r.inspectSource=function(r){return Yn(r)});var Ae=$r.inspectSource,qn=f,Jn=d,Jr=qn.WeakMap,Hn=Jn(Jr)&&/native code/.test(String(Jr)),Xn=Pe,Zn=Ce,Hr=Xn("keys"),Qn=function(r){return Hr[r]||(Hr[r]=Zn(r))},Fe={},ra=Hn,Be=f,ea=_,ta=_e,ur=S,cr=mr,na=Qn,aa=Fe,Xr="Object already initialized",br=Be.TypeError,oa=Be.WeakMap,z,N,Y,ia=function(r){return Y(r)?N(r):z(r,{})},va=function(r){return function(e){var t;if(!ea(e)||(t=N(e)).type!==r)throw new br("Incompatible receiver, "+r+" required");return t}};if(ra||cr.state){var b=cr.state||(cr.state=new oa);b.get=b.get,b.has=b.has,b.set=b.set,z=function(r,e){if(b.has(r))throw new br(Xr);return e.facade=r,b.set(r,e),e},N=function(r){return b.get(r)||{}},Y=function(r){return b.has(r)}}else{var I=na("state");aa[I]=!0,z=function(r,e){if(ur(r,I))throw new br(Xr);return e.facade=r,ta(r,I,e),e},N=function(r){return ur(r,I)?r[I]:{}},Y=function(r){return ur(r,I)}}var ua={set:z,get:N,has:Y,enforce:ia,getterFor:va},Pr=p,ca=h,la=d,U=S,pr=g,fa=kn.CONFIGURABLE,sa=Ae,Le=ua,ya=Le.enforce,da=Le.get,Zr=String,K=Object.defineProperty,$a=Pr("".slice),ba=Pr("".replace),pa=Pr([].join),ha=pr&&!ca(function(){return K(function(){},"length",{value:8}).length!==8}),ga=String(String).split("String"),Oa=De.exports=function(r,e,t){$a(Zr(e),0,7)==="Symbol("&&(e="["+ba(Zr(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),t&&t.getter&&(e="get "+e),t&&t.setter&&(e="set "+e),(!U(r,"name")||fa&&r.name!==e)&&(pr?K(r,"name",{value:e,configurable:!0}):r.name=e),ha&&t&&U(t,"arity")&&r.length!==t.arity&&K(r,"length",{value:t.arity});try{t&&U(t,"constructor")&&t.constructor?pr&&K(r,"prototype",{writable:!1}):r.prototype&&(r.prototype=void 0)}catch{}var n=ya(r);return U(n,"source")||(n.source=pa(ga,typeof e=="string"?e:"")),r};Function.prototype.toString=Oa(function(){return la(this)&&da(this).source||sa(this)},"toString");var Sa=De.exports,Ea=d,Ta=J,wa=Sa,Ia=Ir,ma=function(r,e,t,n){n||(n={});var a=n.enumerable,o=n.name!==void 0?n.name:e;if(Ea(t)&&wa(t,o,n),n.global)a?r[e]=t:Ia(e,t);else{try{n.unsafe?r[e]&&(a=!0):delete r[e]}catch{}a?r[e]=t:Ta.f(r,e,{value:t,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return r},Ue={},Ra=Math.ceil,Pa=Math.floor,Ca=Math.trunc||function(e){var t=+e;return(t>0?Pa:Ra)(t)},ja=Ca,Ge=function(r){var e=+r;return e!==e||e===0?0:ja(e)},Na=Ge,_a=Math.max,Da=Math.min,Ma=function(r,e){var t=Na(r);return t<0?_a(t+e,0):Da(t,e)},Aa=Ge,Fa=Math.min,Ba=function(r){var e=Aa(r);return e>0?Fa(e,9007199254740991):0},La=Ba,xe=function(r){return La(r.length)},Ua=Er,Ga=Ma,xa=xe,Qr=function(r){return function(e,t,n){var a=Ua(e),o=xa(a);if(o===0)return!r&&-1;var i=Ga(n,o),v;if(r&&t!==t){for(;o>i;)if(v=a[i++],v!==v)return!0}else for(;o>i;i++)if((r||i in a)&&a[i]===t)return r||i||0;return!r&&-1}},Ka={includes:Qr(!0),indexOf:Qr(!1)},Va=p,lr=S,ka=Er,Wa=Ka.indexOf,za=Fe,re=Va([].push),Ya=function(r,e){var t=ka(r),n=0,a=[],o;for(o in t)!lr(za,o)&&lr(t,o)&&re(a,o);for(;e.length>n;)lr(t,o=e[n++])&&(~Wa(a,o)||re(a,o));return a},qa=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Ja=Ya,Ha=qa,Xa=Ha.concat("length","prototype");Ue.f=Object.getOwnPropertyNames||function(e){return Ja(e,Xa)};var Ke={};Ke.f=Object.getOwnPropertySymbols;var Za=ge,Qa=p,ro=Ue,eo=Ke,to=M,no=Qa([].concat),ao=Za("Reflect","ownKeys")||function(e){var t=ro.f(to(e)),n=eo.f;return n?no(t,n(e)):t},ee=S,oo=ao,io=gr,vo=J,uo=function(r,e,t){for(var n=oo(e),a=vo.f,o=io.f,i=0;i<n.length;i++){var v=n[i];!ee(r,v)&&!(t&&ee(t,v))&&a(r,v,o(e,v))}},co=h,lo=d,fo=/#|\.prototype\./,A=function(r,e){var t=yo[so(r)];return t===bo?!0:t===$o?!1:lo(e)?co(e):!!e},so=A.normalize=function(r){return String(r).replace(fo,".").toLowerCase()},yo=A.data={},$o=A.NATIVE="N",bo=A.POLYFILL="P",Ve=A,G=f,po=gr.f,ho=_e,go=ma,Oo=Ir,So=uo,Eo=Ve,To=function(r,e){var t=r.target,n=r.global,a=r.stat,o,i,v,u,c,s;if(n?i=G:a?i=G[t]||Oo(t,{}):i=G[t]&&G[t].prototype,i)for(v in e){if(c=e[v],r.dontCallGetSet?(s=po(i,v),u=s&&s.value):u=i[v],o=Eo(n?v:t+(a?".":"#")+v,r.forced),!o&&u!==void 0){if(typeof c==typeof u)continue;So(c,u)}(r.sham||u&&u.sham)&&ho(c,"sham",!0),go(i,v,c,r)}},ke={},te=D,wo=TypeError,Io=function(r){var e,t;this.promise=new r(function(n,a){if(e!==void 0||t!==void 0)throw new wo("Bad Promise constructor");e=n,t=a}),this.resolve=te(e),this.reject=te(t)};ke.f=function(r){return new Io(r)};var mo=function(r){try{return{error:!1,value:r()}}catch(e){return{error:!0,value:e}}},Ro=q,Po=p,Co=function(r){if(Ro(r)==="Function")return Po(r)},ne=Co,jo=D,No=Or,_o=ne(ne.bind),Do=function(r,e){return jo(r),e===void 0?r:No?_o(r,e):function(){return r.apply(e,arguments)}},We={},Mo=E,Ao=We,Fo=Mo("iterator"),Bo=Array.prototype,Lo=function(r){return r!==void 0&&(Ao.Array===r||Bo[Fo]===r)},Uo=E,Go=Uo("toStringTag"),ze={};ze[Go]="z";var xo=String(ze)==="[object z]",Ko=xo,Vo=d,V=q,ko=E,Wo=ko("toStringTag"),zo=Object,Yo=V(function(){return arguments}())==="Arguments",qo=function(r,e){try{return r[e]}catch{}},Jo=Ko?V:function(r){var e,t,n;return r===void 0?"Undefined":r===null?"Null":typeof(t=qo(e=zo(r),Wo))=="string"?t:Yo?V(e):(n=V(e))==="Object"&&Vo(e.callee)?"Arguments":n},Ho=Jo,ae=wr,Xo=Sr,Zo=We,Qo=E,ri=Qo("iterator"),Ye=function(r){if(!Xo(r))return ae(r,ri)||ae(r,"@@iterator")||Zo[Ho(r)]},ei=O,ti=D,ni=M,ai=Tr,oi=Ye,ii=TypeError,vi=function(r,e){var t=arguments.length<2?oi(r):e;if(ti(t))return ni(ei(t,r));throw new ii(ai(r)+" is not iterable")},ui=O,oe=M,ci=wr,li=function(r,e,t){var n,a;oe(r);try{if(n=ci(r,"return"),!n){if(e==="throw")throw t;return t}n=ui(n,r)}catch(o){a=!0,n=o}if(e==="throw")throw t;if(a)throw n;return oe(n),t},fi=Do,si=O,yi=M,di=Tr,$i=Lo,bi=xe,ie=Oe,pi=vi,hi=Ye,ve=li,gi=TypeError,k=function(r,e){this.stopped=r,this.result=e},ue=k.prototype,Oi=function(r,e,t){var n=t&&t.that,a=!!(t&&t.AS_ENTRIES),o=!!(t&&t.IS_RECORD),i=!!(t&&t.IS_ITERATOR),v=!!(t&&t.INTERRUPTED),u=fi(e,n),c,s,T,R,l,w,Cr,jr=function(y){return c&&ve(c,"normal",y),new k(!0,y)},Nr=function(y){return a?(yi(y),v?u(y[0],y[1],jr):u(y[0],y[1])):v?u(y,jr):u(y)};if(o)c=r.iterator;else if(i)c=r;else{if(s=hi(r),!s)throw new gi(di(r)+" is not iterable");if($i(s)){for(T=0,R=bi(r);R>T;T++)if(l=Nr(r[T]),l&&ie(ue,l))return l;return new k(!1)}c=pi(r,s)}for(w=o?r.next:c.next;!(Cr=si(w,c)).done;){try{l=Nr(Cr.value)}catch(y){ve(c,"throw",y)}if(typeof l=="object"&&l&&ie(ue,l))return l}return new k(!1)},Si=f,qe=Si.Promise,Ei=E,Je=Ei("iterator"),He=!1;try{var Ti=0,ce={next:function(){return{done:!!Ti++}},return:function(){He=!0}};ce[Je]=function(){return this},Array.from(ce,function(){throw 2})}catch{}var wi=function(r,e){try{if(!e&&!He)return!1}catch{return!1}var t=!1;try{var n={};n[Je]=function(){return{next:function(){return{done:t=!0}}}},r(n)}catch{}return t},C=f,Ii=Se,mi=q,x=function(r){return Ii.slice(0,r.length)===r},Ri=function(){return x("Bun/")?"BUN":x("Cloudflare-Workers")?"CLOUDFLARE":x("Deno/")?"DENO":x("Node.js/")?"NODE":C.Bun&&typeof Bun.version=="string"?"BUN":C.Deno&&typeof Deno.version=="object"?"DENO":mi(C.process)==="process"?"NODE":C.window&&C.document?"BROWSER":"REST"}(),Pi=f,j=qe,Ci=d,ji=Ve,Ni=Ae,_i=E,le=Ri,fr=Te;j&&j.prototype;var Di=_i("species"),hr=!1,Xe=Ci(Pi.PromiseRejectionEvent),Mi=ji("Promise",function(){var r=Ni(j),e=r!==String(j);if(!e&&fr===66)return!0;if(!fr||fr<51||!/native code/.test(r)){var t=new j(function(o){o(1)}),n=function(o){o(function(){},function(){})},a=t.constructor={};if(a[Di]=n,hr=t.then(function(){})instanceof n,!hr)return!0}return!e&&(le==="BROWSER"||le==="DENO")&&!Xe}),Ai={CONSTRUCTOR:Mi,REJECTION_EVENT:Xe,SUBCLASSING:hr},Fi=qe,Bi=wi,Li=Ai.CONSTRUCTOR,Ui=Li||!Bi(function(r){Fi.all(r).then(void 0,function(){})}),Gi=To,xi=O,Ki=D,Vi=ke,ki=mo,Wi=Oi,zi=Ui;Gi({target:"Promise",stat:!0,forced:zi},{allSettled:function(e){var t=this,n=Vi.f(t),a=n.resolve,o=n.reject,i=ki(function(){var v=Ki(t.resolve),u=[],c=0,s=1;Wi(e,function(T){var R=c++,l=!1;s++,xi(v,t,T).then(function(w){l||(l=!0,u[R]={status:"fulfilled",value:w},--s||a(u))},function(w){l||(l=!0,u[R]={status:"rejected",reason:w},--s||a(u))})}),--s||a(u)});return i.error&&o(i.value),n.promise}});export{F as c,Yi as g};
2
2
  //# sourceMappingURL=vendor.core-js.js.map