text: "use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),n=t(e),r=t(require("@reach/portal")),i=require("@reach/rect"),o=require("@reach/utils"),u=t(require("tabbable"));function f(){return(f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var c=e.forwardRef((function(t,e){return n.createElement(r,null,n.createElement(a,Object.assign({ref:e},t)))})),a=e.forwardRef((function(t,r){var c=t.targetRef,a=t.position,s=void 0===a?d:a,p=t.unstable_observableRefs,v=void 0===p?[]:p,h=function(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(i[n]=t[n]);return i}(t,["targetRef","position","unstable_observableRefs"]),g=e.useRef(null),w=i.useRect(g),b=i.useRect(c),y=o.useForkedRef(g,r);return function(t,n){var r=o.getOwnerDocument(t.current);function i(e){"Tab"===e.key&&n.current&&0===u(n.current).length||("Tab"===e.key&&e.shiftKey?function(t){if(t.shiftKey){var e=f();return t.target===e}}(e)?function(t){var e=n.current&&u(n.current),r=e&&e[e.length-1];r&&(t.preventDefault(),r.focus())}(e):function(t){var e=n.current&&u(n.current);return!!e&&0!==e.length&&t.target===e[0]}(e)?function(e){var n;e.preventDefault(),null===(n=t.current)||void 0===n||n.focus()}(e):function(t){return!!r&&t.target===u(r)[0]}(e)&&a():"Tab"===e.key&&(t.current&&r&&t.current===r.activeElement?function(t){var e=n.current&&u(n.current);e&&e[0]&&(t.preventDefault(),e[0].focus())}(e):function(){if(n.current&&r&&n.current.contains(r.activeElement||null)){var t=n.current&&u(n.current);return Boolean(t&&r&&t[t.length-1]===r.activeElement)}return!1}()?function(t){var e=f();e&&(t.preventDefault(),e.focus())}(e):function(t){var e=r&&n.current?u(r).filter((function(t){return!n.current.contains(t)})):null;return!!e&&t.target===e[e.length-1]}(e)&&a()))}function f(){var e=r&&u(r),n=e&&t.current?e.indexOf(t.current):-1;return e&&e[n+1]}e.useEffect((function(){if(r)return r.addEventListener("keydown",i),function(){r.removeEventListener("keydown",i)}}),[]);var c=[];function a(){var t=n.current&&u(n.current);t&&(t.forEach((function(t){c.push([t,t.tabIndex]),t.tabIndex=-1})),r&&r.addEventListener("focusin",l))}function l(){r&&r.removeEventListener("focusin",l),c.forEach((function(t){t[0].tabIndex=t[1]}))}}(c,g),n.createElement("div",Object.assign({"data-reach-popover":"",ref:y},h,{style:f({position:"absolute"},l.apply(void 0,[s,b,w].concat(v)),{},h.style)}))}));function l(t,e,n){var r=!n;if(r)return{visibility:"hidden"};for(var i=arguments.length,o=new Array(i>3?i-3:0),u=3;u<i;u++)o[u-3]=arguments[u];return t.apply(void 0,[e,n].concat(o.map((function(t){return t.current}))))}function s(t,e){return{top:p(t,e).directionUp?t.top-e.height+window.pageYOffset+"px":t.top+t.height+window.pageYOffset+"px"}}var d=function(t,e){return t&&e?f({left:p(t,e).directionRight?t.right-e.width+window.pageXOffset+"px":t.left+window.pageXOffset+"px"},s(t,e)):{}};function p(t,e,n,r){void 0===n&&(n=0),void 0===r&&(r=0);var i={top:t.top-e.height<0,right:window.innerWidth<t.left+e.width-n,bottom:window.innerHeight<t.bottom+e.height-r,left:t.left+t.width-e.width<0};return{directionRight:i.right&&!i.left,directionLeft:i.left&&!i.right,directionUp:i.bottom&&!i.top,directionDown:i.top&&!i.bottom}}exports.default=c,exports.getCollisions=p,exports.positionDefault=d,exports.positionMatchWidth=function(t,e){return t&&e?f({width:t.width,left:t.left},s(t,e)):{}},exports.positionRight=function(t,e){return t&&e?f({left:p(t,e).directionLeft?t.left+window.pageXOffset+"px":t.right-e.width+window.pageXOffset+"px"},s(t,e)):{}};
  //# sourceMappingURL=popover.cjs.production.min.js.map
  