userflow.js-self-hosted 0.1.1010254 → 0.1.1010263

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/FlowApp.js CHANGED
@@ -1,6 +1,6 @@
1
- import{R as o,r as d}from"./vendor.react.js";import{E as M,P as B,f as k,V as O,n as de,F as pe,T as x,o as L,p as fe,q as me,M as be,U as Q}from"./userflow.js";import"./vendor.core-js.js";import{l as Ee}from"./vendor.lodash.js";import{u as j}from"./vendor.react-i18next.js";import{B as X,F as ge}from"./FlowChrome.js";import{m as we,d as K,R as he,i as Te,g as ve,c as Se,u as ye,r as ke,e as z,h as De,S as Me}from"./use-selector-element-monitoring.js";import{g as Z,i as J}from"./flow-condition-types.js";import{u as N,i as Re}from"./client-context.js";import{z as Ne,d as Ie,r as Fe}from"./roots.js";import{a as ee,S as Ae}from"./flow-host.styl.js";import{f as Be}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Le,u as Ce}from"./stylesheets.js";import{T as Oe}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="e27e4278-d3de-4f78-99f6-4312e11ab6df",e._sentryDebugIdIdentifier="sentry-dbid-e27e4278-d3de-4f78-99f6-4312e11ab6df")}catch{}})();const xe=()=>{const{t:e}=j(),s=N(),{dispatch:t,restart:n}=F(),{session:l,step:p}=D(),a="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return o.createElement("div",{role:"dialog","aria-modal":I(p)?"true":void 0,"aria-label":"Guide menu"},o.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),o.createElement("button",{className:a,onClick:()=>s.endFlow(l,{endReason:M.USER_CLOSED})},e("menu.close")),l.version.restartEnabled&&o.createElement("button",{className:a,onClick:n},e("menu.restart")),o.createElement("button",{className:a,onClick:()=>t({kind:"showFlow"})},e("menu.back")))};var _=(e=>(e.BOTTOM="BOTTOM",e.TOP="TOP",e))(_||{}),te=(e=>(e.CHAINED_ROUNDED="CHAINED_ROUNDED",e.CHAINED_SQUARED="CHAINED_SQUARED",e.DEFAULT="DEFAULT",e.DOTTED="DOTTED",e.NARROW="NARROW",e.NUMBERED="NUMBERED",e))(te||{});const $=({progress:e,type:s,position:t,totalSteps:n})=>{const{t:l}=j(),p=d.useMemo(()=>parseFloat(e||"0"),[e]),a=d.useMemo(()=>({width:`${p*100}%`}),[p]),c=d.useMemo(()=>s===te.DEFAULT?B.TOP:t,[s,t]),u=c===B.BOTTOM?"userflowjs-bubble-progress--bottom":"",m=d.useMemo(()=>`userflowjs-bubble-progress--${Ee.kebabCase(s||"DEFAULT").toLowerCase()} ${u}`,[s,u]),i=n||0,r=d.useMemo(()=>Math.min(Math.floor(p*i),i),[p,i]);return o.createElement(o.Fragment,null,(s==="CHAINED_ROUNDED"||s==="CHAINED_SQUARED"||s==="DOTTED")&&o.createElement("div",{className:m},Array.from({length:3}).map((E,b)=>o.createElement("div",{key:b,className:`userflowjs-bubble-progress-step ${b<Math.floor(p*3)?"userflowjs-bubble-progress-step_completed":""}`}))),s==="NARROW"&&o.createElement("div",{className:m},o.createElement("div",{className:"linear-progress-bar"},o.createElement("div",{className:"userflowjs-bubble-progress--narrow-fill",style:a}))),s==="NUMBERED"&&o.createElement("div",{className:m},o.createElement("span",{className:"numbered-progress"},l("of",{replace:{range:i,selected:r}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&o.createElement("div",{className:`${m} ${c===B.BOTTOM?"userflowjs-bubble-progress--bottom":""}`},o.createElement("div",{className:"userflowjs-bubble-progress__fill",style:a})))},_e=({theme:e})=>{const s=N(),{session:t,step:n,muted:l,shouldLabelDialog:p}=D(),{version:a}=t,{dispatch:c}=F(),u=a.steps[0],m=u&&u.id===n.id,i=m&&n.progress==="1",r=d.useMemo(()=>n.content&&we(K(n.content),{buttons:n.buttons,questions:n.questions}),[n.content,n.buttons,n.questions]),E=a.steps.filter(v=>v.appearance!==k.HIDDEN),b=E.findIndex(v=>v.id===n.id),w=E.length,h=w>0?((b+1)/w).toString():"0";return o.createElement("div",{key:n.id,role:"alertdialog","aria-modal":I(n)?"true":void 0,"aria-label":p?"Guide":void 0},!i&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&o.createElement($,{progress:h,type:e.progressBarType,position:n.appearance===k.MODAL?void 0:_.TOP,totalSteps:w}),o.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content","data-progress-position":e.progressBarPosition,"data-progress-type":e.progressBarType},o.createElement(he,{doc:r,lookupAttribute:Z(t.data),buttons:n.buttons,questions:n.questions})),o.createElement(X,{draftMode:t.draftMode,muted:l,toggleMuted:e.voiceType!==O.NONE?()=>c({kind:"toggleMuted"}):void 0,close:a.closeDisabled?void 0:()=>e.flowXButtonBehavior===de.DISMISS||m?s.endFlow(t,{endReason:M.USER_CLOSED}):c({kind:"showMenu"})}),!i&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&o.createElement($,{progress:h,type:e.progressBarType,position:_.BOTTOM,totalSteps:w}))};function Pe(e,s){if(!e)return"";typeof e=="string"&&(e=K(e));const t=[],n=/[.!?;,]$/;function l(){const c=(t[t.length-1]||"").trim();c&&!c.match(n)&&t.push(".")}function p(c){if(Te(c)){if(c.text&&!c.silent){const u=c.text.split(`
1
+ import{R as n,r as d}from"./vendor.react.js";import{E as B,P as N,f as k,V as A,n as ue,F as de,T as x,o as C,p as pe,q as fe,M as me,U as X}from"./userflow.js";import{P as be,a as W}from"./index.js";import{l as Ee}from"./vendor.lodash.js";import"./vendor.core-js.js";import{u as _}from"./vendor.react-i18next.js";import{B as K,F as ge}from"./FlowChrome.js";import{m as we,d as Q,R as he,i as ve,g as Te,c as Se,u as ye,r as ke,e as z,h as Me,S as Be}from"./use-selector-element-monitoring.js";import{g as Z,i as J}from"./flow-condition-types.js";import{u as I,i as Fe}from"./client-context.js";import{z as Ie,d as De,r as Re}from"./roots.js";import{a as ee,S as Le}from"./flow-host.styl.js";import{f as Ne}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{D as Ce,u as Pe}from"./stylesheets.js";import{T as Ae}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./use-window-resize.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./logomark.js";import"./vendor.obj-str.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="ac256625-a85b-497c-9370-315a0b0cb5f1",e._sentryDebugIdIdentifier="sentry-dbid-ac256625-a85b-497c-9370-315a0b0cb5f1")}catch{}})();const xe=()=>{const{t:e}=_(),s=I(),{dispatch:t,restart:o}=R(),{session:l,step:p}=M(),a="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return n.createElement("div",{role:"dialog","aria-modal":D(p)?"true":void 0,"aria-label":"Guide menu"},n.createElement("div",{className:"userflowjs-bubble-menu__title"},e("menu.title")),n.createElement("button",{className:a,onClick:()=>s.endFlow(l,{endReason:B.USER_CLOSED})},e("menu.close")),l.version.restartEnabled&&n.createElement("button",{className:a,onClick:o},e("menu.restart")),n.createElement("button",{className:a,onClick:()=>t({kind:"showFlow"})},e("menu.back")))},$=({progress:e,type:s,position:t,totalSteps:o})=>{const{t:l}=_(),p=d.useMemo(()=>parseFloat(e||"0"),[e]),a=d.useMemo(()=>({width:`${p*100}%`}),[p]),c=d.useMemo(()=>s===be.DEFAULT?N.TOP:t,[s,t]),u=c===N.BOTTOM?"userflowjs-bubble-progress--bottom":"",m=d.useMemo(()=>`userflowjs-bubble-progress--${Ee.kebabCase(s||"DEFAULT").toLowerCase()} ${u}`,[s,u]),i=o||0,r=d.useMemo(()=>Math.min(Math.floor(p*i),i),[p,i]);return n.createElement(n.Fragment,null,(s==="CHAINED_ROUNDED"||s==="CHAINED_SQUARED"||s==="DOTTED")&&n.createElement("div",{className:m},Array.from({length:3}).map((E,b)=>n.createElement("div",{key:b,className:`userflowjs-bubble-progress-step ${b<Math.floor(p*3)?"userflowjs-bubble-progress-step_completed":""}`}))),s==="NARROW"&&n.createElement("div",{className:m},n.createElement("div",{className:"linear-progress-bar"},n.createElement("div",{className:"userflowjs-bubble-progress--narrow-fill",style:a}))),s==="NUMBERED"&&n.createElement("div",{className:m},n.createElement("span",{className:"numbered-progress"},l("of",{replace:{range:i,selected:r}}))),!["CHAINED_ROUNDED","CHAINED_SQUARED","DOTTED","NARROW","NUMBERED"].includes(s)&&n.createElement("div",{className:`${m} ${c===N.BOTTOM?"userflowjs-bubble-progress--bottom":""}`},n.createElement("div",{className:"userflowjs-bubble-progress__fill",style:a})))},Oe=({theme:e})=>{const s=I(),{session:t,step:o,muted:l,shouldLabelDialog:p}=M(),{version:a}=t,{dispatch:c}=R(),u=a.steps[0],m=u&&u.id===o.id,i=m&&o.progress==="1",r=d.useMemo(()=>o.content&&we(Q(o.content),{buttons:o.buttons,questions:o.questions}),[o.content,o.buttons,o.questions]),E=a.steps.filter(T=>T.appearance!==k.HIDDEN),b=E.findIndex(T=>T.id===o.id),w=E.length,h=w>0?((b+1)/w).toString():"0";return n.createElement("div",{key:o.id,role:"alertdialog","aria-modal":D(o)?"true":void 0,"aria-label":p?"Guide":void 0},!i&&e.progressBarPosition==="TOP"&&e.progressBarEnabled&&n.createElement($,{progress:h,type:e.progressBarType,position:o.appearance===k.MODAL?void 0:W.TOP,totalSteps:w}),n.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content","data-progress-position":e.progressBarPosition,"data-progress-type":e.progressBarType},n.createElement(he,{doc:r,lookupAttribute:Z(t.data),buttons:o.buttons,questions:o.questions})),n.createElement(K,{draftMode:t.draftMode,muted:l,toggleMuted:e.voiceType!==A.NONE?()=>c({kind:"toggleMuted"}):void 0,close:a.closeDisabled?void 0:()=>e.flowXButtonBehavior===ue.DISMISS||m?s.endFlow(t,{endReason:B.USER_CLOSED}):c({kind:"showMenu"})}),!i&&e.progressBarPosition==="BOTTOM"&&e.progressBarEnabled&&n.createElement($,{progress:h,type:e.progressBarType,position:W.BOTTOM,totalSteps:w}))};function _e(e,s){if(!e)return"";typeof e=="string"&&(e=Q(e));const t=[],o=/[.!?;,]$/;function l(){const c=(t[t.length-1]||"").trim();c&&!c.match(o)&&t.push(".")}function p(c){if(ve(c)){if(c.text&&!c.silent){const u=c.text.split(`
2
2
  `);u.forEach((m,i)=>{t.push(m),i<u.length-1&&(l(),t.push(`
3
- `))})}return}switch(c.type){case"attribute":{const u=ve(c,s);u&&t.push(u);break}default:a(c.children),["link"].includes(c.type)||(l(),t.push(`
3
+ `))})}return}switch(c.type){case"attribute":{const u=Te(c,s);u&&t.push(u);break}default:a(c.children),["link"].includes(c.type)||(l(),t.push(`
4
4
 
5
- `));break}}function a(c){c.forEach(u=>p(u))}return a(e.children),t.join("").trim().replace(new RegExp(" ","g")," ").replace(new RegExp("\b","g"),"")}const je=({bubbleFrame:e,theme:s})=>{const t=N(),{dispatch:n}=F(),{muted:l,session:p,step:a}=D(),c=t.getAudio();d.useEffect(()=>{const r=()=>{n({kind:"speechPlaying"})},E=()=>{n({kind:"speechStopped"})};return c.addEventListener("playing",r),c.addEventListener("ended",E),c.addEventListener("pause",E),()=>{c.removeEventListener("playing",r),c.removeEventListener("ended",E),c.removeEventListener("pause",E),c.pause(),c.src="",n({kind:"speechStopped"})}},[n,c]),d.useEffect(()=>{if(t.audioReady)return;const r=e&&qe(e)?e.contentWindow:null,E=()=>{window.removeEventListener("mousedown",b),r&&r.removeEventListener("mousedown",b)},b=()=>{E(),t.playAudio(null)};return window.addEventListener("mousedown",b),r&&r.addEventListener("mousedown",b),E},[e,t]);const u=d.useRef(p),m=d.useRef(s),i=d.useRef(a);return d.useEffect(()=>{u.current=p,m.current=s,i.current=a},[p,s,a]),d.useEffect(()=>{if(!t.audioReady||l){t.pauseAudio();return}let r=!1;return(async()=>{if(await new Promise(w=>setTimeout(w,1)),r)return;const b=await Ue(t,u.current,m.current,i.current);r||b&&t.playAudio(b)})(),()=>{r=!0}},[l,t,a.id,s.voiceType,s.syntheticVoice]),null};async function Ue(e,s,t,n){if(t.voiceType===O.SYNTHETIC&&typeof t.syntheticVoice=="string"&&n.content){e.ensureIdentified();const l=Z(s.data),p=Pe(n.content,l);return e.getStepSpeech(t.syntheticVoice,p)}else if(t.voiceType===O.MANUAL&&n.speechAsset)return n.speechAsset.assetUrl;return null}function qe(e){return e.tagName==="IFRAME"}const Ve="userflowjs-out-of-viewport-pointer--visible",He="userflowjs-out-of-viewport-pointer--visible-up",We="userflowjs-out-of-viewport-pointer--visible-down",ze=o.forwardRef((e,s)=>{const t=ee();return o.createElement("div",{ref:s,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:t+2}},o.createElement(Le,{icon:Be}))});function $e({subjectPosition:e,pointerRef:s,viewportClipRect:t}){const n=s.current;if(!n)return null;const l=n.getBoundingClientRect(),p=Ne(Ie());let a=e.direction,c,u;return a==null?null:(a==="down"&&t.bottom<l.height/2?a="up":a==="up"&&t.top>p&&(a="down"),c=e.left+e.width/2-l.width/2,u=a==="down"?t.bottom-l.height:t.top,{direction:a,left:c,top:u})}function Y(e,s){const t=e.current;t&&(t.classList.toggle(Ve,s!=null),s&&(t.style.left=s.left+"px",t.style.top=s.top+"px",t.classList.toggle(He,s.direction==="up"),t.classList.toggle(We,s.direction==="down")))}const Ye="userflowjs-fixed-widget--visible",Ge=({theme:e})=>{const{step:s}=D();return o.createElement(o.Fragment,null,s.beacons.map(t=>o.createElement(Qe,{key:t.id,beacon:t,theme:e})))},Qe=({beacon:e,theme:s})=>{const{session:t}=D(),n=ee(),l=d.useRef(null),p=d.useRef(null),a=Se(e.hiddenCondition),c=d.useMemo(()=>J(e.selector,t.data),[e.selector,t.data]),u=d.useCallback(({targetRect:i,clipEl:r,viewportClipRect:E})=>{const b=Xe({beacon:e,beaconRef:l,clipEl:r,viewportClipRect:E,targetRect:i,theme:s}),w=b&&$e({subjectPosition:b.pointerSubjectPosition,pointerRef:p,viewportClipRect:E});ke(()=>{G(l,b),Y(p,w)})},[e]),m=d.useCallback(()=>{G(l,null),Y(p,null)},[]);return ye({selector:a?null:c,targetMoved:u,targetLost:m}),o.createElement(o.Fragment,null,o.createElement("div",{ref:l,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},o.createElement("div",{className:"userflowjs-beacon__ring"}),o.createElement("div",{className:"userflowjs-beacon__ring"})),o.createElement(ze,{ref:p}))};function Xe({beacon:e,beaconRef:s,clipEl:t,viewportClipRect:n,targetRect:l,theme:p}){if(!s.current||l.width===0||l.height===0)return null;const c=p.beaconSize,u=p.beaconSize,m=Fe(t);let i=0,r=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=l.left;break;case"top":case"center":case"bottom":i=l.left+l.width/2;break;default:i=l.left+l.width;break}switch(e.placement){case"left":case"center":case"right":r=l.top+l.height/2;break;case"bottom-left":case"bottom":case"bottom-right":r=l.top+l.height;break;default:r=l.top;break}i-=c/2,r-=u/2,i+=e.offsetX,r+=e.offsetY,i=Math.max(i,m.left-(t===document.documentElement?0:t.scrollLeft)),r=Math.max(r,m.top-(t===document.documentElement?0:t.scrollTop));const E=i+c,b=r+u,w=Math.min(32,.5*u);let h;b<n.top+w?h="up":r>n.bottom-w?h="down":h=null;const v=h==null;return{top:r,right:E,bottom:b,left:i,width:c,height:u,pointerSubjectPosition:{direction:h,left:i,width:c},visible:v}}function G(e,s){const t=e.current;t&&(t.classList.toggle(Ye,s!=null),s&&(t.style.transform=`translate3d(${s.left}px, ${s.top}px, 0)`,t.style.visibility=s.visible?"visible":"hidden"))}const Ke=()=>{const{t:e}=j(),s=N(),{restart:t}=F(),{session:n,step:l}=D(),p=l.theme||n.version.theme,a=l.selector,c=!a||a.type===pe.AUTO&&!a.autoData,u=()=>s.endFlow(n,{endReason:M.USER_CLOSED});return o.createElement(o.Fragment,null,o.createElement(X,{draftMode:n.draftMode,close:u}),n.draftMode&&c?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name),".")):n.draftMode&&p.tooltipMissingBehavior===x.END?o.createElement("div",{className:"userflowjs-bubble-content"},o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("p",null,o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found within"," ",p.tooltipMissingToleranceSeconds," ",parseFloat(p.tooltipMissingToleranceSeconds)===1?"second":"seconds","."),o.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),o.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,"Read more in our"," ",o.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):o.createElement(o.Fragment,null,o.createElement("div",{className:"userflowjs-bubble-content"},n.draftMode&&o.createElement("div",{className:"userflowjs-bubble-alert p-like"},o.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",o.createElement("b",null,"Step ",l.idx+1)," of"," ",o.createElement("b",null,n.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),o.createElement("p",null,o.createElement("b",null,e("tooltipTargetMissing.line1"))),o.createElement("p",null,e("tooltipTargetMissing.line2"))),o.createElement("div",{className:"userflowjs-bubble-buttons"},o.createElement(z,{appearance:"primary",onClick:t,text:e("menu.restart")}),o.createElement(z,{appearance:"default",onClick:u,text:e("menu.close")}))))},C="flowsMuted",Nt=({session:e,checklistSession:s,resourceCenterEmbedsChecklist:t})=>{const n=N(),[l,p]=d.useState(!1),[a,c]=d.useState(null),[u,m]=d.useReducer(et,void 0,()=>{const f=e,g=P(f);return{...Je,session:f,step:g,muted:!!L.getItem(C),autoFocusRequested:oe(g)}}),{session:i,step:r,speechPlaying:E,contentType:b}=u,{version:w}=i,h=I(r);let v=0;r.questions.some(f=>f.type===fe.NPS)&&(v=420);const T=Ce(r.theme||w.theme),S=d.useMemo(()=>{let f=T.bubbleY;const g=s?.version.theme;return!t&&s&&g&&s.version.checklist?.launcherEnabled&&r.appearance===k.BUBBLE&&g.checklistLauncherPlacement===T.bubblePlacement&&(T.avatarType===me.NONE||g.checklistLauncherX<T.bubbleX+T.avatarSize)&&(f=Math.max(T.bubbleY,g.checklistLauncherY+g.checklistLauncherHeight+T.bubbleY)),{...T,bubbleWidth:Math.max(T.bubbleWidth,v),bubbleY:f}},[t,s,r.appearance,T,v]);d.useEffect(()=>{i!==e&&m({kind:"updateSession",session:e});const f=g=>{g.session.id===i.id&&m({kind:"goToStep",stepId:g.step.id})};return n.on("gotostep",f),()=>{n.off("gotostep",f)}},[n,i,e]);const le=d.useMemo(()=>({dispatch:m,restart:()=>{n.goToStep(i,ne(i)),m({kind:"showFlow"})}}),[n,m,i]),ae=d.useMemo(()=>r.selector&&J(r.selector,i.data),[r.selector,i.data]),ie=d.useCallback(()=>{De(n,i,r.actions)},[n,i,r.actions]);d.useEffect(()=>{u.muted?L.setItem(C,"true"):L.removeItem(C)},[u.muted]);const U=i.locale?i.locale.standardLocaleId:S.languageId;d.useEffect(()=>{Re.changeLanguage(U)},[U]);const[q,ce]=d.useState(!1),ue=d.useCallback(f=>{ce(f),f&&n.send({kind:"ReportTooltipTargetMissing",sessionId:i.id,stepId:r.id}),f&&S.tooltipMissingBehavior===x.END&&!i.draftMode&&n.endFlow(i,{endReason:M.TOOLTIP_TARGET_MISSING})},[n,i,r.id,S.tooltipMissingBehavior]);return d.useEffect(()=>{if(!l||!u.autoFocusRequested)return;!n.originalActiveElement&&n.originalActiveElement!==a?.ownerDocument.defaultView?.frameElement&&(n.originalActiveElement=document.activeElement);let f=a?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(f&&f.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const g=a?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");g&&(f=g)}f&&typeof f.focus=="function"&&f.focus({preventScroll:!0}),m({kind:"autoFocused"})},[n,a,l,u.autoFocusRequested]),d.useEffect(()=>{const f=a?.ownerDocument.defaultView;if(!f)return;const g=()=>{m({kind:"focusOut"}),delete n.originalActiveElement},y=()=>{m({kind:"focusIn"})};return window.addEventListener("focusin",g),f.addEventListener("focusin",y),()=>{window.removeEventListener("focusin",g),f.removeEventListener("focusin",y)}},[a,n]),d.useEffect(()=>{if(!h||!a)return;const f=a.ownerDocument.defaultView,g=f?f.document:document,y=R=>{if(R.key==="Escape"&&!w.closeDisabled)n.endFlow(i,{endReason:M.USER_CLOSED});else if(R.key==="Tab"){const A=a.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),V=A[0],H=A[A.length-1],W=g.activeElement;R.shiftKey?W===V&&(R.preventDefault(),H.focus()):W===H&&(R.preventDefault(),V.focus())}};return window.addEventListener("keydown",y),f?.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y),f?.removeEventListener("keydown",y)}},[h,n,i,a,w.closeDisabled]),d.useEffect(()=>{if(u.scrollToTopRequested){if(a?.ownerDocument.defaultView?.frameElement){const f=a?.ownerDocument.body;f&&(f.scrollTop=0)}m({kind:"scrolledToTop"})}},[u.scrollToTopRequested,a]),o.createElement(se.Provider,{value:le},o.createElement(re.Provider,{value:u},o.createElement(Me.Provider,{value:i},o.createElement(Ae,null,o.createElement(ge,{company:i.flow.company,theme:S,position:"fixed",stepKey:r.crossVersionId,stepAppearance:r.appearance,width:r.width,backgroundImageUrl:b==="flow"&&!q&&r.backgroundAsset?r.backgroundAsset.assetUrl:null,tooltipSelector:ae,tooltipPlacement:r.tooltipPlacement,backdrop:r.backdrop,tooltipTargetBlocked:r.tooltipTargetBlocked,backdropPadding:r.backdropPadding,onTooltipTargetClick:ie,onTooltipTargetMissingChange:ue,onModalBackdropClick:r.appearance===k.MODAL&&S.modalBackdropOnclick===be.DISMISS&&!w.closeDisabled?()=>n.endFlow(i,{endReason:M.USER_CLOSED}):void 0,speaking:E,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:p,bubbleFrameRootRef:c,rootChildren:f=>o.createElement(Ze,{...f,theme:S})},b==="menu"?o.createElement(xe,null):q&&S.tooltipMissingBehavior!==x.BUBBLE?o.createElement(Ke,null):o.createElement(_e,{theme:S}))))))},Ze=({visible:e,bubbleFrame:s,theme:t})=>{const n=D(),{step:l}=n,p=n.session.currentStep&&n.session.currentStep.id,[a,c]=d.useState(!1),u=d.useRef(p);return d.useEffect(()=>{e?c(!0):u.current!==p&&c(!1),u.current=p},[p,e]),o.createElement(o.Fragment,null,(e||a)&&n.contentType==="flow"&&o.createElement(o.Fragment,null,o.createElement(je,{bubbleFrame:s,theme:t}),o.createElement(Ge,{theme:t})),l.triggers.map(m=>o.createElement(Oe,{key:m.id,trigger:m})))},Je={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function et(e,s){switch(s.kind){case"updateSession":{let t;return s.session.id===e.session.id?t=s.session.version.steps.find(({crossVersionId:n})=>n===e.step.crossVersionId)||P(s.session):t=P(s.session),{...e,session:s.session,step:t}}case"goToStep":{const t=e.session.version.steps.find(n=>n.id===s.stepId);return t?{...e,step:t,contentType:"flow",autoFocusRequested:e.hasFocus||oe(t),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function P(e){const{currentStep:s}=e,{steps:t}=e.version;if(s){const n=t.find(({crossVersionId:l})=>l===s.crossVersionId);if(!n)throw new Q("Session points to an unknown step: "+s.crossVersionId);return n}else return ne(e)}function ne(e){const s=e.version.steps[0];if(!s)throw new Q("Session has no current step and its version has no start step");return s}function oe(e){return I(e)}function I(e){return e.appearance===k.MODAL||e.appearance===k.BUBBLE&&e.backdrop||e.appearance===k.TOOLTIP&&e.tooltipTargetBlocked}const se=d.createContext(null),re=d.createContext(null);function F(){return d.useContext(se)}function D(){return d.useContext(re)}export{Nt as FlowApp,re as FlowStateContext,Nt as default,Je as initialFlowState,I as isStepModal,F as useFlowDispatch,D as useFlowState};
5
+ `));break}}function a(c){c.forEach(u=>p(u))}return a(e.children),t.join("").trim().replace(new RegExp(" ","g")," ").replace(new RegExp("\b","g"),"")}const je=({bubbleFrame:e,theme:s})=>{const t=I(),{dispatch:o}=R(),{muted:l,session:p,step:a}=M(),c=t.getAudio();d.useEffect(()=>{const r=()=>{o({kind:"speechPlaying"})},E=()=>{o({kind:"speechStopped"})};return c.addEventListener("playing",r),c.addEventListener("ended",E),c.addEventListener("pause",E),()=>{c.removeEventListener("playing",r),c.removeEventListener("ended",E),c.removeEventListener("pause",E),c.pause(),c.src="",o({kind:"speechStopped"})}},[o,c]),d.useEffect(()=>{if(t.audioReady)return;const r=e&&qe(e)?e.contentWindow:null,E=()=>{window.removeEventListener("mousedown",b),r&&r.removeEventListener("mousedown",b)},b=()=>{E(),t.playAudio(null)};return window.addEventListener("mousedown",b),r&&r.addEventListener("mousedown",b),E},[e,t]);const u=d.useRef(p),m=d.useRef(s),i=d.useRef(a);return d.useEffect(()=>{u.current=p,m.current=s,i.current=a},[p,s,a]),d.useEffect(()=>{if(!t.audioReady||l){t.pauseAudio();return}let r=!1;return(async()=>{if(await new Promise(w=>setTimeout(w,1)),r)return;const b=await Ue(t,u.current,m.current,i.current);r||b&&t.playAudio(b)})(),()=>{r=!0}},[l,t,a.id,s.voiceType,s.syntheticVoice]),null};async function Ue(e,s,t,o){if(t.voiceType===A.SYNTHETIC&&typeof t.syntheticVoice=="string"&&o.content){e.ensureIdentified();const l=Z(s.data),p=_e(o.content,l);return e.getStepSpeech(t.syntheticVoice,p)}else if(t.voiceType===A.MANUAL&&o.speechAsset)return o.speechAsset.assetUrl;return null}function qe(e){return e.tagName==="IFRAME"}const Ve="userflowjs-out-of-viewport-pointer--visible",He="userflowjs-out-of-viewport-pointer--visible-up",We="userflowjs-out-of-viewport-pointer--visible-down",ze=n.forwardRef((e,s)=>{const t=ee();return n.createElement("div",{ref:s,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:t+2}},n.createElement(Ce,{icon:Ne}))});function $e({subjectPosition:e,pointerRef:s,viewportClipRect:t}){const o=s.current;if(!o)return null;const l=o.getBoundingClientRect(),p=Ie(De());let a=e.direction,c,u;return a==null?null:(a==="down"&&t.bottom<l.height/2?a="up":a==="up"&&t.top>p&&(a="down"),c=e.left+e.width/2-l.width/2,u=a==="down"?t.bottom-l.height:t.top,{direction:a,left:c,top:u})}function Y(e,s){const t=e.current;t&&(t.classList.toggle(Ve,s!=null),s&&(t.style.left=s.left+"px",t.style.top=s.top+"px",t.classList.toggle(He,s.direction==="up"),t.classList.toggle(We,s.direction==="down")))}const Ye="userflowjs-fixed-widget--visible",Ge=({theme:e})=>{const{step:s}=M();return n.createElement(n.Fragment,null,s.beacons.map(t=>n.createElement(Xe,{key:t.id,beacon:t,theme:e})))},Xe=({beacon:e,theme:s})=>{const{session:t}=M(),o=ee(),l=d.useRef(null),p=d.useRef(null),a=Se(e.hiddenCondition),c=d.useMemo(()=>J(e.selector,t.data),[e.selector,t.data]),u=d.useCallback(({targetRect:i,clipEl:r,viewportClipRect:E})=>{const b=Ke({beacon:e,beaconRef:l,clipEl:r,viewportClipRect:E,targetRect:i,theme:s}),w=b&&$e({subjectPosition:b.pointerSubjectPosition,pointerRef:p,viewportClipRect:E});ke(()=>{G(l,b),Y(p,w)})},[e]),m=d.useCallback(()=>{G(l,null),Y(p,null)},[]);return ye({selector:a?null:c,targetMoved:u,targetLost:m}),n.createElement(n.Fragment,null,n.createElement("div",{ref:l,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:o+2}},n.createElement("div",{className:"userflowjs-beacon__ring"}),n.createElement("div",{className:"userflowjs-beacon__ring"})),n.createElement(ze,{ref:p}))};function Ke({beacon:e,beaconRef:s,clipEl:t,viewportClipRect:o,targetRect:l,theme:p}){if(!s.current||l.width===0||l.height===0)return null;const c=p.beaconSize,u=p.beaconSize,m=Re(t);let i=0,r=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=l.left;break;case"top":case"center":case"bottom":i=l.left+l.width/2;break;default:i=l.left+l.width;break}switch(e.placement){case"left":case"center":case"right":r=l.top+l.height/2;break;case"bottom-left":case"bottom":case"bottom-right":r=l.top+l.height;break;default:r=l.top;break}i-=c/2,r-=u/2,i+=e.offsetX,r+=e.offsetY,i=Math.max(i,m.left-(t===document.documentElement?0:t.scrollLeft)),r=Math.max(r,m.top-(t===document.documentElement?0:t.scrollTop));const E=i+c,b=r+u,w=Math.min(32,.5*u);let h;b<o.top+w?h="up":r>o.bottom-w?h="down":h=null;const T=h==null;return{top:r,right:E,bottom:b,left:i,width:c,height:u,pointerSubjectPosition:{direction:h,left:i,width:c},visible:T}}function G(e,s){const t=e.current;t&&(t.classList.toggle(Ye,s!=null),s&&(t.style.transform=`translate3d(${s.left}px, ${s.top}px, 0)`,t.style.visibility=s.visible?"visible":"hidden"))}const Qe=()=>{const{t:e}=_(),s=I(),{restart:t}=R(),{session:o,step:l}=M(),p=l.theme||o.version.theme,a=l.selector,c=!a||a.type===de.AUTO&&!a.autoData,u=()=>s.endFlow(o,{endReason:B.USER_CLOSED});return n.createElement(n.Fragment,null,n.createElement(K,{draftMode:o.draftMode,close:u}),o.draftMode&&c?n.createElement("div",{className:"userflowjs-bubble-content"},n.createElement("div",{className:"userflowjs-bubble-alert p-like"},n.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"No tooltip target selected yet. Please go back to the Builder and select a tooltip target in ",n.createElement("b",null,"Step ",l.idx+1)," of"," ",n.createElement("b",null,o.flow.name),".")):o.draftMode&&p.tooltipMissingBehavior===x.END?n.createElement("div",{className:"userflowjs-bubble-content"},n.createElement("div",{className:"userflowjs-bubble-alert p-like"},n.createElement("p",null,n.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",n.createElement("b",null,"Step ",l.idx+1)," of"," ",n.createElement("b",null,o.flow.name)," was not found within"," ",p.tooltipMissingToleranceSeconds," ",parseFloat(p.tooltipMissingToleranceSeconds)===1?"second":"seconds","."),n.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),n.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),n.createElement("p",null,"Read more in our"," ",n.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):n.createElement(n.Fragment,null,n.createElement("div",{className:"userflowjs-bubble-content"},o.draftMode&&n.createElement("div",{className:"userflowjs-bubble-alert p-like"},n.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",n.createElement("b",null,"Step ",l.idx+1)," of"," ",n.createElement("b",null,o.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),n.createElement("p",null,n.createElement("b",null,e("tooltipTargetMissing.line1"))),n.createElement("p",null,e("tooltipTargetMissing.line2"))),n.createElement("div",{className:"userflowjs-bubble-buttons"},n.createElement(z,{appearance:"primary",onClick:t,text:e("menu.restart")}),n.createElement(z,{appearance:"default",onClick:u,text:e("menu.close")}))))},P="flowsMuted",Dt=({session:e,checklistSession:s,resourceCenterEmbedsChecklist:t})=>{const o=I(),[l,p]=d.useState(!1),[a,c]=d.useState(null),[u,m]=d.useReducer(et,void 0,()=>{const f=e,g=O(f);return{...Je,session:f,step:g,muted:!!C.getItem(P),autoFocusRequested:oe(g)}}),{session:i,step:r,speechPlaying:E,contentType:b}=u,{version:w}=i,h=D(r);let T=0;r.questions.some(f=>f.type===pe.NPS)&&(T=420);const v=Pe(r.theme||w.theme),S=d.useMemo(()=>{let f=v.bubbleY;const g=s?.version.theme;return!t&&s&&g&&s.version.checklist?.launcherEnabled&&r.appearance===k.BUBBLE&&g.checklistLauncherPlacement===v.bubblePlacement&&(v.avatarType===fe.NONE||g.checklistLauncherX<v.bubbleX+v.avatarSize)&&(f=Math.max(v.bubbleY,g.checklistLauncherY+g.checklistLauncherHeight+v.bubbleY)),{...v,bubbleWidth:Math.max(v.bubbleWidth,T),bubbleY:f}},[t,s,r.appearance,v,T]);d.useEffect(()=>{i!==e&&m({kind:"updateSession",session:e});const f=g=>{g.session.id===i.id&&m({kind:"goToStep",stepId:g.step.id})};return o.on("gotostep",f),()=>{o.off("gotostep",f)}},[o,i,e]);const re=d.useMemo(()=>({dispatch:m,restart:()=>{o.goToStep(i,te(i)),m({kind:"showFlow"})}}),[o,m,i]),le=d.useMemo(()=>r.selector&&J(r.selector,i.data),[r.selector,i.data]),ae=d.useCallback(()=>{Me(o,i,r.actions)},[o,i,r.actions]);d.useEffect(()=>{u.muted?C.setItem(P,"true"):C.removeItem(P)},[u.muted]);const j=i.locale?i.locale.standardLocaleId:S.languageId;d.useEffect(()=>{Fe.changeLanguage(j)},[j]);const[U,ie]=d.useState(!1),ce=d.useCallback(f=>{ie(f),f&&o.send({kind:"ReportTooltipTargetMissing",sessionId:i.id,stepId:r.id}),f&&S.tooltipMissingBehavior===x.END&&!i.draftMode&&o.endFlow(i,{endReason:B.TOOLTIP_TARGET_MISSING})},[o,i,r.id,S.tooltipMissingBehavior]);return d.useEffect(()=>{if(!l||!u.autoFocusRequested)return;!o.originalActiveElement&&o.originalActiveElement!==a?.ownerDocument.defaultView?.frameElement&&(o.originalActiveElement=document.activeElement);let f=a?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(f&&f.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const g=a?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");g&&(f=g)}f&&typeof f.focus=="function"&&f.focus({preventScroll:!0}),m({kind:"autoFocused"})},[o,a,l,u.autoFocusRequested]),d.useEffect(()=>{const f=a?.ownerDocument.defaultView;if(!f)return;const g=()=>{m({kind:"focusOut"}),delete o.originalActiveElement},y=()=>{m({kind:"focusIn"})};return window.addEventListener("focusin",g),f.addEventListener("focusin",y),()=>{window.removeEventListener("focusin",g),f.removeEventListener("focusin",y)}},[a,o]),d.useEffect(()=>{if(!h||!a)return;const f=a.ownerDocument.defaultView,g=f?f.document:document,y=F=>{if(F.key==="Escape"&&!w.closeDisabled)o.endFlow(i,{endReason:B.USER_CLOSED});else if(F.key==="Tab"){const L=a.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),q=L[0],V=L[L.length-1],H=g.activeElement;F.shiftKey?H===q&&(F.preventDefault(),V.focus()):H===V&&(F.preventDefault(),q.focus())}};return window.addEventListener("keydown",y),f?.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y),f?.removeEventListener("keydown",y)}},[h,o,i,a,w.closeDisabled]),d.useEffect(()=>{if(u.scrollToTopRequested){if(a?.ownerDocument.defaultView?.frameElement){const f=a?.ownerDocument.body;f&&(f.scrollTop=0)}m({kind:"scrolledToTop"})}},[u.scrollToTopRequested,a]),n.createElement(ne.Provider,{value:re},n.createElement(se.Provider,{value:u},n.createElement(Be.Provider,{value:i},n.createElement(Le,null,n.createElement(ge,{company:i.flow.company,theme:S,position:"fixed",stepKey:r.crossVersionId,stepAppearance:r.appearance,width:r.width,backgroundImageUrl:b==="flow"&&!U&&r.backgroundAsset?r.backgroundAsset.assetUrl:null,tooltipSelector:le,tooltipPlacement:r.tooltipPlacement,backdrop:r.backdrop,tooltipTargetBlocked:r.tooltipTargetBlocked,backdropPadding:r.backdropPadding,onTooltipTargetClick:ae,onTooltipTargetMissingChange:ce,onModalBackdropClick:r.appearance===k.MODAL&&S.modalBackdropOnclick===me.DISMISS&&!w.closeDisabled?()=>o.endFlow(i,{endReason:B.USER_CLOSED}):void 0,speaking:E,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:p,bubbleFrameRootRef:c,rootChildren:f=>n.createElement(Ze,{...f,theme:S})},b==="menu"?n.createElement(xe,null):U&&S.tooltipMissingBehavior!==x.BUBBLE?n.createElement(Qe,null):n.createElement(Oe,{theme:S}))))))},Ze=({visible:e,bubbleFrame:s,theme:t})=>{const o=M(),{step:l}=o,p=o.session.currentStep&&o.session.currentStep.id,[a,c]=d.useState(!1),u=d.useRef(p);return d.useEffect(()=>{e?c(!0):u.current!==p&&c(!1),u.current=p},[p,e]),n.createElement(n.Fragment,null,(e||a)&&o.contentType==="flow"&&n.createElement(n.Fragment,null,n.createElement(je,{bubbleFrame:s,theme:t}),n.createElement(Ge,{theme:t})),l.triggers.map(m=>n.createElement(Ae,{key:m.id,trigger:m})))},Je={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function et(e,s){switch(s.kind){case"updateSession":{let t;return s.session.id===e.session.id?t=s.session.version.steps.find(({crossVersionId:o})=>o===e.step.crossVersionId)||O(s.session):t=O(s.session),{...e,session:s.session,step:t}}case"goToStep":{const t=e.session.version.steps.find(o=>o.id===s.stepId);return t?{...e,step:t,contentType:"flow",autoFocusRequested:e.hasFocus||oe(t),scrollToTopRequested:!0,shouldLabelDialog:!e.hasFocus}:e}case"toggleMuted":return{...e,muted:!e.muted};case"speechPlaying":return{...e,speechPlaying:!0};case"speechStopped":return{...e,speechPlaying:!1};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0,scrollToTopRequested:!0};case"showMenu":return{...e,contentType:"menu",autoFocusRequested:!0,scrollToTopRequested:!0};case"autoFocused":return{...e,autoFocusRequested:!1};case"focusIn":return{...e,hasFocus:!0};case"focusOut":return{...e,hasFocus:!1};case"scrolledToTop":return{...e,scrollToTopRequested:!1}}}function O(e){const{currentStep:s}=e,{steps:t}=e.version;if(s){const o=t.find(({crossVersionId:l})=>l===s.crossVersionId);if(!o)throw new X("Session points to an unknown step: "+s.crossVersionId);return o}else return te(e)}function te(e){const s=e.version.steps[0];if(!s)throw new X("Session has no current step and its version has no start step");return s}function oe(e){return D(e)}function D(e){return e.appearance===k.MODAL||e.appearance===k.BUBBLE&&e.backdrop||e.appearance===k.TOOLTIP&&e.tooltipTargetBlocked}const ne=d.createContext(null),se=d.createContext(null);function R(){return d.useContext(ne)}function M(){return d.useContext(se)}export{Dt as FlowApp,se as FlowStateContext,Dt as default,Je as initialFlowState,D as isStepModal,R as useFlowDispatch,M as useFlowState};
6
6
  //# sourceMappingURL=FlowApp.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.react-i18next.js","vendor.babel.runtime.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","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{a as j,C as W,c as Ce,u as le,g as qt,b as tt,e as nt,E as Kt,A as Y,f as Qt,h as Zt,i as Gt,j as rt,S as st,k as ot,_ as Jt}from"./userflow.js";import{r as l,R as e}from"./vendor.react.js";import{u as R,i as ue}from"./client-context.js";import{f as Xt,u as Yt,w as en,C as tn}from"./flow-host.styl.js";import{S as nn,b as Be,R as $,h as rn,s as Fe,a as q,n as sn}from"./use-selector-element-monitoring.js";import{g as x}from"./flow-condition-types.js";import{D as I,u as De,a as on,g as gt}from"./stylesheets.js";import{u as cn,F as He}from"./use-window-resize.js";import{o as H}from"./vendor.obj-str.js";import{M as ke,c as ct,d as at}from"./roots.js";import{S as an}from"./logomark.js";import"./vendor.core-js.js";import{f as ln,C as un}from"./ChecklistUI.js";import{f as dn,a as Pe,b as mn,c as fn,d as hn,e as Ct,g as Z,h as wn,i as En,j as bn,k as pn}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as vn,B as gn}from"./FlowChrome.js";import{u as Cn}from"./use-element-rect.js";import{B as kn}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]="8240fcf2-4fd5-4996-9b0b-c1a5bbc9becc",t._sentryDebugIdIdentifier="sentry-dbid-8240fcf2-4fd5-4996-9b0b-c1a5bbc9becc")}catch{}})();function jn(t,n,r){return t.resourceCenterAutoDividers?lt(n)||lt(r):!1}function lt(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 d=window,je={[W.CRISP]:{configure:({onShow:t,onHide:n})=>{Nn();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())},v=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(v)}},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");yn();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),Sn();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())},v=new ke(u);v.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=()=>{v.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 In(),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");An();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),Rn(),()=>{xe.delete(r),Me.delete(s)}},show:()=>{d.zE("messenger","open")},hide:()=>{d.zE("messenger","close")}}};let ut=!1;function Nn(){ut||(ut=!0,d.$crisp||(d.$crisp=[]),d.$crisp.push(["do","chat:hide"]))}let it=!1;function yn(){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 Sn(){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 In(){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 An(){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 Rn(){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 Tn=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=R(),[s,c]=l.useState(!0),[a,o]=l.useState(!1),[i,m]=l.useState(null),[u,v]=l.useState(null),[E,h]=l.useState(null),f=l.useRef(0),b=l.useRef(null),g=l.useRef(()=>{});return l.useEffect(()=>{if(n)return;const y=JSON.stringify(t);if(y===b.current)return;b.current=y;const S=++f.current;let k,C;const L=async()=>{c(!0);try{C=t;const T=await r.send(t,{handlesRejection:!0});if(S!==f.current)return;k=T,m(k),v(t),h(null)}catch(T){if(S!==f.current)return;h(T)}finally{c(!1)}};let U=!1;g.current=async(T,J)=>{if(!U){U=!0,o(!0);try{const M=T(k,C);C=M;const te=await r.send(M,{handlesRejection:!0});if(S!==f.current)return;k=J(k,te),m(k),h(null)}catch(M){if(S!==f.current)return;h(M)}finally{U=!1,o(!1)}}},L()},[n,r,t]),{loading:s,loadingMore:a,data:i,messageForData:u,error:E,loadMore:g.current}}const Ln=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)},Ln)},[n]);return l.useEffect(()=>()=>{window.clearTimeout(c.current)},[]),[r,o,a]}const _n=({textareaRef:t,value:n,onChange:r,onBlur:s,onKeyDown:c,onMouseDown:a,placeholder:o,disabled:i,readOnly:m,className:u,mirrorClassName:v,textareaClassName:E,children:h})=>{let f=n||o||"";return(f===""||f.endsWith(`
4
- `))&&(f+=" "),u=u||"growing-textarea",v=v||u+"__mirror",e.createElement("div",{className:u},e.createElement("div",{className:v+" "+(E||"")},f),e.createElement("textarea",{ref:t,value:n,onChange:b=>r&&r(b.target.value),onBlur:s,onKeyDown:c,onMouseDown:a,placeholder:o,disabled:i,readOnly:m,className:E}),h)},xn=({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(_n,{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(I,{icon:dn})))};function Mn(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function jt(t){return Ce.linkUrlDecorator?Ce.linkUrlDecorator(t):t}const Et=5,Bn=async()=>(await Jt(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]))).ResourceCenterAssistantChat,bt=({session:t,isOpen:n,flowSession:r,checklistSession:s})=>{const c=R(),{t:a}=G(),{company:o}=t.flow,{version:i}=t,m=i.resourceCenter,u=De(i.theme),v=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;l.useEffect(()=>{ue.changeLanguage(v)},[v]);const{loaded:E}=on(window,Xt,u),[h,f]=l.useState(!1),b=E&&h,[g,y]=l.useState(ct()),[S,k]=l.useState(at()),C=l.useCallback(()=>{y(ct()),k(at())},[]);cn(C);const{zIndex:L,bringToFront:U}=Yt(),[T,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,Ft]=l.useState(0),[Dt,Ht]=l.useState(0),me=l.useCallback(()=>{M&&Ft(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(!T||typeof ke!="function")return;const w=new ke(()=>{me()});return w.observe(T,{childList:!0,attributes:!0,subtree:!0}),()=>{w.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)},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(!Mn())if(n){const w='button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea';let N=X?.querySelector(".userflowjs-assistant-chat-input textarea")||X?.querySelector(w)||z?.querySelector(w);if(N){const B=N.closest&&N.closest(".userflowjs-resource-center-checklist")||null;B?ln(B):N.focus({preventScroll:!0})}}else M?.focus({preventScroll:!0});K(!1)}},[Ke,n,X,z,M]),l.useEffect(()=>{const w=T?.ownerDocument.defaultView;if(!n||!w)return;const N=B=>{B.key==="Escape"&&(he(),K(!0))};return w.addEventListener("keydown",N),()=>w.removeEventListener("keydown",N)},[n,T,K,he]);const[p,we]=l.useState(()=>Pn(t,le.getItem(`resourceCenterRoute:v1:${t.id}`))),F=l.useCallback((w,N)=>{we(w);const B=Hn(w);B?le.setItem(`resourceCenterRoute:v1:${t.id}`,B):le.removeItem(`resourceCenterRoute:v1:${t.id}`),N?.detail===0&&K(!0)},[t.id]);l.useEffect(()=>{if(!t.draftMode||!p||!("block"in p)||!p.block)return;const w=m.blocks.find(N=>N.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===j.CHECKLIST&&!s||w.type===j.DIVIDER&&u.resourceCenterAutoDividers||w.hiddenWhenFlowsActive&&w.hiddenWhenFlowsActive.some(N=>N===r?.flow.id||N===s?.flow.id))),[m,r,s,u.resourceCenterAutoDividers]),Ee=l.useMemo(()=>yt(se),[se]),be=l.useMemo(()=>!s||!m.blocks.some(w=>w.type===j.CHECKLIST)?0:qt(s),[m,s]),_=l.useMemo(()=>m.blocks.find(w=>w.type===j.CONTACT&&w.chatEnabled&&w.chatProvider),[m]),[Pt,Qe]=l.useState(!1),oe=l.useCallback(()=>{c.closeResourceCenter(),_&&_.chatProvider!==W.CUSTOM&&Qe(!0)},[c,_]),ce=l.useCallback(()=>{Qe(!1)},[]),Ze=l.useCallback(()=>{if(_)try{je[_.chatProvider].hide({block:_}),ce()}catch(w){console.error(`Userflow.js: Error when hiding ${_.chatProvider}:`,w)}},[_,ce]);l.useEffect(()=>{if(!_)return;Ce.autoHide3pDisabled=!0;const w=je[_.chatProvider];try{const N=w.configure({block:_,onShow:oe,onHide:ce});return()=>{N()}}catch(N){console.error(`Userflow.js: Error when configuring ${_.chatProvider}:`,N);return}},[_,oe,ce]),l.useEffect(()=>{n&&Ze()},[Ze,n]);const D=l.useMemo(()=>m.blocks.find(w=>w.type===j.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,g-2*u.resourceCenterPaddingX),Wt=540,Ot=720,$t={zIndex:u.resourceCenterZIndex!=null?u.resourceCenterZIndex:n?L:en(tn),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:Dt,S-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(nn.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(Tn,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(Un,{session:t,navigate:F}):p.kind==="email"?e.createElement(Wn,{block:p.block,session:t}):p.kind==="phone"?e.createElement(On,{block:p.block,session:t}):p.kind==="flows"?e.createElement($n,{block:p.block,initialQ:p.initialQ,session:t,navigate:F}):p.kind==="knowledgeBase"?e.createElement(zn,{block:p.block,initialQ:p.initialQ,session:t,bodyRef:de}):p.kind==="subpage"?e.createElement(Vn,{block:p.block,session:t}):p.kind==="announcementList"||p.kind==="announcementShow"?e.createElement(qn,{bodyRef:de,session:t,route:p,navigate:F}):p.kind==="assistant"?e.createElement(Zn,{block:p.block,initialUserContent:p.initialUserContent,session:t,navigate:F,chatBlock:_,onChatShow:oe}):null:e.createElement(e.Fragment,null,se.map((w,N)=>{const B=ee[w.type],et=se[N+1];return B?e.createElement(e.Fragment,{key:w.id},e.createElement(B.View,{session:t,flowSession:r,checklistSession:s,block:w,navigate:F,onChatShow:oe}),et&&jn(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(an,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(I,{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=>F(p?.kind==="announcementShow"?{kind:"announcementList",block:p.block}:null,w)},e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(I,{icon:mn})),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 N=Ee[0],B=ee[N.type];B.routeTo&&(w=B.routeTo({block:N}))}p?.kind==="search"?F(null):(A(c,t,null,"Search icon"),F(w))},"aria-label":"Search"},e.createElement(I,{icon:fn})),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(I,{icon:hn}))))))),!n&&!r&&D&&D.unreadAnnouncementCount>0&&e.createElement(Fn,{theme:u,count:D.unreadAnnouncementCount,onClick:Xe})),!n&&!r&&D?.popoutAnnouncement&&e.createElement(pt,{session:t,open:re,navigate:F,block:D}),!n&&!r&&D?.boosterAnnouncement&&D?.boosterAnnouncement.level===Y.MODAL&&e.createElement(Dn,{session:t,open:re,navigate:F,block:D}),!n&&!r&&D?.boosterAnnouncement&&D?.boosterAnnouncement.level===Y.TOAST&&e.createElement(pt,{session:t,open:re,navigate:F,block:D,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=De(o.theme),m=i.toastPlacement,u=!!s.boosterAnnouncement,v=m===c;let E=null,h=null;o&&(E=o.toastAutoDismiss??i.toastAutoDismiss,h=o.toastWidth?o.toastWidth:i.toastWidth);const f=R(),[b,g]=l.useState(!1),{height:y,setEl:S}=Cn();l.useEffect(()=>{const T=a.current;if(!T||E===null)return;const J=Date.now(),M=()=>{const z=1-(Date.now()-J)/(new kn(E||0).toNumber()*1e3);z<=0?(T.style.width="0%",o&&O(f,o)):(T.style.width=`${z*100}%`,requestAnimationFrame(M))};return requestAnimationFrame(M),()=>{T&&(T.style.width="0%")}},[a.current,E,f,o,O]);const k=()=>{o&&O(f,o)},C=20,L=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,"-")}`]:!v&&!!m&&u}),style:gt(i)},e.createElement(He,{className:H({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${y}px, 100${L} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - ${C}px)`,position:b?void 0:"absolute",visibility:b?void 0:"hidden",...h&&u?{width:h}:{}},stylesheet:Be,theme:i,onStylesheetsLoad:g,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:S,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})),!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(I,{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:k,"aria-label":"Dismiss announcement"},e.createElement(I,{icon:Pe}))))),!u&&e.createElement("div",{className:"userflowjs-resource-center-popout-notch"})):null},Dn=({session:t,open:n,navigate:r,block:s})=>{const c=s.boosterAnnouncement,a=R(),o=De(c.theme),i=()=>{O(a,c)};return e.createElement(vn,{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})),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:i,"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:()=>{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={[j.ACTION]:{View:t=>{const{block:n,session:r,flowSession:s,checklistSession:c}=t,a=R(),[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 v=n.actions.find(E=>E.type===Zt.START_FLOW);v?v.otherFlow?.id!==c?.flow.id&&i(!0):a.closeResourceCenter(),rn(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=R();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(I,{icon:Z})))}},[j.ASSISTANT]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=R(),[a,o]=l.useState("");return n.assistantAppearance===Gt.INPUT?e.createElement("div",{className:"userflowjs-resource-center-assistant-block"},e.createElement(xn,{value:a,onChange:o,placeholder:Fe(n.name,{lookupAttribute:x(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(un,{session:t}),e.createElement(gn,{draftMode:t.draftMode?"CHECKLIST PREVIEW":!1}))},[j.CONTACT]:{View:t=>{const{block:n,session:r,navigate:s,onChatShow:c}=t,a=R(),o=[];return n.emailEnabled&&o.push({icon:En,label:"Email",isRoute:!0,onClick:i=>{A(a,r,n,"Email"),s({kind:"email",block:n},i)}}),n.phoneEnabled&&o.push({icon:bn,label:"Phone",isRoute:!0,onClick:i=>{A(a,r,n,"Phone"),s({kind:"phone",block:n},i)}}),n.chatEnabled&&o.push({icon:pn,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(I,{icon:o[0].icon})),e.createElement(V,{...t}),o.length>1&&o.map(({icon:i,label:m,onClick:u},v)=>e.createElement("button",{key:v,className:"userflowjs-resource-center-icon-button",onClick:u,"aria-label":m},e.createElement(I,{icon:i}))),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=R();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=St(c,s),o=a.slice(0,Et);return{block:r,truncated:o.length===a.length,results:o.map(i=>({kind:"flow",flow:i}))}}},[j.KNOWLEDGE_BASE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=R();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:Et},{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($,{doc:t.content,lookupAttribute:x(n.data)})))},[j.SUBPAGE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=R();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:x(n.data)}));function Hn(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 Pn(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 Un=({session:t,navigate:n})=>{const r=R(),s=t.version.resourceCenter.blocks,c=yt(s),{t:a}=G(),o=l.useRef(null),[i,m]=l.useState(""),[u,v]=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 g=await Promise.all(s.map(async y=>{const{search:S}=ee[y.type];if(!S)return null;try{return await S({client:r,session:t,block:y,q:i})}catch(k){return console.error(`Userflow.js: Global search failed for ${y.type} block=`,y,"error=",k),null}}));f||h(g.filter(y=>y!=null&&y.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=>v(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:x(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:g},y)=>{const S=ee[f.type],k=S.routeTo&&S.routeTo({block:f,initialQ:i});return e.createElement(e.Fragment,{key:f.cvid},y>0&&e.createElement("div",{className:"userflowjs-resource-center-divider"}),e.createElement("div",{className:"userflowjs-resource-center-label"},e.createElement(q,{doc:f.name,lookupAttribute:x(t.data)})),g.map((C,L)=>C.kind==="flow"?e.createElement(It,{key:C.flow.id,block:f,session:t,flow:C.flow,navigate:n}):C.kind==="article"?e.createElement(At,{key:L,block:f,session:t,article:C.article}):null),!b&&k&&e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:C=>{A(r,t,f),n(k,C)}},e.createElement("div",{className:"userflowjs-resource-center-block-text"},a("more"),":"," ",e.createElement(q,{doc:f.name,lookupAttribute:x(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)))},Wn=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.emailContent,lookupAttribute:x(n.data)})),On=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.phoneContent,lookupAttribute:x(n.data)})),$n=({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:v,error:E}=ie({message:{kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:t.cvid}}),h=v?.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:x(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=R(),[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=Fe(r.url,{lookupAttribute:x(n.data)});i&&sn(i)},disabled:a},e.createElement("div",{className:"userflowjs-resource-center-block-icon"},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))},zn=({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:v,loadingMore:E,data:h,messageForData:f,error:b,loadMore:g}=ie({message:{kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:t.cvid,q:o,offset:0}}),y=h?.truncated,S=l.useCallback(()=>{g((C,L)=>({...L,offset:C.articles.length}),(C,L)=>({...L,articles:[...C.articles,...L.articles]}))},[g]);Rt({bodyRef:s,loading:v,loadingMore:E,truncated:y,loadMoreHelper:S}),l.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]);let k=t.knowledgeBaseUrl||"";return k.match(/^https?:\/\//)||(k=`http://${k}`),k=jt(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:x(r.data)})),e.createElement("a",{className:"userflowjs-resource-center-icon-button",href:k,target:"_blank",rel:"noopener noreferrer"},e.createElement(I,{icon:wn}))),e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:a,className:"userflowjs-text-input",type:"text",value:m,onChange:C=>u(C.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")):v||!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((C,L)=>e.createElement(At,{key:L,block:t,session:r,article:C})),E&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null))))},At=({block:t,article:n,session:r})=>{const s=R();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(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}})))},Vn=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.content,lookupAttribute:x(n.data)})),qn=({bodyRef:t,session:n,route:r,navigate:s})=>{const c=R(),a=ie({message:{kind:"ListAnnouncements",beforeAnnouncementId:null},skip:r?.kind!=="announcementList"}),{loading:o,loadingMore:i,data:m,loadMore:u}=a,v=m?.truncated,E=l.useCallback(()=>{u((b,g)=>b.announcements.length>0?{...g,beforeAnnouncementId:b.announcements[b.announcements.length-1].id}:g,(b,g)=>({...g,announcements:[...b.announcements,...g.announcements]}))},[u]);Rt({bodyRef:t,loading:o,loadingMore:i,truncated:v,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(Kn,{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(Qn,{block:r.block,announcementId:r.announcementId}):null},Kn=({bodyRef:t,block:n,session:r,onMoreClick:s,error:c,loading:a,loadingMore:o,data:i})=>{const{t:m}=G(),[u,v]=l.useMemo(()=>{const h=[],f=[];if(i){let b=-1;for(const g of i.announcements)b++,b<i.pageSize&&!g.seen&&g.level!==Y.SILENT?h.push(g):f.push(g)}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:x(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&&v.length>0&&e.createElement("div",{className:"userflowjs-announcement-seen-divider"}),v.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===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(),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=R(),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})),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:Ct})))))},Qn=({announcementId:t})=>{const n=R(),{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}),o.moreEnabled&&e.createElement($,{doc:o.moreContent,buttons:o.moreButtons})))))},Zn=({block:t,initialUserContent:n,session:r,navigate:s,onChatShow:c})=>{const a=t.assistantFlowId,o=R(),[i,m]=l.useState(null),[u,v]=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 g=!1;return(async()=>{try{const S=le.getItem("assistantConversationId:"+a),[k,C]=await Promise.all([Bn(),o.send({kind:"GetAssistant",assistantFlowId:a,conversationId:S},{handlesRejection:!0,endBatch:!0})]);if(g)return;m(()=>k),v(C)}catch(S){console.error("Resource center assistant route failed to load:",S),h(S.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{g=!0}},[o,a]);const b=l.useMemo(()=>{if(!t.assistantContactEnabled)return;const g=r.version.resourceCenter?.blocks.find(y=>y.type===j.CONTACT);if(g)return()=>{switch(A(o,r,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case ot.EMAIL:s({kind:"email",block:g});break;case ot.PHONE:s({kind:"phone",block:g});break;default:s(null),Tt(r,g,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?Fe(r.name,{lookupAttribute:x(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 hr=Object.freeze(Object.defineProperty({__proto__:null,ResourceCenterApp:bt,default:bt},Symbol.toStringTag,{value:"Module"}));export{xn as A,_n as G,hr 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.react-i18next.js","vendor.babel.runtime.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","use-window-resize.js","logomark.js","ChecklistUI.js","FlowChrome.js","use-element-rect.js","vendor.bignumber.js.js","index.js"])))=>i.map(i=>d[i]);
2
+ import{a as j,C as W,c as Ce,u as le,g as Vt,b as tt,e as nt,E as qt,A as Y,f as Kt,h as Qt,i as Zt,j as Gt,S as rt,k as st,_ as Jt}from"./userflow.js";import{r as l,R as e}from"./vendor.react.js";import{u as R,i as ue}from"./client-context.js";import{f as Xt,u as Yt,w as en,C as tn}from"./flow-host.styl.js";import{S as nn,b as Be,R as $,h as rn,s as Fe,a as q,n as sn}from"./use-selector-element-monitoring.js";import{g as x}from"./flow-condition-types.js";import{D as I,u as De,a as on,g as vt}from"./stylesheets.js";import{u as cn,F as He}from"./use-window-resize.js";import{o as H}from"./vendor.obj-str.js";import{M as ke,c as ot,d as ct}from"./roots.js";import{S as an}from"./logomark.js";import"./vendor.core-js.js";import{f as ln,C as un}from"./ChecklistUI.js";import{f as dn,a as Pe,b as mn,c as fn,d as hn,e as gt,g as Z,h as wn,i as En,j as bn,k as pn}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{F as vn,B as gn}from"./FlowChrome.js";import{u as Cn}from"./use-element-rect.js";import{B as kn}from"./vendor.bignumber.js.js";import{R as jn}from"./index.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]="d97818d0-d9d3-4210-bc36-3ec356f1afa2",t._sentryDebugIdIdentifier="sentry-dbid-d97818d0-d9d3-4210-bc36-3ec356f1afa2")}catch{}})();function Nn(t,n,r){return t.resourceCenterAutoDividers?at(n)||at(r):!1}function at(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 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())},v=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(v)}},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?(it(),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:()=>{it(),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())},v=new ke(u);v.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=()=>{v.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:()=>{Ct(),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()};_e.add(o);const i=m=>{const u=m>0;u!==s&&(s=u,c())};return Le.add(i),()=>{Te.delete(a),_e.delete(o),Le.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 lt=!1;function yn(){lt||(lt=!0,d.$crisp||(d.$crisp=[]),d.$crisp.push(["do","chat:hide"]))}let ut=!1;function Sn(){ut||(ut=!0,Ne())}function it(){d.Beacon("config",{display:{style:"icon"}})}function Ne(){d.Beacon("config",{display:{style:"manual"}})}let dt=!1,Ue=!1;function In(){dt||(dt=!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 mt=!1,Ie=new Set,Ae=new Set;function An(){if(mt)return;mt=!0,Re();let t=!1,n=!1;const r=()=>{Ct();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 Ct(){d.Intercom("update",{hide_default_launcher:!1,vertical_padding:20})}function Re(){d.Intercom("update",{hide_default_launcher:!0,vertical_padding:100})}let ft=!1,Te=new Set,_e=new Set,Le=new Set;function Rn(){ft||(ft=!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 _e)t()}),d.zE("webWidget:on","chat:unreadMessages",t=>{for(const n of Le)n(t)}))}let ht=!1,xe=new Set,Me=new Set;function Tn(){ht||(ht=!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 _n=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=R(),[s,c]=l.useState(!0),[a,o]=l.useState(!1),[i,m]=l.useState(null),[u,v]=l.useState(null),[E,h]=l.useState(null),f=l.useRef(0),b=l.useRef(null),g=l.useRef(()=>{});return l.useEffect(()=>{if(n)return;const y=JSON.stringify(t);if(y===b.current)return;b.current=y;const S=++f.current;let k,C;const _=async()=>{c(!0);try{C=t;const T=await r.send(t,{handlesRejection:!0});if(S!==f.current)return;k=T,m(k),v(t),h(null)}catch(T){if(S!==f.current)return;h(T)}finally{c(!1)}};let U=!1;g.current=async(T,J)=>{if(!U){U=!0,o(!0);try{const M=T(k,C);C=M;const te=await r.send(M,{handlesRejection:!0});if(S!==f.current)return;k=J(k,te),m(k),h(null)}catch(M){if(S!==f.current)return;h(M)}finally{U=!1,o(!1)}}},_()},[n,r,t]),{loading:s,loadingMore:a,data:i,messageForData:u,error:E,loadMore:g.current}}const Ln=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)},Ln)},[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:v,textareaClassName:E,children:h})=>{let f=n||o||"";return(f===""||f.endsWith(`
4
+ `))&&(f+=" "),u=u||"growing-textarea",v=v||u+"__mirror",e.createElement("div",{className:u},e.createElement("div",{className:v+" "+(E||"")},f),e.createElement("textarea",{ref:t,value:n,onChange:b=>r&&r(b.target.value),onBlur:s,onKeyDown:c,onMouseDown:a,placeholder:o,disabled:i,readOnly:m,className:E}),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(I,{icon:dn})))};function Bn(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function kt(t){return Ce.linkUrlDecorator?Ce.linkUrlDecorator(t):t}const wt=5,Fn=async()=>(await Jt(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,Et=({session:t,isOpen:n,flowSession:r,checklistSession:s})=>{const c=R(),{t:a}=G(),{company:o}=t.flow,{version:i}=t,m=i.resourceCenter,u=De(i.theme),v=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;l.useEffect(()=>{ue.changeLanguage(v)},[v]);const{loaded:E}=on(window,Xt,u),[h,f]=l.useState(!1),b=E&&h,[g,y]=l.useState(ot()),[S,k]=l.useState(ct()),C=l.useCallback(()=>{y(ot()),k(ct())},[]);cn(C);const{zIndex:_,bringToFront:U}=Yt(),[T,J]=l.useState(null),[M,te]=l.useState(null),[z,Tt]=l.useState(null),de=l.useRef(null),[X,_t]=l.useState(null),[$e,Lt]=l.useState(null),[ze,xt]=l.useState(null),[Mt,Bt]=l.useState(0),[Ft,Dt]=l.useState(0),me=l.useCallback(()=>{M&&Bt(Math.round(M.offsetWidth)),Dt(Math.round((z?.offsetHeight||0)+(X?.offsetHeight||0)+($e?.offsetHeight||0)+(ze?.offsetHeight||0)))},[M,z,X,$e,ze]);l.useLayoutEffect(()=>{if(!T||typeof ke!="function")return;const w=new ke(()=>{me()});return w.observe(T,{childList:!0,attributes:!0,subtree:!0}),()=>{w.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)},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 N=X?.querySelector(".userflowjs-assistant-chat-input textarea")||X?.querySelector(w)||z?.querySelector(w);if(N){const B=N.closest&&N.closest(".userflowjs-resource-center-checklist")||null;B?ln(B):N.focus({preventScroll:!0})}}else M?.focus({preventScroll:!0});K(!1)}},[Ke,n,X,z,M]),l.useEffect(()=>{const w=T?.ownerDocument.defaultView;if(!n||!w)return;const N=B=>{B.key==="Escape"&&(he(),K(!0))};return w.addEventListener("keydown",N),()=>w.removeEventListener("keydown",N)},[n,T,K,he]);const[p,we]=l.useState(()=>Un(t,le.getItem(`resourceCenterRoute:v1:${t.id}`))),F=l.useCallback((w,N)=>{we(w);const B=Pn(w);B?le.setItem(`resourceCenterRoute:v1:${t.id}`,B):le.removeItem(`resourceCenterRoute:v1:${t.id}`),N?.detail===0&&K(!0)},[t.id]);l.useEffect(()=>{if(!t.draftMode||!p||!("block"in p)||!p.block)return;const w=m.blocks.find(N=>N.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===j.CHECKLIST&&!s||w.type===j.DIVIDER&&u.resourceCenterAutoDividers||w.hiddenWhenFlowsActive&&w.hiddenWhenFlowsActive.some(N=>N===r?.flow.id||N===s?.flow.id))),[m,r,s,u.resourceCenterAutoDividers]),Ee=l.useMemo(()=>Nt(se),[se]),be=l.useMemo(()=>!s||!m.blocks.some(w=>w.type===j.CHECKLIST)?0:Vt(s),[m,s]),L=l.useMemo(()=>m.blocks.find(w=>w.type===j.CONTACT&&w.chatEnabled&&w.chatProvider),[m]),[Ht,Qe]=l.useState(!1),oe=l.useCallback(()=>{c.closeResourceCenter(),L&&L.chatProvider!==W.CUSTOM&&Qe(!0)},[c,L]),ce=l.useCallback(()=>{Qe(!1)},[]),Ze=l.useCallback(()=>{if(L)try{je[L.chatProvider].hide({block:L}),ce()}catch(w){console.error(`Userflow.js: Error when hiding ${L.chatProvider}:`,w)}},[L,ce]);l.useEffect(()=>{if(!L)return;Ce.autoHide3pDisabled=!0;const w=je[L.chatProvider];try{const N=w.configure({block:L,onShow:oe,onHide:ce});return()=>{N()}}catch(N){console.error(`Userflow.js: Error when configuring ${L.chatProvider}:`,N);return}},[L,oe,ce]),l.useEffect(()=>{n&&Ze()},[Ze,n]);const D=l.useMemo(()=>m.blocks.find(w=>w.type===j.ANNOUNCEMENTS),[m]),Pt=!!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,g-2*u.resourceCenterPaddingX),Ut=540,Wt=720,Ot={zIndex:u.resourceCenterZIndex!=null?u.resourceCenterZIndex:n?_:en(tn),position:b?void 0:"absolute",visibility:b&&!Ht?void 0:"hidden"},$t={width:(n?pe:Mt)+"px",height:n?Math.min(Pt?Ut:Ge?Wt:Ft,S-2*u.resourceCenterPaddingY,u.resourceCenterMaxHeight==null?Number.MAX_VALUE:u.resourceCenterMaxHeight)+"px":void 0},[zt,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(nn.Provider,{value:t},e.createElement("div",{"data-testid":"resource-center-app",className:"userflowjs-resource-center-app userflowjs-theme-root",style:vt(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:Ot},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:$t,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":zt}),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(_n,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:F}):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:F}):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:F}):p.kind==="assistant"?e.createElement(Gn,{block:p.block,initialUserContent:p.initialUserContent,session:t,navigate:F,chatBlock:L,onChatShow:oe}):null:e.createElement(e.Fragment,null,se.map((w,N)=>{const B=ee[w.type],et=se[N+1];return B?e.createElement(e.Fragment,{key:w.id},e.createElement(B.View,{session:t,flowSession:r,checklistSession:s,block:w,navigate:F,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:Lt},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(an,null),e.createElement("div",null,"Made with Userflow")))),t.draftMode&&e.createElement("div",{className:"userflowjs-resource-center-preview"},e.createElement("div",{ref:xt,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:qt.USER_CLOSED})}},e.createElement(I,{icon:Pe})))),e.createElement("div",{className:"userflowjs-resource-center-header",style:{width:pe+"px"}},e.createElement("div",{ref:Tt,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=>F(p?.kind==="announcementShow"?{kind:"announcementList",block:p.block}:null,w)},e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(I,{icon:mn})),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 N=Ee[0],B=ee[N.type];B.routeTo&&(w=B.routeTo({block:N}))}p?.kind==="search"?F(null):(A(c,t,null,"Search icon"),F(w))},"aria-label":"Search"},e.createElement(I,{icon:fn})),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(I,{icon:hn}))))))),!n&&!r&&D&&D.unreadAnnouncementCount>0&&e.createElement(Dn,{theme:u,count:D.unreadAnnouncementCount,onClick:Xe})),!n&&!r&&D?.popoutAnnouncement&&e.createElement(bt,{session:t,open:re,navigate:F,block:D}),!n&&!r&&D?.boosterAnnouncement&&D?.boosterAnnouncement.level===Y.MODAL&&e.createElement(Hn,{session:t,open:re,navigate:F,block:D}),!n&&!r&&D?.boosterAnnouncement&&D?.boosterAnnouncement.level===Y.TOAST&&e.createElement(bt,{session:t,open:re,navigate:F,block:D,rcPlacement:u.resourceCenterPlacement}))))},Dn=({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(jt,{count:n,onClick:r}))},jt=({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)},bt=({session:t,open:n,navigate:r,block:s,rcPlacement:c})=>{const a=l.useRef(null),o=s.popoutAnnouncement??s.boosterAnnouncement,i=De(o.theme),m=i.toastPlacement,u=!!s.boosterAnnouncement,v=m===c;let E=null,h=null;o&&(E=o.toastAutoDismiss??i.toastAutoDismiss,h=o.toastWidth?o.toastWidth:i.toastWidth);const f=R(),[b,g]=l.useState(!1),{height:y,setEl:S}=Cn();l.useEffect(()=>{const T=a.current;if(!T||E===null)return;const J=Date.now(),M=()=>{const z=1-(Date.now()-J)/(new kn(E||0).toNumber()*1e3);z<=0?(T.style.width="0%",o&&O(f,o)):(T.style.width=`${z*100}%`,requestAnimationFrame(M))};return requestAnimationFrame(M),()=>{T&&(T.style.width="0%")}},[a.current,E,f,o,O]);const k=()=>{o&&O(f,o)},C=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,"-")}`]:!v&&!!m&&u}),style:vt(i)},e.createElement(He,{className:H({"userflowjs-resource-center-popout-frame":!0}),style:{height:`calc(min(${y}px, 100${_} - 2 * var(--userflow-resource-center-padding-y) - var(--userflow-resource-center-collapsed-height) - ${C}px)`,position:b?void 0:"absolute",visibility:b?void 0:"hidden",...h&&u?{width:h}:{}},stylesheet:Be,theme:i,onStylesheetsLoad:g,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:S,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})),!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(I,{icon:gt})))))),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:k,"aria-label":"Dismiss announcement"},e.createElement(I,{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=R(),o=De(c.theme),i=()=>{O(a,c)};return e.createElement(vn,{company:t.flow.company,theme:o,position:"fixed",width:c.modalWidth,stepAppearance:Kt.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})),e.createElement("div",{className:"userflowjs-bubble-toolbar"},e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:i,"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:()=>{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 Nt(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=R(),[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 v=n.actions.find(E=>E.type===Qt.START_FLOW);v?v.otherFlow?.id!==c?.flow.id&&i(!0):a.closeResourceCenter(),rn(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=R();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(jt,{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=R(),[a,o]=l.useState("");return n.assistantAppearance===Zt.INPUT?e.createElement("div",{className:"userflowjs-resource-center-assistant-block"},e.createElement(Mn,{value:a,onChange:o,placeholder:Fe(n.name,{lookupAttribute:x(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(un,{session:t}),e.createElement(gn,{draftMode:t.draftMode?"CHECKLIST PREVIEW":!1}))},[j.CONTACT]:{View:t=>{const{block:n,session:r,navigate:s,onChatShow:c}=t,a=R(),o=[];return n.emailEnabled&&o.push({icon:En,label:"Email",isRoute:!0,onClick:i=>{A(a,r,n,"Email"),s({kind:"email",block:n},i)}}),n.phoneEnabled&&o.push({icon:bn,label:"Phone",isRoute:!0,onClick:i=>{A(a,r,n,"Phone"),s({kind:"phone",block:n},i)}}),n.chatEnabled&&o.push({icon:pn,label:"Live-chat",isRoute:!1,onClick:()=>{A(a,r,n,"Chat"),Rt(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(I,{icon:o[0].icon})),e.createElement(V,{...t}),o.length>1&&o.map(({icon:i,label:m,onClick:u},v)=>e.createElement("button",{key:v,className:"userflowjs-resource-center-icon-button",onClick:u,"aria-label":m},e.createElement(I,{icon:i}))),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=R();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=yt(c,s),o=a.slice(0,wt);return{block:r,truncated:o.length===a.length,results:o.map(i=>({kind:"flow",flow:i}))}}},[j.KNOWLEDGE_BASE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=R();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:wt},{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($,{doc:t.content,lookupAttribute:x(n.data)})))},[j.SUBPAGE]:{View:t=>{const{block:n,session:r,navigate:s}=t,c=R();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:x(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=R(),s=t.version.resourceCenter.blocks,c=Nt(s),{t:a}=G(),o=l.useRef(null),[i,m]=l.useState(""),[u,v]=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 g=await Promise.all(s.map(async y=>{const{search:S}=ee[y.type];if(!S)return null;try{return await S({client:r,session:t,block:y,q:i})}catch(k){return console.error(`Userflow.js: Global search failed for ${y.type} block=`,y,"error=",k),null}}));f||h(g.filter(y=>y!=null&&y.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=>v(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:x(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:g},y)=>{const S=ee[f.type],k=S.routeTo&&S.routeTo({block:f,initialQ:i});return e.createElement(e.Fragment,{key:f.cvid},y>0&&e.createElement("div",{className:"userflowjs-resource-center-divider"}),e.createElement("div",{className:"userflowjs-resource-center-label"},e.createElement(q,{doc:f.name,lookupAttribute:x(t.data)})),g.map((C,_)=>C.kind==="flow"?e.createElement(St,{key:C.flow.id,block:f,session:t,flow:C.flow,navigate:n}):C.kind==="article"?e.createElement(It,{key:_,block:f,session:t,article:C.article}):null),!b&&k&&e.createElement("button",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:C=>{A(r,t,f),n(k,C)}},e.createElement("div",{className:"userflowjs-resource-center-block-text"},a("more"),":"," ",e.createElement(q,{doc:f.name,lookupAttribute:x(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)))},On=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.emailContent,lookupAttribute:x(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:x(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:v,error:E}=ie({message:{kind:"ListResourceCenterBlockFlows",sessionId:r.id,blockCvid:t.cvid}}),h=v?.flows,f=l.useMemo(()=>h?yt(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:x(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(St,{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 yt(t,n){const r=n.toLowerCase().trim();return r===""?t:t.filter(s=>s.name.toLowerCase().includes(r))}const St=({block:t,session:n,flow:r,navigate:s})=>{const c=R(),[a,o]=l.useState(!1);return l.useEffect(()=>{if(!a||r.type!==Gt.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?rt.DRAFT:rt.RESOURCE_CENTER,replaceCurrent:!0}),o(!0);const i=Fe(r.url,{lookupAttribute:x(n.data)});i&&sn(i)},disabled:a},r.iconSetting!==jn.HIDE&&e.createElement("div",{className:"userflowjs-resource-center-block-icon"},r.icon&&e.createElement(I,{icon:r.icon,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:v,loadingMore:E,data:h,messageForData:f,error:b,loadMore:g}=ie({message:{kind:"SearchKnowledgeBase",sessionId:r.id,blockCvid:t.cvid,q:o,offset:0}}),y=h?.truncated,S=l.useCallback(()=>{g((C,_)=>({..._,offset:C.articles.length}),(C,_)=>({..._,articles:[...C.articles,..._.articles]}))},[g]);At({bodyRef:s,loading:v,loadingMore:E,truncated:y,loadMoreHelper:S}),l.useEffect(()=>{a.current?.focus({preventScroll:!0})},[]);let k=t.knowledgeBaseUrl||"";return k.match(/^https?:\/\//)||(k=`http://${k}`),k=kt(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:x(r.data)})),e.createElement("a",{className:"userflowjs-resource-center-icon-button",href:k,target:"_blank",rel:"noopener noreferrer"},e.createElement(I,{icon:wn}))),e.createElement("div",{className:"userflowjs-resource-center-list-route-search"},e.createElement("input",{ref:a,className:"userflowjs-text-input",type:"text",value:m,onChange:C=>u(C.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")):v||!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((C,_)=>e.createElement(It,{key:_,block:t,session:r,article:C})),E&&e.createElement("div",{className:"userflowjs-resource-center-list-route-spinner"},e.createElement(P,null))))},It=({block:t,article:n,session:r})=>{const s=R();return e.createElement("a",{className:"userflowjs-resource-center-block userflowjs-resource-center-block--clickable",onClick:()=>{A(s,r,t,n.title)},href:kt(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}})))},qn=({block:t,session:n})=>e.createElement("div",{className:"userflowjs-resource-center-content-route userflowjs-bubble-content"},e.createElement($,{doc:t.content,lookupAttribute:x(n.data)})),Kn=({bodyRef:t,session:n,route:r,navigate:s})=>{const c=R(),a=ie({message:{kind:"ListAnnouncements",beforeAnnouncementId:null},skip:r?.kind!=="announcementList"}),{loading:o,loadingMore:i,data:m,loadMore:u}=a,v=m?.truncated,E=l.useCallback(()=>{u((b,g)=>b.announcements.length>0?{...g,beforeAnnouncementId:b.announcements[b.announcements.length-1].id}:g,(b,g)=>({...g,announcements:[...b.announcements,...g.announcements]}))},[u]);At({bodyRef:t,loading:o,loadingMore:i,truncated:v,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,v]=l.useMemo(()=>{const h=[],f=[];if(i){let b=-1;for(const g of i.announcements)b++,b<i.pageSize&&!g.seen&&g.level!==Y.SILENT?h.push(g):f.push(g)}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:x(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(pt,{key:f,bodyRef:t,onMoreClick:()=>s(h),announcement:h})),u.length>0&&v.length>0&&e.createElement("div",{className:"userflowjs-announcement-seen-divider"}),v.map((h,f)=>e.createElement(pt,{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===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(),ge.has(n.id))){t.send({kind:"MarkAnnouncementSeen",announcementId:n.id,versionId:n.versionId});return}}const pt=({bodyRef:t,onMoreClick:n,announcement:r})=>{const s=R(),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})),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:gt})))))},Zn=({announcementId:t})=>{const n=R(),{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}),o.moreEnabled&&e.createElement($,{doc:o.moreContent,buttons:o.moreButtons})))))},Gn=({block:t,initialUserContent:n,session:r,navigate:s,onChatShow:c})=>{const a=t.assistantFlowId,o=R(),[i,m]=l.useState(null),[u,v]=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 g=!1;return(async()=>{try{const S=le.getItem("assistantConversationId:"+a),[k,C]=await Promise.all([Fn(),o.send({kind:"GetAssistant",assistantFlowId:a,conversationId:S},{handlesRejection:!0,endBatch:!0})]);if(g)return;m(()=>k),v(C)}catch(S){console.error("Resource center assistant route failed to load:",S),h(S.humanMessage||"Sorry, something went wrong. Please try again or contact my human friends.")}})(),()=>{g=!0}},[o,a]);const b=l.useMemo(()=>{if(!t.assistantContactEnabled)return;const g=r.version.resourceCenter?.blocks.find(y=>y.type===j.CONTACT);if(g)return()=>{switch(A(o,r,t,t.assistantContactButtonText||void 0),t.assistantContactMethod){case st.EMAIL:s({kind:"email",block:g});break;case st.PHONE:s({kind:"phone",block:g});break;default:s(null),Rt(r,g,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?Fe(r.name,{lookupAttribute:x(n.data)})+(s?` - ${s}`:""):s},{batch:!0})}function At({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 Rt(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:Et,default:Et},Symbol.toStringTag,{value:"Module"}));export{Mn as A,xn as G,Er as R,kt 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{a0 as _,a1 as y,u as Y}from"./userflow.js";import{u as Ee}from"./client-context.js";import{D as q,E as Q,F as be,G as P,H as $,I as V,J as X,K 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"./flow-host.styl.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";import"./vendor.babel.runtime.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="d3f07ad5-cf33-4846-b834-ba6dc9877a6d",t._sentryDebugIdIdentifier="sentry-dbid-d3f07ad5-cf33-4846-b834-ba6dc9877a6d")}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),b=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&&(b.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,b.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 E=R(v);return{...v,...E}}else return v}))},L=s=>{w(R=>R.map((C,v)=>{if(v===R.length-1){const E=s(C);return{...C,...E}}else return C}))},U=u.useCallback(async s=>{if(s=s.trim(),s==="")return;N(),w(E=>[...E,{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:E=>{if(R){console.log("Userflow.js AssistantChat got message after being done",E);return}switch(E.kind){case"conversation_created":H(E.conversationId);break;case"message_created":L(()=>({id:E.messageId,warning:E.warning}));break;case"assistant_content_delta":L(A=>{const he=E.delta,z=A.assistantContent+he,ge=B(z),pe=x(ge);return{assistantContent:z,assistantHtml:pe}});break;case"done":C(),L(A=>({assistantHtml:x(A.assistantContent,"exit"),completed:!0,sources:E.sources}));break;case"error":C(),L(A=>({failed:!0,error:E.message,assistantHtml:x(B(A.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",E)}}});j.current=()=>{C(),v.abort(),L(E=>({assistantHtml:x(B(E.assistantContent),!1)}))}},[N,K,h,H]),J=u.useRef(!1);u.useEffect(()=>{J.current||(J.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&&(b.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(b=>b.completed||b.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((b,I)=>n.createElement(Le,{key:I,assistant:t,message:b,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:be}))):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{a0 as b,a1 as y,u as Y}from"./userflow.js";import{u as Ee}from"./client-context.js";import{D as q,E as Q,F as _e,G as P,H as $,I as V,J as X,K as Z}from"./vendor.fortawesome.pro-regular-svg-icons.js";import{p as be}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"./flow-host.styl.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"./index.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},e=new Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="366de984-fdc1-4a2d-a749-c7181c92afb2",t._sentryDebugIdIdentifier="sentry-dbid-366de984-fdc1-4a2d-a749-c7181c92afb2")}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),_=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&&(_.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,_.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 E=R(v);return{...v,...E}}else return v}))},L=s=>{w(R=>R.map((C,v)=>{if(v===R.length-1){const E=s(C);return{...C,...E}}else return C}))},U=u.useCallback(async s=>{if(s=s.trim(),s==="")return;N(),w(E=>[...E,{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:E=>{if(R){console.log("Userflow.js AssistantChat got message after being done",E);return}switch(E.kind){case"conversation_created":H(E.conversationId);break;case"message_created":L(()=>({id:E.messageId,warning:E.warning}));break;case"assistant_content_delta":L(A=>{const he=E.delta,z=A.assistantContent+he,ge=B(z),pe=x(ge);return{assistantContent:z,assistantHtml:pe}});break;case"done":C(),L(A=>({assistantHtml:x(A.assistantContent,"exit"),completed:!0,sources:E.sources}));break;case"error":C(),L(A=>({failed:!0,error:E.message,assistantHtml:x(B(A.assistantContent),!1)}));break;default:console.log("Userflow.js AssistantChat got unknown message",E)}}});j.current=()=>{C(),v.abort(),L(E=>({assistantHtml:x(B(E.assistantContent),!1)}))}},[N,K,h,H]),J=u.useRef(!1);u.useEffect(()=>{J.current||(J.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&&(_.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 b.LIKE:O(s.messageId,()=>({rating:s.rating}));break;case b.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(_=>_.completed||_.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((_,I)=>n.createElement(Le,{key:I,assistant:t,message:_,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===b.LIKE||t.ratingMode===b.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:b.LIKE,messageId:o,rating:i})}),m.current?.focus({preventScroll:!0}))},g=i=>{const o=e.id;o&&(ee.flushSync(()=>{a({ratingMode:b.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===b.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===b.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===b.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===b.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:_e}))):n.createElement("div",{className:"userflowjs-assistant-chat__rating-options"},t.ratingMode===b.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}},mt=({block:t,session:e,assistantReply:a,initialUserContent:c,onContactClick:m,contactButtonText:f})=>{const h=t.assistantFlowId,l=Ee(),{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(b=>{S({kind:"error",message:b.humanMessage||r})});const M=()=>{l.assistantMessageInProgress=void 0,l.off("private:assistantMessageEvent",j),l.off("private:disconnect",k)},j=b=>{if(b.ref!==w)return;const{event:I}=b;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{mt 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=be.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=Ee(),{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(_=>{S({kind:"error",message:_.humanMessage||r})});const M=()=>{l.assistantMessageInProgress=void 0,l.off("private:assistantMessageEvent",j),l.off("private:disconnect",k)},j=_=>{if(_.ref!==w)return;const{event:I}=_;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 b.LIKE:l.send({kind:"SubmitAssistantRating",messageId:o.messageId,rating:o.rating});break;case b.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};
5
5
  //# sourceMappingURL=ResourceCenterAssistantChat.js.map
package/hash.txt CHANGED
@@ -1 +1 @@
1
- 935b4d8508cc1f487cc2c7fb0ff557c6f6296d78
1
+ 1878a2064f377b795e67a378012770d48abf4a6c
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import"./vendor.core-js.js";(function(){try{var D=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},E=new Error().stack;E&&(D._sentryDebugIds=D._sentryDebugIds||{},D._sentryDebugIds[E]="a30cb804-98c0-49de-8e8b-6c7f796dfb33",D._sentryDebugIdIdentifier="sentry-dbid-a30cb804-98c0-49de-8e8b-6c7f796dfb33")}catch{}})();var d=(D=>(D.BOTTOM="BOTTOM",D.TOP="TOP",D))(d||{}),O=(D=>(D.CHAINED_ROUNDED="CHAINED_ROUNDED",D.CHAINED_SQUARED="CHAINED_SQUARED",D.DEFAULT="DEFAULT",D.DOTTED="DOTTED",D.NARROW="NARROW",D.NUMBERED="NUMBERED",D))(O||{}),f=(D=>(D.BLOCK="BLOCK",D.HIDE="HIDE",D.OTHERS="OTHERS",D))(f||{});export{O as P,f as R,d as a};
2
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "userflow.js-self-hosted",
3
- "version": "0.1.1010254",
3
+ "version": "0.1.1010263",
4
4
  "description": "Self-hosted version of Userflow.js",
5
5
  "main": "userflow.js"
6
6
  }
package/ui.js CHANGED
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ElementSelectionApp.js","vendor.react.js","vendor.core-js.js","vendor.object-assign.js","vendor.is-hotkey.js","vendor.obj-str.js","roots.js","userflow.js","vendor.phoenix.js","vendor.uuid.js","client-context.js","vendor.i18next.js","vendor.react-i18next.js","vendor.babel.runtime.js","use-window-resize.js","vendor.react-dom.js","vendor.scheduler.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","flow-condition-types.js","vendor.date-fns.js","BuilderBar.js","logomark.js","vendor.fortawesome.pro-light-svg-icons.js","FlowApp.js","vendor.lodash.js","FlowChrome.js","flow-host.styl.js","use-selector-element-monitoring.js","Trigger.js","ChecklistApp.js","ChecklistUI.js","LauncherApp.js","NotificationsApp.js","TrackerTestingApp.js","StartConditionTestingApp.js"])))=>i.map(i=>d[i]);
2
- import{R as e,r as s}from"./vendor.react.js";import{r as b}from"./vendor.react-dom.js";import{u as x,i as z,U as V}from"./client-context.js";import{_ as i,B as U,R as F,U as H}from"./userflow.js";import"./vendor.core-js.js";import{I as B}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";(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]="14d43ba4-c929-4c7b-8da5-b8c51e229156",t._sentryDebugIdIdentifier="sentry-dbid-14d43ba4-c929-4c7b-8da5-b8c51e229156")}catch{}})();const N=e.lazy(()=>i(()=>import("./ElementSelectionApp.js"),__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]))),j=e.lazy(()=>i(()=>import("./FlowApp.js"),__vite__mapDeps([25,1,2,3,7,8,9,26,12,13,27,18,17,19,20,21,6,10,11,14,15,16,28,29,5,23,30]))),q=e.lazy(()=>i(()=>import("./ChecklistApp.js"),__vite__mapDeps([31,1,2,3,7,8,9,27,18,17,19,20,21,6,10,11,12,13,14,15,16,28,29,5,23,32]))),G=e.lazy(U),J=e.lazy(F),K=e.lazy(()=>i(()=>import("./LauncherApp.js"),__vite__mapDeps([33,1,2,3,7,8,9,29,20,21,6,17,18,19,10,11,12,13,5,28,27,14,15,16,23,30]))),M=e.lazy(()=>i(()=>import("./NotificationsApp.js"),__vite__mapDeps([34,1,2,3,10,11,12,13,28,7,8,9,17,18,19,20,21,6]))),Q=e.lazy(()=>i(()=>import("./TrackerTestingApp.js"),__vite__mapDeps([35,1,2,3,10,11,12,13,22,14,15,16,17,18,19,7,8,9,20,21,6,23,5,24]))),W=e.lazy(()=>i(()=>import("./StartConditionTestingApp.js"),__vite__mapDeps([36,1,2,3,10,11,12,13,22,14,15,16,17,18,19,7,8,9,20,21,6,23,5,24]))),X=()=>{const t=x(),[n,d]=s.useState(t.getSessionStorageState()),[c,p]=s.useState(()=>u()?null:t.flowSession),[o,C]=s.useState(t.checklistSession),[m,k]=s.useState(t.checklistExpanded),[a,y]=s.useState(t.bannerSession),[l,v]=s.useState(t.resourceCenterSession),[S,g]=s.useState(t.resourceCenterOpen),[w,A]=s.useState(t.resourceCenterLauncherHidden),[f,I]=s.useState(t.resourceCenterEmbedsChecklist()),[L,R]=s.useState(t.launcherSessions),[T,D]=s.useState(t.activeLauncherFlowId),[E,O]=s.useState(t.notifications);s.useEffect(()=>{const r=()=>{d(t.getSessionStorageState()),p(P=>u()&&t.flowSession?.id!==P?.id?null:t.flowSession),C(t.checklistSession),k(t.checklistExpanded),y(t.bannerSession),v(t.resourceCenterSession),g(t.resourceCenterOpen),A(t.resourceCenterLauncherHidden),I(t.resourceCenterEmbedsChecklist()),R(t.launcherSessions),D(t.activeLauncherFlowId),O(t.notifications)};t.on("uistatechange",r);const _=()=>{u()||p(t.flowSession)};return document.addEventListener("visibilitychange",_),()=>{t.off("uistatechange",r),document.removeEventListener("visibilitychange",_)}},[t]);const h=!n.activeApp&&!!c;return s.useLayoutEffect(()=>{if(h)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}},[t,h]),n.activeApp==="elementSelection"&&n.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(N,{state:n.elementSelection})):n.activeApp==="trackerTesting"&&n.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(Q,{state:n.trackerTesting})):e.createElement(e.Fragment,null,c&&e.createElement(e.Suspense,{fallback:null},e.createElement(j,{key:c.id,session:c,checklistSession:o,resourceCenterEmbedsChecklist:f})),o&&!f&&(m||o.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(q,{key:o.id,session:o,checklistExpanded:m})),a&&e.createElement(e.Suspense,{fallback:null},e.createElement(G,{key:a.id,session:a})),l&&(S||!w)&&e.createElement(e.Suspense,{fallback:null},e.createElement(J,{key:l.id,session:l,isOpen:S,flowSession:c,checklistSession:o})),e.createElement(e.Suspense,{fallback:null},L.map(r=>e.createElement(K,{key:r.flow.id,session:r,active:r.flow.id===T}))),E.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(M,{notifications:E})),n.activeApp==="startConditionTesting"&&n.testStartConditionToken&&e.createElement(e.Suspense,{fallback:null},e.createElement(W,{token:n.testStartConditionToken})))};function u(){return document.visibilityState==="hidden"}const Y=({client:t})=>e.createElement(B,{i18n:z},e.createElement(V.Provider,{value:t},e.createElement(X,null)));class ue{constructor(n){this.client=n}mount(){if(this.container)throw new H("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),b.render(e.createElement(Y,{client:this.client}),this.container)}unmount(){this.container&&(b.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{ue as RealUI};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["ElementSelectionApp.js","vendor.react.js","vendor.core-js.js","vendor.object-assign.js","vendor.is-hotkey.js","vendor.obj-str.js","roots.js","userflow.js","vendor.phoenix.js","vendor.uuid.js","client-context.js","vendor.i18next.js","vendor.react-i18next.js","vendor.babel.runtime.js","use-window-resize.js","vendor.react-dom.js","vendor.scheduler.js","stylesheets.js","vendor.fortawesome.pro-regular-svg-icons.js","vendor.fortawesome.pro-solid-svg-icons.js","flow-condition-types.js","vendor.date-fns.js","BuilderBar.js","logomark.js","vendor.fortawesome.pro-light-svg-icons.js","FlowApp.js","index.js","vendor.lodash.js","FlowChrome.js","flow-host.styl.js","use-selector-element-monitoring.js","Trigger.js","ChecklistApp.js","ChecklistUI.js","LauncherApp.js","NotificationsApp.js","TrackerTestingApp.js","StartConditionTestingApp.js"])))=>i.map(i=>d[i]);
2
+ import{R as e,r as s}from"./vendor.react.js";import{r as b}from"./vendor.react-dom.js";import{u as x,i as z,U as V}from"./client-context.js";import{_ as i,B as U,R as F,U as H}from"./userflow.js";import"./vendor.core-js.js";import{I as B}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";(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]="14d43ba4-c929-4c7b-8da5-b8c51e229156",t._sentryDebugIdIdentifier="sentry-dbid-14d43ba4-c929-4c7b-8da5-b8c51e229156")}catch{}})();const N=e.lazy(()=>i(()=>import("./ElementSelectionApp.js"),__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]))),j=e.lazy(()=>i(()=>import("./FlowApp.js"),__vite__mapDeps([25,1,2,3,7,8,9,26,27,12,13,28,18,17,19,20,21,6,10,11,14,15,16,29,30,5,23,31]))),q=e.lazy(()=>i(()=>import("./ChecklistApp.js"),__vite__mapDeps([32,1,2,3,7,8,9,28,18,17,19,20,21,6,10,11,12,13,14,15,16,29,30,5,23,33]))),G=e.lazy(U),J=e.lazy(F),K=e.lazy(()=>i(()=>import("./LauncherApp.js"),__vite__mapDeps([34,1,2,3,7,8,9,30,20,21,6,17,18,19,10,11,12,13,5,29,28,14,15,16,23,31]))),M=e.lazy(()=>i(()=>import("./NotificationsApp.js"),__vite__mapDeps([35,1,2,3,10,11,12,13,29,7,8,9,17,18,19,20,21,6]))),Q=e.lazy(()=>i(()=>import("./TrackerTestingApp.js"),__vite__mapDeps([36,1,2,3,10,11,12,13,22,14,15,16,17,18,19,7,8,9,20,21,6,23,5,24]))),W=e.lazy(()=>i(()=>import("./StartConditionTestingApp.js"),__vite__mapDeps([37,1,2,3,10,11,12,13,22,14,15,16,17,18,19,7,8,9,20,21,6,23,5,24]))),X=()=>{const t=x(),[n,d]=s.useState(t.getSessionStorageState()),[c,p]=s.useState(()=>u()?null:t.flowSession),[o,C]=s.useState(t.checklistSession),[m,k]=s.useState(t.checklistExpanded),[a,y]=s.useState(t.bannerSession),[l,v]=s.useState(t.resourceCenterSession),[S,g]=s.useState(t.resourceCenterOpen),[w,A]=s.useState(t.resourceCenterLauncherHidden),[f,I]=s.useState(t.resourceCenterEmbedsChecklist()),[L,R]=s.useState(t.launcherSessions),[T,D]=s.useState(t.activeLauncherFlowId),[E,O]=s.useState(t.notifications);s.useEffect(()=>{const r=()=>{d(t.getSessionStorageState()),p(P=>u()&&t.flowSession?.id!==P?.id?null:t.flowSession),C(t.checklistSession),k(t.checklistExpanded),y(t.bannerSession),v(t.resourceCenterSession),g(t.resourceCenterOpen),A(t.resourceCenterLauncherHidden),I(t.resourceCenterEmbedsChecklist()),R(t.launcherSessions),D(t.activeLauncherFlowId),O(t.notifications)};t.on("uistatechange",r);const _=()=>{u()||p(t.flowSession)};return document.addEventListener("visibilitychange",_),()=>{t.off("uistatechange",r),document.removeEventListener("visibilitychange",_)}},[t]);const h=!n.activeApp&&!!c;return s.useLayoutEffect(()=>{if(h)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}},[t,h]),n.activeApp==="elementSelection"&&n.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(N,{state:n.elementSelection})):n.activeApp==="trackerTesting"&&n.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(Q,{state:n.trackerTesting})):e.createElement(e.Fragment,null,c&&e.createElement(e.Suspense,{fallback:null},e.createElement(j,{key:c.id,session:c,checklistSession:o,resourceCenterEmbedsChecklist:f})),o&&!f&&(m||o.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(q,{key:o.id,session:o,checklistExpanded:m})),a&&e.createElement(e.Suspense,{fallback:null},e.createElement(G,{key:a.id,session:a})),l&&(S||!w)&&e.createElement(e.Suspense,{fallback:null},e.createElement(J,{key:l.id,session:l,isOpen:S,flowSession:c,checklistSession:o})),e.createElement(e.Suspense,{fallback:null},L.map(r=>e.createElement(K,{key:r.flow.id,session:r,active:r.flow.id===T}))),E.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(M,{notifications:E})),n.activeApp==="startConditionTesting"&&n.testStartConditionToken&&e.createElement(e.Suspense,{fallback:null},e.createElement(W,{token:n.testStartConditionToken})))};function u(){return document.visibilityState==="hidden"}const Y=({client:t})=>e.createElement(B,{i18n:z},e.createElement(V.Provider,{value:t},e.createElement(X,null)));class ue{constructor(n){this.client=n}mount(){if(this.container)throw new H("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),b.render(e.createElement(Y,{client:this.client}),this.container)}unmount(){this.container&&(b.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{ue as RealUI};
3
3
  //# sourceMappingURL=ui.js.map
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.react-i18next.js","vendor.babel.runtime.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","use-window-resize.js","vendor.react-dom.js","vendor.scheduler.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","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.react-i18next.js","vendor.babel.runtime.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","use-window-resize.js","vendor.react-dom.js","vendor.scheduler.js","logomark.js","ChecklistUI.js","FlowChrome.js","use-element-rect.js","vendor.bignumber.js.js","index.js","BannerApp.js","vendor.phoenix.js","vendor.uuid.js","implicit-tracking.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 p}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]="6505a18c-c046-491a-86a6-1519823a2aa8",t._sentryDebugIdIdentifier="sentry-dbid-6505a18c-c046-491a-86a6-1519823a2aa8")}catch{}})();const z="modulepreload",Y=function(t){return"https://js.userflow.com/es2020/"+t},_={},T=function(e,s,i){let n=Promise.resolve();if(s&&s.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),u=a?.nonce||a?.getAttribute("nonce");n=Promise.allSettled(s.map(c=>{if(c=Y(c),c in _)return;_[c]=!0;const h=c.endsWith(".css"),g=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${g}`))return;const E=document.createElement("link");if(E.rel=h?"stylesheet":z,h||(E.as="script"),E.crossOrigin="",E.href=c,u&&E.setAttribute("nonce",u),document.head.appendChild(E),h)return new Promise((V,K)=>{E.addEventListener("load",V),E.addEventListener("error",()=>K(new Error(`Unable to preload CSS for ${c}`)))})}))}function r(a){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=a,window.dispatchEvent(u),!u.defaultPrevented)throw a}return n.then(a=>{for(const u of a||[])u.status==="rejected"&&r(u.reason);return e().catch(r)})};class l extends Error{constructor(e,s,i){super(e),Object.setPrototypeOf(this,l.prototype),this.name="UserflowError",this.code=s,this.humanMessage=i}}class P{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 w=new P("localStorage"),f=new P("sessionStorage");function ze(t){window.location.href=t}function x(){return window.location.href}function L(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 N=new Set;let R=!1;function X(t){return Q(),N.add(t),()=>{G(t)}}function G(t){N.delete(t)}function I(){N.forEach(t=>t())}function Q(){if(R)return;R=!0;const{history:t}=window,e=s=>{const i=t[s];t[s]=(...n)=>{const r=i.apply(t,n);return I(),r}};window.__userflowStatePatched?(window.addEventListener("userflow:pushstate",()=>{I()}),window.addEventListener("userflow:replacestate",()=>{I()})):(e("pushState"),e("replaceState")),window.addEventListener("popstate",()=>{I()})}class Z{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){L({kind:"userflow:crxSendProxyMessage",direction:"targetToBuilder",message:e})}onBuilderMessage(e){return this.unregisterOnMessage=H(e),!1}async captureScreenshot(e,s,i,n){return L({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 k=(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))(k||{}),m=(t=>(t.ACTION="ACTION",t.DRAFT="DRAFT",t.LINK="LINK",t.LAUNCHER_SEEN="LAUNCHER_SEEN",t.RESOURCE_CENTER="RESOURCE_CENTER",t.USERFLOWJS="USERFLOWJS",t))(m||{}),q=(t=>(t.LIKE="LIKE",t.DISLIKE="DISLIKE",t))(q||{}),S=(t=>(t.STRING="STRING",t.BOOLEAN="BOOLEAN",t.NUMBER="NUMBER",t.DATETIME="DATETIME",t.LIST="LIST",t.RANDOM_AB="RANDOM_AB",t.RANDOM_NUMBER="RANDOM_NUMBER",t))(S||{}),C=(t=>(t.FLOW="FLOW",t.BANNER="BANNER",t.CHECKLIST="CHECKLIST",t.LAUNCHER="LAUNCHER",t.RESOURCE_CENTER="RESOURCE_CENTER",t))(C||{}),ee=(t=>(t.ALWAYS_TRUE="ALWAYS_TRUE",t.ATTRIBUTE="ATTRIBUTE",t.CLAUSE="CLAUSE",t.ELEMENT="ELEMENT",t.FILLED_IN_INPUT="FILLED_IN_INPUT",t.FLOW="FLOW",t.INPUT_VALUE="INPUT_VALUE",t.PAGE="PAGE",t.SEGMENT="SEGMENT",t.TIME="TIME",t))(ee||{}),te=(t=>(t.AUTO="AUTO",t.MANUAL="MANUAL",t))(te||{}),se=(t=>(t.INPUT="INPUT",t))(se||{}),ie=(t=>(t.ABSOLUTE_EQ="ABSOLUTE_EQ",t.ABSOLUTE_GT="ABSOLUTE_GT",t.ABSOLUTE_LT="ABSOLUTE_LT",t.AND="AND",t.BETWEEN="BETWEEN",t.CONTAINS="CONTAINS",t.EMPTY="EMPTY",t.ENDS_WITH="ENDS_WITH",t.EQ="EQ",t.EXCLUDES_ALL="EXCLUDES_ALL",t.EXCLUDES_ANY="EXCLUDES_ANY",t.FALSE="FALSE",t.GT="GT",t.GTE="GTE",t.INCLUDES_ALL="INCLUDES_ALL",t.INCLUDES_ANY="INCLUDES_ANY",t.LT="LT",t.LTE="LTE",t.NE="NE",t.NOT_CONTAINS="NOT_CONTAINS",t.NOT_EMPTY="NOT_EMPTY",t.NOT_REGEX="NOT_REGEX",t.OR="OR",t.REGEX="REGEX",t.RELATIVE_EQ="RELATIVE_EQ",t.RELATIVE_GT="RELATIVE_GT",t.RELATIVE_LT="RELATIVE_LT",t.STARTS_WITH="STARTS_WITH",t.TRUE="TRUE",t.URL="URL",t))(ie||{}),ne=(t=>(t.CLICK="CLICK",t.DISABLED="DISABLED",t.MOUSEDOWN="MOUSEDOWN",t.NOT_CLICK="NOT_CLICK",t.NOT_DISABLED="NOT_DISABLED",t.NOT_PRESENT="NOT_PRESENT",t.PRESENT="PRESENT",t))(ne||{}),re=(t=>(t.ASSET="ASSET",t.CARTOON="CARTOON",t.NONE="NONE",t.URL="URL",t))(re||{}),oe=(t=>(t.INSIDE="INSIDE",t.OUTSIDE="OUTSIDE",t))(oe||{}),ae=(t=>(t.TOP_LEFT="TOP_LEFT",t.TOP_CENTER="TOP_CENTER",t.TOP_RIGHT="TOP_RIGHT",t.BOTTOM_RIGHT="BOTTOM_RIGHT",t.BOTTOM_CENTER="BOTTOM_CENTER",t.BOTTOM_LEFT="BOTTOM_LEFT",t.CENTER="CENTER",t))(ae||{}),ce=(t=>(t.GOOGLE="GOOGLE",t.STANDARD="STANDARD",t))(ce||{}),le=(t=>(t.DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",t.DISMISS="DISMISS",t))(le||{}),ue=(t=>(t.DISMISS="DISMISS",t.NONE="NONE",t))(ue||{}),he=(t=>(t.TOP="TOP",t.BOTTOM="BOTTOM",t))(he||{}),de=(t=>(t.DEFAULT="DEFAULT",t.PLAINTEXT="PLAINTEXT",t.CUSTOM="CUSTOM",t))(de||{}),fe=(t=>(t.CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",t.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",t.NONE="NONE",t))(fe||{}),Ee=(t=>(t.BUBBLE="BUBBLE",t.END="END",t.ERROR="ERROR",t.FLAG="FLAG",t))(Ee||{}),Se=(t=>(t.MANUAL="MANUAL",t.NONE="NONE",t.SYNTHETIC="SYNTHETIC",t))(Se||{}),Te=(t=>(t.BUBBLE="BUBBLE",t.HIDDEN="HIDDEN",t.MODAL="MODAL",t.TOOLTIP="TOOLTIP",t))(Te||{}),ge=(t=>(t.ABOVE="ABOVE",t.BELOW="BELOW",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(ge||{}),we=(t=>(t.CLOSE_FLOW="CLOSE_FLOW",t.EVAL_JS="EVAL_JS",t.GO_TO_STEP="GO_TO_STEP",t.NAVIGATE="NAVIGATE",t.SET_ATTRIBUTE="SET_ATTRIBUTE",t.SNOOZE="SNOOZE",t.START_FLOW="START_FLOW",t))(we||{}),Ie=(t=>(t.NEW_TAB="NEW_TAB",t.SAME_TAB="SAME_TAB",t))(Ie||{}),ke=(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))(ke||{}),Ce=(t=>(t.MULTILINE_TEXT="MULTILINE_TEXT",t.MULTIPLE_CHOICE="MULTIPLE_CHOICE",t.NPS="NPS",t.SCALE="SCALE",t.STARS="STARS",t.TEXT="TEXT",t))(Ce||{}),A=(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))(A||{}),me=(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))(me||{}),pe=(t=>(t.BUTTON="BUTTON",t.INPUT="INPUT",t))(pe||{}),Ue=(t=>(t.EMAIL="EMAIL",t.PHONE="PHONE",t.CHAT="CHAT",t))(Ue||{}),Le=(t=>(t.SILENT="SILENT",t.BADGE="BADGE",t.POPOUT="POPOUT",t.MODAL="MODAL",t.TOAST="TOAST",t))(Le||{}),Ae=(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))(Ae||{}),W=(t=>(t.ACTIVATE="ACTIVATE",t.DEACTIVATE="DEACTIVATE",t.NEVER="NEVER",t))(W||{}),Ne=(t=>(t.AUTO="AUTO",t.TOP="TOP",t.RIGHT="RIGHT",t.BOTTOM="BOTTOM",t.LEFT="LEFT",t))(Ne||{}),ve=(t=>(t.START="START",t.CENTER="CENTER",t.END="END",t))(ve||{}),_e=(t=>(t.PERCENT="PERCENT",t.PX="PX",t))(_e||{}),Re=(t=>(t.BEACON="BEACON",t.BUTTON="BUTTON",t.HIDDEN="HIDDEN",t.ICON="ICON",t))(Re||{}),Oe=(t=>(t.LAUNCHER="LAUNCHER",t.TARGET="TARGET",t))(Oe||{}),ye=(t=>(t.BODY_FIRST="BODY_FIRST",t.BODY_LAST="BODY_LAST",t.ELEMENT_FIRST="ELEMENT_FIRST",t.ELEMENT_LAST="ELEMENT_LAST",t.ELEMENT_BEFORE="ELEMENT_BEFORE",t.ELEMENT_AFTER="ELEMENT_AFTER",t))(ye||{}),be=(t=>(t.NONE="NONE",t.LIKE="LIKE",t.SCALE="SCALE",t))(be||{});function De(){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=De();function O(t){return Array.isArray(t)||(t=t?[t]:[]),t=t.map(e=>typeof e=="string"?new RegExp(e):e),t}function Ye(t,e){return t.every(s=>typeof s=="function"?s(e):s instanceof RegExp?s.test(e):!0)}function Me(){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 $="";try{$=localStorage.getItem("debug")||""}catch{}const F=$.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=v("log");o.group=v("group");o.groupCollapsed=v("groupCollapsed");o.groupEnd=function(){F&&console.groupEnd()};let U;function v(t){return function(e,...s){if(F){const i=performance.now(),n=U?Math.round(i-U):0;U=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const Be=()=>T(()=>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]));function Pe(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class y{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const b=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],xe=()=>T(()=>import("./BannerApp.js"),__vite__mapDeps([25,1,2,3,4,5,6,7,16,13,14,15,10,11,12,9,8,18,19,17,23,26,27])),D="1010254",He=import.meta.url,M=50,Ge=5*60*1e3,B="userflowClientState";class We{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.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.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="+D),X(this.onUrlChange),this.setTargetEnv(new Z),this.checkTestUserAtBoot(),this.toggleUI();for(const e of b)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),G(this.onUrlChange),this.destroyTargetEnv();for(const e of b)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(B,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(B);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(He).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 $="";try{$=localStorage.getItem("debug")||""}catch{}const F=$.split(",").some(t=>t==="*"||t.startsWith("userflow:*")),o=v("log");o.group=v("group");o.groupCollapsed=v("groupCollapsed");o.groupEnd=function(){F&&console.groupEnd()};let U;function v(t){return function(e,...s){if(F){const i=performance.now(),n=U?Math.round(i-U):0;U=i,console[t](`%cuserflow %c${e} %c+${n}ms`,"color:#1a57e6;","","color:#1a57e6;",...s)}}}const Be=()=>T(()=>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 Pe(t){const s=t.version.checklist.tasks.length;return Math.max(0,s-t.taskCompletions.length)}class y{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const s of this.observers)s()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const b=["page:before-change","page:change","turbo:before-cache","turbo:load","turbo:visit","turbolinks:before-cache","turbolinks:load","turbolinks:visit"],xe=()=>T(()=>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,23,27,28])),D="1010263",He=import.meta.url,M=50,Ge=5*60*1e3,B="userflowClientState";class We{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.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.refCounter=1,this.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="+D),X(this.onUrlChange),this.setTargetEnv(new Z),this.checkTestUserAtBoot(),this.toggleUI();for(const e of b)document.addEventListener(e,this.remountIfNecessary)}get socketStatus(){return this._socketStatus}destroy(){o("destroy"),this.reset(),G(this.onUrlChange),this.destroyTargetEnv();for(const e of b)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(B,JSON.stringify(s)),this.sessionStorageState=s,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=f.getItem(B);if(s)try{e=JSON.parse(s)}catch(i){console.error("Userflow.js: Parse ElementSelectionState error:",i)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null}),this.sessionStorageState=e}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(o("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState(n=>({...n,testUser:e})),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const s=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:new Date().toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:i}=e;i&&(this.groupId=i.id,s.push(this.group(i.id,{name:i.name},{signature:i.signature}))),await Promise.all(s)}resetTestUser(){this.setSessionStorageState(e=>({...e,testUser:null}))}init(e){if(o("init",e),!e)throw new l("userflow.init() was called but missing Userflow.js Token");if(this.clientToken!==e){if(this.testUserIdentified){o("init() ignoring new token since a test user has been identified");return}this.clientToken&&(o("init() resetting due to new client token"),this.reset()),this.clientToken=e}}ensureInit(){if(!this.clientToken)throw new l("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new l("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new l("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId||(this.debounceInactiveDisconnect(),this.socket))return;this._socketStatus="connecting",o("connecting to socket");let e=d.serverEndpoint||"e.userflow.com";new URL(He).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 T(()=>import("./implicit-tracking.js"),__vite__mapDeps([28,12,2,27,26])).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:D,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()},Ge)}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 T(()=>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:D,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()},Ge)}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",u)},u=this.channel.on("phx_error",c=>{a();const h=`Userflow.js send ${e.kind} got phx_error`;this._socketStatus==="connected"&&console.log(h,`
8
8
  Client message:`,e,`
9
9
  Error:`,c),s&&n(new l(h))});this.channel.push("client_message",e).receive("ok",c=>{a(),i(c)}).receive("error",c=>{a();const h=`Userflow.js error reply (${c.code}): ${c.message}`;console.log(h,`
@@ -14,5 +14,5 @@ Error:`,c),s&&n(new l(h,c.code,c.message))})})}endBatch(){this.inBatch=!1,this.s
14
14
  - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.
15
15
  - The user legitimately being very active, in which case you can just ignore this error.
16
16
 
17
- If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:u,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:h}=e,g=this.launcherSessions.findIndex(E=>E.flow.id===h.flow.id);g===-1?this.launcherSessions=[...this.launcherSessions,h]:this.launcherSessions=[...this.launcherSessions.slice(0,g),h,...this.launcherSessions.slice(g+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const h=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,h)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":u?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!w.isSupported())throw new l("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=w.getItem(i);n||(n="anon-"+p(),w.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:p(),page_title:document.title,...this.buildClientContext()}),this.featureFlagEnabled("cff_implicit_events")===!0&&this.trackRawEvent({name:"page_viewed",attributes:{id:p(),page_title:document.title}})}buildClientContext(){return{pageUrl:Me(),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,w.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:k.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const u={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(u,{batch:r})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===A.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Pe(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===A.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:u}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,u),this.checklistSession?.id===e.id&&this.setChecklistSession(null,u),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===C.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===C.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===C.CHECKLIST&&this.endFlow(e,{endReason:k.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:k.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=T(()=>import("./ui.js"),__vite__mapDeps([29,1,2,3,18,19,4,5,6,7,26,27]));this.bannerSession&&xe(),this.resourceCenterSession&&Be();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 T(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([10,2,11,12])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new y([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await T(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(h=>h.f);return{conditionTypes:c}},__vite__mapDeps([10,2,11,12])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,u=i[a.type];n.untrack&&n.untrack(),n.untrack=u.track({sessionData:new y(r.data),condition:a,flipBackEvents:!0,callback:c=>{const h=n.isTrue;n.isTrue=c,!h&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),L({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||{},$e());window.userflow=t,window.studio1=t,Fe()}function $e(){const t=new We;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]=O(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=O(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},_getInitToken(){return t.getInitToken()},_getIdentifiedUser(){return t.getIdentifiedUser()}}}function Fe(){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 Je=window.userflow;export{b as $,Le as A,xe as B,me as C,ze as D,k as E,te as F,x as G,Ie as H,ke as I,y as J,ce as K,Re as L,ue as M,ie as N,ee as O,he as P,Me as Q,Be as R,m as S,Ee as T,l as U,Se as V,X as W,G as X,ne as Y,Ye as Z,T as _,A as a,be as a0,q as a1,fe as b,d as c,o as d,Je as default,de as e,Te as f,Pe as g,we as h,pe as i,C as j,Ue as k,ye as l,se as m,le as n,w as o,Ce as p,re as q,ae as r,Ae as s,Ne as t,f as u,Oe as v,ve as w,_e as x,ge as y,oe as z};
17
+ If in doubt, reach out to us at support@userflow.com.`);this.pushRateLimitMinute++}handleServerMessage(e){o(`received ${e.kind} message`,e);const{serverClock:s,flowSession:i,flowSessionClock:n,checklistSession:r,checklistSessionClock:a,bannerSession:u,resourceCenterSession:c}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:h}=e,g=this.launcherSessions.findIndex(E=>E.flow.id===h.flow.id);g===-1?this.launcherSessions=[...this.launcherSessions,h]:this.launcherSessions=[...this.launcherSessions.slice(0,g),h,...this.launcherSessions.slice(g+1)],this.toggleUI();return}case"AddTracker":{this.addTracker(e.tracker);return}case"AssistantMessageEventWrapper":{this.emit("private:assistantMessageEvent",e);return}case"CancelConditionWaitTimer":window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),this.conditionWaitTimers.delete(e.conditionId);return;case"ChecklistTaskCompleted":this.unackedTasks.add(e.taskCvid);return;case"ForceGoToStep":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&this.emit("gotostep",{session:i,step:{id:e.stepId}});return;case"RemoveLauncher":this.removeLauncher(e.flowId)&&this.toggleUI();return;case"RemoveTracker":{this.removeTracker(e.flowId);return}case"SetBannerSession":this.setBannerSession(e.session),this.toggleUI();return;case"SetChecklistSession":a<=s||r?.id===e.session.id?(this.setChecklistSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return;case"SetFlowSession":n<=s||i?.id===e.session.id?(this.setFlowSession(e.session,s),this.toggleUI()):o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return;case"SetResourceCenterSession":this.setResourceCenterSession(e.session),this.toggleUI();return;case"StartConditionWaitTimer":{if(!this.conditionWaitTimers.has(e.conditionId)){const h=window.setTimeout(()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})},parseFloat(e.waitTime)*1e3);this.conditionWaitTimers.set(e.conditionId,h)}return}case"TestStartConditionSuccess":this.emit("private:testStartConditionSuccess");return;case"TrackClientCondition":this.trackClientCondition(e.condition);return;case"UnsetBannerSession":u?.id===e.sessionId&&(this.setBannerSession(null),this.toggleUI());return;case"UnsetChecklistSession":if(a>s){o(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${a} > serverClock=${s}`);return}r?.id===e.sessionId&&(this.setChecklistSession(null,s),this.toggleUI());return;case"UnsetFlowSession":if(n>s){o(`ignoring ${e.kind} message due to stale clock flowSessionClock=${n} > serverClock=${s}`);return}i?.id===e.sessionId&&(this.setFlowSession(null,s),this.toggleUI());return;case"UnsetResourceCenterSession":c?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI());return;case"UntrackClientCondition":this.untrackClientCondition(e.conditionId);return;default:console.warn("Userflow.js: Received unknown message",e);return}}async identify(e,s={},{signature:i}={}){if(o("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId){o("identify() ignored since a test user has been identified");return}if(typeof e=="number")e=String(e);else if(!e||typeof e!="string")throw new l(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(o("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=i||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(s)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}async identifyAnonymous(e={},s={}){if(!w.isSupported())throw new l("userflow.identifyAnonymous() is not supported when localStorage access is denied.");const i="anonymousId";let n=w.getItem(i);n||(n="anon-"+p(),w.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:p(),page_title:document.title,...this.buildClientContext()}),this.featureFlagEnabled("cff_implicit_events")===!0&&this.trackRawEvent({name:"page_viewed",attributes:{id:p(),page_title:document.title}})}buildClientContext(){return{pageUrl:Me(),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,w.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:k.REPLACED,batch:!0}),o(`startFlow ${e}`,{startReason:i}),this.checklistSession?.flow.id===e){o("startFlow matches current checklist, so showing it instead"),this.showChecklist();return}const u={kind:"StartFlow",flowId:e,stepCvid:s,startReason:i,once:!!n};await this.send(u,{batch:r})}async startFlowWithToken(e){this.ensureIdentified(),o("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){if(this.resourceCenterEmbedsChecklist()){this.openResourceCenter();return}this.unmarkExpandPending(),!(!this.checklistSession||this.checklistExpanded)&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),f.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async hideChecklist(){if(this.resourceCenterEmbedsChecklist()){this.closeResourceCenter();return}!this.checklistSession||!this.checklistExpanded||(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),f.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){!this.checklistSession||!this.checklistExpandPending||(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),!(!this.resourceCenterSession||this.resourceCenterOpen)&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),f.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){!this.resourceCenterSession||!this.resourceCenterOpen||(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),f.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:s}=this,i=this.resourceCenterSession.version.resourceCenter?.blocks.find(n=>n.type===A.ANNOUNCEMENTS);return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&s?Pe(s):0,unreadAnnouncementCount:i?.unreadAnnouncementCount||0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some(s=>s.type===A.CHECKLIST)}async endFlow(e,{endReason:s,batch:i}){this.ensureIdentified(),this.optimisticClockUIUpdate(()=>{const{clientClock:u}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,u),this.checklistSession?.id===e.id&&this.setChecklistSession(null,u),this.bannerSession?.id===e.id&&this.setBannerSession(null),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)});const{flow:n}=e,r={id:n.id,type:n.type.toLowerCase()};n.type===C.CHECKLIST?this.emit("checklistEnded",{checklist:r,endReason:s}):n.type===C.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===C.CHECKLIST&&this.endFlow(e,{endReason:k.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:k.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:s}){const i=e.flow.id;this.removeLauncher(i),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:i,endReason:s})}removeLauncher(e){const s=this.launcherSessions.findIndex(i=>i.flow.id===e);return s===-1?!1:(this.launcherSessions=[...this.launcherSessions.slice(0,s),...this.launcherSessions.slice(s+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){const e=this.getSessionStorageState();!this.flowSession&&(this.checklistExpandPending||this.checklistSession?.version.checklist?.tasks.some(s=>this.taskIsUnacked(s.cvid)))&&this.showChecklist(),e.isTargetTab&&this.monitorTitle(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){return this.uiDisabled?!1:!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.bannerSession||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(o("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(o("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=T(()=>import("./ui.js"),__vite__mapDeps([30,1,2,3,18,19,4,5,6,7,27,28]));this.bannerSession&&xe(),this.resourceCenterSession&&Be();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 T(async()=>{const{conditionTypes:r}=await import("./flow-condition-types.js").then(a=>a.f);return{conditionTypes:r}},__vite__mapDeps([10,2,11,12])),i=s[e.type],n=this.clientConditions.get(e.id);n&&(n.untrack=i.track({sessionData:new y([]),condition:e,callback:r=>{n.isTrue!==r&&(o("client condition truthiness changed",r,n.condition),n.isTrue=r,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:r},{batch:!0}))}}))}untrackClientCondition(e){const s=this.clientConditions.get(e);s&&(o("untrack client condition",s.condition),s.untrack&&s.untrack(),this.clientConditions.delete(e))}async addTracker(e){let s=this.trackers.get(e.flowId);s?s.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:i}=await T(async()=>{const{conditionTypes:c}=await import("./flow-condition-types.js").then(h=>h.f);return{conditionTypes:c}},__vite__mapDeps([10,2,11,12])),n=this.trackers.get(e.flowId);if(!n)return;const{tracker:r}=n,{condition:a}=r,u=i[a.type];n.untrack&&n.untrack(),n.untrack=u.track({sessionData:new y(r.data),condition:a,flipBackEvents:!0,callback:c=>{const h=n.isTrue;n.isTrue=c,!h&&c&&this.send({kind:"TrackTrackerEvent",token:r.token},{batch:!0})},description:`event tracker ${r.flowId}`}),this.emit("private:trackerStarted")}removeTracker(e){const s=this.trackers.get(e);s&&(s.untrack&&s.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}monitorTitle(){if(this.titleMonitored)return;this.titleMonitored=!0,this.fixTitle();const e=document.querySelector("title");if(e){const s=new MutationObserver(()=>{this.fixTitle()});s.observe(e,{childList:!0}),this.titleObserver=s}}fixTitle(){const e=document.title,i="[Userflow Preview] "+e.replace(/\[Userflow Preview\] /,"");e!==i&&(document.title=i)}reportCspIssue(){const e=this.getSessionStorageState();(this.testUserIdentified||e.activeApp)&&!this.cspIssueReported&&(this.cspIssueReported=!0,o("csp issue detected"),L({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||{},$e());window.userflow=t,window.studio1=t,Fe()}function $e(){const t=new We;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]=O(s)},setInferenceClassNameFilter(e){d.inferenceClassNameFilters=O(e)},setScrollPadding(e){d.scrollPadding=e},setCustomScrollIntoView(e){d.customScrollIntoView=e},prepareAudio(){t.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(e){t.pageTrackingDisabled=e},setBaseZIndex(e){d.baseZIndex=e},setServerEndpoint(e){d.serverEndpoint=e},disableEvalJs(){d.evalJsDisabled=!0},_setTargetEnv(e){t.setTargetEnv(e)},_getInitToken(){return t.getInitToken()},_getIdentifiedUser(){return t.getIdentifiedUser()}}}function Fe(){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 Je=window.userflow;export{b as $,Le as A,xe as B,me as C,ze as D,k as E,te as F,x as G,Ie as H,ke as I,y as J,ce as K,Re as L,ue as M,ie as N,ee as O,he as P,Me as Q,Be as R,m as S,Ee as T,l as U,Se as V,X as W,G as X,ne as Y,Ye as Z,T as _,A as a,be as a0,q as a1,fe as b,d as c,o as d,Je as default,de as e,Te as f,Pe as g,we as h,pe as i,C as j,Ue as k,ye as l,se as m,le as n,w as o,Ce as p,re as q,ae as r,Ae as s,Ne as t,f as u,Oe as v,ve as w,_e as x,ge as y,oe 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]="c7f7c461-d96c-4bff-a8cb-9a8f45c06d14",r._sentryDebugIdIdentifier="sentry-dbid-c7f7c461-d96c-4bff-a8cb-9a8f45c06d14")}catch{}})();var Ze=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};Ze.SENTRY_RELEASE={id:"025d21b4f23815a6de88d1ada63dda0eb718c3d2"};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]="c0fe0575-55f7-4f53-ab4b-206132361fbb",r._sentryDebugIdIdentifier="sentry-dbid-c0fe0575-55f7-4f53-ab4b-206132361fbb")}catch{}})();var Ze=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};Ze.SENTRY_RELEASE={id:"f5a1af2bbc924a5469880750b462925203cc011a"};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 $e=function(r,e){return{enumerable:!(r&1),configurable:!(r&2),writable:!(r&4),value:e}},de=Or,be=Function.prototype,sr=be.call,nt=de&&be.bind.bind(sr,sr),p=de?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,$t=he,Er=function(r){return yt($t(r))},X=typeof document=="object"&&document.all,$=typeof X>"u"&&X!==void 0?function(r){return typeof r=="function"||r===X}:function(r){return typeof r=="function"},dt=$,_=function(r){return typeof r=="object"?r!==null:dt(r)},Z=f,bt=$,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,d,W;Br&&(d=Br.split("."),W=d[0]>0&&d[0]<4?1:+(d[0]+d[1]));!W&&Q&&(d=Q.match(/Edge\/(\d+)/),(!d||d[1]>=74)&&(d=Q.match(/Chrome\/(\d+)/),d&&(W=+d[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=$,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=$,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=$,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),$n=function(r){return yn?yr.createElement(r):{}},dn=g,bn=h,pn=$n,Ne=!dn&&!bn(function(){return Object.defineProperty(pn("div"),"a",{get:function(){return 7}}).a!==7}),hn=g,gn=O,On=fe,Sn=$e,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=$e,_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:{}},$r=g,Gn=S,Me=Function.prototype,xn=$r&&Object.getOwnPropertyDescriptor,Rr=Gn(Me,"name"),Kn=Rr&&function(){}.name==="something",Vn=Rr&&(!$r||$r&&xn(Me,"name").configurable),kn={EXISTS:Rr,PROPER:Kn,CONFIGURABLE:Vn},Wn=p,zn=$,dr=mr,Yn=Wn(Function.toString);zn(dr.inspectSource)||(dr.inspectSource=function(r){return Yn(r)});var Ae=dr.inspectSource,qn=f,Jn=$,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=$,U=S,pr=g,fa=kn.CONFIGURABLE,sa=Ae,Le=ua,ya=Le.enforce,$a=Le.get,Zr=String,K=Object.defineProperty,da=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){da(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)&&$a(this).source||sa(this)},"toString");var Sa=De.exports,Ea=$,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=$,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=$,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,$i=Tr,di=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($i(r)+" is not iterable");if(di(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=$,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