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