From 7fa162c60fadbada19fe16094ba1bbb2c40693ca Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 3 Oct 2022 20:21:36 +0000 Subject: [PATCH] chore(release): 1.1.0-rc.5 # [1.1.0-rc.5](https://github.com/nichollascarter/subjx/compare/v1.1.0-rc.4...v1.1.0-rc.5) (2022-10-03) ### Bug Fixes * **core:** fixed issue on rotating to 90deg ([163e06d](https://github.com/nichollascarter/subjx/commit/163e06dabbf5ed4e956ad33ce7a0738819c59abb)), closes [#47](https://github.com/nichollascarter/subjx/issues/47) --- CHANGELOG.md | 7 +++++++ dist/js/subjx.common.js | 2 +- dist/js/subjx.dev.common.js | 29 +++++++++++++++-------------- dist/js/subjx.dev.js | 29 +++++++++++++++-------------- dist/js/subjx.esm.js | 29 +++++++++++++++-------------- dist/js/subjx.js | 2 +- package-lock.json | 2 +- package.json | 2 +- 8 files changed, 56 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e74a91..b482221 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [1.1.0-rc.5](https://github.com/nichollascarter/subjx/compare/v1.1.0-rc.4...v1.1.0-rc.5) (2022-10-03) + + +### Bug Fixes + +* **core:** fixed issue on rotating to 90deg ([163e06d](https://github.com/nichollascarter/subjx/commit/163e06dabbf5ed4e956ad33ce7a0738819c59abb)), closes [#47](https://github.com/nichollascarter/subjx/issues/47) + # [1.1.0-rc.4](https://github.com/nichollascarter/subjx/compare/v1.1.0-rc.3...v1.1.0-rc.4) (2022-03-21) diff --git a/dist/js/subjx.common.js b/dist/js/subjx.common.js index 4be486f..9fa39ef 100644 --- a/dist/js/subjx.common.js +++ b/dist/js/subjx.common.js @@ -4,4 +4,4 @@ * Karen Sarksyan * nichollascarter@gmail.com */ -"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r=0||(o[r]=e[r]);return o}function _objectWithoutProperties(e,t){if(null==e)return{};var r,a,o=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?_assertThisInitialized(e):t}function _createSuper(e){return function(){var t,r=_getPrototypeOf(e);if(_isNativeReflectConstruct()){var a=_getPrototypeOf(this).constructor;t=Reflect.construct(r,arguments,a)}else t=r.apply(this,arguments);return _possibleConstructorReturn(this,t)}}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(e,t,r){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var a=_superPropBase(e,t);if(a){var o=Object.getOwnPropertyDescriptor(a,t);return o.get?o.get.call(r):o.value}})(e,t,r||e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _iterableToArrayLimit(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],a=!0,o=!1,n=void 0;try{for(var i,s=e[Symbol.iterator]();!(a=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);a=!0);}catch(e){o=!0,n=e}finally{try{a||null==s.return||s.return()}finally{if(o)throw n}}return r}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o,n=!0,i=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var e=a.next();return n=e.done,e},e:function(e){i=!0,o=e},f:function(){try{n||null==a.return||a.return()}finally{if(i)throw o}}}}var requestAnimFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return setTimeout(e,1e3/60)},cancelAnimFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame||function(e){clearTimeout(e)},_Array$prototype=Array.prototype,forEach=_Array$prototype.forEach,arrSlice=_Array$prototype.slice,arrMap=_Array$prototype.map,arrReduce=_Array$prototype.reduce,_console=console,warn=_console.warn,noop=function(e){return e},isDef=function(e){return null!=e},isUndef=function(e){return null==e},isFunc=function(e){return"function"==typeof e},createMethod=function(e){return isFunc(e)?function(){e.call.apply(e,[this].concat(Array.prototype.slice.call(arguments)))}:noop},Helper=function(){function e(t){if(_classCallCheck(this,e),"string"==typeof t){var r=document.querySelectorAll(t);this.length=r.length;for(var a=0;a0&&e.length-1 in e))}function helper(e){return new Helper(e)}var MIN_SIZE=2,THEME_COLOR="#00a8ff",LIB_CLASS_PREFIX="sjx-",E_MOUSEDOWN="mousedown",E_MOUSEUP="mouseup",E_MOUSEMOVE="mousemove",E_TOUCHSTART="touchstart",E_TOUCHEND="touchend",E_TOUCHMOVE="touchmove",E_DRAG_START="dragStart",E_DRAG="drag",E_DRAG_END="dragEnd",E_RESIZE_START="resizeStart",E_RESIZE="resize",E_RESIZE_END="resizeEnd",E_ROTATE_START="rotateStart",E_ROTATE="rotate",E_ROTATE_END="rotateEnd",E_SET_POINT="setPoint",E_SET_POINT_START="setPointStart",E_SET_POINT_END="setPointEnd",EMITTER_EVENTS=[E_DRAG_START,E_DRAG,,E_DRAG_END,E_RESIZE_START,E_RESIZE,E_RESIZE_END,E_ROTATE_START,E_ROTATE,E_ROTATE_END,E_SET_POINT_START,E_SET_POINT_END],CSS_PREFIXES=["","-webkit-","-moz-","-ms-","-o-"],ON_GETSTATE="ongetstate",ON_APPLY="onapply",ON_MOVE="onmove",ON_RESIZE="onresize",ON_ROTATE="onrotate",NOTIFIER_EVENTS=[ON_GETSTATE,ON_APPLY,ON_MOVE,ON_RESIZE,ON_ROTATE],NOTIFIER_CONSTANTS={NOTIFIER_EVENTS:NOTIFIER_EVENTS,ON_GETSTATE:ON_GETSTATE,ON_APPLY:ON_APPLY,ON_MOVE:ON_MOVE,ON_RESIZE:ON_RESIZE,ON_ROTATE:ON_ROTATE},EVENT_EMITTER_CONSTANTS={EMITTER_EVENTS:EMITTER_EVENTS,E_DRAG_START:E_DRAG_START,E_DRAG:E_DRAG,E_DRAG_END:E_DRAG_END,E_RESIZE_START:E_RESIZE_START,E_RESIZE:E_RESIZE,E_RESIZE_END:E_RESIZE_END,E_ROTATE_START:E_ROTATE_START,E_ROTATE:E_ROTATE,E_ROTATE_END:E_ROTATE_END,E_SET_POINT:E_SET_POINT,E_SET_POINT_START:E_SET_POINT_START,E_SET_POINT_END:E_SET_POINT_END},CLIENT_EVENTS_CONSTANTS={E_MOUSEDOWN:E_MOUSEDOWN,E_MOUSEUP:E_MOUSEUP,E_MOUSEMOVE:E_MOUSEMOVE,E_TOUCHSTART:E_TOUCHSTART,E_TOUCHEND:E_TOUCHEND,E_TOUCHMOVE:E_TOUCHMOVE},TRANSFORM_HANDLES_KEYS={TOP_LEFT:"tl",TOP_CENTER:"tc",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br",BOTTOM_CENTER:"bc",MIDDLE_LEFT:"ml",MIDDLE_RIGHT:"mr",CENTER:"center"},TRANSFORM_EDGES_KEYS={TOP_EDGE:"te",BOTTOM_EDGE:"be",LEFT_EDGE:"le",RIGHT_EDGE:"re"},TRANSFORM_HANDLES_CONSTANTS={TRANSFORM_HANDLES_KEYS:TRANSFORM_HANDLES_KEYS,TRANSFORM_EDGES_KEYS:TRANSFORM_EDGES_KEYS},ON_GETSTATE$1=NOTIFIER_CONSTANTS.ON_GETSTATE,ON_APPLY$1=NOTIFIER_CONSTANTS.ON_APPLY,ON_MOVE$1=NOTIFIER_CONSTANTS.ON_MOVE,ON_RESIZE$1=NOTIFIER_CONSTANTS.ON_RESIZE,ON_ROTATE$1=NOTIFIER_CONSTANTS.ON_ROTATE,Observable=function(){function e(){_classCallCheck(this,e),this.observers={}}return _createClass(e,[{key:"subscribe",value:function(e,t){var r=this.observers;return isUndef(r[e])&&Object.defineProperty(r,e,{value:[]}),r[e].push(t),this}},{key:"unsubscribe",value:function(e,t){var r=this.observers;if(isDef(r[e])){var a=r[e].indexOf(t);r[e].splice(a,1)}return this}},{key:"notify",value:function(e,t,r){isUndef(this.observers[e])||this.observers[e].forEach((function(a){if(t!==a)switch(e){case ON_MOVE$1:a.notifyMove(r);break;case ON_ROTATE$1:a.notifyRotate(r);break;case ON_RESIZE$1:a.notifyResize(r);break;case ON_APPLY$1:a.notifyApply(r);break;case ON_GETSTATE$1:a.notifyGetState(r)}}))}}]),e}(),Event=function(){function e(t){_classCallCheck(this,e),this.name=t,this.callbacks=[]}return _createClass(e,[{key:"registerCallback",value:function(e){this.callbacks.push(e)}},{key:"removeCallback",value:function(e){var t=this.callbacks(e);this.callbacks.splice(t,1)}}]),e}(),EventDispatcher=function(){function e(){_classCallCheck(this,e),this.events={}}return _createClass(e,[{key:"registerEvent",value:function(e){this.events[e]=new Event(e)}},{key:"emit",value:function(e,t,r){this.events[t].callbacks.forEach((function(t){t.call(e,r)}))}},{key:"addEventListener",value:function(e,t){this.events[e].registerCallback(t)}},{key:"removeEventListener",value:function(e,t){this.events[e].removeCallback(t)}}]),e}(),E_DRAG$1=EVENT_EMITTER_CONSTANTS.E_DRAG,E_MOUSEMOVE$1=CLIENT_EVENTS_CONSTANTS.E_MOUSEMOVE,E_MOUSEUP$1=CLIENT_EVENTS_CONSTANTS.E_MOUSEUP,E_TOUCHMOVE$1=CLIENT_EVENTS_CONSTANTS.E_TOUCHMOVE,E_TOUCHEND$1=CLIENT_EVENTS_CONSTANTS.E_TOUCHEND,SubjectModel=function(){function e(t){_classCallCheck(this,e),this.elements=t,this.storage=null,this.proxyMethods=null,this.eventDispatcher=new EventDispatcher,this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._animate=this._animate.bind(this)}return _createClass(e,[{key:"enable",value:function(e){this._processOptions(e),this._init(this.elements),this.proxyMethods.onInit.call(this,this.elements)}},{key:"disable",value:function(){throwNotImplementedError()}},{key:"_init",value:function(){throwNotImplementedError()}},{key:"_destroy",value:function(){throwNotImplementedError()}},{key:"_processOptions",value:function(){throwNotImplementedError()}},{key:"_start",value:function(){throwNotImplementedError()}},{key:"_moving",value:function(){throwNotImplementedError()}},{key:"_end",value:function(){throwNotImplementedError()}},{key:"_animate",value:function(){throwNotImplementedError()}},{key:"_drag",value:function(e){var t=e.element,r=e.dx,a=e.dy,o=_objectWithoutProperties(e,["element","dx","dy"]),n=_objectSpread2({dx:r,dy:a,transform:this._processMove(t,{dx:r,dy:a})},o);this.proxyMethods.onMove.call(this,n),this._emitEvent(E_DRAG$1,n)}},{key:"_draw",value:function(){this._animate()}},{key:"_onMouseDown",value:function(e){this._start(e),helper(document).on(E_MOUSEMOVE$1,this._onMouseMove).on(E_MOUSEUP$1,this._onMouseUp)}},{key:"_onTouchStart",value:function(e){this._start(e.touches[0]),helper(document).on(E_TOUCHMOVE$1,this._onTouchMove).on(E_TOUCHEND$1,this._onTouchEnd)}},{key:"_onMouseMove",value:function(e){e.preventDefault&&e.preventDefault(),this._moving(e)}},{key:"_onTouchMove",value:function(e){e.preventDefault&&e.preventDefault(),this._moving(e.touches[0])}},{key:"_onMouseUp",value:function(e){helper(document).off(E_MOUSEMOVE$1,this._onMouseMove).off(E_MOUSEUP$1,this._onMouseUp),this._end(e,this.elements)}},{key:"_onTouchEnd",value:function(e){helper(document).off(E_TOUCHMOVE$1,this._onTouchMove).off(E_TOUCHEND$1,this._onTouchEnd),0===e.touches.length&&this._end(e.changedTouches[0],this.elements)}},{key:"_emitEvent",value:function(){var e;(e=this.eventDispatcher).emit.apply(e,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"on",value:function(e,t){return this.eventDispatcher.addEventListener(e,t),this}},{key:"off",value:function(e,t){return this.eventDispatcher.removeEventListener(e,t),this}}]),e}(),throwNotImplementedError=function(){throw Error("Method not implemented")},RAD=Math.PI/180,DEG=180/Math.PI,snapCandidate=function(e,t){return 0===t?e:Math.round(e/t)*t},snapToGrid=function(e,t){if(0===t)return e;var r=snapCandidate(e,t);return r-e1&&void 0!==arguments[1]?arguments[1]:6;return Number(e.toFixed(t))},getMinMaxOfArray=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=[],a=function(t){var a=e.map((function(e){return e[t]}));r.push([Math.min.apply(Math,_toConsumableArray(a)),Math.max.apply(Math,_toConsumableArray(a))])},o=0;o-1))return e.classList.add(t);t.split(/\s+/).forEach((function(t){return e.classList.add(t)}))}return e}},removeClass=function(e,t){if(t){if(e.classList){if(!(t.indexOf(" ")>-1))return e.classList.remove(t);t.split(/\s+/).forEach((function(t){return e.classList.remove(t)}))}return e}},objectsCollide=function(e,t){var r=getOffset(e),a=r.top,o=r.left,n=getOffset(t),i=n.top,s=n.left,l=helper(e),c=helper(t);return!(ai+parseFloat(c.css("height"))||os+parseFloat(c.css("width")))},matrixToCSS=function(e){var t="matrix3d(".concat(e.join(),")");return{transform:t,webkitTranform:t,mozTransform:t,msTransform:t,otransform:t}},getStyle=function(e,t){var r,a=window.getComputedStyle(e),o=null,n=_createForOfIteratorHelper(CSS_PREFIXES);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(o=a.getPropertyValue("".concat(i).concat(t))||o)break}}catch(e){n.e(e)}finally{n.f()}return o},getScrollOffset=function(){var e=document.documentElement;return{left:(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0),top:(window.pageYOffset||e.scrollTop)-(e.clientTop||0)}},getElementOffset=function(e){for(var t=0,r=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)t+=e.offsetLeft-e.scrollLeft,r+=e.offsetTop-e.scrollTop,e=e.offsetParent;return{left:t,top:r}},NOTIFIER_EVENTS$1=NOTIFIER_CONSTANTS.NOTIFIER_EVENTS,ON_GETSTATE$2=NOTIFIER_CONSTANTS.ON_GETSTATE,ON_APPLY$2=NOTIFIER_CONSTANTS.ON_APPLY,ON_MOVE$2=NOTIFIER_CONSTANTS.ON_MOVE,ON_RESIZE$2=NOTIFIER_CONSTANTS.ON_RESIZE,ON_ROTATE$2=NOTIFIER_CONSTANTS.ON_ROTATE,EMITTER_EVENTS$1=EVENT_EMITTER_CONSTANTS.EMITTER_EVENTS,E_DRAG_START$1=EVENT_EMITTER_CONSTANTS.E_DRAG_START,E_DRAG$2=EVENT_EMITTER_CONSTANTS.E_DRAG,E_DRAG_END$1=EVENT_EMITTER_CONSTANTS.E_DRAG_END,E_RESIZE_START$1=EVENT_EMITTER_CONSTANTS.E_RESIZE_START,E_RESIZE$1=EVENT_EMITTER_CONSTANTS.E_RESIZE,E_RESIZE_END$1=EVENT_EMITTER_CONSTANTS.E_RESIZE_END,E_ROTATE_START$1=EVENT_EMITTER_CONSTANTS.E_ROTATE_START,E_ROTATE$1=EVENT_EMITTER_CONSTANTS.E_ROTATE,E_ROTATE_END$1=EVENT_EMITTER_CONSTANTS.E_ROTATE_END,E_SET_POINT$1=EVENT_EMITTER_CONSTANTS.E_SET_POINT,E_SET_POINT_END$1=EVENT_EMITTER_CONSTANTS.E_SET_POINT_END,TRANSFORM_HANDLES_KEYS$1=TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_HANDLES_KEYS,TRANSFORM_EDGES_KEYS$1=TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_EDGES_KEYS,E_MOUSEDOWN$1=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$1=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,E_MOUSEMOVE$2=CLIENT_EVENTS_CONSTANTS.E_MOUSEMOVE,E_MOUSEUP$2=CLIENT_EVENTS_CONSTANTS.E_MOUSEUP,E_TOUCHMOVE$2=CLIENT_EVENTS_CONSTANTS.E_TOUCHMOVE,E_TOUCHEND$2=CLIENT_EVENTS_CONSTANTS.E_TOUCHEND,TOP_LEFT=TRANSFORM_HANDLES_KEYS$1.TOP_LEFT,TOP_CENTER=TRANSFORM_HANDLES_KEYS$1.TOP_CENTER,TOP_RIGHT=TRANSFORM_HANDLES_KEYS$1.TOP_RIGHT,BOTTOM_LEFT=TRANSFORM_HANDLES_KEYS$1.BOTTOM_LEFT,BOTTOM_RIGHT=TRANSFORM_HANDLES_KEYS$1.BOTTOM_RIGHT,BOTTOM_CENTER=TRANSFORM_HANDLES_KEYS$1.BOTTOM_CENTER,MIDDLE_LEFT=TRANSFORM_HANDLES_KEYS$1.MIDDLE_LEFT,MIDDLE_RIGHT=TRANSFORM_HANDLES_KEYS$1.MIDDLE_RIGHT,TOP_EDGE=TRANSFORM_EDGES_KEYS$1.TOP_EDGE,BOTTOM_EDGE=TRANSFORM_EDGES_KEYS$1.BOTTOM_EDGE,LEFT_EDGE=TRANSFORM_EDGES_KEYS$1.LEFT_EDGE,RIGHT_EDGE=TRANSFORM_EDGES_KEYS$1.RIGHT_EDGE,keys=Object.keys,values=Object.values,Transformable=function(e){_inherits(r,SubjectModel);var t=_createSuper(r);function r(e,a,o){var n;if(_classCallCheck(this,r),(n=t.call(this,e)).constructor===r)throw new TypeError("Cannot construct Transformable instances directly");return n.observable=o,EMITTER_EVENTS$1.forEach((function(e){return n.eventDispatcher.registerEvent(e)})),_get(_getPrototypeOf(r.prototype),"enable",_assertThisInitialized(n)).call(_assertThisInitialized(n),a),n}return _createClass(r,[{key:"_cursorPoint",value:function(){throw Error("'_cursorPoint()' method not implemented")}},{key:"_rotate",value:function(e){var t=e.element,a=e.radians,o=_objectWithoutProperties(e,["element","radians"]),n=_objectSpread2({transform:this._processRotate(t,a),delta:a},o);this.proxyMethods.onRotate.call(this,n),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE$1,n)}},{key:"_resize",value:function(e){var t=e.element,a=e.dx,o=e.dy,n=_objectWithoutProperties(e,["element","dx","dy"]),i=_objectSpread2({},this._processResize(t,{dx:a,dy:o}),{dx:a,dy:o},n);this.proxyMethods.onResize.call(this,i),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE$1,i)}},{key:"_processOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.elements;_toConsumableArray(t).map((function(e){return addClass(e,"".concat(LIB_CLASS_PREFIX,"drag"))}));var r=e.each,a=void 0===r?{move:!1,resize:!1,rotate:!1}:r,o=e.snap,n=void 0===o?{x:10,y:10,angle:10}:o,i=e.axis,s=void 0===i?"xy":i,l=e.cursorMove,c=void 0===l?"auto":l,u=e.cursorResize,d=void 0===u?"auto":u,f=e.cursorRotate,h=void 0===f?"auto":f,_=e.rotationPoint,T=void 0!==_&&_,p=e.transformOrigin,y=void 0!==p&&p,v=e.restrict,E=e.draggable,m=void 0===E||E,x=e.resizable,g=void 0===x||x,b=e.rotatable,S=void 0===b||b,M=e.scalable,O=void 0!==M&&M,A=e.applyTranslate,N=void 0!==A&&A,R=e.onInit,C=void 0===R?noop:R,k=e.onDrop,I=void 0===k?noop:k,D=e.onMove,P=void 0===D?noop:D,w=e.onResize,V=void 0===w?noop:w,$=e.onRotate,G=void 0===$?noop:$,L=e.onDestroy,j=void 0===L?noop:L,F=e.container,H=void 0===F?t[0].parentNode:F,U=e.controlsContainer,B=void 0===U?H:U,Y=e.proportions,z=void 0!==Y&&Y,X=e.rotatorAnchor,W=void 0===X?null:X,Z=e.rotatorOffset,K=void 0===Z?50:Z,q=e.showNormal,Q=void 0===q||q,J=e.custom;this.options={axis:s,cursorMove:c,cursorRotate:h,cursorResize:d,rotationPoint:T,transformOrigin:y||T,restrict:v?helper(v)[0]||document.body:null,container:helper(H)[0],controlsContainer:helper(B)[0],snap:_objectSpread2({},n,{angle:n.angle*RAD}),each:a,proportions:z,draggable:m,resizable:g,rotatable:S,scalable:O,applyTranslate:N,custom:"object"===_typeof(J)&&J||null,rotatorAnchor:W,rotatorOffset:K,showNormal:Q,isGrouped:t.length>1},this.proxyMethods={onInit:createMethod(C),onDrop:createMethod(I),onMove:createMethod(P),onResize:createMethod(V),onRotate:createMethod(G),onDestroy:createMethod(j)},this.subscribe(a)}},{key:"_animate",value:function(){var e=this,t=this,a=t.observable,o=t.storage,n=t.options,i=t.elements;if(!isUndef(o)&&(o.frame=requestAnimFrame(t._animate),o.doDraw)){o.doDraw=!1;var s=o.dox,l=o.doy,c=o.clientX,u=o.clientY,d=o.relativeX,f=o.relativeY,h=o.doDrag,_=o.doResize,T=o.doRotate,p=o.doSetCenter,y=o.revX,v=o.revY,E=o.mouseEvent,m=o.data,x=n.snap,g=n.each,b=g.move,S=g.resize,M=g.rotate,O=n.draggable,A=n.resizable,N=n.rotatable,R=n.isGrouped,C=n.restrict;if(_&&A){var k=snapToGrid(c-d,x.x),I=snapToGrid(u-f,x.y),D=o.cached,P=o.cached,w=(P=void 0===P?{}:P).dist,V=(w=void 0===w?{}:w).dx,$=void 0===V?k:V,G=w.dy,L=void 0===G?I:G,j={dx:k,dy:I,clientX:c,clientY:u,mouseEvent:E},F=C?i.reduce((function(t,r){var a=m.get(r).transform.ctm,o=R?{x:k,y:I}:e._pointToTransform({x:k,y:I,matrix:a}),n=o.x,i=o.y,c=s?y?-n:n:0,u=l?v?-i:i:0,d=e._processResizeRestrict(r,{dx:c,dy:u}),f=d.x,h=d.y;return{x:null!==f&&null===t.x?k:t.x,y:null!==h&&null===t.y?I:t.y}}),{x:null,y:null}):{x:null,y:null},H=F.x,U=F.y,B=C&&(null!==H||null!==U),Y=B?$:k,z=B?L:I,X=_objectSpread2({},j,{dx:Y,dy:z,revX:y,revY:v,dox:s,doy:l});i.map((function(r){var a=m.get(r).transform.ctm,o=R?{x:Y,y:z}:e._pointToTransform({x:Y,y:z,matrix:a}),n=o.x,i=o.y,c=s?y?-n:n:0,u=l?v?-i:i:0;t._resize(_objectSpread2({},X,{element:r,dx:c,dy:u}))})),this.storage.cached=_objectSpread2({},D,{dist:{dx:Y,dy:z}}),this._processControlsResize({dx:Y,dy:z}),S&&a.notify(ON_RESIZE$2,t,X)}if(h&&O){var W=s?snapToGrid(c-d,x.x):0,Z=l?snapToGrid(u-f,x.y):0,K=o.cached,q=o.cached,Q=(q=void 0===q?{}:q).dist,J=(Q=void 0===Q?{}:Q).dx,ee=void 0===J?W:J,te=Q.dy,re=void 0===te?Z:te,ae={dx:W,dy:Z,clientX:c,clientY:u,mouseEvent:E},oe=C?i.reduce((function(t,r){var a=e._processMoveRestrict(r,ae),o=a.x,n=a.y;return{x:null===t.x&&C?o:t.x,y:null===t.y&&C?n:t.y}}),{x:null,y:null}):{x:null,y:null},ne=oe.x,ie=oe.y,se=null!==ne&&C?ee:W,le=null!==ie&&C?re:Z,ce=_objectSpread2({},ae,{dx:se,dy:le});this.storage.cached=_objectSpread2({},K,{dist:{dx:se,dy:le}}),i.map((function(t){return _get(_getPrototypeOf(r.prototype),"_drag",e).call(e,_objectSpread2({element:t},ce,{dx:se,dy:le}))})),this._processControlsMove({dx:se,dy:le}),b&&a.notify(ON_MOVE$2,t,ce)}if(T&&N){var ue=o.pressang,de=o.center,fe=Math.atan2(u-de.y,c-de.x),he=snapToGrid(fe-ue,x.angle);if(C)if(i.some((function(t){var r=e._processRotateRestrict(t,he),a=r.x,o=r.y;return null!==a||null!==o})))return;var _e={clientX:c,clientY:u,mouseEvent:E};i.map((function(e){return t._rotate(_objectSpread2({element:e,radians:he},_e))})),this._processControlsRotate({radians:he}),M&&a.notify(ON_ROTATE$2,t,_objectSpread2({radians:he},_e))}if(p&&N){var Te=o.bx,pe=o.by,ye=this._pointToControls({x:c,y:u}),ve=ye.x,Ee=ye.y;t._moveCenterHandle(ve-Te,Ee-pe)}}}},{key:"_start",value:function(e){var t=e.clientX,a=e.clientY,o=this.elements,n=this.observable,i=this.options,s=i.axis,l=i.each,c=this.storage,u=this.storage.handles,d=values(u).some((function(t){return helper(e.target).is(t)}))||o.some((function(t){return t.contains(e.target)}));if(c.isTarget=d,d){var f=this._compute(e,o);keys(f).map((function(e){return c[e]=f[e]}));var h=f.onRightEdge,_=f.onBottomEdge,T=f.onTopEdge,p=f.onLeftEdge,y=f.handle,v=f.factor,E=f.revX,m=f.revY,x=f.doW,g=f.doH,b=h||_||T||p,S=u.rotator,M=u.center,O=u.radius;isDef(O)&&removeClass(O,"".concat(LIB_CLASS_PREFIX,"hidden"));var A=y.is(S),N=!!isDef(M)&&y.is(M),R=d&&!(A||b||N),C={mouseEvent:e,clientX:t,clientY:a,doResize:b,doDrag:R,doRotate:A,doSetCenter:N,onExecution:!0,cursor:null,dox:/\x/.test(s)&&(!b||(y.is(u.ml)||y.is(u.mr)||y.is(u.tl)||y.is(u.tr)||y.is(u.bl)||y.is(u.br)||y.is(u.le)||y.is(u.re))),doy:/\y/.test(s)&&(!b||(y.is(u.br)||y.is(u.bl)||y.is(u.bc)||y.is(u.tr)||y.is(u.tl)||y.is(u.tc)||y.is(u.te)||y.is(u.be)))};this.storage=_objectSpread2({},c,{},C);var k={clientX:t,clientY:a};b?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE_START$1,k):A?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE_START$1,k):R&&_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_DRAG_START$1,k);var I=l.move,D=l.resize,P=l.rotate,w=b?E_RESIZE$1:A?E_ROTATE$1:E_DRAG$2,V=b&&D||A&&P||R&&I;n.notify(ON_GETSTATE$2,this,{clientX:t,clientY:a,actionName:w,triggerEvent:V,factor:v,revX:E,revY:m,doW:x,doH:g}),this._draw()}}},{key:"_moving",value:function(e){var t=this.storage,r=void 0===t?{}:t,a=this.options;if(r.isTarget){var o=this._cursorPoint(e),n=o.x,i=o.y;r.mouseEvent=e,r.clientX=n,r.clientY=i,r.doDraw=!0;var s=r.doRotate,l=r.doDrag,c=r.doResize,u=r.cursor,d=a.cursorMove,f=a.cursorResize,h=a.cursorRotate;isUndef(u)&&(l?u=d:s?u=h:c&&(u=f),helper(document.body).css({cursor:u}))}}},{key:"_end",value:function(e){var t=this,a=e.clientX,o=e.clientY,n=this.elements,i=this.options.each,s=this.observable,l=this.storage,c=l.doResize,u=l.doDrag,d=l.doRotate,f=l.doSetCenter,h=l.frame,_=l.handles.radius,T=l.isTarget,p=this.proxyMethods;if(T){var y=([{actionName:E_RESIZE$1,condition:c},{actionName:E_DRAG$2,condition:u},{actionName:E_ROTATE$1,condition:d},{actionName:E_SET_POINT$1,condition:f}].find((function(e){return e.condition}))||{}).actionName,v=void 0===y?E_DRAG$2:y;n.map((function(e){return t._applyTransformToElement(e,v)})),this._processActions(v),this._updateStorage();var E={clientX:a,clientY:o};p.onDrop.call(this,E),c?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE_END$1,E):d?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE_END$1,E):u?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_DRAG_END$1,E):f&&_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_SET_POINT_END$1,E);var m=i.move,x=i.resize,g=i.rotate,b=c&&x||d&&g||u&&m;s.notify(ON_APPLY$2,this,{clientX:a,clientY:o,actionName:v,triggerEvent:b}),cancelAnimFrame(h),helper(document.body).css({cursor:"auto"}),isDef(_)&&addClass(_,"".concat(LIB_CLASS_PREFIX,"hidden"))}}},{key:"_compute",value:function(e,t){var r=this,a=this.storage,o=(a=void 0===a?{}:a).handles,n=a.data,i=helper(e.target),s=this._checkHandles(i,o),l=s.revX,c=s.revY,u=s.doW,d=s.doH,f=_objectWithoutProperties(s,["revX","revY","doW","doH"]),h=this._getCommonState(),_=this._cursorPoint(e),T=_.x,p=_.y,y=this._pointToControls({x:T,y:p},h.transform),v=y.x,E=y.y;t.map((function(e){var t=r._getElementState(e,{revX:l,revY:c,doW:u,doH:d}),a=t.transform,o=_objectWithoutProperties(t,["transform"]),i=r._pointToTransform({x:T,y:p,matrix:a.ctm}),s=i.x,f=i.y;n.set(e,_objectSpread2({},n.get(e),{},o,{transform:a,cx:s,cy:f}))}));var m=Math.atan2(p-h.center.y,T-h.center.x);return _objectSpread2({data:n},f,{handle:values(o).some((function(t){return helper(e.target).is(t)}))?i:helper(t[0]),pressang:m},h,{revX:l,revY:c,doW:u,doH:d,relativeX:T,relativeY:p,bx:v,by:E})}},{key:"_checkHandles",value:function(e,t){var r=function(r){return r.some((function(r){return a=t[r],!!isDef(a)&&e.is(a);var a}))};return{revX:r([TOP_LEFT,MIDDLE_LEFT,BOTTOM_LEFT,TOP_CENTER,LEFT_EDGE]),revY:r([TOP_LEFT,TOP_RIGHT,TOP_CENTER,MIDDLE_LEFT,TOP_EDGE]),onTopEdge:r([TOP_CENTER,TOP_RIGHT,TOP_LEFT,TOP_EDGE]),onLeftEdge:r([TOP_LEFT,MIDDLE_LEFT,BOTTOM_LEFT,LEFT_EDGE]),onRightEdge:r([TOP_RIGHT,MIDDLE_RIGHT,BOTTOM_RIGHT,RIGHT_EDGE]),onBottomEdge:r([BOTTOM_RIGHT,BOTTOM_CENTER,BOTTOM_LEFT,BOTTOM_EDGE]),doW:r([MIDDLE_LEFT,MIDDLE_RIGHT,LEFT_EDGE,RIGHT_EDGE]),doH:r([TOP_CENTER,BOTTOM_CENTER,BOTTOM_EDGE,TOP_EDGE])}}},{key:"_restrictHandler",value:function(e,t){for(var r=null,a=null,o=this.getBoundingRect(e,t),n=this._getRestrictedBBox(),i=_slicedToArray(getMinMaxOfArray(n),2),s=_slicedToArray(i[0],2),l=s[0],c=s[1],u=_slicedToArray(i[1],2),d=u[0],f=u[1],h=0,_=o.length;h<_;h++){var T=_slicedToArray(o[h],2),p=T[0],y=T[1];(pc)&&(r=p),(yf)&&(a=y)}return{x:r,y:a}}},{key:"_destroy",value:function(){var e=this,t=this.elements,r=this.storage,a=(r=void 0===r?{}:r).controls,o=r.wrapper;[].concat(_toConsumableArray(t),[a]).map((function(t){return helper(t).off(E_MOUSEDOWN$1,e._onMouseDown).off(E_TOUCHSTART$1,e._onTouchStart)})),o.parentNode.removeChild(o)}},{key:"_updateStorage",value:function(){var e=this.storage,t=this.storage,r=t.transformOrigin,a=t.transform,o=(a=void 0===a?{}:a).controlsMatrix,n=t.cached,i=(n=void 0===n?{}:n).transformOrigin,s=void 0===i?r:i,l=n.controlsMatrix,c=void 0===l?o:l;this.storage=_objectSpread2({},e,{doResize:!1,doDrag:!1,doRotate:!1,doSetCenter:!1,doDraw:!1,onExecution:!1,cursor:null,transformOrigin:s,controlsMatrix:c,cached:{}})}},{key:"notifyMove",value:function(e){var t=this,a=e.dx,o=e.dy;this.elements.map((function(e){return _get(_getPrototypeOf(r.prototype),"_drag",t).call(t,{element:e,dx:a,dy:o})})),this._processControlsMove({dx:a,dy:o})}},{key:"notifyRotate",value:function(e){var t=this,r=e.radians,a=_objectWithoutProperties(e,["radians"]),o=this.elements,n=this.options,i=(n=void 0===n?{}:n).snap.angle;o.map((function(e){return t._rotate(_objectSpread2({element:e,radians:snapToGrid(r,i)},a))})),this._processControlsRotate({radians:r})}},{key:"notifyResize",value:function(e){var t=this,r=e.dx,a=e.dy,o=e.revX,n=e.revY,i=e.dox,s=e.doy,l=this.elements,c=this.storage.data,u=this.options.isGrouped;l.map((function(e){var l=c.get(e).transform.ctm,d=u?{x:r,y:a}:t._pointToTransform({x:r,y:a,matrix:l}),f=d.x,h=d.y;t._resize({element:e,dx:i?o?-f:f:0,dy:s?n?-h:h:0})})),this._processControlsResize({dx:r,dy:a})}},{key:"notifyApply",value:function(e){var t=this,a=e.clientX,o=e.clientY,n=e.actionName,i=e.triggerEvent;this.proxyMethods.onDrop.call(this,{clientX:a,clientY:o}),i&&(this.elements.map((function(e){return t._applyTransformToElement(e,n)})),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,"".concat(n,"End"),{clientX:a,clientY:o}))}},{key:"notifyGetState",value:function(e){var t=this,a=e.clientX,o=e.clientY,n=e.actionName,i=e.triggerEvent,s=_objectWithoutProperties(e,["clientX","clientY","actionName","triggerEvent"]);if(i){var l=this.elements,c=this.storage.data;l.map((function(e){var r=t._getElementState(e,s);c.set(e,_objectSpread2({},c.get(e),{},r))}));var u=this._getCommonState();this.storage=_objectSpread2({},this.storage,{},u),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,"".concat(n,"Start"),{clientX:a,clientY:o})}}},{key:"subscribe",value:function(e){var t=e.resize,r=e.move,a=e.rotate,o=this.observable;(r||t||a)&&o.subscribe(ON_GETSTATE$2,this).subscribe(ON_APPLY$2,this),r&&o.subscribe(ON_MOVE$2,this),t&&o.subscribe(ON_RESIZE$2,this),a&&o.subscribe(ON_ROTATE$2,this)}},{key:"unsubscribe",value:function(){var e=this,t=this.observable;NOTIFIER_EVENTS$1.map((function(r){return t.unsubscribe(r,e)}))}},{key:"disable",value:function(){var e=this.storage,t=this.proxyMethods,r=this.elements;isUndef(e)||(e.onExecution&&helper(document).off(E_MOUSEMOVE$2,this._onMouseMove).off(E_MOUSEUP$2,this._onMouseUp).off(E_TOUCHMOVE$2,this._onTouchMove).off(E_TOUCHEND$2,this._onTouchEnd),r.map((function(e){return removeClass(e,"".concat(LIB_CLASS_PREFIX,"drag"))})),this.unsubscribe(),this._destroy(),t.onDestroy.call(this,r),delete this.storage)}},{key:"exeDrag",value:function(e){var t=this,a=e.dx,o=e.dy,n=this.elements,i=this.options.draggable,s=this.storage,l=this.storage.data;if(i){var c=this._getCommonState();n.map((function(e){var r=t._getElementState(e,{revX:!1,revY:!1,doW:!1,doH:!1});l.set(e,_objectSpread2({},l.get(e),{},r))})),this.storage=_objectSpread2({},s,{},c),n.map((function(e){_get(_getPrototypeOf(r.prototype),"_drag",t).call(t,{element:e,dx:a,dy:o}),t._applyTransformToElement(e,E_DRAG$2)})),this._processControlsMove({dx:a,dy:o})}}},{key:"exeResize",value:function(e){var t=this,r=e.dx,a=e.dy,o=e.revX,n=void 0!==o&&o,i=e.revY,s=void 0!==i&&i,l=e.doW,c=void 0!==l&&l,u=e.doH,d=void 0!==u&&u,f=this.elements,h=this.options.resizable,_=this.storage,T=this.storage.data;if(h){var p=this._getCommonState();f.map((function(e){var r=t._getElementState(e,{revX:n,revY:s,doW:c,doH:d});T.set(e,_objectSpread2({},T.get(e),{},r))})),this.storage=_objectSpread2({},_,{},p),f.map((function(e){t._resize({element:e,dx:r,dy:a}),t._applyTransformToElement(e,E_RESIZE$1)})),this._processControlsMove({dx:r,dy:a})}}},{key:"exeRotate",value:function(e){var t=this,r=e.delta,a=this.elements,o=this.options.rotatable,n=this.storage,i=this.storage.data;if(o){var s=this._getCommonState();a.map((function(e){var r=t._getElementState(e,{revX:!1,revY:!1,doW:!1,doH:!1});i.set(e,_objectSpread2({},i.get(e),{},r))})),this.storage=_objectSpread2({},n,{},s),a.map((function(e){t._rotate({element:e,radians:r}),t._applyTransformToElement(e,E_ROTATE$1)})),this._processControlsRotate({radians:r})}}},{key:"setCenterPoint",value:function(){throw Error("'setCenterPoint()' method not implemented")}},{key:"resetCenterPoint",value:function(){warn('"resetCenterPoint" method is replaced by "resetTransformOrigin" and would be removed soon'),this.setTransformOrigin({dx:0,dy:0},!1)}},{key:"setTransformOrigin",value:function(){throw Error("'setTransformOrigin()' method not implemented")}},{key:"resetTransformOrigin",value:function(){this.setTransformOrigin({dx:0,dy:0},!1)}},{key:"controls",get:function(){return this.storage.wrapper}}]),r}(),cloneMatrix=function(e){return e.map((function(e){return _toConsumableArray(e)}))},flatMatrix=function(e){return e.reduce((function(t,r,a){return[].concat(_toConsumableArray(t),[e[0][a],e[1][a],e[2][a],e[3][a]])}),[])},createIdentityMatrix=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;return _toConsumableArray(Array(e)).map((function(e,t,r){return r.map((function(){return+!t--}))}))},createTranslateMatrix=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return createIdentityMatrix().map((function(a,o){return a[3]=[e,t,r,1][o],a}))},createScaleMatrix=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return createIdentityMatrix().map((function(o,n){return o[n]=[e,t,r,a][n],o}))},createRotateMatrix=function(e,t){var r=createIdentityMatrix();return r[0][0]=t,r[0][1]=-e,r[1][0]=e,r[1][1]=t,r},dropTranslate=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t?cloneMatrix(e):e;return r[0][3]=r[1][3]=r[2][3]=0,r},multiplyMatrixAndPoint=function(e,t){for(var r=[],a=0,o=e.length;a0;f--)for(var h=f-1;h>=0;h--){t=r[h][f];for(var _=0;_1&&void 0!==arguments[1]?arguments[1]:document.body,r=arguments.length>2?arguments[2]:void 0,a=createIdentityMatrix(),o=e,n=r||getTransform(o),i=!1;o&&o instanceof Element;){var s=getTransformOrigin(o,i);if(a=multiplyMatrix(a,computeTransformMatrix(n,s)),i=!0,o===t||null===o.offsetParent)break;o=o.offsetParent,n=getTransform(o)}return a},decompose=function(e){var t=Math.sqrt(e[0][0]*e[0][0]+e[1][0]*e[1][0]+e[2][0]*e[2][0]),r=Math.sqrt(e[0][1]*e[0][1]+e[1][1]*e[1][1]+e[2][1]*e[2][1]),a=Math.sqrt(e[0][2]*e[0][2]+e[1][2]*e[1][2]+e[2][2]*e[2][2]),o=Math.atan2(-e[0][3]/a,e[1][3]/a),n=Math.asin(e[3][1]/a),i=Math.atan2(-e[3][0]/r,e[0][0]/t);return 1!==e[0][1]&&-1!==e[0][1]||(o=0,n=e[0][1]*-Math.PI/2,i=e[0][1]*Math.atan2(e[1][1]/r,e[0][1]/r)),{rotate:{x:o,y:n,z:i},translate:{x:e[0][3]/t,y:e[1][3]/r,z:e[2][3]/a},scale:{sX:t,sY:r,sZ:a}}},getTransform=function(e){var t=getStyle(e,"transform")||"none",r=createIdentityMatrix();if("none"===t)return r;var a=t.split(/\s*[(),]\s*/).slice(1,-1);if(16!==a.length)return[[+a[0],+a[2],0,+a[4]],[+a[1],+a[3],0,+a[5]],[0,0,1,0],[0,0,0,1]];for(var o=0;o<4;++o)for(var n=0;n<4;++n)r[n][o]=+a[4*o+n];return r},getTransformOrigin=function(e,t){for(var r=getStyle(e,"transform-origin"),a=r?r.split(" "):[],o=[t?-e.clientLeft:0,t?-e.clientTop:0,0,1],n=0;n1&&void 0!==arguments[1]?arguments[1]:document.body,r=0,a=0,o=e,n=!1;o&&o.offsetParent;){var i=getCurrentTransformMatrix(o.offsetParent),s=multiplyMatrixAndPoint(dropTranslate(i,!1),[o.offsetLeft+(n?o.clientLeft:0),o.offsetTop+(n?o.clientTop:0),0,1]),l=_slicedToArray(s,2),c=l[0],u=l[1];if(a+=c,r+=u,t===o)break;n=!0,o=o.offsetParent}return[a,r,0,1]},E_MOUSEDOWN$2=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$2=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,keys$1=Object.keys,entries=Object.entries,values$1=Object.values,Draggable=function(e){_inherits(r,Transformable);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"_init",value:function(e){var t=this,r=this.options,a=r.transformOrigin,o=r.container,n=r.controlsContainer,i=r.resizable,s=r.rotatable,l=r.showNormal,c=r.restrict,u=createElement(["sjx-wrapper"]),d=createElement(["sjx-controls"]),f={},h=this._getVertices(),_=h.rotator,T=void 0===_?null:_,p=h.anchor,y=void 0===p?null:p,v=_objectWithoutProperties(h,["rotator","anchor"]),E={};if(s){var m=l?renderLine([[y.x,y.y],T],"normal"):null;l&&d.appendChild(m);var x=null;a&&(x=renderLine([v.center,v.center],"radius"),addClass(x,"sjx-hidden"),d.appendChild(x)),E=_objectSpread2({},E,{normal:m,radius:x})}var g={te:[v.tl,v.tr],be:[v.bl,v.br],le:[v.tl,v.bl],re:[v.tr,v.br]},b=i?{tl:v.tl,tr:v.tr,br:v.br,bl:v.bl,tc:v.tc,bc:v.bc,ml:v.ml,mr:v.mr}:{},S=Array.isArray(a)?[].concat(_toConsumableArray(a),[0,1]):v.center,M=_objectSpread2({},b,{center:a&&s?S:void 0,rotator:T}),O=function(e,t){return keys$1(e).map((function(r){var a=e[r];if(!isUndef(a)){var o=t(a,r);f[r]=o,d.appendChild(o)}}))};O(g,renderLine),O(M,createHandler),u.appendChild(d),n.appendChild(u);var A=new WeakMap;e.map((function(e){return A.set(e,{parent:e.parentNode,transform:{ctm:getCurrentTransformMatrix(e,o)},bBox:t._getBBox(),__data__:new WeakMap,cached:{}})}));var N=c||o;this.storage={wrapper:u,controls:d,handles:_objectSpread2({},f,{},E),data:A,center:{isShifted:Array.isArray(a)},transformOrigin:S,transform:{containerMatrix:getCurrentTransformMatrix(N,N.parentNode)},cached:{}},[].concat(_toConsumableArray(e),[d]).map((function(e){return helper(e).on(E_MOUSEDOWN$2,t._onMouseDown).on(E_TOUCHSTART$2,t._onTouchStart)}))}},{key:"_pointToTransform",value:function(e){var t=e.x,r=e.y,a=e.matrix,o=matrixInvert(a);return this._applyMatrixToPoint(dropTranslate(o,!1),t,r)}},{key:"_pointToControls",value:function(e){var t=e.x,r=e.y,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.storage.transform,o=a.controlsMatrix,n=matrixInvert(o);return this._applyMatrixToPoint(dropTranslate(n,!1),t,r)}},{key:"_applyMatrixToPoint",value:function(e,t,r){var a=_slicedToArray(multiplyMatrixAndPoint(e,[t,r,0,1]),2);return{x:a[0],y:a[1]}}},{key:"_cursorPoint",value:function(e){var t=e.clientX,r=e.clientY,a=this.options.container,o=getCurrentTransformMatrix(a),n=getElementOffset(a),i=getScrollOffset(),s=i.left,l=i.top,c=createTranslateMatrix(n.left-s,n.top-l);return this._applyMatrixToPoint(matrixInvert(multiplyMatrix(o,c)),t,r)}},{key:"_getRestrictedBBox",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.storage.transform.containerMatrix,r=this.options,a=r.restrict,o=r.container,n=a||o;return _getBoundingRect(n,o,e?getCurrentTransformMatrix(n,o):t)}},{key:"_applyTransformToElement",value:function(e){var t=this.storage,r=t.controls,a=t.data,o=this.options.applyTranslate,n=a.get(e),i=n.cached,s=n.transform.matrix,l=helper(r);if(!isUndef(i)&&o){var c=helper(e),u=i.dx,d=i.dy,f=matrixToCSS(s),h=parseFloat(e.style.left||c.css("left")),_=parseFloat(e.style.top||c.css("top"));f.left="".concat(h+u,"px"),f.top="".concat(_+d,"px"),c.css(f),l.css(f)}}},{key:"_processActions",value:function(){}},{key:"_processResize",value:function(e,t){var r,a,o,n,i,s,l=t.dx,c=t.dy,u=this.storage,d=u.revX,f=u.revY,h=u.doW,_=u.doH,T=u.data,p=u.bBox,y=p.width,v=p.height,E=this.options,m=E.proportions,x=E.scalable,g=T.get(e),b=g.transform,S=b.matrix,M=b.auxiliary.scale.translateMatrix,O=g.cached,A=_slicedToArray(function(e,t){var r=h||!h&&!_?(y+e)/y:(v+t)/v,a=m?y*r:y+e,o=m?v*r:v+t;return[a/y,o/v,a,o]}(l,c),4),N=A[0],R=A[1],C=A[2],k=A[3],I=function(e,t){var r=createScaleMatrix(e,t);return multiplyMatrix(multiplyMatrix(M,r),matrixInvert(M))}(N,R),D=x?multiplyMatrix(I,S):(a=S,o=(r=I)[0][3],n=r[1][3],i=createTranslateMatrix(o,n),s=createTranslateMatrix(o*(d?-1:1),n*(f?-1:1)),multiplyMatrix(multiplyMatrix(s,a),matrixInvert(i)));return C<=MIN_SIZE||k<=MIN_SIZE?{transform:D,width:C,height:k}:(this._updateElementView(e,_objectSpread2({},matrixToCSS(flatMatrix(D)),{},!x&&{width:"".concat(C,"px"),height:"".concat(k,"px")})),T.set(e,_objectSpread2({},g,{cached:_objectSpread2({},O,{dx:l,dy:c,bBox:{width:C,height:k}})})),{transform:D,width:C,height:k})}},{key:"_processMove",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data,n=o.get(e),i=n.transform,s=i.matrix,l=i.auxiliary.translate.parentMatrix,c=n.cached,u=void 0===c?{}:c,d=_slicedToArray(multiplyMatrixAndPoint(l,[r,a,0,1]),2),f=d[0],h=d[1],_=multiplyMatrix(s,createTranslateMatrix(f,h)),T=matrixToCSS(flatMatrix(_));return this._updateElementView(e,T),o.set(e,_objectSpread2({},n,{cached:_objectSpread2({},u,{dist:{dx:floatToFixed(r),dy:floatToFixed(a),ox:floatToFixed(f),oy:floatToFixed(h)}})})),_}},{key:"_processRotate",value:function(e,t){var r=this.storage.data,a=this.options.restrict,o=r.get(e).transform,n=o.matrix,i=o.auxiliary.rotate.translateMatrix,s=floatToFixed(Math.cos(t),4),l=floatToFixed(Math.sin(t),4),c=createRotateMatrix(l,s),u=multiplyMatrix(multiplyMatrix(matrixInvert(i),c),i),d=multiplyMatrix(n,u),f=a?this._restrictHandler(d):{x:null,y:null},h=f.x,_=f.y;return isDef(h)||isDef(_)?d:(this._updateElementView(e,matrixToCSS(flatMatrix(d))),d)}},{key:"_getElementState",value:function(e,t){var r=t.revX,a=t.revY,o=t.doW,n=t.doH,i=this.storage,s=i.handles.center,l=i.data,c=i.transformOrigin,u=this.options,d=u.container,f=u.scalable,h=l.get(e).parent,_=_slicedToArray(getAbsoluteOffset(e,d),2),T=_[0],p=_[1],y=e.offsetLeft,v=e.offsetTop,E=e.offsetWidth,m=e.offsetHeight,x=getTransform(e),g=getCurrentTransformMatrix(e,d),b=getCurrentTransformMatrix(h,d),S=E/2,M=m/2,O=_slicedToArray(multiplyMatrixAndPoint(g,[S,M,0,1]),2),A=n?0:r?-S:S,N=o?0:a?-M:M,R=O[0]+T,C=O[1]+p,k=s?getTransform(s):createIdentityMatrix(),I=_slicedToArray(multiplyMatrixAndPoint(multiplyMatrix(matrixInvert(dropTranslate(g)),dropTranslate(k)),[c[0]-R,c[1]-C,0,1]),2),D=I[0],P=I[1],w=_slicedToArray(multiplyMatrixAndPoint(x,[D,P,0,1]),2),V=w[0],$=w[1],G=decompose(getCurrentTransformMatrix(e,e.parentNode)).scale,L=G.sX,j=G.sY;return{transform:{auxiliary:{scale:{translateMatrix:f?createTranslateMatrix(A,N):createTranslateMatrix(n?0:S,o?0:M)},translate:{parentMatrix:matrixInvert(dropTranslate(b))},rotate:{translateMatrix:createTranslateMatrix(V,$)}},scaleX:A,scaleY:N,matrix:x,ctm:g,parentMatrix:b,scX:L,scY:j},bBox:{width:E,height:m,left:y,top:v,offset:{left:T,top:p}}}}},{key:"_getCommonState",value:function(){var e=this.elements,t=this.storage,r=t.controls,a=t.handles.center,o=t.center,n=t.wrapper,i=this.options,s=i.container,l=i.restrict,c=_slicedToArray(getAbsoluteOffset(e[0],s),2),u=c[0],d=c[1],f=getCurrentTransformMatrix(e[0],s),h=l||s,_=getCurrentTransformMatrix(h,h.parentNode),T=this._getBBox(),p=T.width,y=T.height,v=_slicedToArray(multiplyMatrixAndPoint(f,[p/2,y/2,0,1]),2),E=v[0]+u,m=v[1]+d,x=a?getTransform(a):createIdentityMatrix();return{transform:{controlsMatrix:getCurrentTransformMatrix(r,r.parentNode),containerMatrix:_,wrapperMatrix:getCurrentTransformMatrix(n,s)},bBox:_objectSpread2({},this._getBBox()),center:_objectSpread2({},o,{x:E,y:m,matrix:x})}}},{key:"_getBBox",value:function(){var e=_slicedToArray(this.elements,1)[0],t=this.options,r=t.isGrouped,a=t.container;if(r)return this._getGroupBbox();var o=_slicedToArray(getAbsoluteOffset(e,a),2),n=o[0],i=o[1];return{x:e.offsetLeft,y:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight,offset:{left:n,top:i}}}},{key:"_processControlsResize",value:function(){var e=this._applyTransformToHandles().center,t=this.storage.transform.controlsMatrix;e&&(this.storage=_objectSpread2({},this.storage,{cached:{transformOrigin:multiplyMatrixAndPoint(t,e)}}))}},{key:"_processControlsMove",value:function(e){var t=e.dx,r=e.dy,a=this.storage,o=a.transform,n=o.controlsMatrix,i=o.wrapperMatrix,s=a.center,l=a.transformOrigin,c=multiplyMatrix(n,createTranslateMatrix(t,r));this._updateControlsView(c);var u=dropTranslate(matrixInvert(i)),d=_slicedToArray(multiplyMatrixAndPoint(u,[t,r,0,1]),2),f=d[0],h=d[1];if(s.isShifted)this._moveCenterHandle(-f,-h,!1);else{var _=createTranslateMatrix(f,h);this.storage=_objectSpread2({},this.storage,{cached:{transformOrigin:multiplyMatrixAndPoint(_,l)}})}}},{key:"_processControlsRotate",value:function(){this._applyTransformToHandles()}},{key:"_moveCenterHandle",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.storage,o=a.handles.center,n=a.center.matrix,i=a.center,s=a.transformOrigin,l=createTranslateMatrix(e,t),c=multiplyMatrix(n,l);helper(o).css(_objectSpread2({},matrixToCSS(flatMatrix(c)))),this.storage=_objectSpread2({},this.storage,{center:_objectSpread2({},i,{isShifted:!0})},r?{cached:{transformOrigin:multiplyMatrixAndPoint(l,s)}}:{})}},{key:"_processMoveRestrict",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data.get(e).transform,n=o.matrix,i=o.auxiliary.translate.parentMatrix,s=_slicedToArray(multiplyMatrixAndPoint(i,[r,a,0,1]),2),l=s[0],c=s[1],u=multiplyMatrix(n,createTranslateMatrix(l,c));return this._restrictHandler(u)}},{key:"_processRotateRestrict",value:function(e,t){var r=this.storage.data.get(e).transform,a=r.matrix,o=r.auxiliary.rotate.translateMatrix,n=floatToFixed(Math.cos(t),4),i=floatToFixed(Math.sin(t),4),s=createRotateMatrix(i,n),l=multiplyMatrix(multiplyMatrix(matrixInvert(o),s),o),c=multiplyMatrix(a,l);return this._restrictHandler(c)}},{key:"_processResizeRestrict",value:function(e,t){var r,a,o,n,i,s,l,c,u,d,f,h,_=t.dx,T=t.dy,p=this.storage,y=p.revX,v=p.revY,E=p.doW,m=p.doH,x=p.data,g=p.bBox,b=g.width,S=g.height,M=this.options,O=M.proportions,A=M.scalable,N=x.get(e).transform,R=N.matrix,C=N.auxiliary.scale.translateMatrix,k=_slicedToArray((r=_,a=T,o=E||!E&&!m?(b+r)/b:(S+a)/S,[(n=O?b*o:b+r)/b,(i=O?S*o:S+a)/S,n,i]),2),I=k[0],D=k[1],P=(s=createScaleMatrix(I,D),multiplyMatrix(multiplyMatrix(C,s),matrixInvert(C))),w=A?multiplyMatrix(P,R):(c=R,u=(l=P)[0][3],d=l[1][3],f=createTranslateMatrix(u,d),h=createTranslateMatrix(u*(y?-1:1),d*(v?-1:1)),multiplyMatrix(multiplyMatrix(h,c),matrixInvert(f)));return this._restrictHandler(w)}},{key:"_updateElementView",value:function(e,t){helper(e).css(t)}},{key:"_updateControlsView",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createIdentityMatrix(),t=matrixToCSS(flatMatrix(e));helper(this.storage.controls).css(t),this.storage.cached.controlsMatrix=e}},{key:"_getVertices",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createIdentityMatrix(),t=this.elements,r=_slicedToArray(t=void 0===t?[]:t,1),a=r[0],o=this.options,n=o.isGrouped,i=o.rotatable,s=o.rotatorAnchor,l=o.rotatorOffset,c=n?this._getGroupVertices():this._getElementVertices(a,e),u=null;if(i){var d={},f=1;switch(s){case"n":d.x=c.tc[0],d.y=c.tc[1];break;case"s":d.x=c.bc[0],d.y=c.bc[1],f=-1;break;case"w":d.x=c.ml[0],d.y=c.ml[1],f=-1;break;case"e":default:d.x=c.mr[0],d.y=c.mr[1]}var h="n"===s||"s"===s?Math.atan2(c.bl[1]-c.tl[1],c.bl[0]-c.tl[0]):Math.atan2(c.tl[1]-c.tr[1],c.tl[0]-c.tr[0]);u=[d.x-l*f*Math.cos(h),d.y-l*f*Math.sin(h)],c.rotator=u,c.anchor=d}return c}},{key:"_getElementVertices",value:function(e,t){var r=this.options,a=r.container,o=r.isGrouped,n=_slicedToArray(getAbsoluteOffset(e,a),2),i=n[0],s=n[1],l=e.offsetWidth,c=e.offsetHeight,u={tl:[0,0,0,1],bl:[0,c,0,1],br:[l,c,0,1],tr:[l,0,0,1],tc:[l/2,0,0,1],ml:[0,c/2,0,1],bc:[l/2,c,0,1],mr:[l,c/2,0,1],center:[l/2,c/2,0,1]},d=o?t:multiplyMatrix(getCurrentTransformMatrix(e,a),t);return entries(u).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=r[1];return[].concat(_toConsumableArray(e),[[a,multiplyMatrixAndPoint(d,o)]])}),[]).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=_slicedToArray(r[1],4),n=o[0],l=o[1],c=o[2],u=o[3];return e[a]=[n+i,l+s,c,u],e}),{})}},{key:"_getGroupVertices",value:function(){var e=this._getGroupBbox(),t=e.x,r=e.y,a=e.width,o=e.height,n=a/2,i=o/2;return{tl:[t,r],tr:[t+a,r],mr:[t+a,r+i],ml:[t,r+i],tc:[t+n,r],bc:[t+n,r+o],br:[t+a,r+o],bl:[t,r+o],center:[t+n,r+i]}}},{key:"_getGroupBbox",value:function(){var e=this.elements,t=this.options.container,r=e.reduce((function(e,r){var a=_slicedToArray(getAbsoluteOffset(r,t),2),o=a[0],n=a[1],i=r.offsetWidth,s=r.offsetHeight,l=[[0,0,0,1],[0,s,0,1],[i,s,0,1],[i,0,0,1]],c=getCurrentTransformMatrix(r,t),u=l.reduce((function(e,t){return[].concat(_toConsumableArray(e),[multiplyMatrixAndPoint(c,t)])}),[]).map((function(e){var t=_slicedToArray(e,4),r=t[0],a=t[1],i=t[2],s=t[3];return[r+o,a+n,i,s]}));return[].concat(_toConsumableArray(e),[u])}),[]),a=_slicedToArray(getMinMaxOfArray(r.reduce((function(e,t){return[].concat(_toConsumableArray(e),_toConsumableArray(t))}),[])),2),o=_slicedToArray(a[0],2),n=o[0],i=o[1],s=_slicedToArray(a[1],2),l=s[0];return{x:n,y:l,width:i-n,height:s[1]-l}}},{key:"_getElementBBox",value:function(e){var t=this.options.container,r=_slicedToArray(getAbsoluteOffset(e,t),2),a=r[0],o=r[1],n=e.offsetWidth,i=e.offsetHeight,s=[[0,0,0,1],[0,i,0,1],[n,i,0,1],[n,0,0,1]],l=getCurrentTransformMatrix(e,t),c=s.reduce((function(e,t){return[].concat(_toConsumableArray(e),[multiplyMatrixAndPoint(l,t)])}),[]).map((function(e){var t=_slicedToArray(e,4),r=t[0],n=t[1],i=t[2],s=t[3];return[r+a,n+o,i,s]})),u=_slicedToArray(getMinMaxOfArray(c),2),d=_slicedToArray(u[0],2),f=d[0],h=d[1],_=_slicedToArray(u[1],2),T=_[0];return{x:f,y:T,width:h-f,height:_[1]-T}}},{key:"_applyTransformToHandles",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.boxMatrix,r=void 0===t?createIdentityMatrix():t,a=this.options,o=a.rotatable,n=a.resizable,i=a.showNormal,s=this.storage,l=s.handles,c=s.controls,u=s.center,d=(u=void 0===u?{}:u).isShifted,f=void 0!==d&&d,h=s.transform,_=(h=void 0===h?{}:h).controlsMatrix,T=void 0===_?getCurrentTransformMatrix(c,c.parentNode):_,p=multiplyMatrix(r,matrixInvert(T)),y=this._getVertices(p),v=y.anchor,E=void 0===v?null:v,m=y.center,x=_objectWithoutProperties(y,["anchor","center"]),g=null,b={};o&&(g=i?[[E.x,E.y],x.rotator]:null,b={rotator:x.rotator});var S=_objectSpread2({te:[x.tl,x.tr],be:[x.bl,x.br],le:[x.tl,x.bl],re:[x.tr,x.br]},i&&g&&{normal:g});keys$1(S).forEach((function(e){var t=_slicedToArray(S[e],2),r=t[0],a=t[1],o=getLineAttrs(r,a),n=o.cx,i=o.cy,s=o.length,c=o.theta;helper(l[e]).css({transform:"translate(".concat(n,"px, ").concat(i,"px) rotate(").concat(c,"deg)"),width:"".concat(s,"px")})}));var M=_objectSpread2({},n&&x,{},b,{},!f&&Boolean(m)&&{center:m});return keys$1(M).reduce((function(e,t){var r=l[t],a=M[t];if(e[t]=a,isUndef(a)||isUndef(r))return e;var o=_slicedToArray(a,2),n=o[0],i=o[1];return helper(r).css({transform:"translate(".concat(n,"px, ").concat(i,"px)")}),e}),{})}},{key:"setCenterPoint",value:function(){warn('"setCenterPoint" method is replaced by "setTransformOrigin" and would be removed soon'),this.setTransformOrigin.apply(this,arguments)}},{key:"setTransformOrigin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.x,r=e.y,a=e.dx,o=e.dy,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.elements,s=_slicedToArray(i=void 0===i?[]:i,1),l=s[0],c=this.storage,u=this.storage,d=(u=void 0===u?{}:u).wrapper,f=u.handles.center,h=u.center,_=this.options,T=(_=void 0===_?{}:_).container,p=isDef(a)&&isDef(o),y=isDef(t)&&isDef(r);if(f&&h&&(p||y)){var v,E,m=multiplyMatrix(getCurrentTransformMatrix(l,T),matrixInvert(getCurrentTransformMatrix(d,d.parentNode))),x=getAbsoluteOffset(l,T),g=_slicedToArray(x,2),b=g[0],S=g[1];if(p){var M=l.offsetHeight,O=l.offsetWidth,A=O/2-a,N=M/2-o,R=multiplyMatrixAndPoint(m,[A,N,0,1]),C=_slicedToArray(R,2);v=C[0],E=C[1]}else v=t,E=r;helper(f).css({transform:"translate(".concat(v+b,"px, ").concat(E+S,"px)")}),h.isShifted=n,c.transformOrigin=multiplyMatrixAndPoint(createIdentityMatrix(),[v,E,0,1])}}},{key:"fitControlsToSize",value:function(){var e=this.storage,t=e.controls,r=e.center,a=(r=void 0===r?{}:r).isShifted,o=_slicedToArray(e.transformOrigin,2),n=o[0],i=o[1],s=getCurrentTransformMatrix(t,t.parentNode),l=_slicedToArray(multiplyMatrixAndPoint(s,[n,i,0,1]),2),c=l[0],u=l[1],d=[{nextValues:function(){return{x:c,y:u}},pin:!0,condition:function(){return a}},{nextValues:function(){return{dx:0,dy:0}},pin:!1,condition:function(){return!a}}].find((function(e){return(0,e.condition)()})),f=d.nextValues,h=d.pin;this._updateControlsView(),this.setTransformOrigin(_objectSpread2({},f()),h),this._applyTransformToHandles()}},{key:"getBoundingRect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this.elements,r=_slicedToArray(t=void 0===t?[]:t,1),a=r[0],o=this.options,n=o.scalable,i=o.restrict,s=o.container,l=this.storage,c=l.bBox,u=l.bBox,d=(u=void 0===u?{}:u).width,f=u.height,h=l.cached,_=(h=void 0===h?{}:h).bBox,T=(_=void 0===_?{}:_).width,p=void 0===T?d:T,y=_.height,v=void 0===y?f:y,E=n?c:_objectSpread2({},c,{width:p,height:v}),m=i||s;return _getBoundingRect(a,m,getCurrentTransformMatrix(a,m,e),E)}},{key:"applyAlignment",value:function(e){var t=this,r=this.elements,a=this.options.container,o=this._getVertices(),n=(o.anchor,o.rotator,o.center,_objectWithoutProperties(o,["anchor","rotator","center"])),i=this._getRestrictedBBox(!0),s=values$1(n),l=_slicedToArray(getMinMaxOfArray(i),2),c=_slicedToArray(l[0],2),u=c[0],d=c[1],f=_slicedToArray(l[1],2),h=f[0],_=f[1],T=_slicedToArray(getMinMaxOfArray(s),2),p=_slicedToArray(T[0],2),y=p[0],v=p[1],E=_slicedToArray(T[1],2),m=E[0],x=E[1],g=_slicedToArray(multiplyMatrixAndPoint(matrixInvert(dropTranslate(getCurrentTransformMatrix(r[0].parentNode,a))),[function(){switch(!0){case/[l]/.test(e):return u-y;case/[r]/.test(e):return d-v;case/[h]/.test(e):return(d+u)/2-(v+y)/2;default:return 0}}(),function(){switch(!0){case/[t]/.test(e):return h-m;case/[b]/.test(e):return _-x;case/[v]/.test(e):return(_+h)/2-(x+m)/2;default:return 0}}(),0,1]),2),b=g[0],S=g[1],M=multiplyMatrix(getTransform(r[0]),createTranslateMatrix(b,S));r.map((function(e){return t._updateElementView(e,matrixToCSS(flatMatrix(M)))})),this.fitControlsToSize()}},{key:"getDimensions",value:function(){var e=this.elements,t=_slicedToArray(e=void 0===e?[]:e,1)[0],r=this.options.isGrouped?this._getGroupVertices():this._getElementVertices(t,createIdentityMatrix()),a=r.tl,o=r.tr,n=r.br;return{x:floatToFixed(a[0]),y:floatToFixed(a[1]),width:floatToFixed(Math.sqrt(Math.pow(a[0]-o[0],2)+Math.pow(a[1]-o[1],2))),height:floatToFixed(Math.sqrt(Math.pow(o[0]-n[0],2)+Math.pow(o[1]-n[1],2))),rotation:floatToFixed(Math.atan2(o[1]-a[1],o[0]-a[0])*DEG)}}}]),r}(),createHandler=function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"handler",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=createElement(["sjx-hdl","sjx-hdl-".concat(o)]);return helper(i).css(_objectSpread2({transform:"translate(".concat(r,"px, ").concat(a,"px)")},n)),i},renderLine=function(e,t){var r=_slicedToArray(e,3),a=r[0],o=r[1],n=r[2],i=void 0===n?1:n,s=getLineAttrs(a,o,i),l=s.cx,c=s.cy,u=s.length,d=s.theta,f=createElement(["sjx-hdl-line","sjx-hdl-".concat(t)]);return helper(f).css({transform:"translate(".concat(l,"px, ").concat(c,"px) rotate(").concat(d,"deg)"),height:"".concat(i,"px"),width:"".concat(u,"px")}),f},getLineAttrs=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=_slicedToArray(e,2),o=a[0],n=a[1],i=_slicedToArray(t,2),s=i[0],l=i[1],c=Math.sqrt((s-o)*(s-o)+(l-n)*(l-n)),u=(o+s)/2-c/2,d=(n+l)/2-r/2,f=Math.atan2(n-l,o-s)*(180/Math.PI);return{cx:u,cy:d,thickness:r,theta:f,length:c}},_getBoundingRect=function(e,t,r,a){var o=_slicedToArray(getAbsoluteOffset(e,t),2),n=o[0],i=o[1],s=a||{width:e.offsetWidth,height:e.offsetHeight,offset:{left:n,top:i}},l=s.width,c=s.height,u=s.offset,d=(u=void 0===u?{}:u).left,f=u.top;return[[0,0,0,1],[l,0,0,1],[0,c,0,1],[l,c,0,1]].reduce((function(e,t){return[].concat(_toConsumableArray(e),[multiplyMatrixAndPoint(r,t)])}),[]).map((function(e){var t=_slicedToArray(e,4),r=t[0],a=t[1],o=t[2],n=t[3];return[r+d,a+f,o,n]}))},createElement=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=document.createElement("div");return e.forEach((function(e){return addClass(t,e)})),t},sepRE=/\s*,\s*|\s+/g,allowedElements=["circle","ellipse","image","line","path","polygon","polyline","rect","text","g","foreignobject","use"];function createSVGElement(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=document.createElementNS("http://www.w3.org/2000/svg",e);return t.forEach((function(e){return addClass(r,e)})),r}var createSVGPoint=function(e,t){var r=createSVGElement("svg").createSVGPoint();return r.x=e,r.y=t,r},checkChildElements=function e(t){var r=[];return isSVGGroup(t)?forEach.call(t.childNodes,(function(t){if(1===t.nodeType){var a=t.tagName.toLowerCase();-1!==allowedElements.indexOf(a)&&("g"===a&&r.push.apply(r,_toConsumableArray(e(t))),r.push(t))}})):r.push(t),r},createSVGMatrix=function(){return createSVGElement("svg").createSVGMatrix()},createTranslateMatrix$1=function(e,t){var r=createSVGMatrix();return r.e=e,r.f=t,r},createRotateMatrix$1=function(e,t){var r=createSVGMatrix();return r.a=t,r.b=e,r.c=-e,r.d=t,r},createScaleMatrix$1=function(e,t){var r=createSVGMatrix();return r.a=e,r.d=t,r},getTransformToElement=function(e,t){return(t.getScreenCTM&&t.getScreenCTM()||createSVGMatrix()).inverse().multiply(e.getScreenCTM()||createSVGMatrix())},matrixToString=function(e){var t=e.a,r=e.b,a=e.c,o=e.d,n=e.e,i=e.f;return"matrix(".concat(t,",").concat(r,",").concat(a,",").concat(o,",").concat(n,",").concat(i,")")},pointTo=function(e,t,r){return createSVGPoint(t,r).matrixTransform(e)},cloneMatrix$1=function(e){var t=createSVGMatrix();return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f,t},isIdentity=function(e){var t=e.a,r=e.b,a=e.c,o=e.d,n=e.e,i=e.f;return 1===t&&0===r&&0===a&&1===o&&0===n&&0===i},checkElement=function(e){var t=e.tagName.toLowerCase();return-1!==allowedElements.indexOf(t)||(warn('Selected element "'.concat(t,'" is not allowed to transform. Allowed elements:\n\n circle, ellipse, image, line, path, polygon, polyline, rect, text, g')),!1)},isSVGGroup=function(e){return"g"===e.tagName.toLowerCase()},normalizeString=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.replace(/[\n\r]/g,"").replace(/([^e])-/g,"$1 -").replace(/ +/g," ").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ")},parsePoints=function(e){return normalizeString(e).trim().split(sepRE).reduce((function(e,t,r,a){return r%2==0&&e.push(a.slice(r,r+2)),e}),[])},arrayToChunks=function(e,t){return Array.from(new Array(Math.ceil(e.length/t)),(function(r,a){return e.slice(a*t,a*t+t)}))},dRE=/\s*([achlmqstvz])([^achlmqstvz]*)\s*/gi,getCommandValuesLength=function(e){return[{size:2,condition:["M","m","L","l","T","t"].includes(e)},{size:1,condition:["H","h","V","v"].includes(e)},{size:6,condition:["C","c"].includes(e)},{size:4,condition:["S","s","Q","q"].includes(e)},{size:7,condition:["A","a"].includes(e)},{size:1,condition:!0}].find((function(e){return!!e.condition}))},parsePath=function(e){for(var t=dRE.lastIndex=0,r=[],a=function(){var e=_slicedToArray(t,3),a=e[1],o=e[2],n=a.toUpperCase(),i=a!==n,s=normalizeString(o).trim().split(sepRE).map((function(e){if(!isNaN(e))return Number(e)})),l=!1,c="M"===n,u=getCommandValuesLength(a).size;arrayToChunks(s,u).map((function(e){var t=l&&c;return l=l||c,r.push({relative:i,key:t?"L":n,cmd:t?i?"l":"L":a,values:e})}))};t=dRE.exec(e);)a();return reducePathData(absolutizePathData(r))},movePath=function(e){var t=e.path,r=e.dx,a=e.dy;try{for(var o=parsePath(t),n="",i=" ",s=!0,l=0,c=o.length;l1&&(n*=b=Math.sqrt(b),i*=b);var S=n*n,M=i*i,O=S*M-S*g*g-M*x*x,A=S*g*g+M*x*x,N=(l===c?-1:1)*Math.sqrt(Math.abs(O/A));_=N*n*g/i+(t+a)/2,T=N*-i*x/n+(r+o)/2,f=Math.asin(parseFloat(((r-T)/i).toFixed(9))),h=Math.asin(parseFloat(((o-T)/i).toFixed(9))),t<_&&(f=Math.PI-f),a<_&&(h=Math.PI-h),f<0&&(f=2*Math.PI+f),h<0&&(h=2*Math.PI+h),c&&f>h&&(f-=2*Math.PI),!c&&h>f&&(h-=2*Math.PI)}var R=h-f;if(Math.abs(R)>120*Math.PI/180){var C=h,k=a,I=o,D=c&&h>f?1:-1;h=f+120*Math.PI/180*D,a=_+n*Math.cos(h),o=T+i*Math.sin(h),v=e(a,o,k,I,n,i,s,0,c,[h,C,_,T])}R=h-f;var P=Math.cos(f),w=Math.sin(f),V=Math.cos(h),$=Math.sin(h),G=Math.tan(R/4),L=4/3*n*G,j=4/3*i*G,F=[t,r],H=[t+L*w,r-j*P],U=[a+L*$,o-j*V],B=[a,o];if(H[0]=2*F[0]-H[0],H[1]=2*F[1]-H[1],u)return[H,U,B].concat(_toConsumableArray(v));v=[H,U,B].concat(_toConsumableArray(v)).join().split(",");var Y=[],z=[];return v.forEach((function(e,t){t%2?z.push(p(v[t-1],v[t],y).y):z.push(p(v[t],v[t+1],y).x),6===z.length&&(Y.push(z),z=[])})),Y},E_DRAG$3=EVENT_EMITTER_CONSTANTS.E_DRAG,E_RESIZE$2=EVENT_EMITTER_CONSTANTS.E_RESIZE,E_ROTATE$2=EVENT_EMITTER_CONSTANTS.E_ROTATE,E_MOUSEDOWN$3=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$3=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,keys$2=Object.keys,entries$1=Object.entries,values$2=Object.values,DraggableSVG=function(e){_inherits(r,Transformable);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"_init",value:function(e){var t=this,r=this.options,a=r.container,o=r.controlsContainer,n=r.resizable,i=r.rotatable,s=r.showNormal,l=r.transformOrigin,c=r.restrict,u=createSVGElement("g",["sjx-svg-wrapper"]),d=createSVGElement("g",["sjx-svg-controls"]),f=this._getVertices(),h=f.rotator,_=void 0===h?null:h,T=f.anchor,p=void 0===T?null:T,y=_objectWithoutProperties(f,["rotator","anchor"]),v={},E={},m=Array.isArray(l)?pointTo(createSVGMatrix(),l[0],l[1]):y.center;if(i){var x=s?renderLine$1([p,_],THEME_COLOR,"normal"):null;s&&d.appendChild(x);var g=null;l&&((g=createSVGElement("line",["sjx-hidden"])).x1.baseVal.value=y.center.x,g.y1.baseVal.value=y.center.y,g.x2.baseVal.value=m.x,g.y2.baseVal.value=m.y,setLineStyle(g,"#fe3232"),g.setAttribute("opacity",.5),d.appendChild(g)),E=_objectSpread2({},E,{normal:x,radius:g})}var b=n?{tl:y.tl,tr:y.tr,br:y.br,bl:y.bl,tc:y.tc,bc:y.bc,ml:y.ml,mr:y.mr}:{},S={te:[y.tl,y.tr],be:[y.bl,y.br],le:[y.tl,y.bl],re:[y.tr,y.br]};keys$2(S).forEach((function(e){var t=S[e];isUndef(t)||(v[e]=renderLine$1(t,THEME_COLOR,e),d.appendChild(v[e]))}));var M=_objectSpread2({},b,{rotator:_,center:l&&i?m:void 0});keys$2(M).forEach((function(e){var t=M[e];if(!isUndef(t)){var r=t.x,a=t.y,o="center"===e?"#fe3232":THEME_COLOR;v[e]=createHandler$1(r,a,o,e),d.appendChild(v[e])}})),u.appendChild(d),o.appendChild(u);var O=new WeakMap;e.map((function(e){return O.set(e,{parent:e.parentNode,transform:{ctm:getTransformToElement(e,a)},bBox:e.getBBox(),__data__:new WeakMap,cached:{}})}));var A=c||a;this.storage={wrapper:u,controls:d,handles:_objectSpread2({},v,{},E),data:O,center:{isShifted:Array.isArray(l)},transformOrigin:m,transform:{containerMatrix:getTransformToElement(A,A.parentNode)},cached:{}},[].concat(_toConsumableArray(e),[d]).map((function(e){return helper(e).on(E_MOUSEDOWN$3,t._onMouseDown).on(E_TOUCHSTART$3,t._onTouchStart)}))}},{key:"_cursorPoint",value:function(e){var t=e.clientX,r=e.clientY,a=this.options.container;return this._applyMatrixToPoint(a.getScreenCTM().inverse(),t,r)}},{key:"_getRestrictedBBox",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.storage,r=(t=void 0===t?{}:t).transform,a=(r=void 0===r?{}:r).containerMatrix,o=this.options,n=(o=void 0===o?{}:o).container,i=o.restrict,s=i||n;return _getBoundingRect$1(s,e?getTransformToElement(s,n):a)}},{key:"_pointToTransform",value:function(e){var t=e.x,r=e.y,a=e.matrix.inverse();return a.e=a.f=0,this._applyMatrixToPoint(a,t,r)}},{key:"_pointToControls",value:function(e){var t=e.x,r=e.y,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.storage.transform,o=a.controlsMatrix,n=o.inverse();return n.e=n.f=0,this._applyMatrixToPoint(n,t,r)}},{key:"_applyMatrixToPoint",value:function(e,t,r){var a=createSVGElement("svg").createSVGPoint();return a.x=t,a.y=r,a.matrixTransform(e)}},{key:"_applyTransformToElement",value:function(e,t){var r=this.storage,a=(r=void 0===r?{}:r).data,o=r.bBox,n=this.options,i=(n=void 0===n?{}:n).isGrouped,s=n.scalable,l=n.applyTranslate,c=a.get(e),u=c.cached,d=void 0===u?{}:u,f=_objectWithoutProperties(c,["cached"]),h=f.transform,_=h.matrix,T=h.parentMatrix,p=f.__data__,y=d.scaleX,v=d.scaleY,E=d.dist,m=(E=void 0===E?{}:E).dx,x=E.dy,g=E.ox,b=E.oy,S=d.transformMatrix;if(t===E_DRAG$3){if(!l||!m&&!x)return;var M=createTranslateMatrix$1(g,b),O=M.multiply(_).multiply(M.inverse());this._updateElementView(["transform",O]),isSVGGroup(e)?checkChildElements(e).map((function(e){var t=createTranslateMatrix$1(m,x),r=t.multiply(getTransformToElement(e,e.parentNode)).multiply(t.inverse());if(isIdentity(r)||e.setAttribute("transform",matrixToString(r)),!isSVGGroup(e)){var a=T.inverse();a.e=a.f=0;var o=pointTo(a,g,b),n=o.x,i=o.y;applyTranslate(e,{x:n,y:i})}})):applyTranslate(e,{x:g,y:b})}if(t===E_RESIZE$2){if(!S)return;if(!s)if(isSVGGroup(e)||i)checkChildElements(e).forEach((function(t){if(!isSVGGroup(t)){var r=getTransformToElement(t,i?e.parentNode:e),a=r.inverse().multiply(S).multiply(r);applyResize(t,{dx:m,dy:x,scaleX:y,scaleY:v,localCTM:a,transformMatrix:S,bBox:o,__data__:p,isGrouped:i})}}));else applyResize(e,{dx:m,dy:x,scaleX:y,scaleY:v,localCTM:S,transformMatrix:S,bBox:o,__data__:p,isGrouped:i})}a.set(e,_objectSpread2({},f))}},{key:"_processActions",value:function(e){var t=this.storage,r=t.transform.controlsMatrix,a=t.center,o=(a=void 0===a?{}:a).isShifted;if(this.options.isGrouped&&e===E_ROTATE$2){this._applyTransformToHandles();var n=pointTo(r,0,0),i=n.x,s=n.y;o&&this._moveCenterHandle(i,s),this._updateControlsView(),o||this.setTransformOrigin({dx:0,dy:0},!1)}}},{key:"_processResize",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage,n=o.revX,i=o.revY,s=o.doW,l=o.doH,c=o.data,u=o.bBox,d=u.x,f=u.y,h=u.width,_=u.height,T=this.options,p=T.isGrouped,y=T.proportions,v=T.scalable,E=c.get(e),m=E.transform,x=m.matrix,g=m.auxiliary.scale.translateMatrix,b=E.cached,S=void 0===b?{}:b,M=_slicedToArray(function(e,t){var r=Math.max(1,h),a=Math.max(1,_),o=s||!s&&!l?(r+e)/r:(a+t)/a,n=y?r*o:r+e,i=y?a*o:a+t;return[n/r,i/a,n,i]}(r,a),4),O=M[0],A=M[1],N=M[2],R=M[3],C=function(e,t){var r=createScaleMatrix$1(e,t);return g.multiply(r).multiply(g.inverse())}(O,A),k=d-(N-h)*(l?.5:n?1:0),I=f-(R-_)*(s?.5:i?1:0),D=p?C.multiply(x):x.multiply(C);return v&&this._updateElementView(e,["transform",D]),c.set(e,_objectSpread2({},E,{cached:_objectSpread2({},S,{scaleX:O,scaleY:A,transformMatrix:C,resultMatrix:D})})),this._applyTransformToElement(e,E_RESIZE$2),{x:k,y:I,width:N,height:R,transform:D}}},{key:"_processMove",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data,n=o.get(e),i=n.transform,s=i.matrix,l=i.auxiliary.translate,c=l.translateMatrix,u=l.parentMatrix,d=n.cached;u.e=u.f=0;var f=pointTo(u,r,a),h=f.x,_=f.y;o.set(e,_objectSpread2({},n,{cached:_objectSpread2({},d,{dist:{dx:floatToFixed(r),dy:floatToFixed(a),ox:floatToFixed(h),oy:floatToFixed(_)}})})),c.e=h,c.f=_;var T=c.multiply(s);return this._updateElementView(e,["transform",T]),T}},{key:"_processRotate",value:function(e,t){var r=this.storage,a=(r=void 0===r?{}:r).data.get(e).transform,o=a.matrix,n=a.parentMatrix,i=a.auxiliary.rotate.translateMatrix,s=floatToFixed(Math.cos(t)),l=floatToFixed(Math.sin(t)),c=createRotateMatrix$1(l,s);n.e=n.f=0;var u=n.inverse().multiply(c).multiply(n),d=i.multiply(u).multiply(i.inverse()).multiply(o);return this._updateElementView(e,["transform",d]),d}},{key:"_getElementState",value:function(e,t){var r=t.revX,a=t.revY,o=t.doW,n=t.doH,i=this.options,s=i.container,l=i.isGrouped,c=this.storage,u=c.data,d=c.controls,f=c.handles.center,h=c.transformOrigin,_=h.x,T=h.y,p=u.get(e),y=p.__data__;storeElementAttributes(e,p,s),y.delete(e),checkChildElements(e).forEach((function(t){y.delete(t),storeElementAttributes(t,p,e,l)}));var v=this._getBBox(),E=v.x,m=v.y,x=v.width,g=v.height,b=getTransformToElement(e,e.parentNode),S=getTransformToElement(e,s),M=getTransformToElement(e.parentNode,s),O=M.inverse(),A=E+x*(n?.5:r?1:0),N=m+g*(o?.5:a?1:0),R=getTransformToElement(d,s),C=E+x/2,k=m+g/2,I=pointTo(R,_,T),D=I.x,P=I.y,w=f?pointTo(O,D,P):pointTo(l?O:b,C,k),V=w.x,$=w.y,G=f?pointTo(l?O:S.inverse(),D,P):pointTo(l?O:createSVGMatrix(),A,N),L=G.x,j=G.y;return{transform:{auxiliary:{scale:{scaleMatrix:createSVGMatrix(),translateMatrix:createTranslateMatrix$1(L,j)},translate:{parentMatrix:O,translateMatrix:createSVGMatrix()},rotate:{translateMatrix:createTranslateMatrix$1(V,$)}},matrix:b,ctm:S,parentMatrix:M,scX:Math.sqrt(S.a*S.a+S.b*S.b),scY:Math.sqrt(S.c*S.c+S.d*S.d)},bBox:v}}},{key:"_getCommonState",value:function(){var e=this.elements,t=this.options,r=t.isGrouped,a=t.container,o=t.restrict,n=this.storage,i=n.controls,s=n.handles.center,l=this._getBBox(),c=l.x,u=l.y,d=c+l.width/2,f=u+l.height/2,h=getTransformToElement(i,a),_=s?s.cx.baseVal.value:d,T=s?s.cy.baseVal.value:f,p=pointTo(h,_,T),y=p.x,v=p.y,E=pointTo(r?createSVGMatrix():getTransformToElement(e[0],a),d,f),m=E.x,x=E.y,g=o||a,b=getTransformToElement(g,g.parentNode),S=_objectSpread2({},this.storage.center||{},{x:s?y:m,y:s?v:x,hx:s?s.cx.baseVal.value:null,hy:s?s.cy.baseVal.value:null});return{transform:{containerMatrix:b,controlsMatrix:getTransformToElement(i,i.parentNode),controlsTranslateMatrix:createSVGMatrix(),wrapperOriginMatrix:createTranslateMatrix$1(S.x,S.y)},bBox:l,center:S}}},{key:"_getVertices",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createSVGMatrix(),t=this.elements,r=this.options,a=r.isGrouped,o=r.rotatable,n=r.rotatorAnchor,i=r.rotatorOffset,s=r.container,l=this._getBBox(),c=l.x,u=l.y,d=l.width,f=l.height,h=d/2,_=f/2,T={tl:[c,u],tr:[c+d,u],mr:[c+d,u+_],ml:[c,u+_],tc:[c+h,u],bc:[c+h,u+f],br:[c+d,u+f],bl:[c,u+f],center:[c+h,u+_]},p=a?e:e.multiply(getTransformToElement(t[0],s)),y=entries$1(T).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=_slicedToArray(r[1],2),n=o[0],i=o[1];return e[a]=pointTo(p,n,i),e}),{});if(o){var v={},E=1;switch(n){case"n":var m=y.tc,x=m.x,g=m.y;v.x=x,v.y=g;break;case"s":var b=y.bc,S=b.x,M=b.y;v.x=S,v.y=M,E=-1;break;case"w":var O=y.ml,A=O.x,N=O.y;v.x=A,v.y=N,E=-1;break;case"e":default:var R=y.mr,C=R.x,k=R.y;v.x=C,v.y=k}var I="n"===n||"s"===n?Math.atan2(y.bl.y-y.tl.y,y.bl.x-y.tl.x):Math.atan2(y.tl.y-y.tr.y,y.tl.x-y.tr.x),D=i*E,P={x:v.x-D*Math.cos(I),y:v.y-D*Math.sin(I)};y.rotator=P,y.anchor=v}return y}},{key:"_getBBox",value:function(){var e=this.elements,t=this.options,r=t.container;if(t.isGrouped){var a=e.reduce((function(e,t){var a=getTransformToElement(t,r);return[].concat(_toConsumableArray(e),_toConsumableArray(_getBoundingRect$1(t,a)))}),[]),o=_slicedToArray(getMinMaxOfArray(a),2),n=_slicedToArray(o[0],2),i=n[0],s=n[1],l=_slicedToArray(o[1],2),c=l[0];return{x:i,y:c,width:s-i,height:l[1]-c}}return e[0].getBBox()}},{key:"_moveCenterHandle",value:function(e,t){var r=this.storage,a=r.handles,o=a.center,n=a.radius,i=r.center,s=r.transform,l=(s=void 0===s?{}:s).controlsMatrix,c=void 0===l?createSVGMatrix():l,u=r.transformOrigin,d=(u=void 0===u?{}:u).x,f=u.y,h=r.cached;if(!isUndef(o)){var _=d+e,T=f+t;o.cx.baseVal.value=_,o.cy.baseVal.value=T,n.x2.baseVal.value=_,n.y2.baseVal.value=T,this.storage=_objectSpread2({},this.storage,{center:_objectSpread2({},i,{isShifted:!0},pointTo(c.inverse(),_,T)),cached:_objectSpread2({},h,{transformOrigin:pointTo(createSVGMatrix(),_,T)})})}}},{key:"_processMoveRestrict",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data.get(e).transform,n=o.matrix,i=o.auxiliary.translate.parentMatrix;i.e=i.f=0;var s=pointTo(i,r,a),l=s.x,c=s.y,u=createTranslateMatrix$1(l,c).multiply(n);return this._restrictHandler(e,u)}},{key:"_processRotateRestrict",value:function(e,t){var r=this.storage,a=(r=void 0===r?{}:r).data.get(e).transform,o=a.matrix,n=a.parentMatrix,i=a.auxiliary.rotate.translateMatrix,s=floatToFixed(Math.cos(t)),l=floatToFixed(Math.sin(t)),c=createRotateMatrix$1(l,s);n.e=n.f=0;var u=n.inverse().multiply(c).multiply(n),d=i.multiply(u).multiply(i.inverse()).multiply(o);return this._restrictHandler(e,d)}},{key:"_processResizeRestrict",value:function(e,t){var r,a,o,n,i,s,l,c=t.dx,u=t.dy,d=this.storage,f=d.doW,h=d.doH,_=d.data,T=d.bBox,p=T.width,y=T.height,v=this.options.proportions,E=_.get(e).transform,m=E.matrix,x=E.auxiliary.scale.translateMatrix,g=m.multiply(function(e,t){var r=createScaleMatrix$1(e,t);return x.multiply(r).multiply(x.inverse())}.apply(void 0,_toConsumableArray((r=c,a=u,o=Math.max(1,p),n=Math.max(1,y),i=f||!f&&!h?(o+r)/o:(n+a)/n,[(s=v?o*i:o+r)/o,(l=v?n*i:n+a)/n,s,l]))));return this._restrictHandler(e,g)}},{key:"_processControlsResize",value:function(){var e=this.storage,t=(e=void 0===e?{}:e).transform.controlsMatrix;this._applyTransformToHandles({boxMatrix:t.inverse()})}},{key:"_processControlsMove",value:function(e){var t=e.dx,r=e.dy,a=this.storage,o=(a=void 0===a?{}:a).transform,n=o.controlsMatrix,i=o.controlsTranslateMatrix,s=a.center;i.e=t,i.f=r;var l=i.multiply(n);if(this._updateControlsView(l),s.isShifted){var c=n.inverse();c.e=c.f=0;var u=pointTo(c,t,r),d=u.x,f=u.y;this._moveCenterHandle(-d,-f)}}},{key:"_processControlsRotate",value:function(e){var t=e.radians,r=this.storage,a=(r=void 0===r?{}:r).transform,o=a.controlsMatrix,n=a.wrapperOriginMatrix,i=floatToFixed(Math.cos(t)),s=floatToFixed(Math.sin(t)),l=createRotateMatrix$1(s,i),c=n.multiply(l).multiply(n.inverse()).multiply(o);this._updateControlsView(c)}},{key:"_updateElementView",value:function(e,t){var r=_slicedToArray(t,2),a=r[0],o=r[1];"transform"===a&&e.setAttribute(a,matrixToString(o))}},{key:"_updateControlsView",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createSVGMatrix();this.storage.controls.setAttribute("transform",matrixToString(e)),this.storage.cached.controlsMatrix=e}},{key:"_applyTransformToHandles",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.boxMatrix,r=void 0===t?createSVGMatrix():t,a=this.options.rotatable,o=this.storage,n=o.handles,i=o.center.isShifted,s=this._getVertices(r),l=s.anchor,c=void 0===l?null:l,u=s.center,d=_objectWithoutProperties(s,["anchor","center"]),f={te:[d.tl,d.tr],be:[d.bl,d.br],le:[d.tl,d.bl],re:[d.tr,d.br]};if(a){var h=n.normal,_=n.radius;isDef(h)&&(h.x1.baseVal.value=c.x,h.y1.baseVal.value=c.y,h.x2.baseVal.value=d.rotator.x,h.y2.baseVal.value=d.rotator.y),isDef(_)&&(_.x1.baseVal.value=u.x,_.y1.baseVal.value=u.y,i||(_.x2.baseVal.value=u.x,_.y2.baseVal.value=u.y))}keys$2(f).forEach((function(e){var t=n[e],r=_slicedToArray(f[e],2),a=r[0],o=r[1];isUndef(a)||isUndef(t)||entries$1({x1:a.x,y1:a.y,x2:o.x,y2:o.y}).map((function(e){var r=_slicedToArray(e,2),a=r[0],o=r[1];return t.setAttribute(a,o)}))}));var T=_objectSpread2({},d,{},!i&&Boolean(u)&&{center:u});return keys$2(T).reduce((function(e,t){var r=n[t],a=T[t];return e[t]=a,isUndef(a)||isUndef(r)?e:(r.setAttribute("cx",a.x),r.setAttribute("cy",a.y),e)}),{})}},{key:"setCenterPoint",value:function(){warn('"setCenterPoint" method is replaced by "setTransformOrigin" and would be removed soon'),this.setTransformOrigin.apply(this,arguments)}},{key:"setTransformOrigin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.x,r=e.y,a=e.dx,o=e.dy,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.elements,s=this.storage,l=this.storage,c=(l=void 0===l?{}:l).controls,u=l.handles,d=(u=void 0===u?{}:u).center,f=u.radius,h=l.center,_=this.options,T=_.container,p=_.isGrouped,y=isDef(a)&&isDef(o),v=isDef(t)&&isDef(r);if(h&&d&&f&&(y||v)){var E,m,x=getTransformToElement(c,c.parentNode).inverse(),g=p?x:x.multiply(getTransformToElement(i[0],T));if(y){var b=this._getBBox(),S=b.x,M=b.y,O=b.width,A=b.height,N=O/2,R=A/2,C=pointTo(g,S+N+a,M+R+o);E=C.x,m=C.y}else E=t,m=r;d.cx.baseVal.value=E,d.cy.baseVal.value=m,f.x2.baseVal.value=E,f.y2.baseVal.value=m,h.isShifted=n,s.transformOrigin=pointTo(createSVGMatrix(),E,m)}}},{key:"fitControlsToSize",value:function(){var e=this.storage,t=e.controls,r=e.center,a=(r=void 0===r?{}:r).isShifted,o=e.transformOrigin,n=(o=void 0===o?{}:o).x,i=o.y,s=getTransformToElement(t,t.parentNode),l=pointTo(s,n,i),c=l.x,u=l.y,d=[{nextValues:function(){return{x:c,y:u}},pin:!0,condition:function(){return a}},{nextValues:function(){return{dx:0,dy:0}},pin:!1,condition:function(){return!a}}].find((function(e){return(0,e.condition)()})),f=d.nextValues,h=d.pin;this._updateControlsView(),this.setTransformOrigin(_objectSpread2({},f()),h),this._applyTransformToHandles()}},{key:"getBoundingRect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.options,a=(r=void 0===r?{}:r).restrict,o=r.container,n=a||o,i=t?getTransformToElement(e.parentNode,n).multiply(t):getTransformToElement(e,n);return _getBoundingRect$1(e,i,e.getBBox())}},{key:"applyAlignment",value:function(e){var t=this,r=this.elements,a=this.options.container,o=this._getVertices(),n=(o.anchor,o.rotator,o.center,_objectWithoutProperties(o,["anchor","rotator","center"])),i=this._getRestrictedBBox(!0),s=values$2(n).map((function(e){return[e.x,e.y]})),l=_slicedToArray(getMinMaxOfArray(i),2),c=_slicedToArray(l[0],2),u=c[0],d=c[1],f=_slicedToArray(l[1],2),h=f[0],_=f[1],T=_slicedToArray(getMinMaxOfArray(s),2),p=_slicedToArray(T[0],2),y=p[0],v=p[1],E=_slicedToArray(T[1],2),m=E[0],x=E[1];r.map((function(r){var o=getTransformToElement(r.parentNode,a);o.e=o.f=0;var n=pointTo(o.inverse(),function(){switch(!0){case/[l]/.test(e):return u-y;case/[r]/.test(e):return d-v;case/[h]/.test(e):return(d+u)/2-(v+y)/2;default:return 0}}(),function(){switch(!0){case/[t]/.test(e):return h-m;case/[b]/.test(e):return _-x;case/[v]/.test(e):return(_+h)/2-(x+m)/2;default:return 0}}()),i=n.x,s=n.y,l=createTranslateMatrix$1(i,s).multiply(getTransformToElement(r,r.parentNode));t._updateElementView(r,["transform",l])})),this.fitControlsToSize()}},{key:"getDimensions",value:function(){var e=this.elements,t=this.options,r=t.isGrouped,a=t.container,o=this._getBBox(),n=o.x,i=o.y,s=o.width,l=o.height,c={tl:[n,i],tr:[n+s,i],bl:[n,i+l],br:[n+s,i+l]},u=r?createSVGMatrix():getTransformToElement(e[0],a),d=entries$1(c).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=_slicedToArray(r[1],2),n=o[0],i=o[1];return e[a]=pointTo(u,n,i),e}),{}),f=d.tl,h=d.br,_=d.tr;return{x:floatToFixed(f.x),y:floatToFixed(f.y),width:floatToFixed(Math.sqrt(Math.pow(f.x-_.x,2)+Math.pow(f.y-_.y,2))),height:floatToFixed(Math.sqrt(Math.pow(_.x-h.x,2)+Math.pow(_.y-h.y,2))),rotation:floatToFixed(Math.atan2(_.y-f.y,_.x-f.x)*DEG)}}}]),r}(),applyTranslate=function(e,t){var r=t.x,a=t.y,o=[];switch(e.tagName.toLowerCase()){case"text":var n=isDef(e.x.baseVal[0])?e.x.baseVal[0].value+r:(Number(e.getAttribute("x"))||0)+r,i=isDef(e.y.baseVal[0])?e.y.baseVal[0].value+a:(Number(e.getAttribute("y"))||0)+a;o.push(["x",n],["y",i]);break;case"foreignobject":case"use":case"image":case"rect":var s=isDef(e.x.baseVal.value)?e.x.baseVal.value+r:(Number(e.getAttribute("x"))||0)+r,l=isDef(e.y.baseVal.value)?e.y.baseVal.value+a:(Number(e.getAttribute("y"))||0)+a;o.push(["x",s],["y",l]);break;case"circle":case"ellipse":var c=e.cx.baseVal.value+r,u=e.cy.baseVal.value+a;o.push(["cx",c],["cy",u]);break;case"line":var d=e.x1.baseVal.value+r,f=e.y1.baseVal.value+a,h=e.x2.baseVal.value+r,_=e.y2.baseVal.value+a;o.push(["x1",d],["y1",f],["x2",h],["y2",_]);break;case"polygon":case"polyline":var T=parsePoints(e.getAttribute("points")).map((function(e){return e[0]=Number(e[0])+r,e[1]=Number(e[1])+a,e.join(" ")})).join(" ");o.push(["points",T]);break;case"path":var p=e.getAttribute("d");o.push(["d",movePath({path:p,dx:r,dy:a})])}o.forEach((function(t){e.setAttribute(t[0],t[1])}))},applyResize=function(e,t){var r=t.scaleX,a=t.scaleY,o=t.localCTM,n=t.bBox,i=n.width,s=n.height,l=t.__data__,c=t.transformMatrix,u=t.isGrouped,d=[],f=l.get(e);switch(e.tagName.toLowerCase()){case"text":case"tspan":var h=f.x,_=f.y,T=f.textLength,p=pointTo(o,h,_),y=p.x,v=p.y;d.push(["x",y+(r<0?i:0)],["y",v-(a<0?s:0)],["textLength",Math.abs(r*T)]);break;case"circle":var E=f.r,m=f.cx,x=f.cy,g=E*(Math.abs(r)+Math.abs(a))/2,b=pointTo(o,m,x),S=b.x,M=b.y;d.push(["r",g],["cx",S],["cy",M]);break;case"foreignobject":case"image":case"rect":if(u){var O=f.matrix,A=f.childCTM,N=A.inverse().multiply(c).multiply(A),R=O.multiply(N);d.push(["transform",matrixToString(R)])}else{var C=f.width,k=f.height,I=f.x,D=f.y,P=pointTo(o,I,D),w=P.x,V=P.y,$=Math.abs(C*r),G=Math.abs(k*a);d.push(["x",w-(r<0?$:0)],["y",V-(a<0?G:0)],["width",$],["height",G])}break;case"ellipse":var L=f.rx,j=f.ry,F=f.cx,H=f.cy,U=pointTo(o,F,H),B=U.x,Y=U.y,z=createSVGMatrix();z.a=r,z.d=a;var X=pointTo(z,L,j),W=X.x,Z=X.y;d.push(["rx",Math.abs(W)],["ry",Math.abs(Z)],["cx",B],["cy",Y]);break;case"line":var K=f.resX1,q=f.resY1,Q=f.resX2,J=f.resY2,ee=pointTo(o,K,q),te=ee.x,re=ee.y,ae=pointTo(o,Q,J),oe=ae.x,ne=ae.y;d.push(["x1",te],["y1",re],["x2",oe],["y2",ne]);break;case"polygon":case"polyline":var ie=f.points,se=parsePoints(ie).map((function(e){var t=pointTo(o,Number(e[0]),Number(e[1])),r=t.x,a=t.y;return e[0]=floatToFixed(r),e[1]=floatToFixed(a),e.join(" ")})).join(" ");d.push(["points",se]);break;case"path":var le=f.path;d.push(["d",resizePath({path:le,localCTM:o})])}d.forEach((function(t){var r=_slicedToArray(t,2),a=r[0],o=r[1];e.setAttribute(a,o)}))},createHandler$1=function(e,t,r,a){var o=createSVGElement("circle",["sjx-svg-hdl","sjx-svg-hdl-".concat(a)]);return entries$1({cx:e,cy:t,r:4,fill:"#fff",stroke:r,"stroke-width":1,"fill-opacity":1,"vector-effect":"non-scaling-stroke"}).forEach((function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1];return o.setAttribute(r,a)})),o},setLineStyle=function(e,t){e.setAttribute("stroke",t),e.setAttribute("stroke-dasharray","3 3"),e.setAttribute("vector-effect","non-scaling-stroke")},storeElementAttributes=function(e,t,r,a){var o=null;switch(e.tagName.toLowerCase()){case"text":o={x:isDef(e.x.baseVal[0])?e.x.baseVal[0].value:Number(e.getAttribute("x"))||0,y:isDef(e.y.baseVal[0])?e.y.baseVal[0].value:Number(e.getAttribute("y"))||0,textLength:isDef(e.textLength.baseVal)?e.textLength.baseVal.value:Number(e.getAttribute("textLength"))||null};break;case"circle":o={r:e.r.baseVal.value,cx:e.cx.baseVal.value,cy:e.cy.baseVal.value};break;case"foreignobject":case"image":case"rect":o={width:e.width.baseVal.value,height:e.height.baseVal.value,x:e.x.baseVal.value,y:e.y.baseVal.value};break;case"ellipse":o={rx:e.rx.baseVal.value,ry:e.ry.baseVal.value,cx:e.cx.baseVal.value,cy:e.cy.baseVal.value};break;case"line":o={resX1:e.x1.baseVal.value,resY1:e.y1.baseVal.value,resX2:e.x2.baseVal.value,resY2:e.y2.baseVal.value};break;case"polygon":case"polyline":o={points:e.getAttribute("points")};break;case"path":o={path:e.getAttribute("d")}}t.__data__.set(e,_objectSpread2({},o,{matrix:getTransformToElement(e,e.parentNode),ctm:getTransformToElement(e.parentNode,r),childCTM:getTransformToElement(e,a?r.parentNode:r)}))},renderLine$1=function(e,t,r){var a=_slicedToArray(e,2),o=a[0],n=a[1],i=createSVGElement("line",["sjx-svg-line","sjx-svg-line-".concat(r)]),s={x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:t,"stroke-width":1,"vector-effect":"non-scaling-stroke"};return entries$1(s).forEach((function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1];return i.setAttribute(r,a)})),i},_getBoundingRect$1=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.getBBox(),a=r.x,o=r.y,n=r.width,i=r.height,s=[[a,o],[a+n,o],[a+n,o+i],[a,o+i]];return s.map((function(e){var r=_slicedToArray(e,2),a=r[0],o=r[1],n=pointTo(t,a,o);return[n.x,n.y]}))};function drag(e,t){if(this.length){var r=isDef(t)&&t instanceof Observable?t:new Observable;if(this[0]instanceof SVGElement){var a=arrReduce.call(this,(function(e,t){return checkElement(t)&&e.push(t),e}),[]);return new DraggableSVG(a,e,r)}return new Draggable(arrMap.call(this,(function(e){return e})),e,r)}}var EMITTER_EVENTS$2=EVENT_EMITTER_CONSTANTS.EMITTER_EVENTS,E_MOUSEDOWN$4=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$4=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,Cloneable=function(e){_inherits(r,SubjectModel);var t=_createSuper(r);function r(e,a){var o;return _classCallCheck(this,r),(o=t.call(this,e)).enable(a),o}return _createClass(r,[{key:"_init",value:function(){var e=this,t=this.elements,r=this.options,a=helper(t),o=r.style,n=r.appendTo,i=_objectSpread2({position:"absolute","z-index":"2147483647"},o),s=new WeakMap;t.map((function(e){return s.set(e,{parent:isDef(n)?helper(n)[0]:document.body})})),this.storage={css:i,data:s},a.on(E_MOUSEDOWN$4,this._onMouseDown).on(E_TOUCHSTART$4,this._onTouchStart),EMITTER_EVENTS$2.slice(0,3).forEach((function(t){e.eventDispatcher.registerEvent(t)}))}},{key:"_processOptions",value:function(e){var t={},r=null,a=document,o=noop,n=noop,i=noop,s=noop;if(isDef(e)){var l=e.style,c=e.appendTo,u=e.stack,d=e.onInit,f=e.onMove,h=e.onDrop,_=e.onDestroy;t=isDef(l)&&"object"===_typeof(l)?l:t,r=c||null;var T=isDef(u)?helper(u)[0]:document;o=createMethod(d),n=createMethod(f),i=isFunc(h)?function(e){var t=this.storage,r=(t=void 0===t?{}:t).clone;objectsCollide(r,T)&&h.call(this,e,this.elements,r)}:noop,s=createMethod(_)}this.options={style:t,appendTo:r,stack:a},this.proxyMethods={onInit:o,onDrop:i,onMove:n,onDestroy:s}}},{key:"_start",value:function(e){var t=e.target,r=e.clientX,a=e.clientY,o=this.elements,n=this.storage,i=this.storage,s=i.data,l=i.css,c=o.find((function(e){return e===t||e.contains(t)}));if(c){var u=(s.get(c)||{}).parent,d=void 0===u?c.parentNode:u,f=getOffset(d),h=f.left,_=f.top;l.left="".concat(r-h,"px"),l.top="".concat(a-_,"px");var T=c.cloneNode(!0);helper(T).css(l),n.clientX=r,n.clientY=a,n.cx=r,n.cy=a,n.clone=T,d.appendChild(T),this._draw()}}},{key:"_moving",value:function(e){var t=e.clientX,r=e.clientY,a=this.storage;a.clientX=t,a.clientY=r,a.doDraw=!0,a.doMove=!0}},{key:"_end",value:function(e){var t=this.storage,r=t.clone,a=t.frameId;t.doDraw=!1,cancelAnimFrame(a),isUndef(r)||(this.proxyMethods.onDrop.call(this,e),r.parentNode.removeChild(r),delete t.clone)}},{key:"_animate",value:function(){var e=this.storage;e.frameId=requestAnimFrame(this._animate);var t=e.doDraw,r=e.clientX,a=e.clientY,o=e.cx,n=e.cy,i=e.clone;t&&(e.doDraw=!1,this._drag({element:i,dx:r-o,dy:a-n}))}},{key:"_processMove",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage,n=(o=void 0===o?{}:o).clone,i="translate(".concat(r,"px, ").concat(a,"px)");helper(n).css({transform:i,webkitTranform:i,mozTransform:i,msTransform:i,otransform:i})}},{key:"_destroy",value:function(){var e=this.storage,t=this.proxyMethods,r=this.elements;isUndef(e)||(helper(r).off(E_MOUSEDOWN$4,this._onMouseDown).off(E_TOUCHSTART$4,this._onTouchStart),t.onDestroy.call(this,r),delete this.storage)}},{key:"disable",value:function(){this._destroy()}}]),r}();function clone(e){if(this.length)return new Cloneable(arrMap.call(this,(function(e){return e})),e)}var Subjx=function(e){_inherits(r,Helper);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"drag",value:function(){return drag.call.apply(drag,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"clone",value:function(){return clone.call.apply(clone,[this].concat(Array.prototype.slice.call(arguments)))}}]),r}();function subjx(e){return new Subjx(e)}Object.defineProperty(subjx,"createObservable",{value:function(){return new Observable}}),Object.defineProperty(subjx,"Subjx",{value:Subjx}),Object.defineProperty(subjx,"Observable",{value:Observable}),module.exports=subjx; +"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r=0||(o[r]=e[r]);return o}function _objectWithoutProperties(e,t){if(null==e)return{};var r,a,o=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _possibleConstructorReturn(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?_assertThisInitialized(e):t}function _createSuper(e){return function(){var t,r=_getPrototypeOf(e);if(_isNativeReflectConstruct()){var a=_getPrototypeOf(this).constructor;t=Reflect.construct(r,arguments,a)}else t=r.apply(this,arguments);return _possibleConstructorReturn(this,t)}}function _superPropBase(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=_getPrototypeOf(e)););return e}function _get(e,t,r){return(_get="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var a=_superPropBase(e,t);if(a){var o=Object.getOwnPropertyDescriptor(a,t);return o.get?o.get.call(r):o.value}})(e,t,r||e)}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function _iterableToArrayLimit(e,t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e)){var r=[],a=!0,o=!1,n=void 0;try{for(var i,s=e[Symbol.iterator]();!(a=(i=s.next()).done)&&(r.push(i.value),!t||r.length!==t);a=!0);}catch(e){o=!0,n=e}finally{try{a||null==s.return||s.return()}finally{if(o)throw n}}return r}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(r):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[t++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o,n=!0,i=!1;return{s:function(){a=e[Symbol.iterator]()},n:function(){var e=a.next();return n=e.done,e},e:function(e){i=!0,o=e},f:function(){try{n||null==a.return||a.return()}finally{if(i)throw o}}}}var requestAnimFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return setTimeout(e,1e3/60)},cancelAnimFrame=window.cancelAnimationFrame||window.mozCancelAnimationFrame||function(e){clearTimeout(e)},_Array$prototype=Array.prototype,forEach=_Array$prototype.forEach,arrSlice=_Array$prototype.slice,arrMap=_Array$prototype.map,arrReduce=_Array$prototype.reduce,_console=console,warn=_console.warn,noop=function(e){return e},isDef=function(e){return null!=e},isUndef=function(e){return null==e},isFunc=function(e){return"function"==typeof e},createMethod=function(e){return isFunc(e)?function(){e.call.apply(e,[this].concat(Array.prototype.slice.call(arguments)))}:noop},Helper=function(){function e(t){if(_classCallCheck(this,e),"string"==typeof t){var r=document.querySelectorAll(t);this.length=r.length;for(var a=0;a0&&e.length-1 in e))}function helper(e){return new Helper(e)}var MIN_SIZE=2,THEME_COLOR="#00a8ff",LIB_CLASS_PREFIX="sjx-",E_MOUSEDOWN="mousedown",E_MOUSEUP="mouseup",E_MOUSEMOVE="mousemove",E_TOUCHSTART="touchstart",E_TOUCHEND="touchend",E_TOUCHMOVE="touchmove",E_DRAG_START="dragStart",E_DRAG="drag",E_DRAG_END="dragEnd",E_RESIZE_START="resizeStart",E_RESIZE="resize",E_RESIZE_END="resizeEnd",E_ROTATE_START="rotateStart",E_ROTATE="rotate",E_ROTATE_END="rotateEnd",E_SET_POINT="setPoint",E_SET_POINT_START="setPointStart",E_SET_POINT_END="setPointEnd",EMITTER_EVENTS=[E_DRAG_START,E_DRAG,,E_DRAG_END,E_RESIZE_START,E_RESIZE,E_RESIZE_END,E_ROTATE_START,E_ROTATE,E_ROTATE_END,E_SET_POINT_START,E_SET_POINT_END],CSS_PREFIXES=["","-webkit-","-moz-","-ms-","-o-"],ON_GETSTATE="ongetstate",ON_APPLY="onapply",ON_MOVE="onmove",ON_RESIZE="onresize",ON_ROTATE="onrotate",NOTIFIER_EVENTS=[ON_GETSTATE,ON_APPLY,ON_MOVE,ON_RESIZE,ON_ROTATE],NOTIFIER_CONSTANTS={NOTIFIER_EVENTS:NOTIFIER_EVENTS,ON_GETSTATE:ON_GETSTATE,ON_APPLY:ON_APPLY,ON_MOVE:ON_MOVE,ON_RESIZE:ON_RESIZE,ON_ROTATE:ON_ROTATE},EVENT_EMITTER_CONSTANTS={EMITTER_EVENTS:EMITTER_EVENTS,E_DRAG_START:E_DRAG_START,E_DRAG:E_DRAG,E_DRAG_END:E_DRAG_END,E_RESIZE_START:E_RESIZE_START,E_RESIZE:E_RESIZE,E_RESIZE_END:E_RESIZE_END,E_ROTATE_START:E_ROTATE_START,E_ROTATE:E_ROTATE,E_ROTATE_END:E_ROTATE_END,E_SET_POINT:E_SET_POINT,E_SET_POINT_START:E_SET_POINT_START,E_SET_POINT_END:E_SET_POINT_END},CLIENT_EVENTS_CONSTANTS={E_MOUSEDOWN:E_MOUSEDOWN,E_MOUSEUP:E_MOUSEUP,E_MOUSEMOVE:E_MOUSEMOVE,E_TOUCHSTART:E_TOUCHSTART,E_TOUCHEND:E_TOUCHEND,E_TOUCHMOVE:E_TOUCHMOVE},TRANSFORM_HANDLES_KEYS={TOP_LEFT:"tl",TOP_CENTER:"tc",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br",BOTTOM_CENTER:"bc",MIDDLE_LEFT:"ml",MIDDLE_RIGHT:"mr",CENTER:"center"},TRANSFORM_EDGES_KEYS={TOP_EDGE:"te",BOTTOM_EDGE:"be",LEFT_EDGE:"le",RIGHT_EDGE:"re"},TRANSFORM_HANDLES_CONSTANTS={TRANSFORM_HANDLES_KEYS:TRANSFORM_HANDLES_KEYS,TRANSFORM_EDGES_KEYS:TRANSFORM_EDGES_KEYS},ON_GETSTATE$1=NOTIFIER_CONSTANTS.ON_GETSTATE,ON_APPLY$1=NOTIFIER_CONSTANTS.ON_APPLY,ON_MOVE$1=NOTIFIER_CONSTANTS.ON_MOVE,ON_RESIZE$1=NOTIFIER_CONSTANTS.ON_RESIZE,ON_ROTATE$1=NOTIFIER_CONSTANTS.ON_ROTATE,Observable=function(){function e(){_classCallCheck(this,e),this.observers={}}return _createClass(e,[{key:"subscribe",value:function(e,t){var r=this.observers;return isUndef(r[e])&&Object.defineProperty(r,e,{value:[]}),r[e].push(t),this}},{key:"unsubscribe",value:function(e,t){var r=this.observers;if(isDef(r[e])){var a=r[e].indexOf(t);r[e].splice(a,1)}return this}},{key:"notify",value:function(e,t,r){isUndef(this.observers[e])||this.observers[e].forEach((function(a){if(t!==a)switch(e){case ON_MOVE$1:a.notifyMove(r);break;case ON_ROTATE$1:a.notifyRotate(r);break;case ON_RESIZE$1:a.notifyResize(r);break;case ON_APPLY$1:a.notifyApply(r);break;case ON_GETSTATE$1:a.notifyGetState(r)}}))}}]),e}(),Event=function(){function e(t){_classCallCheck(this,e),this.name=t,this.callbacks=[]}return _createClass(e,[{key:"registerCallback",value:function(e){this.callbacks.push(e)}},{key:"removeCallback",value:function(e){var t=this.callbacks(e);this.callbacks.splice(t,1)}}]),e}(),EventDispatcher=function(){function e(){_classCallCheck(this,e),this.events={}}return _createClass(e,[{key:"registerEvent",value:function(e){this.events[e]=new Event(e)}},{key:"emit",value:function(e,t,r){this.events[t].callbacks.forEach((function(t){t.call(e,r)}))}},{key:"addEventListener",value:function(e,t){this.events[e].registerCallback(t)}},{key:"removeEventListener",value:function(e,t){this.events[e].removeCallback(t)}}]),e}(),E_DRAG$1=EVENT_EMITTER_CONSTANTS.E_DRAG,E_MOUSEMOVE$1=CLIENT_EVENTS_CONSTANTS.E_MOUSEMOVE,E_MOUSEUP$1=CLIENT_EVENTS_CONSTANTS.E_MOUSEUP,E_TOUCHMOVE$1=CLIENT_EVENTS_CONSTANTS.E_TOUCHMOVE,E_TOUCHEND$1=CLIENT_EVENTS_CONSTANTS.E_TOUCHEND,SubjectModel=function(){function e(t){_classCallCheck(this,e),this.elements=t,this.storage=null,this.proxyMethods=null,this.eventDispatcher=new EventDispatcher,this._onMouseDown=this._onMouseDown.bind(this),this._onTouchStart=this._onTouchStart.bind(this),this._onMouseMove=this._onMouseMove.bind(this),this._onTouchMove=this._onTouchMove.bind(this),this._onMouseUp=this._onMouseUp.bind(this),this._onTouchEnd=this._onTouchEnd.bind(this),this._animate=this._animate.bind(this)}return _createClass(e,[{key:"enable",value:function(e){this._processOptions(e),this._init(this.elements),this.proxyMethods.onInit.call(this,this.elements)}},{key:"disable",value:function(){throwNotImplementedError()}},{key:"_init",value:function(){throwNotImplementedError()}},{key:"_destroy",value:function(){throwNotImplementedError()}},{key:"_processOptions",value:function(){throwNotImplementedError()}},{key:"_start",value:function(){throwNotImplementedError()}},{key:"_moving",value:function(){throwNotImplementedError()}},{key:"_end",value:function(){throwNotImplementedError()}},{key:"_animate",value:function(){throwNotImplementedError()}},{key:"_drag",value:function(e){var t=e.element,r=e.dx,a=e.dy,o=_objectWithoutProperties(e,["element","dx","dy"]),n=_objectSpread2({dx:r,dy:a,transform:this._processMove(t,{dx:r,dy:a})},o);this.proxyMethods.onMove.call(this,n),this._emitEvent(E_DRAG$1,n)}},{key:"_draw",value:function(){this._animate()}},{key:"_onMouseDown",value:function(e){this._start(e),helper(document).on(E_MOUSEMOVE$1,this._onMouseMove).on(E_MOUSEUP$1,this._onMouseUp)}},{key:"_onTouchStart",value:function(e){this._start(e.touches[0]),helper(document).on(E_TOUCHMOVE$1,this._onTouchMove).on(E_TOUCHEND$1,this._onTouchEnd)}},{key:"_onMouseMove",value:function(e){e.preventDefault&&e.preventDefault(),this._moving(e)}},{key:"_onTouchMove",value:function(e){e.preventDefault&&e.preventDefault(),this._moving(e.touches[0])}},{key:"_onMouseUp",value:function(e){helper(document).off(E_MOUSEMOVE$1,this._onMouseMove).off(E_MOUSEUP$1,this._onMouseUp),this._end(e,this.elements)}},{key:"_onTouchEnd",value:function(e){helper(document).off(E_TOUCHMOVE$1,this._onTouchMove).off(E_TOUCHEND$1,this._onTouchEnd),0===e.touches.length&&this._end(e.changedTouches[0],this.elements)}},{key:"_emitEvent",value:function(){var e;(e=this.eventDispatcher).emit.apply(e,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"on",value:function(e,t){return this.eventDispatcher.addEventListener(e,t),this}},{key:"off",value:function(e,t){return this.eventDispatcher.removeEventListener(e,t),this}}]),e}(),throwNotImplementedError=function(){throw Error("Method not implemented")},RAD=Math.PI/180,DEG=180/Math.PI,snapCandidate=function(e,t){return 0===t?e:Math.round(e/t)*t},snapToGrid=function(e,t){if(0===t)return e;var r=snapCandidate(e,t);return r-e1&&void 0!==arguments[1]?arguments[1]:6;return Number(e.toFixed(t))},getMinMaxOfArray=function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=[],a=function(t){var a=e.map((function(e){return e[t]}));r.push([Math.min.apply(Math,_toConsumableArray(a)),Math.max.apply(Math,_toConsumableArray(a))])},o=0;o-1))return e.classList.add(t);t.split(/\s+/).forEach((function(t){return e.classList.add(t)}))}return e}},removeClass=function(e,t){if(t){if(e.classList){if(!(t.indexOf(" ")>-1))return e.classList.remove(t);t.split(/\s+/).forEach((function(t){return e.classList.remove(t)}))}return e}},objectsCollide=function(e,t){var r=getOffset(e),a=r.top,o=r.left,n=getOffset(t),i=n.top,s=n.left,l=helper(e),c=helper(t);return!(ai+parseFloat(c.css("height"))||os+parseFloat(c.css("width")))},matrixToCSS=function(e){var t="matrix3d(".concat(e.join(),")");return{transform:t,webkitTranform:t,mozTransform:t,msTransform:t,otransform:t}},getStyle=function(e,t){var r,a=window.getComputedStyle(e),o=null,n=_createForOfIteratorHelper(CSS_PREFIXES);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(o=a.getPropertyValue("".concat(i).concat(t))||o)break}}catch(e){n.e(e)}finally{n.f()}return o},getScrollOffset=function(){var e=document.documentElement;return{left:(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0),top:(window.pageYOffset||e.scrollTop)-(e.clientTop||0)}},getElementOffset=function(e){for(var t=0,r=0;e&&!isNaN(e.offsetLeft)&&!isNaN(e.offsetTop);)t+=e.offsetLeft-e.scrollLeft,r+=e.offsetTop-e.scrollTop,e=e.offsetParent;return{left:t,top:r}},NOTIFIER_EVENTS$1=NOTIFIER_CONSTANTS.NOTIFIER_EVENTS,ON_GETSTATE$2=NOTIFIER_CONSTANTS.ON_GETSTATE,ON_APPLY$2=NOTIFIER_CONSTANTS.ON_APPLY,ON_MOVE$2=NOTIFIER_CONSTANTS.ON_MOVE,ON_RESIZE$2=NOTIFIER_CONSTANTS.ON_RESIZE,ON_ROTATE$2=NOTIFIER_CONSTANTS.ON_ROTATE,EMITTER_EVENTS$1=EVENT_EMITTER_CONSTANTS.EMITTER_EVENTS,E_DRAG_START$1=EVENT_EMITTER_CONSTANTS.E_DRAG_START,E_DRAG$2=EVENT_EMITTER_CONSTANTS.E_DRAG,E_DRAG_END$1=EVENT_EMITTER_CONSTANTS.E_DRAG_END,E_RESIZE_START$1=EVENT_EMITTER_CONSTANTS.E_RESIZE_START,E_RESIZE$1=EVENT_EMITTER_CONSTANTS.E_RESIZE,E_RESIZE_END$1=EVENT_EMITTER_CONSTANTS.E_RESIZE_END,E_ROTATE_START$1=EVENT_EMITTER_CONSTANTS.E_ROTATE_START,E_ROTATE$1=EVENT_EMITTER_CONSTANTS.E_ROTATE,E_ROTATE_END$1=EVENT_EMITTER_CONSTANTS.E_ROTATE_END,E_SET_POINT$1=EVENT_EMITTER_CONSTANTS.E_SET_POINT,E_SET_POINT_END$1=EVENT_EMITTER_CONSTANTS.E_SET_POINT_END,TRANSFORM_HANDLES_KEYS$1=TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_HANDLES_KEYS,TRANSFORM_EDGES_KEYS$1=TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_EDGES_KEYS,E_MOUSEDOWN$1=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$1=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,E_MOUSEMOVE$2=CLIENT_EVENTS_CONSTANTS.E_MOUSEMOVE,E_MOUSEUP$2=CLIENT_EVENTS_CONSTANTS.E_MOUSEUP,E_TOUCHMOVE$2=CLIENT_EVENTS_CONSTANTS.E_TOUCHMOVE,E_TOUCHEND$2=CLIENT_EVENTS_CONSTANTS.E_TOUCHEND,TOP_LEFT=TRANSFORM_HANDLES_KEYS$1.TOP_LEFT,TOP_CENTER=TRANSFORM_HANDLES_KEYS$1.TOP_CENTER,TOP_RIGHT=TRANSFORM_HANDLES_KEYS$1.TOP_RIGHT,BOTTOM_LEFT=TRANSFORM_HANDLES_KEYS$1.BOTTOM_LEFT,BOTTOM_RIGHT=TRANSFORM_HANDLES_KEYS$1.BOTTOM_RIGHT,BOTTOM_CENTER=TRANSFORM_HANDLES_KEYS$1.BOTTOM_CENTER,MIDDLE_LEFT=TRANSFORM_HANDLES_KEYS$1.MIDDLE_LEFT,MIDDLE_RIGHT=TRANSFORM_HANDLES_KEYS$1.MIDDLE_RIGHT,TOP_EDGE=TRANSFORM_EDGES_KEYS$1.TOP_EDGE,BOTTOM_EDGE=TRANSFORM_EDGES_KEYS$1.BOTTOM_EDGE,LEFT_EDGE=TRANSFORM_EDGES_KEYS$1.LEFT_EDGE,RIGHT_EDGE=TRANSFORM_EDGES_KEYS$1.RIGHT_EDGE,keys=Object.keys,values=Object.values,Transformable=function(e){_inherits(r,SubjectModel);var t=_createSuper(r);function r(e,a,o){var n;if(_classCallCheck(this,r),(n=t.call(this,e)).constructor===r)throw new TypeError("Cannot construct Transformable instances directly");return n.observable=o,EMITTER_EVENTS$1.forEach((function(e){return n.eventDispatcher.registerEvent(e)})),_get(_getPrototypeOf(r.prototype),"enable",_assertThisInitialized(n)).call(_assertThisInitialized(n),a),n}return _createClass(r,[{key:"_cursorPoint",value:function(){throw Error("'_cursorPoint()' method not implemented")}},{key:"_rotate",value:function(e){var t=e.element,a=e.radians,o=_objectWithoutProperties(e,["element","radians"]),n=_objectSpread2({transform:this._processRotate(t,a),delta:a},o);this.proxyMethods.onRotate.call(this,n),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE$1,n)}},{key:"_resize",value:function(e){var t=e.element,a=e.dx,o=e.dy,n=_objectWithoutProperties(e,["element","dx","dy"]),i=_objectSpread2({},this._processResize(t,{dx:a,dy:o}),{dx:a,dy:o},n);this.proxyMethods.onResize.call(this,i),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE$1,i)}},{key:"_processOptions",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.elements;_toConsumableArray(t).map((function(e){return addClass(e,"".concat(LIB_CLASS_PREFIX,"drag"))}));var r=e.each,a=void 0===r?{move:!1,resize:!1,rotate:!1}:r,o=e.snap,n=void 0===o?{x:10,y:10,angle:10}:o,i=e.axis,s=void 0===i?"xy":i,l=e.cursorMove,c=void 0===l?"auto":l,u=e.cursorResize,d=void 0===u?"auto":u,f=e.cursorRotate,h=void 0===f?"auto":f,_=e.rotationPoint,T=void 0!==_&&_,p=e.transformOrigin,y=void 0!==p&&p,v=e.restrict,E=e.draggable,m=void 0===E||E,x=e.resizable,g=void 0===x||x,b=e.rotatable,S=void 0===b||b,M=e.scalable,O=void 0!==M&&M,A=e.applyTranslate,N=void 0!==A&&A,R=e.onInit,C=void 0===R?noop:R,k=e.onDrop,I=void 0===k?noop:k,D=e.onMove,P=void 0===D?noop:D,w=e.onResize,V=void 0===w?noop:w,$=e.onRotate,G=void 0===$?noop:$,L=e.onDestroy,j=void 0===L?noop:L,F=e.container,H=void 0===F?t[0].parentNode:F,U=e.controlsContainer,B=void 0===U?H:U,Y=e.proportions,z=void 0!==Y&&Y,X=e.rotatorAnchor,W=void 0===X?null:X,Z=e.rotatorOffset,K=void 0===Z?50:Z,q=e.showNormal,Q=void 0===q||q,J=e.custom;this.options={axis:s,cursorMove:c,cursorRotate:h,cursorResize:d,rotationPoint:T,transformOrigin:y||T,restrict:v?helper(v)[0]||document.body:null,container:helper(H)[0],controlsContainer:helper(B)[0],snap:_objectSpread2({},n,{angle:n.angle*RAD}),each:a,proportions:z,draggable:m,resizable:g,rotatable:S,scalable:O,applyTranslate:N,custom:"object"===_typeof(J)&&J||null,rotatorAnchor:W,rotatorOffset:K,showNormal:Q,isGrouped:t.length>1},this.proxyMethods={onInit:createMethod(C),onDrop:createMethod(I),onMove:createMethod(P),onResize:createMethod(V),onRotate:createMethod(G),onDestroy:createMethod(j)},this.subscribe(a)}},{key:"_animate",value:function(){var e=this,t=this,a=t.observable,o=t.storage,n=t.options,i=t.elements;if(!isUndef(o)&&(o.frame=requestAnimFrame(t._animate),o.doDraw)){o.doDraw=!1;var s=o.dox,l=o.doy,c=o.clientX,u=o.clientY,d=o.relativeX,f=o.relativeY,h=o.doDrag,_=o.doResize,T=o.doRotate,p=o.doSetCenter,y=o.revX,v=o.revY,E=o.mouseEvent,m=o.data,x=n.snap,g=n.each,b=g.move,S=g.resize,M=g.rotate,O=n.draggable,A=n.resizable,N=n.rotatable,R=n.isGrouped,C=n.restrict;if(_&&A){var k=snapToGrid(c-d,x.x),I=snapToGrid(u-f,x.y),D=o.cached,P=o.cached,w=(P=void 0===P?{}:P).dist,V=(w=void 0===w?{}:w).dx,$=void 0===V?k:V,G=w.dy,L=void 0===G?I:G,j={dx:k,dy:I,clientX:c,clientY:u,mouseEvent:E},F=C?i.reduce((function(t,r){var a=m.get(r).transform.ctm,o=R?{x:k,y:I}:e._pointToTransform({x:k,y:I,matrix:a}),n=o.x,i=o.y,c=s?y?-n:n:0,u=l?v?-i:i:0,d=e._processResizeRestrict(r,{dx:c,dy:u}),f=d.x,h=d.y;return{x:null!==f&&null===t.x?k:t.x,y:null!==h&&null===t.y?I:t.y}}),{x:null,y:null}):{x:null,y:null},H=F.x,U=F.y,B=C&&(null!==H||null!==U),Y=B?$:k,z=B?L:I,X=_objectSpread2({},j,{dx:Y,dy:z,revX:y,revY:v,dox:s,doy:l});i.map((function(r){var a=m.get(r).transform.ctm,o=R?{x:Y,y:z}:e._pointToTransform({x:Y,y:z,matrix:a}),n=o.x,i=o.y,c=s?y?-n:n:0,u=l?v?-i:i:0;t._resize(_objectSpread2({},X,{element:r,dx:c,dy:u}))})),this.storage.cached=_objectSpread2({},D,{dist:{dx:Y,dy:z}}),this._processControlsResize({dx:Y,dy:z}),S&&a.notify(ON_RESIZE$2,t,X)}if(h&&O){var W=s?snapToGrid(c-d,x.x):0,Z=l?snapToGrid(u-f,x.y):0,K=o.cached,q=o.cached,Q=(q=void 0===q?{}:q).dist,J=(Q=void 0===Q?{}:Q).dx,ee=void 0===J?W:J,te=Q.dy,re=void 0===te?Z:te,ae={dx:W,dy:Z,clientX:c,clientY:u,mouseEvent:E},oe=C?i.reduce((function(t,r){var a=e._processMoveRestrict(r,ae),o=a.x,n=a.y;return{x:null===t.x&&C?o:t.x,y:null===t.y&&C?n:t.y}}),{x:null,y:null}):{x:null,y:null},ne=oe.x,ie=oe.y,se=null!==ne&&C?ee:W,le=null!==ie&&C?re:Z,ce=_objectSpread2({},ae,{dx:se,dy:le});this.storage.cached=_objectSpread2({},K,{dist:{dx:se,dy:le}}),i.map((function(t){return _get(_getPrototypeOf(r.prototype),"_drag",e).call(e,_objectSpread2({element:t},ce,{dx:se,dy:le}))})),this._processControlsMove({dx:se,dy:le}),b&&a.notify(ON_MOVE$2,t,ce)}if(T&&N){var ue=o.pressang,de=o.center,fe=Math.atan2(u-de.y,c-de.x),he=snapToGrid(fe-ue,x.angle);if(C)if(i.some((function(t){var r=e._processRotateRestrict(t,he),a=r.x,o=r.y;return null!==a||null!==o})))return;var _e={clientX:c,clientY:u,mouseEvent:E};i.map((function(e){return t._rotate(_objectSpread2({element:e,radians:he},_e))})),this._processControlsRotate({radians:he}),M&&a.notify(ON_ROTATE$2,t,_objectSpread2({radians:he},_e))}if(p&&N){var Te=o.bx,pe=o.by,ye=this._pointToControls({x:c,y:u}),ve=ye.x,Ee=ye.y;t._moveCenterHandle(ve-Te,Ee-pe)}}}},{key:"_start",value:function(e){var t=e.clientX,a=e.clientY,o=this.elements,n=this.observable,i=this.options,s=i.axis,l=i.each,c=this.storage,u=this.storage.handles,d=values(u).some((function(t){return helper(e.target).is(t)}))||o.some((function(t){return t.contains(e.target)}));if(c.isTarget=d,d){var f=this._compute(e,o);keys(f).map((function(e){return c[e]=f[e]}));var h=f.onRightEdge,_=f.onBottomEdge,T=f.onTopEdge,p=f.onLeftEdge,y=f.handle,v=f.factor,E=f.revX,m=f.revY,x=f.doW,g=f.doH,b=h||_||T||p,S=u.rotator,M=u.center,O=u.radius;isDef(O)&&removeClass(O,"".concat(LIB_CLASS_PREFIX,"hidden"));var A=y.is(S),N=!!isDef(M)&&y.is(M),R=d&&!(A||b||N),C={mouseEvent:e,clientX:t,clientY:a,doResize:b,doDrag:R,doRotate:A,doSetCenter:N,onExecution:!0,cursor:null,dox:/\x/.test(s)&&(!b||(y.is(u.ml)||y.is(u.mr)||y.is(u.tl)||y.is(u.tr)||y.is(u.bl)||y.is(u.br)||y.is(u.le)||y.is(u.re))),doy:/\y/.test(s)&&(!b||(y.is(u.br)||y.is(u.bl)||y.is(u.bc)||y.is(u.tr)||y.is(u.tl)||y.is(u.tc)||y.is(u.te)||y.is(u.be)))};this.storage=_objectSpread2({},c,{},C);var k={clientX:t,clientY:a};b?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE_START$1,k):A?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE_START$1,k):R&&_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_DRAG_START$1,k);var I=l.move,D=l.resize,P=l.rotate,w=b?E_RESIZE$1:A?E_ROTATE$1:E_DRAG$2,V=b&&D||A&&P||R&&I;n.notify(ON_GETSTATE$2,this,{clientX:t,clientY:a,actionName:w,triggerEvent:V,factor:v,revX:E,revY:m,doW:x,doH:g}),this._draw()}}},{key:"_moving",value:function(e){var t=this.storage,r=void 0===t?{}:t,a=this.options;if(r.isTarget){var o=this._cursorPoint(e),n=o.x,i=o.y;r.mouseEvent=e,r.clientX=n,r.clientY=i,r.doDraw=!0;var s=r.doRotate,l=r.doDrag,c=r.doResize,u=r.cursor,d=a.cursorMove,f=a.cursorResize,h=a.cursorRotate;isUndef(u)&&(l?u=d:s?u=h:c&&(u=f),helper(document.body).css({cursor:u}))}}},{key:"_end",value:function(e){var t=this,a=e.clientX,o=e.clientY,n=this.elements,i=this.options.each,s=this.observable,l=this.storage,c=l.doResize,u=l.doDrag,d=l.doRotate,f=l.doSetCenter,h=l.frame,_=l.handles.radius,T=l.isTarget,p=this.proxyMethods;if(T){var y=([{actionName:E_RESIZE$1,condition:c},{actionName:E_DRAG$2,condition:u},{actionName:E_ROTATE$1,condition:d},{actionName:E_SET_POINT$1,condition:f}].find((function(e){return e.condition}))||{}).actionName,v=void 0===y?E_DRAG$2:y;n.map((function(e){return t._applyTransformToElement(e,v)})),this._processActions(v),this._updateStorage();var E={clientX:a,clientY:o};p.onDrop.call(this,E),c?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE_END$1,E):d?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE_END$1,E):u?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_DRAG_END$1,E):f&&_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_SET_POINT_END$1,E);var m=i.move,x=i.resize,g=i.rotate,b=c&&x||d&&g||u&&m;s.notify(ON_APPLY$2,this,{clientX:a,clientY:o,actionName:v,triggerEvent:b}),cancelAnimFrame(h),helper(document.body).css({cursor:"auto"}),isDef(_)&&addClass(_,"".concat(LIB_CLASS_PREFIX,"hidden"))}}},{key:"_compute",value:function(e,t){var r=this,a=this.storage,o=(a=void 0===a?{}:a).handles,n=a.data,i=helper(e.target),s=this._checkHandles(i,o),l=s.revX,c=s.revY,u=s.doW,d=s.doH,f=_objectWithoutProperties(s,["revX","revY","doW","doH"]),h=this._getCommonState(),_=this._cursorPoint(e),T=_.x,p=_.y,y=this._pointToControls({x:T,y:p},h.transform),v=y.x,E=y.y;t.map((function(e){var t=r._getElementState(e,{revX:l,revY:c,doW:u,doH:d}),a=t.transform,o=_objectWithoutProperties(t,["transform"]),i=r._pointToTransform({x:T,y:p,matrix:a.ctm}),s=i.x,f=i.y;n.set(e,_objectSpread2({},n.get(e),{},o,{transform:a,cx:s,cy:f}))}));var m=Math.atan2(p-h.center.y,T-h.center.x);return _objectSpread2({data:n},f,{handle:values(o).some((function(t){return helper(e.target).is(t)}))?i:helper(t[0]),pressang:m},h,{revX:l,revY:c,doW:u,doH:d,relativeX:T,relativeY:p,bx:v,by:E})}},{key:"_checkHandles",value:function(e,t){var r=function(r){return r.some((function(r){return a=t[r],!!isDef(a)&&e.is(a);var a}))};return{revX:r([TOP_LEFT,MIDDLE_LEFT,BOTTOM_LEFT,TOP_CENTER,LEFT_EDGE]),revY:r([TOP_LEFT,TOP_RIGHT,TOP_CENTER,MIDDLE_LEFT,TOP_EDGE]),onTopEdge:r([TOP_CENTER,TOP_RIGHT,TOP_LEFT,TOP_EDGE]),onLeftEdge:r([TOP_LEFT,MIDDLE_LEFT,BOTTOM_LEFT,LEFT_EDGE]),onRightEdge:r([TOP_RIGHT,MIDDLE_RIGHT,BOTTOM_RIGHT,RIGHT_EDGE]),onBottomEdge:r([BOTTOM_RIGHT,BOTTOM_CENTER,BOTTOM_LEFT,BOTTOM_EDGE]),doW:r([MIDDLE_LEFT,MIDDLE_RIGHT,LEFT_EDGE,RIGHT_EDGE]),doH:r([TOP_CENTER,BOTTOM_CENTER,BOTTOM_EDGE,TOP_EDGE])}}},{key:"_restrictHandler",value:function(e,t){for(var r=null,a=null,o=this.getBoundingRect(e,t),n=this._getRestrictedBBox(),i=_slicedToArray(getMinMaxOfArray(n),2),s=_slicedToArray(i[0],2),l=s[0],c=s[1],u=_slicedToArray(i[1],2),d=u[0],f=u[1],h=0,_=o.length;h<_;h++){var T=_slicedToArray(o[h],2),p=T[0],y=T[1];(pc)&&(r=p),(yf)&&(a=y)}return{x:r,y:a}}},{key:"_destroy",value:function(){var e=this,t=this.elements,r=this.storage,a=(r=void 0===r?{}:r).controls,o=r.wrapper;[].concat(_toConsumableArray(t),[a]).map((function(t){return helper(t).off(E_MOUSEDOWN$1,e._onMouseDown).off(E_TOUCHSTART$1,e._onTouchStart)})),o.parentNode.removeChild(o)}},{key:"_updateStorage",value:function(){var e=this.storage,t=this.storage,r=t.transformOrigin,a=t.transform,o=(a=void 0===a?{}:a).controlsMatrix,n=t.cached,i=(n=void 0===n?{}:n).transformOrigin,s=void 0===i?r:i,l=n.controlsMatrix,c=void 0===l?o:l;this.storage=_objectSpread2({},e,{doResize:!1,doDrag:!1,doRotate:!1,doSetCenter:!1,doDraw:!1,onExecution:!1,cursor:null,transformOrigin:s,controlsMatrix:c,cached:{}})}},{key:"notifyMove",value:function(e){var t=this,a=e.dx,o=e.dy;this.elements.map((function(e){return _get(_getPrototypeOf(r.prototype),"_drag",t).call(t,{element:e,dx:a,dy:o})})),this._processControlsMove({dx:a,dy:o})}},{key:"notifyRotate",value:function(e){var t=this,r=e.radians,a=_objectWithoutProperties(e,["radians"]),o=this.elements,n=this.options,i=(n=void 0===n?{}:n).snap.angle;o.map((function(e){return t._rotate(_objectSpread2({element:e,radians:snapToGrid(r,i)},a))})),this._processControlsRotate({radians:r})}},{key:"notifyResize",value:function(e){var t=this,r=e.dx,a=e.dy,o=e.revX,n=e.revY,i=e.dox,s=e.doy,l=this.elements,c=this.storage.data,u=this.options.isGrouped;l.map((function(e){var l=c.get(e).transform.ctm,d=u?{x:r,y:a}:t._pointToTransform({x:r,y:a,matrix:l}),f=d.x,h=d.y;t._resize({element:e,dx:i?o?-f:f:0,dy:s?n?-h:h:0})})),this._processControlsResize({dx:r,dy:a})}},{key:"notifyApply",value:function(e){var t=this,a=e.clientX,o=e.clientY,n=e.actionName,i=e.triggerEvent;this.proxyMethods.onDrop.call(this,{clientX:a,clientY:o}),i&&(this.elements.map((function(e){return t._applyTransformToElement(e,n)})),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,"".concat(n,"End"),{clientX:a,clientY:o}))}},{key:"notifyGetState",value:function(e){var t=this,a=e.clientX,o=e.clientY,n=e.actionName,i=e.triggerEvent,s=_objectWithoutProperties(e,["clientX","clientY","actionName","triggerEvent"]);if(i){var l=this.elements,c=this.storage.data;l.map((function(e){var r=t._getElementState(e,s);c.set(e,_objectSpread2({},c.get(e),{},r))}));var u=this._getCommonState();this.storage=_objectSpread2({},this.storage,{},u),_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,"".concat(n,"Start"),{clientX:a,clientY:o})}}},{key:"subscribe",value:function(e){var t=e.resize,r=e.move,a=e.rotate,o=this.observable;(r||t||a)&&o.subscribe(ON_GETSTATE$2,this).subscribe(ON_APPLY$2,this),r&&o.subscribe(ON_MOVE$2,this),t&&o.subscribe(ON_RESIZE$2,this),a&&o.subscribe(ON_ROTATE$2,this)}},{key:"unsubscribe",value:function(){var e=this,t=this.observable;NOTIFIER_EVENTS$1.map((function(r){return t.unsubscribe(r,e)}))}},{key:"disable",value:function(){var e=this.storage,t=this.proxyMethods,r=this.elements;isUndef(e)||(e.onExecution&&helper(document).off(E_MOUSEMOVE$2,this._onMouseMove).off(E_MOUSEUP$2,this._onMouseUp).off(E_TOUCHMOVE$2,this._onTouchMove).off(E_TOUCHEND$2,this._onTouchEnd),r.map((function(e){return removeClass(e,"".concat(LIB_CLASS_PREFIX,"drag"))})),this.unsubscribe(),this._destroy(),t.onDestroy.call(this,r),delete this.storage)}},{key:"exeDrag",value:function(e){var t=this,a=e.dx,o=e.dy,n=this.elements,i=this.options.draggable,s=this.storage,l=this.storage.data;if(i){var c=this._getCommonState();n.map((function(e){var r=t._getElementState(e,{revX:!1,revY:!1,doW:!1,doH:!1});l.set(e,_objectSpread2({},l.get(e),{},r))})),this.storage=_objectSpread2({},s,{},c),n.map((function(e){_get(_getPrototypeOf(r.prototype),"_drag",t).call(t,{element:e,dx:a,dy:o}),t._applyTransformToElement(e,E_DRAG$2)})),this._processControlsMove({dx:a,dy:o})}}},{key:"exeResize",value:function(e){var t=this,r=e.dx,a=e.dy,o=e.revX,n=void 0!==o&&o,i=e.revY,s=void 0!==i&&i,l=e.doW,c=void 0!==l&&l,u=e.doH,d=void 0!==u&&u,f=this.elements,h=this.options.resizable,_=this.storage,T=this.storage.data;if(h){var p=this._getCommonState();f.map((function(e){var r=t._getElementState(e,{revX:n,revY:s,doW:c,doH:d});T.set(e,_objectSpread2({},T.get(e),{},r))})),this.storage=_objectSpread2({},_,{},p),f.map((function(e){t._resize({element:e,dx:r,dy:a}),t._applyTransformToElement(e,E_RESIZE$1)})),this._processControlsMove({dx:r,dy:a})}}},{key:"exeRotate",value:function(e){var t=this,r=e.delta,a=this.elements,o=this.options.rotatable,n=this.storage,i=this.storage.data;if(o){var s=this._getCommonState();a.map((function(e){var r=t._getElementState(e,{revX:!1,revY:!1,doW:!1,doH:!1});i.set(e,_objectSpread2({},i.get(e),{},r))})),this.storage=_objectSpread2({},n,{},s),a.map((function(e){t._rotate({element:e,radians:r}),t._applyTransformToElement(e,E_ROTATE$1)})),this._processControlsRotate({radians:r})}}},{key:"setCenterPoint",value:function(){throw Error("'setCenterPoint()' method not implemented")}},{key:"resetCenterPoint",value:function(){warn('"resetCenterPoint" method is replaced by "resetTransformOrigin" and would be removed soon'),this.setTransformOrigin({dx:0,dy:0},!1)}},{key:"setTransformOrigin",value:function(){throw Error("'setTransformOrigin()' method not implemented")}},{key:"resetTransformOrigin",value:function(){this.setTransformOrigin({dx:0,dy:0},!1)}},{key:"controls",get:function(){return this.storage.wrapper}}]),r}(),cloneMatrix=function(e){return e.map((function(e){return _toConsumableArray(e)}))},flatMatrix=function(e){return e.reduce((function(t,r,a){return[].concat(_toConsumableArray(t),[e[0][a],e[1][a],e[2][a],e[3][a]])}),[])},createIdentityMatrix=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;return _toConsumableArray(Array(e)).map((function(e,t,r){return r.map((function(){return+!t--}))}))},createTranslateMatrix=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return createIdentityMatrix().map((function(a,o){return a[3]=[e,t,r,1][o],a}))},createScaleMatrix=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return createIdentityMatrix().map((function(o,n){return o[n]=[e,t,r,a][n],o}))},createRotateMatrix=function(e,t){var r=createIdentityMatrix();return r[0][0]=t,r[0][1]=-e,r[1][0]=e,r[1][1]=t,r},dropTranslate=function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=t?cloneMatrix(e):e;return r[0][3]=r[1][3]=r[2][3]=0,r},multiplyMatrixAndPoint=function(e,t){for(var r=[],a=0,o=e.length;a0;f--)for(var h=f-1;h>=0;h--){t=r[h][f];for(var _=0;_1&&void 0!==arguments[1]?arguments[1]:document.body,r=arguments.length>2?arguments[2]:void 0,a=createIdentityMatrix(),o=e,n=r||getTransform(o),i=!1;o&&o instanceof Element;){var s=getTransformOrigin(o,i);if(a=multiplyMatrix(a,computeTransformMatrix(n,s)),i=!0,o===t||null===o.offsetParent)break;o=o.offsetParent,n=getTransform(o)}return a},decompose=function(e){var t=Math.sqrt(e[0][0]*e[0][0]+e[1][0]*e[1][0]+e[2][0]*e[2][0]),r=Math.sqrt(e[0][1]*e[0][1]+e[1][1]*e[1][1]+e[2][1]*e[2][1]),a=Math.sqrt(e[0][2]*e[0][2]+e[1][2]*e[1][2]+e[2][2]*e[2][2]),o=Math.atan2(-e[0][3]/a,e[1][3]/a),n=Math.asin(e[3][1]/a),i=Math.atan2(-e[3][0]/r,e[0][0]/t);return 1!==e[0][1]&&-1!==e[0][1]||(o=0,n=e[0][1]*-Math.PI/2,i=e[0][1]*Math.atan2(e[1][1]/r,e[0][1]/r)),{rotate:{x:o,y:n,z:i},translate:{x:e[0][3]/t,y:e[1][3]/r,z:e[2][3]/a},scale:{sX:t,sY:r,sZ:a}}},getTransform=function(e){var t=getStyle(e,"transform")||"none",r=createIdentityMatrix();if("none"===t)return r;var a=t.split(/\s*[(),]\s*/).slice(1,-1);if(16!==a.length)return[[+a[0],+a[2],0,+a[4]],[+a[1],+a[3],0,+a[5]],[0,0,1,0],[0,0,0,1]];for(var o=0;o<4;++o)for(var n=0;n<4;++n)r[n][o]=+a[4*o+n];return r},getTransformOrigin=function(e,t){for(var r=getStyle(e,"transform-origin"),a=r?r.split(" "):[],o=[t?-e.clientLeft:0,t?-e.clientTop:0,0,1],n=0;n1&&void 0!==arguments[1]?arguments[1]:document.body,r=0,a=0,o=e,n=!1;o&&o.offsetParent;){var i=getCurrentTransformMatrix(o.offsetParent),s=multiplyMatrixAndPoint(dropTranslate(i,!1),[o.offsetLeft+(n?o.clientLeft:0),o.offsetTop+(n?o.clientTop:0),0,1]),l=_slicedToArray(s,2),c=l[0],u=l[1];if(a+=c,r+=u,t===o)break;n=!0,o=o.offsetParent}return[a,r,0,1]},E_MOUSEDOWN$2=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$2=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,keys$1=Object.keys,entries=Object.entries,values$1=Object.values,Draggable=function(e){_inherits(r,Transformable);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"_init",value:function(e){var t=this,r=this.options,a=r.transformOrigin,o=r.container,n=r.controlsContainer,i=r.resizable,s=r.rotatable,l=r.showNormal,c=r.restrict,u=createElement(["sjx-wrapper"]),d=createElement(["sjx-controls"]),f={},h=this._getVertices(),_=h.rotator,T=void 0===_?null:_,p=h.anchor,y=void 0===p?null:p,v=_objectWithoutProperties(h,["rotator","anchor"]),E={};if(s){var m=l?renderLine([[y.x,y.y],T],"normal"):null;l&&d.appendChild(m);var x=null;a&&(x=renderLine([v.center,v.center],"radius"),addClass(x,"sjx-hidden"),d.appendChild(x)),E=_objectSpread2({},E,{normal:m,radius:x})}var g={te:[v.tl,v.tr],be:[v.bl,v.br],le:[v.tl,v.bl],re:[v.tr,v.br]},b=i?{tl:v.tl,tr:v.tr,br:v.br,bl:v.bl,tc:v.tc,bc:v.bc,ml:v.ml,mr:v.mr}:{},S=Array.isArray(a)?[].concat(_toConsumableArray(a),[0,1]):v.center,M=_objectSpread2({},b,{center:a&&s?S:void 0,rotator:T}),O=function(e,t){return keys$1(e).map((function(r){var a=e[r];if(!isUndef(a)){var o=t(a,r);f[r]=o,d.appendChild(o)}}))};O(g,renderLine),O(M,createHandler),u.appendChild(d),n.appendChild(u);var A=new WeakMap;e.map((function(e){return A.set(e,{parent:e.parentNode,transform:{ctm:getCurrentTransformMatrix(e,o)},bBox:t._getBBox(),__data__:new WeakMap,cached:{}})}));var N=c||o;this.storage={wrapper:u,controls:d,handles:_objectSpread2({},f,{},E),data:A,center:{isShifted:Array.isArray(a)},transformOrigin:S,transform:{containerMatrix:getCurrentTransformMatrix(N,N.parentNode)},cached:{}},[].concat(_toConsumableArray(e),[d]).map((function(e){return helper(e).on(E_MOUSEDOWN$2,t._onMouseDown).on(E_TOUCHSTART$2,t._onTouchStart)}))}},{key:"_pointToTransform",value:function(e){var t=e.x,r=e.y,a=e.matrix,o=matrixInvert(a);return this._applyMatrixToPoint(dropTranslate(o,!1),t,r)}},{key:"_pointToControls",value:function(e){var t=e.x,r=e.y,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.storage.transform,o=a.controlsMatrix,n=matrixInvert(o);return this._applyMatrixToPoint(dropTranslate(n,!1),t,r)}},{key:"_applyMatrixToPoint",value:function(e,t,r){var a=_slicedToArray(multiplyMatrixAndPoint(e,[t,r,0,1]),2);return{x:a[0],y:a[1]}}},{key:"_cursorPoint",value:function(e){var t=e.clientX,r=e.clientY,a=this.options.container,o=getCurrentTransformMatrix(a),n=getElementOffset(a),i=getScrollOffset(),s=i.left,l=i.top,c=createTranslateMatrix(n.left-s,n.top-l);return this._applyMatrixToPoint(matrixInvert(multiplyMatrix(o,c)),t,r)}},{key:"_getRestrictedBBox",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.storage.transform.containerMatrix,r=this.options,a=r.restrict,o=r.container,n=a||o;return _getBoundingRect(n,o,e?getCurrentTransformMatrix(n,o):t)}},{key:"_applyTransformToElement",value:function(e){var t=this.storage,r=t.controls,a=t.data,o=this.options.applyTranslate,n=a.get(e),i=n.cached,s=n.transform.matrix,l=helper(r);if(!isUndef(i)&&o){var c=helper(e),u=i.dx,d=i.dy,f=matrixToCSS(s),h=parseFloat(e.style.left||c.css("left")),_=parseFloat(e.style.top||c.css("top"));f.left="".concat(h+u,"px"),f.top="".concat(_+d,"px"),c.css(f),l.css(f)}}},{key:"_processActions",value:function(){}},{key:"_processResize",value:function(e,t){var r,a,o,n,i,s,l=t.dx,c=t.dy,u=this.storage,d=u.revX,f=u.revY,h=u.doW,_=u.doH,T=u.data,p=u.bBox,y=p.width,v=p.height,E=this.options,m=E.proportions,x=E.scalable,g=T.get(e),b=g.transform,S=b.matrix,M=b.auxiliary.scale.translateMatrix,O=g.cached,A=_slicedToArray(function(e,t){var r=h||!h&&!_?(y+e)/y:(v+t)/v,a=m?y*r:y+e,o=m?v*r:v+t;return[a/y,o/v,a,o]}(l,c),4),N=A[0],R=A[1],C=A[2],k=A[3],I=function(e,t){var r=createScaleMatrix(e,t);return multiplyMatrix(multiplyMatrix(M,r),matrixInvert(M))}(N,R),D=x?multiplyMatrix(I,S):(a=S,o=(r=I)[0][3],n=r[1][3],i=createTranslateMatrix(o,n),s=createTranslateMatrix(o*(d?-1:1),n*(f?-1:1)),multiplyMatrix(multiplyMatrix(s,a),matrixInvert(i)));return C<=MIN_SIZE||k<=MIN_SIZE?{transform:D,width:C,height:k}:(this._updateElementView(e,_objectSpread2({},matrixToCSS(flatMatrix(D)),{},!x&&{width:"".concat(C,"px"),height:"".concat(k,"px")})),T.set(e,_objectSpread2({},g,{cached:_objectSpread2({},O,{dx:l,dy:c,bBox:{width:C,height:k}})})),{transform:D,width:C,height:k})}},{key:"_processMove",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data,n=o.get(e),i=n.transform,s=i.matrix,l=i.auxiliary.translate.parentMatrix,c=n.cached,u=void 0===c?{}:c,d=_slicedToArray(multiplyMatrixAndPoint(l,[r,a,0,1]),2),f=d[0],h=d[1],_=multiplyMatrix(s,createTranslateMatrix(f,h)),T=matrixToCSS(flatMatrix(_));return this._updateElementView(e,T),o.set(e,_objectSpread2({},n,{cached:_objectSpread2({},u,{dist:{dx:floatToFixed(r),dy:floatToFixed(a),ox:floatToFixed(f),oy:floatToFixed(h)}})})),_}},{key:"_processRotate",value:function(e,t){var r=this.storage.data,a=this.options.restrict,o=r.get(e).transform,n=o.matrix,i=o.auxiliary.rotate.translateMatrix,s=floatToFixed(Math.cos(t),4),l=floatToFixed(Math.sin(t),4),c=createRotateMatrix(l,s),u=multiplyMatrix(multiplyMatrix(matrixInvert(i),c),i),d=multiplyMatrix(n,u),f=a?this._restrictHandler(d):{x:null,y:null},h=f.x,_=f.y;return isDef(h)||isDef(_)?d:(this._updateElementView(e,matrixToCSS(flatMatrix(d))),d)}},{key:"_getElementState",value:function(e,t){var r=t.revX,a=t.revY,o=t.doW,n=t.doH,i=this.storage,s=i.handles.center,l=i.data,c=i.transformOrigin,u=this.options,d=u.container,f=u.scalable,h=l.get(e).parent,_=_slicedToArray(getAbsoluteOffset(e,d),2),T=_[0],p=_[1],y=e.offsetLeft,v=e.offsetTop,E=e.offsetWidth,m=e.offsetHeight,x=getTransform(e),g=getCurrentTransformMatrix(e,d),b=getCurrentTransformMatrix(h,d),S=E/2,M=m/2,O=_slicedToArray(multiplyMatrixAndPoint(g,[S,M,0,1]),2),A=n?0:r?-S:S,N=o?0:a?-M:M,R=O[0]+T,C=O[1]+p,k=s?getTransform(s):createIdentityMatrix(),I=_slicedToArray(multiplyMatrixAndPoint(multiplyMatrix(matrixInvert(dropTranslate(g)),dropTranslate(k)),[c[0]-R,c[1]-C,0,1]),2),D=I[0],P=I[1],w=_slicedToArray(multiplyMatrixAndPoint(x,[D,P,0,1]),2),V=w[0],$=w[1],G=decompose(getCurrentTransformMatrix(e,e.parentNode)).scale,L=G.sX,j=G.sY;return{transform:{auxiliary:{scale:{translateMatrix:f?createTranslateMatrix(A,N):createTranslateMatrix(n?0:S,o?0:M)},translate:{parentMatrix:matrixInvert(dropTranslate(b))},rotate:{translateMatrix:createTranslateMatrix(V,$)}},scaleX:A,scaleY:N,matrix:x,ctm:g,parentMatrix:b,scX:L,scY:j},bBox:{width:E,height:m,left:y,top:v,offset:{left:T,top:p}}}}},{key:"_getCommonState",value:function(){var e=this.elements,t=this.storage,r=t.controls,a=t.handles.center,o=t.center,n=t.wrapper,i=this.options,s=i.container,l=i.restrict,c=_slicedToArray(getAbsoluteOffset(e[0],s),2),u=c[0],d=c[1],f=getCurrentTransformMatrix(e[0],s),h=l||s,_=getCurrentTransformMatrix(h,h.parentNode),T=this._getBBox(),p=T.width,y=T.height,v=_slicedToArray(multiplyMatrixAndPoint(f,[p/2,y/2,0,1]),2),E=v[0]+u,m=v[1]+d,x=a?getTransform(a):createIdentityMatrix();return{transform:{controlsMatrix:getCurrentTransformMatrix(r,r.parentNode),containerMatrix:_,wrapperMatrix:getCurrentTransformMatrix(n,s)},bBox:_objectSpread2({},this._getBBox()),center:_objectSpread2({},o,{x:E,y:m,matrix:x})}}},{key:"_getBBox",value:function(){var e=_slicedToArray(this.elements,1)[0],t=this.options,r=t.isGrouped,a=t.container;if(r)return this._getGroupBbox();var o=_slicedToArray(getAbsoluteOffset(e,a),2),n=o[0],i=o[1];return{x:e.offsetLeft,y:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight,offset:{left:n,top:i}}}},{key:"_processControlsResize",value:function(){var e=this._applyTransformToHandles().center,t=this.storage.transform.controlsMatrix;e&&(this.storage=_objectSpread2({},this.storage,{cached:{transformOrigin:multiplyMatrixAndPoint(t,e)}}))}},{key:"_processControlsMove",value:function(e){var t=e.dx,r=e.dy,a=this.storage,o=a.transform,n=o.controlsMatrix,i=o.wrapperMatrix,s=a.center,l=a.transformOrigin,c=multiplyMatrix(n,createTranslateMatrix(t,r));this._updateControlsView(c);var u=dropTranslate(matrixInvert(i)),d=_slicedToArray(multiplyMatrixAndPoint(u,[t,r,0,1]),2),f=d[0],h=d[1];if(s.isShifted)this._moveCenterHandle(-f,-h,!1);else{var _=createTranslateMatrix(f,h);this.storage=_objectSpread2({},this.storage,{cached:{transformOrigin:multiplyMatrixAndPoint(_,l)}})}}},{key:"_processControlsRotate",value:function(){this._applyTransformToHandles()}},{key:"_moveCenterHandle",value:function(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],a=this.storage,o=a.handles.center,n=a.center.matrix,i=a.center,s=a.transformOrigin,l=createTranslateMatrix(e,t),c=multiplyMatrix(n,l);helper(o).css(_objectSpread2({},matrixToCSS(flatMatrix(c)))),this.storage=_objectSpread2({},this.storage,{center:_objectSpread2({},i,{isShifted:!0})},r?{cached:{transformOrigin:multiplyMatrixAndPoint(l,s)}}:{})}},{key:"_processMoveRestrict",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data.get(e).transform,n=o.matrix,i=o.auxiliary.translate.parentMatrix,s=_slicedToArray(multiplyMatrixAndPoint(i,[r,a,0,1]),2),l=s[0],c=s[1],u=multiplyMatrix(n,createTranslateMatrix(l,c));return this._restrictHandler(u)}},{key:"_processRotateRestrict",value:function(e,t){var r=this.storage.data.get(e).transform,a=r.matrix,o=r.auxiliary.rotate.translateMatrix,n=floatToFixed(Math.cos(t),4),i=floatToFixed(Math.sin(t),4),s=createRotateMatrix(i,n),l=multiplyMatrix(multiplyMatrix(matrixInvert(o),s),o),c=multiplyMatrix(a,l);return this._restrictHandler(c)}},{key:"_processResizeRestrict",value:function(e,t){var r,a,o,n,i,s,l,c,u,d,f,h,_=t.dx,T=t.dy,p=this.storage,y=p.revX,v=p.revY,E=p.doW,m=p.doH,x=p.data,g=p.bBox,b=g.width,S=g.height,M=this.options,O=M.proportions,A=M.scalable,N=x.get(e).transform,R=N.matrix,C=N.auxiliary.scale.translateMatrix,k=_slicedToArray((r=_,a=T,o=E||!E&&!m?(b+r)/b:(S+a)/S,[(n=O?b*o:b+r)/b,(i=O?S*o:S+a)/S,n,i]),2),I=k[0],D=k[1],P=(s=createScaleMatrix(I,D),multiplyMatrix(multiplyMatrix(C,s),matrixInvert(C))),w=A?multiplyMatrix(P,R):(c=R,u=(l=P)[0][3],d=l[1][3],f=createTranslateMatrix(u,d),h=createTranslateMatrix(u*(y?-1:1),d*(v?-1:1)),multiplyMatrix(multiplyMatrix(h,c),matrixInvert(f)));return this._restrictHandler(w)}},{key:"_updateElementView",value:function(e,t){helper(e).css(t)}},{key:"_updateControlsView",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createIdentityMatrix(),t=matrixToCSS(flatMatrix(e));helper(this.storage.controls).css(t),this.storage.cached.controlsMatrix=e}},{key:"_getVertices",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createIdentityMatrix(),t=this.elements,r=_slicedToArray(t=void 0===t?[]:t,1),a=r[0],o=this.options,n=o.isGrouped,i=o.rotatable,s=o.rotatorAnchor,l=o.rotatorOffset,c=n?this._getGroupVertices():this._getElementVertices(a,e),u=null;if(i){var d={},f=1;switch(s){case"n":d.x=c.tc[0],d.y=c.tc[1];break;case"s":d.x=c.bc[0],d.y=c.bc[1],f=-1;break;case"w":d.x=c.ml[0],d.y=c.ml[1],f=-1;break;case"e":default:d.x=c.mr[0],d.y=c.mr[1]}var h="n"===s||"s"===s?Math.atan2(c.bl[1]-c.tl[1],c.bl[0]-c.tl[0]):Math.atan2(c.tl[1]-c.tr[1],c.tl[0]-c.tr[0]);u=[d.x-l*f*Math.cos(h),d.y-l*f*Math.sin(h)],c.rotator=u,c.anchor=d}return c}},{key:"_getElementVertices",value:function(e,t){var r=this.options,a=r.container,o=r.isGrouped,n=_slicedToArray(getAbsoluteOffset(e,a),2),i=n[0],s=n[1],l=e.offsetWidth,c=e.offsetHeight,u={tl:[0,0,0,1],bl:[0,c,0,1],br:[l,c,0,1],tr:[l,0,0,1],tc:[l/2,0,0,1],ml:[0,c/2,0,1],bc:[l/2,c,0,1],mr:[l,c/2,0,1],center:[l/2,c/2,0,1]},d=o?t:multiplyMatrix(getCurrentTransformMatrix(e,a),t);return entries(u).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=r[1];return[].concat(_toConsumableArray(e),[[a,multiplyMatrixAndPoint(d,o)]])}),[]).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=_slicedToArray(r[1],4),n=o[0],l=o[1],c=o[2],u=o[3];return e[a]=[n+i,l+s,c,u],e}),{})}},{key:"_getGroupVertices",value:function(){var e=this._getGroupBbox(),t=e.x,r=e.y,a=e.width,o=e.height,n=a/2,i=o/2;return{tl:[t,r],tr:[t+a,r],mr:[t+a,r+i],ml:[t,r+i],tc:[t+n,r],bc:[t+n,r+o],br:[t+a,r+o],bl:[t,r+o],center:[t+n,r+i]}}},{key:"_getGroupBbox",value:function(){var e=this.elements,t=this.options.container,r=e.reduce((function(e,r){var a=_slicedToArray(getAbsoluteOffset(r,t),2),o=a[0],n=a[1],i=r.offsetWidth,s=r.offsetHeight,l=[[0,0,0,1],[0,s,0,1],[i,s,0,1],[i,0,0,1]],c=getCurrentTransformMatrix(r,t),u=l.reduce((function(e,t){return[].concat(_toConsumableArray(e),[multiplyMatrixAndPoint(c,t)])}),[]).map((function(e){var t=_slicedToArray(e,4),r=t[0],a=t[1],i=t[2],s=t[3];return[r+o,a+n,i,s]}));return[].concat(_toConsumableArray(e),[u])}),[]),a=_slicedToArray(getMinMaxOfArray(r.reduce((function(e,t){return[].concat(_toConsumableArray(e),_toConsumableArray(t))}),[])),2),o=_slicedToArray(a[0],2),n=o[0],i=o[1],s=_slicedToArray(a[1],2),l=s[0];return{x:n,y:l,width:i-n,height:s[1]-l}}},{key:"_getElementBBox",value:function(e){var t=this.options.container,r=_slicedToArray(getAbsoluteOffset(e,t),2),a=r[0],o=r[1],n=e.offsetWidth,i=e.offsetHeight,s=[[0,0,0,1],[0,i,0,1],[n,i,0,1],[n,0,0,1]],l=getCurrentTransformMatrix(e,t),c=s.reduce((function(e,t){return[].concat(_toConsumableArray(e),[multiplyMatrixAndPoint(l,t)])}),[]).map((function(e){var t=_slicedToArray(e,4),r=t[0],n=t[1],i=t[2],s=t[3];return[r+a,n+o,i,s]})),u=_slicedToArray(getMinMaxOfArray(c),2),d=_slicedToArray(u[0],2),f=d[0],h=d[1],_=_slicedToArray(u[1],2),T=_[0];return{x:f,y:T,width:h-f,height:_[1]-T}}},{key:"_applyTransformToHandles",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.boxMatrix,r=void 0===t?createIdentityMatrix():t,a=this.options,o=a.rotatable,n=a.resizable,i=a.showNormal,s=this.storage,l=s.handles,c=s.controls,u=s.center,d=(u=void 0===u?{}:u).isShifted,f=void 0!==d&&d,h=s.transform,_=(h=void 0===h?{}:h).controlsMatrix,T=void 0===_?getCurrentTransformMatrix(c,c.parentNode):_,p=multiplyMatrix(r,matrixInvert(T)),y=this._getVertices(p),v=y.anchor,E=void 0===v?null:v,m=y.center,x=_objectWithoutProperties(y,["anchor","center"]),g=null,b={};o&&(g=i?[[E.x,E.y],x.rotator]:null,b={rotator:x.rotator});var S=_objectSpread2({te:[x.tl,x.tr],be:[x.bl,x.br],le:[x.tl,x.bl],re:[x.tr,x.br]},i&&g&&{normal:g});keys$1(S).forEach((function(e){var t=_slicedToArray(S[e],2),r=t[0],a=t[1],o=getLineAttrs(r,a),n=o.cx,i=o.cy,s=o.length,c=o.theta;helper(l[e]).css({transform:"translate(".concat(n,"px, ").concat(i,"px) rotate(").concat(c,"deg)"),width:"".concat(s,"px")})}));var M=_objectSpread2({},n&&x,{},b,{},!f&&Boolean(m)&&{center:m});return keys$1(M).reduce((function(e,t){var r=l[t],a=M[t];if(e[t]=a,isUndef(a)||isUndef(r))return e;var o=_slicedToArray(a,2),n=o[0],i=o[1];return helper(r).css({transform:"translate(".concat(n,"px, ").concat(i,"px)")}),e}),{})}},{key:"setCenterPoint",value:function(){warn('"setCenterPoint" method is replaced by "setTransformOrigin" and would be removed soon'),this.setTransformOrigin.apply(this,arguments)}},{key:"setTransformOrigin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.x,r=e.y,a=e.dx,o=e.dy,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.elements,s=_slicedToArray(i=void 0===i?[]:i,1),l=s[0],c=this.storage,u=this.storage,d=(u=void 0===u?{}:u).wrapper,f=u.handles.center,h=u.center,_=this.options,T=(_=void 0===_?{}:_).container,p=isDef(a)&&isDef(o),y=isDef(t)&&isDef(r);if(f&&h&&(p||y)){var v,E,m=multiplyMatrix(getCurrentTransformMatrix(l,T),matrixInvert(getCurrentTransformMatrix(d,d.parentNode))),x=getAbsoluteOffset(l,T),g=_slicedToArray(x,2),b=g[0],S=g[1];if(p){var M=l.offsetHeight,O=l.offsetWidth,A=O/2-a,N=M/2-o,R=multiplyMatrixAndPoint(m,[A,N,0,1]),C=_slicedToArray(R,2);v=C[0],E=C[1]}else v=t,E=r;helper(f).css({transform:"translate(".concat(v+b,"px, ").concat(E+S,"px)")}),h.isShifted=n,c.transformOrigin=multiplyMatrixAndPoint(createIdentityMatrix(),[v,E,0,1])}}},{key:"fitControlsToSize",value:function(){var e=this.storage,t=e.controls,r=e.center,a=(r=void 0===r?{}:r).isShifted,o=_slicedToArray(e.transformOrigin,2),n=o[0],i=o[1],s=getCurrentTransformMatrix(t,t.parentNode),l=_slicedToArray(multiplyMatrixAndPoint(s,[n,i,0,1]),2),c=l[0],u=l[1],d=[{nextValues:function(){return{x:c,y:u}},pin:!0,condition:function(){return a}},{nextValues:function(){return{dx:0,dy:0}},pin:!1,condition:function(){return!a}}].find((function(e){return(0,e.condition)()})),f=d.nextValues,h=d.pin;this._updateControlsView(),this.setTransformOrigin(_objectSpread2({},f()),h),this._applyTransformToHandles()}},{key:"getBoundingRect",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this.elements,r=_slicedToArray(t=void 0===t?[]:t,1),a=r[0],o=this.options,n=o.scalable,i=o.restrict,s=o.container,l=this.storage,c=l.bBox,u=l.bBox,d=(u=void 0===u?{}:u).width,f=u.height,h=l.cached,_=(h=void 0===h?{}:h).bBox,T=(_=void 0===_?{}:_).width,p=void 0===T?d:T,y=_.height,v=void 0===y?f:y,E=n?c:_objectSpread2({},c,{width:p,height:v}),m=i||s;return _getBoundingRect(a,m,getCurrentTransformMatrix(a,m,e),E)}},{key:"applyAlignment",value:function(e){var t=this,r=this.elements,a=this.options.container,o=this._getVertices(),n=(o.anchor,o.rotator,o.center,_objectWithoutProperties(o,["anchor","rotator","center"])),i=this._getRestrictedBBox(!0),s=values$1(n),l=_slicedToArray(getMinMaxOfArray(i),2),c=_slicedToArray(l[0],2),u=c[0],d=c[1],f=_slicedToArray(l[1],2),h=f[0],_=f[1],T=_slicedToArray(getMinMaxOfArray(s),2),p=_slicedToArray(T[0],2),y=p[0],v=p[1],E=_slicedToArray(T[1],2),m=E[0],x=E[1],g=_slicedToArray(multiplyMatrixAndPoint(matrixInvert(dropTranslate(getCurrentTransformMatrix(r[0].parentNode,a))),[function(){switch(!0){case/[l]/.test(e):return u-y;case/[r]/.test(e):return d-v;case/[h]/.test(e):return(d+u)/2-(v+y)/2;default:return 0}}(),function(){switch(!0){case/[t]/.test(e):return h-m;case/[b]/.test(e):return _-x;case/[v]/.test(e):return(_+h)/2-(x+m)/2;default:return 0}}(),0,1]),2),b=g[0],S=g[1],M=multiplyMatrix(getTransform(r[0]),createTranslateMatrix(b,S));r.map((function(e){return t._updateElementView(e,matrixToCSS(flatMatrix(M)))})),this.fitControlsToSize()}},{key:"getDimensions",value:function(){var e=this.elements,t=_slicedToArray(e=void 0===e?[]:e,1)[0],r=this.options.isGrouped?this._getGroupVertices():this._getElementVertices(t,createIdentityMatrix()),a=r.tl,o=r.tr,n=r.br;return{x:floatToFixed(a[0]),y:floatToFixed(a[1]),width:floatToFixed(Math.sqrt(Math.pow(a[0]-o[0],2)+Math.pow(a[1]-o[1],2))),height:floatToFixed(Math.sqrt(Math.pow(o[0]-n[0],2)+Math.pow(o[1]-n[1],2))),rotation:floatToFixed(Math.atan2(o[1]-a[1],o[0]-a[0])*DEG)}}}]),r}(),createHandler=function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1],o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"handler",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=createElement(["sjx-hdl","sjx-hdl-".concat(o)]);return helper(i).css(_objectSpread2({transform:"translate(".concat(r,"px, ").concat(a,"px)")},n)),i},renderLine=function(e,t){var r=_slicedToArray(e,3),a=r[0],o=r[1],n=r[2],i=void 0===n?1:n,s=getLineAttrs(a,o,i),l=s.cx,c=s.cy,u=s.length,d=s.theta,f=createElement(["sjx-hdl-line","sjx-hdl-".concat(t)]);return helper(f).css({transform:"translate(".concat(l,"px, ").concat(c,"px) rotate(").concat(d,"deg)"),height:"".concat(i,"px"),width:"".concat(u,"px")}),f},getLineAttrs=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,a=_slicedToArray(e,2),o=a[0],n=a[1],i=_slicedToArray(t,2),s=i[0],l=i[1],c=Math.sqrt((s-o)*(s-o)+(l-n)*(l-n)),u=(o+s)/2-c/2,d=(n+l)/2-r/2,f=Math.atan2(n-l,o-s)*(180/Math.PI);return{cx:u,cy:d,thickness:r,theta:f,length:c}},_getBoundingRect=function(e,t,r,a){var o=_slicedToArray(getAbsoluteOffset(e,t),2),n=o[0],i=o[1],s=a||{width:e.offsetWidth,height:e.offsetHeight,offset:{left:n,top:i}},l=s.width,c=s.height,u=s.offset,d=(u=void 0===u?{}:u).left,f=u.top;return[[0,0,0,1],[l,0,0,1],[0,c,0,1],[l,c,0,1]].reduce((function(e,t){return[].concat(_toConsumableArray(e),[multiplyMatrixAndPoint(r,t)])}),[]).map((function(e){var t=_slicedToArray(e,4),r=t[0],a=t[1],o=t[2],n=t[3];return[r+d,a+f,o,n]}))},createElement=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=document.createElement("div");return e.forEach((function(e){return addClass(t,e)})),t},sepRE=/\s*,\s*|\s+/g,allowedElements=["circle","ellipse","image","line","path","polygon","polyline","rect","text","g","foreignobject","use"];function createSVGElement(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],r=document.createElementNS("http://www.w3.org/2000/svg",e);return t.forEach((function(e){return addClass(r,e)})),r}var createSVGPoint=function(e,t){var r=createSVGElement("svg").createSVGPoint();return r.x=e,r.y=t,r},checkChildElements=function e(t){var r=[];return isSVGGroup(t)?forEach.call(t.childNodes,(function(t){if(1===t.nodeType){var a=t.tagName.toLowerCase();-1!==allowedElements.indexOf(a)&&("g"===a&&r.push.apply(r,_toConsumableArray(e(t))),r.push(t))}})):r.push(t),r},createSVGMatrix=function(){return createSVGElement("svg").createSVGMatrix()},createTranslateMatrix$1=function(e,t){var r=createSVGMatrix();return r.e=e,r.f=t,r},createRotateMatrix$1=function(e,t){var r=createSVGMatrix();return r.a=t,r.b=e,r.c=-e,r.d=t,r},createScaleMatrix$1=function(e,t){var r=createSVGMatrix();return r.a=e,r.d=t,r},getTransformToElement=function(e,t){return(t.getScreenCTM&&t.getScreenCTM()||createSVGMatrix()).inverse().multiply(e.getScreenCTM()||createSVGMatrix())},matrixToString=function(e){var t=e.a,r=e.b,a=e.c,o=e.d,n=e.e,i=e.f;return"matrix(".concat(t,",").concat(r,",").concat(a,",").concat(o,",").concat(n,",").concat(i,")")},pointTo=function(e,t,r){return createSVGPoint(t,r).matrixTransform(e)},cloneMatrix$1=function(e){var t=createSVGMatrix();return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.e=e.e,t.f=e.f,t},isIdentity=function(e){var t=e.a,r=e.b,a=e.c,o=e.d,n=e.e,i=e.f;return 1===t&&0===r&&0===a&&1===o&&0===n&&0===i},checkElement=function(e){var t=e.tagName.toLowerCase();return-1!==allowedElements.indexOf(t)||(warn('Selected element "'.concat(t,'" is not allowed to transform. Allowed elements:\n\n circle, ellipse, image, line, path, polygon, polyline, rect, text, g')),!1)},isSVGGroup=function(e){return"g"===e.tagName.toLowerCase()},normalizeString=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.replace(/[\n\r]/g,"").replace(/([^e])-/g,"$1 -").replace(/ +/g," ").replace(/(\d*\.)(\d+)(?=\.)/g,"$1$2 ")},parsePoints=function(e){return normalizeString(e).trim().split(sepRE).reduce((function(e,t,r,a){return r%2==0&&e.push(a.slice(r,r+2)),e}),[])},arrayToChunks=function(e,t){return Array.from(new Array(Math.ceil(e.length/t)),(function(r,a){return e.slice(a*t,a*t+t)}))},dRE=/\s*([achlmqstvz])([^achlmqstvz]*)\s*/gi,getCommandValuesLength=function(e){return[{size:2,condition:["M","m","L","l","T","t"].includes(e)},{size:1,condition:["H","h","V","v"].includes(e)},{size:6,condition:["C","c"].includes(e)},{size:4,condition:["S","s","Q","q"].includes(e)},{size:7,condition:["A","a"].includes(e)},{size:1,condition:!0}].find((function(e){return!!e.condition}))},parsePath=function(e){for(var t=dRE.lastIndex=0,r=[],a=function(){var e=_slicedToArray(t,3),a=e[1],o=e[2],n=a.toUpperCase(),i=a!==n,s=normalizeString(o).trim().split(sepRE).map((function(e){if(!isNaN(e))return Number(e)})),l=!1,c="M"===n,u=getCommandValuesLength(a).size;arrayToChunks(s,u).map((function(e){var t=l&&c;return l=l||c,r.push({relative:i,key:t?"L":n,cmd:t?i?"l":"L":a,values:e})}))};t=dRE.exec(e);)a();return reducePathData(absolutizePathData(r))},movePath=function(e){var t=e.path,r=e.dx,a=e.dy;try{for(var o=parsePath(t),n="",i=" ",s=!0,l=0,c=o.length;l1&&(n*=b=Math.sqrt(b),i*=b);var S=n*n,M=i*i,O=S*M-S*g*g-M*x*x,A=S*g*g+M*x*x,N=(l===c?-1:1)*Math.sqrt(Math.abs(O/A));_=N*n*g/i+(t+a)/2,T=N*-i*x/n+(r+o)/2,f=Math.asin(parseFloat(((r-T)/i).toFixed(9))),h=Math.asin(parseFloat(((o-T)/i).toFixed(9))),t<_&&(f=Math.PI-f),a<_&&(h=Math.PI-h),f<0&&(f=2*Math.PI+f),h<0&&(h=2*Math.PI+h),c&&f>h&&(f-=2*Math.PI),!c&&h>f&&(h-=2*Math.PI)}var R=h-f;if(Math.abs(R)>120*Math.PI/180){var C=h,k=a,I=o,D=c&&h>f?1:-1;h=f+120*Math.PI/180*D,a=_+n*Math.cos(h),o=T+i*Math.sin(h),v=e(a,o,k,I,n,i,s,0,c,[h,C,_,T])}R=h-f;var P=Math.cos(f),w=Math.sin(f),V=Math.cos(h),$=Math.sin(h),G=Math.tan(R/4),L=4/3*n*G,j=4/3*i*G,F=[t,r],H=[t+L*w,r-j*P],U=[a+L*$,o-j*V],B=[a,o];if(H[0]=2*F[0]-H[0],H[1]=2*F[1]-H[1],u)return[H,U,B].concat(_toConsumableArray(v));v=[H,U,B].concat(_toConsumableArray(v)).join().split(",");var Y=[],z=[];return v.forEach((function(e,t){t%2?z.push(p(v[t-1],v[t],y).y):z.push(p(v[t],v[t+1],y).x),6===z.length&&(Y.push(z),z=[])})),Y},E_DRAG$3=EVENT_EMITTER_CONSTANTS.E_DRAG,E_RESIZE$2=EVENT_EMITTER_CONSTANTS.E_RESIZE,E_ROTATE$2=EVENT_EMITTER_CONSTANTS.E_ROTATE,E_MOUSEDOWN$3=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$3=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,keys$2=Object.keys,entries$1=Object.entries,values$2=Object.values,DraggableSVG=function(e){_inherits(r,Transformable);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"_init",value:function(e){var t=this,r=this.options,a=r.container,o=r.controlsContainer,n=r.resizable,i=r.rotatable,s=r.showNormal,l=r.transformOrigin,c=r.restrict,u=createSVGElement("g",["sjx-svg-wrapper"]),d=createSVGElement("g",["sjx-svg-controls"]),f=this._getVertices(),h=f.rotator,_=void 0===h?null:h,T=f.anchor,p=void 0===T?null:T,y=_objectWithoutProperties(f,["rotator","anchor"]),v={},E={},m=Array.isArray(l)?pointTo(createSVGMatrix(),l[0],l[1]):y.center;if(i){var x=s?renderLine$1([p,_],THEME_COLOR,"normal"):null;s&&d.appendChild(x);var g=null;l&&((g=createSVGElement("line",["sjx-hidden"])).x1.baseVal.value=y.center.x,g.y1.baseVal.value=y.center.y,g.x2.baseVal.value=m.x,g.y2.baseVal.value=m.y,setLineStyle(g,"#fe3232"),g.setAttribute("opacity",.5),d.appendChild(g)),E=_objectSpread2({},E,{normal:x,radius:g})}var b=n?{tl:y.tl,tr:y.tr,br:y.br,bl:y.bl,tc:y.tc,bc:y.bc,ml:y.ml,mr:y.mr}:{},S={te:[y.tl,y.tr],be:[y.bl,y.br],le:[y.tl,y.bl],re:[y.tr,y.br]};keys$2(S).forEach((function(e){var t=S[e];isUndef(t)||(v[e]=renderLine$1(t,THEME_COLOR,e),d.appendChild(v[e]))}));var M=_objectSpread2({},b,{rotator:_,center:l&&i?m:void 0});keys$2(M).forEach((function(e){var t=M[e];if(!isUndef(t)){var r=t.x,a=t.y,o="center"===e?"#fe3232":THEME_COLOR;v[e]=createHandler$1(r,a,o,e),d.appendChild(v[e])}})),u.appendChild(d),o.appendChild(u);var O=new WeakMap;e.map((function(e){return O.set(e,{parent:e.parentNode,transform:{ctm:getTransformToElement(e,a)},bBox:e.getBBox(),__data__:new WeakMap,cached:{}})}));var A=c||a;this.storage={wrapper:u,controls:d,handles:_objectSpread2({},v,{},E),data:O,center:{isShifted:Array.isArray(l)},transformOrigin:m,transform:{containerMatrix:getTransformToElement(A,A.parentNode)},cached:{}},[].concat(_toConsumableArray(e),[d]).map((function(e){return helper(e).on(E_MOUSEDOWN$3,t._onMouseDown).on(E_TOUCHSTART$3,t._onTouchStart)}))}},{key:"_cursorPoint",value:function(e){var t=e.clientX,r=e.clientY,a=this.options.container;return this._applyMatrixToPoint(a.getScreenCTM().inverse(),t,r)}},{key:"_getRestrictedBBox",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.storage,r=(t=void 0===t?{}:t).transform,a=(r=void 0===r?{}:r).containerMatrix,o=this.options,n=(o=void 0===o?{}:o).container,i=o.restrict,s=i||n;return _getBoundingRect$1(s,e?getTransformToElement(s,n):a)}},{key:"_pointToTransform",value:function(e){var t=e.x,r=e.y,a=e.matrix.inverse();return a.e=a.f=0,this._applyMatrixToPoint(a,t,r)}},{key:"_pointToControls",value:function(e){var t=e.x,r=e.y,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.storage.transform,o=a.controlsMatrix,n=o.inverse();return n.e=n.f=0,this._applyMatrixToPoint(n,t,r)}},{key:"_applyMatrixToPoint",value:function(e,t,r){var a=createSVGElement("svg").createSVGPoint();return a.x=t,a.y=r,a.matrixTransform(e)}},{key:"_applyTransformToElement",value:function(e,t){var r=this.storage,a=(r=void 0===r?{}:r).data,o=r.bBox,n=this.options,i=(n=void 0===n?{}:n).isGrouped,s=n.scalable,l=n.applyTranslate,c=a.get(e),u=c.cached,d=void 0===u?{}:u,f=_objectWithoutProperties(c,["cached"]),h=f.transform,_=h.matrix,T=h.parentMatrix,p=f.__data__,y=d.scaleX,v=d.scaleY,E=d.dist,m=(E=void 0===E?{}:E).dx,x=E.dy,g=E.ox,b=E.oy,S=d.transformMatrix;if(t===E_DRAG$3){if(!l||!m&&!x)return;var M=createTranslateMatrix$1(g,b),O=M.multiply(_).multiply(M.inverse());this._updateElementView(["transform",O]),isSVGGroup(e)?checkChildElements(e).map((function(e){var t=createTranslateMatrix$1(m,x),r=t.multiply(getTransformToElement(e,e.parentNode)).multiply(t.inverse());if(isIdentity(r)||e.setAttribute("transform",matrixToString(r)),!isSVGGroup(e)){var a=T.inverse();a.e=a.f=0;var o=pointTo(a,g,b),n=o.x,i=o.y;applyTranslate(e,{x:n,y:i})}})):applyTranslate(e,{x:g,y:b})}if(t===E_RESIZE$2){if(!S)return;if(!s)if(isSVGGroup(e)||i)checkChildElements(e).forEach((function(t){if(!isSVGGroup(t)){var r=getTransformToElement(t,i?e.parentNode:e),a=r.inverse().multiply(S).multiply(r);applyResize(t,{dx:m,dy:x,scaleX:y,scaleY:v,localCTM:a,transformMatrix:S,bBox:o,__data__:p,isGrouped:i})}}));else applyResize(e,{dx:m,dy:x,scaleX:y,scaleY:v,localCTM:S,transformMatrix:S,bBox:o,__data__:p,isGrouped:i})}a.set(e,_objectSpread2({},f))}},{key:"_processActions",value:function(e){var t=this.storage,r=t.transform.controlsMatrix,a=t.center,o=(a=void 0===a?{}:a).isShifted;if(this.options.isGrouped&&e===E_ROTATE$2){this._applyTransformToHandles();var n=pointTo(r,0,0),i=n.x,s=n.y;o&&this._moveCenterHandle(i,s),this._updateControlsView(),o||this.setTransformOrigin({dx:0,dy:0},!1)}}},{key:"_processResize",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage,n=o.revX,i=o.revY,s=o.doW,l=o.doH,c=o.data,u=o.bBox,d=u.x,f=u.y,h=u.width,_=u.height,T=this.options,p=T.isGrouped,y=T.proportions,v=T.scalable,E=c.get(e),m=E.transform,x=m.matrix,g=m.auxiliary.scale.translateMatrix,b=E.cached,S=void 0===b?{}:b,M=_slicedToArray(function(e,t){var r=Math.max(1,h),a=Math.max(1,_),o=s||!s&&!l?(r+e)/r:(a+t)/a,n=y?r*o:r+e,i=y?a*o:a+t;return[n/r,i/a,n,i]}(r,a),4),O=M[0],A=M[1],N=M[2],R=M[3],C=function(e,t){var r=createScaleMatrix$1(e,t);return g.multiply(r).multiply(g.inverse())}(O,A),k=d-(N-h)*(l?.5:n?1:0),I=f-(R-_)*(s?.5:i?1:0),D=p?C.multiply(x):x.multiply(C);return v&&this._updateElementView(e,["transform",D]),c.set(e,_objectSpread2({},E,{cached:_objectSpread2({},S,{scaleX:O,scaleY:A,transformMatrix:C,resultMatrix:D})})),this._applyTransformToElement(e,E_RESIZE$2),{x:k,y:I,width:N,height:R,transform:D}}},{key:"_processMove",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data,n=o.get(e),i=n.transform,s=i.matrix,l=i.auxiliary.translate,c=l.translateMatrix,u=l.parentMatrix,d=n.cached;u.e=u.f=0;var f=pointTo(u,r,a),h=f.x,_=f.y;o.set(e,_objectSpread2({},n,{cached:_objectSpread2({},d,{dist:{dx:floatToFixed(r),dy:floatToFixed(a),ox:floatToFixed(h),oy:floatToFixed(_)}})})),c.e=h,c.f=_;var T=c.multiply(s);return this._updateElementView(e,["transform",T]),T}},{key:"_processRotate",value:function(e,t){var r=this.storage,a=(r=void 0===r?{}:r).data.get(e).transform,o=a.matrix,n=a.parentMatrix,i=a.auxiliary.rotate.translateMatrix,s=floatToFixed(Math.cos(t)),l=floatToFixed(Math.sin(t)),c=createRotateMatrix$1(l,s);n.e=n.f=0;var u=n.inverse().multiply(c).multiply(n),d=i.multiply(u).multiply(i.inverse()).multiply(o);return this._updateElementView(e,["transform",d]),d}},{key:"_getElementState",value:function(e,t){var r=t.revX,a=t.revY,o=t.doW,n=t.doH,i=this.options,s=i.container,l=i.isGrouped,c=this.storage,u=c.data,d=c.controls,f=c.handles.center,h=c.transformOrigin,_=h.x,T=h.y,p=u.get(e),y=p.__data__;storeElementAttributes(e,p,s),y.delete(e),checkChildElements(e).forEach((function(t){y.delete(t),storeElementAttributes(t,p,e,l)}));var v=this._getBBox(),E=v.x,m=v.y,x=v.width,g=v.height,b=getTransformToElement(e,e.parentNode),S=getTransformToElement(e,s),M=getTransformToElement(e.parentNode,s),O=M.inverse(),A=E+x*(n?.5:r?1:0),N=m+g*(o?.5:a?1:0),R=getTransformToElement(d,s),C=E+x/2,k=m+g/2,I=pointTo(R,_,T),D=I.x,P=I.y,w=f?pointTo(O,D,P):pointTo(l?O:b,C,k),V=w.x,$=w.y,G=f?pointTo(l?O:S.inverse(),D,P):pointTo(l?O:createSVGMatrix(),A,N),L=G.x,j=G.y;return{transform:{auxiliary:{scale:{scaleMatrix:createSVGMatrix(),translateMatrix:createTranslateMatrix$1(L,j)},translate:{parentMatrix:O,translateMatrix:createSVGMatrix()},rotate:{translateMatrix:createTranslateMatrix$1(V,$)}},matrix:b,ctm:S,parentMatrix:M,scX:Math.sqrt(S.a*S.a+S.b*S.b),scY:Math.sqrt(S.c*S.c+S.d*S.d)},bBox:v}}},{key:"_getCommonState",value:function(){var e=this.elements,t=this.options,r=t.isGrouped,a=t.container,o=t.restrict,n=this.storage,i=n.controls,s=n.handles.center,l=this._getBBox(),c=l.x,u=l.y,d=c+l.width/2,f=u+l.height/2,h=getTransformToElement(i,a),_=s?s.cx.baseVal.value:d,T=s?s.cy.baseVal.value:f,p=pointTo(h,_,T),y=p.x,v=p.y,E=pointTo(r?createSVGMatrix():getTransformToElement(e[0],a),d,f),m=E.x,x=E.y,g=o||a,b=getTransformToElement(g,g.parentNode),S=_objectSpread2({},this.storage.center||{},{x:s?y:m,y:s?v:x,hx:s?s.cx.baseVal.value:null,hy:s?s.cy.baseVal.value:null});return{transform:{containerMatrix:b,controlsMatrix:getTransformToElement(i,i.parentNode),controlsTranslateMatrix:createSVGMatrix(),wrapperOriginMatrix:createTranslateMatrix$1(S.x,S.y)},bBox:l,center:S}}},{key:"_getVertices",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createSVGMatrix(),t=this.elements,r=this.options,a=r.isGrouped,o=r.rotatable,n=r.rotatorAnchor,i=r.rotatorOffset,s=r.container,l=this._getBBox(),c=l.x,u=l.y,d=l.width,f=l.height,h=d/2,_=f/2,T={tl:[c,u],tr:[c+d,u],mr:[c+d,u+_],ml:[c,u+_],tc:[c+h,u],bc:[c+h,u+f],br:[c+d,u+f],bl:[c,u+f],center:[c+h,u+_]},p=a?e:e.multiply(getTransformToElement(t[0],s)),y=entries$1(T).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=_slicedToArray(r[1],2),n=o[0],i=o[1];return e[a]=pointTo(p,n,i),e}),{});if(o){var v={},E=1;switch(n){case"n":var m=y.tc,x=m.x,g=m.y;v.x=x,v.y=g;break;case"s":var b=y.bc,S=b.x,M=b.y;v.x=S,v.y=M,E=-1;break;case"w":var O=y.ml,A=O.x,N=O.y;v.x=A,v.y=N,E=-1;break;case"e":default:var R=y.mr,C=R.x,k=R.y;v.x=C,v.y=k}var I="n"===n||"s"===n?Math.atan2(y.bl.y-y.tl.y,y.bl.x-y.tl.x):Math.atan2(y.tl.y-y.tr.y,y.tl.x-y.tr.x),D=i*E,P={x:v.x-D*Math.cos(I),y:v.y-D*Math.sin(I)};y.rotator=P,y.anchor=v}return y}},{key:"_getBBox",value:function(){var e=this.elements,t=this.options,r=t.container;if(t.isGrouped){var a=e.reduce((function(e,t){var a=getTransformToElement(t,r);return[].concat(_toConsumableArray(e),_toConsumableArray(_getBoundingRect$1(t,a)))}),[]),o=_slicedToArray(getMinMaxOfArray(a),2),n=_slicedToArray(o[0],2),i=n[0],s=n[1],l=_slicedToArray(o[1],2),c=l[0];return{x:i,y:c,width:s-i,height:l[1]-c}}return e[0].getBBox()}},{key:"_moveCenterHandle",value:function(e,t){var r=this.storage,a=r.handles,o=a.center,n=a.radius,i=r.center,s=r.transform,l=(s=void 0===s?{}:s).controlsMatrix,c=void 0===l?createSVGMatrix():l,u=r.transformOrigin,d=(u=void 0===u?{}:u).x,f=u.y,h=r.cached;if(!isUndef(o)){var _=d+e,T=f+t;o.cx.baseVal.value=_,o.cy.baseVal.value=T,n.x2.baseVal.value=_,n.y2.baseVal.value=T,this.storage=_objectSpread2({},this.storage,{center:_objectSpread2({},i,{isShifted:!0},pointTo(c.inverse(),_,T)),cached:_objectSpread2({},h,{transformOrigin:pointTo(createSVGMatrix(),_,T)})})}}},{key:"_processMoveRestrict",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage.data.get(e).transform,n=o.matrix,i=o.auxiliary.translate.parentMatrix;i.e=i.f=0;var s=pointTo(i,r,a),l=s.x,c=s.y,u=createTranslateMatrix$1(l,c).multiply(n);return this._restrictHandler(e,u)}},{key:"_processRotateRestrict",value:function(e,t){var r=this.storage,a=(r=void 0===r?{}:r).data.get(e).transform,o=a.matrix,n=a.parentMatrix,i=a.auxiliary.rotate.translateMatrix,s=floatToFixed(Math.cos(t)),l=floatToFixed(Math.sin(t)),c=createRotateMatrix$1(l,s);n.e=n.f=0;var u=n.inverse().multiply(c).multiply(n),d=i.multiply(u).multiply(i.inverse()).multiply(o);return this._restrictHandler(e,d)}},{key:"_processResizeRestrict",value:function(e,t){var r,a,o,n,i,s,l,c=t.dx,u=t.dy,d=this.storage,f=d.doW,h=d.doH,_=d.data,T=d.bBox,p=T.width,y=T.height,v=this.options.proportions,E=_.get(e).transform,m=E.matrix,x=E.auxiliary.scale.translateMatrix,g=m.multiply(function(e,t){var r=createScaleMatrix$1(e,t);return x.multiply(r).multiply(x.inverse())}.apply(void 0,_toConsumableArray((r=c,a=u,o=Math.max(1,p),n=Math.max(1,y),i=f||!f&&!h?(o+r)/o:(n+a)/n,[(s=v?o*i:o+r)/o,(l=v?n*i:n+a)/n,s,l]))));return this._restrictHandler(e,g)}},{key:"_processControlsResize",value:function(){var e=this.storage,t=(e=void 0===e?{}:e).transform.controlsMatrix;this._applyTransformToHandles({boxMatrix:t.inverse()})}},{key:"_processControlsMove",value:function(e){var t=e.dx,r=e.dy,a=this.storage,o=(a=void 0===a?{}:a).transform,n=o.controlsMatrix,i=o.controlsTranslateMatrix,s=a.center;i.e=t,i.f=r;var l=i.multiply(n);if(this._updateControlsView(l),s.isShifted){var c=n.inverse();c.e=c.f=0;var u=pointTo(c,t,r),d=u.x,f=u.y;this._moveCenterHandle(-d,-f)}}},{key:"_processControlsRotate",value:function(e){var t=e.radians,r=this.storage,a=(r=void 0===r?{}:r).transform,o=a.controlsMatrix,n=a.wrapperOriginMatrix,i=floatToFixed(Math.cos(t)),s=floatToFixed(Math.sin(t)),l=createRotateMatrix$1(s,i),c=n.multiply(l).multiply(n.inverse()).multiply(o);this._updateControlsView(c)}},{key:"_updateElementView",value:function(e,t){var r=_slicedToArray(t,2),a=r[0],o=r[1];"transform"===a&&e.setAttribute(a,matrixToString(o))}},{key:"_updateControlsView",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:createSVGMatrix();this.storage.controls.setAttribute("transform",matrixToString(e)),this.storage.cached.controlsMatrix=e}},{key:"_applyTransformToHandles",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.boxMatrix,r=void 0===t?createSVGMatrix():t,a=this.options.rotatable,o=this.storage,n=o.handles,i=o.center.isShifted,s=this._getVertices(r),l=s.anchor,c=void 0===l?null:l,u=s.center,d=_objectWithoutProperties(s,["anchor","center"]),f={te:[d.tl,d.tr],be:[d.bl,d.br],le:[d.tl,d.bl],re:[d.tr,d.br]};if(a){var h=n.normal,_=n.radius;isDef(h)&&(h.x1.baseVal.value=c.x,h.y1.baseVal.value=c.y,h.x2.baseVal.value=d.rotator.x,h.y2.baseVal.value=d.rotator.y),isDef(_)&&(_.x1.baseVal.value=u.x,_.y1.baseVal.value=u.y,i||(_.x2.baseVal.value=u.x,_.y2.baseVal.value=u.y))}keys$2(f).forEach((function(e){var t=n[e],r=_slicedToArray(f[e],2),a=r[0],o=r[1];isUndef(a)||isUndef(t)||entries$1({x1:a.x,y1:a.y,x2:o.x,y2:o.y}).map((function(e){var r=_slicedToArray(e,2),a=r[0],o=r[1];return t.setAttribute(a,o)}))}));var T=_objectSpread2({},d,{},!i&&Boolean(u)&&{center:u});return keys$2(T).reduce((function(e,t){var r=n[t],a=T[t];return e[t]=a,isUndef(a)||isUndef(r)?e:(r.setAttribute("cx",a.x),r.setAttribute("cy",a.y),e)}),{})}},{key:"setCenterPoint",value:function(){warn('"setCenterPoint" method is replaced by "setTransformOrigin" and would be removed soon'),this.setTransformOrigin.apply(this,arguments)}},{key:"setTransformOrigin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.x,r=e.y,a=e.dx,o=e.dy,n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this.elements,s=this.storage,l=this.storage,c=(l=void 0===l?{}:l).controls,u=l.handles,d=(u=void 0===u?{}:u).center,f=u.radius,h=l.center,_=this.options,T=_.container,p=_.isGrouped,y=isDef(a)&&isDef(o),v=isDef(t)&&isDef(r);if(h&&d&&f&&(y||v)){var E,m,x=getTransformToElement(c,c.parentNode).inverse(),g=p?x:x.multiply(getTransformToElement(i[0],T));if(y){var b=this._getBBox(),S=b.x,M=b.y,O=b.width,A=b.height,N=O/2,R=A/2,C=pointTo(g,S+N+a,M+R+o);E=C.x,m=C.y}else E=t,m=r;d.cx.baseVal.value=E,d.cy.baseVal.value=m,f.x2.baseVal.value=E,f.y2.baseVal.value=m,h.isShifted=n,s.transformOrigin=pointTo(createSVGMatrix(),E,m)}}},{key:"fitControlsToSize",value:function(){var e=this.storage,t=e.controls,r=e.center,a=(r=void 0===r?{}:r).isShifted,o=e.transformOrigin,n=(o=void 0===o?{}:o).x,i=o.y,s=getTransformToElement(t,t.parentNode),l=pointTo(s,n,i),c=l.x,u=l.y,d=[{nextValues:function(){return{x:c,y:u}},pin:!0,condition:function(){return a}},{nextValues:function(){return{dx:0,dy:0}},pin:!1,condition:function(){return!a}}].find((function(e){return(0,e.condition)()})),f=d.nextValues,h=d.pin;this._updateControlsView(),this.setTransformOrigin(_objectSpread2({},f()),h),this._applyTransformToHandles()}},{key:"getBoundingRect",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=this.options,a=(r=void 0===r?{}:r).restrict,o=r.container,n=a||o,i=t?getTransformToElement(e.parentNode,n).multiply(t):getTransformToElement(e,n);return _getBoundingRect$1(e,i,e.getBBox())}},{key:"applyAlignment",value:function(e){var t=this,r=this.elements,a=this.options.container,o=this._getVertices(),n=(o.anchor,o.rotator,o.center,_objectWithoutProperties(o,["anchor","rotator","center"])),i=this._getRestrictedBBox(!0),s=values$2(n).map((function(e){return[e.x,e.y]})),l=_slicedToArray(getMinMaxOfArray(i),2),c=_slicedToArray(l[0],2),u=c[0],d=c[1],f=_slicedToArray(l[1],2),h=f[0],_=f[1],T=_slicedToArray(getMinMaxOfArray(s),2),p=_slicedToArray(T[0],2),y=p[0],v=p[1],E=_slicedToArray(T[1],2),m=E[0],x=E[1];r.map((function(r){var o=getTransformToElement(r.parentNode,a);o.e=o.f=0;var n=pointTo(o.inverse(),function(){switch(!0){case/[l]/.test(e):return u-y;case/[r]/.test(e):return d-v;case/[h]/.test(e):return(d+u)/2-(v+y)/2;default:return 0}}(),function(){switch(!0){case/[t]/.test(e):return h-m;case/[b]/.test(e):return _-x;case/[v]/.test(e):return(_+h)/2-(x+m)/2;default:return 0}}()),i=n.x,s=n.y,l=createTranslateMatrix$1(i,s).multiply(getTransformToElement(r,r.parentNode));t._updateElementView(r,["transform",l])})),this.fitControlsToSize()}},{key:"getDimensions",value:function(){var e=this.elements,t=this.options,r=t.isGrouped,a=t.container,o=this._getBBox(),n=o.x,i=o.y,s=o.width,l=o.height,c={tl:[n,i],tr:[n+s,i],bl:[n,i+l],br:[n+s,i+l]},u=r?createSVGMatrix():getTransformToElement(e[0],a),d=entries$1(c).reduce((function(e,t){var r=_slicedToArray(t,2),a=r[0],o=_slicedToArray(r[1],2),n=o[0],i=o[1];return e[a]=pointTo(u,n,i),e}),{}),f=d.tl,h=d.br,_=d.tr;return{x:floatToFixed(f.x),y:floatToFixed(f.y),width:floatToFixed(Math.sqrt(Math.pow(f.x-_.x,2)+Math.pow(f.y-_.y,2))),height:floatToFixed(Math.sqrt(Math.pow(_.x-h.x,2)+Math.pow(_.y-h.y,2))),rotation:floatToFixed(Math.atan2(_.y-f.y,_.x-f.x)*DEG)}}}]),r}(),applyTranslate=function(e,t){var r=t.x,a=t.y,o=[];switch(e.tagName.toLowerCase()){case"text":var n=isDef(e.x.baseVal[0])?e.x.baseVal[0].value+r:(Number(e.getAttribute("x"))||0)+r,i=isDef(e.y.baseVal[0])?e.y.baseVal[0].value+a:(Number(e.getAttribute("y"))||0)+a;o.push(["x",n],["y",i]);break;case"foreignobject":case"use":case"image":case"rect":var s=isDef(e.x.baseVal.value)?e.x.baseVal.value+r:(Number(e.getAttribute("x"))||0)+r,l=isDef(e.y.baseVal.value)?e.y.baseVal.value+a:(Number(e.getAttribute("y"))||0)+a;o.push(["x",s],["y",l]);break;case"circle":case"ellipse":var c=e.cx.baseVal.value+r,u=e.cy.baseVal.value+a;o.push(["cx",c],["cy",u]);break;case"line":var d=e.x1.baseVal.value+r,f=e.y1.baseVal.value+a,h=e.x2.baseVal.value+r,_=e.y2.baseVal.value+a;o.push(["x1",d],["y1",f],["x2",h],["y2",_]);break;case"polygon":case"polyline":var T=parsePoints(e.getAttribute("points")).map((function(e){return e[0]=Number(e[0])+r,e[1]=Number(e[1])+a,e.join(" ")})).join(" ");o.push(["points",T]);break;case"path":var p=e.getAttribute("d");o.push(["d",movePath({path:p,dx:r,dy:a})])}o.forEach((function(t){e.setAttribute(t[0],t[1])}))},applyResize=function(e,t){var r=t.scaleX,a=t.scaleY,o=t.localCTM,n=t.bBox,i=n.width,s=n.height,l=t.__data__,c=t.transformMatrix,u=t.isGrouped,d=[],f=l.get(e);switch(e.tagName.toLowerCase()){case"text":case"tspan":var h=f.x,_=f.y,T=f.textLength,p=pointTo(o,h,_),y=p.x,v=p.y;d.push(["x",y+(r<0?i:0)],["y",v-(a<0?s:0)],["textLength",Math.abs(r*T)]);break;case"circle":var E=f.r,m=f.cx,x=f.cy,g=E*(Math.abs(r)+Math.abs(a))/2,b=pointTo(o,m,x),S=b.x,M=b.y;d.push(["r",g],["cx",S],["cy",M]);break;case"foreignobject":case"image":case"rect":if(u){var O=f.matrix,A=f.childCTM,N=A.inverse().multiply(c).multiply(A),R=O.multiply(N);d.push(["transform",matrixToString(R)])}else{var C=f.width,k=f.height,I=f.x,D=f.y,P=pointTo(o,I,D),w=P.x,V=P.y,$=Math.abs(C*r),G=Math.abs(k*a);d.push(["x",w-(r<0?$:0)],["y",V-(a<0?G:0)],["width",$],["height",G])}break;case"ellipse":var L=f.rx,j=f.ry,F=f.cx,H=f.cy,U=pointTo(o,F,H),B=U.x,Y=U.y,z=createSVGMatrix();z.a=r,z.d=a;var X=pointTo(z,L,j),W=X.x,Z=X.y;d.push(["rx",Math.abs(W)],["ry",Math.abs(Z)],["cx",B],["cy",Y]);break;case"line":var K=f.resX1,q=f.resY1,Q=f.resX2,J=f.resY2,ee=pointTo(o,K,q),te=ee.x,re=ee.y,ae=pointTo(o,Q,J),oe=ae.x,ne=ae.y;d.push(["x1",te],["y1",re],["x2",oe],["y2",ne]);break;case"polygon":case"polyline":var ie=f.points,se=parsePoints(ie).map((function(e){var t=pointTo(o,Number(e[0]),Number(e[1])),r=t.x,a=t.y;return e[0]=floatToFixed(r),e[1]=floatToFixed(a),e.join(" ")})).join(" ");d.push(["points",se]);break;case"path":var le=f.path;d.push(["d",resizePath({path:le,localCTM:o})])}d.forEach((function(t){var r=_slicedToArray(t,2),a=r[0],o=r[1];e.setAttribute(a,o)}))},createHandler$1=function(e,t,r,a){var o=createSVGElement("circle",["sjx-svg-hdl","sjx-svg-hdl-".concat(a)]);return entries$1({cx:e,cy:t,r:4,fill:"#fff",stroke:r,"stroke-width":1,"fill-opacity":1,"vector-effect":"non-scaling-stroke"}).forEach((function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1];return o.setAttribute(r,a)})),o},setLineStyle=function(e,t){e.setAttribute("stroke",t),e.setAttribute("stroke-dasharray","3 3"),e.setAttribute("vector-effect","non-scaling-stroke")},storeElementAttributes=function(e,t,r,a){var o=null;switch(e.tagName.toLowerCase()){case"text":o={x:isDef(e.x.baseVal[0])?e.x.baseVal[0].value:Number(e.getAttribute("x"))||0,y:isDef(e.y.baseVal[0])?e.y.baseVal[0].value:Number(e.getAttribute("y"))||0,textLength:isDef(e.textLength.baseVal)?e.textLength.baseVal.value:Number(e.getAttribute("textLength"))||null};break;case"circle":o={r:e.r.baseVal.value,cx:e.cx.baseVal.value,cy:e.cy.baseVal.value};break;case"foreignobject":case"image":case"rect":o={width:e.width.baseVal.value,height:e.height.baseVal.value,x:e.x.baseVal.value,y:e.y.baseVal.value};break;case"ellipse":o={rx:e.rx.baseVal.value,ry:e.ry.baseVal.value,cx:e.cx.baseVal.value,cy:e.cy.baseVal.value};break;case"line":o={resX1:e.x1.baseVal.value,resY1:e.y1.baseVal.value,resX2:e.x2.baseVal.value,resY2:e.y2.baseVal.value};break;case"polygon":case"polyline":o={points:e.getAttribute("points")};break;case"path":o={path:e.getAttribute("d")}}t.__data__.set(e,_objectSpread2({},o,{matrix:getTransformToElement(e,e.parentNode),ctm:getTransformToElement(e.parentNode,r),childCTM:getTransformToElement(e,a?r.parentNode:r)}))},renderLine$1=function(e,t,r){var a=_slicedToArray(e,2),o=a[0],n=a[1],i=createSVGElement("line",["sjx-svg-line","sjx-svg-line-".concat(r)]),s={x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:t,"stroke-width":1,"vector-effect":"non-scaling-stroke"};return entries$1(s).forEach((function(e){var t=_slicedToArray(e,2),r=t[0],a=t[1];return i.setAttribute(r,a)})),i},_getBoundingRect$1=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.getBBox(),a=r.x,o=r.y,n=r.width,i=r.height,s=[[a,o],[a+n,o],[a+n,o+i],[a,o+i]];return s.map((function(e){var r=_slicedToArray(e,2),a=r[0],o=r[1],n=pointTo(t,a,o);return[n.x,n.y]}))};function drag(e,t){if(this.length){var r=isDef(t)&&t instanceof Observable?t:new Observable;if(this[0]instanceof SVGElement){var a=arrReduce.call(this,(function(e,t){return checkElement(t)&&e.push(t),e}),[]);return new DraggableSVG(a,e,r)}return new Draggable(arrMap.call(this,(function(e){return e})),e,r)}}var EMITTER_EVENTS$2=EVENT_EMITTER_CONSTANTS.EMITTER_EVENTS,E_MOUSEDOWN$4=CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN,E_TOUCHSTART$4=CLIENT_EVENTS_CONSTANTS.E_TOUCHSTART,Cloneable=function(e){_inherits(r,SubjectModel);var t=_createSuper(r);function r(e,a){var o;return _classCallCheck(this,r),(o=t.call(this,e)).enable(a),o}return _createClass(r,[{key:"_init",value:function(){var e=this,t=this.elements,r=this.options,a=helper(t),o=r.style,n=r.appendTo,i=_objectSpread2({position:"absolute","z-index":"2147483647"},o),s=new WeakMap;t.map((function(e){return s.set(e,{parent:isDef(n)?helper(n)[0]:document.body})})),this.storage={css:i,data:s},a.on(E_MOUSEDOWN$4,this._onMouseDown).on(E_TOUCHSTART$4,this._onTouchStart),EMITTER_EVENTS$2.slice(0,3).forEach((function(t){e.eventDispatcher.registerEvent(t)}))}},{key:"_processOptions",value:function(e){var t={},r=null,a=document,o=noop,n=noop,i=noop,s=noop;if(isDef(e)){var l=e.style,c=e.appendTo,u=e.stack,d=e.onInit,f=e.onMove,h=e.onDrop,_=e.onDestroy;t=isDef(l)&&"object"===_typeof(l)?l:t,r=c||null;var T=isDef(u)?helper(u)[0]:document;o=createMethod(d),n=createMethod(f),i=isFunc(h)?function(e){var t=this.storage,r=(t=void 0===t?{}:t).clone;objectsCollide(r,T)&&h.call(this,e,this.elements,r)}:noop,s=createMethod(_)}this.options={style:t,appendTo:r,stack:a},this.proxyMethods={onInit:o,onDrop:i,onMove:n,onDestroy:s}}},{key:"_start",value:function(e){var t=e.target,r=e.clientX,a=e.clientY,o=this.elements,n=this.storage,i=this.storage,s=i.data,l=i.css,c=o.find((function(e){return e===t||e.contains(t)}));if(c){var u=(s.get(c)||{}).parent,d=void 0===u?c.parentNode:u,f=getOffset(d),h=f.left,_=f.top;l.left="".concat(r-h,"px"),l.top="".concat(a-_,"px");var T=c.cloneNode(!0);helper(T).css(l),n.clientX=r,n.clientY=a,n.cx=r,n.cy=a,n.clone=T,d.appendChild(T),this._draw()}}},{key:"_moving",value:function(e){var t=e.clientX,r=e.clientY,a=this.storage;a.clientX=t,a.clientY=r,a.doDraw=!0,a.doMove=!0}},{key:"_end",value:function(e){var t=this.storage,r=t.clone,a=t.frameId;t.doDraw=!1,cancelAnimFrame(a),isUndef(r)||(this.proxyMethods.onDrop.call(this,e),r.parentNode.removeChild(r),delete t.clone)}},{key:"_animate",value:function(){var e=this.storage;e.frameId=requestAnimFrame(this._animate);var t=e.doDraw,r=e.clientX,a=e.clientY,o=e.cx,n=e.cy,i=e.clone;t&&(e.doDraw=!1,this._drag({element:i,dx:r-o,dy:a-n}))}},{key:"_processMove",value:function(e,t){var r=t.dx,a=t.dy,o=this.storage,n=(o=void 0===o?{}:o).clone,i="translate(".concat(r,"px, ").concat(a,"px)");helper(n).css({transform:i,webkitTranform:i,mozTransform:i,msTransform:i,otransform:i})}},{key:"_destroy",value:function(){var e=this.storage,t=this.proxyMethods,r=this.elements;isUndef(e)||(helper(r).off(E_MOUSEDOWN$4,this._onMouseDown).off(E_TOUCHSTART$4,this._onTouchStart),t.onDestroy.call(this,r),delete this.storage)}},{key:"disable",value:function(){this._destroy()}}]),r}();function clone(e){if(this.length)return new Cloneable(arrMap.call(this,(function(e){return e})),e)}var Subjx=function(e){_inherits(r,Helper);var t=_createSuper(r);function r(){return _classCallCheck(this,r),t.apply(this,arguments)}return _createClass(r,[{key:"drag",value:function(){return drag.call.apply(drag,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"clone",value:function(){return clone.call.apply(clone,[this].concat(Array.prototype.slice.call(arguments)))}}]),r}();function subjx(e){return new Subjx(e)}Object.defineProperty(subjx,"createObservable",{value:function(){return new Observable}}),Object.defineProperty(subjx,"Subjx",{value:Subjx}),Object.defineProperty(subjx,"Observable",{value:Observable}),module.exports=subjx; diff --git a/dist/js/subjx.dev.common.js b/dist/js/subjx.dev.common.js index a3139ff..c63e3e8 100644 --- a/dist/js/subjx.dev.common.js +++ b/dist/js/subjx.dev.common.js @@ -2462,10 +2462,9 @@ var multiplyMatrix = function multiplyMatrix(m1, m2) { return result; }; var matrixInvert = function matrixInvert(matrix) { - var _A = cloneMatrix(matrix); - + var A = cloneMatrix(matrix); + var N = A.length; var temp, - N = _A.length, E = []; for (var i = 0; i < N; i++) { @@ -2475,23 +2474,25 @@ var matrixInvert = function matrixInvert(matrix) { for (var _i = 0; _i < N; _i++) { for (var j = 0; j < N; j++) { E[_i][j] = 0; - if (_i == j) E[_i][j] = 1; + if (_i === j) E[_i][j] = 1; } } for (var k = 0; k < N; k++) { - temp = _A[k][k]; + temp = A[k][k]; - for (var _j = 0; _j < N; _j++) { - _A[k][_j] /= temp; - E[k][_j] /= temp; + if (temp !== 0) { + for (var _j = 0; _j < N; _j++) { + A[k][_j] /= temp; + E[k][_j] /= temp; + } } for (var _i2 = k + 1; _i2 < N; _i2++) { - temp = _A[_i2][k]; + temp = A[_i2][k]; for (var _j2 = 0; _j2 < N; _j2++) { - _A[_i2][_j2] -= _A[k][_j2] * temp; + A[_i2][_j2] -= A[k][_j2] * temp; E[_i2][_j2] -= E[k][_j2] * temp; } } @@ -2499,10 +2500,10 @@ var matrixInvert = function matrixInvert(matrix) { for (var _k = N - 1; _k > 0; _k--) { for (var _i3 = _k - 1; _i3 >= 0; _i3--) { - temp = _A[_i3][_k]; + temp = A[_i3][_k]; for (var _j3 = 0; _j3 < N; _j3++) { - _A[_i3][_j3] -= _A[_k][_j3] * temp; + A[_i3][_j3] -= A[_k][_j3] * temp; E[_i3][_j3] -= E[_k][_j3] * temp; } } @@ -2510,11 +2511,11 @@ var matrixInvert = function matrixInvert(matrix) { for (var _i4 = 0; _i4 < N; _i4++) { for (var _j4 = 0; _j4 < N; _j4++) { - _A[_i4][_j4] = E[_i4][_j4]; + A[_i4][_j4] = E[_i4][_j4]; } } - return _A; + return A; }; var computeTransformMatrix = function computeTransformMatrix(tx, _ref) { var _ref2 = _slicedToArray(_ref, 3), diff --git a/dist/js/subjx.dev.js b/dist/js/subjx.dev.js index 4e1ada1..95f5590 100644 --- a/dist/js/subjx.dev.js +++ b/dist/js/subjx.dev.js @@ -2466,10 +2466,9 @@ return result; }; var matrixInvert = function matrixInvert(matrix) { - var _A = cloneMatrix(matrix); - + var A = cloneMatrix(matrix); + var N = A.length; var temp, - N = _A.length, E = []; for (var i = 0; i < N; i++) { @@ -2479,23 +2478,25 @@ for (var _i = 0; _i < N; _i++) { for (var j = 0; j < N; j++) { E[_i][j] = 0; - if (_i == j) E[_i][j] = 1; + if (_i === j) E[_i][j] = 1; } } for (var k = 0; k < N; k++) { - temp = _A[k][k]; + temp = A[k][k]; - for (var _j = 0; _j < N; _j++) { - _A[k][_j] /= temp; - E[k][_j] /= temp; + if (temp !== 0) { + for (var _j = 0; _j < N; _j++) { + A[k][_j] /= temp; + E[k][_j] /= temp; + } } for (var _i2 = k + 1; _i2 < N; _i2++) { - temp = _A[_i2][k]; + temp = A[_i2][k]; for (var _j2 = 0; _j2 < N; _j2++) { - _A[_i2][_j2] -= _A[k][_j2] * temp; + A[_i2][_j2] -= A[k][_j2] * temp; E[_i2][_j2] -= E[k][_j2] * temp; } } @@ -2503,10 +2504,10 @@ for (var _k = N - 1; _k > 0; _k--) { for (var _i3 = _k - 1; _i3 >= 0; _i3--) { - temp = _A[_i3][_k]; + temp = A[_i3][_k]; for (var _j3 = 0; _j3 < N; _j3++) { - _A[_i3][_j3] -= _A[_k][_j3] * temp; + A[_i3][_j3] -= A[_k][_j3] * temp; E[_i3][_j3] -= E[_k][_j3] * temp; } } @@ -2514,11 +2515,11 @@ for (var _i4 = 0; _i4 < N; _i4++) { for (var _j4 = 0; _j4 < N; _j4++) { - _A[_i4][_j4] = E[_i4][_j4]; + A[_i4][_j4] = E[_i4][_j4]; } } - return _A; + return A; }; var computeTransformMatrix = function computeTransformMatrix(tx, _ref) { var _ref2 = _slicedToArray(_ref, 3), diff --git a/dist/js/subjx.esm.js b/dist/js/subjx.esm.js index 128fdff..90e75e6 100644 --- a/dist/js/subjx.esm.js +++ b/dist/js/subjx.esm.js @@ -2460,10 +2460,9 @@ var multiplyMatrix = function multiplyMatrix(m1, m2) { return result; }; var matrixInvert = function matrixInvert(matrix) { - var _A = cloneMatrix(matrix); - + var A = cloneMatrix(matrix); + var N = A.length; var temp, - N = _A.length, E = []; for (var i = 0; i < N; i++) { @@ -2473,23 +2472,25 @@ var matrixInvert = function matrixInvert(matrix) { for (var _i = 0; _i < N; _i++) { for (var j = 0; j < N; j++) { E[_i][j] = 0; - if (_i == j) E[_i][j] = 1; + if (_i === j) E[_i][j] = 1; } } for (var k = 0; k < N; k++) { - temp = _A[k][k]; + temp = A[k][k]; - for (var _j = 0; _j < N; _j++) { - _A[k][_j] /= temp; - E[k][_j] /= temp; + if (temp !== 0) { + for (var _j = 0; _j < N; _j++) { + A[k][_j] /= temp; + E[k][_j] /= temp; + } } for (var _i2 = k + 1; _i2 < N; _i2++) { - temp = _A[_i2][k]; + temp = A[_i2][k]; for (var _j2 = 0; _j2 < N; _j2++) { - _A[_i2][_j2] -= _A[k][_j2] * temp; + A[_i2][_j2] -= A[k][_j2] * temp; E[_i2][_j2] -= E[k][_j2] * temp; } } @@ -2497,10 +2498,10 @@ var matrixInvert = function matrixInvert(matrix) { for (var _k = N - 1; _k > 0; _k--) { for (var _i3 = _k - 1; _i3 >= 0; _i3--) { - temp = _A[_i3][_k]; + temp = A[_i3][_k]; for (var _j3 = 0; _j3 < N; _j3++) { - _A[_i3][_j3] -= _A[_k][_j3] * temp; + A[_i3][_j3] -= A[_k][_j3] * temp; E[_i3][_j3] -= E[_k][_j3] * temp; } } @@ -2508,11 +2509,11 @@ var matrixInvert = function matrixInvert(matrix) { for (var _i4 = 0; _i4 < N; _i4++) { for (var _j4 = 0; _j4 < N; _j4++) { - _A[_i4][_j4] = E[_i4][_j4]; + A[_i4][_j4] = E[_i4][_j4]; } } - return _A; + return A; }; var computeTransformMatrix = function computeTransformMatrix(tx, _ref) { var _ref2 = _slicedToArray(_ref, 3), diff --git a/dist/js/subjx.js b/dist/js/subjx.js index effa871..0cdbcaf 100644 --- a/dist/js/subjx.js +++ b/dist/js/subjx.js @@ -4,4 +4,4 @@ * Karen Sarksyan * nichollascarter@gmail.com */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).subjx=e()}(this,function(){"use strict";function et(t){return(et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,a=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,n,o=!0,i=!1;return{s:function(){a=t[Symbol.iterator]()},n:function(){var t=a.next();return o=t.done,t},e:function(t){i=!0,n=t},f:function(){try{o||null==a.return||a.return()}finally{if(i)throw n}}}}(N);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(a=r.getPropertyValue("".concat(i).concat(e))||a)break}}catch(t){o.e(t)}finally{o.f()}return a}var Ct=z.NOTIFIER_EVENTS,Vt=z.ON_GETSTATE,Nt=z.ON_APPLY,At=z.ON_MOVE,Pt=z.ON_RESIZE,Dt=z.ON_ROTATE;var jt=H.EMITTER_EVENTS,Bt=H.E_DRAG_START,Lt=H.E_DRAG,zt=H.E_DRAG_END,Ht=H.E_RESIZE_START,It=H.E_RESIZE,Xt=H.E_RESIZE_END,Gt=H.E_ROTATE_START,Wt=H.E_ROTATE,Ft=H.E_ROTATE_END,qt=H.E_SET_POINT,Zt=H.E_SET_POINT_END;var Qt=Z,Ut=Q;var $t=I,Jt=W,Kt=G,te=X,ee=q,re=F;var ae=Qt.TOP_LEFT,ne=Qt.TOP_CENTER,oe=Qt.TOP_RIGHT,ie=Qt.BOTTOM_LEFT,le=Qt.BOTTOM_RIGHT,ue=Qt.BOTTOM_CENTER,he=Qt.MIDDLE_LEFT,fe=Qt.MIDDLE_RIGHT;var de=Ut.TOP_EDGE,pe=Ut.BOTTOM_EDGE,ye=Ut.LEFT_EDGE,me=Ut.RIGHT_EDGE;var xe=Object.keys,ge=Object.values;var be=function(){o(gt,dt);var n=c(gt);function gt(t,e,r){var a;if(i(this,gt),(a=n.call(this,t)).constructor===gt)throw new TypeError("Cannot construct Transformable instances directly");return a.observable=r,jt.forEach(function(t){return a.eventDispatcher.registerEvent(t)}),kt(_t(gt.prototype),"enable",s(a)).call(s(a),e),a}return r(gt,[{key:"_cursorPoint",value:function(){throw Error("'_cursorPoint()' method not implemented")}},{key:"_rotate",value:function(t){var e=t.element,r=t.radians,a=R(t,["element","radians"]);var n=bt({transform:this._processRotate(e,r),delta:r},a);this.proxyMethods.onRotate.call(this,n),kt(_t(gt.prototype),"_emitEvent",this).call(this,Wt,n)}},{key:"_resize",value:function(t){var e=t.element,r=t.dx,a=t.dy,n=R(t,["element","dx","dy"]);var o=bt({},this._processResize(e,{dx:r,dy:a}),{dx:r,dy:a},n);this.proxyMethods.onResize.call(this,o),kt(_t(gt.prototype),"_emitEvent",this).call(this,It,o)}},{key:"_processOptions",value:function(t){var e=0120*Math.PI/180){var C=y;var V=a;var N=n;var A=v&&pi+parseFloat(v.css("height"))||ns+parseFloat(v.css("width")))}(r,p)||f.call(this,t,this.elements,r)}:rt,s=at(d)}this.options={style:e,appendTo:r,stack:a},this.proxyMethods={onInit:n,onDrop:i,onMove:o,onDestroy:s}}},{key:"_start",value:function(t){var e=t.target,r=t.clientX,a=t.clientY;var n=this.elements,o=this.storage,i=this.storage,s=i.data,c=i.css;var v=n.find(function(t){return t===e||t.contains(e)});if(v){var l=(s.get(v)||{}).parent,u=void 0===l?v.parentNode:l;var h=gt(u),f=h.left,d=h.top;c.left="".concat(r-f,"px"),c.top="".concat(a-d,"px");var p=v.cloneNode(!0);nt(p).css(c),o.clientX=r,o.clientY=a,o.cx=r,o.cy=a,o.clone=p,u.appendChild(p),this._draw()}}},{key:"_moving",value:function(t){var e=t.clientX,r=t.clientY;var a=this.storage;a.clientX=e,a.clientY=r,a.doDraw=!0,a.doMove=!0}},{key:"_end",value:function(t){var e=this.storage;var r=e.clone,a=e.frameId;e.doDraw=!1,M(a),Et(r)||(this.proxyMethods.onDrop.call(this,t),r.parentNode.removeChild(r),delete e.clone)}},{key:"_animate",value:function(){var t=this.storage;t.frameId=Mt(this._animate);var e=t.doDraw,r=t.clientX,a=t.clientY,n=t.cx,o=t.cy,i=t.clone;e&&(t.doDraw=!1,this._drag({element:i,dx:r-n,dy:a-o}))}},{key:"_processMove",value:function(t,e){var r=e.dx,a=e.dy;var n=this.storage;var o=(n=void 0===n?{}:n).clone;var i="translate(".concat(r,"px, ").concat(a,"px)");nt(o).css({transform:i,webkitTranform:i,mozTransform:i,msTransform:i,otransform:i})}},{key:"_destroy",value:function(){var t=this.storage,e=this.proxyMethods,r=this.elements;Et(t)||(nt(r).off(Cr,this._onMouseDown).off(Vr,this._onTouchStart),e.onDestroy.call(this,r),delete this.storage)}},{key:"disable",value:function(){this._destroy()}}]),n}();function Ar(t){if(this.length)return new Nr(f.call(this,function(t){return t}),t)}var Pr=function(){o(e,p);var t=c(e);function e(){return i(this,e),t.apply(this,arguments)}return r(e,[{key:"drag",value:function(){return Sr.call.apply(Sr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"clone",value:function(){return Ar.call.apply(Ar,[this].concat(Array.prototype.slice.call(arguments)))}}]),e}();function Dr(t){return new Pr(t)}return Object.defineProperty(Dr,"createObservable",{value:function(){return new it}}),Object.defineProperty(Dr,"Subjx",{value:Pr}),Object.defineProperty(Dr,"Observable",{value:it}),Dr}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).subjx=e()}(this,function(){"use strict";function et(t){return(et="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){for(var r=0;rt.length)&&(e=t.length);for(var r=0,a=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,n,o=!0,i=!1;return{s:function(){a=t[Symbol.iterator]()},n:function(){var t=a.next();return o=t.done,t},e:function(t){i=!0,n=t},f:function(){try{o||null==a.return||a.return()}finally{if(i)throw n}}}}(N);try{for(o.s();!(n=o.n()).done;){var i=n.value;if(a=r.getPropertyValue("".concat(i).concat(e))||a)break}}catch(t){o.e(t)}finally{o.f()}return a}var Ct=z.NOTIFIER_EVENTS,Vt=z.ON_GETSTATE,Nt=z.ON_APPLY,At=z.ON_MOVE,Pt=z.ON_RESIZE,Dt=z.ON_ROTATE;var jt=H.EMITTER_EVENTS,Bt=H.E_DRAG_START,Lt=H.E_DRAG,zt=H.E_DRAG_END,Ht=H.E_RESIZE_START,It=H.E_RESIZE,Xt=H.E_RESIZE_END,Gt=H.E_ROTATE_START,Wt=H.E_ROTATE,Ft=H.E_ROTATE_END,qt=H.E_SET_POINT,Zt=H.E_SET_POINT_END;var Qt=Z,Ut=Q;var $t=I,Jt=W,Kt=G,te=X,ee=q,re=F;var ae=Qt.TOP_LEFT,ne=Qt.TOP_CENTER,oe=Qt.TOP_RIGHT,ie=Qt.BOTTOM_LEFT,le=Qt.BOTTOM_RIGHT,ue=Qt.BOTTOM_CENTER,he=Qt.MIDDLE_LEFT,fe=Qt.MIDDLE_RIGHT;var de=Ut.TOP_EDGE,pe=Ut.BOTTOM_EDGE,ye=Ut.LEFT_EDGE,me=Ut.RIGHT_EDGE;var xe=Object.keys,ge=Object.values;var be=function(){o(gt,dt);var n=c(gt);function gt(t,e,r){var a;if(i(this,gt),(a=n.call(this,t)).constructor===gt)throw new TypeError("Cannot construct Transformable instances directly");return a.observable=r,jt.forEach(function(t){return a.eventDispatcher.registerEvent(t)}),kt(_t(gt.prototype),"enable",s(a)).call(s(a),e),a}return r(gt,[{key:"_cursorPoint",value:function(){throw Error("'_cursorPoint()' method not implemented")}},{key:"_rotate",value:function(t){var e=t.element,r=t.radians,a=R(t,["element","radians"]);var n=bt({transform:this._processRotate(e,r),delta:r},a);this.proxyMethods.onRotate.call(this,n),kt(_t(gt.prototype),"_emitEvent",this).call(this,Wt,n)}},{key:"_resize",value:function(t){var e=t.element,r=t.dx,a=t.dy,n=R(t,["element","dx","dy"]);var o=bt({},this._processResize(e,{dx:r,dy:a}),{dx:r,dy:a},n);this.proxyMethods.onResize.call(this,o),kt(_t(gt.prototype),"_emitEvent",this).call(this,It,o)}},{key:"_processOptions",value:function(t){var e=0120*Math.PI/180){var C=y;var V=a;var N=n;var A=v&&pi+parseFloat(v.css("height"))||ns+parseFloat(v.css("width")))}(r,p)||f.call(this,t,this.elements,r)}:rt,s=at(d)}this.options={style:e,appendTo:r,stack:a},this.proxyMethods={onInit:n,onDrop:i,onMove:o,onDestroy:s}}},{key:"_start",value:function(t){var e=t.target,r=t.clientX,a=t.clientY;var n=this.elements,o=this.storage,i=this.storage,s=i.data,c=i.css;var v=n.find(function(t){return t===e||t.contains(e)});if(v){var l=(s.get(v)||{}).parent,u=void 0===l?v.parentNode:l;var h=gt(u),f=h.left,d=h.top;c.left="".concat(r-f,"px"),c.top="".concat(a-d,"px");var p=v.cloneNode(!0);nt(p).css(c),o.clientX=r,o.clientY=a,o.cx=r,o.cy=a,o.clone=p,u.appendChild(p),this._draw()}}},{key:"_moving",value:function(t){var e=t.clientX,r=t.clientY;var a=this.storage;a.clientX=e,a.clientY=r,a.doDraw=!0,a.doMove=!0}},{key:"_end",value:function(t){var e=this.storage;var r=e.clone,a=e.frameId;e.doDraw=!1,M(a),Et(r)||(this.proxyMethods.onDrop.call(this,t),r.parentNode.removeChild(r),delete e.clone)}},{key:"_animate",value:function(){var t=this.storage;t.frameId=Mt(this._animate);var e=t.doDraw,r=t.clientX,a=t.clientY,n=t.cx,o=t.cy,i=t.clone;e&&(t.doDraw=!1,this._drag({element:i,dx:r-n,dy:a-o}))}},{key:"_processMove",value:function(t,e){var r=e.dx,a=e.dy;var n=this.storage;var o=(n=void 0===n?{}:n).clone;var i="translate(".concat(r,"px, ").concat(a,"px)");nt(o).css({transform:i,webkitTranform:i,mozTransform:i,msTransform:i,otransform:i})}},{key:"_destroy",value:function(){var t=this.storage,e=this.proxyMethods,r=this.elements;Et(t)||(nt(r).off(Cr,this._onMouseDown).off(Vr,this._onTouchStart),e.onDestroy.call(this,r),delete this.storage)}},{key:"disable",value:function(){this._destroy()}}]),n}();function Ar(t){if(this.length)return new Nr(f.call(this,function(t){return t}),t)}var Pr=function(){o(e,p);var t=c(e);function e(){return i(this,e),t.apply(this,arguments)}return r(e,[{key:"drag",value:function(){return Sr.call.apply(Sr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"clone",value:function(){return Ar.call.apply(Ar,[this].concat(Array.prototype.slice.call(arguments)))}}]),e}();function Dr(t){return new Pr(t)}return Object.defineProperty(Dr,"createObservable",{value:function(){return new it}}),Object.defineProperty(Dr,"Subjx",{value:Pr}),Object.defineProperty(Dr,"Observable",{value:it}),Dr}); diff --git a/package-lock.json b/package-lock.json index 29e7583..8976d25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "subjx", - "version": "1.1.0-rc.4", + "version": "1.1.0-rc.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7caab4c..b9b2ed0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "subjx", - "version": "1.1.0-rc.4", + "version": "1.1.0-rc.5", "description": "Drag, Rotate, Resize library", "author": "Karen Sarksyan (https://github.com/nichollascarter)", "license": "MIT",