#!/bin/bash
# NEONCYBER - Black/White + Color Highlights
# Monochrome base with selective color pops
# Usage: ./generate-bw-color.sh

set -e

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

echo "⚫⚪ NEONCYBER - Black/White + Color Highlights"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Monochrome with strategic color pops"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

PROMPTS=(
    # 1: Single magenta neon sign
    "Black and white cyberpunk alley with pixel sorting glitch, anime aesthetic. Entire scene monochrome except one vertical neon sign in vivid magenta. Gray wet pavement, white highlights, black shadows. The single magenta sign streaks vertically through pixel sort effect. Everything else pure grayscale. Empty atmospheric noir with one color accent. 1920x1080 widescreen, selective color masterpiece."

    # 2: Cyan vending machine only
    "Monochrome cyberpunk street with databending corruption, minimal style. Black, white, and gray tones dominate. Single vending machine glows in pure electric cyan - only color in entire scene. Grayscale buildings, white wet pavement reflections, black sky. Cyan machine creates stark contrast. Digital glitch artifacts in monochrome. 1920x1080 widescreen, color isolation quality."

    # 3: Purple rain only
    "Black and white empty street with chromatic aberration, anime aesthetic. Entire scene grayscale - buildings, pavement, signs all monochrome. Only the falling rain rendered in deep purple. Purple rain streaks create bokeh against gray cityscape. White highlights on wet surfaces, black shadows. Single color element. 1920x1080 widescreen, purple rain noir masterpiece."

    # 4: Orange hazard lights
    "Monochrome mecha hangar with scan line glitch, minimal industrial style. Pure black and white brutalist architecture. Only hazard warning lights glow in burnt orange - rotating beacons, caution strips. Everything else stark grayscale contrast. Orange cuts through the monochrome dramatically. Empty geometric space. 1920x1080 widescreen, warning light quality."

    # 5: Red exit sign
    "Black and white cyberpunk convenience store with pixel glitch, anime aesthetic. Entire scene monochrome gray scale. Single red exit sign glows above doorway - only color. White interior light spill, black night outside, gray wet pavement. Red sign creates cinematic focal point. Glitch artifacts in grayscale. 1920x1080 widescreen, film noir color pop masterpiece."

    # 6: Gold reflections only
    "Monochrome wet alley with displacement glitch, minimal style. Black shadows, white highlights, gray midtones throughout. Only the puddle reflections rendered in liquid gold color. Gold mirror of grayscale world above. Stark contrast between monochrome reality and golden reflection. Empty surreal atmosphere. 1920x1080 widescreen, selective reflection quality."
)

DESCRIPTIONS=(
    "Magenta Sign Only"
    "Cyan Vending Only"
    "Purple Rain Only"
    "Orange Hazard Only"
    "Red Exit Only"
    "Gold Reflections Only"
)

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, colorful, multiple colors, rainbow", "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_bw_${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 B/W + color variations queued!"
echo ""
echo "📁 Files: ComfyUI/output/wp/"
echo "  wp_bw_${TIMESTAMP}_v1_*.png - Magenta Sign Only"
echo "  wp_bw_${TIMESTAMP}_v2_*.png - Cyan Vending Only"
echo "  wp_bw_${TIMESTAMP}_v3_*.png - Purple Rain Only"
echo "  wp_bw_${TIMESTAMP}_v4_*.png - Orange Hazard Only"
echo "  wp_bw_${TIMESTAMP}_v5_*.png - Red Exit Only"
echo "  wp_bw_${TIMESTAMP}_v6_*.png - Gold Reflections Only"
echo ""
echo "⚫⚪🎨 Monochrome + selective color incoming!"
