#!/bin/bash
# NEONCYBER - Color Palette Exploration
# Pixel glitch aesthetic with different color schemes
# Usage: ./generate-color-explore.sh

set -e

COMFYUI="http://192.168.1.57:8188"
TIMESTAMP=$(date +%H%M%S)

echo "🌈 NEONCYBER - Color Palette Exploration"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Pixel glitch aesthetic + different color palettes"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

PROMPTS=(
    # 1: Orange/Teal (Blade Runner cinema palette)
    "Cyberpunk alley with pixel sorting glitch in orange and teal cinema palette, anime aesthetic. Neon signs streak vertically in burnt orange and electric teal. Reality sorted by brightness creating abstract patterns. Wet pavement reflects orange sodium lights and teal neon. Black shadows, warm orange highlights, cool teal accents. Empty atmospheric glitch. Film noir color grading. 1920x1080 widescreen, cinematic color masterpiece."

    # 2: Red/Blue (classic anaglyph 3D)
    "Narrow street with extreme chromatic separation in pure red and cyan blue, minimal glitch style. Every element splits into offset red and blue ghost copies. Reality rendered like broken 3D glasses. Neon signs triple into red/blue displacement. Wet surfaces mirror the color split. Black base with maximum red/cyan contrast. Empty retro glitch atmosphere. 1920x1080 widescreen, anaglyph aesthetic quality."

    # 3: Green/Purple (toxic/radioactive)
    "Cyberpunk convenience store with databending corruption in toxic green and deep purple, anime glitch aesthetic. Neon green signage corrupts into purple digital artifacts. Radioactive color palette meets digital decay. Vending machines glow sickly green with purple scan line errors. Wet floor reflects toxic color patterns. Black shadows. Empty eerie atmosphere. 1920x1080 widescreen, toxic glitch masterpiece."

    # 4: Gold/Black (luxury minimal)
    "Minimal cyberpunk street with pixel sort in gold and pure black, luxury glitch aesthetic. Golden neon signs streak downward against obsidian void. Monochrome elegance meets digital corruption. Wet pavement reflects liquid gold light patterns. Single color luxury with maximum contrast. Empty sophisticated atmosphere. 1920x1080 widescreen, golden glitch quality."

    # 5: Pink/Mint (vaporwave pastel)
    "Alley stairs with soft glitch in pastel pink and mint green, vaporwave aesthetic. Neon signs rendered in cotton candy pink and seafoam mint. Gentle RGB separation, dreamy pixel sorting. Wet surfaces reflect soft pastel gradients. Black accents, soft focus atmosphere. Empty nostalgic digital space. 1920x1080 widescreen, vaporwave glitch masterpiece."

    # 6: White/Black (high contrast ink)
    "Cyberpunk street with aggressive pixel sorting in pure white and black, stark minimal aesthetic. Zero color, maximum contrast glitch. Neon rendered as white light streaks against void. Reality corrupts into binary ink patterns. Wet pavement creates white reflections on black. Brutalist digital aesthetic. Empty high-contrast atmosphere. 1920x1080 widescreen, monochrome glitch quality."
)

DESCRIPTIONS=(
    "Orange/Teal Cinema"
    "Red/Cyan Anaglyph"
    "Green/Purple Toxic"
    "Gold/Black Luxury"
    "Pink/Mint Vaporwave"
    "White/Black Ink"
)

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, normal, clean, colorful", "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_color_${TIMESTAMP}_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 color variations queued!"
echo ""
echo "📁 Files: ComfyUI/output/wp/"
echo "  wp_color_${TIMESTAMP}_v1_*.png - Orange/Teal (Blade Runner)"
echo "  wp_color_${TIMESTAMP}_v2_*.png - Red/Cyan (Anaglyph 3D)"
echo "  wp_color_${TIMESTAMP}_v3_*.png - Green/Purple (Toxic)"
echo "  wp_color_${TIMESTAMP}_v4_*.png - Gold/Black (Luxury)"
echo "  wp_color_${TIMESTAMP}_v5_*.png - Pink/Mint (Vaporwave)"
echo "  wp_color_${TIMESTAMP}_v6_*.png - White/Black (Ink)"
echo ""
echo "🌈 Color palette exploration incoming!"
