import ATiOSJS from "./ATiOSJS"; // Assuming ATiOSJS is a module

const OC_WRAPPER_CLASS = "ATInterstitialAdWrapper";

interface AdListener {
    // Define the structure of the listener if known
}

const ATiOSInterstitialJS = {
    loadInterstitial(placementId: string, extra: string): void {
        ATiOSJS.printJsLog(`ATiOSInterstitialJS::loadInterstitial(${placementId}, ${extra})`);
        jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "loadInterstitialWithPlacementID:extra:", placementId, extra);
    },

    setAdListener(listener: AdListener): void {
        ATiOSJS.printJsLog(`ATiOSInterstitialJS::setAdListener(${JSON.stringify(listener)})`);
        jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "setDelegates:", JSON.stringify(listener));
    },

    hasAdReady(placementId: string): boolean {
        ATiOSJS.printJsLog(`ATiOSInterstitialJS::hasAdReady(${placementId})`);
        return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "interstitialReadyForPlacementID:", placementId);
    },

    checkAdStatus(placementId: string): string {
        ATiOSJS.printJsLog(`ATiOSInterstitialJS::checkAdStatus(${placementId})`);
        return jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "checkAdStatus:", placementId);
    },

    setUserData(placementId: string, userId: string, userData: string): void {
        cc.log("iOS-setUserData");
    },

    showAd(placementId: string): void {
        ATiOSJS.printJsLog(`ATiOSInterstitialJS::showAd(${placementId})`);
        jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showInterstitialWithPlacementID:scene:", placementId, null);
    },

    showAdInScenario(placementId: string, scenario: string): void {
        ATiOSJS.printJsLog(`ATiOSInterstitialJS::showAd(${placementId}, ${scenario})`);
        jsb.reflection.callStaticMethod(OC_WRAPPER_CLASS, "showInterstitialWithPlacementID:scene:", placementId, scenario);
    }
};

export default ATiOSInterstitialJS;
