"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TemplateService = void 0; const node_fs_1 = require("node:fs"); const node_path_1 = require("node:path"); const nunjucks_1 = __importDefault(require("nunjucks")); const findAppNewRoot = () => { const candidates = [(0, node_path_1.join)(__dirname, "../../.."), (0, node_path_1.join)(__dirname, "../..")]; for (const candidate of candidates) { if ((0, node_fs_1.existsSync)((0, node_path_1.join)(candidate, "templates.json"))) { return candidate; } } throw new Error("Unable to resolve app-new template root"); }; class TemplateService { appNewRoot = findAppNewRoot(); env = nunjucks_1.default.configure((0, node_path_1.join)(this.appNewRoot, "templates"), { autoescape: false, noCache: true }); templates = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(this.appNewRoot, "templates.json"), "utf8")); getTemplates() { return this.templates; } render(templateFile, selection) { return this.env.render(templateFile, selection); } buildSkuExport(skus) { return `[\n${skus.map((sku) => `\t\"${sku}\"`).join(",\n")}\n]`; } } exports.TemplateService = TemplateService;