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