import{c as P,a as s,h as g,d as K,C as se,R as le,b6 as ue,D as ie,E as re,g as ce,r as M,F as de,aj as fe,G as ve,b7 as ge,H as he,b8 as me,w as A,b9 as be,ba as R,bb as ye,x as Be,bc as xe,M as Pe,bd as Te,T as Ce,e as Se,be as ke,bf as qe,B as Ee}from"./index-DA5wU65Q.js";import{v as Oe,g as H,i as pe,j as we,k as Fe,p as Q,l as De,r as j,s as Me}from"./QItemLabel-CBTzOxdh.js";const Qe=P({name:"QBtnGroup",props:{unelevated:Boolean,outline:Boolean,flat:Boolean,rounded:Boolean,square:Boolean,push:Boolean,stretch:Boolean,glossy:Boolean,spread:Boolean},setup(e,{slots:l}){const u=s(()=>{const i=["unelevated","outline","flat","rounded","square","push","stretch","glossy"].filter(o=>e[o]===!0).map(o=>`q-btn-group--${o}`).join(" ");return`q-btn-group row no-wrap${i.length!==0?" "+i:""}`+(e.spread===!0?" q-btn-group--spread":" inline")});return()=>g("div",{class:u.value},K(l.default))}}),je=P({name:"QSpace",setup(){const e=g("div",{class:"q-space"});return()=>e}}),Ke=P({name:"QMenu",inheritAttrs:!1,props:{...pe,...re,...ie,...ue,persistent:Boolean,autoClose:Boolean,separateClosePopup:Boolean,noEscDismiss:Boolean,noRouteDismiss:Boolean,noRefocus:Boolean,noFocus:Boolean,fit:Boolean,cover:Boolean,square:Boolean,anchor:{type:String,validator:H},self:{type:String,validator:H},offset:{type:Array,validator:Oe},scrollTarget:le,touchPosition:Boolean,maxHeight:{type:String,default:null},maxWidth:{type:String,default:null}},emits:[...se,"click","escapeKey"],setup(e,{slots:l,emit:u,attrs:i}){let o=null,v,c,h;const T=ce(),{proxy:m}=T,{$q:a}=m,n=M(null),r=M(!1),G=s(()=>e.persistent!==!0&&e.noRouteDismiss!==!0),L=de(e,a),{registerTick:W,removeTick:$}=fe(),{registerTimeout:C}=ve(),{transitionProps:_,transitionStyle:I}=ge(e),{localScrollTarget:S,changeScrollEvent:U,unconfigureScrollTarget:z}=we(e,F),{anchorEl:d,canShow:J}=Fe({showing:r}),{hide:k}=he({showing:r,canShow:J,handleShow:Z,handleHide:ee,hideOnRouteChange:G,processOnMount:!0}),{showPortal:q,hidePortal:E,renderPortal:N}=me(T,n,oe,"menu"),b={anchorEl:d,innerRef:n,onClickOutside(t){if(e.persistent!==!0&&r.value===!0)return k(t),(t.type==="touchstart"||t.target.classList.contains("q-dialog__backdrop"))&&Ee(t),!0}},O=s(()=>Q(e.anchor||(e.cover===!0?"center middle":"bottom start"),a.lang.rtl)),V=s(()=>e.cover===!0?O.value:Q(e.self||"top start",a.lang.rtl)),X=s(()=>(e.square===!0?" q-menu--square":"")+(L.value===!0?" q-menu--dark q-dark":"")),Y=s(()=>e.autoClose===!0?{onClick:te}:{}),p=s(()=>r.value===!0&&e.persistent!==!0);A(p,t=>{t===!0?(be(B),De(b)):(R(B),j(b))});function y(){ke(()=>{let t=n.value;t&&t.contains(document.activeElement)!==!0&&(t=t.querySelector("[autofocus][tabindex], [data-autofocus][tabindex]")||t.querySelector("[autofocus] [tabindex], [data-autofocus] [tabindex]")||t.querySelector("[autofocus], [data-autofocus]")||t,t.focus({preventScroll:!0}))})}function Z(t){if(o=e.noRefocus===!1?document.activeElement:null,ye(D),q(),F(),v=void 0,t!==void 0&&(e.touchPosition||e.contextMenu)){const x=Be(t);if(x.left!==void 0){const{top:ae,left:ne}=d.value.getBoundingClientRect();v={left:x.left-ne,top:x.top-ae}}}c===void 0&&(c=A(()=>a.screen.width+"|"+a.screen.height+"|"+e.self+"|"+e.anchor+"|"+a.lang.rtl,f)),e.noFocus!==!0&&document.activeElement.blur(),W(()=>{f(),e.noFocus!==!0&&y()}),C(()=>{a.platform.is.ios===!0&&(h=e.autoClose,n.value.click()),f(),q(!0),u("show",t)},e.transitionDuration)}function ee(t){$(),E(),w(!0),o!==null&&(t===void 0||t.qClickOutside!==!0)&&(((t?.type.indexOf("key")===0?o.closest('[tabindex]:not([tabindex^="-"])'):void 0)||o).focus(),o=null),C(()=>{E(!0),u("hide",t)},e.transitionDuration)}function w(t){v=void 0,c!==void 0&&(c(),c=void 0),(t===!0||r.value===!0)&&(xe(D),z(),j(b),R(B)),t!==!0&&(o=null)}function F(){(d.value!==null||e.scrollTarget!==void 0)&&(S.value=Pe(d.value,e.scrollTarget),U(S.value,f))}function te(t){h!==!0?(Te(m,t),u("click",t)):h=!1}function D(t){p.value===!0&&e.noFocus!==!0&&qe(n.value,t.target)!==!0&&y()}function B(t){e.noEscDismiss!==!0&&(u("escapeKey"),k(t))}function f(){Me({targetEl:n.value,offset:e.offset,anchorEl:d.value,anchorOrigin:O.value,selfOrigin:V.value,absoluteOffset:v,fit:e.fit,cover:e.cover,maxHeight:e.maxHeight,maxWidth:e.maxWidth})}function oe(){return g(Ce,_.value,()=>r.value===!0?g("div",{role:"menu",...i,ref:n,tabindex:-1,class:["q-menu q-position-engine scroll"+X.value,i.class],style:[i.style,I.value],...Y.value},K(l.default)):null)}return Se(w),Object.assign(m,{focus:y,updatePosition:f}),N}});let Ae=!1;{const e=document.createElement("div");e.setAttribute("dir","rtl"),Object.assign(e.style,{width:"1px",height:"1px",overflow:"auto"});const l=document.createElement("div");Object.assign(l.style,{width:"1000px",height:"1px"}),document.body.appendChild(e),e.appendChild(l),e.scrollLeft=-1e3,Ae=e.scrollLeft>=0,e.remove()}export{Ke as Q,Qe as a,je as b,Ae as r};
