"use strict";exports.id=6102,exports.ids=[6102],exports.modules={36102:(e,t,r)=>{r.a(e,async(e,a)=>{try{r.r(t),r.d(t,{default:()=>__WEBPACK_DEFAULT_EXPORT__});var n=r(20997),s=r(16689),o=r(86819),i=r(71798),c=r(11377),_=r(45009),d=r(52324),l=r(44555),u=r(34483),m=e([d,l]);[d,l]=m.then?(await m)():m;let __WEBPACK_DEFAULT_EXPORT__=({trackingNumber:e,paymentIntentInfo:t})=>{let{t:r}=(0,c.useTranslation)(),{closeModal:a}=(0,_.SO)(),{loadRazorpayScript:m,checkScriptLoaded:y}=(0,o.Z)(),{settings:p,isLoading:E}=(0,d.r)(),{order:A,isLoading:T,refetch:f}=(0,l.Aj)({tracking_number:e}),{createOrderPayment:P}=(0,l.fY)(),{customer_name:w,customer_contact:b,customer:C,billing_address:O}=A??{},h=(0,s.useCallback)(async()=>{y()||await m();let n={key:process.env.NEXT_PUBLIC_RAZORPAY_KEY_ID,amount:t?.amount,currency:t?.currency,name:w,description:`${r("text-order")}#${e}`,image:p?.logo?.original,order_id:t?.payment_id,handler:async()=>{a(),P({tracking_number:e,payment_gateway:"razorpay"})},prefill:{...w&&{name:w},...b&&{contact:`+${b}`},...C?.email&&{email:C?.email}},notes:{address:(0,i.T)(O)},modal:{ondismiss:async()=>{a(),await f()}}},s=window.Razorpay(n);return s.open()},[T,E]);return((0,s.useEffect)(()=>{T||E||(async()=>{await h()})()},[T,E]),T||E)?n.jsx(u.ZP,{showText:!1}):null};a()}catch(e){a(e)}})},71798:(e,t,r)=>{r.d(t,{T:()=>formatAddress});function formatAddress(e){if(!e)return;let t=["street_address","state","city","zip","country"].reduce((t,r)=>({...t,[r]:e[r]}),{}),r=Object.fromEntries(Object.entries(t).filter(([e,t])=>!!t));return Object.values(r).join(", ")}},86819:(e,t,r)=>{r.d(t,{Z:()=>__WEBPACK_DEFAULT_EXPORT__});var a=r(16689);let __WEBPACK_DEFAULT_EXPORT__=()=>{let e=(0,a.useMemo)(()=>!1,[]),t=(0,a.useCallback)(()=>!!(e&&"Razorpay"in window),[]),r=(0,a.useCallback)(()=>{if(e)return new Promise((e,t)=>{let r=document.createElement("script");r.src="https://checkout.razorpay.com/v1/checkout.js",r.onload=t=>e(t),r.onerror=e=>t(e),document.body.appendChild(r)})},[]);return{checkScriptLoaded:t,loadRazorpayScript:r}}}};