"""
电子吧唧 - 序列化器
"""
from rest_framework import serializers
from .models import BadgeImage

VALID_STYLES = [
    'anime', 'realistic', 'pixel', 'watercolor',
    'cyberpunk', 'cute', 'ink', 'comic',
]


class BadgeImageSerializer(serializers.ModelSerializer):
    class Meta:
        model = BadgeImage
        fields = [
            'id', 'prompt', 'style', 'source', 'image_url',
            'generation_status', 'created_at',
        ]


class Text2ImageSerializer(serializers.Serializer):
    prompt = serializers.CharField(max_length=500)
    style = serializers.ChoiceField(choices=VALID_STYLES, required=False)


class Image2ImageSerializer(serializers.Serializer):
    image = serializers.ImageField()
    prompt = serializers.CharField(max_length=500, required=False, allow_blank=True, default='')
    style = serializers.ChoiceField(choices=VALID_STYLES, required=False)
    strength = serializers.FloatField(default=0.7, min_value=0.1, max_value=1.0, required=False)
