UNPKG

@clerk/clerk-js

Version:
1 lines • 21.4 kB
"use strict";(globalThis.webpackChunk_clerk_clerk_js=globalThis.webpackChunk_clerk_clerk_js||[]).push([["294"],{2264:function(e,t,r){r.r(t),r.d(t,{PaymentAttemptPage:()=>$,PaymentAttemptsList:()=>d});var o=r(9109),i=r(6600),a=r(9082),n=r(5913),l=r(1576),c=r(4204),s=r(4676);let d=()=>{let{data:e,isLoading:t,count:r}=(0,l.usePaymentAttempts)(),a=(0,l.useSubscriberTypeLocalizationRoot)();return(0,o.tZ)(i.wQ,{page:1,onPageChange:e=>{},itemCount:r,pageCount:1,itemsPerPage:10,isLoading:t,emptyStateLocalizationKey:(0,c.localizationKeys)(`${a}.billingPage.paymentHistorySection.empty`),headers:[(0,c.localizationKeys)(`${a}.billingPage.paymentHistorySection.tableHeader__date`),(0,c.localizationKeys)(`${a}.billingPage.paymentHistorySection.tableHeader__amount`),(0,c.localizationKeys)(`${a}.billingPage.paymentHistorySection.tableHeader__status`)],rows:e.map(e=>(0,o.tZ)(p,{paymentAttempt:e},e.id))})},p=({paymentAttempt:e})=>{let{id:t,amount:r,failedAt:l,paidAt:d,updatedAt:p,status:u}=e,{navigate:m}=(0,s.useRouter)();return(0,o.BX)(i.Uk,{onClick:()=>{m(`payment-attempt/${t}`)},children:[(0,o.BX)(c.Td,{sx:{cursor:"pointer"},children:[(0,o.tZ)(c.Text,{variant:"subtitle",children:(0,a.p)(d||l||p,"long")}),(0,o.tZ)(c.Text,{colorScheme:"secondary",variant:"caption",truncate:!0,sx:e=>({marginTop:e.space.$0x5}),children:(0,n.L)(t)})]}),(0,o.tZ)(c.Td,{sx:{cursor:"pointer"},children:(0,o.BX)(c.Text,{children:[r.currencySymbol,r.amountFormatted]})}),(0,o.tZ)(c.Td,{children:(0,o.tZ)(c.Badge,{colorScheme:"paid"===u?"success":"failed"===u?"danger":"primary",sx:{textTransform:"capitalize"},children:u})})]})};var u=r(3799),m=r(7901),h=r(9117),y=r(2654),g=r(8e3),b=r(8018),S=r(2464),x=r(4174);let $=()=>{let{params:e,navigate:t}=(0,s.useRouter)(),r=(0,b.sC)(),{organization:i}=(0,u.o8)(),l=(0,b.xr)(),{t:d,translateError:p}=(0,c.useLocalizations)(),S=(0,u.cL)(),{data:x,isLoading:$,error:z}=(0,m.default)(e.paymentAttemptId?{type:"payment-attempt",id:e.paymentAttemptId,orgId:"organization"===r?i?.id:void 0}:null,()=>S.billing.getPaymentAttempt({id:e.paymentAttemptId,orgId:"organization"===r?i?.id:void 0})),f=x?.subscriptionItem;return $?(0,o.tZ)(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.tZ)(c.Spinner,{colorScheme:"primary",sx:{margin:"auto",display:"block"},elementDescriptor:c.descriptors.spinner})}):(0,o.BX)(o.HY,{children:[(0,o.tZ)(y.h.Root,{sx:e=>({borderBlockEndWidth:e.borderWidths.$normal,borderBlockEndStyle:e.borderStyles.$solid,borderBlockEndColor:e.colors.$borderAlpha100,marginBlockEnd:e.space.$4,paddingBlockEnd:e.space.$4}),children:(0,o.tZ)(y.h.BackLink,{onClick:()=>void t("../../",{searchParams:new URLSearchParams("tab=payments")}),children:(0,o.tZ)(y.h.Title,{localizationKey:(0,c.localizationKeys)(`${l}.billingPage.start.headerTitle__payments`),textVariant:"h2"})})}),x?(0,o.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptRoot,as:"article",sx:e=>({borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,borderRadius:e.radii.$lg,overflow:"clip"}),children:[(0,o.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptHeader,as:"header",sx:e=>({padding:e.space.$4,background:e.colors.$neutralAlpha25,display:"flex",justifyContent:"space-between",alignItems:"flex-start"}),children:[(0,o.BX)(c.Span,{elementDescriptor:c.descriptors.paymentAttemptHeaderTitleContainer,children:[(0,o.tZ)(c.Heading,{elementDescriptor:c.descriptors.paymentAttemptHeaderTitle,textVariant:"h2",localizationKey:(0,a.p)(x.paidAt||x.failedAt||x.updatedAt,"long")}),(0,o.BX)(c.Span,{sx:e=>({display:"flex",alignItems:"center",gap:e.space.$0x25,color:e.colors.$colorMutedForeground}),children:[(0,o.tZ)(Z,{copyLabel:"Copy payment attempt ID",text:x.id}),(0,o.tZ)(c.Text,{colorScheme:"secondary",variant:"subtitle",children:(0,n.L)(x.id)})]})]}),(0,o.tZ)(c.Badge,{elementDescriptor:c.descriptors.paymentAttemptHeaderBadge,colorScheme:"paid"===x.status?"success":"failed"===x.status?"danger":"primary",sx:{textTransform:"capitalize"},children:x.status})]}),(0,o.tZ)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptBody,sx:e=>({padding:e.space.$4}),children:f&&(0,o.BX)(g.a.Root,{children:[(0,o.BX)(g.a.Group,{children:[(0,o.tZ)(g.a.Title,{title:f.plan.name}),(0,o.tZ)(g.a.Description,{prefix:"annual"===f.planPeriod?"x12":void 0,text:`${f.plan.currencySymbol}${"month"===f.planPeriod?f.plan.amountFormatted:f.plan.annualMonthlyAmountFormatted}`})]}),(0,o.BX)(g.a.Group,{borderTop:!0,variant:"tertiary",children:[(0,o.tZ)(g.a.Title,{title:(0,c.localizationKeys)("commerce.subtotal")}),(0,o.tZ)(g.a.Description,{text:`${f.amount?.currencySymbol}${f.amount?.amountFormatted}`})]}),f.credit&&f.credit.amount.amount>0&&(0,o.BX)(g.a.Group,{variant:"tertiary",children:[(0,o.tZ)(g.a.Title,{title:(0,c.localizationKeys)("commerce.credit")}),(0,o.tZ)(g.a.Description,{text:`- ${f.credit.amount.currencySymbol}${f.credit.amount.amountFormatted}`})]})]})}),(0,o.BX)(c.Box,{elementDescriptor:c.descriptors.paymentAttemptFooter,as:"footer",sx:e=>({paddingInline:e.space.$4,paddingBlock:e.space.$3,background:e.colors.$neutralAlpha25,borderBlockStartWidth:e.borderWidths.$normal,borderBlockStartStyle:e.borderStyles.$solid,borderBlockStartColor:e.colors.$borderAlpha100,display:"flex",justifyContent:"space-between"}),children:[(0,o.tZ)(c.Text,{variant:"h3",localizationKey:(0,c.localizationKeys)("commerce.totalDue"),elementDescriptor:c.descriptors.paymentAttemptFooterLabel}),(0,o.BX)(c.Span,{elementDescriptor:c.descriptors.paymentAttemptFooterValueContainer,sx:e=>({display:"flex",alignItems:"center",gap:e.space.$2x5}),children:[(0,o.tZ)(c.Text,{variant:"caption",colorScheme:"secondary",elementDescriptor:c.descriptors.paymentAttemptFooterCurrency,sx:{textTransform:"uppercase"},children:x.amount.currency}),(0,o.BX)(c.Text,{variant:"h3",elementDescriptor:c.descriptors.paymentAttemptFooterValue,children:[x.amount.currencySymbol,x.amount.amountFormatted]})]})]})]}):(0,o.tZ)(c.Box,{sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"},children:(0,o.tZ)(h.b,{variant:"danger",colorScheme:"danger",children:z?p(z.errors[0]):d((0,c.localizationKeys)(`${l}.billingPage.paymentHistorySection.notFound`))})})]})};function Z({text:e,copyLabel:t="Copy"}){let{onCopy:r,hasCopied:i}=(0,S.VP)(e);return(0,o.tZ)(c.Button,{elementDescriptor:c.descriptors.paymentAttemptCopyButton,variant:"unstyled",onClick:r,sx:e=>({color:"inherit",width:e.sizes.$4,height:e.sizes.$4,padding:0,borderRadius:e.radii.$sm,"&:focus-visible":{outline:"2px solid",outlineColor:e.colors.$colorRing}}),focusRing:!1,"aria-label":i?"Copied":t,children:(0,o.tZ)(c.Icon,{size:"sm",icon:i?x.Jr:x.CK,"aria-hidden":!0})})}},5058:function(e,t,r){r.d(t,{hG:()=>A,ph:()=>T,fC:()=>v,OL:()=>P});var o=r(9109),i=r(3799),a=r(9144),n=r(2418),l=r(2672),c=r(431),s=r(9460),d=r(8487),p=r(8849),u=r(8870),m=r(1576),h=r(4204);let y=e=>(0,o.tZ)(h.Box,{sx:[e=>({height:e.space.$2,width:"100%",borderRadius:e.radii.$md,background:e.colors.$neutralAlpha100}),e.sx]}),g=()=>(0,o.tZ)(y,{sx:e=>({height:e.space.$10,width:"100%"})}),b=e=>(0,o.tZ)(h.Flex,{direction:"col",gap:2,children:e.children}),S=()=>(0,o.tZ)(h.Box,{"aria-label":"Loading...",sx:{position:"relative",minHeight:0,flex:1,overflowY:"auto"},children:(0,o.BX)(h.Flex,{direction:"col",gap:5,children:[(0,o.BX)(b,{children:[(0,o.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$24})}),(0,o.tZ)(g,{})]}),(0,o.BX)(h.Grid,{columns:2,gap:4,children:[(0,o.BX)(b,{children:[(0,o.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$20})}),(0,o.tZ)(g,{})]}),(0,o.BX)(b,{children:[(0,o.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$24})}),(0,o.tZ)(g,{})]})]}),(0,o.BX)(b,{children:[(0,o.tZ)(y,{sx:e=>({height:e.space.$3,width:e.sizes.$16})}),(0,o.tZ)(g,{})]}),(0,o.BX)(b,{children:[(0,o.tZ)(y,{}),(0,o.tZ)(y,{}),(0,o.tZ)(y,{sx:{width:"66.666667%"}})]})]})}),[x,$]=(0,i.uH)("AddPaymentSourceRoot"),Z=({children:e,checkout:t,...r})=>{let n=(0,m.useSubscriberTypeContext)(),l=(0,a.useRef)(null),{t:c}=(0,h.useLocalizations)(),[s,d]=(0,a.useState)(void 0),[u,y]=(0,a.useState)(void 0),[g,b]=(0,a.useState)(void 0),S=(e=>{let t=(0,h.useAppearance)().parsedInternalTheme;return(0,a.useMemo)(()=>{if(!e)return;let{colors:r,fontWeights:o,fontSizes:i,radii:a,space:n}=t;return{colorPrimary:(0,p.Aj)(e,r.$primary500,r.$colorBackground),colorBackground:(0,p.Aj)(e,r.$colorInput,r.$colorBackground),colorText:(0,p.Aj)(e,r.$colorForeground,r.$colorBackground),colorTextSecondary:(0,p.Aj)(e,r.$colorMutedForeground,r.$colorBackground),colorSuccess:(0,p.Aj)(e,r.$success500,r.$colorBackground),colorDanger:(0,p.Aj)(e,r.$danger500,r.$colorBackground),colorWarning:(0,p.Aj)(e,r.$warning500,r.$colorBackground),fontWeightNormal:(0,p.uj)(e,"font-weight",o.$normal.toString()),fontWeightMedium:(0,p.uj)(e,"font-weight",o.$medium.toString()),fontWeightBold:(0,p.uj)(e,"font-weight",o.$bold.toString()),fontSizeXl:(0,p.uj)(e,"font-size",i.$xl),fontSizeLg:(0,p.uj)(e,"font-size",i.$lg),fontSizeSm:(0,p.uj)(e,"font-size",i.$md),fontSizeXs:(0,p.uj)(e,"font-size",i.$sm),borderRadius:(0,p.uj)(e,"border-radius",a.$lg),spacingUnit:(0,p.uj)(e,"padding",n.$1)}},[t,e])})(l.current);return(0,o.BX)(x.Provider,{value:{value:{headerTitle:s,headerSubtitle:u,submitLabel:g,setHeaderTitle:d,setHeaderSubtitle:y,setSubmitLabel:b,checkout:t,...r}},children:[(0,o.tZ)("div",{ref:l,style:{display:"none"}}),(0,o.tZ)(i.pe,{checkout:t,for:n,stripeAppearance:S,paymentDescription:c((0,h.localizationKeys)(t?.planPeriod==="month"?"commerce.paymentSource.applePayDescription.monthly":"commerce.paymentSource.applePayDescription.annual")),children:e})]})},z=e=>{let{isProviderReady:t}=(0,i.Wh)();return t?null:e.children},f=e=>{let{isProviderReady:t}=(0,i.Wh)();return t?(0,o.tZ)(o.HY,{children:e.children}):null},v=e=>{let{children:t,...r}=e;return(0,o.BX)(Z,{...r,children:[(0,o.tZ)(z,{children:(0,o.tZ)(h.Flex,{direction:"row",align:"center",justify:"center",sx:e=>({width:"100%",minHeight:e.sizes.$60}),children:(0,o.tZ)(h.Spinner,{size:"lg",colorScheme:"primary",elementDescriptor:h.descriptors.spinner})})}),(0,o.tZ)(f,{children:(0,o.tZ)(w,{children:t})})]})},B=(e,t)=>{(0,a.useRef)(()=>{t(e)}),(0,a.useEffect)(()=>{t(e)},[e,t])},T=({text:e})=>{let{setHeaderTitle:t}=$();return B(e,t),null},A=({text:e})=>{let{setHeaderSubtitle:t}=$();return B(e,t),null},P=({text:e})=>{let{setSubmitLabel:t}=$();return B(e,t),null},w=({children:e})=>{let{headerTitle:t,headerSubtitle:r,submitLabel:a,checkout:p,onSuccess:y,cancelAction:g}=$(),b=(0,l.useCardState)(),x=(0,m.useSubscriberTypeLocalizationRoot)(),{isFormReady:Z,submit:z,reset:f}=(0,i.Wh)(),v=async e=>{e.preventDefault(),b.setLoading(),b.setError(void 0);let{data:t,error:r}=await z();if(!r)try{await y(t)}catch(e){(0,u.S3)(e,[],b.setError)}finally{b.setIdle(),f()}};return(0,o.tZ)(d.Y,{headerTitle:t,headerSubtitle:r,children:(0,o.BX)(c.l.Root,{onSubmit:v,sx:e=>({display:"flex",flexDirection:"column",rowGap:e.space.$3}),children:[e,(0,o.tZ)(i.Y7,{fallback:(0,o.tZ)(S,{})}),(0,o.tZ)(n.Z.Alert,{children:b.error}),(0,o.tZ)(s.A,{isDisabled:!Z,submitLabel:a??(0,h.localizationKeys)(`${x}.billingPage.paymentSourcesSection.formButtonPrimary__add`),onReset:g,hideReset:!g,sx:{flex:p?1:void 0}})]})})}},7106:function(e,t,r){r.d(t,{j:()=>n});var o=r(9109),i=r(4204),a=r(4174);let n=({paymentSource:e})=>(0,o.BX)(i.Flex,{sx:{overflow:"hidden"},gap:2,align:"baseline",elementDescriptor:i.descriptors.paymentSourceRow,children:[(0,o.tZ)(i.Icon,{icon:"card"===e.paymentMethod?a.aB:a.Nn,sx:{alignSelf:"center"},elementDescriptor:i.descriptors.paymentSourceRowIcon}),(0,o.tZ)(i.Text,{sx:e=>({color:e.colors.$colorForeground,textTransform:"capitalize"}),truncate:!0,elementDescriptor:i.descriptors.paymentSourceRowType,children:"card"===e.paymentMethod?e.cardType:e.paymentMethod}),(0,o.tZ)(i.Text,{sx:e=>({color:e.colors.$colorMutedForeground}),variant:"caption",truncate:!0,elementDescriptor:i.descriptors.paymentSourceRowValue,children:"card"===e.paymentMethod?`\u{22EF} ${e.last4}`:null}),e.isDefault&&(0,o.tZ)(i.Badge,{elementDescriptor:i.descriptors.paymentSourceRowBadge,elementId:i.descriptors.paymentSourceRowBadge.setId("default"),localizationKey:(0,i.localizationKeys)("badge__default")}),"expired"===e.status&&(0,o.tZ)(i.Badge,{elementDescriptor:i.descriptors.paymentSourceRowBadge,elementId:i.descriptors.paymentSourceRowBadge.setId("expired"),colorScheme:"danger",localizationKey:(0,i.localizationKeys)("badge__expired")})]})},6054:function(e,t,r){r.d(t,{Hw:()=>f});var o=r(5058),i=r(9109),a=r(3799),n=r(9144),l=r(2672),c=r(8104),s=r(9655),d=r(3009),p=r(8870),u=r(8969),m=r(2189),h=r(1576),y=r(4204),g=r(9805),b=r(4709),S=r(7106),x=r(8e3);let $=()=>{let{t:e}=(0,y.useLocalizations)();return(0,i.BX)(y.Box,{sx:e=>({background:e.colors.$neutralAlpha50,padding:e.space.$2x5,borderRadius:e.radii.$md,borderWidth:e.borderWidths.$normal,borderStyle:e.borderStyles.$solid,borderColor:e.colors.$borderAlpha100,display:"flex",flexDirection:"column",rowGap:e.space.$2,position:"relative"}),children:[(0,i.tZ)(y.Box,{sx:e=>({position:"absolute",inset:0,background:`repeating-linear-gradient(-45deg,${e.colors.$warningAlpha100},${e.colors.$warningAlpha100} 6px,${e.colors.$warningAlpha150} 6px,${e.colors.$warningAlpha150} 12px)`,maskImage:"linear-gradient(transparent 20%, black)",pointerEvents:"none"})}),(0,i.BX)(y.Box,{sx:{display:"flex",alignItems:"baseline",justifyContent:"space-between"},children:[(0,i.tZ)(y.Text,{variant:"caption",colorScheme:"body",localizationKey:(0,y.localizationKeys)("commerce.paymentSource.dev.testCardInfo")}),(0,i.tZ)(y.Text,{variant:"caption",sx:e=>({color:e.colors.$warning500,fontWeight:e.fontWeights.$semibold}),localizationKey:(0,y.localizationKeys)("commerce.paymentSource.dev.developmentMode")})]}),(0,i.BX)(x.a.Root,{children:[(0,i.BX)(x.a.Group,{variant:"tertiary",children:[(0,i.tZ)(x.a.Title,{title:(0,y.localizationKeys)("commerce.paymentSource.dev.cardNumber")}),(0,i.tZ)(x.a.Description,{text:"4242 4242 4242 4242"})]}),(0,i.BX)(x.a.Group,{variant:"tertiary",children:[(0,i.tZ)(x.a.Title,{title:(0,y.localizationKeys)("commerce.paymentSource.dev.expirationDate")}),(0,i.tZ)(x.a.Description,{text:"11/44"})]}),(0,i.BX)(x.a.Group,{variant:"tertiary",children:[(0,i.tZ)(x.a.Title,{title:(0,y.localizationKeys)("commerce.paymentSource.dev.cvcZip")}),(0,i.tZ)(x.a.Description,{text:e((0,y.localizationKeys)("commerce.paymentSource.dev.anyNumbers"))})]})]})]})},Z=(0,l.withCardStateProvider)(({onSuccess:e})=>{let{close:t}=(0,b.XC)(),r=(0,a.cL)(),n=(0,h.useSubscriberTypeContext)(),l=(0,h.useSubscriberTypeLocalizationRoot)(),c=async o=>{let i="organization"===n?r?.organization:r.user;return await i?.addPaymentSource(o),e(),t(),Promise.resolve()};return(0,i.BX)(o.fC,{onSuccess:c,cancelAction:t,children:[(0,i.tZ)(o.ph,{text:(0,y.localizationKeys)(`${l}.billingPage.paymentSourcesSection.add`)}),(0,i.tZ)(o.hG,{text:(0,y.localizationKeys)(`${l}.billingPage.paymentSourcesSection.addSubtitle`)}),(0,i.tZ)(m.P,{children:(0,i.tZ)($,{})})]})}),z=({paymentSource:e,revalidate:t})=>{let{close:r}=(0,b.XC)(),o=(0,l.useCardState)(),c=(0,h.useSubscriberTypeContext)(),{organization:s}=(0,a.o8)(),d=(0,h.useSubscriberTypeLocalizationRoot)(),m=(0,n.useRef)(`${"card"===e.paymentMethod?e.cardType:e.paymentMethod} ${"card"===e.paymentMethod?`\u{22EF} ${e.last4}`:"-"}`);if(!m.current)return null;let g=async()=>{await e.remove({orgId:"organization"===c?s?.id:void 0}).then(t).catch(e=>{(0,p.S3)(e,[],o.setError)})};return(0,i.tZ)(u.LE,{title:(0,y.localizationKeys)(`${d}.billingPage.paymentSourcesSection.removeResource.title`),messageLine1:(0,y.localizationKeys)(`${d}.billingPage.paymentSourcesSection.removeResource.messageLine1`,{identifier:m.current}),messageLine2:(0,y.localizationKeys)(`${d}.billingPage.paymentSourcesSection.removeResource.messageLine2`),successMessage:(0,y.localizationKeys)(`${d}.billingPage.paymentSourcesSection.removeResource.successMessage`,{paymentSource:m.current}),deleteResource:g,onSuccess:r,onReset:r})},f=(0,l.withCardStateProvider)(()=>{let e=(0,a.cL)(),t=(0,h.useSubscriberTypeContext)(),r=(0,h.useSubscriberTypeLocalizationRoot)(),o="organization"===t?e?.organization:e.user,{data:l,isLoading:d,revalidate:p}=(0,h.usePaymentMethods)(),u=(0,n.useMemo)(()=>l.sort((e,t)=>e.isDefault&&!t.isDefault?-1:1),[l]);return o?(0,i.tZ)(s.zd.Root,{title:(0,y.localizationKeys)(`${r}.billingPage.paymentSourcesSection.title`),centered:!1,id:"paymentSources",sx:e=>({flex:1,borderTopWidth:e.borderWidths.$normal,borderTopStyle:e.borderStyles.$solid,borderTopColor:e.colors.$borderAlpha100}),children:(0,i.tZ)(g.a.Root,{children:(0,i.tZ)(s.zd.ItemList,{id:"paymentSources",disableAnimation:!0,children:d?(0,i.tZ)(c.m,{}):(0,i.BX)(i.HY,{children:[u.map(e=>(0,i.BX)(n.Fragment,{children:[(0,i.BX)(s.zd.Item,{id:"paymentSources",children:[(0,i.tZ)(S.j,{paymentSource:e}),(0,i.tZ)(v,{paymentSource:e,revalidate:p})]}),(0,i.tZ)(g.a.Open,{value:`remove-${e.id}`,children:(0,i.tZ)(g.a.Card,{variant:"destructive",children:(0,i.tZ)(z,{paymentSource:e,revalidate:p})})})]},e.id)),(0,i.tZ)(g.a.Trigger,{value:"add",children:(0,i.tZ)(s.zd.ArrowButton,{id:"paymentSources",localizationKey:(0,y.localizationKeys)(`${r}.billingPage.paymentSourcesSection.add`)})}),(0,i.tZ)(g.a.Open,{value:"add",children:(0,i.tZ)(g.a.Card,{children:(0,i.tZ)(Z,{onSuccess:p})})})]})})})}):null}),v=({paymentSource:e,revalidate:t})=>{let{open:r}=(0,b.XC)(),o=(0,l.useCardState)(),{organization:n}=(0,a.o8)(),c=(0,h.useSubscriberTypeContext)(),s=(0,h.useSubscriberTypeLocalizationRoot)(),u=[{label:(0,y.localizationKeys)(`${s}.billingPage.paymentSourcesSection.actionLabel__remove`),isDestructive:!0,onClick:()=>r(`remove-${e.id}`),isDisabled:!e.isRemovable}];return e.isDefault||u.unshift({label:(0,y.localizationKeys)(`${s}.billingPage.paymentSourcesSection.actionLabel__default`),isDestructive:!1,onClick:()=>{e.makeDefault({orgId:"organization"===c?n?.id:void 0}).then(t).catch(e=>{(0,p.S3)(e,[],o.setError)})},isDisabled:!1}),(0,i.tZ)(d.a,{actions:u})}},5746:function(e,t,r){r.d(t,{u:()=>l});var o=r(9109),i=r(4204);let a={active:"badge__activePlan",upcoming:"badge__upcomingPlan",past_due:"badge__pastDuePlan"},n={active:"secondary",upcoming:"primary",past_due:"warning"},l=({subscription:e,elementDescriptor:t})=>(0,o.tZ)(i.Badge,{elementDescriptor:t,colorScheme:n[e.status],localizationKey:(0,i.localizationKeys)(a[e.status])})},1800:function(e,t,r){r.d(t,{b:()=>u});var o=r(9109),i=r(9144),a=r(9655),n=r(8969),l=r(1576),c=r(4204),s=r(4174),d=r(4676),p=r(5746);function u({title:e,arrowButtonText:t,arrowButtonEmptyText:r}){let{captionForSubscription:u,openSubscriptionDetails:m}=(0,l.usePlansContext)(),h=(0,l.useSubscriberTypeLocalizationRoot)(),y=(0,l.useSubscriberTypeContext)(),{subscriptionItems:g}=(0,l.useSubscription)(),b=(0,n.N2)(e=>e({permission:"org:sys_billing:manage"})||"user"===y),{navigate:S}=(0,d.useRouter)(),{commerceSettings:x}=(0,l.useEnvironment)(),$=(0,i.useMemo)(()=>g.sort((e,t)=>"active"===e.status&&"active"!==t.status?-1:("active"===t.status&&e.status,1)),[g]);return(0,o.BX)(a.zd.Root,{id:"subscriptionsList",title:e,centered:!1,sx:e=>({borderTop:"none",paddingTop:e.space.$1}),children:[g.length>0&&(0,o.BX)(c.Table,{tableHeadVisuallyHidden:!0,children:[(0,o.tZ)(c.Thead,{children:(0,o.BX)(c.Tr,{children:[(0,o.tZ)(c.Th,{localizationKey:(0,c.localizationKeys)(`${h}.billingPage.subscriptionsListSection.tableHeader__plan`)}),(0,o.tZ)(c.Th,{localizationKey:(0,c.localizationKeys)(`${h}.billingPage.subscriptionsListSection.tableHeader__startDate`)}),(0,o.tZ)(c.Th,{localizationKey:(0,c.localizationKeys)(`${h}.billingPage.subscriptionsListSection.tableHeader__edit`)})]})}),(0,o.tZ)(c.Tbody,{children:$.map(e=>(0,o.BX)(c.Tr,{children:[(0,o.tZ)(c.Td,{children:(0,o.BX)(c.Col,{gap:1,children:[(0,o.BX)(c.Flex,{align:"center",gap:1,children:[(0,o.tZ)(c.Icon,{icon:s.ou,sx:e=>({width:e.sizes.$4,height:e.sizes.$4,opacity:e.opacity.$inactive})}),(0,o.tZ)(c.Text,{variant:"subtitle",sx:e=>({marginRight:e.sizes.$1}),children:e.plan.name}),$.length>1||e.canceledAtDate?(0,o.tZ)(p.u,{subscription:e}):null]}),(!e.plan.isDefault||"upcoming"===e.status)&&(0,o.tZ)(c.Text,{variant:"caption",colorScheme:"secondary",localizationKey:u(e)})]})}),(0,o.tZ)(c.Td,{sx:e=>({textAlign:"right"}),children:(0,o.BX)(c.Text,{variant:"subtitle",children:[e.plan.currencySymbol,"annual"===e.planPeriod?e.plan.annualAmountFormatted:e.plan.amountFormatted,(e.plan.amount>0||e.plan.annualAmount>0)&&(0,o.tZ)(c.Span,{sx:e=>({color:e.colors.$colorMutedForeground,textTransform:"lowercase",":before":{content:'"/"',marginInline:e.space.$1}}),localizationKey:"annual"===e.planPeriod?(0,c.localizationKeys)("commerce.year"):(0,c.localizationKeys)("commerce.month")})]})}),(0,o.tZ)(c.Td,{sx:e=>({textAlign:"right"}),children:(0,o.tZ)(c.Button,{"aria-label":"Manage subscription",onClick:e=>m(e),variant:"bordered",colorScheme:"secondary",isDisabled:!b,sx:e=>({width:e.sizes.$6,height:e.sizes.$6}),children:(0,o.tZ)(c.Icon,{icon:s.tc,sx:e=>({width:e.sizes.$4,height:e.sizes.$4,opacity:e.opacity.$inactive})})})})]},e.id))})]}),x.billing.user.hasPaidPlans&&"user"===y||x.billing.organization.hasPaidPlans&&"organization"===y?(0,o.tZ)(a.zd.ArrowButton,{id:"subscriptionsList",textLocalizationKey:g.length>0?t:r,sx:[e=>({justifyContent:"start",height:e.sizes.$8})],leftIcon:g.length>0?s.Ic:s.v3,leftIconSx:e=>({width:e.sizes.$4,height:e.sizes.$4}),onClick:()=>void S("plans")}):null]})}}}]);