import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Mi as s,ki as a}from"./vendor-frame-CwiylG4Y.js";import{kt as t,yt as r}from"./shared-1-3-6x7RKF.js";import{a as d}from"./shared-6-Cf_fMhRZ.js";import{L as n,nn as i}from"./vendor-all-2-BJdkbLSj.js";import{$ as l}from"./shared-frame-DbQbH4Yr.js";import{i as o,n as c}from"./c184b2ab0-Ev4Zvq-y.js";import{t as m}from"./cdfe1762a-E-DmkQ2f.js";import{ts as h}from"./shared-5-UQAFGbWu.js";var x=e(s()),f=a();function p(){const{data:e}=r(),{isBankTransferSubscription:s}=t();return!(!s||!e)||!!e&&"bank_transfer"!==e.type}function b({selectedPaymentMethodType:e,onPaymentMethodTypeChange:s,onPaymentMethodUpdated:a,onEditPaymentMethod:p,linkPassthrough:b=!1}){const[j,u]=(0,x.useState)(!1),g=p??(()=>u(!0)),{data:y,refetch:k}=r(),{isBankTransferSubscription:v}=t(),N=y&&"bank_transfer"!==y.type;return v&&s?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(d,{value:e??"bank_transfer",onValueChange:e=>s(e),children:[(0,f.jsx)(n,{value:"bank_transfer",asChild:!0,children:(0,f.jsx)("div",{className:"group flex items-center gap-4 p-4 border rounded-lg cursor-pointer "+("bank_transfer"===e?"border-accent-100 bg-accent-900":"border-border-300"),onClick:()=>s("bank_transfer"),children:(0,f.jsxs)("div",{className:"flex items-start gap-4 flex-1",children:[(0,f.jsxs)("div",{className:"shrink-0 relative h-4 w-4 mt-1",children:[(0,f.jsx)("div",{className:"bg-bg-000 absolute left-0 top-0 rounded-full h-full w-full shadow-inset-border-0.5 shadow-border-100 group-data-[state=checked]:shadow-inset-border group-data-[state=checked]:shadow-accent-000"}),(0,f.jsx)("div",{className:"hidden group-data-[state=checked]:block bg-accent-100 absolute left-1 top-1 rounded-full h-2 w-2"})]}),(0,f.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)(m,{size:18,className:"text-text-200"}),(0,f.jsx)("span",{className:"font-base-bold text-text-100",children:(0,f.jsx)(i,{defaultMessage:"Bank transfer",id:"mtIIl7P3WD"})})]}),(0,f.jsx)("span",{className:"text-sm text-text-300",children:(0,f.jsx)(i,{defaultMessage:"An invoice will be created. Credits are added once payment is received.",id:"UPgjLVlMiA"})})]})]})})}),(0,f.jsx)(n,{value:"card",asChild:!0,children:(0,f.jsx)("div",{className:"group flex items-center gap-4 p-4 border rounded-lg cursor-pointer "+("card"===e?"border-accent-100 bg-accent-900":"border-border-300"),onClick:()=>s("card"),children:(0,f.jsxs)("div",{className:"flex items-start gap-4 flex-1",children:[(0,f.jsxs)("div",{className:"shrink-0 relative h-4 w-4 mt-1",children:[(0,f.jsx)("div",{className:"bg-bg-000 absolute left-0 top-0 rounded-full h-full w-full shadow-inset-border-0.5 shadow-border-100 group-data-[state=checked]:shadow-inset-border group-data-[state=checked]:shadow-accent-000"}),(0,f.jsx)("div",{className:"hidden group-data-[state=checked]:block bg-accent-100 absolute left-1 top-1 rounded-full h-2 w-2"})]}),(0,f.jsxs)("div",{className:"flex flex-col gap-0.5 flex-1",children:[(0,f.jsxs)("div",{className:"flex items-center justify-between",children:[(0,f.jsx)("span",{className:"font-base-bold text-text-100",children:(0,f.jsx)(i,{defaultMessage:"Credit or debit card",id:"f7+XwrgWh2"})}),N&&(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[(0,f.jsx)(o,{type:y.type,brand:y.brand,last4:y.last4}),(0,f.jsx)(h,{variant:"ghost",iconOnly:!0,size:"sm",icon:(0,f.jsx)(l,{name:"Edit",size:"sm"}),"aria-label":"Edit payment method",onClick:e=>{e.stopPropagation(),g()}})]})]}),!N&&(0,f.jsx)(h,{variant:"secondary",size:"sm",className:"mt-1 w-fit",onClick:e=>{e.stopPropagation(),s("card"),g()},children:(0,f.jsx)(i,{defaultMessage:"Add a card",id:"oLpiKzY7N/"})})]})]})})})]}),(0,f.jsx)(c,{isOpen:j,linkPassthrough:b,onClose:()=>u(!1),onPaymentMethodUpdated:()=>{k(),a?.(),u(!1)}})]}):(0,f.jsxs)(f.Fragment,{children:[y&&"bank_transfer"!==y.type?(0,f.jsxs)("div",{className:"flex items-center justify-between rounded-card border bg-surface-1 px-lg py-md",children:[(0,f.jsx)("span",{className:"text-body font-medium text-primary",children:(0,f.jsx)(i,{defaultMessage:"Payment method",id:"BVTni9A2ca"})}),(0,f.jsxs)("div",{className:"flex items-center gap-3",children:[(0,f.jsx)(o,{type:y.type,brand:y.brand,last4:y.last4}),(0,f.jsx)(h,{variant:"ghost",iconOnly:!0,size:"sm",icon:(0,f.jsx)(l,{name:"Edit",size:"sm"}),"aria-label":"Edit payment method",onClick:g})]})]}):(0,f.jsxs)("div",{className:"flex items-center justify-between rounded-card border bg-surface-1 px-lg py-md",children:[(0,f.jsx)("span",{className:"text-body font-medium text-primary",children:(0,f.jsx)(i,{defaultMessage:"Payment method",id:"BVTni9A2ca"})}),(0,f.jsx)(h,{variant:"secondary",onClick:g,children:(0,f.jsx)(i,{defaultMessage:"Add payment method",id:"+EIsonKmCI"})})]}),!p&&(0,f.jsx)(c,{isOpen:j,linkPassthrough:b,onClose:()=>u(!1),onPaymentMethodUpdated:()=>{k(),a?.(),u(!1)}})]})}export{p as n,b as t};