import { t as configProvider } from "../config_provider-t1UIlTp8.js";
import { t as main_exports } from "../main-B-RqQwgz.js";
import { RuntimeException } from "@poppinss/utils/exception";
//#region providers/hash_provider.ts
/**
* Registers the passwords hasher with the container
*
* This provider sets up password hashing functionality by:
* - Registering the HashManager with configuration from config/hash.ts
* - Providing a Hash class that uses the default hasher
* - Supporting multiple hashing drivers (bcrypt, argon2, etc.)
*
* @example
* const provider = new HashServiceProvider(app)
* provider.register()
* const hash = await app.container.make('hash')
*/
var HashServiceProvider = class {
	app;
	/**
	* Hash service provider constructor
	*
	* @param app - The application service instance
	*/
	constructor(app) {
		this.app = app;
	}
	/**
	* Registering the hash class to resolve an instance with the
	* default hasher.
	*
	* Creates a singleton binding for the Hash class that resolves
	* the default hasher from the hash manager.
	*
	* @example
	* const hash = await container.make(Hash)
	* const hashed = await hash.make('password')
	*/
	registerHash() {
		this.app.container.singleton(main_exports.Hash, async (resolver) => {
			return (await resolver.make("hash")).use();
		});
	}
	/**
	* Registers the hash manager with the container
	*
	* Creates a singleton binding for 'hash' that instantiates
	* the HashManager with configuration from config/hash.ts file.
	* Throws an error if the configuration is invalid.
	*
	* @example
	* const hashManager = await container.make('hash')
	* const bcryptHasher = hashManager.use('bcrypt')
	*/
	registerHashManager() {
		this.app.container.singleton("hash", async () => {
			const hashConfigProvider = this.app.config.get("hash");
			/**
			* Resolve config from the provider
			*/
			const config = await configProvider.resolve(this.app, hashConfigProvider);
			if (!config) throw new RuntimeException("Invalid \"config/hash.ts\" file. Make sure you are using the \"defineConfig\" method");
			const { HashManager } = await import("../modules/hash/main.js");
			return new HashManager(config);
		});
	}
	/**
	* Registers bindings
	*
	* Called during the application bootstrap phase to register
	* the hash manager and hash class with the IoC container.
	*
	* @example
	* const provider = new HashServiceProvider(app)
	* provider.register() // Registers hash services
	*/
	register() {
		this.registerHashManager();
		this.registerHash();
	}
};
//#endregion
export { HashServiceProvider as default };
