PageSourceSearch

https://myka.ng/assets/PolicyDetailPage-DUaoo8cJ.js

js myka.ng collected 2026-10-09 22:41:26 UTC 75,571 bytes, 1 lines download raw bytes

1import{r as u,p as Rt,j as r,d as Tt,l as or}from"./vendor-react-DfYGAhtm.js";import{l as G,e as It,m as l,t as O,aR as ir,g as te,$ as sr,B as Ie,I as it,M as st}from"./index-DsBgCU7r.js";import{E as ar}from"./EmailVerificationModal-BxNiYJiq.js";import"./fnolAccidentDetailsSchema-J33INL6o.js";import"./vendor-forms-BP-7CbAP.js";import{u as lr}from"./useAnalytics-HP01GbIH.js";import{g as ee}from"./errors-BYKXB8DF.js";import{n as ve,c as cr,g as Dt,u as Ke,i as ur}from"./policyProductType-BD61ZnUx.js";import{g as dr}from"./getPolicyClaimEntryPath-DKxxrScc.js";import{u as mr,L as pr}from"./usePaymentReadiness-DQ-J6Nqr.js";import{M as fr}from"./Modal-DS-VW05m.js";import{P as at,g as br,a as gr,u as xr,t as hr,c as yr,r as Cr,b as Sr}from"./PaymentTermsConsentCopy-DOzXQujc.js";import{C as Pr}from"./Checkbox-DwOz6egu.js";import{a as d,h as H,T as m,a9 as Ze,w as fe,H as le,F as R,B as Ce,o as Et,G as Pe,n as jr,s as ke,t as wr,V as lt,S as vr}from"./vendor-ui-DA_r9yXk.js";import{b as Ar,a as Rr,u as Tr,D as Ir,c as Dr,P as Er}from"./paymentReturnUrls-CXEwLwaV.js";import{S as Be}from"./StepPageLayout-DdZUweau.js";import{r as kr}from"./missedContributionRetry-D0dCo6_S.js";import{u as Fr}from"./policiesApi-DYBxVdNQ.js";import{p as et,c as kt,d as Mr,e as Nr,j as Lr,k as Wr,l as _r,m as Or,M as zr}from"./constants-DZgaJSjb.js";import"./normalizeBrand-Cr5Qmi7I.js";import{P as Hr}from"./PolicyContributionFilters-CIXgAXYH.js";import{aG as Br,aM as Ur,aI as Le,p as Gr,aH as Ft,m as $r,S as Vr,g as Mt,az as qr,aN as Ue,i as Yr,aJ as Kr,aC as Qr,z as Jr,aO as Xr}from"./vendor-icons-1odZwi-b.js";import{a as be,f as Zr}from"./currency-tq8RhIEU.js";import{p as Qe,f as Je,C as en,n as tn,b as rn,c as nn,a as Nt,k as on,m as sn,s as an,o as ct,l as ln,t as cn,e as We,d as un,q as Lt,r as dn,u as mn,i as pn}from"./contributionPeriods-BVOAzSfZ.js";import{i as q,P as fn,U as bn,b as gn,c as xn,a as Wt}from"./PolicyStatusCard-CW7LcbtB.js";import{f as hn,h as yn,g as _t}from"./vendor-state-BsBVN-fX.js";import{P as Cn,a as Sn}from"./PolicyContributionPager-BOoAZAgj.js";import{C as Pn}from"./CollapsibleSection-5BGvoOUT.js";import{P as Fe}from"./transactionsApi-CANA4ntQ.js";import"./LinkPaymentMethodOption-CuZHpNDU.js";import{u as jn}from"./educationPolicyApi-BFZ7uOa_.js";import{u as wn}from"./gadgetPolicyApi-C0LGK2Xi.js";import{i as vn}from"./gadgetInspectionFromPolicy-BWnWyYwv.js";import{i as Ot,b as An}from"./healthPolicyActivation-BCt2rMDw.js";import{u as Rn}from"./lifeHospitalPolicyApi-BDmAYPE7.js";import{l as zt,d as Tn,m as In,h as Dn,i as En,j as kn,n as Fn,o as ut,p as Mn}from"./policyDetailFromApi-DMEz0xFY.js";import{u as Nn}from"./savingsPolicyApi-D4i5qSCX.js";import{u as Ln}from"./termLifePolicyApi-DrghAF1t.js";import{i as Wn,h as _n,b as On}from"./router-CbysvjTw.js";import{i as zn,h as Hn,b as Bn}from"./router-Bz1-kiAm.js";import"./transit-insurance-DHaUSpuL.js";import"./fire-BtgY-J44.js";import"./healthCategoryUi-C2_keODf.js";import"./other-icon-DC1bN4dP.js";import"./savings-BJUwUGln.js";import"./routes-BR5I3bEX.js";import"./annuity-retirement-C1dZ1QHM.js";import"./health-ped-DAki1cTK.js";import"./professional-indemnity-Cx_HID73.js";import"./property-building-content-BPs_xKUv.js";import"./property-business-assets-DHEXMjWx.js";import"./property-home-content-BS-RQEdB.js";import"./savings-specialized-hA4moY7S.js";import"./savings-targeted-goals-BG697KhM.js";import"./routes-CNOe4p0Z.js";import"./ocrConfig-B-KSx9JM.js";import"./checkoutSessionStore-BRM5sYZN.js";import"./gadgetPostPaymentFlowConfig-ChCU4qBA.js";import"./routes-Dr23NpA-.js";import"./routes-BTwm__Y5.js";import"./routes-rIK6zvx1.js";import"./routes-D6u-5hjo.js";import"./routes-alBnq1HL.js";import"./routes-SlierU_8.js";import"./walletApi-DyFgHNVA.js";import"./walletMandateApi-Du1GplC_.js";import"./walletMandateSession-B-c6J5GS.js";import"./failed-Dd90HJgP.js";import"./success-C0L8gZxS.js";import"./userEmail-9DwyWHBc.js";import"./useApiQuery-mQnoCtpJ.js";import"./api-BEJchXjA.js";import"./DropdownPopover-KjBTPKBF.js";import"./SelectField-B8rkxDSz.js";import"./underwriterLogoDisplay-B0FBG3Nn.js";import"./underwriterDisplay-CEihXxjA.js";import"./UnderwriterPlanLogo-CdMcnE2i.js";import"./deviceBrandLogos-CnwfDF74.js";import"./useUploader-CBNPOY8T.js";import"./CarLogo-DqMBPg2N.js";import"./cancelled-Dfzba4Al.js";import"./verification_mark-CJRfnqWz.js";import"./phone-ouFZPfGU.js";import"./nigerianPhone-B1rv0Wc5.js";import"./routes-BuiSREd6.js";import"./ProductAuthGate-BV--HzK8.js";import"./routes-Bvg9FlGf.js";const je=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),De=(e,t)=>{const n=e[t];
1return typeof n!="string"?null:n.trim()||null},Ge=e=>{if(!je(e)||typeof e.subscriptionReference!="string")return!1;const t=e.tracker;return je(t)&&Array.isArray(t.cells)},Un=e=>{if(Ge(e))return e;if(!je(e))return null;const t=e.data;return Ge(t)?t:je(t)&&Ge(t.data)?t.data:null},Gn=e=>{if(je(e)&&typeof e.message=="string"){const t=e.message.trim();if(t)return t}return"Failed to load contribution history"},Ht=e=>{if(e==null)return null;const t=e;return De(t,"subscriptionReference")??De(t,"subscription_reference")??De(t,"engineReference")??De(t,"engine_reference")},Bt=e=>{if(e==null||typeof e!="object")return null;const t=e,n=typeof t.name=="string"?t.name.trim():"",o=typeof t.description=="string"?t.description.trim():"";return!n&&!o?null:{name:n||"Coverage item",description:o||"N/A"}},dt=e=>Array.isArray(e)?e.map(Bt).filter(t=>t!=null):[],$n=e=>{if(Array.isArray(e)){const t=dt(e);return t.length>0?[{title:null,items:t}]:[]}return e==null||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({title:t.trim()||null,items:dt(n)})).filter(t=>t.items.length>0)},Vn=e=>{const t=e,n=[t.coverageDetails];for(const[o,i]of Object.entries(t))o!=="details"&&!o.endsWith("Details")||i==null||typeof i!="object"||Array.isArray(i)||n.push(i.coverageDetails);return n},tt=e=>{if(e==null)return[];for(const n of Vn(e)){const o=$n(n);if(o.length>0)return o}if(e.details==null||typeof e.details!="object")return[];const t=Object.entries(e.details).filter(([n])=>/^\d+$/.test(n)).sort(([n],[o])=>Number(n)-Number(o)).map(([,n])=>Bt(n)).filter(n=>n!=null);return t.length>0?[{title:null,items:t}]:[]},qn=new Set(["QUOTED","PENDING_PAYMENT","FAILED_PAYMENT"]),Se=e=>{if(e==null||e==="")return null;if(typeof e=="number")return Number.isFinite(e)&&e>0?e:null;if(typeof e!="string")return null;const t=Number(e.replace(/,/g,"").trim());return Number.isFinite(t)&&t>0?t:null},$e=e=>e==null?null:Se(e.coverPremium)??Se(e.cover_premium)??Se(e.lifeCoverPremium),Me=e=>e!=null&&typeof e=="object"&&!Array.isArray(e)?e:null,Yn=e=>{const t=Me(e.details),n=Se(t?.frequencyAmount);if(n!=null)return n;const o=Me(e.lifeDetails);return Se(o?.frequencyAmount)},Ut=e=>{const t=e,n=$e(t);if(n!=null)return n;const o=$e(Me(e.details));if(o!=null)return o;const i=$e(Me(t.lifeDetails));if(i!=null)return i;const s=e.coverageBreakdown?.find(c=>/life cover|term life/i.test(c.name));return s!=null&&s.amount>0?s.amount:0},Kn=e=>ve(e.productType)==="LIFE_SAVINGS"&&qn.has(e.status.trim().toUpperCase()),Qn=e=>{if(e==null)return;const t=et(e.premium);if(t==null)return;if(!Kn(e))return t;const n=Ut(e);if(n<=0)return t;const o=Yn(e);return o!=null&&t>=o+n?t:t+n},Gt=e=>{const t=e?.transactions;return t==null?[]:(Array.isArray(t)?t:[t]).filter(o=>o!=null&&typeof o=="object"&&(o.amount!=null||o.status!=null||o.paidAt!=null))},$t=e=>{const t=n=>{const o=n.paidAt??n.createdAt,i=o?new Date(o).getTime():Number.NaN;return Number.isNaN(i)?0:i};return[...e].sort((n,o)=>t(o)-t(n))},Jn=e=>{const t=e?.trim();if(!t)return"N/A";const n=t.toLowerCase().replace(/_/g," ");return n.charAt(0).toUpperCase()+n.slice(1)},Vt=e=>e.ourReference?.trim()||e.engineReference?.trim()||e.id?.trim()||null,Xn={LIFE_SAVINGS:{category:"Savings Plan",coveredItem:"Savings Target",providerFallback:"Myka Savings",benefitRowLabel:"Target Amount",showWithdrawal:!0},EDUCATION_SAVINGS:{category:"Education Savings",coveredItem:"Education Savings",providerFallback:"Myka Education",benefitRowLabel:"Target Amount",showWithdrawal:!0},TERM_LIFE:{category:"Term Life",coveredItem:"Life Cover",providerFallback:"Myka Life",benefitRowLabel:"Sum Assured",showWithdrawal:!1}},Zn=e=>{const t=e.trim().toLowerCase().replace(/_/g," ");return t?t.charAt(0).toUpperCase()+t.slice(1):""},mt=e=>{if(e==null||e==="")return null;if(typeof e=="number")return Number.isFinite(e)?e:null;const t=Number(String(e).replace(/,/g,"").trim());return Number.isFinite(t)?t:null},we=(e,t)=>e==null?"—":be(e,t??"NGN"),eo=e=>e.details==null||typeof e.details!="object"?null:e.details,to=(e,t)=>{const n=mt(t?.benefitAmount);if(n!=null&&n>0)return n;if(e.totalCoverage!=null&&Number.isFinite(e.totalCoverage))return e.totalCoverage;if(e.details!=null&&typeof e.details=="object"){const o=e.details.sumInsured,i=mt(o);if(i!=null&&i>0)return i}return null},ro=e=>{for(const t of tt(e))for(const n of t.items){if(!`${n.name} ${n.description}`.toLowerCase().includes("interest"))continue;const i=`${n.name} ${n.description}`.match(/(\d+(?:\.\d+)?\s*%[^,]*)/i);if(i?.[1])return i[1].trim();if(n.description.trim()&&n.description.trim()!=="N/A")return n.description.trim()}return null},no=(e,t,n,o)=>{const i=tt(e);if(i.length>0)return i.flatMap(a=>a.items.map(f=>({label:f.name,value:f.description.trim()&&f.description.trim()!=="N/A"?f.description.trim():"Included"})));const s=[];n!=null&&s.push({label:t.benefitRowLabel,value:we(n,o)});const c=ro(e);return c&&s.push({label:"Interest Rate",value:c}),s},oo=(e,t,n,o)=>
1{if(ve(e.productType)!=="LIFE_SAVINGS"||t.some(c=>/life cover|term life/i.test(c.label)))return t;const i=Ut(e);if(i<=0)return t;const s=n!=null&&n>0?`Term Life Cover (${we(n,o)})`:"Term Life Cover";return[...t,{label:s,value:we(i,o)}]},io=e=>{const t=e?.trim().toUpperCase()??"";return t==="SUCCESS"||t==="SUCCESSFUL"||t==="COMPLETED"||t==="PAID"},so=e=>{const t=ve(e);return t==="LIFE_SAVINGS"||t==="EDUCATION_SAVINGS"||t==="TERM_LIFE"?t:null},ao=e=>{const t=so(e.productType);if(t==null)return null;const n=Xn[t],o=eo(e),i=e.currency??"NGN",s=et(e.premium),c=to(e,o),a=o?.frequency?.trim()??"",f=a?Zn(a):"",p=e.underwriterProductName?.trim()||n.category,b=e.policyNumber?.trim()||e.ourReference?.trim()||"N/A",S=e.underwriter?.trim()||n.providerFallback,j=e.deductible!=null&&Number.isFinite(e.deductible)?e.deductible:0,h=o?.beneficiaries??e.beneficiaries??[],g=$t(Gt(e)).find(P=>io(P.status)),w=G(e.startDate,{preset:"gb-short",fallback:"—"}),x=G(e.endDate,{preset:"gb-short",fallback:"—"});return{product:t,category:n.category,planTitle:p,reference:b,statusLabel:kt(e.status),statusRaw:e.status,premiumDisplay:we(s,i),premiumAmount:s,frequencyLabel:f,startDateDisplay:w,endDateDisplay:x,startDateIso:e.startDate??null,endD
1ateIso:e.endDate??null,coveredItem:n.coveredItem,provider:S,deductibleDisplay:we(j,i),coverageRows:oo(e,no(e,n,c,i),c,i),beneficiaries:h,showWithdrawal:n.showWithdrawal,agentName:"—",agentCode:"—",latestReceiptRef:g?Vt(g):null,latestReceiptDateIso:g?.paidAt??g?.createdAt??null,durationDisplay:w!=="—"&&x!=="—"?`${w} - ${x}`:"—",currency:i,productType:e.productType}},lo=e=>{const t=e.trim().toLowerCase().replace(/_/g," ");return t?t.charAt(0).toUpperCase()+t.slice(1):""},Ve=e=>{const t=Je(e);return t==null?null:new Date(t.year,t.month-1,t.day)},co=({tracker:e,view:t})=>{const n=Ve(e?.details?.nextDueDate??e?.summary?.nextDueDate??null),o=G(n,{preset:"gb-short",fallback:"—"}),i=Qe(e?.details?.nextAmount)??Qe(e?.summary?.nextDueAmount)??t.premiumAmount,s=i!=null?be(i,e?.subscription?.currency??t.currency):t.premiumDisplay,c=e?.details?.frequency?.trim()||e?.subscription?.frequency?.trim()||"",a=c?lo(c):t.frequencyLabel,f=e?.details?.beneficiary?.trim()||e?.policy?.beneficiaryName?.trim()||t.beneficiaries.find(h=>h.name?.trim())?.name.trim()||"—",p=Ve(e?.details?.duration?.from),b=Ve(e?.details?.duration?.to),S=p!=null&&b!=null?`${G(p,{preset:"gb-short"})} - ${G(b,{preset:"gb-short"})}`:t.durationDisplay,j=(e?.tracker?.cells??[]).filter(h=>{const C=h.state?.trim().toUpperCase();return(C==="PAID"||C==="PAID_LATE"||C==="PREPAID")&&h.paidAt}).at(-1);return{nextDueDateDisplay:o,nextAmountDisplay:s,frequencyLabel:a,beneficiaryName:f,durationDisplay:S,latestReceiptDateIso:j?.paidAt??t.latestReceiptDateIso}},K=e=>{const t=e?.trim();return t||null},uo=(e,t)=>{const n=K(t?.details?.frequency)||K(t?.subscription?.frequency);if(n)return n;const o=e.details!=null&&typeof e.details=="object"?e.details:null;return K(o?.frequency??null)},mo=(e,t)=>uo(e,t)!=null,po=e=>({startDateIso:K(e.subscription?.startDate)||K(e.details?.duration?.from),endDateIso:K(e.subscription?.endDate)||K(e.details?.duration?.to),source:"contribution"}),pt=e=>({startDateIso:K(e.startDate),endDateIso:K(e.endDate),source:"policy"}),fo=({policy:e,tracker:t=null})=>mo(e,t)&&t!=null?po(t):pt(e),bo=(e,t)=>q(e??"")&&q(t??""),rt=["life-policy","tracker"],qt=async(e,t={})=>{const n=!!t.from&&!!t.to,{data:o}=await It.get(`/api/v1/life-policy/${encodeURIComponent(e)}/tracker`,{timeout:en,params:{...n?{from:t.from,to:t.to}:{},...t.limit!=null?{limit:t.limit}:{},...t.status?{status:t.status}:{}}}),i=Un(o);if(i==null)throw new Error(Gn(o));return i},ft=({productType:e,subscriptionReference:t,from:n,to:o,limit:i,status:s,enabled:c=!0})=>{const a=cr(e,t),f=t?.trim()??"",p=a&&c&&!!f,{data:b,isLoading:S,isError:j,error:h,refetch:C,isFetching:g}=hn({queryKey:[...rt,f,n??null,o??null,s??null,i??null],queryFn:()=>qt(f,{from:n,to:o,limit:i,status:s}),enabled:p,refetchOnWindowFocus:!1,retry:!1});return{tracker:b??null,isLoading:p&&S,isFetching:g,isError:p&&j,error:h,refetch:C}},go=e=>{if(e==="SEMI_ANNUAL")return"Semi-annual";const t=e.toLowerCase().replace(/_/g," ");return t.charAt(0).toUpperCase()+t.slice(1)},xo=(e,t)=>{const n=Je(e),o=Je(t);return n==null||o==null?!1:n.year<o.year||n.year===o.year&&n.month<o.month||n.year===o.year&&n.month===o.month&&n.day<=o.day},ho=e=>{const t=e?.summary;if(t==null)return null;const n=Qe(t.totalSaved);return n==null?null:{totalSaved:n,totalSavedDisplay:be(n,e?.subscription?.currency?.trim()||"NGN"),paidInstallments:t.paidInstallments,cycles:t.cycles}},yo=({productType:e,subscriptionReference:t,enabled:n=!0})=>{const[o,i]=u.useState(null),[s,c]=u.useState(null),[a,f]=u.useState(""),[p,b]=u.useState(""),[S,j]=u.useState("native"),h=ft({productType:e,subscriptionReference:t,enabled:n}),C=tn(h.tracker?.subscription?.frequency??h.tracker?.tracker?.frequency),g=h.tracker?.subscription?.startDate?.trim()??"",w=h.tracker?.subscription?.endDate?.trim()??"",x=C!=null&&ln(C),P=x?S:"native",L=x&&P==="months",A=C==null?null:L?"MONTHLY":C,D=u.useMemo(()=>A==null||!g||!w?[]:rn(A,g,w,cn(A,L)),[A,g,w,L]),T=D.length===0?0:Math.min(o??nn(D,Nt()),D.length-1),M=D[T]??null,v=u.useMemo(()=>xo(a,p)?{from:a,to:p}:null,[a,p]),E=s!=null||v!=null,I=v?.from??(s!=null?g:M?.from),k=v?.to??
1(s!=null?w:M?.to),F=u.useMemo(()=>C==null||!g||!w||I==null||k==null?null:v!=null||s!=null?on(C,g,w,I,k):M?.cells.length??null,[C,g,w,I,k,v,s,M]),N=!!h.tracker&&!!I&&!!k&&F!=null&&F>0,W=ft({productType:e,subscriptionReference:t,...I?{from:I}:{},...k?{to:k}:{},...F!=null?{limit:F}:{},...s?{status:s}:{},enabled:n&&N}),y=u.useMemo(()=>{const $=W.tracker?.tracker?.cells??[];if(s!=null)return sn($);if(v!=null&&C!=null&&A!=null){const oe=an(A,g,w,v.from,v.to);return ct(C,oe,$)}return M==null||C==null?[]:ct(C,M.cells,$)},[s,v,C,A,g,w,M,W.tracker]),z=$=>{j($),i(null)},U=()=>{E||T<=0||i(T-1)},Q=()=>{E||T>=D.length-1||i(T+1)},re=()=>{h.refetch(),W.refetch()},J=E&&N&&W.isLoading,ne=!E&&N&&W.isLoading&&W.tracker==null;return{baseTracker:h.tracker,summary:ho(h.tracker),frequency:C,frequencyLabel:C==null?"":go(C),canExpand:x,viewToggle:P,setViewToggle:z,pages:D,pageIndex:T,pageCount:D.length,pageTitle:M?.title??"",canGoPrev:!E&&T>0,canGoNext:!E&&T<D.length-1,goToPrevPage:U,goToNextPage:Q,cells:y,view:A,isFilterOn:E,statusFilter:s,setStatusFilter:c,rangeFrom:a,rangeTo:p,termStart:g,termEnd:w,setRangeFrom:f,setRangeTo:b,clearFilters:()=>{c(null),f(""),b("")},isBaseLoading:h.isLoading,isPageLoading:ne,isLooking:J,isBaseError:h.isError,isPageError:W.isError,hasPlan:D.length>0,isPeriodEmpty:v!=null&&s==null&&F===0,currency:h.tracker?.subscription?.currency?.trim()||"NGN",refetchAll:re}},Co=5e3,So="myka:contribution-tracker-hold:",Po=e=>`${So}${e}`,jo=e=>e?.trim()||"success",Xe=({startedAt:e,now:t,holdMs:n=Co})=>Math.max(0,n-(t-e)),wo=e=>{if(e==null)return null;try{const t=JSON.parse(e);if(t==null||typeof t!="object"||Array.isArray(t))return null;const n=t,o=Number(n.startedAt),i=typeof n.paymentReference=="string"?n.paymentReference.trim():"";return!Number.isFinite(o)||!i?null:{startedAt:o,paymentReference:i}}catch{return null}},vo=e=>{try{return wo(sessionStorage.getItem(e))}catch{return null}},Ao=({key:e,record:t})=>{try{sessionStorage.setItem(e,JSON.stringify(t))}catch{}},Ro=({storageKey:e,isPaymentSuccess:t,paymentReference:n,now:o})=>{const i=vo(e),s=i==null?0:Xe({startedAt:i.startedAt,now:o});if(t){if(!(i==null||i.paymentReference!==n))return i;const a={startedAt:o,paymentReference:n};return Ao({key:e,record:a}),a}return i!=null&&s>0?i:null},To=({policyId:e})=>{const[t]=Rt(),n=t.get("payment")==="success",o=jo(t.get("reference")??t.get("trxref")),i=Po(e),[s,c]=u.useState(()=>Date.now()),a=Ro({storageKey:i,isPaymentSuccess:n,paymentReference:o,now:s}),p=(a==null?0:Xe({startedAt:a.startedAt,now:Math.max(s,a.startedAt)}))>0,b=a?.startedAt;return u.useEffect(()=>{if(!p||b==null)return;const S=Xe({startedAt:b,now:Date.now()}),j=window.setTimeout(()=>{c(Date.now())},S);return()=>window.clearTimeout(j)},[p,b]),{isHolding:p}},Io=(e,t)=>{const n=G(t.startDateIso,{preset:"gb-short",fallback:"—"}),o=G(t.endDateIso,{preset:"gb-short",fallback:"—"});return{...e,startDateIso:t.startDateIso,endDateIso:t.endDateIso,startDateDisplay:n,endDateDisplay:o,durationDisplay:n!=="—"&&o!=="—"?`${n} - ${o}`:"—"}},Do=e=>{const t=u.useMemo(()=>ao(e),[e]),n=u.useMemo(()=>Ht(e),[e]),o=To({policyId:e.id}),i=yo({productType:e.productType,subscriptionReference:n,enabled:!o.isHolding}),s=u.useMemo(()=>t==null?null:fo({policy:e,tracker:i.baseTracker}),[t,e,i.baseTracker]),c=u.useMemo(()=>t==null||s==null?null:Io(t,s),[t,s]),a=u.useMemo(()=>c==null?null:co({tracker:i.baseTracker,view:c}),[i.baseTracker,c]);return{view:c,meta:a,coverageDates:s,tracker:i,hold:o}},nt="myka:missed-contribution-retry-watches",Eo=15e3,Yt=6e4,ko=4,Fo=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),xe=(e,t)=>{const n=e[t];return typeof n!="string"?null:n.trim()||null},Mo=e=>{if(!Fo(e))return null;const t=xe(e,"invoiceReference"),n=xe(e,"sourceInvoiceReference"),o=xe(e,"subscriptionReference"),i=xe(e,"policyId"),s=xe(e,"dueDate"),c=Number(e.startedAt),a=Number(e.attempts??0),f=e.amount,p=typeof f=="number"&&Number.isFinite(f)?f:f==null?null:Number(f);return t==null||o==null||i==null||s==null||!Number.isFinite(c)?null:{
1invoiceReference:t,sourceInvoiceReference:n,subscriptionReference:o,policyId:i,dueDate:s,amount:p!=null&&Number.isFinite(p)?p:null,startedAt:c,attempts:Number.isFinite(a)&&a>=0?Math.floor(a):0}},No=e=>{if(e==null||!e.trim())return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.map(Mo).filter(n=>n!=null):[]}catch{return[]}},Lo=e=>JSON.stringify(e),Kt=()=>{try{return No(localStorage.getItem(nt))}catch{return[]}},Qt=e=>{try{localStorage.setItem(nt,Lo(e))}catch{}},Wo=e=>{const t=We(e);return t==="PAID"||t==="PAID_LATE"||t==="PREPAID"},_o=e=>We(e)==="PENDING",Jt=({watches:e,now:t,maxAgeMs:n=Yt})=>e.filter(o=>t-o.startedAt<n),Xt=({watches:e,subscriptionReference:t})=>{const n=t.trim();return n?e.filter(o=>o.subscriptionReference===n):[]},Oo=({watches:e,watch:t,now:n=Date.now()})=>{const o=t.invoiceReference.trim(),i=t.subscriptionReference.trim(),s=t.policyId.trim(),c=t.dueDate.trim().slice(0,10);if(!o||!i||!s||!c)return[...e];const a=t.sourceInvoiceReference?.trim()||null,f={invoiceReference:o,sourceInvoiceReference:a,subscriptionReference:i,policyId:s,dueDate:c,amount:t.amount,startedAt:t.startedAt??n,attempts:t.attempts??0};return[...e.filter(b=>!(b.invoiceReference===o||a!=null&&(b.invoiceReference===a||b.sourceInvoiceReference===a))),f]},bt=({watches:e,invoiceReference:t})=>{const n=t.trim();return n?e.filter(o=>o.invoiceReference!==n):[...e]},zo=({watches:e,invoiceReference:t})=>{const n=t.trim();return e.map(o=>o.invoiceReference===n?{...o,attempts:o.attempts+1}:o)},gt=({cells:e,invoiceReference:t})=>{const n=t.trim();return n?e.find(o=>o.invoiceReference?.trim()===n)??null:null},Ho=({cells:e,watch:t})=>{const n=gt({cells:e,invoiceReference:t.invoiceReference});if(n!=null)return n;const o=t.sourceInvoiceReference?.trim();return o==null||o===t.invoiceReference?null:gt({cells:e,invoiceReference:o})},Bo=({watch:e,cells:t,now:n,maxAttempts:o,maxAgeMs:i})=>{if(n-e.startedAt>=i||e.attempts>=o)return"timed_out";const s=Ho({cells:t,watch:e});return s==null?"awaiting":Wo(s.state)?"paid":_o(s.state)?"in_flight":"awaiting"},Uo=(e,t)=>{if(e.length===0)return null;const n=e.map(c=>c.dueDate.trim().slice(0,10)).filter(Boolean).sort();if(n.length===0)return null;const o=n[0],i=n[n.length-1],s=i>t?i:t;return{from:o,to:s,limit:Math.max(e.length+8,24)}},Go=(e,t)=>t.size===0?[...e]:e.map(n=>{const o=n.invoiceReference?.trim();return o==null||!t.has(o)||We(n.state)!=="MISSED"?n:{...n,state:"PENDING"}}),$o=e=>{const t=new Set;for(const n of e){const o=n.invoiceReference.trim();o&&t.add(o);const i=n.sourceInvoiceReference?.trim();i&&t.add(i)}return t},Zt=({policy:e,isMotor:t,isGadget:n,isTermLife:o,isSavings:i,isIndividualHealth:s,isAutoActivateBusy:c,isActivatingMotorPolicy:a,isSubmittingGadgetPolicy:f,isSubmittingSavingsPolicy:p,onMakePayment:b,onActivateMotorPolicy:S,onActivateGadgetPolicy:j,onActivateSavingsPolicy:h,onActivateTermLifePolicy:C,onActivateIndividualHealthPolicy:g,onRenewPolicy:w})=>{const x={},P=e.status.toUpperCase();return(P==="PENDING_PAYMENT"||P==="QUOTED"||P==="FAILED_PAYMENT")&&(x.onMakePayment=b),P==="PAID"&&t&&(x.onActivatePolicy=S,x.isActivatingPolicy=a||c),P==="PAID"&&n&&(x.onActivatePolicy=j,x.isActivatingPolicy=f),P==="PAID"&&o&&(x.onActivatePolicy=C,x.isActivatingPolicy=p),P==="PAID"&&i&&(x.onActivatePolicy=h,x.isActivatingPolicy=p),P==="PAID"&&s&&(x.onActivatePolicy=g),(P==="EXPIRED"||P==="ACTIVE")&&(x.onRenewPolicy=w),x},Vo=e=>{if(e==null||typeof e!="object")return null;const n=e.sumInsured;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n;if(typeof n=="string"){const o=Number(n.replace(/,/g,"").trim());if(Number.isFinite(o)&&o>0)return o}return null},pe=({label:e,value:t})=>q(t)?r.jsxs(d,{minW:0,children:[r.jsx(m,{fontSize:"sm",fontWeight:"medium",color:l.text.subtle,mb:1,children:e}),r.jsx(m,{fontSize:"md",fontWeight:"medium",color:l.text.primary,truncate:!0,title:t,children:t})]}):null,xt=({label:e,dateIso:t})=>{const n=G(t,{preset:"gb-short",fallback:""});return q(n)?r.jsxs(d,{minW:0,children:[r.jsx(m,{fontSize:"sm",fontWeight:"medium",color:l.text.subtle,mb:1,children:e}),r.jsxs(le,{gap:2,minW:0,align:"center",children:[r.jsx(Br,{size:18,color:l.orange[500],style:{flexShrink:0},"aria-hidden":!0}),r.jsx(m,{fontSize:"md",fontWeight:"medium",color:l.text.primary,children:n})]})]}):null},er=({policy:e,hideRedundantFields:t=!1,coverageDates:n})=>{const o=kt(e.status),i=Mr(e.status),s=Nr(e.productType),c=Dt(e.productType),a=c==="MOTOR"?Lr(e.usageType):e.underwriterProductName?.trim()||e.usageType?.trim()||"",f=Wr(e),p=et(e.premium),b=p!=null?be(p,e.currency??"NGN"):"",S=n?.startDateIso??e.startDate,j=n?.endDateIso??e.endDate,h=bo(S,j)?_r(j):"",C=Vo(e.details),g=C!=null?be(C,e.currency??"NGN"):null,w=Or(e.productType);return r.jsx(d,{borderRadius:"xl",border:"1px solid",borderColor:l.border.primary,bg:l.white.DEFAULT,px:{base:4,md:5},py:{base:4,md:5},maxW:"100%",minW:0,overflow:"hidden",children:r.jsxs(H,{gap:5,align:"stretch",children:[r.jsxs(d,{children:[r.jsx(m,{fontSize:"md",fontWeight:"bold",color:l.text.primary,children:"Policy Information"}),r.jsx(Ze,{mt:3,borderColor:"rgba(0,0,0,0.06)"})]}),r.jsx(d,{w:"full",children:r.jsx(fn,{policy:e,hideBeneficiaryCount:t})}),r.jsxs(fe,{columns:{base:1,md:3},gap:{base:4,md:8},children:[r.jsx(pe,{label:"Insurance type",value:s}),r.jsx(pe,{label:"Coverage type",value:a}),r.jsx(bn,{underwriterName:e.underwriter?.trim()??""})]}),r.jsxs(fe,{columns:{base:1,md:t?1:2},gap:{base:4,md:8},children:[r.jsx(pe,{label:"Policy",value:f}),t?null:r.jsxs(d,{minW:0,children:[r.jsx(m,{fontSize:"sm",fontWeight:"medium",color:l.text.subtle,mb:1,children:"Status"}),r.jsx(d,{display:"inline-flex",alignItems:"center",px:3,py:1,borderRadius:"full",bg:i.bg,children:r.jsx(m,{fontSize:"sm",fontWeight:"semibold",color:i.color,children:o})})]})]}),t?null:r.jsxs(fe,{columns:{base:1,md:3},gap:{base:4,md:8},children:[r.jsx(xt,{label:"Start date",dateIso:S}),r.jsx(xt,{label:"End date",dateIso:j}),q(h)&&r.jsx(pe,{label:"Days remaining",value:h})]}),(g!=null||!t&&q(b))&&r.jsxs(fe,{columns:{base:1,md:3},gap:{base:4,md:6},children:[g!=null&&r.jsx(pe,{label:w,value:g}),!t&&q(b)&&r.jsx(pe,{label:"Premium",value:b})]}),c==="HEALTH"&&e.details!=null&&r.jsx(gn,{dependents:e.details.dependents}),(c==="LIFE"||c==="GROUP_LIFE"||c==="SAVINGS")&&r.jsx(xn,{beneficiaries:e.details?.beneficiaries??e.beneficiaries})]})})},qe={h:"44px",px:5,borderRadius:"full",fontSize:"14px",fontWeight:"medium",bg:"white"},qo=({showWithdrawal:e,isDownloadDisabled:t=!1,onDownloadCert:n,onGetHelp:o})=>{const i=()=>{O.message("Withdrawals coming soon.")};return r.jsxs(R,{gap:4,align:"center",wrap:"wrap",pb:6,pt:2,borderBottom:"1px solid",borderColor:"#F3F4F6",children:[e?r.jsxs(Ce,{type:"button",...qe,border:"1px solid",disabled:!0,borderColor:"#E46921",color:"#E46921",boxShadow:"0px 1px 1.5px rgba(0,0,0,0.1), 0px 1px 1px rgba(0,0,0,0.1)",onClick:i,_hover:{bg:l.orange[50]},children:[r.jsx(Ur,{size:16}),r.jsx(m,{as:"span",ml:2,children:"Make Withdrawal"})]}):null,r.jsxs(Ce,{type:"button",...qe,border:"1px solid",borderColor:l.gray[200],color:l.text.label,disabled:t,onClick:n,_hover:{bg:l.gray[50]},children:[r.jsx(Le,{size:16}),r.jsx(m,{as:"span",ml:2,children:"Download Cert"})]}),r.jsx(d,{flex:"1",minW:0,display:{base:"none",sm:"block"}}),r.jsx(Ce,{type:"button",...qe,border:"1px solid",borderColor:l.gray[200],color:l.text.label,onClick:o,_hover:{bg:l.gray[50]},children:"Get Help"})]})},Yo="/assets/card-coin-Bo8F-MB5.png",Ko="#0D7C3D",Ee=({label:e,value:t,hint:n,valueFontSize:o="16px",valueLineHeight:i="24px",testId:s})=>r.jsxs(d,{...s!=null?{"data-testid":s}:{},bg:"rgba(0,0,0,0.2)",borderRadius:"12px",p:4,minW:0,display:"flex",flexDirection:"column",gap:"4px",alignSelf:"stretch",children:[r.jsx(m,{fontSize:"12px",color:"rgba(255,255,255,0.7)",lineHeight:"18px",children:e}),r.jsx(m,{fontSize:o,fontWeight:"semibold",color:"white",lineHeight:i,truncate:!0,title:t,children:t}),n?r.jsx(m,{fontSize:"11px",color:"rgba(255,255,255,0.6)",lineHeight:"16.5px",children:n}):null]}),Qo=({view:e,summary:t,isSummaryLoading:n=!1})=>r.jsxs(d,{position:"relative",overflow:"hidden",borderRadius:"20px",boxShadow:"0px 8px 30px rgba(0,0,0,0.1)",w:"full",children:[r.jsxs(d,{"aria-hidden":!0,position:"absolute",inset:0,borderRadius:"20px",pointerEvents:"none",children:[r.jsx(d,{position:"absolute",inset:0,bg:Ko,borderRadius:"20px"}),r.jsx(Et,{src:Yo,alt:"",position:"absolute",inset:0,w:"100%",h:"100%",objectFit:"cover",opacity:.2,borderRadius:"20px"})]}),r.jsx(d,{"aria-hidden":!0,position:"absolute",inset:0,opacity:.1,pointerEvents:"none",style:{backgroundImage:`url("data:image/svg+xml;utf8,<svg viewBox='0 0 736 253' xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none'><rect width='100%' height='100%' fill='url(%23g)'/><defs><radialGradient id='g' gradientUnits='userSpaceOnUse' cx='0' cy='0' r='10' gradientTransform='matrix(0 -39 -39 0 368 126.5)'><stop stop-color='rgb(255,255,255)' offset='0'/><stop stop-color='rgb(255,255,255)' stop-opacity='0' offset='1'/></radialGradient></defs></svg>")`,backgroundSize:"100% 100%"}}),r.jsxs(R,{direction:"column",gap:4,position:"relative",p:6,children:[r.jsxs(R,{justify:"space-between",align:"flex-start",ga
1p:3,children:[r.jsxs(d,{minW:0,flex:1,children:[r.jsx(m,{fontSize:"14px",color:"rgba(255,255,255,0.8)",lineHeight:"21px",children:e.category}),r.jsx(m,{fontFamily:"heading",fontSize:{base:"22px",md:"28px"},fontWeight:"semibold",color:"white",letterSpacing:"-0.5px",mt:"4px",lineHeight:{base:"28px",md:"33.6px"},children:e.planTitle}),r.jsxs(m,{fontSize:"13px",color:"rgba(255,255,255,0.8)",mt:"4px",lineHeight:"19.5px",children:["Ref:"," ",r.jsx(m,{as:"span",fontWeight:"medium",color:"white",children:e.reference})]})]}),r.jsx(d,{px:3,py:1.5,borderRadius:"full",bg:"rgba(255,255,255,0.2)",border:"1px solid",borderColor:"rgba(255,255,255,0.3)",backdropFilter:"blur(8px)",flexShrink:0,children:r.jsx(m,{fontSize:"13px",fontWeight:"medium",color:"white",lineHeight:"19.5px",children:e.statusLabel})})]}),r.jsxs(Pe,{templateColumns:{base:"repeat(2, 1fr)",md:t!=null||n?"repeat(4, 1fr)":"repeat(3, 1fr)"},gap:4,pt:2,children:[t!=null||n?r.jsx(Ee,{label:"Total Saved",value:n?"—":t?.totalSavedDisplay??"—",testId:"contribution-summary"}):null,r.jsx(Ee,{label:"Premium",value:e.premiumDisplay}),r.jsx(Ee,{label:"Start Date",value:e.startDateDisplay,valueFontSize:"15px",valueLineHeight:"22.5px"}),r.jsx(Ee,{label:"End Date",value:e.endDateDisplay,valueFontSize:"15px",valueLineHeight:"22.5px"})]})]})]}),tr="#F6F9FF",rr="#D8DEEA",Jo=({rows:e})=>e.length===0?null:r.jsxs(d,{bg:tr,border:"1px solid",borderColor:rr,borderRadius:"16px",p:"20px",children:[r.jsx(m,{fontSize:"16px",fontWeight:"semibold",color:l.text.label,mb:4,lineHeight:"1.5",children:"Coverage Includes"}),r.jsx(H,{gap:0,children:e.map((t,n)=>r.jsxs(R,{justify:"space-between",align:"center",gap:3,py:3,borderBottom:n<e.length-1?"1px solid":void 0,borderColor:l.gray[100],children:[r.jsxs(R,{align:"center",gap:2,minW:0,children:[r.jsx(d,{color:"#04802E",flexShrink:0,children:r.jsx(Gr,{size:14})}),r.jsx(m,{fontSize:"13px",color:l.text.label,truncate:!0,lineHeight:"1.5",children:t.label})]}),r.jsx(m,{fontSize:"13px",fontWeight:"medium",color:l.text.label,flexShrink:0,lineHeight:"1.5",children:t.value})]},`${t.label}-${t.value}`))})]}),Xo=({documents:e,onDownloadDocument:t})=>e.length===0?null:r.jsxs(d,{bg:tr,border:"1px solid",borderColor:rr,borderRadius:"16px",p:"20px",children:[r.jsx(m,{fontSize:"16px",fontWeight:"semibold",color:l.text.label,mb:4,lineHeight:"1.5",children:"Documents"}),r.jsx(H,{gap:3,children:e.map(n=>r.jsxs(R,{align:"center",justify:"space-between",gap:3,bg:"white",border:"1px solid",borderColor:l.gray[100],borderRadius:"10px",p:3,minH:"63px",children:[r.jsxs(R,{align:"center",gap:3,minW:0,flex:1,children:[r.jsx(d,{w:8,h:8,borderRadius:"8px",bg:l.error[50],display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,children:r.jsx(Ft,{size:16,color:l.error[500]})}),r.jsxs(d,{minW:0,children:[r.jsx(m,{fontSize:"13px",fontWeight:"medium",color:l.text.label,truncate:!0,title:n.name,lineHeight:"1.5",children:n.name}),r.jsx(m,{fontSize:"11px",color:"#98A2B3",lineHeight:"1.5",children:n.size})]})]}),r.jsx(jr,{"aria-label":`Download ${n.name}`,size:"sm",variant:"ghost",disabled:!n.downloadUrl?.trim(),onClick:()=>t(n),color:l.text.label,children:r.jsx(Le,{size:18})})]},n.id))})]}),he=({label:e,value:t,borderRight:n=!1})=>r.jsxs(R,{justify:"space-between",align:"center",gap:3,p:4,borderRight:n?"1px solid":void 0,borderColor:"#F0F2F5",minW:0,children:[r.jsx(m,{fontSize:"13px",fontWeight:"medium",color:l.text.label,children:e}),r.jsx(m,{fontSize:"14px",fontWeight:"semibold",color:l.navy[500],textAlign:"right",truncate:!0,title:t,children:t})]}),Zo=({nextDueDateDisplay:e,nextAmountDisplay:t,frequencyLabel:n,beneficiaryName:o,durationDisplay:i})=>r.jsxs(d,{w:"full",children:[r.jsxs(m,{fontSize:"22px",fontWeight:"semibold",color:"#485B7E",mb:4,children:["Policy"," ",r.jsx(m,{as:"span",color:l.orange[500],children:"Details"})]}),r.jsx(d,{bg:"white",border:"1px solid",borderColor:"#F0F2F5",borderRadius:"24px",boxShadow:"0px 4px 20px rgba(0,0,0,0.01)",overflow:"hidden",children:r.jsxs(Pe,{templateColumns:{base:"1fr",md:"1fr 1fr"},children:[r.jsx(d,{borderBottom:"1px solid",borderColor:"#F0F2F5",children:r.jsx(he,{label:"Next Due Date",value:e,borderRight:!0})}),r.jsx(d,{borderBottom:"1px solid",borderColor:"#F0F2F5",children:r.jsx(he,{label:"Next Amount",value:t})}),r.jsx(d,{borderBottom:"1px solid",borderColor:"#F0F2F5",children:r.jsx(he,{label:"Frequency",value:n||"—",borderRight:!0})}),r.jsx(d,{borderBottom:"1px solid",borderColor:"#F0F2F5",children:r.jsx(he,{label:"Beneficiary",value:o})}),r.jsx(d,{gridColumn:{md:"1 / -1"},children:r.jsx(he,{label:"Duration",value:i})})]})}),r.jsx(H,{gap:3,mt:8,align:"stretch",children:r.jsxs(R,{align:"flex-start",ga
1p:2,color:l.text.subtle,children:[r.jsx(d,{pt:.5,flexShrink:0,children:r.jsx($r,{size:16})}),r.jsx(m,{fontSize:"13px",children:"Contribution amounts and due dates may take a short time to update after payment."})]})})]}),ei="#F6F9FF",ti=()=>r.jsxs(d,{"data-testid":"contribution-skeleton",bg:ei,border:"2px solid",borderColor:"rgba(31,54,95,0.1)",borderRadius:"16px",px:{base:4,md:6},py:{base:6,md:8},w:"full",children:[r.jsxs(R,{justify:"space-between",gap:3,children:[r.jsx(ke,{height:"28px",width:"180px"}),r.jsx(ke,{height:"32px",width:"90px",borderRadius:"full"})]}),r.jsx(R,{gap:2,pt:6,wrap:"wrap",children:Array.from({length:8},(e,t)=>r.jsx(ke,{minW:"72px",h:"72px",borderRadius:"16px",flex:"1 0 18%"},t))})]}),ri="data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Icon'%20clip-path='url(%23clip0_0_4)'%3e%3cpath%20id='Vector'%20d='M10%2018.3333C14.6024%2018.3333%2018.3333%2014.6024%2018.3333%2010C18.3333%205.39763%2014.6024%201.66667%2010%201.66667C5.39763%201.66667%201.66667%205.39763%201.66667%2010C1.66667%2014.6024%205.39763%2018.3333%2010%2018.3333Z'%20stroke='%23E46921'%20stroke-width='1.66667'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20id='Vector_2'%20d='M10%206.66667V10'%20stroke='%23E46921'%20stroke-width='1.66667'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20id='Vector_3'%20d='M10%2013.3333H10.0083'%20stroke='%23E46921'%20stroke-width='1.66667'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_0_4'%3e%3crect%20width='20'%20height='20'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",ni="data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='10'%20height='10'%20viewBox='0%200%2010%2010'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Icon'%20clip-path='url(%23clip0_0_4)'%3e%3cpath%20id='Vector'%20d='M5%209.16667C7.30119%209.16667%209.16667%207.30119%209.16667%205C9.16667%202.69881%207.30119%200.833333%205%200.833333C2.69881%200.833333%200.833333%202.69881%200.833333%205C0.833333%207.30119%202.69881%209.16667%205%209.16667Z'%20fill='%2398A2B3'%20stroke='%2398A2B3'%20stroke-width='0.833333'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_0_4'%3e%3crect%20width='10'%20height='10'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",oi="data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Icon'%3e%3cpath%20id='Vector'%20d='M12%2022C17.5228%2022%2022%2017.5228%2022%2012C22%206.47715%2017.5228%202%2012%202C6.47715%202%202%206.47715%202%2012C2%2017.5228%206.47715%2022%2012%2022Z'%20stroke='%2304802E'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20id='Vector_2'%20d='M9%2012L11%2014L15%2010'%20stroke='%2304802E'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3c/svg%3e",Ye={icon:"check",iconSize:24,border:"#B5E3C4",fill:"#E7F6EC",labelColor:"#04802E",borderStyle:"solid",borderWidth:"1px",opacity:1,textOpacity:1,showPaidStamp:!0,opensSheet:!0},ht={icon:"due-alert",iconSize:20,border:"#E46921",fill:"#FFFCF9",labelColor:"#E46921",borderStyle:"solid",borderWidth:"2px",opacity:1,textOpacity:1,boxShadow:"0px 1px 1.5px rgba(0,0,0,0.1), 0px 1px 1px rgba(0,0,0,0.1)",showPaidStamp:!1,opensSheet:!1},ii={PAID:Ye,PAID_LATE:Ye,PREPAID:Ye,PENDING:{icon:"clock",iconSize:20,border:"#2B6CB0",fill:"#EBF8FF",labelColor:"#2B6CB0",borderStyle:"solid",borderWidth:"1px",opacity:1,textOpacity:1,showPaidStamp:!1,opensSheet:!0},DUE:ht,DUE_NEXT:ht,MISSED:{icon:"dot",iconSize:10,border:"#E4E7EC",fill:"#F0F2F5",labelColor:"#5E7297",borderStyle:"solid",borderWidth:"1px",opacity:1,textOpacity:1,showPaidStamp:!1,opensSheet:!1},REVERSED:{icon:"alert",iconSize:20,border:"#DC2626",fill:"#FEF2F2",labelColor:"#DC2626",borderStyle:"solid",borderWidth:"1px",opacity:1,textOpacity:1,showPaidStamp:!1,opensSheet:!0},UPCOMING:{icon:"none",iconSize:0,border:"#E4E7EC",fill:"#F9FAFB",labelColor:"#98A2B3",borderStyle:"dashed",borderWidth:"1px",opacity:1,textOpacity:.6,showPaidStamp:!1,opensSheet:!1}},si=e=>{const t=We(e);return{...ii[t],opensSheet:un(t)}},ai={check:oi,"due-alert":ri,dot:ni},li=({icon:e,size:t,color:n})=>{if(e==="none"||t<=0)return null;
1if(e==="clock"||e==="alert"){const i=e==="clock"?Vr:Mt;return r.jsx(d,{color:n,boxSize:`${t}px`,display:"flex",alignItems:"center",justifyContent:"center",children:r.jsx(i,{size:t})})}const o=ai[e];return o==null?null:r.jsx(d,{boxSize:`${t}px`,overflow:"hidden",flexShrink:0,children:r.jsx(Et,{src:o,alt:"",w:"100%",h:`${t}px`,display:"block"})})},ci=({cell:e,minHeight:t,onSelect:n})=>{const o=si(e.state),i=o.opensSheet;return r.jsxs(wr.button,{type:"button","data-testid":"contribution-cell","data-state":e.state,onClick:()=>{i&&n(e)},disabled:!i,cursor:i?"pointer":"default",position:"relative",overflow:"hidden",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",w:"100%",minH:`${t}px`,h:`${t}px`,borderRadius:"16px",bg:o.fill,borderWidth:o.borderWidth,borderStyle:o.borderStyle,borderColor:o.border,boxShadow:o.boxShadow,opacity:o.opacity,children:[o.icon!=="none"?r.jsx(d,{pb:"4px",children:r.jsx(li,{icon:o.icon,size:o.iconSize,color:o.labelColor})}):null,r.jsx(m,{fontSize:"11px",fontWeight:"bold",letterSpacing:"0.55px",lineHeight:"16.5px",textTransform:"uppercase",color:o.labelColor,textAlign:"center",opacity:o.textOpacity,whiteSpace:"nowrap",children:e.label}),o.showPaidStamp?r.jsx(d,{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",children:r.jsx(d,{transform:"rotate(-20deg)",opacity:.08,display:"flex",alignItems:"center",justifyContent:"center",children:r.jsx(m,{fontSize:"10px",fontWeight:"black",letterSpacing:"1px",lineHeight:"15px",color:"#04802E",border:"2px solid",borderColor:"#04802E",borderRadius:"6px",px:"6px",py:"2px",textTransform:"uppercase",children:"PAID"})})}):null]})},ui=[{label:"Paid",fill:"#E7F6EC",border:"#B5E3C4",borderStyle:"solid",borderWidth:"1px"},{label:"Due Next",fill:"#FFFCF9",border:"#E46921",borderStyle:"solid",borderWidth:"2px"},{label:"Missed",fill:"#F0F2F5",border:"#E4E7EC",borderStyle:"solid",borderWidth:"1px"},{label:"Upcoming",fill:"#F9FAFB",border:"#E4E7EC",borderStyle:"dashed",borderWidth:"1px"}],di=()=>r.jsx(R,{gap:"16px",wrap:"wrap",justify:"center",pt:"24px",children:ui.map(e=>r.jsxs(R,{align:"center",gap:"8px",h:"full",children:[r.jsx(d,{boxSize:"12px",borderRadius:"4px",bg:e.fill,borderWidth:e.borderWidth,borderStyle:e.borderStyle,borderColor:e.border,flexShrink:0}),r.jsx(m,{fontSize:"11px",fontWeight:"semibold",letterSpacing:"0.55px",lineHeight:"16.5px",textTransform:"uppercase",color:"#5E7297",whiteSpace:"nowrap",children:e.label})]},e.label))}),mi={updating:{title:"Contributions will be updated soon",description:"This can take a few seconds after a payment."},error:{title:"Contributions will be updated soon",description:"This can take a few seconds after a payment. Refresh if they haven't appeared yet."},empty:{title:"No contributions yet",description:"History will show here once payments start posting to this policy."},"filtered-empty":{title:"No matching contributions",description:"Try a different date range or status, or clear the filters."}},pi={updating:Ue,error:Ue,empty:Ue,"filtered-empty":qr},yt=({variant:e,onRetry:t})=>{const{title:n,description:o}=mi[e],i=pi[e],s=(e==="updating"||e==="error")&&t!=null;return r.jsxs(R,{"data-testid":`contribution-tracker-status-${e}`,mt:6,py:{base:8,md:10},px:6,direction:"column",align:"center",justify:"center",gap:4,bg:"white",border:"1px dashed",borderColor:"#E4E7EC",borderRadius:"16px","aria-live":"polite",children:[r.jsx(d,{boxSize:"56px",borderRadius:"full",display:"flex",alignItems:"center",justifyContent:"center",bg:l.gray[50],border:"1.5px solid",borderColor:"#E4E7EC",color:l.text.label,children:r.jsx(i,{size:24,"aria-hidden":!0})}),r.jsxs(R,{direction:"column",align:"center",gap:1,maxW:"360px",children:[r.jsx(m,{fontSize:"16px",fontWeight:"semibold",color:l.navy[500],textAlign:"center",lineHeight:"24px",children:n}),r.jsx(m,{fontSize:"13px",color:l.text.info,textAlign:"center",lineHeight:"20px",children:o})]}),s?r.jsxs(Ce,{type:"button",onClick:t,h:"44px",px:6,mt:1,borderRadius:"full",bg:l.orange[500],color:"white",fontSize:"14px",fontWeight:"medium",boxShadow:"inset 0px 4px 10px rgba(255,255,255,0.42)",_hover:{bg:l.orange[600]},children:[r.jsx(Yr,{size:16}),r.jsx(m,{as:"span",ml:2,children:"Refresh"})]}):null]})},fi="#F6F9FF",Ne=8,bi=({canExpand:e,viewToggle:t,frequencyLabel:n,nativeLabel:o,onViewToggle:i})=>e?r.jsx(R,{"data-testid":"contribution-view-toggle",bg:"white",border:"1px solid",borderColor:"#E4E7EC",borderRadius:"full",p:"2px",gap:0,children:[{value:"native",label:o},{value:"months",label:"Months"}].map(s=>{const c=t===s.value;return r.jsx(Ce,{type:"button",unstyled:!0,onClick:()=>i(s.value),px:3,py:1,borderRadius:"full",fontSize:"13px",fontWeight:"semibold",bg:c?l.orange[500]:"transparent",color:c?"white":l.text.label,cursor:"pointer",children:s.label},s.value)})}):n?r.jsx(d,{bg:l.gray[50],border:"1px solid",borderColor:"#F0F2F5",borderRadius:"full",px:3,py:1,children:r.jsx(m,{fontSize:"14px",fontWeight:"semibold",color:l.text.label,children:n})}):null,gi=({columns:e})=>r.jsx(R,{flexWrap:"wrap",mx:`-${Ne/2}px`,pt:6,children:Array.from({length:e*2},(t,n)=>r.jsx(d,{width:`${Lt(e)}%`,p:`${Ne/2}px`,children:r.jsx(ke,{h:"72px",borderRadius:"16px",variant:"pulse"})},n))}),xi=({frequencyLabel:e,canExpand:t,viewToggle:n,onViewToggle:o,pageTitle:i,canGoPrev:s,
1canGoNext:c,isFilterOn:a,onPrevPage:f,onNextPage:p,cells:b,view:S,statusFilter:j,rangeFrom:h,rangeTo:C,termStart:g,termEnd:w,onStatusChange:x,onRangeFromChange:P,onRangeToChange:L,onClearFilters:A,isPageLoading:D,isLooking:T,isPeriodEmpty:M,isUpdating:v=!1,isError:E,onRetry:I,onSelectCell:k})=>{const F=S??"MONTHLY",N=dn({view:F,isFiltered:j!=null}),W=Lt(N),y=mn({view:F,isFiltered:j!=null}),z=e==="Semi-annual"?"Halves":"Quarters";return r.jsxs(d,{"data-testid":"contribution-tracker",bg:fi,border:"2px solid",borderColor:"rgba(31,54,95,0.1)",borderRadius:"16px",px:{base:4,md:6},py:{base:6,md:8},w:"full",children:[r.jsxs(R,{justify:"space-between",align:"center",gap:3,wrap:"wrap",children:[r.jsxs(m,{fontSize:"22px",fontWeight:"semibold",color:"#485B7E",children:["My"," ",r.jsx(m,{as:"span",color:l.orange[500],children:"Contributions"})]}),r.jsx(bi,{canExpand:t,viewToggle:n,frequencyLabel:e,nativeLabel:z,onViewToggle:o})]}),r.jsx(Hr,{statusFilter:j,rangeFrom:h,rangeTo:C,termStart:g,termEnd:w,onStatusChange:x,onRangeFromChange:P,onRangeToChange:L,onClear:A}),r.jsx(Cn,{title:i,canGoPrev:s,canGoNext:c,locked:a,onPrev:f,onNext:p}),v?r.jsx(yt,{variant:"updating"}):E?r.jsx(yt,{variant:"error",...I?{onRetry:I}:{}}):T?r.jsx(m,{"data-testid":"contribution-looking",pt:6,textAlign:"center",fontSize:"14px",color:l.text.label,children:"Looking…"}):j!=null&&b.length===0?r.jsx(m,{"data-testid":"contribution-filter-empty",pt:6,textAlign:"center",fontSize:"14px",color:l.text.label,children:"No contributions match this filter."}):M?r.jsx(m,{"data-testid":"contribution-period-empty",pt:6,textAlign:"center",fontSize:"14px",color:l.text.label,children:"No contributions fall in this period."}):D?r.jsx(gi,{columns:N}):r.jsx(R,{flexWrap:"wrap",mx:`-${Ne/2}px`,pt:6,children:b.map(U=>r.jsx(d,{width:`${W}%`,p:`${Ne/2}px`,children:r.jsx(ci,{cell:U,minHeight:y,onSelect:k})},U.dueDate))}),r.jsx(di,{})]})},hi=({policy:e,documents:t,isMotor:n,isGadget:o,isTermLife:i,isSavings:s,isIndividualHealth:c,isMakingPayment:a,isAutoActivateBusy:f,isActivatingMotorPolicy:p,isSubmittingGadgetPolicy:b,isSubmittingSavingsPolicy:S,onFileClaim:j,onDownloadPolicy:h,onDownloadDocument:C,onMakePayment:g,onActivateMotorPolicy:w,onActivateGadgetPolicy:x,onActivateSavingsPolicy:P,onActivateTermLifePolicy:L,onActivateIndividualHealthPolicy:A,onRenewPolicy:D,onTalkToAgent:T,onVisitHelpCenter:M,onPayMissedContribution:v,isPayingMissedContribution:E=!1,missedPaymentSettledAt:I=null,watchingInvoiceReferences:k})=>{const{view:F,meta:N,coverageDates:W,tracker:y,hold:z}=Do(e),[U,Q]=u.useState(null),[re,J]=u.useState(0),ne=u.useMemo(()=>Go(y.cells,k??new Set),[y.cells,k]),$=Y=>{Q(Y),J(Date.now())},oe=Y=>{v?.(Y)},V=U!=null&&(I==null||I<re),X=Zt({policy:e,isMotor:n,isGadget:o,isTermLife:i,isSavings:s,isIndividualHealth:c,isAutoActivateBusy:f,isActivatingMotorPolicy:p,isSubmittingGadgetPolicy:b,isSubmittingSavingsPolicy:S,onMakePayment:g,onActivateMotorPolicy:w,onActivateGadgetPolicy:x,onActivateSavingsPolicy:P,onActivateTermLifePolicy:L,onActivateIndividualHealthPolicy:A,onRenewPolicy:D});return F==null||N==null?null:r.jsxs(r.Fragment,{children:[r.jsxs(H,{gap:6,align:"stretch",minW:0,w:"full",children:[r.jsxs(Pe,{templateColumns:{base:"1fr",lg:"minmax(0, 1fr) 340px"},columnGap:{base:0,lg:"35px"},rowGap:6,alignItems:"start",minW:0,w:"full",children:[r.jsxs(H,{gap:6,minW:0,align:"stretch",w:"full",children:[r.jsx(Qo,{view:F,summary:y.summary,isSummaryLoading:z.isHolding||y.isBaseLoading}),r.jsx(qo,{showWithdrawal:F.showWithdrawal,isDownloadDisabled:t.length===0,onDownloadCert:h,onGetHelp:M}),r.jsx(er,{policy:e,...W!=null?{coverageDates:{startDateIso:W.startDateIso,endDateIso:W.endDateIso}}:{}}),r.jsxs(Pe,{templateColumns:{base:"1fr",md:"1fr 1fr"},gap:6,alignItems:"stretch",w:"full",children:[r.jsx(Jo,{rows:F.coverageRows}),r.jsx(Xo,{documents:t,onDownloadDocument:C})]})]}),r.jsx(d,{w:"full",maxW:{lg:"340px"},children:r.jsx(Wt,{policy:e,onFileClaim:j,isMakingPayment:a,onTalkToAgent:T,onVisitHelpCenter:M,...X})})]}),z.isHolding||y.hasPlan||y.isBaseError?r.jsx(xi,{frequencyLabel:y.frequencyLabel||F.frequencyLabel,canExpand:y.canExpand,viewToggle:y.viewToggle,onViewToggle:y.setViewToggle,pageTitle:y.pageTitle,canGoPrev:y.canGoPrev,canGoNext:y.canGoNext,is
1FilterOn:y.isFilterOn,onPrevPage:y.goToPrevPage,onNextPage:y.goToNextPage,cells:ne,view:y.view,statusFilter:y.statusFilter,rangeFrom:y.rangeFrom,rangeTo:y.rangeTo,termStart:y.termStart,termEnd:y.termEnd,onStatusChange:y.setStatusFilter,onRangeFromChange:y.setRangeFrom,onRangeToChange:y.setRangeTo,onClearFilters:y.clearFilters,isPageLoading:!z.isHolding&&y.isPageLoading,isLooking:y.isLooking,isPeriodEmpty:y.isPeriodEmpty,isUpdating:z.isHolding,isError:!z.isHolding&&(y.isBaseError||y.isPageError),onRetry:y.refetchAll,onSelectCell:$}):y.isBaseLoading?r.jsx(ti,{}):null,r.jsx(Zo,{nextDueDateDisplay:N.nextDueDateDisplay,nextAmountDisplay:N.nextAmountDisplay,frequencyLabel:N.frequencyLabel||F.frequencyLabel,beneficiaryName:N.beneficiaryName,durationDisplay:N.durationDisplay})]}),r.jsx(Sn,{open:V,cell:U,currency:y.currency,frequencyLabel:y.frequencyLabel||F.frequencyLabel,onClose:()=>{Q(null),J(0)},...v!=null?{onPayMissed:oe}:{},isPayingMissed:E})]})},yi=({name:e,phone:t,onCall:n})=>r.jsxs(d,{borderRadius:"xl",border:"1px solid",borderColor:l.border.primary,bg:l.gray[50],px:4,py:4,children:[r.jsx(m,{fontSize:"md",fontWeight:"semibold",color:l.text.label,mb:3,children:"Talk to Myka"}),r.jsxs(R,{align:"center",gap:3,bg:l.white.DEFAULT,p:3,borderRadius:"full",border:".5px solid",borderColor:l.border.primary,children:[r.jsx(d,{flexShrink:0,children:r.jsx(ir,{initial:"",size:"lg"})}),r.jsxs(d,{flex:"1",minW:0,children:[r.jsx(m,{fontSize:"sm",fontWeight:"bold",color:l.text.label,lineHeight:"short",children:e}),r.jsx(m,{fontSize:"sm",color:l.text.info,children:t})]}),r.jsx(le,{gap:2,flexShrink:0,children:r.jsx(te,{type:"button",buttonType:"text",icon:r.jsx(Kr,{size:21,color:l.success[500]}),onClick:n,"aria-label":"WhatsApp agent",w:12,h:12,minW:12,p:0,lineHeight:"1",borderRadius:"full",bg:l.success[50],_hover:{bg:l.success[100],transform:"translateY(-1px)",boxShadow:"sm"},_active:{bg:l.success[200],transform:"translateY(0)"}})})]})]}),Ci=({groups:e})=>{const t=e.filter(n=>n.items.length>0);return t.length===0?null:r.jsx(d,{borderRadius:"xl",border:"1px solid",borderColor:"#D8E4EF",bg:"#ffffff",px:4,py:4,children:r.jsx(Pn,{defaultOpen:!1,label:r.jsx(le,{gap:2,children:r.jsx(m,{fontSize:"md",fontWeight:"bold",color:l.text.primary,children:"Coverage Details"})}),children:r.jsx(H,{gap:4,children:t.map((n,o)=>r.jsxs(d,{children:[n.title?r.jsx(m,{fontSize:"sm",fontWeight:"bold",color:l.text.primary,mb:1,children:n.title}):null,r.jsx(H,{gap:0,children:n.items.map((i,s)=>r.jsxs(d,{py:3,children:[r.jsx(m,{fontSize:"sm",fontWeight:"semibold",color:l.text.primary,children:i.name}),r.jsx(m,{fontSize:"sm",color:l.text.info,mt:1,children:i.description}),s<n.items.length-1?r.jsx(Ze,{mt:3,borderColor:"rgba(0,0,0,0.06)"}):null]},`${i.name}-${s}`))})]},`${n.title??"group"}-${o}`))})})})},Si=({policyNumber:e,onFileClaim:t,onDownloadPolicy:n,isDownloadPolicyDisabled:o,isFileClaimDisabled:i})=>r.jsxs(R,{justify:"space-between",align:{base:"stretch",sm:"flex-start"},gap:4,wrap:"wrap",direction:{base:"column",sm:"row"},children:[r.jsxs(H,{gap:2,flex:"1",minW:0,children:[r.jsxs(m,{fontSize:{base:"xl",md:"2xl"},fontWeight:"bold",color:l.text.primary,lineHeight:"short",children:["Policy #",e]}),r.jsxs(le,{gap:1.5,align:"flex-start",mt:-2,color:l.text.info,minW:0,children:[r.jsx(d,{flexShrink:0,pt:.5,children:r.jsx(Qr,{size:16,"aria-hidden":!0})}),r.jsx(m,{fontSize:"sm",color:"#64748B",fontWeight:"medium",wordBreak:"break-word",children:"Reference number for this policy"})]})]}),r.jsxs(H,{direction:{base:"column",sm:"row"},gap:3,flexShrink:0,justify:{base:"stretch",sm:"flex-end"},align:{base:"stretch",sm:"center"},w:{base:"full",sm:"auto"},ml:{base:0,sm:"auto"},children:[r.jsx(te,{type:"button",buttonType:"outline",text:"Get Certificate",size:"sm",icon:r.jsx(Le,{size:18,color:l.orange[500]}),iconPosition:"left",disabled:o,onClick:n,w:{base:"full",sm:"auto"},style:{border:`1px solid ${l.gray[200]}`,color:l.text.label}}),r.jsx(te,{type:"button",buttonType:"primary",text:"File a Claim",size:"sm",icon:r.jsx(Jr,{size:18}),iconPosition:"right",disabled:i,onClick:t,w:{base:"full",sm:"auto"}})]})]}),Pi=({documents:e,onDownloadDocument:t})=>e.length===0?null:r.jsxs(d,{borderRadius:"xl",border:"1px solid",borderColor:"#D8E4EF",bg:"#ffffff",px:4,py:4,children:[r.jsx(R,{justify:"space-between",align:"center",mb:4,children:r.jsxs(le,{gap:2,children:[r.jsx(m,{fontSize:"md",fontWeight:"bold",color:l.text.primary,children:"Policy Documents"}),r.jsx(m,{fontSize:"xs",fontWeight:"bold",color:l.text.info,bg:l.white.DEFAULT,px:2,py:.5,borderRadius:"full",border:"1px solid",borderColor:l.gray[200],children:e.length})]})}),e.map((n,o)=>r.jsxs(d,{children:[r.jsxs(R,{direction:{base:"column",sm:"row"},justify:"space-between",align:{base:"stretch",sm:"center"},py:3,gap:3,children:[r.jsxs(le,{gap:3,flex:"1",minW:0,children:[r.jsx(d,{w:10,h:10,borderRadius:"md",bg:l.error[50],display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,children:r.jsx(Ft,{size:22,color:l.error[500]})}),r.jsxs(d,{minW:0,children:[r.jsx(m,{fontSize:"sm",fontWeight:"semibold",color:l.text.primary,truncate:!0,children:"Policy Certificate"}),r.jsx(m,{fontSize:"xs",color:l.text.info,children:`${n.size} • Uploaded ${n.uploadedDate}`})]})]}),r.jsx(te,{type:"button",buttonType:"primary",text:"Download",icon:r.
1jsx(Le,{size:22}),disabled:!n.downloadUrl?.trim(),"aria-label":`Download ${n.name}`,onClick:()=>t?.(n),w:{base:"full",sm:"auto"},alignSelf:{base:"stretch",sm:"center"},flexShrink:0})]}),o<e.length-1&&r.jsx(Ze,{borderColor:"rgba(0,0,0,0.06)"})]},n.id))]}),Ct=({label:e,dateIso:t})=>{const n=G(t,{preset:"gb-short",fallback:""});return q(n)?r.jsxs(d,{minW:0,children:[r.jsx(m,{fontSize:"xs",fontWeight:"medium",color:l.text.subtle,mb:.5,children:e}),r.jsx(m,{fontSize:"sm",fontWeight:"medium",color:l.text.secondary,children:n})]}):null},ji=({createdAt:e,updatedAt:t})=>{const n=q(G(e,{preset:"gb-short",fallback:""})),o=q(G(t,{preset:"gb-short",fallback:""}));return!n&&!o?null:r.jsx(d,{borderRadius:"lg",bg:l.gray[50],px:{base:3,md:4},py:{base:3,md:3.5},maxW:"100%",minW:0,children:r.jsxs(fe,{columns:{base:1,md:2},gap:3,children:[r.jsx(Ct,{label:"Created at",dateIso:e}),r.jsx(Ct,{label:"Updated at",dateIso:t})]})})},wi=e=>{const t=e?.trim().toUpperCase()??"";return t==="SUCCESS"||t==="SUCCESSFUL"||t==="COMPLETED"?l.success[600]:t.includes("FAIL")||t.includes("REVERS")||t==="CANCELLED"?l.error[600]:l.warning[700]},ye=({label:e,value:t,color:n,align:o="left"})=>r.jsxs(d,{minW:0,textAlign:o,children:[r.jsx(m,{fontSize:"xs",fontWeight:"medium",letterSpacing:"0.04em",textTransform:"uppercase",color:l.text.subtle,mb:1,children:e}),r.jsx(m,{fontSize:"md",fontWeight:"semibold",color:n??l.text.label,wordBreak:"break-word",children:t})]}),vi=({transactions:e,fallbackCurrency:t})=>{if(e.length===0)return null;const n=e.length===1;return r.jsxs(d,{borderRadius:"xl",border:"1px solid",borderColor:l.border.primary,bg:l.white.DEFAULT,px:{base:4,md:5},py:{base:4,md:5},maxW:"100%",minW:0,overflow:"hidden",children:[r.jsx(m,{fontSize:"md",fontWeight:"bold",color:l.text.primary,children:n?"Policy Transaction":"Policy Transactions"}),r.jsx(H,{gap:5,mt:4,align:"stretch",children:e.map((o,i)=>{const s=o.currency??t??"NGN",c=Vt(o),a=o.paidAt??o.createdAt;return r.jsxs(H,{gap:4,align:"stretch",...i>0?{pt:5,borderTop:"1px solid",borderColor:l.border.primary}:{},children:[r.jsxs(fe,{columns:2,gap:4,children:[r.jsx(ye,{label:"Amount paid",value:Zr(Number(o.amount),s)}),r.jsx(ye,{label:"Status",value:Jn(o.status),color:wi(o.status),align:"right"}
1),r.jsx(ye,{label:"Payment date",value:G(a,{preset:"gb-short",fallback:"N/A"})}),r.jsx(ye,{label:"Currency",value:s,align:"right"})]}),c?r.jsx(ye,{label:"Transaction ref.",value:c}):null]},c??`transaction-${i}`)})})]})},Ai=({policy:e,policyNumber:t,coverageGroups:n,documents:o,isMotor:i,isGadget:s,isTermLife:c,isSavings:a,isIndividualHealth:f,isMakingPayment:p,isAutoActivateBusy:b,isActivatingMotorPolicy:S,isSubmittingGadgetPolicy:j,isSubmittingSavingsPolicy:h,canFileClaim:C,onFileClaim:g,onDownloadPolicy:w,onDownloadDocument:x,onMakePayment:P,onActivateMotorPolicy:L,onActivateGadgetPolicy:A,onActivateSavingsPolicy:D,onActivateTermLifePolicy:T,onActivateIndividualHealthPolicy:M,onRenewPolicy:v,onTalkToAgent:E,onVisitHelpCenter:I,onPayMissedContribution:k,isPayingMissedContribution:F,missedPaymentSettledAt:N,watchingInvoiceReferences:W})=>{if(Ke(e.productType))return r.jsx(hi,{policy:e,documents:o,isMotor:i,isGadget:s,isTermLife:c,isSavings:a,isIndividualHealth:f,isMakingPayment:p,isAutoActivateBusy:b,isActivatingMotorPolicy:S,isSubmittingGadgetPolicy:j,isSubmittingSavingsPolicy:h,onFileClaim:g,onDownloadPolicy:w,onDownloadDocument:x,onMakePayment:P,onActivateMotorPolicy:L,onActivateGadgetPolicy:A,onActivateSavingsPolicy:D,onActivateTermLifePolicy:T,onActivateIndividualHealthPolicy:M,onRenewPolicy:v,onTalkToAgent:E,onVisitHelpCenter:I,...k!=null?{onPayMissedContribution:k}:{},...F!=null?{isPayingMissedContribution:F}:{},...N!=null?{missedPaymentSettledAt:N}:{},...W!=null?{watchingInvoiceReferences:W}:{}});const y=$t(Gt(e)),z=Zt({policy:e,isMotor:i,isGadget:s,isTermLife:c,isSavings:a,isIndividualHealth:f,isAutoActivateBusy:b,isActivatingMotorPolicy:S,isSubmittingGadgetPolicy:j,isSubmittingSavingsPolicy:h,onMakePayment:P,onActivateMotorPolicy:L,onActivateGadgetPolicy:A,onActivateSavingsPolicy:D,onActivateTermLifePolicy:T,onActivateIndividualHealthPolicy:M,onRenewPolicy:v});return r.jsx(d,{border:"1px solid",borderColor:l.border.primary,borderRadius:"xl",p:{base:4,md:6},maxW:"100%",minW:0,overflow:"hidden",children:r.jsxs(H,{gap:6,minW:0,align:"stretch",children:[r.jsx(Si,{policyNumber:t,onFileClaim:g,onDownloadPolicy:w,isDownloadPolicyDisabled:o.length===0,isFileClaimDisabled:!C}),r.jsxs(Pe,{templateColumns:{base:"1fr",lg:"1fr 340px"},templateRows:{lg:"auto 1fr"},columnGap:{base:0,lg:8},rowGap:5,alignItems:"start",minW:0,w:"full",children:[r.jsxs(H,{gap:5,minW:0,align:"stretch",gridColumn:{lg:1},gridRow:{lg:1},children:[r.jsx(er,{policy:e}),r.jsx(Pi,{documents:o,onDownloadDocument:x})]}),r.jsx(d,{position:{base:"static",lg:"sticky"},top:"88px",gridColumn:{lg:2},gridRow:{lg:"1 / span 2"},children:r.jsx(Wt,{policy:e,onFileClaim:g,isMakingPayment:p,onTalkToAgent:E,onVisitHelpCenter:I,...z})}),r.jsxs(H,{gap:5,minW:0,align:"stretch",gridColumn:{lg:1},gridRow:{lg:2},children:[r.jsx(Ci,{groups:n}),r.jsx(vi,{transactions:y,fallbackCurrency:e.currency}),r.jsx(ji,{createdAt:e.createdAt,updatedAt:e.updatedAt})]})]})]})})},Ri=(e,t)=>e==="not-found"?{title:"This policy is no longer available",description:"It may have been removed, or the link has expired. Head back to your policies to see your active cover."}:{title:"We couldn't load this policy",description:t?.trim()||"Something went wrong loading these details. Check your connection and try again — if it keeps happening, reach out to us."},Ti=({variant:e,errorMessage:t,onViewAllPolicies:n,onRetry:o,onContactSupport:i})=>{const{title:s,description:c}=Ri(e,t),a=e==="not-found";return r.jsx(d,{w:"100%",maxW:"520px",mx:"auto",borderRadius:"xl",border:`1px solid ${l.gray[200]}`,bg:l.white.DEFAULT,style:{boxShadow:"0px 1px 3px 0px rgba(0,0,0,0.06), 0px 1px 2px -1px rgba(0,0,0,0.04)"},children:r.jsx(d,{p:{base:8,md:12},children:r.jsxs(lt,{gap:4,align:"center",children:[r.jsx(d,{w:14,h:14,borderRadius:"full",display:"flex",alignItems:"center",justifyContent:"center",bg:a?l.orange[50]:l.error[50],border:`1.5px solid ${a?l.orange[200]:l.error[200]}`,color:a?l.orange[500]:l.error[500],children:a?r.jsx(Xr,{size:26,"aria-hidden":!0}):r.jsx(Mt,{size:26,"aria-hidden":!0})}),r.jsxs(lt,{gap:2,align:"center",children:[r.jsx(m,{fontSize:"lg",fontWeight:"bold",color:l.text.label,textAlign:"center",children:s}),r.jsx(m,{fontSize:"sm",color:l.text.info,textAlign:"center",maxW:"400px",lineHeight:"1.6",children:c})]}),r.jsxs(le,{gap:3,flexWrap:"wrap",justify:"center",pt:1,children:[o!=null?r.jsx(te,{type:"button",buttonType:"secondary",text:"Try again",size:"md",onClick:o}):null,r.jsx(te,{type:"button",buttonType:"primary",text:"View all policies",size:"md",onClick:n}),i!=null?r.jsx(te,{type:"button",buttonType:"outline",text:"Contact support",size:"md",onClick:i}):null]})]})})})},St=({isChecked:e,onToggle:t,label:n,ariaLabel:o})=>
1r.jsxs(R,{align:"flex-start",gap:"8px",bg:"#FBFBFB",border:"1px solid",borderColor:"rgba(168, 168, 168, 0.2)",borderRadius:"16px",px:"18px",py:"12px",cursor:"pointer",role:"checkbox","aria-checked":e,"aria-label":o,tabIndex:0,onClick:i=>{i.target.closest("a")||t(!e)},onKeyDown:i=>{i.target===i.currentTarget&&(i.key===" "||i.key==="Enter")&&(i.preventDefault(),t(!e))},children:[r.jsx(Pr,{checked:e,controlProps:{boxSize:"20px",borderRadius:"6px"},flexShrink:0,mt:"1px",pointerEvents:"none"}),r.jsx(m,{fontSize:"13px",fontWeight:"medium",lineHeight:"20px",color:l.text.primary,children:n})]}),Ii=({open:e,onClose:t,requiresDebitConsent:n,termsAccepted:o,onTermsAcceptedChange:i,debitConsent:s,onDebitConsentChange:c,canProceed:a,isRecording:f,onConfirm:p})=>r.jsx(fr,{open:e,onClose:t,title:"Consent",size:"md",mobileBottomSheet:!0,scrollBehavior:"inside",bodyPadded:!1,contentProps:{w:{base:"100%",md:"42rem"},maxW:{base:"100%",md:"42rem"}},children:r.jsxs(R,{direction:"column",gap:"16px",px:"24px",pt:"8px",pb:"24px",children:[r.jsx(m,{fontSize:"14px",lineHeight:"21px",color:l.text.tertiary,children:"Please review and accept the required consent before continuing to payment."}),n?r.jsx(St,{isChecked:s,onToggle:c,label:at,ariaLabel:at}):null,r.jsx(St,{isChecked:o,onToggle:i,label:r.jsx(gr,{instalment:n}),ariaLabel:br(n)}),r.jsx(d,{pt:"8px",children:r.jsx(te,{buttonType:"primary",type:"button",text:"Continue",size:"lg",fullWidth:!0,loading:f,disabled:!a||f,onClick:p})})]})}),Di=({policyId:e,requiresDebitConsent:t,onConsented:n})=>{const[o,i]=u.useState(!1),[s,c]=u.useState(!1),[a,f]=u.useState(!1),[p,b]=u.useState(!1),{recordPolicyConsentAsync:S,isRecordingConsent:j}=xr("payments"),h=yr({termsAccepted:a,debitConsent:p,requiresDebitConsent:t}),C=u.useCallback(()=>{f(!1),b(!1),i(!0)},[]),g=u.useCallback(()=>{i(!1)},[]),w=u.useCallback(async()=>{if(h){c(!0);try{if(e&&await S({policyId:e,...hr({termsAccepted:a,debitConsent:t&&p})}),await n()==="error")return;i(!1)}catch(P){O.error(ee(P)??"We could not record your consent. Please try again.")}finally{c(!1)}}},[h,p,n,e,S,t,a]);return{openConsentModal:C,modalProps:{open:o,onClose:g,requiresDebitConsent:t,termsAccepted:a,onTermsAcceptedChange:f,debitConsent:p,onDebitConsentChange:b,canProceed:h,isRecording:j||s,onConfirm:w}}},Ei=async(e,t={})=>{const{data:n}=await It.post(`/api/v1/life-policy/${encodeURIComponent(e)}/retry`,t);return kr(n)},ki=()=>{const{mutate:e,isPending:t,isError:n,error:o}=yn({mutationKey:["life-policy","retry-missed-contribution"],mutationFn:({invoiceReference:i,note:s})=>Ei(i,s!=null&&s.trim()?{note:s.trim()}:{})});return{retryMissedContribution:e,isRetrying:t,isError:n,error:o}},Fi="Your missed contribution is now marked as paid.",Mi="We’re still confirming this payment. Please check your contributions again in a little while.",Pt=(e,t)=>{const n=Jt({watches:Kt(),now:t});return Qt(n),Xt({watches:n,subscriptionReference:e})},Ni=({policyId:e,subscriptionReference:t,enabled:n=!0})=>{const o=_t(),i=u.useRef(!1),[s,c]=u.useState([]),a=t?.trim()||null,f=e?.trim()||null,p=s.length>0,b=u.useCallback(()=>{if(a==null){c([]);return}c(Pt(a,Date.now()))},[a]);u.useEffect(()=>{b()},[b]),u.useEffect(()=>{const x=P=>{P.key!=null&&P.key!==nt||b()};return window.addEventListener("storage",x),()=>window.removeEventListener("storage",x)},[b]);const S=u.useCallback(x=>{const P=Date.now(),L=Jt({watches:x(Kt()),now:P});if(Qt(L),a==null)return c([]),L;const A=Xt({watches:L,subscriptionReference:a});return c(A),L},[a]),j=u.useCallback(({invoiceReference:x,sourceInvoiceReference:P=null,dueDate:L,amount:A})=>{a==null||f==null||S(D=>Oo({watches:D,watch:{invoiceReference:x,sourceInvoiceReference:P,subscriptionReference:a,policyId:f,dueDate:L,amount:A}}))},[S,a,f]),h=u.useCallback(async()=>{a!=null&&await o.invalidateQueries({queryKey:[...rt,a]})},[o,a]),C=u.useCallback(async()=>{if(!n||a==null||i.current)return;const x=Pt(a,Date.now());if(c(x),x.length===0)return;const P=Uo(x,Nt());if(P!=null){i.current=!0;try{const A=(await qt(a,{from:P.from,to:P.to,limit:P.limit})).tracker?.cells??[],D=Date.now();let T=0,M=0;S(v=>{let E=[...v];for(const I of x){const k=zo({watches:E,invoiceReference:I.invoiceReference}),F=k.find(W=>W.invoiceReference===I.invoiceReference)??I,N=Bo({watch:F,cells:A,now:D,maxAttempts:ko,maxAgeMs:Yt});if(N==="paid"){T+=1,E=bt({watches:k,invoiceReference:I.invoiceReference});continue}if(N==="timed_out"){M+=1,E=bt({watches:k,invoiceReference:I.invoiceReference});continue}E=k}return E}),T>0&&(O.success(T===1?Fi:`${T} missed contributions are now marked as paid.`),await h()),M>0&&O.message(Mi,{duration:Fe})}catch{}finally{i.current=!1}}},[n,h,S,a]),g=u.useRef(C);return g.current=C,u.useEffect(()=>{if(!n||a==null||!p)return;g.current();const x=window.setInterval(()=>{g.current()},Eo);return()=>window.clearInterval(x)},[n,a,p]),{watchingInvoiceReferences:u.useMemo(()=>$o(s),[s]),isWatching:p,enqueueWatch:j}},Li="This missed contribution has no invoice reference yet.",Wi="We could not collect this missed contribution. Please try again.",_i=e=>{const t={duration:Fe};if(e.action==="paid"){O.success(e.fallbackMessage,t);return}O.error(e.message||e.fallbackMessage,t)},Oi=({policy:e,onSettled:t})=>{const n=_t(),[o,i]=u.useState(null),s=Ht(e),{retryMissedContribution:c,isRetrying:a}=ki(),{enqueueWatch:f,watchingInvoiceReferences:p,isWatching:b}=Ni({policyId:e?.id,subscriptionReference:s,enabled:!!(e?.id&&s)}),S=u.useCallback(async()=>{s!=null&&await n.invalidateQueries({queryKey:[...rt,s]})},[n,s]),j=u.useCallback(()=>{i(Date.now()),t?.()},[t]),h=u.useCallback((g,w)=>{const x=w.invoiceReference?.trim()??"",P=g.invoiceReference?.trim()??"";if(_i(g),g.shouldWatch&&P){f({invoiceReference:P,sourceInvoiceReference:x||null,dueDate:w.dueDate,amount:w.amount}),j();return}g.shouldInvalidateTracker&&S(),g.action==="paid"&&j()},[f,S,j]),C=u.useCallback(g=>{if(s==null||e?.id==null){O.error("This policy is not ready for contribution payments.");return}if(!pn(g.state))return;const w=g.invoiceReference?.trim()??"";if(!w){O.error(Li,{duration:Fe});return}c({invoiceReference:w,note:"customer retried missed payment"},{onSuccess:x=>{h(x,g)},onError:x=>{O.error(ee(x)??Wi,{duration:Fe})}})},[h,e?.id,c,s]);return{isPayingMissedContribution:a,requestMissedContributionPayment:C,missedPaymentSettledAt:o,watchingInvoiceReferences:p,isWatchingMissedContribution:b}},zi=({origin:e,policyId:t})=>({successUrl:`${e}/policies/${t}?activation=success`,failedUrl:`${e}/policies/${t}?activation=failed`}),Hi=e=>{if(Ot(e))return An(e.id);const t=ve(e.productType);if(t==="GADGET")return`/gadget/policy-activation?policyId=${e.id}`;if(t==="MOTOR"){const n=(e.usageType??"personal").toLowerCase(),o=zt(e).toLowerCase().replace(/_/g,"-")||"third-party";return`/motor/${n}/${o}/activate?policyId=${e.id}`}return null},Bi=e=>{const t=ve(e.productType);if(t==="LIFE_SAVINGS")return{kind:"submit-issuance",product:"LIFE_SAVINGS"};if(ur(e.productType))return{kind:"submit-issuance",product:"EDUCATION_SAVINGS"};if(t==="TERM_LIFE"||t==="LIFE")return zn(e)?{kind:"stay"}:Hn(e)?{kind:"submit-issuance",product:"TERM_LIFE"}:{kind:"navigate",path:Bn(e)};if(t==="MYKA_LIFE_AND_HOSPITAL")return Wn(e)?{kind:"stay"}:_n(e)?{kind:"submit-issuance",product:"MYKA_LIFE_AND_HOSPITAL"}:{kind:"navigate",path:On(e)};const n=Hi(e);return n?{kind:"navigate",path:n}:{kind:"stay"}},jt=async({policy:e,navigate:t,submitIssuance:n}
1)=>{const o=Bi(e);if(o.kind!=="stay"){if(o.kind==="navigate"){t(o.path);return}await n(o.product)}},wt="Payment failed. Please try again or contact support.",vt="Missing quote reference. Please contact support to activate this policy.",Ui="Could not activate your policy. Please try again.",At=new Set,Gi=({policyId:e,payment:t,reference:n})=>{const o=n?.trim();return o?`${t}:${o}`:`${e??"unknown"}:${t}`},$i=({policy:e,refetch:t})=>{const n=Tt(),[o]=Rt(),i=sr(_=>_?.kycApproved??!1),[s,c]=u.useState("success"),[a,f]=u.useState(!1),p=o.get("payment")==="success",b=o.get("payment")==="failed",S=e?.id,j=Qn(e),h=Dt(e?.productType),C=h==="MOTOR",g=h==="GADGET",w=h==="LIFE",x=h==="SAVINGS",P=Ot(e),{activatePolicyAsync:L,isLoading:A}=Tn(),{submitGadgetPolicyAsync:D,isLoading:T}=wn(),{submitSavingsPolicyAsync:M,isSubmitting:v}=Nn(),{submitEducationPolicyAsync:E,isSubmitting:I}=jn(),{submitTermLifePolicyAsync:k,isLoading:F}=Ln(),{submitLifeHospitalPolicyAsync:N,isLoading:W}=Rn(),y=v||I||F||W,z=e!=null&&C&&In({policy:e,kycApproved:i}),U=g&&e!=null&&vn(e)&&i,Q=Cr({productType:e?.productType,coverType:Sr(e?.details)}),{continueAfterConsent:re,linkModalProps:J}=mr({onReadyForPayment:()=>f(!0)}),{openConsentModal:ne,modalProps:$}=Di({policyId:S,requiresDebitConsent:Q,onConsented:re}),oe=u.useMemo(()=>{if(!(typeof window>"u"||!S))return Ar({origin:window.location.origin,policyId:S,successPath:`/policies/${S}`})},[S]),V=u.useCallback(()=>{if(e?.id==null)return;O.success("Policy activated successfully!");const _=new URLSearchParams(o);_.delete("payment"),n({pathname:`/policies/${e.id}`,search:_.toString()},{replace:!0}),t()},[n,e,t,o]),X=u.useCallback(_=>{O.success("Policy Pending"),e?.id===_&&t()},[e,t]),{isAutoActivateBusy:Y,isAwaitingManualActivation:Ae}=Dn({enabled:!!(p&&z&&e?.id),policyId:e?.id,quoteId:e?.quoteReference??void 0,refetchPolicy:async()=>({data:(await t()).data}),onPolicyActive:V,onPolicyUnresolved:X}),ce=u.useCallback(async _=>{if(e?.id==null||y)return;const{successUrl:B,failedUrl:ae}=zi({origin:window.location.origin,policyId:e.id}),de={policyId:e.id,successUrl:B,failedUrl:ae};try{const me=_==="LIFE_SAVINGS"?await M(de):_==="EDUCATION_SAVINGS"?await E(de):_==="MYKA_LIFE_AND_HOSPITAL"?await N(de):await k(de);if(!me.success){O.error(ee(me)??me.message??"Activation could not be completed. Please try again.");return}V()}catch(me){O.error(ee(me)??Ui)}},[V,y,e,E,N,M,k]),ie=u.useCallback(()=>{e!=null&&(t(),jt({policy:e,navigate:n,submitIssuance:ce}))},[n,e,t,ce]),{isOpen:se,start:ue}=Rr({holdMs:Ir,onComplete:()=>{b||s==="failed"||ie()}});u.useEffect(()=>{if(!p&&!b||e==null)return;const _=p?"success":"failed",B=o.get("reference")??o.get("trxref");if(!B?.trim()&&S==null)return;const ae=Gi({policyId:S,payment:_,reference:B});At.has(ae)||(At.add(ae),ue())},[b,p,e,S,o,ue]);const Z=b?"failed":s,{isProcessing:_e,handleSelectMethod:Re,handleEmailVerifiedAndPay:Oe,emailModal:ze}=Tr({policyId:S,amountDue:j,paymentRedirectUrls:oe,onDirectDebitCompleted:_=>{f(!1),c(_),ue()},errorFallback:wt,onCloseMethodModal:()=>{f(!1)}}),He=u.useCallback(async(_,B)=>{e!=null&&(b&&n({pathname:`/policies/${e.id}`,search:""},{replace:!0}),await Re(_,B))},[b,n,e,Re]),ge=u.useCallback(async()=>{e!=null&&await jt({policy:e,navigate:n,submitIssuance:ce})},[n,e,ce]),Te=u.useCallback(async()=>{if(e?.id==null||A)return;if(z){if(Y)return;if(Ae){const ae=e.quoteReference?.trim();if(!ae){O.error(vt);return}try{const de=await L({policyId:e.id,quoteId:ae});if(En(de.data))try{const ot=(await t()).data?.data;if(ot!=null&&kn(ot.status)){V();return}}catch{}X(e.id);return}catch{X(e.id);return}}return}const _=(e.usageType??"personal").toLowerCase(),B=zt(e).toLowerCase().replace(/_/g,"-")||"third-party";n(`/motor/${_}/${B}/activate?policyId=${e.id}`)},[L,X,V,A,Y,Ae,n,e,t,z]),nr=u.useCallback(async()=>{if(e?.id==null)return;if(!U){n(`/gadget/policy-activation?policyId=${e.id}`);return}if(T)return;const _=e.quoteReference?.trim();if(!_){O.error(vt);return}try{const B=await D({policyId:e.id,quoteId:_});if(!B.success){O.error(ee(B)??B.message??"Activation could not be completed. Please try again.");return}if(B.data.status?.trim().toUpperCase()==="ACTIVE"){V();return}O.success("Policy Pending"),t()}catch(B){O.error(ee(B)??"Could not activate your policy. Please try again.")}},[U,V,T,n,e,t,D]);return{isMakingPayment:_e,amountDue:j,requestPayment:ne,consentModal:$,linkModal:J,isMethodModalOpen:a,closeMethodModal:()=>f(!1),handleSelectMethod:He,emailModal:{...ze,onVerified:Oe},successModalProps:{open:se,outcome:Z,...j!=null&&Z!=="failed"?{amountDisplay:be(j)}:{},...Z==="failed"?{subtitle:wt}:{}},isMotor:C,isGadget:g,isTermLife:w,isSavings:x,isIndividualHealth:P,isAutoActivateBusy:Y,isActivatingMotorPolicy:A,isSubmittingGadgetPolicy:T,isSubmittingSavingsPolicy:y,handleActivateMotorPolicy:Te,handleActivateGadgetPolicy:nr,handleActivateSavingsPolicy:ge,handleActivateTermLifePolicy:ge,handleActivateIndividualHealthPolicy:ge}},Vi=e=>{const t=u.useMemo(()=>e!=null?Fn(e):[],[e]),n=u.useCallback(i=>{i.downloadUrl?.trim()&&ut(i.downloadUrl)},[]),o=u.useCallback(()=>
1{if(e==null)return;const i=Mn(e),s=t[0]?.downloadUrl?.trim(),c=i??s;c&&ut(c)},[t,e]);return{downloadableDocuments:t,handleDownloadDocument:n,handleDownloadPolicyFromHeader:o}},Aa=()=>{const e=Tt(),{id:t}=or(),{data:n,isLoading:o,isError:i,error:s,refetch:c}=Fr(t??""),a=n?.data,p=s?.response?.status===404||!o&&!i&&a==null;u.useEffect(()=>{!s||p||O.error(ee(s)??"Unable to load policy details.")},[s,p]);const b=a?.policyNumber?.trim()||a?.ourReference?.trim()||"N/A",S=u.useMemo(()=>[{labelKey:"Policies",isActive:!1},{labelKey:b,isActive:!0}],[b]),j=u.useMemo(()=>tt(a),[a]),{downloadableDocuments:h,handleDownloadDocument:C,handleDownloadPolicyFromHeader:g}=Vi(a),{isMakingPayment:w,amountDue:x,requestPayment:P,consentModal:L,linkModal:A,isMethodModalOpen:D,closeMethodModal:T,handleSelectMethod:M,emailModal:v,successModalProps:E,isMotor:I,isGadget:k,isTermLife:F,isSavings:N,isIndividualHealth:W,isAutoActivateBusy:y,isActivatingMotorPolicy:z,isSubmittingGadgetPolicy:U,isSubmittingSavingsPolicy:Q,handleActivateMotorPolicy:re,handleActivateGadgetPolicy:J,handleActivateSavingsPolicy:ne,handleActivateTermLifePolicy:$,handleActivateIndividualHealthPolicy:oe}=$i({policy:a,refetch:c}),V=a!=null&&Ke(a.productType),{isPayingMissedContribution:X,requestMissedContributionPayment:Y,missedPaymentSettledAt:Ae,watchingInvoiceReferences:ce}=Oi({policy:a}),{track:ie}=lr(),se=I?"motor":k?"screen":"others",ue=u.useRef(!1);u.useEffect(()=>{!a||ue.current||(ue.current=!0,ie(Ie.POLICY_DETAIL_VIEWED,{product_type:se,policy_status:a.status??"unknown"}))},[a,se,ie]);const Z=()=>e("/policies"),_e=()=>{a!=null&&(ie(Ie.CLAIM_FLOW_STARTED,{product_type:se,entry_point:"policy_detail"}),e(dr(a),{state:{policy:a}}))},Re=()=>{a?.id!=null&&(ie(Ie.POLICY_RENEWAL_TAPPED,{product_type:se}),e(`/policies/${a.id}/renew`))},Oe=()=>{ie(Ie.POLICY_SUPPORT_TAPPED,{product_type:se,trigger_reason:"other"}),window.location.href=`tel:${st.replace(/\s/g,"")}`},ze=()=>e("/support"),He=a?.status?.toUpperCase()==="ACTIVE",ge=o&&a==null,Te=ee(s);return r.jsxs(r.Fragment,{children:[r.jsx(Dr,{...E}),a!=null&&r.jsxs(r.Fragment,{children:[r.jsx(ar,{open:v.open,onClose:v.onClose,onVerified:v.onVerified,initialEmail:v.initialEmail,initialStep:v.initialStep,pendingEmail:v.pendingEmail}),r.jsx(Ii,{...L}),r.jsx(pr,{...A}),r.jsx(Er,{open:D,onClose:T,amountDue:x??0,isProcessing:w,onConfirmPayment:M})]}),ge?r.jsx(Be,{items:[],onGoBack:Z,contentMaxW:"1100px",children:r.jsx(R,{justify:"center",align:"center",minH:"50vh",children:r.jsx(vr,{size:"xl",color:l.orange[500]})})}):i||a==null?r.jsx(Be,{items:[],onGoBack:Z,contentMaxW:"1100px",children:r.jsx(R,{justify:"center",align:"center",minH:"50vh",px:4,children:r.jsx(Ti,{variant:p?"not-found":"load-error",...Te!=null?{errorMessage:Te}:{},onViewAllPolicies:Z,...p?{}:{onRetry:()=>void c()},onContactSupport:it})})}):r.jsx(Be,{items:S,onGoBack:Z,contentMaxW:"1100px",children:r.jsxs(H,{gap:5,align:"stretch",minW:0,w:"full",pb:{base:4,md:10},children:[r.jsx(Ai,{policy:a,policyNumber:b,coverageGroups:j,documents:h,isMotor:I,isGadget:k,isTermLife:F,isSavings:N,isIndividualHealth:W,isMakingPayment:w,isAutoActivateBusy:y,isActivatingMotorPolicy:z,isSubmittingGadgetPolicy:U,isSubmittingSavingsPolicy:Q,canFileClaim:He,onFileClaim:_e,onDownloadPolicy:g,onDownloadDocument:C,onMakePayment:P,onActivateMotorPolicy:re,onActivateTermLifePolicy:$,onActivateIndividualHealthPolicy:oe,onActivateGadgetPolicy:()=>{J()},onActivateSavingsPolicy:()=>{ne()},onRenewPolicy:Re,onTalkToAgent:it,onVisitHelpCenter:ze,...V?{onPayMissedContribution:Y,isPayingMissedContribution:X,missedPaymentSettledAt:Ae,watchingInvoiceReferences:ce}:{}}),Ke(a.productType)?null:r.jsx(yi,{name:zr.name,phone:st,onCall:Oe})]})})]})};export{Aa as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.