mazey 4.7.2 → 4.7.4
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.
- package/README.md +84 -82
- package/lib/browser.d.ts +2 -2
- package/lib/calc.d.ts +9 -4
- package/lib/calc.d.ts.map +1 -1
- package/lib/debug.d.ts +9 -9
- package/lib/index.cjs.js +2 -2
- package/lib/index.esm.js +2 -2
- package/lib/load.d.ts +10 -10
- package/lib/load.d.ts.map +1 -1
- package/lib/mazey.min.js +2 -2
- package/lib/perf.d.ts +5 -5
- package/lib/store.d.ts +25 -25
- package/lib/typing.d.ts +3 -1
- package/lib/url.d.ts +38 -38
- package/lib/util.d.ts +97 -51
- package/lib/util.d.ts.map +1 -1
- package/package.json +1 -1
- package/scripts/README.md +1 -1
- package/scripts/dev.js +0 -16
- package/scripts/git-helper.js +4 -4
package/lib/mazey.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Mazey v4.7.
|
|
2
|
+
* Mazey v4.7.4 https://github.com/mazeyqian/mazey
|
|
3
3
|
* (c) 2018-2024 Cheng
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
var mazey=function(e){"use strict";var n=function(){return n=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},n.apply(this,arguments)};function t(e,n,t,r){return new(t||(t=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}u((r=r.apply(e,n||[])).next())}))}function r(e,n){var t,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(t=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=n.call(e,a)}catch(e){c=[6,e],r=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}function o(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}function i(e){if("object"!=typeof e)return e;var t=["string","number","boolean","undefined"];return Object.values(e).every((function(e){return t.includes(typeof e)}))?n({},e):JSON.parse(JSON.stringify(e))}function a(e){var n=e.replace(/([A-Z])/g,"-$1").toLowerCase();return"-"===n[0]?n.substring(1):n}function c(e){var n=e.replace(/([A-Z])/g,"_$1").toLowerCase();return"_"===n[0]?n.substring(1):n}function u(e){return c(e)}function s(e){try{if("object"==typeof JSON.parse(e))return!0}catch(e){}return!1}function d(e){void 0===e&&(e=5);for(var n="";e--;)n+=Math.floor(10*Math.random());return n}function f(e){return void 0===e&&(e=5),d(e)}function l(e){void 0===e&&(e=3);var n=[g(),f(e||3)];return n[0]+n[1]}function g(){return Date.now?Date.now():(new Date).getTime()}"function"==typeof SuppressedError&&SuppressedError;var p={type:"d"};function v(e,n){void 0===n&&(n={});var t=n.isNaNAsNumber,r=void 0!==t&&t,o=n.isInfinityAsNumber,i=void 0!==o&&o,a=n.isUnFiniteAsNumber;return"number"==typeof e&&(!(!0!==i&&!0!==(void 0!==a&&a)&&!isFinite(e))&&!(!r&&isNaN(e)))}function m(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var r=null;return e&&"function"==typeof e&&(r=e.apply(void 0,n)),r}function h(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return m.apply(void 0,o([e],n,!1))}function w(e){var n=!1;return Array.isArray(e)&&e.length&&(n=!0),n}function y(e){var n=Boolean(e),t="object"==typeof e,r="[object Object]"===Object.prototype.toString.call(e);return n&&t&&r}function b(e){if(!e)return"";var n=new RegExp("\\n","g");return e.replace(n,"<br />")}function S(e,n){void 0===n&&(n={});var t=n.removeNewLine,r=void 0!==t&&t,o="";return e&&(o=e.replace(/<\/?.+?>/g,""),r&&(o=o.replace(/[\r\n]/g,""))),o}function E(e){var n={"&":"&","<":"<",">":">",""":'"',"'":"'","/":"/"};if("string"!=typeof e)throw new Error("Input must be a string");return e.replace(/(&|<|>|"|'|/)/g,(function(e){return n[e]}))}function T(e,n,t){if(void 0===t&&(t={hasDot:!1,dotText:"..."}),t=Object.assign({hasDot:!1,dotText:"..."},t),""!=e&&e){for(var r=0,o="",i=/[^\x00-\xff]/g,a="",c=e.replace(i,"**").length,u=0;u<c&&(null!=(a=e.charAt(u).toString()).match(i)?r+=2:r++,!(r>n));u++)o+=a;return t.hasDot&&c>n&&(o+=t.dotText),o}return""}function A(e,n,t){return void 0===t&&(t=!1),T(e,n,{hasDot:t})}function x(e){return t(this,void 0,void 0,(function(){return r(this,(function(n){return[2,new Promise((function(n){setTimeout((function(){n(e)}),e)}))]}))}))}function C(e,n){for(var t=e.length,r=n.length,o=i(new Array(t).fill(new Array(r).fill(0))),a=0;a<t;++a)for(var c=0;c<r;++c)if(e[a]===n[c]){var u=0;a>0&&c>0&&(u=o[a-1][c-1]),o[a][c]=u+1}var s=Array.prototype.concat.apply([],o);return Math.max.apply(Math,s)}function O(e,n){for(var t=e.length,r=n.length,o=i(new Array(t).fill(new Array(r).fill(0))),a=0;a<t;++a)for(var c=0;c<r;++c)if(e[a]===n[c]){var u=0;a>0&&c>0&&(u=o[a-1][c-1]),o[a][c]=u+1}else{var s=[0,0],d=s[0],f=s[1];c>0&&(d=o[a][c-1]),a>0&&(f=o[a-1][c]),o[a][c]=Math.max(d,f)}var l=Array.prototype.concat.apply([],o);return Math.max.apply(Math,l)}function P(e){return Math.random()<e}function M(e,n){void 0===n&&(n={strict:!0});var t=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9\u4E00-\u9FA5()!@:%_+.~#?&//=]*)/;return n.strict||(t=/^(https?:)?\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9\u4E00-\u9FA5()!@:%_+.~#?&//=]*)/),t.test(e)}function k(e){return e.replace(/^http:/,"https:")}function N(e){void 0===e&&(e="");var n=window.URL;if(!n)return!1;if(!n.canParse)return!1;if("function"!=typeof n.canParse)return!1;try{var t=new n("b","http://a");return t.pathname="c d","http://a/c%20d"===t.href&&Boolean(t.searchParams)&&n.canParse(e)}catch(e){return!1}}function _(e,n){void 0===e&&(e=""),void 0===n&&(n={isClosed:!1,showWrap:!1,showDate:!1,locales:"en-US",logFn:function(){},errorFn:function(){}});var t=Object.assign({isClosed:!1,showWrap:!1,showDate:!1,locales:"en-US",logFn:function(){},errorFn:function(){}},n),r=t.isClosed,i=t.showWrap,a=t.showDate,c=t.locales,u=t.logFn,s=t.errorFn,d=Object.create(null),f=function(){return(new Date).toLocaleDateString(c,{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})};return["log","info","warn","error"].forEach((function(n){d[n]=function(){for(var t=[],c=0;c<arguments.length;c++)t[c]=arguments[c];if(r)return!1;var d=e,l=e;if("string"==typeof e&&e.length>=2){var g=e.length;d=":"===e[g-1]?e.substring(0,g-1):e}i&&console.log("--- ".concat(d," - begin ---")),a&&(l=e?"".concat(f()," ").concat(e):"".concat(f())),e||a?console[n].apply(console,o([l],t,!1)):console[n].apply(console,t),"log"===n&&u(),"error"===n&&s(),i&&console.log("--- ".concat(d," - end ---"))}})),d}var R=_("[Mazey]");function j(e,n){if(e)if(Array.isArray(n))n.forEach((function(n){e.classList.add(n)}));else{for(var t=e.className,r=t.split(/\s+/),o=0;o<r.length;o++)if(r[o]===n)return;var i,a="";""!==t&&(a=" "),i=t+a+n,e.className=i}else R.error("The element is not exist.")}function L(){var e,n=window.jQuery||window.$;return n?!(!(e=n("img"))||!e.length)&&(e.each((function(){var e=n(this);if(e){var t=e.attr("src");if(t&&"string"==typeof t&&t.length){var r=t.match(/width=([0-9]+[a-z%]*)/),o=t.match(/height=([0-9]+[a-z%]*)/);r&&w(r)&&r[1]&&e.width(r[1]),o&&w(o)&&o[1]&&e.height(o[1])}}})),!0):(e=document.getElementsByTagName("img")).length>0&&(Array.from(e).forEach((function(e){var n=e;if(n){var t=n.getAttribute("src");if(t&&"string"==typeof t&&t.length){var r=t.match(/width=([0-9]+[a-z%]*)/),o=t.match(/height=([0-9]+[a-z%]*)/);r&&w(r)&&r[1]&&(n.style.width=r[1]),o&&w(o)&&o[1]&&(n.style.height=o[1])}}})),!0)}function B(){var e=window.MAZEY_DEFINE_LISTENERS;return"object"!=typeof e&&(e={},window.MAZEY_DEFINE_LISTENERS=e),e}function F(e,t){void 0===t&&(t={});var r=B()[e];if(r instanceof Array)for(var o=0,i=r.length;o<i;o++)"function"==typeof r[o]&&r[o](n(n({},t),{type:e}))}function I(e){for(var n=e+"=",t=document.cookie.split(";"),r=0;r<t.length;r++){for(var o=t[r];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(n))return o.substring(n.length,o.length)}return""}function U(e){for(var n=document.cookie.split(";"),t=0;t<n.length;t++){var r=n[t].trim();if(r.startsWith("".concat(e,"="))){var o=r.split("=")[0],i=new Date;return i.setTime(i.getTime()-1),document.cookie="".concat(o,"=;expires=").concat(i.toUTCString()),!0}}return!1}function D(e,n){void 0===n&&(n={id:"",callback:function(){},timeout:5e3,isDefer:!1});var t,r,o=Object.assign({id:"",callback:function(){},timeout:5e3,isDefer:!1},n),i=o.id,a=o.callback,c=o.timeout,u=o.isDefer,s=document.createElement("script");s||Promise.reject("Not support create script element");var d=document.getElementsByTagName("script")[0];return s.type="text/javascript",u&&(s.defer=!0),i&&(s.id=i),s.readyState?s.onreadystatechange=function(){"loaded"!==s.readyState&&"complete"!==s.readyState||(s.onreadystatechange=null,h(a),h(t,"loaded"))}:s.onload=function(){h(a),h(t,"loaded")},s.src=e,d&&d.parentNode.insertBefore(s,d),new Promise((function(e,n){var o;t=(o=[e,n])[0],r=o[1],c&&setTimeout(r.bind(null,"timeout"),c)}))}function z(e){var n=[],t=window.PerformanceObserver;return!!t&&(w(t.supportedEntryTypes)&&(n=t.supportedEntryTypes),n.includes(e))}function q(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return z("paint")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"first-contentful-paint"===e.name}));r&&(n.disconnect(),e(Math.round(r.startTime)))}));n.observe({type:"paint",buffered:!0})}))]:[2,0]}))}))}function H(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return z("paint")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"first-paint"===e.name}));r&&(n.disconnect(),e(Math.round(r.startTime)))}));n.observe({type:"paint",buffered:!0})}))]:[2,0]}))}))}var Z="";function V(){if(window.MAZEY_BROWSER_INFO&&"object"==typeof window.MAZEY_BROWSER_INFO)return window.MAZEY_BROWSER_INFO;var e={engine:"",engineVs:"",platform:"",supporter:"",supporterVs:"",system:"",systemVs:"",shell:"",shellVs:"",appleType:""};try{var t=navigator.userAgent.toLowerCase();if(!t)return e;var r=function(e){return e.test(t)},o=function(e){var n="",r=t.match(e);return r&&w(r)&&(n=(n=(n=r.toString()).replace(/[^0-9|_.]/g,"")).replace(/_/g,".")),n},i="",a="";r(/windows|win32|win64|wow32|wow64/g)?i="windows":r(/macintosh|macintel/g)?i="macos":r(/x11/g)?i="linux":r(/android|adr/g)?i="android":r(/ios|iphone|ipad|ipod|iwatch/g)&&(i="ios",r(/ipad/g)?a="ipad":r(/iphone/g)?a="iphone":r(/iwatch/g)?a="iwatch":r(/ipod/g)&&(a="ipod")),e=n(n({},e),{system:i,appleType:a});var c="";"windows"===i?r(/windows nt 5.0|windows 2000/g)?c="2000":r(/windows nt 5.1|windows xp/g)?c="xp":r(/windows nt 5.2|windows 2003/g)?c="2003":r(/windows nt 6.0|windows vista/g)?c="vista":r(/windows nt 6.1|windows 7/g)?c="7":r(/windows nt 6.2|windows 8/g)?c="8":r(/windows nt 6.3|windows 8.1/g)?c="8.1":r(/windows nt 10.0|windows 10/g)&&(c="10"):"macos"===i?c=o(/os x [\d._]+/g):"android"===i?c=o(/android [\d._]+/g):"ios"===i&&(c=o(/os [\d._]+/g)),e=n(n({},e),{systemVs:c});var u="";"windows"===i||"macos"===i||"linux"===i?u="desktop":("android"===i||"ios"===i||r(/mobile/g))&&(u="mobile"),e=n(n({},e),{platform:u});var s="",d="";r(/applewebkit/g)?(s="webkit",r(/edge/g)?d="edge":r(/opr/g)?d="opera":r(/chrome/g)?d="chrome":r(/safari/g)&&(d="safari")):r(/gecko/g)&&r(/firefox/g)?(s="gecko",d="firefox"):r(/presto/g)?(s="presto",d="opera"):r(/trident|compatible|msie/g)&&(s="trident",d="iexplore"),e=n(n({},e),{engine:s,supporter:d});var f="";"webkit"===s?f=o(/applewebkit\/[\d._]+/g):"gecko"===s?f=o(/gecko\/[\d._]+/g):"presto"===s?f=o(/presto\/[\d._]+/g):"trident"===s&&(f=o(/trident\/[\d._]+/g)),e=n(n({},e),{engineVs:f});var l="";"chrome"===d?l=o(/chrome\/[\d._]+/g):"safari"===d?l=o(/version\/[\d._]+/g):"firefox"===d?l=o(/firefox\/[\d._]+/g):"opera"===d?l=o(/opr\/[\d._]+/g):"iexplore"===d?l=o(/(msie [\d._]+)|(rv:[\d._]+)/g):"edge"===d&&(l=o(/edge\/[\d._]+/g)),e=n(n({},e),{supporterVs:l});var g="",p="";return r(/micromessenger/g)?(g="wechat",p=o(/micromessenger\/[\d._]+/g)):r(/qqbrowser/g)?(g="qq_browser",p=o(/qqbrowser\/[\d._]+/g)):r(/\sqq/g)?g="qq_app":r(/ucbrowser/g)?(g="uc",p=o(/ucbrowser\/[\d._]+/g)):r(/qihu 360se/g)?g="360":r(/2345explorer/g)?(g="2345",p=o(/2345explorer\/[\d._]+/g)):r(/metasr/g)?g="sougou":r(/lbbrowser/g)?g="liebao":r(/maxthon/g)?(g="maxthon",p=o(/maxthon\/[\d._]+/g)):r(/biliapp/g)&&(g="bilibili"),e=n(n({},e),{shell:g,shellVs:p}),window.MAZEY_BROWSER_INFO=e,e}catch(n){return R.warn(n),e}}var W="";return e.addClass=j,e.addEvent=function(e,n){var t=B();void 0===t[e]&&(t[e]=[]),"function"==typeof n&&t[e].push(n)},e.addStyle=function(e,n){if(void 0===n&&(n={id:""}),!e)return!1;var t=document.createDocumentFragment(),r=null,o="",i=document.createElement("style");return n.id?(o="".concat(n.id),(r=document.getElementById(o))?r.innerHTML=e:(i.setAttribute("id",n.id),i.innerHTML=e,t.appendChild(i),document.head.appendChild(t))):(i.innerHTML=e,t.appendChild(i),document.head.appendChild(t)),!0},e.calLongestCommonSubsequence=function(e,n){return O(e,n)},e.calLongestCommonSubstring=function(e,n){return C(e,n)},e.camelCase2Underscore=u,e.camelCaseToKebabCase=function(e){return a(e)},e.cancelBubble=function(e){var n=e||window.event;n.stopPropagation?n.stopPropagation():n.cancelBubble=!0},e.clearHTML=function(e,n){return void 0===n&&(n={}),S(e,n)},e.clearHtml=function(e,n){return void 0===n&&(n={}),S(e,n)},e.convert10To26=function(e){for(var n="";e>0;){var t=e%26;0===t&&(t=26),n=String.fromCharCode(t+96)+n,e=(e-t)/26}return n},e.convertCamelToKebab=a,e.convertCamelToUnder=c,e.convertHttpToHttps=k,e.convertKebabToCamel=function(e){var n=e.replace(/-([a-z])/g,(function(e,n){return n.toUpperCase()}));return n.endsWith("-")?n.slice(0,-1):n},e.convertObjectToQuery=function(e){if(e&&0===Object.keys(e).length)return"";var n="?";for(var t in e)n+="".concat(t,"=").concat(e[t],"&");return n.slice(0,-1)},e.convertToHtmlBreaks=b,e.cutCHSString=function(e,n,t){return void 0===t&&(t=!1),A(e,n,t)},e.cutZHString=T,e.debounce=function(e,n,t){var r=null,o=null,i=null,a=null,c=null,u=function u(){var s=g()-i;s<n&&s>=0?o=setTimeout(u,n-s):(o=null,t||(c=e.apply(r,a),o||(r=a=null)))};return function(){for(var s=[],d=0;d<arguments.length;d++)s[d]=arguments[d];r=this,a=s,i=g();var f=t&&!o;return o||(o=setTimeout(u,n)),f&&(c=e.apply(r,a),r=a=null),c}},e.deepCopy=i,e.deepCopyObject=function(e){return i(e)},e.delCookie=function(e){U(e)},e.doFn=h,e.fireEvent=F,e.floatFixed=function(e,n){return void 0===n&&(n=0),parseFloat(e).toFixed(n)},e.floatToPercent=function(e,n){void 0===n&&(n=0);var t="";return t=n?(100*e).toFixed(n):String(Math.floor(100*e)),"".concat(t,"%")},e.formatDate=function(e,n){void 0===n&&(n="yyyy-MM-dd"),e||(e=new Date);var t=new Date(e),r=t.getHours(),o={yyyy:t.getFullYear(),MM:t.getMonth()+1,dd:t.getDate()<10?"0"+t.getDate():t.getDate(),HH:r<10?"0"+r:r,hh:(r%12||12)<10?"0"+(r%12||12):r%12||12,mm:t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes(),ss:t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds(),a:r<12?"AM":"PM"},i=n||"yyyy-MM-dd";return Object.keys(o).forEach((function(e){var n=o[e];"MM"===e&&Number(n)<=9&&(n="0".concat(n)),i=i.replace(e,String(n))})),i},e.genBrowserAttrs=function(e,n){void 0===e&&(e=""),void 0===n&&(n="-");var t=V(),r=[];return["system","platform","engine","supporter","shell","appleType"].forEach((function(o){var i=t[o];if(i){var a="";e&&e.length>0&&(a="".concat(e).concat(n)),r.push("".concat(a).concat(i))}})),r},e.genCustomConsole=_,e.genHashCode=function(e){var n,t=0;for(n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t},e.genRndNumString=d,e.genStyleString=function(e,n){var t="";return n&&n.length>0&&(t=n.join(";")+";"),"".concat(e,"{").concat(t,"}")},e.genUniqueNumString=l,e.generateRndNum=f,e.generateUniqueNum=function(e){return void 0===e&&(e=3),l(e)},e.getAllQueryParams=function(e){void 0===e&&(e=""),""===e&&(e=location.search);var n={};return e.replace(/\??(\w+)=([^&]*)&?/g,(function(e,t,r){return void 0===n[t]&&(n[t]=decodeURIComponent(r)),""})),n},e.getBrowserInfo=V,e.getCLS=function(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return z("layout-shift")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().reduce((function(e,n){var t=0;return v(n.value)&&(t=n.value),e+t}),0);n.disconnect(),e(r)}));n.observe({type:"layout-shift",buffered:!0})}))]:[2,0]}))}))},e.getCookie=I,e.getCurrentVersion=function(){return"v4"},e.getDefineListeners=B,e.getDomain=function(e,n){if(void 0===n&&(n=["hostname"]),N(e)){var t=new window.URL(e);return n.reduce((function(e,n){return e+=t[n]}),"")}var r=document.createElement("a");return r.href=e,n.reduce((function(e,n){return e+=r[n]}),"")},e.getFCP=q,e.getFID=function(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return z("first-input")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"first-input"===e.entryType}));if(r){n.disconnect();var o=r.processingStart;e(o?Math.round(r.processingStart-r.startTime):0)}}));n.observe({type:"first-input",buffered:!0})}))]:[2,0]}))}))},e.getFP=H,e.getFileSize=function(e){var n=function(e){return String(Math.ceil(e))};if(!e||e<0)return"";var t=1024;return e<t?e+" B":e<Math.pow(t,2)?n(e/t)+" KB":e<Math.pow(t,3)?n(e/Math.pow(t,2))+" MB":e<Math.pow(t,4)?n(e/Math.pow(t,3))+" G":n(e/Math.pow(t,4))+" T"},e.getFriendlyInterval=function(e,n,t){void 0===e&&(e=0),void 0===n&&(n=0),void 0===t&&(t=p);var r=(t=Object.assign(p,t)).type;v(e)||(e=new Date(e).getTime()),v(n)||(n=new Date(n).getTime());var o=Number(n)-Number(e),i="",a=new Array(4).fill(0),c=a[0],u=(a[1],a[2],a[3]),s=decodeURIComponent("%20%E5%A4%A9%20"),d=decodeURIComponent("%20%E6%97%B6%20"),f=decodeURIComponent("%20%E5%88%86%20"),l=decodeURIComponent("%20%E7%A7%92");if(o>=0)switch(c=Math.floor(o/1e3/60/60/24),Math.floor(o/1e3/60/60),Math.floor(o/1e3/60),u=Math.floor(o/1e3),r){case"d":i=c;break;case"text":i=(c=Math.floor(o/1e3/60/60/24))+s+Math.floor(o/1e3/60/60%24)+d+Math.floor(o/1e3/60%60)+f+(u=Math.floor(o/1e3%60))+l;break;default:i=u}return i},e.getHashQueryParam=function(e){var n=location.hash.split("?");if(1===n.length)return"";var t=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),r=n[1].match(t);return r?r[2]:""},e.getLCP=function(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return z("largest-contentful-paint")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"largest-contentful-paint"===e.entryType}));r&&(n.disconnect(),e(Math.round(r.startTime)))}));n.observe({type:"largest-contentful-paint",buffered:!0})}))]:[2,0]}))}))},e.getLocalStorage=function(e){var n=null;if(e){var t=localStorage.getItem(e);t&&(n=JSON.parse(t))}return n},e.getPageMeta=function(e){var n;return document.querySelector&&(null===(n=document.querySelector('meta[name="'.concat(e,'"]')))||void 0===n?void 0:n.getAttribute("content"))||""},e.getPerformance=function(e){return void 0===e&&(e=!1),t(this,void 0,void 0,(function(){function n(){var n={source:I,os:t(),osVersion:o(),deviceType:i(),network:a(),screenDirection:c(),unloadTime:h-y,redirectTime:b-S,dnsTime:E-T,tcpTime:A-x,sslTime:s(A,C),responseTime:O-P,downloadTime:M-O,firstPaintTime:Z,firstContentfulPaintTime:V,domReadyTime:k-U,onloadTime:N-U,whiteTime:O-U,renderTime:_-U,decodedBodySize:L,encodedBodySize:B};Object.keys(n).forEach((function(e){v(n[e])&&(n[e]<0?n[e]=0:n[e]=Math.round(n[e]))})),v(n.whiteTime)&&n.whiteTime>n.onloadTime&&(n.whiteTime=0);var r={};e||Object.keys(n).forEach((function(e){r[u(e)]=n[e]})),Object.keys(r).length?f(r):f(n)}function t(){return navigator.userAgent.indexOf("Android")>-1||navigator.userAgent.indexOf("Linux")>-1?"android":navigator.userAgent.indexOf("iPhone")>-1?"ios":navigator.userAgent.indexOf("Windows Phone")>-1?"wp":"others"}function o(){var e="",n=navigator.userAgent,t=n.indexOf("Android")>-1||n.indexOf("Linux")>-1,r=!!n.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),o=navigator.userAgent.split(";");if(o.length<2)return e;var i=o[1];return i?(t&&(e=(i.match(/\d+\.\d+/g)||[])[0]),r&&(e=(i.match(/(\d+)_(\d+)_?(\d+)?/)||[])[0]),e||(e=""),e):e}function i(){var e,n=navigator.userAgent.toLowerCase(),t=n.match(/(ipad)/i)&&"ipad",r=n.match(/iphone os/i)&&"iphone os",o=n.match(/midp/i)&&"midp",i=n.match(/rv:1.2.3.4/i)&&"rv:1.2.3.4",a=n.match(/ucweb/i)&&"ucweb",c=n.match(/android/i)&&"android",u=n.match(/windows ce/i)&&"windows ce",s=n.match(/windows mobile/i)&&"windows mobile";return(e=t||r||o||i||a||c||u||s?r||o||i||a||c||u||s?"phone":t?"ipad":void 0:"pc")||(e=""),e}function a(){var e="",n=window.navigator;if(n.connection&&n.connection.effectiveType)switch(n.connection.effectiveType){case"wifi":e="wifi";break;case"4g":e="4g";break;case"2g":e="2g";break;case"3g":e="3g";break;case"ethernet":e="ethernet";break;case"default":e=void 0}return e||(e=""),e}function c(){var e="";return window.screen&&window.screen.orientation&&window.screen.orientation.angle&&(180!==window.screen.orientation.angle&&0!==window.screen.orientation.angle||(e="|"),90!==window.screen.orientation.angle&&-90!==window.screen.orientation.angle||(e="-")),e}function s(e,n){var t=0;return n&&(t=e-n),t}var d,f,l,g,p,m,h,y,b,S,E,T,A,x,C,O,P,M,k,N,_,R,j,L,B,F,I,U,D,Z,V;return r(this,(function(e){switch(e.label){case 0:if(!z("navigation"))return[2,Promise.reject(new Error("navigation is not supported"))];if(!(d=window.performance)||"function"!=typeof d.getEntries||"function"!=typeof d.getEntriesByType)return[2,Promise.reject(new Error("performance is not supported"))];if(l=new Promise((function(e){f=[e][0]})),g=null,w(p=d.getEntriesByType("navigation"))&&(g=p[0]),m=new Array(19).fill(0),h=m[0],y=m[1],b=m[2],S=m[3],E=m[4],T=m[5],A=m[6],x=m[7],C=m[8],O=m[9],P=m[10],M=m[11],k=m[12],N=m[13],_=m[14],R=m[15],j=m[16],L=m[17],B=m[18],F=d.timing,I="",g)I="PerformanceNavigationTiming",L=g.decodedBodySize,B=g.encodedBodySize,h=g.unloadEventEnd,y=g.unloadEventStart,b=g.redirectEnd,S=g.redirectStart,E=g.domainLookupEnd,T=g.domainLookupStart,A=g.connectEnd,x=g.connectStart,C=g.secureConnectionStart,O=g.responseStart,P=g.requestStart,M=g.responseEnd,k=g.domContentLoadedEventStart,N=g.loadEventStart,_=g.loadEventEnd,R=g.startTime,j=g.fetchStart;else{if(!F)return[2,Promise.reject(new Error("NavigationTiming and Timing are not supported"))];I="PerformanceTiming",h=F.unloadEventEnd,y=F.unloadEventStart,b=F.redirectEnd,S=F.redirectStart,E=F.domainLookupEnd,T=F.domainLookupStart,A=F.connectEnd,x=F.connectStart,C=F.secureConnectionStart,O=F.responseStart,P=F.requestStart,M=F.responseEnd,k=F.domContentLoadedEventStart,N=F.loadEventStart,_=F.loadEventEnd,R=F.navigationStart,j=F.fetchStart}if(U=0,v(R))U=R;else{if(!v(j))return[2,Promise.reject(new Error("startTime, navigationStart or fetchStart are required"))];U=j}return[4,Promise.all([H(),q()])];case 1:return D=e.sent(),Z=D[0],V=D[1],v(_)&&_>0?n():window.addEventListener("load",(function(){window.setTimeout((function(){n()}),0)})),[2,l]}}))}))},e.getQueryParam=function(e){var n=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),t=location.search.substring(1).match(n);return null!==t?decodeURIComponent(t[2]):""},e.getScriptQueryParam=function(e,n){void 0===n&&(n=""),n||(n=".js");for(var t=new RegExp("[?&]".concat(e,"=([^&]*)")),r=document.querySelectorAll('script[src*="'.concat(n,'"]')),o=0;o<r.length;o++){var i=r[o].getAttribute("src");if(i&&-1!==i.indexOf(n)){var a=i.match(t);if(a)return decodeURIComponent(a[1])}}return""},e.getSessionStorage=function(e){var n=null;if(e){var t=sessionStorage.getItem(e);t&&(n=JSON.parse(t))}return n},e.getTTFB=function(){return t(this,void 0,void 0,(function(){var e,n;return r(this,(function(t){return z("navigation")&&window.performance&&window.performance.getEntriesByType?(e=performance.getEntriesByType("navigation")[0],0,e?(n=e.responseStart-e.requestStart,[2,Math.round(n)]):[2,0]):[2,0]}))}))},e.getUrlFileType=function(e){var n="";if("string"!=typeof e||""==e)return n;var t=/\.[^/?#]+$/.exec(e);return t?(t[0].length>1&&(n=t[0].substring(1)),n):n},e.getUrlHost=function(e){var n="";return!M(e)&&M(e,{strict:!1})&&0===e.indexOf("//")&&(e="https:"+e),N(e)&&(n=new URL(e).host),n},e.getUrlParam=function(e,n,t){void 0===t&&(t={});var r=null;if(e.includes("#")){r=new URL(e).searchParams.getAll(n)}else{var o={};e.replace(/\??(\w+)=([^&]*)&?/g,(function(e,n,t){return void 0!==o[n]?o[n].push(t):o[n]=[t],""})),r=o[n]||[]}return t.returnArray?r:r.length?r[0]:null},e.getUrlPath=function(e){var n="";return!M(e)&&M(e,{strict:!1})&&0===e.indexOf("//")&&(e="https:"+e),N(e)&&(n=new URL(e).pathname),n},e.hasClass=function(e,n){if(!e)return R.error("The element is not exist."),!1;for(var t=e.className.split(/\s+/),r=0;r<t.length;r++)if(t[r]===n)return!0;return!1},e.inRate=function(e){return P(e)},e.invokeEvent=function(e){F(e)},e.invokeFn=m,e.isHit=P,e.isJSONString=s,e.isJsonString=function(e){return s(e)},e.isNonEmptyArray=w,e.isNonEmptyObject=function(e){return!!y(e)&&0!==Object.keys(e).length},e.isNumber=v,e.isPureObject=y,e.isSafePWAEnv=function(){if(Z)return"pwa"===Z;var e=V();return"serviceWorker"in navigator&&function(){var e;try{return e=new Function("return async function(){};")(),null!=Object.getPrototypeOf(e).constructor}catch(e){return!1}}()&&"undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]")&&Boolean(window.fetch)&&Boolean(window.indexedDB)&&Boolean(window.caches)&&!e.shell?(Z="pwa",!0):(Z="no-pwa",!1)},e.isSupportWebp=function(){return W?Promise.resolve("webp"===W):new Promise((function(e){var n=new Image;n.onload=function(){var t=n.width>0&&n.height>0;W=t?"webp":"no-webp",e(t)},n.onerror=function(){W="no-webp",e(!1)},n.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="}))},e.isSupportedEntryType=z,e.isValidData=function(e,n,t){var r=!1;return"object"!=typeof e||n.reduce((function(e,n){return void 0===e[n]?Object.create(null):e=e[n]}),e)===t&&(r=!0),r},e.isValidEmail=function(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},e.isValidHttpUrl=M,e.isValidPhoneNumber=function(e){return/^1\d{10}$/.test(e)},e.isValidUrl=function(e){return/^[a-zA-Z0-9]+:\/\/[-a-zA-Z0-9@:%._+~#=]{1,256}\b([-a-zA-Z0-9\u4E00-\u9FA5()!@:%_+.~#?&//=]*)$/.test(e)},e.loadCSS=function(e,n){void 0===n&&(n={id:""});var t,r=n.id,o=function(){},i=new Promise((function(e,n){var r;t=(r=[e,n])[0],o=r[1]})),a=function(){t("loaded")},c=document.createElement("link");c||o(new Error("Not support create link element"));var u="onload"in c,s=+navigator.userAgent.replace(/.*(?:AppleWebKit|AndroidWebKit)\/?(\d+).*/i,"$1")<536;if(c.rel="stylesheet",c.type="text/css",c.href=e,void 0!==r&&(c.id=r),document.getElementsByTagName("head")[0].appendChild(c),s||!u)return setTimeout((function(){f(c,a,0)}),1),i;function d(){c&&(c.onload=c.onerror=c.onreadystatechange=null),c=null,a()}function f(e,n,t){if(e){var r,o=e.sheet;if((t+=1)>3e5)return r=!0,e&&(e=null),void n();if(s)o&&(r=!0);else if(o)try{o.cssRules&&(r=!0)}catch(e){var i=e;if(!i.name)return;"NS_ERROR_DOM_SECURITY_ERR"===i.name&&(r=!0)}setTimeout((function(){r?n():f(e,n,t)}),20)}}return u?(c.onload=d,c.onerror=function(){d()}):c.onreadystatechange=function(){c&&/loaded|complete/.test(c.readyState)&&d()},i},e.loadImage=function(e){return new Promise((function(n,t){var r=new Image;r.onload=function(){n(r)},r.onerror=function(e){t(e)},r.src=e}))},e.loadScript=D,e.loadScriptIfUndefined=function(e,n){return window[e]?Promise.resolve("defined"):D(n)},e.longestComSubsequence=O,e.longestComSubstring=C,e.mNow=g,e.mTrim=function(e){for(var n=(e=e.replace(/^\s+/,"")).length-1,t=/\s/;t.test(e.charAt(n));)n--;return e.slice(0,n+1)},e.mazeyCon=R,e.newLine=function(e){return b(e)},e.removeClass=function(e,n){var t;e?(t=(t=(t=(t=" "+e.className+" ").replace(/(\s+)/gi," ")).replace(" "+n+" "," ")).replace(/(^\s+)|(\s+$)/g,""),e.className=t):R.error("The element is not exist.")},e.removeCookie=U,e.removeEvent=function(e,n){var t=B(),r=t[e];if("string"==typeof e&&r instanceof Array)if("function"==typeof n){for(var o=0,i=r.length;o<i;o++)if(r[o]===n){t[e].splice(o,1);break}}else delete t[e]},e.removeHTML=S,e.removeHtml=function(e,n){return void 0===n&&(n={}),S(e,n)},e.repeatUntilConditionMet=function(e,n,o){var i=this;void 0===n&&(n={}),void 0===o&&(o=function(e){return!0===e});var a=n.interval,c=void 0===a?1e3:a,u=n.times,s=void 0===u?10:u,d=n.context,f=n.args,l=0;"function"!=typeof e&&console.error("Expected a function."),("number"!=typeof c||c<0)&&console.error("Expected a non-negative number for interval."),("number"!=typeof s||s<0)&&console.error("Expected a non-negative number for times."),function n(){setTimeout((function(){return t(i,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,e.apply(d,f)];case 1:return t=r.sent(),o(t)||++l>=s?[2]:(n(),[2])}}))}))}),c)}()},e.replaceHttp=function(e){return k(e)},e.sanitizeInput=function(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};if("string"!=typeof e)throw new Error("Input must be a string");return e.replace(/[&<>"'/]/g,(function(e){return n[e]}))},e.setClass=function(e,n){j(e,n)},e.setCookie=function(e,n,t,r){var o,i;if(t){var a=new Date;a.setTime(a.getTime()+24*t*60*60*1e3),i="; expires="+a.toUTCString()}else i="";var c=location.host;1===c.split(".").length?document.cookie=e+"="+n+i+"; path=/":((o=c.split(".")).shift(),r=r||"."+o.join("."),document.cookie=e+"="+n+i+"; path=/; domain="+r,null!==I(e)&&I(e)===n||(r=r||"."+c,document.cookie=e+"="+n+i+"; path=/; domain="+r))},e.setImgSizeBySrc=L,e.setImgWidHeiBySrc=function(){return L()},e.setLocalStorage=function(e,n){void 0===n&&(n=null),e&&localStorage.setItem(e,JSON.stringify(n))},e.setSessionStorage=function(e,n){void 0===n&&(n=null),e&&sessionStorage.setItem(e,JSON.stringify(n))},e.sleep=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(n){return[2,x(e)]}))}))},e.throttle=function(e,n,t){void 0===t&&(t={}),t=Object.assign({},t);var r=null,o=null,i=null,a=[null,0],c=a[0],u=a[1],s=function(){u=!1===t.leading?0:g(),i=null,c=e.apply(this,o),i||(r=o=null)};return function(){for(var a=[],d=0;d<arguments.length;d++)a[d]=arguments[d];var f=g();u||!1!==t.leading||(u=f);var l=n-(f-u);return r=this,o=a,l<=0||l>n?(i&&(clearTimeout(i),i=null),u=f,c=e.apply(r,o),i||(r=o=null)):i||!1===t.trailing||(i=setTimeout(s.bind(r),l)),c}},e.truncateZHString=A,e.unsanitize=function(e){return E(e)},e.unsanitizeInput=E,e.updateQueryParam=function(e,n,t){if(e.includes("#")){var r=new URL(e);return r.searchParams.set(n,t),r.toString()}var o=new RegExp("([?&])"+n+"=.*?(&|$)","i"),i=-1!==e.indexOf("?")?"&":"?";return e.match(o)?e.replace(o,"$1"+n+"="+t+"$2"):e+i+n+"="+t},e.waitTime=x,e.windowLoaded=function(e){void 0===e&&(e=90);var n,t=function(){},r=new Promise((function(e,r){t=e,n=r}));return"complete"===document.readyState?t("complete"):window.addEventListener("load",(function(){return t("load")})),setTimeout((function(){return n(Error("timeout"))}),1e3*e),r},e.zAxiosIsValidRes=function(e,n){void 0===n&&(n={validStatusRange:[200,300],validCode:[0]});var t=Object.assign({validStatusRange:[200,300],validCode:[0]},n),r=t.validStatusRange,o=t.validCode;2!==r.length&&console.error("valid validStatusRange is required");var i=!1;if(e&&e.status&&2===r.length&&e.status>=r[0]&&e.status<r[1]){var a=e.data;a&&o.includes(a.code)&&(i=!0)}return i},e}({});
|
|
6
|
+
var mazey=function(e){"use strict";var n=function(){return n=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},n.apply(this,arguments)};function t(e,n,t,r){return new(t||(t=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function c(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t((function(e){e(n)}))).then(a,c)}u((r=r.apply(e,n||[])).next())}))}function r(e,n){var t,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(t)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(t=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=n.call(e,a)}catch(e){c=[6,e],r=0}finally{t=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,u])}}}function o(e,n,t){if(t||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return e.concat(r||Array.prototype.slice.call(n))}function i(e){if("object"!=typeof e)return e;var t=["string","number","boolean","undefined"];return Object.values(e).every((function(e){return t.includes(typeof e)}))?n({},e):JSON.parse(JSON.stringify(e))}function a(e){var n=e.replace(/([A-Z])/g,"-$1").toLowerCase();return"-"===n[0]?n.substring(1):n}function c(e){var n=e.replace(/([A-Z])/g,"_$1").toLowerCase();return"_"===n[0]?n.substring(1):n}function u(e){return c(e)}function s(e){try{if("object"==typeof JSON.parse(e))return!0}catch(e){}return!1}function d(e){void 0===e&&(e=5);for(var n="";e--;)n+=Math.floor(10*Math.random());return n}function f(e){return void 0===e&&(e=5),d(e)}function l(e){void 0===e&&(e=3);var n=[g(),f(e||3)];return n[0]+n[1]}function g(){return Date.now?Date.now():(new Date).getTime()}"function"==typeof SuppressedError&&SuppressedError;var p={type:"d"};function v(e,n){void 0===n&&(n={});var t=n.isNaNAsNumber,r=void 0!==t&&t,o=n.isInfinityAsNumber,i=void 0!==o&&o,a=n.isUnFiniteAsNumber;return"number"==typeof e&&(!(!0!==i&&!0!==(void 0!==a&&a)&&!isFinite(e))&&!(!r&&isNaN(e)))}function m(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];var r=null;return e&&"function"==typeof e&&(r=e.apply(void 0,n)),r}function h(e){for(var n=[],t=1;t<arguments.length;t++)n[t-1]=arguments[t];return m.apply(void 0,o([e],n,!1))}function w(e){var n=!1;return Array.isArray(e)&&e.length&&(n=!0),n}function y(e){var n=Boolean(e),t="object"==typeof e,r="[object Object]"===Object.prototype.toString.call(e);return n&&t&&r}function b(e){if(!e)return"";var n=new RegExp("\\n","g");return e.replace(n,"<br />")}function S(e,n){void 0===n&&(n={});var t=n.removeNewLine,r=void 0!==t&&t,o="";return e&&(o=e.replace(/<\/?.+?>/g,""),r&&(o=o.replace(/[\r\n]/g,""))),o}function E(e){var n={"&":"&","<":"<",">":">",""":'"',"'":"'","/":"/"};if("string"!=typeof e)throw new Error("Input must be a string");return e.replace(/(&|<|>|"|'|/)/g,(function(e){return n[e]}))}function T(e,n,t){if(void 0===t&&(t={hasDot:!1,dotText:"..."}),t=Object.assign({hasDot:!1,dotText:"..."},t),""!=e&&e){for(var r=0,o="",i=/[^\x00-\xff]/g,a="",c=e.replace(i,"**").length,u=0;u<c&&(null!=(a=e.charAt(u).toString()).match(i)?r+=2:r++,!(r>n));u++)o+=a;return t.hasDot&&c>n&&(o+=t.dotText),o}return""}function A(e,n,t){return void 0===t&&(t=!1),T(e,n,{hasDot:t})}function x(e){return t(this,void 0,void 0,(function(){return r(this,(function(n){return[2,new Promise((function(n){setTimeout((function(){n(e)}),e)}))]}))}))}var O="";function C(e,n){for(var t=e.length,r=n.length,o=i(new Array(t).fill(new Array(r).fill(0))),a=0;a<t;++a)for(var c=0;c<r;++c)if(e[a]===n[c]){var u=0;a>0&&c>0&&(u=o[a-1][c-1]),o[a][c]=u+1}var s=Array.prototype.concat.apply([],o);return Math.max.apply(Math,s)}function P(e,n){for(var t=e.length,r=n.length,o=i(new Array(t).fill(new Array(r).fill(0))),a=0;a<t;++a)for(var c=0;c<r;++c)if(e[a]===n[c]){var u=0;a>0&&c>0&&(u=o[a-1][c-1]),o[a][c]=u+1}else{var s=[0,0],d=s[0],f=s[1];c>0&&(d=o[a][c-1]),a>0&&(f=o[a-1][c]),o[a][c]=Math.max(d,f)}var l=Array.prototype.concat.apply([],o);return Math.max.apply(Math,l)}function M(e){return Math.random()<e}function k(e,n){void 0===n&&(n={strict:!0});var t=/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9\u4E00-\u9FA5()!@:%_+.~#?&//=]*)/;return n.strict||(t=/^(https?:)?\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9\u4E00-\u9FA5()!@:%_+.~#?&//=]*)/),t.test(e)}function N(e){return e.replace(/^http:/,"https:")}function _(e){void 0===e&&(e="");var n=window.URL;if(!n)return!1;if(!n.canParse)return!1;if("function"!=typeof n.canParse)return!1;try{var t=new n("b","http://a");return t.pathname="c d","http://a/c%20d"===t.href&&Boolean(t.searchParams)&&n.canParse(e)}catch(e){return!1}}function j(e,n){void 0===e&&(e=""),void 0===n&&(n={isClosed:!1,showWrap:!1,showDate:!1,locales:"en-US",logFn:function(){},errorFn:function(){}});var t=Object.assign({isClosed:!1,showWrap:!1,showDate:!1,locales:"en-US",logFn:function(){},errorFn:function(){}},n),r=t.isClosed,i=t.showWrap,a=t.showDate,c=t.locales,u=t.logFn,s=t.errorFn,d=Object.create(null),f=function(){return(new Date).toLocaleDateString(c,{weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})};return["log","info","warn","error"].forEach((function(n){d[n]=function(){for(var t=[],c=0;c<arguments.length;c++)t[c]=arguments[c];if(r)return!1;var d=e,l=e;if("string"==typeof e&&e.length>=2){var g=e.length;d=":"===e[g-1]?e.substring(0,g-1):e}i&&console.log("--- ".concat(d," - begin ---")),a&&(l=e?"".concat(f()," ").concat(e):"".concat(f())),e||a?console[n].apply(console,o([l],t,!1)):console[n].apply(console,t),"log"===n&&u(),"error"===n&&s(),i&&console.log("--- ".concat(d," - end ---"))}})),d}var R=j("[Mazey]");function B(e,n){if(e)if(Array.isArray(n))n.forEach((function(n){e.classList.add(n)}));else{for(var t=e.className,r=t.split(/\s+/),o=0;o<r.length;o++)if(r[o]===n)return;var i,a="";""!==t&&(a=" "),i=t+a+n,e.className=i}else R.error("The element is not exist.")}function L(){var e,n=window.jQuery||window.$;return n?!(!(e=n("img"))||!e.length)&&(e.each((function(){var e=n(this);if(e){var t=e.attr("src");if(t&&"string"==typeof t&&t.length){var r=t.match(/width=([0-9]+[a-z%]*)/),o=t.match(/height=([0-9]+[a-z%]*)/);r&&w(r)&&r[1]&&e.width(r[1]),o&&w(o)&&o[1]&&e.height(o[1])}}})),!0):(e=document.getElementsByTagName("img")).length>0&&(Array.from(e).forEach((function(e){var n=e;if(n){var t=n.getAttribute("src");if(t&&"string"==typeof t&&t.length){var r=t.match(/width=([0-9]+[a-z%]*)/),o=t.match(/height=([0-9]+[a-z%]*)/);r&&w(r)&&r[1]&&(n.style.width=r[1]),o&&w(o)&&o[1]&&(n.style.height=o[1])}}})),!0)}function F(){var e=window.MAZEY_DEFINE_LISTENERS;return"object"!=typeof e&&(e={},window.MAZEY_DEFINE_LISTENERS=e),e}function D(e,t){void 0===t&&(t={});var r=F()[e];if(r instanceof Array)for(var o=0,i=r.length;o<i;o++)"function"==typeof r[o]&&r[o](n(n({},t),{type:e}))}function I(e){for(var n=e+"=",t=document.cookie.split(";"),r=0;r<t.length;r++){for(var o=t[r];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(n))return o.substring(n.length,o.length)}return""}function U(e){for(var n=document.cookie.split(";"),t=0;t<n.length;t++){var r=n[t].trim();if(r.startsWith("".concat(e,"="))){var o=r.split("=")[0],i=new Date;return i.setTime(i.getTime()-1),document.cookie="".concat(o,"=;expires=").concat(i.toUTCString()),!0}}return!1}function z(e,n){void 0===n&&(n={id:"",callback:function(){},timeout:5e3,isDefer:!1});var t,r,o=Object.assign({id:"",callback:function(){},timeout:5e3,isDefer:!1},n),i=o.id,a=o.callback,c=o.timeout,u=o.isDefer,s=document.createElement("script");s||Promise.reject("Not support create script element");var d=document.getElementsByTagName("script")[0];return s.type="text/javascript",u&&(s.defer=!0),i&&(s.id=i),s.readyState?s.onreadystatechange=function(){"loaded"!==s.readyState&&"complete"!==s.readyState||(s.onreadystatechange=null,h(a),h(t,"loaded"))}:s.onload=function(){h(a),h(t,"loaded")},s.src=e,d&&d.parentNode.insertBefore(s,d),new Promise((function(e,n){var o;t=(o=[e,n])[0],r=o[1],c&&setTimeout(r.bind(null,"timeout"),c)}))}function q(e){var n=[],t=window.PerformanceObserver;return!!t&&(w(t.supportedEntryTypes)&&(n=t.supportedEntryTypes),n.includes(e))}function H(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return q("paint")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"first-contentful-paint"===e.name}));r&&(n.disconnect(),e(Math.round(r.startTime)))}));n.observe({type:"paint",buffered:!0})}))]:[2,0]}))}))}function Z(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return q("paint")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"first-paint"===e.name}));r&&(n.disconnect(),e(Math.round(r.startTime)))}));n.observe({type:"paint",buffered:!0})}))]:[2,0]}))}))}var V="";function W(){if(window.MAZEY_BROWSER_INFO&&"object"==typeof window.MAZEY_BROWSER_INFO)return window.MAZEY_BROWSER_INFO;var e={engine:"",engineVs:"",platform:"",supporter:"",supporterVs:"",system:"",systemVs:"",shell:"",shellVs:"",appleType:""};try{var t=navigator.userAgent.toLowerCase();if(!t)return e;var r=function(e){return e.test(t)},o=function(e){var n="",r=t.match(e);return r&&w(r)&&(n=(n=(n=r.toString()).replace(/[^0-9|_.]/g,"")).replace(/_/g,".")),n},i="",a="";r(/windows|win32|win64|wow32|wow64/g)?i="windows":r(/macintosh|macintel/g)?i="macos":r(/x11/g)?i="linux":r(/android|adr/g)?i="android":r(/ios|iphone|ipad|ipod|iwatch/g)&&(i="ios",r(/ipad/g)?a="ipad":r(/iphone/g)?a="iphone":r(/iwatch/g)?a="iwatch":r(/ipod/g)&&(a="ipod")),e=n(n({},e),{system:i,appleType:a});var c="";"windows"===i?r(/windows nt 5.0|windows 2000/g)?c="2000":r(/windows nt 5.1|windows xp/g)?c="xp":r(/windows nt 5.2|windows 2003/g)?c="2003":r(/windows nt 6.0|windows vista/g)?c="vista":r(/windows nt 6.1|windows 7/g)?c="7":r(/windows nt 6.2|windows 8/g)?c="8":r(/windows nt 6.3|windows 8.1/g)?c="8.1":r(/windows nt 10.0|windows 10/g)&&(c="10"):"macos"===i?c=o(/os x [\d._]+/g):"android"===i?c=o(/android [\d._]+/g):"ios"===i&&(c=o(/os [\d._]+/g)),e=n(n({},e),{systemVs:c});var u="";"windows"===i||"macos"===i||"linux"===i?u="desktop":("android"===i||"ios"===i||r(/mobile/g))&&(u="mobile"),e=n(n({},e),{platform:u});var s="",d="";r(/applewebkit/g)?(s="webkit",r(/edge/g)?d="edge":r(/opr/g)?d="opera":r(/chrome/g)?d="chrome":r(/safari/g)&&(d="safari")):r(/gecko/g)&&r(/firefox/g)?(s="gecko",d="firefox"):r(/presto/g)?(s="presto",d="opera"):r(/trident|compatible|msie/g)&&(s="trident",d="iexplore"),e=n(n({},e),{engine:s,supporter:d});var f="";"webkit"===s?f=o(/applewebkit\/[\d._]+/g):"gecko"===s?f=o(/gecko\/[\d._]+/g):"presto"===s?f=o(/presto\/[\d._]+/g):"trident"===s&&(f=o(/trident\/[\d._]+/g)),e=n(n({},e),{engineVs:f});var l="";"chrome"===d?l=o(/chrome\/[\d._]+/g):"safari"===d?l=o(/version\/[\d._]+/g):"firefox"===d?l=o(/firefox\/[\d._]+/g):"opera"===d?l=o(/opr\/[\d._]+/g):"iexplore"===d?l=o(/(msie [\d._]+)|(rv:[\d._]+)/g):"edge"===d&&(l=o(/edge\/[\d._]+/g)),e=n(n({},e),{supporterVs:l});var g="",p="";return r(/micromessenger/g)?(g="wechat",p=o(/micromessenger\/[\d._]+/g)):r(/qqbrowser/g)?(g="qq_browser",p=o(/qqbrowser\/[\d._]+/g)):r(/\sqq/g)?g="qq_app":r(/ucbrowser/g)?(g="uc",p=o(/ucbrowser\/[\d._]+/g)):r(/qihu 360se/g)?g="360":r(/2345explorer/g)?(g="2345",p=o(/2345explorer\/[\d._]+/g)):r(/metasr/g)?g="sougou":r(/lbbrowser/g)?g="liebao":r(/maxthon/g)?(g="maxthon",p=o(/maxthon\/[\d._]+/g)):r(/biliapp/g)&&(g="bilibili"),e=n(n({},e),{shell:g,shellVs:p}),window.MAZEY_BROWSER_INFO=e,e}catch(n){return R.warn(n),e}}var $="";return e.addClass=B,e.addEvent=function(e,n){var t=F();void 0===t[e]&&(t[e]=[]),"function"==typeof n&&t[e].push(n)},e.addStyle=function(e,n){if(void 0===n&&(n={id:""}),!e)return!1;var t=document.createDocumentFragment(),r=null,o="",i=document.createElement("style");return n.id?(o="".concat(n.id),(r=document.getElementById(o))?r.innerHTML=e:(i.setAttribute("id",n.id),i.innerHTML=e,t.appendChild(i),document.head.appendChild(t))):(i.innerHTML=e,t.appendChild(i),document.head.appendChild(t)),!0},e.calLongestCommonSubsequence=function(e,n){return P(e,n)},e.calLongestCommonSubstring=function(e,n){return C(e,n)},e.camelCase2Underscore=u,e.camelCaseToKebabCase=function(e){return a(e)},e.cancelBubble=function(e){var n=e||window.event;n.stopPropagation?n.stopPropagation():n.cancelBubble=!0},e.clearHTML=function(e,n){return void 0===n&&(n={}),S(e,n)},e.clearHtml=function(e,n){return void 0===n&&(n={}),S(e,n)},e.convert10To26=function(e){for(var n="";e>0;){var t=e%26;0===t&&(t=26),n=String.fromCharCode(t+96)+n,e=(e-t)/26}return n},e.convertCamelToKebab=a,e.convertCamelToUnder=c,e.convertHttpToHttps=N,e.convertKebabToCamel=function(e){var n=e.replace(/-([a-z])/g,(function(e,n){return n.toUpperCase()}));return n.endsWith("-")?n.slice(0,-1):n},e.convertObjectToQuery=function(e){if(e&&0===Object.keys(e).length)return"";var n="?";for(var t in e)n+="".concat(t,"=").concat(e[t],"&");return n.slice(0,-1)},e.convertToHtmlBreaks=b,e.cutCHSString=function(e,n,t){return void 0===t&&(t=!1),A(e,n,t)},e.cutZHString=T,e.debounce=function(e,n,t){var r=null,o=null,i=null,a=null,c=null,u=function u(){var s=g()-i;s<n&&s>=0?o=setTimeout(u,n-s):(o=null,t||(c=e.apply(r,a),o||(r=a=null)))};return function(){for(var s=[],d=0;d<arguments.length;d++)s[d]=arguments[d];r=this,a=s,i=g();var f=t&&!o;return o||(o=setTimeout(u,n)),f&&(c=e.apply(r,a),r=a=null),c}},e.deepCopy=i,e.deepCopyObject=function(e){return i(e)},e.delCookie=function(e){U(e)},e.doFn=h,e.fireEvent=D,e.floatFixed=function(e,n){return void 0===n&&(n=0),parseFloat(e).toFixed(n)},e.floatToPercent=function(e,n){void 0===n&&(n=0);var t="";return t=n?(100*e).toFixed(n):String(Math.floor(100*e)),"".concat(t,"%")},e.formatDate=function(e,n){void 0===n&&(n="yyyy-MM-dd"),e||(e=new Date);var t=new Date(e),r=t.getHours(),o={yyyy:t.getFullYear(),MM:t.getMonth()+1,dd:t.getDate()<10?"0"+t.getDate():t.getDate(),HH:r<10?"0"+r:r,hh:(r%12||12)<10?"0"+(r%12||12):r%12||12,mm:t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes(),ss:t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds(),a:r<12?"AM":"PM"},i=n||"yyyy-MM-dd";return Object.keys(o).forEach((function(e){var n=o[e];"MM"===e&&Number(n)<=9&&(n="0".concat(n)),i=i.replace(e,String(n))})),i},e.genBrowserAttrs=function(e,n){void 0===e&&(e=""),void 0===n&&(n="-");var t=W(),r=[];return["system","platform","engine","supporter","shell","appleType"].forEach((function(o){var i=t[o];if(i){var a="";e&&e.length>0&&(a="".concat(e).concat(n)),r.push("".concat(a).concat(i))}})),r},e.genCustomConsole=j,e.genHashCode=function(e){var n,t=0;for(n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t},e.genRndNumString=d,e.genStyleString=function(e,n){var t="";return n&&n.length>0&&(t=n.join(";")+";"),"".concat(e,"{").concat(t,"}")},e.genUniqueNumString=l,e.generateRndNum=f,e.generateUniqueNum=function(e){return void 0===e&&(e=3),l(e)},e.getAllQueryParams=function(e){void 0===e&&(e=""),""===e&&(e=location.search);var n={};return e.replace(/\??(\w+)=([^&]*)&?/g,(function(e,t,r){return void 0===n[t]&&(n[t]=decodeURIComponent(r)),""})),n},e.getBrowserInfo=W,e.getCLS=function(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return q("layout-shift")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().reduce((function(e,n){var t=0;return v(n.value)&&(t=n.value),e+t}),0);n.disconnect(),e(r)}));n.observe({type:"layout-shift",buffered:!0})}))]:[2,0]}))}))},e.getCookie=I,e.getCurrentVersion=function(){return"v4"},e.getDefineListeners=F,e.getDomain=function(e,n){if(void 0===n&&(n=["hostname"]),_(e)){var t=new window.URL(e);return n.reduce((function(e,n){return e+=t[n]}),"")}var r=document.createElement("a");return r.href=e,n.reduce((function(e,n){return e+=r[n]}),"")},e.getFCP=H,e.getFID=function(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return q("first-input")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"first-input"===e.entryType}));if(r){n.disconnect();var o=r.processingStart;e(o?Math.round(r.processingStart-r.startTime):0)}}));n.observe({type:"first-input",buffered:!0})}))]:[2,0]}))}))},e.getFP=Z,e.getFileSize=function(e){var n=function(e){return String(Math.ceil(e))};if(!e||e<0)return"";var t=1024;return e<t?e+" B":e<Math.pow(t,2)?n(e/t)+" KB":e<Math.pow(t,3)?n(e/Math.pow(t,2))+" MB":e<Math.pow(t,4)?n(e/Math.pow(t,3))+" G":n(e/Math.pow(t,4))+" T"},e.getFriendlyInterval=function(e,n,t){void 0===e&&(e=0),void 0===n&&(n=0),void 0===t&&(t=p);var r=(t=Object.assign(p,t)).type,o=decodeURIComponent;v(e)||(e=new Date(e).getTime()),v(n)||(n=new Date(n).getTime());var i=Number(n)-Number(e),a="",c=new Array(4).fill(0),u=c[0],s=(c[1],c[2],c[3]),d=o("%20%E5%A4%A9%20"),f=o("%20%E6%97%B6%20"),l=o("%20%E5%88%86%20"),g=o("%20%E7%A7%92");if(i>=0)switch(u=Math.floor(i/1e3/60/60/24),Math.floor(i/1e3/60/60),Math.floor(i/1e3/60),s=Math.floor(i/1e3),r){case"d":a=u;break;case"text":a=(u=Math.floor(i/1e3/60/60/24))+d+Math.floor(i/1e3/60/60%24)+f+Math.floor(i/1e3/60%60)+l+(s=Math.floor(i/1e3%60))+g;break;default:a=s}return a},e.getHashQueryParam=function(e){var n=location.hash.split("?");if(1===n.length)return"";var t=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),r=n[1].match(t);return r?r[2]:""},e.getLCP=function(){return t(this,void 0,void 0,(function(){return r(this,(function(e){return q("largest-contentful-paint")?[2,new Promise((function(e){var n=new PerformanceObserver((function(t){var r=t.getEntries().find((function(e){return"largest-contentful-paint"===e.entryType}));r&&(n.disconnect(),e(Math.round(r.startTime)))}));n.observe({type:"largest-contentful-paint",buffered:!0})}))]:[2,0]}))}))},e.getLocalStorage=function(e){var n=null;if(e){var t=localStorage.getItem(e);t&&(n=JSON.parse(t))}return n},e.getPageMeta=function(e){var n;return document.querySelector&&(null===(n=document.querySelector('meta[name="'.concat(e,'"]')))||void 0===n?void 0:n.getAttribute("content"))||""},e.getPerformance=function(e){return void 0===e&&(e=!1),t(this,void 0,void 0,(function(){function n(){var n={source:D,os:t(),osVersion:o(),deviceType:i(),network:a(),screenDirection:c(),unloadTime:h-y,redirectTime:b-S,dnsTime:E-T,tcpTime:A-x,sslTime:s(A,O),responseTime:C-P,downloadTime:M-C,firstPaintTime:z,firstContentfulPaintTime:V,domReadyTime:k-I,onloadTime:N-I,whiteTime:C-I,renderTime:_-I,decodedBodySize:B,encodedBodySize:L};Object.keys(n).forEach((function(e){v(n[e])&&(n[e]<0?n[e]=0:n[e]=Math.round(n[e]))})),v(n.whiteTime)&&n.whiteTime>n.onloadTime&&(n.whiteTime=0);var r={};e||Object.keys(n).forEach((function(e){r[u(e)]=n[e]})),Object.keys(r).length?f(r):f(n)}function t(){return navigator.userAgent.indexOf("Android")>-1||navigator.userAgent.indexOf("Linux")>-1?"android":navigator.userAgent.indexOf("iPhone")>-1?"ios":navigator.userAgent.indexOf("Windows Phone")>-1?"wp":"others"}function o(){var e="",n=navigator.userAgent,t=n.indexOf("Android")>-1||n.indexOf("Linux")>-1,r=!!n.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),o=navigator.userAgent.split(";");if(o.length<2)return e;var i=o[1];return i?(t&&(e=(i.match(/\d+\.\d+/g)||[])[0]),r&&(e=(i.match(/(\d+)_(\d+)_?(\d+)?/)||[])[0]),e||(e=""),e):e}function i(){var e,n=navigator.userAgent.toLowerCase(),t=n.match(/(ipad)/i)&&"ipad",r=n.match(/iphone os/i)&&"iphone os",o=n.match(/midp/i)&&"midp",i=n.match(/rv:1.2.3.4/i)&&"rv:1.2.3.4",a=n.match(/ucweb/i)&&"ucweb",c=n.match(/android/i)&&"android",u=n.match(/windows ce/i)&&"windows ce",s=n.match(/windows mobile/i)&&"windows mobile";return(e=t||r||o||i||a||c||u||s?r||o||i||a||c||u||s?"phone":t?"ipad":void 0:"pc")||(e=""),e}function a(){var e="",n=window.navigator;if(n.connection&&n.connection.effectiveType)switch(n.connection.effectiveType){case"wifi":e="wifi";break;case"4g":e="4g";break;case"2g":e="2g";break;case"3g":e="3g";break;case"ethernet":e="ethernet";break;case"default":e=void 0}return e||(e=""),e}function c(){var e="";return window.screen&&window.screen.orientation&&window.screen.orientation.angle&&(180!==window.screen.orientation.angle&&0!==window.screen.orientation.angle||(e="|"),90!==window.screen.orientation.angle&&-90!==window.screen.orientation.angle||(e="-")),e}function s(e,n){var t=0;return n&&(t=e-n),t}var d,f,l,g,p,m,h,y,b,S,E,T,A,x,O,C,P,M,k,N,_,j,R,B,L,F,D,I,U,z,V;return r(this,(function(e){switch(e.label){case 0:if(!q("navigation"))return[2,Promise.reject(new Error("navigation is not supported"))];if(!(d=window.performance)||"function"!=typeof d.getEntries||"function"!=typeof d.getEntriesByType)return[2,Promise.reject(new Error("performance is not supported"))];if(l=new Promise((function(e){f=[e][0]})),g=null,w(p=d.getEntriesByType("navigation"))&&(g=p[0]),m=new Array(19).fill(0),h=m[0],y=m[1],b=m[2],S=m[3],E=m[4],T=m[5],A=m[6],x=m[7],O=m[8],C=m[9],P=m[10],M=m[11],k=m[12],N=m[13],_=m[14],j=m[15],R=m[16],B=m[17],L=m[18],F=d.timing,D="",g)D="PerformanceNavigationTiming",B=g.decodedBodySize,L=g.encodedBodySize,h=g.unloadEventEnd,y=g.unloadEventStart,b=g.redirectEnd,S=g.redirectStart,E=g.domainLookupEnd,T=g.domainLookupStart,A=g.connectEnd,x=g.connectStart,O=g.secureConnectionStart,C=g.responseStart,P=g.requestStart,M=g.responseEnd,k=g.domContentLoadedEventStart,N=g.loadEventStart,_=g.loadEventEnd,j=g.startTime,R=g.fetchStart;else{if(!F)return[2,Promise.reject(new Error("NavigationTiming and Timing are not supported"))];D="PerformanceTiming",h=F.unloadEventEnd,y=F.unloadEventStart,b=F.redirectEnd,S=F.redirectStart,E=F.domainLookupEnd,T=F.domainLookupStart,A=F.connectEnd,x=F.connectStart,O=F.secureConnectionStart,C=F.responseStart,P=F.requestStart,M=F.responseEnd,k=F.domContentLoadedEventStart,N=F.loadEventStart,_=F.loadEventEnd,j=F.navigationStart,R=F.fetchStart}if(I=0,v(j))I=j;else{if(!v(R))return[2,Promise.reject(new Error("startTime, navigationStart or fetchStart are required"))];I=R}return[4,Promise.all([Z(),H()])];case 1:return U=e.sent(),z=U[0],V=U[1],v(_)&&_>0?n():window.addEventListener("load",(function(){window.setTimeout((function(){n()}),0)})),[2,l]}}))}))},e.getQueryParam=function(e){var n=new RegExp("(^|&)"+e+"=([^&]*)(&|$)"),t=location.search.substring(1).match(n);return null!==t?decodeURIComponent(t[2]):""},e.getScriptQueryParam=function(e,n){void 0===n&&(n=""),n||(n=".js");for(var t=new RegExp("[?&]".concat(e,"=([^&]*)")),r=document.querySelectorAll('script[src*="'.concat(n,'"]')),o=0;o<r.length;o++){var i=r[o].getAttribute("src");if(i&&-1!==i.indexOf(n)){var a=i.match(t);if(a)return decodeURIComponent(a[1])}}return""},e.getSessionStorage=function(e){var n=null;if(e){var t=sessionStorage.getItem(e);t&&(n=JSON.parse(t))}return n},e.getTTFB=function(){return t(this,void 0,void 0,(function(){var e,n;return r(this,(function(t){return q("navigation")&&window.performance&&window.performance.getEntriesByType?(e=performance.getEntriesByType("navigation")[0],0,e?(n=e.responseStart-e.requestStart,[2,Math.round(n)]):[2,0]):[2,0]}))}))},e.getUrlFileType=function(e){var n="";if("string"!=typeof e||""==e)return n;var t=/\.[^/?#]+$/.exec(e);return t?(t[0].length>1&&(n=t[0].substring(1)),n):n},e.getUrlHost=function(e){var n="";return!k(e)&&k(e,{strict:!1})&&0===e.indexOf("//")&&(e="https:"+e),_(e)&&(n=new URL(e).host),n},e.getUrlParam=function(e,n,t){void 0===t&&(t={});var r=null;if(e.includes("#")){r=new URL(e).searchParams.getAll(n)}else{var o={};e.replace(/\??(\w+)=([^&]*)&?/g,(function(e,n,t){return void 0!==o[n]?o[n].push(t):o[n]=[t],""})),r=o[n]||[]}return t.returnArray?r:r.length?r[0]:null},e.getUrlPath=function(e){var n="";return!k(e)&&k(e,{strict:!1})&&0===e.indexOf("//")&&(e="https:"+e),_(e)&&(n=new URL(e).pathname),n},e.hasClass=function(e,n){if(!e)return R.error("The element is not exist."),!1;for(var t=e.className.split(/\s+/),r=0;r<t.length;r++)if(t[r]===n)return!0;return!1},e.inRate=function(e){return M(e)},e.invokeEvent=function(e){D(e)},e.invokeFn=m,e.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},e.isBrowser=function(){if(O)return"browser"===O;var e="undefined"!=typeof window;return e&&(O="browser"),e},e.isHit=M,e.isJSONString=s,e.isJsonString=function(e){return s(e)},e.isNonEmptyArray=w,e.isNonEmptyObject=function(e){return!!y(e)&&0!==Object.keys(e).length},e.isNumber=v,e.isPureObject=y,e.isSafePWAEnv=function(){if(V)return"pwa"===V;var e=W();return"serviceWorker"in navigator&&function(){var e;try{return e=new Function("return async function(){};")(),null!=Object.getPrototypeOf(e).constructor}catch(e){return!1}}()&&"undefined"!=typeof Promise&&-1!==Promise.toString().indexOf("[native code]")&&Boolean(window.fetch)&&Boolean(window.indexedDB)&&Boolean(window.caches)&&!e.shell?(V="pwa",!0):(V="no-pwa",!1)},e.isSupportWebp=function(){return $?Promise.resolve("webp"===$):new Promise((function(e){var n=new Image;n.onload=function(){var t=n.width>0&&n.height>0;$=t?"webp":"no-webp",e(t)},n.onerror=function(){$="no-webp",e(!1)},n.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="}))},e.isSupportedEntryType=q,e.isValidData=function(e,n,t){var r=!1;return"object"!=typeof e||n.reduce((function(e,n){return void 0===e[n]?Object.create(null):e=e[n]}),e)===t&&(r=!0),r},e.isValidEmail=function(e){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(e)},e.isValidHttpUrl=k,e.isValidPhoneNumber=function(e){return/^1\d{10}$/.test(e)},e.isValidUrl=function(e){return/^[a-zA-Z0-9]+:\/\/[-a-zA-Z0-9@:%._+~#=]{1,256}\b([-a-zA-Z0-9\u4E00-\u9FA5()!@:%_+.~#?&//=]*)$/.test(e)},e.loadCSS=function(e,n){void 0===n&&(n={id:""});var t,r=n.id,o=function(){},i=new Promise((function(e,n){var r;t=(r=[e,n])[0],o=r[1]})),a=function(){t("loaded")},c=document.createElement("link");c||o(new Error("Not support create link element"));var u="onload"in c,s=+navigator.userAgent.replace(/.*(?:AppleWebKit|AndroidWebKit)\/?(\d+).*/i,"$1")<536;if(c.rel="stylesheet",c.type="text/css",c.href=e,void 0!==r&&(c.id=r),document.getElementsByTagName("head")[0].appendChild(c),s||!u)return setTimeout((function(){f(c,a,0)}),1),i;function d(){c&&(c.onload=c.onerror=c.onreadystatechange=null),c=null,a()}function f(e,n,t){if(e){var r,o=e.sheet;if((t+=1)>3e5)return r=!0,e&&(e=null),void n();if(s)o&&(r=!0);else if(o)try{o.cssRules&&(r=!0)}catch(e){var i=e;if(!i.name)return;"NS_ERROR_DOM_SECURITY_ERR"===i.name&&(r=!0)}setTimeout((function(){r?n():f(e,n,t)}),20)}}return u?(c.onload=d,c.onerror=function(){d()}):c.onreadystatechange=function(){c&&/loaded|complete/.test(c.readyState)&&d()},i},e.loadImage=function(e){return new Promise((function(n,t){var r=new Image;r.onload=function(){n(r)},r.onerror=function(e){t(e)},r.src=e}))},e.loadScript=z,e.loadScriptIfUndefined=function(e,n){return window[e]?Promise.resolve("defined"):z(n)},e.longestComSubsequence=P,e.longestComSubstring=C,e.mNow=g,e.mTrim=function(e){for(var n=(e=e.replace(/^\s+/,"")).length-1,t=/\s/;t.test(e.charAt(n));)n--;return e.slice(0,n+1)},e.mazeyCon=R,e.newLine=function(e){return b(e)},e.removeClass=function(e,n){var t;e?(t=(t=(t=(t=" "+e.className+" ").replace(/(\s+)/gi," ")).replace(" "+n+" "," ")).replace(/(^\s+)|(\s+$)/g,""),e.className=t):R.error("The element is not exist.")},e.removeCookie=U,e.removeEvent=function(e,n){var t=F(),r=t[e];if("string"==typeof e&&r instanceof Array)if("function"==typeof n){for(var o=0,i=r.length;o<i;o++)if(r[o]===n){t[e].splice(o,1);break}}else delete t[e]},e.removeHTML=S,e.removeHtml=function(e,n){return void 0===n&&(n={}),S(e,n)},e.repeatUntilConditionMet=function(e,n,o){var i=this;void 0===n&&(n={}),void 0===o&&(o=function(e){return!0===e});var a=n.interval,c=void 0===a?1e3:a,u=n.times,s=void 0===u?10:u,d=n.context,f=n.args,l=0;"function"!=typeof e&&console.error("Expected a function."),("number"!=typeof c||c<0)&&console.error("Expected a non-negative number for interval."),("number"!=typeof s||s<0)&&console.error("Expected a non-negative number for times."),function n(){setTimeout((function(){return t(i,void 0,void 0,(function(){var t;return r(this,(function(r){switch(r.label){case 0:return[4,e.apply(d,f)];case 1:return t=r.sent(),o(t)||++l>=s?[2]:(n(),[2])}}))}))}),c)}()},e.replaceHttp=function(e){return N(e)},e.sanitizeInput=function(e){var n={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};if("string"!=typeof e)throw new Error("Input must be a string");return e.replace(/[&<>"'/]/g,(function(e){return n[e]}))},e.setClass=function(e,n){B(e,n)},e.setCookie=function(e,n,t,r){var o,i;if(t){var a=new Date;a.setTime(a.getTime()+24*t*60*60*1e3),i="; expires="+a.toUTCString()}else i="";var c=location.host;1===c.split(".").length?document.cookie=e+"="+n+i+"; path=/":((o=c.split(".")).shift(),r=r||"."+o.join("."),document.cookie=e+"="+n+i+"; path=/; domain="+r,null!==I(e)&&I(e)===n||(r=r||"."+c,document.cookie=e+"="+n+i+"; path=/; domain="+r))},e.setImgSizeBySrc=L,e.setImgWidHeiBySrc=function(){return L()},e.setLocalStorage=function(e,n){void 0===n&&(n=null),e&&localStorage.setItem(e,JSON.stringify(n))},e.setSessionStorage=function(e,n){void 0===n&&(n=null),e&&sessionStorage.setItem(e,JSON.stringify(n))},e.sleep=function(e){return t(this,void 0,void 0,(function(){return r(this,(function(n){return[2,x(e)]}))}))},e.throttle=function(e,n,t){void 0===t&&(t={}),t=Object.assign({},t);var r=null,o=null,i=null,a=[null,0],c=a[0],u=a[1],s=function(){u=!1===t.leading?0:g(),i=null,c=e.apply(this,o),i||(r=o=null)};return function(){for(var a=[],d=0;d<arguments.length;d++)a[d]=arguments[d];var f=g();u||!1!==t.leading||(u=f);var l=n-(f-u);return r=this,o=a,l<=0||l>n?(i&&(clearTimeout(i),i=null),u=f,c=e.apply(r,o),i||(r=o=null)):i||!1===t.trailing||(i=setTimeout(s.bind(r),l)),c}},e.truncateZHString=A,e.unsanitize=function(e){return E(e)},e.unsanitizeInput=E,e.updateQueryParam=function(e,n,t){if(e.includes("#")){var r=new URL(e);return r.searchParams.set(n,t),r.toString()}var o=new RegExp("([?&])"+n+"=.*?(&|$)","i"),i=-1!==e.indexOf("?")?"&":"?";return e.match(o)?e.replace(o,"$1"+n+"="+t+"$2"):e+i+n+"="+t},e.waitTime=x,e.windowLoaded=function(e){void 0===e&&(e=90);var n,t=function(){},r=new Promise((function(e,r){t=e,n=r}));return"complete"===document.readyState?t("complete"):window.addEventListener("load",(function(){return t("load")})),setTimeout((function(){return n(Error("timeout"))}),1e3*e),r},e.zAxiosIsValidRes=function(e,n){void 0===n&&(n={validStatusRange:[200,300],validCode:[0]});var t=Object.assign({validStatusRange:[200,300],validCode:[0]},n),r=t.validStatusRange,o=t.validCode;2!==r.length&&console.error("valid validStatusRange is required");var i=!1;if(e&&e.status&&2===r.length&&e.status>=r[0]&&e.status<r[1]){var a=e.data;a&&o.includes(a.code)&&(i=!0)}return i},e}({});
|
package/lib/perf.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare function isSupportedEntryType(name: string): boolean;
|
|
|
23
23
|
* FCP: 123
|
|
24
24
|
* ```
|
|
25
25
|
*
|
|
26
|
-
* @returns A promise that resolves with the FCP time in milliseconds, or 0 if the
|
|
26
|
+
* @returns A promise that resolves with the FCP time in milliseconds, or 0 if the "paint" entry type is not supported.
|
|
27
27
|
* @category Perf
|
|
28
28
|
*/
|
|
29
29
|
export declare function getFCP(): Promise<number>;
|
|
@@ -47,7 +47,7 @@ export declare function getFCP(): Promise<number>;
|
|
|
47
47
|
* FP: 123
|
|
48
48
|
* ```
|
|
49
49
|
*
|
|
50
|
-
* @returns A promise that resolves with the FP time in milliseconds, or 0 if the
|
|
50
|
+
* @returns A promise that resolves with the FP time in milliseconds, or 0 if the "paint" entry type is not supported.
|
|
51
51
|
* @category Perf
|
|
52
52
|
*/
|
|
53
53
|
export declare function getFP(): Promise<number>;
|
|
@@ -71,7 +71,7 @@ export declare function getFP(): Promise<number>;
|
|
|
71
71
|
* LCP: 123
|
|
72
72
|
* ```
|
|
73
73
|
*
|
|
74
|
-
* @returns A promise that resolves with the LCP time in milliseconds, or 0 if the
|
|
74
|
+
* @returns A promise that resolves with the LCP time in milliseconds, or 0 if the "largest-contentful-paint" entry type is not supported.
|
|
75
75
|
* @category Perf
|
|
76
76
|
*/
|
|
77
77
|
export declare function getLCP(): Promise<number>;
|
|
@@ -95,7 +95,7 @@ export declare function getLCP(): Promise<number>;
|
|
|
95
95
|
* FID: 123
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
98
|
-
* @returns A promise that resolves with the FID in milliseconds, or 0 if the
|
|
98
|
+
* @returns A promise that resolves with the FID in milliseconds, or 0 if the "first-input" entry type is not supported.
|
|
99
99
|
* @category Perf
|
|
100
100
|
*/
|
|
101
101
|
export declare function getFID(): Promise<number>;
|
|
@@ -119,7 +119,7 @@ export declare function getFID(): Promise<number>;
|
|
|
119
119
|
* CLS: 123
|
|
120
120
|
* ```
|
|
121
121
|
*
|
|
122
|
-
* @returns A promise that resolves with the CLS score, or 0 if the
|
|
122
|
+
* @returns A promise that resolves with the CLS score, or 0 if the "layout-shift" entry type is not supported.
|
|
123
123
|
* @category Perf
|
|
124
124
|
*/
|
|
125
125
|
export declare function getCLS(): Promise<number>;
|
package/lib/store.d.ts
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
* Usage:
|
|
7
7
|
*
|
|
8
8
|
* ```javascript
|
|
9
|
-
* setSessionStorage(
|
|
10
|
-
* const ret1 = getSessionStorage(
|
|
11
|
-
* setLocalStorage(
|
|
12
|
-
* const ret2 = getLocalStorage(
|
|
9
|
+
* setSessionStorage("test", "123");
|
|
10
|
+
* const ret1 = getSessionStorage("test");
|
|
11
|
+
* setLocalStorage("test", "123");
|
|
12
|
+
* const ret2 = getLocalStorage("test");
|
|
13
13
|
* console.log(ret1, ret2);
|
|
14
14
|
*
|
|
15
15
|
* // or package in usage
|
|
16
|
-
* const projectName =
|
|
16
|
+
* const projectName = "mazey";
|
|
17
17
|
* function mSetLocalStorage (key, value) {
|
|
18
18
|
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
19
19
|
* }
|
|
@@ -42,14 +42,14 @@ export declare function setSessionStorage<T>(key: string, value?: T | null): voi
|
|
|
42
42
|
* Usage:
|
|
43
43
|
*
|
|
44
44
|
* ```javascript
|
|
45
|
-
* setSessionStorage(
|
|
46
|
-
* const ret1 = getSessionStorage(
|
|
47
|
-
* setLocalStorage(
|
|
48
|
-
* const ret2 = getLocalStorage(
|
|
45
|
+
* setSessionStorage("test", "123");
|
|
46
|
+
* const ret1 = getSessionStorage("test");
|
|
47
|
+
* setLocalStorage("test", "123");
|
|
48
|
+
* const ret2 = getLocalStorage("test");
|
|
49
49
|
* console.log(ret1, ret2);
|
|
50
50
|
*
|
|
51
51
|
* // or package in usage
|
|
52
|
-
* const projectName =
|
|
52
|
+
* const projectName = "mazey";
|
|
53
53
|
* function mSetLocalStorage (key, value) {
|
|
54
54
|
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
55
55
|
* }
|
|
@@ -78,14 +78,14 @@ export declare function getSessionStorage<T>(key: string): T | null;
|
|
|
78
78
|
* Usage:
|
|
79
79
|
*
|
|
80
80
|
* ```javascript
|
|
81
|
-
* setSessionStorage(
|
|
82
|
-
* const ret1 = getSessionStorage(
|
|
83
|
-
* setLocalStorage(
|
|
84
|
-
* const ret2 = getLocalStorage(
|
|
81
|
+
* setSessionStorage("test", "123");
|
|
82
|
+
* const ret1 = getSessionStorage("test");
|
|
83
|
+
* setLocalStorage("test", "123");
|
|
84
|
+
* const ret2 = getLocalStorage("test");
|
|
85
85
|
* console.log(ret1, ret2);
|
|
86
86
|
*
|
|
87
87
|
* // or package in usage
|
|
88
|
-
* const projectName =
|
|
88
|
+
* const projectName = "mazey";
|
|
89
89
|
* function mSetLocalStorage (key, value) {
|
|
90
90
|
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
91
91
|
* }
|
|
@@ -114,14 +114,14 @@ export declare function setLocalStorage<T>(key: string, value?: T | null): void;
|
|
|
114
114
|
* Usage:
|
|
115
115
|
*
|
|
116
116
|
* ```javascript
|
|
117
|
-
* setSessionStorage(
|
|
118
|
-
* const ret1 = getSessionStorage(
|
|
119
|
-
* setLocalStorage(
|
|
120
|
-
* const ret2 = getLocalStorage(
|
|
117
|
+
* setSessionStorage("test", "123");
|
|
118
|
+
* const ret1 = getSessionStorage("test");
|
|
119
|
+
* setLocalStorage("test", "123");
|
|
120
|
+
* const ret2 = getLocalStorage("test");
|
|
121
121
|
* console.log(ret1, ret2);
|
|
122
122
|
*
|
|
123
123
|
* // or package in usage
|
|
124
|
-
* const projectName =
|
|
124
|
+
* const projectName = "mazey";
|
|
125
125
|
* function mSetLocalStorage (key, value) {
|
|
126
126
|
* return setLocalStorage(`${projectName}_${key}`, value);
|
|
127
127
|
* }
|
|
@@ -150,8 +150,8 @@ export declare function getLocalStorage<T>(key: string): T | null;
|
|
|
150
150
|
* Usage:
|
|
151
151
|
*
|
|
152
152
|
* ```javascript
|
|
153
|
-
* setCookie(
|
|
154
|
-
* const ret = getCookie(
|
|
153
|
+
* setCookie("test", "123", 30, "example.com"); // key value day domain
|
|
154
|
+
* const ret = getCookie("test");
|
|
155
155
|
* console.log(ret);
|
|
156
156
|
* ```
|
|
157
157
|
*
|
|
@@ -172,8 +172,8 @@ export declare function getCookie(name: string): string;
|
|
|
172
172
|
* Usage:
|
|
173
173
|
*
|
|
174
174
|
* ```javascript
|
|
175
|
-
* setCookie(
|
|
176
|
-
* const ret = getCookie(
|
|
175
|
+
* setCookie("test", "123", 30, "example.com"); // key value day domain
|
|
176
|
+
* const ret = getCookie("test");
|
|
177
177
|
* console.log(ret);
|
|
178
178
|
* ```
|
|
179
179
|
*
|
|
@@ -192,7 +192,7 @@ export declare function setCookie(name: string, value: string, days?: number, do
|
|
|
192
192
|
* Usage:
|
|
193
193
|
*
|
|
194
194
|
* ```javascript
|
|
195
|
-
* const ret = removeCookie(
|
|
195
|
+
* const ret = removeCookie("test");
|
|
196
196
|
* console.log(ret);
|
|
197
197
|
* ```
|
|
198
198
|
*
|
package/lib/typing.d.ts
CHANGED
|
@@ -84,4 +84,6 @@ interface WebPerformance {
|
|
|
84
84
|
|
|
85
85
|
type MazeyElement = HTMLElement | null;
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
type MazeyDate = Date | string | number;
|
|
88
|
+
|
|
89
|
+
export type { AnyFunction, BrowserInfo, DebounceFunc, DefineListeners, IsNumberOptions, LoadScriptReturns, MazeyDate, MazeyElement, MazeyFn, MazeyFnParams, MazeyFnReturn, MazeyFunction, MazeyObject, MazeyWindow, MultiValueUrlParams, RepeatUntilOptions, SimpleObject, SimpleType, SingleValueUrlParams, TestUa, TestVs, ThrottleFunc, WebPerformance, ZResIsValidResOptions, ZResResponse };
|
package/lib/url.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ import type { SingleValueUrlParams } from "./typing";
|
|
|
7
7
|
* ```javascript
|
|
8
8
|
* // http://example.com/?t1=1&t2=2&t3=3&t4=4#2333
|
|
9
9
|
* // ?t1=1&t2=2&t3=3&t4=4
|
|
10
|
-
* const p1 = getQueryParam(
|
|
11
|
-
* const p2 = getQueryParam(
|
|
10
|
+
* const p1 = getQueryParam("t3");
|
|
11
|
+
* const p2 = getQueryParam("t4");
|
|
12
12
|
* console.log(p1, p2);
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
@@ -38,7 +38,7 @@ export declare function getQueryParam(param: string): string;
|
|
|
38
38
|
* Output:
|
|
39
39
|
*
|
|
40
40
|
* ```text
|
|
41
|
-
* { t1:
|
|
41
|
+
* { t1: "1", t2: "2", t3: "3", t4: "4" }
|
|
42
42
|
* ```
|
|
43
43
|
*
|
|
44
44
|
* @param {string} url Optional, The URL string.
|
|
@@ -52,8 +52,8 @@ export declare function getAllQueryParams(url?: string): SingleValueUrlParams;
|
|
|
52
52
|
* Usage:
|
|
53
53
|
*
|
|
54
54
|
* ```javascript
|
|
55
|
-
* const p1 = getUrlParam(
|
|
56
|
-
* const p2 = getUrlParam(
|
|
55
|
+
* const p1 = getUrlParam("http://example.com/?t1=1&t2=2&t3=3&t4=4", "t3");
|
|
56
|
+
* const p2 = getUrlParam("http://example.com/?t1=1&t2=2&t3=3&t4=4", "t4");
|
|
57
57
|
* console.log(p1, p2);
|
|
58
58
|
* ```
|
|
59
59
|
*
|
|
@@ -79,8 +79,8 @@ export declare function getUrlParam(url: string, param: string, options?: {
|
|
|
79
79
|
* Usage:
|
|
80
80
|
*
|
|
81
81
|
* ```javascript
|
|
82
|
-
* const ret1 = updateQueryParam(
|
|
83
|
-
* const ret2 = updateQueryParam(
|
|
82
|
+
* const ret1 = updateQueryParam("http://example.com/?t1=1&t2=2&t3=3&t4=4", "t3", "three");
|
|
83
|
+
* const ret2 = updateQueryParam("http://example.com/?t1=1&t2=2&t3=3&t4=4", "t4", "four");
|
|
84
84
|
* console.log(ret1);
|
|
85
85
|
* console.log(ret2);
|
|
86
86
|
* ```
|
|
@@ -107,8 +107,8 @@ export declare function updateQueryParam(url: string, param: string, value: stri
|
|
|
107
107
|
* ```javascript
|
|
108
108
|
* // http://example.com/?#2333?t1=1&t2=2&t3=3&t4=4
|
|
109
109
|
* // #2333?t1=1&t2=2&t3=3&t4=4
|
|
110
|
-
* const p1 = getHashQueryParam(
|
|
111
|
-
* const p2 = getHashQueryParam(
|
|
110
|
+
* const p1 = getHashQueryParam("t3");
|
|
111
|
+
* const p2 = getHashQueryParam("t4");
|
|
112
112
|
* console.log(p1, p2);
|
|
113
113
|
* ```
|
|
114
114
|
*
|
|
@@ -129,12 +129,12 @@ export declare function getHashQueryParam(param: string): string;
|
|
|
129
129
|
* Usage:
|
|
130
130
|
*
|
|
131
131
|
* ```javascript
|
|
132
|
-
* const ret1 = getDomain(
|
|
133
|
-
* const ret2 = getDomain(
|
|
134
|
-
* const ret3 = getDomain(
|
|
135
|
-
* const ret4 = getDomain(
|
|
136
|
-
* const ret5 = getDomain(
|
|
137
|
-
* const ret6 = getDomain(
|
|
132
|
+
* const ret1 = getDomain("http://example.com/?t1=1&t2=2&t3=3&t4=4");
|
|
133
|
+
* const ret2 = getDomain("http://example.com/test/thanks?t1=1&t2=2&t3=3&t4=4", ["hostname", "pathname"]);
|
|
134
|
+
* const ret3 = getDomain("http://example.com:7890/test/thanks", ["hostname"]);
|
|
135
|
+
* const ret4 = getDomain("http://example.com:7890/test/thanks", ["host"]); // With Port
|
|
136
|
+
* const ret5 = getDomain("http://example.com:7890/test/thanks", ["origin"]);
|
|
137
|
+
* const ret6 = getDomain("http://example.com:7890/test/thanks?id=1", ["origin", "pathname", "search"]);
|
|
138
138
|
* console.log(ret1);
|
|
139
139
|
* console.log(ret2);
|
|
140
140
|
* console.log(ret3);
|
|
@@ -155,7 +155,7 @@ export declare function getHashQueryParam(param: string): string;
|
|
|
155
155
|
* ```
|
|
156
156
|
*
|
|
157
157
|
* @param {string} url
|
|
158
|
-
* @param {array} rules Object.keys(location), [
|
|
158
|
+
* @param {array} rules Object.keys(location), ["href", "origin", "protocol", "host", "hostname", "port", "pathname", "search", "hash"], ["hostname", "pathname"] = "km.mazey.net/plugins/servlet/mobile"
|
|
159
159
|
* @category URL
|
|
160
160
|
*/
|
|
161
161
|
export declare function getDomain(url: string, rules?: string[]): string;
|
|
@@ -165,11 +165,11 @@ export declare function getDomain(url: string, rules?: string[]): string;
|
|
|
165
165
|
* Usage:
|
|
166
166
|
*
|
|
167
167
|
* ```javascript
|
|
168
|
-
* const ret1 = isValidUrl(
|
|
169
|
-
* const ret2 = isValidUrl(
|
|
170
|
-
* const ret3 = isValidUrl(
|
|
171
|
-
* const ret4 = isValidUrl(
|
|
172
|
-
* const ret5 = isValidUrl(
|
|
168
|
+
* const ret1 = isValidUrl("https://www.example.com");
|
|
169
|
+
* const ret2 = isValidUrl("http://example.com/path/exx/ss");
|
|
170
|
+
* const ret3 = isValidUrl("https://www.example.com/?q=hello&age=24#world");
|
|
171
|
+
* const ret4 = isValidUrl("http://www.example.com/#world?id=9");
|
|
172
|
+
* const ret5 = isValidUrl("ftp://example.com");
|
|
173
173
|
* console.log(ret1, ret2, ret3, ret4, ret5);
|
|
174
174
|
* ```
|
|
175
175
|
*
|
|
@@ -194,12 +194,12 @@ export declare function isValidUrl(url: string): boolean;
|
|
|
194
194
|
* Usage:
|
|
195
195
|
*
|
|
196
196
|
* ```javascript
|
|
197
|
-
* const ret1 = isValidHttpUrl(
|
|
198
|
-
* const ret2 = isValidHttpUrl(
|
|
199
|
-
* const ret3 = isValidHttpUrl(
|
|
200
|
-
* const ret4 = isValidHttpUrl(
|
|
201
|
-
* const ret5 = isValidHttpUrl(
|
|
202
|
-
* const ret6 = isValidHttpUrl(
|
|
197
|
+
* const ret1 = isValidHttpUrl("https://www.example.com");
|
|
198
|
+
* const ret2 = isValidHttpUrl("http://example.com/path/exx/ss");
|
|
199
|
+
* const ret3 = isValidHttpUrl("https://www.example.com/?q=hello&age=24#world");
|
|
200
|
+
* const ret4 = isValidHttpUrl("http://www.example.com/#world?id=9");
|
|
201
|
+
* const ret5 = isValidHttpUrl("//example.com/a/b/c?q=1", { strict: false });
|
|
202
|
+
* const ret6 = isValidHttpUrl("ftp://example.com");
|
|
203
203
|
* console.log(ret1, ret2, ret3, ret4, ret5, ret6);
|
|
204
204
|
* ```
|
|
205
205
|
*
|
|
@@ -225,18 +225,18 @@ export declare function isValidHttpUrl(url: string, options?: {
|
|
|
225
225
|
* Usage:
|
|
226
226
|
*
|
|
227
227
|
* ```javascript
|
|
228
|
-
* const ret1 = getUrlFileType(
|
|
229
|
-
* const ret2 = getUrlFileType(
|
|
230
|
-
* const ret3 = getUrlFileType(
|
|
231
|
-
* const ret4 = getUrlFileType(
|
|
232
|
-
* const ret5 = getUrlFileType(
|
|
228
|
+
* const ret1 = getUrlFileType("https://example.com/a/b/c.png");
|
|
229
|
+
* const ret2 = getUrlFileType("https://example.com/a/b/c.jpg");
|
|
230
|
+
* const ret3 = getUrlFileType("https://example.com/a/b/c.jpeg");
|
|
231
|
+
* const ret4 = getUrlFileType("/a/b/c.jpeg");
|
|
232
|
+
* const ret5 = getUrlFileType("https://example.com/a/b/c.v/a");
|
|
233
233
|
* console.log(ret1, ret2, ret3, ret4, ret5);
|
|
234
234
|
* ```
|
|
235
235
|
*
|
|
236
236
|
* Output:
|
|
237
237
|
*
|
|
238
238
|
* ```text
|
|
239
|
-
* png jpg jpeg jpeg
|
|
239
|
+
* png jpg jpeg jpeg ""
|
|
240
240
|
* ```
|
|
241
241
|
*
|
|
242
242
|
* @param url
|
|
@@ -250,7 +250,7 @@ export declare function getUrlFileType(url: string): boolean | string;
|
|
|
250
250
|
* Usage:
|
|
251
251
|
*
|
|
252
252
|
* ```javascript
|
|
253
|
-
* const ret = getScriptQueryParam(
|
|
253
|
+
* const ret = getScriptQueryParam("test", "https://example.com/example.js");
|
|
254
254
|
* console.log(ret);
|
|
255
255
|
* ```
|
|
256
256
|
*
|
|
@@ -273,7 +273,7 @@ export declare function getScriptQueryParam(param: string, matchString?: string)
|
|
|
273
273
|
* Usage:
|
|
274
274
|
*
|
|
275
275
|
* ```javascript
|
|
276
|
-
* const ret = convertObjectToQuery({ t1:
|
|
276
|
+
* const ret = convertObjectToQuery({ t1: "1", t2: "2", t3: "3", t4: "4" });
|
|
277
277
|
* console.log(ret);
|
|
278
278
|
* ```
|
|
279
279
|
*
|
|
@@ -296,7 +296,7 @@ export declare function convertObjectToQuery(obj: {
|
|
|
296
296
|
* Usage:
|
|
297
297
|
*
|
|
298
298
|
* ```javascript
|
|
299
|
-
* const ret = convertHttpToHttps(
|
|
299
|
+
* const ret = convertHttpToHttps("http://example.com");
|
|
300
300
|
* console.log(ret);
|
|
301
301
|
* ```
|
|
302
302
|
*
|
|
@@ -325,7 +325,7 @@ export declare function replaceHttp(url: string): string;
|
|
|
325
325
|
* ```javascript
|
|
326
326
|
* import { getUrlHost } from "mazey";
|
|
327
327
|
*
|
|
328
|
-
* const ret = getUrlHost(
|
|
328
|
+
* const ret = getUrlHost("https://example.com/path/to/page");
|
|
329
329
|
* console.log(ret);
|
|
330
330
|
* ```
|
|
331
331
|
*
|
|
@@ -348,7 +348,7 @@ export declare function getUrlHost(url: string): string;
|
|
|
348
348
|
* ```javascript
|
|
349
349
|
* import { getUrlPath } from "mazey";
|
|
350
350
|
*
|
|
351
|
-
* const ret = getUrlPath(
|
|
351
|
+
* const ret = getUrlPath("https://example.com/path/to/page");
|
|
352
352
|
* console.log(ret);
|
|
353
353
|
* ```
|
|
354
354
|
*
|