@fundly.ai/payment-sdk 1.4.0-beta.8 → 1.4.0

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.
@@ -1,5 +1,5 @@
1
- import { g as Xn } from "./index-CREEoAJa.js";
2
- import { r as pe } from "./index-CEzdQXZE.js";
1
+ import { g as Xn } from "./index-CXu6Jk-h.js";
2
+ import { r as pe } from "./index-DoadyuNK.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-CREEoAJa.js";
2
+ import { r as require$$5 } from "./index-CXu6Jk-h.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.');
@@ -605,7 +605,7 @@ Thank you for your payment!`;await Mt.shareByteImage(ee,H,`Transaction_${U}`)}ca
605
605
  #date-picker-input::-webkit-inner-spin-button {
606
606
  display: none;
607
607
  }
608
- `})]})},t0=({open:u,onClose:o,onPaymentCollected:A,metadata:I})=>{const{payableValue:a,typeOfApp:P,salesmanPhoneNumber:O,distributorName:k,chemistName:R,payerMobileNumber:F,payerUuid:J}=ms(),z=()=>{o(),X(null),Y(null),be(""),ke(""),Me(""),Se([]),Le(!1),H(!1),me(!1),ge(!1),se("Submit"),lt(!1)},[G,X]=C.useState(null),[ee,Y]=C.useState(null),U=C.useRef(null),[q,be]=C.useState(""),[Ne,H]=C.useState(!1),[ie,me]=C.useState(!1),[Ce,ge]=C.useState(!1),[V,se]=C.useState("Submit"),[ue,Ae]=C.useState(!1),[ve,ke]=C.useState(""),[ce,Me]=C.useState(""),[Z,Se]=C.useState([]),[De,Le]=C.useState(!1),[xe,Be]=C.useState(!1),Ze=C.useRef(null),We=C.useRef(null),$e=C.useCallback(async le=>{We.current&&clearTimeout(We.current),We.current=setTimeout(async()=>{Be(!0);try{const Ee=await _l(le),K=Array.isArray(Ee)?Ee:Ee?.data??[];Se(K),Le(K.length>0)}catch{Se([])}finally{Be(!1)}},le.trim()?300:0)},[]);C.useEffect(()=>{const le=Ee=>{Ze.current&&!Ze.current.contains(Ee.target)&&Le(!1)};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[]);async function he(le,Ee){try{return(await Dt.post(Ji(),{byteString:le,fileName:Ee,type:"CHEQUE"},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${He()||""}`}})).data}catch(K){throw K}}const ne=le=>new Promise((Ee,K)=>{const Ie=new FileReader;Ie.onload=()=>{const Ye=Ie.result,it=Ye.split(",")[1]||Ye;Ee(it)},Ie.onerror=Ye=>K(Ye),Ie.readAsDataURL(le)}),ye=async()=>{if(!navigator.onLine){ge(!0),se("Submit Again");return}ge(!1),se("Submit"),Ae(!0);try{let le;if(ee){const it=await ne(ee),tt=await he(it,ee.name);le=tt?.data?.documentId||tt?.documentId||tt?.id||void 0}const Ee=G?G.toISOString():new Date().toISOString(),K=ii.buildPayload(I,"CHEQUE",Number(a)||0,{chequeNumber:q,chequeDate:Ee,bankName:ve.trim()||void 0,documentId:le||void 0,salesmanName:Ue.trim()||void 0,salesmanPhoneNumber:O||void 0,chemistName:R||void 0,distributorName:k||void 0,mobileNumber:F||void 0,uuid:J||null});ii.validatePayload(K);const Ie=await dn(K),Ye=Ie.data||Ie;Ye&&!Ye.chequeNumber&&(Ye.chequeNumber=q),A&&A(Ye)}catch(le){const Ee=le?.response?.data?.errorMessage||le?.response?.data?.errorDesc||le?.response?.data?.message||le?.message||"Cheque payment failed. Please try again.";Re(Ee)}finally{Ae(!1)}},[qe,lt]=C.useState(!1),[Ue,Te]=C.useState(""),[Ge,Re]=C.useState(""),[Ve,et]=C.useState(null);return C.useEffect(()=>{u||(X(null),Y(null),be(""),ke(""),Me(""),Se([]),Le(!1),H(!1),me(!1),ge(!1),se("Submit"),lt(!1),Te(""),Re(""),Ae(!1))},[u]),C.useEffect(()=>{if(ee){const le=URL.createObjectURL(ee);return et(le),()=>{URL.revokeObjectURL(le)}}else et(null)},[ee]),e.jsxs(e.Fragment,{children:[e.jsxs(ws,{open:u,onClose:z,children:[e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-4 fp:pt-6 fp:mb-12 ",children:[e.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between",children:[e.jsxs("h1",{className:"fp:font-normal fp:items-center fp:text-[#222222]",children:["Payable Amount :"," ",e.jsxs("label",{className:"fp:font-semibold",children:["₹",a]})]}),e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>H(!0)})]}),Ge&&e.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:[e.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:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"fp:flex-1",children:[e.jsx("p",{className:"fp:text-[14px] fp:text-red-700 fp:font-medium",children:"Payment Failed"}),e.jsx("p",{className:"fp:text-[12px] fp:text-red-600 fp:mt-1",children:Ge})]}),e.jsx("button",{onClick:()=>Re(""),className:"fp:text-red-400 fp:hover:text-red-600",children:e.jsx("svg",{className:"fp:w-4 fp:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("input",{ref:U,type:"file",accept:"image/*,application/pdf",hidden:!0,onChange:le=>{const Ee=le.target.files?.[0];if(Ee){if(Ee.size>10485760){Re(`File size exceeds 10MB limit. Please select a smaller file. (Current: ${(Ee.size/1024/1024).toFixed(2)}MB)`);return}Y(Ee),Re("")}le.target.value=""}}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-8 fp:space-y-4",children:[e.jsx("div",{children:e.jsx(Yi,{value:G,onChange:le=>X(le),label:"Cheque Date",fullWidth:!0})}),P==="FUNDLY_CUSTOMER_APP"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"salesman-name",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#BBBBBB",fontFamily:"Poppins"},children:"Salesman Name (Optional)"}),e.jsx("input",{id:"salesman-name",type:"text",value:Ue,onChange:le=>Te(le.target.value),style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocus:le=>le.currentTarget.style.borderColor="#16558B",onBlur:le=>le.currentTarget.style.borderColor="#ccc"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"cheque-number",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Cheque Number"}),e.jsx("input",{id:"cheque-number",type:"text",value:q,onChange:le=>{const Ee=le.target.value.replace(/\D/g,"").slice(0,50);be(Ee)},inputMode:"numeric",pattern:"[0-9]*",maxLength:50,style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocus:le=>le.currentTarget.style.borderColor="#16558B",onBlur:le=>le.currentTarget.style.borderColor="#ccc"}),e.jsx("span",{className:"fp:w-full fp:flex fp:justify-end fp:text-[10px] fp:text-gray-400 fp:mt-1",children:"* Max 50 Char Allowed"})]}),e.jsxs("div",{ref:Ze,style:{position:"relative"},children:[e.jsx("label",{htmlFor:"bank-name",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Bank Name"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{id:"bank-name",type:"text",value:ve||ce,onChange:le=>{const Ee=le.target.value;ke(""),Me(Ee),$e(Ee)},onFocus:()=>{ve?(Me(ve),ke(""),$e(ve)):Z.length>0?Le(!0):$e("")},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:le=>le.currentTarget.style.borderColor="#16558B",onBlurCapture:le=>le.currentTarget.style.borderColor="#ccc",autoComplete:"off"}),e.jsx("div",{style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"},children:xe?e.jsxs("svg",{className:"fp:animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#ccc",strokeWidth:"3"}),e.jsx("path",{d:"M12 2a10 10 0 019.8 8",stroke:"#16558B",strokeWidth:"3",strokeLinecap:"round"})]}):ve?e.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:le=>{le.stopPropagation(),ke(""),Me(""),Se([]),Le(!1)},children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),De&&Z.length>0&&e.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:Z.map((le,Ee)=>{const K=typeof le=="string"?le:le?.bankName||le?.name||String(le);return e.jsx("div",{onClick:()=>{ke(K),Me(""),Le(!1)},style:{padding:"10px 16px",fontSize:"14px",fontFamily:"Poppins",cursor:"pointer",borderBottom:Ee<Z.length-1?"1px solid #F0F0F0":"none"},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor="#F5F9FD",onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="#fff",children:K},Ee)})})]}),!ee&&e.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:()=>U.current?.click(),children:[e.jsxs("div",{className:"fp:flex fp:flex-col fp:items-center",children:[e.jsx("span",{className:"fp:text-[#aaa]",children:"Upload Cheque Image"}),e.jsx("span",{className:"fp:text-[12px] fp:text-[#aaa]",children:"(JPG, JPEG, PNG, PDF - Max 10MB)"})]}),e.jsx("img",{src:we.uploadIcon,className:"fp:w-5 fp:h-5",alt:"Upload"})]}),ee&&e.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:[e.jsx("label",{className:"fp:text-[12px] fp:text-[#16558B]",children:"Payment Proof"}),e.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between fp:gap-2",children:[e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:truncate fp:flex-1 fp:min-w-0",children:ee.name}),e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-4 fp:flex-shrink-0",children:[e.jsx("img",{src:we.trash,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>lt(!0)}),e.jsx("img",{src:we.eye,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>me(!0)})]})]})]}),Ce&&e.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."}),e.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 ${!G||!q.trim()||!ve.trim()||ue?"fp:opacity-50 fp:cursor-not-allowed":"fp:cursor-pointer"}`,onClick:ye,disabled:!q.trim()||!ve.trim()||!G||ue,children:ue?e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.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:[e.jsx("circle",{className:"fp:opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"fp:opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:"Processing..."})]}):V})]})]}),e.jsxs(gs,{open:Ne,onClose:()=>H(!1),children:[e.jsx(Is,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center",children:[e.jsx("img",{src:we.Gateway,className:"fp:w-15 fp:h-15"}),e.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?"})]})}),e.jsx(Ls,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[e.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:()=>{H(!1),o()},children:"Exit"}),e.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:()=>H(!1),children:"Continue"})]})})]}),e.jsxs(gs,{open:qe,onClose:()=>lt(!1),children:[e.jsx(Is,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center fp:space-y-1",children:[e.jsx("img",{src:we.chequeDeleted,className:"fp:w-14 fp:h-14"}),e.jsx("span",{style:{fontFamily:"Poppins"},className:"fp:text-[14px] fp:text-center fp:font-semibold",children:"Are you sure?"}),e.jsx("span",{style:{fontFamily:"Poppins"},className:"fp:text-[12px] fp:text-gray-500 fp:text-center",children:"This cheque image will be deleted."})]})}),e.jsx(Ls,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[e.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[44px] fp:text-[16px] fp:border fp:border-gray-300 fp:text-gray-500 fp:rounded-xl",onClick:()=>{Y(null),lt(!1)},children:"Yes, Delete"}),e.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[44px] fp:text-[16px] fp:bg-[#16558B] fp:text-white fp:rounded-xl",onClick:()=>lt(!1),children:"No"})]})})]})]}),e.jsxs(gs,{open:ie,onClose:()=>me(!1),children:[e.jsx(ln,{sx:{padding:"8px 12px"},children:e.jsx("div",{className:"fp:w-full fp:flex fp:justify-end",children:e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:bg-gray-100 fp:hover:bg-gray-200 fp:rounded-full fp:cursor-pointer fp:shadow-md",onClick:()=>me(!1),children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4",alt:"Close"})})})}),e.jsx(Is,{children:Ve&&ee&&e.jsx(e.Fragment,{children:ee.type.includes("pdf")?e.jsx("iframe",{src:Ve,className:"fp:w-full fp:h-[500px] fp:rounded-lg"}):e.jsx("img",{src:Ve,alt:"Preview",className:"fp:w-full fp:rounded-lg"})})})]})]})};function pt(u){return Number(u??0).toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}const Zf=({open:u,onClose:o,onPaymentCollected:A,selectedLenderIdx:I=-1,selectedLenderFiCode:a=null,selectedLenderTenureMappings:P=[],selectedLenderRepaymentOption:O=null,selectedLenderDisbursementAccount:k=null})=>{const{tenureMappings:R,payableValue:F,paymentType:J,paymentInvoice:z,invoices:G,chemistId:X,leadId:ee,fiCode:Y,typeOfApp:U,payerMobileNumber:q,salesmanId:be,distributorIdnum:Ne,distributorName:H,drawdownRepaymentOption:ie,creditLimitData:me,payerUuid:Ce}=ms(),ge=P.length>0?P:R,[V,se]=C.useState(-1),[ue,Ae]=C.useState(I);C.useEffect(()=>{I!==-1&&Ae(I)},[I]);const[ve,ke]=C.useState(!1),ce=()=>{o()},Me=a||Y,Z=Me==="TRILLIONLOAN",Se=new Date;Se.setDate(Se.getDate()+1);const[De,Le]=C.useState(Z?new Date:Se),[xe,Be]=C.useState(["","","","","",""]),Ze=C.useRef([]),[We,$e]=C.useState(0),[he,ne]=C.useState("idle"),[ye,qe]=C.useState(!1),[lt,Ue]=C.useState(!1),[Te,Ge]=C.useState(""),[Re,Ve]=C.useState(""),[et,le]=C.useState(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"?"Collect":"Pay Now"),[Ee,K]=C.useState(!1),[Ie,Ye]=C.useState(null),[it,tt]=C.useState(null),[ht,rt]=C.useState(!1),[at,Lt]=C.useState(null),[nt,Fe]=C.useState([]),[Ct,Tt]=C.useState(!1),St=C.useMemo(()=>C.lazy(()=>Promise.all([Promise.resolve().then(()=>require("./index-Byk5pSDI.cjs")).then(je=>je.index),Promise.resolve().then(()=>require("./index-Cq5QBVwp.cjs")).then(je=>je.index)]).then(([{Worker:je,Viewer:Xe},{defaultLayoutPlugin:bt}])=>({default:({fileUrl:Nt})=>{const vt=/Android|iPhone|iPad|iPod/i.test(navigator.userAgent),jt=()=>{let rs;if(Nt.startsWith("data:application/pdf;base64,")){const Bt=Nt.replace("data:application/pdf;base64,",""),Un=Uint8Array.from(atob(Bt),Jt=>Jt.charCodeAt(0)),Qn=new Blob([Un],{type:"application/pdf"});rs=URL.createObjectURL(Qn)}else rs=Nt;if(vt){const Bt=document.createElement("a");Bt.href=rs,Bt.download="KFS_Document.pdf",document.body.appendChild(Bt),Bt.click(),document.body.removeChild(Bt),setTimeout(()=>{rs.startsWith("blob:")&&URL.revokeObjectURL(rs)},1e3)}else{const Bt=document.createElement("iframe");Bt.style.display="none",Bt.src=rs,document.body.appendChild(Bt),Bt.onload=()=>{Bt.contentWindow?.focus(),Bt.contentWindow?.print(),setTimeout(()=>{document.body.removeChild(Bt),rs.startsWith("blob:")&&URL.revokeObjectURL(rs)},1e3)}}},os=bt({sidebarTabs:()=>[],renderToolbar:rs=>e.jsx(rs,{children:Bt=>{const{CurrentPageInput:Un,NumberOfPages:Qn,Zoom:Jt,ZoomIn:Wi,ZoomOut:ri}=Bt;return e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"0 8px",gap:"4px"},children:[e.jsx(ri,{}),e.jsx(Jt,{}),e.jsx(Wi,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginLeft:"8px"},children:[e.jsx(Un,{}),e.jsx("span",{style:{fontSize:"13px",color:"#555"},children:"/"}),e.jsx(Qn,{})]}),e.jsx("button",{onClick:jt,style:{marginLeft:"auto",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center"},title:"Print",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#16558B",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),e.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),e.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})})]})}})});return e.jsx(je,{workerUrl:"https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js",children:e.jsx(Xe,{fileUrl:Nt,plugins:[os]})})}}))),[]),ft=C.useCallback(je=>{const Xe=je.getFullYear(),bt=String(je.getMonth()+1).padStart(2,"0"),Nt=String(je.getDate()).padStart(2,"0");return`${Xe}-${bt}-${Nt}`},[]),ut=C.useCallback(async()=>{if(Me!=="TRILLIONLOAN"){K(!1);return}K(!0);try{const je=He(),Xe=a||Y||"",bt=O||ie||"BULLET",Nt=new URLSearchParams({loanAmount:String(F),businessId:X||"",openedOnDate:ft(De||Se),productType:"INSTACASH",tenureMagnitude:String(ge[V]?.tenureValue||""),tenureUnit:String(ge[V]?.tenureUnit||""),fiCode:Xe,repaymentOption:bt,supplierId:Ne||""});J==="INVOICE_COLLECT"&&z?.length>0&&Nt.append("invoiceNumber",z.map(os=>os.invoiceId).join(","));const vt=`${Rn()}/kfs/report?${Nt.toString()}`,jt=await Dt.get(vt,{headers:{accept:"application/json",Authorization:`Bearer ${je}`}});Ye(jt.data),tt(jt.data?.documentId??null),rt(!1)}catch(je){console.error("[Fundly Pay] Error fetching KFS:",je),Ye(null),tt(null),rt(!1)}finally{K(!1)}},[a,Y,O,ie,F,X,De,V,ge,Ne,J,z,ft]),st=C.useCallback(async()=>{if(Me==="TRILLIONLOAN")try{const je=He(),Xe=new URLSearchParams({businessId:X||"",intents:"DRAWDOWN_KFS_SIGN",fiCode:Me||""}),bt=`${Rn()}/consent?${Xe.toString()}`,vt=(await Dt.get(bt,{headers:{accept:"*/*","Content-Type":"application/json",Authorization:`Bearer ${je}`}})).data;if(Fe(Array.isArray(vt)?vt:[]),vt?.[0]?.consentMessage){let jt=vt[0].consentMessage;jt=jt.replace("{{lenderName}}",Me||""),jt=jt.replace("Drawdown Request Letter",'<span class="kfs-link" style="color:#16558B;text-decoration:underline;cursor:pointer">Drawdown Request Letter</span>'),jt=jt.replace("Sanction Letter",'<span class="kfs-link" style="color:#16558B;text-decoration:underline;cursor:pointer">Sanction Letter</span>'),jt=jt.replace("Key Fact Statement",'<span class="kfs-link" style="color:#16558B;text-decoration:underline;cursor:pointer">Key Fact Statement</span>'),Lt(jt)}}catch(je){console.error("[Fundly Pay] Error fetching consent:",je),Lt(null)}},[X]),re=C.useCallback(async()=>{try{const je=He(),Xe=`${Rn()}/consent`;await Dt.post(Xe,{businessId:X||"",intent:"DRAWDOWN_KFS_SIGN",consents:nt.map(bt=>({consentId:bt.consentId,accepted:!0}))},{headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${je}`}})}catch(je){console.error("[Fundly Pay] Error submitting consent:",je)}},[X,nt]),Oe=C.useCallback(()=>{Ie&&Tt(!0)},[Ie]),Pe=C.useMemo(()=>Ie?Ie.kfsDocumentBytes?`data:application/pdf;base64,${Ie.kfsDocumentBytes}`:Ie.kfsDocumentUrl||Ie.documentUrl||null:null,[Ie]),xt=C.useRef(null);C.useEffect(()=>{const je=xt.current;if(!je)return;const Xe=bt=>{bt.target.classList.contains("kfs-link")&&Oe()};return je.addEventListener("click",Xe),()=>je.removeEventListener("click",Xe)},[Oe,at]);const yt=async()=>{Ve("");try{q&&H&&await vf(q,H)}catch(je){console.error("Error sending OTP:",je);const Xe=je,bt=Xe?.response?.data?.errorMessage||Xe?.response?.data?.message||Xe?.message||"Failed to send OTP. Please try again.";Ve(bt),ne("resend"),$e(0)}},Ft=async()=>{if(!navigator.onLine){Ue(!0),le("Submit Again");return}if(Ue(!1),ye)return;if(qe(!0),!De){console.error("[Fundly Pay] Payment date is required"),qe(!1);return}const je=De.toISOString(),Xe=je.split("T")[0],bt=a||Y,Nt={paymentMode:"FUNDLY_PAY",paymentDate:je,paymentType:J,distributorCode:Ne,...it&&{documentId:it},salesmanId:be,invoiceCount:z?.length||G?.length||0,mobileNumber:q||void 0,uuid:Ce||null,loanDrawdownRequestDTO:{businessId:X||ee,fiCode:bt,requestedAmount:F,scheduledDate:Xe,tenure:ge[V]?.tenureValue||"",tenureUnit:ge[V]?.tenureUnit?.replace(/s$/i,"")||"",invoiceIds:U==="FUNDLY_MART"||U==="FUNDLY_TRADE"?[]:J==="INVOICE_COLLECT"?z?.map(vt=>vt.invoiceId)??[]:G??[],sourceSystem:U,paymentType:J}};X&&X.trim()!==""?Nt.chemistBusinessId=X:ee&&ee.trim()!==""&&(Nt.leadId=ee),J==="INVOICE_COLLECT"?Nt.paymentInvoice=z:J==="DIRECT_COLLECT"&&(Nt.invoiceIds=G,Nt.paidAmount=F),(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"||U==="FUNDLY_TRADE")&&(Nt.loanDrawdownRequestDTO.mobileNumber=q,Nt.loanDrawdownRequestDTO.loanInitiateOtp=xe.join("")),q&&(Nt.payerMobileNumber=q),Me==="TRILLIONLOAN"&&re();try{const vt=await dn(Nt),jt=vt?.data||vt;jt&&!jt.scheduleDate&&(jt.scheduleDate=Xe),jt&&At?.lastRepaymentDate&&(jt.dueDate=At.lastRepaymentDate),A&&A(jt)}catch(vt){const jt=vt?.response?.data?.errorMessage||vt?.response?.data?.errorDesc||vt?.response?.data?.message||vt?.message||"Payment failed. Please try again.";Ge(jt)}finally{qe(!1)}},Ss=(je,Xe)=>{if(!/^[0-9]?$/.test(je))return;const bt=[...xe];bt[Xe]=je,Be(bt),je&&Xe<5&&Ze.current[Xe+1]?.focus()},Ns=(je,Xe)=>{je.key==="Backspace"&&!xe[Xe]&&Xe>0&&Ze.current[Xe-1]?.focus()},Gs=()=>{ne("countdown"),$e(30),yt()};C.useEffect(()=>{if(he==="countdown"&&We>0){const je=setInterval(()=>{$e(Xe=>Xe-1)},1e3);return()=>clearInterval(je)}else he==="countdown"&&We===0&&(ne("resend"),yt())},[We,he]);const Zt=C.useMemo(()=>{if(Z&&Ee)return!0;const je=V!==-1,Xe=De!==null,bt=ue!==-1||!me?.subLimits,Nt=Z?ht:!0;if(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"||U==="FUNDLY_TRADE"){const vt=xe.every(jt=>jt!=="");return!(je&&vt&&Xe&&bt&&Nt)}return!(je&&Xe&&bt&&Nt)},[V,ue,xe,U,De,me,ht,Ee]),[At,hs]=C.useState(null),[pn,wt]=C.useState(!1),Bs=async()=>{if(V===-1)return;const je=ge[V],Xe=a||Y||"",bt=O||ie||"BULLET",Nt=k||"SUPPLIER";wt(!0);try{const vt=await Tf({loanAmount:Number(F),businessId:X||"",openedOnDate:ft(De||Se),productType:"INSTACASH",tenureMagnitude:je.tenureValue,tenureUnit:je.tenureUnit,fiCode:Xe,repaymentOption:bt,disbursementAccount:Nt});hs(vt)}catch(vt){console.error("Error fetching EMI:",vt),hs(null)}finally{wt(!1)}};return C.useEffect(()=>{let je;return u&&V!==-1&&ue!==-1&&(je=window.setTimeout(()=>{Bs()},1e3)),()=>{clearTimeout(je)}},[V,ue,De]),C.useEffect(()=>{if(u){if(se(0),Z)Le(new Date),rt(!1);else{const je=new Date;je.setDate(je.getDate()+1),Le(je)}st()}},[u,st]),C.useEffect(()=>{if(!u||Me!=="TRILLIONLOAN")return;const je=window.setTimeout(()=>{ut()},400);return()=>clearTimeout(je)},[V,De,ut]),C.useEffect(()=>{const je=()=>{u&&V!==-1&&(Bs(),ut())};return window.addEventListener("online",je),()=>{window.removeEventListener("online",je)}},[u,V,ut]),e.jsxs(ws,{open:u,onClose:ce,children:[e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-4 fp:pt-6 fp:mb-12 ",children:[e.jsx("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-end",children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>ke(!0)})}),Te&&e.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:[e.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:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"fp:flex-1",children:[e.jsx("p",{className:"fp:text-[14px] fp:text-red-700 fp:font-medium",children:"Payment Failed"}),e.jsx("p",{className:"fp:text-[12px] fp:text-red-600 fp:mt-1",children:Te})]}),e.jsx("button",{onClick:()=>Ge(""),className:"fp:text-red-400 fp:hover:text-red-600",children:e.jsx("svg",{className:"fp:w-4 fp:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-4 fp:space-y-4",children:[e.jsx("div",{children:e.jsx(Yi,{value:De,onChange:je=>Le(je),minDate:Z?void 0:Se,label:"Select Payment Date",fullWidth:!0,disabled:Z})}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-2 ",children:[e.jsx("span",{className:"fp:text-[15px] fp:font-medium fp:text-[#222222]",children:"Tenure"}),e.jsx("div",{className:"fp:w-full fp:flex fp:space-x-4 ",children:ge&&ge.length>0?ge.map((je,Xe)=>e.jsxs("button",{type:"button",className:`fp:py-1 fp:px-6 fp:border-[] fp:rounded-2xl fp:text-[14px] fp:font-medium fp:focus:outline-none fp:transition-colors fp:duration-150 ${V===Xe?"fp:border-[#16558B] fp:bg-[#E6F0FA] fp:text-[#16558B]":"fp:border-[#D0D0D0] fp:text-gray-700 fp:bg-white"}`,onClick:()=>{se(Xe)},children:[je.tenureValue," ",je.tenureUnit]},Xe)):e.jsx("span",{className:"fp:py-1 fp:px-6 fp:border-2 fp:rounded-2xl fp:text-[14px] fp:border-[#D0D0D0] fp:text-gray-700 fp:font-medium",children:"No tenure available"})})]}),!Z&&e.jsxs("span",{className:"fp:text-[12px] fp:font-medium fp:text-green-600 fp:text-wrap",children:["₹",pt(F)," will be processed via Fundly Credit — a loan will be set up in retailer's account."]}),e.jsxs("div",{className:"fp:text-[12px] fp:w-full fp:border fp:p-4 fp:space-y-3 fp:rounded-2xl fp:flex fp:flex-col fp:border-[#E8EEF3] ",children:[e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Due date"}),e.jsx("label",{className:"fp:font-medium",children:At?.lastRepaymentDate?ni(At.lastRepaymentDate):"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"ROI (Annualised)"}),e.jsx("label",{className:"fp:font-medium",children:At?.normalInterestRate!=null?`${At.normalInterestRate}%`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Interest/₹ 10,000/day"}),e.jsx("label",{className:"fp:font-medium",children:At?.interestPerDay!=null?`₹${At.interestPerDay}`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Penal Charges"}),e.jsx("label",{className:"fp:font-medium",children:At?.penalInterestRate!=null?`${At.penalInterestRate}% p.a`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Processing Fee"}),e.jsx("label",{className:"fp:font-medium",children:At?.processingFeeExclGst!=null?`₹${Number(At.processingFeeExclGst).toLocaleString("en-IN")}`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"APR"}),e.jsx("label",{className:"fp:font-medium",children:At?.apr!=null?`${At.apr}%`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Net Disbursed Amount"}),e.jsx("label",{className:"fp:font-medium",children:At?.creditedAmount!=null?`₹${Number(At.creditedAmount).toLocaleString("en-IN")}`:"—"})]})]}),(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"||U==="FUNDLY_TRADE")&&e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-4 fp:border-2 fp:border-[#E8EEF3] fp:mt-2 fp:rounded-2xl fp:p-3",children:[e.jsx("label",{className:"fp:font-medium fp:text-[15px]",children:"Retailer Verification"}),e.jsxs("div",{className:"fp:w-full fp:flex fp:space-x-2 fp:justify-between",children:[e.jsx("div",{className:"fp:flex fp:border-2 fp:rounded-lg fp:px-1 fp:space-x-2 ",children:xe.map((je,Xe)=>e.jsx("input",{type:"text",value:je,maxLength:1,placeholder:"●",ref:bt=>{Ze.current[Xe]=bt},onChange:bt=>Ss(bt.target.value,Xe),onKeyDown:bt=>Ns(bt,Xe),className:"fp:w-7 fp:h-8 fp:text-center fp:text-[16px] fp:outline-none"},Xe))}),e.jsxs("button",{onClick:Gs,disabled:he==="countdown",className:`fp:text-white fp:text-[12px] fp:px-7 fp:rounded-lg ${he==="resend"?"fp:bg-gray-500":"fp:bg-[#16558B]"}`,children:[he==="idle"&&"Get OTP",he==="countdown"&&`${We}s`,he==="resend"&&"Resend"]})]}),Re?e.jsxs("div",{className:"fp:w-full fp:bg-red-50 fp:border fp:border-red-200 fp:rounded-lg fp:p-2 fp:flex fp:items-start fp:space-x-2",children:[e.jsx("svg",{className:"fp:w-4 fp:h-4 fp:text-red-500 fp:flex-shrink-0 fp:mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"fp:text-[11px] fp:text-red-700",children:Re})]}):e.jsxs("label",{className:"fp:text-[13px] fp:flex fp:text-center fp:items-center fp:text-[#16558B]",children:[e.jsx("img",{src:we.info,className:"fp:w-4 fp:h-4 fp:mr-1"}),he==="idle"?"OTP will be sent to the retailer for consent.":"An OTP has been sent to the retailer for consent."]})]}),at&&e.jsx("div",{ref:xt,className:"fp:text-[12px] fp:text-gray-600 fp:leading-relaxed fp:select-none",dangerouslySetInnerHTML:{__html:at}}),Z&&e.jsxs("label",{className:"fp:flex fp:items-start fp:space-x-2 fp:cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ht,onChange:je=>{const Xe=je.target.checked;rt(Xe),Xe&&Oe()},className:"fp:mt-0.5 fp:w-4 fp:h-4 fp:flex-shrink-0 fp:accent-[#16558B]"}),e.jsxs("span",{className:"fp:text-[12px] fp:text-gray-700",children:["I agree to the loan terms and accept the"," ",e.jsx("span",{className:"fp:text-[#16558B] fp:underline fp:cursor-pointer",onClick:je=>{je.preventDefault(),Oe()},children:"Key Fact Statement (KFS)"})]})]}),lt&&e.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."}),e.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
608
+ `})]})},t0=({open:u,onClose:o,onPaymentCollected:A,metadata:I})=>{const{payableValue:a,typeOfApp:P,salesmanPhoneNumber:O,distributorName:k,chemistName:R,payerMobileNumber:F,payerUuid:J}=ms(),z=()=>{o(),X(null),Y(null),be(""),ke(""),Me(""),Se([]),Le(!1),H(!1),me(!1),ge(!1),se("Submit"),lt(!1)},[G,X]=C.useState(null),[ee,Y]=C.useState(null),U=C.useRef(null),[q,be]=C.useState(""),[Ne,H]=C.useState(!1),[ie,me]=C.useState(!1),[Ce,ge]=C.useState(!1),[V,se]=C.useState("Submit"),[ue,Ae]=C.useState(!1),[ve,ke]=C.useState(""),[ce,Me]=C.useState(""),[Z,Se]=C.useState([]),[De,Le]=C.useState(!1),[xe,Be]=C.useState(!1),Ze=C.useRef(null),We=C.useRef(null),$e=C.useCallback(async le=>{We.current&&clearTimeout(We.current),We.current=setTimeout(async()=>{Be(!0);try{const Ee=await _l(le),K=Array.isArray(Ee)?Ee:Ee?.data??[];Se(K),Le(K.length>0)}catch{Se([])}finally{Be(!1)}},le.trim()?300:0)},[]);C.useEffect(()=>{const le=Ee=>{Ze.current&&!Ze.current.contains(Ee.target)&&Le(!1)};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[]);async function he(le,Ee){try{return(await Dt.post(Ji(),{byteString:le,fileName:Ee,type:"CHEQUE"},{headers:{"Content-Type":"application/json",Authorization:`Bearer ${He()||""}`}})).data}catch(K){throw K}}const ne=le=>new Promise((Ee,K)=>{const Ie=new FileReader;Ie.onload=()=>{const Ye=Ie.result,it=Ye.split(",")[1]||Ye;Ee(it)},Ie.onerror=Ye=>K(Ye),Ie.readAsDataURL(le)}),ye=async()=>{if(!navigator.onLine){ge(!0),se("Submit Again");return}ge(!1),se("Submit"),Ae(!0);try{let le;if(ee){const it=await ne(ee),tt=await he(it,ee.name);le=tt?.data?.documentId||tt?.documentId||tt?.id||void 0}const Ee=G?G.toISOString():new Date().toISOString(),K=ii.buildPayload(I,"CHEQUE",Number(a)||0,{chequeNumber:q,chequeDate:Ee,bankName:ve.trim()||void 0,documentId:le||void 0,salesmanName:Ue.trim()||void 0,salesmanPhoneNumber:O||void 0,chemistName:R||void 0,distributorName:k||void 0,mobileNumber:F||void 0,uuid:J||null});ii.validatePayload(K);const Ie=await dn(K),Ye=Ie.data||Ie;Ye&&!Ye.chequeNumber&&(Ye.chequeNumber=q),A&&A(Ye)}catch(le){const Ee=le?.response?.data?.errorMessage||le?.response?.data?.errorDesc||le?.response?.data?.message||le?.message||"Cheque payment failed. Please try again.";Re(Ee)}finally{Ae(!1)}},[qe,lt]=C.useState(!1),[Ue,Te]=C.useState(""),[Ge,Re]=C.useState(""),[Ve,et]=C.useState(null);return C.useEffect(()=>{u||(X(null),Y(null),be(""),ke(""),Me(""),Se([]),Le(!1),H(!1),me(!1),ge(!1),se("Submit"),lt(!1),Te(""),Re(""),Ae(!1))},[u]),C.useEffect(()=>{if(ee){const le=URL.createObjectURL(ee);return et(le),()=>{URL.revokeObjectURL(le)}}else et(null)},[ee]),e.jsxs(e.Fragment,{children:[e.jsxs(ws,{open:u,onClose:z,children:[e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-4 fp:pt-6 fp:mb-12 ",children:[e.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between",children:[e.jsxs("h1",{className:"fp:font-normal fp:items-center fp:text-[#222222]",children:["Payable Amount :"," ",e.jsxs("label",{className:"fp:font-semibold",children:["₹",a]})]}),e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>H(!0)})]}),Ge&&e.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:[e.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:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"fp:flex-1",children:[e.jsx("p",{className:"fp:text-[14px] fp:text-red-700 fp:font-medium",children:"Payment Failed"}),e.jsx("p",{className:"fp:text-[12px] fp:text-red-600 fp:mt-1",children:Ge})]}),e.jsx("button",{onClick:()=>Re(""),className:"fp:text-red-400 fp:hover:text-red-600",children:e.jsx("svg",{className:"fp:w-4 fp:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("input",{ref:U,type:"file",accept:"image/*,application/pdf",hidden:!0,onChange:le=>{const Ee=le.target.files?.[0];if(Ee){if(Ee.size>10485760){Re(`File size exceeds 10MB limit. Please select a smaller file. (Current: ${(Ee.size/1024/1024).toFixed(2)}MB)`);return}Y(Ee),Re("")}le.target.value=""}}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-8 fp:space-y-4",children:[e.jsx("div",{children:e.jsx(Yi,{value:G,onChange:le=>X(le),label:"Cheque Date",fullWidth:!0})}),P==="FUNDLY_CUSTOMER_APP"&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"salesman-name",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#BBBBBB",fontFamily:"Poppins"},children:"Salesman Name (Optional)"}),e.jsx("input",{id:"salesman-name",type:"text",value:Ue,onChange:le=>Te(le.target.value),style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocus:le=>le.currentTarget.style.borderColor="#16558B",onBlur:le=>le.currentTarget.style.borderColor="#ccc"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"cheque-number",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Cheque Number"}),e.jsx("input",{id:"cheque-number",type:"text",value:q,onChange:le=>{const Ee=le.target.value.replace(/\D/g,"").slice(0,50);be(Ee)},inputMode:"numeric",pattern:"[0-9]*",maxLength:50,style:{width:"100%",height:"48px",padding:"12px 16px",fontSize:"16px",fontFamily:"Poppins",border:"1px solid #ccc",borderRadius:"8px",outline:"none"},onFocus:le=>le.currentTarget.style.borderColor="#16558B",onBlur:le=>le.currentTarget.style.borderColor="#ccc"}),e.jsx("span",{className:"fp:w-full fp:flex fp:justify-end fp:text-[10px] fp:text-gray-400 fp:mt-1",children:"* Max 50 Char Allowed"})]}),e.jsxs("div",{ref:Ze,style:{position:"relative"},children:[e.jsx("label",{htmlFor:"bank-name",style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:500,color:"#222222",fontFamily:"Poppins"},children:"Bank Name"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx("input",{id:"bank-name",type:"text",value:ve||ce,onChange:le=>{const Ee=le.target.value;ke(""),Me(Ee),$e(Ee)},onFocus:()=>{ve?(Me(ve),ke(""),$e(ve)):Z.length>0?Le(!0):$e("")},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:le=>le.currentTarget.style.borderColor="#16558B",onBlurCapture:le=>le.currentTarget.style.borderColor="#ccc",autoComplete:"off"}),e.jsx("div",{style:{position:"absolute",right:"12px",top:"50%",transform:"translateY(-50%)",display:"flex",alignItems:"center"},children:xe?e.jsxs("svg",{className:"fp:animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"#ccc",strokeWidth:"3"}),e.jsx("path",{d:"M12 2a10 10 0 019.8 8",stroke:"#16558B",strokeWidth:"3",strokeLinecap:"round"})]}):ve?e.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:le=>{le.stopPropagation(),ke(""),Me(""),Se([]),Le(!1)},children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"#999",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),De&&Z.length>0&&e.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:Z.map((le,Ee)=>{const K=typeof le=="string"?le:le?.bankName||le?.name||String(le);return e.jsx("div",{onClick:()=>{ke(K),Me(""),Le(!1)},style:{padding:"10px 16px",fontSize:"14px",fontFamily:"Poppins",cursor:"pointer",borderBottom:Ee<Z.length-1?"1px solid #F0F0F0":"none"},onMouseEnter:Ie=>Ie.currentTarget.style.backgroundColor="#F5F9FD",onMouseLeave:Ie=>Ie.currentTarget.style.backgroundColor="#fff",children:K},Ee)})})]}),!ee&&e.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:()=>U.current?.click(),children:[e.jsxs("div",{className:"fp:flex fp:flex-col fp:items-center",children:[e.jsx("span",{className:"fp:text-[#aaa]",children:"Upload Cheque Image"}),e.jsx("span",{className:"fp:text-[12px] fp:text-[#aaa]",children:"(JPG, JPEG, PNG, PDF - Max 10MB)"})]}),e.jsx("img",{src:we.uploadIcon,className:"fp:w-5 fp:h-5",alt:"Upload"})]}),ee&&e.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:[e.jsx("label",{className:"fp:text-[12px] fp:text-[#16558B]",children:"Payment Proof"}),e.jsxs("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-between fp:gap-2",children:[e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:truncate fp:flex-1 fp:min-w-0",children:ee.name}),e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-4 fp:flex-shrink-0",children:[e.jsx("img",{src:we.trash,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>lt(!0)}),e.jsx("img",{src:we.eye,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>me(!0)})]})]})]}),Ce&&e.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."}),e.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 ${!G||!q.trim()||!ve.trim()||ue?"fp:opacity-50 fp:cursor-not-allowed":"fp:cursor-pointer"}`,onClick:ye,disabled:!q.trim()||!ve.trim()||!G||ue,children:ue?e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.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:[e.jsx("circle",{className:"fp:opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"fp:opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v4a4 4 0 00-4 4H4z"})]}),e.jsx("span",{children:"Processing..."})]}):V})]})]}),e.jsxs(gs,{open:Ne,onClose:()=>H(!1),children:[e.jsx(Is,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center",children:[e.jsx("img",{src:we.Gateway,className:"fp:w-15 fp:h-15"}),e.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?"})]})}),e.jsx(Ls,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[e.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:()=>{H(!1),o()},children:"Exit"}),e.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:()=>H(!1),children:"Continue"})]})})]}),e.jsxs(gs,{open:qe,onClose:()=>lt(!1),children:[e.jsx(Is,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center fp:space-y-1",children:[e.jsx("img",{src:we.chequeDeleted,className:"fp:w-14 fp:h-14"}),e.jsx("span",{style:{fontFamily:"Poppins"},className:"fp:text-[14px] fp:text-center fp:font-semibold",children:"Are you sure?"}),e.jsx("span",{style:{fontFamily:"Poppins"},className:"fp:text-[12px] fp:text-gray-500 fp:text-center",children:"This cheque image will be deleted."})]})}),e.jsx(Ls,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[e.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[44px] fp:text-[16px] fp:border fp:border-gray-300 fp:text-gray-500 fp:rounded-xl",onClick:()=>{Y(null),lt(!1)},children:"Yes, Delete"}),e.jsx("button",{style:{fontFamily:"Poppins"},className:"fp:flex-1 fp:h-[44px] fp:text-[16px] fp:bg-[#16558B] fp:text-white fp:rounded-xl",onClick:()=>lt(!1),children:"No"})]})})]})]}),e.jsxs(gs,{open:ie,onClose:()=>me(!1),children:[e.jsx(ln,{sx:{padding:"8px 12px"},children:e.jsx("div",{className:"fp:w-full fp:flex fp:justify-end",children:e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:bg-gray-100 fp:hover:bg-gray-200 fp:rounded-full fp:cursor-pointer fp:shadow-md",onClick:()=>me(!1),children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4",alt:"Close"})})})}),e.jsx(Is,{children:Ve&&ee&&e.jsx(e.Fragment,{children:ee.type.includes("pdf")?e.jsx("iframe",{src:Ve,className:"fp:w-full fp:h-[500px] fp:rounded-lg"}):e.jsx("img",{src:Ve,alt:"Preview",className:"fp:w-full fp:rounded-lg"})})})]})]})};function pt(u){return Number(u??0).toLocaleString("en-IN",{minimumFractionDigits:2,maximumFractionDigits:2})}const Zf=({open:u,onClose:o,onPaymentCollected:A,selectedLenderIdx:I=-1,selectedLenderFiCode:a=null,selectedLenderTenureMappings:P=[],selectedLenderRepaymentOption:O=null,selectedLenderDisbursementAccount:k=null})=>{const{tenureMappings:R,payableValue:F,paymentType:J,paymentInvoice:z,invoices:G,chemistId:X,leadId:ee,fiCode:Y,typeOfApp:U,payerMobileNumber:q,salesmanId:be,distributorIdnum:Ne,distributorName:H,drawdownRepaymentOption:ie,creditLimitData:me,payerUuid:Ce}=ms(),ge=P.length>0?P:R,[V,se]=C.useState(-1),[ue,Ae]=C.useState(I);C.useEffect(()=>{I!==-1&&Ae(I)},[I]);const[ve,ke]=C.useState(!1),ce=()=>{o()},Me=a||Y,Z=Me==="TRILLIONLOAN",Se=new Date;Se.setDate(Se.getDate()+1);const[De,Le]=C.useState(Z?new Date:Se),[xe,Be]=C.useState(["","","","","",""]),Ze=C.useRef([]),[We,$e]=C.useState(0),[he,ne]=C.useState("idle"),[ye,qe]=C.useState(!1),[lt,Ue]=C.useState(!1),[Te,Ge]=C.useState(""),[Re,Ve]=C.useState(""),[et,le]=C.useState(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"?"Collect":"Pay Now"),[Ee,K]=C.useState(!1),[Ie,Ye]=C.useState(null),[it,tt]=C.useState(null),[ht,rt]=C.useState(!1),[at,Lt]=C.useState(null),[nt,Fe]=C.useState([]),[Ct,Tt]=C.useState(!1),St=C.useMemo(()=>C.lazy(()=>Promise.all([Promise.resolve().then(()=>require("./index-6wVCaTBh.cjs")).then(je=>je.index),Promise.resolve().then(()=>require("./index-BLhMaxVO.cjs")).then(je=>je.index)]).then(([{Worker:je,Viewer:Xe},{defaultLayoutPlugin:bt}])=>({default:({fileUrl:Nt})=>{const vt=/Android|iPhone|iPad|iPod/i.test(navigator.userAgent),jt=()=>{let rs;if(Nt.startsWith("data:application/pdf;base64,")){const Bt=Nt.replace("data:application/pdf;base64,",""),Un=Uint8Array.from(atob(Bt),Jt=>Jt.charCodeAt(0)),Qn=new Blob([Un],{type:"application/pdf"});rs=URL.createObjectURL(Qn)}else rs=Nt;if(vt){const Bt=document.createElement("a");Bt.href=rs,Bt.download="KFS_Document.pdf",document.body.appendChild(Bt),Bt.click(),document.body.removeChild(Bt),setTimeout(()=>{rs.startsWith("blob:")&&URL.revokeObjectURL(rs)},1e3)}else{const Bt=document.createElement("iframe");Bt.style.display="none",Bt.src=rs,document.body.appendChild(Bt),Bt.onload=()=>{Bt.contentWindow?.focus(),Bt.contentWindow?.print(),setTimeout(()=>{document.body.removeChild(Bt),rs.startsWith("blob:")&&URL.revokeObjectURL(rs)},1e3)}}},os=bt({sidebarTabs:()=>[],renderToolbar:rs=>e.jsx(rs,{children:Bt=>{const{CurrentPageInput:Un,NumberOfPages:Qn,Zoom:Jt,ZoomIn:Wi,ZoomOut:ri}=Bt;return e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"0 8px",gap:"4px"},children:[e.jsx(ri,{}),e.jsx(Jt,{}),e.jsx(Wi,{}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginLeft:"8px"},children:[e.jsx(Un,{}),e.jsx("span",{style:{fontSize:"13px",color:"#555"},children:"/"}),e.jsx(Qn,{})]}),e.jsx("button",{onClick:jt,style:{marginLeft:"auto",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center"},title:"Print",children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#16558B",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),e.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),e.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})})]})}})});return e.jsx(je,{workerUrl:"https://unpkg.com/pdfjs-dist@3.11.174/build/pdf.worker.min.js",children:e.jsx(Xe,{fileUrl:Nt,plugins:[os]})})}}))),[]),ft=C.useCallback(je=>{const Xe=je.getFullYear(),bt=String(je.getMonth()+1).padStart(2,"0"),Nt=String(je.getDate()).padStart(2,"0");return`${Xe}-${bt}-${Nt}`},[]),ut=C.useCallback(async()=>{if(Me!=="TRILLIONLOAN"){K(!1);return}K(!0);try{const je=He(),Xe=a||Y||"",bt=O||ie||"BULLET",Nt=new URLSearchParams({loanAmount:String(F),businessId:X||"",openedOnDate:ft(De||Se),productType:"INSTACASH",tenureMagnitude:String(ge[V]?.tenureValue||""),tenureUnit:String(ge[V]?.tenureUnit||""),fiCode:Xe,repaymentOption:bt,supplierId:Ne||""});J==="INVOICE_COLLECT"&&z?.length>0&&Nt.append("invoiceNumber",z.map(os=>os.invoiceId).join(","));const vt=`${Rn()}/kfs/report?${Nt.toString()}`,jt=await Dt.get(vt,{headers:{accept:"application/json",Authorization:`Bearer ${je}`}});Ye(jt.data),tt(jt.data?.documentId??null),rt(!1)}catch(je){console.error("[Fundly Pay] Error fetching KFS:",je),Ye(null),tt(null),rt(!1)}finally{K(!1)}},[a,Y,O,ie,F,X,De,V,ge,Ne,J,z,ft]),st=C.useCallback(async()=>{if(Me==="TRILLIONLOAN")try{const je=He(),Xe=new URLSearchParams({businessId:X||"",intents:"DRAWDOWN_KFS_SIGN",fiCode:Me||""}),bt=`${Rn()}/consent?${Xe.toString()}`,vt=(await Dt.get(bt,{headers:{accept:"*/*","Content-Type":"application/json",Authorization:`Bearer ${je}`}})).data;if(Fe(Array.isArray(vt)?vt:[]),vt?.[0]?.consentMessage){let jt=vt[0].consentMessage;jt=jt.replace("{{lenderName}}",Me||""),jt=jt.replace("Drawdown Request Letter",'<span class="kfs-link" style="color:#16558B;text-decoration:underline;cursor:pointer">Drawdown Request Letter</span>'),jt=jt.replace("Sanction Letter",'<span class="kfs-link" style="color:#16558B;text-decoration:underline;cursor:pointer">Sanction Letter</span>'),jt=jt.replace("Key Fact Statement",'<span class="kfs-link" style="color:#16558B;text-decoration:underline;cursor:pointer">Key Fact Statement</span>'),Lt(jt)}}catch(je){console.error("[Fundly Pay] Error fetching consent:",je),Lt(null)}},[X]),re=C.useCallback(async()=>{try{const je=He(),Xe=`${Rn()}/consent`;await Dt.post(Xe,{businessId:X||"",intent:"DRAWDOWN_KFS_SIGN",consents:nt.map(bt=>({consentId:bt.consentId,accepted:!0}))},{headers:{Accept:"application/json","Content-Type":"application/json",Authorization:`Bearer ${je}`}})}catch(je){console.error("[Fundly Pay] Error submitting consent:",je)}},[X,nt]),Oe=C.useCallback(()=>{Ie&&Tt(!0)},[Ie]),Pe=C.useMemo(()=>Ie?Ie.kfsDocumentBytes?`data:application/pdf;base64,${Ie.kfsDocumentBytes}`:Ie.kfsDocumentUrl||Ie.documentUrl||null:null,[Ie]),xt=C.useRef(null);C.useEffect(()=>{const je=xt.current;if(!je)return;const Xe=bt=>{bt.target.classList.contains("kfs-link")&&Oe()};return je.addEventListener("click",Xe),()=>je.removeEventListener("click",Xe)},[Oe,at]);const yt=async()=>{Ve("");try{q&&H&&await vf(q,H)}catch(je){console.error("Error sending OTP:",je);const Xe=je,bt=Xe?.response?.data?.errorMessage||Xe?.response?.data?.message||Xe?.message||"Failed to send OTP. Please try again.";Ve(bt),ne("resend"),$e(0)}},Ft=async()=>{if(!navigator.onLine){Ue(!0),le("Submit Again");return}if(Ue(!1),ye)return;if(qe(!0),!De){console.error("[Fundly Pay] Payment date is required"),qe(!1);return}const je=De.toISOString(),Xe=je.split("T")[0],bt=a||Y,Nt={paymentMode:"FUNDLY_PAY",paymentDate:je,paymentType:J,distributorCode:Ne,...it&&{documentId:it},salesmanId:be,invoiceCount:z?.length||G?.length||0,mobileNumber:q||void 0,uuid:Ce||null,loanDrawdownRequestDTO:{businessId:X||ee,fiCode:bt,requestedAmount:F,scheduledDate:Xe,tenure:ge[V]?.tenureValue||"",tenureUnit:ge[V]?.tenureUnit?.replace(/s$/i,"")||"",invoiceIds:U==="FUNDLY_MART"||U==="FUNDLY_TRADE"?[]:J==="INVOICE_COLLECT"?z?.map(vt=>vt.invoiceId)??[]:G??[],sourceSystem:U,paymentType:J}};X&&X.trim()!==""?Nt.chemistBusinessId=X:ee&&ee.trim()!==""&&(Nt.leadId=ee),J==="INVOICE_COLLECT"?Nt.paymentInvoice=z:J==="DIRECT_COLLECT"&&(Nt.invoiceIds=G,Nt.paidAmount=F),(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"||U==="FUNDLY_TRADE")&&(Nt.loanDrawdownRequestDTO.mobileNumber=q,Nt.loanDrawdownRequestDTO.loanInitiateOtp=xe.join("")),q&&(Nt.payerMobileNumber=q),Me==="TRILLIONLOAN"&&re();try{const vt=await dn(Nt),jt=vt?.data||vt;jt&&!jt.scheduleDate&&(jt.scheduleDate=Xe),jt&&At?.lastRepaymentDate&&(jt.dueDate=At.lastRepaymentDate),A&&A(jt)}catch(vt){const jt=vt?.response?.data?.errorMessage||vt?.response?.data?.errorDesc||vt?.response?.data?.message||vt?.message||"Payment failed. Please try again.";Ge(jt)}finally{qe(!1)}},Ss=(je,Xe)=>{if(!/^[0-9]?$/.test(je))return;const bt=[...xe];bt[Xe]=je,Be(bt),je&&Xe<5&&Ze.current[Xe+1]?.focus()},Ns=(je,Xe)=>{je.key==="Backspace"&&!xe[Xe]&&Xe>0&&Ze.current[Xe-1]?.focus()},Gs=()=>{ne("countdown"),$e(30),yt()};C.useEffect(()=>{if(he==="countdown"&&We>0){const je=setInterval(()=>{$e(Xe=>Xe-1)},1e3);return()=>clearInterval(je)}else he==="countdown"&&We===0&&(ne("resend"),yt())},[We,he]);const Zt=C.useMemo(()=>{if(Z&&Ee)return!0;const je=V!==-1,Xe=De!==null,bt=ue!==-1||!me?.subLimits,Nt=Z?ht:!0;if(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"||U==="FUNDLY_TRADE"){const vt=xe.every(jt=>jt!=="");return!(je&&vt&&Xe&&bt&&Nt)}return!(je&&Xe&&bt&&Nt)},[V,ue,xe,U,De,me,ht,Ee]),[At,hs]=C.useState(null),[pn,wt]=C.useState(!1),Bs=async()=>{if(V===-1)return;const je=ge[V],Xe=a||Y||"",bt=O||ie||"BULLET",Nt=k||"SUPPLIER";wt(!0);try{const vt=await Tf({loanAmount:Number(F),businessId:X||"",openedOnDate:ft(De||Se),productType:"INSTACASH",tenureMagnitude:je.tenureValue,tenureUnit:je.tenureUnit,fiCode:Xe,repaymentOption:bt,disbursementAccount:Nt});hs(vt)}catch(vt){console.error("Error fetching EMI:",vt),hs(null)}finally{wt(!1)}};return C.useEffect(()=>{let je;return u&&V!==-1&&ue!==-1&&(je=window.setTimeout(()=>{Bs()},1e3)),()=>{clearTimeout(je)}},[V,ue,De]),C.useEffect(()=>{if(u){if(se(0),Z)Le(new Date),rt(!1);else{const je=new Date;je.setDate(je.getDate()+1),Le(je)}st()}},[u,st]),C.useEffect(()=>{if(!u||Me!=="TRILLIONLOAN")return;const je=window.setTimeout(()=>{ut()},400);return()=>clearTimeout(je)},[V,De,ut]),C.useEffect(()=>{const je=()=>{u&&V!==-1&&(Bs(),ut())};return window.addEventListener("online",je),()=>{window.removeEventListener("online",je)}},[u,V,ut]),e.jsxs(ws,{open:u,onClose:ce,children:[e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:px-4 fp:pt-6 fp:mb-12 ",children:[e.jsx("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-end",children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>ke(!0)})}),Te&&e.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:[e.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:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{className:"fp:flex-1",children:[e.jsx("p",{className:"fp:text-[14px] fp:text-red-700 fp:font-medium",children:"Payment Failed"}),e.jsx("p",{className:"fp:text-[12px] fp:text-red-600 fp:mt-1",children:Te})]}),e.jsx("button",{onClick:()=>Ge(""),className:"fp:text-red-400 fp:hover:text-red-600",children:e.jsx("svg",{className:"fp:w-4 fp:h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-4 fp:space-y-4",children:[e.jsx("div",{children:e.jsx(Yi,{value:De,onChange:je=>Le(je),minDate:Z?void 0:Se,label:"Select Payment Date",fullWidth:!0,disabled:Z})}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-2 ",children:[e.jsx("span",{className:"fp:text-[15px] fp:font-medium fp:text-[#222222]",children:"Tenure"}),e.jsx("div",{className:"fp:w-full fp:flex fp:space-x-4 ",children:ge&&ge.length>0?ge.map((je,Xe)=>e.jsxs("button",{type:"button",className:`fp:py-1 fp:px-6 fp:border-[] fp:rounded-2xl fp:text-[14px] fp:font-medium fp:focus:outline-none fp:transition-colors fp:duration-150 ${V===Xe?"fp:border-[#16558B] fp:bg-[#E6F0FA] fp:text-[#16558B]":"fp:border-[#D0D0D0] fp:text-gray-700 fp:bg-white"}`,onClick:()=>{se(Xe)},children:[je.tenureValue," ",je.tenureUnit]},Xe)):e.jsx("span",{className:"fp:py-1 fp:px-6 fp:border-2 fp:rounded-2xl fp:text-[14px] fp:border-[#D0D0D0] fp:text-gray-700 fp:font-medium",children:"No tenure available"})})]}),!Z&&e.jsxs("span",{className:"fp:text-[12px] fp:font-medium fp:text-green-600 fp:text-wrap",children:["₹",pt(F)," will be processed via Fundly Credit — a loan will be set up in retailer's account."]}),e.jsxs("div",{className:"fp:text-[12px] fp:w-full fp:border fp:p-4 fp:space-y-3 fp:rounded-2xl fp:flex fp:flex-col fp:border-[#E8EEF3] ",children:[e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Due date"}),e.jsx("label",{className:"fp:font-medium",children:At?.lastRepaymentDate?ni(At.lastRepaymentDate):"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"ROI (Annualised)"}),e.jsx("label",{className:"fp:font-medium",children:At?.normalInterestRate!=null?`${At.normalInterestRate}%`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Interest/₹ 10,000/day"}),e.jsx("label",{className:"fp:font-medium",children:At?.interestPerDay!=null?`₹${At.interestPerDay}`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Penal Charges"}),e.jsx("label",{className:"fp:font-medium",children:At?.penalInterestRate!=null?`${At.penalInterestRate}% p.a`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Processing Fee"}),e.jsx("label",{className:"fp:font-medium",children:At?.processingFeeExclGst!=null?`₹${Number(At.processingFeeExclGst).toLocaleString("en-IN")}`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"APR"}),e.jsx("label",{className:"fp:font-medium",children:At?.apr!=null?`${At.apr}%`:"—"})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsx("label",{className:"fp:text-gray-700",children:"Net Disbursed Amount"}),e.jsx("label",{className:"fp:font-medium",children:At?.creditedAmount!=null?`₹${Number(At.creditedAmount).toLocaleString("en-IN")}`:"—"})]})]}),(U==="FUNDLY_COLLECT_APP"||U==="FUNDLY_QR_COLLECT_APP"||U==="FUNDLY_QR_WEB"||U==="FUNDLY_TRADE")&&e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-4 fp:border-2 fp:border-[#E8EEF3] fp:mt-2 fp:rounded-2xl fp:p-3",children:[e.jsx("label",{className:"fp:font-medium fp:text-[15px]",children:"Retailer Verification"}),e.jsxs("div",{className:"fp:w-full fp:flex fp:space-x-2 fp:justify-between",children:[e.jsx("div",{className:"fp:flex fp:border-2 fp:rounded-lg fp:px-1 fp:space-x-2 ",children:xe.map((je,Xe)=>e.jsx("input",{type:"text",value:je,maxLength:1,placeholder:"●",ref:bt=>{Ze.current[Xe]=bt},onChange:bt=>Ss(bt.target.value,Xe),onKeyDown:bt=>Ns(bt,Xe),className:"fp:w-7 fp:h-8 fp:text-center fp:text-[16px] fp:outline-none"},Xe))}),e.jsxs("button",{onClick:Gs,disabled:he==="countdown",className:`fp:text-white fp:text-[12px] fp:px-7 fp:rounded-lg ${he==="resend"?"fp:bg-gray-500":"fp:bg-[#16558B]"}`,children:[he==="idle"&&"Get OTP",he==="countdown"&&`${We}s`,he==="resend"&&"Resend"]})]}),Re?e.jsxs("div",{className:"fp:w-full fp:bg-red-50 fp:border fp:border-red-200 fp:rounded-lg fp:p-2 fp:flex fp:items-start fp:space-x-2",children:[e.jsx("svg",{className:"fp:w-4 fp:h-4 fp:text-red-500 fp:flex-shrink-0 fp:mt-0.5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("p",{className:"fp:text-[11px] fp:text-red-700",children:Re})]}):e.jsxs("label",{className:"fp:text-[13px] fp:flex fp:text-center fp:items-center fp:text-[#16558B]",children:[e.jsx("img",{src:we.info,className:"fp:w-4 fp:h-4 fp:mr-1"}),he==="idle"?"OTP will be sent to the retailer for consent.":"An OTP has been sent to the retailer for consent."]})]}),at&&e.jsx("div",{ref:xt,className:"fp:text-[12px] fp:text-gray-600 fp:leading-relaxed fp:select-none",dangerouslySetInnerHTML:{__html:at}}),Z&&e.jsxs("label",{className:"fp:flex fp:items-start fp:space-x-2 fp:cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:ht,onChange:je=>{const Xe=je.target.checked;rt(Xe),Xe&&Oe()},className:"fp:mt-0.5 fp:w-4 fp:h-4 fp:flex-shrink-0 fp:accent-[#16558B]"}),e.jsxs("span",{className:"fp:text-[12px] fp:text-gray-700",children:["I agree to the loan terms and accept the"," ",e.jsx("span",{className:"fp:text-[#16558B] fp:underline fp:cursor-pointer",onClick:je=>{je.preventDefault(),Oe()},children:"Key Fact Statement (KFS)"})]})]}),lt&&e.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."}),e.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
609
609
  ${Zt||ye?"fp:bg-gray-400 fp:text-white fp:cursor-not-allowed":"fp:bg-[#16558B] fp:text-white"}`,onClick:()=>{!Zt&&!ye&&Ft()},disabled:Zt||ye,children:ye?"Processing...":et})]})]}),Ct&&Pe&&Op.createPortal(e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,zIndex:99999,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},onClick:()=>Tt(!1),children:e.jsxs("div",{style:{backgroundColor:"#fff",borderRadius:"16px",display:"flex",flexDirection:"column",width:"calc(100% - 40px)",height:"calc(100% - 80px)",maxWidth:"700px",overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.2)"},onClick:je=>je.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid #E8EEF3",fontFamily:"Poppins",flexShrink:0},children:[e.jsx("span",{style:{fontSize:"16px",fontWeight:600,color:"#222",fontFamily:"Poppins"},children:"Key Fact Statement"}),e.jsx("button",{onClick:()=>Tt(!1),style:{padding:"4px",background:"none",border:"none",cursor:"pointer"},children:e.jsx("img",{src:we.closingCross,style:{width:"20px",height:"20px"}})})]}),e.jsx("div",{style:{flex:1,overflow:"hidden"},children:e.jsx(C.Suspense,{fallback:e.jsx("div",{style:{padding:"20px",color:"#666",fontFamily:"Poppins"},children:"Loading..."}),children:e.jsx(St,{fileUrl:Pe})})})]})}),document.body),e.jsxs(gs,{open:ve,onClose:()=>ke(!1),children:[e.jsx(Is,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center",children:[e.jsx("img",{src:we.Gateway,className:"fp:w-15 fp:h-15"}),e.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?"})]})}),e.jsx(Ls,{children:e.jsxs("div",{className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[e.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:()=>{ke(!1),ce()},children:"Exit"}),e.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:()=>ke(!1),children:"Continue"})]})})]})]})},qf=({open:u,onClose:o})=>{const{distributorName:A,chemistName:I,paymentType:a,paymentInvoice:P,invoices:O,payableValue:k,salesmanId:R,salesmanPhoneNumber:F,distributorIdnum:J,chemistId:z,leadId:G,payerMobileNumber:X,payerUuid:ee}=ms(),Y=()=>{o()},[U,q]=C.useState(""),[be,Ne]=C.useState(!1),[H,ie]=C.useState(""),[me,Ce]=C.useState(!1),[ge,V]=C.useState(5),[se,ue]=C.useState(""),Ae=C.useRef(null),ve=C.useRef(null);C.useEffect(()=>{u||(q(""),ie(""),Ce(!1),V(5),Ae.current&&clearTimeout(Ae.current),ve.current&&clearInterval(ve.current))},[u]);const ke=()=>{V(5),Ae.current&&clearTimeout(Ae.current),ve.current&&clearInterval(ve.current);let Le=5;ve.current=setInterval(()=>{Le--,V(Le),Le<=0&&ve.current&&clearInterval(ve.current)},1e3),Ae.current=setTimeout(async()=>{await Mt.navigateHome()},5e3)},ce=async()=>{Ce(!0),ie("");const Le={paymentMode:"PAYMENT_LINK",paymentDate:new Date().toISOString(),paymentType:a,paidAmount:k,distributorCode:J,salesmanId:R,salesmanPhoneNumber:F?.trim()||void 0,invoiceCount:P?.length||O?.length||0,chemistName:I||void 0,distributorName:A||void 0,mobileNumber:X||void 0,uuid:ee||null};z&&z.trim()!==""?Le.chemistBusinessId=z:G&&G.trim()!==""&&(Le.leadId=G),a==="INVOICE_COLLECT"?Le.paymentInvoice=P:a==="DIRECT_COLLECT"&&(Le.invoiceIds=O),X&&(Le.payerMobileNumber=X);try{const xe=await dn(Le),Be=xe.data||xe;ue(Be.chemistCode||""),Be?.link?(q(Be.link),ie("")):(q(""),ie("Failed to generate payment link. Please try again."),ke())}catch(xe){q("");const Be=xe?.response?.data?.errorResponse?.errorMessage||xe?.response?.data?.errorMessage||xe?.response?.data?.errorResponse?.errorDesc||xe?.response?.data?.errorDesc||xe?.response?.data?.message||xe?.message||"Failed to generate payment link. Please try again.";ie(Be),ke()}finally{Ce(!1)}},[Me,Z]=C.useState(!1),Se=async()=>{if(U)try{await navigator.clipboard.writeText(U),Z(!0),setTimeout(()=>Z(!1),1500)}catch{}},De=async()=>{if(U){const Le=`Complete your payment:
610
610
 
611
611
  Amount: ₹${Number(k).toLocaleString("en-IN")}
@@ -662,7 +662,7 @@ Fundly Team`;await Mt.shareString(Le)}};return e.jsxs(ws,{open:u,onClose:Y,child
662
662
  .animate-spin-slow {
663
663
  animation: spin-slow 2s linear infinite;
664
664
  }
665
- `})]}),eu=({size:u=24,color:o="currentColor",className:A,style:I})=>e.jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:A,style:I,"aria-hidden":"true",children:e.jsx("path",{d:"M22 16.92V19.92C22.0011 20.1985 21.9441 20.4742 21.8325 20.7293C21.7209 20.9845 21.5573 21.2136 21.3521 21.4019C21.1468 21.5901 20.9046 21.7335 20.6407 21.8227C20.3769 21.9119 20.0974 21.9451 19.82 21.92C16.7428 21.5856 13.787 20.5341 11.19 18.85C8.77382 17.3147 6.72533 15.2662 5.18999 12.85C3.49997 10.2412 2.44824 7.27099 2.11999 4.18C2.095 3.90347 2.12787 3.62476 2.21649 3.36162C2.30512 3.09849 2.44756 2.85669 2.63476 2.65162C2.82196 2.44655 3.0498 2.28271 3.30379 2.17052C3.55777 2.05833 3.83233 2.00026 4.10999 2H7.10999C7.5953 1.99522 8.06579 2.16708 8.43376 2.48353C8.80173 2.79999 9.04207 3.23945 9.10999 3.72C9.23662 4.68007 9.47144 5.62273 9.80999 6.53C9.94454 6.88792 9.97366 7.27691 9.89384 7.65088C9.81401 8.02485 9.62892 8.36811 9.35999 8.64L8.08999 9.91C9.51355 12.4135 11.5864 14.4864 14.09 15.91L15.36 14.64C15.6319 14.3711 15.9751 14.186 16.3491 14.1062C16.7231 14.0263 17.1121 14.0555 17.47 14.19C18.3773 14.5286 19.3199 14.7634 20.28 14.89C20.7658 14.9585 21.2094 15.2032 21.5265 15.5775C21.8437 15.9518 22.0122 16.4296 22 16.92Z",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),tu=({size:u=24,color:o="currentColor",className:A,style:I})=>e.jsxs("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:A,style:I,"aria-hidden":"true",children:[e.jsx("path",{d:"M4 4H20C21.1 4 22 4.9 22 6V18C22 19.1 21.1 20 20 20H4C2.9 20 2 19.1 2 18V6C2 4.9 2.9 4 4 4Z",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M22 6L12 13L2 6",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Ur={PHONE:"+91-9892422528",EMAIL:"connect@fundly.ai"},is={FUNDLY_PAY:"FUNDLY_PAY",DYNAMIC_QR:"DYNAMIC_QR",STATIC_QR:"STATIC_QR",PAYMENT_LINK:"PAYMENT_LINK",CASH:"CASH",CHEQUE:"CHEQUE",UPI:"UPI",NETBANKING:"NETBANKING",BANK_TRANSFER:"BANK_TRANSFER"},us={FUNDLY_CUSTOMER_APP:"FUNDLY_CUSTOMER_APP",FUNDLY_COLLECT_APP:"FUNDLY_COLLECT_APP",FUNDLY_TRADE:"FUNDLY_TRADE",FUNDLY_MART:"FUNDLY_MART"},su=({open:u,onClose:o})=>{const A=I=>{navigator.clipboard.writeText(I)};return e.jsx(ws,{open:u,onClose:o,children:e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:px-8 fp:py-4 fp:space-y-4 fp:mt-2 fp:mb-12",children:[e.jsx("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-end",children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:o,alt:"Close"})}),e.jsx("img",{src:we.customerSup,className:"fp:w-14 fp:h-14",alt:"Support"}),e.jsxs("div",{className:"fp:flex fp:space-x-6 fp:items-center",children:[e.jsx(eu,{size:24,color:"#16558B"}),e.jsx("span",{className:"fp:font-semibold",children:Ur.PHONE}),e.jsx("img",{src:we.copy,className:"fp:w-5 fp:h-5 fp:cursor-pointer",onClick:()=>A(Ur.PHONE),alt:"Copy"})]}),e.jsxs("div",{className:"fp:flex fp:space-x-6 fp:items-center",children:[e.jsx(tu,{size:24,color:"#16558B"}),e.jsx("span",{className:"fp:font-semibold",children:Ur.EMAIL}),e.jsx("img",{src:we.copy,className:"fp:w-5 fp:h-5 fp:cursor-pointer",onClick:()=>A(Ur.EMAIL),alt:"Copy"})]})]})})},nu=({open:u,onClose:o,onConfirm:A})=>e.jsxs(gs,{open:u,onClose:o,children:[e.jsx(ln,{children:e.jsx("div",{className:"fp:w-full fp:flex fp:justify-end",children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:o,alt:"Close"})})}),e.jsx(Is,{children:e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center",children:[e.jsx("img",{src:we.paymentLeave,className:"fp:w-18 fp:h-18",alt:"Leave"}),e.jsx("span",{className:"fp:text-[18px] fp:text-wrap fp:font-bold fp:text-center",children:"Leave this page?"}),e.jsx("span",{className:"fp:text-[14px] fp:text-wrap fp:font-semibold fp:text-center fp:text-[#6D6D6D]",children:"Any unsaved payment details will be lost."})]})}),e.jsx(Ls,{children:e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[e.jsx("button",{className:"fp:flex-1 fp:w-[96px] fp:h-[48px] fp:border-2 fp:border-gray-400 fp:text-gray-400 fp:rounded-xl",onClick:A,children:"Yes, Leave"}),e.jsx("button",{className:"fp:flex-1 fp:w-[96px] fp:h-[48px] fp:bg-[#16558B] fp:text-white fp:rounded-xl",onClick:o,children:"No"})]})})]}),iu=()=>{const{partnerCredentials:u}=ms(),[o,A]=C.useState(null),[I,a]=C.useState(!1),[P,O]=C.useState(null);return{login:C.useCallback(async()=>{a(!0),O(null);try{if(!u)throw new Error("Partner credentials not provided");const R={loginType:"PARTNER",username:u.username,password:u.password},F=await bf(R);if(F?.accessToken){const J=F.accessToken;return Fo(J),A(J),J}throw new Error("No access token received")}catch(R){const F=R instanceof Error?R:new Error("Login failed");throw O(F),F}finally{a(!1)}},[u]),token:o,isLoading:I,error:P}},ru=u=>{const{setChemistId:o,setLeadId:A,setDistributorIdnum:I,setTypeOfApp:a,setPaymentInvoice:P,setPayableValue:O,setInvoices:k,setPaymentType:R,setSalesmanId:F,distributorIdnum:J,chemistId:z,leadId:G}=ms(),X=C.useRef(!1);C.useEffect(()=>{const ee=q=>{if(typeof q.data!="object"||q.data===null||q.source!==window||q.data?.source==="react-devtools-content-script"||q.source!==window||q.data?.source?.includes("react-devtools")||q.origin!==window.origin)return;const{source:be,distributorId:Ne,chemistId:H,paymentType:ie,payableAmount:me,invoices:Ce,paymentInvoice:ge,salesmanId:V}=q.data;Ne&&I(Ne),H&&o(H),be&&a(be),Array.isArray(ge)&&P(ge),me&&O(me),Array.isArray(Ce)&&k(Ce),ie&&R(ie),V&&F(V),X.current||(u(),X.current=!0)},Y=z&&z.trim()!=="",U=G&&G.trim()!=="";return J&&(Y||U)&&!X.current&&(u(),X.current=!0),window.addEventListener("message",ee),()=>window.removeEventListener("message",ee)},[u,o,A,I,a,P,O,k,R,F,J,z,G])},ou=u=>{const{distributorIdnum:o,typeOfApp:A,chemistId:I,leadId:a,payableValue:P,salesmanId:O,paymentType:k,setDistributorName:R,setChemistName:F,setPayerMobileNumber:J,setSalesmanPhoneNumber:z,setTenureMappings:G,setFiCode:X,setDrawdownRepaymentOption:ee,setCreditLimitData:Y,setPayerUuid:U}=ms(),[q,be]=C.useState([]),[Ne,H]=C.useState(null),[ie,me]=C.useState(null),[Ce,ge]=C.useState(null),[V,se]=C.useState(null),[ue,Ae]=C.useState(!0);return C.useEffect(()=>{u&&(async()=>{const ke={distributorBusinessId:o,source:A,...I&&I.trim()!==""&&{chemistBusinessId:I},...a&&a.trim()!==""&&{leadId:a},payableAmount:P,...O&&{salesmanId:O},...k&&{collectType:k}};try{const ce=await jf(ke);H(ce.bankDetails),ce.bankDetails&&(R(ce.bankDetails.distributorName||""),F(ce.bankDetails.chemistName||""),J(ce.bankDetails.mobileNumber||""),z(ce.bankDetails.salesmanPhoneNumber||""),ce.bankDetails.mobileNumber&&Jf(ce.bankDetails.mobileNumber).then(Se=>{Se&&U(Se)}));const Me=ce.paymentOption.find(Se=>Se.name==="FUNDLY_PAY");Me?.details?.tenureMappings&&G(Me.details.tenureMappings),me(Me?.details?.maxEligibleLimit??null),ge(Me?.details?.minEligibleLimit??null),se(Me?.reason??null),Me?.details?.fiCode&&X(Me.details.fiCode),Me?.details?.drawdownRepaymentOption&&ee(Me.details.drawdownRepaymentOption);const Z=ce.paymentOption.filter(Se=>Se.isActive).map(Se=>Se.name);if(be(Z),Me?.isActive&&ce.bankDetails?.chemistBusinessId)try{const Se=await Mf(ce.bankDetails.chemistBusinessId);Y(Se)}catch(Se){console.warn("Credit limit filter API failed:",Se),Y(null)}Ae(!1)}catch{Ae(!1)}})()},[u]),{paymentOptions:q,bankDetails:Ne,maxEligibleLimit:ie,minEligibleLimit:Ce,fundlyPayReason:V,loading:ue}};function n0(){const[u,o]=C.useState({activeDrawer:null,paymentData:null}),A=C.useCallback(k=>{o({activeDrawer:k,paymentData:null})},[]),I=C.useCallback(()=>{o({activeDrawer:null,paymentData:null})},[]),a=C.useCallback(k=>{o({activeDrawer:"SUCCESS",paymentData:k||null})},[]),P=C.useCallback(k=>{o({activeDrawer:"FAILURE",paymentData:k||null})},[]),O=C.useCallback(k=>u.activeDrawer===k,[u.activeDrawer]);return{activeDrawer:u.activeDrawer,paymentData:u.paymentData,openPaymentDrawer:A,closeDrawer:I,isDrawerOpen:O,handlePaymentSuccess:a,handlePaymentFailure:P,showFundlyPayDrawer:O("FUNDLY_PAY"),showUpiDrawer:O("UPI"),showDynamicQrDrawer:O("DYNAMIC_QR"),showStaticQrDrawer:O("STATIC_QR"),showPaymentLinkDrawer:O("PAYMENT_LINK"),showNetbankingDrawer:O("NETBANKING"),showCashDrawer:O("CASH"),showChequeDrawer:O("CHEQUE"),showBankTransferDrawer:O("BANK_TRANSFER"),showSuccessDrawer:O("SUCCESS"),showFailureDrawer:O("FAILURE")}}const au=({onPaymentCollected:u,onPaymentFailed:o})=>{const[A,I]=C.useState(!1),[a,P]=C.useState(!1),[O,k]=C.useState(!1),[R,F]=C.useState(null),{paymentData:J,openPaymentDrawer:z,closeDrawer:G,handlePaymentSuccess:X,handlePaymentFailure:ee,showFundlyPayDrawer:Y,showUpiDrawer:U,showDynamicQrDrawer:q,showStaticQrDrawer:be,showPaymentLinkDrawer:Ne,showNetbankingDrawer:H,showCashDrawer:ie,showChequeDrawer:me,showBankTransferDrawer:Ce,showSuccessDrawer:ge,showFailureDrawer:V}=n0(),[se,ue]=C.useState(!1),[Ae,ve]=C.useState(-1),[ke,ce]=C.useState(null),[Me,Z]=C.useState([]),[Se,De]=C.useState(null),[Le,xe]=C.useState(null),Be=C.useRef(!1),{distributorName:Ze,distributorIdnum:We,payableValue:$e,typeOfApp:he,transactionId:ne,showResultOnly:ye,successButtonText:qe,failureButtonText:lt,creditLimitData:Ue,paymentType:Te,paymentInvoice:Ge,chemistId:Re,leadId:Ve,salesmanId:et,payerMobileNumber:le,payerUuid:Ee,scanId:K,viewId:Ie,sessionId:Ye,erpId:it}=ms(),tt=C.useMemo(()=>({type:"collection",distributorId:We||"",chemistId:Re||void 0,leadId:Ve||void 0,invoices:Ge||[],paymentType:Te||"INVOICE_COLLECT",salesmanId:et||void 0,payerMobileNumber:le||void 0}),[We,Re,Ve,Ge,Te,et,le]),{login:ht,token:rt,error:at}=iu(),Lt=C.useCallback(async()=>{try{await ht(),F(null)}catch(re){const Oe=re instanceof Error?re.message:"Authentication failed. Please try again later.";F(Oe)}},[ht]);ru(Lt);const{paymentOptions:nt,bankDetails:Fe,maxEligibleLimit:Ct,minEligibleLimit:Tt,fundlyPayReason:St,loading:ft}=ou(rt);C.useEffect(()=>{if(!ye&&!ne){const re=new URLSearchParams(window.location.search);if((re.has("orderId")||re.has("transactionId"))&&!rt){const Pe=new URL(window.location.href);Pe.searchParams.delete("orderId"),Pe.searchParams.delete("transactionId"),window.history.replaceState({},"",Pe.toString())}}},[ye,rt,ne]),C.useEffect(()=>{if(R||at){const re=setTimeout(async()=>{await Mt.navigateHome()},1e4);return()=>clearTimeout(re)}},[R,at]),C.useEffect(()=>{const re=new URLSearchParams(window.location.search);(re.get("orderId")||re.get("transactionId"))&&rt&&!ye&&z("UPI")},[rt,ye,z]),C.useEffect(()=>{!ye||!ne||!rt||!ge&&!V&&!U&&z("UPI")},[ye,ne,rt,ge,V,U,z]),C.useEffect(()=>{he===us.FUNDLY_TRADE&&xs.setEnabled(!1)},[he]),C.useEffect(()=>{if(ye||ft||!rt||Be.current||nt.length===0)return;const re=he===us.FUNDLY_MART?"customer":he===us.FUNDLY_TRADE?"internal_user":et&&et>0?"salesman":Ve&&Ve.trim()!==""?"guest":"retailer";if((re==="customer"||re==="internal_user"||re==="guest")&&!Ee)return;Be.current=!0,Ee&&xs.setUserIdentity(Ee);const Pe=()=>{const Zt=navigator.userAgent.toLowerCase();return Zt.includes("android")?"android":Zt.includes("iphone")||Zt.includes("ipad")||Zt.includes("ipod")?"ios":"web"},xt=()=>he===us.FUNDLY_COLLECT_APP?"collect_app":he===us.FUNDLY_CUSTOMER_APP?"customer_app":he==="FUNDLY_QR_WEB"?"web":he===us.FUNDLY_MART?"fundly_mart":he===us.FUNDLY_TRADE?"fundly_trade":"external_app",yt=()=>he===us.FUNDLY_COLLECT_APP?"collect_app":he===us.FUNDLY_CUSTOMER_APP?"customer_app":null,Ft=()=>he==="FUNDLY_QR_WEB"?"invoice_qr":Te==="INVOICE_COLLECT"?"invoice_pay_page":Te==="DIRECT_COLLECT"?"direct_pay_page":"invoice_qr",Ss=Ge?.map(Zt=>Zt.invoiceId?.toString()||Zt.invoiceNumber?.toString()).filter(Boolean)||null,Ns=Ye||`sdk_session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,Gs={scan_id:K||null,view_id:Ie||null,invoice_id:Ss,supplier_id:We?.toString()||"",erp_id:it||null,business_id:Re||null,salesman_id:et?.toString()||null,user_type:re,session_id:Ns,scan_channel:yt(),scan_origin:Te==="INVOICE_COLLECT"?"invoice":null,device_type:Pe(),payment_type:Te==="INVOICE_COLLECT"?"invoice_pay":"direct_pay",payment_sdk_entry_point:Ft(),payment_options:nt,default_payment_option:null,payment_amount:Number($e)||0,is_payment_enabled:nt.length>0,status:"success",failure_reason:null,error_code:null,error_description:null,failure_stage:null,sdk_version:"1.4.0-beta.8",app_context:xt(),app_version:"1.4.0-beta.8",mobile_number:le||null,uuid:Ee||null};xs.trackPaymentSDKLaunched(Gs)},[ft,rt,ye,nt,Ee,We,Re,Ve,et,$e,Te,Ge,he,K,Ie,Ye,it]);const ut=async()=>{I(!1),await Mt.navigateHome()},st=re=>{if(!re?.productRules||!Array.isArray(re.productRules))return{tenureMappings:[],repaymentOption:null,disbursementAccount:null};const Oe=Te==="INVOICE_COLLECT"?"YES":"NO",xt=re.productRules.find(yt=>yt.isInvoiceRequired===Oe&&yt.disbursementAccount==="SUPPLIER")||re.productRules[0];return{tenureMappings:xt?.tenureMappings||[],repaymentOption:xt?.repaymentOption||null,disbursementAccount:xt?.disbursementAccount||null}};return R||at?e.jsx("div",{style:{fontFamily:"Poppins"},className:"fp:relative fp:w-full fp:h-screen fp:flex fp:items-center fp:justify-center fp:px-4 fp:bg-[#F8FCFF]",children:e.jsxs("div",{className:"fp:w-full fp:max-w-md fp:bg-white fp:border fp:border-red-100 fp:rounded-2xl fp:p-8 fp:text-center fp:shadow-lg",children:[e.jsx("div",{className:"fp:w-16 fp:h-16 fp:mx-auto fp:mb-4 fp:bg-red-50 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:e.jsx("svg",{className:"fp:w-8 fp:h-8 fp:text-red-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h3",{className:"fp:text-[20px] fp:font-semibold fp:text-gray-800 fp:mb-3",children:"Authentication Failed"}),e.jsx("p",{className:"fp:text-[14px] fp:text-gray-600 fp:mb-4",children:R||at?.message||"We're unable to authenticate your session at the moment. Please try again later."}),e.jsx("p",{className:"fp:text-[12px] fp:text-gray-500",children:"This window will close automatically in a few seconds..."})]})}):ft?e.jsx($f,{}):ye?e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:relative fp:w-full fp:h-screen fp:flex fp:items-center fp:justify-center fp:bg-[#F8FCFF]",children:[e.jsx(Oo,{open:ge,onClose:()=>{G(),u&&J&&u(J)},paymentData:J,buttonText:qe}),e.jsx(Po,{open:V,onClose:()=>{G(),o&&J&&o(J)},paymentData:J,buttonText:lt}),e.jsx(Tl,{open:U,onClose:()=>G(),onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}})]}):e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:relative fp:w-full fp:h-screen fp:pt-10 fp:flex fp:flex-col fp:px-4 fp:bg-[#F8FCFF] fp:overflow-x-hidden",children:[e.jsx("div",{className:"fp:w-full fp:h-10 fp:flex fp:items-center fp:space-x-3",children:e.jsx("img",{src:we.backButton,alt:"Back",className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>I(!0)})}),e.jsxs("div",{className:"fp:w-full fp:items-center fp:text-center fp:justify-between fp:flex ",children:[e.jsx("h1",{className:"fp:font-medium fp:text-[20px] fp:text-[#222222]",children:"Payment Options"}),e.jsxs("label",{className:"fp:flex fp:items-center fp:text-[14px] fp:cursor-pointer",onClick:()=>k(!0),children:[e.jsx("img",{src:we.QuestionMark,className:"fp:w-4 fp:h-4 fp:mr-1"}),"Get Help"]})]}),e.jsx("div",{className:"fp:flex-1 fp:overflow-y-auto fp:mb-12 fp:mt-2",children:he==="FUNDLY_CUSTOMER_APP"&&!Fe?e.jsx("div",{className:"fp:w-full fp:h-full fp:flex fp:items-center fp:justify-center",children:e.jsxs("div",{className:"fp:w-full fp:max-w-md fp:bg-white fp:border fp:border-gray-200 fp:rounded-2xl fp:p-8 fp:text-center fp:shadow-sm",children:[e.jsx("div",{className:"fp:w-16 fp:h-16 fp:mx-auto fp:mb-4 fp:bg-gray-100 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:e.jsx("svg",{className:"fp:w-8 fp:h-8 fp:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h3",{className:"fp:text-[18px] fp:font-semibold fp:text-gray-800 fp:mb-2",children:"Bank Details Not Available"}),e.jsx("p",{className:"fp:text-[14px] fp:text-gray-500",children:"We couldn't find bank details for this distributor. Please contact support for assistance."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:rounded-xl fp:p-4 fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsxs("div",{className:"fp:flex fp:justify-between fp:items-start",children:[e.jsxs("div",{className:"fp:flex fp:flex-col fp:flex-1",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"Collect For"}),e.jsx("label",{className:"fp:font-semibold fp:text-[16px] fp:text-[#222222]",children:Ze})]}),e.jsxs("div",{className:"fp:flex fp:flex-col fp:items-end fp:flex-shrink-0",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400 fp:text-right",children:"Collection Amount"}),e.jsxs("label",{className:"fp:font-semibold fp:text-[16px] fp:text-[#222222]",children:["₹",pt($e)]})]})]}),(he==="FUNDLY_CUSTOMER_APP"||he==="FUNDLY_QR_WEB")&&Fe&&e.jsxs("div",{className:"fp:w-full fp:mt-2",children:[e.jsxs("label",{className:"fp:cursor-pointer fp:select-none fp:text-[#16558B] fp:font-medium fp:text-[12px]",onClick:()=>P(re=>!re),children:["Bank Details ",a?"▲":"▼"]}),a&&e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-3 fp:mt-2",children:[e.jsxs("div",{className:"fp:flex fp:flex-col ",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"Account Holder Name"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:Fe.accountName})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-1",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"Account Number"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:Fe.accountNumber})]}),e.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-1",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"IFSC Code"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:Fe.ifsc})]})]})]})]})]}),nt.includes(is.FUNDLY_PAY)&&(()=>{const re=Number($e??0),Oe=Tt??1e3,Pe=Ct??null;let xt=null,yt=!1;re<Oe?(xt=`Fundly Pay not available below ₹${Oe.toLocaleString("en-IN")} payment.`,yt=!0):Pe!==null&&re>Pe?(xt=`Max Eligible Amount: ₹${pt(Pe)}`,yt=!0):St&&(xt=St);let Ft=[],Ss=0;Ue?.subLimits&&Array.isArray(Ue.subLimits)&&(Ft=Ue.subLimits.filter(At=>At.expired===!1),Ft.sort((At,hs)=>{const pn=At.maxEligibleAmount||At.availableLimit||0;return(hs.maxEligibleAmount||hs.availableLimit||0)-pn}),Ft.length>0&&(Ss=Math.max(...Ft.map(At=>At.maxEligibleAmount||At.availableLimit||0))));const Ns=Ft.length>1,Gs=Ft.length===1,Zt=Ft.length===0;return e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-6",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Preferred Payment"}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-2",children:[e.jsxs("div",{className:`fp:w-full fp:border fp:border-gray-100 ${yt?"fp:bg-[#efefef]":"fp:bg-white"} ${xt||Ns&&se||Gs?"fp:rounded-t-xl":"fp:rounded-xl"} ${yt?"":"fp:cursor-pointer fp:hover:shadow-2xs"} fp:p-4 fp:flex fp:items-center fp:justify-between`,onClick:()=>{if(!yt)if(Ns)ue(!se);else if(Gs){ve(0),ce(Ft[0].fiCode);const At=st(Ft[0]);Z(At.tenureMappings),De(At.repaymentOption),xe(At.disbursementAccount),z("FUNDLY_PAY")}else z("FUNDLY_PAY")},children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.logo,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:cursor-pointer",children:"Fundly Pay"}),e.jsxs("div",{className:"fp:flex fp:items-center fp:bg-[#34A877] fp:py-1 fp:px-3 fp:rounded-4xl",children:[e.jsx("img",{src:we.primary,className:"fp:w-3 fp:h-3"}),e.jsx("label",{className:"fp:text-[10px] fp:font-medium fp:text-white",children:"1 Click Payment"})]})]}),e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[!yt&&Ns&&e.jsx("svg",{className:`fp:w-5 fp:h-5 fp:text-[#16558B] fp:transition-transform fp:duration-200 ${se?"fp:rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",d:"M19 9l-7 7-7-7"})}),!yt&&!Ns&&e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),!yt&&Gs&&e.jsx("div",{className:"fp:w-full fp:bg-[#E6F7EF] fp:flex fp:p-2 fp:text-[#34A877] fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{className:"fp:text-[10px] fp:font-medium",children:["Max Eligible Amount:"," ",e.jsxs("span",{className:"fp:font-bold",children:["₹",pt(Ft[0].maxEligibleAmount||Ft[0].availableLimit||0)]})]})}),!yt&&Ns&&!se&&e.jsx("div",{className:"fp:w-[95%] fp:m-auto fp:bg-[#E6F7EF] fp:flex fp:p-2 fp:text-[#34A877] fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{className:"fp:text-[10px] fp:font-medium",children:["Max Eligible Amount:"," ",e.jsxs("span",{className:"fp:font-bold",children:["₹",pt(Ss)]})]})}),!yt&&Ns&&se&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fp:w-full fp:bg-white fp:border-x fp:border-gray-100 fp:rounded-b-xl fp:px-3 fp:pt-3 fp:pb-2 fp:flex fp:flex-col fp:space-y-2.5",children:Ft.map((At,hs)=>{const pn=At.maxEligibleAmount||At.availableLimit||0,wt=pn<re;return e.jsx("button",{type:"button",disabled:wt,className:`fp:w-full fp:text-left fp:focus:outline-none fp:transition-all fp:duration-150 ${wt?"fp:cursor-not-allowed fp:opacity-50":Ae===hs?"fp:bg-[#EBF4FA]":"fp:bg-white fp:hover:border-[#16558B] fp:cursor-pointer"}`,style:{fontFamily:"Poppins",paddingTop:"10px",paddingLeft:"10px",paddingBottom:"10px",paddingRight:"16px",borderRadius:"8px",borderWidth:"0.87px",borderStyle:"solid",borderColor:wt?"#E0E0E0":Ae===hs?"#C5DBED":"#E8EEF3",height:"35px",display:"flex",alignItems:"center"},onClick:()=>{if(!wt){ve(hs),ce(At.fiCode);const Bs=st(At);Z(Bs.tenureMappings),De(Bs.repaymentOption),xe(Bs.disbursementAccount),ue(!1),z("FUNDLY_PAY")}},children:e.jsxs("div",{className:"fp:flex fp:justify-between fp:items-center fp:w-full",style:{lineHeight:"24px"},children:[e.jsx("span",{className:`fp:font-medium ${wt?"fp:text-gray-400":"fp:text-[#16558B]"}`,style:{fontSize:"12px",letterSpacing:"0px",textTransform:"capitalize"},children:At.fiCode?.toLowerCase()}),e.jsxs("span",{className:`fp:text-[12px] fp:font-semibold ${wt?"fp:text-gray-400":"fp:text-[#000000]"}`,style:{letterSpacing:"0px",lineHeight:"100%"},children:["₹ ",pt(pn)]})]})},hs)})}),e.jsx("div",{className:"fp:w-[95%] fp:m-auto fp:bg-[#E6F7EF] fp:flex fp:p-2 fp:text-[#34A877] fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{style:{fontFamily:"Poppins"},children:[e.jsxs("span",{className:"fp:text-[10px] fp:font-medium",children:["Max Eligible Amount:"," "]}),e.jsxs("span",{className:"fp:font-bold fp:text-[10px]",children:["₹",pt(Ss)]})]})})]}),xt&&Zt&&e.jsx("div",{className:"fp:w-full fp:bg-red-50 fp:flex fp:p-2 fp:text-red-700 fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsx("label",{className:"fp:text-[11px] fp:ml-2",children:xt})}),!xt&&Zt&&Pe!==null&&e.jsx("div",{className:"fp:w-full fp:bg-green-50 fp:flex fp:p-2 fp:text-green-700 fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{className:"fp:text-[11px] fp:ml-2",children:["Max Eligible Amount:"," ",e.jsxs("span",{className:"fp:font-medium",children:["₹",pt(Pe)]})]})})]})]})})(),nt.includes(is.UPI)&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.upi,className:"fp:h-[20px]",alt:"UPI Logo"}),e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Pay by UPI"})]}),e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("UPI"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.upiIcon,className:"fp:w-[32px] fp:h-[32px]",alt:"UPI"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"UPI"}),e.jsx("div",{className:"fp:flex fp:items-center fp:bg-green-50 fp:rounded-4xl fp:py-1 fp:px-2",children:e.jsx("label",{className:"fp:text-[10px] fp:text-green-700 fp:font-medium",children:"₹ 0 charges"})})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),nt.includes(is.NETBANKING)&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Netbanking"}),e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("NETBANKING"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.scanqrIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Netbanking"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),(nt.includes(is.BANK_TRANSFER)||nt.includes(is.DYNAMIC_QR)&&!(he===us.FUNDLY_CUSTOMER_APP&&nt.includes(is.PAYMENT_LINK))||nt.includes(is.PAYMENT_LINK)&&(he===us.FUNDLY_COLLECT_APP||he===us.FUNDLY_TRADE))&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Online Payment Options"}),nt.includes(is.DYNAMIC_QR)&&!(he===us.FUNDLY_CUSTOMER_APP&&nt.includes(is.PAYMENT_LINK))&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("DYNAMIC_QR"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.generateqrIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium",children:"Generate QR"}),e.jsx("div",{className:"fp:flex fp:items-center fp:bg-green-50 fp:rounded-4xl fp:py-1 fp:px-2",children:e.jsx("label",{className:"fp:text-[10px] fp:text-green-700 fp:font-medium",children:"₹ 0 charges"})})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.PAYMENT_LINK)&&(he===us.FUNDLY_COLLECT_APP||he===us.FUNDLY_TRADE)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:mt-2 fp:flex fp:items-center fp:justify-between",onClick:()=>z("PAYMENT_LINK"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.paymentlinkIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium",children:"Payment Link"}),e.jsx("div",{className:"fp:flex fp:items-center fp:bg-green-50 fp:rounded-4xl fp:py-1 fp:px-2",children:e.jsx("label",{className:"fp:text-[10px] fp:text-green-700 fp:font-medium",children:"₹ 0 charges"})})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.BANK_TRANSFER)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:mt-2 fp:flex fp:items-center fp:justify-between",onClick:()=>z("BANK_TRANSFER"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.bankTransferIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Bank Transfer"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),(nt.includes(is.CASH)||nt.includes(is.CHEQUE)||nt.includes(is.STATIC_QR))&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"More Payment Options"}),nt.includes(is.STATIC_QR)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("STATIC_QR"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.scanqrIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Scan QR"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.CASH)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("CASH"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.cashIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Cash"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.CHEQUE)&&e.jsxs("div",{className:"fp:w-full fp:bg-white fp:border fp:border-gray-100 fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:mt-2 fp:flex fp:items-center fp:justify-between",onClick:()=>z("CHEQUE"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.chequeIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Cheque"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]})]})}),e.jsx(Hf,{open:be,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(Tl,{open:U,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}}),e.jsx(Kf,{open:H,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}}),e.jsx(e0,{open:ie,metadata:tt,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(t0,{open:me,metadata:tt,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(s0,{open:Ce,metadata:tt,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(Zf,{open:Y,onClose:()=>{G()},onPaymentCollected:re=>{X(re)},selectedLenderIdx:Ae,selectedLenderFiCode:ke,selectedLenderTenureMappings:Me,selectedLenderRepaymentOption:Se,selectedLenderDisbursementAccount:Le}),e.jsx(qf,{open:Ne,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:()=>{X()}}),e.jsx(Vf,{open:q,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}}),e.jsx(Oo,{open:ge,onClose:()=>G(),paymentData:J,buttonText:qe}),e.jsx(Po,{open:V,onClose:()=>G(),paymentData:J,buttonText:lt}),e.jsx(nu,{open:A,onClose:()=>I(!1),onConfirm:ut}),e.jsx(su,{open:O,onClose:()=>k(!1)}),e.jsxs("div",{className:"fp:absolute fp:bottom-0 fp:left-0 fp:w-full fp:flex fp:flex-col fp:items-center fp:justify-center fp:py-2 fp:bg-[#F8FCFF]",children:[e.jsx("span",{className:"fp:text-[10px] fp:text-[#9CA3AF] fp:font-medium",children:"Powered by"}),e.jsx("a",{href:"https://fundly.ai",target:"_blank",rel:"noopener noreferrer",className:"fp:text-[12px] fp:text-[#16558B] fp:font-bold fp:no-underline",children:"Fundly.ai"})]})]})},i0=C.createContext(void 0);function r0({children:u,initialValues:o}){Hr(o?.environment??"production");const[A,I]=C.useState(o?.partnerCredentials||null),[a,P]=C.useState(o?.businessId||null),[O,k]=C.useState(o?.businessName||null),[R,F]=C.useState(null),[J,z]=C.useState([]),[G,X]=C.useState([]),[ee,Y]=C.useState([]),[U,q]=C.useState(0),[be,Ne]=C.useState("FULL"),[H,ie]=C.useState(null),[me,Ce]=C.useState(o?.onPaymentComplete?()=>o.onPaymentComplete:void 0),[ge,V]=C.useState(o?.onNavigateHome?()=>o.onNavigateHome:void 0),[se,ue]=C.useState(o?.sessionId||null),[Ae,ve]=C.useState(o?.erpId||null);C.useEffect(()=>{const ce=Xr(),Me=Gr();ce&&xs.configure({enabled:!0,clevertap:{accountId:ce,region:Me}})},[]);const ke={partnerCredentials:A,setPartnerCredentials:I,businessId:a,setBusinessId:P,businessName:O,setBusinessName:k,selectedLender:R,setSelectedLender:F,lenderList:J,setLenderList:z,selectedLoans:G,setSelectedLoans:X,loanList:ee,setLoanList:Y,totalAmount:U,setTotalAmount:q,repaymentType:be,setRepaymentType:Ne,redirectionUrl:H,setRedirectionUrl:ie,onPaymentComplete:me,setOnPaymentComplete:Ce,onNavigateHome:ge,setOnNavigateHome:V,sessionId:se,setSessionId:ue,erpId:Ae,setErpId:ve};return e.jsx(i0.Provider,{value:ke,children:u})}function Hi(){const u=C.useContext(i0);if(!u)throw new Error("useRepaymentContext must be used within a RepaymentProvider");return u}const o0=C.createContext(void 0);function zo({children:u,initialValues:o}){Hr(o?.environment??"production");const[A,I]=C.useState(o?.partnerCredentials||null),[a,P]=C.useState(o?.businessId||null),[O,k]=C.useState(o?.businessName||null),[R,F]=C.useState([]),[J,z]=C.useState(null),[G,X]=C.useState(o?.filters||null),[ee,Y]=C.useState(o?.defaultTab||"all"),[U,q]=C.useState(1),[be,Ne]=C.useState(!0),[H,ie]=C.useState(!1),[me,Ce]=C.useState(o?.onNavigateHome?()=>o.onNavigateHome:void 0),[ge,V]=C.useState(o?.sessionId||null),[se,ue]=C.useState(o?.erpId||null);C.useEffect(()=>{const ve=Xr(),ke=Gr();ve&&xs.configure({enabled:!0,clevertap:{accountId:ve,region:ke}})},[]);const Ae={partnerCredentials:A,setPartnerCredentials:I,businessId:a,setBusinessId:P,businessName:O,setBusinessName:k,transactions:R,setTransactions:F,selectedTransaction:J,setSelectedTransaction:z,filter:G,setFilter:X,activeTab:ee,setActiveTab:Y,currentPage:U,setCurrentPage:q,hasMore:be,setHasMore:Ne,isLoading:H,setIsLoading:ie,onNavigateHome:me,setOnNavigateHome:Ce,sessionId:ge,setSessionId:V,erpId:se,setErpId:ue};return e.jsx(o0.Provider,{value:Ae,children:u})}function lu(){const u=C.useContext(o0);if(!u)throw new Error("useTransactionContext must be used within a TransactionProvider");return u}const Je=({className:u=""})=>e.jsx("div",{className:`fp:animate-pulse fp:bg-gray-200 fp:rounded ${u}`}),cu=[{label:"All",value:"all"},{label:"Success",value:"success"},{label:"Failure",value:"failed"},{label:"Pending",value:"pending"}],du=[{label:"Last 30 days",value:"30"},{label:"Last 60 days",value:"60"},{label:"Last 90 days",value:"90"},{label:"Custom date range",value:"custom"}],pu=[{label:"All",value:"all"},{label:"UPI",value:"UPI"},{label:"NEFT",value:"NEFT"},{label:"RTGS",value:"RTGS"},{label:"IMPS",value:"IMPS"}],fu=u=>{if(!u)return null;const o=new Date,A=new Date(o.getFullYear(),o.getMonth(),o.getDate()),I=Math.round((A.getTime()-u.from.getTime())/(1e3*60*60*24));return I>=29&&I<=31?"30":I>=59&&I<=61?"60":I>=89&&I<=91?"90":"custom"},uu=u=>{if(u==="custom")return;const o=Number(u),A=new Date,I=new Date;return I.setDate(I.getDate()-o),{from:I,to:A}},xu=({open:u,onClose:o,currentFilter:A,onApply:I})=>{const[a,P]=C.useState(["all"]),[O,k]=C.useState(null),[R,F]=C.useState(null),[J,z]=C.useState(null),[G,X]=C.useState(["all"]);C.useEffect(()=>{if(u){const H=A.statuses;P(H&&H.length>0?H:["all"]);const ie=A.paymentMethods;X(ie&&ie.length>0?ie:["all"]);const me=fu(A.dateRange);k(me),me==="custom"&&A.dateRange?(F(A.dateRange.from),z(A.dateRange.to)):(F(null),z(null))}},[u]);const ee=H=>{if(H==="all"){P(["all"]);return}P(ie=>{const me=ie.filter(Ce=>Ce!=="all");if(me.includes(H)){const Ce=me.filter(ge=>ge!==H);return Ce.length===0?["all"]:Ce}return[...me,H]})},Y=H=>{if(H==="all"){X(["all"]);return}X(ie=>{const me=ie.filter(Ce=>Ce!=="all");if(me.includes(H)){const Ce=me.filter(ge=>ge!==H);return Ce.length===0?["all"]:Ce}return[...me,H]})},U=()=>{P(["all"]),k(null),F(null),z(null),X(["all"])},q=()=>{const H={...A,statuses:a,paymentMethods:G};O&&O!=="custom"?H.dateRange=uu(O):O==="custom"&&R&&J?H.dateRange={from:R,to:J}:H.dateRange=void 0,I(H),o()},be=H=>{O===H?(k(null),F(null),z(null)):(k(H),H!=="custom"&&(F(null),z(null)))},Ne=H=>`fp:px-4 fp:py-2 fp:rounded-full fp:text-[13px] fp:font-medium fp:transition-colors ${H?"fp:bg-[#16558B] fp:text-white":"fp:border fp:border-[#D0D0D0] fp:text-[#222222] fp:bg-white"}`;return e.jsx(ws,{open:u,onClose:o,children:e.jsxs("div",{className:"fp:px-5 fp:pt-5 fp:pb-6",children:[e.jsx("div",{className:"fp:flex fp:justify-center fp:mb-4",children:e.jsx("div",{className:"fp:w-10 fp:h-1 fp:rounded-full fp:bg-[#D0D0D0]"})}),e.jsxs("div",{className:"fp:flex fp:items-center fp:gap-2.5 fp:mb-6",children:[e.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"#16558B",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})}),e.jsx("h2",{className:"fp:text-[18px] fp:font-semibold fp:text-[#222222]",children:"Apply filters"})]}),e.jsxs("div",{className:"fp:mb-5",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:mb-3",children:"Status"}),e.jsx("div",{className:"fp:flex fp:flex-wrap fp:gap-2",children:cu.map(H=>e.jsx("button",{className:Ne(a.includes(H.value)),onClick:()=>ee(H.value),children:H.label},H.value))})]}),e.jsxs("div",{className:"fp:mb-5",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:mb-3",children:"Date Range"}),e.jsx("div",{className:"fp:flex fp:flex-wrap fp:gap-2",children:du.map(H=>e.jsx("button",{className:Ne(O===H.value),onClick:()=>be(H.value),children:H.label},H.value))}),O==="custom"&&e.jsxs("div",{className:"fp:flex fp:gap-3 fp:mt-3",children:[e.jsx("div",{className:"fp:flex-1",children:e.jsx(Yi,{value:R,onChange:F,label:"From",placeholder:"Start date",fullWidth:!0})}),e.jsx("div",{className:"fp:flex-1",children:e.jsx(Yi,{value:J,onChange:z,minDate:R||void 0,label:"To",placeholder:"End date",fullWidth:!0})})]})]}),e.jsxs("div",{className:"fp:mb-6",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:mb-3",children:"Payment Mode"}),e.jsx("div",{className:"fp:flex fp:flex-wrap fp:gap-2",children:pu.map(H=>e.jsx("button",{className:Ne(G.includes(H.value)),onClick:()=>Y(H.value),children:H.label},H.value))})]}),e.jsxs("div",{className:"fp:flex fp:gap-3",children:[e.jsx("button",{onClick:U,className:"fp:flex-1 fp:py-3 fp:rounded-xl fp:border fp:border-[#16558B] fp:text-[#16558B] fp:font-semibold fp:text-[14px] fp:active:scale-[0.97] fp:transition-transform",children:"Clear All"}),e.jsx("button",{onClick:q,className:"fp:flex-1 fp:py-3 fp:rounded-xl fp:bg-[#16558B] fp:text-white fp:font-semibold fp:text-[14px] fp:active:scale-[0.97] fp:transition-transform",children:"Apply"})]})]})})},mu=({status:u})=>{switch(u.toUpperCase()){case"SUCCESS":return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{d:"M8 0.0996094C10.0945 0.101867 12.1029 0.934966 13.584 2.41602C15.065 3.89706 15.8981 5.90548 15.9004 8L15.8945 8.29297C15.8404 9.75276 15.382 11.1709 14.5684 12.3887C13.7003 13.6878 12.4669 14.7009 11.0234 15.2988C9.57995 15.8967 7.99139 16.0528 6.45898 15.748C4.92653 15.4432 3.5189 14.6908 2.41406 13.5859C1.30923 12.4811 0.556776 11.0735 0.251953 9.54102C-0.0528274 8.00861 0.10326 6.42005 0.701172 4.97656C1.29911 3.53309 2.31222 2.29968 3.61133 1.43164C4.82912 0.617965 6.24724 0.159629 7.70703 0.105469L8 0.0996094ZM10.334 2.36426C9.21945 1.90269 7.99273 1.78223 6.80957 2.01758C5.62646 2.253 4.53952 2.83353 3.68652 3.68652C2.83353 4.53952 2.253 5.62645 2.01758 6.80957C1.78223 7.99273 1.90269 9.21945 2.36426 10.334C2.82595 11.4486 3.60819 12.402 4.61133 13.0723C5.61439 13.7424 6.79368 14.0996 8 14.0996C9.61725 14.0978 11.168 13.4551 12.3115 12.3115C13.4551 11.168 14.0978 9.61725 14.0996 8L14.0957 7.77441C14.054 6.64712 13.7006 5.55177 13.0723 4.61133C12.402 3.60819 11.4486 2.82595 10.334 2.36426Z",fill:"#2FB551",stroke:"white",strokeWidth:"0.2"}),e.jsx("g",{transform:"translate(4.5, 5)",children:e.jsx("path",{d:"M5.91895 0.103516C6.03691 0.0926467 6.15642 0.105413 6.26953 0.140625C6.3824 0.175812 6.48733 0.232873 6.57812 0.308594C6.66904 0.384472 6.74396 0.478068 6.79883 0.583008C6.8537 0.687993 6.88803 0.802895 6.89844 0.920898C6.90882 1.03885 6.89501 1.1576 6.85938 1.27051C6.82373 1.38344 6.76666 1.48847 6.69043 1.5791H6.68945L3.35547 5.5791C3.27113 5.68031 3.16618 5.76248 3.04688 5.81836C2.92748 5.87424 2.79687 5.90243 2.66504 5.90234C2.5332 5.90226 2.40254 5.87342 2.2832 5.81738C2.16405 5.76135 2.05877 5.67939 1.97461 5.57812L0.308594 3.57812C0.233081 3.48748 0.175742 3.38313 0.140625 3.27051C0.105548 3.15793 0.0929033 3.03931 0.103516 2.92188C0.114206 2.80428 0.148246 2.68951 0.203125 2.58496C0.257993 2.48043 0.333141 2.38808 0.423828 2.3125C0.514465 2.23697 0.618817 2.17966 0.731445 2.14453C0.84418 2.10941 0.963459 2.09673 1.08105 2.10742C1.19848 2.11816 1.31258 2.15223 1.41699 2.20703C1.52132 2.26181 1.61396 2.33629 1.68945 2.42676H1.69043L2.58887 3.50391L2.66504 3.59668L2.74219 3.50391L5.30859 0.425781C5.38413 0.334582 5.4773 0.259367 5.58203 0.204102C5.6867 0.148897 5.80111 0.114394 5.91895 0.103516Z",fill:"#2FB551",stroke:"white",strokeWidth:"0.2"})})]})});case"FAILED":return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{d:"M8 0.75C12.0041 0.75 15.25 3.99594 15.25 8C15.25 12.0041 12.0041 15.25 8 15.25C3.99594 15.25 0.75 12.0041 0.75 8C0.75 3.99594 3.99594 0.75 8 0.75Z",stroke:"#E80000",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M9.88595 6.11719L6.11475 9.88842",stroke:"#E80000",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M6.11475 6.11719L9.88598 9.88842",stroke:"#E80000",strokeWidth:"1.5",strokeLinecap:"round"})]})});case"INITIATED":return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsx("svg",{width:"24",height:"24",viewBox:"-2 -1 16 17",fill:"none",children:e.jsx("path",{d:"M0.75 1.00098C0.750262 0.801579 0.97265 0.682461 1.13867 0.792969L10.3359 6.9248C10.4843 7.02376 10.4843 7.24186 10.3359 7.34082L1.13867 13.4727C0.972648 13.5832 0.750262 13.464 0.75 13.2646V1.00098Z",stroke:"#1E88E5",strokeWidth:"1.5"})})});case"PENDING":default:return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{d:"M8 0.0996094C10.0945 0.101867 12.1029 0.934966 13.584 2.41602C15.065 3.89706 15.8981 5.90548 15.9004 8L15.8945 8.29297C15.8404 9.75276 15.382 11.1709 14.5684 12.3887C13.7003 13.6878 12.4669 14.7009 11.0234 15.2988C9.57995 15.8967 7.99139 16.0528 6.45898 15.748C4.92653 15.4432 3.5189 14.6908 2.41406 13.5859C1.30923 12.4811 0.556776 11.0735 0.251953 9.54102C-0.0528275 8.00862 0.10326 6.42005 0.701172 4.97656C1.29911 3.53309 2.31222 2.29968 3.61133 1.43164C4.82912 0.617965 6.24724 0.159629 7.70703 0.105469L8 0.0996094ZM10.334 2.36426C9.21945 1.90269 7.99273 1.78223 6.80957 2.01758C5.62646 2.253 4.53952 2.83353 3.68652 3.68652C2.83353 4.53952 2.253 5.62646 2.01758 6.80957C1.78223 7.99273 1.90268 9.21945 2.36426 10.334C2.82595 11.4486 3.60819 12.402 4.61133 13.0723C5.61439 13.7424 6.79368 14.0996 8 14.0996C9.61725 14.0978 11.168 13.4551 12.3115 12.3115C13.4551 11.168 14.0978 9.61725 14.0996 8L14.0957 7.77441C14.054 6.64712 13.7006 5.55177 13.0723 4.61133C12.402 3.60819 11.4486 2.82595 10.334 2.36426Z",fill:"#FFA500",stroke:"white",strokeWidth:"0.2"}),e.jsx("path",{d:"M9.58325 10.4995L7.5404 8.9791C7.24263 8.80264 7 8.37804 7 8.03064V5",stroke:"#FFA500",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}},hu=({onNavigateBack:u,onViewTransaction:o})=>{const{businessId:A}=lu(),[I,a]=C.useState([]),[P,O]=C.useState(!0),[k,R]=C.useState(null),[F,J]=C.useState(0),[z,G]=C.useState(!1),[X,ee]=C.useState(0),[Y,U]=C.useState({}),[q,be]=C.useState(!1);C.useEffect(()=>{A&&Ne()},[A,F,Y]);const Ne=async()=>{if(!A){R("Business ID is required"),O(!1);return}try{O(!0),R(null);const ie=await Bf({businessId:A,filter:Y,page:F,size:10});a(F===0?ie.transactions:me=>[...me,...ie.transactions]),ee(ie.totalCount),G(ie.hasMore)}catch(ie){console.error("Error loading transactions:",ie);const me=ie?.response?.data?.errorMessage||ie?.response?.data?.message||ie?.message||"Failed to load transactions. Please try again.";R(me)}finally{O(!1)}},H=ie=>new Date(ie).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"});return P&&F===0?e.jsxs("div",{className:"fp:min-h-screen fp:bg-[#F8FCFF]",children:[e.jsxs("div",{className:"fp:bg-[#F8FCFF] fp:px-4 fp:pt-4 fp:pb-3",children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:justify-between fp:mb-3",children:[e.jsx(Je,{className:"fp:w-6 fp:h-6 fp:rounded-full"}),e.jsx(Je,{className:"fp:w-9 fp:h-9 fp:rounded-[10px]"})]}),e.jsx(Je,{className:"fp:w-40 fp:h-7 fp:rounded-lg"})]}),e.jsx("div",{className:"fp:px-4 fp:py-4 fp:space-y-3",children:[1,2,3,4,5].map(ie=>e.jsxs("div",{className:"fp:bg-white fp:rounded-[12px] fp:border fp:border-[#E8EEF8] fp:px-4 fp:py-3.5 fp:flex fp:items-center fp:gap-3",children:[e.jsx(Je,{className:"fp:w-8 fp:h-8 fp:rounded-full fp:flex-shrink-0"}),e.jsxs("div",{className:"fp:flex-1",children:[e.jsx(Je,{className:"fp:w-36 fp:h-3.5 fp:rounded fp:mb-2"}),e.jsx(Je,{className:"fp:w-28 fp:h-3 fp:rounded"})]}),e.jsx(Je,{className:"fp:w-16 fp:h-3.5 fp:rounded fp:flex-shrink-0"})]},ie))})]}):k?e.jsxs("div",{className:"fp:min-h-screen fp:bg-[#F8FCFF]",children:[e.jsxs("div",{className:"fp:bg-[#F8FCFF] fp:px-4 fp:pt-4 fp:pb-3",children:[e.jsx("button",{onClick:u,className:"fp:mb-3 fp:p-1 fp:-ml-1",children:e.jsx("img",{src:we.backButton,alt:"Back",className:"fp:w-6 fp:h-6"})}),e.jsx("h1",{className:"fp:text-2xl fp:font-bold fp:text-[#222222]",children:"Transactions"})]}),e.jsx("div",{className:"fp:flex fp:items-center fp:justify-center fp:min-h-[calc(100vh-80px)] fp:px-4",children:e.jsxs("div",{className:"fp:text-center fp:max-w-md",children:[e.jsx("div",{className:"fp:w-20 fp:h-20 fp:mx-auto fp:mb-4 fp:bg-red-100 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:e.jsx("svg",{className:"fp:w-10 fp:h-10 fp:text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h2",{className:"fp:text-lg fp:font-semibold fp:text-gray-900 fp:mb-2",children:"Failed to Load"}),e.jsx("p",{className:"fp:text-gray-600 fp:mb-6 fp:text-sm",children:k}),e.jsx("button",{onClick:()=>{J(0),Ne()},className:"fp:bg-[#16558B] fp:text-white fp:font-semibold fp:py-3 fp:px-6 fp:rounded-xl fp:transition-colors",children:"Try Again"})]})})]}):e.jsxs("div",{className:"fp:min-h-screen fp:bg-[#F8FCFF] fp:pb-10",children:[e.jsxs("div",{className:"fp:bg-[#F8FCFF] fp:px-4 fp:pt-4 fp:pb-3",children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:justify-between fp:mb-2",children:[e.jsx("button",{onClick:u,className:"fp:p-1 fp:-ml-1",children:e.jsx("img",{src:we.backButton,alt:"Back",className:"fp:w-6 fp:h-6"})}),e.jsx("button",{onClick:()=>be(!0),className:"fp:w-9 fp:h-9 fp:rounded-[10px] fp:bg-[#EAF2FF] fp:flex fp:items-center fp:justify-center",children:e.jsxs("svg",{className:"fp:w-5 fp:h-5 fp:text-[#16558B]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.8,children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6",strokeLinecap:"round"}),e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12",strokeLinecap:"round"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18",strokeLinecap:"round"}),e.jsx("circle",{cx:"8",cy:"6",r:"2",fill:"#16558B",stroke:"#16558B"}),e.jsx("circle",{cx:"16",cy:"12",r:"2",fill:"#16558B",stroke:"#16558B"}),e.jsx("circle",{cx:"10",cy:"18",r:"2",fill:"#16558B",stroke:"#16558B"})]})})]}),e.jsx("h1",{className:"fp:text-2xl fp:font-bold fp:text-[#222222]",children:"Transactions"})]}),e.jsx(xu,{open:q,onClose:()=>be(!1),currentFilter:Y,onApply:ie=>{U(ie),J(0),a([])}}),e.jsx("div",{className:"fp:px-4 fp:space-y-3",children:I.length===0&&!P?e.jsxs("div",{className:"fp:flex fp:flex-col fp:items-center fp:justify-center fp:py-20 fp:px-6",children:[e.jsx("div",{className:"fp:w-20 fp:h-20 fp:rounded-full fp:bg-[#D6E8FF] fp:flex fp:items-center fp:justify-center fp:mb-5",children:e.jsx("svg",{className:"fp:w-9 fp:h-9 fp:text-[#16558B]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),e.jsx("p",{className:"fp:text-[16px] fp:font-medium fp:text-[#222222] fp:mb-2",children:"No Transactions"}),e.jsx("p",{className:"fp:text-[13px] fp:font-normal fp:text-[#6D6D6D] fp:text-center fp:leading-5",children:"Your payment history will appear here once you make a transaction."})]}):e.jsxs(e.Fragment,{children:[I.map(ie=>e.jsxs("button",{onClick:()=>o(ie),className:"fp:w-full fp:bg-white fp:rounded-[12px] fp:border fp:border-[#E8EEF8] fp:px-4 fp:py-3.5 fp:flex fp:items-center fp:gap-3 fp:text-left fp:active:scale-[0.98] fp:transition-all",children:[e.jsx(mu,{status:ie.status}),e.jsxs("div",{className:"fp:flex-1 fp:min-w-0",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#16558B] fp:leading-[14px] fp:truncate",children:ie.name||ie.supplierName||ie.lenderName||"N/A"}),e.jsxs("p",{className:"fp:text-[12px] fp:font-normal fp:text-[#6D6D6D] fp:leading-[14px] fp:mt-1.5",children:[H(ie.date),"  •  ",ie.paymentMode]})]}),e.jsxs("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:leading-[14px] fp:flex-shrink-0",children:["₹",pt(ie.amount)]})]},ie.transactionId)),z&&e.jsx("div",{className:"fp:flex fp:justify-center fp:pt-2 fp:pb-4",children:e.jsx("button",{onClick:()=>J(F+1),disabled:P,className:"fp:text-sm fp:font-medium fp:text-[#16558B] fp:py-2 fp:px-6 fp:rounded-full fp:border fp:border-[#16558B] fp:disabled:opacity-50 fp:disabled:cursor-not-allowed fp:active:scale-95 fp:transition-transform",children:P?"Loading...":"Load More"})}),!z&&X>0&&e.jsxs("p",{className:"fp:text-center fp:text-xs fp:text-[#6D6D6D] fp:py-4",children:[X," transaction",X!==1?"s":""," total"]})]})})]})},Au=({open:u,onClose:o,transaction:A})=>{const I=C.useRef(null),[a,P]=C.useState(null),[O,k]=C.useState(!1),[R,F]=C.useState(null),[J,z]=C.useState([]),[G,X]=C.useState(!1),[ee,Y]=C.useState(!1),[U,q]=C.useState(""),be=async ne=>{const ye=ne.documentIds.flat().map(qe=>qe.documentId);if(ye.length!==0){Y(!0),q(ne.invoiceNumber),X(!0);try{const qe=await Pf(ye);z(Array.isArray(qe)?qe:[])}catch(qe){console.error("Error fetching documents:",qe),z([])}finally{Y(!1)}}},Ne=()=>{X(!1),z([]),q("")};C.useEffect(()=>{u&&A&&H(),u||(P(null),F(null))},[u,A?.transactionId]);const H=async()=>{if(A){k(!0),F(null);try{const ne=A.source==="LOS"?"LMS":A.source,ye=await kf(A.transactionId,ne);P(ye)}catch(ne){console.error("Error fetching transaction details:",ne);const ye=ne?.response?.data?.errorMessage||ne?.response?.data?.message||ne?.message||"Failed to load details";F(ye)}finally{k(!1)}}};if(!A)return null;const ie=ne=>{const ye=new Date(ne),qe=ye.getDate(),lt=ye.toLocaleDateString("en-IN",{month:"short"}),Ue=ye.getFullYear(),Te=ye.getHours(),Ge=ye.getMinutes().toString().padStart(2,"0"),Re=Te>=12?"PM":"AM",Ve=Te%12||12;return`${qe} ${lt} ${Ue}, ${Ve}:${Ge} ${Re}`},me=ne=>{switch(ne.toUpperCase()){case"SUCCESS":return"fp:text-[#2FB551]";case"FAILED":case"FAILURE":return"fp:text-[#E80000]";case"INITIATED":return"fp:text-[#1E88E5]";case"PENDING":return"fp:text-[#FFA500]";default:return"fp:text-[#6D6D6D]"}},Ce=ne=>{switch(ne.toUpperCase()){case"SUCCESS":return"Success";case"FAILED":case"FAILURE":return"Failed";case"INITIATED":return"Initiated";case"PENDING":return"Pending";default:return ne}},ge=a?.id??A.transactionId,V=a?.amount??A.amount,se=a?.status??A.status,ue=a?.date??A.date,Ae=a?.paymentMode??A.paymentMode,ve=a?.supplierName&&a.supplierName.trim()||A.supplierName||A.name||"",ke=a?.lender||A.lenderName||"",ce=a?.type==="LENDING"||A.transactionType==="LOAN_REPAYMENT",Z=a?.loan?.loans||[],Se=a?.invoice||[],De=A.invoiceNumbers||[],Le=Se.length>0||De.length>0,xe=Se.length>0?Se.map(ne=>ne.invoiceNumber).join(", "):De.join(", "),Be=Se.find(ne=>ne.remark&&ne.remark.trim())?.remark||a?.settlement?.find(ne=>ne.description&&ne.description.trim())?.description||"",Ze=Se.filter(ne=>ne.documentIds&&ne.documentIds.length>0),We=async()=>{let ne=`Transaction Details
665
+ `})]}),eu=({size:u=24,color:o="currentColor",className:A,style:I})=>e.jsx("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:A,style:I,"aria-hidden":"true",children:e.jsx("path",{d:"M22 16.92V19.92C22.0011 20.1985 21.9441 20.4742 21.8325 20.7293C21.7209 20.9845 21.5573 21.2136 21.3521 21.4019C21.1468 21.5901 20.9046 21.7335 20.6407 21.8227C20.3769 21.9119 20.0974 21.9451 19.82 21.92C16.7428 21.5856 13.787 20.5341 11.19 18.85C8.77382 17.3147 6.72533 15.2662 5.18999 12.85C3.49997 10.2412 2.44824 7.27099 2.11999 4.18C2.095 3.90347 2.12787 3.62476 2.21649 3.36162C2.30512 3.09849 2.44756 2.85669 2.63476 2.65162C2.82196 2.44655 3.0498 2.28271 3.30379 2.17052C3.55777 2.05833 3.83233 2.00026 4.10999 2H7.10999C7.5953 1.99522 8.06579 2.16708 8.43376 2.48353C8.80173 2.79999 9.04207 3.23945 9.10999 3.72C9.23662 4.68007 9.47144 5.62273 9.80999 6.53C9.94454 6.88792 9.97366 7.27691 9.89384 7.65088C9.81401 8.02485 9.62892 8.36811 9.35999 8.64L8.08999 9.91C9.51355 12.4135 11.5864 14.4864 14.09 15.91L15.36 14.64C15.6319 14.3711 15.9751 14.186 16.3491 14.1062C16.7231 14.0263 17.1121 14.0555 17.47 14.19C18.3773 14.5286 19.3199 14.7634 20.28 14.89C20.7658 14.9585 21.2094 15.2032 21.5265 15.5775C21.8437 15.9518 22.0122 16.4296 22 16.92Z",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),tu=({size:u=24,color:o="currentColor",className:A,style:I})=>e.jsxs("svg",{width:u,height:u,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:A,style:I,"aria-hidden":"true",children:[e.jsx("path",{d:"M4 4H20C21.1 4 22 4.9 22 6V18C22 19.1 21.1 20 20 20H4C2.9 20 2 19.1 2 18V6C2 4.9 2.9 4 4 4Z",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M22 6L12 13L2 6",stroke:o,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),Ur={PHONE:"+91-9892422528",EMAIL:"connect@fundly.ai"},is={FUNDLY_PAY:"FUNDLY_PAY",DYNAMIC_QR:"DYNAMIC_QR",STATIC_QR:"STATIC_QR",PAYMENT_LINK:"PAYMENT_LINK",CASH:"CASH",CHEQUE:"CHEQUE",UPI:"UPI",NETBANKING:"NETBANKING",BANK_TRANSFER:"BANK_TRANSFER"},us={FUNDLY_CUSTOMER_APP:"FUNDLY_CUSTOMER_APP",FUNDLY_COLLECT_APP:"FUNDLY_COLLECT_APP",FUNDLY_TRADE:"FUNDLY_TRADE",FUNDLY_MART:"FUNDLY_MART"},su=({open:u,onClose:o})=>{const A=I=>{navigator.clipboard.writeText(I)};return e.jsx(ws,{open:u,onClose:o,children:e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:px-8 fp:py-4 fp:space-y-4 fp:mt-2 fp:mb-12",children:[e.jsx("div",{className:"fp:w-full fp:flex fp:items-center fp:justify-end",children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:o,alt:"Close"})}),e.jsx("img",{src:we.customerSup,className:"fp:w-14 fp:h-14",alt:"Support"}),e.jsxs("div",{className:"fp:flex fp:space-x-6 fp:items-center",children:[e.jsx(eu,{size:24,color:"#16558B"}),e.jsx("span",{className:"fp:font-semibold",children:Ur.PHONE}),e.jsx("img",{src:we.copy,className:"fp:w-5 fp:h-5 fp:cursor-pointer",onClick:()=>A(Ur.PHONE),alt:"Copy"})]}),e.jsxs("div",{className:"fp:flex fp:space-x-6 fp:items-center",children:[e.jsx(tu,{size:24,color:"#16558B"}),e.jsx("span",{className:"fp:font-semibold",children:Ur.EMAIL}),e.jsx("img",{src:we.copy,className:"fp:w-5 fp:h-5 fp:cursor-pointer",onClick:()=>A(Ur.EMAIL),alt:"Copy"})]})]})})},nu=({open:u,onClose:o,onConfirm:A})=>e.jsxs(gs,{open:u,onClose:o,children:[e.jsx(ln,{children:e.jsx("div",{className:"fp:w-full fp:flex fp:justify-end",children:e.jsx("img",{src:we.closingCross,className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:o,alt:"Close"})})}),e.jsx(Is,{children:e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:flex fp:flex-col fp:justify-center fp:items-center",children:[e.jsx("img",{src:we.paymentLeave,className:"fp:w-18 fp:h-18",alt:"Leave"}),e.jsx("span",{className:"fp:text-[18px] fp:text-wrap fp:font-bold fp:text-center",children:"Leave this page?"}),e.jsx("span",{className:"fp:text-[14px] fp:text-wrap fp:font-semibold fp:text-center fp:text-[#6D6D6D]",children:"Any unsaved payment details will be lost."})]})}),e.jsx(Ls,{children:e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:w-full fp:flex fp:justify-between fp:px-3 fp:mb-3 fp:gap-3",children:[e.jsx("button",{className:"fp:flex-1 fp:w-[96px] fp:h-[48px] fp:border-2 fp:border-gray-400 fp:text-gray-400 fp:rounded-xl",onClick:A,children:"Yes, Leave"}),e.jsx("button",{className:"fp:flex-1 fp:w-[96px] fp:h-[48px] fp:bg-[#16558B] fp:text-white fp:rounded-xl",onClick:o,children:"No"})]})})]}),iu=()=>{const{partnerCredentials:u}=ms(),[o,A]=C.useState(null),[I,a]=C.useState(!1),[P,O]=C.useState(null);return{login:C.useCallback(async()=>{a(!0),O(null);try{if(!u)throw new Error("Partner credentials not provided");const R={loginType:"PARTNER",username:u.username,password:u.password},F=await bf(R);if(F?.accessToken){const J=F.accessToken;return Fo(J),A(J),J}throw new Error("No access token received")}catch(R){const F=R instanceof Error?R:new Error("Login failed");throw O(F),F}finally{a(!1)}},[u]),token:o,isLoading:I,error:P}},ru=u=>{const{setChemistId:o,setLeadId:A,setDistributorIdnum:I,setTypeOfApp:a,setPaymentInvoice:P,setPayableValue:O,setInvoices:k,setPaymentType:R,setSalesmanId:F,distributorIdnum:J,chemistId:z,leadId:G}=ms(),X=C.useRef(!1);C.useEffect(()=>{const ee=q=>{if(typeof q.data!="object"||q.data===null||q.source!==window||q.data?.source==="react-devtools-content-script"||q.source!==window||q.data?.source?.includes("react-devtools")||q.origin!==window.origin)return;const{source:be,distributorId:Ne,chemistId:H,paymentType:ie,payableAmount:me,invoices:Ce,paymentInvoice:ge,salesmanId:V}=q.data;Ne&&I(Ne),H&&o(H),be&&a(be),Array.isArray(ge)&&P(ge),me&&O(me),Array.isArray(Ce)&&k(Ce),ie&&R(ie),V&&F(V),X.current||(u(),X.current=!0)},Y=z&&z.trim()!=="",U=G&&G.trim()!=="";return J&&(Y||U)&&!X.current&&(u(),X.current=!0),window.addEventListener("message",ee),()=>window.removeEventListener("message",ee)},[u,o,A,I,a,P,O,k,R,F,J,z,G])},ou=u=>{const{distributorIdnum:o,typeOfApp:A,chemistId:I,leadId:a,payableValue:P,salesmanId:O,paymentType:k,setDistributorName:R,setChemistName:F,setPayerMobileNumber:J,setSalesmanPhoneNumber:z,setTenureMappings:G,setFiCode:X,setDrawdownRepaymentOption:ee,setCreditLimitData:Y,setPayerUuid:U}=ms(),[q,be]=C.useState([]),[Ne,H]=C.useState(null),[ie,me]=C.useState(null),[Ce,ge]=C.useState(null),[V,se]=C.useState(null),[ue,Ae]=C.useState(!0);return C.useEffect(()=>{u&&(async()=>{const ke={distributorBusinessId:o,source:A,...I&&I.trim()!==""&&{chemistBusinessId:I},...a&&a.trim()!==""&&{leadId:a},payableAmount:P,...O&&{salesmanId:O},...k&&{collectType:k}};try{const ce=await jf(ke);H(ce.bankDetails),ce.bankDetails&&(R(ce.bankDetails.distributorName||""),F(ce.bankDetails.chemistName||""),J(ce.bankDetails.mobileNumber||""),z(ce.bankDetails.salesmanPhoneNumber||""),ce.bankDetails.mobileNumber&&Jf(ce.bankDetails.mobileNumber).then(Se=>{Se&&U(Se)}));const Me=ce.paymentOption.find(Se=>Se.name==="FUNDLY_PAY");Me?.details?.tenureMappings&&G(Me.details.tenureMappings),me(Me?.details?.maxEligibleLimit??null),ge(Me?.details?.minEligibleLimit??null),se(Me?.reason??null),Me?.details?.fiCode&&X(Me.details.fiCode),Me?.details?.drawdownRepaymentOption&&ee(Me.details.drawdownRepaymentOption);const Z=ce.paymentOption.filter(Se=>Se.isActive).map(Se=>Se.name);if(be(Z),Me?.isActive&&ce.bankDetails?.chemistBusinessId)try{const Se=await Mf(ce.bankDetails.chemistBusinessId);Y(Se)}catch(Se){console.warn("Credit limit filter API failed:",Se),Y(null)}Ae(!1)}catch{Ae(!1)}})()},[u]),{paymentOptions:q,bankDetails:Ne,maxEligibleLimit:ie,minEligibleLimit:Ce,fundlyPayReason:V,loading:ue}};function n0(){const[u,o]=C.useState({activeDrawer:null,paymentData:null}),A=C.useCallback(k=>{o({activeDrawer:k,paymentData:null})},[]),I=C.useCallback(()=>{o({activeDrawer:null,paymentData:null})},[]),a=C.useCallback(k=>{o({activeDrawer:"SUCCESS",paymentData:k||null})},[]),P=C.useCallback(k=>{o({activeDrawer:"FAILURE",paymentData:k||null})},[]),O=C.useCallback(k=>u.activeDrawer===k,[u.activeDrawer]);return{activeDrawer:u.activeDrawer,paymentData:u.paymentData,openPaymentDrawer:A,closeDrawer:I,isDrawerOpen:O,handlePaymentSuccess:a,handlePaymentFailure:P,showFundlyPayDrawer:O("FUNDLY_PAY"),showUpiDrawer:O("UPI"),showDynamicQrDrawer:O("DYNAMIC_QR"),showStaticQrDrawer:O("STATIC_QR"),showPaymentLinkDrawer:O("PAYMENT_LINK"),showNetbankingDrawer:O("NETBANKING"),showCashDrawer:O("CASH"),showChequeDrawer:O("CHEQUE"),showBankTransferDrawer:O("BANK_TRANSFER"),showSuccessDrawer:O("SUCCESS"),showFailureDrawer:O("FAILURE")}}const au=({onPaymentCollected:u,onPaymentFailed:o})=>{const[A,I]=C.useState(!1),[a,P]=C.useState(!1),[O,k]=C.useState(!1),[R,F]=C.useState(null),{paymentData:J,openPaymentDrawer:z,closeDrawer:G,handlePaymentSuccess:X,handlePaymentFailure:ee,showFundlyPayDrawer:Y,showUpiDrawer:U,showDynamicQrDrawer:q,showStaticQrDrawer:be,showPaymentLinkDrawer:Ne,showNetbankingDrawer:H,showCashDrawer:ie,showChequeDrawer:me,showBankTransferDrawer:Ce,showSuccessDrawer:ge,showFailureDrawer:V}=n0(),[se,ue]=C.useState(!1),[Ae,ve]=C.useState(-1),[ke,ce]=C.useState(null),[Me,Z]=C.useState([]),[Se,De]=C.useState(null),[Le,xe]=C.useState(null),Be=C.useRef(!1),{distributorName:Ze,distributorIdnum:We,payableValue:$e,typeOfApp:he,transactionId:ne,showResultOnly:ye,successButtonText:qe,failureButtonText:lt,creditLimitData:Ue,paymentType:Te,paymentInvoice:Ge,chemistId:Re,leadId:Ve,salesmanId:et,payerMobileNumber:le,payerUuid:Ee,scanId:K,viewId:Ie,sessionId:Ye,erpId:it}=ms(),tt=C.useMemo(()=>({type:"collection",distributorId:We||"",chemistId:Re||void 0,leadId:Ve||void 0,invoices:Ge||[],paymentType:Te||"INVOICE_COLLECT",salesmanId:et||void 0,payerMobileNumber:le||void 0}),[We,Re,Ve,Ge,Te,et,le]),{login:ht,token:rt,error:at}=iu(),Lt=C.useCallback(async()=>{try{await ht(),F(null)}catch(re){const Oe=re instanceof Error?re.message:"Authentication failed. Please try again later.";F(Oe)}},[ht]);ru(Lt);const{paymentOptions:nt,bankDetails:Fe,maxEligibleLimit:Ct,minEligibleLimit:Tt,fundlyPayReason:St,loading:ft}=ou(rt);C.useEffect(()=>{if(!ye&&!ne){const re=new URLSearchParams(window.location.search);if((re.has("orderId")||re.has("transactionId"))&&!rt){const Pe=new URL(window.location.href);Pe.searchParams.delete("orderId"),Pe.searchParams.delete("transactionId"),window.history.replaceState({},"",Pe.toString())}}},[ye,rt,ne]),C.useEffect(()=>{if(R||at){const re=setTimeout(async()=>{await Mt.navigateHome()},1e4);return()=>clearTimeout(re)}},[R,at]),C.useEffect(()=>{const re=new URLSearchParams(window.location.search);(re.get("orderId")||re.get("transactionId"))&&rt&&!ye&&z("UPI")},[rt,ye,z]),C.useEffect(()=>{!ye||!ne||!rt||!ge&&!V&&!U&&z("UPI")},[ye,ne,rt,ge,V,U,z]),C.useEffect(()=>{he===us.FUNDLY_TRADE&&xs.setEnabled(!1)},[he]),C.useEffect(()=>{if(ye||ft||!rt||Be.current||nt.length===0)return;const re=he===us.FUNDLY_MART?"customer":he===us.FUNDLY_TRADE?"internal_user":et&&et>0?"salesman":Ve&&Ve.trim()!==""?"guest":"retailer";if((re==="customer"||re==="internal_user"||re==="guest")&&!Ee)return;Be.current=!0,Ee&&xs.setUserIdentity(Ee);const Pe=()=>{const Zt=navigator.userAgent.toLowerCase();return Zt.includes("android")?"android":Zt.includes("iphone")||Zt.includes("ipad")||Zt.includes("ipod")?"ios":"web"},xt=()=>he===us.FUNDLY_COLLECT_APP?"collect_app":he===us.FUNDLY_CUSTOMER_APP?"customer_app":he==="FUNDLY_QR_WEB"?"web":he===us.FUNDLY_MART?"fundly_mart":he===us.FUNDLY_TRADE?"fundly_trade":"external_app",yt=()=>he===us.FUNDLY_COLLECT_APP?"collect_app":he===us.FUNDLY_CUSTOMER_APP?"customer_app":null,Ft=()=>he==="FUNDLY_QR_WEB"?"invoice_qr":Te==="INVOICE_COLLECT"?"invoice_pay_page":Te==="DIRECT_COLLECT"?"direct_pay_page":"invoice_qr",Ss=Ge?.map(Zt=>Zt.invoiceId?.toString()||Zt.invoiceNumber?.toString()).filter(Boolean)||null,Ns=Ye||`sdk_session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`,Gs={scan_id:K||null,view_id:Ie||null,invoice_id:Ss,supplier_id:We?.toString()||"",erp_id:it||null,business_id:Re||null,salesman_id:et?.toString()||null,user_type:re,session_id:Ns,scan_channel:yt(),scan_origin:Te==="INVOICE_COLLECT"?"invoice":null,device_type:Pe(),payment_type:Te==="INVOICE_COLLECT"?"invoice_pay":"direct_pay",payment_sdk_entry_point:Ft(),payment_options:nt,default_payment_option:null,payment_amount:Number($e)||0,is_payment_enabled:nt.length>0,status:"success",failure_reason:null,error_code:null,error_description:null,failure_stage:null,sdk_version:"1.4.0",app_context:xt(),app_version:"1.4.0",mobile_number:le||null,uuid:Ee||null};xs.trackPaymentSDKLaunched(Gs)},[ft,rt,ye,nt,Ee,We,Re,Ve,et,$e,Te,Ge,he,K,Ie,Ye,it]);const ut=async()=>{I(!1),await Mt.navigateHome()},st=re=>{if(!re?.productRules||!Array.isArray(re.productRules))return{tenureMappings:[],repaymentOption:null,disbursementAccount:null};const Oe=Te==="INVOICE_COLLECT"?"YES":"NO",xt=re.productRules.find(yt=>yt.isInvoiceRequired===Oe&&yt.disbursementAccount==="SUPPLIER")||re.productRules[0];return{tenureMappings:xt?.tenureMappings||[],repaymentOption:xt?.repaymentOption||null,disbursementAccount:xt?.disbursementAccount||null}};return R||at?e.jsx("div",{style:{fontFamily:"Poppins"},className:"fp:relative fp:w-full fp:h-screen fp:flex fp:items-center fp:justify-center fp:px-4 fp:bg-[#F8FCFF]",children:e.jsxs("div",{className:"fp:w-full fp:max-w-md fp:bg-white fp:border fp:border-red-100 fp:rounded-2xl fp:p-8 fp:text-center fp:shadow-lg",children:[e.jsx("div",{className:"fp:w-16 fp:h-16 fp:mx-auto fp:mb-4 fp:bg-red-50 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:e.jsx("svg",{className:"fp:w-8 fp:h-8 fp:text-red-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),e.jsx("h3",{className:"fp:text-[20px] fp:font-semibold fp:text-gray-800 fp:mb-3",children:"Authentication Failed"}),e.jsx("p",{className:"fp:text-[14px] fp:text-gray-600 fp:mb-4",children:R||at?.message||"We're unable to authenticate your session at the moment. Please try again later."}),e.jsx("p",{className:"fp:text-[12px] fp:text-gray-500",children:"This window will close automatically in a few seconds..."})]})}):ft?e.jsx($f,{}):ye?e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:relative fp:w-full fp:h-screen fp:flex fp:items-center fp:justify-center fp:bg-[#F8FCFF]",children:[e.jsx(Oo,{open:ge,onClose:()=>{G(),u&&J&&u(J)},paymentData:J,buttonText:qe}),e.jsx(Po,{open:V,onClose:()=>{G(),o&&J&&o(J)},paymentData:J,buttonText:lt}),e.jsx(Tl,{open:U,onClose:()=>G(),onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}})]}):e.jsxs("div",{style:{fontFamily:"Poppins"},className:"fp:relative fp:w-full fp:h-screen fp:pt-10 fp:flex fp:flex-col fp:px-4 fp:bg-[#F8FCFF] fp:overflow-x-hidden",children:[e.jsx("div",{className:"fp:w-full fp:h-10 fp:flex fp:items-center fp:space-x-3",children:e.jsx("img",{src:we.backButton,alt:"Back",className:"fp:w-4 fp:h-4 fp:cursor-pointer",onClick:()=>I(!0)})}),e.jsxs("div",{className:"fp:w-full fp:items-center fp:text-center fp:justify-between fp:flex ",children:[e.jsx("h1",{className:"fp:font-medium fp:text-[20px] fp:text-[#222222]",children:"Payment Options"}),e.jsxs("label",{className:"fp:flex fp:items-center fp:text-[14px] fp:cursor-pointer",onClick:()=>k(!0),children:[e.jsx("img",{src:we.QuestionMark,className:"fp:w-4 fp:h-4 fp:mr-1"}),"Get Help"]})]}),e.jsx("div",{className:"fp:flex-1 fp:overflow-y-auto fp:mb-12 fp:mt-2",children:he==="FUNDLY_CUSTOMER_APP"&&!Fe?e.jsx("div",{className:"fp:w-full fp:h-full fp:flex fp:items-center fp:justify-center",children:e.jsxs("div",{className:"fp:w-full fp:max-w-md fp:bg-white fp:border fp:border-gray-200 fp:rounded-2xl fp:p-8 fp:text-center fp:shadow-sm",children:[e.jsx("div",{className:"fp:w-16 fp:h-16 fp:mx-auto fp:mb-4 fp:bg-gray-100 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:e.jsx("svg",{className:"fp:w-8 fp:h-8 fp:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h3",{className:"fp:text-[18px] fp:font-semibold fp:text-gray-800 fp:mb-2",children:"Bank Details Not Available"}),e.jsx("p",{className:"fp:text-[14px] fp:text-gray-500",children:"We couldn't find bank details for this distributor. Please contact support for assistance."})]})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:rounded-xl fp:p-4 fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsxs("div",{className:"fp:flex fp:justify-between fp:items-start",children:[e.jsxs("div",{className:"fp:flex fp:flex-col fp:flex-1",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"Collect For"}),e.jsx("label",{className:"fp:font-semibold fp:text-[16px] fp:text-[#222222]",children:Ze})]}),e.jsxs("div",{className:"fp:flex fp:flex-col fp:items-end fp:flex-shrink-0",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400 fp:text-right",children:"Collection Amount"}),e.jsxs("label",{className:"fp:font-semibold fp:text-[16px] fp:text-[#222222]",children:["₹",pt($e)]})]})]}),(he==="FUNDLY_CUSTOMER_APP"||he==="FUNDLY_QR_WEB")&&Fe&&e.jsxs("div",{className:"fp:w-full fp:mt-2",children:[e.jsxs("label",{className:"fp:cursor-pointer fp:select-none fp:text-[#16558B] fp:font-medium fp:text-[12px]",onClick:()=>P(re=>!re),children:["Bank Details ",a?"▲":"▼"]}),a&&e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:space-y-3 fp:mt-2",children:[e.jsxs("div",{className:"fp:flex fp:flex-col ",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"Account Holder Name"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:Fe.accountName})]}),e.jsxs("div",{className:"fp:flex fp:justify-between",children:[e.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-1",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"Account Number"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:Fe.accountNumber})]}),e.jsxs("div",{className:"fp:flex fp:flex-col fp:space-y-1",children:[e.jsx("h4",{className:"fp:text-[12px] fp:font-normal fp:text-gray-400",children:"IFSC Code"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:Fe.ifsc})]})]})]})]})]}),nt.includes(is.FUNDLY_PAY)&&(()=>{const re=Number($e??0),Oe=Tt??1e3,Pe=Ct??null;let xt=null,yt=!1;re<Oe?(xt=`Fundly Pay not available below ₹${Oe.toLocaleString("en-IN")} payment.`,yt=!0):Pe!==null&&re>Pe?(xt=`Max Eligible Amount: ₹${pt(Pe)}`,yt=!0):St&&(xt=St);let Ft=[],Ss=0;Ue?.subLimits&&Array.isArray(Ue.subLimits)&&(Ft=Ue.subLimits.filter(At=>At.expired===!1),Ft.sort((At,hs)=>{const pn=At.maxEligibleAmount||At.availableLimit||0;return(hs.maxEligibleAmount||hs.availableLimit||0)-pn}),Ft.length>0&&(Ss=Math.max(...Ft.map(At=>At.maxEligibleAmount||At.availableLimit||0))));const Ns=Ft.length>1,Gs=Ft.length===1,Zt=Ft.length===0;return e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-6",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Preferred Payment"}),e.jsxs("div",{className:"fp:w-full fp:flex fp:flex-col fp:mt-2",children:[e.jsxs("div",{className:`fp:w-full fp:border fp:border-gray-100 ${yt?"fp:bg-[#efefef]":"fp:bg-white"} ${xt||Ns&&se||Gs?"fp:rounded-t-xl":"fp:rounded-xl"} ${yt?"":"fp:cursor-pointer fp:hover:shadow-2xs"} fp:p-4 fp:flex fp:items-center fp:justify-between`,onClick:()=>{if(!yt)if(Ns)ue(!se);else if(Gs){ve(0),ce(Ft[0].fiCode);const At=st(Ft[0]);Z(At.tenureMappings),De(At.repaymentOption),xe(At.disbursementAccount),z("FUNDLY_PAY")}else z("FUNDLY_PAY")},children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.logo,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:cursor-pointer",children:"Fundly Pay"}),e.jsxs("div",{className:"fp:flex fp:items-center fp:bg-[#34A877] fp:py-1 fp:px-3 fp:rounded-4xl",children:[e.jsx("img",{src:we.primary,className:"fp:w-3 fp:h-3"}),e.jsx("label",{className:"fp:text-[10px] fp:font-medium fp:text-white",children:"1 Click Payment"})]})]}),e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[!yt&&Ns&&e.jsx("svg",{className:`fp:w-5 fp:h-5 fp:text-[#16558B] fp:transition-transform fp:duration-200 ${se?"fp:rotate-180":""}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",d:"M19 9l-7 7-7-7"})}),!yt&&!Ns&&e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),!yt&&Gs&&e.jsx("div",{className:"fp:w-full fp:bg-[#E6F7EF] fp:flex fp:p-2 fp:text-[#34A877] fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{className:"fp:text-[10px] fp:font-medium",children:["Max Eligible Amount:"," ",e.jsxs("span",{className:"fp:font-bold",children:["₹",pt(Ft[0].maxEligibleAmount||Ft[0].availableLimit||0)]})]})}),!yt&&Ns&&!se&&e.jsx("div",{className:"fp:w-[95%] fp:m-auto fp:bg-[#E6F7EF] fp:flex fp:p-2 fp:text-[#34A877] fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{className:"fp:text-[10px] fp:font-medium",children:["Max Eligible Amount:"," ",e.jsxs("span",{className:"fp:font-bold",children:["₹",pt(Ss)]})]})}),!yt&&Ns&&se&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fp:w-full fp:bg-white fp:border-x fp:border-gray-100 fp:rounded-b-xl fp:px-3 fp:pt-3 fp:pb-2 fp:flex fp:flex-col fp:space-y-2.5",children:Ft.map((At,hs)=>{const pn=At.maxEligibleAmount||At.availableLimit||0,wt=pn<re;return e.jsx("button",{type:"button",disabled:wt,className:`fp:w-full fp:text-left fp:focus:outline-none fp:transition-all fp:duration-150 ${wt?"fp:cursor-not-allowed fp:opacity-50":Ae===hs?"fp:bg-[#EBF4FA]":"fp:bg-white fp:hover:border-[#16558B] fp:cursor-pointer"}`,style:{fontFamily:"Poppins",paddingTop:"10px",paddingLeft:"10px",paddingBottom:"10px",paddingRight:"16px",borderRadius:"8px",borderWidth:"0.87px",borderStyle:"solid",borderColor:wt?"#E0E0E0":Ae===hs?"#C5DBED":"#E8EEF3",height:"35px",display:"flex",alignItems:"center"},onClick:()=>{if(!wt){ve(hs),ce(At.fiCode);const Bs=st(At);Z(Bs.tenureMappings),De(Bs.repaymentOption),xe(Bs.disbursementAccount),ue(!1),z("FUNDLY_PAY")}},children:e.jsxs("div",{className:"fp:flex fp:justify-between fp:items-center fp:w-full",style:{lineHeight:"24px"},children:[e.jsx("span",{className:`fp:font-medium ${wt?"fp:text-gray-400":"fp:text-[#16558B]"}`,style:{fontSize:"12px",letterSpacing:"0px",textTransform:"capitalize"},children:At.fiCode?.toLowerCase()}),e.jsxs("span",{className:`fp:text-[12px] fp:font-semibold ${wt?"fp:text-gray-400":"fp:text-[#000000]"}`,style:{letterSpacing:"0px",lineHeight:"100%"},children:["₹ ",pt(pn)]})]})},hs)})}),e.jsx("div",{className:"fp:w-[95%] fp:m-auto fp:bg-[#E6F7EF] fp:flex fp:p-2 fp:text-[#34A877] fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{style:{fontFamily:"Poppins"},children:[e.jsxs("span",{className:"fp:text-[10px] fp:font-medium",children:["Max Eligible Amount:"," "]}),e.jsxs("span",{className:"fp:font-bold fp:text-[10px]",children:["₹",pt(Ss)]})]})})]}),xt&&Zt&&e.jsx("div",{className:"fp:w-full fp:bg-red-50 fp:flex fp:p-2 fp:text-red-700 fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsx("label",{className:"fp:text-[11px] fp:ml-2",children:xt})}),!xt&&Zt&&Pe!==null&&e.jsx("div",{className:"fp:w-full fp:bg-green-50 fp:flex fp:p-2 fp:text-green-700 fp:rounded-b-xl fp:border-x fp:border-b fp:border-gray-100",children:e.jsxs("label",{className:"fp:text-[11px] fp:ml-2",children:["Max Eligible Amount:"," ",e.jsxs("span",{className:"fp:font-medium",children:["₹",pt(Pe)]})]})})]})]})})(),nt.includes(is.UPI)&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.upi,className:"fp:h-[20px]",alt:"UPI Logo"}),e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Pay by UPI"})]}),e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("UPI"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.upiIcon,className:"fp:w-[32px] fp:h-[32px]",alt:"UPI"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"UPI"}),e.jsx("div",{className:"fp:flex fp:items-center fp:bg-green-50 fp:rounded-4xl fp:py-1 fp:px-2",children:e.jsx("label",{className:"fp:text-[10px] fp:text-green-700 fp:font-medium",children:"₹ 0 charges"})})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),nt.includes(is.NETBANKING)&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Netbanking"}),e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("NETBANKING"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.scanqrIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Netbanking"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),(nt.includes(is.BANK_TRANSFER)||nt.includes(is.DYNAMIC_QR)&&!(he===us.FUNDLY_CUSTOMER_APP&&nt.includes(is.PAYMENT_LINK))||nt.includes(is.PAYMENT_LINK)&&(he===us.FUNDLY_COLLECT_APP||he===us.FUNDLY_TRADE))&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"Online Payment Options"}),nt.includes(is.DYNAMIC_QR)&&!(he===us.FUNDLY_CUSTOMER_APP&&nt.includes(is.PAYMENT_LINK))&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("DYNAMIC_QR"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.generateqrIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium",children:"Generate QR"}),e.jsx("div",{className:"fp:flex fp:items-center fp:bg-green-50 fp:rounded-4xl fp:py-1 fp:px-2",children:e.jsx("label",{className:"fp:text-[10px] fp:text-green-700 fp:font-medium",children:"₹ 0 charges"})})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.PAYMENT_LINK)&&(he===us.FUNDLY_COLLECT_APP||he===us.FUNDLY_TRADE)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:mt-2 fp:flex fp:items-center fp:justify-between",onClick:()=>z("PAYMENT_LINK"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.paymentlinkIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium",children:"Payment Link"}),e.jsx("div",{className:"fp:flex fp:items-center fp:bg-green-50 fp:rounded-4xl fp:py-1 fp:px-2",children:e.jsx("label",{className:"fp:text-[10px] fp:text-green-700 fp:font-medium",children:"₹ 0 charges"})})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.BANK_TRANSFER)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:mt-2 fp:flex fp:items-center fp:justify-between",onClick:()=>z("BANK_TRANSFER"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.bankTransferIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Bank Transfer"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]}),(nt.includes(is.CASH)||nt.includes(is.CHEQUE)||nt.includes(is.STATIC_QR))&&e.jsxs("div",{className:"fp:w-full fp:mt-6 fp:flex fp:flex-col fp:space-y-2",children:[e.jsx("h2",{className:"fp:text-[16px] fp:font-semibold",children:"More Payment Options"}),nt.includes(is.STATIC_QR)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("STATIC_QR"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.scanqrIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Scan QR"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.CASH)&&e.jsxs("div",{className:"fp:w-full fp:border fp:border-gray-100 fp:bg-white fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:flex fp:items-center fp:justify-between",onClick:()=>z("CASH"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.cashIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Cash"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]}),nt.includes(is.CHEQUE)&&e.jsxs("div",{className:"fp:w-full fp:bg-white fp:border fp:border-gray-100 fp:hover:shadow-2xs fp:cursor-pointer fp:rounded-xl fp:p-4 fp:mt-2 fp:flex fp:items-center fp:justify-between",onClick:()=>z("CHEQUE"),children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:space-x-2",children:[e.jsx("img",{src:we.chequeIcon,className:"fp:w-[32px] fp:h-[32px]"}),e.jsx("label",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222]",children:"Cheque"})]}),e.jsx("img",{src:we.cardOpener,className:"fp:w-4 fp:h-4"})]})]})]})}),e.jsx(Hf,{open:be,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(Tl,{open:U,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}}),e.jsx(Kf,{open:H,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}}),e.jsx(e0,{open:ie,metadata:tt,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(t0,{open:me,metadata:tt,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(s0,{open:Ce,metadata:tt,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)}}),e.jsx(Zf,{open:Y,onClose:()=>{G()},onPaymentCollected:re=>{X(re)},selectedLenderIdx:Ae,selectedLenderFiCode:ke,selectedLenderTenureMappings:Me,selectedLenderRepaymentOption:Se,selectedLenderDisbursementAccount:Le}),e.jsx(qf,{open:Ne,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:()=>{X()}}),e.jsx(Vf,{open:q,onClose:async()=>{G(),await Mt.navigateHome()},onPaymentCollected:re=>{X(re)},onPaymentFailed:re=>{ee(re)}}),e.jsx(Oo,{open:ge,onClose:()=>G(),paymentData:J,buttonText:qe}),e.jsx(Po,{open:V,onClose:()=>G(),paymentData:J,buttonText:lt}),e.jsx(nu,{open:A,onClose:()=>I(!1),onConfirm:ut}),e.jsx(su,{open:O,onClose:()=>k(!1)}),e.jsxs("div",{className:"fp:absolute fp:bottom-0 fp:left-0 fp:w-full fp:flex fp:flex-col fp:items-center fp:justify-center fp:py-2 fp:bg-[#F8FCFF]",children:[e.jsx("span",{className:"fp:text-[10px] fp:text-[#9CA3AF] fp:font-medium",children:"Powered by"}),e.jsx("a",{href:"https://fundly.ai",target:"_blank",rel:"noopener noreferrer",className:"fp:text-[12px] fp:text-[#16558B] fp:font-bold fp:no-underline",children:"Fundly.ai"})]})]})},i0=C.createContext(void 0);function r0({children:u,initialValues:o}){Hr(o?.environment??"production");const[A,I]=C.useState(o?.partnerCredentials||null),[a,P]=C.useState(o?.businessId||null),[O,k]=C.useState(o?.businessName||null),[R,F]=C.useState(null),[J,z]=C.useState([]),[G,X]=C.useState([]),[ee,Y]=C.useState([]),[U,q]=C.useState(0),[be,Ne]=C.useState("FULL"),[H,ie]=C.useState(null),[me,Ce]=C.useState(o?.onPaymentComplete?()=>o.onPaymentComplete:void 0),[ge,V]=C.useState(o?.onNavigateHome?()=>o.onNavigateHome:void 0),[se,ue]=C.useState(o?.sessionId||null),[Ae,ve]=C.useState(o?.erpId||null);C.useEffect(()=>{const ce=Xr(),Me=Gr();ce&&xs.configure({enabled:!0,clevertap:{accountId:ce,region:Me}})},[]);const ke={partnerCredentials:A,setPartnerCredentials:I,businessId:a,setBusinessId:P,businessName:O,setBusinessName:k,selectedLender:R,setSelectedLender:F,lenderList:J,setLenderList:z,selectedLoans:G,setSelectedLoans:X,loanList:ee,setLoanList:Y,totalAmount:U,setTotalAmount:q,repaymentType:be,setRepaymentType:Ne,redirectionUrl:H,setRedirectionUrl:ie,onPaymentComplete:me,setOnPaymentComplete:Ce,onNavigateHome:ge,setOnNavigateHome:V,sessionId:se,setSessionId:ue,erpId:Ae,setErpId:ve};return e.jsx(i0.Provider,{value:ke,children:u})}function Hi(){const u=C.useContext(i0);if(!u)throw new Error("useRepaymentContext must be used within a RepaymentProvider");return u}const o0=C.createContext(void 0);function zo({children:u,initialValues:o}){Hr(o?.environment??"production");const[A,I]=C.useState(o?.partnerCredentials||null),[a,P]=C.useState(o?.businessId||null),[O,k]=C.useState(o?.businessName||null),[R,F]=C.useState([]),[J,z]=C.useState(null),[G,X]=C.useState(o?.filters||null),[ee,Y]=C.useState(o?.defaultTab||"all"),[U,q]=C.useState(1),[be,Ne]=C.useState(!0),[H,ie]=C.useState(!1),[me,Ce]=C.useState(o?.onNavigateHome?()=>o.onNavigateHome:void 0),[ge,V]=C.useState(o?.sessionId||null),[se,ue]=C.useState(o?.erpId||null);C.useEffect(()=>{const ve=Xr(),ke=Gr();ve&&xs.configure({enabled:!0,clevertap:{accountId:ve,region:ke}})},[]);const Ae={partnerCredentials:A,setPartnerCredentials:I,businessId:a,setBusinessId:P,businessName:O,setBusinessName:k,transactions:R,setTransactions:F,selectedTransaction:J,setSelectedTransaction:z,filter:G,setFilter:X,activeTab:ee,setActiveTab:Y,currentPage:U,setCurrentPage:q,hasMore:be,setHasMore:Ne,isLoading:H,setIsLoading:ie,onNavigateHome:me,setOnNavigateHome:Ce,sessionId:ge,setSessionId:V,erpId:se,setErpId:ue};return e.jsx(o0.Provider,{value:Ae,children:u})}function lu(){const u=C.useContext(o0);if(!u)throw new Error("useTransactionContext must be used within a TransactionProvider");return u}const Je=({className:u=""})=>e.jsx("div",{className:`fp:animate-pulse fp:bg-gray-200 fp:rounded ${u}`}),cu=[{label:"All",value:"all"},{label:"Success",value:"success"},{label:"Failure",value:"failed"},{label:"Pending",value:"pending"}],du=[{label:"Last 30 days",value:"30"},{label:"Last 60 days",value:"60"},{label:"Last 90 days",value:"90"},{label:"Custom date range",value:"custom"}],pu=[{label:"All",value:"all"},{label:"UPI",value:"UPI"},{label:"NEFT",value:"NEFT"},{label:"RTGS",value:"RTGS"},{label:"IMPS",value:"IMPS"}],fu=u=>{if(!u)return null;const o=new Date,A=new Date(o.getFullYear(),o.getMonth(),o.getDate()),I=Math.round((A.getTime()-u.from.getTime())/(1e3*60*60*24));return I>=29&&I<=31?"30":I>=59&&I<=61?"60":I>=89&&I<=91?"90":"custom"},uu=u=>{if(u==="custom")return;const o=Number(u),A=new Date,I=new Date;return I.setDate(I.getDate()-o),{from:I,to:A}},xu=({open:u,onClose:o,currentFilter:A,onApply:I})=>{const[a,P]=C.useState(["all"]),[O,k]=C.useState(null),[R,F]=C.useState(null),[J,z]=C.useState(null),[G,X]=C.useState(["all"]);C.useEffect(()=>{if(u){const H=A.statuses;P(H&&H.length>0?H:["all"]);const ie=A.paymentMethods;X(ie&&ie.length>0?ie:["all"]);const me=fu(A.dateRange);k(me),me==="custom"&&A.dateRange?(F(A.dateRange.from),z(A.dateRange.to)):(F(null),z(null))}},[u]);const ee=H=>{if(H==="all"){P(["all"]);return}P(ie=>{const me=ie.filter(Ce=>Ce!=="all");if(me.includes(H)){const Ce=me.filter(ge=>ge!==H);return Ce.length===0?["all"]:Ce}return[...me,H]})},Y=H=>{if(H==="all"){X(["all"]);return}X(ie=>{const me=ie.filter(Ce=>Ce!=="all");if(me.includes(H)){const Ce=me.filter(ge=>ge!==H);return Ce.length===0?["all"]:Ce}return[...me,H]})},U=()=>{P(["all"]),k(null),F(null),z(null),X(["all"])},q=()=>{const H={...A,statuses:a,paymentMethods:G};O&&O!=="custom"?H.dateRange=uu(O):O==="custom"&&R&&J?H.dateRange={from:R,to:J}:H.dateRange=void 0,I(H),o()},be=H=>{O===H?(k(null),F(null),z(null)):(k(H),H!=="custom"&&(F(null),z(null)))},Ne=H=>`fp:px-4 fp:py-2 fp:rounded-full fp:text-[13px] fp:font-medium fp:transition-colors ${H?"fp:bg-[#16558B] fp:text-white":"fp:border fp:border-[#D0D0D0] fp:text-[#222222] fp:bg-white"}`;return e.jsx(ws,{open:u,onClose:o,children:e.jsxs("div",{className:"fp:px-5 fp:pt-5 fp:pb-6",children:[e.jsx("div",{className:"fp:flex fp:justify-center fp:mb-4",children:e.jsx("div",{className:"fp:w-10 fp:h-1 fp:rounded-full fp:bg-[#D0D0D0]"})}),e.jsxs("div",{className:"fp:flex fp:items-center fp:gap-2.5 fp:mb-6",children:[e.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"#16558B",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})}),e.jsx("h2",{className:"fp:text-[18px] fp:font-semibold fp:text-[#222222]",children:"Apply filters"})]}),e.jsxs("div",{className:"fp:mb-5",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:mb-3",children:"Status"}),e.jsx("div",{className:"fp:flex fp:flex-wrap fp:gap-2",children:cu.map(H=>e.jsx("button",{className:Ne(a.includes(H.value)),onClick:()=>ee(H.value),children:H.label},H.value))})]}),e.jsxs("div",{className:"fp:mb-5",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:mb-3",children:"Date Range"}),e.jsx("div",{className:"fp:flex fp:flex-wrap fp:gap-2",children:du.map(H=>e.jsx("button",{className:Ne(O===H.value),onClick:()=>be(H.value),children:H.label},H.value))}),O==="custom"&&e.jsxs("div",{className:"fp:flex fp:gap-3 fp:mt-3",children:[e.jsx("div",{className:"fp:flex-1",children:e.jsx(Yi,{value:R,onChange:F,label:"From",placeholder:"Start date",fullWidth:!0})}),e.jsx("div",{className:"fp:flex-1",children:e.jsx(Yi,{value:J,onChange:z,minDate:R||void 0,label:"To",placeholder:"End date",fullWidth:!0})})]})]}),e.jsxs("div",{className:"fp:mb-6",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:mb-3",children:"Payment Mode"}),e.jsx("div",{className:"fp:flex fp:flex-wrap fp:gap-2",children:pu.map(H=>e.jsx("button",{className:Ne(G.includes(H.value)),onClick:()=>Y(H.value),children:H.label},H.value))})]}),e.jsxs("div",{className:"fp:flex fp:gap-3",children:[e.jsx("button",{onClick:U,className:"fp:flex-1 fp:py-3 fp:rounded-xl fp:border fp:border-[#16558B] fp:text-[#16558B] fp:font-semibold fp:text-[14px] fp:active:scale-[0.97] fp:transition-transform",children:"Clear All"}),e.jsx("button",{onClick:q,className:"fp:flex-1 fp:py-3 fp:rounded-xl fp:bg-[#16558B] fp:text-white fp:font-semibold fp:text-[14px] fp:active:scale-[0.97] fp:transition-transform",children:"Apply"})]})]})})},mu=({status:u})=>{switch(u.toUpperCase()){case"SUCCESS":return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{d:"M8 0.0996094C10.0945 0.101867 12.1029 0.934966 13.584 2.41602C15.065 3.89706 15.8981 5.90548 15.9004 8L15.8945 8.29297C15.8404 9.75276 15.382 11.1709 14.5684 12.3887C13.7003 13.6878 12.4669 14.7009 11.0234 15.2988C9.57995 15.8967 7.99139 16.0528 6.45898 15.748C4.92653 15.4432 3.5189 14.6908 2.41406 13.5859C1.30923 12.4811 0.556776 11.0735 0.251953 9.54102C-0.0528274 8.00861 0.10326 6.42005 0.701172 4.97656C1.29911 3.53309 2.31222 2.29968 3.61133 1.43164C4.82912 0.617965 6.24724 0.159629 7.70703 0.105469L8 0.0996094ZM10.334 2.36426C9.21945 1.90269 7.99273 1.78223 6.80957 2.01758C5.62646 2.253 4.53952 2.83353 3.68652 3.68652C2.83353 4.53952 2.253 5.62645 2.01758 6.80957C1.78223 7.99273 1.90269 9.21945 2.36426 10.334C2.82595 11.4486 3.60819 12.402 4.61133 13.0723C5.61439 13.7424 6.79368 14.0996 8 14.0996C9.61725 14.0978 11.168 13.4551 12.3115 12.3115C13.4551 11.168 14.0978 9.61725 14.0996 8L14.0957 7.77441C14.054 6.64712 13.7006 5.55177 13.0723 4.61133C12.402 3.60819 11.4486 2.82595 10.334 2.36426Z",fill:"#2FB551",stroke:"white",strokeWidth:"0.2"}),e.jsx("g",{transform:"translate(4.5, 5)",children:e.jsx("path",{d:"M5.91895 0.103516C6.03691 0.0926467 6.15642 0.105413 6.26953 0.140625C6.3824 0.175812 6.48733 0.232873 6.57812 0.308594C6.66904 0.384472 6.74396 0.478068 6.79883 0.583008C6.8537 0.687993 6.88803 0.802895 6.89844 0.920898C6.90882 1.03885 6.89501 1.1576 6.85938 1.27051C6.82373 1.38344 6.76666 1.48847 6.69043 1.5791H6.68945L3.35547 5.5791C3.27113 5.68031 3.16618 5.76248 3.04688 5.81836C2.92748 5.87424 2.79687 5.90243 2.66504 5.90234C2.5332 5.90226 2.40254 5.87342 2.2832 5.81738C2.16405 5.76135 2.05877 5.67939 1.97461 5.57812L0.308594 3.57812C0.233081 3.48748 0.175742 3.38313 0.140625 3.27051C0.105548 3.15793 0.0929033 3.03931 0.103516 2.92188C0.114206 2.80428 0.148246 2.68951 0.203125 2.58496C0.257993 2.48043 0.333141 2.38808 0.423828 2.3125C0.514465 2.23697 0.618817 2.17966 0.731445 2.14453C0.84418 2.10941 0.963459 2.09673 1.08105 2.10742C1.19848 2.11816 1.31258 2.15223 1.41699 2.20703C1.52132 2.26181 1.61396 2.33629 1.68945 2.42676H1.69043L2.58887 3.50391L2.66504 3.59668L2.74219 3.50391L5.30859 0.425781C5.38413 0.334582 5.4773 0.259367 5.58203 0.204102C5.6867 0.148897 5.80111 0.114394 5.91895 0.103516Z",fill:"#2FB551",stroke:"white",strokeWidth:"0.2"})})]})});case"FAILED":return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{d:"M8 0.75C12.0041 0.75 15.25 3.99594 15.25 8C15.25 12.0041 12.0041 15.25 8 15.25C3.99594 15.25 0.75 12.0041 0.75 8C0.75 3.99594 3.99594 0.75 8 0.75Z",stroke:"#E80000",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M9.88595 6.11719L6.11475 9.88842",stroke:"#E80000",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("path",{d:"M6.11475 6.11719L9.88598 9.88842",stroke:"#E80000",strokeWidth:"1.5",strokeLinecap:"round"})]})});case"INITIATED":return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsx("svg",{width:"24",height:"24",viewBox:"-2 -1 16 17",fill:"none",children:e.jsx("path",{d:"M0.75 1.00098C0.750262 0.801579 0.97265 0.682461 1.13867 0.792969L10.3359 6.9248C10.4843 7.02376 10.4843 7.24186 10.3359 7.34082L1.13867 13.4727C0.972648 13.5832 0.750262 13.464 0.75 13.2646V1.00098Z",stroke:"#1E88E5",strokeWidth:"1.5"})})});case"PENDING":default:return e.jsx("div",{className:"fp:w-8 fp:h-8 fp:flex fp:items-center fp:justify-center fp:flex-shrink-0",children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 16 16",fill:"none",children:[e.jsx("path",{d:"M8 0.0996094C10.0945 0.101867 12.1029 0.934966 13.584 2.41602C15.065 3.89706 15.8981 5.90548 15.9004 8L15.8945 8.29297C15.8404 9.75276 15.382 11.1709 14.5684 12.3887C13.7003 13.6878 12.4669 14.7009 11.0234 15.2988C9.57995 15.8967 7.99139 16.0528 6.45898 15.748C4.92653 15.4432 3.5189 14.6908 2.41406 13.5859C1.30923 12.4811 0.556776 11.0735 0.251953 9.54102C-0.0528275 8.00862 0.10326 6.42005 0.701172 4.97656C1.29911 3.53309 2.31222 2.29968 3.61133 1.43164C4.82912 0.617965 6.24724 0.159629 7.70703 0.105469L8 0.0996094ZM10.334 2.36426C9.21945 1.90269 7.99273 1.78223 6.80957 2.01758C5.62646 2.253 4.53952 2.83353 3.68652 3.68652C2.83353 4.53952 2.253 5.62646 2.01758 6.80957C1.78223 7.99273 1.90268 9.21945 2.36426 10.334C2.82595 11.4486 3.60819 12.402 4.61133 13.0723C5.61439 13.7424 6.79368 14.0996 8 14.0996C9.61725 14.0978 11.168 13.4551 12.3115 12.3115C13.4551 11.168 14.0978 9.61725 14.0996 8L14.0957 7.77441C14.054 6.64712 13.7006 5.55177 13.0723 4.61133C12.402 3.60819 11.4486 2.82595 10.334 2.36426Z",fill:"#FFA500",stroke:"white",strokeWidth:"0.2"}),e.jsx("path",{d:"M9.58325 10.4995L7.5404 8.9791C7.24263 8.80264 7 8.37804 7 8.03064V5",stroke:"#FFA500",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}},hu=({onNavigateBack:u,onViewTransaction:o})=>{const{businessId:A}=lu(),[I,a]=C.useState([]),[P,O]=C.useState(!0),[k,R]=C.useState(null),[F,J]=C.useState(0),[z,G]=C.useState(!1),[X,ee]=C.useState(0),[Y,U]=C.useState({}),[q,be]=C.useState(!1);C.useEffect(()=>{A&&Ne()},[A,F,Y]);const Ne=async()=>{if(!A){R("Business ID is required"),O(!1);return}try{O(!0),R(null);const ie=await Bf({businessId:A,filter:Y,page:F,size:10});a(F===0?ie.transactions:me=>[...me,...ie.transactions]),ee(ie.totalCount),G(ie.hasMore)}catch(ie){console.error("Error loading transactions:",ie);const me=ie?.response?.data?.errorMessage||ie?.response?.data?.message||ie?.message||"Failed to load transactions. Please try again.";R(me)}finally{O(!1)}},H=ie=>new Date(ie).toLocaleDateString("en-IN",{day:"numeric",month:"short",year:"numeric"});return P&&F===0?e.jsxs("div",{className:"fp:min-h-screen fp:bg-[#F8FCFF]",children:[e.jsxs("div",{className:"fp:bg-[#F8FCFF] fp:px-4 fp:pt-4 fp:pb-3",children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:justify-between fp:mb-3",children:[e.jsx(Je,{className:"fp:w-6 fp:h-6 fp:rounded-full"}),e.jsx(Je,{className:"fp:w-9 fp:h-9 fp:rounded-[10px]"})]}),e.jsx(Je,{className:"fp:w-40 fp:h-7 fp:rounded-lg"})]}),e.jsx("div",{className:"fp:px-4 fp:py-4 fp:space-y-3",children:[1,2,3,4,5].map(ie=>e.jsxs("div",{className:"fp:bg-white fp:rounded-[12px] fp:border fp:border-[#E8EEF8] fp:px-4 fp:py-3.5 fp:flex fp:items-center fp:gap-3",children:[e.jsx(Je,{className:"fp:w-8 fp:h-8 fp:rounded-full fp:flex-shrink-0"}),e.jsxs("div",{className:"fp:flex-1",children:[e.jsx(Je,{className:"fp:w-36 fp:h-3.5 fp:rounded fp:mb-2"}),e.jsx(Je,{className:"fp:w-28 fp:h-3 fp:rounded"})]}),e.jsx(Je,{className:"fp:w-16 fp:h-3.5 fp:rounded fp:flex-shrink-0"})]},ie))})]}):k?e.jsxs("div",{className:"fp:min-h-screen fp:bg-[#F8FCFF]",children:[e.jsxs("div",{className:"fp:bg-[#F8FCFF] fp:px-4 fp:pt-4 fp:pb-3",children:[e.jsx("button",{onClick:u,className:"fp:mb-3 fp:p-1 fp:-ml-1",children:e.jsx("img",{src:we.backButton,alt:"Back",className:"fp:w-6 fp:h-6"})}),e.jsx("h1",{className:"fp:text-2xl fp:font-bold fp:text-[#222222]",children:"Transactions"})]}),e.jsx("div",{className:"fp:flex fp:items-center fp:justify-center fp:min-h-[calc(100vh-80px)] fp:px-4",children:e.jsxs("div",{className:"fp:text-center fp:max-w-md",children:[e.jsx("div",{className:"fp:w-20 fp:h-20 fp:mx-auto fp:mb-4 fp:bg-red-100 fp:rounded-full fp:flex fp:items-center fp:justify-center",children:e.jsx("svg",{className:"fp:w-10 fp:h-10 fp:text-red-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("h2",{className:"fp:text-lg fp:font-semibold fp:text-gray-900 fp:mb-2",children:"Failed to Load"}),e.jsx("p",{className:"fp:text-gray-600 fp:mb-6 fp:text-sm",children:k}),e.jsx("button",{onClick:()=>{J(0),Ne()},className:"fp:bg-[#16558B] fp:text-white fp:font-semibold fp:py-3 fp:px-6 fp:rounded-xl fp:transition-colors",children:"Try Again"})]})})]}):e.jsxs("div",{className:"fp:min-h-screen fp:bg-[#F8FCFF] fp:pb-10",children:[e.jsxs("div",{className:"fp:bg-[#F8FCFF] fp:px-4 fp:pt-4 fp:pb-3",children:[e.jsxs("div",{className:"fp:flex fp:items-center fp:justify-between fp:mb-2",children:[e.jsx("button",{onClick:u,className:"fp:p-1 fp:-ml-1",children:e.jsx("img",{src:we.backButton,alt:"Back",className:"fp:w-6 fp:h-6"})}),e.jsx("button",{onClick:()=>be(!0),className:"fp:w-9 fp:h-9 fp:rounded-[10px] fp:bg-[#EAF2FF] fp:flex fp:items-center fp:justify-center",children:e.jsxs("svg",{className:"fp:w-5 fp:h-5 fp:text-[#16558B]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",strokeWidth:1.8,children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6",strokeLinecap:"round"}),e.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12",strokeLinecap:"round"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18",strokeLinecap:"round"}),e.jsx("circle",{cx:"8",cy:"6",r:"2",fill:"#16558B",stroke:"#16558B"}),e.jsx("circle",{cx:"16",cy:"12",r:"2",fill:"#16558B",stroke:"#16558B"}),e.jsx("circle",{cx:"10",cy:"18",r:"2",fill:"#16558B",stroke:"#16558B"})]})})]}),e.jsx("h1",{className:"fp:text-2xl fp:font-bold fp:text-[#222222]",children:"Transactions"})]}),e.jsx(xu,{open:q,onClose:()=>be(!1),currentFilter:Y,onApply:ie=>{U(ie),J(0),a([])}}),e.jsx("div",{className:"fp:px-4 fp:space-y-3",children:I.length===0&&!P?e.jsxs("div",{className:"fp:flex fp:flex-col fp:items-center fp:justify-center fp:py-20 fp:px-6",children:[e.jsx("div",{className:"fp:w-20 fp:h-20 fp:rounded-full fp:bg-[#D6E8FF] fp:flex fp:items-center fp:justify-center fp:mb-5",children:e.jsx("svg",{className:"fp:w-9 fp:h-9 fp:text-[#16558B]",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}),e.jsx("p",{className:"fp:text-[16px] fp:font-medium fp:text-[#222222] fp:mb-2",children:"No Transactions"}),e.jsx("p",{className:"fp:text-[13px] fp:font-normal fp:text-[#6D6D6D] fp:text-center fp:leading-5",children:"Your payment history will appear here once you make a transaction."})]}):e.jsxs(e.Fragment,{children:[I.map(ie=>e.jsxs("button",{onClick:()=>o(ie),className:"fp:w-full fp:bg-white fp:rounded-[12px] fp:border fp:border-[#E8EEF8] fp:px-4 fp:py-3.5 fp:flex fp:items-center fp:gap-3 fp:text-left fp:active:scale-[0.98] fp:transition-all",children:[e.jsx(mu,{status:ie.status}),e.jsxs("div",{className:"fp:flex-1 fp:min-w-0",children:[e.jsx("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#16558B] fp:leading-[14px] fp:truncate",children:ie.name||ie.supplierName||ie.lenderName||"N/A"}),e.jsxs("p",{className:"fp:text-[12px] fp:font-normal fp:text-[#6D6D6D] fp:leading-[14px] fp:mt-1.5",children:[H(ie.date),"  •  ",ie.paymentMode]})]}),e.jsxs("p",{className:"fp:text-[14px] fp:font-medium fp:text-[#222222] fp:leading-[14px] fp:flex-shrink-0",children:["₹",pt(ie.amount)]})]},ie.transactionId)),z&&e.jsx("div",{className:"fp:flex fp:justify-center fp:pt-2 fp:pb-4",children:e.jsx("button",{onClick:()=>J(F+1),disabled:P,className:"fp:text-sm fp:font-medium fp:text-[#16558B] fp:py-2 fp:px-6 fp:rounded-full fp:border fp:border-[#16558B] fp:disabled:opacity-50 fp:disabled:cursor-not-allowed fp:active:scale-95 fp:transition-transform",children:P?"Loading...":"Load More"})}),!z&&X>0&&e.jsxs("p",{className:"fp:text-center fp:text-xs fp:text-[#6D6D6D] fp:py-4",children:[X," transaction",X!==1?"s":""," total"]})]})})]})},Au=({open:u,onClose:o,transaction:A})=>{const I=C.useRef(null),[a,P]=C.useState(null),[O,k]=C.useState(!1),[R,F]=C.useState(null),[J,z]=C.useState([]),[G,X]=C.useState(!1),[ee,Y]=C.useState(!1),[U,q]=C.useState(""),be=async ne=>{const ye=ne.documentIds.flat().map(qe=>qe.documentId);if(ye.length!==0){Y(!0),q(ne.invoiceNumber),X(!0);try{const qe=await Pf(ye);z(Array.isArray(qe)?qe:[])}catch(qe){console.error("Error fetching documents:",qe),z([])}finally{Y(!1)}}},Ne=()=>{X(!1),z([]),q("")};C.useEffect(()=>{u&&A&&H(),u||(P(null),F(null))},[u,A?.transactionId]);const H=async()=>{if(A){k(!0),F(null);try{const ne=A.source==="LOS"?"LMS":A.source,ye=await kf(A.transactionId,ne);P(ye)}catch(ne){console.error("Error fetching transaction details:",ne);const ye=ne?.response?.data?.errorMessage||ne?.response?.data?.message||ne?.message||"Failed to load details";F(ye)}finally{k(!1)}}};if(!A)return null;const ie=ne=>{const ye=new Date(ne),qe=ye.getDate(),lt=ye.toLocaleDateString("en-IN",{month:"short"}),Ue=ye.getFullYear(),Te=ye.getHours(),Ge=ye.getMinutes().toString().padStart(2,"0"),Re=Te>=12?"PM":"AM",Ve=Te%12||12;return`${qe} ${lt} ${Ue}, ${Ve}:${Ge} ${Re}`},me=ne=>{switch(ne.toUpperCase()){case"SUCCESS":return"fp:text-[#2FB551]";case"FAILED":case"FAILURE":return"fp:text-[#E80000]";case"INITIATED":return"fp:text-[#1E88E5]";case"PENDING":return"fp:text-[#FFA500]";default:return"fp:text-[#6D6D6D]"}},Ce=ne=>{switch(ne.toUpperCase()){case"SUCCESS":return"Success";case"FAILED":case"FAILURE":return"Failed";case"INITIATED":return"Initiated";case"PENDING":return"Pending";default:return ne}},ge=a?.id??A.transactionId,V=a?.amount??A.amount,se=a?.status??A.status,ue=a?.date??A.date,Ae=a?.paymentMode??A.paymentMode,ve=a?.supplierName&&a.supplierName.trim()||A.supplierName||A.name||"",ke=a?.lender||A.lenderName||"",ce=a?.type==="LENDING"||A.transactionType==="LOAN_REPAYMENT",Z=a?.loan?.loans||[],Se=a?.invoice||[],De=A.invoiceNumbers||[],Le=Se.length>0||De.length>0,xe=Se.length>0?Se.map(ne=>ne.invoiceNumber).join(", "):De.join(", "),Be=Se.find(ne=>ne.remark&&ne.remark.trim())?.remark||a?.settlement?.find(ne=>ne.description&&ne.description.trim())?.description||"",Ze=Se.filter(ne=>ne.documentIds&&ne.documentIds.length>0),We=async()=>{let ne=`Transaction Details
666
666
 
667
667
  Transaction ID: ${ge}
668
668
  Paid Amount: ₹${Number(V).toLocaleString("en-IN")}
@@ -1,5 +1,5 @@
1
- import { g as f } from "./index-CREEoAJa.js";
2
- import { r as s } from "./index-CEzdQXZE.js";
1
+ import { g as f } from "./index-CXu6Jk-h.js";
2
+ import { r as s } from "./index-DoadyuNK.js";
3
3
  function c(t, n) {
4
4
  for (var o = 0; o < n.length; o++) {
5
5
  const e = n[o];
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");const e=require("./index-SA0sJUwl.cjs");exports.CleverTapProvider=e.CleverTapProvider;exports.CollectionFlow=e.CollectionFlow;exports.PaymentOptionPage=e.PaymentOptionPage;exports.PaymentProvider=e.PaymentProvider;exports.RepaymentFlow=e.RepaymentFlow;exports.RepaymentProvider=e.RepaymentProvider;exports.TransactionHistory=e.TransactionHistory;exports.TransactionProvider=e.TransactionProvider;exports.analyticsService=e.analyticsService;exports.getAccessToken=e.getAccessToken;exports.sdkConfig=e.sdkConfig;exports.setAccessToken=e.setAccessToken;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");const e=require("./index-OaLaderQ.cjs");exports.CleverTapProvider=e.CleverTapProvider;exports.CollectionFlow=e.CollectionFlow;exports.PaymentOptionPage=e.PaymentOptionPage;exports.PaymentProvider=e.PaymentProvider;exports.RepaymentFlow=e.RepaymentFlow;exports.RepaymentProvider=e.RepaymentProvider;exports.TransactionHistory=e.TransactionHistory;exports.TransactionProvider=e.TransactionProvider;exports.analyticsService=e.analyticsService;exports.getAccessToken=e.getAccessToken;exports.sdkConfig=e.sdkConfig;exports.setAccessToken=e.setAccessToken;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "react/jsx-runtime";
2
- import { h as o, C as r, a as n, P as t, b as i, R as c, c as P, T as d, f as l, e as m, s as p, d as v } from "./index-CREEoAJa.js";
2
+ import { h as o, C as r, a as n, P as t, b as i, R as c, c as P, T as d, f as l, e as m, s as p, d as v } from "./index-CXu6Jk-h.js";
3
3
  export {
4
4
  o as CleverTapProvider,
5
5
  r as CollectionFlow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fundly.ai/payment-sdk",
3
- "version": "1.4.0-beta.8",
3
+ "version": "1.4.0",
4
4
  "description": "Fundly Payment SDK for seamless integration with Fundly Pay systems.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",