import{D as e,G as t,U as n,_ as r,b as i,et as a,s as o,tt as s}from"./runtime-core.esm-bundler-Babufkcf.js";import{i as c}from"./runtime-dom.esm-bundler-Ce9t-RuK.js";import{t as l}from"./create-CGAkPJkS.js";import{m as u}from"./dom-BXiDqs7-.js";import{a as d,t as f}from"./QIcon-cTVL6ikA.js";import{c as p}from"./QBtn-DkiaKEsC.js";import{n as m,t as h}from"./use-dark-B6e4te0z.js";import{n as g,t as _}from"./use-id-BFm4JAvS.js";import{A as v,M as y,j as b,o as x}from"./index-uCtpzrM3.js";import{t as S}from"./QSlideTransition-dIkZu85g.js";import{n as C,t as w}from"./QItem-CjO__PJ-.js";import{t as T}from"./QItemLabel-0SX_AwSO.js";var E=s({}),D=Object.keys(p),O=l({name:`QExpansionItem`,props:{...p,...y,...m,icon:String,label:String,labelLines:[Number,String],caption:String,captionLines:[Number,String],dense:Boolean,toggleAriaLabel:String,expandIcon:String,expandedIcon:String,expandIconClass:[Array,String,Object],duration:{},headerInsetLevel:Number,contentInsetLevel:Number,expandSeparator:Boolean,defaultOpened:Boolean,hideExpandIcon:Boolean,expandIconToggle:Boolean,switchToggleSide:Boolean,denseToggle:Boolean,group:String,popup:Boolean,headerStyle:[Array,String,Object],headerClass:[Array,String,Object]},emits:[...b,`click`,`afterShow`,`afterHide`],setup(s,{slots:l,emit:p}){let{proxy:{$q:m}}=r(),y=h(s,m),b=a(s.modelValue===null?s.defaultOpened:s.modelValue),O=a(null),k=_(),{show:A,hide:j,toggle:M}=v({showing:b}),N,P,F=o(()=>`q-expansion-item q-item-type q-expansion-item--${b.value?`expanded`:`collapsed`} q-expansion-item--${s.popup?`popup`:`standard`}`),I=o(()=>s.contentInsetLevel===void 0?null:{[`padding`+(m.lang.rtl?`Right`:`Left`)]:s.contentInsetLevel*56+`px`}),L=o(()=>!s.disable&&(s.href!==void 0||s.to!==void 0&&s.to!==null&&s.to!==``)),R=o(()=>{let e={};return D.forEach(t=>{e[t]=s[t]}),e}),z=o(()=>L.value||!s.expandIconToggle),B=o(()=>s.expandedIcon!==void 0&&b.value?s.expandedIcon:s.expandIcon||m.iconSet.expansionItem[s.denseToggle?`denseIcon`:`icon`]),V=o(()=>!s.disable&&(L.value||s.expandIconToggle)),H=o(()=>({expanded:b.value,detailsId:k.value,toggle:M,show:A,hide:j})),U=o(()=>{let e=s.toggleAriaLabel===void 0?m.lang.label[b.value?`collapse`:`expand`](s.label):s.toggleAriaLabel;return{role:`button`,"aria-expanded":b.value?`true`:`false`,"aria-controls":k.value,"aria-label":e}});n(()=>s.group,e=>{P?.(),e!==void 0&&Y()});function W(e){L.value||M(e),p(`click`,e)}function G(e){e.keyCode===13&&K(e,!0)}function K(e,t){!t&&!e.qAvoidFocus&&O.value?.focus(),M(e),u(e)}function q(){p(`afterShow`)}function J(){p(`afterHide`)}function Y(){N===void 0&&(N=g()),b.value&&(E[s.group]=N);let e=n(b,e=>{e?E[s.group]=N:E[s.group]===N&&delete E[s.group]}),t=n(()=>E[s.group],(e,t)=>{t===N&&e!==void 0&&e!==N&&j()});P=()=>{e(),t(),E[s.group]===N&&delete E[s.group],P=void 0}}function X(){let e={class:[`q-focusable relative-position cursor-pointer${s.denseToggle&&s.switchToggleSide?` items-end`:``}`,s.expandIconClass],side:!s.switchToggleSide,avatar:s.switchToggleSide},t=[i(f,{class:`q-expansion-item__toggle-icon`+(s.expandedIcon===void 0&&b.value?` q-expansion-item__toggle-icon--rotated`:``),name:B.value})];return V.value&&(Object.assign(e,{tabindex:0,...U.value,onClick:K,onKeyup:G}),t.unshift(i(`div`,{ref:O,class:`q-expansion-item__toggle-focus q-icon q-focus-helper q-focus-helper--rounded`,tabindex:-1}))),i(C,e,()=>t)}function Z(){let e;return l.header===void 0?(e=[i(C,()=>[i(T,{lines:s.labelLines},()=>s.label||``),s.caption?i(T,{lines:s.captionLines,caption:!0},()=>s.caption):null])],s.icon&&e[s.switchToggleSide?`push`:`unshift`](i(C,{side:s.switchToggleSide,avatar:!s.switchToggleSide},()=>i(f,{name:s.icon})))):e=[l.header(H.value)].flat(),!s.disable&&!s.hideExpandIcon&&e[s.switchToggleSide?`unshift`:`push`](X()),e}function Q(){let e={ref:`item`,style:s.headerStyle,class:s.headerClass,dark:y.value,disable:s.disable,dense:s.dense,insetLevel:s.headerInsetLevel};return z.value&&(e.clickable=!0,e.onClick=W,Object.assign(e,L.value?R.value:U.value)),i(w,e,Z)}function $(){return t(i(`div`,{key:`e-content`,class:`q-expansion-item__content relative-position`,style:I.value,id:k.value},d(l.default)),[[c,b.value]])}function ee(){let e=[Q(),i(S,{duration:s.duration,onShow:q,onHide:J},$)];return s.expandSeparator&&e.push(i(x,{class:`q-expansion-item__border q-expansion-item__border--top absolute-top`,dark:y.value}),i(x,{class:`q-expansion-item__border q-expansion-item__border--bottom absolute-bottom`,dark:y.value})),e}return s.group!==void 0&&Y(),e(()=>{P?.()}),()=>i(`div`,{class:F.value},[i(`div`,{class:`q-expansion-item__container relative-position`},ee())])}});export{O as t};