import{aa as d,ah as u,ab as h,ac as b,B as c,am as f,ap as p,ak as r,bm as s,aC as v,C as T,a2 as o,b as y,o as g,w as m,aD as K,G as w}from"./dVzHJMF1.js";var $={root:function(a){var e=a.instance,n=a.props;return["p-tab",{"p-tab-active":e.active,"p-disabled":n.disabled}]}},A=d.extend({name:"tab",classes:$}),k={name:"BaseTab",extends:h,props:{value:{type:[String,Number],default:void 0},disabled:{type:Boolean,default:!1},as:{type:[String,Object],default:"BUTTON"},asChild:{type:Boolean,default:!1}},style:A,provide:function(){return{$pcTab:this,$parentInstance:this}}},P={name:"Tab",extends:k,inheritAttrs:!1,inject:["$pcTabs","$pcTabList"],methods:{onFocus:function(){this.$pcTabs.selectOnFocus&&this.changeActiveValue()},onClick:function(){this.changeActiveValue()},onKeydown:function(a){switch(a.code){case"ArrowRight":this.onArrowRightKey(a);break;case"ArrowLeft":this.onArrowLeftKey(a);break;case"Home":this.onHomeKey(a);break;case"End":this.onEndKey(a);break;case"PageDown":this.onPageDownKey(a);break;case"PageUp":this.onPageUpKey(a);break;case"Enter":case"NumpadEnter":case"Space":this.onEnterKey(a);break}},onArrowRightKey:function(a){var e=this.findNextTab(a.currentTarget);e?this.changeFocusedTab(a,e):this.onHomeKey(a),a.preventDefault()},onArrowLeftKey:function(a){var e=this.findPrevTab(a.currentTarget);e?this.changeFocusedTab(a,e):this.onEndKey(a),a.preventDefault()},onHomeKey:function(a){var e=this.findFirstTab();this.changeFocusedTab(a,e),a.preventDefault()},onEndKey:function(a){var e=this.findLastTab();this.changeFocusedTab(a,e),a.preventDefault()},onPageDownKey:function(a){this.scrollInView(this.findLastTab()),a.preventDefault()},onPageUpKey:function(a){this.scrollInView(this.findFirstTab()),a.preventDefault()},onEnterKey:function(a){this.changeActiveValue(),a.preventDefault()},findNextTab:function(a){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=e?a:a.nextElementSibling;return n?s(n,"data-p-disabled")||s(n,"data-pc-section")==="activebar"?this.findNextTab(n):r(n,'[data-pc-name="tab"]'):null},findPrevTab:function(a){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,n=e?a:a.previousElementSibling;return n?s(n,"data-p-disabled")||s(n,"data-pc-section")==="activebar"?this.findPrevTab(n):r(n,'[data-pc-name="tab"]'):null},findFirstTab:function(){return this.findNextTab(this.$pcTabList.$refs.tabs.firstElementChild,!0)},findLastTab:function(){return this.findPrevTab(this.$pcTabList.$refs.tabs.lastElementChild,!0)},changeActiveValue:function(){this.$pcTabs.updateValue(this.value)},changeFocusedTab:function(a,e){p(e),this.scrollInView(e)},scrollInView:function(a){var e;a==null||(e=a.scrollIntoView)===null||e===void 0||e.call(a,{block:"nearest"})}},computed:{active:function(){var a;return f((a=this.$pcTabs)===null||a===void 0?void 0:a.d_value,this.value)},id:function(){var a;return"".concat((a=this.$pcTabs)===null||a===void 0?void 0:a.$id,"_tab_").concat(this.value)},ariaControls:function(){var a;return"".concat((a=this.$pcTabs)===null||a===void 0?void 0:a.$id,"_tabpanel_").concat(this.value)},attrs:function(){return c(this.asAttrs,this.a11yAttrs,this.ptmi("root",this.ptParams))},asAttrs:function(){return this.as==="BUTTON"?{type:"button",disabled:this.disabled}:void 0},a11yAttrs:function(){return{id:this.id,tabindex:this.active?this.$pcTabs.tabindex:-1,role:"tab","aria-selected":this.active,"aria-controls":this.ariaControls,"data-pc-name":"tab","data-p-disabled":this.disabled,"data-p-active":this.active,onFocus:this.onFocus,onKeydown:this.onKeydown}},ptParams:function(){return{context:{active:this.active}}},dataP:function(){return b({active:this.active})}},directives:{ripple:u}};function C(t,a,e,n,D,i){var l=v("ripple");return t.asChild?o(t.$slots,"default",{key:1,dataP:i.dataP,class:w(t.cx("root")),active:i.active,a11yAttrs:i.a11yAttrs,onClick:i.onClick}):T((g(),y(K(t.as),c({key:0,class:t.cx("root"),"data-p":i.dataP,onClick:i.onClick},i.attrs),{default:m(function(){return[o(t.$slots,"default")]}),_:3},16,["class","data-p","onClick"])),[[l]])}P.render=C;export{P as default};
