text: /*!
   * ui-grid - v4.6.3-1051dee5 - 2018-09-17
   * Copyright (c) 2018 ; License: MIT 
   */
  
  
  !function(){"use strict";var e=angular.module("ui.grid.moveColumns",["ui.grid"]);e.service("uiGridMoveColumnService",["$q","$rootScope","$log","ScrollEvent","uiGridConstants","gridUtil",function(o,d,e,i,s,u){var f={initializeGrid:function(e){this.registerPublicApi(e),this.defaultGridOptions(e.options),e.moveColumns={orderCache:[]},e.registerColumnBuilder(this.movableColumnBuilder),e.registerDataChangeCallback(this.verifyColumnOrder,[s.dataChange.COLUMN])},registerPublicApi:function(t){var a=this,e={events:{colMovable:{columnPositionChanged:function(e,i,n){}}},methods:{colMovable:{moveColumn:function(e,i){var o=t.columns;if(angular.isNumber(e)&&angular.isNumber(i)){for(var n=0,r=0;r<o.length;r++)(angular.isDefined(o[r].colDef.visible)&&!1===o[r].colDef.visible||!0===o[r].isRowHeader)&&n++;if(e>=o.length-n||i>=o.length-n)u.logError("MoveColumn: Invalid values for originalPosition, finalPosition");else{var l=function(e){for(var i=e,n=0;n<=i;n++)angular.isDefined(o[n])&&(angular.isDefined(o[n].colDef.visible)&&!1===o[n].colDef.visible||!0===o[n].isRowHeader)&&i++;return i};a.redrawColumnAtPosition(t,l(e),l(i))}}else u.logError("MoveColumn: Please provide valid values for originalPosition and finalPosition")}}}};t.api.registerEventsFromObject(e.events),t.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.enableColumnMoving=!1!==e.enableColumnMoving},movableColumnBuilder:function(e,i,n){return e.enableColumnMoving=void 0===e.enableColumnMoving?n.enableColumnMoving:e.enableColumnMoving,o.all([])},updateColumnCache:function(e){e.moveColumns.orderCache=e.getOnlyDataColumns()},verifyColumnOrder:function(o){var r,l=o.rowHeaderColumns.length;angular.forEach(o.moveColumns.orderCache,function(e,i){if(-1!==(r=o.columns.indexOf(e))&&r-l!==i){var n=o.columns.splice(r,1)[0];o.columns.splice(i+l,0,n)}})},redrawColumnAtPosition:function(e,i,n){var o=e.columns;if(i!==n){for(var r=i<n?i+1:i-1,l=Math.min(r,n);l<=Math.max(r,n)&&!o[l].visible;l++);if(!(l>Math.max(r,n))){var t=o[i];if(t.colDef.enableColumnMoving){if(n<i)for(var a=i;n<a;a--)o[a]=o[a-1];else if(i<n)for(var u=i;u<n;u++)o[u]=o[u+1];o[n]=t,f.updateColumnCache(e),e.queueGridRefresh(),d.$applyAsync(function(){e.api.core.notifyDataChange(s.dataChange.COLUMN),e.api.colMovable.raise.columnPositionChanged(t.colDef,i,n)})}}}}};return f}]),e.directive("uiGridMoveColumns",["uiGridMoveColumnService",function(r){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,compile:function(){return{pre:function(e,i,n,o){r.initializeGrid(o.grid)},post:function(e,i,n,o){}}}}}]),e.directive("uiGridHeaderCell",["$q","gridUtil","uiGridMoveColumnService","$document","$log","uiGridConstants","ScrollEvent",function(e,i,w,D,n,o,M){return{priority:-10,require:"^uiGrid",compile:function(){return{post:function(s,o,e,f){if(s.col.colDef.enableColumnMoving){var c,r,g,v,m,h,i=angular.element(o[0].querySelectorAll(".ui-grid-cell-contents")),d=!1,C=!1,n=function(e){c=s.grid.element[0].getBoundingClientRect().left,s.grid.hasLeftContainer()&&(c+=s.grid.renderContainers.left.header[0].getBoundingClientRect().width),r=e.pageX||(e.originalEvent?e.originalEvent.pageX:0),g=0,v=c+s.grid.getViewportWidth(),"mousedown"===e.type?(D.on("mousemove",l),D.on("mouseup",t)):"touchstart"===e.type&&(D.on("touchmove",l),D.on("touchend",t))},l=function(e){var i=e.pageX||(e.originalEvent?e.originalEvent.pageX:0),n=i-r;0!==n&&(document.onselectstart=function(){return!1},C=!0,d?d&&(u(n),r=i):a())},t=function(e){if(document.onselectstart=null,m&&(m.remove(),d=!1),p(),b(),C){for(var i,n=s.grid.columns,o=0,r=0;r<n.length&&n[r].colDef.name!==s.col.colDef.name;r++)o++;if(g<0){var l,t=0;if(s.grid.isRTL()){for(l=o+1;l<n.length;l++)if((angular.isUndefined(n[l].colDef.visible)||!0===n[l].colDef.visible)&&(t+=n[l].drawnWidth||n[l].width||n[l].colDef.width)>Math.abs(g)){w.redrawColumnAtPosition(s.grid,o,l-1);break}}else for(l=o-1;0<=l;l--)if((angular.isUndefined(n[l].colDef.visible)||!0===n[l].colDef.visible)&&(t+=n[l].drawnWidth||n[l].width||n[l].colDef.width)>Math.abs(g)){w.redrawColumnAtPosition(s.grid,o,l+1);break}t<Math.abs(g)&&(i=0,s.grid.isRTL()&&(i=n.length-1),w.redrawColumnAtPosition(s.grid,o,i))}else if(0<g){var a,u=0;if(s.grid.isRTL()){for(a=o-1;0<a;a--)if((angular.isUndefined(n[a].colDef.visible)||!0===n[a].colDef.visible)&&(u+=n[a].drawnWidth||n[a].width||n[a].colDef.width,g<u)){w.redrawColumnAtPosition(s.grid,o,a);break}}else for(a=o+1;a<n.length;a++)if((angular.isUndefined(n[a].colDef.visible)||!0===n[a].colDef.visible)&&(u+=n[a].drawnWidth||n[a].width||n[a].colDef.width,g<u)){w.redrawColumnAtPosition(s.grid,o,a-1);break}u<g&&(i=n.length-1,s.grid.isRTL()&&(i=0),w.redrawColumnAtPosition(s.grid,o,i))}}},b=function(){i.on("touchstart",n),i.on("mousedown",n)},p=function(){i.off("touchstart",n),i.off("mousedown",n),D.off("mousemove",l),D.off("touchmove",l),D.off("mouseup",t),D.off("touchend",t)};b();var a=function(){d=!0,m=o.clone(),o.parent().append(m),m.addClass("movingColumn");var e={};e.left=o[0].offsetLeft+"px";var i=s.grid.element[0].getBoundingClientRect().right,n=o[0].getBoundingClientRect().right;i<n&&(h=s.col.drawnWidth+(i-n),e.width=h+"px"),m.css(e)},u=function(e){for(var i=s.grid.columns,n=0,o=0;o<i.length;o++)(angular.isUndefined(i[o].colDef.visible)||!0===i[o].colDef.visible)&&(n+=i[o].drawnWidth||i[o].width||i[o].colDef.width);var r,l=m[0].getBoundingClientRect().left-1,t=m[0].getBoundingClientRect().right;if(r=(r=l-c+e)<v?r:v,(c<=l||0<e)&&(t<=v||e<0))m.css({visibility:"visible",left:m[0].offsetLeft+(r<v?e:v-l)+"px"});else if(n>Math.ceil(f.grid.gridWidth)){e*=8;var a=new M(s.col.grid,null,null,"uiGridHeaderCell.moveElement");a.x={pixels:e},a.grid.scrollContainers("",a)}for(var u=0,d=0;d<i.length;d++)if(angular.isUndefined(i[d].colDef.visible)||!0===i[d].colDef.visible){if(i[d].colDef.name===s.col.colDef.name)break;u+=i[d].drawnWidth||i[d].width||i[d].colDef.width}void 0===s.newScrollLeft?g+=e:g=s.newScrollLeft+r-u,h<s.col.drawnWidth&&(h+=Math.abs(e),m.css({width:h+"px"}))};s.$on("$destroy",p)}}}}}}])}();