/**
 * 路由配置验证 Schema（使用 Zod）
 */ "use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get componentImportSchema () {
        return componentImportSchema;
    },
    get routeConfigSchema () {
        return routeConfigSchema;
    },
    get routeItemHandleSchema () {
        return routeItemHandleSchema;
    },
    get routerConfigSchema () {
        return routerConfigSchema;
    },
    get safeValidateRouterConfig () {
        return safeValidateRouterConfig;
    },
    get validateRouterConfig () {
        return validateRouterConfig;
    }
});
const _zod = require("zod");
const routeItemHandleSchema = _zod.z.object({
    title: _zod.z.string().min(1, '路由标题不能为空'),
    i18nKey: _zod.z.string().optional(),
    order: _zod.z.number().int('排序值必须是整数'),
    icon: _zod.z.string().optional(),
    hideInMenu: _zod.z.boolean().optional(),
    hideFooter: _zod.z.boolean().optional(),
    keepAlive: _zod.z.boolean().optional(),
    needLogin: _zod.z.boolean().optional(),
    roles: _zod.z.array(_zod.z.string()).optional(),
    name: _zod.z.string().optional()
}).passthrough(); // 允许其他自定义字段
const componentImportSchema = _zod.z.union([
    _zod.z.string().min(1, '组件路径不能为空'),
    _zod.z.function(),
    _zod.z.null()
]);
const routeConfigSchema = _zod.z.lazy(()=>_zod.z.object({
        layout: componentImportSchema.optional().nullable(),
        page: componentImportSchema.optional().nullable(),
        loading: componentImportSchema.optional().nullable(),
        errors: componentImportSchema.optional().nullable(),
        name: _zod.z.string().min(1, '路由名称不能为空'),
        path: _zod.z.string().optional(),
        isGroup: _zod.z.boolean().optional(),
        enableRedirection: _zod.z.boolean().optional(),
        handle: routeItemHandleSchema,
        children: _zod.z.array(routeConfigSchema).optional()
    }));
const routerConfigSchema = _zod.z.object({
    enabled: _zod.z.union([
        _zod.z.boolean(),
        _zod.z.literal('disabled')
    ]).optional(),
    routes: _zod.z.union([
        _zod.z.array(routeConfigSchema),
        _zod.z.function()
    ]).optional(),
    mode: _zod.z.enum([
        'browser',
        'hash',
        'memory'
    ]).optional(),
    options: _zod.z.any().optional(),
    pathResolve: _zod.z.object({
        basePath: _zod.z.string().optional(),
        pathAliases: _zod.z.record(_zod.z.string(), _zod.z.string()).optional()
    }).optional(),
    transformOptions: _zod.z.any().optional()
});
function validateRouterConfig(config) {
    return routerConfigSchema.parse(config);
}
function safeValidateRouterConfig(config) {
    return routerConfigSchema.safeParse(config);
}

//# sourceMappingURL=schema.js.map