import {
  ordersQueryKeys
} from "./chunk-DIAWPVYS.js";
import {
  queryClient
} from "./chunk-RHKRREUU.js";
import {
  queryKeysFactory
} from "./chunk-ZA2KFUFR.js";
import {
  sdk
} from "./chunk-DTGEFKK4.js";

// src/hooks/api/payments.tsx
import {
  useMutation,
  useQuery
} from "@tanstack/react-query";
var PAYMENT_QUERY_KEY = "payment";
var paymentQueryKeys = queryKeysFactory(PAYMENT_QUERY_KEY);
var PAYMENT_PROVIDERS_QUERY_KEY = "payment_providers";
var paymentProvidersQueryKeys = queryKeysFactory(
  PAYMENT_PROVIDERS_QUERY_KEY
);
var useRefundPayment = (orderId, paymentId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.vendor.payments.$id.refund.mutate({ $id: paymentId, ...payload }),
    onSuccess: (data, variables, context) => {
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.details()
      });
      queryClient.invalidateQueries({
        queryKey: ordersQueryKeys.preview(orderId)
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};

// src/hooks/api/refund-reasons.tsx
import {
  useMutation as useMutation2,
  useQuery as useQuery2
} from "@tanstack/react-query";
var REFUND_REASONS_QUERY_KEY = "refund_reasons";
var refundReasonsQueryKeys = queryKeysFactory(
  REFUND_REASONS_QUERY_KEY
);
var useRefundReasons = (query, options) => {
  const { data, ...rest } = useQuery2({
    queryFn: () => sdk.vendor.refundReasons.query({ ...query }),
    queryKey: refundReasonsQueryKeys.list(query),
    ...options
  });
  return { ...data, ...rest };
};

export {
  useRefundPayment,
  useRefundReasons
};
