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