1import{r as x,u as q,j as t,q as z,F as Y,b2 as Z,B as ee,S as T,a7 as te,n as E}from"./elements-5kxJS_4j.js";import{x as V,A as ne,p as B,k as ae,$ as se,a3 as s,j as U,o as oe,R as re,O as ie,a4 as m}from"./index-CtCeyryw.js";import{t as g}from"./trackEvent-CeNPAPKA.js";import{E as le}from"./useEpayLaunchDarkly-DZE0z9-1.js";import"./grids-DGmfp9GI.js";import"./startOfDay-AazlW55I.js";function ce(n){return n.verdict==="oneClickEligible"&&n.bankPreview!=null&&n.variant!=null}function ue(n){return n.verdict==="checkPayerFallback"&&n.exclusionReason!=="featureFlagDisabled"}function de(){const n=x.useRef(!1);x.useEffect(()=>{var o;n.current||(n.current=!0,(o=window.pendo)==null||o.initialize({visitor:{user:"prelogin"}}))},[])}function pe(){return de(),null}const u="billing.expiredLink";function me(){const{t:n}=q(),o=V(),[f]=ne(),y=f.get("c")??f.get("C")??void 0,{data:i,isLoading:k}=B({queryKey:["epayExpiredHomeSettings",y??null],queryFn:()=>ae.getUserSettings({lastAssociationCode:y}),staleTime:1/0,retry:!1}),d=(i==null?void 0:i.logoUrl)??null,C=(i==null?void 0:i.companyName)??"",[p,h]=x.useState("loading"),j=k||!!d&&p==="loading",b=()=>{g("button:clicked",{buttonText:n(`${u}.button`),destinationUrl:"/public",page:"expresspay-expired"}),o("/public")};return t.jsxs("div",{className:"min-h-screen w-full flex flex-col bg-white",children:[t.jsxs("header",{className:"relative w-full h-[52px] bg-white border-b border-base-border flex items-center justify-center",children:[j&&t.jsx("div",{role:"status","aria-busy":"true","aria-label":n(`${u}.logoLoading`),className:"absolute h-11 w-[126px] rounded-md bg-base-fg/10 animate-pulse"}),d&&p!=="error"&&t.jsx("img",{src:d,alt:C,onLoad:()=>h("loaded"),onError:()=>h("error"),className:z("h-11 w-auto object-contain transition-opacity duration-200",p==="loaded"?"opacity-100":"opacity-0")})]}),t.jsx("main",{className:"flex-1 flex flex-col items-center px-6 pt-16",children:t.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-[345px] text-center",children:[t.jsxs("div",{className:"flex flex-col items-center gap-2 w-full",children:[t.jsx("div",{className:"flex items-center justify-center size-16 rounded-full bg-white drop-shadow-[0px_1px_1px_rgba(0,0,0,0.08)]",children:t.jsx(Y,{icon:Z,className:"text-[32px] text-error"})}),t.jsx("h1",{className:"text-base font-medium text-base-header",children:n(`${u}.title`)}),t.jsx("p",{className:"text-sm text-base-fg/70 tracking-[0.3px]",children:n(`${u}.body`)})]}),t.jsx("p",{className:"text-sm text-base-fg/70 tracking-[0.3px]",children:n(`${u}.instruction`)}),t.jsx(ee,{variant:"additive",onClick:b,className:"w-full text-center",id:"expired-link-login","data-qa":"expired-link-login",children:n(`${u}.button`)})]})})]})}function ge(n,o){return n&&o?`${n}_${o}`:void 0}function Ie(){var A,D;const{t:n}=q(),{link:o}=se(),f=s(e=>e.paymentSetup),y=s(e=>e.enrollmentContext),i=s(e=>e.account),k=s(e=>e.savePaymentMethod),d=s(e=>e.setEpayToken),C=s(e=>e.setEpayUserValues),p=s(e=>e.setIntentValues),h=s(e=>e.setClientSecret),j=s(e=>e.setAccountInfo),b=s(e=>e.setEnrollmentContext),S=s(e=>e.setFallbackContext),N=s(e=>e.setAutoDraftNextDraftDate),L=U(e=>e.theme),w=V(),v=oe(),_=U(e=>e.isLoggedIn);x.useEffect(()=>{if(_){const e=`${v.pathname.replace(/^\//,"")}${v.search}`;w(`/logout?redirect=${encodeURIComponent(e)}`)}},[]);const M=async()=>{var e,a;if(o)try{const{token:r}=await m.authenticate({strategy:1,webToken:o});d(r),C()}catch(r){const l=r,c=(a=(e=l==null?void 0:l.response)==null?void 0:e.data)==null?void 0:a.errorCode;throw g("payment:expresspay:auth:failed",{reason:c==="PA051"?"expired-link":"auth-error",errorCode:c??null}),c==="PA051"||(E({type:"error",message:n("billing.expressLayout.errorAuthenticating")}),w("/login")),r}},H=async()=>{try{const e=await m.createIntent({savePaymentMethod:k});p(e),h(e.paymentSetup.clientSecret)}catch(e){const a=s.getState();throw g("payment:expresspay:flow:dropped",{reason:"intent-failed",userId:a.userId,ownerId:a.ownerId,managementCompanyId:a.managementCompanyId}),E({type:"error",message:n("billing.expressLayout.errorCreatingPayment")}),w("/login"),e}},K=async()=>{try{const e=await m.getAccount();j(e)}
1catch(e){const a=s.getState();throw g("payment:expresspay:flow:dropped",{reason:"account-failed",userId:a.userId,ownerId:a.ownerId,managementCompanyId:a.managementCompanyId}),E({type:"error",message:n("billing.expressLayout.errorLoadingAccount")}),w("/login"),e}},Q=v.pathname.includes("/one-click/"),W=async()=>{if(!s.getState().enrollmentResult){try{const e=await m.getEnrollmentEligibility();if(ce(e)){b({bankPreview:e.bankPreview,variant:e.variant}),await P();return}if(Q&&ue(e)){S({exclusionReason:e.exclusionReason??null}),await P();return}}catch(e){console.error("[1-Click] Eligibility check failed; falling back to standard flow:",e)}b(null),S(null)}},P=async()=>{var e;try{const a=await m.getRecurringPaymentSettings();N(((e=a.autoDraftSettings)==null?void 0:e.nextDraftDate)??null)}catch(a){console.warn('[1-Click] getRecurringPaymentSettings failed; "Starting on" will fall back to nextChargeDate:',a),N(null)}},{error:I,isPending:X}=B({queryKey:["getEpayToken"],staleTime:1/0,gcTime:1/0,refetchOnWindowFocus:!1,refetchOnReconnect:!1,refetchOnMount:!1,retry:!1,queryFn:async()=>{var R,$,F,O;const e=s.getState();if(e.epayToken&&(e.formState==="complete"||e.enrollmentResult||((R=e.paymentSetup)==null?void 0:R.status)==="succeeded"))return!0;await M();const a=s.getState(),{managementCompanyId:r}=a,l=ge(r,a.userId);l&&r&&(($=window.pendo)==null||$.identify({visitor:{id:l,mcId:r,userId:a.userId,ownerId:a.ownerId,subLedgerId:a.subLedgerId},account:{id:r}})),g("payment:expresspay:link-accessed",{userId:a.userId,ownerId:a.ownerId,managementCompanyId:a.managementCompanyId,subLedgerId:a.subLedgerId}),await H(),await K();const c=s.getState();l&&((F=window.pendo)==null||F.updateOptions({visitor:{hasRecurringPayments:c.hasRecurringPayments,hasAutoDraftPayments:c.hasAutoDraftPayments,balance:c.balance}})),await W();const J=!!s.getState().enrollmentContext;return(O=window.pendo)==null||O.updateOptions({visitor:{isOneClickEligible:J}}),!0}}),G=((D=(A=I==null?void 0:I.response)==null?void 0:A.data)==null?void 0:D.errorCode)==="PA051";return I?G?t.jsx(me,{}):t.jsx("div",{children:t.jsx(re,{to:"/login"})}):t.jsxs("div",{className:z("default bg-base-bg min-h-screen flex items-center justify-center",L==="Default"||L==="LightNeutral"&&"bg-white"),children:[!X&&(f||y&&i)?t.jsx(x.Suspense,{fallback:t.jsx("div",{className:"w-full h-full py-16 flex items-center justify-center",children:t.jsx(T,{})}),children:t.jsx(ie,{})}):t.jsxs("div",{className:"flex flex-col items-center justify-center gap-4 py-16 px-6 text-center",children:[t.jsx(T,{}),t.jsx("p",{className:"text-lg font-bold text-base-fg",children:n("billing.expressLayout.loadingHeadline")}),t.jsx("p",{className:"max-w-sm text-sm text-base-fg/70",children:n("billing.expressLayout.loadingBody")})]}),t.jsx(te,{position:"bottom-right"}),t.jsx(pe,{}),t.jsx(le,{})]})}export{Ie 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.