import{y as e,d as a,ae as l,ac as s,a as n,ai as o,G as t,w as r,a5 as d,A as i,I as u,aq as c,c as v,aR as p,j as m,as as b,L as g,X as f,ay as y,H as x,au as h,aA as k}from"./index-4bd11d60.js";import{c as V,C as j}from"./index-5b07b517.js";const[A,C]=e("collapse"),B=Symbol(A),L=r(a({name:A,props:{border:t,accordion:Boolean,modelValue:{type:[String,Number,Array],"default":""}},emits:["change","update:modelValue"],setup(e,{emit:a,slots:t}){const{linkChildren:r,children:d}=l(B),i=e=>{a("change",e),a("update:modelValue",e)};return s({toggleAll:(a={})=>{if(e.accordion)return;"boolean"==typeof a&&(a={expanded:a});const{expanded:l,skipDisabled:s}=a,n=d.filter((e=>e.disabled&&s?e.expanded.value:null!=l?l:!e.expanded.value)).map((e=>e.itemName.value));i(n)}}),r({toggle:(a,l)=>{const{accordion:s,modelValue:n}=e;i(s?a===n?"":a:l?n.concat(a):n.filter((e=>e!==a)))},isExpanded:a=>{const{accordion:l,modelValue:s}=e;return l?s===a:s.includes(a)}}),()=>{var a;return n("div",{"class":[C(),{[o]:e.border}]},[null==(a=t["default"])?void 0:a.call(t)])}}})),[N,R]=e("collapse-item"),S=["icon","title","value","label","right-icon"],w=r(a({name:N,props:d({},V,{name:i,isLink:t,disabled:Boolean,readonly:Boolean,lazyRender:t}),setup(e,{slots:a}){const l=u(),o=u(),{parent:t,index:r}=c(B);if(!t)return;const d=v((()=>{var a;return null!=(a=e.name)?a:r.value})),i=v((()=>t.isExpanded(d.value))),A=u(i.value),C=p((()=>A.value||!e.lazyRender)),L=()=>{i.value?l.value&&(l.value.style.height=""):A.value=!1};m(i,((e,a)=>{null!==a&&(e&&(A.value=!0),(e?g:f)((()=>{if(!o.value||!l.value)return;const{offsetHeight:a}=o.value;if(a){const s="".concat(a,"px");l.value.style.height=e?"0":s,b((()=>{l.value&&(l.value.style.height=e?s:"0")}))}else L()})))}));const N=(e=!i.value)=>{t.toggle(d.value,e)},w=()=>{e.disabled||e.readonly||N()},z=()=>{const{border:l,disabled:s,readonly:o}=e,t=y(e,Object.keys(V));return o&&(t.isLink=!1),(s||o)&&(t.clickable=!1),n(j,x({role:"button","class":R("title",{disabled:s,expanded:i.value,borderless:!l}),"aria-expanded":String(i.value),onClick:w},t),y(a,S))},E=C((()=>{var e;return h(n("div",{ref:l,"class":R("wrapper"),onTransitionend:L},[n("div",{ref:o,"class":R("content")},[null==(e=a["default"])?void 0:e.call(a)])]),[[k,A.value]])}));return s({toggle:N,expanded:i,itemName:d}),()=>n("div",{"class":[R({border:r.value&&e.border})]},[z(),E()])}}));export{w as C,L as a};
