@frigade/react 2.4.28 → 2.4.29
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 +1 -1
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ var Vo=Object.defineProperty,Fr=Object.defineProperties;var vr=Object.getOwnProp
|
|
|
53
53
|
to {
|
|
54
54
|
opacity: 1;
|
|
55
55
|
}
|
|
56
|
-
`;function ir(e){return e instanceof HTMLElement?!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length):!1}function $(l){var d=l,{anchor:e,children:o,className:t,spotlight:n=!1,style:r}=d,a=m(d,["anchor","children","className","spotlight","style"]);let{node:c,rect:u,ref:f}=to(),{node:y,rect:x,ref:h}=to(),ra=rr(a,u),{contentProps:w,otherProps:wr}=ra,Ao=wr,{part:k}=Ao,B=m(Ao,["part"]),{rootProps:F}=ra,[C,v]=useState(w.align),[T,D]=useState(w.side),[U,I]=useState(0),[j,A]=useState(0);if(c!==null){let q=c.getAttribute("data-align"),ce=c.getAttribute("data-side");C!==q&&v(q),T!==ce&&D(ce);}let J=useRef(null);if(useEffect(()=>{let q=document.querySelector(e);q!=null?(h(q),J.current=q):console.debug(`[frigade] Tooltip: No anchor found for query: ${e}`);},[e]),useEffect(()=>{function q(be){if(be.matches(e))return ir(be)?be:null;let ue=be.querySelectorAll(e);return ue.length>0&&ir(ue[0])?ue[0]:null}let ce=new MutationObserver(be=>{for(let ue of be)if(ue.type==="childList"){for(let Ee of ue.addedNodes){if(Ee.nodeType!==Node.ELEMENT_NODE)continue;let me=q(Ee);if(me!=null){h(me),J.current=me,console.debug("[frigade] Tooltip: MutationObserver added anchor: ",me);break}}for(let Ee of ue.removedNodes){if(Ee.nodeType!==Node.ELEMENT_NODE)continue;let me=q(Ee);if(me!=null){h(null),J.current=null,console.debug("[frigade] Tooltip: MutationObserver removed anchor: ",me);break}}}});return ce.observe(document.querySelector("body"),{childList:!0,subtree:!0}),()=>ce.disconnect()},[]),useEffect(()=>{let{scrollX:q,scrollY:ce}=window;I(x.left+q),A(x.top+ce);},[x.left,x.top]),y==null)return null;let ke="0";typeof window!="undefined"&&(ke=window.getComputedStyle(y).borderRadius);let Sr=tr({props:a,alignAttr:C,sideAttr:T});return jsxs(ee.Root,s(i({defaultOpen:!0},F),{children:[jsx(ee.Anchor,{virtualRef:J}),jsx(ee.Portal,{children:jsxs(Fragment,{children:[n&&jsx(g,i({animation:`${nr} 300ms ease-out`,boxShadow:"0 0 0 20000px rgb(0 0 0 / 0.5)",part:"tooltip-spotlight",pointerEvents:"none",position:"absolute",style:{borderRadius:ke,height:x.height,left:U,top:j,width:x.width}},a.zIndex!=null?{zIndex:a.zIndex}:{})),jsx(ee.Content,s(i({asChild:!0},w),{ref:f,children:jsxs(b,s(i({animation:`${nr} 300ms ease-out`,boxShadow:"md",position:"relative",className:t,maxWidth:"min(360px, calc(100vw - 25px))",part:["tooltip",k],pointerEvents:"auto",style:r},B),{children:[jsx(er,{style:Sr}),o]}))}))]})})]}))}$.Close=e=>jsx(ee.Close,{"aria-label":"Close",asChild:!0,children:jsx(E.Plain,s(i({css:{top:"0px",right:"-6px"},part:"close",position:"absolute"},e),{children:jsx(Pe,{height:"20",fill:"currentColor"})}))});$.Media=t=>{var n=t,{src:e}=n,o=m(n,["src"]);return e==null?null:jsx(de,i({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:e,transform:"translate3d(0, 0, 1px)"},o))};$.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null?null:jsx(E.Primary,i({title:o,onClick:e},t))};$.Progress=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.Body2,s(i({part:"progress"},o),{children:e}))};$.Secondary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null?null:jsx(E.Secondary,i({title:o,onClick:e},t))};$.Subtitle=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.Body2,s(i({part:"subtitle"},o),{children:e}))};$.Title=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.H4,s(i({part:"title"},o),{children:e}))};function ar(c){var u=c,{dismissible:e=!0,flow:o,onDismiss:t,onEscapeKeyDown:n,onPrimary:r,onSecondary:a,step:l}=u,d=m(u,["dismissible","flow","onDismiss","onEscapeKeyDown","onPrimary","onSecondary","step"]);var F,C,v,T,D,U;let{handleDismiss:f}=xe(o,{onDismiss:t}),{handlePrimary:y,handleSecondary:x}=ne(l,{onPrimary:r,onSecondary:a}),h=(F=l.props)!=null?F:{},w=(v=(C=l.primaryButton)==null?void 0:C.title)!=null?v:l.primaryButtonTitle,k=(D=(T=l.secondaryButton)==null?void 0:T.title)!=null?D:l.secondaryButtonTitle,B=l.$state.blocked;return jsxs($,s(i(i({anchor:l.selector,collisionPadding:12,onOpenAutoFocus:I=>I.preventDefault(),onPointerDownOutside:I=>I.preventDefault(),onInteractOutside:I=>I.preventDefault()},d),h),{onEscapeKeyDown:I=>{typeof n=="function"&&n(I),I.defaultPrevented||f(I);},children:[e&&jsx($.Close,{onClick:f}),jsx($.Media,{src:(U=l.videoUri)!=null?U:l.imageUri,type:l.videoUri?"video":"image"}),jsxs(P.Column,{gap:1,part:"tooltip-header",children:[jsx($.Title,{children:l.title}),jsx($.Subtitle,{color:"neutral.400",children:l.subtitle})]}),jsxs(P.Row,{alignItems:"center",gap:3,justifyContent:"flex-end",part:"tooltip-footer",children:[o.getNumberOfAvailableSteps()>1&&jsx($.Progress,{marginRight:"auto",transform:"translateY(1px)",children:`${o.getCurrentStepOrder()+1}/${o.getNumberOfAvailableSteps()}`}),jsx($.Secondary,{disabled:B,onClick:x,title:k}),jsx($.Primary,{disabled:B,onClick:y,title:w})]})]}),l.id)}var le=new Set;function Ve(e,o=!0){let t=useCallback(()=>{le.has(e==null?void 0:e.id)&&le.delete(e==null?void 0:e.id);},[le,o]),n=useCallback(()=>{o&&(e!=null&&e.isVisible)&&!le.has(e.id)&&le.add(e.id);},[le,o]);useEffect(()=>()=>{t();},[]),e!=null&&e.isVisible?n():t();let r=le.size>0?le.values().next().value:null;return {isCurrentModal:o?r===(e==null?void 0:e.id)||le.size==0:!0}}function Oo(a){var l=a,{flowId:e,onComplete:o,variables:t,part:n}=l,r=m(l,["flowId","onComplete","variables","part"]);useState(!1);let {flow:u}=ae(e,{variables:t});xe(u,{onComplete:o});let{isCurrentModal:f}=Ve(u);if(!(u!=null&&u.isVisible)||!f)return null;let y=u.getCurrentStep();return y==null||y.start(),jsx(ar,i({"data-flow-id":u.id,flow:u,part:["tour",n],step:y},r))}function sr(e){var u,f,y;let{frigade:o}=useContext(V),[,t]=useState(!1),n,r=useCallback(x=>{o.getCollection(e).then(()=>{x();});let h=()=>{clearTimeout(n),n=setTimeout(()=>{t(w=>!w),x();},100);};return o.onStateChange(h),()=>{o.removeStateChangeHandler(h);}},[e]),a=useSyncExternalStore(r,()=>{let x;try{x=o.getCollectionSync(e);}catch(h){}return x},()=>{let x;try{x=o.getCollectionSync(e);}catch(h){}return x}),d=(y=((f=(u=a==null?void 0:a.flows)==null?void 0:u.map(x=>s(i({},x),{flow:o.getFlowSync(x.flowId)})))!=null?f:[]).find(({flow:x})=>x.isVisible))==null?void 0:y.flowId,{flow:c}=ae(d);return {collection:a,currentFlow:c}}function Io(n){var r=n,{collectionId:e,part:o}=r,t=m(r,["collectionId","part"]);var c,u,f;let a={ANNOUNCEMENT:Ho,BANNER:xo,CARD:b,CHECKLIST:Xe,EMBEDDED_TIP:b,FORM:Re,NPS_SURVEY:Le,SURVEY:Le,TOUR:Oo},{currentFlow:l}=sr(e),d=(u=a[(c=l==null?void 0:l.rawData)==null?void 0:c.flowType])!=null?u:null;return l==null||d==null?null:((f=l==null?void 0:l.rawData)==null?void 0:f.flowType)===FlowType.FORM?jsx(g,s(i({part:["collection",o],"data-collection-id":e},t),{children:jsx(Re,{flowId:l.id,as:O},l.id)})):jsx(g,s(i({part:["collection",o],"data-collection-id":e},t),{children:jsx(d,{flowId:l.id},l.id)}))}function $e(){let{frigade:e}=useContext(V);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function pr(){let[e,o]=useState(),{frigade:t}=$e();return useEffect(()=>{t.getCollections().then(n=>{n==null||n.forEach((r,a)=>{r.collectionType==="DEFAULT"&&o(a);});});},[]),e==null?null:jsx(Io,{as:null,collectionId:e})}var V=createContext({apiKey:"",navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{}});function dr(){let{frigade:e}=$e();return useEffect(()=>{L(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(n=>{if(n.imageUri){let r=new Image;r.src=n.imageUri;}});});});},[]),null}var cr="2.4.28";function gr(l){var d=l,{children:e,css:o={},defaultCollection:t=!0,navigate:n,theme:r}=d,a=m(d,["children","css","defaultCollection","navigate","theme"]);let c=r?co(r):{},u=useRef(new Map),f=useRef(),[y,x]=useState(!1),h=useMemo(()=>(x(!1),f.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:cr,__platformName:"React"})),[a.userId,a.groupId,a.apiKey]);useEffect(()=>{if(a.__flowStateOverrides){let C=h.getConfig();C.__flowStateOverrides=a.__flowStateOverrides,h.reload(C);}},[a.__flowStateOverrides]);function w(){let C=[...u.current.entries()].map(([v,T])=>[v,T.callback]);h.batchRegister(C),x(!0);}function k(C,v){if(f.current&&clearTimeout(f.current),y){u.current.has(C)?h.getFlow(C).then(T=>v(T.isVisible)):(h.getFlow(C).then(T=>T.register(v)),u.current.set(C,{callback:v}));return}u.current.has(C)||u.current.set(C,{callback:v}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>w(),0);}function B(C){u.current.has(C)&&h.getFlow(C).then(v=>{u.current.delete(C),v==null||v.unregister();});}let F=n!=null?n:(C,v="_self")=>{window.open(C,v);};return useEffect(()=>()=>{h.destroy();},[]),jsxs(V.Provider,{value:s(i({navigate:F},a),{frigade:h,registerComponent:k,unregisterComponent:B,hasInitialized:y}),children:[jsx(Global,{styles:{":root":i(i(i({},uo),c),o)}}),jsxs(ThemeProvider,{theme:R,children:[t&&jsx(pr,{}),e]}),a.preloadImages!==!1&&jsx(dr,{})]})}function ae(e,o){let{frigade:t}=useContext(V),[,n]=useState(!1),r=useCallback(l=>{t==null||t.getFlow(e).then(()=>{l();});let d=c=>{c.id===e&&setTimeout(()=>{n(u=>!u),l();},0);};return t==null||t.onStateChange(d),()=>{t.removeStateChangeHandler(d);}},[e]),a=useSyncExternalStore(r,()=>t==null?void 0:t.getFlowSync(e),()=>t==null?void 0:t.getFlowSync(e));return a!=null&&(o!=null&&o.variables)&&a.applyVariables(o.variables),{flow:a,isLoading:t!=null&&t.hasFailedToLoad()?!1:!a}}function G(u){var f=u,{as:e,children:o,flowId:t,onComplete:n,onDismiss:r,onPrimary:a,onSecondary:l,variables:d}=f,c=m(f,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var j,J;let{flow:y}=ae(t,{variables:d}),A=i(i({},(j=y==null?void 0:y.props)!=null?j:{}),c),{dismissible:x=!1,forceMount:h=!1}=A,w=m(A,["dismissible","forceMount"]),k=y==null?void 0:y.getCurrentStep(),{handleDismiss:B}=xe(y,{onComplete:n,onDismiss:r}),{handlePrimary:F,handleSecondary:C}=ne(k,{onPrimary:a,onSecondary:l}),v=(w==null?void 0:w.modal)||typeof e=="function"&&(e==null?void 0:e.displayName)==="Dialog"||[FlowType.ANNOUNCEMENT,FlowType.TOUR].includes((J=y==null?void 0:y.rawData)==null?void 0:J.flowType),{isCurrentModal:T}=Ve(y,v),D=h&&((y==null?void 0:y.isCompleted)||(y==null?void 0:y.isSkipped));if(!y||!y.isVisible&&!D||!D&&!T)return null;(D||!y.isCompleted&&!y.isSkipped)&&k.start();let U=e===null?Fragment$1:e!=null?e:g,I=s(i({},w),{"data-flow-id":y.id});return jsx(U,s(i({},e===null?{}:I),{children:o({flow:y,handleDismiss:B,handlePrimary:F,handleSecondary:C,parentProps:{dismissible:x,flowId:t,variables:d,containerProps:I},step:k})}))}function hr(t){var n=t,{part:e}=n,o=m(n,["part"]);return jsx(G,s(i({as:b,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:r,handlePrimary:a,handleSecondary:l,parentProps:{dismissible:d},step:c})=>{var y,x,h,w;let u=(x=(y=c.primaryButton)==null?void 0:y.title)!=null?x:c.primaryButtonTitle,f=(w=(h=c.secondaryButton)==null?void 0:h.title)!=null?w:c.secondaryButtonTitle;return jsxs(Fragment,{children:[jsx(b.Header,{dismissible:d,handleDismiss:r,subtitle:c.subtitle,title:c.title}),jsx(b.Media,{src:c.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxs(P.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(b.Secondary,{title:f,onClick:l}),jsx(b.Primary,{title:u,onClick:a})]})]})}}))}var b=yo.forwardRef((r,n)=>{var a=r,{children:e,flowId:o}=a,t=m(a,["children","flowId"]);var d;if(o!=null)return jsx(hr,i({flowId:o},t));let l=(d=t.as)!=null?d:P.Column;return jsx(l,s(i({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5},t),{ref:n,children:e}))});b.Dismiss=e=>jsx(E.Plain,s(i({part:"dismiss",padding:0},e),{children:jsx(Pe,{height:"20",fill:"currentColor"})}));b.Header=a=>{var l=a,{dismissible:e,handleDismiss:o,subtitle:t,title:n}=l,r=m(l,["dismissible","handleDismiss","subtitle","title"]);return jsxs(P.Row,s(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:"card-header"},r),{children:[jsx(b.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsx(b.Dismiss,{onClick:o,marginLeft:"auto"}),jsx(b.Subtitle,{color:"neutral.400",flexBasis:"100%",children:t})]}))};b.Media=t=>{var n=t,{src:e}=n,o=m(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(de,i({borderRadius:"md",src:e},o))};b.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(E.Primary,i({title:o,onClick:e},t))};b.Secondary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(E.Secondary,i({title:o,onClick:e},t))};b.Subtitle=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.Body2,s(i({display:"block",color:"neutral.400",part:"subtitle"},o),{children:e}))};b.Title=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.H4,s(i({display:"block",part:"title"},o),{children:e}))};var so={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Pr(e){let o=Object.fromEntries(so.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),t=Object.fromEntries(so.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!so.content.some(a=>a===r)&&!so.root.some(a=>a===r)&&(n[r]=e[r]);return {contentProps:o,otherProps:n,rootProps:t}}var qi=keyframes`
|
|
56
|
+
`;function ir(e){return e instanceof HTMLElement?!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length):!1}function $(l){var d=l,{anchor:e,children:o,className:t,spotlight:n=!1,style:r}=d,a=m(d,["anchor","children","className","spotlight","style"]);let{node:c,rect:u,ref:f}=to(),{node:y,rect:x,ref:h}=to(),ra=rr(a,u),{contentProps:w,otherProps:wr}=ra,Ao=wr,{part:k}=Ao,B=m(Ao,["part"]),{rootProps:F}=ra,[C,v]=useState(w.align),[T,D]=useState(w.side),[U,I]=useState(0),[j,A]=useState(0);if(c!==null){let q=c.getAttribute("data-align"),ce=c.getAttribute("data-side");C!==q&&v(q),T!==ce&&D(ce);}let J=useRef(null);if(useEffect(()=>{let q=document.querySelector(e);q!=null?(h(q),J.current=q):console.debug(`[frigade] Tooltip: No anchor found for query: ${e}`);},[e]),useEffect(()=>{function q(be){if(be.matches(e))return ir(be)?be:null;let ue=be.querySelectorAll(e);return ue.length>0&&ir(ue[0])?ue[0]:null}let ce=new MutationObserver(be=>{for(let ue of be)if(ue.type==="childList"){for(let Ee of ue.addedNodes){if(Ee.nodeType!==Node.ELEMENT_NODE)continue;let me=q(Ee);if(me!=null){h(me),J.current=me,console.debug("[frigade] Tooltip: MutationObserver added anchor: ",me);break}}for(let Ee of ue.removedNodes){if(Ee.nodeType!==Node.ELEMENT_NODE)continue;let me=q(Ee);if(me!=null){h(null),J.current=null,console.debug("[frigade] Tooltip: MutationObserver removed anchor: ",me);break}}}});return ce.observe(document.querySelector("body"),{childList:!0,subtree:!0}),()=>ce.disconnect()},[]),useEffect(()=>{let{scrollX:q,scrollY:ce}=window;I(x.left+q),A(x.top+ce);},[x.left,x.top]),y==null)return null;let ke="0";typeof window!="undefined"&&(ke=window.getComputedStyle(y).borderRadius);let Sr=tr({props:a,alignAttr:C,sideAttr:T});return jsxs(ee.Root,s(i({defaultOpen:!0},F),{children:[jsx(ee.Anchor,{virtualRef:J}),jsx(ee.Portal,{children:jsxs(Fragment,{children:[n&&jsx(g,i({animation:`${nr} 300ms ease-out`,boxShadow:"0 0 0 20000px rgb(0 0 0 / 0.5)",part:"tooltip-spotlight",pointerEvents:"none",position:"absolute",style:{borderRadius:ke,height:x.height,left:U,top:j,width:x.width}},a.zIndex!=null?{zIndex:a.zIndex}:{})),jsx(ee.Content,s(i({asChild:!0},w),{ref:f,children:jsxs(b,s(i({animation:`${nr} 300ms ease-out`,boxShadow:"md",position:"relative",className:t,maxWidth:"min(360px, calc(100vw - 25px))",part:["tooltip",k],pointerEvents:"auto",style:r},B),{children:[jsx(er,{style:Sr}),o]}))}))]})})]}))}$.Close=e=>jsx(ee.Close,{"aria-label":"Close",asChild:!0,children:jsx(E.Plain,s(i({css:{top:"0px",right:"-6px"},part:"close",position:"absolute"},e),{children:jsx(Pe,{height:"20",fill:"currentColor"})}))});$.Media=t=>{var n=t,{src:e}=n,o=m(n,["src"]);return e==null?null:jsx(de,i({aspectRatio:"2",borderRadius:"md md 0 0",borderWidth:"0",margin:"-5 -5 0",objectFit:"cover",overflowClipMargin:"unset",src:e,transform:"translate3d(0, 0, 1px)"},o))};$.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null?null:jsx(E.Primary,i({title:o,onClick:e},t))};$.Progress=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.Body2,s(i({part:"progress"},o),{children:e}))};$.Secondary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null?null:jsx(E.Secondary,i({title:o,onClick:e},t))};$.Subtitle=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.Body2,s(i({part:"subtitle"},o),{children:e}))};$.Title=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.H4,s(i({part:"title"},o),{children:e}))};function ar(c){var u=c,{dismissible:e=!0,flow:o,onDismiss:t,onEscapeKeyDown:n,onPrimary:r,onSecondary:a,step:l}=u,d=m(u,["dismissible","flow","onDismiss","onEscapeKeyDown","onPrimary","onSecondary","step"]);var F,C,v,T,D,U;let{handleDismiss:f}=xe(o,{onDismiss:t}),{handlePrimary:y,handleSecondary:x}=ne(l,{onPrimary:r,onSecondary:a}),h=(F=l.props)!=null?F:{},w=(v=(C=l.primaryButton)==null?void 0:C.title)!=null?v:l.primaryButtonTitle,k=(D=(T=l.secondaryButton)==null?void 0:T.title)!=null?D:l.secondaryButtonTitle,B=l.$state.blocked;return jsxs($,s(i(i({anchor:l.selector,collisionPadding:12,onOpenAutoFocus:I=>I.preventDefault(),onPointerDownOutside:I=>I.preventDefault(),onInteractOutside:I=>I.preventDefault()},d),h),{onEscapeKeyDown:I=>{typeof n=="function"&&n(I),I.defaultPrevented||f(I);},children:[e&&jsx($.Close,{onClick:f}),jsx($.Media,{src:(U=l.videoUri)!=null?U:l.imageUri,type:l.videoUri?"video":"image"}),jsxs(P.Column,{gap:1,part:"tooltip-header",children:[jsx($.Title,{children:l.title}),jsx($.Subtitle,{color:"neutral.400",children:l.subtitle})]}),jsxs(P.Row,{alignItems:"center",gap:3,justifyContent:"flex-end",part:"tooltip-footer",children:[o.getNumberOfAvailableSteps()>1&&jsx($.Progress,{marginRight:"auto",transform:"translateY(1px)",children:`${o.getCurrentStepOrder()+1}/${o.getNumberOfAvailableSteps()}`}),jsx($.Secondary,{disabled:B,onClick:x,title:k}),jsx($.Primary,{disabled:B,onClick:y,title:w})]})]}),l.id)}var le=new Set;function Ve(e,o=!0){let t=useCallback(()=>{le.has(e==null?void 0:e.id)&&le.delete(e==null?void 0:e.id);},[le,o]),n=useCallback(()=>{o&&(e!=null&&e.isVisible)&&!le.has(e.id)&&le.add(e.id);},[le,o]);useEffect(()=>()=>{t();},[]),e!=null&&e.isVisible?n():t();let r=le.size>0?le.values().next().value:null;return {isCurrentModal:o?r===(e==null?void 0:e.id)||le.size==0:!0}}function Oo(a){var l=a,{flowId:e,onComplete:o,variables:t,part:n}=l,r=m(l,["flowId","onComplete","variables","part"]);useState(!1);let {flow:u}=ae(e,{variables:t});xe(u,{onComplete:o});let{isCurrentModal:f}=Ve(u);if(!(u!=null&&u.isVisible)||!f)return null;let y=u.getCurrentStep();return y==null||y.start(),jsx(ar,i({"data-flow-id":u.id,flow:u,part:["tour",n],step:y},r))}function sr(e){var u,f,y;let{frigade:o}=useContext(V),[,t]=useState(!1),n,r=useCallback(x=>{o==null||o.getCollection(e).then(()=>{x();});let h=()=>{clearTimeout(n),n=setTimeout(()=>{t(w=>!w),x();},100);};return o==null||o.onStateChange(h),()=>{o==null||o.removeStateChangeHandler(h);}},[e]),a=useSyncExternalStore(r,()=>{let x;try{x=o==null?void 0:o.getCollectionSync(e);}catch(h){}return x},()=>{let x;try{x=o==null?void 0:o.getCollectionSync(e);}catch(h){}return x}),d=(y=((f=(u=a==null?void 0:a.flows)==null?void 0:u.map(x=>s(i({},x),{flow:o==null?void 0:o.getFlowSync(x.flowId)})))!=null?f:[]).find(({flow:x})=>x.isVisible))==null?void 0:y.flowId,{flow:c}=ae(d);return {collection:a,currentFlow:c}}function Io(n){var r=n,{collectionId:e,part:o}=r,t=m(r,["collectionId","part"]);var c,u,f;let a={ANNOUNCEMENT:Ho,BANNER:xo,CARD:b,CHECKLIST:Xe,EMBEDDED_TIP:b,FORM:Re,NPS_SURVEY:Le,SURVEY:Le,TOUR:Oo},{currentFlow:l}=sr(e),d=(u=a[(c=l==null?void 0:l.rawData)==null?void 0:c.flowType])!=null?u:null;return l==null||d==null?null:((f=l==null?void 0:l.rawData)==null?void 0:f.flowType)===FlowType.FORM?jsx(g,s(i({part:["collection",o],"data-collection-id":e},t),{children:jsx(Re,{flowId:l.id,as:O},l.id)})):jsx(g,s(i({part:["collection",o],"data-collection-id":e},t),{children:jsx(d,{flowId:l.id},l.id)}))}function $e(){let{frigade:e}=useContext(V);return {frigade:e,isLoading:!(e!=null&&e.isReady())}}function pr(){let[e,o]=useState(),{frigade:t}=$e();return useEffect(()=>{t.getCollections().then(n=>{n==null||n.forEach((r,a)=>{r.collectionType==="DEFAULT"&&o(a);});});},[]),e==null?null:jsx(Io,{as:null,collectionId:e})}var V=createContext({apiKey:"",navigate:()=>{},hasInitialized:!1,registerComponent:()=>{},unregisterComponent:()=>{}});function dr(){let{frigade:e}=$e();return useEffect(()=>{L(this,null,function*(){(yield e.getFlows()).forEach(t=>{t.steps.forEach(n=>{if(n.imageUri){let r=new Image;r.src=n.imageUri;}});});});},[]),null}var cr="2.4.29";function gr(l){var d=l,{children:e,css:o={},defaultCollection:t=!0,navigate:n,theme:r}=d,a=m(d,["children","css","defaultCollection","navigate","theme"]);let c=r?co(r):{},u=useRef(new Map),f=useRef(),[y,x]=useState(!1),h=useMemo(()=>(x(!1),f.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:cr,__platformName:"React"})),[a.userId,a.groupId,a.apiKey]);useEffect(()=>{if(a.__flowStateOverrides){let C=h.getConfig();C.__flowStateOverrides=a.__flowStateOverrides,h.reload(C);}},[a.__flowStateOverrides]);function w(){let C=[...u.current.entries()].map(([v,T])=>[v,T.callback]);h.batchRegister(C),x(!0);}function k(C,v){if(f.current&&clearTimeout(f.current),y){u.current.has(C)?h.getFlow(C).then(T=>v(T.isVisible)):(h.getFlow(C).then(T=>T.register(v)),u.current.set(C,{callback:v}));return}u.current.has(C)||u.current.set(C,{callback:v}),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>w(),0);}function B(C){u.current.has(C)&&h.getFlow(C).then(v=>{u.current.delete(C),v==null||v.unregister();});}let F=n!=null?n:(C,v="_self")=>{window.open(C,v);};return useEffect(()=>()=>{h.destroy();},[]),jsxs(V.Provider,{value:s(i({navigate:F},a),{frigade:h,registerComponent:k,unregisterComponent:B,hasInitialized:y}),children:[jsx(Global,{styles:{":root":i(i(i({},uo),c),o)}}),jsxs(ThemeProvider,{theme:R,children:[t&&jsx(pr,{}),e]}),a.preloadImages!==!1&&jsx(dr,{})]})}function ae(e,o){let{frigade:t}=useContext(V),[,n]=useState(!1),r=useCallback(l=>{t==null||t.getFlow(e).then(()=>{l();});let d=c=>{c.id===e&&setTimeout(()=>{n(u=>!u),l();},0);};return t==null||t.onStateChange(d),()=>{t==null||t.removeStateChangeHandler(d);}},[e]),a=useSyncExternalStore(r,()=>t==null?void 0:t.getFlowSync(e),()=>t==null?void 0:t.getFlowSync(e));return a!=null&&(o!=null&&o.variables)&&a.applyVariables(o.variables),{flow:a,isLoading:t!=null&&t.hasFailedToLoad()?!1:!a}}function G(u){var f=u,{as:e,children:o,flowId:t,onComplete:n,onDismiss:r,onPrimary:a,onSecondary:l,variables:d}=f,c=m(f,["as","children","flowId","onComplete","onDismiss","onPrimary","onSecondary","variables"]);var j,J;let{flow:y}=ae(t,{variables:d}),A=i(i({},(j=y==null?void 0:y.props)!=null?j:{}),c),{dismissible:x=!1,forceMount:h=!1}=A,w=m(A,["dismissible","forceMount"]),k=y==null?void 0:y.getCurrentStep(),{handleDismiss:B}=xe(y,{onComplete:n,onDismiss:r}),{handlePrimary:F,handleSecondary:C}=ne(k,{onPrimary:a,onSecondary:l}),v=(w==null?void 0:w.modal)||typeof e=="function"&&(e==null?void 0:e.displayName)==="Dialog"||[FlowType.ANNOUNCEMENT,FlowType.TOUR].includes((J=y==null?void 0:y.rawData)==null?void 0:J.flowType),{isCurrentModal:T}=Ve(y,v),D=h&&((y==null?void 0:y.isCompleted)||(y==null?void 0:y.isSkipped));if(!y||!y.isVisible&&!D||!D&&!T)return null;(D||!y.isCompleted&&!y.isSkipped)&&k.start();let U=e===null?Fragment$1:e!=null?e:g,I=s(i({},w),{"data-flow-id":y.id});return jsx(U,s(i({},e===null?{}:I),{children:o({flow:y,handleDismiss:B,handlePrimary:F,handleSecondary:C,parentProps:{dismissible:x,flowId:t,variables:d,containerProps:I},step:k})}))}function hr(t){var n=t,{part:e}=n,o=m(n,["part"]);return jsx(G,s(i({as:b,gap:5,borderColor:"neutral.border",borderStyle:"solid",borderWidth:"md",part:["card",e]},o),{children:({handleDismiss:r,handlePrimary:a,handleSecondary:l,parentProps:{dismissible:d},step:c})=>{var y,x,h,w;let u=(x=(y=c.primaryButton)==null?void 0:y.title)!=null?x:c.primaryButtonTitle,f=(w=(h=c.secondaryButton)==null?void 0:h.title)!=null?w:c.secondaryButtonTitle;return jsxs(Fragment,{children:[jsx(b.Header,{dismissible:d,handleDismiss:r,subtitle:c.subtitle,title:c.title}),jsx(b.Media,{src:c.imageUri,css:{objectFit:"contain",width:"100%"}}),jsxs(P.Row,{gap:3,justifyContent:"flex-end",part:"card-footer",children:[jsx(b.Secondary,{title:f,onClick:l}),jsx(b.Primary,{title:u,onClick:a})]})]})}}))}var b=yo.forwardRef((r,n)=>{var a=r,{children:e,flowId:o}=a,t=m(a,["children","flowId"]);var d;if(o!=null)return jsx(hr,i({flowId:o},t));let l=(d=t.as)!=null?d:P.Column;return jsx(l,s(i({backgroundColor:"neutral.background",borderColor:"neutral.border",borderStyle:"solid",borderRadius:"md",borderWidth:"0",gap:5,p:5},t),{ref:n,children:e}))});b.Dismiss=e=>jsx(E.Plain,s(i({part:"dismiss",padding:0},e),{children:jsx(Pe,{height:"20",fill:"currentColor"})}));b.Header=a=>{var l=a,{dismissible:e,handleDismiss:o,subtitle:t,title:n}=l,r=m(l,["dismissible","handleDismiss","subtitle","title"]);return jsxs(P.Row,s(i({alignItems:"flex-start",flexWrap:"wrap",gap:1,part:"card-header"},r),{children:[jsx(b.Title,{maxWidth:"calc(100% - 32px)",children:n}),e&&jsx(b.Dismiss,{onClick:o,marginLeft:"auto"}),jsx(b.Subtitle,{color:"neutral.400",flexBasis:"100%",children:t})]}))};b.Media=t=>{var n=t,{src:e}=n,o=m(n,["src"]);return e==null||(e==null?void 0:e.length)===0?null:jsx(de,i({borderRadius:"md",src:e},o))};b.Primary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(E.Primary,i({title:o,onClick:e},t))};b.Secondary=n=>{var r=n,{onClick:e,title:o}=r,t=m(r,["onClick","title"]);return o==null||(o==null?void 0:o.length)===0?null:jsx(E.Secondary,i({title:o,onClick:e},t))};b.Subtitle=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.Body2,s(i({display:"block",color:"neutral.400",part:"subtitle"},o),{children:e}))};b.Title=t=>{var n=t,{children:e}=n,o=m(n,["children"]);return e==null?null:jsx(S.H4,s(i({display:"block",part:"title"},o),{children:e}))};var so={content:["onOpenAutoFocus","onCloseAutoFocus","onEscapeKeyDown","onPointerDownOutside","onInteractOutside"],root:["defaultOpen","modal","onOpenChange","open"]};function Pr(e){let o=Object.fromEntries(so.content.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),t=Object.fromEntries(so.root.map(r=>[r,e[r]]).filter(r=>r[1]!==void 0)),n={};for(let r of Object.keys(e))!so.content.some(a=>a===r)&&!so.root.some(a=>a===r)&&(n[r]=e[r]);return {contentProps:o,otherProps:n,rootProps:t}}var qi=keyframes`
|
|
57
57
|
from {
|
|
58
58
|
opacity: 0;
|
|
59
59
|
}
|