From 7d54258ba2843d55d605eeaf2a9a628358dddf08 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Tue, 14 Dec 2021 13:58:10 +0000 Subject: [PATCH] chore(release): 1.0.0-rc.4 # [1.0.0-rc.4](https://github.com/nichollascarter/subjx/compare/v1.0.0-rc.3...v1.0.0-rc.4) (2021-12-14) ### Bug Fixes * **src:** prevent rotation point moving when groupable is rotating ([080cf48](https://github.com/nichollascarter/subjx/commit/080cf486bf3749b636610141cd825d989bc35d4e)), closes [#58](https://github.com/nichollascarter/subjx/issues/58) --- CHANGELOG.md | 7 + dist/js/subjx.common.js | 2 +- dist/js/subjx.dev.common.js | 246 ++++++++++++++++++++---------------- dist/js/subjx.dev.js | 246 ++++++++++++++++++++---------------- dist/js/subjx.esm.js | 246 ++++++++++++++++++++---------------- dist/js/subjx.js | 2 +- package.json | 2 +- 7 files changed, 427 insertions(+), 324 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e148df5..b58480f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [1.0.0-rc.4](https://github.com/nichollascarter/subjx/compare/v1.0.0-rc.3...v1.0.0-rc.4) (2021-12-14) + + +### Bug Fixes + +* **src:** prevent rotation point moving when groupable is rotating ([080cf48](https://github.com/nichollascarter/subjx/commit/080cf486bf3749b636610141cd825d989bc35d4e)), closes [#58](https://github.com/nichollascarter/subjx/issues/58) + # [1.0.0-rc.3](https://github.com/nichollascarter/subjx/compare/v1.0.0-rc.2...v1.0.0-rc.3) (2021-12-12) diff --git a/dist/js/subjx.common.js b/dist/js/subjx.common.js index 081f312..14944ed 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_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_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,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,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.restrict,y=e.draggable,v=void 0===y||y,E=e.resizable,m=void 0===E||E,x=e.rotatable,b=void 0===x||x,g=e.scalable,S=void 0!==g&&g,M=e.applyTranslate,O=void 0!==M&&M,A=e.onInit,N=void 0===A?noop:A,R=e.onDrop,C=void 0===R?noop:R,k=e.onMove,I=void 0===k?noop:k,D=e.onResize,V=void 0===D?noop:D,w=e.onRotate,P=void 0===w?noop:w,$=e.onDestroy,L=void 0===$?noop:$,G=e.container,j=void 0===G?t[0].parentNode:G,F=e.controlsContainer,H=void 0===F?j:F,U=e.proportions,B=void 0!==U&&U,Y=e.rotatorAnchor,z=void 0===Y?null:Y,X=e.rotatorOffset,W=void 0===X?50:X,Z=e.showNormal,K=void 0===Z||Z,q=e.custom;this.options={axis:s,cursorMove:c,cursorRotate:h,cursorResize:d,rotationPoint:T,restrict:p?helper(p)[0]||document.body:null,container:helper(j)[0],controlsContainer:helper(H)[0],snap:_objectSpread2({},n,{angle:n.angle*RAD}),each:a,proportions:B,draggable:v,resizable:m,rotatable:b,scalable:S,applyTranslate:O,custom:"object"===_typeof(q)&&q||null,rotatorAnchor:z,rotatorOffset:W,showNormal:K,isGrouped:t.length>1},this.proxyMethods={onInit:createMethod(N),onDrop:createMethod(C),onMove:createMethod(I),onResize:createMethod(V),onRotate:createMethod(P),onDestroy:createMethod(L)},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,b=n.each,g=b.move,S=b.resize,M=b.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,V=o.cached,w=(V=void 0===V?{}:V).dist,P=(w=void 0===w?{}:w).dx,$=void 0===P?k:P,L=w.dy,G=void 0===L?I:L,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?G: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}),g&&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,b=f.doH,g=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||g||N),C={mouseEvent:e,clientX:t,clientY:a,doResize:g,doDrag:R,doRotate:A,doSetCenter:N,onExecution:!0,cursor:null,dox:/\x/.test(s)&&(!g||(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)&&(!g||(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};g?_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,V=l.rotate,w=g?E_RESIZE$1:A?E_ROTATE$1:E_DRAG$2,P=g&&D||A&&V||R&&I;n.notify(ON_GETSTATE$2,this,{clientX:t,clientY:a,actionName:w,triggerEvent:P,factor:v,revX:E,revY:m,doW:x,doH:b}),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=this.storage,u=c.doResize,d=c.doDrag,f=c.doRotate,h=c.frame,_=c.handles.radius,T=c.isTarget,p=this.proxyMethods;if(T){var y=u?E_RESIZE$1:d?E_DRAG$2:E_ROTATE$1;l.doResize=!1,l.doDrag=!1,l.doRotate=!1,l.doSetCenter=!1,l.doDraw=!1,l.onExecution=!1,l.cursor=null,n.map((function(e){return t._applyTransformToElement(e,y)}));var v={clientX:a,clientY:o};p.onDrop.call(this,v),u?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE_END$1,v):f?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE_END$1,v):d&&_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_DRAG_END$1,v);var E=i.move,m=i.resize,x=i.rotate,b=u&&m||f&&x||d&&E;s.notify(ON_APPLY$2,this,{clientX:a,clientY:o,actionName:y,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:"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:"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.rotationPoint,o=r.container,n=r.controlsContainer,i=r.resizable,s=r.rotatable,l=r.showNormal,c=createElement(["sjx-wrapper"]),u=createElement(["sjx-controls"]),d={},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={};if(s){var E=l?renderLine([[p.x,p.y],_],"normal"):null;l&&u.appendChild(E);var m=null;a&&(m=renderLine([y.center,y.center],"radius"),addClass(m,"sjx-hidden"),u.appendChild(m)),v=_objectSpread2({},v,{normal:E,radius:m})}var x={te:[y.tl,y.tr],be:[y.bl,y.br],le:[y.tl,y.bl],re:[y.tr,y.br]},b=i?{tl:y.tl,tr:y.tr,br:y.br,bl:y.bl,tc:y.tc,bc:y.bc,ml:y.ml,mr:y.mr}:{},g=Array.isArray(a)?[].concat(_toConsumableArray(a),[0,1]):y.center,S=_objectSpread2({},b,{center:a&&s?g:void 0,rotator:_}),M=function(e,t){return keys$1(e).map((function(r){var a=e[r];if(!isUndef(a)){var o=t(a,r);d[r]=o,u.appendChild(o)}}))};M(x,renderLine),M(S,createHandler),c.appendChild(u),n.appendChild(c);var O=new WeakMap;e.map((function(e){return O.set(e,{parent:e.parentNode,transform:{ctm:getCurrentTransformMatrix(e,o)},bBox:t._getBBox(),__data__:new WeakMap,cached:{}})})),this.storage={wrapper:c,controls:u,handles:_objectSpread2({},d,{},v),data:O,center:{isShifted:Boolean(a)}},[].concat(_toConsumableArray(e),[u]).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)){if(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)}this.storage.cached={}}}},{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,b=T.get(e),g=b.transform,S=g.matrix,M=g.auxiliary.scale.translateMatrix,O=b.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({},b,{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,n=o.data,i=o.center,s=n.get(e),l=s.transform,c=l.matrix,u=l.auxiliary.translate.parentMatrix,d=s.cached,f=void 0===d?{}:d,h=_slicedToArray(multiplyMatrixAndPoint(u,[r,a,0,1]),2),_=h[0],T=h[1],p=multiplyMatrix(c,createTranslateMatrix(_,T)),y=matrixToCSS(flatMatrix(p));return this._updateElementView(e,y),n.set(e,_objectSpread2({},s,{cached:_objectSpread2({},f,{dist:{dx:floatToFixed(r),dy:floatToFixed(a),ox:floatToFixed(_),oy:floatToFixed(T)}})})),i.isShifted,p}},{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.wrapper,c=i.data,u=this.options,d=u.container,f=u.restrict,h=u.scalable,_=c.get(e).parent,T=f||d,p=T.offsetWidth,y=T.offsetHeight,v=_slicedToArray(getAbsoluteOffset(e,d),2),E=v[0],m=v[1],x=e.offsetLeft,b=e.offsetTop,g=e.offsetWidth,S=e.offsetHeight,M=getTransform(e),O=getCurrentTransformMatrix(e,d),A=getCurrentTransformMatrix(_,d),N=getCurrentTransformMatrix(l,d),R=f?getCurrentTransformMatrix(f,f.parentNode):getCurrentTransformMatrix(d,d.parentNode),C=g/2,k=S/2,I=_slicedToArray(multiplyMatrixAndPoint(O,[C,k,0,1]),2),D=n?0:r?-C:C,V=o?0:a?-k:k,w=I[0]+E,P=I[1]+m,$=s?getTransform(s):createIdentityMatrix(),L=(s?decompose(getCurrentTransformMatrix(s)):{translate:{x:w,y:P}}).translate,G=L.x,j=L.y,F=_slicedToArray(multiplyMatrixAndPoint(multiplyMatrix(matrixInvert(dropTranslate(O)),dropTranslate($)),[G-w,j-P,0,1]),2),H=F[0],U=F[1],B=_slicedToArray(multiplyMatrixAndPoint(M,[H,U,0,1]),2),Y=B[0],z=B[1],X=multiplyMatrixAndPoint(dropTranslate(R),[p,y,0,1]),W=decompose(getCurrentTransformMatrix(e,e.parentNode)).scale,Z=W.sX,K=W.sY;return{transform:{auxiliary:{scale:{translateMatrix:h?createTranslateMatrix(D,V):createTranslateMatrix(n?0:C,o?0:k)},translate:{parentMatrix:matrixInvert(dropTranslate(A))},rotate:{translateMatrix:createTranslateMatrix(Y,z)}},scaleX:D,scaleY:V,matrix:M,ctm:O,parentMatrix:A,containerMatrix:R,wrapperMatrix:N,scX:Z,scY:K,containerBox:X},bBox:{width:g,height:S,left:x,top:b,offset:{left:E,top:m}}}}},{key:"_getCommonState",value:function(){var e=this.elements,t=this.storage,r=t.controls,a=t.handles.center,o=t.center,n=this.options,i=n.container,s=n.restrict,l=_slicedToArray(getAbsoluteOffset(e[0],i),2),c=l[0],u=l[1],d=getCurrentTransformMatrix(e[0],i),f=this._getBBox(),h=f.width,_=f.height,T=_slicedToArray(multiplyMatrixAndPoint(d,[h/2,_/2,0,1]),2),p=T[0]+c,y=T[1]+u,v=a?getTransform(a):createIdentityMatrix();return{transform:{controlsMatrix:getCurrentTransformMatrix(r,r.parentNode),containerMatrix:s?getCurrentTransformMatrix(s,s.parentNode):getCurrentTransformMatrix(i,i.parentNode)},bBox:_objectSpread2({},this._getBBox()),center:_objectSpread2({},o,{x:p,y:y,matrix:v})}}},{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(){this._applyTransformToHandles({boxMatrix:createIdentityMatrix()})}},{key:"_processControlsMove",value:function(e){var t=e.dx,r=e.dy,a=this.storage.transform.controlsMatrix,o=multiplyMatrix(a,createTranslateMatrix(t,r)),n=matrixToCSS(flatMatrix(o));this._updateControlsView(n)}},{key:"_processControlsRotate",value:function(){this._applyTransformToHandles({boxMatrix:createIdentityMatrix()})}},{key:"_moveCenterHandle",value:function(e,t){var r=this.storage,a=r.handles.center,o=r.center.matrix,n=multiplyMatrix(o,createTranslateMatrix(e,t));helper(a).css(_objectSpread2({},matrixToCSS(flatMatrix(n)))),this.storage.center.isShifted=!0}},{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,b=p.bBox,g=b.width,S=b.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?(g+r)/g:(S+a)/S,[(n=O?g*o:g+r)/g,(i=O?S*o:S+a)/S,n,i]),2),I=k[0],D=k[1],V=(s=createScaleMatrix(I,D),multiplyMatrix(multiplyMatrix(C,s),matrixInvert(C))),w=A?multiplyMatrix(V,R):(c=R,u=(l=V)[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(e){helper(this.storage.controls).css(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.center,u=(c=void 0===c?{}:c).isShifted,d=void 0!==u&&u,f=s.transform.controlsMatrix,h=multiplyMatrix(r,matrixInvert(f)),_=this._getVertices(h),T=_.anchor,p=void 0===T?null:T,y=_.center,v=_objectWithoutProperties(_,["anchor","center"]),E=null,m={};o&&(E=i?[[p.x,p.y],v.rotator]:null,m={rotator:v.rotator});var x=_objectSpread2({te:[v.tl,v.tr],be:[v.bl,v.br],le:[v.tl,v.bl],re:[v.tr,v.br]},i&&E&&{normal:E});keys$1(x).forEach((function(e){var t=_slicedToArray(x[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 b=_objectSpread2({},n&&v,{},m,{},!d&&Boolean(y)&&{center:y});keys$1(b).forEach((function(e){var t=l[e],r=b[e];if(!isUndef(r)&&!isUndef(t)){var a=_slicedToArray(r,2),o=a[0],n=a[1];helper(t).css({transform:"translate(".concat(o,"px, ").concat(n,"px)")})}}))}},{key:"resetCenterPoint",value:function(){var e=this.elements,t=_slicedToArray(e=void 0===e?[]:e,1)[0],r=this.storage,a=r.wrapper,o=r.handles.center,n=this.options.container;if(o){var i=t.offsetHeight,s=t.offsetWidth,l=_slicedToArray(getAbsoluteOffset(t,n),2),c=l[0],u=l[1],d=multiplyMatrix(getCurrentTransformMatrix(t,n),matrixInvert(getCurrentTransformMatrix(a,a.parentNode))),f=_slicedToArray(multiplyMatrixAndPoint(d,[s/2,i/2,0,1]),2),h=f[0],_=f[1];helper(o).css({transform:"translate(".concat(h+c,"px, ").concat(_+u,"px)")})}}},{key:"fitControlsToSize",value:function(){var e=createIdentityMatrix();this.storage=_objectSpread2({},this.storage,{transform:_objectSpread2({},this.storage.transform||{},{controlsMatrix:e})}),this._updateControlsView(matrixToCSS(flatMatrix(e))),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.elements,r=this.options.container,a=this._getVertices(),o=(a.anchor,a.rotator,a.center,_objectWithoutProperties(a,["anchor","rotator","center"])),n=this._getRestrictedBBox(!0),i=values$1(o),s=_slicedToArray(getMinMaxOfArray(n),2),l=_slicedToArray(s[0],2),c=l[0],u=l[1],d=_slicedToArray(s[1],2),f=d[0],h=d[1],_=_slicedToArray(getMinMaxOfArray(i),2),T=_slicedToArray(_[0],2),p=T[0],y=T[1],v=_slicedToArray(_[1],2),E=v[0],m=v[1],x=_slicedToArray(multiplyMatrixAndPoint(matrixInvert(dropTranslate(getCurrentTransformMatrix(t[0].parentNode,r))),[function(){switch(!0){case/[l]/.test(e):return c-p;case/[r]/.test(e):return u-y;case/[h]/.test(e):return(u+c)/2-(y+p)/2;default:return 0}}(),function(){switch(!0){case/[t]/.test(e):return f-E;case/[b]/.test(e):return h-m;case/[v]/.test(e):return(h+f)/2-(m+E)/2;default:return 0}}(),0,1]),2),b=x[0],g=x[1],S=multiplyMatrix(getTransform(t[0]),createTranslateMatrix(b,g));this._updateElementView(t[0],matrixToCSS(flatMatrix(S))),this.fitControlsToSize()}}]),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*=g=Math.sqrt(g),i*=g);var S=n*n,M=i*i,O=S*M-S*b*b-M*x*x,A=S*b*b+M*x*x,N=(l===c?-1:1)*Math.sqrt(Math.abs(O/A));_=N*n*b/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 V=Math.cos(f),w=Math.sin(f),P=Math.cos(h),$=Math.sin(h),L=Math.tan(R/4),G=4/3*n*L,j=4/3*i*L,F=[t,r],H=[t+G*w,r-j*V],U=[a+G*$,o-j*P],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.rotationPoint,o=r.container,n=r.controlsContainer,i=r.resizable,s=r.rotatable,l=r.showNormal,c=createSVGElement("g",["sjx-svg-wrapper"]),u=createSVGElement("g",["sjx-svg-controls"]),d=this._getVertices(),f=d.rotator,h=void 0===f?null:f,_=d.anchor,T=void 0===_?null:_,p=_objectWithoutProperties(d,["rotator","anchor"]),y={},v={},E=Array.isArray(a)?pointTo(createSVGMatrix(),a[0],a[1]):p.center;if(s){var m=l?renderLine$1([T,h],THEME_COLOR,"normal"):null;l&&u.appendChild(m);var x=null;a&&((x=createSVGElement("line",["sjx-hidden"])).x1.baseVal.value=p.center.x,x.y1.baseVal.value=p.center.y,x.x2.baseVal.value=E.x,x.y2.baseVal.value=E.y,setLineStyle(x,"#fe3232"),x.setAttribute("opacity",.5),u.appendChild(x)),v=_objectSpread2({},v,{normal:m,radius:x})}var b=i?{tl:p.tl,tr:p.tr,br:p.br,bl:p.bl,tc:p.tc,bc:p.bc,ml:p.ml,mr:p.mr}:{},g={te:[p.tl,p.tr],be:[p.bl,p.br],le:[p.tl,p.bl],re:[p.tr,p.br]};keys$2(g).forEach((function(e){var t=g[e];isUndef(t)||(y[e]=renderLine$1(t,THEME_COLOR,e),u.appendChild(y[e]))}));var S=_objectSpread2({},b,{rotator:h,center:a&&s?E:void 0});keys$2(S).forEach((function(e){var t=S[e];if(!isUndef(t)){var r=t.x,a=t.y,o="center"===e?"#fe3232":THEME_COLOR;y[e]=createHandler$1(r,a,o,e),u.appendChild(y[e])}})),c.appendChild(u),n.appendChild(c);var M=new WeakMap;e.map((function(e){return M.set(e,{parent:e.parentNode,transform:{ctm:getTransformToElement(e,o)},bBox:e.getBBox(),__data__:new WeakMap,cached:{}})})),this.storage={wrapper:c,controls:u,handles:_objectSpread2({},y,{},v),data:M,center:{isShifted:Boolean(a)}},[].concat(_toConsumableArray(e),[u]).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,b=E.ox,g=E.oy,S=d.transformMatrix;if(t===E_DRAG$3){if(!l||!m&&!x)return;var M=createTranslateMatrix$1(b,g),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,b,g),n=o.x,i=o.y;applyTranslate(e,{x:n,y:i})}})):applyTranslate(e,{x:b,y:g})}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})}i&&t===E_ROTATE$2&&(this._applyTransformToHandles(),this._updateControlsView()),a.set(e,_objectSpread2({},f))}},{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,b=m.auxiliary.scale.translateMatrix,g=E.cached,S=void 0===g?{}:g,M=_slicedToArray(function(e,t){var r=s||!s&&!l?(h+e)/h:(_+t)/_,a=y?h*r:h+e,o=y?_*r:_+t;return[a/h,o/_,a,o]}(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 b.multiply(r).multiply(b.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=u.get(e),_=h.__data__;storeElementAttributes(e,h,s),_.delete(e),checkChildElements(e).forEach((function(t){_.delete(t),storeElementAttributes(t,h,e,l)}));var T=this._getBBox(),p=T.x,y=T.y,v=T.width,E=T.height,m=getTransformToElement(e,e.parentNode),x=getTransformToElement(e,s),b=getTransformToElement(e.parentNode,s),g=b.inverse(),S=p+v*(n?.5:r?1:0),M=y+E*(o?.5:a?1:0),O=getTransformToElement(d,s),A=p+v/2,N=y+E/2,R=f?f.cx.baseVal.value:A,C=f?f.cy.baseVal.value:N,k=pointTo(O,R,C),I=k.x,D=k.y,V=f?pointTo(g,I,D):pointTo(l?g:m,A,N),w=V.x,P=V.y,$=pointTo(l?g:createSVGMatrix(),S,M),L=$.x,G=$.y;return{transform:{auxiliary:{scale:{scaleMatrix:createSVGMatrix(),translateMatrix:createTranslateMatrix$1(L,G)},translate:{parentMatrix:g,translateMatrix:createSVGMatrix()},rotate:{translateMatrix:createTranslateMatrix$1(w,P)}},matrix:m,ctm:x,parentMatrix:b,scX:Math.sqrt(x.a*x.a+x.b*x.b),scY:Math.sqrt(x.c*x.c+x.d*x.d)},bBox:T}}},{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,b=o?getTransformToElement(o,o.parentNode):getTransformToElement(a,a.parentNode),g=_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(g.x,g.y)},bBox:l,center:g}}},{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,b=m.y;v.x=x,v.y=b;break;case"s":var g=y.bc,S=g.x,M=g.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,V={x:v.x-D*Math.cos(I),y:v.y-D*Math.sin(I)};y.rotator=V,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.center,l=s.hx,c=s.hy,u=r.transform,d=(u=void 0===u?{}:u).controlsMatrix,f=void 0===d?createSVGMatrix():d;if(!isUndef(o)){var h=l+e,_=c+t;o.cx.baseVal.value=h,o.cy.baseVal.value=_,n.x2.baseVal.value=h,n.y2.baseVal.value=_,this.storage.center=_objectSpread2({},i,{isShifted:!0,cached:_objectSpread2({},pointTo(f.inverse(),h,_))})}}},{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=t.dx,l=t.dy,c=this.storage,u=c.doW,d=c.doH,f=c.data,h=c.bBox,_=h.width,T=h.height,p=this.options.proportions,y=f.get(e).transform,v=y.matrix,E=y.auxiliary.scale.translateMatrix,m=v.multiply(function(e,t){var r=createScaleMatrix$1(e,t);return E.multiply(r).multiply(E.inverse())}.apply(void 0,_toConsumableArray((r=s,a=l,o=u||!u&&!d?(_+r)/_:(T+a)/T,[(n=p?_*o:_+r)/_,(i=p?T*o:T+a)/T,n,i]))));return this._restrictHandler(e,m)}},{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))}},{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});keys$2(T).forEach((function(e){var t=n[e],r=T[e];isUndef(r)||isUndef(t)||(t.setAttribute("cx",r.x),t.setAttribute("cy",r.y))}))}},{key:"resetCenterPoint",value:function(){var e=this.elements,t=this.storage,r=(t=void 0===t?{}:t).controls,a=t.handles,o=(a=void 0===a?{}:a).center,n=a.radius,i=t.center,s=this.options,l=s.container,c=s.isGrouped;if(i&&o&&n){var u=this._getBBox(),d=u.x,f=u.y,h=u.width/2,_=u.height/2,T=getTransformToElement(r,r.parentNode).inverse(),p=c?T:T.multiply(getTransformToElement(e[0],l)),y=pointTo(p,d+h,f+_),v=y.x,E=y.y;o.cx.baseVal.value=v,o.cy.baseVal.value=E,n.x2.baseVal.value=v,n.y2.baseVal.value=E,i.isShifted=!1}}},{key:"fitControlsToSize",value:function(){var e=this.storage,t=void 0===e?{}:e,r=createSVGMatrix();this.storage=_objectSpread2({},t,{transform:_objectSpread2({},t.transform||{},{controlsMatrix:r})}),this._updateControlsView(r),this._applyTransformToHandles({boxMatrix:r})}},{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()}}]),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,b=E*(Math.abs(r)+Math.abs(a))/2,g=pointTo(o,m,x),S=g.x,M=g.y;d.push(["r",b],["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,V=pointTo(o,I,D),w=V.x,P=V.y,$=Math.abs(C*r),L=Math.abs(k*a);d.push(["x",w-(r<0?$:0)],["y",P-(a<0?L:0)],["width",$],["height",L])}break;case"ellipse":var G=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,G,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,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,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.restrict,y=e.draggable,v=void 0===y||y,E=e.resizable,m=void 0===E||E,x=e.rotatable,b=void 0===x||x,g=e.scalable,S=void 0!==g&&g,M=e.applyTranslate,O=void 0!==M&&M,A=e.onInit,N=void 0===A?noop:A,R=e.onDrop,C=void 0===R?noop:R,k=e.onMove,I=void 0===k?noop:k,D=e.onResize,P=void 0===D?noop:D,V=e.onRotate,w=void 0===V?noop:V,$=e.onDestroy,L=void 0===$?noop:$,G=e.container,j=void 0===G?t[0].parentNode:G,F=e.controlsContainer,H=void 0===F?j:F,U=e.proportions,B=void 0!==U&&U,Y=e.rotatorAnchor,z=void 0===Y?null:Y,X=e.rotatorOffset,W=void 0===X?50:X,Z=e.showNormal,K=void 0===Z||Z,q=e.custom;this.options={axis:s,cursorMove:c,cursorRotate:h,cursorResize:d,rotationPoint:T,restrict:p?helper(p)[0]||document.body:null,container:helper(j)[0],controlsContainer:helper(H)[0],snap:_objectSpread2({},n,{angle:n.angle*RAD}),each:a,proportions:B,draggable:v,resizable:m,rotatable:b,scalable:S,applyTranslate:O,custom:"object"===_typeof(q)&&q||null,rotatorAnchor:z,rotatorOffset:W,showNormal:K,isGrouped:t.length>1},this.proxyMethods={onInit:createMethod(N),onDrop:createMethod(C),onMove:createMethod(I),onResize:createMethod(P),onRotate:createMethod(w),onDestroy:createMethod(L)},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,b=n.each,g=b.move,S=b.resize,M=b.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,V=(P=void 0===P?{}:P).dist,w=(V=void 0===V?{}:V).dx,$=void 0===w?k:w,L=V.dy,G=void 0===L?I:L,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?G: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}),g&&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,b=f.doH,g=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||g||N),C={mouseEvent:e,clientX:t,clientY:a,doResize:g,doDrag:R,doRotate:A,doSetCenter:N,onExecution:!0,cursor:null,dox:/\x/.test(s)&&(!g||(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)&&(!g||(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};g?_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,V=g?E_RESIZE$1:A?E_ROTATE$1:E_DRAG$2,w=g&&D||A&&P||R&&I;n.notify(ON_GETSTATE$2,this,{clientX:t,clientY:a,actionName:V,triggerEvent:w,factor:v,revX:E,revY:m,doW:x,doH:b}),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=this.storage,u=c.doResize,d=c.doDrag,f=c.doRotate,h=c.doSetCenter,_=c.frame,T=c.handles.radius,p=c.isTarget,y=this.proxyMethods;if(p){var v=([{actionName:E_RESIZE$1,condition:u},{actionName:E_DRAG$2,condition:d},{actionName:E_ROTATE$1,condition:f},{actionName:E_SET_POINT$1,condition:h}].find((function(e){return e.condition}))||{}).actionName,E=void 0===v?E_DRAG$2:v;l.doResize=!1,l.doDrag=!1,l.doRotate=!1,l.doSetCenter=!1,l.doDraw=!1,l.onExecution=!1,l.cursor=null,n.map((function(e){return t._applyTransformToElement(e,E)}));var m={clientX:a,clientY:o};y.onDrop.call(this,m),u?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_RESIZE_END$1,m):f?_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_ROTATE_END$1,m):d&&_get(_getPrototypeOf(r.prototype),"_emitEvent",this).call(this,E_DRAG_END$1,m);var x=i.move,b=i.resize,g=i.rotate,S=u&&b||f&&g||d&&x;s.notify(ON_APPLY$2,this,{clientX:a,clientY:o,actionName:E,triggerEvent:S}),cancelAnimFrame(_),helper(document.body).css({cursor:"auto"}),isDef(T)&&addClass(T,"".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:"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:"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.rotationPoint,o=r.container,n=r.controlsContainer,i=r.resizable,s=r.rotatable,l=r.showNormal,c=createElement(["sjx-wrapper"]),u=createElement(["sjx-controls"]),d={},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={};if(s){var E=l?renderLine([[p.x,p.y],_],"normal"):null;l&&u.appendChild(E);var m=null;a&&(m=renderLine([y.center,y.center],"radius"),addClass(m,"sjx-hidden"),u.appendChild(m)),v=_objectSpread2({},v,{normal:E,radius:m})}var x={te:[y.tl,y.tr],be:[y.bl,y.br],le:[y.tl,y.bl],re:[y.tr,y.br]},b=i?{tl:y.tl,tr:y.tr,br:y.br,bl:y.bl,tc:y.tc,bc:y.bc,ml:y.ml,mr:y.mr}:{},g=Array.isArray(a)?[].concat(_toConsumableArray(a),[0,1]):y.center,S=_objectSpread2({},b,{center:a&&s?g:void 0,rotator:_}),M=function(e,t){return keys$1(e).map((function(r){var a=e[r];if(!isUndef(a)){var o=t(a,r);d[r]=o,u.appendChild(o)}}))};M(x,renderLine),M(S,createHandler),c.appendChild(u),n.appendChild(c);var O=new WeakMap;e.map((function(e){return O.set(e,{parent:e.parentNode,transform:{ctm:getCurrentTransformMatrix(e,o)},bBox:t._getBBox(),__data__:new WeakMap,cached:{}})})),this.storage={wrapper:c,controls:u,handles:_objectSpread2({},d,{},v),data:O,center:{isShifted:Array.isArray(a)}},[].concat(_toConsumableArray(e),[u]).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)){if(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)}this.storage.cached={}}}},{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,b=T.get(e),g=b.transform,S=g.matrix,M=g.auxiliary.scale.translateMatrix,O=b.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({},b,{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,n=o.data,i=o.center,s=n.get(e),l=s.transform,c=l.matrix,u=l.auxiliary.translate.parentMatrix,d=s.cached,f=void 0===d?{}:d,h=_slicedToArray(multiplyMatrixAndPoint(u,[r,a,0,1]),2),_=h[0],T=h[1],p=multiplyMatrix(c,createTranslateMatrix(_,T)),y=matrixToCSS(flatMatrix(p));return this._updateElementView(e,y),n.set(e,_objectSpread2({},s,{cached:_objectSpread2({},f,{dist:{dx:floatToFixed(r),dy:floatToFixed(a),ox:floatToFixed(_),oy:floatToFixed(T)}})})),i.isShifted,p}},{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.wrapper,c=i.data,u=this.options,d=u.container,f=u.restrict,h=u.scalable,_=c.get(e).parent,T=f||d,p=T.offsetWidth,y=T.offsetHeight,v=_slicedToArray(getAbsoluteOffset(e,d),2),E=v[0],m=v[1],x=e.offsetLeft,b=e.offsetTop,g=e.offsetWidth,S=e.offsetHeight,M=getTransform(e),O=getCurrentTransformMatrix(e,d),A=getCurrentTransformMatrix(_,d),N=getCurrentTransformMatrix(l,d),R=f?getCurrentTransformMatrix(f,f.parentNode):getCurrentTransformMatrix(d,d.parentNode),C=g/2,k=S/2,I=_slicedToArray(multiplyMatrixAndPoint(O,[C,k,0,1]),2),D=n?0:r?-C:C,P=o?0:a?-k:k,V=I[0]+E,w=I[1]+m,$=s?getTransform(s):createIdentityMatrix(),L=(s?decompose(getCurrentTransformMatrix(s)):{translate:{x:V,y:w}}).translate,G=L.x,j=L.y,F=_slicedToArray(multiplyMatrixAndPoint(multiplyMatrix(matrixInvert(dropTranslate(O)),dropTranslate($)),[G-V,j-w,0,1]),2),H=F[0],U=F[1],B=_slicedToArray(multiplyMatrixAndPoint(M,[H,U,0,1]),2),Y=B[0],z=B[1],X=multiplyMatrixAndPoint(dropTranslate(R),[p,y,0,1]),W=decompose(getCurrentTransformMatrix(e,e.parentNode)).scale,Z=W.sX,K=W.sY;return{transform:{auxiliary:{scale:{translateMatrix:h?createTranslateMatrix(D,P):createTranslateMatrix(n?0:C,o?0:k)},translate:{parentMatrix:matrixInvert(dropTranslate(A))},rotate:{translateMatrix:createTranslateMatrix(Y,z)}},scaleX:D,scaleY:P,matrix:M,ctm:O,parentMatrix:A,containerMatrix:R,wrapperMatrix:N,scX:Z,scY:K,containerBox:X},bBox:{width:g,height:S,left:x,top:b,offset:{left:E,top:m}}}}},{key:"_getCommonState",value:function(){var e=this.elements,t=this.storage,r=t.controls,a=t.handles.center,o=t.center,n=this.options,i=n.container,s=n.restrict,l=_slicedToArray(getAbsoluteOffset(e[0],i),2),c=l[0],u=l[1],d=getCurrentTransformMatrix(e[0],i),f=this._getBBox(),h=f.width,_=f.height,T=_slicedToArray(multiplyMatrixAndPoint(d,[h/2,_/2,0,1]),2),p=T[0]+c,y=T[1]+u,v=a?getTransform(a):createIdentityMatrix();return{transform:{controlsMatrix:getCurrentTransformMatrix(r,r.parentNode),containerMatrix:s?getCurrentTransformMatrix(s,s.parentNode):getCurrentTransformMatrix(i,i.parentNode)},bBox:_objectSpread2({},this._getBBox()),center:_objectSpread2({},o,{x:p,y:y,matrix:v})}}},{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(){this._applyTransformToHandles({boxMatrix:createIdentityMatrix()})}},{key:"_processControlsMove",value:function(e){var t=e.dx,r=e.dy,a=this.storage.transform.controlsMatrix,o=multiplyMatrix(a,createTranslateMatrix(t,r)),n=matrixToCSS(flatMatrix(o));this._updateControlsView(n)}},{key:"_processControlsRotate",value:function(){this._applyTransformToHandles({boxMatrix:createIdentityMatrix()})}},{key:"_moveCenterHandle",value:function(e,t){var r=this.storage,a=r.handles.center,o=r.center.matrix,n=multiplyMatrix(o,createTranslateMatrix(e,t));helper(a).css(_objectSpread2({},matrixToCSS(flatMatrix(n)))),this.storage.center.isShifted=!0}},{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,b=p.bBox,g=b.width,S=b.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?(g+r)/g:(S+a)/S,[(n=O?g*o:g+r)/g,(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))),V=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(V)}},{key:"_updateElementView",value:function(e,t){helper(e).css(t)}},{key:"_updateControlsView",value:function(e){helper(this.storage.controls).css(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.center,u=(c=void 0===c?{}:c).isShifted,d=void 0!==u&&u,f=s.transform.controlsMatrix,h=multiplyMatrix(r,matrixInvert(f)),_=this._getVertices(h),T=_.anchor,p=void 0===T?null:T,y=_.center,v=_objectWithoutProperties(_,["anchor","center"]),E=null,m={};o&&(E=i?[[p.x,p.y],v.rotator]:null,m={rotator:v.rotator});var x=_objectSpread2({te:[v.tl,v.tr],be:[v.bl,v.br],le:[v.tl,v.bl],re:[v.tr,v.br]},i&&E&&{normal:E});keys$1(x).forEach((function(e){var t=_slicedToArray(x[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 b=_objectSpread2({},n&&v,{},m,{},!d&&Boolean(y)&&{center:y});keys$1(b).forEach((function(e){var t=l[e],r=b[e];if(!isUndef(r)&&!isUndef(t)){var a=_slicedToArray(r,2),o=a[0],n=a[1];helper(t).css({transform:"translate(".concat(o,"px, ").concat(n,"px)")})}}))}},{key:"resetCenterPoint",value:function(){var e=this.elements,t=_slicedToArray(e=void 0===e?[]:e,1)[0],r=this.storage,a=r.wrapper,o=r.handles.center,n=this.options.container;if(o){var i=t.offsetHeight,s=t.offsetWidth,l=_slicedToArray(getAbsoluteOffset(t,n),2),c=l[0],u=l[1],d=multiplyMatrix(getCurrentTransformMatrix(t,n),matrixInvert(getCurrentTransformMatrix(a,a.parentNode))),f=_slicedToArray(multiplyMatrixAndPoint(d,[s/2,i/2,0,1]),2),h=f[0],_=f[1];helper(o).css({transform:"translate(".concat(h+c,"px, ").concat(_+u,"px)")})}}},{key:"fitControlsToSize",value:function(){var e=createIdentityMatrix();this.storage=_objectSpread2({},this.storage,{transform:_objectSpread2({},this.storage.transform||{},{controlsMatrix:e})}),this._updateControlsView(matrixToCSS(flatMatrix(e))),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.elements,r=this.options.container,a=this._getVertices(),o=(a.anchor,a.rotator,a.center,_objectWithoutProperties(a,["anchor","rotator","center"])),n=this._getRestrictedBBox(!0),i=values$1(o),s=_slicedToArray(getMinMaxOfArray(n),2),l=_slicedToArray(s[0],2),c=l[0],u=l[1],d=_slicedToArray(s[1],2),f=d[0],h=d[1],_=_slicedToArray(getMinMaxOfArray(i),2),T=_slicedToArray(_[0],2),p=T[0],y=T[1],v=_slicedToArray(_[1],2),E=v[0],m=v[1],x=_slicedToArray(multiplyMatrixAndPoint(matrixInvert(dropTranslate(getCurrentTransformMatrix(t[0].parentNode,r))),[function(){switch(!0){case/[l]/.test(e):return c-p;case/[r]/.test(e):return u-y;case/[h]/.test(e):return(u+c)/2-(y+p)/2;default:return 0}}(),function(){switch(!0){case/[t]/.test(e):return f-E;case/[b]/.test(e):return h-m;case/[v]/.test(e):return(h+f)/2-(m+E)/2;default:return 0}}(),0,1]),2),b=x[0],g=x[1],S=multiplyMatrix(getTransform(t[0]),createTranslateMatrix(b,g));this._updateElementView(t[0],matrixToCSS(flatMatrix(S))),this.fitControlsToSize()}}]),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*=g=Math.sqrt(g),i*=g);var S=n*n,M=i*i,O=S*M-S*b*b-M*x*x,A=S*b*b+M*x*x,N=(l===c?-1:1)*Math.sqrt(Math.abs(O/A));_=N*n*b/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),V=Math.sin(f),w=Math.cos(h),$=Math.sin(h),L=Math.tan(R/4),G=4/3*n*L,j=4/3*i*L,F=[t,r],H=[t+G*V,r-j*P],U=[a+G*$,o-j*w],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.rotationPoint,o=r.container,n=r.controlsContainer,i=r.resizable,s=r.rotatable,l=r.showNormal,c=createSVGElement("g",["sjx-svg-wrapper"]),u=createSVGElement("g",["sjx-svg-controls"]),d=this._getVertices(),f=d.rotator,h=void 0===f?null:f,_=d.anchor,T=void 0===_?null:_,p=_objectWithoutProperties(d,["rotator","anchor"]),y={},v={},E=Array.isArray(a)?pointTo(createSVGMatrix(),a[0],a[1]):p.center;if(s){var m=l?renderLine$1([T,h],THEME_COLOR,"normal"):null;l&&u.appendChild(m);var x=null;a&&((x=createSVGElement("line",["sjx-hidden"])).x1.baseVal.value=p.center.x,x.y1.baseVal.value=p.center.y,x.x2.baseVal.value=E.x,x.y2.baseVal.value=E.y,setLineStyle(x,"#fe3232"),x.setAttribute("opacity",.5),u.appendChild(x)),v=_objectSpread2({},v,{normal:m,radius:x})}var b=i?{tl:p.tl,tr:p.tr,br:p.br,bl:p.bl,tc:p.tc,bc:p.bc,ml:p.ml,mr:p.mr}:{},g={te:[p.tl,p.tr],be:[p.bl,p.br],le:[p.tl,p.bl],re:[p.tr,p.br]};keys$2(g).forEach((function(e){var t=g[e];isUndef(t)||(y[e]=renderLine$1(t,THEME_COLOR,e),u.appendChild(y[e]))}));var S=_objectSpread2({},b,{rotator:h,center:a&&s?E:void 0});keys$2(S).forEach((function(e){var t=S[e];if(!isUndef(t)){var r=t.x,a=t.y,o="center"===e?"#fe3232":THEME_COLOR;y[e]=createHandler$1(r,a,o,e),u.appendChild(y[e])}})),c.appendChild(u),n.appendChild(c);var M=new WeakMap;e.map((function(e){return M.set(e,{parent:e.parentNode,transform:{ctm:getTransformToElement(e,o)},bBox:e.getBBox(),__data__:new WeakMap,cached:{}})})),this.storage={wrapper:c,controls:u,handles:_objectSpread2({},y,{},v),data:M,center:{isShifted:Array.isArray(a)}},[].concat(_toConsumableArray(e),[u]).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=r.transform.controlsMatrix,i=r.center.isShifted,s=this.options,l=(s=void 0===s?{}:s).isGrouped,c=s.scalable,u=s.applyTranslate,d=a.get(e),f=d.cached,h=void 0===f?{}:f,_=_objectWithoutProperties(d,["cached"]),T=_.transform,p=T.matrix,y=T.parentMatrix,v=_.__data__,E=h.scaleX,m=h.scaleY,x=h.dist,b=(x=void 0===x?{}:x).dx,g=x.dy,S=x.ox,M=x.oy,O=h.transformMatrix;if(t===E_DRAG$3){if(!u||!b&&!g)return;var A=createTranslateMatrix$1(S,M),N=A.multiply(p).multiply(A.inverse());this._updateElementView(["transform",N]),isSVGGroup(e)?checkChildElements(e).map((function(e){var t=createTranslateMatrix$1(b,g),r=t.multiply(getTransformToElement(e,e.parentNode)).multiply(t.inverse());if(isIdentity(r)||e.setAttribute("transform",matrixToString(r)),!isSVGGroup(e)){var a=y.inverse();a.e=a.f=0;var o=pointTo(a,S,M),n=o.x,i=o.y;applyTranslate(e,{x:n,y:i})}})):applyTranslate(e,{x:S,y:M})}if(t===E_RESIZE$2){if(!O)return;if(!c)if(isSVGGroup(e)||l)checkChildElements(e).forEach((function(t){if(!isSVGGroup(t)){var r=getTransformToElement(t,l?e.parentNode:e),a=r.inverse().multiply(O).multiply(r);applyResize(t,{dx:b,dy:g,scaleX:E,scaleY:m,localCTM:a,transformMatrix:O,bBox:o,__data__:v,isGrouped:l})}}));else applyResize(e,{dx:b,dy:g,scaleX:E,scaleY:m,localCTM:O,transformMatrix:O,bBox:o,__data__:v,isGrouped:l})}if(l&&t===E_ROTATE$2){if(this._applyTransformToHandles(),i){var R=pointTo(n,0,0),C=R.x,k=R.y;this._moveCenterHandle(C,k)}this._updateControlsView()}a.set(e,_objectSpread2({},_))}},{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,b=m.auxiliary.scale.translateMatrix,g=E.cached,S=void 0===g?{}:g,M=_slicedToArray(function(e,t){var r=s||!s&&!l?(h+e)/h:(_+t)/_,a=y?h*r:h+e,o=y?_*r:_+t;return[a/h,o/_,a,o]}(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 b.multiply(r).multiply(b.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=u.get(e),_=h.__data__;storeElementAttributes(e,h,s),_.delete(e),checkChildElements(e).forEach((function(t){_.delete(t),storeElementAttributes(t,h,e,l)}));var T=this._getBBox(),p=T.x,y=T.y,v=T.width,E=T.height,m=getTransformToElement(e,e.parentNode),x=getTransformToElement(e,s),b=getTransformToElement(e.parentNode,s),g=b.inverse(),S=p+v*(n?.5:r?1:0),M=y+E*(o?.5:a?1:0),O=getTransformToElement(d,s),A=p+v/2,N=y+E/2,R=f?f.cx.baseVal.value:A,C=f?f.cy.baseVal.value:N,k=pointTo(O,R,C),I=k.x,D=k.y,P=f?pointTo(g,I,D):pointTo(l?g:m,A,N),V=P.x,w=P.y,$=pointTo(l?g:createSVGMatrix(),S,M),L=$.x,G=$.y;return{transform:{auxiliary:{scale:{scaleMatrix:createSVGMatrix(),translateMatrix:createTranslateMatrix$1(L,G)},translate:{parentMatrix:g,translateMatrix:createSVGMatrix()},rotate:{translateMatrix:createTranslateMatrix$1(V,w)}},matrix:m,ctm:x,parentMatrix:b,scX:Math.sqrt(x.a*x.a+x.b*x.b),scY:Math.sqrt(x.c*x.c+x.d*x.d)},bBox:T}}},{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,b=o?getTransformToElement(o,o.parentNode):getTransformToElement(a,a.parentNode),g=_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(g.x,g.y)},bBox:l,center:g}}},{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,b=m.y;v.x=x,v.y=b;break;case"s":var g=y.bc,S=g.x,M=g.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.center,l=s.hx,c=s.hy,u=r.transform,d=(u=void 0===u?{}:u).controlsMatrix,f=void 0===d?createSVGMatrix():d;if(!isUndef(o)){var h=l+e,_=c+t;o.cx.baseVal.value=h,o.cy.baseVal.value=_,n.x2.baseVal.value=h,n.y2.baseVal.value=_,this.storage.center=_objectSpread2({},i,{isShifted:!0,cached:_objectSpread2({},pointTo(f.inverse(),h,_))})}}},{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=t.dx,l=t.dy,c=this.storage,u=c.doW,d=c.doH,f=c.data,h=c.bBox,_=h.width,T=h.height,p=this.options.proportions,y=f.get(e).transform,v=y.matrix,E=y.auxiliary.scale.translateMatrix,m=v.multiply(function(e,t){var r=createScaleMatrix$1(e,t);return E.multiply(r).multiply(E.inverse())}.apply(void 0,_toConsumableArray((r=s,a=l,o=u||!u&&!d?(_+r)/_:(T+a)/T,[(n=p?_*o:_+r)/_,(i=p?T*o:T+a)/T,n,i]))));return this._restrictHandler(e,m)}},{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))}},{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});keys$2(T).forEach((function(e){var t=n[e],r=T[e];isUndef(r)||isUndef(t)||(t.setAttribute("cx",r.x),t.setAttribute("cy",r.y))}))}},{key:"resetCenterPoint",value:function(){var e=this.elements,t=this.storage,r=(t=void 0===t?{}:t).controls,a=t.handles,o=(a=void 0===a?{}:a).center,n=a.radius,i=t.center,s=this.options,l=s.container,c=s.isGrouped;if(i&&o&&n){var u=this._getBBox(),d=u.x,f=u.y,h=u.width/2,_=u.height/2,T=getTransformToElement(r,r.parentNode).inverse(),p=c?T:T.multiply(getTransformToElement(e[0],l)),y=pointTo(p,d+h,f+_),v=y.x,E=y.y;o.cx.baseVal.value=v,o.cy.baseVal.value=E,n.x2.baseVal.value=v,n.y2.baseVal.value=E,i.isShifted=!1}}},{key:"fitControlsToSize",value:function(){var e=this.storage,t=void 0===e?{}:e,r=createSVGMatrix();this.storage=_objectSpread2({},t,{transform:_objectSpread2({},t.transform||{},{controlsMatrix:r})}),this._updateControlsView(r),this._applyTransformToHandles({boxMatrix:r})}},{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()}}]),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,b=E*(Math.abs(r)+Math.abs(a))/2,g=pointTo(o,m,x),S=g.x,M=g.y;d.push(["r",b],["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),V=P.x,w=P.y,$=Math.abs(C*r),L=Math.abs(k*a);d.push(["x",V-(r<0?$:0)],["y",w-(a<0?L:0)],["width",$],["height",L])}break;case"ellipse":var G=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,G,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 4e9519e..ef43cda 100644 --- a/dist/js/subjx.dev.common.js +++ b/dist/js/subjx.dev.common.js @@ -613,6 +613,7 @@ var E_RESIZE_END = 'resizeEnd'; var E_ROTATE_START = 'rotateStart'; var E_ROTATE = 'rotate'; var E_ROTATE_END = 'rotateEnd'; +var E_SET_POINT = 'setPoint'; var E_SET_POINT_START = 'setPointStart'; var E_SET_POINT_END = 'setPointEnd'; var 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]; @@ -642,6 +643,7 @@ var EVENT_EMITTER_CONSTANTS = { 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 }; @@ -1136,7 +1138,8 @@ var EMITTER_EVENTS$1 = EVENT_EMITTER_CONSTANTS.EMITTER_EVENTS, 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_ROTATE_END$1 = EVENT_EMITTER_CONSTANTS.E_ROTATE_END, + E_SET_POINT$1 = EVENT_EMITTER_CONSTANTS.E_SET_POINT; var TRANSFORM_HANDLES_KEYS$1 = TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_HANDLES_KEYS, TRANSFORM_EDGES_KEYS$1 = TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_EDGES_KEYS; var E_MOUSEDOWN$1 = CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN, @@ -1758,12 +1761,32 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { doResize = _this$storage2.doResize, doDrag = _this$storage2.doDrag, doRotate = _this$storage2.doRotate, + doSetCenter = _this$storage2.doSetCenter, frame = _this$storage2.frame, radius = _this$storage2.handles.radius, isTarget = _this$storage2.isTarget, proxyMethods = this.proxyMethods; if (!isTarget) return; - var actionName = doResize ? E_RESIZE$1 : doDrag ? E_DRAG$2 : E_ROTATE$1; + + var _ref8 = [{ + actionName: E_RESIZE$1, + condition: doResize + }, { + actionName: E_DRAG$2, + condition: doDrag + }, { + actionName: E_ROTATE$1, + condition: doRotate + }, { + actionName: E_SET_POINT$1, + condition: doSetCenter + }].find(function (_ref9) { + var condition = _ref9.condition; + return condition; + }) || {}, + _ref8$actionName = _ref8.actionName, + actionName = _ref8$actionName === void 0 ? E_DRAG$2 : _ref8$actionName; + storage.doResize = false; storage.doDrag = false; storage.doRotate = false; @@ -1967,11 +1990,11 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyMove", - value: function notifyMove(_ref8) { + value: function notifyMove(_ref10) { var _this6 = this; - var dx = _ref8.dx, - dy = _ref8.dy; + var dx = _ref10.dx, + dy = _ref10.dy; this.elements.map(function (element) { return _get(_getPrototypeOf(Transformable.prototype), "_drag", _this6).call(_this6, { element: element, @@ -1987,11 +2010,11 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyRotate", - value: function notifyRotate(_ref9) { + value: function notifyRotate(_ref11) { var _this7 = this; - var radians = _ref9.radians, - rest = _objectWithoutProperties(_ref9, ["radians"]); + var radians = _ref11.radians, + rest = _objectWithoutProperties(_ref11, ["radians"]); var elements = this.elements, _this$options2 = this.options; @@ -2010,15 +2033,15 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyResize", - value: function notifyResize(_ref10) { + value: function notifyResize(_ref12) { var _this8 = this; - var dx = _ref10.dx, - dy = _ref10.dy, - revX = _ref10.revX, - revY = _ref10.revY, - dox = _ref10.dox, - doy = _ref10.doy; + var dx = _ref12.dx, + dy = _ref12.dy, + revX = _ref12.revX, + revY = _ref12.revY, + dox = _ref12.dox, + doy = _ref12.doy; var elements = this.elements, data = this.storage.data, isGrouped = this.options.isGrouped; @@ -2026,7 +2049,7 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { var _data$get3 = data.get(element), ctm = _data$get3.transform.ctm; - var _ref11 = !isGrouped ? _this8._pointToTransform({ + var _ref13 = !isGrouped ? _this8._pointToTransform({ x: dx, y: dy, matrix: ctm @@ -2034,8 +2057,8 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { x: dx, y: dy }, - x = _ref11.x, - y = _ref11.y; + x = _ref13.x, + y = _ref13.y; _this8._resize({ element: element, @@ -2051,13 +2074,13 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyApply", - value: function notifyApply(_ref12) { + value: function notifyApply(_ref14) { var _this9 = this; - var clientX = _ref12.clientX, - clientY = _ref12.clientY, - actionName = _ref12.actionName, - triggerEvent = _ref12.triggerEvent; + var clientX = _ref14.clientX, + clientY = _ref14.clientY, + actionName = _ref14.actionName, + triggerEvent = _ref14.triggerEvent; this.proxyMethods.onDrop.call(this, { clientX: clientX, clientY: clientY @@ -2076,14 +2099,14 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyGetState", - value: function notifyGetState(_ref13) { + value: function notifyGetState(_ref15) { var _this10 = this; - var clientX = _ref13.clientX, - clientY = _ref13.clientY, - actionName = _ref13.actionName, - triggerEvent = _ref13.triggerEvent, - rest = _objectWithoutProperties(_ref13, ["clientX", "clientY", "actionName", "triggerEvent"]); + var clientX = _ref15.clientX, + clientY = _ref15.clientY, + actionName = _ref15.actionName, + triggerEvent = _ref15.triggerEvent, + rest = _objectWithoutProperties(_ref15, ["clientX", "clientY", "actionName", "triggerEvent"]); if (triggerEvent) { var elements = this.elements, @@ -2106,10 +2129,10 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "subscribe", - value: function subscribe(_ref14) { - var resize = _ref14.resize, - move = _ref14.move, - rotate = _ref14.rotate; + value: function subscribe(_ref16) { + var resize = _ref16.resize, + move = _ref16.move, + rotate = _ref16.rotate; var ob = this.observable; if (move || resize || rotate) { @@ -2162,11 +2185,11 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "exeDrag", - value: function exeDrag(_ref15) { + value: function exeDrag(_ref17) { var _this12 = this; - var dx = _ref15.dx, - dy = _ref15.dy; + var dx = _ref17.dx, + dy = _ref17.dy; var elements = this.elements, draggable = this.options.draggable, storage = this.storage, @@ -2203,19 +2226,19 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "exeResize", - value: function exeResize(_ref16) { + value: function exeResize(_ref18) { var _this13 = this; - var dx = _ref16.dx, - dy = _ref16.dy, - _ref16$revX = _ref16.revX, - revX = _ref16$revX === void 0 ? false : _ref16$revX, - _ref16$revY = _ref16.revY, - revY = _ref16$revY === void 0 ? false : _ref16$revY, - _ref16$doW = _ref16.doW, - doW = _ref16$doW === void 0 ? false : _ref16$doW, - _ref16$doH = _ref16.doH, - doH = _ref16$doH === void 0 ? false : _ref16$doH; + var dx = _ref18.dx, + dy = _ref18.dy, + _ref18$revX = _ref18.revX, + revX = _ref18$revX === void 0 ? false : _ref18$revX, + _ref18$revY = _ref18.revY, + revY = _ref18$revY === void 0 ? false : _ref18$revY, + _ref18$doW = _ref18.doW, + doW = _ref18$doW === void 0 ? false : _ref18$doW, + _ref18$doH = _ref18.doH, + doH = _ref18$doH === void 0 ? false : _ref18$doH; var elements = this.elements, resizable = this.options.resizable, storage = this.storage, @@ -2252,10 +2275,10 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "exeRotate", - value: function exeRotate(_ref17) { + value: function exeRotate(_ref19) { var _this14 = this; - var delta = _ref17.delta; + var delta = _ref19.delta; var elements = this.elements, rotatable = this.options.rotatable, storage = this.storage, @@ -2665,7 +2688,7 @@ var Draggable = /*#__PURE__*/function (_Transformable) { handles: _objectSpread2({}, handles, {}, rotationHandles), data: data, center: { - isShifted: Boolean(rotationPoint) + isShifted: Array.isArray(rotationPoint) } }; [].concat(_toConsumableArray(elements), [controls]).map(function (target) { @@ -5292,7 +5315,7 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { handles: _objectSpread2({}, handles, {}, rotationHandles), data: data, center: { - isShifted: Boolean(rotationPoint) + isShifted: Array.isArray(rotationPoint) } }; [].concat(_toConsumableArray(elements), [controls]).map(function (target) { @@ -5359,6 +5382,8 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { _this$storage2 = _this$storage2 === void 0 ? {} : _this$storage2; var data = _this$storage2.data, bBox = _this$storage2.bBox, + controlsMatrix = _this$storage2.transform.controlsMatrix, + isShifted = _this$storage2.center.isShifted, _this$options3 = this.options; _this$options3 = _this$options3 === void 0 ? {} : _this$options3; var isGrouped = _this$options3.isGrouped, @@ -5373,8 +5398,7 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var _nextData$transform = nextData.transform, matrix = _nextData$transform.matrix, parentMatrix = _nextData$transform.parentMatrix, - __data__ = nextData.__data__; //if (isUndef(cached)) return; - + __data__ = nextData.__data__; var scaleX = cached.scaleX, scaleY = cached.scaleY, _cached$dist = cached.dist; @@ -5465,6 +5489,14 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { if (isGrouped && actionName === E_ROTATE$2) { this._applyTransformToHandles(); + if (isShifted) { + var _pointTo2 = pointTo(controlsMatrix, 0, 0), + _dx = _pointTo2.x, + _dy = _pointTo2.y; + + this._moveCenterHandle(_dx, _dy); + } + this._updateControlsView(); } @@ -5559,9 +5591,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { cached = elementStorage.cached; parentMatrix.e = parentMatrix.f = 0; - var _pointTo2 = pointTo(parentMatrix, dx, dy), - nx = _pointTo2.x, - ny = _pointTo2.y; + var _pointTo3 = pointTo(parentMatrix, dx, dy), + nx = _pointTo3.x, + ny = _pointTo3.y; data.set(element, _objectSpread2({}, elementStorage, { cached: _objectSpread2({}, cached, { @@ -5650,18 +5682,18 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var centerX = cHandle ? cHandle.cx.baseVal.value : elCenterX; var centerY = cHandle ? cHandle.cy.baseVal.value : elCenterY; // c-handle's coordinates - var _pointTo3 = pointTo(boxCTM, centerX, centerY), - bcx = _pointTo3.x, - bcy = _pointTo3.y; // element's center coordinates + var _pointTo4 = pointTo(boxCTM, centerX, centerY), + bcx = _pointTo4.x, + bcy = _pointTo4.y; // element's center coordinates var _ref7 = cHandle ? pointTo(parentMatrixInverted, bcx, bcy) : pointTo(isGrouped ? parentMatrixInverted : elMatrix, elCenterX, elCenterY), elcx = _ref7.x, elcy = _ref7.y; - var _pointTo4 = pointTo(isGrouped ? parentMatrixInverted : createSVGMatrix(), scaleX, scaleY), - nextScaleX = _pointTo4.x, - nextScaleY = _pointTo4.y; + var _pointTo5 = pointTo(isGrouped ? parentMatrixInverted : createSVGMatrix(), scaleX, scaleY), + nextScaleX = _pointTo5.x, + nextScaleY = _pointTo5.y; var transform = { auxiliary: { @@ -5712,14 +5744,14 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var centerX = cHandle ? cHandle.cx.baseVal.value : elCenterX; var centerY = cHandle ? cHandle.cy.baseVal.value : elCenterY; // c-handle's coordinates - var _pointTo5 = pointTo(boxCTM, centerX, centerY), - bcx = _pointTo5.x, - bcy = _pointTo5.y; // box's center coordinates + var _pointTo6 = pointTo(boxCTM, centerX, centerY), + bcx = _pointTo6.x, + bcy = _pointTo6.y; // box's center coordinates - var _pointTo6 = pointTo(isGrouped ? createSVGMatrix() : getTransformToElement(elements[0], container), elCenterX, elCenterY), - rcx = _pointTo6.x, - rcy = _pointTo6.y; + var _pointTo7 = pointTo(isGrouped ? createSVGMatrix() : getTransformToElement(elements[0], container), elCenterX, elCenterY), + rcx = _pointTo7.x, + rcy = _pointTo7.y; var containerMatrix = restrict ? getTransformToElement(restrict, restrict.parentNode) : getTransformToElement(container, container.parentNode); @@ -5917,9 +5949,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { parentMatrix = _elementStorage$trans3.auxiliary.translate.parentMatrix; parentMatrix.e = parentMatrix.f = 0; - var _pointTo7 = pointTo(parentMatrix, dx, dy), - x = _pointTo7.x, - y = _pointTo7.y; + var _pointTo8 = pointTo(parentMatrix, dx, dy), + x = _pointTo8.x, + y = _pointTo8.y; var preTranslateMatrix = createTranslateMatrix$1(x, y).multiply(matrix); return this._restrictHandler(element, preTranslateMatrix); @@ -6013,9 +6045,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var centerTransformMatrix = controlsMatrix.inverse(); centerTransformMatrix.e = centerTransformMatrix.f = 0; - var _pointTo8 = pointTo(centerTransformMatrix, dx, dy), - cx = _pointTo8.x, - cy = _pointTo8.y; + var _pointTo9 = pointTo(centerTransformMatrix, dx, dy), + cx = _pointTo9.x, + cy = _pointTo9.y; this._moveCenterHandle(-cx, -cy); } @@ -6162,9 +6194,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var controlsTransformMatrix = getTransformToElement(controls, controls.parentNode).inverse(); var nextTransform = isGrouped ? controlsTransformMatrix : controlsTransformMatrix.multiply(getTransformToElement(elements[0], container)); - var _pointTo9 = pointTo(nextTransform, bx + hW, by + hH), - x = _pointTo9.x, - y = _pointTo9.y; + var _pointTo10 = pointTo(nextTransform, bx + hW, by + hH), + x = _pointTo10.x, + y = _pointTo10.y; handle.cx.baseVal.value = x; handle.cy.baseVal.value = y; @@ -6278,9 +6310,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var parentMatrix = getTransformToElement(element.parentNode, container); parentMatrix.e = parentMatrix.f = 0; - var _pointTo10 = pointTo(parentMatrix.inverse(), getXDir(), getYDir()), - x = _pointTo10.x, - y = _pointTo10.y; + var _pointTo11 = pointTo(parentMatrix.inverse(), getXDir(), getYDir()), + x = _pointTo11.x, + y = _pointTo11.y; var moveElementMtrx = createTranslateMatrix$1(x, y).multiply(getTransformToElement(element, element.parentNode)); @@ -6392,9 +6424,9 @@ var applyResize = function applyResize(element, data) { y = storedData.y, textLength = storedData.textLength; - var _pointTo11 = pointTo(localCTM, x, y), - resX = _pointTo11.x, - resY = _pointTo11.y; + var _pointTo12 = pointTo(localCTM, x, y), + resX = _pointTo12.x, + resY = _pointTo12.y; attrs.push(['x', resX + (scaleX < 0 ? boxW : 0)], ['y', resY - (scaleY < 0 ? boxH : 0)], ['textLength', Math.abs(scaleX * textLength)]); break; @@ -6407,9 +6439,9 @@ var applyResize = function applyResize(element, data) { cy = storedData.cy, newR = r * (Math.abs(scaleX) + Math.abs(scaleY)) / 2; - var _pointTo12 = pointTo(localCTM, cx, cy), - _resX3 = _pointTo12.x, - _resY3 = _pointTo12.y; + var _pointTo13 = pointTo(localCTM, cx, cy), + _resX3 = _pointTo13.x, + _resY3 = _pointTo13.y; attrs.push(['r', newR], ['cx', _resX3], ['cy', _resY3]); break; @@ -6425,9 +6457,9 @@ var applyResize = function applyResize(element, data) { _x5 = storedData.x, _y5 = storedData.y; - var _pointTo13 = pointTo(localCTM, _x5, _y5), - _resX4 = _pointTo13.x, - _resY4 = _pointTo13.y; + var _pointTo14 = pointTo(localCTM, _x5, _y5), + _resX4 = _pointTo14.x, + _resY4 = _pointTo14.y; var newWidth = Math.abs(width * scaleX), newHeight = Math.abs(height * scaleY); @@ -6451,17 +6483,17 @@ var applyResize = function applyResize(element, data) { _cx = storedData.cx, _cy = storedData.cy; - var _pointTo14 = pointTo(localCTM, _cx, _cy), - cx1 = _pointTo14.x, - cy1 = _pointTo14.y; + var _pointTo15 = pointTo(localCTM, _cx, _cy), + cx1 = _pointTo15.x, + cy1 = _pointTo15.y; var scaleMatrix = createSVGMatrix(); scaleMatrix.a = scaleX; scaleMatrix.d = scaleY; - var _pointTo15 = pointTo(scaleMatrix, rx, ry), - nRx = _pointTo15.x, - nRy = _pointTo15.y; + var _pointTo16 = pointTo(scaleMatrix, rx, ry), + nRx = _pointTo16.x, + nRy = _pointTo16.y; attrs.push(['rx', Math.abs(nRx)], ['ry', Math.abs(nRy)], ['cx', cx1], ['cy', cy1]); break; @@ -6474,13 +6506,13 @@ var applyResize = function applyResize(element, data) { resX2 = storedData.resX2, resY2 = storedData.resY2; - var _pointTo16 = pointTo(localCTM, resX1, resY1), - resX1_ = _pointTo16.x, - resY1_ = _pointTo16.y; + var _pointTo17 = pointTo(localCTM, resX1, resY1), + resX1_ = _pointTo17.x, + resY1_ = _pointTo17.y; - var _pointTo17 = pointTo(localCTM, resX2, resY2), - resX2_ = _pointTo17.x, - resY2_ = _pointTo17.y; + var _pointTo18 = pointTo(localCTM, resX2, resY2), + resX2_ = _pointTo18.x, + resY2_ = _pointTo18.y; attrs.push(['x1', resX1_], ['y1', resY1_], ['x2', resX2_], ['y2', resY2_]); break; @@ -6491,9 +6523,9 @@ var applyResize = function applyResize(element, data) { { var points = storedData.points; var result = parsePoints(points).map(function (item) { - var _pointTo18 = pointTo(localCTM, Number(item[0]), Number(item[1])), - x = _pointTo18.x, - y = _pointTo18.y; + var _pointTo19 = pointTo(localCTM, Number(item[0]), Number(item[1])), + x = _pointTo19.x, + y = _pointTo19.y; item[0] = floatToFixed(x); item[1] = floatToFixed(y); @@ -6692,9 +6724,9 @@ var _getBoundingRect$1 = function _getBoundingRect(element, ctm) { l = _ref30[0], t = _ref30[1]; - var _pointTo19 = pointTo(ctm, l, t), - nx = _pointTo19.x, - ny = _pointTo19.y; + var _pointTo20 = pointTo(ctm, l, t), + nx = _pointTo20.x, + ny = _pointTo20.y; return [nx, ny]; }); diff --git a/dist/js/subjx.dev.js b/dist/js/subjx.dev.js index baf07ff..359d901 100644 --- a/dist/js/subjx.dev.js +++ b/dist/js/subjx.dev.js @@ -617,6 +617,7 @@ var E_ROTATE_START = 'rotateStart'; var E_ROTATE = 'rotate'; var E_ROTATE_END = 'rotateEnd'; + var E_SET_POINT = 'setPoint'; var E_SET_POINT_START = 'setPointStart'; var E_SET_POINT_END = 'setPointEnd'; var 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]; @@ -646,6 +647,7 @@ 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 }; @@ -1140,7 +1142,8 @@ 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_ROTATE_END$1 = EVENT_EMITTER_CONSTANTS.E_ROTATE_END, + E_SET_POINT$1 = EVENT_EMITTER_CONSTANTS.E_SET_POINT; var TRANSFORM_HANDLES_KEYS$1 = TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_HANDLES_KEYS, TRANSFORM_EDGES_KEYS$1 = TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_EDGES_KEYS; var E_MOUSEDOWN$1 = CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN, @@ -1762,12 +1765,32 @@ doResize = _this$storage2.doResize, doDrag = _this$storage2.doDrag, doRotate = _this$storage2.doRotate, + doSetCenter = _this$storage2.doSetCenter, frame = _this$storage2.frame, radius = _this$storage2.handles.radius, isTarget = _this$storage2.isTarget, proxyMethods = this.proxyMethods; if (!isTarget) return; - var actionName = doResize ? E_RESIZE$1 : doDrag ? E_DRAG$2 : E_ROTATE$1; + + var _ref8 = [{ + actionName: E_RESIZE$1, + condition: doResize + }, { + actionName: E_DRAG$2, + condition: doDrag + }, { + actionName: E_ROTATE$1, + condition: doRotate + }, { + actionName: E_SET_POINT$1, + condition: doSetCenter + }].find(function (_ref9) { + var condition = _ref9.condition; + return condition; + }) || {}, + _ref8$actionName = _ref8.actionName, + actionName = _ref8$actionName === void 0 ? E_DRAG$2 : _ref8$actionName; + storage.doResize = false; storage.doDrag = false; storage.doRotate = false; @@ -1971,11 +1994,11 @@ } }, { key: "notifyMove", - value: function notifyMove(_ref8) { + value: function notifyMove(_ref10) { var _this6 = this; - var dx = _ref8.dx, - dy = _ref8.dy; + var dx = _ref10.dx, + dy = _ref10.dy; this.elements.map(function (element) { return _get(_getPrototypeOf(Transformable.prototype), "_drag", _this6).call(_this6, { element: element, @@ -1991,11 +2014,11 @@ } }, { key: "notifyRotate", - value: function notifyRotate(_ref9) { + value: function notifyRotate(_ref11) { var _this7 = this; - var radians = _ref9.radians, - rest = _objectWithoutProperties(_ref9, ["radians"]); + var radians = _ref11.radians, + rest = _objectWithoutProperties(_ref11, ["radians"]); var elements = this.elements, _this$options2 = this.options; @@ -2014,15 +2037,15 @@ } }, { key: "notifyResize", - value: function notifyResize(_ref10) { + value: function notifyResize(_ref12) { var _this8 = this; - var dx = _ref10.dx, - dy = _ref10.dy, - revX = _ref10.revX, - revY = _ref10.revY, - dox = _ref10.dox, - doy = _ref10.doy; + var dx = _ref12.dx, + dy = _ref12.dy, + revX = _ref12.revX, + revY = _ref12.revY, + dox = _ref12.dox, + doy = _ref12.doy; var elements = this.elements, data = this.storage.data, isGrouped = this.options.isGrouped; @@ -2030,7 +2053,7 @@ var _data$get3 = data.get(element), ctm = _data$get3.transform.ctm; - var _ref11 = !isGrouped ? _this8._pointToTransform({ + var _ref13 = !isGrouped ? _this8._pointToTransform({ x: dx, y: dy, matrix: ctm @@ -2038,8 +2061,8 @@ x: dx, y: dy }, - x = _ref11.x, - y = _ref11.y; + x = _ref13.x, + y = _ref13.y; _this8._resize({ element: element, @@ -2055,13 +2078,13 @@ } }, { key: "notifyApply", - value: function notifyApply(_ref12) { + value: function notifyApply(_ref14) { var _this9 = this; - var clientX = _ref12.clientX, - clientY = _ref12.clientY, - actionName = _ref12.actionName, - triggerEvent = _ref12.triggerEvent; + var clientX = _ref14.clientX, + clientY = _ref14.clientY, + actionName = _ref14.actionName, + triggerEvent = _ref14.triggerEvent; this.proxyMethods.onDrop.call(this, { clientX: clientX, clientY: clientY @@ -2080,14 +2103,14 @@ } }, { key: "notifyGetState", - value: function notifyGetState(_ref13) { + value: function notifyGetState(_ref15) { var _this10 = this; - var clientX = _ref13.clientX, - clientY = _ref13.clientY, - actionName = _ref13.actionName, - triggerEvent = _ref13.triggerEvent, - rest = _objectWithoutProperties(_ref13, ["clientX", "clientY", "actionName", "triggerEvent"]); + var clientX = _ref15.clientX, + clientY = _ref15.clientY, + actionName = _ref15.actionName, + triggerEvent = _ref15.triggerEvent, + rest = _objectWithoutProperties(_ref15, ["clientX", "clientY", "actionName", "triggerEvent"]); if (triggerEvent) { var elements = this.elements, @@ -2110,10 +2133,10 @@ } }, { key: "subscribe", - value: function subscribe(_ref14) { - var resize = _ref14.resize, - move = _ref14.move, - rotate = _ref14.rotate; + value: function subscribe(_ref16) { + var resize = _ref16.resize, + move = _ref16.move, + rotate = _ref16.rotate; var ob = this.observable; if (move || resize || rotate) { @@ -2166,11 +2189,11 @@ } }, { key: "exeDrag", - value: function exeDrag(_ref15) { + value: function exeDrag(_ref17) { var _this12 = this; - var dx = _ref15.dx, - dy = _ref15.dy; + var dx = _ref17.dx, + dy = _ref17.dy; var elements = this.elements, draggable = this.options.draggable, storage = this.storage, @@ -2207,19 +2230,19 @@ } }, { key: "exeResize", - value: function exeResize(_ref16) { + value: function exeResize(_ref18) { var _this13 = this; - var dx = _ref16.dx, - dy = _ref16.dy, - _ref16$revX = _ref16.revX, - revX = _ref16$revX === void 0 ? false : _ref16$revX, - _ref16$revY = _ref16.revY, - revY = _ref16$revY === void 0 ? false : _ref16$revY, - _ref16$doW = _ref16.doW, - doW = _ref16$doW === void 0 ? false : _ref16$doW, - _ref16$doH = _ref16.doH, - doH = _ref16$doH === void 0 ? false : _ref16$doH; + var dx = _ref18.dx, + dy = _ref18.dy, + _ref18$revX = _ref18.revX, + revX = _ref18$revX === void 0 ? false : _ref18$revX, + _ref18$revY = _ref18.revY, + revY = _ref18$revY === void 0 ? false : _ref18$revY, + _ref18$doW = _ref18.doW, + doW = _ref18$doW === void 0 ? false : _ref18$doW, + _ref18$doH = _ref18.doH, + doH = _ref18$doH === void 0 ? false : _ref18$doH; var elements = this.elements, resizable = this.options.resizable, storage = this.storage, @@ -2256,10 +2279,10 @@ } }, { key: "exeRotate", - value: function exeRotate(_ref17) { + value: function exeRotate(_ref19) { var _this14 = this; - var delta = _ref17.delta; + var delta = _ref19.delta; var elements = this.elements, rotatable = this.options.rotatable, storage = this.storage, @@ -2669,7 +2692,7 @@ handles: _objectSpread2({}, handles, {}, rotationHandles), data: data, center: { - isShifted: Boolean(rotationPoint) + isShifted: Array.isArray(rotationPoint) } }; [].concat(_toConsumableArray(elements), [controls]).map(function (target) { @@ -5296,7 +5319,7 @@ handles: _objectSpread2({}, handles, {}, rotationHandles), data: data, center: { - isShifted: Boolean(rotationPoint) + isShifted: Array.isArray(rotationPoint) } }; [].concat(_toConsumableArray(elements), [controls]).map(function (target) { @@ -5363,6 +5386,8 @@ _this$storage2 = _this$storage2 === void 0 ? {} : _this$storage2; var data = _this$storage2.data, bBox = _this$storage2.bBox, + controlsMatrix = _this$storage2.transform.controlsMatrix, + isShifted = _this$storage2.center.isShifted, _this$options3 = this.options; _this$options3 = _this$options3 === void 0 ? {} : _this$options3; var isGrouped = _this$options3.isGrouped, @@ -5377,8 +5402,7 @@ var _nextData$transform = nextData.transform, matrix = _nextData$transform.matrix, parentMatrix = _nextData$transform.parentMatrix, - __data__ = nextData.__data__; //if (isUndef(cached)) return; - + __data__ = nextData.__data__; var scaleX = cached.scaleX, scaleY = cached.scaleY, _cached$dist = cached.dist; @@ -5469,6 +5493,14 @@ if (isGrouped && actionName === E_ROTATE$2) { this._applyTransformToHandles(); + if (isShifted) { + var _pointTo2 = pointTo(controlsMatrix, 0, 0), + _dx = _pointTo2.x, + _dy = _pointTo2.y; + + this._moveCenterHandle(_dx, _dy); + } + this._updateControlsView(); } @@ -5563,9 +5595,9 @@ cached = elementStorage.cached; parentMatrix.e = parentMatrix.f = 0; - var _pointTo2 = pointTo(parentMatrix, dx, dy), - nx = _pointTo2.x, - ny = _pointTo2.y; + var _pointTo3 = pointTo(parentMatrix, dx, dy), + nx = _pointTo3.x, + ny = _pointTo3.y; data.set(element, _objectSpread2({}, elementStorage, { cached: _objectSpread2({}, cached, { @@ -5654,18 +5686,18 @@ var centerX = cHandle ? cHandle.cx.baseVal.value : elCenterX; var centerY = cHandle ? cHandle.cy.baseVal.value : elCenterY; // c-handle's coordinates - var _pointTo3 = pointTo(boxCTM, centerX, centerY), - bcx = _pointTo3.x, - bcy = _pointTo3.y; // element's center coordinates + var _pointTo4 = pointTo(boxCTM, centerX, centerY), + bcx = _pointTo4.x, + bcy = _pointTo4.y; // element's center coordinates var _ref7 = cHandle ? pointTo(parentMatrixInverted, bcx, bcy) : pointTo(isGrouped ? parentMatrixInverted : elMatrix, elCenterX, elCenterY), elcx = _ref7.x, elcy = _ref7.y; - var _pointTo4 = pointTo(isGrouped ? parentMatrixInverted : createSVGMatrix(), scaleX, scaleY), - nextScaleX = _pointTo4.x, - nextScaleY = _pointTo4.y; + var _pointTo5 = pointTo(isGrouped ? parentMatrixInverted : createSVGMatrix(), scaleX, scaleY), + nextScaleX = _pointTo5.x, + nextScaleY = _pointTo5.y; var transform = { auxiliary: { @@ -5716,14 +5748,14 @@ var centerX = cHandle ? cHandle.cx.baseVal.value : elCenterX; var centerY = cHandle ? cHandle.cy.baseVal.value : elCenterY; // c-handle's coordinates - var _pointTo5 = pointTo(boxCTM, centerX, centerY), - bcx = _pointTo5.x, - bcy = _pointTo5.y; // box's center coordinates + var _pointTo6 = pointTo(boxCTM, centerX, centerY), + bcx = _pointTo6.x, + bcy = _pointTo6.y; // box's center coordinates - var _pointTo6 = pointTo(isGrouped ? createSVGMatrix() : getTransformToElement(elements[0], container), elCenterX, elCenterY), - rcx = _pointTo6.x, - rcy = _pointTo6.y; + var _pointTo7 = pointTo(isGrouped ? createSVGMatrix() : getTransformToElement(elements[0], container), elCenterX, elCenterY), + rcx = _pointTo7.x, + rcy = _pointTo7.y; var containerMatrix = restrict ? getTransformToElement(restrict, restrict.parentNode) : getTransformToElement(container, container.parentNode); @@ -5921,9 +5953,9 @@ parentMatrix = _elementStorage$trans3.auxiliary.translate.parentMatrix; parentMatrix.e = parentMatrix.f = 0; - var _pointTo7 = pointTo(parentMatrix, dx, dy), - x = _pointTo7.x, - y = _pointTo7.y; + var _pointTo8 = pointTo(parentMatrix, dx, dy), + x = _pointTo8.x, + y = _pointTo8.y; var preTranslateMatrix = createTranslateMatrix$1(x, y).multiply(matrix); return this._restrictHandler(element, preTranslateMatrix); @@ -6017,9 +6049,9 @@ var centerTransformMatrix = controlsMatrix.inverse(); centerTransformMatrix.e = centerTransformMatrix.f = 0; - var _pointTo8 = pointTo(centerTransformMatrix, dx, dy), - cx = _pointTo8.x, - cy = _pointTo8.y; + var _pointTo9 = pointTo(centerTransformMatrix, dx, dy), + cx = _pointTo9.x, + cy = _pointTo9.y; this._moveCenterHandle(-cx, -cy); } @@ -6166,9 +6198,9 @@ var controlsTransformMatrix = getTransformToElement(controls, controls.parentNode).inverse(); var nextTransform = isGrouped ? controlsTransformMatrix : controlsTransformMatrix.multiply(getTransformToElement(elements[0], container)); - var _pointTo9 = pointTo(nextTransform, bx + hW, by + hH), - x = _pointTo9.x, - y = _pointTo9.y; + var _pointTo10 = pointTo(nextTransform, bx + hW, by + hH), + x = _pointTo10.x, + y = _pointTo10.y; handle.cx.baseVal.value = x; handle.cy.baseVal.value = y; @@ -6282,9 +6314,9 @@ var parentMatrix = getTransformToElement(element.parentNode, container); parentMatrix.e = parentMatrix.f = 0; - var _pointTo10 = pointTo(parentMatrix.inverse(), getXDir(), getYDir()), - x = _pointTo10.x, - y = _pointTo10.y; + var _pointTo11 = pointTo(parentMatrix.inverse(), getXDir(), getYDir()), + x = _pointTo11.x, + y = _pointTo11.y; var moveElementMtrx = createTranslateMatrix$1(x, y).multiply(getTransformToElement(element, element.parentNode)); @@ -6396,9 +6428,9 @@ y = storedData.y, textLength = storedData.textLength; - var _pointTo11 = pointTo(localCTM, x, y), - resX = _pointTo11.x, - resY = _pointTo11.y; + var _pointTo12 = pointTo(localCTM, x, y), + resX = _pointTo12.x, + resY = _pointTo12.y; attrs.push(['x', resX + (scaleX < 0 ? boxW : 0)], ['y', resY - (scaleY < 0 ? boxH : 0)], ['textLength', Math.abs(scaleX * textLength)]); break; @@ -6411,9 +6443,9 @@ cy = storedData.cy, newR = r * (Math.abs(scaleX) + Math.abs(scaleY)) / 2; - var _pointTo12 = pointTo(localCTM, cx, cy), - _resX3 = _pointTo12.x, - _resY3 = _pointTo12.y; + var _pointTo13 = pointTo(localCTM, cx, cy), + _resX3 = _pointTo13.x, + _resY3 = _pointTo13.y; attrs.push(['r', newR], ['cx', _resX3], ['cy', _resY3]); break; @@ -6429,9 +6461,9 @@ _x5 = storedData.x, _y5 = storedData.y; - var _pointTo13 = pointTo(localCTM, _x5, _y5), - _resX4 = _pointTo13.x, - _resY4 = _pointTo13.y; + var _pointTo14 = pointTo(localCTM, _x5, _y5), + _resX4 = _pointTo14.x, + _resY4 = _pointTo14.y; var newWidth = Math.abs(width * scaleX), newHeight = Math.abs(height * scaleY); @@ -6455,17 +6487,17 @@ _cx = storedData.cx, _cy = storedData.cy; - var _pointTo14 = pointTo(localCTM, _cx, _cy), - cx1 = _pointTo14.x, - cy1 = _pointTo14.y; + var _pointTo15 = pointTo(localCTM, _cx, _cy), + cx1 = _pointTo15.x, + cy1 = _pointTo15.y; var scaleMatrix = createSVGMatrix(); scaleMatrix.a = scaleX; scaleMatrix.d = scaleY; - var _pointTo15 = pointTo(scaleMatrix, rx, ry), - nRx = _pointTo15.x, - nRy = _pointTo15.y; + var _pointTo16 = pointTo(scaleMatrix, rx, ry), + nRx = _pointTo16.x, + nRy = _pointTo16.y; attrs.push(['rx', Math.abs(nRx)], ['ry', Math.abs(nRy)], ['cx', cx1], ['cy', cy1]); break; @@ -6478,13 +6510,13 @@ resX2 = storedData.resX2, resY2 = storedData.resY2; - var _pointTo16 = pointTo(localCTM, resX1, resY1), - resX1_ = _pointTo16.x, - resY1_ = _pointTo16.y; + var _pointTo17 = pointTo(localCTM, resX1, resY1), + resX1_ = _pointTo17.x, + resY1_ = _pointTo17.y; - var _pointTo17 = pointTo(localCTM, resX2, resY2), - resX2_ = _pointTo17.x, - resY2_ = _pointTo17.y; + var _pointTo18 = pointTo(localCTM, resX2, resY2), + resX2_ = _pointTo18.x, + resY2_ = _pointTo18.y; attrs.push(['x1', resX1_], ['y1', resY1_], ['x2', resX2_], ['y2', resY2_]); break; @@ -6495,9 +6527,9 @@ { var points = storedData.points; var result = parsePoints(points).map(function (item) { - var _pointTo18 = pointTo(localCTM, Number(item[0]), Number(item[1])), - x = _pointTo18.x, - y = _pointTo18.y; + var _pointTo19 = pointTo(localCTM, Number(item[0]), Number(item[1])), + x = _pointTo19.x, + y = _pointTo19.y; item[0] = floatToFixed(x); item[1] = floatToFixed(y); @@ -6696,9 +6728,9 @@ l = _ref30[0], t = _ref30[1]; - var _pointTo19 = pointTo(ctm, l, t), - nx = _pointTo19.x, - ny = _pointTo19.y; + var _pointTo20 = pointTo(ctm, l, t), + nx = _pointTo20.x, + ny = _pointTo20.y; return [nx, ny]; }); diff --git a/dist/js/subjx.esm.js b/dist/js/subjx.esm.js index db61269..8a76392 100644 --- a/dist/js/subjx.esm.js +++ b/dist/js/subjx.esm.js @@ -611,6 +611,7 @@ var E_RESIZE_END = 'resizeEnd'; var E_ROTATE_START = 'rotateStart'; var E_ROTATE = 'rotate'; var E_ROTATE_END = 'rotateEnd'; +var E_SET_POINT = 'setPoint'; var E_SET_POINT_START = 'setPointStart'; var E_SET_POINT_END = 'setPointEnd'; var 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]; @@ -640,6 +641,7 @@ var EVENT_EMITTER_CONSTANTS = { 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 }; @@ -1134,7 +1136,8 @@ var EMITTER_EVENTS$1 = EVENT_EMITTER_CONSTANTS.EMITTER_EVENTS, 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_ROTATE_END$1 = EVENT_EMITTER_CONSTANTS.E_ROTATE_END, + E_SET_POINT$1 = EVENT_EMITTER_CONSTANTS.E_SET_POINT; var TRANSFORM_HANDLES_KEYS$1 = TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_HANDLES_KEYS, TRANSFORM_EDGES_KEYS$1 = TRANSFORM_HANDLES_CONSTANTS.TRANSFORM_EDGES_KEYS; var E_MOUSEDOWN$1 = CLIENT_EVENTS_CONSTANTS.E_MOUSEDOWN, @@ -1756,12 +1759,32 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { doResize = _this$storage2.doResize, doDrag = _this$storage2.doDrag, doRotate = _this$storage2.doRotate, + doSetCenter = _this$storage2.doSetCenter, frame = _this$storage2.frame, radius = _this$storage2.handles.radius, isTarget = _this$storage2.isTarget, proxyMethods = this.proxyMethods; if (!isTarget) return; - var actionName = doResize ? E_RESIZE$1 : doDrag ? E_DRAG$2 : E_ROTATE$1; + + var _ref8 = [{ + actionName: E_RESIZE$1, + condition: doResize + }, { + actionName: E_DRAG$2, + condition: doDrag + }, { + actionName: E_ROTATE$1, + condition: doRotate + }, { + actionName: E_SET_POINT$1, + condition: doSetCenter + }].find(function (_ref9) { + var condition = _ref9.condition; + return condition; + }) || {}, + _ref8$actionName = _ref8.actionName, + actionName = _ref8$actionName === void 0 ? E_DRAG$2 : _ref8$actionName; + storage.doResize = false; storage.doDrag = false; storage.doRotate = false; @@ -1965,11 +1988,11 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyMove", - value: function notifyMove(_ref8) { + value: function notifyMove(_ref10) { var _this6 = this; - var dx = _ref8.dx, - dy = _ref8.dy; + var dx = _ref10.dx, + dy = _ref10.dy; this.elements.map(function (element) { return _get(_getPrototypeOf(Transformable.prototype), "_drag", _this6).call(_this6, { element: element, @@ -1985,11 +2008,11 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyRotate", - value: function notifyRotate(_ref9) { + value: function notifyRotate(_ref11) { var _this7 = this; - var radians = _ref9.radians, - rest = _objectWithoutProperties(_ref9, ["radians"]); + var radians = _ref11.radians, + rest = _objectWithoutProperties(_ref11, ["radians"]); var elements = this.elements, _this$options2 = this.options; @@ -2008,15 +2031,15 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyResize", - value: function notifyResize(_ref10) { + value: function notifyResize(_ref12) { var _this8 = this; - var dx = _ref10.dx, - dy = _ref10.dy, - revX = _ref10.revX, - revY = _ref10.revY, - dox = _ref10.dox, - doy = _ref10.doy; + var dx = _ref12.dx, + dy = _ref12.dy, + revX = _ref12.revX, + revY = _ref12.revY, + dox = _ref12.dox, + doy = _ref12.doy; var elements = this.elements, data = this.storage.data, isGrouped = this.options.isGrouped; @@ -2024,7 +2047,7 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { var _data$get3 = data.get(element), ctm = _data$get3.transform.ctm; - var _ref11 = !isGrouped ? _this8._pointToTransform({ + var _ref13 = !isGrouped ? _this8._pointToTransform({ x: dx, y: dy, matrix: ctm @@ -2032,8 +2055,8 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { x: dx, y: dy }, - x = _ref11.x, - y = _ref11.y; + x = _ref13.x, + y = _ref13.y; _this8._resize({ element: element, @@ -2049,13 +2072,13 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyApply", - value: function notifyApply(_ref12) { + value: function notifyApply(_ref14) { var _this9 = this; - var clientX = _ref12.clientX, - clientY = _ref12.clientY, - actionName = _ref12.actionName, - triggerEvent = _ref12.triggerEvent; + var clientX = _ref14.clientX, + clientY = _ref14.clientY, + actionName = _ref14.actionName, + triggerEvent = _ref14.triggerEvent; this.proxyMethods.onDrop.call(this, { clientX: clientX, clientY: clientY @@ -2074,14 +2097,14 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "notifyGetState", - value: function notifyGetState(_ref13) { + value: function notifyGetState(_ref15) { var _this10 = this; - var clientX = _ref13.clientX, - clientY = _ref13.clientY, - actionName = _ref13.actionName, - triggerEvent = _ref13.triggerEvent, - rest = _objectWithoutProperties(_ref13, ["clientX", "clientY", "actionName", "triggerEvent"]); + var clientX = _ref15.clientX, + clientY = _ref15.clientY, + actionName = _ref15.actionName, + triggerEvent = _ref15.triggerEvent, + rest = _objectWithoutProperties(_ref15, ["clientX", "clientY", "actionName", "triggerEvent"]); if (triggerEvent) { var elements = this.elements, @@ -2104,10 +2127,10 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "subscribe", - value: function subscribe(_ref14) { - var resize = _ref14.resize, - move = _ref14.move, - rotate = _ref14.rotate; + value: function subscribe(_ref16) { + var resize = _ref16.resize, + move = _ref16.move, + rotate = _ref16.rotate; var ob = this.observable; if (move || resize || rotate) { @@ -2160,11 +2183,11 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "exeDrag", - value: function exeDrag(_ref15) { + value: function exeDrag(_ref17) { var _this12 = this; - var dx = _ref15.dx, - dy = _ref15.dy; + var dx = _ref17.dx, + dy = _ref17.dy; var elements = this.elements, draggable = this.options.draggable, storage = this.storage, @@ -2201,19 +2224,19 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "exeResize", - value: function exeResize(_ref16) { + value: function exeResize(_ref18) { var _this13 = this; - var dx = _ref16.dx, - dy = _ref16.dy, - _ref16$revX = _ref16.revX, - revX = _ref16$revX === void 0 ? false : _ref16$revX, - _ref16$revY = _ref16.revY, - revY = _ref16$revY === void 0 ? false : _ref16$revY, - _ref16$doW = _ref16.doW, - doW = _ref16$doW === void 0 ? false : _ref16$doW, - _ref16$doH = _ref16.doH, - doH = _ref16$doH === void 0 ? false : _ref16$doH; + var dx = _ref18.dx, + dy = _ref18.dy, + _ref18$revX = _ref18.revX, + revX = _ref18$revX === void 0 ? false : _ref18$revX, + _ref18$revY = _ref18.revY, + revY = _ref18$revY === void 0 ? false : _ref18$revY, + _ref18$doW = _ref18.doW, + doW = _ref18$doW === void 0 ? false : _ref18$doW, + _ref18$doH = _ref18.doH, + doH = _ref18$doH === void 0 ? false : _ref18$doH; var elements = this.elements, resizable = this.options.resizable, storage = this.storage, @@ -2250,10 +2273,10 @@ var Transformable = /*#__PURE__*/function (_SubjectModel) { } }, { key: "exeRotate", - value: function exeRotate(_ref17) { + value: function exeRotate(_ref19) { var _this14 = this; - var delta = _ref17.delta; + var delta = _ref19.delta; var elements = this.elements, rotatable = this.options.rotatable, storage = this.storage, @@ -2663,7 +2686,7 @@ var Draggable = /*#__PURE__*/function (_Transformable) { handles: _objectSpread2({}, handles, {}, rotationHandles), data: data, center: { - isShifted: Boolean(rotationPoint) + isShifted: Array.isArray(rotationPoint) } }; [].concat(_toConsumableArray(elements), [controls]).map(function (target) { @@ -5290,7 +5313,7 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { handles: _objectSpread2({}, handles, {}, rotationHandles), data: data, center: { - isShifted: Boolean(rotationPoint) + isShifted: Array.isArray(rotationPoint) } }; [].concat(_toConsumableArray(elements), [controls]).map(function (target) { @@ -5357,6 +5380,8 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { _this$storage2 = _this$storage2 === void 0 ? {} : _this$storage2; var data = _this$storage2.data, bBox = _this$storage2.bBox, + controlsMatrix = _this$storage2.transform.controlsMatrix, + isShifted = _this$storage2.center.isShifted, _this$options3 = this.options; _this$options3 = _this$options3 === void 0 ? {} : _this$options3; var isGrouped = _this$options3.isGrouped, @@ -5371,8 +5396,7 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var _nextData$transform = nextData.transform, matrix = _nextData$transform.matrix, parentMatrix = _nextData$transform.parentMatrix, - __data__ = nextData.__data__; //if (isUndef(cached)) return; - + __data__ = nextData.__data__; var scaleX = cached.scaleX, scaleY = cached.scaleY, _cached$dist = cached.dist; @@ -5463,6 +5487,14 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { if (isGrouped && actionName === E_ROTATE$2) { this._applyTransformToHandles(); + if (isShifted) { + var _pointTo2 = pointTo(controlsMatrix, 0, 0), + _dx = _pointTo2.x, + _dy = _pointTo2.y; + + this._moveCenterHandle(_dx, _dy); + } + this._updateControlsView(); } @@ -5557,9 +5589,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { cached = elementStorage.cached; parentMatrix.e = parentMatrix.f = 0; - var _pointTo2 = pointTo(parentMatrix, dx, dy), - nx = _pointTo2.x, - ny = _pointTo2.y; + var _pointTo3 = pointTo(parentMatrix, dx, dy), + nx = _pointTo3.x, + ny = _pointTo3.y; data.set(element, _objectSpread2({}, elementStorage, { cached: _objectSpread2({}, cached, { @@ -5648,18 +5680,18 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var centerX = cHandle ? cHandle.cx.baseVal.value : elCenterX; var centerY = cHandle ? cHandle.cy.baseVal.value : elCenterY; // c-handle's coordinates - var _pointTo3 = pointTo(boxCTM, centerX, centerY), - bcx = _pointTo3.x, - bcy = _pointTo3.y; // element's center coordinates + var _pointTo4 = pointTo(boxCTM, centerX, centerY), + bcx = _pointTo4.x, + bcy = _pointTo4.y; // element's center coordinates var _ref7 = cHandle ? pointTo(parentMatrixInverted, bcx, bcy) : pointTo(isGrouped ? parentMatrixInverted : elMatrix, elCenterX, elCenterY), elcx = _ref7.x, elcy = _ref7.y; - var _pointTo4 = pointTo(isGrouped ? parentMatrixInverted : createSVGMatrix(), scaleX, scaleY), - nextScaleX = _pointTo4.x, - nextScaleY = _pointTo4.y; + var _pointTo5 = pointTo(isGrouped ? parentMatrixInverted : createSVGMatrix(), scaleX, scaleY), + nextScaleX = _pointTo5.x, + nextScaleY = _pointTo5.y; var transform = { auxiliary: { @@ -5710,14 +5742,14 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var centerX = cHandle ? cHandle.cx.baseVal.value : elCenterX; var centerY = cHandle ? cHandle.cy.baseVal.value : elCenterY; // c-handle's coordinates - var _pointTo5 = pointTo(boxCTM, centerX, centerY), - bcx = _pointTo5.x, - bcy = _pointTo5.y; // box's center coordinates + var _pointTo6 = pointTo(boxCTM, centerX, centerY), + bcx = _pointTo6.x, + bcy = _pointTo6.y; // box's center coordinates - var _pointTo6 = pointTo(isGrouped ? createSVGMatrix() : getTransformToElement(elements[0], container), elCenterX, elCenterY), - rcx = _pointTo6.x, - rcy = _pointTo6.y; + var _pointTo7 = pointTo(isGrouped ? createSVGMatrix() : getTransformToElement(elements[0], container), elCenterX, elCenterY), + rcx = _pointTo7.x, + rcy = _pointTo7.y; var containerMatrix = restrict ? getTransformToElement(restrict, restrict.parentNode) : getTransformToElement(container, container.parentNode); @@ -5915,9 +5947,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { parentMatrix = _elementStorage$trans3.auxiliary.translate.parentMatrix; parentMatrix.e = parentMatrix.f = 0; - var _pointTo7 = pointTo(parentMatrix, dx, dy), - x = _pointTo7.x, - y = _pointTo7.y; + var _pointTo8 = pointTo(parentMatrix, dx, dy), + x = _pointTo8.x, + y = _pointTo8.y; var preTranslateMatrix = createTranslateMatrix$1(x, y).multiply(matrix); return this._restrictHandler(element, preTranslateMatrix); @@ -6011,9 +6043,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var centerTransformMatrix = controlsMatrix.inverse(); centerTransformMatrix.e = centerTransformMatrix.f = 0; - var _pointTo8 = pointTo(centerTransformMatrix, dx, dy), - cx = _pointTo8.x, - cy = _pointTo8.y; + var _pointTo9 = pointTo(centerTransformMatrix, dx, dy), + cx = _pointTo9.x, + cy = _pointTo9.y; this._moveCenterHandle(-cx, -cy); } @@ -6160,9 +6192,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var controlsTransformMatrix = getTransformToElement(controls, controls.parentNode).inverse(); var nextTransform = isGrouped ? controlsTransformMatrix : controlsTransformMatrix.multiply(getTransformToElement(elements[0], container)); - var _pointTo9 = pointTo(nextTransform, bx + hW, by + hH), - x = _pointTo9.x, - y = _pointTo9.y; + var _pointTo10 = pointTo(nextTransform, bx + hW, by + hH), + x = _pointTo10.x, + y = _pointTo10.y; handle.cx.baseVal.value = x; handle.cy.baseVal.value = y; @@ -6276,9 +6308,9 @@ var DraggableSVG = /*#__PURE__*/function (_Transformable) { var parentMatrix = getTransformToElement(element.parentNode, container); parentMatrix.e = parentMatrix.f = 0; - var _pointTo10 = pointTo(parentMatrix.inverse(), getXDir(), getYDir()), - x = _pointTo10.x, - y = _pointTo10.y; + var _pointTo11 = pointTo(parentMatrix.inverse(), getXDir(), getYDir()), + x = _pointTo11.x, + y = _pointTo11.y; var moveElementMtrx = createTranslateMatrix$1(x, y).multiply(getTransformToElement(element, element.parentNode)); @@ -6390,9 +6422,9 @@ var applyResize = function applyResize(element, data) { y = storedData.y, textLength = storedData.textLength; - var _pointTo11 = pointTo(localCTM, x, y), - resX = _pointTo11.x, - resY = _pointTo11.y; + var _pointTo12 = pointTo(localCTM, x, y), + resX = _pointTo12.x, + resY = _pointTo12.y; attrs.push(['x', resX + (scaleX < 0 ? boxW : 0)], ['y', resY - (scaleY < 0 ? boxH : 0)], ['textLength', Math.abs(scaleX * textLength)]); break; @@ -6405,9 +6437,9 @@ var applyResize = function applyResize(element, data) { cy = storedData.cy, newR = r * (Math.abs(scaleX) + Math.abs(scaleY)) / 2; - var _pointTo12 = pointTo(localCTM, cx, cy), - _resX3 = _pointTo12.x, - _resY3 = _pointTo12.y; + var _pointTo13 = pointTo(localCTM, cx, cy), + _resX3 = _pointTo13.x, + _resY3 = _pointTo13.y; attrs.push(['r', newR], ['cx', _resX3], ['cy', _resY3]); break; @@ -6423,9 +6455,9 @@ var applyResize = function applyResize(element, data) { _x5 = storedData.x, _y5 = storedData.y; - var _pointTo13 = pointTo(localCTM, _x5, _y5), - _resX4 = _pointTo13.x, - _resY4 = _pointTo13.y; + var _pointTo14 = pointTo(localCTM, _x5, _y5), + _resX4 = _pointTo14.x, + _resY4 = _pointTo14.y; var newWidth = Math.abs(width * scaleX), newHeight = Math.abs(height * scaleY); @@ -6449,17 +6481,17 @@ var applyResize = function applyResize(element, data) { _cx = storedData.cx, _cy = storedData.cy; - var _pointTo14 = pointTo(localCTM, _cx, _cy), - cx1 = _pointTo14.x, - cy1 = _pointTo14.y; + var _pointTo15 = pointTo(localCTM, _cx, _cy), + cx1 = _pointTo15.x, + cy1 = _pointTo15.y; var scaleMatrix = createSVGMatrix(); scaleMatrix.a = scaleX; scaleMatrix.d = scaleY; - var _pointTo15 = pointTo(scaleMatrix, rx, ry), - nRx = _pointTo15.x, - nRy = _pointTo15.y; + var _pointTo16 = pointTo(scaleMatrix, rx, ry), + nRx = _pointTo16.x, + nRy = _pointTo16.y; attrs.push(['rx', Math.abs(nRx)], ['ry', Math.abs(nRy)], ['cx', cx1], ['cy', cy1]); break; @@ -6472,13 +6504,13 @@ var applyResize = function applyResize(element, data) { resX2 = storedData.resX2, resY2 = storedData.resY2; - var _pointTo16 = pointTo(localCTM, resX1, resY1), - resX1_ = _pointTo16.x, - resY1_ = _pointTo16.y; + var _pointTo17 = pointTo(localCTM, resX1, resY1), + resX1_ = _pointTo17.x, + resY1_ = _pointTo17.y; - var _pointTo17 = pointTo(localCTM, resX2, resY2), - resX2_ = _pointTo17.x, - resY2_ = _pointTo17.y; + var _pointTo18 = pointTo(localCTM, resX2, resY2), + resX2_ = _pointTo18.x, + resY2_ = _pointTo18.y; attrs.push(['x1', resX1_], ['y1', resY1_], ['x2', resX2_], ['y2', resY2_]); break; @@ -6489,9 +6521,9 @@ var applyResize = function applyResize(element, data) { { var points = storedData.points; var result = parsePoints(points).map(function (item) { - var _pointTo18 = pointTo(localCTM, Number(item[0]), Number(item[1])), - x = _pointTo18.x, - y = _pointTo18.y; + var _pointTo19 = pointTo(localCTM, Number(item[0]), Number(item[1])), + x = _pointTo19.x, + y = _pointTo19.y; item[0] = floatToFixed(x); item[1] = floatToFixed(y); @@ -6690,9 +6722,9 @@ var _getBoundingRect$1 = function _getBoundingRect(element, ctm) { l = _ref30[0], t = _ref30[1]; - var _pointTo19 = pointTo(ctm, l, t), - nx = _pointTo19.x, - ny = _pointTo19.y; + var _pointTo20 = pointTo(ctm, l, t), + nx = _pointTo20.x, + ny = _pointTo20.y; return [nx, ny]; }); diff --git a/dist/js/subjx.js b/dist/js/subjx.js index 7c613ce..3ef7321 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 K(t){return(K="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}}}}(A);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 St=z.NOTIFIER_EVENTS,Vt=z.ON_GETSTATE,Ct=z.ON_APPLY,At=z.ON_MOVE,Nt=z.ON_RESIZE,Pt=z.ON_ROTATE;var Dt=H.EMITTER_EVENTS,jt=H.E_DRAG_START,Bt=H.E_DRAG,Lt=H.E_DRAG_END,zt=H.E_RESIZE_START,Ht=H.E_RESIZE,Xt=H.E_RESIZE_END,It=H.E_ROTATE_START,Gt=H.E_ROTATE,Wt=H.E_ROTATE_END;var Ft=Z,qt=Q;var Zt=X,Qt=W,Ut=G,$t=I,Jt=q,Kt=F;var te=Ft.TOP_LEFT,ee=Ft.TOP_CENTER,re=Ft.TOP_RIGHT,ae=Ft.BOTTOM_LEFT,ne=Ft.BOTTOM_RIGHT,oe=Ft.BOTTOM_CENTER,ie=Ft.MIDDLE_LEFT,le=Ft.MIDDLE_RIGHT;var ue=qt.TOP_EDGE,he=qt.BOTTOM_EDGE,fe=qt.LEFT_EDGE,de=qt.RIGHT_EDGE;var pe=Object.keys,ye=Object.values;var me=function(){o(bt,dt);var n=c(bt);function bt(t,e,r){var a;if(i(this,bt),(a=n.call(this,t)).constructor===bt)throw new TypeError("Cannot construct Transformable instances directly");return a.observable=r,Dt.forEach(function(t){return a.eventDispatcher.registerEvent(t)}),kt(_t(bt.prototype),"enable",s(a)).call(s(a),e),a}return r(bt,[{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=gt({transform:this._processRotate(e,r),delta:r},a);this.proxyMethods.onRotate.call(this,n),kt(_t(bt.prototype),"_emitEvent",this).call(this,Gt,n)}},{key:"_resize",value:function(t){var e=t.element,r=t.dx,a=t.dy,n=R(t,["element","dx","dy"]);var o=gt({},this._processResize(e,{dx:r,dy:a}),{dx:r,dy:a},n);this.proxyMethods.onResize.call(this,o),kt(_t(bt.prototype),"_emitEvent",this).call(this,Ht,o)}},{key:"_processOptions",value:function(t){var e=0120*Math.PI/180){var V=y;var C=a;var A=n;var N=v&&pi+parseFloat(v.css("height"))||ns+parseFloat(v.css("width")))}(r,p)||f.call(this,t,this.elements,r)}:tt,s=et(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=xt(u),f=h.left,d=h.top;c.left="".concat(r-f,"px"),c.top="".concat(a-d,"px");var p=v.cloneNode(!0);rt(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,k(a),Mt(r)||(this.proxyMethods.onDrop.call(this,t),r.parentNode.removeChild(r),delete e.clone)}},{key:"_animate",value:function(){var t=this.storage;t.frameId=Et(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)");rt(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;Mt(t)||(rt(r).off(Or,this._onMouseDown).off(Sr,this._onTouchStart),e.onDestroy.call(this,r),delete this.storage)}},{key:"disable",value:function(){this._destroy()}}]),n}();function Cr(t){if(this.length)return new Vr(f.call(this,function(t){return t}),t)}var Ar=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 wr.call.apply(wr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"clone",value:function(){return Cr.call.apply(Cr,[this].concat(Array.prototype.slice.call(arguments)))}}]),e}();function Nr(t){return new Ar(t)}return Object.defineProperty(Nr,"createObservable",{value:function(){return new it}}),Object.defineProperty(Nr,"Subjx",{value:Ar}),Object.defineProperty(Nr,"Observable",{value:it}),Nr}); +!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 K(t){return(K="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}}}}(V);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 St=z.NOTIFIER_EVENTS,Ct=z.ON_GETSTATE,Vt=z.ON_APPLY,Nt=z.ON_MOVE,At=z.ON_RESIZE,Pt=z.ON_ROTATE;var Dt=H.EMITTER_EVENTS,jt=H.E_DRAG_START,Bt=H.E_DRAG,Lt=H.E_DRAG_END,zt=H.E_RESIZE_START,Ht=H.E_RESIZE,It=H.E_RESIZE_END,Xt=H.E_ROTATE_START,Gt=H.E_ROTATE,Wt=H.E_ROTATE_END,Ft=H.E_SET_POINT;var qt=Z,Zt=Q;var Qt=I,Ut=W,$t=G,Jt=X,Kt=q,te=F;var ee=qt.TOP_LEFT,re=qt.TOP_CENTER,ae=qt.TOP_RIGHT,ne=qt.BOTTOM_LEFT,oe=qt.BOTTOM_RIGHT,ie=qt.BOTTOM_CENTER,le=qt.MIDDLE_LEFT,ue=qt.MIDDLE_RIGHT;var he=Zt.TOP_EDGE,fe=Zt.BOTTOM_EDGE,de=Zt.LEFT_EDGE,pe=Zt.RIGHT_EDGE;var ye=Object.keys,me=Object.values;var xe=function(){o(bt,dt);var n=c(bt);function bt(t,e,r){var a;if(i(this,bt),(a=n.call(this,t)).constructor===bt)throw new TypeError("Cannot construct Transformable instances directly");return a.observable=r,Dt.forEach(function(t){return a.eventDispatcher.registerEvent(t)}),kt(_t(bt.prototype),"enable",s(a)).call(s(a),e),a}return r(bt,[{key:"_cursorPoint",value:function(){throw Error("'_cursorPoint()' method not implemented")}},{key:"_rotate",value:function(t){var e=t.element,r=t.radians,a=N(t,["element","radians"]);var n=gt({transform:this._processRotate(e,r),delta:r},a);this.proxyMethods.onRotate.call(this,n),kt(_t(bt.prototype),"_emitEvent",this).call(this,Gt,n)}},{key:"_resize",value:function(t){var e=t.element,r=t.dx,a=t.dy,n=N(t,["element","dx","dy"]);var o=gt({},this._processResize(e,{dx:r,dy:a}),{dx:r,dy:a},n);this.proxyMethods.onResize.call(this,o),kt(_t(bt.prototype),"_emitEvent",this).call(this,Ht,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)}:tt,s=et(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=xt(u),f=h.left,d=h.top;c.left="".concat(r-f,"px"),c.top="".concat(a-d,"px");var p=v.cloneNode(!0);rt(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),Mt(r)||(this.proxyMethods.onDrop.call(this,t),r.parentNode.removeChild(r),delete e.clone)}},{key:"_animate",value:function(){var t=this.storage;t.frameId=Et(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)");rt(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;Mt(t)||(rt(r).off(Sr,this._onMouseDown).off(Cr,this._onTouchStart),e.onDestroy.call(this,r),delete this.storage)}},{key:"disable",value:function(){this._destroy()}}]),n}();function Nr(t){if(this.length)return new Vr(f.call(this,function(t){return t}),t)}var Ar=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 Rr.call.apply(Rr,[this].concat(Array.prototype.slice.call(arguments)))}},{key:"clone",value:function(){return Nr.call.apply(Nr,[this].concat(Array.prototype.slice.call(arguments)))}}]),e}();function Pr(t){return new Ar(t)}return Object.defineProperty(Pr,"createObservable",{value:function(){return new it}}),Object.defineProperty(Pr,"Subjx",{value:Ar}),Object.defineProperty(Pr,"Observable",{value:it}),Pr}); diff --git a/package.json b/package.json index 7011515..87ea9c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "subjx", - "version": "1.0.0-rc.3", + "version": "1.0.0-rc.4", "description": "Drag, Rotate, Resize library", "author": "Karen Sarksyan (https://github.com/nichollascarter)", "license": "MIT",