(function(s,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(s=typeof globalThis!="undefined"?globalThis:s||self,e(s.index={},s.Vue))})(this,function(s,e){"use strict";const y={type:{type:String,default:"default"},cssClass:{type:String,default:""},isCollapsed:{type:Boolean,default:!1},beforeToggle:{type:Function,default:null},showAnimation:{type:Boolean,default:!0},hasLeftPadding:{type:Boolean,default:!0}},v=e.reactive({});class f{static getByKey(n){return v[n]}static state(){return v}static setData(n,c){v[n]=e.ref(c)}}var k="",h=e.defineComponent({name:"DPanel",props:y,emits:["toggle"],setup(a,n){e.provide("beforeToggle",a.beforeToggle),e.provide("showAnimation",e.computed(()=>a.showAnimation)),e.provide("hasLeftPadding",e.computed(()=>a.hasLeftPadding));const c=e.ref(a.isCollapsed),g=e.computed(()=>a.type),d=e.computed(()=>a.cssClass),t=new Date().getTime().toString()+Math.random(),u=()=>{n.emit("toggle",f.getByKey(`isCollapsed[${t}]`))};return f.setData(`isCollapsed[${t}]`,c.value),()=>{var p,o;return e.createVNode("div",{onClick:u,class:`devui-panel devui-panel-${g.value} ${d.value}`},[(o=(p=n.slots).default)==null?void 0:o.call(p)])}}}),P=e.defineComponent({name:"DPanelHeader",props:y,emits:["toggle"],setup(a,n){const c=e.inject("beforeToggle"),d=Object.keys(f.state()).pop(),t=e.ref(f.state()[d]),u=e.ref();let p=null;const o=e.ref(t.value);let m=!0;const r=()=>{if(o.value=!o.value,!u.value){o.value&&(f.setData(`${d}`,o.value),t.value=o.value,n.emit("toggle",o.value));return}o.value!==void 0&&(f.setData(`${d}`,o.value),t.value=o.value,n.emit("toggle",o.value))},l=async()=>{if(c){const i=c(t,r);typeof i!="undefined"?i instanceof Promise?m=await i:m=i:m=!0}return m};l().then(i=>u.value=i);const b=()=>{l().then(i=>{if(u.value=i,!i){t.value||(f.setData(`${d}`,!t.value),t.value=!t.value,n.emit("toggle",t.value));return}t.value!==void 0&&(f.setData(`${d}`,!t.value),t.value=!t.value,n.emit("toggle",t.value))})};return()=>{var i,T;return n.slots.default&&(p=e.createVNode("div",{class:"devui-panel-heading",onClick:b,style:{cursor:u.value?"pointer":"auto"}},[(T=(i=n.slots).default)==null?void 0:T.call(i)])),p}}}),C=e.defineComponent({name:"DPanelBody",props:y,setup(a,n){const c=e.inject("showAnimation"),g=e.inject("hasLeftPadding"),t=Object.keys(f.state()).pop(),u=f.state(),p=e.ref();e.onMounted(()=>{if(p.value){const r=p.value;u[t]&&(r.style.height=`${r.offsetHeight}px`)}});const o=r=>{const l=r;l.style.height="";const b=l.offsetHeight;l.style.height="0px",l.offsetHeight,l.style.height=`${b}px`},m=r=>{const l=r;l.style.height="0px"};return()=>e.createVNode("div",{class:`devui-panel devui-panel-${a.type} ${a.cssClass}`},[e.createVNode(e.Transition,{name:c.value?"devui-panel":"",onEnter:o,onLeave:m},{default:()=>{var r,l;return[u[t]===void 0||u[t]?e.createVNode("div",{ref:p,class:`devui-panel-body ${u[t]!==void 0?"devui-panel-body-collapse":""} ${g.value?"":"no-left-padding"}`},[e.createVNode("div",{class:"devui-panel-content"},[(l=(r=n.slots).default)==null?void 0:l.call(r)])]):null]}})])}}),$=e.defineComponent({name:"DPanelFooter",setup(a,n){return()=>{var g,d;return n.slots.default?e.createVNode("div",{class:"devui-panel-footer"},[(d=(g=n.slots).default)==null?void 0:d.call(g)]):null}}}),D={title:"Panel \u9762\u677F",category:"\u901A\u7528",status:"100%",install(a){a.component(h.name,h),a.component(P.name,P),a.component(C.name,C),a.component($.name,$)}};s.Panel=h,s.PanelBody=C,s.PanelFooter=$,s.PanelHeader=P,s.default=D,s.panelProps=y,Object.defineProperties(s,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
