import { PlatformAdapter } from './base.js';
export class LiftoffAdapter extends PlatformAdapter {
    getName() {
        return 'Liftoff';
    }
    getSizeLimit() {
        // Liftoff: 建议 <5MB
        return 5 * 1024 * 1024;
    }
    getDefaultFormat() {
        return 'zip';
    }
    async modifyHTML(html, assets) {
        // Liftoff 支持 MRAID 或 window.open
        const liftoffScriptCode = `
      window.mraid = window.mraid || {
        getVersion: function() { return '2.0'; },
        isReady: function() { return true; },
        open: function(url) { 
          console.log('Liftoff CTA: opening store');
          if (url) { window.open(url, '_blank'); return; }
          var ua = navigator.userAgent || '';
          var isIOS = /iPad|iPhone|iPod/.test(ua) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
          window.open(isIOS ? 'https://apps.apple.com/us/app/8-ball-pool/id543186831' : 'https://play.google.com/store/apps/details?id=com.miniclip.eightballpool', '_blank');
        },
        addEventListener: function(event, listener) {},
        removeEventListener: function(event, listener) {},
        getMaxSize: function() { return { width: window.innerWidth, height: window.innerHeight }; },
        getCurrentPosition: function() { return { x: 0, y: 0, width: window.innerWidth, height: window.innerHeight }; },
        getScreenSize: function() { return { width: screen.width, height: screen.height }; }
      };
    `;
        const liftoffScript = await this.minifyPlatformScript(liftoffScriptCode, 'liftoff-mraid');
        const comment = `<!-- Liftoff: ZIP格式, ASCII文件名, 使用mraid.open()或window.open() -->`;
        // 在 </head> 之前插入
        html = html.replace('</head>', `${liftoffScript}${comment}</head>`);
        // 注入统一的 CTA 适配器
        html = await this.injectCTAAdapterAsync(html);
        html = await this.injectTrackingAdapterAsync(html);
        return html;
    }
    getPlatformScript() {
        return `
      // Liftoff Playable Ad
      // 使用 mraid.open() 或 window.open() 跳转
      // 禁止 window.location 重定向
    `;
    }
    validateOptions() {
        if (this.options.format && this.options.format !== 'zip') {
            console.warn('警告: Liftoff 要求 ZIP 格式');
        }
    }
}
