1import{as as D,bL as R,cV as H,dd as y,bJ as K,ai as $,dg as N,di as W,c9 as P,c3 as r,by as U,cK as J,bR as x,c5 as T,ct as l,H as j,ae as E}from"./C9Z41gEb.js";const G={name:"WsMenu"},X=D({...G,props:{modelValue:{type:Boolean,default:!1},allowOutsideClick:{type:Boolean,default:!1},allowOutsideFocus:{type:Boolean,default:!1},allowRouteChange:{type:Boolean,default:!1},disableContentRole:{type:Boolean,default:!1},tag:{default:"div"},teleport:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(m,{expose:z,emit:S}){const v=".ws-menu__content",n=m,u=`ws-menu-${J()}`,F=E(()=>({"aria-controls":u,"aria-expanded":n.modelValue})),b=r(!1),_=r(!1),q=E(()=>n.modelValue&&!n.allowOutsideClick),M=E(()=>n.modelValue&&!n.allowOutsideFocus),d=S;R(()=>{const e=H();y(e,()=>{n.allowRouteChange||d("update:modelValue",!1)})});const o=r(null),h=r(!1),a=E(()=>n.teleport&&h.value),B=r({}),C=r("body"),A=()=>{if(!o.value)return;const{bottom:e,left:t,width:s}=o.value.getBoundingClientRect();B.value={top:`${e}px`,left:`${t}px`,width:`${s}px`,minWidth:"0"}},i=e=>{const{target:t}=e;e.type==="scroll"&&t instanceof Node&&document.getElementById(u)?.contains(t)||d("update:modelValue",!1)},w=e=>{const{target:t}=e;if(!(t instanceof HTMLElement))return;const s=document.getElementById(u);!o.value?.contains(t)&&!s?.contains(t)&&d("update:modelValue",!1)},V=(e,t)=>{e?document.body.addEventListener(t,w):document.body.removeEventListener(t,w)};y(q,e=>{V(e,"mousedown")}),y(M,e=>{V(e,"focusin")});const g=e=>{o.value&&e.key==="Escape"&&(e.stopPropagation(),o.value?.querySelector(`[aria-controls="${u}"]`)?.focus(),d("update:modelValue",!1))},L=()=>{const e=o?.value?.querySelector(v)?.getBoundingClientRect();if(!e)return;const s=(o?.value?.closest(".ws-dialog__content")??o?.value?.closest(".ws-layout-default__main")??document.body).getBoundingClientRect();_.value=s.left>e.left,b.value=s.right<e.right},O=()=>{window.requestAnimationFrame(()=>{k(),U(()=>{L()})})},k=()=>{_.value=!1,b.value=!1},I=()=>{d("update:modelValue",!n.modelValue)};let p=0,c,f;return R(()=>{h.value=!0,C.value=o.value?.closest(".ws-dialog")??"body",p=0,c=new ResizeObserver(()=>{const e=o?.value?.querySelector(v)?.getBoundingClientRect().width;e!==p&&(L(),p=e)}),f=new MutationObserver(()=>{const e=o?.value?.querySelector(v);e&&(c?.observe(e),f?.disconnect())})}),y(()=>n.modelValue,e=>{if(e){if((n.allowOutsideFocus||a.value)&&document.body.addEventListener("keydown",g),a.value){A(),window.addEventListener("scroll",i,{capture:!0,passive:!0}),window.addEventListener("resize",i);return}window.addEventListener("resize",O),k();const t=o?.value?.querySelector(v);t?c?.observe(t):o.value&&f?.observe(o.value,{childList:!0})}else{if(document.body.removeEventListener("keydown",g),a.value){window.removeEventListener("scroll",i,{capture:!0}),window.removeEventListener("resize",i);return}window.removeEventListener("resize",O),f?.disconnect(),c?.disconnect(),p=0}}),K(()=>{document.body.removeEventListener("keydown",g),document.body.removeEventListener("mousedown",w),document.body.removeEventListener("focusin",w),window.removeEventListener("resize",O),window.removeEventListener("resize",i),window.removeEventListener("scroll",i,{capture:!0}),f?.disconnect(),c?.disconnect()}),z({checkOverflow:L}),(e,t)=>(x(),$(P(m.tag),{ref_key:"rootRef",ref:o,class:"ws-menu",onKeydown:t[0]||(t[0]=W(s=>m.modelValue?g(s):void 0,["esc"]))},{default:N(()=>[T(e.$slots,"trigger",{attrs:{...l(F),class:"ws-menu__trigger"},toggle:I}),(x(),$(j,{to:l(C),disabled:!l(a)},[T(e.$slots,"content",{attrs:{class:["ws-menu__content",{"ws-menu__content--teleported":l(a),"ws-menu__content--overflowing-left":l(_),"ws-menu__content--overflowing-right":l(b)}],style:l(a)?l(B):void 0,hidden:!m.modelValue,id:u}})],8,["to","disabled"]))]),_:3},544))}});export{X as _};
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.