@mxssfd/ts-utils
Version:
utils工具函数ts/js库
7 lines • 62.5 kB
JavaScript
/*!
* tsUtils(@mxssfd/ts-utils) v5.0.1-beta.1
* Author: dyh
* Documentation: https://github.com/mengxinssfd/ts-utils#readme
* Date: 2022-11-8
*/
var tsUtils=function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(e){i(e)}}function c(t){try{u(r.throw(t))}catch(e){i(e)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,c)}u((r=r.apply(t,e||[])).next())}))}function n(t,e,n){for(const r in t){if(!E(t,r))continue;if(!1===e(t[r],r,t))return!1}return n&&n(),!0}const r=n;function o(t){return i(t,((t,e,n)=>(t[e]=n,t)),{})}function i(t,e,r){let o=r;return n(t,((t,n,r)=>{o=e(o,t,n,r)})),o}const s=i;function c(t,e,n){const r=n||(t=>t);return e.reduce(((e,n)=>(E(t,n)&&(e[n]=r(t[n],n,t)),e)),{})}function u(t,e,n){const r=n||(t=>t);return i(e,((e,n,o)=>(E(t,n)&&(e[o]=r(t[n],n,t)),e)),{})}function a(t,e,n){const o=n||((t,e,n,r)=>E(r,n)&&t===e||j(t)&&j(e));return e.reduce(((e,n)=>(r(n,((r,i)=>{o(t[i],r,i,t,n)||(e[i]=r)})),e)),{})}function l(t,...e){return e.forEach((e=>{n(e,((e,n)=>{t[n]=e}))})),t}function h(t,e,n){B(e,(e=>{if(e&&E(e,n))return t[n]=e[n],!1}))}function f(t,...e){return e[e.length-1]===t||r(t,((n,r)=>h(t,e,r))),t}const d=f;function p(t){const e=[];let n=t;for(;n;){e.push(...Object.keys(n));const t=Object.getPrototypeOf(n);if(!t||t===Object.prototype)break;e.push(...Reflect.ownKeys(t)),n=t}return G(e.filter((t=>"constructor"!==t)))}function g(t,...e){if(e[e.length-1]===t)return t;return p(t).forEach((n=>h(t,e,n))),t}function m(t){return t.reduce(((t,e)=>{if(!C(e)||e.length<1)throw new TypeError("createObj args type error");const[n,r]=e;return void 0!==n&&(t[n]=r),t}),{})}const w=m;function y(t){return i(t,((t,e,n)=>(t.push(n),t)),[])}function v(t,e=""){let n=t;return n=n.replace(new RegExp(`^${e}`),""),n=n.replace(/\[([^\]]+)]/g,".$1"),n=n.replace(/^\.|\[]/g,""),n}function b(t){return t.reduce(((t,e)=>{const{key:n,value:r,innerKey:o}=function(t){const[e,n]=t.split("=").map((t=>decodeURIComponent(t)));let r=e,o="";const i=/(?:\[([^[\]]*)])|(?:\.\[?([^[\]]*)]?)/g;return i.test(r)&&(o=RegExp.$1||RegExp.$2,r=r.replace(i,"")),{key:r,value:n,innerKey:o}}(e),i=t[n];switch(S(i)){case"undefined":if(o){const e=[];e[o]=r,t[n]=e}else t[n]=r;break;case"string":t[n]=[i];case"array":o?t[n][o]=r:t[n].push(r)}return t}),{})}function E(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function x(t){const e=RegExp(`^${Function.prototype.toString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\])/g,"$1.*?")}$`);return R(t)&&e.test(t)}function S(t){const e=typeof t;return"object"!==e?e:Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function T(t){return"object"===S(t)}function L(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}const R=L;function C(t){return"array"===S(t)}function O(t){const e=S(t);if("string"===e)return!0;if(["null","undefined","number","boolean"].indexOf(e)>-1)return!1;const n=!!t&&"length"in t&&t.length;return"function"!==e&&t!==window&&("array"===e||0===n||M(n)&&n>0&&n-1 in t)}function $(t){return"string"===S(t)}function M(t){return"number"===S(t)}function I(t){return"function"===S(t)}function D(t){return void 0===t}function A(t){const e=typeof t;return!!t&&("object"===e||"function"===e)&&"function"==typeof t.then}function j(t){return M(t)&&t!=t}function P(t){if(!T(t))return!1;for(const e in t)return void 0===e;return!0}function k(t,e){if(t===e)return!0;const n=S(t);if(n!==S(e))return!1;switch(n){case"boolean":case"string":case"function":return!1;case"number":return j(e);default:return _(t,e)}}function _(t,e){if(t===e)return!0;for(const n in t){if(!k(t[n],e[n]))return!1}return!0}function N({start:t=0,end:e,len:n,fill:r}){let o,i=t;switch(n&&e?i=Math.min(t+n,e):(void 0!==n&&(i=t+n),void 0!==e&&(i=e)),S(r)){case"function":o=r;break;case"undefined":case"null":o=t=>t;break;default:o=()=>r}const s=[];for(let c=t,u=0;c<i;c++,u++)s.push(o(c,u));return s}function U(t,e,n){const r=t.length||0;for(let o=0;o<r;o++)if(!1===e(t[o],o,t))return!1;return n&&n(),!0}function F(t,n){return e(this,void 0,void 0,(function*(){const e=t.length;for(let r=0;r<e;r++){if(!1===(yield n(t[r],r,t)))break}}))}function B(t,e){for(let n=t.length-1;n>-1&&!1!==e(t[n],n,t);n--);}function H(t,e,n=0){const r=t.length;for(let o=n;o<r;o++){const n=t[o];if("function"==typeof e){if(e(n,o,t))return!0}else if(n===e)return!0;if(j(n)&&j(e))return!0}return!1}function z(t,e){const n=t.length;for(let r=0;r<n;r++){if(e(t[r],r,t))return r}return-1}function W(t,e){for(let n=t.length-1;n>=0;n--){if(e(t[n],n,t))return n}return-1}function q(t,e,n,{after:r=!1,reverse:o=!1}={}){const i=X(t);let s=e;if(I(e)){if(s=(o?W:z)(n,((n,r,o)=>e(n,r,o,t))),-1===s)return-1}else e<0?s=0:e>n.length&&(s=n.length-(r?1:0));return r&&s++,n.splice(s,0,...i),s}function V(t,e){const n=e.indexOf(t);if(-1!==n)return e.splice(n,1)[0]}function G(t,e){if(!t.length)return t;const n=e||((t,e)=>t===e||j(t)&&j(e)),r=[t[0]];for(let o=1,i=t.length;o<i;o++){const e=t[o];r.some((t=>n(t,e)))||r.push(e)}return r}function X(t){return C(t)?t:[t]}function K(t,[e=-1/0,n=1/0]){return e<=t&&t<=n}function J(t,e,n=" ",r=!1){if(t.length>=e||""===n)return r?t.substr(t.length-e):t;const o=e-t.length;for(;n.length<o;)n+=n;return(n=n.substr(0,o))+t}function Y(t,e,n=" ",r=!1){if(t.length>=e||""===n)return r?t.substr(0,e):t;const o=e-t.length;return t+J(t,e,n).substr(0,o)}const Q=["零","一","二","三","四","五","六","七","八","九"],Z=["十","百","千"],tt=["",...Z,"万",...Z,"亿"],et=tt.length,nt=function(t){let e=~~t,n="",r=0;if(t>=0&&t<10)return nt.numbers[t];for(;e>=1&&r<et;){const t=nt.units[r],o=nt.numbers[e%10];o!==nt.numbers[0]&&(n=t+n),1===e&&1===r||(n=o+n),e=~~(e/10),r++}return n.replace(/(零+$)|((零)\3+)/g,"$3")};nt.units=[...tt],nt.numbers=[...Q];const rt=function(t){if(new RegExp(`([^${rt.units.join()+rt.numbers.join()}])`).test(t))throw new TypeError("发现不符合规则的字符(必须在units和numbers里存在的字符):"+RegExp.$1);return t.split(new RegExp(`[${rt.units[4]}${rt.units[8]}]`,"g")).map((t=>{let e=0,n=1;for(let r=t.length-1;r>-1;r--){const o=t[r],i=rt.numbers.indexOf(o);i>0&&(e+=i*n);const s=rt.units.indexOf(o);n=s>0?Math.pow(10,s):n}return t[0]===rt.units[1]&&(e+=10),e})).reverse().reduce(((t,e,n)=>t+Math.pow(1e4,n)*e),0)};function ot(t,e){if(e<0||e*t.length>ot.MAX_STR_LENGTH)throw new RangeError("strRepeat Invalid repeatCount value");let n="";if(""===t)return"";for(;e-- >0;)n+=t;return n}function it(t){if(!t.length)return t;return`${t[0].toUpperCase()}${t.substring(1).toLowerCase()}`}function st(t,e="_",n=!1){const r=t.replace(/([A-Z]+)/g,((t,n,r)=>(r>0?e:"")+n.toLowerCase()));return n?r.toUpperCase():r}rt.units=[...tt],rt.numbers=[...Q],ot.MAX_STR_LENGTH=536870912;const ct=function(t,e="yyyy-MM-dd hh:mm:ss",{seasonText:n=ct.seasonText,weekText:r=ct.weekText}={}){var o;const i={"M+":()=>t.getMonth()+1,"d+":()=>t.getDate(),"h+":()=>t.getHours(),"m+":()=>t.getMinutes(),"s+":()=>t.getSeconds(),q:()=>{const e=Math.floor((t.getMonth()+3)/3)-1;return n[e]},"S+":()=>t.getMilliseconds(),w:()=>r[t.getDay()]};/(y+)/.test(e)&&(e=e.replace(RegExp.$1,J(String(t.getFullYear()),RegExp.$1.length,"0",!0)));for(const s in i)if(new RegExp("("+s+")").test(e)){const t=RegExp.$1,n=String(null===(o=i[s])||void 0===o?void 0:o.call(i));e=e.replace(t,J(n,t.length,"0"))}return e};function ut(t){if(!t||/[^/\d: -]/.test(t))return null;const e=t.split(/[- :/]/).map((t=>Number(t)));if(e.length<6)for(let n=e.length;n<6;n++)e[n]=n<3?1:0;return new Date(e[0],e[1]-1,e[2],e[3],e[4],e[5])}ct.weekText=["日","一","二","三","四","五","六"],ct.seasonText=["春","夏","秋","冬"];const at=ut;function lt(){const t=Date.now();return function(){return Date.now()-t}}function ht(t){const e=lt();return function(){return t-e()}}function ft(t){const e=new Date(t.getTime());return e.setMonth(t.getMonth()+1),e.setDate(0),e}function dt(t,e,n=!1){let r,o,i,s,c=!0;const u=()=>{clearTimeout(s),s=void 0},a=function(...t){return s&&u(),r=this,o=t,c&&n?(a.flush(),c=!1,s=setTimeout((()=>{c=!0}),e),i):(s=setTimeout((()=>{u(),a.flush(),c=!0}),e),i)};return a.cancel=u,a.flush=()=>(i=t.apply(r,o),r=o=void 0,i),a}function pt(t,e,n=(()=>{})){let r=()=>0;return function(...o){const i=r();if(!(i>0))return r=ht(e),t.apply(this,o);n(i)}}function gt(t,e,n=!0){let r,o,i;!function(t){t[t.running=0]="running",t[t.stopped=1]="stopped"}(r||(r={}));let s=0,c=Date.now(),u=0;function a(){const e=t(s++);e instanceof Promise?e.then(l):l()}function l(){const t=e-u;o=setTimeout((()=>{if(i!==r.running)return;const e=Date.now();u=e-c-t,c=e,a()}),t)}return i=r.running,n?a():l(),function(){i=r.stopped,clearTimeout(o)}}function mt(t){let e="return arguments[0][arguments[1]](";for(let n=0;n<t;n++)n>0&&(e+=","),e+="arguments[2]["+n+"]";return e+=")",e}const wt=function(){try{return Function("return this")()}catch(t){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global}}();class yt{}class vt extends yt{constructor(){super(...arguments),this.cache=[]}set(t){return this.has(t)||this.cache.push(t),this}has(t){return this.cache.some((e=>t===e||j(t)&&j(e)))}clear(){this.cache=[]}get size(){return this.cache.length}}class bt extends yt{constructor(){super(...arguments),this.cache=new Set}set(t){return this.cache.add(t),this}has(t){return this.cache.has(t)}clear(){this.cache=new Set}get size(){return this.cache.size}}const Et=x(wt.Set)?bt:vt;const xt=function(){const t={array:t=>new t.constructor,function:t=>t,date:t=>new t.constructor(t)};return Object.assign(Object.assign({},t),{object:t.array,regexp:t.date})}();function St(t){if("object"!=typeof t||!t)return t;const e=new t.constructor;function n(t,e){for(const n in t)E(t,n)&&r.push([n,t[n],e])}const r=[];for(n(t,e);r.length;){const[t,e,o]=r.shift();"object"===typeof e&&null!==e?(void 0===o[t]&&(o[t]=new e.constructor),n(e,o[t])):o[t]=e}return e}function Tt(t,e=12){return+parseFloat(t.toPrecision(e))}function Lt(t){var e;Number(1e3).toPrecision();const n=String(t).split(/[eE]/),r=((null===(e=n[0])||void 0===e?void 0:e.split(".")[1])||"").length-+(n[1]||0);return r>0?r:0}function Rt(t,e){const n=Lt(t),r=Lt(e);return Math.pow(10,Math.max(n,r))}function Ct(t,e,n){return e.reduce(((t,e)=>{const r=Rt(t,e);return n(t,e,r)}),t)}function Ot(t,...e){return Ct(t,e,((t,e,n)=>(t*n+e*n)/n))}function $t(t,...e){return Ct(t,e,((t,e,n)=>(t*n-e*n)/n))}function Mt(t,...e){return Ct(t,e,((t,e,n)=>n*t*(e*n)/(n*n)))}function It(t,...e){return Ct(t,e,((t,e,n)=>t*n/(e*n)))}function Dt(t,e=-1/0,n=1/0){return Math.max(e,Math.min(t,n))}class At{constructor(t){this.initNumber=t,this.plus=this["+"],this.minus=this["-"],this.times=this["*"],this.divide=this["/"],this.setValue(t)}static init(t){return new At(t)}"+"(...t){return this.setValue(Ot(this._value,...t)),this}"-"(...t){return this.setValue($t(this._value,...t)),this}"*"(...t){return this.setValue(Mt(this._value,...t)),this}"/"(...t){return this.setValue(It(this._value,...t)),this}by(t,e){const n=this._value;return this.setValue(t),this[e](n),this}setValue(t){this._value=t}get value(){return Tt(this._value)}set value(t){this.setValue(t)}reset(){return this._value=this.initNumber,this}valueOf(){return this._value}}function jt(t,[e,n]){return e<=t&&t<=n||n<=t&&t<=e}function Pt(t,e){const[n,r]=t,[o,i]=e,s=n-o,c=r-i;return Math.sqrt(s*s+c*c)}var kt;function _t(t){return function(e,n,r){e.descriptor&&(r=e.descriptor),r.value=t(r)}}t.Direct=void 0,(kt=t.Direct||(t.Direct={})).top="top",kt.left="left",kt.right="right",kt.bottom="bottom";class Nt{constructor(){this.events={}}static get Ins(){return Nt.instance||(Nt.instance=new Nt),Nt.instance}getCallbackList(t){return Array.isArray(this.events[t])||(this.events[t]=[]),this.events[t]}on(t,e){this.getCallbackList(t).push(e)}once(t,e){const n=(...r)=>{e(...r),this.off(t,n)};this.getCallbackList(t).push(n)}times(t,e,n){this.getCallbackList(e).push((()=>{let r=0;const o=(...i)=>{n(...i),r++,r===t&&this.off(e,o)};return o})())}emit(t,...e){this.getCallbackList(t).forEach((t=>{t(...e)}))}off(t,e){const n=this.getCallbackList(t),r=z(n,(t=>t===e));r>-1&&n.splice(r,1)}offAll(){this.events={}}}var Ut;!function(t){t[t.default=0]="default",t[t.pause=1]="pause",t[t.stop=2]="stop"}(Ut||(Ut={}));class Ft{constructor(t){this.protocol="",this.port="",this.host="",this.path="",this.href="",this.hash="",this.query={},this.href=t,this.parseAll(t)}parseAll(t){this.protocol=Ht(t),this.host=Wt(t),this.port=qt(t),this.path=Vt(t),this.hash=Gt(t),this.query=Xt(t)}toString(t="{protocol}{host}{port}{pathname}{params}{hash}"){const e={"{protocol}":()=>this.protocol?`${this.protocol}://`:"","{host}":()=>this.host||"","{port}":()=>this.port?`:${this.port}`:"","{pathname}":()=>this.path||"","{params}":()=>{const t=Jt(this.query);return t?"?"+t:""},"{hash}":()=>this.hash||""};for(const n in e){const r=e[n],o=new RegExp(n,"g");t=t.replace(o,r)}return t}}const Bt=/^(\w+):\/\//;function Ht(t=location.href){let e="";return new RegExp(Bt).test(t)&&(e=RegExp.$1),e}const zt=/(?:\w+:\/\/|\/\/)((?:[\w\-\u4e00-\u9fa5]+\.?)+\w+)/;function Wt(t=location.href){const e=new RegExp(zt).exec(t);return e?e[1]:""}function qt(t=location.href){return t=t.split("?")[0],/:(\d+)/.test(t)?RegExp.$1:""}function Vt(t=location.href){return(t=t.split(/[?#]/)[0]).replace(new RegExp(`(${zt.source}(?::\\d+)?)|${Bt.source}`),"")}function Gt(t=location.href){const e=t.indexOf("#");return e<0?"":t.substring(e)}function Xt(t=location.href){const e=t.match(/[^&#?/]+=[^&#?/]+/g);return e?b(e):{}}const Kt=Xt;function Jt(t){return i(t,((t,e,r)=>(void 0===e||("object"==typeof e?n(e,((e,n)=>{void 0!==e&&t.push(`${r}[${n}]=${encodeURIComponent(e)}`)})):t.push(`${r}=${encodeURIComponent(e)}`)),t)),[]).join("&")}function Yt(t,e=location.href,n=!1){const r=new RegExp("(?:\\?|#|&)"+t+"=([^&#]*)(?:$|&|#)","i").exec(e);if(null===r)return"";const o=r[1];return n?o:decodeURIComponent(o)}const Qt=new RegExp("^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4])|(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*\\.[a-z\\u00a1-\\uffff]{2,})|localhost)(?::\\d{2,5})?(?:([/?#])[^\\s]*)?$","i");function Zt(t,e,n){if(!arguments.length)return Math.random();if(1===arguments.length&&(e=t,t=0),void 0===n){const n=e-t;return Math.random()*n+t}return N({len:n,fill:()=>Zt(t,e)})}function te(t,e,n){if(!arguments.length)return Math.random();if(1===arguments.length&&(e=t,t=0),void 0===n){const n=e-t;return parseInt(Math.random()*n)+t}return N({len:n,fill:()=>te(t,e)})}function ee(){const t=te(0,255,3);return`rgb(${t[0]},${t[1]},${t[2]})`}function ne(){const t=te(0,255,3),e=+Zt().toFixed(2);return`rgba(${t[0]},${t[1]},${t[2]},${e})`}function re(){return"#"+J(te(16777215).toString(16),6,"0")}function oe(t){return/^[rR][gG][Bb][Aa]?\((\s*(2[0-4]\d|25[0-5]|[01]?\d{1,2}),){2}\s*(2[0-4]\d|25[0-5]|[01]?\d{1,2})(,\s*(0\.\d+|1|0))?\)$/.test(t)}function ie(t){return Math.max(0,Math.min(t,255))}class se{constructor(t=0,e=0,n=0){this.r=t,this.g=e,this.b=n}get r(){return this._r}set r(t){this._r=ie(t)}get g(){return this._g}set g(t){this._g=ie(t)}get b(){return this._b}set b(t){this._b=ie(t)}toHEX(){const{r:t,g:e,b:n}=this;return"#"+((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)}}se.validate=oe;class ce extends se{constructor(t,e,n){super(t,e,n)}static random(){const t=te(0,255,3);return new ce(t[0],t[1],t[2])}static fromStr(t){if(!ce.validate(t))throw new TypeError("color is not rgb");const e=(t=t.replace(/(rgba?\(|\))/g,"")).split(","),n=parseInt(e[0]),r=parseInt(e[1]),o=parseInt(e[2]);return new ce(n,r,o)}static fromHEX(t){const e=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,((t,e,n,r)=>e+e+n+n+r+r)),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!C(n)||n.length<4)throw new TypeError;const r=parseInt(n[1],16),o=parseInt(n[2],16),i=parseInt(n[3],16);return new ce(r,o,i)}toRGBA(){const{r:t,g:e,b:n}=this;return new ue(t,e,n)}toString(){const{r:t,g:e,b:n}=this;return`rgb(${t},${e},${n})`}}class ue extends se{constructor(t,e,n,r=1){super(t,e,n),this.a=r}get a(){return this._a}set a(t){const e=Math.max(0,Math.min(t,1));this._a=Number(e.toFixed(2))}static random(){const t=te(0,255,3);return new ue(t[0],t[1],t[2],te())}static fromStr(t){if(!ue.validate(t))throw new TypeError("color is not rgb");const e=(t=t.replace(/(rgba?\(|\))/g,"")).split(","),n=parseInt(e[0]),r=parseInt(e[1]),o=parseInt(e[2]),i=parseInt(e[3]);return new ue(n,r,o,i)}toRGB(){const{r:t,g:e,b:n}=this;return new ce(t,e,n)}toString(){const{r:t,g:e,b:n,a:r}=this;return`rgba(${t},${e},${n},${r})`}}var ae;!function(t){t.ready="ready",t.running="running",t.done="done"}(ae||(ae={}));class le{constructor(t,e,n){this.initValue=e,this.onDone=n,this._status=ae.ready,this.next=t=>{const{chain:e}=this;this._value=t,this.index>=e.length-1?this.done():(this.index++,this.run())},this.done=(t=this.value)=>{const{onDone:e,index:n}=this;this._status=ae.done,e&&e(t,n)},this.chain=t.map((t=>I(t)?{handler:t}:t))}get value(){return this._value}get status(){return this._status}start(t){return this._status===ae.running||(this.initValue=null!=t?t:this.initValue,this._value=null!=t?t:this.initValue,this.index=0,this._status=ae.running,this.run()),this}run(){const{chain:t,index:e,next:n,done:r,value:o,initValue:i}=this,{handler:s}=t[e];s(o,n,r,i)}}function he(t){return t&&"object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName}function fe(t){return t instanceof HTMLElement}le.State=ae;const de=D(wt.HTMLElement)?he:fe;function pe(t,e){return de(e)&&e.nodeName===t.toUpperCase()}function ge(t){return pe("SELECT",t)}function me(t){return pe("INPUT",t)}function we(t){return pe("TEXTAREA",t)}function ye(t){return pe("IMG",t)}function ve(t){return"nodelist"===S(t)}function be({el:t,onDown:e,onMove:n,onUp:r,capture:o={down:!1,up:!0,move:!1}}){let i=t;if(!de(t))if($(t)){if(i=document.querySelector(t),!i)throw new Error("element not found!")}else i=window;let s,c={x:0,y:0},u={x:0,y:0};function a(t){const{screenX:e,screenY:n}=t,r={x:e,y:n};return r.x=~~r.x,r.y=~~r.y,r}function l(t){const e=(["touchcancel","touchend"].indexOf(t.type)>-1?t.changedTouches:t.touches)[0],n={x:e.clientX,y:e.clientY};return n.x=~~n.x,n.y=~~n.y,n}function h(t,n){if(t.touches&&t.touches.length>1)return void m();let r;return s="mouse"===n?a:l,u=s(t),c=u,e&&I(e)&&(r=e.call(this,t,u)),r}function f(t){const e=s(t);let r;return n&&I(n)&&(r=n.call(this,t,e,c,u)),c=e,r}function d(t){const e=s(t);let n;return c=e,r&&I(r)&&(n=r.call(this,t,e,u)),m(),n}function p(t){const e=h.call(this,t,"mouse");return window.addEventListener("mousemove",f,o.move),window.addEventListener("mouseup",d,o.up),e}function g(t){const e=h.call(this,t,"touch");return window.addEventListener("touchmove",f,o.move),window.addEventListener("touchend",d,o.up),window.addEventListener("touchcancel",d,o.up),e}function m(){window.removeEventListener("mousemove",f,o.move),window.removeEventListener("mouseup",d,o.up),window.removeEventListener("touchmove",f,o.move),window.removeEventListener("touchend",d,o.up),window.removeEventListener("touchcancel",d,o.up)}return i.addEventListener("mousedown",p,o.down),i.addEventListener("touchstart",g,o.down),function(){i.removeEventListener("mousedown",p,o.down),i.removeEventListener("touchstart",g,o.down),m()}}function Ee(t,e,n,r=!1){let o;if($(t)){if(o=document.querySelector(t),!o)throw new Error("element not found!")}else o=de(t)?t:window;o.addEventListener(e,(function t(i){if(o.removeEventListener(e,t,r),n&&I(n))return n.call(this,i)}),r)}function xe(t){const e={w:0,h:0};return t===window?(e.w=window.innerWidth,e.h=window.innerHeight):(e.w=t.offsetWidth,e.h=t.offsetHeight),e}var Se,Te;const Le=null!==(Te=null===(Se=null==wt?void 0:wt.document)||void 0===Se?void 0:Se.createElement("div").style)&&void 0!==Te?Te:{},Re=(()=>{const t={webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"};for(const e in t){if(void 0!==Le[t[e]])return e}return!1})();function Ce(){var t;return!!(null===(t=null==wt?void 0:wt.document)||void 0===t?void 0:t.documentElement.classList)}function Oe(t){if(!t)return[];let e=t;return $(t)&&(e=[t.trim()]),e.reduce(((t,e)=>{const n=e.trim().split(/ +/);return t.push(...n),t}),[])}function $e(t,e){const n=Oe(e),r=t.className.split(/ +/);return n.every((t=>H(r,t)))}function Me(t,e){const n=Oe(e),r=t.classList;return n.every((t=>H(r,t)))}const Ie=Ce()?Me:$e;function De(t,e){const n=Oe(e),r=t.classList;return n.forEach((t=>r.add(t))),t.className}function Ae(t,e){let n=Oe(e);const r=t.className+" "+n.join(" ");return n=r.split(" "),n=G(n),n=n.filter((t=>Boolean(t))),t.className=n.join(" "),t.className}const je=Ce()?De:Ae;function Pe(t,e){const n=Oe(e),r=G(t.className.split(/ +/).filter((t=>!H(n,t))));return t.className=r.join(" ")}function ke(t,e){return Oe(e).forEach((e=>{t.classList.remove(e)})),t.className}const _e=Ce()?ke:Pe;function Ne(t){return!1===Re?null:"standard"===Re?t:Re+t.charAt(0).toUpperCase()+t.substr(1)}function Ue(t,{toCssText:e=!0,el:n}={}){$(n)&&(n=document.querySelector(n));const r=n||this;if(!de(r))throw new TypeError("setStyle param el | this is not HTMLElement");if(e=!C(t)&&e){const e=r.style.cssText.replace(/; ?$/,"").split(";").reduce(((t,e)=>{const[n,r]=e.split(/: ?/);return t[n]=r,t}),{});l(e,t),r.style.cssText=s(e,((t,e,n)=>t+`${st(n,"-")}: ${e};`),"")}else{X(t).forEach((t=>l(r.style,t)))}return Ue.bind(r)}function Fe(t,e={}){return new Promise((function(n,r){const o=t=>{r(t)},i=Be("img",{props:l({crossOrigin:"anonymous",onload(){n(i)},onabort:o,onerror:o},e)});i.src=t}))}function Be(t,e={}){const r=document.createElement(t),{attrs:o={},props:i={},parent:s,children:c}=e;if(n(i,((t,e)=>{"style"===e&&"object"==typeof t?l(r.style,t):r[e]=t})),n(o,((t,e)=>{r.setAttribute(e,"object"==typeof t?JSON.stringify(t):t)})),(C(c)||ve(c))&&c.forEach((t=>r.appendChild(t))),s)if(de(s))s.appendChild(r);else if($(s)){const t=document.querySelector(s);if(!t)throw new TypeError(`createHtmlElement param 'parent' => "${s}" not founded`);t.appendChild(r)}return r}const He=Be;function ze(t,e="div"){return Be(e,{props:Object.assign(Object.assign({},t),{style:Object.assign({position:"fixed",left:"-10000px",visibility:"hidden"},null==t?void 0:t.style)}),parent:document.body})}const We=t=>t.toFixed(6).replace(/\.?0+$/,"");function qe(){const t=getComputedStyle(document.documentElement);return parseInt(t.fontSize)}function Ve(t){return qe()*parseFloat(t)+"px"}function Ge(t){const e=qe(),n=It(parseFloat(t),e);return We(n)+"rem"}function Xe(t,e){return It(Mt(parseFloat(e),parseFloat(t)),100)+"px"}function Ke(t,e){const n=100*parseFloat(t)/parseFloat(e);return We(n)+"%"}let Je=null;class Ye{static downloadOrJSON({res:t,filename:e,onGetJSON:n}){if(200===t.status){const r=t.data;if("application/json"===t.data.type){const t=new FileReader;t.onload=t=>{const e=JSON.parse(t.target.result)||{};n&&n(e)},t.readAsText(r,"utf-8")}else Ye.download(e,window.URL.createObjectURL(new Blob([t.data])))}}static download(t,e){const n=document.createElement("a");"download"in n?(n.href=e,n.setAttribute("download",t),document.body.appendChild(n),n.click(),document.body.removeChild(n),window.URL.revokeObjectURL(e)):navigator.msSaveBlob(e,t),window.URL.revokeObjectURL(e)}}let Qe=0;class Ze{constructor(t){this.parent=t,this.style={};const e=t instanceof nn?t:t.computedStyle;this.auto={width:e.width,height:e.height}}setStyle(t){l(this.style,t),this.computeStyle()}get root(){const t=this.parent;return t instanceof nn?t:this.parent.root}get ctx(){return this.parent.ctx}render(){this.renderBackGround(),this._render()}renderBackGround(){const{background:t}=this.style;if(!t)return;this.ctx.fillStyle=t;const{left:e,top:n,width:r,height:o}=this.computedStyle;this.ctx.fillRect(e,n,r,o)}computeStyle(){const{left:t,top:e,right:n,bottom:r,width:o,height:i,horizontalAlign:s,verticalAlign:c,zIndex:u}=this.style;let a,l,h=0,f=0;const d=this.parent,{width:p,height:g}=d instanceof nn?d:d.computedStyle;if(a=o||p,l=i||g,void 0!==t&&void 0!==n?(h=t,void 0===o&&(a=p-n-t)):void 0!==t?h=t:void 0!==n&&(h=p-n-a),void 0!==e&&void 0!==r?(f=e,void 0===i&&(l=g-e-r)):void 0!==e?f=e:void 0!==r&&(f=g-r-l),"auto"===o&&(a=this.auto.width),"auto"===i&&(l=this.auto.height),(void 0===t||void 0===n)&&s)switch(s){case"left":h=0;break;case"middle":h=~~((p-a)/2);break;case"right":h=p-a}if((void 0===e||void 0===r)&&c)switch(c){case"top":f=0;break;case"middle":f=~~((g-l)/2);break;case"bottom":f=g-l}if(!(d instanceof nn)){const t=d.computedStyle;h+=t.left,f+=t.top}this.computedStyle={width:a,height:l,zIndex:u||0,left:h,top:f}}}class tn extends Ze{constructor(t,e,n){super(t),this.content=n,this.id=Qe++;const r=n,{width:o,height:i}=e;let s=o||r.width,c=i||r.height;"auto"===o&&(s=(c/r.height||1)*r.width),"auto"===i&&(c=(s/r.width||1)*r.height),this.auto={width:s,height:c},this.setStyle(e)}_render(){if(!this.ctx)throw new Error;const t=this.computedStyle;this.ctx.drawImage(this.content,t.left,t.top,t.width,t.height)}}class en extends Ze{constructor(t,e){super(t),this.style=e,this.children=[],this.setStyle(e)}add(t){var e;t.style.zIndex=null!==(e=t.style.zIndex)&&void 0!==e?e:0;const n=this.children;return n.length?q(t,((e,n)=>e.style.zIndex<=t.style.zIndex||0===n),n,{after:!0,reverse:!0}):this.children.push(t)}addImg(t,n={}){return e(this,void 0,void 0,(function*(){let e;e=ye(t)?t:A(t)?yield t:yield Fe(t);const r=new tn(this,n,e),o=this,i=o.add(r);return 1===o.children.length?this.render():i!==o.children.length-1?this.root.render():r.render(),r}))}_render(){this.children.forEach((t=>t.render()))}remove(t){return M(t)?this.children.splice(t,1)[0]:V(t,this.children)}clear(){this.children=[]}}class nn{constructor(t=0,e=0){this.width=t,this.height=e,this.layers=[];const n=document.body,r=He("canvas",{props:{style:{height:e+"px",width:t+"px",display:"none"},width:t,height:e},parent:n});this.canvas=r,this.parent=n,this._ctx=r.getContext("2d"),n.appendChild(r),this.addLayer()}addLayer(t){var e;const n=new en(this,l({width:this.width,height:this.height},t));n.style.zIndex=null!==(e=n.style.zIndex)&&void 0!==e?e:0;const r=this.layers;return r.length?q(n,((t,e)=>t.style.zIndex<=n.style.zIndex||0===e),r,{after:!0,reverse:!0}):r.push(n),n}get ctx(){return this._ctx}static createWithBg(t){return e(this,void 0,void 0,(function*(){const e=Fe(t),n=yield e,r=new nn(n.width,n.height);return yield r.addLayer().addImg(e),r}))}render(){console.count("render count"),this.clear(),this.layers.forEach((t=>{t.render()}))}clear(){var t;null===(t=this._ctx)||void 0===t||t.clearRect(0,0,this.width,this.height)}toDataURL(t="image/png",e){if(!this.canvas)throw new Error;return this.canvas.toDataURL(t,e)}toBlob(t="image/png",e){const n=this.canvas;if(!n)throw new Error;return new Promise(((r,o)=>{n.toBlob((t=>{t?r(t):o(t)}),t,e)}))}drawRoundRect(t){return e(this,void 0,void 0,(function*(){const e=yield Fe(this.toDataURL()),n=this.ctx;this.clear();const r=n.createPattern(e,"no-repeat"),o=this.width,i=this.height;o<2*t&&(t=o/2),i<2*t&&(t=i/2),n.beginPath(),n.moveTo(0+t,0),n.arcTo(0+o,0,0+o,0+i,t),n.arcTo(0+o,0+i,0,0+i,t),n.arcTo(0,0+i,0,0,t),n.arcTo(0,0,0+o,0,t),n.closePath(),n.fillStyle=r,n.fill()}))}destroy(){if(!this.canvas)throw new Error("destroyed");this._ctx=void 0,this.layers=[],this.parent.removeChild(this.canvas),this.canvas=void 0}}function rn(t){var e;const n=t.split(","),r=(null!==(e=n[0].match(/:(.*?);/))&&void 0!==e?e:[])[1],o=window.atob(n[1]);let i=o.length;const s=new Uint8Array(i);for(;i--;)s[i]=o.charCodeAt(i);return{mime:r,uint8Array:s}}var on;function sn(t){let e;if(ge(t))t.focus(),e=t.value;else if(me(t)||we(t)){const n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();const n=window.getSelection(),r=document.createRange();r.selectNodeContents(t),n.removeAllRanges(),n.addRange(r),e=n.toString()}return e}function cn(t){const e=de(t),n=e?t:ze({innerText:String(t),style:{visibility:"visible",opacity:"0"}}),r=new Promise(((e,r)=>{let o,i;sn(n);try{o=document.execCommand("copy")}catch(s){o=!1,i=s}o?e(t):r(i)}));return r.finally((function(){window.getSelection&&window.getSelection().removeAllRanges(),!e&&n&&document.body.removeChild(n)})),r}cn.once=function(t,e,n="click",r=!1){return new Promise(((o,i)=>{Ee(t,n,(()=>{cn(e()).then(o,i)}),r)}))},cn.interceptor=({cb:t,el:e=window,capture:n=!0,type:r="copy",format:o="text/plain"})=>{const i=e=>{const n=e.clipboardData;if(!n)return;const r=window.getSelection();n.setData(o,t(e,r.toString())),e.preventDefault()};return e.addEventListener("copy",i,n),()=>{e.removeEventListener(r,i,n)}};const un=null===(on=null==wt?void 0:wt.navigator)||void 0===on?void 0:on.clipboard;function an(){return Boolean(null==un?void 0:un.write)}class ln{static set(t,e,n,r){const o=new Date;o.setSeconds(o.getSeconds()+n);const i=n?";expires="+o.toUTCString():"";r=";path="+(r||"/"),document.cookie=t+"="+encodeURIComponent(e)+i+r}static get(t){const e=[];if(document.cookie.length>0){const n=new RegExp(`(?:^${t}|; ${t})=([^;]+)`,"g");let r=null;for(;r=n.exec(document.cookie);)e.push(decodeURIComponent(r[1]))}return e}static remove(t,e="/"){ln.set(t,"",-1,e)}}class hn{constructor(t){this.list=[],this.list=this.transformOptions(t)}transformOptions(t){return t.map((t=>{if(!Array.isArray(t))return{option:t,weights:1};const[e,n]=t;return{option:e,weights:null!=n?n:1}}))}remove(t){const e=this.list.findIndex((e=>e.option===t));return-1!==e&&(this.list.splice(e,1),!0)}add(t){this.list.push(...this.transformOptions(t))}export(){return this.list.map((t=>[t.option,t.weights]))}get len(){return this.list.length}}class fn{constructor(t){this.pool=[],this.generatePool(t)}computeWeights(t){const[e,n]=t.reduce((([t,e],n)=>"number"==typeof n.weights?[t+n.weights,e]:(e.push(n),[t,e])),[0,[]]);return[n.reduce(((t,n)=>t+n.weights(e)),e)||1,e||1]}generatePool(t){const[e,n]=this.computeWeights(t);let r=0;this.pool=t.map((t=>{const o="number"==typeof t.weights?t.weights:t.weights(n);if(o<=0)throw new RangeError(`权重不能小于等于0,weights: ${o}`);r+=o;const i=~~(r/e*1e6)/1e4;return Object.assign(Object.assign({},t),{range:i})}))}get randomOption(){if(!this.pool.length)return null;const t=100*Math.random();return this.pool.find((e=>e.range>t)).option}remove(t){const e=this.pool.filter((e=>e.option!==t));this.generatePool(e)}get len(){return this.pool.length}get options(){return this.pool.map((t=>t.option))}rateOf(t){var e,n;const r=this.pool,o=r.findIndex((e=>e.option===t));if(-1===o)return 0;const i=1e4;return(~~(r[o].range*i)-~~((null!==(n=null===(e=r[o-1])||void 0===e?void 0:e.range)&&void 0!==n?n:0)*i))/i}export(){return this.pool.map((t=>[t.option,t.weights]))}}var dn=Object.freeze({__proto__:null,OptionsStore:hn,OptionsPool:fn,RandomPicker:class{constructor(t=[]){this.seed=t,this.seed=t.slice(),this.refreshStore(),this.refreshPool()}refreshStore(){this.store=new hn(this.seed)}refreshPool(){this.pool=new fn(this.store.list)}option(t,e=1){return this.options([[t,e]])}options(t){return this.store.add(t),this.refreshPool(),this}pick(t=1){return 1===t?this.pool.randomOption:Array(t).fill(void 0).map((()=>this.pool.randomOption))}take(t=1){const e=()=>{const t=this.pool.randomOption;return null===t||this.pool.remove(t),t};return 1===t?e():Array(Math.min(t,this.poolLen)).fill(null).map((()=>e()))}remove(t){const e=this.store.remove(t);return e&&this.refreshPool(),e}resetWithSeed(){return this.refreshStore(),this.refreshPool(),this}reset(){return this.refreshPool(),this}get len(){return this.store.len}get poolLen(){return this.pool.len}get poolOptions(){return this.pool.options}rateOf(t){return this.pool.rateOf(t)}export(){return this.store.export()}exportPool(){return this.pool.export()}}});return t.Cookie=ln,t.Debounce=(...t)=>_t((e=>dt(e.value,...t))),t.Download=Ye,t.EventBus=Nt,t.ListCache=vt,t.MergeImg=nn,t.ObjFromEntries=w,t.OneByOne=class{constructor(t,e){this.status=Ut.default,this.joinWord="",this.sayWord=t,this.wordArr=t.split(""),this.config=e}run(){this.timer=window.setTimeout((()=>{if(this.status!==Ut.default)return;const t=this.wordArr.shift();this.joinWord+=t;const e=this.wordArr.length;let n=!!e;if(this.config.callback){const r=this.config.callback.call(this,t,this.joinWord,this.sayWord);e&&!1===r&&(this.status=Ut.pause),n=!!e&&!1!==r}else console.log(t);if(!e)return this.status=Ut.stop,void(this.config.loop&&this.replay());n&&this.run()}),this.config.delay)}play(){this.status!==Ut.stop&&(this.status=Ut.default,this.run())}replay(){clearTimeout(this.timer),this.status=Ut.default,this.wordArr=this.sayWord.split(""),this.joinWord="",this.run()}pause(){this.status!==Ut.stop&&(this.status=Ut.pause,clearTimeout(this.timer))}stop(){this.status===Ut.default&&(this.status=Ut.stop,clearTimeout(this.timer))}},t.Polling=(t,e=!0)=>_t((n=>{let r;!function(t){t[t.running=0]="running",t[t.stopped=1]="stopped"}(r||(r={}));const o=n.value;let i,s;function c(){s=r.stopped,clearTimeout(i)}function u(){c();const n=new Promise(((n,u)=>{let a=0;function l(){i=setTimeout(f,t)}function h(){c(),n()}const f=()=>{const t=o.call(this,a++,n,u);s===r.running&&(t instanceof Promise?t.then((function(){l()})).catch(h):!1===t?h():l())};s=r.running,e?f():l()}));return n.finally(c),n}return u.stop=c,u})),t.Pool=class{constructor(t){this.itemClass=t,this.events=new Nt,this._aliveList=[],this._recycleList=[]}get aliveList(){return this._aliveList.slice()}get recycleList(){return this._recycleList.slice()}get length(){return this._aliveList.length}push(t,e){t=null!=t?t:this.getRecycleOne()||new this.itemClass;const n=this._aliveList.indexOf(t);return n>-1&&this._aliveList.splice(n,1),this._aliveList.push(t),this.events.emit("add",t,e),t}remove(t,e){const n=this._aliveList.indexOf(t);if(-1!==n)return this._aliveList.splice(n,1),this._recycleList.push(t),this.events.emit("remove",t,e),t}pop(t){const e=this._aliveList;if(0===e.length)return;const n=e.pop();return this._recycleList.push(n),this.events.emit("remove",n,t),n}shift(t){const e=this._aliveList;if(0===e.length)return;const n=e.shift();return this._recycleList.push(n),this.events.emit("remove",n,t),n}unshift(t,e){t=null!=t?t:this.getRecycleOne()||new this.itemClass;const n=this._aliveList,r=n.indexOf(t);return r>-1&&n.splice(r,1),n.unshift(t),this.events.emit("add",t,e),t}getRecycleOne(){return this._recycleList.shift()}forEach(t){this._aliveList.forEach(t)}},t.RGB=ce,t.RGBA=ue,t.RandomPicker=dn,t.ResponsibilityChain=le,t.SetCache=bt,t.Stack=Et,t.StorageProxy=class{constructor(t,e){this.storage=t,e&&g(this,e)}encodeKey(t){return t}decodeKey(t){return t}encodeValue(t){return t}decodeValue(t){return t}parseValue(t,e){if(!e)return null;const n=JSON.parse(e);return n.exp<Date.now()?(this.storage.removeItem(t),null):n.value}handleValue(t,e){let n;switch(typeof e){case"number":n=Date.now()+e;break;case"undefined":n=Number.MAX_SAFE_INTEGER;break;default:n=e.getTime()}return JSON.stringify({value:t,exp:n})}get length(){return this.storage.length}setItemWithExp(t,e,n){const r=this.encodeKey(t);e=this.handleValue(e,n);const o=this.encodeValue(e);this.storage.setItem(r,o)}setItem(t,e){this.setItemWithExp(t,e)}getItem(t){const e=this.encodeKey(t);let n=this.storage.getItem(e);return n=this.decodeValue(n),this.parseValue(e,n)}key(t){return this.decodeKey(this.storage.key(t))}removeItem(t){this.storage.removeItem(this.encodeKey(t))}clear(){this.storage.clear()}},t.Throttle=(...t)=>_t((e=>pt(e.value,...t))),t.UrlModel=Ft,t.UrlRegExp=Qt,t.addClass=je,t.addClassIe8=Ae,t.addClassStandard=De,t.addDragEventListener=be,t.addResizeListener=function(t,e){if(!(t instanceof HTMLElement))throw new TypeError("Parameter 1 is not instance of 'HTMLElement'.");if(/^(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr|script|style|textarea|title)$/i.test(t.tagName))throw new TypeError("Unsupported tag type. Change the tag or wrap it in a supported tag(e.g. div).");if("function"!=typeof e)throw new TypeError("Parameter 2 is not of type 'function'.");let n=t.offsetWidth||1,r=t.offsetHeight||1;const o=1e4*n,i=1e4*r,s=document.createElement("div");s.className="expand",s.style.cssText="position:absolute;top:0;bottom:0;left:0;right:0;z-index=-10000;overflow:hidden;visibility:hidden;";const c=s.cloneNode(!1);c.className="shrink";const u=document.createElement("div");u.style.cssText="transition:0s;animation:none;";const a=u.cloneNode(!1);u.style.width=o+"px",u.style.height=i+"px",a.style.width="250%",a.style.height="250%",s.appendChild(u),c.appendChild(a),t.appendChild(s),t.appendChild(c),s.offsetParent!==t&&(t.style.position="relative"),s.scrollTop=c.scrollTop=i,s.scrollLeft=c.scrollLeft=o;let l=0,h=0;function f(){l===n&&h===r||(n=l,r=h,console.log("onResize"),e())}function d(){console.log("onScroll"),l=t.offsetWidth||1,h=t.offsetHeight||1,l===n&&h===r||requestAnimationFrame(f),s.scrollTop=c.scrollTop=i,s.scrollLeft=c.scrollLeft=o}s.addEventListener("scroll",d),c.addEventListener("scroll",d)},t.addScaleEventListener=function(t,e,n={down:!1,up:!0,move:!1}){let r=t;if(!de(t))if($(t)){if(r=document.querySelector(t),!r)throw new Error("element not found!")}else r=window;let o=0;function i(t){const e=t[0],n=t[1];return Pt([e.pageX,e.pageY],[n.pageX,n.pageY])}function s(t){t.touches.length<2||e(+i(t.touches).toFixed(2),o)}function c(){a()}function u(t){t.touches.length<2||(window.addEventListener("touchmove",s,n.move),window.addEventListener("touchend",c,n.up),window.addEventListener("touchcancel",c,n.up),o=+i(t.touches).toFixed(2))}function a(){window.removeEventListener("touchmove",s,n.move),window.removeEventListener("touchend",c,n.up),window.removeEventListener("touchcancel",c,n.up)}return r.addEventListener("touchstart",u,n.down),function(){r.removeEventListener("touchstart",u,n.down),a()}},t.animateTo=function({from:t,to:e,callback:n,speed:r=.5,immediate:o=!0,minStepDenominator:i=50}){const s=r;let c,u,a,l,h=1;function f(){c=!1,u=t,h=e>t?1:-1,r=s,l=Math.max(Math.abs(e),Math.abs(t))/i,a=t>e?()=>u<=e:()=>u>=e,o&&n(u)}function d(){if(!c)if(a())p(),u=e,n(u);else{const t=Math.max(Math.abs(u-e),1),o=Math.min(t/10*r,l)*h;u+=o,n(u),window.requestAnimationFrame(d)}}function p(){c=!0}return f(),d(),{isStop:()=>c,reset(){f(),d()},reverse(){[e,t]=[t,e],f(),d()},run(){c=!1,d()},stop:p}},t.arrayRemoveItem=V,t.arrayRemoveItemsBy=function(t,e){const n=[];return B(e,((r,o,i)=>{if(!t(r,o,i))return;const s=e.splice(o,1)[0];n.unshift(s)})),n},t.assign=l,t.at=function(t,e,n){return"number"==typeof e&&e<0&&(e=t.length+e),E(t,e)?t[e]:n},t.base64ToBlob=function(t){const{mime:e,uint8Array:n}=rn(t);return new Blob([n],{type:e})},t.base64ToFile=function(t,e){const{mime:n,uint8Array:r}=rn(t),o=e||Date.now()+"."+n.replace(/^.*\//,"");return new File([r],o,{type:n})},t.binaryFind=function(t,e){let n=0,r=t.length;for(;n<r;){const o=~~((r+n)/2),i=t[o],s=e(i,o,t);if(0===s)return i;s>0?n=o+1:r=o}},t.binaryFind2=function t(e,n,r=0){if(0===e.length)return;let o,i=Math.floor(e.length/2);const s=e[i],c=n(s,i+r,e);return 0===c?s:1!==e.length?(c>0?(i++,o=t(e.slice(i),n,r+i)):o=t(e.slice(0,i),n,r),o):void 0},t.binaryFindIndex=function(t,e){if(0===t.length)return-1;let n=0,r=t.length;do{const o=Math.floor((r-n)/2)+n,i=e(t[o],o,n,r);if(0===i)return o;i>0?n=o+1:r=o}while(r>n);return-1},t.blobToBase64=function(t){return new Promise(((e,n)=>{const r=new FileReader;r.onload=t=>{e(t.target.result)},r.readAsDataURL(t),r.onerror=r.onabort=()=>{n(new Error("blobToBase64 error"))}}))},t.calcArr=Ct,t.calcRelativeDate=function(t){const e=t.getTime()-Date.now();return()=>new Date(Date.now()+e)},t.capitalize=it,t.castArray=X,t.chinese2Number=rt,t.chunk=function(t,e){if(!C(t))throw new TypeError("chunk param arr type error");if(e<1)return t.slice();const n=[];let r=0;for(;r<t.length;)n.push(t.slice(r,r+=e));return n},t.cloneFunction=function(t){if("function"!==S(t))return t;let e=t.toString();return e=e.replace(/(function)? ?\w+ ?\(/,"function("),new Function("return "+e)()},t.copy2Clipboard=cn,t.createArray=N,t.createElement=He,t.createEnum=function(t){const e={};return t.forEach(((t,n)=>{e[t]=n,e[n]=t})),Object.freeze(e),e},t.createEnumByObj=function(t){return l({},t,o(t))},t.createHiddenHtmlElement=ze,t.createHtmlElement=Be,t.createObj=m,t.createTimeCountDown=ht,t.createTimeCountUp=lt,t.createUUID=function(t){const e=[];for(let n=0;n<t;n++)e[n]="0123456789abcdef".substr(16*Math.random(),1);return e.join("")},t.cssSupport=function(t,e){return t in Le&&(Le[t]=e,Le[t]===e)},t.dateDiff=function(t,e,n="y年d天hh时mm分ss秒"){let r=n;t.getTime()>e.getTime()&&([t,e]=[e,t]);const o=e.getTime()-t.getTime(),i=~~(o/1e3),s={"S+":o%1e3,"s+":i%60,"m+":~~(i/60)%60,"h+":~~(i/3600)%24,"d+":function(){const t=~~(i/86400);return/y+/.test(r)?t%365:t}(),"y+":~~(i/31536e3)};for(const c in s){if(new RegExp("("+c+")").test(r)){const t=RegExp.$1;let e=J(String(s[c]),t.length,"0");e=e.substring(e.length-t.length),r=r.replace(t,e)}}return r},t.debounce=dt,t.debounceAsync=function(t,n){let r,o=null;return function(...i){return new Promise(((s,c)=>{null!==o&&(clearTimeout(o),o=null,r("debounceAsync reject")),r=c,o=setTimeout((()=>e(this,void 0,void 0,(function*(){o=null;const e=yield t.apply(this,i);s(e)}))),n)}))}},t.debounceByPromise=function(t){let n;return function(...r){return n&&n(),new Promise(((o,i)=>e(this,void 0,void 0,(function*(){n=i;const e=yield t.apply(this,r);o(e)}))))}},t.debounceCancelable=function(t,e){let n=null;function r(){n&&(clearTimeout(n),n=null)}return function(...o){return r(),n=setTimeout((()=>{n=null,t.apply(this,o)}),e),r}},t.decoratorfy=_t,t.deepClone=function(t){const e=new Et;return function t(n){const r=S(n);if(R(n)){if(e.has(n))return n;e.set(n)}const o=xt[r],i=o?o(n):n;if(-1===["object","array","function"].indexOf(r))return i;const s=n;for(const e in s)E(s,e)&&(i[e]=t(s[e]));return i}(t)},t.deepCloneBfs=St,t.deepMerge=function(t,e){function n(t,e){for(const r in e){if(!E(e,r))continue;const o=e[r];o&&"object"==typeof o?(t[r]=new o.constructor,n(t[r],o)):t[r]=o}}const r={};return n(r,t),n(r,e),r},t.defaults=function(t,...e){return e.forEach((e=>{n(e,((e,n)=>{void 0!==e&&void 0===t[n]&&(t[n]=e)}))})),t},t.divide=It,t.eventProxy=function(t,e,n,r){let o;function i(t){t=t||window.event;H(de(n)?[n]:document.querySelectorAll(n),t.target)&&r(t)}return o=t?de(t)?t:document.querySelector(t):document.documentElement,null===o?null:(o.addEventListener(e,i),function(){o.removeEventListener(e,i)})},t.filter=function(t,e){const n=[],r=t.length;for(let o=0;o<r;o++){const r=t[o];e(r,o,t)&&n.push(r)}return n},t.find=function(t,e){const n=t.length;for(let r=0;r<n;r++){const n=t[r];if(e(n,r,t))return n}},t.findIndex=z,t.findIndexRight=W,t.flat=function(t,e=1){return function t(n,r=0){if(!C(n)||r++===e)return n;const o=[];for(let e=0;e<n.length;e++){const i=t(n[e],r);o.push(...C(i)?i:[i])}return o}(t)},t.forEach=U,t.forEachAsync=F,t.forEachByLen=function(t,e){for(let n=0;n<t&&!1!==e(n);n++);},t.forEachByLenRight=function(t,e){for(let n=t-1;n>=0&&!1!==e(n);n--);},t.forEachObj=n,t.forEachRight=B,t.formatDate=ct,t.formatJSON=function(t,e=2){if("string"==typeof t)try{t=JSON.parse(t)}catch(n){throw new TypeError}return function t(n,r=0){switch(typeof n){case"object":const o=C(n),i="\r\n"+" ".repeat(e*r)+(o?"]":"}");let s=0,c=o?"[\r\n":"{\r\n";for(const u in n){if(!E(n,u))continue;const i=n[u];s&&(c+=",\r\n");const a=" ".repeat(e*r+e),l=t(i,r+1);c+=o?`${a}${l}`:`${a}"${u}":${l}`,s++}return c+i;case"function":return`"${n.toString()}"`;default:return $(n)?'"'+n+'"':n}}(t)},t.from=function(t,e=(t=>t)){const n=[];if(O(t))U(t,((t,r)=>{n.push(e(t,r))}));else for(const r of t)n.push(e(r));return n},t.fromCamel=st,t.functionApply=function(t,e,n){return new Function(mt(n.length))(t,e,n)},t.generateFunctionCode=mt,t.get1rem=qe,t.getAngle=function(e,n,r=t.Direct.top){const[o,i]=e,[s,c]=n,u=Math.atan2(s-o,c-i)*(180/Math.PI);return{[t.Direct.top]:180-u,[t.Direct.right]:u,[t.Direct.bottom]:360-u,[t.Direct.left]:u+180}[r]},t.getAverageRGB=function(t){const e={r:0,g:0,b:0},n=document.createElement("canvas"),r=n.getContext&&n.getContext("2d");let o=-4;const i={r:0,g:0,b:0};let s=0;if(!r)return e;const c=n.height=t.naturalHeight||t.offsetHeight||t.height,u=n.width=t.naturalWidth||t.offsetWidth||t.width;let a;r.drawImage(t,0,0);try{a=r.getImageData(0,0,u,c)}catch(h){return e}const l=a.data.length;for(;(o+=20)<l;)++s,i.r+=a.data[o],i.g+=a.data[o+1],i.b+=a.data[o+2];return i.r=~~(i.r/s),i.g=~~(i.g/s),i.b=~~(i.b/s),i},t.getBorderWidthByCos=function(t,e,n){const r=n*Math.PI/180,o=Math.pow(t,2)+Math.pow(e,2)-2*t*e*Math.cos(r);return Math.sqrt(o)},t.getBorderWidthBySin=function(t,e,n){const r=Math.PI/180,o=r*n;return t/Math.sin(r*e)*Math.sin(o)},t.getCommonPow=Rt,t.getCurrentScriptTag=function(){if(document.currentScript)return document.currentScript;const t=document.scripts;return t.length?t[t.length-1]:null},t.getDateFromStr=ut,t.getDistance=Pt,t.getFontScale=function(t=!1){const e=He("div",{props:{style:{fontSize:"10px"}},parent:document.body}),n=getComputedStyle(e).fontSize;return document.body.removeChild(e),t?10/parseInt(n):parseInt(n)/10},t.getInsKeys=p,t.getMilliseconds=function({days:t=0,hours:e=0,minutes:n=0,seconds:r=0}={}){const o=36e5;let i=1e3*r;return i+=6e4*n,i+=e*o,i+=t*o*24,i},t.getMonthTheNthWeekday=function(t,e,n=0){if(!e||!K(n,[0,7]))return null;const r=t.getTime(),o=ft(t);let i;e>0?(i=new Date(r),i.setDate(1)):i=new Date(o.getTime());const s=(n=0===n?7:n)-i.getDay();e>0?s>=0&&e--:s<=0&&e++;const c=7*e+i.getDate()+s;return c>o.getDate()||c<1?null:(i.setDate(c),i)},t.getNumberLenAfterDot=Lt,t.getObjPathEntries=function t(e,n=""){return i(e,((e,r,o)=>{const i=`${n}[${o}]`;return R(r)?e.push(...t(r,i)):e.push([i,r]),e}),[])},t.getObjValueByPath=function(t,e,n=""){return v(e,n).split(".").reduce(((t,e)=>{if(R(t))return t[e]}),t)},t.getReverseObj=o,t.getRotatePoint=function(t,e,n){const r=Math.PI/180*n;return[At.init(e)["*"](Math.sin(r))["+"](t[0]).value,At.init(e)["*"](Math.cos(r)).by(t[1],"-").value]},t.getSafeNum=Dt,t.getStringLen=function(t){const e="[\ud800-\udbff][\udc00-\udfff]";return t.replace(new RegExp(`${e}(${e})+`,"g"),"_").replace(new RegExp(`${e}\ud83c[\udffc-\udfff]`,"g"),"_").replace(new RegExp(e,"g"),"_").length},t.getTheLastDateOfAMonth=ft,t.getTreeMaxDeep=function(t){return function e(r,o=0){if("object"!=typeof t||null===t)return o;const i=[++o];return n(r,(t=>{i.push(e(t,o))})),Math.max(...i)}(t)},t.getTreeNodeLen=function(t,e=1){let r=0;return"object"!=typeof t||null===t||e<0||function t(o,i=0){e!==i++?n(o,(e=>{t(e,i)})):r++}(t),r},t.getUrlHash=Gt,t.getUrlHashParam=function(t,e=location.href,n=!1){return Yt(t,Gt(e),n)},t.getUrlHost=Wt,t.getUrlParam=Yt,t.getUrlParamObj=Xt,t.getUrlPath=Vt,t.getUrlPort=qt,t.getUrlProtocol=Ht,t.getUrlQuery=Kt,t.groupBy=function(t,e,n="*"){const r=I(e)?e:t=>t[e];return t.reduce(((t,e)=>{var o;const i=null!==(o=r(e,t))&&void 0!==o?o:n;return E(t,i)?t[i].push(e):t[i]=[e],t}),{})},t.hasClass=Ie,t.hasClassIe8=$e,t.hasClassStandard=Me,t.hasOwn=E,t.hostReg=zt,t.hslToRgb=function(t){const e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t),n=Number(e[1])/360,r=Number(e[2])/100,o=Number(e[3])/100;function i(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}let s,c,u;if(0==r)s=c=u=o;else{const t=o<.5?o*(1+r):o+r-o*r,e=2*o-t;s=i(e,t,n+1/3),c=i(e,t,n),u=i(e,t,n-1/3)}return`rgb(${Math.round(255*s)},${Math.round(255*c)},${Math.round(255*u)})`},t.idGen=function*(t=0,e=1,n=Number.MAX_SAFE_INTEGER){let r=t;const o=t<n?()=>r<n:()=>r>n;for(;o();){const t=(yield r)||e;r+=t}},t.imgToBlob=function(t){return new Promise(((e,n)=>{const r=new XMLHttpRequest;r.open("get",t,!0),r.responseType="blob",r.onload=function(){200==this.status?e(this.response):n()},r.onerror=r.onabort=n,r.send()}))},t.inIframe=function(){return Boolean(wt.self.frameElement&&"IFRAME"===wt.self.frameElement.tagName||wt.frames.length!==parent.frames.length||wt.self!==wt.top)},t.inRange=K,t.inRanges=function(t,...e){return e.some((e=>K(t,e)))},t.inSameWeek=function({date:t,weekStart:e="Mon",now:n=new Date}){const r=t.getTime(),o=n.getDay(),i=n.getDate(),s=new Date(n.getFullYear(),n.getMonth(),i),c=new Date(s),u="Mon"===e?1:0;return s.setDate(i-o+u),c.setDate(i+(7-o+u)),s.getTime()<r&&r<c.getTime()},t.inTypes=function(t,e){const n=S(t);if(!C(e))throw TypeError("inTypes param types expected Array<string> but received "+n);return e.indexOf(n)>-1},t.includes=H,t.insertToArray=q,t.isArray=C,t.isArrayLike=O,t.isArrayObj=function(t){const e=y(t),n=/\d+/;return C(t)&&e.some((t=>!n.test(String(t))))},t.isBoolean=function(t){return"boolean"===S(t)},t.isBroadlyObj=R,t.isChildHTMLElement=function(t,e=document.documentElement){const n="string"==typeof t?document.querySelector(t):t;if(!n)throw"child not founded";const r="string"==typeof e?document.querySelector(e):e;if(!r)throw"parent not founded";const o=document.documentElement;return function t(e,n){return!!e&&(e!==n&&(e!==o&&(e.parentNode===n||t(e.parentNode,n))))}(n,r)},t.isDivElement=function(t){return pe("DIV",t)},t.isDom=de,t.isDomIe8=he,t.isDomStandard=fe,t.isElementOf=pe,t.isEmpty=function(t){if(H([void 0,null,"",NaN],t))return!0;switch(S(t)){case"array":return!t.length;case"object":return P(t)}return!1},t.isEmptyObject=P,t.isEqual=k,t.isFunction=I,t.isHEXColor=function(t){return/^#([\da-fA-F]{3}){1,2}$/.test(t)},t.isImgElement=ye,t.isIncludeChinese=function(t){return/[\u4e00-\u9fa5]/.test(t)},t.isInputElement=me,t.isInteger=function(t){return t%1==0},t.isIterable=function(t){try{for(const e of t)break;return!0}catch(e){return!1}},t.isNaN=j,t.isNative=x,t.isNodeList=ve,t.isNumber=M,t.isObject=T,t.isObjectLike=L,t.isPercent=function(t){return/^\d+(\.\d+)?%$/.test(t.trim(