import{c as R,d as T,aa as O,Y as _,a as b,aU as N,t as k,k as w,ac as z,n as B,r as x,ad as I,e as A,aV as $,w as D,aG as H,z as M,aH as Y,ae as P,h as j,g as G,v as K}from"./index-0890a9ad.js";import{c as E,C as U}from"./index-e320d1f3.js";const[L,q]=R("collapse"),S=Symbol(L),F={border:k,accordion:Boolean,modelValue:{type:[String,Number,Array],default:""}};function J(a,o){return o&&Array.isArray(a)?(console.error('[Vant] Collapse: "v-model" should not be Array in accordion mode'),!1):!o&&!Array.isArray(a)?(console.error('[Vant] Collapse: "v-model" should be Array in non-accordion mode'),!1):!0}var Q=T({name:L,props:F,emits:["change","update:modelValue"],setup(a,{emit:o,slots:l}){const{linkChildren:v,children:p}=O(S),d=e=>{o("change",e),o("update:modelValue",e)},m=(e,t)=>{const{accordion:r,modelValue:u}=a;d(r?e===u?"":e:t?u.concat(e):u.filter(h=>h!==e))},s=(e={})=>{if(a.accordion)return;typeof e=="boolean"&&(e={expanded:e});const{expanded:t,skipDisabled:r}=e,h=p.filter(c=>c.disabled&&r?c.expanded.value:t!=null?t:!c.expanded.value).map(c=>c.itemName.value);d(h)},i=e=>{const{accordion:t,modelValue:r}=a;return J(r,t)?t?r===e:r.includes(e):!1};return _({toggleAll:s}),v({toggle:m,isExpanded:i}),()=>{var e;return b("div",{class:[q(),{[N]:a.border}]},[(e=l.default)==null?void 0:e.call(l)])}}});const le=w(Q),[W,g]=R("collapse-item"),X=["icon","title","value","label","right-icon"],Z=z({},E,{name:B,isLink:k,disabled:Boolean,readonly:Boolean,lazyRender:k});var ee=T({name:W,props:Z,setup(a,{slots:o}){const l=x(),v=x(),{parent:p,index:d}=I(S);if(!p){console.error("[Vant] <CollapseItem> must be a child component of <Collapse>.");return}const m=A(()=>{var n;return(n=a.name)!=null?n:d.value}),s=A(()=>p.isExpanded(m.value)),i=x(s.value),e=$(()=>i.value||!a.lazyRender),t=()=>{s.value?l.value&&(l.value.style.height=""):i.value=!1};D(s,(n,y)=>{if(y===null)return;n&&(i.value=!0),(n?M:Y)(()=>{if(!v.value||!l.value)return;const{offsetHeight:f}=v.value;if(f){const V=`${f}px`;l.value.style.height=n?"0":V,H(()=>{l.value&&(l.value.style.height=n?V:"0")})}else t()})});const r=(n=!s.value)=>{p.toggle(m.value,n)},u=()=>{!a.disabled&&!a.readonly&&r()},h=()=>{const{border:n,disabled:y,readonly:C}=a,f=P(a,Object.keys(E));return C&&(f.isLink=!1),(y||C)&&(f.clickable=!1),b(U,j({role:"button",class:g("title",{disabled:y,expanded:s.value,borderless:!n}),"aria-expanded":String(s.value),onClick:u},f),P(o,X))},c=e(()=>{var n;return G(b("div",{ref:l,class:g("wrapper"),onTransitionend:t},[b("div",{ref:v,class:g("content")},[(n=o.default)==null?void 0:n.call(o)])]),[[K,i.value]])});return _({toggle:r,expanded:s,itemName:m}),()=>b("div",{class:[g({border:d.value&&a.border})]},[h(),c()])}});const te=w(ee);export{le as C,te as a};
