tenacity-tools
Version:
tenacity's js tool library
1 lines • 16 kB
JavaScript
var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{FN:()=>c,Mi:()=>Ee,YN:()=>H,JG:()=>u,_o:()=>ke,x5:()=>a,ej:()=>p,l7:()=>y,Ph:()=>d,kD:()=>v,tq:()=>f,oE:()=>De,UG:()=>l,Y2:()=>i,Td:()=>s,gz:()=>Se});var n=function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},r=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(Q){a(Q)}}function c(e){try{u(r.throw(e))}catch(Q){a(Q)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}u((r=r.apply(e,t||[])).next())}))},o=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"===typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(Q){a=[6,Q],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}},a=function(){var e=document.body,t=document.documentElement;return e.clientWidth||t.clientWidth||window.innerWidth||375},i=a()/375,c={info:function(e,t,n){void 0===t&&(t=2);var r=n||document.body,o=document.createElement("div");o.innerText=e,o.style.position=n?"absolute":"fixed",o.style.left="50%",o.style.top="50%",o.style.maxWidth="150px",o.style.lineHeight="20px",o.style.transform="translate(-50%, -50%)",o.style.backgroundColor="rgba(0, 0, 0, 0.8)",o.style.padding="8px 15px",o.style.borderRadius="5px",o.style.fontSize="12px",o.style.color="#ffffff",o.style.zIndex="99999",r.appendChild(o),setTimeout((function(){r.removeChild(o)}),1e3*t)},success:function(e,t){void 0===t&&(t=2),this.info(e,t)},fail:function(e,t){void 0===t&&(t=2),this.info(e,t)}},u=function(e,t){return void 0===t&&(t=!1),r(void 0,void 0,void 0,(function(){var n,r;return o(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),navigator.clipboard&&navigator.clipboard.writeText?[4,navigator.clipboard.writeText(e)]:[3,2];case 1:return o.sent(),t&&c.info("\u590d\u5236\u6210\u529f"),[3,3];case 2:(n=document.createElement("textarea")).value=e,n.style.position="absolute",n.style.left="-9999px",document.body.appendChild(n),n.select(),document.execCommand("copy"),t&&c.info("\u590d\u5236\u6210\u529f"),document.body.removeChild(n),o.label=3;case 3:return[3,5];case 4:return r=o.sent(),console.error("\u590d\u5236\u5931\u8d25:",r),[3,5];case 5:return[2]}}))}))},s=function(e){document.title=e;var t=document.createElement("iframe");t.style.cssText="display: none; width: 0; height: 0;",t.src="";var n=function(){setTimeout((function(){t.removeEventListener("load",n),setTimeout((function(){document.body.removeChild(t)}),0)}),0)};t.addEventListener("load",n),document.body.appendChild(t)},l=function(e){void 0===e&&(e=window.location.search);var t=e.indexOf("?"),n=(t>-1?e.slice(t+1):e).split("&"),r={};return n.forEach((function(e){var t=e.split("=");r[t[0]]=t[1]})),r},d=function(e){var t=window.location,r=t.hash,o=t.search,a=r.indexOf("?"),i={};return a>-1&&(i=l(r.slice(a))),o&&(i=n(n({},i),l(o))),e?i[e]||null:i},f=function(){return/Android|webOS|iPhone|iPod|BlackBerry/i.test(window.navigator.userAgent)},p=function(e){if(!document.cookie||!window.navigator.cookieEnabled)return"";var t=new RegExp("".concat(e,"=([\\w]+)"));return(document.cookie.match(t)||[])[1]},v=function(){return Math.random().toString(36).slice(2)},y=function(e){var t=e||window.navigator.userAgent.toLowerCase();return/windows/.test(t)?"windows":/iphone|ipod/.test(t)?"ios":/ipad/.test(t)?"ipad":/android/.test(t)?"android":/mac/.test(t)?"mac":"others"},h=[19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448],g=["\u7532","\u4e59","\u4e19","\u4e01","\u620a","\u5df1","\u5e9a","\u8f9b","\u58ec","\u7678"],m=["\u5b50","\u4e11","\u5bc5","\u536f","\u8fb0","\u5df3","\u5348","\u672a","\u7533","\u9149","\u620c","\u4ea5"],b=new Date,w=b.getFullYear(),x=b.getMonth(),C=b.getDate(),T=b.getFullYear(),D=b.getMonth()+1,S=b.getDate(),E=b.getHours(),k=b.getMinutes(),M=b.getSeconds(),O=D.toString().padStart(2,"0"),A=S.toString().padStart(2,"0"),U=E.toString().padStart(2,"0"),P=k.toString().padStart(2,"0"),Y=M.toString().padStart(2,"0");function L(e){return 15&h[e-1900]}function R(e){return L(e)?65536&h[e-1900]?30:29:0}function j(e){var t,n=348;for(t=32768;t>8;t>>=1)n+=h[e-1900]&t?1:0;return n+R(e)}function z(e,t){return h[e-1900]&65536>>t?30:29}function B(e,t){var n,r,o=["\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d","\u4e03","\u516b","\u4e5d","\u5341"];switch(n=e>10?"\u5341"+o[e-10]:o[e],n+="\u6708",t){case 10:r="\u521d\u5341";break;case 20:r="\u4e8c\u5341";break;case 30:r="\u4e09\u5341";break;default:r=["\u521d","\u5341","\u5eff","\u5345",""][Math.floor(t/10)]+o[t%10]}return{lunarMonthCn:n,lunarDayCn:r}}var I={};I.gregorianYear=T,I.gregorianMonth=O,I.gregorianDay=A,I.weekday=["\u661f\u671f\u65e5","\u661f\u671f\u4e00","\u661f\u671f\u4e8c","\u661f\u671f\u4e09","\u661f\u671f\u56db","\u661f\u671f\u4e94","\u661f\u671f\u516d"][b.getDay()],I.weekdayEn=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][b.getDay()],I.hours=U,I.minutes=P,I.seconds=Y;var N,W,F,G,_,q=function(e){var t,n=0,r=new Date(1900,0,31),o=Math.floor((e.getTime()-r.getTime())/864e5),a=o+40,i=14;for(t=1900;t<2050&&o>0;t++)o-=n=j(t),i+=12;o<0&&(o+=n,t--,i-=12);var c=t,u=t-1864,s=L(t),l=!1;for(t=1;t<13&&o>0;t++)s>0&&t===s+1&&!1===l?(--t,l=!0,n=R(c)):n=z(c,t),!0===l&&t===s+1&&(l=!1),o-=n,!1===l&&i++;return 0===o&&s>0&&t===s+1&&(l?l=!1:(l=!0,--t,--i)),o<0&&(o+=n,--t,--i),{year:c,month:t,day:o+1,isLeap:l,leap:s,yearCyl:u,dayCyl:a,monCyl:i}}(new Date(w,x,C));I.lunarYear=q.year,I.lunarMonth=q.month,I.lunarDay=q.day,I.zodiacYear=["\u9f20","\u725b","\u864e","\u5154","\u9f99","\u86c7","\u9a6c","\u7f8a","\u7334","\u9e21","\u72d7","\u732a"][(w-4)%12],I.lunarYearCn=g[(N=w-1900+36)%10]+m[N%12],I.lunarMonthCn=B(q.month,q.day).lunarMonthCn,I.lunarDayCn=B(q.month,q.day).lunarDayCn,I.solarTerm=(W=[0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758],F=["\u5c0f\u5bd2","\u5927\u5bd2","\u7acb\u6625","\u96e8\u6c34","\u60ca\u86f0","\u6625\u5206","\u6e05\u660e","\u8c37\u96e8","\u7acb\u590f","\u5c0f\u6ee1","\u8292\u79cd","\u590f\u81f3","\u5c0f\u6691","\u5927\u6691","\u7acb\u79cb","\u5904\u6691","\u767d\u9732","\u79cb\u5206","\u5bd2\u9732","\u971c\u964d","\u7acb\u51ac","\u5c0f\u96ea","\u5927\u96ea","\u51ac\u81f3"],G="",_=new Date(31556925974.7*(w-1900)+6e4*W[2*x+1]+Date.UTC(1900,0,6,2,5)),_.getUTCDate()===C&&(G=F[2*x+1]),(_=new Date(31556925974.7*(w-1900)+6e4*W[2*x]+Date.UTC(1900,0,6,2,5))).getUTCDate()===C&&(G=F[2*x]),G);const H=I;function J(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{u(r.next(e))}catch(e){a(e)}}function c(e){try{u(r.throw(e))}catch(e){a(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}u((r=r.apply(e,t||[])).next())}))}function Q(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function c(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!((o=(o=i.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}var K=function(e){};function V(e){K(e)}var X=!0;function Z(){return X}(function(){(console.warn||console.log).apply(console,arguments)}).bind("[clipboard-polyfill]");var $,ee,te,ne,re="undefined"==typeof navigator?void 0:navigator,oe=null==re?void 0:re.clipboard,ae=(null===($=null==oe?void 0:oe.read)||void 0===$||$.bind(oe),null===(ee=null==oe?void 0:oe.readText)||void 0===ee||ee.bind(oe),null===(te=null==oe?void 0:oe.write)||void 0===te?void 0:te.bind(oe)),ie=(null===(ne=null==oe?void 0:oe.writeText)||void 0===ne||ne.bind(oe),"undefined"==typeof window?void 0:window),ce=null==ie?void 0:ie.ClipboardItem,ue=ie;function se(){return"undefined"==typeof ClipboardEvent&&void 0!==ue.clipboardData&&void 0!==ue.clipboardData.setData}var le=function(){this.success=!1};function de(e,t,n){for(var r in V("listener called"),e.success=!0,t){var o=t[r],a=n.clipboardData;a.setData(r,o),"text/plain"===r&&a.getData(r)!==o&&(V("setting text/plain failed"),e.success=!1)}n.preventDefault()}function fe(e){var t=new le,n=de.bind(this,t,e);document.addEventListener("copy",n);try{document.execCommand("copy")}finally{document.removeEventListener("copy",n)}return t.success}function pe(e,t){ve(e);var n=fe(t);return ye(),n}function ve(e){var t=document.getSelection();if(t){var n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}}function ye(){var e=document.getSelection();e&&e.removeAllRanges()}function he(e){return J(this,void 0,void 0,(function(){var t;return Q(this,(function(n){if(t="text/plain"in e,se()){if(!t)throw new Error("No `text/plain` value was specified.");if(r=e["text/plain"],ue.clipboardData.setData("Text",r))return[2,!0];throw new Error("Copying failed, possibly because the user rejected it.")}var r;return fe(e)?(V("regular execCopy worked"),[2,!0]):navigator.userAgent.indexOf("Edge")>-1?(V('UA "Edge" => assuming success'),[2,!0]):pe(document.body,e)?(V("copyUsingTempSelection worked"),[2,!0]):function(e){var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important"),t.textContent="temporary element",document.body.appendChild(t);var n=pe(t,e);return document.body.removeChild(t),n}(e)?(V("copyUsingTempElem worked"),[2,!0]):function(e){V("copyTextUsingDOM");var t=document.createElement("div");t.setAttribute("style","-webkit-user-select: text !important");var n=t;t.attachShadow&&(V("Using shadow DOM."),n=t.attachShadow({mode:"open"}));var r=document.createElement("span");r.innerText=e,n.appendChild(r),document.body.appendChild(t),ve(r);var o=document.execCommand("copy");return ye(),document.body.removeChild(t),o}(e["text/plain"])?(V("copyTextUsingDOM worked"),[2,!0]):[2,!1]}))}))}function ge(e,t){for(var n=0,r=e;n<r.length;n++)if(-1!==r[n].types.indexOf(t))return!0;return!1}var me=function(){function e(e,t){var n;for(var r in void 0===t&&(t={}),this.types=Object.keys(e),this._items={},e){var o=e[r];this._items[r]="string"==typeof o?be(r,o):o}this.presentationStyle=null!==(n=null==t?void 0:t.presentationStyle)&&void 0!==n?n:"unspecified"}return e.prototype.getType=function(e){return J(this,void 0,void 0,(function(){return Q(this,(function(t){return[2,this._items[e]]}))}))},e}();function be(e,t){return new Blob([t],{type:e})}function we(e){return J(this,void 0,void 0,(function(){return Q(this,(function(t){return[2,new Promise((function(t,n){var r=new FileReader;r.addEventListener("load",(function(){var e=r.result;"string"==typeof e?t(e):n("could not convert blob to string")})),r.readAsText(e)}))]}))}))}function xe(e){return J(this,void 0,void 0,(function(){var t,n,r,o,a,i,c;return Q(this,(function(u){switch(u.label){case 0:t={},n=0,r=e.types,u.label=1;case 1:return n<r.length?(o=r[n],a=t,i=o,[4,e.getType(o)]):[3,4];case 2:a[i]=u.sent(),u.label=3;case 3:return n++,[3,1];case 4:return c={},e.presentationStyle&&(c.presentationStyle=e.presentationStyle),[2,new ce(t,c)]}}))}))}function Ce(e,t){return J(this,void 0,void 0,(function(){return Q(this,(function(n){switch(n.label){case 0:return[4,e.getType(t)];case 1:return[4,we(n.sent())];case 2:return[2,n.sent()]}}))}))}function Te(e){return J(this,void 0,void 0,(function(){var t,n,r,o,a,i;return Q(this,(function(c){switch(c.label){case 0:t={},n=0,r=e.types,c.label=1;case 1:return n<r.length?(o=r[n],a=t,i=o,[4,Ce(e,o)]):[3,4];case 2:a[i]=c.sent(),c.label=3;case 3:return n++,[3,1];case 4:return[2,t]}}))}))}var De=function(){var e=new IntersectionObserver((function(e){e.forEach((function(e){e.isIntersecting&&e.target.dataset.src&&(e.target.src=e.target.dataset.src)}))}));Array.from(document.getElementsByTagName("img")).filter((function(e){return!e.getAttribute("src")})).forEach((function(t){e.observe(t)}))},Se="IntersectionObserver"in window,Ee=function(e,t,n){void 0===t&&(t="image/png"),void 0===n&&(n=512);for(var r=window.atob(e.split(",")[1]),o=[],a=0;a<r.length;a+=n){for(var i=r.slice(a,a+n),c=new Array(i.length),u=0;u<i.length;u++)c[u]=i.charCodeAt(u);var s=new Uint8Array(c);o.push(s)}return new Blob(o,{type:t})},ke=function(e,t){!function(e){J(this,void 0,void 0,(function(){var t,n,r,o;return Q(this,(function(a){switch(a.label){case 0:return ae&&ce?(V("Using `navigator.clipboard.write()`."),[4,Promise.all(e.map(xe))]):[3,5];case 1:t=a.sent(),a.label=2;case 2:return a.trys.push([2,4,,5]),[4,ae(t)];case 3:return[2,a.sent()];case 4:if(n=a.sent(),!ge(e,"text/plain")&&!ge(e,"text/html"))throw n;return[3,5];case 5:return r=ge(e,"text/plain"),Z&&!r&&V("clipboard.write() was called without a `text/plain` data type. On some platforms, this may result in an empty clipboard. Call suppressWarnings() to suppress this warning."),o=he,[4,Te(e[0])];case 6:if(!o.apply(void 0,[a.sent()]))throw new Error("write() failed");return[2]}}))}))}([new me({"image/png":Ee(e)})]),t&&c.success("\u590d\u5236\u6210\u529f")},Me=t.FN,Oe=t.Mi,Ae=t.YN,Ue=t.JG,Pe=t._o,Ye=t.x5,Le=t.ej,Re=t.l7,je=t.Ph,ze=t.kD,Be=t.tq,Ie=t.oE,Ne=t.UG,We=t.Y2,Fe=t.Td,Ge=t.gz;export{Me as Toast,Oe as b64toBlob,Ae as calendar,Ue as copy,Pe as copyBase64Img,Ye as getClientWidth,Le as getCookie,Re as getDeviceType,je as getQueryParam,ze as getRandomStr,Be as isMobile,Ie as lazyLoadImg,Ne as parseSearch,We as screenRate,Fe as setTitle,Ge as supportLazy};