From 69cc2b09fdafde928857adf1a264b50b8087a9a3 Mon Sep 17 00:00:00 2001 From: litt1e-p Date: Thu, 23 Feb 2023 16:22:22 +0800 Subject: [PATCH] release v0.3.2 --- dist/jstd.esm.js | 2 +- dist/jstd.min.js | 2 +- dist/jstd.umd.js | 2 +- package.json | 2 +- packages/function/copy.ts | 4 +- test/copy.spec.ts | 865 ++++++++++++++++++++------------------ 6 files changed, 451 insertions(+), 426 deletions(-) diff --git a/dist/jstd.esm.js b/dist/jstd.esm.js index 229c93f..1f73b79 100644 --- a/dist/jstd.esm.js +++ b/dist/jstd.esm.js @@ -1 +1 @@ -function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;te.length)&&(r=e.length);for(var t=0,n=new Array(r);t=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},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 a,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}var stringable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.string&&(!r||e.length>0)},strLen=function(e){var r=0;if(!stringable(e))return r;for(var t=0,n=e.length;t2&&void 0!==arguments[2])||arguments[2];if(isNil(e))return!1;if(!re(kRegStartStrictNumberic,e)||re(kRegEndStrictNumberic,e))return!1;var n=+e;return!isNaN(n)&&(t?typeis(r)===Types.bool?re(r?kRegSignNumberic:kRegUnSignNumberic,n):re(kRegNumberic,n):typeis(n)===Types.number)},objectable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(typeis(e)!==Types.object)return!1;var t=Object.getPrototypeOf(e);if(!t)return!r||Object.keys(e).length>0;if(t.constructor===Object)return!r||Object.keys(e).length>0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&Object.prototype.hasOwnProperty.toString.call(n)===Object.prototype.hasOwnProperty.toString.call(Object)&&(!r||Object.keys(e).length>0)},optional=function optional(path,obj){var separator=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",rs=void 0,properties;if(!stringable(path)||!stringable(separator))return rs;var p=path,o;if(properties=-1===p.indexOf(separator)?Array.of(p):p.split(separator),isNil(obj)){try{o=isNumberic(properties[0])?eval("this[".concat(properties[0],"]")):eval("this."+properties[0])}catch(e){o=Object.prototype.constructor()}if(properties.shift(),typeis(o)===Types.object);else if(typeis(o)!==Types.array)return rs}else o=obj;return rs=properties.reduce((function(e,r){return objectable(e)?e[r]:arrayable(e)?isNumberic(r)?e[+r]:e[r]:e?e[r]:void 0}),o),rs},extractable=function extractable(){for(var rs=Object.prototype.constructor(),_len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];if(!arrayable(args)||args.length<2)return rs;var t=Array.prototype.slice.call(args,-1)[0];if(typeis(t)===Types.string)try{t=eval("this."+t)}catch(e){t=void 0}if(!objectable(t))return rs;var o=Array.prototype.slice.apply(args,[0,-1]),_iterator=_createForOfIteratorHelper(o),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var i=_step.value;typeis(i)===Types.string?rs[i]=optional(i,t)||String.prototype.constructor():typeis(i)===Types.array?2===i.length?rs[i[0]]=(typeis(i[1])===Types.string?optional(i[1],t):i[1])||String.prototype.constructor():3===i.length&&(rs[i[0]]=objectable(i[2])||arrayable(i[2])?optional(i[1],i[2]):String.prototype.constructor()):typeis(i)===Types.object&&(rs=Object.assign(rs,i))}}catch(e){_iterator.e(e)}finally{_iterator.f()}return rs},assign=function e(r,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";typeis(t)!==Types.object&&typeis(t)!==Types.array&&typeis(t)!==Types.unknown||(stringable(r)||arrayable(r))&&(stringable(r)&&(r=r.split(o)),r.length>1?e(r,t[r.shift()],n):t[r[0]]=n)},objReverse=function(e){if(!objectable(e))return e;var r=e,t=Object.keys(r).reduce((function(e,t){var n=String(r[t]),o=[];return arrayable(e[n],!1)&&(o=e[n]),Object.assign(e,_defineProperty({},n,o.concat(t)))}),{});for(var n in t)t.hasOwnProperty(n)&&(t[n]=Array.isArray(t[n])&&1===t[n].length?t[n][0]:t[n]);return t},TypesDesc,Types;!function(e){e["[object Number]"]="number",e["[object String]"]="string",e["[object Boolean]"]="bool",e["[object Undefined]"]="undefined",e["[object Null]"]="null",e["[object Array]"]="array",e["[object Uint8Array]"]="uint8Array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object AsyncFunction]"]="asyncFunction",e["[object BigInt]"]="bigInt",e["[object Date]"]="date",e["[object WeakMap]"]="weakMap",e["[object Map]"]="map",e["[object WeakSet]"]="weakSet",e["[object ArrayBuffer]"]="arrayBuffer",e["[object Set]"]="set",e["[object Symbol]"]="symbol",e["[object DataView]"]="dataView",e["[object Float32Array]"]="float32Array",e["[object Float64Array]"]="float64Array",e["[object Int8Array]"]="int8Array",e["[object Int16Array]"]="int16Array",e["[object Int32Array]"]="int32Array",e["[object Uint8ClampedArray]"]="uint8ClampedArray",e["[object Uint16Array]"]="uint16Array",e["[object Uint32Array]"]="uint32Array",e["[object BigInt64Array]"]="bigInt64Array",e["[object BigUint64Array]"]="bigUint64Array",e["[object RegExp]"]="regExp"}(TypesDesc||(TypesDesc={})),function(e){e.number="number",e.string="string",e.bool="bool",e[void 0]="undefined",e.null="null",e.bigInt="bigInt",e.object="object",e.function="function",e.asyncFunction="asyncFunction",e.symbol="symbol",e.arrayBuffer="arrayBuffer",e.regExp="regExp",e.date="date",e.dataView="dataView",e.weakMap="weakMap",e.map="map",e.weakSet="weakSet",e.set="set",e.array="array",e.uint8Array="uint8Array",e.float32Array="float32Array",e.float64Array="float64Array",e.int8Array="int8Array",e.int16Array="int16Array",e.int32Array="int32Array",e.uint8ClampedArray="uint8ClampedArray",e.uint16Array="uint16Array",e.uint32Array="uint32Array",e.bigInt64Array="bigInt64Array",e.bigUint64Array="bigUint64Array",e.unknown=""}(Types||(Types={}));var inEnum=function(e,r){return!(!objectable(e)||e!==Object(e))&&(Object.prototype.hasOwnProperty.call(e,r)||Object.values(e).indexOf(r)>-1)},typeis=function(e){var r=Object.prototype.toString.call(e);if("[object Object]"===r){var t=Object.getPrototypeOf(e);if(t&&t.constructor!==Object)return Types.unknown}var n=Types.unknown;return Object.keys(TypesDesc).includes(r)&&(n=Types[TypesDesc[r]]),n},re=function(e,r){return e.test(r.toString())},arrayable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(typeis(e)===Types.array||typeis(e)===Types.uint8Array)&&(!r||e.length>0)},arrayUnique=function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!arrayable(e))return e;if(r){var t=e.map((function(e){return JSON.stringify(e)}));return Array.from(new Set(t)).map((function(e){return JSON.parse(e)}))}return Array.from(new Set(e))},arrValsCount=function(e){var r={};return arrayable(e)?e.reduce((function(e,r){var t=r+"";return e[t]?e[t]++:e[t]=1,e}),r):r},arrValCount=function(e,r){if(!arrayable(e)||!e.includes(r))return 0;var t=arrValsCount(e),n=r+"";return t.hasOwnProperty(n)?t[n]:0},flat=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,n=Array.prototype.constructor();if(!arrayable(r,!1))return r;var o=isNaN(t)?1:Number(t);if(!o)return Array.prototype.slice.call(r);for(var a=0,i=r.length>>>0;a>8-a%1*8)){if((o=r.charCodeAt(a+=3/4))>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|o}return t},_atob="undefined"!=typeof window&&window.atob?window.atob:function(e){var r=String(e).replace(/[=]+$/,"");if(r.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,n="",o=0,a=0,i=0;t=r.charAt(i++);~t&&(a=o%4?64*a+t:t,o++%4)?n+=String.fromCharCode(255&a>>(-2*o&6)):0)t=chars.indexOf(t);return n};var url2Blob=function(e){if("undefined"==typeof window)throw new Error("url2Blob only works in browser environment");if(!stringable(e))throw new TypeError(e+" can not be null");var r=e.split(",");if(!arrayable(r))throw new ReferenceError("invalid data url");var t=r[0].match(/:(.*?);/);if(!arrayable(t)||t.length<2)throw new ReferenceError("invalid data format");for(var n=t,o=_atob(r[1]),a=o.length,i=new Uint8Array(a);a--;)i[a]=o.charCodeAt(a);return new Blob([i],{type:n[1]})},str2Buffer=function(e){if(stringable(e))return e=_btoa(unescape(encodeURIComponent(e))),new Uint8Array(Array.prototype.map.call(e,(function(e){return e.charCodeAt(0)})))},buffer2Str=function(e){if(arrayable(e)||objectable(e)||stringable(e)){typeis(e)===Types.string&&(e=JSON.parse.call(null,e));var r=Object.values(e);if(arrayable(r))return decodeURIComponent(escape(_atob(String.fromCharCode.apply(null,Array.prototype.map.call(new Uint8Array(r),(function(e){return e}))))))}},formatNumber=function(e){return(e=e.toString())[1]?e:"0"+e},dateable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.date&&(!r||"Invalid Date"!==e.toString())},formatDate=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd hh:mm:ss",t=String.prototype.constructor();if(typeis(e)!==Types.date&&!stringable(e))return t;if(typeis(e)===Types.string&&(e=new Date(e)),"Invalid Date"===e.toString())return t;for(var n=e,o={Y:n.getFullYear(),M:n.getMonth()+1,D:n.getDate(),h:n.getHours(),m:n.getMinutes(),s:n.getSeconds()},a=0,i=Object.keys(o).length>>>0;a0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,i=arguments.length>6?arguments[6]:void 0;if([e,r,t,n,o,a].every((function(e){return typeis(e)===Types.number&&e>=0}))){var u=new Date(Date.UTC(e,r-1,t,n,o,a)),l=new Date(u.toLocaleString("en-US",{timeZone:"UTC"})),y=u;if(stringable(i))y=new Date(u.toLocaleString("en-US",{timeZone:i}));else if("Invalid Date"===(y=new Date("".concat(r,"/").concat(t,"/").concat(e," ").concat(n,":").concat(o,":").concat(a))).toString())return;var c=l.getTime()-y.getTime();return u.setTime(u.getTime()+c),u}},quarterable=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Q",n=Array(2).fill(String.prototype.constructor()),o=new RegExp("^\\d{4}".concat(t,"\\d$"),"g");if(stringable(e)&&o.test(e)){var a=e.split(t),i=_slicedToArray(a,2),u=i[0],l=i[1];if(isNumberic(u)&&isNumberic(l)){var y=+l+ +r,c=4*+u+y;return y%4==0?(n[0]=0===y?u-1:+u+y/4-1,n[1]=4):(n[1]=c%4,n[0]=(c-n[1])/4),n.join(t)}}},mappable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.map&&(!r||e.size>0)},DecimalMathCalcType;!function(e){e.round="round",e.ceil="ceil",e.floor="floor",e.trunc="trunc"}(DecimalMathCalcType||(DecimalMathCalcType={}));var Decimal=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"powers",void 0),void 0===Math.trunc&&(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),this.powers=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,1e22]}return _createClass(e,[{key:"intpow10",value:function(e){return e<0||e>22?Math.pow(10,e):this.powers[e]}},{key:"isRound",value:function(e,r){var t=this.intpow10(r);return Math.round(e*t)/t===e}},{key:"decimalAdjust",value:function(e,r,t){if("round"!==e&&this.isRound(r,t||0))return r;var n=this.intpow10(t||0),o=r*n*(1+Number.EPSILON);return Math[e](o)/n}},{key:"round",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r)}},{key:"ceil",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.ceil,e,r)}},{key:"floor",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.floor,e,r)}},{key:"trunc",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.trunc,e,r)}},{key:"toFixed",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r).toFixed(r)}}]),e}(),rangeRandom=function(e,r){return!isNumberic(e)||!isNumberic(r)||e>r?Math.random():Math.random()*(r-e)+e},numberic=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(isNumberic(e,void 0,!1)){var t=+e,n=Math.sign(t);return r=isNumberic(r,!0)?r:2,(new Decimal).round(Math.abs(t),r)*n}},guid=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz0123456789",t=r.split("");return t.length||(t="abcdefghijklmnopqrstuvwxyz0123456789".split("")),_toConsumableArray(Array(e)).map((function(e){return t[Math.random()*t.length|0]})).join("")},hash=function(){return(16777215*Math.random()<<7).toString(16)},numberFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=arguments.length>2?arguments[2]:void 0,n=numberic(e,r);if(void 0!==n)return(t=isNumberic(t,!0)?t:r)>0?n.toFixed(t):e},moneyFormat=function(e){var r,t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,o=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return isNumberic(e)?(o=isNumberic(o,!0)?o:n,null!==(r=null===(t=numberic(e,n))||void 0===t?void 0:t.toLocaleString(void 0,{minimumFractionDigits:o,maximumFractionDigits:o}))&&void 0!==r?r:a):a},signFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return isNumberic(e)?"".concat(e>0?"+":e<0?"-":"").concat(Math.abs(e)):r},sleep=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16;return new Promise((function(r){return setTimeout(r,e)}))},settable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.set&&(!r||e.size>0)},PromiseStatus;!function(e){e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected"}(PromiseStatus||(PromiseStatus={}));var PromisePolyfill=function(){function e(r){var t=this;_classCallCheck(this,e),_defineProperty(this,"status",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"reason",void 0),_defineProperty(this,"onResolvedClosures",void 0),_defineProperty(this,"onRejectedClosures",void 0),this.status=PromiseStatus.pending,this.value=void 0,this.reason=void 0,this.onResolvedClosures=[],this.onRejectedClosures=[];var n=function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.rejected,t.reason=e,t.onRejectedClosures.forEach((function(e){return e()})))};try{r((function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.fulfilled,t.value=e,t.onResolvedClosures.forEach((function(e){return e()})))}),n)}catch(e){n(e)}}return _createClass(e,[{key:"then",value:function(r,t){var n=this;r="function"==typeof r?r:function(e){return e},t="function"==typeof t?t:function(e){throw e};var o=new e((function(e,a){n.status===PromiseStatus.fulfilled&µ((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(n.value);resolvePromise(o,i,e,a)}catch(e){a(e)}})),n.status===PromiseStatus.rejected&µ((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(n.reason);resolvePromise(o,i,e,a)}catch(e){a(e)}})),n.status===PromiseStatus.pending&&(n.onResolvedClosures.push((function(){micro((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(n.value);resolvePromise(o,i,e,a)}catch(e){a(e)}}))})),n.onRejectedClosures.push((function(){micro((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(n.reason);resolvePromise(o,i,e,a)}catch(e){a(e)}}))})))}));return o}},{key:"catch",value:function(e){return this.then(void 0,e)}}]),e}();function micro(e){return"undefined"!=typeof window?window.queueMicrotask(e):process.nextTick(e)}function resolvePromise(e,r,t,n){if(r===e)return n(new TypeError("Chaining cycle detected for promise"));var o=!1;if(null===r||"object"!==_typeof(r)&&"function"!=typeof r)t(r);else try{var a=r.then;"function"==typeof a?a.call(r,(function(r){o||(o=!0,resolvePromise(e,r,t,n))}),(function(e){o||(o=!0,n(e))})):t(r)}catch(e){if(o)return;o=!0,n(e)}}_defineProperty(PromisePolyfill,"resolve",void 0),_defineProperty(PromisePolyfill,"reject",void 0),_defineProperty(PromisePolyfill,"race",void 0),_defineProperty(PromisePolyfill,"all",void 0),_defineProperty(PromisePolyfill,"deferred",void 0),PromisePolyfill.resolve=function(e){return new PromisePolyfill((function(r,t){return r(e)}))},PromisePolyfill.reject=function(e){return new PromisePolyfill((function(r,t){return t(e)}))},PromisePolyfill.race=function(e){return new PromisePolyfill((function(r,t){for(var n=0;n2&&void 0!==arguments[2]&&arguments[2];if(typeis(e)!==Types.function&&typeis(e)!==Types.asyncFunction)throw new TypeError("Expected a function");if(!isNumberic(r,!0))throw new TypeError("Expected a numberic time");var a=function(){for(var a=arguments.length,i=new Array(a),u=0;uu?(a&&(clearTimeout(a),a=null),l=c,e.apply(y,n)):a||!1===(null==t?void 0:t.trailing)||(a=setTimeout((function(){l=!1===(null==t?void 0:t.leading)?0:(new Date).getTime(),a=null,e.apply(y,n)}),s)),i};return y.cancel=function(){a&&clearTimeout(a),l=0,a=null},y},_TypedCopyMap,TypedArrayMap={"[object Float32Array]":Float32Array,"[object Float64Array]":Float64Array,"[object Int8Array]":Int8Array,"[object Int16Array]":Int16Array,"[object Int32Array]":Int32Array,"[object Uint8Array]":Uint8Array,"[object Uint16Array]":Uint16Array,"[object Uint32Array]":Uint32Array,"[object Uint8ClampedArray]":Uint8ClampedArray},TypedCopyMap=(_TypedCopyMap={},_defineProperty(_TypedCopyMap,Types.date,copyDate),_defineProperty(_TypedCopyMap,Types.arrayBuffer,copyArrayBuffer),_defineProperty(_TypedCopyMap,Types.dataView,copyDataView),_defineProperty(_TypedCopyMap,Types.float32Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.float64Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.int8Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.int16Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.int32Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint8Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint8ClampedArray,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint16Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint32Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.bigInt64Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.bigUint64Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.regExp,copyRegExp),_TypedCopyMap),copy=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=function e(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,o=r;if(isNull(o))return o;if(TypedCopyMap[typeis(o)])return TypedCopyMap[typeis(o)](r);if(n.get(o))return n.get(o);if(arrayable(r)){var a=Array.prototype.constructor();return n.set(o,a),r.map((function(e){return a.push(e)})),t?a.map((function(r){return e(r,t,n)})):a}if(objectable(r)){var i=Object.prototype.constructor();for(var u in n.set(o,i),r)Object.prototype.hasOwnProperty.call(r,u)&&(i[u]=r[u]);if(!t)return i;for(var l in i)Object.prototype.hasOwnProperty.call(i,l)&&(i[l]=e(i[l],t,n));return i}return r};return t.call(null,e,r)};function copyArrayBuffer(e){var r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e)),r}function copyDataView(e){var r=copyArrayBuffer(e.buffer);return new DataView(r,e.byteOffset,e.byteLength)}function copyDate(e){return new Date(e.getTime())}function copyRegExp(e){var r=new RegExp(e.source,e.flags);return r.lastIndex=e.lastIndex,r}function copyTypedArray(e){try{TypedArrayMap["[object BigInt64Array]"]=BigInt64Array,TypedArrayMap["[object BigUint64Array]"]=BigUint64Array}catch(e){}var r=copyArrayBuffer(e.buffer);return new(TypedArrayMap[Object.prototype.toString.call(e)])(r,e.byteOffset,e.length)}var sort=function(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"zh-Hans-CN",o=null!=e?e:"",a=null!=r?r:"",i=/[a-zA-Z0-9]/;return isNumberic(e)&&isNumberic(r)?Number(e)>Number(r)?1:Number(e)a?1:oe.length)&&(r=e.length);for(var t=0,n=new Array(r);t=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},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 a,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}var stringable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.string&&(!r||e.length>0)},strLen=function(e){var r=0;if(!stringable(e))return r;for(var t=0,n=e.length;t2&&void 0!==arguments[2])||arguments[2];if(isNil(e))return!1;if(!re(kRegStartStrictNumberic,e)||re(kRegEndStrictNumberic,e))return!1;var n=+e;return!isNaN(n)&&(t?typeis(r)===Types.bool?re(r?kRegSignNumberic:kRegUnSignNumberic,n):re(kRegNumberic,n):typeis(n)===Types.number)},objectable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(typeis(e)!==Types.object)return!1;var t=Object.getPrototypeOf(e);if(!t)return!r||Object.keys(e).length>0;if(t.constructor===Object)return!r||Object.keys(e).length>0;var n=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof n&&Object.prototype.hasOwnProperty.toString.call(n)===Object.prototype.hasOwnProperty.toString.call(Object)&&(!r||Object.keys(e).length>0)},optional=function optional(path,obj){var separator=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",rs=void 0,properties;if(!stringable(path)||!stringable(separator))return rs;var p=path,o;if(properties=-1===p.indexOf(separator)?Array.of(p):p.split(separator),isNil(obj)){try{o=isNumberic(properties[0])?eval("this[".concat(properties[0],"]")):eval("this."+properties[0])}catch(e){o=Object.prototype.constructor()}if(properties.shift(),typeis(o)===Types.object);else if(typeis(o)!==Types.array)return rs}else o=obj;return rs=properties.reduce((function(e,r){return objectable(e)?e[r]:arrayable(e)?isNumberic(r)?e[+r]:e[r]:e?e[r]:void 0}),o),rs},extractable=function extractable(){for(var rs=Object.prototype.constructor(),_len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];if(!arrayable(args)||args.length<2)return rs;var t=Array.prototype.slice.call(args,-1)[0];if(typeis(t)===Types.string)try{t=eval("this."+t)}catch(e){t=void 0}if(!objectable(t))return rs;var o=Array.prototype.slice.apply(args,[0,-1]),_iterator=_createForOfIteratorHelper(o),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var i=_step.value;typeis(i)===Types.string?rs[i]=optional(i,t)||String.prototype.constructor():typeis(i)===Types.array?2===i.length?rs[i[0]]=(typeis(i[1])===Types.string?optional(i[1],t):i[1])||String.prototype.constructor():3===i.length&&(rs[i[0]]=objectable(i[2])||arrayable(i[2])?optional(i[1],i[2]):String.prototype.constructor()):typeis(i)===Types.object&&(rs=Object.assign(rs,i))}}catch(e){_iterator.e(e)}finally{_iterator.f()}return rs},assign=function e(r,t,n){var o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";typeis(t)!==Types.object&&typeis(t)!==Types.array&&typeis(t)!==Types.unknown||(stringable(r)||arrayable(r))&&(stringable(r)&&(r=r.split(o)),r.length>1?e(r,t[r.shift()],n):t[r[0]]=n)},objReverse=function(e){if(!objectable(e))return e;var r=e,t=Object.keys(r).reduce((function(e,t){var n=String(r[t]),o=[];return arrayable(e[n],!1)&&(o=e[n]),Object.assign(e,_defineProperty({},n,o.concat(t)))}),{});for(var n in t)t.hasOwnProperty(n)&&(t[n]=Array.isArray(t[n])&&1===t[n].length?t[n][0]:t[n]);return t},TypesDesc,Types;!function(e){e["[object Number]"]="number",e["[object String]"]="string",e["[object Boolean]"]="bool",e["[object Undefined]"]="undefined",e["[object Null]"]="null",e["[object Array]"]="array",e["[object Uint8Array]"]="uint8Array",e["[object Object]"]="object",e["[object Function]"]="function",e["[object AsyncFunction]"]="asyncFunction",e["[object BigInt]"]="bigInt",e["[object Date]"]="date",e["[object WeakMap]"]="weakMap",e["[object Map]"]="map",e["[object WeakSet]"]="weakSet",e["[object ArrayBuffer]"]="arrayBuffer",e["[object Set]"]="set",e["[object Symbol]"]="symbol",e["[object DataView]"]="dataView",e["[object Float32Array]"]="float32Array",e["[object Float64Array]"]="float64Array",e["[object Int8Array]"]="int8Array",e["[object Int16Array]"]="int16Array",e["[object Int32Array]"]="int32Array",e["[object Uint8ClampedArray]"]="uint8ClampedArray",e["[object Uint16Array]"]="uint16Array",e["[object Uint32Array]"]="uint32Array",e["[object BigInt64Array]"]="bigInt64Array",e["[object BigUint64Array]"]="bigUint64Array",e["[object RegExp]"]="regExp"}(TypesDesc||(TypesDesc={})),function(e){e.number="number",e.string="string",e.bool="bool",e[void 0]="undefined",e.null="null",e.bigInt="bigInt",e.object="object",e.function="function",e.asyncFunction="asyncFunction",e.symbol="symbol",e.arrayBuffer="arrayBuffer",e.regExp="regExp",e.date="date",e.dataView="dataView",e.weakMap="weakMap",e.map="map",e.weakSet="weakSet",e.set="set",e.array="array",e.uint8Array="uint8Array",e.float32Array="float32Array",e.float64Array="float64Array",e.int8Array="int8Array",e.int16Array="int16Array",e.int32Array="int32Array",e.uint8ClampedArray="uint8ClampedArray",e.uint16Array="uint16Array",e.uint32Array="uint32Array",e.bigInt64Array="bigInt64Array",e.bigUint64Array="bigUint64Array",e.unknown=""}(Types||(Types={}));var inEnum=function(e,r){return!(!objectable(e)||e!==Object(e))&&(Object.prototype.hasOwnProperty.call(e,r)||Object.values(e).indexOf(r)>-1)},typeis=function(e){var r=Object.prototype.toString.call(e);if("[object Object]"===r){var t=Object.getPrototypeOf(e);if(t&&t.constructor!==Object)return Types.unknown}var n=Types.unknown;return Object.keys(TypesDesc).includes(r)&&(n=Types[TypesDesc[r]]),n},re=function(e,r){return e.test(r.toString())},arrayable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(typeis(e)===Types.array||typeis(e)===Types.uint8Array)&&(!r||e.length>0)},arrayUnique=function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!arrayable(e))return e;if(r){var t=e.map((function(e){return JSON.stringify(e)}));return Array.from(new Set(t)).map((function(e){return JSON.parse(e)}))}return Array.from(new Set(e))},arrValsCount=function(e){var r={};return arrayable(e)?e.reduce((function(e,r){var t=r+"";return e[t]?e[t]++:e[t]=1,e}),r):r},arrValCount=function(e,r){if(!arrayable(e)||!e.includes(r))return 0;var t=arrValsCount(e),n=r+"";return t.hasOwnProperty(n)?t[n]:0},flat=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,n=Array.prototype.constructor();if(!arrayable(r,!1))return r;var o=isNaN(t)?1:Number(t);if(!o)return Array.prototype.slice.call(r);for(var a=0,i=r.length>>>0;a>8-a%1*8)){if((o=r.charCodeAt(a+=3/4))>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");n=n<<8|o}return t},_atob="undefined"!=typeof window&&window.atob?window.atob:function(e){var r=String(e).replace(/[=]+$/,"");if(r.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,n="",o=0,a=0,i=0;t=r.charAt(i++);~t&&(a=o%4?64*a+t:t,o++%4)?n+=String.fromCharCode(255&a>>(-2*o&6)):0)t=chars.indexOf(t);return n};var url2Blob=function(e){if("undefined"==typeof window)throw new Error("url2Blob only works in browser environment");if(!stringable(e))throw new TypeError(e+" can not be null");var r=e.split(",");if(!arrayable(r))throw new ReferenceError("invalid data url");var t=r[0].match(/:(.*?);/);if(!arrayable(t)||t.length<2)throw new ReferenceError("invalid data format");for(var n=t,o=_atob(r[1]),a=o.length,i=new Uint8Array(a);a--;)i[a]=o.charCodeAt(a);return new Blob([i],{type:n[1]})},str2Buffer=function(e){if(stringable(e))return e=_btoa(unescape(encodeURIComponent(e))),new Uint8Array(Array.prototype.map.call(e,(function(e){return e.charCodeAt(0)})))},buffer2Str=function(e){if(arrayable(e)||objectable(e)||stringable(e)){typeis(e)===Types.string&&(e=JSON.parse.call(null,e));var r=Object.values(e);if(arrayable(r))return decodeURIComponent(escape(_atob(String.fromCharCode.apply(null,Array.prototype.map.call(new Uint8Array(r),(function(e){return e}))))))}},formatNumber=function(e){return(e=e.toString())[1]?e:"0"+e},dateable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.date&&(!r||"Invalid Date"!==e.toString())},formatDate=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd hh:mm:ss",t=String.prototype.constructor();if(typeis(e)!==Types.date&&!stringable(e))return t;if(typeis(e)===Types.string&&(e=new Date(e)),"Invalid Date"===e.toString())return t;for(var n=e,o={Y:n.getFullYear(),M:n.getMonth()+1,D:n.getDate(),h:n.getHours(),m:n.getMinutes(),s:n.getSeconds()},a=0,i=Object.keys(o).length>>>0;a0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,i=arguments.length>6?arguments[6]:void 0;if([e,r,t,n,o,a].every((function(e){return typeis(e)===Types.number&&e>=0}))){var u=new Date(Date.UTC(e,r-1,t,n,o,a)),l=new Date(u.toLocaleString("en-US",{timeZone:"UTC"})),y=u;if(stringable(i))y=new Date(u.toLocaleString("en-US",{timeZone:i}));else if("Invalid Date"===(y=new Date("".concat(r,"/").concat(t,"/").concat(e," ").concat(n,":").concat(o,":").concat(a))).toString())return;var c=l.getTime()-y.getTime();return u.setTime(u.getTime()+c),u}},quarterable=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Q",n=Array(2).fill(String.prototype.constructor()),o=new RegExp("^\\d{4}".concat(t,"\\d$"),"g");if(stringable(e)&&o.test(e)){var a=e.split(t),i=_slicedToArray(a,2),u=i[0],l=i[1];if(isNumberic(u)&&isNumberic(l)){var y=+l+ +r,c=4*+u+y;return y%4==0?(n[0]=0===y?u-1:+u+y/4-1,n[1]=4):(n[1]=c%4,n[0]=(c-n[1])/4),n.join(t)}}},mappable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.map&&(!r||e.size>0)},DecimalMathCalcType;!function(e){e.round="round",e.ceil="ceil",e.floor="floor",e.trunc="trunc"}(DecimalMathCalcType||(DecimalMathCalcType={}));var Decimal=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"powers",void 0),void 0===Math.trunc&&(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),this.powers=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,1e22]}return _createClass(e,[{key:"intpow10",value:function(e){return e<0||e>22?Math.pow(10,e):this.powers[e]}},{key:"isRound",value:function(e,r){var t=this.intpow10(r);return Math.round(e*t)/t===e}},{key:"decimalAdjust",value:function(e,r,t){if("round"!==e&&this.isRound(r,t||0))return r;var n=this.intpow10(t||0),o=r*n*(1+Number.EPSILON);return Math[e](o)/n}},{key:"round",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r)}},{key:"ceil",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.ceil,e,r)}},{key:"floor",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.floor,e,r)}},{key:"trunc",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.trunc,e,r)}},{key:"toFixed",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r).toFixed(r)}}]),e}(),rangeRandom=function(e,r){return!isNumberic(e)||!isNumberic(r)||e>r?Math.random():Math.random()*(r-e)+e},numberic=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(isNumberic(e,void 0,!1)){var t=+e,n=Math.sign(t);return r=isNumberic(r,!0)?r:2,(new Decimal).round(Math.abs(t),r)*n}},guid=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz0123456789",t=r.split("");return t.length||(t="abcdefghijklmnopqrstuvwxyz0123456789".split("")),_toConsumableArray(Array(e)).map((function(e){return t[Math.random()*t.length|0]})).join("")},hash=function(){return(16777215*Math.random()<<7).toString(16)},numberFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=arguments.length>2?arguments[2]:void 0,n=numberic(e,r);if(void 0!==n)return(t=isNumberic(t,!0)?t:r)>0?n.toFixed(t):e},moneyFormat=function(e){var r,t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,o=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return isNumberic(e)?(o=isNumberic(o,!0)?o:n,null!==(r=null===(t=numberic(e,n))||void 0===t?void 0:t.toLocaleString(void 0,{minimumFractionDigits:o,maximumFractionDigits:o}))&&void 0!==r?r:a):a},signFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return isNumberic(e)?"".concat(e>0?"+":e<0?"-":"").concat(Math.abs(e)):r},sleep=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16;return new Promise((function(r){return setTimeout(r,e)}))},settable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===Types.set&&(!r||e.size>0)},PromiseStatus;!function(e){e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected"}(PromiseStatus||(PromiseStatus={}));var PromisePolyfill=function(){function e(r){var t=this;_classCallCheck(this,e),_defineProperty(this,"status",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"reason",void 0),_defineProperty(this,"onResolvedClosures",void 0),_defineProperty(this,"onRejectedClosures",void 0),this.status=PromiseStatus.pending,this.value=void 0,this.reason=void 0,this.onResolvedClosures=[],this.onRejectedClosures=[];var n=function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.rejected,t.reason=e,t.onRejectedClosures.forEach((function(e){return e()})))};try{r((function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.fulfilled,t.value=e,t.onResolvedClosures.forEach((function(e){return e()})))}),n)}catch(e){n(e)}}return _createClass(e,[{key:"then",value:function(r,t){var n=this;r="function"==typeof r?r:function(e){return e},t="function"==typeof t?t:function(e){throw e};var o=new e((function(e,a){n.status===PromiseStatus.fulfilled&µ((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(n.value);resolvePromise(o,i,e,a)}catch(e){a(e)}})),n.status===PromiseStatus.rejected&µ((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(n.reason);resolvePromise(o,i,e,a)}catch(e){a(e)}})),n.status===PromiseStatus.pending&&(n.onResolvedClosures.push((function(){micro((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(n.value);resolvePromise(o,i,e,a)}catch(e){a(e)}}))})),n.onRejectedClosures.push((function(){micro((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(n.reason);resolvePromise(o,i,e,a)}catch(e){a(e)}}))})))}));return o}},{key:"catch",value:function(e){return this.then(void 0,e)}}]),e}();function micro(e){return"undefined"!=typeof window?window.queueMicrotask(e):process.nextTick(e)}function resolvePromise(e,r,t,n){if(r===e)return n(new TypeError("Chaining cycle detected for promise"));var o=!1;if(null===r||"object"!==_typeof(r)&&"function"!=typeof r)t(r);else try{var a=r.then;"function"==typeof a?a.call(r,(function(r){o||(o=!0,resolvePromise(e,r,t,n))}),(function(e){o||(o=!0,n(e))})):t(r)}catch(e){if(o)return;o=!0,n(e)}}_defineProperty(PromisePolyfill,"resolve",void 0),_defineProperty(PromisePolyfill,"reject",void 0),_defineProperty(PromisePolyfill,"race",void 0),_defineProperty(PromisePolyfill,"all",void 0),_defineProperty(PromisePolyfill,"deferred",void 0),PromisePolyfill.resolve=function(e){return new PromisePolyfill((function(r,t){return r(e)}))},PromisePolyfill.reject=function(e){return new PromisePolyfill((function(r,t){return t(e)}))},PromisePolyfill.race=function(e){return new PromisePolyfill((function(r,t){for(var n=0;n2&&void 0!==arguments[2]&&arguments[2];if(typeis(e)!==Types.function&&typeis(e)!==Types.asyncFunction)throw new TypeError("Expected a function");if(!isNumberic(r,!0))throw new TypeError("Expected a numberic time");var a=function(){for(var a=arguments.length,i=new Array(a),u=0;uu?(a&&(clearTimeout(a),a=null),l=c,e.apply(y,n)):a||!1===(null==t?void 0:t.trailing)||(a=setTimeout((function(){l=!1===(null==t?void 0:t.leading)?0:(new Date).getTime(),a=null,e.apply(y,n)}),s)),i};return y.cancel=function(){a&&clearTimeout(a),l=0,a=null},y},_TypedCopyMap,TypedArrayMap={"[object Float32Array]":Float32Array,"[object Float64Array]":Float64Array,"[object Int8Array]":Int8Array,"[object Int16Array]":Int16Array,"[object Int32Array]":Int32Array,"[object Uint8Array]":Uint8Array,"[object Uint16Array]":Uint16Array,"[object Uint32Array]":Uint32Array,"[object Uint8ClampedArray]":Uint8ClampedArray},TypedCopyMap=(_TypedCopyMap={},_defineProperty(_TypedCopyMap,Types.date,copyDate),_defineProperty(_TypedCopyMap,Types.arrayBuffer,copyArrayBuffer),_defineProperty(_TypedCopyMap,Types.dataView,copyDataView),_defineProperty(_TypedCopyMap,Types.float32Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.float64Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.int8Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.int16Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.int32Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint8Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint8ClampedArray,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint16Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.uint32Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.bigInt64Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.bigUint64Array,copyTypedArray),_defineProperty(_TypedCopyMap,Types.regExp,copyRegExp),_TypedCopyMap),copy=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=function e(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,o=r;if(isNull(o))return o;if(TypedCopyMap[typeis(o)])return TypedCopyMap[typeis(o)](r);if(n.get(o))return n.get(o);if(arrayable(r,!1)){var a=Array.prototype.constructor();return n.set(o,a),r.map((function(e){return a.push(e)})),t?a.map((function(r){return e(r,t,n)})):a}if(objectable(r,!1)){var i=Object.prototype.constructor();for(var u in n.set(o,i),r)Object.prototype.hasOwnProperty.call(r,u)&&(i[u]=r[u]);if(!t)return i;for(var l in i)Object.prototype.hasOwnProperty.call(i,l)&&(i[l]=e(i[l],t,n));return i}return r};return t.call(null,e,r)};function copyArrayBuffer(e){var r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e)),r}function copyDataView(e){var r=copyArrayBuffer(e.buffer);return new DataView(r,e.byteOffset,e.byteLength)}function copyDate(e){return new Date(e.getTime())}function copyRegExp(e){var r=new RegExp(e.source,e.flags);return r.lastIndex=e.lastIndex,r}function copyTypedArray(e){try{TypedArrayMap["[object BigInt64Array]"]=BigInt64Array,TypedArrayMap["[object BigUint64Array]"]=BigUint64Array}catch(e){}var r=copyArrayBuffer(e.buffer);return new(TypedArrayMap[Object.prototype.toString.call(e)])(r,e.byteOffset,e.length)}var sort=function(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"zh-Hans-CN",o=null!=e?e:"",a=null!=r?r:"",i=/[a-zA-Z0-9]/;return isNumberic(e)&&isNumberic(r)?Number(e)>Number(r)?1:Number(e)a?1:oe.length)&&(r=e.length);for(var t=0,o=new Array(r);t=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}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 a,i=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(s)throw a}}}}var stringable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.string&&(!r||e.length>0)},strLen=function(e){var r=0;if(!stringable(e))return r;for(var t=0,o=e.length;t2&&void 0!==arguments[2])||arguments[2];if(isNil(e))return!1;if(!re(kRegStartStrictNumberic,e)||re(kRegEndStrictNumberic,e))return!1;var o=+e;return!isNaN(o)&&(t?typeis(r)===exports.Types.bool?re(r?kRegSignNumberic:kRegUnSignNumberic,o):re(kRegNumberic,o):typeis(o)===exports.Types.number)},objectable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(typeis(e)!==exports.Types.object)return!1;var t=Object.getPrototypeOf(e);if(!t)return!r||Object.keys(e).length>0;if(t.constructor===Object)return!r||Object.keys(e).length>0;var o=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof o&&Object.prototype.hasOwnProperty.toString.call(o)===Object.prototype.hasOwnProperty.toString.call(Object)&&(!r||Object.keys(e).length>0)},optional=function optional(path,obj){var separator=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",rs=void 0,properties;if(!stringable(path)||!stringable(separator))return rs;var p=path,o;if(properties=-1===p.indexOf(separator)?Array.of(p):p.split(separator),isNil(obj)){try{o=isNumberic(properties[0])?eval("this[".concat(properties[0],"]")):eval("this."+properties[0])}catch(e){o=Object.prototype.constructor()}if(properties.shift(),typeis(o)===exports.Types.object);else if(typeis(o)!==exports.Types.array)return rs}else o=obj;return rs=properties.reduce((function(e,r){return objectable(e)?e[r]:arrayable(e)?isNumberic(r)?e[+r]:e[r]:e?e[r]:void 0}),o),rs},extractable=function extractable(){for(var rs=Object.prototype.constructor(),_len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];if(!arrayable(args)||args.length<2)return rs;var t=Array.prototype.slice.call(args,-1)[0];if(typeis(t)===exports.Types.string)try{t=eval("this."+t)}catch(e){t=void 0}if(!objectable(t))return rs;var o=Array.prototype.slice.apply(args,[0,-1]),_iterator=_createForOfIteratorHelper(o),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var i=_step.value;typeis(i)===exports.Types.string?rs[i]=optional(i,t)||String.prototype.constructor():typeis(i)===exports.Types.array?2===i.length?rs[i[0]]=(typeis(i[1])===exports.Types.string?optional(i[1],t):i[1])||String.prototype.constructor():3===i.length&&(rs[i[0]]=objectable(i[2])||arrayable(i[2])?optional(i[1],i[2]):String.prototype.constructor()):typeis(i)===exports.Types.object&&(rs=Object.assign(rs,i))}}catch(e){_iterator.e(e)}finally{_iterator.f()}return rs},assign=function e(r,t,o){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";typeis(t)!==exports.Types.object&&typeis(t)!==exports.Types.array&&typeis(t)!==exports.Types.unknown||(stringable(r)||arrayable(r))&&(stringable(r)&&(r=r.split(n)),r.length>1?e(r,t[r.shift()],o):t[r[0]]=o)},objReverse=function(e){if(!objectable(e))return e;var r=e,t=Object.keys(r).reduce((function(e,t){var o=String(r[t]),n=[];return arrayable(e[o],!1)&&(n=e[o]),Object.assign(e,_defineProperty({},o,n.concat(t)))}),{});for(var o in t)t.hasOwnProperty(o)&&(t[o]=Array.isArray(t[o])&&1===t[o].length?t[o][0]:t[o]);return t},TypesDesc,Types;exports.TypesDesc=void 0,TypesDesc=exports.TypesDesc||(exports.TypesDesc={}),TypesDesc["[object Number]"]="number",TypesDesc["[object String]"]="string",TypesDesc["[object Boolean]"]="bool",TypesDesc["[object Undefined]"]="undefined",TypesDesc["[object Null]"]="null",TypesDesc["[object Array]"]="array",TypesDesc["[object Uint8Array]"]="uint8Array",TypesDesc["[object Object]"]="object",TypesDesc["[object Function]"]="function",TypesDesc["[object AsyncFunction]"]="asyncFunction",TypesDesc["[object BigInt]"]="bigInt",TypesDesc["[object Date]"]="date",TypesDesc["[object WeakMap]"]="weakMap",TypesDesc["[object Map]"]="map",TypesDesc["[object WeakSet]"]="weakSet",TypesDesc["[object ArrayBuffer]"]="arrayBuffer",TypesDesc["[object Set]"]="set",TypesDesc["[object Symbol]"]="symbol",TypesDesc["[object DataView]"]="dataView",TypesDesc["[object Float32Array]"]="float32Array",TypesDesc["[object Float64Array]"]="float64Array",TypesDesc["[object Int8Array]"]="int8Array",TypesDesc["[object Int16Array]"]="int16Array",TypesDesc["[object Int32Array]"]="int32Array",TypesDesc["[object Uint8ClampedArray]"]="uint8ClampedArray",TypesDesc["[object Uint16Array]"]="uint16Array",TypesDesc["[object Uint32Array]"]="uint32Array",TypesDesc["[object BigInt64Array]"]="bigInt64Array",TypesDesc["[object BigUint64Array]"]="bigUint64Array",TypesDesc["[object RegExp]"]="regExp",exports.Types=void 0,Types=exports.Types||(exports.Types={}),Types.number="number",Types.string="string",Types.bool="bool",Types[void 0]="undefined",Types.null="null",Types.bigInt="bigInt",Types.object="object",Types.function="function",Types.asyncFunction="asyncFunction",Types.symbol="symbol",Types.arrayBuffer="arrayBuffer",Types.regExp="regExp",Types.date="date",Types.dataView="dataView",Types.weakMap="weakMap",Types.map="map",Types.weakSet="weakSet",Types.set="set",Types.array="array",Types.uint8Array="uint8Array",Types.float32Array="float32Array",Types.float64Array="float64Array",Types.int8Array="int8Array",Types.int16Array="int16Array",Types.int32Array="int32Array",Types.uint8ClampedArray="uint8ClampedArray",Types.uint16Array="uint16Array",Types.uint32Array="uint32Array",Types.bigInt64Array="bigInt64Array",Types.bigUint64Array="bigUint64Array",Types.unknown="";var inEnum=function(e,r){return!(!objectable(e)||e!==Object(e))&&(Object.prototype.hasOwnProperty.call(e,r)||Object.values(e).indexOf(r)>-1)},typeis=function(e){var r=Object.prototype.toString.call(e);if("[object Object]"===r){var t=Object.getPrototypeOf(e);if(t&&t.constructor!==Object)return exports.Types.unknown}var o=exports.Types.unknown;return Object.keys(exports.TypesDesc).includes(r)&&(o=exports.Types[exports.TypesDesc[r]]),o},re=function(e,r){return e.test(r.toString())},arrayable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(typeis(e)===exports.Types.array||typeis(e)===exports.Types.uint8Array)&&(!r||e.length>0)},arrayUnique=function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!arrayable(e))return e;if(r){var t=e.map((function(e){return JSON.stringify(e)}));return Array.from(new Set(t)).map((function(e){return JSON.parse(e)}))}return Array.from(new Set(e))},arrValsCount=function(e){var r={};return arrayable(e)?e.reduce((function(e,r){var t=r+"";return e[t]?e[t]++:e[t]=1,e}),r):r},arrValCount=function(e,r){if(!arrayable(e)||!e.includes(r))return 0;var t=arrValsCount(e),o=r+"";return t.hasOwnProperty(o)?t[o]:0},flat=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,o=Array.prototype.constructor();if(!arrayable(r,!1))return r;var n=isNaN(t)?1:Number(t);if(!n)return Array.prototype.slice.call(r);for(var a=0,i=r.length>>>0;a>8-a%1*8)){if((n=r.charCodeAt(a+=3/4))>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}return t},exports._atob=void 0,"undefined"!=typeof window&&window.atob?exports._atob=window.atob:exports._atob=function(e){var r=String(e).replace(/[=]+$/,"");if(r.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,o="",n=0,a=0,i=0;t=r.charAt(i++);~t&&(a=n%4?64*a+t:t,n++%4)?o+=String.fromCharCode(255&a>>(-2*n&6)):0)t=chars.indexOf(t);return o};var url2Blob=function(e){if("undefined"==typeof window)throw new Error("url2Blob only works in browser environment");if(!stringable(e))throw new TypeError(e+" can not be null");var r=e.split(",");if(!arrayable(r))throw new ReferenceError("invalid data url");var t=r[0].match(/:(.*?);/);if(!arrayable(t)||t.length<2)throw new ReferenceError("invalid data format");for(var o=t,n=exports._atob(r[1]),a=n.length,i=new Uint8Array(a);a--;)i[a]=n.charCodeAt(a);return new Blob([i],{type:o[1]})},str2Buffer=function(e){if(stringable(e))return e=exports._btoa(unescape(encodeURIComponent(e))),new Uint8Array(Array.prototype.map.call(e,(function(e){return e.charCodeAt(0)})))},buffer2Str=function(e){if(arrayable(e)||objectable(e)||stringable(e)){typeis(e)===exports.Types.string&&(e=JSON.parse.call(null,e));var r=Object.values(e);if(arrayable(r))return decodeURIComponent(escape(exports._atob(String.fromCharCode.apply(null,Array.prototype.map.call(new Uint8Array(r),(function(e){return e}))))))}},formatNumber=function(e){return(e=e.toString())[1]?e:"0"+e},dateable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.date&&(!r||"Invalid Date"!==e.toString())},formatDate=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd hh:mm:ss",t=String.prototype.constructor();if(typeis(e)!==exports.Types.date&&!stringable(e))return t;if(typeis(e)===exports.Types.string&&(e=new Date(e)),"Invalid Date"===e.toString())return t;for(var o=e,n={Y:o.getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()},a=0,i=Object.keys(n).length>>>0;a0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,i=arguments.length>6?arguments[6]:void 0;if([e,r,t,o,n,a].every((function(e){return typeis(e)===exports.Types.number&&e>=0}))){var s=new Date(Date.UTC(e,r-1,t,o,n,a)),p=new Date(s.toLocaleString("en-US",{timeZone:"UTC"})),y=s;if(stringable(i))y=new Date(s.toLocaleString("en-US",{timeZone:i}));else if("Invalid Date"===(y=new Date("".concat(r,"/").concat(t,"/").concat(e," ").concat(o,":").concat(n,":").concat(a))).toString())return;var l=p.getTime()-y.getTime();return s.setTime(s.getTime()+l),s}},quarterable=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Q",o=Array(2).fill(String.prototype.constructor()),n=new RegExp("^\\d{4}".concat(t,"\\d$"),"g");if(stringable(e)&&n.test(e)){var a=e.split(t),i=_slicedToArray(a,2),s=i[0],p=i[1];if(isNumberic(s)&&isNumberic(p)){var y=+p+ +r,l=4*+s+y;return y%4==0?(o[0]=0===y?s-1:+s+y/4-1,o[1]=4):(o[1]=l%4,o[0]=(l-o[1])/4),o.join(t)}}},mappable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.map&&(!r||e.size>0)},DecimalMathCalcType;!function(e){e.round="round",e.ceil="ceil",e.floor="floor",e.trunc="trunc"}(DecimalMathCalcType||(DecimalMathCalcType={}));var Decimal=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"powers",void 0),void 0===Math.trunc&&(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),this.powers=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,1e22]}return _createClass(e,[{key:"intpow10",value:function(e){return e<0||e>22?Math.pow(10,e):this.powers[e]}},{key:"isRound",value:function(e,r){var t=this.intpow10(r);return Math.round(e*t)/t===e}},{key:"decimalAdjust",value:function(e,r,t){if("round"!==e&&this.isRound(r,t||0))return r;var o=this.intpow10(t||0),n=r*o*(1+Number.EPSILON);return Math[e](n)/o}},{key:"round",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r)}},{key:"ceil",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.ceil,e,r)}},{key:"floor",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.floor,e,r)}},{key:"trunc",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.trunc,e,r)}},{key:"toFixed",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r).toFixed(r)}}]),e}(),rangeRandom=function(e,r){return!isNumberic(e)||!isNumberic(r)||e>r?Math.random():Math.random()*(r-e)+e},numberic=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(isNumberic(e,void 0,!1)){var t=+e,o=Math.sign(t);return r=isNumberic(r,!0)?r:2,(new Decimal).round(Math.abs(t),r)*o}},guid=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz0123456789",t=r.split("");return t.length||(t="abcdefghijklmnopqrstuvwxyz0123456789".split("")),_toConsumableArray(Array(e)).map((function(e){return t[Math.random()*t.length|0]})).join("")},hash=function(){return(16777215*Math.random()<<7).toString(16)},numberFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=arguments.length>2?arguments[2]:void 0,o=numberic(e,r);if(void 0!==o)return(t=isNumberic(t,!0)?t:r)>0?o.toFixed(t):e},moneyFormat=function(e){var r,t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return isNumberic(e)?(n=isNumberic(n,!0)?n:o,null!==(r=null===(t=numberic(e,o))||void 0===t?void 0:t.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n}))&&void 0!==r?r:a):a},signFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return isNumberic(e)?"".concat(e>0?"+":e<0?"-":"").concat(Math.abs(e)):r},sleep=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16;return new Promise((function(r){return setTimeout(r,e)}))},settable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.set&&(!r||e.size>0)},PromiseStatus;!function(e){e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected"}(PromiseStatus||(PromiseStatus={}));var PromisePolyfill=function(){function e(r){var t=this;_classCallCheck(this,e),_defineProperty(this,"status",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"reason",void 0),_defineProperty(this,"onResolvedClosures",void 0),_defineProperty(this,"onRejectedClosures",void 0),this.status=PromiseStatus.pending,this.value=void 0,this.reason=void 0,this.onResolvedClosures=[],this.onRejectedClosures=[];var o=function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.rejected,t.reason=e,t.onRejectedClosures.forEach((function(e){return e()})))};try{r((function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.fulfilled,t.value=e,t.onResolvedClosures.forEach((function(e){return e()})))}),o)}catch(e){o(e)}}return _createClass(e,[{key:"then",value:function(r,t){var o=this;r="function"==typeof r?r:function(e){return e},t="function"==typeof t?t:function(e){throw e};var n=new e((function(e,a){o.status===PromiseStatus.fulfilled&µ((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.rejected&µ((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.pending&&(o.onResolvedClosures.push((function(){micro((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})),o.onRejectedClosures.push((function(){micro((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})))}));return n}},{key:"catch",value:function(e){return this.then(void 0,e)}}]),e}();function micro(e){return"undefined"!=typeof window?window.queueMicrotask(e):process.nextTick(e)}function resolvePromise(e,r,t,o){if(r===e)return o(new TypeError("Chaining cycle detected for promise"));var n=!1;if(null===r||"object"!==_typeof(r)&&"function"!=typeof r)t(r);else try{var a=r.then;"function"==typeof a?a.call(r,(function(r){n||(n=!0,resolvePromise(e,r,t,o))}),(function(e){n||(n=!0,o(e))})):t(r)}catch(e){if(n)return;n=!0,o(e)}}_defineProperty(PromisePolyfill,"resolve",void 0),_defineProperty(PromisePolyfill,"reject",void 0),_defineProperty(PromisePolyfill,"race",void 0),_defineProperty(PromisePolyfill,"all",void 0),_defineProperty(PromisePolyfill,"deferred",void 0),PromisePolyfill.resolve=function(e){return new PromisePolyfill((function(r,t){return r(e)}))},PromisePolyfill.reject=function(e){return new PromisePolyfill((function(r,t){return t(e)}))},PromisePolyfill.race=function(e){return new PromisePolyfill((function(r,t){for(var o=0;o2&&void 0!==arguments[2]&&arguments[2];if(typeis(e)!==exports.Types.function&&typeis(e)!==exports.Types.asyncFunction)throw new TypeError("Expected a function");if(!isNumberic(r,!0))throw new TypeError("Expected a numberic time");var a=function(){for(var a=arguments.length,i=new Array(a),s=0;ss?(a&&(clearTimeout(a),a=null),p=l,e.apply(y,o)):a||!1===(null==t?void 0:t.trailing)||(a=setTimeout((function(){p=!1===(null==t?void 0:t.leading)?0:(new Date).getTime(),a=null,e.apply(y,o)}),u)),i};return y.cancel=function(){a&&clearTimeout(a),p=0,a=null},y},_TypedCopyMap,TypedArrayMap={"[object Float32Array]":Float32Array,"[object Float64Array]":Float64Array,"[object Int8Array]":Int8Array,"[object Int16Array]":Int16Array,"[object Int32Array]":Int32Array,"[object Uint8Array]":Uint8Array,"[object Uint16Array]":Uint16Array,"[object Uint32Array]":Uint32Array,"[object Uint8ClampedArray]":Uint8ClampedArray},TypedCopyMap=(_TypedCopyMap={},_defineProperty(_TypedCopyMap,exports.Types.date,copyDate),_defineProperty(_TypedCopyMap,exports.Types.arrayBuffer,copyArrayBuffer),_defineProperty(_TypedCopyMap,exports.Types.dataView,copyDataView),_defineProperty(_TypedCopyMap,exports.Types.float32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.float64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8ClampedArray,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigInt64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigUint64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.regExp,copyRegExp),_TypedCopyMap),copy=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=function e(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,n=r;if(isNull(n))return n;if(TypedCopyMap[typeis(n)])return TypedCopyMap[typeis(n)](r);if(o.get(n))return o.get(n);if(arrayable(r)){var a=Array.prototype.constructor();return o.set(n,a),r.map((function(e){return a.push(e)})),t?a.map((function(r){return e(r,t,o)})):a}if(objectable(r)){var i=Object.prototype.constructor();for(var s in o.set(n,i),r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s]);if(!t)return i;for(var p in i)Object.prototype.hasOwnProperty.call(i,p)&&(i[p]=e(i[p],t,o));return i}return r};return t.call(null,e,r)};function copyArrayBuffer(e){var r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e)),r}function copyDataView(e){var r=copyArrayBuffer(e.buffer);return new DataView(r,e.byteOffset,e.byteLength)}function copyDate(e){return new Date(e.getTime())}function copyRegExp(e){var r=new RegExp(e.source,e.flags);return r.lastIndex=e.lastIndex,r}function copyTypedArray(e){try{TypedArrayMap["[object BigInt64Array]"]=BigInt64Array,TypedArrayMap["[object BigUint64Array]"]=BigUint64Array}catch(e){}var r=copyArrayBuffer(e.buffer);return new(TypedArrayMap[Object.prototype.toString.call(e)])(r,e.byteOffset,e.length)}var sort=function(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"zh-Hans-CN",n=null!=e?e:"",a=null!=r?r:"",i=/[a-zA-Z0-9]/;return isNumberic(e)&&isNumberic(r)?Number(e)>Number(r)?1:Number(e)a?1:ne.length)&&(r=e.length);for(var t=0,o=new Array(r);t=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}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 a,i=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(s)throw a}}}}var stringable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.string&&(!r||e.length>0)},strLen=function(e){var r=0;if(!stringable(e))return r;for(var t=0,o=e.length;t2&&void 0!==arguments[2])||arguments[2];if(isNil(e))return!1;if(!re(kRegStartStrictNumberic,e)||re(kRegEndStrictNumberic,e))return!1;var o=+e;return!isNaN(o)&&(t?typeis(r)===exports.Types.bool?re(r?kRegSignNumberic:kRegUnSignNumberic,o):re(kRegNumberic,o):typeis(o)===exports.Types.number)},objectable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(typeis(e)!==exports.Types.object)return!1;var t=Object.getPrototypeOf(e);if(!t)return!r||Object.keys(e).length>0;if(t.constructor===Object)return!r||Object.keys(e).length>0;var o=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof o&&Object.prototype.hasOwnProperty.toString.call(o)===Object.prototype.hasOwnProperty.toString.call(Object)&&(!r||Object.keys(e).length>0)},optional=function optional(path,obj){var separator=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",rs=void 0,properties;if(!stringable(path)||!stringable(separator))return rs;var p=path,o;if(properties=-1===p.indexOf(separator)?Array.of(p):p.split(separator),isNil(obj)){try{o=isNumberic(properties[0])?eval("this[".concat(properties[0],"]")):eval("this."+properties[0])}catch(e){o=Object.prototype.constructor()}if(properties.shift(),typeis(o)===exports.Types.object);else if(typeis(o)!==exports.Types.array)return rs}else o=obj;return rs=properties.reduce((function(e,r){return objectable(e)?e[r]:arrayable(e)?isNumberic(r)?e[+r]:e[r]:e?e[r]:void 0}),o),rs},extractable=function extractable(){for(var rs=Object.prototype.constructor(),_len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];if(!arrayable(args)||args.length<2)return rs;var t=Array.prototype.slice.call(args,-1)[0];if(typeis(t)===exports.Types.string)try{t=eval("this."+t)}catch(e){t=void 0}if(!objectable(t))return rs;var o=Array.prototype.slice.apply(args,[0,-1]),_iterator=_createForOfIteratorHelper(o),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var i=_step.value;typeis(i)===exports.Types.string?rs[i]=optional(i,t)||String.prototype.constructor():typeis(i)===exports.Types.array?2===i.length?rs[i[0]]=(typeis(i[1])===exports.Types.string?optional(i[1],t):i[1])||String.prototype.constructor():3===i.length&&(rs[i[0]]=objectable(i[2])||arrayable(i[2])?optional(i[1],i[2]):String.prototype.constructor()):typeis(i)===exports.Types.object&&(rs=Object.assign(rs,i))}}catch(e){_iterator.e(e)}finally{_iterator.f()}return rs},assign=function e(r,t,o){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";typeis(t)!==exports.Types.object&&typeis(t)!==exports.Types.array&&typeis(t)!==exports.Types.unknown||(stringable(r)||arrayable(r))&&(stringable(r)&&(r=r.split(n)),r.length>1?e(r,t[r.shift()],o):t[r[0]]=o)},objReverse=function(e){if(!objectable(e))return e;var r=e,t=Object.keys(r).reduce((function(e,t){var o=String(r[t]),n=[];return arrayable(e[o],!1)&&(n=e[o]),Object.assign(e,_defineProperty({},o,n.concat(t)))}),{});for(var o in t)t.hasOwnProperty(o)&&(t[o]=Array.isArray(t[o])&&1===t[o].length?t[o][0]:t[o]);return t},TypesDesc,Types;exports.TypesDesc=void 0,TypesDesc=exports.TypesDesc||(exports.TypesDesc={}),TypesDesc["[object Number]"]="number",TypesDesc["[object String]"]="string",TypesDesc["[object Boolean]"]="bool",TypesDesc["[object Undefined]"]="undefined",TypesDesc["[object Null]"]="null",TypesDesc["[object Array]"]="array",TypesDesc["[object Uint8Array]"]="uint8Array",TypesDesc["[object Object]"]="object",TypesDesc["[object Function]"]="function",TypesDesc["[object AsyncFunction]"]="asyncFunction",TypesDesc["[object BigInt]"]="bigInt",TypesDesc["[object Date]"]="date",TypesDesc["[object WeakMap]"]="weakMap",TypesDesc["[object Map]"]="map",TypesDesc["[object WeakSet]"]="weakSet",TypesDesc["[object ArrayBuffer]"]="arrayBuffer",TypesDesc["[object Set]"]="set",TypesDesc["[object Symbol]"]="symbol",TypesDesc["[object DataView]"]="dataView",TypesDesc["[object Float32Array]"]="float32Array",TypesDesc["[object Float64Array]"]="float64Array",TypesDesc["[object Int8Array]"]="int8Array",TypesDesc["[object Int16Array]"]="int16Array",TypesDesc["[object Int32Array]"]="int32Array",TypesDesc["[object Uint8ClampedArray]"]="uint8ClampedArray",TypesDesc["[object Uint16Array]"]="uint16Array",TypesDesc["[object Uint32Array]"]="uint32Array",TypesDesc["[object BigInt64Array]"]="bigInt64Array",TypesDesc["[object BigUint64Array]"]="bigUint64Array",TypesDesc["[object RegExp]"]="regExp",exports.Types=void 0,Types=exports.Types||(exports.Types={}),Types.number="number",Types.string="string",Types.bool="bool",Types[void 0]="undefined",Types.null="null",Types.bigInt="bigInt",Types.object="object",Types.function="function",Types.asyncFunction="asyncFunction",Types.symbol="symbol",Types.arrayBuffer="arrayBuffer",Types.regExp="regExp",Types.date="date",Types.dataView="dataView",Types.weakMap="weakMap",Types.map="map",Types.weakSet="weakSet",Types.set="set",Types.array="array",Types.uint8Array="uint8Array",Types.float32Array="float32Array",Types.float64Array="float64Array",Types.int8Array="int8Array",Types.int16Array="int16Array",Types.int32Array="int32Array",Types.uint8ClampedArray="uint8ClampedArray",Types.uint16Array="uint16Array",Types.uint32Array="uint32Array",Types.bigInt64Array="bigInt64Array",Types.bigUint64Array="bigUint64Array",Types.unknown="";var inEnum=function(e,r){return!(!objectable(e)||e!==Object(e))&&(Object.prototype.hasOwnProperty.call(e,r)||Object.values(e).indexOf(r)>-1)},typeis=function(e){var r=Object.prototype.toString.call(e);if("[object Object]"===r){var t=Object.getPrototypeOf(e);if(t&&t.constructor!==Object)return exports.Types.unknown}var o=exports.Types.unknown;return Object.keys(exports.TypesDesc).includes(r)&&(o=exports.Types[exports.TypesDesc[r]]),o},re=function(e,r){return e.test(r.toString())},arrayable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(typeis(e)===exports.Types.array||typeis(e)===exports.Types.uint8Array)&&(!r||e.length>0)},arrayUnique=function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!arrayable(e))return e;if(r){var t=e.map((function(e){return JSON.stringify(e)}));return Array.from(new Set(t)).map((function(e){return JSON.parse(e)}))}return Array.from(new Set(e))},arrValsCount=function(e){var r={};return arrayable(e)?e.reduce((function(e,r){var t=r+"";return e[t]?e[t]++:e[t]=1,e}),r):r},arrValCount=function(e,r){if(!arrayable(e)||!e.includes(r))return 0;var t=arrValsCount(e),o=r+"";return t.hasOwnProperty(o)?t[o]:0},flat=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,o=Array.prototype.constructor();if(!arrayable(r,!1))return r;var n=isNaN(t)?1:Number(t);if(!n)return Array.prototype.slice.call(r);for(var a=0,i=r.length>>>0;a>8-a%1*8)){if((n=r.charCodeAt(a+=3/4))>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}return t},exports._atob=void 0,"undefined"!=typeof window&&window.atob?exports._atob=window.atob:exports._atob=function(e){var r=String(e).replace(/[=]+$/,"");if(r.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,o="",n=0,a=0,i=0;t=r.charAt(i++);~t&&(a=n%4?64*a+t:t,n++%4)?o+=String.fromCharCode(255&a>>(-2*n&6)):0)t=chars.indexOf(t);return o};var url2Blob=function(e){if("undefined"==typeof window)throw new Error("url2Blob only works in browser environment");if(!stringable(e))throw new TypeError(e+" can not be null");var r=e.split(",");if(!arrayable(r))throw new ReferenceError("invalid data url");var t=r[0].match(/:(.*?);/);if(!arrayable(t)||t.length<2)throw new ReferenceError("invalid data format");for(var o=t,n=exports._atob(r[1]),a=n.length,i=new Uint8Array(a);a--;)i[a]=n.charCodeAt(a);return new Blob([i],{type:o[1]})},str2Buffer=function(e){if(stringable(e))return e=exports._btoa(unescape(encodeURIComponent(e))),new Uint8Array(Array.prototype.map.call(e,(function(e){return e.charCodeAt(0)})))},buffer2Str=function(e){if(arrayable(e)||objectable(e)||stringable(e)){typeis(e)===exports.Types.string&&(e=JSON.parse.call(null,e));var r=Object.values(e);if(arrayable(r))return decodeURIComponent(escape(exports._atob(String.fromCharCode.apply(null,Array.prototype.map.call(new Uint8Array(r),(function(e){return e}))))))}},formatNumber=function(e){return(e=e.toString())[1]?e:"0"+e},dateable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.date&&(!r||"Invalid Date"!==e.toString())},formatDate=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd hh:mm:ss",t=String.prototype.constructor();if(typeis(e)!==exports.Types.date&&!stringable(e))return t;if(typeis(e)===exports.Types.string&&(e=new Date(e)),"Invalid Date"===e.toString())return t;for(var o=e,n={Y:o.getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()},a=0,i=Object.keys(n).length>>>0;a0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,i=arguments.length>6?arguments[6]:void 0;if([e,r,t,o,n,a].every((function(e){return typeis(e)===exports.Types.number&&e>=0}))){var s=new Date(Date.UTC(e,r-1,t,o,n,a)),p=new Date(s.toLocaleString("en-US",{timeZone:"UTC"})),y=s;if(stringable(i))y=new Date(s.toLocaleString("en-US",{timeZone:i}));else if("Invalid Date"===(y=new Date("".concat(r,"/").concat(t,"/").concat(e," ").concat(o,":").concat(n,":").concat(a))).toString())return;var l=p.getTime()-y.getTime();return s.setTime(s.getTime()+l),s}},quarterable=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Q",o=Array(2).fill(String.prototype.constructor()),n=new RegExp("^\\d{4}".concat(t,"\\d$"),"g");if(stringable(e)&&n.test(e)){var a=e.split(t),i=_slicedToArray(a,2),s=i[0],p=i[1];if(isNumberic(s)&&isNumberic(p)){var y=+p+ +r,l=4*+s+y;return y%4==0?(o[0]=0===y?s-1:+s+y/4-1,o[1]=4):(o[1]=l%4,o[0]=(l-o[1])/4),o.join(t)}}},mappable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.map&&(!r||e.size>0)},DecimalMathCalcType;!function(e){e.round="round",e.ceil="ceil",e.floor="floor",e.trunc="trunc"}(DecimalMathCalcType||(DecimalMathCalcType={}));var Decimal=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"powers",void 0),void 0===Math.trunc&&(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),this.powers=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,1e22]}return _createClass(e,[{key:"intpow10",value:function(e){return e<0||e>22?Math.pow(10,e):this.powers[e]}},{key:"isRound",value:function(e,r){var t=this.intpow10(r);return Math.round(e*t)/t===e}},{key:"decimalAdjust",value:function(e,r,t){if("round"!==e&&this.isRound(r,t||0))return r;var o=this.intpow10(t||0),n=r*o*(1+Number.EPSILON);return Math[e](n)/o}},{key:"round",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r)}},{key:"ceil",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.ceil,e,r)}},{key:"floor",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.floor,e,r)}},{key:"trunc",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.trunc,e,r)}},{key:"toFixed",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r).toFixed(r)}}]),e}(),rangeRandom=function(e,r){return!isNumberic(e)||!isNumberic(r)||e>r?Math.random():Math.random()*(r-e)+e},numberic=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(isNumberic(e,void 0,!1)){var t=+e,o=Math.sign(t);return r=isNumberic(r,!0)?r:2,(new Decimal).round(Math.abs(t),r)*o}},guid=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz0123456789",t=r.split("");return t.length||(t="abcdefghijklmnopqrstuvwxyz0123456789".split("")),_toConsumableArray(Array(e)).map((function(e){return t[Math.random()*t.length|0]})).join("")},hash=function(){return(16777215*Math.random()<<7).toString(16)},numberFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=arguments.length>2?arguments[2]:void 0,o=numberic(e,r);if(void 0!==o)return(t=isNumberic(t,!0)?t:r)>0?o.toFixed(t):e},moneyFormat=function(e){var r,t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return isNumberic(e)?(n=isNumberic(n,!0)?n:o,null!==(r=null===(t=numberic(e,o))||void 0===t?void 0:t.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n}))&&void 0!==r?r:a):a},signFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return isNumberic(e)?"".concat(e>0?"+":e<0?"-":"").concat(Math.abs(e)):r},sleep=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16;return new Promise((function(r){return setTimeout(r,e)}))},settable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.set&&(!r||e.size>0)},PromiseStatus;!function(e){e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected"}(PromiseStatus||(PromiseStatus={}));var PromisePolyfill=function(){function e(r){var t=this;_classCallCheck(this,e),_defineProperty(this,"status",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"reason",void 0),_defineProperty(this,"onResolvedClosures",void 0),_defineProperty(this,"onRejectedClosures",void 0),this.status=PromiseStatus.pending,this.value=void 0,this.reason=void 0,this.onResolvedClosures=[],this.onRejectedClosures=[];var o=function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.rejected,t.reason=e,t.onRejectedClosures.forEach((function(e){return e()})))};try{r((function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.fulfilled,t.value=e,t.onResolvedClosures.forEach((function(e){return e()})))}),o)}catch(e){o(e)}}return _createClass(e,[{key:"then",value:function(r,t){var o=this;r="function"==typeof r?r:function(e){return e},t="function"==typeof t?t:function(e){throw e};var n=new e((function(e,a){o.status===PromiseStatus.fulfilled&µ((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.rejected&µ((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.pending&&(o.onResolvedClosures.push((function(){micro((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})),o.onRejectedClosures.push((function(){micro((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})))}));return n}},{key:"catch",value:function(e){return this.then(void 0,e)}}]),e}();function micro(e){return"undefined"!=typeof window?window.queueMicrotask(e):process.nextTick(e)}function resolvePromise(e,r,t,o){if(r===e)return o(new TypeError("Chaining cycle detected for promise"));var n=!1;if(null===r||"object"!==_typeof(r)&&"function"!=typeof r)t(r);else try{var a=r.then;"function"==typeof a?a.call(r,(function(r){n||(n=!0,resolvePromise(e,r,t,o))}),(function(e){n||(n=!0,o(e))})):t(r)}catch(e){if(n)return;n=!0,o(e)}}_defineProperty(PromisePolyfill,"resolve",void 0),_defineProperty(PromisePolyfill,"reject",void 0),_defineProperty(PromisePolyfill,"race",void 0),_defineProperty(PromisePolyfill,"all",void 0),_defineProperty(PromisePolyfill,"deferred",void 0),PromisePolyfill.resolve=function(e){return new PromisePolyfill((function(r,t){return r(e)}))},PromisePolyfill.reject=function(e){return new PromisePolyfill((function(r,t){return t(e)}))},PromisePolyfill.race=function(e){return new PromisePolyfill((function(r,t){for(var o=0;o2&&void 0!==arguments[2]&&arguments[2];if(typeis(e)!==exports.Types.function&&typeis(e)!==exports.Types.asyncFunction)throw new TypeError("Expected a function");if(!isNumberic(r,!0))throw new TypeError("Expected a numberic time");var a=function(){for(var a=arguments.length,i=new Array(a),s=0;ss?(a&&(clearTimeout(a),a=null),p=l,e.apply(y,o)):a||!1===(null==t?void 0:t.trailing)||(a=setTimeout((function(){p=!1===(null==t?void 0:t.leading)?0:(new Date).getTime(),a=null,e.apply(y,o)}),u)),i};return y.cancel=function(){a&&clearTimeout(a),p=0,a=null},y},_TypedCopyMap,TypedArrayMap={"[object Float32Array]":Float32Array,"[object Float64Array]":Float64Array,"[object Int8Array]":Int8Array,"[object Int16Array]":Int16Array,"[object Int32Array]":Int32Array,"[object Uint8Array]":Uint8Array,"[object Uint16Array]":Uint16Array,"[object Uint32Array]":Uint32Array,"[object Uint8ClampedArray]":Uint8ClampedArray},TypedCopyMap=(_TypedCopyMap={},_defineProperty(_TypedCopyMap,exports.Types.date,copyDate),_defineProperty(_TypedCopyMap,exports.Types.arrayBuffer,copyArrayBuffer),_defineProperty(_TypedCopyMap,exports.Types.dataView,copyDataView),_defineProperty(_TypedCopyMap,exports.Types.float32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.float64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8ClampedArray,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigInt64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigUint64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.regExp,copyRegExp),_TypedCopyMap),copy=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=function e(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,n=r;if(isNull(n))return n;if(TypedCopyMap[typeis(n)])return TypedCopyMap[typeis(n)](r);if(o.get(n))return o.get(n);if(arrayable(r,!1)){var a=Array.prototype.constructor();return o.set(n,a),r.map((function(e){return a.push(e)})),t?a.map((function(r){return e(r,t,o)})):a}if(objectable(r,!1)){var i=Object.prototype.constructor();for(var s in o.set(n,i),r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s]);if(!t)return i;for(var p in i)Object.prototype.hasOwnProperty.call(i,p)&&(i[p]=e(i[p],t,o));return i}return r};return t.call(null,e,r)};function copyArrayBuffer(e){var r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e)),r}function copyDataView(e){var r=copyArrayBuffer(e.buffer);return new DataView(r,e.byteOffset,e.byteLength)}function copyDate(e){return new Date(e.getTime())}function copyRegExp(e){var r=new RegExp(e.source,e.flags);return r.lastIndex=e.lastIndex,r}function copyTypedArray(e){try{TypedArrayMap["[object BigInt64Array]"]=BigInt64Array,TypedArrayMap["[object BigUint64Array]"]=BigUint64Array}catch(e){}var r=copyArrayBuffer(e.buffer);return new(TypedArrayMap[Object.prototype.toString.call(e)])(r,e.byteOffset,e.length)}var sort=function(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"zh-Hans-CN",n=null!=e?e:"",a=null!=r?r:"",i=/[a-zA-Z0-9]/;return isNumberic(e)&&isNumberic(r)?Number(e)>Number(r)?1:Number(e)a?1:ne.length)&&(r=e.length);for(var t=0,o=new Array(r);t=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}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 a,i=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(s)throw a}}}}var stringable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.string&&(!r||e.length>0)},strLen=function(e){var r=0;if(!stringable(e))return r;for(var t=0,o=e.length;t2&&void 0!==arguments[2])||arguments[2];if(isNil(e))return!1;if(!re(kRegStartStrictNumberic,e)||re(kRegEndStrictNumberic,e))return!1;var o=+e;return!isNaN(o)&&(t?typeis(r)===exports.Types.bool?re(r?kRegSignNumberic:kRegUnSignNumberic,o):re(kRegNumberic,o):typeis(o)===exports.Types.number)},objectable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(typeis(e)!==exports.Types.object)return!1;var t=Object.getPrototypeOf(e);if(!t)return!r||Object.keys(e).length>0;if(t.constructor===Object)return!r||Object.keys(e).length>0;var o=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof o&&Object.prototype.hasOwnProperty.toString.call(o)===Object.prototype.hasOwnProperty.toString.call(Object)&&(!r||Object.keys(e).length>0)},optional=function optional(path,obj){var separator=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",rs=void 0,properties;if(!stringable(path)||!stringable(separator))return rs;var p=path,o;if(properties=-1===p.indexOf(separator)?Array.of(p):p.split(separator),isNil(obj)){try{o=isNumberic(properties[0])?eval("this[".concat(properties[0],"]")):eval("this."+properties[0])}catch(e){o=Object.prototype.constructor()}if(properties.shift(),typeis(o)===exports.Types.object);else if(typeis(o)!==exports.Types.array)return rs}else o=obj;return rs=properties.reduce((function(e,r){return objectable(e)?e[r]:arrayable(e)?isNumberic(r)?e[+r]:e[r]:e?e[r]:void 0}),o),rs},extractable=function extractable(){for(var rs=Object.prototype.constructor(),_len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];if(!arrayable(args)||args.length<2)return rs;var t=Array.prototype.slice.call(args,-1)[0];if(typeis(t)===exports.Types.string)try{t=eval("this."+t)}catch(e){t=void 0}if(!objectable(t))return rs;var o=Array.prototype.slice.apply(args,[0,-1]),_iterator=_createForOfIteratorHelper(o),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var i=_step.value;typeis(i)===exports.Types.string?rs[i]=optional(i,t)||String.prototype.constructor():typeis(i)===exports.Types.array?2===i.length?rs[i[0]]=(typeis(i[1])===exports.Types.string?optional(i[1],t):i[1])||String.prototype.constructor():3===i.length&&(rs[i[0]]=objectable(i[2])||arrayable(i[2])?optional(i[1],i[2]):String.prototype.constructor()):typeis(i)===exports.Types.object&&(rs=Object.assign(rs,i))}}catch(e){_iterator.e(e)}finally{_iterator.f()}return rs},assign=function e(r,t,o){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";typeis(t)!==exports.Types.object&&typeis(t)!==exports.Types.array&&typeis(t)!==exports.Types.unknown||(stringable(r)||arrayable(r))&&(stringable(r)&&(r=r.split(n)),r.length>1?e(r,t[r.shift()],o):t[r[0]]=o)},objReverse=function(e){if(!objectable(e))return e;var r=e,t=Object.keys(r).reduce((function(e,t){var o=String(r[t]),n=[];return arrayable(e[o],!1)&&(n=e[o]),Object.assign(e,_defineProperty({},o,n.concat(t)))}),{});for(var o in t)t.hasOwnProperty(o)&&(t[o]=Array.isArray(t[o])&&1===t[o].length?t[o][0]:t[o]);return t},TypesDesc,Types;exports.TypesDesc=void 0,TypesDesc=exports.TypesDesc||(exports.TypesDesc={}),TypesDesc["[object Number]"]="number",TypesDesc["[object String]"]="string",TypesDesc["[object Boolean]"]="bool",TypesDesc["[object Undefined]"]="undefined",TypesDesc["[object Null]"]="null",TypesDesc["[object Array]"]="array",TypesDesc["[object Uint8Array]"]="uint8Array",TypesDesc["[object Object]"]="object",TypesDesc["[object Function]"]="function",TypesDesc["[object AsyncFunction]"]="asyncFunction",TypesDesc["[object BigInt]"]="bigInt",TypesDesc["[object Date]"]="date",TypesDesc["[object WeakMap]"]="weakMap",TypesDesc["[object Map]"]="map",TypesDesc["[object WeakSet]"]="weakSet",TypesDesc["[object ArrayBuffer]"]="arrayBuffer",TypesDesc["[object Set]"]="set",TypesDesc["[object Symbol]"]="symbol",TypesDesc["[object DataView]"]="dataView",TypesDesc["[object Float32Array]"]="float32Array",TypesDesc["[object Float64Array]"]="float64Array",TypesDesc["[object Int8Array]"]="int8Array",TypesDesc["[object Int16Array]"]="int16Array",TypesDesc["[object Int32Array]"]="int32Array",TypesDesc["[object Uint8ClampedArray]"]="uint8ClampedArray",TypesDesc["[object Uint16Array]"]="uint16Array",TypesDesc["[object Uint32Array]"]="uint32Array",TypesDesc["[object BigInt64Array]"]="bigInt64Array",TypesDesc["[object BigUint64Array]"]="bigUint64Array",TypesDesc["[object RegExp]"]="regExp",exports.Types=void 0,Types=exports.Types||(exports.Types={}),Types.number="number",Types.string="string",Types.bool="bool",Types[void 0]="undefined",Types.null="null",Types.bigInt="bigInt",Types.object="object",Types.function="function",Types.asyncFunction="asyncFunction",Types.symbol="symbol",Types.arrayBuffer="arrayBuffer",Types.regExp="regExp",Types.date="date",Types.dataView="dataView",Types.weakMap="weakMap",Types.map="map",Types.weakSet="weakSet",Types.set="set",Types.array="array",Types.uint8Array="uint8Array",Types.float32Array="float32Array",Types.float64Array="float64Array",Types.int8Array="int8Array",Types.int16Array="int16Array",Types.int32Array="int32Array",Types.uint8ClampedArray="uint8ClampedArray",Types.uint16Array="uint16Array",Types.uint32Array="uint32Array",Types.bigInt64Array="bigInt64Array",Types.bigUint64Array="bigUint64Array",Types.unknown="";var inEnum=function(e,r){return!(!objectable(e)||e!==Object(e))&&(Object.prototype.hasOwnProperty.call(e,r)||Object.values(e).indexOf(r)>-1)},typeis=function(e){var r=Object.prototype.toString.call(e);if("[object Object]"===r){var t=Object.getPrototypeOf(e);if(t&&t.constructor!==Object)return exports.Types.unknown}var o=exports.Types.unknown;return Object.keys(exports.TypesDesc).includes(r)&&(o=exports.Types[exports.TypesDesc[r]]),o},re=function(e,r){return e.test(r.toString())},arrayable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(typeis(e)===exports.Types.array||typeis(e)===exports.Types.uint8Array)&&(!r||e.length>0)},arrayUnique=function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!arrayable(e))return e;if(r){var t=e.map((function(e){return JSON.stringify(e)}));return Array.from(new Set(t)).map((function(e){return JSON.parse(e)}))}return Array.from(new Set(e))},arrValsCount=function(e){var r={};return arrayable(e)?e.reduce((function(e,r){var t=r+"";return e[t]?e[t]++:e[t]=1,e}),r):r},arrValCount=function(e,r){if(!arrayable(e)||!e.includes(r))return 0;var t=arrValsCount(e),o=r+"";return t.hasOwnProperty(o)?t[o]:0},flat=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,o=Array.prototype.constructor();if(!arrayable(r,!1))return r;var n=isNaN(t)?1:Number(t);if(!n)return Array.prototype.slice.call(r);for(var a=0,i=r.length>>>0;a>8-a%1*8)){if((n=r.charCodeAt(a+=3/4))>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}return t},exports._atob=void 0,"undefined"!=typeof window&&window.atob?exports._atob=window.atob:exports._atob=function(e){var r=String(e).replace(/[=]+$/,"");if(r.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,o="",n=0,a=0,i=0;t=r.charAt(i++);~t&&(a=n%4?64*a+t:t,n++%4)?o+=String.fromCharCode(255&a>>(-2*n&6)):0)t=chars.indexOf(t);return o};var url2Blob=function(e){if("undefined"==typeof window)throw new Error("url2Blob only works in browser environment");if(!stringable(e))throw new TypeError(e+" can not be null");var r=e.split(",");if(!arrayable(r))throw new ReferenceError("invalid data url");var t=r[0].match(/:(.*?);/);if(!arrayable(t)||t.length<2)throw new ReferenceError("invalid data format");for(var o=t,n=exports._atob(r[1]),a=n.length,i=new Uint8Array(a);a--;)i[a]=n.charCodeAt(a);return new Blob([i],{type:o[1]})},str2Buffer=function(e){if(stringable(e))return e=exports._btoa(unescape(encodeURIComponent(e))),new Uint8Array(Array.prototype.map.call(e,(function(e){return e.charCodeAt(0)})))},buffer2Str=function(e){if(arrayable(e)||objectable(e)||stringable(e)){typeis(e)===exports.Types.string&&(e=JSON.parse.call(null,e));var r=Object.values(e);if(arrayable(r))return decodeURIComponent(escape(exports._atob(String.fromCharCode.apply(null,Array.prototype.map.call(new Uint8Array(r),(function(e){return e}))))))}},formatNumber=function(e){return(e=e.toString())[1]?e:"0"+e},dateable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.date&&(!r||"Invalid Date"!==e.toString())},formatDate=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd hh:mm:ss",t=String.prototype.constructor();if(typeis(e)!==exports.Types.date&&!stringable(e))return t;if(typeis(e)===exports.Types.string&&(e=new Date(e)),"Invalid Date"===e.toString())return t;for(var o=e,n={Y:o.getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()},a=0,i=Object.keys(n).length>>>0;a0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,i=arguments.length>6?arguments[6]:void 0;if([e,r,t,o,n,a].every((function(e){return typeis(e)===exports.Types.number&&e>=0}))){var s=new Date(Date.UTC(e,r-1,t,o,n,a)),p=new Date(s.toLocaleString("en-US",{timeZone:"UTC"})),y=s;if(stringable(i))y=new Date(s.toLocaleString("en-US",{timeZone:i}));else if("Invalid Date"===(y=new Date("".concat(r,"/").concat(t,"/").concat(e," ").concat(o,":").concat(n,":").concat(a))).toString())return;var l=p.getTime()-y.getTime();return s.setTime(s.getTime()+l),s}},quarterable=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Q",o=Array(2).fill(String.prototype.constructor()),n=new RegExp("^\\d{4}".concat(t,"\\d$"),"g");if(stringable(e)&&n.test(e)){var a=e.split(t),i=_slicedToArray(a,2),s=i[0],p=i[1];if(isNumberic(s)&&isNumberic(p)){var y=+p+ +r,l=4*+s+y;return y%4==0?(o[0]=0===y?s-1:+s+y/4-1,o[1]=4):(o[1]=l%4,o[0]=(l-o[1])/4),o.join(t)}}},mappable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.map&&(!r||e.size>0)},DecimalMathCalcType;!function(e){e.round="round",e.ceil="ceil",e.floor="floor",e.trunc="trunc"}(DecimalMathCalcType||(DecimalMathCalcType={}));var Decimal=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"powers",void 0),void 0===Math.trunc&&(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),this.powers=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,1e22]}return _createClass(e,[{key:"intpow10",value:function(e){return e<0||e>22?Math.pow(10,e):this.powers[e]}},{key:"isRound",value:function(e,r){var t=this.intpow10(r);return Math.round(e*t)/t===e}},{key:"decimalAdjust",value:function(e,r,t){if("round"!==e&&this.isRound(r,t||0))return r;var o=this.intpow10(t||0),n=r*o*(1+Number.EPSILON);return Math[e](n)/o}},{key:"round",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r)}},{key:"ceil",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.ceil,e,r)}},{key:"floor",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.floor,e,r)}},{key:"trunc",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.trunc,e,r)}},{key:"toFixed",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r).toFixed(r)}}]),e}(),rangeRandom=function(e,r){return!isNumberic(e)||!isNumberic(r)||e>r?Math.random():Math.random()*(r-e)+e},numberic=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(isNumberic(e,void 0,!1)){var t=+e,o=Math.sign(t);return r=isNumberic(r,!0)?r:2,(new Decimal).round(Math.abs(t),r)*o}},guid=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz0123456789",t=r.split("");return t.length||(t="abcdefghijklmnopqrstuvwxyz0123456789".split("")),_toConsumableArray(Array(e)).map((function(e){return t[Math.random()*t.length|0]})).join("")},hash=function(){return(16777215*Math.random()<<7).toString(16)},numberFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=arguments.length>2?arguments[2]:void 0,o=numberic(e,r);if(void 0!==o)return(t=isNumberic(t,!0)?t:r)>0?o.toFixed(t):e},moneyFormat=function(e){var r,t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return isNumberic(e)?(n=isNumberic(n,!0)?n:o,null!==(r=null===(t=numberic(e,o))||void 0===t?void 0:t.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n}))&&void 0!==r?r:a):a},signFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return isNumberic(e)?"".concat(e>0?"+":e<0?"-":"").concat(Math.abs(e)):r},sleep=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16;return new Promise((function(r){return setTimeout(r,e)}))},settable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.set&&(!r||e.size>0)},PromiseStatus;!function(e){e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected"}(PromiseStatus||(PromiseStatus={}));var PromisePolyfill=function(){function e(r){var t=this;_classCallCheck(this,e),_defineProperty(this,"status",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"reason",void 0),_defineProperty(this,"onResolvedClosures",void 0),_defineProperty(this,"onRejectedClosures",void 0),this.status=PromiseStatus.pending,this.value=void 0,this.reason=void 0,this.onResolvedClosures=[],this.onRejectedClosures=[];var o=function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.rejected,t.reason=e,t.onRejectedClosures.forEach((function(e){return e()})))};try{r((function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.fulfilled,t.value=e,t.onResolvedClosures.forEach((function(e){return e()})))}),o)}catch(e){o(e)}}return _createClass(e,[{key:"then",value:function(r,t){var o=this;r="function"==typeof r?r:function(e){return e},t="function"==typeof t?t:function(e){throw e};var n=new e((function(e,a){o.status===PromiseStatus.fulfilled&µ((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.rejected&µ((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.pending&&(o.onResolvedClosures.push((function(){micro((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})),o.onRejectedClosures.push((function(){micro((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})))}));return n}},{key:"catch",value:function(e){return this.then(void 0,e)}}]),e}();function micro(e){return"undefined"!=typeof window?window.queueMicrotask(e):process.nextTick(e)}function resolvePromise(e,r,t,o){if(r===e)return o(new TypeError("Chaining cycle detected for promise"));var n=!1;if(null===r||"object"!==_typeof(r)&&"function"!=typeof r)t(r);else try{var a=r.then;"function"==typeof a?a.call(r,(function(r){n||(n=!0,resolvePromise(e,r,t,o))}),(function(e){n||(n=!0,o(e))})):t(r)}catch(e){if(n)return;n=!0,o(e)}}_defineProperty(PromisePolyfill,"resolve",void 0),_defineProperty(PromisePolyfill,"reject",void 0),_defineProperty(PromisePolyfill,"race",void 0),_defineProperty(PromisePolyfill,"all",void 0),_defineProperty(PromisePolyfill,"deferred",void 0),PromisePolyfill.resolve=function(e){return new PromisePolyfill((function(r,t){return r(e)}))},PromisePolyfill.reject=function(e){return new PromisePolyfill((function(r,t){return t(e)}))},PromisePolyfill.race=function(e){return new PromisePolyfill((function(r,t){for(var o=0;o2&&void 0!==arguments[2]&&arguments[2];if(typeis(e)!==exports.Types.function&&typeis(e)!==exports.Types.asyncFunction)throw new TypeError("Expected a function");if(!isNumberic(r,!0))throw new TypeError("Expected a numberic time");var a=function(){for(var a=arguments.length,i=new Array(a),s=0;ss?(a&&(clearTimeout(a),a=null),p=l,e.apply(y,o)):a||!1===(null==t?void 0:t.trailing)||(a=setTimeout((function(){p=!1===(null==t?void 0:t.leading)?0:(new Date).getTime(),a=null,e.apply(y,o)}),u)),i};return y.cancel=function(){a&&clearTimeout(a),p=0,a=null},y},_TypedCopyMap,TypedArrayMap={"[object Float32Array]":Float32Array,"[object Float64Array]":Float64Array,"[object Int8Array]":Int8Array,"[object Int16Array]":Int16Array,"[object Int32Array]":Int32Array,"[object Uint8Array]":Uint8Array,"[object Uint16Array]":Uint16Array,"[object Uint32Array]":Uint32Array,"[object Uint8ClampedArray]":Uint8ClampedArray},TypedCopyMap=(_TypedCopyMap={},_defineProperty(_TypedCopyMap,exports.Types.date,copyDate),_defineProperty(_TypedCopyMap,exports.Types.arrayBuffer,copyArrayBuffer),_defineProperty(_TypedCopyMap,exports.Types.dataView,copyDataView),_defineProperty(_TypedCopyMap,exports.Types.float32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.float64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8ClampedArray,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigInt64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigUint64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.regExp,copyRegExp),_TypedCopyMap),copy=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=function e(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,n=r;if(isNull(n))return n;if(TypedCopyMap[typeis(n)])return TypedCopyMap[typeis(n)](r);if(o.get(n))return o.get(n);if(arrayable(r)){var a=Array.prototype.constructor();return o.set(n,a),r.map((function(e){return a.push(e)})),t?a.map((function(r){return e(r,t,o)})):a}if(objectable(r)){var i=Object.prototype.constructor();for(var s in o.set(n,i),r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s]);if(!t)return i;for(var p in i)Object.prototype.hasOwnProperty.call(i,p)&&(i[p]=e(i[p],t,o));return i}return r};return t.call(null,e,r)};function copyArrayBuffer(e){var r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e)),r}function copyDataView(e){var r=copyArrayBuffer(e.buffer);return new DataView(r,e.byteOffset,e.byteLength)}function copyDate(e){return new Date(e.getTime())}function copyRegExp(e){var r=new RegExp(e.source,e.flags);return r.lastIndex=e.lastIndex,r}function copyTypedArray(e){try{TypedArrayMap["[object BigInt64Array]"]=BigInt64Array,TypedArrayMap["[object BigUint64Array]"]=BigUint64Array}catch(e){}var r=copyArrayBuffer(e.buffer);return new(TypedArrayMap[Object.prototype.toString.call(e)])(r,e.byteOffset,e.length)}var sort=function(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"zh-Hans-CN",n=null!=e?e:"",a=null!=r?r:"",i=/[a-zA-Z0-9]/;return isNumberic(e)&&isNumberic(r)?Number(e)>Number(r)?1:Number(e)a?1:ne.length)&&(r=e.length);for(var t=0,o=new Array(r);t=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:n}}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 a,i=!0,s=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){s=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(s)throw a}}}}var stringable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.string&&(!r||e.length>0)},strLen=function(e){var r=0;if(!stringable(e))return r;for(var t=0,o=e.length;t2&&void 0!==arguments[2])||arguments[2];if(isNil(e))return!1;if(!re(kRegStartStrictNumberic,e)||re(kRegEndStrictNumberic,e))return!1;var o=+e;return!isNaN(o)&&(t?typeis(r)===exports.Types.bool?re(r?kRegSignNumberic:kRegUnSignNumberic,o):re(kRegNumberic,o):typeis(o)===exports.Types.number)},objectable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(typeis(e)!==exports.Types.object)return!1;var t=Object.getPrototypeOf(e);if(!t)return!r||Object.keys(e).length>0;if(t.constructor===Object)return!r||Object.keys(e).length>0;var o=Object.prototype.hasOwnProperty.call(t,"constructor")&&t.constructor;return"function"==typeof o&&Object.prototype.hasOwnProperty.toString.call(o)===Object.prototype.hasOwnProperty.toString.call(Object)&&(!r||Object.keys(e).length>0)},optional=function optional(path,obj){var separator=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".",rs=void 0,properties;if(!stringable(path)||!stringable(separator))return rs;var p=path,o;if(properties=-1===p.indexOf(separator)?Array.of(p):p.split(separator),isNil(obj)){try{o=isNumberic(properties[0])?eval("this[".concat(properties[0],"]")):eval("this."+properties[0])}catch(e){o=Object.prototype.constructor()}if(properties.shift(),typeis(o)===exports.Types.object);else if(typeis(o)!==exports.Types.array)return rs}else o=obj;return rs=properties.reduce((function(e,r){return objectable(e)?e[r]:arrayable(e)?isNumberic(r)?e[+r]:e[r]:e?e[r]:void 0}),o),rs},extractable=function extractable(){for(var rs=Object.prototype.constructor(),_len=arguments.length,args=new Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];if(!arrayable(args)||args.length<2)return rs;var t=Array.prototype.slice.call(args,-1)[0];if(typeis(t)===exports.Types.string)try{t=eval("this."+t)}catch(e){t=void 0}if(!objectable(t))return rs;var o=Array.prototype.slice.apply(args,[0,-1]),_iterator=_createForOfIteratorHelper(o),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var i=_step.value;typeis(i)===exports.Types.string?rs[i]=optional(i,t)||String.prototype.constructor():typeis(i)===exports.Types.array?2===i.length?rs[i[0]]=(typeis(i[1])===exports.Types.string?optional(i[1],t):i[1])||String.prototype.constructor():3===i.length&&(rs[i[0]]=objectable(i[2])||arrayable(i[2])?optional(i[1],i[2]):String.prototype.constructor()):typeis(i)===exports.Types.object&&(rs=Object.assign(rs,i))}}catch(e){_iterator.e(e)}finally{_iterator.f()}return rs},assign=function e(r,t,o){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".";typeis(t)!==exports.Types.object&&typeis(t)!==exports.Types.array&&typeis(t)!==exports.Types.unknown||(stringable(r)||arrayable(r))&&(stringable(r)&&(r=r.split(n)),r.length>1?e(r,t[r.shift()],o):t[r[0]]=o)},objReverse=function(e){if(!objectable(e))return e;var r=e,t=Object.keys(r).reduce((function(e,t){var o=String(r[t]),n=[];return arrayable(e[o],!1)&&(n=e[o]),Object.assign(e,_defineProperty({},o,n.concat(t)))}),{});for(var o in t)t.hasOwnProperty(o)&&(t[o]=Array.isArray(t[o])&&1===t[o].length?t[o][0]:t[o]);return t},TypesDesc,Types;exports.TypesDesc=void 0,TypesDesc=exports.TypesDesc||(exports.TypesDesc={}),TypesDesc["[object Number]"]="number",TypesDesc["[object String]"]="string",TypesDesc["[object Boolean]"]="bool",TypesDesc["[object Undefined]"]="undefined",TypesDesc["[object Null]"]="null",TypesDesc["[object Array]"]="array",TypesDesc["[object Uint8Array]"]="uint8Array",TypesDesc["[object Object]"]="object",TypesDesc["[object Function]"]="function",TypesDesc["[object AsyncFunction]"]="asyncFunction",TypesDesc["[object BigInt]"]="bigInt",TypesDesc["[object Date]"]="date",TypesDesc["[object WeakMap]"]="weakMap",TypesDesc["[object Map]"]="map",TypesDesc["[object WeakSet]"]="weakSet",TypesDesc["[object ArrayBuffer]"]="arrayBuffer",TypesDesc["[object Set]"]="set",TypesDesc["[object Symbol]"]="symbol",TypesDesc["[object DataView]"]="dataView",TypesDesc["[object Float32Array]"]="float32Array",TypesDesc["[object Float64Array]"]="float64Array",TypesDesc["[object Int8Array]"]="int8Array",TypesDesc["[object Int16Array]"]="int16Array",TypesDesc["[object Int32Array]"]="int32Array",TypesDesc["[object Uint8ClampedArray]"]="uint8ClampedArray",TypesDesc["[object Uint16Array]"]="uint16Array",TypesDesc["[object Uint32Array]"]="uint32Array",TypesDesc["[object BigInt64Array]"]="bigInt64Array",TypesDesc["[object BigUint64Array]"]="bigUint64Array",TypesDesc["[object RegExp]"]="regExp",exports.Types=void 0,Types=exports.Types||(exports.Types={}),Types.number="number",Types.string="string",Types.bool="bool",Types[void 0]="undefined",Types.null="null",Types.bigInt="bigInt",Types.object="object",Types.function="function",Types.asyncFunction="asyncFunction",Types.symbol="symbol",Types.arrayBuffer="arrayBuffer",Types.regExp="regExp",Types.date="date",Types.dataView="dataView",Types.weakMap="weakMap",Types.map="map",Types.weakSet="weakSet",Types.set="set",Types.array="array",Types.uint8Array="uint8Array",Types.float32Array="float32Array",Types.float64Array="float64Array",Types.int8Array="int8Array",Types.int16Array="int16Array",Types.int32Array="int32Array",Types.uint8ClampedArray="uint8ClampedArray",Types.uint16Array="uint16Array",Types.uint32Array="uint32Array",Types.bigInt64Array="bigInt64Array",Types.bigUint64Array="bigUint64Array",Types.unknown="";var inEnum=function(e,r){return!(!objectable(e)||e!==Object(e))&&(Object.prototype.hasOwnProperty.call(e,r)||Object.values(e).indexOf(r)>-1)},typeis=function(e){var r=Object.prototype.toString.call(e);if("[object Object]"===r){var t=Object.getPrototypeOf(e);if(t&&t.constructor!==Object)return exports.Types.unknown}var o=exports.Types.unknown;return Object.keys(exports.TypesDesc).includes(r)&&(o=exports.Types[exports.TypesDesc[r]]),o},re=function(e,r){return e.test(r.toString())},arrayable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return(typeis(e)===exports.Types.array||typeis(e)===exports.Types.uint8Array)&&(!r||e.length>0)},arrayUnique=function(e){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!arrayable(e))return e;if(r){var t=e.map((function(e){return JSON.stringify(e)}));return Array.from(new Set(t)).map((function(e){return JSON.parse(e)}))}return Array.from(new Set(e))},arrValsCount=function(e){var r={};return arrayable(e)?e.reduce((function(e,r){var t=r+"";return e[t]?e[t]++:e[t]=1,e}),r):r},arrValCount=function(e,r){if(!arrayable(e)||!e.includes(r))return 0;var t=arrValsCount(e),o=r+"";return t.hasOwnProperty(o)?t[o]:0},flat=function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1/0,o=Array.prototype.constructor();if(!arrayable(r,!1))return r;var n=isNaN(t)?1:Number(t);if(!n)return Array.prototype.slice.call(r);for(var a=0,i=r.length>>>0;a>8-a%1*8)){if((n=r.charCodeAt(a+=3/4))>255)throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");o=o<<8|n}return t},exports._atob=void 0,"undefined"!=typeof window&&window.atob?exports._atob=window.atob:exports._atob=function(e){var r=String(e).replace(/[=]+$/,"");if(r.length%4==1)throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");for(var t,o="",n=0,a=0,i=0;t=r.charAt(i++);~t&&(a=n%4?64*a+t:t,n++%4)?o+=String.fromCharCode(255&a>>(-2*n&6)):0)t=chars.indexOf(t);return o};var url2Blob=function(e){if("undefined"==typeof window)throw new Error("url2Blob only works in browser environment");if(!stringable(e))throw new TypeError(e+" can not be null");var r=e.split(",");if(!arrayable(r))throw new ReferenceError("invalid data url");var t=r[0].match(/:(.*?);/);if(!arrayable(t)||t.length<2)throw new ReferenceError("invalid data format");for(var o=t,n=exports._atob(r[1]),a=n.length,i=new Uint8Array(a);a--;)i[a]=n.charCodeAt(a);return new Blob([i],{type:o[1]})},str2Buffer=function(e){if(stringable(e))return e=exports._btoa(unescape(encodeURIComponent(e))),new Uint8Array(Array.prototype.map.call(e,(function(e){return e.charCodeAt(0)})))},buffer2Str=function(e){if(arrayable(e)||objectable(e)||stringable(e)){typeis(e)===exports.Types.string&&(e=JSON.parse.call(null,e));var r=Object.values(e);if(arrayable(r))return decodeURIComponent(escape(exports._atob(String.fromCharCode.apply(null,Array.prototype.map.call(new Uint8Array(r),(function(e){return e}))))))}},formatNumber=function(e){return(e=e.toString())[1]?e:"0"+e},dateable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.date&&(!r||"Invalid Date"!==e.toString())},formatDate=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"yyyy-MM-dd hh:mm:ss",t=String.prototype.constructor();if(typeis(e)!==exports.Types.date&&!stringable(e))return t;if(typeis(e)===exports.Types.string&&(e=new Date(e)),"Invalid Date"===e.toString())return t;for(var o=e,n={Y:o.getFullYear(),M:o.getMonth()+1,D:o.getDate(),h:o.getHours(),m:o.getMinutes(),s:o.getSeconds()},a=0,i=Object.keys(n).length>>>0;a0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0,i=arguments.length>6?arguments[6]:void 0;if([e,r,t,o,n,a].every((function(e){return typeis(e)===exports.Types.number&&e>=0}))){var s=new Date(Date.UTC(e,r-1,t,o,n,a)),p=new Date(s.toLocaleString("en-US",{timeZone:"UTC"})),y=s;if(stringable(i))y=new Date(s.toLocaleString("en-US",{timeZone:i}));else if("Invalid Date"===(y=new Date("".concat(r,"/").concat(t,"/").concat(e," ").concat(o,":").concat(n,":").concat(a))).toString())return;var l=p.getTime()-y.getTime();return s.setTime(s.getTime()+l),s}},quarterable=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Q",o=Array(2).fill(String.prototype.constructor()),n=new RegExp("^\\d{4}".concat(t,"\\d$"),"g");if(stringable(e)&&n.test(e)){var a=e.split(t),i=_slicedToArray(a,2),s=i[0],p=i[1];if(isNumberic(s)&&isNumberic(p)){var y=+p+ +r,l=4*+s+y;return y%4==0?(o[0]=0===y?s-1:+s+y/4-1,o[1]=4):(o[1]=l%4,o[0]=(l-o[1])/4),o.join(t)}}},mappable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.map&&(!r||e.size>0)},DecimalMathCalcType;!function(e){e.round="round",e.ceil="ceil",e.floor="floor",e.trunc="trunc"}(DecimalMathCalcType||(DecimalMathCalcType={}));var Decimal=function(){function e(){_classCallCheck(this,e),_defineProperty(this,"powers",void 0),void 0===Math.trunc&&(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),this.powers=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,1e22]}return _createClass(e,[{key:"intpow10",value:function(e){return e<0||e>22?Math.pow(10,e):this.powers[e]}},{key:"isRound",value:function(e,r){var t=this.intpow10(r);return Math.round(e*t)/t===e}},{key:"decimalAdjust",value:function(e,r,t){if("round"!==e&&this.isRound(r,t||0))return r;var o=this.intpow10(t||0),n=r*o*(1+Number.EPSILON);return Math[e](n)/o}},{key:"round",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r)}},{key:"ceil",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.ceil,e,r)}},{key:"floor",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.floor,e,r)}},{key:"trunc",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.trunc,e,r)}},{key:"toFixed",value:function(e,r){return this.decimalAdjust(DecimalMathCalcType.round,e,r).toFixed(r)}}]),e}(),rangeRandom=function(e,r){return!isNumberic(e)||!isNumberic(r)||e>r?Math.random():Math.random()*(r-e)+e},numberic=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(isNumberic(e,void 0,!1)){var t=+e,o=Math.sign(t);return r=isNumberic(r,!0)?r:2,(new Decimal).round(Math.abs(t),r)*o}},guid=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz0123456789",t=r.split("");return t.length||(t="abcdefghijklmnopqrstuvwxyz0123456789".split("")),_toConsumableArray(Array(e)).map((function(e){return t[Math.random()*t.length|0]})).join("")},hash=function(){return(16777215*Math.random()<<7).toString(16)},numberFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,t=arguments.length>2?arguments[2]:void 0,o=numberic(e,r);if(void 0!==o)return(t=isNumberic(t,!0)?t:r)>0?o.toFixed(t):e},moneyFormat=function(e){var r,t,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";return isNumberic(e)?(n=isNumberic(n,!0)?n:o,null!==(r=null===(t=numberic(e,o))||void 0===t?void 0:t.toLocaleString(void 0,{minimumFractionDigits:n,maximumFractionDigits:n}))&&void 0!==r?r:a):a},signFormat=function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return isNumberic(e)?"".concat(e>0?"+":e<0?"-":"").concat(Math.abs(e)):r},sleep=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16;return new Promise((function(r){return setTimeout(r,e)}))},settable=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return typeis(e)===exports.Types.set&&(!r||e.size>0)},PromiseStatus;!function(e){e.pending="pending",e.fulfilled="fulfilled",e.rejected="rejected"}(PromiseStatus||(PromiseStatus={}));var PromisePolyfill=function(){function e(r){var t=this;_classCallCheck(this,e),_defineProperty(this,"status",void 0),_defineProperty(this,"value",void 0),_defineProperty(this,"reason",void 0),_defineProperty(this,"onResolvedClosures",void 0),_defineProperty(this,"onRejectedClosures",void 0),this.status=PromiseStatus.pending,this.value=void 0,this.reason=void 0,this.onResolvedClosures=[],this.onRejectedClosures=[];var o=function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.rejected,t.reason=e,t.onRejectedClosures.forEach((function(e){return e()})))};try{r((function(e){t.status===PromiseStatus.pending&&(t.status=PromiseStatus.fulfilled,t.value=e,t.onResolvedClosures.forEach((function(e){return e()})))}),o)}catch(e){o(e)}}return _createClass(e,[{key:"then",value:function(r,t){var o=this;r="function"==typeof r?r:function(e){return e},t="function"==typeof t?t:function(e){throw e};var n=new e((function(e,a){o.status===PromiseStatus.fulfilled&µ((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.rejected&µ((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}})),o.status===PromiseStatus.pending&&(o.onResolvedClosures.push((function(){micro((function(){try{var t,i=null===(t=r)||void 0===t?void 0:t(o.value);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})),o.onRejectedClosures.push((function(){micro((function(){try{var r,i=null===(r=t)||void 0===r?void 0:r(o.reason);resolvePromise(n,i,e,a)}catch(e){a(e)}}))})))}));return n}},{key:"catch",value:function(e){return this.then(void 0,e)}}]),e}();function micro(e){return"undefined"!=typeof window?window.queueMicrotask(e):process.nextTick(e)}function resolvePromise(e,r,t,o){if(r===e)return o(new TypeError("Chaining cycle detected for promise"));var n=!1;if(null===r||"object"!==_typeof(r)&&"function"!=typeof r)t(r);else try{var a=r.then;"function"==typeof a?a.call(r,(function(r){n||(n=!0,resolvePromise(e,r,t,o))}),(function(e){n||(n=!0,o(e))})):t(r)}catch(e){if(n)return;n=!0,o(e)}}_defineProperty(PromisePolyfill,"resolve",void 0),_defineProperty(PromisePolyfill,"reject",void 0),_defineProperty(PromisePolyfill,"race",void 0),_defineProperty(PromisePolyfill,"all",void 0),_defineProperty(PromisePolyfill,"deferred",void 0),PromisePolyfill.resolve=function(e){return new PromisePolyfill((function(r,t){return r(e)}))},PromisePolyfill.reject=function(e){return new PromisePolyfill((function(r,t){return t(e)}))},PromisePolyfill.race=function(e){return new PromisePolyfill((function(r,t){for(var o=0;o2&&void 0!==arguments[2]&&arguments[2];if(typeis(e)!==exports.Types.function&&typeis(e)!==exports.Types.asyncFunction)throw new TypeError("Expected a function");if(!isNumberic(r,!0))throw new TypeError("Expected a numberic time");var a=function(){for(var a=arguments.length,i=new Array(a),s=0;ss?(a&&(clearTimeout(a),a=null),p=l,e.apply(y,o)):a||!1===(null==t?void 0:t.trailing)||(a=setTimeout((function(){p=!1===(null==t?void 0:t.leading)?0:(new Date).getTime(),a=null,e.apply(y,o)}),u)),i};return y.cancel=function(){a&&clearTimeout(a),p=0,a=null},y},_TypedCopyMap,TypedArrayMap={"[object Float32Array]":Float32Array,"[object Float64Array]":Float64Array,"[object Int8Array]":Int8Array,"[object Int16Array]":Int16Array,"[object Int32Array]":Int32Array,"[object Uint8Array]":Uint8Array,"[object Uint16Array]":Uint16Array,"[object Uint32Array]":Uint32Array,"[object Uint8ClampedArray]":Uint8ClampedArray},TypedCopyMap=(_TypedCopyMap={},_defineProperty(_TypedCopyMap,exports.Types.date,copyDate),_defineProperty(_TypedCopyMap,exports.Types.arrayBuffer,copyArrayBuffer),_defineProperty(_TypedCopyMap,exports.Types.dataView,copyDataView),_defineProperty(_TypedCopyMap,exports.Types.float32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.float64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.int32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint8ClampedArray,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint16Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.uint32Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigInt64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.bigUint64Array,copyTypedArray),_defineProperty(_TypedCopyMap,exports.Types.regExp,copyRegExp),_TypedCopyMap),copy=function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],t=function e(r){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,n=r;if(isNull(n))return n;if(TypedCopyMap[typeis(n)])return TypedCopyMap[typeis(n)](r);if(o.get(n))return o.get(n);if(arrayable(r,!1)){var a=Array.prototype.constructor();return o.set(n,a),r.map((function(e){return a.push(e)})),t?a.map((function(r){return e(r,t,o)})):a}if(objectable(r,!1)){var i=Object.prototype.constructor();for(var s in o.set(n,i),r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s]);if(!t)return i;for(var p in i)Object.prototype.hasOwnProperty.call(i,p)&&(i[p]=e(i[p],t,o));return i}return r};return t.call(null,e,r)};function copyArrayBuffer(e){var r=new ArrayBuffer(e.byteLength);return new Uint8Array(r).set(new Uint8Array(e)),r}function copyDataView(e){var r=copyArrayBuffer(e.buffer);return new DataView(r,e.byteOffset,e.byteLength)}function copyDate(e){return new Date(e.getTime())}function copyRegExp(e){var r=new RegExp(e.source,e.flags);return r.lastIndex=e.lastIndex,r}function copyTypedArray(e){try{TypedArrayMap["[object BigInt64Array]"]=BigInt64Array,TypedArrayMap["[object BigUint64Array]"]=BigUint64Array}catch(e){}var r=copyArrayBuffer(e.buffer);return new(TypedArrayMap[Object.prototype.toString.call(e)])(r,e.byteOffset,e.length)}var sort=function(e,r){var t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"zh-Hans-CN",n=null!=e?e:"",a=null!=r?r:"",i=/[a-zA-Z0-9]/;return isNumberic(e)&&isNumberic(r)?Number(e)>Number(r)?1:Number(e)a?1:n = Array.prototype.constructor() obj.map((i: any) => cy.push(i)) return deep ? cy.map((i: any) => copy(i)) : cy } - if (objectable(obj)) { + if (objectable(obj, false)) { const cy = { ...(obj as { [key: string]: any }) } as { [key: string]: any } diff --git a/test/copy.spec.ts b/test/copy.spec.ts index 7e04dd6..fe47ef7 100644 --- a/test/copy.spec.ts +++ b/test/copy.spec.ts @@ -1,420 +1,445 @@ -import { copyArrayBuffer, copyDataView, copyDate, copyRegExp, copyTypedArray, copy } from '../' - -// Copy -describe('Copy - cases', () => { - test('Copy - copyArrayBuffer', () => { - const arrayBuffer = new ArrayBuffer(16) - const copy = copyArrayBuffer(arrayBuffer) - - expect(copy).not.toBe(arrayBuffer) - expect(Object.prototype.toString.call(copy)).toEqual("[object ArrayBuffer]") - expect(copy.byteLength).toEqual(16) - }) - - test('Copy - copyDataView', () => { - const buffer = new ArrayBuffer(16) - const view = new DataView(buffer, 0) - view.setInt16(1, 42) - const copy = copyDataView(view) - - expect(copy).not.toBe(view) - expect(Object.prototype.toString.call(copy)).toEqual("[object DataView]") - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy.getInt16(1)).toEqual(42) - }) - - test('Copy - copyDate', () => { - const date = new Date() - const copy = copyDate(date) - - expect(copy).not.toBe(date) - expect(Object.prototype.toString.call(copy)).toEqual("[object Date]") - expect(copy.getTime()).toEqual(date.getTime()) - }) - - test('Copy - copyRegExp', () => { - const regexp = new RegExp("ab+c", "i") - const copy = copyRegExp(regexp) - - expect(copy).not.toBe(regexp) - expect(Object.prototype.toString.call(copy)).toEqual("[object RegExp]") - expect(copy.source).toEqual(regexp.source) - expect(copy.flags).toEqual(regexp.flags) - expect(copy.lastIndex).toEqual(regexp.lastIndex) - }) - - test('Copy - copyTypedArray - Float32Array', () => { - const buffer = new ArrayBuffer(16) - const float32Array = new Float32Array(buffer, 0) - float32Array[0] = 42 - const copy = copyTypedArray(float32Array) - - expect(copy).not.toBe(float32Array) - expect(Object.prototype.toString.call(copy)).toEqual( - "[object Float32Array]" - ) - expect(copy.BYTES_PER_ELEMENT).toEqual(4) - expect(copy.length).toEqual(4) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Float64Array', () => { - const buffer = new ArrayBuffer(16) - const float64Array = new Float64Array(buffer, 0) - float64Array[0] = 42 - const copy = copyTypedArray(float64Array) - - expect(copy).not.toBe(float64Array) - expect(Object.prototype.toString.call(copy)).toEqual( - "[object Float64Array]" - ) - expect(copy.BYTES_PER_ELEMENT).toEqual(8) - expect(copy.length).toEqual(2) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Int8Array', () => { - const buffer = new ArrayBuffer(16) - const int8Array = new Int8Array(buffer, 0) - int8Array[0] = 42 - const copy = copyTypedArray(int8Array) - - expect(copy).not.toBe(int8Array) - expect(Object.prototype.toString.call(copy)).toEqual("[object Int8Array]") - expect(copy.BYTES_PER_ELEMENT).toEqual(1) - expect(copy.length).toEqual(16) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Int16Array', () => { - const buffer = new ArrayBuffer(16) - const int16Array = new Int16Array(buffer, 0) - int16Array[0] = 42 - const copy = copyTypedArray(int16Array) - - expect(copy).not.toBe(int16Array) - expect(Object.prototype.toString.call(copy)).toEqual("[object Int16Array]") - expect(copy.BYTES_PER_ELEMENT).toEqual(2) - expect(copy.length).toEqual(8) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Int32Array', () => { - const buffer = new ArrayBuffer(16) - const int32Array = new Int32Array(buffer, 0) - int32Array[0] = 42 - const copy = copyTypedArray(int32Array) - - expect(copy).not.toBe(int32Array) - expect(Object.prototype.toString.call(copy)).toEqual("[object Int32Array]") - expect(copy.BYTES_PER_ELEMENT).toEqual(4) - expect(copy.length).toEqual(4) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Uint8Array', () => { - const buffer = new ArrayBuffer(16) - const uint8Array = new Uint8Array(buffer, 0) - uint8Array[0] = 42 - const copy = copyTypedArray(uint8Array) - - expect(copy).not.toBe(uint8Array) - expect(Object.prototype.toString.call(copy)).toEqual("[object Uint8Array]") - expect(copy.BYTES_PER_ELEMENT).toEqual(1) - expect(copy.length).toEqual(16) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Uint16Array', () => { - const buffer = new ArrayBuffer(16) - const uint16Array = new Uint16Array(buffer, 0) - uint16Array[0] = 42 - const copy = copyTypedArray(uint16Array) - - expect(copy).not.toBe(uint16Array) - expect(Object.prototype.toString.call(copy)).toEqual( - "[object Uint16Array]" - ) - expect(copy.BYTES_PER_ELEMENT).toEqual(2) - expect(copy.length).toEqual(8) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Uint32Array', () => { - const buffer = new ArrayBuffer(16) - const uint32Array = new Uint32Array(buffer, 0) - uint32Array[0] = 42 - const copy = copyTypedArray(uint32Array) - - expect(copy).not.toBe(uint32Array) - expect(Object.prototype.toString.call(copy)).toEqual( - "[object Uint32Array]" - ) - expect(copy.BYTES_PER_ELEMENT).toEqual(4) - expect(copy.length).toEqual(4) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - Uint8ClampedArray', () => { - const buffer = new ArrayBuffer(16) - const uint8ClampedArray = new Uint8ClampedArray(buffer, 0) - uint8ClampedArray[0] = 42 - const copy = copyTypedArray(uint8ClampedArray) - - expect(copy).not.toBe(uint8ClampedArray) - expect(Object.prototype.toString.call(copy)).toEqual( - "[object Uint8ClampedArray]" - ) - expect(copy.BYTES_PER_ELEMENT).toEqual(1) - expect(copy.length).toEqual(16) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(42) - }) - - test('Copy - copyTypedArray - BigInt64Array', () => { - const buffer = new ArrayBuffer(16) - const bigInt64Array = new BigInt64Array(buffer, 0) - bigInt64Array[0] = BigInt(42) - const copy = copyTypedArray(bigInt64Array) - - expect(copy).not.toBe(bigInt64Array) - expect(Object.prototype.toString.call(copy)).toEqual( - "[object BigInt64Array]" - ) - expect(copy.BYTES_PER_ELEMENT).toEqual(8) - expect(copy.length).toEqual(2) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(BigInt(42)) - }) - - test('Copy - copyTypedArray - BigUint64Array', () => { - const buffer = new ArrayBuffer(16) - const bigUint64Array = new BigUint64Array(buffer, 0) - bigUint64Array[0] = BigInt(42) - const copy = copyTypedArray(bigUint64Array) - - expect(copy).not.toBe(bigUint64Array) - expect(Object.prototype.toString.call(copy)).toEqual( - "[object BigUint64Array]" - ) - expect(copy.BYTES_PER_ELEMENT).toEqual(8) - expect(copy.length).toEqual(2) - expect(copy.byteLength).toEqual(16) - expect(copy.byteOffset).toEqual(0) - expect(copy[0]).toEqual(BigInt(42)) - }) - - test('Copy - copy - basic', () => { - expect(copy(true)).toBe(true) - expect(copy(false)).toBe(false) - expect(copy(0.234)).toEqual(0.234) - expect(copy(0)).toEqual(0) - expect(copy(1)).toEqual(1) - expect(copy(-1)).toEqual(-1) - expect(copy(null)).toEqual(null) - expect(copy(undefined)).toEqual(undefined) - expect(copy('abc')).toEqual('abc') - // expect(copy(120n)).toEqual(120n) // @support target: ES2020 - }) - - // copy object - test('Copy - copy - object - deep: true', () => { - const obj1 = {} - expect(copy(obj1)).toEqual({}) - // reference with mutation - const obj2 = {a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}} - const obj2UnCopy = obj2 - const obj2CopyMutated = copy(obj2) - obj2UnCopy.a.c = 3 - obj2UnCopy.g.h = 7 - obj2CopyMutated.a.c = 3 - obj2CopyMutated.g.h = 7 - expect(obj2).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) - expect(obj2UnCopy).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) - expect(obj2CopyMutated).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) - - // reference without mutation - const obj3 = {a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}} - const obj3UnCopy = obj3 - const obj3CopyMutated = copy(obj3) - obj3CopyMutated.a.c = 3 - obj3CopyMutated.g.h = 7 - expect(obj3).toEqual({a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}}) - expect(obj3UnCopy).toEqual({a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}}) - expect(obj3CopyMutated).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) - }) - - test('Copy - copy - object - deep: false', () => { - const obj = {a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: 9} - const objCopy = copy(obj, false) - obj.a.c = 3 - obj.g = 10 - expect(obj).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: 10}) - expect(objCopy).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: 9}) - }) - - test('Copy - copy - regExp in an object - deep: true', () => { - const rgo = {a: 1, b: {r: new RegExp(/\d{4,}/, 'ig')}} - let rgoCopy = copy(rgo) - rgoCopy.b.r = new RegExp(/\d{5,}/, 'ig') - const rgoMutated = rgo - rgoMutated.b.r = new RegExp(/\d{6,}/, 'ig') - expect(rgoCopy).not.toBe(rgo) - expect(rgoCopy).toEqual({a: 1, b: {r: new RegExp(/\d{5,}/, 'ig')}}) - expect(rgo).toEqual({a: 1, b: {r: new RegExp(/\d{6,}/, 'ig')}}) - expect(rgoMutated).toEqual({a: 1, b: {r: new RegExp(/\d{6,}/, 'ig')}}) - }) - - test('Copy - copy - regExp in an object - deep: false', () => { - const rgo = {a: 1, b: {r: new RegExp(/\d{4,}/, 'ig')}} - let rgoCopy = copy(rgo, false) - rgoCopy.b.r = new RegExp(/\d{5,}/, 'ig') - rgoCopy.a = 2 - expect(rgoCopy).not.toBe(rgo) - expect(rgo).toEqual({a: 1, b: {r: new RegExp(/\d{5,}/, 'ig')}}) - expect(rgoCopy).toEqual({a: 2, b: {r: new RegExp(/\d{5,}/, 'ig')}}) - }) - - test('Copy - copy - Date in an object - deep: true', () => { - const dto = {a: 1, b: {r: new Date('2021-05-18')}} - let dtoCopy = copy(dto) - dtoCopy.b.r = new Date('2021-05-20') - const dtoMutated = dto - dtoMutated.b.r = new Date('2021-05-30') - expect(dtoCopy).not.toBe(dto) - expect(dtoCopy).toEqual({a: 1, b: {r: new Date('2021-05-20')}}) - expect(dto).toEqual({a: 1, b: {r: new Date('2021-05-30')}}) - expect(dtoMutated).toEqual({a: 1, b: {r: new Date('2021-05-30')}}) - }) - - test('Copy - copy - Date in an object - deep: false', () => { - const dto = {a: 1, b: {r: new Date('2021-05-18')}} - let dtoCopy = copy(dto, false) - dtoCopy.b.r = new Date('2021-05-20') - dtoCopy.a = 2 - expect(dtoCopy).not.toBe(dto) - expect(dto).toEqual({a: 1, b: {r: new Date('2021-05-20')}}) - expect(dtoCopy).toEqual({a: 2, b: {r: new Date('2021-05-20')}}) - }) - - // copy array - test('Copy - copy - array - deep: true', () => { - const arr1: number[] = [] - expect(copy(arr1)).toEqual([]) - // reference with mutation - const arr2 = [{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}] - const arr2UnCopy = arr2 - const arr2CopyMutated = copy(arr2) - arr2UnCopy[0].c = 3 - arr2UnCopy[1].h = 7 - arr2CopyMutated[0].c = 3 - arr2CopyMutated[1].h = 7 - expect(arr2).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) - expect(arr2UnCopy).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) - expect(arr2CopyMutated).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) - - // reference without mutation - const arr3 = [{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}] - const arr3UnCopy = arr3 - const arr3CopyMutated = copy(arr3) - arr3CopyMutated[0].c = 3 - arr3CopyMutated[1].h = 7 - expect(arr3).toEqual([{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}]) - expect(arr3UnCopy).toEqual([{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}]) - expect(arr3CopyMutated).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) - }) - - test('Copy - copy - array - deep: false', () => { - const arr = [[1, 2, 3, 4, 5], 9] - const arrCopy = copy(arr, false) - // @ts-ignore - arr[0][2] = 0 - arr[1] = 10 - expect(arr).toEqual([[1, 2, 0, 4, 5], 10]) - expect(arrCopy).toEqual([[1, 2, 0, 4, 5], 9]) - }) - - test('Copy - copy - regExp in an array - deep: true', () => { - const rgo = [1, {r: new RegExp(/\d{4,}/, 'ig')}] - let rgoCopy = copy(rgo) - // @ts-ignore - rgoCopy[1].r = new RegExp(/\d{5,}/, 'ig') - const rgoMutated = rgo - // @ts-ignore - rgoMutated[1].r = new RegExp(/\d{6,}/, 'ig') - expect(rgoCopy).not.toBe(rgo) - expect(rgoCopy).toEqual([1, {r: new RegExp(/\d{5,}/, 'ig')}]) - expect(rgo).toEqual([1, {r: new RegExp(/\d{6,}/, 'ig')}]) - expect(rgoMutated).toEqual([1, {r: new RegExp(/\d{6,}/, 'ig')}]) - }) - - test('Copy - copy - regExp in an array - deep: false', () => { - const rgo = [1, {r: new RegExp(/\d{4,}/, 'ig')}] - let rgoCopy = copy(rgo, false) - // @ts-ignore - rgoCopy[1].r = new RegExp(/\d{5,}/, 'ig') - // @ts-ignore - rgoCopy[0] = 2 - expect(rgoCopy).not.toBe(rgo) - expect(rgo).toEqual([1, {r: new RegExp(/\d{5,}/, 'ig')}]) - expect(rgoCopy).toEqual([2, {r: new RegExp(/\d{5,}/, 'ig')}]) - }) - - test('Copy - copy - Date in an array - deep: true', () => { - const dto = [1, {r: new Date('2021-05-18')}] - let dtoCopy = copy(dto) - // @ts-ignore - dtoCopy[1].r = new Date('2021-05-20') - const dtoMutated = dto - // @ts-ignore - dtoMutated[1].r = new Date('2021-05-30') - expect(dtoCopy).not.toBe(dto) - expect(dtoCopy).toEqual([1, {r: new Date('2021-05-20')}]) - expect(dto).toEqual([1, {r: new Date('2021-05-30')}]) - expect(dtoMutated).toEqual([1, {r: new Date('2021-05-30')}]) - }) - - test('Copy - copy - Date in an array - deep: false', () => { - const dto = [1, {r: new Date('2021-05-18')}] - let dtoCopy = copy(dto, false) - dtoCopy[1].r = new Date('2021-05-20') - dtoCopy[0] = 2 - expect(dtoCopy).not.toBe(dto) - expect(dto).toEqual([1, {r: new Date('2021-05-20')}]) - expect(dtoCopy).toEqual([2, {r: new Date('2021-05-20')}]) - }) - - test('Copy - recursive copy', () => { - type O = { - k: number, - r: any - } - const o: O = { - k: 1, - r: void 0 - } - o.r = o - const co = copy(o) - expect(co).not.toBe(o) - }) - -}) +import { copyArrayBuffer, copyDataView, copyDate, copyRegExp, copyTypedArray, copy } from '../' + +// Copy +describe('Copy - cases', () => { + test('Copy - copyArrayBuffer', () => { + const arrayBuffer = new ArrayBuffer(16) + const copy = copyArrayBuffer(arrayBuffer) + + expect(copy).not.toBe(arrayBuffer) + expect(Object.prototype.toString.call(copy)).toEqual("[object ArrayBuffer]") + expect(copy.byteLength).toEqual(16) + }) + + test('Copy - copyDataView', () => { + const buffer = new ArrayBuffer(16) + const view = new DataView(buffer, 0) + view.setInt16(1, 42) + const copy = copyDataView(view) + + expect(copy).not.toBe(view) + expect(Object.prototype.toString.call(copy)).toEqual("[object DataView]") + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy.getInt16(1)).toEqual(42) + }) + + test('Copy - copyDate', () => { + const date = new Date() + const copy = copyDate(date) + + expect(copy).not.toBe(date) + expect(Object.prototype.toString.call(copy)).toEqual("[object Date]") + expect(copy.getTime()).toEqual(date.getTime()) + }) + + test('Copy - copyRegExp', () => { + const regexp = new RegExp("ab+c", "i") + const copy = copyRegExp(regexp) + + expect(copy).not.toBe(regexp) + expect(Object.prototype.toString.call(copy)).toEqual("[object RegExp]") + expect(copy.source).toEqual(regexp.source) + expect(copy.flags).toEqual(regexp.flags) + expect(copy.lastIndex).toEqual(regexp.lastIndex) + }) + + test('Copy - copyTypedArray - Float32Array', () => { + const buffer = new ArrayBuffer(16) + const float32Array = new Float32Array(buffer, 0) + float32Array[0] = 42 + const copy = copyTypedArray(float32Array) + + expect(copy).not.toBe(float32Array) + expect(Object.prototype.toString.call(copy)).toEqual( + "[object Float32Array]" + ) + expect(copy.BYTES_PER_ELEMENT).toEqual(4) + expect(copy.length).toEqual(4) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Float64Array', () => { + const buffer = new ArrayBuffer(16) + const float64Array = new Float64Array(buffer, 0) + float64Array[0] = 42 + const copy = copyTypedArray(float64Array) + + expect(copy).not.toBe(float64Array) + expect(Object.prototype.toString.call(copy)).toEqual( + "[object Float64Array]" + ) + expect(copy.BYTES_PER_ELEMENT).toEqual(8) + expect(copy.length).toEqual(2) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Int8Array', () => { + const buffer = new ArrayBuffer(16) + const int8Array = new Int8Array(buffer, 0) + int8Array[0] = 42 + const copy = copyTypedArray(int8Array) + + expect(copy).not.toBe(int8Array) + expect(Object.prototype.toString.call(copy)).toEqual("[object Int8Array]") + expect(copy.BYTES_PER_ELEMENT).toEqual(1) + expect(copy.length).toEqual(16) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Int16Array', () => { + const buffer = new ArrayBuffer(16) + const int16Array = new Int16Array(buffer, 0) + int16Array[0] = 42 + const copy = copyTypedArray(int16Array) + + expect(copy).not.toBe(int16Array) + expect(Object.prototype.toString.call(copy)).toEqual("[object Int16Array]") + expect(copy.BYTES_PER_ELEMENT).toEqual(2) + expect(copy.length).toEqual(8) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Int32Array', () => { + const buffer = new ArrayBuffer(16) + const int32Array = new Int32Array(buffer, 0) + int32Array[0] = 42 + const copy = copyTypedArray(int32Array) + + expect(copy).not.toBe(int32Array) + expect(Object.prototype.toString.call(copy)).toEqual("[object Int32Array]") + expect(copy.BYTES_PER_ELEMENT).toEqual(4) + expect(copy.length).toEqual(4) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Uint8Array', () => { + const buffer = new ArrayBuffer(16) + const uint8Array = new Uint8Array(buffer, 0) + uint8Array[0] = 42 + const copy = copyTypedArray(uint8Array) + + expect(copy).not.toBe(uint8Array) + expect(Object.prototype.toString.call(copy)).toEqual("[object Uint8Array]") + expect(copy.BYTES_PER_ELEMENT).toEqual(1) + expect(copy.length).toEqual(16) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Uint16Array', () => { + const buffer = new ArrayBuffer(16) + const uint16Array = new Uint16Array(buffer, 0) + uint16Array[0] = 42 + const copy = copyTypedArray(uint16Array) + + expect(copy).not.toBe(uint16Array) + expect(Object.prototype.toString.call(copy)).toEqual( + "[object Uint16Array]" + ) + expect(copy.BYTES_PER_ELEMENT).toEqual(2) + expect(copy.length).toEqual(8) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Uint32Array', () => { + const buffer = new ArrayBuffer(16) + const uint32Array = new Uint32Array(buffer, 0) + uint32Array[0] = 42 + const copy = copyTypedArray(uint32Array) + + expect(copy).not.toBe(uint32Array) + expect(Object.prototype.toString.call(copy)).toEqual( + "[object Uint32Array]" + ) + expect(copy.BYTES_PER_ELEMENT).toEqual(4) + expect(copy.length).toEqual(4) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - Uint8ClampedArray', () => { + const buffer = new ArrayBuffer(16) + const uint8ClampedArray = new Uint8ClampedArray(buffer, 0) + uint8ClampedArray[0] = 42 + const copy = copyTypedArray(uint8ClampedArray) + + expect(copy).not.toBe(uint8ClampedArray) + expect(Object.prototype.toString.call(copy)).toEqual( + "[object Uint8ClampedArray]" + ) + expect(copy.BYTES_PER_ELEMENT).toEqual(1) + expect(copy.length).toEqual(16) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(42) + }) + + test('Copy - copyTypedArray - BigInt64Array', () => { + const buffer = new ArrayBuffer(16) + const bigInt64Array = new BigInt64Array(buffer, 0) + bigInt64Array[0] = BigInt(42) + const copy = copyTypedArray(bigInt64Array) + + expect(copy).not.toBe(bigInt64Array) + expect(Object.prototype.toString.call(copy)).toEqual( + "[object BigInt64Array]" + ) + expect(copy.BYTES_PER_ELEMENT).toEqual(8) + expect(copy.length).toEqual(2) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(BigInt(42)) + }) + + test('Copy - copyTypedArray - BigUint64Array', () => { + const buffer = new ArrayBuffer(16) + const bigUint64Array = new BigUint64Array(buffer, 0) + bigUint64Array[0] = BigInt(42) + const copy = copyTypedArray(bigUint64Array) + + expect(copy).not.toBe(bigUint64Array) + expect(Object.prototype.toString.call(copy)).toEqual( + "[object BigUint64Array]" + ) + expect(copy.BYTES_PER_ELEMENT).toEqual(8) + expect(copy.length).toEqual(2) + expect(copy.byteLength).toEqual(16) + expect(copy.byteOffset).toEqual(0) + expect(copy[0]).toEqual(BigInt(42)) + }) + + test('Copy - copy - basic', () => { + expect(copy(true)).toBe(true) + expect(copy(false)).toBe(false) + expect(copy(0.234)).toEqual(0.234) + expect(copy(0)).toEqual(0) + expect(copy(1)).toEqual(1) + expect(copy(-1)).toEqual(-1) + expect(copy(null)).toEqual(null) + expect(copy(undefined)).toEqual(undefined) + expect(copy('abc')).toEqual('abc') + // expect(copy(120n)).toEqual(120n) // @support target: ES2020 + }) + + // copy object + test('Copy - copy - object - deep: true', () => { + const obj1 = {} + expect(copy(obj1)).toEqual({}) + // reference with mutation + const obj2 = {a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}} + const obj2UnCopy = obj2 + const obj2CopyMutated = copy(obj2) + obj2UnCopy.a.c = 3 + obj2UnCopy.g.h = 7 + obj2CopyMutated.a.c = 3 + obj2CopyMutated.g.h = 7 + expect(obj2).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) + expect(obj2UnCopy).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) + expect(obj2CopyMutated).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) + + // reference without mutation + const obj3 = {a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}} + const obj3UnCopy = obj3 + const obj3CopyMutated = copy(obj3) + obj3CopyMutated.a.c = 3 + obj3CopyMutated.g.h = 7 + expect(obj3).toEqual({a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}}) + expect(obj3UnCopy).toEqual({a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: {h: 6, i: 7}}) + expect(obj3CopyMutated).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: {h: 7, i: 7}}) + }) + + test('Copy - copy - object - deep: false', () => { + const obj = {a: {b: 1, c: 2, d: 3, e: 4, f: 5}, g: 9} + const objCopy = copy(obj, false) + obj.a.c = 3 + obj.g = 10 + expect(obj).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: 10}) + expect(objCopy).toEqual({a: {b: 1, c: 3, d: 3, e: 4, f: 5}, g: 9}) + }) + + test('Copy - copy - regExp in an object - deep: true', () => { + const rgo = {a: 1, b: {r: new RegExp(/\d{4,}/, 'ig')}} + let rgoCopy = copy(rgo) + rgoCopy.b.r = new RegExp(/\d{5,}/, 'ig') + const rgoMutated = rgo + rgoMutated.b.r = new RegExp(/\d{6,}/, 'ig') + expect(rgoCopy).not.toBe(rgo) + expect(rgoCopy).toEqual({a: 1, b: {r: new RegExp(/\d{5,}/, 'ig')}}) + expect(rgo).toEqual({a: 1, b: {r: new RegExp(/\d{6,}/, 'ig')}}) + expect(rgoMutated).toEqual({a: 1, b: {r: new RegExp(/\d{6,}/, 'ig')}}) + }) + + test('Copy - copy - regExp in an object - deep: false', () => { + const rgo = {a: 1, b: {r: new RegExp(/\d{4,}/, 'ig')}} + let rgoCopy = copy(rgo, false) + rgoCopy.b.r = new RegExp(/\d{5,}/, 'ig') + rgoCopy.a = 2 + expect(rgoCopy).not.toBe(rgo) + expect(rgo).toEqual({a: 1, b: {r: new RegExp(/\d{5,}/, 'ig')}}) + expect(rgoCopy).toEqual({a: 2, b: {r: new RegExp(/\d{5,}/, 'ig')}}) + }) + + test('Copy - copy - Date in an object - deep: true', () => { + const dto = {a: 1, b: {r: new Date('2021-05-18')}} + let dtoCopy = copy(dto) + dtoCopy.b.r = new Date('2021-05-20') + const dtoMutated = dto + dtoMutated.b.r = new Date('2021-05-30') + expect(dtoCopy).not.toBe(dto) + expect(dtoCopy).toEqual({a: 1, b: {r: new Date('2021-05-20')}}) + expect(dto).toEqual({a: 1, b: {r: new Date('2021-05-30')}}) + expect(dtoMutated).toEqual({a: 1, b: {r: new Date('2021-05-30')}}) + }) + + test('Copy - copy - Date in an object - deep: false', () => { + const dto = {a: 1, b: {r: new Date('2021-05-18')}} + let dtoCopy = copy(dto, false) + dtoCopy.b.r = new Date('2021-05-20') + dtoCopy.a = 2 + expect(dtoCopy).not.toBe(dto) + expect(dto).toEqual({a: 1, b: {r: new Date('2021-05-20')}}) + expect(dtoCopy).toEqual({a: 2, b: {r: new Date('2021-05-20')}}) + }) + + // copy array + test('Copy - copy - array - deep: true', () => { + const arr1: number[] = [] + expect(copy(arr1)).toEqual([]) + // reference with mutation + const arr2 = [{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}] + const arr2UnCopy = arr2 + const arr2CopyMutated = copy(arr2) + arr2UnCopy[0].c = 3 + arr2UnCopy[1].h = 7 + arr2CopyMutated[0].c = 3 + arr2CopyMutated[1].h = 7 + expect(arr2).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) + expect(arr2UnCopy).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) + expect(arr2CopyMutated).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) + + // reference without mutation + const arr3 = [{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}] + const arr3UnCopy = arr3 + const arr3CopyMutated = copy(arr3) + arr3CopyMutated[0].c = 3 + arr3CopyMutated[1].h = 7 + expect(arr3).toEqual([{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}]) + expect(arr3UnCopy).toEqual([{b: 1, c: 2, d: 3, e: 4, f: 5}, {h: 6, i: 7}]) + expect(arr3CopyMutated).toEqual([{b: 1, c: 3, d: 3, e: 4, f: 5}, {h: 7, i: 7}]) + }) + + test('Copy - copy - array - deep: false', () => { + const arr = [[1, 2, 3, 4, 5], 9] + const arrCopy = copy(arr, false) + // @ts-ignore + arr[0][2] = 0 + arr[1] = 10 + expect(arr).toEqual([[1, 2, 0, 4, 5], 10]) + expect(arrCopy).toEqual([[1, 2, 0, 4, 5], 9]) + }) + + test('Copy - copy - regExp in an array - deep: true', () => { + const rgo = [1, {r: new RegExp(/\d{4,}/, 'ig')}] + let rgoCopy = copy(rgo) + // @ts-ignore + rgoCopy[1].r = new RegExp(/\d{5,}/, 'ig') + const rgoMutated = rgo + // @ts-ignore + rgoMutated[1].r = new RegExp(/\d{6,}/, 'ig') + expect(rgoCopy).not.toBe(rgo) + expect(rgoCopy).toEqual([1, {r: new RegExp(/\d{5,}/, 'ig')}]) + expect(rgo).toEqual([1, {r: new RegExp(/\d{6,}/, 'ig')}]) + expect(rgoMutated).toEqual([1, {r: new RegExp(/\d{6,}/, 'ig')}]) + }) + + test('Copy - copy - regExp in an array - deep: false', () => { + const rgo = [1, {r: new RegExp(/\d{4,}/, 'ig')}] + let rgoCopy = copy(rgo, false) + // @ts-ignore + rgoCopy[1].r = new RegExp(/\d{5,}/, 'ig') + // @ts-ignore + rgoCopy[0] = 2 + expect(rgoCopy).not.toBe(rgo) + expect(rgo).toEqual([1, {r: new RegExp(/\d{5,}/, 'ig')}]) + expect(rgoCopy).toEqual([2, {r: new RegExp(/\d{5,}/, 'ig')}]) + }) + + test('Copy - copy - Date in an array - deep: true', () => { + const dto = [1, {r: new Date('2021-05-18')}] + let dtoCopy = copy(dto) + // @ts-ignore + dtoCopy[1].r = new Date('2021-05-20') + const dtoMutated = dto + // @ts-ignore + dtoMutated[1].r = new Date('2021-05-30') + expect(dtoCopy).not.toBe(dto) + expect(dtoCopy).toEqual([1, {r: new Date('2021-05-20')}]) + expect(dto).toEqual([1, {r: new Date('2021-05-30')}]) + expect(dtoMutated).toEqual([1, {r: new Date('2021-05-30')}]) + }) + + test('Copy - copy - Date in an array - deep: false', () => { + const dto = [1, {r: new Date('2021-05-18')}] + let dtoCopy = copy(dto, false) + dtoCopy[1].r = new Date('2021-05-20') + dtoCopy[0] = 2 + expect(dtoCopy).not.toBe(dto) + expect(dto).toEqual([1, {r: new Date('2021-05-20')}]) + expect(dtoCopy).toEqual([2, {r: new Date('2021-05-20')}]) + }) + + test('Copy - recursive copy', () => { + type O = { + k: number, + r: any + } + const o: O = { + k: 1, + r: void 0 + } + o.r = o + const co = copy(o) + expect(co).not.toBe(o) + }) + + + test('Copy - proxy copy', () => { + type O = { + arr: Array + } + const o: O = { + arr: [1, 2, 3] + } + const po = new Proxy(o, {}) + const co = copy(po) + po.arr = [1, 2] + expect(co).not.toBe(po) + }) + + test('Copy - array with object copy', () => { + type O = { + arr: Array + } + const o: Array = [{ + arr: [] + }] + const co = copy(o) + co[0].arr[0] = 1 + expect(co).not.toBe(o) + }) +})