1import{Y as I,_ as E,gQ as ee,aG as w,bx as U,$ as R,a6 as te,u as B,cw as H,j as e,a9 as se,aL as _,gR as Z,aa as ae,ab as ie,b4 as be,ad as ne,c9 as V,r as h,y as pe,cd as le,gS as ge,bi as re,aC as ue,gT as he,gU as fe,gV as ye,T as A,a1 as oe,a2 as de,a3 as F,a5 as W,ax as $,e_ as ve,am as je,E as D,S as z,U as Ne,ap as we,fP as Ee,gW as Me,d as Pe}from"./index-DMQ34O7E.js";import{A as ke}from"./AgencyTierProgressModal-Dyse1GpL.js";import{E as Be}from"./external-link-DGOH_I46.js";import{P as _e}from"./PaymentFailedAlert-4lbxHc9l.js";import{N as Ce,A as Se}from"./AgencyUnconfirmedPaymentBanner-DjZ-7gTo.js";import"./separator-COA4eDqS.js";/** 2 * @license lucide-react v0.503.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const De=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],Ie=I("calendar",De);/** 7 * @license lucide-react v0.503.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Te=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],Oe=I("file-text",Te);/** 12 * @license lucide-react v0.503.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const Le=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],Ae=I("globe",Le);/** 17 * @license lucide-react v0.503.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Fe=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],We=I("mail",Fe);/** 22 * @license lucide-react v0.503.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const $e=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],He=I("map-pin",$e);/** 27 * @license lucide-react v0.503.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const Ue=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],qe=I("user",Ue),C={fetchInvoices:async t=>{try{const{data:s}=await E.get("/api/v2/invoices",{params:t}),n=s.data;return n.invoices&&(n.invoices=n.invoices.map(o=>({...o,src:ee(o.card_brand)}))),n}catch(s){throw console.error("Error fetching invoices:",s),s}},fetchBillingDetails:async()=>{var t,s,n,o;try{const{data:a}=await E.get("/api/v2/billing/details");return{customerEmail:((t=a.customer)==null?void 0:t.customer_email)||"",customerBillingName:((s=a.customer)==null?void 0:s.customer_name)||"",customerBillingAddress:((n=a.customer)==null?void 0:n.customer_addres)||{line1:"",city:"",state:"",postal_code:""},customerBillingCountry:a.country||"",customerBillingTaxId:(o=a.tax_id)==null?void 0:o.value,customerPaymentMethod:a.paymentMethod,isAfterOverageRollout:a.is_after_overage_rollout??!1,overageEnabled:a.overage_enabled??!1,hasOverage:a.has_overage??!1,shouldDisplayOverageSection:a.should_display_overage_section??!1,canEnableOverageSection:a.should_enable_overage_section??!1,isFreeOnlyUser:a.free_only??!1,isTrialOnlyUser:a.trial_only??!1}}catch(a){throw console.error("Error fetching billing details:",a),a}},fetchBillingEmail:async()=>{try{const{data:t}=await E.get("/api/v2/billing/email");return{email:(t==null?void 0:t.billing_email)||""}}catch(t){return console.error("Error fetching billing email:",t),{email:""}}},fetchAgencyBillingDetails:async()=>{try{const{data:t}=await E.get("/api/v2/agency/billing/details");return t.data}catch(t){throw console.error("Error fetching agency billing details:",t),t}},getStripeCustomerPortal:async()=>{try{const{data:t}=await E.post("/api/v2/billing/portal");return t}catch(t){throw console.error("Error getting Stripe customer portal:",t),t}},updateBillingEmail:async t=>{try{const{data:s}=await E.put("/api/v2/billing/email",t);return s}catch(s){throw console.error("Error updating billing email:",s),s}},retryPayment:async t=>{try{const{data:s}=await E.get("/api/v2/invoices/payment-page",{params:t});return s}catch(s){throw console.error("Error retrying payment:",s),s}},updateOverageStatus:async t=>{try{const{data:s}=await E.post("/api/v2/pageview-overage/update",t);return s}catch(s){throw console.error("Error updating overage status:",s),s}}},T={all:["billing"],invoices:(t,s)=>["billing","invoices",t,s],billingDetails:t=>["billing","details",t],billingEmail:t=>["billing","email",t],agencyBilling:t=>["billing","agency",t]};function Ke(t){const{__enabled:s,...n}=t,o=w(a=>a.accountID());return U({queryKey:T.invoices(o,n),queryFn:()=>C.fetchInvoices(n),staleTime:5*60*1e3,enabled:s??!0})}function Q(){const t=w(s=>s.accountID());return U({queryKey:T.billingDetails(t),queryFn:()=>C.fetchBillingDetails(),staleTime:10*60*1e3})}function ce(){const t=w(s=>s.accountID());return U({queryKey:T.billingEmail(t),queryFn:()=>C.fetchBillingEmail(),staleTime:10*60*1e3})}function Y(){const t=w(s=>s.accountID());return U({queryKey:T.agencyBilling(t),queryFn:()=>C.fetchAgencyBillingDetails(),staleTime:5*60*1e3})}function ze(){return R({mutationFn:()=>C.getStripeCustomerPortal(),onSuccess:t=>{window.open(t,"_blank","noopener,noreferrer")}})}
31function Re(){const t=te(),s=w(n=>n.accountID());return R({mutationFn:n=>C.updateBillingEmail(n),onSuccess:()=>{t.invalidateQueries({queryKey:T.billingEmail(s)})}})}function Ve(){const t=te(),s=w(n=>n.accountID());return R({mutationFn:n=>C.updateOverageStatus(n),onSuccess:()=>{t.invalidateQueries({queryKey:T.billingDetails(s)})}})}function Qe(){const{t}=B(),{data:s,isLoading:n}=Y(),o=H(r=>r.licenseStatus()),a=r=>{if(!r)return"";try{return V(new Date(r),"MMMM dd, yyyy")}catch{return r}},d=r=>r==="USD"?"$":"",c=()=>{const r=o==="no_license"?"emptyState.agencyNoSubscription":"emptyState.agencyBillingDetails";return e.jsx("div",{className:"flex justify-center items-center",children:e.jsxs("div",{className:"max-w-[400px] mx-auto text-center",children:[e.jsx("p",{className:"text-[#4e4b66] font-semibold mb-2",children:t(`${r}.infoMessage`)}),e.jsx("p",{className:"text-secondary",children:t(`${r}.actionMessage`)})]})})},g=()=>{if(!s)return null;const{agency_license:r,agency_upgrades:m,agency_add_ons:x,currency:b}=s,u=d(b);return e.jsx("div",{className:"overflow-x-auto mb-0","data-testid":"billing-plans-table",children:e.jsxs("table",{className:"w-full border-collapse mb-0",children:[e.jsx("thead",{className:"border-t border-[#e5e7eb] bg-transparent","data-testid":"billing-plans-table-header",children:e.jsxs("tr",{children:[e.jsx("th",{className:"pr-3 border-bottom-0 pl-6 pr-4 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.agencyBilling.tableHeaders.plan")}),e.jsx("th",{className:"px-3 border-bottom-0 px-4 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.agencyBilling.tableHeaders.sites")}),e.jsx("th",{className:"px-3 border-bottom-0 px-4 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.agencyBilling.tableHeaders.price")}),e.jsx("th",{className:"pl-3 border-bottom-0 px-4 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.agencyBilling.tableHeaders.renewal")})]})}),e.jsxs("tbody",{"data-testid":"billing-plans-table-body",children:[e.jsxs("tr",{className:"border-[#f3f4f6] hover:bg-[#f9fafb] transition-colors duration-150","data-testid":"billing-plan-row","data-plan-key":"agency-license-basic",children:[e.jsx("td",{className:"pl-6 pr-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-name",children:r.plan}),e.jsx("td",{className:"px-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-sites",children:t("invoices.agencyBilling.tableBody.totalSites",{count:r.sites})}),e.jsx("td",{className:"px-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-price",children:t("invoices.agencyBilling.tableBody.licenseCost",{cost:`${u}${r.price}`})}),e.jsx("td",{className:"pl-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-next-renewal",children:a(r.next_renewal_date)})]}),m.map((l,v)=>e.jsxs("tr",{className:"border-[#f3f4f6] hover:bg-[#f9fafb] transition-colors duration-150","data-testid":"billing-plan-row","data-plan-key":"agency-license-basic",children:[e.jsx("td",{className:"pl-6 pr-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-name",children:t(`common.plans.${Z(l.plan.toLowerCase())}.common`)}),e.jsx("td",{className:"px-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-sites",children:t("invoices.agencyBilling.tableBody.noOfSites",{count:l.sites,totalLicense:r.sites})}),e.jsx("td",{className:"px-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-price",children:t("invoices.agencyBilling.tableBody.singleSitePrice",{price:l.price})}),e.jsx("td",{className:"pl-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-next-renewal",children:a(l.next_renewal_date)})]},`upgrade-${l.plan}-${l.sites}-${v}`)),x.map((l,v)=>e.jsxs("tr",{className:"border-[#f3f4f6] hover:bg-[#f9fafb] transition-colors duration-150","data-testid":"billing-plan-row","data-plan-key":"agency-license-basic",children:[e.jsx("td",{className:"pl-6 pr-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-name",children:t(`agency.plans.${Z(l.plan.toLowerCase())}.common`)}),e.jsx("td",{className:"px-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-sites",children:t("invoices.agencyBilling.tableBody.noOfSites",{count:l.sites,totalLicense:r.sites})}),e.jsx("td",{className:"px-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-price",children:t("invoices.agencyBilling.tableBody.singleSitePrice",{price:l.price})}),e.jsx("td",{className:"pl-3 px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"billing-plan-cell-next-renewal",children:a(l.next_renewal_date)})]},`addon-${l.plan}-${l.sites}-${v}`)),e.jsx("tr",{className:"border-t border-secondary-lighter border-[#f3f4f6] border-b-0 transition-colors duration-150",children:e.jsx("td",{colSpan:4,className:"pl-6 pr-4 py-4 text-sm text-[#6e7191] align-middle",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{"data-testid":"billing-next-payment",children:[e.jsx("p",{className:"text-md mb-2 text-secondary","data-testid":"billing-next-payment-label",children:t("invoices.agencyBilling.nextPayment")}),e.jsxs("p",{className:"mb-0 text-sm font-semibold text-[#4e4b66]","data-testid":"billing-next-payment-value",children:[a(s.next_payment_date),e.jsxs(ae,{children:[e.jsx(ie,{asChild:!0,children:e.jsx("span",{className:"ml-2 inline-flex align-middle","data-testid":"billing-next-payment-info-button",children:e.jsx(be,{width:15,height:15,svgColor:"primary"})})}),e.jsx(ne,{showArrow:!0,"data-testid":"billing-next-payment-info-tooltip",children:e.jsx("p",{className:"max-w-xs",children:t("invoices.agencyBilling.tooltip")})})]})]})]}),e.jsxs("div",{"data-testid":"billing-total-due",children:[e.jsx("p",{className:"text-md mb-2 text-secondary","data-testid":"billing-total-due-label",children:t("invoices.agencyBilling.totalDue")}),e.jsxs("p",{className:"mb-0 text-sm font-semibold text-[#4e4b66]","data-testid":"billing-total-due-value",children:[u,s.total_due]})]})]})})})]})]})})};return e.jsx(se,{children:e.jsxs("div",{className:"bg-white rounded-xl overflow-hidden mb-3 bg-white","data-testid":"billing-summary-card",children:[e.jsx("div",{className:"py-4 px-6 border-[#e5e7eb] border-bottom-0 flex justify-between items-center flex-wrap items-center",children:e.jsx("p",{className:"mt-2.5 mb-2.5 text-base font-semibold text-[#4e4b66] text-base font-semibold text-[#4e4b66] m-0 mb
31-0","data-testid":"billing-summary-title",children:t("invoices.agencyBilling.title")})}),e.jsxs("div",{className:"p-6-table",children:[n&&e.jsx(_,{}),!n&&o!=="active"&&e.jsx("div",{className:"mb-2",children:c()}),!n&&o==="active"&&g()]})]})})}function Ye(t){const s=[];return t.basic>0&&s.push(`${t.basic} Basic`),t.pro>0&&s.push(`${t.pro} Pro`),t.ultimate>0&&s.push(`${t.ultimate} Ultimate`),s.join(" + ")}function Je(){var u;const{t}=B(),{data:s,isLoading:n}=Y(),[o,a]=h.useState(!1);if(n)return e.jsx(_,{isCardLoader:!0});if(!((u=s==null?void 0:s.upcoming_invoices)!=null&&u.length))return null;const{upcoming_invoices:d,next_payment_date:c,total_due:g,currency:r}=s,x=(l=>l==="USD"?"$":"")(r),b=l=>{if(!l)return"";try{return V(new Date(l),"MMM dd, yyyy")}catch{return l}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-primary/10 border border-primary rounded-xl px-8 py-4 mb-4 flex items-center justify-between","data-testid":"upcoming-billing-banner",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ie,{size:20,className:"text-primary shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-secondary-dark",children:t("invoices.upcomingBilling.nextPaymentLabel")}),e.jsx("p",{className:"text-xl font-bold text-dark",children:b(c)})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-sm text-secondary-dark",children:t("invoices.upcomingBilling.amountDue")}),e.jsxs("p",{children:[e.jsxs("span",{className:"text-xl font-extrabold text-dark",children:[x,g]}),e.jsx("span",{className:"text-sm font-light text-secondary-dark ml-1",children:t("invoices.upcomingBilling.exclVat")})]})]})]}),e.jsxs("div",{className:"bg-white border border-secondary-lighter rounded-xl overflow-hidden mb-4","data-testid":"upcoming-billing-table-card",children:[e.jsx("div",{className:"px-8 pt-4 pb-3 flex items-start justify-between",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold text-dark",children:t("invoices.upcomingBilling.billingTitle")}),e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx("p",{className:"text-sm text-secondary-dark",children:t("invoices.upcomingBilling.billingSubtitle")}),e.jsx("button",{type:"button",className:"text-sm text-primary underline cursor-pointer shrink-0",onClick:()=>a(!0),"data-testid":"view-discount-tiers-link",children:t("invoices.upcomingBilling.viewDiscountTiers")})]})]})}),e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{className:"bg-secondary-lightest border-y border-secondary-lighter",children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-sm font-semibold text-secondary-dark text-left w-[200px] pl-8 py-3",children:t("invoices.upcomingBilling.tableHeaders.planQuantity")}),e.jsx("th",{className:"text-sm font-semibold text-secondary-dark text-left w-[100px] px-4 py-3",children:t("invoices.upcomingBilling.tableHeaders.discount")}),e.jsx("th",{className:"text-sm font-semibold text-secondary-dark text-left w-[150px] px-4 py-3",children:t("invoices.upcomingBilling.tableHeaders.nextBilling")}),e.jsx("th",{className:"text-sm font-semibold text-secondary-dark text-left w-[200px] px-4 py-3",children:t("invoices.upcomingBilling.tableHeaders.amountDue")})]})}),e.jsx("tbody",{children:d.map((l,v)=>{const p=Ye(l.plan_breakdown);return e.jsxs("tr",{className:"border-b border-secondary-lighter last:border-b-0","data-testid":"upcoming-billing-row",children:[e.jsxs("td",{className:"text-md text-secondary-dark pl-8 py-4",children:[e.jsx("span",{className:"font-bold",children:l.total_sites}),p&&e.jsxs("span",{className:"font-normal ml-1",children:["(",p,")"]})]}),e.jsx("td",{className:"text-md text-secondary-dark px-4 py-4",children:l.discount_percentage?t("invoices.upcomingBilling.discountOff",{percent:l.discount_percentage}):e.jsx("span",{"data-testid":"discount-starter-label",children:t("invoices.upcomingBilling.discountStarterLabel")})}),e.jsx("td",{className:"text-md text-secondary-dark px-4 py-4",children:b(l.next_billing_date)}),e.jsxs("td",{className:"text-md text-secondary-dark px-4 py-4",children:[x,l.amount_due]}
31)]},v)})})]})]}),e.jsx(ke,{isOpen:o,onClose:()=>a(!1)})]})}function X({className:t="",size:s=16}){return e.jsxs("svg",{width:s,height:s,viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,children:[e.jsx("path",{d:"M13 6.91406V13C13 13.3978 12.842 13.7794 12.5607 14.0607C12.2794 14.342 11.8978 14.5 11.5 14.5H4.5C4.10218 14.5 3.72064 14.342 3.43934 14.0607C3.15804 13.7794 3 13.3978 3 13V3C3 2.60218 3.15804 2.22064 3.43934 1.93934C3.72064 1.65804 4.10218 1.5 4.5 1.5H7.58594C7.85106 1.50004 8.10532 1.60536 8.29281 1.79281L12.7072 6.20719C12.8946 6.39468 13 6.64894 13 6.91406Z",className:"stroke-current",strokeLinejoin:"round"}),e.jsx("path",{d:"M8 1.75V5.5C8 5.76522 8.10536 6.01957 8.29289 6.20711C8.48043 6.39464 8.73478 6.5 9 6.5H12.75",className:"stroke-current",strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ge(t){try{return V(new Date(t),"MMM d, yyyy")}catch{return t}}function Ze(){var G;const{t}=B(),s=pe(i=>i.websites),n=w(i=>i.isAgency),o=H(i=>i.pricingModel),a=le("account::billing-invoice:index"),d=n()&&o==="v2",{data:c,isLoading:g}=Y(),r=d&&(g||(((G=c==null?void 0:c.upcoming_invoices)==null?void 0:G.length)??0)>0),m=d?c==null?void 0:c.next_payment_date:void 0,x=h.useMemo(()=>{const i=new Date().getFullYear(),N=[];for(let k=2018;k<=i;k++)N.push(k);return N},[]),b=["January","February","March","April","May","June","July","August","September","October","November","December"],[u,l]=h.useState(void 0),[v,p]=h.useState(void 0),[S,q]=h.useState(null),[O,M]=h.useState(null),[P,f]=h.useState([null]),{data:y,isLoading:j}=Ke({year:u,month:v,website_id:S,starting_after:O,per_page:10,__enabled:a}),K=(y==null?void 0:y.invoices)||[],L=(y==null?void 0:y.hasInvoice)||!1,me=i=>{const N=he(i);let k="invoices.status.completed";return i==="draft"||i==="open"?k="invoices.status.pending":(i==="uncollectible"||i==="void")&&(k="invoices.status.failed"),e.jsx(ue,{variant:N,className:`inline-flex items-center 32 px-3 py-1 33 text-xs font-normal 34 rounded 35 whitespace-nowrap`,children:t(k)})},J=()=>{const i=!L&&!!m,N=L?"emptyState.invoiceWithPaymentHistory":"emptyState.invoiceWithoutPaymentHistory";return e.jsx("div",{className:"flex justify-center items-center h-full w-full",children:e.jsxs("div",{className:"max-w-[400px] mx-auto text-center",children:[e.jsx(re,{className:"mb-2 mx-auto"}),i?e.jsx("p",{className:"text-[#4e4b66] font-semibold mb-2",children:t("emptyState.invoiceTrialPending.infoMessage",{date:Ge(m)})}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[#4e4b66] font-semibold mb-2",children:t(`${N}.infoMessage`)}),e.jsx("p",{className:"text-secondary",children:t(`${N}.actionMessage`)})]})]})})},xe=()=>K.length===0?e.jsx("div",{className:"overflow-x-auto min-h-[400px] flex items-center justify-center",children:J()}):e.jsx("div",{className:"overflow-x-auto overflow-x-auto min-h-[400px] mb-0","data-testid":"invoices-table",children:e.jsxs("table",{className:"w-full border-collapse mb-0",children:[e.jsx("thead",{className:"border-y border-[#e5e7eb] bg-transparent","data-testid":"invoices-table-header",children:e.jsxs("tr",{children:[e.jsx("th",{className:"pl-6 pr-3 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.issueDate")}),e.jsxs("th",{className:"px-3 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:[e.jsx(X,{className:"mr-1 text-[#4e4b66] font-semibold inline-block align-middle",size:16}),t("invoices.invoiceNo")]}),e.jsx("th",{className:"px-3 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.amount")}),e.jsx("th",{className:"px-3 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.paymentMethod")}),e.jsx("th",{className:"pl-3 px-4 py-4 text-sm font-semibold text-[#4e4b66] text-left whitespace-nowrap",children:t("invoices.paymentStatus")})]})}),e.jsx("tbody",{"data-testid":"invoices-table-body",children:K.map(i=>e.jsxs("tr",{className:"border-[#f3f4f6] last:border-b-0 hover:bg-[#f9fafb] transition-colors duration-150","data-testid":"invoice-row","data-invoice-id":i.invoice_id,children:[e.jsx("td",{className:"pr-3 align-middle text-nowrap pl-6 pr-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"invoice-cell-issue-date",children:i.issued_date}),e.jsx("td",{className:"px-3 align-middle px-4 py-4 text-sm text-[#6e7191] align-middle",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(X,{className:"mr-1 text-secondary inline-block align-middle",size:16}),e.jsx("span",{"data-testid":"invoice-cell-number-link",children:i.number}),i.status!=="uncollectible"&&i.status!=="void"&&e.jsx("a",{href:i.download_link,target:"_blank",rel:"noopener noreferrer",className:"ml-2","data-testid":"invoice-download-button",children:e.jsx("img",{src:"/images/icons/download-cloud.svg",alt:"download-icon"})})]})}),e.jsx("td",{className:"px-3 align-middle text-nowrap px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"invoice-cell-amount",children:i.amount}),e.jsx("td",{className:"px-3 align-middle px-4 py-4 text-sm text-[#6e7191] align-middle",children:e.jsxs("div",{className:"flex items-center",children:[i.src&&e.jsx("img",{className:"border border-secondary-lighter rounded px-1 mr-2",src:i.src,"data-testid":"invoice-cell-method-brand"}),e.jsx("span",{"data-testid":"invoice-cell-method-text",children:i.payment_method})]})}),e.jsx("td",{className:"pl-3 align-middle text-nowrap px-4 py-4 text-sm text-[#6e7191] align-middle","data-testid":"invoice-cell-status-pill",children:me(i.status)})]},i.invoice_id))})]})});return!L&&K.length===0&&!j&&!r?e.jsx("div",{className:"bg-white rounded-xl overflow-hidden bg-white h-[calc(100vh-160px)]",children:e.jsx("div",{className:"p-6 h-full flex justify-center items-center",children:J()})}):e.jsxs(e.Fragment,{children:[n()&&o==="v2"&&e.jsx(Je,{}),n()&&o!=="v2"&&e.jsx(Qe,{}),e.jsxs("div",{className:"bg-white rounded-xl overflow-hidden bg-white",children:[e.jsxs("div",{className:"py-4 px-6 border-[#e5e7eb] flex justify-between items-center items-center",children:[e.jsx("p",{className:"mt-2.5 mb-2.5 text-base font-semibold text-[#4e4b66] text-base font-semibold text-[#4e4b66] m-0 mb
35-0","data-testid":"invoices-section-title",children:t("invoices.invoices")}),L&&e.jsxs("div",{className:"flex",children:[e.jsxs("div",{className:"relative inline-block mr-4",children:[e.jsxs("select",{value:u||"",onChange:i=>{l(i.target.value?Number(i.target.value):void 0),M(null),f([null])},className:`appearance-none bg-white border border-gray-500 rounded-md 36 py-1 pl-3 pr-7 text-sm text-[#6e7191] cursor-pointer 37 transition-all duration-150 min-w-[80px] 38 focus:outline-none focus:border-blue-500 focus:ring focus:ring-blue-500/20 hover:border-gray-400 focus:outline-none focus:border-blue-500 focus:ring focus:ring-blue-500/20`,"data-testid":"invoice-filter-year",children:[e.jsx("option",{value:"",children:t("invoices.filters.year")}),x.map(i=>e.jsx("option",{value:i,"data-testid":`invoice-filter-year-${i}`,children:i},i))]}),e.jsx("img",{src:"/images/icons/chevron-down.svg",className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 w-2 h-2"})]}),e.jsxs("div",{className:"relative inline-block mr-4",children:[e.jsxs("select",{value:v||"",onChange:i=>{p(i.target.value||void 0),M(null),f([null])},className:`appearance-none bg-white border border-gray-500 rounded-md 39 py-1 pl-3 pr-7 text-sm text-[#6e7191] cursor-pointer 40 transition-all duration-150 min-w-[80px] 41 focus:outline-none focus:border-blue-500 focus:ring focus:ring-blue-500/20 hover:border-gray-400`,"data-testid":"invoice-filter-month",children:[e.jsx("option",{value:"",children:t("invoices.filters.month")}),b.map(i=>e.jsx("option",{value:i,"data-testid":`invoice-filter-month-${i.toLowerCase()}`,children:i},i))]}),e.jsx("img",{src:"/images/icons/chevron-down.svg",className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 w-2 h-2"})]}),!n()&&e.jsxs("div",{className:"relative inline-block",children:[e.jsxs("select",{value:S||"",onChange:i=>{q(i.target.value?Number(i.target.value):null),M(null),f([null])},className:`appearance-none bg-white border border-gray-500 rounded-md 42 py-1 pl-3 pr-7 text-sm text-[#6e7191] cursor-pointer 43 transition-all duration-150 min-w-[80px] 44 focus:outline-none focus:border-blue-500 focus:ring focus:ring-blue-500/20 hover:border-gray-400`,"data-testid":"invoice-filter-website",children:[e.jsx("option",{value:"","data-testid":"invoice-filter-website-all",children:t("invoices.filters.allWebsites")}),s().map(i=>e.jsx("option",{value:i.id,"data-testid":`invoice-filter-website-${i.id}`,children:ge(i.url)},i.id))]}),e.jsx("img",{src:"/images/icons/chevron-down.svg",className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 w-2 h-2"})]})]})]}),e.jsx("div",{className:"p-6-table p-0",children:j?e.jsx(_,{}):xe()}),(y==null?void 0:y.pagination)&&(P.length>1||y.pagination.has_more)&&e.jsx("div",{className:"flex justify-center items-center px-6 py-4 border-t border-[#e5e7eb]","data-testid":"invoices-pagination",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{if(P.length>1){const i=[...P];i.pop();const N=i[i.length-1];f(i),M(N)}},disabled:P.length<=1,className:"px-4 py-2 text-sm font-semibold text-[#6e7191] border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer transition-colors","data-testid":"invoices-pagination-prev-button",children:"Previous"}),e.jsx("button",{onClick:()=>{var i;(i=y.pagination)!=null&&i.starting_after&&(f([...P,O]),M(y.pagination.starting_after))},disabled:!y.pagination.has_more,className:"px-4 py-2 text-sm font-semibold text-[#6e7191] border border-gray-300 rounded-md hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer transition-colors","data-testid":"invoices-pagination-next-button",children:"Next"})]})})]})]})}function Xe(){const{t}=B(),{data:s,isLoading:n}=Q(),o=ze(),a=()=>{o.mutate()};if(n)return e.jsx("div",{className:"bg-white rounded-xl overflow-hidden",children:e.jsx("div",{className:"p-6 flex justify-center items-center min-h-[400px]",children:e.jsx(_,{})})});if(!(s!=null&&s.customerEmail))return e.jsx("div",{className:"bg-white rounded-xl overflow-hidden mb-4 bg-white",children:e.jsxs("div",{className:"p-6",children:[e.jsx("p",{className:"mt-2.5 mb-2.5 text-base font-semibold text-[#4e4b66] text-base font-semibold text-[#4e4b66] m-0 mb
44-3",children:t("billingDetailsWrapper.userBillingDetails.title")}),e.jsx("div",{className:"px-3 py-5",children:e.jsxs("div",{className:"max-w-[400px] mx-auto text-center py-5 mb-5",children:[e.jsx(re,{className:"mb-2 mx-auto"}),e.jsx("p",{className:"text-[#4e4b66] font-semibold mb-2",children:t("emptyState.billingDetailsWithoutPaymentHistory.infoMessage")}),e.jsx("p",{className:"text-secondary",children:t("emptyState.billingDetailsWithoutPaymentHistory.actionMessage")})]})})]})});const{customerBillingName:d,customerBillingAddress:c,customerBillingCountry:g,customerBillingTaxId:r,customerPaymentMethod:m}=s,x=fe(c),b=m?ye(m,t):null,u=m!=null&&m.brand?ee(m.brand):"";return e.jsx("div",{className:"bg-white rounded-xl overflow-hidden mb-4 bg-white","data-testid":"billing-details-card",children:e.jsxs("div",{className:"p-6",children:[e.jsx("p",{className:"mt-2.5 mb-2.5 text-base font-semibold text-[#4e4b66] text-base font-semibold text-[#4e4b66] m-0 mb-3",children:t("billingDetailsWrapper.userBillingDetails.title")}),e.jsx("div",{className:"bg-[#ffe8c6] rounded p-2 mb-3",children:e.jsx("p",{className:"text-[#4e4b66] text-sm leading-6 mb-0 text-dark",children:e.jsx(A,{i18nKey:"billingDetailsWrapper.userBillingDetails.paymentInformation",components:{stripePortal:e.jsx("a",{onClick:a,onKeyDown:l=>l.key==="Enter"&&a(),role:"button",tabIndex:0,className:"text-semi-sm text-[#1578f7] font-semibold cursor-pointer no-underline"})}})})}),e.jsxs("div",{className:"flex mb-4",children:[e.jsx(qe,{className:"mr-3 text-secondary",size:24}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-[#4e4b66] font-semibold text-sm font-semibold",children:t("billingDetailsWrapper.userBillingDetails.name")}),e.jsx("p",{className:"text-md mb-0 text-secondary","data-testid":"billing-details-name",children:d})]})]}),e.jsxs("div",{className:"flex mb-4 mr-5",children:[e.jsx(He,{className:"mr-3 text-secondary",size:24}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm font-semibold text-[#4e4b66]",children:t("billingDetailsWrapper.userBillingDetails.address")}),e.jsx("p",{className:"text-md mb-0 text-secondary","data-testid":"billing-details-address",children:x})]})]}),e.jsxs("div",{className:"flex justify-between items-center mr-5 flex-wrap",children:[e.jsxs("div",{className:"flex mb-4",children:[e.jsx(Ae,{className:"mr-3 text-secondary",size:24}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm font-semibold text-[#4e4b66]",children:t("billingDetailsWrapper.userBillingDetails.country")}),e.jsx("p",{className:"text-md mb-0 text-secondary","data-testid":"billing-details-country",children:g})]})]}),r&&e.jsxs("div",{className:"flex mb-4",children:[e.jsx(Oe,{className:"mr-3 text-secondary",size:24}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-sm text-[#4e4b66] font-semibold",children:t("billingDetailsWrapper.userBillingDetails.taxId")}),e.jsx("p",{className:"text-md mb-0 text-secondary",children:r})]})]})]}),m&&b&&e.jsxs("div",{className:"p-5 rounded-lg mt-4 bg-[#f7f7fc] border border-[#e2e5f1] px-3 border border-secondary-lighter","data-testid":"billing-payment-method-card",children:[e.jsx("p",{className:"mb-2 text-[#4e4b66] font-semibold",children:t("billingDetailsWrapper.userBillingDetails.paymentMethod")}),e.jsxs("div",{className:"flex",children:[u&&e.jsx("img",{src:u,alt:"card",className:"border border-secondary-lighter rounded px-1",height:"42",width:"58","data-testid":"billing-payment-method-brand"}),e.jsxs("div",{className:"ml-3 flex flex-col",children:[e.jsx("p",{className:"mb-0 text-sm font-semibold text-dark",dangerouslySetInnerHTML:{__html:b.mainText},"data-testid":"billing-payment-method-last4"}),b.subText&&e.jsx("p",{className:"mb-0 text-sm text-secondary","data-testid":"billing-payment-method-expiry",children:b.subText})]})]})]}),e.jsxs("a",{onClick:a,onKeyDown:l=>l.key==="Enter"&&a(),role:"button",tabIndex:0,className:"flex align-items-center mt-4","data-testid":"billing-details-stripe-portal-link",children:[e.jsx("span",{className:"text-base text-[#1578f7] font-semibold cursor-pointer no-underline",children:t("billingDetailsWrapper.userBillingDetails.str
44ipePortal")}),e.jsx(Be,{className:"ml-2 text-[#1578f7] font-semibold cursor-pointer no-underline",size:20})]})]})})}function et(){const{t}=B(),{data:s,isLoading:n}=ce(),o=Re(),[a,d]=h.useState(!1),[c,g]=h.useState(""),[r,m]=h.useState(""),x=s==null?void 0:s.email,b=()=>{g(x||""),m(""),d(!0)},u=()=>{d(!1),m(""),g(x||"")},l=p=>!p||p.trim()===""?t("billingDetailsWrapper.updateEmailModal.emailRequired"):p.length>190?t("billingDetailsWrapper.updateEmailModal.emailExceed"):ve(p.trim())?"":t("billingDetailsWrapper.updateEmailModal.invalidEmail"),v=async()=>{const p=l(c);if(p){m(p);return}try{await o.mutateAsync({email:c}),d(!1),m("")}catch(S){console.error("Error updating billing email:",S),m(t("billingDetailsWrapper.updateEmailModal.updateBillingEmailError"))}};return n?e.jsx("div",{className:"bg-white rounded-xl overflow-hidden my-4 bg-white",children:e.jsx("div",{className:"p-6 flex justify-center items-center py-5",children:e.jsx(_,{})})}):x?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-white rounded-xl overflow-hidden my-4 bg-white","data-testid":"billing-email-card",children:e.jsxs("div",{className:"p-6",children:[e.jsx("p",{className:"mt-2.5 mb-2.5 text-base font-semibold text-[#4e4b66] text-base font-semibold text-[#4e4b66] m-0 mb
44-0",children:t("billingDetailsWrapper.billingEmail")}),e.jsx("p",{className:"mt-1 mb-0 text-sm text-[#6e7191] text-md text-secondary",children:t("billingDetailsWrapper.updateBillingEmail.subTitle")}),e.jsxs("div",{className:"flex justify-between items-center mt-3 flex-wrap",children:[e.jsxs("div",{className:"flex justify-center items-center",children:[e.jsx(We,{className:"mr-2 text-secondary",size:20,strokeWidth:1}),e.jsx("p",{className:"text-md mb-0 text-secondary truncate max-w-[200px]",title:x,"data-testid":"billing-email-value",children:x})]}),e.jsx("button",{className:`border border-blue-500 text-blue-500 px-4 py-2 mt-1 rounded 45 hover:bg-blue-500 hover:text-white transition cursor-pointer`,onClick:b,type:"button","data-testid":"billing-email-update-button",children:e.jsx("span",{className:"text-sm font-semibold",children:t("billingDetailsWrapper.updateBillingEmail.updateEmail")})})]})]})}),e.jsx(oe,{open:a,onOpenChange:d,children:e.jsxs(de,{className:"max-w-148","data-testid":"billing-email-modal",children:[e.jsx(F,{children:e.jsx(W,{"data-testid":"billing-email-modal-title",children:t("billingDetailsWrapper.billingEmail")})}),e.jsx("div",{className:"py-4",children:e.jsx("form",{onSubmit:p=>p.preventDefault(),children:e.jsx("div",{className:"form-row",children:e.jsx("div",{className:"col-12",children:e.jsxs("div",{className:"mb-4",children:[e.jsxs("label",{htmlFor:"billing-email",className:"block mb-2 text-md text-secondary","data-testid":"billing-email-label",children:[t("billingDetailsWrapper.updateEmailModal.emailRecipient"),e.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),e.jsx("input",{id:"billing-email",type:"email",value:c,onChange:p=>g(p.target.value),className:`w-full px-3 py-2.5 46 border border-[#d1d5db] rounded-md 47 text-sm text-[#4e4b66] 48 transition-all duration-150 49 focus:outline-none focus:border-[#1578f7] 50 focus:ring focus:ring-[#1578f7]/10 font-semibold`,required:!0,"data-testid":"billing-email-input","aria-invalid":!!r}),r&&e.jsx("div",{className:"pt-2 rounded-md text-sm text-[#dc2626]",role:"alert","data-testid":"billing-email-error-text",children:r})]})})})})}),e.jsxs($,{className:"flex justify-end gap-3 pt-4",children:[e.jsx("button",{type:"button",className:`inline-flex items-center justify-center 51 bg-transparent border border-[#d1d5db] 52 text-sm font-semibold text-[#6e7191] 53 px-6 py-2.5 rounded-md 54 cursor-pointer 55 transition-all duration-200 56 hover:bg-[#f9fafb]`,disabled:o.isPending,onClick:u,"data-testid":"billing-email-cancel-button",children:e.jsx("span",{className:"text-base font-semibold",children:t("common.cancel")})}),e.jsxs("button",{type:"button",className:`inline-flex items-center justify-center 57 px-6 py-2.5 rounded-md 58 text-sm font-semibold text-white 59 bg-[#1578f7] 60 transition-all duration-200 61 hover:bg-[#0d5fd9] 62 disabled:bg-[#9ca3af] 63 disabled:cursor-not-allowed`,disabled:o.isPending,onClick:v,"data-testid":"billing-email-save-button","aria-busy":o.isPending,children:[e.jsx("span",{className:"text-base font-semibold",children:t("billingDetailsWrapper.updateEmailModal.saveChanges")}),o.isPending&&e.jsx("output",{className:"spinner-border spinner-border-sm ml-1","aria-live":"polite",children:e.jsx("span",{className:"sr-only",children:"Loading..."})})]})]})]})})]}):null}function tt({isOpen:t,onClose:s,onConfirm:n,targetStatus:o,hasOverage:a}){const{t:d}=B(),[c,g]=h.useState(!1),r=async()=>{g(!0);try{await n()}finally{g(!1)}},m=()=>e.jsxs(e.Fragment,{children:[e.jsx(F,{children:e.jsx(W,{className:"text-2xl font-semibold text-[#4e4b66]","data-testid":"extra-usage-enable-modal-title",children:d("invoices.enableExtraPageviews.enableExtraPageviewsModal.title")})}),e.jsxs("div",{className:"text-left mt-4","data-testid":"extra-usage-enable-modal-description",children:[e.jsx("p",{className:"mb-3 text-md text-[#4e4b66] leading-relaxed",children:e.jsx(A,{i18nKey:"invoices.enableExtraPageviews.enableExtraPageviewsModal.turnOnExtraPageviews",components:{strong:e.jsx("strong",{})}})}),e.jsx("p",{className:"mb-0 text-md text-[#4e4b66] leading-relaxed",children:e.jsx(A,{i18nKey:"invoices.enableExtraPageviews.enableExtraPageviewsModal.additionalCharges",components:{strong:e.jsx("strong",{})}})})]}),e.jsxs("div",{className:"bg-[#e8f2ff] rounded-lg p-2 flex gap-2 mt-4","data-testid":"extra-usage-enable-modal-callout",children:[e.jsx(je,{className:"flex-shrink-0 mt-0.5 text-[#1578f7] font-semibold cursor-pointer no-underline",size:16,"data-testid":"extra-usage-enable-modal-callout-icon"}),e.jsx("p",{className:"mb-0 text-xs text-[#4e4b66] leading-snug",children:d("invoices.enableExtraPageviews.enableExtraPageviewsModal.info")})]}),e.jsx("div",{className:"text-left mt-4",children:e.jsxs("p",{className:"mb-0 text-md text-[#4e4b66] leading-relaxed",children:[d("invoices.enableExtraPageviews.enableExtraPageviewsModal.extraCh
63arges")," ",e.jsxs("a",{href:"https://www.cookieyes.com/documentation/pageview-pricing/#:~:text=Pageviews%20in%20CookieYes%3F-,How%20does%20extra%20pageviews%20billing%20work%3F,-Extra%20pageviews%20billing",target:"_blank",rel:"noopener noreferrer",className:"text-[#1578f7] font-semibold cursor-pointer no-underline border-0 bg-transparent p-0","data-testid":"extra-usage-enable-modal-learn-more-link",children:[d("invoices.enableExtraPageviews.enableExtraPageviewsModal.learnMore")," ","â"]})]})}),e.jsxs($,{className:"flex justify-end gap-3 mt-6",children:[e.jsx(D,{variant:"outline-secondary-light",onClick:s,disabled:c,className:"font-semibold","data-testid":"extra-usage-enable-modal-cancel-button",children:"Cancel"}),e.jsx(D,{onClick:r,disabled:c,className:"bg-blue-600 hover:bg-blue-700 font-semibold","data-testid":"extra-usage-enable-modal-confirm-button","aria-busy":c,children:c?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2"}),"Enabling..."]}):d("invoices.enableExtraPageviews.enableExtraPageviewsModal.enableExtraPageviews")})]})]}),x=()=>e.jsxs(e.Fragment,{children:[e.jsx(F,{children:e.jsx(W,{className:"text-2xl font-semibold text-[#4e4b66]",children:d("invoices.disableExtraPageviewsModals.disableExtraPageviewsModal.title")})}),e.jsxs("div",{className:"text-left mt-4",children:[e.jsx("p",{className:"mb-3 text-md text-[#4e4b66] leading-relaxed",children:d("invoices.disableExtraPageviewsModals.disableExtraPageviewsModal.turnOffExtraPageviews")}),e.jsx("p",{className:"mb-0 text-md text-[#4e4b66] leading-relaxed",children:e.jsx(A,{i18nKey:"invoices.disableExtraPageviewsModals.disableExtraPageviewsModal.disableBannerInfo",components:{strong:e.jsx("strong",{})}})})]}),e.jsxs($,{className:"flex justify-end gap-3 mt-6",children:[e.jsx(D,{variant:"outline-secondary-light",onClick:s,disabled:c,className:"font-semibold",children:d("Cancel")}),e.jsx(D,{variant:"danger",onClick:r,disabled:c,className:"font-semibold",children:c?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2"}),"Disabling..."]}):d("invoices.disableExtraPageviewsModals.disableExtraPageviewsModal.disableExtraPageviews")})]})]}),b=()=>e.jsxs(e.Fragment,{children:[e.jsx(F,{children:e.jsx(W,{className:"text-lg font-semibold text-[#4e4b66]",children:d("invoices.disableExtraPageviewsModals.disableExtraPageviewsMidOverageModal.title")})}),e.jsxs("div",{className:"text-left mt-4",children:[e.jsx("p",{className:"mb-3 text-md text-[#4e4b66] leading-relaxed",children:d("invoices.disableExtraPageviewsModals.disableExtraPageviewsMidOverageModal.disableBanner")}),e.jsxs("p",{className:"mb-3 text-md text-[#4e4b66] leading-relaxed",children:[d("invoices.disableExtraPageviewsModals.disableExtraPageviewsMidOverageModal.option1")," ",d("invoices.disableExtraPageviewsModals.disableExtraPageviewsMidOverageModal.option2")]}),e.jsx("p",{className:"mb-0 text-md text-[#4e4b66] leading-relaxed",children:d("invoices.disableExtraPageviewsModals.disableExtraPageviewsMidOverageModal.note")})]}),e.jsxs($,{className:"flex justify-end gap-3 mt-6",children:[e.jsx(D,{variant:"outline-secondary-light",onClick:s,disabled:c,className:"font-semibold",children:d("Cancel")}),e.jsx(D,{variant:"danger",onClick:r,disabled:c,className:"font-semibold",children:c?e.jsxs(e.Fragment,{children:[e.jsx(z,{className:"w-4 h-4 mr-2"}),"Disabling..."]}):d("invoices.disableExtraPageviewsModals.disableExtraPageviewsModal.disableExtraPageviews")})]})]}),u=()=>o?m():a?b():x();return e.jsx(oe,{open:t,onOpenChange:s,children:e.jsx(de,{className:"sm:max-w-[600px]","data-testid":"extra-usage-enable-modal",children:u()})})}function st(){const{t}=B(),s=w(f=>f.accountID()),n=w(f=>f.isAgency()),o=Ne({select:f=>new URLSearchParams(f.searchStr).get("ref")}),{data:a,isLoading:d,refetch:c}=Q(),g=h.useMemo(()=>a?!a.canEnableOverageSection||a.isFreeOnlyUser||a.isTrialOnlyUser:!0,[a]),[r,m]=h.useState(!1),[x,b]=h.useState(null),[u,l]=h.useState(!1),[v,p]=h.useState(!1);h.useEffect(()=>{(a==null?void 0:a.overageEnabled)!==void 0&&p(a.overageEnabled)},[a==null?void 0:a.overageEnabled]);const S=Ve(),q=f=>{g||(b(f),m(!0))},O=()=>{m(!1),b(null),p((a==null?void 0:a.overageEnabled)||!1)},M=async()=>{var f;if(!(x===null||!s))try{await S.mutateAsync({account_id:s,overage_status:x,ref:o||void 0}),await c(),m(!1),b(null)}catch(y){p((a==null?void 0:a.overageEnabled)||!1),m(!1),b(null);const j=y;(((f=j==null?void 0:j.response)==null?void 0:f.status)===403||(j==null?void 0:j.status)===403)&&l(!0),console.error("Error updating overage status:",y)}},P=()=>{l(!1)};return n||!(a!=null&&a.shouldDisplayOverageSection)?null:d?e.jsx("div",{className:"my-6",children:e.jsx("div",{className:"bg-white rounded-xl overflow-hidden",children:e.jsx("div",{className:"p-6 flex justify-center items-center min-h-[200px]",children:e.jsx(_,{})})})}):a!=null&&a.customerEmail?e.jsxs(se,{children:[e.jsx("div",{className:"my-6",children:e.jsx("div",{className:"bg-white rounded-xl overflow-hidden","data-testid":"extra-usage-card",children:e.jsxs("div",{className:"p-6",children:[e.jsx("p",{className:"text-lg font-semibold text-[#4e4b66] mb-3","data-testid":"extra-usage-title",children:t("invoices.enableExtraPageviews.title")}),e.jsxs("div",{className:"flex items-center mb-1","data-testid":"extra-usage-toggle-row",children:[e.jsx("p",{className:"text-[#4e4b66] font-semibold text-md mb-0 mr-2",children:t("invoices.enableExtraPageviews.enableExtraPageviews")}),e.jsx(we,{checked:v,onCheckedChange:g?void 0:q,disabled:g,"aria-label":t("invoices.enableExtraPageviews.enableExtraPageviews"),className:` 64 mr-2 65 data-[state=unchecked]:bg-gray-400 66 [&_[data-slot='switch-thumb']]:data-[state=unchecked]:bg-gray-50 67 disabled:opacity-50 68 disabled:cursor-not-allowed 69 `,"data-testid":"extra-usage-toggle"}),e.jsxs(ae,{children:[e.jsx(ie,{asChild:!0,children:e.jsx("span",{className:"inline-flex ml-1","data-testid":"extra-usage-info-button",children:e.jsx(Ee,{className:"w-[18px] h-[18px] text-[#4e4b66]"})})}),e.jsx(ne,{showArrow:!0,"data-testid":"extra-usage-info-tooltip",children:e.jsx("div",{className:"max-w-xs",children:e.jsxs("p",{className:"mb-0 text-left",children:[a!=null&&a.canEnableOverageSection?t("invoices.enableExtraPageviews.tooltip"):a!=null&&a.isFreeOnlyUser?t("invoices.enableExtraPageviews.isFreeOnlyUserTooltip"):a!=null&&a.isTrialOnlyUser?t("invoices.enableExtraPageviews.isTrialOnlyUserTooltip"):t("invoices.enableExtraPageviews.cannotEnableOverageSectionTooltip")," ",e.jsx("a",{href:t("invoices.enableExtraPageviews.learnMoreLink"),target:"_blank",rel:"noopener noreferrer",className:"text-[#1578f7] font-semibold cursor-pointer no-underline",children:t("invoices.enableExtraPageviews.learnMoreText")})]})})})]})]}),e.jsx("p",{className:"text-xs italic text-secondary mb-0","data-testid":"extra-usage-description",children:t("invoices.enableExtraPageviews.extraCharges")})]})})}),x!==null&&e.jsx(tt,{isOpen:r,onClose:O,onConfirm:M,targetStatus:x,hasOverage:(a==null?void 0:a.hasOverage)||!1}),e.jsx(Me,{isOpen:u,onClose:P})]}):null}function at(){const{isLoading:t}=Q(),{isLoading:s}=ce();return t||s?e.jsx("div",{className:"flex justify-center items-center min-h-[400px]",children:e.jsx(_,{})}):e.jsxs("div",{"data-testid":"billing-side-panel",children:[e.jsx(Xe,{}),e.jsx(st,{}),e.jsx(et,{})]})}function it(){const t=H(o=>o.showWebsiteRenewalFailedAlert),s=H(o=>o.license),n=le("account::billing-invoice:index");return e.jsxs("div",{className:"pt-[112px] min-h-screen bg-secondary-lightest px-8","data-testid":"billing-invoices-page",children:[t()&&(s==null?void 0:s.id)&&e.jsx(_e,{licenseId:s.id}),e.jsx(Ce,{}),e.jsx(Se,{}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-12 gap-6",children:[e.jsx("div",{className:n?"w-full min-w-0 md:col-span-8 mb-4":"w-full min-w-0 md:col-span-12 mb-4",children:e.jsx(Ze,{})}),n&&e.jsx("div",{className:"w-full md:col-span-4",children:e.jsx(at,{})})]})]})}const mt=Pe("/settings/billing")({component:it});export{mt as Route};
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.