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