@fundly.ai/payment-sdk 1.5.1-beta.4 → 1.5.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed.js +1 -1
- package/dist/{index-Dlo7TEkX.js → index-B8zykwej.js} +2 -2
- package/dist/{index-BYAh24Hs.cjs → index-ByFpMyTW.cjs} +1 -1
- package/dist/{index-D8cvCsSy.js → index-C9akEZTb.js} +2 -2
- package/dist/{index-C56L6oBw.js → index-CAnbE8Uz.js} +1 -1
- package/dist/{index-BUIXDZL2.js → index-DF39Q_Pq.js} +6 -6
- package/dist/{index-B8Duey7A.cjs → index-cETuXup5.cjs} +1 -1
- package/dist/{index-feBaWZ-T.cjs → index-fs-lVhQW.cjs} +1 -1
- package/dist/{index-CTk_fi4V.cjs → index-o0K3ginw.cjs} +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/embed.js
CHANGED
|
@@ -689,7 +689,7 @@ Fundly Team`;await sdkConfig.shareString(Q)}};return jsxRuntimeExports.jsxs(Draw
|
|
|
689
689
|
stroke-dashoffset: ${H*.8};
|
|
690
690
|
}
|
|
691
691
|
}
|
|
692
|
-
`})]})},UpiDrawer=({open:o,onClose:n,onPaymentCollected:s,onPaymentFailed:l})=>{const{paymentType:c,paymentInvoice:m,invoices:S,payableValue:H,typeOfApp:K,salesmanId:b,salesmanPhoneNumber:v,distributorIdnum:y,distributorName:D,chemistName:k,chemistId:C,leadId:I,payerMobileNumber:P,payerUuid:O,isMobileChanged:W,redirectionUrl:u1,transactionId:J,showResultOnly:G,sessionId:r1,erpId:p1}=usePaymentContext(),[o1,A1]=reactExports.useState(!1),[I1,s1]=reactExports.useState("INITIATED"),[v1,j1]=reactExports.useState(null),[k1,O1]=reactExports.useState(0),[h1,i1]=reactExports.useState(null),q=reactExports.useRef(null),$=reactExports.useRef(!1),Q=reactExports.useRef({amount:0,invoiceCount:0});reactExports.useEffect(()=>{o||(q.current&&(clearTimeout(q.current),q.current=null),$.current=!1,M1.current=!1,s1("INITIATED"),j1(null),i1(null),sessionStorage.removeItem("fundly_payment_initiated"),sessionStorage.removeItem("fundly_last_transaction_id"))},[o]);const n1=g1=>{switch(g1){case"UPI":return"UPI";case"CASH":return"Cash";case"CHEQUE":return"Cheque";default:return g1||"-"}},f1=g1=>{if(!g1)return null;const D1=g1.toLowerCase();return D1.includes("zaakpay.com")?"zaakpay":D1.includes("cashfree")?"cashfree":D1.includes("yesbank")||D1.includes("yes_bank")?"yes_bank":D1.includes("razorpay")?"razorpay":null},d1=()=>{const g1=Date.now(),D1=Math.floor(Math.random()*1e6);return`PAY-${g1}-${D1}`},R1=g1=>{if(!g1)return"gateway";const D1=g1.toLowerCase();return D1.includes("cancel")||D1.includes("abort")||D1.includes("declined by user")?"user_abort":D1.includes("bank")||D1.includes("insufficient")?"bank":"gateway"},M1=React.useRef(!1);reactExports.useEffect(()=>{if(!o||M1.current)return;const g1=new URLSearchParams(window.location.search),D1=g1.get("transactionId")||g1.get("orderId");if(G){const W1=J||D1;if(!W1){j1("Transaction ID not found. Unable to fetch payment status.");return}M1.current=!0,A1(!1),s1("PROCESSING");const le=async()=>{if(!$.current)try{const Me=await http.get(`${getCollectionBaseUrl()}/transactions/${W1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:ge,paymentAmount:xe,invoiceNumbers:oe,paymentType:Z1,paymentMode:K1,transactionDate:ye,chemistId:Ie,leadId:Le,upiTxnRefNo:Qe,link:et,errorCode:rt,errorMessage:dt,partyCode:st}=Me.data;if(Q.current.amount===0&&xe&&(Q.current={amount:Number(xe),invoiceCount:oe?.length||m?.length||S?.length||0,transactionId:W1,initiatedAt:Q.current.initiatedAt}),ge&&s1(ge),ge==="SUCCESS"||ge==="COMPLETED"){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:W1||"",status:"success",amount:Q.current.amount,paymentMode:K1||"UPI",gateway:f1(et),invoiceIds:oe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Ie||null,salesmanId:b||null,paymentType:Z1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Le||I?String(Le||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Qe||null,successAt:ye||new Date().toISOString(),partyCode:st||null}),i1(Me.data);const Lt=new URL(window.location.href);Lt.searchParams.delete("orderId"),Lt.searchParams.delete("transactionId"),window.history.replaceState({},"",Lt.toString()),s&&s(Me.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(ge)){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:W1||"",status:"failed",amount:Q.current.amount,paymentMode:K1||"UPI",gateway:f1(et),invoiceIds:oe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Ie||null,salesmanId:b||null,paymentType:Z1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Le||I?String(Le||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Qe||null,failedAt:ye||new Date().toISOString(),errorCode:rt||null,errorMessage:dt||ge,failureStage:R1(dt||ge),partyCode:st||null}),i1(Me.data);const Lt=new URL(window.location.href);Lt.searchParams.delete("orderId"),Lt.searchParams.delete("transactionId"),window.history.replaceState({},"",Lt.toString()),l&&l(Me.data);return}$.current||(q.current=setTimeout(()=>{le()},3e3))}catch{$.current||(q.current=setTimeout(()=>{le()},5e3))}};le();return}if(D1){M1.current=!0,A1(!1),s1("PROCESSING");const W1=async()=>{if(!$.current)try{const le=await http.get(`${getCollectionBaseUrl()}/transactions/${D1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:Me,paymentAmount:ge,invoiceNumbers:xe,paymentType:oe,paymentMode:Z1,transactionDate:K1,chemistId:ye,leadId:Ie,upiTxnRefNo:Le,link:Qe,errorCode:et,errorMessage:rt,partyCode:dt}=le.data;if(Q.current.amount===0&&ge&&(Q.current={amount:Number(ge),invoiceCount:xe?.length||m?.length||S?.length||0,transactionId:D1,initiatedAt:Q.current.initiatedAt}),Me&&s1(Me),Me==="SUCCESS"||Me==="COMPLETED"){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:D1||"",status:"success",amount:Q.current.amount,paymentMode:Z1||"UPI",gateway:f1(Qe),invoiceIds:xe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:ye||null,salesmanId:b||null,paymentType:oe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Ie||I?String(Ie||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Le||null,successAt:K1||new Date().toISOString(),partyCode:dt||null}),i1(le.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),s&&s(le.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(Me)){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:D1||"",status:"failed",amount:Q.current.amount,paymentMode:Z1||"UPI",gateway:f1(Qe),invoiceIds:xe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:ye||null,salesmanId:b||null,paymentType:oe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Ie||I?String(Ie||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Le||null,failedAt:K1||new Date().toISOString(),errorCode:et||null,errorMessage:rt||Me,failureStage:R1(rt||Me),partyCode:dt||null}),i1(le.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),l&&l(le.data);return}$.current||(q.current=setTimeout(()=>{W1()},3e3))}catch{$.current||(q.current=setTimeout(()=>{W1()},5e3))}};W1();return}if(sessionStorage.getItem("fundly_payment_initiated")==="true"){sessionStorage.getItem("fundly_last_transaction_id")&&(s1("PROCESSING"),A1(!1),M1.current=!0);return}(async()=>{A1(!0),$.current=!1,sessionStorage.setItem("fundly_payment_initiated","true");const W1={paymentMode:"UPI",paymentDate:new Date().toISOString(),paymentType:c,paidAmount:H,distributorCode:y,returnUrl:getPaymentWebhookUrl(),redirectUrl:u1||window.location.href.split("?")[0],salesmanId:b,salesmanPhoneNumber:v?.trim()||void 0,invoiceCount:m?.length||S?.length||0,chemistName:k||void 0,distributorName:D||void 0,mobileNumber:P||void 0,payerMobileNumber:P||void 0,newMobileNumber:W&&P||void 0};C&&C.trim()!==""?W1.chemistBusinessId=C:I&&I.trim()!==""&&(W1.leadId=I),c==="INVOICE_COLLECT"?W1.paymentInvoice=m:c==="DIRECT_COLLECT"&&(W1.invoiceIds=S);try{const le=await makePaymentWithAnalytics(W1),{link:Me,transactionId:ge}=le.data||le;if(Me&&ge){const xe=typeof H=="string"?parseFloat(H):Number(H);Q.current={amount:xe,invoiceCount:m?.length||S?.length||0,transactionId:ge,initiatedAt:new Date().toISOString()},sessionStorage.setItem("fundly_last_transaction_id",ge),window.location.replace(Me),s1("PROCESSING");const oe=async()=>{if(!$.current)try{const Z1=await http.get(`${getCollectionBaseUrl()}/transactions/${ge}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:K1,invoiceNumbers:ye,paymentType:Ie,paymentMode:Le,transactionDate:Qe,chemistId:et,leadId:rt,mobileNumber:dt,upiTxnRefNo:st,partyCode:Lt}=Z1.data;if(K1&&s1(K1),K1==="SUCCESS"||K1==="COMPLETED"){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:Q.current.transactionId||"",status:"success",amount:Q.current.amount,paymentMode:Le||"UPI",gateway:f1(Me),invoiceIds:ye||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:et||null,salesmanId:b||null,paymentType:Ie==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:rt?String(rt):void 0,mobileNumber:P||dt||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:st||null,successAt:Qe||new Date().toISOString(),partyCode:Lt||null}),i1(Z1.data);const xt=new URL(window.location.href);xt.searchParams.delete("orderId"),xt.searchParams.delete("transactionId"),window.history.replaceState({},"",xt.toString()),s&&s(Z1.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(K1)){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:Q.current.transactionId||"",status:"failed",amount:Q.current.amount,paymentMode:Le||"UPI",gateway:f1(Me),invoiceIds:ye||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:et||null,salesmanId:b||null,paymentType:Ie==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:rt?String(rt):void 0,mobileNumber:P||dt||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:st||null,failedAt:Qe||new Date().toISOString(),errorCode:null,errorMessage:K1,failureStage:R1(K1),partyCode:Lt||null}),i1(Z1.data);const xt=new URL(window.location.href);xt.searchParams.delete("orderId"),xt.searchParams.delete("transactionId"),window.history.replaceState({},"",xt.toString()),l&&l(Z1.data);return}$.current||(q.current=setTimeout(()=>{oe()},3e3))}catch{$.current||(q.current=setTimeout(()=>{oe()},5e3))}};q.current=setTimeout(()=>{oe()},2e3)}else j1("Payment initiation failed. Please try again.")}catch(le){const Me=le?.response?.data?.errorResponse?.errorMessage||le?.response?.data?.errorMessage||le?.response?.data?.errorResponse?.errorDesc||le?.response?.data?.errorDesc||"An unexpected error occurred while creating payment links.";j1(Me)}finally{}})()},[S,n,o,m,c,s,l,H,y,K,b,P,u1,G,J,k1]);const a1=(g1=>({INITIATED:2,PROCESSING:2,SUCCESS:3,COMPLETED:3,FAILED:2,CANCELLED:2,DECLINED:2})[g1]||1)(I1);return jsxRuntimeExports.jsx(Drawer,{open:o,onClose:n,children:jsxRuntimeExports.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-6 fp:py-8 fp:flex fp:flex-col fp:items-center",children:[v1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"fp:relative fp:w-16 fp:h-16 fp:flex fp:items-center fp:justify-center fp:mb-4",children:[jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-16 fp:h-16 fp:bg-red-50 fp:rounded-full"}),jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-12 fp:h-12 fp:bg-red-500 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:jsxRuntimeExports.jsx("svg",{className:"fp:w-6 fp:h-6 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),jsxRuntimeExports.jsx("h2",{className:"fp:text-[24px] fp:font-semibold fp:text-gray-900 fp:mb-2",children:"Payment Failed"}),jsxRuntimeExports.jsx("p",{className:"fp:text-[14px] fp:text-gray-600 fp:text-center fp:mb-6 fp:max-w-sm",children:v1}),jsxRuntimeExports.jsx("button",{onClick:()=>{M1.current=!1,j1(null),s1("INITIATED"),$.current=!1,sessionStorage.removeItem("fundly_payment_initiated"),sessionStorage.removeItem("fundly_last_transaction_id"),O1(g1=>g1+1)},className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:bg-[#16558B] fp:text-white fp:mb-2",children:"Retry Payment"}),jsxRuntimeExports.jsx("button",{onClick:n,className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:border fp:border-gray-300 fp:text-gray-600",children:"Close"})]}):o1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsx("p",{className:"fp:text-[18px] fp:text-[#16558B] fp:font-medium",children:"Taking you to UPI..."})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsxs("h1",{className:"fp:text-[32px] fp:font-bold fp:text-gray-800 fp:mb-1",children:["₹",formatCurrency(H)]}),jsxRuntimeExports.jsx("p",{className:"fp:text-[16px] fp:text-gray-600 fp:mb-6",children:"Payment Processing..."}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:mb-6",children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[14px] fp:font-semibold fp:text-gray-700 fp:mb-3",children:"Payment Status"}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-3",children:[jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${a1>=1?"fp:bg-green-500":"fp:bg-gray-300"}`,children:a1>=1&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${a1>=1?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment started"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${a1>=2?"fp:bg-green-500":"fp:bg-gray-300"}`,children:a1>=2&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${a1>=2?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment in progress"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${a1>=3?"fp:bg-green-500":"fp:bg-gray-300"}`,children:a1>=3&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${a1>=3?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment success"})]})]})]})]}),h1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[16px] fp:font-semibold fp:w-full fp:text-left fp:mt-2 fp:mb-2",children:"Payment Details"}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-2 fp:p-4 fp:border-2 fp:border-gray-300 fp:rounded-2xl",children:[jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Transaction ID"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:h1?.transactionId??"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Date & Time"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:h1?.transactionDate?`${formatDateLong(h1.transactionDate)}, ${formatTime(h1.transactionDate)}`:"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Payment Method"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:n1(h1?.paymentMode??"")})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Party Code"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:h1?.partyCode??"-"})]})]}),jsxRuntimeExports.jsx("button",{onClick:()=>{window.flutter_inappwebview?.callHandler("homeWebView")},className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:mt-4 fp:mb-14 fp:justify-center fp:bg-[#16558B] fp:text-white",children:"Home"})]})]})})},NetbankingDrawer=({open:o,onClose:n,onPaymentCollected:s,onPaymentFailed:l})=>{const{paymentType:c,paymentInvoice:m,invoices:S,payableValue:H,typeOfApp:K,salesmanId:b,salesmanPhoneNumber:v,distributorIdnum:y,distributorName:D,chemistName:k,chemistId:C,leadId:I,payerMobileNumber:P,payerUuid:O,isMobileChanged:W,redirectionUrl:u1,transactionId:J,showResultOnly:G,sessionId:r1,erpId:p1}=usePaymentContext(),[o1,A1]=reactExports.useState(!1),[I1,s1]=reactExports.useState("INITIATED"),[v1,j1]=reactExports.useState(null),[k1,O1]=reactExports.useState(null),h1=reactExports.useRef(null),i1=reactExports.useRef(!1),q=reactExports.useRef({amount:0,invoiceCount:0});reactExports.useEffect(()=>{o||(h1.current&&(clearTimeout(h1.current),h1.current=null),i1.current=!1,d1.current=!1,s1("INITIATED"),j1(null),O1(null),sessionStorage.removeItem("fundly_netbanking_payment_initiated"),sessionStorage.removeItem("fundly_netbanking_last_transaction_id"))},[o]);const $=_=>{switch(_){case"NETBANKING":return"Netbanking";case"CASH":return"Cash";case"CHEQUE":return"Cheque";default:return _||"-"}},Q=_=>{if(!_)return null;const a1=_.toLowerCase();return a1.includes("zaakpay.com")?"zaakpay":a1.includes("cashfree")?"cashfree":a1.includes("yesbank")||a1.includes("yes_bank")?"yes_bank":a1.includes("razorpay")?"razorpay":null},n1=()=>{const _=Date.now(),a1=Math.floor(Math.random()*1e6);return`PAY-${_}-${a1}`},f1=_=>{if(!_)return"gateway";const a1=_.toLowerCase();return a1.includes("cancel")||a1.includes("abort")||a1.includes("declined by user")?"user_abort":a1.includes("bank")||a1.includes("insufficient")?"bank":"gateway"},d1=React.useRef(!1);reactExports.useEffect(()=>{if(!o||d1.current)return;const _=new URLSearchParams(window.location.search),a1=_.get("transactionId")||_.get("orderId");if(G){const U1=J||a1;if(!U1){j1("Transaction ID not found. Unable to fetch payment status.");return}d1.current=!0,A1(!1),s1("PROCESSING");const X1=async()=>{if(!i1.current)try{const W1=await http.get(`${getCollectionBaseUrl()}/transactions/${U1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:le,paymentAmount:Me,invoiceNumbers:ge,paymentType:xe,paymentMode:oe,transactionDate:Z1,chemistId:K1,leadId:ye,upiTxnRefNo:Ie,link:Le,errorCode:Qe,errorMessage:et,partyCode:rt}=W1.data;if(q.current.amount===0&&Me&&(q.current={amount:Number(Me),invoiceCount:ge?.length||m?.length||S?.length||0,transactionId:U1,initiatedAt:q.current.initiatedAt}),le&&s1(le),le==="SUCCESS"||le==="COMPLETED"){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:U1||"",status:"success",amount:q.current.amount,paymentMode:oe||"NETBANKING",gateway:Q(Le),invoiceIds:ge||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:K1||null,salesmanId:b||null,paymentType:xe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:ye||I?String(ye||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:Ie||null,successAt:Z1||new Date().toISOString(),partyCode:rt||null}),O1(W1.data);const dt=new URL(window.location.href);dt.searchParams.delete("orderId"),dt.searchParams.delete("transactionId"),window.history.replaceState({},"",dt.toString()),s&&s(W1.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(le)){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:U1||"",status:"failed",amount:q.current.amount,paymentMode:oe||"NETBANKING",gateway:Q(Le),invoiceIds:ge||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:K1||null,salesmanId:b||null,paymentType:xe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:ye||I?String(ye||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:Ie||null,failedAt:Z1||new Date().toISOString(),errorCode:Qe||null,errorMessage:et||le,failureStage:f1(et||le),partyCode:rt||null}),O1(W1.data);const dt=new URL(window.location.href);dt.searchParams.delete("orderId"),dt.searchParams.delete("transactionId"),window.history.replaceState({},"",dt.toString()),l&&l(W1.data);return}i1.current||(h1.current=setTimeout(()=>{X1()},3e3))}catch{i1.current||(h1.current=setTimeout(()=>{X1()},5e3))}};X1();return}if(a1){d1.current=!0,A1(!1),s1("PROCESSING");const U1=async()=>{if(!i1.current)try{const X1=await http.get(`${getCollectionBaseUrl()}/transactions/${a1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:W1,paymentAmount:le,invoiceNumbers:Me,paymentType:ge,paymentMode:xe,transactionDate:oe,chemistId:Z1,leadId:K1,upiTxnRefNo:ye,link:Ie,errorCode:Le,errorMessage:Qe,partyCode:et}=X1.data;if(q.current.amount===0&&le&&(q.current={amount:Number(le),invoiceCount:Me?.length||m?.length||S?.length||0,transactionId:a1,initiatedAt:q.current.initiatedAt}),W1&&s1(W1),W1==="SUCCESS"||W1==="COMPLETED"){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:a1||"",status:"success",amount:q.current.amount,paymentMode:xe||"NETBANKING",gateway:Q(Ie),invoiceIds:Me||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Z1||null,salesmanId:b||null,paymentType:ge==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:K1||I?String(K1||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:ye||null,successAt:oe||new Date().toISOString(),partyCode:et||null}),O1(X1.data);const rt=new URL(window.location.href);rt.searchParams.delete("orderId"),rt.searchParams.delete("transactionId"),window.history.replaceState({},"",rt.toString()),s&&s(X1.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(W1)){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:a1||"",status:"failed",amount:q.current.amount,paymentMode:xe||"NETBANKING",gateway:Q(Ie),invoiceIds:Me||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Z1||null,salesmanId:b||null,paymentType:ge==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:K1||I?String(K1||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:ye||null,failedAt:oe||new Date().toISOString(),errorCode:Le||null,errorMessage:Qe||W1,failureStage:f1(Qe||W1),partyCode:et||null}),O1(X1.data);const rt=new URL(window.location.href);rt.searchParams.delete("orderId"),rt.searchParams.delete("transactionId"),window.history.replaceState({},"",rt.toString()),l&&l(X1.data);return}i1.current||(h1.current=setTimeout(()=>{U1()},3e3))}catch{i1.current||(h1.current=setTimeout(()=>{U1()},5e3))}};U1();return}if(sessionStorage.getItem("fundly_netbanking_payment_initiated")==="true"){sessionStorage.getItem("fundly_netbanking_last_transaction_id")&&(s1("PROCESSING"),A1(!1),d1.current=!0);return}(async()=>{A1(!0),i1.current=!1,sessionStorage.setItem("fundly_netbanking_payment_initiated","true");const U1={paymentMode:"NETBANKING",paymentDate:new Date().toISOString(),paymentType:c,paidAmount:H,distributorCode:y,returnUrl:getPaymentWebhookUrl(),redirectUrl:u1||window.location.href.split("?")[0],salesmanId:b,salesmanPhoneNumber:v?.trim()||void 0,invoiceCount:m?.length||S?.length||0,chemistName:k||void 0,distributorName:D||void 0,mobileNumber:P||void 0,payerMobileNumber:P||void 0,newMobileNumber:W&&P||void 0};C&&C.trim()!==""?U1.chemistBusinessId=C:I&&I.trim()!==""&&(U1.leadId=I),c==="INVOICE_COLLECT"?U1.paymentInvoice=m:c==="DIRECT_COLLECT"&&(U1.invoiceIds=S);try{const X1=await makePaymentWithAnalytics(U1),{link:W1,transactionId:le}=X1.data||X1;if(W1&&le){const Me=typeof H=="string"?parseFloat(H):Number(H);q.current={amount:Me,invoiceCount:m?.length||S?.length||0,transactionId:le,initiatedAt:new Date().toISOString()},sessionStorage.setItem("fundly_netbanking_last_transaction_id",le),window.location.replace(W1),s1("PROCESSING");const ge=async()=>{if(!i1.current)try{const xe=await http.get(`${getCollectionBaseUrl()}/transactions/${le}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:oe,invoiceNumbers:Z1,paymentType:K1,paymentMode:ye,transactionDate:Ie,chemistId:Le,leadId:Qe,mobileNumber:et,upiTxnRefNo:rt,partyCode:dt}=xe.data;if(oe&&s1(oe),oe==="SUCCESS"||oe==="COMPLETED"){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:q.current.transactionId||"",status:"success",amount:q.current.amount,paymentMode:ye||"NETBANKING",gateway:Q(W1),invoiceIds:Z1||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Le||null,salesmanId:b||null,paymentType:K1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Qe?String(Qe):void 0,mobileNumber:P||et||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:rt||null,successAt:Ie||new Date().toISOString(),partyCode:dt||null}),O1(xe.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),s&&s(xe.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(oe)){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:q.current.transactionId||"",status:"failed",amount:q.current.amount,paymentMode:ye||"NETBANKING",gateway:Q(W1),invoiceIds:Z1||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Le||null,salesmanId:b||null,paymentType:K1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Qe?String(Qe):void 0,mobileNumber:P||et||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:rt||null,failedAt:Ie||new Date().toISOString(),errorCode:null,errorMessage:oe,failureStage:f1(oe),partyCode:dt||null}),O1(xe.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),l&&l(xe.data);return}i1.current||(h1.current=setTimeout(()=>{ge()},3e3))}catch{i1.current||(h1.current=setTimeout(()=>{ge()},5e3))}};h1.current=setTimeout(()=>{ge()},2e3)}else j1("Payment initiation failed. Please try again.")}catch(X1){const W1=X1?.response?.data?.errorResponse?.errorMessage||X1?.response?.data?.errorMessage||X1?.response?.data?.errorResponse?.errorDesc||X1?.response?.data?.errorDesc||"An unexpected error occurred while creating payment links.";j1(W1)}finally{}})(),d1.current=!0},[S,n,o,m,c,s,l,H,y,K,b,P,u1,G,J]);const M1=(_=>({INITIATED:2,PROCESSING:2,SUCCESS:3,COMPLETED:3,FAILED:2,CANCELLED:2,DECLINED:2})[_]||1)(I1);return jsxRuntimeExports.jsx(Drawer,{open:o,onClose:n,children:jsxRuntimeExports.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-6 fp:py-8 fp:flex fp:flex-col fp:items-center",children:[v1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"fp:relative fp:w-16 fp:h-16 fp:flex fp:items-center fp:justify-center fp:mb-4",children:[jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-16 fp:h-16 fp:bg-red-50 fp:rounded-full"}),jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-12 fp:h-12 fp:bg-red-500 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:jsxRuntimeExports.jsx("svg",{className:"fp:w-6 fp:h-6 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),jsxRuntimeExports.jsx("h2",{className:"fp:text-[24px] fp:font-semibold fp:text-gray-900 fp:mb-2",children:"Payment Failed"}),jsxRuntimeExports.jsx("p",{className:"fp:text-[14px] fp:text-gray-600 fp:text-center fp:mb-6 fp:max-w-sm",children:v1}),jsxRuntimeExports.jsx("button",{onClick:n,className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:bg-[#16558B] fp:text-white",children:"Close"})]}):o1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsx("p",{className:"fp:text-[18px] fp:text-[#16558B] fp:font-medium",children:"Taking you to Netbanking..."})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsxs("h1",{className:"fp:text-[32px] fp:font-bold fp:text-gray-800 fp:mb-1",children:["₹",formatCurrency(H)]}),jsxRuntimeExports.jsx("p",{className:"fp:text-[16px] fp:text-gray-600 fp:mb-6",children:"Payment Processing..."}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:mb-6",children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[14px] fp:font-semibold fp:text-gray-700 fp:mb-3",children:"Payment Status"}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-3",children:[jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${M1>=1?"fp:bg-green-500":"fp:bg-gray-300"}`,children:M1>=1&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${M1>=1?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment started"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${M1>=2?"fp:bg-green-500":"fp:bg-gray-300"}`,children:M1>=2&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${M1>=2?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment in progress"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${M1>=3?"fp:bg-green-500":"fp:bg-gray-300"}`,children:M1>=3&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${M1>=3?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment success"})]})]})]})]}),k1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[16px] fp:font-semibold fp:w-full fp:text-left fp:mt-2 fp:mb-2",children:"Payment Details"}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-2 fp:p-4 fp:border-2 fp:border-gray-300 fp:rounded-2xl",children:[jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Transaction ID"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:k1?.transactionId??"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Date & Time"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:k1?.transactionDate?`${formatDateLong(k1.transactionDate)}, ${formatTime(k1.transactionDate)}`:"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Payment Method"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:$(k1?.paymentMode??"")})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Party Code"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:k1?.partyCode??"-"})]})]}),jsxRuntimeExports.jsx("button",{onClick:()=>{window.flutter_inappwebview?.callHandler("homeWebView")},className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:mt-4 fp:mb-14 fp:justify-center fp:bg-[#16558B] fp:text-white",children:"Home"})]})]})})},PAYMENT_CHANNELS=["NEFT","IMPS","RTGS"],BankTransferDrawer=({open:o,onClose:n,onPaymentCollected:s,metadata:l})=>{const{payableValue:c,salesmanPhoneNumber:m,distributorName:S,chemistName:H,payerUuid:K,payerMobileNumber:b,typeOfApp:v}=usePaymentContext(),y=v==="FUNDLY_TRADE",[D,k]=reactExports.useState(null),[C,I]=reactExports.useState(""),[P,O]=reactExports.useState(""),[W,u1]=reactExports.useState(!1),[J,G]=reactExports.useState(""),[r1,p1]=reactExports.useState(""),[o1,A1]=reactExports.useState([]),[I1,s1]=reactExports.useState(!1),[v1,j1]=reactExports.useState(!1),[k1,O1]=reactExports.useState(""),[h1,i1]=reactExports.useState(null),[q,$]=reactExports.useState(!1),[Q,n1]=reactExports.useState(!1),[f1,d1]=reactExports.useState("Submit"),[R1,M1]=reactExports.useState(!1),[_,a1]=reactExports.useState(""),g1=reactExports.useRef(null),D1=reactExports.useRef(null),U1=reactExports.useRef(null),X1=reactExports.useRef(null),W1=()=>{n(),le()},le=()=>{k(null),I(""),O(""),u1(!1),G(""),p1(""),A1([]),s1(!1),O1(""),i1(null),$(!1),n1(!1),d1("Submit"),a1(""),M1(!1)};reactExports.useEffect(()=>{o||le()},[o]);const Me=reactExports.useCallback(async K1=>{U1.current&&clearTimeout(U1.current),U1.current=setTimeout(async()=>{j1(!0);try{const ye=await fetchBankList(K1),Ie=Array.isArray(ye)?ye:ye?.data??[];A1(Ie),s1(Ie.length>0)}catch{A1([])}finally{j1(!1)}},K1.trim()?300:0)},[]);reactExports.useEffect(()=>{const K1=ye=>{g1.current&&!g1.current.contains(ye.target)&&s1(!1),D1.current&&!D1.current.contains(ye.target)&&u1(!1)};return document.addEventListener("mousedown",K1),()=>document.removeEventListener("mousedown",K1)},[]);async function ge(K1,ye){return(await http.post(getDocumentApiUrl(),{byteString:K1,fileName:ye,type:"BANK_TRANSFER"},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${getAccessToken()||""}`}})).data}const xe=K1=>new Promise((ye,Ie)=>{const Le=new FileReader;Le.onload=()=>{const Qe=Le.result,et=Qe.split(",")[1]||Qe;ye(et)},Le.onerror=Qe=>Ie(Qe),Le.readAsDataURL(K1)}),oe=async()=>{if(!navigator.onLine){n1(!0),d1("Submit Again");return}n1(!1),d1("Submit"),M1(!0);try{let K1;if(h1){const et=await xe(h1),rt=await ge(et,h1.name);K1=rt?.data?.documentId||rt?.documentId||rt?.id||void 0}const Ie={...PaymentPayloadBuilder.buildPayload(l,"BANK_TRANSFER",Number(c)||0,{bankName:J.trim()||void 0,salesmanPhoneNumber:m||void 0,chemistName:H||void 0,distributorName:S||void 0}),utr:C.trim(),paymentChannel:P,bankName:J.trim(),notes:k1.trim()||void 0,documentId:K1?Number(K1):void 0,paymentDate:D?D.toISOString():new Date().toISOString(),mobileNumber:b||void 0,uuid:K||null};PaymentPayloadBuilder.validatePayload(Ie);const Le=await makePaymentWithAnalytics(Ie),Qe=Le.data||Le;s&&s(Qe)}catch(K1){const ye=K1?.response?.data?.errorMessage||K1?.response?.data?.errorDesc||K1?.response?.data?.message||K1?.message||"Bank transfer payment failed. Please try again.";a1(ye)}finally{M1(!1)}},Z1=D!==null&&C.trim().length>0&&P.length>0&&(y||J.trim().length>0);return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs(Drawer,{open:o,onClose:W1,children:[jsxRuntimeExports.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-4 fp:pt-6 fp:mb-12",children:[jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between",children:[jsxRuntimeExports.jsxs("h1",{className:"fp:font-normal fp:items-center fp:text-[#222222]",children:["Payable Amount :"," ",jsxRuntimeExports.jsxs("label",{className:"fp:font-semibold",children:["₹",c]})]}),jsxRuntimeExports.jsx("img",{src:assets.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>$(!0)})]}),_&&jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:bg-red-50 fp:border fp:border-red-200 fp:rounded-xl fp:p-3 fp:flex fp:items-start fp:space-x-2 fp:mt-4",children:[jsxRuntimeExports.jsx("svg",{className:"fp:w-5 fp:h-5 fp:text-red-500 fp:flex-shrink-0 fp:mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),jsxRuntimeExports.jsxs("div",{className:"fp:flex-1",children:[jsxRuntimeExports.jsx("p",{className:"fp:text-[14px] fp:text-red-700 fp:font-medium",children:"Payment Failed"}),jsxRuntimeExports.jsx("p",{className:"fp:text-[12px] fp:text-red-600 fp:mt-1",children:_})]}),jsxRuntimeExports.jsx("button",{onClick:()=>a1(""),className:"fp:text-red-400 fp:hover:text-red-600",children:jsxRuntimeExports.jsx("svg",{className:"fp:w-4 fp:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),jsxRuntimeExports.jsx("input",{ref:X1,type:"file",accept:"image/*,application/pdf",hidden:!0,onChange:K1=>{const ye=K1.target.files?.[0];if(ye){if(ye.size>10485760){a1(`File size exceeds 10MB limit. Please select a smaller file. (Current: ${(ye.size/1024/1024).toFixed(2)}MB)`);return}i1(ye),a1("")}K1.target.value=""}}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-8 fp:space-y-4",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(DatePicker,{value:D,onChange:K1=>k(K1),label:"Payment Date",fullWidth:!0})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{htmlFor:"utr-number",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"UTR"}),jsxRuntimeExports.jsx("input",{id:"utr-number",type:"text",value:C,onChange:K1=>I(K1.target.value.slice(0,50)),placeholder:"Enter UTR number",style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocus:K1=>K1.currentTarget.style.borderColor="#16558B",onBlur:K1=>K1.currentTarget.style.borderColor="#ccc"})]}),jsxRuntimeExports.jsxs("div",{ref:D1,style:{position:"relative"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Payment Channel"}),jsxRuntimeExports.jsxs("div",{onClick:()=>u1(!W),style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:`1px solid ${W?"#16558B":"#ccc"}`,borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff"},children:[jsxRuntimeExports.jsx("span",{style:{color:P?"#222":"#999"},children:P||"Select payment channel"}),jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntimeExports.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),W&&jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:"#fff",border:"1px solid #E0E0E0",borderRadius:"8px",maxHeight:"200px",overflowY:"auto",zIndex:100,boxShadow:"0 4px 12px rgba(0,0,0,0.1)",marginTop:"4px"},children:PAYMENT_CHANNELS.map(K1=>jsxRuntimeExports.jsx("div",{onClick:()=>{O(K1),u1(!1)},style:{padding:"10px 16px",fontSize:"14px",fontFamily:"Poppins",cursor:"pointer",backgroundColor:P===K1?"#F5F9FD":"#fff"},onMouseEnter:ye=>ye.currentTarget.style.backgroundColor="#F5F9FD",onMouseLeave:ye=>ye.currentTarget.style.backgroundColor=P===K1?"#F5F9FD":"#fff",children:K1},K1))})]}),jsxRuntimeExports.jsxs("div",{ref:g1,style:{position:"relative"},children:[jsxRuntimeExports.jsxs("label",{htmlFor:"bank-name-transfer",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:["Bank Name",y&&" (Optional)"]}),jsxRuntimeExports.jsxs("div",{style:{position:"relative"},children:[jsxRuntimeExports.jsx("input",{id:"bank-name-transfer",type:"text",value:J||r1,onChange:K1=>{const ye=K1.target.value;G(""),p1(ye),Me(ye)},onFocus:()=>{J?(p1(J),G(""),Me(J)):o1.length>0?s1(!0):Me("")},placeholder:"Search bank name...",style:{width:"100%",height:"48px",padding:"12px 36px 12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocusCapture:K1=>K1.currentTarget.style.borderColor="#16558B",onBlurCapture:K1=>K1.currentTarget.style.borderColor="#ccc",autoComplete:"off"}),jsxRuntimeExports.jsx("div",{style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"},children:v1?jsxRuntimeExports.jsxs("svg",{className:"fp:animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntimeExports.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#ccc",strokeWidth:"3"}),jsxRuntimeExports.jsx("path",{d:"M12 2a10 10 0 019.8 8",stroke:"#16558B",strokeWidth:"3",strokeLinecap:"round"})]}):J?jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{cursor:"pointer"},onClick:K1=>{K1.stopPropagation(),G(""),p1(""),A1([]),s1(!1)},children:[jsxRuntimeExports.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntimeExports.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntimeExports.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),I1&&o1.length>0&&jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:"#fff",border:"1px solid #E0E0E0",borderRadius:"8px",maxHeight:"200px",overflowY:"auto",zIndex:100,boxShadow:"0 4px 12px rgba(0,0,0,0.1)",marginTop:"4px"},children:o1.map((K1,ye)=>{const Ie=typeof K1=="string"?K1:K1?.bankName||K1?.name||String(K1);return jsxRuntimeExports.jsx("div",{onClick:()=>{G(Ie),p1(""),s1(!1)},style:{padding:"10px 16px",fontSize:"14px",fontFamily:"Poppins",cursor:"pointer",borderBottom:ye<o1.length-1?"1px solid #F0F0F0":"none"},onMouseEnter:Le=>Le.currentTarget.style.backgroundColor="#F5F9FD",onMouseLeave:Le=>Le.currentTarget.style.backgroundColor="#fff",children:Ie},ye)})})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{htmlFor:"notes",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Additional Notes"}),jsxRuntimeExports.jsx("textarea",{id:"notes",value:k1,onChange:K1=>O1(K1.target.value),placeholder:"Additional Notes...",rows:3,style:{width:"100%",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none",resize:"vertical"},onFocus:K1=>K1.currentTarget.style.borderColor="#16558B",onBlur:K1=>K1.currentTarget.style.borderColor="#ccc"})]}),!h1&&jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between fp:border-1 fp:border-dashed fp:border-[#cccccc] fp:rounded-lg fp:py-3 fp:px-8 fp:cursor-pointer fp:mt-2",onClick:()=>X1.current?.click(),children:[jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:flex-col fp:items-center",children:[jsxRuntimeExports.jsx("span",{className:"fp:text-[#aaa]",children:"Upload Proof (Optional)"}),jsxRuntimeExports.jsx("span",{className:"fp:text-[12px] fp:text-[#aaa]",children:"(JPG, JPEG, PNG, PDF - Max 10MB)"})]}),jsxRuntimeExports.jsx("img",{src:assets.uploadIcon,className:"fp:w-5 fp:h-5",alt:"Upload"})]}),h1&&jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:p-3 fp:space-y-1 fp:border-2 fp:border-gray-200 fp:rounded-lg",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:text-[#16558B]",children:"Payment Proof"}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between fp:gap-2",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:truncate fp:flex-1 fp:min-w-0",children:h1.name}),jsxRuntimeExports.jsx("img",{src:assets.trash,className:"fp:w-4 fp:h-4 fp:cursor-pointer fp:flex-shrink-0",onClick:()=>i1(null)})]})]}),Q&&jsxRuntimeExports.jsx("span",{className:"fp:text-red-500 fp:text-[12px] fp:mt-1",children:"We couldn't process your payment due to a network error. Please retry."}),jsxRuntimeExports.jsx("button",{className:`fp:w-full fp:h-12 fp:mt-4 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:bg-[#16558B] fp:text-white ${!Z1||R1?"fp:opacity-50 fp:cursor-not-allowed":"fp:cursor-pointer"}`,onClick:oe,disabled:!Z1||R1,children:R1?jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[jsxRuntimeExports.jsxs("svg",{className:"fp:animate-spin fp:h-5 fp:w-5 fp:text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntimeExports.jsx("circle",{className:"fp:opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntimeExports.jsx("path",{className:"fp:opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),jsxRuntimeExports.jsx("span",{children:"Processing..."})]}):f1})]})]}),jsxRuntimeExports.jsxs(Dialog,{open:q,onClose:()=>$(!1),children:[jsxRuntimeExports.jsx(DialogContent,{children:jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center",children:[jsxRuntimeExports.jsx("img",{src:assets.Gateway,className:"fp:w-15 fp:h-15"}),jsxRuntimeExports.jsx("span",{style:{fontFamily:"Poppins"},className:"fp:text-[16px] fp:mt-3 fp:text-wrap fp:font-semibold fp:text-center fp:text-[#222222]",children:"Payment has not been completed. Do you still want to close?"})]})}),jsxRuntimeExports.jsx(DialogActions,{children:jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[jsxRuntimeExports.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[48px] fp:text-[18px] fp:border-2 fp:border-gray-300 fp:text-gray-400 fp:rounded-xl",onClick:()=>{$(!1),n()},children:"Exit"}),jsxRuntimeExports.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[48px] fp:text-[18px] fp:bg-[#16558B] fp:text-white fp:rounded-xl",onClick:()=>$(!1),children:"Continue"})]})})]})]})})},LoadingSpinner=({message:o})=>jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:h-screen fp:flex fp:flex-col fp:items-center fp:justify-center fp:bg-[#F8FCFF] fp:relative",children:[jsxRuntimeExports.jsxs("div",{className:"fp:relative fp:w-32 fp:h-32 fp:flex fp:items-center fp:justify-center",children:[jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:inset-0 fp:rounded-full fp:border-4 fp:border-t-[#16558B] fp:border-[#E5E9F2] animate-spin-slow"}),jsxRuntimeExports.jsx("img",{src:assets.logo,className:"fp:w-20 fp:h-20",alt:"Fundly Logo"})]}),o&&jsxRuntimeExports.jsxs("p",{className:"fp:mt-6 fp:text-sm fp:font-bold fp:text-[16px]",style:{color:"#16558B",letterSpacing:"0.5px"},children:[o,jsxRuntimeExports.jsxs("span",{className:"fp:inline-block loading-dots fp:pl-1",style:{minWidth:24},children:[jsxRuntimeExports.jsx("span",{children:"."}),jsxRuntimeExports.jsx("span",{children:"."}),jsxRuntimeExports.jsx("span",{children:"."})]})]}),jsxRuntimeExports.jsx("style",{children:`
|
|
692
|
+
`})]})},UpiDrawer=({open:o,onClose:n,onPaymentCollected:s,onPaymentFailed:l})=>{const{paymentType:c,paymentInvoice:m,invoices:S,payableValue:H,typeOfApp:K,salesmanId:b,salesmanPhoneNumber:v,distributorIdnum:y,distributorName:D,chemistName:k,chemistId:C,leadId:I,payerMobileNumber:P,payerUuid:O,isMobileChanged:W,redirectionUrl:u1,transactionId:J,showResultOnly:G,sessionId:r1,erpId:p1}=usePaymentContext(),[o1,A1]=reactExports.useState(!1),[I1,s1]=reactExports.useState("INITIATED"),[v1,j1]=reactExports.useState(null),[k1,O1]=reactExports.useState(0),[h1,i1]=reactExports.useState(null),q=reactExports.useRef(null),$=reactExports.useRef(!1),Q=reactExports.useRef({amount:0,invoiceCount:0});reactExports.useEffect(()=>{o||(q.current&&(clearTimeout(q.current),q.current=null),$.current=!1,M1.current=!1,s1("INITIATED"),j1(null),i1(null),sessionStorage.removeItem("fundly_payment_initiated"),sessionStorage.removeItem("fundly_last_transaction_id"))},[o]);const n1=g1=>{switch(g1){case"UPI":return"UPI";case"CASH":return"Cash";case"CHEQUE":return"Cheque";default:return g1||"-"}},f1=g1=>{if(!g1)return null;const D1=g1.toLowerCase();return D1.includes("zaakpay.com")?"zaakpay":D1.includes("cashfree")?"cashfree":D1.includes("yesbank")||D1.includes("yes_bank")?"yes_bank":D1.includes("razorpay")?"razorpay":null},d1=()=>{const g1=Date.now(),D1=Math.floor(Math.random()*1e6);return`PAY-${g1}-${D1}`},R1=g1=>{if(!g1)return"gateway";const D1=g1.toLowerCase();return D1.includes("cancel")||D1.includes("abort")||D1.includes("declined by user")?"user_abort":D1.includes("bank")||D1.includes("insufficient")?"bank":"gateway"},M1=React.useRef(!1);reactExports.useEffect(()=>{if(!o||M1.current)return;const g1=new URLSearchParams(window.location.search),D1=g1.get("transactionId")||g1.get("orderId");if(G){const W1=J||D1;if(!W1){j1("Transaction ID not found. Unable to fetch payment status.");return}M1.current=!0,A1(!1),s1("PROCESSING");const le=async()=>{if(!$.current)try{const Me=await http.get(`${getCollectionBaseUrl()}/transactions/${W1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:ge,paymentAmount:xe,invoiceNumbers:oe,paymentType:Z1,paymentMode:K1,transactionDate:ye,chemistId:Ie,leadId:Le,upiTxnRefNo:Qe,link:et,errorCode:rt,errorMessage:dt,partyCode:st}=Me.data;if(Q.current.amount===0&&xe&&(Q.current={amount:Number(xe),invoiceCount:oe?.length||m?.length||S?.length||0,transactionId:W1,initiatedAt:Q.current.initiatedAt}),ge&&s1(ge),ge==="SUCCESS"||ge==="COMPLETED"){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:W1||"",status:"success",amount:Q.current.amount,paymentMode:K1||"UPI",gateway:f1(et),invoiceIds:oe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Ie||null,salesmanId:b||null,paymentType:Z1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Le||I?String(Le||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Qe||null,successAt:ye||new Date().toISOString(),partyCode:st||null}),i1(Me.data);const Lt=new URL(window.location.href);Lt.searchParams.delete("orderId"),Lt.searchParams.delete("transactionId"),window.history.replaceState({},"",Lt.toString()),s&&s(Me.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(ge)){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:W1||"",status:"failed",amount:Q.current.amount,paymentMode:K1||"UPI",gateway:f1(et),invoiceIds:oe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Ie||null,salesmanId:b||null,paymentType:Z1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Le||I?String(Le||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Qe||null,failedAt:ye||new Date().toISOString(),errorCode:rt||null,errorMessage:dt||ge,failureStage:R1(dt||ge),partyCode:st||null}),i1(Me.data);const Lt=new URL(window.location.href);Lt.searchParams.delete("orderId"),Lt.searchParams.delete("transactionId"),window.history.replaceState({},"",Lt.toString()),l&&l(Me.data);return}$.current||(q.current=setTimeout(()=>{le()},3e3))}catch{$.current||(q.current=setTimeout(()=>{le()},5e3))}};le();return}if(D1){M1.current=!0,A1(!1),s1("PROCESSING");const W1=async()=>{if(!$.current)try{const le=await http.get(`${getCollectionBaseUrl()}/transactions/${D1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:Me,paymentAmount:ge,invoiceNumbers:xe,paymentType:oe,paymentMode:Z1,transactionDate:K1,chemistId:ye,leadId:Ie,upiTxnRefNo:Le,link:Qe,errorCode:et,errorMessage:rt,partyCode:dt}=le.data;if(Q.current.amount===0&&ge&&(Q.current={amount:Number(ge),invoiceCount:xe?.length||m?.length||S?.length||0,transactionId:D1,initiatedAt:Q.current.initiatedAt}),Me&&s1(Me),Me==="SUCCESS"||Me==="COMPLETED"){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:D1||"",status:"success",amount:Q.current.amount,paymentMode:Z1||"UPI",gateway:f1(Qe),invoiceIds:xe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:ye||null,salesmanId:b||null,paymentType:oe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Ie||I?String(Ie||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Le||null,successAt:K1||new Date().toISOString(),partyCode:dt||null}),i1(le.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),s&&s(le.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(Me)){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:D1||"",status:"failed",amount:Q.current.amount,paymentMode:Z1||"UPI",gateway:f1(Qe),invoiceIds:xe||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:ye||null,salesmanId:b||null,paymentType:oe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Ie||I?String(Ie||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:Le||null,failedAt:K1||new Date().toISOString(),errorCode:et||null,errorMessage:rt||Me,failureStage:R1(rt||Me),partyCode:dt||null}),i1(le.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),l&&l(le.data);return}$.current||(q.current=setTimeout(()=>{W1()},3e3))}catch{$.current||(q.current=setTimeout(()=>{W1()},5e3))}};W1();return}if(sessionStorage.getItem("fundly_payment_initiated")==="true"){sessionStorage.getItem("fundly_last_transaction_id")&&(s1("PROCESSING"),A1(!1),M1.current=!0);return}(async()=>{A1(!0),$.current=!1,sessionStorage.setItem("fundly_payment_initiated","true");const W1={paymentMode:"UPI",paymentDate:new Date().toISOString(),paymentType:c,paidAmount:H,distributorCode:y,returnUrl:getPaymentWebhookUrl(),redirectUrl:u1||window.location.href.split("?")[0],salesmanId:b,salesmanPhoneNumber:v?.trim()||void 0,invoiceCount:m?.length||S?.length||0,chemistName:k||void 0,distributorName:D||void 0,mobileNumber:P||void 0,payerMobileNumber:P||void 0,isMobileChanged:W||!1};C&&C.trim()!==""?W1.chemistBusinessId=C:I&&I.trim()!==""&&(W1.leadId=I),c==="INVOICE_COLLECT"?W1.paymentInvoice=m:c==="DIRECT_COLLECT"&&(W1.invoiceIds=S);try{const le=await makePaymentWithAnalytics(W1),{link:Me,transactionId:ge}=le.data||le;if(Me&&ge){const xe=typeof H=="string"?parseFloat(H):Number(H);Q.current={amount:xe,invoiceCount:m?.length||S?.length||0,transactionId:ge,initiatedAt:new Date().toISOString()},sessionStorage.setItem("fundly_last_transaction_id",ge),window.location.replace(Me),s1("PROCESSING");const oe=async()=>{if(!$.current)try{const Z1=await http.get(`${getCollectionBaseUrl()}/transactions/${ge}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:K1,invoiceNumbers:ye,paymentType:Ie,paymentMode:Le,transactionDate:Qe,chemistId:et,leadId:rt,mobileNumber:dt,upiTxnRefNo:st,partyCode:Lt}=Z1.data;if(K1&&s1(K1),K1==="SUCCESS"||K1==="COMPLETED"){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:Q.current.transactionId||"",status:"success",amount:Q.current.amount,paymentMode:Le||"UPI",gateway:f1(Me),invoiceIds:ye||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:et||null,salesmanId:b||null,paymentType:Ie==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:rt?String(rt):void 0,mobileNumber:P||dt||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:st||null,successAt:Qe||new Date().toISOString(),partyCode:Lt||null}),i1(Z1.data);const xt=new URL(window.location.href);xt.searchParams.delete("orderId"),xt.searchParams.delete("transactionId"),window.history.replaceState({},"",xt.toString()),s&&s(Z1.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(K1)){$.current=!0,q.current&&(clearTimeout(q.current),q.current=null),trackPaymentTransaction({orderId:d1(),transactionId:Q.current.transactionId||"",status:"failed",amount:Q.current.amount,paymentMode:Le||"UPI",gateway:f1(Me),invoiceIds:ye||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:et||null,salesmanId:b||null,paymentType:Ie==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:rt?String(rt):void 0,mobileNumber:P||dt||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:Q.current.initiatedAt||null,bankReferenceId:st||null,failedAt:Qe||new Date().toISOString(),errorCode:null,errorMessage:K1,failureStage:R1(K1),partyCode:Lt||null}),i1(Z1.data);const xt=new URL(window.location.href);xt.searchParams.delete("orderId"),xt.searchParams.delete("transactionId"),window.history.replaceState({},"",xt.toString()),l&&l(Z1.data);return}$.current||(q.current=setTimeout(()=>{oe()},3e3))}catch{$.current||(q.current=setTimeout(()=>{oe()},5e3))}};q.current=setTimeout(()=>{oe()},2e3)}else j1("Payment initiation failed. Please try again.")}catch(le){const Me=le?.response?.data?.errorResponse?.errorMessage||le?.response?.data?.errorMessage||le?.response?.data?.errorResponse?.errorDesc||le?.response?.data?.errorDesc||"An unexpected error occurred while creating payment links.";j1(Me)}finally{}})()},[S,n,o,m,c,s,l,H,y,K,b,P,u1,G,J,k1]);const a1=(g1=>({INITIATED:2,PROCESSING:2,SUCCESS:3,COMPLETED:3,FAILED:2,CANCELLED:2,DECLINED:2})[g1]||1)(I1);return jsxRuntimeExports.jsx(Drawer,{open:o,onClose:n,children:jsxRuntimeExports.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-6 fp:py-8 fp:flex fp:flex-col fp:items-center",children:[v1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"fp:relative fp:w-16 fp:h-16 fp:flex fp:items-center fp:justify-center fp:mb-4",children:[jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-16 fp:h-16 fp:bg-red-50 fp:rounded-full"}),jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-12 fp:h-12 fp:bg-red-500 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:jsxRuntimeExports.jsx("svg",{className:"fp:w-6 fp:h-6 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),jsxRuntimeExports.jsx("h2",{className:"fp:text-[24px] fp:font-semibold fp:text-gray-900 fp:mb-2",children:"Payment Failed"}),jsxRuntimeExports.jsx("p",{className:"fp:text-[14px] fp:text-gray-600 fp:text-center fp:mb-6 fp:max-w-sm",children:v1}),jsxRuntimeExports.jsx("button",{onClick:()=>{M1.current=!1,j1(null),s1("INITIATED"),$.current=!1,sessionStorage.removeItem("fundly_payment_initiated"),sessionStorage.removeItem("fundly_last_transaction_id"),O1(g1=>g1+1)},className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:bg-[#16558B] fp:text-white fp:mb-2",children:"Retry Payment"}),jsxRuntimeExports.jsx("button",{onClick:n,className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:border fp:border-gray-300 fp:text-gray-600",children:"Close"})]}):o1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsx("p",{className:"fp:text-[18px] fp:text-[#16558B] fp:font-medium",children:"Taking you to UPI..."})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsxs("h1",{className:"fp:text-[32px] fp:font-bold fp:text-gray-800 fp:mb-1",children:["₹",formatCurrency(H)]}),jsxRuntimeExports.jsx("p",{className:"fp:text-[16px] fp:text-gray-600 fp:mb-6",children:"Payment Processing..."}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:mb-6",children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[14px] fp:font-semibold fp:text-gray-700 fp:mb-3",children:"Payment Status"}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-3",children:[jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${a1>=1?"fp:bg-green-500":"fp:bg-gray-300"}`,children:a1>=1&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${a1>=1?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment started"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${a1>=2?"fp:bg-green-500":"fp:bg-gray-300"}`,children:a1>=2&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${a1>=2?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment in progress"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${a1>=3?"fp:bg-green-500":"fp:bg-gray-300"}`,children:a1>=3&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${a1>=3?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment success"})]})]})]})]}),h1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[16px] fp:font-semibold fp:w-full fp:text-left fp:mt-2 fp:mb-2",children:"Payment Details"}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-2 fp:p-4 fp:border-2 fp:border-gray-300 fp:rounded-2xl",children:[jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Transaction ID"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:h1?.transactionId??"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Date & Time"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:h1?.transactionDate?`${formatDateLong(h1.transactionDate)}, ${formatTime(h1.transactionDate)}`:"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Payment Method"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:n1(h1?.paymentMode??"")})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Party Code"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:h1?.partyCode??"-"})]})]}),jsxRuntimeExports.jsx("button",{onClick:()=>{window.flutter_inappwebview?.callHandler("homeWebView")},className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:mt-4 fp:mb-14 fp:justify-center fp:bg-[#16558B] fp:text-white",children:"Home"})]})]})})},NetbankingDrawer=({open:o,onClose:n,onPaymentCollected:s,onPaymentFailed:l})=>{const{paymentType:c,paymentInvoice:m,invoices:S,payableValue:H,typeOfApp:K,salesmanId:b,salesmanPhoneNumber:v,distributorIdnum:y,distributorName:D,chemistName:k,chemistId:C,leadId:I,payerMobileNumber:P,payerUuid:O,isMobileChanged:W,redirectionUrl:u1,transactionId:J,showResultOnly:G,sessionId:r1,erpId:p1}=usePaymentContext(),[o1,A1]=reactExports.useState(!1),[I1,s1]=reactExports.useState("INITIATED"),[v1,j1]=reactExports.useState(null),[k1,O1]=reactExports.useState(null),h1=reactExports.useRef(null),i1=reactExports.useRef(!1),q=reactExports.useRef({amount:0,invoiceCount:0});reactExports.useEffect(()=>{o||(h1.current&&(clearTimeout(h1.current),h1.current=null),i1.current=!1,d1.current=!1,s1("INITIATED"),j1(null),O1(null),sessionStorage.removeItem("fundly_netbanking_payment_initiated"),sessionStorage.removeItem("fundly_netbanking_last_transaction_id"))},[o]);const $=_=>{switch(_){case"NETBANKING":return"Netbanking";case"CASH":return"Cash";case"CHEQUE":return"Cheque";default:return _||"-"}},Q=_=>{if(!_)return null;const a1=_.toLowerCase();return a1.includes("zaakpay.com")?"zaakpay":a1.includes("cashfree")?"cashfree":a1.includes("yesbank")||a1.includes("yes_bank")?"yes_bank":a1.includes("razorpay")?"razorpay":null},n1=()=>{const _=Date.now(),a1=Math.floor(Math.random()*1e6);return`PAY-${_}-${a1}`},f1=_=>{if(!_)return"gateway";const a1=_.toLowerCase();return a1.includes("cancel")||a1.includes("abort")||a1.includes("declined by user")?"user_abort":a1.includes("bank")||a1.includes("insufficient")?"bank":"gateway"},d1=React.useRef(!1);reactExports.useEffect(()=>{if(!o||d1.current)return;const _=new URLSearchParams(window.location.search),a1=_.get("transactionId")||_.get("orderId");if(G){const U1=J||a1;if(!U1){j1("Transaction ID not found. Unable to fetch payment status.");return}d1.current=!0,A1(!1),s1("PROCESSING");const X1=async()=>{if(!i1.current)try{const W1=await http.get(`${getCollectionBaseUrl()}/transactions/${U1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:le,paymentAmount:Me,invoiceNumbers:ge,paymentType:xe,paymentMode:oe,transactionDate:Z1,chemistId:K1,leadId:ye,upiTxnRefNo:Ie,link:Le,errorCode:Qe,errorMessage:et,partyCode:rt}=W1.data;if(q.current.amount===0&&Me&&(q.current={amount:Number(Me),invoiceCount:ge?.length||m?.length||S?.length||0,transactionId:U1,initiatedAt:q.current.initiatedAt}),le&&s1(le),le==="SUCCESS"||le==="COMPLETED"){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:U1||"",status:"success",amount:q.current.amount,paymentMode:oe||"NETBANKING",gateway:Q(Le),invoiceIds:ge||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:K1||null,salesmanId:b||null,paymentType:xe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:ye||I?String(ye||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:Ie||null,successAt:Z1||new Date().toISOString(),partyCode:rt||null}),O1(W1.data);const dt=new URL(window.location.href);dt.searchParams.delete("orderId"),dt.searchParams.delete("transactionId"),window.history.replaceState({},"",dt.toString()),s&&s(W1.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(le)){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:U1||"",status:"failed",amount:q.current.amount,paymentMode:oe||"NETBANKING",gateway:Q(Le),invoiceIds:ge||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:K1||null,salesmanId:b||null,paymentType:xe==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:ye||I?String(ye||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:Ie||null,failedAt:Z1||new Date().toISOString(),errorCode:Qe||null,errorMessage:et||le,failureStage:f1(et||le),partyCode:rt||null}),O1(W1.data);const dt=new URL(window.location.href);dt.searchParams.delete("orderId"),dt.searchParams.delete("transactionId"),window.history.replaceState({},"",dt.toString()),l&&l(W1.data);return}i1.current||(h1.current=setTimeout(()=>{X1()},3e3))}catch{i1.current||(h1.current=setTimeout(()=>{X1()},5e3))}};X1();return}if(a1){d1.current=!0,A1(!1),s1("PROCESSING");const U1=async()=>{if(!i1.current)try{const X1=await http.get(`${getCollectionBaseUrl()}/transactions/${a1}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:W1,paymentAmount:le,invoiceNumbers:Me,paymentType:ge,paymentMode:xe,transactionDate:oe,chemistId:Z1,leadId:K1,upiTxnRefNo:ye,link:Ie,errorCode:Le,errorMessage:Qe,partyCode:et}=X1.data;if(q.current.amount===0&&le&&(q.current={amount:Number(le),invoiceCount:Me?.length||m?.length||S?.length||0,transactionId:a1,initiatedAt:q.current.initiatedAt}),W1&&s1(W1),W1==="SUCCESS"||W1==="COMPLETED"){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:a1||"",status:"success",amount:q.current.amount,paymentMode:xe||"NETBANKING",gateway:Q(Ie),invoiceIds:Me||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Z1||null,salesmanId:b||null,paymentType:ge==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:K1||I?String(K1||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:ye||null,successAt:oe||new Date().toISOString(),partyCode:et||null}),O1(X1.data);const rt=new URL(window.location.href);rt.searchParams.delete("orderId"),rt.searchParams.delete("transactionId"),window.history.replaceState({},"",rt.toString()),s&&s(X1.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(W1)){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:a1||"",status:"failed",amount:q.current.amount,paymentMode:xe||"NETBANKING",gateway:Q(Ie),invoiceIds:Me||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Z1||null,salesmanId:b||null,paymentType:ge==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:K1||I?String(K1||I):void 0,mobileNumber:P||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:ye||null,failedAt:oe||new Date().toISOString(),errorCode:Le||null,errorMessage:Qe||W1,failureStage:f1(Qe||W1),partyCode:et||null}),O1(X1.data);const rt=new URL(window.location.href);rt.searchParams.delete("orderId"),rt.searchParams.delete("transactionId"),window.history.replaceState({},"",rt.toString()),l&&l(X1.data);return}i1.current||(h1.current=setTimeout(()=>{U1()},3e3))}catch{i1.current||(h1.current=setTimeout(()=>{U1()},5e3))}};U1();return}if(sessionStorage.getItem("fundly_netbanking_payment_initiated")==="true"){sessionStorage.getItem("fundly_netbanking_last_transaction_id")&&(s1("PROCESSING"),A1(!1),d1.current=!0);return}(async()=>{A1(!0),i1.current=!1,sessionStorage.setItem("fundly_netbanking_payment_initiated","true");const U1={paymentMode:"NETBANKING",paymentDate:new Date().toISOString(),paymentType:c,paidAmount:H,distributorCode:y,returnUrl:getPaymentWebhookUrl(),redirectUrl:u1||window.location.href.split("?")[0],salesmanId:b,salesmanPhoneNumber:v?.trim()||void 0,invoiceCount:m?.length||S?.length||0,chemistName:k||void 0,distributorName:D||void 0,mobileNumber:P||void 0,payerMobileNumber:P||void 0,isMobileChanged:W||!1};C&&C.trim()!==""?U1.chemistBusinessId=C:I&&I.trim()!==""&&(U1.leadId=I),c==="INVOICE_COLLECT"?U1.paymentInvoice=m:c==="DIRECT_COLLECT"&&(U1.invoiceIds=S);try{const X1=await makePaymentWithAnalytics(U1),{link:W1,transactionId:le}=X1.data||X1;if(W1&&le){const Me=typeof H=="string"?parseFloat(H):Number(H);q.current={amount:Me,invoiceCount:m?.length||S?.length||0,transactionId:le,initiatedAt:new Date().toISOString()},sessionStorage.setItem("fundly_netbanking_last_transaction_id",le),window.location.replace(W1),s1("PROCESSING");const ge=async()=>{if(!i1.current)try{const xe=await http.get(`${getCollectionBaseUrl()}/transactions/${le}`,{headers:{Authorization:getAccessToken()?`Bearer ${getAccessToken()}`:void 0,"Content-Type":"application/json"}}),{paymentStatus:oe,invoiceNumbers:Z1,paymentType:K1,paymentMode:ye,transactionDate:Ie,chemistId:Le,leadId:Qe,mobileNumber:et,upiTxnRefNo:rt,partyCode:dt}=xe.data;if(oe&&s1(oe),oe==="SUCCESS"||oe==="COMPLETED"){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:q.current.transactionId||"",status:"success",amount:q.current.amount,paymentMode:ye||"NETBANKING",gateway:Q(W1),invoiceIds:Z1||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Le||null,salesmanId:b||null,paymentType:K1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Qe?String(Qe):void 0,mobileNumber:P||et||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:rt||null,successAt:Ie||new Date().toISOString(),partyCode:dt||null}),O1(xe.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),s&&s(xe.data);return}if(["FAILED","CANCELLED","DECLINED"].includes(oe)){i1.current=!0,h1.current&&(clearTimeout(h1.current),h1.current=null),trackPaymentTransaction({orderId:n1(),transactionId:q.current.transactionId||"",status:"failed",amount:q.current.amount,paymentMode:ye||"NETBANKING",gateway:Q(W1),invoiceIds:Z1||null,distributorId:y?.toString()||"",erpId:p1||null,chemistId:Le||null,salesmanId:b||null,paymentType:K1==="INVOICE_COLLECT"?"INVOICE_COLLECT":"DIRECT_COLLECT",typeOfApp:K||void 0,sessionId:r1||void 0,leadId:Qe?String(Qe):void 0,mobileNumber:P||et||null,uuid:O||null,isMobileChanged:W||!1,newMobileNumber:W&&P||null,initiatedAt:q.current.initiatedAt||null,bankReferenceId:rt||null,failedAt:Ie||new Date().toISOString(),errorCode:null,errorMessage:oe,failureStage:f1(oe),partyCode:dt||null}),O1(xe.data);const st=new URL(window.location.href);st.searchParams.delete("orderId"),st.searchParams.delete("transactionId"),window.history.replaceState({},"",st.toString()),l&&l(xe.data);return}i1.current||(h1.current=setTimeout(()=>{ge()},3e3))}catch{i1.current||(h1.current=setTimeout(()=>{ge()},5e3))}};h1.current=setTimeout(()=>{ge()},2e3)}else j1("Payment initiation failed. Please try again.")}catch(X1){const W1=X1?.response?.data?.errorResponse?.errorMessage||X1?.response?.data?.errorMessage||X1?.response?.data?.errorResponse?.errorDesc||X1?.response?.data?.errorDesc||"An unexpected error occurred while creating payment links.";j1(W1)}finally{}})(),d1.current=!0},[S,n,o,m,c,s,l,H,y,K,b,P,u1,G,J]);const M1=(_=>({INITIATED:2,PROCESSING:2,SUCCESS:3,COMPLETED:3,FAILED:2,CANCELLED:2,DECLINED:2})[_]||1)(I1);return jsxRuntimeExports.jsx(Drawer,{open:o,onClose:n,children:jsxRuntimeExports.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-6 fp:py-8 fp:flex fp:flex-col fp:items-center",children:[v1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"fp:relative fp:w-16 fp:h-16 fp:flex fp:items-center fp:justify-center fp:mb-4",children:[jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-16 fp:h-16 fp:bg-red-50 fp:rounded-full"}),jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:w-12 fp:h-12 fp:bg-red-500 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:jsxRuntimeExports.jsx("svg",{className:"fp:w-6 fp:h-6 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"2.5",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),jsxRuntimeExports.jsx("h2",{className:"fp:text-[24px] fp:font-semibold fp:text-gray-900 fp:mb-2",children:"Payment Failed"}),jsxRuntimeExports.jsx("p",{className:"fp:text-[14px] fp:text-gray-600 fp:text-center fp:mb-6 fp:max-w-sm",children:v1}),jsxRuntimeExports.jsx("button",{onClick:n,className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:bg-[#16558B] fp:text-white",children:"Close"})]}):o1?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsx("p",{className:"fp:text-[18px] fp:text-[#16558B] fp:font-medium",children:"Taking you to Netbanking..."})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(CircularProgress,{size:40,color:"#16558B",style:{marginBottom:"24px"}}),jsxRuntimeExports.jsxs("h1",{className:"fp:text-[32px] fp:font-bold fp:text-gray-800 fp:mb-1",children:["₹",formatCurrency(H)]}),jsxRuntimeExports.jsx("p",{className:"fp:text-[16px] fp:text-gray-600 fp:mb-6",children:"Payment Processing..."}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:mb-6",children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[14px] fp:font-semibold fp:text-gray-700 fp:mb-3",children:"Payment Status"}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-3",children:[jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${M1>=1?"fp:bg-green-500":"fp:bg-gray-300"}`,children:M1>=1&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${M1>=1?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment started"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${M1>=2?"fp:bg-green-500":"fp:bg-gray-300"}`,children:M1>=2&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${M1>=2?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment in progress"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-3",children:[jsxRuntimeExports.jsx("div",{className:`fp:w-5 fp:h-5 fp:rounded-full fp:flex fp:items-center fp:justify-center ${M1>=3?"fp:bg-green-500":"fp:bg-gray-300"}`,children:M1>=3&&jsxRuntimeExports.jsx("svg",{className:"fp:w-3 fp:h-3 fp:text-white",fill:"none",stroke:"currentColor",strokeWidth:"3",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),jsxRuntimeExports.jsx("span",{className:`fp:text-[14px] ${M1>=3?"fp:text-gray-800 fp:font-medium":"fp:text-gray-400"}`,children:"Payment success"})]})]})]})]}),k1&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("h3",{className:"fp:text-[16px] fp:font-semibold fp:w-full fp:text-left fp:mt-2 fp:mb-2",children:"Payment Details"}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-2 fp:p-4 fp:border-2 fp:border-gray-300 fp:rounded-2xl",children:[jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Transaction ID"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:k1?.transactionId??"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Date & Time"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:k1?.transactionDate?`${formatDateLong(k1.transactionDate)}, ${formatTime(k1.transactionDate)}`:"-"})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Payment Method"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:$(k1?.paymentMode??"")})]}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-gray-700 fp:text-[12px] fp:font-medium",children:"Party Code"}),jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:font-medium",children:k1?.partyCode??"-"})]})]}),jsxRuntimeExports.jsx("button",{onClick:()=>{window.flutter_inappwebview?.callHandler("homeWebView")},className:"fp:w-full fp:h-12 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:mt-4 fp:mb-14 fp:justify-center fp:bg-[#16558B] fp:text-white",children:"Home"})]})]})})},PAYMENT_CHANNELS=["NEFT","IMPS","RTGS"],BankTransferDrawer=({open:o,onClose:n,onPaymentCollected:s,metadata:l})=>{const{payableValue:c,salesmanPhoneNumber:m,distributorName:S,chemistName:H,payerUuid:K,payerMobileNumber:b,typeOfApp:v}=usePaymentContext(),y=v==="FUNDLY_TRADE",[D,k]=reactExports.useState(null),[C,I]=reactExports.useState(""),[P,O]=reactExports.useState(""),[W,u1]=reactExports.useState(!1),[J,G]=reactExports.useState(""),[r1,p1]=reactExports.useState(""),[o1,A1]=reactExports.useState([]),[I1,s1]=reactExports.useState(!1),[v1,j1]=reactExports.useState(!1),[k1,O1]=reactExports.useState(""),[h1,i1]=reactExports.useState(null),[q,$]=reactExports.useState(!1),[Q,n1]=reactExports.useState(!1),[f1,d1]=reactExports.useState("Submit"),[R1,M1]=reactExports.useState(!1),[_,a1]=reactExports.useState(""),g1=reactExports.useRef(null),D1=reactExports.useRef(null),U1=reactExports.useRef(null),X1=reactExports.useRef(null),W1=()=>{n(),le()},le=()=>{k(null),I(""),O(""),u1(!1),G(""),p1(""),A1([]),s1(!1),O1(""),i1(null),$(!1),n1(!1),d1("Submit"),a1(""),M1(!1)};reactExports.useEffect(()=>{o||le()},[o]);const Me=reactExports.useCallback(async K1=>{U1.current&&clearTimeout(U1.current),U1.current=setTimeout(async()=>{j1(!0);try{const ye=await fetchBankList(K1),Ie=Array.isArray(ye)?ye:ye?.data??[];A1(Ie),s1(Ie.length>0)}catch{A1([])}finally{j1(!1)}},K1.trim()?300:0)},[]);reactExports.useEffect(()=>{const K1=ye=>{g1.current&&!g1.current.contains(ye.target)&&s1(!1),D1.current&&!D1.current.contains(ye.target)&&u1(!1)};return document.addEventListener("mousedown",K1),()=>document.removeEventListener("mousedown",K1)},[]);async function ge(K1,ye){return(await http.post(getDocumentApiUrl(),{byteString:K1,fileName:ye,type:"BANK_TRANSFER"},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${getAccessToken()||""}`}})).data}const xe=K1=>new Promise((ye,Ie)=>{const Le=new FileReader;Le.onload=()=>{const Qe=Le.result,et=Qe.split(",")[1]||Qe;ye(et)},Le.onerror=Qe=>Ie(Qe),Le.readAsDataURL(K1)}),oe=async()=>{if(!navigator.onLine){n1(!0),d1("Submit Again");return}n1(!1),d1("Submit"),M1(!0);try{let K1;if(h1){const et=await xe(h1),rt=await ge(et,h1.name);K1=rt?.data?.documentId||rt?.documentId||rt?.id||void 0}const Ie={...PaymentPayloadBuilder.buildPayload(l,"BANK_TRANSFER",Number(c)||0,{bankName:J.trim()||void 0,salesmanPhoneNumber:m||void 0,chemistName:H||void 0,distributorName:S||void 0}),utr:C.trim(),paymentChannel:P,bankName:J.trim(),notes:k1.trim()||void 0,documentId:K1?Number(K1):void 0,paymentDate:D?D.toISOString():new Date().toISOString(),mobileNumber:b||void 0,uuid:K||null};PaymentPayloadBuilder.validatePayload(Ie);const Le=await makePaymentWithAnalytics(Ie),Qe=Le.data||Le;s&&s(Qe)}catch(K1){const ye=K1?.response?.data?.errorMessage||K1?.response?.data?.errorDesc||K1?.response?.data?.message||K1?.message||"Bank transfer payment failed. Please try again.";a1(ye)}finally{M1(!1)}},Z1=D!==null&&C.trim().length>0&&P.length>0&&(y||J.trim().length>0);return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs(Drawer,{open:o,onClose:W1,children:[jsxRuntimeExports.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-4 fp:pt-6 fp:mb-12",children:[jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between",children:[jsxRuntimeExports.jsxs("h1",{className:"fp:font-normal fp:items-center fp:text-[#222222]",children:["Payable Amount :"," ",jsxRuntimeExports.jsxs("label",{className:"fp:font-semibold",children:["₹",c]})]}),jsxRuntimeExports.jsx("img",{src:assets.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>$(!0)})]}),_&&jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:bg-red-50 fp:border fp:border-red-200 fp:rounded-xl fp:p-3 fp:flex fp:items-start fp:space-x-2 fp:mt-4",children:[jsxRuntimeExports.jsx("svg",{className:"fp:w-5 fp:h-5 fp:text-red-500 fp:flex-shrink-0 fp:mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),jsxRuntimeExports.jsxs("div",{className:"fp:flex-1",children:[jsxRuntimeExports.jsx("p",{className:"fp:text-[14px] fp:text-red-700 fp:font-medium",children:"Payment Failed"}),jsxRuntimeExports.jsx("p",{className:"fp:text-[12px] fp:text-red-600 fp:mt-1",children:_})]}),jsxRuntimeExports.jsx("button",{onClick:()=>a1(""),className:"fp:text-red-400 fp:hover:text-red-600",children:jsxRuntimeExports.jsx("svg",{className:"fp:w-4 fp:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),jsxRuntimeExports.jsx("input",{ref:X1,type:"file",accept:"image/*,application/pdf",hidden:!0,onChange:K1=>{const ye=K1.target.files?.[0];if(ye){if(ye.size>10485760){a1(`File size exceeds 10MB limit. Please select a smaller file. (Current: ${(ye.size/1024/1024).toFixed(2)}MB)`);return}i1(ye),a1("")}K1.target.value=""}}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-8 fp:space-y-4",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx(DatePicker,{value:D,onChange:K1=>k(K1),label:"Payment Date",fullWidth:!0})}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{htmlFor:"utr-number",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"UTR"}),jsxRuntimeExports.jsx("input",{id:"utr-number",type:"text",value:C,onChange:K1=>I(K1.target.value.slice(0,50)),placeholder:"Enter UTR number",style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocus:K1=>K1.currentTarget.style.borderColor="#16558B",onBlur:K1=>K1.currentTarget.style.borderColor="#ccc"})]}),jsxRuntimeExports.jsxs("div",{ref:D1,style:{position:"relative"},children:[jsxRuntimeExports.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Payment Channel"}),jsxRuntimeExports.jsxs("div",{onClick:()=>u1(!W),style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:`1px solid ${W?"#16558B":"#ccc"}`,borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff"},children:[jsxRuntimeExports.jsx("span",{style:{color:P?"#222":"#999"},children:P||"Select payment channel"}),jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntimeExports.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),W&&jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:"#fff",border:"1px solid #E0E0E0",borderRadius:"8px",maxHeight:"200px",overflowY:"auto",zIndex:100,boxShadow:"0 4px 12px rgba(0,0,0,0.1)",marginTop:"4px"},children:PAYMENT_CHANNELS.map(K1=>jsxRuntimeExports.jsx("div",{onClick:()=>{O(K1),u1(!1)},style:{padding:"10px 16px",fontSize:"14px",fontFamily:"Poppins",cursor:"pointer",backgroundColor:P===K1?"#F5F9FD":"#fff"},onMouseEnter:ye=>ye.currentTarget.style.backgroundColor="#F5F9FD",onMouseLeave:ye=>ye.currentTarget.style.backgroundColor=P===K1?"#F5F9FD":"#fff",children:K1},K1))})]}),jsxRuntimeExports.jsxs("div",{ref:g1,style:{position:"relative"},children:[jsxRuntimeExports.jsxs("label",{htmlFor:"bank-name-transfer",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:["Bank Name",y&&" (Optional)"]}),jsxRuntimeExports.jsxs("div",{style:{position:"relative"},children:[jsxRuntimeExports.jsx("input",{id:"bank-name-transfer",type:"text",value:J||r1,onChange:K1=>{const ye=K1.target.value;G(""),p1(ye),Me(ye)},onFocus:()=>{J?(p1(J),G(""),Me(J)):o1.length>0?s1(!0):Me("")},placeholder:"Search bank name...",style:{width:"100%",height:"48px",padding:"12px 36px 12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocusCapture:K1=>K1.currentTarget.style.borderColor="#16558B",onBlurCapture:K1=>K1.currentTarget.style.borderColor="#ccc",autoComplete:"off"}),jsxRuntimeExports.jsx("div",{style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"},children:v1?jsxRuntimeExports.jsxs("svg",{className:"fp:animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[jsxRuntimeExports.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#ccc",strokeWidth:"3"}),jsxRuntimeExports.jsx("path",{d:"M12 2a10 10 0 019.8 8",stroke:"#16558B",strokeWidth:"3",strokeLinecap:"round"})]}):J?jsxRuntimeExports.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{cursor:"pointer"},onClick:K1=>{K1.stopPropagation(),G(""),p1(""),A1([]),s1(!1)},children:[jsxRuntimeExports.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),jsxRuntimeExports.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntimeExports.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),I1&&o1.length>0&&jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,backgroundColor:"#fff",border:"1px solid #E0E0E0",borderRadius:"8px",maxHeight:"200px",overflowY:"auto",zIndex:100,boxShadow:"0 4px 12px rgba(0,0,0,0.1)",marginTop:"4px"},children:o1.map((K1,ye)=>{const Ie=typeof K1=="string"?K1:K1?.bankName||K1?.name||String(K1);return jsxRuntimeExports.jsx("div",{onClick:()=>{G(Ie),p1(""),s1(!1)},style:{padding:"10px 16px",fontSize:"14px",fontFamily:"Poppins",cursor:"pointer",borderBottom:ye<o1.length-1?"1px solid #F0F0F0":"none"},onMouseEnter:Le=>Le.currentTarget.style.backgroundColor="#F5F9FD",onMouseLeave:Le=>Le.currentTarget.style.backgroundColor="#fff",children:Ie},ye)})})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("label",{htmlFor:"notes",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Additional Notes"}),jsxRuntimeExports.jsx("textarea",{id:"notes",value:k1,onChange:K1=>O1(K1.target.value),placeholder:"Additional Notes...",rows:3,style:{width:"100%",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none",resize:"vertical"},onFocus:K1=>K1.currentTarget.style.borderColor="#16558B",onBlur:K1=>K1.currentTarget.style.borderColor="#ccc"})]}),!h1&&jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between fp:border-1 fp:border-dashed fp:border-[#cccccc] fp:rounded-lg fp:py-3 fp:px-8 fp:cursor-pointer fp:mt-2",onClick:()=>X1.current?.click(),children:[jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:flex-col fp:items-center",children:[jsxRuntimeExports.jsx("span",{className:"fp:text-[#aaa]",children:"Upload Proof (Optional)"}),jsxRuntimeExports.jsx("span",{className:"fp:text-[12px] fp:text-[#aaa]",children:"(JPG, JPEG, PNG, PDF - Max 10MB)"})]}),jsxRuntimeExports.jsx("img",{src:assets.uploadIcon,className:"fp:w-5 fp:h-5",alt:"Upload"})]}),h1&&jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:p-3 fp:space-y-1 fp:border-2 fp:border-gray-200 fp:rounded-lg",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-[12px] fp:text-[#16558B]",children:"Payment Proof"}),jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between fp:gap-2",children:[jsxRuntimeExports.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:truncate fp:flex-1 fp:min-w-0",children:h1.name}),jsxRuntimeExports.jsx("img",{src:assets.trash,className:"fp:w-4 fp:h-4 fp:cursor-pointer fp:flex-shrink-0",onClick:()=>i1(null)})]})]}),Q&&jsxRuntimeExports.jsx("span",{className:"fp:text-red-500 fp:text-[12px] fp:mt-1",children:"We couldn't process your payment due to a network error. Please retry."}),jsxRuntimeExports.jsx("button",{className:`fp:w-full fp:h-12 fp:mt-4 fp:rounded-lg fp:text-[16px] fp:flex fp:items-center fp:justify-center fp:bg-[#16558B] fp:text-white ${!Z1||R1?"fp:opacity-50 fp:cursor-not-allowed":"fp:cursor-pointer"}`,onClick:oe,disabled:!Z1||R1,children:R1?jsxRuntimeExports.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[jsxRuntimeExports.jsxs("svg",{className:"fp:animate-spin fp:h-5 fp:w-5 fp:text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[jsxRuntimeExports.jsx("circle",{className:"fp:opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),jsxRuntimeExports.jsx("path",{className:"fp:opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),jsxRuntimeExports.jsx("span",{children:"Processing..."})]}):f1})]})]}),jsxRuntimeExports.jsxs(Dialog,{open:q,onClose:()=>$(!1),children:[jsxRuntimeExports.jsx(DialogContent,{children:jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center",children:[jsxRuntimeExports.jsx("img",{src:assets.Gateway,className:"fp:w-15 fp:h-15"}),jsxRuntimeExports.jsx("span",{style:{fontFamily:"Poppins"},className:"fp:text-[16px] fp:mt-3 fp:text-wrap fp:font-semibold fp:text-center fp:text-[#222222]",children:"Payment has not been completed. Do you still want to close?"})]})}),jsxRuntimeExports.jsx(DialogActions,{children:jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[jsxRuntimeExports.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[48px] fp:text-[18px] fp:border-2 fp:border-gray-300 fp:text-gray-400 fp:rounded-xl",onClick:()=>{$(!1),n()},children:"Exit"}),jsxRuntimeExports.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[48px] fp:text-[18px] fp:bg-[#16558B] fp:text-white fp:rounded-xl",onClick:()=>$(!1),children:"Continue"})]})})]})]})})},LoadingSpinner=({message:o})=>jsxRuntimeExports.jsxs("div",{className:"fp:w-full fp:h-screen fp:flex fp:flex-col fp:items-center fp:justify-center fp:bg-[#F8FCFF] fp:relative",children:[jsxRuntimeExports.jsxs("div",{className:"fp:relative fp:w-32 fp:h-32 fp:flex fp:items-center fp:justify-center",children:[jsxRuntimeExports.jsx("div",{className:"fp:absolute fp:inset-0 fp:rounded-full fp:border-4 fp:border-t-[#16558B] fp:border-[#E5E9F2] animate-spin-slow"}),jsxRuntimeExports.jsx("img",{src:assets.logo,className:"fp:w-20 fp:h-20",alt:"Fundly Logo"})]}),o&&jsxRuntimeExports.jsxs("p",{className:"fp:mt-6 fp:text-sm fp:font-bold fp:text-[16px]",style:{color:"#16558B",letterSpacing:"0.5px"},children:[o,jsxRuntimeExports.jsxs("span",{className:"fp:inline-block loading-dots fp:pl-1",style:{minWidth:24},children:[jsxRuntimeExports.jsx("span",{children:"."}),jsxRuntimeExports.jsx("span",{children:"."}),jsxRuntimeExports.jsx("span",{children:"."})]})]}),jsxRuntimeExports.jsx("style",{children:`
|
|
693
693
|
.loading-dots span {
|
|
694
694
|
opacity: 0.2;
|
|
695
695
|
animation: loading-dot 1.2s infinite;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const c=require("./index-
|
|
1
|
+
"use strict";const c=require("./index-o0K3ginw.cjs"),u=require("./index-cETuXup5.cjs");function f(t,i){for(var n=0;n<i.length;n++){const e=i[n];if(typeof e!="string"&&!Array.isArray(e)){for(const r in e)if(r!=="default"&&!(r in t)){const o=Object.getOwnPropertyDescriptor(e,r);o&&Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var s=u.requireLib();const a=c.getDefaultExportFromCjs(s),d=f({__proto__:null,default:a},[s]);exports.index=d;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as Xn } from "./index-
|
|
2
|
-
import { r as pe } from "./index-
|
|
1
|
+
import { g as Xn } from "./index-DF39Q_Pq.js";
|
|
2
|
+
import { r as pe } from "./index-CAnbE8Uz.js";
|
|
3
3
|
import he from "react";
|
|
4
4
|
import Tn from "react-dom";
|
|
5
5
|
function Qn(e, j) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import require$$1 from "react";
|
|
2
|
-
import { r as require$$5 } from "./index-
|
|
2
|
+
import { r as require$$5 } from "./index-DF39Q_Pq.js";
|
|
3
3
|
var lib = { exports: {} }, core_min = {};
|
|
4
4
|
function commonjsRequire(r) {
|
|
5
5
|
throw new Error('Could not dynamically require "' + r + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
@@ -13908,8 +13908,8 @@ const $f = ({
|
|
|
13908
13908
|
), [De, _] = k(!1), [ve, Xe] = k(null), [_e, at] = k(null), [ht, tt] = k(!1), [pt, lt] = k(null), [Rt, $t] = k([]), [Ue, Jt] = k(!1), Zn = on.useMemo(
|
|
13909
13909
|
() => on.lazy(
|
|
13910
13910
|
() => Promise.all([
|
|
13911
|
-
import("./index-
|
|
13912
|
-
import("./index-
|
|
13911
|
+
import("./index-B8zykwej.js").then((Ie) => Ie.i),
|
|
13912
|
+
import("./index-C9akEZTb.js").then((Ie) => Ie.i)
|
|
13913
13913
|
]).then(([{ Worker: Ie, Viewer: ze }, { defaultLayoutPlugin: mt }]) => ({
|
|
13914
13914
|
default: ({ fileUrl: Ct }) => {
|
|
13915
13915
|
const xt = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent), gt = () => {
|
|
@@ -15412,7 +15412,7 @@ Fundly Team`;
|
|
|
15412
15412
|
// For analytics only
|
|
15413
15413
|
payerMobileNumber: O || void 0,
|
|
15414
15414
|
// For API
|
|
15415
|
-
|
|
15415
|
+
isMobileChanged: re || !1
|
|
15416
15416
|
};
|
|
15417
15417
|
te && te.trim() !== "" ? Se.chemistBusinessId = te : W && W.trim() !== "" && (Se.leadId = W), o === "INVOICE_COLLECT" ? Se.paymentInvoice = Q : o === "DIRECT_COLLECT" && (Se.invoiceIds = z);
|
|
15418
15418
|
try {
|
|
@@ -16075,7 +16075,7 @@ Fundly Team`;
|
|
|
16075
16075
|
distributorName: Z || void 0,
|
|
16076
16076
|
mobileNumber: O || void 0,
|
|
16077
16077
|
payerMobileNumber: O || void 0,
|
|
16078
|
-
|
|
16078
|
+
isMobileChanged: re || !1
|
|
16079
16079
|
};
|
|
16080
16080
|
te && te.trim() !== "" ? ot.chemistBusinessId = te : W && W.trim() !== "" && (ot.leadId = W), o === "INVOICE_COLLECT" ? ot.paymentInvoice = Q : o === "DIRECT_COLLECT" && (ot.invoiceIds = z);
|
|
16081
16081
|
try {
|
|
@@ -17619,9 +17619,9 @@ const fu = ({
|
|
|
17619
17619
|
error_code: null,
|
|
17620
17620
|
error_description: null,
|
|
17621
17621
|
failure_stage: null,
|
|
17622
|
-
sdk_version: "1.5.1-beta.
|
|
17622
|
+
sdk_version: "1.5.1-beta.5",
|
|
17623
17623
|
app_context: qt(),
|
|
17624
|
-
app_version: "1.5.1-beta.
|
|
17624
|
+
app_version: "1.5.1-beta.5",
|
|
17625
17625
|
mobile_number: ue || null,
|
|
17626
17626
|
uuid: De || null
|
|
17627
17627
|
};
|