import{ref as m,inject as A,onMounted as C,watch as S,resolveComponent as N,createElementBlock as b,openBlock as u,Fragment as w,createElementVNode as T,renderSlot as V,normalizeStyle as D,normalizeClass as O,unref as y,renderList as B,createBlock as E,createCommentVNode as $,createTextVNode as x,toDisplayString as z}from"/vue.js";import{n as c}from"./nc-main.DEgIQeOo.js";/* empty css                                               *//* empty css                */import"./service-worker.DGZzV4eE.js";const R=["id","onClick","onDblclick"],q=Object.assign({name:"NcTab"},{__name:"nc-tab",props:{id:{type:String,default:void 0},model:{type:String,default:()=>""},class:{type:[Object,Array,String],default:void 0},style:{type:[Array,Object,String],default:()=>{}},itemStyle:{type:[Array,Object,String],default:()=>{}}},emits:["change","dblclick"],setup(d,{emit:_}){const p=_,i=d,s=m(null),f=m(!1),t=A("state"),n=i.model&&i.model.substring(i.model.indexOf(".")+1),a=m(n&&c.recData(t.arr,n)||[]);function g(){setTimeout(()=>{f.value=s.value?s.value.scrollWidth>s.value.clientWidth:!1},0)}function j(e){if(e==null)return!1;const r=c.recData(t.rec,n);return e===r}function k(e,r,o,l){!r||r.value==null?console.error(`nc-tab selected item or item.value at index ${o} is null, item, tab, event:`,r,a,e):(n&&c.setRec(t,n,r.value),p(l?"dblclick":"change",r.value,o,e,a.value))}return C(()=>{g()}),S(t.rec,()=>{if(n&&t.arr){const e=c.recData(t.arr,n);e!=null&&(a.value=Object.assign([],e))}}),S(t.arr,()=>{if(n&&t.arr){const e=c.recData(t.arr,n);e!=null&&(a.value=e)}g()}),(n==null||c.recData(t.rec,n)==null)&&(c.isArray(a.value)||(console.warn(`nc-tab '${i.model}' array does not exist`),a.value=[{show:"undefined tab",value:"undefined"}]),a.value[0]&&c.setRec(t,n,a.value[0].value)),(e,r)=>{const o=N("nc-icon");return u(),b(w,null,[T("div",{class:O(["nc-tab ui secondary pointing menu nc-no-print",y(f)?"overflownElement":""]),ref_key:"element",ref:s,style:D(d.style)},[(u(!0),b(w,null,B(y(a),(l,h)=>(u(),b("a",{class:O(["link item nc-tab-item",[y(f)?"overflownItem":"",{active:j(l.value),disabled:l.disabled==!0}]]),id:l.value,key:l.value,style:D(d.itemStyle),onClick:v=>k(v,l,h),onDblclick:v=>k(v,l,h,!0)},[l.icon?(u(),E(o,{key:0,icon:l.icon},null,8,["icon"])):$("",!0),x(z(l.show),1)],46,R))),128))],6),V(e.$slots,"default")],64)}}});export{q as default};
