const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
const require_types_runtime = require('../types/runtime.cjs');
const require_types_plugin = require('../types/plugin.cjs');
const require_join_paths = require('../node_modules/.pnpm/@stryke_path@0.26.4/node_modules/@stryke/path/dist/join-paths.cjs');
const require_is_parent_path = require('../node_modules/.pnpm/@stryke_path@0.26.4/node_modules/@stryke/path/dist/is-parent-path.cjs');
const require_helpers_persistence = require('./persistence.cjs');
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
let __powerlines_deepkit_reflect_type = require("@powerlines/deepkit/reflect-type");

//#region src/helpers/reflect.ts
function __assignType(fn, args) {
	fn.__type = args;
	return fn;
}
function mergeEnvReflections(context, reflections) {
	return createEnvReflection(context, { type: (0, __powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
		"reflection",
		"",
		"P\"2!\"/\""
	]))) });
}
mergeEnvReflections.__type = [
	() => require_types_plugin.__ΩEnvPluginContext,
	"context",
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"reflections",
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"mergeEnvReflections",
	"Pn!2\"P\"7#F2$P\"7%/&"
];
function mergeSecretsReflections(context, reflections) {
	return createSecretsReflection(context, { type: (0, __powerlines_deepkit_vendor_type.merge)(reflections.map(__assignType((reflection) => reflection.type, [
		"reflection",
		"",
		"P\"2!\"/\""
	]))) });
}
mergeSecretsReflections.__type = [
	() => require_types_plugin.__ΩEnvPluginContext,
	"context",
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"reflections",
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"mergeSecretsReflections",
	"Pn!2\"P\"7#F2$P\"7%/&"
];
const __ΩCreateEnvReflectionOptions = [
	() => __powerlines_deepkit_vendor_type.__ΩTypeObjectLiteral,
	() => __powerlines_deepkit_vendor_type.__ΩTypeClass,
	"type",
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"superReflection",
	"CreateEnvReflectionOptions",
	"PPn!n\"J4#8P\"7$4%8Mw&y"
];
var BaseEnv = class {
	PLATFORM = "neutral";
	MODE = "production";
	DEBUG = false;
	TEST = false;
	MINIMAL = false;
	NO_COLOR = false;
	FORCE_COLOR = false;
	FORCE_HYPERLINK = false;
	STACKTRACE = false;
	INCLUDE_ERROR_DATA = false;
	CI = false;
	static __type = [
		"APP_NAME",
		"APP_VERSION",
		"BUILD_ID",
		"BUILD_TIMESTAMP",
		"BUILD_CHECKSUM",
		"RELEASE_ID",
		"RELEASE_TAG",
		"ORGANIZATION",
		"node",
		"browser",
		"neutral",
		"PLATFORM",
		function() {
			return "neutral";
		},
		"development",
		"test",
		"production",
		"MODE",
		function() {
			return "production";
		},
		"ENVIRONMENT",
		"DEBUG",
		function() {
			return false;
		},
		"TEST",
		function() {
			return false;
		},
		"MINIMAL",
		function() {
			return false;
		},
		"NO_COLOR",
		function() {
			return false;
		},
		"FORCE_COLOR",
		function() {
			return false;
		},
		"FORCE_HYPERLINK",
		function() {
			return false;
		},
		"STACKTRACE",
		function() {
			return false;
		},
		"INCLUDE_ERROR_DATA",
		function() {
			return false;
		},
		"ERROR_URL",
		"DEFAULT_TIMEZONE",
		"DEFAULT_LOCALE",
		"CI",
		function() {
			return false;
		},
		() => require_types_runtime.__ΩEnvInterface,
		"BaseEnv",
		"&3!&3\"&3#&3$&3%&3&&3'&3(P.).*.+J3,>-P.../.0J31>2&33)34>5)36>7)38>9)3:>;P')J3<>=P')J3>>?)3@>A)3B>C&3D&3E&3F)3G>H5nIx\"wJ"
	];
};
var BaseSecrets = class {
	static __type = [
		"ENCRYPTION_KEY",
		() => require_types_runtime.__ΩSecretsInterface,
		"BaseSecrets",
		"&3!5n\"x\"w#"
	];
};
function createEnvReflection(context, options = {}) {
	const parent = options.superReflection ?? new __powerlines_deepkit_vendor_type.ReflectionClass({
		kind: __powerlines_deepkit_vendor_type.ReflectionKind.class,
		description: `The base environment configuration definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
		classType: BaseEnv,
		types: [],
		implements: [{
			kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
			typeName: "EnvInterface",
			description: `The environment configuration interface definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
			types: []
		}]
	});
	parent.name = "Env";
	const result = new __powerlines_deepkit_vendor_type.ReflectionClass(options.type ?? {
		kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
		typeName: "Env",
		description: `A schema describing the list of available environment variables that can be used by the ${context.config.name ? `${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} application` : "application"}.`,
		types: []
	}, parent);
	result.name = "Env";
	return result;
}
createEnvReflection.__type = [
	() => require_types_plugin.__ΩEnvPluginContext,
	"context",
	() => __ΩCreateEnvReflectionOptions,
	"options",
	() => ({}),
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"createEnvReflection",
	"Pn!2\"n#2$>%P\"7&/'"
];
function createSecretsReflection(context, options = {}) {
	const parent = options.superReflection ?? new __powerlines_deepkit_vendor_type.ReflectionClass({
		kind: __powerlines_deepkit_vendor_type.ReflectionKind.class,
		description: `The base secrets configuration definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
		classType: BaseSecrets,
		types: [],
		implements: [{
			kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
			typeName: "SecretsInterface",
			description: `The secrets configuration interface definition for the ${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} project.`,
			types: []
		}]
	});
	parent.name = "Secrets";
	const result = new __powerlines_deepkit_vendor_type.ReflectionClass(options.type ?? {
		kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
		typeName: "Secrets",
		description: `A schema describing the list of available environment secrets that can be used by the ${context.config.name ? `${(0, __stryke_string_format_title_case.titleCase)(context.config.name)} application` : "application"}.`,
		types: []
	}, parent);
	result.name = "Secrets";
	return result;
}
createSecretsReflection.__type = [
	() => require_types_plugin.__ΩEnvPluginContext,
	"context",
	() => __ΩCreateEnvReflectionOptions,
	"options",
	() => ({}),
	() => __powerlines_deepkit_vendor_type.ReflectionClass,
	"createSecretsReflection",
	"Pn!2\"n#2$>%P\"7&/'"
];
async function reflectEnv(context, file, name) {
	let config;
	if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, {
		file: !require_is_parent_path.isParentPath(file, context.workspaceConfig.workspaceRoot) ? require_join_paths.joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
		name
	}));
	const defaultConfigType = await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getEnvDefaultTypeDefinition(context));
	return mergeEnvReflections(context, [
		await require_helpers_persistence.readEnvTypeReflection(context, "env"),
		config,
		(0, __powerlines_deepkit_vendor_type.resolveClassType)(defaultConfigType)
	].filter(Boolean));
}
reflectEnv.__type = [
	() => require_types_plugin.__ΩEnvPluginContext,
	"context",
	"file",
	"name",
	"reflectEnv",
	"Pn!2\"&2#8&2$8\"/%"
];
async function reflectSecrets(context, file, name) {
	let config;
	if (file) config = (0, __powerlines_deepkit_vendor_type.resolveClassType)(await (0, __powerlines_deepkit_reflect_type.reflectType)(context, {
		file: !require_is_parent_path.isParentPath(file, context.workspaceConfig.workspaceRoot) ? require_join_paths.joinPaths(context.workspaceConfig.workspaceRoot, file) : file,
		name
	}));
	const defaultSecretsType = await (0, __powerlines_deepkit_reflect_type.reflectType)(context, await require_helpers_persistence.getSecretsDefaultTypeDefinition(context));
	return mergeSecretsReflections(context, [
		await require_helpers_persistence.readSecretsReflection(context),
		config,
		(0, __powerlines_deepkit_vendor_type.resolveClassType)(defaultSecretsType)
	].filter(Boolean));
}
reflectSecrets.__type = [
	() => require_types_plugin.__ΩEnvPluginContext,
	"context",
	"file",
	"name",
	"reflectSecrets",
	"Pn!2\"&2#8&2$8\"/%"
];

//#endregion
exports.BaseEnv = BaseEnv;
exports.BaseSecrets = BaseSecrets;
exports.__ΩCreateEnvReflectionOptions = __ΩCreateEnvReflectionOptions;
exports.createEnvReflection = createEnvReflection;
exports.createSecretsReflection = createSecretsReflection;
exports.mergeEnvReflections = mergeEnvReflections;
exports.mergeSecretsReflections = mergeSecretsReflections;
exports.reflectEnv = reflectEnv;
exports.reflectSecrets = reflectSecrets;