import{r as i,g as d,a as E}from"./vendor-react-ece1c85f.js";import{bE as h}from"./index-c62ac197.js";function N(t){const r=i.useRef(null);return t||r}var p=h,D=0;function m(t){var r=++D;return p(t)+r}var v=m;const y=d(v),I=(t=10)=>{const r=[],n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",c=n.length,o=t;for(let u=0;u<o;u++)r[u]=n.charAt(Math.floor(Math.random()*c));return r.join("")};function U(t="",r=10){const n=i.useRef();return n.current||(n.current=`${y(t)}-${I(r)}`),n.current}const e=(t,r)=>{if(t.contains)return t.contains(r);if(t.compareDocumentPosition)return t===r||!!(t.compareDocumentPosition(r)&16);if(r)do if(r===t)return!0;while(r=r.parentNode);return!1},M=t=>t&&("current"in t?t.current:t);function f(t){const r=(t==null?void 0:t.root)||(t==null?void 0:t.child)||M(t);return r!=null&&r.nodeType&&typeof(r==null?void 0:r.nodeName)=="string"?r:E.findDOMNode(r)}function b(t){return(t==null?void 0:t.button)===0}function g(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t!=null&&t.shiftKey)}function q(t,r,n,c=!1){return t.addEventListener(r,n,c),{off(){t.removeEventListener(r,n,c)}}}function l(t,{disabled:r,triggerTarget:n,overlayTarget:c}){const o=i.useCallback(u=>{const a=f(n),s=f(c);a&&e(a,u.target)||s&&e(s,u.target)||g(u)||!b(u)||t==null||t(u)},[t,n,c]);i.useEffect(()=>{const u=f(n);if(r||!u)return;const s=q((()=>u&&u.ownerDocument||document)(),"mousedown",o,!0);return()=>{s==null||s.off()}},[n,r,t,o])}function L(t,r){const n=i.useRef(!1);i.useEffect(()=>()=>{n.current=!1},[]),i.useEffect(()=>{if(n.current)return t();n.current=!0},r)}export{U as a,l as b,L as c,N as u};
