@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
*/
function t(t){return function e(n,o=0){if("object"!=typeof t||null===t)return o;const i=[++o];return r(n,(t=>{i.push(e(t,o))})),Math.max(...i)}(t)}function e(t,e=1){let n=0;if("object"!=typeof t||null===t||e<0)return n;return function t(o,i=0){e!==i++?r(o,(e=>{t(e,i)})):n++}(t),n}function n(t,e){function n(t,e){for(const r in e){if(!k(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}function r(t,e,n){for(const r in t){if(!k(t,r))continue;if(!1===e(t[r],r,t))return!1}return n&&n(),!0}const o=r;function i(t){return s(t,((t,e,n)=>(t[e]=n,t)),{})}function s(t,e,n){let o=n;return r(t,((t,n,r)=>{o=e(o,t,n,r)})),o}const c=s;function u(t,e,n){const r=n||(t=>t);return e.reduce(((e,n)=>(k(t,n)&&(e[n]=r(t[n],n,t)),e)),{})}function l(t,e,n){const r=n||(t=>t);return s(e,((e,n,o)=>(k(t,n)&&(e[o]=r(t[n],n,t)),e)),{})}function a(t,e,n){return N(e)?l(t,e,n):u(t,e,n)}function h(t,e,n){const r=n||((t,e,n,r)=>k(r,n)&&t===e||K(t)&&K(e));return e.reduce(((e,n)=>(o(n,((o,i)=>{r(t[i],o,i,t,n)||(e[i]=o)})),e)),{})}function f(t,...e){return h(t,e,((e,n,r)=>k(t,r)))}function d(t,e){const n=g({},t),o=[],i=[];return r(e,((t,e)=>{k(n,t)&&(n[e]=n[t],o.push(t),i.push(e))})),o.forEach((t=>{i.indexOf(t)>-1||delete n[t]})),n}function p(t,e){const n=e.slice();return s(t,((t,e,r)=>{const o=n.indexOf(r);return-1===o?t[r]=e:n.splice(o,1),t}),{})}function g(t,...e){return e.forEach((e=>{r(e,((e,n)=>{t[n]=e}))})),t}function m(t,...e){return e.forEach((e=>{r(e,((e,n)=>{void 0!==e&&void 0===t[n]&&(t[n]=e)}))})),t}function w(t,e,n){ht(e,(e=>{if(e&&k(e,n))return t[n]=e[n],!1}))}function v(t,...e){return e[e.length-1]===t||o(t,((n,r)=>w(t,e,r))),t}const y=v;function b(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 Lt(e.filter((t=>"constructor"!==t)))}function E(t,...e){if(e[e.length-1]===t)return t;return b(t).forEach((n=>w(t,e,n))),t}function x(t,e,n=((t,e)=>t===e||K(t)&&K(e))){return c(t,((r,o,i)=>(ht(e,(function(e){if(e&&k(e,i))return n(t[i],e[i])||(r[i]=e[i]),!1})),r)),{})}function T(t){return t.reduce(((t,e)=>{if(!z(e)||e.length<1)throw new TypeError("createObj args type error");const[n,r]=e;return void 0!==n&&(t[n]=r),t}),{})}const S=T;function L(t){return s(t,((t,e,n)=>(t.push(n),t)),[])}function $(t){return s(t,((t,e)=>(t.push(e),t)),[])}function R(t){return s(t,((t,e,n)=>(t.push([n,e]),t)),[])}function M(t,e=""){let n=t;return n=n.replace(new RegExp(`^${e}`),""),n=n.replace(/\[([^\]]+)]/g,".$1"),n=n.replace(/^\.|\[]/g,""),n}function _(t,e,n=""){return M(e,n).split(".").reduce(((t,e)=>{if(F(t))return t[e]}),t)}function I(t,e,n,r=((t,e)=>e),o=""){const i=M(e,o).split("."),s=i.length-1;return i.reduce((([t,e],o,i)=>(e+=e?"."+o:o,i===s?(k(t,o)&&(n=r(t[o],n,!0,e)),t[o]=n,[t[o],e]):(F(t[o])||(t[o]=k(t,o)?r(t[o],{},!1,e):{}),[t[o],e]))),[t,""]),t}function A(t,e=""){return s(t,((t,n,r)=>{const o=`${e}[${r}]`;return F(n)?t.push(...A(n,o)):t.push([o,n]),t}),[])}function C(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(P(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 O(t,e=(t=>t)){return c(t,((t,n,r)=>(e(n,r)&&(t[r]=n),t)),{})}function k(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function D(t){const e=RegExp(`^${Function.prototype.toString.call(Object.prototype.hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\])/g,"$1.*?")}$`);return F(t)&&e.test(t)}function P(t){const e=typeof t;return"object"!==e?e:Object.prototype.toString.call(t).slice(8,-1).toLowerCase()}function N(t){return"object"===P(t)}function j(t){const e=typeof t;return null!=t&&("object"===e||"function"===e)}const F=j;function z(t){return"array"===P(t)}function U(t){const e=P(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||W(n)&&n>0&&n-1 in t)}function H(t){return"string"===P(t)}function W(t){return"number"===P(t)}function q(t){return"function"===P(t)}function V(t){return"boolean"===P(t)}function B(t){return void 0===t}function X(t,e){const n=P(t);if(!z(e))throw TypeError("inTypes param types expected Array<string> but received "+n);return e.indexOf(n)>-1}function G(t){const e=typeof t;return!!t&&("object"===e||"function"===e)&&"function"==typeof t.then}function K(t){return W(t)&&t!=t}function Y(t){if(!N(t))return!1;for(const e in t)return void 0===e;return!0}function J(t){if(pt([void 0,null,"",NaN],t))return!0;switch(P(t)){case"array":return!t.length;case"object":return Y(t)}return!1}function Z(t,e){if(t===e)return!0;const n=P(t);if(n!==P(e))return!1;switch(n){case"boolean":case"string":case"function":return!1;case"number":return K(e);default:return Q(t,e)}}function Q(t,e){if(t===e)return!0;for(const n in t){if(!Z(t[n],e[n]))return!1}return!0}function tt(t,e){return P(t)===P(e)}function et(t){try{for(const e of t)break;return!0}catch(e){return!1}}function nt(t){return/^\d+(\.\d+)?%$/.test(t.trim())}function rt(t){return/[\u4e00-\u9fa5]/.test(t)}function ot(t){return t%1==0}function it(t){const e=L(t),n=/\d+/;return z(t)&&e.some((t=>!n.test(String(t))))}function st({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)),P(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 ct(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}async function ut(t,e){const n=t.length;for(let r=0;r<n;r++){if(!1===await e(t[r],r,t))break}}async function lt(t,e){const n=[];return await ut(t,(async(t,r,o)=>{const i=await e(t,r,o);n.push(i)})),n}async function at(t,e,n){const r=t.length;if(!r){if(void 0===n)throw new Error("Reduce of empty array with no initial value");return Promise.resolve(n)}let o=null!=n?n:await t[0]();for(let i=n?0:1;i<r;i++){const n=t[i],r=await e(o,n,i,t);if(!1===r)break;o=r}return o}function ht(t,e){for(let n=t.length-1;n>-1&&!1!==e(t[n],n,t);n--);}function ft(t,e=(t=>t)){const n=[];if(U(t))ct(t,((t,r)=>{n.push(e(t,r))}));else for(const r of t)n.push(e(r));return n}function dt(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}function pt(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(K(n)&&K(e))return!0}return!1}function gt(t,e){const n=t.length;for(let r=0;r<n;r++){const n=t[r];if(e(n,r,t))return n}}function mt(t,e){const n=t.length;for(let r=0;r<n;r++){if(e(t[r],r,t))return r}return-1}function wt(t,e){for(let n=t.length-1;n>=0;n--){if(e(t[n],n,t))return n}return-1}function vt(t,e=1){return function t(n,r=0){if(!z(n)||r++===e)return n;const o=[];for(let e=0;e<n.length;e++){const i=t(n[e],r);o.push(...z(i)?i:[i])}return o}(t)}function yt(t,e,n=0){if(0===t.length)return;let r,o=Math.floor(t.length/2);const i=t[o],s=e(i,o+n,t);return 0===s?i:1!==t.length?(s>0?(o++,r=yt(t.slice(o),e,n+o)):r=yt(t.slice(0,o),e,n),r):void 0}function bt(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}}function Et(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}function xt(t,e,n,{after:r=!1,reverse:o=!1}={}){const i=$t(t);let s=e;if(q(e)){if(s=(o?wt:mt)(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 Tt(t,e){const n=e.indexOf(t);if(-1!==n)return e.splice(n,1)[0]}function St(t,e){const n=[];return ht(e,((r,o,i)=>{if(!t(r,o,i))return;const s=e.splice(o,1)[0];n.unshift(s)})),n}function Lt(t,e){if(!t.length)return t;const n=e||((t,e)=>t===e||K(t)&&K(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 $t(t){return z(t)?t:[t]}function Rt(t,e){if(!z(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}function Mt(t,[e=-1/0,n=1/0]){return e<=t&&t<=n}function _t(t,...e){return e.some((e=>Mt(t,e)))}function It(t,e,n="*"){const r=q(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 k(t,i)?t[i].push(e):t[i]=[e],t}),{})}function At(t,e,n=((t,e,n)=>pt(n,t))){return t.some(((t,r)=>n(t,r,e)))}function Ct(t,e=!1,n=","){const r=String(t).split(".");return r[0]=r[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,n),1!==r.length&&e?(r[1]=r[1].replace(/(\d{3})/g,`$1${n}`),r.join(".").replace(new RegExp(`${n}$`),"")):r.join(".")}function Ot(t,...e){return t.replace(/%s/g,(function(){return e.length?e.shift():""}))}function kt(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 Dt(t,e,n=" ",r=!1){if(t.length>=e||""===n)return r?t.substr(0,e):t;const o=e-t.length;return t+kt(t,e,n).substr(0,o)}const Pt=["零","一","二","三","四","五","六","七","八","九"],Nt=["十","百","千"],jt=["",...Nt,"万",...Nt,"亿"],Ft=jt.length,zt=function(t){let e=~~t,n="",r=0;if(t>=0&&t<10)return zt.numbers[t];for(;e>=1&&r<Ft;){const t=zt.units[r],o=zt.numbers[e%10];o!==zt.numbers[0]&&(n=t+n),1===e&&1===r||(n=o+n),e=~~(e/10),r++}return n.replace(/(零+$)|((零)\3+)/g,"$3")};zt.units=[...jt],zt.numbers=[...Pt];const Ut=function(t){if(new RegExp(`([^${Ut.units.join()+Ut.numbers.join()}])`).test(t))throw new TypeError("发现不符合规则的字符(必须在units和numbers里存在的字符):"+RegExp.$1);return t.split(new RegExp(`[${Ut.units[4]}${Ut.units[8]}]`,"g")).map((t=>{let e=0,n=1;for(let r=t.length-1;r>-1;r--){const o=t[r],i=Ut.numbers.indexOf(o);i>0&&(e+=i*n);const s=Ut.units.indexOf(o);n=s>0?10**s:n}return t[0]===Ut.units[1]&&(e+=10),e})).reverse().reduce(((t,e,n)=>t+1e4**n*e),0)};function Ht(t,e,n){let r=1;return String(t).replace(new RegExp(n,"g"),(t=>r++===e?"":t))}function Wt(t,e,n=t.length){return n<0&&(n+=t.length),t.substring(e,n)}function qt(t,e){if(e<0||e*t.length>qt.MAX_STR_LENGTH)throw new RangeError("strRepeat Invalid repeatCount value");let n="";if(""===t)return"";for(;e-- >0;)n+=t;return n}function Vt(t){let e;const n=/(\d+)\[([^[\]]+)](?!\d+\[)/;for(;e=n.exec(t);){const[,r,o]=e;t=t.replace(n,qt(o,Number(r)))}return t}function Bt(t){if(!t.length)return t;return`${t[0].toUpperCase()}${t.substring(1).toLowerCase()}`}function Xt(t,e="_",n=!1){const r=t.replace(/([A-Z]+)/g,((t,n,r)=>(r>0?e:"")+n.toLowerCase()));return n?r.toUpperCase():r}function Gt(t,e="_",n=!1){if(!t.length)return t;const r="string"==typeof e?new RegExp(e+"+"):e,o=t.split(r).map((t=>Bt(t)));return!n&&o.length&&(o[0]=o[0].toLowerCase()),o.join("")}function Kt(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}function Yt(t,e="d天hh时mm分ss秒"){let n=e;const r=t/1e3,o={"s+":r%60,"m+":~~(r/60)%60,"h+":~~(r/3600)%24};n=n.replace(/d+/,String(~~(r/86400)));for(const i in o){if(new RegExp("("+i+")").test(n)){const t=RegExp.$1;let e=String(o[i]).padStart(t.length,"0");e=e.substring(e.length-t.length),n=n.replace(t,e)}}return n}function Jt(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=kt(String(s[c]),t.length,"0");e=e.substring(e.length-t.length),r=r.replace(t,e)}}return r}Ut.units=[...jt],Ut.numbers=[...Pt],qt.MAX_STR_LENGTH=536870912;const Zt=function(t,e="yyyy-MM-dd hh:mm:ss",{seasonText:n=Zt.seasonText,weekText:r=Zt.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,kt(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,kt(n,t.length,"0"))}return e};function Qt(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])}Zt.weekText=["日","一","二","三","四","五","六"],Zt.seasonText=["春","夏","秋","冬"];const te=Qt;function ee(t){return new Promise((e=>setTimeout(e,t)))}function ne(){const t=Date.now();return function(){return Date.now()-t}}function re(t){const e=ne();return function(){return t-e()}}function oe(t){const e=new Date(t.getTime());return e.setMonth(t.getMonth()+1),e.setDate(0),e}function ie(t,e,n=0){if(!e||!Mt(n,[0,7]))return null;const r=t.getTime(),o=oe(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)}function se({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}function ce(t,e,...n){const r=Zt(e,t);return n.every((e=>Zt(e,t)===r))}function ue({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()}function le(t,e){let n=t.getMonth()-e.getMonth();n+=12*(t.getFullYear()-e.getFullYear());return n+=~~(100*(t.getDate()-e.getDate())/(oe(t).getDate()-1))/100,~~(1e3*n/12)/1e3}function ae(t){const e=t.getTime()-Date.now();return()=>new Date(Date.now()+e)}function he(t,e,n=!1){let r,o,i,s,c=!0;const u=()=>{clearTimeout(s),s=void 0},l=function(...t){return s&&u(),r=this,o=t,c&&n?(l.flush(),c=!1,s=setTimeout((()=>{c=!0}),e),i):(s=setTimeout((()=>{u(),l.flush(),c=!0}),e),i)};return l.cancel=u,l.flush=()=>(i=t.apply(r,o),r=o=void 0,i),l}function fe(t,e){let n,r=null;return function(...o){return new Promise(((i,s)=>{null!==r&&(clearTimeout(r),r=null,n("debounceAsync reject")),n=s,r=setTimeout((async()=>{r=null;const e=await t.apply(this,o);i(e)}),e)}))}}function de(t,e,n=(()=>{})){let r=()=>0;return function(...o){const i=r();if(!(i>0))return r=re(e),t.apply(this,o);n(i)}}function pe(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}}function ge(t){let e;return function(...n){return e&&e(),new Promise((async(r,o)=>{e=o;r(await t.apply(this,n))}))}}function me(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 l(){const e=t(s++);e instanceof Promise?e.then(a):a()}function a(){const t=e-u;o=setTimeout((()=>{if(i!==r.running)return;const e=Date.now();u=e-c-t,c=e,l()}),t)}return i=r.running,n?l():a(),function(){i=r.stopped,clearTimeout(o)}}function we(t,e){for(let n=0;n<t&&!1!==e(n);n++);}function ve(t,e){for(let n=t-1;n>=0&&!1!==e(n);n--);}function ye(t,e,n){const r=t.split(""),o=me((e=>{const i=r.shift();let s=!!r.length;if(n){const r=n(i,e,t);s=s&&!1!==r}s||o()}),e);return o}function be(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}function Ee(t,e,n){return new Function(be(n.length))(t,e,n)}function xe(t){const e=[];for(let n=0;n<t;n++)e[n]="0123456789abcdef".substr(16*Math.random(),1);return e.join("")}function Te(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=z(n),i="\r\n"+" ".repeat(e*r)+(o?"]":"}");let s=0,c=o?"[\r\n":"{\r\n";for(const u in n){if(!k(n,u))continue;const i=n[u];s&&(c+=",\r\n");const l=" ".repeat(e*r+e),a=t(i,r+1);c+=o?`${l}${a}`:`${l}"${u}":${a}`,s++}return c+i;case"function":return`"${n.toString()}"`;default:return H(n)?'"'+n+'"':n}}(t)}function Se(t){const e={};return t.forEach(((t,n)=>{e[t]=n,e[n]=t})),Object.freeze(e),e}function Le(t){return g({},t,i(t))}function $e(t){return new Promise(((e,n)=>{let r=0;try{for(const o of t){if(!G(o)){e(o);break}o.then((t=>e(t)),(()=>{r++,r===t.length&&n("AggregateError: All promises were rejected")}))}!t.length&&n("AggregateError: All promises were rejected")}catch(o){n(o.toString())}}))}function Re(t){return t.reduce(((t,e)=>t.then((t=>e(t).then((e=>(t.push(e),t)))))),Promise.resolve([]))}async function Me(t,e){return t.reduce(((t,e)=>t.then((t=>e(t)))),Promise.resolve(e))}const _e=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}}();function Ie(t,e=0,n=!1){if(!W(e)||!Mt(e,[0,100]))throw new TypeError("numToFixed() fractionDigits argument must be between 0 and 100");if(0===e)return String(~~t);const r=10**(e+1);t=~~(t*r),n&&t&&(t+=5),t/=r;const o=String(t).split("."),i=Dt((o[1]||"").substr(0,e),e,"0");return o[0]+"."+i}function Ae(t,e,n){return"number"==typeof e&&e<0&&(e=t.length+e),k(t,e)?t[e]:n}function Ce(t,e){const n=new RegExp(e);if("undefined"!=typeof Map&&t instanceof Map){const e=[];for(const r of t.keys())n.test(r)&&e.push(r);return e}return L(t).filter((t=>n.test(t)))}function Oe(t,e="-",n="default"){const r=/([^=]+)=([\s\S]+)?/,o=new RegExp(`^${e}`),i=t.slice(),s=new Map;let c,u=n;function l(){let t=c.replace(o,"");if(r.test(t)){t=RegExp.$1;const e=RegExp.$2;e&&i.unshift(e)}u=t,s.has(u)||s.set(u,!0)}function a(){const t=s.get(u);switch(P(t)){case"undefined":case"boolean":s.set(u,c);break;case"array":t.push(c);break;default:s.set(u,[t,c])}}for(;c=i.shift();)o.test(c)?l():a();return s}function*ke(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}}function De(){let t=Promise.resolve();function e(e){const n=t;t=new Promise((t=>{n.then((n=>e(t,n)))}))}const n={wait:t=>(e(((e,n)=>setTimeout((()=>e(n)),t))),n),do:t=>(e(((e,n)=>{const r=t(e,n);r&&r.then&&r.then((t=>e(t)))})),n)};return n}function Pe(t,e,n){const r=t[e];return t[e]=t[n],t[n]=r,t}class Ne{}class je extends Ne{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||K(t)&&K(e)))}clear(){this.cache=[]}get size(){return this.cache.length}}class Fe extends Ne{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 ze=D(_e.Set)?Fe:je;function Ue(t){if("function"!==P(t))return t;let e=t.toString();return e=e.replace(/(function)? ?\w+ ?\(/,"function("),new Function("return "+e)()}const He=function(){const t={array:t=>new t.constructor,function:t=>t,date:t=>new t.constructor(t)};return{...t,object:t.array,regexp:t.date}}();function We(t){const e=new ze;return function t(n){const r=P(n);if(F(n)){if(e.has(n))return n;e.set(n)}const o=He[r],i=o?o(n):n;if(-1===["object","array","function"].indexOf(r))return i;const s=n;for(const e in s)k(s,e)&&(i[e]=t(s[e]));return i}(t)}function qe(t){if("object"!=typeof t||!t)return t;const e=new t.constructor;function n(t,e){for(const n in t)k(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 Ve(t,e=12){return+parseFloat(t.toPrecision(e))}function Be(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 Xe(t,e){const n=Be(t),r=Be(e);return Math.pow(10,Math.max(n,r))}function Ge(t,e,n){return e.reduce(((t,e)=>{const r=Xe(t,e);return n(t,e,r)}),t)}function Ke(t){const e=String(t),n=e.match(/\d(?:\.(\d*))?e([+-]\d+)/);return t>Number.MAX_SAFE_INTEGER||!n||n.length<3?e:t.toFixed(Math.max(0,(n[1]||"").length-Number(n[2])))}function Ye(t,...e){return Ge(t,e,((t,e,n)=>(t*n+e*n)/n))}function Je(t,...e){return Ge(t,e,((t,e,n)=>(t*n-e*n)/n))}function Ze(t,...e){return Ge(t,e,((t,e,n)=>n*t*(e*n)/(n*n)))}function Qe(t,...e){return Ge(t,e,((t,e,n)=>t*n/(e*n)))}function tn(t,e=-1/0,n=1/0){return Math.max(e,Math.min(t,n))}class en{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 en(t)}"+"(...t){return this.setValue(Ye(this._value,...t)),this}"-"(...t){return this.setValue(Je(this._value,...t)),this}"*"(...t){return this.setValue(Ze(this._value,...t)),this}"/"(...t){return this.setValue(Qe(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 Ve(this._value)}set value(t){this.setValue(t)}reset(){return this._value=this.initNumber,this}valueOf(){return this._value}}function nn(t,[e,n]){return e<=t&&t<=n||n<=t&&t<=e}function rn(t,e){const[n,r]=t;for(let o=1;o<e.length;o++){const[t,i]=e[o-1],[s,c]=e[o];if((r-i)/(n-t)===(c-i)/(s-t)&&nn(n,[t,s])&&nn(r,[i,c]))return!0}return!1}function on(t,e){const[n,r]=t,[o,i]=e,s=n-o,c=r-i;return Math.sqrt(s*s+c*c)}var sn;function cn(t,e,n=sn.top){const[r,o]=t,[i,s]=e,c=Math.atan2(i-r,s-o)*(180/Math.PI);return{[sn.top]:180-c,[sn.right]:c,[sn.bottom]:360-c,[sn.left]:c+180}[n]}function un(t,e,n){const r=Math.PI/180*n;return[en.init(e)["*"](Math.sin(r))["+"](t[0]).value,en.init(e)["*"](Math.cos(r)).by(t[1],"-").value]}function ln(t,e,n,r){const[o,i]=e,[s,c]=r,[u,l]=n;return[(1-t)*(1-t)*o+2*t*(1-t)*s+t*t*u,(1-t)*(1-t)*i+2*t*(1-t)*c+t*t*l]}function an(t,e,n){const r=n*Math.PI/180,o=t**2+e**2-2*t*e*Math.cos(r);return Math.sqrt(o)}function hn(t,e,n){const r=Math.PI/180,o=r*n;return t/Math.sin(r*e)*Math.sin(o)}function fn(t){return function(e,n,r){e.descriptor&&(r=e.descriptor),r.value=t(r)}}!function(t){t.top="top",t.left="left",t.right="right",t.bottom="bottom"}(sn||(sn={}));const dn=(...t)=>fn((e=>he(e.value,...t))),pn=(...t)=>fn((e=>de(e.value,...t))),gn=(t,e=!0)=>fn((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 l=0;function a(){i=setTimeout(f,t)}function h(){c(),n()}const f=()=>{const t=o.call(this,l++,n,u);s===r.running&&(t instanceof Promise?t.then((function(){a()})).catch(h):!1===t?h():a())};s=r.running,e?f():a()}));return n.finally(c),n}return u.stop=c,u}));class mn{constructor(){this.events={}}static get Ins(){return mn.instance||(mn.instance=new mn),mn.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=mt(n,(t=>t===e));r>-1&&n.splice(r,1)}offAll(){this.events={}}}var wn;!function(t){t[t.default=0]="default",t[t.pause=1]="pause",t[t.stop=2]="stop"}(wn||(wn={}));class vn{constructor(t,e){this.status=wn.default,this.joinWord="",this.sayWord=t,this.wordArr=t.split(""),this.config=e}run(){this.timer=window.setTimeout((()=>{if(this.status!==wn.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=wn.pause),n=!!e&&!1!==r}else console.log(t);if(!e)return this.status=wn.stop,void(this.config.loop&&this.replay());n&&this.run()}),this.config.delay)}play(){this.status!==wn.stop&&(this.status=wn.default,this.run())}replay(){clearTimeout(this.timer),this.status=wn.default,this.wordArr=this.sayWord.split(""),this.joinWord="",this.run()}pause(){this.status!==wn.stop&&(this.status=wn.pause,clearTimeout(this.timer))}stop(){this.status===wn.default&&(this.status=wn.stop,clearTimeout(this.timer))}}class yn{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=En(t),this.host=Tn(t),this.port=Sn(t),this.path=Ln(t),this.hash=$n(t),this.query=Mn(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=In(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 bn=/^(\w+):\/\//;function En(t=location.href){let e="";return new RegExp(bn).test(t)&&(e=RegExp.$1),e}const xn=/(?:\w+:\/\/|\/\/)((?:[\w\-\u4e00-\u9fa5]+\.?)+\w+)/;function Tn(t=location.href){const e=new RegExp(xn).exec(t);return e?e[1]:""}function Sn(t=location.href){return t=t.split("?")[0],/:(\d+)/.test(t)?RegExp.$1:""}function Ln(t=location.href){return(t=t.split(/[?#]/)[0]).replace(new RegExp(`(${xn.source}(?::\\d+)?)|${bn.source}`),"")}function $n(t=location.href){const e=t.indexOf("#");return e<0?"":t.substring(e)}function Rn(t,e=location.href,n=!1){return An(t,$n(e),n)}function Mn(t=location.href){const e=t.match(/[^&#?/]+=[^&#?/]+/g);return e?C(e):{}}const _n=Mn;function In(t){return s(t,((t,e,n)=>(void 0===e||("object"==typeof e?r(e,((e,r)=>{void 0!==e&&t.push(`${n}[${r}]=${encodeURIComponent(e)}`)})):t.push(`${n}=${encodeURIComponent(e)}`)),t)),[]).join("&")}function An(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)}function Cn(t,e=location.href,n=!0){return o(t,((t,r)=>{if(new RegExp("(?:\\?|#|&)"+r+"=([^&#]*)(?:$|&|#)","i").test(e)){const o=n?encodeURIComponent(t):t;e=e.replace(`${r}=${RegExp.$1}`,`${r}=${o}`)}})),e}function On(t,e=location.href){const n=new yn(e);return g(n.query,t),n.toString()}const kn=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 Dn(t){return kn.test(t)}class Pn{constructor(t){this.itemClass=t,this.events=new mn,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)}}function Nn(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 st({len:n,fill:()=>Nn(t,e)})}function jn(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 st({len:n,fill:()=>jn(t,e)})}function Fn(t){return t[jn(t.length)]}function*zn(t){const e=t.slice();for(;e.length;){const t=jn(e.length);yield e.splice(t,1)[0]}}function Un(t){if(!U(t))throw new TypeError;const e=qe(t);let n=e.length;for(;n;){const t=jn(n--);[e[n],e[t]]=[e[t],e[n]]}return e}function Hn(){const t=jn(0,255,3);return`rgb(${t[0]},${t[1]},${t[2]})`}function Wn(){const t=jn(0,255,3),e=+Nn().toFixed(2);return`rgba(${t[0]},${t[1]},${t[2]},${e})`}function qn(){return"#"+kt(jn(16777215).toString(16),6,"0")}function Vn(t,e){if(W(t)&&(e=t,t="HEX"),void 0===t&&(t="HEX"),t=t.toUpperCase(),void 0===e){const e={HEX:qn,RGB:Hn,RGBA:Wn};return(e[t]||e.HEX)()}return st({len:e,fill:()=>Vn(t)})}function Bn(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 Xn(t){return/^#([\da-fA-F]{3}){1,2}$/.test(t)}function Gn(t){if(!Bn(t))throw new TypeError;const e=t.split(",");return"#"+((1<<24)+(parseInt(e[0].split("(")[1])<<16)+(parseInt(e[1])<<8)+parseInt(e[2].split(")")[0])).toString(16).slice(1)}function Kn(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)})`}function Yn(t){return Math.max(0,Math.min(t,255))}class Jn{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=Yn(t)}get g(){return this._g}set g(t){this._g=Yn(t)}get b(){return this._b}set b(t){this._b=Yn(t)}toHEX(){const{r:t,g:e,b:n}=this;return"#"+((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1)}}Jn.validate=Bn;class Zn extends Jn{constructor(t,e,n){super(t,e,n)}static random(){const t=jn(0,255,3);return new Zn(t[0],t[1],t[2])}static fromStr(t){if(!Zn.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 Zn(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(!z(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 Zn(r,o,i)}toRGBA(){const{r:t,g:e,b:n}=this;return new Qn(t,e,n)}toString(){const{r:t,g:e,b:n}=this;return`rgb(${t},${e},${n})`}}class Qn extends Jn{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=jn(0,255,3);return new Qn(t[0],t[1],t[2],jn())}static fromStr(t){if(!Qn.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 Qn(n,r,o,i)}toRGB(){const{r:t,g:e,b:n}=this;return new Zn(t,e,n)}toString(){const{r:t,g:e,b:n,a:r}=this;return`rgba(${t},${e},${n},${r})`}}var tr;!function(t){t.ready="ready",t.running="running",t.done="done"}(tr||(tr={}));class er{constructor(t,e,n){this.initValue=e,this.onDone=n,this._status=tr.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=tr.done,e&&e(t,n)},this.chain=t.map((t=>q(t)?{handler:t}:t))}get value(){return this._value}get status(){return this._status}start(t){return this._status===tr.running||(this.initValue=null!=t?t:this.initValue,this._value=null!=t?t:this.initValue,this.index=0,this._status=tr.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 nr(t){return t&&"object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName}function rr(t){return t instanceof HTMLElement}er.State=tr;const or=B(_e.HTMLElement)?nr:rr;function ir(t,e){return or(e)&&e.nodeName===t.toUpperCase()}function sr(t){return ir("SELECT",t)}function cr(t){return ir("INPUT",t)}function ur(t){return ir("TEXTAREA",t)}function lr(t){return ir("IMG",t)}function ar(t){return ir("DIV",t)}function hr(t){return ir("SPAN",t)}function fr(t){return ir("UL",t)}function dr(){return"ontouchstart"in window}function pr(t){return"nodelist"===P(t)}function gr({el:t,onDown:e,onMove:n,onUp:r,capture:o={down:!1,up:!0,move:!1}}){let i=t;if(!or(t))if(H(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 l(t){const{screenX:e,screenY:n}=t,r={x:e,y:n};return r.x=~~r.x,r.y=~~r.y,r}function a(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?l:a,u=s(t),c=u,e&&q(e)&&(r=e.call(this,t,u)),r}function f(t){const e=s(t);let r;return n&&q(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&&q(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 mr(t,{el:e=window,capture:n={down:!1,up:!0,move:!1}}={}){const r={el:e,capture:n};return t({onDown:t=>{r.onDown=t},onMove:t=>{r.onMove=t},onUp:t=>{r.onUp=t}}),gr(r)}function wr(t,e,n={down:!1,up:!0,move:!1}){let r=t;if(!or(t))if(H(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 on([e.pageX,e.pageY],[n.pageX,n.pageY])}function s(t){t.touches.length<2||e(+i(t.touches).toFixed(2),o)}function c(){l()}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 l(){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),l()}}function vr(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 l=u.cloneNode(!1);u.style.width=o+"px",u.style.height=i+"px",l.style.width="250%",l.style.height="250%",s.appendChild(u),c.appendChild(l),t.appendChild(s),t.appendChild(c),s.offsetParent!==t&&(t.style.position="relative"),s.scrollTop=c.scrollTop=i,s.scrollLeft=c.scrollLeft=o;let a=0,h=0;function f(){a===n&&h===r||(n=a,r=h,console.log("onResize"),e())}function d(){console.log("onScroll"),a=t.offsetWidth||1,h=t.offsetHeight||1,a===n&&h===r||requestAnimationFrame(f),s.scrollTop=c.scrollTop=i,s.scrollLeft=c.scrollLeft=o}s.addEventListener("scroll",d),c.addEventListener("scroll",d)}function yr(t,e,n,r){let o;function i(t){t=t||window.event;pt(or(n)?[n]:document.querySelectorAll(n),t.target)&&r(t)}return o=t?or(t)?t:document.querySelector(t):document.documentElement,null===o?null:(o.addEventListener(e,i),function(){o.removeEventListener(e,i)})}function br(t,e,n,r=!1){let o;if(H(t)){if(o=document.querySelector(t),!o)throw new Error("element not found!")}else o=or(t)?t:window;o.addEventListener(e,(function t(i){if(o.removeEventListener(e,t,r),n&&q(n))return n.call(this,i)}),r)}function Er(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}function xr(t,e=window){const n=Er(e),r=Er(t),o=t.offsetTop-e.scrollTop;return o>=-r.h&&o<=n.h}function Tr(t,e="vertical",n=10){let r,o,i=t;if(t===window){const t=document.documentElement;i=document.body.scrollTop?document.body:t,r=t.clientWidth,o=t.clientHeight}else r=i.clientWidth,o=i.clientHeight;const{scrollTop:s,scrollLeft:c,scrollHeight:u,scrollWidth:l}=i;return"vertical"===e?s>=u-o-n:c>=l-r-n}function Sr(t,e="vertical",n=10){return"vertical"===e?t.scrollTop>=n:t.scrollLeft>=n}var Lr,$r;const Rr=null!==($r=null===(Lr=null==_e?void 0:_e.document)||void 0===Lr?void 0:Lr.createElement("div").style)&&void 0!==$r?$r:{},Mr=(()=>{const t={webkit:"webkitTransform",Moz:"MozTransform",O:"OTransform",ms:"msTransform",standard:"transform"};for(const e in t){if(void 0!==Rr[t[e]])return e}return!1})();function _r(){var t;return!!(null===(t=null==_e?void 0:_e.document)||void 0===t?void 0:t.documentElement.classList)}function Ir(t){if(!t)return[];let e=t;return H(t)&&(e=[t.trim()]),e.reduce(((t,e)=>{const n=e.trim().split(/ +/);return t.push(...n),t}),[])}function Ar(t,e){const n=Ir(e),r=t.className.split(/ +/);return n.every((t=>pt(r,t)))}function Cr(t,e){const n=Ir(e),r=t.classList;return n.every((t=>pt(r,t)))}const Or=_r()?Cr:Ar;function kr(t,e){const n=Ir(e),r=t.classList;return n.forEach((t=>r.add(t))),t.className}function Dr(t,e){let n=Ir(e);const r=t.className+" "+n.join(" ");return n=r.split(" "),n=Lt(n),n=n.filter((t=>Boolean(t))),t.className=n.join(" "),t.className}const Pr=_r()?kr:Dr;function Nr(t,e){const n=Ir(e),r=Lt(t.className.split(/ +/).filter((t=>!pt(n,t))));return t.className=r.join(" ")}function jr(t,e){return Ir(e).forEach((e=>{t.classList.remove(e)})),t.className}const Fr=_r()?jr:Nr;function zr(t,e){return Or(t,e)?Fr(t,e):Pr(t,e)}function Ur(t){return!1===Mr?null:"standard"===Mr?t:Mr+t.charAt(0).toUpperCase()+t.substr(1)}function Hr(t,e){return t in Rr&&(Rr[t]=e,Rr[t]===e)}function Wr(t,{toCssText:e=!0,el:n}={}){H(n)&&(n=document.querySelector(n));const r=n||this;if(!or(r))throw new TypeError("setStyle param el | this is not HTMLElement");if(e=!z(t)&&e){const e=r.style.cssText.replace(/; ?$/,"").split(";").reduce(((t,e)=>{const[n,r]=e.split(/: ?/);return t[n]=r,t}),{});g(e,t),r.style.cssText=c(e,((t,e,n)=>t+`${Xt(n,"-")}: ${e};`),"")}else{$t(t).forEach((t=>g(r.style,t)))}return Wr.bind(r)}function qr(t,e={}){return new Promise((function(n,r){const o=t=>{r(t)},i=Xr("img",{props:g({crossOrigin:"anonymous",onload(){n(i)},onabort:o,onerror:o},e)});i.src=t}))}function Vr(t,e){let n,r,o,i="";"string"==typeof t?i=t:({url:i,onLoad:n,onError:r,props:e,attrs:o}=t);const s=(t,n)=>{const r=Gr("script",{props:{onload:()=>t&&t(r),onabort:n,onerror:n,src:i,...e},attrs:o,parent:document.body})};if(!n&&!r)return new Promise((function(t,e){s(t,e)}));s(n,r)}function Br(t=window){let e=t;if(H(t)){if(e=document.querySelector(t),!e)throw new Error("el not found")}else t===window&&(e=document.body.scrollTop?document.body:document.documentElement);const n=u(getComputedStyle(e),["marginTop","overflow"]),r=e.scrollTop;return e.scrollTop=0,e.style.overflow="hidden",e.style.marginTop=-r+parseInt(n.marginTop)+"px",function(){g(e.style,n),e.scrollTop=r}}function Xr(t,e={}){const n=document.createElement(t),{attrs:o={},props:i={},parent:s,children:c}=e;if(r(i,((t,e)=>{"style"===e&&"object"==typeof t?g(n.style,t):n[e]=t})),r(o,((t,e)=>{n.setAttribute(e,"object"==typeof t?JSON.stringify(t):t)})),(z(c)||pr(c))&&c.forEach((t=>n.appendChild(t))),s)if(or(s))s.appendChild(n);else if(H(s)){const t=document.querySelector(s);if(!t)throw new TypeError(`createHtmlElement param 'parent' => "${s}" not founded`);t.appendChild(n)}return n}const Gr=Xr;function Kr(t,e="div"){return Xr(e,{props:{...t,style:{position:"fixed",left:"-10000px",visibility:"hidden",...null==t?void 0:t.style}},parent:document.body})}function Yr(t=!1){const e=Gr("div",{props:{style:{fontSize:"10px"}},parent:document.body}),n=getComputedStyle(e).fontSize;return document.body.removeChild(e),t?10/parseInt(n):parseInt(n)/10}function Jr(){return Boolean(_e.self.frameElement&&"IFRAME"===_e.self.frameElement.tagName||_e.frames.length!==parent.frames.length||_e.self!==_e.top)}function Zr(t,e,n=0,r=window){const o=r===window?()=>document.documentElement.scrollTop||document.body.scrollTop:()=>r.scrollTop,i=t.getBoundingClientRect().top+o()-n;let s;return e(o()>=i),r.addEventListener("scroll",s=function(){e(o()>=i)}),function(){r.removeEventListener("scroll",s)}}const Qr=t=>t.toFixed(6).replace(/\.?0+$/,"");function to(){const t=getComputedStyle(document.documentElement);return parseInt(t.fontSize)}function eo(t){return to()*parseFloat(t)+"px"}function no(t){const e=to(),n=Qe(parseFloat(t),e);return Qr(n)+"rem"}function ro(t,e){return Qe(Ze(parseFloat(e),parseFloat(t)),100)+"px"}function oo(t,e){const n=100*parseFloat(t)/parseFloat(e);return Qr(n)+"%"}function io(t,e){return oo(eo(t),e)}function so(t,e){return no(ro(t,e))}function co(t,e,n={}){const r="transition",o=Ur(r),i="hide"===t.getAttribute("toggle-status"),s=`${e} ${n.duration||".3s"} ${n.timingFunction||""} ${n.delay||""}`.trim();if(i){t.removeAttribute("toggle-status");const n=Wr({[r]:"none",[e]:"0"},{el:t})({[o]:s,[r]:s});setTimeout((function(){n({[e]:("height"===e?t.scrollHeight:t.scrollWidth)+"px"})})),br(t,"transitionend",(function(){n({[e]:""})}))}else{t.setAttribute("toggle-status","hide");const n=Wr([{[r]:"none"},{[e]:("height"===e?t.scrollHeight:t.scrollWidth)+"px"}],{el:t});n({[o]:s,[r]:s}),setTimeout((function(){n({[e]:"0"})}))}}function uo({from:t,to:e,callback:n,speed:r=.5,immediate:o=!0,minStepDenominator:i=50}){const s=r;let c,u,l,a,h=1;function f(){c=!1,u=t,h=e>t?1:-1,r=s,a=Math.max(Math.abs(e),Math.abs(t))/i,l=t>e?()=>u<=e:()=>u>=e,o&&n(u)}function d(){if(!c)if(l())p(),u=e,n(u);else{const t=Math.max(Math.abs(u-e),1),o=Math.min(t/10*r,a)*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}}let lo=null;function ao(t=0,e=10,n=window,r="vertical"){lo&&lo(),e=tn(e,1,100);const o="horizontal"===r?{scrollTo:"scrollLeft",scrollSize:"scrollWidth",inner:"innerWidth",offset:"offsetWidth"}:{scrollTo:"scrollTop",scrollSize:"scrollHeight",inner:"innerHeight",offset:"offsetHeight"},i=o.scrollTo;let s=0;const c=n===window?document.body[i]?document.body:document.documentElement:n,u=()=>s=c[i];u();let l,a=1/0;if(s>t)l=()=>u()<=t;else{if(!(s<t))return;t=Math.min(t,c[o.scrollSize]-(n===window?window[o.inner]:c[o.offset])),e*=-1,l=()=>u()>=t}let h=!1;lo=()=>{h=!0,lo=null};const f=["wheel","touchstart","mousedown"],d=()=>{h=!0,f.forEach((t=>window.removeEventListener(t,d))),lo=null};f.forEach((t=>window.addEventListener(t,d))),function n(){if(!h)if(l()||a===s)c[i]=t,d();else{const r=Math.abs(t-s),o=Number((e+r/50*e/10).toFixed(1));c[i]=s-o,a=s,window.requestAnimationFrame(n)}}()}function ho(){if(document.currentScript)return document.currentScript;const t=document.scripts;return t.length?t[t.length-1]:null}function fo(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)}function po(t,e=1){const n=t=>{var n;const r=document.createElement("canvas");return r.width=t.width,r.height=t.height,null===(n=r.getContext("2d"))||void 0===n||n.drawImage(t,0,0),r.toDataURL("image/webp",e)};return"string"==typeof t?qr(t).then(n):new Promise(((e,r)=>{const o=new FileReader;o.onabort=o.onerror=r,o.onload=t=>{var r;return qr(null===(r=t.target)||void 0===r?void 0:r.result).then(n).then(e)},o.readAsDataURL(t)}))}class go{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 go.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 mo=0;class wo{constructor(t){this.parent=t,this.style={};const e=t instanceof bo?t:t.computedStyle;this.auto={width:e.width,height:e.height}}setStyle(t){g(this.style,t),this.computeStyle()}get root(){const t=this.parent;return t instanceof bo?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 l,a,h=0,f=0;const d=this.parent,{width:p,height:g}=d instanceof bo?d:d.computedStyle;if(l=o||p,a=i||g,void 0!==t&&void 0!==n?(h=t,void 0===o&&(l=p-n-t)):void 0!==t?h=t:void 0!==n&&(h=p-n-l),void 0!==e&&void 0!==r?(f=e,void 0===i&&(a=g-e-r)):void 0!==e?f=e:void 0!==r&&(f=g-r-a),"auto"===o&&(l=this.auto.width),"auto"===i&&(a=this.auto.height),(void 0===t||void 0===n)&&s)switch(s){case"left":h=0;break;case"middle":h=~~((p-l)/2);break;case"right":h=p-l}if((void 0===e||void 0===r)&&c)switch(c){case"top":f=0;break;case"middle":f=~~((g-a)/2);break;case"bottom":f=g-a}if(!(d instanceof bo)){const t=d.computedStyle;h+=t.left,f+=t.top}this.computedStyle={width:l,height:a,zIndex:u||0,left:h,top:f}}}class vo extends wo{constructor(t,e,n){super(t),this.content=n,this.id=mo++;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 yo extends wo{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?xt(t,((e,n)=>e.style.zIndex<=t.style.zIndex||0===n),n,{after:!0,reverse:!0}):this.children.push(t)}async addImg(t,e={}){let n;n=lr(t)?t:G(t)?await t:await qr(t);const r=new vo(this,e,n),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 W(t)?this.children.splice(t,1)[0]:Tt(t,this.children)}clear(){this.children=[]}}class bo{constructor(t=0,e=0){this.width=t,this.height=e,this.layers=[];const n=document.body,r=Gr("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 yo(this,g({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?xt(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 async createWithBg(t){const e=qr(t),n=await e,r=new bo(n.width,n.height);return await 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)}))}async drawRoundRect(t){const e=await qr(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.b