<!DOCTYPE html>
<html lang="pt-BR">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/vite.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="google-site-verification" content="XK12kaz7PuEQckd1Ivr3BaI52EEyfocgxLSFDAmb9Ds" />
    <title>Pag2Pay - Plataforma de Vendas e Afiliados</title>
    <script>
      // REDE DE SEGURANCA contra cache antigo (erro "Unexpected token '<'").
      // Se o navegador tem um index.html velho em cache, ele pede um arquivo JS
      // com hash que nao existe mais e recebe HTML -> erro de carregamento de
      // modulo. Aqui detectamos essa falha e recarregamos a pagina forcando
      // buscar a versao nova (com cache-busting real). Um contador em
      // sessionStorage limita as tentativas pra nunca virar loop infinito.
      (function () {
        var MAX_RETRIES = 2;

        function getRetries() {
          try { return parseInt(sessionStorage.getItem('p2p_chunk_retries') || '0', 10) || 0; }
          catch (e) { return 0; }
        }
        function setRetries(n) {
          try { sessionStorage.setItem('p2p_chunk_retries', String(n)); } catch (e) {}
        }

        function isChunkLoadError(msg) {
          if (!msg) return false;
          msg = String(msg);
          return (
            msg.indexOf("Unexpected token '<'") !== -1 ||
            msg.indexOf('Unexpected token \'<\'') !== -1 ||
            msg.indexOf('expected expression, got \'<\'') !== -1 ||
            msg.indexOf('Failed to fetch dynamically imported module') !== -1 ||
            msg.indexOf('error loading dynamically imported module') !== -1 ||
            msg.indexOf('Importing a module script failed') !== -1 ||
            msg.indexOf('Failed to load module script') !== -1 ||
            msg.indexOf('Loading chunk') !== -1 ||
            msg.indexOf('ChunkLoadError') !== -1 ||
            msg.indexOf('MIME type') !== -1
          );
        }

        function recover() {
          var retries = getRetries();
          if (retries >= MAX_RETRIES) return; // ja tentou o suficiente, evita loop
          setRetries(retries + 1);
          // Recarrega adicionando um parametro unico na URL. Isso forca o
          // navegador a buscar um DOCUMENTO novo (ignorando o index.html em
          // cache local), que por sua vez aponta pros assets da versao atual.
          try {
            var u = new URL(window.location.href);
            u.searchParams.set('_cb', Date.now().toString());
            window.location.replace(u.toString());
          } catch (e) {
            // Fallback pra navegadores sem URL API
            var sep = window.location.href.indexOf('?') === -1 ? '?' : '&';
            window.location.replace(window.location.href + sep + '_cb=' + Date.now());
          }
        }

        // 1) Erro de carregamento de um <script> (o caso mais comum aqui: o
        //    modulo principal falha porque recebeu HTML no lugar de JS).
        window.addEventListener('error', function (e) {
          var target = e && e.target;
          if (target && (target.tagName === 'SCRIPT' || target.tagName === 'LINK')) {
            var src = target.src || target.href || '';
            // so age em assets do proprio app (evita reagir a scripts de terceiros)
            if (src.indexOf('/assets/') !== -1 || src.indexOf('/src/') !== -1 || /\.(js|mjs|css)(\?|$)/.test(src)) {
              recover();
              return;
            }
          }
          var msg = (e && e.message) || '';
          if (isChunkLoadError(msg)) recover();
        }, true);

        // 2) Import dinamico rejeitado (rotas lazy que falham ao baixar chunk).
        window.addEventListener('unhandledrejection', function (e) {
          var reason = e && e.reason;
          var msg = (reason && (reason.message || reason)) || '';
          if (isChunkLoadError(msg)) recover();
        });

        // 3) Se a app montar com sucesso, zera o contador — assim uma futura
        //    troca de versao volta a ter as tentativas disponiveis.
        window.addEventListener('load', function () {
          setTimeout(function () {
            var root = document.getElementById('root');
            if (root && root.childNodes && root.childNodes.length > 0) {
              setRetries(0); // app renderizou, tudo certo
            }
          }, 1500);
        });
      })();
    </script>
    <script type="module" crossorigin src="/assets/index-C0ose-7r.js"></script>
    <link rel="stylesheet" crossorigin href="/assets/index-BKDpghrR.css">
  </head>
  <body>
    <div id="root"></div>
  </body>
</html>
