
import { WhiskClient } from '../lib/whisk-client';

// User-provided Whisk cookies
const WHISK_COOKIES = JSON.stringify([
    {
        "domain": "labs.google",
        "hostOnly": true,
        "httpOnly": true,
        "name": "__Host-next-auth.csrf-token",
        "path": "/",
        "sameSite": "lax",
        "secure": true,
        "session": true,
        "storeId": null,
        "value": "7485620ca6c96e35b3949dc2ddc79dcf4419285e50534bdba72575e4901324a1%7C1a14ffc355e181cb4ef8c01a6446d33c583ca940be54c20e157c1851a3313e8f"
    },
    {
        "domain": "labs.google",
        "hostOnly": true,
        "httpOnly": true,
        "name": "__Secure-next-auth.callback-url",
        "path": "/",
        "sameSite": "lax",
        "secure": true,
        "session": true,
        "storeId": null,
        "value": "https%3A%2F%2Flabs.google%2Ffx%2Ftools%2Fmusic-fx%2Funsupported-country"
    },
    {
        "domain": "labs.google",
        "expirationDate": 1770190006.527353,
        "hostOnly": true,
        "httpOnly": true,
        "name": "__Secure-next-auth.session-token",
        "path": "/",
        "sameSite": "lax",
        "secure": true,
        "session": false,
        "storeId": null,
        "value": "eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..sNTX3pzNatN34d3B.CNKFzpp_4ZYRyVnB2zyVa_4kGxtHgcIgYxD_zuV1oNW5bjQteCUm83gNr3o0kM4pVYk8zkrfeWvJj9D6JbH8pu2ylhtRlI8__iGhL6ZrS2iRZ8Ia1ojVMrXnFMttv6J6PVZEsPTBaI__O4Fqe4sVp8GIkBya5PTq_hmaYFKgAao4jplGrl7f63_IYzWwUmNs5BOwQtIxfJiTulm3333jVaeazfnq3jSC93aPiPM5z-XTtV2vE1gxJqNbAyJXgli_i-aoIUMB9d-sy7YWLAdwSPZoANp8tuXjd62AaZ74IJ-9lnKUoasBnU2oogDPcArIgD5W1Bacf-Snb131_uQ_uidmvGNmk6-JfFRpfjAVTL7c_S00IDowJzODQOJ2kLVYy8hFgGfuxDGFfOCBLztrTCTmmlWB_yGHjmUSr8mrI2_fn6cDOiAEoZ75M70NU-v3oJB14tr1h3r4jmUAVwbT7Knh2fCjpv-DT1yk3kzqPHpLrdL4cx3liq0mYoszZ8W5bM0IJiKueLVXulIEpHxUkKzDglMEud0ABGWFfWO4UfZnCc8XJXRf1aLIuA3q_DgvlnCH2Wo5go7OdPR6HFKqzOASGoxpm6f1qQMhiDzFn5-Fs_wyenGauJfwap9qwINZxQWSA1_5jl6VSRbFcHMQghB0tJiMhIwV9XPlENafIszvQAVIhpA9ACniG_Mxb8wBWuYFtnphlK4w3ehTxus15G8P0CtaPWJn4I40DyHZnZqulDU2y05ozW-D66LkIGFuUlO-PpHTPQvh2hlL5fq6ac92iN_eZuSLI3qPNCv11PHRhXzDj87S3J2fRc4dzKAN6PUooSZTSQSYTJa5MJVhP1wnRdfLoEfLJ7oCt7XnLNqIEas7J3hi55s3oATuT93fi-edjF7gnZaM4zEKQKqxGKFbOmuiglV7eFADRxkGz7vEZ-kjxvPgEtO4jVCxE-SJ_s1e067bpkYVy9IHZXhJOUO61bCQykIwjlZckP2Fz2VF1W6HYnc.AXU0oelImaOeGzkoH7OxRg"
    }
]);

// Use a small test image (1x1 red pixel PNG)
const TINY_TEST_IMAGE_BASE64 = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg==";

async function testUpload() {
    console.log("=== Whisk Upload Debug Test ===\n");

    const client = new WhiskClient(WHISK_COOKIES);

    try {
        console.log("1. Testing Subject upload...");
        const subjectId = await client.uploadReferenceImage(TINY_TEST_IMAGE_BASE64, "image/png", "subject");
        console.log(`   ✅ Subject upload SUCCESS: ${subjectId}`);
    } catch (e: any) {
        console.error(`   ❌ Subject upload FAILED: ${e.message}`);
    }

    try {
        console.log("\n2. Testing Scene upload...");
        const sceneId = await client.uploadReferenceImage(TINY_TEST_IMAGE_BASE64, "image/png", "scene");
        console.log(`   ✅ Scene upload SUCCESS: ${sceneId}`);
    } catch (e: any) {
        console.error(`   ❌ Scene upload FAILED: ${e.message}`);
    }

    try {
        console.log("\n3. Testing Style upload...");
        const styleId = await client.uploadReferenceImage(TINY_TEST_IMAGE_BASE64, "image/png", "style");
        console.log(`   ✅ Style upload SUCCESS: ${styleId}`);
    } catch (e: any) {
        console.error(`   ❌ Style upload FAILED: ${e.message}`);
    }

    console.log("\n=== Test Complete ===");
}

testUpload();
