Module 885714

3,061 characters · in no known chunk
Dependencies
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{Cl:()=>R,K7:()=>L,ME:()=>C,lb:()=>O,pP:()=>N});var r=n(89494),i=n(408713),s=n(23975),a=n(297987),o=n(64700),l=n(341221);let u=null,c=new Set,d=new Map,_=!1,f=!1,p={Tab:!0,Escape:!0};function h(e,t){for(let n of c)n(e,t)}function m(e){return!(e.metaKey||!(0,i.cX)()&&e.altKey||e.ctrlKey||"Control"===e.key||"Shift"===e.key||"Meta"===e.key)}function E(e){_=!0,m(e)&&(u="keyboard",h("keyboard",e))}function g(e){u="pointer",("mousedown"===e.type||"pointerdown"===e.type)&&(_=!0,h("pointer",e))}function A(e){(0,s.Y)(e)&&(_=!0,u="virtual")}function I(e){e.target!==window&&e.target!==document&&!r.lR&&e.isTrusted&&(_||f||(u="virtual",h("virtual",e)),_=!1,f=!1)}function T(){r.lR||(_=!1,f=!0)}function S(e){if("u"<typeof window||"u"<typeof document||d.get((0,a.mD)(e)))return;let t=(0,a.mD)(e),n=(0,a.TW)(e),r=t.HTMLElement.prototype.focus;t.HTMLElement.prototype.focus=function(){_=!0,r.apply(this,arguments)},n.addEventListener("keydown",E,!0),n.addEventListener("keyup",E,!0),n.addEventListener("click",A,!0),t.addEventListener("focus",I,!0),t.addEventListener("blur",T,!1),"u">typeof PointerEvent&&(n.addEventListener("pointerdown",g,!0),n.addEventListener("pointermove",g,!0),n.addEventListener("pointerup",g,!0)),t.addEventListener("beforeunload",()=>{y(e)},{once:!0}),d.set(t,{focus:r})}let y=(e,t)=>{let n=(0,a.mD)(e),r=(0,a.TW)(e);t&&r.removeEventListener("DOMContentLoaded",t),d.has(n)&&(n.HTMLElement.prototype.focus=d.get(n).focus,r.removeEventListener("keydown",E,!0),r.removeEventListener("keyup",E,!0),r.removeEventListener("click",A,!0),n.removeEventListener("focus",I,!0),n.removeEventListener("blur",T,!1),"u">typeof PointerEvent&&(r.removeEventListener("pointerdown",g,!0),r.removeEventListener("pointermove",g,!0),r.removeEventListener("pointerup",g,!0)),d.delete(n))};function v(e){let t,n=(0,a.TW)(e);return"loading"!==n.readyState?S(e):(t=()=>{S(e)},n.addEventListener("DOMContentLoaded",t)),()=>y(e,t)}function N(){return"pointer"!==u}function C(){return u}function R(e){u=e,h(e,null)}function O(){S();let[e,t]=(0,o.useState)(u);return(0,o.useEffect)(()=>{let e=()=>{t(u)};return c.add(e),()=>{c.delete(e)}},[]),(0,l.wR)()?null:e}"u">typeof document&&v();let b=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function D(e,t,n){let r=(0,a.TW)(null==n?void 0:n.target),i="u">typeof window?(0,a.mD)(null==n?void 0:n.target).HTMLInputElement:HTMLInputElement,s="u">typeof window?(0,a.mD)(null==n?void 0:n.target).HTMLTextAreaElement:HTMLTextAreaElement,o="u">typeof window?(0,a.mD)(null==n?void 0:n.target).HTMLElement:HTMLElement,l="u">typeof window?(0,a.mD)(null==n?void 0:n.target).KeyboardEvent:KeyboardEvent;return!((e=e||r.activeElement instanceof i&&!b.has(r.activeElement.type)||r.activeElement instanceof s||r.activeElement instanceof o&&r.activeElement.isContentEditable)&&"keyboard"===t&&n instanceof l&&!p[n.key])}function L(e,t,n){S(),(0,o.useEffect)(()=>{let t=(t,r)=>{D(!!(null==n?void 0:n.isTextInput),t,r)&&e(N())};return c.add(t),()=>{c.delete(t)}},t)}}