userflow.js-self-hosted 0.1.1002558 → 0.1.1002564
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/BubbleToolbar.js +1 -1
- package/BuilderBar.js +1 -1
- package/ChecklistApp.js +1 -1
- package/ChecklistUI.js +1 -1
- package/FlowApp.js +1 -1
- package/FlowChrome.js +1 -1
- package/Icons.js +1 -1
- package/LauncherApp.js +1 -1
- package/TrackerTestingApp.js +1 -1
- package/hash.txt +1 -1
- package/package.json +1 -1
- package/stylesheets.js +1 -1
- package/ui.js +1 -1
- package/userflow.js +1 -1
package/BubbleToolbar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{c as t,a as n,i as r,b as l}from"./flow-condition-types.js";import{b as o}from"./stylesheets.js";import{o as a}from"./vendor.obj-str.js";import{c as i,s,n as u,l as c,p as d,S as m,E as b,U as p,q as f,d as h}from"./userflow.js";import{S as w,a as g,V as v,b as E,c as y,T as k}from"./Icons.js";import{F as _}from"./vendor.fortawesome.react-fontawesome.js";import{f as x}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as j}from"./vendor.react-i18next.js";import{u as q}from"./client-context.js";const N=e.createContext(null);function S(){const t=e.useContext(N);if(!t)throw new Error("useSession: Session was not set");return t}function C(n){const r=S(),[l,a]=e.useState(!1),i=o(r.data),s=function(t){const n=e.useRef(t),r=e.useRef(t);return t!==r.current&&JSON.stringify(t)!==JSON.stringify(r.current)&&(n.current=t),r.current=t,n.current}(n);return e.useLayoutEffect((()=>{if(s){return t[s.type].track({sessionData:i,condition:s,callback:e=>{a(e)}})}}),[i,s]),null!=s&&l}const T=({appearance:t,hidden:n,disabled:r,onMouseDown:l,onClick:o,text:i,active:s,children:u})=>e.createElement("button",{className:a({[me(t)]:!0,"userflowjs-bubble-button--hidden":!!n,"userflowjs-bubble-button--active":!!s}),onMouseDown:l,onClick:o,disabled:r},u||e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i));function I(e){const t=u();t!==new URL(e,t).toString()&&(i.customNavigate?i.customNavigate(e):window.setTimeout((()=>{s(e)}),0))}async function P(e,t,l){const{steps:o}=t.version;switch(l.type){case c.CLOSE_FLOW:switch(t.kind){case"launcher":await e.dismissLauncher(t,{endReason:b.ACTION});break;case"flow":case"checklist":await e.endFlow(t,{endReason:b.ACTION})}return;case c.EVAL_JS:try{const e=r(l.code||"",t.data);new Function('"use strict";\n'+e)()}catch(a){console.error(`Userflow.js: Evaluate JavaScript action failed.\n\nError:\n${a.stack||a.message||a}\n\nCode:\n${l.code}`)}return;case c.GO_TO_STEP:{if("flow"!==t.kind)return;const n=o.find((({crossVersionId:e})=>e===l.stepCvid));if(!n)throw new p("Action points to unknown step: "+l.stepCvid);return void(await e.goToStep(t,n))}case c.NAVIGATE:{if(!l.url)return void console.warn("Userflow.js: NAVIGATE action is missing url property");const e=W(l.url,{lookupAttribute:n(t.data)});return void(l.navigateTarget===d.NEW_TAB?window.open(e):I(e))}case c.SNOOZE:return void("flow"===t.kind&&l.timeValue&&l.timeUnit&&(e.endFlow(t,{endReason:b.SNOOZED,batch:!0}),t.draftMode?window.alert(`In preview mode, flows can't be snoozed.\n\nBut if this flow was running in published mode, the flow would now be snoozed for ${l.timeValue} ${l.timeUnit.toLowerCase()+(1===l.timeValue?"":"s")}.`):e.send({kind:"Snooze",flowId:t.flow.id,timeValue:l.timeValue,timeUnit:l.timeUnit},{batch:!0})));case c.START_FLOW:return"launcher"===t.kind&&e.deactivateLauncher(t),void(l.otherFlow?await e.startFlow({flowId:l.otherFlow.id,stepCvid:l.otherFlowStepCvid,startReason:t.draftMode?m.DRAFT:m.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow"))}}async function A(e,t,n){const r=[],l=[],o=[];for(const a of n)a.type===c.NAVIGATE?a.navigateTarget===d.NEW_TAB?r.push(a):o.push(a):l.push(a);for(const a of r)P(e,t,a);await Promise.all(l.map((n=>P(e,t,n))));for(const a of o)P(e,t,a)}const L=({button:t})=>{const n=q(),l=S(),o=C(t.disabledCondition),a=C(t.hiddenCondition);return e.createElement(T,{appearance:t.appearance,hidden:a,disabled:o,onClick:()=>A(n,l,t.actions),text:r(t.text,l.data)})},$=({type:t,required:n,buttonText:r,options:l,otherOption:o,multipleSelection:i,shuffleOptions:s,labelLeft:u,labelCenter:c,labelRight:d,minValue:m,maxValue:b,onSubmit:p,inert:h})=>{const{t:v}=j(),E=e.useRef(null),[y,k]=e.useState(""),[q,N]=e.useState(new Set),[S,C]=e.useState(),[T,I]=e.useState(),[P,A]=e.useState(!1),[L,$]=e.useState(!1),[R,F]=e.useState(null),O=e.useMemo((()=>l&&(s?[...l].sort((()=>Math.random()-.5)):l)),[l,s]),U=e=>{if(!h&&p){if(n&&""===y&&[f.MULTILINE_TEXT,f.TEXT].includes(t))return F(v("question.requiredError")),void W();$(!0),F(null),p({...e,onCancel:()=>{$(!1)},onError:e=>{$(!1),F(e||"Sorry, something went wrong saving your answer. Please try again.")}})}},W=e.useCallback((()=>{!h&&E.current&&E.current.focus()}),[h]),[B,V]=e.useState(!1);e.useEffect((()=>{B&&(W(),V(!1))}),[W,B]);const D=e.createElement("div",{className:"userflowjs-bubble-question__button-row userflowjs-bubble-question__button-row--end"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>U({answer:{kind:"text",value:y}}),tabIndex:h?-1:void 0,disabled:L},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},r||v("question.submit"))));let z=null,K=0;if(t===f.NPS)u=u||v("question.npsLabelLeft"),d=d||v("question.npsLabelRight"),z=[0,1,2,3,4,5,6,7,8,9,10],K=z.length;else if([f.SCALE,f.STARS].includes(t)){b=null!=b?b:5,z=[];for(let e=m=null!=m?m:1;e<=b;e++)z.push(e);K=z.length}else t===f.MULTIPLE_CHOICE&&(K=(O?O.length:0)+(o&&!P?1:0));const[J,H]=e.useState(-1),G=-1===J?-1:Math.min(J,K-1),X=e=>{if(!e.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let t=null;if("ArrowRight"===e.key||"ArrowDown"===e.key?t=1:"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(t=-1),null!=t){e.preventDefault();const n=e.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let r=G+t;r<0?r=n.length-1:r>n.length-1&&(r=0),H(r),n[r].focus()}};let Q,Z=null,Y=null;if(z&&(u||c||d)){const t=[];u&&t.push(z[0],u),d&&t.push(z[z.length-1],d),Z=e.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},t.join(", ")),Y=e.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},e.createElement("div",{className:"userflowjs-bubble-question__scale-label"},u),c&&e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},c),e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},d))}switch(t){case f.MULTILINE_TEXT:Q=e.createElement(e.Fragment,null,e.createElement("textarea",{ref:E,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&U({answer:{kind:"text",value:y}})},placeholder:v("question.placeholder"),readOnly:h||L,tabIndex:h?-1:void 0,rows:3,"aria-required":n?"true":void 0,"aria-invalid":null!=R?"true":void 0}),D);break;case f.MULTIPLE_CHOICE:{const t=()=>{y&&U({answer:{kind:"text",value:y},animationPromise:M()})},n=(O?.length||0)+(o?1:0),l=Math.max(0,Math.min(n,null==m?1:m)),s=Math.max(0,Math.min(n,null==b?n:b)),u=()=>{const e=(O||[]).filter(((e,t)=>q.has(t))).map((e=>e.value));o&&P&&""!==y&&e.push(y),l!==s||e.length===l?e.length<l?F(v("question.multiple_selection_too_few",{count:l})):e.length>s?F(v("question.multiple_selection_too_many",{count:s})):U({answer:{kind:"list",values:e}}):F(v("question.multiple_selection_wrong",{count:l}))};Q=e.createElement(e.Fragment,null,i&&e.createElement("div",{className:a({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!R})},v("question.multiple_selection_hint",{replace:{selected:q.size+(o&&P&&""!==y?1:0),range:l===s?l:`${l}-${s}`}}),R&&e.createElement(e.Fragment,null,". ",e.createElement("span",{role:"alert"},R))),e.createElement("div",{className:a({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!i,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!i,"userflowjs-bubble-question__multiple-choice--other-option-active":!!o&&P}),role:i?"group":"radiogroup",tabIndex:h||-1!==G?-1:0,onKeyDown:X},O?.map((({value:t,label:n},r)=>e.createElement("button",{key:r,className:a({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":i?q.has(r):L&&!P&&y==t}),onClick:L?void 0:()=>{if(i){F(null);const e=new Set(q);q.has(r)?e.delete(r):e.add(r),N(e)}else A(!1),k(t),U({answer:{kind:"text",value:t},animationPromise:M()})},disabled:L,tabIndex:h||r!==G?-1:0,role:i?"checkbox":"radio","aria-label":n||t,"aria-checked":!P&&y==t},i?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(_,{icon:x}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},n||t)))),o&&(P?e.createElement("div",{className:a({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":i?""!=y:L})},i?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{k(""),A(!1)}},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(_,{icon:x}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("input",{ref:E,className:"userflowjs-bubble-question__multiple-choice-option-input",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key?"Escape"===e.key&&(e.stopPropagation(),k(""),A(!1)):i?u():t()},onBlur:()=>{""===y&&A(!1)},placeholder:v("question.placeholder"),readOnly:h||L,tabIndex:h?-1:void 0}),!i&&e.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>t(),disabled:L,"aria-label":v("question.submit")},e.createElement(g,null))):e.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:L?void 0:()=>{F(null),A(!0),V(!0)},disabled:L,tabIndex:h||O?.length!==G?-1:0,role:"radio","aria-label":v("question.other"),"aria-checked":"false"},i?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(_,{icon:x}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},v("question.other"))))),i&&e.createElement("div",{className:"userflowjs-bubble-question__button-row"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:u,tabIndex:h?-1:void 0,disabled:L},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},r||v("question.submit")))));break}case f.NPS:case f.SCALE:Q=e.createElement(e.Fragment,null,Z,e.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:h||-1!==G?-1:0,onKeyDown:X},z?.map(((t,n)=>e.createElement("button",{className:a({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":L&&S==t}),key:t,tabIndex:h||n!==G?-1:0,onClick:()=>{C(t),U({answer:{kind:"number",value:t},animationPromise:M()})},disabled:L,role:"radio","aria-checked":S==t},t)))),Y);break;case f.STARS:Q=e.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},Z,e.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:h||-1!==G?-1:0,onKeyDown:X},z?.map(((t,n)=>e.createElement("button",{className:a({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!L&&null!=T&&T>=t,"userflowjs-bubble-question__star--selected":L&&null!=S&&S>=t,"userflowjs-bubble-question__star--not-selected":L&&null!=S&&S<t}),key:t,tabIndex:h||n!==G?-1:0,onClick:()=>{C(t),U({answer:{kind:"number",value:t},animationPromise:M()})},onMouseOver:()=>I(t),onMouseLeave:()=>I(null),disabled:L,role:"radio","aria-checked":S==t,"aria-label":String(t)},e.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},e.createElement(w,null)),e.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},t))))),Y);break;case f.TEXT:Q=e.createElement(e.Fragment,null,e.createElement("input",{ref:E,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||U({answer:{kind:"text",value:y}})},placeholder:v("question.placeholder"),readOnly:h||L,tabIndex:h?-1:void 0,"aria-required":n?"true":void 0,"aria-invalid":null!=R?"true":void 0}),D)}return e.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:h?"none":void 0}},R&&!(t===f.MULTIPLE_CHOICE&&i)&&e.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},R),Q)};function M(){return new Promise((e=>window.setTimeout(e,250)))}const R=({question:t})=>{const n=q(),r=function(){const e=S();if("flow"!==e.kind)throw new Error("useFlowSession: Wrong session kind");return e}();return e.createElement($,{type:t.type,required:!!t.required,buttonText:t.buttonText||"",options:t.options,otherOption:t.otherOption,multipleSelection:t.multipleSelection,shuffleOptions:t.shuffleOptions,labelLeft:t.labelLeft||"",labelCenter:t.labelCenter||"",labelRight:t.labelRight||"",minValue:t.minValue,maxValue:t.maxValue,onSubmit:async e=>{h("answerQuestion",r.id,t.cvid,e);const{answer:l}=e;try{await Promise.all([await n.send({kind:"AnswerQuestion",sessionId:r.id,questionName:t.name,questionCvid:t.cvid,textAnswer:"text"==l.kind?l.value:null,numberAnswer:"number"==l.kind?String(l.value):null,listAnswer:"list"==l.kind?l.values:null}),e.animationPromise])}catch(a){return console.log("Userflow.js: Error when answering question:",a),void e.onError()}const{bindAttributeFqn:o}=t;if(o&&n.flowSession?.id===r.id){let e;switch(l.kind){case"text":e={name:o,value:l.value};break;case"number":e={name:o,value:String(l.value)};break;case"list":e={name:o,value:l.values}}n.optimisticClockUIUpdate((()=>{n.setFlowSession({...r,data:[...r.data.filter((e=>e.name!==o)),e]})}))}A(n,r,t.actions)}})},F=({text:t})=>{if(!t)return null;const n=t.split(/\n/);return 1===n.length?e.createElement(e.Fragment,null,n[0]):e.createElement(e.Fragment,null,n.map(((t,n)=>e.createElement(e.Fragment,{key:n},n>0&&e.createElement("br",null),t))))};function O(e=""){return{type:"paragraph",children:[{text:e}]}}function U(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse rich content doc: "+e)}if("rich2"===n.type)return n;throw new Error("Could not recognize rich content doc: "+e)}return function(e=""){return{type:"rich2",children:[O(e)]}}()}function W(e,{lookupAttribute:t}){if(!e)return"";"string"==typeof e&&(e=function(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse plaintext doc: "+e)}if("plaintext2"===n.type)return n;throw new Error("Could not recognize plaintext doc: "+e)}return function(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}()}(e));const n=[];function r(e){e&&e.forEach((e=>e&&function(e){if(se(e))e.text&&n.push(e.text);else switch(e.type){case"attribute":{const r=oe(e,t);r&&n.push(r);break}default:r(e.children)}}(e)))}return r(e.children),n.join("")}function B(e){let t=!0;if(!e)return!0;"string"==typeof e&&(e=U(e));const n=new Set(["attribute","button","image","question","video"]);return ue(e,(e=>{se(e)?""!==e.text&&(t=!1):"type"in e&&n.has(e.type)&&(t=!1)})),t}const V=e.memo((({doc:t,...n})=>t?("string"==typeof t&&(t=U(t)),e.createElement(D,{parent:t,...n})):null)),D=({parent:t,...n})=>e.createElement(e.Fragment,null,t.children.map(((r,l)=>se(r)?e.createElement(z,{key:l,node:r}):e.createElement(J,{key:l,node:r,parent:t,...n})))),z=({node:t})=>t.text?e.createElement(K,{node:t},e.createElement(F,{text:t.text})):null,K=({node:t,children:n})=>(t.color&&"string"==typeof t.color&&(n=e.createElement("span",{style:{color:t.color}},n)),t.bold&&(n=e.createElement("b",null,n)),t.italic&&(n=e.createElement("i",null,n)),t.underline&&(n=e.createElement("u",null,n)),t.strikeThrough&&(n=e.createElement("s",null,n)),t.code&&(n=e.createElement("code",null,n)),t.sup&&(n=e.createElement("sup",null,n)),n),J=({node:t,parent:n,...r})=>{const{lookupAttribute:l}=r,o=e.createElement(D,{parent:t,...r});switch(t.type){case"attribute":return e.createElement(H,{node:t,...r});case"button":return e.createElement(G,{node:t,...r});case"button-group":return e.createElement("div",{className:"userflowjs-bubble-buttons"},o);case"column":return e.createElement("div",{style:re(t,n)},o);case"column-group":return e.createElement("div",{className:"p-like",style:ne(t)},o);case"container":return e.createElement("div",{className:"p-like"+(t.className?` ${t.className}`:""),style:le(t)},o);case"image":return e.createElement(Q,{node:t,...r});case"link":return e.createElement("a",{href:W(t.href,{lookupAttribute:l}),target:"same"===t.target?"_top":"_blank",rel:"noopener noreferrer"},o);case"paragraph":return e.createElement("p",{className:ee(t)},o);case"heading1":return e.createElement("h1",{className:ee(t)},o);case"heading2":return e.createElement("h2",{className:ee(t)},o);case"question":return e.createElement(X,{node:t,...r});case"quote":return e.createElement("blockquote",null,o);case"code-block":return e.createElement("pre",null,e.createElement("code",null,o));case"ordered-list":return e.createElement("ol",null,o);case"unordered-list":return e.createElement("ul",null,o);case"list-item":return e.createElement("li",null,o);case"video":return e.createElement(Z,{node:t,...r});default:return e.createElement("div",null,o)}},H=({node:t,lookupAttribute:n})=>{let r=oe(t,n);return e.createElement(K,{node:t},r)},G=({node:t,buttons:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement(L,{key:r.id,button:r}):null},X=({node:t,questions:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement(R,{key:r.id,question:r}):null},Q=({node:t,lookupAttribute:n})=>{const{src:r,widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m,hasLink:b,href:p}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:f,blockStyle:h}=te({widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m});let w=e.createElement("img",{src:r,style:{...h,objectFit:"contain"}});return b&&p&&(w=e.createElement("a",{href:W(p,{lookupAttribute:n}),target:"_blank",rel:"noopener noreferrer",style:h},w)),e.createElement("div",{className:"p-like"},e.createElement("div",{style:f},w))},Z=({node:t,lookupAttribute:n})=>{const{url:r,widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:b,blockStyle:p}=te({widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m});return e.createElement("div",{className:"p-like"},e.createElement("div",{style:b},e.createElement("div",{style:p},e.createElement(Y,{element:t,noFocus:!0,lookupAttribute:n}))))},Y=({element:{embedType:t,url:n,src:r,autoPlay:o,controls:a,loop:i,muted:s},noFocus:u,forceMuted:c,lookupAttribute:d})=>{if(!n)return null;const m={width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block"},tabIndex:u?-1:void 0};if("video"===t)return e.createElement("video",{key:n+";"+String(o)+";"+String(a)+";"+String(i)+";"+String(s),src:n,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!o,controls:!1!==a,loop:i,muted:c||s});if(r){let t;try{t=new URL(r)}catch(w){return null}return c&&(t.searchParams.has("autoplay")||t.searchParams.has("autoPlay"))&&(t.searchParams.set("mute","1"),t.searchParams.set("muted","1"),t.searchParams.set("volume","0")),e.createElement("iframe",{src:t.toString(),...m})}let b=function(e,{iframeFallback:t}={}){let n;try{n=new URL(e)}catch(w){return{kind:"invalid"}}const{hostname:r,pathname:l,searchParams:o}=n;if(r.match(/^(www\.)?(use)?loom\.com$/)){const e=l.match(/^\/share\/([a-z0-9]+)$/i);if(e){const[,t]=e;return{kind:"ok",videoProvider:"loom",videoId:t,searchParams:o}}}if(e.startsWith("raw:")){return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:o}}if(e.startsWith("iframe:")){return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:o}}if(["youtube.com","www.youtube.com"].includes(r)){const e=o.get("v");if(e)return o.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:e,searchParams:o}}if("youtu.be"===r){const e=l.match(/^\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"youtube",videoId:t,searchParams:o}}}if("vimeo.com"===r){const e=l.match(/^\/(\d+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:o}}}if("player.vimeo.com"===r){const e=l.match(/^\/video\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:o}}}if(r.match(/^[^.]+\.wistia.com$/)){const e=l.match(/^\/medias\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"wistia",videoId:t,searchParams:o}}}return t?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:o}:{kind:"invalid"}}(n,{iframeFallback:!0});if("invalid"===b.kind)return null;const{videoProvider:p,videoId:f,searchParams:h}=b;switch(o=o||h.has("autoplay")||h.has("autoPlay"),p){case"iframe":return e.createElement("iframe",{src:l(f,(e=>encodeURIComponent(d(e)||""))),scrolling:h.get("scrolling")||void 0,...m});case"loom":return e.createElement("iframe",{src:`https://www.loom.com/embed/${f}?${h.toString()}`,...m});case"raw":return e.createElement("video",{src:f,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:h.has("autoplay"),muted:c||h.has("muted")});case"youtube":return c&&o&&h.set("mute","1"),e.createElement("iframe",{src:`https://www.youtube.com/embed/${f}?${h.toString()}`,...m});case"vimeo":return c&&o&&h.set("muted","1"),e.createElement("iframe",{src:`https://player.vimeo.com/video/${f}?${h.toString()}`,...m});case"wistia":return h.set("videoFoam","true"),c&&o&&h.set("volume","0"),e.createElement(e.Fragment,null,e.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${f}?${h.toString()}`,...m}))}};function ee(e){return"right"===e.align?"userflowjs-text-align-end":"center"===e.align?"userflowjs-text-align-center":""}function te({widthMode:e,displayWidth:t,width:n,height:r,marginTop:l,marginRight:o,marginBottom:a,marginLeft:i,align:s}){const u={position:"relative"};"number"!=typeof t&&(t=100,e="percent"),"center"===s?(u.marginLeft="auto",u.marginRight="auto"):"right"===s&&(u.marginLeft="auto");let c=0;if(null!=l&&"number"==typeof l&&(u.marginTop=`${l}px`),null!=o&&"number"==typeof o&&(u.marginRight=`${o}px`,c+=o),null!=a&&"number"==typeof a&&(u.marginBottom=`${a}px`),null!=i&&"number"==typeof i&&(u.marginLeft=`${i}px`,c+=i),"number"!=typeof t||"number"!=typeof n||"number"!=typeof r)u.width="100px",u.height="100px";else if("px"===e){const e=10,l=Math.max(e,t);u.width=`${l}px`,u.height=l/(n/r)+"px"}else{const e=Math.max(0,Math.min(100,t));u.width=`calc(${e}% - ${c}px)`,u.height="0",u.paddingBottom=`calc((${e}% - ${c}px) / (${n} / ${r})`}return{wrapperStyle:u,blockStyle:{position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"}}}function ne(e){return{display:"flex",alignItems:"stretch",marginRight:`-${null==e.spacing?16:e.spacing}px`}}function re(e,t){const n="fill"===e.widthMode||null==e.displayWidth;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:n?void 0:"px"===e.widthMode?`${e.displayWidth||50}px`:"percent"===e.widthMode?`${e.displayWidth||50}%`:void 0,flex:n?"1 0 0":void 0,marginRight:`${null==t.spacing?16:t.spacing}px`,marginBottom:"0"}}function le(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:"px"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}px`:"percent"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}%`:void 0,minHeight:"px"===e.heightMode?`${e.displayHeight||50}px`:void 0,flex:"fill"===e.heightMode?"1 0 0":void 0,marginTop:null!=e.marginTop?`${e.marginTop}px`:void 0,marginRight:null!=e.marginRight?`${e.marginRight}px`:"fill"!==e.widthMode&&"center"===e.align?"auto":void 0,marginBottom:null!=e.marginBottom?`${e.marginBottom}px`:void 0,marginLeft:null!=e.marginLeft?`${e.marginLeft}px`:"fill"===e.widthMode||"center"!==e.align&&"right"!==e.align?void 0:"auto"}}function oe(e,t){const n=e.attributeName;if("string"==typeof n){const r=t(n)||e.fallback;if("string"==typeof r)return r}return null}function ae(e){return Array.isArray(e.children)&&void 0===e.addMark}function ie(e,t,n="type"){return ae(e)&&e[n]===t}function se(e){return"string"==typeof e.text}function ue(e,t){function n(e){e&&e.forEach(((e,r)=>e&&function(e,r){t(e,r),ae(e)&&n(e.children)}(e,r)))}n(Array.isArray(e)?e:e.children)}const ce=e.memo((({doc:t,lookupAttribute:n})=>t?e.createElement(e.Fragment,null,W(t,{lookupAttribute:n})):null));function de(e,{buttons:t,questions:n}){const r=new Set,l=new Set;if(ue(e,(e=>{ie(e,"button")&&r.add(e.cvid),ie(e,"question")&&l.add(e.cvid)})),n){const t=n.filter((e=>!l.has(e.cvid)));t.length>0&&(e={...e,children:[...e.children,...t.map((e=>({type:"question",cvid:e.cvid,children:[{text:""}]})))]})}if(t){const n=t.filter((e=>!r.has(e.cvid)));n.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:n.map((e=>({type:"button",cvid:e.cvid,children:[{text:""}]})))}]})}return e}function me(e){return"userflowjs-bubble-button "+("primary"===(e=e||"default")||"PRIMARY"===e?"userflowjs-bubble-button--primary":"default"===e||"DEFAULT"===e?"userflowjs-bubble-button--default":e)}var be=new URL("flow-host.css",import.meta.url).href,pe=new URL("bubble-frame.css",import.meta.url).href;const fe=({draftMode:t,muted:n,toggleMuted:r,close:l,minimize:o})=>{const{t:a}=j();return e.createElement("div",{className:"userflowjs-bubble-toolbar"},t&&e.createElement("div",{className:"userflowjs-bubble-draft"},"string"==typeof t?t:"Preview"),r&&e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:r,"aria-label":n?"Unmute":"Mute"},n?e.createElement(v,null):e.createElement(E,null)),o&&e.createElement("button",{"data-testid":"minimize-button",className:"userflowjs-bubble-toolbar-button",onClick:o,"aria-label":"Minimize checklist"},e.createElement(y,null)),l&&e.createElement("button",{"data-testid":"close-button",className:"userflowjs-bubble-toolbar-button",onClick:l,"aria-label":a("menu.close")},e.createElement(k,null)))};export{fe as B,V as R,N as S,ce as a,pe as b,T as c,U as d,S as e,be as f,oe as g,A as h,se as i,de as m,I as n,B as r,W as s,C as u};
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{c as t,a as n,i as r,b as l}from"./flow-condition-types.js";import{b as o}from"./stylesheets.js";import{o as a}from"./vendor.obj-str.js";import{c as i,s,n as u,l as c,p as d,S as m,E as b,q as p,U as f,r as h,d as w}from"./userflow.js";import{S as g,a as v,V as E,b as y,c as k,T as _}from"./Icons.js";import{F as x}from"./vendor.fortawesome.react-fontawesome.js";import{f as j}from"./vendor.fortawesome.pro-solid-svg-icons.js";import{u as q}from"./vendor.react-i18next.js";import{u as N}from"./client-context.js";const S=e.createContext(null);function T(){const t=e.useContext(S);if(!t)throw new Error("useSession: Session was not set");return t}function C(n){const r=T(),[l,a]=e.useState(!1),i=o(r.data),s=function(t){const n=e.useRef(t),r=e.useRef(t);return t!==r.current&&JSON.stringify(t)!==JSON.stringify(r.current)&&(n.current=t),r.current=t,n.current}(n);return e.useLayoutEffect((()=>{if(s){return t[s.type].track({sessionData:i,condition:s,callback:e=>{a(e)}})}}),[i,s]),null!=s&&l}const A=({appearance:t,hidden:n,disabled:r,onMouseDown:l,onClick:o,text:i,active:s,children:u})=>e.createElement("button",{className:a({[be(t)]:!0,"userflowjs-bubble-button--hidden":!!n,"userflowjs-bubble-button--active":!!s}),onMouseDown:l,onClick:o,disabled:r},u||e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},i));function I(e){const t=u();t!==new URL(e,t).toString()&&(i.customNavigate?i.customNavigate(e):window.setTimeout((()=>{s(e)}),0))}async function P(e,t,l){const{steps:o}=t.version;switch(l.type){case c.CLOSE_FLOW:switch(t.kind){case"launcher":await e.dismissLauncher(t,{endReason:b.ACTION});break;case"flow":case"checklist":await e.endFlow(t,{endReason:b.ACTION})}return;case c.EVAL_JS:try{const e=r(l.code||"",t.data);new Function('"use strict";\n'+e)()}catch(a){console.error(`Userflow.js: Evaluate JavaScript action failed.\n\nError:\n${a.stack||a.message||a}\n\nCode:\n${l.code}`)}return;case c.GO_TO_STEP:{if("flow"!==t.kind)return;const n=o.find((({crossVersionId:e})=>e===l.stepCvid));if(!n)throw new f("Action points to unknown step: "+l.stepCvid);return void(await e.goToStep(t,n))}case c.NAVIGATE:{if(!l.url)return void console.warn("Userflow.js: NAVIGATE action is missing url property");const e=B(l.url,{lookupAttribute:n(t.data)});return void(l.navigateTarget===d.NEW_TAB?window.open(e):I(e))}case c.SET_ATTRIBUTE:{let t;const n=l.attributeValue||"";switch(l.attributeOperation){case p.SET:t={set:n};break;case p.SET_ONCE:t={set_once:n};break;case p.ADD:t={add:n};break;case p.SUBTRACT:t={subtract:n};break;case p.UNSET:t={set:null};break;default:return}const r=l.attributeFqn||"",o=r.split("/");return void(1===o.length?e.updateUser({[r]:t}):"group"===o[0]?e.updateGroup({[o[1]]:t}):"group_membership"===o[0]&&e.updateGroup({},{membership:{[o[1]]:t}}))}case c.SNOOZE:return void("flow"===t.kind&&l.timeValue&&l.timeUnit&&(e.endFlow(t,{endReason:b.SNOOZED,batch:!0}),t.draftMode?window.alert(`In preview mode, flows can't be snoozed.\n\nBut if this flow was running in published mode, the flow would now be snoozed for ${l.timeValue} ${l.timeUnit.toLowerCase()+(1===l.timeValue?"":"s")}.`):e.send({kind:"Snooze",flowId:t.flow.id,timeValue:l.timeValue,timeUnit:l.timeUnit},{batch:!0})));case c.START_FLOW:return"launcher"===t.kind&&e.deactivateLauncher(t),void(l.otherFlow?await e.startFlow({flowId:l.otherFlow.id,stepCvid:l.otherFlowStepCvid,startReason:t.draftMode?m.DRAFT:m.ACTION,replaceCurrent:!0}):console.warn("Userflow.js: START_FLOW action is missing other flow"))}}async function L(e,t,n){const r=[],l=[],o=[];for(const a of n)a.type===c.NAVIGATE?a.navigateTarget===d.NEW_TAB?r.push(a):o.push(a):l.push(a);for(const a of r)P(e,t,a);await Promise.all(l.map((n=>P(e,t,n))));for(const a of o)P(e,t,a)}const $=({button:t})=>{const n=N(),l=T(),o=C(t.disabledCondition),a=C(t.hiddenCondition);return e.createElement(A,{appearance:t.appearance,hidden:a,disabled:o,onClick:()=>L(n,l,t.actions),text:r(t.text,l.data)})},M=({type:t,required:n,buttonText:r,options:l,otherOption:o,multipleSelection:i,shuffleOptions:s,labelLeft:u,labelCenter:c,labelRight:d,minValue:m,maxValue:b,onSubmit:p,inert:f})=>{const{t:w}=q(),E=e.useRef(null),[y,k]=e.useState(""),[_,N]=e.useState(new Set),[S,T]=e.useState(),[C,A]=e.useState(),[I,P]=e.useState(!1),[L,$]=e.useState(!1),[M,F]=e.useState(null),O=e.useMemo((()=>l&&(s?[...l].sort((()=>Math.random()-.5)):l)),[l,s]),U=e=>{if(!f&&p){if(n&&""===y&&[h.MULTILINE_TEXT,h.TEXT].includes(t))return F(w("question.requiredError")),void W();$(!0),F(null),p({...e,onCancel:()=>{$(!1)},onError:e=>{$(!1),F(e||"Sorry, something went wrong saving your answer. Please try again.")}})}},W=e.useCallback((()=>{!f&&E.current&&E.current.focus()}),[f]),[B,D]=e.useState(!1);e.useEffect((()=>{B&&(W(),D(!1))}),[W,B]);const V=e.createElement("div",{className:"userflowjs-bubble-question__button-row userflowjs-bubble-question__button-row--end"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>U({answer:{kind:"text",value:y}}),tabIndex:f?-1:void 0,disabled:L},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},r||w("question.submit"))));let z=null,K=0;if(t===h.NPS)u=u||w("question.npsLabelLeft"),d=d||w("question.npsLabelRight"),z=[0,1,2,3,4,5,6,7,8,9,10],K=z.length;else if([h.SCALE,h.STARS].includes(t)){b=null!=b?b:5,z=[];for(let e=m=null!=m?m:1;e<=b;e++)z.push(e);K=z.length}else t===h.MULTIPLE_CHOICE&&(K=(O?O.length:0)+(o&&!I?1:0));const[J,G]=e.useState(-1),H=-1===J?-1:Math.min(J,K-1),X=e=>{if(!e.target.closest('[role="radio"], [role="checkbox"], [role="radiogroup"], [role="group"]'))return;let t=null;if("ArrowRight"===e.key||"ArrowDown"===e.key?t=1:"ArrowLeft"!==e.key&&"ArrowUp"!==e.key||(t=-1),null!=t){e.preventDefault();const n=e.currentTarget.querySelectorAll('[role="radio"], [role="checkbox"]');let r=H+t;r<0?r=n.length-1:r>n.length-1&&(r=0),G(r),n[r].focus()}};let Q,Z=null,Y=null;if(z&&(u||c||d)){const t=[];u&&t.push(z[0],u),d&&t.push(z[z.length-1],d),Z=e.createElement("div",{id:"a11y-scale-labels",className:"userflowjs-a11y-only"},t.join(", ")),Y=e.createElement("div",{id:"userflowjs-bubble-question-labels",className:"userflowjs-bubble-question__scale-labels","aria-hidden":"true"},e.createElement("div",{className:"userflowjs-bubble-question__scale-label"},u),c&&e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--center"},c),e.createElement("div",{className:"userflowjs-bubble-question__scale-label userflowjs-bubble-question__scale-label--right"},d))}switch(t){case h.MULTILINE_TEXT:Q=e.createElement(e.Fragment,null,e.createElement("textarea",{ref:E,className:"userflowjs-textarea userflowjs-bubble-question__textarea",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>{(e.ctrlKey||e.metaKey)&&"Enter"===e.key&&U({answer:{kind:"text",value:y}})},placeholder:w("question.placeholder"),readOnly:f||L,tabIndex:f?-1:void 0,rows:3,"aria-required":n?"true":void 0,"aria-invalid":null!=M?"true":void 0}),V);break;case h.MULTIPLE_CHOICE:{const t=()=>{y&&U({answer:{kind:"text",value:y},animationPromise:R()})},n=(O?.length||0)+(o?1:0),l=Math.max(0,Math.min(n,null==m?1:m)),s=Math.max(0,Math.min(n,null==b?n:b)),u=()=>{const e=(O||[]).filter(((e,t)=>_.has(t))).map((e=>e.value));o&&I&&""!==y&&e.push(y),l!==s||e.length===l?e.length<l?F(w("question.multiple_selection_too_few",{count:l})):e.length>s?F(w("question.multiple_selection_too_many",{count:s})):U({answer:{kind:"list",values:e}}):F(w("question.multiple_selection_wrong",{count:l}))};Q=e.createElement(e.Fragment,null,i&&e.createElement("div",{className:a({"userflowjs-bubble-question__multiple-choice-hint":!0,"userflowjs-bubble-question__multiple-choice-hint--error":!!M})},w("question.multiple_selection_hint",{replace:{selected:_.size+(o&&I&&""!==y?1:0),range:l===s?l:`${l}-${s}`}}),M&&e.createElement(e.Fragment,null,". ",e.createElement("span",{role:"alert"},M))),e.createElement("div",{className:a({"userflowjs-bubble-question__multiple-choice":!0,"userflowjs-bubble-question__multiple-choice--single-selection":!i,"userflowjs-bubble-question__multiple-choice--multiple-selection":!!i,"userflowjs-bubble-question__multiple-choice--other-option-active":!!o&&I}),role:i?"group":"radiogroup",tabIndex:f||-1!==H?-1:0,onKeyDown:X},O?.map((({value:t,label:n},r)=>e.createElement("button",{key:r,className:a({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--selected":i?_.has(r):L&&!I&&y==t}),onClick:L?void 0:()=>{if(i){F(null);const e=new Set(_);_.has(r)?e.delete(r):e.add(r),N(e)}else P(!1),k(t),U({answer:{kind:"text",value:t},animationPromise:R()})},disabled:L,tabIndex:f||r!==H?-1:0,role:i?"checkbox":"radio","aria-label":n||t,"aria-checked":!I&&y==t},i?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(x,{icon:j}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},n||t)))),o&&(I?e.createElement("div",{className:a({"userflowjs-bubble-question__multiple-choice-option":!0,"userflowjs-bubble-question__multiple-choice-option--other":!0,"userflowjs-bubble-question__multiple-choice-option--selected":i?""!=y:L})},i?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox",onClick:()=>{k(""),P(!1)}},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(x,{icon:j}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("input",{ref:E,className:"userflowjs-bubble-question__multiple-choice-option-input",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key?"Escape"===e.key&&(e.stopPropagation(),k(""),P(!1)):i?u():t()},onBlur:()=>{""===y&&P(!1)},placeholder:w("question.placeholder"),readOnly:f||L,tabIndex:f?-1:void 0}),!i&&e.createElement("button",{"data-testid":"multiple-choice-other-submit",className:"userflowjs-bubble-question__multiple-choice-option-submit",onClick:()=>t(),disabled:L,"aria-label":w("question.submit")},e.createElement(v,null))):e.createElement("button",{className:"userflowjs-bubble-question__multiple-choice-option",onClick:L?void 0:()=>{F(null),P(!0),D(!0)},disabled:L,tabIndex:f||O?.length!==H?-1:0,role:"radio","aria-label":w("question.other"),"aria-checked":"false"},i?e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-checkbox-inner"},e.createElement(x,{icon:j}))):e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio"},e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-radio-inner"})),e.createElement("div",{className:"userflowjs-bubble-question__multiple-choice-option-text","aria-hidden":"true"},w("question.other"))))),i&&e.createElement("div",{className:"userflowjs-bubble-question__button-row"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:u,tabIndex:f?-1:void 0,disabled:L},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},r||w("question.submit")))));break}case h.NPS:case h.SCALE:Q=e.createElement(e.Fragment,null,Z,e.createElement("div",{className:"userflowjs-bubble-question__scale-options",role:"radiogroup",tabIndex:f||-1!==H?-1:0,onKeyDown:X},z?.map(((t,n)=>e.createElement("button",{className:a({"userflowjs-bubble-question__scale-option":!0,"userflowjs-bubble-question__scale-option--selected":L&&S==t}),key:t,tabIndex:f||n!==H?-1:0,onClick:()=>{T(t),U({answer:{kind:"number",value:t},animationPromise:R()})},disabled:L,role:"radio","aria-checked":S==t},t)))),Y);break;case h.STARS:Q=e.createElement("div",{className:"userflowjs-bubble-question__stars-wrapper"},Z,e.createElement("div",{className:"userflowjs-bubble-question__stars",role:"radiogroup",tabIndex:f||-1!==H?-1:0,onKeyDown:X},z?.map(((t,n)=>e.createElement("button",{className:a({"userflowjs-bubble-question__star":!0,"userflowjs-bubble-question__star--hovered":!L&&null!=C&&C>=t,"userflowjs-bubble-question__star--selected":L&&null!=S&&S>=t,"userflowjs-bubble-question__star--not-selected":L&&null!=S&&S<t}),key:t,tabIndex:f||n!==H?-1:0,onClick:()=>{T(t),U({answer:{kind:"number",value:t},animationPromise:R()})},onMouseOver:()=>A(t),onMouseLeave:()=>A(null),disabled:L,role:"radio","aria-checked":S==t,"aria-label":String(t)},e.createElement("div",{className:"userflowjs-bubble-question__star-icon","aria-hidden":"true"},e.createElement(g,null)),e.createElement("div",{className:"userflowjs-bubble-question__star-value","aria-hidden":"true"},t))))),Y);break;case h.TEXT:Q=e.createElement(e.Fragment,null,e.createElement("input",{ref:E,className:"userflowjs-text-input userflowjs-bubble-question__text-input",value:y,onChange:e=>k(e.target.value),onKeyDown:e=>{e.shiftKey||"Enter"!==e.key||U({answer:{kind:"text",value:y}})},placeholder:w("question.placeholder"),readOnly:f||L,tabIndex:f?-1:void 0,"aria-required":n?"true":void 0,"aria-invalid":null!=M?"true":void 0}),V)}return e.createElement("div",{className:"userflowjs-bubble-question",style:{pointerEvents:f?"none":void 0}},M&&!(t===h.MULTIPLE_CHOICE&&i)&&e.createElement("div",{className:"userflowjs-bubble-question__error",role:"alert"},M),Q)};function R(){return new Promise((e=>window.setTimeout(e,250)))}const F=({question:t})=>{const n=N(),r=function(){const e=T();if("flow"!==e.kind)throw new Error("useFlowSession: Wrong session kind");return e}();return e.createElement(M,{type:t.type,required:!!t.required,buttonText:t.buttonText||"",options:t.options,otherOption:t.otherOption,multipleSelection:t.multipleSelection,shuffleOptions:t.shuffleOptions,labelLeft:t.labelLeft||"",labelCenter:t.labelCenter||"",labelRight:t.labelRight||"",minValue:t.minValue,maxValue:t.maxValue,onSubmit:async e=>{w("answerQuestion",r.id,t.cvid,e);const{answer:l}=e;try{await Promise.all([await n.send({kind:"AnswerQuestion",sessionId:r.id,questionName:t.name,questionCvid:t.cvid,textAnswer:"text"==l.kind?l.value:null,numberAnswer:"number"==l.kind?String(l.value):null,listAnswer:"list"==l.kind?l.values:null}),e.animationPromise])}catch(a){return console.log("Userflow.js: Error when answering question:",a),void e.onError()}const{bindAttributeFqn:o}=t;if(o&&n.flowSession?.id===r.id){let e;switch(l.kind){case"text":e={name:o,value:l.value};break;case"number":e={name:o,value:String(l.value)};break;case"list":e={name:o,value:l.values}}n.optimisticClockUIUpdate((()=>{n.setFlowSession({...r,data:[...r.data.filter((e=>e.name!==o)),e]})}))}L(n,r,t.actions)}})},O=({text:t})=>{if(!t)return null;const n=t.split(/\n/);return 1===n.length?e.createElement(e.Fragment,null,n[0]):e.createElement(e.Fragment,null,n.map(((t,n)=>e.createElement(e.Fragment,{key:n},n>0&&e.createElement("br",null),t))))};function U(e=""){return{type:"paragraph",children:[{text:e}]}}function W(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse rich content doc: "+e)}if("rich2"===n.type)return n;throw new Error("Could not recognize rich content doc: "+e)}return function(e=""){return{type:"rich2",children:[U(e)]}}()}function B(e,{lookupAttribute:t}){if(!e)return"";"string"==typeof e&&(e=function(e){if(e){let n;try{n=JSON.parse(e)}catch(t){throw new Error("Could not JSON.parse plaintext doc: "+e)}if("plaintext2"===n.type)return n;throw new Error("Could not recognize plaintext doc: "+e)}return function(e=""){return{type:"plaintext2",children:[{type:"plaintext",children:[{text:e}]}]}}()}(e));const n=[];function r(e){e&&e.forEach((e=>e&&function(e){if(ue(e))e.text&&n.push(e.text);else switch(e.type){case"attribute":{const r=ae(e,t);r&&n.push(r);break}default:r(e.children)}}(e)))}return r(e.children),n.join("")}function D(e){let t=!0;if(!e)return!0;"string"==typeof e&&(e=W(e));const n=new Set(["attribute","button","image","question","video"]);return ce(e,(e=>{ue(e)?""!==e.text&&(t=!1):"type"in e&&n.has(e.type)&&(t=!1)})),t}const V=e.memo((({doc:t,...n})=>t?("string"==typeof t&&(t=W(t)),e.createElement(z,{parent:t,...n})):null)),z=({parent:t,...n})=>e.createElement(e.Fragment,null,t.children.map(((r,l)=>ue(r)?e.createElement(K,{key:l,node:r}):e.createElement(G,{key:l,node:r,parent:t,...n})))),K=({node:t})=>t.text?e.createElement(J,{node:t},e.createElement(O,{text:t.text})):null,J=({node:t,children:n})=>(t.color&&"string"==typeof t.color&&(n=e.createElement("span",{style:{color:t.color}},n)),t.bold&&(n=e.createElement("b",null,n)),t.italic&&(n=e.createElement("i",null,n)),t.underline&&(n=e.createElement("u",null,n)),t.strikeThrough&&(n=e.createElement("s",null,n)),t.code&&(n=e.createElement("code",null,n)),t.sup&&(n=e.createElement("sup",null,n)),n),G=({node:t,parent:n,...r})=>{const{lookupAttribute:l}=r,o=e.createElement(z,{parent:t,...r});switch(t.type){case"attribute":return e.createElement(H,{node:t,...r});case"button":return e.createElement(X,{node:t,...r});case"button-group":return e.createElement("div",{className:"userflowjs-bubble-buttons"},o);case"column":return e.createElement("div",{style:le(t,n)},o);case"column-group":return e.createElement("div",{className:"p-like",style:re(t)},o);case"container":return e.createElement("div",{className:"p-like"+(t.className?` ${t.className}`:""),style:oe(t)},o);case"image":return e.createElement(Z,{node:t,...r});case"link":return e.createElement("a",{href:B(t.href,{lookupAttribute:l}),target:"same"===t.target?"_top":"_blank",rel:"noopener noreferrer"},o);case"paragraph":return e.createElement("p",{className:te(t)},o);case"heading1":return e.createElement("h1",{className:te(t)},o);case"heading2":return e.createElement("h2",{className:te(t)},o);case"question":return e.createElement(Q,{node:t,...r});case"quote":return e.createElement("blockquote",null,o);case"code-block":return e.createElement("pre",null,e.createElement("code",null,o));case"ordered-list":return e.createElement("ol",null,o);case"unordered-list":return e.createElement("ul",null,o);case"list-item":return e.createElement("li",null,o);case"video":return e.createElement(Y,{node:t,...r});default:return e.createElement("div",null,o)}},H=({node:t,lookupAttribute:n})=>{let r=ae(t,n);return e.createElement(J,{node:t},r)},X=({node:t,buttons:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement($,{key:r.id,button:r}):null},Q=({node:t,questions:n})=>{const r=n?.find((e=>e.cvid===t.cvid));return r?e.createElement(F,{key:r.id,question:r}):null},Z=({node:t,lookupAttribute:n})=>{const{src:r,widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m,hasLink:b,href:p}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:f,blockStyle:h}=ne({widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m});let w=e.createElement("img",{src:r,style:{...h,objectFit:"contain"}});return b&&p&&(w=e.createElement("a",{href:B(p,{lookupAttribute:n}),target:"_blank",rel:"noopener noreferrer",style:h},w)),e.createElement("div",{className:"p-like"},e.createElement("div",{style:f},w))},Y=({node:t,lookupAttribute:n})=>{const{url:r,widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m}=t;if("string"!=typeof r||!r)return null;const{wrapperStyle:b,blockStyle:p}=ne({widthMode:l,displayWidth:o,width:a,height:i,marginTop:s,marginRight:u,marginBottom:c,marginLeft:d,align:m});return e.createElement("div",{className:"p-like"},e.createElement("div",{style:b},e.createElement("div",{style:p},e.createElement(ee,{element:t,noFocus:!0,lookupAttribute:n}))))},ee=({element:{embedType:t,url:n,src:r,autoPlay:o,controls:a,loop:i,muted:s},noFocus:u,forceMuted:c,lookupAttribute:d})=>{if(!n)return null;const m={width:"100%",height:"100%",frameBorder:"0",allow:"accelerometer; autoplay; fullscreen; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,allowtransparency:"true",mozallowfullscreen:"true",webkitallowfullscreen:"true",oallowfullscreen:"true",msallowfullscreen:"true",style:{display:"block"},tabIndex:u?-1:void 0};if("video"===t)return e.createElement("video",{key:n+";"+String(o)+";"+String(a)+";"+String(i)+";"+String(s),src:n,style:{width:"100%",height:"100%",display:"block"},autoPlay:!!o,controls:!1!==a,loop:i,muted:c||s});if(r){let t;try{t=new URL(r)}catch(w){return null}return c&&(t.searchParams.has("autoplay")||t.searchParams.has("autoPlay"))&&(t.searchParams.set("mute","1"),t.searchParams.set("muted","1"),t.searchParams.set("volume","0")),e.createElement("iframe",{src:t.toString(),...m})}let b=function(e,{iframeFallback:t}={}){let n;try{n=new URL(e)}catch(w){return{kind:"invalid"}}const{hostname:r,pathname:l,searchParams:o}=n;if(r.match(/^(www\.)?(use)?loom\.com$/)){const e=l.match(/^\/share\/([a-z0-9]+)$/i);if(e){const[,t]=e;return{kind:"ok",videoProvider:"loom",videoId:t,searchParams:o}}}if(e.startsWith("raw:")){return{kind:"ok",videoProvider:"raw",videoId:e.replace(/^raw:/,""),searchParams:o}}if(e.startsWith("iframe:")){return{kind:"ok",videoProvider:"iframe",videoId:e.replace(/^iframe:/,""),searchParams:o}}if(["youtube.com","www.youtube.com"].includes(r)){const e=o.get("v");if(e)return o.delete("v"),{kind:"ok",videoProvider:"youtube",videoId:e,searchParams:o}}if("youtu.be"===r){const e=l.match(/^\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"youtube",videoId:t,searchParams:o}}}if("vimeo.com"===r){const e=l.match(/^\/(\d+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:o}}}if("player.vimeo.com"===r){const e=l.match(/^\/video\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"vimeo",videoId:t,searchParams:o}}}if(r.match(/^[^.]+\.wistia.com$/)){const e=l.match(/^\/medias\/([^/]+)$/);if(e){const[,t]=e;return{kind:"ok",videoProvider:"wistia",videoId:t,searchParams:o}}}return t?{kind:"ok",videoProvider:"iframe",videoId:e,searchParams:o}:{kind:"invalid"}}(n,{iframeFallback:!0});if("invalid"===b.kind)return null;const{videoProvider:p,videoId:f,searchParams:h}=b;switch(o=o||h.has("autoplay")||h.has("autoPlay"),p){case"iframe":return e.createElement("iframe",{src:l(f,(e=>encodeURIComponent(d(e)||""))),scrolling:h.get("scrolling")||void 0,...m});case"loom":return e.createElement("iframe",{src:`https://www.loom.com/embed/${f}?${h.toString()}`,...m});case"raw":return e.createElement("video",{src:f,controls:!0,style:{width:"100%",height:"100%",display:"block"},autoPlay:h.has("autoplay"),muted:c||h.has("muted")});case"youtube":return c&&o&&h.set("mute","1"),e.createElement("iframe",{src:`https://www.youtube.com/embed/${f}?${h.toString()}`,...m});case"vimeo":return c&&o&&h.set("muted","1"),e.createElement("iframe",{src:`https://player.vimeo.com/video/${f}?${h.toString()}`,...m});case"wistia":return h.set("videoFoam","true"),c&&o&&h.set("volume","0"),e.createElement(e.Fragment,null,e.createElement("iframe",{src:`https://fast.wistia.net/embed/iframe/${f}?${h.toString()}`,...m}))}};function te(e){return"right"===e.align?"userflowjs-text-align-end":"center"===e.align?"userflowjs-text-align-center":""}function ne({widthMode:e,displayWidth:t,width:n,height:r,marginTop:l,marginRight:o,marginBottom:a,marginLeft:i,align:s}){const u={position:"relative"};"number"!=typeof t&&(t=100,e="percent"),"center"===s?(u.marginLeft="auto",u.marginRight="auto"):"right"===s&&(u.marginLeft="auto");let c=0;if(null!=l&&"number"==typeof l&&(u.marginTop=`${l}px`),null!=o&&"number"==typeof o&&(u.marginRight=`${o}px`,c+=o),null!=a&&"number"==typeof a&&(u.marginBottom=`${a}px`),null!=i&&"number"==typeof i&&(u.marginLeft=`${i}px`,c+=i),"number"!=typeof t||"number"!=typeof n||"number"!=typeof r)u.width="100px",u.height="100px";else if("px"===e){const e=10,l=Math.max(e,t);u.width=`${l}px`,u.height=l/(n/r)+"px"}else{const e=Math.max(0,Math.min(100,t));u.width=`calc(${e}% - ${c}px)`,u.height="0",u.paddingBottom=`calc((${e}% - ${c}px) / (${n} / ${r})`}return{wrapperStyle:u,blockStyle:{position:"absolute",top:"0",left:"0",display:"block",width:"100%",height:"100%"}}}function re(e){return{display:"flex",alignItems:"stretch",marginRight:`-${null==e.spacing?16:e.spacing}px`}}function le(e,t){const n="fill"===e.widthMode||null==e.displayWidth;return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:n?void 0:"px"===e.widthMode?`${e.displayWidth||50}px`:"percent"===e.widthMode?`${e.displayWidth||50}%`:void 0,flex:n?"1 0 0":void 0,marginRight:`${null==t.spacing?16:t.spacing}px`,marginBottom:"0"}}function oe(e){return{display:"flex",flexDirection:"column",justifyContent:e.justifyContent,width:"px"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}px`:"percent"===e.widthMode&&null!=e.displayWidth?`${e.displayWidth}%`:void 0,minHeight:"px"===e.heightMode?`${e.displayHeight||50}px`:void 0,flex:"fill"===e.heightMode?"1 0 0":void 0,marginTop:null!=e.marginTop?`${e.marginTop}px`:void 0,marginRight:null!=e.marginRight?`${e.marginRight}px`:"fill"!==e.widthMode&&"center"===e.align?"auto":void 0,marginBottom:null!=e.marginBottom?`${e.marginBottom}px`:void 0,marginLeft:null!=e.marginLeft?`${e.marginLeft}px`:"fill"===e.widthMode||"center"!==e.align&&"right"!==e.align?void 0:"auto"}}function ae(e,t){const n=e.attributeName;if("string"==typeof n){const r=t(n)||e.fallback;if("string"==typeof r)return r}return null}function ie(e){return Array.isArray(e.children)&&void 0===e.addMark}function se(e,t,n="type"){return ie(e)&&e[n]===t}function ue(e){return"string"==typeof e.text}function ce(e,t){function n(e){e&&e.forEach(((e,r)=>e&&function(e,r){t(e,r),ie(e)&&n(e.children)}(e,r)))}n(Array.isArray(e)?e:e.children)}const de=e.memo((({doc:t,lookupAttribute:n})=>t?e.createElement(e.Fragment,null,B(t,{lookupAttribute:n})):null));function me(e,{buttons:t,questions:n}){const r=new Set,l=new Set;if(ce(e,(e=>{se(e,"button")&&r.add(e.cvid),se(e,"question")&&l.add(e.cvid)})),n){const t=n.filter((e=>!l.has(e.cvid)));t.length>0&&(e={...e,children:[...e.children,...t.map((e=>({type:"question",cvid:e.cvid,children:[{text:""}]})))]})}if(t){const n=t.filter((e=>!r.has(e.cvid)));n.length>0&&(e={...e,children:[...e.children,{type:"button-group",children:n.map((e=>({type:"button",cvid:e.cvid,children:[{text:""}]})))}]})}return e}function be(e){return"userflowjs-bubble-button "+("primary"===(e=e||"default")||"PRIMARY"===e?"userflowjs-bubble-button--primary":"default"===e||"DEFAULT"===e?"userflowjs-bubble-button--default":e)}var pe=new URL("flow-host.css",import.meta.url).href,fe=new URL("bubble-frame.css",import.meta.url).href;const he=({draftMode:t,muted:n,toggleMuted:r,close:l,minimize:o})=>{const{t:a}=q();return e.createElement("div",{className:"userflowjs-bubble-toolbar"},t&&e.createElement("div",{className:"userflowjs-bubble-draft"},"string"==typeof t?t:"Preview"),r&&e.createElement("button",{className:"userflowjs-bubble-toolbar-button",onClick:r,"aria-label":n?"Unmute":"Mute"},n?e.createElement(E,null):e.createElement(y,null)),o&&e.createElement("button",{"data-testid":"minimize-button",className:"userflowjs-bubble-toolbar-button",onClick:o,"aria-label":"Minimize checklist"},e.createElement(k,null)),l&&e.createElement("button",{"data-testid":"close-button",className:"userflowjs-bubble-toolbar-button",onClick:l,"aria-label":a("menu.close")},e.createElement(_,null)))};export{he as B,V as R,S,de as a,fe as b,A as c,W as d,T as e,pe as f,ae as g,L as h,ue as i,me as m,I as n,D as r,B as s,C as u};
|
package/BuilderBar.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{u as t,F as r,S as s}from"./logomark.js";import{o}from"./vendor.obj-str.js";import{f as a,a as n}from"./vendor.fortawesome.pro-light-svg-icons.js";import{
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{u as t,F as r,S as s}from"./logomark.js";import{o}from"./vendor.obj-str.js";import{f as a,a as n}from"./vendor.fortawesome.pro-light-svg-icons.js";import{x as l}from"./userflow.js";import{a as m}from"./stylesheets.js";import{D as i}from"./DynamicIcon.js";var u=new URL("builder-ui-host.css",import.meta.url).href,c=new URL("builder-ui-frame.css",import.meta.url).href;const f=e.forwardRef((({onReadyChange:f,children:d,buttons:p},b)=>{const{loaded:h}=m(window,u),[v,E]=e.useState(!1),g=h&&v,y=e.useRef(!1);e.useEffect((()=>{g&&!y.current&&f&&(y.current=!0,f(!0))}),[g,f]);const j=e.useRef(null),[w,R]=e.useState(null),[k,N]=e.useState((()=>"top"===l.getItem("builderBarPos")?"top":"bottom")),S=e.useCallback((e=>{N(e),l.setItem("builderBarPos",e)}),[]),C=e.useRef(0),I=e.useCallback((()=>{const e=j.current;if(!e||!w||!g)return;const t=w.clientHeight;t!==C.current&&(C.current=t,e.style.setProperty("height",t+"px","important"))}),[g,w]);return e.useLayoutEffect((()=>{I()})),t(I),e.useImperativeHandle(b,(()=>({getFrame:()=>j.current,getRootEl:()=>w})),[w]),e.createElement(e.Fragment,null,e.createElement(r,{className:o({"userflowjs-builder-bar":!0,"userflowjs-builder-bar--top":"top"===k}),style:{visibility:g?void 0:"hidden",animation:g?void 0:"none"},elRef:j,stylesheetUrl:c,onStylesheetsLoad:E},g&&e.createElement("div",{className:"root",ref:R},e.createElement("div",{className:"logomark"},e.createElement(s,null)),e.createElement("div",{className:"main"},d),e.createElement("div",{className:"buttons"},p,e.createElement("button",{key:k,className:"btn btn--square btn--plain-on-dark",onClick:()=>S("top"===k?"bottom":"top")},e.createElement(i,{icon:"top"===k?a:n,size:20}))))))}));export{f as B};
|
package/ChecklistApp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{D as t,A as s,z as o,i as n}from"./userflow.js";import{F as r}from"./FlowChrome.js";import{i,u as c}from"./client-context.js";import{w as a,C as l,a as u,g as m}from"./Icons.js";import{f as d,B as h}from"./BubbleToolbar.js";import{a as p,u as f}from"./stylesheets.js";import{F as k}from"./logomark.js";import{o as v}from"./vendor.obj-str.js";import{z as b}from"./flow-condition-types.js";import{u as j}from"./vendor.react-i18next.js";import{C as E}from"./ChecklistUI.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.i18next.js";import"./vendor.fortawesome.react-fontawesome.js";import"./vendor.fortawesome.fontawesome-svg-core.js";import"./vendor.prop-types.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.date-fns.js";import"./vendor.babel.runtime.js";var x=new URL("checklist-launcher-frame.css",import.meta.url).href;const w=({position:s,theme:o,onClick:n,onVisibleChange:r,buttonRef:i,text:c,uncompletedCount:m})=>{const h=s||"absolute",{i18n:f}=j(),E=f.dir(),{loaded:w}=p(window,d,o),[g,y]=e.useState(!1),L=w&&g;e.useEffect((()=>{r&&r(L)}),[r,L]);const F=e.useRef(null),I=e.useRef(0),[C,A]=e.useState(null);e.useLayoutEffect((()=>{const e=F.current;if(!e||!C)return;const t=C.clientWidth;t!==I.current&&(I.current=t,e.style.setProperty("width",b(t)+"px","important"),e.style.setProperty("height",o.checklistLauncherHeight+"px","important"))}));const T=o.checklistLauncherPlacement,R=T===t.TOP_LEFT||T===t.TOP_RIGHT,N=T===t.TOP_LEFT||T===t.BOTTOM_LEFT,P={zIndex:"fixed"===h?null!=o.checklistZIndex?o.checklistZIndex:a(l):1,top:R?o.checklistLauncherY+"px":void 0,bottom:R?void 0:o.checklistLauncherY+"px",["ltr"===E?"left":"right"]:N?o.checklistLauncherX+"px":void 0,["ltr"===E?"right":"left"]:N?void 0:o.checklistLauncherX+"px",height:o.checklistLauncherHeight+"px",borderRadius:o.checklistLauncherBorderRadius+"px",position:L?void 0:"absolute",visibility:L?void 0:"hidden",animation:L?void 0:"none"};return e.createElement(k,{elRef:F,testId:"checklist-launcher-app",className:v({"userflowjs-checklist-launcher":!0,[`userflowjs-checklist-launcher--position-${h}`]:!0}),style:P,stylesheetUrl:x,theme:o,onStylesheetsLoad:y},e.createElement("button",{ref:i,className:"userflowjs-checklist-launcher-frame-root",onClick:n},e.createElement("div",{ref:A,className:"userflowjs-checklist-launcher-content"},e.createElement("div",{className:"userflowjs-checklist-launcher-text"},c||"Get Started"),e.createElement("div",{"data-testid":"checklist-launcher-uncompleted-count",className:"userflowjs-checklist-launcher-uncompleted-count"},0===m?e.createElement(u,null):m,e.createElement("div",{className:"userflowjs-a11y-only"},"uncompleted tasks")))))},g=({session:t,checklistExpanded:s})=>{const{version:o}=t,n=o.checklist,r=t.locale?t.locale.standardLocaleId:t.version.theme.languageId;e.useEffect((()=>{i.changeLanguage(r)}),[r]);const[c,a]=e.useState(!1);return s?e.createElement(y,{session:t,initialAutoFocus:c,setInitialAutoFocus:a}):n.launcherEnabled?e.createElement(L,{session:t,initialAutoFocus:c,setInitialAutoFocus:a}):null},y=({session:t,initialAutoFocus:n,setInitialAutoFocus:i})=>{const a=c(),[l,u]=e.useState(null),{version:d}=t,p=d.checklist,k=f(d.theme),v=e.useMemo((()=>({...k,avatarType:s.NONE,bubblePlacement:k.checklistPlacement,bubbleX:k.checklistX,bubbleY:k.checklistY,bubbleWidth:k.checklistWidth})),[k]);return e.useEffect((()=>{const e=l?.ownerDocument.defaultView;if(!e)return;const t=e=>{"Escape"===e.key&&(i(!0),a.hideChecklist())};return e.addEventListener("keydown",t),()=>e.removeEventListener("keydown",t)}),[l,i,a]),e.createElement(m,null,e.createElement(r,{company:t.flow.company,theme:v,position:"fixed",stepAppearance:o.BUBBLE,zIndex:k.checklistZIndex,autoHide3pEnabled:!0,backgroundImageUrl:p.backgroundAsset&&p.backgroundAsset.assetUrl,bubbleFrameRootRef:u},e.createElement("div",{role:"dialog","aria-label":"Checklist"},e.createElement(E,{session:t,initialAutoFocus:n}),e.createElement(h,{draftMode:t.draftMode,minimize:e=>{i(0===e.detail),a.hideChecklist()}}))))},L=({session:t,initialAutoFocus:s,setInitialAutoFocus:o})=>{const r=c(),[i,a]=e.useState(!1),[l,u]=e.useState(null),{version:m}=t,d=m.checklist,h=f(m.theme);return e.useEffect((()=>{i&&l&&s&&l.focus()}),[r,l,i,s]),e.createElement(w,{position:"fixed",theme:h,onClick:e=>{o(0===e.detail),r.showChecklist()},onVisibleChange:a,buttonRef:u,text:d.launcherText,uncompletedCount:n(t)})};export default g;export{g as ChecklistApp};
|
package/ChecklistUI.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{E as t,
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{E as t,x as s}from"./userflow.js";import{u as l}from"./client-context.js";import{u as o}from"./vendor.react-i18next.js";import{o as n}from"./vendor.obj-str.js";import{a as c,A as a,L as r,d as u}from"./Icons.js";import{h as i,a as b,r as m,R as d}from"./BubbleToolbar.js";import{a as k}from"./flow-condition-types.js";const f=e.forwardRef((({elProps:t,onClick:s,onCheckmarkClick:l,completed:o,disabled:r,name:u,text:i,active:b,htmlAttributes:m,children:d},k)=>{const f=e.useRef(o);return e.createElement("button",{...t,ref:k,"data-testid":"bubble-task",tabIndex:s?0:-1,className:n({"userflowjs-bubble-task":!0,"userflowjs-bubble-task--completed":!!o,"userflowjs-bubble-task--just-completed":!f.current&&!!o,"userflowjs-bubble-task--disabled":!o&&!!r,"userflowjs-bubble-task--clickable":!!s,"userflowjs-bubble-task--active":!!b}),onClick:s,...m},e.createElement("div",{className:"userflowjs-bubble-task__checkmark",onClick:l},o&&e.createElement(c,null)),e.createElement("div",{className:"userflowjs-bubble-task__content"},e.createElement("div",{className:"userflowjs-bubble-task__name"},u),e.createElement("div",{className:"userflowjs-bubble-task__text"},i)),e.createElement("div",{className:"userflowjs-bubble-task__arrow"},!o&&e.createElement("div",{className:"userflowjs-rtl-mirrored"},e.createElement(a,null))),d)})),E=({task:t,previousTasksCompleted:s})=>{const o=l(),{session:n}=R(),c=n.version.checklist,[a,r]=e.useState((()=>o.taskIsUnacked(t.cvid)));e.useEffect((()=>{if(!a)return;const e=window.setTimeout((()=>r(!1)),500);return()=>window.clearTimeout(e)}),[a]);const u=n.taskCompletions.some((({taskCvid:e})=>e===t.cvid)),m=!a&&u;e.useEffect((()=>{m&&o.ackCompletedTask(t.cvid)}),[o,m,t.cvid]);const d=c.completeInOrder&&!s,E=d||0===t.actions.length&&m?void 0:()=>{o.send({kind:"ClickChecklistTask",sessionId:n.id,taskCvid:t.cvid},{batch:!0}),t.actions.length>0&&(m||!t.completesOnClick)&&o.hideChecklist(),i(o,n,t.actions)};return e.createElement(f,{onClick:E,name:e.createElement(b,{doc:t.name,lookupAttribute:k(n.data)}),text:e.createElement(b,{doc:t.text,lookupAttribute:k(n.data)}),completed:m,disabled:d})},p=({completedCount:t,taskCount:s})=>{const l=0===s?0:Math.min(100,Math.round(t/s*100));return e.createElement("div",{className:"userflowjs-bubble-checklist-progress"},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-bg"},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},l,"%")),e.createElement("div",{className:"userflowjs-bubble-checklist-progress-fill",style:{width:`${l}%`}},e.createElement("div",{className:"userflowjs-bubble-checklist-progress-text"},l,"%")))},w=()=>{const{t:c}=o(),a=l(),i=R(),{session:b}=i,{version:f}=b,w=f.checklist,{dispatch:v}=F(),j=b.taskCompletions.length,C=w.tasks.length,h=j===C;let N=!0,x=w.tasks,S=[],g=i.currentSectionName,y=!1;if(w.sectionsEnabled){let e=null;const t=Array.from(w.tasks).sort(((e,t)=>e.sectionName.localeCompare(t.sectionName)));for(const s of t)s.sectionName!==e&&(S.push(s.sectionName),e=s.sectionName);g&&S.includes(g)||(g=S[0]),x=t.filter((e=>e.sectionName===g)),y=x.some((e=>{const t=b.taskCompletions.some((({taskCvid:t})=>t===e.cvid));return e.blocksNextSection&&!t}))}const _=null==g?-1:S.indexOf(g),T=e=>{const t=_+e;if(t>=0&&t<=S.length-1){const e=S[t];s.setItem("currentChecklistSectionName:"+b.id,e),v({kind:"setCurrentSection",sectionName:e})}};return e.createElement(e.Fragment,null,!m(w.content)&&e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement(d,{doc:w.content,lookupAttribute:k(b.data)})),e.createElement(p,{completedCount:j,taskCount:C}),w.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-name"},g||"First section"),e.createElement("div",{className:"userflowjs-bubble-tasks"},x.map((t=>{const s=N;return b.taskCompletions.some((({taskCvid:e})=>e===t.cvid))||(N=!1),e.createElement(E,{key:t.id,task:t,previousTasksCompleted:s})}))),w.sectionsEnabled&&e.createElement("div",{className:"userflowjs-bubble-section-buttons"},e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>T(-1),disabled:_<=0},e.createElement(r,null),e.createElement("span",null,c("checklist.previousSection"))),e.createElement("button",{className:"userflowjs-bubble-section-button",onClick:()=>T(1),disabled:_>=S.length-1||y},e.createElement("span",null,c("checklist.nextSection")),e.createElement(u,null))),!f.closeDisabled&&e.createElement("div",{className:"userflowjs-bubble-dismiss-row"},e.createElement("button",{className:n({"userflowjs-bubble-dismiss-button":!0,"userflowjs-bubble-dismiss-button--completed":h}),onClick:()=>h?a.endFlow(b,{endReason:t.USER_CLOSED}):v({kind:"showClose"})},c("checklistDismiss.button"))))},v=()=>{const{t:s}=o(),n=l(),{dispatch:c}=F(),{session:a}=R();return e.createElement("div",{role:"alert"},e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("p",null,e.createElement("b",null,s("checklistDismiss.title")),e.createElement("br",null),s("checklistDismiss.text"))),e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--primary",onClick:()=>n.endFlow(a,{endReason:t.USER_CLOSED})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},s("checklistDismiss.yes"))),e.createElement("button",{className:"userflowjs-bubble-button userflowjs-bubble-button--default",onClick:()=>c({kind:"showFlow"})},e.createElement("div",{className:"userflowjs-bubble-button-text",role:"presentation"},s("checklistDismiss.cancel")))))};function j(e){const t=e?.querySelector(".userflowjs-bubble-task--clickable:not(.userflowjs-bubble-task--completed)")||e?.querySelector(".userflowjs-bubble-task--clickable")||e?.querySelector('button:not([tabIndex="-1"])');t&&"function"==typeof t.focus&&t.focus()}const C=({session:t,initialAutoFocus:o})=>{const n=l(),c=e.useRef(null),[a,r]=e.useReducer(N,void 0,(()=>({...h,session:t,currentSectionName:s.getItem("currentChecklistSectionName:"+t.id),autoFocusRequested:!!o}))),{session:u,contentType:i}=a;e.useEffect((()=>{u!==t&&r({kind:"updateSession",session:t})}),[u,t]);const b=e.useMemo((()=>({dispatch:r})),[r]);return e.useEffect((()=>{if(!a.autoFocusRequested)return;const e=c.current;e&&j(e),r({kind:"autoFocused"})}),[n,a.autoFocusRequested]),e.createElement(x.Provider,{value:b},e.createElement(S.Provider,{value:a},e.createElement("div",{ref:c},"close"===i?e.createElement(v,null):e.createElement(w,null))))},h={contentType:"flow"};function N(e,t){switch(t.kind){case"updateSession":return{...e,session:t.session};case"showFlow":return{...e,contentType:"flow",autoFocusRequested:!0};case"showClose":return{...e,contentType:"close",autoFocusRequested:!0};case"setCurrentSection":return{...e,currentSectionName:t.sectionName};case"autoFocused":return{...e,autoFocusRequested:!1}}}const x=e.createContext(null),S=e.createContext(null);function F(){return e.useContext(x)}function R(){return e.useContext(S)}export{C,j as f};
|
package/FlowApp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{E as t,V as o,x as n,b as s,T as r,w as l,y as a,q as i,A as c,M as u,U as d}from"./userflow.js";import{m as p,d as m,R as f,B as b,i as h,g as w,u as g,c as E,h as v,S as k}from"./BubbleToolbar.js";import{a as y,z as j,g as T,n as R,r as S}from"./flow-condition-types.js";import{u as L,i as M}from"./client-context.js";import{u as x,r as F,F as C}from"./FlowChrome.js";import{e as N,f as I,g as B}from"./Icons.js";import{T as D}from"./Trigger.js";import{u as P}from"./vendor.react-i18next.js";import{u as q}from"./stylesheets.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.react-fontawesome.js";import"./vendor.fortawesome.fontawesome-svg-core.js";import"./vendor.prop-types.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./logomark.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.babel.runtime.js";const A=()=>{const{t:o}=P(),n=L(),{dispatch:s,restart:r}=re(),{session:l,step:a}=le(),i="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return e.createElement("div",{role:"dialog","aria-modal":oe(a)?"true":void 0,"aria-label":"Guide menu"},e.createElement("div",{className:"userflowjs-bubble-menu__title"},o("menu.title")),e.createElement("button",{className:i,onClick:()=>n.endFlow(l,{endReason:t.USER_CLOSED})},o("menu.close")),l.version.restartEnabled&&e.createElement("button",{className:i,onClick:r},o("menu.restart")),e.createElement("button",{className:i,onClick:()=>s({kind:"showFlow"})},o("menu.back")))},_=({progress:t})=>{const o={width:100*parseFloat(t||"0")+"%"};return e.createElement("div",{className:"userflowjs-bubble-progress"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",style:o}))},O=()=>{const s=L(),{session:r,step:l,muted:a,shouldLabelDialog:i}=le(),{version:c}=r,u=l.theme||r.version.theme,{dispatch:d}=re(),h=c.steps[0],w=h&&h.id===l.id,g=w&&"1"===l.progress,E=e.useMemo((()=>l.content&&p(m(l.content),{buttons:l.buttons,questions:l.questions})),[l.content,l.buttons,l.questions]);return e.createElement("div",{key:l.id,role:"alertdialog","aria-modal":oe(l)?"true":void 0,"aria-label":i?"Guide":void 0},!g&&e.createElement(_,{progress:l.progress}),e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement(f,{doc:E,lookupAttribute:y(r.data),buttons:l.buttons,questions:l.questions})),e.createElement(b,{draftMode:r.draftMode,muted:a,toggleMuted:u.voiceType!==o.NONE?()=>d({kind:"toggleMuted"}):void 0,close:c.closeDisabled?void 0:()=>u.flowXButtonBehavior===n.DISMISS||w?s.endFlow(r,{endReason:t.USER_CLOSED}):d({kind:"showMenu"})}))};function U(e,t){if(!e)return"";"string"==typeof e&&(e=m(e));const o=[],n=/[.!?;,]$/;function s(){const e=(o[o.length-1]||"").trim();e&&!e.match(n)&&o.push(".")}function r(e){e.forEach((e=>function(e){if(h(e)){if(e.text&&!e.silent){const t=e.text.split("\n");t.forEach(((e,n)=>{o.push(e),n<t.length-1&&(s(),o.push("\n"))}))}}else switch(e.type){case"attribute":{const n=w(e,t);n&&o.push(n);break}default:r(e.children),["link"].includes(e.type)||(s(),o.push("\n\n"))}}(e)))}return r(e.children),o.join("").trim().replace(new RegExp(String.fromCharCode(160),"g")," ").replace(new RegExp(String.fromCharCode(8),"g"),"")}const V=({bubbleFrame:t,theme:n})=>{const s=L(),{dispatch:r}=re(),{muted:l,session:a,step:i}=le(),c=s.getAudio();e.useEffect((()=>{const e=()=>{r({kind:"speechPlaying"})},t=()=>{r({kind:"speechStopped"})};return c.addEventListener("playing",e),c.addEventListener("ended",t),c.addEventListener("pause",t),()=>{c.removeEventListener("playing",e),c.removeEventListener("ended",t),c.removeEventListener("pause",t),c.pause(),c.src="",r({kind:"speechStopped"})}}),[r,c]),e.useEffect((()=>{if(s.audioReady)return;const e=t&&"IFRAME"===t.tagName?t.contentWindow:null;const o=()=>{window.removeEventListener("mousedown",n),e&&e.removeEventListener("mousedown",n)},n=()=>{o(),s.playAudio(null)};return window.addEventListener("mousedown",n),e&&e.addEventListener("mousedown",n),o}),[t,s]);const u=e.useRef(a),d=e.useRef(n),p=e.useRef(i);return e.useEffect((()=>{u.current=a,d.current=n,p.current=i}),[a,n,i]),e.useEffect((()=>{if(!s.audioReady||l)return void s.pauseAudio();let e=!1;return async function(e,t,n,s){if(n.voiceType===o.SYNTHETIC&&"string"==typeof n.syntheticVoice&&s.content){e.ensureIdentified();const o=y(t.data),r=U(s.content,o);return e.getStepSpeech(n.syntheticVoice,r)}if(n.voiceType===o.MANUAL&&s.speechAsset)return s.speechAsset.assetUrl;return null}(s,u.current,d.current,p.current).then((t=>{t&&!e&&s.playAudio(t)})),()=>{e=!0}}),[l,s,i.id]),null};const Y=e.forwardRef(((t,o)=>{const n=N();return e.createElement("div",{ref:o,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:n+2}},e.createElement(I,null))}));function z(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-out-of-viewport-pointer--visible",null!=t),t&&(o.style.left=t.left+"px",o.style.top=t.top+"px",o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-up","up"===t.direction),o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-down","down"===t.direction)))}const G=()=>{const{step:t}=le();return e.createElement(e.Fragment,null,t.beacons.map((t=>e.createElement(X,{key:t.id,beacon:t}))))},X=({beacon:t})=>{const{session:o}=le(),n=N(),s=e.useRef(null),r=e.useRef(null),l=g(t.hiddenCondition),a=e.useMemo((()=>R(t.selector,o.data)),[t.selector,o.data]),i=e.useCallback((({targetRect:e,clipEl:o,viewportClipRect:n})=>{const l=function({beacon:e,beaconRef:t,clipEl:o,viewportClipRect:n,targetRect:s}){if(!t.current)return null;if(0===s.width||0===s.height)return null;const r=16,l=16,a=S(o);let i=0,c=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=s.left;break;case"top":case"center":case"bottom":i=s.left+s.width/2;break;default:i=s.left+s.width}switch(e.placement){case"left":case"center":case"right":c=s.top+s.height/2;break;case"bottom-left":case"bottom":case"bottom-right":c=s.top+s.height;break;default:c=s.top}i-=r/2,c-=l/2,i+=e.offsetX,c+=e.offsetY,i=Math.max(i,a.left-(o===document.documentElement?0:o.scrollLeft)),c=Math.max(c,a.top-(o===document.documentElement?0:o.scrollTop));const u=i+r,d=c+l,p=Math.min(32,.5*l);let m;m=d<n.top+p?"up":c>n.bottom-p?"down":null;return{top:c,right:u,bottom:d,left:i,width:r,height:l,pointerSubjectPosition:{direction:m,left:i,width:r},visible:null==m}}({beacon:t,beaconRef:s,clipEl:o,viewportClipRect:n,targetRect:e}),a=l&&function({subjectPosition:e,pointerRef:t,viewportClipRect:o}){const n=t.current;if(!n)return null;const s=n.getBoundingClientRect(),r=j(T());let l,a,i=e.direction;return null==i?null:("down"===i&&o.bottom<s.height/2?i="up":"up"===i&&o.top>r&&(i="down"),l=e.left+e.width/2-s.width/2,a="down"===i?o.bottom-s.height:o.top,{direction:i,left:l,top:a})}({subjectPosition:l.pointerSubjectPosition,pointerRef:r,viewportClipRect:n});F((()=>{H(s,l),z(r,a)}))}),[t]),c=e.useCallback((()=>{H(s,null),z(r,null)}),[]);return x({selector:l?null:a,targetMoved:i,targetLost:c}),e.createElement(e.Fragment,null,e.createElement("div",{ref:s,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},e.createElement("div",{className:"userflowjs-beacon__ring"}),e.createElement("div",{className:"userflowjs-beacon__ring"})),e.createElement(Y,{ref:r}))};function H(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-fixed-widget--visible",null!=t),t&&(o.style.transform=`translate3d(${t.left}px, ${t.top}px, 0)`,o.style.visibility=t.visible?"visible":"hidden"))}const W=()=>{const{t:o}=P(),n=L(),{restart:l}=re(),{session:a,step:i}=le(),c=i.theme||a.version.theme,u=i.selector,d=!u||u.type===s.AUTO&&!u.autoData,p=()=>n.endFlow(a,{endReason:t.USER_CLOSED});return e.createElement(e.Fragment,null,e.createElement(b,{draftMode:a.draftMode,close:p}),a.draftMode&&d?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.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 ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name),".")):a.draftMode&&c.tooltipMissingBehavior===r.END?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("p",null,e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found within"," ",c.tooltipMissingToleranceSeconds," ",1===parseFloat(c.tooltipMissingToleranceSeconds)?"second":"seconds","."),e.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),e.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,"Read more in our"," ",e.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-bubble-content"},a.draftMode&&e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,e.createElement("b",null,o("tooltipTargetMissing.line1"))),e.createElement("p",null,o("tooltipTargetMissing.line2"))),e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement(E,{appearance:"primary",onClick:l,text:o("menu.restart")}),e.createElement(E,{appearance:"default",onClick:p,text:o("menu.close")}))))},$=({session:o,checklistSession:n,resourceCenterEmbedsChecklist:s})=>{const d=L(),[p,m]=e.useState(!1),[f,b]=e.useState(null),[h,w]=e.useReducer(Q,void 0,(()=>{const e=o,t=Z(e);return{...J,session:e,step:t,muted:!!l.getItem("flowsMuted"),autoFocusRequested:te(t)}})),{session:g,step:E,speechPlaying:y,contentType:j}=h,{version:T}=g,S=oe(E);let x=0;E.questions.some((e=>e.type===i.NPS))&&(x=420);const F=q(E.theme||T.theme),N=e.useMemo((()=>{let e=F.bubbleY;const t=n?.version.theme;return!s&&n&&t&&n.version.checklist?.launcherEnabled&&E.appearance===a.BUBBLE&&t.checklistLauncherPlacement===F.bubblePlacement&&(F.avatarType===c.NONE||t.checklistLauncherX<F.bubbleX+F.avatarSize)&&(e=Math.max(F.bubbleY,t.checklistLauncherY+t.checklistLauncherHeight+F.bubbleY)),{...F,bubbleWidth:Math.max(F.bubbleWidth,x),bubbleY:e}}),[s,n,E.appearance,F,x]);e.useEffect((()=>{g!==o&&w({kind:"updateSession",session:o});const e=e=>{e.session.id===g.id&&w({kind:"goToStep",stepId:e.step.id})};return d.on("gotostep",e),()=>{d.off("gotostep",e)}}),[d,g,o]);const I=e.useMemo((()=>({dispatch:w,restart:()=>{d.goToStep(g,ee(g)),w({kind:"showFlow"})}})),[d,w,g]),D=e.useMemo((()=>E.selector&&R(E.selector,g.data)),[E.selector,g.data]),P=e.useCallback((()=>{v(d,g,E.actions)}),[d,g,E.actions]);e.useEffect((()=>{h.muted?l.setItem("flowsMuted","true"):l.removeItem("flowsMuted")}),[h.muted]);const _=g.locale?g.locale.standardLocaleId:N.languageId;e.useEffect((()=>{M.changeLanguage(_)}),[_]);const[U,V]=e.useState(!1),Y=e.useCallback((e=>{V(e),e&&N.tooltipMissingBehavior===r.END&&!g.draftMode&&d.endFlow(g,{endReason:t.TOOLTIP_TARGET_MISSING})}),[d,g,N.tooltipMissingBehavior]);return e.useEffect((()=>{if(!p||!h.autoFocusRequested)return;d.originalActiveElement||d.originalActiveElement===f?.ownerDocument.defaultView?.frameElement||(d.originalActiveElement=document.activeElement);let e=f?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(e&&e.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const t=f?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");t&&(e=t)}e&&"function"==typeof e.focus&&e.focus({preventScroll:!0}),w({kind:"autoFocused"})}),[d,f,p,h.autoFocusRequested]),e.useEffect((()=>{const e=f?.ownerDocument.defaultView;if(!e)return;const t=()=>{w({kind:"focusOut"}),delete d.originalActiveElement},o=()=>{w({kind:"focusIn"})};return window.addEventListener("focusin",t),e.addEventListener("focusin",o),()=>{window.removeEventListener("focusin",t),e.removeEventListener("focusin",o)}}),[f,d]),e.useEffect((()=>{if(!S||!f)return;const e=f.ownerDocument.defaultView,o=e?e.document:document,n=e=>{if("Escape"!==e.key||T.closeDisabled){if("Tab"===e.key){const t=f.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),n=t[0],s=t[t.length-1],r=o.activeElement;e.shiftKey?r===n&&(e.preventDefault(),s.focus()):r===s&&(e.preventDefault(),n.focus())}}else d.endFlow(g,{endReason:t.USER_CLOSED})};return window.addEventListener("keydown",n),e?.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n),e?.removeEventListener("keydown",n)}}),[S,d,g,f,T.closeDisabled]),e.useEffect((()=>{if(h.scrollToTopRequested){if(f?.ownerDocument.defaultView?.frameElement){const e=f?.ownerDocument.body;e&&(e.scrollTop=0)}w({kind:"scrolledToTop"})}}),[h.scrollToTopRequested,f]),e.createElement(ne.Provider,{value:I},e.createElement(se.Provider,{value:h},e.createElement(k.Provider,{value:g},e.createElement(B,null,e.createElement(C,{company:g.flow.company,theme:N,position:"fixed",stepKey:E.crossVersionId,stepAppearance:E.appearance,width:E.width,backgroundImageUrl:"flow"===j&&!U&&E.backgroundAsset?E.backgroundAsset.assetUrl:null,tooltipSelector:D,tooltipPlacement:E.tooltipPlacement,backdrop:E.backdrop,tooltipTargetBlocked:E.tooltipTargetBlocked,backdropPadding:E.backdropPadding,onTooltipTargetClick:P,onTooltipTargetMissingChange:Y,onModalBackdropClick:E.appearance!==a.MODAL||N.modalBackdropOnclick!==u.DISMISS||T.closeDisabled?void 0:()=>d.endFlow(g,{endReason:t.USER_CLOSED}),speaking:y,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:m,bubbleFrameRootRef:b,rootChildren:t=>e.createElement(K,{...t,theme:N})},"menu"===j?e.createElement(A,null):U&&N.tooltipMissingBehavior!==r.BUBBLE?e.createElement(W,null):e.createElement(O,null))))))},K=({visible:t,bubbleFrame:o,theme:n})=>{const s=le(),{step:r}=s,l=s.session.currentStep&&s.session.currentStep.id,[a,i]=e.useState(!1),c=e.useRef(l);return e.useEffect((()=>{t?i(!0):c.current!==l&&i(!1),c.current=l}),[l,t]),e.createElement(e.Fragment,null,(t||a)&&"flow"===s.contentType&&e.createElement(e.Fragment,null,e.createElement(V,{bubbleFrame:o,theme:n}),e.createElement(G,null)),r.triggers.map((t=>e.createElement(D,{key:t.id,trigger:t}))))},J={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Q(e,t){switch(t.kind){case"updateSession":{let o;return o=t.session.id===e.session.id&&t.session.version.steps.find((({crossVersionId:t})=>t===e.step.crossVersionId))||Z(t.session),{...e,session:t.session,step:o}}case"goToStep":{const o=e.session.version.steps.find((e=>e.id===t.stepId));return o?{...e,step:o,contentType:"flow",autoFocusRequested:e.hasFocus||te(o),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 Z(e){const{currentStep:t}=e,{steps:o}=e.version;if(t){const e=o.find((({crossVersionId:e})=>e===t.crossVersionId));if(!e)throw new d("Session points to an unknown step: "+t.crossVersionId);return e}return ee(e)}function ee(e){const t=e.version.steps[0];if(!t)throw new d("Session has no current step and its version has no start step");return t}function te(e){return oe(e)}function oe(e){return e.appearance===a.MODAL||e.appearance===a.BUBBLE&&e.backdrop||e.appearance===a.TOOLTIP&&e.tooltipTargetBlocked}const ne=e.createContext(null),se=e.createContext(null);function re(){return e.useContext(ne)}function le(){return e.useContext(se)}export default $;export{$ as FlowApp,se as FlowStateContext,J as initialFlowState,oe as isStepModal,re as useFlowDispatch,le as useFlowState};
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{E as t,V as o,y as n,b as s,T as r,x as l,z as a,r as i,A as c,M as u,U as d}from"./userflow.js";import{m as p,d as m,R as f,B as b,i as h,g as w,u as g,c as E,h as v,S as k}from"./BubbleToolbar.js";import{a as y,z as j,g as T,n as R,r as S}from"./flow-condition-types.js";import{u as L,i as M}from"./client-context.js";import{u as x,r as F,F as C}from"./FlowChrome.js";import{e as N,f as I,g as B}from"./Icons.js";import{T as D}from"./Trigger.js";import{u as P}from"./vendor.react-i18next.js";import{u as q}from"./stylesheets.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.react-fontawesome.js";import"./vendor.fortawesome.fontawesome-svg-core.js";import"./vendor.prop-types.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.js";import"./vendor.i18next.js";import"./logomark.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.babel.runtime.js";const A=()=>{const{t:o}=P(),n=L(),{dispatch:s,restart:r}=re(),{session:l,step:a}=le(),i="userflowjs-bubble-button userflowjs-bubble-button--default userflowjs-bubble-menu__item";return e.createElement("div",{role:"dialog","aria-modal":oe(a)?"true":void 0,"aria-label":"Guide menu"},e.createElement("div",{className:"userflowjs-bubble-menu__title"},o("menu.title")),e.createElement("button",{className:i,onClick:()=>n.endFlow(l,{endReason:t.USER_CLOSED})},o("menu.close")),l.version.restartEnabled&&e.createElement("button",{className:i,onClick:r},o("menu.restart")),e.createElement("button",{className:i,onClick:()=>s({kind:"showFlow"})},o("menu.back")))},_=({progress:t})=>{const o={width:100*parseFloat(t||"0")+"%"};return e.createElement("div",{className:"userflowjs-bubble-progress"},e.createElement("div",{className:"userflowjs-bubble-progress__fill",style:o}))},O=()=>{const s=L(),{session:r,step:l,muted:a,shouldLabelDialog:i}=le(),{version:c}=r,u=l.theme||r.version.theme,{dispatch:d}=re(),h=c.steps[0],w=h&&h.id===l.id,g=w&&"1"===l.progress,E=e.useMemo((()=>l.content&&p(m(l.content),{buttons:l.buttons,questions:l.questions})),[l.content,l.buttons,l.questions]);return e.createElement("div",{key:l.id,role:"alertdialog","aria-modal":oe(l)?"true":void 0,"aria-label":i?"Guide":void 0},!g&&e.createElement(_,{progress:l.progress}),e.createElement("div",{id:"userflowjs-bubble-content",className:"userflowjs-bubble-content"},e.createElement(f,{doc:E,lookupAttribute:y(r.data),buttons:l.buttons,questions:l.questions})),e.createElement(b,{draftMode:r.draftMode,muted:a,toggleMuted:u.voiceType!==o.NONE?()=>d({kind:"toggleMuted"}):void 0,close:c.closeDisabled?void 0:()=>u.flowXButtonBehavior===n.DISMISS||w?s.endFlow(r,{endReason:t.USER_CLOSED}):d({kind:"showMenu"})}))};function U(e,t){if(!e)return"";"string"==typeof e&&(e=m(e));const o=[],n=/[.!?;,]$/;function s(){const e=(o[o.length-1]||"").trim();e&&!e.match(n)&&o.push(".")}function r(e){e.forEach((e=>function(e){if(h(e)){if(e.text&&!e.silent){const t=e.text.split("\n");t.forEach(((e,n)=>{o.push(e),n<t.length-1&&(s(),o.push("\n"))}))}}else switch(e.type){case"attribute":{const n=w(e,t);n&&o.push(n);break}default:r(e.children),["link"].includes(e.type)||(s(),o.push("\n\n"))}}(e)))}return r(e.children),o.join("").trim().replace(new RegExp(String.fromCharCode(160),"g")," ").replace(new RegExp(String.fromCharCode(8),"g"),"")}const V=({bubbleFrame:t,theme:n})=>{const s=L(),{dispatch:r}=re(),{muted:l,session:a,step:i}=le(),c=s.getAudio();e.useEffect((()=>{const e=()=>{r({kind:"speechPlaying"})},t=()=>{r({kind:"speechStopped"})};return c.addEventListener("playing",e),c.addEventListener("ended",t),c.addEventListener("pause",t),()=>{c.removeEventListener("playing",e),c.removeEventListener("ended",t),c.removeEventListener("pause",t),c.pause(),c.src="",r({kind:"speechStopped"})}}),[r,c]),e.useEffect((()=>{if(s.audioReady)return;const e=t&&"IFRAME"===t.tagName?t.contentWindow:null;const o=()=>{window.removeEventListener("mousedown",n),e&&e.removeEventListener("mousedown",n)},n=()=>{o(),s.playAudio(null)};return window.addEventListener("mousedown",n),e&&e.addEventListener("mousedown",n),o}),[t,s]);const u=e.useRef(a),d=e.useRef(n),p=e.useRef(i);return e.useEffect((()=>{u.current=a,d.current=n,p.current=i}),[a,n,i]),e.useEffect((()=>{if(!s.audioReady||l)return void s.pauseAudio();let e=!1;return async function(e,t,n,s){if(n.voiceType===o.SYNTHETIC&&"string"==typeof n.syntheticVoice&&s.content){e.ensureIdentified();const o=y(t.data),r=U(s.content,o);return e.getStepSpeech(n.syntheticVoice,r)}if(n.voiceType===o.MANUAL&&s.speechAsset)return s.speechAsset.assetUrl;return null}(s,u.current,d.current,p.current).then((t=>{t&&!e&&s.playAudio(t)})),()=>{e=!0}}),[l,s,i.id]),null};const Y=e.forwardRef(((t,o)=>{const n=N();return e.createElement("div",{ref:o,className:"userflowjs-out-of-viewport-pointer",style:{zIndex:n+2}},e.createElement(I,null))}));function z(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-out-of-viewport-pointer--visible",null!=t),t&&(o.style.left=t.left+"px",o.style.top=t.top+"px",o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-up","up"===t.direction),o.classList.toggle("userflowjs-out-of-viewport-pointer--visible-down","down"===t.direction)))}const G=()=>{const{step:t}=le();return e.createElement(e.Fragment,null,t.beacons.map((t=>e.createElement(X,{key:t.id,beacon:t}))))},X=({beacon:t})=>{const{session:o}=le(),n=N(),s=e.useRef(null),r=e.useRef(null),l=g(t.hiddenCondition),a=e.useMemo((()=>R(t.selector,o.data)),[t.selector,o.data]),i=e.useCallback((({targetRect:e,clipEl:o,viewportClipRect:n})=>{const l=function({beacon:e,beaconRef:t,clipEl:o,viewportClipRect:n,targetRect:s}){if(!t.current)return null;if(0===s.width||0===s.height)return null;const r=16,l=16,a=S(o);let i=0,c=0;switch(e.placement){case"top-left":case"left":case"bottom-left":i=s.left;break;case"top":case"center":case"bottom":i=s.left+s.width/2;break;default:i=s.left+s.width}switch(e.placement){case"left":case"center":case"right":c=s.top+s.height/2;break;case"bottom-left":case"bottom":case"bottom-right":c=s.top+s.height;break;default:c=s.top}i-=r/2,c-=l/2,i+=e.offsetX,c+=e.offsetY,i=Math.max(i,a.left-(o===document.documentElement?0:o.scrollLeft)),c=Math.max(c,a.top-(o===document.documentElement?0:o.scrollTop));const u=i+r,d=c+l,p=Math.min(32,.5*l);let m;m=d<n.top+p?"up":c>n.bottom-p?"down":null;return{top:c,right:u,bottom:d,left:i,width:r,height:l,pointerSubjectPosition:{direction:m,left:i,width:r},visible:null==m}}({beacon:t,beaconRef:s,clipEl:o,viewportClipRect:n,targetRect:e}),a=l&&function({subjectPosition:e,pointerRef:t,viewportClipRect:o}){const n=t.current;if(!n)return null;const s=n.getBoundingClientRect(),r=j(T());let l,a,i=e.direction;return null==i?null:("down"===i&&o.bottom<s.height/2?i="up":"up"===i&&o.top>r&&(i="down"),l=e.left+e.width/2-s.width/2,a="down"===i?o.bottom-s.height:o.top,{direction:i,left:l,top:a})}({subjectPosition:l.pointerSubjectPosition,pointerRef:r,viewportClipRect:n});F((()=>{H(s,l),z(r,a)}))}),[t]),c=e.useCallback((()=>{H(s,null),z(r,null)}),[]);return x({selector:l?null:a,targetMoved:i,targetLost:c}),e.createElement(e.Fragment,null,e.createElement("div",{ref:s,className:"userflowjs-beacon userflowjs-beacon--pulse userflowjs-beacon--for-flow userflowjs-fixed-widget",style:{zIndex:n+2}},e.createElement("div",{className:"userflowjs-beacon__ring"}),e.createElement("div",{className:"userflowjs-beacon__ring"})),e.createElement(Y,{ref:r}))};function H(e,t){const o=e.current;o&&(o.classList.toggle("userflowjs-fixed-widget--visible",null!=t),t&&(o.style.transform=`translate3d(${t.left}px, ${t.top}px, 0)`,o.style.visibility=t.visible?"visible":"hidden"))}const W=()=>{const{t:o}=P(),n=L(),{restart:l}=re(),{session:a,step:i}=le(),c=i.theme||a.version.theme,u=i.selector,d=!u||u.type===s.AUTO&&!u.autoData,p=()=>n.endFlow(a,{endReason:t.USER_CLOSED});return e.createElement(e.Fragment,null,e.createElement(b,{draftMode:a.draftMode,close:p}),a.draftMode&&d?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.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 ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name),".")):a.draftMode&&c.tooltipMissingBehavior===r.END?e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("p",null,e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found within"," ",c.tooltipMissingToleranceSeconds," ",1===parseFloat(c.tooltipMissingToleranceSeconds)?"second":"seconds","."),e.createElement("p",null,"For regular users, the flow will auto-dismiss when this happens."),e.createElement("p",null,"If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,"Read more in our"," ",e.createElement("a",{href:"https://userflow.com/docs/trouble/element-not-found",target:"_blank",rel:"noopener noreferrer"},"Element not found guide"),"."))):e.createElement(e.Fragment,null,e.createElement("div",{className:"userflowjs-bubble-content"},a.draftMode&&e.createElement("div",{className:"userflowjs-bubble-alert p-like"},e.createElement("span",{className:"userflowjs-bubble-alert__label"},"Preview-only tip"),"The tooltip target element in ",e.createElement("b",null,"Step ",i.idx+1)," of"," ",e.createElement("b",null,a.flow.name)," was not found on the page. If you are on the right page, then try reselecting the element in the Builder."),e.createElement("p",null,e.createElement("b",null,o("tooltipTargetMissing.line1"))),e.createElement("p",null,o("tooltipTargetMissing.line2"))),e.createElement("div",{className:"userflowjs-bubble-buttons"},e.createElement(E,{appearance:"primary",onClick:l,text:o("menu.restart")}),e.createElement(E,{appearance:"default",onClick:p,text:o("menu.close")}))))},$=({session:o,checklistSession:n,resourceCenterEmbedsChecklist:s})=>{const d=L(),[p,m]=e.useState(!1),[f,b]=e.useState(null),[h,w]=e.useReducer(Q,void 0,(()=>{const e=o,t=Z(e);return{...J,session:e,step:t,muted:!!l.getItem("flowsMuted"),autoFocusRequested:te(t)}})),{session:g,step:E,speechPlaying:y,contentType:j}=h,{version:T}=g,S=oe(E);let x=0;E.questions.some((e=>e.type===i.NPS))&&(x=420);const F=q(E.theme||T.theme),N=e.useMemo((()=>{let e=F.bubbleY;const t=n?.version.theme;return!s&&n&&t&&n.version.checklist?.launcherEnabled&&E.appearance===a.BUBBLE&&t.checklistLauncherPlacement===F.bubblePlacement&&(F.avatarType===c.NONE||t.checklistLauncherX<F.bubbleX+F.avatarSize)&&(e=Math.max(F.bubbleY,t.checklistLauncherY+t.checklistLauncherHeight+F.bubbleY)),{...F,bubbleWidth:Math.max(F.bubbleWidth,x),bubbleY:e}}),[s,n,E.appearance,F,x]);e.useEffect((()=>{g!==o&&w({kind:"updateSession",session:o});const e=e=>{e.session.id===g.id&&w({kind:"goToStep",stepId:e.step.id})};return d.on("gotostep",e),()=>{d.off("gotostep",e)}}),[d,g,o]);const I=e.useMemo((()=>({dispatch:w,restart:()=>{d.goToStep(g,ee(g)),w({kind:"showFlow"})}})),[d,w,g]),D=e.useMemo((()=>E.selector&&R(E.selector,g.data)),[E.selector,g.data]),P=e.useCallback((()=>{v(d,g,E.actions)}),[d,g,E.actions]);e.useEffect((()=>{h.muted?l.setItem("flowsMuted","true"):l.removeItem("flowsMuted")}),[h.muted]);const _=g.locale?g.locale.standardLocaleId:N.languageId;e.useEffect((()=>{M.changeLanguage(_)}),[_]);const[U,V]=e.useState(!1),Y=e.useCallback((e=>{V(e),e&&N.tooltipMissingBehavior===r.END&&!g.draftMode&&d.endFlow(g,{endReason:t.TOOLTIP_TARGET_MISSING})}),[d,g,N.tooltipMissingBehavior]);return e.useEffect((()=>{if(!p||!h.autoFocusRequested)return;d.originalActiveElement||d.originalActiveElement===f?.ownerDocument.defaultView?.frameElement||(d.originalActiveElement=document.activeElement);let e=f?.querySelector('button:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), [tabindex]:not([tabindex="-1"]):not(.userflowjs-bubble-toolbar-button), input, textarea');if(e&&e.matches(".userflowjs-bubble-buttons button:not(.userflowjs-bubble-button--primary)")){const t=f?.querySelector(".userflowjs-bubble-buttons .userflowjs-bubble-button--primary");t&&(e=t)}e&&"function"==typeof e.focus&&e.focus({preventScroll:!0}),w({kind:"autoFocused"})}),[d,f,p,h.autoFocusRequested]),e.useEffect((()=>{const e=f?.ownerDocument.defaultView;if(!e)return;const t=()=>{w({kind:"focusOut"}),delete d.originalActiveElement},o=()=>{w({kind:"focusIn"})};return window.addEventListener("focusin",t),e.addEventListener("focusin",o),()=>{window.removeEventListener("focusin",t),e.removeEventListener("focusin",o)}}),[f,d]),e.useEffect((()=>{if(!S||!f)return;const e=f.ownerDocument.defaultView,o=e?e.document:document,n=e=>{if("Escape"!==e.key||T.closeDisabled){if("Tab"===e.key){const t=f.querySelectorAll('button:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"]), input, textarea'),n=t[0],s=t[t.length-1],r=o.activeElement;e.shiftKey?r===n&&(e.preventDefault(),s.focus()):r===s&&(e.preventDefault(),n.focus())}}else d.endFlow(g,{endReason:t.USER_CLOSED})};return window.addEventListener("keydown",n),e?.addEventListener("keydown",n),()=>{window.removeEventListener("keydown",n),e?.removeEventListener("keydown",n)}}),[S,d,g,f,T.closeDisabled]),e.useEffect((()=>{if(h.scrollToTopRequested){if(f?.ownerDocument.defaultView?.frameElement){const e=f?.ownerDocument.body;e&&(e.scrollTop=0)}w({kind:"scrolledToTop"})}}),[h.scrollToTopRequested,f]),e.createElement(ne.Provider,{value:I},e.createElement(se.Provider,{value:h},e.createElement(k.Provider,{value:g},e.createElement(B,null,e.createElement(C,{company:g.flow.company,theme:N,position:"fixed",stepKey:E.crossVersionId,stepAppearance:E.appearance,width:E.width,backgroundImageUrl:"flow"===j&&!U&&E.backgroundAsset?E.backgroundAsset.assetUrl:null,tooltipSelector:D,tooltipPlacement:E.tooltipPlacement,backdrop:E.backdrop,tooltipTargetBlocked:E.tooltipTargetBlocked,backdropPadding:E.backdropPadding,onTooltipTargetClick:P,onTooltipTargetMissingChange:Y,onModalBackdropClick:E.appearance!==a.MODAL||N.modalBackdropOnclick!==u.DISMISS||T.closeDisabled?void 0:()=>d.endFlow(g,{endReason:t.USER_CLOSED}),speaking:y,minimizeOnAvatarClick:!0,autoHide3pEnabled:!0,onVisibleChange:m,bubbleFrameRootRef:b,rootChildren:t=>e.createElement(K,{...t,theme:N})},"menu"===j?e.createElement(A,null):U&&N.tooltipMissingBehavior!==r.BUBBLE?e.createElement(W,null):e.createElement(O,null))))))},K=({visible:t,bubbleFrame:o,theme:n})=>{const s=le(),{step:r}=s,l=s.session.currentStep&&s.session.currentStep.id,[a,i]=e.useState(!1),c=e.useRef(l);return e.useEffect((()=>{t?i(!0):c.current!==l&&i(!1),c.current=l}),[l,t]),e.createElement(e.Fragment,null,(t||a)&&"flow"===s.contentType&&e.createElement(e.Fragment,null,e.createElement(V,{bubbleFrame:o,theme:n}),e.createElement(G,null)),r.triggers.map((t=>e.createElement(D,{key:t.id,trigger:t}))))},J={muted:!1,speechPlaying:!1,contentType:"flow",autoFocusRequested:!1,hasFocus:!1,scrollToTopRequested:!1,shouldLabelDialog:!0};function Q(e,t){switch(t.kind){case"updateSession":{let o;return o=t.session.id===e.session.id&&t.session.version.steps.find((({crossVersionId:t})=>t===e.step.crossVersionId))||Z(t.session),{...e,session:t.session,step:o}}case"goToStep":{const o=e.session.version.steps.find((e=>e.id===t.stepId));return o?{...e,step:o,contentType:"flow",autoFocusRequested:e.hasFocus||te(o),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 Z(e){const{currentStep:t}=e,{steps:o}=e.version;if(t){const e=o.find((({crossVersionId:e})=>e===t.crossVersionId));if(!e)throw new d("Session points to an unknown step: "+t.crossVersionId);return e}return ee(e)}function ee(e){const t=e.version.steps[0];if(!t)throw new d("Session has no current step and its version has no start step");return t}function te(e){return oe(e)}function oe(e){return e.appearance===a.MODAL||e.appearance===a.BUBBLE&&e.backdrop||e.appearance===a.TOOLTIP&&e.tooltipTargetBlocked}const ne=e.createContext(null),se=e.createContext(null);function re(){return e.useContext(ne)}function le(){return e.useContext(se)}export default $;export{$ as FlowApp,se as FlowStateContext,J as initialFlowState,oe as isStepModal,re as useFlowDispatch,le as useFlowState};
|
package/FlowChrome.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t}from"./vendor.react.js";import{u as e,F as o,S as a}from"./logomark.js";import{c as l,y as r,A as i,b as n,z as s,B as c,D as u}from"./userflow.js";import{f as d,b as p}from"./BubbleToolbar.js";import{o as m}from"./vendor.obj-str.js";import{p as f,j as b,q as h,s as g,r as w,h as T,e as E,g as v,d as M,t as L,M as y,m as k}from"./flow-condition-types.js";import{a as j,g as R}from"./stylesheets.js";import{e as B}from"./Icons.js";import{u as O}from"./vendor.react-i18next.js";var P=new URL("avatar-frame.css",import.meta.url).href;let x=!1;const I=[];let N,_=[];function H(t){_.push(t)}function C(){I.forEach((t=>t())),_.length>0&&(_.forEach((t=>t())),_=[]),S()}function S(){x&&(N=window.requestAnimationFrame(C))}function D(){}function U({selector:e,targetMoved:o,targetLost:a,onTargetClick:l,onTargetMouseEnter:r,onTargetMouseLeave:i}){const n=t.useRef(o),s=t.useRef(a),c=t.useRef(l),u=t.useRef(r),d=t.useRef(i);t.useLayoutEffect((()=>{n.current=o,s.current=a,c.current=l,u.current=r,d.current=i})),t.useLayoutEffect((()=>{let t=null,o=null,a=null,l=!1;const r=()=>{t=null,o=null,a=null,s.current()};if(!e)return void r();const i=()=>{if(!a||!t)return;const e=w(t);var l,i;o&&(i=e,(l=o).left===i.left&&l.top===i.top&&l.width===i.width&&l.height===i.height)||(o=e,0===e.width&&0===e.height?r():n.current({targetEl:t,targetRect:o,clipEl:a,viewportClipRect:F(a)}))};let p=!1;const m=()=>{var t;p||(p=!0,t=i,I.push(t),1===I.length&&(x=!0,S(),window.addEventListener("scroll",D)))},T=()=>{p&&(p=!1,function(t){const e=I.indexOf(t);e>=0&&(I.splice(e,1),0===I.length&&(x=!1,window.cancelAnimationFrame(N),window.removeEventListener("scroll",D)))}(i))},E=()=>{c.current&&c.current()},v=()=>{u.current&&u.current()},M=()=>{d.current&&d.current()},L=()=>{const o=t;t=b(e)?e:h(e),l&&t===o||(o&&(o.removeEventListener("click",E),o.removeEventListener("mouseenter",v),o.removeEventListener("mouseleave",M)),t?(m(),t.addEventListener("click",E),t.addEventListener("mouseenter",v),t.addEventListener("mouseleave",M),a=g(t)):(T(),r())),l=!0};L();const y=f(L);return()=>{y.disconnect(),T(),t&&(t.removeEventListener("click",E),t.removeEventListener("mouseenter",v),t.removeEventListener("mouseleave",M))}}),[e])}function F(t){T();const e=E(v()),o=E(M());if(t&&t!==document.documentElement){const a=w(t);return{top:Math.max(0,a.top),right:Math.min(o,a.right),bottom:Math.min(e,a.bottom),left:Math.max(0,a.left)}}return{top:0,right:o,bottom:e,left:0}}const A=({company:f,theme:h,position:w,absoluteWidth:x,absoluteHeight:I,stepKey:N,stepAppearance:_,width:H,backgroundImageUrl:C,tooltipSelector:S,allowMissingTooltipTarget:D,tooltipPlacement:F,backdrop:A,tooltipTargetBlocked:K,backdropPadding:q,zIndex:Y,onTooltipTargetClick:X,onTooltipTargetMissingChange:J,onModalBackdropClick:Q,onVisibleChange:Z,speaking:tt,noIframe:et,MadeWithUserflow:ot,minimizeOnAvatarClick:at,autoHide3pEnabled:lt,bubbleFrameRootRef:rt,frameWrapperHtmlAttributes:it,rootChildren:nt,children:st})=>{const ct=w||"absolute",ut=F||null,dt=q||"0",pt=ot||z,mt=B(),ft="fixed"===ct?null!=Y?Y:mt+1:1,bt=ft-1,{i18n:ht}=O(),gt=ht.dir(),wt=t.useRef(null),Tt=t.useRef(null),Et=t.useRef(null),[vt,Mt]=t.useState(null),Lt=t.useRef(null),yt=t.useRef(null),kt=t.useRef(null),jt=t.useRef(null),Rt=t.useRef(null),Bt=t.useRef(null),Ot=t.useRef(null),Pt=t.useRef(null),xt=t.useRef(null);t.useLayoutEffect((()=>{const t=wt.current.style;t.animation="none",t.visibility="hidden",t.position="absolute",t.top="-99999px",t.left="-99999px"}),[]);const{loaded:It}=j(window,d,h),[Nt,_t]=t.useState(!1),[Ht,Ct]=t.useState(!1),St=It&&Nt&&Ht;let[Dt,Ut]=t.useState(!1);_!==r.BUBBLE&&(at=!1,Dt=!1),t.useEffect((()=>{Ut(!1)}),[N]);const Ft=t.useRef({appearance:null,width:null,theme:h,bubbleFrameHeight:0,backdrop:!1,backdropPadding:"0",prevTooltipTargetParams:null,tooltipTargetParams:null,desiredTooltipPlacement:null,tooltipPlacement:null,lastReportedTooltipTargetMissing:!1,tooltipTargetMissing:!1,tooltipTargetMissingTimeout:void 0,stepKeyScrolledIntoView:void 0,targetScrolledIntoView:null}),[At,Wt]=t.useState(null),zt=null!=At&&St;t.useEffect((()=>{Z&&Z(zt)}),[Z,zt]);const Vt=t.useCallback((t=>{Ft.current.lastReportedTooltipTargetMissing!==t&&(Ft.current.lastReportedTooltipTargetMissing=t,J&&J(t))}),[J]),Gt=t.useCallback((({forceAppearanceLayout:t,forceUpdatePosition:e}={})=>{const o=wt.current,a=Tt.current,n=Et.current,d=yt.current,p=Lt.current,m=kt.current,f=jt.current,b=Rt.current,w=Bt.current,y=Ot.current,j=Pt.current,R=xt.current;if(!(o&&a&&n&&vt&&d&&p&&m&&f&&b&&w&&y&&j&&R))return;if(!St)return;const B=Ft.current,{tooltipTargetParams:O}=B;T();let P=_,C=!1;P!==r.TOOLTIP||D||O||(B.tooltipTargetMissing?(P=r.BUBBLE,C=!0):P=null);const S=P!==B.appearance,U=H!==B.width;if((t||S||U||h!==B.theme||A!=B.backdrop||dt!=B.backdropPadding||ut!==B.desiredTooltipPlacement)&&(B.appearance=P,B.width=H,B.theme=h,B.backdrop=A,B.backdropPadding=dt,B.desiredTooltipPlacement=ut,e=!0,function({layoutState:{appearance:t,theme:e,backdrop:o,tooltipTargetMissing:a},width:l,position:n,absoluteWidth:c,root:u,bubble:d,bubbleFrameRoot:p,avatar:m,avatarNotch:f,modalBackdrop:b,dir:h}){const g="absolute"===n?c||1024:E(M()),{avatarSize:w,bubblePlacement:T}=e;let v=e.bubbleWidth,L=null,y=null,k="userflowjs-bubble-frame-root",j="hidden",R=null,B=null,O=null,P=null,x="userflowjs-bubble__avatar-notch",I="hidden",N=null,_=null,H=null,C=null,S="userflowjs-modal-backdrop";(t===r.MODAL||!a&&t===r.BUBBLE&&o)&&(S+=" userflowjs-modal-backdrop--visible");switch(t){case r.BUBBLE:if(e.avatarType!==i.NONE){j="",I="",T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.TOP_RIGHT?(L=w+20,R=0,N=-40,x+=" userflowjs-bubble__avatar-notch--top"):(y=w+20,O=0,H=-40,x+=" userflowjs-bubble__avatar-notch--bottom");const t=T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.BOTTOM_LEFT||T===s.BOTTOM_CENTER||T===s.CENTER;"ltr"===h&&t||"rtl"===h&&!t?(P=0,C=w,x+=" userflowjs-bubble__avatar-notch--left"):(B=0,_=w,x+=" userflowjs-bubble__avatar-notch--right")}break;case r.MODAL:v=e.modalWidth,k+=" userflowjs-bubble-frame-root--appearance-modal",e.avatarType!==i.NONE&&(j="",P=`calc(50% - ${w/2}px)`,R=-w/2);break;case r.TOOLTIP:v=e.tooltipWidth}null!=l&&(v=l);v=Math.min(v,g),u.classList.toggle("userflowjs-flow-chrome--position-absolute","absolute"===n),u.classList.toggle("userflowjs-flow-chrome--position-relative","relative"===n),u.classList.toggle("userflowjs-flow-chrome--position-fixed","fixed"===n),u.classList.toggle("userflowjs-flow-chrome--appearance-modal",t===r.MODAL);const D=null!=t&&t!==r.HIDDEN;u.style.position="",u.style.top="",u.style.left="",u.style.visibility=D?"":"hidden",u.style.animation=D?"":"none",V(d,"width",E(v)),V(d,"padding-top",L),V(d,"padding-bottom",y),p.className=k,V(m,"width",E(e.avatarSize)),V(m,"height",E(e.avatarSize)),m.style.visibility=j,V(m,"top",R),V(m,"right",B),V(m,"bottom",O),V(m,"left",P),f.className=x,f.style.visibility=I,V(f,"top",N),V(f,"right",_),V(f,"bottom",H),V(f,"left",C),b.className=S}({layoutState:B,width:H,position:ct,absoluteWidth:x,root:o,bubble:a,bubbleFrameRoot:vt,avatar:d,avatarNotch:p,modalBackdrop:R,dir:gt})),!et){const t=vt.offsetHeight,o=v()-2*(M()<800?0:16)-(P===r.BUBBLE&&h.avatarType!==i.NONE?20+h.avatarSize:0),a=Math.min(t,o);if(P&&a!==B.bubbleFrameHeight){if(B.bubbleFrameHeight=a,V(n,"height",E(a)),L(n)&&n.contentDocument){n.contentDocument.documentElement.style.overflowY=t<=o?"hidden":"scroll"}e=!0}}if(e&&P){let t=S;if(P===r.TOOLTIP){(B.tooltipTargetParams&&B.tooltipTargetParams.targetEl)!==(B.prevTooltipTargetParams&&B.prevTooltipTargetParams.targetEl)&&(t=!0)}B.prevTooltipTargetParams=B.tooltipTargetParams,function({layoutState:t,animateIn:e,position:o,absoluteWidth:a,absoluteHeight:l,desiredTooltipPlacement:i,root:n,bubble:d,tooltipNotch:p,tooltipBackdrop:m,tooltipBlockTop:f,tooltipBlockRight:b,tooltipBlockBottom:h,tooltipBlockLeft:g,dir:w}){const{appearance:T,theme:L,tooltipTargetParams:y,backdrop:j,backdropPadding:R}=t,{bubblePlacement:B}=L,O=16,P=L.tooltipNotchSize,x=10,{width:I,height:N}=d.getBoundingClientRect(),_="absolute"===o?a||1024:E(M()),H="absolute"===o?l||768:E(v());let C=0,S=0,D="userflowjs-bubble__tooltip-notch",U="hidden",F=null,A=null,W=null,z=null,K="userflowjs-tooltip-backdrop",q=null,Y=null,X=null,J=null,Q=null,Z=null,tt=null,et=null,ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",at=null,lt=null,rt="userflowjs-tooltip-block userflowjs-tooltip-block--right",it=null,nt=null,st="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",ct=null,ut=null,dt="userflowjs-tooltip-block userflowjs-tooltip-block--left",pt=null,mt=null;switch(T){case r.BUBBLE:C=B===s.TOP_LEFT||B===s.BOTTOM_LEFT?L.bubbleX:B===s.TOP_CENTER||B===s.CENTER||B===s.BOTTOM_CENTER?(_-I)/2:_-I-L.bubbleX,S=B===s.TOP_LEFT||B===s.TOP_CENTER||B===s.TOP_RIGHT?L.bubbleY:B===s.CENTER?(H-N)/2:H-N-L.bubbleY,"rtl"===w&&(C=_-C-I),C=Math.max(0,Math.min(_-I,C)),S=Math.max(0,Math.min(H-N,S));break;case r.MODAL:C=O+(_-2*O-I)/2,S=O+(H-2*O-N)/2;break;case r.TOOLTIP:{let e;if(y){let{targetRect:a,viewportClipRect:l}=y;if("absolute"===o){const t=n.offsetParent.getBoundingClientRect();l={top:0,right:_,bottom:H,left:0},a={top:a.top-t.top,right:a.right-t.left,bottom:a.bottom-t.top,left:a.left-t.left,width:a.width,height:a.height}}let r=0;if(j){const{paddingTop:t,paddingRight:e,paddingBottom:o,paddingLeft:l}=function(t){if(!t||"0"===t)return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const e=t.trim().split(" ");if(1===e.length){const t=$(e[0]);return{paddingTop:t,paddingRight:t,paddingBottom:t,paddingLeft:t}}if(2===e.length){const t=$(e[0]),o=$(e[1]);return{paddingTop:t,paddingRight:o,paddingBottom:t,paddingLeft:o}}return{paddingTop:$(e[0]),paddingRight:$(e[1]),paddingBottom:$(e[2]),paddingLeft:$(e[3])}}(R);a={top:a.top-t,right:a.right+e,bottom:a.bottom+o,left:a.left-l,width:a.width+l+e,height:a.height+t+o},r=Math.min(t,e,o,l)}const s=a,d=L.backdropHighlightType==c.OUTSIDE?L.backdropHighlightSpread:0;if(j&&d&&(a={top:a.top-d,right:a.right+d,bottom:a.bottom+d,left:a.left-d,width:a.width+2*d,height:a.height+2*d}),e=function({targetRect:t,bubbleWidth:e,bubbleHeight:o,containerWidth:a,containerHeight:l,viewportClipRect:r,tooltipNotchSize:i,currentTooltipPlacement:n,desiredTooltipPlacement:s}){if(t.bottom<=r.top)return o+i<=l-r.top?u.BELOW:u.ABOVE;if(t.top>=r.bottom)return o+i<=r.bottom?u.ABOVE:u.BELOW;if(t.right<=r.left)return e+i<=a-r.left?u.RIGHT:u.LEFT;if(t.left>=r.right)return e+i<=r.right?u.LEFT:u.RIGHT;const c=n=>{const s=t.left+t.width/2,c=s>=r.left&&s<=r.right,d=t.top+t.height/2,p=d>=r.top&&d<=r.bottom;switch(n){case u.BELOW:return l-t.bottom>o+i&&c;case u.ABOVE:return t.top>o+i&&c;case u.RIGHT:return a-t.right>e+i&&p;case u.LEFT:return t.left>e+i&&p}};if(s&&c(s))return s;if(n&&c(n))return n;const d=[{placement:u.BELOW,dist:t.top},{placement:u.ABOVE,dist:l-t.bottom},{placement:u.RIGHT,dist:t.left},{placement:u.LEFT,dist:a-t.right}];d.sort(((t,e)=>t.dist-e.dist));for(const{placement:u}of d)if(c(u))return u;return u.BELOW}({targetRect:a,bubbleWidth:I,bubbleHeight:N,containerWidth:_,containerHeight:H,viewportClipRect:l,tooltipNotchSize:P,currentTooltipPlacement:t.tooltipPlacement,desiredTooltipPlacement:i}),e===u.BELOW||e===u.ABOVE?(C=a.left+a.width/2-I/2,C=Math.max(O,Math.min(_-I-O,C)),z=Math.max(x,Math.min(I-x-2*P,a.left+a.width/2-P-C)),e===u.BELOW?F=2*-P:W=2*-P):e===u.RIGHT?(C=a.right+P,C=Math.max(C,l.left+P),C=Math.min(C,l.right+P),C=Math.max(C,P),C=Math.min(C,_-I)):(C=a.left-P-I,C=Math.max(C,l.left-I-P),C=Math.min(C,l.right-I-P),C=Math.max(C,0),C=Math.min(C,_-I-P)),e===u.LEFT||e===u.RIGHT?(S=a.top+a.height/2-N/2,S=Math.max(O,Math.min(H-N-O,S)),F=Math.max(x,Math.min(N-x-2*P,a.top+a.height/2-P-S)),e===u.LEFT?A=2*-P:z=2*-P):e===u.BELOW?(S=a.bottom+P,S=Math.max(S,l.top+P),S=Math.min(S,l.bottom+P),S=Math.max(S,P),S=Math.min(S,H-N)):(S=a.top-P-N,S=Math.max(S,l.top-N-P),S=Math.min(S,l.bottom-N-P),S=Math.max(S,0),S=Math.min(S,H-N-P)),j){const t=window.getComputedStyle(y.targetEl);q=Math.max(0,s.top),Y=Math.max(0,_-s.right),X=Math.max(0,H-s.bottom),J=Math.max(0,s.left),Q=Math.max(0,k(t.borderTopLeftRadius)+r),Z=Math.max(0,k(t.borderTopRightRadius)+r),tt=Math.max(0,k(t.borderBottomRightRadius)+r),et=Math.max(0,k(t.borderBottomLeftRadius)+r),at=Math.max(0,s.right),lt=Math.max(0,s.top),it=Math.max(0,s.right),nt=Math.max(0,s.bottom),ct=Math.max(0,s.left),ut=Math.max(0,s.bottom),pt=Math.max(0,s.left),mt=Math.max(0,s.top)}}else e=i||u.BELOW,e!==u.BELOW&&e!==u.ABOVE||(z=I/2-P,e===u.BELOW?F=2*-P:W=2*-P),e!==u.LEFT&&e!==u.RIGHT||(F=N/2-P,e===u.LEFT?A=2*-P:z=2*-P);t.tooltipPlacement=e,D+=` userflowjs-bubble__tooltip-notch--${e.toLowerCase()}`,U="",j&&(K+=" userflowjs-tooltip-backdrop--visible",ot+=" userflowjs-tooltip-block--visible",rt+=" userflowjs-tooltip-block--visible",st+=" userflowjs-tooltip-block--visible",dt+=" userflowjs-tooltip-block--visible");break}}d.style.transition="";let ft=C,bt=S;if(e&&(d.style.opacity="0",T===r.TOOLTIP)){const e=24;switch(t.tooltipPlacement){case u.BELOW:S+=e;break;case u.ABOVE:S-=e;break;case u.RIGHT:C+=e;break;case u.LEFT:C-=e}}"relative"!==o&&G(d,C,S);if(p.className=D,p.style.visibility=U,V(p,"top",F),V(p,"right",A),V(p,"bottom",W),V(p,"left",z),m.className=K,V(m,"top",q),V(m,"right",Y),V(m,"bottom",X),V(m,"left",J),V(m,"border-top-left-radius",Q),V(m,"border-top-right-radius",Z),V(m,"border-bottom-right-radius",tt),V(m,"border-bottom-left-radius",et),f.className=ot,V(f,"width",at),V(f,"height",lt),b.className=rt,V(b,"left",it),V(b,"height",nt),h.className=st,V(h,"left",ct),V(h,"top",ut),g.className=dt,V(g,"width",pt),V(g,"top",mt),e){d.offsetWidth;const t="opacity 250ms linear";T===r.TOOLTIP?d.style.transition=`${t}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:d.style.transition=t,d.style.opacity="1","relative"!==o&&G(d,ft,bt)}}({layoutState:B,animateIn:t,position:ct,absoluteWidth:x,absoluteHeight:I,desiredTooltipPlacement:ut,root:o,bubble:a,tooltipNotch:m,tooltipBackdrop:f,tooltipBlockTop:b,tooltipBlockRight:w,tooltipBlockBottom:y,tooltipBlockLeft:j,dir:gt})}if(P===r.TOOLTIP){const t=O&&O.targetEl;t&&B.stepKeyScrolledIntoView!==N&&B.targetScrolledIntoView!==t&&(B.stepKeyScrolledIntoView=N,B.targetScrolledIntoView=t,function(t){if(l.customScrollIntoView)return void l.customScrollIntoView(t);const{scrollPadding:e}=l;if(e&&g(t)===document.scrollingElement){const o=e.top||0,a=e.right||0,l=e.bottom||0,r=e.left||0;let i=0,n=0;const s=t.getBoundingClientRect(),c=M(),u=v();if(s.top<o?i=s.top-o:s.bottom>u-l&&(i=s.bottom-u+l),s.left<r?n=s.left-r:s.right>c-a&&(n=s.right-c+a),0!=i||0!=n)return void window.scrollBy({top:i,left:n,behavior:"smooth"})}try{t.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),t.scrollIntoView()}}(t))}else B.stepKeyScrolledIntoView=void 0,B.targetScrolledIntoView=null;Vt(C),Wt(P)}),[St,vt,N,_,H,h,ct,x,I,D,ut,A,dt,et,Vt,gt]),$t=t.useRef(Gt);$t.current=Gt;const Kt=t.useRef(!1);t.useEffect((()=>{const t=()=>{Kt.current=!0};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)}),[]);const qt=()=>{window.clearTimeout(Ft.current.tooltipTargetMissingTimeout),Ft.current.tooltipTargetMissingTimeout=void 0};t.useEffect((()=>qt),[]);const Yt=t.useCallback((()=>{const t=Ft.current;if(t.tooltipTargetParams=null,D||(t.tooltipPlacement=null),_!==r.TOOLTIP)return qt(),void(t.tooltipTargetMissing=!1);if(!D&&!t.tooltipTargetMissingTimeout){t.tooltipTargetMissing=!1;const e=!S||b(S)||S.type!==n.AUTO||S.autoData?1e3*parseFloat(h.tooltipMissingToleranceSeconds):1;t.tooltipTargetMissingTimeout=window.setTimeout((()=>{if(!Kt.current){if(S&&!b(S)){let t=S.autoData;if(S.autoData)try{t=JSON.parse(S.autoData)}catch(e){}console.warn("Userflow.js: Tooltip target not found on page.\n",{type:S.type,autoData:t,excludeText:S.excludeText,precision:S.precision,text:S.text,css:S.css})}qt(),t.tooltipTargetMissing=!0,$t.current()}}),e)}$t.current()}),[_,D,S,h.tooltipMissingToleranceSeconds]),Xt=t.useCallback((t=>{const e=Ft.current;qt(),e.tooltipTargetParams&&e.tooltipTargetParams.targetEl!==t.targetEl&&(e.tooltipPlacement=null),e.tooltipTargetParams=t,Gt({forceUpdatePosition:!0})}),[Gt]);U({selector:_===r.TOOLTIP&&S||null,targetMoved:Xt,targetLost:Yt,onTargetClick:X});const Jt=t.useCallback((()=>Gt({forceAppearanceLayout:!0})),[Gt]);e(Jt),t.useEffect((()=>{if(!vt||et||"function"!=typeof y)return;let t;const e=new y((()=>{t||(t=window.requestAnimationFrame((()=>{t=void 0,$t.current()})))}));return e.observe(vt,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect(),t&&window.cancelAnimationFrame(t)}}),[vt,et]),t.useLayoutEffect((()=>{$t.current()})),t.useLayoutEffect((()=>{"absolute"===ct&&Gt({forceAppearanceLayout:!0})}),[ct,x,I]);const Qt=t=>{t.preventDefault(),t.stopPropagation()};return function(e,o){const a=window.Intercom;t.useEffect((()=>{if(o&&e.autoHideIntercom&&"function"==typeof a&&!l.autoHide3pDisabled){try{a("update",{hide_default_launcher:!0})}catch(t){console.warn("Userflow.js: Error when hiding Intercom launcher",t)}return()=>{if(!l.autoHide3pDisabled)try{a("update",{hide_default_launcher:!1})}catch(t){console.warn("Userflow.js: Error when unhiding Intercom launcher",t)}}}}),[a,e.autoHideIntercom,o]);const r=window.$crisp;t.useEffect((()=>{if(o&&e.autoHideCrisp&&r&&!l.autoHide3pDisabled){try{r.push(["do","chat:hide"])}catch(t){console.warn("Userflow.js: Error when hiding Crisp Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{r.push(["do","chat:show"])}catch(t){console.warn("Userflow.js: Error when unhiding Crisp Chat",t)}}}}),[r,e.autoHideCrisp,o]);const i=window.HubSpotConversations;t.useEffect((()=>{if(o&&e.autoHideHubspot&&i&&!l.autoHide3pDisabled){try{i.widget.remove()}catch(t){console.warn("Userflow.js: Error when hiding HubSpot Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{i.widget.load()}catch(t){console.warn("Userflow.js: Error when unhiding HubSpot Chat",t)}}}}),[i,e.autoHideHubspot,o]);const n=window.drift;t.useEffect((()=>{if(o&&e.autoHideDrift&&n&&!l.autoHide3pDisabled){try{n.api.widget.hide()}catch(t){console.warn("Userflow.js: Error when hiding Drift Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{n.api.widget.show()}catch(t){console.warn("Userflow.js: Error when unhiding Drift Chat",t)}}}}),[n,e.autoHideDrift,o])}(h,!!lt&&At===r.BUBBLE),t.createElement("div",{ref:wt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:R(h),dir:gt},t.createElement("div",{className:"userflowjs-bubble",ref:Tt,style:{zIndex:ft}},t.createElement("div",{className:m({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(h.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!at,"userflowjs-bubble-outline--minimized":Dt})},t.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...it},t.createElement(o,{className:"userflowjs-bubble__frame",elRef:Et,stylesheetUrl:p,theme:h,onStylesheetsLoad:_t,noIframe:et},t.createElement("div",{className:"userflowjs-bubble-frame-root",dir:gt,ref:t=>{rt&&rt(t),Mt(t)},style:C?{backgroundImage:`url("${encodeURI(C)}")`}:void 0},st,f.flowBranding&&t.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},t.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},t.createElement(pt,{company:f},t.createElement(a,null),t.createElement("div",null,"Made with Userflow"))))))),t.createElement("div",{ref:Lt,className:"userflowjs-bubble__avatar-notch"})),t.createElement(o,{className:m({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!at,"userflowjs-bubble__avatar--speaking":!!tt}),elRef:yt,stylesheetUrl:P,theme:h,onStylesheetsLoad:Ct,noIframe:et,ariaHidden:!0},t.createElement("div",{className:m({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!at}),onClick:at?()=>Ut((t=>!t)):void 0},t.createElement(W,{theme:h}))),t.createElement("div",{ref:kt,className:"userflowjs-bubble__tooltip-notch"})),t.createElement("div",{ref:jt,className:"userflowjs-tooltip-backdrop",onMouseDown:Qt,style:{zIndex:bt,pointerEvents:K?void 0:"none"}}),t.createElement("div",{ref:Rt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:Ot,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:Pt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:xt,className:"userflowjs-modal-backdrop",onMouseDown:Qt,onClick:Q,style:{zIndex:bt}}),nt&&nt({visible:zt,bubbleFrame:Et.current}))},W=({theme:e})=>{const o="https://js.userflow.com/cartoon-avatars-no-bg/";let a;return a=e.avatarType===i.ASSET&&e.avatarAsset?e.avatarAsset.assetUrl:e.avatarType===i.CARTOON&&e.avatarName?o+e.avatarName+".svg?3":e.avatarType===i.URL&&e.avatarUrl?e.avatarUrl:o+"none.svg",t.createElement("img",{src:a,alt:""})},z=({company:e,children:o})=>t.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+e.slug,target:"_blank",rel:"noopener noreferrer"},o);function V(t,e,o){null==o?t.style.removeProperty(e):t.style.setProperty(e,"number"==typeof o?o+"px":o,"important")}function G(t,e,o){e=Math.round(e),o=Math.round(o),t.style.transform=`translate3d(${e}px, ${o}px, 0px)`}function $(t){const e=parseInt(t,10);return isNaN(e)?0:e}export{A as F,H as r,U as u};
|
|
1
|
+
import{r as t}from"./vendor.react.js";import{u as e,F as o,S as a}from"./logomark.js";import{c as l,z as r,A as i,b as n,D as s,B as c,G as u}from"./userflow.js";import{f as d,b as p}from"./BubbleToolbar.js";import{o as m}from"./vendor.obj-str.js";import{p as f,j as b,q as h,s as g,r as w,h as T,e as E,g as v,d as M,t as L,M as y,m as k}from"./flow-condition-types.js";import{a as j,g as R}from"./stylesheets.js";import{e as B}from"./Icons.js";import{u as O}from"./vendor.react-i18next.js";var P=new URL("avatar-frame.css",import.meta.url).href;let x=!1;const I=[];let N,_=[];function H(t){_.push(t)}function C(){I.forEach((t=>t())),_.length>0&&(_.forEach((t=>t())),_=[]),S()}function S(){x&&(N=window.requestAnimationFrame(C))}function D(){}function U({selector:e,targetMoved:o,targetLost:a,onTargetClick:l,onTargetMouseEnter:r,onTargetMouseLeave:i}){const n=t.useRef(o),s=t.useRef(a),c=t.useRef(l),u=t.useRef(r),d=t.useRef(i);t.useLayoutEffect((()=>{n.current=o,s.current=a,c.current=l,u.current=r,d.current=i})),t.useLayoutEffect((()=>{let t=null,o=null,a=null,l=!1;const r=()=>{t=null,o=null,a=null,s.current()};if(!e)return void r();const i=()=>{if(!a||!t)return;const e=w(t);var l,i;o&&(i=e,(l=o).left===i.left&&l.top===i.top&&l.width===i.width&&l.height===i.height)||(o=e,0===e.width&&0===e.height?r():n.current({targetEl:t,targetRect:o,clipEl:a,viewportClipRect:F(a)}))};let p=!1;const m=()=>{var t;p||(p=!0,t=i,I.push(t),1===I.length&&(x=!0,S(),window.addEventListener("scroll",D)))},T=()=>{p&&(p=!1,function(t){const e=I.indexOf(t);e>=0&&(I.splice(e,1),0===I.length&&(x=!1,window.cancelAnimationFrame(N),window.removeEventListener("scroll",D)))}(i))},E=()=>{c.current&&c.current()},v=()=>{u.current&&u.current()},M=()=>{d.current&&d.current()},L=()=>{const o=t;t=b(e)?e:h(e),l&&t===o||(o&&(o.removeEventListener("click",E),o.removeEventListener("mouseenter",v),o.removeEventListener("mouseleave",M)),t?(m(),t.addEventListener("click",E),t.addEventListener("mouseenter",v),t.addEventListener("mouseleave",M),a=g(t)):(T(),r())),l=!0};L();const y=f(L);return()=>{y.disconnect(),T(),t&&(t.removeEventListener("click",E),t.removeEventListener("mouseenter",v),t.removeEventListener("mouseleave",M))}}),[e])}function F(t){T();const e=E(v()),o=E(M());if(t&&t!==document.documentElement){const a=w(t);return{top:Math.max(0,a.top),right:Math.min(o,a.right),bottom:Math.min(e,a.bottom),left:Math.max(0,a.left)}}return{top:0,right:o,bottom:e,left:0}}const A=({company:f,theme:h,position:w,absoluteWidth:x,absoluteHeight:I,stepKey:N,stepAppearance:_,width:H,backgroundImageUrl:C,tooltipSelector:S,allowMissingTooltipTarget:D,tooltipPlacement:F,backdrop:A,tooltipTargetBlocked:K,backdropPadding:q,zIndex:Y,onTooltipTargetClick:X,onTooltipTargetMissingChange:J,onModalBackdropClick:Q,onVisibleChange:Z,speaking:tt,noIframe:et,MadeWithUserflow:ot,minimizeOnAvatarClick:at,autoHide3pEnabled:lt,bubbleFrameRootRef:rt,frameWrapperHtmlAttributes:it,rootChildren:nt,children:st})=>{const ct=w||"absolute",ut=F||null,dt=q||"0",pt=ot||z,mt=B(),ft="fixed"===ct?null!=Y?Y:mt+1:1,bt=ft-1,{i18n:ht}=O(),gt=ht.dir(),wt=t.useRef(null),Tt=t.useRef(null),Et=t.useRef(null),[vt,Mt]=t.useState(null),Lt=t.useRef(null),yt=t.useRef(null),kt=t.useRef(null),jt=t.useRef(null),Rt=t.useRef(null),Bt=t.useRef(null),Ot=t.useRef(null),Pt=t.useRef(null),xt=t.useRef(null);t.useLayoutEffect((()=>{const t=wt.current.style;t.animation="none",t.visibility="hidden",t.position="absolute",t.top="-99999px",t.left="-99999px"}),[]);const{loaded:It}=j(window,d,h),[Nt,_t]=t.useState(!1),[Ht,Ct]=t.useState(!1),St=It&&Nt&&Ht;let[Dt,Ut]=t.useState(!1);_!==r.BUBBLE&&(at=!1,Dt=!1),t.useEffect((()=>{Ut(!1)}),[N]);const Ft=t.useRef({appearance:null,width:null,theme:h,bubbleFrameHeight:0,backdrop:!1,backdropPadding:"0",prevTooltipTargetParams:null,tooltipTargetParams:null,desiredTooltipPlacement:null,tooltipPlacement:null,lastReportedTooltipTargetMissing:!1,tooltipTargetMissing:!1,tooltipTargetMissingTimeout:void 0,stepKeyScrolledIntoView:void 0,targetScrolledIntoView:null}),[At,Wt]=t.useState(null),zt=null!=At&&St;t.useEffect((()=>{Z&&Z(zt)}),[Z,zt]);const Vt=t.useCallback((t=>{Ft.current.lastReportedTooltipTargetMissing!==t&&(Ft.current.lastReportedTooltipTargetMissing=t,J&&J(t))}),[J]),Gt=t.useCallback((({forceAppearanceLayout:t,forceUpdatePosition:e}={})=>{const o=wt.current,a=Tt.current,n=Et.current,d=yt.current,p=Lt.current,m=kt.current,f=jt.current,b=Rt.current,w=Bt.current,y=Ot.current,j=Pt.current,R=xt.current;if(!(o&&a&&n&&vt&&d&&p&&m&&f&&b&&w&&y&&j&&R))return;if(!St)return;const B=Ft.current,{tooltipTargetParams:O}=B;T();let P=_,C=!1;P!==r.TOOLTIP||D||O||(B.tooltipTargetMissing?(P=r.BUBBLE,C=!0):P=null);const S=P!==B.appearance,U=H!==B.width;if((t||S||U||h!==B.theme||A!=B.backdrop||dt!=B.backdropPadding||ut!==B.desiredTooltipPlacement)&&(B.appearance=P,B.width=H,B.theme=h,B.backdrop=A,B.backdropPadding=dt,B.desiredTooltipPlacement=ut,e=!0,function({layoutState:{appearance:t,theme:e,backdrop:o,tooltipTargetMissing:a},width:l,position:n,absoluteWidth:c,root:u,bubble:d,bubbleFrameRoot:p,avatar:m,avatarNotch:f,modalBackdrop:b,dir:h}){const g="absolute"===n?c||1024:E(M()),{avatarSize:w,bubblePlacement:T}=e;let v=e.bubbleWidth,L=null,y=null,k="userflowjs-bubble-frame-root",j="hidden",R=null,B=null,O=null,P=null,x="userflowjs-bubble__avatar-notch",I="hidden",N=null,_=null,H=null,C=null,S="userflowjs-modal-backdrop";(t===r.MODAL||!a&&t===r.BUBBLE&&o)&&(S+=" userflowjs-modal-backdrop--visible");switch(t){case r.BUBBLE:if(e.avatarType!==i.NONE){j="",I="",T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.TOP_RIGHT?(L=w+20,R=0,N=-40,x+=" userflowjs-bubble__avatar-notch--top"):(y=w+20,O=0,H=-40,x+=" userflowjs-bubble__avatar-notch--bottom");const t=T===s.TOP_LEFT||T===s.TOP_CENTER||T===s.BOTTOM_LEFT||T===s.BOTTOM_CENTER||T===s.CENTER;"ltr"===h&&t||"rtl"===h&&!t?(P=0,C=w,x+=" userflowjs-bubble__avatar-notch--left"):(B=0,_=w,x+=" userflowjs-bubble__avatar-notch--right")}break;case r.MODAL:v=e.modalWidth,k+=" userflowjs-bubble-frame-root--appearance-modal",e.avatarType!==i.NONE&&(j="",P=`calc(50% - ${w/2}px)`,R=-w/2);break;case r.TOOLTIP:v=e.tooltipWidth}null!=l&&(v=l);v=Math.min(v,g),u.classList.toggle("userflowjs-flow-chrome--position-absolute","absolute"===n),u.classList.toggle("userflowjs-flow-chrome--position-relative","relative"===n),u.classList.toggle("userflowjs-flow-chrome--position-fixed","fixed"===n),u.classList.toggle("userflowjs-flow-chrome--appearance-modal",t===r.MODAL);const D=null!=t&&t!==r.HIDDEN;u.style.position="",u.style.top="",u.style.left="",u.style.visibility=D?"":"hidden",u.style.animation=D?"":"none",V(d,"width",E(v)),V(d,"padding-top",L),V(d,"padding-bottom",y),p.className=k,V(m,"width",E(e.avatarSize)),V(m,"height",E(e.avatarSize)),m.style.visibility=j,V(m,"top",R),V(m,"right",B),V(m,"bottom",O),V(m,"left",P),f.className=x,f.style.visibility=I,V(f,"top",N),V(f,"right",_),V(f,"bottom",H),V(f,"left",C),b.className=S}({layoutState:B,width:H,position:ct,absoluteWidth:x,root:o,bubble:a,bubbleFrameRoot:vt,avatar:d,avatarNotch:p,modalBackdrop:R,dir:gt})),!et){const t=vt.offsetHeight,o=v()-2*(M()<800?0:16)-(P===r.BUBBLE&&h.avatarType!==i.NONE?20+h.avatarSize:0),a=Math.min(t,o);if(P&&a!==B.bubbleFrameHeight){if(B.bubbleFrameHeight=a,V(n,"height",E(a)),L(n)&&n.contentDocument){n.contentDocument.documentElement.style.overflowY=t<=o?"hidden":"scroll"}e=!0}}if(e&&P){let t=S;if(P===r.TOOLTIP){(B.tooltipTargetParams&&B.tooltipTargetParams.targetEl)!==(B.prevTooltipTargetParams&&B.prevTooltipTargetParams.targetEl)&&(t=!0)}B.prevTooltipTargetParams=B.tooltipTargetParams,function({layoutState:t,animateIn:e,position:o,absoluteWidth:a,absoluteHeight:l,desiredTooltipPlacement:i,root:n,bubble:d,tooltipNotch:p,tooltipBackdrop:m,tooltipBlockTop:f,tooltipBlockRight:b,tooltipBlockBottom:h,tooltipBlockLeft:g,dir:w}){const{appearance:T,theme:L,tooltipTargetParams:y,backdrop:j,backdropPadding:R}=t,{bubblePlacement:B}=L,O=16,P=L.tooltipNotchSize,x=10,{width:I,height:N}=d.getBoundingClientRect(),_="absolute"===o?a||1024:E(M()),H="absolute"===o?l||768:E(v());let C=0,S=0,D="userflowjs-bubble__tooltip-notch",U="hidden",F=null,A=null,W=null,z=null,K="userflowjs-tooltip-backdrop",q=null,Y=null,X=null,J=null,Q=null,Z=null,tt=null,et=null,ot="userflowjs-tooltip-block userflowjs-tooltip-block--top",at=null,lt=null,rt="userflowjs-tooltip-block userflowjs-tooltip-block--right",it=null,nt=null,st="userflowjs-tooltip-block userflowjs-tooltip-block--bottom",ct=null,ut=null,dt="userflowjs-tooltip-block userflowjs-tooltip-block--left",pt=null,mt=null;switch(T){case r.BUBBLE:C=B===s.TOP_LEFT||B===s.BOTTOM_LEFT?L.bubbleX:B===s.TOP_CENTER||B===s.CENTER||B===s.BOTTOM_CENTER?(_-I)/2:_-I-L.bubbleX,S=B===s.TOP_LEFT||B===s.TOP_CENTER||B===s.TOP_RIGHT?L.bubbleY:B===s.CENTER?(H-N)/2:H-N-L.bubbleY,"rtl"===w&&(C=_-C-I),C=Math.max(0,Math.min(_-I,C)),S=Math.max(0,Math.min(H-N,S));break;case r.MODAL:C=O+(_-2*O-I)/2,S=O+(H-2*O-N)/2;break;case r.TOOLTIP:{let e;if(y){let{targetRect:a,viewportClipRect:l}=y;if("absolute"===o){const t=n.offsetParent.getBoundingClientRect();l={top:0,right:_,bottom:H,left:0},a={top:a.top-t.top,right:a.right-t.left,bottom:a.bottom-t.top,left:a.left-t.left,width:a.width,height:a.height}}let r=0;if(j){const{paddingTop:t,paddingRight:e,paddingBottom:o,paddingLeft:l}=function(t){if(!t||"0"===t)return{paddingTop:0,paddingRight:0,paddingBottom:0,paddingLeft:0};const e=t.trim().split(" ");if(1===e.length){const t=$(e[0]);return{paddingTop:t,paddingRight:t,paddingBottom:t,paddingLeft:t}}if(2===e.length){const t=$(e[0]),o=$(e[1]);return{paddingTop:t,paddingRight:o,paddingBottom:t,paddingLeft:o}}return{paddingTop:$(e[0]),paddingRight:$(e[1]),paddingBottom:$(e[2]),paddingLeft:$(e[3])}}(R);a={top:a.top-t,right:a.right+e,bottom:a.bottom+o,left:a.left-l,width:a.width+l+e,height:a.height+t+o},r=Math.min(t,e,o,l)}const s=a,d=L.backdropHighlightType==c.OUTSIDE?L.backdropHighlightSpread:0;if(j&&d&&(a={top:a.top-d,right:a.right+d,bottom:a.bottom+d,left:a.left-d,width:a.width+2*d,height:a.height+2*d}),e=function({targetRect:t,bubbleWidth:e,bubbleHeight:o,containerWidth:a,containerHeight:l,viewportClipRect:r,tooltipNotchSize:i,currentTooltipPlacement:n,desiredTooltipPlacement:s}){if(t.bottom<=r.top)return o+i<=l-r.top?u.BELOW:u.ABOVE;if(t.top>=r.bottom)return o+i<=r.bottom?u.ABOVE:u.BELOW;if(t.right<=r.left)return e+i<=a-r.left?u.RIGHT:u.LEFT;if(t.left>=r.right)return e+i<=r.right?u.LEFT:u.RIGHT;const c=n=>{const s=t.left+t.width/2,c=s>=r.left&&s<=r.right,d=t.top+t.height/2,p=d>=r.top&&d<=r.bottom;switch(n){case u.BELOW:return l-t.bottom>o+i&&c;case u.ABOVE:return t.top>o+i&&c;case u.RIGHT:return a-t.right>e+i&&p;case u.LEFT:return t.left>e+i&&p}};if(s&&c(s))return s;if(n&&c(n))return n;const d=[{placement:u.BELOW,dist:t.top},{placement:u.ABOVE,dist:l-t.bottom},{placement:u.RIGHT,dist:t.left},{placement:u.LEFT,dist:a-t.right}];d.sort(((t,e)=>t.dist-e.dist));for(const{placement:u}of d)if(c(u))return u;return u.BELOW}({targetRect:a,bubbleWidth:I,bubbleHeight:N,containerWidth:_,containerHeight:H,viewportClipRect:l,tooltipNotchSize:P,currentTooltipPlacement:t.tooltipPlacement,desiredTooltipPlacement:i}),e===u.BELOW||e===u.ABOVE?(C=a.left+a.width/2-I/2,C=Math.max(O,Math.min(_-I-O,C)),z=Math.max(x,Math.min(I-x-2*P,a.left+a.width/2-P-C)),e===u.BELOW?F=2*-P:W=2*-P):e===u.RIGHT?(C=a.right+P,C=Math.max(C,l.left+P),C=Math.min(C,l.right+P),C=Math.max(C,P),C=Math.min(C,_-I)):(C=a.left-P-I,C=Math.max(C,l.left-I-P),C=Math.min(C,l.right-I-P),C=Math.max(C,0),C=Math.min(C,_-I-P)),e===u.LEFT||e===u.RIGHT?(S=a.top+a.height/2-N/2,S=Math.max(O,Math.min(H-N-O,S)),F=Math.max(x,Math.min(N-x-2*P,a.top+a.height/2-P-S)),e===u.LEFT?A=2*-P:z=2*-P):e===u.BELOW?(S=a.bottom+P,S=Math.max(S,l.top+P),S=Math.min(S,l.bottom+P),S=Math.max(S,P),S=Math.min(S,H-N)):(S=a.top-P-N,S=Math.max(S,l.top-N-P),S=Math.min(S,l.bottom-N-P),S=Math.max(S,0),S=Math.min(S,H-N-P)),j){const t=window.getComputedStyle(y.targetEl);q=Math.max(0,s.top),Y=Math.max(0,_-s.right),X=Math.max(0,H-s.bottom),J=Math.max(0,s.left),Q=Math.max(0,k(t.borderTopLeftRadius)+r),Z=Math.max(0,k(t.borderTopRightRadius)+r),tt=Math.max(0,k(t.borderBottomRightRadius)+r),et=Math.max(0,k(t.borderBottomLeftRadius)+r),at=Math.max(0,s.right),lt=Math.max(0,s.top),it=Math.max(0,s.right),nt=Math.max(0,s.bottom),ct=Math.max(0,s.left),ut=Math.max(0,s.bottom),pt=Math.max(0,s.left),mt=Math.max(0,s.top)}}else e=i||u.BELOW,e!==u.BELOW&&e!==u.ABOVE||(z=I/2-P,e===u.BELOW?F=2*-P:W=2*-P),e!==u.LEFT&&e!==u.RIGHT||(F=N/2-P,e===u.LEFT?A=2*-P:z=2*-P);t.tooltipPlacement=e,D+=` userflowjs-bubble__tooltip-notch--${e.toLowerCase()}`,U="",j&&(K+=" userflowjs-tooltip-backdrop--visible",ot+=" userflowjs-tooltip-block--visible",rt+=" userflowjs-tooltip-block--visible",st+=" userflowjs-tooltip-block--visible",dt+=" userflowjs-tooltip-block--visible");break}}d.style.transition="";let ft=C,bt=S;if(e&&(d.style.opacity="0",T===r.TOOLTIP)){const e=24;switch(t.tooltipPlacement){case u.BELOW:S+=e;break;case u.ABOVE:S-=e;break;case u.RIGHT:C+=e;break;case u.LEFT:C-=e}}"relative"!==o&&G(d,C,S);if(p.className=D,p.style.visibility=U,V(p,"top",F),V(p,"right",A),V(p,"bottom",W),V(p,"left",z),m.className=K,V(m,"top",q),V(m,"right",Y),V(m,"bottom",X),V(m,"left",J),V(m,"border-top-left-radius",Q),V(m,"border-top-right-radius",Z),V(m,"border-bottom-right-radius",tt),V(m,"border-bottom-left-radius",et),f.className=ot,V(f,"width",at),V(f,"height",lt),b.className=rt,V(b,"left",it),V(b,"height",nt),h.className=st,V(h,"left",ct),V(h,"top",ut),g.className=dt,V(g,"width",pt),V(g,"top",mt),e){d.offsetWidth;const t="opacity 250ms linear";T===r.TOOLTIP?d.style.transition=`${t}, transform 500ms cubic-bezier(0.25, 0.8, 0.5, 1)`:d.style.transition=t,d.style.opacity="1","relative"!==o&&G(d,ft,bt)}}({layoutState:B,animateIn:t,position:ct,absoluteWidth:x,absoluteHeight:I,desiredTooltipPlacement:ut,root:o,bubble:a,tooltipNotch:m,tooltipBackdrop:f,tooltipBlockTop:b,tooltipBlockRight:w,tooltipBlockBottom:y,tooltipBlockLeft:j,dir:gt})}if(P===r.TOOLTIP){const t=O&&O.targetEl;t&&B.stepKeyScrolledIntoView!==N&&B.targetScrolledIntoView!==t&&(B.stepKeyScrolledIntoView=N,B.targetScrolledIntoView=t,function(t){if(l.customScrollIntoView)return void l.customScrollIntoView(t);const{scrollPadding:e}=l;if(e&&g(t)===document.scrollingElement){const o=e.top||0,a=e.right||0,l=e.bottom||0,r=e.left||0;let i=0,n=0;const s=t.getBoundingClientRect(),c=M(),u=v();if(s.top<o?i=s.top-o:s.bottom>u-l&&(i=s.bottom-u+l),s.left<r?n=s.left-r:s.right>c-a&&(n=s.right-c+a),0!=i||0!=n)return void window.scrollBy({top:i,left:n,behavior:"smooth"})}try{t.scrollIntoView({behavior:"smooth",block:"nearest"})}catch(o){console.warn("Userflow.js: scrollIntoView error (falling back to no options).",o),t.scrollIntoView()}}(t))}else B.stepKeyScrolledIntoView=void 0,B.targetScrolledIntoView=null;Vt(C),Wt(P)}),[St,vt,N,_,H,h,ct,x,I,D,ut,A,dt,et,Vt,gt]),$t=t.useRef(Gt);$t.current=Gt;const Kt=t.useRef(!1);t.useEffect((()=>{const t=()=>{Kt.current=!0};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)}),[]);const qt=()=>{window.clearTimeout(Ft.current.tooltipTargetMissingTimeout),Ft.current.tooltipTargetMissingTimeout=void 0};t.useEffect((()=>qt),[]);const Yt=t.useCallback((()=>{const t=Ft.current;if(t.tooltipTargetParams=null,D||(t.tooltipPlacement=null),_!==r.TOOLTIP)return qt(),void(t.tooltipTargetMissing=!1);if(!D&&!t.tooltipTargetMissingTimeout){t.tooltipTargetMissing=!1;const e=!S||b(S)||S.type!==n.AUTO||S.autoData?1e3*parseFloat(h.tooltipMissingToleranceSeconds):1;t.tooltipTargetMissingTimeout=window.setTimeout((()=>{if(!Kt.current){if(S&&!b(S)){let t=S.autoData;if(S.autoData)try{t=JSON.parse(S.autoData)}catch(e){}console.warn("Userflow.js: Tooltip target not found on page.\n",{type:S.type,autoData:t,excludeText:S.excludeText,precision:S.precision,text:S.text,css:S.css})}qt(),t.tooltipTargetMissing=!0,$t.current()}}),e)}$t.current()}),[_,D,S,h.tooltipMissingToleranceSeconds]),Xt=t.useCallback((t=>{const e=Ft.current;qt(),e.tooltipTargetParams&&e.tooltipTargetParams.targetEl!==t.targetEl&&(e.tooltipPlacement=null),e.tooltipTargetParams=t,Gt({forceUpdatePosition:!0})}),[Gt]);U({selector:_===r.TOOLTIP&&S||null,targetMoved:Xt,targetLost:Yt,onTargetClick:X});const Jt=t.useCallback((()=>Gt({forceAppearanceLayout:!0})),[Gt]);e(Jt),t.useEffect((()=>{if(!vt||et||"function"!=typeof y)return;let t;const e=new y((()=>{t||(t=window.requestAnimationFrame((()=>{t=void 0,$t.current()})))}));return e.observe(vt,{childList:!0,attributes:!0,subtree:!0}),()=>{e.disconnect(),t&&window.cancelAnimationFrame(t)}}),[vt,et]),t.useLayoutEffect((()=>{$t.current()})),t.useLayoutEffect((()=>{"absolute"===ct&&Gt({forceAppearanceLayout:!0})}),[ct,x,I]);const Qt=t=>{t.preventDefault(),t.stopPropagation()};return function(e,o){const a=window.Intercom;t.useEffect((()=>{if(o&&e.autoHideIntercom&&"function"==typeof a&&!l.autoHide3pDisabled){try{a("update",{hide_default_launcher:!0})}catch(t){console.warn("Userflow.js: Error when hiding Intercom launcher",t)}return()=>{if(!l.autoHide3pDisabled)try{a("update",{hide_default_launcher:!1})}catch(t){console.warn("Userflow.js: Error when unhiding Intercom launcher",t)}}}}),[a,e.autoHideIntercom,o]);const r=window.$crisp;t.useEffect((()=>{if(o&&e.autoHideCrisp&&r&&!l.autoHide3pDisabled){try{r.push(["do","chat:hide"])}catch(t){console.warn("Userflow.js: Error when hiding Crisp Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{r.push(["do","chat:show"])}catch(t){console.warn("Userflow.js: Error when unhiding Crisp Chat",t)}}}}),[r,e.autoHideCrisp,o]);const i=window.HubSpotConversations;t.useEffect((()=>{if(o&&e.autoHideHubspot&&i&&!l.autoHide3pDisabled){try{i.widget.remove()}catch(t){console.warn("Userflow.js: Error when hiding HubSpot Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{i.widget.load()}catch(t){console.warn("Userflow.js: Error when unhiding HubSpot Chat",t)}}}}),[i,e.autoHideHubspot,o]);const n=window.drift;t.useEffect((()=>{if(o&&e.autoHideDrift&&n&&!l.autoHide3pDisabled){try{n.api.widget.hide()}catch(t){console.warn("Userflow.js: Error when hiding Drift Chat",t)}return()=>{if(!l.autoHide3pDisabled)try{n.api.widget.show()}catch(t){console.warn("Userflow.js: Error when unhiding Drift Chat",t)}}}}),[n,e.autoHideDrift,o])}(h,!!lt&&At===r.BUBBLE),t.createElement("div",{ref:wt,"data-testid":"flow-chrome",className:"userflowjs-flow-chrome userflowjs-theme-root",style:R(h),dir:gt},t.createElement("div",{className:"userflowjs-bubble",ref:Tt,style:{zIndex:ft}},t.createElement("div",{className:m({"userflowjs-bubble-outline":!0,[`userflowjs-bubble-outline--bubble-placement-${(h.bubblePlacement||"").toLowerCase().replace(/_/,"-")}`]:!0,"userflowjs-bubble-outline--minimizable":!!at,"userflowjs-bubble-outline--minimized":Dt})},t.createElement("div",{className:"userflowjs-bubble__frame-wrapper",...it},t.createElement(o,{className:"userflowjs-bubble__frame",elRef:Et,stylesheetUrl:p,theme:h,onStylesheetsLoad:_t,noIframe:et},t.createElement("div",{className:"userflowjs-bubble-frame-root",dir:gt,ref:t=>{rt&&rt(t),Mt(t)},style:C?{backgroundImage:`url("${encodeURI(C)}")`}:void 0},st,f.flowBranding&&t.createElement("div",{className:"userflowjs-bubble-made-with-userflow"},t.createElement("div",{className:"userflowjs-bubble-made-with-userflow__absolute"},t.createElement(pt,{company:f},t.createElement(a,null),t.createElement("div",null,"Made with Userflow"))))))),t.createElement("div",{ref:Lt,className:"userflowjs-bubble__avatar-notch"})),t.createElement(o,{className:m({"userflowjs-bubble__avatar":!0,"userflowjs-bubble__avatar--minimizable":!!at,"userflowjs-bubble__avatar--speaking":!!tt}),elRef:yt,stylesheetUrl:P,theme:h,onStylesheetsLoad:Ct,noIframe:et,ariaHidden:!0},t.createElement("div",{className:m({"userflowjs-avatar-frame-root":!0,"userflowjs-avatar-frame-root--minimizable":!!at}),onClick:at?()=>Ut((t=>!t)):void 0},t.createElement(W,{theme:h}))),t.createElement("div",{ref:kt,className:"userflowjs-bubble__tooltip-notch"})),t.createElement("div",{ref:jt,className:"userflowjs-tooltip-backdrop",onMouseDown:Qt,style:{zIndex:bt,pointerEvents:K?void 0:"none"}}),t.createElement("div",{ref:Rt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:Bt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:Ot,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:Pt,className:"userflowjs-tooltip-block",onMouseDown:Qt,style:{zIndex:bt}}),t.createElement("div",{ref:xt,className:"userflowjs-modal-backdrop",onMouseDown:Qt,onClick:Q,style:{zIndex:bt}}),nt&&nt({visible:zt,bubbleFrame:Et.current}))},W=({theme:e})=>{const o="https://js.userflow.com/cartoon-avatars-no-bg/";let a;return a=e.avatarType===i.ASSET&&e.avatarAsset?e.avatarAsset.assetUrl:e.avatarType===i.CARTOON&&e.avatarName?o+e.avatarName+".svg?3":e.avatarType===i.URL&&e.avatarUrl?e.avatarUrl:o+"none.svg",t.createElement("img",{src:a,alt:""})},z=({company:e,children:o})=>t.createElement("a",{href:"https://userflow.com/?utm_source=made-with-userflow&utm_medium=link&utm_campaign=made-with-userflow-"+e.slug,target:"_blank",rel:"noopener noreferrer"},o);function V(t,e,o){null==o?t.style.removeProperty(e):t.style.setProperty(e,"number"==typeof o?o+"px":o,"important")}function G(t,e,o){e=Math.round(e),o=Math.round(o),t.style.transform=`translate3d(${e}px, ${o}px, 0px)`}function $(t){const e=parseInt(t,10);return isNaN(e)?0:e}export{A as F,H as r,U as u};
|
package/Icons.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";const
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{c as t}from"./userflow.js";const r=0,c=10,l=2e3;function n(e){return t.baseZIndex+e}const a=[];function s(){const e={zIndex:0===a.length?n(100):a[a.length-1].zIndex+10};return a.push(e),e}function o(e){const t=a.indexOf(e);-1!==t&&a.splice(t,1)}function i(){const[t,r]=e.useState(s);e.useEffect((()=>()=>o(t)),[t]);const c=e.useCallback((()=>{o(t),r(s())}),[t]);return{zIndex:t.zIndex,bringToFront:c}}const w=({children:t})=>{const{zIndex:r}=i();return e.createElement(v.Provider,{value:r},t)},v=e.createContext(void 0);function m(){return e.useContext(v)||n(100)}const g=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M0 304v-96c0-13.3 10.7-24 24-24h200V80.2c0-21.4 25.8-32.1 41-17L441 239c9.4 9.4 9.4 24.6 0 34L265 448.7c-15.1 15.1-41 4.4-41-17V328H24c-13.3 0-24-10.7-24-24z"})),h=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M272 480h-96c-13.3 0-24-10.7-24-24V256H48.2c-21.4 0-32.1-25.8-17-41L207 39c9.4-9.4 24.6-9.4 34 0l175.8 176c15.1 15.1 4.4 41-17 41H296v200c0 13.3-10.7 24-24 24z"})),d=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},e.createElement("path",{fill:"currentColor",d:"M435.848 83.466L172.804 346.51l-96.652-96.652c-4.686-4.686-12.284-4.686-16.971 0l-28.284 28.284c-4.686 4.686-4.686 12.284 0 16.971l133.421 133.421c4.686 4.686 12.284 4.686 16.971 0l299.813-299.813c4.686-4.686 4.686-12.284 0-16.971l-28.284-28.284c-4.686-4.686-12.284-4.686-16.97 0z"})),u=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M441.9 167.3l-19.8-19.8c-4.7-4.7-12.3-4.7-17 0L224 328.2 42.9 147.5c-4.7-4.7-12.3-4.7-17 0L6.1 167.3c-4.7 4.7-4.7 12.3 0 17l209.4 209.4c4.7 4.7 12.3 4.7 17 0l209.4-209.4c4.7-4.7 4.7-12.3 0-17z"})),x=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M107.515 150.971L8.485 250c-4.686 4.686-4.686 12.284 0 16.971L107.515 366c7.56 7.56 20.485 2.206 20.485-8.485v-71.03h308c6.627 0 12-5.373 12-12v-32c0-6.627-5.373-12-12-12H128v-71.03c0-10.69-12.926-16.044-20.485-8.484z"})),L=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512"},e.createElement("path",{fill:"currentColor",d:"M340.485 366l99.03-99.029c4.686-4.686 4.686-12.284 0-16.971l-99.03-99.029c-7.56-7.56-20.485-2.206-20.485 8.485v71.03H12c-6.627 0-12 5.373-12 12v32c0 6.627 5.373 12 12 12h308v71.03c0 10.689 12.926 16.043 20.485 8.484z"})),p=()=>e.createElement("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg"},e.createElement("polygon",{className:"userflowjs-star-shape",fill:"#fff",points:"16 22.7785728 7.18322122 29.1352549 10.5042507 18.7856772 1.73415226 12.3647451 12.6034401 12.3250364 16 2 19.3965599 12.3250364 30.2658477 12.3647451 21.4957493 18.7856772 24.8167788 29.1352549"})),f=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512"},e.createElement("path",{fill:"currentColor",d:"M207.6 256l107.72-107.72c6.23-6.23 6.23-16.34 0-22.58l-25.03-25.03c-6.23-6.23-16.34-6.23-22.58 0L160 208.4 52.28 100.68c-6.23-6.23-16.34-6.23-22.58 0L4.68 125.7c-6.23 6.23-6.23 16.34 0 22.58L112.4 256 4.68 363.72c-6.23 6.23-6.23 16.34 0 22.58l25.03 25.03c6.23 6.23 16.34 6.23 22.58 0L160 303.6l107.72 107.72c6.23 6.23 16.34 6.23 22.58 0l25.03-25.03c6.23-6.23 6.23-16.34 0-22.58L207.6 256z"})),E=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 480 512"},e.createElement("path",{fill:"currentColor",d:"M394.23 100.85c-11.19-7.09-26.03-3.8-33.12 7.41s-3.78 26.03 7.41 33.12C408.27 166.6 432 209.44 432 256s-23.73 89.41-63.48 114.62c-11.19 7.09-14.5 21.92-7.41 33.12 6.51 10.28 21.12 15.03 33.12 7.41C447.94 377.09 480 319.09 480 256s-32.06-121.09-85.77-155.15zm-56 78.28c-11.58-6.33-26.19-2.16-32.61 9.45-6.39 11.61-2.16 26.2 9.45 32.61C327.98 228.28 336 241.63 336 256c0 14.37-8.02 27.72-20.92 34.81-11.61 6.41-15.84 21-9.45 32.61 6.43 11.66 21.05 15.8 32.61 9.45 28.23-15.55 45.77-45 45.77-76.87s-17.54-61.33-45.78-76.87zM231.81 64c-5.91 0-11.92 2.18-16.78 7.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c4.87 4.87 10.88 7.05 16.78 7.05 12.33 0 24.19-9.52 24.19-24.02V88.02C256 73.51 244.13 64 231.81 64zM208 366.05L145.94 304H48v-96h97.94L208 145.95v220.1z"})),z=()=>e.createElement("svg",{"aria-hidden":"true",role:"img",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},e.createElement("path",{fill:"currentColor",d:"M231.81 64c-5.91 0-11.92 2.18-16.78 7.05L126.06 160H24c-13.26 0-24 10.74-24 24v144c0 13.25 10.74 24 24 24h102.06l88.97 88.95c4.87 4.87 10.88 7.05 16.78 7.05 12.33 0 24.19-9.52 24.19-24.02V88.02C256 73.51 244.13 64 231.81 64zM208 366.05l-48-47.99L145.94 304H48v-96h97.94L160 193.94l48-47.99v220.1zM465.94 256l41.37-41.37c6.25-6.25 6.25-16.38 0-22.63L496 180.69c-6.25-6.25-16.38-6.25-22.63 0L432 222.06l-41.37-41.37c-6.25-6.25-16.38-6.25-22.63 0L356.69 192c-6.25 6.25-6.25 16.38 0 22.63L398.06 256l-41.37 41.37c-6.25 6.25-6.25 16.38 0 22.63L368 331.32c6.25 6.25 16.38 6.25 22.63 0L432 289.94l41.37 41.37c6.25 6.25 16.38 6.25 22.63 0L507.31 320c6.25-6.25 6.25-16.38 0-22.63L465.94 256z"}));export{g as A,c as C,x as L,l as N,p as S,f as T,z as V,d as a,E as b,u as c,L as d,m as e,h as f,w as g,r as h,i as u,n as w};
|
package/LauncherApp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{L as t,
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{L as t,H as r,I as o,z as s,J as n,K as a,N as c,G as i}from"./userflow.js";import{u as l,F as u,r as E}from"./FlowChrome.js";import{f as d,m as p,d as m,S as T,B as f,R as h,h as w}from"./BubbleToolbar.js";import{u as g,i as v}from"./client-context.js";import{o as C}from"./vendor.obj-str.js";import{a as R,c as b,g as L,u as j}from"./stylesheets.js";import{D as A}from"./DynamicIcon.js";import{w as O,h as N,g as I}from"./Icons.js";import{a as _,r as k}from"./flow-condition-types.js";import{T as H}from"./Trigger.js";import"./vendor.object-assign.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./logomark.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./vendor.fortawesome.react-fontawesome.js";import"./vendor.fortawesome.fontawesome-svg-core.js";import"./vendor.prop-types.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.i18next.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.date-fns.js";const x=e.forwardRef((({appearance:r,icon:o,buttonText:s,theme:n,noAnimation:a,noFixed:c,onClick:i,onMouseEnter:l,onMouseLeave:u,noPointerEvents:E,zIndex:p},m)=>{const{loaded:T}=R(window,d,n),f=n&&r===t.BUTTON?n:null,{loaded:h}=b(window,f),w={"userflowjs-launcher":!0,"userflowjs-launcher--activate-on-click":!!i,"userflowjs-fixed-widget":!c},g={ref:m,style:{...L(n),zIndex:p||O(N),pointerEvents:E?"none":void 0},onClick:i,onMouseEnter:l,onMouseLeave:u};if(!T||!h)return null;switch(r){case t.BEACON:return e.createElement("div",{className:C({...w,"userflowjs-beacon":!0,"userflowjs-beacon--pulse":!a,"userflowjs-beacon--pulse-still":!!a}),...g},e.createElement("div",{className:"userflowjs-beacon__ring"}),e.createElement("div",{className:"userflowjs-beacon__ring"}));case t.BUTTON:return e.createElement("div",{className:C({...w,"userflowjs-launcher--button":!0}),...g},s);case t.HIDDEN:return null;case t.ICON:return e.createElement("div",{className:C({...w,"userflowjs-launcher--icon":!0}),...g},e.createElement(A,{icon:o||"solid/info-circle",size:n.launcherIconSize}))}})),M=({session:d,active:C})=>{const R=g(),{version:b}=d,L=d.id,A=d.flow.id,O=d.version.launcher,[N,M]=e.useState(null),G=j(b.theme),U=d.locale?d.locale.standardLocaleId:G.languageId;e.useEffect((()=>{v.changeLanguage(U)}),[U]);const{activateOn:P}=O,y=O.activeWhileTooltipHover||O.buttons.length>0,B=O.hiddenWhileActive&&P!==r.LAUNCHER_HOVER,K=!C||!B,F=P===r.LAUNCHER_CLICK||P===r.TARGET_CLICK||P===r.LAUNCHER_TARGET_CLICK||y,D=e.useRef({}),S=e.useCallback((()=>{const e=N;if(!e)return;const{targetEl:r,clipEl:s,viewportClipRect:n}=D.current;let i=null;r&&s&&n&&(i=function({targetEl:e,subjectEl:t,clipEl:r,viewportClipRect:s,position:n,subjectAnchor:i}){const l=k(e);if(0===l.width||0===l.height)return null;const u=t.getBoundingClientRect();let E=0,d=0,{side:p,align:m}=n;p===o.AUTO&&(p=o.TOP,m=a.END);switch(p){case o.TOP:d=l.top;break;case o.BOTTOM:d=l.bottom;break;case o.LEFT:E=l.left;break;case o.RIGHT:E=l.right}switch(p){case o.TOP:case o.BOTTOM:switch(m){case a.START:E=l.left;break;case a.CENTER:E=l.left+l.width/2;break;case a.END:E=l.right}break;case o.LEFT:case o.RIGHT:switch(m){case a.START:d=l.top;break;case a.CENTER:d=l.top+l.height/2;break;case a.END:d=l.bottom}}n.xUnit===c.PERCENT?E+=n.xOffset/100*l.width:E+=n.xOffset;n.yUnit===c.PERCENT?d+=n.yOffset/100*l.height:d+=n.yOffset;switch(i){case"center":E-=u.width/2,d-=u.height/2;break;case"side":switch(p){case o.TOP:d-=u.height;break;case o.LEFT:E-=u.width}switch(p){case o.TOP:case o.BOTTOM:switch(m){case a.CENTER:E-=u.width/2;break;case a.END:E-=u.width}break;case o.LEFT:case o.RIGHT:switch(m){case a.CENTER:d-=u.height/2;break;case a.END:d-=u.height}}}if(E+u.width<s.left||E>s.right)return null;if(d+u.height<s.top||d>s.bottom)return null;const T=k(r);return E=Math.max(E,T.left-r.scrollLeft),d=Math.max(d,T.top-r.scrollTop),E=Math.round(E),d=Math.round(d),{left:E,top:d}}({targetEl:r,subjectEl:e,clipEl:s,viewportClipRect:n,position:O.targetPosition,subjectAnchor:O.appearance===t.BEACON?"center":"side"})),E((()=>{!function(e,t){e.classList.toggle("userflowjs-fixed-widget--visible",null!=t),t&&(e.style.transform=`translate3d(${t.left}px, ${t.top}px, 0)`)}(e,i)})),!i||D.current.seenTriggered||L||(D.current.seenTriggered=!0,R.launcherSeen(A))}),[N,O,R,L,A]);e.useLayoutEffect((()=>{S()}),[S]);const z=e.useRef(!1),V=e.useRef(!1),W=e.useRef(!1),$=e.useRef(),J=()=>{q();$.current=window.setTimeout((()=>X.current()),250)},q=e.useCallback((()=>{window.clearTimeout($.current)}),[]),Q=()=>{if(P===r.LAUNCHER_CLICK||P===r.TARGET_CLICK||P===r.LAUNCHER_TARGET_CLICK)return;const e=P===r.LAUNCHER_HOVER||P===r.LAUNCHER_TARGET_HOVER,t=P===r.TARGET_HOVER||P===r.LAUNCHER_TARGET_HOVER;z.current&&(!B||!C)&&e||V.current&&t||W.current&&y?Y():Z()},X=e.useRef(Q);X.current=Q;const Y=()=>{C||(q(),w(R,d,O.actions),O.tooltipEnabled?R.activateLauncher(d):(R.activateLauncher(d),R.deactivateLauncher(d)))},Z=e.useCallback((()=>{C&&(q(),R.deactivateLauncher(d))}),[C,R,d,q]),ee=()=>{C?Z():Y()},te=e.useCallback((({targetEl:e,clipEl:t,viewportClipRect:r})=>{D.current.targetEl=e,D.current.clipEl=t,D.current.viewportClipRect=r,S()}),[S]),re=e.useCallback((()=>{D.current.targetEl=void 0,D.current.clipEl=void 0,S(),Z()}),[S,Z]);l({selector:O.targetSelector,targetMoved:te,targetLost:re,onTargetMouseEnter:()=>{V.current=!0,J()},onTargetMouseLeave:()=>{V.current=!1,J()},onTargetClick:P===r.TARGET_CLICK||P===r.LAUNCHER_TARGET_CLICK?ee:void 0}),e.useEffect((()=>{if(!C)return;const e=e=>{const t=e.target;N&&N.contains(t)||(P===r.TARGET_CLICK||P===r.LAUNCHER_TARGET_CLICK)&&D.current.targetEl&&D.current.targetEl.contains(t)||Z()};return window.addEventListener("click",e,{capture:!0}),()=>window.removeEventListener("click",e,{capture:!0})}),[C,P,N,Z]);const oe=function(e){switch(e.side){case o.AUTO:return null;case o.TOP:return i.ABOVE;case o.BOTTOM:return i.BELOW;case o.LEFT:return i.LEFT;case o.RIGHT:return i.RIGHT}}(O.tooltipPosition.side===o.AUTO?O.targetPosition:O.tooltipPosition),se=e.useMemo((()=>O.content&&p(m(O.content),{buttons:O.buttons})),[O.content,O.buttons]);return e.createElement(T.Provider,{value:d},K&&e.createElement(x,{ref:M,appearance:O.appearance,icon:O.icon,buttonText:O.buttonText,theme:G,onClick:P===r.LAUNCHER_CLICK||P===r.LAUNCHER_TARGET_CLICK?ee:void 0,onMouseEnter:()=>{z.current=!0,J()},onMouseLeave:()=>{z.current=!1,J()},noPointerEvents:P===r.TARGET_HOVER,zIndex:O.zIndex}),C&&e.createElement(I,null,e.createElement(u,{company:d.flow.company,theme:G,position:"fixed",stepAppearance:s.TOOLTIP,width:O.tooltipWidth,tooltipSelector:O.tooltipAnchor===n.TARGET?D.current.targetEl:N,tooltipPlacement:oe,frameWrapperHtmlAttributes:{onMouseEnter:()=>{W.current=!0,J()},onMouseLeave:()=>{W.current=!1,J()}},rootChildren:()=>e.createElement(e.Fragment,null,O.triggers.map((t=>e.createElement(H,{key:t.id,trigger:t}))))},e.createElement(f,{draftMode:d.draftMode,close:F?Z:void 0}),e.createElement("div",{className:"userflowjs-bubble-content"},e.createElement(h,{doc:se,lookupAttribute:_(d.data),buttons:O.buttons})))))};export default M;export{M as LauncherApp};
|
package/TrackerTestingApp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{u as t}from"./client-context.js";import{B as r}from"./BuilderBar.js";import{c as o}from"./flow-condition-types.js";import{
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{u as t}from"./client-context.js";import{B as r}from"./BuilderBar.js";import{c as o}from"./flow-condition-types.js";import{v as s}from"./userflow.js";import"./vendor.object-assign.js";import"./vendor.i18next.js";import"./vendor.react-i18next.js";import"./vendor.babel.runtime.js";import"./logomark.js";import"./vendor.react-dom.js";import"./vendor.scheduler.js";import"./stylesheets.js";import"./vendor.obj-str.js";import"./vendor.fortawesome.pro-light-svg-icons.js";import"./DynamicIcon.js";import"./vendor.fortawesome.pro-regular-svg-icons.js";import"./vendor.fortawesome.pro-solid-svg-icons.js";import"./vendor.date-fns.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";const n=({state:n})=>{const i=t(),[a,c]=e.useState("notIdentified");e.useEffect((()=>{let e,t,r=!1;const a=async()=>{c("trackerLoading");const{tracker:e}=await i.send({kind:"GetTrackerForTesting",token:n.token});if(r)return;const{condition:a}=e,d=o[a.type];let l=!1;t=d.track({sessionData:new s(e.data),condition:a,flipBackEvents:!0,callback:e=>{const t=l;l=e,!t&&e&&i.setSessionStorageState((e=>({...e,trackerTesting:{...e.trackerTesting,events:e.trackerTesting.events+1}})))}}),c("trackerLoaded")};return e=()=>{i.off("private:identified",e),a()},i.isIdentified()?e():i.on("private:identified",e),()=>{r=!0,e&&i.off("private:identified",e),t&&t()}}),[i,n.token]);const d=e.useCallback((async()=>{i.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null}))),i.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerClosed"})}),[i]);return e.createElement(r,{buttons:e.createElement("button",{className:"btn btn--default",onClick:()=>d()},"Back to Builder")},e.createElement("div",null,e.createElement("div",{className:"label"},"Testing tracker: ",n.trackerName),"notIdentified"===a?e.createElement("div",null,"Waiting for your app to identify user..."):"trackerLoading"===a?e.createElement("div",null,"Loading tracker..."):0===n.events?e.createElement("div",{className:"error"},"Not tracked yet"):e.createElement("div",{className:"success"},"Tracked ",n.events," time",1===n.events?"":"s")))};export default n;export{n as TrackerTestingApp};
|
package/hash.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8dfc62093b70d24aca0fe1a79520b7ffaa081ace
|
package/package.json
CHANGED
package/stylesheets.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as o}from"./vendor.react.js";import{r,B as t,A as e,v as n}from"./userflow.js";import{c as u}from"./flow-condition-types.js";import{a as l}from"./client-context.js";function a(t){const[e]=o.useState((()=>new r(t)));return e.update(t),e}function c(o){return o?o.match(/^#[0-9a-f]{6}$/i)?[parseInt(o.substring(1,3),16),parseInt(o.substring(3,5),16),parseInt(o.substring(5,7),16)]:o.match(/^#[0-9a-f]{3}$/i)?[parseInt(o.substring(1,2).repeat(2),16),parseInt(o.substring(2,3).repeat(2),16),parseInt(o.substring(3,4).repeat(2),16)]:[0,0,0]:[0,0,0]}function i([o,r,t]){return"#"+o.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0")+t.toString(16).padStart(2,"0")}function d(o){const r=c(o);return r?r.join(", "):"0, 0, 0"}function s(o){return i(c(o))}function f(o,r,t){return[Math.max(0,Math.min(255,Math.round(o[0]+(r[0]-o[0])*t))),Math.max(0,Math.min(255,Math.round(o[1]+(r[1]-o[1])*t))),Math.max(0,Math.min(255,Math.round(o[2]+(r[2]-o[2])*t)))]}function h(o,r,t){const e=c(o),n=c(r);return e&&n?i(f(e,n,t)):o}function g([o,r,t]){o/=255,r/=255,t/=255;const e=Math.max(o,r,t),n=Math.min(o,r,t);let u,l,a=(e+n)/2;if(e==n)u=l=0;else{const c=e-n;switch(l=a>.5?c/(2-e-n):c/(e+n),e){case o:u=(r-t)/c+(r<t?6:0);break;case r:u=(t-o)/c+2;break;default:u=(o-r)/c+4}u/=6}return[u,l,a]}function B([o,r,t]){let e=r/255,n=t/255;function u(o){let r=0;return r=o<=.04045?o/12.92:Math.pow((o+.055)/1.055,2.4),r}let l=.2126*u(o/255)+.7152*u(e)+.0722*u(n);return Math.round(10*function(o){let r=0;return r=o<=216/24389?o*(24389/27):116*Math.pow(o,1/3)-16,r}(l))/1e3}function C(o,r){const t=B(o),e=B(r);let n=.13*((1-(e-t))/2)+.05,u=1-Math.abs(e-t),l=n+Math.pow((1-n)*u,4);return Math.round(1e3*l)/1e3}function b(o,r){const t=c(o),e=g(t);let n=null,u=null;for(const i of r){const o=c(i),r=g(o);let t=!1;if(n&&u){const o=.3;Math.abs(r[2]-e[2])>o?r[1]>u[1]&&(t=!0):Math.abs(e[2]-r[2])>Math.abs(e[2]-u[2])&&(t=!0)}else t=!0;t&&(n=o,u=r)}let l=n,a=n,d=C(l,t),s=2*d;return e[2]>.2&&e[2]<.8&&(a=function([o,r,t]){return[Math.round(255-o),Math.round(255-r),Math.round(255-t)]}(a),s=C(a,t)),[i(f(t,l,d)),i(f(t,a,s))]}function k(o){const[r,t,e,n,u,l,a,i]=function(o,r,t,e){const[n,u]=b(o,[r]);let l,a;if(o===t)l=n,a=u;else{const n=b(t,[o,r,e]);l=n[0],a=n[1]}const i=c(o),d=c(t);let s,f,h,g;if(Math.abs(i[0]-d[0])<20&&Math.abs(i[1]-d[1])<20&&Math.abs(i[2]-d[2])<20){s=r,f=o;const t=b(s,[f]);h=t[0],g=t[1]}else s=o,f=r,h=n,g=u;return[n,u,l,a,s,f,h,g]}(o.brandBackgroundColor,o.brandForegroundColor,o.mainBackgroundColor,o.mainForegroundColor),d={...o,widgetBackgroundColor:u,widgetForegroundColor:l,widgetHoverBackgroundColor:a,widgetActiveBackgroundColor:i,sameBackground:s(o.mainBackgroundColor)==s(o.brandBackgroundColor)};if(d.brandHoverBackgroundColor&&(d.widgetHoverBackgroundColor=d.brandHoverBackgroundColor),d.brandActiveBackgroundColor&&(d.widgetActiveBackgroundColor=d.brandActiveBackgroundColor),d.brandHoverBackgroundColor||(d.brandHoverBackgroundColor=r),d.brandActiveBackgroundColor||(d.brandActiveBackgroundColor=t),d.mainHoverBackgroundColor||(d.mainHoverBackgroundColor=e),d.mainActiveBackgroundColor||(d.mainActiveBackgroundColor=n),d.bubbleBorderColor||(d.bubbleBorderColor=d.mainForegroundColor),d.checklistLauncherActiveBackgroundColor||(d.checklistLauncherActiveBackgroundColor=d.brandActiveBackgroundColor),d.checklistLauncherBackgroundColor||(d.checklistLauncherBackgroundColor=d.brandBackgroundColor),d.checklistLauncherCounterBackgroundColor||(d.checklistLauncherCounterBackgroundColor=d.brandForegroundColor),d.checklistLauncherCounterFontColor||(d.checklistLauncherCounterFontColor=d.brandBackgroundColor),d.checklistLauncherFontColor||(d.checklistLauncherFontColor=d.brandForegroundColor),d.checklistLauncherHoverBackgroundColor||(d.checklistLauncherHoverBackgroundColor=d.brandHoverBackgroundColor),d.focusColor||(d.focusColor=d.mainActiveBackgroundColor),d.launcherIconActiveColor||(d.launcherIconActiveColor=d.brandActiveBackgroundColor),d.launcherIconColor||(d.launcherIconColor=d.brandBackgroundColor),d.launcherIconHoverColor||(d.launcherIconHoverColor=d.brandHoverBackgroundColor),d.linkColor||(d.linkColor=d.widgetBackgroundColor),d.progressBarColor||(d.progressBarColor=d.widgetBackgroundColor),d.questionColor||(d.questionColor=d.widgetBackgroundColor),d.toolbarForegroundColor||(d.toolbarForegroundColor=d.mainForegroundColor),d.primaryButtonBackgroundColor||(d.primaryButtonBackgroundColor=d.widgetBackgroundColor),d.primaryButtonFontColor||(d.primaryButtonFontColor=d.widgetForegroundColor),d.primaryButtonHoverFontColor||(d.primaryButtonHoverFontColor=d.primaryButtonFontColor),d.primaryButtonActiveFontColor||(d.primaryButtonActiveFontColor=d.primaryButtonFontColor),!d.primaryButtonHoverBackgroundColor||!d.primaryButtonActiveBackgroundColor){const[o,r]=b(d.primaryButtonBackgroundColor,[d.primaryButtonFontColor]);d.primaryButtonHoverBackgroundColor||(d.primaryButtonHoverBackgroundColor=o),d.primaryButtonActiveBackgroundColor||(d.primaryButtonActiveBackgroundColor=r)}if(d.primaryButtonBorderColor||(d.primaryButtonBorderColor=d.widgetBackgroundColor),d.primaryButtonHoverBorderColor||(d.primaryButtonHoverBorderColor=d.primaryButtonHoverBackgroundColor),d.primaryButtonActiveBorderColor||(d.primaryButtonActiveBorderColor=d.primaryButtonActiveBackgroundColor),d.defaultButtonBackgroundColor||(d.defaultButtonBackgroundColor=d.mainBackgroundColor),d.defaultButtonFontColor||(d.defaultButtonFontColor=u),d.defaultButtonHoverFontColor||(d.defaultButtonHoverFontColor=d.defaultButtonFontColor),d.defaultButtonActiveFontColor||(d.defaultButtonActiveFontColor=d.defaultButtonFontColor),!d.defaultButtonHoverBackgroundColor||!d.defaultButtonActiveBackgroundColor){const[o,r]=b(d.defaultButtonBackgroundColor,[d.defaultButtonFontColor]);d.defaultButtonHoverBackgroundColor||(d.defaultButtonHoverBackgroundColor=o),d.defaultButtonActiveBackgroundColor||(d.defaultButtonActiveBackgroundColor=r)}return d.defaultButtonBorderColor||(d.defaultButtonBorderColor=d.defaultButtonFontColor),d.defaultButtonHoverBorderColor||(d.defaultButtonHoverBorderColor=d.defaultButtonBorderColor),d.defaultButtonActiveBorderColor||(d.defaultButtonActiveBorderColor=d.defaultButtonBorderColor),d.launcherButtonBackgroundColor||(d.launcherButtonBackgroundColor=d.brandBackgroundColor),d.launcherButtonBorderColor||(d.launcherButtonBorderColor=d.brandBackgroundColor),d.launcherButtonFontColor||(d.launcherButtonFontColor=d.brandForegroundColor),d.launcherButtonHoverBackgroundColor||(d.launcherButtonHoverBackgroundColor=d.brandHoverBackgroundColor),d.launcherButtonHoverBorderColor||(d.launcherButtonHoverBorderColor=d.launcherButtonHoverBackgroundColor),d.launcherButtonHoverFontColor||(d.launcherButtonHoverFontColor=d.launcherButtonFontColor),d.launcherButtonActiveBackgroundColor||(d.launcherButtonActiveBackgroundColor=d.brandActiveBackgroundColor),d.launcherButtonActiveBorderColor||(d.launcherButtonActiveBorderColor=d.launcherButtonActiveBackgroundColor),d.launcherButtonActiveFontColor||(d.launcherButtonActiveFontColor=d.launcherButtonFontColor),d}function w(o){const{questionColor:r}=o;return{"--userflow-backdrop-highlight-color-rgb":d(o.backdropHighlightColor),"--userflow-backdrop-highlight-inset":o.backdropHighlightType===t.INSIDE?"inset":"","--userflow-backdrop-highlight-opacity":o.backdropHighlightOpacity,"--userflow-backdrop-highlight-radius":o.backdropHighlightRadius+"px","--userflow-backdrop-highlight-spread":o.backdropHighlightSpread+"px","--userflow-backdrop-opacity":o.backdropOpacity,"--userflow-beacon-color":o.beaconColor,"--userflow-brand-active-background-color":o.brandActiveBackgroundColor,"--userflow-brand-background-color":o.brandBackgroundColor,"--userflow-brand-foreground-color":o.brandForegroundColor,"--userflow-brand-foreground-color-rgb":d(o.brandForegroundColor),"--userflow-brand-hover-background-color":o.brandHoverBackgroundColor,"--userflow-bubble-border-color":o.bubbleBorderColor,"--userflow-bubble-border-radius":o.bubbleBorderRadius+"px","--userflow-bubble-border-width":o.bubbleBorderWidth+"px","--userflow-button-border-radius":o.buttonBorderRadius+"px","--userflow-button-height":o.buttonHeight+"px","--userflow-button-min-width":o.buttonMinWidth+"px","--userflow-button-text-align":0===o.buttonMinWidth?"start":"center","--userflow-buttons-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"center"===o.buttonHorizontalAlign?"center":"flex-end","--userflow-buttons-modal-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"right"===o.buttonHorizontalAlign?"flex-end":"center","--userflow-checklist-launcher-active-background-color":o.checklistLauncherActiveBackgroundColor,"--userflow-checklist-launcher-background-color":o.checklistLauncherBackgroundColor,"--userflow-checklist-launcher-border-radius":o.checklistLauncherBorderRadius+"px","--userflow-checklist-launcher-counter-background-color":o.checklistLauncherCounterBackgroundColor,"--userflow-checklist-launcher-counter-font-color":o.checklistLauncherCounterFontColor,"--userflow-checklist-launcher-font-color-rgb":d(o.checklistLauncherFontColor),"--userflow-checklist-launcher-font-color":o.checklistLauncherFontColor,"--userflow-checklist-launcher-font-weight":String(o.checklistLauncherFontWeight),"--userflow-checklist-launcher-height":o.checklistLauncherHeight+"px","--userflow-checklist-launcher-hover-background-color":o.checklistLauncherHoverBackgroundColor,"--userflow-checkmark-background-color":o.checkmarkBackgroundColor,"--userflow-completed-task-text-decoration":o.completedTaskTextDecoration,"--userflow-default-button-active-background-color":o.defaultButtonActiveBackgroundColor,"--userflow-default-button-active-border-color":o.defaultButtonActiveBorderColor,"--userflow-default-button-active-font-color":o.defaultButtonActiveFontColor,"--userflow-default-button-background-color":o.defaultButtonBackgroundColor,"--userflow-default-button-border-color":o.defaultButtonBorderColor,"--userflow-default-button-border-width":o.defaultButtonBorderWidth+"px","--userflow-default-button-font-color":o.defaultButtonFontColor,"--userflow-default-button-font-weight":String(o.defaultButtonFontWeight),"--userflow-default-button-hover-background-color":o.defaultButtonHoverBackgroundColor,"--userflow-default-button-hover-border-color":o.defaultButtonHoverBorderColor,"--userflow-default-button-hover-font-color":o.defaultButtonHoverFontColor,"--userflow-focus-color":`rgba(${d(o.focusColor)}, ${o.focusOpacity})`,"--userflow-font-family":o.builtinFontFamily?o.builtinFontFamily.name+(o.builtinFontFamily.fallback?", "+o.builtinFontFamily.fallback:""):o.fontFamily?o.fontFamily:"sans-serif","--userflow-font-size":o.fontSize+"px","--userflow-font-weight-bold":String(o.fontWeightBold),"--userflow-font-weight-normal":String(o.fontWeightNormal),"--userflow-h1-font-size":o.h1FontSize+"px","--userflow-h2-font-size":o.h2FontSize+"px","--userflow-launcher-button-active-background-color":o.launcherButtonActiveBackgroundColor,"--userflow-launcher-button-active-border-color":o.launcherButtonActiveBorderColor,"--userflow-launcher-button-active-font-color":o.launcherButtonActiveFontColor,"--userflow-launcher-button-background-color":o.launcherButtonBackgroundColor,"--userflow-launcher-button-border-color":o.launcherButtonBorderColor,"--userflow-launcher-button-border-radius":o.launcherButtonBorderRadius+"px","--userflow-launcher-button-border-width":o.launcherButtonBorderWidth+"px","--userflow-launcher-button-font-color":o.launcherButtonFontColor,"--userflow-launcher-button-font-weight":String(o.launcherButtonFontWeight),"--userflow-launcher-button-height":o.launcherButtonHeight+"px","--userflow-launcher-button-horizontal-padding":o.launcherButtonHorizontalPadding+"px","--userflow-launcher-button-hover-background-color":o.launcherButtonHoverBackgroundColor,"--userflow-launcher-button-hover-border-color":o.launcherButtonHoverBorderColor,"--userflow-launcher-button-hover-font-color":o.launcherButtonHoverFontColor,"--userflow-launcher-button-width":o.launcherButtonWidth?o.launcherButtonWidth+"px":"auto","--userflow-launcher-icon-active-color":o.launcherIconActiveColor,"--userflow-launcher-icon-color":o.launcherIconColor,"--userflow-launcher-icon-hover-color":o.launcherIconHoverColor,"--userflow-launcher-icon-opacity":o.launcherIconOpacity,"--userflow-launcher-icon-size":o.launcherIconSize+"px","--userflow-line-height":o.lineHeight+"px","--userflow-link-color":o.linkColor,"--userflow-main-active-background-color":o.mainActiveBackgroundColor,"--userflow-main-background-color":o.mainBackgroundColor,"--userflow-main-background-color-rgb":d(o.mainBackgroundColor),"--userflow-main-foreground-color":o.mainForegroundColor,"--userflow-main-foreground-color-rgb":d(o.mainForegroundColor),"--userflow-main-hover-background-color":o.mainHoverBackgroundColor,"--userflow-modal-padding":o.modalPadding+"px","--userflow-modal-padding-top":(o.avatarType===e.NONE?o.modalPadding:o.modalPadding+Math.max((o.avatarSize-o.modalPadding)/2,0))+"px","--userflow-backdrop-color-rgb":d(o.backdropColor),"--userflow-notch-color":o.bubbleBorderWidth>0&&o.bubbleBorderColor||o.mainBackgroundColor,"--userflow-primary-button-active-background-color":o.primaryButtonActiveBackgroundColor,"--userflow-primary-button-active-border-color":o.primaryButtonActiveBorderColor,"--userflow-primary-button-active-font-color":o.primaryButtonActiveFontColor,"--userflow-primary-button-background-color":o.primaryButtonBackgroundColor,"--userflow-primary-button-border-color":o.primaryButtonBorderColor,"--userflow-primary-button-border-width":o.primaryButtonBorderWidth+"px","--userflow-primary-button-font-color":o.primaryButtonFontColor,"--userflow-primary-button-font-weight":String(o.primaryButtonFontWeight),"--userflow-primary-button-hover-background-color":o.primaryButtonHoverBackgroundColor,"--userflow-primary-button-hover-border-color":o.primaryButtonHoverBorderColor,"--userflow-primary-button-hover-font-color":o.primaryButtonHoverFontColor,"--userflow-progress-bar-color":o.progressBarColor,"--userflow-progress-bar-height":o.progressBarHeight+"px","--userflow-resource-center-collapsed-height":o.resourceCenterCollapsedHeight+"px","--userflow-resource-center-launcher-border-radius":(null!=o.resourceCenterLauncherBorderRadius?o.resourceCenterLauncherBorderRadius:o.resourceCenterCollapsedHeight/2)+"px","--userflow-resource-center-padding-x":o.resourceCenterPaddingX+"px","--userflow-resource-center-padding-y":o.resourceCenterPaddingY+"px","--userflow-resource-center-transition-duration":o.resourceCenterTransitionDuration+"ms","--userflow-resource-center-width":o.resourceCenterWidth+"px","--userflow-question-color-light":h(r,o.mainBackgroundColor,.5),"--userflow-question-color-lighter":h(r,o.mainBackgroundColor,.75),"--userflow-question-color-lightest":h(r,o.mainBackgroundColor,.9),"--userflow-question-color-medium-light":h(r,o.mainBackgroundColor,.15),"--userflow-question-color":r,"--userflow-toolbar-foreground-color":o.toolbarForegroundColor,"--userflow-toolbar-foreground-color-rgb":d(o.toolbarForegroundColor),"--userflow-tooltip-notch-size":o.tooltipNotchSize+"px","--userflow-widget-background-color":o.widgetBackgroundColor}}const p=[];function m(r){let[t,e]=o.useState(r);const n=a(r.sessionData||p);return o.useLayoutEffect((()=>{const{variations:o}=r;if(!o)return;const t=[],l=[],a=()=>{let n=r,u=!1;for(const[r,e]of o.entries())if(t[r]){u||(u=!0,n={...n});for(const o of e.overriddenKeys)n[o]=e[o]}e(n)};for(const[r,e]of o.entries()){t[r]=!1;const{condition:o}=e;if(o&&e.overriddenKeys&&e.overriddenKeys.length>0){const e=u[o.type].track({sessionData:n,condition:o,callback:o=>{t[r]=o,a()}});l[r]=e}else l[r]=()=>{}}return a(),()=>{for(const o of l)o()}}),[r,n]),o.useMemo((()=>k(t)),[t])}const v=new Map;function y(r,t,e){const n=l(),[u,a]=o.useState(!t);return o.useLayoutEffect((()=>{if(!r||!t)return;let o=!1;return(async()=>{let u=t;if(window.MSInputMethodContext&&document.documentMode&&e){let r=await function(o){return new Promise(((r,t)=>{let e=F.get(o);if(e)return void r(e);const n=new XMLHttpRequest;n.addEventListener("load",(()=>{if(200!==n.status)return void t(new Error("Userflow.js could not fetch stylesheet: "+o));const e=n.responseText;F.set(o,e),r(e)})),n.addEventListener("error",(()=>{t(new Error("Userflow.js could not fetch stylesheet: "+o))})),n.open("GET",o),n.send()}))}(t);if(o)return;r=function(o,r){for(const t in r)if(r.hasOwnProperty(t)){const e=r[t];e&&(o=o.replace(new RegExp(`var\\(${t}.*?\\)`,"g"),e))}return o=o.replace(/var\(--[a-z0-9-]+(,\s*(.*?))?\)/g,"$2")}(r,w(e)),u="data:text/css;base64,"+btoa(r)}await A(n,r,u),o||a(!0)})(),()=>{o=!0}}),[n,r,t,e]),{loaded:u}}const F=new Map;function H(r,t){const e=t&&function(o){if(!o.builtinFontFamily)return o.fontCssUrl?{url:o.fontCssUrl,fontFamily:o.fontFamily}:null;switch(o.builtinFontFamily.provider){case n.GOOGLE:{const r=Array.from(new Set(["0,400","1,400",`0,${o.fontWeightBold}`,`0,${o.defaultButtonFontWeight}`,`0,${o.primaryButtonFontWeight}`,`0,${o.checklistLauncherFontWeight}`,`0,${o.launcherButtonFontWeight}`])).sort().join(";");return{url:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(o.builtinFontFamily.name)}:ital,wght@${r}`,fontFamily:o.builtinFontFamily.name}}case n.STANDARD:return null}}(t),u=e?.url,l=e?.fontFamily,[a,c]=o.useState(!u||!l);return o.useLayoutEffect((()=>{if(!r||!u||!l)return;let o=!1;return A(null,r,u),function(o,r,t){if(!o.document.fonts)return t(),()=>{};let e=!1;const n=()=>{const u=o.document.fonts.load(`100px ${r}`,"BESbswy");if(!u)return l(),void t();u.then((o=>{e||(o.length>=1?(l(),t()):window.setTimeout(n,25))}),(o=>{console.log("Userflow.js: observeFont error:"),console.log(o),t()}))};n();const u=window.setTimeout((()=>{console.warn(`Userflow.js: Timed out waiting for font family ${r} to load. Will continue anyway.`),t()}),2e3),l=()=>{e=!0,window.clearTimeout(void 0),window.clearTimeout(u)}}(r,l,(()=>{o||c(!0)})),()=>{o=!0}}),[r,u,l]),{loaded:a}}function A(o,r,t){const e=function(o){let r=v.get(o);return r||(r={stylesheets:new Map},v.set(o,r)),r}(r),n=e.stylesheets.get(t);if(n)return n.loadPromise;const u=new Promise(((e,n)=>{const u=r.document.createElement("link");u.dataset.userflowStylesheet="true",u.rel="stylesheet",u.href=t,u.onload=()=>{e()},u.onerror=r=>{console.log(`Userflow.js: Error installing Stylesheet ${t}:`,r),o&&o.reportCspIssue(),n()},r.document.head.appendChild(u)}));return e.stylesheets.set(t,{loadPromise:u}),u}export{y as a,a as b,H as c,w as g,m as u};
|
|
1
|
+
import{r as o}from"./vendor.react.js";import{v as r,B as t,A as e,w as n}from"./userflow.js";import{c as u}from"./flow-condition-types.js";import{a as l}from"./client-context.js";function a(t){const[e]=o.useState((()=>new r(t)));return e.update(t),e}function c(o){return o?o.match(/^#[0-9a-f]{6}$/i)?[parseInt(o.substring(1,3),16),parseInt(o.substring(3,5),16),parseInt(o.substring(5,7),16)]:o.match(/^#[0-9a-f]{3}$/i)?[parseInt(o.substring(1,2).repeat(2),16),parseInt(o.substring(2,3).repeat(2),16),parseInt(o.substring(3,4).repeat(2),16)]:[0,0,0]:[0,0,0]}function i([o,r,t]){return"#"+o.toString(16).padStart(2,"0")+r.toString(16).padStart(2,"0")+t.toString(16).padStart(2,"0")}function d(o){const r=c(o);return r?r.join(", "):"0, 0, 0"}function s(o){return i(c(o))}function f(o,r,t){return[Math.max(0,Math.min(255,Math.round(o[0]+(r[0]-o[0])*t))),Math.max(0,Math.min(255,Math.round(o[1]+(r[1]-o[1])*t))),Math.max(0,Math.min(255,Math.round(o[2]+(r[2]-o[2])*t)))]}function h(o,r,t){const e=c(o),n=c(r);return e&&n?i(f(e,n,t)):o}function g([o,r,t]){o/=255,r/=255,t/=255;const e=Math.max(o,r,t),n=Math.min(o,r,t);let u,l,a=(e+n)/2;if(e==n)u=l=0;else{const c=e-n;switch(l=a>.5?c/(2-e-n):c/(e+n),e){case o:u=(r-t)/c+(r<t?6:0);break;case r:u=(t-o)/c+2;break;default:u=(o-r)/c+4}u/=6}return[u,l,a]}function B([o,r,t]){let e=r/255,n=t/255;function u(o){let r=0;return r=o<=.04045?o/12.92:Math.pow((o+.055)/1.055,2.4),r}let l=.2126*u(o/255)+.7152*u(e)+.0722*u(n);return Math.round(10*function(o){let r=0;return r=o<=216/24389?o*(24389/27):116*Math.pow(o,1/3)-16,r}(l))/1e3}function C(o,r){const t=B(o),e=B(r);let n=.13*((1-(e-t))/2)+.05,u=1-Math.abs(e-t),l=n+Math.pow((1-n)*u,4);return Math.round(1e3*l)/1e3}function b(o,r){const t=c(o),e=g(t);let n=null,u=null;for(const i of r){const o=c(i),r=g(o);let t=!1;if(n&&u){const o=.3;Math.abs(r[2]-e[2])>o?r[1]>u[1]&&(t=!0):Math.abs(e[2]-r[2])>Math.abs(e[2]-u[2])&&(t=!0)}else t=!0;t&&(n=o,u=r)}let l=n,a=n,d=C(l,t),s=2*d;return e[2]>.2&&e[2]<.8&&(a=function([o,r,t]){return[Math.round(255-o),Math.round(255-r),Math.round(255-t)]}(a),s=C(a,t)),[i(f(t,l,d)),i(f(t,a,s))]}function k(o){const[r,t,e,n,u,l,a,i]=function(o,r,t,e){const[n,u]=b(o,[r]);let l,a;if(o===t)l=n,a=u;else{const n=b(t,[o,r,e]);l=n[0],a=n[1]}const i=c(o),d=c(t);let s,f,h,g;if(Math.abs(i[0]-d[0])<20&&Math.abs(i[1]-d[1])<20&&Math.abs(i[2]-d[2])<20){s=r,f=o;const t=b(s,[f]);h=t[0],g=t[1]}else s=o,f=r,h=n,g=u;return[n,u,l,a,s,f,h,g]}(o.brandBackgroundColor,o.brandForegroundColor,o.mainBackgroundColor,o.mainForegroundColor),d={...o,widgetBackgroundColor:u,widgetForegroundColor:l,widgetHoverBackgroundColor:a,widgetActiveBackgroundColor:i,sameBackground:s(o.mainBackgroundColor)==s(o.brandBackgroundColor)};if(d.brandHoverBackgroundColor&&(d.widgetHoverBackgroundColor=d.brandHoverBackgroundColor),d.brandActiveBackgroundColor&&(d.widgetActiveBackgroundColor=d.brandActiveBackgroundColor),d.brandHoverBackgroundColor||(d.brandHoverBackgroundColor=r),d.brandActiveBackgroundColor||(d.brandActiveBackgroundColor=t),d.mainHoverBackgroundColor||(d.mainHoverBackgroundColor=e),d.mainActiveBackgroundColor||(d.mainActiveBackgroundColor=n),d.bubbleBorderColor||(d.bubbleBorderColor=d.mainForegroundColor),d.checklistLauncherActiveBackgroundColor||(d.checklistLauncherActiveBackgroundColor=d.brandActiveBackgroundColor),d.checklistLauncherBackgroundColor||(d.checklistLauncherBackgroundColor=d.brandBackgroundColor),d.checklistLauncherCounterBackgroundColor||(d.checklistLauncherCounterBackgroundColor=d.brandForegroundColor),d.checklistLauncherCounterFontColor||(d.checklistLauncherCounterFontColor=d.brandBackgroundColor),d.checklistLauncherFontColor||(d.checklistLauncherFontColor=d.brandForegroundColor),d.checklistLauncherHoverBackgroundColor||(d.checklistLauncherHoverBackgroundColor=d.brandHoverBackgroundColor),d.focusColor||(d.focusColor=d.mainActiveBackgroundColor),d.launcherIconActiveColor||(d.launcherIconActiveColor=d.brandActiveBackgroundColor),d.launcherIconColor||(d.launcherIconColor=d.brandBackgroundColor),d.launcherIconHoverColor||(d.launcherIconHoverColor=d.brandHoverBackgroundColor),d.linkColor||(d.linkColor=d.widgetBackgroundColor),d.progressBarColor||(d.progressBarColor=d.widgetBackgroundColor),d.questionColor||(d.questionColor=d.widgetBackgroundColor),d.toolbarForegroundColor||(d.toolbarForegroundColor=d.mainForegroundColor),d.primaryButtonBackgroundColor||(d.primaryButtonBackgroundColor=d.widgetBackgroundColor),d.primaryButtonFontColor||(d.primaryButtonFontColor=d.widgetForegroundColor),d.primaryButtonHoverFontColor||(d.primaryButtonHoverFontColor=d.primaryButtonFontColor),d.primaryButtonActiveFontColor||(d.primaryButtonActiveFontColor=d.primaryButtonFontColor),!d.primaryButtonHoverBackgroundColor||!d.primaryButtonActiveBackgroundColor){const[o,r]=b(d.primaryButtonBackgroundColor,[d.primaryButtonFontColor]);d.primaryButtonHoverBackgroundColor||(d.primaryButtonHoverBackgroundColor=o),d.primaryButtonActiveBackgroundColor||(d.primaryButtonActiveBackgroundColor=r)}if(d.primaryButtonBorderColor||(d.primaryButtonBorderColor=d.widgetBackgroundColor),d.primaryButtonHoverBorderColor||(d.primaryButtonHoverBorderColor=d.primaryButtonHoverBackgroundColor),d.primaryButtonActiveBorderColor||(d.primaryButtonActiveBorderColor=d.primaryButtonActiveBackgroundColor),d.defaultButtonBackgroundColor||(d.defaultButtonBackgroundColor=d.mainBackgroundColor),d.defaultButtonFontColor||(d.defaultButtonFontColor=u),d.defaultButtonHoverFontColor||(d.defaultButtonHoverFontColor=d.defaultButtonFontColor),d.defaultButtonActiveFontColor||(d.defaultButtonActiveFontColor=d.defaultButtonFontColor),!d.defaultButtonHoverBackgroundColor||!d.defaultButtonActiveBackgroundColor){const[o,r]=b(d.defaultButtonBackgroundColor,[d.defaultButtonFontColor]);d.defaultButtonHoverBackgroundColor||(d.defaultButtonHoverBackgroundColor=o),d.defaultButtonActiveBackgroundColor||(d.defaultButtonActiveBackgroundColor=r)}return d.defaultButtonBorderColor||(d.defaultButtonBorderColor=d.defaultButtonFontColor),d.defaultButtonHoverBorderColor||(d.defaultButtonHoverBorderColor=d.defaultButtonBorderColor),d.defaultButtonActiveBorderColor||(d.defaultButtonActiveBorderColor=d.defaultButtonBorderColor),d.launcherButtonBackgroundColor||(d.launcherButtonBackgroundColor=d.brandBackgroundColor),d.launcherButtonBorderColor||(d.launcherButtonBorderColor=d.brandBackgroundColor),d.launcherButtonFontColor||(d.launcherButtonFontColor=d.brandForegroundColor),d.launcherButtonHoverBackgroundColor||(d.launcherButtonHoverBackgroundColor=d.brandHoverBackgroundColor),d.launcherButtonHoverBorderColor||(d.launcherButtonHoverBorderColor=d.launcherButtonHoverBackgroundColor),d.launcherButtonHoverFontColor||(d.launcherButtonHoverFontColor=d.launcherButtonFontColor),d.launcherButtonActiveBackgroundColor||(d.launcherButtonActiveBackgroundColor=d.brandActiveBackgroundColor),d.launcherButtonActiveBorderColor||(d.launcherButtonActiveBorderColor=d.launcherButtonActiveBackgroundColor),d.launcherButtonActiveFontColor||(d.launcherButtonActiveFontColor=d.launcherButtonFontColor),d}function w(o){const{questionColor:r}=o;return{"--userflow-backdrop-highlight-color-rgb":d(o.backdropHighlightColor),"--userflow-backdrop-highlight-inset":o.backdropHighlightType===t.INSIDE?"inset":"","--userflow-backdrop-highlight-opacity":o.backdropHighlightOpacity,"--userflow-backdrop-highlight-radius":o.backdropHighlightRadius+"px","--userflow-backdrop-highlight-spread":o.backdropHighlightSpread+"px","--userflow-backdrop-opacity":o.backdropOpacity,"--userflow-beacon-color":o.beaconColor,"--userflow-brand-active-background-color":o.brandActiveBackgroundColor,"--userflow-brand-background-color":o.brandBackgroundColor,"--userflow-brand-foreground-color":o.brandForegroundColor,"--userflow-brand-foreground-color-rgb":d(o.brandForegroundColor),"--userflow-brand-hover-background-color":o.brandHoverBackgroundColor,"--userflow-bubble-border-color":o.bubbleBorderColor,"--userflow-bubble-border-radius":o.bubbleBorderRadius+"px","--userflow-bubble-border-width":o.bubbleBorderWidth+"px","--userflow-button-border-radius":o.buttonBorderRadius+"px","--userflow-button-height":o.buttonHeight+"px","--userflow-button-min-width":o.buttonMinWidth+"px","--userflow-button-text-align":0===o.buttonMinWidth?"start":"center","--userflow-buttons-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"center"===o.buttonHorizontalAlign?"center":"flex-end","--userflow-buttons-modal-justify-content":"left"===o.buttonHorizontalAlign?"flex-start":"right"===o.buttonHorizontalAlign?"flex-end":"center","--userflow-checklist-launcher-active-background-color":o.checklistLauncherActiveBackgroundColor,"--userflow-checklist-launcher-background-color":o.checklistLauncherBackgroundColor,"--userflow-checklist-launcher-border-radius":o.checklistLauncherBorderRadius+"px","--userflow-checklist-launcher-counter-background-color":o.checklistLauncherCounterBackgroundColor,"--userflow-checklist-launcher-counter-font-color":o.checklistLauncherCounterFontColor,"--userflow-checklist-launcher-font-color-rgb":d(o.checklistLauncherFontColor),"--userflow-checklist-launcher-font-color":o.checklistLauncherFontColor,"--userflow-checklist-launcher-font-weight":String(o.checklistLauncherFontWeight),"--userflow-checklist-launcher-height":o.checklistLauncherHeight+"px","--userflow-checklist-launcher-hover-background-color":o.checklistLauncherHoverBackgroundColor,"--userflow-checkmark-background-color":o.checkmarkBackgroundColor,"--userflow-completed-task-text-decoration":o.completedTaskTextDecoration,"--userflow-default-button-active-background-color":o.defaultButtonActiveBackgroundColor,"--userflow-default-button-active-border-color":o.defaultButtonActiveBorderColor,"--userflow-default-button-active-font-color":o.defaultButtonActiveFontColor,"--userflow-default-button-background-color":o.defaultButtonBackgroundColor,"--userflow-default-button-border-color":o.defaultButtonBorderColor,"--userflow-default-button-border-width":o.defaultButtonBorderWidth+"px","--userflow-default-button-font-color":o.defaultButtonFontColor,"--userflow-default-button-font-weight":String(o.defaultButtonFontWeight),"--userflow-default-button-hover-background-color":o.defaultButtonHoverBackgroundColor,"--userflow-default-button-hover-border-color":o.defaultButtonHoverBorderColor,"--userflow-default-button-hover-font-color":o.defaultButtonHoverFontColor,"--userflow-focus-color":`rgba(${d(o.focusColor)}, ${o.focusOpacity})`,"--userflow-font-family":o.builtinFontFamily?o.builtinFontFamily.name+(o.builtinFontFamily.fallback?", "+o.builtinFontFamily.fallback:""):o.fontFamily?o.fontFamily:"sans-serif","--userflow-font-size":o.fontSize+"px","--userflow-font-weight-bold":String(o.fontWeightBold),"--userflow-font-weight-normal":String(o.fontWeightNormal),"--userflow-h1-font-size":o.h1FontSize+"px","--userflow-h2-font-size":o.h2FontSize+"px","--userflow-launcher-button-active-background-color":o.launcherButtonActiveBackgroundColor,"--userflow-launcher-button-active-border-color":o.launcherButtonActiveBorderColor,"--userflow-launcher-button-active-font-color":o.launcherButtonActiveFontColor,"--userflow-launcher-button-background-color":o.launcherButtonBackgroundColor,"--userflow-launcher-button-border-color":o.launcherButtonBorderColor,"--userflow-launcher-button-border-radius":o.launcherButtonBorderRadius+"px","--userflow-launcher-button-border-width":o.launcherButtonBorderWidth+"px","--userflow-launcher-button-font-color":o.launcherButtonFontColor,"--userflow-launcher-button-font-weight":String(o.launcherButtonFontWeight),"--userflow-launcher-button-height":o.launcherButtonHeight+"px","--userflow-launcher-button-horizontal-padding":o.launcherButtonHorizontalPadding+"px","--userflow-launcher-button-hover-background-color":o.launcherButtonHoverBackgroundColor,"--userflow-launcher-button-hover-border-color":o.launcherButtonHoverBorderColor,"--userflow-launcher-button-hover-font-color":o.launcherButtonHoverFontColor,"--userflow-launcher-button-width":o.launcherButtonWidth?o.launcherButtonWidth+"px":"auto","--userflow-launcher-icon-active-color":o.launcherIconActiveColor,"--userflow-launcher-icon-color":o.launcherIconColor,"--userflow-launcher-icon-hover-color":o.launcherIconHoverColor,"--userflow-launcher-icon-opacity":o.launcherIconOpacity,"--userflow-launcher-icon-size":o.launcherIconSize+"px","--userflow-line-height":o.lineHeight+"px","--userflow-link-color":o.linkColor,"--userflow-main-active-background-color":o.mainActiveBackgroundColor,"--userflow-main-background-color":o.mainBackgroundColor,"--userflow-main-background-color-rgb":d(o.mainBackgroundColor),"--userflow-main-foreground-color":o.mainForegroundColor,"--userflow-main-foreground-color-rgb":d(o.mainForegroundColor),"--userflow-main-hover-background-color":o.mainHoverBackgroundColor,"--userflow-modal-padding":o.modalPadding+"px","--userflow-modal-padding-top":(o.avatarType===e.NONE?o.modalPadding:o.modalPadding+Math.max((o.avatarSize-o.modalPadding)/2,0))+"px","--userflow-backdrop-color-rgb":d(o.backdropColor),"--userflow-notch-color":o.bubbleBorderWidth>0&&o.bubbleBorderColor||o.mainBackgroundColor,"--userflow-primary-button-active-background-color":o.primaryButtonActiveBackgroundColor,"--userflow-primary-button-active-border-color":o.primaryButtonActiveBorderColor,"--userflow-primary-button-active-font-color":o.primaryButtonActiveFontColor,"--userflow-primary-button-background-color":o.primaryButtonBackgroundColor,"--userflow-primary-button-border-color":o.primaryButtonBorderColor,"--userflow-primary-button-border-width":o.primaryButtonBorderWidth+"px","--userflow-primary-button-font-color":o.primaryButtonFontColor,"--userflow-primary-button-font-weight":String(o.primaryButtonFontWeight),"--userflow-primary-button-hover-background-color":o.primaryButtonHoverBackgroundColor,"--userflow-primary-button-hover-border-color":o.primaryButtonHoverBorderColor,"--userflow-primary-button-hover-font-color":o.primaryButtonHoverFontColor,"--userflow-progress-bar-color":o.progressBarColor,"--userflow-progress-bar-height":o.progressBarHeight+"px","--userflow-resource-center-collapsed-height":o.resourceCenterCollapsedHeight+"px","--userflow-resource-center-launcher-border-radius":(null!=o.resourceCenterLauncherBorderRadius?o.resourceCenterLauncherBorderRadius:o.resourceCenterCollapsedHeight/2)+"px","--userflow-resource-center-padding-x":o.resourceCenterPaddingX+"px","--userflow-resource-center-padding-y":o.resourceCenterPaddingY+"px","--userflow-resource-center-transition-duration":o.resourceCenterTransitionDuration+"ms","--userflow-resource-center-width":o.resourceCenterWidth+"px","--userflow-question-color-light":h(r,o.mainBackgroundColor,.5),"--userflow-question-color-lighter":h(r,o.mainBackgroundColor,.75),"--userflow-question-color-lightest":h(r,o.mainBackgroundColor,.9),"--userflow-question-color-medium-light":h(r,o.mainBackgroundColor,.15),"--userflow-question-color":r,"--userflow-toolbar-foreground-color":o.toolbarForegroundColor,"--userflow-toolbar-foreground-color-rgb":d(o.toolbarForegroundColor),"--userflow-tooltip-notch-size":o.tooltipNotchSize+"px","--userflow-widget-background-color":o.widgetBackgroundColor}}const p=[];function m(r){let[t,e]=o.useState(r);const n=a(r.sessionData||p);return o.useLayoutEffect((()=>{const{variations:o}=r;if(!o)return;const t=[],l=[],a=()=>{let n=r,u=!1;for(const[r,e]of o.entries())if(t[r]){u||(u=!0,n={...n});for(const o of e.overriddenKeys)n[o]=e[o]}e(n)};for(const[r,e]of o.entries()){t[r]=!1;const{condition:o}=e;if(o&&e.overriddenKeys&&e.overriddenKeys.length>0){const e=u[o.type].track({sessionData:n,condition:o,callback:o=>{t[r]=o,a()}});l[r]=e}else l[r]=()=>{}}return a(),()=>{for(const o of l)o()}}),[r,n]),o.useMemo((()=>k(t)),[t])}const v=new Map;function y(r,t,e){const n=l(),[u,a]=o.useState(!t);return o.useLayoutEffect((()=>{if(!r||!t)return;let o=!1;return(async()=>{let u=t;if(window.MSInputMethodContext&&document.documentMode&&e){let r=await function(o){return new Promise(((r,t)=>{let e=F.get(o);if(e)return void r(e);const n=new XMLHttpRequest;n.addEventListener("load",(()=>{if(200!==n.status)return void t(new Error("Userflow.js could not fetch stylesheet: "+o));const e=n.responseText;F.set(o,e),r(e)})),n.addEventListener("error",(()=>{t(new Error("Userflow.js could not fetch stylesheet: "+o))})),n.open("GET",o),n.send()}))}(t);if(o)return;r=function(o,r){for(const t in r)if(r.hasOwnProperty(t)){const e=r[t];e&&(o=o.replace(new RegExp(`var\\(${t}.*?\\)`,"g"),e))}return o=o.replace(/var\(--[a-z0-9-]+(,\s*(.*?))?\)/g,"$2")}(r,w(e)),u="data:text/css;base64,"+btoa(r)}await A(n,r,u),o||a(!0)})(),()=>{o=!0}}),[n,r,t,e]),{loaded:u}}const F=new Map;function H(r,t){const e=t&&function(o){if(!o.builtinFontFamily)return o.fontCssUrl?{url:o.fontCssUrl,fontFamily:o.fontFamily}:null;switch(o.builtinFontFamily.provider){case n.GOOGLE:{const r=Array.from(new Set(["0,400","1,400",`0,${o.fontWeightBold}`,`0,${o.defaultButtonFontWeight}`,`0,${o.primaryButtonFontWeight}`,`0,${o.checklistLauncherFontWeight}`,`0,${o.launcherButtonFontWeight}`])).sort().join(";");return{url:`https://fonts.googleapis.com/css2?family=${encodeURIComponent(o.builtinFontFamily.name)}:ital,wght@${r}`,fontFamily:o.builtinFontFamily.name}}case n.STANDARD:return null}}(t),u=e?.url,l=e?.fontFamily,[a,c]=o.useState(!u||!l);return o.useLayoutEffect((()=>{if(!r||!u||!l)return;let o=!1;return A(null,r,u),function(o,r,t){if(!o.document.fonts)return t(),()=>{};let e=!1;const n=()=>{const u=o.document.fonts.load(`100px ${r}`,"BESbswy");if(!u)return l(),void t();u.then((o=>{e||(o.length>=1?(l(),t()):window.setTimeout(n,25))}),(o=>{console.log("Userflow.js: observeFont error:"),console.log(o),t()}))};n();const u=window.setTimeout((()=>{console.warn(`Userflow.js: Timed out waiting for font family ${r} to load. Will continue anyway.`),t()}),2e3),l=()=>{e=!0,window.clearTimeout(void 0),window.clearTimeout(u)}}(r,l,(()=>{o||c(!0)})),()=>{o=!0}}),[r,u,l]),{loaded:a}}function A(o,r,t){const e=function(o){let r=v.get(o);return r||(r={stylesheets:new Map},v.set(o,r)),r}(r),n=e.stylesheets.get(t);if(n)return n.loadPromise;const u=new Promise(((e,n)=>{const u=r.document.createElement("link");u.dataset.userflowStylesheet="true",u.rel="stylesheet",u.href=t,u.onload=()=>{e()},u.onerror=r=>{console.log(`Userflow.js: Error installing Stylesheet ${t}:`,r),o&&o.reportCspIssue(),n()},r.document.head.appendChild(u)}));return e.stylesheets.set(t,{loadPromise:u}),u}export{y as a,a as b,H as c,w as g,m as u};
|
package/ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{u as n,i as s,U as i}from"./client-context.js";import{_ as r,R as o,U as c}from"./userflow.js";import{I as a}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";const l=e.lazy((()=>r((()=>import("./ElementSelectionApp.js")),[new URL("ElementSelectionApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.is-hotkey.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),u=e.lazy((()=>r((()=>import("./FlowApp.js")),[new URL("FlowApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),m=e.lazy((()=>r((()=>import("./ChecklistApp.js")),[new URL("ChecklistApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()]))),d=e.lazy(o),p=e.lazy((()=>r((()=>import("./LauncherApp.js")),[new URL("LauncherApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),h=e.lazy((()=>r((()=>import("./NotificationsApp.js")),[new URL("NotificationsApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]))),E=e.lazy((()=>r((()=>import("./TrackerTestingApp.js")),[new URL("TrackerTestingApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),S=()=>{const t=n(),[s,i]=e.useState(t.getSessionStorageState()),[r,o]=e.useState((()=>f()?null:t.flowSession)),[c,a]=e.useState(t.checklistSession),[S,_]=e.useState(t.checklistExpanded),[v,k]=e.useState(t.resourceCenterSession),[b,y]=e.useState(t.resourceCenterOpen),[j,g]=e.useState(t.resourceCenterLauncherHidden),[w,A]=e.useState(t.resourceCenterEmbedsChecklist()),[C,L]=e.useState(t.launcherSessions),[T,I]=e.useState(t.activeLauncherFlowId),[O,x]=e.useState(t.notifications);e.useEffect((()=>{const e=()=>{i(t.getSessionStorageState()),o((e=>f()&&t.flowSession?.id!==e?.id?null:t.flowSession)),a(t.checklistSession),_(t.checklistExpanded),k(t.resourceCenterSession),y(t.resourceCenterOpen),g(t.resourceCenterLauncherHidden),A(t.resourceCenterEmbedsChecklist()),L(t.launcherSessions),I(t.activeLauncherFlowId),x(t.notifications)};t.on("uistatechange",e);const n=()=>{f()||o(t.flowSession)};return document.addEventListener("visibilitychange",n),()=>{t.off("uistatechange",e),document.removeEventListener("visibilitychange",n)}}),[t]);const z=!s.activeApp&&!!r;return e.useLayoutEffect((()=>{if(z)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}}),[t,z]),"elementSelection"===s.activeApp&&s.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(l,{state:s.elementSelection})):"trackerTesting"===s.activeApp&&s.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(E,{state:s.trackerTesting})):e.createElement(e.Fragment,null,r&&e.createElement(e.Suspense,{fallback:null},e.createElement(u,{key:r.id,session:r,checklistSession:c,resourceCenterEmbedsChecklist:w})),c&&!w&&(S||c.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(m,{key:c.id,session:c,checklistExpanded:S})),v&&(b||!j)&&e.createElement(e.Suspense,{fallback:null},e.createElement(d,{key:v.id,session:v,isOpen:b,flowSession:r,checklistSession:c})),!r&&e.createElement(e.Suspense,{fallback:null},C.map((t=>e.createElement(p,{key:t.flow.id,session:t,active:t.flow.id===T})))),O.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(h,{notifications:O})))};function f(){return"hidden"===document.visibilityState}const _=({client:t})=>e.createElement(a,{i18n:s},e.createElement(i.Provider,{value:t},e.createElement(S,null)));class v{constructor(e){this.client=e}mount(){if(this.container)throw new c("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),t.render(e.createElement(_,{client:this.client}),this.container)}unmount(){this.container&&(t.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{v as RealUI};
|
|
1
|
+
import{r as e}from"./vendor.react.js";import{r as t}from"./vendor.react-dom.js";import{u as n,i as s,U as i}from"./client-context.js";import{_ as r,R as o,U as c}from"./userflow.js";import{I as a}from"./vendor.react-i18next.js";import"./vendor.object-assign.js";import"./vendor.scheduler.js";import"./vendor.i18next.js";import"./vendor.phoenix.js";import"./vendor.uuid.js";import"./vendor.babel.runtime.js";const l=e.lazy((()=>r((()=>import("./ElementSelectionApp.js")),[new URL("ElementSelectionApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.is-hotkey.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),u=e.lazy((()=>r((()=>import("./FlowApp.js")),[new URL("FlowApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),m=e.lazy((()=>r((()=>import("./ChecklistApp.js")),[new URL("ChecklistApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString()]))),d=e.lazy(o),p=e.lazy((()=>r((()=>import("./LauncherApp.js")),[new URL("LauncherApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("FlowChrome.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("Trigger.js",import.meta.url).toString()]))),h=e.lazy((()=>r((()=>import("./NotificationsApp.js")),[new URL("NotificationsApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]))),E=e.lazy((()=>r((()=>import("./TrackerTestingApp.js")),[new URL("TrackerTestingApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("BuilderBar.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("userflow.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-light-svg-icons.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString()]))),S=()=>{const t=n(),[s,i]=e.useState(t.getSessionStorageState()),[r,o]=e.useState((()=>f()?null:t.flowSession)),[c,a]=e.useState(t.checklistSession),[S,_]=e.useState(t.checklistExpanded),[v,k]=e.useState(t.resourceCenterSession),[b,y]=e.useState(t.resourceCenterOpen),[j,g]=e.useState(t.resourceCenterLauncherHidden),[w,A]=e.useState(t.resourceCenterEmbedsChecklist()),[C,L]=e.useState(t.launcherSessions),[T,I]=e.useState(t.activeLauncherFlowId),[O,x]=e.useState(t.notifications);e.useEffect((()=>{const e=()=>{i(t.getSessionStorageState()),o((e=>f()&&t.flowSession?.id!==e?.id?null:t.flowSession)),a(t.checklistSession),_(t.checklistExpanded),k(t.resourceCenterSession),y(t.resourceCenterOpen),g(t.resourceCenterLauncherHidden),A(t.resourceCenterEmbedsChecklist()),L(t.launcherSessions),I(t.activeLauncherFlowId),x(t.notifications)};t.on("uistatechange",e);const n=()=>{f()||o(t.flowSession)};return document.addEventListener("visibilitychange",n),()=>{t.off("uistatechange",e),document.removeEventListener("visibilitychange",n)}}),[t]);const z=!s.activeApp&&!!r;return e.useLayoutEffect((()=>{if(z)return t.emit("flowvisibilitychange",!0),()=>{t.emit("flowvisibilitychange",!1)}}),[t,z]),"elementSelection"===s.activeApp&&s.elementSelection?e.createElement(e.Suspense,{fallback:null},e.createElement(l,{state:s.elementSelection})):"trackerTesting"===s.activeApp&&s.trackerTesting?e.createElement(e.Suspense,{fallback:null},e.createElement(E,{state:s.trackerTesting})):e.createElement(e.Fragment,null,r&&e.createElement(e.Suspense,{fallback:null},e.createElement(u,{key:r.id,session:r,checklistSession:c,resourceCenterEmbedsChecklist:w})),c&&!w&&(S||c.version.checklist?.launcherEnabled)&&e.createElement(e.Suspense,{fallback:null},e.createElement(m,{key:c.id,session:c,checklistExpanded:S})),v&&(b||!j)&&e.createElement(e.Suspense,{fallback:null},e.createElement(d,{key:v.id,session:v,isOpen:b,flowSession:r,checklistSession:c})),!r&&e.createElement(e.Suspense,{fallback:null},C.map((t=>e.createElement(p,{key:t.flow.id,session:t,active:t.flow.id===T})))),O.length>0&&e.createElement(e.Suspense,{fallback:null},e.createElement(h,{notifications:O})))};function f(){return"hidden"===document.visibilityState}const _=({client:t})=>e.createElement(a,{i18n:s},e.createElement(i.Provider,{value:t},e.createElement(S,null)));class v{constructor(e){this.client=e}mount(){if(this.container)throw new c("UI has already been mounted");this.container=document.createElement("div"),this.container.id="userflow-ui",document.body.appendChild(this.container),t.render(e.createElement(_,{client:this.client}),this.container)}unmount(){this.container&&(t.unmountComponentAtNode(this.container),document.body.contains(this.container)&&document.body.removeChild(this.container),delete this.container)}}export{v as RealUI};
|
package/userflow.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}getItem(e){return e=this.formatKey(e),"undefined"==typeof window?null:window[this.type].getItem(e)}setItem(e,t){e=this.formatKey(e),"undefined"!=typeof window&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),"undefined"!=typeof window)return window[this.type].removeItem(e)}clear(){if("undefined"!=typeof window)return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function f(e,t,{toOrigin:s}={}){e.postMessage(t,s||"*")}function w(e,{fromWindow:t,fromOrigin:s}={}){const i=i=>{if(!i.isTrusted)return;if(t&&t!==i.source)return;if(s&&i.origin!==s)return;const o=i.data;o&&"object"==typeof o&&"string"==typeof o.kind&&o.kind.startsWith("userflow:")&&!0===e(o)&&n()};window.addEventListener("message",i);const n=()=>window.removeEventListener("message",i);return n}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const T=new Set;let p=!1;function S(e){return function(){if(p)return;p=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),C()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{C()}))}(),T.add(e),()=>{g(e)}}function g(e){T.delete(e)}function C(){T.forEach((e=>e()))}class I{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){f(window.opener,e,{toOrigin:"https://userflow.com"})}onBuilderMessage(e){return this.unregisterOnMessage=w(e,{fromOrigin:"https://userflow.com"}),!1}async captureScreenshot(e,t,s,i){f(window,{kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{w((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,y,R,O,v,N,_,b,D,F,M,P,B,x,H,G,W,$,V,j,K,z,Y,J,X,Q,Z,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,fe,we,Te,pe,Se,ge,Ce,Ie,me,ke,Ae,Ue,Le,ye,Re,Oe,ve,Ne,_e,be,De,Fe,Me,Pe;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(y=L||(L={})).ACTION="ACTION",y.DRAFT="DRAFT",y.LINK="LINK",y.LAUNCHER_SEEN="LAUNCHER_SEEN",y.RESOURCE_CENTER="RESOURCE_CENTER",y.USERFLOWJS="USERFLOWJS",(O=R||(R={})).STRING="STRING",O.BOOLEAN="BOOLEAN",O.NUMBER="NUMBER",O.DATETIME="DATETIME",O.LIST="LIST",O.RANDOM_AB="RANDOM_AB",O.RANDOM_NUMBER="RANDOM_NUMBER",(N=v||(v={})).FLOW="FLOW",N.CHECKLIST="CHECKLIST",N.LAUNCHER="LAUNCHER",N.RESOURCE_CENTER="RESOURCE_CENTER",(b=_||(_={})).ALWAYS_TRUE="ALWAYS_TRUE",b.ATTRIBUTE="ATTRIBUTE",b.CLAUSE="CLAUSE",b.ELEMENT="ELEMENT",b.FILLED_IN_INPUT="FILLED_IN_INPUT",b.FLOW="FLOW",b.INPUT_VALUE="INPUT_VALUE",b.PAGE="PAGE",b.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(D||(D={})),(F||(F={})).INPUT="INPUT",(P=M||(M={})).ABSOLUTE_EQ="ABSOLUTE_EQ",P.ABSOLUTE_GT="ABSOLUTE_GT",P.ABSOLUTE_LT="ABSOLUTE_LT",P.AND="AND",P.BETWEEN="BETWEEN",P.CONTAINS="CONTAINS",P.EMPTY="EMPTY",P.ENDS_WITH="ENDS_WITH",P.EQ="EQ",P.EXCLUDES_ALL="EXCLUDES_ALL",P.EXCLUDES_ANY="EXCLUDES_ANY",P.FALSE="FALSE",P.GT="GT",P.GTE="GTE",P.INCLUDES_ALL="INCLUDES_ALL",P.INCLUDES_ANY="INCLUDES_ANY",P.LT="LT",P.LTE="LTE",P.NE="NE",P.NOT_CONTAINS="NOT_CONTAINS",P.NOT_EMPTY="NOT_EMPTY",P.NOT_REGEX="NOT_REGEX",P.OR="OR",P.REGEX="REGEX",P.RELATIVE_EQ="RELATIVE_EQ",P.RELATIVE_GT="RELATIVE_GT",P.RELATIVE_LT="RELATIVE_LT",P.STARTS_WITH="STARTS_WITH",P.TRUE="TRUE",P.URL="URL",(x=B||(B={})).CLICK="CLICK",x.DISABLED="DISABLED",x.MOUSEDOWN="MOUSEDOWN",x.NOT_CLICK="NOT_CLICK",x.NOT_DISABLED="NOT_DISABLED",x.NOT_PRESENT="NOT_PRESENT",x.PRESENT="PRESENT",(G=H||(H={})).ASSET="ASSET",G.CARTOON="CARTOON",G.NONE="NONE",G.URL="URL",($=W||(W={})).INSIDE="INSIDE",$.OUTSIDE="OUTSIDE",(j=V||(V={})).TOP_LEFT="TOP_LEFT",j.TOP_CENTER="TOP_CENTER",j.TOP_RIGHT="TOP_RIGHT",j.BOTTOM_RIGHT="BOTTOM_RIGHT",j.BOTTOM_CENTER="BOTTOM_CENTER",j.BOTTOM_LEFT="BOTTOM_LEFT",j.CENTER="CENTER",(z=K||(K={})).GOOGLE="GOOGLE",z.STANDARD="STANDARD",(J=Y||(Y={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",J.DISMISS="DISMISS",(Q=X||(X={})).DISMISS="DISMISS",Q.NONE="NONE",(q=Z||(Z={})).DEFAULT="DEFAULT",q.PLAINTEXT="PLAINTEXT",(te=ee||(ee={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",te.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",te.NONE="NONE",(ie=se||(se={})).BUBBLE="BUBBLE",ie.END="END",ie.ERROR="ERROR",ie.FLAG="FLAG",(oe=ne||(ne={})).MANUAL="MANUAL",oe.NONE="NONE",oe.SYNTHETIC="SYNTHETIC",(ae=re||(re={})).BUBBLE="BUBBLE",ae.HIDDEN="HIDDEN",ae.MODAL="MODAL",ae.TOOLTIP="TOOLTIP",(le=ce||(ce={})).ABOVE="ABOVE",le.BELOW="BELOW",le.LEFT="LEFT",le.RIGHT="RIGHT",(he=de||(de={})).CLOSE_FLOW="CLOSE_FLOW",he.EVAL_JS="EVAL_JS",he.GO_TO_STEP="GO_TO_STEP",he.NAVIGATE="NAVIGATE",he.SNOOZE="SNOOZE",he.START_FLOW="START_FLOW",(Ee=ue||(ue={})).NEW_TAB="NEW_TAB",Ee.SAME_TAB="SAME_TAB",(we=fe||(fe={})).MULTILINE_TEXT="MULTILINE_TEXT",we.MULTIPLE_CHOICE="MULTIPLE_CHOICE",we.NPS="NPS",we.SCALE="SCALE",we.STARS="STARS",we.TEXT="TEXT",(pe=Te||(Te={})).ACTION="ACTION",pe.CHECKLIST="CHECKLIST",pe.CONTACT="CONTACT",pe.FLOWS="FLOWS",pe.KNOWLEDGE_BASE="KNOWLEDGE_BASE",pe.MESSAGE="MESSAGE",pe.SUBPAGE="SUBPAGE",(ge=Se||(Se={})).CRISP="CRISP",ge.CUSTOM="CUSTOM",ge.FRESHCHAT="FRESHCHAT",ge.HELPSCOUT="HELPSCOUT",ge.HUBSPOT="HUBSPOT",ge.INTERCOM="INTERCOM",ge.ZENDESK="ZENDESK",ge.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(Ie=Ce||(Ce={})).LAUNCHER_CLICK="LAUNCHER_CLICK",Ie.LAUNCHER_HOVER="LAUNCHER_HOVER",Ie.TARGET_CLICK="TARGET_CLICK",Ie.TARGET_HOVER="TARGET_HOVER",Ie.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",Ie.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(ke=me||(me={})).ACTIVATE="ACTIVATE",ke.DEACTIVATE="DEACTIVATE",ke.NEVER="NEVER",(Ue=Ae||(Ae={})).AUTO="AUTO",Ue.TOP="TOP",Ue.RIGHT="RIGHT",Ue.BOTTOM="BOTTOM",Ue.LEFT="LEFT",(ye=Le||(Le={})).START="START",ye.CENTER="CENTER",ye.END="END",(Oe=Re||(Re={})).PERCENT="PERCENT",Oe.PX="PX",(Ne=ve||(ve={})).BEACON="BEACON",Ne.BUTTON="BUTTON",Ne.HIDDEN="HIDDEN",Ne.ICON="ICON",(be=_e||(_e={})).LAUNCHER="LAUNCHER",be.TARGET="TARGET",(Fe=De||(De={})).ACTIVE="ACTIVE",Fe.COMPLETED="COMPLETED",Fe.ENDED="ENDED",Fe.NOT_SEEN="NOT_SEEN",(Pe=Me||(Me={})).HIGHLIGHT="HIGHLIGHT",Pe.MODAL="MODAL",Pe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const Be={customInputs:[],customNavigate:null,urlFilter:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")]};function xe(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function He(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function Ge(){let e=d();if(Be.urlFilter){if(e=Be.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}const We=(localStorage.getItem("debug")||"").split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),$e=je("log");let Ve;function je(e){return function(t,...s){if(We){const i=performance.now(),n=Ve?Math.round(i-Ve):0;Ve=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#4579E4;","","color:#4579E4;",...s)}}}$e.group=je("group"),$e.groupCollapsed=je("groupCollapsed"),$e.groupEnd=function(){We&&console.groupEnd()};const Ke=()=>n((()=>import("./ResourceCenterApp.js")),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);function ze(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class Ye{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const Je=import.meta.url;class Xe{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{$e(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}}));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),$e("constructor, build=1002558"),S(this.onUrlChange),this.setTargetEnv(new I),this.checkTestUserAtBoot(),this.toggleUI()}get socketStatus(){return this._socketStatus}destroy(){$e("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv()}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=c.getItem("userflowClientState");if(s)try{e=JSON.parse(s)}catch(t){console.error("Userflow.js: Parse ElementSelectionState error:",t)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null})}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&($e("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:(new Date).toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if($e("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?$e("init() ignoring new token since a test user has been identified"):(this.clientToken&&($e("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",$e("connecting to socket");let t="e.userflow.com";"js.getuserflow.com"===new URL(Je).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{$e("socket opened")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),$e("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1002558",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return $e("channel join payload",t),t}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout((()=>{this.hasDraftSession()?this.debounceInactiveDisconnect():($e("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,handlesRejection:s}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=window.setTimeout((()=>{this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}),50)),this.sendRaw(e,{handlesRejection:s})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel)throw Error("Userflow.js: send() should not be called if channel is not set");$e(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n="Userflow.js send got phx_error";console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(t=>{r();const s=`Userflow.js error reply (${t.code}): ${t.message}`;console.log(s,"\nClient message:",e,"\nError:",t),i(new o(s,t.code))}))}))}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){$e(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,resourceCenterSession:r}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void $e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):$e(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):$e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetChecklistSession":return o>t?void $e(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void $e(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(r?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if($e("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)$e("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&($e("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){$e("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if($e("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)$e("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){$e("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once||i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return R.STRING;case"number":return R.NUMBER;case"boolean":return R.BOOLEAN;case"datetime":return R.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=R.STRING;break;case"boolean":n=R.BOOLEAN;break;case"integer":case"decimal":n=R.NUMBER;break;case"datetime":n=R.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){$e(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout((()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()}),0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&($e(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();this.clientContext&&e.pageUrl===this.clientContext.pageUrl||(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:Ge(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){$e("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach(((e,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),$e(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return $e("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),$e("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){this.checklistSession&&this.checklistExpandPending&&(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),this.resourceCenterSession&&!this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),c.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){this.resourceCenterSession&&this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),c.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:t}=this;return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?ze(t):0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===Te.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===v.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===v.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){$e("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){$e("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){$e("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===v.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setResourceCenterSession(e){const t=this.resourceCenterSession;this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===me.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&($e("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&($e("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.resourceCenterSession&&Ke();const{RealUI:t}=await e;return new t(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;$e("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new Ye([]),condition:e,callback:t=>{i.isTrue!==t&&($e("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&($e("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new Ye(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})}}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,$e("csp issue detected"),f(window,{kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new Xe;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>window.userflow.endAll(),async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&Be.customInputs.push({cssSelector:e})},registerCustomInput(e,t){Be.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){Be.customNavigate=e},setUrlFilter(e){Be.urlFilter=e},setInferenceAttributeNames(e){Be.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){Be.inferenceAttributeFilters[e]=xe(t)},setInferenceClassNameFilter(e){Be.inferenceClassNameFilters=xe(e)},setScrollPadding(e){Be.scrollPadding=e},setCustomScrollIntoView(e){Be.customScrollIntoView=e},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(t){e.pageTrackingDisabled=t},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;$e(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}$e("queue processed")}()}export{H as A,W as B,Se as C,ce as D,m as E,M as F,Ce as G,Ae as H,_e as I,Le as J,Re as K,ve as L,X as M,Ke as R,L as S,se as T,o as U,ne as V,n as _,F as a,D as b,Be as c,$e as d,_ as e,B as f,Ge as g,Te as h,ze as i,ee as j,Z as k,de as l,v as m,d as n,S as o,ue as p,fe as q,Ye as r,l as s,He as t,g as u,K as v,a as w,Y as x,re as y,V as z};export default window.userflow;
|
|
1
|
+
import{S as e}from"./vendor.phoenix.js";import{v as t}from"./vendor.uuid.js";let s;const i={},n=function(e,t){if(!t)return e();if(void 0===s){const e=document.createElement("link").relList;s=e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"}return Promise.all(t.map((e=>{if(e in i)return;i[e]=!0;const t=e.endsWith(".css"),n=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${n}`))return;const o=document.createElement("link");return o.rel=t?"stylesheet":s,t||(o.as="script",o.crossOrigin=""),o.href=e,document.head.appendChild(o),t?new Promise(((e,t)=>{o.addEventListener("load",e),o.addEventListener("error",t)})):void 0}))).then((()=>e()))};class o extends Error{constructor(e,t){super(e),Object.setPrototypeOf(this,o.prototype),this.name="UserflowError",this.code=t}}class r{constructor(e){this.type=e,this.testState={}}formatKey(e){return`userflow:${e}`}getItem(e){return e=this.formatKey(e),"undefined"==typeof window?null:window[this.type].getItem(e)}setItem(e,t){e=this.formatKey(e),"undefined"!=typeof window&&window[this.type].setItem(e,t)}removeItem(e){if(e=this.formatKey(e),"undefined"!=typeof window)return window[this.type].removeItem(e)}clear(){if("undefined"!=typeof window)return window[this.type].clear()}}const a=new r("localStorage"),c=new r("sessionStorage");function l(e){window.location.href=e}function d(){return window.location.href}var h,u,E;function f(e,t,{toOrigin:s}={}){e.postMessage(t,s||"*")}function T(e,{fromWindow:t,fromOrigin:s}={}){const i=i=>{if(!i.isTrusted)return;if(t&&t!==i.source)return;if(s&&i.origin!==s)return;const o=i.data;o&&"object"==typeof o&&"string"==typeof o.kind&&o.kind.startsWith("userflow:")&&!0===e(o)&&n()};window.addEventListener("message",i);const n=()=>window.removeEventListener("message",i);return n}(h||(h={})).INPUT="INPUT",(E=u||(u={})).AUTO="AUTO",E.MANUAL="MANUAL";const w=new Set;let S=!1;function p(e){return function(){if(S)return;S=!0;const{history:e}=window,t=t=>{const s=e[t];e[t]=(...t)=>{s.apply(e,t),C()}};t("pushState"),t("replaceState"),window.addEventListener("popstate",(()=>{C()}))}(),w.add(e),()=>{g(e)}}function g(e){w.delete(e)}function C(){w.forEach((e=>e()))}class I{destroy(){this.unregisterOnMessage&&this.unregisterOnMessage()}postBuilderMessage(e){f(window.opener,e,{toOrigin:"https://userflow.com"})}onBuilderMessage(e){return this.unregisterOnMessage=T(e,{fromOrigin:"https://userflow.com"}),!1}async captureScreenshot(e,t,s,i){f(window,{kind:"userflow:crxScreenshot",x:e,y:t,width:s,height:i,devicePixelRatio:window.devicePixelRatio});var n;return(await(n=e=>"userflow:crxScreenshotResult"===e.kind?e:null,new Promise((e=>{T((t=>{const s=n(t);return!!s&&(e(s),!0)}))})))).imageDataUrl}}var m,k,A,U,L,R,y,O,v,N,_,b,D,F,M,B,P,x,H,G,W,$,V,j,K,z,Y,J,X,Z,Q,q,ee,te,se,ie,ne,oe,re,ae,ce,le,de,he,ue,Ee,fe,Te,we,Se,pe,ge,Ce,Ie,me,ke,Ae,Ue,Le,Re,ye,Oe,ve,Ne,_e,be,De,Fe,Me,Be,Pe,xe;(k=m||(m={})).ACTION="ACTION",k.LAUNCHER_DEACTIVATED="LAUNCHER_DEACTIVATED",k.REPLACED="REPLACED",k.SNOOZED="SNOOZED",k.TOOLTIP_TARGET_MISSING="TOOLTIP_TARGET_MISSING",k.USERFLOWJS="USERFLOWJS",k.USER_CLOSED="USER_CLOSED",(U=A||(A={})).SECOND="SECOND",U.MINUTE="MINUTE",U.HOUR="HOUR",U.DAY="DAY",(R=L||(L={})).ACTION="ACTION",R.DRAFT="DRAFT",R.LINK="LINK",R.LAUNCHER_SEEN="LAUNCHER_SEEN",R.RESOURCE_CENTER="RESOURCE_CENTER",R.USERFLOWJS="USERFLOWJS",(O=y||(y={})).STRING="STRING",O.BOOLEAN="BOOLEAN",O.NUMBER="NUMBER",O.DATETIME="DATETIME",O.LIST="LIST",O.RANDOM_AB="RANDOM_AB",O.RANDOM_NUMBER="RANDOM_NUMBER",(N=v||(v={})).FLOW="FLOW",N.CHECKLIST="CHECKLIST",N.LAUNCHER="LAUNCHER",N.RESOURCE_CENTER="RESOURCE_CENTER",(b=_||(_={})).ALWAYS_TRUE="ALWAYS_TRUE",b.ATTRIBUTE="ATTRIBUTE",b.CLAUSE="CLAUSE",b.ELEMENT="ELEMENT",b.FILLED_IN_INPUT="FILLED_IN_INPUT",b.FLOW="FLOW",b.INPUT_VALUE="INPUT_VALUE",b.PAGE="PAGE",b.TIME="TIME",function(e){e.AUTO="AUTO",e.MANUAL="MANUAL"}(D||(D={})),(F||(F={})).INPUT="INPUT",(B=M||(M={})).ABSOLUTE_EQ="ABSOLUTE_EQ",B.ABSOLUTE_GT="ABSOLUTE_GT",B.ABSOLUTE_LT="ABSOLUTE_LT",B.AND="AND",B.BETWEEN="BETWEEN",B.CONTAINS="CONTAINS",B.EMPTY="EMPTY",B.ENDS_WITH="ENDS_WITH",B.EQ="EQ",B.EXCLUDES_ALL="EXCLUDES_ALL",B.EXCLUDES_ANY="EXCLUDES_ANY",B.FALSE="FALSE",B.GT="GT",B.GTE="GTE",B.INCLUDES_ALL="INCLUDES_ALL",B.INCLUDES_ANY="INCLUDES_ANY",B.LT="LT",B.LTE="LTE",B.NE="NE",B.NOT_CONTAINS="NOT_CONTAINS",B.NOT_EMPTY="NOT_EMPTY",B.NOT_REGEX="NOT_REGEX",B.OR="OR",B.REGEX="REGEX",B.RELATIVE_EQ="RELATIVE_EQ",B.RELATIVE_GT="RELATIVE_GT",B.RELATIVE_LT="RELATIVE_LT",B.STARTS_WITH="STARTS_WITH",B.TRUE="TRUE",B.URL="URL",(x=P||(P={})).CLICK="CLICK",x.DISABLED="DISABLED",x.MOUSEDOWN="MOUSEDOWN",x.NOT_CLICK="NOT_CLICK",x.NOT_DISABLED="NOT_DISABLED",x.NOT_PRESENT="NOT_PRESENT",x.PRESENT="PRESENT",(G=H||(H={})).ASSET="ASSET",G.CARTOON="CARTOON",G.NONE="NONE",G.URL="URL",($=W||(W={})).INSIDE="INSIDE",$.OUTSIDE="OUTSIDE",(j=V||(V={})).TOP_LEFT="TOP_LEFT",j.TOP_CENTER="TOP_CENTER",j.TOP_RIGHT="TOP_RIGHT",j.BOTTOM_RIGHT="BOTTOM_RIGHT",j.BOTTOM_CENTER="BOTTOM_CENTER",j.BOTTOM_LEFT="BOTTOM_LEFT",j.CENTER="CENTER",(z=K||(K={})).GOOGLE="GOOGLE",z.STANDARD="STANDARD",(J=Y||(Y={})).DISMISS_FIRST_MENU_AFTER="DISMISS_FIRST_MENU_AFTER",J.DISMISS="DISMISS",(Z=X||(X={})).DISMISS="DISMISS",Z.NONE="NONE",(q=Q||(Q={})).DEFAULT="DEFAULT",q.PLAINTEXT="PLAINTEXT",(te=ee||(ee={})).CHECKLIST_OVERRIDE="CHECKLIST_OVERRIDE",te.RESOURCE_CENTER_ONLY="RESOURCE_CENTER_ONLY",te.NONE="NONE",(ie=se||(se={})).BUBBLE="BUBBLE",ie.END="END",ie.ERROR="ERROR",ie.FLAG="FLAG",(oe=ne||(ne={})).MANUAL="MANUAL",oe.NONE="NONE",oe.SYNTHETIC="SYNTHETIC",(ae=re||(re={})).BUBBLE="BUBBLE",ae.HIDDEN="HIDDEN",ae.MODAL="MODAL",ae.TOOLTIP="TOOLTIP",(le=ce||(ce={})).ABOVE="ABOVE",le.BELOW="BELOW",le.LEFT="LEFT",le.RIGHT="RIGHT",(he=de||(de={})).CLOSE_FLOW="CLOSE_FLOW",he.EVAL_JS="EVAL_JS",he.GO_TO_STEP="GO_TO_STEP",he.NAVIGATE="NAVIGATE",he.SET_ATTRIBUTE="SET_ATTRIBUTE",he.SNOOZE="SNOOZE",he.START_FLOW="START_FLOW",(Ee=ue||(ue={})).NEW_TAB="NEW_TAB",Ee.SAME_TAB="SAME_TAB",(Te=fe||(fe={})).SET="SET",Te.SET_ONCE="SET_ONCE",Te.ADD="ADD",Te.SUBTRACT="SUBTRACT",Te.UNSET="UNSET",(Se=we||(we={})).MULTILINE_TEXT="MULTILINE_TEXT",Se.MULTIPLE_CHOICE="MULTIPLE_CHOICE",Se.NPS="NPS",Se.SCALE="SCALE",Se.STARS="STARS",Se.TEXT="TEXT",(ge=pe||(pe={})).ACTION="ACTION",ge.CHECKLIST="CHECKLIST",ge.CONTACT="CONTACT",ge.FLOWS="FLOWS",ge.KNOWLEDGE_BASE="KNOWLEDGE_BASE",ge.MESSAGE="MESSAGE",ge.SUBPAGE="SUBPAGE",(Ie=Ce||(Ce={})).CRISP="CRISP",Ie.CUSTOM="CUSTOM",Ie.FRESHCHAT="FRESHCHAT",Ie.HELPSCOUT="HELPSCOUT",Ie.HUBSPOT="HUBSPOT",Ie.INTERCOM="INTERCOM",Ie.ZENDESK="ZENDESK",Ie.ZENDESK_MESSENGER="ZENDESK_MESSENGER",(ke=me||(me={})).LAUNCHER_CLICK="LAUNCHER_CLICK",ke.LAUNCHER_HOVER="LAUNCHER_HOVER",ke.TARGET_CLICK="TARGET_CLICK",ke.TARGET_HOVER="TARGET_HOVER",ke.LAUNCHER_TARGET_CLICK="LAUNCHER_TARGET_CLICK",ke.LAUNCHER_TARGET_HOVER="LAUNCHER_TARGET_HOVER",(Ue=Ae||(Ae={})).ACTIVATE="ACTIVATE",Ue.DEACTIVATE="DEACTIVATE",Ue.NEVER="NEVER",(Re=Le||(Le={})).AUTO="AUTO",Re.TOP="TOP",Re.RIGHT="RIGHT",Re.BOTTOM="BOTTOM",Re.LEFT="LEFT",(Oe=ye||(ye={})).START="START",Oe.CENTER="CENTER",Oe.END="END",(Ne=ve||(ve={})).PERCENT="PERCENT",Ne.PX="PX",(be=_e||(_e={})).BEACON="BEACON",be.BUTTON="BUTTON",be.HIDDEN="HIDDEN",be.ICON="ICON",(Fe=De||(De={})).LAUNCHER="LAUNCHER",Fe.TARGET="TARGET",(Be=Me||(Me={})).ACTIVE="ACTIVE",Be.COMPLETED="COMPLETED",Be.ENDED="ENDED",Be.NOT_SEEN="NOT_SEEN",(xe=Pe||(Pe={})).HIGHLIGHT="HIGHLIGHT",xe.MODAL="MODAL",xe.HIGHLIGHT_MODAL="HIGHLIGHT_MODAL";const He={customInputs:[],customNavigate:null,urlFilter:null,customScrollIntoView:null,scrollPadding:null,inferenceAttributeNames:["data-for","data-id","data-testid","data-test-id","for","id","name","placeholder","role"],inferenceAttributeFilters:{id:[e=>!e.match(/\d$/)],"data-id":[e=>!e.match(/\d$/)]},inferenceClassNameFilters:[e=>!e.startsWith("css-")],baseZIndex:1234500};function Ge(e){return Array.isArray(e)||(e=e?[e]:[]),e=e.map((e=>"string"==typeof e?new RegExp(e):e))}function We(e,t){return e.every((e=>"function"==typeof e?e(t):!(e instanceof RegExp)||e.test(t)))}function $e(){let e=d();if(He.urlFilter){if(e=He.urlFilter(e),"string"!=typeof e)throw new o("Userflow.js: URL filter returned non-string value. Please check your userflow.setUrlFilter() implementation.");try{new URL(e)}catch(t){throw new o("Userflow.js: URL filter returned an invalid URL. Please check your userflow.setUrlFilter() implementation.\nReturned URL: "+e+"\nError message: "+t.message)}}return e}const Ve=(localStorage.getItem("debug")||"").split(",").some((e=>"*"===e||e.startsWith("userflow:*"))),je=ze("log");let Ke;function ze(e){return function(t,...s){if(Ve){const i=performance.now(),n=Ke?Math.round(i-Ke):0;Ke=i,console[e](`%cuserflow %c${t} %c+${n}ms`,"color:#4579E4;","","color:#4579E4;",...s)}}}je.group=ze("group"),je.groupCollapsed=ze("groupCollapsed"),je.groupEnd=function(){Ve&&console.groupEnd()};const Ye=()=>n((()=>import("./ResourceCenterApp.js")),[new URL("ResourceCenterApp.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("Icons.js",import.meta.url).toString(),new URL("BubbleToolbar.js",import.meta.url).toString(),new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString(),new URL("stylesheets.js",import.meta.url).toString(),new URL("vendor.obj-str.js",import.meta.url).toString(),new URL("vendor.fortawesome.react-fontawesome.js",import.meta.url).toString(),new URL("vendor.fortawesome.fontawesome-svg-core.js",import.meta.url).toString(),new URL("vendor.prop-types.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-solid-svg-icons.js",import.meta.url).toString(),new URL("logomark.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("DynamicIcon.js",import.meta.url).toString(),new URL("vendor.fortawesome.pro-regular-svg-icons.js",import.meta.url).toString(),new URL("ChecklistUI.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);function Je(e){const t=e.version.checklist.tasks.length;return Math.max(0,t-e.taskCompletions.length)}class Xe{constructor(e){this.observers=new Set,this._value=e}get value(){return this._value}update(e){if(e!==this._value){this._value=e;for(const e of this.observers)e()}}observe(e){return this.observers.add(e),()=>this.observers.delete(e)}}const Ze=import.meta.url;class Qe{constructor(){this.clientToken=null,this.externalId=null,this.signature=null,this.groupId=null,this.groupSignature=null,this._socketStatus="disconnected",this.socket=null,this.channel=null,this.featureFlags=new Set,this.logrocketAppId=null,this.debounceInactiveDisconnectTimeout=void 0,this.inBatch=!1,this.endBatchTimeout=void 0,this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=0,this.clientClock=1,this.serverClock=1,this.flowSession=null,this.flowSessionClock=0,this.checklistSession=null,this.checklistExpanded=!1,this.checklistExpandPending=!1,this.checklistSessionClock=0,this.resourceCenterSession=null,this.resourceCenterOpen=!1,this.resourceCenterLauncherHidden=!1,this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.notificationIdCounter=0,this.sessionStorageState=null,this.clientContext=null,this.flushUrlChangeTimeout=void 0,this.onFirstIdentifyRun=!1,this.onFirstIdentifyTimeout=void 0,this.firstIdentifyCallback=null,this.ui=null,this.unackedTasks=new Set,this.clientConditions=new Map,this.trackers=new Map,this.conditionWaitTimers=new Map,this.listeners=new Map,this.targetEnv=null,this.idempotencyKeysSeen=new Set,this.testUserIdentified=!1,this.cspIssueReported=!1,this.uiDisabled=!1,this.audio=null,this.audioReady=!1,this.pageTrackingDisabled=!1,this.onBuilderMessage=e=>(this.handleBuilderMessage(e),!1),this.handleBuilderMessage=async e=>{je(`builder ${e.kind} message received`,e);const t="idempotencyKey"in e&&"string"==typeof e.idempotencyKey?e.idempotencyKey:null;if(t&&this.idempotencyKeysSeen.has(t))return;const s=()=>{t&&this.idempotencyKeysSeen.add(t)};switch(e.kind){case"userflow:selectElement":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:selectElementAck",idempotencyKey:e.idempotencyKey}),void this.setSessionStorageState((t=>({...t,activeApp:"elementSelection",elementSelection:{mode:"select",elementType:e.elementType}})));case"userflow:selectElementCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,elementSelection:null})));case"userflow:startFlowWithToken":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:startFlowWithTokenAck",idempotencyKey:e.idempotencyKey}),c.setItem("previewFlowId",e.flowId),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.onceIdentified((()=>{if(this.startFlowWithToken(e.token),e.isResourceCenter){const t=()=>{const s=this.resourceCenterSession;s&&s.draftMode&&s.flow.id===e.flowId&&(this.openResourceCenter(),this.off("resourceCenterChanged",t))};this.on("resourceCenterChanged",t),t()}}));case"userflow:testTracker":return s(),this.getTargetEnv().postBuilderMessage({kind:"userflow:testTrackerAck",idempotencyKey:e.idempotencyKey}),e.testUser?this.identifyTestUser(e.testUser):this.resetTestUser(),void this.setSessionStorageState((t=>({...t,activeApp:"trackerTesting",trackerTesting:{trackerName:e.trackerName,token:e.token,events:0}})));case"userflow:testTrackerCancel":return void this.setSessionStorageState((e=>({...e,activeApp:null,trackerTesting:null})))}},this.onUrlChange=()=>{this.externalId&&(window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=window.setTimeout((()=>this.flushUrlChange()),50))},this.onUserActivity=()=>this.ensureConnected(),je("constructor, build=1002564"),p(this.onUrlChange),this.setTargetEnv(new I),this.checkTestUserAtBoot(),this.toggleUI()}get socketStatus(){return this._socketStatus}destroy(){je("destroy"),this.reset(),g(this.onUrlChange),this.destroyTargetEnv()}setTargetEnv(e){this.destroyTargetEnv(),this.targetEnv=e,e.onBuilderMessage(this.onBuilderMessage)}destroyTargetEnv(){this.targetEnv&&(this.targetEnv.destroy(),this.targetEnv=null)}getTargetEnv(){if(!this.targetEnv)throw new o("Userflow.js: Cannot call getTargetEnv when protocol is not set");return this.targetEnv}setSessionStorageState(e){const t=e(this.getSessionStorageState());c.setItem("userflowClientState",JSON.stringify(t)),this.sessionStorageState=t,this.toggleUI()}getSessionStorageState(){let e=this.sessionStorageState;if(!e){const s=c.getItem("userflowClientState");if(s)try{e=JSON.parse(s)}catch(t){console.error("Userflow.js: Parse ElementSelectionState error:",t)}e||(e={testUser:null,activeApp:null,elementSelection:null,trackerTesting:null})}return e}checkTestUserAtBoot(){const e=this.getSessionStorageState().testUser;e&&(je("checkTestUserAtBoot identifying test user"),this.identifyTestUser(e))}async identifyTestUser(e){this.setSessionStorageState((t=>({...t,testUser:e}))),this.reset(),this.init(e.clientToken),this.testUserIdentified=!0,this.externalId=e.id;const t=[this.identify(e.id,{name:e.name,email:e.email,signed_up_at:{set_once:(new Date).toISOString(),data_type:"datetime"}},{signature:e.signature})],{group:s}=e;s&&(this.groupId=s.id,t.push(this.group(s.id,{name:s.name},{signature:s.signature}))),await Promise.all(t)}resetTestUser(){this.setSessionStorageState((e=>({...e,testUser:null})))}init(e){if(je("init",e),!e)throw new o("userflow.init() was called but missing Userflow.js Token");this.clientToken!==e&&(this.testUserIdentified?je("init() ignoring new token since a test user has been identified"):(this.clientToken&&(je("init() resetting due to new client token"),this.reset()),this.clientToken=e))}ensureInit(){if(!this.clientToken)throw new o("You must call userflow.init() first")}ensureIdentified(){if(this.ensureInit(),!this.externalId)throw new o("You must call userflow.identify() first");return this.externalId}ensureGroup(){if(this.ensureIdentified(),!this.groupId)throw new o("You must call userflow.group() first");return this.groupId}ensureConnected(){if(!this.clientToken||!this.externalId)return;if(this.debounceInactiveDisconnect(),this.socket)return;this._socketStatus="connecting",je("connecting to socket");let t="e.userflow.com";"js.getuserflow.com"===new URL(Ze).hostname&&"e.userflow.com"===t&&(t="e.getuserflow.com");const s="wss://"+t+"/end-users/"+this.clientToken+"/socket";this.socket=new e(s,{reconnectAfterMs:e=>[100,500,1e3,5e3][e-1]||1e4,timeout:2e4}),this.socket.connect(),this.socket.onOpen((()=>{je("socket opened")})),this.socket.onError((e=>{console.log("Userflow.js socket error",e),this.reportCspIssue()})),this.channel=this.socket.channel(`end_users:${this.externalId}`,(()=>this.makeChannelJoinPayload())),this.channel.join().receive("ok",(e=>{this.logrocketAppId=e.logrocketAppId,this.featureFlags=new Set(e.featureFlags),je("channel joined"),"connected"!==this._socketStatus&&(this._socketStatus="connected")})).receive("error",(e=>{["company_closed","invalid_client_token","invalid_user_external_id","incorrect_user_signature","rate_limit_exceeded","user_signature_required"].includes(e.code)?(console.error(`Userflow.js resetting due to: [${e.code}] ${e.message}`),this.reset(),this.clientToken=null):"invalid_protocol_version"===e.code?(console.error(`Userflow.js destroying due to: [${e.code}] ${e.message}`),this.destroy()):console.log("Userflow.js channel join error",e)})),this.channel.on("server_message",(e=>this.handleServerMessage(e))),this.channel.on("server_error",(e=>{console.log(`Userflow.js server error (${e.code}): ${e.message}`+(e.details&&e.details.length>0?"\nDetails:\n"+e.details.map((e=>(e.path?`${e.path}: `:"")+e.message)):""))}))}makeChannelJoinPayload(){const e=this.buildClientContext();this.clientContext=e;const t={protocolVersion:2,userflowClientBuild:"1002564",signature:this.signature,groupExternalId:this.groupId,groupSignature:this.groupSignature,flowSessionId:this.flowSession?.id||null,checklistSessionId:this.checklistSession?.id||null,resourceCenterSessionId:this.resourceCenterSession?.id||null,launchers:this.launcherSessions.map((e=>({flowId:e.flow.id}))),trackers:Array.from(this.trackers.values()).map((e=>({flowId:e.tracker.flowId}))),hasDraftSession:this.hasDraftSession(),clientConditions:Array.from(this.clientConditions.values()).map((e=>({conditionId:e.condition.id,isTrue:e.isTrue}))),previewFlowId:c.getItem("previewFlowId"),clientContext:e};return je("channel join payload",t),t}disconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.socket&&this.socket.disconnect(),this._socketStatus="disconnected",this.socket=null,this.channel=null}debounceInactiveDisconnect(){window.clearTimeout(this.debounceInactiveDisconnectTimeout),this.debounceInactiveDisconnectTimeout=window.setTimeout((()=>{this.hasDraftSession()?this.debounceInactiveDisconnect():(je("disconnecting from socket due to inactivity"),this.disconnect())}),3e5)}hasDraftSession(){return!!this.flowSession?.draftMode||!!this.checklistSession?.draftMode||!!this.resourceCenterSession?.draftMode||this.launcherSessions.some((e=>e.draftMode))}async send(e,{batch:t,handlesRejection:s}={}){return this.inBatch&&["ToggleClientCondition","UpdateClientContext"].includes(e.kind)||this.checkPushRateLimit(),this.ensureConnected(),t&&!this.inBatch&&(this.inBatch=!0,this.sendRaw({kind:"BeginBatch"})),this.inBatch&&(window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=window.setTimeout((()=>{this.inBatch=!1,this.sendRaw({kind:"EndBatch"})}),50)),this.sendRaw(e,{handlesRejection:s})}async sendRaw(e,{handlesRejection:t}={}){return new Promise(((s,i)=>{if(!this.channel)throw Error("Userflow.js: send() should not be called if channel is not set");je(`push ${e.kind} message`,e);const n=this.clientClock,r=()=>{this.serverClock=n,this.channel?.off("phx_error",a)},a=this.channel.on("phx_error",(s=>{r();const n="Userflow.js send got phx_error";console.log(n,"\nClient message:",e,"\nError:",s),t&&i(new o(n))}));this.channel.push("client_message",e).receive("ok",(e=>{r(),s(e)})).receive("error",(t=>{r();const s=`Userflow.js error reply (${t.code}): ${t.message}`;console.log(s,"\nClient message:",e,"\nError:",t),i(new o(s,t.code))}))}))}checkPushRateLimit(){const e=Date.now();if(this.pushRateLimitMinuteExpires<e&&(this.pushRateLimitMinute=0,this.pushRateLimitMinuteExpires=e+6e4),this.pushRateLimitMinute>=100)throw new o("This Userflow.js client has reached a maximum of 100 operations in the last 1 minute. This is usually due to one of the following:\n\n - Excessive calls to Userflow.js. Check if any of userflow.track(), userflow.identify(), userflow.updateUser() or similar are called repeatedly.\n - The URL changing too frequently. Look into https://userflow.com/docs/userflow-js#seturlfilter and filter out the changing part of the URL.\n - The user legitimately being very active, in which case you can just ignore this error.\n \n If in doubt, reach out to us at support@userflow.com.");this.pushRateLimitMinute++}handleServerMessage(e){je(`received ${e.kind} message`,e);const{serverClock:t,flowSession:s,flowSessionClock:i,checklistSession:n,checklistSessionClock:o,resourceCenterSession:r}=this;switch(e.kind){case"CheckSessionsAck":case"ServerDebug":return;case"AddLauncher":{const{session:t}=e,s=this.launcherSessions.findIndex((e=>e.flow.id===t.flow.id));return this.launcherSessions=-1===s?[...this.launcherSessions,t]:[...this.launcherSessions.slice(0,s),t,...this.launcherSessions.slice(s+1)],void this.toggleUI()}case"AddTracker":return void this.addTracker(e.tracker);case"CancelConditionWaitTimer":return window.clearTimeout(this.conditionWaitTimers.get(e.conditionId)),void this.conditionWaitTimers.delete(e.conditionId);case"ChecklistTaskCompleted":return void this.unackedTasks.add(e.taskCvid);case"ForceGoToStep":return i>t?void je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&this.emit("gotostep",{session:s,step:{id:e.stepId}}));case"RemoveLauncher":return void(this.removeLauncher(e.flowId)&&this.toggleUI());case"RemoveTracker":return void this.removeTracker(e.flowId);case"SetChecklistSession":return void(o<=t||n?.id===e.session.id?(this.setChecklistSession(e.session,t),this.toggleUI()):je(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`));case"SetFlowSession":return void(i<=t||s?.id===e.session.id?(this.setFlowSession(e.session,t),this.toggleUI()):je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`));case"SetResourceCenterSession":return this.setResourceCenterSession(e.session),void this.toggleUI();case"StartConditionWaitTimer":if(!this.conditionWaitTimers.has(e.conditionId)){const t=window.setTimeout((()=>{this.conditionWaitTimers.delete(e.conditionId),this.send({kind:"FireConditionWaitTimer",conditionId:e.conditionId},{batch:!0})}),1e3*parseFloat(e.waitTime));this.conditionWaitTimers.set(e.conditionId,t)}return;case"TrackClientCondition":return void this.trackClientCondition(e.condition);case"UnsetChecklistSession":return o>t?void je(`ignoring ${e.kind} message due to stale clock checklistSessionClock=${o} > serverClock=${t}`):void(n?.id===e.sessionId&&(this.setChecklistSession(null,t),this.toggleUI()));case"UnsetFlowSession":return i>t?void je(`ignoring ${e.kind} message due to stale clock flowSessionClock=${i} > serverClock=${t}`):void(s?.id===e.sessionId&&(this.setFlowSession(null,t),this.toggleUI()));case"UnsetResourceCenterSession":return void(r?.id===e.sessionId&&(this.setResourceCenterSession(null),this.toggleUI()));case"UntrackClientCondition":return void this.untrackClientCondition(e.conditionId);default:return void console.warn("Userflow.js: Received unknown message",e)}}async identify(e,t={},{signature:s}={}){if(je("identify",e),this.ensureInit(),this.testUserIdentified&&e!==this.externalId)je("identify() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.identify: First argument must be a non-empty string representing the user's ID in your database. Value received: ${JSON.stringify(e)}`);this.externalId&&e!==this.externalId&&(je("identify resetting due to new externalId"),this.reset()),this.externalId=e,this.signature=s||null,this.observeUserActivity(),await Promise.all([this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(t)},{batch:!0}),this.onFirstIdentify()]),this.emit("private:identified")}}async identifyAnonymous(e={},s={}){const i="anonymousId";let n=a.getItem(i);n||(n="anon-"+t(),a.setItem(i,n)),await this.identify(n,e,s)}async updateUser(e={},t={}){je("updateUser"),this.ensureIdentified(),await this.send({kind:"UpsertUser",attributes:this.normalizeAttributes(e)},{batch:!0})}async group(e,t={},{signature:s,membership:i}={}){if(je("group",e),this.ensureIdentified(),this.testUserIdentified&&e!==this.groupId)je("group() ignored since a test user has been identified");else{if("number"==typeof e)e=String(e);else if(!e||"string"!=typeof e)throw new o(`userflow.group: First argument must be a non-empty string representing the group's ID in your database. Value received: ${JSON.stringify(e)}`);this.groupId=e,this.groupSignature=s||null,await this.send({kind:"UpsertGroup",groupExternalId:e,groupSignature:this.groupSignature,groupAttributes:this.normalizeAttributes(t),membershipAttributes:this.normalizeAttributes(i)},{batch:!0})}}async updateGroup(e={},t={}){je("updateGroup");const s=this.ensureGroup();await this.send({kind:"UpsertGroup",groupExternalId:s,groupSignature:this.groupSignature,membershipAttributes:this.normalizeAttributes(t.membership),groupAttributes:this.normalizeAttributes(e)},{batch:!0})}normalizeAttributes(e){if(null==e)return{};if("object"!=typeof e)throw new o("Userflow: 'attributes' must be an object.");const t={};for(const s in e){if(!e.hasOwnProperty(s))continue;if("traits"===s){const i=e[s];Object.assign(t,this.extractLegacyTraits(i));continue}let i=e[s];if("string"==typeof i||"number"==typeof i||"boolean"==typeof i||null==i||Array.isArray(i))t[s]=this.normalizeAttributeLiteralOrList(s,i);else{if("object"!=typeof i||null==i)throw new o(`Userflow: Invalid value for '${s}' attribute.`);if("set"in i)t[s]={set:this.normalizeAttributeLiteralOrList(s,i.set),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("set_once"in i||"setOnce"in i)t[s]={setOnce:this.normalizeAttributeLiteralOrList(s,i.set_once||i.setOnce),dataType:this.normalizeDataType(s,i.data_type||i.dataType)};else if("add"in i){const e=i.add;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'add' value for '${s}' attribute. Must be a number or string.`);t[s]={add:e}}else if("subtract"in i){const e=i.subtract;if("string"!=typeof e&&"number"!=typeof e)throw new o(`Userflow: Invalid 'subtract' value for '${s}' attribute. Must be a number or string.`);t[s]={subtract:e}}else if("append"in i)t[s]={append:this.normalizeAttributeLiteralOrList(s,i.append)};else if("prepend"in i)t[s]={prepend:this.normalizeAttributeLiteralOrList(s,i.prepend)};else{if(!("remove"in i))throw new o(`Userflow: Invalid value for '${s}' attribute.`);t[s]={remove:this.normalizeAttributeLiteralOrList(s,i.remove)}}}}return t}normalizeAttributeLiteralOrList(e,t){return Array.isArray(t)?t.map((t=>this.normalizeAttributeLiteral(e,t))):this.normalizeAttributeLiteral(e,t)}normalizeAttributeLiteral(e,t){if(null==t)return null;if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return t;throw new o(`Userflow: Invalid value for '${e}' attribute.`)}normalizeDataType(e,t){if(!t)return null;switch(t){case"string":return y.STRING;case"number":return y.NUMBER;case"boolean":return y.BOOLEAN;case"datetime":return y.DATETIME}throw new o(`Userflow: Invalid data_type for '${e}' attribute.`)}extractLegacyTraits(e){if(!e)return{};if(!Array.isArray(e)){const t=[];for(const s in e)e.hasOwnProperty(s)&&t.push({name:s,value:e[s]});e=t}return e.reduce(((e,{name:t,value:s,dataType:i})=>{if("string"!=typeof t||t.length>100||!t.match(/^[a-z0-9_]+$/))return this.warn("Userflow.identify: Invalid trait name (must be string, no more than 100 characters, and only consist of a-z, 0-9 and underscores). The trait will be ignored. Name was:",t),e;if("string"==typeof s);else if("boolean"==typeof s)i||(i="boolean"),s=s?"true":"false";else{if("number"!=typeof s)return this.warn(`userflow.identify: The value of trait '${t}' is invalid (must be a string, a boolean or a number). The trait will be ignored. Value was:`,s),e;i||(i=Number.isInteger(s)?"integer":"decimal"),s=String(s)}let n=null;if(i)switch(i){case"string":n=y.STRING;break;case"boolean":n=y.BOOLEAN;break;case"integer":case"decimal":n=y.NUMBER;break;case"datetime":n=y.DATETIME;break;default:return this.warn(`userflow.identify: The data type of trait '${t}' is invalid (must be a 'string', 'boolean', 'integer', 'decimal' or 'datetime'). The trait will be ignored. Data type was:`,i),e}return e[t]={set:s,dataType:n},e}),{})}async track(e,t={},{userOnly:s}={}){je(`track '${e}'`,t),this.ensureIdentified(),await this.send({kind:"TrackEvent",userOnly:!!s,name:e,attributes:this.normalizeEventAttributes(t)},{batch:!0})}normalizeEventAttributes(e){const t=this.normalizeAttributes(e);for(const s in t){if(!t.hasOwnProperty(s))continue;const e=t[s];if(null!=e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e&&!Array.isArray(e)&&!("set"in e))throw new o(`Userflow: Invalid value for '${s}' attribute. Event attributes only support literal values, list values and 'set' changes.`)}return t}onFirstIdentify(){this.onFirstIdentifyRun||(this.onFirstIdentifyRun=!0,this.onFirstIdentifyTimeout=window.setTimeout((()=>{this.trackPageViewed(),this.firstIdentifyCallback?(this.firstIdentifyCallback(),this.firstIdentifyCallback=null):this.checkUrlForStartFlow()}),0))}onceIdentified(e){this.isIdentified()?e():this.firstIdentifyCallback=e}checkUrlForStartFlow(){const e=new URL(d()),t=e.searchParams.get("userflow")||e.searchParams.get("studio1_flow")||e.searchParams.get("studio1_walkthrough");t&&(je(`url contained flow ${t}`),this.startFlow({flowId:t,startReason:L.LINK,batch:!0}),e.searchParams.delete("userflow"),e.searchParams.delete("studio1_flow"),e.searchParams.delete("studio1_walkthrough"),window.history.replaceState({},"",e.toString()),this.clientContext=this.buildClientContext(),this.pushUpdateClientContext())}flushUrlChange(){const e=this.buildClientContext();this.clientContext&&e.pageUrl===this.clientContext.pageUrl||(this.clientContext=e,this.pushUpdateClientContext(),this.trackPageViewed(),this.checkUrlForStartFlow())}async trackPageViewed(){this.pageTrackingDisabled||this.track("page_viewed",{})}buildClientContext(){return{pageUrl:$e(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight}}pushUpdateClientContext(){this.send({kind:"UpdateClientContext",clientContext:this.clientContext},{batch:!0})}ackCompletedTask(e){this.unackedTasks.delete(e)}taskIsUnacked(e){return this.unackedTasks.has(e)}isIdentified(){return null!=this.externalId}on(e,t){let s=this.listeners.get(e);s||(s=new Set,this.listeners.set(e,s)),s.add(t)}off(e,t){const s=this.listeners.get(e);s&&s.delete(t)}emit(e,...t){const s=this.listeners.get(e);if(s){Array.from(s).forEach((e=>e(...t)))}}observeUserActivity(){document.addEventListener("mouseover",this.onUserActivity),document.addEventListener("pointerdown",this.onUserActivity),document.addEventListener("keydown",this.onUserActivity)}unobserveUserActivity(){document.removeEventListener("mouseover",this.onUserActivity),document.removeEventListener("pointerdown",this.onUserActivity),document.removeEventListener("keydown",this.onUserActivity)}reset(){je("reset"),this.externalId=null,this.groupId=null,this.sessionStorageState=null,this.setFlowSession(null,0),this.setChecklistSession(null,0),this.setResourceCenterSession(null),this.launcherSessions=[],this.activeLauncherFlowId=null,this.notifications=[],this.unackedTasks=new Set,this.onFirstIdentifyRun=!1,window.clearTimeout(this.onFirstIdentifyTimeout),this.onFirstIdentifyTimeout=void 0,this.clientContext=null,this.unobserveUserActivity(),window.clearTimeout(this.flushUrlChangeTimeout),this.flushUrlChangeTimeout=void 0,this.clientConditions.forEach(((e,t)=>{this.untrackClientCondition(t)})),this.firstIdentifyCallback=null,this.testUserIdentified=!1,a.removeItem("anonymousId"),this.unmountUI(),this.disconnect(),this.inBatch=!1,window.clearTimeout(this.endBatchTimeout),this.endBatchTimeout=void 0,this.clientClock=1,this.serverClock=1}async startFlow({flowId:e,stepCvid:t,startReason:s,once:i,batch:n,replaceCurrent:o}){if(this.ensureIdentified(),o&&this.flowSession&&this.endFlow(this.flowSession,{endReason:m.REPLACED,batch:!0}),je(`startFlow ${e}`,{startReason:s}),this.checklistSession?.flow.id===e)return je("startFlow matches current checklist, so showing it instead"),void this.showChecklist();const r={kind:"StartFlow",flowId:e,stepCvid:t,startReason:s,once:!!i};await this.send(r,{batch:n})}async startFlowWithToken(e){this.ensureIdentified(),je("startFlowWithToken",{token:e}),await this.send({kind:"StartFlowWithToken",token:e},{batch:!0})}optimisticClockUIUpdate(e){this.clientClock++,e(),this.toggleUI()}async showChecklist(){this.resourceCenterEmbedsChecklist()?this.openResourceCenter():(this.unmarkExpandPending(),this.checklistSession&&!this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!0,this.toggleUI(),c.setItem(`checklistExpanded:${this.checklistSession.id}`,"1"),await this.send({kind:"ShowChecklist",sessionId:this.checklistSession.id},{batch:!0})))}async hideChecklist(){this.resourceCenterEmbedsChecklist()?this.closeResourceCenter():this.checklistSession&&this.checklistExpanded&&(this.ensureIdentified(),this.checklistExpanded=!1,this.toggleUI(),c.removeItem(`checklistExpanded:${this.checklistSession.id}`),await this.send({kind:"HideChecklist",sessionId:this.checklistSession.id},{batch:!0}))}async unmarkExpandPending(){this.checklistSession&&this.checklistExpandPending&&(this.checklistExpandPending=!1,await this.send({kind:"UnmarkExpandPending",sessionId:this.checklistSession.id},{batch:!0}))}async openResourceCenter(){this.resourceCenterEmbedsChecklist()&&this.unmarkExpandPending(),this.resourceCenterSession&&!this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!0,this.toggleUI(),this.emit("resourceCenterChanged"),c.setItem(`resourceCenterOpen:${this.resourceCenterSession.id}`,"1"),await this.send({kind:"OpenResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}async closeResourceCenter(){this.resourceCenterSession&&this.resourceCenterOpen&&(this.ensureIdentified(),this.resourceCenterOpen=!1,this.toggleUI(),this.emit("resourceCenterChanged"),c.removeItem(`resourceCenterOpen:${this.resourceCenterSession.id}`),await this.send({kind:"CloseResourceCenter",sessionId:this.resourceCenterSession.id},{batch:!0}))}toggleResourceCenter(){this.resourceCenterOpen?this.closeResourceCenter():this.openResourceCenter()}setResourceCenterLauncherHidden(e){this.resourceCenterLauncherHidden=e,this.toggleUI()}getResourceCenterState(){if(!this.resourceCenterSession)return null;const e=this.resourceCenterEmbedsChecklist(),{checklistSession:t}=this;return{isOpen:this.resourceCenterOpen,hasChecklist:e,uncompletedChecklistTaskCount:e&&t?Je(t):0}}resourceCenterEmbedsChecklist(){const e=this.resourceCenterSession;return!!e&&!!e.version.resourceCenter?.blocks.some((e=>e.type===pe.CHECKLIST))}async endFlow(e,{endReason:t,batch:s}){this.ensureIdentified(),this.optimisticClockUIUpdate((()=>{const{clientClock:t}=this;this.flowSession?.id===e.id&&this.setFlowSession(null,t),this.checklistSession?.id===e.id&&this.setChecklistSession(null,t),this.resourceCenterSession?.id===e.id&&this.setResourceCenterSession(null)}));const{flow:i}=e,n={id:i.id,type:i.type.toLowerCase()};i.type===v.CHECKLIST?this.emit("checklistEnded",{checklist:n,endReason:t}):i.type===v.FLOW&&this.emit("flowEnded",{flow:n,endReason:t});const o={kind:"EndFlow",sessionId:e.id,endReason:t};await this.send(o,{batch:s})}async goToStep(e,t){je("goToStep",e.id,t.name||t.id),this.ensureIdentified();const s=this.send({kind:"GoToStep",sessionId:e.id,stepId:t.id});e.currentStep=t,this.emit("gotostep",{session:e,step:t}),await s}async endAllFlows(){je("endAllFlows"),this.optimisticClockUIUpdate((()=>{const{clientClock:e}=this;this.setFlowSession(null,e),this.setChecklistSession(null,e)})),await this.send({kind:"EndAllFlows"})}async endChecklist(){je("endChecklist");const e=this.checklistSession||this.flowSession;e?.flow.type===v.CHECKLIST&&this.endFlow(e,{endReason:m.USERFLOWJS})}setFlowSession(e,t=this.clientClock){const s=this.flowSession;this.flowSession=e,this.flowSessionClock=t,e&&!s&&(this.hideChecklist(),this.closeResourceCenter()),null==e&&this.originalActiveElement&&("function"==typeof this.originalActiveElement.focus&&this.originalActiveElement.focus(),this.originalActiveElement=void 0)}setChecklistSession(e,t=this.clientClock){const s=this.checklistSession;this.checklistSession=e,this.checklistSessionClock=t,null===e&&(this.checklistExpanded=!1,this.checklistExpandPending=!1),e&&e.id!==s?.id&&(this.checklistExpanded=!!c.getItem(`checklistExpanded:${e.id}`),e.expandPending&&(this.checklistExpandPending=!0)),this.emit("checklistChanged"),this.emit("resourceCenterChanged")}setResourceCenterSession(e){const t=this.resourceCenterSession;this.resourceCenterSession=e,null===e&&(this.resourceCenterOpen=!1),t&&t.id!==e?.id&&c.removeItem(`resourceCenterOpen:${t.id}`),e&&e.id!==t?.id&&(this.resourceCenterOpen=!!c.getItem(`resourceCenterOpen:${e.id}`)),this.emit("resourceCenterChanged")}launcherSeen(e){this.send({kind:"StartFlow",flowId:e,startReason:L.LAUNCHER_SEEN,once:!1})}activateLauncher(e){const t=this.activeLauncherFlowId&&this.launcherSessions.find((e=>e.flow.id===this.activeLauncherFlowId));t&&this.deactivateLauncher(t),this.activeLauncherFlowId=e.flow.id,this.toggleUI(),this.send({kind:"ActivateLauncher",flowId:e.flow.id})}deactivateLauncher(e){const{launcher:t}=e.version;e.flow.id===this.activeLauncherFlowId&&(t?.dismissOn===Ae.DEACTIVATE?this.dismissLauncher(e,{endReason:m.LAUNCHER_DEACTIVATED}):(this.activeLauncherFlowId=null,this.toggleUI()))}dismissLauncher(e,{endReason:t}){const s=e.flow.id;this.removeLauncher(s),this.toggleUI(),this.send({kind:"DismissLauncher",flowId:s,endReason:t})}removeLauncher(e){const t=this.launcherSessions.findIndex((t=>t.flow.id===e));return-1!==t&&(this.launcherSessions=[...this.launcherSessions.slice(0,t),...this.launcherSessions.slice(t+1)],e===this.activeLauncherFlowId&&(this.activeLauncherFlowId=null),!0)}async toggleUI(){this.flowSession||!this.checklistExpandPending&&!this.checklistSession?.version.checklist?.tasks.some((e=>this.taskIsUnacked(e.cvid)))||this.showChecklist(),this.emit("uistatechange"),this.shouldBeMounted()?await this.mountUI():this.unmountUI()}shouldBeMounted(){if(this.uiDisabled)return!1;return!!this.getSessionStorageState().activeApp||!!this.flowSession||!!this.checklistSession&&(this.checklistExpanded||!!this.checklistSession?.version.checklist?.launcherEnabled)||!!this.resourceCenterSession&&(this.resourceCenterOpen||!this.resourceCenterLauncherHidden)||this.launcherSessions.length>0||this.notifications.length>0}async mountUI(){if(!this.ui){const e=await this.createUI();this.shouldBeMounted()&&!this.ui&&(je("mount UI"),this.ui=e,this.ui.mount())}}unmountUI(){this.ui&&(je("unmount UI"),this.ui.unmount(),this.ui=null)}remount(){this.unmountUI(),this.toggleUI()}async createUI(){try{const e=n((()=>import("./ui.js")),[new URL("ui.js",import.meta.url).toString(),new URL("vendor.react.js",import.meta.url).toString(),new URL("vendor.object-assign.js",import.meta.url).toString(),new URL("vendor.react-dom.js",import.meta.url).toString(),new URL("vendor.scheduler.js",import.meta.url).toString(),new URL("client-context.js",import.meta.url).toString(),new URL("vendor.i18next.js",import.meta.url).toString(),new URL("vendor.react-i18next.js",import.meta.url).toString(),new URL("vendor.babel.runtime.js",import.meta.url).toString(),new URL("vendor.phoenix.js",import.meta.url).toString(),new URL("vendor.uuid.js",import.meta.url).toString()]);this.resourceCenterSession&&Ye();const{RealUI:t}=await e;return new t(this)}catch(e){throw this.reportCspIssue(),e}}async trackClientCondition(e){if(this.clientConditions.has(e.id))return;je("track client condition",e),this.clientConditions.set(e.id,{condition:e,isTrue:null});const{conditionTypes:t}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),s=t[e.type],i=this.clientConditions.get(e.id);i&&(i.untrack=s.track({sessionData:new Xe([]),condition:e,callback:t=>{i.isTrue!==t&&(je("client condition truthiness changed",t,i.condition),i.isTrue=t,this.send({kind:"ToggleClientCondition",conditionId:e.id,isTrue:t},{batch:!0}))}}))}untrackClientCondition(e){const t=this.clientConditions.get(e);t&&(je("untrack client condition",t.condition),t.untrack&&t.untrack(),this.clientConditions.delete(e))}async addTracker(e){let t=this.trackers.get(e.flowId);t?t.tracker=e:this.trackers.set(e.flowId,{tracker:e,isTrue:!1});const{conditionTypes:s}=await n((()=>import("./flow-condition-types.js").then((function(e){return e.u}))),[new URL("flow-condition-types.js",import.meta.url).toString(),new URL("vendor.date-fns.js",import.meta.url).toString()]),i=this.trackers.get(e.flowId);if(!i)return;const{tracker:o}=i,{condition:r}=o,a=s[r.type];i.untrack&&i.untrack(),i.untrack=a.track({sessionData:new Xe(o.data),condition:r,flipBackEvents:!0,callback:e=>{const t=i.isTrue;i.isTrue=e,!t&&e&&this.send({kind:"TrackTrackerEvent",token:o.token},{batch:!0})}}),this.emit("private:trackerStarted")}removeTracker(e){const t=this.trackers.get(e);t&&(t.untrack&&t.untrack(),this.trackers.delete(e),this.emit("private:trackerStopped"))}reportCspIssue(){const e=this.getSessionStorageState();!this.testUserIdentified&&!e.activeApp||this.cspIssueReported||(this.cspIssueReported=!0,je("csp issue detected"),f(window,{kind:"userflow:crxCspIssueDetected"}))}getAudio(){return this.audio||(this.audio=new Audio),this.audio}playAudio(e){if(document.hidden)return;const t=this.getAudio();e&&(t.src=e);const s=t.play();this.audioReady=!0,s&&s.catch((e=>{e.name}))}pauseAudio(){const e=this.audio;e&&!e.paused&&e.pause()}async getStepSpeech(e,t){return(await this.send({kind:"GetStepSpeechV2",syntheticVoice:e,text:t})).url}featureFlagEnabled(e){return this.featureFlags.has(e)}showNotification(e,t,s){const i={id:++this.notificationIdCounter,label:e,message:t,type:s};this.notifications=[...this.notifications,i],this.toggleUI()}dismissNotification(e){this.notifications=this.notifications.filter((t=>t.id!==e)),this.toggleUI()}warn(...e){console.warn(...e)}}if(void 0===window.userflow||window.userflow._stubbed){const e=Object.assign(window.userflow||{},function(){const e=new Qe;return{_stubbed:!1,init(t){e.init(t)},identify:(t,s={},i={})=>e.identify(t,s,i),identifyAnonymous:(t={},s={})=>e.identifyAnonymous(t,s),isIdentified:()=>e.isIdentified(),updateUser:(t,s={})=>e.updateUser(t,s),group:(t,s={},i={})=>e.group(t,s,i),updateGroup:(t,s={})=>e.updateGroup(t,s),track:(t,s={},i={})=>e.track(t,s,i),start:(t,{once:s}={})=>e.startFlow({flowId:t,startReason:L.USERFLOWJS,once:s}),startFlow:e=>(console.warn("Userflow.js: userflow.startFlow() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),startWalk:e=>(console.warn("Userflow.js: userflow.startWalk() has been deprecated. Use userflow.start() instead."),window.userflow.start(e)),endAll:()=>e.endAllFlows(),endChecklist:()=>e.endChecklist(),endAllFlows:()=>window.userflow.endAll(),async endFlow(){console.warn("Userflow.js: userflow.endFlow() has been deprecated and no longer has any effect.")},async endWalk(){console.warn("Userflow.js: userflow.endWalk() has been deprecated and no longer has any effect.")},openResourceCenter(){e.openResourceCenter()},closeResourceCenter(){e.closeResourceCenter()},toggleResourceCenter(){e.toggleResourceCenter()},setResourceCenterLauncherHidden(t){e.setResourceCenterLauncherHidden(t)},getResourceCenterState:()=>e.getResourceCenterState(),setWalkPosition(){console.warn("Userflow.js: userflow.setWalkPosition() has been deprecated and no longer has any effect.")},reset(){e.reset()},remount(){e.remount()},on(t,s){e.on(t,s)},off(t,s){e.off(t,s)},setCustomInputSelector(e){console.warn("Userflow.js: userflow.setCustomInputSelector() has been deprecated. Use userflow.registerCustomInput() instead. See docs: https://userflow.com/docs/userflow-js"),e&&He.customInputs.push({cssSelector:e})},registerCustomInput(e,t){He.customInputs.push({cssSelector:e,getValue:t})},setCustomNavigate(e){He.customNavigate=e},setUrlFilter(e){He.urlFilter=e},setInferenceAttributeNames(e){He.inferenceAttributeNames=e},setInferenceAttributeFilter(e,t){He.inferenceAttributeFilters[e]=Ge(t)},setInferenceClassNameFilter(e){He.inferenceClassNameFilters=Ge(e)},setScrollPadding(e){He.scrollPadding=e},setCustomScrollIntoView(e){He.customScrollIntoView=e},prepareAudio(){e.playAudio(null)},setShadowDomEnabled(e){console.warn("Userflow.js: userflow.setShadowDomEnabled() has been deprecated. Please remove this call from your Userflow.js snippet. Shadow DOM is supported by default now.")},setPageTrackingDisabled(t){e.pageTrackingDisabled=t},setBaseZIndex(e){He.baseZIndex=e},_setTargetEnv(t){e.setTargetEnv(t)}}}());window.userflow=e,window.studio1=e,function(){const e=window.userflow,t=window.USERFLOWJS_QUEUE;if(delete window.USERFLOWJS_QUEUE,!t||0===t.length)return;je(`processing ${t.length} items in the queue`);for(const[s,i,n]of t){if("function"!=typeof e[s]){console.error(`Userflow.js: Invalid method '${s}' in queue`);continue}const t=e[s](...n);i&&t&&"function"==typeof t.then&&t.then(i.resolve,i.reject)}je("queue processed")}()}export{H as A,W as B,Ce as C,V as D,m as E,M as F,ce as G,me as H,Le as I,De as J,ye as K,_e as L,X as M,ve as N,Ye as R,L as S,se as T,o as U,ne as V,n as _,F as a,D as b,He as c,je as d,_ as e,P as f,$e as g,pe as h,Je as i,ee as j,Q as k,de as l,v as m,d as n,p as o,ue as p,fe as q,we as r,l as s,We as t,g as u,Xe as v,K as w,a as x,Y as y,re as z};export default window.userflow;
|