/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import t from"../../core/ArrayPool.js";import{handlesGroup as e,makeHandle as n}from"../../core/handleUtils.js";import"../../core/has.js";import"../../core/Logger.js";import{wrapAbortWithTimeout as o,signalFromSignalOrOptions as i,isAborted as r}from"../../core/promiseUtils.js";import{watch as s,syncAndInitial as c}from"../../core/reactiveUtils.js";import{waitAnimationFrame as a}from"../../core/scheduling.js";import{clearVNodeCache as u}from"./vnodeCache.js";var f,l,d=function(t){if("WebkitTransition"in t.style)f="webkitTransitionEnd",l="webkitAnimationEnd";else{if(!("transition"in t.style))throw new Error("Your browser is not supported!");f="transitionend",l="animationend"}},m=function(t){f||d(t)},v=function(t,e){return void 0===e&&(e=t+"-active"),function(n){m(n);var o=!1,i=function(r){o||(o=!0,n.removeEventListener(f,i),n.removeEventListener(l,i),n.classList.remove(t),n.classList.remove(e))};n.classList.add(t),n.addEventListener(f,i),n.addEventListener(l,i),requestAnimationFrame(function(){n.classList.add(e)})}},p=function(t,e){return void 0===e&&(e=t+"-active"),function(n,o){m(n);var i=!1,r=function(t){i||(i=!0,n.removeEventListener(f,r),n.removeEventListener(l,r),o())};n.classList.add(t),n.addEventListener(f,r),n.addEventListener(l,r),requestAnimationFrame(function(){n.classList.add(e)})}};const L=1e4;function w(...e){const n=t.acquire();for(let t=0;t<e.length;t++){const o=e[t],i=typeof o;if("string"===i)n.push(o);else if(Array.isArray(o))n.push.apply(n,o);else if("object"===i)for(const t in o)o[t]&&n.push(t)}const o=n.join(" ");return t.release(n),o}const y=(()=>{const t=new Map,o=new ResizeObserver(e=>{u();for(const n of e)t.get(n.target)?.(n)}),i=(e,i,r)=>(t.set(e,i),o.observe(e,r),n(()=>{o.unobserve(e),t.delete(e)}));return(t,o,r)=>{let a=null;return e([s(()=>"function"==typeof t?t():t,t=>{a?.remove(),t&&(a=i(t,o,r))},c),n(()=>a?.remove())])}})();function E(t){const e=t?.closest("[dir]");return null!==e&&e instanceof HTMLElement&&"rtl"===e.dir||"rtl"===document.dir}function h(t,e){return("enter"===t?v:p)(e)}function b(t){const e="data-node-ref";this[t.getAttribute(e)]=null}function j(t){const e="data-node-ref";this[t.getAttribute(e)]=t}async function g(t,e){const n=o(e,L),s=i(n),c=e?.waitForFocus??!0;await a(s);const u="function"==typeof t?t():t;if(!u)return;const f=async()=>{"setFocus"in u&&"function"==typeof u.setFocus?await u.setFocus():u instanceof HTMLElement&&u.focus()};if(c)for(;!A(u)&&!r(n);)await a(s),await f();else r(n)||A(u)||await f()}function A(t){return t.matches(":focus-within")||document.activeElement===t}async function T(t,e){await a(i(e));const n="function"==typeof t?t():t;n&&("selectText"in n&&"function"==typeof n.selectText?await n.selectText():n instanceof HTMLInputElement&&n.select())}export{w as classes,h as cssTransition,b as discardNode,E as isRTL,y as onResize,T as selectText,g as setFocus,j as storeNode};
