"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),g=require("@ant-design/icons-vue");require("../config-provider/index.js");const k=require("../config-provider/hooks/use-namespace.js"),S=["aria-valuenow","aria-valuemin","aria-valuemax"],I=e.defineComponent({name:"SplitBar",__name:"SplitBar",props:{index:{},active:{type:Boolean},resizable:{type:Boolean},startCollapsible:{type:Boolean},endCollapsible:{type:Boolean},onOffsetStart:{type:Function},onOffsetUpdate:{type:Function},onOffsetEnd:{},onCollapse:{type:Function},vertical:{type:Boolean},ariaNow:{},ariaMin:{},ariaMax:{},lazy:{type:Boolean},containerSize:{},draggerIcon:{},collapsibleIcon:{},showStartCollapsibleIcon:{type:[Boolean,String]},showEndCollapsibleIcon:{type:[Boolean,String]}},setup(l){function b(t){return typeof t=="number"&&!Number.isNaN(t)&&Number.isFinite(t)?Math.round(t):0}const n=l,{b:a,cssVar:E}=k.useNamespace("splitter-bar"),v=e.ref(null),u=e.ref(0),B=e.computed(()=>n.vertical?0:e.unref(u)),M=e.computed(()=>n.vertical?e.unref(u):0),O=t=>{n.resizable&&t.currentTarget&&(v.value=[t.pageX,t.pageY],n.onOffsetStart(n.index))},x=t=>{if(n.resizable&&t.touches.length===1){const o=t.touches[0];v.value=[o.pageX,o.pageY],n.onOffsetStart(n.index)}},N=t=>{const{containerSize:o,ariaMax:s,ariaMin:i,ariaNow:c}=n,r=o*c/100,d=r+t,f=Math.max(0,o*i/100),m=Math.max(o,o*s/100);return Math.max(f,Math.min(m,d))-r},C=(t,o)=>{const s=N(n.vertical?o:t);u.value=s},h=()=>{n.onOffsetUpdate(n.index,e.unref(B),e.unref(M)),u.value=0},y=t=>{switch(t){case!0:return a("collapse-bar-always-visible");case!1:return a("collapse-bar-always-hidden");case"auto":return a("collapse-bar-hover-only")}};e.watchEffect(t=>{const o=e.unref(v);if(o){const s=d=>{const{pageX:f,pageY:m}=d,p=f-o[0],z=m-o[1];n.lazy?C(p,z):n.onOffsetUpdate(n.index,p,z)},i=()=>{n.lazy&&h(),v.value=null,n.onOffsetEnd()},c=d=>{if(d.touches.length===1){const f=d.touches[0],m=f.pageX-o[0],p=f.pageY-o[1];n.lazy?C(m,p):n.onOffsetUpdate(n.index,m,p)}},r=()=>{n.lazy&&h(),v.value=null,n.onOffsetEnd()};window.addEventListener("touchmove",c),window.addEventListener("touchend",r),window.addEventListener("mousemove",s),window.addEventListener("mouseup",i),t(()=>{window.removeEventListener("touchmove",c),window.removeEventListener("touchend",r),window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",i)})}},{flush:"post"});const w=e.computed(()=>{const{collapsibleIcon:t,vertical:o}=n;let s=null,i=null;const c=t?.start!==void 0,r=t?.end!==void 0;return o?(s=c?()=>t.start:g.UpOutlined,i=r?()=>t.end:g.DownOutlined):(s=c?()=>t.start:g.LeftOutlined,i=r?()=>t.end:g.RightOutlined),{startIcon:s,endIcon:i,startCustomize:c,endCustomize:r}});return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(a)()),role:"separator","aria-valuenow":b(n.ariaNow),"aria-valuemin":b(n.ariaMin),"aria-valuemax":b(n.ariaMax)},[n.lazy?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass([e.unref(a)("preview"),{[e.unref(a)("preview-active")]:!!u.value}]),style:e.normalizeStyle(e.unref(E)({"preview-offset":`${u.value}px`}))},null,6)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass([e.unref(a)("dragger"),{[e.unref(a)("dragger-disabled")]:!l.resizable,[e.unref(a)("dragger-active")]:l.active,[e.unref(a)("dragger-customize")]:l.draggerIcon!==void 0}]),onMousedown:O,onTouchstart:x},[l.draggerIcon!==void 0?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(e.unref(a)("dragger-icon"))},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(l.draggerIcon)))],2)):e.createCommentVNode("",!0)],34),l.startCollapsible?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass([e.unref(a)("collapse-bar"),e.unref(a)("collapse-bar-start"),w.value.startCustomize?e.unref(a)("collapse-bar-customize"):"",y(l.showStartCollapsibleIcon)]),onClick:o[0]||(o[0]=()=>l.onCollapse(l.index,"start"))},[e.createElementVNode("span",{class:e.normalizeClass([e.unref(a)("collapse-icon"),e.unref(a)("collapse-start")])},[e.createVNode(e.unref(w).startIcon)],2)],2)):e.createCommentVNode("",!0),l.endCollapsible?(e.openBlock(),e.createElementBlock("div",{key:2,class:e.normalizeClass([e.unref(a)("collapse-bar"),e.unref(a)("collapse-bar-end"),w.value.endCustomize?e.unref(a)("collapse-bar-customize"):"",y(l.showEndCollapsibleIcon)]),onClick:o[1]||(o[1]=()=>l.onCollapse(l.index,"end"))},[e.createElementVNode("span",{class:e.normalizeClass([e.unref(a)("collapse-icon"),e.unref(a)("collapse-end")])},[e.createVNode(e.unref(w).endIcon)],2)],2)):e.createCommentVNode("",!0)],10,S))}});exports.default=I;
