@frigade/react 2.7.0 → 2.7.1
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.d.ts +26 -24
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -95,7 +95,7 @@ var ut=Object.defineProperty,fn=Object.defineProperties;var gn=Object.getOwnProp
|
|
|
95
95
|
to {
|
|
96
96
|
opacity: 1;
|
|
97
97
|
}
|
|
98
|
-
`;function go(w){var C=w,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:i,handleDismiss:l,modal:s,onPrimary:d,onSecondary:u,part:m,side:f,sideOffset:x,spotlight:v,step:S}=C,P=g(C,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var q,X,U,ee,oe;let{handlePrimary:B,handleSecondary:E}=ge(S,{onPrimary:d,onSecondary:u}),{videoProps:h,otherProps:k}=de(P),F=(X=(q=S.primaryButton)==null?void 0:q.title)!=null?X:S.primaryButtonTitle,I=(ee=(U=S.secondaryButton)==null?void 0:U.title)!=null?ee:S.secondaryButtonTitle,H=!!S.$state.blocked;return jsxRuntime.jsx(Jo,p(a({align:e,alignOffset:o,anchor:S.selector,autoScroll:t,"data-step-id":S.id,defaultOpen:r,modal:s,part:m,side:f,sideOffset:x,spotlight:v},k),{children:jsxRuntime.jsxs(b,{animation:`${Wa} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(b.Media,a({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(oe=S.videoUri)!=null?oe:S.imageUri,transform:"translate3d(0, 0, 1px)",type:S.videoUri?"video":"image"},h)),jsxRuntime.jsx(b.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:l,subtitle:S.subtitle,title:S.title}),jsxRuntime.jsxs(b.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Oe,{current:i.getCurrentStepOrder()+1,marginRight:"auto",total:i.getNumberOfAvailableSteps()}),jsxRuntime.jsx(b.Secondary,{disabled:H,onClick:E,title:I}),jsxRuntime.jsx(b.Primary,{disabled:H,onClick:B,title:F})]})]})}))}function _r(n){var i=n,{children:e,container:o,flowId:t}=i,r=g(i,["children","container","flowId"]);return jsxRuntime.jsx(Fr,{container:o,children:jsxRuntime.jsx(y,p(a({"data-flow-id":t,part:"tour"},r),{children:e}))})}function yo(r){var n=r,{as:e,flowId:o}=n,t=g(n,["as","flowId"]);let{onDismiss:i,onPrimary:l,onSecondary:s}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o},t),{children:({flow:d,handleDismiss:u,parentProps:m,step:f})=>{var Q;let te=m.containerProps,{align:x="after",alignOffset:v=0,autoScroll:S=!1,container:P="body",defaultOpen:w,modal:C,onOpenChange:B,open:E,part:h,sequential:k=!0,side:F="bottom",sideOffset:I=0,spotlight:H,zIndex:q=9999}=te,X=g(te,["align","alignOffset","autoScroll","container","defaultOpen","modal","onOpenChange","open","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:U}=m,ee=a({align:x,alignOffset:v,autoScroll:S,dismissible:U,flow:d,handleDismiss:u,modal:C,onPrimary:l,onSecondary:s,onOpenChange:B,open:E,part:h,side:F,sideOffset:I,spotlight:H,step:f,zIndex:q},(Q=f.props)!=null?Q:{});if(k)return jsxRuntime.jsx(_r,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:q},X),{children:jsxRuntime.jsx(go,a({defaultOpen:w!=null?w:!0},ee),f.id)}));let oe=Array.from(d.steps.values()).filter(L=>{let{blocked:ae,completed:A,skipped:G,visible:se}=L.$state;return !ae&&!A&&!G&&se}).map(L=>{var le,xe,pe,pt;function ae(dt){return V(this,null,function*(){return (yield i==null?void 0:i(d,dt))===!1?(dt.preventDefault(),!1):(L.skip(),!0)})}let A=H&&L.id===f.id,G=(xe=(le=L.props)==null?void 0:le.zIndex)!=null?xe:q,se=a({align:x,alignOffset:v,dismissible:U,flow:d,handleDismiss:ae,onPrimary:l,onSecondary:s,onOpenChange:B,open:E,part:h,side:F,sideOffset:I,spotlight:H,zIndex:G},(pe=L.props)!=null?pe:{});return jsxRuntime.jsx(go,a({css:{"&:has([aria-expanded=true])":{zIndex:Number(G)+2},".fr-overlay":{zIndex:Number(G)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(pt=w||A)!=null?pt:!1,step:L},se),`${L.id}-${A}`)});return jsxRuntime.jsx(_r,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:q},X),{children:oe}))}}))}var xo="useSyncExternalStore"in Do__namespace?Do__namespace.useSyncExternalStore:Ur__namespace.useSyncExternalStore;function ho(){let{frigade:e}=Do.useContext($),[,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($),{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 Zo(n){var i=n,{collectionId:e,part:o,variables:t={}}=i,r=g(i,["collectionId","part","variables"]);var u,m,f;let l={ANNOUNCEMENT:Yo,BANNER:Io,CARD:b,CHECKLIST:no,EMBEDDED_TIP:b,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(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(Ve,{flowId:s.id,as:M,variables:t},s.id)})):jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function zr(){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(Zo,{as:null,collectionId:o})}var $=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 Qo(){let e=Do.useContext($);(!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 Gr(){let{frigade:e}=Qo();return Do.useEffect(()=>{V(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 Kr="2.7.0";function Zr(l){var s=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=s,i=g(s,["children","css","defaultCollection","navigate","theme"]);let d=n?To(n):{},u=Do.useRef(new Map),m=Do.useRef(),[f,x]=Do.useState(!1),[v,S]=Do.useState(null),P=Do.useMemo(()=>(x(!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:Kr,__platformName:"React"})),[i.apiKey,i.apiUrl,i.userId,i.groupId,i.userProperties,i.groupProperties,i.generateGuestId,i.syncOnWindowUpdates,i.__readOnly,i.__flowStateOverrides]);Do.useEffect(()=>{if(i.__flowStateOverrides){let h=P.getConfig();h.__flowStateOverrides=i.__flowStateOverrides,P.reload(h);}},[P,i.__flowStateOverrides]);function w(){let h=[...u.current.entries()].map(([k,F])=>[k,F.callback]);P.batchRegister(h),x(!0);}function C(h,k){if(m.current&&clearTimeout(m.current),f){u.current.has(h)?P.getFlow(h).then(F=>k(F.isVisible)):(P.getFlow(h).then(F=>F.register(k)),u.current.set(h,{callback:k}));return}u.current.has(h)||u.current.set(h,{callback:k}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>w(),0);}function B(h){u.current.has(h)&&P.getFlow(h).then(k=>{u.current.delete(h),k==null||k.unregister();});}let E=r!=null?r:(h,k="_self")=>{window.open(h,k);};return Do.useEffect(()=>()=>{P.destroy();},[P]),jsxRuntime.jsxs($.Provider,{value:p(a({currentModal:v,setCurrentModal:S,navigate:E},i),{frigade:P,registerComponent:C,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(zr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx(Gr,{})]})}function Te(e,o){let t=Do.useContext($);(!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(x=>!x),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 ot(e,{onComplete:o,onDismiss:t}={}){let r=Do.useRef(null);return Do.useEffect(()=>{if(e==null)return;function n(){return V(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=>V(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e,t])}}function en(e,o=!0){let{currentModal:t,setCurrentModal:r}=Do.useContext($),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 rt(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(u){var m=u,{as:e,children:o,flowId:t,onComplete:r,onDismiss:n,onPrimary:i,onSecondary:l,variables:s}=m,d=g(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var U,ee,oe,Q;let{flow:f}=Te(t,{variables:s}),x=f==null?void 0:f.getCurrentStep(),v=(U=x==null?void 0:x.props)!=null?U:{},{otherProps:S}=de(v),te=a(a(a({},d),(ee=f==null?void 0:f.props)!=null?ee:{}),((oe=f==null?void 0:f.rawData)==null?void 0:oe.flowType)===js.FlowType.CHECKLIST?{}:S),{dismissible:P=!!rt(e),forceMount:w=!1}=te,C=g(te,["dismissible","forceMount"]),{handleDismiss:B}=ot(f,{onComplete:r,onDismiss:n}),{handlePrimary:E,handleSecondary:h}=ge(x,{onPrimary:i,onSecondary:l}),k=(C==null?void 0:C.modal)||rt(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((Q=f==null?void 0:f.rawData)==null?void 0:Q.flowType),{hasModalCollision:F}=en(f,k);function I(L){if(P===!1){L.preventDefault();return}typeof d.onEscapeKeyDown=="function"&&d.onEscapeKeyDown(L),L.defaultPrevented||B(L);}let H=w&&((f==null?void 0:f.isCompleted)||(f==null?void 0:f.isSkipped));if(!f||(!f.isVisible||F)&&!H)return null;(H||!f.isCompleted&&!f.isSkipped)&&(x==null||x.start());let q=e===null?Do.Fragment:e!=null?e:y,X=p(a({},C),{"data-flow-id":f.id});return rt(e)&&(X.onEscapeKeyDown=I),jsxRuntime.jsx(q,p(a({},e===null?{}:X),{children:o({flow:f,handleDismiss:B,handlePrimary:E,handleSecondary:h,parentProps:{dismissible:P,flowId:t,variables:s,containerProps:X},step:x})}))}function tn(t){var r=t,{part:e}=r,o=g(r,["part"]);return jsxRuntime.jsx(z,p(a({as:b,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 x,v,S,P,w,C;let u=(v=(x=d.primaryButton)==null?void 0:x.title)!=null?v:d.primaryButtonTitle,m=(P=(S=d.secondaryButton)==null?void 0:S.title)!=null?P:d.secondaryButtonTitle,{videoProps:f}=de((w=d.props)!=null?w:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(b.Header,{dismissible:s,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(b.Media,a({src:(C=d.videoUri)!=null?C:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},f)),jsxRuntime.jsxs(R.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(b.Secondary,{title:m,onClick:l}),jsxRuntime.jsx(b.Primary,{title:u,onClick:i})]})]})}}))}function Co(r){var n=r,{part:e,src:o}=n,t=g(n,["part","src"]);return jsxRuntime.jsx(y,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function ms(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(S){var P=S,{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:x}=P,v=g(P,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let w=ms(x);return w?jsxRuntime.jsx(y,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:w},v)):x!=null&&x.endsWith(".mp4")?jsxRuntime.jsx(y,a({as:"video",part:["video",f],src:x,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},v)):(console.error(`Could not map videoUri ${x} 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=g(n,["src","type"]);return jsxRuntime.jsx(o==="video"?So:Co,a({src:e},t))}var b=Do__namespace.forwardRef((i,n)=>{var l=i,{children:e,flowId:o,part:t}=l,r=g(l,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(tn,a({flowId:o},r));let s=(d=r.as)!=null?d:R.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}))});b.Dismiss=e=>jsxRuntime.jsx(D.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(Be,{height:"20",fill:"currentColor"})}));b.Footer=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return jsxRuntime.jsx(R.Row,p(a({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};b.Header=l=>{var s=l,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=s,i=g(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(R.Row,p(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},i),{children:[jsxRuntime.jsx(b.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsxRuntime.jsx(b.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(b.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};b.Media=t=>{var r=t,{src:e}=r,o=g(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(Pe,a({borderRadius:"md",src:e},o))};b.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Primary,a({title:o,onClick:e},t))};b.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Secondary,a({title:o,onClick:e},t))};b.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(T.Body2,p(a({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};b.Title=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(T.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 an(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 xs=react.keyframes`
|
|
98
|
+
`;function go(w){var C=w,{align:e,alignOffset:o,autoScroll:t,defaultOpen:r,dismissible:n,flow:i,handleDismiss:l,modal:s,onPrimary:d,onSecondary:u,part:m,side:f,sideOffset:x,spotlight:v,step:S}=C,P=g(C,["align","alignOffset","autoScroll","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var q,X,U,ee,oe;let{handlePrimary:B,handleSecondary:E}=ge(S,{onPrimary:d,onSecondary:u}),{videoProps:h,otherProps:k}=de(P),F=(X=(q=S.primaryButton)==null?void 0:q.title)!=null?X:S.primaryButtonTitle,I=(ee=(U=S.secondaryButton)==null?void 0:U.title)!=null?ee:S.secondaryButtonTitle,H=!!S.$state.blocked;return jsxRuntime.jsx(Jo,p(a({align:e,alignOffset:o,anchor:S.selector,autoScroll:t,"data-step-id":S.id,defaultOpen:r,modal:s,part:m,side:f,sideOffset:x,spotlight:v},k),{children:jsxRuntime.jsxs(b,{animation:`${Wa} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsxRuntime.jsx(b.Media,a({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(oe=S.videoUri)!=null?oe:S.imageUri,transform:"translate3d(0, 0, 1px)",type:S.videoUri?"video":"image"},h)),jsxRuntime.jsx(b.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:l,subtitle:S.subtitle,title:S.title}),jsxRuntime.jsxs(b.Footer,{children:[i.getNumberOfAvailableSteps()>1&&jsxRuntime.jsx(Oe,{current:i.getCurrentStepOrder()+1,marginRight:"auto",total:i.getNumberOfAvailableSteps()}),jsxRuntime.jsx(b.Secondary,{disabled:H,onClick:E,title:I}),jsxRuntime.jsx(b.Primary,{disabled:H,onClick:B,title:F})]})]})}))}function _r(n){var i=n,{children:e,container:o,flowId:t}=i,r=g(i,["children","container","flowId"]);return jsxRuntime.jsx(Fr,{container:o,children:jsxRuntime.jsx(y,p(a({"data-flow-id":t,part:"tour"},r),{children:e}))})}function yo(r){var n=r,{as:e,flowId:o}=n,t=g(n,["as","flowId"]);let{onDismiss:i,onPrimary:l,onSecondary:s}=t;return jsxRuntime.jsx(z,p(a({as:null,flowId:o},t),{children:({flow:d,handleDismiss:u,parentProps:m,step:f})=>{var Q;let te=m.containerProps,{align:x="after",alignOffset:v=0,autoScroll:S=!1,container:P="body",defaultOpen:w,modal:C,onOpenChange:B,open:E,part:h,sequential:k=!0,side:F="bottom",sideOffset:I=0,spotlight:H,zIndex:q=9999}=te,X=g(te,["align","alignOffset","autoScroll","container","defaultOpen","modal","onOpenChange","open","part","sequential","side","sideOffset","spotlight","zIndex"]),{dismissible:U}=m,ee=a({align:x,alignOffset:v,autoScroll:S,dismissible:U,flow:d,handleDismiss:u,modal:C,onPrimary:l,onSecondary:s,onOpenChange:B,open:E,part:h,side:F,sideOffset:I,spotlight:H,step:f,zIndex:q},(Q=f.props)!=null?Q:{});if(k)return jsxRuntime.jsx(_r,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:q},X),{children:jsxRuntime.jsx(go,a({defaultOpen:w!=null?w:!0},ee),f.id)}));let oe=Array.from(d.steps.values()).filter(L=>{let{blocked:ae,completed:A,skipped:G,visible:se}=L.$state;return !ae&&!A&&!G&&se}).map(L=>{var le,xe,pe,pt;function ae(dt){return V(this,null,function*(){return (yield i==null?void 0:i(d,dt))===!1?(dt.preventDefault(),!1):(L.skip(),!0)})}let A=H&&L.id===f.id,G=(xe=(le=L.props)==null?void 0:le.zIndex)!=null?xe:q,se=a({align:x,alignOffset:v,dismissible:U,flow:d,handleDismiss:ae,onPrimary:l,onSecondary:s,onOpenChange:B,open:E,part:h,side:F,sideOffset:I,spotlight:H,zIndex:G},(pe=L.props)!=null?pe:{});return jsxRuntime.jsx(go,a({css:{"&:has([aria-expanded=true])":{zIndex:Number(G)+2},".fr-overlay":{zIndex:Number(G)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(pt=w||A)!=null?pt:!1,step:L},se),`${L.id}-${A}`)});return jsxRuntime.jsx(_r,p(a({as:e,container:P,flowId:o,part:"tour",zIndex:q},X),{children:oe}))}}))}var xo="useSyncExternalStore"in Do__namespace?Do__namespace.useSyncExternalStore:Ur__namespace.useSyncExternalStore;function ho(){let{frigade:e}=Do.useContext($),[,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($),{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 Zo(n){var i=n,{collectionId:e,part:o,variables:t={}}=i,r=g(i,["collectionId","part","variables"]);var u,m,f;let l={ANNOUNCEMENT:Yo,BANNER:Io,CARD:b,CHECKLIST:no,EMBEDDED_TIP:b,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(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(Ve,{flowId:s.id,as:M,variables:t},s.id)})):jsxRuntime.jsx(y,p(a({part:["collection",o],"data-collection-id":e},r),{children:jsxRuntime.jsx(d,{flowId:s.id,variables:t},s.id)}))}function zr(){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(Zo,{as:null,collectionId:o})}var $=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 Qo(){let e=Do.useContext($);(!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 Gr(){let{frigade:e}=Qo();return Do.useEffect(()=>{V(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 Kr="2.7.1";function Zr(l){var s=l,{children:e,css:o={},defaultCollection:t=!0,navigate:r,theme:n}=s,i=g(s,["children","css","defaultCollection","navigate","theme"]);let d=n?To(n):{},u=Do.useRef(new Map),m=Do.useRef(),[f,x]=Do.useState(!1),[v,S]=Do.useState(null),P=Do.useMemo(()=>(x(!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:Kr,__platformName:"React"})),[i.apiKey,i.apiUrl,i.userId,i.groupId,i.userProperties,i.groupProperties,i.generateGuestId,i.syncOnWindowUpdates,i.__readOnly,i.__flowStateOverrides]);Do.useEffect(()=>{if(i.__flowStateOverrides){let h=P.getConfig();h.__flowStateOverrides=i.__flowStateOverrides,P.reload(h);}},[P,i.__flowStateOverrides]);function w(){let h=[...u.current.entries()].map(([k,F])=>[k,F.callback]);P.batchRegister(h),x(!0);}function C(h,k){if(m.current&&clearTimeout(m.current),f){u.current.has(h)?P.getFlow(h).then(F=>k(F.isVisible)):(P.getFlow(h).then(F=>F.register(k)),u.current.set(h,{callback:k}));return}u.current.has(h)||u.current.set(h,{callback:k}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>w(),0);}function B(h){u.current.has(h)&&P.getFlow(h).then(k=>{u.current.delete(h),k==null||k.unregister();});}let E=r!=null?r:(h,k="_self")=>{window.open(h,k);};return Do.useEffect(()=>()=>{P.destroy();},[P]),jsxRuntime.jsxs($.Provider,{value:p(a({currentModal:v,setCurrentModal:S,navigate:E},i),{frigade:P,registerComponent:C,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(zr,{}),e]}),i.preloadImages!==!1&&jsxRuntime.jsx(Gr,{})]})}function Te(e,o){let t=Do.useContext($);(!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(x=>!x),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 ot(e,{onComplete:o,onDismiss:t}={}){let r=Do.useRef(null);return Do.useEffect(()=>{if(e==null)return;function n(){return V(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=>V(this,null,function*(){if((yield t==null?void 0:t(e,n))===!1)return n.preventDefault(),!1;e.skip();}),[e,t])}}function en(e,o=!0){let{currentModal:t,setCurrentModal:r}=Do.useContext($),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 rt(e){return typeof e=="function"&&e.displayName==="Dialog"}function z(u){var m=u,{as:e,children:o,flowId:t,onComplete:r,onDismiss:n,onPrimary:i,onSecondary:l,variables:s}=m,d=g(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var U,ee,oe,Q;let{flow:f}=Te(t,{variables:s}),x=f==null?void 0:f.getCurrentStep(),v=(U=x==null?void 0:x.props)!=null?U:{},{otherProps:S}=de(v),te=a(a(a({},d),(ee=f==null?void 0:f.props)!=null?ee:{}),((oe=f==null?void 0:f.rawData)==null?void 0:oe.flowType)===js.FlowType.CHECKLIST?{}:S),{dismissible:P=!!rt(e),forceMount:w=!1}=te,C=g(te,["dismissible","forceMount"]),{handleDismiss:B}=ot(f,{onComplete:r,onDismiss:n}),{handlePrimary:E,handleSecondary:h}=ge(x,{onPrimary:i,onSecondary:l}),k=(C==null?void 0:C.modal)||rt(e)||[js.FlowType.ANNOUNCEMENT,js.FlowType.TOUR].includes((Q=f==null?void 0:f.rawData)==null?void 0:Q.flowType),{hasModalCollision:F}=en(f,k);function I(L){if(P===!1){L.preventDefault();return}typeof d.onEscapeKeyDown=="function"&&d.onEscapeKeyDown(L),L.defaultPrevented||B(L);}let H=w&&((f==null?void 0:f.isCompleted)||(f==null?void 0:f.isSkipped));if(!f||(!f.isVisible||F)&&!H)return null;(H||!f.isCompleted&&!f.isSkipped)&&(x==null||x.start());let q=e===null?Do.Fragment:e!=null?e:y,X=p(a({},C),{"data-flow-id":f.id});return rt(e)&&(X.onEscapeKeyDown=I),jsxRuntime.jsx(q,p(a({},e===null?{}:X),{children:o({flow:f,handleDismiss:B,handlePrimary:E,handleSecondary:h,parentProps:{dismissible:P,flowId:t,variables:s,containerProps:X},step:x})}))}function tn(t){var r=t,{part:e}=r,o=g(r,["part"]);return jsxRuntime.jsx(z,p(a({as:b,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 x,v,S,P,w,C;let u=(v=(x=d.primaryButton)==null?void 0:x.title)!=null?v:d.primaryButtonTitle,m=(P=(S=d.secondaryButton)==null?void 0:S.title)!=null?P:d.secondaryButtonTitle,{videoProps:f}=de((w=d.props)!=null?w:{});return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(b.Header,{dismissible:s,handleDismiss:n,subtitle:d.subtitle,title:d.title}),jsxRuntime.jsx(b.Media,a({src:(C=d.videoUri)!=null?C:d.imageUri,type:d.videoUri?"video":"image",css:{objectFit:"contain",width:"100%"}},f)),jsxRuntime.jsxs(R.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsxRuntime.jsx(b.Secondary,{title:m,onClick:l}),jsxRuntime.jsx(b.Primary,{title:u,onClick:i})]})]})}}))}function Co(r){var n=r,{part:e,src:o}=n,t=g(n,["part","src"]);return jsxRuntime.jsx(y,a({as:"img",maxWidth:"unset",part:["image",e],src:o},t))}function ms(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(S){var P=S,{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:x}=P,v=g(P,["autoPlay","controls","controlsList","crossOrigin","disablePictureInPicture","disableRemotePlayback","loop","muted","playsInline","poster","preload","part","src"]);let w=ms(x);return w?jsxRuntime.jsx(y,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:w},v)):x!=null&&x.endsWith(".mp4")?jsxRuntime.jsx(y,a({as:"video",part:["video",f],src:x,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},v)):(console.error(`Could not map videoUri ${x} 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=g(n,["src","type"]);return jsxRuntime.jsx(o==="video"?So:Co,a({src:e},t))}var b=Do__namespace.forwardRef((i,n)=>{var l=i,{children:e,flowId:o,part:t}=l,r=g(l,["children","flowId","part"]);var d;if(o!=null)return jsxRuntime.jsx(tn,a({flowId:o},r));let s=(d=r.as)!=null?d:R.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}))});b.Dismiss=e=>jsxRuntime.jsx(D.Plain,p(a({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsxRuntime.jsx(Be,{height:"20",fill:"currentColor"})}));b.Footer=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return jsxRuntime.jsx(R.Row,p(a({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",o]},t),{children:e}))};b.Header=l=>{var s=l,{dismissible:e,handleDismiss:o,part:t,subtitle:r,title:n}=s,i=g(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(R.Row,p(a({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",t]},i),{children:[jsxRuntime.jsx(b.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsxRuntime.jsx(b.Dismiss,{onClick:o,marginLeft:"auto"}),jsxRuntime.jsx(b.Subtitle,{color:"neutral.400",flexBasis:"100%",children:r})]}))};b.Media=t=>{var r=t,{src:e}=r,o=g(r,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsxRuntime.jsx(Pe,a({borderRadius:"md",src:e},o))};b.Primary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Primary,a({title:o,onClick:e},t))};b.Secondary=r=>{var n=r,{onClick:e,title:o}=n,t=g(n,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsxRuntime.jsx(D.Secondary,a({title:o,onClick:e},t))};b.Subtitle=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(T.Body2,p(a({display:"block",color:"neutral.400",part:["subtitle",o]},t),{children:e}))};b.Title=r=>{var n=r,{children:e,part:o}=n,t=g(n,["children","part"]);return e==null?null:jsxRuntime.jsx(T.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 an(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 xs=react.keyframes`
|
|
99
99
|
from {
|
|
100
100
|
opacity: 0;
|
|
101
101
|
}
|