w-mousekey 1.0.12 → 1.0.13
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/dist/action.umd.js +1 -1
- package/dist/ck-pic.umd.js +2 -2
- package/dist/ck-pic.umd.js.map +1 -1
- package/dist/ck-pics.umd.js +1 -1
- package/dist/compare.umd.js +2 -2
- package/dist/compare.umd.js.map +1 -1
- package/dist/get-ahk.umd.js +1 -1
- package/dist/get-settings.umd.js +1 -1
- package/dist/mousekey.umd.js +1 -1
- package/dist/rec-scp.umd.js +1 -1
- package/dist/run-scp.umd.js +1 -1
- package/dist/screen.umd.js +1 -1
- package/dist/wait-pics.umd.js +2 -2
- package/dist/wait-pics.umd.js.map +1 -1
- package/docs/index.html +1 -1
- package/package.json +1 -1
- package/src/compare.mjs +6 -3
package/dist/wait-pics.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wait-pics v1.0.
|
|
2
|
+
* wait-pics v1.0.13
|
|
3
3
|
* (c) 2018-2021 yuda-lyu(semisphere)
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("fs"),require("child_process"),require("util"),require("path"),require("screenshot-desktop"),require("sharp"),require("@u4/opencv4nodejs")):"function"==typeof define&&define.amd?define(["fs","child_process","util","path","screenshot-desktop","sharp","@u4/opencv4nodejs"],r):(t="undefined"!=typeof globalThis?globalThis:t||self)["wait-pics"]=r(t.fs,t.child_process,t.util,t.path,t["screenshot-desktop"],t.sharp,t["@u4/opencv4nodejs"])}(this,function(t,r,e,n,o,i,u){"use strict";var a=Array.isArray,f="object"==typeof global&&global&&global.Object===Object&&global,c="object"==typeof self&&self&&self.Object===Object&&self,l=f||c||Function("return this")(),s=l.Symbol,h=Object.prototype,d=h.hasOwnProperty,g=h.toString,b=s?s.toStringTag:void 0;var p=Object.prototype.toString;var v=s?s.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":v&&v in Object(t)?function(t){var r=d.call(t,b),e=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=g.call(t);return n&&(r?t[b]=e:delete t[b]),o}(t):function(t){return p.call(t)}(t)}function w(t){return null!=t&&"object"==typeof t}function m(t){return"symbol"==typeof t||w(t)&&"[object Symbol]"==y(t)}var _=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,j=/^\w*$/;function $(t,r){if(a(t))return!1;var e=typeof t;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=t&&!m(t))||(j.test(t)||!_.test(t)||null!=r&&t in Object(r))}function S(t){var r=typeof t;return null!=t&&("object"==r||"function"==r)}function k(t){if(!S(t))return!1;var r=y(t);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}var x,O=l["__core-js_shared__"],E=(x=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||""))?"Symbol(src)_1."+x:"";var P=Function.prototype.toString;function A(t){if(null!=t){try{return P.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var H=/^\[object .+?Constructor\]$/,R=Function.prototype,z=Object.prototype,M=R.toString,T=z.hasOwnProperty,F=RegExp("^"+M.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function C(t){return!(!S(t)||(r=t,E&&E in r))&&(k(t)?F:H).test(A(t));var r}function q(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return C(e)?e:void 0}var D=q(Object,"create");var B=Object.prototype.hasOwnProperty;var N=Object.prototype.hasOwnProperty;function L(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function I(t,r){return t===r||t!=t&&r!=r}function V(t,r){for(var e=t.length;e--;)if(I(t[e][0],r))return e;return-1}L.prototype.clear=function(){this.__data__=D?D(null):{},this.size=0},L.prototype.delete=function(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r},L.prototype.get=function(t){var r=this.__data__;if(D){var e=r[t];return"__lodash_hash_undefined__"===e?void 0:e}return B.call(r,t)?r[t]:void 0},L.prototype.has=function(t){var r=this.__data__;return D?void 0!==r[t]:N.call(r,t)},L.prototype.set=function(t,r){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=D&&void 0===r?"__lodash_hash_undefined__":r,this};var U=Array.prototype.splice;function G(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}G.prototype.clear=function(){this.__data__=[],this.size=0},G.prototype.delete=function(t){var r=this.__data__,e=V(r,t);return!(e<0)&&(e==r.length-1?r.pop():U.call(r,e,1),--this.size,!0)},G.prototype.get=function(t){var r=this.__data__,e=V(r,t);return e<0?void 0:r[e][1]},G.prototype.has=function(t){return V(this.__data__,t)>-1},G.prototype.set=function(t,r){var e=this.__data__,n=V(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var W=q(l,"Map");function J(t,r){var e,n,o=t.__data__;return("string"==(n=typeof(e=r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==e:null===e)?o["string"==typeof r?"string":"hash"]:o.map}function K(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}K.prototype.clear=function(){this.size=0,this.__data__={hash:new L,map:new(W||G),string:new L}},K.prototype.delete=function(t){var r=J(this,t).delete(t);return this.size-=r?1:0,r},K.prototype.get=function(t){return J(this,t).get(t)},K.prototype.has=function(t){return J(this,t).has(t)},K.prototype.set=function(t,r){var e=J(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this};function Q(t,r){if("function"!=typeof t||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var e=function(){var n=arguments,o=r?r.apply(this,n):n[0],i=e.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return e.cache=i.set(o,u)||i,u};return e.cache=new(Q.Cache||K),e}Q.Cache=K;var X,Y,Z,tt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rt=/\\(\\)?/g,et=(X=function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(tt,function(t,e,n,o){r.push(n?o.replace(rt,"$1"):e||t)}),r},Y=Q(X,function(t){return 500===Z.size&&Z.clear(),t}),Z=Y.cache,Y),nt=et;function ot(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e<n;)o[e]=r(t[e],e,t);return o}var it=s?s.prototype:void 0,ut=it?it.toString:void 0;function at(t){if("string"==typeof t)return t;if(a(t))return ot(t,at)+"";if(m(t))return ut?ut.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}function ft(t){return null==t?"":at(t)}function ct(t,r){return a(t)?t:$(t,r)?[t]:nt(ft(t))}function lt(t){if("string"==typeof t||m(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}function st(t,r){for(var e=0,n=(r=ct(r,t)).length;null!=t&&e<n;)t=t[lt(r[e++])];return e&&e==n?t:void 0}function ht(t,r,e){var n=null==t?void 0:st(t,r);return void 0===n?e:n}var dt=Object.prototype;var gt=function(t,r){return function(e){return t(r(e))}}(Object.keys,Object),bt=gt,pt=Object.prototype.hasOwnProperty;function vt(t){if(e=(r=t)&&r.constructor,r!==("function"==typeof e&&e.prototype||dt))return bt(t);var r,e,n=[];for(var o in Object(t))pt.call(t,o)&&"constructor"!=o&&n.push(o);return n}var yt=q(l,"DataView"),wt=q(l,"Promise"),mt=q(l,"Set"),_t=q(l,"WeakMap"),jt="[object Map]",$t="[object Promise]",St="[object Set]",kt="[object WeakMap]",xt="[object DataView]",Ot=A(yt),Et=A(W),Pt=A(wt),At=A(mt),Ht=A(_t),Rt=y;(yt&&Rt(new yt(new ArrayBuffer(1)))!=xt||W&&Rt(new W)!=jt||wt&&Rt(wt.resolve())!=$t||mt&&Rt(new mt)!=St||_t&&Rt(new _t)!=kt)&&(Rt=function(t){var r=y(t),e="[object Object]"==r?t.constructor:void 0,n=e?A(e):"";if(n)switch(n){case Ot:return xt;case Et:return jt;case Pt:return $t;case At:return St;case Ht:return kt}return r});var zt=Rt;function Mt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function Tt(t){return null!=t&&Mt(t.length)&&!k(t)}function Ft(t){return function(r){return null==r?void 0:r[t]}}var Ct=Ft("length"),qt=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");function Dt(t){return qt.test(t)}var Bt="\\ud800-\\udfff",Nt="["+Bt+"]",Lt="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",It="\\ud83c[\\udffb-\\udfff]",Vt="[^"+Bt+"]",Ut="(?:\\ud83c[\\udde6-\\uddff]){2}",Gt="[\\ud800-\\udbff][\\udc00-\\udfff]",Wt="(?:"+Lt+"|"+It+")"+"?",Jt="[\\ufe0e\\ufe0f]?",Kt=Jt+Wt+("(?:\\u200d(?:"+[Vt,Ut,Gt].join("|")+")"+Jt+Wt+")*"),Qt="(?:"+[Vt+Lt+"?",Lt,Ut,Gt,Nt].join("|")+")",Xt=RegExp(It+"(?="+It+")|"+Qt+Kt,"g");function Yt(t){return Dt(t)?function(t){for(var r=Xt.lastIndex=0;Xt.test(t);)++r;return r}(t):Ct(t)}function Zt(t){if(null==t)return 0;if(Tt(t))return"string"==typeof(r=t)||!a(r)&&w(r)&&"[object String]"==y(r)?Yt(t):t.length;var r,e=zt(t);return"[object Map]"==e||"[object Set]"==e?t.size:vt(t).length}function tr(t){return"[object String]"===Object.prototype.toString.call(t)}function rr(t){return!(!tr(t)||""===t)}function er(){let t,r,e=new Promise(function(){t=arguments[0],r=arguments[1]});return e.resolve=t,e.reject=r,e}function nr(t){let r=!1;if(rr(t))r=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(function(t){return t!=t}(t))return!1;r=!0}return r}function or(t=10){nr(t)||(t=10);let r=er();return setTimeout(function(){r.resolve()},t),r}function ir(r){return function(t,r={}){let e=ht(r,"fs");return!!e.existsSync(t)&&!e.lstatSync(t).isDirectory()&&!e.lstatSync(t).isSymbolicLink()}(r,{fs:t})}function ur(t,r={}){let e=ht(r,"fs");if(!e.existsSync(t))return!1;let n=e.lstatSync(t);return!n.isFile()&&!n.isSymbolicLink()}function ar(r){return ur(r,{fs:t})}function fr(r){return function(t,r={}){let e=ht(r,"fs");if(ur(t,{fs:e}))return{success:"input folder is already exists: "+t};if(e.existsSync(t))return{error:"input path already exists: "+t};try{e.mkdirSync(t,{recursive:!0})}catch(t){return{error:t}}return{success:"done: "+t}}(r,{fs:t})}let cr=e.promisify(r.execFile),lr=function(){let t=n.resolve(),r="AutoHotkey64.exe",e="";{let n=`${t}/AutoHotkey_2.0.19/`,o=`${t}/node_modules/w-mousekey/AutoHotkey_2.0.19/`;if(ir(`${n}${r}`))e=n;else{if(!ir(`${o}${r}`))throw new Error("can not find folder for AutoHotkey");e=o}}return{ahkExePath:`${e}/AutoHotkey64.exe`,ahkScriptPathClick:`${e}/zclick.ahk`,ahkScriptPathDrag:`${e}/zdrag.ahk`,ahkScriptPathSend:`${e}/zsend.ahk`,ahkScriptPathRecord:`${e}/zrecord.ahk`}}();async function sr(t,r,e=[]){let n=er();try{let{stdout:o,stderr:i}=await cr(t,["/force",r,...e]);i?n.reject(i):n.resolve(o)}catch(t){n.reject(t)}return n}let hr={mouseClick:async function(t,r){await sr(lr.ahkExePath,lr.ahkScriptPathClick,[t,r])},mouseDrag:async function(t,r,e,n){await sr(lr.ahkExePath,lr.ahkScriptPathDrag,[t,r,e,n])},sendKey:async function(t){await sr(lr.ahkExePath,lr.ahkScriptPathSend,[`${t}`])},sendString:async function(t){await sr(lr.ahkExePath,lr.ahkScriptPathSend,[`${t}`])}};async function dr(){let t=await o({format:"png"});if(!t||0===t.length)throw console.log("img",t),new Error("can not get the screenshot");return t}let gr={screenFull:async function(){return await dr()},screen:async function(t,r,e,n){let o=await dr();return await i(o).extract({left:t,top:r,width:e,height:n}).toBuffer()},screenFullSave:async function(r){let e=await dr();return t.writeFileSync(r,e),e},screenSave:async function(r,e,n,o,u){let a=await dr(),f=await i(a).extract({left:r,top:e,width:n,height:o}).toBuffer();return t.writeFileSync(u,f),f}};function br(t){return!0===(r=t)||!1===r||w(r)&&"[object Boolean]"==y(r);var r}var pr=/\s/;var vr=/^\s+/;function yr(t){return t?t.slice(0,function(t){for(var r=t.length;r--&&pr.test(t.charAt(r)););return r}(t)+1).replace(vr,""):t}var wr=/^[-+]0x[0-9a-f]+$/i,mr=/^0b[01]+$/i,_r=/^0o[0-7]+$/i,jr=parseInt;function $r(t){if("number"==typeof t)return t;if(m(t))return NaN;if(S(t)){var r="function"==typeof t.valueOf?t.valueOf():t;t=S(r)?r+"":r}if("string"!=typeof t)return 0===t?t:+t;t=yr(t);var e=mr.test(t);return e||_r.test(t)?jr(t.slice(2),e?2:8):wr.test(t)?NaN:+t}var Sr=1/0;function kr(t){return t?(t=$r(t))===Sr||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function xr(t){var r=kr(t),e=r%1;return r==r?e?r-e:r:0}function Or(t){if(!nr(t))return 0;return kr(t)}function Er(t){return!!nr(t)&&(t=Or(t),"number"==typeof(r=t)&&r==xr(r));var r}var Pr=l.isFinite,Ar=Math.min;var Hr=function(t){var r=Math[t];return function(t,e){if(t=$r(t),(e=null==e?0:Ar(xr(e),292))&&Pr(t)){var n=(ft(t)+"e").split("e");return+((n=(ft(r(n[0]+"e"+(+n[1]+e)))+"e").split("e"))[0]+"e"+(+n[1]-e))}return r(t)}}("round"),Rr=Hr;function zr(t){if(!nr(t))return 0;t=Or(t);let r=Rr(t);return"0"===String(r)?0:r}function Mr(t){if(!Er(t))return!1;return zr(t)>0}function Tr(t,r,e){var n=t.length;return e=void 0===e?n:e,!r&&e>=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+r];return i}(t,r,e)}function Fr(t){return t!=t}function Cr(t,r,e){return r==r?function(t,r,e){for(var n=e-1,o=t.length;++n<o;)if(t[n]===r)return n;return-1}(t,r,e):function(t,r,e,n){for(var o=t.length,i=e+(n?1:-1);n?i--:++i<o;)if(r(t[i],i,t))return i;return-1}(t,Fr,e)}var qr="\\ud800-\\udfff",Dr="["+qr+"]",Br="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Nr="\\ud83c[\\udffb-\\udfff]",Lr="[^"+qr+"]",Ir="(?:\\ud83c[\\udde6-\\uddff]){2}",Vr="[\\ud800-\\udbff][\\udc00-\\udfff]",Ur="(?:"+Br+"|"+Nr+")"+"?",Gr="[\\ufe0e\\ufe0f]?",Wr=Gr+Ur+("(?:\\u200d(?:"+[Lr,Ir,Vr].join("|")+")"+Gr+Ur+")*"),Jr="(?:"+[Lr+Br+"?",Br,Ir,Vr,Dr].join("|")+")",Kr=RegExp(Nr+"(?="+Nr+")|"+Jr+Wr,"g");function Qr(t){return Dt(t)?function(t){return t.match(Kr)||[]}(t):function(t){return t.split("")}(t)}function Xr(t,r,e){if((t=ft(t))&&(e||void 0===r))return yr(t);if(!t||!(r=at(r)))return t;var n=Qr(t),o=Qr(r),i=function(t,r){for(var e=-1,n=t.length;++e<n&&Cr(r,t[e],0)>-1;);return e}(n,o),u=function(t,r){for(var e=t.length;e--&&Cr(r,t[e],0)>-1;);return e}(n,o)+1;return Tr(n,i,u).join("")}function Yr(t){var r=this.__data__=new G(t);this.size=r.size}Yr.prototype.clear=function(){this.__data__=new G,this.size=0},Yr.prototype.delete=function(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e},Yr.prototype.get=function(t){return this.__data__.get(t)},Yr.prototype.has=function(t){return this.__data__.has(t)},Yr.prototype.set=function(t,r){var e=this.__data__;if(e instanceof G){var n=e.__data__;if(!W||n.length<199)return n.push([t,r]),this.size=++e.size,this;e=this.__data__=new K(n)}return e.set(t,r),this.size=e.size,this};function Zr(t){var r=-1,e=null==t?0:t.length;for(this.__data__=new K;++r<e;)this.add(t[r])}function te(t,r){for(var e=-1,n=null==t?0:t.length;++e<n;)if(r(t[e],e,t))return!0;return!1}function re(t,r){return t.has(r)}Zr.prototype.add=Zr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Zr.prototype.has=function(t){return this.__data__.has(t)};function ee(t,r,e,n,o,i){var u=1&e,a=t.length,f=r.length;if(a!=f&&!(u&&f>a))return!1;var c=i.get(t),l=i.get(r);if(c&&l)return c==r&&l==t;var s=-1,h=!0,d=2&e?new Zr:void 0;for(i.set(t,r),i.set(r,t);++s<a;){var g=t[s],b=r[s];if(n)var p=u?n(b,g,s,r,t,i):n(g,b,s,t,r,i);if(void 0!==p){if(p)continue;h=!1;break}if(d){if(!te(r,function(t,r){if(!re(d,r)&&(g===t||o(g,t,e,n,i)))return d.push(r)})){h=!1;break}}else if(g!==b&&!o(g,b,e,n,i)){h=!1;break}}return i.delete(t),i.delete(r),h}var ne=l.Uint8Array;function oe(t){var r=-1,e=Array(t.size);return t.forEach(function(t,n){e[++r]=[n,t]}),e}function ie(t){var r=-1,e=Array(t.size);return t.forEach(function(t){e[++r]=t}),e}var ue=s?s.prototype:void 0,ae=ue?ue.valueOf:void 0;function fe(t,r){for(var e=-1,n=r.length,o=t.length;++e<n;)t[o+e]=r[e];return t}var ce=Object.prototype.propertyIsEnumerable,le=Object.getOwnPropertySymbols,se=le?function(t){return null==t?[]:(t=Object(t),function(t,r){for(var e=-1,n=null==t?0:t.length,o=0,i=[];++e<n;){var u=t[e];r(u,e,t)&&(i[o++]=u)}return i}(le(t),function(r){return ce.call(t,r)}))}:function(){return[]},he=se;function de(t){return w(t)&&"[object Arguments]"==y(t)}var ge=Object.prototype,be=ge.hasOwnProperty,pe=ge.propertyIsEnumerable,ve=de(function(){return arguments}())?de:function(t){return w(t)&&be.call(t,"callee")&&!pe.call(t,"callee")},ye=ve;var we="object"==typeof exports&&exports&&!exports.nodeType&&exports,me=we&&"object"==typeof module&&module&&!module.nodeType&&module,_e=me&&me.exports===we?l.Buffer:void 0,je=(_e?_e.isBuffer:void 0)||function(){return!1},$e=/^(?:0|[1-9]\d*)$/;function Se(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&$e.test(t))&&t>-1&&t%1==0&&t<r}var ke={};function xe(t){return function(r){return t(r)}}ke["[object Float32Array]"]=ke["[object Float64Array]"]=ke["[object Int8Array]"]=ke["[object Int16Array]"]=ke["[object Int32Array]"]=ke["[object Uint8Array]"]=ke["[object Uint8ClampedArray]"]=ke["[object Uint16Array]"]=ke["[object Uint32Array]"]=!0,ke["[object Arguments]"]=ke["[object Array]"]=ke["[object ArrayBuffer]"]=ke["[object Boolean]"]=ke["[object DataView]"]=ke["[object Date]"]=ke["[object Error]"]=ke["[object Function]"]=ke["[object Map]"]=ke["[object Number]"]=ke["[object Object]"]=ke["[object RegExp]"]=ke["[object Set]"]=ke["[object String]"]=ke["[object WeakMap]"]=!1;var Oe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ee=Oe&&"object"==typeof module&&module&&!module.nodeType&&module,Pe=Ee&&Ee.exports===Oe&&f.process,Ae=function(){try{var t=Ee&&Ee.require&&Ee.require("util").types;return t||Pe&&Pe.binding&&Pe.binding("util")}catch(t){}}(),He=Ae&&Ae.isTypedArray,Re=He?xe(He):function(t){return w(t)&&Mt(t.length)&&!!ke[y(t)]},ze=Object.prototype.hasOwnProperty;function Me(t,r){var e=a(t),n=!e&&ye(t),o=!e&&!n&&je(t),i=!e&&!n&&!o&&Re(t),u=e||n||o||i,f=u?function(t,r){for(var e=-1,n=Array(t);++e<t;)n[e]=r(e);return n}(t.length,String):[],c=f.length;for(var l in t)!r&&!ze.call(t,l)||u&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Se(l,c))||f.push(l);return f}function Te(t){return Tt(t)?Me(t):vt(t)}function Fe(t){return function(t,r,e){var n=r(t);return a(t)?n:fe(n,e(t))}(t,Te,he)}var Ce=Object.prototype.hasOwnProperty;var qe="[object Arguments]",De="[object Array]",Be="[object Object]",Ne=Object.prototype.hasOwnProperty;function Le(t,r,e,n,o,i){var u=a(t),f=a(r),c=u?De:zt(t),l=f?De:zt(r),s=(c=c==qe?Be:c)==Be,h=(l=l==qe?Be:l)==Be,d=c==l;if(d&&je(t)){if(!je(r))return!1;u=!0,s=!1}if(d&&!s)return i||(i=new Yr),u||Re(t)?ee(t,r,e,n,o,i):function(t,r,e,n,o,i,u){switch(e){case"[object DataView]":if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=r.byteLength||!i(new ne(t),new ne(r)));case"[object Boolean]":case"[object Date]":case"[object Number]":return I(+t,+r);case"[object Error]":return t.name==r.name&&t.message==r.message;case"[object RegExp]":case"[object String]":return t==r+"";case"[object Map]":var a=oe;case"[object Set]":var f=1&n;if(a||(a=ie),t.size!=r.size&&!f)return!1;var c=u.get(t);if(c)return c==r;n|=2,u.set(t,r);var l=ee(a(t),a(r),n,o,i,u);return u.delete(t),l;case"[object Symbol]":if(ae)return ae.call(t)==ae.call(r)}return!1}(t,r,c,e,n,o,i);if(!(1&e)){var g=s&&Ne.call(t,"__wrapped__"),b=h&&Ne.call(r,"__wrapped__");if(g||b){var p=g?t.value():t,v=b?r.value():r;return i||(i=new Yr),o(p,v,e,n,i)}}return!!d&&(i||(i=new Yr),function(t,r,e,n,o,i){var u=1&e,a=Fe(t),f=a.length;if(f!=Fe(r).length&&!u)return!1;for(var c=f;c--;){var l=a[c];if(!(u?l in r:Ce.call(r,l)))return!1}var s=i.get(t),h=i.get(r);if(s&&h)return s==r&&h==t;var d=!0;i.set(t,r),i.set(r,t);for(var g=u;++c<f;){var b=t[l=a[c]],p=r[l];if(n)var v=u?n(p,b,l,r,t,i):n(b,p,l,t,r,i);if(!(void 0===v?b===p||o(b,p,e,n,i):v)){d=!1;break}g||(g="constructor"==l)}if(d&&!g){var y=t.constructor,w=r.constructor;y==w||!("constructor"in t)||!("constructor"in r)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(d=!1)}return i.delete(t),i.delete(r),d}(t,r,e,n,o,i))}function Ie(t,r,e,n,o){return t===r||(null==t||null==r||!w(t)&&!w(r)?t!=t&&r!=r:Le(t,r,e,n,Ie,o))}function Ve(t){return t==t&&!S(t)}function Ue(t,r){return function(e){return null!=e&&(e[t]===r&&(void 0!==r||t in Object(e)))}}function Ge(t){var r=function(t){for(var r=Te(t),e=r.length;e--;){var n=r[e],o=t[n];r[e]=[n,o,Ve(o)]}return r}(t);return 1==r.length&&r[0][2]?Ue(r[0][0],r[0][1]):function(e){return e===t||function(t,r,e,n){var o=e.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var a=e[o];if(u&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++o<i;){var f=(a=e[o])[0],c=t[f],l=a[1];if(u&&a[2]){if(void 0===c&&!(f in t))return!1}else{var s=new Yr;if(n)var h=n(c,l,f,t,r,s);if(!(void 0===h?Ie(l,c,3,n,s):h))return!1}}return!0}(e,t,r)}}function We(t,r){return null!=t&&r in Object(t)}function Je(t,r){return null!=t&&function(t,r,e){for(var n=-1,o=(r=ct(r,t)).length,i=!1;++n<o;){var u=lt(r[n]);if(!(i=null!=t&&e(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&Mt(o)&&Se(u,o)&&(a(t)||ye(t))}(t,r,We)}function Ke(t){return t}function Qe(t){return $(t)?Ft(lt(t)):function(t){return function(r){return st(r,t)}}(t)}function Xe(t){return"function"==typeof t?t:null==t?Ke:"object"==typeof t?a(t)?function(t,r){return $(t)&&Ve(r)?Ue(lt(t),r):function(e){var n=ht(e,t);return void 0===n&&n===r?Je(e,t):Ie(r,n,3)}}(t[0],t[1]):Ge(t):Qe(t)}var Ye,Ze=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),u=i.length;u--;){var a=i[Ye?u:++n];if(!1===r(o[a],a,o))break}return t};var tn=function(t,r){return function(e,n){if(null==e)return e;if(!Tt(e))return t(e,n);for(var o=e.length,i=r?o:-1,u=Object(e);(r?i--:++i<o)&&!1!==n(u[i],i,u););return e}}(function(t,r){return t&&Ze(t,r,Te)}),rn=tn;function en(t,r){var e=-1,n=Tt(t)?Array(t.length):[];return rn(t,function(t,o,i){n[++e]=r(t,o,i)}),n}function nn(t,r){return(a(t)?ot:en)(t,Xe(r))}function on(t,r){for(var e=-1,n=null==t?0:t.length;++e<n&&!1!==r(t[e],e,t););return t}function un(t,r){var e;return(a(t)?on:rn)(t,"function"==typeof(e=r)?e:Ke)}var an=s?s.isConcatSpreadable:void 0;function fn(t){return a(t)||ye(t)||!!(an&&t&&t[an])}function cn(t,r,e,n,o){var i=-1,u=t.length;for(e||(e=fn),o||(o=[]);++i<u;){var a=t[i];r>0&&e(a)?r>1?cn(a,r-1,e,n,o):fe(o,a):n||(o[o.length]=a)}return o}function ln(t,r){if(t!==r){var e=void 0!==t,n=null===t,o=t==t,i=m(t),u=void 0!==r,a=null===r,f=r==r,c=m(r);if(!a&&!c&&!i&&t>r||i&&u&&f&&!a&&!c||n&&u&&f||!e&&f||!o)return 1;if(!n&&!i&&!c&&t<r||c&&e&&o&&!n&&!i||a&&e&&o||!u&&o||!f)return-1}return 0}function sn(t,r,e){r=r.length?ot(r,function(t){return a(t)?function(r){return st(r,1===t.length?t[0]:t)}:t}):[Ke];var n=-1;return r=ot(r,xe(Xe)),function(t,r){var e=t.length;for(t.sort(r);e--;)t[e]=t[e].value;return t}(en(t,function(t,e,o){return{criteria:ot(r,function(r){return r(t)}),index:++n,value:t}}),function(t,r){return function(t,r,e){for(var n=-1,o=t.criteria,i=r.criteria,u=o.length,a=e.length;++n<u;){var f=ln(o[n],i[n]);if(f)return n>=a?f:f*("desc"==e[n]?-1:1)}return t.index-r.index}(t,r,e)})}var hn=Math.max;var dn=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),gn=dn,bn=gn?function(t,r){return gn(t,"toString",{configurable:!0,enumerable:!1,value:(e=r,function(){return e}),writable:!0});var e}:Ke,pn=bn,vn=Date.now;var yn=function(t){var r=0,e=0;return function(){var n=vn(),o=16-(n-e);if(e=n,o>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(pn),wn=yn;function mn(t,r,e){if(!S(e))return!1;var n=typeof r;return!!("number"==n?Tt(e)&&Se(r,e.length):"string"==n&&r in e)&&I(e[r],t)}var _n=function(t,r){return wn(function(t,r,e){return r=hn(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,i=hn(n.length-r,0),u=Array(i);++o<i;)u[o]=n[r+o];o=-1;for(var a=Array(r+1);++o<r;)a[o]=n[o];return a[r]=e(u),function(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}(t,this,a)}}(t,r,Ke),t+"")}(function(t,r){if(null==t)return[];var e=r.length;return e>1&&mn(t,r[0],r[1])?r=[]:e>2&&mn(r[0],r[1],r[2])&&(r=[r[0]]),sn(t,cn(r,1),[])}),jn=_n;function $n(t){return ft(t).toLowerCase()}function Sn(t){return ft(t).toUpperCase()}function kn(t){return"[object Object]"===Object.prototype.toString.call(t)}function xn(t){if(kn(t)){for(let r in t)return!0;return!1}return!1}function On(t){if(!Er(t))return!1;return zr(t)>=0}function En(t,r){return rr(t)&&On(r)?0===(r=zr(r))?"":t.substring(0,r):""}function Pn(t,r){return rr(t)&&On(r)?0===(r=zr(r))?t:function(t,r){if(!rr(t))return"";if(!On(r))return"";if(0===(r=zr(r)))return"";let e=t.length-r;return e<0&&(e=0),t.substring(e,e+r)}(t,t.length-r):""}function An(t,r,e){if(!rr(t))return"";if(!rr(r))return"";if(!tr(e))return"";return String(t).replaceAll(r,e)}function Hn(t,r){if(!rr(t))return[];if(!rr(r))return[];let e=function(t,r){return rr(t)&&rr(r)?t.split(r):[]}(t,r);e=nn(e,Xr);let n=[];return un(e,function(t){rr(t)&&n.push(t)}),n}function Rn(t){if(!rr(t)&&!nr(t)&&!m(t))return"";let r="";try{r=String(t)}catch(t){}try{r=t.toString()}catch(t){}return r}function zn(t,r){return!!kn(t)&&(!(!rr(r)&&!nr(r))&&r in t)}function Mn(t,r,e=1){return rr(t)&&On(r)?(e=Mr(e)?zr(e):1,t.substring(r,r+e)):""}let Tn={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function Fn(t){return qn(t,1)}function Cn(t){return qn(t,360)}function qn(t,r=1){if(t.indexOf("%")>=0){if(!nr(t=An(t,"%","")))throw new Error("invalid color: value is not a number");t=Or(t)/100}else{if(!nr(t))throw new Error("invalid color: value is not a number");t=Or(t)/r}if(t>1)throw new Error("invalid color: value > 1");if(t<0)throw new Error("invalid color: value < 0");return t}function Dn(t){if(!nr(t))throw new Error("invalid color: value is not a number");if((t=Or(t))>1)throw new Error("invalid color: value > 1");if(t<0)throw new Error("invalid color: value < 0");return t}function Bn(t,r="rgba"){if(e=t,"[object Array]"!==Object.prototype.toString.call(e))throw new Error("invalid colors array");var e;let n=ht(t,0,0),o=ht(t,1,0),i=ht(t,2,0),u=ht(t,3,1);if(4!==Zt(r=r.split("")))throw new Error("tar.length !== 4");let a=ht(r,0),f=ht(r,1),c=ht(r,2),l=ht(r,3);return{[a]:n,[f]:o,[c]:i,[l]:u}}function Nn(t){let r=(t=Pn(t,1)).length;if(2===r)t=`${t}${t}${t}ff`;else if(3===r){let r=Mn(t,0,1),e=Mn(t,1,1),n=Mn(t,2,1);t=`${r}${r}${e}${e}${n}${n}ff`}else if(6===r)t=`${t}ff`;else if(8!==r)throw new Error("invalid hex color");function e(t){if(2!==t.length)throw new Error("hex.length of color is not equal to 2");if(!nr(t=parseInt(t,16)))throw new Error("invalid hex of color");return(t=Or(t))/255}return{r:e(Mn(t,0,2)),g:e(Mn(t,2,2)),b:e(Mn(t,4,2)),a:e(Mn(t,6,2))}}function Ln(t){return t=Bn(t=nn(t,(t,r)=>r<=2?qn(t,255):3===r?Dn(t):null),"rgba")}function In(t){return t=Xn(t=Bn(t=nn(t,(t,r)=>0===r?Cn(t):1===r||2===r?Fn(t):3===r?Dn(t):null),"hsla"))}function Vn(t){return t=Yn(t=Bn(t=nn(t,(t,r)=>0===r?Cn(t):1===r||2===r?Fn(t):3===r?Dn(t):null),"hsva"))}function Un(t){if("transparent"===t)return{r:0,g:0,b:0,a:0};if(function(t){return zn(Tn,t)}(t))return Nn(t=`#${Tn[t]}`);if(function(t){return"#"===En(t,1)&&(!!/[0-9A-Fa-f]{2}/g.test(t)||(!!/[0-9A-Fa-f]{3}/g.test(t)||(!!/[0-9A-Fa-f]{6}/g.test(t)||!!/[0-9A-Fa-f]{8}/g.test(t))))}(t))return Nn(t);if(function(t){return"rgb"===En(t,3)||"rgba"===En(t,4)}(t))return function(t){return t=An(t,"rgba",""),t=An(t,"rgb",""),Ln(Hn(t=An(t=t.replace(/[()]/g,""),","," ")," "))}(t);if(function(t){return"hsl"===En(t,3)||"hsla"===En(t,4)}(t))return function(t){return t=An(t,"hsla",""),t=An(t,"hsl",""),In(Hn(t=An(t=t.replace(/[()]/g,""),","," ")," "))}(t);if(function(t){return"hsv"===En(t,3)||"hsva"===En(t,4)}(t))return function(t){return t=An(t,"hsva",""),t=An(t,"hsv",""),Vn(Hn(t=An(t=t.replace(/[()]/g,""),","," ")," "))}(t);throw new Error("format of color string is not hex-color, name-color, rgba, hsla, hsva")}function Gn(t,r){return!!zn(t,r=$n(r))||!!zn(t,r=Sn(r))}function Wn(t,r,e){let n;return n=ht(t,r,null),null!==n?n:(n=ht(t,r=Sn(r),null),null!==n?n:e)}function Jn(t){if(function(t){let r=Gn(t,"r"),e=Gn(t,"g"),n=Gn(t,"b");return r&&e&&n}(t))return function(t){let r=[Wn(t,"r",null),Wn(t,"g",null),Wn(t,"b",null),Wn(t,"a",1)];return r=nn(r,Rn),Ln(r)}(t);if(function(t){let r=Gn(t,"h"),e=Gn(t,"s"),n=Gn(t,"l");return r&&e&&n}(t))return function(t){let r=[Wn(t,"h",null),Wn(t,"s",null),Wn(t,"l",null),Wn(t,"a",1)];return r=nn(r,Rn),In(r)}(t);if(function(t){let r=Gn(t,"h"),e=Gn(t,"s"),n=Gn(t,"v");return r&&e&&n}(t))return function(t){let r=[Wn(t,"h",null),Wn(t,"s",null),Wn(t,"v",null),Wn(t,"a",1)];return r=nn(r,Rn),Vn(r)}(t);throw new Error("color object is not one of rgba, hsla, hsva")}function Kn(t){let r,e,n=t.r,o=t.g,i=t.b,u=Math.max(n,o,i),a=Math.min(n,o,i),f=(u+a)/2;if(u===a)r=e=0;else{let t=u-a;switch(e=f>.5?t/(2-u-a):t/(u+a),u){case n:r=(o-i)/t+(o<i?6:0);break;case o:r=(i-n)/t+2;break;case i:r=(n-o)/t+4}r/=6}return{h:r,s:e,l:f,a:t.a}}function Qn(t){let r,e,n=t.r,o=t.g,i=t.b,u=Math.max(n,o,i),a=Math.min(n,o,i),f=u,c=u-a;if(e=0===u?0:c/u,u===a)r=0;else{switch(u){case n:r=(o-i)/c+(o<i?6:0);break;case o:r=(i-n)/c+2;break;case i:r=(n-o)/c+4}r/=6}return{h:r,s:e,v:f,a:t.a}}function Xn(t){let r,e,n,o=t.h,i=t.s,u=t.l;function a(t,r,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+6*(r-t)*e:e<.5?r:e<2/3?t+(r-t)*(2/3-e)*6:t}if(0===i)r=e=n=u;else{let t=u<.5?u*(1+i):u+i-u*i,f=2*u-t;r=a(f,t,o+1/3),e=a(f,t,o),n=a(f,t,o-1/3)}return{r:r,g:e,b:n,a:t.a}}function Yn(t){let r,e,n,o=t.h,i=t.s,u=t.v,a=Math.floor(6*o),f=6*o-a,c=u*(1-i),l=u*(1-f*i),s=u*(1-(1-f)*i);switch(a%6){case 0:r=u,e=s,n=c;break;case 1:r=l,e=u,n=c;break;case 2:r=c,e=u,n=s;break;case 3:r=c,e=l,n=u;break;case 4:r=s,e=c,n=u;break;case 5:r=u,e=c,n=l}return{r:r,g:e,b:n,a:t.a}}function Zn(t){let r=Math.round(255*t).toString(16);if(1===r.length)return`0${r}`;if(2===r.length)return r;throw new Error("invalid value")}function to(t,r=!0){let e=t.r,n=t.g,o=t.b,i=t.a,u=`${Zn(e)}${Zn(n)}${Zn(o)}`;return r&&(u=`${u}${Zn(i)}`),u}function ro(t){return Math.min(1,Math.max(0,t))}function eo(t,r){if(!rr(r))throw new Error("fmtOutput is not a string");if(!Co[r])throw console.log(`fmtOutput must be [${Te(Co)}]`),new Error("invalid fmtOutput");return t=Co[r](t)}function no(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");let n=Kn(t);return n.h+=r,n.h=n.h%1,eo(Xn(n),e)}function oo(t,r,e,n,o="toRgbString"){if(r<0||r>1)throw new Error("w1 < 0 or > 1");if(n<0||n>1)throw new Error("w1 < 0 or > 1");return eo({r:t.r*r+e.r*n,g:t.g*r+e.g*n,b:t.b*r+e.b*n,a:t.a*r+e.a*n},o)}function io(t){return`${Rr(100*t,1)}%`}function uo(t){return Rr(t,0)}function ao(t){return Rr(t,3)}function fo(t){return{r:uo(255*t.r),g:uo(255*t.g),b:uo(255*t.b)}}function co(t){return`rgb(${uo(255*t.r)}, ${uo(255*t.g)}, ${uo(255*t.b)})`}function lo(t){return{r:uo(255*t.r),g:uo(255*t.g),b:uo(255*t.b),a:ao(t.a)}}function so(t){return`rgba(${uo(255*t.r)}, ${uo(255*t.g)}, ${uo(255*t.b)}, ${ao(t.a)})`}function ho(t){let r=Kn(t);return{h:uo(360*r.h),s:ao(r.s),l:ao(r.l)}}function go(t){let r=Kn(t);return`hsl(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.l)})`}function bo(t){let r=Kn(t);return{h:uo(360*r.h),s:ao(r.s),l:ao(r.l),a:ao(r.a)}}function po(t){let r=Kn(t);return`hsla(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.l)}, ${ao(r.a)})`}function vo(t){let r=Qn(t);return{h:uo(360*r.h),s:ao(r.s),v:ao(r.v)}}function yo(t){let r=Qn(t);return`hsv(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.v)})`}function wo(t){let r=Qn(t);return{h:uo(360*r.h),s:ao(r.s),v:ao(r.v),a:ao(r.a)}}function mo(t){let r=Qn(t);return`hsva(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.v)}, ${ao(r.a)})`}function _o(t){return{r:io(t.r),g:io(t.g),b:io(t.b)}}function jo(t){return`rgb(${io(t.r)}, ${io(t.g)}, ${io(t.b)})`}function $o(t){return{r:io(t.r),g:io(t.g),b:io(t.b),a:ao(t.a)}}function So(t){return`rgba(${io(t.r)}, ${io(t.g)}, ${io(t.b)}, ${ao(t.a)})`}function ko(t){let r=Kn(t);return{h:uo(360*r.h),s:io(r.s),l:io(r.l)}}function xo(t){let r=Kn(t);return`hsl(${uo(360*r.h)}, ${io(r.s)}, ${io(r.l)})`}function Oo(t){let r=Kn(t);return{h:uo(360*r.h),s:io(r.s),l:io(r.l),a:ao(r.a)}}function Eo(t){let r=Kn(t);return`hsla(${uo(360*r.h)}, ${io(r.s)}, ${io(r.l)}, ${ao(r.a)})`}function Po(t){let r=Qn(t);return{h:uo(360*r.h),s:io(r.s),v:io(r.v)}}function Ao(t){let r=Qn(t);return`hsv(${uo(360*r.h)}, ${io(r.s)}, ${io(r.v)})`}function Ho(t){let r=Qn(t);return{h:uo(360*r.h),s:io(r.s),v:io(r.v),a:ao(r.a)}}function Ro(t){let r=Qn(t);return`hsva(${uo(360*r.h)}, ${io(r.s)}, ${io(r.v)}, ${ao(r.a)})`}function zo(t){let r=function(t){return to(t,!1)}(t);return`#${r}`}function Mo(t){return`#${to(t)}`}function To(t){let r=null,e=null,n=null;if(rr(t))r=$n(Xr(t));else{if(!xn(t))throw console.log("color=",t),new Error("color is not a string or an object");e=t}if(null!==r)try{n=Un(r)}catch(t){throw console.log(t),new Error(`can not parse color: ${r}`)}else if(null!==e)try{n=Jn(e)}catch(t){throw console.log(t),new Error(`can not parse color: ${JSON.stringify(e)}`)}return n}function Fo(t){if(!xn(t))return console.log("gradient is not an effective object"),t=>`rgb(${255*(t=Math.min(Math.max(t,0),1))},${255*t},${255*t})`;let r=[];return un(t,(t,e)=>{r.push([Or(e),lo(To(t)),t])}),r=jn(r,0),function(t){let e=null;for(let n=1;n<r.length;n++){let o=r[n-1][0],i=r[n-1][1],u=r[n][0],a=r[n][1];if(o<=t&&u>=t){let r=(u-t)/(u-o),n=(t-o)/(u-o);e=oo(To(i),r,To(a),n,"toRgbaString");break}}return e}}let Co={toRgb:fo,toRgbString:co,toRgba:lo,toRgbaString:so,toHsl:ho,toHslString:go,toHsla:bo,toHslaString:po,toHsv:vo,toHsvString:yo,toHsva:wo,toHsvaString:mo,toRgbP:_o,toRgbPString:jo,toRgbaP:$o,toRgbaPString:So,toHslP:ko,toHslPString:xo,toHslaP:Oo,toHslaPString:Eo,toHsvP:Po,toHsvPString:Ao,toHsvaP:Ho,toHsvaPString:Ro,toHexString:zo,toHex8String:Mo};var qo={toRgb:t=>fo(To(t)),toRgbString:t=>co(To(t)),toRgba:t=>lo(To(t)),toRgbaString:t=>so(To(t)),toHsl:t=>ho(To(t)),toHslString:t=>go(To(t)),toHsla:t=>bo(To(t)),toHslaString:t=>po(To(t)),toHsv:t=>vo(To(t)),toHsvString:t=>yo(To(t)),toHsva:t=>wo(To(t)),toHsvaString:t=>mo(To(t)),toRgbP:t=>_o(To(t)),toRgbPString:t=>jo(To(t)),toRgbaP:t=>$o(To(t)),toRgbaPString:t=>So(To(t)),toHslP:t=>ko(To(t)),toHslPString:t=>xo(To(t)),toHslaP:t=>Oo(To(t)),toHslaPString:t=>Eo(To(t)),toHsvP:t=>Po(To(t)),toHsvPString:t=>Ao(To(t)),toHsvaP:t=>Ho(To(t)),toHsvaPString:t=>Ro(To(t)),toHexString:t=>zo(To(t)),toHex8String:t=>Mo(To(t)),modSaturate:(t,r,e)=>function(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");let n=Kn(t);return n.s+=r,n.s=ro(n.s),eo(Xn(n),e)}(To(t),r,e),modGrey:(t,r)=>function(t,r="toRgbString"){let e=Kn(t);return e.s=0,eo(Xn(e),r)}(To(t),r),modLighten:(t,r,e)=>function(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");let n=Kn(t);return n.l+=r,n.l=ro(n.l),eo(Xn(n),e)}(To(t),r,e),modBrighten:(t,r,e)=>function(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");return t.r+=r,t.r=ro(t.r),t.g+=r,t.g=ro(t.g),t.b+=r,t.b=ro(t.b),eo(t,e)}(To(t),r,e),modHue:(t,r,e)=>no(To(t),r,e),modComplement:(t,r)=>function(t,r="toRgbString"){return no(t,.5,r)}(To(t),r),spreadHue:(t,r,e)=>function(t,r,e="toRgbString"){if(!Er(r))throw new Error("num is not an integer");if((r=zr(r))<=1)return[t];let n=Kn(t),o=1/r,i=[];for(let t=0;t<r;t++)i.push(eo(Xn(n),e)),n.h+=o,n.h=n.h%1;return i}(To(t),r,e),spreadMonochromatic:(t,r,e)=>function(t,r,e="toRgbString"){if(!Er(r))throw new Error("num is not an integer");if((r=zr(r))<=1)return[t];let n=Qn(t);n.s=1,n.l=1;let o=1/r,i=[];for(let t=0;t<r;t++)i.push(eo(Yn(n),e)),n.h-=o,n.l-=o;return i}(To(t),r,e),mix:(t,r,e,n,o)=>oo(To(t),r,To(e),n,o),getBrightness:t=>function(t){if(1!==t.a)throw new Error("alpha of color can not be equal to 1");return(299*t.r+587*t.g+114*t.b)/1e3}(To(t)),getLuminance:t=>function(t){if(1!==t.a)throw new Error("alpha of color can not be equal to 1");let r,e,n,o=t.r,i=t.g,u=t.b;return r=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),e=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4),n=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),.2126*r+.7152*e+.0722*n}(To(t)),interp:Fo};async function Do(r){let e=t.readFileSync(r);return u.imdecode(e)}async function Bo(r,e){let n=u.imencode(".png",e);t.writeFileSync(r,n)}async function No(t,r,e,n={}){let o=ht(n,"useToGray");br(o)||(o=!1);let i=t.resize(Math.floor(t.rows*e),Math.floor(t.cols*e));if(i.rows<5||i.cols<5)throw new Error(`縮放後檢測尺寸過小: [imgTarResize:${i.cols}x${i.rows}]`);if(i.rows>r.rows||i.cols>r.cols)throw new Error(`縮放後檢測>截圖尺寸: [imgScreen:${r.cols}x${r.rows}] > [imgTarResize:${i.cols}x${i.rows}]`);o&&(r=r.bgrToGray(),i=i.bgrToGray());let a=null;a=o?r.matchTemplate(i,u.TM_CCOEFF_NORMED):r.matchTemplate(i,u.TM_SQDIFF_NORMED);let{maxVal:f,minVal:c,maxLoc:l}=a.minMaxLoc(),s=null;return s=o?f:1-c,{similarity:s,x:l.x,y:l.y,width:i.cols,height:i.rows,scale:e}}let Lo={calcSimilarity:async function(t,r,e,n={}){let o=await Do(r),i=await Do(t);return await No(i,o,e,n)},calcSimilarityAndDraw:async function(t,r,e,n,o={}){let i=ht(o,"drawBorderWidth");Mr(i)||(i=2);let a=ht(o,"drawBorderColor");rr(a)||(a="#f00"),a=qo.toRgb(a);let f=await Do(r),c=await Do(t),l=await No(c,f,e,o),s=new u.Point2(l.x,l.y),h=new u.Point2(l.x+l.width,l.y+l.height);return f.drawRectangle(s,h,new u.Vec3(a.b,a.g,a.r),i,u.LINE_8),await Bo(n,f),{...l,fp:n}},screenAndDrawCircle:async function(t,r,e,n,o,i,a,f={}){let c=ht(f,"drawCircleRadius");Mr(c)||(c=5);let l=ht(f,"drawBorderWidth");Mr(l)||(l=2);let s=ht(f,"drawBorderColor");rr(s)||(s="#f00"),s=qo.toRgb(s),await gr.screenSave(t,r,e,n,a);let h=await Do(a),d=new u.Point2(o,i);h.drawCircle(d,c,new u.Vec3(s.b,s.g,s.r),l,u.LINE_8),await Bo(a,h)}},Io=async(t,r={})=>{let e=!1,n=ht(r,"fdTar",null);if(rr(n)||(n="./pic"),!ar(n))throw new Error(`opt.fdTar[${r.fdTar}] is not a folder`);let o=ht(r,"fdTmp",null);rr(o)||(o="./_tmp"),ar(o)||fr(o);let i=!0;"color"===ht(r,"modeCompare","gray")&&(i=!1);let u=`${n}/${t}.png`;if(!ir(u))throw new Error(`fpTar[${u}] is not a file`);let a=`${o}/${t}.all.png`,f=`${o}/${t}.det.png`,c=ht(r,"x",0),l=ht(r,"y",0),s=ht(r,"width",1920),h=ht(r,"height",1080),d=ht(r,"threshold",.9),g=ht(r,"withClick",!0),b=ht(r,"withDrag",!1);await gr.screenSave(c,l,s,h,a);let p=await Lo.calcSimilarityAndDraw(u,a,1,f,{useToGray:i});console.log(t,"similarity",p.similarity);let v=(t=>({cx:t.x+t.width/2,cy:t.y+t.height/2}))(p);if(p={...p,...v},p.similarity>d){if(g){let t=ht(r,"dx",0),e=ht(r,"dy",0);await hr.mouseClick(p.cx+c+t,p.cy+l+e)}if(b){let t=ht(r,"dx1",0),e=ht(r,"dy1",0),n=ht(r,"dx2",0),o=ht(r,"dy2",0);await hr.mouseDrag(p.cx+c+t,p.cy+l+e,p.cx+c+n,p.cy+l+o)}e=!0}return e};return async(t,r={})=>{let e=!1;rr(t)&&(t=[t]);let n=ht(r,"numMax",60),o=ht(r,"timeDelay",1500);for(let i=1;i<=n;i++){console.log(`waitPics names[${t}]...`,i);let n=!1;for(let e=0;e<Zt(t);e++){let o=t[e];if(n=await Io(o,r),n)break}if(n){e=!0;break}await or(o)}return e}});
|
|
6
|
+
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("fs"),require("child_process"),require("util"),require("path"),require("screenshot-desktop"),require("sharp"),require("@u4/opencv4nodejs")):"function"==typeof define&&define.amd?define(["fs","child_process","util","path","screenshot-desktop","sharp","@u4/opencv4nodejs"],r):(t="undefined"!=typeof globalThis?globalThis:t||self)["wait-pics"]=r(t.fs,t.child_process,t.util,t.path,t["screenshot-desktop"],t.sharp,t["@u4/opencv4nodejs"])}(this,function(t,r,e,n,o,i,u){"use strict";var a=Array.isArray,f="object"==typeof global&&global&&global.Object===Object&&global,c="object"==typeof self&&self&&self.Object===Object&&self,l=f||c||Function("return this")(),s=l.Symbol,h=Object.prototype,d=h.hasOwnProperty,g=h.toString,b=s?s.toStringTag:void 0;var p=Object.prototype.toString;var v=s?s.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":v&&v in Object(t)?function(t){var r=d.call(t,b),e=t[b];try{t[b]=void 0;var n=!0}catch(t){}var o=g.call(t);return n&&(r?t[b]=e:delete t[b]),o}(t):function(t){return p.call(t)}(t)}function w(t){return null!=t&&"object"==typeof t}function m(t){return"symbol"==typeof t||w(t)&&"[object Symbol]"==y(t)}var _=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,j=/^\w*$/;function $(t,r){if(a(t))return!1;var e=typeof t;return!("number"!=e&&"symbol"!=e&&"boolean"!=e&&null!=t&&!m(t))||(j.test(t)||!_.test(t)||null!=r&&t in Object(r))}function S(t){var r=typeof t;return null!=t&&("object"==r||"function"==r)}function k(t){if(!S(t))return!1;var r=y(t);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}var x,O=l["__core-js_shared__"],E=(x=/[^.]+$/.exec(O&&O.keys&&O.keys.IE_PROTO||""))?"Symbol(src)_1."+x:"";var P=Function.prototype.toString;function A(t){if(null!=t){try{return P.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var H=/^\[object .+?Constructor\]$/,R=Function.prototype,z=Object.prototype,M=R.toString,T=z.hasOwnProperty,F=RegExp("^"+M.call(T).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function C(t){return!(!S(t)||(r=t,E&&E in r))&&(k(t)?F:H).test(A(t));var r}function q(t,r){var e=function(t,r){return null==t?void 0:t[r]}(t,r);return C(e)?e:void 0}var D=q(Object,"create");var B=Object.prototype.hasOwnProperty;var N=Object.prototype.hasOwnProperty;function L(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}function I(t,r){return t===r||t!=t&&r!=r}function V(t,r){for(var e=t.length;e--;)if(I(t[e][0],r))return e;return-1}L.prototype.clear=function(){this.__data__=D?D(null):{},this.size=0},L.prototype.delete=function(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r},L.prototype.get=function(t){var r=this.__data__;if(D){var e=r[t];return"__lodash_hash_undefined__"===e?void 0:e}return B.call(r,t)?r[t]:void 0},L.prototype.has=function(t){var r=this.__data__;return D?void 0!==r[t]:N.call(r,t)},L.prototype.set=function(t,r){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=D&&void 0===r?"__lodash_hash_undefined__":r,this};var U=Array.prototype.splice;function G(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}G.prototype.clear=function(){this.__data__=[],this.size=0},G.prototype.delete=function(t){var r=this.__data__,e=V(r,t);return!(e<0)&&(e==r.length-1?r.pop():U.call(r,e,1),--this.size,!0)},G.prototype.get=function(t){var r=this.__data__,e=V(r,t);return e<0?void 0:r[e][1]},G.prototype.has=function(t){return V(this.__data__,t)>-1},G.prototype.set=function(t,r){var e=this.__data__,n=V(e,t);return n<0?(++this.size,e.push([t,r])):e[n][1]=r,this};var W=q(l,"Map");function J(t,r){var e,n,o=t.__data__;return("string"==(n=typeof(e=r))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==e:null===e)?o["string"==typeof r?"string":"hash"]:o.map}function K(t){var r=-1,e=null==t?0:t.length;for(this.clear();++r<e;){var n=t[r];this.set(n[0],n[1])}}K.prototype.clear=function(){this.size=0,this.__data__={hash:new L,map:new(W||G),string:new L}},K.prototype.delete=function(t){var r=J(this,t).delete(t);return this.size-=r?1:0,r},K.prototype.get=function(t){return J(this,t).get(t)},K.prototype.has=function(t){return J(this,t).has(t)},K.prototype.set=function(t,r){var e=J(this,t),n=e.size;return e.set(t,r),this.size+=e.size==n?0:1,this};function Q(t,r){if("function"!=typeof t||null!=r&&"function"!=typeof r)throw new TypeError("Expected a function");var e=function(){var n=arguments,o=r?r.apply(this,n):n[0],i=e.cache;if(i.has(o))return i.get(o);var u=t.apply(this,n);return e.cache=i.set(o,u)||i,u};return e.cache=new(Q.Cache||K),e}Q.Cache=K;var X,Y,Z,tt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rt=/\\(\\)?/g,et=(X=function(t){var r=[];return 46===t.charCodeAt(0)&&r.push(""),t.replace(tt,function(t,e,n,o){r.push(n?o.replace(rt,"$1"):e||t)}),r},Y=Q(X,function(t){return 500===Z.size&&Z.clear(),t}),Z=Y.cache,Y),nt=et;function ot(t,r){for(var e=-1,n=null==t?0:t.length,o=Array(n);++e<n;)o[e]=r(t[e],e,t);return o}var it=s?s.prototype:void 0,ut=it?it.toString:void 0;function at(t){if("string"==typeof t)return t;if(a(t))return ot(t,at)+"";if(m(t))return ut?ut.call(t):"";var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}function ft(t){return null==t?"":at(t)}function ct(t,r){return a(t)?t:$(t,r)?[t]:nt(ft(t))}function lt(t){if("string"==typeof t||m(t))return t;var r=t+"";return"0"==r&&1/t==-1/0?"-0":r}function st(t,r){for(var e=0,n=(r=ct(r,t)).length;null!=t&&e<n;)t=t[lt(r[e++])];return e&&e==n?t:void 0}function ht(t,r,e){var n=null==t?void 0:st(t,r);return void 0===n?e:n}var dt=Object.prototype;var gt=function(t,r){return function(e){return t(r(e))}}(Object.keys,Object),bt=gt,pt=Object.prototype.hasOwnProperty;function vt(t){if(e=(r=t)&&r.constructor,r!==("function"==typeof e&&e.prototype||dt))return bt(t);var r,e,n=[];for(var o in Object(t))pt.call(t,o)&&"constructor"!=o&&n.push(o);return n}var yt=q(l,"DataView"),wt=q(l,"Promise"),mt=q(l,"Set"),_t=q(l,"WeakMap"),jt="[object Map]",$t="[object Promise]",St="[object Set]",kt="[object WeakMap]",xt="[object DataView]",Ot=A(yt),Et=A(W),Pt=A(wt),At=A(mt),Ht=A(_t),Rt=y;(yt&&Rt(new yt(new ArrayBuffer(1)))!=xt||W&&Rt(new W)!=jt||wt&&Rt(wt.resolve())!=$t||mt&&Rt(new mt)!=St||_t&&Rt(new _t)!=kt)&&(Rt=function(t){var r=y(t),e="[object Object]"==r?t.constructor:void 0,n=e?A(e):"";if(n)switch(n){case Ot:return xt;case Et:return jt;case Pt:return $t;case At:return St;case Ht:return kt}return r});var zt=Rt;function Mt(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function Tt(t){return null!=t&&Mt(t.length)&&!k(t)}function Ft(t){return function(r){return null==r?void 0:r[t]}}var Ct=Ft("length"),qt=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");function Dt(t){return qt.test(t)}var Bt="\\ud800-\\udfff",Nt="["+Bt+"]",Lt="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",It="\\ud83c[\\udffb-\\udfff]",Vt="[^"+Bt+"]",Ut="(?:\\ud83c[\\udde6-\\uddff]){2}",Gt="[\\ud800-\\udbff][\\udc00-\\udfff]",Wt="(?:"+Lt+"|"+It+")"+"?",Jt="[\\ufe0e\\ufe0f]?",Kt=Jt+Wt+("(?:\\u200d(?:"+[Vt,Ut,Gt].join("|")+")"+Jt+Wt+")*"),Qt="(?:"+[Vt+Lt+"?",Lt,Ut,Gt,Nt].join("|")+")",Xt=RegExp(It+"(?="+It+")|"+Qt+Kt,"g");function Yt(t){return Dt(t)?function(t){for(var r=Xt.lastIndex=0;Xt.test(t);)++r;return r}(t):Ct(t)}function Zt(t){if(null==t)return 0;if(Tt(t))return"string"==typeof(r=t)||!a(r)&&w(r)&&"[object String]"==y(r)?Yt(t):t.length;var r,e=zt(t);return"[object Map]"==e||"[object Set]"==e?t.size:vt(t).length}function tr(t){return"[object String]"===Object.prototype.toString.call(t)}function rr(t){return!(!tr(t)||""===t)}function er(){let t,r,e=new Promise(function(){t=arguments[0],r=arguments[1]});return e.resolve=t,e.reject=r,e}function nr(t){let r=!1;if(rr(t))r=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(function(t){return t!=t}(t))return!1;r=!0}return r}function or(t=10){nr(t)||(t=10);let r=er();return setTimeout(function(){r.resolve()},t),r}function ir(r){return function(t,r={}){let e=ht(r,"fs");return!!e.existsSync(t)&&!e.lstatSync(t).isDirectory()&&!e.lstatSync(t).isSymbolicLink()}(r,{fs:t})}function ur(t,r={}){let e=ht(r,"fs");if(!e.existsSync(t))return!1;let n=e.lstatSync(t);return!n.isFile()&&!n.isSymbolicLink()}function ar(r){return ur(r,{fs:t})}function fr(r){return function(t,r={}){let e=ht(r,"fs");if(ur(t,{fs:e}))return{success:"input folder is already exists: "+t};if(e.existsSync(t))return{error:"input path already exists: "+t};try{e.mkdirSync(t,{recursive:!0})}catch(t){return{error:t}}return{success:"done: "+t}}(r,{fs:t})}let cr=e.promisify(r.execFile),lr=function(){let t=n.resolve(),r="AutoHotkey64.exe",e="";{let n=`${t}/AutoHotkey_2.0.19/`,o=`${t}/node_modules/w-mousekey/AutoHotkey_2.0.19/`;if(ir(`${n}${r}`))e=n;else{if(!ir(`${o}${r}`))throw new Error("can not find folder for AutoHotkey");e=o}}return{ahkExePath:`${e}/AutoHotkey64.exe`,ahkScriptPathClick:`${e}/zclick.ahk`,ahkScriptPathDrag:`${e}/zdrag.ahk`,ahkScriptPathSend:`${e}/zsend.ahk`,ahkScriptPathRecord:`${e}/zrecord.ahk`}}();async function sr(t,r,e=[]){let n=er();try{let{stdout:o,stderr:i}=await cr(t,["/force",r,...e]);i?n.reject(i):n.resolve(o)}catch(t){n.reject(t)}return n}let hr={mouseClick:async function(t,r){await sr(lr.ahkExePath,lr.ahkScriptPathClick,[t,r])},mouseDrag:async function(t,r,e,n){await sr(lr.ahkExePath,lr.ahkScriptPathDrag,[t,r,e,n])},sendKey:async function(t){await sr(lr.ahkExePath,lr.ahkScriptPathSend,[`${t}`])},sendString:async function(t){await sr(lr.ahkExePath,lr.ahkScriptPathSend,[`${t}`])}};async function dr(){let t=await o({format:"png"});if(!t||0===t.length)throw console.log("img",t),new Error("can not get the screenshot");return t}let gr={screenFull:async function(){return await dr()},screen:async function(t,r,e,n){let o=await dr();return await i(o).extract({left:t,top:r,width:e,height:n}).toBuffer()},screenFullSave:async function(r){let e=await dr();return t.writeFileSync(r,e),e},screenSave:async function(r,e,n,o,u){let a=await dr(),f=await i(a).extract({left:r,top:e,width:n,height:o}).toBuffer();return t.writeFileSync(u,f),f}};function br(t){return!0===(r=t)||!1===r||w(r)&&"[object Boolean]"==y(r);var r}var pr=/\s/;var vr=/^\s+/;function yr(t){return t?t.slice(0,function(t){for(var r=t.length;r--&&pr.test(t.charAt(r)););return r}(t)+1).replace(vr,""):t}var wr=/^[-+]0x[0-9a-f]+$/i,mr=/^0b[01]+$/i,_r=/^0o[0-7]+$/i,jr=parseInt;function $r(t){if("number"==typeof t)return t;if(m(t))return NaN;if(S(t)){var r="function"==typeof t.valueOf?t.valueOf():t;t=S(r)?r+"":r}if("string"!=typeof t)return 0===t?t:+t;t=yr(t);var e=mr.test(t);return e||_r.test(t)?jr(t.slice(2),e?2:8):wr.test(t)?NaN:+t}var Sr=1/0;function kr(t){return t?(t=$r(t))===Sr||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function xr(t){var r=kr(t),e=r%1;return r==r?e?r-e:r:0}function Or(t){if(!nr(t))return 0;return kr(t)}function Er(t){return!!nr(t)&&(t=Or(t),"number"==typeof(r=t)&&r==xr(r));var r}var Pr=l.isFinite,Ar=Math.min;var Hr=function(t){var r=Math[t];return function(t,e){if(t=$r(t),(e=null==e?0:Ar(xr(e),292))&&Pr(t)){var n=(ft(t)+"e").split("e");return+((n=(ft(r(n[0]+"e"+(+n[1]+e)))+"e").split("e"))[0]+"e"+(+n[1]-e))}return r(t)}}("round"),Rr=Hr;function zr(t){if(!nr(t))return 0;t=Or(t);let r=Rr(t);return"0"===String(r)?0:r}function Mr(t){if(!Er(t))return!1;return zr(t)>0}function Tr(t,r,e){var n=t.length;return e=void 0===e?n:e,!r&&e>=n?t:function(t,r,e){var n=-1,o=t.length;r<0&&(r=-r>o?0:o+r),(e=e>o?o:e)<0&&(e+=o),o=r>e?0:e-r>>>0,r>>>=0;for(var i=Array(o);++n<o;)i[n]=t[n+r];return i}(t,r,e)}function Fr(t){return t!=t}function Cr(t,r,e){return r==r?function(t,r,e){for(var n=e-1,o=t.length;++n<o;)if(t[n]===r)return n;return-1}(t,r,e):function(t,r,e,n){for(var o=t.length,i=e+(n?1:-1);n?i--:++i<o;)if(r(t[i],i,t))return i;return-1}(t,Fr,e)}var qr="\\ud800-\\udfff",Dr="["+qr+"]",Br="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Nr="\\ud83c[\\udffb-\\udfff]",Lr="[^"+qr+"]",Ir="(?:\\ud83c[\\udde6-\\uddff]){2}",Vr="[\\ud800-\\udbff][\\udc00-\\udfff]",Ur="(?:"+Br+"|"+Nr+")"+"?",Gr="[\\ufe0e\\ufe0f]?",Wr=Gr+Ur+("(?:\\u200d(?:"+[Lr,Ir,Vr].join("|")+")"+Gr+Ur+")*"),Jr="(?:"+[Lr+Br+"?",Br,Ir,Vr,Dr].join("|")+")",Kr=RegExp(Nr+"(?="+Nr+")|"+Jr+Wr,"g");function Qr(t){return Dt(t)?function(t){return t.match(Kr)||[]}(t):function(t){return t.split("")}(t)}function Xr(t,r,e){if((t=ft(t))&&(e||void 0===r))return yr(t);if(!t||!(r=at(r)))return t;var n=Qr(t),o=Qr(r),i=function(t,r){for(var e=-1,n=t.length;++e<n&&Cr(r,t[e],0)>-1;);return e}(n,o),u=function(t,r){for(var e=t.length;e--&&Cr(r,t[e],0)>-1;);return e}(n,o)+1;return Tr(n,i,u).join("")}function Yr(t){var r=this.__data__=new G(t);this.size=r.size}Yr.prototype.clear=function(){this.__data__=new G,this.size=0},Yr.prototype.delete=function(t){var r=this.__data__,e=r.delete(t);return this.size=r.size,e},Yr.prototype.get=function(t){return this.__data__.get(t)},Yr.prototype.has=function(t){return this.__data__.has(t)},Yr.prototype.set=function(t,r){var e=this.__data__;if(e instanceof G){var n=e.__data__;if(!W||n.length<199)return n.push([t,r]),this.size=++e.size,this;e=this.__data__=new K(n)}return e.set(t,r),this.size=e.size,this};function Zr(t){var r=-1,e=null==t?0:t.length;for(this.__data__=new K;++r<e;)this.add(t[r])}function te(t,r){for(var e=-1,n=null==t?0:t.length;++e<n;)if(r(t[e],e,t))return!0;return!1}function re(t,r){return t.has(r)}Zr.prototype.add=Zr.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Zr.prototype.has=function(t){return this.__data__.has(t)};function ee(t,r,e,n,o,i){var u=1&e,a=t.length,f=r.length;if(a!=f&&!(u&&f>a))return!1;var c=i.get(t),l=i.get(r);if(c&&l)return c==r&&l==t;var s=-1,h=!0,d=2&e?new Zr:void 0;for(i.set(t,r),i.set(r,t);++s<a;){var g=t[s],b=r[s];if(n)var p=u?n(b,g,s,r,t,i):n(g,b,s,t,r,i);if(void 0!==p){if(p)continue;h=!1;break}if(d){if(!te(r,function(t,r){if(!re(d,r)&&(g===t||o(g,t,e,n,i)))return d.push(r)})){h=!1;break}}else if(g!==b&&!o(g,b,e,n,i)){h=!1;break}}return i.delete(t),i.delete(r),h}var ne=l.Uint8Array;function oe(t){var r=-1,e=Array(t.size);return t.forEach(function(t,n){e[++r]=[n,t]}),e}function ie(t){var r=-1,e=Array(t.size);return t.forEach(function(t){e[++r]=t}),e}var ue=s?s.prototype:void 0,ae=ue?ue.valueOf:void 0;function fe(t,r){for(var e=-1,n=r.length,o=t.length;++e<n;)t[o+e]=r[e];return t}var ce=Object.prototype.propertyIsEnumerable,le=Object.getOwnPropertySymbols,se=le?function(t){return null==t?[]:(t=Object(t),function(t,r){for(var e=-1,n=null==t?0:t.length,o=0,i=[];++e<n;){var u=t[e];r(u,e,t)&&(i[o++]=u)}return i}(le(t),function(r){return ce.call(t,r)}))}:function(){return[]},he=se;function de(t){return w(t)&&"[object Arguments]"==y(t)}var ge=Object.prototype,be=ge.hasOwnProperty,pe=ge.propertyIsEnumerable,ve=de(function(){return arguments}())?de:function(t){return w(t)&&be.call(t,"callee")&&!pe.call(t,"callee")},ye=ve;var we="object"==typeof exports&&exports&&!exports.nodeType&&exports,me=we&&"object"==typeof module&&module&&!module.nodeType&&module,_e=me&&me.exports===we?l.Buffer:void 0,je=(_e?_e.isBuffer:void 0)||function(){return!1},$e=/^(?:0|[1-9]\d*)$/;function Se(t,r){var e=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==e||"symbol"!=e&&$e.test(t))&&t>-1&&t%1==0&&t<r}var ke={};function xe(t){return function(r){return t(r)}}ke["[object Float32Array]"]=ke["[object Float64Array]"]=ke["[object Int8Array]"]=ke["[object Int16Array]"]=ke["[object Int32Array]"]=ke["[object Uint8Array]"]=ke["[object Uint8ClampedArray]"]=ke["[object Uint16Array]"]=ke["[object Uint32Array]"]=!0,ke["[object Arguments]"]=ke["[object Array]"]=ke["[object ArrayBuffer]"]=ke["[object Boolean]"]=ke["[object DataView]"]=ke["[object Date]"]=ke["[object Error]"]=ke["[object Function]"]=ke["[object Map]"]=ke["[object Number]"]=ke["[object Object]"]=ke["[object RegExp]"]=ke["[object Set]"]=ke["[object String]"]=ke["[object WeakMap]"]=!1;var Oe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ee=Oe&&"object"==typeof module&&module&&!module.nodeType&&module,Pe=Ee&&Ee.exports===Oe&&f.process,Ae=function(){try{var t=Ee&&Ee.require&&Ee.require("util").types;return t||Pe&&Pe.binding&&Pe.binding("util")}catch(t){}}(),He=Ae&&Ae.isTypedArray,Re=He?xe(He):function(t){return w(t)&&Mt(t.length)&&!!ke[y(t)]},ze=Object.prototype.hasOwnProperty;function Me(t,r){var e=a(t),n=!e&&ye(t),o=!e&&!n&&je(t),i=!e&&!n&&!o&&Re(t),u=e||n||o||i,f=u?function(t,r){for(var e=-1,n=Array(t);++e<t;)n[e]=r(e);return n}(t.length,String):[],c=f.length;for(var l in t)!r&&!ze.call(t,l)||u&&("length"==l||o&&("offset"==l||"parent"==l)||i&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||Se(l,c))||f.push(l);return f}function Te(t){return Tt(t)?Me(t):vt(t)}function Fe(t){return function(t,r,e){var n=r(t);return a(t)?n:fe(n,e(t))}(t,Te,he)}var Ce=Object.prototype.hasOwnProperty;var qe="[object Arguments]",De="[object Array]",Be="[object Object]",Ne=Object.prototype.hasOwnProperty;function Le(t,r,e,n,o,i){var u=a(t),f=a(r),c=u?De:zt(t),l=f?De:zt(r),s=(c=c==qe?Be:c)==Be,h=(l=l==qe?Be:l)==Be,d=c==l;if(d&&je(t)){if(!je(r))return!1;u=!0,s=!1}if(d&&!s)return i||(i=new Yr),u||Re(t)?ee(t,r,e,n,o,i):function(t,r,e,n,o,i,u){switch(e){case"[object DataView]":if(t.byteLength!=r.byteLength||t.byteOffset!=r.byteOffset)return!1;t=t.buffer,r=r.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=r.byteLength||!i(new ne(t),new ne(r)));case"[object Boolean]":case"[object Date]":case"[object Number]":return I(+t,+r);case"[object Error]":return t.name==r.name&&t.message==r.message;case"[object RegExp]":case"[object String]":return t==r+"";case"[object Map]":var a=oe;case"[object Set]":var f=1&n;if(a||(a=ie),t.size!=r.size&&!f)return!1;var c=u.get(t);if(c)return c==r;n|=2,u.set(t,r);var l=ee(a(t),a(r),n,o,i,u);return u.delete(t),l;case"[object Symbol]":if(ae)return ae.call(t)==ae.call(r)}return!1}(t,r,c,e,n,o,i);if(!(1&e)){var g=s&&Ne.call(t,"__wrapped__"),b=h&&Ne.call(r,"__wrapped__");if(g||b){var p=g?t.value():t,v=b?r.value():r;return i||(i=new Yr),o(p,v,e,n,i)}}return!!d&&(i||(i=new Yr),function(t,r,e,n,o,i){var u=1&e,a=Fe(t),f=a.length;if(f!=Fe(r).length&&!u)return!1;for(var c=f;c--;){var l=a[c];if(!(u?l in r:Ce.call(r,l)))return!1}var s=i.get(t),h=i.get(r);if(s&&h)return s==r&&h==t;var d=!0;i.set(t,r),i.set(r,t);for(var g=u;++c<f;){var b=t[l=a[c]],p=r[l];if(n)var v=u?n(p,b,l,r,t,i):n(b,p,l,t,r,i);if(!(void 0===v?b===p||o(b,p,e,n,i):v)){d=!1;break}g||(g="constructor"==l)}if(d&&!g){var y=t.constructor,w=r.constructor;y==w||!("constructor"in t)||!("constructor"in r)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(d=!1)}return i.delete(t),i.delete(r),d}(t,r,e,n,o,i))}function Ie(t,r,e,n,o){return t===r||(null==t||null==r||!w(t)&&!w(r)?t!=t&&r!=r:Le(t,r,e,n,Ie,o))}function Ve(t){return t==t&&!S(t)}function Ue(t,r){return function(e){return null!=e&&(e[t]===r&&(void 0!==r||t in Object(e)))}}function Ge(t){var r=function(t){for(var r=Te(t),e=r.length;e--;){var n=r[e],o=t[n];r[e]=[n,o,Ve(o)]}return r}(t);return 1==r.length&&r[0][2]?Ue(r[0][0],r[0][1]):function(e){return e===t||function(t,r,e,n){var o=e.length,i=o,u=!n;if(null==t)return!i;for(t=Object(t);o--;){var a=e[o];if(u&&a[2]?a[1]!==t[a[0]]:!(a[0]in t))return!1}for(;++o<i;){var f=(a=e[o])[0],c=t[f],l=a[1];if(u&&a[2]){if(void 0===c&&!(f in t))return!1}else{var s=new Yr;if(n)var h=n(c,l,f,t,r,s);if(!(void 0===h?Ie(l,c,3,n,s):h))return!1}}return!0}(e,t,r)}}function We(t,r){return null!=t&&r in Object(t)}function Je(t,r){return null!=t&&function(t,r,e){for(var n=-1,o=(r=ct(r,t)).length,i=!1;++n<o;){var u=lt(r[n]);if(!(i=null!=t&&e(t,u)))break;t=t[u]}return i||++n!=o?i:!!(o=null==t?0:t.length)&&Mt(o)&&Se(u,o)&&(a(t)||ye(t))}(t,r,We)}function Ke(t){return t}function Qe(t){return $(t)?Ft(lt(t)):function(t){return function(r){return st(r,t)}}(t)}function Xe(t){return"function"==typeof t?t:null==t?Ke:"object"==typeof t?a(t)?function(t,r){return $(t)&&Ve(r)?Ue(lt(t),r):function(e){var n=ht(e,t);return void 0===n&&n===r?Je(e,t):Ie(r,n,3)}}(t[0],t[1]):Ge(t):Qe(t)}var Ye,Ze=function(t,r,e){for(var n=-1,o=Object(t),i=e(t),u=i.length;u--;){var a=i[Ye?u:++n];if(!1===r(o[a],a,o))break}return t};var tn=function(t,r){return function(e,n){if(null==e)return e;if(!Tt(e))return t(e,n);for(var o=e.length,i=r?o:-1,u=Object(e);(r?i--:++i<o)&&!1!==n(u[i],i,u););return e}}(function(t,r){return t&&Ze(t,r,Te)}),rn=tn;function en(t,r){var e=-1,n=Tt(t)?Array(t.length):[];return rn(t,function(t,o,i){n[++e]=r(t,o,i)}),n}function nn(t,r){return(a(t)?ot:en)(t,Xe(r))}function on(t,r){for(var e=-1,n=null==t?0:t.length;++e<n&&!1!==r(t[e],e,t););return t}function un(t,r){var e;return(a(t)?on:rn)(t,"function"==typeof(e=r)?e:Ke)}var an=s?s.isConcatSpreadable:void 0;function fn(t){return a(t)||ye(t)||!!(an&&t&&t[an])}function cn(t,r,e,n,o){var i=-1,u=t.length;for(e||(e=fn),o||(o=[]);++i<u;){var a=t[i];r>0&&e(a)?r>1?cn(a,r-1,e,n,o):fe(o,a):n||(o[o.length]=a)}return o}function ln(t,r){if(t!==r){var e=void 0!==t,n=null===t,o=t==t,i=m(t),u=void 0!==r,a=null===r,f=r==r,c=m(r);if(!a&&!c&&!i&&t>r||i&&u&&f&&!a&&!c||n&&u&&f||!e&&f||!o)return 1;if(!n&&!i&&!c&&t<r||c&&e&&o&&!n&&!i||a&&e&&o||!u&&o||!f)return-1}return 0}function sn(t,r,e){r=r.length?ot(r,function(t){return a(t)?function(r){return st(r,1===t.length?t[0]:t)}:t}):[Ke];var n=-1;return r=ot(r,xe(Xe)),function(t,r){var e=t.length;for(t.sort(r);e--;)t[e]=t[e].value;return t}(en(t,function(t,e,o){return{criteria:ot(r,function(r){return r(t)}),index:++n,value:t}}),function(t,r){return function(t,r,e){for(var n=-1,o=t.criteria,i=r.criteria,u=o.length,a=e.length;++n<u;){var f=ln(o[n],i[n]);if(f)return n>=a?f:f*("desc"==e[n]?-1:1)}return t.index-r.index}(t,r,e)})}var hn=Math.max;var dn=function(){try{var t=q(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),gn=dn,bn=gn?function(t,r){return gn(t,"toString",{configurable:!0,enumerable:!1,value:(e=r,function(){return e}),writable:!0});var e}:Ke,pn=bn,vn=Date.now;var yn=function(t){var r=0,e=0;return function(){var n=vn(),o=16-(n-e);if(e=n,o>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}}(pn),wn=yn;function mn(t,r,e){if(!S(e))return!1;var n=typeof r;return!!("number"==n?Tt(e)&&Se(r,e.length):"string"==n&&r in e)&&I(e[r],t)}var _n=function(t,r){return wn(function(t,r,e){return r=hn(void 0===r?t.length-1:r,0),function(){for(var n=arguments,o=-1,i=hn(n.length-r,0),u=Array(i);++o<i;)u[o]=n[r+o];o=-1;for(var a=Array(r+1);++o<r;)a[o]=n[o];return a[r]=e(u),function(t,r,e){switch(e.length){case 0:return t.call(r);case 1:return t.call(r,e[0]);case 2:return t.call(r,e[0],e[1]);case 3:return t.call(r,e[0],e[1],e[2])}return t.apply(r,e)}(t,this,a)}}(t,r,Ke),t+"")}(function(t,r){if(null==t)return[];var e=r.length;return e>1&&mn(t,r[0],r[1])?r=[]:e>2&&mn(r[0],r[1],r[2])&&(r=[r[0]]),sn(t,cn(r,1),[])}),jn=_n;function $n(t){return ft(t).toLowerCase()}function Sn(t){return ft(t).toUpperCase()}function kn(t){return"[object Object]"===Object.prototype.toString.call(t)}function xn(t){if(kn(t)){for(let r in t)return!0;return!1}return!1}function On(t){if(!Er(t))return!1;return zr(t)>=0}function En(t,r){return rr(t)&&On(r)?0===(r=zr(r))?"":t.substring(0,r):""}function Pn(t,r){return rr(t)&&On(r)?0===(r=zr(r))?t:function(t,r){if(!rr(t))return"";if(!On(r))return"";if(0===(r=zr(r)))return"";let e=t.length-r;return e<0&&(e=0),t.substring(e,e+r)}(t,t.length-r):""}function An(t,r,e){if(!rr(t))return"";if(!rr(r))return"";if(!tr(e))return"";return String(t).replaceAll(r,e)}function Hn(t,r){if(!rr(t))return[];if(!rr(r))return[];let e=function(t,r){return rr(t)&&rr(r)?t.split(r):[]}(t,r);e=nn(e,Xr);let n=[];return un(e,function(t){rr(t)&&n.push(t)}),n}function Rn(t){if(!rr(t)&&!nr(t)&&!m(t))return"";let r="";try{r=String(t)}catch(t){}try{r=t.toString()}catch(t){}return r}function zn(t,r){return!!kn(t)&&(!(!rr(r)&&!nr(r))&&r in t)}function Mn(t,r,e=1){return rr(t)&&On(r)?(e=Mr(e)?zr(e):1,t.substring(r,r+e)):""}let Tn={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function Fn(t){return qn(t,1)}function Cn(t){return qn(t,360)}function qn(t,r=1){if(t.indexOf("%")>=0){if(!nr(t=An(t,"%","")))throw new Error("invalid color: value is not a number");t=Or(t)/100}else{if(!nr(t))throw new Error("invalid color: value is not a number");t=Or(t)/r}if(t>1)throw new Error("invalid color: value > 1");if(t<0)throw new Error("invalid color: value < 0");return t}function Dn(t){if(!nr(t))throw new Error("invalid color: value is not a number");if((t=Or(t))>1)throw new Error("invalid color: value > 1");if(t<0)throw new Error("invalid color: value < 0");return t}function Bn(t,r="rgba"){if(e=t,"[object Array]"!==Object.prototype.toString.call(e))throw new Error("invalid colors array");var e;let n=ht(t,0,0),o=ht(t,1,0),i=ht(t,2,0),u=ht(t,3,1);if(4!==Zt(r=r.split("")))throw new Error("tar.length !== 4");let a=ht(r,0),f=ht(r,1),c=ht(r,2),l=ht(r,3);return{[a]:n,[f]:o,[c]:i,[l]:u}}function Nn(t){let r=(t=Pn(t,1)).length;if(2===r)t=`${t}${t}${t}ff`;else if(3===r){let r=Mn(t,0,1),e=Mn(t,1,1),n=Mn(t,2,1);t=`${r}${r}${e}${e}${n}${n}ff`}else if(6===r)t=`${t}ff`;else if(8!==r)throw new Error("invalid hex color");function e(t){if(2!==t.length)throw new Error("hex.length of color is not equal to 2");if(!nr(t=parseInt(t,16)))throw new Error("invalid hex of color");return(t=Or(t))/255}return{r:e(Mn(t,0,2)),g:e(Mn(t,2,2)),b:e(Mn(t,4,2)),a:e(Mn(t,6,2))}}function Ln(t){return t=Bn(t=nn(t,(t,r)=>r<=2?qn(t,255):3===r?Dn(t):null),"rgba")}function In(t){return t=Xn(t=Bn(t=nn(t,(t,r)=>0===r?Cn(t):1===r||2===r?Fn(t):3===r?Dn(t):null),"hsla"))}function Vn(t){return t=Yn(t=Bn(t=nn(t,(t,r)=>0===r?Cn(t):1===r||2===r?Fn(t):3===r?Dn(t):null),"hsva"))}function Un(t){if("transparent"===t)return{r:0,g:0,b:0,a:0};if(function(t){return zn(Tn,t)}(t))return Nn(t=`#${Tn[t]}`);if(function(t){return"#"===En(t,1)&&(!!/[0-9A-Fa-f]{2}/g.test(t)||(!!/[0-9A-Fa-f]{3}/g.test(t)||(!!/[0-9A-Fa-f]{6}/g.test(t)||!!/[0-9A-Fa-f]{8}/g.test(t))))}(t))return Nn(t);if(function(t){return"rgb"===En(t,3)||"rgba"===En(t,4)}(t))return function(t){return t=An(t,"rgba",""),t=An(t,"rgb",""),Ln(Hn(t=An(t=t.replace(/[()]/g,""),","," ")," "))}(t);if(function(t){return"hsl"===En(t,3)||"hsla"===En(t,4)}(t))return function(t){return t=An(t,"hsla",""),t=An(t,"hsl",""),In(Hn(t=An(t=t.replace(/[()]/g,""),","," ")," "))}(t);if(function(t){return"hsv"===En(t,3)||"hsva"===En(t,4)}(t))return function(t){return t=An(t,"hsva",""),t=An(t,"hsv",""),Vn(Hn(t=An(t=t.replace(/[()]/g,""),","," ")," "))}(t);throw new Error("format of color string is not hex-color, name-color, rgba, hsla, hsva")}function Gn(t,r){return!!zn(t,r=$n(r))||!!zn(t,r=Sn(r))}function Wn(t,r,e){let n;return n=ht(t,r,null),null!==n?n:(n=ht(t,r=Sn(r),null),null!==n?n:e)}function Jn(t){if(function(t){let r=Gn(t,"r"),e=Gn(t,"g"),n=Gn(t,"b");return r&&e&&n}(t))return function(t){let r=[Wn(t,"r",null),Wn(t,"g",null),Wn(t,"b",null),Wn(t,"a",1)];return r=nn(r,Rn),Ln(r)}(t);if(function(t){let r=Gn(t,"h"),e=Gn(t,"s"),n=Gn(t,"l");return r&&e&&n}(t))return function(t){let r=[Wn(t,"h",null),Wn(t,"s",null),Wn(t,"l",null),Wn(t,"a",1)];return r=nn(r,Rn),In(r)}(t);if(function(t){let r=Gn(t,"h"),e=Gn(t,"s"),n=Gn(t,"v");return r&&e&&n}(t))return function(t){let r=[Wn(t,"h",null),Wn(t,"s",null),Wn(t,"v",null),Wn(t,"a",1)];return r=nn(r,Rn),Vn(r)}(t);throw new Error("color object is not one of rgba, hsla, hsva")}function Kn(t){let r,e,n=t.r,o=t.g,i=t.b,u=Math.max(n,o,i),a=Math.min(n,o,i),f=(u+a)/2;if(u===a)r=e=0;else{let t=u-a;switch(e=f>.5?t/(2-u-a):t/(u+a),u){case n:r=(o-i)/t+(o<i?6:0);break;case o:r=(i-n)/t+2;break;case i:r=(n-o)/t+4}r/=6}return{h:r,s:e,l:f,a:t.a}}function Qn(t){let r,e,n=t.r,o=t.g,i=t.b,u=Math.max(n,o,i),a=Math.min(n,o,i),f=u,c=u-a;if(e=0===u?0:c/u,u===a)r=0;else{switch(u){case n:r=(o-i)/c+(o<i?6:0);break;case o:r=(i-n)/c+2;break;case i:r=(n-o)/c+4}r/=6}return{h:r,s:e,v:f,a:t.a}}function Xn(t){let r,e,n,o=t.h,i=t.s,u=t.l;function a(t,r,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?t+6*(r-t)*e:e<.5?r:e<2/3?t+(r-t)*(2/3-e)*6:t}if(0===i)r=e=n=u;else{let t=u<.5?u*(1+i):u+i-u*i,f=2*u-t;r=a(f,t,o+1/3),e=a(f,t,o),n=a(f,t,o-1/3)}return{r:r,g:e,b:n,a:t.a}}function Yn(t){let r,e,n,o=t.h,i=t.s,u=t.v,a=Math.floor(6*o),f=6*o-a,c=u*(1-i),l=u*(1-f*i),s=u*(1-(1-f)*i);switch(a%6){case 0:r=u,e=s,n=c;break;case 1:r=l,e=u,n=c;break;case 2:r=c,e=u,n=s;break;case 3:r=c,e=l,n=u;break;case 4:r=s,e=c,n=u;break;case 5:r=u,e=c,n=l}return{r:r,g:e,b:n,a:t.a}}function Zn(t){let r=Math.round(255*t).toString(16);if(1===r.length)return`0${r}`;if(2===r.length)return r;throw new Error("invalid value")}function to(t,r=!0){let e=t.r,n=t.g,o=t.b,i=t.a,u=`${Zn(e)}${Zn(n)}${Zn(o)}`;return r&&(u=`${u}${Zn(i)}`),u}function ro(t){return Math.min(1,Math.max(0,t))}function eo(t,r){if(!rr(r))throw new Error("fmtOutput is not a string");if(!Co[r])throw console.log(`fmtOutput must be [${Te(Co)}]`),new Error("invalid fmtOutput");return t=Co[r](t)}function no(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");let n=Kn(t);return n.h+=r,n.h=n.h%1,eo(Xn(n),e)}function oo(t,r,e,n,o="toRgbString"){if(r<0||r>1)throw new Error("w1 < 0 or > 1");if(n<0||n>1)throw new Error("w1 < 0 or > 1");return eo({r:t.r*r+e.r*n,g:t.g*r+e.g*n,b:t.b*r+e.b*n,a:t.a*r+e.a*n},o)}function io(t){return`${Rr(100*t,1)}%`}function uo(t){return Rr(t,0)}function ao(t){return Rr(t,3)}function fo(t){return{r:uo(255*t.r),g:uo(255*t.g),b:uo(255*t.b)}}function co(t){return`rgb(${uo(255*t.r)}, ${uo(255*t.g)}, ${uo(255*t.b)})`}function lo(t){return{r:uo(255*t.r),g:uo(255*t.g),b:uo(255*t.b),a:ao(t.a)}}function so(t){return`rgba(${uo(255*t.r)}, ${uo(255*t.g)}, ${uo(255*t.b)}, ${ao(t.a)})`}function ho(t){let r=Kn(t);return{h:uo(360*r.h),s:ao(r.s),l:ao(r.l)}}function go(t){let r=Kn(t);return`hsl(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.l)})`}function bo(t){let r=Kn(t);return{h:uo(360*r.h),s:ao(r.s),l:ao(r.l),a:ao(r.a)}}function po(t){let r=Kn(t);return`hsla(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.l)}, ${ao(r.a)})`}function vo(t){let r=Qn(t);return{h:uo(360*r.h),s:ao(r.s),v:ao(r.v)}}function yo(t){let r=Qn(t);return`hsv(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.v)})`}function wo(t){let r=Qn(t);return{h:uo(360*r.h),s:ao(r.s),v:ao(r.v),a:ao(r.a)}}function mo(t){let r=Qn(t);return`hsva(${uo(360*r.h)}, ${ao(r.s)}, ${ao(r.v)}, ${ao(r.a)})`}function _o(t){return{r:io(t.r),g:io(t.g),b:io(t.b)}}function jo(t){return`rgb(${io(t.r)}, ${io(t.g)}, ${io(t.b)})`}function $o(t){return{r:io(t.r),g:io(t.g),b:io(t.b),a:ao(t.a)}}function So(t){return`rgba(${io(t.r)}, ${io(t.g)}, ${io(t.b)}, ${ao(t.a)})`}function ko(t){let r=Kn(t);return{h:uo(360*r.h),s:io(r.s),l:io(r.l)}}function xo(t){let r=Kn(t);return`hsl(${uo(360*r.h)}, ${io(r.s)}, ${io(r.l)})`}function Oo(t){let r=Kn(t);return{h:uo(360*r.h),s:io(r.s),l:io(r.l),a:ao(r.a)}}function Eo(t){let r=Kn(t);return`hsla(${uo(360*r.h)}, ${io(r.s)}, ${io(r.l)}, ${ao(r.a)})`}function Po(t){let r=Qn(t);return{h:uo(360*r.h),s:io(r.s),v:io(r.v)}}function Ao(t){let r=Qn(t);return`hsv(${uo(360*r.h)}, ${io(r.s)}, ${io(r.v)})`}function Ho(t){let r=Qn(t);return{h:uo(360*r.h),s:io(r.s),v:io(r.v),a:ao(r.a)}}function Ro(t){let r=Qn(t);return`hsva(${uo(360*r.h)}, ${io(r.s)}, ${io(r.v)}, ${ao(r.a)})`}function zo(t){let r=function(t){return to(t,!1)}(t);return`#${r}`}function Mo(t){return`#${to(t)}`}function To(t){let r=null,e=null,n=null;if(rr(t))r=$n(Xr(t));else{if(!xn(t))throw console.log("color=",t),new Error("color is not a string or an object");e=t}if(null!==r)try{n=Un(r)}catch(t){throw console.log(t),new Error(`can not parse color: ${r}`)}else if(null!==e)try{n=Jn(e)}catch(t){throw console.log(t),new Error(`can not parse color: ${JSON.stringify(e)}`)}return n}function Fo(t){if(!xn(t))return console.log("gradient is not an effective object"),t=>`rgb(${255*(t=Math.min(Math.max(t,0),1))},${255*t},${255*t})`;let r=[];return un(t,(t,e)=>{r.push([Or(e),lo(To(t)),t])}),r=jn(r,0),function(t){let e=null;for(let n=1;n<r.length;n++){let o=r[n-1][0],i=r[n-1][1],u=r[n][0],a=r[n][1];if(o<=t&&u>=t){let r=(u-t)/(u-o),n=(t-o)/(u-o);e=oo(To(i),r,To(a),n,"toRgbaString");break}}return e}}let Co={toRgb:fo,toRgbString:co,toRgba:lo,toRgbaString:so,toHsl:ho,toHslString:go,toHsla:bo,toHslaString:po,toHsv:vo,toHsvString:yo,toHsva:wo,toHsvaString:mo,toRgbP:_o,toRgbPString:jo,toRgbaP:$o,toRgbaPString:So,toHslP:ko,toHslPString:xo,toHslaP:Oo,toHslaPString:Eo,toHsvP:Po,toHsvPString:Ao,toHsvaP:Ho,toHsvaPString:Ro,toHexString:zo,toHex8String:Mo};var qo={toRgb:t=>fo(To(t)),toRgbString:t=>co(To(t)),toRgba:t=>lo(To(t)),toRgbaString:t=>so(To(t)),toHsl:t=>ho(To(t)),toHslString:t=>go(To(t)),toHsla:t=>bo(To(t)),toHslaString:t=>po(To(t)),toHsv:t=>vo(To(t)),toHsvString:t=>yo(To(t)),toHsva:t=>wo(To(t)),toHsvaString:t=>mo(To(t)),toRgbP:t=>_o(To(t)),toRgbPString:t=>jo(To(t)),toRgbaP:t=>$o(To(t)),toRgbaPString:t=>So(To(t)),toHslP:t=>ko(To(t)),toHslPString:t=>xo(To(t)),toHslaP:t=>Oo(To(t)),toHslaPString:t=>Eo(To(t)),toHsvP:t=>Po(To(t)),toHsvPString:t=>Ao(To(t)),toHsvaP:t=>Ho(To(t)),toHsvaPString:t=>Ro(To(t)),toHexString:t=>zo(To(t)),toHex8String:t=>Mo(To(t)),modSaturate:(t,r,e)=>function(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");let n=Kn(t);return n.s+=r,n.s=ro(n.s),eo(Xn(n),e)}(To(t),r,e),modGrey:(t,r)=>function(t,r="toRgbString"){let e=Kn(t);return e.s=0,eo(Xn(e),r)}(To(t),r),modLighten:(t,r,e)=>function(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");let n=Kn(t);return n.l+=r,n.l=ro(n.l),eo(Xn(n),e)}(To(t),r,e),modBrighten:(t,r,e)=>function(t,r,e="toRgbString"){if(r<0||r>1)throw new Error("amount < 0 or > 1");return t.r+=r,t.r=ro(t.r),t.g+=r,t.g=ro(t.g),t.b+=r,t.b=ro(t.b),eo(t,e)}(To(t),r,e),modHue:(t,r,e)=>no(To(t),r,e),modComplement:(t,r)=>function(t,r="toRgbString"){return no(t,.5,r)}(To(t),r),spreadHue:(t,r,e)=>function(t,r,e="toRgbString"){if(!Er(r))throw new Error("num is not an integer");if((r=zr(r))<=1)return[t];let n=Kn(t),o=1/r,i=[];for(let t=0;t<r;t++)i.push(eo(Xn(n),e)),n.h+=o,n.h=n.h%1;return i}(To(t),r,e),spreadMonochromatic:(t,r,e)=>function(t,r,e="toRgbString"){if(!Er(r))throw new Error("num is not an integer");if((r=zr(r))<=1)return[t];let n=Qn(t);n.s=1,n.l=1;let o=1/r,i=[];for(let t=0;t<r;t++)i.push(eo(Yn(n),e)),n.h-=o,n.l-=o;return i}(To(t),r,e),mix:(t,r,e,n,o)=>oo(To(t),r,To(e),n,o),getBrightness:t=>function(t){if(1!==t.a)throw new Error("alpha of color can not be equal to 1");return(299*t.r+587*t.g+114*t.b)/1e3}(To(t)),getLuminance:t=>function(t){if(1!==t.a)throw new Error("alpha of color can not be equal to 1");let r,e,n,o=t.r,i=t.g,u=t.b;return r=o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4),e=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4),n=u<=.03928?u/12.92:Math.pow((u+.055)/1.055,2.4),.2126*r+.7152*e+.0722*n}(To(t)),interp:Fo};async function Do(r){let e=t.readFileSync(r);return u.imdecode(e)}async function Bo(r,e){let n=u.imencode(".png",e);t.writeFileSync(r,n)}async function No(t,r,e,n={}){let o=ht(n,"useToGray");br(o)||(o=!1);let i=t.resize(Math.floor(t.rows*e),Math.floor(t.cols*e));if(i.rows<5||i.cols<5)throw new Error(`縮放後檢測尺寸過小: [imgTarResize:${i.cols}x${i.rows}]`);if(i.rows>r.rows||i.cols>r.cols)throw new Error(`縮放後檢測>截圖尺寸: [imgScreen:${r.cols}x${r.rows}] > [imgTarResize:${i.cols}x${i.rows}]`);o&&(r=r.bgrToGray(),i=i.bgrToGray());let a=null;a=o?r.matchTemplate(i,u.TM_CCOEFF_NORMED):r.matchTemplate(i,u.TM_SQDIFF_NORMED);let{maxVal:f,minVal:c,maxLoc:l,minLoc:s}=a.minMaxLoc(),h=null,d=null;return o?(h=f,d=l):(h=1-c,d=s),{similarity:h,x:d.x,y:d.y,width:i.cols,height:i.rows,scale:e}}let Lo={calcSimilarity:async function(t,r,e,n={}){let o=await Do(r),i=await Do(t);return await No(i,o,e,n)},calcSimilarityAndDraw:async function(t,r,e,n,o={}){let i=ht(o,"drawBorderWidth");Mr(i)||(i=2);let a=ht(o,"drawBorderColor");rr(a)||(a="#f00"),a=qo.toRgb(a);let f=await Do(r),c=await Do(t),l=await No(c,f,e,o),s=new u.Point2(l.x,l.y),h=new u.Point2(l.x+l.width,l.y+l.height);return f.drawRectangle(s,h,new u.Vec3(a.b,a.g,a.r),i,u.LINE_8),await Bo(n,f),{...l,fp:n}},screenAndDrawCircle:async function(t,r,e,n,o,i,a,f={}){let c=ht(f,"drawCircleRadius");Mr(c)||(c=5);let l=ht(f,"drawBorderWidth");Mr(l)||(l=2);let s=ht(f,"drawBorderColor");rr(s)||(s="#f00"),s=qo.toRgb(s),await gr.screenSave(t,r,e,n,a);let h=await Do(a),d=new u.Point2(o,i);h.drawCircle(d,c,new u.Vec3(s.b,s.g,s.r),l,u.LINE_8),await Bo(a,h)}},Io=async(t,r={})=>{let e=!1,n=ht(r,"fdTar",null);if(rr(n)||(n="./pic"),!ar(n))throw new Error(`opt.fdTar[${r.fdTar}] is not a folder`);let o=ht(r,"fdTmp",null);rr(o)||(o="./_tmp"),ar(o)||fr(o);let i=!0;"color"===ht(r,"modeCompare","gray")&&(i=!1);let u=`${n}/${t}.png`;if(!ir(u))throw new Error(`fpTar[${u}] is not a file`);let a=`${o}/${t}.all.png`,f=`${o}/${t}.det.png`,c=ht(r,"x",0),l=ht(r,"y",0),s=ht(r,"width",1920),h=ht(r,"height",1080),d=ht(r,"threshold",.9),g=ht(r,"withClick",!0),b=ht(r,"withDrag",!1);await gr.screenSave(c,l,s,h,a);let p=await Lo.calcSimilarityAndDraw(u,a,1,f,{useToGray:i});console.log(t,"similarity",p.similarity);let v=(t=>({cx:t.x+t.width/2,cy:t.y+t.height/2}))(p);if(p={...p,...v},p.similarity>d){if(g){let t=ht(r,"dx",0),e=ht(r,"dy",0);await hr.mouseClick(p.cx+c+t,p.cy+l+e)}if(b){let t=ht(r,"dx1",0),e=ht(r,"dy1",0),n=ht(r,"dx2",0),o=ht(r,"dy2",0);await hr.mouseDrag(p.cx+c+t,p.cy+l+e,p.cx+c+n,p.cy+l+o)}e=!0}return e};return async(t,r={})=>{let e=!1;rr(t)&&(t=[t]);let n=ht(r,"numMax",60),o=ht(r,"timeDelay",1500);for(let i=1;i<=n;i++){console.log(`waitPics names[${t}]...`,i);let n=!1;for(let e=0;e<Zt(t);e++){let o=t[e];if(n=await Io(o,r),n)break}if(n){e=!0;break}await or(o)}return e}});
|
|
7
7
|
//# sourceMappingURL=wait-pics.umd.js.map
|