import { useLoginToken } from "@contember/react-client";
import { useMemo } from "react";
import { GQLVariable } from "../../lib/variables.js";
import { useSingleTenantMutation } from "../../lib/useSingleTenantMutation.js";
const SIGN_IN_IDP_MUTATION = `
signInIDP(identityProvider: $identityProvider, idpResponse: {url: $url}, redirectUrl: $redirectUrl, sessionData: $session, expiration: $expiration) {
	ok
	error {
		developerMessage
		code
	}
	result {
		token
		person {
			id
			email
		}
	}
}
`;
const SignInIdpVariables = {
  redirectUrl: GQLVariable.Required(GQLVariable.String),
  url: GQLVariable.Required(GQLVariable.String),
  identityProvider: GQLVariable.Required(GQLVariable.String),
  session: GQLVariable.Required(GQLVariable.Json),
  expiration: GQLVariable.Int
};
const useSignInIDP = () => {
  const loginToken = useLoginToken();
  return useSingleTenantMutation(
    SIGN_IN_IDP_MUTATION,
    SignInIdpVariables,
    useMemo(() => ({
      apiTokenOverride: loginToken,
      headers: {
        "X-Contember-Token-Path": "data.result.result.token"
      }
    }), [loginToken])
  );
};
export {
  useSignInIDP
};
//# sourceMappingURL=signInIDP.js.map
