import{O as e,n,S as a,f as r,c as t,g as l,d as o,e as u,h as s,k as c,l as i,m as f}from"../../vendor.js";import{forwardRef as v,useState as g,useEffect as d,Children as p,cloneElement as D}from"react";var m=["className","children","disabled","onDrop","onDragOver","onDragLeave"];function b(e,n){var a=c(e);if(i){var r=i(e);n&&(r=f(r).call(r,(function(n){return s(e,n).enumerable}))),a.push.apply(a,r)}return a}function h(e){for(var n=1;n<arguments.length;n++){var a,c=null!=arguments[n]?arguments[n]:{};if(n%2)r(a=b(Object(c),!0)).call(a,(function(n){t(e,n,c[n])}));else if(l)o(e,l(c));else{var i;r(i=b(Object(c))).call(i,(function(n){u(e,n,s(c,n))}))}}return e}var O=v((function(r,t){var l=r.className,o=r.children,u=r.disabled,s=void 0!==u&&u,c=r.onDrop,i=r.onDragOver,f=r.onDragLeave,v=e(r,m),b=g(!1),O=n(b,2),N=O[0],j=O[1],L=g(0),x=n(L,2),y=x[0],S=x[1],T=g(null),Y=n(T,2),k=Y[0],B=Y[1];d((function(){y<=0&&j(!1)}),[y]);var C=p.only(o);return D(C,h(h({},v),{},{ref:t,className:a(l,C.props.className,{"drag-enter":!s&&N},{"drag-top":!s&&N&&k&&"before"===k},{"drag-bottom":!s&&N&&k&&"after"===k}),onDragEnter:function(){s||(S(y+1),j(!0))},onDragLeave:function(e){s||(S(y-1),B(null),null==f||f(e))},onDrop:function(e){s||(S(0),j(!1),null==c||c(JSON.parse(e.dataTransfer.getData("text")),k,e),e.preventDefault(),B(null))},onDragOver:function(e){var n,a=e.currentTarget.getBoundingClientRect(),r=(null==a?void 0:a.top)+(null==a?void 0:a.height)/2;return e.clientY>=r?n="after":e.clientY<r&&(n="before"),B(n),e.preventDefault(),null==i||i(e,n),!1}}))}));export{O as D};
//# sourceMappingURL=index.js.map
