"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.themeLimitMessage = exports.checkThemeLimits = exports.getThemeTotalBytes = exports.MAX_THEME_FILE_BYTES = exports.MAX_THEME_TOTAL_BYTES = exports.ORGANIZATION_DESIGN_FILE_KINDS = void 0;
/**
 * The kind of file inside an organization design. The pipeline uses this
 * to decide where to place the file inside the sandbox (`css/`, `fonts/`,
 * `images/`) and which files to concatenate into the system-prompt skill
 * append (`instruction`).
 */
exports.ORGANIZATION_DESIGN_FILE_KINDS = [
    'css',
    'font',
    'image',
    'instruction',
];
/**
 * Guardrails on how large a theme can grow. A theme's files are streamed into
 * the data-app sandbox on every generation, so an oversized theme times out on
 * the copy when a build applies it.
 *
 * The binding constraint is total bytes (large images), NOT file count — a
 * theme with many small text files is cheap, while a handful of big images is
 * not. So we cap aggregate size only; there is intentionally no file-count cap.
 * `MAX_THEME_FILE_BYTES` bounds any single file. Enforced at upload time and
 * re-checked before a build starts.
 */
exports.MAX_THEME_TOTAL_BYTES = 100 * 1024 * 1024; // 100 MB across all files
exports.MAX_THEME_FILE_BYTES = 10 * 1024 * 1024; // 10 MB per file
const getThemeTotalBytes = (files) => files.reduce((sum, f) => sum + f.sizeBytes, 0);
exports.getThemeTotalBytes = getThemeTotalBytes;
/**
 * Returns the total-size limit if a set of theme files exceeds it, or null
 * when within limits.
 */
const checkThemeLimits = (files) => {
    const bytes = (0, exports.getThemeTotalBytes)(files);
    if (bytes > exports.MAX_THEME_TOTAL_BYTES) {
        return { bytes, limit: exports.MAX_THEME_TOTAL_BYTES };
    }
    return null;
};
exports.checkThemeLimits = checkThemeLimits;
const formatThemeMb = (bytes) => `${Math.round(bytes / (1024 * 1024))} MB`;
const themeLimitMessage = (violation, themeName) => {
    const label = themeName ? `Theme "${themeName}"` : 'This theme';
    return `${label} totals ${formatThemeMb(violation.bytes)} of assets, above the limit of ${formatThemeMb(violation.limit)}. Remove some assets and try again.`;
};
exports.themeLimitMessage = themeLimitMessage;
//# sourceMappingURL=types.js.map