@frigade/react 1.32.41 → 1.32.42
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/lib/index.js +30 -30
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +37 -37
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import{ThemeProvider as va}from"styled-components";import ft,{useContext as Fa,useEffect as bo,useState as Ko}from"react";import{useCallback as pt,useContext as Qs,useEffect as Zs}from"react";import No,{useMemo as _s}from"react";var dr="1.32.41 ";var ke="https://api.frigade.com/v1/public/",Ie="NOT_STARTED_STEP",X="COMPLETED_FLOW",io="ABORTED_FLOW",at="STARTED_FLOW",Le="NOT_STARTED_FLOW",Oe="COMPLETED_STEP",no="STARTED_STEP";function Me(){let{publicApiKey:e,userId:t}=No.useContext(q);return{config:_s(()=>({headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Frigade-SDK-Version":dr,"X-Frigade-SDK-Platform":"React"}}),[e,t])}}var Ws="frigade-last-call-at-",zs="frigade-last-call-data-";function wt(){let{shouldGracefullyDegrade:e}=No.useContext(q);return async(t,o)=>{if(e)return console.log(`Skipping ${t} call to Frigade due to error`),Wt();let i=Ws+t,r=zs+t;if(window&&window.localStorage&&o&&o.body&&o.method==="POST"){let s=window.localStorage.getItem(i),p=window.localStorage.getItem(r);if(s&&p&&p==o.body){let d=new Date(s);if(new Date().getTime()-d.getTime()<1e3)return Wt()}window.localStorage.setItem(i,new Date().toISOString()),window.localStorage.setItem(r,o.body)}let n;try{n=await fetch(t,o)}catch(s){return Wt(s)}return n?n.ok?n:Wt(n.statusText):Wt()}}function Wt(e){return e&&console.log("Call to Frigade failed",e),{json:()=>({})}}function Tt(){let{publicApiKey:e,shouldGracefullyDegrade:t}=No.useContext(q);function o(){if(t){console.error("Frigade hooks cannot be used when Frigade SDK has failed to initialize");return}e||console.error("Frigade hooks cannot be used outside the scope of FrigadeProvider")}return{verifySDKInitiated:o}}import{useContext as Ys,useState as cr}from"react";import{useContext as js,useEffect as Gs,useState as Vs}from"react";import qs from"swr";import{useContext as Hs}from"react";function ve(){let{openFlowStates:e,setOpenFlowStates:t,hasActiveFullPageFlow:o,setCompletedFlowsToKeepOpenDuringSession:i,completedFlowsToKeepOpenDuringSession:r}=Hs(q);function n(c,u=!1){return e[c]??u}function s(c,u){t(w=>({...w,[c]:u}))}function p(c){t(u=>{let{[c]:w,...T}=u;return{...T}})}function d(c){r.includes(c)||i(u=>[...u,c])}function a(c){return r.includes(c)}function f(){return Object.values(e).some(c=>c)||o}return{getOpenFlowState:n,setOpenFlowState:s,resetOpenFlowState:p,hasOpenModals:f,setKeepCompletedFlowOpenDuringSession:d,shouldKeepCompletedFlowOpenDuringSession:a}}var Ks="unknown";function Be(){let{config:e}=Me(),{publicApiKey:t,userId:o,flows:i,setShouldGracefullyDegrade:r}=js(q),{resetOpenFlowState:n}=ve(),[s,p]=Vs(!1),d={data:i.map(F=>({flowId:F.id,flowState:X,lastStepId:null,userId:o,foreignUserId:o,stepStates:{},shouldTrigger:!1}))},a=F=>fetch(F,e).then(x=>{if(x.ok)return x.json();throw new Error("Failed to fetch user flow states")}).catch(x=>(console.log(`Error fetching ${F}: ${x}. Will gracefully degrade and hide Frigade`),r(!0),d)),{data:f,isLoading:c,mutate:u,error:w}=qs(t&&i&&o?`${ke}userFlowStates?foreignUserId=${encodeURIComponent(o)}`:null,a,{revalidateIfStale:!0,keepPreviousData:!0,revalidateOnMount:!0,errorRetryInterval:1e4,errorRetryCount:3,onError:()=>d,onLoadingSlow:()=>d}),T=f==null?void 0:f.data;Gs(()=>{!s&&!c&&T&&p(!0)},[T,s,c]);async function S(F){if(T){let x=T.find(m=>m.flowId===F);x&&x.flowState!==X&&(x.flowState=X),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function h(F,x,m){if(T){let C=T.find(P=>P.flowId===F);C&&(C.stepStates[x]=m,C.flowState=at),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function E(F,x,m){if(T){let C=T.find(P=>P.flowId===F);C&&(C.lastStepId=x,C.stepStates[x]=m,C.flowState=at),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function y(F){if(T){let x=T.find(m=>m.flowId===F);x&&x.flowState!==Le&&(x.flowState=Le,x.lastStepId=Ks,Object.keys(x.stepStates).forEach(m=>{x.stepStates[m].actionType=Ie,x.stepStates[m].createdAt=new Date().toISOString()}),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1}),n(F))}}async function A(F,x){if(T){let m=T.find(C=>C.flowId===F);m&&m.stepStates[x]!==Ie&&(m.stepStates[x]=Ie),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}return{userFlowStatesData:T,isLoadingUserFlowStateData:!s,mutateUserFlowState:u,optimisticallyMarkFlowCompleted:S,optimisticallyMarkFlowNotStarted:y,optimisticallyMarkStepCompleted:h,optimisticallyMarkStepNotStarted:A,optimisticallyMarkStepStarted:E,error:w}}function zt(){let{config:e}=Me(),{userFlowStatesData:t,mutateUserFlowState:o}=Be(),{failedFlowResponses:i,setFailedFlowResponses:r,flowResponses:n,setFlowResponses:s}=Ys(q),[p,d]=cr(new Set),[a,f]=cr(new Set),c=wt();function u(S){let h=JSON.stringify(S);if(p.has(h))return null;p.add(h),d(p),a.add(S),f(a);let E=n==null?void 0:n.find(y=>y.flowSlug===S.flowSlug&&y.stepId===S.stepId&&y.actionType===S.actionType&&y.createdAt===S.createdAt);return c(`${ke}flowResponses`,{...e,method:"POST",body:h}).then(y=>{y.status!==200&&y.status!==201?(console.log("Failed to send flow response for step "+S.stepId+". Will retry again later."),r([...i,S])):E||s(A=>[...A??[],S])})}async function w(S){S.foreignUserId&&(S.actionType===at||S.actionType===Le?await u(S):S.actionType===X?await u(S):S.actionType===no?await u(S):S.actionType===Oe?await u(S):S.actionType===io?await u(S):S.actionType===Ie&&await u(S))}function T(){let S=[];return t==null||t.forEach(h=>{if(h&&h.stepStates&&Object.keys(h.stepStates).length!==0)for(let E in h.stepStates){let y=h.stepStates[E];S.push({foreignUserId:h.foreignUserId,flowSlug:h.flowId,stepId:y.stepId,actionType:y.actionType,data:{},createdAt:new Date(y.createdAt),blocked:y.blocked,hidden:y.hidden})}}),[...S,...n]}return{addResponse:w,setFlowResponses:s,getFlowResponses:T}}import Rs from"swr";var Xs=/user.flow\(([^\)]+)\) == '?COMPLETED_FLOW'?/gm,mr=e=>{let t=Xs.exec(e);if(t===null)return null;let o=null;return t.forEach((i,r)=>{let n=Js(i,"'","");n.startsWith("flow_")&&(o=n)}),o},Js=function(e,t,o){return e.replace(new RegExp(t,"g"),o)};function J(){let{config:e}=Me(),{flows:t,setFlows:o,userId:i,publicApiKey:r,customVariables:n,setCustomVariables:s,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,setFlowResponses:a,setShouldGracefullyDegrade:f}=Qs(q),c={data:[]},{verifySDKInitiated:u}=Tt(),{addResponse:w,getFlowResponses:T}=zt(),S=g=>fetch(g,e).then(b=>b.ok?b.json():(console.log(`Error fetching ${g} (${b.status}): ${b.statusText}. .Will gracefully degrade and hide Frigade`),f(!0),c)).catch(b=>(console.log(`Error fetching ${g}: ${b}. Will gracefully degrade and hide Frigade`),f(!0),c)),{userFlowStatesData:h,isLoadingUserFlowStateData:E,optimisticallyMarkFlowCompleted:y,optimisticallyMarkFlowNotStarted:A,optimisticallyMarkStepCompleted:F,optimisticallyMarkStepNotStarted:x,optimisticallyMarkStepStarted:m}=Be(),{data:C,error:P,isLoading:M}=Rs(r?`${ke}flows`:null,S,{keepPreviousData:!0});Zs(()=>{if(P){console.error(P);return}C&&C.data&&(C.data=o(C.data))},[C,P]);function U(g){if(M)return null;let b=t.find(v=>v.slug===g);return!b&&t.length>0&&!E&&!M?(console.log(`Flow with slug ${g} not found`),null):(b==null?void 0:b.active)===!1?null:b}function $(g){var H;if(!U(g))return[];let b=U(g).data;return b?(b=I(b),(((H=JSON.parse(b))==null?void 0:H.data)??[]).map(ce=>{let z=oe(ce);return{handleSecondaryButtonClick:()=>{ce.skippable===!0&&_(g,ce.id,{skipped:!0})},...ce,complete:L(g,ce.id)===Oe||z>=1,blocked:te(g,ce.id),hidden:xe(g,ce.id),handlePrimaryButtonClick:()=>{(!ce.completionCriteria&&(ce.autoMarkCompleted||ce.autoMarkCompleted===void 0)||ce.completionCriteria&&ce.autoMarkCompleted===!0)&&_(g,ce.id)},progress:z}}).filter(ce=>ce.hidden!==!0)):[]}function I(g){return g.replace(/\${(.*?)}/g,(b,v)=>n[v]!==void 0?String(n[v]):"")}function j(g){if(!U(g))return[];let b=U(g).data;return b?(b=I(b),JSON.parse(b)??{}):[]}function B(g,b){s(v=>({...v,[g]:b}))}function D(g){!E&&!M&&g&&JSON.stringify(n)!=JSON.stringify({...n,...g})&&Object.keys(g).forEach(b=>{B(b,g[b])})}let re=pt(async(g,b,v)=>{u();let H={foreignUserId:i,flowSlug:g,stepId:b,actionType:no,data:v??{},createdAt:new Date,blocked:!1,hidden:!1};G(H)&&(await m(g,b,H),w(H))},[i,h]),R=pt(async(g,b,v)=>{u();let H={foreignUserId:i,flowSlug:g,stepId:b,actionType:Ie,data:v??{},createdAt:new Date,blocked:!1,hidden:!1};G(H)&&(await x(g,b),w(H))},[i,h]),_=pt(async(g,b,v)=>{u();let H={foreignUserId:i,flowSlug:g,stepId:b,actionType:Oe,data:v??{},createdAt:new Date,blocked:!1,hidden:!1};G(H)&&(await F(g,b,H),w(H))},[i,h]),he=pt(async(g,b)=>{if(u(),K(g)===Le)return;let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:Le,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};await A(g),G(v)&&w(v)},[i,h]),Fe=pt(async(g,b)=>{u();let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:at,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};G(v)&&w(v)},[i,h]),W=pt(async(g,b)=>{u();let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:X,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};G(v)&&(await y(g),w(v))},[i,h]),se=pt(async(g,b)=>{u();let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:io,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};G(v)&&(await y(g),w(v))},[i,h]);function G(g){var b;if(!h&&g.actionType===Ie)return!1;if(h){let v=h.find(H=>H.flowId===g.flowSlug);if(g.actionType===Ie&&(!(v!=null&&v.stepStates[g.stepId])||v.stepStates[g.stepId].actionType===Ie)||v&&((b=v.stepStates[g.stepId])==null?void 0:b.actionType)===g.actionType||v&&v.flowState===X&&g.actionType===X)return!1}return!0}function L(g,b){let v=Ce(g,b);return E?null:v?v.actionType:Ie}function te(g,b){let v=Ce(g,b);return v?v.blocked:!1}function xe(g,b){let v=Ce(g,b);return v?v.hidden:!1}function Ce(g,b){if(E)return null;let v=h==null?void 0:h.find(H=>H.flowId===g);return!v||!v.stepStates[b]?null:v.stepStates[b]??null}function V(g){var v;if(E||!h)return null;if(K(g)===Le)return $(g)[0]??null;let b=(v=h.find(H=>H.flowId===g))==null?void 0:v.lastStepId;return b?$(g).find(H=>H.id===b):null}function de(g){let b=V(g);if(!b)return 0;let v=$(g).findIndex(H=>H.id===b.id)??0;return L(g,b.id)===Oe&&v<$(g).length-1?v+1:v}function oe(g){if(!g.completionCriteria)return;let b=mr(g.completionCriteria);if(b===null)return;let v=je(b),H=Ge(b);return H===0?void 0:v/H}function K(g){let b=h==null?void 0:h.find(v=>v.flowId===g);return b?b.flowState:null}function je(g){let b=$(g);return b.length===0?0:b.filter(H=>L(g,H.id)===Oe).length}function Ge(g){return $(g).length}function Y(g){return JSON.parse(t.find(b=>b.slug===g).data)}function Se(g){if(E)return!0;if(g!=null&&g.targetingLogic&&h){let b=h.find(v=>v.flowId===g.slug);if(b)return b.shouldTrigger===!1}return!!(g!=null&&g.targetingLogic&&i&&i.startsWith("guest_"))}function st(g){return!Se(U(g))}return{getFlow:U,getFlowData:Y,isLoading:E||M,getStepStatus:L,getFlowSteps:$,getCurrentStepIndex:de,markStepStarted:re,markStepCompleted:_,markFlowNotStarted:he,markFlowStarted:Fe,markFlowCompleted:W,markFlowAborted:se,markStepNotStarted:R,getFlowStatus:K,getNumberOfStepsCompleted:je,getNumberOfSteps:Ge,targetingLogicShouldHideFlow:Se,setCustomVariable:B,updateCustomVariables:D,customVariables:n,getStepOptionalProgress:oe,getFlowMetadata:j,isStepBlocked:te,isStepHidden:xe,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,isFlowAvailableToUser:st}}import{useCallback as ur,useContext as el,useEffect as tl}from"react";var Ft="guest_";function Lo(){let{userId:e,organizationId:t,setUserId:o,setUserProperties:i,shouldGracefullyDegrade:r}=el(q),{config:n}=Me(),{mutateUserFlowState:s}=Be(),p=wt(),{verifySDKInitiated:d}=Tt();tl(()=>{if(e&&!t){if(e.startsWith(Ft))return;let c=`frigade-user-registered-${e}`;localStorage.getItem(c)||(p(`${ke}users`,{...n,method:"POST",body:JSON.stringify({foreignId:e})}),localStorage.setItem(c,"true"))}},[e,r,t]);let a=ur(async c=>{d();let u={foreignId:e,properties:c};await p(`${ke}users`,{...n,method:"POST",body:JSON.stringify(u)}),i(w=>({...w,...c})),s()},[e,n,r,s]),f=ur(async(c,u)=>{d();let T={foreignId:e,events:[{event:c,properties:u}]};await p(`${ke}users`,{...n,method:"POST",body:JSON.stringify(T)}),s()},[e,n,s]);return{userId:e,setUserId:o,addPropertiesToUser:a,trackEventForUser:f}}import{v4 as ka}from"uuid";import Ue,{useEffect as ya,useState as ba}from"react";import Ve,{useEffect as ll}from"react";import lo from"styled-components";import ol from"react";import rl from"styled-components";var fr="fr-",Ht="cfr-";function l(e,t){let o=`${fr}${e}`;if(!t)return o;if(t.styleOverrides&&t.styleOverrides[e]){if(typeof t.styleOverrides[e]=="string")return o+" "+t.styleOverrides[e];if(typeof t.styleOverrides[e]=="object")return o+" "+Ht+e}return o}function k(e){if(!e.className||e.className.indexOf(Ht)!==-1)return"";let o=e.className.replace(/\s+/g," ").split(" ");return o.length==1&&o[0].startsWith(fr)?"":`:not(${o.map(i=>`.${i}`).join(", ")})`}function Oo(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function dt(e){return e!=null&&e.styleOverrides?Object.keys(e.styleOverrides).map(t=>`${Oo(t)}: ${e.styleOverrides[t]};`).join(" "):""}function ye(...e){return e.filter(Boolean).join(" ")}function gr(e){return e.charAt(0).toUpperCase()+e.slice(1)}var il=rl.div`
|
|
2
|
+
import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import{ThemeProvider as va}from"styled-components";import ft,{useContext as Fa,useEffect as bo,useState as Ko}from"react";import{useCallback as pt,useContext as Qs,useEffect as Zs}from"react";import No,{useMemo as _s}from"react";var dr="1.32.42 ";var ke="https://api.frigade.com/v1/public/",Ie="NOT_STARTED_STEP",X="COMPLETED_FLOW",io="ABORTED_FLOW",at="STARTED_FLOW",Le="NOT_STARTED_FLOW",Oe="COMPLETED_STEP",no="STARTED_STEP";function $e(){let{publicApiKey:e,userId:t}=No.useContext(q);return{config:_s(()=>({headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","X-Frigade-SDK-Version":dr,"X-Frigade-SDK-Platform":"React"}}),[e,t])}}var Ws="frigade-last-call-at-",zs="frigade-last-call-data-";function wt(){let{shouldGracefullyDegrade:e}=No.useContext(q);return async(t,o)=>{if(e)return console.log(`Skipping ${t} call to Frigade due to error`),Wt();let i=Ws+t,r=zs+t;if(window&&window.localStorage&&o&&o.body&&o.method==="POST"){let s=window.localStorage.getItem(i),p=window.localStorage.getItem(r);if(s&&p&&p==o.body){let d=new Date(s);if(new Date().getTime()-d.getTime()<1e3)return Wt()}window.localStorage.setItem(i,new Date().toISOString()),window.localStorage.setItem(r,o.body)}let n;try{n=await fetch(t,o)}catch(s){return Wt(s)}return n?n.ok?n:Wt(n.statusText):Wt()}}function Wt(e){return e&&console.log("Call to Frigade failed",e),{json:()=>({})}}function Tt(){let{publicApiKey:e,shouldGracefullyDegrade:t}=No.useContext(q);function o(){if(t){console.error("Frigade hooks cannot be used when Frigade SDK has failed to initialize");return}e||console.error("Frigade hooks cannot be used outside the scope of FrigadeProvider")}return{verifySDKInitiated:o}}import{useContext as Ys,useState as cr}from"react";import{useContext as js,useEffect as Gs,useState as Vs}from"react";import qs from"swr";import{useContext as Hs}from"react";function ve(){let{openFlowStates:e,setOpenFlowStates:t,hasActiveFullPageFlow:o,setCompletedFlowsToKeepOpenDuringSession:i,completedFlowsToKeepOpenDuringSession:r}=Hs(q);function n(c,u=!1){return e[c]??u}function s(c,u){t(w=>({...w,[c]:u}))}function p(c){t(u=>{let{[c]:w,...T}=u;return{...T}})}function d(c){r.includes(c)||i(u=>[...u,c])}function a(c){return r.includes(c)}function f(){return Object.values(e).some(c=>c)||o}return{getOpenFlowState:n,setOpenFlowState:s,resetOpenFlowState:p,hasOpenModals:f,setKeepCompletedFlowOpenDuringSession:d,shouldKeepCompletedFlowOpenDuringSession:a}}var Ks="unknown";function Be(){let{config:e}=$e(),{publicApiKey:t,userId:o,flows:i,setShouldGracefullyDegrade:r}=js(q),{resetOpenFlowState:n}=ve(),[s,p]=Vs(!1),d={data:i.map(F=>({flowId:F.id,flowState:X,lastStepId:null,userId:o,foreignUserId:o,stepStates:{},shouldTrigger:!1}))},a=F=>fetch(F,e).then(x=>{if(x.ok)return x.json();throw new Error("Failed to fetch user flow states")}).catch(x=>(console.log(`Error fetching ${F}: ${x}. Will gracefully degrade and hide Frigade`),r(!0),d)),{data:f,isLoading:c,mutate:u,error:w}=qs(t&&i&&o?`${ke}userFlowStates?foreignUserId=${encodeURIComponent(o)}`:null,a,{revalidateIfStale:!0,keepPreviousData:!0,revalidateOnMount:!0,errorRetryInterval:1e4,errorRetryCount:3,onError:()=>d,onLoadingSlow:()=>d}),T=f==null?void 0:f.data;Gs(()=>{!s&&!c&&T&&p(!0)},[T,s,c]);async function S(F){if(T){let x=T.find(m=>m.flowId===F);x&&x.flowState!==X&&(x.flowState=X),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function h(F,x,m){if(T){let C=T.find(P=>P.flowId===F);C&&(C.stepStates[x]=m,C.flowState=at),await u(Promise.resolve({...f,data:T}),{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function E(F,x,m){if(T){let C=T.find(P=>P.flowId===F);C&&(C.lastStepId=x,C.stepStates[x]=m,C.flowState=at),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}async function y(F){if(T){let x=T.find(m=>m.flowId===F);x&&x.flowState!==Le&&(x.flowState=Le,x.lastStepId=Ks,Object.keys(x.stepStates).forEach(m=>{x.stepStates[m].actionType=Ie,x.stepStates[m].createdAt=new Date().toISOString()}),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1}),n(F))}}async function A(F,x){if(T){let m=T.find(C=>C.flowId===F);m&&m.stepStates[x]!==Ie&&(m.stepStates[x]=Ie),await u({...f,data:T},{optimisticData:{...f,data:T},revalidate:!1,rollbackOnError:!1})}}return{userFlowStatesData:T,isLoadingUserFlowStateData:!s,mutateUserFlowState:u,optimisticallyMarkFlowCompleted:S,optimisticallyMarkFlowNotStarted:y,optimisticallyMarkStepCompleted:h,optimisticallyMarkStepNotStarted:A,optimisticallyMarkStepStarted:E,error:w}}function zt(){let{config:e}=$e(),{userFlowStatesData:t,mutateUserFlowState:o}=Be(),{failedFlowResponses:i,setFailedFlowResponses:r,flowResponses:n,setFlowResponses:s}=Ys(q),[p,d]=cr(new Set),[a,f]=cr(new Set),c=wt();function u(S){let h=JSON.stringify(S);if(p.has(h))return null;p.add(h),d(p),a.add(S),f(a);let E=n==null?void 0:n.find(y=>y.flowSlug===S.flowSlug&&y.stepId===S.stepId&&y.actionType===S.actionType&&y.createdAt===S.createdAt);return c(`${ke}flowResponses`,{...e,method:"POST",body:h}).then(y=>{y.status!==200&&y.status!==201?(console.log("Failed to send flow response for step "+S.stepId+". Will retry again later."),r([...i,S])):E||s(A=>[...A??[],S])})}async function w(S){S.foreignUserId&&(S.actionType===at||S.actionType===Le?await u(S):S.actionType===X?await u(S):S.actionType===no?await u(S):S.actionType===Oe?await u(S):S.actionType===io?await u(S):S.actionType===Ie&&await u(S))}function T(){let S=[];return t==null||t.forEach(h=>{if(h&&h.stepStates&&Object.keys(h.stepStates).length!==0)for(let E in h.stepStates){let y=h.stepStates[E];S.push({foreignUserId:h.foreignUserId,flowSlug:h.flowId,stepId:y.stepId,actionType:y.actionType,data:{},createdAt:new Date(y.createdAt),blocked:y.blocked,hidden:y.hidden})}}),[...S,...n]}return{addResponse:w,setFlowResponses:s,getFlowResponses:T}}import Rs from"swr";var Xs=/user.flow\(([^\)]+)\) == '?COMPLETED_FLOW'?/gm,mr=e=>{let t=Xs.exec(e);if(t===null)return null;let o=null;return t.forEach((i,r)=>{let n=Js(i,"'","");n.startsWith("flow_")&&(o=n)}),o},Js=function(e,t,o){return e.replace(new RegExp(t,"g"),o)};function J(){let{config:e}=$e(),{flows:t,setFlows:o,userId:i,publicApiKey:r,customVariables:n,setCustomVariables:s,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,setFlowResponses:a,setShouldGracefullyDegrade:f}=Qs(q),c={data:[]},{verifySDKInitiated:u}=Tt(),{addResponse:w,getFlowResponses:T}=zt(),S=g=>fetch(g,e).then(b=>b.ok?b.json():(console.log(`Error fetching ${g} (${b.status}): ${b.statusText}. .Will gracefully degrade and hide Frigade`),f(!0),c)).catch(b=>(console.log(`Error fetching ${g}: ${b}. Will gracefully degrade and hide Frigade`),f(!0),c)),{userFlowStatesData:h,isLoadingUserFlowStateData:E,optimisticallyMarkFlowCompleted:y,optimisticallyMarkFlowNotStarted:A,optimisticallyMarkStepCompleted:F,optimisticallyMarkStepNotStarted:x,optimisticallyMarkStepStarted:m}=Be(),{data:C,error:P,isLoading:$}=Rs(r?`${ke}flows`:null,S,{keepPreviousData:!0});Zs(()=>{if(P){console.error(P);return}C&&C.data&&(C.data=o(C.data))},[C,P]);function U(g){if($)return null;let b=t.find(v=>v.slug===g);return!b&&t.length>0&&!E&&!$?(console.log(`Flow with slug ${g} not found`),null):(b==null?void 0:b.active)===!1?null:b}function M(g){var H;if(!U(g))return[];let b=U(g).data;return b?(b=I(b),(((H=JSON.parse(b))==null?void 0:H.data)??[]).map(ce=>{let z=oe(ce);return{handleSecondaryButtonClick:()=>{ce.skippable===!0&&_(g,ce.id,{skipped:!0})},...ce,complete:L(g,ce.id)===Oe||z>=1,blocked:te(g,ce.id),hidden:xe(g,ce.id),handlePrimaryButtonClick:()=>{(!ce.completionCriteria&&(ce.autoMarkCompleted||ce.autoMarkCompleted===void 0)||ce.completionCriteria&&ce.autoMarkCompleted===!0)&&_(g,ce.id)},progress:z}}).filter(ce=>ce.hidden!==!0)):[]}function I(g){return g.replace(/\${(.*?)}/g,(b,v)=>n[v]!==void 0?String(n[v]):"")}function j(g){if(!U(g))return[];let b=U(g).data;return b?(b=I(b),JSON.parse(b)??{}):[]}function B(g,b){s(v=>({...v,[g]:b}))}function D(g){!E&&!$&&g&&JSON.stringify(n)!=JSON.stringify({...n,...g})&&Object.keys(g).forEach(b=>{B(b,g[b])})}let re=pt(async(g,b,v)=>{u();let H={foreignUserId:i,flowSlug:g,stepId:b,actionType:no,data:v??{},createdAt:new Date,blocked:!1,hidden:!1};G(H)&&(await m(g,b,H),w(H))},[i,h]),R=pt(async(g,b,v)=>{u();let H={foreignUserId:i,flowSlug:g,stepId:b,actionType:Ie,data:v??{},createdAt:new Date,blocked:!1,hidden:!1};G(H)&&(await x(g,b),w(H))},[i,h]),_=pt(async(g,b,v)=>{u();let H={foreignUserId:i,flowSlug:g,stepId:b,actionType:Oe,data:v??{},createdAt:new Date,blocked:!1,hidden:!1};G(H)&&(await F(g,b,H),w(H))},[i,h]),he=pt(async(g,b)=>{if(u(),K(g)===Le)return;let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:Le,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};await A(g),G(v)&&w(v)},[i,h]),Fe=pt(async(g,b)=>{u();let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:at,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};G(v)&&w(v)},[i,h]),W=pt(async(g,b)=>{u();let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:X,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};G(v)&&(await y(g),w(v))},[i,h]),se=pt(async(g,b)=>{u();let v={foreignUserId:i,flowSlug:g,stepId:"unknown",actionType:io,data:b??{},createdAt:new Date,blocked:!1,hidden:!1};G(v)&&(await y(g),w(v))},[i,h]);function G(g){var b;if(!h&&g.actionType===Ie)return!1;if(h){let v=h.find(H=>H.flowId===g.flowSlug);if(g.actionType===Ie&&(!(v!=null&&v.stepStates[g.stepId])||v.stepStates[g.stepId].actionType===Ie)||v&&((b=v.stepStates[g.stepId])==null?void 0:b.actionType)===g.actionType||v&&v.flowState===X&&g.actionType===X)return!1}return!0}function L(g,b){let v=Ce(g,b);return E?null:v?v.actionType:Ie}function te(g,b){let v=Ce(g,b);return v?v.blocked:!1}function xe(g,b){let v=Ce(g,b);return v?v.hidden:!1}function Ce(g,b){if(E)return null;let v=h==null?void 0:h.find(H=>H.flowId===g);return!v||!v.stepStates[b]?null:v.stepStates[b]??null}function V(g){var v;if(E||!h)return null;if(K(g)===Le)return M(g)[0]??null;let b=(v=h.find(H=>H.flowId===g))==null?void 0:v.lastStepId;return b?M(g).find(H=>H.id===b):null}function de(g){let b=V(g);if(!b)return 0;let v=M(g).findIndex(H=>H.id===b.id)??0;return L(g,b.id)===Oe&&v<M(g).length-1?v+1:v}function oe(g){if(!g.completionCriteria)return;let b=mr(g.completionCriteria);if(b===null)return;let v=je(b),H=Ge(b);return H===0?void 0:v/H}function K(g){let b=h==null?void 0:h.find(v=>v.flowId===g);return b?b.flowState:null}function je(g){let b=M(g);return b.length===0?0:b.filter(H=>L(g,H.id)===Oe).length}function Ge(g){return M(g).length}function Y(g){return JSON.parse(t.find(b=>b.slug===g).data)}function Se(g){if(E)return!0;if(g!=null&&g.targetingLogic&&h){let b=h.find(v=>v.flowId===g.slug);if(b)return b.shouldTrigger===!1}return!!(g!=null&&g.targetingLogic&&i&&i.startsWith("guest_"))}function st(g){return!Se(U(g))}return{getFlow:U,getFlowData:Y,isLoading:E||$,getStepStatus:L,getFlowSteps:M,getCurrentStepIndex:de,markStepStarted:re,markStepCompleted:_,markFlowNotStarted:he,markFlowStarted:Fe,markFlowCompleted:W,markFlowAborted:se,markStepNotStarted:R,getFlowStatus:K,getNumberOfStepsCompleted:je,getNumberOfSteps:Ge,targetingLogicShouldHideFlow:Se,setCustomVariable:B,updateCustomVariables:D,customVariables:n,getStepOptionalProgress:oe,getFlowMetadata:j,isStepBlocked:te,isStepHidden:xe,hasActiveFullPageFlow:p,setHasActiveFullPageFlow:d,isFlowAvailableToUser:st}}import{useCallback as ur,useContext as el,useEffect as tl}from"react";var Ft="guest_";function Lo(){let{userId:e,organizationId:t,setUserId:o,setUserProperties:i,shouldGracefullyDegrade:r}=el(q),{config:n}=$e(),{mutateUserFlowState:s}=Be(),p=wt(),{verifySDKInitiated:d}=Tt();tl(()=>{if(e&&!t){if(e.startsWith(Ft))return;let c=`frigade-user-registered-${e}`;localStorage.getItem(c)||(p(`${ke}users`,{...n,method:"POST",body:JSON.stringify({foreignId:e})}),localStorage.setItem(c,"true"))}},[e,r,t]);let a=ur(async c=>{d();let u={foreignId:e,properties:c};await p(`${ke}users`,{...n,method:"POST",body:JSON.stringify(u)}),i(w=>({...w,...c})),s()},[e,n,r,s]),f=ur(async(c,u)=>{d();let T={foreignId:e,events:[{event:c,properties:u}]};await p(`${ke}users`,{...n,method:"POST",body:JSON.stringify(T)}),s()},[e,n,s]);return{userId:e,setUserId:o,addPropertiesToUser:a,trackEventForUser:f}}import{v4 as ka}from"uuid";import Ue,{useEffect as ya,useState as ba}from"react";import Ve,{useEffect as ll}from"react";import lo from"styled-components";import ol from"react";import rl from"styled-components";var fr="fr-",Ht="cfr-";function l(e,t){let o=`${fr}${e}`;if(!t)return o;if(t.styleOverrides&&t.styleOverrides[e]){if(typeof t.styleOverrides[e]=="string")return o+" "+t.styleOverrides[e];if(typeof t.styleOverrides[e]=="object")return o+" "+Ht+e}return o}function k(e){if(!e.className||e.className.indexOf(Ht)!==-1)return"";let o=e.className.replace(/\s+/g," ").split(" ");return o.length==1&&o[0].startsWith(fr)?"":`:not(${o.map(i=>`.${i}`).join(", ")})`}function Oo(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}function dt(e){return e!=null&&e.styleOverrides?Object.keys(e.styleOverrides).map(t=>`${Oo(t)}: ${e.styleOverrides[t]};`).join(" "):""}function ye(...e){return e.filter(Boolean).join(" ")}function gr(e){return e.charAt(0).toUpperCase()+e.slice(1)}var il=rl.div`
|
|
3
3
|
display: flex;
|
|
4
4
|
justify-content: center;
|
|
5
5
|
position: fixed;
|
|
@@ -129,7 +129,7 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
129
129
|
::-webkit-scrollbar {
|
|
130
130
|
display: none;
|
|
131
131
|
}
|
|
132
|
-
`,xr=({onClose:e,visible:t,headerContent:o=null,children:i,appearance:r})=>(ul(()=>{let n=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",n),t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset",document.removeEventListener("keydown",n)}},[e,t]),t?Re.createElement(fl,null,Re.createElement(gl,{appearance:r,className:l("cornerModalContainer",r)},Re.createElement(xl,{className:l("cornerModalClose",r),onClick:()=>e()},Re.createElement(Ee,null)),o&&Re.createElement(hl,null,o),Re.createElement(Cl,null,i))):Re.createElement(Re.Fragment,null));import{useContext as Sl}from"react";function Q(){let{defaultAppearance:e}=Sl(q);function t(o){let i=JSON.parse(JSON.stringify(e));return o?{styleOverrides:Object.assign(i.styleOverrides??{},o.styleOverrides??{}),theme:Object.assign(i.theme,o.theme??{})}:i}return{mergeAppearanceWithDefault:t}}import jt,{useEffect as Il,useState as _o}from"react";import Wo from"styled-components";import mo,{useEffect as yl,useState as Tr}from"react";import
|
|
132
|
+
`,xr=({onClose:e,visible:t,headerContent:o=null,children:i,appearance:r})=>(ul(()=>{let n=s=>{s.key==="Escape"&&e()};return document.addEventListener("keydown",n),t?document.body.style.overflow="hidden":document.body.style.overflow="unset",()=>{document.body.style.overflow="unset",document.removeEventListener("keydown",n)}},[e,t]),t?Re.createElement(fl,null,Re.createElement(gl,{appearance:r,className:l("cornerModalContainer",r)},Re.createElement(xl,{className:l("cornerModalClose",r),onClick:()=>e()},Re.createElement(Ee,null)),o&&Re.createElement(hl,null,o),Re.createElement(Cl,null,i))):Re.createElement(Re.Fragment,null));import{useContext as Sl}from"react";function Q(){let{defaultAppearance:e}=Sl(q);function t(o){let i=JSON.parse(JSON.stringify(e));return o?{styleOverrides:Object.assign(i.styleOverrides??{},o.styleOverrides??{}),theme:Object.assign(i.theme,o.theme??{})}:i}return{mergeAppearanceWithDefault:t}}import jt,{useEffect as Il,useState as _o}from"react";import Wo from"styled-components";import mo,{useEffect as yl,useState as Tr}from"react";import Mo from"styled-components";import po from"styled-components";var Cr=po.label`
|
|
133
133
|
${e=>k(e)} {
|
|
134
134
|
font-size: 14px;
|
|
135
135
|
line-height: 20px;
|
|
@@ -148,7 +148,7 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
148
148
|
font-weight: 400;
|
|
149
149
|
font-size: 14px;
|
|
150
150
|
line-height: 22px;
|
|
151
|
-
color:
|
|
151
|
+
color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorTextError}};
|
|
152
152
|
display: flex;
|
|
153
153
|
margin-right: 5px;
|
|
154
154
|
margin-top: 10px;
|
|
@@ -157,11 +157,11 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
157
157
|
align-items: flex-start;
|
|
158
158
|
justify-content: left;
|
|
159
159
|
margin-bottom: 10px;
|
|
160
|
-
`;import Do from"react";function et({title:e,required:t,appearance:o}){return Do.createElement(co,null,t?Do.createElement(yr,
|
|
160
|
+
`;import Do from"react";function et({title:e,required:t,appearance:o}){return Do.createElement(co,null,t?Do.createElement(yr,{className:l("formLabelRequired",o),appearance:o},"*"):null,Do.createElement(Cr,{className:l("formLabel",o)},e))}import br from"react";function kt({title:e,appearance:t}){return e?br.createElement(co,null,br.createElement(Sr,{className:l("formSubLabel",t)},e)):null}import{z as $o}from"zod";function wr(e,t){try{if(t){if(t.type=="number"){let o=$o.number();if(t.props)for(let i of t.props)i.requirement=="min"?o=o.min(Number(i.value),i.message??"Value is too small"):i.requirement=="max"?o=o.max(Number(i.value),i.message??"Value is too large"):i.requirement=="positive"?o=o.positive(i.message??"Value must be positive"):i.requirement=="negative"&&(o=o.nonpositive(i.message??"Value must be negative"));o.parse(Number(e))}if(t.type=="string"){let o=$o.string();if(t.props)for(let i of t.props)i.requirement=="min"?o=o.min(Number(i.value),i.message??"Value is too short"):i.requirement=="max"?o=o.max(Number(i.value),i.message??"Value is too long"):i.requirement=="regex"&&(o=o.regex(new RegExp(String(i.value)),i.message??"Value does not match requirements"));o.parse(e)}return}}catch(o){if(o instanceof $o.ZodError)return o.issues&&o.issues.length>0?o.issues[0].message:null;console.error("Frigade Form validation failed for rule ",t,o)}return null}var bl=Mo.div`
|
|
161
161
|
display: flex;
|
|
162
162
|
flex-direction: column;
|
|
163
163
|
width: 100%;
|
|
164
|
-
`,Uo
|
|
164
|
+
`,Uo=Mo.input`
|
|
165
165
|
${e=>k(e)} {
|
|
166
166
|
// Anything inside this block will be ignored if the user provides a custom class
|
|
167
167
|
border: 1px solid ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorBorder}};
|
|
@@ -177,7 +177,7 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
177
177
|
box-sizing: border-box;
|
|
178
178
|
padding: 0 10px;
|
|
179
179
|
margin-bottom: 10px;
|
|
180
|
-
`,wl
|
|
180
|
+
`,wl=Mo.textarea`
|
|
181
181
|
${e=>k(e)} {
|
|
182
182
|
// Anything inside this block will be ignored if the user provides a custom class
|
|
183
183
|
border: 1px solid ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorBorder}};
|
|
@@ -193,7 +193,7 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
193
193
|
min-height: 70px;
|
|
194
194
|
box-sizing: border-box;
|
|
195
195
|
margin-bottom: 10px;
|
|
196
|
-
`;function Fr({formInput:e,customFormTypeProps:t,onSaveInputData:o,setFormValidationErrors:i,inputData:r}){let n=e,[s,p]=Tr((r==null?void 0:r.text)||""),[d,a]=Tr(!1),f=Uo;yl(()=>{s===""&&!d&&(a(!0),c(""))},[]);function c(w){if(p(w),o({text:w}),n.required===!0&&w.trim()===""){i([{id:n.id,message:`${n.title} is required`}]);return}let T=wr(w,n.validation);if(T){i([{id:n.id,message:T}]);return}i([])}n.multiline&&(f=wl);function u(){var w;switch((w=n==null?void 0:n.validation)==null?void 0:w.type){case"email":return"email";case"number":return"number";case"password":return"password"}return null}return mo.createElement(bl,null,mo.createElement(et,{title:n.title,required:n.required,appearance:t.appearance}),mo.createElement(f,{className:l("inputComponent",t.appearance),value:s,onChange:w=>{c(w.target.value)},appearance:t.appearance,placeholder:n.placeholder,type:u()}),mo.createElement(kt,{title:n.subtitle,appearance:t.appearance}))}import
|
|
196
|
+
`;function Fr({formInput:e,customFormTypeProps:t,onSaveInputData:o,setFormValidationErrors:i,inputData:r}){let n=e,[s,p]=Tr((r==null?void 0:r.text)||""),[d,a]=Tr(!1),f=Uo;yl(()=>{s===""&&!d&&(a(!0),c(""))},[]);function c(w){if(p(w),o({text:w}),n.required===!0&&w.trim()===""){i([{id:n.id,message:`${n.title} is required`}]);return}let T=wr(w,n.validation);if(T){i([{id:n.id,message:T}]);return}i([])}n.multiline&&(f=wl);function u(){var w;switch((w=n==null?void 0:n.validation)==null?void 0:w.type){case"email":return"email";case"number":return"number";case"password":return"password"}return null}return mo.createElement(bl,null,mo.createElement(et,{title:n.title,required:n.required,appearance:t.appearance}),mo.createElement(f,{className:l("inputComponent",t.appearance),value:s,onChange:w=>{c(w.target.value)},appearance:t.appearance,placeholder:n.placeholder,type:u()}),mo.createElement(kt,{title:n.subtitle,appearance:t.appearance}))}import Me,{useEffect as kr,useState as Pr}from"react";import vr from"styled-components";var Tl=vr.div`
|
|
197
197
|
display: flex;
|
|
198
198
|
flex-direction: column;
|
|
199
199
|
width: 100%;
|
|
@@ -223,7 +223,7 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
223
223
|
background-repeat: no-repeat;
|
|
224
224
|
background-size: 1.5em 1.5em;
|
|
225
225
|
-webkit-print-color-adjust: exact;
|
|
226
|
-
`,uo="null";function Er({formInput:e,customFormTypeProps:t,onSaveInputData:o,inputData:i,setFormValidationErrors:r}){var f,c,u,w,T,S;let n=e,[s,p]=Pr(((f=i==null?void 0:i.choice)==null?void 0:f[0])||""),[d,a]=Pr(!1);return kr(()=>{var h,E,y,A;if(s===""&&!d){if(a(!0),n.requireSelection){p(uo);return}if(n.defaultValue&&((h=n.props.options)!=null&&h.find(F=>F.id===n.defaultValue))){let F=(E=n.props.options)==null?void 0:E.find(x=>x.id===n.defaultValue);p(F.id),o({choice:[F.id]})}else p(((y=n.props.options)==null?void 0:y[0].id)||""),o({choice:[((A=n.props.options)==null?void 0:A[0].id)||""]})}},[]),kr(()=>{n.requireSelection&&s===uo?r([{message:"Please select an option",id:n.id}]):r([])},[s])
|
|
226
|
+
`,uo="null";function Er({formInput:e,customFormTypeProps:t,onSaveInputData:o,inputData:i,setFormValidationErrors:r}){var f,c,u,w,T,S;let n=e,[s,p]=Pr(((f=i==null?void 0:i.choice)==null?void 0:f[0])||""),[d,a]=Pr(!1);return kr(()=>{var h,E,y,A;if(s===""&&!d){if(a(!0),n.requireSelection){p(uo);return}if(n.defaultValue&&((h=n.props.options)!=null&&h.find(F=>F.id===n.defaultValue))){let F=(E=n.props.options)==null?void 0:E.find(x=>x.id===n.defaultValue);p(F.id),o({choice:[F.id]})}else p(((y=n.props.options)==null?void 0:y[0].id)||""),o({choice:[((A=n.props.options)==null?void 0:A[0].id)||""]})}},[]),kr(()=>{n.requireSelection&&s===uo?r([{message:"Please select an option",id:n.id}]):r([])},[s]),Me.createElement(Tl,null,Me.createElement(et,{title:n.title,required:!1,appearance:t.appearance}),Me.createElement(Fl,{value:s,onChange:h=>{p(h.target.value),o({choice:[h.target.value]})},placeholder:n.placeholder,appearance:t.appearance,className:l("multipleChoiceSelect",t.appearance)},n.requireSelection&&Me.createElement("option",{key:uo,value:uo},"Select an option"),(c=n.props.options)==null?void 0:c.map(h=>Me.createElement("option",{key:h.id,value:h.id},h.title))),((w=(u=n.props.options)==null?void 0:u.find(h=>h.id===s))==null?void 0:w.isOpenEnded)&&Me.createElement(Me.Fragment,null,Me.createElement(et,{title:((S=(T=n.props.options)==null?void 0:T.find(h=>h.id===s))==null?void 0:S.openEndedLabel)??"Please specify",required:!1,appearance:t.appearance}),Me.createElement(Uo,{type:"text",placeholder:"Enter your answer here",onChange:h=>{o({choice:[h.target.value]})},appearance:t.appearance})),Me.createElement(kt,{title:n.subtitle,appearance:t.appearance}))}import fo,{useEffect as Ar,useState as Ir}from"react";import Br from"styled-components";var kl=Br.div`
|
|
227
227
|
display: flex;
|
|
228
228
|
flex-direction: column;
|
|
229
229
|
width: 100%;
|
|
@@ -288,10 +288,10 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
288
288
|
display: flex;
|
|
289
289
|
justify-content: space-between;
|
|
290
290
|
padding-top: 14px;
|
|
291
|
-
|
|
291
|
+
`,$r=ct.div`
|
|
292
292
|
color: ${e=>e.appearance.theme.colorTextError};
|
|
293
293
|
font-size: 12px;
|
|
294
|
-
|
|
294
|
+
`,Mr=ct.div`
|
|
295
295
|
display: flex;
|
|
296
296
|
gap: 12px;
|
|
297
297
|
`,Ur=ct.div`
|
|
@@ -322,7 +322,7 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
322
322
|
background-position: center;
|
|
323
323
|
border-top-right-radius: ${e=>e.appearance.theme.borderRadius}px;
|
|
324
324
|
border-bottom-right-radius: ${e=>e.appearance.theme.borderRadius}px;
|
|
325
|
-
`;import tt from"react";import Dl from"react";import Hr from"styled-components";var
|
|
325
|
+
`;import tt from"react";import Dl from"react";import Hr from"styled-components";var $l=Hr.button`
|
|
326
326
|
justify-content: center;
|
|
327
327
|
align-content: center;
|
|
328
328
|
${e=>k(e)} {
|
|
@@ -362,7 +362,7 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
362
362
|
margin-right: 8px;
|
|
363
363
|
}
|
|
364
364
|
}
|
|
365
|
-
`,ee=({onClick:e,title:t,style:o,disabled:i,type:r="inline",size:n="medium",secondary:s=!1,appearance:p,withMargin:d=!0,classPrefix:a=""})=>{function f(){let c=s?"buttonSecondary":"button";return a===""?c:`${a}${gr(c)}`}return Dl.createElement(
|
|
365
|
+
`,ee=({onClick:e,title:t,style:o,disabled:i,type:r="inline",size:n="medium",secondary:s=!1,appearance:p,withMargin:d=!0,classPrefix:a=""})=>{function f(){let c=s?"buttonSecondary":"button";return a===""?c:`${a}${gr(c)}`}return Dl.createElement($l,{secondary:s,appearance:p,disabled:i,onClick:e,style:o,type:r,withMargin:d,size:n,className:l(f(),p)},t)};var jr=({step:e,canContinue:t,appearance:o,onPrimaryClick:i,onSecondaryClick:r,formType:n,selectedStep:s,steps:p,onBack:d,allowBackNavigation:a,errorMessage:f})=>{let c=n==="inline"?"inline":"full-width";return tt.createElement(tt.Fragment,null,f&&tt.createElement($r,{appearance:o,className:l("formCTAError",o)},f),tt.createElement(Dr,{className:l("formCTAContainer",o)},p.length>1&&s!=0&&a&&tt.createElement(ee,{title:"\u2190",onClick:d,secondary:!0,withMargin:!1,type:c,appearance:o}),tt.createElement(Mr,{className:l("ctaWrapper",o)},e.secondaryButtonTitle?tt.createElement(ee,{title:e.secondaryButtonTitle,onClick:r,secondary:!0,withMargin:!1,type:c,appearance:o}):null," ",e.primaryButtonTitle?tt.createElement(ee,{disabled:!t,withMargin:!1,title:e.primaryButtonTitle,onClick:i,type:c,appearance:o}):null)))};import zo from"react";import Ml from"styled-components";var Ul=Ml.div`
|
|
366
366
|
text-align: center;
|
|
367
367
|
`,Gr=({stepCount:e=0,currentStep:t=0,className:o,appearance:i})=>{let{theme:r}=Q().mergeAppearanceWithDefault(i);return zo.createElement(Ul,{className:o},zo.createElement("svg",{width:16*e-8,height:8,viewBox:`0 0 ${16*e-8} 8`,fill:"none"},Array(e).fill(null).map((n,s)=>zo.createElement("rect",{key:s,x:16*s,y:0,width:8,height:8,rx:4,fill:t===s?r.colorPrimary:"#E6E6E6"}))))};import mt from"react";import Pt from"styled-components";import{useContext as _l}from"react";function ne(){let e=_l(q);function t(r){i(r.primaryButtonUri,r.primaryButtonUriTarget)}function o(r){i(r.secondaryButtonUri,r.secondaryButtonUriTarget)}function i(r,n){if(!r)return;let s=r.startsWith("http")?"_blank":"_self";n&&n!=="_blank"&&(s="_self"),e.navigate(r,s)}return{primaryCTAClickSideEffects:t,secondaryCTAClickSideEffects:o,handleUrl:i}}var Wl=Pt.div`
|
|
368
368
|
display: flex;
|
|
@@ -528,8 +528,8 @@ import gt,{createContext as Pa,useEffect as Yo,useState as Ne}from"react";import
|
|
|
528
528
|
color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorText}};
|
|
529
529
|
display: flex;
|
|
530
530
|
align-self: center;
|
|
531
|
-
`;var oi=({stepData:e,setCanContinue:t,onSaveData:o,appearance:i})=>{let r=e.props,[n,s]=Go([]),[p,d]=Go(!1),[a,f]=Go(e.id);return jo(()=>{n.length==0&&!p&&(d(!0),o({choice:[]}))},[p]),jo(()=>{a!==e.id&&(f(e.id),s([]))},[e]),jo(()=>{o({choice:n}),n.length>=r.minChoices?t(!0):t(!1)},[n]),qe.createElement(Yr,{className:l("selectListContainer",i)},qe.createElement(Xr,null,qe.createElement(Jr,{className:l("selectListTitle",i)},e.title),qe.createElement(Qr,{appearance:i,className:l("selectListSubtitle",i)},e.subtitle)),r.options.map((c,u)=>{let w=n.includes(c.id);return qe.createElement(Zr,{key:`select-item-${u}`,onClick:()=>{if(n.includes(c.id)){s(n.filter(T=>T!==c.id));return}n.length<r.maxChoices?s([...n,c.id]):n.length==1&&r.maxChoices==1&&s([c.id])},hideBottomBorder:u===r.options.length-1,className:l("selectListSelectItem",i)},qe.createElement(Rr,{className:l("selectListItemImage",i)},c.imageUri&&qe.createElement(ei,{src:c.imageUri,alt:`select-icon-${u}`}),qe.createElement(ti,{appearance:i,className:l("selectListSelectItemText",i)},c.title)),qe.createElement(ut,{appearance:i,value:w,primaryColor:i.theme.colorPrimary}))}))};import we,{useEffect as Vo,useState as Kt}from"react";import{AnimatePresence as ha,motion as xa}from"framer-motion";var Ca=({children:e,id:t,shouldWrap:o=!1})=>we.createElement(we.Fragment,null,o?we.createElement(ha,{initial:!1},we.createElement(xa.div,{key:t,initial:{opacity:1,y:"100%"},animate:{opacity:1,y:0},exit:{opacity:0,y:"-100%"},transition:{duration:.5,ease:"easeInOut"},style:{width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:1,overflowY:"auto"}},e)):e),yo=({appearance:e,steps:t,selectedStep:o,customStepTypes:i,customVariables:r,onButtonClick:n,onStepCompletion:s,flowId:p,type:d,hideOnFlowCompletion:a,onComplete:f,setVisible:c,setShowModal:u,onDismiss:w,showPagination:T=!1,customFormElements:S,allowBackNavigation:h,validationHandler:E})=>{var Ce;let A={...{linkCollection:Vr,multiInput:Or,callToAction:qr,selectList:oi},...i},{primaryCTAClickSideEffects:F,secondaryCTAClickSideEffects:x}=ne(),[m,C]=Kt(!1),[P
|
|
532
|
-
${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map(([s,p])=>`${Oo(s)}: ${p};`).join(" ")} }`).join(" ")}`;return Yt.createElement(o,{inlineStyles:t})}var ri=({flowId:e,customStepTypes:t={},type:o="inline",visible:i,setVisible:r,customVariables:n,customFormElements:s,onComplete:p,appearance:d,hideOnFlowCompletion:a=!0,onStepCompletion:f,onButtonClick:c,dismissible:u=!0,endFlowOnDismiss:w=!1,modalPosition:T="center",repeatable:S=!1,onDismiss:h,showPagination:E=!1,allowBackNavigation:y=!1,validationHandler:A})=>{let{getFlow:F,getFlowSteps:x,isLoading:m,targetingLogicShouldHideFlow:C,getFlowStatus:P,getCurrentStepIndex
|
|
531
|
+
`;var oi=({stepData:e,setCanContinue:t,onSaveData:o,appearance:i})=>{let r=e.props,[n,s]=Go([]),[p,d]=Go(!1),[a,f]=Go(e.id);return jo(()=>{n.length==0&&!p&&(d(!0),o({choice:[]}))},[p]),jo(()=>{a!==e.id&&(f(e.id),s([]))},[e]),jo(()=>{o({choice:n}),n.length>=r.minChoices?t(!0):t(!1)},[n]),qe.createElement(Yr,{className:l("selectListContainer",i)},qe.createElement(Xr,null,qe.createElement(Jr,{className:l("selectListTitle",i)},e.title),qe.createElement(Qr,{appearance:i,className:l("selectListSubtitle",i)},e.subtitle)),r.options.map((c,u)=>{let w=n.includes(c.id);return qe.createElement(Zr,{key:`select-item-${u}`,onClick:()=>{if(n.includes(c.id)){s(n.filter(T=>T!==c.id));return}n.length<r.maxChoices?s([...n,c.id]):n.length==1&&r.maxChoices==1&&s([c.id])},hideBottomBorder:u===r.options.length-1,className:l("selectListSelectItem",i)},qe.createElement(Rr,{className:l("selectListItemImage",i)},c.imageUri&&qe.createElement(ei,{src:c.imageUri,alt:`select-icon-${u}`}),qe.createElement(ti,{appearance:i,className:l("selectListSelectItemText",i)},c.title)),qe.createElement(ut,{appearance:i,value:w,primaryColor:i.theme.colorPrimary}))}))};import we,{useEffect as Vo,useState as Kt}from"react";import{AnimatePresence as ha,motion as xa}from"framer-motion";var Ca=({children:e,id:t,shouldWrap:o=!1})=>we.createElement(we.Fragment,null,o?we.createElement(ha,{initial:!1},we.createElement(xa.div,{key:t,initial:{opacity:1,y:"100%"},animate:{opacity:1,y:0},exit:{opacity:0,y:"-100%"},transition:{duration:.5,ease:"easeInOut"},style:{width:"100%",height:"100%",position:"absolute",top:0,left:0,zIndex:1,overflowY:"auto"}},e)):e),yo=({appearance:e,steps:t,selectedStep:o,customStepTypes:i,customVariables:r,onButtonClick:n,onStepCompletion:s,flowId:p,type:d,hideOnFlowCompletion:a,onComplete:f,setVisible:c,setShowModal:u,onDismiss:w,showPagination:T=!1,customFormElements:S,allowBackNavigation:h,validationHandler:E})=>{var Ce;let A={...{linkCollection:Vr,multiInput:Or,callToAction:qr,selectList:oi},...i},{primaryCTAClickSideEffects:F,secondaryCTAClickSideEffects:x}=ne(),[m,C]=Kt(!1),[P,$]=Kt({}),[U,M]=Kt(!1),[I,j]=Kt(!1),[B,D]=Kt(null),re=t[o]??null,{markStepCompleted:R,markStepStarted:_,isLoading:he,updateCustomVariables:Fe,markFlowCompleted:W}=J();Vo(()=>{Fe(r)},[r,he]),Vo(()=>{window&&h&&!I&&(window.location.hash=t[o].id,j(!0))},[h,I,j]),Vo(()=>{var V;if(window&&((V=window==null?void 0:window.location)!=null&&V.hash)&&window.location.hash.replace("#","")!==t[o].id){let de=window.location.hash.replace("#",""),oe=t.findIndex(K=>K.id===de);oe!==-1&&_(p,t[oe].id)}},[(Ce=window==null?void 0:window.location)==null?void 0:Ce.hash,_,o,t]);function se(){return{data:P[t[o].id]??{},stepId:t[o].id,customVariables:r}}function G(V,de,oe){let K=o+1<t.length?t[o+1]:null;n&&n(V,o,de,K),s&&s(V,oe,K,P,se())}function L(V,de){$(oe=>{let K={};return K[V.id]=de,{...oe,...K}})}function te(V){return V.selectedStep.imageUri?we.createElement(zr,{image:V.selectedStep.imageUri,appearance:e,className:l("formContainerSidebarImage",e)}):null}let xe=we.createElement(jr,{step:t[o],canContinue:m&&!U,formType:d,selectedStep:o,appearance:e,onPrimaryClick:async()=>{if(M(!0),E){let de=E(t[o],o,t[o+1],P,se());if(de){D(de),M(!1);return}else D(null)}let V={...se()};await R(p,t[o].id,V),o+1<t.length&&await _(p,t[o+1].id),G(t[o],"primary",o),o+1>=t.length&&(f&&f(),w&&w(),a&&(c&&c(!1),u(!1)),await W(p)),F(t[o]),M(!1),window&&h&&o+1<t.length&&(window.location.hash=t[o+1].id)},onSecondaryClick:()=>{G(t[o],"secondary",o),x(t[o])},onBack:async()=>{o-1>=0&&(M(!0),await _(p,t[o-1].id),M(!1))},steps:t,allowBackNavigation:h,errorMessage:B});return we.createElement(we.Fragment,null,we.createElement(Ur,{className:l("formContainer",e)},we.createElement(_r,null,we.createElement(Ca,{id:o,shouldWrap:d==="large-modal"},we.createElement(Wr,{key:re.id,type:d,className:l("formContent",e)},t.map(V=>{let de=A[V.type];return re.id!==V.id?null:we.createElement(de,{key:V.id,stepData:V,canContinue:m,setCanContinue:C,onSaveData:oe=>{L(V,oe)},appearance:e,customFormElements:S})}),T&&we.createElement(Gr,{className:l("formPagination",e),appearance:e,stepCount:t.length,currentStep:o}),xe))),d=="large-modal"&&we.createElement(te,{selectedStep:t[o]})))};import Yt from"react";import{createGlobalStyle as Sa}from"styled-components";function ie({appearance:e}){if(!e||!e.styleOverrides)return Yt.createElement(Yt.Fragment,null);let t=Object.entries(e.styleOverrides).filter(([i,r])=>typeof r=="object");if(t.length===0)return Yt.createElement(Yt.Fragment,null);let o=Sa`
|
|
532
|
+
${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map(([s,p])=>`${Oo(s)}: ${p};`).join(" ")} }`).join(" ")}`;return Yt.createElement(o,{inlineStyles:t})}var ri=({flowId:e,customStepTypes:t={},type:o="inline",visible:i,setVisible:r,customVariables:n,customFormElements:s,onComplete:p,appearance:d,hideOnFlowCompletion:a=!0,onStepCompletion:f,onButtonClick:c,dismissible:u=!0,endFlowOnDismiss:w=!1,modalPosition:T="center",repeatable:S=!1,onDismiss:h,showPagination:E=!1,allowBackNavigation:y=!1,validationHandler:A})=>{let{getFlow:F,getFlowSteps:x,isLoading:m,targetingLogicShouldHideFlow:C,getFlowStatus:P,getCurrentStepIndex:$,markFlowCompleted:U,markFlowNotStarted:M}=J(),I=$(e),{mergeAppearanceWithDefault:j}=Q(),[B,D]=ba(!1),{setOpenFlowState:re,getOpenFlowState:R}=ve();d=j(d);let[_,he]=i!==void 0&&r!==void 0?[i,r]:[R(e,!0),G=>re(e,G)];if(ya(()=>{!B&&!m&&(D(!0),P(e)===X&&S&&M(e),D(!0))},[B,D,m]),m)return null;let Fe=F(e);if(!Fe||C(Fe))return null;let W=x(e);if(!W||i!==void 0&&i===!1||P(e)===X&&a)return null;let se=()=>{he(!1),h&&h(),w===!0&&U(e)};if(T=="center"&&o==="modal"||o==="large-modal"){let G={padding:"24px"};return o==="large-modal"?(G.width="85%",G.height="90%",G.maxHeight="800px",G.minHeight="500px",G.padding="0"):G.width="400px",Ue.createElement(Ze,{appearance:d,onClose:se,visible:_,style:G,dismissible:u},Ue.createElement(ie,{appearance:d}),Ue.createElement(yo,{appearance:d,steps:W,selectedStep:I,customStepTypes:t,customVariables:n,onButtonClick:c,onStepCompletion:f,flowId:e,type:o,hideOnFlowCompletion:a,onComplete:p,setVisible:r,setShowModal:he,onDismiss:h,showPagination:E,customFormElements:s,allowBackNavigation:y,validationHandler:A}))}return o==="modal"&&T!=="center"?Ue.createElement(xr,{appearance:d,onClose:se,visible:_},Ue.createElement(ie,{appearance:d}),Ue.createElement(yo,{appearance:d,steps:W,selectedStep:I,customStepTypes:t,customVariables:n,onButtonClick:c,onStepCompletion:f,flowId:e,type:o,hideOnFlowCompletion:a,onComplete:p,setVisible:r,setShowModal:he,onDismiss:h,showPagination:E,customFormElements:s,allowBackNavigation:y,validationHandler:A})):Ue.createElement(Ue.Fragment,null,Ue.createElement(ie,{appearance:d}),Ue.createElement(yo,{appearance:d,steps:W,selectedStep:I,customStepTypes:t,customVariables:n,onButtonClick:c,onStepCompletion:f,flowId:e,type:o,hideOnFlowCompletion:a,onComplete:p,setVisible:r,setShowModal:he,onDismiss:h,showPagination:E,customFormElements:s,allowBackNavigation:y,validationHandler:A}))},ii=ri;import{useCallback as ni,useContext as wa,useEffect as Ta}from"react";function qo(){let{organizationId:e,userId:t,setOrganizationId:o}=wa(q),{mutateUserFlowState:i}=Be(),{config:r}=$e(),n=wt(),{verifySDKInitiated:s}=Tt();Ta(()=>{if(t&&e){if(t.startsWith(Ft))return;let a=`frigade-user-group-registered-${t}-${e}`;localStorage.getItem(a)||(n(`${ke}userGroups`,{...r,method:"POST",body:JSON.stringify({foreignUserId:t,foreignUserGroupId:e})}),localStorage.setItem(a,"true"))}},[t,e]);let p=ni(async a=>{if(s(),!e||!t){console.error("Cannot add properties to organization: Organization ID and User ID must both be set.",{organizationId:e,userId:t});return}let f={foreignUserId:t,foreignUserGroupId:e,properties:a};await n(`${ke}userGroups`,{...r,method:"POST",body:JSON.stringify(f)}),i()},[e,t,r,i]),d=ni(async(a,f)=>{if(s(),!e||!t){console.error("Cannot track event for organization: Organization ID and User ID must both be set.",{organizationId:e,userId:t});return}let u={foreignUserId:t,foreignUserGroupId:e,events:[{event:a,properties:f}]};await n(`${ke}userGroups`,{...r,method:"POST",body:JSON.stringify(u)}),i()},[e,t,r,i]);return{organizationId:e,setOrganizationId:o,addPropertiesToOrganization:p,trackEventForOrganization:d}}var si="xFrigade_guestUserId",li="xFrigade_userId",ai=({})=>{let{setFlowResponses:e}=zt(),{userFlowStatesData:t,isLoadingUserFlowStateData:o,mutateUserFlowState:i}=Be(),{userId:r,setUserId:n}=Lo(),[s,p]=Ko(null),{getFlowStatus:d}=J(),{flows:a,userProperties:f,setIsNewGuestUser:c,flowResponses:u}=Fa(q),[w,T]=Ko([]),[S,h]=Ko([]),{organizationId:E}=qo();bo(()=>{if(!o&&t)for(let x=0;x<t.length;x++){let m=t[x],C=a.find(P=>P.slug===(m==null?void 0:m.flowId));if(C&&m&&m.shouldTrigger===!0&&C.type=="FORM"&&C.triggerType==="AUTOMATIC"&&!S.includes(C.slug)){setTimeout(()=>{y(m.flowId)},500);break}}},[o,t]),bo(()=>{u.length>0&&i()},[u]);function y(x){let m=a.find(C=>C.slug===x);m&&m.triggerType==="AUTOMATIC"&&!S.includes(m.slug)&&(h([...S,m.slug]),T([m]))}function A(){if(!r){let x=localStorage.getItem(li);if(x){n(x);return}let m=localStorage.getItem(si);if(m){n(m);return}c(!0);let C=Ft+ka();try{localStorage.setItem(si,C)}catch(P){console.log("Failed to save guest user id locally: Local storage unavailable",P)}n(P=>P||C)}}bo(()=>{try{if(a){let x=[];a.forEach(m=>{if(m.data){let C=m.data.match(/"imageUri":"(.*?)"/g);C&&C.forEach(P=>{let $=P.replace('"imageUri":"',"").replace('"',"");if(x.includes($))return;let U=new Image;U.src=$,x.push($)})}})}}catch{}},[a]),bo(()=>{if(r!==s&&e([]),p(r),r&&!r.startsWith(Ft))try{localStorage.setItem(li,r)}catch(x){console.log("Failed to save user id locally: Local storage available",x)}r===null&&setTimeout(()=>{r===null&&A()},50)},[r,a,f]);function F(){return ft.createElement(ft.Fragment,null,w.map(x=>d(x.slug)!==Le?null:ft.createElement("span",{key:x.slug},ft.createElement(ii,{flowId:x.slug,type:"modal",modalPosition:"center",endFlowOnDismiss:!0}))))}return ft.createElement(ft.Fragment,null,ft.createElement(F,null))};import{ErrorBoundary as Ea}from"react-error-boundary";var q=Pa({publicApiKey:"",setUserId:()=>{},flows:[],setFlows:()=>{},failedFlowResponses:[],setFailedFlowResponses:()=>{},flowResponses:[],setFlowResponses:()=>{},userProperties:{},setUserProperties:()=>{},openFlowStates:{},setOpenFlowStates:()=>{},completedFlowsToKeepOpenDuringSession:[],setCompletedFlowsToKeepOpenDuringSession:()=>{},customVariables:{},setCustomVariables:()=>{},isNewGuestUser:!1,setIsNewGuestUser:()=>{},hasActiveFullPageFlow:!1,setHasActiveFullPageFlow:()=>{},organizationId:"",setOrganizationId:()=>{},navigate:()=>{},defaultAppearance:It,shouldGracefullyDegrade:!1,setShouldGracefullyDegrade:()=>{}}),Aa=({publicApiKey:e,userId:t,organizationId:o,config:i,children:r})=>{var re,R;let[n,s]=Ne(t||null),[p,d]=Ne(o||null),[a,f]=Ne([]),[c,u]=Ne([]),[w,T]=Ne([]),[S,h]=Ne({}),[E,y]=Ne({}),[A,F]=Ne([]),[x,m]=Ne({}),[C,P]=Ne(!1),[$,U]=Ne(!1),[M,I]=Ne(!D(e)),j=(_,he)=>{if(he==="_blank"){window.open(_,"_blank");return}setTimeout(()=>{window.location.href=_},50)},B={theme:{...It.theme,...((re=i==null?void 0:i.defaultAppearance)==null?void 0:re.theme)??{}},styleOverrides:{...It.styleOverrides,...((R=i==null?void 0:i.defaultAppearance)==null?void 0:R.styleOverrides)??{}}};function D(_){return!!(_&&_.length>10&&_.substring(0,10)==="api_public")}return Yo(()=>{t&&s(t)},[t]),Yo(()=>{o&&d(o)},[o]),Yo(()=>{if(D(e))I(!1);else{console.error("Frigade SDK failed to initialize. API key provided is either missing or valid."),I(!0);return}},[e,I]),M?gt.createElement(q.Provider,{value:{publicApiKey:e,userId:n,setUserId:s,setFlows:f,flows:a,failedFlowResponses:c,setFailedFlowResponses:u,flowResponses:w,setFlowResponses:T,userProperties:S,setUserProperties:h,openFlowStates:E,setOpenFlowStates:y,completedFlowsToKeepOpenDuringSession:A,setCompletedFlowsToKeepOpenDuringSession:F,customVariables:x,setCustomVariables:m,isNewGuestUser:C,setIsNewGuestUser:P,hasActiveFullPageFlow:$,setHasActiveFullPageFlow:U,organizationId:p,setOrganizationId:d,navigate:i&&i.navigate?i.navigate:j,defaultAppearance:B,shouldGracefullyDegrade:M,setShouldGracefullyDegrade:I}},r):gt.createElement(Ea,{fallback:gt.createElement(gt.Fragment,null,r)},gt.createElement(q.Provider,{value:{publicApiKey:e,userId:n,setUserId:s,setFlows:f,flows:a,failedFlowResponses:c,setFailedFlowResponses:u,flowResponses:w,setFlowResponses:T,userProperties:S,setUserProperties:h,openFlowStates:E,setOpenFlowStates:y,completedFlowsToKeepOpenDuringSession:A,setCompletedFlowsToKeepOpenDuringSession:F,customVariables:x,setCustomVariables:m,isNewGuestUser:C,setIsNewGuestUser:P,hasActiveFullPageFlow:$,setHasActiveFullPageFlow:U,organizationId:p,setOrganizationId:d,navigate:i&&i.navigate?i.navigate:j,defaultAppearance:B,shouldGracefullyDegrade:M,setShouldGracefullyDegrade:I}},gt.createElement(va,{theme:B.theme},r,gt.createElement(ai,null))))};import Pp from"react";import pe,{useEffect as _n,useState as Wn}from"react";import De,{useState as Qa}from"react";import Ct from"styled-components";import Fo from"react";import ht from"react";import di from"styled-components";var pi=di.span`
|
|
533
533
|
font-weight: 400;
|
|
534
534
|
font-size: 15px;
|
|
535
535
|
line-height: 20px;
|
|
@@ -585,7 +585,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
585
585
|
flex-grow: 1;
|
|
586
586
|
position: relative;
|
|
587
587
|
${e=>e.textLocation=="top"?"width: 100%;":""}
|
|
588
|
-
|
|
588
|
+
`,$a=Xo.span`
|
|
589
589
|
font-weight: 500;
|
|
590
590
|
font-size: 15px;
|
|
591
591
|
line-height: 18px;
|
|
@@ -593,7 +593,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
593
593
|
color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorTextSecondary}};
|
|
594
594
|
margin-bottom: ${e=>e.textLocation=="top"?"8px":"0px"};
|
|
595
595
|
${e=>dt(e)}
|
|
596
|
-
|
|
596
|
+
`,Ma={position:"relative",left:0,top:0,width:"100%",minWidth:"40px",height:"10px",borderRadius:"20px"},Ua={position:"absolute",left:0,top:0,height:"10px",borderRadius:"20px"},_e=({count:e,total:t,fillColor:o,bgColor:i=La.backgroundColor,display:r="count",textLocation:n="left",style:s={},textStyle:p={},appearance:d})=>{var T,S;if(t===0)return xt.createElement(xt.Fragment,null);let a=e===0?"10px":`${e/t*100}%`,f=r==="compact"?"5px":"10px",c=Math.round(e/t*100),u=r==="compact"?"5px":"20px",w;return r==="count"?w=`${e} of ${t}`:r==="compact"?w=`${c}%`:r==="percent"&&(w=`${c}% complete`),n==="top"&&(u="0px"),xt.createElement(Oa,{className:l("progressBarContainer",d),textLocation:n,styleOverrides:s},xt.createElement($a,{className:l("progressBarStepText",d),style:{...p,fontSize:r==="compact"?12:15,fontWeight:r==="compact"?400:500},appearance:d,padding:u,textLocation:n},w),xt.createElement(Da,{textLocation:n,className:l("progressBar",d)},xt.createElement(Na.div,{style:{...Ua,width:a,height:f,backgroundColor:((T=d==null?void 0:d.theme)==null?void 0:T.colorPrimary)??o,zIndex:r=="compact"?1:5},className:l("progressBarFill",d)}),xt.createElement("div",{className:l("progressBarBackground",d),style:{...Ma,height:f,backgroundColor:((S=d==null?void 0:d.theme)==null?void 0:S.colorSecondary)??i}})))};import Qt from"react";import _a from"styled-components";import Po from"react";import ko from"react";var Bt=({stepData:e,appearance:t})=>ko.createElement(ko.Fragment,null,ko.createElement(mi,{appearance:t,className:l("checklistStepTitle",t),dangerouslySetInnerHTML:me(e.title)}),ko.createElement(ui,{appearance:t,className:l("checklistStepSubtitle",t),dangerouslySetInnerHTML:me(e.subtitle)}));import Jt from"react";var Nt=({stepData:e,appearance:t})=>{let o=()=>{e.handlePrimaryButtonClick&&e.handlePrimaryButtonClick()},i=()=>{e.handleSecondaryButtonClick&&e.handleSecondaryButtonClick()};return Jt.createElement(Jt.Fragment,null,Jt.createElement(ho,null,e.secondaryButtonTitle&&Jt.createElement(ee,{appearance:t,secondary:!0,title:e.secondaryButtonTitle,onClick:i,style:{width:"auto",marginRight:"12px"}}),Jt.createElement(ee,{appearance:t,title:e.primaryButtonTitle,onClick:o})))};var Lt=({stepData:e,appearance:t})=>Po.createElement(Po.Fragment,null,Po.createElement(Bt,{stepData:e,appearance:t}),Po.createElement(Nt,{stepData:e,appearance:t}));import hi from"react";function xi(e){if(e.videoUri.includes("youtube")){let t=e.videoUri.split("v=")[1],o=t.indexOf("&");return o!==-1&&(t=t.substring(0,o)),hi.createElement("iframe",{width:"480",height:"260",src:`https://www.youtube.com/embed/${t}`,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,className:l("checklistStepVideo",e.appearance)})}else return hi.createElement("video",{width:"480",height:"260",controls:!0,src:e.videoUri})}var Jo="default",Wa=_a.img`
|
|
597
597
|
border-radius: 4px;
|
|
598
598
|
max-height: 260px;
|
|
599
599
|
min-height: 200px;
|
|
@@ -749,7 +749,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
749
749
|
flex-direction: row;
|
|
750
750
|
`,Di=ue.div`
|
|
751
751
|
flex: 1;
|
|
752
|
-
|
|
752
|
+
`,$i=ue.div`
|
|
753
753
|
${e=>k(e)} {
|
|
754
754
|
display: flex;
|
|
755
755
|
justify-content: center;
|
|
@@ -759,7 +759,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
759
759
|
padding-left: 8px;
|
|
760
760
|
padding-right: 8px;
|
|
761
761
|
}
|
|
762
|
-
|
|
762
|
+
`,Mi=ue.p`
|
|
763
763
|
${e=>k(e)} {
|
|
764
764
|
font-style: normal;
|
|
765
765
|
font-weight: 600;
|
|
@@ -913,7 +913,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
913
913
|
line-height: 14px;
|
|
914
914
|
font-weight: 400;
|
|
915
915
|
cursor: pointer;
|
|
916
|
-
`;var pp=({steps:e,style:t,title:o,primaryColor:i,appearance:r,onButtonClick:n})=>{let{primaryCTAClickSideEffects:s}=ne();return Xe.createElement(qi,{style:t,className:l("guideContainer",r)},Xe.createElement(Yi,{className:l("guideTitle",r)},o),Xe.createElement(Ki,{className:l("guideItemContainer",r)},e.map((p,d)=>Xe.createElement(Xi,{key:`guide-${p.id??d}`,as:ap.div,whileHover:{boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.05)",transition:{duration:.25}},className:l("guideItem",r)},p.icon&&Xe.createElement(Ji,{className:l("guideIcon",r)},Xe.createElement(Qi,null,p.icon)),Xe.createElement(Zi,{className:l("guideItemTitle",r),dangerouslySetInnerHTML:me(p.title)}),Xe.createElement(Ri,{className:l("guideItemSubtitle",r),dangerouslySetInnerHTML:me(p.subtitle)}),Xe.createElement(en,{className:l("guideItemLink",r),color:i,onClick:()=>{p.primaryButtonUri&&s(p),n&&n(p)}},p.primaryButtonTitle)))))},Zt=pp;var mp=({steps:e,title:t,subtitle:o,stepsTitle:i,visible:r,onClose:n,selectedStep:s,setSelectedStep:p,customStepTypes:d,appearance:a,guideData:f,guideTitle:c,onGuideButtonClick:u})=>{let w=({stepData:m,handleSecondaryCTAClick:C,handleCTAClick:P})=>m?N.createElement(
|
|
916
|
+
`;var pp=({steps:e,style:t,title:o,primaryColor:i,appearance:r,onButtonClick:n})=>{let{primaryCTAClickSideEffects:s}=ne();return Xe.createElement(qi,{style:t,className:l("guideContainer",r)},Xe.createElement(Yi,{className:l("guideTitle",r)},o),Xe.createElement(Ki,{className:l("guideItemContainer",r)},e.map((p,d)=>Xe.createElement(Xi,{key:`guide-${p.id??d}`,as:ap.div,whileHover:{boxShadow:"0px 2px 8px rgba(0, 0, 0, 0.05)",transition:{duration:.25}},className:l("guideItem",r)},p.icon&&Xe.createElement(Ji,{className:l("guideIcon",r)},Xe.createElement(Qi,null,p.icon)),Xe.createElement(Zi,{className:l("guideItemTitle",r),dangerouslySetInnerHTML:me(p.title)}),Xe.createElement(Ri,{className:l("guideItemSubtitle",r),dangerouslySetInnerHTML:me(p.subtitle)}),Xe.createElement(en,{className:l("guideItemLink",r),color:i,onClick:()=>{p.primaryButtonUri&&s(p),n&&n(p)}},p.primaryButtonTitle)))))},Zt=pp;var mp=({steps:e,title:t,subtitle:o,stepsTitle:i,visible:r,onClose:n,selectedStep:s,setSelectedStep:p,customStepTypes:d,appearance:a,guideData:f,guideTitle:c,onGuideButtonClick:u})=>{let w=({stepData:m,handleSecondaryCTAClick:C,handleCTAClick:P})=>m?N.createElement($i,{className:l("checklistStepContainer",a),"data-testid":"checklistStepContainer"},N.createElement(Mi,{appearance:a,className:l("checklistStepTitle",a),dangerouslySetInnerHTML:me(m.title)}),N.createElement(Ui,{appearance:a,className:l("checklistStepSubtitle",a),dangerouslySetInnerHTML:me(m.subtitle)}),N.createElement(_i,{className:l("checklistCTAContainer",a)},m.secondaryButtonTitle&&N.createElement(ee,{title:m.secondaryButtonTitle,onClick:C,appearance:a,secondary:!0}),N.createElement(ee,{title:m.primaryButtonTitle,onClick:P,appearance:a}))):N.createElement(N.Fragment,null),S={...{default:m=>{var U;if((U=e[y])!=null&&U.StepContent){let M=e[y].StepContent;return N.createElement("div",null,M)}let C=e[y];return N.createElement(w,{stepData:m,handleCTAClick:()=>{C.handlePrimaryButtonClick&&C.handlePrimaryButtonClick()},handleSecondaryCTAClick:()=>{C.handleSecondaryButtonClick&&C.handleSecondaryButtonClick()}})}},...d},[h,E]=dp(0),y=s??h,A=p??E,F=()=>{var m;return e?!((m=e[y])!=null&&m.type)||!S[e[y].type]?S.default(e[y]):S[e[y].type]({stepData:e[y],primaryColor:a.theme.colorPrimary}):N.createElement(N.Fragment,null)},x=e.filter(m=>m.complete).length;return r?(a.theme.modalContainer||(a.theme.borderRadius&&(Zo.borderRadius=a.theme.borderRadius+"px"),a.theme.modalContainer=Zo),N.createElement(Ze,{onClose:n,visible:r,appearance:a},N.createElement(Gi,null,N.createElement(Ei,null,N.createElement(Ai,{appearance:a,className:l("checklistTitle",a)},t),N.createElement(Ii,{appearance:a,className:l("checklistSubtitle",a)},o)),N.createElement(vi,null,e&&e.length>0&&N.createElement(Bi,{className:l("stepsContainer",a)},N.createElement(Ni,null,N.createElement("div",{style:{flex:3}},N.createElement(Li,{className:l("stepsTitle",a)},i)),N.createElement(ji,null,N.createElement(_e,{fillColor:a.theme.colorPrimary,style:{width:"100%"},count:x,total:e.length,appearance:a}))),N.createElement(Oi,null,N.createElement(Di,{className:l("checklistStepListContainer",a),appearance:a},e.map((m,C)=>{let P=y===C;return N.createElement(Wi,{selected:P,className:l(`checklistStepListItem${P?"Selected":""}`,a),key:`checklist-guide-step-${m.id??C}`,disabled:m.blocked,onClick:()=>{m.blocked||A(C)},title:m.blocked?"Finish remaining steps to continue":void 0},P&&N.createElement(To,{className:l("checklistStepItemSelectedIndicator",a),as:cp.div,layoutId:"checklist-step-selected",style:{backgroundColor:a.theme.colorPrimary,borderRadius:0,height:"100%",top:"0%",width:"2px"}}),N.createElement(zi,{selected:P,className:l(`checklistStepListStepName${P?"Selected":""}`,a)},m.stepName),N.createElement(Hi,null,N.createElement(ut,{value:m.complete,type:"round",primaryColor:a.theme.colorPrimary,progress:m.progress,appearance:a}),N.createElement(Vi,null,N.createElement(Dt,{style:{marginLeft:"10px"},color:a.theme.colorBackgroundSecondary}))))})),N.createElement(F,null))),f&&f.length>0&&N.createElement(Zt,{steps:f,title:c,primaryColor:a.theme.colorPrimary,style:{border:"none",boxShadow:"none"},appearance:a,onButtonClick:m=>(u&&u(m),!0)}))))):N.createElement(N.Fragment,null)},Ro=mp;import{useEffect as up,useState as fp}from"react";var tn=()=>{let e={isSmall:"(max-width: 480px)",isMedium:"(min-width: 481px) AND (max-width: 1023px)",isLarge:"(min-width: 1025px)"},t=Object.fromEntries(Object.entries(e).map(([p])=>[p,!1])),[o,i]=fp(t),r=null,n=()=>{r!==null?clearTimeout(r):s(),r=setTimeout(()=>{s()},16)},s=()=>{let p=Object.fromEntries(Object.entries(e).map(([d,a])=>{if(!window)return[d,!1];let f=window.matchMedia(a);return f.addEventListener("change",n),[d,f.matches]}));i(p)};return up(()=>{s()},[]),o};import Pe,{useEffect as xn,useState as xp}from"react";import fe from"react";import{AnimatePresence as gp,motion as hp}from"framer-motion";import Je from"styled-components";var on=Je.div`
|
|
917
917
|
background-color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorBackground}};
|
|
918
918
|
border: 1px solid;
|
|
919
919
|
border-color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorBorder}};
|
|
@@ -960,7 +960,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
960
960
|
flex-direction: row;
|
|
961
961
|
justify-content: flex-start;
|
|
962
962
|
align-items: center;
|
|
963
|
-
`;var cn=({stepData:e,collapsed:t,onClick:o,onPrimaryButtonClick:i,onSecondaryButtonClick:r,appearance:n,customStepTypes:s})=>{var f,c;let p=t?{}:{transform:"rotate(90deg)"};function d(){return fe.createElement(fe.Fragment,null,e.imageUri||e.videoUri?fe.createElement(rn,{className:l("stepMediaContainer",n)},e.imageUri?fe.createElement(nn,{className:l("stepImage",n),src:e.imageUri,style:e.imageStyle}):null,e.videoUri?fe.createElement(vt,{appearance:n,videoUri:e.videoUri}):null):null,fe.createElement(pn,{className:l("stepSubtitle",n),appearance:n,dangerouslySetInnerHTML:me(e.subtitle)}),fe.createElement(ho,{className:l("checklistCTAContainer",n)},e.secondaryButtonTitle?fe.createElement(ee,{secondary:!0,title:e.secondaryButtonTitle,onClick:()=>r(),appearance:n}):null,fe.createElement(ee,{title:e.primaryButtonTitle??"Continue",onClick:()=>i(),appearance:n})))}function a(){if(!s)return null;let u=s[e.type];return u?u(e,n):null}return fe.createElement(on,{onClick:()=>t?o():null,"data-testid":`step-${e.id}`,className:l("checklistStepContainer",n),appearance:n},fe.createElement(sn,{className:l("stepHeader",n)},fe.createElement(dn,null,fe.createElement(wo,{value:e.complete,style:{width:"auto",borderTop:0},primaryColor:(f=n==null?void 0:n.theme)==null?void 0:f.colorPrimary,appearance:n}),fe.createElement(ln,{appearance:n,className:l("stepTitle",n),dangerouslySetInnerHTML:me(e.title)})),fe.createElement(an,{className:l("stepChevronContainer",n),onClick:()=>o()},fe.createElement(Dt,{style:{...p,transition:"transform 0.1s ease-in-out"},color:(c=n==null?void 0:n.theme)==null?void 0:c.colorTextSecondary}))),fe.createElement(gp,null,!t&&fe.createElement(hp.div,{initial:{opacity:1,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:1,height:0},key:e.id,style:{overflow:"hidden"}},a()??d())))};import
|
|
963
|
+
`;var cn=({stepData:e,collapsed:t,onClick:o,onPrimaryButtonClick:i,onSecondaryButtonClick:r,appearance:n,customStepTypes:s})=>{var f,c;let p=t?{}:{transform:"rotate(90deg)"};function d(){return fe.createElement(fe.Fragment,null,e.imageUri||e.videoUri?fe.createElement(rn,{className:l("stepMediaContainer",n)},e.imageUri?fe.createElement(nn,{className:l("stepImage",n),src:e.imageUri,style:e.imageStyle}):null,e.videoUri?fe.createElement(vt,{appearance:n,videoUri:e.videoUri}):null):null,fe.createElement(pn,{className:l("stepSubtitle",n),appearance:n,dangerouslySetInnerHTML:me(e.subtitle)}),fe.createElement(ho,{className:l("checklistCTAContainer",n)},e.secondaryButtonTitle?fe.createElement(ee,{secondary:!0,title:e.secondaryButtonTitle,onClick:()=>r(),appearance:n}):null,fe.createElement(ee,{title:e.primaryButtonTitle??"Continue",onClick:()=>i(),appearance:n})))}function a(){if(!s)return null;let u=s[e.type];return u?u(e,n):null}return fe.createElement(on,{onClick:()=>t?o():null,"data-testid":`step-${e.id}`,className:l("checklistStepContainer",n),appearance:n},fe.createElement(sn,{className:l("stepHeader",n)},fe.createElement(dn,null,fe.createElement(wo,{value:e.complete,style:{width:"auto",borderTop:0},primaryColor:(f=n==null?void 0:n.theme)==null?void 0:f.colorPrimary,appearance:n}),fe.createElement(ln,{appearance:n,className:l("stepTitle",n),dangerouslySetInnerHTML:me(e.title)})),fe.createElement(an,{className:l("stepChevronContainer",n),onClick:()=>o()},fe.createElement(Dt,{style:{...p,transition:"transform 0.1s ease-in-out"},color:(c=n==null?void 0:n.theme)==null?void 0:c.colorTextSecondary}))),fe.createElement(gp,null,!t&&fe.createElement(hp.div,{initial:{opacity:1,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:1,height:0},key:e.id,style:{overflow:"hidden"}},a()??d())))};import $t from"styled-components";var Zh=$t.div`
|
|
964
964
|
background: #ffffff;
|
|
965
965
|
box-shadow: 0px 6px 25px rgba(0, 0, 0, 0.06);
|
|
966
966
|
border-radius: 6px;
|
|
@@ -974,26 +974,26 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
974
974
|
|
|
975
975
|
max-width: 800px;
|
|
976
976
|
min-width: 350px;
|
|
977
|
-
`,mn
|
|
977
|
+
`,mn=$t.div`
|
|
978
978
|
display: flex;
|
|
979
979
|
flex-direction: column;
|
|
980
|
-
`,un
|
|
980
|
+
`,un=$t.h1`
|
|
981
981
|
color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorText}};
|
|
982
982
|
font-style: normal;
|
|
983
983
|
font-weight: 700;
|
|
984
984
|
font-size: 20px;
|
|
985
985
|
line-height: 24px;
|
|
986
986
|
margin-bottom: 8px;
|
|
987
|
-
`,fn
|
|
987
|
+
`,fn=$t.h2`
|
|
988
988
|
color: ${e=>{var t,o;return(o=(t=e.appearance)==null?void 0:t.theme)==null?void 0:o.colorTextSecondary}};
|
|
989
989
|
font-weight: 400;
|
|
990
990
|
font-size: 14px;
|
|
991
991
|
line-height: 23px;
|
|
992
992
|
margin: 2px 0 0 0;
|
|
993
|
-
`,gn
|
|
993
|
+
`,gn=$t.div`
|
|
994
994
|
display: block;
|
|
995
995
|
width: 100%;
|
|
996
|
-
`,hn
|
|
996
|
+
`,hn=$t.div`
|
|
997
997
|
display: flex;
|
|
998
998
|
width: 100%;
|
|
999
999
|
flex-direction: column;
|
|
@@ -1135,7 +1135,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1135
1135
|
color: ${({theme:e})=>e.colorTextSecondary};
|
|
1136
1136
|
${e=>e.blocked||e.complete?"opacity: 0.4;":`
|
|
1137
1137
|
`}
|
|
1138
|
-
`;var Dn=({stepData:e,style:t={},appearance:o})=>{let{mergeAppearanceWithDefault:i}=Q(),{primaryCTAClickSideEffects:r}=ne(),{theme:n,styleOverrides:s}=i(o),{imageUri:p=null,subtitle:d=null,title:a=null,complete:f=!1,blocked:c=!1}=e,u=()=>{r(e)};return St.createElement(Pn,{className:l("carouselCard",o),onClick:c?null:u,style:t,blocked:c,complete:f},St.createElement("div",{style:{alignItems:"flex-start",display:"flex",justifyContent:"space-between"}},p&&St.createElement(vn,{className:l("carouselCardImage",o),src:p,alt:a,style:{opacity:f||c?.4:1}}),f&&St.createElement(Bn,{className:l("carouselCompletedPill",o)},St.createElement(On,{style:{color:"#108E0B"}},"Complete"))),a&&St.createElement(Ln,{blocked:c,complete:f,className:l("carouselCardTitle",o)},a),d&&St.createElement(We.Quiet,{blocked:c,complete:f,className:l("carouselCardSubtitle",o)},d))};import Rt from"react";var
|
|
1138
|
+
`;var Dn=({stepData:e,style:t={},appearance:o})=>{let{mergeAppearanceWithDefault:i}=Q(),{primaryCTAClickSideEffects:r}=ne(),{theme:n,styleOverrides:s}=i(o),{imageUri:p=null,subtitle:d=null,title:a=null,complete:f=!1,blocked:c=!1}=e,u=()=>{r(e)};return St.createElement(Pn,{className:l("carouselCard",o),onClick:c?null:u,style:t,blocked:c,complete:f},St.createElement("div",{style:{alignItems:"flex-start",display:"flex",justifyContent:"space-between"}},p&&St.createElement(vn,{className:l("carouselCardImage",o),src:p,alt:a,style:{opacity:f||c?.4:1}}),f&&St.createElement(Bn,{className:l("carouselCompletedPill",o)},St.createElement(On,{style:{color:"#108E0B"}},"Complete"))),a&&St.createElement(Ln,{blocked:c,complete:f,className:l("carouselCardTitle",o)},a),d&&St.createElement(We.Quiet,{blocked:c,complete:f,className:l("carouselCardSubtitle",o)},d))};import Rt from"react";var $n=({numberOfStepsCompleted:e,numberOfSteps:t,appearance:o})=>{let i=t>0?e/t:0,r=200,n=Math.min(r,Math.max(10,Math.round(r*i)));return Rt.createElement(An,{className:l("carouselProgressBar",o)},Rt.createElement(In,{as:We.Loud,style:{marginRight:8}},e," of ",t),Rt.createElement("svg",{height:10,width:r},Rt.createElement("rect",{x:0,y:0,rx:5,width:r,height:10,fill:"#E6E6E6"}),Rt.createElement("rect",{x:0,y:0,rx:5,width:n,height:10,fill:"currentColor"})))};var kp=()=>ae.createElement("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},ae.createElement("path",{d:"M14 6L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),ae.createElement("path",{d:"M14 18L20 12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"}),ae.createElement("path",{d:"M4 12H20",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})),Mn=({side:e="left",show:t=!1,onClick:o=()=>{}})=>{let[i,r]=yt(!1),[n,s]=yt(!1);tr(()=>{t===!0&&i===!1?r(!0):t===!1&&i===!0&&s(!0)},[t]);let p=()=>{r(!1),s(!1)},d=e=="left"?{top:0,bottom:0,left:-20,transform:"rotate(180deg)"}:{top:0,bottom:0,right:-20};return i?ae.createElement(Tn,{style:d,reversed:n,onAnimationEnd:n?p:null},ae.createElement(Fn,{onClick:()=>o(),style:{right:16,top:"calc(50% - 24px)"}},ae.createElement(kp,null))):null},Un=({flowId:e,appearance:t,customVariables:o,className:i})=>{let r=Fp(null),[n,s]=yt(!1),[p,d]=yt(!1),[a,f]=yt(null),[c,u]=yt([]),[w,T]=yt(0),{getFlowMetadata:S,getFlowSteps:h,getNumberOfStepsCompleted:E,updateCustomVariables:y,getFlowStatus:A,isLoading:F,targetingLogicShouldHideFlow:x,getFlow:m}=J();tr(()=>{y(o)},[o,F]),tr(()=>{if(F)return;let I=S(e),j=E(e),B=h(e);f(I),I.data!==null&&(u(B.sort((D,re)=>Number(D.complete)-Number(re.complete))),d(B.length>3),T(j))},[F]);let C=[];for(let I=0;I<c.length;I+=3)C.push(c.slice(I,I+3));let P=I=>{let j=I.target,B=j.scrollWidth-j.clientWidth,D=Math.ceil(j.scrollLeft);D>0&&n===!1&&s(!0),D===0&&n===!0&&s(!1),D<B&&p===!1&&d(!0),D===B&&p===!0&&d(!1)},$=(I=!0)=>{let j=I?1:-1;r.current!==null&&r.current.scrollBy({left:r.current.clientWidth*j,behavior:"smooth"})},U=null,M=I=>{U!==null?clearTimeout(U):P(I),U=setTimeout(()=>{P(I)},16)};return F?null:ae.createElement(En,{className:ye(l("carouselContainer",t),i)},ae.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:20}},ae.createElement("div",null,ae.createElement(Nn,{className:l("carouselTitle",t)},a==null?void 0:a.title),ae.createElement(We.Quiet,{className:l("carouselSubtitle",t)},a==null?void 0:a.subtitle)),ae.createElement($n,{numberOfStepsCompleted:w,numberOfSteps:c.length})),ae.createElement("div",{style:{position:"relative"}},ae.createElement(Mn,{show:n,onClick:()=>$(!1)}),ae.createElement(Mn,{side:"right",show:p,onClick:$}),ae.createElement(bn,{ref:r,onScroll:M},C.map((I,j)=>ae.createElement(wn,{key:j,style:{flex:`0 0 calc(100% - ${c.length>3?36:0}px)`}},I.map((B,D)=>ae.createElement(Dn,{key:D,stepData:B,style:{flex:c.length>3?"0 1 calc(33% - 16px * 2 / 3)":1},appearance:t})))))))};var or=({flowId:e,title:t,subtitle:o,style:i,initialSelectedStep:r,className:n,type:s="inline",onDismiss:p,visible:d,customVariables:a,onStepCompletion:f,onButtonClick:c,appearance:u,hideOnFlowCompletion:w,setVisible:T,customStepTypes:S,checklistStyle:h="default",autoExpandFirstIncompleteStep:E,autoExpandNextStep:y,...A})=>{let{getFlow:F,getFlowSteps:x,markStepCompleted:m,getStepStatus:C,getNumberOfStepsCompleted:P,isLoading:$,targetingLogicShouldHideFlow:U,updateCustomVariables:M,getFlowMetadata:I,isStepBlocked:j,getFlowStatus:B,hasActiveFullPageFlow:D,setHasActiveFullPageFlow:re}=J(),{primaryCTAClickSideEffects:R,secondaryCTAClickSideEffects:_}=ne(),{getOpenFlowState:he,setOpenFlowState:Fe}=ve(),[W,se]=Wn(r||0),[G,L]=Wn(!1),te=d===void 0?he(e):d,xe=s==="modal",{mergeAppearanceWithDefault:Ce}=Q(),{isLarge:V}=tn();if(u=Ce(u),_n(()=>{M(a)},[a,$]),_n(()=>{d!==void 0&&(xe&&d===!0?re(!0):xe&&d===!1&&re(!1))},[d,T,D]),$)return null;let de=F(e);if(!de||U(de))return null;let oe=x(e);if(!oe||w===!0&&B(e)===X)return null;let K=I(e);if(K!=null&&K.title&&(t=K.title),K!=null&&K.subtitle&&(o=K.subtitle),!G&&r===void 0&&P(e)>0){let z=Math.min(P(e),oe.length-1);se(z),L(!0)}function je(){if(W+1>=oe.length){xe&&Fe(e,!1);return}j(e,oe[W+1].id)||se(W+1)}function Ge(z,lt,ro){let pr=W+1<oe.length?oe[W+1]:null;c&&c(z,W,lt,pr)===!0&&xe&&g(),f&&f(z,ro,pr),!f&&!c&&(z.primaryButtonUri||z.secondaryButtonUri)&&xe&&g()}function Y(){return oe.map((z,lt)=>({...z,handleSecondaryButtonClick:()=>{je(),_(z),z.skippable===!0&&m(e,z.id,{skipped:!0}),Ge(z,"secondary",lt)},handlePrimaryButtonClick:()=>{(!z.completionCriteria&&(z.autoMarkCompleted||z.autoMarkCompleted===void 0)||z.completionCriteria&&z.autoMarkCompleted===!0)&&(m(e,z.id),je()),Ge(z,"primary",lt),R(z),C(e,z.id)===Oe&&je()}}))}function Se(){return pe.createElement(ie,{appearance:u})}let st={steps:Y(),title:t,subtitle:o,primaryColor:u.theme.colorPrimary,appearance:u,customStepTypes:S,type:s,className:n,autoExpandFirstIncompleteStep:E,autoExpandNextStep:y};function g(){Fe(e,!1),p&&p(),T&&T(!1)}function b(){return pe.createElement(pe.Fragment,null,pe.createElement(Se,null),pe.createElement(Un,{flowId:e,appearance:u,customVariables:a,className:n}))}function v(){return pe.createElement(pe.Fragment,null,pe.createElement(Se,null),pe.createElement(er,{visible:te,onClose:()=>{g()},selectedStep:W,setSelectedStep:se,autoExpandNextStep:!0,appearance:u,...st}))}function H(){if(!V)return v();let z=A.guideFlowId,lt;return z&&F(z)&&(lt=x(z)),pe.createElement(pe.Fragment,null,pe.createElement(Se,null),pe.createElement(Ro,{visible:te,stepsTitle:K.stepsTitle?K.stepsTitle:"Your quick start guide",onClose:()=>{g()},selectedStep:W,setSelectedStep:se,guideData:lt,guideTitle:A.guideTitle??"Guide",appearance:u,title:t,subtitle:o,onGuideButtonClick:ro=>{Ge(ro,"link",0)},customStepTypes:S,...st}))}function ce(){if(!V)return v();let z=pe.createElement(Qo,{flowId:e,style:i,selectedStep:W,setSelectedStep:se,appearance:u,type:s,...st});return xe?pe.createElement(Ze,{onClose:()=>{g()},visible:te,appearance:u,style:{paddingTop:"0px",padding:"12px",paddingLeft:0}},pe.createElement(Se,null),z):pe.createElement(pe.Fragment,null,pe.createElement(Se,null),z)}switch(h){case"condensed":return v();case"with-guide":return H();case"default":return ce();case"carousel":return b();default:return ce()}};var vp=e=>Pp.createElement(or,{type:"inline",...e});import it,{useEffect as Ap}from"react";import ze from"react";import Eo from"styled-components";var zn=Eo.div`
|
|
1139
1139
|
border: 1px solid ${e=>e.appearance.theme.colorBorder};
|
|
1140
1140
|
border-radius: 8px;
|
|
1141
1141
|
padding: 6px 10px 6px 10px;
|
|
@@ -1200,7 +1200,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1200
1200
|
:hover {
|
|
1201
1201
|
opacity: 0.8;
|
|
1202
1202
|
}
|
|
1203
|
-
`;var Jn=({title:e,subtitle:t,icon:o,appearance:i,count:r,total:n,className:s,style:p})=>rt.createElement(rt.Fragment,null,rt.createElement(qn,{appearance:i,className:ye(l("fullWidthProgressBadgeContainer",i),s??""),style:p},o&&rt.createElement(Kn,{className:l("fullWidthProgressBadgeIcon",i)},o),rt.createElement(Yn,null,rt.createElement(be,{size:"small",appearance:i,title:e,subtitle:t})),rt.createElement(Xn,{className:l("fullWidthProgressBadgeProgressContainer",i)},rt.createElement(_e,{count:r,total:n,display:"percent",textLocation:"top",fillColor:i.theme.colorPrimary}))));var Ip=({flowId:e,title:t,subtitle:o,icon:i,style:r,onClick:n,className:s,customVariables:p,hideOnFlowCompletion:d,appearance:a,type:f="default"})=>{let{getFlow:c,getFlowSteps:u,getFlowStatus:w,getNumberOfStepsCompleted:T,isLoading:S,targetingLogicShouldHideFlow:h,updateCustomVariables:E}=J(),{mergeAppearanceWithDefault:y}=Q();a=y(a);let{setOpenFlowState:A,getOpenFlowState:F}=ve();if(Ap(()=>{E(p)},[p,S]),S)return null;let x=c(e);if(!x||h(x)||d===!0&&w(e)===X)return null;let m=u(e),C=T(e);return f==="full-width"?it.createElement(it.Fragment,null,it.createElement(ie,{appearance:a}),it.createElement(Jn,{title:t,subtitle:o,count:C,total:m.length,style:r,className:s,appearance:a,icon:i,onClick:()=>{}})):it.createElement(it.Fragment,null,it.createElement(ie,{appearance:a}),it.createElement(Vn,{count:C,total:m.length,title:t,style:r,onClick:()=>{A(e,!0),n&&n()},type:f,className:s,appearance:a}))};import Bp from"react";var Np=({flowId:e,style:t,appearance:o,...i})=>{let{getFlow:r,targetingLogicShouldHideFlow:n,getFlowSteps:s}=J(),{mergeAppearanceWithDefault:p}=Q();o=p(o);let d=r(e);if(!d||n(d))return null;let a=s(e);return Bp.createElement(Zt,{steps:a,style:t,appearance:o,...i})};import Ut,{useContext as Gp,useEffect as Vp}from"react";import O,{useEffect as Ao,useLayoutEffect as ls,useRef as
|
|
1203
|
+
`;var Jn=({title:e,subtitle:t,icon:o,appearance:i,count:r,total:n,className:s,style:p})=>rt.createElement(rt.Fragment,null,rt.createElement(qn,{appearance:i,className:ye(l("fullWidthProgressBadgeContainer",i),s??""),style:p},o&&rt.createElement(Kn,{className:l("fullWidthProgressBadgeIcon",i)},o),rt.createElement(Yn,null,rt.createElement(be,{size:"small",appearance:i,title:e,subtitle:t})),rt.createElement(Xn,{className:l("fullWidthProgressBadgeProgressContainer",i)},rt.createElement(_e,{count:r,total:n,display:"percent",textLocation:"top",fillColor:i.theme.colorPrimary}))));var Ip=({flowId:e,title:t,subtitle:o,icon:i,style:r,onClick:n,className:s,customVariables:p,hideOnFlowCompletion:d,appearance:a,type:f="default"})=>{let{getFlow:c,getFlowSteps:u,getFlowStatus:w,getNumberOfStepsCompleted:T,isLoading:S,targetingLogicShouldHideFlow:h,updateCustomVariables:E}=J(),{mergeAppearanceWithDefault:y}=Q();a=y(a);let{setOpenFlowState:A,getOpenFlowState:F}=ve();if(Ap(()=>{E(p)},[p,S]),S)return null;let x=c(e);if(!x||h(x)||d===!0&&w(e)===X)return null;let m=u(e),C=T(e);return f==="full-width"?it.createElement(it.Fragment,null,it.createElement(ie,{appearance:a}),it.createElement(Jn,{title:t,subtitle:o,count:C,total:m.length,style:r,className:s,appearance:a,icon:i,onClick:()=>{}})):it.createElement(it.Fragment,null,it.createElement(ie,{appearance:a}),it.createElement(Vn,{count:C,total:m.length,title:t,style:r,onClick:()=>{A(e,!0),n&&n()},type:f,className:s,appearance:a}))};import Bp from"react";var Np=({flowId:e,style:t,appearance:o,...i})=>{let{getFlow:r,targetingLogicShouldHideFlow:n,getFlowSteps:s}=J(),{mergeAppearanceWithDefault:p}=Q();o=p(o);let d=r(e);if(!d||n(d))return null;let a=s(e);return Bp.createElement(Zt,{steps:a,style:t,appearance:o,...i})};import Ut,{useContext as Gp,useEffect as Vp}from"react";import O,{useEffect as Ao,useLayoutEffect as ls,useRef as Mp,useState as to}from"react";import oo from"styled-components";import{useCallback as Lp,useEffect as Op,useState as Dp}from"react";var rr=(e,t,o,i={x:20,y:20},r)=>{let n=r=="fixed"?0:window.scrollY,s=r=="fixed"?0:window.scrollX;return!e||!e.left||!e.top?{x:0,y:0}:t==="left"?{x:e.left-o+i.x+s,y:e.top-i.y+n}:t==="right"?{x:e.left+e.width+i.x+s,y:e.top-i.y+n}:{x:0,y:0}},Qn={bottom:0,height:0,left:0,right:0,top:0,width:0,x:0,y:0};function $p(e){let t=Qn;return e&&(t=e.getBoundingClientRect()),t}function Zn(e,t){let[o,i]=Dp(Qn),r=Lp(()=>{e&&i($p(e))},[e]);return Op(()=>(r(),window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)),[e,t]),o}import nt from"styled-components";var Rn=nt.div`
|
|
1204
1204
|
${e=>k(e)} {
|
|
1205
1205
|
background: ${e=>e.appearance.theme.colorBackground};
|
|
1206
1206
|
}
|
|
@@ -1266,7 +1266,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1266
1266
|
color: #808080;
|
|
1267
1267
|
}
|
|
1268
1268
|
margin: 0;
|
|
1269
|
-
`;var as=300,ps=100,Up=500
|
|
1269
|
+
`;var as=300,ps=100,Up=500,Mt=12,_p=oo.div`
|
|
1270
1270
|
width: 100%;
|
|
1271
1271
|
height: 100%;
|
|
1272
1272
|
border-radius: 9999px;
|
|
@@ -1290,8 +1290,8 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
1292
|
`,Wp=oo.div`
|
|
1293
|
-
width: ${
|
|
1294
|
-
height: ${
|
|
1293
|
+
width: ${Mt}px;
|
|
1294
|
+
height: ${Mt}px;
|
|
1295
1295
|
border-radius: 100px;
|
|
1296
1296
|
background-color: ${e=>e.primaryColor};
|
|
1297
1297
|
z-index: 20;
|
|
@@ -1305,9 +1305,9 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1305
1305
|
align-items: center;
|
|
1306
1306
|
z-index: ${e=>e.zIndex?e.zIndex:90};
|
|
1307
1307
|
`,Hp=oo(ds)`
|
|
1308
|
-
width: ${
|
|
1309
|
-
height: ${
|
|
1310
|
-
`,jp=({steps:e=[],onDismiss:t,onComplete:o=()=>{},tooltipPosition:i="auto",showHighlight:r=!0,primaryColor:n="#000000",offset:s={x:0,y:0},visible:p=!0,containerStyle:d={},selectedStep:a=0,customStepTypes:f,appearance:c,dismissible:u=!1,showHighlightOnly:w,showStepCount:T=!0,completedStepsCount:S=0})=>{var oe,K,je,Ge;let[h,E]=to(),[y,A]=to(new Date),F
|
|
1308
|
+
width: ${Mt+12}px;
|
|
1309
|
+
height: ${Mt+12}px;
|
|
1310
|
+
`,jp=({steps:e=[],onDismiss:t,onComplete:o=()=>{},tooltipPosition:i="auto",showHighlight:r=!0,primaryColor:n="#000000",offset:s={x:0,y:0},visible:p=!0,containerStyle:d={},selectedStep:a=0,customStepTypes:f,appearance:c,dismissible:u=!1,showHighlightOnly:w,showStepCount:T=!0,completedStepsCount:S=0})=>{var oe,K,je,Ge;let[h,E]=to(),[y,A]=to(new Date),F=Mp(null),[x,m]=to(document.querySelector(e[a].selector)),C=Zn(x,y),[P,$]=to(),[U,M]=to(!w),I=(K=(oe=e[a])==null?void 0:oe.props)!=null&&K.position?e[a].props.position:"absolute",j=((Ge=(je=e[a])==null?void 0:je.props)==null?void 0:Ge.zIndex)??90,B=(h==null?void 0:h.width)??as,D=(h==null?void 0:h.height)??ps;ls(()=>{F.current&&E({width:F.current.clientWidth,height:F.current.clientHeight})},[a,y,I]),Ao(()=>{w||M(!0)},[a]);let re=i==="auto"?"right":i,R=rr(C,re,B,s,I),_=C.right+B>(window.innerWidth||document.documentElement.clientWidth),he=C.bottom+ps>(window.innerHeight||document.documentElement.clientHeight);_&&i==="auto"&&(R=rr(C,"left",B,s,I),re="left");let Fe=window.location.pathname.split("/").pop(),W=()=>{let Y=document.querySelector(e[a].selector);P&&P===JSON.stringify(Y==null?void 0:Y.getBoundingClientRect())||(m(Y),A(new Date),Y&&$(JSON.stringify(Y.getBoundingClientRect())))};if(Ao(()=>{let Y=new MutationObserver(W);return Y.observe(document.body,{subtree:!0,childList:!0}),()=>Y.disconnect()},[W]),Ao(()=>{let Y=new MutationObserver(W);return Y.observe(document.body,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["style","class"]}),()=>Y.disconnect()},[W]),Ao(()=>{let Y=setInterval(()=>{W()},10);return()=>clearInterval(Y)},[W]),ls(()=>{setTimeout(()=>{W()},Up),W()},[a,Fe]),x===null)return O.createElement(O.Fragment,null);if(R.x==0&&R.y==0)return O.createElement(O.Fragment,null);if(!p)return O.createElement(O.Fragment,null);let se=()=>{let Y=()=>{if(e[a].handlePrimaryButtonClick&&(e[a].handlePrimaryButtonClick(),M(!1),setTimeout(()=>{W()},30)),S===e.length-1)return o()},Se=()=>{e[a].handleSecondaryButtonClick&&(e[a].handleSecondaryButtonClick(),w&&M(!1))};return O.createElement(O.Fragment,null,T&&O.createElement(is,null,O.createElement(ss,{className:l("tooltipStepCounter",c)},a+1," of ",e.length)),O.createElement(ns,{showStepCount:T,className:l("tooltipCTAContainer",c)},e[a].secondaryButtonTitle&&O.createElement(ee,{title:e[a].secondaryButtonTitle,appearance:c,onClick:Se,size:"small",withMargin:!1,secondary:!0}),e[a].primaryButtonTitle&&O.createElement(ee,{title:e[a].primaryButtonTitle,appearance:c,onClick:Y,withMargin:!1,size:"small"})))},G=()=>O.createElement(O.Fragment,null,u&&O.createElement(es,{"data-testid":"tooltip-dismiss",onClick:()=>{t&&t()},className:l("tooltipClose",c)},O.createElement(Ee,null)),e[a].imageUri&&O.createElement(ts,{dismissible:u,appearance:c,src:e[a].imageUri,className:l("tooltipImageContainer",c)}),e[a].videoUri&&!e[a].imageUri&&O.createElement(os,{dismissible:u,appearance:c,className:l("tooltipVideoContainer",c)},O.createElement(vt,{appearance:c,videoUri:e[a].videoUri})),O.createElement(be,{appearance:c,title:e[a].title,subtitle:e[a].subtitle,size:"small"}),O.createElement(rs,{className:l("tooltipFooter",c)},O.createElement(se,null))),te={...{default:Y=>{var Se;if((Se=e[a])!=null&&Se.StepContent){let st=e[a].StepContent;return O.createElement("div",null,st)}return O.createElement(G,null)}},...f},xe=()=>{var Y;return e?!((Y=e[a])!=null&&Y.type)||!te[e[a].type]?te.default(e[a]):te[e[a].type]({stepData:e[a],primaryColor:n}):O.createElement(O.Fragment,null)};if(w&&e[a].complete===!0)return null;let Ce={top:(R==null?void 0:R.y)-Mt,left:(re=="left"?C.x+s.x:(R==null?void 0:R.x)-Mt)??0,cursor:w?"pointer":"default",position:I},V=()=>{let Se=Ce.left+(re=="left"?-B:24);return Math.min(Math.max(Se,20),window.innerWidth-B-20)},de=()=>{w&&(A(new Date),M(!U))};return O.createElement(zp,null,O.createElement(Hp,{style:Ce,zIndex:j,className:l("tourHighlightContainer",c)},r&&e[a].showHighlight!==!1&&O.createElement(O.Fragment,null,O.createElement(Wp,{style:{position:I},onClick:de,primaryColor:c.theme.colorPrimary}),O.createElement(_p,{style:{position:"absolute"},onClick:de,primaryColor:c.theme.colorPrimary}))),O.createElement(ds,{style:{...Ce,left:V()},zIndex:j+1,className:l("tooltipContainerWrapper",c)},U&&O.createElement(Rn,{ref:F,layoutId:"tooltip-container",style:{position:"relative",width:"max-content",right:0,top:12,...d},appearance:c,className:l("tooltipContainer",c),maxWidth:as,zIndex:j+10},O.createElement(xe,null))))},Io=jp;import{Portal as qp}from"react-portal";var Kp=({flowId:e,customVariables:t,appearance:o,onStepCompletion:i,onButtonClick:r,showTooltipsSimultaneously:n=!1,onDismiss:s,dismissible:p,tooltipPosition:d="auto",showHighlightOnly:a=!1,dismissBehavior:f="complete-flow",onComplete:c,...u})=>{let{getFlow:w,getFlowSteps:T,isLoading:S,targetingLogicShouldHideFlow:h,markStepCompleted:E,markStepStarted:y,markFlowCompleted:A,updateCustomVariables:F,getCurrentStepIndex:x,getStepStatus:m,isStepBlocked:C,getFlowStatus:P,getNumberOfStepsCompleted:$}=J(),{isLoadingUserFlowStateData:U}=Be(),{primaryCTAClickSideEffects:M,secondaryCTAClickSideEffects:I}=ne(),{hasOpenModals:j}=ve(),B=x(e),{openFlowStates:D}=Gp(q),{mergeAppearanceWithDefault:re}=Q();if(o=re(o),Vp(()=>{F(t)},[t,S]),U)return null;let R=w(e);if(!R||h(R)||P(e)==X||j())return null;let _=T(e);if(Object.keys(D).length>0){let L=Object.keys(D).find(te=>D[te]===!0);if(L!==void 0&&L!==e)return Ut.createElement(Ut.Fragment,null)}async function he(L){if(await E(e,L.id),_.map(te=>m(e,te.id)).every(te=>te===Oe)){await A(e);return}if(!a&&B+1<_.length){if(C(e,_[B+1].id))return;await y(e,_[B+1].id)}}function Fe(L,te,xe){let Ce=B+1<_.length?_[B+1]:null;r&&r(L,B,te,Ce),i&&i(L,xe,Ce)}function W(){return _.map(L=>({...L,handleSecondaryButtonClick:async()=>{I(L),L.skippable===!0&&await E(e,L.id,{skipped:!0}),Fe(L,"secondary",B)},handlePrimaryButtonClick:async()=>{(!L.completionCriteria&&(L.autoMarkCompleted||L.autoMarkCompleted===void 0)||L.completionCriteria&&L.autoMarkCompleted===!0)&&await he(L),Fe(L,"primary",B),M(L)}}))}async function se(L){s&&s(),f==="complete-flow"?await A(e):await E(e,L.id)}function G(){c&&c()}return Ut.createElement(qp,null,Ut.createElement(ie,{appearance:o}),n?_.map((L,te)=>Ut.createElement(Io,{key:L.id,appearance:o,steps:W(),selectedStep:te,showTooltipsSimultaneously:n,dismissible:p,onDismiss:()=>se(L),tooltipPosition:d,showHighlightOnly:a,completedStepsCount:$(e),onComplete:G,...u})):Ut.createElement(Io,{appearance:o,steps:W(),selectedStep:B,showTooltipsSimultaneously:n,dismissible:p,onDismiss:()=>se(_[B]),tooltipPosition:d,completedStepsCount:$(e),showHighlightOnly:a,onComplete:G,...u}))};import Te,{useEffect as Yp,useRef as Xp,useState as Jp}from"react";import{Portal as Qp}from"react-portal";import bt from"styled-components";var cs=bt.button`
|
|
1311
1311
|
${e=>k(e)} {
|
|
1312
1312
|
// Anything inside this block will be ignored if the user provides a custom class
|
|
1313
1313
|
|
|
@@ -1395,7 +1395,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1395
1395
|
font-size: 14px;
|
|
1396
1396
|
|
|
1397
1397
|
padding: 8px 12px;
|
|
1398
|
-
`;import{AnimatePresence as ws,motion as Ts}from"framer-motion";import Cs from"react";var Ss=({style:e,className:t})=>Cs.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 18 18",style:e,className:t},Cs.createElement("path",{fill:"currentColor",d:"M13.43 4.938a4.494 4.494 0 00-1.043-1.435A4.955 4.955 0 009 2.197c-1.276 0-2.48.464-3.387 1.305A4.502 4.502 0 004.57 4.938a4.242 4.242 0 00-.386 1.773v.475c0 .109.087.197.196.197h.95a.197.197 0 00.197-.197V6.71c0-1.749 1.557-3.17 3.473-3.17s3.473 1.421 3.473 3.17c0 .718-.254 1.393-.738 1.955a3.537 3.537 0 01-1.9 1.125 1.928 1.928 0 00-1.085.682c-.271.343-.42.768-.42 1.206v.552c0 .109.088.197.197.197h.95a.197.197 0 00.196-.197v-.552c0-.276.192-.519.457-.578a4.904 4.904 0 002.625-1.56c.335-.392.597-.828.778-1.3a4.256 4.256 0 00-.103-3.303zM9 13.834a.985.985 0 10.001 1.97.985.985 0 00-.001-1.97z"}));import ys from"react";var bs=({style:e,className:t})=>ys.createElement("svg",{style:e,className:t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},ys.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"}));var Zp=({flowId:e,style:t,onStepCompletion:o,visible:i=!0,type:r="inline",title:n="Help",appearance:s})=>{let{getFlow:p,getFlowSteps:d,markStepCompleted:a,getStepStatus:f,getNumberOfStepsCompleted:c,isLoading:u,targetingLogicShouldHideFlow:w}=J(),{primaryCTAClickSideEffects:T}=ne(),S=Xp(null),[h,E]=Jp(!1),{mergeAppearanceWithDefault:y}=Q();s=y(s),Yp(()=>(document.addEventListener("click",A,!1),()=>{document.removeEventListener("click",A,!1)}),[]);let A=P=>{S.current&&!S.current.contains(P.target)&&E(!1)};if(u)return null;let F=p(e);if(!F||w(F))return null;let x=d(e);if(!x||!i)return null;function m(P
|
|
1398
|
+
`;import{AnimatePresence as ws,motion as Ts}from"framer-motion";import Cs from"react";var Ss=({style:e,className:t})=>Cs.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",fill:"none",viewBox:"0 0 18 18",style:e,className:t},Cs.createElement("path",{fill:"currentColor",d:"M13.43 4.938a4.494 4.494 0 00-1.043-1.435A4.955 4.955 0 009 2.197c-1.276 0-2.48.464-3.387 1.305A4.502 4.502 0 004.57 4.938a4.242 4.242 0 00-.386 1.773v.475c0 .109.087.197.196.197h.95a.197.197 0 00.197-.197V6.71c0-1.749 1.557-3.17 3.473-3.17s3.473 1.421 3.473 3.17c0 .718-.254 1.393-.738 1.955a3.537 3.537 0 01-1.9 1.125 1.928 1.928 0 00-1.085.682c-.271.343-.42.768-.42 1.206v.552c0 .109.088.197.197.197h.95a.197.197 0 00.196-.197v-.552c0-.276.192-.519.457-.578a4.904 4.904 0 002.625-1.56c.335-.392.597-.828.778-1.3a4.256 4.256 0 00-.103-3.303zM9 13.834a.985.985 0 10.001 1.97.985.985 0 00-.001-1.97z"}));import ys from"react";var bs=({style:e,className:t})=>ys.createElement("svg",{style:e,className:t,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},ys.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z"}));var Zp=({flowId:e,style:t,onStepCompletion:o,visible:i=!0,type:r="inline",title:n="Help",appearance:s})=>{let{getFlow:p,getFlowSteps:d,markStepCompleted:a,getStepStatus:f,getNumberOfStepsCompleted:c,isLoading:u,targetingLogicShouldHideFlow:w}=J(),{primaryCTAClickSideEffects:T}=ne(),S=Xp(null),[h,E]=Jp(!1),{mergeAppearanceWithDefault:y}=Q();s=y(s),Yp(()=>(document.addEventListener("click",A,!1),()=>{document.removeEventListener("click",A,!1)}),[]);let A=P=>{S.current&&!S.current.contains(P.target)&&E(!1)};if(u)return null;let F=p(e);if(!F||w(F))return null;let x=d(e);if(!x||!i)return null;function m(P,$){!P.completionCriteria&&(P.autoMarkCompleted||P.autoMarkCompleted===void 0)&&a(e,P.id),T(P),o&&o(P,$),E(!1)}function C(){return h&&Te.createElement(hs,{className:l("floatingWidgetMenu",s),as:Ts.div,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.1},type:r},x.map((P,$)=>Te.createElement(xs,{className:l("floatingWidgetMenuItem",s),key:$,onClick:()=>m(P,$)},P.title)))}return r=="inline"?Te.createElement("span",{ref:S},Te.createElement(cs,{style:t,onClick:()=>{E(!h)},className:l("supportButton",s)},Te.createElement(us,{className:l("supportIconContainer",s)},Te.createElement(bs,{className:l("supportIcon",s),style:{width:"18px",height:"18px"}})),Te.createElement(ms,{className:l("supportButtonTitle",s)},n)),Te.createElement(ws,null,Te.createElement(C,null))):Te.createElement(Qp,null,Te.createElement(fs,{style:t,ref:S},Te.createElement(ws,null,Te.createElement(C,null)),Te.createElement(gs,{onClick:()=>{E(!h)},as:Ts.button,whileHover:{scale:1.1},className:l("floatingWidgetButton",s)},Te.createElement(Ss,{className:l("floatingWidgetButtonIcon",s),style:{display:"flex",width:"20px",height:"20px"}}))))};import He,{useEffect as Rp}from"react";import Bo from"styled-components";var Fs=Bo.div`
|
|
1399
1399
|
${e=>k(e)} {
|
|
1400
1400
|
display: flex;
|
|
1401
1401
|
flex-direction: column;
|
|
@@ -1523,7 +1523,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1523
1523
|
justify-content: flex-end;
|
|
1524
1524
|
margin-top: 24px;
|
|
1525
1525
|
gap: 8px;
|
|
1526
|
-
|
|
1526
|
+
`,$s=Qe.div`
|
|
1527
1527
|
display: flex;
|
|
1528
1528
|
justify-content: space-between;
|
|
1529
1529
|
margin-top: 24px;
|
|
@@ -1541,7 +1541,7 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1541
1541
|
justify-content: center;
|
|
1542
1542
|
align-items: flex-start;
|
|
1543
1543
|
margin-top: 16px;
|
|
1544
|
-
|
|
1544
|
+
`,Ms=Qe.textarea`
|
|
1545
1545
|
${e=>k(e)} {
|
|
1546
1546
|
margin-top: 16px;
|
|
1547
1547
|
border: 1px solid ${e=>e.appearance.theme.colorBorder};
|
|
@@ -1563,5 +1563,5 @@ ${i=>i.inlineStyles.map(([r,n])=>`.${Ht}${r}.${Ht}${r} { ${Object.entries(n).map
|
|
|
1563
1563
|
opacity: 0.8;
|
|
1564
1564
|
}
|
|
1565
1565
|
}
|
|
1566
|
-
`;var nd=({flowId:e,onDismiss:t,customVariables:o,onButtonClick:i,appearance:r,className:n,style:s})=>{let{getFlow:p,markFlowCompleted:d,markStepCompleted:a,getNumberOfStepsCompleted:f,isLoading:c,targetingLogicShouldHideFlow:u,updateCustomVariables:w,getFlowSteps:T,getFlowStatus:S,getCurrentStepIndex:h}=J(),{primaryCTAClickSideEffects:E}=ne(),{mergeAppearanceWithDefault:y}=Q(),[A,F]=Z.useState(null),[x,m]=Z.useState(""),{hasOpenModals:C,setKeepCompletedFlowOpenDuringSession:P,shouldKeepCompletedFlowOpenDuringSession
|
|
1566
|
+
`;var nd=({flowId:e,onDismiss:t,customVariables:o,onButtonClick:i,appearance:r,className:n,style:s})=>{let{getFlow:p,markFlowCompleted:d,markStepCompleted:a,getNumberOfStepsCompleted:f,isLoading:c,targetingLogicShouldHideFlow:u,updateCustomVariables:w,getFlowSteps:T,getFlowStatus:S,getCurrentStepIndex:h}=J(),{primaryCTAClickSideEffects:E}=ne(),{mergeAppearanceWithDefault:y}=Q(),[A,F]=Z.useState(null),[x,m]=Z.useState(""),{hasOpenModals:C,setKeepCompletedFlowOpenDuringSession:P,shouldKeepCompletedFlowOpenDuringSession:$}=ve();if(r=y(r),rd(()=>{w(o)},[o,c]),c)return null;let U=p(e);if(!U||u(U)||S(e)===X||f(e)===1&&!$(e)||C())return null;let I=T(e)[h(e)];function j(){return Z.createElement(Z.Fragment,null,Z.createElement(ar,null,Z.createElement(be,{size:"large",appearance:r,title:I.title,subtitle:I.subtitle})),Z.createElement(sr,{className:l("npsNumberButtonContainer",r),appearance:r},Array.from(Array(10).keys()).map(D=>Z.createElement(Ds,{className:l("npsNumberButton",r),selected:A===D+1,key:D,onClick:async()=>{P(e),F(D+1),await a(e,I.id,{score:D+1})},appearance:r},D+1))),Z.createElement($s,{appearance:r},Z.createElement(lr,{appearance:r},"Not likely at all"),Z.createElement(lr,{appearance:r},"Extremely likely")))}function B(){return Z.createElement(Z.Fragment,null,Z.createElement(ar,null,Z.createElement(be,{appearance:r,title:"Why did you choose this score?",size:"large"})),Z.createElement(Ms,{appearance:r,value:x,onChange:D=>{m(D.target.value)},placeHolder:"Add your optional fedback here..."}),Z.createElement(sr,{appearance:r,className:l("npsNumberButtonContainer",r)},Z.createElement(ee,{size:"large",withMargin:!1,onClick:async()=>{await d(e),i&&i(I,1,"primary")},appearance:r,title:I.secondaryButtonTitle||"Skip",secondary:!0}),Z.createElement(ee,{size:"large",withMargin:!1,onClick:async()=>{await a(e,I.id,{feedbackText:x}),await d(e),i&&i(I,1,"primary")},appearance:r,title:I.primaryButtonTitle||"Submit"})))}return Z.createElement(id,null,Z.createElement(ie,{appearance:r}),Z.createElement(Os,{appearance:r,className:ye(l("npsSurveyContainer",r),n),style:s},Z.createElement(Us,{onClick:async()=>{await d(e),t&&t()},className:l("npsSurveyDismissButton",r)},Z.createElement(Ee,null)),f(e)==0&&j(),f(e)==1&&B()))};export{ut as CheckBox,et as FormLabel,od as FrigadeBanner,or as FrigadeChecklist,ed as FrigadeEmbeddedTip,ri as FrigadeForm,Np as FrigadeGuide,vp as FrigadeHeroChecklist,nd as FrigadeNPSSurvey,Ip as FrigadeProgressBadge,Aa as FrigadeProvider,Zp as FrigadeSupportWidget,Kp as FrigadeTour,At as ProgressRing,ve as useFlowOpens,zt as useFlowResponses,J as useFlows,qo as useOrganization,Lo as useUser};
|
|
1567
1567
|
//# sourceMappingURL=index.mjs.map
|