rx-util

rxliuli 在浏览器上使用的 js 工具集

Tính đến 18-06-2019. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/382120/710203/rx-util.js

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).rx={})}(this,function(t){"use strict";function e(t,e="unknown"){const n=document.createElement("a");n.download=e,n.style.display="none",n.href=URL.createObjectURL(t),document.body.appendChild(n),n.click(),document.body.removeChild(n)}function n(t,e,n,r){return new(n||(n=Promise))(function(o,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):new n(function(e){e(t.value)}).then(s,c)}a((r=r.apply(t,e||[])).next())})}const r=(new Map).set("http",80).set("https",443).set("ssh",22).set("ftp",21);var o;function i(t,{type:e=i.DataURL,encoding:n="UTF-8"}={}){return new Promise((r,i)=>{t||i(new Error("file not exists"));const s=new FileReader;s.onload=(()=>{r(s.result)}),s.onerror=(t=>{i(t)}),(new Map).set(o.DataURL,()=>s.readAsDataURL(t)).set(o.Text,()=>s.readAsText(t,n)).set(o.BinaryString,()=>s.readAsBinaryString(t)).set(o.ArrayBuffer,()=>s.readAsArrayBuffer(t)).get(e)()})}function s(t,e){const n={"y+":t.getFullYear(),"M+":t.getMonth()+1,"d+":t.getDate(),"h+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),"S+":t.getMilliseconds()};for(const t in n)if(new RegExp("("+t+")").test(e))if("y+"===t)e=e.replace(RegExp.$1,(""+n[t]).substr(4-RegExp.$1.length));else if("S+"===t){let r=RegExp.$1.length;r=1===r?3:r,e=e.replace(RegExp.$1,("00"+n[t]).substr((""+n[t]).length-1,r))}else{const r=Reflect.get(n,t);e=e.replace(RegExp.$1,1===RegExp.$1.length?r:("00"+r).substr((""+r).length))}return e}!function(t){t.DataURL="readAsDataURL",t.Text="readAsText",t.BinaryString="readAsBinaryString",t.ArrayBuffer="readAsArrayBuffer"}(o||(o={})),i.DataURL=o.DataURL,i.Text=o.Text,i.BinaryString=o.BinaryString,i.ArrayBuffer=o.ArrayBuffer;const c="yyyy-MM-ddThh:mm:ss.SSS",a=(t,e)=>encodeURIComponent(t)+"="+encodeURIComponent(e);function u(t){return new Promise(e=>{if("number"==typeof t)setTimeout(e,t);else if("function"==typeof t){const n=setInterval(()=>{t()&&(clearInterval(n),e())},100)}else e()})}function l(t,e){return Promise.race([t,u(e).then(()=>{throw new Error("timeout")})])}function f(t,e,n=((t,e)=>(t.push(e),t)),r=(()=>[])){return t.reduce((t,o,i,s)=>{const c=e(o,i,s);return t.has(c)||t.set(c,r()),t.set(c,n(t.get(c),o,i,s)),t},new Map)}function d(t,e,n=1){const r=[];for(let o=t;o<e;o+=n)r.push(o);return r}function h(t){return t}function p(t,e,n=h){const r=e instanceof Function?e:t=>Reflect.get(t,e),o=n instanceof Function?n:t=>Reflect.get(t,n);return t.reduce((t,e,n,i)=>t.set(r(e,n,i),o(e,n,i)),new Map)}function y(t,e){return e<=0?"":t+y(t,e-1)}class g{constructor(t,e,n,r){this.name=t,this.format=e,this.value=n,this.index=r}}const m=(new Map).set("year","y{4}|y{2}").set("month","M{1,2}").set("day","d{1,2}").set("hour","h{1,2}").set("minute","m{1,2}").set("second","s{1,2}").set("millieSecond","S{1,3}"),w=(new Map).set("month","01").set("day","01").set("hour","00").set("minute","00").set("second","00").set("millieSecond","000");function v(t,e){const n=new Date;w.set("year",n.getFullYear().toString());const r=[];for(const[t,n]of m){const o=new RegExp(n);if(o.test(e)){const n=o.exec(e)[0],i=y("`",n.length),s=e.indexOf(n);e=e.replace(n,i),r.push(new g(t,y("\\d",n.length),null,s))}else r.push(new g(t,null,w.get(t),-1))}if(e=e.replace(new RegExp("`","g"),"\\d"),!new RegExp(`^${e}$`).test(t))return null;r.filter(({format:t})=>t).sort(function(t,e){return t.index-e.index}).map(e=>{const n=new RegExp(e.format).exec(t);return null!==n&&n.length>0&&(t=t.replace(n[0],""),e.value=n[0]),e}).forEach(({format:e},n)=>{const o=new RegExp(e).exec(t);null!==o&&o.length>0&&(t=t.replace(o[0],""),r[n].value=o[0])});const o=p(r,t=>t.name,t=>t.value);2===o.get("year").length&&o.set("year",w.get("year").substr(0,2).concat(o.get("year")));const i=`${o.get("year")}-${o.get("month")}-${o.get("day")}T${o.get("hour")}:${o.get("minute")}:${o.get("second")}.${o.get("millieSecond")}`;return new Date(i)}function S(t){return t.selectionStart}function b(t,e,n=e){t.focus(),t.setSelectionRange(e,n)}function R(t){return null==t}function x(t){return R(t)||"string"!=typeof t?t:t.toLowerCase()}let E;document.addEventListener("focus",t=>{E=t.target},!0),document.addEventListener("blur",()=>{E=null},!0);class M{constructor(t,e,n,r){this.el=t,this.type=e,this.listener=n,this.options=r}}function O(t){return R(t)?"":t instanceof Date?t.toISOString():t.toString()}function P(t,e=null,...n){try{return t(...n)}catch(t){return e}}class _{constructor(){this.classMap=new Map}static getFactory(){return new _}register(t,e){return this.classMap.set(t,e),e}getInstance(t,...e){const n=this.classMap.get(t);return n?new n(...e):null}*[Symbol.iterator](){for(const t of this.classMap.entries())yield t}}function T(t,e){return t instanceof Promise?t.then(e):e(t)}function I(t){const e=performance.now();return T(t(),()=>performance.now()-e)}function A(t,e,n){return t>=e&&t<n}const D=/^(-?\d+)(.\d+)?$/,C=/^-?\d+$/,L=/^\w+((-\w+)|(\.\w+))*@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/,$=/^((25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(25[0-5]|2[0-4]\d|1?\d?\d)$/,j=/^0[1-9][0-9]{1,2}-[2-8][0-9]{6,7}$/,k=/^(((13[0-9]{1})|15[0-9]{1}|18[0-9]{1}|)+\d{8})$/,F=/^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/,U=/^\d{6}$/;class B{static isEmpty(t){return R(t)||""===t}static isBlank(t){return B.isEmpty(t)||""===t.trim()}static isFloat(t){return!R(t)&&D.test(t)}static isInteger(t){return!R(t)&&C.test(t)}static isEmail(t){return!R(t)&&L.test(t)}static isIpv4(t){return!R(t)&&$.test(t)}static isPort(t){return B.isInteger(t)&&A(parseInt(t),1,65535)}static isTelephone(t){return!R(t)&&j.test(t)}static isMobile(t){return!R(t)&&k.test(t)}static isDomain(t){return!R(t)&&F.test(t)}static isPostcode(t){return!R(t)&&U.test(t)}}const N=B;function z(t){return R(t)||"string"!=typeof t?t:t.toUpperCase()}function Y(t){return N.isBlank(t)?null:t}function K(t,...e){const n=new Set(e);return Reflect.ownKeys(t).reduce((e,r)=>(n.has(r)||Reflect.set(e,r,Reflect.get(t,r)),e),{})}class J{static dayStart(t=new Date){return new Date(`${s(t,"yyyy-MM-dd")}T00:00:00.000`)}static dayEnd(t=new Date){return new Date(`${s(t,"yyyy-MM-dd")}T23:59:59.999`)}static yearStart(t=new Date){return new Date(`${t.getFullYear()}-01-01T00:00:00.000`)}static yearEnd(t=new Date){return new Date(`${t.getFullYear()}-12-31T23:59:59.999`)}}const Z=J,q=864e5;class W{constructor(t){this.date=t}year(){return this.date.getFullYear()}month(){return this.date.getMonth()}monthOfYear(){return this.date.getMonth()+1}dayOfYear(){return Math.ceil((this.date.getTime()-Z.yearStart(this.date).getTime())/q)}dayOfMonth(){return this.date.getDate()}dayOfWeek(){return this.date.getDay()}weekOfYear(){return Math.ceil(this.dayOfYear()/7)}weekOfMonth(){return Math.ceil(this.dayOfMonth()/7)}quarter(){const t=this.month();return A(t,0,3)?1:A(t,3,6)?2:A(t,6,9)?3:4}hour(){return this.date.getHours()}minute(){return this.date.getMinutes()}second(){return this.date.getSeconds()}milliSecond(){return this.date.getMilliseconds()}}function V(t){return new W(t)}class H{constructor(t,e){this.start=t,this.end=e}milliSecond(){return this.end.getTime()-this.start.getTime()}second(){return Math.floor(this.milliSecond()/1e3)}minute(){return Math.floor(this.second()/60)}hour(){return Math.floor(this.minute()/60)}day(){return Math.floor(this.hour()/24)}month(){return 12*this.year()+(this.end.getMonth()-this.start.getMonth())}year(){return this.end.getFullYear()-this.start.getFullYear()}}const G=function*(){for(let t=0;;t++)yield t}();class Q{from(t){throw new Error("子类必须重写 from 函数")}to(t){throw new Error("子类必须重写 to 函数")}}class X extends Q{from(t){const e=[],n=t.length;let r=0;for(let o=0;o<n;o++){const n=t.charAt(o);n>="A"&&n<="Z"&&(0!==o&&e.push(t.substring(r,o)),r=o)}return r!==t.length&&e.push(t.substring(r,t.length)),e}}class tt extends X{to(t){return t.reduce((t,e,n)=>{const r=x(e);return t+((0===n?x:z)(r.substring(0,1))+r.substring(1))},"")}}class et extends X{to(t){return t.reduce((t,e)=>{const n=x(e);return t+(z(n.substring(0,1))+n.substring(1))},"")}}class nt extends Q{from(t){return t.split("_")}}class rt extends nt{to(t){return t.map(x).join("_")}}class ot extends nt{to(t){return t.map(z).join("_")}}var it;(it=t.StringStyleType||(t.StringStyleType={}))[it.Camel=1]="Camel",it[it.Pascal=2]="Pascal",it[it.Snake=3]="Snake",it[it.ScreamingSnake=4]="ScreamingSnake";class st{static getInstance(e){switch(e){case t.StringStyleType.Camel:return new tt;case t.StringStyleType.Pascal:return new et;case t.StringStyleType.Snake:return new rt;case t.StringStyleType.ScreamingSnake:return new ot;default:throw new Error("No corresponding converter found")}}}class ct{constructor(t,e){this.fromConverter=st.getInstance(t),this.toConverter=st.getInstance(e)}convert(t){return N.isEmpty(t)?t:this.toConverter.to(this.fromConverter.from(t))}}function at(t,e=t.toString()){const n=new Map;return new Proxy(t,{apply(t,r,o){const i=(t=>`onceOfSameParam-${e}-${JSON.stringify(t)}`)(o),s=n.get(i);return void 0!==s?s:T(Reflect.apply(t,r,o),t=>(n.set(i,t),t))}})}const ut=at((t,e)=>new ct(t,e));class lt{static getConverter(t,e){return ut(t,e)}static convert(t,e,n){return lt.getConverter(t,e).convert(n)}}function ft(t){return R(t)?[]:Reflect.ownKeys(t)}function dt(t,...e){const n=e.filter(t=>t!==dt._);if(n.length>=t.length)return t(...n);function r(...n){const r=new Set;let o=0;const i=e.map(t=>t!==dt._||void 0===n[o]||n[o]===dt._?t:(r.add(o),n[o++])),s=n.filter((t,e)=>!r.has(e));return dt(t,...i,...s)}return r._length=t.length-e.filter(t=>t!==dt._).length,r.toString=(()=>`name: ${t.name}, args: [${e.map(t=>t.toString()).join(", ")}]`),r._curry=!0,r}dt._=Symbol("_");class ht{constructor(t){this.fmt=t}format(t){return R(t)?"":s(t,this.fmt)}parse(t){return N.isEmpty(t)?null:v(t,this.fmt)}strFormat(t,e){if(N.isEmpty(t))return"";return s(e?v(t,e):new Date(t),this.fmt)}}function pt(t,e,n=1){let r=0;for(let o=0,i=t.length;o<i;o++)if(e.call(t,t[o],o,t)&&++r>=n)return o;return-1}ht.dateFormatter=new ht("yyyy-MM-dd"),ht.timeFormatter=new ht("hh:mm:ss"),ht.dateTimeFormatter=new ht("yyyy-MM-dd hh:mm:ss");const yt=(t,e)=>(function(...n){const r=pt(n,t=>t!==dt._,t._length||t.length),o=dt(t,...n);return-1===r?yt(o,e):dt(e,o,...n.slice(r+1))});class gt{constructor(t={}){Object.assign(this,t)}}const mt="TimoutInfinite";function wt(t,...e){return[t,...e].reduce((t,e)=>R(e)?t:Reflect.ownKeys(e).reduce((t,n)=>{const r=Reflect.get(e,n);return R(r)?t:(Reflect.set(t,n,r),t)},t),{})}class vt{constructor({timeout:t=mt,serialize:e=JSON.stringify,deserialize:n=JSON.parse}={}){this.cacheOption={timeout:t,serialize:e,deserialize:n},this.localStorage=window.localStorage,this.clearExpired()}clearExpired(){return n(this,void 0,void 0,function*(){const t=this.localStorage,e=t.length,r=[];for(let n=0;n<e;n++){yield u(0);const e=t.key(n),o=t.getItem(e),i=P(JSON.parse,null,o);if(null===i)continue;const{timeStart:s,timeout:c}=i.cacheOption;c!==mt&&Date.now()-s>c&&r.push(e)}yield r.forEach(e=>n(this,void 0,void 0,function*(){return t.removeItem(e)}))})}add(t,e,n={}){null===this.get(t,n)&&this.set(t,e,n)}del(t){this.localStorage.removeItem(t)}set(t,e,n={}){const r=wt(this.cacheOption,n);this.localStorage.setItem(t,JSON.stringify(new gt({key:t,val:r.serialize(e),cacheOption:Object.assign({},r,{timeStart:r.timeStart||Date.now()})})))}get(t,e={}){const n=this.localStorage.getItem(t),r=P(JSON.parse,null,n);if(null===r)return null;const{timeStart:o,timeout:i,deserialize:s}=wt(this.cacheOption,r.cacheOption,e);if(i!==mt&&Date.now()-o>i)return this.del(t),null;try{return s(r.val)}catch(e){return this.del(t),null}}touch(t,e={}){const n=this.localStorage.getItem(t),r=P(JSON.parse,null,n);if(null===r)return null;const o=wt(this.cacheOption,r.cacheOption,e),{timeStart:i,timeout:s,deserialize:c}=o;if(s!==mt&&Date.now()-i>s)return this.del(t),null;try{const e=c(r.val);return this.set(t,e,wt(o,{timeStart:Date.now()})),e}catch(e){return this.del(t),null}}}const St=new vt;class bt{static once(t,{identity:e=t.toString(),timeout:n=mt}={}){const r=()=>`CacheUtil.onceOfSameParam-${e}`,o=new Proxy(t,{apply(t,e,o){const i=r(),s={timeout:n},c=St.get(i);return null!==c?c:T(Reflect.apply(t,e,o),t=>(St.set(i,t,s),t))}});return Object.assign(o,{origin:t,clear(){St.del(r())}})}static onceOfSameParam(t,{identity:e=t.toString(),timeout:n=mt}={}){const r=t=>`CacheUtil.onceOfSameParam-${e}-${JSON.stringify(t)}`,o=new Proxy(t,{apply(t,e,o){const i=r(o),s={timeout:n},c=St.get(i);return null!==c?c:T(Reflect.apply(t,e,o),t=>(St.set(i,t,s),t))}});return Object.assign(o,{origin:t,clear(...t){St.del(r(t))}})}}const Rt=bt;function xt(...t){}class Et{static cyclingDebugger(){const t=setInterval(()=>{},100);return()=>clearInterval(t)}static checkDebug(t=(()=>window.location.reload())){const e=setInterval(()=>{const e=I(()=>{for(let t=0;t<1e3;t++)console.log(t),console.clear()});e>500&&(console.log(e),t())},1e3);return()=>clearInterval(e)}static disableConsoleOutput(){if(!window.console)return xt;const t=p(Object.keys(console),h,t=>{const e=console[t];return console[t]=xt,e});return()=>{for(const[e,n]of t)console[e]=n}}}const Mt=Et;function Ot(t,e,n){return T((0,t[0])(...e),function(r){if(n(r))return r;const o=t.slice(1);return 0===o.length?r:Ot(o,e,n)})}class Pt{static and(...t){return function(...e){return Ot(t,e,t=>!t)}}static or(...t){return function(...e){return Ot(t,e,t=>t)}}static not(t){return new Proxy(t,{apply(t,e,n){return T(Reflect.apply(t,this,n),t=>!t)}})}}class _t{static isEmpty(t){return R(t)||!(t instanceof Array)||0===t.length}}const Tt=_t;class It{static join(...t){return t.reduce(It._join)}static _join(t,e){return t.endsWith(It.Separator)?(t+e).replace(It.Separator+It.Separator,It.Separator):e.startsWith(It.Separator)?t+e:t+It.Separator+e}}It.Separator="/";const At=It;const Dt=new class{constructor({enable:t=!0}={}){this.reset=h,this.enable=t}set enable(t){this._enable=t,Object.keys(console).forEach(e=>this[e]=t?console[e]:xt)}get enable(){return this._enable}log(t,...e){}};function Ct(t){return function(e){return new Proxy(e,{get:(e,n)=>Reflect.has(t,n)?Reflect.get(e,Reflect.get(t,n)):Reflect.get(e,n),set:(e,n,r)=>Reflect.has(t,n)?(Reflect.set(e,Reflect.get(t,n),r),!0):(Reflect.set(e,n,r),!0)})}}function Lt(t,{before:e=h,after:n=h,paramFn:r=((t,...e)=>[])}={}){return function t(o,...i){const s=e(o,...i),c=s.child;return Tt.isEmpty(c)||(s.child=c.map(e=>t(e,...r(s,...i)))),n(s,...i)}(t)}class $t{static bridge({id:t="id",parentId:e="parentId",child:n="child",path:r="path"}={}){return Ct({id:t,parentId:e,child:n,path:r})}static bridgeTree(t,e){return Lt(t,{before:this.bridge(e)})}static bridgeList(t,e){return t.map(this.bridge(e))}}const jt=$t;function kt(t,e){const n=function(t){return t instanceof Function?/^(?:constructor|prototype|arguments|caller|name|bind|call|apply|toString|length)$/:/^(?:toString|length)$/}(e);return Reflect.ownKeys(e).forEach(r=>{"string"==typeof r&&n.test(r)||Reflect.set(t,r,Reflect.get(e,r))}),t}const Ft=()=>!1;class Ut{constructor(...t){this._arr=t}get length(){return this._arr.length}value(){return this._arr.slice()}*[Symbol.iterator](){for(const t of this._arr)yield t}}class Bt extends Ut{constructor(...t){super(...t)}static from(t){return R(t)?new Bt:new Bt(...Array.from(t))}forEach(t){return n(this,void 0,void 0,function*(){for(let e=0;e<this.length;e++)yield t.call(this,this._arr[e],e,this)})}filter(t){return n(this,void 0,void 0,function*(){const e=new Bt;for(let n=this.length-1;n>=0;n--)(yield t.call(this,this._arr[n],n,this))&&e._arr.push(this._arr[n]);return e})}map(t){return n(this,void 0,void 0,function*(){const e=new Bt;for(let n=0;n<this.length;n++)e._arr.push(yield t.call(this,this._arr[n],n,this));return e})}flatMap(t){return n(this,void 0,void 0,function*(){const e=new Bt;for(let n=0;n<this.length;n++)e._arr.push(...yield t.call(this,this._arr[n],n,this));return e})}every(t){return n(this,void 0,void 0,function*(){for(let e=0;e<this.length;e++)if(!(yield t.call(this,this._arr[e],e,this)))return!1;return!0})}find(t){return n(this,void 0,void 0,function*(){for(let e=0;e<this.length;e++){if(yield t.call(this,this._arr[e],e,this))return this._arr[e]}return null})}findIndex(t){return n(this,void 0,void 0,function*(){for(let e=0;e<this.length;e++){if(yield t.call(this,this._arr[e],e,this))return e}return null})}reduce(t,e){return n(this,void 0,void 0,function*(){for(let n=0;n<this.length;n++)e=e?yield t.call(this,e,this._arr[n],n,this):this._arr[n];return e})}reduceRight(t,e){return n(this,void 0,void 0,function*(){for(let n=this.length-1;n>=0;n--)e=e?yield t.apply(this,[e,this._arr[n],n,this]):this._arr[n];return e})}parallel(){return new Nt(...this._arr)}}class Nt extends Ut{constructor(...t){super(...t)}static from(t){return R(t)?new Nt:new Nt(...Array.from(t))}forEach(t){return n(this,void 0,void 0,function*(){yield this._all(t)})}filter(t){return n(this,void 0,void 0,function*(){const e=yield this._all(t),n=new Nt;for(let t=0,r=e.length;t<r;t++)e[t]&&n._arr.push(this._arr[t]);return n})}map(t){return n(this,void 0,void 0,function*(){return new Nt(...yield this._all(t))})}flatMap(t){return n(this,void 0,void 0,function*(){const e=yield this._all(t);return new Nt(...e.flat())})}every(t){return n(this,void 0,void 0,function*(){return(yield this._all(t)).every(h)})}find(t){return n(this,void 0,void 0,function*(){const e=yield this._all(t);for(let t=0,n=e.length;t<n;t++)if(e[t])return this._arr[t];return null})}findIndex(t){return n(this,void 0,void 0,function*(){return(yield this._all(t)).findIndex(h)})}reduce(t,e){return n(this,void 0,void 0,function*(){for(let n=0;n<this.length;n++)e=e?yield t.call(this,e,this._arr[n],n,this):this._arr[n];return e})}reduceRight(t,e){return n(this,void 0,void 0,function*(){for(let n=this.length-1;n>=0;n--)e=e?yield t.apply(this,[e,this._arr[n],n,this]):this._arr[n];return e})}serial(){return new Bt(...this._arr)}_all(t){return n(this,void 0,void 0,function*(){return yield Promise.all(this._arr.map((e,n)=>t.apply(this,[e,n,this])))})}}t.AntiDebug=Et,t.ArrayValidator=_t,t.AsyncArray=Bt,t.CacheUtil=bt,t.CombinedPredicate=Pt,t.DateConstants=J,t.DateFormatter=ht,t.FetchLimiting=class{constructor({timeout:t=1e4,limit:e=10}={}){this.timeout=t,this.limit=e,this.execCount=0,this.waitArr=[]}fetch(t,e){return n(this,void 0,void 0,function*(){return this.waitArr.push([t,e]),yield u(()=>this.execCount<this.limit),(()=>n(this,void 0,void 0,function*(){this.execCount++;const t=this.waitArr.shift();try{return yield l(fetch(t[0],t[1]),this.timeout)}finally{this.execCount--}}))()})}},t.LocalStorageCache=vt,t.Locker=class{constructor({limit:t=1,timeout:e}={}){this.limit=t,this.timeout=e||Ft}isLocked(){return this.limit<=0}lock(t=this.timeout){return n(this,void 0,void 0,function*(){this.isLocked()?yield Promise.race([u(()=>{const t=!this.isLocked();return t&&this.limit--,t}),u(t)]):this.limit--})}unlock(){this.limit++}},t.NodeBridgeUtil=$t,t.PathUtil=It,t.StateMachine=_,t.StringStyleUtil=lt,t.StringValidator=B,t.aggregation=function(t){const e=Array.from(t);class n{constructor(...t){e.forEach(([e,n=h])=>kt(this,new e(...n(t))))}}return e.forEach(([t])=>{kt(n.prototype,t.prototype),kt(n,t)}),n},t.antiDebug=Mt,t.appends=function(t,e){for(const n in e){const r=e[n];t.append(n,O(r))}return t},t.arrayDiffBy=function(t,e,n=h){const r=new Set(t.map(n)),o=new Set(e.map(n)),i=t.filter((t,...e)=>!o.has(n(t,...e))),s=e.filter((t,...e)=>!r.has(n(t,...e))),c=new Set(i.map(n));return{left:i,right:s,common:t.filter((t,...e)=>!c.has(n(t,...e)))}},t.arrayToMap=p,t.arrayValidator=Tt,t.asIterator=function(t){const e=[];for(;;){const n=t.next();if(n.done)break;e.push(n.value)}return e},t.assign=wt,t.async=function(t){return new Proxy(t,{apply(t,e,r){return n(this,void 0,void 0,function*(){return yield Reflect.apply(t,e,r)})}})},t.asyncFlatMap=function(t,e){return n(this,void 0,void 0,function*(){const n=[];for(let r=0;r<t.length;r++)n.push(...yield e(t[r],r,t));return n})},t.asyncLimiting=function(t,{limit:e=1}={}){let r=0;const o=[];let i=!1;return new Proxy(t,{apply(t,s,c){return n(this,void 0,void 0,function*(){return o.push(c),yield u(()=>{const t=r<e;return t&&(i=!0,r++),t}),(()=>n(this,void 0,void 0,function*(){i||(r++,i=!1);const e=o.shift();try{return yield Reflect.apply(t,s,e)}finally{r--}}))()})}})},t.autoIncrement=function(){return G.next().value},t.blankToNull=Y,t.blankToNullField=function(t){return Reflect.ownKeys(t).reduce((e,n)=>{const r=Reflect.get(t,n);return Reflect.set(e,n,"string"==typeof r?Y(r):r),e},{})},t.bridge=Ct,t.cacheUtil=Rt,t.compare=function t(e,n){if(("number"==typeof e||e instanceof Number)&&("number"==typeof n||n instanceof Number)){const t=+e,r=+n;if(isNaN(t)&&isNaN(r))return!0;if(t===r)return 1/t==1/r;if(Math.abs(t-r)<Number.EPSILON)return!0}if(e===n)return!0;if(e instanceof RegExp&&n instanceof RegExp||("string"==typeof e||e instanceof String)&&("string"==typeof n||n instanceof String))return e.toString()===n.toString();if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(!(e instanceof Object&&n instanceof Object))return!1;if(e.prototype!==n.prototype)return!1;if(e.constructor!==n.constructor)return!1;for(const t of Reflect.ownKeys(n))if(!Reflect.has(e,t))return!1;for(const r of Reflect.ownKeys(e)){if(!Reflect.has(n,r))return!1;if(typeof n[r]!=typeof e[r])return!1;if(!t(e[r],n[r]))return!1}return!0},t.compose=function(...t){return t.reduceRight((t,e)=>yt(e,t))},t.concatMap=function(t){let e=0;const r=new Set;return new Proxy(t,{apply(t,o,i){return n(this,void 0,void 0,function*(){const n=e;r.add(n),e++,yield u(()=>!r.has(n-1));const s=Reflect.apply(t,o,i);return r.delete(n),yield s})}})},t.copyText=function(t){const e=document.createElement("input");document.body.appendChild(e),e.setAttribute("value",t),e.select();const n=document.execCommand("copy");return document.body.removeChild(e),n},t.createElByString=function(t){const e=document.createElement("div");return e.innerHTML=t,e.querySelector("*")},t.curry=dt,t.dateBetween=function(t,e){return new H(t,e)},t.dateConstants=Z,t.dateEnhance=V,t.dateFormat=s,t.dateParse=v,t.debounce=function(t,e,n=null){let r,o=n;return new Proxy(e,{apply:(e,n,i)=>new Promise(s=>{r&&clearTimeout(r),r=setTimeout(()=>s(o=Reflect.apply(e,n,i)),t),setTimeout(()=>s(o),t)})})},t.deepFreeze=function t(e){return e instanceof Array?e.forEach(e=>{"object"==typeof e&&t(e)}):e instanceof Object&&function(t){return ft(t).map(e=>Reflect.get(t,e))}(e).forEach(e=>{"object"==typeof e&&t(e)}),Object.freeze(e)},t.deepProxy=function(t){const e={get(t,n){Reflect.set(t,n,Reflect.has(t,n)?Reflect.get(t,n):{});const r=Reflect.get(t,n);return"object"==typeof r?new Proxy(r,e):r}};return new Proxy(t,e)},t.deletes=function(t,e){return e.forEach(e=>t.delete(e)),t},t.deny=function(t){return Pt.not(t)},t.download=e,t.downloadString=function(t,r="unknown.txt"){return n(this,void 0,void 0,function*(){e(function(t){return new Blob([t],{type:"text/plain"})}(t),r)})},t.downloadUrl=function(t,r=t.substr(t.lastIndexOf("/"))){return n(this,void 0,void 0,function*(){try{const n=yield fetch(t);e(yield n.blob(),r)}catch(t){throw t}})},t.emptyAllField=function(t){return Reflect.ownKeys(t).reduce((t,e)=>(Reflect.set(t,e,null),t),{})},t.emptyFunc=xt,t.excludeFields=K,t.excludeFieldsDeep=function t(e,...n){return Reflect.ownKeys(e).reduce((r,o)=>{const i=Reflect.get(r,o);return i instanceof Object&&Reflect.set(e,o,t(i,...n)),r},e instanceof Array?e:K(e,...n))},t.fetchTimeout=l,t.fill=y,t.filterItems=function(t,e,n=h){const r=new Set(e.map(n));return t.filter((t,e,o)=>!r.has(n(t,e,o)))},t.findIndex=pt,t.flatMap=function(t,e=(t=>Array.from(t))){return t.reduce((t,n,r,o)=>(t.push(...e(n,r,o)),t),new Array)},t.floatEquals=function(t,e){return Math.abs(t-e)<Number.EPSILON},t.formDataToArray=function(t){return Array.from(t)},t.format=function(t,e){return Object.keys(e).reduce((t,n)=>t.replace(new RegExp(`{${n}}`,"g"),O(e[n])),t)},t.getCookies=function(){return document.cookie.split(";").reduce((t,e)=>{const[n,r]=e.split("=");return t.set(n,r),t},new Map)},t.getCusorPostion=S,t.getObjectEntries=function(t){return Reflect.ownKeys(t).map(e=>[e,Reflect.get(t,e)])},t.getObjectKeys=ft,t.getYearWeek=function(t){return V(t).weekOfYear()},t.groupBy=f,t.insertText=function(t,e,n=S(t)){const r=t.value;t.value=r.substr(0,n)+e+r.substr(n),b(t,n+e.length)},t.isBlank=function(t){return N.isBlank(t)},t.isEditable=function(t){return t&&(t.isContentEditable||["input","date","datetime","select","textarea"].includes(x(t.tagName)))},t.isEmpty=function(t){return N.isEmpty(t)},t.isFloat=function(t){return N.isFloat(t)},t.isNullOrUndefined=R,t.isNumber=function(t){return N.isInteger(t)},t.isRange=A,t.lastFocus=function(){return E},t.listToTree=function(t,{bridge:e=h,isRoot:n=(t=>!t.parentId)}={}){const r=t.reduce((r,o)=>{const i=e(o);if(n(i))return r.push(i),r;for(const n of t){const t=e(n);if(i.parentId===t.id)return t.child=t.child||[],t.child.push(i),r}return r},[]),o=r.length;return 0===o?{}:1===o?r[0]:r},t.loadResource=function(t,e,r={}){return n(this,void 0,void 0,function*(){const n=yield fetch(t,r),o=yield n.blob();e.src=window.URL.createObjectURL(o)})},t.loadScript=function(t){return new Promise((e,n)=>{const r=document.createElement("script");r.src=t,r.addEventListener("load",()=>e()),r.addEventListener("error",n),document.body.appendChild(r)})},t.logger=Dt,t.mapToObject=function(t){const e={};for(const[n,r]of t)Reflect.set(e,n,r);return e},t.mergeMap=function(t){let e=0;const r=new Set;return new Proxy(t,{apply(t,o,i){return n(this,void 0,void 0,function*(){const n=Reflect.apply(t,o,i),s=e;return r.add(s),e++,yield u(()=>!r.has(s-1)),r.delete(s),yield n})}})},t.nodeBridgeUtil=jt,t.objToFormData=function(t){return Object.entries(t).reduce((t,[e,n])=>(n instanceof Blob?t.append(e,n):t.append(e,n&&n.toString()),t),new FormData)},t.objectToMap=function(t){return Reflect.ownKeys(t).reduce((e,n)=>e.set(n,Reflect.get(t,n)),new Map)},t.once=function(t){let e,n=!0;return new Proxy(t,{apply:(t,r,o)=>!1===n?e:(n=!1,T(Reflect.apply(t,r,o),t=>e=t))})},t.onceOfSameParam=at,t.parseUrl=function(t){if(!t)throw new Error("Url cannot be empty");const e=new RegExp("^((\\w+)://([\\w\\.]*)(:(\\d+))?)(.*)").exec(t);if(null===e)return null;const n=e[1],o=e[2],i=e[3],s=e[5],c=e[6],a=t.substr(n.length),u=a.indexOf("?");if(-1===u){const e=a;return{url:t,website:n,protocol:o,domain:i,port:parseInt(s),href:c,accessPath:e,params:new Map}}let l=a.substr(0,u);return l.endsWith("/")&&(l=l.substring(0,l.length-1)),{url:t,website:n,protocol:o,domain:i,port:s||r.get(o)||0,href:c,accessPath:l,params:a.substr(u+1).split("&").map(t=>t.split("=")).filter(t=>""!==t[0]).reduce((t,e)=>{const n=decodeURIComponent(e[0]),r=decodeURIComponent(1===e.length?"":e[1]),o=t.get(n);return void 0===o?t.set(n,r):(Array.isArray(o)||t.set(n,[o]),void 0!==t.get(n).length&&t.get(n).push(r)),t},new Map)}},t.pathUtil=At,t.randomInt=function(t,e){const n=e?t:0,r=e||t;return n+Math.floor(Math.random()*(r-n))},t.range=d,t.readLocal=i,t.removeEl=function(t){const e=t.parentElement;return null==e?null:e.removeChild(t)},t.removeText=function(t,e=t.selectionStart,n=t.selectionEnd){const r=S(t),o=t.value;t.value=o.substr(0,e)+o.substr(n,o.length),b(t,r)},t.returnItself=h,t.returnReasonableItself=function(...t){const e=t.length;return 0===e?null:1===e?t[0]:t},t.safeExec=P,t.setCusorPostion=b,t.sets=function(t,e){for(const n in e)t.set(n,e[n]);return t},t.singleModel=function(t){let e;return new Proxy(t,{construct:(t,n,r)=>(void 0===e&&(e=Reflect.construct(t,n,r)),e)})},t.sleep=function(t){const e=performance.now()+t;for(;performance.now()<=e;);},t.sortBy=function t(e,n=h){if(e.length<=1)return e;const r=Math.floor(e.length/2),o=e.slice(),i=o.splice(r,1)[0],s=n(i,r,e),c=f(o,(t,...e)=>n(t,...e)<s);return[...t(c.get(!0)||[],n),i,...t(c.get(!1)||[],n)]},t.spliceParams=function(t={}){return Array.from(Object.entries(t)).reduce((t,[e,n])=>null==n?t:(n instanceof Date?t+=a(e,s(n,c)):n instanceof Array?t+=n.map(t=>a(e,t instanceof Date?s(t,c):t)).join("&"):t+=a(e,n),t+"&"),"")},t.strToArrayBuffer=function(t){const e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let e=0;e<t.length;++e)n[e]=255&t.charCodeAt(e);return e},t.strToDate=function(t,e){return v(t,e)},t.stringValidator=N,t.switchMap=function(t){let e,r=0,o=0;return new Proxy(t,{apply(t,i,s){return n(this,void 0,void 0,function*(){const n=r;r++;const c=yield Reflect.apply(t,i,s);return n<o?e:(e=c,o=n,c)})}})},t.throttle=function(t,e){let n,r=0;return new Proxy(e,{apply:(e,o,i)=>new Promise(s=>{const c=Date.now();if(c-r>t)return n=Reflect.apply(e,o,i),r=c,void s(n);s(n)})})},t.timing=I,t.toLowerCase=x,t.toObject=function(t,e,n=h){return t.reduce((t,r,o,i)=>{const s=e(r,o,i);return Reflect.has(t,s)||Reflect.set(t,s,n(r,o,i)),t},{})},t.toString=O,t.toUpperCase=z,t.treeMapping=Lt,t.treeToList=function(t,{calcPath:e=!1,bridge:n=h}={}){const r=[];return Lt(t,{before(t,o){const i=n(t);return e&&(i.path=(o?o+",":"")+i.id),r.push(i),i},paramFn:t=>e?[t.path]:[]}),r},t.trySometime=function(t,e=1,r=(t=>!0)){return new Proxy(t,{apply(t,o,i){return n(this,void 0,void 0,function*(){let n;for(let s=0;s<e;s++)try{const e=yield Reflect.apply(t,o,i);if(!0===r(e))return e;throw e}catch(t){n=t}throw n})}})},t.trySometimeParallel=function(t,e=1,r=(t=>!0)){return new Proxy(t,{apply(t,o,i){return n(this,void 0,void 0,function*(){return new Promise((s,c)=>n(this,void 0,void 0,function*(){let a;try{yield Promise.all(d(0,e).map(()=>n(this,void 0,void 0,function*(){try{const e=yield Reflect.apply(t,o,i);throw!0===r(e)&&s(e),e}catch(t){a=t}})))}catch(t){console.log(t)}c(a)}))})}})},t.uniqueBy=function(t,e=h){const n=new Set;return t.filter((t,...r)=>{const o=e(t,...r);return!n.has(o)&&(n.add(o),!0)})},t.wait=u,t.waitResource=function(t,{interval:e=100,max:n=10}={}){let r=0;return new Promise((o,i)=>{const s=setInterval(()=>{t()&&(clearInterval(s),o()),++r>=n&&(clearInterval(s),i(new Error("waitResource call timeout")))},e)})},t.watch=function(t,e,n=100){let r=t();const o=setInterval(()=>{const n=t();r!==n&&(e(n,r),r=n)},n);return()=>clearInterval(o)},t.watchEventListener=function(){const t=document.addEventListener,e=EventTarget.prototype.addEventListener,n=document.removeEventListener,r=EventTarget.prototype.removeEventListener;let o=[];document.addEventListener=EventTarget.prototype.addEventListener=function(n,r,i){const s=this===document?t:e;o.push(new M(this,n,r,i)),s.apply(this,n,r,i)},document.removeEventListenerByType=EventTarget.prototype.removeEventListenerByType=function(t){const e=this,i=e===document?n:r,s=f(o,n=>n.el===e&&n.type===t);s.get(!0).forEach(t=>{i.apply(t.el,[t.type,t.listener,t.useCapture])}),o=s.get(!1)}},t.watchObject=function(t,e){const n={get(t,e){try{return new Proxy(Reflect.get(t,e),n)}catch(n){return Reflect.get(t,e)}},set:(t,n,r)=>(e(t,n,r),Reflect.set(t,n,r))};return new Proxy(t,n)},Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=rx-util.min.js.map