/**
 * React Query key factory for the refunds domain (hierarchical, per the `services/{domain}` pattern).
 * The cancellation preview and the refund status are keyed by the **booking** id (the customer reaches a
 * refund through its booking, never through an admin-only refund id); `detail` keys the by-refund-id read
 * used by the real `refunds/{id}/status` route.
 */
export const refundKeys = {
  all: ['refunds'] as const,

  policyPreviews: () => [...refundKeys.all, 'policy_preview'] as const,
  policyPreview: (bookingId: number) => [...refundKeys.policyPreviews(), bookingId] as const,

  byBookings: () => [...refundKeys.all, 'by_booking'] as const,
  byBooking: (bookingId: number) => [...refundKeys.byBookings(), bookingId] as const,

  details: () => [...refundKeys.all, 'detail'] as const,
  detail: (refundId: number) => [...refundKeys.details(), refundId] as const,

  // Admin refund tooling: the decomposition preview is keyed by the booking **and** the linking ticket
  // (a refund is always initiated in a ticket's context), so re-previewing under a different ticket caches
  // independently.
  adminPreviews: () => [...refundKeys.all, 'admin_preview'] as const,
  adminPreview: (bookingId: number, ticketId: number | null) =>
    [...refundKeys.adminPreviews(), bookingId, ticketId] as const,
};
