1import{f as ue,t as ie}from"./BT9aYxTL.js";import{m as K,U as B,l as L,aY as _,a5 as le,d as oe,W as H,z as S,f as w,b0 as de,v as Y,ay as fe,ab as ve,az as x,a3 as pe,a7 as ne,e as me,aX as Ee,a4 as j,R as ye,A as Te,c6 as he,df as be,dg as we,dh as Fe,di as Ce}from"./DIaYQIFd.js";import{g as se,E as ae}from"./M1sZw_ff.js";import{P as A}from"./C6NrRSbh.js";const M="focus-trap.focus-after-trapped",U="focus-trap.focus-after-released",ge="focus-trap.focusout-prevented",q={cancelable:!0,bubbles:!1},Pe={cancelable:!0,bubbles:!1},J="focusAfterTrapped",X="focusAfterReleased",Se=Symbol("elFocusTrap"),D=L(),O=L(0),W=L(0);let F=0;const re=e=>{const o=[],t=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0||n===document.activeElement?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;t.nextNode();)o.push(t.currentNode);return o},G=(e,o)=>{for(const t of e)if(!_e(t,o))return t},_e=(e,o)=>{if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(o&&e===o)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1},Le=e=>{const o=re(e),t=G(o,e),n=G(o.reverse(),e);return[t,n]},Oe=e=>e instanceof HTMLInputElement&&"select"in e,m=(e,o)=>{if(e){const t=document.activeElement;ue(e,{preventScroll:!0}),W.value=window.performance.now(),e!==t&&Oe(e)&&o&&e.select()}};function Q(e,o){const t=[...e],n=e.indexOf(o);return n!==-1&&t.splice(n,1),t}const ke=()=>{let e=[];return{push:n=>{const a=e[0];a&&n!==a&&a.pause(),e=Q(e,n),e.unshift(n)},remove:n=>{var a,r;e=Q(e,n),(r=(a=e[0])==null?void 0:a.resume)==null||r.call(a)}}},Re=(e,o=!1)=>{const t=document.activeElement;for(const n of e)if(m(n,o),document.activeElement!==t)return},Z=ke(),Ne=()=>O.value>W.value,C=()=>{D.value="pointer",O.value=window.performance.now()},ee=()=>{D.value="keyboard",O.value=window.performance.now()},Ie=()=>(K(()=>{F===0&&(document.addEventListener("mousedown",C),document.addEventListener("touchstart",C),document.addEventListener("keydown",ee)),F++}),B(()=>{F--,F<=0&&(document.removeEventListener("mousedown",C),document.removeEventListener("touchstart",C),document.removeEventListener("keydown",ee))}),{focusReason:D,lastUserFocusTimestamp:O,lastAutomatedFocusTimestamp:W}),g=e=>new CustomEvent(ge,{...Pe,detail:e});let y=[];const te=e=>{se(e)===ae.esc&&y.forEach(t=>t(e))},xe=e=>{K(()=>{y.length===0&&document.addEventListener("keydown",te),_&&y.push(e)}),B(()=>{y=y.filter(o=>o!==e),y.length===0&&_&&document.removeEventListener("keydown",te)})},Ae=oe({name:"ElFocusTrap",inheritAttrs:!1,props:{loop:Boolean,trapped:Boolean,focusTrapEl:Object,focusStartEl:{type:[Object,String],default:"first"}},emits:[J,X,"focusin","focusout","focusout-prevented","release-requested"],setup(e,{emit:o}){const t=L();let n,a;const{focusReason:r}=Ie();xe(s=>{e.trapped&&!c.paused&&o("release-requested",s)});const c={paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}},i=s=>{if(!e.loop&&!e.trapped||c.paused)return;const{altKey:u,ctrlKey:l,metaKey:d,currentTarget:f,shiftKey:k}=s,{loop:$}=e,ce=se(s)===ae.tab&&!u&&!l&&!d,b=document.activeElement;if(ce&&b){const R=f,[N,I]=Le(R);if(N&&I){if(!k&&b===I){const p=g({focusReason:r.value});o("focusout-prevented",p),p.defaultPrevented||(s.preventDefault(),$&&m(N,!0))}else if(k&&[N,R].includes(b)){const p=g({focusReason:r.value});o("focusout-prevented",p),p.defaultPrevented||(s.preventDefault(),$&&m(I,!0))}}else if(b===R){const p=g({focusReason:r.value});o("focusout-prevented",p),p.defaultPrevented||s.preventDefault()}}};ve(Se,{focusTrapRef:t,onKeydown:i}),S(()=>e.focusTrapEl,s=>{s&&(t.value=s)},{immediate:!0}),S([t],([s],[u])=>{s&&(s.addEventListener("keydown",i),s.addEventListener("focusin",T),s.addEventListener("focusout",h)),u&&(u.removeEventListener("keydown",i),u.removeEventListener("focusin",T),u.removeEventListener("focusout",h))});const v=s=>{o(J,s)},E=s=>o(X,s),T=s=>{const u=w(t);if(!u)return;const l=s.target,d=s.relatedTarget,f=l&&u.contains(l);e.trapped||d&&u.contains(d)||(n=d),f&&o("focusin",s),!c.paused&&e.trapped&&(f?a=l:m(a,!0))},h=s=>{const u=w(t);if(!(c.paused||!u))if(e.trapped){const l=s.relatedTarget;!de(l)&&!u.contains(l)&&setTimeout(()=>{if(!c.paused&&e.trapped){const d=g({focusReason:r.value});o("focusout-prevented",d),d.defaultPrevented||m(a,!0)}},0)}else{const l=s.target;
1l&&u.contains(l)||o("focusout",s)}};async function V(){await Y();const s=w(t);if(s){Z.push(c);const u=s.contains(document.activeElement)?n:document.activeElement;if(n=u,!s.contains(u)){const d=new Event(M,q);s.addEventListener(M,v),s.dispatchEvent(d),d.defaultPrevented||Y(()=>{let f=e.focusStartEl;fe(f)||(m(f),document.activeElement!==f&&(f="first")),f==="first"&&Re(re(s),!0),(document.activeElement===u||f==="container")&&m(s)})}}}function z(){const s=w(t);if(s){s.removeEventListener(M,v);const u=new CustomEvent(U,{...q,detail:{focusReason:r.value}});s.addEventListener(U,E),s.dispatchEvent(u),!u.defaultPrevented&&(r.value=="keyboard"||!Ne()||s.contains(document.activeElement))&&m(n??document.body),s.removeEventListener(U,E),Z.remove(c),n=null,a=null}}return K(()=>{e.trapped&&V(),S(()=>e.trapped,s=>{s?V():z()})}),B(()=>{e.trapped&&z(),t.value&&(t.value.removeEventListener("keydown",i),t.value.removeEventListener("focusin",T),t.value.removeEventListener("focusout",h),t.value=void 0),n=null,a=null}),{onKeydown:i}}});function Me(e,o,t,n,a,r){return H(e.$slots,"default",{handleKeydown:e.onKeydown})}var Je=le(Ae,[["render",Me],["__file","/home/runner/work/element-plus/element-plus/packages/components/focus-trap/src/focus-trap.vue"]]);const Ue=e=>{if(!e)return{onClick:x,onMousedown:x,onMouseup:x};let o=!1,t=!1;return{onClick:c=>{o&&t&&e(c),o=t=!1},onMousedown:c=>{o=c.target===c.currentTarget},onMouseup:c=>{t=c.target===c.currentTarget}}},He=pe({mask:{type:Boolean,default:!0},customMaskEvent:Boolean,overlayClass:{type:j([String,Array,Object])},zIndex:{type:j([String,Number])}}),Ke={click:e=>e instanceof MouseEvent},Be="overlay";var De=oe({name:"ElOverlay",props:He,emits:Ke,setup(e,{slots:o,emit:t}){const n=ne(Be),a=v=>{t("click",v)},{onClick:r,onMousedown:c,onMouseup:i}=Ue(e.customMaskEvent?void 0:a);return()=>e.mask?me("div",{class:[n.b(),e.overlayClass],style:{zIndex:e.zIndex},onClick:r,onMousedown:c,onMouseup:i},[H(o,"default")],A.STYLE|A.CLASS|A.PROPS,["onClick","onMouseup","onMousedown"]):Ee("div",{class:e.overlayClass,style:{zIndex:e.zIndex,position:"fixed",top:"0px",right:"0px",bottom:"0px",left:"0px"}},[H(o,"default")])}});const Xe=De;let P;const We=e=>{var o;if(!_)return 0;if(P!==void 0)return P;const t=document.createElement("div");t.className=`${e}-scrollbar__wrap`,t.style.visibility="hidden",t.style.width="100px",t.style.position="absolute",t.style.top="-9999px",document.body.appendChild(t);const n=t.offsetWidth;t.style.overflow="scroll";const a=document.createElement("div");a.style.width="100%",t.appendChild(a);const r=a.offsetWidth;return(o=t.parentNode)==null||o.removeChild(t),P=n-r,P};function Ge(e,o){if(!_)return;if(!o){e.scrollTop=0;return}const t=[];let n=o.offsetParent;for(;n!==null&&e!==n&&e.contains(n);)t.push(n),n=n.offsetParent;const a=o.offsetTop+t.reduce((v,E)=>v+E.offsetTop,0),r=a+o.offsetHeight,c=e.scrollTop,i=c+e.clientHeight;a<c?e.scrollTop=a:r>i&&(e.scrollTop=r-e.clientHeight)}const Qe=(e,o={})=>{ye(e)||ie("[useLockscreen]","You need to pass a ref param to this function");const t=o.ns||ne("popup"),n=Te(()=>t.bm("parent","hidden"));let a=0,r=!1,c="0",i=!1;const v=()=>{i||(i=!0,setTimeout(()=>{typeof document>"u"||r&&document&&(document.body.style.width=c,Ce(document.body,n.value))},200))};S(e,E=>{if(!E){v();return}i=!1,r=!be(document.body,n.value),r&&(c=document.body.style.width,we(document.body,n.value)),a=We(t.namespace.value);const T=document.documentElement.clientHeight<document.body.scrollHeight,h=Fe(document.body,"overflowY");a>0&&(T||h==="scroll")&&r&&(document.body.style.width=`calc(100% - ${a}px)`)}),he(()=>v())};export{Je as E,Se as F,Xe as a,Ue as b,Ge as s,Qe as u};
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.