"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),w=require("@ant-design/icons-vue");require("../config-provider/index.js");const I=require("../config-provider/hooks/use-namespace.js"),S=["aria-valuenow","aria-valuemin","aria-valuemax"],L=300,V=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]},onDraggerDoubleClick:{type:Function}},setup(l){function C(n){return typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n)?Math.round(n):0}const t=l,{b:a,cssVar:B}=I.useNamespace("splitter-bar");let b=0;const v=e.ref(null),u=e.ref(0),k=e.computed(()=>t.vertical?0:e.unref(u)),M=e.computed(()=>t.vertical?e.unref(u):0),O=n=>{n.stopPropagation();const o=Date.now(),s=o-b;s>0&&s<L||(b=o,t.resizable&&n.currentTarget&&(v.value=[n.pageX,n.pageY],t.onOffsetStart(t.index)))},x=n=>{if(t.resizable&&n.touches.length===1){const o=n.touches[0];v.value=[o.pageX,o.pageY],t.onOffsetStart(t.index)}},N=n=>{const{containerSize:o,ariaMax:s,ariaMin:i,ariaNow:c}=t,r=o*c/100,d=r+n,f=Math.max(0,o*i/100),m=Math.max(o,o*s/100);return Math.max(f,Math.min(m,d))-r},y=(n,o)=>{const s=N(t.vertical?o:n);u.value=s},h=()=>{t.onOffsetUpdate(t.index,e.unref(k),e.unref(M)),u.value=0},z=n=>{switch(n){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(n=>{const o=e.unref(v);if(o){const s=d=>{const{pageX:f,pageY:m}=d,p=f-o[0],E=m-o[1];t.lazy?y(p,E):t.onOffsetUpdate(t.index,p,E)},i=()=>{t.lazy&&h(),v.value=null,t.onOffsetEnd()},c=d=>{if(d.touches.length===1){const f=d.touches[0],m=f.pageX-o[0],p=f.pageY-o[1];t.lazy?y(m,p):t.onOffsetUpdate(t.index,m,p)}},r=()=>{t.lazy&&h(),v.value=null,t.onOffsetEnd()};window.addEventListener("touchmove",c),window.addEventListener("touchend",r),window.addEventListener("mousemove",s),window.addEventListener("mouseup",i),n(()=>{window.removeEventListener("touchmove",c),window.removeEventListener("touchend",r),window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",i)})}},{flush:"post"});const g=e.computed(()=>{const{collapsibleIcon:n,vertical:o}=t;let s=null,i=null;const c=n?.start!==void 0,r=n?.end!==void 0;return o?(s=c?()=>n.start:w.UpOutlined,i=r?()=>n.end:w.DownOutlined):(s=c?()=>n.start:w.LeftOutlined,i=r?()=>n.end:w.RightOutlined),{startIcon:s,endIcon:i,startCustomize:c,endCustomize:r}});return(n,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(e.unref(a)()),role:"separator","aria-valuenow":C(t.ariaNow),"aria-valuemin":C(t.ariaMin),"aria-valuemax":C(t.ariaMax)},[t.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(B)({"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,onDblclick:o[0]||(o[0]=()=>l.onDraggerDoubleClick?.(l.index))},[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"),g.value.startCustomize?e.unref(a)("collapse-bar-customize"):"",z(l.showStartCollapsibleIcon)]),onClick:o[1]||(o[1]=()=>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(g).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"),g.value.endCustomize?e.unref(a)("collapse-bar-customize"):"",z(l.showEndCollapsibleIcon)]),onClick:o[2]||(o[2]=()=>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(g).endIcon)],2)],2)):e.createCommentVNode("",!0)],10,S))}});exports.default=V;
