#!/bin/bash

# Development server wrapper that filters out Leptos reactive warnings
# This script starts the development server and filters noisy warnings

echo "🚀 Starting development server (filtered output)..."

# Build CSS first
echo "🎨 Building CSS..."
pnpm run build:all

# Kill existing servers
echo "🔄 Cleaning up existing servers..."
lsof -ti:3030 | xargs kill -9 2>/dev/null || true
lsof -ti:3031 | xargs kill -9 2>/dev/null || true

# Start the server with filtered output
cargo leptos serve 2>&1 | grep -v \
    -e "you access a reactive_graph" \
    -e "outside a reactive tracking context" \
    -e "Here's how to fix it:" \
    -e "❌ NO" \
    -e "✅ YES" \
    -e "If this is inside a \`view!\` macro" \
    -e "If it's in the body of a component" \
    -e "If you're \*trying\* to access the value" \
    -e "make sure you are passing a function" \
    -e "try wrapping this access in a closure" \
    -e "use \.get_untracked\(\) or \.with_untracked\(\)"
