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

  var _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, UITransform, Vec2, Vec3, screen, _decorator, find, director, Color, UIOpacity, tween, _dec, _class, _crd, ccclass, property, utils;

  return {
    setters: [function (_cc) {
      _cclegacy = _cc.cclegacy;
      __checkObsolete__ = _cc.__checkObsolete__;
      __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
      UITransform = _cc.UITransform;
      Vec2 = _cc.Vec2;
      Vec3 = _cc.Vec3;
      screen = _cc.screen;
      _decorator = _cc._decorator;
      find = _cc.find;
      director = _cc.director;
      Color = _cc.Color;
      UIOpacity = _cc.UIOpacity;
      tween = _cc.tween;
    }],
    execute: function () {
      _crd = true;

      _cclegacy._RF.push({}, "1828dk+2jlPB7I0ZNZXcWus", "utils", undefined);

      __checkObsolete__(['UITransform', 'Vec2', 'Vec3', 'Node', 'screen', '_decorator', 'find', 'director', 'Color', 'UIOpacity', 'tween', 'Label']);

      ({
        ccclass,
        property
      } = _decorator);

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

          if (typeof s === 'string') {
            var re = new RegExp("^[ ]+$");
            return re.test(s);
          } else {
            return false;
          }
        }
        /**
         * 合并多个字典
         * @param args 
         */


        static merge() {
          var mergeFn = (arg1, arg2) => {
            var res = {};
            res = Object.assign(arg1, arg2);
            return res;
          };

          var nDict = {};

          for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
            args[_key] = arguments[_key];
          }

          args.forEach(obj => {
            nDict = mergeFn(nDict, obj);
          });
          return nDict;
        }
        /**
         * 深度拷贝
         * @param {any} sObj 拷贝的对象
         * @returns 
         */


        static clone(sObj) {
          if (sObj === null || typeof sObj !== "object") {
            return sObj;
          }

          var s = {};

          if (sObj.constructor === Array) {
            s = [];
          }

          for (var i in sObj) {
            if (sObj.hasOwnProperty(i)) {
              s[i] = this.clone(sObj[i]);
            }
          }

          return s;
        }
        /**
         * 将object转化为数组
         * @param { any} srcObj  
         * @returns 
         */


        static objectToArray(srcObj) {
          var resultArr = []; // to array

          for (var _key2 in srcObj) {
            if (!srcObj.hasOwnProperty(_key2)) {
              continue;
            }

            resultArr.push(srcObj[_key2]);
          }

          return resultArr;
        }
        /**
         * !#zh 将数组转化为object。
         */

        /**
         * 将数组转化为object。
         * @param { any} srcObj 
         * @param { string} objectKey 
         * @returns 
         */


        static arrayToObject(srcObj, objectKey) {
          var resultObj = {}; // to object

          for (var key in srcObj) {
            if (!srcObj.hasOwnProperty(key) || !srcObj[key][objectKey]) {
              continue;
            }

            resultObj[srcObj[key][objectKey]] = srcObj[key];
          }

          return resultObj;
        }
        /**
         * 根据权重,计算随机内容
         * @param {arrany} weightArr 
         * @param {number} totalWeight 权重
         * @returns 
         */


        static getWeightRandIndex(weightArr, totalWeight) {
          var randWeight = Math.floor(Math.random() * totalWeight);
          var sum = 0;

          for (var weightIndex = 0; weightIndex < weightArr.length; weightIndex++) {
            sum += weightArr[weightIndex];

            if (randWeight < sum) {
              break;
            }
          }

          return weightIndex;
        }
        /**
         * 从n个数中获取m个随机数
         * @param {Number} n   总数
         * @param {Number} m    获取数
         * @returns {Array} array   获取数列
         */


        static getRandomNFromM(n, m) {
          var array = [];
          var intRd = 0;
          var count = 0;

          while (count < m) {
            if (count >= n + 1) {
              break;
            }

            intRd = this.getRandomInt(0, n);
            var flag = 0;

            for (var i = 0; i < count; i++) {
              if (array[i] === intRd) {
                flag = 1;
                break;
              }
            }

            if (flag === 0) {
              array[count] = intRd;
              count++;
            }
          }

          return array;
        }
        /**
         * 获取随机整数
         * @param {Number} min 最小值
         * @param {Number} max 最大值
         * @returns 
         */


        static getRandomInt(min, max) {
          var r = Math.random();
          var rr = r * (max - min + 1) + min;
          return Math.floor(rr);
        }
        /**
         * 获取字符串长度
         * @param {string} render 
         * @returns 
         */


        static getStringLength(render) {
          var strArr = render;
          var len = 0;

          for (var i = 0, n = strArr.length; i < n; i++) {
            var val = strArr.charCodeAt(i);

            if (val <= 255) {
              len = len + 1;
            } else {
              len = len + 2;
            }
          }

          return Math.ceil(len / 2);
        }
        /**
         * 要从一个数组模型中随机取出 n 个元素
         * @param arr 
         * @param n 
         * @returns 返回一个新的数组
         */


        static getRandomElements(arr, n) {
          if (n <= 0) return []; // 如果 n 小于等于 0，返回空数组
          //复制数组以避免修改原数组

          var copy = [...arr]; //Fisher-Yates 洗牌算法

          for (var i = copy.length - 1; i > 0; i--) {
            var j = Math.floor(Math.random() * (i + 1));
            [copy[i], copy[j]] = [copy[j], copy[i]];
          } //如果 n 超过数组长度，返回乱序后的整个数组


          if (n >= copy.length) {
            return copy;
          } //返回前 n 个元素


          return copy.slice(0, n);
        }
        /**
         * 判断传入的参数是否为空的Object。数组或undefined会返回false
         * @param obj
         */


        static isEmptyObject(obj) {
          var result = true;

          if (obj && obj.constructor === Object) {
            for (var key in obj) {
              if (obj.hasOwnProperty(key)) {
                result = false;
                break;
              }
            }
          } else {
            result = false;
          }

          return result;
        }
        /**
         * 判断是否是新的一天
         * @param {Object|Number} dateValue 时间对象 todo MessageCenter 与 pve 相关的时间存储建议改为 Date 类型
         * @returns {boolean}
         */


        static isNewDay(dateValue) {
          // todo：是否需要判断时区？
          var oldDate = new Date(dateValue);
          var curDate = new Date();
          var oldYear = oldDate.getYear();
          var oldMonth = oldDate.getMonth();
          var oldDay = oldDate.getDate();
          var curYear = curDate.getYear();
          var curMonth = curDate.getMonth();
          var curDay = curDate.getDate();

          if (curYear > oldYear) {
            return true;
          } else {
            if (curMonth > oldMonth) {
              return true;
            } else {
              if (curDay > oldDay) {
                return true;
              }
            }
          }

          return false;
        }
        /**
         * 获取对象属性数量
         * @param {object}o 对象
         * @returns 
         */


        static getPropertyCount(o) {
          var n,
              count = 0;

          for (n in o) {
            if (o.hasOwnProperty(n)) {
              count++;
            }
          }

          return count;
        }
        /**
         * 返回一个差异化数组（将array中diff里的值去掉）
         * @param array
         * @param diff
         */


        static difference(array, diff) {
          var result = [];

          if (array.constructor !== Array || diff.constructor !== Array) {
            return result;
          }

          var length = array.length;

          for (var i = 0; i < length; i++) {
            if (diff.indexOf(array[i]) === -1) {
              result.push(array[i]);
            }
          }

          return result;
        }

        static _stringToArray(string) {
          // 用于判断emoji的正则们
          var rsAstralRange = '\\ud800-\\udfff';
          var rsZWJ = '\\u200d';
          var rsVarRange = '\\ufe0e\\ufe0f';
          var rsComboMarksRange = '\\u0300-\\u036f';
          var reComboHalfMarksRange = '\\ufe20-\\ufe2f';
          var rsComboSymbolsRange = '\\u20d0-\\u20ff';
          var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
          var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
          var rsFitz = '\\ud83c[\\udffb-\\udfff]';
          var rsOptVar = '[' + rsVarRange + ']?';
          var rsCombo = '[' + rsComboRange + ']';
          var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
          var reOptMod = rsModifier + '?';
          var rsAstral = '[' + rsAstralRange + ']';
          var rsNonAstral = '[^' + rsAstralRange + ']';
          var rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}';
          var rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]';
          var rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*';
          var rsSeq = rsOptVar + reOptMod + rsOptJoin;
          var rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')';
          var reUnicode = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g');

          var hasUnicode = function hasUnicode(val) {
            return reHasUnicode.test(val);
          };

          var unicodeToArray = function unicodeToArray(val) {
            return val.match(reUnicode) || [];
          };

          var asciiToArray = function asciiToArray(val) {
            return val.split('');
          };

          return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
        } // 模拟传msg的uuid


        static simulationUUID() {
          function s4() {
            return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
          }

          return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
        }

        static trim(str) {
          return str.replace(/(^\s*)|(\s*$)/g, "");
        }
        /**
         * 判断当前时间是否在有效时间内
         * @param {String|Number} start 起始时间。带有时区信息
         * @param {String|Number} end 结束时间。带有时区信息
         */


        static isNowValid(start, end) {
          var startTime = new Date(start);
          var endTime = new Date(end);
          var result = false;

          if (startTime.getDate() + '' !== 'NaN' && endTime.getDate() + '' !== 'NaN') {
            var curDate = new Date();
            result = curDate < endTime && curDate > startTime;
          }

          return result;
        }
        /**
         * 返回相隔天数
         * @param start 
         * @param end 
         * @returns 
         */


        static getDeltaDays(start, end) {
          start = new Date(start);
          end = new Date(end);
          var startYear = start.getFullYear();
          var startMonth = start.getMonth() + 1;
          var startDate = start.getDate();
          var endYear = end.getFullYear();
          var endMonth = end.getMonth() + 1;
          var endDate = end.getDate();
          start = new Date(startYear + '/' + startMonth + '/' + startDate + ' GMT+0800').getTime();
          end = new Date(endYear + '/' + endMonth + '/' + endDate + ' GMT+0800').getTime();
          var deltaTime = end - start;
          return Math.floor(deltaTime / (24 * 60 * 60 * 1000));
        }
        /**
         * 获取数组最小值
         * @param array 数组
         * @returns 
         */


        static getMin(array) {
          var result = null;

          if (array.constructor === Array) {
            var length = array.length;

            for (var i = 0; i < length; i++) {
              if (i === 0) {
                result = Number(array[0]);
              } else {
                result = result > Number(array[i]) ? Number(array[i]) : result;
              }
            }
          }

          return result;
        }
        /**
         * 格式化两位小数点
         * @param time 
         * @returns 
         */


        static formatTwoDigits(time) {
          //@ts-ignore
          return (Array(2).join(0) + time).slice(-2);
        }
        /**
         * 根据格式返回时间
         * @param date  时间
         * @param fmt 格式
         * @returns 
         */


        static formatDate(date, fmt) {
          var o = {
            "M+": date.getMonth() + 1,
            //月份
            "d+": date.getDate(),
            //日
            "h+": date.getHours(),
            //小时
            "m+": date.getMinutes(),
            //分
            "s+": date.getSeconds(),
            //秒
            "q+": Math.floor((date.getMonth() + 3) / 3),
            //季度
            "S": date.getMilliseconds() //毫秒

          };
          if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));

          for (var k in o) if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));

          return fmt;
        }
        /**
         * 获取格式化后的日期（不含小时分秒）
         */


        static getDay() {
          var date = new Date();
          return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
        }
        /**
         * 格式化名字，XXX...
         * @param {string} name 需要格式化的字符串 
         * @param {number}limit 
         * @returns {string} 返回格式化后的字符串XXX...
         */


        static formatName(name, limit) {
          limit = limit || 6;

          var nameArray = this._stringToArray(name);

          var str = '';
          var length = nameArray.length;

          if (length > limit) {
            for (var i = 0; i < limit; i++) {
              str += nameArray[i];
            }

            str += '...';
          } else {
            str = name;
          }

          return str;
        }
        /**
         * 格式化钱数，超过10000 转换位 10K   10000K 转换为 10M
         * @param {number}money 需要被格式化的数值
         * @returns {string}返回 被格式化的数值
         */


        static formatMoney(money) {
          var arrUnit = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y', 'B', 'N', 'D'];
          var strValue = '';

          for (var idx = 0; idx < arrUnit.length; idx++) {
            if (money >= 10000) {
              money /= 1000;
            } else {
              strValue = Math.floor(money) + arrUnit[idx];
              break;
            }
          }

          if (strValue === '') {
            strValue = Math.floor(money) + 'U'; //超过最大值就加个U
          }

          return strValue;
        }
        /**
         * 格式化数值
         * @param {number}value 需要被格式化的数值
         * @returns {string}返回 被格式化的数值
         */


        static formatValue(value) {
          var arrUnit = [];
          var strValue = '';

          for (var i = 0; i < 26; i++) {
            arrUnit.push(String.fromCharCode(97 + i));
          }

          for (var idx = 0; idx < arrUnit.length; idx++) {
            if (value >= 10000) {
              value /= 1000;
            } else {
              strValue = Math.floor(value) + arrUnit[idx];
              break;
            }
          }

          return strValue;
        }
        /**
         * 根据剩余秒数格式化剩余时间 返回 HH:MM:SS
         * @param {Number} leftSec 
         */


        static formatTimeForSecond(leftSec, withoutSeconds) {
          if (withoutSeconds === void 0) {
            withoutSeconds = false;
          }

          var timeStr = '';
          var sec = leftSec % 60;
          var leftMin = Math.floor(leftSec / 60);
          leftMin = leftMin < 0 ? 0 : leftMin;
          var hour = Math.floor(leftMin / 60);
          var min = leftMin % 60;

          if (hour > 0) {
            timeStr += hour > 9 ? hour.toString() : '0' + hour;
            timeStr += ':';
          } else {
            timeStr += '00:';
          }

          timeStr += min > 9 ? min.toString() : '0' + min;

          if (!withoutSeconds) {
            timeStr += ':';
            timeStr += sec > 9 ? sec.toString() : '0' + sec;
          }

          return timeStr;
        }
        /**
         *  根据剩余毫秒数格式化剩余时间 返回 HH:MM:SS
         *
         * @param {Number} ms
         */


        static formatTimeForMillisecond(ms) {
          var second = Math.floor(ms / 1000 % 60);
          var minute = Math.floor(ms / 1000 / 60 % 60);
          var hour = Math.floor(ms / 1000 / 60 / 60);
          return {
            'hour': hour,
            'minute': minute,
            'second': second
          };
        }
        /**
         * 格式化时间戳字符串
         * @param timestamp 1740006560000
         * @returns 输出2025-02-20 05:09:20
         */


        static formatTimestamp(timestamp) {
          var date = new Date(timestamp); //获取年月日时分秒

          var year = date.getFullYear(); //月份从 0 开始，需要 +1

          var month = String(date.getMonth() + 1).padStart(2, '0');
          var day = String(date.getDate()).padStart(2, '0');
          var hours = String(date.getHours()).padStart(2, '0');
          var minutes = String(date.getMinutes()).padStart(2, '0');
          var seconds = String(date.getSeconds()).padStart(2, '0'); //拼接成 YYYY-MM-DD HH:MM:SS 格式

          return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
        }
        /**
         * 随机乱序数组
         * @param array 
         * @returns 
         */


        static randomArray(array) {
          // 使用 Fisher-Yates Shuffle 算法
          for (var i = array.length - 1; i > 0; i--) {
            var j = Math.floor(Math.random() * (i + 1)); // 交换元素

            [array[i], array[j]] = [array[j], array[i]];
          }

          return array;
        }
        /**
         * 获得开始和结束两者之间相隔分钟数
         *
         * @static
         * @param {number} start
         * @param {number} end
         * @memberof utils
         */


        static getOffsetMimutes(start, end) {
          var offSetTime = end - start;
          var minute = Math.floor(offSetTime % (1000 * 60 * 60) / (1000 * 60));
          return minute;
        }
        /**
         * 获取随机小数
         * @param {Number} min 最小值
         * @param {Number} max 最大值
         * @returns 
         */


        static getRandomFloat(min, max) {
          return Math.random() * (max - min) + min;
        }
        /**
         * 返回指定小数位的数值
         * @param {number} num 
         * @param {number} idx 
         */


        static formatNumToFixed(num, idx) {
          if (idx === void 0) {
            idx = 0;
          }

          return Number(num.toFixed(idx));
        }
        /**
         * 用于数值到达另外一个目标数值之间进行平滑过渡运动效果
         * @param {number} targetValue 目标数值 
         * @param {number} curValue 当前数值
         * @param {number} ratio    过渡比率
         * @returns 
         */


        static lerp(targetValue, curValue, ratio) {
          if (ratio === void 0) {
            ratio = 0.25;
          }

          var v = curValue;

          if (targetValue > curValue) {
            v = curValue + (targetValue - curValue) * ratio;
          } else if (targetValue < curValue) {
            v = curValue - (curValue - targetValue) * ratio;
          }

          return v;
        }
        /**
         * 数据解密
         * @param {String} str 
         */


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

          var n = 6;

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

          var 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 "";
          }

          var b64Data = this._base64encode(str);

          var n = 6;

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

          var encodeData = '';

          for (var 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) {
          var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
          var 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");
          var utftext = "";

          for (var n = 0; n < string.length; n++) {
            var 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) {
          var string = "";
          var i = 0;
          var c = 0;
          var c1 = 0;
          var c2 = 0;
          var 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) {
          var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
          var output = "";
          var chr1;
          var chr2;
          var chr3;
          var enc1;
          var enc2;
          var enc3;
          var enc4;
          var 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;
        }
        /**
         * 开始展示文字
         * @param lable 文本
         * @param words 播放的文字
         * @param cb 播放完成回调
         * @param cbbS 回调延迟
         * @param delay 延迟逐字播放
         * @param s 一个字的播放速度/秒
         */


        static verbatim(lable, words, cb, cbbS, delay, s) {
          if (cbbS === void 0) {
            cbbS = 0;
          }

          if (delay === void 0) {
            delay = 0;
          }

          if (s === void 0) {
            s = 0.1;
          }

          if (!words.hasOwnProperty('length')) {
            return;
          }

          lable.node.active = true;
          lable.unscheduleAllCallbacks();

          var f = function f() {
            var arr = words.replace(/ /g, "").split('');
            var step = 0;
            var allWords = "";

            var fun = function () {
              allWords += arr[step];
              lable.string = allWords;

              if (++step >= arr.length) {
                lable.unschedule(fun);

                var cbFun = () => {
                  cb == null ? void 0 : cb();
                };

                cbbS > 0 ? lable.scheduleOnce(cbFun, cbbS) : cbFun();
              }
            }.bind(this);

            lable.schedule(fun, s, Number.MAX_SAFE_INTEGER);
          };

          delay > 0 ? lable.scheduleOnce(f.bind(this), delay) : f();
        }
        /**
         * 页面渐隐渐显动画
         * @param n 节点
         * @param isApper 是否是出现
         * @param restore 是否恢复255显示的状态
         * @param cb 执行完回调 
         */


        static pageAnim(n, isApper, cb) {
          if (isApper === void 0) {
            isApper = true;
          }

          var uiop = n.getComponent(UIOpacity);

          if (!n || !uiop) {
            cb == null ? void 0 : cb();
          } else {
            uiop.opacity = isApper ? 25 : 255;
            var toOpacity = isApper ? 255 : 25;
            tween(uiop).to(0.4, {
              opacity: toOpacity
            }).call(function () {
              cb == null ? void 0 : cb();
            }.bind(this)).start();
          }
        }
        /**
         * 将数组（array）拆分成多个 size 长度的区块，并将这些区块组成一个新数组
         * @param {Array}array 
         * @param {number}size 
         * @returns 
         */


        static chunk(array, size) {
          var length = array === null ? 0 : array.length;

          if (!length || size < 1) {
            return [];
          }

          var result = [];

          while (array.length > size) {
            result.push(array.slice(0, size));
            array = array.slice(size);
          }

          result.push(array);
          return result;
        }
        /**
         * 查询一个节点下的子节点
         */


        static findName(root, name) {
          var 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) {
          var child = parent.getChildByName(name);

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

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

              if (child) {
                return child;
              }
            }
          }

          return null;
        }
        /**
         * 处理万为单位
         * @param num 数值
         * @param point 保留小数点
         * @param s 是否去掉无用的0
         * @returns 
         */


        static numUnit(num, point, f) {
          if (point === void 0) {
            point = 0;
          }

          if (f === void 0) {
            f = true;
          }

          var n = num;
          var unit = 10000;

          if (n > unit) {
            if (point == 0) {
              n = Math.ceil(n / unit);
              return n.toString() + "万";
            } else {
              var s = (n / unit).toFixed(point);

              if (f) {
                return this.removeZeros(s) + "万";
              } else {
                return s + "万";
              }
            }
          } else {
            return Math.ceil(num).toString();
          }
        }
        /**
         * 格式化数字：
         * * 如果小数部分全是 0（如 38.0 或 38.00），去掉小数部分，返回整数。
         * 如果是小数（如 38.1 或 38.01），保留两位小数。
         * @param num 输入的数字
         * @returns 格式化后的数字
         */


        static formatNumber(num) {
          // 如果 num 是 undefined 或 null，返回 0 或空字符串
          if (num == undefined || num == null) return 0; //将数字转换为字符串

          var numStr = num.toString(); //判断小数部分是否全是 0 如果小数部分全是 0，去掉小数部分并返回整数

          if (numStr.includes('.') && /\.0+$/.test(numStr)) {
            return parseInt(numStr, 10);
          } else {
            //否则保留两位小数
            var fixedNum = num.toFixed(2); //如果小数部分全是 0，去掉小数部分

            if (fixedNum.endsWith(".00")) {
              return parseInt(fixedNum, 10);
            }

            return parseFloat(fixedNum);
          }
        }
        /**
         * 去掉小数点后无用的0
         * @param numberString 字符串呢
         * @returns 
         */


        static removeZeros(numberString) {
          var trimmedString = numberString.trim(); // 去除首尾空格

          var decimalIndex = trimmedString.indexOf('.');

          if (decimalIndex !== -1) {
            var endIndex = trimmedString.length - 1;

            while (trimmedString[endIndex] === '0') {
              endIndex--;
            }

            if (trimmedString[endIndex] === '.') {
              endIndex--; // 如果小数点后面全是零，也去掉小数点
            }

            return trimmedString.slice(0, endIndex + 1);
          }

          return trimmedString;
        }
        /**
         * 数组移除某一个元素
         */


        static remove(arr, p) {
          var index = arr.indexOf(p);

          if (index > -1) {
            arr.splice(index, 1);
          }
        }
        /**
         * 16进制的颜色
         * @param hexColor 
         * @returns 
         */


        static hexColor(hexColor) {
          var hex = hexColor.replace(/^#?/, "0x");
          var c = parseInt(hex);
          var r = c >> 16;
          var g = (65280 & c) >> 8;
          var b = 255 & c;
          return new Color(r, g, b, 255);
        }

        /**
         * 计算两点间的距离
         */
        static pDistance(localPos, tarPos) {
          var dx = localPos.x - tarPos.x;
          var dy = localPos.y - tarPos.y;
          var dis = Math.sqrt(dx * dx + dy * dy);
          return dis;
        }
        /**
         * 计算两点之间的绝对距离
         */


        static pAbsDistance(a, b) {
          var p = Math.abs(a.x - b.x);
          var k = Math.abs(a.y - b.y);
          return p + k;
        }
        /**
         * 角度转向量 
         * @param angle 
         * @returns 
         */


        static angle_to_vector(angle) {
          // tan = sin / cos 将传入的角度转为弧度
          var radian = this.angle_to_radian(angle); // 算出cos,sin和tan

          var cos = Math.cos(radian); // 邻边 / 斜边

          var sin = Math.sin(radian); // 对边 / 斜边

          var tan = sin / cos; // 对边 / 邻边
          //结合在一起并归一化

          var vec = new Vec2(cos, sin).normalize(); //返回向量

          return vec;
        }
        /**
         * 向量转角度
         * @param vector 
         * @returns 
         */


        static vector_to_angle(vector) {
          //将传入的向量归一化
          var dir = vector.normalize(); //计算出目标角度的弧度

          var radian = dir.signAngle(new Vec2(1, 0)); //把弧度计算成角度

          var angle = -this.radian_to_angle(radian); //返回角度

          return angle;
        }
        /**
         * 角度转弧度
         * @param angle 
         * @returns 
         */


        static angle_to_radian(angle) {
          //角度转弧度公式 π / 180 * 角度 计算出弧度
          var radian = Math.PI / 180 * angle; //返回弧度

          return radian;
        }
        /**
         * 弧度转角度
         * @param radian 
         * @returns 
         */


        static radian_to_angle(radian) {
          //弧度转角度公式 180 / π * 弧度 计算出角度
          var angle = 180 / Math.PI * radian; //返回角度

          return angle;
        }
        /**
         * 计算弧度
         * @param start 
         * @param end 
         */


        static getAngle(start, end) {
          //两点的x、y值
          var x = end.x - start.x;
          var y = end.y - start.y;
          var hypotenuse = Math.sqrt(x * x + y * y); //斜边长度

          var cos = x / hypotenuse;
          var radian = Math.acos(cos); //求出弧度

          var angle = 180 / (Math.PI / radian); //用弧度算出角度

          if (y < 0) {
            angle = 0 - angle;
          } else if (y == 0 && x < 0) {
            angle = 180;
          }

          return angle;
        }
        /**
         * 扣血转化成字符串
         * @param number 
         * @returns 
         */


        static numberToString(number) {
          var str = '';
          var data = [{
            minnum: 1000000000,
            maxnum: 9999999999,
            toStr: 'o'
          }, {
            minnum: 100000000,
            maxnum: 999999999,
            toStr: 'p'
          }, {
            minnum: 10000000,
            maxnum: 99999999,
            toStr: 't'
          }, {
            minnum: 1000000,
            maxnum: 9999999,
            toStr: 'g'
          }, {
            minnum: 100000,
            maxnum: 999999,
            toStr: 'm'
          }, {
            minnum: 10000,
            maxnum: 99999,
            toStr: 'b'
          }, {
            minnum: 1000,
            maxnum: 9999,
            toStr: 'K'
          }];

          for (var i = 0; i < data.length; i++) {
            if (number >= data[i].minnum && number <= data[i].maxnum) {
              number /= data[i].minnum;
              var m = number.toFixed(1);
              str = m + data[i].toStr;
              return str;
            }
          }

          return number.toFixed(0);
        }
        /**
         * 将某个节点下的坐标转移到另外一个节点
         * @param fromNode 坐标所在的节点
         * @param toNode 目标节点
         * @returns 转换后的坐标值
         */


        static convertPosition(fromNode, toNode) {
          var pos = fromNode.position.clone(); // 将 pos 转为世界坐标系下的坐标

          var worldPos = fromNode.parent.getComponent(UITransform).convertToWorldSpaceAR(pos); // 将世界坐标系下的坐标转为目标节点的局部坐标系下的坐标

          var localPos = toNode.getComponent(UITransform).convertToNodeSpaceAR(worldPos);
          return localPos;
        }
        /**
         * 以敌人的中心点 攻击范围为半径 产生随机坐标
         * @param center 中心点
         * @param radius 半径
         * @returns 
         */


        static randomPointGenerator(center, radius) {
          //随机角度
          var angle = Math.random() * Math.PI * 2; //随机距离

          var distance = Math.sqrt(Math.random()) * radius; //根据极坐标转换成笛卡尔坐标

          var x = center.x + distance * Math.cos(angle);
          var y = center.y + distance * Math.sin(angle);
          return new Vec3(x, y, 1);
        }
        /**
         * 将某个节点上的坐标转移到另外一个节点
         * @param fromNode 坐标所在的节点
         * @param toNode 目标节点
         * @returns 转换后的坐标值
         */


        static convertPositionPos(fromNode, pos, toNode) {
          var nPos = pos.clone(); // 将 pos 转为世界坐标系下的坐标

          var worldPos = fromNode.parent.getComponent(UITransform).convertToWorldSpaceAR(nPos); // 将世界坐标系下的坐标转为目标节点的局部坐标系下的坐标

          var localPos = toNode.getComponent(UITransform).convertToNodeSpaceAR(worldPos);
          return localPos;
        }
        /**
         * 根据A，B两个坐标点 和抛物线的弧度 来计算中心点坐标
         */


        static calculateParabolaCenter(start, end) {
          // 计算两点之间的水平距离
          var deltaX = end.x - start.x; // 将控制点的 x 坐标设置为两点的中点

          var controlX = (start.x + end.x) / 2; // 计算抛物线的最高点，使其位于两点之间的中间位置 可以根据需要调整最高点的位置

          var highestY = Math.max(start.y, end.y) + Math.abs(deltaX) / 4; // 计算控制点的 y 坐标

          var controlY = highestY; //返回抛物线的中心坐标点

          return new Vec3(controlX, controlY);
        }
        /**
         * 生成一个随机颜色值的函数
         */


        static getRandomColor() {
          var r = Math.floor(Math.random() * 256);
          var g = Math.floor(Math.random() * 256);
          var b = Math.floor(Math.random() * 256);
          return new Color(r, g, b);
        }
        /**
         * 获取是否为16:9的常规屏幕尺寸
         */


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

      }) || _class));

      _cclegacy._RF.pop();

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