"use strict";const o=require("./utils-yMPNzXQX.cjs.js"),$=require("./openLink-CkDzR4gQ.cjs.js"),l=require("react"),g=require("./SSRProvider-DZRLwxPS.cjs.js");function E(e){return e.pointerType===""&&e.isTrusted?!0:$.$c87311424ea30a05$export$a11b0059900ceec8()&&e.pointerType?e.type==="click"&&e.buttons===1:e.detail===0&&!e.pointerType}function k(e){return!$.$c87311424ea30a05$export$a11b0059900ceec8()&&e.width===0&&e.height===0||e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType==="mouse"}let f=null,i=new Set,c=new Map,d=!1,v=!1;const M={Tab:!0,Escape:!0};function b(e,r){for(let t of i)t(e,r)}function H(e){return!(e.metaKey||!$.$c87311424ea30a05$export$9ac100e40613ea10()&&e.altKey||e.ctrlKey||e.key==="Control"||e.key==="Shift"||e.key==="Meta")}function u(e){d=!0,!$.$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening&&H(e)&&(f="keyboard",b("keyboard",e))}function a(e){f="pointer","pointerType"in e&&e.pointerType,(e.type==="mousedown"||e.type==="pointerdown")&&(d=!0,b("pointer",e))}function y(e){!$.$ea8dcbcb9ea1b556$export$95185d699e05d4d7.isOpening&&E(e)&&(d=!0,f="virtual")}function m(e){e.target===window||e.target===document||o.$8a9cb279dc87e130$export$fda7da73ab5d4c48||!e.isTrusted||(!d&&!v&&(f="virtual",b("virtual",e)),d=!1,v=!1)}function L(){o.$8a9cb279dc87e130$export$fda7da73ab5d4c48||(d=!1,v=!0)}function x(e){if(typeof window>"u"||typeof document>"u"||c.get(o.$431fbd86ca7dc216$export$f21a1ffae260145a(e)))return;const r=o.$431fbd86ca7dc216$export$f21a1ffae260145a(e),t=o.$431fbd86ca7dc216$export$b204af158042fbac(e);let n=r.HTMLElement.prototype.focus;r.HTMLElement.prototype.focus=function(){d=!0,n.apply(this,arguments)},t.addEventListener("keydown",u,!0),t.addEventListener("keyup",u,!0),t.addEventListener("click",y,!0),r.addEventListener("focus",m,!0),r.addEventListener("blur",L,!1),typeof PointerEvent<"u"?(t.addEventListener("pointerdown",a,!0),t.addEventListener("pointermove",a,!0),t.addEventListener("pointerup",a,!0)):process.env.NODE_ENV==="test"&&(t.addEventListener("mousedown",a,!0),t.addEventListener("mousemove",a,!0),t.addEventListener("mouseup",a,!0)),r.addEventListener("beforeunload",()=>{O(e)},{once:!0}),c.set(r,{focus:n})}const O=(e,r)=>{const t=o.$431fbd86ca7dc216$export$f21a1ffae260145a(e),n=o.$431fbd86ca7dc216$export$b204af158042fbac(e);r&&n.removeEventListener("DOMContentLoaded",r),c.has(t)&&(t.HTMLElement.prototype.focus=c.get(t).focus,n.removeEventListener("keydown",u,!0),n.removeEventListener("keyup",u,!0),n.removeEventListener("click",y,!0),t.removeEventListener("focus",m,!0),t.removeEventListener("blur",L,!1),typeof PointerEvent<"u"?(n.removeEventListener("pointerdown",a,!0),n.removeEventListener("pointermove",a,!0),n.removeEventListener("pointerup",a,!0)):process.env.NODE_ENV==="test"&&(n.removeEventListener("mousedown",a,!0),n.removeEventListener("mousemove",a,!0),n.removeEventListener("mouseup",a,!0)),c.delete(t))};function w(){return f!=="pointer"}function S(){return f}function I(e){f=e,b(e,null)}function K(){x();let[e,r]=l.useState(f);return l.useEffect(()=>{let t=()=>{r(f)};return i.add(t),()=>{i.delete(t)}},[]),g.$b5e257d569688ac6$export$535bd6ca7f90a273()?null:e}const C=new Set(["checkbox","radio","range","color","file","image","button","submit","reset"]);function F(e,r,t){let n=o.$431fbd86ca7dc216$export$b204af158042fbac(t?.target);const s=typeof window<"u"?o.$431fbd86ca7dc216$export$f21a1ffae260145a(t?.target).HTMLInputElement:HTMLInputElement,p=typeof window<"u"?o.$431fbd86ca7dc216$export$f21a1ffae260145a(t?.target).HTMLTextAreaElement:HTMLTextAreaElement,T=typeof window<"u"?o.$431fbd86ca7dc216$export$f21a1ffae260145a(t?.target).HTMLElement:HTMLElement,h=typeof window<"u"?o.$431fbd86ca7dc216$export$f21a1ffae260145a(t?.target).KeyboardEvent:KeyboardEvent;return e=e||n.activeElement instanceof s&&!C.has(n.activeElement.type)||n.activeElement instanceof p||n.activeElement instanceof T&&n.activeElement.isContentEditable,!(e&&r==="keyboard"&&t instanceof h&&!M[t.key])}function j(e,r,t){x(),l.useEffect(()=>{let n=(s,p)=>{F(!!t?.isTextInput,s,p)&&e(w())};return i.add(n),()=>{i.delete(n)}},r)}exports.$507fabe10e71c6fb$export$630ff653c5ada6a9=S;exports.$507fabe10e71c6fb$export$8397ddfc504fdb9a=I;exports.$507fabe10e71c6fb$export$98e20ec92f614cfe=K;exports.$507fabe10e71c6fb$export$b9b3dfddab17db27=w;exports.$507fabe10e71c6fb$export$ec71b4b83ac08ec3=j;exports.$6a7db85432448f7f$export$29bf1b5f2c56cf63=k;exports.$6a7db85432448f7f$export$60278871457622de=E;
//# sourceMappingURL=useFocusVisible-CKofa_M1.cjs.js.map
