1import{j as e,a as h,cO as q,cP as G,cQ as J,ag as f,aj as b,ak as y,al as g,ax as D,ay as P,B as x,az as k,aA as T,aB as L,aC as A,aD as F,aE as M,aF as E,cR as K,o as ee,aY as se,i as te,cS as V,cT as ae,r as ne,cU as re,k as ie,b1 as ce,cg as le,cV as oe,am as de,ch as xe,c9 as ue,cW as pe,L as me,ap as he,a7 as je,cX as fe,ah as m}from"./index-CGR8USYX.js";import{S as l}from"./skeleton-Da42guHO.js";import{P as be}from"./payment-history-table-BSW-VWU9.js";import{C as ye}from"./credit-card-CNHblL-P.js";import{B as ge}from"./badge-rLYC_Uh8.js";import"./table-BCejWtm9.js";import"./download-8MDSW6IM.js";function Ne({brand:t,className:s="h-8 w-12"}){const r=t.toLowerCase();return r==="visa"?e.jsx("div",{className:`flex shrink-0 items-center justify-center rounded-md bg-[#1a1f71] ${s}`,children:e.jsx("span",{className:"text-[13px] font-black tracking-tight text-white italic",children:"VISA"})}):r==="mastercard"?e.jsx("div",{className:`flex shrink-0 items-center justify-center rounded-md bg-[#f4f4f5] ${s}`,children:e.jsxs("svg",{viewBox:"0 0 36 22",className:"h-[18px] w-[28px]",children:[e.jsx("circle",{cx:"14",cy:"11",r:"10",fill:"#eb001b"}),e.jsx("circle",{cx:"22",cy:"11",r:"10",fill:"#f79e1b"}),e.jsx("path",{d:"M18 3.5a10 10 0 0 1 0 15 10 10 0 0 1 0-15Z",fill:"#ff5f00"})]})}):r==="amex"||r==="american_express"?e.jsx("div",{className:`flex shrink-0 items-center justify-center rounded-md bg-[#2e77bc] ${s}`,children:e.jsx("span",{className:"text-[11px] font-black tracking-tight text-white",children:"AMEX"})}):r==="discover"?e.jsx("div",{className:`flex shrink-0 items-center justify-center rounded-md bg-[#f4f4f5] ${s}`,children:e.jsx("span",{className:"text-[10px] font-black tracking-tight text-[#ff6000]",children:"DISCOVER"})}):e.jsx("div",{className:`flex shrink-0 items-center justify-center rounded-md bg-secondary ${s}`,children:e.jsx(ye,{className:"size-4 text-text-secondary"})})}function Se({memberId:t}){const{t:s}=h(),{data:r,isLoading:c}=q(t),o=G(t),a=J(t);return e.jsxs(f,{children:[e.jsx(b,{children:e.jsx(y,{children:s("portalPayments.savedPaymentMethodsTitle")})}),e.jsxs(g,{className:"space-y-4",children:[c&&e.jsx("div",{className:"space-y-2",children:Array.from({length:2}).map((i,N)=>e.jsxs("div",{"aria-hidden":"true",className:"flex items-center gap-3 rounded-lg border border-border p-3",children:[e.jsx(l,{className:"h-8 w-12 rounded-md"}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(l,{className:"h-4 w-40"}),e.jsx(l,{className:"h-3 w-24"})]})]},N))}),!c&&(r==null?void 0:r.length)===0&&e.jsx("p",{className:"text-sm text-text-secondary",children:s("portalPayments.noPaymentMethodsOnFile")}),e.jsx("div",{className:"space-y-2",children:r==null?void 0:r.map(i=>e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-border p-3 transition-colors hover:bg-secondary/40",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ne,{brand:i.brand}),e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[e.jsx("span",{className:"capitalize",children:i.brand}),e.jsxs("span",{className:"tracking-widest text-text-secondary",children:["â¢â¢â¢â¢ ",i.last4]}),i.isDefault&&e.jsx("span",{className:"rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-semibold text-accent",children:s("portalPayments.default")})]}),i.exp!=="N/A"&&e.jsx("p",{className:"text-xs text-text-secondary",children:s("portalPayments.expLabel",{exp:i.exp})})]})]}),e.jsx("div",{className:"flex gap-2",children:!i.isDefault&&e.jsxs(e.Fragment,{children:[e.jsxs(D,{children:[e.jsx(P,{asChild:!0,children:e.jsx(x,{size:"sm",variant:"outline",children:s("portalPayments.makeDefault")})}),e.jsxs(k,{children:[e.jsxs(T,{children:[e.jsx(L,{children:s("portalPayments.makeDefaultConfirmTitle",{card:`${i.brand} â¢â¢â¢â¢ ${i.last4}`})}),e.jsx(A,{children:s("portalPayments.makeDefaultConfirmDescription")})]}),e.jsxs(F,{children:[e.jsx(M,{children:s("common.cancel")}),e.jsx(E,{onClick:()=>a.mutate(i.id),children:s("portalPayments.makeDefault")})]})]})]}),e.jsxs(D,{children:[e.jsx(P,{asChild:!0,children:e.jsx(x,{size:"sm",variant:"ghost",children:s("portalPayments.remove")})}),e.jsxs(k,{children:[e.jsxs(T,{children:[e.jsx(L,{children:s("portalPayments.removeConfirmTitle",{card:`${i.brand} â¢â¢â¢â¢ ${i.last4}`})}),e.jsx(A,{children:s("portalPayments.removeConfirmDescription")})]}),e.jsxs(F,{children:[e.jsx(M,{children:s("common.cancel")}),e.jsx(E,{onClick:()=>o.mutate(i.id),children:s("portalPayments.remove")})]})]})]})]})})]},i.id))}),e.jsx("div",{className:"border-t border-border pt-4",children:e.jsx(K,{memberId:t})})]})]})}function Me(){const{t}=h(),s=ee();return s?s.level==="driver"?e.jsx("p",{className:"text-text-secondary",children:t("portalSubscription.notAp
1plicableToDriver")}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:t("portalSubscription.title")}),e.jsx("p",{className:"text-text-secondary",children:t("portalSubscription.subtitle")})]}),e.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.3fr)]",children:[e.jsx(ve,{member:s}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(Ce,{member:s}),e.jsx(Se,{memberId:s.id})]})]}),e.jsx(we,{memberId:s.id})]}):e.jsx("p",{className:"text-text-secondary",children:t("portalSubscription.switchPersona")})}function we({memberId:t}){const{t:s}=h(),{data:r,isLoading:c}=fe(t);return e.jsxs(f,{children:[e.jsx(b,{children:e.jsx(y,{children:s("portalSubscription.transactionHistoryTitle")})}),e.jsx(g,{children:e.jsx(be,{payments:r,isLoading:c})})]})}function ve({member:t}){const{t:s,locale:r}=h(),{data:c,isLoading:o}=se(),a=c==null?void 0:c.find(n=>n.id===t.levelId),{data:i}=te(t.id),{data:N}=V(t.cancelledAt?void 0:t.id),B=ae(t.id),[I,R]=ne.useState(""),S=re(t.id),w=ie(t.id),u=t.level==="fleet",j=(a==null?void 0:a.fleetFirstTruckPrice)??ce,$=(a==null?void 0:a.fleetAdditionalTruckPrice)??void 0,Y=u?le(t.truckCount??0,j,$):(a==null?void 0:a.price)??0,d=o,p=Y,_=u?s("portalSubscription.monthlyPrice",{amount:p}):(a==null?void 0:a.cycle)==="monthly"?s("portalSubscription.monthlyPrice",{amount:p}):(a==null?void 0:a.cycle)==="annual"?s("portalSubscription.annualPrice",{amount:p}):null,z=u?oe(t.truckCount??0,j,$):0,Q=u?[{label:s("portalSubscription.firstTruckLineItem"),amount:j},...z>0?[{label:s("portalSubscription.additionalTrucksLineItem",{count:z}),amount:p-j}]:[]]:null,U=!!N&&(t.status==="active"||t.status==="renewal_due"||t.status==="past_due"),v=(a==null?void 0:a.cycle)==="monthly"||(a==null?void 0:a.cycle)==="annual",C=v&&!!t.renewalDate&&(()=>{const n=new Date;return a.cycle==="monthly"?n.setMonth(n.getMonth()+1):n.setFullYear(n.getFullYear()+1),new Date(t.renewalDate).getTime()>n.getTime()})(),H=!!t.cancelledAt,O=((a==null?void 0:a.benefits)??"").split(/[.,]\s*/).map(n=>n.trim()).filter(Boolean),X=()=>{B.mutate(I.trim(),{onSuccess:()=>{R(""),m.success(s("portalSubscription.subscriptionCancelledToast"))},onError:n=>m.error(n instanceof Error?n.message:s("portalSubscription.couldNotCancelToast"))})},W=()=>{S.mutate(void 0,{onSuccess:()=>m.success(s("portalSubscription.subscriptionResumedToast")),onError:n=>m.error(n instanceof Error?n.message:s("portalSubscription.couldNotResumeToast"))})},Z=()=>{w.mutate(void 0,{onSuccess:({url:n})=>{window.location.href=n},onError:n=>m.error(n instanceof Error?n.message:s("portalSubscription.couldNotStartCheckoutToast"))})};return e.jsxs(f,{children:[e.jsxs(b,{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(y,{className:"text-lg capitalize",children:t.level.replace(/_/g," ")}),e.jsx(de,{status:xe(t)})]}),u?e.jsx("p",{className:"text-sm text-text-secondary",children:ue(a,s)}):(a==null?void 0:a.durationLabel)&&e.jsx("p",{className:"text-sm text-text-secondary",children:a.durationLabel})]}),e.jsxs(g,{className:"space-y-4",children:[d&&e.jsxs("div",{className:"space-y-4","aria-hidden":"true",children:[e.jsx(l,{className:"h-9 w-32"}),e.jsx(l,{className:"h-9 w-full"}),e.jsxs("div",{className:"space-y-2 border-t border-border pt-3.5",children:[e.jsx(l,{className:"h-4 w-full"}),e.jsx(l,{className:"h-4 w-5/6"}),e.jsx(l,{className:"h-4 w-4/6"})]})]}),!d&&_&&e.jsx("p",{className:"text-3xl font-bold text-foreground",children:_}),!d&&Q&&e.jsx(pe,{items:Q,total:p,totalLabel:s("portalSubscription.monthlyTotalLabel")}),!d&&!H&&t.renewalDate&&e.jsx(ge,{variant:"secondary",className:"font-semibold",children:s(U?"portalSubscription.renewsOnLabel":"portalSubscription.validTillLabel",{date:new Date(t.renewalDate).toLocaleDateString(r)})}),!d&&H?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:s("portalSubscription.cancelledUntilLabel",{date:t.cancelAt?new Date(t.cancelAt).toLocaleDateString(r):"â"})}),t.pendingLevelId?e.jsx("p",{className:"text-sm text-text-secondary",children:s("portalSubscription.staffPlanChangePending")}):e.jsx(x,{className:"w-full",variant:"outline",onClick:W,disabled:S.isPending,children:S.isPending?s("portalSubscription.resuming"):s("portalSubscription.resumeSubscription")})]}):v&&U?e.jsxs(D,{children:[e.jsx(P,{asChild:!0,children:e.jsx(x,{className:"w-full",variant:"outline",children:s("portalSubscription.cancelSubscription")})}),e.jsxs(k,{children:[e.jsxs(T,{children:[e.jsx(L,{children:s("portalSubscription.cancelConfirmTitle")}),e.jsx(A,{children:s("portalSubscription.cancelConfirmDescription",{date:t.renew
1alDate?new Date(t.renewalDate).toLocaleDateString(r):"â"})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(me,{htmlFor:"cancel-reason",children:[s("portalSubscription.cancelReasonLabel")," ",e.jsx("span",{className:"font-normal text-text-secondary",children:s("portalSubscription.optionalLabel")})]}),e.jsx(he,{id:"cancel-reason",value:I,onChange:n=>R(n.target.value),placeholder:s("portalSubscription.cancelReasonPlaceholder"),rows:3})]}),e.jsxs(F,{children:[e.jsx(M,{children:s("common.cancel")}),e.jsx(E,{onClick:X,disabled:B.isPending,children:s("portalSubscription.cancelSubscription")})]})]})]}):v?e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(x,{className:"w-full",onClick:Z,disabled:w.isPending||C,title:C?s("portalSubscription.renewalTooFarTooltip"):void 0,children:w.isPending?s("portalSubscription.redirecting"):s("portalSubscription.subscribeNow")}),C&&t.renewalDate&&e.jsx("p",{className:"text-xs text-text-secondary",children:s("portalSubscription.renewalTooFarNotice",{date:new Date(t.renewalDate).toLocaleDateString(r)})})]}):null,!d&&i&&e.jsx(x,{className:"w-full",asChild:!0,children:e.jsx("a",{href:i.hostedInvoiceUrl,target:"_blank",rel:"noreferrer",children:s("portalSubscription.payNow",{amount:i.amountDue})})}),!d&&O.length>0&&e.jsx("ul",{className:"space-y-2 border-t border-border pt-3.5",children:O.map(n=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-foreground",children:[e.jsx(je,{className:"mt-0.5 size-4 shrink-0 text-accent"}),n]},n))})]})]})}function Ce({member:t}){const{t:s,locale:r}=h(),{data:c,isLoading:o}=V(t.cancelledAt?void 0:t.id);return t.cancelledAt?null:e.jsxs(f,{children:[e.jsx(b,{children:e.jsx(y,{children:s("portalSubscription.nextPaymentTitle")})}),e.jsxs(g,{className:"space-y-3",children:[o&&e.jsxs("div",{className:"space-y-3","aria-hidden":"true",children:[e.jsx(l,{className:"h-4 w-40"}),e.jsxs("div",{className:"space-y-2 border-t border-border pt-3.5",children:[e.jsx(l,{className:"h-4 w-full"}),e.jsx(l,{className:"h-4 w-full"}),e.jsx(l,{className:"h-5 w-full"})]})]}),!o&&!c&&e.jsx("p",{className:"text-base text-text-secondary",children:s("portalSubscription.noUpcomingPayment")}),!o&&c&&e.jsxs(e.Fragment,{children:[c.nextPaymentDate&&e.jsx("p",{className:"text-base text-text-secondary",children:s("portalSubscription.nextPaymentDate",{date:new Date(c.nextPaymentDate).toLocaleDateString(r)})}),e.jsxs("div",{className:"space-y-2.5 border-t border-border pt-3.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-base",children:[e.jsx("span",{className:"text-text-secondary",children:s("portalSubscription.subtotalLabel")}),e.jsxs("span",{className:"font-medium text-foreground",children:["$",c.subtotal.toFixed(2)]})]}),c.discount>0&&e.jsxs("div",{className:"flex items-center justify-between text-base",children:[e.jsx("span",{className:"text-text-secondary",children:s("portalSubscription.discountLabel")}),e.jsxs("span",{className:"font-medium text-success",children:["-$",c.discount.toFixed(2)]})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-border pt-2.5 text-lg",children:[e.jsx("span",{className:"font-semibold text-foreground",children:s("portalSubscription.totalLabel")}),e.jsxs("span",{className:"font-bold text-foreground",children:["$",c.total.toFixed(2)]})]})]})]})]})]})}export{Me as component};
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.