System.register(["__unresolved_0", "cc", "__unresolved_1", "__unresolved_2", "__unresolved_3"], function (_export, _context) {
  "use strict";

  var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, screen, assetManager, tween, find, v2, v3, director, Prefab, GameConst, PoolManager, bundleMgr, Utils, _crd;

  function _reportPossibleCrUseOfGameConst(extras) {
    _reporterNs.report("GameConst", "../common/GameConst", _context.meta, extras);
  }

  function _reportPossibleCrUseOfITEM_TYPE(extras) {
    _reporterNs.report("ITEM_TYPE", "../common/GameConst", _context.meta, extras);
  }

  function _reportPossibleCrUseOfPoolManager(extras) {
    _reporterNs.report("PoolManager", "../manager/PoolManager", _context.meta, extras);
  }

  function _reportPossibleCrUseOfbundleMgr(extras) {
    _reporterNs.report("bundleMgr", "../manager/BundleManager", _context.meta, extras);
  }

  _export("default", void 0);

  return {
    setters: [function (_unresolved_) {
      _reporterNs = _unresolved_;
    }, function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      screen = _cc.screen;
      assetManager = _cc.assetManager;
      tween = _cc.tween;
      find = _cc.find;
      v2 = _cc.v2;
      v3 = _cc.v3;
      director = _cc.director;
      Prefab = _cc.Prefab;
    }, function (_unresolved_2) {
      GameConst = _unresolved_2.GameConst;
    }, function (_unresolved_3) {
      PoolManager = _unresolved_3.PoolManager;
    }, function (_unresolved_4) {
      bundleMgr = _unresolved_4.bundleMgr;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "d0788kA+CpAb7fGbF4Gj2lV", "Utils", undefined);

      __checkObsolete__(['screen', 'Asset', 'assetManager', 'error', 'Node', 'Vec3', 'sp', 'tween', 'Layers', 'find', 'Camera', 'v2', 'UITransform', 'v3', 'isValid', 'CCObject', 'AssetManager', 'director', 'Prefab']);

      _export("default", Utils = class Utils {
        /**
         * 验证字符串是否是空的
         * @s 字符串
         */
        static isNull(s) {
          if (s == "" || s == null || s == undefined) {
            return true;
          }

          if (typeof s === 'string') {
            let re = new RegExp("^[ ]+$");
            return re.test(s);
          } else {
            return false;
          }
        }
        /**
         * 数组移除某一个元素
         */


        static remove(arr, param) {
          let index = arr.indexOf(param);

          if (index > -1) {
            arr.splice(index, 1);
          }
        }
        /**
         * 查询一个节点下的子节点
         */


        static findName(root, name) {
          let child;

          if (name.indexOf("/") != -1) {
            child = find(name, root);
          } else {
            if (!root) {
              root = director.getScene();
            }

            if (root.name === name) {
              child = root;
            } else {
              child = this.findChild(name, root);
            }
          }

          if (child) {
            return child;
          } else {
            console.log("没有找到指定的Node, node name ==", name);
            return null;
          }
        }

        static findChild(name, parent) {
          let child = parent.getChildByName(name);

          if (child) {
            return child;
          } else {
            let children = parent.children;

            for (let i = 0; i < children.length; i++) {
              child = this.findChild(name, children[i]);

              if (child) {
                return child;
              }
            }
          }

          return null;
        } //检查是否同一天


        static checkIsToDay(time) {
          var date = new Date(time);
          var dateNow = new Date();
          let bSameDay = false;

          if (date.getFullYear() == dateNow.getFullYear() && date.getMonth() == dateNow.getMonth() && date.getDate() == dateNow.getDate()) {
            bSameDay = true;
          }

          return bSameDay;
        }

        static getRandom(lower, upper) {
          return Math.random() * (upper - lower) + lower;
        }

        static getRandomInt(lower, upper) {
          return Math.floor(Math.random() * (upper - lower)) + lower;
        }

        static seedRandom() {
          return Utils.getRandom(0, 1); // this.seed = (this.seed * 9301 + 49297) % 233280;
          // return this.seed / 233280.0;
        }

        static seedRandomInt(lower, upper) {
          return Utils.getRandomInt(lower, upper); // return Math.floor(Utils.seedRandom() * (upper - lower)) + lower;
        } // public static formatNumber(num: number, afterdot: number = 1) {
        //     num = Math.floor(num);
        //     return BigNumber.getLargeString(num);
        // };


        static getPowNum(p) {
          return Math.pow(10, p);
        }

        // static showTip(value: string) {
        //     if (sys.platform == sys.WECHAT_GAME) {
        //         wx.showToast({ title: value, icon: 'none', duration: 1500 })
        //     }
        // }
        static formatDate(t) {
          var date = new Date(t);
          var YY = date.getFullYear() + '-';
          var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
          var DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
          var hh = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
          var mm = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
          var ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
          return YY + MM + DD + " " + hh + mm + ss;
        }

        static cloneObj(obj) {
          obj = JSON.stringify(obj);
          obj = JSON.parse(obj);
          return obj;
        }

        static getTimeStrByS(second) {
          second = Math.floor(second);
          if (second < 0) second = 0;
          var d = Math.floor(second / 3600 / 24);
          second -= d * 3600 * 24;
          var h = Math.floor(second / 3600);
          second -= h * 3600;
          var m = Math.floor(second / 60);
          second -= m * 60;
          var front = "00";

          if (h > 9) {
            front = "" + h;
          } else {
            front = "0" + h;
          }

          var mid = "00";

          if (m > 9) {
            mid = "" + m;
          } else {
            mid = "0" + m;
          }

          var back = "00";

          if (second > 9) {
            back = "" + second;
          } else {
            back = "0" + second;
          }

          if (d > 0) {
            return d + "天" + h + "时" + m + "分";
          } else {
            var longTime = h > 0;

            if (longTime) {
              return front + ":" + mid;
            } else {
              return mid + ":" + back; //+ '秒';
            }
          }
        }

        static getClockStrByS(second, showsecond = true, showhour = true) {
          second = Math.floor(second);
          if (second < 0) second = 0;
          var h = Math.floor(second / 3600);
          second -= h * 3600;
          var m = Math.floor(second / 60);
          second -= m * 60;
          var front = "00";

          if (h > 9) {
            front = "" + h;
          } else {
            front = "0" + h;
          }

          var mid = "00";

          if (m > 9) {
            mid = "" + m;
          } else {
            mid = "0" + m;
          }

          let str = "";

          if (showhour) {
            str += front;
            str += ":";
          }

          str += mid;
          if (showsecond) str += ":" + (second < 10 ? "0" : "") + second;
          return str;
        }

        static checkObjEmpty(obj) {
          if (obj) {
            for (var i in obj) {
              return false;
            }

            return true;
          } else {
            return true;
          }
        }

        static checkOrderOver(orderTime) {
          var date = new Date(orderTime);
          var dateNow = new Date();

          if (date.getFullYear() == dateNow.getFullYear() && date.getMonth() == dateNow.getMonth() && date.getDate() == dateNow.getDate()) {
            return false;
          } else {
            return true;
          }
        }

        static loadBundler(name) {
          return new Promise((resolve, reject) => {
            assetManager.loadBundle(name, (err, ret) => {
              console.log(ret);
              resolve(null);
            });
          });
        }
        /**
         * 获取Bundle内资源路径列表
         */


        static async _getBundleAssets(bundle) {
          try {
            var _bundle$config;

            let paths = []; //方法1：直接从配置的paths._map中获取所有键（路径）

            if ((_bundle$config = bundle['config']) != null && (_bundle$config = _bundle$config.paths) != null && _bundle$config._map) {
              //直接从配置的paths._map中获取所有键（路径）
              paths = Array.from(Object.keys(bundle['config'].paths._map));
            } else if (bundle['_assetMap']) {
              //方法2：兼容旧的_assetMap方式
              paths = Array.from(bundle['_assetMap'].keys());
            } else {
              //方法3：回退方案
              paths = bundle.getDirWithPath('').map(item => item.path);
            }

            return paths;
          } catch (error) {
            console.error(`获取Bundle资源路径失败:`, error);
            throw error;
          }
        }
        /*public static loadRes(path: string, bundle: string, type: typeof Asset, callback: any = null) {
            return new Promise((resolve, reject) => {
                if (!assetManager.getBundle(bundle)) {
                    console.log(bundle);
                }
                let ret = assetManager.getBundle(bundle).get(path, type);
                if (ret) {
                    if (callback) callback(null, ret);
                    resolve(ret);
                    return;
                }
                assetManager.getBundle(bundle).load(path, type, (err, ret: Asset) => {
                    if (err) {
                        console.warn("加载错误：", path, err);
                        if (callback) callback(err, null);
                        reject(null);
                    }
                    else {
                        if (callback) callback(null, ret);
                        resolve(ret);
                    }
                });
            })
        }*/


        static weight(v) {
          var mTotalWeight = 0;

          for (var i = 0; i < v.length; ++i) {
            mTotalWeight += v[i];
          }

          if (mTotalWeight <= 0) return -1;
          var randnum = Math.round(Math.random() * Number.MAX_VALUE) % mTotalWeight;

          for (var i = 0; i < v.length; ++i) {
            if (randnum < v[i]) {
              return i;
            } else {
              randnum -= v[i];
            }
          }

          return -1;
        }

        static shuffle(arr) {
          for (let i = arr.length - 1; i >= 0; i--) {
            let rIndex = Math.floor(Math.random() * (i + 1));
            let temp = arr[rIndex];
            arr[rIndex] = arr[i];
            arr[i] = temp;
          }

          return arr;
        }
        /**
         * 从数组中随机选择指定数量的元素，如果超出数组长度则循环取值
         * @param array 原始数组
         * @param count 需要选择的元素数量
         * @returns 包含随机选择元素的新数组
         */


        static getRandomElements(array, count) {
          if (array.length === 0) {
            console.warn('Warning: The input array is empty.');
            return [];
          } //创建数组的副本以避免修改原数组


          const shuffledArray = [...array]; //使用 Fisher-Yates Shuffle 算法进行乱序

          for (let i = shuffledArray.length - 1; i > 0; i--) {
            const j = Math.floor(Math.random() * (i + 1)); // 交换元素

            [shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]];
          } //如果请求的数量大于数组长度，给出提示并循环取值


          if (count > array.length) {
            const excess = count - array.length;
            console.log(`Notice: Requested ${count} elements but array only has ${array.length}. Will cycle and return ${excess} extra elements.`);
            const result = [];

            for (let i = 0; i < count; i++) {
              result.push(shuffledArray[i % shuffledArray.length]);
            }

            return result;
          } //如果不超过数组长度，直接返回前count个元素


          return shuffledArray.slice(0, count);
        }
        /**
         * 扩展数组到指定长度，新增的元素从原始数组中随机选取
         * @param originalArray 原始数组（元素唯一）
         * @param targetLength 目标长度
         * @returns 扩展后的数组
         */


        static extendArray(originalArray, targetLength) {
          //如果目标长度 <= 原数组长度，直接返回原数组的浅拷贝
          if (targetLength <= originalArray.length) {
            return [...originalArray];
          } //创建结果数组的初始副本


          const result = [...originalArray]; //计算需要添加的元素数量

          const elementsToAdd = targetLength - originalArray.length; //随机从 originalArray 选取元素并添加到 result

          for (let i = 0; i < elementsToAdd; i++) {
            //从 originalArray 中随机选择一个元素
            const randomIndex = Math.floor(Math.random() * originalArray.length);
            const randomElement = originalArray[randomIndex]; // 将随机元素添加到结果数组中

            result.push(randomElement);
          }

          return result;
        }

        static getDate(time) {
          var now = new Date(time),
              y = now.getFullYear(),
              m = now.getMonth() + 1,
              d = now.getDate();
          return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8);
        } //货币进位


        static goldCrarryBit(gold) {
          var array = [[100000000, 'N'], [10000000, 'T'], [1000000, 'G'], [100000, 'M'], [10000, 'K'], [1000, 'B']];

          for (var i = 0; i < array.length; i++) {
            var value = gold / array[i][0];

            if (value > 1) {
              return '' + value.toFixed(1) + array[i][1];
            }
          }

          return gold.toString();
        } //定点数


        static fixFloat(val, count = 2) {
          var a = Math.pow(10, count);
          return Math.floor(val * a) / a;
        }

        static async flyAnim(type, starNode, targetNode, count, radius, callback) {
          let getPoint = (r, ox, oy, count) => {
            var point = []; //结果

            var radians = Math.PI / 180 * Math.round(360 / count),
                //弧度
            i = 0;

            for (; i < count; i++) {
              var x = ox + r * Math.sin(radians * i),
                  y = oy + r * Math.cos(radians * i);
              point.unshift(v2(x, y)); //为保持数据顺时针
            }

            return point;
          };

          let start = starNode.worldPosition;
          var array = getPoint(radius, start.x, start.y, count);
          var nodeArray = new Array();

          for (var i = 0; i < array.length; i++) {
            let ret = await (_crd && bundleMgr === void 0 ? (_reportPossibleCrUseOfbundleMgr({
              error: Error()
            }), bundleMgr) : bundleMgr).loadAsset((_crd && GameConst === void 0 ? (_reportPossibleCrUseOfGameConst({
              error: Error()
            }), GameConst) : GameConst).bundleName.resources, `prefabs/${type}`, Prefab);
            var gold = (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
              error: Error()
            }), PoolManager) : PoolManager).getNode(ret);
            gold.setWorldScale(v3(0.7, 0.7, 0.7)); // gold.zIndex = GameConst.WIN_LAYER.TIP;

            gold.parent = find("Canvas");
            var randPos = v3(array[i].x + Utils.getRandomInt(0, 50), array[i].y + Utils.getRandomInt(0, 50), 1);
            gold.setWorldPosition(start);
            nodeArray.push({
              gold,
              randPos
            });
          }

          var notPlay = false;
          let dstPos = targetNode.worldPosition;

          for (let i = 0; i < nodeArray.length; i++) {
            let pos = nodeArray[i].randPos;
            let node = nodeArray[i].gold;
            nodeArray[i].gold.id = i;
            tween(node).to(0.2, {
              worldPosition: pos
            }).delay(i * 0.03).to(0.7, {
              worldPosition: v3(dstPos.x, dstPos.y, 1)
            }).call(() => {
              if (!notPlay) {
                notPlay = true;
                tween(targetNode).to(0.1, {
                  scale: v3(2, 2, 2)
                }).to(0.1, {
                  scale: v3(1, 1, 1)
                }).call(() => {
                  notPlay = false;
                }).start();
              }

              callback(i == nodeArray.length - 1);
              (_crd && PoolManager === void 0 ? (_reportPossibleCrUseOfPoolManager({
                error: Error()
              }), PoolManager) : PoolManager).putNode(node);
            }).start();
          }
        }

        static formatString(s, ...arg) {
          for (var i = 0; i < arg.length; i++) {
            var reg = new RegExp("\\{" + i + "\\}", "gm");
            s = s.replace(reg, arg[i]);
          }

          return s;
        } // static convetOtherNodeSpaceAR(sourceNode:Node, targetNode:Node)
        // {
        //     var worldP:Vec2=sourceNode.convertToWorldSpaceAR(v2(0,0))        
        //     return targetNode.convertToNodeSpaceAR(worldP)
        // }


        static count(obj) {
          if (!obj) return 0;
          var num = 0;

          for (var k in obj) {
            num++;
          }

          return num;
        }

        static copy(obj) {
          var newObj = Object.create(obj);
          Object.assign(newObj, obj);
          return newObj;
        }
        /**
         * 数据解密
         * @param {String} str 
         */


        static decrypt(b64Data) {
          if (b64Data == null || b64Data == undefined) {
            return "";
          }

          let n = 6;

          if (b64Data.length % 2 === 0) {
            n = 7;
          }

          let decodeData = '';

          for (var idx = 0; idx < b64Data.length - n; idx += 2) {
            decodeData += b64Data[idx + 1];
            decodeData += b64Data[idx];
          }

          decodeData += b64Data.slice(b64Data.length - n + 1);
          decodeData = this._base64Decode(decodeData);
          return decodeData;
        }
        /**
         * 数据加密
         * @param {String} str 
         */


        static encrypt(str) {
          if (str == null || str == undefined) {
            return "";
          }

          let b64Data = this._base64encode(str);

          let n = 6;

          if (b64Data.length % 2 === 0) {
            n = 7;
          }

          let encodeData = '';

          for (let idx = 0; idx < (b64Data.length - n + 1) / 2; idx++) {
            encodeData += b64Data[2 * idx + 1];
            encodeData += b64Data[2 * idx];
          }

          encodeData += b64Data.slice(b64Data.length - n + 1);
          return encodeData;
        } //public method for encoding

        /**
         * base64加密
         * @param {string}input 
         * @returns 
         */


        static _base64encode(input) {
          let keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
          let output = "",
              chr1,
              chr2,
              chr3,
              enc1,
              enc2,
              enc3,
              enc4,
              i = 0;
          input = this._utf8Encode(input);

          while (i < input.length) {
            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);
            enc1 = chr1 >> 2;
            enc2 = (chr1 & 3) << 4 | chr2 >> 4;
            enc3 = (chr2 & 15) << 2 | chr3 >> 6;
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
              enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
              enc4 = 64;
            }

            output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + keyStr.charAt(enc3) + keyStr.charAt(enc4);
          }

          return output;
        }
        /**
         * utf-8 加密
         * @param string 
         * @returns 
         */


        static _utf8Encode(string) {
          string = string.replace(/\r\n/g, "\n");
          let utftext = "";

          for (let n = 0; n < string.length; n++) {
            let c = string.charCodeAt(n);

            if (c < 128) {
              utftext += String.fromCharCode(c);
            } else if (c > 127 && c < 2048) {
              utftext += String.fromCharCode(c >> 6 | 192);
              utftext += String.fromCharCode(c & 63 | 128);
            } else {
              utftext += String.fromCharCode(c >> 12 | 224);
              utftext += String.fromCharCode(c >> 6 & 63 | 128);
              utftext += String.fromCharCode(c & 63 | 128);
            }
          }

          return utftext;
        }
        /**
         * utf-8解密
         * @param utftext 
         * @returns 
         */


        static _utf8Decode(utftext) {
          let string = "";
          let i = 0;
          let c = 0;
          let c1 = 0;
          let c2 = 0;
          let c3 = 0;

          while (i < utftext.length) {
            c = utftext.charCodeAt(i);

            if (c < 128) {
              string += String.fromCharCode(c);
              i++;
            } else if (c > 191 && c < 224) {
              c2 = utftext.charCodeAt(i + 1);
              string += String.fromCharCode((c & 31) << 6 | c2 & 63);
              i += 2;
            } else {
              c2 = utftext.charCodeAt(i + 1);
              c3 = utftext.charCodeAt(i + 2);
              string += String.fromCharCode((c & 15) << 12 | (c2 & 63) << 6 | c3 & 63);
              i += 3;
            }
          }

          return string;
        }
        /**
         * base64解密
         * @param {string}input 解密字符串
         * @returns 
         */


        static _base64Decode(input) {
          let keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
          let output = "";
          let chr1;
          let chr2;
          let chr3;
          let enc1;
          let enc2;
          let enc3;
          let enc4;
          let i = 0;
          input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

          while (i < input.length) {
            enc1 = keyStr.indexOf(input.charAt(i++));
            enc2 = keyStr.indexOf(input.charAt(i++));
            enc3 = keyStr.indexOf(input.charAt(i++));
            enc4 = keyStr.indexOf(input.charAt(i++));
            chr1 = enc1 << 2 | enc2 >> 4;
            chr2 = (enc2 & 15) << 4 | enc3 >> 2;
            chr3 = (enc3 & 3) << 6 | enc4;
            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
              output = output + String.fromCharCode(chr2);
            }

            if (enc4 != 64) {
              output = output + String.fromCharCode(chr3);
            }
          }

          output = this._utf8Decode(output);
          return output;
        }
        /**
         * 获取是否为16:9的常规屏幕尺寸
         */


        static isNormalScreen() {
          return screen.windowSize.height / screen.windowSize.width < 1335 / 750;
        }

      });

      Utils.loadedAssets = new Map();
      Utils.bundles = new Map();
      Utils.seed = 5;
      ;

      _cclegacy._RF.pop();

      _crd = false;
    }
  };
});
//# sourceMappingURL=fafa0bdea57fcf83961c2dc904502e31d7f358c4.js.map