import { createDynamicParamParser } from "../utils/dynamicParamParser.js";
import { clerkCoreErrorContextProviderNotFound, clerkCoreErrorNoClerkSingleton } from "@clerk/shared/internal/clerk-js/errors";
import { snakeToCamel } from "@clerk/shared/underscore";

//#region src/contexts/utils.ts
function assertClerkSingletonExists(clerk) {
	if (!clerk) clerkCoreErrorNoClerkSingleton();
}
function assertContextExists(contextVal, providerName) {
	if (!contextVal) clerkCoreErrorContextProviderNotFound(providerName);
}
function getInitialValuesFromQueryParams(queryString, params) {
	const props = {};
	new URLSearchParams(queryString).forEach((value, key) => {
		if (params.includes(key) && typeof value === "string") props[snakeToCamel(key)] = value;
	});
	return props;
}
const populateParamFromObject = createDynamicParamParser({ regex: /:(\w+)/ });

//#endregion
export { assertClerkSingletonExists, assertContextExists, getInitialValuesFromQueryParams, populateParamFromObject };
//# sourceMappingURL=utils.js.map