/** * 由 Fantastic-admin 提供技术支持 * Powered by Fantastic-admin * Gitee https://gitee.com/hooray/fantastic-admin * Github https://github.com/hooray/fantastic-admin */ var C=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function M(e,t,i,r){e.addEventListener?e.addEventListener(t,i,r):e.attachEvent&&e.attachEvent("on".concat(t),function(){i(window.event)})}function B(e,t){for(var i=t.slice(0,t.length-1),r=0;r=0;)t[i-1]+=",",t.splice(i,1),i=t.lastIndexOf("");return t}function F(e,t){for(var i=e.length>=t.length?e:t,r=e.length>=t.length?t:e,n=!0,a=0;a=0&&f.splice(i,1),e.key&&e.key.toLowerCase()==="meta"&&f.splice(0,f.length),(t===93||t===224)&&(t=91),t in u){u[t]=!1;for(var r in h)h[r]===t&&(v[r]=!1)}}function N(e){if(typeof e>"u")Object.keys(s).forEach(function(o){return delete s[o]});else if(Array.isArray(e))e.forEach(function(o){o.key&&P(o)});else if(typeof e=="object")e.key&&P(e);else if(typeof e=="string"){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r1?B(h,p):[];s[d]=s[d].filter(function(g){var w=n?g.method===n:!0;return!(w&&g.scope===r&&F(g.mods,K))})}})};function k(e,t,i,r){if(t.element===r){var n;if(t.scope===i||t.scope==="all"){n=t.mods.length>0;for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(!u[a]&&t.mods.indexOf(+a)>-1||u[a]&&t.mods.indexOf(+a)===-1)&&(n=!1);(t.mods.length===0&&!u[16]&&!u[18]&&!u[17]&&!u[91]||n||t.shortcut==="*")&&t.method(e,t)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}}function A(e,t){var i=s["*"],r=e.keyCode||e.which||e.charCode;if(v.filter.call(this,e)){if((r===93||r===224)&&(r=91),f.indexOf(r)===-1&&r!==229&&f.push(r),["ctrlKey","altKey","shiftKey","metaKey"].forEach(function(g){var w=L[g];e[g]&&f.indexOf(w)===-1?f.push(w):!e[g]&&f.indexOf(w)>-1?f.splice(f.indexOf(w),1):g==="metaKey"&&e[g]&&f.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(f=f.slice(f.indexOf(w))))}),r in u){u[r]=!0;for(var n in h)h[n]===r&&(v[n]=!0);if(!i)return}for(var a in u)Object.prototype.hasOwnProperty.call(u,a)&&(u[a]=e[L[a]]);e.getModifierState&&!(e.altKey&&!e.ctrlKey)&&e.getModifierState("AltGraph")&&(f.indexOf(17)===-1&&f.push(17),f.indexOf(18)===-1&&f.push(18),u[17]=!0,u[18]=!0);var o=b();if(i)for(var l=0;l-1}function v(e,t,i){f=[];var r=T(e),n=[],a="all",o=document,l=0,c=!1,p=!0,m="+",y=!1;for(i===void 0&&typeof t=="function"&&(i=t),Object.prototype.toString.call(t)==="[object Object]"&&(t.scope&&(a=t.scope),t.element&&(o=t.element),t.keyup&&(c=t.keyup),t.keydown!==void 0&&(p=t.keydown),t.capture!==void 0&&(y=t.capture),typeof t.splitKey=="string"&&(m=t.splitKey)),typeof t=="string"&&(a=t);l1&&(n=B(h,e)),e=e[e.length-1],e=e==="*"?"*":x(e),e in s||(s[e]=[]),s[e].push({keyup:c,keydown:p,scope:a,mods:n,shortcut:r[l],method:i,key:r[l],splitKey:m,element:o});typeof o<"u"&&!Q(o)&&window&&(D.push(o),M(o,"keydown",function(d){A(d,o)},y),_||(_=!0,M(window,"focus",function(){f=[]},y)),M(o,"keyup",function(d){A(d,o),J(d)},y))}function W(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(s).forEach(function(i){var r=s[i].filter(function(n){return n.scope===t&&n.shortcut===e});r.forEach(function(n){n&&n.method&&n.method()})})}var S={getPressedKeyString:X,setScope:H,getScope:b,deleteScope:z,getPressedKeyCodes:V,isPressed:q,filter:$,trigger:W,unbind:N,keyMap:O,modifier:h,modifierMap:L};for(var j in S)Object.prototype.hasOwnProperty.call(S,j)&&(v[j]=S[j]);if(typeof window<"u"){var Y=window.hotkeys;v.noConflict=function(e){return e&&window.hotkeys===v&&(window.hotkeys=Y),v},window.hotkeys=v}export{v as h};