1import{a6 as st,j as t,s as o,B as i,a3 as jt,G as ot,c1 as St,c2 as wt,c3 as Pt,aZ as vt,M as me,r as c,b as Se,O as we,Y as at,c4 as rt,R as Pe,c5 as ge,X as fe,a2 as ne,H as ce,E as ve,U as ie,c6 as le,c7 as it,c8 as lt,T as x,aY as ct,F as X,a5 as Re,c9 as re,ca as ue,cb as kt,bV as _t,cc as Ce,cd as Fe,ce as je,aE as ze,cf as dt,cg as Mt,ch as he,ci as ut,u as ke,P as Bt,c as Tt,cj as It,ck as Et,cl as Wt,cm as Rt,V as Ae,W as $e,b_ as Ft,b3 as Le,ah as De,b2 as He,p as zt,cn as At}from"./index-6arvOuHO.js";import{C as _e,S as mt,O as ht}from"./OrgPaymentMethodSelector-WO7Krdfu.js";import{E as pt,l as Me,a as gt,b as xt,P as Be,C as xe,c as $t,m as Lt,v as Dt,u as Ht}from"./visa-7LKeUMw8.js";import{T as Ot}from"./index-g2tXe62R.js";import{d as Yt}from"./done-DsrxoJ4g.js";import"./Radio-BJ3v5vfb.js";const Nt=st(t.jsx("path",{d:"M4 10h3v7H4zm6.5 0h3v7h-3zM2 19h20v3H2zm15-9h3v7h-3zm-5-9L2 6v2h20V6z"})),Ut=st(t.jsx("path",{d:"M12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})),Kt=o(i,{shouldForwardProp:e=>e!=="isOnboarding"})(({theme:{spacing:e,breakpoints:n},isOnboarding:s})=>({maxWidth:"1200px",width:"100%",backgroundColor:"inherit",padding:`0 ${e(2)}`,[n.down("sm")]:{padding:`0 ${e(1)}`}}));o(wt)(({theme:{palette:e,breakpoints:n,customBorderRadius:s}})=>({gap:"8px",padding:"4px",display:"flex",border:"1px solid",borderColor:e.gray200?.main,borderRadius:s.pill,backgroundColor:"white",minHeight:"44px","& .MuiToggleButtonGroup-grouped":{margin:0,border:0,"&:not(:first-of-type)":{borderRadius:s.pill},"&:first-of-type":{borderRadius:s.pill}},[n.down("sm")]:{gap:"4px",padding:"2px",width:"100%"}}));o(Pt)(({theme:{spacing:e,palette:n,breakpoints:s}})=>({textTransform:"none",height:e(5.5),padding:e(1.25,2.5),fontSize:e(2),letterSpacing:"0.5px",minHeight:"44px","&.Mui-selected.MuiToggleButton-root":{backgroundColor:`${n.primary.main}`,color:n.background?.main||"white"},"&:hover":{backgroundColor:vt(n.primary.main,.04)},[s.down("sm")]:{height:e(5),padding:e(1,1.5),fontSize:"14px",flex:1}}));const qt=o(St)(({theme:{palette:e,spacing:n,breakpoints:s}})=>({fontSize:"1rem",marginTop:n(.5),color:e.primary.main,[s.down("sm")]:{fontSize:"0.875rem"}})),Oe=o("span")(({color:e,theme:n})=>({color:e||n.palette.secondary.main,[n.breakpoints.down("sm")]:{fontSize:n.typography.body2.fontSize}})),Gt=o(i)(({theme:e})=>{const{spacing:n,palette:s,customBorderRadius:a,breakpoints:r}=e;return{maxWidth:"1200px",width:"100%",marginTop:"30px",backgroundColor:s.colors.neutral[50],borderRadius:a.sm,padding:n(4),display:"flex",flexDirection:"column",gap:n(4),boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)",[r.up("md")]:{flexDirection:"row",alignItems:"center"},[r.down("sm")]:{padding:n(2),marginTop:"20px",gap:n(2),borderRadius:a.sm}}}),Vt=o(i)(({theme:e})=>({flex:1,display:"flex",flexDirection:"column",gap:e.spacing(1),[e.breakpoints.down("sm")]:{gap:e.spacing(.5)}})),Qt=o(ot)(({theme:e})=>({flex:2,display:"grid",gridTemplateColumns:"1fr",gap:e.spacing(1),[e.breakpoints.up("sm")]:{gridTemplateColumns:"repeat(2, 1fr)"},[e.breakpoints.down("sm")]:{gap:e.spacing(.5)}})),Xt=o(i)(({theme:e})=>({display:"flex",alignItems:"center",gap:e.spacing(1),[e.breakpoints.down("sm")]:{gap:e.spacing(.5)}})),Zt=o(jt)(({theme:e})=>({width:"100%",margin:`${e.spacing(2)} 0`,[e.breakpoints.up("sm")]:{width:1,height:"auto",margin:0}})),Jt=o(i,{shouldForwardProp:e=>e!=="isOnboarding"})(({theme:e,isOnboarding:n})=>({marginBottom:e.spacing(3),marginTop:n?0:e.spacing(4),position:"relative",width:"100%"})),en=o(i)(({theme:e})=>({display:"flex",justifyContent:"center",flexWrap:"wrap",width:"100%",alignItems:"center",[e.breakpoints.down("sm")]:{flexDirection:"column",gap:e.spacing(2)}})),tn=o(i)(({theme:e})=>{const{palette:n,customBorderRadius:s,customSpacing:a}=e;return{display:"inline-flex",alignItems:"center",height:a["7xl"],width:"max-content",minWidth:225,gap:a.xs,padding:a.xs,borderRadius:s.md,backgroundColor:n.colors.neutral[100]}}),Ye=o("button",{shouldForwardProp:e=>e!=="active"})(({theme:e,active:n})=>{const{palette:s,customBorderRadius:a,customFontWeight:r,customShadows:p,customSpacing:u,typography:j,transitions:v}=e,S=j["body-sm"];return{height:"100%",width:"max-content",flex:"none",cursor:"pointer",border:"none",background:n?s.colors.system.white:"transparent",borderRadius:a.sm,padding:`0 ${u.lg}px`,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:u.lg,whiteSpace:"nowrap",fontSize:S.fontSize,lineHeight:S.lineHeight,fontWeight:n?r.semibold:r.medium,color:n?s.colors.neutral[900]:s.colors.neutral[600],boxSh
1adow:n?p.xs:"none",fontFamily:"inherit",transition:v.create("all")}}),nn=o("span")(({theme:e})=>{const{palette:n,customSpacing:s,customFontWeight:a}=e;return{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,height:s["2xl"],padding:"0 5.5px",borderRadius:s.sm,backgroundColor:n.colors.success[200],color:n.colors.success[600],fontSize:11,lineHeight:1,fontWeight:a.semibold,letterSpacing:"0.02em",whiteSpace:"nowrap",boxSizing:"border-box"}}),sn=o("p")(({theme:e})=>{const{spacing:n,palette:s,customFontWeight:a,typography:r}=e,p=r["body-sm-medium"];return{margin:0,padding:n(1.25,2),backgroundColor:"#FFF8EC",textAlign:"center",fontSize:p.fontSize,fontWeight:a.medium,lineHeight:p.lineHeight,color:s.colors.neutral[800]}}),Te={fontSize:e=>e.spacing(2.5),fontWeight:600,color:e=>e.palette.colors.neutral[900]},Ie=e=>({minWidth:154,height:40,color:e.palette.colors.neutral[900],borderColor:e.palette.colors.neutral[200],"&:hover":{borderColor:e.palette.colors.neutral[200],backgroundColor:e.palette.colors.neutral[50]}}),Ee={minWidth:154,height:40}
1,ft=o(i)(({theme:{palette:e,spacing:n,customBorderRadius:s}})=>({margin:n(4,0),padding:n(0,2.5),paddingBottom:n(5),border:"1px solid rgba(0, 0, 0, 0.08)",borderRadius:s.md,backgroundColor:e.colors.neutral[100]})),on=Me("pk_live_51Q7DoYRoJcs6tsRnZqmxt4iCKCPpADBfcXleLi3nlnmYmsimfBiBDtB2Z6pF4RafsrI9wIYLylEaXBphyB9G4R4n00k5lpK58P"),an={hidePostalCode:!0,style:{base:{fontSize:"16px",color:ne.colors.neutral[800],"::placeholder":{color:ne.colors.neutral[400]}},invalid:{color:ne.error.main}}},rn=({open:e,onClose:n,selectedPlan:s,billingType:a,onBillingChange:r,hasUsedTrial:p,onTrialActivated:u,isOnboarding:j,trialDays:v=15})=>{const S=gt(),T=xt(),{chatbotId:A,orgId:H}=me(),[N,$]=c.useState(!1),[y,Y]=c.useState(!1),[I,F]=c.useState("new"),[b,U]=c.useState(null),[E,O]=c.useState(!1),C=Se(),h=we(),g=c.useMemo(()=>at().add(v,"day").format("D MMM"),[v]),{data:{data:d}={}}=rt(H,A),{data:{data:f}={}}=Pe(A),k=!!f?.id,P=c.useMemo(()=>(Array.isArray(d)?d:d?.results||d?.payment_methods||[]).filter(z=>!!z?.id),[d]).length>0;c.useEffect(()=>{!P&&I==="existing"&&F("new")},[P,I]);const{mutateAsync:W}=ge(`subscription/client/add-stripe-payment-method/?bot_id=${A}`,[[ie],[le]]),{mutateAsync:_}=ge(`subscription/client/attach-existing-payment-method-to-bot/${A}/?org_id=${H}`,[[ie],[le],[it],[lt]]),G=async()=>{if(!S||!T){C({success:!1,message:"Stripe not initialized"});return}const D=T.getElement(xe);if(!D){C({success:!1,message:"Card element not found"});return}try{$(!0);const z=await h(`subscription/client/payment/create-stripe-setup-intent/?bot_id=${A}`,"POST",{});if(!z?.success||!z?.data?.clientSecret){C({success:!1,message:z?.message||"Failed to create setup intent."});return}const{setupIntent:ee,error:ae}=await S.confirmCardSetup(z.data.clientSecret,{payment_method:{card:D}});if(ae){C({success:!1,message:ae.message||"Card authentication failed."});return}if(!ee?.payment_method){C({success:!1,message:"Failed to set up payment method."});return}const ye=typeof ee.payment_method=="string"?ee.payment_method:ee.payment_method.id,Q=await W({payment_method_id:ye});Q?.success?(C(Q),typeof u=="function"&&u(!1,Q)):C({success:!1,message:Q?.message||"Failed to add payment method"})}catch(z){C({success:!1,message:z?.message||"An unexpected error occurred"})}finally{$(!1)}},Z=async()=>{if(!b){C({success:!1,message:"Please select a payment method to continue."});return}O(!0);try{const D={payment_method_id:b};k||(D.is_default=!0);const z=await _(D);z?.success?(C(z),typeof u=="function"&&u(!1,z)):C(z||{success:!1,message:"Failed to attach payment method."})}catch(D){C({success:!1,message:D?.message||"Failed to attach payment method."})}finally{O(!1)}},K=I==="existing",R=K?!!b:y,L=K?Z:G,M=K?E:N,se=()=>{typeof u=="function"&&u(!1)},J=()=>{if(R){L();return}se()},V=R?K?!b||E:!S||!T||!y||N:M,de=R?"Start Free Trial & Save Card":"Start Free Trial · No Card Needed",oe="Cancel",pe=n;return t.jsxs(fe,{open:e,onClose:n,title:"Confirm Your Trial Plan",titleVariant:"h4-semibold",titleSx:Te,maxWidth:560,minWidth:560,children:[t.jsx(ln,{children:t.jsx(Be,{selectedPlan:s,hasUsedTrialPeriod:p,billingType:a,onBillingChange:r,trialDays:v})}),t.jsxs(cn,{children:[t.jsx(dn,{children:t.jsxs(un,{children:[t.jsx(mn,{fontSize:"small"}),t.jsx(pn,{children:"Add payment option (optional)"})]})}),t.jsxs(hn,{children:[t.jsx(gn,{children:`Add your card now so ${s?.name||"your plan"} continues automatically after the trial. You won't be charged until ${g}, and can remove it anytime before then.`}),P&&t.jsxs(t.Fragment,{children:[t.jsx(xn,{children:"Payment method"}),t.jsxs(bn,{children:[t.jsxs(Ue,{active:I==="new",onClick:()=>F("new"),children:[t.jsx(_e,{fontSize:"small"}),t.jsx(Ne,{active:I==="new",children:"New card"})]}),t.jsxs(Ue,{active:I==="existing",onClick:()=>F("existing"),children:[t.jsx(mt,{fontSize:"small"}),t.jsx(Ne,{active:I==="existing",children:"Use existing card"})]})]})]}),K?t.jsx(ht,{orgId:H,chatbotId:A,value:b,onChange:U,minHeight:140,emptyContent:"No saved payment methods found in your organization."}):t.jsx(fn,{children:t.jsx(xe,{options:an,onChange:D=>Y(D.complete)})})]})]}),t.jsxs(yn,{children:[t.jsx(ce,{type:"button",variant:"outlined",sm:!0,onClick:pe,sx:Ie,children:oe}),t.jsx(ve,{isPending:M,sm:!0,onClick:J,disabled:V,sx:Ee,children:de})]})]})},ln=o(i)(({theme:{spacing:e}})=>({marginTop:e(-2)})),cn=o(i)(({theme:{palette:e,spacing:n,customBorderRadius:s,breakpoints:a}})=>({margin:n(3,0,4),border:`1px solid ${e.colors.neutral[200]}`,borderRadius:s.md,backgroundColor:e.colors.neutral[100],overflow:"hidden",[a.down("sm")]:{margin:n(2,0,3)}}
1)),dn=o(i)(({theme:{spacing:e,breakpoints:n}})=>({width:"100%",display:"flex",alignItems:"center",padding:e(1.75,2,.5,2),[n.down("sm")]:{padding:e(1.5,1.5,.5,1.5)}})),un=o(i)(({theme:{spacing:e}})=>({display:"flex",alignItems:"center",gap:e(1),minWidth:0})),mn=o(_e)(({theme:{palette:e}})=>({color:e.colors.neutral[700],flexShrink:0})),hn=o(i)(({theme:{spacing:e,breakpoints:n}})=>({padding:e(.5,2,2.5,2),[n.down("sm")]:{padding:e(.5,1.5,2,1.5)}})),pn=o(x)(({theme:{palette:e,spacing:n,customFontWeight:s}})=>({fontSize:n(1.75),fontWeight:s.semibold,lineHeight:n(2.5),color:e.colors.neutral[900],minWidth:0})),gn=o(x)(({theme:{palette:e,spacing:n,customFontWeight:s}})=>({fontSize:n(1.75),fontWeight:s.regular,lineHeight:n(2.5),color:e.colors.neutral[700],marginBottom:n(2)})),xn=o(x)(({theme:{palette:e,spacing:n,customFontWeight:s}})=>({fontSize:n(1.75),fontWeight:s.semibold,lineHeight:n(2.5),color:e.colors.neutral[900],marginBottom:n(1.5),display:"block"})),Ne=o("span",{shouldForwardProp:e=>e!=="active"})(({theme:{palette:e,spacing:n,customFontWeight:s},active:a})=>({fontSize:n(1.75),fontWeight:a?s.semibold:s.medium,lineHeight:n(2.5),color:a?e.primary.main:e.colors.neutral[600]})),fn=o(i)(({theme:{palette:e,customBorderRadius:n,spacing:s}})=>({padding:s(1.5),border:`1px solid ${e.colors.neutral[200]}`,borderRadius:n.sm,backgroundColor:e.background.paper})),yn=o(X)(({theme:{spacing:e,breakpoints:n}})=>({justifyContent:"flex-end",gap:e(2),flexWrap:"wrap",[n.down("sm")]:{flexDirection:"column-reverse","& > *":{width:"100%"}}})),bn=o(i)(({theme:{spacing:e,palette:n,customBorderRadius:s,breakpoints:a}})=>({display:"flex",gap:e(.5),padding:e(.5),backgroundColor:n.colors.neutral[100],border:`1px solid ${n.colors.neutral[200]}`,borderRadius:s.md,marginBottom:e(3),[a.down("sm")]:{flexDirection:"column"}})),Ue=o(ct,{shouldForwardProp:e=>e!=="active"})(({theme:{spacing:e,palette:n,customBorderRadius:s,customShadows:a},active:r})=>({flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:e(1),minHeight:38,minWidth:0,padding:e(1,1.5),borderRadius:s.sm,color:r?n.primary.main:n.colors.neutral[600],backgroundColor:r?n.background.paper:"transparent",boxShadow:r?a.xs:"none",transition:"background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease"})),Cn=e=>t.jsx(pt,{stripe:on,children:t.jsx(rn,{...e})}),jn={visa:Dt,mastercard:Lt,amex:$t},Sn=({defaultCardPaymentModal:e,onCloseDefaultCardModal:n,defaultCardDetails:s,handleActivateTrialWithDefaultCard:a,handleConfirmPurchaseWithDefaultCard:r,hasUsedTrialPeriod:p,trialDays:u,selectedPlan:j,billingType:v,onBillingChange:S})=>{const[T,A]=c.useState(!1),H=async()=>{if(p){A(!0);try{await r()}finally{A(!1)}}else a()},N=s?.brand?.toLowerCase(),$=jn[N],y=p?"Confirm your purchase":"Confirm Your Trial Plan";return t.jsxs(fe,{open:e,onClose:n,title:y,titleVariant:"h4-semibold",titleSx:Te,maxWidth:560,minWidth:560,children:[t.jsx(i,{sx:{mt:-2},children:t.jsx(Be,{selectedPlan:j,hasUsedTrialPeriod:p,trialDays:u,billingType:v,onBillingChange:S})}),t.jsxs(ft,{children:[t.jsx(x,{variant:"h5-semibold",sx:{pt:2,mb:3,display:"block",color:"colors.neutral.900"},children:"Payment method"}),t.jsxs(X,{alignItems:"center",children:[$&&t.jsx(wn,{src:$,alt:`${s?.brand} logo`}),t.jsxs(i,{children:[t.jsxs(x,{variant:"body",fontWeight:500,children:[(s?.brand??"Card").toUpperCase()," â¢â¢â¢â¢ ",s?.last4??"****"]}),t.jsxs(x,{variant:"body-sm",color:ne.colors.neutral[700],sx:{mt:.5},children:["Expires ",s?.exp_month??"N/A","/",s?.exp_year??"N/A"]})]})]})]}),t.jsxs(X,{justifyContent:"flex-end",gap:2,children:[t.jsx(ce,{type:"button",variant:"outlined",sm:!0,onClick:n,sx:Ie,children:"Cancel"}),t.jsx(ve,{isPending:T,sm:!0,onClick:H,sx:Ee,children:p?"Confirm Purchase":"Start Free Trial"})]})]})},wn=o("img")({height:"28px",marginRight:"16px"}),Pn=Me("pk_live_51Q7DoYRoJcs6tsRnZqmxt4iCKCPpADBfcXleLi3nlnmYmsimfBiBDtB2Z6pF4RafsrI9wIYLylEaXBphyB9G4R4n00k5lpK58P"),vn={hidePostalCode:!0,style:{base:{fontSize:"16px",color:ne.colors.neutral[800],"::placeholder":{color:ne.colors.neutral[400]}},invalid:{color:ne.error.main}}},kn=({open:e,onClose:n,selectedPlan:s,billingType:a,onBillingChange:r,isOnboarding:p,onCardAdded:u})=>{const j=gt(),v=xt(),{chatbotId:S,orgId:T}=me(),[A,H]=c.useState(!1),[N,$]=c.useState(!1),[y,Y]=c.useState("new"),[I,F]=c.useState(null),[b,U]=c.useState(!1),E=Se(),O=we(),{data:{data:C}
1={}}=rt(T,S),{data:{data:h}={}}=Pe(S),g=!!h?.id,f=c.useMemo(()=>(Array.isArray(C)?C:C?.results||C?.payment_methods||[]).filter(L=>!!L?.id),[C]).length>0;c.useEffect(()=>{!f&&y==="existing"&&Y("new")},[f,y]);const{mutateAsync:k}=ge(`subscription/client/add-stripe-payment-method/?bot_id=${S}`,[[ie],[le]]),{mutateAsync:w}=ge(`subscription/client/attach-existing-payment-method-to-bot/${S}/?org_id=${T}`,[[ie],[le],[it],[lt]]),P=async()=>{if(!j||!v){E({success:!1,message:"Stripe not initialized"});return}const R=v.getElement(xe);if(!R){E({success:!1,message:"Card element not found"});return}try{H(!0);const L=await O(`subscription/client/payment/create-stripe-setup-intent/?bot_id=${S}`,"POST",{});if(!L?.success||!L?.data?.clientSecret){E({success:!1,message:L?.message||"Failed to create setup intent."});return}const{setupIntent:M,error:se}=await j.confirmCardSetup(L.data.clientSecret,{payment_method:{card:R}});if(se){E({success:!1,message:se.message||"Card authentication failed."});return}if(!M?.payment_method){E({success:!1,message:"Failed to set up payment method."});return}const J=typeof M.payment_method=="string"?M.payment_method:M.payment_method.id,V=await k({payment_method_id:J});if(!V?.success){E(V||{success:!1,message:"Failed to add payment method"});return}u?.(J)}catch(L){E({success:!1,message:L?.message||"An unexpected error occurred"})}finally{H(!1)}},W=async()=>{if(!I){E({success:!1,message:"Please select a payment method to continue."});return}U(!0);try{const R={payment_method_id:I};g||(R.is_default=!0);const L=await w(R);if(!L?.success){E(L||{success:!1,message:"Failed to attach payment method."});return}u?.(I)}catch(R){E({success:!1,message:R?.message||"Failed to attach payment method."})}finally{U(!1)}},_=y==="existing",G=_?W:P,Z=_?b:A,K=_?!I||b:!j||!v||!N;return console.log("purchase payment modal content",s,a,p,f,y,_,K,Z),t.jsxs(fe,{open:e,onClose:n,title:"Confirm your purchase",titleVariant:"h4-semibold",titleSx:Te,maxWidth:560,minWidth:560,children:[t.jsx(i,{sx:{mt:-2},children:t.jsx(Be,{selectedPlan:s,hasUsedTrialPeriod:!0,billingType:a,onBillingChange:r})}),t.jsxs(ft,{children:[f&&t.jsxs(t.Fragment,{children:[t.jsx(x,{variant:"h5-semibold",sx:{pt:2,mb:2,display:"block",color:"colors.neutral.900"},children:"Payment method"}),t.jsxs(_n,{children:[t.jsxs(Ke,{active:y==="new",onClick:()=>Y("new"),children:[t.jsx(_e,{fontSize:"small"}),t.jsx(x,{variant:"body-sm",component:"span",sx:{fontWeight:y==="new"?600:500},children:"New card"})]}),t.jsxs(Ke,{active:y==="existing",onClick:()=>Y("existing"),children:[t.jsx(mt,{fontSize:"small"}),t.jsx(x,{variant:"body-sm",component:"span",sx:{fontWeight:y==="existing"?600:500},children:"Use existing card"})]})]})]}
1),_?t.jsx(ht,{orgId:T,chatbotId:S,value:I,onChange:F,minHeight:140,emptyContent:"No saved payment methods found in your organization."}):t.jsxs(t.Fragment,{children:[t.jsx(x,{variant:"h5-semibold",sx:{pt:2,mb:3,display:"block",color:"colors.neutral.900"},children:"Please enter your card details"}),t.jsx(xe,{options:vn,onChange:R=>$(R.complete)})]})]}),t.jsxs(X,{justifyContent:"flex-end",gap:2,children:[t.jsx(ce,{type:"button",variant:"outlined",sm:!0,onClick:n,sx:Ie,children:"Cancel"}),t.jsx(ve,{isPending:Z,sm:!0,onClick:G,disabled:K||Z,sx:Ee,children:Z?"Processing...":"Confirm Purchase"})]})]})},_n=o(i)(({theme:e})=>{const{spacing:n,palette:s,customBorderRadius:a}=e;return{display:"flex",gap:n(.5),padding:n(.5),backgroundColor:s.colors.neutral[100],border:`1px solid ${s.colors.neutral[200]}`,borderRadius:a.md,marginBottom:n(3)}}),Ke=o(ct,{shouldForwardProp:e=>e!=="active"})(({theme:e,active:n})=>{const{spacing:s,palette:a,customBorderRadius:r,customShadows:p}=e;return{flex:1,display:"flex",alignItems:"center",justifyContent:"center",gap:s(1),minHeight:38,padding:s(1,1.5),borderRadius:r.sm,color:n?a.primary.main:a.colors.neutral[600],backgroundColor:n?a.background.paper:"transparent",boxShadow:n?p.xs:"none",transition:"background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease"}}),Mn=e=>t.jsx(pt,{stripe:Pn,children:t.jsx(kn,{...e})}),Bn=()=>{const e=["Unlimited AI messages","Unlimited product information queries","Unlimited FAQ handling","Unlimited order status queries","Unlimited customer agent chat takeover","24/7 uptime","Email, Chat, and Call Support","180-day transcript retention"];return t.jsxs(Gt,{children:[t.jsxs(Vt,{children:[t.jsx(x,{variant:"h4-semibold",children:"Custom Plan"}),t.jsx(Oe,{children:"More security, control, and support"}),t.jsxs(i,{sx:{mt:2,display:"flex",alignItems:"center",gap:1},children:[t.jsx(Nt,{}),t.jsx(x,{variant:"body-semibold",children:"Talk to our team for pricing"})]}),t.jsx(ce,{variant:"contained",md:!0,sx:{mt:1},component:"a",href:"https://elxchatbot.ai/contact",target:"_blank",rel:"noopener noreferrer",children:"Contact our team"})]}),t.jsx(Zt,{orientation:"vertical",flexItem:!0}),t.jsx(Qt,{children:e.map((n,s)=>t.jsx(ot,{item:!0,size:{xs:12,sm:6},children:t.jsxs(Xt,{sx:{my:1},children:[t.jsx(qt,{}),t.jsx(Oe,{children:n})]})},s))})]})},qe=({billingType:e,onChange:n,isOnboarding:s,compact:a})=>{const r=e==="yearly",p=t.jsxs(tn,{role:"group","aria-label":"Billing period",children:[t.jsx(Ye,{type:"button","aria-pressed":!r,active:!r,onClick:()=>n?.("monthly"),children:"Monthly"}),t.jsxs(Ye,{type:"button","aria-pressed":r,active:r,onClick:()=>n?.("yearly"),children:["Yearly",t.jsx(nn,{children:"SAVE UP TO 20%"})]})]});return a?p:t.jsx(Jt,{isOnboarding:s,children:t.jsx(en,{children:p})})},Tn=({packages:e=[],currency:n,billingType:s="monthly",onSelect:a,freeTrial:r,setBillingType:p,suggestedPlanIndex:u=null,preSelectedPlanIndex:j=null,isOnboarding:v=!1,progressValue:S=66})=>{const T=Re("(max-width: 1135px)"),A=Re("(max-width: 679px)"),[H,N]=c.useState(null),$=t.jsxs(sn,{children:["Every plan starts with a 15-day free trial",A?t.jsx("br",{}):" ","â no credit card required."]}),y=c.useMemo(()=>e.map(h=>{const{packages:g=[],package_name:d,features_include:f=[]}=h,k=g.find(_=>{const G=_.subscription_type;return G===s||s==="yearly"&&G==="annual"||s==="annual"&&G==="yearly"})||g[0]||{},P=k?.currency_wise_price?.find(_=>_?.currency?.toUpperCase()===n?.currency_name?.toUpperCase())?.final_price,W=k?.pay_per_use_cost_currency_wise?.find(_=>_?.currency?.toUpperCase()===n?.currency_name?.toUpperCase())?.final_price;return{planName:d,price:P?s==="yearly"?re(Math.ceil(P/12)):re(Math.ceil(P)):0,originalMonthlyPrice:s==="yearly"?re(Math.ceil(g?.find(_=>_.subscription_type==="monthly")?.currency_wise_price?.find(_=>_?.currency?.toUpperCase()===n?.currency_name?.toUpperCase())?.final_price||0)):null,messagesQty:k?.messages_qty||0,features:Array.isArray(f)?f:Object.values(f||{}),payPerUseCost:W,id:k?.id}}),[e,n,s]),Y=c.useMemo(()=>{if(!e.length)return[];const h=new Set;e.forEach(d=>{Array.isArray(d.features_include)&&d.features_include.forEach(f=>{f.key&&h.add(f.key)})});const g=Array.from(h).map(d=>({key:d,tooltip:e[0]?.features_include?.find(f=>f.key===d)?.tooltip||`Information about ${d}`,values:e.map(f=>{const w=(Array.isArray(f.features_include)?f.features_include:Object.values(f.features_include||{})).find(W=>W.key===d);return w&&w.Value||""})}));
1return g.push({key:"Additional Cost Per Message",tooltip:"Cost applied per AI-generated message beyond your included quota.",values:y.map(d=>d.payPerUseCost!==void 0?`${ue(n?.currency_name)}${re(d.payPerUseCost)}`:"-")}),g},[e,y,n]),I=h=>{N(g=>g===h?null:h)},F=y.length>=6,b=j!=null,U=h=>u!=null?u===h?"Suggested":null:b&&j===h?"Selected":null,E=h=>t.jsxs($n,{compact:F?1:0,children:[t.jsx(Ln,{compact:F?1:0}),t.jsx(Dn,{compact:F?1:0,children:h})]}),O=(h,g)=>{const d=u===g,f=j===g,k=d||u==null&&f,w=U(g);return t.jsxs(On,{cell_index:g,plans_length:y.length,is_preselected:k?1:0,children:[t.jsxs(Ve,{children:[t.jsx(Qe,{variant:"h5",children:h.planName}),w&&E(w)]}),t.jsxs(i,{sx:{flex:1},children:[t.jsxs(Xe,{children:[t.jsxs(Je,{variant:"h4-semibold",sx:{fontSize:36},children:[ue(n?.currency_name),re(h.price)]}),s==="yearly"&&t.jsxs(Ze,{children:[ue(n?.currency_name),re(Math.ceil(e[g]?.packages?.find(P=>P.subscription_type==="monthly")?.currency_wise_price?.find(P=>P?.currency?.toUpperCase()===n?.currency_name?.toUpperCase())?.final_price||0))]}),t.jsx(et,{variant:"body-xs",children:"/month"})]}),t.jsx(tt,{variant:"body-xs",children:s==="yearly"?"(billed annually)":"(billed month-to-month)"})]}),t.jsx(X,{justifyContent:"center",sx:{mt:1},children:t.jsx(nt,{sm:!0,onClick:()=>a?.(h.id),children:r?"Select":"Start Free Trial"})})]},g)},C=()=>t.jsx(Wn,{children:t.jsx(Ce,{sx:{borderCollapse:"collapse"},children:t.jsx(Fe,{children:Y.map((h,g)=>t.jsx(Yn,{is_last:g===Y.length-1,children:t.jsxs(Nn,{children:[t.jsx(Un,{children:t.jsxs(Gn,{children:[t.jsx(x,{variant:"body",sx:{fontWeight:500,fontSize:"14px"},children:h.key}),t.jsx(ze,{title:h.tooltip,arrow:!0,placement:"top",children:t.jsx(Vn,{fontSize:"16px",color:"action"})})]})}),t.jsx(Kn,{column_count:y.length,children:y.map((d,f)=>t.jsx(qn,{cell_index:f,children:t.jsx(x,{variant:"body-sm",children:h.values[f]})},f))})]})},g))})})});return e.length?T?t.jsxs(Ge,{children:[t.jsx(qe,{billingType:s,onChange:p,isOnboarding:v}),t.jsx(i,{sx:{mt:2},children:$}),t.jsx(i,{sx:{mt:3},children:y.map((h,g)=>{const d=H===g,f=U(g),k=e[g]?.features_include?.find?.(w=>w.key==="User Sessions")?.Value;return t.jsxs(Qn,{sx:{mb:3},children:[t.jsxs(Hn,{children:[t.jsxs(Ve,{children:[t.jsx(Qe,{variant:"h5",children:h.planName}),f&&E(f)]}),k&&t.jsxs(x,{variant:"body-sm",color:"secondary.main",sx:{mb:2,display:"block",fontWeight:300},children:[k," user sessions"]}),t.jsxs(Xe,{sx:{mb:2},children:[t.jsxs(Je,{variant:"body-sm-medium",children:[ue(n?.currency_name),h.price]}),s==="yearly"&&h.originalMonthlyPrice&&t.jsxs(Ze,{children:[ue(n?.currency_name),h.originalMonthlyPrice]}),t.jsx(et,{variant:"body-xs",children:"/month"})]}),t.jsx(tt,{variant:"body-xs",children:s==="yearly"?"(billed annually)":"(billed month-to-month)"}),t.jsx(nt,{fullWidth:!0,onClick:()=>a?.(h.id),sx:{mt:2},children:r?"Select":"Start Free Trial"})]}),t.jsx(i,{sx:{borderTop:1,borderColor:"grey.200"}}),t.jsxs(Xn,{onClick:()=>I(g),children:[t.jsx(x,{variant:"body-sm",color:"grey.600",sx:{fontWeight:600,letterSpacing:1.2},children:"What's included"}),t.jsx(kt,{sx:{transform:d?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.3s",color:d?"primary.main":"grey.500"}})]}),t.jsx(_t,{in:d,timeout:"auto",unmountOnExit:!0,children:t.jsx(i,{sx:{borderTop:1,borderColor:"grey.200"},children:t.jsx(Ce,{size:"small",children:t.jsx(Fe,{children:Y.map((w,P)=>t.jsxs(je,{sx:{"&:not(:last-child)":{borderBottom:1,borderColor:"grey.200"}},children:[t.jsx(Zn,{sx:W=>({backgroundColor:P%2===0?W.palette.colors.neutral[50]:W.palette.common.white}),children:t.jsxs(i,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx(x,{variant:"body-sm",sx:{fontWeight:500},children:w.key}),t.jsx(ze,{title:w.tooltip,arrow:!0,placement:"top",children:t.jsx(dt,{sx:{fontSize:16,color:"grey.500",cursor:"pointer"}})})]})}),t.jsx(Jn,{sx:W=>({backgroundColor:P%2===0?W.palette.colors.neutral[50]:W.palette.common.white}),children:t.jsx(x,{variant:"body-sm",sx:W=>({color:W.palette.colors.neutral[700]}),children:w.values[g]})})]},P))})})})})]},g)})})]}):t.jsxs(Ge,{children:[t.jsx(qe,{billingType:s,onChange:p,isOnboarding:v}),t.jsx(In,{children:t.jsxs(Rn,{children:[t.jsx(En,{children:t.jsx(Ce,{sx:{borderCollapse:"separate",borderSpacing:0},children:t.jsx(Mt,{children:t.jsxs(je,{children:[t.jsx(Fn,{}),t.jsxs(zn,{colSpan:y.length,children:[$,t.jsx(An,{column_count:y.length,children:y.map((h,g)=>O(h,g))})]})]})})})}),t.jsx(i,{sx:{width:198,minWidth:198,maxWidth:198,mt:-2},children:t.jsx(x,{variant:"body-sm",sx:{fontWeight:600,textAlign:"left"},children:"What's included:"})})]})}),C()]}):t.jsx(i,{sx:{p:4,textAlign:"center"},children:t.jsx(x,{variant:"h6",color:"textSecondary",children:"No pricing plans available"})})},Ge=o(i)(({theme:{spacing:e}})=>({maxWidth:"100%",overflow:"hidden",overflowX:"auto",background:"white"})),In=o(i)(({theme:{spacing:e}})=>({paddingBottom:e(2),paddingTop:e(2)})),En=o(ut)(({theme:{customBorderRadius:e}})=>({boxShadow:"none",overflow:"hidden",overflowX:"auto",borderRadius:e.lg})),Wn=o(ut)(({theme:{spacing:e,palette:n,customBorderRadius:s}})=>({boxShadow:"none",border:`1px solid ${n.grey[200]}`,borderLeft:`1px solid ${n.grey[200]}`,borderRadius:s.lg,overflow:"hidden",overflowX:"auto"})),Rn=o(i)(()=>({overflow:"hidden",overflowX:"auto"})),Fn=o(he)(({theme:{spacing:e}})=>({width:198,minWidth:198,maxWidth:198,paddingTop:e(3),paddingBottom:e(3),border:"none",borderBottom:"none",boxSizing:"border-box"})),zn=o(he)(({theme:{palette:e,customBorderRadius:n}})=>({padding:0,border:`1px solid ${e.primary[500]}`,borderRadius:n.lg,overflow:"hidden"})),An=o(i,{shouldForwardProp:e=>e!=="column_count"})(({column_count:e})=>({display:"grid",gridTemplateColumns:`repeat(${e}
1, minmax(0, 1fr))`,overflow:"hidden",width:"100%"})),Ve=o(i)(({theme:{spacing:e,customSpacing:n}})=>({display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:"space-between",columnGap:n.xs,rowGap:n.xs,marginBottom:e(2)})),Qe=o(x)(({theme:{customFontWeight:e}})=>({fontWeight:e.semibold,whiteSpace:"nowrap",flexShrink:0})),$n=o(i,{shouldForwardProp:e=>e!=="compact"})(({theme:{palette:e,spacing:n,customSpacing:s,customBorderRadius:a},compact:r})=>({display:"inline-flex",alignItems:"center",flexShrink:0,marginLeft:"auto",gap:r?s["2xs"]:s.xs,height:r?s.lg+s["2xs"]:s["2xl"],padding:r?`${s["2xs"]}px ${s.xs}px`:n(.25,1),paddingLeft:r?s["2xs"]:s.xs,borderRadius:`${s.sm}px / ${a.xs}px`,backgroundColor:e.colors.blue[50]})),Ln=o(Ut,{shouldForwardProp:e=>e!=="compact"})(({theme:{palette:e,typography:n,customSpacing:s},compact:a})=>({fontSize:a?s.md:n["body-xs"].fontSize,color:e.colors.blue[500]})),Dn=o(x,{shouldForwardProp:e=>e!=="compact"})(({theme:{palette:e,customFontWeight:n,typography:s,customLineHeight:a,customSpacing:r},compact:p})=>({color:e.colors.blue[500],fontWeight:n.semibold,fontSize:p?r.md+r["2xs"]:s["body-xs"].fontSize,lineHeight:1,whiteSpace:"nowrap"})),Hn=o(i)(({theme:{spacing:e}})=>({padding:e(2)})),On=o(i,{shouldForwardProp:e=>e!=="is_preselected"})(({theme:{spacing:e,palette:n,customBorderRadius:s,customSpacing:a},cell_index:r,plans_length:p,is_preselected:u})=>({paddingTop:e(2),paddingBottom:e(2),paddingLeft:e(1.5),paddingRight:e(1.5),position:"relative",textAlign:"left",display:"flex",flexDirection:"column",backgroundColor:n.colors.system.white,borderRight:r<p-1?`1px solid ${n.colors.neutral[200]}`:"none",...u?{borderRadius:`${a.sm}px / ${s.xs}px`}:{...r===0&&{borderBottomLeftRadius:s.lg},...r===p-1&&{borderBottomRightRadius:s.lg}}})),Xe=o(i)(({theme:{spacing:e}})=>({display:"flex",marginBottom:e(1),justifyContent:"flex-start",alignItems:"center",flexWrap:"wrap",gap:e(.5)})),Ze=o(x)(({theme:{spacing:e,palette:n}})=>({textDecoration:"line-through",color:n.colors.neutral[700],fontWeight:300,fontSize:e(2),marginTop:e(-1)})),Je=o(x)(({theme:{palette:e,spacing:n}})=>({})),et=o(x)(({theme:{spacing:e,palette:n}})=>({fontWeight:400,lineHeight:e(2),fontSize:"12px",alignSelf:"flex-end",marginBottom:e(.5)})),tt=o(x)(({theme:{spacing:e}})=>({marginBottom:e(2),display:"block",fontWeight:400,lineHeight:e(2),fontSize:"12px"})),nt=o(ce)(({theme:{spacing:e}})=>({textTransform:"none",width:"100%",fontWeight:600,paddingTop:e(1),paddingBottom:e(1)})),Yn=o(je)(({theme:{palette:e},is_last:n})=>({borderBottom:n?"none":`1px solid ${e.grey[200]}`})),Nn=o(he)(()=>({display:"flex",alignItems:"stretch",justifyContent:"center",padding:0,border:"none",minHeight:"60px"})),Un=o(i)(({theme:{spacing:e,palette:n}})=>({minWidth:198,width:198,maxWidth:198,fontWeight:500,display:"flex",justifyContent:"center",alignItems:"center",flexWrap:"wrap",padding:e(2),fontSize:"14px",lineHeight:e(2.5)})),Kn=o(i,{shouldForwardProp:e=>e!=="column_count"})(({column_count:e})=>({display:"grid",gridTemplateColumns:`repeat(${e}, minmax(0, 1fr))`,flexGrow:1,minHeight:"100%",alignItems:"stretch"})),qn=o(i)(({theme:{spacing:e,palette:n},cell_index:s})=>({textAlign:"center",display:"flex",alignItems:"center",justifyContent:"center",width:"100%",minHeight:"100%",height:"100%",backgroundColor:s%2===0?n.colors.neutral[50]:n.background.paper,padding:e(2),color:n.colors.neutral[700],fontWeight:300,boxSizing:"border-box"})),Gn=o(i)(({theme:{spacing:e}})=>({display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"})),Vn=o(dt)(({theme:{palette:e}})=>({cursor:"pointer",color:e.grey[500]})),Qn=o(i)(({theme:{palette:e,customBorderRadius:n}})=>({border:`1px solid ${e.primary[500]}`,borderRadius:n.lg,overflow:"hidden",backgroundColor:e.colors.system.white})),Xn=o(i)(({theme:{spacing:e}})=>({display:"flex",justifyContent:"center",alignItems:"center",gap:e(2),padding:e(2),cursor:"pointer",transition:"background-color 0.2s","&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)"}})),Zn=o(he)(({theme:{spacing:e}})=>({padding:e(2),borderBottom:"none"})),Jn=o(he)(({theme:{spacing:e}})=>({padding:e(2),textAlign:"right",borderBottom:"none"})),es=({onClose:e,trialDays:n=15,botId:s})=>{const[a,r]=c.useState(""),p=ke(),{orgId:u,chatbotId:j}=me(),v=s||j,S=()=>{e(),localStorage.setItem("settingsTabName","Installation"),p(`/organizations/${u}/chatbots/${v}/settings`)};return c.useEffect(()=>{const T=at().add(n,"day");r(T.format("MMMM D, YYYY"))},[n]),t.jsxs(X,{flexDirection:"column",sx:{justifyContent:"center",alignItems:"center"},children:[t.jsxs(X,{flexDirection:"column",children:[t.jsx("img",{width:100,height:100,src:Yt,alt:"Success",style:{marginBottom:24}}),t.jsx(x,{variant:"h4-semibold",sx:{fontSize:"30px"},children:"Trial Activated!"})]}),t.jsxs(x,{variant:"body-xs",sx:{fontSize:"16px",my:1},children:["Your ",n,"-day free trial ends on ",a]}),t.jsx(i,{sx:{display:"flex",gap:2,width:"100%",mt:2},children:t.jsx(ce,{md:!0,fullWidth:!0,onClick:S,children:"Get Started"})})]})},ts=({open:e,onClose:n,...s})=>{const a=ke(),{orgId:r,chatbotId:p}=me(),u=()=>{n(),localStorage.setItem("settingsTabName","Installation"),a(`/organizations/${r}/chatbots/${p}/settings`)};return t.jsx(fe,{open:e,onClose:u,maxWidth:560,minWidth:560,contentSx:{pt:1,pb:3},children:t.jsx(es,{onClose:n,...s})})},ns=o(At)(({theme:e})=>({height:4,borderRadius:0,"&.MuiLinearProgress-root":{backgroundColor:e.palette.primary[100]},"& .MuiLinearProgress-bar":{borderRadius:0,backgroundColor:e.palette.primary[500]}})),cs=()=>{const e=we(),n=Bt(),{orgId:s,chatbotId:a}=me(),r=ke(),p=Tt(),u=Se(),j=!!p?.state?.fromSetupFlow,v=p?.state?.setupProgress,[S,T]=c.useState(!1),[A,H]=c.useState(!1),[N,$]=c.useState(!1),[y,Y]=c.useState(!1),[I,F]=c.useState(!1),[b,U]=c.useState({}),[E,O]=c.useState(!1),[C]=c.useState(15),h=c.useRef(""),g=c.useRef(null),{packageList:d,activeCurrency:f,getSelectedPlan:k,hasUsedTrial:w,isLoading:P,packageRefetch:W,botDetailsRefetch:_,monthlyTrafficKey:G}=Ht(a),{isExpiredTrialWithoutCard:Z}
1=It(a),K=Et(p?.state?.monthlyTrafficKey),R=G||K,L=c.useMemo(()=>Wt(d,R),[d,R]),M=c.useMemo(()=>{const l=Rt("selectedPlan");if(!l)return null;const m=l.match(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i);return m?m[0]:l.trim()},[]),se=c.useMemo(()=>{if(!M||!d.length)return null;let l=d.findIndex(m=>m.id===M);return l<0&&(l=d.findIndex(m=>m.packages?.some(B=>B.id===M))),l<0&&(l=d.findIndex(m=>m.package_name?.toLowerCase()===M.toLowerCase())),l>=0?l:null},[M,d]),J=c.useMemo(()=>{if(!M||!d.length)return null;const l=d.find(B=>B.packages?.some(q=>q.id===M))||d.find(B=>B.id===M);if(l){const q=l.packages?.find(te=>te.id===M)?.subscription_type;return q==="annual"?"yearly":q||null}const m=M.match(/(monthly|yearly|annual)$/i);return m?m[1].toLowerCase()==="annual"?"yearly":m[1].toLowerCase():null},[M,d]),[V,de]=c.useState("yearly");c.useEffect(()=>{J&&de(J)},[J]);const{data:oe={}}=Pe(a),pe=oe?.success?oe?.data?.id:null,D=oe?.success?oe?.data?.card:null,z=async(l=!0,m=null)=>{try{if(O(!0),!l&&m&&!m?.success){O(!1);return}if(!b?.id){O(!1),u({success:!1,message:"No plan selected"});return}const B=await e(`subscription/client/trial/set-trial-period/${b.id}/?bot_id=${a}`,"POST",{});await W(),await _(),B?.success?(n.invalidateQueries({queryKey:[ie]}),n.invalidateQueries({queryKey:[Ae]}),n.invalidateQueries({queryKey:[$e]}),n.invalidateQueries({queryKey:[le]}),O(!1),l&&F(!1),setTimeout(()=>{Y(!0),U({})},400),zt({event:"complete_subscription",link_text:l||m?"Complete Subscription":"Start Free Trial",content_type:"complete subscription",link_url:window.location.href})):(O(!1),u(B||{success:!1,message:"Trial activation failed"}))}catch(B){O(!1),u({success:!1,message:B?.message||"Failed to activate trial"})}},ee=c.useCallback(async l=>{try{const m=await e(`subscription/client/payment/create-stripe-payment-intent/${l}/?bot_id=${a}`,"POST",{});if(!m?.success)return u(m),null;const B=m?.data?.clientSecret||"";return h.current=B,g.current=l,B}catch(m){return console.error("Error creating payment intent",m),u({success:!1,message:"Failed to create payment intent"}),null}},[e,a,u]),ae=c.useCallback(l=>{const m=d.find(be=>be.packages?.some(Ct=>Ct.id===b?.id));if(!m)return;const B=l==="yearly"?["annual","yearly"]:["monthly"],q=m.packages?.find(be=>B.includes(be.subscription_type));if(!q)return;const te=k(q.id);te&&(de(l),U(te))},[d,b,k]),ye=c.useCallback(async l=>{const m=k(l);if(!m){u({success:!1,message:"Plan details not found"});return}$(!1),T(!1),F(!1),U(m),w?D?F(!0):T(!0):D?F(!0):$(!0)},[D,k,w]),Q=c.useCallback(async l=>{if(!b?.id)return u({success:!1,message:"Please select a plan."}),{success:!1};if(!l)return u({success:!1,message:"Payment method not available."}),{success:!1};try{let m=h.current;if((!m||g.current!==b.id)&&(m=await ee(b.id),!m))return{success:!1};const B=await Me("pk_live_51Q7DoYRoJcs6tsRnZqmxt4iCKCPpADBfcXleLi3nlnmYmsimfBiBDtB2Z6pF4RafsrI9wIYLylEaXBphyB9G4R4n00k5lpK58P");if(!B)return u({success:!1,message:"Payment system unavailable"}),{success:!1};const{paymentIntent:q,error:te}=await B.confirmCardPayment(m,{payment_method:l,return_url:window.location.href.replace("pricing","complete")});return te?(u({success:!1,message:te?.message||"Something went wrong"}),{success:!1}):q?.status==="succeeded"?(n.invalidateQueries({queryKey:[ie]}),n.invalidateQueries({queryKey:[Ae]}),n.invalidateQueries({queryKey:[$e]}),n.invalidateQueries({queryKey:[le]}),r(`/organizations/${s}/chatbots/${a}/complete`),{success:!0}):q?.status==="requires_action"?(u({success:!1,message:"Additional authentication required."}),{success:!1}):{success:!1}}catch(m){return console.error("Error confirming payment",m),u({success:!1,message:m?.message||"Payment confirmation failed"}),{success:!1}}},[b,ee,r,s,a,u,n]),yt=c.useCallback(async()=>{(await Q(pe))?.success&&F(!1)},[Q,pe]),bt=c.useCallback(async l=>{T(!1),H(!0);try{await Q(l)}finally{H(!1)}},[Q]);if(E||P||A)return t.jsx(Ft,{});const We=t.jsxs(t.Fragment,{children:[t.jsxs(Kt,{isOnboarding:j,children:[Z&&t.jsx(Ot,{showAction:!1,sx:{mb:3,textAlign:"left"}}),!j&&t.jsxs(X,{flexDirection:"column",alignItems:"center",sx:{textAlign:"center"},children:[t.jsx(x,{variant:"h4-semibold",children:"Flexible pricing options for every business"}),t.jsx(x,{variant:"body-sm",children:"Chatbot that will delight your users and answer the questions about your products and services"})]}),t.jsx(Tn,{packages:d,billingType:V,onSelect:ye,freeTrial:w,currency:f,setBillingType:de,suggestedPlanIndex:L,preSelectedPlanIndex:se,isOnboarding:j,progressValue:v||66}),t.jsx(Bn,{})]}),S&&t.jsx(Mn,{open:S,onClose:()=>T(!1),selectedPlan:b,billingType:V,onBillingChange:ae,isOnboarding:j,onCardAdded:bt}),N&&t.jsx(Cn,{open:N,onClose:()=>$(!1),selectedPlan:b,billingType:V,onBillingChange:ae,hasUsedTrial:w,onTrialActivated:(l,m)=>{$(!1),z(l,m)},isOnboarding:j}
1),I&&t.jsx(Sn,{defaultCardDetails:D,defaultCardPaymentModal:I,onCloseDefaultCardModal:()=>F(!1),handleActivateTrialWithDefaultCard:z,handleConfirmPurchaseWithDefaultCard:yt,hasUsedTrialPeriod:w,trialDays:C,selectedPlan:b,billingType:V,onBillingChange:ae,isOnboarding:j}),t.jsx(ts,{open:y,onClose:()=>Y(!1),trialDays:C,planName:b.name})]});return j?t.jsxs(i,{sx:{display:"flex",flexDirection:"column",height:"100%"},children:[t.jsx(i,{sx:l=>({mt:-4,mx:-2,mb:0,overflow:"hidden",borderRadius:"12px 12px 0 0",position:"sticky",top:0,zIndex:1,[l.breakpoints.down("sm")]:{mt:-2,mx:-1}}),children:t.jsx(ns,{variant:"determinate",value:v||66})}),t.jsx(i,{sx:{display:{xs:"flex",md:"none"},justifyContent:"flex-end",alignItems:"center",px:3,pt:2},children:t.jsxs(Le,{onClick:()=>r(`/organizations/${s}/chatbots`),size:"small",sx:{gap:.5,borderRadius:l=>l.customBorderRadius.pill,color:l=>l.palette.colors.neutral[500],"&:hover":{backgroundColor:"transparent",color:l=>l.palette.colors.neutral[700]}},children:[t.jsx(De,{fontSize:"small"}),t.jsx(x,{variant:"body-sm",sx:{textTransform:"none",color:"inherit"},children:"Cancel setup"})]})}),t.jsxs(X,{flexDirection:"column",alignItems:"center",sx:{textAlign:"center",mt:3,px:3,position:"relative"},children:[t.jsx(x,{variant:"h4-semibold",children:"Your chatbot setup is almost complete"}),t.jsx(x,{variant:"body-sm",sx:{mb:4},children:"Choose a plan to activate your 15-day free trial. No charge during trial, upgrade or cancel anytime."}),t.jsx(i,{sx:{display:{xs:"none",md:"flex"},position:"absolute",right:24,top:0},children:t.jsxs(Le,{onClick:()=>r(`/organizations/${s}/chatbots`),size:"small",sx:{gap:.5,borderRadius:l=>l.customBorderRadius.pill,flexShrink:0,color:l=>l.palette.colors.neutral[500],"&:hover":{backgroundColor:"transparent",color:l=>l.palette.colors.neutral[700]}},children:[t.jsx(De,{fontSize:"small"}),t.jsx(x,{variant:"body-sm",sx:{textTransform:"none",color:"inherit"},children:"Cancel setup"})]})})]}),t.jsx(He,{children:We})]}):t.jsx(He,{children:We})};export{cs as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.