'use strict';

require('zod-to-json-schema');
require('zod-validation-error');
require('@backstage/errors');
var readDeclarativeSignInResolver = require('../sign-in/readDeclarativeSignInResolver.cjs.js');
require('../sign-in/commonSignInResolvers.cjs.js');
var createProxyRouteHandlers = require('./createProxyRouteHandlers.cjs.js');

function createProxyAuthProviderFactory(options) {
  return (ctx) => {
    const signInResolver = options.signInResolver ?? readDeclarativeSignInResolver.readDeclarativeSignInResolver({
      config: ctx.config,
      signInResolverFactories: options.signInResolverFactories ?? {}
    });
    if (!signInResolver) {
      throw new Error(
        `No sign-in resolver configured for proxy auth provider '${ctx.providerId}'`
      );
    }
    return createProxyRouteHandlers.createProxyAuthRouteHandlers({
      signInResolver,
      config: ctx.config,
      authenticator: options.authenticator,
      resolverContext: ctx.resolverContext,
      profileTransform: options.profileTransform
    });
  };
}

exports.createProxyAuthProviderFactory = createProxyAuthProviderFactory;
//# sourceMappingURL=createProxyAuthProviderFactory.cjs.js.map
