/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("../_virtual/_rollupPluginBabelHelpers.js"),i=require("../../../../_virtual/index.js");function e(t){var i=parseFloat(t);return-1===t.indexOf("%")&&!Number.isNaN(i)&&i}var n=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],o=n.length;function r(i){if("string"==typeof i&&(i=document.querySelector(i)),i&&"object"===t.typeof(i)&&i.nodeType){var r=function(t){return window.getComputedStyle(t)}(i);if("none"===r.display)return function(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},i=0;i<o;i++)t[n[i]]=0;return t}();var s={};s.width=i.offsetWidth,s.height=i.offsetHeight;for(var a=s.isBorderBox="border-box"===r.boxSizing,h=0;h<o;h++){var d=n[h],u=r[d],c=parseFloat(u);s[d]=Number.isNaN(c)?0:c}var g=s.paddingLeft+s.paddingRight,l=s.paddingTop+s.paddingBottom,v=s.marginLeft+s.marginRight,f=s.marginTop+s.marginBottom,p=s.borderLeftWidth+s.borderRightWidth,y=s.borderTopWidth+s.borderBottomWidth,m=a,_=e(r.width);!1!==_&&(s.width=_+(m?0:g+p));var b=e(r.height);return!1!==b&&(s.height=b+(m?0:l+y)),s.innerWidth=s.width-(g+p),s.innerHeight=s.height-(l+y),s.outerWidth=s.width+v,s.outerHeight=s.height+f,s}}function s(t,i){for(var e=0;e<t.length;e++){var n=t[e];if(n.identifier===i)return n}}var a="dragStart",h="dragMove",d="dragEnded",u={mousedown:["mousemove","mouseup"],touchstart:["touchmove","touchend","touchcancel"],pointerdown:["pointermove","pointerup","pointercancel"]},c=function(i){t.inherits(n,i);var e=t.createSuper(n);function n(i){var o,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.classCallCheck(this,n),(o=e.call(this)).isEnabled=!0,o.isDragging=!1,o.isDown=!1,o.position={},o.downPoint={},o.dragPoint={x:0,y:0},o.startPos={x:0,y:0},o._root=i instanceof Element?i:document.querySelector(i),o._handlerDom=r.handle instanceof Element?r.handle:document.querySelector(r.handle),o._root&&o._handlerDom?(o._bindStartEvent(),o):t.possibleConstructorReturn(o)}return t.createClass(n,[{key:"_bindStartEvent",value:function(){var t=this;"ontouchstart"in window?this._startKey="touchstart":this._startKey="mousedown",this["on".concat(this._startKey)]=this["on".concat(this._startKey)].bind(this),this._handlerDom.addEventListener(this._startKey,this["on".concat(this._startKey)]),u[this._startKey].map(function(i){t["on".concat(i)]=t["on".concat(i)].bind(t)})}},{key:"_unbindStartEvent",value:function(){this._handlerDom.removeEventListener(this._startKey,this["on".concat(this._startKey)])}},{key:"_bindPostStartEvents",value:function(t){var i=this;if(t){var e=u[this._startKey];e.map(function(t){window.addEventListener(t,i["on".concat(t)])}),this._boundPointerEvents=e}}},{key:"_unbindPostStartEvents",value:function(){var t=this;this._boundPointerEvents&&(this._boundPointerEvents.map(function(i){window.removeEventListener(i,t["on".concat(i)])}),delete this._boundPointerEvents)}},{key:"enable",value:function(){this.isEnabled=!0}},{key:"disable",value:function(){this.isEnabled=!1,this.isDragging&&this.onUp()}},{key:"onDocUp",value:function(t){this.onUp()}},{key:"animate",value:function(){var t=this;this.isDragging&&(this.positionDrag(),window.requestAnimationFrame(function(){t.animate()}))}},{key:"positionDrag",value:function(){var t="translate3d(".concat(this.dragPoint.x,"px, ").concat(this.dragPoint.y,"px, 0)");this._root.style.transform=t,this._root.style.webKitTransform=t}},{key:"setLeftTop",value:function(){this._root.style.left=this.position.x+"px",this._root.style.top=this.position.y+"px"}},{key:"onmousedown",value:function(t){this.dragStart(t,t)}},{key:"onmousemove",value:function(t){this.dragMove(t,t)}},{key:"onmouseup",value:function(t){this.dragEnd(t,t)}},{key:"ontouchstart",value:function(t){var i=t.changedTouches[0];this.dragStart(t,i),this.touchIdentifier=void 0!==i.pointerId?i.pointerId:i.identifier,t.preventDefault()}},{key:"ontouchmove",value:function(t){var i=s(t.changedTouches,this.touchIdentifier);i&&this.dragMove(t,i)}},{key:"ontouchend",value:function(t){var i=s(t.changedTouches,this.touchIdentifier);i&&this.dragEnd(t,i),t.preventDefault()}},{key:"ontouchcancel",value:function(t){var i=s(t.changedTouches,this.touchIdentifier);i&&this.dragCancel(t,i)}},{key:"dragStart",value:function(t,i){if(this._root&&!this.isDown&&this.isEnabled){this.downPoint=i,this.dragPoint.x=0,this.dragPoint.y=0,this._getPosition();var e=r(this._root);this.startPos.x=this.position.x,this.startPos.y=this.position.y,this.startPos.maxY=window.innerHeight-e.height,this.startPos.maxX=window.innerWidth-e.width,this.setLeftTop(),this.isDown=!0,this._bindPostStartEvents(t)}}},{key:"dragRealStart",value:function(t,i){this.isDragging=!0,this.animate(),this.emit(a,this.startPos)}},{key:"dragEnd",value:function(t,i){this._root&&(this._unbindPostStartEvents(),this.isDragging&&(this._root.style.transform="",this.setLeftTop(),this.emit(d)),this.presetInfo())}},{key:"_dragPointerMove",value:function(t,i){var e={x:i.pageX-this.downPoint.pageX,y:i.pageY-this.downPoint.pageY};return!this.isDragging&&this.hasDragStarted(e)&&this.dragRealStart(t,i),e}},{key:"dragMove",value:function(t,i){if(t=t||window.event,this.isDown){var e=this.startPos,n=e.x,o=e.y,r=this._dragPointerMove(t,i),s=r.x,a=r.y;s=this.checkContain("x",s,n),a=this.checkContain("y",a,o),this.position.x=n+s,this.position.y=o+a,this.dragPoint.x=s,this.dragPoint.y=a,this.emit(h,this.position)}}},{key:"dragCancel",value:function(t,i){this.dragEnd(t,i)}},{key:"presetInfo",value:function(){this.isDragging=!1,this.startPos={x:0,y:0},this.dragPoint={x:0,y:0},this.isDown=!1}},{key:"destroy",value:function(){this._unbindStartEvent(),this._unbindPostStartEvents(),this.isDragging&&this.dragEnd(),this.removeAllListeners(),this._handlerDom=null}},{key:"hasDragStarted",value:function(t){return Math.abs(t.x)>3||Math.abs(t.y)>3}},{key:"checkContain",value:function(t,i,e){return i+e<0?0-e:"x"===t&&i+e>this.startPos.maxX?this.startPos.maxX-e:"y"===t&&i+e>this.startPos.maxY?this.startPos.maxY-e:i}},{key:"_getPosition",value:function(){var t=window.getComputedStyle(this._root),i=this._getPositionCoord(t.left,"width"),e=this._getPositionCoord(t.top,"height");this.position.x=Number.isNaN(i)?0:i,this.position.y=Number.isNaN(e)?0:e,this._addTransformPosition(t)}},{key:"_addTransformPosition",value:function(t){var i=t.transform;if(0===i.indexOf("matrix")){var e=i.split(","),n=0===i.indexOf("matrix3d")?12:4,o=parseInt(e[n],10),r=parseInt(e[n+1],10);this.position.x+=o,this.position.y+=r}}},{key:"_getPositionCoord",value:function(t,i){if(-1!==t.indexOf("%")){var e=r(this._root.parentNode);return e?parseFloat(t)/100*e[i]:0}return parseInt(t,10)}}]),n}(i.default);exports.default=c;