1import{j as O,G as $,A as R,bL as Q,i as y,ag as te,d as ne,k as se,z as h,D as T,bo as oe,Z as ce,S as j,bg as re}from"./DWU_OSrH.js";function Pe(e){return e===void 0}let E=[];const M=e=>{const n=e;n.key===Q.esc&&E.forEach(s=>s(n))},ae=e=>{O(()=>{E.length===0&&document.addEventListener("keydown",M),$&&E.push(e)}),R(()=>{E=E.filter(n=>n!==e),E.length===0&&$&&document.removeEventListener("keydown",M)})},w="focus-trap.focus-after-trapped",g="focus-trap.focus-after-released",ue="focus-trap.focusout-prevented",q={cancelable:!0,bubbles:!1},ie={cancelable:!0,bubbles:!1},W="focusAfterTrapped",z="focusAfterReleased",de=Symbol("elFocusTrap"),k=y(),P=y(0),N=y(0);let F=0;const X=e=>{const n=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const r=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||r?NodeFilter.FILTER_SKIP:o.tabIndex>=0||o===document.activeElement?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)n.push(s.currentNode);return n},G=(e,n)=>{for(const s of e)if(!fe(s,n))return s},fe=(e,n)=>{if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(n&&e===n)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1},le=e=>{const n=X(e),s=G(n,e),o=G(n.reverse(),e);return[s,o]},ve=e=>e instanceof HTMLInputElement&&"select"in e,l=(e,n)=>{if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),N.value=window.performance.now(),e!==s&&ve(e)&&n&&e.select()}};function J(e,n){const s=[...e],o=e.indexOf(n);return o!==-1&&s.splice(o,1),s}const Ee=()=>{let e=[];return{push:o=>{const r=e[0];r&&o!==r&&r.pause(),e=J(e,o),e.unshift(o)},remove:o=>{var r,d;e=J(e,o),(d=(r=e[0])==null?void 0:r.resume)==null||d.call(r)}}},pe=(e,n=!1)=>{const s=document.activeElement;for(const o of e)if(l(o,n),document.activeElement!==s)return},Y=Ee(),me=()=>P.value>N.value,b=()=>{k.value="pointer",P.value=window.performance.now()},Z=()=>{k.value="keyboard",P.value=window.performance.now()},Te=()=>(O(()=>{F===0&&(document.addEventListener("mousedown",b),document.addEventListener("touchstart",b),document.addEventListener("keydown",Z)),F++}),R(()=>{F--,F<=0&&(document.removeEventListener("mousedown",b),document.removeEventListener("touchstart",b),document.removeEventListener("keydown",Z))}),{focusReason:k,lastUserFocusTimestamp:P,lastAutomatedFocusTimestamp:N}),_=e=>new CustomEvent(ue,{...ie,detail:e}),Fe=ne({name:"ElFocusTrap",inheritAttrs:!1,props:{loop:Boolean,trapped:Boolean,focusTrapEl:Object,focusStartEl:{type:[Object,String],default:"first"}},emits:[W,z,"focusin","focusout","focusout-prevented","release-requested"],setup(e,{emit:n}){const s=y();let o,r;const{focusReason:d}=Te();ae(t=>{e.trapped&&!v.paused&&n("release-requested",t)});const v={paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}},p=t=>{if(!e.loop&&!e.trapped||v.paused)return;const{key:c,altKey:a,ctrlKey:u,metaKey:i,currentTarget:H,shiftKey:V}=t,{loop:B}=e,ee=c===Q.tab&&!a&&!u&&!i,m=document.activeElement;if(ee&&m){const S=H,[L,C]=le(S);if(L&&C){if(!V&&m===C){const f=_({focusReason:d.value});n("focusout-prevented",f),f.defaultPrevented||(t.preventDefault(),B&&l(L,!0))}else if(V&&[L,S].includes(m)){const f=_({focusReason:d.value});n("focusout-prevented",f),f.defaultPrevented||(t.preventDefault(),B&&l(C,!0))}}else if(m===S){const f=_({focusReason:d.value});n("focusout-prevented",f),f.defaultPrevented||t.preventDefault()}}};se(de,{focusTrapRef:s,onKeydown:p}),h(()=>e.focusTrapEl,t=>{t&&(s.value=t)},{immediate:!0}),h([s],([t],[c])=>{t&&(t.addEventListener("keydown",p),t.addEventListener("focusin",U),t.addEventListener("focusout",K)),c&&(c.removeEventListener("keydown",p),c.removeEventListener("focusin",U),c.removeEventListener("focusout",K))});const A=t=>{n(W,t)},I=t=>n(z,t),U=t=>{const c=T(s);if(!c)return;const a=t.target,u=t.relatedTarget,i=a&&c.contains(a);e.trapped||u&&c.contains(u)||(o=u),i&&n("focusin",t),!v.paused&&e.trapped&&(i?r=a:l(r,!0))},K=t=>{const c=T(s);if(!(v.paused||!c))if(e.trapped){const a=t.relatedTarget;!oe(a)&&!c.contains(a)&&setTimeout(()=>{if(!v.paused&&e.trapped){const u=_({focusReason:d.value});n("focusout-prevented",u),u.defaultPrevented||l(r,!0)}},0)}else{const a=t.target;a&&c.contains(a)||n("focusout",t)}};async function D(){await j();const t=T(s);if(t){Y.push(v);const c=t.contains(document.activeElement)?o:document.activeElement;if(o=c,!t.contains(c)){const u=new Event(w,q);t.addEventListener(w,A),t.dispatchEvent(u),u.defaultPrevented||j(()=>{let i=e.focusStartEl;re(i)||(l(i),document.activeElement!==i&&(i="first")),i==="first"&&pe(X(t),!0),(document.activeElement===c||i==="container")&&l(t)})}}}function x(){const t=T(s);if(t){t.removeEventListener(w,A);
1const c=new CustomEvent(g,{...q,detail:{focusReason:d.value}});t.addEventListener(g,I),t.dispatchEvent(c),!c.defaultPrevented&&(d.value=="keyboard"||!me()||t.contains(document.activeElement))&&l(o??document.body),t.removeEventListener(g,I),Y.remove(v)}}return O(()=>{e.trapped&&D(),h(()=>e.trapped,t=>{t?D():x()})}),R(()=>{e.trapped&&x()}),{onKeydown:p}}});function be(e,n,s,o,r,d){return ce(e.$slots,"default",{handleKeydown:e.onKeydown})}var Se=te(Fe,[["render",be],["__file","focus-trap.vue"]]);export{Se as E,de as F,Pe as i};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.