import { ENV_PREFIXES } from "@stryke/env/types";
import { camelCase } from "@stryke/string-format/camel-case";
import { isString } from "@stryke/type-checks/is-string";

//#region src/helpers/source-file-env.ts
function __assignType(fn, args) {
	fn.__type = args;
	return fn;
}
const __ΩTReturned = [
	"TEnv",
	"TReturned",
	"l2&R!RPe#!&qk#%QRb!Pde\"!p'w\"y"
];
function removeEnvPrefix(env) {
	if (isString(env)) {
		let name = ENV_PREFIXES.reduce(__assignType((ret, prefix) => {
			if (ret.startsWith(prefix)) ret = ret.slice(prefix.length);
			return ret;
		}, [
			"ret",
			"prefix",
			"",
			"P\"2!\"2\"\"/#"
		]), env.toUpperCase());
		while (name.startsWith("_")) name = name.slice(1);
		return name;
	}
	return Object.keys(env).reduce(__assignType((ret, key) => {
		const name = removeEnvPrefix(key);
		if (name) ret[name] = env[key];
		return ret;
	}, [
		"ret",
		"key",
		"",
		"P\"2!\"2\"\"/#"
	]), {});
}
removeEnvPrefix.__type = [
	"env",
	() => __ΩTReturned,
	"removeEnvPrefix",
	"P\"2!\"o\"\"/#"
];
function formatEnvField(key) {
	return camelCase(removeEnvPrefix(key));
}
formatEnvField.__type = [
	"key",
	"formatEnvField",
	"P&2!&/\""
];

//#endregion
export { formatEnvField, removeEnvPrefix };
//# sourceMappingURL=source-file-env.mjs.map