"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const reactClient = require("@contember/react-client");
const react = require("react");
const variables = require("../../lib/variables.cjs");
const useSingleTenantMutation = require("../../lib/useSingleTenantMutation.cjs");
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: variables.GQLVariable.Required(variables.GQLVariable.String),
  url: variables.GQLVariable.Required(variables.GQLVariable.String),
  identityProvider: variables.GQLVariable.Required(variables.GQLVariable.String),
  session: variables.GQLVariable.Required(variables.GQLVariable.Json),
  expiration: variables.GQLVariable.Int
};
const useSignInIDP = () => {
  const loginToken = reactClient.useLoginToken();
  return useSingleTenantMutation.useSingleTenantMutation(
    SIGN_IN_IDP_MUTATION,
    SignInIdpVariables,
    react.useMemo(() => ({
      apiTokenOverride: loginToken,
      headers: {
        "X-Contember-Token-Path": "data.result.result.token"
      }
    }), [loginToken])
  );
};
exports.useSignInIDP = useSignInIDP;
//# sourceMappingURL=signInIDP.cjs.map
