@frigade/react 2.5.9 → 2.5.11
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 +0 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1879,10 +1879,6 @@ interface TourProps extends FlowPropsWithoutChildren, Omit<HintProps, 'anchor'>
|
|
|
1879
1879
|
* The offset of the tooltip relative to the anchor along the alignment axis.
|
|
1880
1880
|
*/
|
|
1881
1881
|
alignOffset?: number;
|
|
1882
|
-
/**
|
|
1883
|
-
* The CSS selector or DOM element to anchor the tooltip to.
|
|
1884
|
-
*/
|
|
1885
|
-
anchor: string;
|
|
1886
1882
|
/**
|
|
1887
1883
|
* Whether the tooltip should be open by default.
|
|
1888
1884
|
*/
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,7 @@ var Zo=Object.defineProperty,Jr=Object.defineProperties;var qr=Object.getOwnProp
|
|
|
56
56
|
to {
|
|
57
57
|
opacity: 1;
|
|
58
58
|
}
|
|
59
|
-
`;function lo(v){var B=v,{align:e,alignOffset:t,defaultOpen:o,dismissible:n,flow:r,handleDismiss:a,modal:p,onPrimary:s,onSecondary:d,part:u,side:m,sideOffset:g,spotlight:b,step:x}=B,T=f(B,["align","alignOffset","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var $,L,E,I,A;let{handlePrimary:w,handleSecondary:P}=le(x,{onPrimary:s,onSecondary:d}),C=(L=($=x.primaryButton)==null?void 0:$.title)!=null?L:x.primaryButtonTitle,R=(I=(E=x.secondaryButton)==null?void 0:E.title)!=null?I:x.secondaryButtonTitle,k=!!x.$state.blocked;return jsx(Vo,l(i({align:e,alignOffset:t,anchor:x.selector,"data-step-id":x.id,defaultOpen:o,modal:p,part:u,side:m,sideOffset:g,spotlight:b},T),{children:jsxs(h,{animation:`${sa} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsx(h.Media,{aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(A=x.videoUri)!=null?A:x.imageUri,transform:"translate3d(0, 0, 1px)",type:x.videoUri?"video":"image"}),jsx(h.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:a,subtitle:x.subtitle,title:x.title}),jsxs(h.Footer,{children:[r.getNumberOfAvailableSteps()>1&&jsx(Ye,{current:r.getCurrentStepOrder()+1,marginRight:"auto",total:r.getNumberOfAvailableSteps()}),jsx(h.Secondary,{disabled:k,onClick:P,title:R}),jsx(h.Primary,{disabled:k,onClick:w,title:C})]})]})}))}function wr(e,t,o){let[n,r]=useState(!1),a=useRef();return useEffect(()=>{a.current=typeof t=="string"?document.querySelector(t):t,r(!0);},[]),n?createPortal(e,a.current,o):null}function po(T){var v=T,{align:e="after",alignOffset:t=0,as:o,defaultOpen:n,dismissible:r=!1,flowId:a,modal:p,part:s,sequential:d=!0,side:u="bottom",sideOffset:m=0,spotlight:g,zIndex:b=9999}=v,x=f(v,["align","alignOffset","as","defaultOpen","dismissible","flowId","modal","part","sequential","side","sideOffset","spotlight","zIndex"]);let{onDismiss:B,onPrimary:w,onSecondary:P}=x;return wr(jsx(z,l(i({as:o,flowId:a,part:"tour"},x),{children:({flow:C,handleDismiss:R,parentProps:{containerProps:k},step:$})=>{var E,I,A,he;let L=i({align:e,alignOffset:t,dismissible:r,flow:C,handleDismiss:R,modal:p,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,step:$,zIndex:(A=(I=(E=$.props)==null?void 0:E.zIndex)!=null?I:k==null?void 0:k.zIndex)!=null?A:b},(he=$.props)!=null?he:{});return d?jsx(lo,i({defaultOpen:n!=null?n:!0},L),$.id):Array.from(C.steps.values()).filter(Q=>{let{blocked:$e,completed:ue,skipped:ee,visible:we}=Q.$state;return !$e&&!ue&&!ee&&we}).map(Q=>{var Ge,K,oe,ne,te;function $e(me){return M(this,null,function*(){return (yield B==null?void 0:B(C,me))===!1?(me.preventDefault(),!1):(Q.skip(),!0)})}let ue=g&&Q.id===$.id,ee=(oe=(K=(Ge=Q.props)==null?void 0:Ge.zIndex)!=null?K:k==null?void 0:k.zIndex)!=null?oe:b,we=i({align:e,alignOffset:t,dismissible:r,flow:C,handleDismiss:$e,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,zIndex:ee},(ne=Q.props)!=null?ne:{});return jsx(lo,i({css:{"&:has([aria-expanded=true])":{zIndex:Number(ee)+2},".fr-overlay":{zIndex:Number(ee)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(te=n||ue)!=null?te:!1,step:Q},we),`${Q.id}-${ue}`)})}})),"body")}function co(){let{frigade:e}=useContext(V),[,t]=useState(!1),o,n=useCallback(p=>{e==null||e.getCollections().then(()=>{p();});let s=()=>{clearTimeout(o),o=setTimeout(()=>{t(d=>!d),p();},0);};return e==null||e.onStateChange(s),()=>{e==null||e.removeStateChangeHandler(s);}},[]),r=()=>{let p;try{p=e==null?void 0:e.getCollectionsSync();}catch(s){}return p};return {collections:useSyncExternalStore(n,r,r)}}function Fr(e){var s,d,u,m;let{frigade:t}=useContext(V),{collections:o}=co(),n=o==null?void 0:o.get(e),a=(m=((u=(d=(s=o==null?void 0:o.get(e))==null?void 0:s.flows)==null?void 0:d.filter(g=>g.visible).map(g=>l(i({},g),{flow:t==null?void 0:t.getFlowSync(g.flowId)})))!=null?u:[]).find(({flow:g})=>g.isVisible))==null?void 0:m.flowId,{flow:p}=Se(a);return {collection:n,currentFlow:p}}function No(r){var a=r,{collectionId:e,part:t,variables:o={}}=a,n=f(a,["collectionId","part","variables"]);var u,m,g;let p={ANNOUNCEMENT:_o,BANNER:vo,CARD:h,CHECKLIST:eo,EMBEDDED_TIP:h,FORM:Ie,NPS_SURVEY:_e,SURVEY:_e,TOUR:po},{currentFlow:s}=Fr(e),d=(m=p[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?m:null;return s==null||d==null?null:((g=s==null?void 0:s.rawData)==null?void 0:g.flowType)===FlowType.FORM?jsx(y,l(i({part:["collection",t],"data-collection-id":e},n),{children:jsx(Ie,{flowId:s.id,as:H,variables:o},s.id)})):jsx(y,l(i({part:["collection",t],"data-collection-id":e},n),{children:jsx(d,{flowId:s.id,variables:o},s.id)}))}function vr(){var o,n;let{collections:e}=co(),t=(n=Array.from((o=e==null?void 0:e.entries())!=null?o:[]).find(r=>r[1].collectionType==="DEFAULT"))==null?void 0:n[0];return t==null?null:jsx(No,{as:null,collectionId:t})}var V=createContext({apiKey:"",navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});function zo(){let{frigade:e}=useContext(V);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function Rr(){let{frigade:e}=zo();return useEffect(()=>{M(this,null,function*(){(yield e.getFlows()).forEach(o=>{o.steps.forEach(n=>{if(n.imageUri){let r=new Image;r.src=n.imageUri;}});});});},[]),null}var Br="2.5.9";function Dr(p){var s=p,{children:e,css:t={},defaultCollection:o=!0,navigate:n,theme:r}=s,a=f(s,["children","css","defaultCollection","navigate","theme"]);let d=r?bo(r):{},u=useRef(new Map),m=useRef(),[g,b]=useState(!1),x=useMemo(()=>(b(!1),m.current=void 0,new Frigade(a.apiKey,{apiKey:a.apiKey,apiUrl:a.apiUrl,userId:a.userId,groupId:a.groupId,userProperties:a.userProperties,groupProperties:a.groupProperties,generateGuestId:a.generateGuestId,syncOnWindowUpdates:a.syncOnWindowUpdates,__readOnly:a.__readOnly,__flowStateOverrides:a.__flowStateOverrides,__platformVersion:Br,__platformName:"React"})),[a.userId,a.groupId,a.apiKey]);useEffect(()=>{if(a.__flowStateOverrides){let P=x.getConfig();P.__flowStateOverrides=a.__flowStateOverrides,x.reload(P);}},[a.__flowStateOverrides]);function T(){let P=[...u.current.entries()].map(([C,R])=>[C,R.callback]);x.batchRegister(P),b(!0);}function v(P,C){if(m.current&&clearTimeout(m.current),g){u.current.has(P)?x.getFlow(P).then(R=>C(R.isVisible)):(x.getFlow(P).then(R=>R.register(C)),u.current.set(P,{callback:C}));return}u.current.has(P)||u.current.set(P,{callback:C}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>T(),0);}function B(P){u.current.has(P)&&x.getFlow(P).then(C=>{u.current.delete(P),C==null||C.unregister();});}let w=n!=null?n:(P,C="_self")=>{window.open(P,C);};return useEffect(()=>()=>{x.destroy();},[]),jsxs(V.Provider,{value:l(i({navigate:w},a),{frigade:x,registerComponent:v,unregisterComponent:B,hasInitialized:g,variables:a.variables||{}}),children:[jsx(Global,{styles:{":root":i(i(i({},Po),d),t)}}),jsxs(ThemeProvider,{theme:D,children:[o&&jsx(vr,{}),e]}),a.preloadImages!==!1&&jsx(Rr,{})]})}function Se(e,t){let{frigade:o,variables:n}=useContext(V),[,r]=useState(!1),a=useCallback(s=>{o==null||o.getFlow(e).then(()=>{s();});let d=u=>{u.id===e&&setTimeout(()=>{r(m=>!m),s();},0);};return o==null||o.onStateChange(d),()=>{o==null||o.removeStateChangeHandler(d);}},[e,o]),p=useSyncExternalStore(a,()=>o==null?void 0:o.getFlowSync(e),()=>o==null?void 0:o.getFlowSync(e));return p==null||p.applyVariables(i(i({},n),t==null?void 0:t.variables)),{flow:p,isLoading:o!=null&&o.hasFailedToLoad()?!1:!p}}function Go(e,{onComplete:t,onDismiss:o}={}){let n=useRef(null);return useEffect(()=>{if(e==null)return;function r(){return M(this,null,function*(){e.isCompleted&&n.current===!1&&(yield t==null?void 0:t(e));})}return r(),n.current=e==null?void 0:e.isCompleted,()=>{r();}},[e==null?void 0:e.isCompleted]),{handleDismiss:useCallback(r=>M(this,null,function*(){if((yield o==null?void 0:o(e,r))===!1)return r.preventDefault(),!1;e.skip();}),[e])}}var de=new Set;function Ko(e,t=!0){let o=useCallback(()=>{de.has(e==null?void 0:e.id)&&de.delete(e==null?void 0:e.id);},[de,t]),n=useCallback(()=>{t&&(e!=null&&e.isVisible)&&!de.has(e.id)&&de.add(e.id);},[de,t]);useEffect(()=>()=>{o();},[]),useEffect(()=>{n();let a=()=>{o();};return window.addEventListener("popstate",a),window.addEventListener("beforeunload",a),()=>{o(),window.removeEventListener("popstate",a),window.removeEventListener("beforeunload",a);}},[n,o]),e!=null&&e.isVisible?n():o();let r=de.size>0?de.values().next().value:null;return {isCurrentModal:t?r===(e==null?void 0:e.id)||de.size==0:!0}}function z(u){var m=u,{as:e,children:t,flowId:o,onComplete:n,onDismiss:r,onPrimary:a,onSecondary:p,variables:s}=m,d=f(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var E,A;let{flow:g}=Se(o,{variables:s}),I=i(i({},d),(E=g==null?void 0:g.props)!=null?E:{}),{dismissible:b=!1,forceMount:x=!1}=I,T=f(I,["dismissible","forceMount"]),v=g==null?void 0:g.getCurrentStep(),{handleDismiss:B}=Go(g,{onComplete:n,onDismiss:r}),{handlePrimary:w,handleSecondary:P}=le(v,{onPrimary:a,onSecondary:p}),C=(T==null?void 0:T.modal)||typeof e=="function"&&(e==null?void 0:e.displayName)==="Dialog"||[FlowType.ANNOUNCEMENT,FlowType.TOUR].includes((A=g==null?void 0:g.rawData)==null?void 0:A.flowType),{isCurrentModal:R}=Ko(g,C),k=x&&((g==null?void 0:g.isCompleted)||(g==null?void 0:g.isSkipped));if(!g||!g.isVisible&&!k||!k&&!R)return null;(k||!g.isCompleted&&!g.isSkipped)&&v.start();let $=e===null?Fragment$1:e!=null?e:y,L=l(i({},T),{"data-flow-id":g.id});return jsx($,l(i({},e===null?{}:L),{children:t({flow:g,handleDismiss:B,handlePrimary:w,handleSecondary:P,parentProps:{dismissible:b,flowId:o,variables:s,containerProps:L},step:v})}))}function Ar(o){var n=o,{part:e}=n,t=f(n,["part"]);return jsx(z,l(i({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},t),{children:({handleDismiss:r,handlePrimary:a,handleSecondary:p,parentProps:{dismissible:s},step:d})=>{var g,b,x,T;let u=(b=(g=d.primaryButton)==null?void 0:g.title)!=null?b:d.primaryButtonTitle,m=(T=(x=d.secondaryButton)==null?void 0:x.title)!=null?T:d.secondaryButtonTitle;return jsxs(Fragment,{children:[jsx(h.Header,{dismissible:s,handleDismiss:r,subtitle:d.subtitle,title:d.title}),jsx(h.Media,{src:d.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxs(S.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(h.Secondary,{title:m,onClick:p}),jsx(h.Primary,{title:u,onClick:a})]})]})}}))}function mo(n){var r=n,{part:e,src:t}=r,o=f(r,["part","src"]);return jsx(y,i({as:"img",maxWidth:"unset",part:["image",e],src:t},o))}function Wa(e){var t,o,n,r,a;return e.includes("youtube")?`https://www.youtube.com/embed/${(t=e.split("v=")[1])==null?void 0:t.split("&")[0]}`:e.includes("youtu.be")?`https://www.youtube.com/embed/${(o=e.split("youtu.be/")[1])==null?void 0:o.split("&")[0]}`:e.includes("vimeo")?`https://player.vimeo.com/video/${(n=e.split("vimeo.com/")[1])==null?void 0:n.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(r=e.split("wistia.com/medias/")[1])==null?void 0:r.split("&")[0]}`:e.includes("loom")?`https://loom.com/embed/${(a=e.split("loom.com/share/")[1])==null?void 0:a.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function fo(n){var r=n,{part:e,src:t}=r,o=f(r,["part","src"]);let a=Wa(t);return a?jsx(y,i({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",e],src:a},o)):t!=null&&t.endsWith(".mp4")?jsx(y,i({as:"video",controls:!0,part:["video",e],src:t},o)):(console.error(`Could not map videoUri ${t} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function ye(n){var r=n,{src:e,type:t}=r,o=f(r,["src","type"]);return jsx(t==="video"?fo:mo,i({src:e},o))}var h=Fo.forwardRef((a,r)=>{var p=a,{children:e,flowId:t,part:o}=p,n=f(p,["children","flowId","part"]);var d;if(t!=null)return jsx(Ar,i({flowId:t},n));let s=(d=n.as)!=null?d:S.Column;return jsx(s,l(i({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",o]},n),{ref:r,children:e}))});h.Dismiss=e=>jsx(O.Plain,l(i({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsx(Fe,{height:"20",fill:"currentColor"})}));h.Footer=n=>{var r=n,{children:e,part:t}=r,o=f(r,["children","part"]);return jsx(S.Row,l(i({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",t]},o),{children:e}))};h.Header=p=>{var s=p,{dismissible:e,handleDismiss:t,part:o,subtitle:n,title:r}=s,a=f(s,["dismissible","handleDismiss","part","subtitle","title"]);return jsxs(S.Row,l(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",o]},a),{children:[jsx(h.Title,{maxWidth:"calc(100% - 32px)",children:r}),e&&jsx(h.Dismiss,{onClick:t,marginLeft:"auto"}),jsx(h.Subtitle,{color:"neutral.400",flexBasis:"100%",children:n})]}))};h.Media=o=>{var n=o,{src:e}=n,t=f(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(ye,i({borderRadius:"md",src:e},t))};h.Primary=n=>{var r=n,{onClick:e,title:t}=r,o=f(r,["onClick","title"]);return t==null||(t==null?void 0:t.length)===0?null:jsx(O.Primary,i({title:t,onClick:e},o))};h.Secondary=n=>{var r=n,{onClick:e,title:t}=r,o=f(r,["onClick","title"]);return t==null||(t==null?void 0:t.length)===0?null:jsx(O.Secondary,i({title:t,onClick:e},o))};h.Subtitle=n=>{var r=n,{children:e,part:t}=r,o=f(r,["children","part"]);return e==null?null:jsx(F.Body2,l(i({display:"block",color:"neutral.400",part:["subtitle",t]},o),{children:e}))};h.Title=n=>{var r=n,{children:e,part:t}=r,o=f(r,["children","part"]);return e==null?null:jsx(F.H4,l(i({display:"block",part:["title",t]},o),{children:e}))};var go={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Vr(e){let t=Object.fromEntries(go.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),o=Object.fromEntries(go.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!go.content.some(a=>a===r)&&!go.root.some(a=>a===r)&&(n[r]=e[r]);return {contentProps:t,otherProps:n,rootProps:o}}var _a=keyframes`
|
|
59
|
+
`;function lo(v){var B=v,{align:e,alignOffset:t,defaultOpen:o,dismissible:n,flow:r,handleDismiss:a,modal:p,onPrimary:s,onSecondary:d,part:u,side:m,sideOffset:g,spotlight:b,step:x}=B,T=f(B,["align","alignOffset","defaultOpen","dismissible","flow","handleDismiss","modal","onPrimary","onSecondary","part","side","sideOffset","spotlight","step"]);var $,L,E,I,A;let{handlePrimary:w,handleSecondary:P}=le(x,{onPrimary:s,onSecondary:d}),C=(L=($=x.primaryButton)==null?void 0:$.title)!=null?L:x.primaryButtonTitle,R=(I=(E=x.secondaryButton)==null?void 0:E.title)!=null?I:x.secondaryButtonTitle,k=!!x.$state.blocked;return jsx(Vo,l(i({align:e,alignOffset:t,anchor:x.selector,"data-step-id":x.id,defaultOpen:o,modal:p,part:u,side:m,sideOffset:g,spotlight:b},T),{children:jsxs(h,{animation:`${sa} 300ms ease-out`,boxShadow:"md",maxWidth:"min(360px, calc(100vw - 25px))",children:[jsx(h.Media,{aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:(A=x.videoUri)!=null?A:x.imageUri,transform:"translate3d(0, 0, 1px)",type:x.videoUri?"video":"image"}),jsx(h.Header,{css:{".fr-dismiss":{position:"absolute",right:"12px",top:"12px"}},dismissible:n,handleDismiss:a,subtitle:x.subtitle,title:x.title}),jsxs(h.Footer,{children:[r.getNumberOfAvailableSteps()>1&&jsx(Ye,{current:r.getCurrentStepOrder()+1,marginRight:"auto",total:r.getNumberOfAvailableSteps()}),jsx(h.Secondary,{disabled:k,onClick:P,title:R}),jsx(h.Primary,{disabled:k,onClick:w,title:C})]})]})}))}function wr(e,t,o){let[n,r]=useState(!1),a=useRef();return useEffect(()=>{a.current=typeof t=="string"?document.querySelector(t):t,r(!0);},[]),n?createPortal(e,a.current,o):null}function po(T){var v=T,{align:e="after",alignOffset:t=0,as:o,defaultOpen:n,dismissible:r=!1,flowId:a,modal:p,part:s,sequential:d=!0,side:u="bottom",sideOffset:m=0,spotlight:g,zIndex:b=9999}=v,x=f(v,["align","alignOffset","as","defaultOpen","dismissible","flowId","modal","part","sequential","side","sideOffset","spotlight","zIndex"]);let{onDismiss:B,onPrimary:w,onSecondary:P}=x;return wr(jsx(z,l(i({as:o,flowId:a,part:"tour"},x),{children:({flow:C,handleDismiss:R,parentProps:{containerProps:k},step:$})=>{var E,I,A,he;let L=i({align:e,alignOffset:t,dismissible:r,flow:C,handleDismiss:R,modal:p,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,step:$,zIndex:(A=(I=(E=$.props)==null?void 0:E.zIndex)!=null?I:k==null?void 0:k.zIndex)!=null?A:b},(he=$.props)!=null?he:{});return d?jsx(lo,i({defaultOpen:n!=null?n:!0},L),$.id):Array.from(C.steps.values()).filter(Q=>{let{blocked:$e,completed:ue,skipped:ee,visible:we}=Q.$state;return !$e&&!ue&&!ee&&we}).map(Q=>{var Ge,K,oe,ne,te;function $e(me){return M(this,null,function*(){return (yield B==null?void 0:B(C,me))===!1?(me.preventDefault(),!1):(Q.skip(),!0)})}let ue=g&&Q.id===$.id,ee=(oe=(K=(Ge=Q.props)==null?void 0:Ge.zIndex)!=null?K:k==null?void 0:k.zIndex)!=null?oe:b,we=i({align:e,alignOffset:t,dismissible:r,flow:C,handleDismiss:$e,onPrimary:w,onSecondary:P,part:s,side:u,sideOffset:m,spotlight:g,zIndex:ee},(ne=Q.props)!=null?ne:{});return jsx(lo,i({css:{"&:has([aria-expanded=true])":{zIndex:Number(ee)+2},".fr-overlay":{zIndex:Number(ee)+1},".fr-progress-fraction":{display:"none"}},defaultOpen:(te=n||ue)!=null?te:!1,step:Q},we),`${Q.id}-${ue}`)})}})),"body")}function co(){let{frigade:e}=useContext(V),[,t]=useState(!1),o,n=useCallback(p=>{e==null||e.getCollections().then(()=>{p();});let s=()=>{clearTimeout(o),o=setTimeout(()=>{t(d=>!d),p();},0);};return e==null||e.onStateChange(s),()=>{e==null||e.removeStateChangeHandler(s);}},[]),r=()=>{let p;try{p=e==null?void 0:e.getCollectionsSync();}catch(s){}return p};return {collections:useSyncExternalStore(n,r,r)}}function Fr(e){var s,d,u,m;let{frigade:t}=useContext(V),{collections:o}=co(),n=o==null?void 0:o.get(e),a=(m=((u=(d=(s=o==null?void 0:o.get(e))==null?void 0:s.flows)==null?void 0:d.filter(g=>g.visible).map(g=>l(i({},g),{flow:t==null?void 0:t.getFlowSync(g.flowId)})))!=null?u:[]).find(({flow:g})=>g.isVisible))==null?void 0:m.flowId,{flow:p}=Se(a);return {collection:n,currentFlow:p}}function No(r){var a=r,{collectionId:e,part:t,variables:o={}}=a,n=f(a,["collectionId","part","variables"]);var u,m,g;let p={ANNOUNCEMENT:_o,BANNER:vo,CARD:h,CHECKLIST:eo,EMBEDDED_TIP:h,FORM:Ie,NPS_SURVEY:_e,SURVEY:_e,TOUR:po},{currentFlow:s}=Fr(e),d=(m=p[(u=s==null?void 0:s.rawData)==null?void 0:u.flowType])!=null?m:null;return s==null||d==null?null:((g=s==null?void 0:s.rawData)==null?void 0:g.flowType)===FlowType.FORM?jsx(y,l(i({part:["collection",t],"data-collection-id":e},n),{children:jsx(Ie,{flowId:s.id,as:H,variables:o},s.id)})):jsx(y,l(i({part:["collection",t],"data-collection-id":e},n),{children:jsx(d,{flowId:s.id,variables:o},s.id)}))}function vr(){var o,n;let{collections:e}=co(),t=(n=Array.from((o=e==null?void 0:e.entries())!=null?o:[]).find(r=>r[1].collectionType==="DEFAULT"))==null?void 0:n[0];return t==null?null:jsx(No,{as:null,collectionId:t})}var V=createContext({apiKey:"",navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{},variables:{}});function zo(){let{frigade:e}=useContext(V);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function Rr(){let{frigade:e}=zo();return useEffect(()=>{M(this,null,function*(){(yield e.getFlows()).forEach(o=>{o.steps.forEach(n=>{if(n.imageUri){let r=new Image;r.src=n.imageUri;}});});});},[]),null}var Br="2.5.11";function Dr(p){var s=p,{children:e,css:t={},defaultCollection:o=!0,navigate:n,theme:r}=s,a=f(s,["children","css","defaultCollection","navigate","theme"]);let d=r?bo(r):{},u=useRef(new Map),m=useRef(),[g,b]=useState(!1),x=useMemo(()=>(b(!1),m.current=void 0,new Frigade(a.apiKey,{apiKey:a.apiKey,apiUrl:a.apiUrl,userId:a.userId,groupId:a.groupId,userProperties:a.userProperties,groupProperties:a.groupProperties,generateGuestId:a.generateGuestId,syncOnWindowUpdates:a.syncOnWindowUpdates,__readOnly:a.__readOnly,__flowStateOverrides:a.__flowStateOverrides,__platformVersion:Br,__platformName:"React"})),[a.userId,a.groupId,a.apiKey]);useEffect(()=>{if(a.__flowStateOverrides){let P=x.getConfig();P.__flowStateOverrides=a.__flowStateOverrides,x.reload(P);}},[a.__flowStateOverrides]);function T(){let P=[...u.current.entries()].map(([C,R])=>[C,R.callback]);x.batchRegister(P),b(!0);}function v(P,C){if(m.current&&clearTimeout(m.current),g){u.current.has(P)?x.getFlow(P).then(R=>C(R.isVisible)):(x.getFlow(P).then(R=>R.register(C)),u.current.set(P,{callback:C}));return}u.current.has(P)||u.current.set(P,{callback:C}),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>T(),0);}function B(P){u.current.has(P)&&x.getFlow(P).then(C=>{u.current.delete(P),C==null||C.unregister();});}let w=n!=null?n:(P,C="_self")=>{window.open(P,C);};return useEffect(()=>()=>{x.destroy();},[]),jsxs(V.Provider,{value:l(i({navigate:w},a),{frigade:x,registerComponent:v,unregisterComponent:B,hasInitialized:g,variables:a.variables||{}}),children:[jsx(Global,{styles:{":root":i(i(i({},Po),d),t)}}),jsxs(ThemeProvider,{theme:D,children:[o&&jsx(vr,{}),e]}),a.preloadImages!==!1&&jsx(Rr,{})]})}function Se(e,t){let{frigade:o,variables:n}=useContext(V),[,r]=useState(!1),a=useCallback(s=>{o==null||o.getFlow(e).then(()=>{s();});let d=u=>{u.id===e&&setTimeout(()=>{r(m=>!m),s();},0);};return o==null||o.onStateChange(d),()=>{o==null||o.removeStateChangeHandler(d);}},[e,o]),p=useSyncExternalStore(a,()=>o==null?void 0:o.getFlowSync(e),()=>o==null?void 0:o.getFlowSync(e));return p==null||p.applyVariables(i(i({},n),t==null?void 0:t.variables)),{flow:p,isLoading:o!=null&&o.hasFailedToLoad()?!1:!p}}function Go(e,{onComplete:t,onDismiss:o}={}){let n=useRef(null);return useEffect(()=>{if(e==null)return;function r(){return M(this,null,function*(){e.isCompleted&&n.current===!1&&(yield t==null?void 0:t(e));})}return r(),n.current=e==null?void 0:e.isCompleted,()=>{r();}},[e==null?void 0:e.isCompleted]),{handleDismiss:useCallback(r=>M(this,null,function*(){if((yield o==null?void 0:o(e,r))===!1)return r.preventDefault(),!1;e.skip();}),[e])}}var de=new Set;function Ko(e,t=!0){let o=useCallback(()=>{de.has(e==null?void 0:e.id)&&de.delete(e==null?void 0:e.id);},[de,t]),n=useCallback(()=>{t&&(e!=null&&e.isVisible)&&!de.has(e.id)&&de.add(e.id);},[de,t]);useEffect(()=>()=>{o();},[]),useEffect(()=>{n();let a=()=>{o();};return window.addEventListener("popstate",a),window.addEventListener("beforeunload",a),()=>{o(),window.removeEventListener("popstate",a),window.removeEventListener("beforeunload",a);}},[n,o]),e!=null&&e.isVisible?n():o();let r=de.size>0?de.values().next().value:null;return {isCurrentModal:t?r===(e==null?void 0:e.id)||de.size==0:!0}}function z(u){var m=u,{as:e,children:t,flowId:o,onComplete:n,onDismiss:r,onPrimary:a,onSecondary:p,variables:s}=m,d=f(m,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var E,A;let{flow:g}=Se(o,{variables:s}),I=i(i({},d),(E=g==null?void 0:g.props)!=null?E:{}),{dismissible:b=!1,forceMount:x=!1}=I,T=f(I,["dismissible","forceMount"]),v=g==null?void 0:g.getCurrentStep(),{handleDismiss:B}=Go(g,{onComplete:n,onDismiss:r}),{handlePrimary:w,handleSecondary:P}=le(v,{onPrimary:a,onSecondary:p}),C=(T==null?void 0:T.modal)||typeof e=="function"&&(e==null?void 0:e.displayName)==="Dialog"||[FlowType.ANNOUNCEMENT,FlowType.TOUR].includes((A=g==null?void 0:g.rawData)==null?void 0:A.flowType),{isCurrentModal:R}=Ko(g,C),k=x&&((g==null?void 0:g.isCompleted)||(g==null?void 0:g.isSkipped));if(!g||!g.isVisible&&!k||!k&&!R)return null;(k||!g.isCompleted&&!g.isSkipped)&&v.start();let $=e===null?Fragment$1:e!=null?e:y,L=l(i({},T),{"data-flow-id":g.id});return jsx($,l(i({},e===null?{}:L),{children:t({flow:g,handleDismiss:B,handlePrimary:w,handleSecondary:P,parentProps:{dismissible:b,flowId:o,variables:s,containerProps:L},step:v})}))}function Ar(o){var n=o,{part:e}=n,t=f(n,["part"]);return jsx(z,l(i({as:h,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},t),{children:({handleDismiss:r,handlePrimary:a,handleSecondary:p,parentProps:{dismissible:s},step:d})=>{var g,b,x,T;let u=(b=(g=d.primaryButton)==null?void 0:g.title)!=null?b:d.primaryButtonTitle,m=(T=(x=d.secondaryButton)==null?void 0:x.title)!=null?T:d.secondaryButtonTitle;return jsxs(Fragment,{children:[jsx(h.Header,{dismissible:s,handleDismiss:r,subtitle:d.subtitle,title:d.title}),jsx(h.Media,{src:d.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxs(S.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(h.Secondary,{title:m,onClick:p}),jsx(h.Primary,{title:u,onClick:a})]})]})}}))}function mo(n){var r=n,{part:e,src:t}=r,o=f(r,["part","src"]);return jsx(y,i({as:"img",maxWidth:"unset",part:["image",e],src:t},o))}function Wa(e){var t,o,n,r,a;return e.includes("youtube")?`https://www.youtube.com/embed/${(t=e.split("v=")[1])==null?void 0:t.split("&")[0]}`:e.includes("youtu.be")?`https://www.youtube.com/embed/${(o=e.split("youtu.be/")[1])==null?void 0:o.split("&")[0]}`:e.includes("vimeo")?`https://player.vimeo.com/video/${(n=e.split("vimeo.com/")[1])==null?void 0:n.split("&")[0]}`:e.includes("wistia")?`https://fast.wistia.net/embed/iframe/${(r=e.split("wistia.com/medias/")[1])==null?void 0:r.split("&")[0]}`:e.includes("loom")?`https://loom.com/embed/${(a=e.split("loom.com/share/")[1])==null?void 0:a.split("&")[0]}?hideEmbedTopBar=true&hide_title=true&hide_share=true&hide_owner=true`:null}function fo(n){var r=n,{part:e,src:t}=r,o=f(r,["part","src"]);let a=Wa(t);return a?jsx(y,i({allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,as:"iframe",backgroundColor:"neutral.100",borderWidth:"0",part:["video",e],src:a},o)):t!=null&&t.endsWith(".mp4")?jsx(y,i({as:"video",controls:!0,part:["video",e],src:t},o)):(console.error(`Could not map videoUri ${t} to a known provider (Youtube, Vimeo, Wistia, Loom) or valid mp4 file.`),null)}function ye(n){var r=n,{src:e,type:t}=r,o=f(r,["src","type"]);return jsx(t==="video"?fo:mo,i({src:e},o))}var h=Fo.forwardRef((a,r)=>{var p=a,{children:e,flowId:t,part:o}=p,n=f(p,["children","flowId","part"]);var d;if(t!=null)return jsx(Ar,i({flowId:t},n));let s=(d=n.as)!=null?d:S.Column;return jsx(s,l(i({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5,part:["card",o]},n),{ref:r,children:e}))});h.Dismiss=e=>jsx(O.Plain,l(i({"aria-label":"Dismiss",part:"dismiss",padding:0},e),{children:jsx(Fe,{height:"20",fill:"currentColor"})}));h.Footer=n=>{var r=n,{children:e,part:t}=r,o=f(r,["children","part"]);return jsx(S.Row,l(i({alignItems:"center",gap:3,justifyContent:"flex-end",part:["card-footer",t]},o),{children:e}))};h.Header=p=>{var s=p,{dismissible:e,handleDismiss:t,part:o,subtitle:n,title:r}=s,a=f(s,["dismissible","handleDismiss","part","subtitle","title"]);return jsxs(S.Row,l(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:["card-header",o]},a),{children:[jsx(h.Title,{maxWidth:"calc(100% - 32px)",children:r}),e&&jsx(h.Dismiss,{onClick:t,marginLeft:"auto"}),jsx(h.Subtitle,{color:"neutral.400",flexBasis:"100%",children:n})]}))};h.Media=o=>{var n=o,{src:e}=n,t=f(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(ye,i({borderRadius:"md",src:e},t))};h.Primary=n=>{var r=n,{onClick:e,title:t}=r,o=f(r,["onClick","title"]);return t==null||(t==null?void 0:t.length)===0?null:jsx(O.Primary,i({title:t,onClick:e},o))};h.Secondary=n=>{var r=n,{onClick:e,title:t}=r,o=f(r,["onClick","title"]);return t==null||(t==null?void 0:t.length)===0?null:jsx(O.Secondary,i({title:t,onClick:e},o))};h.Subtitle=n=>{var r=n,{children:e,part:t}=r,o=f(r,["children","part"]);return e==null?null:jsx(F.Body2,l(i({display:"block",color:"neutral.400",part:["subtitle",t]},o),{children:e}))};h.Title=n=>{var r=n,{children:e,part:t}=r,o=f(r,["children","part"]);return e==null?null:jsx(F.H4,l(i({display:"block",part:["title",t]},o),{children:e}))};var go={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Vr(e){let t=Object.fromEntries(go.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),o=Object.fromEntries(go.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!go.content.some(a=>a===r)&&!go.root.some(a=>a===r)&&(n[r]=e[r]);return {contentProps:t,otherProps:n,rootProps:o}}var _a=keyframes`
|
|
60
60
|
from {
|
|
61
61
|
opacity: 0;
|
|
62
62
|
}
|