"""Add extended plan configuration fields"""
from decimal import Decimal

from django.core.validators import MinValueValidator
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('igny8_core_auth', '0006_add_industry_to_site'),
    ]

    operations = [
        migrations.AddField(
            model_name='plan',
            name='ai_cost_per_request',
            field=models.JSONField(default=dict, help_text="Cost per request type (e.g., {'cluster': 2, 'idea': 3, 'content': 5, 'image': 1})"),
        ),
        migrations.AddField(
            model_name='plan',
            name='allow_credit_topup',
            field=models.BooleanField(default=True, help_text='Can user purchase more credits?'),
        ),
        migrations.AddField(
            model_name='plan',
            name='billing_cycle',
            field=models.CharField(choices=[('monthly', 'Monthly'), ('annual', 'Annual')], default='monthly', max_length=20),
        ),
        migrations.AddField(
            model_name='plan',
            name='daily_ai_request_limit',
            field=models.IntegerField(default=100, help_text='Global daily AI request cap', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='daily_ai_requests',
            field=models.IntegerField(default=50, help_text='Total AI executions (content + idea + image) allowed per day', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='daily_cluster_limit',
            field=models.IntegerField(default=10, help_text='Max clusters that can be created per day', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='daily_content_tasks',
            field=models.IntegerField(default=10, help_text='Max number of content tasks (blogs) per day', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='daily_keyword_import_limit',
            field=models.IntegerField(default=100, help_text='SeedKeywords import limit per day', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='extra_credit_price',
            field=models.DecimalField(decimal_places=2, default=Decimal('0.01'), help_text='Price per additional credit', max_digits=10),
        ),
        migrations.AddField(
            model_name='plan',
            name='image_model_choices',
            field=models.JSONField(default=list, help_text="Allowed image models (e.g., ['dalle3', 'hidream'])"),
        ),
        migrations.AddField(
            model_name='plan',
            name='included_credits',
            field=models.IntegerField(default=0, help_text='Monthly credits included', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='max_author_profiles',
            field=models.IntegerField(default=5, help_text='Limit for saved writing styles', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='max_clusters',
            field=models.IntegerField(default=100, help_text='Total clusters allowed (global)', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='max_images_per_task',
            field=models.IntegerField(default=4, help_text='Max images per content task', validators=[MinValueValidator(1)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='max_industries',
            field=models.IntegerField(blank=True, default=None, help_text='Optional limit for industries/sectors', null=True, validators=[MinValueValidator(1)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='max_keywords',
            field=models.IntegerField(default=1000, help_text='Total keywords allowed (global limit)', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='max_users',
            field=models.IntegerField(default=1, help_text='Total users allowed per account', validators=[MinValueValidator(1)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='monthly_ai_credit_limit',
            field=models.IntegerField(default=500, help_text='Unified credit ceiling per month (all AI functions)', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='monthly_cluster_ai_credits',
            field=models.IntegerField(default=50, help_text='AI credits allocated for clustering', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='monthly_content_ai_credits',
            field=models.IntegerField(default=200, help_text='AI credit pool for content generation', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='monthly_image_ai_credits',
            field=models.IntegerField(default=100, help_text='AI credit pool for image generation', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='monthly_image_count',
            field=models.IntegerField(default=100, help_text='Max images per month', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='monthly_word_count_limit',
            field=models.IntegerField(default=50000, help_text='Monthly word limit (for generated content)', validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='auto_credit_topup_threshold',
            field=models.IntegerField(blank=True, default=None, help_text='Auto top-up trigger point (optional)', null=True, validators=[MinValueValidator(0)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='auto_credit_topup_amount',
            field=models.IntegerField(blank=True, default=None, help_text='How many credits to auto-buy', null=True, validators=[MinValueValidator(1)]),
        ),
        migrations.AddField(
            model_name='plan',
            name='stripe_product_id',
            field=models.CharField(blank=True, help_text='For Stripe plan sync', max_length=255, null=True),
        ),
        migrations.AlterField(
            model_name='plan',
            name='features',
            field=models.JSONField(default=list, help_text="Plan features as JSON array (e.g., ['ai_writer', 'image_gen', 'auto_publish'])"),
        ),
    ]

