/**
 * Settings validation schema for Assets
 * Auto-generated from baseline.json
 * 
 * @module Performance/Assets
 * @since 0.1.0
 */

import { z } from 'zod';

/**
 * Settings schema for Assets
 */
export const AssetsSchema = z.object({
  enable_asset_optimization: z.boolean().default(false),  // Enable CSS/JS optimization
  minify_css: z.boolean().default(true),  // Minify CSS files
  minify_js: z.boolean().default(true),  // Minify JavaScript files
  combine_css: z.boolean().default(false),  // Combine CSS files
  combine_js: z.boolean().default(false),  // Combine JavaScript files
  defer_js: z.boolean().default(true),  // Defer JavaScript execution
  async_js: z.array(z.string()).default([]),  // Scripts to load asynchronously
  remove_query_strings: z.boolean().default(true),  // Remove query strings from static resources
  exclude_css: z.array(z.string()).default([]),  // CSS files to exclude from optimization
  exclude_js: z.array(z.string()).default(["jquery","jquery-migrate"]),  // JS files to exclude from optimization
  cdn_url: z.string().default(''),  // CDN URL for static assets (URL validation applied only when non-empty)
  enable_preload: z.boolean().default(true),  // Enable resource preloading
  preload_fonts: z.array(z.string()).default([]),  // Font files to preload
});

/**
 * TypeScript type for Assets settings
 */
export type AssetsSettings = z.infer<typeof AssetsSchema>;

/**
 * Default values for Assets settings
 */
export const AssetsDefaults: AssetsSettings = AssetsSchema.parse({});

/**
 * Validate Assets settings
 */
export function validateAssetsSettings(data: unknown): AssetsSettings {
  return AssetsSchema.parse(data);
}

/**
 * Safely validate Assets settings (returns validation result)
 */
export function safeValidateAssetsSettings(data: unknown) {
  return AssetsSchema.safeParse(data);
}
