"use strict";

import ATReactNativeBridge from "../specs/NativeATBridge.js";
import { ATAdEvents } from "../events/ATAdEvents.js";
import { dispatchInterstitialEvent } from "./ATInterstitialAd.js";
import { ATLog } from "../utils/ATLog.js";
/**
 * 插屏 AutoLoad（静态入口；复用同一事件通道，callbackName 与手动 `ATInterstitialAd` 完全一致）。
 */
export class ATInterstitialAutoAd {
  static setAdListener(placementID, listener) {
    ATAdEvents.setAdListener(placementID, p => dispatchInterstitialEvent(listener, p));
  }
  static removeAdListener(placementID) {
    ATAdEvents.removeAdListener(placementID);
  }
  static addPlacement(placementID, settings = {}) {
    ATReactNativeBridge.addAutoLoadInterstitial(placementID, settings);
  }
  static removePlacement(placementID) {
    ATReactNativeBridge.removeAutoLoadInterstitial(placementID);
  }
  static isAdReady(placementID) {
    return ATReactNativeBridge.autoLoadInterstitialReady(placementID);
  }

  /**
   * 展示 AutoLoad 插屏。
   * - 无参 / string：走 scenario 参数（showAutoLoadInterstitial）
   * - ATShowConfig 对象：走 showConfig（showAutoLoadInterstitialWithConfig）
   */
  static show(placementID, scenarioOrConfig) {
    if (typeof scenarioOrConfig === 'string') {
      return ATReactNativeBridge.showAutoLoadInterstitial(placementID, scenarioOrConfig);
    }
    if (scenarioOrConfig) {
      const bridge = ATReactNativeBridge;
      const showWithConfig = bridge.showAutoLoadInterstitialWithConfig;
      if (typeof showWithConfig === 'function') {
        return showWithConfig.call(bridge, placementID, scenarioOrConfig);
      }
      ATLog.call('ATInterstitialAutoAd', 'show(showConfig fallback)', 'showAutoLoadInterstitialWithConfig unavailable; using JSON scenario');
      return ATReactNativeBridge.showAutoLoadInterstitial(placementID, JSON.stringify(scenarioOrConfig));
    }
    return ATReactNativeBridge.showAutoLoadInterstitial(placementID, '');
  }
}
//# sourceMappingURL=ATInterstitialAutoAd.js.map