1import{Q as et,m,ax as ot,r as c,as as h,an as at,t as it,c1 as k,b$ as nt,j as t,bi as s,B as $,T as u,S as g,c2 as st,M as _,a8 as rt,i as B,h as H,at as ct,c3 as lt,c4 as pt,bd as ut,bh as n,P as dt}from"./index-Ece0SzLF.js";import{D as mt}from"./DialogHeader-Bfgcxt23.js";import{O as ht}from"./index-xtp0spi8.js";import{L as xt}from"./index-DlssC2RQ.js";import{u as ft,M as P,h as Pt,A as gt}from"./useAutoPay-DKqbM94w.js";import{d as yt}from"./InfoOutlined-CtvbudJx.js";import{D as At}from"./DialogContent-CXY4PECt.js";import{I as G}from"./InputAdornment-jm20PLMy.js";import{T as St}from"./Tooltip-qdTI5Uu7.js";import{a as Tt}from"./TextField-BfNPitYc.js";import{D as Dt}from"./DialogActions-BQQjYYyh.js";import"./FormControlLabel-HmYKRb_C.js";import"./SwitchBase-D6yeZMCG.js";import"./Popper-BtfpxQmG.js";const It=C=>{const{apiPlanRates:x,pricingApiStatus:L}=m(o=>o.pricingDialog),D=(o,y)=>{if(y==="minutes"){const r=Math.floor(o/60),d=Math.floor(o%60);return r>0?`${r}h ${d}m`:`${d}m`}const f=(r,d)=>r%1===0?r+d:r.toFixed(1)+d;return o>=1e6?f(o/1e6,"M"):o>=1e3?f(o/1e3,"K"):o.toString()};return L===h.LOADING?t.jsx(g,{height:"100%",alignItems:"center",justifyContent:"center",children:t.jsx(ct,{})}):t.jsxs(g,{spacing:.5,p:.5,children:[t.jsx(u,{variant:"caption",color:"text.secondary",children:"Your Top-up amount offers:"}),x.map((o,y)=>{const f=Math.floor(C/o.price*10)/10*(o.unit==="characters"?1e4:1);return t.jsxs(g,{spacing:.3,children:[t.jsxs(u,{variant:"caption",color:"text.secondary",children:[t.jsx(u,{component:"span",variant:"caption",color:"text.primary",fontWeight:"bold",children:D(f,o.unit)})," ",o.unit," for ",o.name]}),y<x.length-1&&t.jsx(u,{variant:"caption",color:"text.secondary",children:"or"})]},o.id)}),x.length>1&&t.jsx(u,{variant:"caption",color:"text.secondary",children:"A combination of the above as per your needs."})]})},Ft=()=>{const C=et(),{checkoutPlan:x,topupValue:L}=m(e=>e.pricingDialog.checkoutDetails),{entryPoint:D,calculatedFunds:o,autoPayTopUpValues:y}=m(e=>e.pricingDialog),{UserEnrichDetails:f}=m(e=>e.workspace),{useStripeIndia:r}=m(e=>e.workspace),{activeTheme:d}=ot(),A=r?lt:pt,[a,I]=c.useState(o??L),[l,K]=c.useState(!0),[S,z]=c.useState(y.autoPayLowerLimit??5),[T,W]=c.useState(y.autoPayUpperLimit??20),[E,Y]=c.useState({}),[v,N]=c.useState(h.IDLE),i=at(),{trackMixpanelEvent:U}=it(),{validateAutoPay:O}=ft(),{pricingApiStatus:M}=m(e=>e.pricingDialog),{workspaceId:R}=m(e=>e.workspace),{calculatorEntryPoint:b}=m(e=>e.pricingDialog),[F,j]=c.useState(!1),p=(e,V)=>{Y(tt=>({...tt,[e]:V}))},w=c.useCallback(()=>{let e=!0;return a>=k?j(!0):j(!1),isNaN(a)||a<P?(p("topupValue",`Minimum amount $${P}`),e=!1):a>A?(p("topupValue",`Maximum amount $${A}`),e=!1):p("topupValue",""),O({autoPayEnabled:l,autoPayLowerLimit:S,autoPayUpperLimit:T,updateErrorMessages:p})?(p("autoPayLowerLimit",""),p("autoPayUpperLimit","")):e=!1,e},[l,S,T,a,O]),X=async()=>{if(w())try{N(h.LOADING),U(_.UPGRADE_SETUP_SUCCESS,{"Top-Up Amount":a,"AutoPay Enabled":l?"Yes":"No","Balance Threshold":l?S:null,"Recharge Amount":l?T:null,"Entry Point":D}),await i(ut.updateAutoPayData({autoPayEnabled:l,autoPayLowerLimit:l?S:5,autoPayUpperLimit:l?T:100})).unwrap(),i(n.actions.setTopupValue(a)),i(n.actions.setAutoPayTopUpValues({autoPayUpperLimit:T,autoPayLowerLimit:S})),i(n.actions.setActiveStep(s.CHECKOUT)),N(h.SUCCESS)}catch(e){p("root",e.toString()),N(h.ERROR)}},q=()=>{o&&i(n.actions.setCalculatedFunds(null)),x?.entryPoint===s.PRICING_PLANS?b===s.PRICING_PLANS||b===s.SETUP_FUNDS?i(n.actions.setActiveStep(s.CALCULATE_FUNDS)):i(n.actions.setActiveStep(s.PRICING_PLANS)):x?.entryPoint==="DASHBOARD_TOPUP"?b===s.SETUP_FUNDS?i(n.actions.setActiveStep(s.CALCULATE_FUNDS)):i(n.actions.setPricingDialog(!1)):i(n.actions.setPricingDialog(!1))},Q=()=>{i(n.actions.setPricingDialog(!1))},J=()=>{U(_.CALCULATOR_OPENED,{"Entry Point":"API setup funds page","Stripe Account Type":r?"India":"US",...f}),i(n.actions.setActiveStep(s.CALCULATE_FUNDS)),i(n.actions.setCalculatorEntryPoint(s.SETUP_FUNDS))},Z=()=>{U(_.CONTACT_SALES_CLICK,{"Entry Point":"API setup funds page","Stripe Account Type":r?"India":"US",...f}),window.open(dt+"/falcon?openPopup=true&src=d_contact_sales_api_falcon_form")};return c.useEffect(()=>{isNaN(a)||a<P?(I(P),p("topupValue",`Minimum amount $${P}`)):a>A&&(I(A),p("topupValue",`Maximum amount $${A}`)),a>=k&&j(!0)},[]),c.useEffect(()=>{M===h.IDLE&&i(nt.fetchPricingPlans({workspaceId:R}))},[i,M,R]),t.jsxs(t.Fragment,{children:[t.jsx(mt,{title:x?.entryPoint===s.PRICING_PLANS?"Set up funds":"Top-up",onClose:Q}),t.jsx(At,{dividers:!0,sx:{padding:3,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column"},children:t.jsxs($,{maxWidth:600,children:[t.jsx(u,{variant:"h6",mb:3,children:"Add funds to your account"}),t.jsx(u,{variant:"body2",mb:3,children:"The funds in your account are consumed based on your usage across different API endpoints."}),t.jsxs(g,{direction:"row",alignItems:"center",gap:3,justifyContent:"space-between",mb:F?4:7,children:[t.jsxs(g,{direction:"row",alignItems:"center",gap:1,children:[t.jsx(u,{variant:"subtitle1",component:"label",htmlFor:`${C}topup`,whiteSpace:"nowrap",children:"Top-up Amount"}
1),t.jsx(ht,{size:"small",sx:{"& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button":{display:"none"},"& input[type=number]":{MozAppearance:"textfield"},width:150},FormHelperTextProps:{sx:{width:"250px",whiteSpace:"normal",wordBreak:"break-word",minHeight:"20px",position:"absolute",bottom:"-24px"}},id:`${C}topup`,value:a,type:"number",onChange:e=>{isNaN(Number(e.target.value))?I(P):I(e.target.value)},onKeyDown:e=>{st(e)&&e.preventDefault()},onBlur:()=>{U(_.TOP_UP_AMOUNT_MODIFIED,{"Top-Up Amount":a,"Entry Point":D}),w(),I(Pt(a,P,A))},error:!!E.topupValue,helperText:E.topupValue,InputProps:{startAdornment:t.jsx(G,{position:"start",children:"$"}),endAdornment:t.jsx(G,{position:"end",children:t.jsx(St,{title:It(a),placement:"right",arrow:!0,componentsProps:{tooltip:{sx:{backgroundColor:d==="light"?"white":"black","& .MuiTooltip-arrow":{color:d==="light"?"white":"black"}}},arrow:!0},children:t.jsx(rt,{size:"small",children:t.jsx(yt,{fontSize:"small"})})})}),inputProps:{min:0}}})]}),t.jsx(g,{direction:"row",alignItems:"center",gap:1,children:t.jsx(u,{variant:"body2",color:"primary.light",fontWeight:500,sx:e=>({cursor:"pointer",textDecoration:"underline",textDecorationColor:e.palette.primary.light,textDecorationThickness:"1px",textUnderlineOffset:"3px"}),onClick:J,children:"Calculate Your Requirement"})})]}),F&&t.jsx(B,{severity:"info",sx:{bgcolor:"#2B96F91A",mb:3,display:"flex",alignItems:"center"},children:t.jsxs(g,{direction:"row",spacing:1,alignItems:"center",flexWrap:"nowrap",width:"100%",children:[t.jsxs($,{flexShrink:1,children:["For top-ups over ",`$${k}`,", contact our sales team to explore bulk discount offers."]}),t.jsx(H,{sx:{height:"100%",display:"block",whiteSpace:"nowrap",flexShrink:0},variant:"contained",color:"secondary",onClick:Z,children:"Contact Sales"})]})}),t.jsx(gt,{autoPayEnabled:l,autoPayLowerLimit:S,autoPayUpperLimit:T,entryPoint:D,setAutoPayEnabled:K,setAutoPayLowerLimit:z,setAutoPayUpperLimit:W,errorMessage:E,validate:w}),t.jsx(B,{severity:"info",sx:{bgcolor:"#2B96F91A"},children:"You can modify the auto-pay details in your account settings at any time."}),v===h.ERROR&&t.jsx(Tt,{sx:{textAlign:"center"},error:!0,children:E.root})]})}),t.jsxs(Dt,{sx:{p:3,gap:2},disableSpacing:!0,children:[t.jsx(H,{onClick:q,variant:"text",color:"secondary",children:"Back"}),t.jsx(xt,{loading:v===h.LOADING,onClick:X,variant:"contained",children:"Proceed to Pay"})]})]})};export{Ft 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.