
import * as fs from 'fs';
import path from "path";

const html = fs.readFileSync('./build/web-mobile/index.html', 'utf8');

const json = JSON.stringify({
    skinId:"B_Client",
    html: `<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <link rel="dns-prefetch" href="//yun.duiba.com.cn" />
    <link rel="preconnect" href="//embedlog.duiba.com.cn">
    <title>B client</title>
    <script type="text/javascript">
      if (localStorage && localStorage.isWebp) {
        document
                .getElementsByTagName('html')[0]
                .setAttribute('duiba-webp', 'true');
      }
    </script>
    <script src="//duiba-credits-test.oss-cn-hangzhou.aliyuncs.com/TNGD_GAMES/libs/zepto.min.js"></script>
    <script>
      var CFG = CFG || {};
      CFG.projectId = location.pathname.split('/')[2] || '1';

      function getUrlParam(name) {
        var search = window.location.search;
        var matched = search
                .slice(1)
                .match(new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'));
        return search.length ? matched && matched[2] : null;
      }

    // document.addEventListener("DOMContentLoaded", function () {
    //   !(function (e, i) {
    //     var t = e.documentElement,
    //       n = navigator.userAgent.match(/iphone|ipod|ipad/gi),
    //       a = n ? Math.min(i.devicePixelRatio, 3) : 1,
    //       m = 'orientationchange' in window ? 'orientationchange' : 'resize';
    //     t.dataset.dpr = a;
    //     for (
    //       var d, l, c = !1, o = e.getElementsByTagName('meta'), r = 0; r < o.length; r++
    //     )
    //       (l = o[r]), 'viewport' == l.name && ((c = !0), (d = l));
    //     if (c)
    //       d.content =
    //         'width=device-width,initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0,user-scalable=no';
    //     else {
    //       var o = e.createElement('meta');
    //       (o.name = 'viewport'),
    //         (o.content =
    //           'width=device-width,initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0,user-scalable=no'),
    //         t.firstElementChild.appendChild(o);
    //     }
    //     var s = function () {
    //       var e = t.clientWidth;
    //       e / a > 750 && (e = 750 * a),
    //         (window.remScale = e / 750),
    //         (t.style.fontSize = 100 * (e / 750) + 'px');
    //     };
    //     s(), e.addEventListener && i.addEventListener(m, s, !1);
    //   })(document, window);
    // })


      if (!getUrlParam("appID")) {
        // alert("【警告】检测到活动url中没有appID参数\\n缺少该参数会导致埋点、分享、app信息获取错误。")
      }
    </script>
    <script type="module" crossorigin src="//duiba-credits-test.oss-cn-hangzhou.aliyuncs.com/TNGD_GAMES/B_Client/1726224129317/assets/index-DZvPPS42.js"></script>
    <link rel="stylesheet" crossorigin href="//duiba-credits-test.oss-cn-hangzhou.aliyuncs.com/TNGD_GAMES/B_Client/1726224129317/assets/index-BF9DaJcw.css">
    <script type="module">import.meta.url;import("_").catch(()=>1);(async function*(){})().next();if(location.protocol!="file:"){window.__vite_is_modern_browser=true}</script>
    <script type="module">!function(){if(window.__vite_is_modern_browser)return;console.warn("vite: loading legacy chunks, syntax error above and the same error below should be ignored");var e=document.getElementById("vite-legacy-polyfill"),n=document.createElement("script");n.src=e.src,n.onload=function(){System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))},document.body.appendChild(n)}();</script>
  </head>
  <body>
    <div id="root"></div>
    <script nomodule>!function(){var e=document,t=e.createElement("script");if(!("noModule"in t)&&"onbeforeload"in t){var n=!1;e.addEventListener("beforeload",(function(e){if(e.target===t)n=!0;else if(!e.target.hasAttribute("nomodule")||!n)return;e.preventDefault()}),!0),t.type="module",t.src=".",e.head.appendChild(t),t.remove()}}();</script>
    <script nomodule crossorigin id="vite-legacy-polyfill" src="//duiba-credits-test.oss-cn-hangzhou.aliyuncs.com/TNGD_GAMES/B_Client/1726224129317/assets/polyfills-legacy-Cqy8ASFC.js"></script>
    <script nomodule crossorigin id="vite-legacy-entry" data-src="//duiba-credits-test.oss-cn-hangzhou.aliyuncs.com/TNGD_GAMES/B_Client/1726224129317/assets/index-legacy-DrUXGpaw.js">System.import(document.getElementById('vite-legacy-entry').getAttribute('data-src'))</script>
  </body>
</html>

`,
});

fs.writeFileSync('./build/publish.json', json);


const a = JSON.stringify({
    appId: "2171020205274922",
    uid: "uid0000003",
    fullName: "uid0000003",
})

console.log(encodeURIComponent(a))

// console.log(path.relative("E:\\Duiba\\project\\TNGD\\MalaysiaBClient\\dist","E:\\Duiba\\project\\TNGD\\MalaysiaBClient\\dist\\assets\\index-_1R5vqJD.js", ))