UNPKG

jcommon

Version:

JavaScript 常用纯函数工具库

2 lines (1 loc) 35 kB
function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function e(t,e,n,r,o,i,u){try{var a=t[i](u),c=a.value}catch(t){return void n(t)}a.done?e(c):Promise.resolve(c).then(r,o)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,f(r.key),r)}}function o(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=d(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){a=!0,i=t},f:function(){try{u||null==n.return||n.return()}finally{if(a)throw i}}}}function u(t,e,n){return(e=f(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function c(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach((function(e){u(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function s(){s=function(){return e};var t,e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(t,e,n){t[e]=n.value},i="function"==typeof Symbol?Symbol:{},u=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,n){return t[e]=n}}function f(t,e,n,r){var i=e&&e.prototype instanceof y?e:y,u=Object.create(i.prototype),a=new k(r||[]);return o(u,"_invoke",{value:L(t,n,a)}),u}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var d="suspendedStart",v="suspendedYield",p="executing",g="completed",m={};function y(){}function b(){}function w(){}var S={};l(S,u,(function(){return this}));var O=Object.getPrototypeOf,E=O&&O(O(M([])));E&&E!==n&&r.call(E,u)&&(S=E);var x=w.prototype=y.prototype=Object.create(S);function j(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function A(t,e){function n(o,i,u,a){var c=h(t[o],t,i);if("throw"!==c.type){var s=c.arg,l=s.value;return l&&"object"==typeof l&&r.call(l,"__await")?e.resolve(l.__await).then((function(t){n("next",t,u,a)}),(function(t){n("throw",t,u,a)})):e.resolve(l).then((function(t){s.value=t,u(s)}),(function(t){return n("throw",t,u,a)}))}a(c.arg)}var i;o(this,"_invoke",{value:function(t,r){function o(){return new e((function(e,o){n(t,r,e,o)}))}return i=i?i.then(o,o):o()}})}function L(e,n,r){var o=d;return function(i,u){if(o===p)throw Error("Generator is already running");if(o===g){if("throw"===i)throw u;return{value:t,done:!0}}for(r.method=i,r.arg=u;;){var a=r.delegate;if(a){var c=T(a,r);if(c){if(c===m)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===d)throw o=g,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=p;var s=h(e,n,r);if("normal"===s.type){if(o=r.done?g:v,s.arg===m)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=g,r.method="throw",r.arg=s.arg)}}}function T(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,T(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=h(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var u=i.arg;return u?u.done?(n[e.resultName]=u.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):u:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function D(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function N(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(D,this),this.reset(!0)}function M(e){if(e||""===e){var n=e[u];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o<e.length;)if(r.call(e,o))return n.value=e[o],n.done=!1,n;return n.value=t,n.done=!0,n};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return b.prototype=w,o(x,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:b,configurable:!0}),b.displayName=l(w,c,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===b||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,c,"GeneratorFunction")),t.prototype=Object.create(x),t},e.awrap=function(t){return{__await:t}},j(A.prototype),l(A.prototype,a,(function(){return this})),e.AsyncIterator=A,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var u=new A(f(t,n,r,o),i);return e.isGeneratorFunction(n)?u:u.next().then((function(t){return t.done?t.value:u.next()}))},j(x),l(x,c,"Generator"),l(x,u,(function(){return this})),l(x,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},e.values=M,k.prototype={constructor:k,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(N),!e)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var n=this;function o(r,o){return a.type="throw",a.arg=e,n.next=r,o&&(n.method="next",n.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var u=this.tryEntries[i],a=u.completion;if("root"===u.tryLoc)return o("end");if(u.tryLoc<=this.prev){var c=r.call(u,"catchLoc"),s=r.call(u,"finallyLoc");if(c&&s){if(this.prev<u.catchLoc)return o(u.catchLoc,!0);if(this.prev<u.finallyLoc)return o(u.finallyLoc)}else if(c){if(this.prev<u.catchLoc)return o(u.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<u.finallyLoc)return o(u.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var u=i?i.completion:{};return u.type=t,u.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(u)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),N(n),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;N(n)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:M(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}function l(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||d(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}function d(e,n){if(e){if("string"==typeof e)return t(e,n);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?t(e,n):void 0}}var v=function(t,e){var n=c(c({},{filterRuleKey:"",rule:[],sortKey:"",sortOrder:1}),e),r=n.sortKey,o=void 0===r?"":r,u=n.filterRuleKey,a=void 0===u?"":u,s=n.rule,l=void 0===s?[]:s,f=n.sortOrder,h=void 0===f?1:f;if(0===l.length)return t;var d,v={},p=i(t=t.filter((function(t){return!l||-1!==l.indexOf(t[a])})));try{for(p.s();!(d=p.n()).done;){var g=d.value;Object.prototype.hasOwnProperty.call(v,g[a])?v[g[a]].push(g):v[g[a]]=[g]}}catch(t){p.e(t)}finally{p.f()}for(var m in v)v[m]=v[m].sort((function(t,e){return t[o]>e[o]?1*h:-1*h}));for(var y=[],b=0;b<l.length;b++)Object.prototype.hasOwnProperty.call(v,l[b])&&(y=y.concat(v[l[b]]));return y},p=function(t,e){for(var n=[],r=0;r<t;r++){for(var o={},i=0;i<e.length;i++)o[e[i]]=e[i]+String(Math.random()).substr(15);n.push(o)}return n},g=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if("[object Array]"!==Object.prototype.toString.call(t))return console.error("arrByObj 参数错误,请检查:",t),{};var r={};return t.forEach((function(t){r[t[e]]=n?t[n]:t})),r},m=function(t){if(!Array.isArray(t))throw new Error("The first parameter must be an array");return 1==t.length?t:l(new Set(t))},y=function(t,e){var n=new Set(t),r=new Set(e);return[].concat(l(new Set(l(n).filter((function(t){return!r.has(t)})))),l(new Set(l(r).filter((function(t){return!n.has(t)})))))},b=function(t,e){return t.length===e.length&&t.every((function(t){return e.some((function(e){return t===e}))}))&&e.every((function(e){return t.some((function(t){return t===e}))}))},w=function(t){return function(e,n){return e[t].localeCompare(n[t],"zh")}},S=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function(n,r){var o=e?1:-1;return new Date(P(r[t])).getTime()-new Date(P(n[t])).getTime()>0?1*o:-1*o}},O=function(t){return function(e,n){var r=n[t]||0;return"string"==typeof r&&(r=isNaN(Number(r))?0:Number(r)),e+r}},E=function(){var t,e,n,r={name:"other",version:"0"},o=navigator.userAgent.toLowerCase();for(e=[["WeiXin",/micromessenger\/([^\s]+)/],["QQ",/qq\/([^\s]+)/],["QQBrowser",/(?:qqbrowser|qqlivebrowser)\/([^\s]+)/],["JDAPP",/jdapp;/],["QIHU",/qihu|360se/],["LieBao",/(?:lbbrowser|liebaofast)\/?([\d\.]+)?/],["Sogou",/(?:metasr|sogou[\w]*)[ \/]([\d\.]+)/],["Opera",/(?:opera|opr|oupeng)\/([\d\.]+)/],["BaiduBrowser",/(?:bidubrowser|baidubrowser)[\/ ]?([\d\.\w]+)/],["BaiduBox",/baiduboxapp|baiduboxpad/],["UC",/(?:ucweb|ucbrowser)\/?([\d\.]+)/],["Maxthon",/maxthon\/([\d\.]+)/],["Samsung",/samsungbrowser\/([\d\.]+)/],["Dolphin",/aphone|apad/],["2345",/2345/],["Miui",/miuibrowser\/([\d\.]+)/],["OppoBrowser",/oppobrowser\/([\d\.]+)/],["MeiZu",/mz-/],["Weibo",/weibo/],["Youku",/youku/],["NewsApp",/newsapp/],["AliApp",/aliapp/],["Firefox",/firefox\/([\d\.\w]+)/],["Chrome",/chrome\/([\d\.]+)/],["IE",/msie[ ](\d+\.\d+)/],["Safari",/safari\/([\d\.]+)/]],t=0;t<e.length;t++)if(n=o.match(e[t][1])){r.name=e[t][0],r.version=n[1]||"0";break}return r},x=function(t){window.localStorage.removeItem(t)},j=function(t,e){if(void 0===e||"function"==typeof e)window.localStorage.setItem(t,"");else try{window.localStorage.setItem(t,JSON.stringify(e))}catch(t){console.error(t)}},A=function(t){var e=window.localStorage.getItem(t)||"";return void 0===e||"function"==typeof e?"":JSON.parse(e)},L=function(){if(!window.localStorage)return!1;try{return window.localStorage.setItem("JUTILS_STOARGE_TEST","true"),window.localStorage.removeItem("JUTILS_STOARGE_TEST"),!0}catch(t){return!1}},T=function(t){var e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]*)(;|$)"));return null!=e?unescape(e[2]):null},D=function(t,e){var n=[0,0,0,0],r="",o=e>t?parseInt(((e-t)/1e3).toString()):0;return n[0]=o>86400?parseInt((o/86400).toString()):0,o-=86400*n[0],n[1]=o>3600?parseInt((o/3600).toString()):0,o-=3600*n[1],n[2]=o>60?parseInt((o/60).toString()):0,n[3]=o-60*n[2],r=n[0]>0?n[0]+"天":"",r+=n[0]<=0&&n[1]<=0?"":n[1]+"小时",r+=n[0]<=0&&n[1]<=0&&n[2]<=0?"":n[2]+"分钟",r+=n[0]<=0&&n[1]<=0&&n[2]<=0&&n[3]<=0?"":n[3]+"秒"},N=function(t,e){return t.toString().padStart(e,"0")},k=function(t,e){return e.replace(/yyyy|YYYY/,t.getFullYear().toString()).replace(/yy|YY/,N(t.getFullYear()%100,2)).replace(/mm|MM/,N(t.getMonth()+1,2)).replace(/m|M/g,(t.getMonth()+1).toString()).replace(/dd|DD/,N(t.getDate(),2)).replace(/d|D/g,t.getDate().toString()).replace(/hh|HH/,N(t.getHours(),2)).replace(/h|H/g,t.getHours().toString()).replace(/ii|II/,N(t.getMinutes(),2)).replace(/i|I/g,t.getMinutes().toString()).replace(/ss|SS/,N(t.getSeconds(),2)).replace(/s|S/g,t.getSeconds().toString()).replace(/w/g,t.getDay().toString()).replace(/W/g,["日","一","二","三","四","五","六"][t.getDay()])},M=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"YYYY-MM-DD HH:II:SS";if(!t)return arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";try{return"string"==typeof t&&(t=isNaN(Number(t))?new Date(t):Number(t)),"number"==typeof t&&(t=new Date(t)),t instanceof Date?k(t,e):""}catch(t){return""}},P=function(t){return M(t)},I=function(t){return M(t,"YYYY-MM-DD")},Y=function(t){return M(t,"YYYY-MM-DD HH")},C=function(t){var e=t?new Date(t):new Date,n=e.getMonth();return e.setMonth(n+1),e.setDate(0),e.getDate()},_=function(t){var e,n=new Date(t),r=new Date,o=n.getFullYear(),i=n.getMonth()+10,u=n.getDate(),a=n.getHours(),c=n.getMinutes(),s=r.getFullYear(),l=r.getHours();if(o<s)e=o+"年"+i+"月"+u+"日 "+a+":"+c;else{var f=(r.getTime()-n.getTime())/36e5;if(f>l)e=i+"月"+u+"日 "+a+":"+c;else if(f>=1)e="今天 "+a+":"+c+"分";else{var h=r.getMinutes()-c;e=h>1?h+"分钟前":"刚刚"}}return e},R=function(t){var e=new Date(t),n=e.getMonth();return e.setMonth(n+1),e.setDate(0),e.getDate()},F=function(t){t=t||navigator.userAgent;for(var e={os:"other",version:""},n=[["android",/Android;?[\s\/]+([\d.]+)?/],["android",/jdapp;android;[\d.]+;([\d.]+);/],["android",/[aA]ndroid;/],["ipad",/iPad;.*?OS\s([\d_]+)/],["ipod",/iPod(?:\stouch)?;.*?\sOS\s([\d_]+)?/],["iphone",/CPU\siPhone\s(?:OS\s)?([\d_]+)/],["windows",/Windows NT/],["mac",/Macintosh;.*?Mac OS X\s([\d._]+)/],["windows phone",/Windows Phone\s([\d.]+)?/],["symbianos",/SymbianOS\/([\d.]+)?/],["bb",/BlackBerry|BB10|RIM Tablet OS\s([\d.]+)?/],["linux",/linux/i]],r=0;r<n.length;r++){var o=n[r],i=t.match(o[1]);if(i){e.os=o[0],e.version=(i[1]||"").replace(/_/g,".");break}}return e},q=function(t,e){return Math.floor(Math.random()*(e-t)+t)},B=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return"number"!=typeof t&&(t=Number(t)),Number(t.toFixed(e))},J=function(){return!!/qq\/([\d\.]+)*/i.test(navigator.userAgent)},U=function(){return!!/MicroMessenger/i.test(navigator.userAgent)},H=function(t){var e=t||"",n=e.substring(0,3),r=e.substring(0,4);return!!/^1\d{10}$/.test(e)&&("130,131,132,155,156,185,186,145,176".indexOf(n)>=0?"联通":"133,153,180,181,189,177,173,170".indexOf(n)>=0||"1349"==r?"电信":"134,135,136,137,138,139,150,151,152,157,158,159,187,188,147,182,183,184,178".indexOf(n)>=0?"移动":"未知")},G=function(){return/android/i.test(navigator.userAgent.toLowerCase())},$=function(){return/iphone|ipod|ipad|Macintosh/i.test(navigator.userAgent.toLowerCase())},z=function(t){var e,n,r,o,i,u,a,c;if(i=["1","0","x","9","8","7","6","5","4","3","2"],u=["7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2"],e="",!t)return"身份证号码不能为空";if(18!=t.length)return"身份证号码长度应该为18位";if(18==t.length?e=t.substring(0,17):15==t.length&&(e=t.substring(0,6)+"19"+t.substring(6,15)),!/^\d+$/.test(e))return"身份证格式错误";if(n=e.substring(6,10),r=e.substring(10,12),o=e.substring(12,14),!1===/[1-9]\d{3}-(0[1-9]|1[0-2])-([0-2]\d|3[0-1])/.test(n+"-"+r+"-"+o))return"身份证生日无效。";if((new Date).getFullYear()-Number(n)>150||(new Date).getTime()-new Date(Number(n),Number(r)-1,Number(o)).getTime()<0)return"身份证生日不在有效范围";if(Number(r)>12||0===Number(r))return"身份证月份无效";if(Number(o)>31||0==Number(o))return"身份证日期无效";if(!{11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外"}[e.substring(0,2)])return"身份证地区编码错误";for(c=0,a=0;a<17;a++)c+=Number(e.charAt(a))*Number(u[a]);return e+=i[c%11],18!=t.length?"":e!=t.toLowerCase()?"不是合法的身份证号码":""},Q=function(t,e){return Object.prototype.toString.call(t)==="[object ".concat(e,"]")},W=function(t){return Q(t,"String")},K=function(t){return Q(t,"Number")},X=function(t){return Q(t,"Boolean")},Z=function(t){return Q(t,"Undefined")},V=function(t){return Q(t,"Null")},tt=function(t){return Q(t,"Function")},et=function(t){return Q(t,"Date")},nt=function(t){return Q(t,"Array")},rt=function(t){return Q(t,"RegExp")},ot=function(t){return Q(t,"Error")},it=function(t){return Q(t,"Object")},ut=function(t){if(!t)return!1;return/(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/.test(t)},at=function(t){return/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(t)},ct=function(t){return 0!==t&&!t},st=function(t){return null==t||""===t},lt=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.length?n.reduce((function(e,n){var r;return null!==(r=null==e?void 0:e[n])&&void 0!==r?r:t})):t},ft=function(t){if(V(t)||Z(t))return"";var e,n=t.constructor===Array?[]:{};if("object"===h(t)){if(JSON)e=JSON.stringify(t),n=JSON.parse(e);else for(var r in t)n[r]="object"===h(t[r])?ft(t[r]):t[r];return n}},ht=function(t){return"object"!=h(t)||null==t?t:JSON.parse(JSON.stringify(t))},dt=function(t,e,n){for(var r in e)if(it(e[r])&&it(t[r]))t[r]=dt(t[r],e[r],n);else{if(Object.keys(t).includes(r)&&!n.includes(r))continue;t[r]=e[r]}for(var o in t)void 0===e[o]&&delete t[o];return t},vt=function(t){if(null==t)return!0;if(Array.isArray(t))return!t.length;for(var e in t)if(Object.hasOwnProperty.call(t,e))return!1;return!0},pt=function(t){if(!t)return{};var e=c({},t);return Object.keys(e).forEach((function(t){var n=e[t];st(n)&&delete e[t]})),e},gt=function(t){var e;if("object"===h(t))if(Array.isArray(t))for(var n in e=[],t)e.push(gt(t[n]));else if(null===t)e=null;else if(t.constructor===RegExp)e=t;else for(var r in e={},t)e[r]=gt(t[r]);else e=t;return e},mt=function(t,e){return JSON.stringify(t)===JSON.stringify(e)},yt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"id",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"pid",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"children",o=[];if(!Array.isArray(t))return o;var i={};return t.forEach((function(t){i[t[e]]=t})),t.forEach((function(t){var e=i[t[n]];e?(e[r]||(e[r]=[])).push(t):o.push(t)})),o},bt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"children",n=[],r=1;return function t(o){o.forEach((function(o){n.push(c(c({},o),{},u(u({},e,void 0),"index",r))),r++,o[e]&&t(o[e])}))}(t),n},wt=function(t,e){return t.reduce((function(t,n){return(t[n[e]]=t[n[e]]||[]).push(n),t}),{})},St=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t.replace(/(^\s+)|(\s+$)/g,"");return e&&(n=n.replace(/\s/g,"")),n},Ot=function(t){return 18==t.length?Number(t.charAt(16))%2==0?"FEMALE":"MALE":15==t.length?Number(t.charAt(14))%2==0?"FEMALE":"MALE":""},Et=function(t){var e="";return e=15==t.length?(e="19"+(e=t.substring(6,12))).substring(0,4)+"-"+e.substring(4,6)+"-"+e.substring(6):(e=t.substring(6,14)).substring(0,4)+"-"+e.substring(4,6)+"-"+e.substring(6)},xt=function(t){return"".concat(String(t).slice(0,1),"****************").concat(String(t).slice(17))},jt=function(){var t=Math.random,e=parseInt;return Number(new Date).toString()+e((10*t()).toString())+e((10*t()).toString())+e((10*t()).toString())},At=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:99,n=t.split(".").map((function(t){return Number(t)})),r=n.some((function(t){return isNaN(t)})),o=!0;return r?t:((n=n.reverse()).forEach((function(t,r){o&&(t>=e?n[r]=0:(o=!1,n[r]=n[r]+1))})),n.reverse().join("."))},Lt=function(t){if("string"==typeof t)return t.split(".").pop();throw new Error("filename must be a string type")},Tt=function(t,e){e=e||"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";for(var n="",r=t=t||8;r>0;--r)n+=e[Math.floor(Math.random()*e.length)];return n},Dt=function(t,e){var n=t.length-e.length;return n>=0&&t.lastIndexOf(e)==n},Nt=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2;if(!t||!e)return 0;if(t===e)return 100;var r,o,i,u,a,c,s,l=t.length>e.length?t.length:e.length,f=t.length,h=e.length,d=[];if(0===f)return h;if(0===h)return f;for(r=0;r<=f;r++)d[r]=[],d[r][0]=r;for(o=0;o<=h;o++)d[0][o]=o;for(r=1;r<=f;r++)for(i=t.charAt(r-1),o=1;o<=h;o++)u=i===e.charAt(o-1)?0:1,d[r][o]=(a=d[r-1][o]+1,c=d[r][o-1]+1,s=d[r-1][o-1]+u,a<c?a<s?a:s:c<s?c:s);var v=100*(1-d[f][h]/l);return Number(v.toFixed(n))},kt=function(t){if(!t)return 0;var e=t.length;t=t.toString();for(var n=0,r=0;r<e;r++)n+=t.charCodeAt(r)<0||t.charCodeAt(r)>255?2:1;return n},Mt=function(t){var e=window.location.search,n=new RegExp("(^|&)"+t+"=([^&]*)(&|$)"),r=e.substr(e.indexOf("?")+1).match(n);return null!=r?r[2]:""},Pt=function(t){var e=ft(t);for(var n in e)"object"===h(e[n])?e[n]=Pt(e[n]):"string"==typeof e[n]&&(e[n]=St(e[n]));return e},It=function(t){t=Pt(t);var e="";if("[object Object]"===Object.prototype.toString.call(t)){var n=function(n){Array.isArray(t[n])?t[n].forEach((function(t){e+="".concat(n,"=").concat(t,"&")})):null!==t[n]&&(e+="".concat(n,"=").concat(t[n],"&"))};for(var r in t)n(r)}return e.length>0?(e="?".concat(e)).substring(0,e.length-1):""},Yt=function(t){var e={},n=t.match(/[?&][^?&]+=[^?&]+/g);return n&&n.forEach((function(t){var n=t.substring(1).split("="),r=decodeURIComponent(n[0]),o=decodeURIComponent(n[1]);e[r]=o})),e},Ct=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=null,o=function(){for(var o=arguments.length,i=new Array(o),u=0;u<o;u++)i[u]=arguments[u];if(r&&clearTimeout(r),n){var a=!r;r=setTimeout((function(){r=null}),e),a&&t.apply(void 0,i)}else r=setTimeout((function(){t.apply(void 0,i)}),e)};return o.cancel=function(){clearTimeout(r),r=null},o},_t=function(t){var e,n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500,i=arguments.length>2?arguments[2]:void 0,u=0;i||(i={leading:!1,trailing:!0});var a=function(){u=!1===i.leading?0:(new Date).getTime(),e=null,t.apply(n,r),e||(n=r=null)};return function(){for(var r=arguments.length,c=new Array(r),s=0;s<r;s++)c[s]=arguments[s];var l=(new Date).getTime();u||!1!==i.leading||(u=l);var f=o-(l-u);n=null,f<=0||f>o?(e&&(clearTimeout(e),e=null),u=l,t.apply(n,c),e||(n=c=null)):e||!1===i.trailing||(e=setTimeout(a,f))}},Rt=function(t,e){e||(e=t.slice(t.lastIndexOf("/")+1));var n=document.createElement("a");n.download=e,n.style.display="none",n.href=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)},Ft=function(t,e){if(void 0===t)throw new Error("The first parameter name is a must");if(void 0===e)throw new Error("The second parameter content is a must");e instanceof Blob||(e=new Blob([e]));var n=URL.createObjectURL(e);Rt(n,t)},qt=function(t){var e=document.createElement("textarea");return document.body.appendChild(e),e.value=t,e.select(),document.execCommand("copy")?(document.execCommand("copy"),document.body.removeChild(e),!0):(document.body.removeChild(e),!1)},Bt=function(t){var e=0,n=0,r=0,o=0;function i(i){return 0===i.button&&(r=i.clientX,o=i.clientY,e=t.scrollLeft||0,n=t.scrollTop||0,document.addEventListener("mousemove",u),document.addEventListener("mouseup",a),t.style.cursor="grab"),!1}function u(i){return t.scrollTo(e-(i.clientX-r),n-(i.clientY-o)),!1}function a(){document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",a)}return t.addEventListener("mousedown",i),{destroy:function(){t.removeEventListener("mousedown",i),t.style.cursor=""}}},Jt=function(t){return new Promise((function(e,n){var r=new FileReader;r.readAsDataURL(t),r.onload=function(){return e(r.result)},r.onerror=function(t){return n(t)}}))},Ut=function(){return new Promise((function(t){var e=document.createElement("input");e.type="file",e.accept="application/json",e.onchange=function(n){var r=n.target.files;if(!r||!r.length)throw e=null,new Error("No files");var o=new FileReader;o.onload=function(n){try{var r=JSON.parse(n.target.result);console.log(r),e=null,t(r)}catch(n){e=null,t(!1)}},o.readAsText(r[0])},e.click()}))},Ht=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"data",n=document.createElement("a");try{n.href=URL.createObjectURL(new Blob([JSON.stringify(t)],{type:"application/json"})),n.download="".concat(e,".json"),n.click(),n=null}catch(t){n=null}},Gt=function(t){return new Promise((function(e){return setTimeout(e,t)}))},$t=function(t){var e=new FormData;return Object.keys(t).forEach((function(n){var r=t[n];Array.isArray(r)?r.forEach((function(t,r){return e.append(n+"[".concat(r,"]"),t)})):e.append(n,t[n])})),e},zt=function(t,e){var n=c(c({},{format:["阴性","阳性"],default:"未知",negative:["阴性","-"],positive:["阳性","+"]}),e),r=n.negative,o=n.positive,i=n.format,u=n.default;return r.includes(t)?i[0]:o.includes(t)?i[1]:t.includes("d")?i[0]:t.includes("D")?i[1]:u},Qt=function(t){return zt(t,{format:[!0,!1]})},Wt=function(t){return zt(t,{format:[!1,!0]})},Kt=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return function(n,r){return n[t]>r[t]?e?1:-1:e?-1:1}},Xt=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:300,e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];var o=null,i=0,u=0;return function(){for(var e=arguments.length,r=new Array(e),a=0;a<e;a++)r[a]=arguments[a];clearTimeout(o);var c=(new Date).getTime();u=c-i<t?u+1:0,i=(new Date).getTime(),n.forEach((function(e,n){n===u&&(o=setTimeout((function(){u=0,i=0,tt(e)&&e.apply(void 0,r)}),t))}))}},Zt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:300,r=null,o=0,i=0;return function(){for(var u=arguments.length,a=new Array(u),c=0;c<u;c++)a[c]=arguments[c];clearTimeout(r);var s=(new Date).getTime();i=s-o<n?i+1:0,o=(new Date).getTime(),i===e&&(r=setTimeout((function(){i=0,o=0,tt(t)&&t.apply(void 0,a)}),n))}},Vt=function(){return"rgba(".concat(Math.floor(255*Math.random()),", ").concat(Math.floor(255*Math.random()),", ").concat(Math.floor(255*Math.random()),", 1)")},te=function(t,e,n){return(t/e*n).toFixed(arguments.length>3&&void 0!==arguments[3]?arguments[3]:2)},ee=function(t){return function(e){return new Promise((function(n){Promise.all([e,Gt(t)]).then((function(t){n(t[0])}))}))}},ne=function(){var t,n=(t=s().mark((function t(e,n){var r,o,u,a,c,l,f,h,d,v,p,g,m;return s().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=new TextDecoder("utf-8"),o=e.body.getReader(),t.prev=2;case 3:return t.next=6,o.read();case 6:if(u=t.sent,a=u.done,c=u.value,!a){t.next=12;break}return n.done(),t.abrupt("break",19);case 12:l=r.decode(c),f=l.split(/(\n){2}/),h=f.map((function(t){return t.replace(/(\n)?^data:\s*/,"").trim()})).filter((function(t){return""!==t&&"[DONE]"!==t})).map((function(t){try{return JSON.parse(t)}catch(t){return console.log(t),{choices:[{delta:{content:""}}]}}})),d=i(h);try{for(d.s();!(v=d.n()).done;)g=v.value,m=(m=null!==(p=g.choices[0].delta.content)&&void 0!==p?p:"").replace(/^`\s*/,"`"),n.add(m)}catch(t){d.e(t)}finally{d.f()}t.next=3;break;case 19:t.next=24;break;case 21:t.prev=21,t.t0=t.catch(2),console.log(t.t0);case 24:case"end":return t.stop()}}),t,null,[[2,21]])})),function(){var n=this,r=arguments;return new Promise((function(o,i){var u=t.apply(n,r);function a(t){e(u,o,i,a,c,"next",t)}function c(t){e(u,o,i,a,c,"throw",t)}a(void 0)}))});return function(t,e){return n.apply(this,arguments)}}(),re=function(){return o((function t(e){n(this,t),u(this,"items",[]),this.items=e||[]}),[{key:"enqueue",value:function(t){nt(t)?this.items=this.items.concat(t):this.items.push(t)}},{key:"dequeue",value:function(){return this.items.shift()}},{key:"front",value:function(){return this.items[0]}},{key:"isEmpty",value:function(){return 0===this.items.length}},{key:"size",value:function(){return this.items.length}},{key:"clear",value:function(){this.items=[]}},{key:"print",value:function(){console.log(this.items.toString())}}])}();"function"==typeof SuppressedError&&SuppressedError;var oe=function(){return o((function t(){n(this,t),u(this,"listeners",void 0),u(this,"maxListener",void 0),this.listeners={},this.maxListener=5}),[{key:"addListener",value:function(t,e){var n=this.listeners;if(n[t]&&n[t].length>=this.maxListener)throw new Error("监听器的最大数量是".concat(this.maxListener,",您已超出限制"));n[t]instanceof Array?-1===n[t].indexOf(e)&&n[t].push(e):n[t]=[e]}},{key:"emit",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];this.listeners[t]&&this.listeners[t].forEach((function(t){t.apply(void 0,n)}))}},{key:"getListeners",value:function(t){return this.listeners[t]}},{key:"setMaxListeners",value:function(t){this.maxListener=t}},{key:"removeListener",value:function(t,e){var n=this.listeners,r=(n[t]||[]).indexOf(e);r>=0&&n[t].splice(r,1)}},{key:"removeAllListener",value:function(t){delete this.listeners[t]}},{key:"once",value:function(t,e){var n=this,r=function(){e.apply(void 0,arguments),n.removeListener(t,r)};this.addListener(t,r)}}])}();!function(t,e,n,r){var o,i=arguments.length,u=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(u=(i<3?o(u):i>3?o(e,n,u):o(e,n))||u);i>3&&u&&Object.defineProperty(e,n,u)}([function(t,e,n){return n.enumerable=!1,n}],oe.prototype,"emit",null);var ie=function(){return o((function t(e,r){n(this,t),u(this,"onConsume",void 0),u(this,"onDone",void 0),u(this,"queue",[]),u(this,"consuming",!1),u(this,"timer",void 0),u(this,"strTemp",""),this.onConsume=e,this.onDone=r}),[{key:"dynamicSpeed",value:function(){var t=2e3/this.queue.length;return t>200?200:t}},{key:"add",value:function(t){var e;t&&(e=this.queue).push.apply(e,l(t.split("")))}},{key:"consume",value:function(){if(this.queue.length>0){var t=this.queue.shift();t&&(this.strTemp+=t,this.onConsume(this.strTemp))}}},{key:"next",value:function(){var t=this;this.consume(),this.timer=setTimeout((function(){t.consume(),t.consuming&&t.next()}),this.dynamicSpeed())}},{key:"start",value:function(){this.consuming=!0,this.next()}},{key:"done",value:function(){this.consuming=!1,clearTimeout(this.timer),this.strTemp+=this.queue.join(""),this.onConsume(this.strTemp),this.onDone(this.strTemp),this.queue=[]}}])}(),ue=function(){function t(){n(this,t),u(this,"cache",void 0),this.cache=new Map}return o(t,[{key:"set",value:function(t,e){this.cache.set(t,e)}},{key:"get",value:function(t){return this.cache.get(t)}},{key:"has",value:function(t){return this.cache.has(t)}},{key:"delete",value:function(t){this.cache.delete(t)}},{key:"clear",value:function(){this.cache.clear()}}],[{key:"getInstance",value:function(){return t.instance}}])}();u(ue,"instance",new ue);var ae=ue.getInstance();Object.freeze(ae);export{oe as EventBus,re as Queue,ie as Typewriter,N as addZero,g as arrByObj,b as arrayCompare,pt as cleanObject,ht as cloneJson,ft as cloneObj,yt as convertDataToTree,P as convertDateToStandard,I as convertDateToStandardDay,Y as convertDateToStandardHours,M as convertDateToView,bt as convertTreeToList,qt as copyToBoar,B as cutNumber,k as dateFormat,D as dateInterval,C as dateMonthDays,Ct as debounce,gt as deepClone,y as difference,v as doubleRanking,Rt as download,Ft as downloadFile,Bt as dragScroll,Dt as endWith,Pt as everyTrim,Ht as exportJson,ee as fetchToSlow,It as formatQueryParam,zt as formatRhBloodGroup,Jt as getBase64,Et as getBirthdatByIdNo,E as getBrowserInfo,T as getCookie,R as getCountDays,Lt as getExt,$t as getFormData,Ot as getSexByIdNO,A as getStorage,kt as getStringLen,Mt as getUrlQuery,lt as getV,ae as globalCache,wt as groupBy,xt as hideIdNum,Ut as importJson,G as isAndroidMobileDevice,$ as isAppleMobileDevice,nt as isArray,X as isBoolean,et as isDate,at as isEmail,vt as isEmptyObject,mt as isEqual,ot as isError,ct as isFalsy,tt as isFunc,V as isNull,K as isNumber,it as isObject,ut as isPhone,J as isQQ,rt as isReg,Qt as isRhNegative,Wt as isRhPositive,W as isString,L as isSupportStorage,Q as isType,Z as isUndefined,z as isUserId,st as isVoid,U as isWX,dt as mergeObj,Zt as moreClick,Xt as oneClickToMoreClick,H as operattelecom,F as osInfo,ne as processStreamResponse,Vt as randomColor,p as randomData,O as reduceCallBackNumber,x as removeStorage,j as saveStorage,te as scaleLinear,q as scopeRandom,Nt as similar,Gt as sleep,w as sortCallBackChinese,S as sortCallBackTime,Kt as sorterCallBack,_t as throttle,_ as timeFormat,St as trim,m as uniqueArray,jt as uniqueId,Yt as urlByObj,Tt as uuid,At as versionCount};