import { __ΩEnvPluginContext, __ΩEnvType } from "../types/plugin.mjs";
import { readEnvTypeReflection } from "./persistence.mjs";
import { ReflectionClass } from "@powerlines/deepkit/vendor/type";
import { titleCase } from "@stryke/string-format/title-case";

//#region src/helpers/template-helpers.ts
function __assignType(fn, args) {
	fn.__type = args;
	return fn;
}
/**
* Creates the reflection data used when generating runtime template files.
*
* @param context - The context for the configuration plugin.
* @param name - The name of the configuration template.
* @returns The reflection for the specified configuration template.
*/
async function createTemplateReflection(context, name) {
	const reflection = await readEnvTypeReflection(context, name);
	reflection.getProperties().forEach(__assignType((prop) => {
		prop.getAlias().filter(Boolean).forEach(__assignType((alias) => {
			reflection.addProperty({
				name: alias,
				optional: prop.isOptional() ? true : void 0,
				readonly: prop.isReadonly() ? true : void 0,
				description: prop.getDescription(),
				visibility: prop.getVisibility(),
				type: prop.getType(),
				default: prop.getDefaultValue(),
				tags: {
					hidden: prop.isHidden(),
					ignore: prop.isIgnored(),
					internal: prop.isInternal(),
					alias: prop.getAlias().filter(__assignType((a) => a !== alias, [
						"a",
						"",
						"P\"2!\"/\""
					])).concat(prop.name),
					title: prop.getTitle() || titleCase(prop.name),
					readonly: prop.isReadonly(),
					permission: prop.getPermission(),
					domain: prop.getDomain()
				}
			});
		}, [
			"alias",
			"",
			"P\"2!\"/\""
		]));
	}, [
		"prop",
		"",
		"P\"2!\"/\""
	]));
	return reflection;
}
createTemplateReflection.__type = [
	() => __ΩEnvPluginContext,
	"context",
	() => __ΩEnvType,
	"name",
	() => ReflectionClass,
	"createTemplateReflection",
	"Creates the reflection data used when generating runtime template files.",
	"Pn!2\"n#2$8P\"7%`/&?'"
];

//#endregion
export { createTemplateReflection };
//# sourceMappingURL=template-helpers.mjs.map