text: /*!
   * ui-grid - v4.8.2 - 2019-10-07
   * Copyright (c) 2019 ; License: MIT 
   */
  
  
  !function(){"use strict";var e=angular.module("ui.grid.saveState",["ui.grid","ui.grid.selection","ui.grid.cellNav","ui.grid.grouping","ui.grid.pinning","ui.grid.treeView"]);e.constant("uiGridSaveStateConstants",{featureName:"saveState"}),e.service("uiGridSaveStateService",function(){var s={initializeGrid:function(n){n.saveState={},this.defaultGridOptions(n.options);var e={events:{saveState:{}},methods:{saveState:{save:function(){return s.save(n)},restore:function(e,i){return s.restore(n,e,i)}}}};n.api.registerEventsFromObject(e.events),n.api.registerMethodsFromObject(e.methods)},defaultGridOptions:function(e){e.saveWidths=!1!==e.saveWidths,e.saveOrder=!1!==e.saveOrder,e.saveScroll=!0===e.saveScroll,e.saveFocus=!0!==e.saveScroll&&!1!==e.saveFocus,e.saveVisible=!1!==e.saveVisible,e.saveSort=!1!==e.saveSort,e.saveFilter=!1!==e.saveFilter,e.saveSelection=!1!==e.saveSelection,e.saveGrouping=!1!==e.saveGrouping,e.saveGroupingExpandedStates=!0===e.saveGroupingExpandedStates,e.savePinning=!1!==e.savePinning,e.saveTreeView=!1!==e.saveTreeView},save:function(e){var i={};return i.columns=s.saveColumns(e),i.scrollFocus=s.saveScrollFocus(e),i.selection=s.saveSelection(e),i.grouping=s.saveGrouping(e),i.treeView=s.saveTreeView(e),i.pagination=s.savePagination(e),i},restore:function(e,i,n){return n.columns&&s.restoreColumns(e,n.columns),n.scrollFocus&&s.restoreScrollFocus(e,i,n.scrollFocus),n.selection&&s.restoreSelection(e,n.selection),n.grouping&&s.restoreGrouping(e,n.grouping),n.treeView&&s.restoreTreeView(e,n.treeView),n.pagination&&s.restorePagination(e,n.pagination),e.refresh()},saveColumns:function(n){var o=[];return n.getOnlyDataColumns().forEach(function(e){var i={};i.name=e.name,n.options.saveVisible&&(i.visible=e.visible),n.options.saveWidths&&(i.width=e.width),n.options.saveSort&&(i.sort=angular.copy(e.sort)),n.options.saveFilter&&(i.filters=[],e.filters.forEach(function(e){var n={};angular.forEach(e,function(e,i){"condition"!==i&&"$$hashKey"!==i&&"placeholder"!==i&&(n[i]=e)}),i.filters.push(n)})),n.api.pinning&&n.options.savePinning&&(i.pinned=e.renderContainer?e.renderContainer:""),o.push(i)}),o},saveScrollFocus:function(e){if(!e.api.cellNav)return{};var i={};if(e.options.saveFocus){i.focus=!0;var n=e.api.cellNav.getFocusedCell();null!==n&&(null!==n.col&&(i.colName=n.col.colDef.name),null!==n.row&&(i.rowVal=s.getRowVal(e,n.row)))}return(e.options.saveScroll||e.options.saveFocus&&!i.colName&&!i.rowVal)&&(i.focus=!1,e.renderContainers.body.prevRowScrollIndex&&(i.rowVal=s.getRowVal(e,e.renderContainers.body.visibleRowCache[e.renderContainers.body.prevRowScrollIndex])),e.renderContainers.body.prevColScrollIndex&&(i.colName=e.renderContainers.body.visibleColumnCache[e.renderContainers.body.prevColScrollIndex].name)),i},saveSelection:function(i){return i.api.selection&&i.options.saveSelection?i.api.selection.getSelectedGridRows().map(function(e){return s.getRowVal(i,e)}):[]},saveGrouping:function(e){return e.api.grouping&&e.options.saveGrouping?e.api.grouping.getGrouping(e.options.saveGroupingExpandedStates):{}},savePagination:function(e){return e.api.pagination&&e.options.paginationPageSize?{paginationCurrentPage:e.options.paginationCurrentPage,paginationPageSize:e.options.paginationPageSize}:{}},saveTreeView:function(e){return e.api.treeView&&e.options.saveTreeView?e.api.treeView.getTreeView():{}},getRowVal:function(e,i){if(!i)return null;var n={};return e.options.saveRowIdentity?(n.identity=!0,n.row=e.options.saveRowIdentity(i.entity)):(n.identity=!1,n.row=e.renderContainers.body.visibleRowCache.indexOf(i)),n},restoreColumns:function(r,e){var a=!1;e.forEach(function(e,i){var n=r.getColumn(e.name);if(n&&!r.isRowHeaderColumn(n)){!r.options.saveVisible||n.visible===e.visible&&n.colDef.visible===e.visible||(n.visible=e.visible,n.colDef.visible=e.visible,r.api.core.raise.columnVisibilityChanged(n)),r.options.saveWidths&&n.width!==e.width&&(n.width=e.width,n.hasCustomWidth=!0),!r.options.saveSort||angular.equals(n.sort,e.sort)||void 0===n.sort&&angular.isEmpty(e.sort)||(n.sort=angular.copy(e.sort),a=!0),r.options.saveFilter&&!angular.equals(n.filters,e.filters)&&(e.filters.forEach(function(e,i){angular.extend(n.filters[i],e),void 0!==e.term&&null!==e.term||delete n.filters[i].term}),r.api.core.raise.filterChanged(n)),r.api.pinning&&r.options.savePinning&&n.renderContainer!==e.pinned&&r.api.pinning.pinColumn(n,e.pinned);var o=r.getOnlyDataColumns().indexOf(n);if(-1!==o&&r.options.saveOrder&&o!==i){var t=r.columns.splice(o+r.rowHeaderColumns.length,1)[0];r.columns.splice(i+r.rowHeaderColumns.length,0,t)}}}),a&&r.api.core.raise.sortChanged(r,r.getColumnSorting())},restoreScrollFocus:function(e,i,n){if(e.api.cellNav){var o,t;if(n.colName){var r=e.options.columnDefs.filter(function(e){return e.name===n.colName});0<r.length&&(o=r[0])}n.rowVal&&n.rowVal.row&&(t=n.rowVal.identity?s.findRowByIdentity(e,n.rowVal):e.renderContainers.body.visibleRowCache[n.rowVal.row]);var a=t&&t.entity?t.entity:null;(o||a)&&(n.focus?e.api.cellNav.scrollToFocus(a,o):e.scrollTo(a,o))}},restoreSelection:function(n,e){n.api.selection&&(n.api.selection.clearSelectedRows(),e.forEach(function(e){if(e.identity){var i=s.findRowByIdentity(n,e);i&&n.api.selection.selectRow(i.entity)}else n.api.selection.selectRowByVisibleIndex(e.row)}))},restoreGrouping:function(e,i){e.api.grouping&&null!=i&&!angular.equals(i,{})&&e.api.grouping.setGrouping(i)},restoreTreeView:function(e,i){e.api.treeView&&null!=i&&!angular.equals(i,{})&&e.api.treeView.setTreeView(i)},restorePagination:function(e,i){e.api.pagination&&e.options.paginationPageSize&&(e.options.paginationCurrentPage=i.paginationCurrentPage,e.options.paginationPageSize=i.paginationPageSize)},findRowByIdentity:function(i,n){if(!i.options.saveRowIdentity)return null;var e=i.rows.filter(function(e){return i.options.saveRowIdentity(e.entity)===n.row});return 0<e.length?e[0]:null}};return s}),e.directive("uiGridSaveState",["uiGridSaveStateConstants","uiGridSaveStateService","gridUtil","$compile",function(e,t,i,n){return{replace:!0,priority:0,require:"^uiGrid",scope:!1,link:function(e,i,n,o){t.initializeGrid(o.grid)}}}])}();