import{aa as h,ah as f,ab as P,ac as A,B as i,ap as v,bm as l,ak as g,aC as m,C as y,a2 as o,b as r,o as s,w as $,G as u,aD as d}from"./dVzHJMF1.js";import{s as C}from"./a1m94JqE.js";import{s as w}from"./BGFPOxrp.js";var b={root:"p-accordionheader",toggleicon:"p-accordionheader-toggle-icon"},k=h.extend({name:"accordionheader",classes:b}),K={name:"BaseAccordionHeader",extends:P,props:{as:{type:[String,Object],default:"BUTTON"},asChild:{type:Boolean,default:!1}},style:k,provide:function(){return{$pcAccordionHeader:this,$parentInstance:this}}},D={name:"AccordionHeader",extends:K,inheritAttrs:!1,inject:["$pcAccordion","$pcAccordionPanel"],methods:{onFocus:function(){this.$pcAccordion.selectOnFocus&&this.changeActiveValue()},onClick:function(){this.changeActiveValue()},onKeydown:function(e){switch(e.code){case"ArrowDown":this.onArrowDownKey(e);break;case"ArrowUp":this.onArrowUpKey(e);break;case"Home":this.onHomeKey(e);break;case"End":this.onEndKey(e);break;case"Enter":case"NumpadEnter":case"Space":this.onEnterKey(e);break}},onArrowDownKey:function(e){var c=this.findNextPanel(this.findPanel(e.currentTarget));c?this.changeFocusedPanel(e,c):this.onHomeKey(e),e.preventDefault()},onArrowUpKey:function(e){var c=this.findPrevPanel(this.findPanel(e.currentTarget));c?this.changeFocusedPanel(e,c):this.onEndKey(e),e.preventDefault()},onHomeKey:function(e){var c=this.findFirstPanel();this.changeFocusedPanel(e,c),e.preventDefault()},onEndKey:function(e){var c=this.findLastPanel();this.changeFocusedPanel(e,c),e.preventDefault()},onEnterKey:function(e){this.changeActiveValue(),e.preventDefault()},findPanel:function(e){return e==null?void 0:e.closest('[data-pc-name="accordionpanel"]')},findHeader:function(e){return g(e,'[data-pc-name="accordionheader"]')},findNextPanel:function(e){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,t=c?e:e.nextElementSibling;return t?l(t,"data-p-disabled")?this.findNextPanel(t):this.findHeader(t):null},findPrevPanel:function(e){var c=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,t=c?e:e.previousElementSibling;return t?l(t,"data-p-disabled")?this.findPrevPanel(t):this.findHeader(t):null},findFirstPanel:function(){return this.findNextPanel(this.$pcAccordion.$el.firstElementChild,!0)},findLastPanel:function(){return this.findPrevPanel(this.$pcAccordion.$el.lastElementChild,!0)},changeActiveValue:function(){this.$pcAccordion.updateValue(this.$pcAccordionPanel.value)},changeFocusedPanel:function(e,c){v(this.findHeader(c))}},computed:{id:function(){return"".concat(this.$pcAccordion.id,"_accordionheader_").concat(this.$pcAccordionPanel.value)},ariaControls:function(){return"".concat(this.$pcAccordion.id,"_accordioncontent_").concat(this.$pcAccordionPanel.value)},attrs:function(){return i(this.asAttrs,this.a11yAttrs,this.ptmi("root",this.ptParams))},asAttrs:function(){return this.as==="BUTTON"?{type:"button",disabled:this.$pcAccordionPanel.disabled}:void 0},a11yAttrs:function(){return{id:this.id,tabindex:this.$pcAccordion.tabindex,"aria-expanded":this.$pcAccordionPanel.active,"aria-controls":this.ariaControls,"data-pc-name":"accordionheader","data-p-disabled":this.$pcAccordionPanel.disabled,"data-p-active":this.$pcAccordionPanel.active,onFocus:this.onFocus,onKeydown:this.onKeydown}},ptParams:function(){return{context:{active:this.$pcAccordionPanel.active}}},dataP:function(){return A({active:this.$pcAccordionPanel.active})}},components:{ChevronUpIcon:w,ChevronDownIcon:C},directives:{ripple:f}};function x(n,e,c,t,F,a){var p=m("ripple");return n.asChild?o(n.$slots,"default",{key:1,class:u(n.cx("root")),active:a.$pcAccordionPanel.active,a11yAttrs:a.a11yAttrs,onClick:a.onClick}):y((s(),r(d(n.as),i({key:0,"data-p":a.dataP,class:n.cx("root"),onClick:a.onClick},a.attrs),{default:$(function(){return[o(n.$slots,"default",{active:a.$pcAccordionPanel.active}),o(n.$slots,"toggleicon",{active:a.$pcAccordionPanel.active,class:u(n.cx("toggleicon"))},function(){return[a.$pcAccordionPanel.active?(s(),r(d(a.$pcAccordion.$slots.collapseicon?a.$pcAccordion.$slots.collapseicon:a.$pcAccordion.collapseIcon?"span":"ChevronUpIcon"),i({key:0,class:[a.$pcAccordion.collapseIcon,n.cx("toggleicon")],"aria-hidden":"true"},n.ptm("toggleicon",a.ptParams)),null,16,["class"])):(s(),r(d(a.$pcAccordion.$slots.expandicon?a.$pcAccordion.$slots.expandicon:a.$pcAccordion.expandIcon?"span":"ChevronDownIcon"),i({key:1,class:[a.$pcAccordion.expandIcon,n.cx("toggleicon")],"aria-hidden":"true"},n.ptm("toggleicon",a.ptParams)),null,16,["class"]))]})]}),_:3},16,["data-p","class","onClick"])),[[p]])}D.render=x;export{D as default};
