@frigade/react 2.7.3 → 2.7.4
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -95,7 +95,7 @@ var ft=Object.defineProperty,gn=Object.defineProperties;var yn=Object.getOwnProp
|
|
|
95
95
|
to {
|
|
96
96
|
opacity: 1;
|
|
97
97
|
}
|
|
98
|
-
`;function go(w){var B=w,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:i,handleDismiss:l,lockScroll:s,modal:d,onPrimary:u,onSecondary:m,part:f,side:g,sideOffset:C,spotlight:T,step:h}=B,S=y(B,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","lockScroll","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var Z,Y,Q,U,ee;let{handlePrimary:E,handleSecondary:b}=ye(h,{onPrimary:u,onSecondary:m}),{videoProps:k,otherProps:v}=ce(S),I=(Y=(Z=h.primaryButton)==null?void 0:Z.title)!=null?Y:h.primaryButtonTitle,H=(U=(Q=h.secondaryButton)==null?void 0:Q.title)!=null?U:h.secondaryButtonTitle,J=!!h.$state.blocked;return jsxRuntime.jsx(qo,p(a({align:e,alignOffset:o,anchor:h.selector,autoScroll:t,"data-step-id":h.id,defaultOpen:r,lockScroll:s,modal:d,part:f,side:g,sideOffset:C,spotlight:T,onMount:()=>{r&&!J&&(h==null||h.start());}},v),{children:jsxRuntime.jsxs(P,{animation:`${Ua} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(P.Media,a({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(ee=h.videoUri)!=null?ee:h.imageUri,transform:"translate3d(0, 0, 1px)",type:h.videoUri?"video":"image"},k)),jsxRuntime.jsx(P.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:l,subtitle:h.subtitle,title:h.title}),jsxRuntime.jsxs(P.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Oe,{current:i.getCurrentStepOrder()+1,marginRight:"auto",total:i.getNumberOfAvailableSteps()}),jsxRuntime.jsx(P.Secondary,{disabled:J,onClick:b,title:H}),jsxRuntime.jsx(P.Primary,{disabled:J,onClick:E,title:I})]})]})}))}function zr(n){var i=n,{children:e,container:o,flowId:t}=i,r=y(i,["children","container","flowId"]);return jsxRuntime.jsx(Tr,{container:o,children:jsxRuntime.jsx(x,p(a({"data-flow-id":t,part:"tour"},r),{children:e}))})}function yo(r){var n=r,{as:e,flowId:o}=n,t=y(n,["as","flowId"]);let{onDismiss:i,onPrimary:l,onSecondary:s}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o,autoStart:!1},t),{children:({flow:d,handleDismiss:u,parentProps:m,step:f})=>{var de;let ne=m.containerProps,{align:g="after",alignOffset:C=0,autoScroll:T=!1,container:h="body",defaultOpen:S,lockScroll:w=!0,modal:B,onOpenChange:E,open:b,part:k,sequential:v=!0,side:I="bottom",sideOffset:H=0,spotlight:J,zIndex:Z=9999}=ne,Y=y(ne,["align","alignOffset","autoScroll","container","defaultOpen","lockScroll","modal","onOpenChange","open","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:Q}=m,U=a({align:g,alignOffset:C,autoScroll:T,dismissible:Q,flow:d,handleDismiss:u,modal:B,onPrimary:l,onSecondary:s,onOpenChange:E,open:b,part:k,side:I,sideOffset:H,spotlight:J,step:f,zIndex:Z},(de=f.props)!=null?de:{});if(v)return jsxRuntime.jsx(zr,p(a({as:e,container:h,flowId:o,part:"tour",zIndex:Z},Y),{children:jsxRuntime.jsx(go,a({defaultOpen:S!=null?S:!0,lockScroll:w},U),f.id)}));let ee=Array.from(d.steps.values()).filter(N=>{let{blocked:_,completed:G,skipped:oe,visible:K}=N.$state;return !_&&!G&&!oe&&K}).map(N=>{var ae,ie,dt,ct;function _(ut){return A(this,null,function*(){return (yield i==null?void 0:i(d,ut))===!1?(ut.preventDefault(),!1):(N.skip(),!0)})}let G=J&&N.id===f.id,oe=(ie=(ae=N.props)==null?void 0:ae.zIndex)!=null?ie:Z,K=a({align:g,alignOffset:C,dismissible:Q,flow:d,handleDismiss:_,onPrimary:l,onSecondary:s,onOpenChange:E,open:b,part:k,side:I,sideOffset:H,spotlight:J,zIndex:oe},(dt=N.props)!=null?dt:{});return jsxRuntime.jsx(go,a({css:{"&:has([aria-expanded=true])":{zIndex:Number(oe)+2},".fr-overlay":{zIndex:Number(oe)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(ct=S||G)!=null?ct:!1,lockScroll:w,step:N},K),`${N.id}-${G}`)});return jsxRuntime.jsx(zr,p(a({as:e,container:h,flowId:o,part:"tour",zIndex:Z},Y),{children:ee}))}}))}var xo="useSyncExternalStore"in Do__namespace?Do__namespace.useSyncExternalStore:Ur__namespace.useSyncExternalStore;function ho(){let{frigade:e}=Do.useContext(M),[,o]=Do.useState(!1),t=Do.useRef(),r=Do.useCallback(l=>{e==null||e.getCollections().then(()=>{l();});let s=()=>{clearTimeout(t.current),t.current=setTimeout(()=>{o(d=>!d),l();},0);};return e==null||e.on("flow.any",s),()=>{e==null||e.off("flow.any",s);};},[e]),n=()=>{let l;try{l=e==null?void 0:e.getCollectionsSync();}catch(s){}return l};return {collections:xo(r,n,n)}}function bo(e){var s,d,u,m;let{frigade:o}=Do.useContext(M),{collections:t}=ho(),r=t==null?void 0:t.get(e),i=(m=((u=(d=(s=t==null?void 0:t.get(e))==null?void 0:s.flows)==null?void 0:d.filter(f=>f.visible).map(f=>p(a({},f),{flow:o==null?void 0:o.getFlowSync(f.flowId)})))!=null?u:[]).find(({flow:f})=>f.isVisible))==null?void 0:m.flowId,{flow:l}=Te(i);return Do.useEffect(()=>{o==null||o.registerCollection(e);},[e,o]),{collection:r,currentFlow:l}}function Yo(n){var i=n,{collectionId:e,part:o,variables:t={}}=i,r=y(i,["collectionId","part","variables"]);var u,m,f;let l={ANNOUNCEMENT:Qo,BANNER:Io,CARD:P,CHECKLIST:no,EMBEDDED_TIP:P,FORM:Ve,NPS_SURVEY:Ke,SURVEY:Ke,TOUR:yo},{currentFlow:s}=bo(e),d=(m=l[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?m:null;return s==null||d==null?null:((f=s==null?void 0:s.rawData)==null?void 0:f.flowType)===js.FlowType.FORM?jsxRuntime.jsx(x,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(Ve,{flowId:s.id,as:$,variables:t},s.id)})):jsxRuntime.jsx(x,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function Gr(){var t,r;let{collections:e}=ho(),o=(r=Array.from((t=e==null?void 0:e.entries())!=null?t:[]).find(n=>n[1].collectionType==="DEFAULT"))==null?void 0:r[0];return bo(o),o==null?null:jsxRuntime.jsx(Yo,{as:null,collectionId:o})}var M=Do.createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});var be=(e,o="log")=>{let t=`__frigade_logged_${e}`;globalThis[t]||(globalThis[t]=!0,console[o](e));};function et(){let e=Do.useContext(M);(!e||!e.frigade)&&be("useFrigade() must be used in a child of the Frigade Provider","warn");let{frigade:o}=e;return {frigade:o,isLoading:!(o!=null&&o.isReady())}}function Kr(){let{frigade:e}=et();return Do.useEffect(()=>{A(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[e]),null}var jr="2.7.3";function Yr(l){var s=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=s,i=y(s,["children","css","defaultCollection","navigate","theme"]);let d=n?To(n):{},u=Do.useRef(new Map),m=Do.useRef(),[f,g]=Do.useState(!1),[C,T]=Do.useState(null),h=Do.useMemo(()=>(g(!1),m.current=void 0,new js.Frigade(i.apiKey,{apiKey:i.apiKey,apiUrl:i.apiUrl,userId:i.userId,groupId:i.groupId,userProperties:i.userProperties,groupProperties:i.groupProperties,generateGuestId:i.generateGuestId,syncOnWindowUpdates:i.syncOnWindowUpdates,__readOnly:i.__readOnly,__flowStateOverrides:i.__flowStateOverrides,__platformVersion:jr,__platformName:"React"})),[i.userId,i.groupId,i.apiKey]);Do.useEffect(()=>{if(i.__flowStateOverrides){let b=h.getConfig();b.__flowStateOverrides=i.__flowStateOverrides,h.reload(b);}},[h,i.__flowStateOverrides]);function S(){let b=[...u.current.entries()].map(([k,v])=>[k,v.callback]);h.batchRegister(b),g(!0);}function w(b,k){if(m.current&&clearTimeout(m.current),f){u.current.has(b)?h.getFlow(b).then(v=>k(v.isVisible)):(h.getFlow(b).then(v=>v.register(k)),u.current.set(b,{callback:k}));return}u.current.has(b)||u.current.set(b,{callback:k}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>S(),0);}function B(b){u.current.has(b)&&h.getFlow(b).then(k=>{u.current.delete(b),k==null||k.unregister();});}let E=r!=null?r:(b,k="_self")=>{window.open(b,k);};return Do.useEffect(()=>()=>{h.destroy();},[h]),jsxRuntime.jsxs(M.Provider,{value:p(a({currentModal:C,setCurrentModal:T,navigate:E},i),{frigade:h,registerComponent:w,unregisterComponent:B,hasInitialized:f,variables:i.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":a(a(a({},ko),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:O,children:[t&&jsxRuntime.jsx(Gr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx(Kr,{})]})}function Te(e,o){let t=Do.useContext(M);(!t||!t.frigade)&&be(`useFlow('${e}') must be used in a child of the Frigade Provider`,"warn");let{frigade:r,variables:n}=t!=null?t:{},[,i]=Do.useState(!1),l=Do.useCallback(d=>{r==null||r.getFlow(e).then(()=>{d();});let u=(m,f)=>{f.id===e&&setTimeout(()=>{i(g=>!g),d();},0);};return r==null||r.on("flow.any",u),()=>{r==null||r.off("flow.any",u);}},[e,r]),s=xo(l,()=>r==null?void 0:r.getFlowSync(e),()=>r==null?void 0:r.getFlowSync(e));return Do.useEffect(()=>{s==null||s.applyVariables(a(a({},n),o==null?void 0:o.variables));},[o==null?void 0:o.variables,s,e,n]),{flow:s,isLoading:r!=null&&r.hasFailedToLoad()?!1:!s}}function tt(e,{onComplete:o,onDismiss:t}={}){let r=Do.useRef(null);return Do.useEffect(()=>{if(e==null)return;function n(){return A(this,null,function*(){e.isCompleted&&r.current===!1&&(r.current=!0,yield o==null?void 0:o(e));})}return n(),r.current=e==null?void 0:e.isCompleted,()=>{n();}},[e,o]),{handleDismiss:Do.useCallback(n=>A(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e,t])}}function on(e,o=!0){let{currentModal:t,setCurrentModal:r}=Do.useContext(M),n=Do.useCallback(l=>{o&&(e!=null&&e.isVisible)&&r(l);},[o,e==null?void 0:e.isVisible,r]),i=Do.useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&r(null);},[t,e,r]);return Do.useEffect(()=>(e!=null&&t===null&&e.isVisible&&n(e.id),i),[n,t,e,i]),Do.useEffect(()=>{e!=null&&(!o||!e.isVisible)&&i();},[e,o,i]),e==null?{hasModalCollision:!1}:!o||!e.isVisible?{hasModalCollision:!1}:t===e.id?{hasModalCollision:!1}:t===null?{hasModalCollision:!1}:{hasModalCollision:!0}}function nt(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(m){var f=m,{as:e,autoStart:o=!0,children:t,flowId:r,onComplete:n,onDismiss:i,onPrimary:l,onSecondary:s,variables:d}=f,u=y(f,["as","autoStart","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var Q,U,ee,de;let{flow:g}=Te(r,{variables:d}),C=g==null?void 0:g.getCurrentStep(),T=(Q=C==null?void 0:C.props)!=null?Q:{},{otherProps:h}=ce(T),ne=a(a(a({},u),(U=g==null?void 0:g.props)!=null?U:{}),((ee=g==null?void 0:g.rawData)==null?void 0:ee.flowType)===js.FlowType.CHECKLIST?{}:h),{dismissible:S=!!nt(e),forceMount:w=!1}=ne,B=y(ne,["dismissible","forceMount"]),{handleDismiss:E}=tt(g,{onComplete:n,onDismiss:i}),{handlePrimary:b,handleSecondary:k}=ye(C,{onPrimary:l,onSecondary:s}),v=(B==null?void 0:B.modal)||nt(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((de=g==null?void 0:g.rawData)==null?void 0:de.flowType),{hasModalCollision:I}=on(g,v);function H(N){if(S===!1){N.preventDefault();return}typeof u.onEscapeKeyDown=="function"&&u.onEscapeKeyDown(N),N.defaultPrevented||E(N);}let J=w&&((g==null?void 0:g.isCompleted)||(g==null?void 0:g.isSkipped));if(!g||(!g.isVisible||I)&&!J)return null;(J||!g.isCompleted&&!g.isSkipped&&o)&&(C==null||C.start());let Z=e===null?Do.Fragment:e!=null?e:x,Y=p(a({},B),{"data-flow-id":g.id});return nt(e)&&(Y.onEscapeKeyDown=H),jsxRuntime.jsx(Z,p(a({},e===null?{}:Y),{children:t({flow:g,handleDismiss:E,handlePrimary:b,handleSecondary:k,parentProps:{dismissible:S,flowId:r,variables:d,containerProps:Y},step:C})}))}function rn(t){var r=t,{part:e}=r,o=y(r,["part"]);return jsxRuntime.jsx(z,p(a({as:P,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:i,handleSecondary:l,parentProps:{dismissible:s},step:d})=>{var g,C,T,h,S,w;let u=(C=(g=d.primaryButton)==null?void 0:g.title)!=null?C:d.primaryButtonTitle,m=(h=(T=d.secondaryButton)==null?void 0:T.title)!=null?h:d.secondaryButtonTitle,{videoProps:f}=ce((S=d.props)!=null?S:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P.Header,{dismissible:s,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(P.Media,a({src:(w=d.videoUri)!=null?w:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},f)),jsxRuntime.jsxs(F.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(P.Secondary,{title:m,onClick:l}),jsxRuntime.jsx(P.Primary,{title:u,onClick:i})]})]})}}))}function Co(r){var n=r,{part:e,src:o}=n,t=y(n,["part","src"]);return jsxRuntime.jsx(x,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function hs(e){var o,t,r,n,i;return e.includes("youtube")?`https://www.youtube.com/embed/${(o=e.split("v=")[1])==null?void 0:o.split("&")[0]}`:e.includes("youtu.be")?`https://www.youtube.com/embed/${(t=e.split("youtu.be/")[1])==null?void 0:t.split("&")[0]}`:e.includes("vimeo")?`https://player.vimeo.com/video/${(r=e.split("vimeo.com/")[1])==null?void 0:r.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(n=e.split("wistia.com/medias/")[1])==null?void 0:n.split("&")[0]}`:e.includes("loom")?`https://loom.com/embed/${(i=e.split("loom.com/share/")[1])==null?void 0:i.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function So(T){var h=T,{autoPlay:e,controls:o,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s,playsInline:d,poster:u,preload:m,part:f,src:g}=h,C=y(h,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let S=hs(g);return S?jsxRuntime.jsx(x,a({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",f],src:S},C)):g!=null&&g.endsWith(".mp4")?jsxRuntime.jsx(x,a({as:"video",part:["video",f],src:g,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s!=null?s:e,playsInline:d,poster:u,preload:m},C)):(console.error(`Could not map videoUri ${g} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function Pe(r){var n=r,{src:e,type:o}=n,t=y(n,["src","type"]);return jsxRuntime.jsx(o==="video"?So:Co,a({src:e},t))}var P=Do__namespace.forwardRef((i,n)=>{var l=i,{children:e,flowId:o,part:t}=l,r=y(l,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(rn,a({flowId:o},r));let s=(d=r.as)!=null?d:F.Column;return jsxRuntime.jsx(s,p(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},r),{ref:n,children:e}))});P.Dismiss=e=>jsxRuntime.jsx(D.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(Be,{height:"20",fill:"currentColor"})}));P.Footer=r=>{var n=r,{children:e,part:o}=n,t=y(n,["children","part"]);return jsxRuntime.jsx(F.Row,p(a({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};P.Header=l=>{var s=l,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=s,i=y(s,["dismissible","handleDismiss","part","subtitle","title"]);return !e&&(n==null||(n==null?void 0:n.length)===0)&&(r==null||(r==null?void 0:r.length)===0)?null:jsxRuntime.jsxs(F.Row,p(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},i),{children:[jsxRuntime.jsx(P.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsxRuntime.jsx(P.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(P.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};P.Media=t=>{var r=t,{src:e}=r,o=y(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(Pe,a({borderRadius:"md",src:e},o))};P.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=y(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Primary,a({title:o,onClick:e},t))};P.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=y(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Secondary,a({title:o,onClick:e},t))};P.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=y(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.Body2,p(a({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};P.Title=r=>{var n=r,{children:e,part:o}=n,t=y(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.H4,p(a({display:"block",part:["title",o]},t),{children:e}))};var wo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function sn(e){let o=Object.fromEntries(wo.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(wo.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!wo.content.some(i=>i===n)&&!wo.root.some(i=>i===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var Ss=react.keyframes`
|
|
98
|
+
`;function go(w){var B=w,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:i,handleDismiss:l,lockScroll:s,modal:d,onPrimary:u,onSecondary:m,part:f,side:g,sideOffset:C,spotlight:T,step:h}=B,S=y(B,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","lockScroll","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var Z,Y,Q,U,ee;let{handlePrimary:E,handleSecondary:b}=ye(h,{onPrimary:u,onSecondary:m}),{videoProps:k,otherProps:v}=ce(S),I=(Y=(Z=h.primaryButton)==null?void 0:Z.title)!=null?Y:h.primaryButtonTitle,H=(U=(Q=h.secondaryButton)==null?void 0:Q.title)!=null?U:h.secondaryButtonTitle,J=!!h.$state.blocked;return jsxRuntime.jsx(qo,p(a({align:e,alignOffset:o,anchor:h.selector,autoScroll:t,"data-step-id":h.id,defaultOpen:r,lockScroll:s,modal:d,part:f,side:g,sideOffset:C,spotlight:T,onMount:()=>{r&&!J&&(h==null||h.start());}},v),{children:jsxRuntime.jsxs(P,{animation:`${Ua} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(P.Media,a({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(ee=h.videoUri)!=null?ee:h.imageUri,transform:"translate3d(0, 0, 1px)",type:h.videoUri?"video":"image"},k)),jsxRuntime.jsx(P.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:l,subtitle:h.subtitle,title:h.title}),jsxRuntime.jsxs(P.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Oe,{current:i.getCurrentStepOrder()+1,marginRight:"auto",total:i.getNumberOfAvailableSteps()}),jsxRuntime.jsx(P.Secondary,{disabled:J,onClick:b,title:H}),jsxRuntime.jsx(P.Primary,{disabled:J,onClick:E,title:I})]})]})}))}function zr(n){var i=n,{children:e,container:o,flowId:t}=i,r=y(i,["children","container","flowId"]);return jsxRuntime.jsx(Tr,{container:o,children:jsxRuntime.jsx(x,p(a({"data-flow-id":t,part:"tour"},r),{children:e}))})}function yo(r){var n=r,{as:e,flowId:o}=n,t=y(n,["as","flowId"]);let{onDismiss:i,onPrimary:l,onSecondary:s}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o,autoStart:!1},t),{children:({flow:d,handleDismiss:u,parentProps:m,step:f})=>{var de;let ne=m.containerProps,{align:g="after",alignOffset:C=0,autoScroll:T=!1,container:h="body",defaultOpen:S,lockScroll:w=!0,modal:B,onOpenChange:E,open:b,part:k,sequential:v=!0,side:I="bottom",sideOffset:H=0,spotlight:J,zIndex:Z=9999}=ne,Y=y(ne,["align","alignOffset","autoScroll","container","defaultOpen","lockScroll","modal","onOpenChange","open","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:Q}=m,U=a({align:g,alignOffset:C,autoScroll:T,dismissible:Q,flow:d,handleDismiss:u,modal:B,onPrimary:l,onSecondary:s,onOpenChange:E,open:b,part:k,side:I,sideOffset:H,spotlight:J,step:f,zIndex:Z},(de=f.props)!=null?de:{});if(v)return jsxRuntime.jsx(zr,p(a({as:e,container:h,flowId:o,part:"tour",zIndex:Z},Y),{children:jsxRuntime.jsx(go,a({defaultOpen:S!=null?S:!0,lockScroll:w},U),f.id)}));let ee=Array.from(d.steps.values()).filter(N=>{let{blocked:_,completed:G,skipped:oe,visible:K}=N.$state;return !_&&!G&&!oe&&K}).map(N=>{var ae,ie,dt,ct;function _(ut){return A(this,null,function*(){return (yield i==null?void 0:i(d,ut))===!1?(ut.preventDefault(),!1):(N.skip(),!0)})}let G=J&&N.id===f.id,oe=(ie=(ae=N.props)==null?void 0:ae.zIndex)!=null?ie:Z,K=a({align:g,alignOffset:C,dismissible:Q,flow:d,handleDismiss:_,onPrimary:l,onSecondary:s,onOpenChange:E,open:b,part:k,side:I,sideOffset:H,spotlight:J,zIndex:oe},(dt=N.props)!=null?dt:{});return jsxRuntime.jsx(go,a({css:{"&:has([aria-expanded=true])":{zIndex:Number(oe)+2},".fr-overlay":{zIndex:Number(oe)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(ct=S||G)!=null?ct:!1,lockScroll:w,step:N},K),`${N.id}-${G}`)});return jsxRuntime.jsx(zr,p(a({as:e,container:h,flowId:o,part:"tour",zIndex:Z},Y),{children:ee}))}}))}var xo="useSyncExternalStore"in Do__namespace?Do__namespace.useSyncExternalStore:Ur__namespace.useSyncExternalStore;function ho(){let{frigade:e}=Do.useContext(M),[,o]=Do.useState(!1),t=Do.useRef(),r=Do.useCallback(l=>{e==null||e.getCollections().then(()=>{l();});let s=()=>{clearTimeout(t.current),t.current=setTimeout(()=>{o(d=>!d),l();},0);};return e==null||e.on("flow.any",s),()=>{e==null||e.off("flow.any",s);};},[e]),n=()=>{let l;try{l=e==null?void 0:e.getCollectionsSync();}catch(s){}return l};return {collections:xo(r,n,n)}}function bo(e){var s,d,u,m;let{frigade:o}=Do.useContext(M),{collections:t}=ho(),r=t==null?void 0:t.get(e),i=(m=((u=(d=(s=t==null?void 0:t.get(e))==null?void 0:s.flows)==null?void 0:d.filter(f=>f.visible).map(f=>p(a({},f),{flow:o==null?void 0:o.getFlowSync(f.flowId)})))!=null?u:[]).find(({flow:f})=>f.isVisible))==null?void 0:m.flowId,{flow:l}=Te(i);return Do.useEffect(()=>{o==null||o.registerCollection(e);},[e,o]),{collection:r,currentFlow:l}}function Yo(n){var i=n,{collectionId:e,part:o,variables:t={}}=i,r=y(i,["collectionId","part","variables"]);var u,m,f;let l={ANNOUNCEMENT:Qo,BANNER:Io,CARD:P,CHECKLIST:no,EMBEDDED_TIP:P,FORM:Ve,NPS_SURVEY:Ke,SURVEY:Ke,TOUR:yo},{currentFlow:s}=bo(e),d=(m=l[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?m:null;return s==null||d==null?null:((f=s==null?void 0:s.rawData)==null?void 0:f.flowType)===js.FlowType.FORM?jsxRuntime.jsx(x,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(Ve,{flowId:s.id,as:$,variables:t},s.id)})):jsxRuntime.jsx(x,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function Gr(){var t,r;let{collections:e}=ho(),o=(r=Array.from((t=e==null?void 0:e.entries())!=null?t:[]).find(n=>n[1].collectionType==="DEFAULT"))==null?void 0:r[0];return bo(o),o==null?null:jsxRuntime.jsx(Yo,{as:null,collectionId:o})}var M=Do.createContext({apiKey:"",currentModal:null,setCurrentModal:()=>{},navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});var be=(e,o="log")=>{let t=`__frigade_logged_${e}`;globalThis[t]||(globalThis[t]=!0,console[o](e));};function et(){let e=Do.useContext(M);(!e||!e.frigade)&&be("useFrigade() must be used in a child of the Frigade Provider","warn");let{frigade:o}=e;return {frigade:o,isLoading:!(o!=null&&o.isReady())}}function Kr(){let{frigade:e}=et();return Do.useEffect(()=>{A(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(r=>{if(r.imageUri){let n=new Image;n.src=r.imageUri;}});});});},[e]),null}var jr="2.7.4";function Yr(l){var s=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=s,i=y(s,["children","css","defaultCollection","navigate","theme"]);let d=n?To(n):{},u=Do.useRef(new Map),m=Do.useRef(),[f,g]=Do.useState(!1),[C,T]=Do.useState(null),h=Do.useMemo(()=>(g(!1),m.current=void 0,new js.Frigade(i.apiKey,{apiKey:i.apiKey,apiUrl:i.apiUrl,userId:i.userId,groupId:i.groupId,userProperties:i.userProperties,groupProperties:i.groupProperties,generateGuestId:i.generateGuestId,syncOnWindowUpdates:i.syncOnWindowUpdates,__readOnly:i.__readOnly,__flowStateOverrides:i.__flowStateOverrides,__platformVersion:jr,__platformName:"React"})),[i.userId,i.groupId,i.apiKey]);Do.useEffect(()=>{if(i.__flowStateOverrides){let b=h.getConfig();b.__flowStateOverrides=i.__flowStateOverrides,h.reload(b);}},[h,i.__flowStateOverrides]);function S(){let b=[...u.current.entries()].map(([k,v])=>[k,v.callback]);h.batchRegister(b),g(!0);}function w(b,k){if(m.current&&clearTimeout(m.current),f){u.current.has(b)?h.getFlow(b).then(v=>k(v.isVisible)):(h.getFlow(b).then(v=>v.register(k)),u.current.set(b,{callback:k}));return}u.current.has(b)||u.current.set(b,{callback:k}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>S(),0);}function B(b){u.current.has(b)&&h.getFlow(b).then(k=>{u.current.delete(b),k==null||k.unregister();});}let E=r!=null?r:(b,k="_self")=>{window.open(b,k);};return Do.useEffect(()=>()=>{h.destroy();},[h]),jsxRuntime.jsxs(M.Provider,{value:p(a({currentModal:C,setCurrentModal:T,navigate:E},i),{frigade:h,registerComponent:w,unregisterComponent:B,hasInitialized:f,variables:i.variables||{}}),children:[jsxRuntime.jsx(react.Global,{styles:{":root":a(a(a({},ko),d),o)}}),jsxRuntime.jsxs(react.ThemeProvider,{theme:O,children:[t&&jsxRuntime.jsx(Gr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx(Kr,{})]})}function Te(e,o){let t=Do.useContext(M);(!t||!t.frigade)&&be(`useFlow('${e}') must be used in a child of the Frigade Provider`,"warn");let{frigade:r,variables:n}=t!=null?t:{},[,i]=Do.useState(!1),l=Do.useCallback(d=>{r==null||r.getFlow(e).then(()=>{d();});let u=(m,f)=>{f.id===e&&setTimeout(()=>{i(g=>!g),d();},0);};return r==null||r.on("flow.any",u),()=>{r==null||r.off("flow.any",u);}},[e,r]),s=xo(l,()=>r==null?void 0:r.getFlowSync(e),()=>r==null?void 0:r.getFlowSync(e));return Do.useEffect(()=>{s==null||s.applyVariables(a(a({},n),o==null?void 0:o.variables));},[o==null?void 0:o.variables,s,e,n]),{flow:s,isLoading:r!=null&&r.hasFailedToLoad()?!1:!s}}function tt(e,{onComplete:o,onDismiss:t}={}){let r=Do.useRef(null);return Do.useEffect(()=>{if(e==null)return;function n(){return A(this,null,function*(){e.isCompleted&&r.current===!1&&(r.current=!0,yield o==null?void 0:o(e));})}return n(),r.current=e==null?void 0:e.isCompleted,()=>{n();}},[e,o]),{handleDismiss:Do.useCallback(n=>A(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e,t])}}function on(e,o=!0){let{currentModal:t,setCurrentModal:r}=Do.useContext(M),n=Do.useCallback(l=>{o&&(e!=null&&e.isVisible)&&r(l);},[o,e==null?void 0:e.isVisible,r]),i=Do.useCallback(()=>{e!=null&&t===(e==null?void 0:e.id)&&r(null);},[t,e,r]);return Do.useEffect(()=>(e!=null&&t===null&&e.isVisible&&n(e.id),i),[n,t,e,i]),Do.useEffect(()=>{e!=null&&(!o||!e.isVisible)&&i();},[e,o,i]),e==null?{hasModalCollision:!1}:!o||!e.isVisible?{hasModalCollision:!1}:t===e.id?{hasModalCollision:!1}:t===null?{hasModalCollision:!1}:{hasModalCollision:!0}}function nt(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(m){var f=m,{as:e,autoStart:o=!0,children:t,flowId:r,onComplete:n,onDismiss:i,onPrimary:l,onSecondary:s,variables:d}=f,u=y(f,["as","autoStart","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var Q,U,ee,de;let{flow:g}=Te(r,{variables:d}),C=g==null?void 0:g.getCurrentStep(),T=(Q=C==null?void 0:C.props)!=null?Q:{},{otherProps:h}=ce(T),ne=a(a(a({},u),(U=g==null?void 0:g.props)!=null?U:{}),((ee=g==null?void 0:g.rawData)==null?void 0:ee.flowType)===js.FlowType.CHECKLIST?{}:h),{dismissible:S=!!nt(e),forceMount:w=!1}=ne,B=y(ne,["dismissible","forceMount"]),{handleDismiss:E}=tt(g,{onComplete:n,onDismiss:i}),{handlePrimary:b,handleSecondary:k}=ye(C,{onPrimary:l,onSecondary:s}),v=(B==null?void 0:B.modal)||nt(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((de=g==null?void 0:g.rawData)==null?void 0:de.flowType),{hasModalCollision:I}=on(g,v);function H(N){if(S===!1){N.preventDefault();return}typeof u.onEscapeKeyDown=="function"&&u.onEscapeKeyDown(N),N.defaultPrevented||E(N);}let J=w&&((g==null?void 0:g.isCompleted)||(g==null?void 0:g.isSkipped));if(!g||(!g.isVisible||I)&&!J)return null;(J||!g.isCompleted&&!g.isSkipped&&o)&&(C==null||C.start());let Z=e===null?Do.Fragment:e!=null?e:x,Y=p(a({},B),{"data-flow-id":g.id});return nt(e)&&(Y.onEscapeKeyDown=H),jsxRuntime.jsx(Z,p(a({},e===null?{}:Y),{children:t({flow:g,handleDismiss:E,handlePrimary:b,handleSecondary:k,parentProps:{dismissible:S,flowId:r,variables:d,containerProps:Y},step:C})}))}function rn(t){var r=t,{part:e}=r,o=y(r,["part"]);return jsxRuntime.jsx(z,p(a({as:P,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:n,handlePrimary:i,handleSecondary:l,parentProps:{dismissible:s},step:d})=>{var g,C,T,h,S,w;let u=(C=(g=d.primaryButton)==null?void 0:g.title)!=null?C:d.primaryButtonTitle,m=(h=(T=d.secondaryButton)==null?void 0:T.title)!=null?h:d.secondaryButtonTitle,{videoProps:f}=ce((S=d.props)!=null?S:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P.Header,{dismissible:s,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(P.Media,a({src:(w=d.videoUri)!=null?w:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},f)),jsxRuntime.jsxs(F.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(P.Secondary,{title:m,onClick:l}),jsxRuntime.jsx(P.Primary,{title:u,onClick:i})]})]})}}))}function Co(r){var n=r,{part:e,src:o}=n,t=y(n,["part","src"]);return jsxRuntime.jsx(x,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function hs(e){var o,t,r,n,i;return e.includes("youtube")?`https://www.youtube.com/embed/${(o=e.split("v=")[1])==null?void 0:o.split("&")[0]}`:e.includes("youtu.be")?`https://www.youtube.com/embed/${(t=e.split("youtu.be/")[1])==null?void 0:t.split("&")[0]}`:e.includes("vimeo")?`https://player.vimeo.com/video/${(r=e.split("vimeo.com/")[1])==null?void 0:r.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(n=e.split("wistia.com/medias/")[1])==null?void 0:n.split("&")[0]}`:e.includes("loom")?`https://loom.com/embed/${(i=e.split("loom.com/share/")[1])==null?void 0:i.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function So(T){var h=T,{autoPlay:e,controls:o,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s,playsInline:d,poster:u,preload:m,part:f,src:g}=h,C=y(h,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let S=hs(g);return S?jsxRuntime.jsx(x,a({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",f],src:S},C)):g!=null&&g.endsWith(".mp4")?jsxRuntime.jsx(x,a({as:"video",part:["video",f],src:g,autoPlay:e,controls:o!=null?o:!0,controlsList:t,crossOrigin:r,disablePictureInPicture:n,disableRemotePlayback:i,loop:l,muted:s!=null?s:e,playsInline:d,poster:u,preload:m},C)):(console.error(`Could not map videoUri ${g} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function Pe(r){var n=r,{src:e,type:o}=n,t=y(n,["src","type"]);return jsxRuntime.jsx(o==="video"?So:Co,a({src:e},t))}var P=Do__namespace.forwardRef((i,n)=>{var l=i,{children:e,flowId:o,part:t}=l,r=y(l,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(rn,a({flowId:o},r));let s=(d=r.as)!=null?d:F.Column;return jsxRuntime.jsx(s,p(a({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",t]},r),{ref:n,children:e}))});P.Dismiss=e=>jsxRuntime.jsx(D.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(Be,{height:"20",fill:"currentColor"})}));P.Footer=r=>{var n=r,{children:e,part:o}=n,t=y(n,["children","part"]);return jsxRuntime.jsx(F.Row,p(a({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};P.Header=l=>{var s=l,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=s,i=y(s,["dismissible","handleDismiss","part","subtitle","title"]);return !e&&(n==null||(n==null?void 0:n.length)===0)&&(r==null||(r==null?void 0:r.length)===0)?null:jsxRuntime.jsxs(F.Row,p(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},i),{children:[jsxRuntime.jsx(P.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsxRuntime.jsx(P.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(P.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};P.Media=t=>{var r=t,{src:e}=r,o=y(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(Pe,a({borderRadius:"md",src:e},o))};P.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=y(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Primary,a({title:o,onClick:e},t))};P.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=y(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Secondary,a({title:o,onClick:e},t))};P.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=y(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.Body2,p(a({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};P.Title=r=>{var n=r,{children:e,part:o}=n,t=y(n,["children","part"]);return e==null?null:jsxRuntime.jsx(R.H4,p(a({display:"block",part:["title",o]},t),{children:e}))};var wo={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function sn(e){let o=Object.fromEntries(wo.content.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),t=Object.fromEntries(wo.root.map(n=>[n,e[n]]).filter(n=>n[1]!==void 0)),r={};for(let n of Object.keys(e))!wo.content.some(i=>i===n)&&!wo.root.some(i=>i===n)&&(r[n]=e[n]);return {contentProps:o,otherProps:r,rootProps:t}}var Ss=react.keyframes`
|
|
99
99
|
from {
|
|
100
100
|
opacity: 0;
|
|
101
101
|
}
|