import {
  shippingOptionsQueryKeys
} from "./chunk-5TRY5IMZ.js";
import {
  stockLocationsQueryKeys
} from "./chunk-EPHVGD5Z.js";
import {
  queryClient
} from "./chunk-RHKRREUU.js";
import {
  queryKeysFactory
} from "./chunk-ZA2KFUFR.js";
import {
  sdk
} from "./chunk-ZBWL72TB.js";

// src/hooks/api/fulfillment-sets.tsx
import {
  useMutation,
  useQuery
} from "@tanstack/react-query";
var FULFILLMENT_SETS_QUERY_KEY = "fulfillment_sets";
var fulfillmentSetsQueryKeys = queryKeysFactory(
  FULFILLMENT_SETS_QUERY_KEY
);
var useDeleteFulfillmentSet = (id, options) => {
  return useMutation({
    mutationFn: () => sdk.admin.fulfillmentSets.$id.delete({ $id: id }),
    onSuccess: async (data, variables, context) => {
      await queryClient.invalidateQueries({
        queryKey: fulfillmentSetsQueryKeys.detail(id)
      });
      await queryClient.invalidateQueries({
        queryKey: fulfillmentSetsQueryKeys.lists()
      });
      await queryClient.invalidateQueries({
        queryKey: stockLocationsQueryKeys.all
      });
      await queryClient.invalidateQueries({
        queryKey: shippingOptionsQueryKeys.all
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useCreateFulfillmentSetServiceZone = (fulfillmentSetId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.fulfillmentSets.$id.serviceZones.mutate({
      $id: fulfillmentSetId,
      ...payload
    }),
    onSuccess: async (data, variables, context) => {
      await queryClient.invalidateQueries({
        queryKey: fulfillmentSetsQueryKeys.lists()
      });
      await queryClient.invalidateQueries({
        queryKey: stockLocationsQueryKeys.all
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useUpdateFulfillmentSetServiceZone = (fulfillmentSetId, serviceZoneId, options) => {
  return useMutation({
    mutationFn: (payload) => sdk.admin.fulfillmentSets.$id.serviceZones.$id.mutate({
      $id: serviceZoneId,
      ...payload
    }),
    onSuccess: async (data, variables, context) => {
      await queryClient.invalidateQueries({
        queryKey: fulfillmentSetsQueryKeys.lists()
      });
      await queryClient.invalidateQueries({
        queryKey: stockLocationsQueryKeys.all
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};
var useDeleteFulfillmentServiceZone = (fulfillmentSetId, serviceZoneId, options) => {
  return useMutation({
    mutationFn: () => sdk.admin.fulfillmentSets.$id.serviceZones.$id.delete({
      $id: serviceZoneId
    }),
    onSuccess: async (data, variables, context) => {
      await queryClient.invalidateQueries({
        queryKey: fulfillmentSetsQueryKeys.lists()
      });
      await queryClient.invalidateQueries({
        queryKey: shippingOptionsQueryKeys.lists()
      });
      await queryClient.invalidateQueries({
        queryKey: stockLocationsQueryKeys.all
      });
      options?.onSuccess?.(data, variables, context);
    },
    ...options
  });
};

export {
  useDeleteFulfillmentSet,
  useCreateFulfillmentSetServiceZone,
  useUpdateFulfillmentSetServiceZone,
  useDeleteFulfillmentServiceZone
};
