;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "070b513e-e932-4eae-9148-c773d9c3d1a0", e._sentryDebugIdIdentifier = "sentry-dbid-070b513e-e932-4eae-9148-c773d9c3d1a0");
  } catch (e) {
  }
}
;
import { useQueryClient, useMutation } from "@tanstack/preact-query";
import { a as useInvalidateRootLegalEntity } from "./useToastContext-CPvuqSMm.js";
import { b as useApiContext, $ as httpPost } from "./StoreProvider-CqQrndhS.js";
const updateLegalEntity = async (rootLegalEntityId, baseUrl, data) => {
  return httpPost(
    {
      baseUrl,
      path: `legalEntities/${rootLegalEntityId}`
    },
    data
  );
};
const useUpdateLegalEntity = (options) => {
  const { rootLegalEntityId, baseUrl } = useApiContext();
  const invalidateRootLegalEntity = useInvalidateRootLegalEntity();
  const queryClient = useQueryClient();
  return useMutation({
    mutationFn: (payload) => updateLegalEntity(rootLegalEntityId.value, baseUrl.value, payload),
    onSuccess: async (response, payload) => {
      if (response.id === rootLegalEntityId.value) {
        await invalidateRootLegalEntity();
      } else {
        queryClient.setQueryData(["legalEntity", payload.id], response);
      }
    },
    ...options
  });
};
export {
  useUpdateLegalEntity as u
};
