1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7145],{84638:function(e,t,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/business",function(){return a(456)}])},456:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return eH}});var s=a(52322),n=a(2784),l=a(5632),o=a(35353),i=a(68953);let r=e=>{let[t,a]=(0,n.useState)(null),[s,l]=(0,n.useState)(!0),[o,r]=(0,n.useState)(!1),[d,c]=(0,n.useState)(null),[u,p]=(0,n.useState)(null),m=(0,n.useRef)(0),x=(0,n.useCallback)(async()=>{let t=++m.current;r(!0);try{let s=await i.b.handle(e);if(t!==m.current)return;let n=s.getValue();s.isFailure||!n?c(s.error instanceof Error?s.error:Error("Failed to load business overview")):(a(n),c(null),p(new Date))}catch(e){if(t!==m.current)return;c(e instanceof Error?e:Error("Failed to load business overview"))}finally{t===m.current&&(r(!1),l(!1))}},[e]);return(0,n.useEffect)(()=>{x()},[x]),(0,n.useEffect)(()=>{let e=()=>void x();return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[x]),{data:t,isLoading:s,refreshing:o,error:d,refetch:x,updatedAt:u}},d="business-overview-snapshot",c=(e,t)=>{var a,s;let n=e.attention.find(e=>"UNBILLED_DELIVERED"===e.key);return{at:t.toISOString(),monthKey:e.windows.monthKey,billed:e.billed.amount,collected:e.collected.amount,overdueAmount:e.arAging.overdueAmount,overdueCount:e.arAging.overdueCount,unbilledAmount:null!==(a=null==n?void 0:n.amount)&&void 0!==a?a:0,unbilledCount:null!==(s=null==n?void 0:n.count)&&void 0!==s?s:0,quietKeys:e.atRiskCustomers.map(e=>e.key)}},u=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(Math.abs(e)),p=(e,t,a)=>{var s;if(!t||t.monthKey!==e.windows.monthKey)return{changes:[],since:null};let n=new Date(t.at);if(Number.isNaN(n.getTime())||a.getTime()-n.getTime()<36e5)return{changes:[],since:null};let l=[],o=e.attention.find(e=>"UNBILLED_DELIVERED"===e.key),i=e.billed.amount-t.billed;0!==Math.round(i)&&l.push({key:"billed",tone:i>0?"good":"neutral",text:"".concat(i>0?"Invoiced":"Billing dropped by"," ").concat(u(i))});let r=e.collected.amount-t.collected;r>0&&l.push({key:"collected",tone:"good",text:"Collected ".concat(u(r))});let d=e.arAging.overdueAmount-t.overdueAmount,c=e.arAging.overdueCount-t.overdueCount;0!==Math.round(d)&&l.push({key:"overdue",tone:d>0?"bad":"good",text:d>0?"".concat(u(d)," went past due").concat(c>0?" across ".concat(c," more ").concat(1===c?"invoice":"invoices"):""):"".concat(u(d)," cleared out of past due")});let p=(null!==(s=null==o?void 0:o.amount)&&void 0!==s?s:0)-t.unbilledAmount;0!==Math.round(p)&&l.push({key:"unbilled",tone:p>0?"bad":"good",text:p>0?"".concat(u(p)," delivered and still not invoiced"):"".concat(u(p)," of delivered work got invoiced")});let m=new Set(t.quietKeys),x=e.atRiskCustomers.filter(e=>!m.has(e.key));return x.forEach(e=>{l.push({key:"quiet-".concat(e.key),tone:"bad",text:"".concat(e.name," stopped shipping")})}),{changes:l,since:n}},m=()=>{try{let e=window.localStorage.getItem(d);return e?JSON.parse(e):null}catch(e){return null}},x=e=>{try{window.localStorage.setItem(d,JSON.stringify(e))}catch(e){}},h=["late-1","late-2","late-3"],b=(e,t,a)=>{var s,n,l,o;let i=e.buckets.find(e=>"CURRENT"===e.key),r=e.buckets.find(e=>"NO_DUE_DATE"===e.key),d=e.buckets.filter(e=>e.key.startsWith("D")),c=[{key:"UNBILLED",label:"Delivered, not invoiced",amount:t,count:a,tone:"unbilled",why:"Work you have finished but not billed. Nothing is owed to you until it is."},{key:"CURRENT",label:"Invoiced, within terms",amount:(null!==(s=null==i?void 0:i.amount)&&void 0!==s?s:0)+(null!==(n=null==r?void 0:r.amount)&&void 0!==n?n:0),count:(null!==(l=null==i?void 0:i.count)&&void 0!==l?l:0)+(null!==(o=null==r?void 0:r.count)&&void 0!==o?o:0),tone:"terms",why:"Billed and not yet past the payment terms you agreed."},...d.map((e,t)=>({key:e.key,label:e.label,amount:e.amount,count:e.count,tone:h[Math.min(t,h.length-1)],why:"".concat(e.count," ").concat(1===e.count?"invoice":"invoices"," past the terms you agreed.")}))],u=c.reduce((e,t)=>e+t.amount,0),p=c.filter(e=>e.amount>0).map(e=>({...e,pct:u>0?e.amount/u*100:0}));return{segments:p,total:u}},f=(e,t)=>{let a=e.map(e=>e.partial?Math.max(e.billed,t):e.billed),s=Math.max(...a,0);return e.map((e,n)=>{var l;let o=e.partial?Math.max(0,t-e.billed):0;return{...e,ratio:s>0?e.billed/s:0,projectedTopUp:o,projectedRatio:s>0?(null!==(l=a[n])&&void 0!==l?l:0)/s:0}})},g=e=>{var t,a;let s=new Map,n=(e,t)=>{let a=s.get(e);if(a)return a;let n={key:e,name:t,amount:null,sharePct:null,avgDaysLate:null,onTimePct:null,volume:"steady",atRiskRevenue:null,quietDays:null};return s.set(e,n),n};
1return e.customers.top.forEach(e=>{let t=n(e.key,e.name);t.amount=e.amount,t.sharePct=e.sharePct}),e.payerReliability.forEach(e=>{let t=n(e.key,e.name);t.avgDaysLate=e.avgDaysLate,t.onTimePct=e.onTimePct}),e.atRiskCustomers.forEach(e=>{let t=n(e.key,e.name);t.volume="quiet",t.atRiskRevenue=e.baselineRevenue,t.quietDays=e.daysSinceLastLoad}),s.forEach(e=>{"steady"===e.volume&&null!==e.amount&&null===e.avgDaysLate&&(e.volume="new")}),[...s.values()].sort((e,s)=>(null!==(t=s.amount)&&void 0!==t?t:-1)-(null!==(a=e.amount)&&void 0!==a?a:-1))},v=e=>{if(null===e)return{label:"â",tone:"unknown"};let t=Math.round(e);return t<=-1?{label:"".concat(Math.abs(t),"d early"),tone:"good"}:t<1?{label:"On time",tone:"good"}:t<=7?{label:"".concat(t,"d late"),tone:"warn"}:{label:"".concat(t,"d late"),tone:"bad"}},y=(e,t,a)=>{let s="asc"===a?1:-1,n=(e,a)=>{if("name"===t)return e.name.localeCompare(a.name)*s;let n=e=>"amount"===t?e.amount:"pace"===t?e.avgDaysLate:e.onTimePct,l=n(e),o=n(a);return null===l&&null===o?0:null===l?1:null===o?-1:(l-o)*s};return[...e].sort(n)},j=e=>{if(null==e)return"";let t=String(e);return/[",\n]/.test(t)?'"'.concat(t.replace(/"/g,'""'),'"'):t},N=e=>e.map(e=>e.map(j).join(",")).join("\r\n"),w=e=>{let t=[];return t.push(["TruckAtlas â Business Overview"]),t.push(["Period",e.windows.monthKey]),t.push(["Generated",e.generatedAt]),t.push([]),t.push(["Summary (period)"]),t.push(["Metric","Amount USD","Notes"]),t.push(["Invoiced",e.billed.amount,"".concat(e.billed.count," invoices")]),t.push([" of which adjustments",e.billed.adjustments,"Dispute credit memos"]),t.push(["Collected",e.collected.amount,"".concat(e.collected.count," invoices")]),t.push(["Committed (floor)",e.committed.amount,"Invoiced + delivered-not-invoiced + booked to deliver"]),t.push([]),t.push(["Receivables (as of generation, not the period)"]),t.push(["Bucket","Invoices","Amount USD","Without recorded amount"]),e.arAging.buckets.forEach(e=>{t.push([e.label,e.count,e.amount,e.missingAmountCount])}),t.push(["Total",e.arAging.count,e.arAging.total,e.arAging.missingAmountCount]),t.push([]),t.push(["Customers"]),t.push(["Customer","Invoiced USD","Share %","Avg days late","On-time %","Status"]),g(e).forEach(e=>{t.push([e.name,e.amount,null===e.sharePct?null:Math.round(e.sharePct),e.avgDaysLate,e.onTimePct,"quiet"===e.volume?"Gone quiet":"new"===e.volume?"New":"Steady"])}),t.push([]),t.push(["Monthly history"]),t.push(["Month","Invoiced USD","Collected USD","Partial month"]),e.trend.forEach(e=>{t.push([e.month,e.billed,e.collected,e.partial?"yes":"no"])}),N(t)},k=e=>{let t=new Blob(["\uFEFF",w(e)],{type:"text/csv;charset=utf-8;"}),a=URL.createObjectURL(t),s=document.createElement("a");s.href=a,s.download="business-overview-".concat(e.windows.monthKey,".csv"),document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(a)},D="business-overview-dismissed-quiet",E=e=>"".concat(e.key,"@").concat(e.lastLoadAt),C=()=>{try{let e=window.localStorage.getItem(D),t=e?JSON.parse(e):[];return Array.isArray(t)?t.filter(e=>"string"==typeof e):[]}catch(e){return[]}},S=e=>{try{window.localStorage.setItem(D,JSON.stringify(e))}catch(e){}},T=(e,t)=>{var a;let s=null!==(a=null==e?void 0:e.atRiskCustomers)&&void 0!==a?a:[],n=new Set(s.map(E));return{alerts:s.filter(e=>!t.includes(E(e))),prunedIds:t.filter(e=>n.has(e))}},P=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}),R=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),L=e=>null==e?"â":R.format(e),M=e=>null==e?"â":P.format(e),I=e=>{if(null==e)return"â";let t=e<0?"-":"",a=Math.abs(e);return a>=1e6?"".concat(t,"$").concat((a/1e6).toFixed(a>=1e7?0:1),"M"):a>=1e3?"".concat(t,"$").concat((a/1e3).toFixed(a>=1e4?0:1),"k"):"".concat(t,"$").concat(Math.round(a))},U=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return null==e?"â":"".concat(e.toFixed(t),"%")},O=e=>{if(null==e)return"â";let t=Math.round(e);return"".concat(t>0?"+":"").concat(t,"%")},_=e=>null==e?"unknown":Math.round(e)>0?"up":0>Math.round(e)?"down":"flat",A=(e,t,a)=>"".concat(e," ").concat(1===e?t:null!=a?a:"".concat(t,"s")),F=e=>null==e?"â":A(e,"day"),B=e=>{var t;return e.invoiceNumber?e.invoiceNumber:void 0===e.loadNumber?"Load":"Load #".concat(null!==(t=e.jobNumber)&&void 0!==t?t:"â","-").concat(e.loadNumber)},q=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],a=new Date("".concat(e,"-01T00:00:00Z"));if(Number.isNaN(a.getTime()))return e;let s=new Intl.DateTimeFormat("en-US",{month:"short",timeZone:"UTC"}).format(a);return t?"".concat(s," '").concat(String(a.getUTCFullYear()).slice(2)):s},J=e=>{let t=new Date("".concat(e,"-01T00:00:00Z"));return Number.isNaN(t.getTime())?e:new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(t)},W=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:12,a=Number(e.slice(0,4)),s=Number(e.slice(5,7));if(!Number.isFinite(a)||!Number.isFinite(s))return[e];let n=[];for(let e=0;e<t;e++){let t=new Date(Date.UTC(a,s-1-e,1));n.push("".concat(t.getUTCFullYear(),"-").concat(String(t.getUTCMonth()+1).padStart(2,"0")))}return n},Z=e=>{let t=new Date(e.monthStart).getTime(),a=new Date(e.monthEnd).getTime(),s=new Date(e.monthCutoff).getTime(),n=Math.max(1,Math.round((a-t)/864e5)),l=Math.max(1,Math.min(n,Math.ceil((s-t)/864e5)));return{elapsedDays:l,totalDays:n,fraction:l/n,isPartial:l<n}},Y=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(e),V=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.atRiskCustomers,{billed:s,committed:n,attention:l}=e,o=n.unbilledDelivered+n.scheduledRemaining,i=[];if(t.isPartial?(i.push({text:"You have invoiced "}),i.push({text:Y(s.amount),emphasis:"plain"}),i.push({text:", ".concat(t.elapsedDays," ").concat(1===t.elapsedDays?"day":"days"," in")})):(i.push({text:"The month closed at "}),i.push({text:Y(s.amount),emphasis:"plain"}),i.push({text:" invoiced"})),null!==s.deltaPct){let e=s.deltaPct>=0;i.push({text:" â "}),i.push({text:"".concat(Math.abs(Math.round(s.deltaPct)),"% ").concat(e?"ahead of":"behind"),emphasis:e?"up":"down"}),i.push({text:t.isPartial?" where last month stood at this point.":" the month before."})}else i.push({text:"."});o>0&&(i.push({text:" Another "}),i.push({text:Y(o),emphasis:"plain"}),i.push({text:" is already delivered or booked but not yet invoiced."}));let r=t.isPartial?l[0]:void 0,d=r?"The biggest thing you can act on today is ".concat(Y(r.amount)," in ").concat(r.label.toLowerCase())+(null!==r.oldestDays?", the oldest ".concat(r.oldestDays," days old."):"."):null,c=a[0],u=a.length-1,p=c?u>0?"".concat(a.length," customers have stopped shipping, the longest ").concat(c.daysSinceLastLoad," days ago."):"".concat(c.name," has not shipped in ").concat(c.daysSinceLastLoad," days."):null;return{parts:i,followUp:d,quietNote:p}},K=e=>{let{billed:t,committed:a}=e,s=t.previousAmount,n=1.08*Math.max(a.amount,s,1);return{billedPct:Math.min(100,t.amount/n*100),committedPct:Math.min(100,(a.amount-t.amount)/n*100),markerPct:s>0?Math.min(100,s/n*100):null}},z="rounded-[14px] border border-slate-200 bg-white shadow-[0_7px_22px_rgba(31,59,95,0.05)]",H="p-4 sm:p-5",G="font-poppins text-sm font-semibold text-slate-900",$="font-poppins text-xs text-slate-500",X="font-mono tabular-nums tracking-tight",Q="font-poppins text-[10.5px] font-semibold uppercase tracking-[0.09em] text-slate-500",ee="animate-pulse rounded-md bg-slate-100",et="repeating-linear-gradient(135deg, rgba(14,156,143,0.55) 0px, rgba(14,156,143,0.55) 3px, transparent 3px, transparent 8px)",ea={unbilled:"bg-teal-50 [background-image:repeating-linear-gradient(135deg,rgba(14,156,143,0.55)_0px,rgba(14,156,143,0.55)_3px,transparent_3px,transparent_8px)]",terms:"bg-blue-600","late-1":"bg-red-200","late-2":"bg-red-400","late-3":"bg-red-700"},es={unbilled:"bg-teal-500",terms:"bg-blue-600","late-1":"bg-red-200","late-2":"bg-red-400","late-3":"bg-red-700"},en={plain:"font-semibold text-slate-900",up:"font-semibold text-emerald-700",down:"font-semibold text-red-700"},el=e=>
1{let{data:t,loading:a,quiet:n}=e;if(a||!t)return(0,s.jsxs)("section",{className:"".concat(z," flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:gap-8"),children:[(0,s.jsxs)("div",{className:"flex-1",children:[(0,s.jsx)("div",{className:"".concat(ee," h-6 w-full max-w-xl")}),(0,s.jsx)("div",{className:"".concat(ee," mt-2 h-4 w-2/3")})]}),(0,s.jsx)("div",{className:"".concat(ee," h-16 w-full sm:w-72")})]});let l=Z(t.windows),o=V(t,l,n),i=K(t);return(0,s.jsxs)("section",{className:"".concat(z," grid gap-5 p-5 xl:grid-cols-[minmax(0,1.35fr)_minmax(0,1fr)] xl:items-center xl:gap-8"),"aria-labelledby":"verdict-heading","data-testid":"business-verdict",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{id:"verdict-heading",className:Q,children:"Where the month stands"}),(0,s.jsx)("p",{className:"mt-2 font-poppins text-[19px] leading-snug tracking-tight text-slate-700 [text-wrap:balance]","data-testid":"business-verdict-sentence","data-billed":t.billed.amount,"data-delta-pct":t.billed.deltaPct,children:o.parts.map((e,t)=>(0,s.jsx)("span",{className:e.emphasis?en[e.emphasis]:void 0,children:e.text},t))}),o.quietNote?(0,s.jsx)("p",{className:"mt-2 font-poppins text-[13px] leading-relaxed text-red-700","data-testid":"business-verdict-quiet",children:o.quietNote}):null,o.followUp?(0,s.jsx)("p",{className:"mt-2 font-poppins text-[13px] leading-relaxed text-slate-500","data-testid":"business-verdict-second-line",children:o.followUp}):null]}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,s.jsx)("span",{className:Q,children:"Committed so far"}),(0,s.jsx)("span",{className:"".concat(X," text-[26px] font-bold text-slate-900"),"data-testid":"business-committed","data-amount":t.committed.amount,children:M(t.committed.amount)})]}),(0,s.jsxs)("div",{className:"relative h-[30px] overflow-hidden rounded-[6px] border border-slate-200 bg-slate-100",children:[(0,s.jsx)("div",{className:"absolute inset-y-0 left-0 bg-blue-600",style:{width:"".concat(i.billedPct,"%")},"data-testid":"business-billed","data-amount":t.billed.amount}),(0,s.jsx)("div",{className:"absolute inset-y-0 bg-teal-50",style:{left:"".concat(i.billedPct,"%"),width:"".concat(i.committedPct,"%"),backgroundImage:et}}),null!==i.markerPct?(0,s.jsx)("div",{className:"absolute -inset-y-0.5 w-[2px] bg-slate-900",style:{left:"".concat(i.markerPct,"%")},title:"Last month at this point: ".concat(M(t.billed.previousAmount))}):null]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 font-poppins text-[11px] text-slate-500",children:[(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"h-2.5 w-2.5 rounded-[3px] bg-blue-600"})," Invoiced"]}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"h-2.5 w-2.5 rounded-[3px] bg-teal-50",style:{backgroundImage:et}}),"Delivered or booked"]}),null!==i.markerPct?(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"h-2.5 w-[2px] bg-slate-900"})," Last month, same point"]}):null]}),(0,s.jsx)("p",{className:"font-poppins text-[11px] leading-snug text-slate-400",children:l.isPartial?"Day ".concat(l.elapsedDays," of ").concat(l.totalDays,". Counts only work already delivered or booked â loads you take on later this month are not in it."):"Month closed. Everything delivered has been invoiced or is listed below."})]})]})};var eo=a(39097),ei=a.n(eo),er=a(38474);let ed={UNBILLED:"deliveredNotInvoiced",CURRENT:"withinTerms",D1_30:"late1to30",D31_60:"late31to60",D61_PLUS:"late61plus"},ec=e=>{var t,a,n,l,o,i,r,d;let{data:c,loading:u}=e;if(u||!c)return(0,s.jsxs)("section",{className:"".concat(z," flex flex-col gap-4 p-4 sm:p-5"),children:[(0,s.jsx)("div",{className:"".concat(ee," h-5 w-40")}),(0,s.jsx)("div",{className:"".concat(ee," h-[46px]")}),(0,s.jsx)("div",{className:"".concat(ee," h-16")})]});let p=c.attention.find(e=>"UNBILLED_DELIVERED"===e.key),{segments:m,total:x}=b(c.arAging,null!==(a=null==p?void 0:p.amount)&&void 0!==a?a:0,null!==(n=null==p?void 0:p.count)&&void 0!==n?n:0),h=c.arAging.buckets.find(e=>"NO_DUE_DATE"===e.key),f=null!==(l=null===(t=c.attention.find(e=>"OVERDUE"===e.key))||void 0===t?void 0:t.oldestDays)&&void 0!==l?l:null,g=(e,t)=>"UNBILLED"===e?"".concat(null!=t?t:0," delivered \xb7 bill it and the clock starts"):"CURRENT"===e?(null==h?void 0:h.count)?"".concat(null!=t?t:0," invoices \xb7 ").concat(h.count," with no due date at all"):"".concat(null!=t?t:0," invoices \xb7 owed, not yet due"):"D61_PLUS"===e&&null!==f?"".concat(null!=t?t:0," invoices \xb7 oldest ").
1concat(F(f)," out"):"".concat(null!=t?t:0," ").concat(1===t?"invoice":"invoices");return(0,s.jsxs)("section",{className:"".concat(z," flex flex-col gap-4 p-4 sm:p-5"),"aria-labelledby":"pipeline-heading","data-testid":"business-pipeline",children:[(0,s.jsxs)("header",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{id:"pipeline-heading",className:G,children:"Money in flight"}),(0,s.jsx)("p",{className:$,children:"Everything you have earned that is not yet in the bank"})]}),(0,s.jsxs)("span",{className:"".concat(X," text-[22px] font-bold text-slate-900"),"data-testid":"business-pipeline-total","data-amount":x,children:[M(x),c.arAging.missingAmountCount>0?(0,s.jsx)("span",{className:"ml-1.5 font-poppins text-[11px] font-medium tracking-normal text-amber-600",children:"at least"}):null]})]}),0===x?(0,s.jsx)("p",{className:"font-poppins text-sm text-slate-500",children:"Nothing outstanding â everything delivered has been invoiced and paid."}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"hidden h-[46px] gap-[2px] overflow-hidden rounded-[7px] bg-slate-100 sm:flex",role:"img","aria-label":"Cash pipeline: ".concat(m.map(e=>"".concat(e.label," ").concat(L(e.amount))).join(", ")),children:m.map(e=>(0,s.jsx)("div",{className:"min-w-[3px] ".concat(ea[e.tone]),style:{flex:e.amount},title:"".concat(e.label," â ").concat(L(e.amount),". ").concat(e.why)},e.key))}),(0,s.jsx)("div",{className:"flex flex-col gap-1.5 sm:hidden","aria-hidden":!0,children:m.map(e=>(0,s.jsx)("div",{className:"h-2.5 overflow-hidden rounded-full bg-slate-100",children:(0,s.jsx)("div",{className:"h-full rounded-full ".concat(ea[e.tone]),style:{width:"".concat(Math.max(e.pct,2),"%")}})},e.key))}),(0,s.jsx)("div",{className:"grid gap-x-4 gap-y-3 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-5",children:m.map(e=>(0,s.jsxs)("div",{className:"flex min-w-0 gap-2.5","data-testid":"business-pipeline-segment","data-stage":null!==(o=ed[e.key])&&void 0!==o?o:e.key,"data-amount":e.amount,"data-count":e.count,"data-without-due-date":"CURRENT"===e.key?null!==(i=null==h?void 0:h.count)&&void 0!==i?i:0:void 0,children:[(0,s.jsx)("span",{className:"mt-1 h-2.5 w-2.5 shrink-0 rounded-[3px] ".concat(es[e.tone]),"aria-hidden":!0}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,s.jsx)("span",{className:Q,children:e.label}),(0,s.jsx)("b",{className:"".concat(X," text-[15px] font-semibold ").concat(e.tone.startsWith("late")?"text-red-700":"text-slate-900"),children:M(e.amount)}),(0,s.jsx)("small",{className:"font-poppins text-[11.5px] leading-snug text-slate-400",children:g(e.key,e.count)})]})]},e.key))}),(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-x-4 gap-y-2 border-t border-slate-100 pt-3",children:[(0,s.jsxs)("span",{className:"font-poppins text-xs text-slate-500",children:["Landed this month"," ",(0,s.jsx)("b",{className:"".concat(X," ml-1 text-sm font-semibold text-slate-800"),"data-testid":"business-collected","data-amount":c.collected.amount,"data-count":c.collected.count,children:M(c.collected.amount)}),(0,s.jsxs)("span",{className:"ml-2 text-slate-400","data-testid":"business-days-to-bill","data-days-to-bill":c.cashCycle.daysToInvoice,"data-days-to-pay":c.cashCycle.daysToPay,children:[c.collected.count," paid \xb7 ",null!==(r=c.cashCycle.daysToInvoice)&&void 0!==r?r:"â","d to bill,"," ",null!==(d=c.cashCycle.daysToPay)&&void 0!==d?d:"â","d to be paid"]})]}),(0,s.jsx)(ei(),{href:"".concat(er.Z6.MY_JOBS,"?view=billing"),className:"font-poppins text-[11px] font-bold text-main-blue hover:underline",children:"Open these invoices âº"})]})]})]})},eu={UNBILLED_DELIVERED:{href:"".concat(er.Z6.MY_JOBS,"?view=billing"),cta:"Invoice them"},OVERDUE:{href:"".concat(er.Z6.MY_JOBS,"?view=billing"),cta:"Chase payment"},DRAFT_STUCK:{href:"".concat(er.Z6.MY_JOBS,"?view=billing"),cta:"Finish them"},DISPUTED:{href:"".concat(er.Z6.MY_JOBS,"?view=billing"),cta:"Review disputes"}},ep={OVERDUE:"bg-red-600",UNBILLED_DELIVERED:"bg-teal-500",DRAFT_STUCK:"bg-amber-500",DISPUTED:"bg-slate-400"}
1,em={UNBILLED_DELIVERED:"deliveredNotInvoiced",OVERDUE:"invoicesPastDue",DRAFT_STUCK:"invoicesInDraft",DISPUTED:"moneyInDispute"},ex=e=>{var t,a;let{items:l,leakage:o,loading:i}=e,[r,d]=(0,n.useState)(void 0),c=void 0===r?null!==(a=null===(t=l[0])||void 0===t?void 0:t.key)&&void 0!==a?a:null:r,u=Math.max(...l.map(e=>e.amount),1);return(0,s.jsxs)("section",{className:"".concat(z," ").concat(H," flex flex-col gap-3"),"aria-labelledby":"attention-heading","data-testid":"business-attention",children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h2",{id:"attention-heading",className:G,children:"What needs you"}),(0,s.jsx)("p",{className:$,children:"Ranked by how much money is sitting in it"})]}),i?(0,s.jsx)("div",{className:"flex flex-col gap-2",children:[0,1,2].map(e=>(0,s.jsx)("div",{className:"".concat(ee," h-16")},e))}):0===l.length?(0,s.jsxs)("div",{className:"flex flex-col items-start gap-1 py-4","data-testid":"business-attention-empty",children:[(0,s.jsx)("span",{className:"font-poppins text-sm font-semibold text-slate-800",children:"Nothing stuck"}),(0,s.jsx)("span",{className:"font-poppins text-xs text-slate-500",children:"Everything delivered is invoiced, and nothing is past due."})]}):(0,s.jsx)("ul",{className:"flex flex-col",children:l.map(e=>{var t,a;let n=c===e.key,l=eu[e.key];return(0,s.jsx)("li",{"data-testid":"business-attention-row","data-row":null!==(t=em[e.key])&&void 0!==t?t:e.key,"data-amount":e.amount,"data-count":e.count,"data-oldest-days":e.oldestDays,children:(0,s.jsxs)("button",{type:"button",onClick:()=>d(n?null:e.key),"aria-expanded":n,className:"w-full rounded-[8px] px-2.5 py-2.5 text-left transition-colors hover:bg-slate-50",children:[(0,s.jsxs)("span",{className:"flex items-baseline justify-between gap-3",children:[(0,s.jsx)("span",{className:"font-poppins text-[13.5px] font-medium text-slate-800",children:e.label}),(0,s.jsx)("span",{className:"".concat(X," shrink-0 text-[15px] font-semibold text-slate-900"),children:M(e.amount)})]}),(0,s.jsxs)("span",{className:"mt-0.5 block font-poppins text-[11.5px] text-slate-400",children:[e.count," ",1===e.count?"item":"items",null!==e.oldestDays?" \xb7 oldest ".concat(F(e.oldestDays)):""]}),(0,s.jsx)("span",{className:"mt-1.5 block h-1 overflow-hidden rounded-full bg-slate-100",children:(0,s.jsx)("span",{className:"block h-full rounded-full ".concat(null!==(a=ep[e.key])&&void 0!==a?a:"bg-slate-400"),style:{width:"".concat(e.amount/u*100,"%")}})}),n?(0,s.jsxs)("span",{className:"mt-2 block border-l-2 border-slate-200 pl-2.5",children:[e.detail?(0,s.jsx)("span",{className:"block font-poppins text-[12px] leading-relaxed text-slate-600",children:e.detail}):null,e.refs.length>0?(0,s.jsxs)("span",{className:"mt-1.5 block",children:[e.refs.map(e=>(0,s.jsxs)(ei(),{href:"".concat(er.Z6.JOB_DETAILS,"/").concat(e.jobId),onClick:e=>e.stopPropagation(),className:"flex items-baseline justify-between gap-3 rounded-[6px] px-1 py-1 hover:bg-white","data-testid":"business-attention-ref","data-job-id":e.jobId,"data-amount":e.amount,"data-days":e.days,children:[(0,s.jsxs)("span",{className:"min-w-0 truncate font-poppins text-[12px] text-slate-700",children:[e.name,(0,s.jsx)("span",{className:"ml-1.5 text-slate-400",children:B(e)})]}),(0,s.jsxs)("span",{className:"shrink-0 font-poppins text-[11px] text-slate-400",children:[null!==e.days?"".concat(e.days,"d \xb7 "):"",(0,s.jsx)("span",{className:"".concat(X," text-slate-700"),children:L(e.amount)})]})]},e.id)),e.refsTruncated?(0,s.jsxs)("span",{className:"mt-0.5 block px-1 font-poppins text-[11px] text-slate-400",children:["and ",e.count-e.refs.length," more"]}):null]}):null,l?(0,s.jsxs)(ei(),{href:l.href,className:"mt-1.5 inline-block font-poppins text-[11px] font-bold text-main-blue hover:underline",onClick:e=>e.stopPropagation(),children:[l.cta," âº"]}):null]}):null]})},e.key)})}),!i&&o&&o.count>0?(0,s.jsxs)("div",{className:"border-t border-slate-100 pt-2.5","data-testid":"business-dispute-leakage","data-amount":o.amount,"data-count":o.count,children:[(0,s.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,s.jsx)("span",{className:"font-poppins text-xs text-slate-500",children:"Conceded on disputes this month"}),(0,s.jsxs)("span",{className:"".concat(X," text-sm font-semibold text-slate-700"),
1children:["-",M(o.amount)]})]}),(0,s.jsxs)("p",{className:"mt-0.5 font-poppins text-[11px] text-slate-400",children:[o.count," resolved ",1===o.count?"dispute":"disputes"," settled below the original rate",null!==o.pctOfDisputedValue?" â ".concat(o.pctOfDisputedValue,"% of their value"):"","."]})]}):null]})},eh={top:14,right:10,bottom:26,left:46},eb=720-eh.left-eh.right,ef=220-eh.top-eh.bottom,eg="#2563eb",ev="#0E9C8F",ey=e=>"".concat(q(e.month,!0),": ").concat(L(e.billed)," invoiced, ").concat(L(e.collected)," collected").concat(e.projectedTopUp>0?", ".concat(L(e.projectedTopUp)," still committed"):""),ej=e=>{let{trend:t,committedTotal:a}=e,[l,o]=(0,n.useState)(null),i=f(t,a);if(!i.length)return null;let r=1.08*Math.max(...i.map(e=>Math.max(e.billed+e.projectedTopUp,e.collected)),1),d=e=>eh.top+ef-e/r*ef,c=eb/i.length,u=Math.min(.52*c,30),p=e=>eh.left+e*c+c/2,m=i[null!=l?l:i.length-1];return(0,s.jsxs)("figure",{className:"m-0 flex flex-col gap-2.5","data-testid":"business-trend",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-0.5",children:[(0,s.jsx)("span",{className:"font-poppins text-[13px] font-semibold text-slate-800",children:q(m.month,!0)}),(0,s.jsxs)("span",{className:"font-mono text-[13px] tabular-nums text-slate-700",children:[L(m.billed),(0,s.jsx)("span",{className:"ml-1 font-poppins text-[11px] font-normal text-slate-400",children:"invoiced"})]}),(0,s.jsxs)("span",{className:"font-mono text-[13px] tabular-nums text-teal-700",children:[L(m.collected),(0,s.jsx)("span",{className:"ml-1 font-poppins text-[11px] font-normal text-slate-400",children:"collected"})]}),m.projectedTopUp>0?(0,s.jsxs)("span",{className:"font-mono text-[13px] tabular-nums text-slate-500",children:[L(m.projectedTopUp),(0,s.jsx)("span",{className:"ml-1 font-poppins text-[11px] font-normal text-slate-400",children:"still committed"})]}):null,null===l?(0,s.jsx)("span",{className:"font-poppins text-[11px] text-slate-300",children:"pick a month"}):null]}),(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("svg",{viewBox:"0 0 ".concat(720," ").concat(220),className:"h-auto w-full min-w-[480px]",role:"img","aria-label":"Invoiced revenue and collections by month for the last ".concat(i.length," months"),children:[(0,s.jsx)("defs",{children:(0,s.jsxs)("pattern",{id:"committedHatch",width:"8",height:"8",patternUnits:"userSpaceOnUse",patternTransform:"rotate(135)",children:[(0,s.jsx)("rect",{width:"8",height:"8",fill:"#E6F7F4"}),(0,s.jsx)("line",{x1:"0",y1:"0",x2:"0",y2:"8",stroke:ev,strokeWidth:"3",strokeOpacity:"0.5"})]})}),[0,.5,1].map(e=>(0,s.jsxs)("g",{children:[(0,s.jsx)("line",{x1:eh.left,x2:720-eh.right,y1:d(r*e),y2:d(r*e),stroke:"#e2e8f0"}),(0,s.jsx)("text",{x:eh.left-8,y:d(r*e)+3,textAnchor:"end",className:"fill-slate-400 font-mono text-[10px] tabular-nums",children:I(r*e)})]},e)),i.map((e,t)=>{let a=p(t)-u/2,n=d(e.billed),i=d(e.billed+e.projectedTopUp),r=l===t;return(0,s.jsxs)("g",{"data-testid":"business-trend-bar","data-month":e.month,"data-invoiced":e.billed,"data-collected":e.collected,"data-committed":e.billed+e.projectedTopUp,children:[(0,s.jsxs)("g",{tabIndex:0,role:"button","aria-label":ey(e),onMouseEnter:()=>o(t),onMouseLeave:()=>o(null),onFocus:()=>o(t),onBlur:()=>o(null),className:"cursor-pointer outline-none [&:focus-visible>rect]:stroke-blue-600 [&:focus-visible>rect]:[stroke-width:2]",children:[(0,s.jsx)("rect",{x:p(t)-c/2,y:eh.top,width:c,height:ef,rx:4,fill:r?"rgba(37,99,235,0.06)":"transparent"}),(0,s.jsx)("title",{children:ey(e)})]}),e.projectedTopUp>0?(0,s.jsx)("rect",{x:a,y:i,width:u,height:Math.max(0,n-i),rx:4,fill:"url(#committedHatch)",stroke:ev,strokeDasharray:"3 2",strokeOpacity:.55}):null,(0,s.jsx)("rect",{x:a,y:n,width:u,height:Math.max(1,eh.top+ef-n),rx:4,fill:eg,opacity:null===l||r?1:.45,pointerEvents:"none"}),(0,s.jsx)("text",{x:p(t),y:212,textAnchor:"middle",pointerEvents:"none",className:"text-[10px] ".concat(r||e.partial?"fill-slate-700 font-semibold":"fill-slate-400"),children:q(e.month)})]},e.month)}),(0,s.jsx)("polyline",{points:i.map((e,t)=>"".concat(p(t),",").concat(d(e.collected))).join(" "),fill:"none",stroke:ev,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round"}),i.map((e,t)=>(0,s.jsx)("circle",{cx:p(t),cy:d(e.collected),r:3.2,fill:ev,stroke:"#fff",strokeWidth:2},"c-".concat(e.month)))]})}),(0,s.jsxs)("figcaption",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 font-poppins text-[11.5px] text-slate-500",children:[(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"h-2.5 w-2.5 rounded-[3px]",style:{backgroundColor:eg}})," ","Invoiced"]}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"h-0.5 w-3.5 rounded-full",style:{backgroundColor:ev}})," ","Collected"]}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:[(0,s.jsx)("span",{className:"h-2.5 w-2.5 rounded-[3px] border border-teal-300",style:{backgroundImage:"repeating-linear-gradient(135deg, rgba(14,156,143,0.5) 0 2px, transparent 2px 4px)"}}),"Committed, not yet invoiced"]})]})]})},eN={good:"bg-emerald-50 text-emerald-700",warn:"bg-amber-50 text-amber-700",bad:"bg-red-50 text-red-700",unknown:"bg-slate-100 text-slate-400"},ew=e=>{let{tone:t,children:a,dot:n=!0}=e;return(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-0.5 font-poppins text-[11.5px] font-semibold ".concat(t),children:[n?(0,s.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-current"}):null,a]})},ek=[{label:"Customer",key:"name",initial:"asc"},{label:"Share",key:"amount",initial:"desc"},{label:"Invoiced",key:"amount",initial:"desc"},{label:"Pays",key:"pace",initial:"desc"},{label:"On time",key:"onTime",initial:"asc"},{label:"Volume",key:null,initial:"desc"}],eD=e=>{var t,a;let{data:l,loading:o,onSelect:i,quiet:r,onDismissQuiet:d}
1=e,[c,u]=(0,n.useState)({key:"amount",direction:"desc"}),p=(0,n.useMemo)(()=>l?y(g(l),c.key,c.direction):[],[l,c]),m=null!==(t=null==l?void 0:l.customers.concentrationPct)&&void 0!==t?t:null,x=null!==(a=null==l?void 0:l.customers.top[0])&&void 0!==a?a:null;return(0,s.jsxs)("section",{className:"".concat(z," ").concat(H," flex flex-col gap-3"),"aria-labelledby":"customers-heading",children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h2",{id:"customers-heading",className:G,children:"Customers"}),(0,s.jsx)("p",{className:$,children:"What each one is worth, and what they are like to be paid by"})]}),o?(0,s.jsx)("div",{className:"flex flex-col gap-2",children:[0,1,2,3].map(e=>(0,s.jsx)("div",{className:"".concat(ee," h-9")},e))}):0===p.length?(0,s.jsx)("p",{className:"font-poppins text-sm text-slate-500","data-testid":"business-customers-empty",children:"Nothing invoiced this month yet."}):(0,s.jsxs)(s.Fragment,{children:[null!==m&&m>=30&&x?(0,s.jsxs)("p",{className:"rounded-[10px] border border-amber-200 bg-amber-50/60 px-3 py-2 font-poppins text-xs text-amber-800","data-testid":"business-concentration","data-customer-name":x.name,"data-pct":m,children:[(0,s.jsx)("span",{className:"font-semibold",children:x.name})," is ",U(m)," of what you invoiced this period. Anything over ",30,"% from one customer is worth watching."]}):null,r.length>0?(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3 rounded-[10px] border border-red-200 bg-red-50/60 px-3 py-2","data-testid":"business-quiet-alert","data-count":r.length,children:[(0,s.jsx)("div",{className:"font-poppins text-xs text-red-800",children:1===r.length?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"font-semibold","data-testid":"business-quiet-customer","data-customer-name":r[0].name,"data-days":r[0].daysSinceLastLoad,children:r[0].name})," has not shipped in ".concat(r[0].daysSinceLastLoad," days â they used to send one about every ").concat(Math.round(r[0].cadenceDays),". Worth a call.")]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{className:"font-semibold",children:[r.length," customers have stopped shipping"]})," â ".concat(M(r.reduce((e,t)=>e+t.baselineRevenue,0))," of business over the last three months. "),r.map(e=>"".concat(e.name," (").concat(e.daysSinceLastLoad,"d)")).join(", "),"."]})}),(0,s.jsx)("button",{type:"button",onClick:d,className:"shrink-0 rounded-[8px] px-2 py-0.5 font-poppins text-[11px] font-medium text-red-700 hover:bg-white","data-testid":"business-quiet-dismiss",children:"Dismiss"})]}):null,(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full min-w-[620px] border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{className:"border-b border-slate-200 text-left",children:ek.map((e,t)=>{let a=null!==e.key&&c.key===e.key;return(0,s.jsx)("th",{scope:"col","aria-sort":a?"asc"===c.direction?"ascending":"descending":"none",className:"pb-2 font-poppins text-[10.5px] font-semibold uppercase tracking-[0.09em] ".concat(0===t?"":"text-right"," ").concat(a?"text-slate-800":"text-slate-500"),children:e.key?(0,s.jsxs)("button",{type:"button",onClick:()=>u(t=>t.key===e.key?{key:e.key,direction:"asc"===t.direction?"desc":"asc"}:{key:e.key,direction:e.initial}),className:"inline-flex items-center gap-1 uppercase tracking-[0.09em] hover:text-slate-900",children:[e.label,(0,s.jsx)("span",{"aria-hidden":!0,className:a?"opacity-100":"opacity-0",children:"asc"===c.direction?"â²":"â¼"})]}):e.label},e.label)})})}),(0,s.jsx)("tbody",{children:p.map(e=>{var t;let a=v(e.avgDaysLate);return(0,s.jsxs)("tr",{onClick:()=>i(e),className:"cursor-pointer border-b border-slate-50 last:border-0 hover:bg-slate-50","data-testid":"business-customer-row","data-customer-name":e.name,children:[(0,s.jsxs)("td",{className:"py-2.5 pr-3",children:[(0,s.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation(),i(e)},className:"text-left font-poppins text-[13.5px] font-medium text-slate-800 hover:text-blue-700 hover:underline",children:e.name}),"quiet"===e.volume?(0,s.jsxs)("span",{className:"block font-poppins text-[11px] text-slate-400",children:[null!==e.quietDays?"No loads in ".concat(e.quietDays," days"):"Has stopped shipping",null!==e.atRiskRevenue?" \xb7 was worth ".concat(M(e.atRiskRevenue)):""]}):null]}),(0,s.jsx)("td",{className:"py-2.5 text-right","data-testid":"business-customer-share","data-share-pct":e.sharePct,children:(0,s.jsxs)("span",{className:"inline-flex items-center justify-end gap-2",children:[(0,s.jsx)("span",{className:"".concat(X," text-[12.5px] text-slate-500"),children:null!==e.sharePct?"".concat(Math.round(e.sharePct),"%"):"â"}),(0,s.jsx)("span",{className:"h-1.5 w-[54px] shrink-0 overflow-hidden rounded-full bg-slate-100",children:(0,s.jsx)("span",{className:"block h-full rounded-full bg-blue-600",style:{width:"".concat(null!==(t=e.sharePct)&&void 0!==t?t:0,"%")}})})]})}),(0,s.jsx)("td",{className:"".concat(X," py-2.5 pl-3 text-right text-[13.5px] text-slate-900"),"data-testid":"business-customer-invoiced","data-amount":e.amount,children:null!==e.amount?L(e.amount):(0,s.jsx)("span",{className:"text-slate-300",children:"â"})}),(0,s.jsx)("td",{className:"py-2.5 pl-3 text-right","data-testid":"business-customer-pace","data-avg-days-late":e.avgDaysLate,children:(0,s.jsx)(ew,{tone:eN[a.tone],dot:"unknown"!==a.tone,children:a.label})}),(0,s.jsx)("td",{className:"".concat(X," py-2.5 pl-3 text-right text-[13.5px] text-slate-600"),"data-testid":"business-customer-ontime","data-on-time-pct":e.onTimePct,children:U(e.onTimePct)}),(0,s.jsx)("td",{className:"py-2.5 pl-3 text-right","data-testid":"business-customer-status","data-volume":e.volume,children:"new"===e.volume?(0,s.jsx)(ew,{tone:"bg-emerald-50 text-emerald-700",children:"New"}):"quiet"===e.volume?(0,s.jsx)(ew,{tone:"bg-red-50 text-red-700",children:"Gone quiet"}):(0,s.jsx)(ew,{tone:"bg-slate-100 text-slate-500",dot:!1,children:"Steady"})})]},e.key)})})]})}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,s.jsx)("p",{className:"font-poppins text-[11px] leading-relaxed text-slate-400",children:"Select a customer for everything known about them. A dash under Invoiced means the customer shipped nothing this period â not that the relationship is over. Payment pace covers the last 12 months, not just this month."}),(0,s.jsx)(ei(),{href:er.Z6.COMPANY_DIRECTORY,className:"shrink-0 font-poppins text-[11px] font-bold text-main-blue hover:underline",children:"Open your customer directory âº"})]})]})]})},eE=e=>{let{label:t,value:a,note:n,loading:l,muted:o,figure:i}=e;return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5 bg-white px-4 py-3.5","data-testid":"business-ops-tile","data-figure":i,children:[(0,s.jsx)("span",{className:Q,children:t}),l?(0,s.jsx)("div",{className:"".concat(ee," h-6 w-16")}):(0,s.jsx)("b",{className:"".concat(X," text-[20px] font-semibold ").concat(o?"text-slate-400":"text-slate-900"),"data-testid":"business-ops-value",children:a}),(0,s.jsx)("small",{className:"font-poppins text-[11px] leading-snug text-slate-400","data-testid":"business-ops-sub",children:n})]})},eC=e=>{var t,a,n;let{data:l,loading:o}=e,i=null==l?void 0:l.operations,r=null==l?void 0:l.utilization;return(0,s.jsxs)("section",{"aria-labelledby":"ops-heading",className:"flex flex-col gap-2",children:[(0,s.jsx)("h2",{id:"ops-heading",className:"".concat(Q," ml-0.5"),children:"How the month ran"}),(0,s.jsxs)("div",{className:"grid gap-px overflow-hidden rounded-[14px] border border-slate-200 bg-slate-200 shadow-[0_7px_22px_rgba(31,59,95,0.05)] sm:grid-cols-3 xl:grid-cols-6",children:[(0,s.jsx)(eE,{label:"Loads delivered",figure:"loadsDelivered",value:i?String(i.loadsDelivered):"â",note:i?"plus ".concat(i.inTransit," on the road right now"):"",loading:o}),(0,s.jsx)(eE,{label:"On-time delivery",figure:"onTimeDelivery",value:U(null!==(t=null==i?void 0:i.onT
1imeDeliveryPct)&&void 0!==t?t:null),note:(null==i?void 0:i.deliveryCounts)?"".concat(i.deliveryCounts.onTime," of ").concat(i.deliveryCounts.total," measured"):(null==i?void 0:i.truncated)?"too many loads to measure exactly":"no scheduled stops to measure",loading:o}),(0,s.jsx)(eE,{label:"Fleet loaded",figure:"fleetLoaded",value:U(null!==(a=null==r?void 0:r.pct)&&void 0!==a?a:null),note:r?"".concat(r.loadedDays," of ").concat(r.availableDays," driver-days")+(null!==r.coveragePct&&r.coveragePct<90?" \xb7 only ".concat(r.coveragePct,"% measurable"):""):"",loading:o}),(0,s.jsx)(eE,{label:"Revenue per mile",figure:"revenuePerMile",value:(null==i?void 0:i.ratePerMile)!==void 0&&null!==i.ratePerMile?L(i.ratePerMile):"â",note:"loads with recorded miles",loading:o}),(0,s.jsx)(eE,{label:"Quotes won",figure:"quotesWon",value:U(null!==(n=null==l?void 0:l.winRate.pct)&&void 0!==n?n:null),note:l?"".concat(l.winRate.won," of ").concat(l.winRate.won+l.winRate.lost," decided"):"",loading:o}),(0,s.jsx)(eE,{label:"Per truck / week",figure:"perTruckPerWeek",value:i?M(i.revenuePerTruckPerWeek):"â",note:(null==i?void 0:i.truckCount)?"across ".concat(i.truckCount," ").concat(1===i.truckCount?"truck":"trucks"):"set your fleet size on the company profile",muted:!(null==i?void 0:i.truckCount),loading:o})]}),l&&l.unavailable.length>0?(0,s.jsxs)("p",{className:"ml-0.5 font-poppins text-[11px] leading-relaxed text-slate-400","data-testid":"business-not-measured",children:["Not measured:"," ",l.unavailable.map((e,t)=>(0,s.jsxs)("span",{children:[t>0?" \xb7 ":"",e.reason.toLowerCase()]},e.key)),"."]}):null]})},eS={up:"text-emerald-600",down:"text-red-600",flat:"text-slate-400",unknown:"text-slate-300"},eT=e=>{let{lanes:t,winRate:a,loading:n}=e;return(0,s.jsxs)("section",{className:"".concat(z," ").concat(H," flex flex-col gap-3"),children:[(0,s.jsxs)("header",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:G,children:"Lanes & pricing"}),(0,s.jsx)("p",{className:$,children:"Delivered this month, by corridor"})]}),!n&&a?(0,s.jsxs)("div",{className:"flex flex-col items-end",children:[(0,s.jsx)("span",{className:"".concat(X," text-lg font-bold text-slate-900"),children:U(a.pct)}),(0,s.jsxs)("span",{className:"font-poppins text-[11px] text-slate-400",children:["quotes won (",a.won,"/",a.won+a.lost,")"]}),a.pending>0?(0,s.jsxs)("span",{className:"font-poppins text-[11px] text-slate-400",children:[a.pending," still open"]}):null]}):null]}),n?(0,s.jsx)("div",{className:"flex flex-col gap-2",children:[0,1,2,3].map(e=>(0,s.jsx)("div",{className:"".concat(ee," h-8")},e))}):0===t.length?(0,s.jsx)("p",{className:"font-poppins text-sm text-slate-500","data-testid":"business-lanes-empty",children:"No loads delivered this month yet."}):(0,s.jsx)("div",{className:"overflow-x-auto",children:(0,s.jsxs)("table",{className:"w-full min-w-[380px] border-collapse",children:[(0,s.jsx)("thead",{children:(0,s.jsx)("tr",{className:"border-b border-slate-100 text-left",children:["Lane","Loads","Revenue","$/mi","vs last mo."].map((e,t)=>(0,s.jsx)("th",{className:"pb-1.5 font-poppins text-[11px] font-semibold uppercase tracking-wide text-slate-400 ".concat(0===t?"":"text-right"),children:e},e))})}),(0,s.jsx)("tbody",{children:t.map(e=>(0,s.jsxs)("tr",{className:"border-b border-slate-50 last:border-0","data-testid":"business-lane-row","data-origin":e.origin,"data-destination":e.destination,"data-loads":e.loads,"data-revenue":e.revenue,"data-rate-per-mile":e.ratePerMile,"data-delta-pct":e.ratePerMileDeltaPct,children:[(0,s.jsxs)("td",{className:"py-2 pr-3 font-poppins text-xs font-semibold text-slate-700",children:[e.origin," ",(0,s.jsx)("span",{className:"text-slate-300",children:"â"})," ",e.destination]}),(0,s.jsx)("td",{className:"".concat(X," py-2 text-right text-xs text-slate-600"),children:e.loads}),(0,s.jsx)("td",{className:"".concat(X," py-2 pl-3 text-right text-xs text-slate-800"),children:M(e.revenue)}),(0,s.jsx)("td",{className:"".concat(X," py-2 pl-3 text-right text-xs font-semibold text-slate-900"),children:null!==e.ratePerMile?L(e.ratePerMile):"â"}),(0,s.jsx)("td",{className:"".concat(X," py-2 pl-3 text-right text-xs font-medium ").
1concat(eS[_(e.ratePerMileDeltaPct)]),children:O(e.ratePerMileDeltaPct)})]},e.key))})]})})]})};var eP=a(44629);let eR={LOAD_PAID:"bg-emerald-500",LOAD_COMPLETED:"bg-blue-500",JOB_POSTED:"bg-violet-500",JOB_COVERED:"bg-sky-500",JOB_EXPIRED:"bg-amber-500",RATE_CON_CARRIER_SIGNED:"bg-slate-400"},eL=e=>{let{activity:t,loading:a,open:l,onClose:o}=e,i=(0,n.useRef)(null);return((0,n.useEffect)(()=>{var e;if(!l)return;null===(e=i.current)||void 0===e||e.focus();let t=e=>{"Escape"===e.key&&o()};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[l,o]),l)?(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex justify-end",children:[(0,s.jsx)("button",{type:"button","aria-label":"Close recent activity",onClick:o,className:"absolute inset-0 bg-slate-900/25"}),(0,s.jsxs)("aside",{role:"dialog","aria-modal":"true","aria-label":"Recent activity",className:"relative flex h-full w-full max-w-[380px] flex-col gap-3 border-l border-slate-200 bg-white p-5 shadow-2xl",children:[(0,s.jsxs)("header",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:G,children:"Recent activity"}),(0,s.jsx)("p",{className:"font-poppins text-xs text-slate-500",children:"Across the whole company"})]}),(0,s.jsx)("button",{ref:i,type:"button",onClick:o,className:"rounded-[8px] border border-slate-200 px-2.5 py-1 font-poppins text-xs font-medium text-slate-600 hover:border-blue-600 hover:text-blue-700",children:"Close"})]}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:a?(0,s.jsx)("div",{className:"flex flex-col gap-2",children:[0,1,2,3,4].map(e=>(0,s.jsx)("div",{className:"".concat(ee," h-9")},e))}):0===t.length?(0,s.jsx)("p",{className:"font-poppins text-sm text-slate-500",children:"No recent activity."}):(0,s.jsx)("ul",{className:"flex flex-col",children:t.map(e=>{var t;let a=(0,s.jsxs)("div",{className:"flex items-start gap-2.5 py-2",children:[(0,s.jsx)("span",{className:"mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ".concat(null!==(t=eR[e.type])&&void 0!==t?t:"bg-slate-300")}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[(0,s.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,s.jsx)("span",{className:"truncate font-poppins text-xs font-medium text-slate-800",children:e.title}),"number"==typeof e.amount?(0,s.jsx)("span",{className:"".concat(X," shrink-0 text-xs font-semibold text-slate-700"),children:L(e.amount)}):null]}),(0,s.jsxs)("span",{className:"font-poppins text-[11px] text-slate-400",children:[e.subtitle?"".concat(e.subtitle," \xb7 "):"",(0,eP.J)(e.at)]})]})]});return(0,s.jsx)("li",{className:"border-b border-slate-50 last:border-0",children:e.loadRef?(0,s.jsx)(ei(),{href:"".concat(er.Z6.JOB_DETAILS,"/").concat(e.loadRef.jobId),className:"block rounded-[8px] px-1 hover:bg-slate-50",onClick:o,children:a}):a},e.id)})})})]})]}):null},eM=e=>{let{scope:t,label:a,hint:n}=e;return(0,s.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1 pt-1",children:[(0,s.jsx)("h2",{className:Q,children:a}),(0,s.jsx)("span",{className:"inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 font-poppins text-[10.5px] font-semibold ".concat("now"===t?"bg-slate-900/[0.06] text-slate-600":"bg-blue-50 text-blue-700"),children:"now"===t?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"}),"Right now"]}):a&&"This period"}),n?(0,s.jsx)("span",{className:"font-poppins text-[11px] text-slate-400",children:n}):null]})},eI=e=>e.trend.every(e=>0===e.billed&&0===e.collected)&&0===e.arAging.total&&0===e.attention.length&&0===e.operations.loadsDelivered&&0===e.operations.inTransit,eU=[{title:"Take a load",body:"Apply on the load board, or accept a tender someone sent you. Booked work shows up here before it delivers.",href:er.Z6.PUBLIC_JOBS,cta:"Open the load board"},{title:"Deliver it and upload the POD",body:'The proof of delivery is what unlocks invoicing â until it lands, the load sits in "delivered, not invoiced".',href:er.Z6.MY_JOBS,cta:"See your loads"},{title:"Send the invoice",body:"From the moment you bill, this page tracks what you are owed, who is late, and how long each customer takes to pay.",href:"".concat(er.Z6.MY_JOBS,"?view=billing"),cta:"Go to billing"}],eO=()=>(0,s.jsxs)("section",{className:"".concat(z," flex flex-col gap-4 p-5 sm:p-6"),"aria-labelledby":"firstrun-heading","data-testid":"business-first-run",children:[(0,s.jsxs)("header",{className:"flex flex-col gap-1",children:[(0,s.jsx)("h2",{id:"firstrun-heading",className:"font-poppins text-lg font-bold text-primary",children:"Nothing to report yet"}
1),(0,s.jsx)("p",{className:"max-w-[62ch] font-poppins text-sm leading-relaxed text-slate-500",children:"This page fills itself in as you run freight. It follows one thing â your money â from the moment a load is delivered to the day it lands in the bank."})]}),(0,s.jsx)("ol",{className:"grid gap-3 sm:grid-cols-3",children:eU.map((e,t)=>(0,s.jsxs)("li",{className:"flex flex-col gap-1.5 rounded-[12px] border border-slate-200 bg-slate-50/60 p-4",children:[(0,s.jsx)("span",{className:"font-mono text-[11px] font-semibold tabular-nums text-slate-400",children:String(t+1).padStart(2,"0")}),(0,s.jsx)("h3",{className:G,children:e.title}),(0,s.jsx)("p",{className:"font-poppins text-xs leading-relaxed text-slate-500",children:e.body}),(0,s.jsxs)(ei(),{href:e.href,className:"mt-auto pt-1 font-poppins text-[11px] font-bold text-main-blue hover:underline",children:[e.cta," âº"]})]},e.title))}),(0,s.jsx)("p",{className:"font-poppins text-[11px] leading-relaxed text-slate-400",children:"Two things worth setting up now, because this page reads them: your fleet size on the company profile (it is the denominator for revenue per truck), and payment terms when you post or accept a job â an invoice with no terms can never be flagged as late."})]}),e_={good:"text-emerald-700",bad:"text-red-700",neutral:"text-slate-600"},eA={good:"bg-emerald-500",bad:"bg-red-500",neutral:"bg-slate-400"},eF=e=>{let{changes:t,since:a,onDismiss:n}=e;return t.length&&a?(0,s.jsxs)("section",{className:"flex flex-col gap-2 rounded-[14px] border border-slate-300 bg-slate-50 p-4","aria-label":"What changed since your last visit","data-testid":"business-since-last-look",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("h2",{className:"font-poppins text-[13px] font-semibold text-slate-800",children:["Since you last looked"," ",(0,s.jsxs)("span",{className:"font-normal text-slate-400",children:["\xb7 ",(0,eP.J)(a.toISOString()).toLowerCase()]})]}),(0,s.jsx)("button",{type:"button",onClick:n,className:"shrink-0 rounded-[8px] px-2 py-0.5 font-poppins text-[11px] font-medium text-slate-500 hover:bg-white hover:text-slate-800",children:"Dismiss"})]}),(0,s.jsx)("ul",{className:"flex flex-wrap gap-x-5 gap-y-1.5",children:t.map(e=>(0,s.jsxs)("li",{className:"inline-flex items-center gap-2","data-testid":"business-since-last-look-item","data-change":e.key,"data-tone":e.tone,children:[(0,s.jsx)("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full ".concat(eA[e.tone]),"aria-hidden":!0}),(0,s.jsx)("span",{className:"font-poppins text-[13px] ".concat(e_[e.tone]),children:e.text})]},e.key))})]}):null},eB=e=>{let{label:t,value:a,note:n}=e;return(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:Q,children:t}),(0,s.jsx)("b",{className:"".concat(X," text-[17px] font-semibold text-slate-900"),children:a}),n?(0,s.jsx)("small",{className:"font-poppins text-[11px] text-slate-400",children:n}):null]})},eq=e=>{let{customer:t,data:a,onClose:l}=e,o=(0,n.useRef)(null);if((0,n.useEffect)(()=>{var e;if(!t)return;null===(e=o.current)||void 0===e||e.focus();let a=e=>{"Escape"===e.key&&l()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t,l]),!t||!a)return null;let i=v(t.avgDaysLate),r=a.attention.flatMap(e=>e.refs.filter(e=>e.name===t.name).map(t=>({...t,bucket:e.label})));return(0,s.jsxs)("div",{className:"fixed inset-0 z-50 flex justify-end",children:[(0,s.jsx)("button",{type:"button","aria-label":"Close customer detail",onClick:l,className:"absolute inset-0 bg-slate-900/25"}),(0,s.jsxs)("aside",{role:"dialog","aria-modal":"true","aria-label":"".concat(t.name," detail"),className:"relative flex h-full w-full max-w-[400px] flex-col gap-4 overflow-auto border-l border-slate-200 bg-white p-5 shadow-2xl","data-testid":"business-customer-panel","data-customer-name":t.name,children:[(0,s.jsxs)("header",{className:"flex items-start justify-between gap-3",children:[(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("h2",{className:G,children:t.name}),(0,s.jsx)("p",{className:"font-poppins text-xs text-slate-500",children:"quiet"===t.volume?null!==t.quietDays?"No loads in ".concat(t.quietDays," days"):"Has stopped shipping with you":"new"===t.volume?"First period shipping with you":"Shipping steadily"})]}),(0,s.jsx)("button",{ref:o,type:"button",onClick:l,className:"shrink-0 rounded-[8px] border border-slate-200 px-2.5 py-1 font-poppins text-xs font-medium text-slate-600 hover:border-blue-600 hover:text-blue-700",children:"Close"})]}
1),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4 rounded-[12px] border border-slate-200 bg-slate-50/60 p-4",children:[(0,s.jsx)(eB,{label:"Invoiced this period",value:null!==t.amount?L(t.amount):"â",note:null!==t.sharePct?"".concat(Math.round(t.sharePct),"% of the period"):"Nothing billed"}),(0,s.jsx)(eB,{label:"Pays",value:i.label,note:"Against their own due dates"}),(0,s.jsx)(eB,{label:"On time",value:U(t.onTimePct),note:"Over the last 12 months"}),(0,s.jsx)(eB,{label:"quiet"===t.volume?"Was worth":"Status",value:null!==t.atRiskRevenue?M(t.atRiskRevenue):"new"===t.volume?"New":"Steady",note:null!==t.atRiskRevenue?"Over the last three months":void 0})]}),r.length>0?(0,s.jsxs)("section",{className:"flex flex-col gap-2",children:[(0,s.jsx)("h3",{className:Q,children:"What is stuck with them"}),(0,s.jsx)("ul",{className:"flex flex-col",children:r.map(e=>(0,s.jsx)("li",{className:"border-b border-slate-50 last:border-0",children:(0,s.jsxs)(ei(),{href:"".concat(er.Z6.JOB_DETAILS,"/").concat(e.jobId),onClick:l,className:"flex items-baseline justify-between gap-3 rounded-[8px] px-1 py-2 hover:bg-slate-50",children:[(0,s.jsxs)("span",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"block truncate font-poppins text-xs font-medium text-slate-800",children:B(e)}),(0,s.jsx)("span",{className:"font-poppins text-[11px] text-slate-400",children:e.bucket})]}),(0,s.jsxs)("span",{className:"shrink-0 text-right",children:[(0,s.jsx)("span",{className:"".concat(X," block text-xs font-semibold text-slate-800"),children:L(e.amount)}),null!==e.days?(0,s.jsx)("span",{className:"font-poppins text-[11px] text-slate-400",children:F(e.days)}):null]})]})},e.id))})]}):(0,s.jsx)("p",{className:"font-poppins text-xs text-slate-500",children:"Nothing of theirs is stuck â no overdue invoices and no delivered work waiting to be billed."}),(0,s.jsx)(ei(),{href:er.Z6.COMPANY_DIRECTORY,className:"mt-auto font-poppins text-[11px] font-bold text-main-blue hover:underline",children:"Open in your customer directory âº"})]})]})},eJ=e=>{let{monthKey:t,latestMonthKey:a,onChange:n,updatedAt:l,refreshing:o,onRefresh:i}=e,r=W(a,12);return(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[(0,s.jsx)("label",{className:"sr-only",htmlFor:"business-month",children:"Month"}),(0,s.jsx)("select",{id:"business-month",value:t,onChange:e=>n(e.target.value),className:"rounded-[10px] border border-slate-200 bg-white px-3 py-1.5 font-poppins text-sm font-medium text-slate-700 transition-colors hover:border-blue-600 focus:border-blue-600 focus:outline-none","data-testid":"business-month-picker","data-month":t,children:r.map(e=>(0,s.jsxs)("option",{value:e,"data-testid":"business-month-option","data-month":e,children:[J(e),e===a?" (so far)":""]},e))}),(0,s.jsx)("span",{className:"font-poppins text-xs text-slate-500","data-testid":"business-loaded-at","data-updated-at":null==l?void 0:l.toISOString(),children:o?"Updatingâ¦":l?"Loaded ".concat((0,eP.J)(l.toISOString())):""}),(0,s.jsx)("button",{type:"button",onClick:i,disabled:o,className:"rounded-[10px] border border-slate-200 bg-white px-3 py-1.5 font-poppins text-sm font-medium text-slate-600 transition-colors hover:border-blue-600 hover:text-blue-700 disabled:opacity-50",children:"Refresh"}),t===a?null:(0,s.jsx)("span",{className:"rounded-full border border-slate-200 bg-slate-50 px-2.5 py-0.5 font-poppins text-[11px] font-semibold text-slate-600","data-testid":"business-month-closed",children:"Closed month"})]})},eW=/^\d{4}-(0[1-9]|1[0-2])$/,eZ=()=>{let e=new Date;return"".concat(e.getFullYear(),"-").concat(String(e.getMonth()+1).padStart(2,"0"))},eY={warning:"border-amber-200 bg-amber-50/60 text-amber-800",info:"border-slate-200 bg-slate-50 text-slate-600"},eV=()=>{var e,t,a,o,i,d,u;let h=(0,l.useRouter)(),b=eZ(),[f,g]=(0,n.useState)(!1),[v,y]=(0,n.useState)(null),[j,N]=(0,n.useState)(!1),[w]=(0,n.useState)(()=>m()),[D,P]=(0,n.useState)(()=>C()),R="string"==typeof h.query.month&&eW.test(h.query.month)?h.query.month:void 0,[L,M]=(0,n.useState)(R);(0,n.useEffect)(()=>{M(R)},[R]);let{data:I,isLoading:U,refreshing:O,error:_,refetch:A,updatedAt:F}=r(L),B=(0,n.useCallback)(e=>{let t=new URLSearchParams(window.location.search);e===b?t.delete("month"):t.set("month",e),h.replace({pathname:h.pathname,query:Object.fromEntries(t)},void 0,{shallow:!0})},[b,h]),q=null!==(t=null!==(e=null==I?void 0:I.windows.monthKey)&&void 0!==e?e:L)&&void 0!==t?t:b,W=q!==b,Z=!!I&&!U&&eI(I),{alerts:Y,prunedIds:V}=(0,n.useMemo)(()=>T(I,D),[I,D]);(0,n.useEffect)(()=>{I&&V.length!==D.length&&(P(V),S(V))},[I,V,D]);let K=(0,n.useCallback)(()=>{let e=[...D,...Y.map(E)];P(e),S(e)},[D,Y]),{changes:X,since:Q}=(0,n.useMemo)(()=>I?p(I,w,new Date):{changes:[],since:null},[I,w]);(0,n.useEffect)(()=>{!I||U||W||x(c(I,new Date))},[I,U,W]);let et=(0,n.useMemo)(()=>[],[I]);return(0,s.jsxs)("div",{className:"business-print-root flex min-h-0 flex-1 flex-col gap-4","data-testid":"business-overview",children:[(0,s.jsxs)("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"font-poppins text-2xl font-bold text-primary",children:"Business Overview"}),(0,s.jsxs)("p",{className:"font-poppins text-sm text-slate-500",children:[J(q)," \xb7 all figures in USD"]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(eJ,{monthKey:q,latestMonthKey:b,onChange:B,updatedAt:F,refreshing:O,onRefresh:()=>void A()}),(0,s.jsx)("button",{type:"button",onClick:()=>g(!0),className:"rounded-[10px] border border-slate-200 bg-white px-3 py-1.5 font-poppins text-sm font-medium text-slate-600 transition-colors hover:border-blue-600 hover:text-blue-700 print:hidden",children:"Activity"}),(0,s.jsx)("button",{type:"button",disabled:!I,onClick:()=>I&&k(I),className:"rounded-[10px] border border-slate-200 bg-white px-3 py-1.5 font-poppins text-sm font-medium text-slate-600 transition-colors hover:border-blue-600 hover:text-blue-700 disabled:opacity-50 print:hidden","data-testid":"business-export",children:"Export"})]})]}),_&&!I?(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3 rounded-[12px] border border-red-200 bg-red-50/60 px-4 py-3",children:[(0,s.jsx)("span",{className:"font-poppins text-sm text-red-800",children:"We could not load your business overview."}),(0,s.jsx)("button",{type:"button",onClick:()=>void A(),className:"rounded-full bg-main-blue px-3 py-1 font-poppins text-xs font-bold text-white hover:opacity-90",children:"Try again"})]}):null,_&&I?(0,s.jsx)("div",{className:"rounded-[12px] border border-amber-200 bg-amber-50/60 px-4 py-2 font-poppins text-xs text-amber-800","data-testid":"business-stale-notice",children:"Showing the last figures we loaded â the latest refresh did not go through."}):null,null==I?void 0:I.notices.map(e=>(0,s.jsx)("div",{className:"rounded-[12px] border px-4 py-2 font-poppins text-xs ".concat(eY[e.severity]),"data-testid":"business-notice","data-notice-key":e.key,"data-severity":e.severity,children:e.message},e.key)),et.length>0?(0,s.jsxs)("div",{className:"rounded-[12px] border border-red-300 bg-red-50 px-4 py-2 font-poppins text-xs text-red-800",children:[(0,s.jsx)("span",{className:"font-bold",children:"Reconciliation failed (dev only):"}),(0,s.jsx)("ul",{className:"mt-1 list-inside list-disc",children:et.map(e=>(0,s.jsx)("li",{children:e},e))})]}):null,j?null:(0,s.jsx)(eF,{changes:X,since:Q,onDismiss:()=>N(!0)}),Z?(0,s.jsx)(eO,{}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(el,{data:I,loading:U,quiet:Y}),(0,s.jsx)(eM,{scope:"now",label:"Where your money is",hint:W?"Unaffected by the peri
1od above â this is todayâs position":void 0}),(0,s.jsx)(ec,{data:I,loading:U}),(0,s.jsx)(ex,{items:null!==(a=null==I?void 0:I.attention)&&void 0!==a?a:[],leakage:null!==(o=null==I?void 0:I.disputeLeakage)&&void 0!==o?o:null,loading:U}),(0,s.jsx)(eM,{scope:"month",label:"How ".concat(J(q)," went")}),(0,s.jsxs)("section",{className:"".concat(z," ").concat(H," flex flex-col gap-3"),children:[(0,s.jsxs)("header",{children:[(0,s.jsx)("h2",{className:G,children:"Twelve months"}),(0,s.jsx)("p",{className:$,children:"Invoiced and collected, by month"})]}),U?(0,s.jsx)("div",{className:"".concat(ee," h-56")}):I?(0,s.jsx)(ej,{trend:I.trend,committedTotal:I.committed.amount}):null]}),(0,s.jsx)(eD,{data:I,loading:U,onSelect:y,quiet:Y,onDismissQuiet:K}),(0,s.jsx)(eC,{data:I,loading:U}),(0,s.jsx)(eT,{lanes:null!==(i=null==I?void 0:I.lanes)&&void 0!==i?i:[],winRate:null!==(d=null==I?void 0:I.winRate)&&void 0!==d?d:null,loading:U})]}),(0,s.jsx)("footer",{className:"font-poppins text-[11px] leading-relaxed text-slate-400",children:"âInvoicedâ, âowedâ and âcollectedâ count invoices you issued. âCommittedâ adds work delivered or booked but not yet invoiced â it is a floor, not a forecast, since loads you take on later this month are not in it. The Dashboard's revenue figure is different again: it counts loads delivered over the last 30 days. Months follow your own calendar and timezone."}),(0,s.jsx)(eL,{activity:null!==(u=null==I?void 0:I.activity)&&void 0!==u?u:[],loading:U,open:f,onClose:()=>g(!1)}),(0,s.jsx)(eq,{customer:v,data:I,onClose:()=>y(null)})]})};var eK=(0,o.Z)(eV,{greeting:!1});let ez=()=>(0,s.jsx)(eK,{});var eH=ez},44629:function(e,t,a){"use strict";a.d(t,{J:function(){return s}});let s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Date,a=new Date(e).getTime();if(Number.isNaN(a))return"â";let s=t.getTime()-a;if(s<6e4)return"Just now";if(s<36e5)return"".concat(Math.floor(s/6e4)," min ago");if(s<864e5){let e=Math.floor(s/36e5);return"".concat(e," hr").concat(1===e?"":"s"," ago")}let n=Math.floor(s/864e5);return 1===n?"Yesterday":"".concat(n," days ago")}}},function(e){e.O(0,[5353,9774,2888,179],function(){return e(e.s=84638)}),_N_E=e.O()}]);
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.