import{y as e,d as a,ac as l,aa as s,a as n,ag as o,G as t,w as r,a3 as d,A as i,I as u,ao as c,c as v,aP as p,j as m,aq as b,L as g,V as f,aw as y,H as x,as as h,ay as k}from"./index-f2a402e7.js";import{c as V,C as j}from"./index-305d5af8.js";const[C,w]=e("collapse"),A=Symbol(C),B=r(a({name:C,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(A),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":[w(),{[o]:e.border}]},[null==(a=t["default"])?void 0:a.call(t)])}}})),[L,N]=e("collapse-item"),S=["icon","title","value","label","right-icon"],z=r(a({name:L,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(A);if(!t)return;const d=v((()=>{var a;return null!=(a=e.name)?a:r.value})),i=v((()=>t.isExpanded(d.value))),C=u(i.value),w=p((()=>C.value||!e.lazyRender)),B=()=>{i.value?l.value&&(l.value.style.height=""):C.value=!1};m(i,((e,a)=>{null!==a&&(e&&(C.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 B()})))}));const L=(e=!i.value)=>{t.toggle(d.value,e)},z=()=>{e.disabled||e.readonly||L()},E=()=>{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":N("title",{disabled:s,expanded:i.value,borderless:!l}),"aria-expanded":String(i.value),onClick:z},t),y(a,S))},H=w((()=>{var e;return h(n("div",{ref:l,"class":N("wrapper"),onTransitionend:B},[n("div",{ref:o,"class":N("content")},[null==(e=a["default"])?void 0:e.call(a)])]),[[k,C.value]])}));return s({toggle:L,expanded:i,itemName:d}),()=>n("div",{"class":[N({border:r.value&&e.border})]},[E(),H()])}}));export{B as C,z as a};
