/*
    *
    * Wijmo Library 5.20182.500
    * 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 t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();define(["require","exports","wijmo/wijmo.grid","wijmo/wijmo","wijmo/wijmo.input","wijmo/wijmo.grid.filter"],function(t,e,i,n,r,a){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var l=a||e;window.wijmo=window.wijmo||{},window.wijmo.grid=window.wijmo.grid||{},window.wijmo.grid.filter=l;var o=function(){function t(t){this._maxValues=250,this._sortValues=!0,this._col=t,this._bnd=t.binding?new n.Binding(t.binding):null}return Object.defineProperty(t.prototype,"showValues",{get:function(){return this._values},set:function(t){this._values=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filterText",{get:function(){return this._filterText},set:function(t){this._filterText=n.asString(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxValues",{get:function(){return this._maxValues},set:function(t){this._maxValues=n.asNumber(t,!1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"uniqueValues",{get:function(){return this._uniqueValues},set:function(t){this._uniqueValues=n.asArray(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sortValues",{get:function(){return this._sortValues},set:function(t){this._sortValues=n.asBoolean(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataMap",{get:function(){return this._map},set:function(t){this._map=n.asType(t,i.DataMap,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isActive",{get:function(){return null!=this._values&&Object.keys(this._values).length>0},enumerable:!0,configurable:!0}),t.prototype.apply=function(t){var e=this.column;return!(this._bnd&&this._values&&Object.keys(this._values).length)||(t=this._bnd.getValue(t),t=this.dataMap?this.dataMap.getDisplayValue(t):e.dataMap?e.dataMap.getDisplayValue(t):n.Globalize.format(t,e.format),void 0!=this._values[t])},t.prototype.clear=function(){this.showValues=null,this.filterText=null},t.prototype.implementsInterface=function(t){return"IColumnFilter"==t},t.prototype._getUniqueValues=function(t,e){var i=[];if(this.uniqueValues){for(var r=this.uniqueValues,a=0;a<r.length;a++){u=r[a];i.push({value:u,text:u.toString()})}return i}var l={},o=t.collectionView,s=o?o.sourceCollection:[];if(e&&o&&o.sourceCollection&&o.filter){var c=this.showValues;this.showValues=null;for(var d=[],a=0;a<s.length;a++)o.filter(s[a])&&d.push(s[a]);s=d,this.showValues=c}for(a=0;a<s.length;a++){var u=t._binding.getValue(s[a]),p=this.dataMap?this.dataMap.getDisplayValue(u):t.dataMap?t.dataMap.getDisplayValue(u):n.Globalize.format(u,t.format);l[p]||(l[p]=!0,i.push({value:u,text:p}))}return i},t}();e.ValueFilter=o;var s=function(t){function e(e,i){var a=t.call(this,e)||this;a._filter=n.asType(i,o,!1);var l=a.getTemplate();a.applyTemplate("wj-control",l,{_divFilter:"div-filter",_cbSelectAll:"cb-select-all",_spSelectAll:"sp-select-all",_divValues:"div-values"}),a._cbSelectAll.tabIndex=0;var s=n.culture.FlexGridFilter;if(n.setText(a._spSelectAll,s.selectAll),a._view=new n.CollectionView,i.sortValues){var c=i.column.dataMap||i.dataMap?"text":"value",d=i.column.dataType!=n.DataType.Boolean;a._view.sortDescriptions.push(new n.SortDescription(c,d))}return a._view.filter=a._filterValues.bind(a),a._view.collectionChanged.addHandler(a._updateSelectAllCheck,a),a._filterText="",a._cmbFilter=new r.ComboBox(a._divFilter,{placeholder:s.search}),a._lbValues=new r.ListBox(a._divValues,{displayMemberPath:"text",checkedMemberPath:"show",itemsSource:a._view,itemFormatter:function(t,e){return e||s.null},gotFocus:function(t,e){t.selectedIndex<0&&(t.selectedIndex=0)}}),n.setAriaLabel(a._cmbFilter.inputElement,s.ariaLabels.search),a._cmbFilter.textChanged.addHandler(a._filterTextChanged,a),a._cbSelectAll.addEventListener("click",a._cbSelectAllClicked.bind(a)),a.updateEditor(),a}return __extends(e,t),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),e.prototype.updateEditor=function(){var t=this,e=this._filter.column,i=this._filter._getUniqueValues(e,!0);this._lbValues.isContentHtml=e.isContentHtml;var n=this._filter.showValues;if(n&&0!=Object.keys(n).length){for(var r in n)for(a=0;a<i.length;a++)if(i[a].text==r){i[a].show=!0;break}}else for(var a=0;a<i.length;a++)i[a].show=!0;this._view.pageSize=20,this._view.sourceCollection=i,this._view.moveCurrentTo(null),setTimeout(function(){t._view.pageSize=t._filter.maxValues,t._cmbFilter.text=t._filter.filterText,t._filterText=t._cmbFilter.text.toLowerCase()})},e.prototype.clearEditor=function(){this._cmbFilter.text="",this._filterText="",this._view.pageSize=0,this._view.refresh();for(var t=this._view.items,e=0;e<t.length;e++)t[e].show=!1;this._view.pageSize=this._filter.maxValues},e.prototype.updateFilter=function(){var t=null,e=this._view.items;if(this._filterText||this._cbSelectAll.indeterminate){t={};for(var i=0;i<e.length;i++){var n=e[i];n.show&&(t[n.text]=!0)}}this._filter.showValues=t,this._filter.filterText=""},e.prototype._filterTextChanged=function(){var t=this;this._toText&&clearTimeout(this._toText),this._toText=setTimeout(function(){var e=t._cmbFilter.text.toLowerCase(),i=e!=t._filterText;t._filterText=e,t._view.refresh(),i&&(t._cbSelectAll.checked=!0,t._cbSelectAllClicked())},300)},e.prototype._filterValues=function(t){return!this._filterText||!(!t||!t.text)&&t.text.toLowerCase().indexOf(this._filterText)>-1},e.prototype._cbSelectAllClicked=function(){for(var t=this._cbSelectAll.checked,e=this._view.items,i=0;i<e.length;i++)e[i].show=t;this._view.refresh()},e.prototype._updateSelectAllCheck=function(){for(var t=0,e=this._view.items,i=0;i<e.length;i++)e[i].show&&t++;0==t?(this._cbSelectAll.checked=!1,this._cbSelectAll.indeterminate=!1):t==e.length?(this._cbSelectAll.checked=!0,this._cbSelectAll.indeterminate=!1):this._cbSelectAll.indeterminate=!0},e.controlTemplate='<div><div wj-part="div-filter"></div><div class="wj-listbox-item"><label><input wj-part="cb-select-all" type="checkbox"> <span wj-part="sp-select-all"></span></label></div><div wj-part="div-values"></div></div>',e}(n.Control);e.ValueFilterEditor=s;var c=function(){function t(t){this._c1=new u(this),this._c2=new u(this),this._and=!0,this._col=t,this._bnd=t.binding?new n.Binding(t.binding):null}return Object.defineProperty(t.prototype,"condition1",{get:function(){return this._c1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"condition2",{get:function(){return this._c2},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"and",{get:function(){return this._and},set:function(t){this._and=n.asBoolean(t),this._bnd=this._col&&this._col.binding?new n.Binding(this._col.binding):null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataMap",{get:function(){return this._map},set:function(t){this._map=n.asType(t,i.DataMap,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isActive",{get:function(){return this._c1.isActive||this._c2.isActive},enumerable:!0,configurable:!0}),t.prototype.apply=function(t){var e=this._col,i=this._c1,r=this._c2;if(!this._bnd||!this.isActive)return!0;t=this._bnd.getValue(t),e.dataMap?t=e.dataMap.getDisplayValue(t):n.isDate(t)?(n.isString(i.value)||n.isString(r.value))&&(t=n.Globalize.format(t,e.format)):n.isNumber(t)&&(t=n.Globalize.parseFloat(n.Globalize.format(t,e.format)));var a=i.apply(t),l=r.apply(t);return i.isActive&&r.isActive?this._and?a&&l:a||l:i.isActive?a:!r.isActive||l},t.prototype.clear=function(){this._c1.clear(),this._c2.clear(),this.and=!0},t.prototype.implementsInterface=function(t){return"IColumnFilter"==t},t}();e.ConditionFilter=c;var d=function(t){function e(e,i){var r=t.call(this,e)||this;r._filter=n.asType(i,c,!1);var a=r.getTemplate();r.applyTemplate("wj-control",a,{_divHdr:"div-hdr",_divCmb1:"div-cmb1",_divVal1:"div-val1",_btnAnd:"btn-and",_btnOr:"btn-or",_spAnd:"sp-and",_spOr:"sp-or",_divCmb2:"div-cmb2",_divVal2:"div-val2"});var l=n.culture.FlexGridFilter,o=l.ariaLabels;n.setAriaLabel(r._btnAnd,o.and),n.setAriaLabel(r._btnOr,o.or),n.setText(r._divHdr,l.header),n.setText(r._spAnd,l.and),n.setText(r._spOr,l.or),r._cmb1=r._createOperatorCombo(r._divCmb1,o.op1),r._cmb2=r._createOperatorCombo(r._divCmb2,o.op2),r._val1=r._createValueInput(r._divVal1,o.val1),r._val2=r._createValueInput(r._divVal2,o.val2);var s=r.hostElement;return r.addEventListener(s,"change",r._btnAndOrChanged.bind(r)),r.addEventListener(s,"keydown",r._keydown.bind(r)),r.updateEditor(),r}return __extends(e,t),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),e.prototype.updateEditor=function(){var t=this._filter.condition1,e=this._filter.condition2;this._cmb1.selectedValue=t.operator,this._cmb2.selectedValue=e.operator,this._val1 instanceof r.ComboBox?(this._val1.text=n.changeType(t.value,n.DataType.String,null),this._val2.text=n.changeType(e.value,n.DataType.String,null)):(this._val1.value=t.value,this._val2.value=e.value);var i=this._filter.and;this._checkRadio(this._btnAnd,i),this._checkRadio(this._btnOr,!i)},e.prototype.clearEditor=function(){this._cmb1.selectedValue=this._cmb2.selectedValue=null,this._val1.text=this._val2.text=null,this._checkRadio(this._btnAnd,!0),this._checkRadio(this._btnOr,!1)},e.prototype.updateFilter=function(){var t=this._filter.column,e=this._filter.condition1,i=this._filter.condition2;if(e.operator=this._cmb1.selectedValue,i.operator=this._cmb2.selectedValue,this._val1 instanceof r.ComboBox){var a=t.dataType==n.DataType.Date?n.DataType.String:t.dataType;e.value=n.changeType(this._val1.text,a,t.format),i.value=n.changeType(this._val2.text,a,t.format)}else e.value=this._val1.value,i.value=this._val2.value;this._filter.and=this._btnAnd.checked},e.prototype._createOperatorCombo=function(t,e){var i=this._filter.column,a=n.culture.FlexGridFilter,l=a.stringOperators,o=this._filter.dataMap||i.dataMap,s=n.DataType;i.dataType==s.Date&&this._hasDatePart(i.format)?l=a.dateOperators:i.dataType!=s.Number||o?i.dataType!=s.Boolean||o||(l=a.booleanOperators):l=a.numberOperators;var c=new r.ComboBox(t,{itemsSource:l,displayMemberPath:"name",selectedValuePath:"op"});return n.setAriaLabel(c.inputElement,e),c},e.prototype._createValueInput=function(t,e){var i=this._filter.column,a=this._filter.dataMap||i.dataMap,l=null,o=n.DataType;return i.dataType==o.Date&&this._hasDatePart(i.format)?(l=this._hasTimePart(i.format)?new r.InputDateTime(t):new r.InputDate(t)).format=i.format:i.dataType!=o.Number||a?(l=new r.ComboBox(t),a?(l.itemsSource=a.getDisplayValues(),l.isEditable=!0):i.dataType==o.Boolean&&(l.itemsSource=[!0,!1])):(l=new r.InputNumber(t)).format=i.format,l.isRequired=!1,n.setAriaLabel(l.inputElement,e),l},e.prototype._hasDatePart=function(t){return!t||(t=n.culture.Globalize.calendar.patterns[t]||t,/[yMd]+/.test(t))},e.prototype._hasTimePart=function(t){return!!t&&(t=n.culture.Globalize.calendar.patterns[t]||t,/[Hmst]+/.test(t))},e.prototype._btnAndOrChanged=function(t){var e=t.target==this._btnAnd,i=t.target==this._btnOr;(e||i)&&(this._checkRadio(this._btnAnd,e),this._checkRadio(this._btnOr,i))},e.prototype._checkRadio=function(t,e){t.checked=e,t.setAttribute("aria-checked",e.toString()),t.setAttribute("tabindex",e?"1":"-1")},e.prototype._keydown=function(t){var e=t.target==this._btnAnd,i=t.target==this._btnOr;if(e||i)switch(t.keyCode){case n.Key.Left:case n.Key.Right:case n.Key.Up:case n.Key.Down:var r=e?this._btnOr:this._btnAnd;r.click(),r.focus(),t.preventDefault()}},e.controlTemplate='<div><div wj-part="div-hdr"></div><div wj-part="div-cmb1"></div><br/><div wj-part="div-val1"></div><br/><div role="radiogroup" style="text-align:center"><label><input wj-part="btn-and" type="radio" role="radio"> <span wj-part="sp-and"></span> </label>&nbsp;&nbsp;&nbsp;<label><input wj-part="btn-or" type="radio" role="radio"> <span wj-part="sp-or"></span> </label></div><div wj-part="div-cmb2"></div><br/><div wj-part="div-val2"></div><br/></div>',e}(n.Control);e.ConditionFilterEditor=d;var u=function(){function t(t){this._op=null,this._filter=t}return Object.defineProperty(t.prototype,"operator",{get:function(){return this._op},set:function(t){this._op=n.asEnum(t,p,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._val},set:function(t){if(this._val=t,this._strVal=n.isString(t)?t.toString().toLowerCase():null,this._mapVal=null,this._filter){var e=this._filter.dataMap||this._filter.column.dataMap;e&&(this._mapVal=e.getDisplayValue(t),n.isString(this._mapVal)&&(this._strVal=this._mapVal=this._mapVal.toLowerCase()))}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isActive",{get:function(){switch(this._op){case null:return!1;case p.EQ:case p.NE:return!0;default:return null!=this._val||null!=this._strVal}},enumerable:!0,configurable:!0}),t.prototype.clear=function(){this.operator=null,this.value=null},t.prototype.apply=function(t){var e=this._mapVal||this._strVal||this._val;switch(n.isString(t)&&(t=t.toLowerCase()),n.isString(e)&&null==t&&(t=""),this._op){case null:return!0;case p.EQ:return n.isDate(t)&&n.isDate(e)?n.DateTime.sameDate(t,e):t==e;case p.NE:return t!=e;case p.GT:return t>e;case p.GE:return t>=e;case p.LT:return t<e;case p.LE:return t<=e;case p.BW:return!(!this._strVal||!n.isString(t))&&0==t.indexOf(this._strVal);case p.EW:return!!(this._strVal&&n.isString(t)&&t.length>=this._strVal.length)&&t.substr(t.length-this._strVal.length)==e;case p.CT:return!(!this._strVal||!n.isString(t))&&t.indexOf(this._strVal)>-1;case p.NC:return!(!this._strVal||!n.isString(t))&&t.indexOf(this._strVal)<0}throw"Unknown operator"},t}();e.FilterCondition=u;var p;!function(t){t[t.EQ=0]="EQ",t[t.NE=1]="NE",t[t.GT=2]="GT",t[t.GE=3]="GE",t[t.LT=4]="LT",t[t.LE=5]="LE",t[t.BW=6]="BW",t[t.EW=7]="EW",t[t.CT=8]="CT",t[t.NC=9]="NC"}(p=e.Operator||(e.Operator={}));var h=function(){function t(t,e){this._owner=t,this._col=e,this._valueFilter=new o(e),this._conditionFilter=new c(e)}return Object.defineProperty(t.prototype,"filterType",{get:function(){return null!=this._filterType?this._filterType:this._owner.defaultFilterType},set:function(t){if((t=n.asEnum(t,_,!0))!=this._filterType){var e=this.isActive;this.clear(),this._filterType=t,e?this._owner.apply():this._col.grid&&this._col.grid.invalidate()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataMap",{get:function(){return this.conditionFilter.dataMap||this.valueFilter.dataMap},set:function(t){this.conditionFilter.dataMap=t,this.valueFilter.dataMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"valueFilter",{get:function(){return this._valueFilter},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"conditionFilter",{get:function(){return this._conditionFilter},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"column",{get:function(){return this._col},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isActive",{get:function(){return this._conditionFilter.isActive||this._valueFilter.isActive},enumerable:!0,configurable:!0}),t.prototype.apply=function(t){return this._conditionFilter.apply(t)&&this._valueFilter.apply(t)},t.prototype.clear=function(){this._valueFilter.clear(),this._conditionFilter.clear()},t.prototype.implementsInterface=function(t){return"IColumnFilter"==t},t}();e.ColumnFilter=h,n._addCultureInfo("FlexGridFilter",{ariaLabels:{edit:"Edit Filter for Column",dialog:"Filter Editor for Column",asc:"Sort Column in Ascending Order",dsc:"Sort Column in Descending Order",search:"Search Item List",op1:"First Condition Operator",val1:"First Condition Value",and:"Require both Conditions",or:"Require either Condition",op2:"Second Condition Operator",val2:"Second Condition Value"},ascending:"↑ Ascending",descending:"↓ Descending",apply:"Apply",cancel:"Cancel",clear:"Clear",conditions:"Filter by Condition",values:"Filter by Value",search:"Search",selectAll:"Select All",null:"(nothing)",header:"Show items where the value",and:"And",or:"Or",stringOperators:[{name:"(not set)",op:null},{name:"Equals",op:p.EQ},{name:"Does not equal",op:p.NE},{name:"Begins with",op:p.BW},{name:"Ends with",op:p.EW},{name:"Contains",op:p.CT},{name:"Does not contain",op:p.NC}],numberOperators:[{name:"(not set)",op:null},{name:"Equals",op:p.EQ},{name:"Does not equal",op:p.NE},{name:"Is Greater than",op:p.GT},{name:"Is Greater than or equal to",op:p.GE},{name:"Is Less than",op:p.LT},{name:"Is Less than or equal to",op:p.LE}],dateOperators:[{name:"(not set)",op:null},{name:"Equals",op:p.EQ},{name:"Is Before",op:p.LT},{name:"Is After",op:p.GT}],booleanOperators:[{name:"(not set)",op:null},{name:"Equals",op:p.EQ},{name:"Does not equal",op:p.NE}]});var f=function(t){function e(e,i,r){void 0===r&&(r=!0);var a=t.call(this,e,null,!0)||this;a.filterChanged=new n.Event,a.buttonClicked=new n.Event,a._filter=n.asType(i,h);var l=a.getTemplate();a.applyTemplate("wj-control wj-content wj-columnfiltereditor",l,{_divSort:"div-sort",_btnAsc:"btn-asc",_btnDsc:"btn-dsc",_divType:"div-type",_aVal:"a-val",_aCnd:"a-cnd",_divEdtVal:"div-edt-val",_divEdtCnd:"div-edt-cnd",_btnApply:"btn-apply",_btnCancel:"btn-cancel",_btnClear:"btn-clear"});var o=n.culture.FlexGridFilter,s=o.ariaLabels,c=a.hostElement,d=a.filter.column,u=d.grid.collectionView;n.setAttribute(c,"role","dialog"),n.setAriaLabel(c,s.dialog+" "+d.header),n.setAriaLabel(a._btnAsc,s.asc),n.setAriaLabel(a._btnDsc,s.dsc),n.setText(a._btnAsc,o.ascending),n.setText(a._btnDsc,o.descending),n.setText(a._aVal,o.values),n.setText(a._aCnd,o.conditions),n.setText(a._btnApply,o.apply),n.setText(a._btnCancel,o.cancel),n.setText(a._btnClear,o.clear);var p=a.filter.conditionFilter.isActive||0==(i.filterType&_.Value)?_.Condition:_.Value;a._showFilter(p),r&&u&&u.canSort||(a._divSort.style.display="none");var f=a._btnClicked.bind(a);return a._btnApply.addEventListener("click",f),a._btnCancel.addEventListener("click",f),a._btnClear.addEventListener("click",f),a._btnAsc.addEventListener("click",f),a._btnDsc.addEventListener("click",f),a._aVal.addEventListener("click",f),a._aCnd.addEventListener("click",f),c.addEventListener("keydown",function(t){if(!t.defaultPrevented){var e=t.target.tagName.match(/^(a|button)$/i);switch(t.keyCode){case n.Key.Space:e&&(a._btnClicked(t),t.preventDefault());break;case n.Key.Enter:e?a._btnClicked(t):(a.updateFilter(),a.onFilterChanged(),a.onButtonClicked()),t.preventDefault();break;case n.Key.Escape:a.onButtonClicked(),t.preventDefault();break;case n.Key.Tab:n.moveFocus(a.hostElement,t.shiftKey?-1:1),t.preventDefault()}}}),a}return __extends(e,t),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),e.prototype.updateEditor=function(){this._edtVal&&this._edtVal.updateEditor(),this._edtCnd&&this._edtCnd.updateEditor()},e.prototype.updateFilter=function(){switch(this._getFilterType()){case _.Value:this._edtVal.updateFilter(),this.filter.conditionFilter.clear();break;case _.Condition:this._edtCnd.updateFilter(),this.filter.valueFilter.clear()}},e.prototype.onFilterChanged=function(t){this.filterChanged.raise(this,t)},e.prototype.onButtonClicked=function(t){this.buttonClicked.raise(this,t)},e.prototype._handleResize=function(){this.isTouching||this._wasTouching||this.onButtonClicked()},e.prototype._showFilter=function(t){switch(this._wasTouching=this.isTouching,t==_.Value&&null==this._edtVal&&(this._edtVal=new s(this._divEdtVal,this.filter.valueFilter)),t==_.Condition&&null==this._edtCnd&&(this._edtCnd=new d(this._divEdtCnd,this.filter.conditionFilter)),0!=(t&this.filter.filterType)&&(t==_.Value?(this._divEdtVal.style.display="",this._divEdtCnd.style.display="none",this._enableLink(this._aVal,!1),this._enableLink(this._aCnd,!0),this._edtVal.focus()):(this._divEdtVal.style.display="none",this._divEdtCnd.style.display="",this._enableLink(this._aVal,!0),this._enableLink(this._aCnd,!1),this._edtCnd.focus())),this.filter.filterType){case _.None:case _.Condition:case _.Value:this._divType.style.display="none";break;default:this._divType.style.display=""}},e.prototype._enableLink=function(t,e){n.toggleClass(t,"wj-state-disabled",!e),n.setAttribute(t,"href",e?"":null),n.setAttribute(t,"disabled",e?null:"disabled")},e.prototype._getFilterType=function(){var t=_;return"none"!=this._divEdtVal.style.display?t.Value:t.Condition},e.prototype._btnClicked=function(t){if(t.preventDefault(),t.stopPropagation(),!n.hasClass(t.target,"wj-state-disabled")){if(t.target==this._aVal)return this._showFilter(_.Value),void n.moveFocus(this._edtVal.hostElement,0);if(t.target==this._aCnd)return this._showFilter(_.Condition),void n.moveFocus(this._edtCnd.hostElement,0);if(t.target==this._btnAsc||t.target==this._btnDsc){var e=this.filter.column,i=e.sortMemberPath?e.sortMemberPath:e.binding,r=e.grid.collectionView,a=new n.SortDescription(i,t.target==this._btnAsc);r.sortDescriptions.deferUpdate(function(){r.sortDescriptions.clear(),r.sortDescriptions.push(a)})}t.target==this._btnApply?(this.updateFilter(),this.onFilterChanged()):t.target==this._btnClear?this.filter.isActive&&(this.filter.clear(),this.onFilterChanged()):this.updateEditor(),this.onButtonClicked()}},e.controlTemplate='<div><div wj-part="div-sort"><button wj-part="btn-asc" class="wj-btn" style="min-width:95px"></button>&nbsp;&nbsp;&nbsp;<button wj-part="btn-dsc" class="wj-btn" style="min-width:95px"></button></div><div wj-part="div-type" class="wj-filtertype"><a wj-part="a-cnd" href="" draggable="false"></a>&nbsp;|&nbsp;<a wj-part="a-val" href="" draggable="false"></a></div><div wj-part="div-edt-val" tabindex="-1"></div><div wj-part="div-edt-cnd" tabindex="-1"></div><div style="text-align:right;margin-top:10px"><button wj-part="btn-apply" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-cancel" class="wj-btn"></button>&nbsp;&nbsp;<button wj-part="btn-clear" class="wj-btn"></button></div>',e}(n.Control);e.ColumnFilterEditor=f;var _;!function(t){t[t.None=0]="None",t[t.Condition=1]="Condition",t[t.Value=2]="Value",t[t.Both=3]="Both"}(_=e.FilterType||(e.FilterType={}));var b=function(){function t(t,e){this._showIcons=!0,this._showSort=!0,this._defFilterType=_.Both,this.filterApplied=new n.Event,this.filterChanging=new n.Event,this.filterChanged=new n.Event;var a="Missing dependency: FlexGridFilter requires ";n.assert(null!=i,a+"wijmo.grid."),n.assert(null!=r,a+"wijmo.input."),this._filters=[],this._g=n.asType(t,i.FlexGrid,!1),this._g.formatItem.addHandler(this._formatItem.bind(this)),this._g.itemsSourceChanged.addHandler(this.clear.bind(this));var l=this._g.hostElement;t.addEventListener(l,"mousedown",this._mousedown.bind(this),!0),t.addEventListener(l,"click",this._click.bind(this),!0),t.addEventListener(l,"keydown",this._keydown.bind(this),!0),this._g.invalidate(),e&&n.copy(this,e)}return Object.defineProperty(t.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filterColumns",{get:function(){return this._filterColumns},set:function(t){this._filterColumns=n.asArray(t),this.clear()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showFilterIcons",{get:function(){return this._showIcons},set:function(t){t!=this.showFilterIcons&&(this._showIcons=n.asBoolean(t),this._g&&this._g.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showSortButtons",{get:function(){return this._showSort},set:function(t){this._showSort=n.asBoolean(t)},enumerable:!0,configurable:!0}),t.prototype.getColumnFilter=function(t,e){void 0===e&&(e=!0),t=this._asColumn(t);for(var i=0;i<this._filters.length;i++)if(this._filters[i].column==t)return this._filters[i];if(e&&t.binding){var n=new h(this,t);return this._filters.push(n),n}return null},Object.defineProperty(t.prototype,"defaultFilterType",{get:function(){return this._defFilterType},set:function(t){(t=n.asEnum(t,_,!1))!=this.defaultFilterType&&(this._defFilterType=t,this._g.invalidate(),this.clear())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filterDefinition",{get:function(){for(var t={defaultFilterType:this.defaultFilterType,filters:[]},e=0;e<this._filters.length;e++){var i=this._filters[e];if(i&&i.column&&i.column.binding)if(i.conditionFilter.isActive){var n=i.conditionFilter;t.filters.push({binding:i.column.binding,type:"condition",condition1:{operator:n.condition1.operator,value:n.condition1.value},and:n.and,condition2:{operator:n.condition2.operator,value:n.condition2.value}})}else if(i.valueFilter.isActive){var r=i.valueFilter;t.filters.push({binding:i.column.binding,type:"value",filterText:r.filterText,showValues:r.showValues})}}return JSON.stringify(t)},set:function(t){if(t=n.asString(t),this.clear(),t){var e=JSON.parse(t);this.defaultFilterType=e.defaultFilterType;for(var i=0;i<e.filters.length;i++){var r=e.filters[i],a=this._g.getColumn(r.binding),l=this.getColumnFilter(a,!0);if(l)switch(r.type){case"condition":var o=l.conditionFilter;o.condition1.value=a.dataType==n.DataType.Date?n.changeType(r.condition1.value,a.dataType,null):r.condition1.value,o.condition1.operator=r.condition1.operator,o.and=r.and,o.condition2.value=a.dataType==n.DataType.Date?n.changeType(r.condition2.value,a.dataType,null):r.condition2.value,o.condition2.operator=r.condition2.operator;break;case"value":var s=l.valueFilter;s.filterText=r.filterText,s.showValues=r.showValues}}}this.apply()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"activeEditor",{get:function(){return n.Control.getControl(this._divEdt)},enumerable:!0,configurable:!0}),t.prototype.editColumnFilter=function(t,e){var r=this;this.closeEditor(),t=this._asColumn(t);var a=document.createElement("div"),l=this.getColumnFilter(t),o=new f(a,l,this.showSortButtons);n.addClass(a,"wj-dropdown-panel"),this._divEdt=a,this._edtCol=t;var s=new i.CellRangeEventArgs(this._g.cells,new i.CellRange(-1,t.index));if(this.onFilterChanging(s)){s.cancel=!0,this._g.rightToLeft&&(a.dir="rtl"),o.filterChanged.addHandler(function(){s.cancel=!1,setTimeout(function(){s.cancel||r.apply()})}),o.buttonClicked.addHandler(function(){r.closeEditor(),r._g.focus(),r.onFilterChanged(s)}),o.lostFocus.addHandler(function(){setTimeout(function(){var t=n.Control.getControl(r._divEdt);t&&!t.containsFocus()&&r.closeEditor()},10)});var c=this._g;c._edtHdl._commitRowEdits(),c.scrollIntoView(-1,t.index,!0);var d=this._g.columnHeaders,u=e&&e.panel==d?e.row:d.rows.length-1,p=e?e.col:t.index,h=d.getCellBoundingRect(u,p),_=d.getCellElement(u,p);_?n.showPopup(a,_,!1,!1,!1):n.showPopup(a,h),this._setAriaExpanded(_,!0),this._setAriaExpanded(c.cells.getCellElement(-1,p),!0);for(var b=o.hostElement.querySelectorAll("input"),v=0;v<b.length;v++){var g=b[v];if(g.offsetHeight>0&&g.tabIndex>-1&&!g.disabled){g.focus();break}}o.containsFocus()||o.focus()}else this._divEdt=this._edtCol=null},t.prototype._setAriaExpanded=function(e,i){if(e){var r=e.querySelector("."+t._WJC_FILTER);n.setAttribute(r,"aria-expanded",i)}},t.prototype.closeEditor=function(){var t=this._g,e=n.Control.getControl(this._divEdt),i=this._edtCol;if(e&&n.hidePopup(e.hostElement,function(){e.dispose()}),i){var r=t.columnHeaders,a=r.rows.length?r.getCellElement(r.rows.length-1,i.index):null;this._setAriaExpanded(a,!1),a=t.cells.getCellElement(-1,i.index),this._setAriaExpanded(a,!1)}this._divEdt=null,this._edtCol=null},t.prototype.apply=function(){var t=this._g.collectionView;if(t){var e=this._g.editableCollectionView;e&&(e.commitEdit(),e.commitNew()),t.filter=this._filter.bind(this)}var i=t?t.updateFilterDefinition:null;n.isFunction(i)&&i.call(t,this),this.onFilterApplied()},t.prototype.clear=function(){this._filters.length&&(this._filters=[],this.apply())},t.prototype.onFilterApplied=function(t){this.filterApplied.raise(this,t)},t.prototype.onFilterChanging=function(t){return this.filterChanging.raise(this,t),!t.cancel},t.prototype.onFilterChanged=function(t){this.filterChanged.raise(this,t)},t.prototype._asColumn=function(t){return n.isString(t)?this._g.getColumn(t):n.isNumber(t)?this._g.columns[t]:n.asType(t,i.Column,!1)},t.prototype._filter=function(t){for(var e=0;e<this._filters.length;e++)if(!this._filters[e].apply(t))return!1;return!0},t.prototype._formatItem=function(t,e){if(e.panel==t.columnHeaders){var r=this._g,a=r.getMergedRange(e.panel,e.row,e.col)||new i.CellRange(e.row,e.col),l=r.columns[a.col],o=r._getBindingColumn(e.panel,e.row,l),s=e.cell;if(a.row2==e.panel.rows.length-1||l!=o){var c=this.getColumnFilter(o,this.defaultFilterType!=_.None);this._filterColumns&&this._filterColumns.indexOf(o.binding)<0&&(c=null),c?(n.toggleClass(s,"wj-filter-on",c.isActive),n.toggleClass(s,"wj-filter-off",!c.isActive)):(n.removeClass(s,"wj-filter-on"),n.removeClass(s,"wj-filter-off")),c&&c.filterType!=_.None&&(this._showIcons&&this._addFilterButton(o,c,s),0==e.row&&(s=r.cells.getCellElement(-1,e.col))&&this._addFilterButton(l,c,s))}}},t.prototype._addFilterButton=function(e,i,r){var a=t._WJC_FILTER,l=n.createElement('<button class="wj-btn wj-btn-glyph wj-right '+a+'" type="button" tabindex="-1"><span class="wj-glyph-filter"></span></button>');n.setAriaLabel(l,n.culture.FlexGridFilter.ariaLabels.edit+" "+e.header),n.setAttribute(l,"aria-haspopup","dialog"),n.setAttribute(l,"aria-expanded",!1),n.setAttribute(l,"aria-describedby",e.describedById),n.setAttribute(l,"aria-pressed",i.isActive),r.querySelector("."+a)||r.appendChild(l)},t.prototype._mousedown=function(t){this._toggleEditor(t)&&(this._tmd=!0,t.stopPropagation(),t.preventDefault())},t.prototype._click=function(t){(this._tmd||this._toggleEditor(t))&&(t.stopPropagation(),t.preventDefault()),this._tmd=!1},t.prototype._toggleEditor=function(e){var i=this;if(this._tmd=!1,!e.defaultPrevented&&0==e.button)if(n.closestClass(e.target,t._WJC_FILTER)){var r=this._g,a=r.hitTest(e.target);if(a.panel||(a=r.hitTest(e)),a.panel==r.columnHeaders||a.panel==r.cells&&-1==a.row){var l=r.columns[a.col],o=r._getBindingColumn(a.panel,a.row,l);return this._divEdt&&this._edtCol==o?(this.closeEditor(),r.focus()):setTimeout(function(){i.editColumnFilter(o,a)},this._divEdt?100:0),!0}}else this.closeEditor();return!1},t.prototype._keydown=function(t){if(!t.defaultPrevented&&!t.ctrlKey&&t.altKey&&(t.keyCode==n.Key.Down||t.keyCode==n.Key.Up)){var e=this.grid.selection,i=e.col>-1?this.grid.columns[e.col]:null;i&&!i.dataMap&&this.getColumnFilter(i,!0)&&(this.editColumnFilter(i),t.preventDefault(),t.stopPropagation())}},t._WJC_FILTER="wj-elem-filter",t}();e.FlexGridFilter=b});