import{L as ae,aU as ne,aV as se,M as ue,aW as le,aX as w,aY as ie,aZ as re,r as M,c as l,O as ce,a_ as fe,a$ as de,b0 as ve,b1 as ge,b2 as he,b3 as me,b4 as be,w as A,b5 as ye,aa as Pe,b6 as Te,b7 as D,b8 as R,b9 as ke,ba as Ce,h as H,ae as Se,A as xe,l as Oe,g as qe,bb as K,bc as Be,bd as Ee,be as Fe,bf as we,bg as Me,ac as Ae}from"./index.be232763.js";var Re=ae({name:"QMenu",inheritAttrs:!1,props:{...ne,...se,...ue,...le,persistent:Boolean,autoClose:Boolean,separateClosePopup:Boolean,noRouteDismiss:Boolean,noRefocus:Boolean,noFocus:Boolean,fit:Boolean,cover:Boolean,square:Boolean,anchor:{type:String,validator:w},self:{type:String,validator:w},offset:{type:Array,validator:ie},scrollTarget:{default:void 0},touchPosition:Boolean,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null}},emits:[...re,"click","escapeKey"],setup(t,{slots:W,emit:c,attrs:d}){let n=null,f,i,v;const P=qe(),{proxy:g}=P,{$q:o}=g,a=M(null),s=M(!1),Q=l(()=>t.persistent!==!0&&t.noRouteDismiss!==!0),_=ce(t,o),{registerTick:L,removeTick:U}=fe(),{registerTimeout:T}=de(),{transitionProps:$,transitionStyle:j}=ve(t),{localScrollTarget:k,changeScrollEvent:I,unconfigureScrollTarget:V}=ge(t,E),{anchorEl:u,canShow:X}=he({showing:s}),{hide:C}=me({showing:s,canShow:X,handleShow:J,handleHide:N,hideOnRouteChange:Q,processOnMount:!0}),{showPortal:S,hidePortal:x,renderPortal:Y}=be(P,a,ee,"menu"),h={anchorEl:u,innerRef:a,onClickOutside(e){if(t.persistent!==!0&&s.value===!0)return C(e),(e.type==="touchstart"||e.target.classList.contains("q-dialog__backdrop"))&&Ae(e),!0}},O=l(()=>K(t.anchor||(t.cover===!0?"center middle":"bottom start"),o.lang.rtl)),Z=l(()=>t.cover===!0?O.value:K(t.self||"top start",o.lang.rtl)),z=l(()=>(t.square===!0?" q-menu--square":"")+(_.value===!0?" q-menu--dark q-dark":"")),G=l(()=>t.autoClose===!0?{onClick:p}:{}),q=l(()=>s.value===!0&&t.persistent!==!0);A(q,e=>{e===!0?(Be(b),Ee(h)):(R(b),D(h))});function m(){Fe(()=>{let e=a.value;e&&e.contains(document.activeElement)!==!0&&(e=e.querySelector("[autofocus][tabindex], [data-autofocus][tabindex]")||e.querySelector("[autofocus] [tabindex], [data-autofocus] [tabindex]")||e.querySelector("[autofocus], [data-autofocus]")||e,e.focus({preventScroll:!0}))})}function J(e){if(n=t.noRefocus===!1?document.activeElement:null,ye(F),S(),E(),f=void 0,e!==void 0&&(t.touchPosition||t.contextMenu)){const y=Pe(e);if(y.left!==void 0){const{top:te,left:oe}=u.value.getBoundingClientRect();f={left:y.left-oe,top:y.top-te}}}i===void 0&&(i=A(()=>o.screen.width+"|"+o.screen.height+"|"+t.self+"|"+t.anchor+"|"+o.lang.rtl,r)),t.noFocus!==!0&&document.activeElement.blur(),L(()=>{r(),t.noFocus!==!0&&m()}),T(()=>{o.platform.is.ios===!0&&(v=t.autoClose,a.value.click()),r(),S(!0),c("show",e)},t.transitionDuration)}function N(e){U(),x(),B(!0),n!==null&&(e===void 0||e.qClickOutside!==!0)&&(((e&&e.type.indexOf("key")===0?n.closest('[tabindex]:not([tabindex^="-"])'):void 0)||n).focus(),n=null),T(()=>{x(!0),c("hide",e)},t.transitionDuration)}function B(e){f=void 0,i!==void 0&&(i(),i=void 0),(e===!0||s.value===!0)&&(Te(F),V(),D(h),R(b)),e!==!0&&(n=null)}function E(){(u.value!==null||t.scrollTarget!==void 0)&&(k.value=ke(u.value,t.scrollTarget),I(k.value,r))}function p(e){v!==!0?(we(g,e),c("click",e)):v=!1}function F(e){q.value===!0&&t.noFocus!==!0&&Me(a.value,e.target)!==!0&&m()}function b(e){c("escapeKey"),C(e)}function r(){const e=a.value;e===null||u.value===null||Ce({el:e,offset:t.offset,anchorEl:u.value,anchorOrigin:O.value,selfOrigin:Z.value,absoluteOffset:f,fit:t.fit,cover:t.cover,maxHeight:t.maxHeight,maxWidth:t.maxWidth})}function ee(){return H(xe,$.value,()=>s.value===!0?H("div",{role:"menu",...d,ref:a,tabindex:-1,class:["q-menu q-position-engine scroll"+z.value,d.class],style:[d.style,j.value],...G.value},Se(W.default)):null)}return Oe(B),Object.assign(g,{focus:m,updatePosition:r}),Y}});export{Re as Q};
