ddgame_kit
Version:
DDKit - 游戏开发工具库
2 lines (1 loc) • 27.8 kB
JavaScript
class t{static delay(t){return new Promise((r=>setTimeout(r,t)))}}function r(){return class t{static get ins(){return t.t||(t.t=new this),t.t}}}class e{constructor(t=null,r=null,i=null,s=!1){this.caller=null,this.method=null,this.args=null,this.once=!1,this.i=0,this.setTo(t,r,i,s),e.h++}static log(){}setTo(t,r,i,s=!1){return this.i=e.o++,this.caller=t,this.method=r,this.args=i,this.once=s,this}run(){if(null==this.method)return null;var t=this.i,r=this.method.apply(this.caller,this.args);return this.i===t&&this.once&&this.recover(),r}runWith(t){if(null==this.method)return null;var r=this.i;if(null==t)var e=this.method.apply(this.caller,this.args);else e=this.args||t.unshift?this.method.apply(this.caller,this.args?this.args.concat(t):t):this.method.call(this.caller,t);return this.i===r&&this.once&&this.recover(),e}clear(){return this.caller=null,this.method=null,this.args=null,this}recover(){this.i>0&&(this.i=0,e.u.push(this.clear()))}static create(t,r,i=null,s=!0){return e.u.length?e.u.pop().setTo(t,r,i,s):new e(t,r,i,s)}}e.h=0,e.u=[],e.o=1;class i{constructor(){this.l=0,this.m=[]}add(t,r,e){let i=this.m,s=i.findIndex(((e,i,s)=>e==t&&s[i+1]==r));-1!=s?(i[s+2]=e,i[s+3]=1):i.push(t,r,e,1)}once(t,r,e){let i=this.m,s=i.findIndex(((e,i,s)=>e==t&&s[i+1]==r));-1!=s?(i[s+2]=e,i[s+3]=2):i.push(t,r,e,2)}remove(t,r){let e=this.m,i=e.findIndex(((e,i,s)=>e==t&&s[i+1]==r));-1!=i&&(0!=this.l?(e[i+3]=0,this.l=2):e.splice(i,4))}clear(){let t=this.m;0!=this.l?(t.forEach(((t,r,e)=>{r%4==3&&(e[r]=0)})),this.l=2):t.length=0}clearForTarget(t){if(!t)return;let r=this.m;if(0!=this.l)r.forEach(((r,e,i)=>{e%4==1&&i[e]==t&&(i[e+2]=0)})),this.l=2;else{let e=r.length-4;for(;e>=0;)r[e+1]==t&&r.splice(e,4),e-=4}}get count(){return this.m.length/4}invoke(...t){if(0!=this.l)return;this.l=1;let r=this.m,e=r.length;for(let i=0;e>i;i+=4){if(0==r[i+3])continue;let e=r[i+2];try{null!=e?r[i].call(r[i+1],...e,...t):r[i].call(r[i+1],...t)}catch(t){}2==r[i+3]&&(r[i+3]=0,this.l=2)}if(2==this.l){let t=r.length,e=0;for(;t>e;)0!=r[e+3]?e+=4:(r.splice(e,4),t-=4)}this.l=0}}class s{onStartListeningToType(t){}hasListener(t){let r=this.M&&this.M[t];return!!r&&r.count>0}emit(t,r){let e=this.M&&this.M[t];if(!e)return!1;let i=e.count>0;return Array.isArray(r)?e.invoke(...r):void 0!==r?e.invoke(r):e.invoke(),i}on(t,r,e,s){2==arguments.length&&(e=r,r=null),this.M||(this.M={});let n=this.M[t];return n||(this.onStartListeningToType(t),this.M[t]=n=new i),n.add(e,r,s),this}once(t,r,e,s){2==arguments.length&&(e=r,r=null),this.M||(this.M={});let n=this.M[t];return n||(this.onStartListeningToType(t),this.M[t]=n=new i),n.once(e,r,s),this}off(t,r,e){2==arguments.length&&(e=r,r=null);let i=this.M&&this.M[t];return i&&i.remove(e,r),this}offAll(t){if(null==t)this.M=void 0;else{let r=this.M&&this.M[t];r&&r.clear()}return this}offAllCaller(t){if(t&&this.M)for(let r in this.M)this.M[r].clearForTarget(t);return this}}class n{constructor(){this.history=[]}addEntry(t){this.history.push(t)}getHistory(){return this.history}print(){}clear(){this.history=[]}exportToJson(){return JSON.stringify(this.history)}}class h{constructor(t,r,e=!1){this.name=t,this.transitions=new Map,this.states=new Map,this.currentState=null,this.previousState=null,this.debugMode=!1,this.initialStateName=r.initialState,this.debugMode=e}addState(t){this.states.has(t.name)||(t.parent=this,this.states.set(t.name,t),t.name!==this.initialStateName||this.currentState||this.changeState(t.name))}reset(){this.currentState&&this.currentState.onExit(),this.changeState(this.initialStateName)}getCurrentState(){return this.currentState}onEnter(){!this.currentState&&this.initialStateName&&this.changeState(this.initialStateName)}onExit(){this.currentState&&(this.currentState.onExit(),this.currentState=null)}onUpdate(t){this.currentState&&this.currentState.onUpdate(t)}addTransition(t,r,i,s=[],n=[],h=0){const a=s.map((t=>e.create(t[0],t[1],null,!1))),o=n.map((t=>e.create(t[0],t[1],null,!1))),u=this.transitions.get(t)||[];u.push({from:r,to:i,guards:a,actions:o,priority:h}),u.sort(((t,r)=>(r.priority||0)-(t.priority||0))),this.transitions.set(t,u)}getNextState(t,r=[]){var e,i;if(!this.currentState)return{success:!1,failureReason:"No current state found"};let s=this.transitions.get(t);if(s=s?s.filter((t=>this.currentState&&t.from===this.currentState.name)):[],0===s.length)return{success:!1,failureReason:`No transition rules found for input: ${t} current state ${this.currentState.name}`};for(const t of s){if(null===(i=null===(e=t.guards)||void 0===e?void 0:e.every((e=>e.runWith([...r,t]))))||void 0===i||i)return{success:!0,targetState:t.to,rule:t}}return{success:!1,failureReason:"Guard conditions not met"}}handleInput(t,r=[]){var e;if(!this.currentState)return!1;const i=this.getNextState(t,r);return!(!i.success||!i.targetState)&&(this.changeState(i.targetState,t,r),i.rule&&(null===(e=i.rule.actions)||void 0===e||e.forEach((t=>t.runWith(r)))),!0)}enableDebug(){this.debugMode=!0}disableDebug(){this.debugMode=!1}changeState(t,r,e=[]){var i;const s=this.states.get(t);if(!s)return;const n=(null===(i=this.currentState)||void 0===i?void 0:i.name)||null;this.currentState&&(this.currentState.onExit(...e),this.previousState=this.currentState),this.currentState=s,this.currentState.onEnter(...e),this.debugMode&&h.historyManager.addEntry({timestamp:Date.now(),stateMachine:this.name,from:n,to:t,input:r,metadata:{hierarchyLevel:this.getHierarchyLevel(),hasParent:!!this.parent,activeStates:this.getActiveStatesHierarchy()}})}getHierarchyLevel(){let t=0,r=this;for(;r.parent;)t++,r=r.parent;return t}getActiveStatesHierarchy(){const t=[];let r=this;for(;r;)r.currentState&&t.unshift(r.currentState.name),r=r.parent;return t}static getHistory(){return this.historyManager.getHistory()}static printHistory(){this.historyManager.print()}static clearHistory(){this.historyManager.clear()}static exportHistory(){return this.historyManager.exportToJson()}}h.historyManager=new n;class a{constructor(t){this.name=t}onExit(...t){}onEnter(...t){}onUpdate(...t){}}class o{static clone(t){if(null===t||"object"!=typeof t)return t;let r={};t.constructor===Array&&(r=[]);for(let e in t)t.hasOwnProperty(e)&&(r[e]=this.clone(t[e]));return r}static objectToArray(t){let r=[];for(let e in t)t.hasOwnProperty(e)&&r.push(t[e]);return r}static arrayToObject(t,r){let e={};for(var i in t)t.hasOwnProperty(i)&&t[i][r]&&(e[t[i][r]]=t[i]);return e}static getWeightRandIndex(t,r){let e=Math.floor(Math.random()*r),i=0;for(var s=0;t.length>s&&(i+=t[s],i<=e);s++);return s}static getRandomNFromM(t,r){let e=[],i=0,s=0;for(;r>s&&t+1>s;){i=this.getRandomInt(0,t);for(var n=0,h=0;s>h;h++)if(e[h]===i){n=1;break}0===n&&(e[s]=i,s++)}return e}static getRandomInt(t,r){let e=Math.random();return Math.floor(e*(r-t+1)+t)}static getRandom(t,r){return Math.random()*(r-t)+t}static getStringLength(t){let r=t,e=0;for(let t=0,i=r.length;i>t;t++){e+=r.charCodeAt(t)>255?2:1}return Math.ceil(e/2)}static isEmptyObject(t){let r=!0;if(t&&t.constructor===Object){for(var e in t)if(t.hasOwnProperty(e)){r=!1;break}}else r=!1;return r}static isNewDay(t){var r=new Date(t),e=new Date,i=r.getYear(),s=r.getMonth(),n=r.getDate(),h=e.getYear(),a=e.getMonth(),o=e.getDate();return h>i||(a>s||o>n)}static getPropertyCount(t){var r,e=0;for(r in t)t.hasOwnProperty(r)&&e++;return e}static difference(t,r){let e=[];if(t.constructor!==Array||r.constructor!==Array)return e;let i=t.length;for(let s=0;i>s;s++)-1===r.indexOf(t[s])&&e.push(t[s]);return e}static P(t){var r="\\ud800-\\udfff",e="\\u200d",i="\\ufe0e\\ufe0f",s="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",n=RegExp("["+e+r+s+i+"]"),h="\\ud83c[\\udffb-\\udfff]",a="["+i+"]?",o="["+s+"]",u="(?:"+o+"|"+h+")"+"?",l="["+r+"]",c="[^"+r+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",d="[\\ud800-\\udbff][\\udc00-\\udfff]",g=a+u+("(?:"+e+"(?:"+[c,f,d].join("|")+")"+a+u+")*"),m=RegExp(h+"(?="+h+")|"+("(?:"+[c+o+"?",o,f,d,l].join("|")+")")+g,"g");return n.test(t)?function(t){return t.match(m)||[]}(t):function(t){return t.split("")}(t)}static simulationUUID(){function t(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}return t()+t()+"-"+t()+"-"+t()+"-"+t()+"-"+t()+t()+t()}static trim(t){return t.replace(/(^\s*)|(\s*$)/g,"")}static isNowValid(t,r){var e=new Date(t),i=new Date(r),s=!1;if(e.getDate()+""!="NaN"&&i.getDate()+""!="NaN"){var n=new Date;s=i>n&&n>e}return s}static getDeltaDays(t,r){t=new Date(t),r=new Date(r);let e=t.getFullYear(),i=t.getMonth()+1,s=t.getDate(),n=r.getFullYear(),h=r.getMonth()+1,a=r.getDate();return t=new Date(e+"/"+i+"/"+s+" GMT+0800").getTime(),r=new Date(n+"/"+h+"/"+a+" GMT+0800").getTime(),Math.floor((r-t)/864e5)}static getMin(t){let r=null;if(t.constructor===Array){let e=t.length;for(let i=0;e>i;i++)r=0===i?Number(t[0]):r>Number(t[i])?Number(t[i]):r}return r}static formatTwoDigits(t){return("0"+t).slice(-2)}static formatDate(t,r="Y年M月D日 H时I分S秒"){const e=new Date(t),i=e.getFullYear(),s=(e.getMonth()+1+"").padStart(2,"0"),n=(e.getDate()+"").padStart(2,"0"),h=(e.getHours()+"").padStart(2,"0"),a=(e.getMinutes()+"").padStart(2,"0"),o=(e.getSeconds()+"").padStart(2,"0");return r.replace("Y",""+i).replace("M",s).replace("D",n).replace("H",h).replace("I",a).replace("S",o)}static formatLeftTime(t){const r=Math.floor(t/1e3),e=Math.floor(r/3600),i=Math.floor(r%3600/60),s=r%60,n=t=>(""+t).padStart(2,"0");return`${n(e)}:${n(i)}:${n(s)}`}static formatTime(t,r=!0,e="D:H:M",i="H:M:S"){const s=Math.floor((t=r?Math.floor(t/1e3):t)/86400),n=(""+Math.floor(t%86400/3600)).padStart(2,"0"),h=(""+Math.floor(t%3600/60)).padStart(2,"0"),a=(""+t%60).padStart(2,"0");return s>0?e.replace("D",""+s).replace("H",n).replace("M",h):i.replace("H",n).replace("M",h).replace("S",a)}static getDay(){let t=new Date;return t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate()}static formatName(t,r){r=r||6;var e=this.P(t),i="";if(e.length>r){for(var s=0;r>s;s++)i+=e[s];i+="..."}else i=t;return i}static formatMoney(t){let r=["","K","M","G","T","P","E","Z","Y","B","N","D"],e="";for(let i=0;12>i;i++){if(1e4>t){e=Math.floor(t)+r[i];break}t/=1e3}return""===e&&(e=Math.floor(t)+"U"),e}static usd(t){return.01*t}static formatArr(t,r,e=!1){if(!r)return t;let i="",s=r.length;for(let e=0;s>e;e++)i=r[e],i=null==i?"":""+i,t=t.replace(RegExp("\\{"+e+"\\}","g"),i);return t=t.replace(RegExp("\\{#\\}","g"),i)}static getErrorCode(t){return this.errorCode[t]&&this.errorCode[t]}static formatValue(t){let r=[],e="";for(let t=0;26>t;t++)r.push(String.fromCharCode(97+t));for(let i=0;r.length>i;i++){if(1e4>t){e=Math.floor(t)+r[i];break}t/=1e3}return e}static formatTimeForSecond(t,r=!1){let e="",i=t%60,s=Math.floor(t/60);s=0>s?0:s;let n=Math.floor(s/60),h=s%60;return n>0?(e+=n>9?""+n:"0"+n,e+=":"):e+="00:",e+=h>9?""+h:"0"+h,r||(e+=":",e+=i>9?""+i:"0"+i),e}static formatTimeForMillisecond(t){let r=Math.floor(t/1e3%60),e=Math.floor(t/1e3/60%60);return{hour:Math.floor(t/1e3/60/60),minute:e,second:r}}static rand(t){let r=this.clone(t);for(let t=r.length-1;t>=0;t--){const e=Math.floor(Math.random()*(t+1)),i=r[e];r[e]=r[t],r[t]=i}return r}static getOffsetMimutes(t,r){return Math.floor((r-t)%36e5/6e4)}static formatNumToFixed(t,r=0){return Number(t.toFixed(r))}static lerp(t,r,e=.25){let i=r;return t>r?i=r+(t-r)*e:r>t&&(i=r-(r-t)*e),i}static decrypt(t){let r=6;t.length%2==0&&(r=7);let e="";for(var i=0;t.length-r>i;i+=2)e+=t[i+1],e+=t[i];return e+=t.slice(t.length-r+1),e=this.v(e),e}static encrypt(t){let r=this.S(t),e=6;r.length%2==0&&(e=7);let i="";for(let t=0;(r.length-e+1)/2>t;t++)i+=r[2*t+1],i+=r[2*t];return i+=r.slice(r.length-e+1),i}static S(t){let r,e,i,s,n,h,a,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u="",l=0;for(t=this.p(t);t.length>l;)r=t.charCodeAt(l++),e=t.charCodeAt(l++),i=t.charCodeAt(l++),s=r>>2,n=(3&r)<<4|e>>4,h=(15&e)<<2|i>>6,a=63&i,isNaN(e)?h=a=64:isNaN(i)&&(a=64),u=u+o.charAt(s)+o.charAt(n)+o.charAt(h)+o.charAt(a);return u}static p(t){t=t.replace(/\r\n/g,"\n");let r="";for(let e=0;t.length>e;e++){let i=t.charCodeAt(e);128>i?r+=String.fromCharCode(i):i>127&&2048>i?(r+=String.fromCharCode(i>>6|192),r+=String.fromCharCode(63&i|128)):(r+=String.fromCharCode(i>>12|224),r+=String.fromCharCode(i>>6&63|128),r+=String.fromCharCode(63&i|128))}return r}static D(t){let r="",e=0,i=0,s=0,n=0;for(;t.length>e;)i=t.charCodeAt(e),128>i?(r+=String.fromCharCode(i),e++):i>191&&224>i?(s=t.charCodeAt(e+1),r+=String.fromCharCode((31&i)<<6|63&s),e+=2):(s=t.charCodeAt(e+1),n=t.charCodeAt(e+2),r+=String.fromCharCode((15&i)<<12|(63&s)<<6|63&n),e+=3);return r}static v(t){let r,e,i,s,n,h,a,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u="",l=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");t.length>l;)s=o.indexOf(t.charAt(l++)),n=o.indexOf(t.charAt(l++)),h=o.indexOf(t.charAt(l++)),a=o.indexOf(t.charAt(l++)),r=s<<2|n>>4,e=(15&n)<<4|h>>2,i=(3&h)<<6|a,u+=String.fromCharCode(r),64!=h&&(u+=String.fromCharCode(e)),64!=a&&(u+=String.fromCharCode(i));return u=this.D(u),u}static shuffle(t){if(Array.isArray(t)){let r=t.concat();return r.sort((()=>.5-Math.random())),r}}static filterDifferentValue(t,r){let e=[];return e=t.filter((t=>-1!==r.indexOf(t))),e}static checkIsLowPhone(){if(window.wx){let t=-1;const r=window.wx.getSystemInfoSync();if(r.system.indexOf("iOS")>=0){const e=r.model,i=["iPhone1,1","iPhone1,2","iPhone2,1","iPhone3,1","iPhone3,3","iPhone4,1","iPhone5,1","iPhone5,2","iPhone5,3","iPhone5,4","iPhone6,1","iPhone6,2"],s=["iPhone6,2","iPhone7,1","iPhone7,2","iPhone8,1","iPhone8,2","iPhone8,4"],n=["iPhone9,1","iPhone9,2","iPhone9,3","iPhone9,4","iPhone10,1","iPhone10,2","iPhone10,3","iPhone10,4","iPhone10,5","iPhone10,6","iPhone XS"],h=["iPhone11,2","iPhone11,4","iPhone11,6","iPhone11,8","iPhone12,1","iPhone12,3","iPhone12,5","iPhone12,8","iPhone 13","iPhone 14"];for(let r=0;i.length>r;r++)0>e.indexOf(i[r])||(t=5);for(let r=0;s.length>r;r++)0>e.indexOf(s[r])||(t=10);for(let r=0;n.length>r;r++)0>e.indexOf(n[r])||(t=20);for(let r=0;h.length>r;r++)0>e.indexOf(h[r])||(t=30)}else t=r.benchmarkLevel;return 20>t}return!1}static getRandomItemFromArray(t){return t[Math.floor(Math.random()*t.length)]}static parseStringData(t,r="#"){return t.split(r).map((t=>Number(t)))}static toFixed(t,r=2){return Number(t.toFixed(r))}static getTwoPosXZRadius(t,r,e,i){return Math.atan2(t-e,r-i)}static getTwoPosXZLength(t,r,e,i){const s=t-e,n=r-i;return Math.sqrt(s*s+n*n)}static getRandomDirector(){return Math.random()>.5?1:-1}static toFixedPercent(t,r=2){if(isNaN(t)||isNaN(r)||0>r)return"";const e=(100*t).toFixed(r),i=e.split(".");return r>0&&1===i.length?`${i[0]}.${"0".repeat(r)}%`:r>0&&r>i[1].length?`${i[0]}.${i[1].padEnd(r,"0")}%`:e+"%"}}o.errorCode={"1001_err":"解码出现异常","1002_err":"协议号{0}不存在","1003_err":"服务器异常","1004_err":"渠道[{0}]不能登录服务器","1005_err":"请求次数受到限制","1006_err":"操作过于频烦","1007_err":"钻石不足","1008_err":"系统错误","1009_err":"非法操作","1010_err":"参数有错","1011_err":"请先验证登录服务器","1012_err":"请先重新登录游戏","1013_err":"玩家不存在","1014_err":"系统时间不能往回修改","1015_err":"金币不足","1016_err":"体力不足","1021_err":"激活码不存在","1022_err":"激活码已使用","1023_err":"玩家已领取过该类型礼包码","1024_err":"激活码未开放","1025_err":"激活码关闭领取","4001_err":"您已经被禁止发言,结束时间:{0}","4002_err":"{0}需要{1}等级才开放","4003_err":"聊天内容为空","4004_err":"聊天内容不能超出{0}个字符"};class u{static md5(t){let r,e,i,s,n,h,a,o,u,l,c=this;for(t=c.Utf8Encode(t),r=c.ConvertToWordArray(t),a=1732584193,o=4023233417,u=2562383102,l=271733878,e=0;r.length>e;e+=16)i=a,s=o,n=u,h=l,a=c.FF(a,o,u,l,r[e+0],7,3614090360),l=c.FF(l,a,o,u,r[e+1],12,3905402710),u=c.FF(u,l,a,o,r[e+2],17,606105819),o=c.FF(o,u,l,a,r[e+3],22,3250441966),a=c.FF(a,o,u,l,r[e+4],7,4118548399),l=c.FF(l,a,o,u,r[e+5],12,1200080426),u=c.FF(u,l,a,o,r[e+6],17,2821735955),o=c.FF(o,u,l,a,r[e+7],22,4249261313),a=c.FF(a,o,u,l,r[e+8],7,1770035416),l=c.FF(l,a,o,u,r[e+9],12,2336552879),u=c.FF(u,l,a,o,r[e+10],17,4294925233),o=c.FF(o,u,l,a,r[e+11],22,2304563134),a=c.FF(a,o,u,l,r[e+12],7,1804603682),l=c.FF(l,a,o,u,r[e+13],12,4254626195),u=c.FF(u,l,a,o,r[e+14],17,2792965006),o=c.FF(o,u,l,a,r[e+15],22,1236535329),a=c.GG(a,o,u,l,r[e+1],5,4129170786),l=c.GG(l,a,o,u,r[e+6],9,3225465664),u=c.GG(u,l,a,o,r[e+11],14,643717713),o=c.GG(o,u,l,a,r[e+0],20,3921069994),a=c.GG(a,o,u,l,r[e+5],5,3593408605),l=c.GG(l,a,o,u,r[e+10],9,38016083),u=c.GG(u,l,a,o,r[e+15],14,3634488961),o=c.GG(o,u,l,a,r[e+4],20,3889429448),a=c.GG(a,o,u,l,r[e+9],5,568446438),l=c.GG(l,a,o,u,r[e+14],9,3275163606),u=c.GG(u,l,a,o,r[e+3],14,4107603335),o=c.GG(o,u,l,a,r[e+8],20,1163531501),a=c.GG(a,o,u,l,r[e+13],5,2850285829),l=c.GG(l,a,o,u,r[e+2],9,4243563512),u=c.GG(u,l,a,o,r[e+7],14,1735328473),o=c.GG(o,u,l,a,r[e+12],20,2368359562),a=c.HH(a,o,u,l,r[e+5],4,4294588738),l=c.HH(l,a,o,u,r[e+8],11,2272392833),u=c.HH(u,l,a,o,r[e+11],16,1839030562),o=c.HH(o,u,l,a,r[e+14],23,4259657740),a=c.HH(a,o,u,l,r[e+1],4,2763975236),l=c.HH(l,a,o,u,r[e+4],11,1272893353),u=c.HH(u,l,a,o,r[e+7],16,4139469664),o=c.HH(o,u,l,a,r[e+10],23,3200236656),a=c.HH(a,o,u,l,r[e+13],4,681279174),l=c.HH(l,a,o,u,r[e+0],11,3936430074),u=c.HH(u,l,a,o,r[e+3],16,3572445317),o=c.HH(o,u,l,a,r[e+6],23,76029189),a=c.HH(a,o,u,l,r[e+9],4,3654602809),l=c.HH(l,a,o,u,r[e+12],11,3873151461),u=c.HH(u,l,a,o,r[e+15],16,530742520),o=c.HH(o,u,l,a,r[e+2],23,3299628645),a=c.II(a,o,u,l,r[e+0],6,4096336452),l=c.II(l,a,o,u,r[e+7],10,1126891415),u=c.II(u,l,a,o,r[e+14],15,2878612391),o=c.II(o,u,l,a,r[e+5],21,4237533241),a=c.II(a,o,u,l,r[e+12],6,1700485571),l=c.II(l,a,o,u,r[e+3],10,2399980690),u=c.II(u,l,a,o,r[e+10],15,4293915773),o=c.II(o,u,l,a,r[e+1],21,2240044497),a=c.II(a,o,u,l,r[e+8],6,1873313359),l=c.II(l,a,o,u,r[e+15],10,4264355552),u=c.II(u,l,a,o,r[e+6],15,2734768916),o=c.II(o,u,l,a,r[e+13],21,1309151649),a=c.II(a,o,u,l,r[e+4],6,4149444226),l=c.II(l,a,o,u,r[e+11],10,3174756917),u=c.II(u,l,a,o,r[e+2],15,718787259),o=c.II(o,u,l,a,r[e+9],21,3951481745),a=c.AddUnsigned(a,i),o=c.AddUnsigned(o,s),u=c.AddUnsigned(u,n),l=c.AddUnsigned(l,h);return(c.WordToHex(a)+c.WordToHex(o)+c.WordToHex(u)+c.WordToHex(l)).toUpperCase()}static RotateLeft(t,r){return t<<r|t>>>32-r}static AddUnsigned(t,r){let e,i,s,n,h;return s=2147483648&t,n=2147483648&r,e=1073741824&t,i=1073741824&r,h=(1073741823&t)+(1073741823&r),e&i?2147483648^h^s^n:e|i?1073741824&h?3221225472^h^s^n:1073741824^h^s^n:h^s^n}static F(t,r,e){return t&r|~t&e}static G(t,r,e){return t&e|r&~e}static H(t,r,e){return t^r^e}static I(t,r,e){return r^(t|~e)}static FF(t,r,e,i,s,n,h){let a=this;return t=a.AddUnsigned(t,a.AddUnsigned(a.AddUnsigned(a.F(r,e,i),s),h)),a.AddUnsigned(a.RotateLeft(t,n),r)}static GG(t,r,e,i,s,n,h){let a=this;return t=a.AddUnsigned(t,a.AddUnsigned(a.AddUnsigned(a.G(r,e,i),s),h)),a.AddUnsigned(a.RotateLeft(t,n),r)}static HH(t,r,e,i,s,n,h){let a=this;return t=a.AddUnsigned(t,a.AddUnsigned(a.AddUnsigned(a.H(r,e,i),s),h)),a.AddUnsigned(a.RotateLeft(t,n),r)}static II(t,r,e,i,s,n,h){let a=this;return t=a.AddUnsigned(t,a.AddUnsigned(a.AddUnsigned(a.I(r,e,i),s),h)),a.AddUnsigned(a.RotateLeft(t,n),r)}static ConvertToWordArray(t){let r,e=t.length,i=e+8,s=16*((i-i%64)/64+1),n=Array(s-1),h=0,a=0;for(;e>a;)r=(a-a%4)/4,h=a%4*8,n[r]=n[r]|t.charCodeAt(a)<<h,a++;return r=(a-a%4)/4,h=a%4*8,n[r]=n[r]|128<<h,n[s-2]=e<<3,n[s-1]=e>>>29,n}static WordToHex(t){let r,e,i="",s="";for(e=0;3>=e;e++)r=t>>>8*e&255,s="0"+r.toString(16),i+=s.substr(s.length-2,2);return i}static Utf8Encode(t){let r="";for(let e=0;t.length>e;e++){let i=t.charCodeAt(e);128>i?r+=String.fromCharCode(i):i>127&&2048>i?(r+=String.fromCharCode(i>>6|192),r+=String.fromCharCode(63&i|128)):(r+=String.fromCharCode(i>>12|224),r+=String.fromCharCode(i>>6&63|128),r+=String.fromCharCode(63&i|128))}return r}}const l="input is invalid type",c="0123456789abcdef".split(""),f=[-2147483648,8388608,32768,128],d=[24,16,8,0];class g{constructor(t){if(this.lastByteIndex=null,t){var r=[];r[0]=r[16]=r[1]=r[2]=r[3]=r[4]=r[5]=r[6]=r[7]=r[8]=r[9]=r[10]=r[11]=r[12]=r[13]=r[14]=r[15]=0,this.blocks=r}else this.blocks=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.h0=1732584193,this.h1=4023233417,this.h2=2562383102,this.h3=271733878,this.h4=3285377520,this.block=this.start=this.bytes=this.hBytes=0,this.finalized=this.hashed=!1,this.first=!0}update(t){if(this.finalized)throw Error("finalize already called");for(var r,e,i=function(t){var r=typeof t;if("string"===r)return[t,!0];if("object"!==r||null===t)throw Error(l);if(t.constructor===ArrayBuffer)return[new Uint8Array(t),!1];if(!Array.isArray(t)&&!ArrayBuffer.isView(t))throw Error(l);return[t,!1]}(t),s=i[1],n=0,h=(t=i[0]).length||0,a=this.blocks;h>n;){if(this.hashed&&(this.hashed=!1,a[0]=this.block,this.block=a[16]=a[1]=a[2]=a[3]=a[4]=a[5]=a[6]=a[7]=a[8]=a[9]=a[10]=a[11]=a[12]=a[13]=a[14]=a[15]=0),s)for(e=this.start;h>n&&64>e;++n)128>(r=t.charCodeAt(n))?a[e>>>2]|=r<<d[3&e++]:2048>r?(a[e>>>2]|=(192|r>>>6)<<d[3&e++],a[e>>>2]|=(128|63&r)<<d[3&e++]):55296>r||r>=57344?(a[e>>>2]|=(224|r>>>12)<<d[3&e++],a[e>>>2]|=(128|r>>>6&63)<<d[3&e++],a[e>>>2]|=(128|63&r)<<d[3&e++]):(r=65536+((1023&r)<<10|1023&t.charCodeAt(++n)),a[e>>>2]|=(240|r>>>18)<<d[3&e++],a[e>>>2]|=(128|r>>>12&63)<<d[3&e++],a[e>>>2]|=(128|r>>>6&63)<<d[3&e++],a[e>>>2]|=(128|63&r)<<d[3&e++]);else for(e=this.start;h>n&&64>e;++n)a[e>>>2]|=t[n]<<d[3&e++];this.lastByteIndex=e,this.bytes+=e-this.start,64>e?this.start=e:(this.block=a[16],this.start=e-64,this.hash(),this.hashed=!0)}return this.bytes>4294967295&&(this.hBytes+=this.bytes/4294967296|0,this.bytes=this.bytes%4294967296),this}finalize(){if(!this.finalized){this.finalized=!0;var t=this.blocks,r=this.lastByteIndex;t[16]=this.block,t[r>>>2]|=f[3&r],this.block=t[16],56>r||(this.hashed||this.hash(),t[0]=this.block,t[16]=t[1]=t[2]=t[3]=t[4]=t[5]=t[6]=t[7]=t[8]=t[9]=t[10]=t[11]=t[12]=t[13]=t[14]=t[15]=0),t[14]=this.hBytes<<3|this.bytes>>>29,t[15]=this.bytes<<3,this.hash()}}hash(){var t,r,e=this.h0,i=this.h1,s=this.h2,n=this.h3,h=this.h4,a=this.blocks;for(t=16;80>t;++t)a[t]=(r=a[t-3]^a[t-8]^a[t-14]^a[t-16])<<1|r>>>31;for(t=0;20>t;t+=5)e=(r=(i=(r=(s=(r=(n=(r=(h=(r=e<<5|e>>>27)+(i&s|~i&n)+h+1518500249+a[t]|0)<<5|h>>>27)+(e&(i=i<<30|i>>>2)|~e&s)+n+1518500249+a[t+1]|0)<<5|n>>>27)+(h&(e=e<<30|e>>>2)|~h&i)+s+1518500249+a[t+2]|0)<<5|s>>>27)+(n&(h=h<<30|h>>>2)|~n&e)+i+1518500249+a[t+3]|0)<<5|i>>>27)+(s&(n=n<<30|n>>>2)|~s&h)+e+1518500249+a[t+4]|0,s=s<<30|s>>>2;for(;40>t;t+=5)e=(r=(i=(r=(s=(r=(n=(r=(h=(r=e<<5|e>>>27)+(i^s^n)+h+1859775393+a[t]|0)<<5|h>>>27)+(e^(i=i<<30|i>>>2)^s)+n+1859775393+a[t+1]|0)<<5|n>>>27)+(h^(e=e<<30|e>>>2)^i)+s+1859775393+a[t+2]|0)<<5|s>>>27)+(n^(h=h<<30|h>>>2)^e)+i+1859775393+a[t+3]|0)<<5|i>>>27)+(s^(n=n<<30|n>>>2)^h)+e+1859775393+a[t+4]|0,s=s<<30|s>>>2;for(;60>t;t+=5)e=(r=(i=(r=(s=(r=(n=(r=(h=(r=e<<5|e>>>27)+(i&s|i&n|s&n)+h-1894007588+a[t]|0)<<5|h>>>27)+(e&(i=i<<30|i>>>2)|e&s|i&s)+n-1894007588+a[t+1]|0)<<5|n>>>27)+(h&(e=e<<30|e>>>2)|h&i|e&i)+s-1894007588+a[t+2]|0)<<5|s>>>27)+(n&(h=h<<30|h>>>2)|n&e|h&e)+i-1894007588+a[t+3]|0)<<5|i>>>27)+(s&(n=n<<30|n>>>2)|s&h|n&h)+e-1894007588+a[t+4]|0,s=s<<30|s>>>2;for(;80>t;t+=5)e=(r=(i=(r=(s=(r=(n=(r=(h=(r=e<<5|e>>>27)+(i^s^n)+h-899497514+a[t]|0)<<5|h>>>27)+(e^(i=i<<30|i>>>2)^s)+n-899497514+a[t+1]|0)<<5|n>>>27)+(h^(e=e<<30|e>>>2)^i)+s-899497514+a[t+2]|0)<<5|s>>>27)+(n^(h=h<<30|h>>>2)^e)+i-899497514+a[t+3]|0)<<5|i>>>27)+(s^(n=n<<30|n>>>2)^h)+e-899497514+a[t+4]|0,s=s<<30|s>>>2;this.h0=this.h0+e|0,this.h1=this.h1+i|0,this.h2=this.h2+s|0,this.h3=this.h3+n|0,this.h4=this.h4+h|0}hex(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3,s=this.h4;return c[t>>>28&15]+c[t>>>24&15]+c[t>>>20&15]+c[t>>>16&15]+c[t>>>12&15]+c[t>>>8&15]+c[t>>>4&15]+c[15&t]+c[r>>>28&15]+c[r>>>24&15]+c[r>>>20&15]+c[r>>>16&15]+c[r>>>12&15]+c[r>>>8&15]+c[r>>>4&15]+c[15&r]+c[e>>>28&15]+c[e>>>24&15]+c[e>>>20&15]+c[e>>>16&15]+c[e>>>12&15]+c[e>>>8&15]+c[e>>>4&15]+c[15&e]+c[i>>>28&15]+c[i>>>24&15]+c[i>>>20&15]+c[i>>>16&15]+c[i>>>12&15]+c[i>>>8&15]+c[i>>>4&15]+c[15&i]+c[s>>>28&15]+c[s>>>24&15]+c[s>>>20&15]+c[s>>>16&15]+c[s>>>12&15]+c[s>>>8&15]+c[s>>>4&15]+c[15&s]}toString(){return this.hex()}digest(){this.finalize();var t=this.h0,r=this.h1,e=this.h2,i=this.h3,s=this.h4;return[t>>>24&255,t>>>16&255,t>>>8&255,255&t,r>>>24&255,r>>>16&255,r>>>8&255,255&r,e>>>24&255,e>>>16&255,e>>>8&255,255&e,i>>>24&255,i>>>16&255,i>>>8&255,255&i,s>>>24&255,s>>>16&255,s>>>8&255,255&s]}array(){return this.digest()}arrayBuffer(){this.finalize();var t=new ArrayBuffer(20),r=new DataView(t);return r.setUint32(0,this.h0),r.setUint32(4,this.h1),r.setUint32(8,this.h2),r.setUint32(12,this.h3),r.setUint32(16,this.h4),t}}function m(t,r=2){return("0".repeat(r)+t).slice(-r)}class M{constructor(){this._=0,this.N=0,this.tmp=new Date}toString(){let t=this.tmp,r=this.N;return t.setTime(r||this._),`[${m(t.getFullYear())}-${m(t.getMonth())+1}-${m(t.getDate())} ${m(t.getHours())}:${m(t.getMinutes())}:${m(t.getSeconds())}:${m(t.getMilliseconds())} ${r?"ST":"LT"}]`}setServerTime(t){this._=Date.now(),this.N=t}}const y={};var P,v={},w={};!function(t){t.NO_NETWORK="http_request_no_network",t.UNKNOWN_ERROR="http_request_unknown_error",t.TIMEOUT="http_request_timout"}(P||(P={}));class S{constructor(){this.isSucc=!1}}class p{constructor(){this.server="http://127.0.0.1/",this.timeout=1e4,this.header=new Map}static genHttpParam(t,r){const e=Object.assign({cmd:t,randnum:Date.now()+Math.floor(1e3*Math.random())},r),i=Object.keys(e).sort().reduce(((t,r)=>t+""+e[r]),"");return e.key=u.md5(i),e}addHeader(t,r){this.header.set(t,r)}get(t,r,e=null){this.sendRequest(t,e,!1,r)}getAsync(t,r=null){return new Promise(((e,i)=>{this.sendRequest(t,r,!1,(t=>{e(t)}))}))}getByArraybuffer(t,r,e=null){this.sendRequest(t,e,!1,r,"arraybuffer",!1)}getAsyncByArraybuffer(t,r=null){return new Promise(((e,i)=>{this.sendRequest(t,r,!1,(t=>{e(t)}),"arraybuffer",!1)}))}post(t,r,e=null){this.sendRequest(t,e,!0,r)}postAsync(t,r=null){return new Promise(((e,i)=>{this.sendRequest(t,r,!0,(t=>{e(t)}))}))}abort(t){var r=v[this.server+t];r&&r.abort()}getParamString(t){var r="";for(var e in t){let s=t[e];if(s instanceof Object)for(var i in s)r+=`${i}=${s[i]}&`;else r+=`${e}=${s}&`}return r.substring(0,r.length-1)}sendRequest(t,r,e,i,s,n=!0){var h,a,o="";if(h=0==t.toLocaleLowerCase().indexOf("http")?t:this.server+t,r?(o=this.getParamString(r),a=h.indexOf("?")>-1?h+"&"+o:h+"?"+o):a=h,null==v[a]||w[a]!=o){var u=new XMLHttpRequest;v[a]=u,w[a]=o,e?u.open("POST",h):u.open("GET",a);for(const[t,r]of this.header)u.setRequestHeader(t,r);var l={};l.url=h,l.params=r,n&&(u.timeout=this.timeout,u.ontimeout=()=>{this.deleteCache(a),c.isSucc=!1,c.err=P.TIMEOUT,i(l)});var c=new S;u.onloadend=()=>{500==u.status&&(this.deleteCache(a),c.isSucc=!1,c.err=P.NO_NETWORK,i(c))},u.onerror=()=>{this.deleteCache(a),c.isSucc=!1,c.err=0==u.readyState||1==u.readyState||0==u.status?P.NO_NETWORK:P.UNKNOWN_ERROR,i(c)},u.onreadystatechange=()=>{4==u.readyState&&(this.deleteCache(a),200==u.status&&i&&(c.isSucc=!0,"arraybuffer"==s?(u.responseType=s,c.res=u.response):c.res=JSON.parse(u.response),i(c)))},null==r||""==r?u.send():u.send(o)}}deleteCache(t){delete v[t],delete w[t]}}class b{static get requestIns(){return this.T||(this.T=new p),this.T}static genHttpParam(t,r){const e=Object.assign({cmd:t,randnum:Date.now()+Math.floor(1e3*Math.random())},r),i=Object.keys(e).sort().reduce(((t,r)=>t+""+e[r]),"");return e.key=u.md5(i),e}static get(t,r,e){this.requestIns.get(t,(t=>{t.isSucc&&r(t.res)}),e)}}b.T=null;export{o as CommonUtil,s as EventDispatcher,e as Handler,P as HttpEvent,p as HttpRequest,S as HttpReturn,b as HttpUtils,M as LoggerClock,u as Md5Util,t as PromiseEx,g as SHA1,r as Singleton,a as State,n as StateHistoryManager,h as StateMachine,y as logger};