angular.module("angularResizable",[]).directive("resizable",function(){function e(e){void 0===t?(t=e,setTimeout(function(){t(),t=void 0},100)):t=e}var t;return{restrict:"AE",scope:{rDirections:"=",rCenteredX:"=",rCenteredY:"=",rWidth:"=",rHeight:"=",rFlex:"=",rGrabber:"@",rDisabled:"@",rNoThrottle:"=",resizable:"@"},link:function(t,r,n){if("false"!==t.resizable){var i="flexBasis"in document.documentElement.style?"flexBasis":"webkitFlexBasis"in document.documentElement.style?"webkitFlexBasis":"msFlexPreferredSize"in document.documentElement.style?"msFlexPreferredSize":"flexBasis",o=t.$watch("rWidth",function(e){r[0].style[t.rFlex?i:"width"]=t.rWidth+"px"}),s=t.$watch("rHeight",function(e){r[0].style[t.rFlex?i:"height"]=t.rHeight+"px"});t.$on("$destroy",function(){s(),o()}),r.addClass("resizable");var a,l,u,d,c,h=window.getComputedStyle(r[0],null),m=t.rDirections||["right"],v=t.rCenteredX?2:1,p=t.rCenteredY?2:1,f=t.rGrabber?t.rGrabber:"",g={},x=function(e){g.width=!1,g.height=!1,"x"===c?g.width=parseInt(r[0].style[t.rFlex?i:"width"]):g.height=parseInt(r[0].style[t.rFlex?i:"height"]),g.id=r[0].id,g.evt=e},b=function(e){return e.touches?e.touches[0].clientX:e.clientX},y=function(e){return e.touches?e.touches[0].clientY:e.clientY},E=function(n){function o(){t.$emit("angular-resizable.resizing",g)}var s,h="x"===c?u-b(n):u-y(n);switch(d){case"top":s=t.rFlex?i:"height",r[0].style[s]=l+h*p+"px";break;case"bottom":s=t.rFlex?i:"height",r[0].style[s]=l-h*p+"px";break;case"right":s=t.rFlex?i:"width",r[0].style[s]=a-h*v+"px";break;case"left":s=t.rFlex?i:"width",r[0].style[s]=a+h*v+"px"}x(n),t.rNoThrottle?o():e(o)},w=function(e){x(),t.$emit("angular-resizable.resizeEnd",g),t.$apply(),document.removeEventListener("mouseup",w,!1),document.removeEventListener("mousemove",E,!1),document.removeEventListener("touchend",w,!1),document.removeEventListener("touchmove",E,!1),r.removeClass("no-transition")},z=function(e,n){d=n,c="left"===d||"right"===d?"x":"y",u="x"===c?b(e):y(e),a=parseInt(h.getPropertyValue("width")),l=parseInt(h.getPropertyValue("height")),r.addClass("no-transition"),document.addEventListener("mouseup",w,!1),document.addEventListener("mousemove",E,!1),document.addEventListener("touchend",w,!1),document.addEventListener("touchmove",E,!1),e.stopPropagation&&e.stopPropagation(),e.preventDefault&&e.preventDefault(),e.cancelBubble=!0,e.returnValue=!1,x(e),t.$emit("angular-resizable.resizeStart",g),t.$apply()};m.forEach(function(e){var n=document.createElement("div");n.setAttribute("class","rg-"+e),n.innerHTML=f,r[0].appendChild(n),n.ondragstart=function(){return!1};var i=function(r){var n="true"===t.rDisabled;n||1!==r.which&&!r.touches||z(r,e)};n.addEventListener("mousedown",i,!1),n.addEventListener("touchstart",i,!1),t.$on("$destroy",function(){n.removeEventListener("mousedown",i,!1),n.removeEventListener("touchstart",i,!1),n.remove()})})}}}});