/*
    *
    * Wijmo Library 5.20183.550
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
var __extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function o(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}}();define(["require","exports","wijmo/wijmo","wijmo/wijmo.grid"],function(e,t,i,o){"use strict";function n(){var e;return(e=r.wijmo)&&e.input}Object.defineProperty(t,"__esModule",{value:!0});var r="undefined"!=typeof window?window:self,s=o||t;r.wijmo=r.wijmo||{},r.wijmo.grid=s,i._addCultureInfo("FlexGrid",{groupHeaderFormat:"{name}: <b>{value}</b> ({count:n0} items)",ariaLabels:{toggleDropDown:"Toggle Dropdown",toggleGroup:"Toggle Group"}});var l;!function(e){e[e.None=0]="None",e[e.Column=1]="Column",e[e.Row=2]="Row",e[e.All=3]="All"}(l=t.HeadersVisibility||(t.HeadersVisibility={}));var a=function(e){function t(t,o){var n=e.call(this,t,null,!0)||this;n._szClient=new i.Size(0,0),n._ptScrl=new i.Point(0,0),n._cellPadding=3,n._clipToScreen=!1,n._autoGenCols=!0,n._autoClipboard=!0,n._autoScroll=!0,n._autoSearch=!1,n._readOnly=!1,n._indent=14,n._autoSizeMode=O.Both,n._hdrVis=l.All,n._alSorting=!0,n._alAddNew=!1,n._alDelete=!1,n._alResizing=L.Columns,n._alDragging=I.Columns,n._alMerging=E.None,n._ssHdr=l.None,n._shSort=!0,n._shGroups=!0,n._shAlt=!0,n._shErr=!0,n._shDropDown=!0,n._valEdt=!0,n._deferResizing=!1,n._pSel=!0,n._pOutline=!0,n._vt=0,n._vtRows=0,n._vtCols=0,n.itemsSourceChanging=new i.Event,n.itemsSourceChanged=new i.Event,n.scrollPositionChanged=new i.Event,n.selectionChanging=new i.Event,n.selectionChanged=new i.Event,n.loadingRows=new i.Event,n.loadedRows=new i.Event,n.updatingLayout=new i.Event,n.updatedLayout=new i.Event,n.resizingColumn=new i.Event,n.resizedColumn=new i.Event,n.autoSizingColumn=new i.Event,n.autoSizedColumn=new i.Event,n.draggingColumn=new i.Event,n.draggingColumnOver=new i.Event,n.draggedColumn=new i.Event,n.resizingRow=new i.Event,n.resizedRow=new i.Event,n.autoSizingRow=new i.Event,n.autoSizedRow=new i.Event,n.draggingRow=new i.Event,n.draggingRowOver=new i.Event,n.draggedRow=new i.Event,n.groupCollapsedChanging=new i.Event,n.groupCollapsedChanged=new i.Event,n.sortingColumn=new i.Event,n.sortedColumn=new i.Event,n.beginningEdit=new i.Event,n.prepareCellForEdit=new i.Event,n.cellEditEnding=new i.Event,n.cellEditEnded=new i.Event,n.rowEditStarting=new i.Event,n.rowEditStarted=new i.Event,n.rowEditEnding=new i.Event,n.rowEditEnded=new i.Event,n.rowAdded=new i.Event,n.deletingRow=new i.Event,n.deletedRow=new i.Event,n.copying=new i.Event,n.copied=new i.Event,n.pasting=new i.Event,n.pasted=new i.Event,n.pastingCell=new i.Event,n.pastedCell=new i.Event,n.formatItem=new i.Event,n.updatingView=new i.Event,n.updatedView=new i.Event,n._mappedColumns=null;var r=n.hostElement;i.isIE()&&(r.style.borderRadius="0");var s=n.getTemplate();n.applyTemplate("wj-control wj-content wj-flexgrid",s,{_root:"root",_eSz:"sz",_eCt:"cells",_fCt:"fcells",_eTL:"tl",_eBL:"bl",_eCHdr:"ch",_eRHdr:"rh",_eCFtr:"cf",_eTLCt:"tlcells",_eBLCt:"blcells",_eCHdrCt:"chcells",_eCFtrCt:"cfcells",_eRHdrCt:"rhcells",_eMarquee:"marquee",_eFocus:"focus"});return[n._eRHdr,n._eCFtr,n._eCHdr,n._eBL,n._eTL].forEach(function(e){i.setAttribute(e,"aria-hidden",!0),i.setCss(e,{position:"absolute",overflow:"hidden",outline:"none"}),i.setCss(e.firstElementChild,{position:"relative"})}),[n._eFocus,n._eMarquee,n._fCt,n._eSz].forEach(function(e){i.setAttribute(e,"aria-hidden",!0)}),r.tabIndex=-1,n.deferUpdate(function(){var e=n._getDefaultRowHeight();n._rows=new R(n,e),n._cols=new b(n,4*e),n._hdrRows=new R(n,e),n._hdrCols=new b(n,Math.round(1.25*e)),n._ftrRows=new R(n,e),n._gpTL=new g(n,d.TopLeft,n._hdrRows,n._hdrCols,n._eTLCt),n._gpCHdr=new g(n,d.ColumnHeader,n._hdrRows,n._cols,n._eCHdrCt),n._gpRHdr=new g(n,d.RowHeader,n._rows,n._hdrCols,n._eRHdrCt),n._gpCells=new g(n,d.Cell,n._rows,n._cols,n._eCt),n._gpBL=new g(n,d.BottomLeft,n._ftrRows,n._hdrCols,n._eBLCt),n._gpCFtr=new g(n,d.ColumnFooter,n._ftrRows,n._cols,n._eCFtrCt),n._hdrRows.push(new v),n._hdrCols.push(new m({align:"center"})),n._cf=new p,n._keyHdl=new j(n),n._mouseHdl=new A(n),n._edtHdl=new B(n),n._selHdl=new M(n),n._addHdl=new N(n),n._mrgMgr=new z(n),n._bndSortConverter=n._sortConverter.bind(n),i.setAttribute(n.cells.hostElement,"role","grid"),n.selectionMode=H.CellRange,n.initialize(o)}),n.addEventListener(n._root,"scroll",function(e){n._updateScrollPosition()&&(n.finishEditing(),n._updateContent(!0))}),n.addEventListener(r,"focus",function(e){if(r.tabIndex>-1){var t=e.target;if(t instanceof HTMLElement&&t.tabIndex<0)return void n._setFocus(!0)}},!0),n}return __extends(t,e),t.prototype._handleResize=function(){this._rcBounds=null,e.prototype._handleResize.call(this)},Object.defineProperty(t.prototype,"headersVisibility",{get:function(){return this._hdrVis},set:function(e){(e=i.asEnum(e,l))!=this._hdrVis&&(this._hdrVis=e,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stickyHeaders",{get:function(){return this._stickyHdr},set:function(e){e!=this._stickyHdr&&(this._stickyHdr=i.asBoolean(e),this._updateStickyHeaders(),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"preserveSelectedState",{get:function(){return this._pSel},set:function(e){this._pSel=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"preserveOutlineState",{get:function(){return this._pOutline},set:function(e){this._pOutline=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"virtualizationThreshold",{get:function(){return this._vt},set:function(e){this._vt=e,i.isNumber(e)?this._vtRows=this._vtCols=i.asNumber(e):e?i.isArray(e)&&2==e.length?(this._vtRows=i.asNumber(e[0]),this._vtCols=i.asNumber(e[1])):i.assert(!1,"virtualizationThreshold should be a number or an array with two numbers."):this._vtRows=this._vtCols=0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoGenerateColumns",{get:function(){return this._autoGenCols},set:function(e){this._autoGenCols=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoClipboard",{get:function(){return this._autoClipboard},set:function(e){this._autoClipboard=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoScroll",{get:function(){return this._autoScroll},set:function(e){this._autoScroll=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoSearch",{get:function(){return this._autoSearch},set:function(e){this._autoSearch=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columnLayout",{get:function(){for(var e=t._getSerializableProperties(m),o=new m,n=[],r=0;r<this.columns.length;r++){for(var s=this.columns[r],l={},a=0;a<e.length;a++){var h=e[a],c=s[h];c!=o[h]&&i.isPrimitive(c)&&"size"!=h&&(l[h]=c)}n.push(l)}return JSON.stringify({columns:n})},set:function(e){var t=JSON.parse(i.asString(e));if(!t||null==t.columns)throw"Invalid columnLayout data.";this.columns.clear(),this.initialize(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isReadOnly",{get:function(){return this._readOnly},set:function(e){e!=this._readOnly&&(this._readOnly=i.asBoolean(e),this.finishEditing(),this.invalidate(!0),this._addHdl.updateNewRowTemplate(),i.toggleClass(this.hostElement,"wj-state-readonly",this.isReadOnly),this._setAria("readonly",this.isReadOnly?"true":null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imeEnabled",{get:function(){return null!=this._imeHdl},set:function(e){if(i.asBoolean(e)!=this.imeEnabled&&this.finishEditing()){var t=this.containsFocus();this._imeHdl&&(this._imeHdl.dispose(),this._imeHdl=null),e&&(this._imeHdl=new F(this)),t&&this.focus()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowResizing",{get:function(){return this._alResizing},set:function(e){this._alResizing=i.asEnum(e,L)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"deferResizing",{get:function(){return this._deferResizing},set:function(e){this._deferResizing=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoSizeMode",{get:function(){return this._autoSizeMode},set:function(e){this._autoSizeMode=i.asEnum(e,O)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quickAutoSize",{get:function(){return this._quickSize},set:function(e){this._quickSize=i.asBoolean(e,!0)},enumerable:!0,configurable:!0}),t.prototype._getQuickAutoSize=function(){return i.isBoolean(this._quickSize)?this._quickSize:!this.formatItem.hasHandlers&&null==this.itemFormatter},Object.defineProperty(t.prototype,"allowSorting",{get:function(){return this._alSorting},set:function(e){this._alSorting=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowAddNew",{get:function(){return this._alAddNew},set:function(e){e!=this._alAddNew&&(this._alAddNew=i.asBoolean(e),this._addHdl.updateNewRowTemplate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"newRowAtTop",{get:function(){return this._addHdl.newRowAtTop},set:function(e){this._addHdl.newRowAtTop=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowDelete",{get:function(){return this._alDelete},set:function(e){e!=this._alDelete&&(this._alDelete=i.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowMerging",{get:function(){return this._alMerging},set:function(e){(e=i.asEnum(e,E))!=this._alMerging&&(this._alMerging=e,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showSelectedHeaders",{get:function(){return this._ssHdr},set:function(e){(e=i.asEnum(e,l))!=this._ssHdr&&(this._ssHdr=e,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showMarquee",{get:function(){return!this._eMarquee.style.display},set:function(e){if(e!=this.showMarquee){var t=this._eMarquee.style;t.visibility="collapse",t.display=i.asBoolean(e)?"":"none",this.invalidate()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showSort",{get:function(){return this._shSort},set:function(e){e!=this._shSort&&(this._shSort=i.asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showGroups",{get:function(){return this._shGroups},set:function(e){e!=this._shGroups&&(this._shGroups=i.asBoolean(e),this._bindGrid(!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showAlternatingRows",{get:function(){return this._shAlt},set:function(e){e!=this._shAlt&&(this._shAlt=i.asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showErrors",{get:function(){return this._shErr},set:function(e){e!=this._shErr&&(this._clearCells(),this._shErr=i.asBoolean(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"itemValidator",{get:function(){return this._itemValidator},set:function(e){e!=this.itemValidator&&(this._itemValidator=i.asFunction(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"validateEdits",{get:function(){return this._valEdt},set:function(e){this._valEdt=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"groupHeaderFormat",{get:function(){return this._gHdrFmt},set:function(e){e!=this._gHdrFmt&&(this._gHdrFmt=i.asString(e),this._bindGrid(!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowDragging",{get:function(){return this._alDragging},set:function(e){(e=i.asEnum(e,I))!=this._alDragging&&(this._alDragging=e,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"itemsSource",{get:function(){return this._items},set:function(e){if(e!=this._items){var t=new i.CancelEventArgs;if(this.onItemsSourceChanging(t)){if(this._cv&&((o=i.tryCast(this._cv,i.CollectionView))&&o.sortConverter==this._bndSortConverter&&(o.sortConverter=null),this._cv.currentChanged.removeHandler(this._cvCurrentChanged,this),this._cv.collectionChanged.removeHandler(this._cvCollectionChanged,this),this._cv=null),this._items=e,this._cv=this._getCollectionView(e),this._lastCount=0,this._cv){this._cv.currentChanged.addHandler(this._cvCurrentChanged,this),this._cv.collectionChanged.addHandler(this._cvCollectionChanged,this);var o=i.tryCast(this._cv,i.CollectionView);o&&!o.sortConverter&&(o.sortConverter=this._bndSortConverter)}this._bindGrid(!0);var n=H;this.selectionMode==n.ListBox&&(this.selectionMode=n.CellRange,this.selectionMode=n.ListBox),this.onItemsSourceChanged(t)}}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collectionView",{get:function(){return this._cv},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"editableCollectionView",{get:function(){return i.tryCast(this._cv,"IEditableCollectionView")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"childItemsPath",{get:function(){return this._childItemsPath},set:function(e){e!=this._childItemsPath&&(i.assert(null==e||i.isArray(e)||i.isString(e),"childItemsPath should be an array or a string."),this._childItemsPath=e,this._bindGrid(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowHeaderPath",{get:function(){return this._rowHdrPath?this._rowHdrPath.path:null},set:function(e){e!=this.rowHeaderPath&&(e=i.asString(e),this._rowHdrPath=e?new i.Binding(e):null,this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cells",{get:function(){return this._gpCells},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columnHeaders",{get:function(){return this._gpCHdr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columnFooters",{get:function(){return this._gpCFtr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowHeaders",{get:function(){return this._gpRHdr},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"topLeftCells",{get:function(){return this._gpTL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bottomLeftCells",{get:function(){return this._gpBL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rows",{get:function(){return this._rows},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"columns",{get:function(){return this._cols},enumerable:!0,configurable:!0}),t.prototype.getColumn=function(e){return this.columns.getColumn(e)},Object.defineProperty(t.prototype,"frozenRows",{get:function(){return this.rows.frozen},set:function(e){this.rows.frozen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frozenColumns",{get:function(){return this.columns.frozen},set:function(e){this.columns.frozen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cloneFrozenCells",{get:function(){return this._fzClone},set:function(e){e!=this.cloneFrozenCells&&(this._fzClone=i.asBoolean(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sortRowIndex",{get:function(){return this._sortRowIndex},set:function(e){e!=this._sortRowIndex&&(this._sortRowIndex=i.asNumber(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollPosition",{get:function(){return this._ptScrl.clone()},set:function(e){var i=this._root,o=-e.x;if(this.rightToLeft)switch(t._getRtlMode()){case"rev":o=i.scrollWidth-i.clientWidth+e.x;break;case"neg":o=e.x;break;default:o=-e.x}i.scrollLeft=o,i.scrollTop=-e.y},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"clientSize",{get:function(){return this._szClient},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controlRect",{get:function(){return this._rcBounds||(this._rcBounds=i.getElementRect(this._root)),this._rcBounds},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scrollSize",{get:function(){return new i.Size(this._gpCells.width,this._heightBrowser)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"viewRange",{get:function(){return this._gpCells.viewRange},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cellFactory",{get:function(){return this._cf},set:function(e){e!=this._cf&&(this._clearCells(),this._cf=i.asType(e,p,!1))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"itemFormatter",{get:function(){return this._itemFormatter},set:function(e){e!=this._itemFormatter&&(this._clearCells(),this._itemFormatter=i.asFunction(e))},enumerable:!0,configurable:!0}),t.prototype.canEditCell=function(e,t){return this._edtHdl._allowEditing(e,t)},t.prototype.getCellData=function(e,t,i){return this.cells.getCellData(e,t,i)},t.prototype.getCellBoundingRect=function(e,t,i){return this.cells.getCellBoundingRect(e,t,i)},t.prototype.setCellData=function(e,t,i,o,n){return void 0===o&&(o=!0),void 0===n&&(n=!0),this.cells.setCellData(e,t,i,o,n)},t.prototype.hitTest=function(e,t){return i.isNumber(e)&&i.isNumber(t)&&(e=new i.Point(e,t)),i.isBoolean(t)&&t&&(this._rcBounds=null),new S(this,e)},t.prototype.getClipString=function(e){return this._edtHdl.getClipString(e)},t.prototype.setClipString=function(e,t){this._edtHdl.setClipString(e,t)},t.prototype.focus=function(){this._setFocus(!1)},t.prototype.dispose=function(){this.finishEditing(!0),this.itemsSource=null,e.prototype.dispose.call(this)},t.prototype.refresh=function(t){if(void 0===t&&(t=!0),e.prototype.refresh.call(this,t),this.finishEditing(),t){this._updateColumnTypes(),this.scrollPosition=this._ptScrl;var i=this._getDefaultRowHeight();this._rows._setDefaultSize(i),this._cols._setDefaultSize(4*i),this._hdrRows._setDefaultSize(i),this._hdrCols._setDefaultSize(Math.round(1.25*i)),this._ftrRows._setDefaultSize(i)}this.refreshCells(t)},t.prototype.refreshCells=function(e,t,i){this.isUpdating||(e?this._updateLayout():this._updateContent(t,i))},t.prototype.autoSizeColumn=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=4),this.autoSizeColumns(e,e,t,i)},t.prototype.autoSizeColumns=function(e,o,n,r){var s=this;void 0===n&&(n=!1),void 0===r&&(r=4);var l=0,a=n?this.topLeftCells:this.columnHeaders,h=n?this.bottomLeftCells:this.columnFooters,c=n?this.rowHeaders:this.cells,u=this.viewRange;e=null==e?0:i.asInt(e),o=null==o?c.columns.length-1:i.asInt(o),u.row=Math.max(0,u.row-1e3),u.row2=Math.min(u.row2+1e3,this.rows.length-1),this.finishEditing()&&this.columns.deferUpdate(function(){i.setCss(s._eCt,{width:s._gpCells.width});var n=document.createElement("div");n.setAttribute(t._WJS_MEASURE,"true"),n.style.visibility="hidden",c.hostElement.parentElement.appendChild(n);for(var d=s._getCanvasContext(),g=e;g<=o&&g>-1&&g<c.columns.length;g++){var p=c.columns[g];if(p.isVisible){if(l=0,s.autoSizeMode&O.Headers){for(f=0;f<a.rows.length;f++)if(a.rows[f].isVisible){_=s._getDesiredWidth(a,f,g,n);l=Math.max(l,_)}for(f=0;f<h.rows.length;f++)if(h.rows[f].isVisible){_=s._getDesiredWidth(h,f,g,n);l=Math.max(l,_)}}if(s.autoSizeMode&O.Cells&&u.isValid)if(p._getQuickAutoSize()){var f=s._getWidestRow(c,u,g,d),_=s._getDesiredWidth(c,f,g,n);l=Math.max(l,_)}else for(f=u.row;f<=u.row2&&f<c.rows.length;f++)if(c.rows[f].isVisible){_=s._getDesiredWidth(c,f,g,n);l=Math.max(l,_)}l>0&&(p.width=l+r+2)}}s.cellFactory.disposeCell(n),i.removeChild(n)})},t.prototype.autoSizeRow=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=0),this.autoSizeRows(e,e,t,i)},t.prototype.autoSizeRows=function(e,o,n,r){var s=this;void 0===n&&(n=!1),void 0===r&&(r=0);var l=0,a=n?this.topLeftCells:this.rowHeaders,h=n?this.columnHeaders:this.cells;n=i.asBoolean(n),r=i.asNumber(r),e=null==e?0:i.asInt(e),o=null==o?h.rows.length-1:i.asInt(o),this.finishEditing()&&this.rows.deferUpdate(function(){i.setCss(s._eCt,{width:s._gpCells.width});var n=document.createElement("div");n.setAttribute(t._WJS_MEASURE,"true"),n.style.visibility="hidden",h.hostElement.appendChild(n);for(var c={},u=e;u<=o&&u>-1&&u<h.rows.length;u++)h.rows[u].isVisible&&(l=0,s.autoSizeMode&O.Headers&&(l=s._getDesiredRowHeight(a,u,n,c)),s.autoSizeMode&O.Cells&&(l=Math.max(l,s._getDesiredRowHeight(h,u,n,c))),l+=r,h.rows[u].height=l>h.rows.defaultSize?l:null);s.cellFactory.disposeCell(n),i.removeChild(n)})},Object.defineProperty(t.prototype,"treeIndent",{get:function(){return this._indent},set:function(e){e!=this._indent&&(this._indent=i.asNumber(e,!1,!0),this.columns.onCollectionChanged())},enumerable:!0,configurable:!0}),t.prototype.collapseGroupsToLevel=function(e){var t=this;this.finishEditing()&&this.deferUpdate(function(){var i=t.rows;i.deferUpdate(function(){for(var t=0;t<i.length;t++){var o=i[t];o instanceof y&&(o.isCollapsed=o.level>=e)}})})},Object.defineProperty(t.prototype,"selectionMode",{get:function(){return this._selHdl.selectionMode},set:function(e){(e=i.asEnum(e,H))!=this.selectionMode&&(this._clearCells(),this._selHdl.selectionMode=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selection",{get:function(){return this._selHdl.selection.clone()},set:function(e){this._selHdl.selection=e},enumerable:!0,configurable:!0}),t.prototype.select=function(e,t){void 0===t&&(t=!0),this._selHdl.select(e,t)},t.prototype.getSelectedState=function(e,t){return this.cells.getSelectedState(e,t,null)},Object.defineProperty(t.prototype,"selectedRows",{get:function(){var e=[];if(this.selectionMode==H.ListBox)for(i=0;i<this.rows.length;i++)this.rows[i].isSelected&&e.push(this.rows[i]);else if(this.rows.length)for(var t=this.selection,i=t.topRow;i>-1&&i<=t.bottomRow;i++)e.push(this.rows[i]);return e},set:function(e){var t=this;i.assert(this.selectionMode==H.ListBox,"This property can be set only in ListBox mode."),e=i.asArray(e),this.deferUpdate(function(){for(var i=0,o=!0;i<t.rows.length;i++){var n=t.rows[i],r=e&&e.indexOf(n)>-1;r&&o&&(o=!1,t.select(i,t.selection.col)),n.isSelected=r}})},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"selectedItems",{get:function(){for(var e=this.selectedRows,t=0;t<e.length;t++)e[t]=e[t].dataItem;return e},set:function(e){var t=this;i.assert(this.selectionMode==H.ListBox,"This property can be set only in ListBox mode."),e=i.asArray(e),this.deferUpdate(function(){for(var i=0,o=!0;i<t.rows.length;i++){var n=t.rows[i],r=e&&e.indexOf(n.dataItem)>-1;r&&o&&(o=!1,t.select(i,t.selection.col)),n.isSelected=r}})},enumerable:!0,configurable:!0}),t.prototype.scrollIntoView=function(e,t,o){(null==this._maxOffsetY||this._rows._dirty||this._cols._dirty)&&this._updateLayout();var n=this.scrollPosition,r=this._szClient.width,s=this._szClient.height-this._gpCFtr.rows.getTotalSize(),l=this.cells._getFrozenPos();if((e=i.asInt(e))>-1&&e<this._rows.length&&e>=this._rows.frozen){var a=this._rows[e],h=this.cells.height>s?Math.round(a.pos/(this.cells.height-s)*100)/100:0,c=Math.round(this._maxOffsetY*h),u=a.pos-c,d=u+a.renderSize;d>s-n.y&&(n.y=Math.max(-u,s-d)),u-l.y<-n.y&&(n.y=-(u-l.y))}if((t=i.asInt(t))>-1&&t<this._cols.length&&t>=this._cols.frozen){var g=this._cols[t],p=g.pos+g.renderSize;p>-n.x+r&&(n.x=Math.max(-g.pos,r-p)),g.pos-l.x<-n.x&&(n.x=-(g.pos-l.x))}return!n.equals(this._ptScrl)&&(this.scrollPosition=n,o&&(this._updateScrollPosition(),this.refresh()),!0)},t.prototype.isRangeValid=function(e){return e.isValid&&e.bottomRow<this.rows.length&&e.rightCol<this.columns.length},t.prototype.startEditing=function(e,t,i,o){return void 0===e&&(e=!0),this._edtHdl.startEditing(e,t,i,o)},t.prototype.finishEditing=function(e){return this._edtHdl.finishEditing(e)},Object.defineProperty(t.prototype,"activeEditor",{get:function(){return this._edtHdl.activeEditor},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"editRange",{get:function(){return this._edtHdl.editRange},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mergeManager",{get:function(){return this._mrgMgr},set:function(e){e!=this._mrgMgr&&(this._mrgMgr=i.asType(e,z,!0),this.invalidate())},enumerable:!0,configurable:!0}),t.prototype.getMergedRange=function(e,t,i,o){return void 0===o&&(o=!0),this._mrgMgr?this._mrgMgr.getMergedRange(e,t,i,o):null},Object.defineProperty(t.prototype,"keyActionTab",{get:function(){return this._keyHdl._kaTab},set:function(e){this._keyHdl._kaTab=i.asEnum(e,D)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keyActionEnter",{get:function(){return this._keyHdl._kaEnter},set:function(e){this._keyHdl._kaEnter=i.asEnum(e,D)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showDropDown",{get:function(){return this._shDropDown},set:function(e){e!=this._shDropDown&&(this._shDropDown=i.asBoolean(e,!0),this.invalidate())},enumerable:!0,configurable:!0}),t.prototype.toggleDropDownList=function(){this._tglDropDown||(this._tglDropDown=!0,this._edtHdl._toggleListBox(null),this._tglDropDown=!1)},t.prototype.onItemsSourceChanging=function(e){return this.itemsSourceChanging.raise(this,e),!e.cancel},t.prototype.onItemsSourceChanged=function(e){this.itemsSourceChanged.raise(this,e)},t.prototype.onScrollPositionChanged=function(e){this.scrollPositionChanged.raise(this,e)},t.prototype.onSelectionChanging=function(e){return this.selectionChanging.raise(this,e),!e.cancel},t.prototype.onSelectionChanged=function(e){this.selectionChanged.raise(this,e)},t.prototype.onLoadingRows=function(e){return this.loadingRows.raise(this,e),!e.cancel},t.prototype.onLoadedRows=function(e){this.loadedRows.raise(this,e)},t.prototype.onUpdatingLayout=function(e){return this.updatingLayout.raise(this,e),!e.cancel},t.prototype.onUpdatedLayout=function(e){this.updatedLayout.raise(this,e)},t.prototype.onResizingColumn=function(e){return this.resizingColumn.raise(this,e),!e.cancel},t.prototype.onResizedColumn=function(e){this.resizedColumn.raise(this,e)},t.prototype.onAutoSizingColumn=function(e){return this.autoSizingColumn.raise(this,e),!e.cancel},t.prototype.onAutoSizedColumn=function(e){this.autoSizedColumn.raise(this,e)},t.prototype.onDraggingColumn=function(e){return this.draggingColumn.raise(this,e),!e.cancel},t.prototype.onDraggingColumnOver=function(e){return this.draggingColumnOver.raise(this,e),!e.cancel},t.prototype.onDraggedColumn=function(e){this.draggedColumn.raise(this,e)},t.prototype.onResizingRow=function(e){return this.resizingRow.raise(this,e),!e.cancel},t.prototype.onResizedRow=function(e){this.resizedRow.raise(this,e)},t.prototype.onAutoSizingRow=function(e){return this.autoSizingRow.raise(this,e),!e.cancel},t.prototype.onAutoSizedRow=function(e){this.autoSizedRow.raise(this,e)},t.prototype.onDraggingRow=function(e){return this.draggingRow.raise(this,e),!e.cancel},t.prototype.onDraggingRowOver=function(e){return this.draggingRowOver.raise(this,e),!e.cancel},t.prototype.onDraggedRow=function(e){this.draggedRow.raise(this,e)},t.prototype.onGroupCollapsedChanging=function(e){return this.groupCollapsedChanging.raise(this,e),!e.cancel},t.prototype.onGroupCollapsedChanged=function(e){this.groupCollapsedChanged.raise(this,e)},t.prototype.onSortingColumn=function(e){return this.sortingColumn.raise(this,e),!e.cancel},t.prototype.onSortedColumn=function(e){this.sortedColumn.raise(this,e)},t.prototype.onBeginningEdit=function(e){return this.beginningEdit.raise(this,e),!e.cancel},t.prototype.onPrepareCellForEdit=function(e){this.prepareCellForEdit.raise(this,e)},t.prototype.onCellEditEnding=function(e){return this.cellEditEnding.raise(this,e),!e.cancel&&!e.stayInEditMode},t.prototype.onCellEditEnded=function(e){this.cellEditEnded.raise(this,e)},t.prototype.onRowEditStarting=function(e){this.rowEditStarting.raise(this,e)},t.prototype.onRowEditStarted=function(e){this.rowEditStarted.raise(this,e)},t.prototype.onRowEditEnding=function(e){this.rowEditEnding.raise(this,e)},t.prototype.onRowEditEnded=function(e){this.rowEditEnded.raise(this,e)},t.prototype.onRowAdded=function(e){return this.rowAdded.raise(this,e),!e.cancel},t.prototype.onDeletingRow=function(e){return this.deletingRow.raise(this,e),!e.cancel},t.prototype.onDeletedRow=function(e){this.deletedRow.raise(this,e)},t.prototype.onCopying=function(e){return this.copying.raise(this,e),!e.cancel},t.prototype.onCopied=function(e){this.copied.raise(this,e)},t.prototype.onPasting=function(e){return this.pasting.raise(this,e),!e.cancel},t.prototype.onPasted=function(e){this.pasted.raise(this,e)},t.prototype.onPastingCell=function(e){return this.pastingCell.raise(this,e),!e.cancel},t.prototype.onPastedCell=function(e){this.pastedCell.raise(this,e)},t.prototype.onFormatItem=function(e){this.formatItem.raise(this,e)},t.prototype.onUpdatingView=function(e){return this.updatingView.raise(this,e),!e.cancel},t.prototype.onUpdatedView=function(e){this.updatedView.raise(this,e)},t.prototype._getShowErrors=function(){return this.showErrors&&this._hasValidation},t.prototype._getHasValidation=function(){return this._hasValidation},t.prototype._getError=function(e,t,o){if(i.isFunction(this.itemValidator)){if(e==this.cells)return this.itemValidator(t,o);if(e==this.rowHeaders)for(o=0;o<this.columns.length;o++)if(c=this.itemValidator(t,o))return c}var n=this._cv,r=n?n.getError:null;if(i.isFunction(r)){var s=e.rows,l=this.columns,a=s[t].dataItem;if(a)for(;t<s.length&&s[t].dataItem==a;t++){if(e==this.cells)return r(a,(h=this._getBindingColumn(this.cells,t,l[o])).binding);if(e==this.rowHeaders)for(o=0;o<l.length;o++){var h=this._getBindingColumn(this.cells,t,l[o]),c=r(a,h.binding);if(c)return c}}}return null},t.prototype._setAria=function(e,t){i.setAttribute(this.cells.hostElement,"aria-"+e,t)},t.prototype._setFocus=function(e){if(this.hostElement&&(e||!this.containsFocus())){var t=i.getActiveElement(),o=this.activeEditor,n=this._activeCell,r=this._eFocus;o?i.contains(o,t)||(o.focus(),r.tabIndex=-1):n?i.contains(n,t)||t!=this._root&&(n.tabIndex=this._orgTabIndex,n.focus(),r.tabIndex=-1):i.contains(r,t)||t==this._root||(r.tabIndex=this._orgTabIndex,r.focus()),this.containsFocus()||(r.tabIndex=this._orgTabIndex,r.focus())}},t.prototype._setFocusNoScroll=function(e){if(e.tabIndex=this._orgTabIndex,i.supportsFocusOptions())e.focus({preventScroll:!0});else{var t=this.scrollPosition,o=e.style,n=o.position,r=o.opacity;o.opacity="0",o.position="fixed",e.focus(),o.position=n,o.opacity=r,this.scrollPosition=t}this._fixScroll()},t.prototype._getDefaultRowHeight=function(){var e=this._eFocus,t=null;e.offsetHeight||((t=i.createElement('<div><div class="wj-cell">0</div></div>',document.body)).setAttribute("class",this.hostElement.getAttribute("class")),e=t.children[0]);var o=e.offsetHeight;return(isNaN(o)||o<=6)&&(o=28),i.removeChild(t),o},t.prototype._getDefaultCellPadding=function(){var e=getComputedStyle(this._eFocus);return parseInt(this.rightToLeft?e.paddingRight:e.paddingLeft)},t.prototype._getCollectionView=function(e){return i.asCollectionView(e)},t.prototype._getCanvasContext=function(){var e=document.createElement("canvas").getContext("2d"),t=getComputedStyle(this.hostElement);return e.font=t.fontSize+" "+t.fontFamily.split(",")[0],e},t.prototype._getWidestRow=function(e,t,o,n){for(var r=0,s=0,l=e.columns[o].dataType==i.DataType.Boolean,a=t.row;a<=t.row2;a++)if(e.rows[a].isVisible){var h=e.getCellData(a,o,!0),c=n.measureText(h).width;if(c>s&&(s=c,r=a),l)break}return r},t.prototype._getDesiredWidth=function(e,t,i,o){var n=this.getMergedRange(e,t,i,!1),r=o.style;return this.cellFactory.updateCell(e,t,i,o,n),r.width=r.top=r.left="",o.offsetWidth/(n&&n.columnSpan>1?n.columnSpan:1)},t.prototype._getDesiredHeight=function(e,t,i,o){var n=this.getMergedRange(e,t,i,!1),r=o.style;return this.cellFactory.updateCell(e,t,i,o,n),r.height=r.top=r.left="",o.offsetHeight/(n&&n.rowSpan>1?n.rowSpan:1)},t.prototype._getDesiredRowHeight=function(e,t,o,n){for(var r=0,s=0;s<e.columns.length;s++){var l=e.columns[s];if(l.isVisible){var a=this.getMergedRange(e,t,s,!1),h=void 0;if(this._getQuickAutoSize()){var c={ct:e.cellType,col:s,rng:a&&a.rowSpan>1?a.rowSpan:1,content:l.dataType==i.DataType.Number?"1":e.getCellData(t,s,!0)},u=JSON.stringify(c);null==(h=n[u])&&(h=this._getDesiredHeight(e,t,s,o),n[u]=h)}else h=this._getDesiredHeight(e,t,s,o);r=Math.max(r,h)}}return r},t.prototype._getSortRowIndex=function(){return null!=this._sortRowIndex?this._sortRowIndex:this.columnHeaders.rows.length-1},t.prototype._sortConverter=function(e,t,i,o){var n;if(o){if(this._mappedColumns=null,this._cv)for(var r=this._cv.sortDescriptions,s=0;s<r.length;s++)(n=this.getColumn(r[s].property))&&n.dataMap&&(this._mappedColumns||(this._mappedColumns={}),this._mappedColumns[n.binding]=n.dataMap);this._mouseHdl._htDown&&this._mouseHdl._htDown.col>-1&&(n=this.columns[this._mouseHdl._htDown.col],this._mappedColumns&&n.dataMap&&(this._mappedColumns[n.binding]=n.dataMap))}if(this._mappedColumns){var l=this._mappedColumns[e.property];l&&l.sortByDisplayValues&&(i=l.getDisplayValue(i))}return i},t.prototype._bindGrid=function(e){var t=this;if(this.finishEditing(),this.deferUpdate(function(){0==t._lastCount&&i.hasItems(t._cv)&&(e=!0);var o,n=t.selectionMode==H.ListBox;t.preserveSelectedState&&n&&!t.childItemsPath&&(o=t.selectedItems);var r;if(t.preserveOutlineState&&i.isFunction(window.Map)&&t.rows.maxGroupLevel>-1){r=new Map;for(u=0;u<t.rows.length;u++){var s=t.rows[u];if(s instanceof y&&s.isCollapsed&&s.dataItem){var l=s.dataItem;l instanceof i.CollectionViewGroup&&(l=l._path),r.set(l,!0)}}}e&&t.columns.deferUpdate(function(){t._bindColumns()});var a=new i.CancelEventArgs;t.onLoadingRows(a)&&(t.rows.deferUpdate(function(){t._bindRows()}),t.onLoadedRows(a));var h=0;if(o&&o.length)for(u=0;u<t.rows.length&&h<o.length;u++)o.indexOf(t.rows[u].dataItem)>-1&&(t.rows[u].isSelected=!0,h++);if(n&&0==h&&t._lastCount>0)for(var c=t.selection,u=c.topRow;u<=c.bottomRow&&u>-1&&u<t.rows.length;u++)t.rows[u].isSelected=!0;r&&t.rows.deferUpdate(function(){for(var e=0;e<t.rows.length;e++){var o=t.rows[e];if(o instanceof y){var n=o.dataItem;n instanceof i.CollectionViewGroup&&(n=n._path),r.get(n)&&(o.isCollapsed=!0)}}}),!t._lastCount&&t._cv&&t._cv.items&&(t._lastCount=t._cv.items.length)}),!this.rows.length){var o=this._selHdl.selection;o.row=o.row2=-1}this._cv&&setTimeout(function(){t._syncSelection(e)})},t.prototype._cvCollectionChanged=function(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{var o=i.NotifyCollectionChangedAction;if(this.childItemsPath&&t.action!=o.Change)this._bindGrid(!1);else{switch(t.action){case o.Change:return void this.invalidate();case o.Add:if(t.index==this._cv.items.length-1){var n=this.rows.length;return this.rows[n-1]instanceof k&&n--,void this.rows.insert(n,new v(t.item))}i.assert(!1,"added item should be the last one.");break;case o.Remove:var r=this._findRow(t.item);if(r>-1)return this.rows.removeAt(r),void this._syncSelection(!1);i.assert(!1,"removed item not found on grid.")}this._bindGrid(!1)}}},t.prototype._cvCurrentChanged=function(e,t){this._syncSelection(!1)},t.prototype._syncSelection=function(e){if(this._cv&&this.selectionMode!=H.None){var t=this.selection,o=t.row>-1&&t.row<this.rows.length?this.rows[t.row]:null,n=o?o.dataItem:null;if(this.newRowAtTop&&o instanceof k&&(n=null),n instanceof i.CollectionViewGroup&&(n=null),(n!=this._cv.currentItem||e)&&(!this.childItemsPath||!this.editableCollectionView||!this.editableCollectionView.currentAddItem)){var r=this._getRowIndex(this._cv.currentPosition);r==t.row&&this.childItemsPath||(t.row=t.row2=r,this.select(t,!1),this.selectionMode&&this.scrollIntoView(t.row,-1))}}},t.prototype._getRowIndex=function(e){if(this._cv){if(e>-1){for(var t=this._cv.items[e];e<this.rows.length;e++)if(this.rows[e].dataItem===t)return e;return-1}if(1==this.rows.length&&this.rows[0]instanceof k)return 0;var i=this.selection.row,o=i>-1?this.rows[i]:null;return o&&(o instanceof y||null==o.dataItem)?i:-1}return this.selection.row},t.prototype._getCvIndex=function(e){if(this._cv&&e>-1&&e<this.rows.length){var t=this._cv.items,i=this.rows[e].dataItem;for(e=Math.min(e,t.length-1);e>-1;e--)if(t[e]===i)return e}return-1},t.prototype._findRow=function(e){for(var t=0;t<this.rows.length;t++)if(this.rows[t].dataItem==e)return t;return-1},t.prototype._updateLayout=function(){var e=new i.CancelEventArgs;if(this.onUpdatingLayout(e)){var o=this._hdrVis&l.Row?this._hdrCols.getTotalSize():0,n=this._hdrVis&l.Column?this._hdrRows.getTotalSize():0,r=this._ftrRows.getTotalSize(),s=this._rows.getTotalSize()+r;s<1&&(s=1),this._heightBrowser=Math.min(s,t._getMaxSupportedCssHeight()),this._maxOffsetY=Math.max(0,s-this._heightBrowser),this._cellPadding=this._getDefaultCellPadding();var a=this._heightBrowser+n-r,h=this._gpCells.width,c=this._heightBrowser;!h&&this.rows.length&&(h=.1),!c&&this.columns.length&&(c=.1),this.rightToLeft?(i.setCss(this._eTL,{right:0,top:0,width:o,height:n}),i.setCss(this._eCHdr,{right:o,top:0,height:n}),i.setCss(this._eRHdr,{right:0,top:n,width:o}),i.setCss(this._eCt,{right:o,top:n,width:h,height:c}),i.setCss(this._fCt,{right:o,top:n}),i.setCss(this._eBL,{right:0,top:a,width:o,height:r}),i.setCss(this._eCFtr,{right:o,top:a,height:r})):(i.setCss(this._eTL,{left:0,top:0,width:o,height:n}),i.setCss(this._eCHdr,{left:o,top:0,height:n}),i.setCss(this._eRHdr,{left:0,top:n,width:o}),i.setCss(this._eCt,{left:o,top:n,width:h,height:c}),i.setCss(this._fCt,{left:o,top:n}),i.setCss(this._eBL,{left:0,top:a,width:o,height:r}),i.setCss(this._eCFtr,{left:o,top:a,height:r})),this._stickyHdr&&this._updateStickyHeaders();var u=this.frozenRows||this.frozenColumns?"3":"";i.setCss([this._eTL,this._eBL,this._eCHdr,this._eCFtr,this._eRHdr,this._eMarquee],{zIndex:u});var d=this._root,g=d.offsetWidth-d.clientWidth,p=d.offsetHeight-d.clientHeight;i.setCss(this._eSz,{width:o+g+this._gpCells.width,height:n+p+this._heightBrowser});var f=null;this.columns._updateStarSizes(d.clientWidth-o)&&(f=d.clientWidth,i.setCss(this._eCt,{width:this._gpCells.width})),this._szClient=new i.Size(d.clientWidth-o,d.clientHeight-n),this._rcBounds=null,this._updateScrollHandler(),this._updateContent(!1),g=d.offsetWidth-d.clientWidth,p=d.offsetHeight-d.clientHeight,i.setCss(this._eSz,{width:o+g+this._gpCells.width,height:n+p+this._heightBrowser}),this._szClient=new i.Size(d.clientWidth-o,d.clientHeight-n),f&&f!=d.clientWidth&&this.columns._updateStarSizes(d.clientWidth-o)&&(i.setCss(this._eCt,{width:this._gpCells.width}),this._updateContent(!1)),i.setCss([this._eCHdr,this._eCFtr,this._fCt],{width:this._szClient.width}),i.setCss([this._eRHdr,this._fCt],{height:this._szClient.height}),r&&(a=Math.min(a,this._szClient.height+n-r),i.setCss([this._eBL,this._eCFtr],{top:a})),this.onUpdatedLayout(e)}},t.prototype._updateStickyHeaders=function(){var e=!1,o=0;if(this._stickyHdr){for(var n=0,r=null,s=this.hostElement;s;s=s.parentElement){var l=s.getBoundingClientRect();null==r&&(r=l.top),n=Math.max(n,l.top)}o=-(r=Math.max(0,n-r-1)),e=r>0,this._rcBounds=null}this._eTL.style.top=this._eCHdr.style.top=e?-o+"px":"",i.toggleClass(this._eTL,t._WJS_STICKY,e),i.toggleClass(this._eCHdr,t._WJS_STICKY,e)},t.prototype._updateScrollHandler=function(){this._clipToScreen=this._getClipToScreen();var e=this._stickyHdr||this._clipToScreen;e!=this._scrollHandlerAttached&&(this._scrollHandlerAttached=e,e?this.addEventListener(window,"scroll",this._scroll.bind(this),!0):this.removeEventListener(window,"scroll"))},t.prototype._getClipToScreen=function(){if(this.rows.length<=t._MIN_VIRT_ROWS)return!1;if(this._root.clientHeight!=this._root.scrollHeight)return!1;for(var e=this.hostElement;e&&e!=document.documentElement;e=e.parentElement)if("auto"==getComputedStyle(e).overflow)return!1;return!0},t.prototype._scroll=function(e){var t=this;i.contains(e.target,this.hostElement)&&(this._clipToScreen&&(this._afScrl&&cancelAnimationFrame(this._afScrl),this._afScrl=requestAnimationFrame(function(){t._afScrl=null,t.finishEditing(),t._updateContent(!0)})),this._stickyHdr&&(this._afSticky&&cancelAnimationFrame(this._afSticky),this._afSticky=requestAnimationFrame(function(){t._afSticky=null;var e=new i.CancelEventArgs;t.onUpdatingLayout(e)&&(t._updateStickyHeaders(),t.onUpdatedLayout(e))})))},t.prototype._updateScrollPosition=function(){var e=this._root,o=e.scrollTop,n=e.scrollLeft;this.rightToLeft&&"rev"==t._getRtlMode()&&(n=e.scrollWidth-e.clientWidth-n);var r=new i.Point(-Math.abs(n),-o);return!this._ptScrl.equals(r)&&(this._ptScrl=r,this.onScrollPositionChanged(),!0)},t.prototype._updateContent=function(e,t){var o=this._root,n=this.hostElement,r=this.cells.hostElement,s=i.getActiveElement(),a=i.contains(n,s)?s:null,h=this._activeCell,c=new i.CancelEventArgs;if(this.onUpdatingView(c)){if(i.setAttribute(r,"role",this.rows.maxGroupLevel<0?"grid":"treegrid"),this._hasValidation=i.isFunction(this._itemValidator)||this._cv&&i.isFunction(this._cv.getError),this._offsetY=0,this._heightBrowser>this._szClient.height){var u=Math.round(-this._ptScrl.y/(this._heightBrowser-this._szClient.height)*100)/100;this._offsetY=Math.round(this._maxOffsetY*u)}this._updateScrollPosition();var d=this._gpCells._updateContent(e,t,this._offsetY);if(this._hdrVis&l.Column&&(!t||this._ssHdr&l.Column)&&this._gpCHdr._updateContent(e,t,0),this._hdrVis&l.Row&&(!t||this._ssHdr&l.Row)&&this._gpRHdr._updateContent(e,t,this._offsetY),this._hdrVis&&!t&&this._gpTL._updateContent(e,t,0),this._gpCFtr.rows.length&&(this._gpBL._updateContent(e,t,0),this._gpCFtr._updateContent(e,t,0)),this.showMarquee){var g=this._selHdl.selection,p=this._eMarquee;if(this.isRangeValid(g)){var f=this._getMarqueeRect(g),_=p.firstChild,w=p.offsetWidth-_.offsetWidth,m=p.offsetHeight-_.offsetHeight;i.setCss(p,{left:f.left+r.offsetLeft-w/2,top:f.top+r.offsetTop-m/2,width:f.width+w,height:f.height+m,visibility:f.width>0&&f.height>0?"":"collapse"})}else i.setCss(p,{left:0,top:0,width:0,height:0,visibility:"collapse"})}if(this._useFrozenDiv()&&(this._updateFrozenCells(t),d&&i.hasClass(d,"wj-frozen")&&(d=null)),this._fCt.style.display=this._fCt.childElementCount?"":"none",this._activeCell=d,a)if(a!=o&&a!=this._eFocus&&i.contains(n,a)&&!i.contains(r,a)){if(i.getActiveElement()!=a&&a.focus(),i.isIE()&&a instanceof HTMLInputElement&&!a.type.match(/checkbox|radio|range/i)){var v=a.selectionStart,y=a.selectionEnd;a.setSelectionRange(v,y)}}else{var C=d!=h;this._setFocus(C)}!a&&d&&(d.tabIndex=this._orgTabIndex),h&&h!=d&&(h.tabIndex=-1),this._fixScroll(),this._rcBounds=null,this.onUpdatedView(c)}},t.prototype._fixScroll=function(){if(!this._updating){var e=this.hostElement,t=this._root?this._root.parentElement:null;e&&e.scrollTop&&(e.scrollTop=0),t&&t.scrollTop&&(t.scrollTop=0)}},t.prototype._clearCells=function(){for(var e in this)if("_"==e[0]){var t=this[e];t instanceof g&&t._clearCells()}this.invalidate()},t.prototype._useFrozenDiv=function(){return i.isBoolean(this._fzClone)?this._fzClone:i.isIE()||i.isFirefox()||i.isSafari()||i.isMobile()},t.prototype._updateFrozenCells=function(e){var t=this._fCt;if(this.frozenRows||this.frozenColumns){var o=this._eCt.querySelectorAll(".wj-frozen");if(e&&t.children.length==o.length){for(n=0;n<o.length;n++)t.children[n].className=o[n].className;return}if(i.setText(t,null),!this.activeEditor)for(var n=0;n<o.length;n++){var r=o[n];i.closest(r,".wj-flexgrid")==this.hostElement&&(r=o[n].cloneNode(!0),t.appendChild(r))}}else i.setText(t,null)},t.prototype._getMarqueeRect=function(e){var t=this.getMergedRange(this.cells,e.topRow,e.leftCol)||new f(e.topRow,e.leftCol),o=this.getMergedRange(this.cells,e.bottomRow,e.rightCol)||new f(e.bottomRow,e.rightCol),n=this.cells.getCellBoundingRect(t.topRow,t.leftCol,!0),r=this.cells.getCellBoundingRect(o.bottomRow,o.rightCol,!0);if(this.rows.frozen){var s=Math.min(this.rows.length,this.rows.frozen),l=this.cells.getCellBoundingRect(s-1,0,!0);e.topRow>=s&&n.top<l.bottom&&(n.top=l.bottom),e.bottomRow>=s&&r.bottom<l.bottom&&(r.height=l.bottom-r.top)}if(this.columns.frozen){var a=Math.min(this.columns.length,this.columns.frozen),l=this.cells.getCellBoundingRect(0,a-1,!0);this.rightToLeft?(e.leftCol>=a&&n.right>l.left&&(n.left=l.left-n.width),e.rightCol>=a&&r.left>l.left&&(r.left=l.left)):(e.leftCol>=a&&n.left<l.right&&(n.left=l.right),e.rightCol>=a&&r.right<l.right&&(r.width=l.right-r.left))}return this.rightToLeft?new i.Rect(r.left,n.top,n.right-r.left,r.bottom-n.top):new i.Rect(n.left,n.top,r.right-n.left,r.bottom-n.top)},t.prototype._bindColumns=function(){for(var e=0;e<this.columns.length;e++)(a=this.columns[e])._getFlag(_.AutoGenerated)&&(this.columns.removeAt(e),e--);var t=this._cv,o=t?t.sourceCollection:null,n=o&&o.length?o[0]:null;if(n&&this.autoGenerateColumns)for(var r in n)for(var s=null,l=0;l<o.length&&l<1e3&&null==s;l++)if(s=o[l][r],i.isPrimitive(s)){var a=new m;a._setFlag(_.AutoGenerated,!0),a.binding=a.name=r,a.header=i.toHeaderCase(r),a.dataType=i.getType(s),a.dataType==i.DataType.Number&&(a.width=80);var h=Object.getOwnPropertyDescriptor(n,r);!h||h.writable||i.isFunction(h.set)||a._setFlag(_.ReadOnly,!0),this.columns.push(a)}this._updateColumnTypes()},t.prototype._updateColumnTypes=function(){var e=this._cv;if(i.hasItems(e))for(var t=e.items[0],o=this.columns,n=0;n<o.length;n++){var r=o[n];null==r.dataType&&r._binding&&(r.dataType=i.getType(r._binding.getValue(t)))}},t.prototype._getBindingColumn=function(e,t,i){return i},t.prototype._getRowHeaderPath=function(){return this._rowHdrPath},t.prototype._bindRows=function(){this.rows.clear();var e=this._cv;if(e&&e.items){var t=e.items,i=e.groups;if(this.childItemsPath)for(o=0;o<t.length;o++)this._addNode(t,o,0);else if(null!=i&&i.length>0&&this.showGroups)for(o=0;o<i.length;o++)this._addGroup(i[o]);else for(var o=0;o<t.length;o++)this._addBoundRow(t,o)}},t.prototype._addBoundRow=function(e,t){this.rows.push(new v(e[t]))},t.prototype._addNode=function(e,t,o){var n=new y,r=this.childItemsPath,s=i.isArray(r)?r[o]:r,l=e[t],a=l[s];if(n.dataItem=l,n.level=o,this.rows.push(n),i.isArray(a))for(var h=0;h<a.length;h++)this._addNode(a,h,o+1)},t.prototype._addGroup=function(e){var t=new y;if(t.level=e.level,t.dataItem=e,this.rows.push(t),e.isBottomLevel)for(var i=e.items,o=0;o<i.length;o++)this._addBoundRow(i,o);else for(o=0;o<e.groups.length;o++)this._addGroup(e.groups[o])},t._getSerializableProperties=function(e){var t=[];for(e=e.prototype;e!=Object.prototype;e=Object.getPrototypeOf(e))for(var i=Object.getOwnPropertyNames(e),o=0;o<i.length;o++){var n=i[o],r=Object.getOwnPropertyDescriptor(e,n);r&&r.set&&r.get&&"_"!=n[0]&&!n.match(/disabled|required/)&&t.push(n)}return t},t.prototype._copy=function(e,t){if("columns"==e){this.columns.clear();for(var o=i.asArray(t),n=0;n<o.length;n++){var r=new m;i.copy(r,o[n]),this.columns.push(r)}return!0}return!1},t.prototype._isInputElement=function(e){if(e instanceof HTMLElement&&!i.hasClass(e,"wj-btn-glyph")){if("true"==e.contentEditable)return!0;var t=e.tagName.match(/^(BUTTON|A|INPUT|TEXTAREA|SELECT|OPTION)$/i);return t&&t.length>0}return!1},t.prototype._wantsInput=function(e){return this._isInputElement(e)&&!this.activeEditor&&!this._edtHdl._isNativeCheckbox(e)&&!i.hasClass(e,"wj-grid-ime")&&i.contains(document.body,e)},t._getMaxSupportedCssHeight=function(){if(!t._maxCssHeight){var e=335e5;i.isIE()?e=15e5:i.isFirefox()&&(e=175e5),t._maxCssHeight=e}return t._maxCssHeight},t._getRtlMode=function(){if(!t._rtlMode){var e=i.createElement('<div dir="rtl" style="visibility:hidden;width:100px;height:100px;overflow:auto"><div style="width:2000px;height:2000px"></div></div>');document.body.appendChild(e);var o=e.scrollLeft;e.scrollLeft=-1e3;var n=e.scrollLeft;i.removeChild(e),t._rtlMode=n<0?"neg":o>0?"rev":"std"}return t._rtlMode},t._WJS_STICKY="wj-state-sticky",t._WJS_MEASURE="wj-state-measuring",t._WJS_UPDATING="wj-state-updating",t._MIN_VIRT_ROWS=200,t.controlTemplate='<div style="position:relative;width:100%;height:100%;overflow:hidden;max-width:inherit;max-height:inherit"><div wj-part="root" style="position:absolute;width:100%;height:100%;overflow:auto;max-width:inherit;max-height:inherit;-webkit-overflow-scrolling:touch;"><div wj-part="cells" class="wj-cells" style="position:absolute"></div><div wj-part="marquee" class="wj-marquee" style="display:none;pointer-events:none;"><div style="width:100%;height:100%"></div></div></div><div wj-part="fcells" aria-hidden="true" class="wj-cells wj-frozen-clone" style="position:absolute;pointer-events:none;overflow:hidden"></div><div wj-part="rh"><div wj-part="rhcells" class="wj-rowheaders"></div></div><div wj-part="cf"><div wj-part="cfcells" class="wj-colfooters"></div></div><div wj-part="ch"><div wj-part="chcells" class="wj-colheaders"></div></div><div wj-part="bl"><div wj-part="blcells" class="wj-bottomleft"></div></div><div wj-part="tl"><div wj-part="tlcells" class="wj-topleft"></div></div><div wj-part="focus" class="wj-cell" style="position:fixed;left:-32000px">0</div><div wj-part="sz" style="position:relative;visibility:hidden"></div></div>',t}(i.Control);t.FlexGrid=a;var h=function(e){function t(t,o,n){var r=e.call(this)||this;return r._p=i.asType(t,g,!0),r._rng=i.asType(o,f,!0),r._data=n,r}return __extends(t,e),Object.defineProperty(t.prototype,"panel",{get:function(){return this._p},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"range",{get:function(){return this._rng.clone()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"row",{get:function(){return this._rng.row},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"col",{get:function(){return this._rng.col},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"data",{get:function(){return this._data},set:function(e){this._data=e},enumerable:!0,configurable:!0}),t}(i.CancelEventArgs);t.CellRangeEventArgs=h;var c=function(e){function t(t,o,n){var r=e.call(this,t,o)||this;return r._cell=i.asType(n,HTMLElement),r}return __extends(t,e),Object.defineProperty(t.prototype,"cell",{get:function(){return this._cell},enumerable:!0,configurable:!0}),t}(h);t.FormatItemEventArgs=c;var u=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._stayInEditMode=!1,t._refresh=!0,t}return __extends(t,e),Object.defineProperty(t.prototype,"stayInEditMode",{get:function(){return this._stayInEditMode},set:function(e){this._stayInEditMode=i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"refresh",{get:function(){return this._refresh},set:function(e){this._refresh=i.asBoolean(e)},enumerable:!0,configurable:!0}),t}(h);t.CellEditEndingEventArgs=u;var d;!function(e){e[e.None=0]="None",e[e.Cell=1]="Cell",e[e.ColumnHeader=2]="ColumnHeader",e[e.RowHeader=3]="RowHeader",e[e.TopLeft=4]="TopLeft",e[e.ColumnFooter=5]="ColumnFooter",e[e.BottomLeft=6]="BottomLeft"}(d=t.CellType||(t.CellType={}));var g=function(){function e(e,t,o,n,r){this._offsetY=0,this._g=i.asType(e,a),this._ct=i.asInt(t),this._rows=i.asType(o,R),this._cols=i.asType(n,b),this._e=i.asType(r,HTMLElement),this._vrb=new f}return Object.defineProperty(e.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cellType",{get:function(){return this._ct},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewRange",{get:function(){return this._getViewRange()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._cols.getTotalSize()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._rows.getTotalSize()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rows",{get:function(){return this._rows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columns",{get:function(){return this._cols},enumerable:!0,configurable:!0}),e.prototype.getCellData=function(e,t,o){var n,r=this._rows[i.asNumber(e,!1,!0)],s=null;if(i.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";n=this._cols[i.asNumber(t,!1,!0)];var l=this._g?this._g._getBindingColumn(this,e,n):n;if(!l.binding||!r.dataItem||r.dataItem instanceof i.CollectionViewGroup?r._ubv&&(s=r._ubv[n._hash]):s=l._binding.getValue(r.dataItem),null==s)switch(this._ct){case d.ColumnHeader:e!=this._rows.length-1&&l==n||(s=l.header);break;case d.ColumnFooter:if(l.aggregate!=i.Aggregate.None&&r instanceof y){var a=this._g.collectionView;if(a){var h=i.tryCast(a,i.CollectionView);s=h?h.getAggregate(l.aggregate,l.binding):i.getAggregate(l.aggregate,a.items,l.binding)}}break;case d.Cell:if(l.aggregate!=i.Aggregate.None&&r instanceof y){var c=i.tryCast(r.dataItem,i.CollectionViewGroup);c&&(s=c.getAggregate(l.aggregate,l.binding,this._g.collectionView))}}return o&&(this.cellType==d.Cell&&l.dataMap&&(s=l.dataMap.getDisplayValue(s)),s=null!=s?i.Globalize.format(s,l.format):""),s},e.prototype.setCellData=function(e,t,o,n,r){void 0===n&&(n=!0),void 0===r&&(r=!0);var s,l=this._rows[i.asNumber(e,!1,!0)];if(i.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";s=this._cols[i.asNumber(t,!1,!0)];var a=this._g?this._g._getBindingColumn(this,e,s):s;if(this._ct==d.Cell){if(a.dataMap&&null!=o&&(a.isRequired||""!=o)){var h=a.dataMap,c=h.getKeyValue(o);if(null==c&&null==h.getDisplayValue(null)){if(h.getDisplayValue(o)!=o);else if(!h.isEditable||h.displayMemberPath!=h.selectedValuePath)return!1}else o=c}var u=i.DataType.Object;if(a.dataType)u=a.dataType;else{var g=this.getCellData(e,t,!1);u=i.getType(g)}if(i.isBoolean(a.isRequired))if(a.isRequired||""!==o&&null!==o){if(a.isRequired&&(""===o||null===o))return!1}else o=null,n=!1;if(n&&(o=i.changeType(o,u,a.format),u!=i.DataType.Object&&i.getType(o)!=u))return!1}if(l.dataItem&&a.binding){var p=a._binding,f=l.dataItem,_=p.getValue(f);if(o!==_&&!i.DateTime.equals(o,_)){p.setValue(f,o);var w=this._g.collectionView;if(w instanceof i.CollectionView&&f!=w.currentEditItem){var m=new i.NotifyCollectionChangedEventArgs(i.NotifyCollectionChangedAction.Change,f,w.items.indexOf(f));w.onCollectionChanged(m)}}}else l._ubv||(l._ubv={}),l._ubv[s._hash]=o;return r&&this._g&&this._g.invalidate(),!0},e.prototype.getCellBoundingRect=function(e,t,o){var n=this.rows[e],r=this.columns[t],s=new i.Rect(r.pos,n.pos,r.renderSize,n.renderSize);if(this._g.rightToLeft&&(s.left=this.hostElement.clientWidth-s.right,!i.isIE()&&!i.isFirefox())){var l=this.hostElement.parentElement;s.left-=l.offsetWidth-l.clientWidth}if(!o){var a=this.hostElement.getBoundingClientRect();s.left+=a.left,s.top+=a.top-this._offsetY}return e<this.rows.frozen&&(s.top-=this._g.scrollPosition.y),t<this.columns.frozen&&(s.left-=this._g.scrollPosition.x*(this._g.rightToLeft?-1:1)),s},e.prototype.getCellElement=function(t,i){for(var o=this.hostElement.children,n=Math.min(t+2,o.length),r=0;r<n;r++)for(var s=o[r].children,l=Math.min(i+2,s.length),a=0;a<l;a++){var h=s[a],c=h[e._INDEX_KEY];if(c&&(c.row==t&&c.col==i||c.rng&&c.rng.contains(t,i)))return h}return null},e.prototype.getSelectedState=function(e,t,i){var o=this._g,n=o.selectionMode,r=o._selHdl.selection,s=H,a=P;if(n!=s.None)switch(this._ct){case d.Cell:if(i||(i=o.getMergedRange(this,e,t)),i){if(i.contains(r.row,r.col))return o.showMarquee?a.None:a.Cursor;if(i.intersects(r))return a.Selected}if(r.row==e&&r.col==t)return o.showMarquee?a.Active:a.Cursor;if(o.rows[e].isSelected||o.columns[t].isSelected)return a.Selected;if(i)switch(n){case s.Row:case s.RowRange:case s.ListBox:if(i.containsRow(r.row))return a.Selected}return r=o._selHdl._adjustSelection(r),n==H.ListBox?a.None:r.containsRow(e)&&r.containsColumn(t)?a.Selected:a.None;case d.ColumnHeader:if(o.showSelectedHeaders&l.Column&&(o.columns[t].isSelected||r.containsColumn(t)||r.intersectsColumn(i))&&(i&&(e=i.bottomRow),e==this.rows.length-1))return a.Selected;break;case d.RowHeader:if(o.showSelectedHeaders&l.Row&&(o.rows[e].isSelected||r.containsRow(e)||r.intersectsRow(i))&&(i&&(t=i.rightCol),t==this.columns.length-1))return a.Selected}return a.None},Object.defineProperty(e.prototype,"hostElement",{get:function(){return this._e},enumerable:!0,configurable:!0}),e.prototype._getOffsetY=function(){return this._offsetY},e.prototype._updateContent=function(e,t,i){var o=this._g,n=this._e,r=this._rows,s=this._cols,l=this._ct;if(l==d.ColumnHeader||l==d.ColumnFooter||l==d.RowHeader){var a=o._ptScrl,h=n.style;l==d.RowHeader?h.top=a.y+"px":o.rightToLeft?h.right=a.x+"px":h.left=a.x+"px"}this._offsetY!=i&&(e=!1,this._offsetY=i);var c=this._getViewRange(),u=c;if(u.isValid){var g=o.isTouching,p=r.length<=o._vtRows?1e7:g?6:0,_=s.length<=o._vtCols?1e7:g?1:0;u=new f(Math.max(c.row-p,r.frozen),Math.max(c.col-_,s.frozen),Math.min(c.row2+p,r.length-1),Math.min(c.col2+_,s.length-1))}if(e&&!t&&this._vrb.contains(c)&&!r.frozen&&!s.frozen)return this._activeCell;e&&u.equals(this._vrb)||(t=!1),e&&!t&&this._ct!=d.TopLeft&&this._reorderCells(u,this._vrb),this._activeCell=null,this._vru=c,this._vrb=u,this._cf=o.cellFactory;var w=0;this._ct==d.Cell&&(w=this._renderColHdrRow(u,t));for(m=0;m<r.frozen&&m<r.length;m++)w=this._renderRow(m,u,t,w);for(var m=u.topRow;m<=u.bottomRow&&m>-1;m++)w=this._renderRow(m,u,t,w);for(;n.childElementCount>w;){var v=n.lastElementChild;n.removeChild(v),this._removeExtraCells(v,0)}return this._activeCell},e.prototype._updateScrollPosition=function(){var e=this._g,t=e._ptScrl,i=this.hostElement.style;this.cellType==d.RowHeader?i.top=t.y+"px":e.rightToLeft?i.right=t.x+"px":i.left=t.x+"px"},e.prototype._clearCells=function(){for(var e=this.hostElement,t=e.childElementCount-1;t>=0;t--){var i=e.children[t];e.removeChild(i);for(var o=i.childElementCount-1;o>=0;o--)this._cf.disposeCell(i.children[o])}},e.prototype._reorderCells=function(e,t){if(!(this._rows.frozen>0||this._cols.frozen>0||e.columnSpan!=t.columnSpan||e.rowSpan!=t.rowSpan)&&t.isValid&&e.isValid&&e.intersects(t)&&e.row!=t.row){var i=e.row-t.row,o=Math.max(1,e.rowSpan-1),n=this._e;if(0!=i&&Math.abs(i)<o){var r=this._ct==d.Cell?1:0,s=n.childElementCount;if(i>0){var l=r,a=Math.min(r+i,s-1);(h=this._createRange(l,a))&&a<s-1&&n.appendChild(h.extractContents())}if(i<0){var a=s,l=Math.max(r,a+i),h=this._createRange(l,a);if(h&&l>r){var c=n.children[r];n.insertBefore(h.extractContents(),c)}}}}},e.prototype._createRange=function(e,t){var i,o=this._e.childElementCount;return t>e&&t<=o&&e>-1&&((i=document.createRange()).setStart(this._e,e),i.setEnd(this._e,t)),i},e.prototype._renderColHdrRow=function(e,t){var o=this._e.children[0];o||(o=i.createElement('<div class="wj-row" role="row"></div>',this._e));var n=this._g,r=n?n.columnHeaders.rows.ariaLabel:null;i.setAttribute(o,"aria-label",r),i.setAttribute(o,"aria-selected",null);var s=0,l=this._g._getRowHeaderPath();l&&(s=this._renderRowHdrCell(o,-1,l.path));for(a=0;a<this.columns.frozen&&a<this.columns.length;a++)s=this._renderColHdrCell(o,a,e,t,s);for(var a=e.leftCol;a<=e.rightCol&&a>-1;a++)s=this._renderColHdrCell(o,a,e,t,s);return this._removeExtraCells(o,s),1},e.prototype._renderColHdrCell=function(t,o,n,r,s){var l=this.columns[o];if(l.renderSize<=0)return s;if(r)return s+1;var a=t.children[s];a||(a=i.createElement('<div class="wj-cell" tabindex="-1"></div>',t)),i.setAttribute(a,"role","columnheader"),a.textContent=this.columns[o].header,i.setCss(a,{position:"fixed",top:-32e3,height:.1,left:l.pos,width:l.renderWidth,overflow:"hidden",opacity:"0",pointerEvents:"none"});var h=[l.describedById,this.columns.describedById].join(" ").trim();i.setAttribute(a,"aria-describedby",h||null);var c=this.grid;if(c.allowSorting){var u="none";switch(c._getBindingColumn(this,0,l).currentSort){case"+":u="ascending";break;case"-":u="descending"}i.setAttribute(a,"aria-sort",u)}return c.isReadOnly||(i.setAttribute(a,"aria-readonly",l.isReadOnly),i.setAttribute(a,"aria-required",l.getIsRequired())),a[e._INDEX_KEY]={row:-1,col:o,panel:this},s+1},e.prototype._renderRowHdrCell=function(t,o,n){var r=t.children[0];return r||(r=i.createElement('<div class="wj-cell" tabindex="-1"></div>',t)),r.setAttribute("role",o<0?"columnheader":"rowheader"),r.textContent=n?n.toString():"",i.setCss(r,{position:"fixed",left:-32e3,top:-32e3,width:.1,height:.1,overflow:"hidden",opacity:"0"}),r[e._INDEX_KEY]={row:o,col:-1,panel:this},1},e.prototype._renderRow=function(e,t,o,n){var r=this._g,s=this.rows[e];if(s.renderSize<=0)return n;var l=this._e.children[n];if(l||(l=i.createElement('<div class="wj-row"></div>',this._e)),this._ct==d.Cell){l.setAttribute("role","row");var a=H;switch(r.selectionMode){case a.Row:case a.RowRange:case a.ListBox:var h=s.isSelected||this._g._selHdl.selection.containsRow(e);i.setAttribute(l,"aria-selected",!!h)}i.setAttribute(l,"aria-level",s instanceof y?s.level+1:null),i.setAttribute(l,"aria-expanded",s instanceof y?!s.isCollapsed:null),this.rows.ariaLabel&&i.setAttribute(l,"aria-label",this.rows.ariaLabel)}var c=0;if(this._ct==d.Cell){var u=this._g._getRowHeaderPath();u&&(c=this._renderRowHdrCell(l,e,u.getValue(s.dataItem)))}for(g=0;g<this.columns.frozen&&g<this.columns.length;g++)c=this._renderCell(l,e,g,t,o,c);for(var g=t.leftCol;g<=t.rightCol&&g>-1;g++)c=this._renderCell(l,e,g,t,o,c);return this._removeExtraCells(l,c),n+1},e.prototype._renderCell=function(t,o,n,r,s,l){var a=this._g,h=a.getMergedRange(this,o,n);if(h){for(c=Math.max(r.row,h.row);c<o;c++)if(this.rows[c].isVisible)return l;for(var c=Math.max(r.col,h.col);c<n;c++)if(this.columns[c].isVisible)return l}var u=this.columns[n];if(u.renderSize<=0&&(!h||h.getRenderSize(this).width<=0))return l;var g=t.children[l],p=P,f=this.getSelectedState(o,n,h),_=f==p.Cursor||f==p.Active;return g&&s?(i.toggleClass(g,"wj-state-active",_),i.toggleClass(g,"wj-state-selected",f==p.Cursor),i.toggleClass(g,"wj-state-multi-selected",f==p.Selected),i.setAttribute(g,"aria-selected",f!=p.None||_),_&&(this._activeCell=g),l+1):(g||((g=document.createElement("div")).tabIndex=-1,t.appendChild(g)),_&&(this._activeCell=g),this._ct==d.Cell&&(i.setAttribute(g,"role","gridcell"),i.setAttribute(g,"aria-selected",f!=p.None||_),i.setAttribute(g,"aria-readonly",!a.canEditCell(o,n)||null),i.setAttribute(g,"aria-required",u.getIsRequired())),a.cellFactory.updateCell(this,o,n,g,h),g[e._INDEX_KEY]={row:o,col:n,rng:h,panel:this},l+1)},e.prototype._removeExtraCells=function(e,t){for(;e.childElementCount>t;){var i=e.lastElementChild;e.removeChild(i),this._cf.disposeCell(i)}},e.prototype._getViewRange=function(){var e=this._g,t=e._ptScrl,i=this._rows,o=this._cols,n=new f(0,0,i.length-1,o.length-1);if(this._ct==d.Cell||this._ct==d.RowHeader){var r=-t.y+this._offsetY,s=e._szClient.height;if((c=Math.min(i.frozen,i.length-1))>0&&(r+=u=i[c-1].pos,s-=u),n.row=Math.min(i.length-1,Math.max(i.frozen,i.getItemAt(r+1))),n.row2=i.getItemAt(r+s),e._clipToScreen){var l=e.hostElement.getBoundingClientRect();l.top<0&&(n.row=Math.max(n.row,i.getItemAt(-l.top-e._ptScrl.y)-1)),l.bottom>innerHeight&&(n.row2=Math.min(n.row2,i.getItemAt(-l.top-e._ptScrl.y+innerHeight)+1))}}if(this._ct==d.Cell||this._ct==d.ColumnHeader){var a=-t.x,h=e._szClient.width,c=Math.min(o.frozen,o.length-1);if(c>0){var u=o[c-1].pos;a+=u,h-=u}n.col=Math.min(o.length-1,Math.max(o.frozen,o.getItemAt(a+1))),n.col2=o.getItemAt(a+h)}return i.length<=i.frozen&&(n.row=n.row2=-1),o.length<=o.frozen&&(n.col=n.col2=-1),n},e.prototype._getFrozenPos=function(){var e=this._rows.frozen,t=this._cols.frozen,o=e>0?this._rows[e-1]:null,n=t>0?this._cols[t-1]:null,r=o?o.pos+o.renderSize:0,s=n?n.pos+n.renderSize:0;return new i.Point(s,r)},e._INDEX_KEY="wj-cell-index",e}();t.GridPanel=g;var p=function(){function e(){}return e.prototype.updateCell=function(t,o,r,s,l,a){var h=t.grid,u=h.rightToLeft,g=d,p=t.rows,_=t.columns,w=p[o],m=_[r],v=o,C=r,b=w instanceof y?w:null,R=w instanceof k?w:null,S=m.renderWidth,E=w.renderHeight,z=t.cellType,x="wj-cell",H="",T={display:""};if(0!=a&&s.firstElementChild&&(1==s.childNodes.length&&"checkbox"==s.firstElementChild.type||(s.textContent="")),l&&!l.isSingleCell){o=l.row,r=l.col,v=l.row2,C=l.col2,w=p[o],m=_[r],b=w instanceof y?w:null;var M=l.getRenderSize(t);E=M.height,S=M.width}var D=h._getBindingColumn(t,o,m),j=D.dataType==i.DataType.Boolean&&!D.dataMap,L=m.pos,O=w.pos;if(h._useFrozenDiv()&&z==g.Cell&&!h.editRange?(o<p.frozen&&r>=_.frozen&&(L+=h._ptScrl.x),r<_.frozen&&o>=p.frozen&&(O+=h._ptScrl.y)):(o<p.frozen&&(O-=h._ptScrl.y),r<_.frozen&&(L-=h._ptScrl.x)),u?T.right=L+"px":T.left=L+"px",T.top=O-t._getOffsetY()+"px",T.width=S+"px",T.height=E+"px",T.zIndex="",(o<p.frozen||r<_.frozen)&&(T.zIndex=o<p.frozen&&r<_.frozen?2:1),z==g.Cell?(b&&(x+=" wj-group"),h.showAlternatingRows&&w.visibleIndex%2!=0&&(l&&l.row!=l.row2||(x+=" wj-alt")),(o<p.frozen||r<_.frozen)&&(x+=" wj-frozen"),R&&(x+=" wj-new"),w.cssClass&&(x+=" "+w.cssClass),D.cssClass&&(x+=" "+D.cssClass)):(x+=" wj-header",h.showAlternatingRows&&o%2!=0&&(x+=" wj-header-alt")),(z==g.Cell||z==g.RowHeader)&&h._getShowErrors()){var A=h._getError(t,o,r);i.setAttribute(s,"title",A),A&&(x+=" wj-state-invalid")}var B=P,N=t.getSelectedState(o,r,l);switch(N!=B.None&&z==g.Cell&&!j&&h.editRange&&h.editRange.contains(o,r)&&(N=B.None),N){case B.Active:x+=" wj-state-active";break;case B.Cursor:x+=" wj-state-selected wj-state-active";break;case B.Selected:x+=" wj-state-multi-selected"}switch(v==p.frozen-1&&(x+=" wj-frozen-row"),C==_.frozen-1&&(x+=" wj-frozen-col"),(D.wordWrap||w.wordWrap)&&(x+=" wj-wrap"),(D.multiLine||w.multiLine)&&(x+=" wj-multiline"),D.getAlignment()){case"right":H=" wj-align-right";break;case"center":H=" wj-align-center";break;case"justify":H=" wj-align-justify"}if(T.paddingLeft=T.paddingRight=T.paddingTop=T.paddingBottom="",z==g.Cell&&h.rows.maxGroupLevel>-1&&r==h.columns.firstVisibleIndex&&h.treeIndent){var F=b?Math.max(0,b.level):h.rows.maxGroupLevel+1,V=h.treeIndent*F+h._cellPadding;u?T.paddingRight=V+"px":T.paddingLeft=V+"px"}if(0!=a){var K=t.getCellData(o,r,!1),W=t.getCellData(o,r,!0);if(z==g.Cell&&r==h.columns.firstVisibleIndex&&b&&b.hasChildren&&!this._isEditingCell(h,o,r)){te=this._getTreeBtn(b);W=i.escapeHtml(W)||b.getGroupHeader(),s.innerHTML=te.outerHTML+" "+W,H=""}else if(z==g.ColumnHeader&&D.currentSort&&h.showSort&&(v==h._getSortRowIndex()||D!=m))x+=" wj-sort-"+("+"==D.currentSort?"asc":"desc"),s.innerHTML=i.escapeHtml(W)+"&nbsp;"+this._getSortIcon(D);else if(z!=g.RowHeader||r!=h.rowHeaders.columns.length-1||W)if(z!=g.Cell||D.dataType!=i.DataType.Boolean||D.dataMap||b&&!i.isBoolean(K))if(z==g.Cell&&this._isEditingCell(h,o,r)){var G=D.inputType;if(D.inputType||(G=D.dataType!=i.DataType.Number||D.dataMap?"text":"tel"),!D.dataMap&&!D.mask){var q=t.getCellData(o,r,!1);if(i.isNumber(q)){var U=q.toString(),Y=D.format;if(Y&&q!=Math.round(q)){var J=U.match(/\.(\d+)/)[1].length;Y=Y.replace(/([a-z])(\d*)(.*)/gi,"$01"+J+"$3")}W=i.Globalize.formatNumber(q,Y,!0)}}s.innerHTML=(D.multiLine||w.multiLine)&&"checkbox"!=G?'<textarea wrap="soft"></textarea>':'<input type="'+G+'"/>';var X=s.children[0];i.addClass(X,"wj-grid-editor wj-form-control"),i.disableAutoComplete(X),X.value=W,X.required=D.getIsRequired(),i.setAttribute(X,"aria-required",X.required),D.maxLength&&(X.maxLength=D.maxLength),X.style.textAlign=D.getAlignment(),D.mask&&new i._MaskProvider(X,D.mask),h._edtHdl._edt=X}else z==g.Cell&&(w.isContentHtml||D.isContentHtml)?s.innerHTML=W:s.textContent=W||"";else{var Z=s.firstChild;Z instanceof HTMLInputElement&&"checkbox"==Z.type||(s.innerHTML='<input type="checkbox" class="wj-cell-check" tabindex="-1"/>',Z=s.firstChild),Z.checked=1==K,Z.indeterminate=null==K,Z.disabled=!h.canEditCell(o,r),Z.disabled&&(Z.style.cursor="default"),h.editRange&&h.editRange.contains(o,r)&&(h._edtHdl._edt=Z)}else{var Q=h.editableCollectionView,$=Q?Q.currentEditItem:null;$&&w.dataItem==$?s.innerHTML='<span class="wj-glyph-pencil"></span>':w instanceof k&&(s.innerHTML='<span class="wj-glyph-asterisk"></span>')}if(z==g.Cell&&n()&&D.dataMap&&h.showDropDown&&0!=D.showDropDown&&h.canEditCell(o,r)){if(!e._ddBtn){var ee=e._WJC_DROPDOWN,te=i.createElement('<button class="wj-btn wj-btn-glyph wj-right '+ee+'" type="button" tabindex="-1"><span class="wj-glyph-down"></span></button>');i.setAriaLabel(te,i.culture.FlexGrid.ariaLabels.toggleDropDown),i.setAttribute(te,"aria-expanded",!1),e._ddBtn=te}var ie=e._ddBtn.cloneNode(!0);s.appendChild(ie)}}var oe=!1;switch(z){case g.RowHeader:oe=!b&&!R&&w.allowDragging&&0!=(h.allowDragging&I.Rows),i.setAttribute(s,"draggable",oe?"true":null);break;case g.ColumnHeader:oe=m.allowDragging&&0!=(h.allowDragging&I.Columns),i.setAttribute(s,"draggable",oe?"true":null)}x+=H,s.className!=x&&(s.className=x);var ne=s.style;for(var re in T)ne[re]!==T[re]&&(ne[re]=T[re]);if(h._edtHdl._edt&&h._edtHdl._edt.parentElement==s){var se=h._root,le=se.getBoundingClientRect(),ae=s.getBoundingClientRect(),he=le.top+se.clientHeight-ae.top,ce=le.left+se.clientWidth-ae.left;ae.height>he&&(s.style.height=he+"px"),ae.width>ce&&(s.style.width=ce+"px")}if(h.itemFormatter&&h.itemFormatter(t,o,r,s),h.formatItem.hasHandlers){var ue=e._fmtRng;ue?ue.setRange(o,r,v,C):ue=e._fmtRng=new f(o,r,v,C);var de=new c(t,ue,s);h.onFormatItem(de)}},e.prototype.disposeCell=function(e){},e.prototype.getEditorValue=function(e){var t=e._edtHdl._edt;if(t instanceof HTMLInputElement&&"checkbox"==t.type)return t.checked;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){var o=t.maxLength;return i.isNumber(o)&&o>-1&&t.value.length>o?t.value.substr(0,o):t.value}return null},e.prototype._isEditingCell=function(e,t,i){return e.editRange&&e.editRange.contains(t,i)},e.prototype._getTreeBtn=function(t){var o=e._WJC_COLLAPSE,n=(t.isCollapsed?"":"down-")+(t.grid.rightToLeft?"left":"right"),r=i.createElement('<button class="wj-btn wj-btn-glyph '+o+'" type="button" tabindex="-1"><span class="wj-glyph-'+n+'"></span></button>');return i.setAriaLabel(r,i.culture.FlexGrid.ariaLabels.toggleGroup),i.setAttribute(r,"aria-expanded",!t.isCollapsed),r},e.prototype._getSortIcon=function(e){return'<span class="wj-glyph-'+("+"==e.currentSort?"up":"down")+'"></span>'},e._WJC_COLLAPSE="wj-elem-collapse",e._WJC_DROPDOWN="wj-elem-dropdown",e}();t.CellFactory=p;var f=function(){function e(e,t,i,o){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===i&&(i=e),void 0===o&&(o=t),this.setRange(e,t,i,o)}return e.prototype.setRange=function(e,t,o,n){void 0===e&&(e=-1),void 0===t&&(t=-1),void 0===o&&(o=e),void 0===n&&(n=t),this._row=i.asInt(e),this._col=i.asInt(t),this._row2=i.asInt(o),this._col2=i.asInt(n)},Object.defineProperty(e.prototype,"row",{get:function(){return this._row},set:function(e){this._row=i.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col",{get:function(){return this._col},set:function(e){this._col=i.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"row2",{get:function(){return this._row2},set:function(e){this._row2=i.asInt(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col2",{get:function(){return this._col2},set:function(e){this._col2=i.asInt(e)},enumerable:!0,configurable:!0}),e.prototype.clone=function(){return new e(this._row,this._col,this._row2,this._col2)},Object.defineProperty(e.prototype,"rowSpan",{get:function(){return Math.abs(this._row2-this._row)+1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"columnSpan",{get:function(){return Math.abs(this._col2-this._col)+1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topRow",{get:function(){return Math.min(this._row,this._row2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomRow",{get:function(){return Math.max(this._row,this._row2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftCol",{get:function(){return Math.min(this._col,this._col2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightCol",{get:function(){return Math.max(this._col,this._col2)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isValid",{get:function(){return this._row>-1&&this._col>-1&&this._row2>-1&&this._col2>-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSingleCell",{get:function(){return this._row==this._row2&&this._col==this._col2},enumerable:!0,configurable:!0}),e.prototype.contains=function(t,o){var n=i.tryCast(t,e);if(n)return n.topRow>=this.topRow&&n.bottomRow<=this.bottomRow&&n.leftCol>=this.leftCol&&n.rightCol<=this.rightCol;if(i.isInt(t)&&i.isInt(o))return t>=this.topRow&&t<=this.bottomRow&&o>=this.leftCol&&o<=this.rightCol;throw"contains expects a CellRange or row/column indices."},e.prototype.containsRow=function(e){return i.asInt(e)>=this.topRow&&e<=this.bottomRow},e.prototype.containsColumn=function(e){return i.asInt(e)>=this.leftCol&&e<=this.rightCol},e.prototype.intersects=function(e){return this.intersectsRow(e)&&this.intersectsColumn(e)},e.prototype.intersectsRow=function(e){return e&&!(this.bottomRow<e.topRow||this.topRow>e.bottomRow)},e.prototype.intersectsColumn=function(e){return e&&!(this.rightCol<e.leftCol||this.leftCol>e.rightCol)},e.prototype.getRenderSize=function(e){var t=new i.Size(0,0);if(this.isValid){for(var o=this.topRow;o<=this.bottomRow;o++)t.height+=e.rows[o].renderSize;for(var n=this.leftCol;n<=this.rightCol;n++)t.width+=e.columns[n].renderSize}return t},e.prototype.equals=function(t){return t instanceof e&&this._row==t._row&&this._col==t._col&&this._row2==t._row2&&this._col2==t._col2},e}();t.CellRange=f;var _;!function(e){e[e.Visible=1]="Visible",e[e.AllowResizing=2]="AllowResizing",e[e.AllowDragging=4]="AllowDragging",e[e.AllowMerging=8]="AllowMerging",e[e.AllowSorting=16]="AllowSorting",e[e.AutoGenerated=32]="AutoGenerated",e[e.Collapsed=64]="Collapsed",e[e.ParentCollapsed=128]="ParentCollapsed",e[e.Selected=256]="Selected",e[e.ReadOnly=512]="ReadOnly",e[e.HtmlContent=1024]="HtmlContent",e[e.WordWrap=2048]="WordWrap",e[e.MultiLine=4096]="MultiLine",e[e.HasTemplate=8192]="HasTemplate",e[e.RowDefault=3]="RowDefault",e[e.ColumnDefault=23]="ColumnDefault"}(_=t.RowColFlags||(t.RowColFlags={}));var w=function(){function e(){this._list=null,this._pos=0,this._idx=-1,this._vidx=-1}return Object.defineProperty(e.prototype,"visible",{get:function(){return this._getFlag(_.Visible)},set:function(e){this._setFlag(_.Visible,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisible",{get:function(){return!!this._getFlag(_.Visible)&&(!this._getFlag(_.ParentCollapsed)||this instanceof k)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pos",{get:function(){return this._list&&this._list._dirty&&this._list._update(),this._pos},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"index",{get:function(){return this._list&&this._list._dirty&&this._list._update(),this._idx},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visibleIndex",{get:function(){return this._list&&this._list._dirty&&this._list._update(),this.isVisible?this._vidx:-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this._sz},set:function(e){e!=this._sz&&(this._sz=i.asNumber(e,!0),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderSize",{get:function(){if(!this.isVisible)return 0;var e=this._sz,t=this._list;return t&&((null==e||e<0)&&(e=Math.round(t.defaultSize)),null!=t.minSize&&e<t.minSize&&(e=t.minSize),null!=t.maxSize&&e>t.maxSize&&(e=t.maxSize)),null!=this._szMin&&e<this._szMin&&(e=this._szMin),null!=this._szMax&&e>this._szMax&&(e=this._szMax),Math.round(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowResizing",{get:function(){return this._getFlag(_.AllowResizing)},set:function(e){this._setFlag(_.AllowResizing,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowDragging",{get:function(){return this._getFlag(_.AllowDragging)},set:function(e){this._setFlag(_.AllowDragging,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"allowMerging",{get:function(){return this._getFlag(_.AllowMerging)},set:function(e){this._setFlag(_.AllowMerging,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSelected",{get:function(){return this._getFlag(_.Selected)},set:function(e){if(this._setFlag(_.Selected,e,!0)){var t=this.grid;t&&t.refreshCells(!1,!0,!0)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isReadOnly",{get:function(){return this._getFlag(_.ReadOnly)},set:function(e){this._setFlag(_.ReadOnly,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isContentHtml",{get:function(){return this._getFlag(_.HtmlContent)},set:function(e){this.isContentHtml!=e&&(this._setFlag(_.HtmlContent,e),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wordWrap",{get:function(){return this._getFlag(_.WordWrap)},set:function(e){this._setFlag(_.WordWrap,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"multiLine",{get:function(){return this._getFlag(_.MultiLine)},set:function(e){this._setFlag(_.MultiLine,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cssClass",{get:function(){return this._cssClass},set:function(e){e!=this._cssClass&&(this._cssClass=i.asString(e),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){return this._list?this._list._g:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"collectionView",{get:function(){return this.grid?this.grid.collectionView:null},enumerable:!0,configurable:!0}),e.prototype.onPropertyChanged=function(){this._list&&(this._list._dirty=!0,this.grid.invalidate())},e.prototype._getFlag=function(e){return 0!=(this._f&e)},e.prototype._setFlag=function(e,t,i){return t!=this._getFlag(e)&&(this._f=t?this._f|e:this._f&~e,i||this.onPropertyChanged(),!0)},e}();t.RowCol=w;var m=function(e){function t(o){var n=e.call(this)||this;return n._f=_.ColumnDefault,n._hash=t._ctr.toString(36),t._ctr++,o&&i.copy(n,o),n}return __extends(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataType",{get:function(){return this._type},set:function(e){e=i.asEnum(e,i.DataType),this._type!=e&&(this._type=e,this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRequired",{get:function(){return this._required},set:function(e){this._required=i.asBoolean(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showDropDown",{get:function(){return this._showDropDown},set:function(e){e!=this._showDropDown&&(this._showDropDown=i.asBoolean(e,!0),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dropDownCssClass",{get:function(){return this._ddCssClass},set:function(e){this._ddCssClass=i.asString(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"inputType",{get:function(){return this._inpType},set:function(e){this._inpType=i.asString(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask=i.asString(e,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxLength",{get:function(){return this._maxLen},set:function(e){this._maxLen=i.asNumber(e,!0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"binding",{get:function(){return this._binding?this._binding.path:null},set:function(e){if(e!=this.binding){var t=i.asString(e);if(this._binding=t?new i.Binding(t):null,!this._type&&this.grid&&this._binding){var o=this.grid.collectionView;if(o&&o.sourceCollection&&o.sourceCollection.length){var n=o.sourceCollection[0];this._type=i.getType(this._binding.getValue(n))}}this.onPropertyChanged()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sortMemberPath",{get:function(){return this._bindingSort?this._bindingSort.path:null},set:function(e){if(e!=this.sortMemberPath){var t=i.asString(e);this._bindingSort=t?new i.Binding(t):null,this.onPropertyChanged()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return null!=this._szStar?this._szStar:this.size},set:function(e){null!=t._parseStarSize(e)?(this._szStar=e,this.onPropertyChanged()):(this._szStar=null,this.size=i.asNumber(e,!0))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minWidth",{get:function(){return this._szMin},set:function(e){e!=this._szMin&&(this._szMin=i.asNumber(e,!0,!0),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxWidth",{get:function(){return this._szMax},set:function(e){e!=this._szMax&&(this._szMax=i.asNumber(e,!0,!0),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quickAutoSize",{get:function(){return this._quickSize},set:function(e){this._quickSize=i.asBoolean(e,!0)},enumerable:!0,configurable:!0}),t.prototype._getQuickAutoSize=function(){return!!this.grid._getQuickAutoSize()&&(i.isBoolean(this._quickSize)?this._quickSize:!(this.isContentHtml||this.wordWrap||this.multiLine||this._getFlag(_.HasTemplate)))},Object.defineProperty(t.prototype,"renderWidth",{get:function(){return this.renderSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"align",{get:function(){return this._align},set:function(e){this._align!=e&&(this._align=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),t.prototype.getAlignment=function(){var e=this._align;if(null==e&&(e="",!this._map))switch(this._type){case i.DataType.Boolean:e="center";break;case i.DataType.Number:e="right"}return e},t.prototype.getIsRequired=function(){return null!=this._required?this._required:this.dataType!=i.DataType.String||(null!=this.dataMap||null!=this._mask&&this._mask.length>0)},Object.defineProperty(t.prototype,"header",{get:function(){return this._hdr?this._hdr:this.binding},set:function(e){this._hdr!=e&&(this._hdr=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataMap",{get:function(){return this._map},set:function(e){this._map!=e&&(this._map&&this._map.mapChanged.removeHandler(this.onPropertyChanged,this),i.isArray(e)&&(e=new x(e,null,null)),this._map=i.asType(e,x,!0),this._map&&this._map.mapChanged.addHandler(this.onPropertyChanged,this),this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"format",{get:function(){return this._fmt},set:function(e){this._fmt!=e&&(this._fmt=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"allowSorting",{get:function(){return this._getFlag(_.AllowSorting)},set:function(e){this._setFlag(_.AllowSorting,e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentSort",{get:function(){var e=this.grid?this.grid.collectionView:null,t=e?e.sortDescriptions:null,i=t&&t.length?this._getBindingSort():null;if(i)for(var o=0;o<t.length;o++)if(t[o].property==i)return t[o].ascending?"+":"-";return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aggregate",{get:function(){return null!=this._agg?this._agg:i.Aggregate.None},set:function(e){(e=i.asEnum(e,i.Aggregate))!=this._agg&&(this._agg=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"describedById",{get:function(){return this._descById},set:function(e){e!=this._descById&&(this._descById=i.asString(e),this.grid&&this.grid.invalidate())},enumerable:!0,configurable:!0}),t.prototype._getBindingSort=function(){return this.sortMemberPath?this.sortMemberPath:this.binding?this.binding:null},t._parseStarSize=function(e){if(i.isString(e)&&e.length>0&&"*"==e[e.length-1]){var t=1==e.length?1:1*e.substr(0,e.length-1);if(t>0&&!isNaN(t))return t}return null},t._ctr=0,t}(w);t.Column=m;var v=function(e){function t(t){var i=e.call(this)||this;return i._f=_.ColumnDefault,i._data=t,i}return __extends(t,e),Object.defineProperty(t.prototype,"dataItem",{get:function(){return this._data},set:function(e){this._data=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this.size},set:function(e){this.size=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderHeight",{get:function(){return this.renderSize},enumerable:!0,configurable:!0}),t}(w);t.Row=v;var y=function(e){function t(){var t=e.call(this)||this;return t._level=-1,t.isReadOnly=!0,t}return __extends(t,e),Object.defineProperty(t.prototype,"level",{get:function(){return this._level},set:function(e){i.asInt(e),e!=this._level&&(this._level=e,this.onPropertyChanged())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasChildren",{get:function(){if(null!=this.grid&&null!=this._list){this._list._update();var e=this.index<this._list.length-1?this._list[this.index+1]:null,o=i.tryCast(e,t),n=i.tryCast(e,k);return null!=e&&null==n&&(null==o||o.level>this.level)}return!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isCollapsed",{get:function(){return this._getFlag(_.Collapsed)},set:function(e){i.asBoolean(e),e!=this.isCollapsed&&null!=this._list&&this._setCollapsed(e)},enumerable:!0,configurable:!0}),t.prototype.getGroupHeader=function(){var e=this.grid,t=e.groupHeaderFormat||i.culture.FlexGrid.groupHeaderFormat,o=i.tryCast(this.dataItem,i.CollectionViewGroup);if(o&&t){var n=o.groupDescription.propertyName,r=o.name,s=e.getColumn(n),l=this.isContentHtml;s&&(l=l||s.isContentHtml,s.header&&(n=s.header),s.dataMap?r=s.dataMap.getDisplayValue(r):s.format&&(r=i.Globalize.format(r,s.format)));var a=o.getAggregate(i.Aggregate.CntAll,null,e.collectionView);return i.format(t,{name:i.escapeHtml(n),value:l?r:i.escapeHtml(r),level:o.level,count:a})}return""},t.prototype._setCollapsed=function(e){var i=this,o=this.grid,n=o.rows,r=this.getCellRange(),s=new h(o.cells,new f(this.index,-1));o.onGroupCollapsedChanging(s)&&(o.deferUpdate(function(){n.deferUpdate(function(){i._setFlag(_.Collapsed,e,!0);for(var o=r.topRow+1;o<=r.bottomRow&&o>-1&&o<n.length;o++){n[o]._setFlag(_.ParentCollapsed,e,!0);var s=n[o];s instanceof t&&s.isCollapsed&&(o=s.getCellRange().bottomRow)}})}),o.onGroupCollapsedChanged(s))},t.prototype.getCellRange=function(){for(var e=this._list,o=this.index,n=e.length-1,r=o+1;r<=n;r++){var s=i.tryCast(e[r],t);if(null!=s&&s.level<=this.level){n=r-1;break}}return new f(o,0,n,this.grid.columns.length-1)},t}(v);t.GroupRow=y;var C=function(e){function t(t,o){var n=e.call(this)||this;return n._frozen=0,n._vlen=0,n._szDef=28,n._szTot=0,n._szCustom=!1,n._dirty=!1,n._g=i.asType(t,a),n._szDef=i.asNumber(o,!1,!0),n}return __extends(t,e),Object.defineProperty(t.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultSize",{get:function(){return this._szDef},set:function(e){this._szCustom=!0,this._szDef!=e&&(this._szDef=i.asNumber(e,!1,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frozen",{get:function(){return this._frozen},set:function(e){e!=this._frozen&&(this._frozen=i.asNumber(e,!1,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),t.prototype.isFrozen=function(e){return e<this.frozen},Object.defineProperty(t.prototype,"minSize",{get:function(){return this._szMin},set:function(e){e!=this._szMin&&(this._szMin=i.asNumber(e,!0,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxSize",{get:function(){return this._szMax},set:function(e){e!=this._szMax&&(this._szMax=i.asNumber(e,!0,!0),this._dirty=!0,this._g.invalidate())},enumerable:!0,configurable:!0}),t.prototype.getTotalSize=function(){return this._dirty&&this._update(),this._szTot},Object.defineProperty(t.prototype,"visibleLength",{get:function(){return this._dirty&&this._update(),this._vlen},enumerable:!0,configurable:!0}),t.prototype.getItemAt=function(e){if(this._dirty&&this._update(),e<=0&&this.length>0&&this[0].renderSize)return 0;e=Math.round(e);for(var t,i,o=this.length,n=0,r=o-1;n<=r;)if(t=n+r>>>1,(i=this[t])._pos>e&&t>0)r=t-1;else{if(!(i._pos+i.renderSize<=e&&t<o-1)){for(;t>0&&!this[t].renderSize;)t--;for(;t<o-1&&!this[t].renderSize;)t++;return t}n=t+1}return r},t.prototype.getNextCell=function(e,t,i){var o,n=T;switch(t){case n.Next:for(o=e+1;o<this.length;o++)if(this[o].renderSize>0)return o;break;case n.Prev:for(o=e-1;o>=0;o--)if(this[o].renderSize>0)return o;break;case n.End:for(o=this.length-1;o>=0;o--)if(this[o].renderSize>0)return o;break;case n.Home:for(o=0;o<this.length;o++)if(this[o].renderSize>0)return o;break;case n.NextPage:return(o=this.getItemAt(this[e].pos+i))<0?this.getNextCell(e,T.End,i):o==e&&o<this.length-1&&this[o+1].renderSize?o+1:o;case n.PrevPage:return(o=this.getItemAt(this[e].pos-i))<0?this.getNextCell(e,T.Home,i):o==e&&o>0&&this[o-1].renderSize?o-1:o}return e},t.prototype.canMoveElement=function(e,t){if(t==e)return!1;if(e<0||e>=this.length||t>=this.length)return!1;t<0&&(t=this.length-1);for(var i=Math.min(e,t),o=Math.max(e,t),n=i;n<=o;n++)if(!this[n].allowDragging)return!1;return!(this[t]instanceof k)},t.prototype.moveElement=function(e,t){if(this.canMoveElement(e,t)){var i=this[e];this.removeAt(e),t<0&&(t=this.length),this.insert(t,i)}},t.prototype.onCollectionChanged=function(t){void 0===t&&(t=i.NotifyCollectionChangedEventArgs.reset),this._dirty=!0,this._g.invalidate(),e.prototype.onCollectionChanged.call(this,t)},t.prototype.push=function(t){return t._list=this,e.prototype.push.call(this,t)},t.prototype.splice=function(t,i,o){return o&&(o._list=this),e.prototype.splice.call(this,t,i,o)},t.prototype.beginUpdate=function(){this._update(),e.prototype.beginUpdate.call(this)},t.prototype._setDefaultSize=function(e){this._szCustom||(this.defaultSize=e,this._szCustom=!1)},t.prototype._update=function(){if(this._dirty&&!this.isUpdating){this._dirty=!1;for(var e=0,t=0,i=void 0,o=void 0,n=0;n<this.length;n++)(o=this[n])._idx=n,o._vidx=e,o._list=this,o._pos=t,(i=o.renderSize)>0&&(t+=i,e++);return this._vlen=e,this._szTot=t,!0}return!1},t}(i.ObservableArray);t.RowColCollection=C;var b=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._firstVisible=-1,t}return __extends(t,e),t.prototype.getColumn=function(e){var t=i.isNumber(e)?e:this.indexOf(e);return t>-1?this[t]:null},t.prototype.indexOf=function(t){if(t instanceof m)return e.prototype.indexOf.call(this,t);for(i=0;i<this.length;i++)if(this[i].name==t)return i;for(var i=0;i<this.length;i++)if(this[i].binding==t)return i;return-1},Object.defineProperty(t.prototype,"describedById",{get:function(){return this._descById},set:function(e){e!=this._descById&&(this._descById=i.asString(e),this._g&&this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"firstVisibleIndex",{get:function(){return this._dirty&&this._update(),this._firstVisible},enumerable:!0,configurable:!0}),t.prototype._update=function(){if(e.prototype._update.call(this)){this._firstVisible=-1;for(var t=0;t<this.length;t++)if(this[t].visible){this._firstVisible=t;break}return!0}return!1},t.prototype._updateStarSizes=function(e){for(var t,i=0,o=0;o<this.length;o++)(r=this[o]).isVisible&&(r._szStar?(i+=m._parseStarSize(r._szStar),t=r):e-=r.renderWidth);if(t){for(var n=e,o=0;o<this.length;o++){var r=this[o];r.isVisible&&r._szStar&&(r==t&&n>0?r._sz=n:(r._sz=Math.max(0,Math.round(m._parseStarSize(r._szStar)/i*e)),n-=r.renderWidth))}return this._dirty=!0,this._update(),!0}return!1},t}(C);t.ColumnCollection=b;var R=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._maxLevel=-1,t}return __extends(t,e),Object.defineProperty(t.prototype,"ariaLabel",{get:function(){return this._ariaLabel},set:function(e){e!=this.ariaLabel&&(this._ariaLabel=i.asString(e),this._g&&this._g.refresh())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxGroupLevel",{get:function(){return this._dirty&&this._update(),this._maxLevel},enumerable:!0,configurable:!0}),t.prototype._update=function(){if(e.prototype._update.call(this)){this._maxLevel=-1;for(var t=0;t<this.length;t++){var o=i.tryCast(this[t],y);o&&o.level>this._maxLevel&&(this._maxLevel=o.level)}return!0}return!1},t}(C);t.RowCollection=R;var S=function(){function e(t,o){this._row=-1,this._col=-1,this._edge=0;var n;if(o instanceof Element){if(i.closest(o,".wj-flexgrid")!=t.hostElement)return;t=o}if(!(t instanceof Element)||t instanceof a){if(t instanceof a)n=this._g=t;else{if(!(t instanceof g))throw"First parameter should be a FlexGrid or GridPanel.";this._p=t,n=this._g=this._p.grid}var r;o instanceof MouseEvent&&(r=o,"mousedown"==o.type&&(n._rcBounds=null)),o=i.mouseToPage(o),this._pt=o.clone();var s=n.controlRect,h=n._szClient,c=n.topLeftCells,u=n._eTL,p=n.headersVisibility,f=l,_=p&f.Row?c.columns.getTotalSize():0,w=p&f.Column?c.rows.getTotalSize():0,m=p&f.Column?w+u.offsetTop:0,v=n._eBL,y=v.offsetHeight;if(o.x-=s.left,o.y-=s.top,this._g.rightToLeft&&(o.x=s.width-o.x),!this._p&&o.x>=0&&o.y>=u.offsetTop&&h&&o.x<=h.width+_&&o.y<=h.height+m&&(o.y<m?this._p=o.x<_?n.topLeftCells:n.columnHeaders:o.y<v.offsetTop?this._p=o.x<_?n.rowHeaders:n.cells:this._p=o.x<_?n.bottomLeftCells:n.columnFooters),null!=this._p){var C=this._p.rows,b=this._p.columns,R=this._p.cellType,S=d,E=this._p._getFrozenPos(),z=R==S.TopLeft||R==S.ColumnHeader?w:R==S.BottomLeft||R==S.ColumnFooter?y:C.getTotalSize(),x=R==S.TopLeft||R==S.BottomLeft||R==S.RowHeader?_:b.getTotalSize();R==S.RowHeader||R==S.Cell?(o.y-=w,(o.y>E.y||E.y<=0)&&(o.y-=n._ptScrl.y,o.y+=this._p._getOffsetY())):R!=S.BottomLeft&&R!=S.ColumnFooter||(o.y-=v.offsetTop),R!=S.ColumnHeader&&R!=S.Cell&&R!=S.ColumnFooter||(o.x-=_,(o.x>E.x||E.x<=0)&&(o.x-=n._ptScrl.x)),R!=S.ColumnHeader&&R!=S.TopLeft||(o.y-=m-w),this._edge=0;var H=e._SZEDGE[this._g.isTouching?1:0];if(this._g.isTouching&&(H=e._SZEDGE[1],o.x-=H/2),this._row=o.y>z?-1:C.getItemAt(o.y),this._col=o.x>x?-1:b.getItemAt(o.x),this._row<0||this._col<0)return void(this._p=null);if(this._col>-1){var P=b[this._col];o.x-P.pos<=H&&(this._edge|=1),P.pos+P.renderSize-o.x<=H&&(this._edge|=4)}if(this._row>-1){var T=C[this._row];o.y-T.pos<=H&&(this._edge|=2),T.pos+T.renderSize-o.y<=H&&(this._edge|=8)}}if(!(8&this._edge)&&r instanceof MouseEvent){var M=i.closest(r.target,".wj-cell"),D=M?M[g._INDEX_KEY]:null;D&&!D.rng&&D.panel==this._p&&this._row!=D.row&&(this._row=D.row)}}else(D=(M=i.closest(t,".wj-cell"))?M[g._INDEX_KEY]:null)&&(this._row=D.row,this._col=D.col,this._rng=D.rng,this._p=D.panel,this._g=D.panel.grid)}return Object.defineProperty(e.prototype,"point",{get:function(){return this._pt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cellType",{get:function(){return this._p?this._p.cellType:d.None},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"panel",{get:function(){return this._p},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"grid",{get:function(){return this._p?this._p.grid:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"row",{get:function(){return this._row},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"col",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"range",{get:function(){return this._rng||(this._rng=new f(this._row,this._col)),this._rng},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeLeft",{get:function(){return 0!=(1&this._edge)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeTop",{get:function(){return 0!=(2&this._edge)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeRight",{get:function(){return 0!=(4&this._edge)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"edgeBottom",{get:function(){return 0!=(8&this._edge)},enumerable:!0,configurable:!0}),e._SZEDGE=[5,30],e}();t.HitTestInfo=S;var E;!function(e){e[e.None=0]="None",e[e.Cells=1]="Cells",e[e.ColumnHeaders=2]="ColumnHeaders",e[e.RowHeaders=4]="RowHeaders",e[e.AllHeaders=6]="AllHeaders",e[e.All=7]="All"}(E=t.AllowMerging||(t.AllowMerging={}));var z=function(){function e(e){this._g=e}return e.prototype.getMergedRange=function(e,t,o,n){void 0===n&&(n=!0);var r=this._g,s=e.cellType,l=e.columns,a=e.rows,h=a[t],c=l[o];if(h instanceof k)return null;if(h instanceof y&&h.dataItem instanceof i.CollectionViewGroup){g=new f(t,o);if(c.aggregate==i.Aggregate.None){for(;g.col>0&&l[g.col-1].aggregate==i.Aggregate.None&&g.col!=l.frozen;)g.col--;for(;g.col2<l.length-1&&l[g.col2+1].aggregate==i.Aggregate.None&&g.col2+1!=l.frozen;)g.col2++}for(;g.col<o&&!l[g.col].visible;)g.col++;return g.isSingleCell?null:g}var u=!1;switch(this._g.allowMerging){case E.None:u=!0;break;case E.Cells:u=s!=d.Cell;break;case E.ColumnHeaders:u=s!=d.ColumnHeader&&s!=d.TopLeft;break;case E.RowHeaders:u=s!=d.RowHeader&&s!=d.TopLeft;break;case E.AllHeaders:u=s==d.Cell}if(u)return null;if(l[o].allowMerging){var g=new f(t,o),p=0,_=a.length-1;t>=a.frozen?!n||s!=d.Cell&&s!=d.RowHeader||r._vtRows<a.length&&(p=(b=e._getViewRange()).topRow,_=b.bottomRow):_=a.frozen-1;for(var w=t-1;w>=p&&this._mergeCell(e,w,o,t,o);w--)g.row=w;for(var m=t+1;m<=_&&this._mergeCell(e,t,o,m,o);m++)g.row2=m;for(;g.row<t&&!a[g.row].visible;)g.row++;if(!g.isSingleCell)return g}if(a[t].allowMerging){var g=new f(t,o),v=0,C=l.length-1;if(o>=l.frozen){if(n&&(s==d.Cell||s==d.ColumnHeader)&&r._vtCols<l.length){var b=e._getViewRange();v=b.leftCol,C=b.rightCol}}else C=l.frozen-1;for(var R=o-1;R>=v&&this._mergeCell(e,t,R,t,o);R--)g.col=R;for(var S=o+1;S<=C&&this._mergeCell(e,t,o,t,S);S++)g.col2=S;for(;g.col<o&&!l[g.col].visible;)g.col++;if(!g.isSingleCell)return g}return null},e.prototype._mergeCell=function(e,t,i,o,n){var r=e.rows[t],s=e.rows[o];if(r instanceof y||r instanceof k||s instanceof y||s instanceof k)return!1;if(t!=o&&e.rows.isFrozen(t)!=e.rows.isFrozen(o))return!1;if(i!=n&&e.columns.isFrozen(i)!=e.columns.isFrozen(n))return!1;if(t!=o){if(i>0&&(r.allowMerging&&this._mergeCell(e,t,i-1,t,i)||s.allowMerging&&this._mergeCell(e,o,i-1,o,i)))return!1;if(n<e.columns.length-1&&(r.allowMerging&&this._mergeCell(e,t,n,t,n+1)||s.allowMerging&&this._mergeCell(e,o,n,o,n+1)))return!1}return e.getCellData(t,i,!0)==e.getCellData(o,n,!0)},e}();t.MergeManager=z;var x=function(){function e(e,t,o){if(this.mapChanged=new i.Event,i.isArray(e)&&!t&&!o){for(var n=[],r=0;r<e.length;r++)n.push({value:e[r]});e=n,t=o="value"}this._cv=i.asCollectionView(e),this._keyPath=i.asString(t,!1),this._displayPath=i.asString(o,!1),this._cv.collectionChanged.addHandler(this.onMapChanged,this)}return Object.defineProperty(e.prototype,"sortByDisplayValues",{get:function(){return 1!=this._sortByKey},set:function(e){this._sortByKey=!i.asBoolean(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"collectionView",{get:function(){return this._cv},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selectedValuePath",{get:function(){return this._keyPath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayMemberPath",{get:function(){return this._displayPath},enumerable:!0,configurable:!0}),e.prototype.getKeyValue=function(e){var t=this._displayPath,i=this._indexOf(e,t,!0);return i<0&&(i=this._indexOf(e,t,!1)),i>-1?this._cv.sourceCollection[i][this._keyPath]:null},e.prototype.getDisplayValue=function(e){if(!this._hash){this._hash={};var t=this._cv.sourceCollection;if(t&&this._keyPath&&this._displayPath)for(var i=t.length-1;i>=0;i--){var o=t[i],n=o[this._keyPath],r=o[this._displayPath];this._hash[n]=r}}var s=this._hash[e];return null!=s?s:e},e.prototype.getDisplayValues=function(e){var t=[];if(this._cv&&this._displayPath)for(var i=this._cv.items,o=0;o<i.length;o++)t.push(i[o][this._displayPath]);return t},e.prototype.getKeyValues=function(){var e=[];if(this._cv&&this._keyPath)for(var t=this._cv.items,i=0;i<t.length;i++)e.push(t[i][this._keyPath]);return e},Object.defineProperty(e.prototype,"isEditable",{get:function(){return this._editable},set:function(e){this._editable=i.asBoolean(e)},enumerable:!0,configurable:!0}),e.prototype.onMapChanged=function(e){this._hash=null,this.mapChanged.raise(this,e)},e.prototype._indexOf=function(e,t,i){var o=-1,n=-1;if(this._cv&&t)for(var r=null!=e?e.toString():"",s=i?r:r.toLowerCase(),l=this._cv.sourceCollection,a=0;a<l.length;a++){var h=l[a],c=h[t];if(c==e?o=a:i||c.length!=s.length||c.toLowerCase()!=s?null!=c&&c.toString()==r&&(o=a):o=a,o==a){if(!this._cv.filter||this._cv.filter(h))return o;n<0&&(n=o)}}return n},e}();t.DataMap=x;var H;!function(e){e[e.None=0]="None",e[e.Cell=1]="Cell",e[e.CellRange=2]="CellRange",e[e.Row=3]="Row",e[e.RowRange=4]="RowRange",e[e.ListBox=5]="ListBox"}(H=t.SelectionMode||(t.SelectionMode={}));var P;!function(e){e[e.None=0]="None",e[e.Selected=1]="Selected",e[e.Cursor=2]="Cursor",e[e.Active=3]="Active"}(P=t.SelectedState||(t.SelectedState={}));var T;!function(e){e[e.None=0]="None",e[e.Next=1]="Next",e[e.Prev=2]="Prev",e[e.NextPage=3]="NextPage",e[e.PrevPage=4]="PrevPage",e[e.Home=5]="Home",e[e.End=6]="End",e[e.NextCell=7]="NextCell",e[e.PrevCell=8]="PrevCell"}(T=t.SelMove||(t.SelMove={}));var M=function(){function e(e){this._sel=new f(0,0),this._mode=H.CellRange,this._g=e}return Object.defineProperty(e.prototype,"selectionMode",{get:function(){return this._mode},set:function(e){if(e!=this._mode){var t=H;if(e==t.ListBox||this._mode==t.ListBox)for(var i=this._g.rows,o=0;o<i.length;o++){var n=i[o],r=e==H.ListBox&&this._sel.containsRow(o);n._setFlag(_.Selected,r,!0)}switch(e){case t.None:this._sel.setRange(-1,-1);break;case t.Cell:this._sel.row2=this._sel.row,this._sel.col2=this._sel.col;break;case t.Row:this._sel.row2=this._sel.row}this._mode=e,this._g.invalidate()}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"selection",{get:function(){return this._sel},set:function(e){this.select(e)},enumerable:!0,configurable:!0}),e.prototype.select=function(e,t){void 0===t&&(t=!0),i.isNumber(e)&&i.isNumber(t)&&(e=new f(e,t),t=!0),e=i.asType(e,f);var o=this._g,n=this._sel,r=e,s=!1,l=H;switch(o.selectionMode){case l.Cell:e.row2=e.row,e.col2=e.col;break;case l.Row:e.row2=e.row;break;case l.ListBox:s=!0}var a=r.equals(n);if(s&&r.row>-1&&!o.rows[r.row].isSelected&&(a=!1),a)t&&o.scrollIntoView(r.row,r.col);else{var c=new h(o.cells,r);if(o.onSelectionChanging(c)){if(s&&(r.row!=n.row||r.rowSpan>1||n.rowSpan>1)){for(var u=0;u<o.rows.length;u++)o.rows[u]._setFlag(_.Selected,r.containsRow(u),!0);o.refreshCells(!1,!0,!0)}if(r.row=Math.min(r.row,o.rows.length-1),r.row2=Math.min(r.row2,o.rows.length-1),this._sel=r,o.refreshCells(!1,!0,!0),t&&o.scrollIntoView(r.row,r.col),o.collectionView){var d=o._getCvIndex(r.row);o.collectionView.moveCurrentToPosition(d)}o.onSelectionChanged(c)}}},e.prototype.moveSelection=function(e,t,i){var o,n,r=this._g,s=r.rows,l=r.columns,a=this._getReferenceCell(e,t,i),h=Math.max(0,r._szClient.height-r.columnHeaders.height);if(t==T.NextCell)n=l.getNextCell(a.col,T.Next,h),o=a.row,n==a.col&&(o=s.getNextCell(o,T.Next,h))>a.row&&(n=l.getNextCell(0,T.Next,h),n=l.getNextCell(n,T.Prev,h)),r.select(o,n);else if(t==T.PrevCell)n=l.getNextCell(a.col,T.Prev,h),o=a.row,n==a.col&&(o=s.getNextCell(o,T.Prev,h))<a.row&&(n=l.getNextCell(l.length-1,T.Prev,h),n=l.getNextCell(n,T.Next,h)),r.select(o,n);else if(o=s.getNextCell(a.row,e,h),n=l.getNextCell(a.col,t,h),i){var c=r._selHdl._sel;r.select(new f(o,n,c.row2,c.col2))}else r.select(o,n)},e.prototype._getReferenceCell=function(e,t,i){var o=this._g,n=o._selHdl._sel,r=o.getMergedRange(o.cells,n.row,n.col);if(!r||r.isSingleCell)return n;switch(r=r.clone(),e){case T.Next:case T.NextCell:r.row=r.bottomRow;break;case T.None:r.row=n.row}switch(t){case T.Next:case T.NextCell:r.col=r.rightCol;break;case T.None:r.col=n.col}return r},e.prototype._adjustSelection=function(e){switch(this._mode){case H.Cell:return new f(e.row,e.col,e.row,e.col);case H.Row:return new f(e.row,0,e.row,this._g.columns.length-1);case H.RowRange:case H.ListBox:return new f(e.row,0,e.row2,this._g.columns.length-1)}return e},e}();t._SelectionHandler=M;var D;!function(e){e[e.None=0]="None",e[e.MoveDown=1]="MoveDown",e[e.MoveAcross=2]="MoveAcross",e[e.Cycle=3]="Cycle",e[e.CycleOut=4]="CycleOut"}(D=t.KeyAction||(t.KeyAction={}));var j=function(){function e(e){this._kaTab=D.None,this._kaEnter=D.MoveDown,this._g=e;var t=e.hostElement;e.addEventListener(t,"keypress",this._keypress.bind(this)),e.addEventListener(t,"keydown",this._keydown.bind(this))}return e.prototype._keydown=function(e){var t=this._g,o=t._edtHdl,n=t.selection,r=e.ctrlKey||e.metaKey,s=e.shiftKey,l=(e.target,!0);if(this._altDown=!1,!t._wantsInput(e.target)){var a=e.defaultPrevented&&!(e.target instanceof HTMLInputElement);if(t.isRangeValid(n)&&!a&&(!t.activeEditor||!o._keydown(e))){var c=i.tryCast(t.rows[n.row],y),u=t.editableCollectionView,d=t._getKeyCode(e);if(t.autoClipboard){if(r&&(67==d||45==d)){var g=new h(t.cells,n);if(t.onCopying(g)){var p=t.getClipString()+"\r\n";i.Clipboard.copy(p),t.onCopied(g)}return void e.stopPropagation()}if(r&&86==d||s&&45==d)return t.isReadOnly||i.Clipboard.paste(function(e){t.setClipString(e)}),void e.stopPropagation()}var _=T,w=H;switch(d){case i.Key.Space:if(s&&n.isValid)switch(t.selectionMode){case w.CellRange:case w.Row:case w.RowRange:case w.ListBox:t.select(new f(n.row,0,n.row,t.columns.length-1))}else if(r&&n.isValid)switch(t.selectionMode){case w.CellRange:t.select(new f(0,n.col,t.rows.length-1,n.col))}else(l=this._startEditing(!0,e))&&setTimeout(function(){var e=t.activeEditor;e&&(e.disabled||e.readOnly?t.finishEditing():"checkbox"==e.type?(e.checked=!e.checked,t.finishEditing()):i.setSelectionRange(e,e.value.length))});break;case 65:if(r)switch(t.selectionMode){case w.CellRange:case w.Row:case w.RowRange:case w.ListBox:t.select(new f(0,0,t.rows.length-1,t.columns.length-1))}else l=!1;break;case i.Key.Left:r||e.altKey?l=!1:n.isValid&&0==n.col&&null!=c&&!c.isCollapsed&&c.hasChildren?c.isCollapsed=!0:this._moveSel(_.None,r?_.Home:_.Prev,s);break;case i.Key.Right:r||e.altKey?l=!1:n.isValid&&0==n.col&&null!=c&&c.isCollapsed?c.isCollapsed=!1:this._moveSel(_.None,r?_.End:_.Next,s);break;case i.Key.Up:r?l=!1:(this._altDown=e.altKey,e.altKey?l=o._toggleListBox(e):this._moveSel(_.Prev,_.None,s));break;case i.Key.Down:r?l=!1:(this._altDown=e.altKey,e.altKey?l=o._toggleListBox(e):this._moveSel(_.Next,_.None,s));break;case i.Key.PageUp:if(this._altDown=e.altKey,this._moveSel(e.altKey?_.Home:_.PrevPage,_.None,s),t.rows.frozen&&t.selection.row<t.rows.frozen){var m=t.scrollPosition;m.y&&(t.scrollPosition=new i.Point(m.x,0))}break;case i.Key.PageDown:this._altDown=e.altKey,this._moveSel(e.altKey?_.End:_.NextPage,_.None,s);break;case i.Key.Home:this._moveSel(r?_.Home:_.None,_.Home,s);break;case i.Key.End:this._moveSel(r?_.End:_.None,_.End,s);break;case i.Key.Tab:l=this._performKeyAction(t.keyActionTab,s);break;case i.Key.Enter:l=this._performKeyAction(t.keyActionEnter,s),!s&&u&&null!=u.currentEditItem&&o._commitRowEdits();break;case i.Key.Escape:if(l=!1,u&&(u.currentAddItem||u.currentEditItem)){var v=new h(t.cells,t.selection);v.cancel=!0,t.onRowEditEnding(v),u.currentAddItem&&u.cancelNew(),u.currentEditItem&&u.cancelEdit(),t.onRowEditEnded(v),l=!0}t._mouseHdl.resetMouseState();break;case i.Key.Delete:case i.Key.Back:l=this._deleteSel(e);break;case i.Key.F2:l=this._startEditing(!0,e);break;case i.Key.F4:l=o._toggleListBox(e);break;default:l=!1}l&&(t.containsFocus()||t.focus(),e.preventDefault(),e.stopPropagation())}}},e.prototype._performKeyAction=function(e,t){var i=D,o=T;switch(e){case i.MoveDown:return this._moveSel(t?o.Prev:o.Next,o.None,!1),!0;case i.MoveAcross:return this._moveSel(o.None,t?o.Prev:o.Next,!1),!0;case i.Cycle:return this._moveSel(o.None,t?o.PrevCell:o.NextCell,!1),!0;case i.CycleOut:var n=this._g.selection;return this._moveSel(o.None,t?o.PrevCell:o.NextCell,!1),!n.equals(this._g.selection)}return!1},e.prototype._keypress=function(e){var t=this,o=this._g,n=o._edtHdl;if(!o._wantsInput(e.target)&&!e.defaultPrevented)if(this._altDown)e.preventDefault();else if(o.activeEditor)n._keypress(e);else if(e.charCode>i.Key.Space)if(this._startEditing(!1,e)&&o.activeEditor){var r=i.getActiveElement();if(r instanceof HTMLInputElement&&"checkbox"!=r.type||r instanceof HTMLTextAreaElement){var s=o._selHdl.selection,l=o.getCellData(s.row,s.col,!0),a=o.getCellData(s.row,s.col,!1);r.value=String.fromCharCode(e.charCode),i.isNumber(a)&&l.indexOf("%")>-1&&(r.value+="%"),i.setSelectionRange(r,1),r.dispatchEvent(n._evtInput),n._keypress(e),n._edtValue=r.value!=l?r.value:null,e.preventDefault()}}else if(o.autoSearch){var h=!1,s=o._selHdl.selection;if(e.charCode>32||32==e.charCode&&this._search){e.preventDefault(),this._search+=String.fromCharCode(e.charCode).toLowerCase(),this._toSearch&&clearTimeout(this._toSearch),this._toSearch=setTimeout(function(){t._toSearch=null,t._search=""},i.Control._SEARCH_DELAY);var c=this._findNext(s.row,s.col);c<0&&this._search.length>1&&(this._search=this._search[this._search.length-1],c=this._findNext(s.row,s.col)),c>-1&&(h=!0,o.select(c,s.col))}h||(this._search="")}},e.prototype._findNext=function(e,t){var i=this._g,o=i.rows.length;(e<0||1==this._search.length)&&e++;for(var n=0;n<o;n++){var r=(e+n)%o;if(0==i.getCellData(r,t,!0).trim().toLowerCase().indexOf(this._search))return r}return-1},e.prototype._moveSel=function(e,t,i){this._g.selectionMode!=H.None&&this._g._selHdl.moveSelection(e,t,i)},e.prototype._deleteSel=function(e){var t=this._g,i=t.editableCollectionView,o=t.selection,n=t.rows,r=[],s=new f,l=new u(t.cells,s,e),a=H;if(t.allowDelete&&!t.isReadOnly&&(null==i||i.canRemove&&!i.isAddingNew&&!i.isEditingItem))switch(t.selectionMode){case a.CellRange:if(0==o.leftCol&&o.rightCol==t.columns.length-1)for(h=o.topRow;h>-1&&h<=o.bottomRow;h++)r.push(n[h]);break;case a.ListBox:for(h=0;h<n.length;h++)n[h].isSelected&&r.push(n[h]);break;case a.Row:o.topRow>-1&&r.push(n[o.topRow]);break;case a.RowRange:for(var h=o.topRow;h>-1&&h<=o.bottomRow;h++)r.push(n[h])}if(r.length>0){if(t.deferUpdate(function(){i&&i.beginUpdate();for(var e=r.length-1;e>=0;e--){var o=r[e];s.setRange(o.index,-1),t.onDeletingRow(l)&&(i&&o.dataItem?i.remove(o.dataItem):t.rows.removeAt(o.index),t.onDeletedRow(l))}i&&i.endUpdate()}),t.selectionMode==a.ListBox){var c=t.selection.row;c>-1&&c<t.rows.length&&(t.rows[c].isSelected=!0)}return t.childItemsPath&&t.collectionView&&t.collectionView.refresh(),!0}if(!t.isReadOnly&&0==r.length){var d=!1,g=t.scrollPosition;return t.deferUpdate(function(){for(var e=o.topRow;e<=o.bottomRow;e++){var n=t.rows[e];if(!n.isReadOnly)for(var r=o.leftCol;r<=o.rightCol;r++){var a=t._getBindingColumn(t.cells,e,t.columns[r]);if(!a.getIsRequired()&&!a.isReadOnly&&t.getCellData(e,r,!0)&&(s.setRange(e,r),l.cancel=!1,t.onBeginningEdit(l))){if(i){var h=i.currentEditItem;!d&&h&&h!=n.dataItem&&(d=!0,i.beginUpdate()),h=n.dataItem,i.editItem(h),t._edtHdl._edItem=h}t.setCellData(e,r,"",!0,!1),t.onCellEditEnding(l),t.onCellEditEnded(l)}}}t.selection=o,t.scrollPosition=g,d&&i.endUpdate()}),!0}return!1},e.prototype._startEditing=function(e,t,i,o){return this._g._edtHdl.startEditing(e,i,o,!0,t)},e}();t._KeyboardHandler=j;var L;!function(e){e[e.None=0]="None",e[e.Columns=1]="Columns",e[e.Rows=2]="Rows",e[e.Both=3]="Both",e[e.ColumnsAllCells=4|e.Columns]="ColumnsAllCells",e[e.RowsAllCells=4|e.Rows]="RowsAllCells",e[e.BothAllCells=4|e.Both]="BothAllCells"}(L=t.AllowResizing||(t.AllowResizing={}));var O;!function(e){e[e.None=0]="None",e[e.Headers=1]="Headers",e[e.Cells=2]="Cells",e[e.Both=3]="Both"}(O=t.AutoSizeMode||(t.AutoSizeMode={}));var I;!function(e){e[e.None=0]="None",e[e.Columns=1]="Columns",e[e.Rows=2]="Rows",e[e.Both=3]="Both"}(I=t.AllowDragging||(t.AllowDragging={}));var A=function(){function e(e){var t=this;this._tsLast=0;var o=e.hostElement,n=e.addEventListener.bind(e),r=e.removeEventListener.bind(e);this._g=e,this._dvMarker=i.createElement('<div class="wj-marker">&nbsp;</div>'),n(o,"mousedown",function(o){if(e._rcBounds=null,!o.defaultPrevented&&0==o.button){var a=o.target;if(!e.containsFocus()){var h=a instanceof HTMLElement&&a.tabIndex>-1?a:e._eFocus;e._setFocusNoScroll(h)}if(setTimeout(function(){o.defaultPrevented||e.focus()}),i.closest(a,".wj-flexgrid")!=e.hostElement||!e.activeEditor&&e._isInputElement(a)){var c=e.hitTest(o);switch(c.cellType){case d.Cell:e.select(c.range,!1),a.focus();break;case d.ColumnHeader:case d.ColumnFooter:e.scrollIntoView(-1,c.col);break;case d.RowHeader:e.scrollIntoView(c.row,-1)}return}var u=document;r(u,"mousemove"),r(u,"mouseup"),n(u,"mousemove",s),n(u,"mouseup",l),t._isDown=!0,t._mousedown(o)}});var s=function(e){t._mousemove(e)},l=function(e){t._isDown=!1,r(document,"mousemove"),r(document,"mouseup"),t._mouseup(e)};n(o,"mouseup",function(e){t._tsLast=Date.now()}),n(o,"mouseenter",function(t){e._rcBounds=null}),n(o,"mousemove",this._hover.bind(this)),n(o,"dblclick",this._dblclick.bind(this)),n(o,"click",this._click.bind(this)),n(o,"selectstart",function(t){e._isInputElement(t.target)||t.preventDefault()}),n(o,"wheel",function(t){if(!t.defaultPrevented&&t.deltaY&&!t.ctrlKey&&!t.metaKey){var o=e.cells.hostElement.parentElement,n=t.deltaY,r=0;if(o.scrollHeight>o.offsetHeight&&i.closest(t.target,".wj-flexgrid")==e.hostElement){switch(t.deltaMode){case 1:r=e.rows.defaultSize*(n<0?-1:1);break;case 2:r=o.clientHeight*(n<0?-1:1);break;case 0:default:i.isSafari()&&(n=i.clamp(n,-150,150)),r=n}o.scrollTop+=r,t.preventDefault()}}}),n(o,"dragstart",this._dragstart.bind(this)),n(o,"dragover",this._dragover.bind(this)),n(o,"dragleave",this._dragover.bind(this)),n(o,"drop",this._drop.bind(this)),n(o,"dragend",this._dragend.bind(this)),this._enableTouchResizing()}return e.prototype.resetMouseState=function(){this._updating&&(this._updating=!1,this._g.endUpdate()),this._dragSrc&&i.removeClass(this._dragSrc,"wj-state-dragsrc"),this._showDragMarker(null);var e=this._g.hostElement;e&&(e.style.cursor="");var t=this._g;t.removeEventListener(document,"mousemove"),t.removeEventListener(document,"mouseup"),this._tsLast=Date.now(),this._eMouse=null,this._isDown=null,this._htDown=null,this._lbSelRows=null,this._szRowCol=null,this._szArgs=null},e.prototype._enableTouchResizing=function(){var e=this,t=this._g,o=t.hostElement,n="ontouchstart"in window?["touchstart","touchmove","touchend"]:"onpointerdown"in window?["pointerdown","pointermove","pointerup"]:null;n&&(t.addEventListener(o,n[0],function(n){if((null==n.pointerType||"touch"==n.pointerType)&&!i.closest(n.target,".wj-elem-filter")){var r=i.closest(n.target,".wj-cell");r instanceof HTMLElement&&(t._rcBounds=null,e._htDown=null,e._hover(n),e._szRowCol&&(r.removeAttribute("draggable"),o.style.touchAction="none",e._mousedown(n),n.preventDefault()))}}),t.addEventListener(o,n[1],function(t){null!=t.pointerType&&"touch"!=t.pointerType||e._szRowCol&&(e._mousemove(t),t.preventDefault())}),t.addEventListener(o,n[2],function(t){if((null==t.pointerType||"touch"==t.pointerType)&&e._szRowCol){if(e._szArgs)e._finishResizing(e._eMouse);else{var n=i.closest(t.target,".wj-cell");n instanceof HTMLElement&&n.click()}e.resetMouseState(),o.style.touchAction=""}}))},e.prototype._mousedown=function(e){var t=this._g,o=t.hitTest(e),n=o.cellType,r=e.ctrlKey||e.metaKey,s=e.target;if(this._selDown=t.selection,o.panel==t.cells){if(i.closestClass(s,p._WJC_DROPDOWN))return t._edtHdl._toggleListBox(e,o.range),void e.preventDefault();if(t.editRange&&t.editRange.contains(o.range))return}var l=i.getActiveElement();if(s!=l||!t._isInputElement(s)){if(n==d.None)return t.finishEditing(),void(s!=t._root&&s!=t._fCt&&t._edtHdl._commitRowEdits());if(this._htDown=o,this._eMouse=e,null!=this._szRowCol)return l!=t._eFocus&&(t._eFocus.tabIndex=0,t._eFocus.focus()),void this._handleResizing(e);switch(n){case d.Cell:r&&t.selectionMode==H.ListBox&&this._startListBoxSelection(o.row),this._mouseSelect(e,e.shiftKey);break;case d.RowHeader:0==(this._g.allowDragging&I.Rows)&&(r&&t.selectionMode==H.ListBox&&this._startListBoxSelection(o.row),this._mouseSelect(e,e.shiftKey),e.preventDefault(),t.focus())}if(n==d.Cell&&t.rows.maxGroupLevel>-1&&i.closestClass(s,p._WJC_COLLAPSE)){var a=i.tryCast(t.rows[o.row],y);if(a)return r?t.collapseGroupsToLevel(a.isCollapsed?a.level+1:a.level):a.isCollapsed=!a.isCollapsed,void this.resetMouseState()}}},e.prototype._mousemove=function(e){if(null!=this._htDown){if(0==e.buttons&&this._eMouse&&e.timeStamp-this._eMouse.timeStamp>600)return void this.resetMouseState();if(this._eMouse=e,this._szRowCol)this._handleResizing(e);else switch(this._htDown.cellType){case d.Cell:this._mouseSelect(e,!0);break;case d.RowHeader:0==(this._g.allowDragging&I.Rows)&&this._mouseSelect(e,!0)}}},e.prototype._mouseup=function(e){if(!this._g.isTouching||!(this._dragSrc||e.target instanceof HTMLHtmlElement)){var t=this._g,i=t.hitTest(e),o=this._htDown,n=H;if(o&&!e.defaultPrevented)if(this._szArgs)this._finishResizing(e);else if(o.panel!=t.topLeftCells||this._szArgs)o.panel!=t.columnHeaders||e.dataTransfer?o.panel==t.cells&&(this._szRowCol||e.ctrlKey||e.metaKey||e.shiftKey||i.panel==o.panel&&i.range.equals(o.range)&&t.selection.equals(this._selDown)&&t._edtHdl.startEditing(!0,i.row,i.col,!0,e)):i.panel==o.panel&&i.col==o.col&&!i.edgeRight&&i.col>-1&&this._clickSort(e,i);else if(i.panel==o.panel&&i.row==o.row&&i.col==o.col&&t.rows.length&&t.columns.length)switch(t.selectionMode){case n.CellRange:case n.RowRange:case n.ListBox:t.select(new f(0,0,t.rows.length-1,t.columns.length-1))}this.resetMouseState()}},e.prototype._click=function(e){Date.now()-this._tsLast>50&&!e.pointerType&&this._handleClick(e)},e.prototype._handleClick=function(e){var t=this._g,o=e.target,n=new S(o,null),r=n.panel;if(!e.defaultPrevented&&n.grid==t&&!t._isInputElement(o))if(r==t.topLeftCells)t.select(new f(0,0,t.rows.length-1,t.columns.length-1));else if(r==t.columnHeaders)this._clickSort(e,n);else if(r==t.rowHeaders)t.select(new f(n.row,0,n.row,t.columns.length-1));else if(r==t.cells)if(n.row<0)this._clickSort(e,n);else if(i.closestClass(o,p._WJC_COLLAPSE)){var s=t.rows[n.row];s instanceof y&&(e.ctrlKey?t.collapseGroupsToLevel(s.isCollapsed?s.level+1:s.level):s.isCollapsed=!s.isCollapsed)}else i.closestClass(o,p._WJC_DROPDOWN)?t._edtHdl._toggleListBox(e,n.range):t.select(n.range)},e.prototype._clickSort=function(e,t){var o=this._g,n=o.collectionView,r=e.ctrlKey||e.metaKey;if(n&&n.canSort&&o.allowSorting){t.range.bottomRow;var s=t.panel.columns[t.col],l=o._getBindingColumn(t.panel,t.row,s),a=l?l._getBindingSort():null;if(l.allowSorting&&a){for(var c=t.grid.collectionView.sortDescriptions,u=null,d=0;d<c.length;d++)if(c[d].property==a){u=!c[d].ascending;break}if(null==u){if(r)return;u=!0}var g=new h(t.panel,t.range,e);o.onSortingColumn(g)&&(o._edtHdl._commitRowEdits(),r?c.clear():c.splice(0,c.length,new i.SortDescription(a,u)),o.onSortedColumn(g))}}},e.prototype._dblclick=function(e){var t,i=this._g,o=i.hitTest(e),n=o.cellType,r=i.selection,s=o.range;if(!e.defaultPrevented)if(o.edgeRight&&i.allowResizing&L.Columns){if(n==d.ColumnHeader||n==d.Cell&&4&i.allowResizing){e.preventDefault(),e.ctrlKey&&r.containsColumn(o.col)&&(s=r);for(var l=s.leftCol;l<=s.rightCol;l++)i.columns[l].allowResizing&&(t=new h(i.cells,new f(-1,l)),i.onAutoSizingColumn(t)&&i.onResizingColumn(t)&&(i.autoSizeColumn(l),i.onResizedColumn(t),i.onAutoSizedColumn(t)))}else n==d.TopLeft&&o.panel.columns[o.col].allowResizing&&(e.preventDefault(),t=new h(o.panel,new f(-1,o.col)),i.onAutoSizingColumn(t)&&i.onResizingColumn(t)&&(i.autoSizeColumn(o.col,!0),i.onAutoSizedColumn(t),i.onResizedColumn(t)));this.resetMouseState()}else if(o.edgeBottom&&i.allowResizing&L.Rows){if(n==d.RowHeader||n==d.Cell&&4&i.allowResizing){e.ctrlKey&&r.containsRow(o.row)&&(s=r);for(var a=s.topRow;a<=s.bottomRow;a++)i.rows[a].allowResizing&&(t=new h(i.cells,new f(a,-1)),i.onAutoSizingRow(t)&&i.onResizingRow(t)&&(i.autoSizeRow(a),i.onResizedRow(t),i.onAutoSizedRow(t)))}else n==d.TopLeft&&o.panel.rows[o.row].allowResizing&&(t=new h(o.panel,new f(o.row,-1)),i.onAutoSizingRow(t)&&i.onResizingRow(t)&&(i.autoSizeRow(o.row,!0),i.onResizedRow(t),i.onAutoSizedRow(t)));this.resetMouseState()}else;},e.prototype._hover=function(e){if(!this._isDown){var t=this._g,i=t.hitTest(e),o=(i.panel,i.cellType),n="";return this._szRowCol=null,(o==d.ColumnHeader||o==d.TopLeft||o==d.Cell&&4&t.allowResizing)&&i.edgeRight&&0!=(t.allowResizing&L.Columns)&&(this._szRowCol=this._getResizeCol(i)),(o==d.RowHeader||o==d.TopLeft||o==d.Cell&&4&t.allowResizing)&&i.edgeBottom&&0!=(t.allowResizing&L.Rows)&&(this._szRowCol=this._getResizeRow(i)),this._szRowCol instanceof m?n="col-resize":this._szRowCol instanceof v&&(n="row-resize"),this._szStart=this._szRowCol?this._szRowCol.renderSize:0,t.hostElement.style.cursor=n,i}return null},e.prototype._getResizeCol=function(e){for(var t=e.panel.columns,i=t[e.col],o=e.col+1;o<t.length;o++)if((n=t[o]).visible){n.renderSize<1&&(i=n);break}if(e.col==t.length-1&&(e.cellType==d.TopLeft||e.cellType==d.RowHeader)){t=this._g.columns;for(o=0;o<t.length;o++){var n=t[o];if(n.visible){n.renderSize<1&&(i=n);break}}}return i.allowResizing?i:null},e.prototype._getResizeRow=function(e){for(var t=e.panel.rows,i=t[e.row],o=e.row+1;o<t.length;o++)if((n=t[o]).visible){n.renderSize<1&&(i=n);break}if(e.row==t.length-1&&(e.cellType==d.TopLeft||e.cellType==d.ColumnHeader)){t=this._g.rows;for(o=0;o<t.length;o++){var n=t[o];if(n.visible){n.renderSize<1&&(i=n);break}}}return i.allowResizing?i:null},e.prototype._mouseSelect=function(e,t){var o=this,n=this._g;if(e&&this._htDown&&this._htDown.panel&&n.selectionMode!=H.None){var r=new S(this._htDown.panel,e);this._handleSelection(r,t),!i.isIE9()&&e.button>=0&&e.target!=n._root&&(r=new S(n,e)).cellType!=d.Cell&&r.cellType!=d.RowHeader&&this._eMouse&&setTimeout(function(){o._eMouse&&o._mouseSelect(o._eMouse,t)},100)}},e.prototype._handleResizing=function(t){if(t.preventDefault(),this._szRowCol instanceof m){var o=this._g,n=i.mouseToPage(t).x,r=Math.round(Math.max(e._SZ_MIN,this._szStart+(n-this._htDown.point.x)*(o.rightToLeft?-1:1)));if(this._szRowCol.renderSize!=r){if(null==this._szArgs){l=o.rowHeaders.columns.indexOf(this._szRowCol)>-1?o.rowHeaders:o.cells;this._szArgs=new h(l,new f(-1,this._szRowCol.index))}this._szArgs.cancel=!1,o.onResizingColumn(this._szArgs)&&(o.deferResizing?this._showResizeMarker(r):this._szRowCol.width=r)}}if(this._szRowCol instanceof v){var o=this._g,s=i.mouseToPage(t).y,r=Math.round(Math.max(e._SZ_MIN,this._szStart+(s-this._htDown.point.y)));if(this._szRowCol.renderSize!=r){if(null==this._szArgs){var l=o.columnHeaders.rows.indexOf(this._szRowCol)>-1?o.columnHeaders:o.cells;this._szArgs=new h(l,new f(this._szRowCol.index,-1))}this._szArgs.cancel=!1,o.onResizingRow(this._szArgs)&&(o.deferResizing?this._showResizeMarker(r):this._szRowCol.height=r)}}},e.prototype._dragstart=function(e){var t=this._g,o=this._htDown,n=I;if(o){if(this._dragSrc=null,this._htDrag=null,!this._szRowCol){var r=new h(o.panel,o.range);if(o.cellType==d.ColumnHeader&&t.allowDragging&n.Columns&&o.col>-1&&t.columns[o.col].allowDragging)t.onDraggingColumn(r)?this._dragSrc=e.target:e.preventDefault();else if(o.cellType==d.RowHeader&&t.allowDragging&n.Rows&&o.row>-1&&t.rows[o.row].allowDragging){var s=t.rows[o.row];s instanceof y||s instanceof k||(t.onDraggingRow(r)?this._dragSrc=e.target:e.preventDefault())}else o.cellType==d.TopLeft&&t.allowDragging&n.Columns&&o.col>-1&&t.topLeftCells.columns[o.col].allowDragging&&(t.onDraggingColumn(r)?this._dragSrc=e.target:e.preventDefault())}this._dragSrc&&e.dataTransfer&&!e.defaultPrevented&&(this._htDrag=o,i._startDrag(e.dataTransfer,"move"),e.stopPropagation(),i.addClass(this._dragSrc,"wj-state-dragsrc"),t.beginUpdate(),this._updating=!0)}},e.prototype._dragend=function(e){this._dragSrc=null,this._htDrag=null,this.resetMouseState()},e.prototype._dragover=function(e){var t=this._g,o=t.hitTest(e),n=this._dragSrc?this._htDrag:null,r=d,s=!1;if(n&&o.cellType==n.cellType){var l=new h(o.panel,o.range,n);o.cellType==r.ColumnHeader?(l.cancel=!t.columns.canMoveElement(n.col,o.col),s=t.onDraggingColumnOver(l)):o.cellType==r.RowHeader?(l.cancel=!t.rows.canMoveElement(n.row,o.row),s=t.onDraggingRowOver(l)):o.cellType==r.TopLeft&&(l.cancel=!t.topLeftCells.columns.canMoveElement(n.col,o.col),s=t.onDraggingColumnOver(l))}if(s?(e.dataTransfer.dropEffect="move",this._showDragMarker(o),e.preventDefault(),e.stopPropagation()):this._showDragMarker(null),n&&t.autoScroll){var a=t._rcBounds,c=t.scrollPosition,u=i.Control._DRAG_SCROLL_EDGE,g=i.Control._DRAG_SCROLL_STEP;n.panel==t.columnHeaders?(e.pageX-a.left<u&&(c.x+=g),a.right-e.pageX<u&&(c.x-=g)):n.panel==t.rowHeaders&&(e.pageY-a.top<u&&(c.y+=g),a.bottom-e.pageY<u&&(c.y-=g)),c.equals(t._ptScrl)||(t.scrollPosition=c)}},e.prototype._drop=function(e){var t=this._g,i=t.hitTest(e),o=this._dragSrc?this._htDrag:null,n=d;if(o&&i.cellType==o.cellType){var r=t.selection,s=new h(i.panel,i.range,o);i.cellType==n.ColumnHeader?(t.columns.moveElement(o.col,i.col),t.select(r.row,i.col),t.onDraggedColumn(s)):i.cellType==n.RowHeader?(t.rows.moveElement(o.row,i.row),t.select(i.row,r.col),t.onDraggedRow(s)):i.cellType==n.TopLeft&&(t.topLeftCells.columns.moveElement(o.col,i.col),t.onDraggedColumn(s))}this.resetMouseState()},e.prototype._showResizeMarker=function(e){var t=this._g,o=this._dvMarker,n=t.cells.hostElement;o.parentElement!=n&&n.appendChild(o);var r,s=this._szArgs.panel.cellType,l=d;this._szRowCol instanceof m?(r={left:this._szRowCol.pos+e-1,top:-1e3,right:"",bottom:0,width:3,height:""},t.rightToLeft&&(r.left=n.clientWidth-r.left-r.width),s!=l.TopLeft&&s!=l.RowHeader||(r.left-=t._eTL.offsetWidth)):(r={left:-1e3,top:this._szRowCol.pos+e-1,right:0,bottom:"",width:"",height:3},s!=l.TopLeft&&s!=l.ColumnHeader||(r.top-=t._eTL.offsetHeight)),i.setCss(o,r)},e.prototype._showDragMarker=function(e){var t=this._g,o=this._dvMarker;if(!e||!e.panel)return i.removeChild(o),void(this._rngTarget=null);if(!e.range.equals(this._rngTarget)){this._rngTarget=e.range;var n=e.panel.hostElement;o.parentElement!=n&&n.appendChild(o);var r=d,s={left:0,top:0,width:6,height:6,right:"",bottom:""};switch(e.cellType){case r.TopLeft:case r.ColumnHeader:s.height=e.panel.height;var l=e.panel.columns[e.col];s.left=l.pos-s.width/2,this._htDown&&e.col>this._htDown.col&&(s.left+=l.renderWidth),t.rightToLeft&&(s.left=o.parentElement.clientWidth-s.left-s.width);break;case r.RowHeader:s.width=e.panel.width;var a=e.panel.rows[e.row];s.top=a.pos-s.height/2,e.row>this._htDown.row&&(s.top+=a.renderHeight)}i.setCss(o,s)}},e.prototype._finishResizing=function(t){var o=this._g,n=o.selection,r=this._szArgs,s=this._eMouse&&this._eMouse.ctrlKey,l=d;if(r&&!r.cancel){if(r.col>-1){var a=r.col,c=i.mouseToPage(t).x,u=Math.round(Math.max(e._SZ_MIN,this._szStart+(c-this._htDown.point.x)*(this._g.rightToLeft?-1:1)));if(r.panel.columns[a].width=Math.round(u),o.onResizedColumn(r),s&&this._htDown.cellType==l.ColumnHeader&&n.containsColumn(a))for(var g=n.leftCol;g<=n.rightCol;g++)o.columns[g].allowResizing&&g!=a&&(r=new h(o.cells,new f(-1,g)),o.onResizingColumn(r)&&(o.columns[g].size=o.columns[a].size,o.onResizedColumn(r)))}if(r.row>-1){var a=r.row,p=i.mouseToPage(t).y,u=Math.round(Math.max(e._SZ_MIN,this._szStart+(p-this._htDown.point.y)));if(r.panel.rows[a].height=Math.round(u),o.onResizedRow(r),s&&this._htDown.cellType==l.RowHeader&&n.containsRow(a))for(var _=n.topRow;_<=n.bottomRow;_++)o.rows[_].allowResizing&&_!=a&&(r=new h(o.cells,new f(_,-1)),o.onResizingRow(r)&&(o.rows[_].size=o.rows[a].size,o.onResizedRow(r)))}}},e.prototype._startListBoxSelection=function(e){var t=this._g.rows;this._lbSelState=!t[e].isSelected,this._lbSelRows={};for(var i=0;i<t.length;i++)t[i].isSelected&&(this._lbSelRows[i]=!0)},e.prototype._handleSelection=function(e,t){var i=this._g,o=i.rows,n=i._selHdl.selection,r=new f(e.row,e.col);if(e.row>-1&&e.col>-1)if(null!=this._lbSelRows){var s=!1;r=new f(e.row,e.col,this._htDown.row,this._htDown.col);for(var l=0;l<o.length;l++){var a=r.containsRow(l)?this._lbSelState:null!=this._lbSelRows[l];if(a!=o[l].isSelected){var c=new h(i.cells,new f(l,n.col,l,n.col2));i.onSelectionChanging(c)&&(o[l]._setFlag(_.Selected,a,!0),s=!0,i.onSelectionChanged(c))}}s&&i.refreshCells(!1,!0,!0),i.scrollIntoView(e.row,e.col)}else e.cellType==d.RowHeader&&(r.col=0,r.col2=i.columns.length-1),t&&(r.row2=n.row2,r.col2=n.col2),i.select(r)},e._SZ_MIN=0,e}();t._MouseHandler=A;var B=function(){function e(e){var t=this;this._fullEdit=!1,this._list=null,this._g=e,this._evtInput=document.createEvent("HTMLEvents"),this._evtInput.initEvent("input",!0,!1),this._evtChange=document.createEvent("HTMLEvents"),this._evtChange.initEvent("change",!0,!1),e.selectionChanging.addHandler(function(i,o){if(t.finishEditing()){var n=e._selHdl.selection.row;if(n!=o.row){var r=e.rows.length;(n>-1&&n<r?e.rows[n].dataItem:null)!=(o.row>-1&&o.row<r?e.rows[o.row].dataItem:null)&&t._commitRowEdits()}}else o.cancel=!0}),e.lostFocus.addHandler(function(){if(!e.containsFocus()){var o=i.getActiveElement();o&&"fixed"==getComputedStyle(o).position||t._commitRowEdits()}});var o=e.hostElement;e.addEventListener(o,"mousedown",function(o){if(!o.defaultPrevented&&0==o.button&&!e._mouseHdl._szRowCol){e.selection;var n=e.hitTest(o);if(n.cellType!=d.Cell&&n.cellType!=d.None)t.finishEditing();else if(n.cellType!=d.None){var r=i.tryCast(o.target,HTMLInputElement);t._isNativeCheckbox(r)&&(r!=t.activeEditor&&(o.preventDefault(),t.startEditing(!1,n.row,n.col,!0,o)&&(r=t.activeEditor)),!r||"checkbox"!=r.type||r.disabled||r.readOnly||(r.checked=!r.checked,r.focus(),t.finishEditing()))}}},!0),e.addEventListener(o,"click",function(e){t._isNativeCheckbox(e.target)&&e.preventDefault()}),e.addEventListener(o,"compositionend",this._keypress.bind(this))}return e.prototype.startEditing=function(e,t,o,n,r){void 0===e&&(e=!0);var s=this._g;if(t=i.asNumber(t,!0,!0),o=i.asNumber(o,!0,!0),null==t&&(t=s.selection.row),null==o&&(o=s.selection.col),null==n&&(n=!0),!this._allowEditing(t,o))return!1;var l=s.getMergedRange(s.cells,t,o,!1);l||(l=new f(t,o));var a=s.rows[t].dataItem;if(s.scrollIntoView(l.row,l.col,!0),s.select(l,!0),!s.rows[t]||a!=s.rows[t].dataItem)return!1;if(l.equals(this._rng))return!0;if(this.activeEditor&&!this.finishEditing())return!1;var c=new h(s.cells,l,r);if(!s.onBeginningEdit(c))return!1;var u=s.editableCollectionView,d=!1;u&&((d=(a=s.rows[t].dataItem)!=u.currentEditItem)&&s.onRowEditStarting(c),u.editItem(a),d&&(s.onRowEditStarted(c),this._edItem=a)),this._fullEdit=i.asBoolean(e),this._rng=l,this._list=null;var g=s.columns[o].dataMap;g&&(this._list=g.getDisplayValues(a)),l.isSingleCell?this._updateEditorCell(t,o,d):s.refresh(!1);var p=this._edt;if(p){if("checkbox"==p.type)this._fullEdit=!1;else if(n){s._setFocusNoScroll(p);var _=i.culture.Globalize.numberFormat["%"]||"%";if(i.isNumber(s.getCellData(t,o,!1))&&p.value.indexOf(_)>-1){for(var w=p.value,m=0,v=w.length;v>0&&w[v-1]==_;)v--;for(;m<v&&w[m]==_;)m++;i.setSelectionRange(p,m,v)}else i.setSelectionRange(p,0,p.value.length)}if(s.onPrepareCellForEdit(c),p.disabled||p.readOnly)return!1}return null!=p&&!p.disabled&&!p.readOnly},e.prototype.finishEditing=function(e){var t=this._edt;if(!t)return this._removeListBox(),!0;var o=this._g,n=this._rng,r=new u(o.cells,n),s=o.containsFocus(),l=o.hostElement.querySelector(".wj-control.wj-state-focused");if(l){var a=i.Control.getControl(l);a&&a.onLostFocus(r)}if(r.cancel=e,!e&&o.validateEdits){var h=this._getValidationError();if(h){r.cancel=!0;var c=t.parentElement;c&&(i.toggleClass(c,"wj-state-invalid",!0),c.title=h,r.stayInEditMode=!0)}}if(!o.onCellEditEnding(r)&&r.stayInEditMode)return s?setTimeout(function(){t.select()}):t.select(),!1;if(!r.cancel){r.data=o.cells.getCellData(n.topRow,n.leftCol,!1);for(var d=o.cellFactory.getEditorValue(o),g=n.topRow;g<=n.bottomRow&&g<o.rows.length;g++)for(var p=n.leftCol;p<=n.rightCol&&p<o.columns.length;p++)o.cells.setCellData(g,p,d,!0,!1);t.value==this._edtValue&&t.dispatchEvent(this._evtChange)}this._edt=null,this._rng=null,this._list=null,this._edtValue=null,this._removeListBox();var f=i.closest(t,".wj-cell");return i.contains(f,i.getActiveElement())&&f.focus(),r.cancel||!r.refresh?this._updateEditorCell(n.row,n.col,!1):o.refresh(!1),s&&o.focus(),o.onCellEditEnded(r),!0},Object.defineProperty(e.prototype,"activeEditor",{get:function(){return this._edt},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"editRange",{get:function(){return this._rng},enumerable:!0,configurable:!0}),e.prototype.getClipString=function(e){var t=this._g,o="",n=!0,r=H;if(!e)switch(e=t.selection,t.selectionMode){case r.Row:case r.RowRange:e.col=0,e.col2=t.columns.length-1;break;case r.ListBox:e.col=0,e.col2=t.columns.length-1;for(var s=0;s<t.rows.length;s++)t.rows[s].isSelected&&t.rows[s].isVisible&&(e.row=e.row2=s,o&&(o+="\n"),o+=this.getClipString(e));return o}for(var l=(e=i.asType(e,f)).topRow;l<=e.bottomRow;l++)if(t.rows[l].isVisible){n||(o+="\n"),n=!1;for(var a=e.leftCol,h=!0;a<=e.rightCol;a++)if(t.columns[a].isVisible){h||(o+="\t"),h=!1;var c=t.getCellData(l,a,!0);(c=c.replace(/\t/g," ")).indexOf("\n")>-1&&(c='"'+c.replace(/"/g,'""')+'"'),o+=c}}return o},e.prototype.setClipString=function(e,t){var o=this,n=this._g,r=null==t,s=H;if(!t)switch(t=n.selection,n.selectionMode){case s.Row:case s.RowRange:case s.ListBox:t.col=0,t.col2=n.columns.length-1}t=i.asType(t,f);var l=this._parseClipString(i.asString(e));r&&!t.isSingleCell&&l.length&&this._expandClipRows(l,t);var a=new f(t.topRow,t.leftCol,t.topRow+l.length-1,t.leftCol+l[0].length-1),c=new h(n.cells,a);if(!n.onPasting(c))return!1;a=new f(t.topRow,t.leftCol);var u=n.editableCollectionView,d=t.topRow,g=!1;n.deferUpdate(function(){u&&l.length>1&&u.beginUpdate();for(var e=0;e<l.length&&d<n.rows.length;e++,d++)if(n.rows[d].isVisible){for(var r=l[e],s=t.leftCol,p=0;p<r.length&&s<n.columns.length;p++,s++){var _=n.columns[s];if(_.isVisible){if(o._allowEditing(d,s)){var w=r[p];_.maxLength&&(w=w.substr(0,_.maxLength));var m=new h(n.cells,new f(d,s),w);n.onPastingCell(m)&&(u&&(u.editItem(n.rows[d].dataItem),o._edItem=u.currentEditItem),n.cells.setCellData(d,s,m.data)&&(n.onPastedCell(m),g=!0)),a.row2=Math.max(a.row2,d),a.col2=Math.max(a.col2,s)}}else p--}if(o._edItem&&u instanceof i.CollectionView){var v=new i.NotifyCollectionChangedEventArgs(i.NotifyCollectionChangedAction.Change,o._edItem,d);u.onCollectionChanged(v)}}else e--;if(u&&l.length>1&&u.endUpdate(),n.select(a),n.onPasted(c),g&&i.closest(n.hostElement,"form")){var y=i.createElement("<input>",n.hostElement),C=document.createEvent("HTMLEvents");C.initEvent("change",!0,!1),y.dispatchEvent(C),i.removeChild(y)}})},e.prototype._isNativeCheckbox=function(e){return e instanceof HTMLInputElement&&"checkbox"==e.type&&!e.disabled&&!e.readOnly&&i.hasClass(e,"wj-cell-check")&&i.closest(e,".wj-flexgrid")==this._g.hostElement},e.prototype._parseClipString=function(e){var t=[];e=(e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n")).replace(/\n$/,"");var i=0,o=0;for(i=0;i<e.length;i++){var n='"'==e[i]&&e[i+1]>=" ",r=!1,s=!1;for(o=i;o<e.length&&!s;o++){var l=e[o];switch(l){case'"':n&&(r=!r);break;case"\t":case"\n":r||(this._parseClipCell(t,e,i,o,"\n"==l),i=o,s=!0)}}if(o==e.length){this._parseClipCell(t,e,i,o,!1);break}}return 0==t.length&&t.push([""]),t},e.prototype._parseClipCell=function(e,t,i,o,n){e.length||e.push([]);var r=t.substr(i,o-i),s=r.length;s>1&&'"'==r[0]&&'"'==r[s-1]?r=(r=r.substr(1,s-2)).replace(/""/g,'"'):"\t"==r&&(r=""),e[e.length-1].push(r),n&&e.push([])},e.prototype._expandClipRows=function(e,t){for(var i=e.length,o=0,n=0;n<i;n++)o=Math.max(o,e[n].length);for(var r=this._g,s=0,l=0,a=t.topRow;a<=t.bottomRow;a++)r.rows[a].isVisible&&s++;for(h=t.leftCol;h<=t.rightCol;h++)r.columns[h].isVisible&&l++;if((s>1||l>1)&&(1==s&&(s=i),1==l&&(l=o),l%o==0&&s%i==0)){for(var h=o;h<l;h++)for(a=0;a<i;a++)e[a].push(e[a%i][h%o]);for(a=i;a<s;a++)e.push(e[a%i])}},e.prototype._updateEditorCell=function(e,t,i){var o=this._g,n=o.cells.getCellElement(e,t),r=o._useFrozenDiv()&&(e<o.frozenRows||t<o.frozenColumns);if(!n||r||o._hasPendingUpdates())o.refresh(!1);else if(this._updateCell(n),(i=i||o._getHasValidation())&&o.headersVisibility&l.Row){var s=o.rowHeaders,a=s.columns.length-1,h=s.getCellElement(e,a);h&&this._updateCell(h)}},e.prototype._updateCell=function(e){var t=new S(e,null),o=a._WJS_UPDATING;t.panel&&(i.addClass(e,o),t.grid.cellFactory.updateCell(t.panel,t.row,t.col,e,t.range),i.removeClass(e,o))},e.prototype._getValidationError=function(){var e=this._g;if(e._getHasValidation()){var t=this._rng.row,i=this._rng.col,o=e.cellFactory.getEditorValue(e),n=e.getCellData(t,i,!1);if(e.setCellData(t,i,o,!0,!1)){var r=e._getError(e.cells,t,i);return e.setCellData(t,i,n,!0,!1),r}}return null},e.prototype._allowEditing=function(e,t){var i=this._g;if(i.isReadOnly||i.selectionMode==H.None)return!1;if(e<0||e>=i.rows.length||i.rows[e].isReadOnly||!i.rows[e].isVisible)return!1;if(t<0||t>=i.columns.length)return!1;var o=i._getBindingColumn(i.cells,e,i.columns[t]);return!(!o||o.isReadOnly||!o.isVisible)},e.prototype._commitRowEdits=function(){var e=this._g;if(this.finishEditing()&&this._edItem){var t=e.editableCollectionView;if(t&&(t.currentEditItem||t.currentAddItem)){var i=new h(e.cells,e.selection);e.onRowEditEnding(i),t.commitEdit(),e.onRowEditEnded(i)}this._edItem=null}},e.prototype._keydown=function(e){var t=this._edt;switch(e.keyCode){case i.Key.F2:return this._fullEdit=!this._fullEdit,e.preventDefault(),!0;case i.Key.F4:return this._toggleListBox(e),e.preventDefault(),!0;case i.Key.Space:return!t||"checkbox"!=t.type||t.disabled||t.readOnly||(t.checked=!t.checked,this.finishEditing(),e.preventDefault()),!0;case i.Key.Enter:if(e.preventDefault(),t&&e.altKey){var o=e.target;if(o instanceof HTMLTextAreaElement&&"soft"==o.wrap){var n=o.value,r=o.selectionStart,s=o.selectionEnd;o.value=n.substr(0,r)+"\n"+n.substr(s),i.setSelectionRange(o,r+1)}return!0}return!this.finishEditing();case i.Key.Tab:return e.preventDefault(),!this.finishEditing();case i.Key.Escape:return e.preventDefault(),this.finishEditing(!0),!0;case i.Key.Up:case i.Key.Down:case i.Key.Left:case i.Key.Right:case i.Key.PageUp:case i.Key.PageDown:case i.Key.Home:case i.Key.End:if(this._lbx)return this._keydownListBox(e);if(e.altKey)switch(e.keyCode){case i.Key.Up:case i.Key.Down:return this._toggleListBox(e),e.preventDefault(),!0}if(!this._fullEdit&&this.finishEditing())return!1}return!0},e.prototype._keydownListBox=function(e){var t=!0;if(this._lbx)switch(e.keyCode){case i.Key.Up:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex>0&&this._lbx.selectedIndex--;break;case i.Key.Down:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex++;break;case i.Key.Home:case i.Key.PageUp:this._lbx.selectedIndex=0;break;case i.Key.End:case i.Key.PageDown:this._lbx.selectedIndex=this._lbx.collectionView.items.length-1;break;default:t=!1}return!!t&&(e.preventDefault(),!0)},e.prototype._keypress=function(e){var t=this._edt,o=e.charCode||32;if(t&&"checkbox"!=t.type&&i.getActiveElement()==t&&this._list&&this._list.length>0&&o>=32){var n=t.selectionStart,r=t.value.substr(0,n);e.target==t&&e.charCode&&(r+=String.fromCharCode(e.charCode),n++);var s=this._findString(this._list,r,!0);s<0&&(s=this._findString(this._list,r,!1)),s>-1&&(t.value=this._list[s],i.setSelectionRange(t,n,t.value.length),t.dispatchEvent(this._evtInput),e.preventDefault&&e.preventDefault())}},e.prototype._findString=function(e,t,i){i||(t=t.toLowerCase());for(var o=0;o<e.length;o++){var n=e[o];if(i||(n=n.toLowerCase()),0==n.indexOf(t))return o}return-1},e.prototype._toggleListBox=function(e,t){var i=this._g,o=i._selHdl.selection,r=i.isTouching;if(t||(t=o),this._lbx&&(this._removeListBox(),o.contains(t)))return i.activeEditor?i.activeEditor.focus():i.containsFocus()||i.focus(),!0;var s=i._getBindingColumn(i.cells,t.row,i.columns[t.col]);return!(!n()||!s.dataMap||!1===s.showDropDown)&&(!(!n()||!this.startEditing(!0,t.row,t.col,!r,e))&&(this._lbx=this._createListBox(),this._lbx.showSelection(),r&&this._lbx.focus(),!0))},e.prototype._createListBox=function(){var e=this,t=this._g,o=t.activeEditor,r=this._rng,s=t.rows[r.row],l=t._getBindingColumn(t.cells,r.row,t.columns[r.col]),a=document.createElement("div");this._removeListBox(),i.addClass(a,"wj-dropdown-panel wj-grid-listbox"),i.addClass(a,l.dropDownCssClass);var h=new(n().ListBox)(a,{maxHeight:4*s.renderHeight,isContentHtml:l.isContentHtml,itemsSource:l.dataMap.getDisplayValues(s.dataItem),selectedValue:o?o.value:t.getCellData(r.row,r.col,!0)});h.addEventListener(h.hostElement,"click",function(){e._removeListBox(),t.focus(),e.finishEditing()}),h.lostFocus.addHandler(function(){e._removeListBox()}),h.selectedIndexChanged.addHandler(function(){var o=t.activeEditor;o&&(o.value=h.selectedValue,o.dispatchEvent(e._evtInput),i.setSelectionRange(o,0,o.value.length))});var c=t.cells.getCellElement(r.row,r.col);if(c){i.showPopup(a,c,!1,!1,!1);var u=c.querySelector("."+p._WJC_DROPDOWN);i.setAttribute(u,"aria-expanded",!0)}else i.showPopup(a,t.getCellBoundingRect(r.row,r.col)),a[i.Control._OWNR_KEY]=t.hostElement;return h},e.prototype._removeListBox=function(){var e=this._lbx;e&&(this._lbx=null,i.hidePopup(e.hostElement,function(){e.dispose()}))},e}();t._EditHandler=B;var N=function(){function e(e){this._nrt=new k,this._g=e,this._keydownBnd=this._keydown.bind(this),this._attach()}return Object.defineProperty(e.prototype,"newRowAtTop",{get:function(){return this._top},set:function(e){e!=this.newRowAtTop&&(this._top=i.asBoolean(e),this.updateNewRowTemplate())},enumerable:!0,configurable:!0}),e.prototype.updateNewRowTemplate=function(){var e=this._g,t=e.editableCollectionView,i=e.rows,o=t&&t.canAddNew&&e.allowAddNew&&!e.isReadOnly,n=i.indexOf(this._nrt),r=this._top?0:i.length-1,s=!1;if(!o&&n>-1){var l=e.selection;l.row==n&&e.select(l.row-1,l.col),i.removeAt(n)}else o&&(n<0?s=!0:n!=r&&(i.removeAt(n),s=!0),s&&(this._top?i.insert(0,this._nrt):i.push(this._nrt)),this._nrt&&this._nrt._setFlag(_.ParentCollapsed,!1))},e.prototype._attach=function(){var e=this._g;e&&(e.beginningEdit.addHandler(this._beginningEdit,this),e.pastingCell.addHandler(this._beginningEdit,this),e.rowEditEnded.addHandler(this._rowEditEnded,this),e.loadedRows.addHandler(this.updateNewRowTemplate,this),e.hostElement.addEventListener("keydown",this._keydownBnd,!0))},e.prototype._detach=function(){var e=this._g;e&&(e.beginningEdit.removeHandler(this._beginningEdit),e.pastingCell.removeHandler(this._beginningEdit),e.rowEditEnded.removeHandler(this._rowEditEnded),e.loadedRows.removeHandler(this.updateNewRowTemplate),e.hostElement.removeEventListener("keydown",this._keydownBnd,!0))},e.prototype._keydown=function(e){e.defaultPrevented||e.keyCode!=i.Key.Escape||null==this._g.activeEditor&&this._top&&this._nrt.dataItem&&(this._nrt.dataItem=null,this._g.invalidate())},e.prototype._beginningEdit=function(e,t){if(!t.cancel){var o=this._g.rows[t.row];if(i.tryCast(o,k)){var n=this._g.editableCollectionView;if(n&&n.canAddNew)if(this._top){if(null==this._nrt.dataItem){var r=null,s=n.sourceCollection,l=n.newItemCreator;r=i.isFunction(l)?l():s&&s.length?new s[0].constructor:{},this._nrt.dataItem=r}}else{r=n.currentAddItem&&n.currentAddItem==o.dataItem?n.currentAddItem:n.addNew();n.moveCurrentTo(r),this.updateNewRowTemplate(),this._g.refresh(!0),this._g.onRowAdded(t),t.cancel&&n.cancelNew()}}}},e.prototype._rowEditEnded=function(e,t){var i=this,o=this._g,n=o.editableCollectionView,r=this._nrt.dataItem;if(n&&!this._committing)if(n.isAddingNew)n.commitNew();else if(r&&!t.cancel){this._committing=!0,this._nrt.dataItem=null;var s=n.addNew();for(var l in r)s[l]=r[l];o.onRowAdded(t),t.cancel?n.cancelNew():n.commitNew(),setTimeout(function(){o.select(0,o.columns.firstVisibleIndex),i.updateNewRowTemplate()},20),this._committing=!1}},e}();t._AddNewHandler=N;var k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t}(v);t._NewRowTemplate=k;var F=function(){function e(t){this._updateImeFocusBnd=this._updateImeFocus.bind(this),this._cmpstartBnd=this._compositionstart.bind(this),this._mousedownBnd=this._mousedown.bind(this),this._mouseupBnd=this._mouseup.bind(this),this._keypressBnd=this._keypress.bind(this),this._g=t;var o=i.createElement('<textarea class="wj-grid-editor wj-form-control wj-grid-ime" aria-hidden="true"/>');i.disableAutoComplete(o),i.setCss(o,e._cssHidden),this._tbx=o,t.cells.hostElement.parentElement.appendChild(o),this._updateImeFocus();var n=t.hostElement,r=t.addEventListener.bind(t);r(o,"compositionstart",this._cmpstartBnd),r(n,"blur",this._updateImeFocusBnd),r(n,"focus",this._updateImeFocusBnd),r(n,"mousedown",this._mousedownBnd,!0),r(n,"mouseup",this._mouseupBnd,!0),r(n,"keypress",this._keypressBnd,!0),t.cellEditEnded.addHandler(this._cellEditEnded,this),t.selectionChanged.addHandler(this._updateImeFocus,this)}return e.prototype.dispose=function(){var e=this._g,t=e.hostElement,o=this._tbx,n=e.removeEventListener.bind(e);n(o,"compositionstart",this._cmpstartBnd),n(t,"blur",this._updateImeFocusBnd),n(t,"focus",this._updateImeFocusBnd),n(t,"mousedown",this._mousedownBnd),n(t,"mouseup",this._mouseupBnd),n(t,"keypress",this._keypressBnd),e.cellEditEnded.removeHandler(this._cellEditEnded),e.selectionChanged.removeHandler(this._updateImeFocus),i.removeChild(o)},e.prototype._compositionstart=function(){var e=this._g;if(null==e.activeEditor){var t=e._selHdl.selection;if(e.startEditing(!1,t.row,t.col,!1)&&e.activeEditor){t=e.editRange;var o=e.activeEditor,n=this._tbx,r=e.cells.hostElement,s=e.columns[t.col].pos+r.offsetLeft,l=e.rows[t.row].pos+r.offsetTop,a=e.getCellBoundingRect(t.row,t.col),h=o.parentElement,c=getComputedStyle(h),u=h.style.zIndex;t.isSingleCell||(a.width=h.offsetWidth,a.height=h.offsetHeight),t.row<e.frozenRows&&(l+=r.parentElement.scrollTop),t.col<e.frozenColumns&&(s+=r.parentElement.scrollLeft);var d=h.querySelector(".wj-btn.wj-right");d&&(a.width-=d.offsetWidth),"minLength,maxLength,pattern".split(",").forEach(function(e){i.setAttribute(n,e,o.getAttribute(e))}),i.setAttribute(n,"wrap",o instanceof HTMLTextAreaElement?"soft":"off"),i.setCss(n,{position:"absolute",left:s,top:l,width:a.width-1,height:a.height-1,paddingLeft:c.paddingLeft,paddingTop:c.paddingTop,zIndex:u}),e._edtHdl._edt=n,o.value=""}}},e.prototype._cellEditEnded=function(){var t=this;i.setCss(this._tbx,e._cssHidden),setTimeout(function(){t._tbx.value=""})},e.prototype._mousedown=function(e){this._isMouseDown=!0,this._updateImeFocus()},e.prototype._mouseup=function(e){this._isMouseDown=!1,this._updateImeFocus()},e.prototype._keypress=function(e){null==this._g.activeEditor&&(this._tbx.value="",this._compositionstart(),e.stopPropagation())},e.prototype._updateImeFocus=function(){var e=this._g,t=i.getActiveElement();if(!e.activeEditor&&i.closest(t,".wj-flexgrid")==e.hostElement){var o=this._tbx;this._enableIme()?t!=o&&(o.disabled=!1,o.select(),o.focus()):o.disabled=!0}},e.prototype._enableIme=function(){var e=this._g,t=e.selection,o=t.isValid?e._getBindingColumn(e.cells,t.row,e.columns[t.col]):null;return!!e.canEditCell(t.row,t.col)&&!(!o||o.dataType==i.DataType.Boolean)},e._cssHidden={position:"fixed",left:-10,top:-10,width:"1px",overflow:"hidden"},e}();t._ImeHandler=F});