#!/bin/bash
# NEONCYBER Batch v3 - Blade Runner/Eva/FLCL/Arcade Vibes
# Usage: ./generate-batch-v3.sh

set -e

COMFYUI="http://192.168.1.57:8188"
DATE=$(date +%Y-%m-%d)

echo "🎮 NEONCYBER Batch v3 - Blade Runner/Eva/FLCL/Arcade"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Aesthetic: Industrial mecha retro-future chaos"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

PROMPTS=(
    # 1: Blade Runner spinner landing
    "Blade Runner style spinner police car landing on wet cyberpunk street at night, anime aesthetic. Vehicle headlights cast orange and cyan beams through purple rain. Industrial smoke stacks in background emit pollution. Neon advertisements in kanji reflect in puddles. Empty brutalist architecture. Moody film noir lighting with volumetric fog. Orange sodium vapor street lights mix with neon pink and cyan. Retro-futuristic 80s sci-fi, minimal composition. 1920x1080 widescreen, cinematic masterpiece quality."

    # 2: Evangelion power lines
    "Massive industrial power lines and transformers in purple twilight, Evangelion aesthetic. Geometric brutalist electrical infrastructure towers over empty street. Orange warning lights blink on towers. Cyan insulators glow. Wet pavement reflects geometric shadows. Telephone poles cross in complex patterns. Ominous scale, oppressive architecture. Purple and orange sky gradient. Anime mechanical aesthetic, clean minimal composition. 1920x1080 widescreen, Eva Unit 01 color palette quality."

    # 3: FLCL Vespa chaos
    "Empty street with abandoned Vespa scooter and bass guitar against wall, FLCL aesthetic. Chaotic graffiti in magenta and cyan. Industrial factory smokestacks background. Orange sodium lights create long shadows. Purple sky with satellites visible. Rebellious teenage energy frozen in time. Retro anime style with bold colors and dynamic angles. Clean composition with attitude. 1920x1080 widescreen, The Pillows soundtrack energy quality."

    # 4: Arcade cabinet alley
    "Narrow alley lined with glowing arcade cabinets and CRT monitors, retro gaming aesthetic. Cabinets display attract mode screens in magenta, cyan, orange. Joystick silhouettes visible. Wet floor reflects pixelated game graphics. Vending machines between cabinets. Empty atmospheric solitude. 80s arcade culture meets cyberpunk. Scan lines, CRT glow, phosphor blur. 1920x1080 widescreen, insert coin quality."

    # 5: Mecha hangar entrance
    "Massive mecha hangar bay doors partially open revealing purple fog inside, anime aesthetic. Industrial yellow warning stripes on door frame. Orange hazard lights rotating. Wet concrete with oil stains and coolant puddles reflecting cyan emergency lights. Brutalist architecture, oppressive scale. Empty maintenance area. Evangelion meets Blade Runner industrial design. 1920x1080 widescreen, Unit 01 hangar quality."

    # 6: Retro-future vending machine shrine
    "Wall of glowing retro vending machines creating a shrine of consumerism, cyberpunk anime aesthetic. Mix of Japanese drinks, cigarettes, instant ramen machines. Each glows different color - orange, magenta, cyan, purple. Wet pavement reflects the entire wall of light. Empty street, one folding chair. Blade Runner meets convenience culture. Industrial pipes overhead. 1920x1080 widescreen, dystopian beauty quality."
)

DESCRIPTIONS=(
    "Blade Runner Spinner"
    "Eva Power Lines"
    "FLCL Vespa Chaos"
    "Arcade Alley"
    "Mecha Hangar"
    "Vending Machine Shrine"
)

for i in {0..5}; do
    NUM=$((i + 1))
    PROMPT="${PROMPTS[$i]}"
    DESC="${DESCRIPTIONS[$i]}"

    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo "[$NUM/6] $DESC"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

    WORKFLOW=$(cat <<EOF
{
  "prompt": {
    "1": {"inputs": {"unet_name": "z_image_turbo_bf16.safetensors", "weight_dtype": "default"}, "class_type": "UNETLoader"},
    "2": {"inputs": {"clip_name": "qwen_3_4b.safetensors", "type": "qwen_image"}, "class_type": "CLIPLoader"},
    "3": {"inputs": {"vae_name": "ae.safetensors"}, "class_type": "VAELoader"},
    "4": {"inputs": {"text": "$PROMPT", "clip": ["2", 0]}, "class_type": "CLIPTextEncode"},
    "5": {"inputs": {"text": "low quality, blurry, people, crowds, bright daylight", "clip": ["2", 0]}, "class_type": "CLIPTextEncode"},
    "6": {"inputs": {"width": 1920, "height": 1080, "batch_size": 1}, "class_type": "EmptyLatentImage"},
    "7": {"inputs": {"seed": $(python3 -c "import random; print(random.randint(1, 2**32-1))"), "steps": 8, "cfg": 1.0, "sampler_name": "euler", "scheduler": "sgm_uniform", "denoise": 1, "model": ["1", 0], "positive": ["4", 0], "negative": ["5", 0], "latent_image": ["6", 0]}, "class_type": "KSampler"},
    "8": {"inputs": {"samples": ["7", 0], "vae": ["3", 0]}, "class_type": "VAEDecode"},
    "9": {"inputs": {"filename_prefix": "wp/wp_anime_${DATE}_v${NUM}", "images": ["8", 0]}, "class_type": "SaveImage"}
  }
}
EOF
)

    RESPONSE=$(curl -s -X POST "$COMFYUI/prompt" -H "Content-Type: application/json" -d "$WORKFLOW")
    PROMPT_ID=$(echo "$RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin).get('prompt_id', ''))" 2>/dev/null || echo "")

    if [ -n "$PROMPT_ID" ]; then
        echo "✅ Queued: $PROMPT_ID"
    else
        echo "❌ Failed to queue"
    fi
    echo ""
done

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✨ All 6 anime-inspired variations queued!"
echo ""
echo "📁 Files: ComfyUI/output/wp/"
echo "  wp_anime_${DATE}_v1_*.png - Blade Runner Spinner"
echo "  wp_anime_${DATE}_v2_*.png - Eva Power Lines"
echo "  wp_anime_${DATE}_v3_*.png - FLCL Vespa"
echo "  wp_anime_${DATE}_v4_*.png - Arcade Alley"
echo "  wp_anime_${DATE}_v5_*.png - Mecha Hangar"
echo "  wp_anime_${DATE}_v6_*.png - Vending Machine Shrine"
echo ""
echo "🎮 Industrial mecha retro-future chaos incoming!"
