"use strict";
/**
 * @file pattern-registry.ts
 * Pattern Registry for UI Suite Integration
 *
 * This registry defines all AI-powered components in a format
 * compatible with Drupal's UI Patterns module.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.patternRegistry = void 0;
exports.getPatternsByCategory = getPatternsByCategory;
exports.getPatternsWithAIFeature = getPatternsWithAIFeature;
exports.exportToDrupalPattern = exportToDrupalPattern;
/**
 * Registry of all AI-enhanced component patterns
 */
exports.patternRegistry = {
    // AI Button Pattern
    'ai_button': {
        id: 'ai_button',
        label: 'AI-Enhanced Button',
        description: 'Self-optimizing button with predictive loading and usage learning',
        category: 'ai-enhanced',
        fields: {
            text: {
                type: 'text',
                label: 'Button Text',
                required: true,
            },
            variant: {
                type: 'select',
                label: 'Button Variant',
                default: 'primary',
                options: {
                    primary: 'Primary',
                    secondary: 'Secondary',
                    danger: 'Danger',
                    success: 'Success',
                },
            },
            size: {
                type: 'select',
                label: 'Button Size',
                default: 'medium',
                options: {
                    small: 'Small',
                    medium: 'Medium',
                    large: 'Large',
                },
            },
            ai_config: {
                type: 'mapping',
                label: 'AI Configuration',
                fields: {
                    optimize_performance: {
                        type: 'boolean',
                        label: 'Optimize Performance',
                        description: 'AI automatically optimizes button rendering',
                        default: true,
                    },
                    predictive_loading: {
                        type: 'boolean',
                        label: 'Predictive Loading',
                        description: 'Pre-load resources based on user behavior',
                        default: true,
                    },
                    usage_learning: {
                        type: 'boolean',
                        label: 'Usage Learning',
                        description: 'Learn from user interactions to improve UX',
                        default: true,
                    },
                    auto_a11y: {
                        type: 'boolean',
                        label: 'Auto Accessibility',
                        description: 'AI-powered accessibility enhancements',
                        default: true,
                    },
                },
            },
        },
        aiFeatures: [
            {
                id: 'self_optimization',
                label: 'Self-Optimization',
                description: 'Automatically optimizes rendering performance',
                configurable: true,
            },
            {
                id: 'predictive_actions',
                label: 'Predictive Actions',
                description: 'Predicts and preloads next user actions',
                configurable: true,
            },
        ],
    },
    // AI Card Pattern
    'ai_card': {
        id: 'ai_card',
        label: 'AI-Powered Card',
        description: 'Adaptive card component with content personalization',
        category: 'ai-enhanced',
        fields: {
            title: {
                type: 'text',
                label: 'Card Title',
                required: true,
            },
            content: {
                type: 'text',
                label: 'Card Content',
                required: true,
            },
            media: {
                type: 'mapping',
                label: 'Media Configuration',
                fields: {
                    image_url: {
                        type: 'text',
                        label: 'Image URL',
                    },
                    alt_text: {
                        type: 'text',
                        label: 'Alt Text',
                    },
                    ai_optimize: {
                        type: 'boolean',
                        label: 'AI Image Optimization',
                        default: true,
                    },
                },
            },
            ai_features: {
                type: 'mapping',
                label: 'AI Features',
                fields: {
                    content_personalization: {
                        type: 'boolean',
                        label: 'Content Personalization',
                        description: 'Adapt content based on user preferences',
                        default: true,
                    },
                    auto_summarization: {
                        type: 'boolean',
                        label: 'Auto Summarization',
                        description: 'AI generates content summaries',
                        default: false,
                    },
                    engagement_tracking: {
                        type: 'boolean',
                        label: 'Engagement Tracking',
                        description: 'Track and learn from user engagement',
                        default: true,
                    },
                },
            },
        },
        aiFeatures: [
            {
                id: 'adaptive_content',
                label: 'Adaptive Content',
                description: 'Content adapts to user behavior and preferences',
                configurable: true,
            },
            {
                id: 'smart_layout',
                label: 'Smart Layout',
                description: 'AI optimizes card layout for better engagement',
                configurable: true,
            },
        ],
    },
    // AI Input Pattern
    'ai_input': {
        id: 'ai_input',
        label: 'AI-Assisted Input',
        description: 'Input field with AI-powered suggestions and validation',
        category: 'form',
        fields: {
            label: {
                type: 'text',
                label: 'Field Label',
                required: true,
            },
            placeholder: {
                type: 'text',
                label: 'Placeholder Text',
            },
            type: {
                type: 'select',
                label: 'Input Type',
                default: 'text',
                options: {
                    text: 'Text',
                    email: 'Email',
                    url: 'URL',
                    tel: 'Telephone',
                    search: 'Search',
                },
            },
            ai_assistance: {
                type: 'mapping',
                label: 'AI Assistance',
                fields: {
                    auto_complete: {
                        type: 'boolean',
                        label: 'AI Auto-Complete',
                        description: 'Intelligent suggestions as user types',
                        default: true,
                    },
                    smart_validation: {
                        type: 'boolean',
                        label: 'Smart Validation',
                        description: 'AI-powered input validation',
                        default: true,
                    },
                    error_prediction: {
                        type: 'boolean',
                        label: 'Error Prediction',
                        description: 'Predict and prevent input errors',
                        default: false,
                    },
                    language_detection: {
                        type: 'boolean',
                        label: 'Language Detection',
                        description: 'Detect input language and adapt',
                        default: false,
                    },
                },
            },
        },
    },
    // AI Dashboard Pattern
    'ai_dashboard': {
        id: 'ai_dashboard',
        label: 'AI Analytics Dashboard',
        description: 'Self-organizing dashboard with predictive insights',
        category: 'display',
        fields: {
            title: {
                type: 'text',
                label: 'Dashboard Title',
                required: true,
            },
            widgets: {
                type: 'text',
                label: 'Widget Configuration',
                description: 'JSON configuration for dashboard widgets',
            },
            ai_config: {
                type: 'mapping',
                label: 'AI Configuration',
                fields: {
                    auto_arrange: {
                        type: 'boolean',
                        label: 'Auto-Arrange Widgets',
                        description: 'AI arranges widgets based on usage',
                        default: true,
                    },
                    predictive_insights: {
                        type: 'boolean',
                        label: 'Predictive Insights',
                        description: 'Show AI-generated predictions',
                        default: true,
                    },
                    adaptive_refresh: {
                        type: 'boolean',
                        label: 'Adaptive Refresh',
                        description: 'Intelligent data refresh rates',
                        default: true,
                    },
                    personalized_metrics: {
                        type: 'boolean',
                        label: 'Personalized Metrics',
                        description: 'Customize metrics per user',
                        default: true,
                    },
                },
            },
        },
        aiFeatures: [
            {
                id: 'predictive_analytics',
                label: 'Predictive Analytics',
                description: 'AI predicts trends and anomalies',
                configurable: true,
            },
            {
                id: 'smart_organization',
                label: 'Smart Organization',
                description: 'Dashboard self-organizes based on importance',
                configurable: true,
            },
        ],
    },
};
/**
 * Get all patterns by category
 */
function getPatternsByCategory(category) {
    return Object.values(exports.patternRegistry).filter(pattern => pattern.category === category);
}
/**
 * Get patterns with specific AI features
 */
function getPatternsWithAIFeature(featureId) {
    return Object.values(exports.patternRegistry).filter(pattern => pattern.aiFeatures?.some(feature => feature.id === featureId));
}
/**
 * Export pattern for Drupal UI Patterns
 */
function exportToDrupalPattern(patternId) {
    const pattern = exports.patternRegistry[patternId];
    if (!pattern) {
        throw new Error(`Pattern ${patternId} not found`);
    }
    return {
        [patternId]: {
            label: pattern.label,
            description: pattern.description,
            fields: Object.entries(pattern.fields).reduce((acc, [key, field]) => {
                acc[key] = {
                    type: field.type,
                    label: field.label,
                    description: field.description,
                    preview: field.default,
                };
                return acc;
            }, {}),
        },
    };
}
//# sourceMappingURL=pattern-registry.js.map