import{j as z,v as y,t as T,am as N,n as K,d as V,aJ as M,i as D,ac as j,aK as q,E,aw as B,u as H,ai as L,g as r,Y,ap as F,aq as J,O as U,ae as Z,aL as G,q as Q,x as $,aM as X,ax as ee,ay as te,P as oe,m as ne,an as ae,I as se,D as W}from"./index-dbd58bee.js";import{C as le}from"./index-56f3e976.js";const[A,h]=z("dropdown-menu"),re={overlay:y,zIndex:T,duration:N(.2),direction:K("down"),activeColor:String,closeOnClickOutside:y,closeOnClickOverlay:y},R=Symbol(A);var ie=V({name:A,props:re,setup(t,{slots:i}){const c=M(),u=D(),n=D(),l=D(0),{children:d,linkChildren:p}=j(R),g=q(u),f=E(()=>d.some(o=>o.state.showWrapper)),O=E(()=>{if(f.value&&B(t.zIndex))return{zIndex:+t.zIndex+1}}),b=()=>{t.closeOnClickOutside&&d.forEach(o=>{o.toggle(!1)})},w=()=>{if(n.value){const o=Y(n);t.direction==="down"?l.value=o.bottom:l.value=F.value-o.top}},k=()=>{f.value&&w()},x=o=>{d.forEach((e,a)=>{a===o?e.toggle():e.state.showPopup&&e.toggle(!1,{immediate:!0})})},I=(o,e)=>{const{showPopup:a}=o.state,{disabled:s,titleClass:v}=o;return r("div",{id:`${c}-${e}`,role:"button",tabindex:s?void 0:0,class:[h("item",{disabled:s}),{[J]:!s}],onClick:()=>{s||x(e)}},[r("span",{class:[h("title",{down:a===(t.direction==="down"),active:a}),v],style:{color:a?t.activeColor:""}},[r("div",{class:"van-ellipsis"},[o.renderTitle()])])])};return p({id:c,props:t,offset:l,updateOffset:w}),H(u,b),L("scroll",k,{target:g,passive:!0}),()=>{var o;return r("div",{ref:u,class:h()},[r("div",{ref:n,style:O.value,class:h("bar",{opened:f.value})},[d.map(I)]),(o=i.default)==null?void 0:o.call(i)])}}});const[ce,P]=z("dropdown-item"),de={title:String,options:Q(),disabled:Boolean,teleport:[String,Object],lazyRender:y,modelValue:$,titleClass:$};var ue=V({name:ce,inheritAttrs:!1,props:de,emits:["open","opened","close","closed","change","update:modelValue"],setup(t,{emit:i,slots:c,attrs:u}){const n=U({showPopup:!1,transition:!0,showWrapper:!1}),{parent:l,index:d}=Z(R);if(!l)return;const p=e=>()=>i(e),g=p("open"),f=p("close"),O=p("opened"),b=()=>{n.showWrapper=!1,i("closed")},w=e=>{t.teleport&&e.stopPropagation()},k=(e=!n.showPopup,a={})=>{e!==n.showPopup&&(n.showPopup=e,n.transition=!a.immediate,e&&(l.updateOffset(),n.showWrapper=!0))},x=()=>{if(c.title)return c.title();if(t.title)return t.title;const e=t.options.find(a=>a.value===t.modelValue);return e?e.text:""},I=e=>{const{activeColor:a}=l.props,s=e.value===t.modelValue,v=()=>{n.showPopup=!1,e.value!==t.modelValue&&(i("update:modelValue",e.value),i("change",e.value))},m=()=>{if(s)return r(se,{class:P("icon"),color:a,name:"success"},null)};return r(le,{role:"menuitem",key:e.value,icon:e.icon,title:e.text,class:P("option",{active:s}),style:{color:s?a:""},tabindex:s?0:-1,clickable:!0,onClick:v},{value:m})},o=()=>{const{offset:e}=l,{zIndex:a,overlay:s,duration:v,direction:m,closeOnClickOverlay:_}=l.props,S=X(a);return m==="down"?S.top=`${e.value}px`:S.bottom=`${e.value}px`,ee(r("div",ne({style:S,class:P([m]),onClick:w},u),[r(oe,{show:n.showPopup,"onUpdate:show":C=>n.showPopup=C,role:"menu",class:P("content"),overlay:s,position:m==="down"?"top":"bottom",duration:n.transition?v:0,lazyRender:t.lazyRender,overlayStyle:{position:"absolute"},"aria-labelledby":`${l.id}-${d.value}`,closeOnClickOverlay:_,onOpen:g,onClose:f,onOpened:O,onClosed:b},{default:()=>{var C;return[t.options.map(I),(C=c.default)==null?void 0:C.call(c)]}})]),[[te,n.showWrapper]])};return ae({state:n,toggle:k,renderTitle:x}),()=>t.teleport?r(G,{to:t.teleport},{default:()=>[o()]}):o()}});const ve=W(ue),me=W(ie);export{me as D,ve as a};