PageSourceSearch

https://app.metty.ai/assets/SubscriptionPlan-DCMOw6z_.js

js metty.ai collected 2026-10-05 14:00:21 UTC 29,840 bytes, 4 lines download raw bytes

1import{b0 as n,bn as ct,be as Je,bd as Qe,aU as e,aY as mt,ar as xt,l as oe,h as ut,m as ht,L as gt,ad as ft,aw as j,af as se,ac as De,aP as de,ag as ce,bb as yt,bc as pt,ba as bt,Z as wt,w as jt,c as Nt}from"./index-DzBlipNH.js";import{L as vt}from"./LayerContent-B4Jx8IGs.js";import{a as kt,l as Ct}from"./mettyMain-BGaWZB30.js";import{B as St,C as It}from"./Coupons-BLKtw6e6.js";import{T as ae}from"./tag-qarRE1PE.js";import{L as qe}from"./lock-IkyGh816.js";import{R as et}from"./rocket-BSA_X3Fs.js";import{S as tt}from"./sparkles-DcUdiNy9.js";import"./CountryCode-CQlkXvut.js";import"./receipt-Cyqr3XGE.js";const Pt=({isOpen:A,onClose:v,subscriptionPlan:l,onSuccess:W,userBillingInfo:me})=>{var he,ge,fe,ye,pe,be,we,je,Ne,ve,ke,Ce,Se,Ie,Pe,Ae,Le,Me,Ee,Fe,Te,ze,Be,_e,Re,Ue,$e,Ge;const[O,k]=n.useState(!1),[y,z]=n.useState(!1),[B,C]=n.useState(""),[g,re]=n.useState(!1),[t,N]=n.useState(null),[L,V]=n.useState(null),[S,M]=n.useState(null),[H,_]=n.useState(null),{theme:le}=ct(),Z=n.useRef(null),{user:o}=Je(s=>s.auth),[E,b]=n.useState(!1),[R,U]=n.useState(!1),[xe,ue]=n.useState(null),[K,F]=n.useState(!1),[I,Y]=n.useState(!1),T=(he=o==null?void 0:o.profile)==null?void 0:he.billingDetails,[c,X]=n.useState(me||T||null),q=Qe(),[J,$]=n.useState(!1),[Q,G]=n.useState(!1),a=window.location.hostname==="metty.ai"||window.location.hostname==="www.metty.ai"||window.location.hostname==="admin.metty.ai"||window.location.hostname==="app.metty.ai",r=s=>{switch(s){case"Free":return e.jsx(se,{className:"w-6 h-6"});case"Plus":return e.jsx(tt,{className:"w-6 h-6"});case"Pro":return e.jsx(et,{className:"w-6 h-6"});case"ProMax":return e.jsx(De,{className:"w-6 h-6"});default:return e.jsx(se,{className:"w-6 h-6"})}},u=s=>{switch(s){case"Plus":return"from-primary-700 to-primary-500";case"Pro":return"from-primary-700 to-primary-500";case"ProMax":return"from-primary-700 to-primary-500";default:return"from-primary-700 to-primary-500"}};n.useEffect(()=>{!c&&T&&X(T)},[T]);const p=s=>(console.log("Normalizing checkout response:",s),s?s.saved?s:{saved:s,eligibleCoupons:s.eligibleCoupons}:null);async function f(){if(!(!A||!(l!=null&&l.planName))){z(!0);try{const s=await j.post("/wallet/checkout",{product:"SUBSCRIPTION",planId:l.planName,...l.accessCode?{accessCode:l.accessCode}:{},metadata:{planName:l.planName,packageName:l.packageName,durationDays:l.durationDays,features:l.features,credit:l.credit,perDayLimit:l.perDayLimit}});if(console.log("Subscription checkout response:",s),s.ok&&s.checkout){const i=p(s.checkout);N(i),V(m=>m??i),M(null)}else throw new Error("Failed to fetch checkout details")}catch(s){console.error("Error fetching checkout details:",s),C("Failed to load checkout details. Please try again.")}finally{z(!1)}}}n.useEffect(()=>{f()},[A,l==null?void 0:l.planName]);const ne=s=>{X(s)},ie=async()=>{var s,i,m,x,h,D,We,Oe,Ve,He,Ze,Ke,Ye;if(!g){C("Please agree to the Terms of Service");return}if(!((s=t==null?void 0:t.saved)!=null&&s.checkoutId)){C("Checkout not initialized");return}k(!0),C(""),yt({plan_name:l.planName,package_name:l.packageName,value:l.amount,currency:l.currency,duration_days:l.durationDays,checkout_id:(i=t==null?void 0:t.saved)==null?void 0:i.checkoutId,flow:"subscription"});try{console.log("Checkout data:",t);const d=await j.post("/wallet/checkout/order",{checkoutId:(m=t==null?void 0:t.saved)==null?void 0:m.checkoutId});if(!window.Razorpay){const w=document.createElement("script");w.src="https://checkout.razorpay.com/v1/checkout.js",w.async=!0,document.body.appendChild(w),await new Promise((ee,te)=>{w.onload=ee,w.onerror=te})}const dt={key:a?"rzp_live_SeZlgAzpeR9Sj7":"rzp_test_SeZtAf2BXmLTNJ",name:"Metty Subscription",amount:(h=(x=d==null?void 0:d.payment)==null?void 0:x.razorpay)==null?void 0:h.amountMinor,currency:(We=(D=d==null?void 0:d.payment)==null?void 0:D.razorpay)==null?void 0:We.currency,order_id:(Ve=(Oe=d==null?void 0:d.payment)==null?void 0:Oe.razorpay)==null?void 0:Ve.orderId,handler:async w=>{var ee,te;try{if(await j.post("/wallet/checkout/order/payment-state",{orderId:(ee=d==null?void 0:d.order)==null?void 0:ee.id}))pt({transactionId:w==null?void 0:w.razorpay_payment_id,value:l.amount,currency:l.currency,planName:l.planName,package_name:l.packageName,duration_days:l.durationDays,order_id:(te=d==null?void 0:d.order)==null?void 0:te.id,flow:"subscription"}),ce.fire({icon:"success",title:"Subscription Successful!",text:`Your ${l.packageName} plan has been activated.`,confirmButtonColor:"#6366F1"}),W==null||W(),q(de()),v();else throw new Error("Subscription update failed")}catch(Xe){console.error("Verification error:",Xe),bt("Payment Verification Failed",{flow:"subscription",plan_name:l.planName}),C("Payment verification failed. Please contact support."),k(!1)}},notes:{...(Ze=(He=d==null?void 0:d.payment)==null?void 0:He.razorpay)==null?void 0:Ze.notes,planName:l.planName,type:"SUBSCRIPTION"},prefill:{name:(o==null?void 0:o.firstName)+" "+(o==null?void 0:o.lastName)||"Customer",email:(o==null?void 0:o.email)||"",contact:(o==null?void 0:o.mobileNo)||""},theme:{color:"#1DBF73"},modal:{ondismiss:()=>{k(!1)},escape:!1,backdrop_close:!1}};new window.Razorpay(dt).open()}catch(d){console.error("Payment error:",d),C(((Ye=(Ke=d.response)==null?void 0:Ke.data)==null?void 0:Ye.message)||"Payment failed. Please try again."),k(!1)}},at=async s=>{var i,m,x;if(!((i=t==null?void 0:t.saved)!=null&&i.checkoutId)&&!((m=t==null?void 0:t.saved)!=null&&m.id))return!1;F(!0);try{const h=await j.patch("/wallet/checkout/update",{checkoutId:(x=t==null?void 0:t.saved)==null?void 0:x.id,couponCode:s});if(h!=null&&h.ok){const D=p(h);return N(D),M((h==null?void 0:h.coupon)||null),!0}return!1}catch(h){return console.error("Failed to apply coupon:",h),!1}finally{F(!1)}},st=async()=>{var s;G(!0);try{const i=await j.patch("/wallet/checkout/update",{walletUsed:!0,checkoutId:(s=t==null?void 0:t.saved)==null?void 0:s.id});if(i!=null&&i.ok){const m=p(i);return N(m),_(m),!0}return!1}catch(i){return console.error("Failed to apply wallet:",i),!1}finally{G(!1)}},rt=async()=>{var s,i,m;if(!(!((s=t==null?void 0:t.saved)!=null&&s.checkoutId)&&!((i=t==null?void 0:t.saved)!=null&&i.id))){F(!0);try{const x=await j.patch("/wallet/checkout/update",{checkoutId:(m
1=t==null?void 0:t.saved)==null?void 0:m.id,couponCode:null});x!=null&&x.ok&&(H?N(H):L&&N(L),M(null))}catch(x){throw console.error("Failed to remove coupon:",x),x}finally{F(!1)}}};function lt(s){return s==null||isNaN(Number(s))?0:Number(s)/100}function P(s){return`₹${lt(s).toFixed(2)}`}function nt(...s){return s.reduce((i,m)=>{const x=Number(m);return isNaN(x)?i:i+x},0)}n.useEffect(()=>{const s=i=>{i.key==="Escape"&&v()};return A&&(window.addEventListener("keydown",s),document.body.style.overflow="hidden"),()=>{window.removeEventListener("keydown",s),document.body.style.overflow="unset"}},[A,v]);const it=Number(((fe=(ge=t==null?void 0:t.saved)==null?void 0:ge.breakdown)==null?void 0:fe.payableViaGatewayMinor)||0)===0,ot=async()=>{var s;$(!0);try{await j.post("/wallet/checkout/order",{checkoutId:(s=t==null?void 0:t.saved)==null?void 0:s.checkoutId})&&(v(),q(de()),ce.fire({icon:"success",title:"Subscription Activated!",text:"Your subscription has been activated successfully"}))}catch(i){throw console.error("Failed to place order without payment:",i),i}finally{$(!1)}};return A?e.jsxs(e.Fragment,{children:[E&&e.jsx(St,{initialData:c,userId:o==null?void 0:o.id,checkoutId:(ye=t==null?void 0:t.saved)==null?void 0:ye.id,onSave:ne,onLoadingChange:U,isOpen:E,onClose:()=>b(!1)}),e.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center z-50 justify-center p-4 overflow-y-auto",children:e.jsxs(mt.div,{ref:Z,initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},className:"relative bg-white dark:bg-gray-900 rounded-xl shadow-2xl w-full max-w-7xl my-auto flex flex-col lg:flex-row overflow-hidden max-h-[95vh]",children:[e.jsx("button",{onClick:v,className:"absolute right-4 top-4 z-10 p-2 bg-white/90 dark:bg-gray-800/90 backdrop-blur-sm hover:bg-white dark:hover:bg-gray-700 rounded-full transition-colors shadow-lg",children:e.jsx(xt,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"})}),e.jsxs("div",{className:"lg:w-2/3 p-6 lg:p-8 border-r border-gray-200 dark:border-gray-800 overflow-y-auto",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:le==="dark"?e.jsx("img",{src:kt,alt:"GoPluto Logo",className:" h-10 object-contain "}):e.jsx("img",{src:Ct,alt:"GoPluto Logo",className:"h-10 object-contain"})}),e.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:"Subscription Payment"})]}),y?e.jsx("div",{className:"flex flex-col items-center justify-center py-12",children:e.jsx("div",{className:"w-16 h-16 border-4 border-primary-600  border-t-transparent rounded-full animate-spin mb-4"})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-gradient-to-r from-gray-50 to-white dark:from-gray-800 dark:to-gray-900 rounded-xl p-6 mb-8 border border-gray-200 dark:border-gray-700 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-start justify-between mb-4 gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg bg-gradient-to-r ${u(l.planName)} text-white`,children:r(l.planName)}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:l.packageName}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(ae,{className:"w-4 h-4 text-primary dark:text-secondary"}),e.jsx("span",{className:"text-primary dark:text-secondary font-semibold",children:"Subscription Plan"})]})]})]})}),e.jsx("div",{className:"flex flex-col items-end",children:e.jsxs("span",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:["₹",l==null?void 0:l.amount]})})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3",children:"Plan Features:"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2",children:l.features.slice(0,6).map((s,i)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-green-500 flex-shrink-0"}),e.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:s})]},i))})]})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ut,{className:"w-5 h-5 text-primary dark:text-secondary "}),e.jsxs("h3",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:["Billing Information"," ",e.jsx("span",{className:"text-red-700",children:"*"})]})]}),c&&!E&&e.jsx("button",{onClick:()=>b(!0),className:"text-base text-primary dark:text-secondary underline font-semibold",children:"Edit"})]}),c?e.jsx("div",{className:"bg-white dark:bg-gray-800 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Name:"}),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:c.fullName})]}),c.companyName&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Company:"}),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:c.companyName})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Address:"}),e.jsxs("span",{className:"text-sm text-gray-900 dark:text-white text-right",children:[c.addressLine1,c.addressLine2&&e.jsx("br",{}),c.addressLine2,c.city&&`, ${c.city}`,c.stateOrRegion&&`, ${c.stateOrRegion}
1`,c.postalCode&&` - ${c.postalCode}`]})]}),c.taxId&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"Tax ID:"}),e.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:c.taxId.value})]})]})}):e.jsx("div",{className:"",children:e.jsx("button",{onClick:()=>b(!0),disabled:R,className:"text-sm underline text-gray-700 dark:text-gray-300",children:R?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Loading..."]}):"Add Billing Information"})})]}),e.jsxs("div",{className:"mb-4 flex justify-between items-center",children:[e.jsx("div",{className:"flex gap-2 items-center",children:e.jsx("h1",{className:"font-semibold flex gap-2",children:"Available Wallet Balance"})}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsxs("p",{className:"font-semibold",children:["₹ ",(be=(pe=t==null?void 0:t.saved)==null?void 0:pe.breakdown)==null?void 0:be.walletBalanceMinor]}),e.jsx("button",{onClick:()=>st(),className:"px-4 py-2 bg-primary dark:bg-secondary text-white font-medium rounded-md disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 text-sm",children:Q?e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsx("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Applying..."]}):"Apply"})]})]}),e.jsx("div",{children:(t==null?void 0:t.eligibleCoupons)&&t.eligibleCoupons.length>0&&e.jsx(It,{eligibleCoupons:t.eligibleCoupons,checkoutId:(we=t==null?void 0:t.saved)==null?void 0:we.checkoutId,onApplyCoupon:at,onRemoveCoupon:rt,appliedCouponCode:(je=t.saved)==null?void 0:je.couponCode,isLoading:K||y,discountMinor:S==null?void 0:S.previewDiscountMinor})})]})]}),e.jsx("div",{className:"lg:w-1/3 bg-gradient-to-b from-gray-50 to-white dark:from-gray-800 dark:to-gray-900 p-6 lg:p-8 border-t lg:border-t-0 lg:border-l border-gray-200 dark:border-gray-800",children:e.jsxs("div",{className:"sticky top-0 lg:h-full flex flex-col",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("button",{onClick:()=>Y(!I),className:"flex items-center justify-between w-full text-left",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-gray-900 dark:text-white",children:"Total Amount"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:I?"Click to collapse details":"Click to view breakdown"})]}),e.jsx("div",{className:"p-2 rounded-full shadow-md h-fit mt-8",children:e.jsx(ht,{className:`w-5 h-5 text-gray-500 transition-transform duration-200 ${I?"rotate-180":""}`})})]}),!I&&e.jsxs("div",{className:"mt-4",children:[e.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:P((ve=(Ne=t==null?void 0:t.saved)==null?void 0:Ne.breakdown)==null?void 0:ve.payableViaGatewayMinor)}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:"All taxes included"})]})]}),y?e.jsx("div",{className:"space-y-3 animate-pulse",children:[...Array(5)].map((s,i)=>e.jsxs("div",{className:"flex justify-between items-center py-2",children:[e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/3"}),e.jsx("div",{className:"h-4 bg-gray-200 dark:bg-gray-700 rounded w-1/4"})]},i))}):e.jsxs(e.Fragment,{children:[I&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Subscription Amount"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:P((Ce=(ke=t==null?void 0:t.saved)==null?void 0:ke.breakdown)==null?void 0:Ce.subtotalMinor)})]}),e.jsxs("div",{className:"border-t border-gray-200 dark:border-gray-700 pt-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Subtotal"}),e.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:P(nt((Ie=(Se=t==null?void 0:t.saved)==null?void 0:Se.breakdown)==null?void 0:Ie.subtotalMinor,(Ae=(Pe=t==null?void 0:t.saved)==null?void 0:Pe.breakdown)==null?void 0:Ae.platformFeeMinor))})]}),((Me=(Le=t==null?void 0:t.saved)==null?void 0:Le.breakdown)==null?void 0:Me.walletAppliedMinor)>0&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Wallet Applied"}),e.jsxs("span",{className:"font-medium text-gray-900 dark:text-white",children:[e.jsx("span",{children:"-"})," ",P((Fe=(Ee=t==null?void 0:t.saved)==null?void 0:Ee.breakdown)==null?void 0:Fe.walletAppliedMinor)]})]}),((ze=(Te=t==null?void 0:t.saved)==null?void 0:Te.breakdown)==null?void 0:ze.couponAmtMinor)>0&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-gray-600 dark:text-gray-400",children:"Coupon Discount"}),e.jsxs("span",{className:"font-medium text-gray-900 dark:text-white",children:[e.jsx("span",{children:"-"})," ",P((_e=(Be=t==null?void 0:t.saved)==null?void 0:Be.breakdown)==null?void 0:_e.couponAmtMinor)]})]})]}),e.jsx("div",{className:"border-t border-gray-300 dark:border-gray-600 pt-4 mt-3",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Total Payable"}),e.jsx("div",{className:"text-right",children:e.jsx("div",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:P((Ue=(Re=t==null?void 0:t.saved)==null?void 0:Re.breakdown)==null?void 0:Ue.payableViaGatewayMinor)})})]})})]}),e.jsx("div",{className:"mb-4 mt-3",children:e.jsxs("label",{className:"flex items-start gap-3 cursor-pointer p-3 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[e.jsx("input",{type:"checkbox",checked:g,onChange:s=>
1re(s.target.checked),className:"mt-0.5 w-5 h-5 text-green-500 rounded focus:ring-green-500"}),e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-400",children:["I agree to Metty's"," ",e.jsx("a",{href:"#",className:"text-green-600 dark:text-green-400 hover:underline",children:"Terms of Service"})," ","and"," ",e.jsx("a",{href:"#",className:"text-green-600 dark:text-green-400 hover:underline",children:"Subscription Terms"})]})]})}),B&&e.jsx("div",{className:"mb-4 p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg animate-pulse",children:e.jsxs("p",{className:"text-sm text-red-600 dark:text-red-400 flex items-center gap-2",children:[e.jsx(gt,{className:"w-4 h-4"}),B]})}),it?e.jsx("button",{onClick:ot,disabled:!g||y,className:`w-full py-3 bg-gradient-to-r from-blue-500 to-indigo-600
2                                 hover:from-blue-600 hover:to-indigo-700
3                                 text-white font-bold rounded-xl
4                                 transition-all duration-200 shadow-lg`,children:J?e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-3 border-white border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-lg",children:"Placing Order..."})]}):e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-full animate-ping"}),e.jsx(qe,{className:"w-6 h-6 relative"})]}),e.jsx("span",{className:"text-lg",children:"Place Order"})]})}):e.jsx("button",{onClick:ie,disabled:O||!g||y,className:"w-full py-3 bg-primary dark:bg-secondary text-white font-bold rounded-xl disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-200 shadow-lg hover:shadow-xl mb-4 group",children:O?e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("div",{className:"w-6 h-6 border-3 border-white border-t-transparent rounded-full animate-spin"}),e.jsx("span",{className:"text-lg",children:"Processing Payment..."})]}):e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 bg-white/20 rounded-full animate-ping"}),e.jsx(qe,{className:"w-6 h-6 relative"})]}),e.jsxs("div",{className:"text-left",children:[e.jsx("div",{className:"text-lg",children:"Pay with Razorpay"}),e.jsx("div",{className:"text-sm opacity-90",children:P((Ge=($e=t==null?void 0:t.saved)==null?void 0:$e.breakdown)==null?void 0:Ge.payableViaGatewayMinor)})]})]})}),e.jsx("div",{className:"text-center pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center justify-center gap-3 text-sm text-gray-500 dark:text-gray-400 mb-3",children:[e.jsx(ft,{className:"w-5 h-5 text-green-500"}),e.jsx("span",{children:"100% Secure Payment"})]})})]})]})})]})})]}):null},Gt=({isPlanActive:A})=>{var G;const[v,l]=n.useState({}),[W,me]=n.useState("USD"),[O,k]=n.useState(!0),[y,z]=n.useState(null),[B,C]=n.useState(null),{user:g}=Je(a=>a.auth),re=Qe(),[t,N]=n.useState(!1),L=localStorage.getItem("accessToken");n.useEffect(()=>{L||N(!0)},[L]);const[V,S]=n.useState(!1),[M,H]=n.useState(null),[_,le]=n.useState(""),[Z,o]=n.useState(!1),[E,b]=n.useState(null),[R,U]=n.useState(null),[xe,ue]=n.useState({});n.useEffect(()=>{const a=document.createElement("script");return a.src="https://checkout.razorpay.com/v1/checkout.js",a.async=!0,document.body.appendChild(a),()=>{document.body.removeChild(a)}},[]),n.useEffect(()=>{K()},[]);const K=async()=>{try{k(!0);const a=await j.post("/payment/getAllSubscriptionPlans");a.success&&l(a.plans)}catch(a){console.error(a)}finally{k(!1)}},F=a=>{if(!a||a<=0)return"";if(a%365===0){const r=a/365;return r===1?"per year":`for ${r} years`}if(a%30===0){const r=a/30;return r===1?"per month":`for ${r} months`}return`for ${a} days`},I=a=>{switch(a){case"invalid_code":return"That code isn't valid.";case"inactive_code":return"This code is no longer active.";case"expired_code":return"This code has expired.";case"code_exhausted":return"This code has already been fully redeemed.";case"not_allowed_for_user":return"This code isn't available for your account.";case"code_required":return"Please enter a code.";default:return"We couldn't validate that code."}},Y=async()=>{const a=_.trim();if(b(null),U(null),!a){b("Please enter a code.");return}if(!L){N(!0);return}try{o(!0);
4const r=await j.post("/payment/validateAccessCode",{code:a});if(r.success&&r.valid&&r.planId&&r.plan){const u=r.planId,p=r.plan;l(f=>({...f,[u]:p})),ue(f=>({...f,[u]:a})),U(`Unlocked the ${p.packageName} plan below.`)}else b(I(r.reason))}catch(r){console.error(r),b("Failed to validate code. Please try again.")}finally{o(!1)}},T=(a,r)=>{H({planName:a,packageName:r.packageName,amount:r.amount,amountInUSD:r.amountInUSD,currency:r.currency,durationDays:r.durationDays,features:r.features,credit:r.credit,perDayLimit:r.perDayLimit,MRP:r.MRP,discount:r.discount,accessCode:xe[a]}),S(!0)},c=()=>{S(!1),z(null),ce.fire({icon:"success",title:"Subscription Activated!",text:"Your subscription has been successfully activated.",confirmButtonColor:"#6366F1"}),re(de()),K()},X=a=>{switch(a){case"Free":return e.jsx(se,{className:"w-6 h-6"});case"Individual":return e.jsx(tt,{className:"w-6 h-6"});case"GROWTH":return e.jsx(et,{className:"w-6 h-6"});case"ELITE":return e.jsx(De,{className:"w-6 h-6"});default:return e.jsx(se,{className:"w-6 h-6"})}},q=a=>{switch(a){case"Individual":return"from-primary-700 to-primary-500";case"GROWTH":return"from-primary-700 to-primary-500";case"ELITE":return"from-primary-700 to-primary-500";default:return"from-primary-700 to-primary-500"}},J=()=>{var r;const a=(r=g==null?void 0:g.subscriptionPlan)==null?void 0:r.toLowerCase();return a?a==="free"?"Free":a==="individual"?"Individual":a==="growth"?"GROWTH":a==="elite"?"ELITE":null:null};console.log("getUserPlanKey",J());const $=a=>J()===a;if(O)return e.jsx(wt,{});const Q=Object.entries(v).filter(([a])=>a!=="Free");return console.log("otherPlans",Q),e.jsxs("div",{className:"px-2 lg:px-0",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-3xl lg:text-5xl font-bold text-primary-600 dark:text-white text-center mb-3",children:["Unlock Premium Access with ",e.jsx("span",{className:"text-secondary",children:"Metty AI"})]}),e.jsx("h3",{className:"lg:text-2xl text-xl font-bold text-primary dark:text-white text-center mb-4",children:"Smarter AI, better features, and plans designed to grow with you."}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-300 mb-8 max-w-2xl mx-auto",children:"Metty AI subscription plans are built to help individuals and teams move faster. From essential features to premium capabilities, each plan is designed to deliver more efficiency, more control, and a better AI experience."})]}),e.jsxs("div",{className:"max-w-md mx-auto mb-2",children:[e.jsxs("div",{className:"flex items-stretch gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(ae,{className:"w-4 h-4 text-gray-400 absolute left-3 top-1/2 -translate-y-1/2"}),e.jsx("input",{type:"text",value:_,onChange:a=>{le(a.target.value),b(null),U(null)},onKeyDown:a=>{a.key==="Enter"&&Y()},placeholder:"Have an invite code?",className:"w-full pl-9 pr-3 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-gray-900 dark:text-white text-sm focus:outline-none focus:ring-2 focus:ring-secondary"})]}),e.jsx("button",{onClick:Y,disabled:Z||!_.trim(),className:"px-4 py-2 rounded-lg font-semibold text-sm text-white bg-gradient-to-r from-secondary to-secondary-600 hover:from-secondary-700 hover:to-secondary-800 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:Z?"Checking...":"Apply"})]}),E&&e.jsx("p",{className:"text-xs text-red-500 mt-2 text-center",children:E}),R&&e.jsxs("p",{className:"text-xs text-green-600 mt-2 text-center flex items-center justify-center gap-1",children:[e.jsx(oe,{className:"w-3 h-3"}),R]})]}),e.jsx("div",{className:"",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 mt-10",children:Q.map(([a,r])=>{const u=a==="Free",p=a==="GROWTH",f=$(r.packageName);return console.log("isCurrentUserPlan",a),e.jsxs("div",{className:`relative group transition-all duration-300 hover:scale-[1.02] ${p?"lg:col-span-1":""}`,children:[p&&e.jsx("div",{className:"absolute -top-3 left-1/2 transform -translate-x-1/2 z-10",children:e.jsxs("span",{className:"bg-gradient-to-r from-secondary-800 to-secondary-500 text-white text-xs font-semibold px-4 py-2 rounded-full flex items-center shadow-lg",children:[e.jsx(jt,{size:14,className:"mr-1"}),"Most Popular"]})}),f&&e.jsx("div",{className:"absolute -top-3 left-1/2 transform -translate-x-1/2 z-10",children:e.jsxs("span",{className:"bg-gradient-to-r from-green-800 to-emerald-500 text-white text-xs font-semibold px-4 py-2 rounded-full flex items-center shadow-lg",children:[e.jsx(ae,{size:14,className:"mr-1"}),"Current Plan"]})}),e.jsxs("div",{className:"h-full bg-white dark:bg-gray-800 rounded-xl shadow-xl border border-gray-200 dark:border-gray-700 overflow-hidden ",children:[e.jsxs("div",{className:`px-6 py-4 bg-gradient-to-r ${q(a)} text-white relative`,children:[e.jsx("div",{className:"flex justify-between items-center mb-1",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-white/20 rounded-lg",children:X(a)}),e.jsxs("h3",{className:"text-xl font-bold",children:[r.packageName," Plan"]})]})}),e.jsxs("div",{className:"flex justify-between mt-4",children:[!u&&r.discount>0&&e.jsx("div",{className:"flex flex-col",children:e.jsxs("span",{className:"text-base line-through opacity-80",children:["₹ ",r==null?void 0:r.MRP]})}),e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsxs("span",{className:"text-2xl font-bold",children:["₹ ",r==null?void 0:r.amount]}),!u&&r.durationDays>0&&e.jsx("span",{className:"text-xs opacity-80",children:F(r.durationDays)})]})]}),e.jsxs("button",{onClick:()=>!u&&T(a,r),disabled:y===a||u||f,className:`w-fixed py-2 px-4 roun
4ded-lg font-semibold flex items-center justify-center gap-2 transition-all duration-300 ${u?"bg-gray-400 cursor-not-allowed text-white":f?"bg-gradient-to-r from-green-800 to-green-600 hover:from-green-700 hover:to-green-800 cursor-not-allowed text-white":y===a?"bg-blue-400 cursor-not-allowed text-white":p?"bg-gradient-to-r from-secondary to-secondary-600 hover:from-secondary -700 hover:to-secondary-800 text-white shadow-lg hover:shadow-xl":"bg-gradient-to-r from-secondary to-secondary-600 hover:from-secondary -700 hover:to-secondary-800 text-white shadow-md hover:shadow-lg"}`,children:[$(a)&&e.jsx(ae,{className:"w-4 h-4"}),u?"Free Plan":f?"Current Plan":y===a?"Processing...":"Get Started",!u&&!f&&y!==a&&e.jsx(Nt,{className:"w-4 h-4"})]})]}),e.jsx("div",{className:"p-6",children:e.jsx("ul",{className:"space-y-3 mb-6",children:r.features.map((ne,ie)=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx(oe,{className:"w-4 h-4 text-green-500 mt-0.5 flex-shrink-0"}),e.jsx("span",{className:"text-gray-700 dark:text-gray-300 text-sm leading-relaxed",children:ne})]},ie))})})]})]},a)})})}),B&&e.jsx("div",{className:"max-w-4xl mx-auto mt-6",children:e.jsx("p",{className:"text-center text-red-500 bg-red-50 dark:bg-red-900/20 py-3 px-4 rounded-lg",children:B})}),V&&M&&e.jsx(Pt,{isOpen:V,onClose:()=>{S(!1),z(null)},subscriptionPlan:M,onSuccess:c,userBillingInfo:(G=g==null?void 0:g.profile)==null?void 0:G.billingDetails}),t&&e.jsx(vt,{})]})};export{Gt 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.