cc1-js 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # cc1-js
2
+ 对js封装的一系列工具,简介如下,详细实现方法可在文件dist/index.d.ts中查看
3
+
4
+ ## Base64Util
5
+ ```bash
6
+ base64加解密工具
7
+ ```
8
+ ## IFrameUtil
9
+ ```bash
10
+ iframe简单通讯工具
11
+ ```
12
+
13
+ ## JSONUtil
14
+ ```bash
15
+ JSON序列化工具
16
+ ```
17
+
18
+ ## MathUtil
19
+ ```bash
20
+ 数学工具
21
+ ```
22
+
23
+ ## MsgUtil
24
+ ```bash
25
+ 消息提示工具
26
+ ```
27
+
28
+ ## StrUtil
29
+ ```bash
30
+ 字符串工具
31
+ ```
32
+ ## ArrayUtil
33
+ ```bash
34
+ 数组操作工具
35
+ ```
36
+ ## DomUtil
37
+ ```bash
38
+ dom工具
39
+ ```
40
+
41
+
42
+ ## Timer
43
+ ```bash
44
+ 定时器
45
+ ```
46
+
47
+ ## CEvent
48
+ ```bash
49
+ 全局事件管理
50
+ ```
51
+ ## CEventBean
52
+ ```bash
53
+ 事件管理对象
54
+ ```
55
+
56
+ ## 其他实现
57
+ ```bash
58
+ 对原生Date、Array、DomRect、Function、Map一系列扩展
59
+ ```
package/dist/cc1-js.js ADDED
@@ -0,0 +1 @@
1
+ !function(){"use strict";class t{}t.swapArray=(t,e,r)=>(t[e]=t.splice(r,1,t[e])[0],t),t.zIndexUp=(e,r)=>{0!=r&&t.swapArray(e,r,r-1)},t.zIndexDown=(e,r)=>{r+1!=e.length&&t.swapArray(e,r,r+1)},t.zIndexTop=(e,r)=>{if(0!=r)for(var n=r-0,o=0;o<n;o++)t.swapArray(e,r,r-1),r--},t.zIndexBottom=(e,r)=>{if(r+1!=e.length)for(var n=e.length-1-r,o=0;o<n;o++)t.swapArray(e,r,r+1),r++},t.diff=(t,e)=>t.filter(t=>-1===e.indexOf(t));class e{static doCheck(t){var e;if("string"!=typeof t||!t)return!1;const r=t.replace(/[\r\n\s]/g,"");if(r.length%4!=0)return!1;if(!/^[A-Za-z0-9+/]*={0,2}$/.test(r))return!1;const n=(null===(e=r.match(/=+$/))||void 0===e?void 0:e[0].length)||0;return!(n>2)&&!(n>0&&!new RegExp(`^[A-Za-z0-9+/]+={${n}}$`).test(r))}}e._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e.encode=t=>{let r,n,o,s,a,i,l,c="",d=0;for(t=e._utf8_encode(t);d<t.length;)r=t.charCodeAt(d++),n=t.charCodeAt(d++),o=t.charCodeAt(d++),s=r>>2,a=(3&r)<<4|n>>4,i=(15&n)<<2|o>>6,l=63&o,isNaN(n)?i=l=64:isNaN(o)&&(l=64),c=c+e._keyStr.charAt(s)+e._keyStr.charAt(a)+e._keyStr.charAt(i)+e._keyStr.charAt(l);return c},e.decode=t=>{let r,n,o,s,a,i,l,c="",d=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");d<t.length;)s=e._keyStr.indexOf(t.charAt(d++)),a=e._keyStr.indexOf(t.charAt(d++)),i=e._keyStr.indexOf(t.charAt(d++)),l=e._keyStr.indexOf(t.charAt(d++)),r=s<<2|a>>4,n=(15&a)<<4|i>>2,o=(3&i)<<6|l,c+=String.fromCharCode(r),64!=i&&(c+=String.fromCharCode(n)),64!=l&&(c+=String.fromCharCode(o));return c=e._utf8_decode(c),c},e._utf8_encode=t=>{t=t.replace(/\r\n/g,"\n");let e="";for(let r=0;r<t.length;r++){let n=t.charCodeAt(r);n<128?e+=String.fromCharCode(n):n>127&&n<2048?(e+=String.fromCharCode(n>>6|192),e+=String.fromCharCode(63&n|128)):(e+=String.fromCharCode(n>>12|224),e+=String.fromCharCode(n>>6&63|128),e+=String.fromCharCode(63&n|128))}return e},e._utf8_decode=t=>{let e="",r=0,n=0,o=0;for(;r<t.length;)if(n=t.charCodeAt(r),n<128)e+=String.fromCharCode(n),r++;else if(n>191&&n<224)o=t.charCodeAt(r+1),e+=String.fromCharCode((31&n)<<6|63&o),r+=2;else{o=t.charCodeAt(r+1);let s=t.charCodeAt(r+2);e+=String.fromCharCode((15&n)<<12|(63&o)<<6|63&s),r+=3}return e};class r{static uint8ArrayToString(t){for(var e="",r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e}static stringToUint8Array(t){for(var e=[],r=0;r<t.length;r++)e.push(t.charCodeAt(r));return new Uint8Array(e)}}r.byteToString=t=>{if("string"==typeof t)return t;for(var e="",r=t,n=0;n<r.length;n++){var o=r[n].toString(2),s=o.match(/^1+?(?=0)/);if(s&&8==o.length){for(var a=s[0].length,i=r[n].toString(2).slice(7-a),l=1;l<a;l++)i+=r[l+n].toString(2).slice(2);e+=String.fromCharCode(parseInt(i,2)),n+=a-1}else e+=String.fromCharCode(r[n])}return e},r.stringToByte=t=>{var e,r,n=new Array;e=t.length;for(var o=0;o<e;o++)(r=t.charCodeAt(o))>=65536&&r<=1114111?(n.push(r>>18&7|240),n.push(r>>12&63|128),n.push(r>>6&63|128),n.push(63&r|128)):r>=2048&&r<=65535?(n.push(r>>12&15|224),n.push(r>>6&63|128),n.push(63&r|128)):r>=128&&r<=2047?(n.push(r>>6&31|192),n.push(63&r|128)):n.push(255&r);return n};class n{}n.id=1e3,n.getId=()=>"_CEvent_"+n.id++,n.map={},n.add=t=>{n.map[t.id]=t},n.remove=(...t)=>{const e=n;t.forEach(t=>{e.map[t]&&(e.map[t].clear(),e.map[t]=null,delete e.map[t])})};class o{constructor(){this.vm=()=>()=>!0,this.eventMap=new Map,this.id=n.getId(),this.tag="__CEventBean__",this.on=(t,e,r)=>{let o=this;if(!r){const t=o.vm();r=()=>t()}let s=o.tag+n.getId(),a=o.eventMap.get(t);return a||(a=[]),a.push({callback:e,vm:r,uid:s,key:t}),o.eventMap.set(t,a),s},this.once=(t,e,r)=>{let n=this,o="";return o=n.on(t,t=>{e(t),n.off(o)},r),o},this.emit=(t,e={},r=!0)=>{let o=this;r?Object.keys(n.map).forEach(r=>{n.map[r].emit(t,e,!1)}):o.eventMap.forEach(r=>{r.forEach(r=>{if(r.key===t){const t=r.vm();if(![1,0,!0,!1].includes(t))return;t?r.callback(e):(o.off(r.uid),n.remove(o.id))}})})},this.off=(...t)=>{let e=this;if(2===t.length){const r=t[0],n=t[1];if("function"==typeof n){const t=e.eventMap.get(r);if(t){let o=t.filter(t=>t.callback!==n);0==o.length?e.eventMap.delete(r):e.eventMap.set(r,o)}return}}let r=[],n=[];t.forEach(t=>{-1!==t.indexOf(e.tag)?r.push(t):n.push(t)}),r.length>0&&e.eventMap.forEach((t,n)=>{let o=t.filter(t=>!r.includes(t.uid));0==o.length?e.eventMap.delete(n):e.eventMap.set(n,o)}),n.forEach(t=>{e.eventMap.delete(t)})},this.clear=()=>{this.eventMap=new Map},n.add(this)}}class s{static on(t,e,r){return s.eventbean.on(t,e,r)}static once(t,e,r){return s.eventbean.once(t,e,r)}static emit(t,e={},r=!0){return s.eventbean.emit(t,e,r)}static off(...t){return s.eventbean.off(...t)}static clear(){return s.eventbean.clear()}}s.eventbean=new o;class a{}a.setValue=t=>{if(t&&"string"!=typeof t)try{t=JSON.stringify(t)}catch(t){}return t},a.getValue=t=>{if("string"==typeof t)if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(t)}catch(t){}else if(!isNaN(Number(t)))return Number(t);return t};class i{static set(t,e,r){var n,o;e=a.setValue(e),null===(n=i.localStorage)||void 0===n||n.setItem(t,e),(r=r||{}).expire||(r.expire=24*i.expire*60*60);const s=Date.now()+r.expire*this.expireUnit;null===(o=i.localStorage)||void 0===o||o.setItem(t+"_expire",s+"")}static get(t){var e,r;const n=null===(e=i.localStorage)||void 0===e?void 0:e.getItem(t+"_expire");if(n&&Date.now()>Number(n))return this.remove(t),this.remove(t+"_expire"),null;let o=null===(r=i.localStorage)||void 0===r?void 0:r.getItem(t);return o=a.getValue(o),o}static remove(t){var e;null===(e=i.localStorage)||void 0===e||e.removeItem(t)}static clear(){i.localStorage.clear()}}i.localStorage=localStorage,i.expire=3600,i.expireUnit=1e3;class l{static set(t,e,r){e=a.setValue(e);let n=t+"="+encodeURIComponent(e);if(n+="; path="+((null==r?void 0:r.path)?null==r?void 0:r.path:"/"),!(null==r?void 0:r.session)){let t="";if(null==r?void 0:r.expire)t=new Date(Date.now()+r.expire*this.expireUnit).toUTCString();else{let e=new Date;e.setDate(e.getDate()+this.expire),t=e.toUTCString()}n+="; expires="+t}r&&r.domain&&(n+="; domain="+r.domain),document.cookie=n}static get(t){const e=t+"=",r=document.cookie.split(";");for(const t of r){const r=t.trim();if(0===r.indexOf(e)){let t=decodeURIComponent(r.substring(e.length,r.length));return t=a.getValue(t),t}}return null}static remove(t,e){this.set(t,"",{domain:e,expire:-1})}static clear(t=["/"],e=""){document.cookie.split(";").forEach(r=>{const n=r.indexOf("="),o=n>-1?r.substr(0,n):r;t.forEach(t=>{const r=e?`;domain=${e}`:"";document.cookie=`${o}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=${t}${r}`})})}}l.expire=3600,l.expireUnit=1e3;class c{static moveDiv(t,e){const r=(t,e)=>{let r=parseFloat(t.split("px")[0]);return void 0!==e&&(r=parseFloat(r.toFixed(e))),r};t.style.position="absolute",t.style.width=t.offsetWidth+"px",t.style.height=t.offsetHeight+"px",t.style.left=t.offsetLeft+"px",t.style.top=t.offsetTop+"px";const n={start:!1,x:0,y:0};t.onmousedown=e=>{if(0===e.button){if("none"===t.style.pointerEvents)return;n.start=!0,n.x=e.x,n.y=e.y,document.onmousemove=e=>{if(n.start){const o=t.getBoundingClientRect().width/t.offsetWidth;let s=e.x-n.x,a=e.y-n.y;s/=o,a/=o;const i=r(t.style.top)+a,l=r(t.style.left)+s;t.style.top=i+"px",t.style.left=l+"px",n.x=e.x,n.y=e.y}}}},t.onmousemove=()=>{t.style.cursor="move"},t.onmouseup=o=>{const s=r(t.style.top,0),a=r(t.style.left,0),i=r(t.style.width,0),l=r(t.style.height,0);t.style.top=s+"px",t.style.left=a+"px",t.style.width=i+"px",t.style.height=l+"px",n.start=!1,n.x=0,n.y=0,document.onmousemove=null,e&&e({left:a,top:s})}}static getScrollbarWidth(){const t=document.createElement("div");t.style.cssText="width: 99px; height: 99px; overflow: scroll; position: absolute; top: -9999px;",document.body.appendChild(t);const e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e}}c.listenerVm=t=>{},c.listener=(t,e,r)=>{t.addEventListener(e,r);const n=()=>t.removeEventListener(e,r);return c.listenerVm(n),{remove:n}},c.useTouch=()=>{const t={startX:-1,startY:-1,deltaX:0,deltaY:0,offsetX:0,offsetY:0,direction:"",startTime:0,endTime:0,moveX:0,moveOffsetX:0,moveY:0,moveOffsetY:0};const e=()=>{t.startX=-1,t.startY=-1,t.deltaX=0,t.deltaY=0,t.offsetX=0,t.offsetY=0,t.direction="",t.endTime=(new Date).getTime()-t.startTime},r=e=>{const r=e,n=void 0!==r.clientX?r.clientX:r.touches[0].clientX,o=void 0!==r.clientY?r.clientY:r.touches[0].clientY;return t.moveOffsetX=n-t.moveX,t.moveOffsetY=o-t.moveY,t.moveX=n,t.moveY=o,{x:n,y:o}};return{getXY:r,move:e=>{const n=r(e);t.deltaX=(n.x<0?0:n.x)-t.startX,t.deltaY=n.y-t.startY,t.offsetX=Math.abs(t.deltaX),t.offsetY=Math.abs(t.deltaY);var o,s;(!t.direction||t.offsetX<10&&t.offsetY<10)&&(t.direction=(o=t.offsetX,s=t.offsetY,o>s?"horizontal":s>o?"vertical":""))},start:n=>{e(),t.startTime=(new Date).getTime();const o=r(n);t.startX=o.x,t.startY=o.y},reset:e,isVertical:()=>"vertical"===t.direction,isHorizontal:()=>"horizontal"===t.direction,conf:t}},c.isTextOverflow=t=>{const e=document.createElement("div"),r=window.getComputedStyle(t);if("nowrap"!==r.whiteSpace)return!1;e.style.cssText=r.cssText,e.style.fontSize=r.fontSize,e.style.padding=r.padding,e.style.position="absolute",e.style.visibility="hidden",e.style.whiteSpace="nowrap",e.style.width="auto",e.style.maxWidth="none",e.style.overflow="visible",e.textContent=t.textContent,document.body.appendChild(e);const n=e.offsetWidth>t.offsetWidth;return document.body.removeChild(e),n};class d{remove(t){const e=this;for(let r=e.length-1;r>=0;r--)"function"==typeof t?t(e[r])&&e.splice(r,1):e[r]===t&&e.splice(r,1)}toSet(t){return void 0===t&&(t=(t,e)=>t===e),this.filter((e,r,n)=>n.findIndex(r=>t(e,r))===r)}randSort(){const t=this;for(var e=0,r=t.length;e<r;e++){var n=parseInt(Math.random()*r+""),o=t[n];t[n]=t[e],t[e]=o}}sum(t){return this.reduce((e,r)=>e+=t?r[t]:r,0)}}class u{static Format(t,e){return Date.Format(this,t,e)}static FormatDiff(t){return Date.FormatDiff(this,t)}static getTimeDiff(){return Date.timeDiff+this.getTime()}}class h{static contains(t,e){const r=this;return r.left<t&&r.top<e&&t<r.left+r.width&&e<r.top+r.height}static containX(t){const e=this;return e.left<t&&t<e.left+e.width}static containY(t){const e=this;return e.top<t&&t<e.top+e.height}}class p{static args(){let t=this.toString();return t=t.substring(t.indexOf("(")+1,t.indexOf("{")).replace(/\s+/g,""),t.substring(0,t.indexOf(")")).split(",").filter(t=>t.length>0)}}class f{static toJson(){const t=this;let e={};for(const r of t)e[r[0]]=r[1];return JSON.stringify(e)}}class m{static init(){Date.formatFail="",Date.Format=(t,e,r)=>{if(!(t instanceof Date)){if(String(t).length<10)return r||Date.formatFail;t=new Date(t)}const n=new Date(t.getTime());e||(e="yyyy-MM-dd hh:mm:ss");var o={"M+":n.getMonth()+1,"d+":n.getDate(),"h+":n.getHours(),"m+":n.getMinutes(),"s+":n.getSeconds(),"q+":Math.floor((n.getMonth()+3)/3),S:n.getMilliseconds()};for(var s in/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(n.getFullYear()+"").substring(4-RegExp.$1.length))),o)new RegExp("("+s+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?o[s]:("00"+o[s]).substring((""+o[s]).length)));return e},Date.FormatDiff=(t,e)=>(t instanceof Date||(t=new Date(t)),Date.Format(t.getTime()+Date.timeDiff,e)),Date.timeDiff=0}}class g{static getClassNames(t){const e={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0,constructor:!0};let r=[],n=Object.getOwnPropertyNames(t);for(let o=0;o<n.length;++o){const s=n[o];e[s]||"function"!=typeof t[s]||r.push(s)}return r}}g.getFunction=t=>{const e=t.name,r=t+"",n=r.indexOf("{"),o=-1!=r.substring(0,n).indexOf("*")?"*":"";return-1!=r.substring(0,n).indexOf("=>")?new Function(`return function${o} ${e} ${r.substring(0,r.indexOf(")")+1)+r.substring(n)}`)():new Function(`return function${o} ${e}${r.substring(r.indexOf("("))}`)()},g.setPrototype=(t,e,r)=>{r=g.getFunction(r),Object.defineProperty(t.prototype,e,{writable:!0,enumerable:!1,value:r})},g.classSetToProperty=(t,e)=>{g.getClassNames(t).forEach(r=>{g.setPrototype(window[e],r,t[r])})},g.iterator=function(){let t=this,e=Object.keys(t),r=0;return"_Vue3ToolIterator"===this._Vue3ToolIterator&&(e=this.keys,t=this.obj),new class{constructor(){return this._Vue3ToolIterator="_Vue3ToolIterator",this.obj=t,this.keys=e,this.next=()=>(r++,{value:r>e.length?null:t[e[r-1]],done:r>this.keys.length}),this}}};class y{static init(){g.classSetToProperty(d.prototype,"Array"),m.init(),g.classSetToProperty(u,"Date"),g.classSetToProperty(p,"Function"),g.classSetToProperty(h,"DOMRect"),g.classSetToProperty(f,"Map")}static setLang(t){this.langObj=t}}var x,v,b;y.langObj={HttpUtil:{0:"请求中断",404:"请求地址不存在",405:"请求方法不允许",500:"请求异常",504:"请求超时",OtherException:"其他异常"},TimeUtil:{Today:"今天",Yesterday:"昨天",ThisWeek:"本周",LastWeek:"上周",ThisMonth:"本月",JustNow:"刚刚"}};class w{}x=w,w.arrToHex=t=>{let e="";return t.forEach(t=>e+=(2^t).toString(16)+"u"),e.substring(0,e.length-1)},w.hexToArr=t=>{let e=[];return t.split("u").forEach(t=>{e.push(2^parseInt((t=>{for(var e,r=t.length,n=new Array(r),o=0;o<r;o++)48<=(e=t.charCodeAt(o))&&e<58?e-=48:e=(223&e)-65+10,n[o]=e;return n.reduce(function(t,e){return 16*t+e},0)})(t)))}),e},w.encode=t=>x.arrToHex(r.stringToByte(t)),w.decode=t=>r.byteToString(x.hexToArr(t));class T{}v=T,T.httpBean=null,T.getFileFun=t=>{const e=v;null==e.httpBean&&(e.httpBean=httpBean());let r={base:"/",outtime:3e4,responseType:"text"};t&&(r=Object.assign(r,t));return t=>(t.startsWith("http")||(t=r.base+t),new Promise(n=>{e.httpBean.get({url:t,timeout:r.outtime,responseType:r.responseType}).then(t=>{n(t)}).catch(()=>{n(void 0)})}))},T.getFile=(t,e)=>v.getFileFun(e)(t);class C{}C.id=0,C.getId=()=>"_Timer_"+C.id++,C.map={},C.add=(t,e,r,n)=>{const o=C,s=o.getId(),a=r?setInterval:setTimeout,i=r?clearInterval:clearTimeout,l=()=>{o.map[s]&&i(c),o.map[s]=void 0,delete o.map[s]},c=a(()=>{const e=n();r&&![1,0,!0,!1].includes(e)||(e?(t(),r||l()):l())},e);return o.map[s]={fun:t,vm:n,id:s,remove:l},o.map[s]},C.remove=(...t)=>{const e=C;t.forEach(t=>{e.map[t]&&e.map[t].remove()})},C.removeAll=()=>{const t=C;t.remove(...Object.keys(t.map))};class M{constructor(){this.map={},this.vm=()=>()=>!0,this.createVM=t=>{if(!t){const e=this.vm();t=()=>e()}return t},this.once=(t,e=0,r)=>{const n=C.add(t,e,!1,this.createVM(r));return this.map[n.id]=n,n.id},this.clear=()=>{const t=this,e=Object.keys(t.map);for(let r=0;r<e.length;r++){const n=e[r],o=t.map[n];o&&o.remove(),t.map[n]=void 0,delete t.map[n]}},this.delayUnit=1,this.delay=(t=0,e=this.delayUnit)=>{const r=this;return new Promise(n=>{r.once(()=>n(),t*e)})},this.on=(t,e,r=!1,n)=>{r&&t();const o=C.add(t,e,!0,this.createVM(n));return this.map[o.id]=o,o.id},this.un=(...t)=>{const e=this;t.forEach(t=>{const r=e.map[t];r&&r.remove(),e.map[t]=void 0,delete e.map[t]})}}}class S{static once(t,e=0,r){return this.timerBean.once(t,e,r)}static async delay(t=0,e=this.delayUnit){await this.timerBean.delay(t,e)}static on(t,e,r=!1,n){return this.timerBean.on(t,e,r,n)}}S.timerBean=new M,S.clear=()=>{C.removeAll()},S.delayUnit=1,S.un=(...t)=>{C.remove(...t)};const O=t=>{let e=t.toString().trim();return e.length>50&&(e=e.substring(0,22)+e.substring(e.length-22,e.length-1)),e};class k{}b=k,k.timer=S,k.debounceMap={},k.debounce=(t,e=500)=>{const r=b,n=O(t);r.debounceMap[n]&&r.timer.un(r.debounceMap[n]),r.debounceMap[n]=r.timer.once(()=>{t(),delete r.debounceMap[n]},e)},k.throttleMap={},k.throttle=(t,e=500,r=b.throttleTip)=>{const n=b,o=O(t);n.throttleMap[o]?r():(t(),n.throttleMap[o]=n.timer.once(()=>{delete n.throttleMap[o]},e))},k.throttleTip=()=>{},k.lockMap={},k.lock=async t=>{const e=b,r=O(t);return e.lockMap[r]||(e.lockMap[r]=new Promise(async(n,o)=>{try{n(await t())}catch(t){o(t)}delete e.lockMap[r]})),await e.lockMap[r]};class j{static rem(){const t=j;let e=document.getElementsByTagName("head")[0].getAttribute("design-width");e||(e=t.remWidth),t.remWidth=e,t.refresh(),window.addEventListener("resize",()=>{t.refresh()});const r=document.createElement("style");r.innerHTML="@media screen and (min-width:"+t.remWidth+"px){.design-box{width:"+t.remWidth+"px !important;position:relative;}",document.getElementsByTagName("head")[0].appendChild(r)}static refresh(){const t=j;let e=t.getDeviceWidth();document.documentElement.style.fontSize=e/(t.remWidth/t.remFontSize)+"px"}static getDeviceWidth(){const t=j;let e=document.documentElement.clientWidth;const r="function"==typeof t.maxWidth?t.maxWidth():t.maxWidth;return e>=r&&(e=r),e}static rem2px(t){const e=j;return t*(e.getDeviceWidth()/e.remWidth)}static px2rem(t){const e=j;let r=e.getDeviceWidth();return t*(e.remWidth/r)}static getMaxBox(){const t=this.remWidth,e=this.remHeight,r=window.innerWidth,n=window.innerHeight,o=e/t,s=n/r;return o>s?{height:n,width:n/o}:this.maxRatio&&s>this.maxRatio?{height:r*this.maxRatio,width:r}:{height:n,width:r}}static getMaxHeight(){return this.getMaxBox().height}static getMaxWidth(){return this.getMaxBox().width}}var D,E;j.remWidth=750,j.maxWidth=500,j.remFontSize=1,j.maxRatio=2.221,j.remHeight=1334;class A{static deepAssign(t,e){const r=D;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return t;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&("object"==typeof e[n]&&null!==e[n]&&"object"==typeof t[n]&&null!==t[n]?r.deepAssign(t[n],e[n]):t[n]=e[n]);return t}static setPathVal(t,e,r,n){null==n&&(e=e.split("."),n=0),n===e.length-1?t[e[n]]=r:(t[e[n]]=t[e[n]]||{},D.setPathVal(t[e[n]],e,r,n+1))}}D=A,A.objectToString=Object.prototype.toString,A.toTypeString=t=>D.objectToString.call(t),A.isArray=Array.isArray,A.isMap=t=>"[object Map]"===D.toTypeString(t),A.isSet=t=>"[object Set]"===D.toTypeString(t),A.isDate=t=>"[object Date]"===D.toTypeString(t),A.isFunction=t=>"function"==typeof t,A.isString=t=>"string"==typeof t,A.isSymbol=t=>"symbol"==typeof t,A.isObject=t=>null!==t&&"object"==typeof t,A.isPromise=t=>D.isObject(t)&&D.isFunction(t.then)&&D.isFunction(t.catch),A.getObject=(t,e)=>{const r=D;let n=!1;if(r.isArray(t))for(let r=0;r<t.length&&(n=D.getObject(t[r],e),!n);r++);else if(r.isObject(t)){const o=Object.keys(t);for(let s=0;s<o.length;s++){const a=o[s],i=t[a];if(n=e(a,i,t),n)break;if((r.isArray(i)||r.isObject(i))&&(n=r.getObject(i,e)),n)break}}return n},A.getObjectByChildren=(t,e,r=["children"])=>{if(Array.isArray(t))for(let n=0;n<t.length;n++)D.getObjectByChildren(t[n],e,r);else if(D.isObject(t)){e(t);for(let n=0;n<r.length;n++)t[r[n]]&&D.getObjectByChildren(t[r[n]],e,r)}},A.deepMerge=(t,e)=>{const r=D,n=Object.assign({},t);for(const o in e)e.hasOwnProperty(o)&&("object"==typeof e[o]&&t.hasOwnProperty(o)&&"object"==typeof t[o]?n[o]=r.deepMerge(t[o],e[o]):n[o]=e[o]);return n},A.getPathValue=(t,e,r)=>{if("object"!=typeof t)return r;const n=e.split(".");let o=t;for(let t=0;t<n.length;t++)try{o=o[n[t]]}catch(t){return r}return o};class F{static uuid(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)})}static isNull(t){return Array.isArray(t)?0==t.length:t+""=="null"||t+""=="undefined"||""===t||t+""=="NaN"}static clearBlank(t){return t?t.replace(/\s+|\t|\r|\n/g,""):""}static isNumber(t){return/^[0-9]+$/.test(t)}static getParam(t){const e=t.match(/[?&]([^=#]+)=([^&#]*)/g);return e?e.reduce((t,e)=>{const[r,n]=e.substring(1).split("=");return t[r]=decodeURIComponent(n),t},{}):{}}static copyText(t){return new Promise(e=>{if(navigator.clipboard)navigator.clipboard.writeText(t).then(()=>{e(!0)}).catch(t=>{e(!1)});else{const r=document.createElement("textarea");r.value=t,document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),e(!0)}})}}E=F,F.id=1e3,F.getId=()=>(E.id++,E.id+"");class W{static init(){const t=(t,e,r)=>{if(e){e.onreadystatechange=null,e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null;try{e.onprogress=null}catch(t){}try{e.upload.onprogress=null,e.upload.onload=null,e.upload.onerror=null,e.upload.onabort=null,e.upload.ontimeout=null,e.upload.onloadend=null,e.upload.onloadstart=null}catch(t){}e=void 0}r&&(t.xhr[r]=void 0,delete t.xhr[r])},e=e=>{const r={dataCache:{},xhr:{},get:(e,n)=>{n||(n={}),"string"==typeof e?e={url:e,method:"GET"}:(e.method=e.method||"GET",e.method=e.method.toUpperCase());const o=e;return new Promise(async(s,a)=>{const i=F.getId(),l=r.config,c=l.base,d=l.before,u=l.after,h=l.error,p={headers:l.headers,data:n,param:o,stop:()=>{f&&(f.abort(),t(r,f,i))}};let f=new XMLHttpRequest;d&&await d(p,f);let m=c+o.url;o.url.startsWith("http")&&(m=o.url),m.startsWith("//")&&(m=m.replace(/(\/{2,})/g,"/"));const g=(t=>{const e={};return Object.keys(t).forEach(r=>{"function"!=typeof t[r]&&(e[r]=t[r])}),e})(p.data);if("GET"===o.method){const t=Object.keys(g).map(t=>`${t}=${encodeURIComponent(g[t])}`).join("&");m=t?`${m}?${t}`:m}const x=m+JSON.stringify(g);0!==o.expire&&void 0!==o.expire||delete r.dataCache[x];let v=r.dataCache[x];if(v){if(v.expire>Date.now())return await u({data:v.data,responseType:o.responseType||l.responseType,status:200,xhr:null},p),void s(v.data);delete r.dataCache[x]}f.open(o.method,m,!0),o.headers&&(p.headers=Object.assign(Object.assign({},p.headers),o.headers)),Object.keys(p.headers).forEach(t=>{const e=p.headers[t];e&&!e.startsWith("multipart/form-data")&&f.setRequestHeader(t,e)}),f.timeout=o.timeout||l.timeout,f.responseType=o.responseType||l.responseType;try{f.withCredentials=o.withCredentials||l.withCredentials}catch(t){}const b=y.langObj.HttpUtil,w=(e,n)=>{var o;h(e,p,n),t(r,f,i),a({status:e,message:null!==(o=b[e+""])&&void 0!==o?o:b.OtherException})};f.ontimeout=function(){w(504)},f.onerror=function(t){w(500)},f.onabort=function(){w(0)};const T=e;if(f.upload&&T.onProgress&&(f.upload.onprogress=function(t){if(t.lengthComputable&&t.total>0){const e=parseInt(t.loaded/t.total*100);T.onProgress(e,t.loaded,t.total)}}),f.onreadystatechange=async function(){if(4===f.readyState){const e={data:f.response,responseType:f.responseType,status:f.status,xhr:f};if(0!==f.status){const t=f.getResponseHeader("Content-Type");if(t&&t.includes("application/json")&&"string"==typeof f.response)try{e.data=JSON.parse(f.response)}catch(t){}}if(200===f.status){if(o.expire){let t=o.expire;t<0&&(t=l.expireMaxTime),r.dataCache[x]={data:e.data,expire:Date.now()+1e3*t}}await u(e,p),200!==e.status?w(e.status):t(r,f,i),s(e.data)}else 0!==f.status&&w(f.status,e)}},"GET"===o.method)f.send();else{const t=p.headers["Content-Type"];if("multipart/form-data"==t){const t=new FormData;let e=0;for(let r in g)g[r]instanceof File?(t.append(r,g[r],g[r].name||r),e+=g[r].size):t.append(r,g[r]);T.onProgress&&T.onProgress(0,0,e),f.send(t)}else"application/x-www-form-urlencoded"==t?f.send(Object.keys(g).map(t=>`${t}=${encodeURIComponent(g[t])}`).join("&")):"application/json"==t?f.send(JSON.stringify(g)):f.send(g)}r.xhr[i]=f})},post:(t,e)=>("string"==typeof t?t={url:t,method:"POST"}:t.method=t.method||"POST",r.get(t,e)),stop:()=>{Object.keys(r.xhr).forEach(e=>{r.xhr[e].abort(),t(r,r.xhr[e])}),r.xhr={}},config:{base:"",timeout:3e4,withCredentials:!1,responseType:"text",expireMaxTime:86400,headers:{Accept:"*","Content-Type":"application/json"},before:()=>{},after:()=>{},error:()=>{}},setConfig:t=>{r.dataCache={},t&&"object"==typeof t&&(r.config=A.deepMerge(r.config,t))}};return r.setConfig(e),r};window.httpBean=e,window.http=e()}static ping(t,e=6e3){return new Promise(r=>{t.endsWith("/")||(t+="/");let n=new Image,o=Date.now();const s=setTimeout(()=>{r(e)},e);n.onerror=function(){clearTimeout(s),r(Date.now()-o)},n.src=t+o})}}class U{}U.sendMessage=(t,e)=>{var r,n;if(e){const n=document.getElementById(e);null===(r=null==n?void 0:n.contentWindow)||void 0===r||r.postMessage(t,"*")}else null===(n=window.parent)||void 0===n||n.postMessage(t)},U.onMassage=t=>{window.addEventListener("message",t)},U.offMassage=t=>{window.removeEventListener("message",t)};class N{static handleSrc(t){const e=Element.prototype.setAttribute;Element.prototype.setAttribute=function(t,r){return"IMG"===this.tagName&&"src"===t.toLowerCase()&&(r=o(r)),e.call(this,t,r)};const r=HTMLImageElement.prototype,n=Object.getOwnPropertyDescriptor(r,"src");function o(e){return t(e)}Object.defineProperty(r,"src",{set(t){return t=o(t),n.set.call(this,t)},get(){return n.get.call(this)},configurable:!0})}}N.loadImage=t=>{if(!(t.extensions||[".png",".jpg",".jpeg",".webp",".gif",".svg"]).some(e=>t.url.endsWith(e)))return;let e=new Image;e.crossOrigin="Anonymous",e.src=t.url;let r=!1;return e.onload=function(){var n;if(r)return;r=!0;const o={dataBase64:"",dataArray:null};if(t.base64||t.arrayBuffer){let r=document.createElement("canvas");const n=r.getContext("2d");r.height=e.height,r.width=e.width,n.drawImage(e,0,0,e.width,e.height);const s=t.url.split(".").pop();t.arrayBuffer&&(o.dataArray=n.getImageData(0,0,e.width,e.height)),t.base64&&(o.dataBase64="gif"===s||"svg"===s?r.toDataURL(`image/${s}`):r.toDataURL(`image/${s}`,t.base64Quality)),r=null}null===(n=t.load)||void 0===n||n.call(t,e,o),e=null},e.onerror=function(){var e;r||(r=!0,null===(e=t.error)||void 0===e||e.call(t))},{img:e,abort:()=>{if(!r){r=!0;try{e.src="",e=null}catch(t){}}}}};class I{static cp(t){try{return JSON.parse(JSON.stringify(t))}catch(t){return null}}static deepClone(t,e=new WeakMap){let r=t;if(null===r)return r;if(r instanceof Date)return new Date(r);if(r instanceof RegExp)return new RegExp(r);if("object"!=typeof r)return r;if(e.get(r))return e.get(r);try{let t=new r.constructor;e.set(r,t);for(let n in r)r.hasOwnProperty(n)&&(t[n]=this.deepClone(r[n],e));return t}catch(t){return r}}}I.strToObject=t=>{Array.isArray(t)?t.forEach(t=>{I.strToObject(t)}):"object"==typeof t&&t&&Object.keys(t).forEach(e=>{const r=t[e];"string"==typeof r&&(r.startsWith("{")||r.startsWith("["))&&(t[e]=JSON.parse(r)),I.strToObject(t[e])})};class B{}function P(t,e=15){return+parseFloat(Number(t).toPrecision(e))}function _(t){const e=t.toString().split(/[eE]/),r=(e[0].split(".")[1]||"").length-+(e[1]||0);return r>0?r:0}function Y(t){if(-1===t.toString().indexOf("e"))return Number(t.toString().replace(".",""));const e=_(t);return e>0?P(Number(t)*Math.pow(10,e)):Number(t)}function L(t){return(...e)=>{const[r,...n]=e;return n.reduce((e,r)=>t(e,r),r)}}B.groupKey=(t,e)=>{let r={};const n={ctrl:"control",esc:"escape"};t=t.map(t=>(t=t.toLocaleLowerCase(),n[t]&&(t=n[t]),t));const o=function(n){if(!n.key)return;const o=n.key.toLocaleLowerCase();if(r[o])return;r[o]=!0;const s=t[t.length-1]===o;let a=!0;for(let e=0;e<t.length-1;e++)if(!r[t[e]]){a=!1;break}s&&a&&e()},s=function(t){if(!t.key)return;const e=t.key.toLocaleLowerCase();r[e]=!1};return document.addEventListener("keydown",o),document.addEventListener("keyup",s),()=>{document.removeEventListener("keydown",o),document.removeEventListener("keyup",s)}};const $=L((t,e)=>{const r=Y(t),n=Y(e),o=_(t)+_(e);return r*n/Math.pow(10,o)}),R=L((t,e)=>{const r=Math.pow(10,Math.max(_(t),_(e)));return($(t,r)+$(e,r))/r}),X=L((t,e)=>{const r=Math.pow(10,Math.max(_(t),_(e)));return($(t,r)-$(e,r))/r}),H=L((t,e)=>{const r=Y(t),n=Y(e);return $(r/n,P(Math.pow(10,_(e)-_(t))))});class V{static getNumber(t,e){let r=parseFloat(t);return r=F.isNull(r)?0:r,e?parseFloat(r.toFixed(e)):r}static getRandomInt(t,e,r,n){const o=(t,e)=>(t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t),s=o(t,e);if(void 0===r||void 0===n)return s;const a=o(r,n);return Number(s+"."+a)}}V.strip=P,V.plus=R,V.minus=X,V.times=$,V.divide=H,V.round=function(t,e){const r=Math.pow(10,e);let n=H(Math.round(Math.abs($(t,r))),r);return t<0&&0!==n&&(n=$(n,-1)),n},V.digitLength=_,V.float2Fixed=Y;class z{static getDateOptions(){const t=y.langObj.TimeUtil,e=[];e.push({label:t.Today,value:z.somedayse(),key:"today"}),e.push({label:t.Yesterday,value:z.somedayse(-1),key:"yesterday"});const r=new Date,n=z.somedayse,o=r.getDay(),s=n(1-o)[0],a=n(7-o)[1],i={label:t.ThisWeek,value:[s,a],key:"thisWeek"};e.push(i);const l=n(1-o-7)[0],c=n(7-o-7)[1],d={label:t.LastWeek,value:[l,c],key:"lastWeek"};e.push(d);const u=new Date;u.setDate(1);const h=n(0,u);u.setMonth(u.getMonth()+1),u.setDate(1),u.setDate(u.getDate()-1);const p=n(0,u),f={label:t.ThisMonth,value:[h[0],p[1]],key:"thisMonth"};return e.push(f),e}}z.countdown=t=>{const e=t=>t<10?`0${t}`:`${t}`;let r=Math.floor(t/1e3);if(r<0)return["00","00","00",0];const n=Math.floor(r/60/60/24),o=Math.floor(r/60/60%24),s=Math.floor(r/60%60),a=r%60;return[e(n),e(o),e(s),e(a),r]},z.somedayse=(t=0,e=new Date)=>{t*=864e5,e.setHours(0,0,0,0);const r=e.getTime()+t;e.setHours(23,59,59,999);return[r,e.getTime()+t]},z.getTimeTip=t=>{const e=y.langObj.TimeUtil,r=new Date,n=new Date(t),o=r.getTime()-t;if(o<6e4)return e.JustNow;if(o<864e5){if(r.Format("dd")==n.Format("dd"))return n.Format("hh:mm")}if(o<1728e5){if(new Date(z.somedayse(-1)[0]).Format("dd")==n.Format("dd"))return e.Yesterday}return r.getFullYear()==n.getFullYear()?n.Format("MM/dd"):n.Format("MM/dd/yyyy")};const J={ArrayUtil:t,Base64Util:e,ByteUtil:r,CEvent:s,CEventBean:o,JSONUtil:I,KeyUtil:B,MathUtil:V,DomUtil:c,EnUtil:w,IFrameUtil:U,StrUtil:F,ScriptUtil:class{static scriptLoad(t){const e=t=>{t.parentNode&&t.parentNode.removeChild(t),t.onload=null,t.onerror=null,t=null},r=document.getElementsByTagName("script")[0]||document.head;let n=document.createElement("script");return n.src=t,r.parentNode.insertBefore(n,r),new Promise(t=>{n.onload=function(){t(!0),e(n)},n.onerror=function(){t(!1),e(n)}})}},TimerBean:M,Timer:S,HttpUtil:W,CookieVal:a,Cookie:i,CookieC:l,FileUtil:T,H5Util:j,ObjectUtil:A,TimeUtil:z,FunUtil:k,ESUtil:y,ImgUtil:N};try{if(!window.CookieL){const t=Object.keys(J);for(let e=0;e<t.length;e++){const r=t[e];window[r]=J[r]}y.init(),W.init(),window.isNull=F.isNull}}catch(t){console.error(t)}}();