"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LEGACY_COMMIT_TEMPLATE_NAME = exports.ApplicationScope = exports.CUSTOM_THEME_TYPOGRAPHY_KEY = exports.ThemeMode = exports.DEFAULT_ROUTE_ID = exports.ComponentEvent = void 0;
exports.getDefaultRoute = getDefaultRoute;
exports.toExportedApplicationSettings = toExportedApplicationSettings;
exports.toNonVersionedApplicationSettings = toNonVersionedApplicationSettings;
exports.isFullApplicationV2Dto = isFullApplicationV2Dto;
exports.isExportedApplicationDto = isExportedApplicationDto;
exports.isSdkApiTemplate = isSdkApiTemplate;
exports.effectiveCommitTemplateName = effectiveCommitTemplateName;
exports.isSdkApiCommitTemplate = isSdkApiCommitTemplate;
var ComponentEvent;
(function (ComponentEvent) {
    ComponentEvent["CREATE"] = "create";
    ComponentEvent["INIT"] = "init";
    ComponentEvent["LOGIN"] = "login";
    ComponentEvent["MIGRATE"] = "migrate";
    ComponentEvent["PULL"] = "pull";
    ComponentEvent["PUSH"] = "push";
    ComponentEvent["REGISTER"] = "register";
    ComponentEvent["UPLOAD"] = "upload";
    ComponentEvent["DEPLOY"] = "deploy";
})(ComponentEvent || (exports.ComponentEvent = ComponentEvent = {}));
// Necessary because the fallback route might not be saved until the user first modifies their routes
exports.DEFAULT_ROUTE_ID = 'ahjjxoy521';
// Necessary for backwards compatibility with pre-multi-page applications
function getDefaultRoute(pageId) {
    return {
        id: exports.DEFAULT_ROUTE_ID,
        pageId,
        path: '/'
    };
}
var ThemeMode;
(function (ThemeMode) {
    ThemeMode["LIGHT"] = "LIGHT";
    ThemeMode["DARK"] = "DARK";
    ThemeMode["AUTO"] = "AUTO";
})(ThemeMode || (exports.ThemeMode = ThemeMode = {}));
exports.CUSTOM_THEME_TYPOGRAPHY_KEY = 'custom';
function toExportedApplicationSettings(applicationSettings) {
    return {
        componentBaseUrl: applicationSettings.componentBaseUrl,
        registeredComponents: applicationSettings.registeredComponents,
        files: applicationSettings.files,
        sourceFiles: applicationSettings.sourceFiles,
        bundledFiles: applicationSettings.bundledFiles,
        cliVersion: applicationSettings.cliVersion,
        componentsLastUploaded: applicationSettings.componentsLastUploaded,
        theme: applicationSettings.theme
    };
}
function toNonVersionedApplicationSettings(applicationSettings) {
    if (!applicationSettings) {
        return;
    }
    return {
        profiles: applicationSettings.profiles
    };
}
function isFullApplicationV2Dto(value) {
    return (isExportedApplicationDto(value) &&
        'updated' in value.application &&
        'created' in value.application &&
        'deletedAt' in value.application &&
        'folderId' in value.application &&
        'isDeployed' in value.application &&
        'isPublic' in value.application &&
        'isEditable' in value.application &&
        'userPermissions' in value.application);
}
function isExportedApplicationDto(value) {
    return Object.prototype.hasOwnProperty.call(value, 'application');
}
var ApplicationScope;
(function (ApplicationScope) {
    ApplicationScope["APP"] = "APP";
    ApplicationScope["PAGE"] = "PAGE";
    ApplicationScope["GLOBAL"] = "GLOBAL";
})(ApplicationScope || (exports.ApplicationScope = ApplicationScope = {}));
/**
 * Returns true if the application's template uses the SDK API structure.
 * Legacy apps (templateName null/undefined) use YAML API.
 *
 * Must stay in sync with the `sdkApi` field in packages/demo-apps/config.json.
 */
const SDK_API_TEMPLATES = new Set(['app-fullstack']);
function isSdkApiTemplate(templateName) {
    if (!templateName)
        return false;
    return SDK_API_TEMPLATES.has(templateName);
}
/**
 * The legacy template name that commits predating the per-commit `template_name`
 * column are treated as. NULL on `application_commit.template_name` means the
 * commit was created before the per-commit column existed (or by a legacy
 * write path), and must be rendered with the old YAML/shadcn code path.
 */
exports.LEGACY_COMMIT_TEMPLATE_NAME = 'shadcn-demo-app';
/**
 * Resolves the effective template name for a given commit. NULL means "legacy
 * template" (rendered as `shadcn-demo-app`); anything non-null is the explicit
 * template the commit was created against.
 *
 * Use this helper anywhere `isSdkApiTemplate` is evaluated against a commit
 * rather than the application row (e.g. when serving preview/deployed versions).
 */
function effectiveCommitTemplateName(commitTemplateName) {
    return commitTemplateName ?? exports.LEGACY_COMMIT_TEMPLATE_NAME;
}
/**
 * Convenience: does the commit-scoped template use the SDK API structure?
 * Equivalent to `isSdkApiTemplate(effectiveCommitTemplateName(commitTemplateName))`.
 */
function isSdkApiCommitTemplate(commitTemplateName) {
    return isSdkApiTemplate(effectiveCommitTemplateName(commitTemplateName));
}
//# sourceMappingURL=index.js.map