<!DOCTYPE html>
<html lang="en" data-device="mobile" data-ui-contain="1" data-isdesktop="1"
  style="--lobby__max-width: 529.047976011994px; --lobby__vh: 9.41px;">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="google" content="notranslate">
  <title>Teen Patti Master</title>
  <meta name="viewport"
    content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link rel="shortcut icon" href="https://assets.googleplaystore.in/4P8TK3YN/images/icon.webp" type="image/x-icon">

  <link rel="stylesheet" href="https://assets.googleplaystore.in/4P8TK3YN/css/input.css">
  <link rel="stylesheet" href="https://assets.googleplaystore.in/4P8TK3YN/css/swiper-bundle.min.css">

  <!-- Google tag (gtag.js) dynamically loaded with Thymeleaf -->
  <script src="https://www.googletagmanager.com/gtag/js?id=G-M947WW7994" async></script>

  <script>
    window.dataLayer = window.dataLayer || [];

    function gtag() {
      dataLayer.push(arguments);
    }

    gtag('js', new Date());

    gtag('config', "G-M947WW7994");
  </script>

  <!-- Facebook Pixel dynamically loaded with Thymeleaf -->
  <script>
    /*<![CDATA[*/
    !function (f, b, e, v, n, t, s) {
      if (f.fbq) return;
      n = f.fbq = function () {
        n.callMethod ?
                n.callMethod.apply(n, arguments) : n.queue.push(arguments)
      };
      if (!f._fbq) f._fbq = n;
      n.push = n;
      n.loaded = !0;
      n.version = '2.0';
      n.queue = [];
      t = b.createElement(e);
      t.async = !0;
      t.src = v;
      s = b.getElementsByTagName(e)[0];
      s.parentNode.insertBefore(t, s)
    }(window, document, 'script',
            'https://connect.facebook.net/en_US/fbevents.js');
    fbq('init', "2231091787685609");
    fbq('track', 'PageView');
    /*]]>*/
  </script>

  <noscript><img height="1" width="1" style="display:none"
                 src="https://www.facebook.com/tr?id=2231091787685609&amp;ev=PageView&amp;noscript=1"/></noscript>
  <!-- End Meta Pixel Code -->
</head>

<body>
  <div id="link">
    <div style="width: 100%;">
      <img src="https://assets.googleplaystore.in/4P8TK3YN/images/bg1.jpg" />
    </div>
    <div style="width: 100%;position:relative">
      <div style="display: flex;justify-content:center;align-items:center;position:absolute;padding:0 1.2rem;cursor: pointer;"
        class="animate-[zoomin_1.2s_infinite]" id="installbtn2" onclick="download('download_button')">
        <img src="https://assets.googleplaystore.in/4P8TK3YN/images/download.png" style="width: 90%;">
      </div>
      <img src="https://assets.googleplaystore.in/4P8TK3YN/images/bg2.jpg" />
      <div class="swiper-container  z-10">
        <div class="swiper mySwiper swiper-initialized swiper-horizontal swiper-backface-hidden"
          style="border-radius: .3rem;">
          <div class="swiper-wrapper" aria-live="off">
            <div class="swiper-slide " style="border-radius: .3rem;">
              <img src="https://assets.googleplaystore.in/4P8TK3YN/images/ban-1.png" alt="F2GAME" style="border-radius: .3rem;">
            </div>
            <div class="swiper-slide">
              <img src="https://assets.googleplaystore.in/4P8TK3YN/images/ban-3.png" alt="F2GAME" style="border-radius: .3rem;">
            </div>
            <div class="swiper-slide swiper-slide-next" style="border-radius: .3rem;">
              <img src="https://assets.googleplaystore.in/4P8TK3YN/images/ban-2.png" alt="F2GAME" style="border-radius: .3rem;">
            </div>
            <div class="swiper-slide swiper-slide-next" style="border-radius: .3rem;">
              <img src="https://assets.googleplaystore.in/4P8TK3YN/images/ban-4.png" alt="F2GAME" style="border-radius: .3rem;">
            </div>
          </div>
          <div
            class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets swiper-pagination-horizontal">
            <span class="swiper-pagination-bullet swiper-pagination-bullet-active" tabindex="0" role="button"
              aria-label="Go to slide 1" aria-current="true"></span><span class="swiper-pagination-bullet" tabindex="0"
              role="button" aria-label="Go to slide 2"></span><span class="swiper-pagination-bullet" tabindex="0"
              role="button" aria-label="Go to slide 3"></span><span class="swiper-pagination-bullet" tabindex="0"
              role="button" aria-label="Go to slide 4"></span>
          </div>
          <span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span>
        </div>
      </div>
    </div>

    <div style="width: 100%;position:relative">
      <img src="https://assets.googleplaystore.in/4P8TK3YN/images/bg3.jpg"/>
    </div>

  </div>
  <script src="https://assets.googleplaystore.in/4P8TK3YN/js/swiper-bundle.min.js"></script>

  <script>
    function resize() {
      const isDesktop = window.innerWidth > 750

      const windowWidth = window.innerWidth
      const windowHeight = window.innerHeight
      const aspectRatio = 750 / 1334

      const device = "mobile"
      let uiContain = "0"

      // calculate the maximum width
      const maxWidth = windowWidth / windowHeight > aspectRatio ? aspectRatio * windowHeight : windowWidth

      // When the width is greater than 450 and is not flat, set uiContain to 1
      if (windowWidth > 450) {
        uiContain = "1"
      }

      // set html element styles and properties
      const htmlElement = document.querySelector("html")
      if (htmlElement) {
        htmlElement.style.setProperty("--lobby__max-width", uiContain === "1" ? `${maxWidth}px` : "100%")
        htmlElement.style.setProperty("--lobby__vh", `${windowHeight * 0.01}px`)
        htmlElement.setAttribute("data-device", device)
        htmlElement.setAttribute("data-ui-contain", uiContain)
        htmlElement.setAttribute("data-isdesktop", isDesktop ? "1" : "0")
      }
    }

    resize();
    window.addEventListener('resize', resize);
    (function preventZoom() {
        let lastTouchEnd = 0

        document.addEventListener("touchstart", (e) => {
          if (e.touches.length > 1) {
            e.preventDefault()
          }
        })

        document.addEventListener("touchend", (e) => {
          const now = new Date().getTime()
          if (now - lastTouchEnd <= 300) {
            e.preventDefault()
          }
          lastTouchEnd = now
        }, false)

        document.addEventListener("gesturestart", (e) => {
          e.preventDefault()
        })
      })();
  </script>
  <script>
    var swiper = new Swiper(".mySwiper", {
      direction: "horizontal",
      loop: true,
      autoplay: {
        delay: 3000,
        disableOnInteraction: false,
      },
      speed: 800,
      pagination: {
        el: ".swiper-pagination",
        clickable: true,
      },
    });

  </script>

  <input type="hidden" id="channel" value="slm_1250011"/>
  <input type="hidden" id="appName" value="Teen Patti Master"/>
  <input type="hidden" id="pkgType" value="1"/>
  <input type="hidden" id="downloadDomain" value="https://d2nd4t9rc4dty3.cloudfront.net"/>
  <input type="hidden" id="adjustTrackerToken" value="1x9om2yt"/>
  <input type="hidden" id="onlinePkgUrl" value=""/>
  <input type="hidden" id="ext" value=""/>
  <input type="hidden" id="pixelId" value="2231091787685609"/>
  <input type="hidden" id="eventId" value="2fcd30f5-23bf-4b92-bdfd-f0f6f59a27a5"/>

  <script>


    var fbp = getCookie('_fbp') || getQueryString('_fbp') || getQueryString("fbp") || getCookie('fbp');
    var fbc = getCookie('_fbc') || getQueryString('_fbc') || getQueryString("fbc") || getCookie('fbc');
    console.log('fbp', fbp)
    console.log('fbc', fbc)

    let pkgType = document.getElementById('pkgType').value;
    let downloadDomain = document.getElementById('downloadDomain').value;
    let adjustTracker = document.getElementById('adjustTrackerToken').value;
    let onlinePkgUrl = document.getElementById('onlinePkgUrl').value;
    let ext = document.getElementById('ext').value;
    let pxid = document.getElementById('pixelId').value;
    let appName = document.getElementById('appName').value;
    let channel = document.getElementById('channel').value;
    let eventId = document.getElementById('eventId').value;

    let extStr = JSON.stringify(ext)
    let encodeExtStr = encodeURIComponent(extStr)
    let offlineUrl;
    let url = '';

    let reportFlag = 0

    // 开始计时
    const startTime = Date.now();

    function checkCookie() {
      const startTime = Date.now(); // 记录开始时间
      let timeCost = 0; // 保存时间花费

      const intervalId = setInterval(() => {
        const fbcValue = getCookie('_fbc');
        const currentTime = Date.now();
        if (fbcValue) {
          // 停止监听
          clearInterval(intervalId);

          // 计算时间花费
          timeCost = currentTime - startTime;
          reportLog(timeCost);
          // 在控制台输出时间花费
          console.log('Time cost:', timeCost, 'milliseconds');
        } else if (currentTime - startTime > 10000) {
          // 超过10秒仍未找到_fbc，打印日志
          clearInterval(intervalId);
          timeCost = currentTime - startTime;
          reportLog(timeCost);
          console.log('Time cost exceeds 10 seconds. _fbc not found.');
        } else {
          console.log('Check Cookie: _fbc not found yet.');
        }
      }, 100); // 间隔0.1秒检查一次
      checkFbc(intervalId, startTime, timeCost)
    }

    function checkFbc(intervalId, starTime, timeCost) {
      console.log('checkFbc')
      const fbcValue = getCookie('_fbc');
      const currentTime = Date.now();
      if (fbcValue) {
        // 停止监听
        clearInterval(intervalId);

        // 计算时间花费
        timeCost = currentTime - startTime;
        reportLog(timeCost);
        // 在控制台输出时间花费
        console.log('Time cost:', timeCost, 'milliseconds');
      } else if (currentTime - startTime > 10000) {
        // 超过10秒仍未找到_fbc，打印日志
        clearInterval(intervalId);
        timeCost = currentTime - startTime;
        reportLog(timeCost);
        console.log('Time cost exceeds 10 seconds. _fbc not found.');
      } else {
        console.log('Check Cookie: _fbc not found yet.');
      }
    }

    // 调用函数开始监听
    checkCookie();

    //读取url参数
    const urlParams = new Proxy({}, {
      get: (target, name) => name in target ? target[name] : ''
    });

    window.addEventListener("DOMContentLoaded", () => {
      const currentURL = window.location.href;
      const parsedURL = new URL(currentURL);
      const params = parsedURL.searchParams;
      for (const [param, value] of params) {
        urlParams[param] = value;
      }
    });
    console.log(urlParams)

    var gclid = getGclid();
    console.log('getGclid:', gclid)

    function getGclid() {
      let ups = readUrlParams();
      if (ups.gclid) {
        return ups.gclid
      }
      let adjust_referrer = ups.adjust_referrer
      if (adjust_referrer) {
        adjust_referrer = decodeURIComponent(adjust_referrer)
        let ar = adjust_referrer.split("=")
        console.log('ar:', ar)
        if (ar && ar.length > 1) {
          return ar[1]
        }
      }
      return ''
    }

    var wbraid = getQueryString("wbraid") || getCookie('wbraid');
    var gbraid = getQueryString("gbraid") || getCookie('gbraid');

    function getQueryString(name) {
      var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
      var r = window.location.search.substr(1).match(reg);
      if (r != null) {
        return unescape(r[2]);
      }
      return "";
    }

    function getCookie(cname) {
      let name = cname + "=";
      let ca = document.cookie.split(';');
      for (let i = 0; i < ca.length; i++) {
        let c = ca[i];
        while (c.charAt(0) == ' ') {
          c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
          return c.substring(name.length, c.length);
        }
      }
      return "";
    }

    function createEventId() {
      return 'xxxxxxxyx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
        var r = Math.random() * 16 | 0,
                v = c === 'x' ? r : (r & 0x3 | 0x8);
        return v.toString(16);
      });
    }

    //线下包地址
    if (pkgType === '1') {
      offlineUrl = downloadDomain + '/cg/gaoct/fg/' + appName + '.apk?' + 'channel=' + channel + '&pxid=' + pxid + '&fbp=' + fbp + '&fbc=' + fbc + '&gclid=' + gclid + '&wbraid=' + wbraid + '&gbraid=' + gbraid + '&eventId=' + eventId + '&ext=' + encodeExtStr;

      console.log('offlineUrl:', offlineUrl)
      url = offlineUrl;
    } else if (pkgType === '2') {
      //线上包地址
      url = buildOnlinePkgReferrer()
    }

    webClick()

    function webClick() {

      let uri = window.location.href;
      uri = uri.replace(/^https?:\/\//, '');
      uri = encodeURIComponent(uri)
      // 获取当前页面的所有 Cookie
      const cookies = document.cookie;
      let logrpUrl = '';

      const urlP = readUrlParams()

      if (isGoogleAdLink()) {
        const campaignName = urlP.campaign
        const adset = urlP.adgroup
        const creative = urlP.creative
        const gbraid = urlP.gbraid
        const wbraid = urlP.wbraid
        logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/click?uri=' + uri + '&eventId=' + eventId + '&channel=' + channel +
                '&gbraid=' + gbraid + '&wbraid=' + wbraid + '&campaignName=' + campaignName + "&campaignId=" + campaignName + '&gclid=' + gclid + '&adsetName=' + adset + '&adsetId=' + adset + '&creative='
                + creative + '&adjustTrackerToken=' + adjustTracker
      } else if (isFacebookAdLink()) {
        const campaignName = urlP.p1
        const campaignId = urlP.p2
        const adsetName = urlP.p3
        const adsetId = urlP.p4
        const adName = urlP.p5
        const adId = urlP.p6
        const fbclid = urlP.fbclid
        const fbpid = urlP.fbpid
        logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/click?uri=' + uri + '&eventId=' + eventId + '&channel=' + channel +
                '&campaignName=' + campaignName + '&adsetName=' + adsetName + '&adjustTrackerToken=' + adjustTracker +
                '&campaignId=' + campaignId + '&adsetId=' + adsetId + '&adName=' + adName + '&adId=' + adId + '&fbclid=' + fbclid + '&fbpid=' + fbpid;
      } else {
        //自然量
        logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/click?uri=' + uri + '&eventId=' + eventId + '&channel=' + channel +
                '&adjustTrackerToken=' + adjustTracker
      }

      // 发送GET请求
      fetch(logrpUrl, {mode: 'no-cors'})
              .then(response => {
              })
              .then(data => {
              })
              .catch(error => {
                console.log('web click error', error)
              });
    }

    function onBtnClick(redirect) {

      if (isGoogleAdLink()) {
        const campaign = urlParams.campaign
        const adgroup = urlParams.adgroup
        const creative = urlParams.creative
        const gbraid = urlParams.gbraid
        const wbraid = urlParams.wbraid
        const url = 'https://app.adjust.com/' + adjustTracker + '?engagement_type=fallback_click&campaign=' + campaign + '&external_click_id=' + gclid +
                '&adgroup=' + adgroup + '&creative=' + creative + '&gbraid=' + gbraid + '&wbraid=' + wbraid + '&redirect=' + redirect
        console.log(url)
        window.location.href = url;
      } else if (isFacebookAdLink()) {
        const campaignName = urlParams.p1
        const campaignId = urlParams.p2
        const adsetName = urlParams.p3
        const adsetId = urlParams.p4
        const adName = urlParams.p5
        const adId = urlParams.p6
        const fbclid = urlParams.fbclid
        const fbpid = urlParams.fbpid
        const url = 'https://app.adjust.com/' + adjustTracker + '?engagement_type=fallback_click&campaign=' + campaignName + '%20%28' + campaignId
                + '%29&adgroup=' + adsetName + '%20%28' + adsetId + '%29&creative=' + adName + '%20%28' + adId + '%29&fbclid='
                + fbclid + '&fbpid=' + fbpid + '&redirect=' + redirect
        window.location.href = url;
      } else {
        window.location.href = 'https://app.adjust.com/' + adjustTracker + '?engagement_type=fallback_click&redirect=' + redirect;
      }
    }

    function isGoogleAdLink() {
      return gclid
    }

    function isFacebookAdLink() {
      return window.location.href.includes('fbclid');
    }

    function sendGtagEvent(action) {
      console.log('sendGtagEvent', action)
      // 其他参数被设定为固定值
      const category = 'button';
      const label = 'myButton';
      const value = 1;

      gtag('event', action, {
        'event_category': category,
        'event_label': label,
        'value': value
      });
    }

    //必须将download赋值给window
    function download(eventName) {
      sendGtagEvent(eventName)
      reportLog(Date.now() - startTime);
      var encodedUrl = encodeURIComponent(url);
      onBtnClick(encodedUrl);
    }

    window.download = download;

    function readUrlParams() {
      //读取url参数
      const urlParams = new Proxy({}, {
        get: (target, name) => name in target ? target[name] : ''
      });

      const currentURL = window.location.href;
      const parsedURL = new URL(currentURL);
      const params = parsedURL.searchParams;

      for (const [param, value] of params) {
        urlParams[param] = value;
        console.log('urlParams: ', urlParams[param])
      }
      return urlParams;
    }

    function reportLog(timeCost) {
      if (reportFlag > 0) {
        return;
      }
      reportFlag = 1
      let uri = window.location.href;
      uri = uri.replace(/^https?:\/\//, '');
      console.log('uri:', uri)
      // 获取当前页面的所有 Cookie
      const cookies = document.cookie;
      // 将 Cookie 添加到 URL 参数中
      let cookieA = `&cookie=${encodeURIComponent(cookies)}`;
      let logrpUrl = '';

      const urlP = readUrlParams()

      var uriWithoutParams = window.location.origin + window.location.pathname;
      const p0 = urlP.p0
      const p1 = urlP.p1
      const p2 = urlP.p2
      const p3 = urlP.p3
      const p4 = urlP.p4
      const p5 = urlP.p5
      const p6 = urlP.p6
      const fbclid = urlP.fbclid

      logrpUrl = 'https://tracker2.bx1.pw/webAdsTracker/report?uri=' + uriWithoutParams + '&p0=' + p0 + '&p1=' + p1 + '&p2=' + p2 + '&p3=' + p3 + '&p4=' + p4
              + '&p5=' + p5 + '&p6=' + p6 + '&fbclid=' + fbclid + '&eventId=' + eventId + cookieA + '&timecost=' + timeCost + '&channel=' + channel;
      // 发送GET请求
      fetch(logrpUrl, {mode: 'no-cors'})
              .then(response => {
                if (!response.ok) {
                  throw new Error(`HTTP error! Status: ${response.status}`);
                }
                return response.json();
              })
              .then(data => {
                console.log('reportLog', logrpUrl)
              })
              .catch(error => {
                console.log('reportLog:', logrpUrl)
              });
    }

    function hasQuestionMark(uri) {
      const regex = /\?/;
      return regex.test(uri);
    }

    function buildOnlinePkgReferrer() {
      let up = readUrlParams()
      if (isFacebookAdLink()) {
        onlinePkgUrl = onlinePkgUrl + '&referrer=fbclid%3D' + up.fbclid + '%26eventId%3D' + eventId
      } else if (isGoogleAdLink()) {
        onlinePkgUrl = onlinePkgUrl + '&referrer=fbclid%3D' + gclid + '%26eventId%3D' + eventId
      } else {
        onlinePkgUrl = onlinePkgUrl + '&referrer=eventId%3D' + eventId
      }
      return onlinePkgUrl
    }

  </script>
</body>
</html>