{"version":3,"sources":["../src/web/components/CheckoutButton.tsx","../src/shared/providers/PaymentsProvider.tsx","../src/hooks/usePayments.ts","../src/shared/types/errors.ts","../src/providers/base/index.ts","../src/providers/stripe/index.ts","../src/providers/mock/index.ts","../src/providers/index.ts","../src/shared/constants.ts","../src/shared/utils/validation.ts","../src/shared/utils/formatting.ts","../src/web/components/PricingTable.tsx","../src/web/components/PaymentForm.tsx","../src/web/components/BillingPortal.tsx","../src/web/components/SubscriptionPlans.tsx","../src/web/components/SubscriptionManager.tsx","../src/web/components/SubscriptionCard.tsx","../src/web/components/BillingHistory.tsx","../src/web/components/PaymentMethods.tsx","../src/web/providers/StripeProvider.tsx","../src/shared/hooks/usePayments.ts","../src/web/hooks/useSubscription.ts","../src/web/hooks/useCheckout.ts","../src/web/hooks/useCustomer.ts","../src/web/utils/stripe-web.ts"],"sourcesContent":["import React, { useState } from 'react';\nimport { useStripe } from '@stripe/react-stripe-js';\nimport { usePaymentsContext } from '../../shared/providers/PaymentsProvider';\nimport { ERROR_MESSAGES } from '../../shared/constants';\nimport { validateStripeId } from '../../shared/utils/validation';\n\ninterface CheckoutButtonProps {\n  priceId: string;\n  customerId?: string;\n  customerEmail?: string;\n  successUrl?: string;\n  cancelUrl?: string;\n  children: React.ReactNode;\n  className?: string;\n  disabled?: boolean;\n  allowPromotionCodes?: boolean;\n  billingAddressCollection?: 'auto' | 'required';\n  metadata?: Record<string, string>;\n  trialPeriodDays?: number;\n  onSuccess?: () => void;\n  onError?: (error: string) => void;\n  onLoading?: (loading: boolean) => void;\n}\n\nexport const CheckoutButton: React.FC<CheckoutButtonProps> = ({\n  priceId,\n  customerId,\n  customerEmail,\n  successUrl = typeof window !== 'undefined'\n    ? `${window.location.origin}/success`\n    : '/success',\n  cancelUrl = typeof window !== 'undefined'\n    ? `${window.location.origin}/cancel`\n    : '/cancel',\n  children,\n  className = '',\n  disabled = false,\n  allowPromotionCodes = true,\n  billingAddressCollection = 'auto',\n  metadata,\n  trialPeriodDays,\n  onSuccess,\n  onError,\n  onLoading,\n}) => {\n  const stripe = useStripe();\n  const { initialized } = usePaymentsContext();\n  const [loading, setLoading] = useState(false);\n\n  const handleCheckout = async () => {\n    if (!stripe) {\n      const error = ERROR_MESSAGES.STRIPE_NOT_LOADED;\n      onError?.(error);\n      console.error(error);\n      return;\n    }\n\n    if (!initialized) {\n      const error = ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED;\n      onError?.(error);\n      console.error(error);\n      return;\n    }\n\n    if (!validateStripeId(priceId, 'price')) {\n      const error = ERROR_MESSAGES.INVALID_PRICE_ID;\n      onError?.(error);\n      console.error(error);\n      return;\n    }\n\n    if (customerId && !validateStripeId(customerId, 'customer')) {\n      const error = ERROR_MESSAGES.INVALID_CUSTOMER_ID;\n      onError?.(error);\n      console.error(error);\n      return;\n    }\n\n    setLoading(true);\n    onLoading?.(true);\n\n    try {\n      const response = await fetch('/api/payments/create-checkout-session', {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/json',\n        },\n        body: JSON.stringify({\n          priceId,\n          customerId,\n          customerEmail,\n          successUrl,\n          cancelUrl,\n          allowPromotionCodes,\n          billingAddressCollection,\n          metadata,\n          trialPeriodDays,\n        }),\n      });\n\n      if (!response.ok) {\n        const errorData = await response\n          .json()\n          .catch(() => ({ error: 'Network error' }));\n        throw new Error(errorData.error || ERROR_MESSAGES.CHECKOUT_FAILED);\n      }\n\n      const { sessionId } = await response.json();\n\n      if (!sessionId) {\n        throw new Error('No session ID returned from server');\n      }\n\n      const result = await stripe.redirectToCheckout({ sessionId });\n\n      if (result.error) {\n        throw new Error(result.error.message || ERROR_MESSAGES.CHECKOUT_FAILED);\n      }\n\n      onSuccess?.();\n    } catch (error) {\n      const errorMessage =\n        error instanceof Error ? error.message : ERROR_MESSAGES.CHECKOUT_FAILED;\n      onError?.(errorMessage);\n      console.error('Checkout error:', error);\n    } finally {\n      setLoading(false);\n      onLoading?.(false);\n    }\n  };\n\n  const isDisabled = !stripe || loading || disabled || !initialized;\n\n  return (\n    <button\n      onClick={handleCheckout}\n      disabled={isDisabled}\n      className={`\n        inline-flex items-center justify-center px-4 py-2 \n        border border-transparent text-sm font-medium rounded-md \n        text-white bg-blue-600 hover:bg-blue-700 \n        focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500\n        disabled:opacity-50 disabled:cursor-not-allowed\n        transition-colors duration-200\n        ${className}\n      `}\n      aria-label={typeof children === 'string' ? children : 'Checkout'}\n    >\n      {loading ? (\n        <>\n          <svg\n            className=\"animate-spin -ml-1 mr-3 h-4 w-4 text-white\"\n            xmlns=\"http://www.w3.org/2000/svg\"\n            fill=\"none\"\n            viewBox=\"0 0 24 24\"\n          >\n            <circle\n              className=\"opacity-25\"\n              cx=\"12\"\n              cy=\"12\"\n              r=\"10\"\n              stroke=\"currentColor\"\n              strokeWidth=\"4\"\n            ></circle>\n            <path\n              className=\"opacity-75\"\n              fill=\"currentColor\"\n              d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n            ></path>\n          </svg>\n          Processing...\n        </>\n      ) : (\n        children\n      )}\n    </button>\n  );\n};\n\nexport default CheckoutButton;\n","import React, { useEffect, createContext, useContext, useRef } from 'react';\nimport { usePayments } from '../../hooks/usePayments';\nimport { PaymentsConfig } from '../types/config';\nimport { PaymentEvent } from '../types/events';\nimport { PaymentError } from '../types/errors';\n\nimport { Customer, CustomerCreateParams } from '../types/customer';\nimport {\n  Subscription,\n  SubscriptionUpdateParams,\n  SubscriptionStatus,\n} from '../types/subscription';\nimport { CheckoutParams, CheckoutSession } from '../types/checkout';\n\ninterface PaymentsContextType {\n  config: PaymentsConfig | null;\n  initialized: boolean;\n  loading: boolean;\n  error: PaymentError | null;\n  customer: Customer | null;\n  subscriptions: Subscription[];\n  activeSubscription: Subscription | null;\n  createCustomer: (params: CustomerCreateParams) => Promise<Customer>;\n  createCheckoutSession: (params: CheckoutParams) => Promise<CheckoutSession>;\n  cancelSubscription: (subscriptionId: string) => Promise<void>;\n  reactivateSubscription: (subscriptionId: string) => Promise<void>;\n  updateSubscription: (\n    subscriptionId: string,\n    params: SubscriptionUpdateParams\n  ) => Promise<Subscription>;\n  refreshCustomer: (customerId: string) => Promise<void>;\n  refreshSubscriptions: (\n    customerId: string,\n    status?: SubscriptionStatus\n  ) => Promise<void>;\n  reset: () => void;\n}\n\nconst PaymentsContext = createContext<PaymentsContextType | undefined>(\n  undefined\n);\n\ninterface PaymentsProviderProps {\n  children: React.ReactNode;\n  config?: PaymentsConfig;\n  onPaymentSuccess?: (event: PaymentEvent) => void;\n  onPaymentError?: (error: PaymentError) => void;\n}\n\nexport const PaymentsProvider: React.FC<PaymentsProviderProps> = ({\n  children,\n  config,\n  onPaymentSuccess,\n  onPaymentError,\n}) => {\n  const store = usePayments();\n  const {\n    initialize,\n    initialized,\n    loading,\n    error,\n    customer,\n    subscriptions,\n    activeSubscription,\n  } = store;\n\n  const onPaymentSuccessRef = useRef(onPaymentSuccess);\n  const onPaymentErrorRef = useRef(onPaymentError);\n\n  useEffect(() => {\n    onPaymentSuccessRef.current = onPaymentSuccess;\n  }, [onPaymentSuccess]);\n\n  useEffect(() => {\n    onPaymentErrorRef.current = onPaymentError;\n  }, [onPaymentError]);\n\n  useEffect(() => {\n    if (!initialized && !loading && !error) {\n      initialize(config).catch(err => {\n        console.error('PaymentsProvider initialization failed:', err);\n        if (onPaymentErrorRef.current) {\n          onPaymentErrorRef.current(err);\n        }\n      });\n    }\n  }, [initialized, loading, error, config, initialize]);\n\n  const contextValue: PaymentsContextType = {\n    config: store.config,\n    initialized,\n    loading,\n    error,\n    customer,\n    subscriptions,\n    activeSubscription,\n    createCustomer: store.createCustomer,\n    createCheckoutSession: store.createCheckoutSession,\n    cancelSubscription: store.cancelSubscription,\n    reactivateSubscription: store.reactivateSubscription,\n    updateSubscription: store.updateSubscription,\n    refreshCustomer: store.refreshCustomer,\n    refreshSubscriptions: store.refreshSubscriptions,\n    reset: store.reset,\n  };\n\n  return (\n    <PaymentsContext.Provider value={contextValue}>\n      {children}\n    </PaymentsContext.Provider>\n  );\n};\n\nexport const usePaymentsContext = () => {\n  const context = useContext(PaymentsContext);\n  if (context === undefined) {\n    throw new Error(\n      'usePaymentsContext must be used within a PaymentsProvider'\n    );\n  }\n  return context;\n};\n","import { create } from 'zustand';\nimport { immer } from 'zustand/middleware/immer';\nimport { PaymentsStore, PaymentsProviderState } from '../shared/types/provider';\nimport { PaymentsConfig } from '../shared/types/config';\nimport { PaymentErrorType, PaymentsError } from '../shared/types/errors';\nimport { Customer, CustomerCreateParams } from '../shared/types/customer';\nimport {\n  Subscription,\n  SubscriptionCreateParams,\n  SubscriptionUpdateParams,\n  SubscriptionStatus,\n} from '../shared/types/subscription';\nimport { CheckoutParams, CheckoutSession } from '../shared/types/checkout';\nimport { PaymentProviderFactory } from '../providers';\nimport { PaymentProvider } from '../shared/types/provider';\n\nconst initialState: PaymentsProviderState = {\n  customer: null,\n  subscriptions: [],\n  activeSubscription: null,\n  loading: false,\n  error: null,\n  initialized: false,\n  config: null, // Add config to the state\n  // Backward compatibility getters (will be computed)\n  isLoading: false,\n  isError: false,\n};\n\nexport const usePayments = create<PaymentsStore>()(\n  immer((set, get) => ({\n    ...initialState,\n\n    // Override getters to always return computed values\n    get isLoading() {\n      return get().loading;\n    },\n    get isError() {\n      return !!get().error;\n    },\n\n    initialize: async (config?: PaymentsConfig) => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        let resolvedConfig: PaymentsConfig;\n        if (config) {\n          resolvedConfig = config;\n        } else {\n          resolvedConfig = PaymentProviderFactory.autodetect();\n        }\n\n        const provider: PaymentProvider =\n          PaymentProviderFactory.create(resolvedConfig);\n        await provider.initialize();\n\n        set((state: PaymentsProviderState) => {\n          state.initialized = true;\n          state.loading = false;\n          state.config = resolvedConfig; // Store the resolved config in the state\n        });\n      } catch (error: unknown) {\n        set(state => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to initialize payments provider.';\n          state.error = new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    createCustomer: async (params: CustomerCreateParams): Promise<Customer> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const customer = await provider.createCustomer(params);\n        set((state: PaymentsProviderState) => {\n          state.customer = customer;\n          state.loading = false;\n        });\n        return customer;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to create customer.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    retrieveCustomer: async (customerId: string): Promise<Customer | null> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const customer = await provider.retrieveCustomer(customerId);\n        set((state: PaymentsProviderState) => {\n          state.customer = customer;\n          state.loading = false;\n        });\n        return customer;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to retrieve customer.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    createCheckoutSession: async (\n      params: CheckoutParams\n    ): Promise<CheckoutSession> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const session = await provider.createCheckoutSession(params);\n        set((state: PaymentsProviderState) => {\n          state.loading = false;\n        });\n        return session;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to create checkout session.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    retrieveCheckoutSession: async (\n      sessionId: string\n    ): Promise<CheckoutSession> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const session = await provider.retrieveCheckoutSession(sessionId);\n        set((state: PaymentsProviderState) => {\n          state.loading = false;\n        });\n        return session;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to retrieve checkout session.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    createSubscription: async (\n      params: SubscriptionCreateParams\n    ): Promise<Subscription> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const newSubscription = await provider.createSubscription(params);\n        await get().refreshSubscriptions(get().customer?.id || '');\n        set((state: PaymentsProviderState) => {\n          state.loading = false;\n        });\n        return newSubscription;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to create subscription.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    cancelSubscription: async (subscriptionId: string): Promise<void> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        await provider.cancelSubscription(subscriptionId);\n        await get().refreshSubscriptions(get().customer?.id || '');\n        set((state: PaymentsProviderState) => {\n          state.loading = false;\n        });\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to cancel subscription.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    reactivateSubscription: async (subscriptionId: string): Promise<void> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        await provider.reactivateSubscription(subscriptionId);\n        await get().refreshSubscriptions(get().customer?.id || '');\n        set((state: PaymentsProviderState) => {\n          state.loading = false;\n        });\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to reactivate subscription.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    updateSubscription: async (\n      subscriptionId: string,\n      params: SubscriptionUpdateParams\n    ): Promise<Subscription> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const updatedSubscription = await provider.updateSubscription(\n          subscriptionId,\n          params\n        );\n        await get().refreshSubscriptions(get().customer?.id || '');\n        set((state: PaymentsProviderState) => {\n          state.loading = false;\n        });\n        return updatedSubscription;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to update subscription.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    listSubscriptions: async (\n      customerId: string,\n      status?: SubscriptionStatus\n    ): Promise<Subscription[]> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const subscriptions = await provider.listSubscriptions(\n          customerId,\n          status\n        );\n        set((state: PaymentsProviderState) => {\n          state.subscriptions = subscriptions;\n          state.loading = false;\n        });\n        return subscriptions;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to list subscriptions.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    retrieveSubscription: async (\n      subscriptionId: string\n    ): Promise<Subscription | null> => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const subscription =\n          await provider.retrieveSubscription(subscriptionId);\n        set((state: PaymentsProviderState) => {\n          state.loading = false;\n        });\n        return subscription;\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to retrieve subscription.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n        throw error;\n      }\n    },\n\n    refreshCustomer: async (customerId: string) => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const customer = await provider.retrieveCustomer(customerId);\n        set((state: PaymentsProviderState) => {\n          state.customer = customer;\n          state.loading = false;\n        });\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to refresh customer.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n      }\n    },\n\n    refreshSubscriptions: async (\n      customerId: string,\n      status?: SubscriptionStatus\n    ) => {\n      set((state: PaymentsProviderState) => {\n        state.loading = true;\n        state.error = null;\n      });\n      try {\n        if (!get().config) {\n          throw new PaymentsError(\n            PaymentErrorType.CONFIGURATION_ERROR,\n            'Payments provider not initialized. Call initialize() first.'\n          );\n        }\n        const provider = PaymentProviderFactory.create(\n          get().config as PaymentsConfig\n        );\n        const subscriptions = await provider.listSubscriptions(\n          customerId,\n          status\n        );\n        const activeSubscription =\n          subscriptions.find(\n            (sub: Subscription) =>\n              sub.status === SubscriptionStatus.ACTIVE ||\n              sub.status === SubscriptionStatus.TRIALING\n          ) || null;\n        set((state: PaymentsProviderState) => {\n          state.subscriptions = subscriptions;\n          state.activeSubscription = activeSubscription;\n          state.loading = false;\n        });\n      } catch (error: unknown) {\n        set((state: PaymentsProviderState) => {\n          const message =\n            error instanceof Error\n              ? error.message\n              : 'Failed to refresh subscriptions.';\n          state.error = new PaymentsError(\n            PaymentErrorType.NETWORK_ERROR,\n            message\n          );\n          state.loading = false;\n        });\n      }\n    },\n\n    reset: () => {\n      set((state: PaymentsProviderState) => {\n        Object.assign(state, initialState);\n      });\n    },\n  }))\n);\n","export enum PaymentErrorType {\n  CARD_DECLINED = 'CARD_DECLINED',\n  INSUFFICIENT_FUNDS = 'INSUFFICIENT_FUNDS',\n  CUSTOMER_NOT_FOUND = 'CUSTOMER_NOT_FOUND',\n  SUBSCRIPTION_NOT_FOUND = 'SUBSCRIPTION_NOT_FOUND',\n  NETWORK_ERROR = 'NETWORK_ERROR',\n  CONFIGURATION_ERROR = 'CONFIGURATION_ERROR',\n  WEBHOOK_ERROR = 'WEBHOOK_ERROR',\n  VALIDATION_ERROR = 'VALIDATION_ERROR',\n  PROVIDER_NOT_CONFIGURED = 'PROVIDER_NOT_CONFIGURED',\n  UNKNOWN_ERROR = 'UNKNOWN_ERROR',\n  INITIALIZATION_ERROR = 'INITIALIZATION_ERROR',\n  AUTHENTICATION_ERROR = 'AUTHENTICATION_ERROR',\n  NOT_FOUND = 'NOT_FOUND',\n  INVALID_REQUEST = 'INVALID_REQUEST',\n  API_ERROR = 'API_ERROR',\n  PERMISSION_DENIED = 'PERMISSION_DENIED',\n  WEBHOOK_VERIFICATION_FAILED = 'WEBHOOK_VERIFICATION_FAILED',\n}\n\nexport interface PaymentError extends Error {\n  type: PaymentErrorType;\n  code?: string;\n  details?: Record<string, unknown>;\n}\n\nexport class PaymentsError extends Error implements PaymentError {\n  public type: PaymentErrorType;\n  public code?: string;\n  public details?: Record<string, unknown>;\n\n  constructor(\n    type: PaymentErrorType,\n    message: string,\n    code?: string,\n    details?: Record<string, unknown>\n  ) {\n    super(message);\n    this.name = 'PaymentsError';\n    this.type = type;\n    this.code = code;\n    this.details = details;\n    Object.setPrototypeOf(this, PaymentsError.prototype);\n  }\n}\n","import { PaymentProvider } from '../../shared/types/provider';\nimport { PaymentsConfig } from '../../shared/types/config';\nimport { PaymentsError, PaymentErrorType } from '../../shared/types/errors';\nimport { CheckoutParams, CheckoutSession } from '../../shared/types/checkout';\nimport { Customer, CustomerCreateParams } from '../../shared/types/customer';\nimport {\n  Subscription,\n  SubscriptionCreateParams,\n  SubscriptionUpdateParams,\n  SubscriptionStatus,\n} from '../../shared/types/subscription';\n\nexport abstract class BasePaymentProvider implements PaymentProvider {\n  public abstract name: string;\n  protected config: PaymentsConfig;\n\n  constructor(config: PaymentsConfig) {\n    this.config = config;\n  }\n\n  public abstract initialize(): Promise<void>;\n  public abstract createCheckoutSession(\n    params: CheckoutParams\n  ): Promise<CheckoutSession>;\n  public abstract retrieveCheckoutSession(\n    sessionId: string\n  ): Promise<CheckoutSession>;\n  public abstract createCustomer(\n    params: CustomerCreateParams\n  ): Promise<Customer>;\n  public abstract retrieveCustomer(\n    customerId: string\n  ): Promise<Customer | null>;\n  public abstract createSubscription(\n    params: SubscriptionCreateParams\n  ): Promise<Subscription>;\n  public abstract cancelSubscription(subscriptionId: string): Promise<void>;\n  public abstract reactivateSubscription(subscriptionId: string): Promise<void>;\n  public abstract listSubscriptions(\n    customerId: string,\n    status?: SubscriptionStatus\n  ): Promise<Subscription[]>;\n  public abstract retrieveSubscription(\n    subscriptionId: string\n  ): Promise<Subscription | null>;\n  public abstract updateSubscription(\n    subscriptionId: string,\n    params: SubscriptionUpdateParams\n  ): Promise<Subscription>;\n\n  protected handleError(\n    error: unknown,\n    type: PaymentErrorType = PaymentErrorType.UNKNOWN_ERROR\n  ): PaymentsError {\n    if (error instanceof PaymentsError) {\n      return error;\n    }\n\n    let message = 'An unknown error occurred';\n    let code: string | undefined;\n    let details: Record<string, unknown> | undefined;\n\n    if (typeof error === 'object' && error !== null) {\n      if (\n        'message' in error &&\n        typeof (error as { message: unknown }).message === 'string'\n      ) {\n        message = (error as { message: string }).message;\n      }\n      if (\n        'code' in error &&\n        typeof (error as { code: unknown }).code === 'string'\n      ) {\n        code = (error as { code: string }).code;\n      }\n      details = { ...(error as Record<string, unknown>) };\n    }\n\n    return new PaymentsError(type, message, code, details);\n  }\n}\n","import { BasePaymentProvider } from '../base';\nimport { PaymentsConfig } from '../../shared/types/config';\nimport { CheckoutParams, CheckoutSession } from '../../shared/types/checkout';\nimport { Customer, CustomerCreateParams } from '../../shared/types/customer';\nimport {\n  Subscription,\n  SubscriptionCreateParams,\n  SubscriptionUpdateParams,\n  SubscriptionStatus,\n} from '../../shared/types/subscription';\nimport { PaymentsError, PaymentErrorType } from '../../shared/types/errors';\nimport Stripe from 'stripe';\n\nexport class StripePaymentProvider extends BasePaymentProvider {\n  public name = 'stripe';\n  private stripeClient: Stripe;\n\n  constructor(config: PaymentsConfig) {\n    super(config);\n    if (!config.stripeConfig?.publishableKey) {\n      throw new PaymentsError(\n        PaymentErrorType.CONFIGURATION_ERROR,\n        'Stripe publishable key is missing in config.'\n      );\n    }\n    if (!process.env.STRIPE_SECRET_KEY) {\n      throw new PaymentsError(\n        PaymentErrorType.CONFIGURATION_ERROR,\n        'STRIPE_SECRET_KEY environment variable is not set.'\n      );\n    }\n    this.stripeClient = new Stripe(process.env.STRIPE_SECRET_KEY, {\n      apiVersion: '2025-02-24.acacia',\n    });\n  }\n\n  public async initialize(): Promise<void> {\n    // No specific client-side initialization needed for server-side Stripe operations\n\n    console.log('StripePaymentProvider initialized (server-side)');\n  }\n\n  public async createCheckoutSession(\n    params: CheckoutParams\n  ): Promise<CheckoutSession> {\n    try {\n      const session = await this.stripeClient.checkout.sessions.create({\n        payment_method_types: ['card'],\n        line_items: [\n          {\n            price: params.priceId,\n            quantity: 1,\n          },\n        ],\n        mode: params.mode || 'payment',\n        success_url:\n          params.successUrl ||\n          `${process.env.NEXT_PUBLIC_BASE_URL}/success?session_id={CHECKOUT_SESSION_ID}`,\n        cancel_url:\n          params.cancelUrl || `${process.env.NEXT_PUBLIC_BASE_URL}/cancel`,\n        customer_email: params.customerEmail,\n        allow_promotion_codes: params.allowPromotionCodes,\n        metadata: params.metadata,\n      });\n\n      if (!session.url) {\n        throw new PaymentsError(\n          PaymentErrorType.UNKNOWN_ERROR,\n          'Stripe checkout session URL is missing.'\n        );\n      }\n\n      return {\n        id: session.id,\n        url: session.url,\n        status: session.status as CheckoutSession['status'],\n        amountTotal: session.amount_total || undefined,\n        currency: session.currency || undefined,\n        customerEmail: session.customer_details?.email || undefined,\n        subscriptionId: session.subscription?.toString() || undefined,\n      };\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async createCustomer(params: CustomerCreateParams): Promise<Customer> {\n    try {\n      const customer = await this.stripeClient.customers.create({\n        email: params.email,\n        name: params.name,\n        metadata: params.metadata,\n      });\n      return {\n        id: customer.id,\n        email: customer.email || params.email,\n        name: customer.name || params.name,\n        phone: null, // Stripe API does not directly return phone for customer creation\n        stripeCustomerId: customer.id,\n        subscriptions: [], // Subscriptions are fetched separately\n        paymentMethods: [], // Payment methods are fetched separately\n        defaultPaymentMethodId: null, // Default payment method is set separately\n        metadata: customer.metadata,\n        created: new Date(customer.created * 1000),\n        updated: new Date(customer.created * 1000), // Stripe customer object doesn't have an 'updated' timestamp directly\n      };\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async retrieveCustomer(customerId: string): Promise<Customer | null> {\n    try {\n      const customer = await this.stripeClient.customers.retrieve(customerId);\n      if (customer.deleted) {\n        return null;\n      }\n      return {\n        id: customer.id,\n        email: customer.email || '',\n        name: customer.name || undefined,\n        phone: customer.phone || undefined,\n        stripeCustomerId: customer.id,\n        subscriptions: [], // Subscriptions are fetched separately\n        paymentMethods: [], // Payment methods are fetched separately\n        defaultPaymentMethodId:\n          customer.invoice_settings?.default_payment_method?.toString() ||\n          undefined,\n        metadata: customer.metadata,\n        created: new Date(customer.created * 1000),\n        updated: new Date(customer.created * 1000), // Stripe customer object doesn't have an 'updated' timestamp directly\n      };\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async createSubscription(\n    params: SubscriptionCreateParams\n  ): Promise<Subscription> {\n    try {\n      const subscription = await this.stripeClient.subscriptions.create({\n        customer: params.customerId,\n        items: (\n          params.items ||\n          (params.priceId ? [{ priceId: params.priceId, quantity: 1 }] : [])\n        ).map((item: { priceId: string; quantity?: number }) => ({\n          price: item.priceId,\n          quantity: item.quantity || 1,\n        })),\n        trial_period_days: params.trialPeriodDays,\n        metadata: params.metadata,\n        expand: ['latest_invoice.payment_intent'],\n      });\n\n      return this.mapStripeSubscriptionToSubscription(subscription);\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async cancelSubscription(subscriptionId: string): Promise<void> {\n    try {\n      await this.stripeClient.subscriptions.cancel(subscriptionId);\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async reactivateSubscription(subscriptionId: string): Promise<void> {\n    try {\n      const subscription =\n        await this.stripeClient.subscriptions.retrieve(subscriptionId);\n      if (\n        subscription.status === SubscriptionStatus.CANCELED &&\n        subscription.cancel_at_period_end\n      ) {\n        await this.stripeClient.subscriptions.update(subscriptionId, {\n          cancel_at_period_end: false,\n        });\n      } else {\n        throw new PaymentsError(\n          PaymentErrorType.VALIDATION_ERROR,\n          'Subscription cannot be reactivated.'\n        );\n      }\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async retrieveCheckoutSession(\n    sessionId: string\n  ): Promise<CheckoutSession> {\n    try {\n      const session =\n        await this.stripeClient.checkout.sessions.retrieve(sessionId);\n      if (!session.url) {\n        throw new PaymentsError(\n          PaymentErrorType.UNKNOWN_ERROR,\n          'Stripe checkout session URL is missing.'\n        );\n      }\n      return {\n        id: session.id,\n        url: session.url,\n        status: session.status as CheckoutSession['status'],\n        amountTotal: session.amount_total || undefined,\n        currency: session.currency || undefined,\n        customerEmail: session.customer_details?.email || undefined,\n        subscriptionId: session.subscription?.toString() || undefined,\n      };\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async listSubscriptions(\n    customerId: string,\n    status?: SubscriptionStatus\n  ): Promise<Subscription[]> {\n    try {\n      const subscriptions = await this.stripeClient.subscriptions.list({\n        customer: customerId,\n        status: status === SubscriptionStatus.ALL ? undefined : status,\n      });\n      return subscriptions.data.map(this.mapStripeSubscriptionToSubscription);\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async retrieveSubscription(\n    subscriptionId: string\n  ): Promise<Subscription | null> {\n    try {\n      const subscription =\n        await this.stripeClient.subscriptions.retrieve(subscriptionId);\n      return this.mapStripeSubscriptionToSubscription(subscription);\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  public async updateSubscription(\n    subscriptionId: string,\n    params: Partial<SubscriptionUpdateParams>\n  ): Promise<Subscription> {\n    try {\n      const currentSubscription =\n        await this.stripeClient.subscriptions.retrieve(subscriptionId);\n      const items = params.items\n        ? params.items.map((item: { priceId: string; quantity?: number }) => ({\n            id: currentSubscription.items.data.find(\n              i => i.price?.id === item.priceId\n            )?.id,\n            price: item.priceId,\n            quantity: item.quantity || 1,\n          }))\n        : undefined;\n\n      const subscription = await this.stripeClient.subscriptions.update(\n        subscriptionId,\n        {\n          items,\n          metadata: params.metadata,\n        }\n      );\n      return this.mapStripeSubscriptionToSubscription(subscription);\n    } catch (error: unknown) {\n      throw this.handleError(error, PaymentErrorType.NETWORK_ERROR);\n    }\n  }\n\n  private mapStripeSubscriptionToSubscription(\n    stripeSubscription: Stripe.Subscription\n  ): Subscription {\n    return {\n      id: stripeSubscription.id,\n      customerId: stripeSubscription.customer.toString(),\n      status: stripeSubscription.status as SubscriptionStatus,\n      items: stripeSubscription.items.data.map(item => ({\n        id: item.id,\n        priceId: item.price?.id || '',\n        quantity: item.quantity || 1,\n      })),\n      currentPeriodStart: new Date(\n        stripeSubscription.current_period_start * 1000\n      ),\n      currentPeriodEnd: new Date(stripeSubscription.current_period_end * 1000),\n      cancelAtPeriodEnd: stripeSubscription.cancel_at_period_end,\n      trialStart: stripeSubscription.trial_start\n        ? new Date(stripeSubscription.trial_start * 1000)\n        : undefined,\n      trialEnd: stripeSubscription.trial_end\n        ? new Date(stripeSubscription.trial_end * 1000)\n        : undefined,\n      metadata: stripeSubscription.metadata,\n      created: new Date(stripeSubscription.created * 1000),\n      updated: new Date(stripeSubscription.created * 1000), // Stripe subscription object doesn't have an 'updated' timestamp directly\n    };\n  }\n}\n","import { CheckoutParams, CheckoutSession } from '../../shared/types/checkout';\nimport {\n  Customer,\n  CustomerCreateParams,\n  PaymentMethod,\n} from '../../shared/types/customer';\nimport {\n  Subscription,\n  SubscriptionCreateParams,\n  SubscriptionUpdateParams,\n  SubscriptionStatus,\n} from '../../shared/types/subscription';\nimport { PaymentProvider } from '../../shared/types/provider';\nimport { PaymentsError, PaymentErrorType } from '../../shared/types/errors';\nimport { PaymentsConfig } from '../../shared/types/config';\nimport { BasePaymentProvider } from '../base';\n\n/**\n * A mock payment provider for testing and development purposes.\n * It simulates payment operations without actual API calls.\n */\nexport class MockPaymentProvider\n  extends BasePaymentProvider\n  implements PaymentProvider\n{\n  name = 'MockPaymentProvider';\n  private customers: Customer[] = [];\n  private subscriptions: Subscription[] = [];\n  private nextCustomerId = 1;\n  private nextSubscriptionId = 1;\n\n  constructor(config: Omit<PaymentsConfig, 'provider'>) {\n    super({ ...config, provider: 'mock' });\n\n    console.log('MockPaymentProvider initialized');\n  }\n\n  async initialize(): Promise<void> {\n    console.log('MockPaymentProvider initialized');\n  }\n\n  async createCheckoutSession(\n    params: CheckoutParams\n  ): Promise<CheckoutSession> {\n    console.log('Mock: createCheckoutSession', params);\n    return {\n      id: 'mock_cs_123',\n      clientSecret: 'mock_client_secret',\n      url: 'https://mock-checkout.example.com/success', // Changed from redirectUrl to url\n      status: 'open', // Changed from 'pending' to 'open'\n    };\n  }\n\n  async retrieveCheckoutSession(id: string): Promise<CheckoutSession> {\n    console.log('Mock: retrieveCheckoutSession', id);\n    if (id === 'mock_cs_123') {\n      return {\n        id: 'mock_cs_123',\n        clientSecret: 'mock_client_secret',\n        url: 'https://mock-checkout.example.com/success', // Changed from redirectUrl to url\n        status: 'complete',\n      };\n    }\n    throw new PaymentsError(\n      PaymentErrorType.CUSTOMER_NOT_FOUND,\n      `Mock checkout session ${id} not found`\n    );\n  }\n\n  async createCustomer(params: CustomerCreateParams): Promise<Customer> {\n    console.log('Mock: createCustomer', params);\n    const newCustomer: Customer = {\n      id: `mock_cus_${this.nextCustomerId++}`,\n      email: params.email,\n      name: params.name || null,\n      phone: params.phone || null,\n      stripeCustomerId: null,\n      subscriptions: [],\n      defaultPaymentMethodId: null,\n      paymentMethods: [], // Added paymentMethods\n      metadata: params.metadata || {},\n      created: new Date(),\n      updated: new Date(),\n    };\n    this.customers.push(newCustomer);\n    return newCustomer;\n  }\n\n  async retrieveCustomer(id: string): Promise<Customer> {\n    console.log('Mock: retrieveCustomer', id);\n    const customer = this.customers.find(c => c.id === id);\n    if (!customer) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${id} not found`\n      );\n    }\n    return customer;\n  }\n\n  async updateCustomer(\n    id: string,\n    params: CustomerCreateParams\n  ): Promise<Customer> {\n    console.log('Mock: updateCustomer', id, params);\n    const customer = this.customers.find(c => c.id === id);\n    if (!customer) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${id} not found`\n      );\n    }\n    if (params.email) customer.email = params.email;\n    if (params.name) customer.name = params.name;\n    if (params.phone) customer.phone = params.phone;\n    if (params.metadata)\n      customer.metadata = { ...customer.metadata, ...params.metadata };\n    customer.updated = new Date();\n    return customer;\n  }\n\n  async deleteCustomer(id: string): Promise<void> {\n    console.log('Mock: deleteCustomer', id);\n    const initialLength = this.customers.length;\n    this.customers = this.customers.filter(c => c.id !== id);\n    if (this.customers.length === initialLength) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${id} not found`\n      );\n    }\n  }\n\n  async listPaymentMethods(customerId: string): Promise<PaymentMethod[]> {\n    console.log('Mock: listPaymentMethods', customerId);\n    const customer = this.customers.find(c => c.id === customerId);\n    if (!customer) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${customerId} not found`\n      );\n    }\n    return customer.paymentMethods || [];\n  }\n\n  async attachPaymentMethod(\n    customerId: string,\n    paymentMethodId: string\n  ): Promise<PaymentMethod> {\n    console.log('Mock: attachPaymentMethod', customerId, paymentMethodId);\n    const customer = this.customers.find(c => c.id === customerId);\n    if (!customer) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${customerId} not found`\n      );\n    }\n    const newPaymentMethod: PaymentMethod = {\n      id: paymentMethodId,\n      type: 'card',\n      card: {\n        brand: 'visa',\n        last4: '4242',\n        expMonth: 12,\n        expYear: 2025,\n        country: 'US',\n      },\n      isDefault: false,\n      created: new Date(),\n    };\n    customer.paymentMethods.push(newPaymentMethod);\n    return newPaymentMethod;\n  }\n\n  async detachPaymentMethod(\n    customerId: string,\n    paymentMethodId: string\n  ): Promise<void> {\n    console.log('Mock: detachPaymentMethod', customerId, paymentMethodId);\n    const customer = this.customers.find(c => c.id === customerId);\n    if (!customer) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${customerId} not found`\n      );\n    }\n    const initialLength = customer.paymentMethods.length;\n    customer.paymentMethods = customer.paymentMethods.filter(\n      (pm: PaymentMethod) => pm.id !== paymentMethodId\n    );\n    if (customer.paymentMethods.length === initialLength) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock payment method ${paymentMethodId} not found for customer ${customerId}`\n      );\n    }\n  }\n\n  async createSubscription(\n    params: SubscriptionCreateParams\n  ): Promise<Subscription> {\n    console.log('Mock: createSubscription', params);\n    const customer = this.customers.find(c => c.id === params.customerId);\n    if (!customer) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${params.customerId} not found`\n      );\n    }\n    const newSubscription: Subscription = {\n      id: `mock_sub_${this.nextSubscriptionId++}`,\n      customerId: params.customerId,\n      status: SubscriptionStatus.ACTIVE,\n      items: (\n        params.items ||\n        (params.priceId ? [{ priceId: params.priceId, quantity: 1 }] : [])\n      ).map((item: { priceId: string; quantity?: number }) => ({\n        id: `mock_sub_item_${Math.random().toString(36).substring(7)}`,\n        priceId: item.priceId,\n        quantity: item.quantity || 1,\n      })),\n      currentPeriodStart: new Date(),\n      currentPeriodEnd: new Date(Date.now() + 30 * 24 * 60 * 60 * 1000), // 30 days from now\n      cancelAtPeriodEnd: false,\n      created: new Date(),\n      updated: new Date(),\n    };\n    this.subscriptions.push(newSubscription);\n    customer.subscriptions.push(newSubscription);\n    return newSubscription;\n  }\n\n  async retrieveSubscription(id: string): Promise<Subscription> {\n    console.log('Mock: retrieveSubscription', id);\n    const subscription = this.subscriptions.find(s => s.id === id);\n    if (!subscription) {\n      throw new PaymentsError(\n        PaymentErrorType.SUBSCRIPTION_NOT_FOUND,\n        `Mock subscription ${id} not found`\n      );\n    }\n    return subscription;\n  }\n\n  async updateSubscription(\n    id: string,\n    params: SubscriptionUpdateParams\n  ): Promise<Subscription> {\n    console.log('Mock: updateSubscription', id, params);\n    const subscription = this.subscriptions.find(s => s.id === id);\n    if (!subscription) {\n      throw new PaymentsError(\n        PaymentErrorType.SUBSCRIPTION_NOT_FOUND,\n        `Mock subscription ${id} not found`\n      );\n    }\n    if (params.cancelAtPeriodEnd !== undefined) {\n      subscription.cancelAtPeriodEnd = params.cancelAtPeriodEnd;\n      subscription.status = params.cancelAtPeriodEnd\n        ? SubscriptionStatus.CANCELED\n        : SubscriptionStatus.ACTIVE;\n    }\n    if (params.items) {\n      subscription.items = params.items.map(\n        (item: { priceId: string; quantity?: number }) => ({\n          id: `mock_sub_item_${Math.random().toString(36).substring(7)}`,\n          priceId: item.priceId,\n          quantity: item.quantity || 1,\n        })\n      );\n    }\n    subscription.updated = new Date();\n    return subscription;\n  }\n\n  async cancelSubscription(id: string): Promise<void> {\n    console.log('Mock: cancelSubscription', id);\n    const subscription = this.subscriptions.find(s => s.id === id);\n    if (!subscription) {\n      throw new PaymentsError(\n        PaymentErrorType.SUBSCRIPTION_NOT_FOUND,\n        `Mock subscription ${id} not found`\n      );\n    }\n    subscription.status = SubscriptionStatus.CANCELED;\n    subscription.cancelAtPeriodEnd = true;\n    subscription.updated = new Date();\n  }\n\n  async reactivateSubscription(id: string): Promise<void> {\n    console.log('Mock: reactivateSubscription', id);\n    const subscription = this.subscriptions.find(s => s.id === id);\n    if (!subscription) {\n      throw new PaymentsError(\n        PaymentErrorType.SUBSCRIPTION_NOT_FOUND,\n        `Mock subscription ${id} not found`\n      );\n    }\n    subscription.status = SubscriptionStatus.ACTIVE;\n    subscription.cancelAtPeriodEnd = false;\n    subscription.updated = new Date();\n  }\n\n  async listSubscriptions(\n    customerId: string,\n    status?: SubscriptionStatus\n  ): Promise<Subscription[]> {\n    console.log('Mock: listSubscriptions', customerId, status);\n    const customer = this.customers.find(c => c.id === customerId);\n    if (!customer) {\n      throw new PaymentsError(\n        PaymentErrorType.CUSTOMER_NOT_FOUND,\n        `Mock customer ${customerId} not found`\n      );\n    }\n    let subs = customer.subscriptions;\n    if (status && status !== SubscriptionStatus.ALL) {\n      subs = subs.filter(s => s.status === status);\n    }\n    return subs;\n  }\n}\n","import { PaymentsConfig, PaymentProviderType } from '../shared/types/config';\nimport { PaymentsError, PaymentErrorType } from '../shared/types/errors';\nimport { PaymentProvider } from '../shared/types/provider';\nimport { StripePaymentProvider } from './stripe';\n// import { PayPalPaymentProvider } from './paypal';\n// import { ApplePayPaymentProvider } from './applepay';\nimport { MockPaymentProvider } from './mock';\n\nexport class PaymentProviderFactory {\n  public static create(config: PaymentsConfig): PaymentProvider {\n    switch (config.provider) {\n      case 'stripe':\n        return new StripePaymentProvider(config);\n      case 'paypal':\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          'PayPal provider is not yet available in this build'\n        );\n      case 'applepay':\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          'Apple Pay provider is not yet available in this build'\n        );\n      case 'mock':\n        return new MockPaymentProvider(config);\n      default:\n        throw new PaymentsError(\n          PaymentErrorType.CONFIGURATION_ERROR,\n          `Unsupported payment provider: ${config.provider}`\n        );\n    }\n  }\n\n  public static autodetect(): PaymentsConfig {\n    // Check for Stripe configuration first (most common)\n    if (\n      process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY &&\n      process.env.STRIPE_SECRET_KEY\n    ) {\n      return {\n        provider: 'stripe',\n        publishableKey: process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY,\n        environment:\n          process.env.NODE_ENV === 'production' ? 'production' : 'development',\n        stripeConfig: {\n          publishableKey: process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY,\n        },\n      };\n    }\n\n    // Check for PayPal configuration\n    if (\n      process.env.NEXT_PUBLIC_PAYPAL_CLIENT_ID &&\n      process.env.PAYPAL_CLIENT_SECRET\n    ) {\n      return {\n        provider: 'paypal',\n        publishableKey: process.env.NEXT_PUBLIC_PAYPAL_CLIENT_ID,\n        environment:\n          process.env.NODE_ENV === 'production' ? 'production' : 'development',\n        paypalConfig: {\n          clientId: process.env.NEXT_PUBLIC_PAYPAL_CLIENT_ID,\n          clientSecret: process.env.PAYPAL_CLIENT_SECRET,\n          environment:\n            process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',\n          currency: process.env.PAYPAL_CURRENCY || 'USD',\n        },\n      };\n    }\n\n    // Check for Apple Pay configuration\n    if (\n      process.env.NEXT_PUBLIC_APPLE_PAY_MERCHANT_ID &&\n      typeof window !== 'undefined' &&\n      window.ApplePaySession\n    ) {\n      return {\n        provider: 'applepay',\n        environment:\n          process.env.NODE_ENV === 'production' ? 'production' : 'development',\n        applePayConfig: {\n          merchantId: process.env.NEXT_PUBLIC_APPLE_PAY_MERCHANT_ID,\n          merchantName:\n            process.env.NEXT_PUBLIC_APPLE_PAY_MERCHANT_NAME || 'Your Store',\n          countryCode: process.env.NEXT_PUBLIC_APPLE_PAY_COUNTRY_CODE || 'US',\n          currencyCode:\n            process.env.NEXT_PUBLIC_APPLE_PAY_CURRENCY_CODE || 'USD',\n          environment:\n            process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',\n        },\n      };\n    }\n\n    // For development/testing, allow mock provider if no other is detected\n    if (\n      process.env.NODE_ENV !== 'production' ||\n      process.env.VERCEL_ENV === 'preview'\n    ) {\n      console.warn(\n        'No payment provider detected, defaulting to MockPaymentProvider for development/preview environment.'\n      );\n      return {\n        provider: 'mock',\n        environment: 'development',\n      };\n    }\n\n    throw new PaymentsError(\n      PaymentErrorType.CONFIGURATION_ERROR,\n      'Could not auto-detect payment provider. Please provide explicit configuration.'\n    );\n  }\n\n  // Helper method to get all available providers based on environment\n  public static getAvailableProviders(): PaymentProviderType[] {\n    const providers: PaymentProviderType[] = [];\n\n    // Check Stripe\n    if (process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY) {\n      providers.push('stripe');\n    }\n\n    // Check PayPal\n    if (process.env.NEXT_PUBLIC_PAYPAL_CLIENT_ID) {\n      providers.push('paypal');\n    }\n\n    // Check Apple Pay (client-side only)\n    if (\n      typeof window !== 'undefined' &&\n      window.ApplePaySession?.canMakePayments()\n    ) {\n      providers.push('applepay');\n    }\n\n    // Always include mock for development\n    if (process.env.NODE_ENV !== 'production') {\n      providers.push('mock');\n    }\n\n    return providers;\n  }\n\n  // Method to create multiple providers for fallback scenarios\n  public static createMultiple(configs: PaymentsConfig[]): PaymentProvider[] {\n    return configs.map(config => this.create(config));\n  }\n}\n","export const STRIPE_API_VERSION = '2023-10-16';\n\nexport const PAYMENT_METHODS = {\n  CARD: 'card',\n  BANK_ACCOUNT: 'bank_account',\n  SEPA_DEBIT: 'sepa_debit',\n  IDEAL: 'ideal',\n  SOFORT: 'sofort',\n} as const;\n\nexport const SUBSCRIPTION_STATUS = {\n  ACTIVE: 'active',\n  CANCELED: 'canceled',\n  PAST_DUE: 'past_due',\n  UNPAID: 'unpaid',\n  INCOMPLETE: 'incomplete',\n  INCOMPLETE_EXPIRED: 'incomplete_expired',\n  TRIALING: 'trialing',\n} as const;\n\nexport const INVOICE_STATUS = {\n  DRAFT: 'draft',\n  OPEN: 'open',\n  PAID: 'paid',\n  UNCOLLECTIBLE: 'uncollectible',\n  VOID: 'void',\n} as const;\n\nexport const CHECKOUT_MODE = {\n  PAYMENT: 'payment',\n  SUBSCRIPTION: 'subscription',\n  SETUP: 'setup',\n} as const;\n\nexport const BILLING_INTERVALS = {\n  DAY: 'day',\n  WEEK: 'week',\n  MONTH: 'month',\n  YEAR: 'year',\n} as const;\n\nexport const CURRENCY_SYMBOLS = {\n  USD: '$',\n  EUR: '€',\n  GBP: '£',\n  JPY: '¥',\n  CAD: 'C$',\n  AUD: 'A$',\n  CHF: 'CHF',\n  CNY: '¥',\n  SEK: 'kr',\n  NZD: 'NZ$',\n} as const;\n\nexport const DEFAULT_CURRENCY = 'USD';\n\nexport const WEBHOOK_EVENTS = {\n  CUSTOMER_SUBSCRIPTION_CREATED: 'customer.subscription.created',\n  CUSTOMER_SUBSCRIPTION_UPDATED: 'customer.subscription.updated',\n  CUSTOMER_SUBSCRIPTION_DELETED: 'customer.subscription.deleted',\n  INVOICE_PAYMENT_SUCCEEDED: 'invoice.payment_succeeded',\n  INVOICE_PAYMENT_FAILED: 'invoice.payment_failed',\n  CHECKOUT_SESSION_COMPLETED: 'checkout.session.completed',\n  PAYMENT_INTENT_SUCCEEDED: 'payment_intent.succeeded',\n  PAYMENT_INTENT_PAYMENT_FAILED: 'payment_intent.payment_failed',\n} as const;\n\nexport const ERROR_MESSAGES = {\n  PROVIDER_NOT_CONFIGURED: 'Payments provider is not properly configured',\n  STRIPE_NOT_LOADED: 'Stripe has not been loaded yet',\n  INVALID_PRICE_ID: 'Invalid price ID provided',\n  INVALID_CUSTOMER_ID: 'Invalid customer ID provided',\n  CHECKOUT_FAILED: 'Checkout session creation failed',\n  PAYMENT_FAILED: 'Payment processing failed',\n  SUBSCRIPTION_NOT_FOUND: 'Subscription not found',\n  CUSTOMER_NOT_FOUND: 'Customer not found',\n} as const;\n","import { PaymentsConfig, PricingPlan } from '../types';\n\nexport const validateEmail = (email: string): boolean => {\n  const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n  return emailRegex.test(email);\n};\n\nexport const validatePhoneNumber = (phone: string): boolean => {\n  // Basic phone number validation - can be enhanced based on requirements\n  const phoneRegex = /^\\+?[\\d\\s-()]{10,}$/;\n  return phoneRegex.test(phone);\n};\n\nexport const validatePaymentsConfig = (\n  config: PaymentsConfig\n): { isValid: boolean; errors: string[] } => {\n  const errors: string[] = [];\n\n  if (!config.publishableKey) {\n    errors.push('publishableKey is required');\n  }\n\n  if (!config.provider) {\n    errors.push('provider is required');\n  }\n\n  if (config.provider !== 'stripe') {\n    errors.push('Only stripe provider is currently supported');\n  }\n\n  if (!config.environment) {\n    errors.push('environment is required');\n  }\n\n  if (\n    config.environment &&\n    !['development', 'production'].includes(config.environment)\n  ) {\n    errors.push('environment must be either \"development\" or \"production\"');\n  }\n\n  if (config.publishableKey && !config.publishableKey.startsWith('pk_')) {\n    errors.push('publishableKey must start with \"pk_\"');\n  }\n\n  if (config.secretKey && !config.secretKey.startsWith('sk_')) {\n    errors.push('secretKey must start with \"sk_\"');\n  }\n\n  if (config.webhookSecret && !config.webhookSecret.startsWith('whsec_')) {\n    errors.push('webhookSecret must start with \"whsec_\"');\n  }\n\n  return {\n    isValid: errors.length === 0,\n    errors,\n  };\n};\n\nexport const validatePricingPlan = (\n  plan: PricingPlan\n): { isValid: boolean; errors: string[] } => {\n  const errors: string[] = [];\n\n  if (!plan.id) {\n    errors.push('id is required');\n  }\n\n  if (!plan.name) {\n    errors.push('name is required');\n  }\n\n  if (typeof plan.price !== 'number' || plan.price < 0) {\n    errors.push('price must be a non-negative number');\n  }\n\n  if (!plan.currency) {\n    errors.push('currency is required');\n  }\n\n  if (!plan.interval) {\n    errors.push('interval is required');\n  }\n\n  if (!['day', 'week', 'month', 'year'].includes(plan.interval)) {\n    errors.push('interval must be one of: day, week, month, year');\n  }\n\n  if (!plan.stripePriceId) {\n    errors.push('stripePriceId is required');\n  }\n\n  if (plan.stripePriceId && !plan.stripePriceId.startsWith('price_')) {\n    errors.push('stripePriceId must start with \"price_\"');\n  }\n\n  if (!Array.isArray(plan.features)) {\n    errors.push('features must be an array');\n  }\n\n  if (\n    plan.intervalCount &&\n    (typeof plan.intervalCount !== 'number' || plan.intervalCount < 1)\n  ) {\n    errors.push('intervalCount must be a positive number');\n  }\n\n  if (\n    plan.trialPeriodDays &&\n    (typeof plan.trialPeriodDays !== 'number' || plan.trialPeriodDays < 0)\n  ) {\n    errors.push('trialPeriodDays must be a non-negative number');\n  }\n\n  return {\n    isValid: errors.length === 0,\n    errors,\n  };\n};\n\nexport const validateStripeId = (\n  id: string,\n  type: 'customer' | 'subscription' | 'price' | 'product' | 'payment_intent'\n): boolean => {\n  const prefixes = {\n    customer: 'cus_',\n    subscription: 'sub_',\n    price: 'price_',\n    product: 'prod_',\n    payment_intent: 'pi_',\n  };\n\n  return id.startsWith(prefixes[type]);\n};\n\nexport const validateAmount = (\n  amount: number,\n  currency: string\n): { isValid: boolean; error?: string } => {\n  if (typeof amount !== 'number') {\n    return { isValid: false, error: 'Amount must be a number' };\n  }\n\n  if (amount < 0) {\n    return { isValid: false, error: 'Amount must be non-negative' };\n  }\n\n  // Stripe minimum amounts by currency\n  const minimumAmounts: Record<string, number> = {\n    USD: 50, // $0.50\n    EUR: 50, // €0.50\n    GBP: 30, // £0.30\n    JPY: 50, // ¥50\n    CAD: 50, // C$0.50\n    AUD: 50, // A$0.50\n  };\n\n  const minAmount = minimumAmounts[currency.toUpperCase()] || 50;\n\n  if (amount < minAmount) {\n    return {\n      isValid: false,\n      error: `Amount must be at least ${minAmount} ${currency.toLowerCase()} cents`,\n    };\n  }\n\n  return { isValid: true };\n};\n\nexport const validateCard = (cardDetails: {\n  number: string;\n  expMonth: number;\n  expYear: number;\n  cvc: string;\n}): { isValid: boolean; errors: string[] } => {\n  const errors: string[] = [];\n\n  // Validate card number (basic Luhn algorithm)\n  const cleanNumber = cardDetails.number.replace(/\\s/g, '');\n  if (!cleanNumber || cleanNumber.length < 13 || cleanNumber.length > 19) {\n    errors.push('Card number must be between 13 and 19 digits');\n  } else if (!luhnCheck(cleanNumber)) {\n    errors.push('Invalid card number');\n  }\n\n  // Validate expiration month\n  if (\n    !cardDetails.expMonth ||\n    cardDetails.expMonth < 1 ||\n    cardDetails.expMonth > 12\n  ) {\n    errors.push('Expiration month must be between 1 and 12');\n  }\n\n  // Validate expiration year\n  const currentYear = new Date().getFullYear();\n  if (\n    !cardDetails.expYear ||\n    cardDetails.expYear < currentYear ||\n    cardDetails.expYear > currentYear + 20\n  ) {\n    errors.push('Invalid expiration year');\n  }\n\n  // Check if card is expired\n  if (cardDetails.expMonth && cardDetails.expYear) {\n    const expirationDate = new Date(\n      cardDetails.expYear,\n      cardDetails.expMonth - 1,\n      1\n    );\n    const currentDate = new Date();\n    if (expirationDate < currentDate) {\n      errors.push('Card has expired');\n    }\n  }\n\n  // Validate CVC\n  if (\n    !cardDetails.cvc ||\n    cardDetails.cvc.length < 3 ||\n    cardDetails.cvc.length > 4\n  ) {\n    errors.push('CVC must be 3 or 4 digits');\n  }\n\n  return {\n    isValid: errors.length === 0,\n    errors,\n  };\n};\n\n// Luhn algorithm for credit card validation\nconst luhnCheck = (cardNumber: string): boolean => {\n  let sum = 0;\n  let alternate = false;\n\n  for (let i = cardNumber.length - 1; i >= 0; i--) {\n    let n = parseInt(cardNumber.charAt(i), 10);\n\n    if (alternate) {\n      n *= 2;\n      if (n > 9) {\n        n = (n % 10) + 1;\n      }\n    }\n\n    sum += n;\n    alternate = !alternate;\n  }\n\n  return sum % 10 === 0;\n};\n","import { CURRENCY_SYMBOLS, DEFAULT_CURRENCY } from '../constants';\nimport { PricingPlan, SubscriptionStatus } from '../types';\n\nexport const formatCurrency = (\n  amount: number,\n  currency: string = DEFAULT_CURRENCY,\n  options: {\n    showSymbol?: boolean;\n    showCents?: boolean;\n    locale?: string;\n  } = {}\n): string => {\n  const { showSymbol = true, showCents = true, locale = 'en-US' } = options;\n\n  const currencyCode = currency.toUpperCase();\n\n  // Convert from cents to dollars for most currencies\n  const isZeroDecimalCurrency = ['JPY', 'KRW', 'VND', 'CLP'].includes(\n    currencyCode\n  );\n  const displayAmount = isZeroDecimalCurrency ? amount : amount / 100;\n\n  if (showSymbol) {\n    try {\n      return new Intl.NumberFormat(locale, {\n        style: 'currency',\n        currency: currencyCode,\n        minimumFractionDigits: showCents && !isZeroDecimalCurrency ? 2 : 0,\n        maximumFractionDigits: showCents && !isZeroDecimalCurrency ? 2 : 0,\n      }).format(displayAmount);\n    } catch {\n      // Fallback to manual formatting if Intl.NumberFormat fails\n      const symbol =\n        CURRENCY_SYMBOLS[currencyCode as keyof typeof CURRENCY_SYMBOLS] ||\n        currencyCode;\n      const formattedAmount =\n        showCents && !isZeroDecimalCurrency\n          ? displayAmount.toFixed(2)\n          : Math.round(displayAmount).toString();\n      return `${symbol}${formattedAmount}`;\n    }\n  }\n\n  return showCents && !isZeroDecimalCurrency\n    ? displayAmount.toFixed(2)\n    : Math.round(displayAmount).toString();\n};\n\nexport const formatPricingPlan = (plan: PricingPlan): string => {\n  const price = formatCurrency(plan.price, plan.currency);\n  const interval =\n    plan.intervalCount && plan.intervalCount > 1\n      ? `${plan.intervalCount} ${plan.interval}s`\n      : plan.interval;\n\n  return `${price}/${interval}`;\n};\n\nexport const formatSubscriptionStatus = (\n  status: SubscriptionStatus\n): string => {\n  const statusMap: Record<SubscriptionStatus, string> = {\n    [SubscriptionStatus.ACTIVE]: 'Active',\n    [SubscriptionStatus.CANCELED]: 'Canceled',\n    [SubscriptionStatus.PAST_DUE]: 'Past Due',\n    [SubscriptionStatus.UNPAID]: 'Unpaid',\n    [SubscriptionStatus.INCOMPLETE]: 'Incomplete',\n    [SubscriptionStatus.INCOMPLETE_EXPIRED]: 'Incomplete (Expired)',\n    [SubscriptionStatus.TRIALING]: 'Trial',\n    [SubscriptionStatus.ENDED]: 'Ended',\n    [SubscriptionStatus.ALL]: 'All',\n  };\n\n  return statusMap[status] || status;\n};\n\nexport const formatDate = (\n  date: Date | string | number,\n  options: {\n    format?: 'short' | 'medium' | 'long' | 'full';\n    locale?: string;\n    timeZone?: string;\n  } = {}\n): string => {\n  const { format = 'medium', locale = 'en-US', timeZone } = options;\n\n  const dateObj =\n    typeof date === 'string' || typeof date === 'number'\n      ? new Date(date)\n      : date;\n\n  const formatOptions: Intl.DateTimeFormatOptions = {\n    timeZone,\n  };\n\n  switch (format) {\n    case 'short':\n      formatOptions.dateStyle = 'short';\n      break;\n    case 'medium':\n      formatOptions.dateStyle = 'medium';\n      break;\n    case 'long':\n      formatOptions.dateStyle = 'long';\n      break;\n    case 'full':\n      formatOptions.dateStyle = 'full';\n      break;\n  }\n\n  try {\n    return new Intl.DateTimeFormat(locale, formatOptions).format(dateObj);\n  } catch {\n    // Fallback to basic formatting\n    return dateObj.toLocaleDateString();\n  }\n};\n\nexport const formatRelativeTime = (\n  date: Date | string | number,\n  options: {\n    locale?: string;\n    numeric?: 'always' | 'auto';\n  } = {}\n): string => {\n  const { locale = 'en-US', numeric = 'auto' } = options;\n\n  const dateObj =\n    typeof date === 'string' || typeof date === 'number'\n      ? new Date(date)\n      : date;\n  const now = new Date();\n  const diffInSeconds = Math.floor((now.getTime() - dateObj.getTime()) / 1000);\n\n  try {\n    const rtf = new Intl.RelativeTimeFormat(locale, { numeric });\n\n    if (Math.abs(diffInSeconds) < 60) {\n      return rtf.format(-diffInSeconds, 'second');\n    } else if (Math.abs(diffInSeconds) < 3600) {\n      return rtf.format(-Math.floor(diffInSeconds / 60), 'minute');\n    } else if (Math.abs(diffInSeconds) < 86400) {\n      return rtf.format(-Math.floor(diffInSeconds / 3600), 'hour');\n    } else if (Math.abs(diffInSeconds) < 2592000) {\n      return rtf.format(-Math.floor(diffInSeconds / 86400), 'day');\n    } else if (Math.abs(diffInSeconds) < 31536000) {\n      return rtf.format(-Math.floor(diffInSeconds / 2592000), 'month');\n    } else {\n      return rtf.format(-Math.floor(diffInSeconds / 31536000), 'year');\n    }\n  } catch {\n    // Fallback to basic relative time\n    if (Math.abs(diffInSeconds) < 60) {\n      return 'just now';\n    } else if (Math.abs(diffInSeconds) < 3600) {\n      const minutes = Math.floor(Math.abs(diffInSeconds) / 60);\n      return diffInSeconds < 0\n        ? `in ${minutes} minutes`\n        : `${minutes} minutes ago`;\n    } else if (Math.abs(diffInSeconds) < 86400) {\n      const hours = Math.floor(Math.abs(diffInSeconds) / 3600);\n      return diffInSeconds < 0 ? `in ${hours} hours` : `${hours} hours ago`;\n    } else {\n      const days = Math.floor(Math.abs(diffInSeconds) / 86400);\n      return diffInSeconds < 0 ? `in ${days} days` : `${days} days ago`;\n    }\n  }\n};\n\nexport const formatBillingInterval = (\n  interval: string,\n  count: number = 1\n): string => {\n  const intervalMap: Record<string, string> = {\n    day: count === 1 ? 'daily' : `every ${count} days`,\n    week: count === 1 ? 'weekly' : `every ${count} weeks`,\n    month: count === 1 ? 'monthly' : `every ${count} months`,\n    year: count === 1 ? 'yearly' : `every ${count} years`,\n  };\n\n  return intervalMap[interval] || interval;\n};\n\nexport const formatTrialPeriod = (days: number): string => {\n  if (days === 0) return 'No trial';\n  if (days === 1) return '1 day trial';\n  if (days < 7) return `${days} days trial`;\n  if (days === 7) return '1 week trial';\n  if (days < 30) return `${Math.floor(days / 7)} weeks trial`;\n  if (days === 30) return '1 month trial';\n  return `${Math.floor(days / 30)} months trial`;\n};\n\nexport const truncateText = (text: string, maxLength: number): string => {\n  if (text.length <= maxLength) return text;\n  return `${text.substring(0, maxLength - 3)}...`;\n};\n\nexport const formatCardBrand = (brand: string): string => {\n  const brandMap: Record<string, string> = {\n    visa: 'Visa',\n    mastercard: 'Mastercard',\n    amex: 'American Express',\n    discover: 'Discover',\n    jcb: 'JCB',\n    diners: 'Diners Club',\n    unionpay: 'UnionPay',\n  };\n\n  return brandMap[brand.toLowerCase()] || brand;\n};\n\nexport const formatPaymentMethodDisplay = (paymentMethod: {\n  type: string;\n  card?: { brand: string; last4: string };\n  bankAccount?: { last4: string; bankName?: string };\n}): string => {\n  if (paymentMethod.type === 'card' && paymentMethod.card) {\n    return `${formatCardBrand(paymentMethod.card.brand)} •••• ${paymentMethod.card.last4}`;\n  }\n\n  if (paymentMethod.type === 'bank_account' && paymentMethod.bankAccount) {\n    const bankName = paymentMethod.bankAccount.bankName || 'Bank';\n    return `${bankName} •••• ${paymentMethod.bankAccount.last4}`;\n  }\n\n  return paymentMethod.type;\n};\n\nexport const calculateTax = (\n  amount: number,\n  taxRate: number,\n  options: {\n    inclusive?: boolean;\n    roundTo?: number;\n  } = {}\n): { subtotal: number; tax: number; total: number } => {\n  const { inclusive = false, roundTo = 2 } = options;\n\n  let subtotal: number;\n  let tax: number;\n  let total: number;\n\n  if (inclusive) {\n    // Tax is included in the amount\n    total = amount;\n    subtotal = amount / (1 + taxRate / 100);\n    tax = amount - subtotal;\n  } else {\n    // Tax is added to the amount\n    subtotal = amount;\n    tax = amount * (taxRate / 100);\n    total = amount + tax;\n  }\n\n  // Round to specified decimal places\n  const multiplier = Math.pow(10, roundTo);\n  return {\n    subtotal: Math.round(subtotal * multiplier) / multiplier,\n    tax: Math.round(tax * multiplier) / multiplier,\n    total: Math.round(total * multiplier) / multiplier,\n  };\n};\n\nexport const formatTaxRate = (rate: number): string => {\n  return `${rate.toFixed(2)}%`;\n};\n\nexport const formatAmountWithTax = (\n  amount: number,\n  taxRate: number,\n  currency: string = DEFAULT_CURRENCY,\n  options: {\n    inclusive?: boolean;\n    showBreakdown?: boolean;\n    locale?: string;\n  } = {}\n): string => {\n  const {\n    inclusive = false,\n    showBreakdown = false,\n    locale = 'en-US',\n  } = options;\n  const taxCalculation = calculateTax(amount, taxRate, { inclusive });\n\n  if (showBreakdown) {\n    const subtotalFormatted = formatCurrency(\n      taxCalculation.subtotal,\n      currency,\n      { locale }\n    );\n    const taxFormatted = formatCurrency(taxCalculation.tax, currency, {\n      locale,\n    });\n    const totalFormatted = formatCurrency(taxCalculation.total, currency, {\n      locale,\n    });\n\n    return `${subtotalFormatted} + ${taxFormatted} tax = ${totalFormatted}`;\n  }\n\n  return formatCurrency(taxCalculation.total, currency, { locale });\n};\n","import React from 'react';\nimport { PricingPlan } from '../../shared/types';\nimport {\n  formatPricingPlan,\n  formatTrialPeriod,\n} from '../../shared/utils/formatting';\nimport { CheckoutButton } from './CheckoutButton';\n\ninterface PricingTableProps {\n  plans: PricingPlan[];\n  customerId?: string;\n  customerEmail?: string;\n  successUrl?: string;\n  cancelUrl?: string;\n  className?: string;\n  onCheckoutSuccess?: (plan: PricingPlan) => void;\n  onCheckoutError?: (plan: PricingPlan, error: string) => void;\n  showFeatures?: boolean;\n  showTrialInfo?: boolean;\n  layout?: 'grid' | 'list';\n  maxColumns?: number;\n}\n\nexport const PricingTable: React.FC<PricingTableProps> = ({\n  plans,\n  customerId,\n  customerEmail,\n  successUrl,\n  cancelUrl,\n  className = '',\n  onCheckoutSuccess,\n  onCheckoutError,\n  showFeatures = true,\n  showTrialInfo = true,\n  layout = 'grid',\n  maxColumns = 3,\n}) => {\n  if (!plans || plans.length === 0) {\n    return (\n      <div className=\"text-center py-8 text-gray-500\">\n        No pricing plans available\n      </div>\n    );\n  }\n\n  const gridCols = Math.min(plans.length, maxColumns);\n  const gridClass =\n    layout === 'grid'\n      ? `grid gap-6 ${gridCols === 1 ? 'grid-cols-1' : gridCols === 2 ? 'grid-cols-1 md:grid-cols-2' : 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3'}`\n      : 'space-y-6';\n\n  return (\n    <div className={`pricing-table ${className}`}>\n      <div className={gridClass}>\n        {plans.map(plan => (\n          <PricingCard\n            key={plan.id}\n            plan={plan}\n            customerId={customerId}\n            customerEmail={customerEmail}\n            successUrl={successUrl}\n            cancelUrl={cancelUrl}\n            onCheckoutSuccess={() => onCheckoutSuccess?.(plan)}\n            onCheckoutError={error => onCheckoutError?.(plan, error)}\n            showFeatures={showFeatures}\n            showTrialInfo={showTrialInfo}\n          />\n        ))}\n      </div>\n    </div>\n  );\n};\n\ninterface PricingCardProps {\n  plan: PricingPlan;\n  customerId?: string;\n  customerEmail?: string;\n  successUrl?: string;\n  cancelUrl?: string;\n  onCheckoutSuccess?: () => void;\n  onCheckoutError?: (error: string) => void;\n  showFeatures?: boolean;\n  showTrialInfo?: boolean;\n}\n\nconst PricingCard: React.FC<PricingCardProps> = ({\n  plan,\n  customerId,\n  customerEmail,\n  successUrl,\n  cancelUrl,\n  onCheckoutSuccess,\n  onCheckoutError,\n  showFeatures = true,\n  showTrialInfo = true,\n}) => {\n  const isPopular = plan.popular;\n\n  return (\n    <div\n      className={`\n      relative bg-white rounded-lg shadow-lg overflow-hidden\n      ${isPopular ? 'ring-2 ring-blue-500 ring-opacity-50' : 'border border-gray-200'}\n      transition-transform duration-200 hover:scale-105\n    `}\n    >\n      {isPopular && (\n        <div className=\"absolute top-0 left-0 right-0 bg-blue-500 text-white text-center py-2 text-sm font-medium\">\n          Most Popular\n        </div>\n      )}\n\n      <div className={`p-6 ${isPopular ? 'pt-12' : ''}`}>\n        {/* Plan Header */}\n        <div className=\"text-center mb-6\">\n          <h3 className=\"text-xl font-semibold text-gray-900 mb-2\">\n            {plan.name}\n          </h3>\n          {plan.description && (\n            <p className=\"text-gray-600 text-sm mb-4\">{plan.description}</p>\n          )}\n          <div className=\"mb-4\">\n            <span className=\"text-3xl font-bold text-gray-900\">\n              {formatPricingPlan(plan)}\n            </span>\n          </div>\n          {showTrialInfo &&\n            plan.trialPeriodDays &&\n            plan.trialPeriodDays > 0 && (\n              <div className=\"text-sm text-green-600 font-medium\">\n                {formatTrialPeriod(plan.trialPeriodDays)}\n              </div>\n            )}\n        </div>\n\n        {/* Features List */}\n        {showFeatures && plan.features && plan.features.length > 0 && (\n          <div className=\"mb-6\">\n            <ul className=\"space-y-3\">\n              {plan.features.map((feature, index) => (\n                <li key={index} className=\"flex items-start\">\n                  <svg\n                    className=\"flex-shrink-0 w-5 h-5 text-green-500 mt-0.5 mr-3\"\n                    fill=\"none\"\n                    stroke=\"currentColor\"\n                    viewBox=\"0 0 24 24\"\n                  >\n                    <path\n                      strokeLinecap=\"round\"\n                      strokeLinejoin=\"round\"\n                      strokeWidth={2}\n                      d=\"M5 13l4 4L19 7\"\n                    />\n                  </svg>\n                  <span className=\"text-gray-700 text-sm\">{feature}</span>\n                </li>\n              ))}\n            </ul>\n          </div>\n        )}\n\n        {/* CTA Button */}\n        <div className=\"mt-6\">\n          <CheckoutButton\n            priceId={plan.stripePriceId}\n            customerId={customerId}\n            customerEmail={customerEmail}\n            successUrl={successUrl}\n            cancelUrl={cancelUrl}\n            trialPeriodDays={plan.trialPeriodDays}\n            metadata={plan.metadata}\n            onSuccess={onCheckoutSuccess}\n            onError={onCheckoutError}\n            className={`\n              w-full justify-center py-3 px-4 text-base font-medium\n              ${\n                isPopular\n                  ? 'bg-blue-600 hover:bg-blue-700 text-white'\n                  : 'bg-gray-100 hover:bg-gray-200 text-gray-900 border border-gray-300'\n              }\n            `}\n          >\n            Get Started\n          </CheckoutButton>\n        </div>\n      </div>\n    </div>\n  );\n};\n\nexport default PricingTable;\n","import React, { useState } from 'react';\nimport {\n  useStripe,\n  useElements,\n  CardElement,\n  PaymentElement,\n} from '@stripe/react-stripe-js';\nimport { usePaymentsContext } from '../../shared/providers/PaymentsProvider';\nimport { PaymentIntent } from '@stripe/stripe-js';\nimport { ERROR_MESSAGES } from '../../shared/constants';\nimport { validateEmail } from '../../shared/utils/validation';\n\nexport interface PaymentFormProps {\n  clientSecret?: string;\n  customerId?: string;\n  customerEmail?: string;\n  amount?: number;\n  currency?: string;\n  description?: string;\n  metadata?: Record<string, string>;\n  onSuccess?: (paymentIntent: PaymentIntent) => void;\n  onError?: (error: string) => void;\n  onLoading?: (loading: boolean) => void;\n  className?: string;\n  showBillingDetails?: boolean;\n  elementType?: 'card' | 'payment';\n}\n\nexport const PaymentForm: React.FC<PaymentFormProps> = ({\n  clientSecret,\n  customerId,\n  customerEmail,\n  amount,\n  currency = 'usd',\n  description,\n  metadata,\n  onSuccess,\n  onError,\n  onLoading,\n  className = '',\n  showBillingDetails = true,\n  elementType = 'payment',\n}) => {\n  const stripe = useStripe();\n  const elements = useElements();\n  const { initialized } = usePaymentsContext();\n\n  const [loading, setLoading] = useState(false);\n  const [email, setEmail] = useState(customerEmail || '');\n  const [billingDetails, setBillingDetails] = useState({\n    name: '',\n    email: customerEmail || '',\n    phone: '',\n    address: {\n      line1: '',\n      line2: '',\n      city: '',\n      state: '',\n      postal_code: '',\n      country: 'US',\n    },\n  });\n\n  const handleSubmit = async (event: React.FormEvent) => {\n    event.preventDefault();\n\n    if (!stripe || !elements) {\n      const error = ERROR_MESSAGES.STRIPE_NOT_LOADED;\n      onError?.(error);\n      return;\n    }\n\n    if (!initialized) {\n      const error = ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED;\n      onError?.(error);\n      return;\n    }\n\n    if (showBillingDetails && email && !validateEmail(email)) {\n      onError?.('Please enter a valid email address');\n      return;\n    }\n\n    setLoading(true);\n    onLoading?.(true);\n\n    try {\n      let result;\n\n      if (elementType === 'payment' && clientSecret) {\n        // Use Payment Element with existing Payment Intent\n        result = await stripe.confirmPayment({\n          elements,\n          confirmParams: {\n            return_url: window.location.href,\n            receipt_email: email || billingDetails.email,\n          },\n          redirect: 'if_required',\n        });\n      } else if (elementType === 'card') {\n        // Use Card Element\n        const cardElement = elements.getElement(CardElement);\n\n        if (!cardElement) {\n          throw new Error('Card element not found');\n        }\n\n        if (clientSecret) {\n          // Confirm existing Payment Intent\n          result = await stripe.confirmCardPayment(clientSecret, {\n            payment_method: {\n              card: cardElement,\n              billing_details: showBillingDetails\n                ? {\n                    name: billingDetails.name || undefined,\n                    email: billingDetails.email || undefined,\n                    phone: billingDetails.phone || undefined,\n                    address: billingDetails.address.line1\n                      ? billingDetails.address\n                      : undefined,\n                  }\n                : undefined,\n            },\n          });\n        } else if (amount) {\n          // Create new Payment Intent\n          const response = await fetch('/api/payments/create-payment-intent', {\n            method: 'POST',\n            headers: { 'Content-Type': 'application/json' },\n            body: JSON.stringify({\n              amount,\n              currency,\n              customerId,\n              description,\n              metadata,\n            }),\n          });\n\n          if (!response.ok) {\n            throw new Error('Failed to create payment intent');\n          }\n\n          const { client_secret } = await response.json();\n\n          result = await stripe.confirmCardPayment(client_secret, {\n            payment_method: {\n              card: cardElement,\n              billing_details: showBillingDetails\n                ? {\n                    name: billingDetails.name || undefined,\n                    email: billingDetails.email || undefined,\n                    phone: billingDetails.phone || undefined,\n                    address: billingDetails.address.line1\n                      ? billingDetails.address\n                      : undefined,\n                  }\n                : undefined,\n            },\n          });\n        } else {\n          throw new Error('Either clientSecret or amount is required');\n        }\n      }\n\n      if (result?.error) {\n        throw new Error(result.error.message || ERROR_MESSAGES.PAYMENT_FAILED);\n      }\n\n      if (result?.paymentIntent?.status === 'succeeded') {\n        onSuccess?.(result.paymentIntent);\n      }\n    } catch (error) {\n      const errorMessage =\n        error instanceof Error ? error.message : ERROR_MESSAGES.PAYMENT_FAILED;\n      onError?.(errorMessage);\n      console.error('Payment error:', error);\n    } finally {\n      setLoading(false);\n      onLoading?.(false);\n    }\n  };\n\n  const cardElementOptions = {\n    style: {\n      base: {\n        fontSize: '16px',\n        color: '#424770',\n        '::placeholder': {\n          color: '#aab7c4',\n        },\n      },\n      invalid: {\n        color: '#9e2146',\n      },\n    },\n  };\n\n  return (\n    <form onSubmit={handleSubmit} className={`payment-form ${className}`}>\n      {showBillingDetails && (\n        <div className=\"mb-6 space-y-4\">\n          <div>\n            <label\n              htmlFor=\"email\"\n              className=\"block text-sm font-medium text-gray-700 mb-1\"\n            >\n              Email\n            </label>\n            <input\n              type=\"email\"\n              id=\"email\"\n              value={email}\n              onChange={e => {\n                setEmail(e.target.value);\n                setBillingDetails(prev => ({ ...prev, email: e.target.value }));\n              }}\n              className=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500\"\n              placeholder=\"your@email.com\"\n              required\n            />\n          </div>\n\n          <div>\n            <label\n              htmlFor=\"name\"\n              className=\"block text-sm font-medium text-gray-700 mb-1\"\n            >\n              Full Name\n            </label>\n            <input\n              type=\"text\"\n              id=\"name\"\n              value={billingDetails.name}\n              onChange={e =>\n                setBillingDetails(prev => ({ ...prev, name: e.target.value }))\n              }\n              className=\"w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500\"\n              placeholder=\"John Doe\"\n            />\n          </div>\n        </div>\n      )}\n\n      <div className=\"mb-6\">\n        <label className=\"block text-sm font-medium text-gray-700 mb-2\">\n          Payment Information\n        </label>\n        <div className=\"p-3 border border-gray-300 rounded-md\">\n          {elementType === 'payment' ? (\n            <PaymentElement />\n          ) : (\n            <CardElement options={cardElementOptions} />\n          )}\n        </div>\n      </div>\n\n      <button\n        type=\"submit\"\n        disabled={!stripe || loading}\n        className=\"w-full bg-blue-600 text-white py-3 px-4 rounded-md font-medium hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200\"\n      >\n        {loading ? (\n          <>\n            <svg\n              className=\"animate-spin -ml-1 mr-3 h-4 w-4 text-white inline\"\n              xmlns=\"http://www.w3.org/2000/svg\"\n              fill=\"none\"\n              viewBox=\"0 0 24 24\"\n            >\n              <circle\n                className=\"opacity-25\"\n                cx=\"12\"\n                cy=\"12\"\n                r=\"10\"\n                stroke=\"currentColor\"\n                strokeWidth=\"4\"\n              ></circle>\n              <path\n                className=\"opacity-75\"\n                fill=\"currentColor\"\n                d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n              ></path>\n            </svg>\n            Processing...\n          </>\n        ) : (\n          `Pay ${amount ? `$${(amount / 100).toFixed(2)}` : ''}`\n        )}\n      </button>\n    </form>\n  );\n};\n\nexport default PaymentForm;\n","import React, { useState } from 'react';\nimport { usePaymentsContext } from '../../shared/providers/PaymentsProvider';\nimport { ERROR_MESSAGES } from '../../shared/constants';\nimport { validateStripeId } from '../../shared/utils/validation';\n\ninterface BillingPortalProps {\n  customerId: string;\n  returnUrl?: string;\n  children?: React.ReactNode;\n  className?: string;\n  onSuccess?: () => void;\n  onError?: (error: string) => void;\n  onLoading?: (loading: boolean) => void;\n}\n\nexport const BillingPortal: React.FC<BillingPortalProps> = ({\n  customerId,\n  returnUrl = typeof window !== 'undefined' ? window.location.href : '/',\n  children,\n  className = '',\n  onSuccess,\n  onError,\n  onLoading,\n}) => {\n  const { initialized } = usePaymentsContext();\n  const [loading, setLoading] = useState(false);\n\n  const handleOpenPortal = async () => {\n    if (!initialized) {\n      const error = ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED;\n      onError?.(error);\n      console.error(error);\n      return;\n    }\n\n    if (!validateStripeId(customerId, 'customer')) {\n      const error = ERROR_MESSAGES.INVALID_CUSTOMER_ID;\n      onError?.(error);\n      console.error(error);\n      return;\n    }\n\n    setLoading(true);\n    onLoading?.(true);\n\n    try {\n      const response = await fetch('/api/payments/create-portal-session', {\n        method: 'POST',\n        headers: {\n          'Content-Type': 'application/json',\n        },\n        body: JSON.stringify({\n          customerId,\n          returnUrl,\n        }),\n      });\n\n      if (!response.ok) {\n        const errorData = await response\n          .json()\n          .catch(() => ({ error: 'Network error' }));\n        throw new Error(errorData.error || 'Failed to create portal session');\n      }\n\n      const { url } = await response.json();\n\n      if (!url) {\n        throw new Error('No portal URL returned from server');\n      }\n\n      // Redirect to Stripe Customer Portal\n      window.location.href = url;\n      onSuccess?.();\n    } catch (error) {\n      const errorMessage =\n        error instanceof Error\n          ? error.message\n          : 'Failed to open billing portal';\n      onError?.(errorMessage);\n      console.error('Billing portal error:', error);\n    } finally {\n      setLoading(false);\n      onLoading?.(false);\n    }\n  };\n\n  const isDisabled = loading || !initialized || !customerId;\n\n  return (\n    <button\n      onClick={handleOpenPortal}\n      disabled={isDisabled}\n      className={`\n        inline-flex items-center justify-center px-4 py-2 \n        border border-gray-300 text-sm font-medium rounded-md \n        text-gray-700 bg-white hover:bg-gray-50 \n        focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500\n        disabled:opacity-50 disabled:cursor-not-allowed\n        transition-colors duration-200\n        ${className}\n      `}\n      aria-label=\"Manage billing\"\n    >\n      {loading ? (\n        <>\n          <svg\n            className=\"animate-spin -ml-1 mr-3 h-4 w-4 text-gray-700\"\n            xmlns=\"http://www.w3.org/2000/svg\"\n            fill=\"none\"\n            viewBox=\"0 0 24 24\"\n          >\n            <circle\n              className=\"opacity-25\"\n              cx=\"12\"\n              cy=\"12\"\n              r=\"10\"\n              stroke=\"currentColor\"\n              strokeWidth=\"4\"\n            ></circle>\n            <path\n              className=\"opacity-75\"\n              fill=\"currentColor\"\n              d=\"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z\"\n            ></path>\n          </svg>\n          Loading...\n        </>\n      ) : (\n        children || (\n          <>\n            <svg\n              className=\"w-4 h-4 mr-2\"\n              fill=\"none\"\n              stroke=\"currentColor\"\n              viewBox=\"0 0 24 24\"\n            >\n              <path\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n                strokeWidth={2}\n                d=\"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z\"\n              />\n              <path\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n                strokeWidth={2}\n                d=\"M15 12a3 3 0 11-6 0 3 3 0 016 0z\"\n              />\n            </svg>\n            Manage Billing\n          </>\n        )\n      )}\n    </button>\n  );\n};\n\nexport default BillingPortal;\n","import React from 'react';\n\nexport interface PricingPlan {\n  id: string;\n  name: string;\n  price: number;\n  interval: 'month' | 'year';\n  features: string[];\n  popular?: boolean;\n  stripePriceId?: string;\n}\n\nexport interface SubscriptionPlansProps {\n  plans: PricingPlan[];\n  onPlanSelect: (planId: string) => void;\n  currentPlan?: string;\n  loading?: boolean;\n  /** Enable dark mode colors (default: false for backward compat) */\n  darkMode?: boolean;\n  className?: string;\n}\n\nexport const SubscriptionPlans: React.FC<SubscriptionPlansProps> = ({\n  plans,\n  onPlanSelect,\n  currentPlan,\n  loading = false,\n  darkMode = false,\n  className = '',\n}) => {\n  const formatPrice = (price: number, interval: string) => {\n    return `$${price}/${interval}`;\n  };\n\n  // Color palette swaps based on dark mode\n  const c = darkMode\n    ? {\n        cardBg: '#1f2937',\n        cardBorder: '#374151',\n        text: '#f9fafb',\n        textMuted: '#9ca3af',\n        featureBorder: '#374151',\n        currentBg: '#064e3b',\n        accent: '#60a5fa',\n        currentAccent: '#34d399',\n      }\n    : {\n        cardBg: 'white',\n        cardBorder: '#e5e7eb',\n        text: '#1f2937',\n        textMuted: '#6b7280',\n        featureBorder: '#f3f4f6',\n        currentBg: '#f0fdf4',\n        accent: '#3b82f6',\n        currentAccent: '#10b981',\n      };\n\n  const styles = {\n    container: {\n      width: '100%',\n    } as React.CSSProperties,\n    plansGrid: {\n      display: 'grid',\n      gridTemplateColumns: 'repeat(auto-fit, minmax(300px, 1fr))',\n      gap: '2rem',\n      margin: '2rem 0',\n    } as React.CSSProperties,\n    planCard: {\n      border: `2px solid ${c.cardBorder}`,\n      borderRadius: '12px',\n      padding: '2rem',\n      position: 'relative',\n      background: c.cardBg,\n      transition: 'all 0.3s ease',\n    } as React.CSSProperties,\n    planCardPopular: {\n      borderColor: c.accent,\n      boxShadow: `0 10px 25px ${darkMode ? 'rgba(96, 165, 250, 0.15)' : 'rgba(59, 130, 246, 0.1)'}`,\n    } as React.CSSProperties,\n    planCardCurrent: {\n      borderColor: c.currentAccent,\n      background: c.currentBg,\n    } as React.CSSProperties,\n    popularBadge: {\n      position: 'absolute',\n      top: '-12px',\n      left: '50%',\n      transform: 'translateX(-50%)',\n      background: c.accent,\n      color: 'white',\n      padding: '0.5rem 1rem',\n      borderRadius: '20px',\n      fontSize: '0.875rem',\n      fontWeight: 600,\n    } as React.CSSProperties,\n    planHeader: {\n      textAlign: 'center',\n      marginBottom: '2rem',\n    } as React.CSSProperties,\n    planName: {\n      fontSize: '1.5rem',\n      fontWeight: 700,\n      marginBottom: '0.5rem',\n      color: c.text,\n    } as React.CSSProperties,\n    planPrice: {\n      fontSize: '2rem',\n      fontWeight: 800,\n      color: c.accent,\n    } as React.CSSProperties,\n    planFeatures: {\n      marginBottom: '2rem',\n    } as React.CSSProperties,\n    featuresList: {\n      listStyle: 'none',\n      padding: 0,\n      margin: 0,\n    } as React.CSSProperties,\n    featureItem: {\n      padding: '0.5rem 0',\n      borderBottom: `1px solid ${c.featureBorder}`,\n      color: c.textMuted,\n    } as React.CSSProperties,\n    planButton: {\n      width: '100%',\n      padding: '1rem',\n      border: 'none',\n      borderRadius: '8px',\n      fontWeight: 600,\n      fontSize: '1rem',\n      cursor: 'pointer',\n      transition: 'all 0.3s ease',\n      background: c.accent,\n      color: 'white',\n    } as React.CSSProperties,\n    planButtonCurrent: {\n      background: c.currentAccent,\n    } as React.CSSProperties,\n    planButtonDisabled: {\n      opacity: 0.6,\n      cursor: 'not-allowed',\n    } as React.CSSProperties,\n  };\n\n  return (\n    <div\n      style={styles.container}\n      className={className}\n      role=\"region\"\n      aria-label=\"Pricing plans\"\n    >\n      <div style={styles.plansGrid} role=\"list\">\n        {plans.map(plan => (\n          <div\n            key={plan.id}\n            role=\"listitem\"\n            aria-label={`${plan.name} plan - ${formatPrice(plan.price, plan.interval)}`}\n            aria-current={currentPlan === plan.id ? 'true' : undefined}\n            style={{\n              ...styles.planCard,\n              ...(plan.popular ? styles.planCardPopular : {}),\n              ...(currentPlan === plan.id ? styles.planCardCurrent : {}),\n            }}\n          >\n            {plan.popular && (\n              <div style={styles.popularBadge} aria-label=\"Most popular plan\">\n                Most Popular\n              </div>\n            )}\n\n            <div style={styles.planHeader}>\n              <h3 style={styles.planName}>{plan.name}</h3>\n              <div\n                style={styles.planPrice}\n                aria-label={`${formatPrice(plan.price, plan.interval)} per ${plan.interval}`}\n              >\n                {formatPrice(plan.price, plan.interval)}\n              </div>\n            </div>\n\n            <div style={styles.planFeatures}>\n              <ul\n                style={styles.featuresList}\n                role=\"list\"\n                aria-label={`${plan.name} features`}\n              >\n                {plan.features.map((feature, index) => (\n                  <li key={index} style={styles.featureItem}>\n                    <span aria-hidden=\"true\">✓ </span>\n                    {feature}\n                  </li>\n                ))}\n              </ul>\n            </div>\n\n            <button\n              style={{\n                ...styles.planButton,\n                ...(currentPlan === plan.id ? styles.planButtonCurrent : {}),\n                ...(loading || currentPlan === plan.id\n                  ? styles.planButtonDisabled\n                  : {}),\n                minHeight: '44px',\n              }}\n              onClick={() => onPlanSelect(plan.id)}\n              disabled={loading || currentPlan === plan.id}\n              aria-label={\n                currentPlan === plan.id\n                  ? `${plan.name} is your current plan`\n                  : `Select ${plan.name} plan`\n              }\n            >\n              {loading\n                ? 'Loading...'\n                : currentPlan === plan.id\n                  ? 'Current Plan'\n                  : 'Select Plan'}\n            </button>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n};\n","import React, { useState } from 'react';\n\nexport type SubscriptionStatus =\n  | 'active'\n  | 'canceled'\n  | 'past_due'\n  | 'unpaid'\n  | 'incomplete';\n\nexport interface Subscription {\n  id: string;\n  planId: string;\n  planName: string;\n  status: SubscriptionStatus;\n  currentPeriodStart: Date;\n  currentPeriodEnd: Date;\n  cancelAtPeriodEnd: boolean;\n  amount: number;\n  currency: string;\n  interval: 'month' | 'year';\n}\n\nexport type SubscriptionAction = 'upgrade' | 'downgrade' | 'pause' | 'resume';\n\nexport interface SubscriptionManagerProps {\n  subscription: Subscription;\n  onSubscriptionChange: (action: SubscriptionAction) => void;\n  onCancel: () => void;\n  /** Enable dark mode colors (default: false for backward compat) */\n  darkMode?: boolean;\n  className?: string;\n}\n\nexport const SubscriptionManager: React.FC<SubscriptionManagerProps> = ({\n  subscription,\n  onSubscriptionChange,\n  onCancel,\n  darkMode = false,\n  className = '',\n}) => {\n  const [loading, setLoading] = useState(false);\n\n  const formatDate = (date: Date) => {\n    return new Intl.DateTimeFormat('en-US', {\n      year: 'numeric',\n      month: 'long',\n      day: 'numeric',\n    }).format(date);\n  };\n\n  const formatAmount = (amount: number, currency: string) => {\n    return new Intl.NumberFormat('en-US', {\n      style: 'currency',\n      currency: currency.toUpperCase(),\n    }).format(amount / 100);\n  };\n\n  const getStatusColor = (status: SubscriptionStatus) => {\n    switch (status) {\n      case 'active':\n        return '#10b981';\n      case 'canceled':\n        return '#ef4444';\n      case 'past_due':\n        return '#f59e0b';\n      case 'unpaid':\n        return '#ef4444';\n      case 'incomplete':\n        return '#6b7280';\n      default:\n        return '#6b7280';\n    }\n  };\n\n  const getStatusText = (status: SubscriptionStatus) => {\n    switch (status) {\n      case 'active':\n        return 'Active';\n      case 'canceled':\n        return 'Canceled';\n      case 'past_due':\n        return 'Past Due';\n      case 'unpaid':\n        return 'Unpaid';\n      case 'incomplete':\n        return 'Incomplete';\n      default:\n        return status;\n    }\n  };\n\n  const handleAction = async (action: SubscriptionAction) => {\n    setLoading(true);\n    try {\n      await onSubscriptionChange(action);\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  const handleCancel = async () => {\n    setLoading(true);\n    try {\n      await onCancel();\n    } finally {\n      setLoading(false);\n    }\n  };\n\n  // Color palette swaps for dark mode\n  const bg = darkMode ? '#1f2937' : 'white';\n  const border = darkMode ? '#374151' : '#e5e7eb';\n  const text = darkMode ? '#f9fafb' : '#1f2937';\n  const textMuted = darkMode ? '#9ca3af' : '#6b7280';\n  const accent = darkMode ? '#60a5fa' : '#3b82f6';\n  const mutedBg = darkMode ? '#111827' : '#f9fafb';\n  const warningBg = darkMode ? '#78350f' : '#fef3c7';\n  const warningText = darkMode ? '#fde68a' : '#92400e';\n  const secondaryBg = darkMode ? '#374151' : '#f3f4f6';\n  const secondaryText = darkMode ? '#d1d5db' : '#374151';\n  const secondaryBorder = darkMode ? '#4b5563' : '#d1d5db';\n\n  const styles = {\n    container: {\n      width: '100%',\n    } as React.CSSProperties,\n    card: {\n      border: `1px solid ${border}`,\n      borderRadius: '12px',\n      padding: '2rem',\n      background: bg,\n      boxShadow: '0 1px 3px rgba(0, 0, 0, 0.1)',\n    } as React.CSSProperties,\n    header: {\n      display: 'flex',\n      justifyContent: 'space-between',\n      alignItems: 'flex-start',\n      marginBottom: '1.5rem',\n    } as React.CSSProperties,\n    info: {\n      flex: 1,\n    } as React.CSSProperties,\n    planName: {\n      fontSize: '1.5rem',\n      fontWeight: 700,\n      color: text,\n      margin: '0 0 0.5rem 0',\n    } as React.CSSProperties,\n    details: {\n      display: 'flex',\n      alignItems: 'baseline',\n      gap: '0.25rem',\n    } as React.CSSProperties,\n    amount: {\n      fontSize: '1.25rem',\n      fontWeight: 600,\n      color: accent,\n    } as React.CSSProperties,\n    interval: {\n      fontSize: '1rem',\n      color: textMuted,\n    } as React.CSSProperties,\n    statusBadge: {\n      padding: '0.5rem 1rem',\n      borderRadius: '20px',\n      color: 'white',\n      fontSize: '0.875rem',\n      fontWeight: 600,\n    } as React.CSSProperties,\n    dates: {\n      marginBottom: '2rem',\n      padding: '1rem',\n      background: mutedBg,\n      borderRadius: '8px',\n    } as React.CSSProperties,\n    dateLabel: {\n      fontSize: '0.875rem',\n      color: textMuted,\n      fontWeight: 500,\n    } as React.CSSProperties,\n    dateValue: {\n      fontSize: '0.875rem',\n      color: text,\n    } as React.CSSProperties,\n    cancellationNotice: {\n      display: 'flex',\n      alignItems: 'center',\n      gap: '0.5rem',\n      marginTop: '1rem',\n      padding: '0.75rem',\n      background: warningBg,\n      borderRadius: '6px',\n      fontSize: '0.875rem',\n      color: warningText,\n    } as React.CSSProperties,\n    actions: {\n      display: 'flex',\n      gap: '1rem',\n      flexWrap: 'wrap' as const,\n    } as React.CSSProperties,\n    button: {\n      padding: '0.75rem 1.5rem',\n      border: 'none',\n      borderRadius: '8px',\n      fontWeight: 600,\n      fontSize: '0.875rem',\n      cursor: 'pointer',\n      transition: 'all 0.3s ease',\n      flex: 1,\n      minWidth: '120px',\n      minHeight: '44px',\n    } as React.CSSProperties,\n    buttonPrimary: {\n      background: accent,\n      color: 'white',\n    } as React.CSSProperties,\n    buttonSecondary: {\n      background: secondaryBg,\n      color: secondaryText,\n      border: `1px solid ${secondaryBorder}`,\n    } as React.CSSProperties,\n    buttonDanger: {\n      background: '#ef4444',\n      color: 'white',\n    } as React.CSSProperties,\n    buttonDisabled: {\n      opacity: 0.6,\n      cursor: 'not-allowed',\n    } as React.CSSProperties,\n  };\n\n  return (\n    <div\n      style={styles.container}\n      className={className}\n      role=\"region\"\n      aria-label=\"Subscription management\"\n    >\n      <div style={styles.card}>\n        <div style={styles.header}>\n          <div style={styles.info}>\n            <h3 style={styles.planName} id=\"subscription-plan-name\">\n              {subscription.planName}\n            </h3>\n            <div style={styles.details}>\n              <span style={styles.amount}>\n                {formatAmount(subscription.amount, subscription.currency)}\n              </span>\n              <span style={styles.interval}>/{subscription.interval}</span>\n            </div>\n          </div>\n          <div>\n            <span\n              style={{\n                ...styles.statusBadge,\n                backgroundColor: getStatusColor(subscription.status),\n              }}\n              role=\"status\"\n              aria-label={`Subscription status: ${getStatusText(subscription.status)}`}\n            >\n              {getStatusText(subscription.status)}\n            </span>\n          </div>\n        </div>\n\n        <div style={styles.dates}>\n          <div>\n            <div style={styles.dateLabel}>Current period:</div>\n            <div style={styles.dateValue}>\n              {formatDate(subscription.currentPeriodStart)} -{' '}\n              {formatDate(subscription.currentPeriodEnd)}\n            </div>\n          </div>\n          {subscription.cancelAtPeriodEnd && (\n            <div style={styles.cancellationNotice} role=\"alert\">\n              <span aria-hidden=\"true\">⚠️</span>\n              <span>\n                Your subscription will be canceled at the end of the current\n                period.\n              </span>\n            </div>\n          )}\n        </div>\n\n        <div style={styles.actions}>\n          {subscription.status === 'active' &&\n            !subscription.cancelAtPeriodEnd && (\n              <>\n                <button\n                  style={{\n                    ...styles.button,\n                    ...styles.buttonSecondary,\n                    ...(loading ? styles.buttonDisabled : {}),\n                  }}\n                  onClick={() => handleAction('upgrade')}\n                  disabled={loading}\n                >\n                  {loading ? 'Loading...' : 'Upgrade Plan'}\n                </button>\n                <button\n                  style={{\n                    ...styles.button,\n                    ...styles.buttonSecondary,\n                    ...(loading ? styles.buttonDisabled : {}),\n                  }}\n                  onClick={() => handleAction('downgrade')}\n                  disabled={loading}\n                >\n                  {loading ? 'Loading...' : 'Downgrade Plan'}\n                </button>\n                <button\n                  style={{\n                    ...styles.button,\n                    ...styles.buttonDanger,\n                    ...(loading ? styles.buttonDisabled : {}),\n                  }}\n                  onClick={handleCancel}\n                  disabled={loading}\n                >\n                  {loading ? 'Loading...' : 'Cancel Subscription'}\n                </button>\n              </>\n            )}\n\n          {subscription.status === 'active' &&\n            subscription.cancelAtPeriodEnd && (\n              <button\n                style={{\n                  ...styles.button,\n                  ...styles.buttonPrimary,\n                  ...(loading ? styles.buttonDisabled : {}),\n                }}\n                onClick={() => handleAction('resume')}\n                disabled={loading}\n              >\n                {loading ? 'Loading...' : 'Resume Subscription'}\n              </button>\n            )}\n\n          {subscription.status === 'past_due' && (\n            <button\n              style={{\n                ...styles.button,\n                ...styles.buttonPrimary,\n                ...(loading ? styles.buttonDisabled : {}),\n              }}\n              onClick={() => handleAction('resume')}\n              disabled={loading}\n            >\n              {loading ? 'Loading...' : 'Update Payment Method'}\n            </button>\n          )}\n        </div>\n      </div>\n    </div>\n  );\n};\n","import React from 'react';\nimport { Subscription, SubscriptionStatus } from '../../shared/types';\nimport {\n  formatCurrency,\n  formatDate,\n  formatSubscriptionStatus,\n} from '../../shared/utils/formatting';\n\nexport interface SubscriptionCardProps {\n  subscription: Subscription;\n  onCancel?: (subscriptionId: string) => void;\n  onReactivate?: (subscriptionId: string) => void;\n  onUpdate?: (subscriptionId: string) => void;\n  className?: string;\n  showActions?: boolean;\n}\n\nexport const SubscriptionCard: React.FC<SubscriptionCardProps> = ({\n  subscription,\n  onCancel,\n  onReactivate,\n  onUpdate,\n  className = '',\n  showActions = true,\n}) => {\n  const getStatusColor = (status: SubscriptionStatus): string => {\n    switch (status) {\n      case SubscriptionStatus.ACTIVE:\n        return 'bg-green-100 text-green-800';\n      case SubscriptionStatus.TRIALING:\n        return 'bg-blue-100 text-blue-800';\n      case SubscriptionStatus.PAST_DUE:\n        return 'bg-yellow-100 text-yellow-800';\n      case SubscriptionStatus.CANCELED:\n        return 'bg-red-100 text-red-800';\n      default:\n        return 'bg-gray-100 text-gray-800';\n    }\n  };\n\n  const isActive =\n    subscription.status === SubscriptionStatus.ACTIVE ||\n    subscription.status === SubscriptionStatus.TRIALING;\n  const isCanceled = subscription.status === SubscriptionStatus.CANCELED;\n  const willCancel = subscription.cancelAtPeriodEnd;\n\n  return (\n    <div\n      className={`bg-white rounded-lg shadow-md border border-gray-200 p-6 ${className}`}\n    >\n      {/* Header */}\n      <div className=\"flex items-start justify-between mb-4\">\n        <div>\n          <h3 className=\"text-lg font-semibold text-gray-900\">\n            {subscription.planName || 'Subscription'}\n          </h3>\n          <div className=\"flex items-center mt-1\">\n            <span\n              className={`px-2 py-1 rounded-full text-xs font-medium ${getStatusColor(subscription.status)}`}\n            >\n              {formatSubscriptionStatus(subscription.status)}\n            </span>\n          </div>\n        </div>\n        <div className=\"text-right\">\n          <div className=\"text-2xl font-bold text-gray-900\">\n            {formatCurrency(subscription.amount || 0, subscription.currency)}\n          </div>\n          <div className=\"text-sm text-gray-500\">\n            per {subscription.interval}\n          </div>\n        </div>\n      </div>\n\n      {/* Details */}\n      <div className=\"space-y-3 mb-6\">\n        <div className=\"flex justify-between\">\n          <span className=\"text-sm text-gray-500\">Current Period:</span>\n          <span className=\"text-sm text-gray-900\">\n            {formatDate(subscription.currentPeriodStart)} -{' '}\n            {formatDate(subscription.currentPeriodEnd)}\n          </span>\n        </div>\n\n        <div className=\"flex justify-between\">\n          <span className=\"text-sm text-gray-500\">Next Billing:</span>\n          <span className=\"text-sm text-gray-900\">\n            {willCancel ? (\n              <span className=\"text-red-600\">\n                Cancels {formatDate(subscription.currentPeriodEnd)}\n              </span>\n            ) : (\n              formatDate(subscription.currentPeriodEnd)\n            )}\n          </span>\n        </div>\n\n        {subscription.trialEnd && (\n          <div className=\"flex justify-between\">\n            <span className=\"text-sm text-gray-500\">Trial Ends:</span>\n            <span className=\"text-sm text-gray-900\">\n              {formatDate(subscription.trialEnd)}\n            </span>\n          </div>\n        )}\n      </div>\n\n      {/* Warning Messages */}\n      {willCancel && (\n        <div className=\"bg-red-50 border border-red-200 rounded-lg p-3 mb-4\">\n          <div className=\"flex\">\n            <svg\n              className=\"w-5 h-5 text-red-400 mr-2 flex-shrink-0\"\n              fill=\"currentColor\"\n              viewBox=\"0 0 20 20\"\n            >\n              <path\n                fillRule=\"evenodd\"\n                d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\"\n                clipRule=\"evenodd\"\n              />\n            </svg>\n            <div>\n              <h4 className=\"text-sm font-medium text-red-800\">\n                Subscription will be canceled\n              </h4>\n              <p className=\"text-sm text-red-700 mt-1\">\n                Your subscription will end on{' '}\n                {formatDate(subscription.currentPeriodEnd)}. You'll retain\n                access until then.\n              </p>\n            </div>\n          </div>\n        </div>\n      )}\n\n      {subscription.status === SubscriptionStatus.PAST_DUE && (\n        <div className=\"bg-yellow-50 border border-yellow-200 rounded-lg p-3 mb-4\">\n          <div className=\"flex\">\n            <svg\n              className=\"w-5 h-5 text-yellow-400 mr-2 flex-shrink-0\"\n              fill=\"currentColor\"\n              viewBox=\"0 0 20 20\"\n            >\n              <path\n                fillRule=\"evenodd\"\n                d=\"M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z\"\n                clipRule=\"evenodd\"\n              />\n            </svg>\n            <div>\n              <h4 className=\"text-sm font-medium text-yellow-800\">\n                Payment failed\n              </h4>\n              <p className=\"text-sm text-yellow-700 mt-1\">\n                We couldn't process your payment. Please update your payment\n                method.\n              </p>\n            </div>\n          </div>\n        </div>\n      )}\n\n      {/* Actions */}\n      {showActions && (\n        <div className=\"flex flex-col sm:flex-row gap-2 pt-4 border-t border-gray-200\">\n          {isActive && !willCancel && (\n            <>\n              <button\n                onClick={() => onUpdate?.(subscription.id)}\n                className=\"flex-1 bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition-colors text-sm\"\n              >\n                Update Plan\n              </button>\n              <button\n                onClick={() => onCancel?.(subscription.id)}\n                className=\"flex-1 bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-4 rounded-lg transition-colors text-sm\"\n              >\n                Cancel\n              </button>\n            </>\n          )}\n\n          {willCancel && (\n            <button\n              onClick={() => onReactivate?.(subscription.id)}\n              className=\"w-full bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-lg transition-colors text-sm\"\n            >\n              Reactivate Subscription\n            </button>\n          )}\n\n          {isCanceled && (\n            <button\n              onClick={() => onUpdate?.(subscription.id)}\n              className=\"w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition-colors text-sm\"\n            >\n              Subscribe Again\n            </button>\n          )}\n\n          {subscription.status === SubscriptionStatus.PAST_DUE && (\n            <button\n              onClick={() => onUpdate?.(subscription.id)}\n              className=\"w-full bg-yellow-600 hover:bg-yellow-700 text-white font-medium py-2 px-4 rounded-lg transition-colors text-sm\"\n            >\n              Update Payment Method\n            </button>\n          )}\n        </div>\n      )}\n    </div>\n  );\n};\n\nexport default SubscriptionCard;\n","import React from 'react';\n\nexport interface Invoice {\n  id: string;\n  amount: number;\n  currency: string;\n  status: 'paid' | 'pending' | 'failed' | 'draft' | 'open';\n  date: Date;\n  description: string;\n  downloadUrl?: string;\n  invoiceNumber?: string;\n}\n\nexport interface BillingHistoryProps {\n  invoices: Invoice[];\n  loading?: boolean;\n  onInvoiceDownload?: (invoiceId: string) => void;\n  className?: string;\n}\n\nexport const BillingHistory: React.FC<BillingHistoryProps> = ({\n  invoices,\n  loading = false,\n  onInvoiceDownload,\n  className = '',\n}) => {\n  const formatDate = (date: Date) => {\n    return new Intl.DateTimeFormat('en-US', {\n      year: 'numeric',\n      month: 'short',\n      day: 'numeric',\n    }).format(date);\n  };\n\n  const formatAmount = (amount: number, currency: string) => {\n    return new Intl.NumberFormat('en-US', {\n      style: 'currency',\n      currency: currency.toUpperCase(),\n    }).format(amount / 100);\n  };\n\n  const getStatusColor = (status: Invoice['status']) => {\n    switch (status) {\n      case 'paid':\n        return '#10b981';\n      case 'pending':\n        return '#f59e0b';\n      case 'failed':\n        return '#ef4444';\n      case 'draft':\n        return '#6b7280';\n      case 'open':\n        return '#3b82f6';\n      default:\n        return '#6b7280';\n    }\n  };\n\n  const getStatusText = (status: Invoice['status']) => {\n    switch (status) {\n      case 'paid':\n        return 'Paid';\n      case 'pending':\n        return 'Pending';\n      case 'failed':\n        return 'Failed';\n      case 'draft':\n        return 'Draft';\n      case 'open':\n        return 'Open';\n      default:\n        return status;\n    }\n  };\n\n  const handleDownload = (invoice: Invoice) => {\n    if (onInvoiceDownload) {\n      onInvoiceDownload(invoice.id);\n    } else if (invoice.downloadUrl) {\n      window.open(invoice.downloadUrl, '_blank');\n    }\n  };\n\n  if (loading) {\n    return (\n      <div className={className} style={{ width: '100%' }}>\n        <div\n          style={{\n            display: 'flex',\n            flexDirection: 'column',\n            alignItems: 'center',\n            justifyContent: 'center',\n            padding: '3rem',\n            color: '#6b7280',\n          }}\n        >\n          <div\n            style={{\n              width: '2rem',\n              height: '2rem',\n              border: '2px solid #e5e7eb',\n              borderTop: '2px solid #3b82f6',\n              borderRadius: '50%',\n              animation: 'spin 1s linear infinite',\n              marginBottom: '1rem',\n            }}\n          ></div>\n          <p>Loading billing history...</p>\n        </div>\n      </div>\n    );\n  }\n\n  if (invoices.length === 0) {\n    return (\n      <div className={className} style={{ width: '100%' }}>\n        <div\n          style={{\n            textAlign: 'center',\n            padding: '3rem',\n            color: '#6b7280',\n          }}\n        >\n          <div style={{ fontSize: '3rem', marginBottom: '1rem' }}>📄</div>\n          <h3\n            style={{\n              fontSize: '1.25rem',\n              fontWeight: 600,\n              color: '#374151',\n              margin: '0 0 0.5rem 0',\n            }}\n          >\n            No billing history\n          </h3>\n          <p style={{ margin: 0 }}>\n            Your invoices will appear here once you start making payments.\n          </p>\n        </div>\n      </div>\n    );\n  }\n\n  return (\n    <div className={className} style={{ width: '100%' }}>\n      <div style={{ marginBottom: '2rem' }}>\n        <h2\n          style={{\n            fontSize: '1.5rem',\n            fontWeight: 700,\n            color: '#1f2937',\n            margin: '0 0 0.5rem 0',\n          }}\n        >\n          Billing History\n        </h2>\n        <p style={{ color: '#6b7280', margin: 0 }}>\n          View and download your past invoices\n        </p>\n      </div>\n\n      <div\n        style={{\n          border: '1px solid #e5e7eb',\n          borderRadius: '12px',\n          overflow: 'hidden',\n          background: 'white',\n        }}\n      >\n        <div\n          style={{\n            display: 'grid',\n            gridTemplateColumns: '120px 1fr 120px 100px 120px',\n            background: '#f9fafb',\n            borderBottom: '1px solid #e5e7eb',\n          }}\n        >\n          <div\n            style={{\n              padding: '1rem',\n              fontWeight: 600,\n              color: '#374151',\n              fontSize: '0.875rem',\n            }}\n          >\n            Date\n          </div>\n          <div\n            style={{\n              padding: '1rem',\n              fontWeight: 600,\n              color: '#374151',\n              fontSize: '0.875rem',\n            }}\n          >\n            Description\n          </div>\n          <div\n            style={{\n              padding: '1rem',\n              fontWeight: 600,\n              color: '#374151',\n              fontSize: '0.875rem',\n            }}\n          >\n            Amount\n          </div>\n          <div\n            style={{\n              padding: '1rem',\n              fontWeight: 600,\n              color: '#374151',\n              fontSize: '0.875rem',\n            }}\n          >\n            Status\n          </div>\n          <div\n            style={{\n              padding: '1rem',\n              fontWeight: 600,\n              color: '#374151',\n              fontSize: '0.875rem',\n            }}\n          >\n            Actions\n          </div>\n        </div>\n\n        <div>\n          {invoices.map(invoice => (\n            <div\n              key={invoice.id}\n              style={{\n                display: 'grid',\n                gridTemplateColumns: '120px 1fr 120px 100px 120px',\n                borderBottom: '1px solid #f3f4f6',\n              }}\n            >\n              <div\n                style={{\n                  padding: '1rem',\n                  display: 'flex',\n                  alignItems: 'center',\n                  fontSize: '0.875rem',\n                  color: '#6b7280',\n                }}\n              >\n                {formatDate(invoice.date)}\n              </div>\n              <div\n                style={{\n                  padding: '1rem',\n                  display: 'flex',\n                  flexDirection: 'column',\n                  alignItems: 'flex-start',\n                  fontSize: '0.875rem',\n                }}\n              >\n                <span style={{ color: '#1f2937', fontWeight: 500 }}>\n                  {invoice.description}\n                </span>\n                {invoice.invoiceNumber && (\n                  <span style={{ color: '#6b7280', fontSize: '0.75rem' }}>\n                    #{invoice.invoiceNumber}\n                  </span>\n                )}\n              </div>\n              <div\n                style={{\n                  padding: '1rem',\n                  display: 'flex',\n                  alignItems: 'center',\n                  fontSize: '0.875rem',\n                  fontWeight: 600,\n                  color: '#1f2937',\n                }}\n              >\n                {formatAmount(invoice.amount, invoice.currency)}\n              </div>\n              <div\n                style={{\n                  padding: '1rem',\n                  display: 'flex',\n                  alignItems: 'center',\n                  fontSize: '0.875rem',\n                }}\n              >\n                <span\n                  style={{\n                    padding: '0.25rem 0.75rem',\n                    borderRadius: '12px',\n                    color: 'white',\n                    fontSize: '0.75rem',\n                    fontWeight: 600,\n                    textTransform: 'uppercase',\n                    backgroundColor: getStatusColor(invoice.status),\n                  }}\n                >\n                  {getStatusText(invoice.status)}\n                </span>\n              </div>\n              <div\n                style={{\n                  padding: '1rem',\n                  display: 'flex',\n                  alignItems: 'center',\n                  fontSize: '0.875rem',\n                }}\n              >\n                {(invoice.downloadUrl || onInvoiceDownload) &&\n                  invoice.status === 'paid' && (\n                    <button\n                      style={{\n                        display: 'flex',\n                        alignItems: 'center',\n                        gap: '0.5rem',\n                        padding: '0.5rem 1rem',\n                        border: '1px solid #d1d5db',\n                        borderRadius: '6px',\n                        background: 'white',\n                        color: '#374151',\n                        fontSize: '0.75rem',\n                        fontWeight: 500,\n                        cursor: 'pointer',\n                      }}\n                      onClick={() => handleDownload(invoice)}\n                      title=\"Download invoice\"\n                    >\n                      <span>⬇️</span>\n                      Download\n                    </button>\n                  )}\n              </div>\n            </div>\n          ))}\n        </div>\n      </div>\n    </div>\n  );\n};\n","import React, { useState } from 'react';\n\nexport interface PaymentMethod {\n  id: string;\n  type: 'card' | 'bank_account';\n  last4: string;\n  brand?: string;\n  expiryMonth?: number;\n  expiryYear?: number;\n  isDefault: boolean;\n  bankName?: string;\n  accountType?: 'checking' | 'savings';\n}\n\nexport interface PaymentMethodsProps {\n  paymentMethods: PaymentMethod[];\n  onAdd: () => void;\n  onEdit: (methodId: string) => void;\n  onDelete: (methodId: string) => void;\n  onSetDefault: (methodId: string) => void;\n  className?: string;\n  loading?: boolean;\n}\n\nexport const PaymentMethods: React.FC<PaymentMethodsProps> = ({\n  paymentMethods,\n  onAdd,\n  onEdit,\n  onDelete,\n  onSetDefault,\n  className = '',\n  loading = false,\n}) => {\n  const [actionLoading, setActionLoading] = useState<string | null>(null);\n\n  const getCardIcon = (brand?: string) => {\n    switch (brand?.toLowerCase()) {\n      case 'visa':\n        return '💳';\n      case 'mastercard':\n        return '💳';\n      case 'amex':\n      case 'american_express':\n        return '💳';\n      case 'discover':\n        return '💳';\n      default:\n        return '💳';\n    }\n  };\n\n  const getBankIcon = () => {\n    return '🏦';\n  };\n\n  const formatCardBrand = (brand?: string) => {\n    if (!brand) return 'Card';\n    return brand.charAt(0).toUpperCase() + brand.slice(1).toLowerCase();\n  };\n\n  const formatExpiry = (month?: number, year?: number) => {\n    if (!month || !year) return '';\n    return `${month.toString().padStart(2, '0')}/${year.toString().slice(-2)}`;\n  };\n\n  const handleAction = async (action: () => void, methodId?: string) => {\n    if (methodId) {\n      setActionLoading(methodId);\n    }\n    try {\n      await action();\n    } finally {\n      setActionLoading(null);\n    }\n  };\n\n  if (loading) {\n    return (\n      <div className={className} style={{ width: '100%' }}>\n        <div\n          style={{\n            display: 'flex',\n            flexDirection: 'column',\n            alignItems: 'center',\n            justifyContent: 'center',\n            padding: '3rem',\n            color: '#6b7280',\n          }}\n        >\n          <div\n            style={{\n              width: '2rem',\n              height: '2rem',\n              border: '2px solid #e5e7eb',\n              borderTop: '2px solid #3b82f6',\n              borderRadius: '50%',\n              animation: 'spin 1s linear infinite',\n              marginBottom: '1rem',\n            }}\n          ></div>\n          <p>Loading payment methods...</p>\n        </div>\n      </div>\n    );\n  }\n\n  return (\n    <div className={className} style={{ width: '100%' }}>\n      <div\n        style={{\n          display: 'flex',\n          justifyContent: 'space-between',\n          alignItems: 'center',\n          marginBottom: '2rem',\n        }}\n      >\n        <h2\n          style={{\n            fontSize: '1.5rem',\n            fontWeight: 700,\n            color: '#1f2937',\n            margin: 0,\n          }}\n        >\n          Payment Methods\n        </h2>\n        <button\n          style={{\n            display: 'flex',\n            alignItems: 'center',\n            gap: '0.5rem',\n            padding: '0.75rem 1.5rem',\n            background: '#3b82f6',\n            color: 'white',\n            border: 'none',\n            borderRadius: '8px',\n            fontWeight: 600,\n            fontSize: '0.875rem',\n            cursor: 'pointer',\n            transition: 'all 0.3s ease',\n          }}\n          onClick={() => handleAction(onAdd)}\n        >\n          <span style={{ fontSize: '1.25rem', fontWeight: 'bold' }}>+</span>\n          Add Payment Method\n        </button>\n      </div>\n\n      {paymentMethods.length === 0 ? (\n        <div\n          style={{\n            textAlign: 'center',\n            padding: '3rem',\n            border: '2px dashed #e5e7eb',\n            borderRadius: '12px',\n            color: '#6b7280',\n          }}\n        >\n          <div style={{ fontSize: '3rem', marginBottom: '1rem' }}>💳</div>\n          <h3\n            style={{\n              fontSize: '1.25rem',\n              fontWeight: 600,\n              color: '#374151',\n              margin: '0 0 0.5rem 0',\n            }}\n          >\n            No payment methods\n          </h3>\n          <p style={{ margin: '0 0 2rem 0' }}>\n            Add a payment method to start making payments.\n          </p>\n          <button\n            style={{\n              padding: '1rem 2rem',\n              background: '#3b82f6',\n              color: 'white',\n              border: 'none',\n              borderRadius: '8px',\n              fontWeight: 600,\n              fontSize: '1rem',\n              cursor: 'pointer',\n              transition: 'all 0.3s ease',\n            }}\n            onClick={() => handleAction(onAdd)}\n          >\n            Add Your First Payment Method\n          </button>\n        </div>\n      ) : (\n        <div\n          style={{\n            display: 'grid',\n            gridTemplateColumns: 'repeat(auto-fill, minmax(350px, 1fr))',\n            gap: '1.5rem',\n          }}\n        >\n          {paymentMethods.map(method => (\n            <div\n              key={method.id}\n              style={{\n                border: method.isDefault\n                  ? '2px solid #10b981'\n                  : '2px solid #e5e7eb',\n                borderRadius: '12px',\n                padding: '1.5rem',\n                background: method.isDefault ? '#f0fdf4' : 'white',\n                position: 'relative',\n                transition: 'all 0.3s ease',\n              }}\n            >\n              {method.isDefault && (\n                <div\n                  style={{\n                    position: 'absolute',\n                    top: '-8px',\n                    right: '1rem',\n                    background: '#10b981',\n                    color: 'white',\n                    padding: '0.25rem 0.75rem',\n                    borderRadius: '12px',\n                    fontSize: '0.75rem',\n                    fontWeight: 600,\n                  }}\n                >\n                  Default\n                </div>\n              )}\n\n              <div\n                style={{\n                  display: 'flex',\n                  alignItems: 'flex-start',\n                  gap: '1rem',\n                  marginBottom: '1.5rem',\n                }}\n              >\n                <div style={{ fontSize: '2rem', flexShrink: 0 }}>\n                  {method.type === 'card'\n                    ? getCardIcon(method.brand)\n                    : getBankIcon()}\n                </div>\n                <div style={{ flex: 1 }}>\n                  {method.type === 'card' ? (\n                    <>\n                      <div\n                        style={{\n                          fontSize: '1rem',\n                          fontWeight: 600,\n                          color: '#1f2937',\n                          marginBottom: '0.25rem',\n                        }}\n                      >\n                        {formatCardBrand(method.brand)} •••• {method.last4}\n                      </div>\n                      {method.expiryMonth && method.expiryYear && (\n                        <div\n                          style={{\n                            fontSize: '0.875rem',\n                            color: '#6b7280',\n                          }}\n                        >\n                          Expires{' '}\n                          {formatExpiry(method.expiryMonth, method.expiryYear)}\n                        </div>\n                      )}\n                    </>\n                  ) : (\n                    <>\n                      <div\n                        style={{\n                          fontSize: '1rem',\n                          fontWeight: 600,\n                          color: '#1f2937',\n                          marginBottom: '0.25rem',\n                        }}\n                      >\n                        {method.bankName || 'Bank Account'} •••• {method.last4}\n                      </div>\n                      <div\n                        style={{\n                          fontSize: '0.875rem',\n                          color: '#6b7280',\n                        }}\n                      >\n                        {method.accountType\n                          ? method.accountType.charAt(0).toUpperCase() +\n                            method.accountType.slice(1)\n                          : 'Bank Account'}\n                      </div>\n                    </>\n                  )}\n                </div>\n              </div>\n\n              <div\n                style={{\n                  display: 'flex',\n                  gap: '0.75rem',\n                  flexWrap: 'wrap',\n                }}\n              >\n                {!method.isDefault && (\n                  <button\n                    style={{\n                      padding: '0.5rem 1rem',\n                      border: '1px solid #d1d5db',\n                      borderRadius: '6px',\n                      background: '#f3f4f6',\n                      color: '#374151',\n                      fontWeight: 500,\n                      fontSize: '0.875rem',\n                      cursor: 'pointer',\n                      transition: 'all 0.2s ease',\n                      flex: 1,\n                      minWidth: '80px',\n                      opacity: actionLoading === method.id ? 0.6 : 1,\n                    }}\n                    onClick={() =>\n                      handleAction(() => onSetDefault(method.id), method.id)\n                    }\n                    disabled={actionLoading === method.id}\n                  >\n                    {actionLoading === method.id\n                      ? 'Loading...'\n                      : 'Set as Default'}\n                  </button>\n                )}\n                <button\n                  style={{\n                    padding: '0.5rem 1rem',\n                    border: '1px solid #d1d5db',\n                    borderRadius: '6px',\n                    background: '#f3f4f6',\n                    color: '#374151',\n                    fontWeight: 500,\n                    fontSize: '0.875rem',\n                    cursor: 'pointer',\n                    transition: 'all 0.2s ease',\n                    flex: 1,\n                    minWidth: '80px',\n                    opacity: actionLoading === method.id ? 0.6 : 1,\n                  }}\n                  onClick={() =>\n                    handleAction(() => onEdit(method.id), method.id)\n                  }\n                  disabled={actionLoading === method.id}\n                >\n                  {actionLoading === method.id ? 'Loading...' : 'Edit'}\n                </button>\n                <button\n                  style={{\n                    padding: '0.5rem 1rem',\n                    border: 'none',\n                    borderRadius: '6px',\n                    background: '#ef4444',\n                    color: 'white',\n                    fontWeight: 500,\n                    fontSize: '0.875rem',\n                    cursor: 'pointer',\n                    transition: 'all 0.2s ease',\n                    flex: 1,\n                    minWidth: '80px',\n                    opacity: actionLoading === method.id ? 0.6 : 1,\n                  }}\n                  onClick={() =>\n                    handleAction(() => onDelete(method.id), method.id)\n                  }\n                  disabled={actionLoading === method.id}\n                >\n                  {actionLoading === method.id ? 'Loading...' : 'Delete'}\n                </button>\n              </div>\n            </div>\n          ))}\n        </div>\n      )}\n    </div>\n  );\n};\n","import React from 'react';\nimport { loadStripe, Stripe, StripeElementLocale } from '@stripe/stripe-js';\nimport { Elements } from '@stripe/react-stripe-js';\nimport { usePaymentsContext } from '../../shared/providers/PaymentsProvider';\nimport { ERROR_MESSAGES } from '../../shared/constants';\n\ninterface StripeProviderProps {\n  children: React.ReactNode;\n  options?: {\n    fonts?: Array<{\n      cssSrc: string;\n    }>;\n    locale?: string;\n    apiVersion?: string;\n  };\n}\n\nlet stripePromise: Promise<Stripe | null> | null = null;\n\nconst getStripe = (publishableKey: string): Promise<Stripe | null> => {\n  if (!stripePromise) {\n    stripePromise = loadStripe(publishableKey);\n  }\n  return stripePromise;\n};\n\nexport const StripeProvider: React.FC<StripeProviderProps> = ({\n  children,\n  options = {},\n}) => {\n  const { config, initialized } = usePaymentsContext();\n\n  const stripe = React.useMemo(() => {\n    if (!initialized || !config?.publishableKey) {\n      if (initialized && !config) {\n        console.error(ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED);\n      }\n      return null;\n    }\n    return getStripe(config.publishableKey);\n  }, [config, initialized]);\n\n  if (!initialized || !config) {\n    if (config?.environment === 'development') {\n      return (\n        <div\n          style={{\n            padding: '20px',\n            backgroundColor: '#fee',\n            border: '1px solid #fcc',\n            borderRadius: '4px',\n            margin: '10px',\n            fontFamily: 'monospace',\n          }}\n        >\n          <strong>Payments Provider Error:</strong>\n          <br />\n          {ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED}\n          <br />\n          Please check your PaymentsProvider configuration.\n        </div>\n      );\n    }\n    return null;\n  }\n\n  const elementsOptions = {\n    fonts: options.fonts,\n    locale: options.locale as StripeElementLocale,\n    appearance: {\n      theme: 'stripe' as const,\n    },\n  };\n\n  return (\n    <Elements stripe={stripe} options={elementsOptions}>\n      {children}\n    </Elements>\n  );\n};\n\nexport default StripeProvider;\n","import { useState, useEffect, useCallback } from 'react';\nimport {\n  Customer,\n  CustomerCreateParams,\n  Subscription,\n  SubscriptionUpdateParams,\n  SubscriptionStatus,\n  CheckoutParams,\n  CheckoutSession,\n} from '../types';\nimport { PaymentsConfig } from '../types/config';\nimport { PaymentProviderFactory } from '../../providers';\nimport { PaymentsError, PaymentErrorType } from '../types/errors';\nimport { ERROR_MESSAGES } from '../constants';\nimport { PaymentProvider } from '../types/provider';\n\ninterface UsePaymentsStore {\n  config: PaymentsConfig | null;\n  provider: PaymentProvider | null;\n  initialized: boolean;\n  loading: boolean;\n  error: PaymentsError | null;\n  // Backward compatibility getters\n  isLoading: boolean; // Maps to loading\n  isError: boolean; // Maps to !!error\n  customer: Customer | null;\n  subscriptions: Subscription[];\n  activeSubscription: Subscription | null;\n  initialize: (config?: PaymentsConfig) => Promise<void>;\n  createCustomer: (params: CustomerCreateParams) => Promise<Customer>;\n  retrieveCustomer: (customerId: string) => Promise<Customer | null>;\n  createCheckoutSession: (params: CheckoutParams) => Promise<CheckoutSession>;\n  retrieveCheckoutSession: (sessionId: string) => Promise<CheckoutSession>;\n  createSubscription: (params: {\n    priceId: string;\n    quantity?: number;\n  }) => Promise<Subscription>;\n  cancelSubscription: (subscriptionId: string) => Promise<void>;\n  reactivateSubscription: (subscriptionId: string) => Promise<void>;\n  listSubscriptions: (\n    customerId: string,\n    status?: SubscriptionStatus\n  ) => Promise<Subscription[]>;\n  retrieveSubscription: (\n    subscriptionId: string\n  ) => Promise<Subscription | null>;\n  updateSubscription: (\n    subscriptionId: string,\n    params: SubscriptionUpdateParams\n  ) => Promise<Subscription>;\n  refreshCustomer: (customerId: string) => Promise<void>;\n  refreshSubscriptions: (\n    customerId: string,\n    status?: SubscriptionStatus\n  ) => Promise<void>;\n  reset: () => void;\n}\n\nexport const usePayments = (): UsePaymentsStore => {\n  const [config, setConfig] = useState<PaymentsConfig | null>(null);\n  const [provider, setProvider] = useState<PaymentProvider | null>(null);\n  const [initialized, setInitialized] = useState(false);\n  const [loading, setLoading] = useState(false);\n  const [error, setError] = useState<PaymentsError | null>(null);\n  const [customer, setCustomer] = useState<Customer | null>(null);\n  const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);\n\n  const handleError = useCallback((err: PaymentsError) => {\n    setError(err);\n    console.error('Payments error:', err);\n  }, []);\n\n  const refreshSubscriptions = useCallback(\n    async (customerId: string, status?: SubscriptionStatus) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const fetchedSubscriptions = await provider.listSubscriptions(\n          customerId,\n          status\n        );\n        setSubscriptions(fetchedSubscriptions);\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, handleError]\n  );\n\n  const initialize = useCallback(\n    async (initialConfig?: PaymentsConfig) => {\n      setLoading(true);\n      setError(null);\n      try {\n        const resolvedConfig =\n          initialConfig || PaymentProviderFactory.autodetect();\n        const newProvider = PaymentProviderFactory.create(resolvedConfig);\n        setConfig(resolvedConfig);\n        setProvider(newProvider);\n        setInitialized(true);\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n      } finally {\n        setLoading(false);\n      }\n    },\n    [handleError]\n  );\n\n  const retrieveCustomer = useCallback(\n    async (customerId: string) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const newCustomer = await provider.retrieveCustomer(customerId);\n        setCustomer(newCustomer);\n        return newCustomer;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, handleError]\n  );\n\n  const createCustomer = useCallback(\n    async (params: CustomerCreateParams) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const newCustomer = await provider.createCustomer(params);\n        setCustomer(newCustomer);\n        return newCustomer;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, handleError]\n  );\n\n  const createSubscription = useCallback(\n    async (params: { priceId: string; quantity?: number }) => {\n      if (!provider || !customer) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const newSubscription = await provider.createSubscription({\n          customerId: customer.id,\n          items: [{ priceId: params.priceId, quantity: params.quantity }],\n        });\n        await refreshSubscriptions(customer.id);\n        return newSubscription;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, customer, handleError, refreshSubscriptions]\n  );\n\n  const listSubscriptions = useCallback(\n    async (customerId: string, status?: SubscriptionStatus) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const subs = await provider.listSubscriptions(customerId, status);\n        setSubscriptions(subs);\n        return subs;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, handleError]\n  );\n\n  const retrieveSubscription = useCallback(\n    async (subscriptionId: string) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const sub = await provider.retrieveSubscription(subscriptionId);\n        // Optionally refresh the list of subscriptions\n        if (customer?.id) {\n          await refreshSubscriptions(customer.id);\n        }\n        return sub;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, customer, handleError, refreshSubscriptions]\n  );\n\n  const createCheckoutSession = useCallback(\n    async (params: CheckoutParams) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const session = await provider.createCheckoutSession(params);\n        return session;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, handleError]\n  );\n\n  const retrieveCheckoutSession = useCallback(\n    async (sessionId: string) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const session = await provider.retrieveCheckoutSession(sessionId);\n        return session;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, handleError]\n  );\n\n  const cancelSubscription = useCallback(\n    async (subscriptionId: string) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        await provider.cancelSubscription(subscriptionId);\n        // Refresh subscriptions after cancellation\n        if (customer?.id) {\n          await refreshSubscriptions(customer.id);\n        }\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, customer, handleError, refreshSubscriptions]\n  );\n\n  const reactivateSubscription = useCallback(\n    async (subscriptionId: string) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        await provider.reactivateSubscription(subscriptionId);\n        // Refresh subscriptions after reactivation\n        if (customer?.id) {\n          await refreshSubscriptions(customer.id);\n        }\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, customer, handleError, refreshSubscriptions]\n  );\n\n  const updateSubscription = useCallback(\n    async (subscriptionId: string, params: SubscriptionUpdateParams) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const updatedSubscription = await provider.updateSubscription(\n          subscriptionId,\n          params\n        );\n        // Refresh subscriptions after update\n        if (customer?.id) {\n          await refreshSubscriptions(customer.id);\n        }\n        return updatedSubscription;\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, customer, handleError, refreshSubscriptions]\n  );\n\n  const refreshCustomer = useCallback(\n    async (customerId: string) => {\n      if (!provider) {\n        throw new PaymentsError(\n          PaymentErrorType.PROVIDER_NOT_CONFIGURED,\n          ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED\n        );\n      }\n      setLoading(true);\n      setError(null);\n      try {\n        const fetchedCustomer = await provider.retrieveCustomer(customerId);\n        setCustomer(fetchedCustomer);\n      } catch (err: unknown) {\n        handleError(err as PaymentsError);\n        throw err;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [provider, handleError]\n  );\n\n  const reset = useCallback(() => {\n    setConfig(null);\n    setProvider(null);\n    setInitialized(false);\n    setLoading(false);\n    setError(null);\n    setCustomer(null);\n    setSubscriptions([]);\n  }, []);\n\n  const activeSubscription =\n    subscriptions.find(s => s.status === 'active' || s.status === 'trialing') ||\n    null;\n\n  // Initial fetch for customer and subscriptions if a customerId is provided\n  useEffect(() => {\n    // This useEffect should be triggered by the PaymentsProvider, not directly here\n    // The PaymentsProvider will call `initialize` with the config.\n    // If a customer ID is available in the config or passed to initialize,\n    // then refreshCustomer and refreshSubscriptions can be called.\n    // For now, removing the auto-fetch logic from here to avoid circular dependencies\n    // and to align with the PaymentsProvider's role in initialization.\n  }, []);\n\n  return {\n    config,\n    provider,\n    initialized,\n    loading,\n    error,\n    // Backward compatibility getters\n    isLoading: loading,\n    isError: !!error,\n    customer,\n    subscriptions,\n    activeSubscription,\n    initialize,\n    createCustomer,\n    retrieveCustomer,\n    createCheckoutSession,\n    retrieveCheckoutSession,\n    createSubscription,\n    cancelSubscription,\n    reactivateSubscription,\n    listSubscriptions,\n    retrieveSubscription,\n    updateSubscription,\n    refreshCustomer,\n    refreshSubscriptions,\n    reset,\n  };\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { Subscription } from '../../shared/types';\nimport { ERROR_MESSAGES } from '../../shared/constants';\nimport { validateStripeId } from '../../shared/utils/validation';\n\ninterface UseSubscriptionOptions {\n  customerId?: string;\n  subscriptionId?: string;\n  autoFetch?: boolean;\n  onError?: (error: string) => void;\n}\n\ninterface UseSubscriptionReturn {\n  subscription: Subscription | null;\n  subscriptions: Subscription[];\n  loading: boolean;\n  error: string | null;\n  // Backward compatibility getters\n  isLoading: boolean; // Maps to loading\n  isError: boolean; // Maps to !!error\n  refetch: () => Promise<void>;\n  cancel: (subscriptionId?: string) => Promise<boolean>;\n  reactivate: (subscriptionId?: string) => Promise<boolean>;\n  updatePaymentMethod: (\n    subscriptionId: string,\n    paymentMethodId: string\n  ) => Promise<boolean>;\n}\n\nexport const useSubscription = (\n  options: UseSubscriptionOptions = {}\n): UseSubscriptionReturn => {\n  const { customerId, subscriptionId, autoFetch = true, onError } = options;\n\n  const [subscription, setSubscription] = useState<Subscription | null>(null);\n  const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);\n  const [loading, setLoading] = useState(false);\n  const [error, setError] = useState<string | null>(null);\n\n  const handleError = useCallback(\n    (errorMessage: string) => {\n      setError(errorMessage);\n      onError?.(errorMessage);\n      console.error('Subscription error:', errorMessage);\n    },\n    [onError]\n  );\n\n  const fetchSubscription = useCallback(\n    async (id: string) => {\n      if (!validateStripeId(id, 'subscription')) {\n        handleError('Invalid subscription ID');\n        return null;\n      }\n\n      try {\n        const response = await fetch(`/api/payments/subscription/${id}`);\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(\n            errorData.error || ERROR_MESSAGES.SUBSCRIPTION_NOT_FOUND\n          );\n        }\n\n        const data = await response.json();\n        return data;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : ERROR_MESSAGES.SUBSCRIPTION_NOT_FOUND;\n        handleError(errorMessage);\n        return null;\n      }\n    },\n    [handleError]\n  );\n\n  const fetchCustomerSubscriptions = useCallback(\n    async (id: string) => {\n      if (!validateStripeId(id, 'customer')) {\n        handleError('Invalid customer ID');\n        return [];\n      }\n\n      try {\n        const response = await fetch(\n          `/api/payments/customer/${id}/subscriptions`\n        );\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || ERROR_MESSAGES.CUSTOMER_NOT_FOUND);\n        }\n\n        const data = await response.json();\n        return data.subscriptions || [];\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : ERROR_MESSAGES.CUSTOMER_NOT_FOUND;\n        handleError(errorMessage);\n        return [];\n      }\n    },\n    [handleError]\n  );\n\n  const refetch = useCallback(async () => {\n    if (!customerId && !subscriptionId) {\n      handleError('Either customerId or subscriptionId is required');\n      return;\n    }\n\n    setLoading(true);\n    setError(null);\n\n    try {\n      if (subscriptionId) {\n        const sub = await fetchSubscription(subscriptionId);\n        setSubscription(sub);\n      }\n\n      if (customerId) {\n        const subs = await fetchCustomerSubscriptions(customerId);\n        setSubscriptions(subs);\n\n        // If no specific subscription ID, set the first active subscription\n        if (!subscriptionId && subs.length > 0) {\n          const activeSub =\n            subs.find((s: Subscription) => s.status === 'active') || subs[0];\n          setSubscription(activeSub);\n        }\n      }\n    } finally {\n      setLoading(false);\n    }\n  }, [\n    customerId,\n    subscriptionId,\n    fetchSubscription,\n    fetchCustomerSubscriptions,\n    handleError,\n  ]);\n\n  const cancel = useCallback(\n    async (targetSubscriptionId?: string): Promise<boolean> => {\n      const idToCancel = targetSubscriptionId || subscriptionId;\n\n      if (!idToCancel) {\n        handleError('Subscription ID is required to cancel');\n        return false;\n      }\n\n      if (!validateStripeId(idToCancel, 'subscription')) {\n        handleError('Invalid subscription ID');\n        return false;\n      }\n\n      try {\n        const response = await fetch(\n          `/api/payments/subscription/${idToCancel}/cancel`,\n          {\n            method: 'POST',\n            headers: { 'Content-Type': 'application/json' },\n          }\n        );\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || 'Failed to cancel subscription');\n        }\n\n        await refetch(); // Refresh data\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error ? err.message : 'Failed to cancel subscription';\n        handleError(errorMessage);\n        return false;\n      }\n    },\n    [subscriptionId, refetch, handleError]\n  );\n\n  const reactivate = useCallback(\n    async (targetSubscriptionId?: string): Promise<boolean> => {\n      const idToReactivate = targetSubscriptionId || subscriptionId;\n\n      if (!idToReactivate) {\n        handleError('Subscription ID is required to reactivate');\n        return false;\n      }\n\n      if (!validateStripeId(idToReactivate, 'subscription')) {\n        handleError('Invalid subscription ID');\n        return false;\n      }\n\n      try {\n        const response = await fetch(\n          `/api/payments/subscription/${idToReactivate}/reactivate`,\n          {\n            method: 'POST',\n            headers: { 'Content-Type': 'application/json' },\n          }\n        );\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(\n            errorData.error || 'Failed to reactivate subscription'\n          );\n        }\n\n        await refetch(); // Refresh data\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : 'Failed to reactivate subscription';\n        handleError(errorMessage);\n        return false;\n      }\n    },\n    [subscriptionId, refetch, handleError]\n  );\n\n  const updatePaymentMethod = useCallback(\n    async (\n      targetSubscriptionId: string,\n      paymentMethodId: string\n    ): Promise<boolean> => {\n      if (!validateStripeId(targetSubscriptionId, 'subscription')) {\n        handleError('Invalid subscription ID');\n        return false;\n      }\n\n      try {\n        const response = await fetch(\n          `/api/payments/subscription/${targetSubscriptionId}/payment-method`,\n          {\n            method: 'PUT',\n            headers: { 'Content-Type': 'application/json' },\n            body: JSON.stringify({ paymentMethodId }),\n          }\n        );\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || 'Failed to update payment method');\n        }\n\n        await refetch(); // Refresh data\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : 'Failed to update payment method';\n        handleError(errorMessage);\n        return false;\n      }\n    },\n    [refetch, handleError]\n  );\n\n  useEffect(() => {\n    if (autoFetch && (customerId || subscriptionId)) {\n      refetch();\n    }\n  }, [autoFetch, customerId, subscriptionId, refetch]);\n\n  return {\n    subscription,\n    subscriptions,\n    loading,\n    error,\n    // Backward compatibility getters\n    isLoading: loading,\n    isError: !!error,\n    refetch,\n    cancel,\n    reactivate,\n    updatePaymentMethod,\n  };\n};\n","import { useState, useCallback } from 'react';\nimport { useStripe } from '@stripe/react-stripe-js';\nimport { usePaymentsContext } from '../../shared/providers/PaymentsProvider';\nimport { CheckoutSessionParams } from '../../shared/types';\nimport { ERROR_MESSAGES } from '../../shared/constants';\nimport { validateStripeId, validateEmail } from '../../shared/utils/validation';\n\ninterface UseCheckoutOptions {\n  onSuccess?: (sessionId: string) => void;\n  onError?: (error: string) => void;\n  onLoading?: (loading: boolean) => void;\n}\n\ninterface UseCheckoutReturn {\n  loading: boolean;\n  error: string | null;\n  // Backward compatibility getters\n  isLoading: boolean; // Maps to loading\n  isError: boolean; // Maps to !!error\n  createCheckoutSession: (\n    params: CheckoutSessionParams\n  ) => Promise<string | null>;\n  redirectToCheckout: (params: CheckoutSessionParams) => Promise<boolean>;\n  createPaymentIntent: (params: {\n    amount: number;\n    currency: string;\n    customerId?: string;\n    description?: string;\n    metadata?: Record<string, string>;\n  }) => Promise<string | null>;\n}\n\nexport const useCheckout = (\n  options: UseCheckoutOptions = {}\n): UseCheckoutReturn => {\n  const { onSuccess, onError, onLoading } = options;\n  const stripe = useStripe();\n  const { initialized } = usePaymentsContext();\n\n  const [loading, setLoading] = useState(false);\n  const [error, setError] = useState<string | null>(null);\n\n  const handleError = useCallback(\n    (errorMessage: string) => {\n      setError(errorMessage);\n      onError?.(errorMessage);\n      console.error('Checkout error:', errorMessage);\n    },\n    [onError]\n  );\n\n  const validateCheckoutParams = useCallback(\n    (params: CheckoutSessionParams): string | null => {\n      if (!params.priceId) {\n        return 'Price ID is required';\n      }\n\n      if (!validateStripeId(params.priceId, 'price')) {\n        return ERROR_MESSAGES.INVALID_PRICE_ID;\n      }\n\n      if (\n        params.customerId &&\n        !validateStripeId(params.customerId, 'customer')\n      ) {\n        return ERROR_MESSAGES.INVALID_CUSTOMER_ID;\n      }\n\n      if (params.customerEmail && !validateEmail(params.customerEmail)) {\n        return 'Invalid customer email';\n      }\n\n      if (!params.successUrl) {\n        return 'Success URL is required';\n      }\n\n      if (!params.cancelUrl) {\n        return 'Cancel URL is required';\n      }\n\n      return null;\n    },\n    []\n  );\n\n  const createCheckoutSession = useCallback(\n    async (params: CheckoutSessionParams): Promise<string | null> => {\n      if (!initialized) {\n        handleError(ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED);\n        return null;\n      }\n\n      const validationError = validateCheckoutParams(params);\n      if (validationError) {\n        handleError(validationError);\n        return null;\n      }\n\n      setLoading(true);\n      setError(null);\n      onLoading?.(true);\n\n      try {\n        const response = await fetch('/api/payments/create-checkout-session', {\n          method: 'POST',\n          headers: {\n            'Content-Type': 'application/json',\n          },\n          body: JSON.stringify(params),\n        });\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || ERROR_MESSAGES.CHECKOUT_FAILED);\n        }\n\n        const { sessionId } = await response.json();\n\n        if (!sessionId) {\n          throw new Error('No session ID returned from server');\n        }\n\n        onSuccess?.(sessionId);\n        return sessionId;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error ? err.message : ERROR_MESSAGES.CHECKOUT_FAILED;\n        handleError(errorMessage);\n        return null;\n      } finally {\n        setLoading(false);\n        onLoading?.(false);\n      }\n    },\n    [initialized, validateCheckoutParams, handleError, onSuccess, onLoading]\n  );\n\n  const redirectToCheckout = useCallback(\n    async (params: CheckoutSessionParams): Promise<boolean> => {\n      if (!stripe) {\n        handleError(ERROR_MESSAGES.STRIPE_NOT_LOADED);\n        return false;\n      }\n\n      const sessionId = await createCheckoutSession(params);\n\n      if (!sessionId) {\n        return false;\n      }\n\n      try {\n        const result = await stripe.redirectToCheckout({ sessionId });\n\n        if (result.error) {\n          throw new Error(\n            result.error.message || ERROR_MESSAGES.CHECKOUT_FAILED\n          );\n        }\n\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error ? err.message : ERROR_MESSAGES.CHECKOUT_FAILED;\n        handleError(errorMessage);\n        return false;\n      }\n    },\n    [stripe, createCheckoutSession, handleError]\n  );\n\n  const createPaymentIntent = useCallback(\n    async (params: {\n      amount: number;\n      currency: string;\n      customerId?: string;\n      description?: string;\n      metadata?: Record<string, string>;\n    }): Promise<string | null> => {\n      if (!initialized) {\n        handleError(ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED);\n        return null;\n      }\n\n      if (params.amount <= 0) {\n        handleError('Amount must be greater than 0');\n        return null;\n      }\n\n      if (\n        params.customerId &&\n        !validateStripeId(params.customerId, 'customer')\n      ) {\n        handleError(ERROR_MESSAGES.INVALID_CUSTOMER_ID);\n        return null;\n      }\n\n      setLoading(true);\n      setError(null);\n      onLoading?.(true);\n\n      try {\n        const response = await fetch('/api/payments/create-payment-intent', {\n          method: 'POST',\n          headers: {\n            'Content-Type': 'application/json',\n          },\n          body: JSON.stringify(params),\n        });\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || 'Failed to create payment intent');\n        }\n\n        const { client_secret } = await response.json();\n\n        if (!client_secret) {\n          throw new Error('No client secret returned from server');\n        }\n\n        return client_secret;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : 'Failed to create payment intent';\n        handleError(errorMessage);\n        return null;\n      } finally {\n        setLoading(false);\n        onLoading?.(false);\n      }\n    },\n    [initialized, handleError, onLoading]\n  );\n\n  return {\n    loading,\n    error,\n    // Backward compatibility getters\n    isLoading: loading,\n    isError: !!error,\n    createCheckoutSession,\n    redirectToCheckout,\n    createPaymentIntent,\n  };\n};\n","import { useState, useEffect, useCallback } from 'react';\nimport { Customer, PaymentMethod } from '../../shared/types';\nimport { ERROR_MESSAGES } from '../../shared/constants';\nimport { validateStripeId, validateEmail } from '../../shared/utils/validation';\n\ninterface UseCustomerOptions {\n  customerId?: string;\n  autoFetch?: boolean;\n  onError?: (error: string) => void;\n}\n\ninterface UseCustomerReturn {\n  customer: Customer | null;\n  paymentMethods: PaymentMethod[];\n  loading: boolean;\n  error: string | null;\n  // Backward compatibility getters\n  isLoading: boolean; // Maps to loading\n  isError: boolean; // Maps to !!error\n  refetch: () => Promise<void>;\n  createCustomer: (params: {\n    email: string;\n    name?: string;\n    phone?: string;\n    metadata?: Record<string, string>;\n  }) => Promise<Customer | null>;\n  updateCustomer: (params: {\n    email?: string;\n    name?: string;\n    phone?: string;\n    metadata?: Record<string, string>;\n  }) => Promise<boolean>;\n  deleteCustomer: () => Promise<boolean>;\n  fetchPaymentMethods: () => Promise<PaymentMethod[]>;\n  addPaymentMethod: (paymentMethodId: string) => Promise<boolean>;\n  removePaymentMethod: (paymentMethodId: string) => Promise<boolean>;\n  setDefaultPaymentMethod: (paymentMethodId: string) => Promise<boolean>;\n}\n\nexport const useCustomer = (\n  options: UseCustomerOptions = {}\n): UseCustomerReturn => {\n  const { customerId, autoFetch = true, onError } = options;\n\n  const [customer, setCustomer] = useState<Customer | null>(null);\n  const [paymentMethods, setPaymentMethods] = useState<PaymentMethod[]>([]);\n  const [loading, setLoading] = useState(false);\n  const [error, setError] = useState<string | null>(null);\n\n  const handleError = useCallback(\n    (errorMessage: string) => {\n      setError(errorMessage);\n      onError?.(errorMessage);\n      console.error('Customer error:', errorMessage);\n    },\n    [onError]\n  );\n\n  const fetchCustomer = useCallback(\n    async (id: string) => {\n      if (!validateStripeId(id, 'customer')) {\n        handleError('Invalid customer ID');\n        return null;\n      }\n\n      try {\n        const response = await fetch(`/api/payments/customer/${id}`);\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || ERROR_MESSAGES.CUSTOMER_NOT_FOUND);\n        }\n\n        const data = await response.json();\n        return data;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : ERROR_MESSAGES.CUSTOMER_NOT_FOUND;\n        handleError(errorMessage);\n        return null;\n      }\n    },\n    [handleError]\n  );\n\n  const refetch = useCallback(async () => {\n    if (!customerId) {\n      handleError('Customer ID is required');\n      return;\n    }\n\n    setLoading(true);\n    setError(null);\n\n    try {\n      const customerData = await fetchCustomer(customerId);\n      setCustomer(customerData);\n    } finally {\n      setLoading(false);\n    }\n  }, [customerId, fetchCustomer, handleError]);\n\n  const createCustomer = useCallback(\n    async (params: {\n      email: string;\n      name?: string;\n      phone?: string;\n      metadata?: Record<string, string>;\n    }): Promise<Customer | null> => {\n      if (!validateEmail(params.email)) {\n        handleError('Invalid email address');\n        return null;\n      }\n\n      setLoading(true);\n      setError(null);\n\n      try {\n        const response = await fetch('/api/payments/customer', {\n          method: 'POST',\n          headers: { 'Content-Type': 'application/json' },\n          body: JSON.stringify(params),\n        });\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || 'Failed to create customer');\n        }\n\n        const customerData = await response.json();\n        setCustomer(customerData);\n        return customerData;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error ? err.message : 'Failed to create customer';\n        handleError(errorMessage);\n        return null;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [handleError]\n  );\n\n  const updateCustomer = useCallback(\n    async (params: {\n      email?: string;\n      name?: string;\n      phone?: string;\n      metadata?: Record<string, string>;\n    }): Promise<boolean> => {\n      if (!customerId) {\n        handleError('Customer ID is required');\n        return false;\n      }\n\n      if (params.email && !validateEmail(params.email)) {\n        handleError('Invalid email address');\n        return false;\n      }\n\n      setLoading(true);\n      setError(null);\n\n      try {\n        const response = await fetch(`/api/payments/customer/${customerId}`, {\n          method: 'PUT',\n          headers: { 'Content-Type': 'application/json' },\n          body: JSON.stringify(params),\n        });\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || 'Failed to update customer');\n        }\n\n        await refetch(); // Refresh customer data\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error ? err.message : 'Failed to update customer';\n        handleError(errorMessage);\n        return false;\n      } finally {\n        setLoading(false);\n      }\n    },\n    [customerId, refetch, handleError]\n  );\n\n  const deleteCustomer = useCallback(async (): Promise<boolean> => {\n    if (!customerId) {\n      handleError('Customer ID is required');\n      return false;\n    }\n\n    setLoading(true);\n    setError(null);\n\n    try {\n      const response = await fetch(`/api/payments/customer/${customerId}`, {\n        method: 'DELETE',\n      });\n\n      if (!response.ok) {\n        const errorData = await response\n          .json()\n          .catch(() => ({ error: 'Network error' }));\n        throw new Error(errorData.error || 'Failed to delete customer');\n      }\n\n      setCustomer(null);\n      setPaymentMethods([]);\n      return true;\n    } catch (err) {\n      const errorMessage =\n        err instanceof Error ? err.message : 'Failed to delete customer';\n      handleError(errorMessage);\n      return false;\n    } finally {\n      setLoading(false);\n    }\n  }, [customerId, handleError]);\n\n  const fetchPaymentMethods = useCallback(async (): Promise<\n    PaymentMethod[]\n  > => {\n    if (!customerId) {\n      handleError('Customer ID is required');\n      return [];\n    }\n\n    try {\n      const response = await fetch(\n        `/api/payments/customer/${customerId}/payment-methods`\n      );\n\n      if (!response.ok) {\n        const errorData = await response\n          .json()\n          .catch(() => ({ error: 'Network error' }));\n        throw new Error(errorData.error || 'Failed to fetch payment methods');\n      }\n\n      const data = await response.json();\n      const methods = data.paymentMethods || [];\n      setPaymentMethods(methods);\n      return methods;\n    } catch (err) {\n      const errorMessage =\n        err instanceof Error ? err.message : 'Failed to fetch payment methods';\n      handleError(errorMessage);\n      return [];\n    }\n  }, [customerId, handleError]);\n\n  const addPaymentMethod = useCallback(\n    async (paymentMethodId: string): Promise<boolean> => {\n      if (!customerId) {\n        handleError('Customer ID is required');\n        return false;\n      }\n\n      try {\n        const response = await fetch(\n          `/api/payments/customer/${customerId}/payment-methods`,\n          {\n            method: 'POST',\n            headers: { 'Content-Type': 'application/json' },\n            body: JSON.stringify({ paymentMethodId }),\n          }\n        );\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || 'Failed to add payment method');\n        }\n\n        await fetchPaymentMethods(); // Refresh payment methods\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error ? err.message : 'Failed to add payment method';\n        handleError(errorMessage);\n        return false;\n      }\n    },\n    [customerId, fetchPaymentMethods, handleError]\n  );\n\n  const removePaymentMethod = useCallback(\n    async (paymentMethodId: string): Promise<boolean> => {\n      if (!customerId) {\n        handleError('Customer ID is required');\n        return false;\n      }\n\n      try {\n        const response = await fetch(\n          `/api/payments/customer/${customerId}/payment-methods/${paymentMethodId}`,\n          {\n            method: 'DELETE',\n          }\n        );\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(errorData.error || 'Failed to remove payment method');\n        }\n\n        await fetchPaymentMethods(); // Refresh payment methods\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : 'Failed to remove payment method';\n        handleError(errorMessage);\n        return false;\n      }\n    },\n    [customerId, fetchPaymentMethods, handleError]\n  );\n\n  const setDefaultPaymentMethod = useCallback(\n    async (paymentMethodId: string): Promise<boolean> => {\n      if (!customerId) {\n        handleError('Customer ID is required');\n        return false;\n      }\n\n      try {\n        const response = await fetch(\n          `/api/payments/customer/${customerId}/default-payment-method`,\n          {\n            method: 'PUT',\n            headers: { 'Content-Type': 'application/json' },\n            body: JSON.stringify({ paymentMethodId }),\n          }\n        );\n\n        if (!response.ok) {\n          const errorData = await response\n            .json()\n            .catch(() => ({ error: 'Network error' }));\n          throw new Error(\n            errorData.error || 'Failed to set default payment method'\n          );\n        }\n\n        await Promise.all([refetch(), fetchPaymentMethods()]); // Refresh both customer and payment methods\n        return true;\n      } catch (err) {\n        const errorMessage =\n          err instanceof Error\n            ? err.message\n            : 'Failed to set default payment method';\n        handleError(errorMessage);\n        return false;\n      }\n    },\n    [customerId, refetch, fetchPaymentMethods, handleError]\n  );\n\n  useEffect(() => {\n    if (autoFetch && customerId) {\n      refetch();\n      fetchPaymentMethods();\n    }\n  }, [autoFetch, customerId, refetch, fetchPaymentMethods]);\n\n  return {\n    customer,\n    paymentMethods,\n    loading,\n    error,\n    // Backward compatibility getters\n    isLoading: loading,\n    isError: !!error,\n    refetch,\n    createCustomer,\n    updateCustomer,\n    deleteCustomer,\n    fetchPaymentMethods,\n    addPaymentMethod,\n    removePaymentMethod,\n    setDefaultPaymentMethod,\n  };\n};\n","import {\n  loadStripe,\n  Stripe,\n  StripeElements,\n  PaymentIntent,\n  StripeError,\n} from '@stripe/stripe-js';\nimport { PaymentsConfig } from '../../shared/types';\nimport { ERROR_MESSAGES } from '../../shared/constants';\n\nlet stripeInstance: Promise<Stripe | null> | null = null;\n\nexport const getStripe = (publishableKey: string): Promise<Stripe | null> => {\n  if (!stripeInstance) {\n    stripeInstance = loadStripe(publishableKey);\n  }\n  return stripeInstance;\n};\n\nexport const initializeStripe = async (\n  config: PaymentsConfig\n): Promise<Stripe | null> => {\n  if (!config.publishableKey) {\n    console.error(ERROR_MESSAGES.PROVIDER_NOT_CONFIGURED);\n    return null;\n  }\n\n  try {\n    const stripe = await getStripe(config.publishableKey);\n    return stripe;\n  } catch (error) {\n    console.error('Failed to initialize Stripe:', error);\n    return null;\n  }\n};\n\nexport const createCheckoutSession = async (params: {\n  priceId: string;\n  customerId?: string;\n  customerEmail?: string;\n  successUrl: string;\n  cancelUrl: string;\n  allowPromotionCodes?: boolean;\n  billingAddressCollection?: 'auto' | 'required';\n  metadata?: Record<string, string>;\n  trialPeriodDays?: number;\n}): Promise<{ sessionId: string } | { error: string }> => {\n  try {\n    const response = await fetch('/api/payments/create-checkout-session', {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify(params),\n    });\n\n    if (!response.ok) {\n      const errorData = await response\n        .json()\n        .catch(() => ({ error: 'Network error' }));\n      return { error: errorData.error || ERROR_MESSAGES.CHECKOUT_FAILED };\n    }\n\n    const data = await response.json();\n    return { sessionId: data.sessionId };\n  } catch (error) {\n    return {\n      error:\n        error instanceof Error ? error.message : ERROR_MESSAGES.CHECKOUT_FAILED,\n    };\n  }\n};\n\nexport const createPaymentIntent = async (params: {\n  amount: number;\n  currency: string;\n  customerId?: string;\n  description?: string;\n  metadata?: Record<string, string>;\n}): Promise<{ clientSecret: string } | { error: string }> => {\n  try {\n    const response = await fetch('/api/payments/create-payment-intent', {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify(params),\n    });\n\n    if (!response.ok) {\n      const errorData = await response\n        .json()\n        .catch(() => ({ error: 'Network error' }));\n      return { error: errorData.error || 'Failed to create payment intent' };\n    }\n\n    const data = await response.json();\n    return { clientSecret: data.client_secret };\n  } catch (error) {\n    return {\n      error:\n        error instanceof Error\n          ? error.message\n          : 'Failed to create payment intent',\n    };\n  }\n};\n\nexport const createPortalSession = async (params: {\n  customerId: string;\n  returnUrl: string;\n}): Promise<{ url: string } | { error: string }> => {\n  try {\n    const response = await fetch('/api/payments/create-portal-session', {\n      method: 'POST',\n      headers: { 'Content-Type': 'application/json' },\n      body: JSON.stringify(params),\n    });\n\n    if (!response.ok) {\n      const errorData = await response\n        .json()\n        .catch(() => ({ error: 'Network error' }));\n      return { error: errorData.error || 'Failed to create portal session' };\n    }\n\n    const data = await response.json();\n    return { url: data.url };\n  } catch (error) {\n    return {\n      error:\n        error instanceof Error\n          ? error.message\n          : 'Failed to create portal session',\n    };\n  }\n};\n\nexport const confirmPayment = async (\n  stripe: Stripe,\n  elements: StripeElements,\n  clientSecret: string,\n  options: {\n    returnUrl?: string;\n    receiptEmail?: string;\n  } = {}\n): Promise<{\n  success: boolean;\n  error?: string;\n  paymentIntent?: PaymentIntent;\n}> => {\n  try {\n    const result = await stripe.confirmPayment({\n      elements,\n      clientSecret,\n      confirmParams: {\n        return_url: options.returnUrl || window.location.href,\n        receipt_email: options.receiptEmail,\n      },\n      redirect: 'if_required',\n    });\n\n    if (result.error) {\n      return { success: false, error: result.error.message };\n    }\n\n    if (result.paymentIntent?.status === 'succeeded') {\n      return { success: true, paymentIntent: result.paymentIntent };\n    }\n\n    return { success: false, error: 'Payment was not completed' };\n  } catch (error) {\n    return {\n      success: false,\n      error:\n        error instanceof Error ? error.message : ERROR_MESSAGES.PAYMENT_FAILED,\n    };\n  }\n};\n\nexport const redirectToCheckout = async (\n  stripe: Stripe,\n  sessionId: string\n): Promise<{ success: boolean; error?: string }> => {\n  try {\n    const result = await stripe.redirectToCheckout({ sessionId });\n\n    if (result.error) {\n      return { success: false, error: result.error.message };\n    }\n\n    return { success: true };\n  } catch (error) {\n    return {\n      success: false,\n      error:\n        error instanceof Error ? error.message : ERROR_MESSAGES.CHECKOUT_FAILED,\n    };\n  }\n};\n\nexport const formatStripeError = (\n  error: StripeError | { code?: string; message?: string } | string\n): string => {\n  if (typeof error === 'string') {\n    return error;\n  }\n\n  if (error?.message) {\n    return error.message;\n  }\n\n  if (error?.code) {\n    const errorMessages: Record<string, string> = {\n      card_declined: 'Your card was declined.',\n      expired_card: 'Your card has expired.',\n      incorrect_cvc: \"Your card's security code is incorrect.\",\n      processing_error: 'An error occurred while processing your card.',\n      incorrect_number: 'Your card number is incorrect.',\n    };\n\n    return errorMessages[error.code] || `Payment failed: ${error.code}`;\n  }\n\n  return 'An unexpected error occurred.';\n};\n"],"mappings":";AAAA,SAAgB,gBAAgB;AAChC,SAAS,iBAAiB;;;ACD1B,SAAgB,WAAW,eAAe,YAAY,cAAc;;;ACApE,SAAS,cAAc;AACvB,SAAS,aAAa;;;ACyBf,IAAM,gBAAN,MAAM,uBAAsB,MAA8B;AAAA,EACxD;AAAA,EACA;AAAA,EACA;AAAA,EAEP,YACE,MACA,SACA,MACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,UAAU;AACf,WAAO,eAAe,MAAM,eAAc,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AAM,IAAI,KAAK,mBAAmB,MAAM,IAAI;AAAA,EACnE;AAEA,SAAO;AACT;","names":["jsx","jsx","jsxs","useState","useStripe","Fragment","jsx","jsxs","useStripe","useState","useState","Fragment","jsx","jsxs","useState","jsx","jsxs","useState","Fragment","jsx","jsxs","formatDate","Fragment","jsx","jsxs","jsx","jsxs","formatDate","useState","Fragment","jsx","jsxs","React","jsx","jsxs","React","useState","useEffect","usePayments","useState","createCheckoutSession","useEffect","useState","useEffect","useCallback","useState","useCallback","useEffect","useState","useCallback","useStripe","useStripe","useState","useCallback","createCheckoutSession","redirectToCheckout","createPaymentIntent","useState","useEffect","useCallback","useState","useCallback","useEffect","loadStripe","getStripe","loadStripe"]}