@10yun/cv-js-utils
Version:
常用 js-utils 工具类库
2 lines (1 loc) • 30.9 kB
JavaScript
(function(a,m){typeof exports=="object"&&typeof module<"u"?m(exports):typeof define=="function"&&define.amd?define(["exports"],m):(a=typeof globalThis<"u"?globalThis:a||self,m(a.cvUtils={}))})(this,function(a){"use strict";function m(){for(var e=arguments.length||0,t=[],n=0;n<e;n++)t.push(...arguments[n]);return t}function K(e,t){var n=Array.prototype.slice.call(arguments),r=1,i,o=typeof n[n.length-1]=="boolean"?n.pop():!0;for(n.length===1&&(e=this,r=0);t=n[r++];)for(i in t)i in e?typeof t[i]=="object"&&typeof e[i]=="object"?e[i]=Object.assign(e[i],t[i]):typeof t[i]=="function"&&typeof e[i]=="function"&&(e[i]=t[i]):(o||!(i in e))&&(e[i]=t[i]);return e}function X(e){for(var t=Array.prototype.slice.call(arguments,1),n=0;n<t.length;n+=1){var r=t[n];for(var i in r)r.hasOwnProperty(i)&&(e[i]=r[i])}return e}function V(e){let t=!1;return typeof e=="object"&&e.length>0&&(t=e[e.length-1]),t}function x(e,t,n){var r=function(c){return function(h,d){var M=h[c],p=d[c];return M<p?-1:M>p?1:0}},i=e.sort(r(t));if(n=n||!1,n==!0){for(var o=[],u=0;u<26;u++){var l=String.fromCharCode(65+u),f=[];for(let c in i)l===i[c][t]&&i[c]!==void 0&&i[c]!==null&&f.push(i[c]);f!==void 0&&f.length>0&&o.push({letter:l,tree:f})}return o}else return i}function ee(e,t){var n=[];return n=e,e.forEach(function(r,i){for(var o in r){(r[o]=="true"||r[o]==!0)&&(n[i][o]=!0),(r[o]=="false"||r[o]==!1)&&(n[i][o]=!1);for(var u in initArr)if(o==u)switch(initArr[u]){case"[]":(r[o]==""||r[o]==null)&&(n[i][o]=[])}}}),n}function te(e,t){for(s=0;s<e.length;s++)if(thisEntry=e[s].toString(),thisEntry==t)return!0;return!1}function ne(e,t,n=!1){return Array.isArray(t)?n?!!t.find(r=>r&&r.indexOf("*")&&new RegExp("^"+r.replace(/[-\/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$","g").test(e)?!0:r==e):t.includes(e):!1}function re(e,t){return e.includes(t)}function ie(e,t){let n=[];return typeof t=="string"&&t.constructor==String&&(t=t.replace(/\s*/g,""),t=t.split(",")),e.forEach(function(r,i){n[i]={},t.map(function(o){n[i][o]="",r[o]!==void 0&&r[o]!==null&&(n[i][o]=r[o])})}),n}function ae(e){return Array.from(new Set(e))}function oe(e){if(e)try{return e.length}catch{return 0}return 0}function ue(e,t){return e.indexOf(t)!=-1}function se(e){if(Array.hasOwnProperty("from"))return Array.from(new Set(e));for(var t={},n=[],r=0;r<e.length;r++)t[e[r]]||(t[e[r]]=!0,n.push(e[r]));return n}function O(e=[],t={id:"id",pid:"pid",children:"children"}){let n=[],r={},i=[0,"0",void 0,"undefined",null,"null","00000000-0000-0000-0000-000000000000",""];return e.forEach(o=>{let u=e.filter(f=>f[t.pid]===o[t.id]);o[t.children]&&o[t.children]instanceof Array&&o[t.children].length>0?(o[t.children].map(f=>r[f[t.id]]=1),o[t.children].push(...u.filter(f=>r[f[t.id]]!==1))):o[t.children]=u;let l=u.length>0;(l||!l&&i.includes(o[t.pid]))&&n.push(o)}),n.every(o=>i.includes(o[t.pid]))?n:O(n,t)}function _(e=[],t="children"){return e.reduce((n,r)=>n.concat(r,r[t]?_(r[t],t):[]),[])}function v(e,t=""){return e.reduce((n,r)=>n.concat(r[t]||[],r[t]?v([r[t]],t):[]),[])}function ce(e=[]){let t=0;return function n(r,i){++i,t=Math.max(i,t);for(let o=0;o<r.length;o++){let u=r[o];u.level=i,u.children&&u.children.length>0?n(u.children,i):delete u.children}}(e,0),t}function D(e=[],t,n="id",r="children"){return e.reduce((i,o)=>i.concat(o[n]==t?o:D(o[r]||[],t,n,r)),[])}function C(e,t,n){e[t]&&(n&&n(e[t]),C(e[t],t,n))}function le(){if(I())return"edge";if(N())return"opera";if($())return"firefox";if(P())return"weixin";if(F())return"safari";if(E())return"chrome"}function fe(e){const t=e||navigator.userAgent;return t.indexOf("MSIE")>=0&&t.indexOf("Opera")<0||t.indexOf("MSIE")>-1&&t.indexOf("compatible")>-1||t.indexOf("MSIE")>-1&&t.indexOf("Trident")>-1}function de(e){const t=e||navigator.userAgent;return t.indexOf("Trident")>-1&&t.indexOf("rv:11.0")>-1}function I(e){return(e||navigator.userAgent).indexOf("Edg")>-1}function E(e){return(e||navigator.userAgent).indexOf("Chrome")>-1}function N(e){const t=e||navigator.userAgent;return t.indexOf("Opera")>-1||t.indexOf("OPR")>-1}function $(e){return(e||navigator.userAgent).indexOf("Firefox")>-1}function F(e){const t=e||navigator.userAgent;return t.indexOf("Safari")>-1&&t.indexOf("Chrome")==-1&&t.indexOf("MicroMessenger")==-1}function he(e){return(e||navigator.userAgent).indexOf("AppleWebKit")>-1}function P(){if(typeof window>"u"||!window)return!1;const e=window.navigator.userAgent.toLowerCase();return e.match(/MicroMessenger/i)=="micromessenger"||e.match(/MicroMessenger/i)+""=="micromessenger"||e.indexOf("MicroMessenger")>-1||e.match(/micromessenger/i)=="micromessenger"}function ge(e){return(e||navigator.userAgent).match(/\sQQ/i)==" QQ"}function be(e){const t=e||navigator.userAgent;return!!/Weibo/i.test(t)}function g(e){return e.replace(/\s+/g,"")}function ye(e){let t=/^[0-9]{12,}$/;return e=e?g(e):"",t.test(e)}function me(e){let t=/^[0-9]{6}$/;return e=e?g(e):"",t.test(e)}function pe(e){const t=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/,n=/^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/;return e.length===7?n.test(e):e.length===8?t.test(e):!1}function Se(e){return/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(e)}function Ae(e){return e=e||"",e==""?!1:(e=e?g(e):"",e=parseInt(e),!!/^((13[0-9])|(14[5,7,9])|(15[^4])|(16[6])|(17[1,2,3,5,6,7,8])|(18[0-9])|(19[1,3,8,9]))+\d{8}$/.test(e))}function we(e){return!!/^[1-9][0-9]{4,9}$/.test(e)}function Me(){return/<("[^"]*"|'[^']*'|[^'">])*>/.test(str)}function je(e){return/((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(e)}function Te(e){e=e?g(e):"";let t=/^([0-9]{3,4}-)?[0-9]{7,8}$/,n=/^0?1[3|4|5|8][0-9]\d{8}$/,r=/^400[0-9]{7}$/;return!!(n.test(e)||t.test(e)||r.test(e))}function Oe(e){return e=e?g(e):"",!!"/^http|https://([w-]+(.[w-]+)+(/[w-./?%@&+=一-龥]*)?)?$/".test(e)}function _e(e){return e=e?g(e):"",!!"/^(w+://)?w+(.w+)+.*$/".test(e)}function ve(e){return/[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF][\u200D|\uFE0F]|[\uD83C|\uD83D|\uD83E][\uDC00-\uDFFF]|[0-9|*|#]\uFE0F\u20E3|[0-9|#]\u20E3|[\u203C-\u3299]\uFE0F\u200D|[\u203C-\u3299]\uFE0F|[\u2122-\u2B55]|\u303D|[\A9|\AE]\u3030|\uA9|\uAE|\u3030/gi.test(e)}function De(e){return e=e?g(e):"",e.replace(/\s+/g,"")!=""}function Ce(e){return e==null||e==null||e==""}function Ie(e){return/^\s*$/g.test(e.replace(/^\s+|\s+$/g,""))}function Ee(e){for(let t in e)return!1;return!0}function S(e){return!!(e!==null&&e!=="null"&&e!==void 0&&e!=="undefined"&&e)}function Ne(e){return!(e||typeof window<"u"&&window.navigator.userAgent).match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)}function $e(e){return!!(e||navigator.userAgent).match(/AppleWebKit.*Mobile.*/)}function Fe(e){const t=e||navigator.userAgent;return!!t.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)||/iphone|ipad|ipod/i.test(t)}function Pe(e){return(e||navigator.userAgent).indexOf("iPhone")>-1}function Be(e){return(e||navigator.userAgent).indexOf("iPad")>-1}function Le(e){const t=e||navigator.userAgent;return t.indexOf("Android")>-1||t.indexOf("android")>-1||t.indexOf("Adr")>-1}function Re(){}function Ue(e,t=2){var n=`/^(([1-9]{1}\\d*)|(0{1}))(\\.\\d{1,${t}})?$/`;return n.test(e)}function ke(e){return/^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(e)}function qe(e,t=6){var n=`/[0-9]{${t}}$/`;return n.test(e)}function Ze(e){return e.toString().search(/^[+-]?[0-9.]*$/)>=0}function He(e){let t=e.toString();return/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)}function Qe(e){return Math.floor(e)===e}function Ge(e){if(e=="")return!1;var t=/^[1-9]\d*$/;return t.test(e)}function ze(e){return/^[\d]{15}$/.test(e)||/^[\d]{17}([Xx\d]{1}$)$/.test(e)}function Je(e){var t=/^\d+(?=\.{0,1}\d+$|$)/;return!!t.test(e)}function We(e){return/[\u4e00-\u9fa5]+$/.test(e)}function Ye(e){return/^[a-zA-Z\u4e00-\u9fa5]+([\u00b7\.\- ]?[a-zA-Z\u4e00-\u9fa5]+)*$/.test(e)}function Ke(e){return/^[a-z0-9A-Z\u4e00-\u9fa5]+$/.test(e)}function Xe(e){return/^[0-9a-zA-Z\u4e00-\u9fa5_-]+$/.test(e)}function Ve(e){return/^[\u4e00-\u9fa5]+[\u00b7\.]?[\u4e00-\u9fa5]+$/.test(e)}function xe(e){return/^[0-9A-Za-z]+$/.test(e)}function et(e,t){return e.charCodeAt(t)>255||e.charCodeAt(t)<0}function tt(e){return/^[a-z]+$/.test(e)}function nt(e){return/^[A-Z]+$/.test(e)}function rt(e){return Object.prototype.toString.call(e)==="[object Array]"}function it(e){return Object.prototype.toString.call(e)==="[object Boolean]"}function at(e){return Object.prototype.toString.call(e)==="[object Date]"}function ot(e){return!/Invalid|NaN/.test(new Date(e).toString())}function ut(e){return/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(e)}function st(e){return Object.prototype.toString.call(e)==="[object Function]"}function ct(e){return Object.prototype.toString.call(e)==="[object Null]"}function lt(e){return Object.prototype.toString.call(e)==="[object Number]"}function ft(e){return Object.prototype.toString.call(e)==="[object Object]"}function dt(e){return Object.prototype.toString.call(e)==="[object String]"}function ht(e){return Object.prototype.toString.call(e)==="[object Symbol]"}function gt(e){return Object.prototype.toString.call(e)==="[object Set]"}function bt(e){return Object.prototype.toString.call(e)==="[object Error]"}function yt(e){return Object.prototype.toString.call(e)==="[object Promise]"}function mt(e){return Object.prototype.toString.call(e)==="[object Undefined]"}function pt(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function St(e){try{JSON.parse(e)}catch{return!1}return!0}function At(e){return typeof e=="object"&&Object.prototype.toString.call(e).toLowerCase()=="[object object]"&&typeof e.length>"u"}const wt=function(e){return{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:"台湾",81:"香港",82:"澳门",91:"国外"}[parseInt(e.substr(0,2))]},Mt=function(e){return/^\d{6}(18|19|20)?\d{2}(0[1-9]|1[012])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i.test(e)};function jt(e){let t=e.split("");const n=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2,1],r=[1,0,10,9,8,7,6,5,4,3,2];let i=0;t[17].toLowerCase()=="x"&&(t[17]=10);for(let u=0;u<17;u++)i+=t[u]*n[u];let o=i%11;return t[17]==r[o]}function Tt(e){let t=e.substring(6,10),n=e.substring(10,12),r=e.substring(12,14),i=new Date(t,parseFloat(n)-1,parseFloat(r));return!(i.getFullYear()!=parseFloat(t)||i.getMonth()!=parseFloat(n)-1||i.getDate()!=parseFloat(r))}function Ot(e){if(!e)return!1;e=(e+"").replace(/(^\s*)|(\s*$)/g,"");let t=e.match(/[^\x00-\xff]/g);return e.length+(t?t.length:0)!=18?!1:!!(Mt(e)&&wt(e)&&Tt(e)&&jt(e))}function _t(e=""){return e?e.replace(/(^\s*)|(\s*$)/g,""):""}function vt(e){return e?e.replace(/\s|\xA0/g,""):""}function Dt(e){return typeof e=="number"||typeof e=="string"?(e+"").length:0}function Ct(e,t,n){var r=strLen(e);return!(r<t||r>n)}function It(e){return e?e.replace(/↵/g,"<br/>"):""}function A(e,t,n=!1){return e+="",t+="",n!==!0&&(e=e.toLowerCase(),t=t.toLowerCase()),e.indexOf(t)!==-1}function B(e,t,n=!1){return e+="",t+="",n!==!0&&(e=e.toLowerCase(),t=t.toLowerCase()),e.substring(0,t.length)===t}function Et(e,t,n=!1){return e+="",t+="",B(e,t,n)&&(e=e.substring(t.length)),e||""}function w(e,t,n=!1){return e+="",t+="",n!==!0&&(e=e.toLowerCase(),t=t.toLowerCase()),e.substring(e.length-t.length)===t}function L(e,t,n=!1){return e+="",t+="",w(e,t,n)&&(e=e.substring(0,e.length-t.length)),e||""}function Nt(e,t){var n=e.length-t.length,r=e.substr(n,t.length);return r==t}function $t(e,t,n){return e?e.replace(new RegExp(t,"g"),n):""}function Ft(t){var t=t.toString();return t.indexOf(".")!=-1?t.replace(/(\d)(?=(\d{3})+\.)/g,function(n,r){return r+","}):t.replace(/(\d)(?=(\d{3}))/g,function(n,r){return r+","})}function Pt(e){return e?e.replace(/(\s)/g,"").replace(/(\d{4})/g,"$1 ").replace(/\s*$/,""):""}function Bt(e){return e?e.replace(/\s/g,"").replace(/(\d{4})\d+(\d{4})$/,"**** **** **** $2"):""}function Lt(e){return e?e.replace(/^(\d{3})\d{4}(\d+)/,"$1****$2"):""}function Rt(e){for(var t=new Array,n=0;n<e.length;n++);return e.charsArray=t,t}function Ut(e=""){return e.replace(/[\u4E00-\u9FA5]/g,"")}function kt(e,t,n){return e+="",S(n)||(n=e.length),e.substring(t,n)}function R(e,t=null,n=null){return e=e.toString(),S(t)&&A(e,t)&&(e=e.substring(e.indexOf(t)+t.length)),S(n)&&A(e,n)&&(e=e.substring(0,e.indexOf(n))),e}function qt(e=0){if(e=parseFloat(e),!isNaN(e)){e=Math.round(e*100);var t=e%100==0,n=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖"],r=["分","角","元","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟"],i="",o,u,l,f=0;if(e==0)return"零元整";e<0&&(i+="负",e=-e),e=e.toString(),l=e.length;for(var c=0;c<l;c++)o=parseInt(e.charAt(c)),u=l-1-c,o==0?u==2||u==6||u==11?(i+=r[u],f=0):f++:(f>0&&(i+="零",f=0),i=i+n[o]+r[u]);return t&&(i+="整"),i}}function Zt(e=0){for(var t=new Array("零","一","二","三","四","五","六","七","八","九","十"),n=new Array("","十","百","仟","萬","億","点",""),r=(""+e).replace(/(^0*)/g,"").split("."),i=0,o="",u=r[0].length-1;u>=0;u--){switch(i){case 0:o=n[7]+o;break;case 4:new RegExp("0{4}//d{"+(r[0].length-u-1)+"}$").test(r[0])||(o=n[4]+o);break;case 8:o=n[5]+o,n[7]=n[5],i=0;break}i%4==2&&r[0].charAt(u+2)!=0&&r[0].charAt(u+1)==0&&(o=t[0]+o),r[0].charAt(u)!=0&&(o=t[r[0].charAt(u)]+n[i%4]+o),i++}if(r.length>1){o+=n[6];for(var u=0;u<r[1].length;u++)o+=t[r[1].charAt(u)]}return o=="一十"&&(o="十"),o.match(/^一/)&&o.length==3&&(o=o.replace("一","")),o}function Ht(e){return e==null?null:(typeof e=="number"&&(e=e.toString()),e.replace(/\B(?=(?:\d{3})+\b)/g,","))}function Qt(e){return parseFloat(e).toFixed(2).toString().split("").reverse().join("").replace(/(\d{3})/g,"$1,").replace(/\,$/,"").split("").reverse().join("")}function U(e,t=null){let n=Number(e);if(n+""=="NaN"&&(n=0),t&&/^[0-9]*[1-9][0-9]*$/.test(t)&&(n=n.toFixed(t),n.indexOf(".")<0)){n+=".";for(let i=0;i<t;i++)n+="0"}return n}function Gt(e,t){let n,r=null;return t=t||500,function(){let i=this,o=arguments,u=+new Date;n&&u-n<t?(clearTimeout(r),r=setTimeout(()=>{n=u,e.apply(i,o)},t)):(n=u,e.apply(i,o))}}function zt(e,t){var n=null;return t=t||500,function(){let r=arguments,i=this;n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,e.apply(i,r)},t)}}function k(e){var t=parseFloat(e[3]||1),n=Math.floor(t*parseInt(e[0])+(1-t)*255),r=Math.floor(t*parseInt(e[1])+(1-t)*255),i=Math.floor(t*parseInt(e[2])+(1-t)*255);return"#"+("0"+n.toString(16)).slice(-2)+("0"+r.toString(16)).slice(-2)+("0"+i.toString(16)).slice(-2)}function Jt(){let e=Math.floor(Math.random()*256),t=Math.floor(Math.random()*256),n=Math.floor(Math.random()*256);return`rgb(${e},${t},${n})`}function Wt(e,t,n){for(var r=1,i=1,o=1,u=e,l=0;l<n;l++)for(var f=0;f<t;f++)l==0?(r+=u[t*l+f],i+=u[t*l+f+1],o+=u[t*l+f+2]):(r+=u[(t*l+f)*4],i+=u[(t*l+f)*4+1],o+=u[(t*l+f)*4+2]);r/=t*n,i/=t*n,o/=t*n,r=Math.round(r),i=Math.round(i),o=Math.round(o);let c=[Math.round(r),Math.round(i),Math.round(o)];return k(c)}function q(e){var t,n;return e.indexOf("?")>-1?(t=e.split("?"),e=t[0]):e.indexOf("#")>-1&&(t=e.split("#"),e=t[0]),t=e.split("/"),e=t[t.length-1],t=e.lastIndexOf("."),n=t>-1?e.substr(t+1).toLowerCase():"",n}function Yt(e){var t=e==""?"":q(e);return t=="jpg"||t=="jpeg"||t=="png"||t=="gif"||t=="bmp"?1:0}function Kt(e,t,n="image/png"){return new Promise((r,i)=>{let o=new Image;o.src=e,o.onload=function(){let u=this,l=u.width,f=u.height,c=l/f;f>=t.height&&(f=t.height),l=f*c;let h=1,d=document.createElement("canvas"),M=d.getContext("2d"),p=document.createAttribute("width");p.nodeValue=l;let Y=document.createAttribute("height");Y.nodeValue=f,d.setAttributeNode(p),d.setAttributeNode(Y),M.drawImage(u,0,0,l,f),t.quality&&t.quality<=1&&t.quality>0&&(h=t.quality);let En=d.toDataURL(n,h);r(En)},o.onerror=()=>{i()}})}function Xt(e){if(e===0)return"0 B";let t=1024,n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=Math.floor(Math.log(e)/Math.log(t));return typeof n[r]>"u"?"0 B":U(e/Math.pow(t,r),2)+" "+n[r]}function Z(e){for(var t=e.split(","),n=t[0].match(/:(.*?);/)[1],r=atob(t[1]),i=r.length,o=new Uint8Array(i);i--;)o[i]=r.charCodeAt(i);return new Blob([o],{type:n})}function H(e,t){var n=new FileReader;n.onload=function(r){t(r.target.result)},n.readAsDataURL(e)}function Vt({b64data:e="",contentType:t="",sliceSize:n=512}={}){return new Promise((r,i)=>{let o=atob(e),u=[];for(let f=0;f<o.length;f+=n){let c=o.slice(f,f+n),h=[];for(let d=0;d<c.length;d++)h.push(c.charCodeAt(d));u.push(new Uint8Array(h))}let l=new Blob(u,{type:t});l=Object.assign(l,{preview:URL.createObjectURL(l),name:"图片示例.png"}),r(l)})}function xt(e){var t=Z(e),n="";return H(t,function(r){n=r}),n}function en(e,t,n,r,i=""){if(e==""||t=="")return"未知";var o=e*Math.PI/180,u=n*Math.PI/180,l=o-u,f=t*Math.PI/180-r*Math.PI/180,c=2*Math.asin(Math.sqrt(Math.pow(Math.sin(l/2),2)+Math.cos(o)*Math.cos(u)*Math.pow(Math.sin(f/2),2)));switch(c=c*6378.137,c=c.toFixed(2),i.toLowerCase()){case"km":c=c+"km";break;case"m":c=c*1e3,c=c<100?"<100m":c+"m";break;default:c>1?c=c+"km":(c=c*1e3,c=c<100?"<100m":c+"m")}return c}function tn(e,t,n){e=e||0,t=t||0;var r,i,o,u;try{r=e.toString().split(".")[1].length}catch{r=0}try{i=t.toString().split(".")[1].length}catch{i=0}if(u=Math.abs(r-i),o=Math.pow(10,Math.max(r,i)),u>0){var l=Math.pow(10,u);r>i?(e=Number(e.toString().replace(".","")),t=Number(t.toString().replace(".",""))*l):(e=Number(e.toString().replace(".",""))*l,t=Number(t.toString().replace(".","")))}else e=Number(e.toString().replace(".","")),t=Number(t.toString().replace(".",""));return n||n===0?((e+t)/o).toFixed(n):(e+t)/o}function nn(e,t,n){e=e||0,t=t||0;var r,i,o,u;try{r=e.toString().split(".")[1].length}catch{r=0}try{i=t.toString().split(".")[1].length}catch{i=0}return o=Math.pow(10,Math.max(r,i)),u=r>=i?r:i,n||n===0?((e*o-t*o)/o).toFixed(n):((e*o-t*o)/o).toFixed(u)}function rn(e,t,n){e=e||0,t=t||0;var r=0,i=e.toString(),o=t.toString();try{r+=i.split(".")[1].length}catch{}try{r+=o.split(".")[1].length}catch{}return n||n===0?(Number(i.replace(".",""))*Number(o.replace(".",""))/Math.pow(10,r)).toFixed(n):Number(i.replace(".",""))*Number(o.replace(".",""))/Math.pow(10,r)}function an(e,t,n){var r=0,i=0,o,u;try{r=e.toString().split(".")[1].length}catch{}try{i=t.toString().split(".")[1].length}catch{}return o=Number(e.toString().replace(".","")),u=Number(t.toString().replace(".","")),n||n===0?(o/u*Math.pow(10,i-r)).toFixed(n):o/u*Math.pow(10,i-r)}function on(e,t){return t=t?parseInt(t):0,t<=0?Math.round(e):(e=Math.round(e*Math.pow(10,t))/Math.pow(10,t),e=Number(e).toFixed(t),e)}function un(e,t=[]){return Object.keys(e).sort().reduce(function(n,r){return t.includes(r)||(n[r]=e[r]),n},{})}function Q(e,t){let n=e instanceof Object,r=t instanceof Object;if(!n||!r)return e===t;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let i in e)if(e.hasOwnProperty(i)){let o=e[i]instanceof Object,u=t[i]instanceof Object;if(o&&u){if(!Q(e[i],t[i]))return!1}else if(e[i]!=t[i])return!1}return!0}function sn(e,t){return t?t in e:Object.keys(e).length>0}function cn(){let e=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){let r=(e+Math.random()*16)%16|0;return e=Math.floor(e/16),(n=="x"?r:r&3|8).toString(16)})}function ln(e){e=e||32;let t="ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678oOLl9gqVvUuI1",n=t.length,r="";for(let i=0;i<e;i++)r+=t.charAt(Math.floor(Math.random()*n));return r}function fn(e,t,n){let r="",i=t,o=[];e&&(i=Math.round(Math.random()*(n-t))+t);let u="";n=n||"",n==""&&(u=new Date().getTime());let l="";for(let f=0;f<i;f++)l=Math.round(Math.random()*(o.length-1)),r+=o[l];return r+u}function dn(e,t){let n=t-e,r=Math.random();return e+Math.round(r*n)}function hn(e){let t=/http(s)?:\/\/([^\/]+)/i,n=(e+"").match(t);return n!=null&&n.length>0?n[2]:""}function gn(e){let t=G();return typeof e>"u"?t:t[e]}function G(){let e=window.location.search||window.location.hash||"",t=[];A(e,"?")&&(t=R(e,"?").split("&"));let n={};for(let r=0;r<t.length;r++){let i=t[r].split("=");i.length===2&&(n[i[0]]=i[1])}return n}function j(e,t){if(t instanceof Array)return t.forEach(r=>{e=j(e,r)}),e;let n=e.split("?");if(n.length>=2){let r=encodeURIComponent(t)+"=",i=n[1].split(/[&;]/g);for(let o=i.length;o-- >0;)i[o].lastIndexOf(r,0)!==-1&&i.splice(o,1);return n[0]+(i.length>0?"?"+i.join("&"):"")}return e}function bn(e,t){if(typeof t=="object"&&Object.prototype.toString.call(t).toLowerCase()=="[object object]"&&typeof t.length>"u"){e&&(e=j(e,Object.keys(t))),e+="",e+=e.indexOf("?")===-1?"?":"";for(let n in t)t.hasOwnProperty(n)&&(e+="&"+n+"="+t[n])}return L(e.replace("?&","?"),"?")}function yn(e){var t=new RegExp("(^|&)"+e+"=([^&]*)(&|$)","i"),n=window.location.search.slice(1),r=n.match(t);if(r!=null)return decodeURIComponent(r[2]);let i=z();return i[e]?i[e]:null}function z(e){e=decodeURIComponent(e);let t={};const n=e.split("?")[1];if(!n)return{};const r=n.split("&");for(let i in r){const u=r[i].split("=");t[u[0]]=u[1]}return t}function mn(e){return e+="",e=e.replace(/%/g,"%25").replace(/\+/g,"%2B").replace(/ /g,"%20").replace(/\//g,"%2F").replace(/\?/g,"%3F").replace(/&/g,"%26").replace(/\=/g,"%3D").replace(/#/g,"%23"),e}function pn(e,t=!1,n=!0){t=t||!1;let r=t?"?":"",i=[];for(let o in e){let u=e[o],l=`${o}=${mn(u)}`;i.push(l)}return i.length?r+i.join("&"):""}function Sn(e,t){var n=t||{};for(var r in e){var i=e[r];i!==n&&(typeof i=="object"?n[r]=i.constructor===Array?[]:Object.create(i):n[r]=i)}return n}function J(e){let t;if(Object.prototype.toString.call(e)=="[object Array]"){t=[];for(let n in e)t.push(J(e[n]));return t}if(Object.prototype.toString.call(e)=="[object Object]"){t={};for(let n in e)t[n]=e[n];return t}}function An(e){if(typeof e!="object"||e===null)return e;if(typeof e.length=="number"){let[...t]=e;return t}else{let{...t}=e;return t}}function T(e){if(typeof e!="object"||e===null)return e;let t;if(Array.isArray(e)){t=[];for(let n=0;n<e.length;n++)t[n]=T(e[n])}else if(e instanceof Date)t=new Date(e.getTime());else if(e instanceof RegExp)t=new RegExp(e.source,e.flags);else{t={};for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=T(e[n]))}return t}function wn(e){var t=parseInt(e),n=0,r=0,i=0;t>60&&(n=parseInt(t/60),t=parseInt(t%60),n>60&&(r=parseInt(n/60),n=parseInt(n%60),r>24&&(i=parseInt(r/24),r=parseInt(r%24))));var o="";return t>0&&(o=""+parseInt(t)+"秒"),n>0&&(o=""+parseInt(n)+"分"+o),r>0&&(o=""+parseInt(r)+"小时"+o),i>0&&(o=""+parseInt(i)+"天"+o),o}function Mn(e,t){let n=parseInt((t-e)/1e3),r=Math.floor(n/86400/365);n=n%(86400*365);let i=Math.floor(n/86400/30);n=n%(86400*30);let o=Math.floor(n/86400);n=n%86400;let u=Math.floor(n/3600);n=n%3600;let l=Math.floor(n/60);n=n%60;let f=n,c="";return r>0&&(c=r+"年"),r<=0&&i>0&&(c=i+"月"),r<=0&&i<=0&&o>0&&(c=o+"天"),r<=0&&i<=0&&o<=0&&u>0&&(c=u+"小时"),r<=0&&i<=0&&o<=0&&u<=0&&l>0&&(c=l+"分钟"),r<=0&&i<=0&&o<=0&&u<=0&&l<=0&&f>0&&(c+=f+"秒"),c+="前",c}let b={},y={};function jn(e){return new Promise(async(t,n)=>{let r=0;for(;y[e]==="loading";)if(await new Promise(o=>setTimeout(o,1e3)),r++,r>30)return n("加载超时");if(y[e]==="loaded")return t(!1);y[e]="loading";const i=document.createElement("link");i.readyState?i.onreadystatechange=()=>{(i.readyState=="loaded"||i.readyState=="complete")&&(i.onreadystatechange=null,y[e]="loaded",t(!0))}:(i.onload=()=>{y[e]="loaded",t(!0)},i.onerror=o=>{y[e]="error",n(o)}),i.rel="stylesheet",w(e,".css")?i.href=e+"?hash="+window.systemInfo.version:i.href=e,document.getElementsByTagName("head").item(0).appendChild(i)})}function Tn(e,t){let n=document.createElement("script");n.type="text/javascript",n.readyState?n.onreadystatechange=()=>{(n.readyState==="loaded"||n.readyState==="complete")&&(n.onreadystatechange=null,t())}:n.onload=()=>{t()},n.src=e,document.body.appendChild(n)}function On(){return!0}function _n(e){return new Promise(async(t,n)=>{let r=0;for(;b[e]==="loading";)if(await new Promise(o=>setTimeout(o,1e3)),r++,r>30)return n("加载超时");if(b[e]==="loaded")return t(!1);b[e]="loading";const i=document.createElement("script");i.type="text/javascript",i.readyState?i.onreadystatechange=()=>{(i.readyState==="loaded"||i.readyState==="complete")&&(i.onreadystatechange=null,b[e]="loaded",t(!0))}:(i.onload=()=>{b[e]="loaded",t(!0)},i.onerror=o=>{b[e]="error",n(o)}),w(e,".js")?i.src=e+"?t="+new Date().getTime():i.src=e,document.body.appendChild(i)})}function vn(e,t=0){return new Promise(async(n,r)=>{e=$A.originUrl(e);let i=0;for(;__load_iframe[e]==="loading";)if(await new Promise(u=>setTimeout(u,1e3)),i++,i>30)return r("加载超时");if(__load_iframe[e]==="loaded")return n(!1);__load_iframe[e]="loading";const o=document.createElement("iframe");o.style.display="none",o.src=e,o.onload=()=>{__load_iframe[e]="loaded",n(!0),t>0&&setTimeout(()=>{document.body.removeChild(o),delete __load_iframe[e]},t)},o.onerror=u=>{__load_iframe[e]="error",r(u)},document.body.appendChild(o)})}const Dn=function(e,t){const n={"y+":e.getFullYear().toString(),"M+":(e.getMonth()+1).toString(),"d+":e.getDate().toString(),"h+":e.getHours().toString(),"m+":e.getMinutes().toString(),"s+":e.getSeconds().toString(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds(),"w+":e.getDay(),"a+":e.getDay(),W:e.getDay(),GMT:e};for(const r in n){r=="W"&&(n[r]==0&&(n[r]="日"),n[r]==1&&(n[r]="一"),n[r]==2&&(n[r]="二"),n[r]==3&&(n[r]="三"),n[r]==4&&(n[r]="四"),n[r]==5&&(n[r]="五"),n[r]==6&&(n[r]="六"));const i=new RegExp("("+r+")").exec(t);i&&(t=t.replace(i[1],i[1].length===1?n[r]:n[r].padStart(i[1].length,"0")))}return t};class W{constructor(){let t=new Date;return this.dateObj=t,this._formatType="yyyy-MM-dd hh:mm:ss",this}setYear(t=0){return t==0||t==""||this.dateObj.setFullYear(this.dateObj.getFullYear()+t),this}setMonth(t=0){return t==0||t==""||this.dateObj.setMonth(this.dateObj.getMonth()+t),this}setDay(t=0){return t==0||t==""||this.dateObj.setDate(this.dateObj.getDate()+t),this}setTime(t){return t=t||"",t!=""&&(t.toString().length==10&&(t=parseInt(t)*1e3),this.dateObj.setTime(t)),this}init(t){return Object.prototype.toString.call(t)=="[object Number]"?this.setTime(t):(Object.prototype.toString.call(t)=="[object Date]"||Object.prototype.toString.call(t)=="[object String]")&&(this.dateObj=new Date(t)),this}format(t="yyyy-MM-dd hh:mm:ss"){return t=t||"",t!=""&&(this._formatType=t),this}_valToString(){return Dn(this.dateObj,this._formatType)}_valToInt(){let t=this.dateObj.getTime();return t=parseInt(t)/1e3,t}_valToObject(){let t={year:this.dateObj.getFullYear(),month:this.dateObj.getMonth()+1,day:this.dateObj.getDate(),hour:this.dateObj.getHours(),minute:this.dateObj.getMinutes(),second:this.dateObj.getSeconds(),millisecond:this.dateObj.getMilliseconds(),quarter:Math.floor((this.dateObj.getMonth()+3)/3),week:this.dateObj.getDay(),week_cn:this.dateObj.getDay()};for(let n in t){let r=t[n];n!="y"&&(n==="a"||n=="week"?t[n]=r:n==="week_cn"?(r==0&&(t[n]="日"),r==1&&(t[n]="一"),r==2&&(t[n]="二"),r==3&&(t[n]="三"),r==4&&(t[n]="四"),r==5&&(t[n]="五"),r==6&&(t[n]="六")):t[n]=String(r<10?"0"+r:r))}return t}_valToArray(){}value(t){t=t||"string";let n;return t=="string"?n=this._valToString():t=="object"?n=this._valToObject():t=="int"&&(n=this._valToInt()),n}}function Cn(){return new W}function In(e){let t=0;const n=r=>{t=r,e.innerHTML=`count is ${t}`};e.addEventListener("click",()=>n(++t)),n(0)}a.LibsDate=Cn,a.LibsDateClass=W,a.amountRmoney=Qt,a.amountSplit3=Ht,a.amountToChinese=qt,a.amountToChinese2=Zt,a.arrayConcat=m,a.arrayExtend=X,a.arrayFilterColumns=ie,a.arrayInArray=ne,a.arrayInText=te,a.arrayInValue=re,a.arrayLast=V,a.arrayLength=oe,a.arrayLetterSort=x,a.arrayMixin=K,a.arrayParseType=ee,a.arrayToTree=O,a.arrayUnique=ae,a.array_contains=ue,a.array_unique=se,a.base64_to_blob=Vt,a.base64_to_blobURL=xt,a.baseDebounce=zt,a.baseThrottle=Gt,a.blob_to_dataURL=H,a.cloneData=An,a.cloneDeep=T,a.colorRandomRgba=Jt,a.colorRgbaToHexify=k,a.colorToImgRbg=Wt,a.dataURL_to_blob=Z,a.fileBytesToSize=Xt,a.fileCheckImg=Yt,a.fileGetExt=q,a.fileImgCompress=Kt,a.geoCalcDistance=en,a.hasDevice_internet=Re,a.isBank=ye,a.isBrowserType=le,a.isBrowser_chrome=E,a.isBrowser_edge=I,a.isBrowser_firefox=$,a.isBrowser_ie=fe,a.isBrowser_ie11=de,a.isBrowser_opera=N,a.isBrowser_qq=ge,a.isBrowser_safari=F,a.isBrowser_webkit=he,a.isBrowser_weibo=be,a.isBrowser_weixin=P,a.isCarNo=pe,a.isDateISO=ut,a.isDateformat=ot,a.isDecimal=Ue,a.isDecimal10=ke,a.isDevice_android=Le,a.isDevice_desktop=Ne,a.isDevice_ios=Fe,a.isDevice_ipad=Be,a.isDevice_iphone=Pe,a.isDevice_mobile=$e,a.isEmail=Se,a.isEmoji=ve,a.isEmpty=Ce,a.isEmptyObject=Ee,a.isEmptyTrim=Ie,a.isHave=S,a.isHtml=Me,a.isIdCard=Ot,a.isIpv4=je,a.isLandline=Te,a.isMobile=Ae,a.isNumCode=qe,a.isNumInt=Qe,a.isNumNumber=Ze,a.isNumNumber10=He,a.isNumPosi=Ge,a.isNumPosiID=ze,a.isNumZS=Je,a.isPostal=me,a.isRequire=De,a.isStrCHS=et,a.isStrEN=Ve,a.isStrEnNum=xe,a.isStrLower=tt,a.isStrUpper=nt,a.isStrZENUM=Xe,a.isStrZh=We,a.isStrZhEn=Ye,a.isStrZhEnNum=Ke,a.isTxQQ=we,a.isTypeArray=rt,a.isTypeBoolean=it,a.isTypeDate=at,a.isTypeError=bt,a.isTypeFunction=st,a.isTypeJson=At,a.isTypeJsonString=St,a.isTypeNull=ct,a.isTypeNumber=lt,a.isTypeObj=ft,a.isTypePromise=yt,a.isTypeRegExp=pt,a.isTypeSet=gt,a.isTypeString=dt,a.isTypeSymbol=ht,a.isTypeUndefined=mt,a.isUrl=_e,a.isUrlHttp=Oe,a.loadCssPromise=jn,a.loadIframePromise=vn,a.loadScript=Tn,a.loadScriptPromise=_n,a.loadScriptSync=On,a.numberAccAdd=tn,a.numberAccDiv=an,a.numberAccMul=rn,a.numberAccSub=nn,a.numberRound=on,a.objDeepClone=Sn,a.objDeepCopy=J,a.objectEquals=Q,a.objectHasKey=sn,a.objectSort=un,a.parseNumber=U,a.randomNum=dn,a.randomString=ln,a.randomUUID=cn,a.randomWord=fn,a.secondsFormat=wn,a.setupCounter=In,a.strExists=A,a.strFeed=It,a.strFilterCN=Ut,a.strFormatMoney=Ft,a.strFourSeparate=Pt,a.strGetMiddle=R,a.strHideBankNo=Bt,a.strHideMobile=Lt,a.strLeftDelete=Et,a.strLeftExists=B,a.strLenLimit=Ct,a.strLength=Dt,a.strReplace=$t,a.strRightDelete=L,a.strRightExists=w,a.strSplitChars=Rt,a.strSubString=kt,a.strTrimAll=vt,a.strTrimSide=_t,a.str_ends_with=Nt,a.timeInterval=Mn,a.treeCalcLevel=ce,a.treeDeepInclude=D,a.treeRegDeepParents=C,a.treeToSubFlatten=_,a.treeToSupFlatten=v,a.uriGetParam=yn,a.urlAddParams=bn,a.urlGetDomain=hn,a.urlGetParameterAll=G,a.urlObjToQuery=pn,a.urlParameter=gn,a.urlQueryToObj=z,a.urlRemoveParameter=j,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});