1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/helperFunctions-B1C4ljAA.js","assets/apiClient-KV8Fj0P3.js"])))=>i.map(i=>d[i]); 2import{c as tn,X as nn,a as an,b as Pt,y as $,d as Te,i as on,t as Se,H as sn,A as rn,_ as ln}from"./index-xsCBv_jq.js";import{r as c,j as t,L as qe,u as dn,b as mn,c as cn,N as pn}from"./vendor-react-Dxo5VVMX.js";import{u as gn}from"./useTrackEvent-YcWewhHW.js";import{a as It,c as Le,r as Ze}from"./helperFunctions-B1C4ljAA.js";import{u as un,M as xn,h as yn}from"./useBookingAbandon-gR5hLwDA.js";import{c as At,b as hn,e as Fe,f as fn}from"./firebase-BVjbF1Sd.js";import{s as kn}from"./vendor-firebase-core-Bea8MryS.js";import{trackBooking as Be,trackPayment as Re,mixpanel as bn}from"./mixpanel-CmVRJZ7N.js";import{C as wn}from"./circle-check-big-jI75ScDR.js";import{C as Nn}from"./circle-x-B0krXiyl.js";import{L as jn}from"./loader-circle-DutfT_Qr.js";import{u as vn}from"./useAccessibleModal-CVIlD6tv.js";import{C as Et}from"./circle-alert-CLusMDPE.js";import{b as we,c as bt,r as Ve,a as Pe}from"./bookingAnalytics-Xih25_gh.js";import{v as _n,l as wt,c as Cn,D as Sn}from"./cashfreeService-B2ZGZ58h.js";import{F as Pn}from"./file-text-BbQeZ2ue.js";import{R as In,c as Nt}from"./rsaOffer-BK3n-NIk.js";import{c as Ft,d as An}from"./mychoize-BOKnbitk.js";import{d as Ye,f as Je,a as jt,c as vt}from"./vendor-firebase-firestore-BI8UjDC3.js";import{r as En,u as Fn,g as Bn,h as Rn}from"./vendor-firebase-extras-Butzwarm.js";import{getAuthHeader as He}from"./authFetch-DLZMbP5m.js";import{captureError as Ne}from"./sentry-Bt8wZbzC.js";import{v as Tn,i as Ln}from"./zoomcarV2-BSWTMMFA.js";import"./vendor-analytics-BolNmaul.js";import"./vendor-query-BGDNI3Fe.js";import"./apiClient-KV8Fj0P3.js";import"./firebaseCore-DdWO-lul.js";const $n=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],On=tn("ExternalLink",$n),Mn=45e3,zn=({isOpen:r,close:e,bookingId:l,carDetail:a,paymentStatus:o="loading"})=>{const[S,n]=c.useState("loading"),[d,K]=c.useState(!1);return c.useEffect(()=>{r&&n(o)},[r,o]),c.useEffect(()=>{if(!r||S!=="loading"){K(!1);return}const F=setTimeout(()=>K(!0),Mn);return()=>clearTimeout(F)},[r,S]),r?t.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm z-50 p-4",children:t.jsxs("div",{className:"bg-white dark:bg-gray-900 rounded-2xl shadow-2xl p-6 sm:p-8 w-full max-w-sm text-center transform transition-all duration-300 border border-gray-200 dark:border-gray-800",children:[S==="success"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-16 h-16 sm:w-20 sm:h-20 bg-gray-900 dark:bg-white rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx(wn,{className:"w-8 h-8 sm:w-10 sm:h-10 text-white dark:text-gray-900"})}),t.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-gray-900 dark:text-white",children:"Booking Confirmed!"}),t.jsx("p",{className:"text-sm sm:text-base text-gray-600 dark:text-gray-300 mt-2",children:"Your payment was successful. We've sent the details to your WhatsApp and email."}),l&&t.jsxs("div",{className:"mt-4 px-4 py-2 bg-gray-100 dark:bg-gray-800 rounded-lg inline-block",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-300 uppercase tracking-wider",children:"Booking ID"}),t.jsx("p",{className:"text-sm sm:text-base font-semibold text-gray-900 dark:text-white",children:l})]}),a&&t.jsxs("div",{className:"mt-4 p-4 bg-gray-50 dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700",children:[t.jsx("p",{className:"font-semibold text-gray-900 dark:text-white",children:a.name}),a.model&&t.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-300",children:a.model})]}),t.jsx(qe,{to:"/my-bookings",className:"block mt-6 w-full py-3 sm:py-3.5 rounded-full font-semibold text-center transition-all bg-indigo-600 hover:bg-indigo-700 text-white min-h-[48px] flex items-center justify-center",children:"Go to My Bookings"})]}),S==="failure"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-16 h-16 sm:w-20 sm:h-20 bg-red-500 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx(Nn,{className:"w-8 h-8 sm:w-10 sm:h-10 text-white"})}),t.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-gray-900 dark:text-white",children:"Payment Failed"}),t.jsx("p",{className:"text-sm sm:text-base text-gray-600 dark:text-gray-300 mt-2",children:"Something went wrong with your transaction. Please try again."}),t.jsxs("div",{className:"mt-4 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700",children:[t.jsx("p",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-300",children:"If any amount was debited, it will be refunded automatically within 5-7 business days."}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:["Need help? Email"," ",t.jsx("a",{href:"mailto:[email protected]",className:"text-indigo-600 dark:text-indigo-400 underline hover:no-underline",children:"[email protected]"})]})]}),t.jsx("div",{className:"mt-6",children:t.jsx("button",{onClick:e,className:"w-full py-3 sm:py-3.5 rounded-full font-semibold transition-all bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-700 min-h-[48px]",children:"Close"})})]}),S==="loading"&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-16 h-16 sm:w-20 sm:h-20 bg-gray-100 dark:bg-gray-800 rounded-full flex items-center justify-center mx-auto mb-4",children:t.jsx(jn,{className:"w-8 h-8 sm:w-10 sm:h-10 text-gray-900 dark:text-white animate-spin"})}),t.jsx("h2",{className:"text-xl sm:text-2xl font-bold text-gray-900 dark:text-white",children:"Processing Payment..."}),t.jsx("p",{className:"text-sm sm:text-base text-gray-600 dark:text-gray-300 mt-2",children:"Please wait while we confirm your payment. Do not close this window."}),t.jsxs("div",{className:"flex items-center justify-center gap-1.5 mt-6",children:[t.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0ms"}}),t.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"150ms"}}),t.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"300ms"}})]}),d&&t.jsxs("div",{className:"mt-6 p-3 bg-gray-50 dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 text-left",children:[t.jsx("p",{className:"text-xs sm:text-sm text-gray-700 dark:text-gray-300",children:"Taking longer than expected? If any amount was debited, it will be refunded automatically within 5-7 business days."}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-2",children:["Need help? Email"," ",t.jsx("a",{href:"mailto:[email protected]",className:"text-indigo-600 dark:text-indigo-400 underline hover:no-underline",children:"[email protected]"})]})]})]})]})}):null},Zn=({isOpen:r,onClose:e})=>{const{dialogRef:l,handleBackdropClick:a}=vn({isOpen:r,onClose:e});return r?t.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[9999]",onClick:a,children:t.jsxs("div",{ref:l,role:"alertdialog","aria-modal":"true","aria-labelledby":"booking-failure-title",className:"bg-white rounded-2xl p-6 max-w-md mx-4 shadow-2xl border border-gray-100",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 bg-red-100 rounded-full flex items-center justify-center",children:t.jsx(Et,{className:"w-5 h-5 text-red-500","aria-hidden":"true"})}),t.jsx("h3",{id:"booking-failure-title",className:"text-lg font-semibold text-gray-800",children:"Oops! Booking Unsuccessful"})]}),t.jsx("button",{onClick:e,"aria-label":"Close dialog",className:"text-gray-400 hover:text-gray-600 transition-colors duration-200",children:t.jsx(nn,{className:"w-5 h-5","aria-hidden":"true"})})]}),t.jsx("p",{className:"text-gray-600 mb-6 leading-relaxed",children:"Don't worry if any money was deducted, it will be automatically refunded within 3â5 working days."}),t.jsx("button",{onClick:e,className:"w-full bg-z2-brand-blue text-white font-semibold py-3 px-4 roun
2ded-lg transition-all duration-300 hover:opacity-90 hover:scale-[1.01] hover:shadow-lg shadow-md",children:"OK"})]})}):null},Hn=()=>t.jsx("svg",{viewBox:"0 0 200 40",width:"90",height:"22",fill:"currentColor",children:t.jsx("text",{x:"0",y:"30",fontFamily:"Arial, sans-serif",fontSize:"24",fontWeight:"bold",fill:"#6933FF",children:"Cashfree"})}),Vn=({className:r=""})=>t.jsx("div",{className:`payment-gateway-selector ${r}`,children:t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"h-6 flex items-center",children:t.jsx(Hn,{})}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"UPI, Cards, Wallets, EMI"})]}),t.jsx("svg",{className:"w-5 h-5 text-green-500",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})]})});function Wn({vendor:r,showCancellationPolicy:e=!0,className:l=""}){return t.jsx("div",{className:`bg-white dark:bg-gray-800 rounded-2xl shadow-sm p-4 ${l}`,children:t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Pn,{className:"w-5 h-5 text-gray-400 flex-shrink-0 mt-0.5"}),t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["By proceeding with the payment, you agree to our"," ",t.jsx(qe,{to:"/terms-and-conditions",className:"text-purple-600 dark:text-purple-400 hover:underline",children:"Terms & Conditions"})," ","and"," ",t.jsx("a",{href:"/privacy-policy",className:"text-purple-600 dark:text-purple-400 hover:underline",children:"Privacy Policy"}),"."]})]}),e&&t.jsxs("div",{className:"flex items-start gap-3",children:[t.jsx(Et,{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5"}),t.jsx("div",{children:t.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:["Cancellation policy applies."," ",t.jsxs(qe,{to:"/cancellation-policy",className:"text-purple-600 dark:text-purple-400 hover:underline inline-flex items-center gap-1",children:["View Policy",t.jsx(On,{className:"w-3 h-3"})]})]})})]}),r==="ZoomCar"&&t.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 mt-2",children:t.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:[t.jsx("strong",{children:"ZoomCar:"})," Security deposit is refundable and will be returned within 5-7 business days after trip completion."]})}),r==="Mychoize"&&t.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 mt-2",children:t.jsxs("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:[t.jsx("strong",{children:"MyChoize:"})," Please carry your original driving license and Aadhaar card for verification at pickup."]})})]})})}const Kn=({promoCode:r,promoDiscount:e,voucherDiscount:l})=>t.jsxs(t.Fragment,{children:[r&&e>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:["Promo code ",r]}),t.jsxs("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:["-â¹",e.toLocaleString("en-IN")]})]}),l>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Voucher"}),t.jsxs("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:["-â¹",l.toLocaleString("en-IN")]})]})]}),Un=({car:r,carDetails:e,zoomCarPricing:l,homeDeliveryCharges:a,deliveryCharges:o=0,wheelupDeliveryCharge:S=0,payableAmount:n,rsaAddon:d=!1,rsaAmount:K=0,promoCode:F=null,promoDiscount:m=0,voucherDiscount:y=0})=>{var A,z,O,D,le,de,ne,me;const g=(F&&m>0?m:0)+Math.max(y,0),I=t.jsx(Kn,{promoCode:F,promoDiscount:m,voucherDiscount:y});return t.jsxs("section",{className:"bg-white dark:bg-gray-900 rounded-2xl border border-gray-200 dark:border-gray-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-4 sm:p-5 space-y-4",children:[t.jsx("h3",{className:"text-xs font-semibold text-gray-400 dark:text-gray-300 uppercase tracking-wider",children:"Price Details"}),t.jsxs("p",{className:"text-[10px] text-emerald-600 dark:text-emerald-400 flex items-center gap-1 mt-1",children:[t.jsx("svg",{className:"w-3 h-3 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),"Transparent prices â we compare across multiple partners"]}),t.jsx("div",{className:"space-y-3",children:(r==null?void 0:r.source)==="zoomcar"&&l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Rental"}),t.jsxs("div",{className:"flex items-center gap-2",children:[l.hasOriginalPrice&&t.jsxs("span",{className:"text-xs text-gray-400 line-through",children:["â¹",l.actualPrice.toLocaleStr
2ing()]}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:(A=e==null?void 0:e.fareDetails)==null?void 0:A.priceAfterDiscount}),l.rentalSavings>0&&t.jsxs("span",{className:"px-1.5 py-0.5 text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded",children:["SAVE â¹",l.rentalSavings.toLocaleString()]})]})]}),l.hasPlatformFee&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Platform Fee"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("span",{className:"text-xs text-gray-400 line-through",children:["â¹",l.platformFee.toLocaleString()]}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:"â¹0"}),t.jsx("span",{className:"px-1.5 py-0.5 text-xs font-medium bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400 rounded",children:"WAIVED"})]})]}),l.tripInsurance>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Trip Insurance"}),t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:(z=e==null?void 0:e.fareDetails)==null?void 0:z.tripInsurance})]}),I,t.jsxs("div",{className:"flex justify-between items-center mt-3 pt-3 border-t border-gray-200 dark:border-gray-700",children:[t.jsx("span",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300",children:"TRIP COST"}),t.jsxs("span",{className:"text-sm font-bold text-gray-900 dark:text-white",children:["â¹",(l.tripCost-g).toLocaleString()]})]}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-300 text-right",children:"Your actual spend"}),l.deposit>0&&t.jsxs("div",{className:"mt-3 pt-3 border-t border-dashed border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Refundable Deposit"}),t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:(O=e==null?void 0:e.fareDetails)==null?void 0:O.deposit})]}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-gray-300 flex items-center gap-1 mt-1",children:"â© Returned in 5-7 days after trip"})]}),(l.hasSavings||g>0)&&t.jsxs("div",{className:"mt-3 pt-3 border-t border-gray-200 dark:border-gray-700 space-y-1",children:[t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"You save"}),t.jsxs("span",{className:"text-sm font-bold text-green-600 dark:text-green-400",children:["â¹",(l.totalSavings+g).toLocaleString()]})]}),t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm font-medium text-gray-600 dark:text-gray-300",children:"Your actual cost"}),t.jsxs("span",{className:"text-sm font-bold text-gray-900 dark:text-white",children:["â¹",(l.tripCost-g).toLocaleString()]})]})]})]}):t.jsxs(t.Fragment,{children:[((D=e==null?void 0:e.fareDetails)==null?void 0:D.priceAfterDiscount)&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Rental"}),t.jsx("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:e.fareDetails.priceAfterDiscount})]}),((le=e==null?void 0:e.fareDetails)==null?void 0:le.deposit)&&parseFloat(e.fareDetails.deposit.replace(/[^0-9.]/g,""))>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Refundable Deposit"})]}),t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.fareDetails.deposit})]}),((de=e==null?void 0:e.fareDetails)==null?void 0:de.tripInsurance)&&parseFloat(e.fareDetails.tripInsurance.replace(/[^0-9.]/g,""))>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Trip Insurance"})]}),t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.fareDetails.tripInsurance})]}),a>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Home Delivery"})]}),t.jsxs("span",{className:"text-sm text-gray-900 dark:text-white",children:["â¹",a]})]}),o>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Pickup & Drop Charges"})]}),t.jsxs("span",{className:"text-sm text-gray-900 dark:text-white",children:["â¹",o]})]}),S>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"WheelUp Delivery"})]}),t.jsxs("span",{className:"text-sm text-gray-900 dark:text-white",children:["â¹",S]})]}),((ne=e==null?void 0:e.fareDetails)==null?void 0:ne.gst)&&parseFloat(e.fareDetails.gst.replace(/[^0-9.]/g,""))>0&&t.jsxs("div",{className:"flex justify-between items-center",children:[t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"GST"}),t.jsx("span",{className:"text-sm text-gray-900 dark:text-white",children:e.fareDetails.gst})]}),I,d&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex justify-between items-center mt-2 pt-2 border-t border-dashed border-gray-200 dark:border-gray-700",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("svg",{className:"w-4 h-4 text-blue-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),t.jsx("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Roadside Assistance"})]}),K>0?t.jsxs("span",{className:"text-sm font-semibold text-gray-900 dark:text-white",children:["â¹",K]}):t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsxs("s",{className:"text-xs text-gray-500 dark:text-gray-400",children:["â¹",In]}),t.jsx("span",{className:"text-sm font-semibold text-green-700 dark:text-green-400",children:"FREE"})]})]}),t.jsx("div",{className:"mt-1 ml-5",children:t.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:["24Ã7 helpline: ",t.jsx("a",{href:`tel:${Nt.tel}
2`,className:"text-blue-600 dark:text-blue-400 underline font-medium",children:Nt.display})]})})]})]})})]}),t.jsx("div",{className:"p-4 sm:p-5 bg-gradient-to-r from-gray-900 to-gray-800 dark:from-gray-900 dark:to-gray-800",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs font-medium text-gray-400 dark:text-gray-300 uppercase tracking-wider",children:"Total Payable"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 mt-0.5",children:"Inclusive of all taxes"})]}),t.jsx("span",{className:"text-xl sm:text-2xl font-bold text-white dark:text-white",children:It(n)})]})}),((me=e==null?void 0:e.fareDetails)==null?void 0:me.deposit)&&parseFloat(e.fareDetails.deposit.replace(/[^0-9.]/g,""))>0&&t.jsx("div",{className:"px-4 sm:px-5 py-4 bg-gray-50 dark:bg-gray-800/50 border-t border-gray-100 dark:border-gray-800",children:t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-400 mt-0.5 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-300 leading-relaxed",children:"Deposit is refundable within 5-7 working days after trip completion, subject to vehicle inspection."})]})})]})},Gn=({documents:r,carSource:e})=>e==="zoomcar"||!(r!=null&&r.length)?null:t.jsxs("section",{className:"bg-white dark:bg-gray-900 p-4 sm:p-6 rounded-2xl border border-gray-200 dark:border-gray-800 shadow-sm",children:[t.jsx("h2",{className:"text-lg sm:text-xl font-semibold mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 text-gray-900 dark:text-white",children:"Uploaded Documents"}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 sm:gap-4",children:r.map((l,a)=>t.jsxs("div",{className:"text-center bg-gray-50 dark:bg-gray-800 p-2 sm:p-3 rounded-xl border border-gray-200 dark:border-gray-700",children:[t.jsx("div",{className:"mb-2 text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider truncate",children:l.name.replaceAll("_"," ")}),l.file&&(l.file.startsWith("data:image/")||l.file.startsWith("http"))?t.jsx("img",{src:l.file,alt:l.name,className:"h-20 sm:h-24 w-full object-cover rounded-lg border border-gray-200 dark:border-gray-600"}):t.jsx("div",{className:"w-full h-20 sm:h-24 bg-gray-100 dark:bg-gray-700 flex items-center justify-center rounded-lg",children:t.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-300",children:"No Preview"})})]},a))})]}),_t=()=>t.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}),Yn=()=>t.jsx("div",{className:"bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 py-4",children:t.jsx("div",{className:"max-w-4xl mx-auto px-4",children:t.jsxs("div",{className:"flex items-center justify-center gap-1 sm:gap-2",children:[t.jsx("div",{className:"flex items-center",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:"w-7 h-7 sm:w-8 sm:h-8 bg-gray-900 dark:bg-white text-white dark:text-gray-900 rounded-full flex items-center justify-center text-sm font-semibold",children:t.jsx(_t,{})}),t.jsx("span",{className:"text-[10px] sm:text-xs mt-1 font-medium text-gray-900 dark:text-white",children:"Search"})]})}),t.jsx("div",{className:"w-6 sm:w-10 md:w-16 h-0.5 bg-gray-900 dark:bg-white"}),t.jsx("div",{className:"flex items-center",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:"w-7 h-7 sm:w-8 sm:h-8 bg-gray-900 dark:bg-white text-white dark:text-gray-900 rounded-full flex items-center justify-center text-sm font-semibold",children:t.jsx(_t,{})}),t.jsx("span",{className:"text-[10px] sm:text-xs mt-1 font-medium text-gray-900 dark:text-white",children:"Details"})]})}),t.jsx("div",{className:"w-6 sm:w-10 md:w-16 h-0.5 bg-gray-900 dark:bg-white"}),t.jsx("div",{className:"flex items-center",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:"w-7 h-7 sm:w-8 sm:h-8 bg-gray-900 dark:bg-white text-white dark:text-gray-900 rounded-full flex items-center justify-center text-sm font-semibold ring-2 ring-gray-400 dark:ring-gray-500 ring-offset-2 dark:ring-offset-gray-900",children:"3"}),t.jsx("span",{className:"text-[10px] sm:text-xs mt-1 font-semibold text-gray-900 dark:text-white",children:"Payment"})]})}),t.jsx("div",{className:"w-6 sm:w-10 md:w-16 h-0.5 bg-gray-300 dark:bg-gray-700"}),t.jsx("div",{className:"flex items-center",children:t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx("div",{className:"w-7 h-7 sm:w-8 sm:h-8 bg-gray-200 dark:bg-gray-800 text-gray-500 dark:text-gray-300 rounded-full flex items-center justify-center text-sm font-semibold",children:"4"}),t.jsx("span",{className:"text-[10px] sm:text-xs mt-1 font-medium text-gray-400 dark:text-gray-300",children:"Confirmed"})]})})]})})}),Jn=({isVisible:r})=>r?t.jsx("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center",role:"status","aria-live":"assertive",children:t.jsxs("div",{className:"bg-white dark:bg-gray-900 text-gray-900 dark:text-white px-6 py-4 rounded-xl shadow-2xl text-base sm:text-lg font-medium flex items-center gap-3 mx-4",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5 text-gray-900 dark:text-white","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),"Processing payment..."]})}):null;function ue(r){return r&&r.trim()!==""?r.trim():null}function qn(r,e){var l,a;return ue(r==null?void 0:r.userName)||ue(r==null?void 0:r.name)||ue((l
2=r==null?void 0:r.email)==null?void 0:l.split("@")[0])||ue(e==null?void 0:e.displayName)||ue((a=e==null?void 0:e.email)==null?void 0:a.split("@")[0])||"Customer"}async function Ct({bookingId:r,userDetails:e,userData:l,startDateFormatted:a,endDateFormatted:o,city:S,car:n,vendor:d,payableAmount:K,selectedPickupLocation:F,functionsUrl:m}){var A,z;const y=(A=e==null?void 0:e.phone)!=null&&A.startsWith("+91")?e==null?void 0:e.phone:`+91${e==null?void 0:e.phone}`,g=qn(e,l),I={id:r,customerName:g,dateOfBirth:(e==null?void 0:e.dob)||"",phone:y||(e==null?void 0:e.phone)||"",email:(e==null?void 0:e.email)||"",startDate:a,endDate:o,city:S||"",pickupLocation:(F==null?void 0:F.HubAddress)||(n==null?void 0:n.address)||"",amount:It(K||0),vendorName:d,vendorLocation:(n==null?void 0:n.address)||"",model:`${(n==null?void 0:n.brand)||""} ${(n==null?void 0:n.name)||""}`,transmission:((z=n==null?void 0:n.options)==null?void 0:z[0])||"",package:Ft(n==null?void 0:n.rateBasis)||"",paymentMode:"Online (Cashfree)",serviceType:"Online"};try{await fetch(`${m}/message/booking-confirmation-other-vendor`,{method:"POST",body:JSON.stringify({data:I}),headers:{"Content-Type":"application/json"}}),console.log("[NOTIFICATION] WhatsApp notification sent successfully")}catch(O){console.warn("[NOTIFICATION] Failed to send WhatsApp notification (non-blocking):",O.message)}}async function Xn({bookingId:r,userDetails:e,userData:l,startDateFormatted:a,endDateFormatted:o,city:S,car:n,selectedPickupLocation:d,functionsUrl:K}){var g,I,A,z;const F=(g=e==null?void 0:e.phone)!=null&&g.startsWith("+91")?e==null?void 0:e.phone:`+91${e==null?void 0:e.phone}`,m=ue(e==null?void 0:e.name)||ue(e==null?void 0:e.userName)||ue((I=e==null?void 0:e.email)==null?void 0:I.split("@")[0])||ue(l==null?void 0:l.displayName)||ue((A=l==null?void 0:l.email)==null?void 0:A.split("@")[0])||"Customer";console.log("ð± [WHATSAPP] Sending booking confirmation",{bookingId:r,customerName:m,phone:F,userDetailsAvailable:!!e,userDetailsName:(e==null?void 0:e.name)||"undefined"});const y={id:r,customerName:m,phone:F||(e==null?void 0:e.phone)||"",email:(e==null?void 0:e.email)||"",startDate:a,endDate:o,city:S||"",pickupLocation:(d==null?void 0:d.HubAddress)||(n==null?void 0:n.address)||"",model:`${(n==null?void 0:n.brand)||""} ${(n==null?void 0:n.name)||""}`,transmission:((z=n==null?void 0:n.options)==null?void 0:z[0])||"",freeKMs:"Unlimited"};try{await fetch(`${K}/message/booking-confirmation-zoomcar-vendor`,{method:"POST",body:JSON.stringify({data:y}),headers:{"Content-Type":"application/json"}}),console.log("[NOTIFICATION] ZoomCar WhatsApp notification sent successfully")}catch(O){console.warn("[NOTIFICATION] Failed to send ZoomCar WhatsApp notification (non-blocking):",O.message)}}const St=r=>{if(!r)return"";const e=new Date(r);return isNaN(e.getTime())?"":e.toLocaleTimeString("en-IN",{hour:"2-digit",minute:"2-digit",hour12:!0})},Ce=r=>{if(!r)return"";const e=new Date(r);return isNaN(e.getTime())?"":e.toLocaleDateString("en-IN",{day:"2-digit",month:"short",year:"numeric"})},Qn=(r,e)=>`userImages/${r}/${e}`,Dn=/[^0-9]/g;function ea(r){if(typeof(r==null?void 0:r.actualPrice)=="number"&&r.actualPrice)return r.actualPrice;for(const e of[r==null?void 0:r.inflated_fare,r==null?void 0:r.fare]){if(typeof e=="number"&&e)return e;if(typeof e=="string"&&e)return parseInt(e.replace(Dn,""),10)||0}return 0}function ta(r){const{car:e,carDetails:l,userDetails:a,userData:o,documents:S,payableAmount:n,vendor:d,derivedOwnerName:K=null,derivedIsPartnerVendor:F=!1,city:m,startDate:y,endDate:g,startDateFormatted:I,endDateFormatted:A,tripDuration:z,deliveryType:O,homeDeliveryCharges:D,street1:le,street2:de,deliveryCity:ne,zipcode:me,selectedPickupLocation:h,selectedDropLocation:H,effectiveUid:B,effectiveEmail:he,functionsUrl:J,setConfirmPopupStatus:ae,setIsConfirmPopupOpen:ce,setShowBookingFailurePopup:j,setIsPaying:f,setBookingData:v,vendorDetails:w,promoCode:V=null,promoDiscount:M=0,voucherDiscount:L=0,rsaAddon:q=!1,rsaAmount:_=0}=r,Q=c.useRef(!1),je=c.useRef({isHandlingPayment:!1,paymentSucceeded:!1,bookingSucceeded:!1,handlerName:null}),Z=c.useRef(null),ye=c.useRef(!1),fe=c.useRef(null),Y=c.useCallback(async s=>{var i;
2if(!s||!Array.isArray(s))return{LicenseBack:null,LicenseFront:null,aadhaarBack:null,aadhaarFront:null};try{const p=Date.now(),k=(i=At.currentUser)==null?void 0:i.uid;if(!k)throw new Error("User not authenticated for document upload");const x=Qn(k,p),b=await Promise.all(s.map(async N=>{if(N.file_object){const ie=En(hn,`${x}/${N.name}`);return await Fn(ie,N.file_object),await Bn(ie)}else if(N.file&&!N.file.startsWith("data:image/"))return N.file;return null})),[P,C,T,ee]=b;return{LicenseBack:ee||null,LicenseFront:T||null,aadhaarBack:C||null,aadhaarFront:P||null}}catch(p){return console.error("Error uploading documents to Firebase:",p),{LicenseBack:null,LicenseFront:null,aadhaarBack:null,aadhaarFront:null}}},[]),R=c.useCallback(s=>{var b,P,C,T,ee;const i=a==null?void 0:a.phone,p=i!=null&&i.startsWith("+91")?i:`+91${i}`,k=an(),x=we();return{Balance:0,Cancelled:!1,CarImage:((b=e==null?void 0:e.images)==null?void 0:b[0])||((P=e==null?void 0:e.image_urls)==null?void 0:P[0])||"",CarName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),carId:(e==null?void 0:e.id)||null,City:(e==null?void 0:e.source)==="ZT"||O==="home-delivery"?ne:m,DateOfBirth:(a==null?void 0:a.dob)||"",DateOfBooking:Date.now(),Documents:{LicenseBack:(s==null?void 0:s.LicenseBack)||null,LicenseFront:(s==null?void 0:s.LicenseFront)||null,aadhaarBack:(s==null?void 0:s.aadhaarBack)||null,aadhaarFront:(s==null?void 0:s.aadhaarFront)||null},Drive:"Self Drive",Email:(a==null?void 0:a.email)||"",EndDate:Ce(g)||g||"N/A",EndTime:St(g),FirstName:(a==null?void 0:a.name)||(a==null?void 0:a.userName)||"",FuelType:((C=e==null?void 0:e.options)==null?void 0:C[1])||"",MapLocation:(e==null?void 0:e.address)||"","Package Selected":(()=>{var ie;let N="";if((e==null?void 0:e.source)==="Zymo"){const W=(e==null?void 0:e.selectedPackage)??0,oe=(ie=e==null?void 0:e.total_km)==null?void 0:ie[W];oe&&oe!=="0"&&oe!=="00"&&oe!=="0.0"&&oe!==0?N=`${oe} KMs`:N="Unlimited KMs"}else{const W=Ft(e==null?void 0:e.rateBasis);if(W&&W!=="Undefined")N=W;else if(e!=null&&e.rateBasis)switch(e.rateBasis.toUpperCase()){case"FF":N="120km/day";break;case"MP":N="300km/day";break;case"DR":N="Unlimited KMs";break;default:N=`${e.rateBasis} Package`}else N="Standard Package"}return N})(),PhoneNumber:(a==null?void 0:a.phone)||p,"Pickup Location":(h==null?void 0:h.LocationName)||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location)||(e==null?void 0:e.address)||"","Drop Location":(H==null?void 0:H.LocationName)||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location)||(e==null?void 0:e.address)||"","Promo Code Used":V||"",clientPlatform:"web",SecurityDeposit:(e==null?void 0:e.securityDeposit)??(w==null?void 0:w.Securitydeposit)??0,StartDate:Ce(y)||y||"N/A",StartTime:St(y),Street1:(e==null?void 0:e.source)==="ZT"||O==="home-delivery"?le:"",Street2:(e==null?void 0:e.source)==="ZT"||O==="home-delivery"?de:"",TimeStamp:Le(Date.now()),Transmission:((T=e==null?void 0:e.options)==null?void 0:T[0])||"",UserId:B||"",Vendor:d,isPartnerVendor:F===!0,vendorId:(e==null?void 0:e.vendorId)||null,Zipcode:(e==null?void 0:e.source)==="ZT"||O==="home-delivery"?me:"",actualPrice:ea(e),deliveryType:(e==null?void 0:e.source)==="ZT"||["Karyana","Zymo","Kyp"].includes(e==null?void 0:e.source)&&O==="home-delivery"?"Home Delivery":(ee=h==null?void 0:h.LocationName)!=null&&ee.includes("Doorstep")?"Doorstep Delivery":"Self Pickup",extraKmCharge:(e==null?void 0:e.extraKMCharge)||(e==null?void 0:e.extrakm_charge)||0,homeDeliveryCharges:D,price:n||0,...V?{promoCode:V,promoDiscount:M||0,priceBeforePromo:(typeof n=="number"?n:parseFloat(String(n))||0)+(M||0)}:{},...L>0?{voucherDiscount:L}:{},...q?{rsaAddon:!0,rsaAmount:_,rsaBasePrice:_>0?Math.round(_/1.18):0,rsaGST:_>0?_-Math.round(_/1.18):0,rsaStatus:"pending"}:{},totalKmLimit:(e==null?void 0:e.total_km)||null,tripDuration:z||null,accountType:(e==null?void 0:e.accountType)||null,ownerName:K||(e==null?void 0:e.ownerName)||null,ownerPhone:(e==null?void 0:e.ownerPhone)||null,ownerEmail:(e==null?void 0:e.ownerEmail)||null,...k?{attribution:k}:{},origin_channel:x.origin_channel,booking_session_id:x.booking_session_id,app_instance_id:x.app_instance_id}},[e,a,d,K,F,m,ne,O,y,g,le,de,me,h,B,n,D,z,w,V,M,L,q,_]),$e=c.useCallback(()=>{var P,C;const s=a==null?void 0:a.phone,i=s!=null&&s.startsWith("+91")?s:`+91${s}`,p=(e==null?void 0:e.source)==="ZT"||O==="home-delivery"?ne:m,k=(h==null?void 0:h.LocationName)||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location)||(e==null?void 0:e.address)||"",x=(e==null?void 0:e.source)==="ZT"||["Karyana","Zymo","Kyp"].includes(e==null?void 0:e.source)&&O==="home-delivery"?"Home Delivery":(P=h==null?void 0:h.LocationName)!=null&&P.includes("Doorstep")?"Doorstep Delivery":"Self Pickup",b=we();return{userId:B||"",firstName:(a==null?void 0:a.name)||(a==null?void 0:a.userName)||"",email:(a==null?void 0:a.email)||"",phoneNumber:i||"",carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`,carImage:((C=e==null?void 0:e.images)==null?void 0:C[0])||"",city:p||"",startDate:I,endDate:A,pickupLocation:k,vendor:d,deliveryType:x,homeDeliveryCharges:D,price:n||0,source:(e==null?void 0:e.source)||"",origin_channel:b.origin_channel,booking_session_id:b.booking_session_id,app_instance_id:b.app_instance_id}},[e,a,B,m,ne,O,I,A,h,d,D,n]),G=c.useCallback(async(s,i=null,p=null)=>{console.log("[FIREBASE SAVE] Starting saveSuccessfulBooking",{paymentId:s,bookingId:i,cashfreeOrderId:p,userId:B,carSource:e==null?void 0:e.source,fullDataPersisted:ye.current});try{const{ga_client_id:k,ga_session_id:x,ga_source:b}=await bt(),P=we();if(ye.current&&Z.current){const W=Z.current;console.log("[BOOKING] Fast path: flipping status for pre-persisted booking:",W);const oe={...fe.current||{},bookingId:W,paymentId:s,cashfreeOrderId:p||null,paymentStatus:"completed",paymentCompletedAt:Date.now()};v(oe);
2const pe=Ye(Fe,"CarsPaymentSuccessDetails",W);return await Ze(()=>Je(pe,{paymentStatus:"completed",paymentCompletedAt:Date.now(),paymentId:s,ga_client_id:k||null,ga_session_id:x||null,ga_source:b||null,origin_channel:P.origin_channel,booking_session_id:P.booking_session_id,app_instance_id:P.app_instance_id},{merge:!0}),[],3,1e3),console.log("[BOOKING] Status flipped to completed for:",W),ye.current=!1,fe.current=null,W}const C=i||"Z"+new Date().getTime().toString();console.log(`[BOOKING ID] Using ${i?"backend-generated":"legacy timestamp"} format:`,C),console.log("[FIREBASE SAVE] Uploading user documents...");const T=await Y(S);console.log("[FIREBASE SAVE] Documents uploaded successfully");const ee={...R(T),bookingId:C,paymentId:s,cashfreeOrderId:p||null,ga_client_id:k||null,ga_session_id:x||null,ga_source:b||null};v(ee);const N=Ye(Fe,"CarsPaymentSuccessDetails",C),ie={...ee,paymentStatus:"completed",paymentCompletedAt:Date.now()};return await Ze(()=>Je(N,ie,{merge:!0}),[],3,1e3),console.log("[FIREBASE SAVE] Booking saved successfully:",{bookingId:C,paymentId:s}),C}catch(k){throw console.error("â [FIREBASE SAVE] Failed to save booking to Firebase",{error:k.message,paymentId:s,bookingId:i}),Ne(k,{context:"saveSuccessfulBooking",paymentId:s,bookingId:i}),k}},[e==null?void 0:e.source,B,S,R,Y,v]),re=c.useCallback(async s=>{var i,p,k;try{const x=a==null?void 0:a.phone,b=x!=null&&x.startsWith("+91")?x:`+91${x}`,P={failureType:s.failureType,failureTimestamp:Date.now(),failureDate:Le(Date.now()),retryAttempts:s.retryAttempts||3,recoveryStatus:"pending",paymentId:s.paymentId,paymentAmount:n||0,paymentStatus:"succeeded",zoomcarBookingId:s.zoomcarBookingId||null,zoomcarResponse:s.zoomcarResponse||null,error:{message:((i=s.error)==null?void 0:i.message)||"Unknown error",stack:((p=s.error)==null?void 0:p.stack)||null,timestamp:Date.now()},bookingData:s.bookingData||{CarImage:((k=e==null?void 0:e.images)==null?void 0:k[0])||"",CarName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`,City:m,Email:(a==null?void 0:a.email)||"",FirstName:(a==null?void 0:a.name)||"",PhoneNumber:b,UserId:B||"",Vendor:"ZoomCar",StartDate:Ce(y)||y||"N/A",EndDate:Ce(g)||g||"N/A",price:n||0,"Pickup Location":(h==null?void 0:h.LocationName)||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location)||""},car:{id:e==null?void 0:e.id,cargroup_id:e==null?void 0:e.cargroup_id,brand:e==null?void 0:e.brand,name:e==null?void 0:e.name,pricing_id:e==null?void 0:e.pricing_id,location_id:e==null?void 0:e.location_id},bookingParams:{city:m,startDate:I,endDate:A,startDateEpoch:Date.parse(y),endDateEpoch:Date.parse(g),pickupLocation:h||(e==null?void 0:e.pickupLocation),dropLocation:H||(e==null?void 0:e.pickupLocation)},user:{uid:B,name:a==null?void 0:a.name,email:a==null?void 0:a.email,phone:a==null?void 0:a.phone}},C=await jt(vt(Fe,"CarsZoomcarBookingFailures"),P);return console.log("â
Failure record saved to CarsZoomcarBookingFailures:",C.id),C.id}catch(x){return console.error("ð¥ CRITICAL: Failed to save failure record to Firebase:",x.message),null}},[e,a,m,B,n,y,g,I,A,h,H]),ve=c.useCallback(async s=>{var i,p,k,x;try{const b=a==null?void 0:a.phone,P=b!=null&&b.startsWith("+91")?b:`+91${b}`,C={vendor:s.vendor||d,failureType:s.failureType||"firebase_save_failed",failureTimestamp:Date.now(),failureDate:Le(Date.now()),recoveryStatus:"pending",paymentId:s.paymentId,orderId:s.orderId||null,paymentAmount:n||0,paymentStatus:"succeeded",error:{message:((i=s.error)==null?void 0:i.message)||"Unknown error",stack:((p=s.error)==null?void 0:p.stack)||null,timestamp:Date.now()},bookingData:{CarImage:((k=e==null?void 0:e.images)==null?void 0:k[0])||"",CarName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`,City:m,Email:(a==null?void 0:a.email)||"",FirstName:(a==null?void 0:a.name)||"",PhoneNumber:P,UserId:B||"",Vendor:s.vendor||d,StartDate:Ce(y)||y||"N/A",EndDate:Ce(g)||g||"N/A",price:n||0,"Pickup Location":(h==null?void 0:h.LocationName)||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location)||"",deliveryType:O,homeDeliveryCharges:D},car:{id:e==null?void 0:e.id,source:e==null?void 0:e.source,brand:e==null?void 0:e.brand,name:e==null?void 0:e.name,vendorId:e==null?void 0:e.vendorId},user:{uid:B,name:a==null?void 0:a.name,email:a==null?void 0:a.email,phone:a==null?void 0:a.phone}},T=await jt(vt(Fe,"CarsBookingFailures"),C);return console.log("â
Failure record saved to CarsBookingFailures:",T.id),Pt("booking_failure",{vendor:s.vendor||d,payment_id:s.paymentId,error_message:(x=s.error)==null?void 0:x.message,failure_record_id:T.id}),T.id}catch(b){return console.error("ð¥ CRITICAL: Failed to save failure record:",b.message),null}},[e,a,m,B,d,n,y,g,h,O,D]),Ie=c.useCallback(async()=>{var C,T,ee;const s=Date.parse(y),i=Date.parse(g),p=we(),k=await He(),x=await Ze(async()=>{const N=await fetch(`${J}/zoomcar/bookings/create-booking`,{method:"POST",body:JSON.stringify({customer:{uid:B,name:a==null?void 0:a.name,phone:a==null?void 0:a.phone,email:a==null?void 0:a.email},booking_params:{type:"normal",cargroup_id:e==null?void 0:e.cargroup_id,car_id:e==null?void 0:e.id,city:m,ends:i,fuel_included:!1,lat:e==null?void 0:e.lat,lng:e==null?void 0:e.lng,pricing_id:e==null?void 0:e.pricing_id,search_location_id:e==null?void 0:e.location_id,starts:s,pickup_location:h||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location),drop_location:H||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location)},origin_channel:p.origin_channel,booking_session_id:p.booking_session_id,ga_client_id:p.ga_client_id,ga_session_id:p.ga_session_id,ga_source:p.ga_source,app_instance_id:p.app_instance_id}),headers:{"Content-Type":"application/json",...k}});if(!N.ok)throw new Error(`Error: ${N.status} - ${N.statusText}`);return N.json()});if(x.status!==1){const N=x.msg||"Failed to reserve car. Please try again.";throw new Error(N)}const b=(C=x==null?void 0:x.booking)==null?void 0:C.confirmation_key,P=(ee=(T=x==null?void 0:x.booking)==null?void 0:T.fare)==null?void 0:ee.total_amount;if(!b)throw new Error("ZoomCar booking created but no confirmation key returned");return console.log("[ZOOMCAR] Booking reserved (pre-payment):",b,"amount:",P),{confirmationKey:b,totalAmount:P}},[e,m,y,g,B,a,J,h,H]),te=c.useCallback(async s=>{try{const i=await He();await fetch(`${J}/zoomcar/bookings/cancel-booking`,{method:"POST",body:JSON.stringify({data:{booking_id:s,uid:B,city:m}}),headers:{"Content-Type":"application/json",...i}}),console.log("[ZOOMCAR] Cancelled booking after payment failure:",s)}catch(i){console.error("[ZOOMCAR] Failed to cancel booking (webhook will handle):",i.message)}},[J,B,m]);c.useCallback(async()=>{var W,oe,pe;const{ga_client_id:s,ga_session_id:i,ga_source:p}=await bt(),k=we(),x=Date.parse(y),b=Date.parse(g),P=await He(),C=await fetch(`${J}/zoomcar/bookings/create-booking`,{method:"POST",body:JSON.stringify({ga_client_id:s,ga_session_id:i,ga_source:p,origin_channel:k.origin_channel,booking_session_id:k.booking_session_id,app_instance_id:k.app_instance_id,customer:{uid:B,name:a==null?void 0:a.name,phone:a==null?void 0:a.phone,email:a==null?void 0:a.email},booking_params:{type:"normal",cargroup_id:e==null?void 0:e.cargroup_id,car_id:e==null?void 0:e.id,city:m,ends:b,fuel_included:!1,lat:e==null?void 0:e.lat,lng:e==null?void 0:e.lng,pricing_id:e==null?void 0:e.pricing_id,search_location_id:e==null?void 0:e.location_id,starts:x,pickup_location:h||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location),drop_location:H||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location)}}),headers:{"Content-Type":"application/json",...P}});if(!C.ok)throw new Error(`Error: ${C.status} - ${C.statusText}`);const T=await C.json();if(T.status!==1){const ke=T.msg||"Something went wrong...";throw $.error(ke,{position:"top-center",autoClose:5e3}),new Error(ke)}$.info("Booking process started...",{position:"top-center",autoClose:5e3});const ee=(W=T==null?void 0:T.booking)==null?void 0:W.confirmation_key,N=(pe=(oe=T==null?void 0:T.booking)==null?void 0:oe.fare)==null?void 0:pe.total_amount,ie=await Ze(We,[ee,N,s,i,p]);if(ie.status!==1){const ke=ie.msg||"Error while payment update";throw $.error(ke,{position:"top-center",autoClose:5e3}),new Error(ke)}return ee},[e,m,y,g,B,a,J,h,H]);const We=c.useCallback(async(s,i,p,k,x)=>{const b=we(),P=await He(),C=await fetch(`${J}/zoomcar/payments`,{method:"POST",body:JSON.stringify({ga_client_id:p,ga_session_id:k,ga_source:x,origin_channel:b.origin_channel,booking_session_id:b.booking_session_id,app_instance_id:b.app_instance_id,customer:{uid:B,name:a==null?void 0:a.name,phone:a==null?void 0:a.phone,email:a==null?void 0:a.email},city:m,bookingData:{booking_id:s,amount:i}}),headers:{"Content-Type":"application/json",...P}});if(!C.ok)throw new Error(`${C.status} (${C.statusText})`);return C.json()},[J,B,a,m]),_e={userDetails:a,userData:o,startDateFormatted:I,endDateFormatted:A,city:m,car:e,vendor:d,payableAmount:n,selectedPickupLocation:h,functionsUrl:J},Ke=c.useCallback(async s=>{try{const i=await G(s.payment_id,null,s.cashfree_order_id||null);if(!Q.current){const p=typeof n=="string"?parseFloat(n)||0:n||0;Te({bookingId:i,amount:p,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`,carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||i,vendor:d,city:m,conversionLabel:"purchase"}),Be.completed({bookingId:i,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||i,vendor:d,city:m,price:p,paymentId:s.payment_id||s.cashfree_payment_id}),Q.current=!0,Ve()}Ct({..._e,bookingId:i}).catch(console.error),ae("success"),ce(!0),j(!1)}catch(i){console.error("â [MYCHOIZE] Booking failed:",i),Ne(i,{context:"handleMychoizeBooking",vendor:"Mychoize"}),Be.failed({errorType:"firebase_save_failed",errorMessage:(i==null?void 0:i.message)||"Unknown error",carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),vendor:"Mychoize"}),await ve({vendor:"Mychoize",paymentId:s.payment_id,orderId:s.order_id,error:{message:i==null?void 0:i.message,stack:i==null?void 0:i.stack},failureType:"firebase_save_failed"}),j(!0)}},[G,n,e,d,m,_e,ve,ae,ce,j]),xe=c.useCallback(async s=>{const i=Z.current,p=s.zoomcarConfirmationKey||null;try{const k=i||"Z"+new Date().getTime().toString();if(await G(s.payment_id,k,s.cashfree_order_id||null),i&&p){const x=Ye(Fe,"CarsPaymentSuccessDetail
2s",i);await Je(x,{zoomcarConfirmationCode:p},{merge:!0}),console.log("[ZOOMCAR] Stored confirmation code:",p,"on doc:",i)}if(!Q.current){const x=p||k,b=typeof n=="string"?parseFloat(n)||0:n||0;Te({bookingId:x,amount:b,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`,carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||x,vendor:"ZoomCar",city:m,conversionLabel:"purchase"}),Be.completed({bookingId:x,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||x,vendor:"ZoomCar",city:m,price:b,paymentId:s.payment_id||s.cashfree_payment_id}),Q.current=!0,Ve()}Xn({..._e,bookingId:p}).catch(console.error),ae("success"),ce(!0),j(!1)}catch(k){await re({failureType:"firebase_save_failed",paymentId:s.payment_id,zoomcarBookingId:p,zoomcarResponse:null,retryAttempts:3,error:{message:k.message,stack:k.stack},bookingData:{paymentAmount:n,startDate:y,endDate:g,city:m,pickupLocation:(h==null?void 0:h.LocationName)||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location),dropLocation:(H==null?void 0:H.LocationName)||(e==null?void 0:e.pickupLocation)||(e==null?void 0:e.pick_up_location),userDetails:{name:a==null?void 0:a.name,email:a==null?void 0:a.email,phone:a==null?void 0:a.phone}}}),j(!0)}},[G,re,e,n,m,y,g,h,H,a,_e,ae,ce,j,Z]),Xe=c.useCallback(async s=>{try{const i=await G(s.payment_id,s.backend_booking_id||null,s.cashfree_order_id||null);if(!Q.current){Q.current=!0;const p=typeof n=="string"?parseFloat(n)||0:n||0;Te({bookingId:i,amount:p,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`,carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||i,vendor:d,city:m,conversionLabel:"purchase"}),Be.completed({bookingId:i,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||i,vendor:d,city:m,price:p,paymentId:s.payment_id||s.cashfree_payment_id}),Ve()}Ct({bookingId:i,userDetails:a,userData:o,startDateFormatted:I,endDateFormatted:A,city:m,car:e,vendor:d,payableAmount:n,selectedPickupLocation:h,functionsUrl:J}).catch(p=>console.warn("[PARTNER] WhatsApp notification failed:",p==null?void 0:p.message)),ae("success"),ce(!0)}catch(i){console.error("â [PARTNER] Booking failed:",i),Ne(i,{context:"handleOthersVendorBooking",vendor:d}),Be.failed({errorType:"firebase_save_failed",errorMessage:(i==null?void 0:i.message)||"Unknown error",carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),vendor:d}),await ve({vendor:d,paymentId:s.payment_id,orderId:s.order_id,error:i,failureType:"firebase_save_failed"}),j(!0)}},[G,ve,n,e,d,m,ae,ce,j]);return{paymentHandlerState:je,backendBookingId:Z,fullDataPersistedRef:ye,prePaymentBookingDataRef:fe,bookingSuccessEventFired:Q,buildFullBookingData:R,buildBookingContext:$e,uploadDocs:Y,handleMychoizeBooking:Ke,handleZoomcarBooking:xe,handleOthersVendorBooking:Xe,saveSuccessfulBooking:G,createZoomcarBookingOnly:Ie,cancelZoomcarBooking:te}}function na(r){const{car:e,vendor:l,city:a,userDetails:o,documents:S,payableAmount:n,effectiveUid:d,setIsPaying:K,setShowBookingFailurePopup:F,paymentHandlerState:m,backendBookingId:y,fullDataPersistedRef:g,prePaymentBookingDataRef:I,bookingSuccessEventFired:A,uploadDocs:z,buildFullBookingData:O,buildBookingContext:D,handleMychoizeBooking:le,handleZoomcarBooking:de,handleOthersVendorBooking:ne,createZoomcarBookingOnly:me,cancelZoomcarBooking:h,runV2ZoomcarBookingFlow:H}=r,B=c.useRef(null),he=c.useRef(null);c.useEffect(()=>{if(typeof window>"u")return;const j=()=>{const f=he.current;if(f)try{const v="https://us-central1-letzrent-5f5a3.cloudfunctions.net/api",w=`${v}/zoomcar/client-unload-recovery`,V=JSON.stringify({cfOrderId:f.cfOrderId,uid:f.uid,reason:"client_unload_before_callable_complete"}),M=new Blob([V],{type:"application/json"});navigator.sendBeacon(w,M)}catch(v){console.warn("[useCashfreePayment] beforeunload beacon send failed:",v)}};return window.addEventListener("beforeunload",j),()=>window.removeEventListener("beforeunload",j)},[]);const J=c.useCallback(async(j,f)=>
2{if(console.log("â
[CASHFREE] Payment completed, verifying...",{orderId:j,paymentId:f.paymentId,timestamp:new Date().toISOString()}),m.current.isHandlingPayment){console.warn("â ï¸ [CASHFREE] Already handling payment - ignoring duplicate call");return}m.current.isHandlingPayment=!0,m.current.handlerName="handleCashfreePaymentSuccess",K(!0);try{const v=typeof n=="string"?parseFloat(n)||0:n||0;Te({bookingId:y.current||j,amount:v,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||y.current||j,vendor:l,city:a,conversionLabel:"purchase"}),console.log("[CASHFREE] GA4 purchase tracked early:",y.current||j),A.current=!0;try{const w=y.current||j;w&&sessionStorage.setItem(`ga4_pt_${w}`,"1")}catch(w){console.warn("[silent-catch useCashfreePayment.ts:167]:",w&&w.message)}}catch(v){console.error("[CASHFREE] GA4 early tracking failed (non-fatal):",v)}try{const v=await _n(j);if(v.success){m.current.paymentSucceeded=!0,console.log("â
[CASHFREE] Verification successful, processing booking..."),Re.completed({amount:n,paymentId:f.paymentId||j,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),vendor:l,city:a,paymentGateway:"cashfree"});const w={payment_id:f.paymentId||`cf_${j}`,order_id:j,cashfree_payment_id:f.paymentId,cashfree_order_id:j,payment_gateway:"cashfree",backend_booking_id:y.current||null,zoomcarConfirmationKey:B.current||null};if(l==="Mychoize")await le(w);else if(l==="ZoomCar"){if(on("zoomcar_website_client_confirm",{userId:d||void 0})&&f.paymentId){he.current={cfOrderId:j,cfPaymentId:f.paymentId,uid:d||""};try{console.log("[ZOOMCAR-CLIENT-CONFIRM] Flag ON â calling finalizeZoomcarPayment callable");const M=Rn(fn,"finalizeZoomcarPayment"),L=45e3,q=new Promise((je,Z)=>setTimeout(()=>Z(new Error("finalizeZoomcarPayment client-side timeout after 45s")),L));q.catch(()=>{});const Q=(await Promise.race([M({cfOrderId:j,cfPaymentId:f.paymentId}),q])).data;console.log("[ZOOMCAR-CLIENT-CONFIRM] Callable result:",Q),Q.success===!1&&Q.requiresManualAction?$.warning("Your booking is being processed. Our team will c
2onfirm shortly and contact you.",{position:"top-center",autoClose:8e3}):Q.pendingConfirmation&&$.info("Payment received. Finalizing your booking...",{position:"top-center",autoClose:5e3})}catch(M){console.error("[ZOOMCAR-CLIENT-CONFIRM] Callable threw:",M),Ne(M,{context:"finalizeZoomcarPayment_error",vendor:l,cfOrderId:j,cfPaymentId:f.paymentId});const L=(M==null?void 0:M.code)||"";if(L==="failed-precondition"||L==="unauthenticated"||L==="permission-denied"){$.error(`Payment could not be finalized. Please contact support with payment ID: ${f.paymentId}`,{position:"top-center",autoClose:1e4}),F(!0);return}console.warn("[ZOOMCAR-CLIENT-CONFIRM] Non-fatal error, deferring to webhook path"),$.info("Finalizing your booking...",{position:"top-center",autoClose:5e3})}finally{he.current=null}}await de(w)}else await ne(w)}else console.error("â [CASHFREE] Verification FAILED:",v),Se("payment_failed",{...Pe(),error:"verification_failed",vendor:l,city:a,amount:n,car_name:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),payment_gateway:"cashfree"}),Re.failed({amount:n,error:"verification_failed",carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),vendor:l,paymentGateway:"cashfree"}),$.error("Payment verification failed. Please contact support if amount was deducted.",{position:"top-center",autoClose:7e3}),F(!0)}catch(v){console.error("â [CASHFREE] Error during verification:",v),Ne(v,{context:"cashfree_verification",vendor:l}),Se("payment_failed",{...Pe(),error:(v==null?void 0:v.message)||"verification_error",vendor:l,city:a,amount:n,car_name:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),payment_gateway:"cashfree"}),Re.failed({amount:n,error:(v==null?void 0:v.message)||"verification_error",carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),vendor:l,paymentGateway:"cashfree"}),$.error("Payment verification failed. Please contact support if amount was deducted.",{position:"top-center",autoClose:7e3}),F(!0)}finally{K(!1),m.current.isHandlingPayment=!1,m.current.handlerName=null}},[e,l,a,n,d,K,F,m,y,le,de,ne]),ae=c.useCallback(async()=>{if(!H)throw new Error("handleV2ZoomcarPayment: runV2ZoomcarBookingFlow not provided");if(g.current=!1,I.current=null,!await wt()){$.error("Could not load Cashfree, Please try again later...",{position:"top-center",autoClose:5e3});return}let f;try{f=await H()}catch(_){console.error("[CASHFREE V2] book step failed:",_),Ne(_,{context:"cashfree_v2_book",vendor:l}),$.error((_==null?void 0:_.message)||"Failed to reserve car. Please try again.",{position:"top-center",autoClose:5e3});return}y.current=f.confirmationKey,B.current=f.confirmationKey,g.current=!0;const w=await window.Cashfree({mode:"production"}).checkout({paymentSessionId:f.paymentSessionId,redirectTarget:"_modal"});if(w.error){console.error("[CASHFREE V2] Payment error:",w.error),$.error(w.error.message||"Payment failed. Please try again.",{position:"top-center",autoClose:5e3}),F(!0);return}const V=w.paymentDetails;if(!(V&&(V.paymentMessage==="Payment successful"||V.paymentStatus==="SUCCESS"))){console.error("[CASHFREE V2] Payment not successful:",V),$.error(V&&V.paymentMessage||"Payment failed. Please try again.",{position:"top-center",autoClose:5e3}),F(!0);return}try{Te({bookingId:f.confirmationKey,amount:f.amount,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),carId:(e==null?void 0:e.id)||(e==null?void 0:e.carId)||f.confirmationKey,vendor:"ZoomCar",city:a,conversionLabel:"purchase"}),A.current=!0;try{const _=y.current||f.confirmationKey;_&&sessionStorage.setItem(`ga4_pt_${_}`,"1")}catch(_){console.warn("[silent-catch useCashfreePayment.ts:371]:",_&&_.message)}Ve()}catch(_){console.error("[CASHFREE V2] GA4 tracking failed (non-fatal):",_)}try{Re.completed({amount:f.amount,paymentId:f.cashfreeOrderId,carName:`${(e==null?void 0:e.brand)||""} ${(e==null?void 0:e.name)||""}`.trim(),vendor:"ZoomCar",city:a,paymentGateway:"cashfree"})}catch(_){console.error("[CASHFREE V2] Mixpanel tracking failed (non-fatal):",_)}m.current.paymentSucceeded=!0,m.current.isHandlingPayment=!0,K(!0);let L=!1;const q=Date.now();for(;Date.now()-q<3e4;){try{if((await Tn(f.confirmationKey)).paymentStatus==="captured"){L=!0;break}}catch(_){console.warn("[CASHFREE V2] bookingState poll failed (will retry):",_)}await new Promise(_=>setTimeout(_,2e3))}m.current.isHandlingPayment=!1,K(!1),L?$.success("Booking confirmed!",{position:"top-center",autoClose:3500}):$.info("Payment received. We're finalising your booking â you'll see it on My Trips shortly.",{position:"top-center",autoClose:7e3})},[e,a,l,H,g,I,y,A,m,K,F]);return{handleCashfreePayment:c.useCallback(async()=>
2{if(l==="ZoomCar"&&Ln()&&typeof H=="function")return ae();try{if(g.current=!1,I.current=null,!await wt()){console.error("[CASHFREE] SDK failed to load!"),$.error("Could not load Cashfree, Please try again later...",{position:"top-center",autoClose:5e3});return}const f=l==="ZoomCar";let v=null,w=null,V=null;if(f){console.log("[CASHFREE] ZoomCar: Creating booking before payment (Book First, Charge Later)...");try{const R=await me();w=R.confirmationKey,V=R.totalAmount,B.current=w,console.log("[CASHFREE] ZoomCar booking reserved:",w,"amount:",V),$.info("Car reserved! Processing payment...",{position:"top-center",autoClose:3e3})}catch(R){console.error("[CASHFREE] ZoomCar booking creation failed:",R),$.error(R.message||"Failed to reserve car. Please try again.",{position:"top-center",autoClose:5e3});return}}if(!f){console.log("[CASHFREE] Uploading documents before payment (pre-payment persistence)...");const R=await z(S),$e=S&&Array.isArray(S)&&S.some(re=>(re==null?void 0:re.file_object)||(re==null?void 0:re.file)),G=!(R!=null&&R.LicenseFront)&&!(R!=null&&R.LicenseBack)&&!(R!=null&&R.aadhaarFront)&&!(R!=null&&R.aadhaarBack);if($e&&G){console.error("[CASHFREE] Document upload failed â all returned null"),$.error("Failed to upload documents. Please try again.",{position:"top-center",autoClose:5e3});return}console.log("[CASHFREE] Documents uploaded:",R),v=O(R),I.current=v,console.log("[CASHFREE] Full booking data built for pre-payment persistence")}const M=Math.round(parseFloat(n));console.log("[CASHFREE] Creating order for amount:",M);const L=D();L.clientPlatform="web",f&&w&&(L.zoomcarConfirmationKey=w,L.zoomcarBookingAmount=V,L.zoomcarCity=L.city,L.zoomcarUserId=d,L.zoomcarCustomerPhone=o==null?void 0:o.phone,L.zoomcarCustomerName=(o==null?void 0:o.name)||(o==null?void 0:o.userName));const q=we(),{ga_client_id:_,ga_session_id:Q,ga_source:je}=q,Z=await Cn(M,"INR",{userId:d,phone:o==null?void 0:o.phone,email:o==null?void 0:o.email,name:(o==null?void 0:o.name)||(o==null?void 0:o.userName)},L,v,q);if(!(Z!=null&&Z.payment_session_id))throw new Error("Failed to get payment session from Cashfree");Z.bookingId&&(y.current=Z.bookingId,console.log("[CASHFREE] Backend generated booking ID:",Z.bookingId)),!f&&Z.bookingId&&(g.current=!0,console.log("[CASHFREE] Full booking data persisted â post-payment will only flip status")),console.log("[CASHFREE] Order created:",{order_id:Z.order_id,payment_session_id:Z.payment_session_id?"present":"missing",bookingId:Z.bookingId||"not returned (will generate client-side)",fullDataPersisted:g.current});const ye=window.Cashfree({mode:"production"}),fe={paymentSessionId:Z.payment_session_id,redirectTarget:"_modal"};console.log("[CASHFREE] Opening checkout modal...");const Y=await ye.checkout(fe);if(console.log("[CASHFREE] Checkout result:",Y),Y.error){console.error("[CASHFREE] Payment error:",Y.error),$.error(Y.error.message||"Payment failed. Please try again.",{position:"top-center",autoClose:5e3}),F(!0);return}Y.paymentDetails&&(Y.paymentDetails.paymentMessage==="Payment successful"||Y.paymentDetails.paymentStatus==="SUCCESS"?(console.log("[CASHFREE] Payment successful:",Y.paymentDetails),await J(Z.order_id,Y.paymentDetails)):(console.error("[CASHFREE] Payment failed:",Y.paymentDetails),$.error(Y.paymentDetails.paymentMessage||"Payment failed. Please try again.",{position:"top-center",autoClose:5e3}),F(!0)))}catch(j){console.error("[CASHFREE] Error during payment:",j),Ne(j,{context:"cashfree_handlePayment",vendor:l}),$.error("Failed to initiate payment. Please try again.",{position:"top-center",autoClose:5e3})}},[l,S,n,d,o,F,g,I,y,z,O,D,J,me,h,H,ae])}}const aa=()=>{var ot,st,rt,it,lt,dt,mt,ct,pt,gt,ut,xt,yt,ht,ft;const r=dn(),e=mn(),l=gn(),{userDetails:a,carDetails:o,documents:S,car:n,payableAmount:d,mychoizeDropupLocations:K,mychoizePickupLocations:F,selectedPickupLocation:m,selectedDropLocation:y,userData:g,startDate:I,endDate:A,tripDuration:z,deliveryType:O,homeDeliveryCharges:D,deliveryCharges:le,wheelupDeliveryCharge:de,street1:ne,street2:me,deliveryCity:h,zipcode:H,profileVerified:B,promoCode:he,promoDiscount:J,voucherDiscount:ae,rsaAddon:ce,rsaAmount:j}=r.state||{},f=I?Le(I):"N/A",v=A?Le(A):"N/A",[w,V]=c.useState(!1),[M,L]=c.useState(!1),[q,_]=c.useState(Sn),[Q,je]=c.useState(!1),[Z,ye]=c.useState("loading"),[fe,Y]=c.useState(null),[R,$e]=c.useState(!1),[G,re]=c.useState(null),[ve,Ie]=c.useState(!1),[te,We]=c.useState(null),[_e,Ke]=c.useState(!0),[xe,Xe]=c.useState(O||"self-pickup"),[s,i]=c.useState(D||0),[p,k]=c.useState(le||0),[x,b]=c.useState(de||0),[P,C]=c.useState(ne||""),[T,ee]=c.useState(me||""),[N,ie]=c.useState(h||""),[W,oe]=c.useState(H||"");c.useEffect(()=>{},[]),c.useEffect(()=>{const u=kn(At,E=>{We(E),Ke(!1),E?console.log("â
[AUTH] User authenticated from Firebase:",{uid:E.uid,email:E.email}):console.log("â ï¸ [AUTH] No authenticated user in Firebase Auth")});return()=>u()},[]);const pe=(te==null?void 0:te.uid)||(g==null?void 0:g.uid),ke=(te==null?void 0:te.email)||(g==null?void 0:g.email),Bt="https://us-central1-letzrent-5f5a3.cloudfunctions.net/api",Rt=((ot=r.pathname.match(/self-drive-car-rental-in-([a-z-]+)\/cars/))==null?void 0:ot[1])||"",{city:Tt}=cn(),se=Tt||Rt;let X,Qe=null,De=!1;(n==null?void 0:n.source)==="zoomcar"?X="ZoomCar":(n==null?void 0:n.source)==="mychoize"?X="Mychoize":(X="ZIP",Qe=(n==null?void 0:n.vendor)||(n==null?void 0:n.source)||null,De=!0);const{paymentHandlerState:Lt,backendBookingId:$t,fullDataPersistedRef:Ot,prePaymentBookingDataRef:Mt,bookingSuccessEventFired:et,buildFullBookingData:zt,buildBookingContext:Zt,uploadDocs:Ht,handleMychoizeBooking:Vt,handleZoomcarBooking:Wt,handleOthersVendorBooking:Kt,createZoomcarBookingOnly:Ut,cancelZoomcarBooking:Gt}=ta({car:n,carDetails:o,userDetails:a,userData:g,documents:S,payableAmount:d,vendor:X,derivedOwnerName:Qe,derivedIsPartnerVendor:De,city:se,startDate:I,endDate:A,startDateFormatted:f,endDateFormatted:v,tripDuration:z,deliveryType:xe,homeDeliveryCharges:s,street1:P,street2:T,deliveryCity:N,zipcode:W,selectedPickupLocation:m,selectedDropLocation:y,effectiveUid:pe,effectiveEmail:ke,functionsUrl:Bt,setConfirmPopupStatus:ye,setIsConfirmPopupOpen:je,setShowBookingFailurePopup:Ie,setIsPaying:V,setBookingData:re,vendorDetails:fe,promoCode:he||null,promoDiscount:J||0,voucherDiscount:ae||0,rsaAddon:ce||!1,rsaAmount:j||0}),{handleCashfreePayment:Yt}=na({car:n,vendor:X,city:se,userDetails:a,documents:S,payableAmount:d,effectiveUid:pe,setIsPaying:V,setShowBookingFailurePopup:Ie,paymentHandlerState:Lt,backendBookingId:$t,fullDataPersistedRef:Ot,prePaymentBookingDataRef:Mt,bookingSuccessEventFired:et,uploadDocs:Ht,buildFullBookingData:zt,buildBookingContext:Zt,handleMychoizeBooking:Vt,handleZoomcarBooking:Wt,handleOthersVendorBooking:Kt,createZoomcarBookingOnly:Ut,cancelZoomcarBooking:Gt});un(()=>{var u;
2return{city:se,vendor:X,price:typeof d=="string"?parseFloat(d)||0:d||0,deposit:parseFloat((((u=o==null?void 0:o.fareDetails)==null?void 0:u.deposit)||"0").replace(/[^0-9.]/g,""))||0,logged_in:!!te,returning_user:!1,last_step:"summary_page"}},et),c.useEffect(()=>{Se("summary_page_viewed",{...Pe(),city:se,vendor:X,car_source:n==null?void 0:n.source,car_id:(n==null?void 0:n.carId)||(n==null?void 0:n.id),amount:typeof d=="string"?parseFloat(d)||0:d||0,pickup_date:I||null,drop_date:A||null,rental_days:z||null,logged_in:!!pe})},[]);const Jt=c.useMemo(()=>{if((n==null?void 0:n.source)!=="zoomcar")return null;const u=(o==null?void 0:o.fareDetails)||{},E=u.actualPrice||(n==null?void 0:n.actualPrice)||0,U=u.platformFee||0,ge=parseFloat((u.priceAfterDiscount||"0").replace(/[^0-9.]/g,"")),be=parseFloat((u.tripInsurance||"0").replace(/[^0-9.]/g,"")),Me=parseFloat((u.deposit||"0").replace(/[^0-9.]/g,"")),Ae=E>ge?Math.round(E)-ge:0,Ee=Ae+U,ze=ge+be;return{actualPrice:Math.round(E),platformFee:U,discountedPrice:ge,tripInsurance:be,deposit:Me,rentalSavings:Ae,totalSavings:Ee,tripCost:ze,hasOriginalPrice:E>0&&E>ge,hasPlatformFee:U>0,hasSavings:Ee>0}},[n==null?void 0:n.source,n==null?void 0:n.actualPrice,o==null?void 0:o.fareDetails]),tt=parseFloat((((st=o==null?void 0:o.fareDetails)==null?void 0:st.deposit)||"0").replace(/[^0-9.]/g,""))||0,qt=()=>{var u,E,U,ge,be,Me,Ae,Ee,ze,kt;return{name:(a==null?void 0:a.name)||"",email:(a==null?void 0:a.email)||"",phone:(a==null?void 0:a.phone)||"",car_name:((u=o==null?void 0:o.headerDetails)==null?void 0:u.name)||"",car_type:((E=o==null?void 0:o.headerDetails)==null?void 0:E.type)||"",car_range:((U=o==null?void 0:o.headerDetails)==null?void 0:U.range)||"",transmission:((ge=o==null?void 0:o.carDetails)==null?void 0:ge.transmission)||"",fuel:((be=o==null?void 0:o.carDetails)==null?void 0:be.fuel)||"",seats:((Me=o==null?void 0:o.carDetails)==null?void 0:Me.seats)||"",pickup_location:Oe(m,(n==null?void 0:n.pickupLocation)||(n==null?void 0:n.pick_up_location)||(n==null?void 0:n.address)),drop_location:Oe(y,(n==null?void 0:n.pickupLocation)||(n==null?void 0:n.pick_up_location)||(n==null?void 0:n.address)),city:((Ae=o==null?void 0:o.pickup)==null?void 0:Ae.city)||se||"",start_date:((Ee=o==null?void 0:o.pickup)==null?void 0:Ee.startDate)||f,end_date:((ze=o==null?void 0:o.pickup)==null?void 0:ze.endDate)||v,duration:((kt=o==null?void 0:o.pickup)==null?void 0:kt.tripDuration)||z||"",...o==null?void 0:o.fareDetails,delivery_type:xe,home_delivery_charges:s,documents_uploaded:(n==null?void 0:n.source)!=="zoomcar"&&(S==null?void 0:S.length)>0}};c.useEffect(()=>{bn.track("car summary page",{...qt()})},[]),c.useEffect(()=>{const u=async()=>{if((n==null?void 0:n.source)==="Zymo"){Y({vendor:"Zymo",CurrentrateSd:1,TaxSd:0,Securitydeposit:(n==null?void 0:n.securityDeposit)||0,DiscountSd:1});return}const{fetchVendorConfig:E}=await ln(async()=>{const{fetchVendorConfig:ge}=await import("./helperFunctions-B1C4ljAA.js").then(be=>be.v);return{fetchVendorConfig:ge}},__vite__mapDeps([0,1])),U=await E(X);U?Y(U):console.warn(`No vendor details found for ${X}`)};n!=null&&n.source&&u()},[n==null?void 0:n.source,X]);const Xt=u=>{l("payment_initiated",{action:"book_and_pay",label:u,car_name:`${(n==null?void 0:n.brand)||""} ${(n==null?void 0:n.name)||""}`,car_source:(n==null?void 0:n.source)||"Unknown",amount:d})},Qt=u=>{_(u);const E=typeof d=="string"?parseFloat(d)||parseInt(String((n==null?void 0:n.fare)||"0").replace(/[^0-9]/g,""))||0:d||parseInt(String((n==null?void 0:n.fare)||"0").replace(/[^0-9]/g,""))||0;Se("add_payment_info",{...Pe(),currency:"INR",value:E,payment_type:u,city:se,vendor:X,car_source:n==null?void 0:n.source,deposit:tt,pickup_date:I||null,drop_date:A||null,rental_days:z||null,items:[{item_id:(n==null?void 0:n.carId)||(n==null?void 0:n.id)||`${n==null?void 0:n.brand}-${n==null?void 0:n.name}`,item_name:`${n==null?void 0:n.brand} ${n==null?void 0:n.name}`,item_brand:n==null?void 0:n.brand,item_category:"Car Rental",item_category2:n==null?void 0:n.source,price:E,quantity:1}]})},nt=async()=>{if(M||w){console.log("[PAYMENT] Blocked duplicate click - payment already in progress");return}L(!0);try{if(Xt("Book & Pay"),((n==null?void 0:n.source)==="ZT"||((n==null?void 0:n.source)==="Karyana"||(n==null?void 0:n.source)==="Zymo")&&xe==="home-delivery")&&(!(P!=null&&P.trim())||!(N!=null&&N.trim())||!(W!=null&&W.trim()))){$.error("Please fill all required delivery address fields",{position:"top-center",autoClose:3e3});return}const u=(a==null?void 0:a.name)||(a==null?void 0:a.userName);if((n==null?void 0:n.source)!=="mychoize"&&!yn(u,a==null?void 0:a.email,a==null?void 0:a.phone)){console.log("userDetails",a);return}if(!pe){console.error("â [PRE-PAYMENT] User not authenticated - uid missing",{authUser:te?{uid:te.uid,email:te.email}:null,userData:g?{uid:g.uid,email:g.email}:null,effectiveUid:pe,authLoading:_e,timestamp:new Date().toISOString()}),$.error("Please login to continue with booking",{position:"top-center",autoClose:5e3}),Pt("pre_payment_validation_failed",{error_type:"missing_uid",car_source:n==null?void 0:n.source,vendor:X,has_auth_user:!!te,has_userData:!!g});return}
2const E=typeof d=="string"?parseFloat(d)||0:d||0;Se("payment_initiated",{...Pe(),currency:"INR",value:E,vendor:X,city:se,car_source:n==null?void 0:n.source,car_id:(n==null?void 0:n.carId)||(n==null?void 0:n.id),car_name:`${(n==null?void 0:n.brand)||""} ${(n==null?void 0:n.name)||""}`.trim(),payment_gateway:q,pickup_date:I||null,drop_date:A||null,rental_days:z||null}),Re.initiated({amount:d,carName:`${(n==null?void 0:n.brand)||""} ${(n==null?void 0:n.name)||""}`.trim(),vendor:X,city:se,paymentGateway:q}),Se("add_payment_info",{...Pe(),currency:"INR",value:E,payment_type:q,city:se,vendor:X,car_source:n==null?void 0:n.source,deposit:tt,pickup_date:I||null,drop_date:A||null,rental_days:z||null,items:[{item_id:(n==null?void 0:n.carId)||(n==null?void 0:n.id)||`${n==null?void 0:n.brand}-${n==null?void 0:n.name}`,item_name:`${n==null?void 0:n.brand} ${n==null?void 0:n.name}`,item_brand:n==null?void 0:n.brand,item_category:"Car Rental",item_category2:n==null?void 0:n.source,price:E,quantity:1}]}),await Yt()}finally{L(!1)}},Oe=(u,E)=>{if(!u)return E||"Not specified";if(typeof u=="object"&&!Array.isArray(u)){if(u.HubAddress)return u.HubAddress;if(u.LocationName)return u.LocationName;if(u.address)return u.address;const U=Object.keys(u);if(U.length===1&&(typeof u[U[0]]=="string"||typeof u[U[0]]=="number"))return`${U[0]}: ${String(u[U[0]])}`;try{return JSON.stringify(u)}catch{return E||"Not specified"}}return Array.isArray(u)?u.map(U=>typeof U=="object"?JSON.stringify(U):String(U)).join(", "):String(u)};if(!n||!o||!a)return t.jsx(pn,{to:`/self-drive-car-rental-in-${se}/cars`});const Ue=(n==null?void 0:n.source)!=="zoomcar"&&!B&&!S,at=((n==null?void 0:n.source)==="ZT"||((n==null?void 0:n.source)==="Karyana"||(n==null?void 0:n.source)==="Zymo")&&xe==="home-delivery")&&(!P.trim()||!N.trim()||!W.trim()),Ge=M||w||Ue||at,Dt=typeof d=="string"?parseFloat(d)||0:d||0,en=`â¹${An(Dt)}`;return t.jsxs(t.Fragment,{children:[t.jsxs(sn,{children:[t.jsx("title",{children:"Booking Summary | Zymo Self-Drive Car Rentals"}),t.jsx("meta",{name:"description",content:"Review your self-drive car rental booking summary, user details, car specifications, and final fare details before payment."}),t.jsx("link",{rel:"canonical",href:`https://zymo.app${r.pathname}`}),t.jsx("meta",{name:"robots",content:"noindex, follow"})]}),t.jsxs("div",{className:"min-h-screen bg-gray-50 dark:bg-gray-950 text-black dark:text-white",children:[t.jsx("div",{className:"bg-white dark:bg-gray-900 border-b border-gray-200 dark:border-gray-800 sticky top-0 z-20",children:t.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-3 sm:py-4 flex items-center gap-4",children:[t.jsx("button",{onClick:()=>e(-1),className:"flex items-center justify-center min-w-11 min-h-11 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors","aria-label":"Go back",children:t.jsx(rn,{className:"w-5 h-5 text-gray-700 dark:text-gray-300"})}),t.jsx("h1",{className:"text-lg sm:text-xl font-semibold text-gray-900 dark:text-white",children:"Booking Summary"})]})}),t.jsx(Yn,{}),t.jsx("div",{className:"p-4 sm:p-6 md:p-8",children:t.jsxs("main",{className:"max-w-4xl mx-auto space-y-8",children:[t.jsxs("section",{className:"bg-white dark:bg-gray-900 p-4 sm:p-6 rounded-2xl border border-gray-200 dark:border-gray-800 shadow-sm",children:[t.jsx("h2",{className:"text-lg sm:text-xl font-semibold mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 text-gray-900 dark:text-white",children:"User Details"}),t.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 sm:gap-4 text-sm",children:a&&Object.entries(a).map(([u,E])=>["address","city","pincode"].includes(u)&&xe!=="home-delivery"?null:t.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-1",children:[t.jsxs("span",{className:"capitalize font-medium text-gray-500 dark:text-gray-300 text-xs sm:text-sm",children:[u.replace(/([A-Z])/g," $1"),":"]}),t.jsx("span",{className:"text-gray-900 dark:text-white break-all",children:E||"N/A"})]},u))})]}),t.jsxs("section",{className:"bg-white dark:bg-gray-900 p-4 sm:p-6 rounded-2xl border border-gray-200 dark:border-gray-800 shadow-sm",children:[t.jsx("h2",{className:"text-lg sm:text-xl font-semibold mb-4 pb-2 border-b border-gray-200 dark:border-gray-700 text-gray-900 dark:text-white",children:"Car Details"}),t.jsxs("div",{className:"flex flex-col md:flex-row gap-4 sm:gap-6 items-start",children:[t.jsx("img",{src:((it=(rt=o==null?void 0:o.headerDetails)==null?void 0:rt.image)==null?void 0:it[0])||"/images/car.webp",alt:"Selected rental car",className:"w-full max-w-xs mx-auto md:mx-0 rounded-xl shadow-md object-cover h-auto aspect-video"}),t.jsxs("div",{className:"flex-1 w-full text-sm space-y-4 text-gray-700 dark:text-gray-300",children:[t.jsxs("div",{className:"flex flex-wrap gap-4",children:[t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("h3",{className:"font-medium text-gray-500 dark:text-gray-300 text-xs uppercase tracking-wider mb-1",children:"Name"}),t.jsx("p",{className:"text-gray-900 dark:text-white font-medium",children:((lt=o==null?void 0:o.headerDetails)==null?void 0:lt.name)||"N/A"})]}),t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("h3",{className:"font-medium text-gray-500 dark:text-gray-300 text-xs uppercase tracking-wider mb-1",children:"Type"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:((dt=o==null?void 0:o.headerDetails)==null?void 0:dt.type)||"N/A"})]}),t.jsxs("div",{className:"flex-1 min-w-[120px]",children:[t.jsx("h3",{className:"font-medium text-gray-500 dark:text-gray-300 text-xs uppercase tracking-wider mb-1",children:"Range"}),t.jsx("p",{className:"text-gray-900 dark:text-white",children:((mt=o==null?void 0:o.headerDetails)==null?void 0:mt.range)||"N/A"})]})]}),t.jsxs("div",{className:"p-3 sm:p-4 bg-gray-50 dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700",children:[t.jsxs("h3",{className:"font-semibold text-sm sm:text-base mb-3 text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx("svg",{className:"w-4 h-4 text-gray-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}),"Trip Details"]}
2),t.jsxs("div",{className:"space-y-3",children:[xe==="self-pickup"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider mb-1",children:"Pickup Location"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white break-words",children:Oe(m,(n==null?void 0:n.pickupLocation)||(n==null?void 0:n.pick_up_location)||(n==null?void 0:n.address))})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider mb-1",children:"Drop Location"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white break-words",children:Oe(y,(n==null?void 0:n.pickupLocation)||(n==null?void 0:n.pick_up_location)||(n==null?void 0:n.address))})]})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider mb-1",children:"City"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:(((ct=o==null?void 0:o.pickup)==null?void 0:ct.city)||se||"N/A").charAt(0).toUpperCase()+(((pt=o==null?void 0:o.pickup)==null?void 0:pt.city)||se||"").slice(1).toLowerCase()})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider mb-1",children:"Duration"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:((gt=o==null?void 0:o.pickup)==null?void 0:gt.tripDuration)||z||"N/A"})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider mb-1",children:"Start Date"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:((ut=o==null?void 0:o.pickup)==null?void 0:ut.startDate)||f})]}),t.jsxs("div",{children:[t.jsx("p",{className:"text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider mb-1",children:"End Date"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:((xt=o==null?void 0:o.pickup)==null?void 0:xt.endDate)||v})]})]})]})]}),t.jsxs("div",{className:"flex flex-wrap gap-2 sm:gap-3",children:[t.jsx("span",{className:"px-3 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-full text-xs sm:text-sm text-gray-700 dark:text-gray-300",children:((yt=o==null?void 0:o.carDetails)==null?void 0:yt.transmission)||"N/A"}),t.jsx("span",{className:"px-3 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-full text-xs sm:text-sm text-gray-700 dark:text-gray-300",children:((ht=o==null?void 0:o.carDetails)==null?void 0:ht.fuel)||"N/A"}),t.jsx("span",{className:"px-3 py-1.5 bg-gray-100 dark:bg-gray-800 rounded-full text-xs sm:text-sm text-gray-700 dark:text-gray-300",children:((ft=o==null?void 0:o.carDetails)==null?void 0:ft.seats)||"N/A"})]}),((n==null?void 0:n.source)==="ZT"||xe==="home-delivery")&&t.jsxs("div",{className:"p-3 sm:p-4 bg-gray-50 dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700",children:[t.jsx("h3",{className:"font-medium text-gray-500 dark:text-gray-300 text-xs uppercase tracking-wider mb-2",children:"Delivery Address"}),t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:P||"N/A"}),T&&t.jsx("p",{className:"text-sm text-gray-900 dark:text-white",children:T}),t.jsxs("p",{className:"text-sm text-gray-900 dark:text-white",children:[N||"N/A",", ",W||"N/A"]}),s>0&&t.jsxs("p",{className:"text-sm font-medium text-gray-900 dark:text-white mt-2",children:["Delivery Charges: ",t.jsxs("span",{className:"text-gray-600 dark:text-gray-300",children:["â¹",s]})]})]})]})]})]}),t.jsx(Un,{car:n,carDetails:o,zoomCarPricing:Jt,homeDeliveryCharges:s,deliveryCharges:p,wheelupDeliveryCharge:x,payableAmount:d,rsaAddon:ce||!1,rsaAmount:j||0,promoCode:he||null,promoDiscount:J||0,voucherDiscount:ae||0}),t.jsx(Gn,{documents:S,carSource:n==null?void 0:n.source}),t.jsx(Wn,{vendor:X,showCancellationPolicy:!1}),t.jsx("div",{className:"mt-4 mb-3",children:t.jsx(Vn,{selectedGateway:q,onSelect:Qt,disabled:w})}),t.jsxs("div",{className:"flex flex-col justify-center items-center mt-3 pb-8 sm:pb-10 gap-2",children:[t.jsx("button",{className:`w-full sm:w-auto px-6 sm:px-10 py-3.5 sm:py-4 rounded-full font-semibold text-base sm:text-lg transition-all min-h-[48px] 3 ${Ge?"text-gray-400 bg-gray-200 dark:bg-gray-700 cursor-not-allowed":"text-white bg-indigo-600 hover:bg-indigo-700 shadow-lg"}`,onClick:nt,disabled:Ge,children:t.jsxs("span",{className:"flex items-center justify-center gap-2",children:[t.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),M?"Initializing Payment...":"Confirm & Pay Securely"]})}),!M&&!w&&Ue&&t.jsx("p",{className:"text-xs text-center text-gray-500 dark:text-gray-400",children:"Please upload your documents to enable payment"}),!M&&!w&&!Ue&&at&&t.jsx("p",{className:"text-xs text-center text-gray-500 dark:text-gray-400",children:"Please complete your delivery address to enable payment"})]})]})}),t.jsx(Jn,{isVisible:w}),t.jsx(zn,{isOpen:Q,close:()=>je(!1),bookingId:(G==null?void 0:G.zoomcarConfirmationCode)||(G==null?void 0:G.zoomcarConfirmationKey)||(G==null?void 0:G.bookingId),carDetail:o==null?void 0:o.headerDetails,paymentStatus:Z}),t.jsx(Zn,{isOpen:ve,onClose:()=>Ie(!1)}),t.jsx(xn,{payableAmount:en,isDisabled:Ge,isLoading:!1,carSource:n==null?void 0:n.source,onContinue:nt})]})]})},Fa=()=>t.jsx(aa,{});export{Fa 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.