import{ac as M,ab as W,aN as z,V,aw as A,ag as D,X as E,W as q,i as N,x as G,Z as x,q as d,C as L,bg as P,av as U,Y as X,f as O,c as F,o as w,ae as I,n as v,N as e,a7 as Y,as as Z,l as J,bh as Q,a as y,e as $,d as R,t as ee,w as B,h as se,au as ae,a5 as te,I as oe,aD as le,y as ne,z as ie,b2 as ce,aj as re,ak as de}from"./index-Dyf_FKwG.js";import{f as S}from"./select-DAf-eM9U.js";const T=s=>M(s)||W(s)||z(s),ue=V({accordion:Boolean,modelValue:{type:E([Array,String,Number]),default:()=>q([])},expandIconPosition:{type:E([String]),default:"right"},beforeCollapse:{type:E(Function)}}),pe={[D]:T,[A]:T},H=Symbol("collapseContextKey"),me="ElCollapse",fe=(s,n)=>{const l=N(S(s.modelValue)),c=t=>{l.value=t;const o=s.accordion?l.value[0]:l.value;n(D,o),n(A,o)},a=t=>{if(s.accordion)c([l.value[0]===t?"":t]);else{const o=[...l.value],i=o.indexOf(t);i>-1?o.splice(i,1):o.push(t),c(o)}},r=async t=>{const{beforeCollapse:o}=s;if(!o){a(t);return}const i=o(t);[P(i),U(i)].includes(!0)||X(me,"beforeCollapse must return type `Promise<boolean>` or `boolean`"),P(i)?i.then(m=>{m!==!1&&a(t)}).catch(m=>{}):i&&a(t)};return G(()=>s.modelValue,()=>l.value=S(s.modelValue),{deep:!0}),L(H,{activeNames:l,handleItemClick:r}),{activeNames:l,setActiveNames:c}},ve=s=>{const n=x("collapse");return{rootKls:d(()=>[n.b(),n.b(`icon-position-${s.expandIconPosition}`)])}};var be=O({name:"ElCollapse",__name:"collapse",props:ue,emits:pe,setup(s,{expose:n,emit:l}){const c=s,a=l,{activeNames:r,setActiveNames:t}=fe(c,a),{rootKls:o}=ve(c);return n({activeNames:r,setActiveNames:t}),(i,b)=>(w(),F("div",{class:v(e(o))},[I(i.$slots,"default")],2))}});const Ce=V({title:{type:String,default:""},name:{type:E([String,Number]),default:void 0},icon:{type:Z,default:Y},disabled:Boolean}),he=s=>{const n=J(H),{namespace:l}=x("collapse"),c=N(!1),a=N(!1),r=Q(),t=d(()=>r.current++),o=d(()=>{var u;return(u=s.name)!=null?u:`${l.value}-id-${r.prefix}-${e(t)}`}),i=d(()=>n?.activeNames.value.includes(e(o)));return{focusing:c,id:t,isActive:i,handleFocus:()=>{setTimeout(()=>{a.value?a.value=!1:c.value=!0},50)},handleHeaderClick:u=>{if(s.disabled)return;const f=u.target;f?.closest("input, textarea, select")||(n?.handleItemClick(e(o)),c.value=!1,a.value=!0)},handleEnterClick:u=>{const f=u.target;f?.closest("input, textarea, select")||(u.preventDefault(),n?.handleItemClick(e(o)))}}},ye=(s,{focusing:n,isActive:l,id:c})=>{const a=x("collapse"),r=d(()=>[a.b("item"),a.is("active",e(l)),a.is("disabled",s.disabled)]),t=d(()=>[a.be("item","header"),a.is("active",e(l)),{focusing:e(n)&&!s.disabled}]),o=d(()=>[a.be("item","arrow"),a.is("active",e(l))]),i=d(()=>[a.be("item","title")]),b=d(()=>a.be("item","wrap")),m=d(()=>a.be("item","content")),h=d(()=>a.b(`content-${e(c)}`)),u=d(()=>a.b(`head-${e(c)}`));return{itemTitleKls:i,arrowKls:o,headKls:t,rootKls:r,itemWrapperKls:b,itemContentKls:m,scopedContentId:h,scopedHeadId:u}},Ee=["id","aria-expanded","aria-controls","aria-describedby","tabindex","aria-disabled"],Ie=["id","aria-hidden","aria-labelledby"];var _=O({name:"ElCollapseItem",__name:"collapse-item",props:Ce,setup(s,{expose:n}){const l=s,{focusing:c,id:a,isActive:r,handleFocus:t,handleHeaderClick:o,handleEnterClick:i}=he(l),{arrowKls:b,headKls:m,rootKls:h,itemTitleKls:u,itemWrapperKls:f,itemContentKls:j,scopedContentId:g,scopedHeadId:k}=ye(l,{focusing:c,isActive:r,id:a});return n({isActive:r}),(K,p)=>(w(),F("div",{class:v(e(h))},[y("div",{id:e(k),class:v(e(m)),"aria-expanded":e(r),"aria-controls":e(g),"aria-describedby":e(g),tabindex:s.disabled?void 0:0,"aria-disabled":s.disabled,role:"button",onClick:p[0]||(p[0]=(...C)=>e(o)&&e(o)(...C)),onKeydown:p[1]||(p[1]=oe(le((...C)=>e(i)&&e(i)(...C),["stop"]),["space","enter"])),onFocus:p[2]||(p[2]=(...C)=>e(t)&&e(t)(...C)),onBlur:p[3]||(p[3]=C=>c.value=!1)},[y("span",{class:v(e(u))},[I(K.$slots,"title",{isActive:e(r)},()=>[R(ee(s.title),1)])],2),I(K.$slots,"icon",{isActive:e(r)},()=>[$(e(te),{class:v(e(b))},{default:B(()=>[(w(),se(ae(s.icon)))]),_:1},8,["class"])])],42,Ee),$(e(ce),null,{default:B(()=>[ne(y("div",{id:e(g),role:"region",class:v(e(f)),"aria-hidden":!e(r),"aria-labelledby":e(k)},[y("div",{class:v(e(j))},[I(K.$slots,"default")],2)],10,Ie),[[ie,e(r)]])]),_:3})],2))}});const Ne=re(be,{CollapseItem:_}),we=de(_);export{Ne as E,we as a};
