util-helpers 4.8.3 → 4.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).utilHelpers={})}(this,(function(t){"use strict";const n=Object.prototype.toString;function e(t,e){return n.call(t)===`[object ${e}]`}function r(t){return e(t,"String")}function o(t){return r(t)?t:String(t)}const i=/^1[3456789]\d{9}$/;const s=/^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;const u=/^\d{6}$/;const c=/^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X)?$/i;function a(t,{loose:n=!1,checkCode:e=!0}={}){const r=o(t);return 15===r.length&&n?c.test(r):!(18!==r.length||!c.test(r))&&(!e||function(t){let n,e,r;for(e=n=0;n<17;n++)e+=Math.pow(2,17-n)%11*Number(t[n]);return r=(12-e%11)%11,r<10?r===Number(t[17]):"X"===t[17].toUpperCase()}(r))}const l=/^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})+$/i;const d=/^[1-9]\d{4,10}$/;const f=/^[a-z]([-_a-z0-9]{5,19})+$/i;const g=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;const p=/^[1-9]\d{9,20}$/,h=/^\d{8,30}$/;const b=/^[\dA-HJ-NPQRTUWXY]{2}\d{6}[\dA-HJ-NPQRTUWXY]{10}$/,m="0123456789ABCDEFGHJKLMNPQRTUWXY".split("");const $={disableWarning:!0};const y=/[\d]/,w=/[a-z]/,x=/[A-Z]/,A=/[\d|a-z]/gi;function F(t){return t.indexOf("\\x")>-1||t.indexOf("\\u")>-1}function M(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){let o=t;"string"!=typeof t&&($.disableWarning||console.warn("[validatePassword] value must be a string."),o="");let i=0;const s=(u=o,y.test(u));var u;const c=function(t){return w.test(t)}(o),a=function(t){return x.test(t)}(o),l=function(t,n=""){if(!n)return!1;const e=t.replace(A,""),r=F(n)?new RegExp(`[${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(n.indexOf(t)>-1&&(o=!0),o))),o}(o,r),d=function(t,n=""){const e=t.replace(A,"");if(!n&&e)return!0;const r=F(n)?new RegExp(`[^${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(-1===n.indexOf(t)&&(o=!0),o))),o}(o,r);s&&(i+=1),e?(c||a)&&(i+=1):(c&&(i+=1),a&&(i+=1)),l&&(i+=1);return{validated:i>=n&&!d,level:i,containes:{number:s,lowerCaseLetter:c,upperCaseLetter:a,specialCharacter:l,unallowableCharacter:d}}}const v=/^((e[\da-z])|(de)|(se)|(pe)|(k[\da-z])|(kj)|(ma))[\da-z]{7}$/i;const C="[一-龥]",N="[麦-鿯]",B="[㐀-䶵]",z="[𠀀-𪛖]",E="[𪜀-𫜴]",P="[𫝀-𫠝]",R="[𫠠-𬺡]",S="[𬺰-𮯠]";let T=C+"+",D="^"+C+"+$";const j=RegExp.prototype.hasOwnProperty("unicode");j&&(T="(?:"+C+"|"+N+"|"+B+"|"+z+"|"+E+"|"+P+"|"+R+"|"+S+")+",D="^(?:"+C+"|"+N+"|"+B+"|"+z+"|"+E+"|"+P+"|"+R+"|"+S+")+$");const W=/^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;const I=/^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;const U=/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\*\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;const Z=/^\d{15}$/;const L=/^[hm]{1}([0-9]{10}|[0-9]{8})$/i;const _=/^(\d{8}|[\da-z]{10})$/i;const k=Number.MAX_SAFE_INTEGER||9007199254740991,O=Number.MIN_SAFE_INTEGER||-9007199254740991;function X(t){return/\d+\.?\d*e[\+\-]*\d+/i.test(t)}function H(t,n=12){return+parseFloat(t.toPrecision(n))}function Q(t){const n=t.toString().split(/e/i),e=(n[0].split(".")[1]||"").length-+(n[1]||0);return e>0?e:0}function G(t){if(!X(t.toString()))return Number(t.toString().replace(".",""));const n=Q(t);return n>0?H(+t*Math.pow(10,n)):+t}function Y(t){(+t>k||+t<O)&&($.disableWarning||console.warn(`${t} is beyond boundary when transfer to integer, the results may not be accurate`))}function J(t){const n=/^([+-])?(0+)([0-9\.]+)$/.exec(t);let e;return n?(e=n[1]||"",e+("."===n[3][0]?"0"+n[3]:n[3])):t}function K(t){return e(t,"Number")&&isNaN(t)}const q=/^[+-]?\d*\.?\d*$/;function V(t){return function(t){return void 0===t}(t)||function(t){return null===t}(t)}function tt(t){return V(t)?"":o(t)}const nt=["零","一","二","三","四","五","六","七","八","九"],et=["","十","百","千"],rt=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],ot=["","拾","佰","仟"];let it,st,ut;function ct(t){let n="",e="",r=!1,o=0;for(;t>0;){let i=t%10;0==i?r&&(r=!1,e=it[i]+e):(r=!0,n=it[i],n+=st[o],e=n+e),o++,t=Math.floor(t/10)}return e}function at(t){const n=t+"";let e="";for(let t=0,r=n.length;t<r;t++)e+=it[parseInt(n[t])];return e}const lt=/^(?<province>\d{2})(?<city>\d{2})(?<area>\d{2})(?<year>(?:\d{2})?\d{2})(?<month>\d{2})(?<day>\d{2})\d{2}(?<gender>\d)(?:\d|X)?$/i,dt=[["11","北京市"],["12","天津市"],["13","河北省"],["14","山西省"],["15","内蒙古自治区"],["21","辽宁省"],["22","吉林省"],["23","黑龙江省"],["31","上海市"],["32","江苏省"],["33","浙江省"],["34","安徽省"],["35","福建省"],["36","江西省"],["37","山东省"],["41","河南省"],["42","湖北省"],["43","湖南省"],["44","广东省"],["45","广西壮族自治区"],["46","海南省"],["50","重庆市"],["51","四川省"],["52","贵州省"],["53","云南省"],["54","西藏自治区"],["61","陕西省"],["62","甘肃省"],["63","青海省"],["64","宁夏回族自治区"],["65","新疆维吾尔自治区"],["71","台湾省"],["83","台湾省"],["81","香港特别行政区"],["82","澳门特别行政区"]];function ft(t){return e(t,"Number")}function gt(...t){const[n,e,...o]=t;if(o.length>0)return gt(gt(n,e),...o);if((!ft(e)||K(e))&&!r(e))return n;const i=G(n),s=G(e),u=Q(n)+Q(e),c=i*s;return Y(c),c/Math.pow(10,u)}function pt(...t){const[n,e,...o]=t;if(o.length>0)return pt(pt(n,e),...o);if((!ft(e)||K(e))&&!r(e))return n;const i=G(n),s=G(e);return Y(i),Y(s),gt(i/s,H(Math.pow(10,Q(e)-Q(n))))}const ht="abcdefghijklmnopqrstuvwxyz",bt="0123456789"+ht+ht.toUpperCase();function mt(t=0,n=bt,e=""){for(;t-- >0;){return mt(t,n,e+n[Math.floor(Math.random()*n.length)])}return e}t.blobToDataURL=function(t){return new Promise(((n,e)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>n(r.result),r.onerror=t=>e(t)}))},t.bytesToSize=function(t){if(0===t)return"0 B";const n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],e=Math.floor(Math.log(t)/Math.log(1024));return n[e]?`${Number((t/Math.pow(1024,e)).toFixed(2))} ${n[e]}`:t+""},t.calculateCursorPosition=function(t,n,e,r,{placeholderChar:o=" ",maskReg:i=/\D/g,type:s}={}){const u=tt(n),c=tt(e),a=Array.isArray(o)?o:[o],l=c.length-u.length;let d=t;if(l>0){let t=c.substring(d-l,d).replace(i,"").length;d-=l-t;let n=0;for(;t>0;)-1!==a.indexOf(r.charAt(d-t+n))?n++:t--;d+=n}return("mobile"===s&&(4===d||9===d)||"bankCard"===s&&d>0&&d%5==0)&&(d-=1),d},t.dataURLToBlob=function(t){const n=t.split(","),e=n[0].match(/:(.*?);/)[1],r=atob(n[1]);let o=r.length;const i=new Uint8Array(o);for(;o--;)i[o]=r.charCodeAt(o);return new Blob([i],{type:e})},t.divide=pt,t.formatBankCard=function(t="",{char:n=" ",length:e=4}={}){const r=new RegExp(`(.{${e}})`,"g"),o=new RegExp(`${n}`,"g"),i=tt(t).replace(o,""),s=i.replace(r,`$1${n}`);return i.length%e==0?s.substring(0,s.length-1):s},t.formatMobile=function(t,{char:n=" "}={}){const e=new RegExp(n,"g"),r=tt(t).replace(e,"").substring(0,11);return r.length>7?r.replace(/^(...)(....)/g,`$1${n}$2${n}`):r.length>3?r.replace(/^(...)/g,`$1${n}`):r},t.formatMoney=(t,{precision:n=2,symbol:e,thousand:r=",",decimal:o="."}={})=>{if(!function(t){return!q.test(t)&&!X(t)||K(t)||"number"!=typeof t&&"string"!=typeof t||""===t?($.disableWarning||console.warn(`${t} invalid parameter.`),!1):("number"==typeof t&&Y(t),!0)}(t))return"";"number"!=typeof n||K(n)||n<0?n=2:n>10&&(n=10),e="string"==typeof e?e:"",r="string"==typeof r?r:",",o="string"==typeof o?o:".";const i=function(t){if(X(t.toString())){const n="0",e=String(t).toLowerCase().split("e"),r=e.pop(),o=Math.abs(r),i=r/o,s=e[0].split(".");if(-1===i)t=n+"."+new Array(o).join(n)+s.join("");else{const e=s[1];t=o-e.length<0?J(s[0]+e.substring(0,o))+"."+e.substring(o):s.join("")+new Array(o-e.length+1).join(n)}}return t}(t)+"",[s,u]=i.split(".");return e+function(t,n){let e="";t="+"===(t=J(t))[0]?t.substring(1):t;const r=Number(t)<0?"-":"",o=r?t.substring(1).split("").reverse():t.split("").reverse();for(let t=0;t<o.length;t++)e+=o[t]+((t+1)%3==0&&t+1!==o.length?n:"");return r+e.split("").reverse().join("")}(s,r)+function(t,n,e){if(0===n)return"";let r="";r=t&&Number(t)>0?parseFloat("0."+t).toFixed(n).substring(2):(0).toFixed(n).substring(2);return e+r}(u,n,o)},t.isBankCard=function(t,{loose:n=!1,luhn:e=!1}={}){const r=o(t),i=n?h.test(r):p.test(r);if(i&&e){const t=r.substring(0,r.length-1);return r[r.length-1]===String(function(t){const n=(t+"").replace(/\D/g,"").split("").reverse();let e=0;for(let t=0;t<n.length;t++){const r=parseInt(n[t]);e+=t%2==0?2*r-(r>4?9:0):r}const r=e%10;return 0!==r?10-r:0}(t))}return i},t.isBusinessLicense=function(t,{loose:n=!1}={}){const e=o(t),r=Z.test(e);if(n||!r)return r;const i=e.substring(0,14),s=e.substring(e.length-1),u=function(t){let n,e=10;for(let n=0;n<14;n++){let r=(e+Number(t[n]))%10;r=0===r?10:r,e=2*r%11}return n=10===e||1===e?1:11-e,n}(i);return s===String(u)},t.isChinese=function(t,{loose:n=!1}={}){const e=o(t);return new RegExp(n?T:D,j?"u":void 0).test(e)},t.isEmail=function(t){const n=o(t);return l.test(n)},t.isHMCard=function(t){const n=o(t);return L.test(n)},t.isIPv4=function(t){const n=o(t);return W.test(n)},t.isIPv6=function(t){const n=o(t);return I.test(n)},t.isIdCard=a,t.isMobile=function(t){const n=o(t);return i.test(n)},t.isPassport=function(t){const n=o(t);return v.test(n)},t.isPassword=function(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){return M(t,{level:n,ignoreCase:e,special:r}).validated},t.isPostcode=function(t){const n=o(t);return u.test(n)},t.isPromiseLike=function(t){return null!==t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then},t.isQQ=function(t){const n=o(t);return d.test(n)},t.isSocialCreditCode=function(t,{loose:n=!1}={}){const e=o(t),r=b.test(e);if(n||!r)return r;const i=e.substring(0,17);return e.substring(e.length-1)===function(t){let n=0;for(let e=0;e<17;e++)n+=m.findIndex((n=>n===t[e]))*(Math.pow(3,e)%31);const e=n%31;return m[0!==e?31-e:0]}(i)},t.isTWCard=function(t){const n=o(t);return _.test(n)},t.isTelephone=function(t){const n=o(t);return s.test(n)},t.isUrl=function(t){const n=o(t);return U.test(n)},t.isVehicle=function(t){const n=o(t);return g.test(n)},t.isWX=function(t){const n=o(t);return f.test(n)},t.minus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!ft(o)||K(o))&&!r(o))return e;const s=Math.pow(10,Math.max(Q(e),Q(o)));return(gt(e,s)-gt(o,s))/s},t.normalizeString=tt,t.numberToChinese=function(t,{big5:n=!1,unit:e=!0,decimal:r="点",zero:o="",negative:i="负",unitConfig:s={w:"万",y:"亿"}}={}){if("number"!=typeof t||isNaN(t))return $.disableWarning||console.warn(`参数错误 ${t},请传入数字`),"";Y(t),n?(it=rt.slice(),st=ot.slice()):(it=nt.slice(),st=et.slice()),ut=["",s.w||"万",s.y||"亿",s.w&&s.y?s.w+s.y:"万亿"],o&&(it[0]=o);const u=t<0?i:"";let c,a;return c=e?function(t){let n=0,e="",r="",o=!1;if(0===(t=Math.floor(t)))return it[0];for(;t>0;){var i=t%1e4;o&&(r=it[0]+r),e=ct(i),e+=0!==i?ut[n]:ut[0],r=e+r,o=i<1e3&&i>0,t=Math.floor(t/1e4),n++}return r}(t):at(Math.floor(t)),a=function(t){const n=t+"",e=n.indexOf(".");let r="";if(e>-1){let t=n.slice(e+1);r=at(parseInt(t))}return r}(t),a?`${u}${c}${r}${a}`:`${u}${c}`},t.padZero=function(t,n=2){const e=tt(t),r=e.length;return("number"!=typeof n||n<0)&&(n=0),r<n?"0".repeat(n-r)+e:e},t.parseIdCard=function(t){if(!a(t,{loose:!0}))return null;const n=lt.exec(t);if(!n)return null;let e={province:"",city:"",area:"",year:"",month:"",day:"",gender:""};e=n.groups?n.groups:{province:n[1],city:n[2],area:n[3],year:n[4],month:n[5],day:n[6],gender:n[7]};const r=dt.find((t=>t[0]===e.province));if(!r)return null;const o=`${e.year}-${e.month}-${e.day}`,i=Number(e.gender)%2==0?"女":"男";return{province:r[1],birthday:o,gender:i,origin:e}},t.plus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!ft(o)||K(o))&&!r(o))return e;const s=Math.pow(10,Math.max(Q(e),Q(o)));return(gt(e,s)+gt(o,s))/s},t.randomString=function(t=0,n){return mt(t,"string"==typeof n&&n?n:bt)},t.replaceChar=function(t="",{start:n=3,end:e=-4,char:r="*",repeat:o,exclude:i}={}){const s=t.length;if(Math.abs(n)>=s)return t;if((n=n>=0?n:s+n)>=(e=e>=0?e:s+e))return t;let u=t.substring(n,e);if(i){const t=new RegExp(`[^${i}]`,"g");u=u.replace(t,r)}else o="number"==typeof o&&o>=0?o:u.length,u=r.repeat(o);return t.substring(0,n)+u+t.substring(e)},t.round=function(t,n=0){const e=Math.pow(10,n);return pt(Math.round(gt(t,e)),e)},t.safeDate=function(t,...n){const e="string"==typeof t?t.replace(/[\\.-]/g,"/"):t;return n&&n.length>0?new Date(e,...n):V(e)?new Date:new Date(e)},t.setDataURLPrefix=function(t,n="image/png",e=!0){return`data:${n}${e?";base64":""},${t}`},t.setDisableWarning=function(t){$.disableWarning=!!t},t.times=gt,t.validatePassword=M,t.waitTime=function(t=1e3){return new Promise((n=>{setTimeout(n,t)}))},Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).utilHelpers={})}(this,(function(t){"use strict";const n=Object.prototype.toString;function e(t,e){return n.call(t)===`[object ${e}]`}function r(t){return e(t,"String")}function o(t){return r(t)?t:String(t)}const i=/^1[3456789]\d{9}$/;const s=/^(0\d{2,3}\-)?([2-9]\d{6,7})(\-\d{1,6})?$/;const u=/^\d{6}$/;const c=/^[1-9]\d{5}(19|20)?\d{2}((0[1-9])|(1[012]))(([0-2][1-9])|10|20|30|31)\d{3}(\d|X)?$/i;function a(t,{loose:n=!1,checkCode:e=!0}={}){const r=o(t);return 15===r.length&&n?c.test(r):!(18!==r.length||!c.test(r))&&(!e||function(t){let n,e,r;for(e=n=0;n<17;n++)e+=Math.pow(2,17-n)%11*Number(t[n]);return r=(12-e%11)%11,r<10?r===Number(t[17]):"X"===t[17].toUpperCase()}(r))}const d=/^[\da-z]+([\-\.\_]?[\da-z]+)*@[\da-z]+([\-\.]?[\da-z]+)*(\.[a-z]{2,})+$/i;const l=/^[1-9]\d{4,10}$/;const f=/^[a-z]([-_a-z0-9]{5,19})+$/i;const g=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([A-Z0-9]{4}[A-Z0-9挂学警港澳]{1})|([A-Z0-9]{5}[DF])|([DF][A-Z0-9]{5}))$/;const p=/^[1-9]\d{9,20}$/,h=/^\d{8,30}$/;const b=/^[\dA-HJ-NPQRTUWXY]{2}\d{6}[\dA-HJ-NPQRTUWXY]{10}$/,m="0123456789ABCDEFGHJKLMNPQRTUWXY".split("");const $={disableWarning:!0};const y=/[\d]/,w=/[a-z]/,A=/[A-Z]/,x=/[\d|a-z]/gi;function F(t){return t.indexOf("\\x")>-1||t.indexOf("\\u")>-1}function M(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){let o=t;"string"!=typeof t&&($.disableWarning||console.warn("[validatePassword] value must be a string."),o="");let i=0;const s=(u=o,y.test(u));var u;const c=function(t){return w.test(t)}(o),a=function(t){return A.test(t)}(o),d=function(t,n=""){if(!n)return!1;const e=t.replace(x,""),r=F(n)?new RegExp(`[${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(n.indexOf(t)>-1&&(o=!0),o))),o}(o,r),l=function(t,n=""){const e=t.replace(x,"");if(!n&&e)return!0;const r=F(n)?new RegExp(`[^${n}]`):null;if(r)return r.test(e);let o=!1;return e.split("").some((t=>(-1===n.indexOf(t)&&(o=!0),o))),o}(o,r);s&&(i+=1),e?(c||a)&&(i+=1):(c&&(i+=1),a&&(i+=1)),d&&(i+=1);return{validated:i>=n&&!l,level:i,containes:{number:s,lowerCaseLetter:c,upperCaseLetter:a,specialCharacter:d,unallowableCharacter:l}}}const v=/^((e[\da-z])|(de)|(se)|(pe)|(k[\da-z])|(kj)|(ma))[\da-z]{7}$/i;const C="[一-龥]",N="[麦-鿯]",B="[㐀-䶵]",z="[𠀀-𪛖]",E="[𪜀-𫜴]",P="[𫝀-𫠝]",R="[𫠠-𬺡]",S="[𬺰-𮯠]";let T=C+"+",Z="^"+C+"+$";const D=RegExp.prototype.hasOwnProperty("unicode");D&&(T="(?:"+C+"|"+N+"|"+B+"|"+z+"|"+E+"|"+P+"|"+R+"|"+S+")+",Z="^(?:"+C+"|"+N+"|"+B+"|"+z+"|"+E+"|"+P+"|"+R+"|"+S+")+$");const j=/^((\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;const W=/^((([0-9A-F]{1,4}:){7}([0-9A-F]{1,4}|:))|(([0-9A-F]{1,4}:){6}(:[0-9A-F]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){5}(((:[0-9A-F]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3})|:))|(([0-9A-F]{1,4}:){4}(((:[0-9A-F]{1,4}){1,3})|((:[0-9A-F]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){3}(((:[0-9A-F]{1,4}){1,4})|((:[0-9A-F]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){2}(((:[0-9A-F]{1,4}){1,5})|((:[0-9A-F]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(([0-9A-F]{1,4}:){1}(((:[0-9A-F]{1,4}){1,6})|((:[0-9A-F]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:))|(:(((:[0-9A-F]{1,4}){1,7})|((:[0-9A-F]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|\d{1,2})(\.(25[0-5]|2[0-4]\d|1\d\d|\d{1,2})){3}))|:)))(%.+)?$/i;const I=/(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\*\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;const U=/^\d{15}$/;const L=/^[hm]{1}([0-9]{10}|[0-9]{8})$/i;const _=/^(\d{8}|[\da-z]{10})$/i;const k=/^[A-Z]{6}[A-Z\d]{2}(?:[A-Z\d]{3})?$/;const O=Number.MAX_SAFE_INTEGER||9007199254740991,X=Number.MIN_SAFE_INTEGER||-9007199254740991;function H(t){return/\d+\.?\d*e[\+\-]*\d+/i.test(t)}function Q(t,n=12){return+parseFloat(t.toPrecision(n))}function G(t){const n=t.toString().split(/e/i),e=(n[0].split(".")[1]||"").length-+(n[1]||0);return e>0?e:0}function Y(t){if(!H(t.toString()))return Number(t.toString().replace(".",""));const n=G(t);return n>0?Q(+t*Math.pow(10,n)):+t}function J(t){(+t>O||+t<X)&&($.disableWarning||console.warn(`${t} is beyond boundary when transfer to integer, the results may not be accurate`))}function K(t){const n=/^([+-])?(0+)([0-9\.]+)$/.exec(t);let e;return n?(e=n[1]||"",e+("."===n[3][0]?"0"+n[3]:n[3])):t}function q(t){return e(t,"Number")&&isNaN(t)}const V=/^[+-]?\d*\.?\d*$/;function tt(t){return function(t){return void 0===t}(t)||function(t){return null===t}(t)}function nt(t){return tt(t)?"":o(t)}const et=["零","一","二","三","四","五","六","七","八","九"],rt=["","十","百","千"],ot=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],it=["","拾","佰","仟"];let st,ut,ct;function at(t){let n="",e="",r=!1,o=0;for(;t>0;){let i=t%10;0==i?r&&(r=!1,e=st[i]+e):(r=!0,n=st[i],n+=ut[o],e=n+e),o++,t=Math.floor(t/10)}return e}function dt(t){const n=t+"";let e="";for(let t=0,r=n.length;t<r;t++)e+=st[parseInt(n[t])];return e}const lt=/^(?<province>\d{2})(?<city>\d{2})(?<area>\d{2})(?<year>(?:\d{2})?\d{2})(?<month>\d{2})(?<day>\d{2})\d{2}(?<gender>\d)(?:\d|X)?$/i,ft=[["11","北京市"],["12","天津市"],["13","河北省"],["14","山西省"],["15","内蒙古自治区"],["21","辽宁省"],["22","吉林省"],["23","黑龙江省"],["31","上海市"],["32","江苏省"],["33","浙江省"],["34","安徽省"],["35","福建省"],["36","江西省"],["37","山东省"],["41","河南省"],["42","湖北省"],["43","湖南省"],["44","广东省"],["45","广西壮族自治区"],["46","海南省"],["50","重庆市"],["51","四川省"],["52","贵州省"],["53","云南省"],["54","西藏自治区"],["61","陕西省"],["62","甘肃省"],["63","青海省"],["64","宁夏回族自治区"],["65","新疆维吾尔自治区"],["71","台湾省"],["83","台湾省"],["81","香港特别行政区"],["82","澳门特别行政区"]];function gt(t){return e(t,"Number")}function pt(...t){const[n,e,...o]=t;if(o.length>0)return pt(pt(n,e),...o);if((!gt(e)||q(e))&&!r(e))return n;const i=Y(n),s=Y(e),u=G(n)+G(e),c=i*s;return J(c),c/Math.pow(10,u)}function ht(...t){const[n,e,...o]=t;if(o.length>0)return ht(ht(n,e),...o);if((!gt(e)||q(e))&&!r(e))return n;const i=Y(n),s=Y(e);return J(i),J(s),pt(i/s,Q(Math.pow(10,G(e)-G(n))))}const bt="abcdefghijklmnopqrstuvwxyz",mt="0123456789"+bt+bt.toUpperCase();function $t(t=0,n=mt,e=""){for(;t-- >0;){return $t(t,n,e+n[Math.floor(Math.random()*n.length)])}return e}t.blobToDataURL=function(t){return new Promise(((n,e)=>{const r=new FileReader;r.readAsDataURL(t),r.onload=()=>n(r.result),r.onerror=t=>e(t)}))},t.bytesToSize=function(t){if(0===t)return"0 B";const n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],e=Math.floor(Math.log(t)/Math.log(1024));return n[e]?`${Number((t/Math.pow(1024,e)).toFixed(2))} ${n[e]}`:t+""},t.calculateCursorPosition=function(t,n,e,r,{placeholderChar:o=" ",maskReg:i=/\D/g,type:s}={}){const u=nt(n),c=nt(e),a=Array.isArray(o)?o:[o],d=c.length-u.length;let l=t;if(d>0){let t=c.substring(l-d,l).replace(i,"").length;l-=d-t;let n=0;for(;t>0;)-1!==a.indexOf(r.charAt(l-t+n))?n++:t--;l+=n}return("mobile"===s&&(4===l||9===l)||"bankCard"===s&&l>0&&l%5==0)&&(l-=1),l},t.dataURLToBlob=function(t){const n=t.split(","),e=n[0].match(/:(.*?);/)[1],r=atob(n[1]);let o=r.length;const i=new Uint8Array(o);for(;o--;)i[o]=r.charCodeAt(o);return new Blob([i],{type:e})},t.divide=ht,t.formatBankCard=function(t="",{char:n=" ",length:e=4}={}){const r=new RegExp(`(.{${e}})`,"g"),o=new RegExp(`${n}`,"g"),i=nt(t).replace(o,""),s=i.replace(r,`$1${n}`);return i.length%e==0?s.substring(0,s.length-1):s},t.formatMobile=function(t,{char:n=" "}={}){const e=new RegExp(n,"g"),r=nt(t).replace(e,"").substring(0,11);return r.length>7?r.replace(/^(...)(....)/g,`$1${n}$2${n}`):r.length>3?r.replace(/^(...)/g,`$1${n}`):r},t.formatMoney=(t,{precision:n=2,symbol:e,thousand:r=",",decimal:o="."}={})=>{if(!function(t){return!V.test(t)&&!H(t)||q(t)||"number"!=typeof t&&"string"!=typeof t||""===t?($.disableWarning||console.warn(`${t} invalid parameter.`),!1):("number"==typeof t&&J(t),!0)}(t))return"";"number"!=typeof n||q(n)||n<0?n=2:n>10&&(n=10),e="string"==typeof e?e:"",r="string"==typeof r?r:",",o="string"==typeof o?o:".";const i=function(t){if(H(t.toString())){const n="0",e=String(t).toLowerCase().split("e"),r=e.pop(),o=Math.abs(r),i=r/o,s=e[0].split(".");if(-1===i)t=n+"."+new Array(o).join(n)+s.join("");else{const e=s[1];t=o-e.length<0?K(s[0]+e.substring(0,o))+"."+e.substring(o):s.join("")+new Array(o-e.length+1).join(n)}}return t}(t)+"",[s,u]=i.split(".");return e+function(t,n){let e="";t="+"===(t=K(t))[0]?t.substring(1):t;const r=Number(t)<0?"-":"",o=r?t.substring(1).split("").reverse():t.split("").reverse();for(let t=0;t<o.length;t++)e+=o[t]+((t+1)%3==0&&t+1!==o.length?n:"");return r+e.split("").reverse().join("")}(s,r)+function(t,n,e){if(0===n)return"";let r="";r=t&&Number(t)>0?parseFloat("0."+t).toFixed(n).substring(2):(0).toFixed(n).substring(2);return e+r}(u,n,o)},t.isBankCard=function(t,{loose:n=!1,luhn:e=!1}={}){const r=o(t),i=n?h.test(r):p.test(r);if(i&&e){const t=r.substring(0,r.length-1);return r[r.length-1]===String(function(t){const n=(t+"").replace(/\D/g,"").split("").reverse();let e=0;for(let t=0;t<n.length;t++){const r=parseInt(n[t]);e+=t%2==0?2*r-(r>4?9:0):r}const r=e%10;return 0!==r?10-r:0}(t))}return i},t.isBusinessLicense=function(t,{loose:n=!1}={}){const e=o(t),r=U.test(e);if(n||!r)return r;const i=e.substring(0,14),s=e.substring(e.length-1),u=function(t){let n,e=10;for(let n=0;n<14;n++){let r=(e+Number(t[n]))%10;r=0===r?10:r,e=2*r%11}return n=10===e||1===e?1:11-e,n}(i);return s===String(u)},t.isChinese=function(t,{loose:n=!1}={}){const e=o(t);return new RegExp(n?T:Z,D?"u":void 0).test(e)},t.isEmail=function(t){const n=o(t);return d.test(n)},t.isHMCard=function(t){const n=o(t);return L.test(n)},t.isIPv4=function(t){const n=o(t);return j.test(n)},t.isIPv6=function(t){const n=o(t);return W.test(n)},t.isIdCard=a,t.isMobile=function(t){const n=o(t);return i.test(n)},t.isPassport=function(t){const n=o(t);return v.test(n)},t.isPassword=function(t,{level:n=2,ignoreCase:e=!1,special:r="\\x21-\\x2F\\x3A-\\x40\\x5B-\\x60\\x7B-\\x7E"}={}){return M(t,{level:n,ignoreCase:e,special:r}).validated},t.isPostcode=function(t){const n=o(t);return u.test(n)},t.isPromiseLike=function(t){return null!==t&&("object"==typeof t||"function"==typeof t)&&"function"==typeof t.then},t.isQQ=function(t){const n=o(t);return l.test(n)},t.isSocialCreditCode=function(t,{loose:n=!1}={}){const e=o(t),r=b.test(e);if(n||!r)return r;const i=e.substring(0,17);return e.substring(e.length-1)===function(t){let n=0;for(let e=0;e<17;e++)n+=m.findIndex((n=>n===t[e]))*(Math.pow(3,e)%31);const e=n%31;return m[0!==e?31-e:0]}(i)},t.isSwiftCode=function(t){const n=o(t);return k.test(n)},t.isTWCard=function(t){const n=o(t);return _.test(n)},t.isTelephone=function(t){const n=o(t);return s.test(n)},t.isUrl=function(t){const n=o(t);return I.test(n)},t.isVehicle=function(t){const n=o(t);return g.test(n)},t.isWX=function(t){const n=o(t);return f.test(n)},t.minus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!gt(o)||q(o))&&!r(o))return e;const s=Math.pow(10,Math.max(G(e),G(o)));return(pt(e,s)-pt(o,s))/s},t.normalizeString=nt,t.numberToChinese=function(t,{big5:n=!1,unit:e=!0,decimal:r="点",zero:o="",negative:i="负",unitConfig:s={w:"万",y:"亿"}}={}){if("number"!=typeof t||isNaN(t))return $.disableWarning||console.warn(`参数错误 ${t},请传入数字`),"";J(t),n?(st=ot.slice(),ut=it.slice()):(st=et.slice(),ut=rt.slice()),ct=["",s.w||"万",s.y||"亿",s.w&&s.y?s.w+s.y:"万亿"],o&&(st[0]=o);const u=t<0?i:"";let c,a;return c=e?function(t){let n=0,e="",r="",o=!1;if(0===(t=Math.floor(t)))return st[0];for(;t>0;){var i=t%1e4;o&&(r=st[0]+r),e=at(i),e+=0!==i?ct[n]:ct[0],r=e+r,o=i<1e3&&i>0,t=Math.floor(t/1e4),n++}return r}(t):dt(Math.floor(t)),a=function(t){const n=t+"",e=n.indexOf(".");let r="";if(e>-1){let t=n.slice(e+1);r=dt(parseInt(t))}return r}(t),a?`${u}${c}${r}${a}`:`${u}${c}`},t.padZero=function(t,n=2){const e=nt(t),r=e.length;return("number"!=typeof n||n<0)&&(n=0),r<n?"0".repeat(n-r)+e:e},t.parseIdCard=function(t){if(!a(t,{loose:!0}))return null;const n=lt.exec(t);if(!n)return null;let e={province:"",city:"",area:"",year:"",month:"",day:"",gender:""};e=n.groups?n.groups:{province:n[1],city:n[2],area:n[3],year:n[4],month:n[5],day:n[6],gender:n[7]};const r=ft.find((t=>t[0]===e.province));if(!r)return null;const o=`${e.year}-${e.month}-${e.day}`,i=Number(e.gender)%2==0?"女":"男";return{province:r[1],birthday:o,gender:i,origin:e}},t.plus=function t(...n){const[e,o,...i]=n;if(i.length>0)return t(t(e,o),...i);if((!gt(o)||q(o))&&!r(o))return e;const s=Math.pow(10,Math.max(G(e),G(o)));return(pt(e,s)+pt(o,s))/s},t.randomString=function(t=0,n){return $t(t,"string"==typeof n&&n?n:mt)},t.replaceChar=function(t="",{start:n=3,end:e=-4,char:r="*",repeat:o,exclude:i}={}){const s=t.length;if(Math.abs(n)>=s)return t;if((n=n>=0?n:s+n)>=(e=e>=0?e:s+e))return t;let u=t.substring(n,e);if(i){const t=new RegExp(`[^${i}]`,"g");u=u.replace(t,r)}else o="number"==typeof o&&o>=0?o:u.length,u=r.repeat(o);return t.substring(0,n)+u+t.substring(e)},t.round=function(t,n=0){const e=Math.pow(10,n);return ht(Math.round(pt(t,e)),e)},t.safeDate=function(t,...n){const e="string"==typeof t?t.replace(/[\\.-]/g,"/"):t;return n&&n.length>0?new Date(e,...n):tt(e)?new Date:new Date(e)},t.setDataURLPrefix=function(t,n="image/png",e=!0){return`data:${n}${e?";base64":""},${t}`},t.setDisableWarning=function(t){$.disableWarning=!!t},t.times=pt,t.validatePassword=M,t.waitTime=function(t=1e3){return new Promise((n=>{setTimeout(n,t)}))},Object.defineProperty(t,"__esModule",{value:!0})}));
2
2
  //# sourceMappingURL=util-helpers.min.js.map