Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ej2-querybuilder.min.js 93KB

12345678910
  1. /*!
  2. * filename: ej2-querybuilder.min.js
  3. * version : 19.1.63
  4. * Copyright Syncfusion Inc. 2001 - 2020. All rights reserved.
  5. * Use of this code is subject to the terms of our license.
  6. * A copy of the current license can be obtained at any time by e-mailing
  7. * licensing@syncfusion.com. Any infringement will be prosecuted under
  8. * applicable laws.
  9. */
  10. this.ej=this.ej||{},this.ej.querybuilder=function(e,t,l,i,r,n,o,s,a){"use strict";var u=function(){var e=function(t,l){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var l in t)t.hasOwnProperty(l)&&(e[l]=t[l])})(t,l)};return function(t,l){function i(){this.constructor=t}e(t,l),t.prototype=null===l?Object.create(l):(i.prototype=l.prototype,new i)}}(),d=function(){return(d=Object.assign||function(e){for(var t,l=1,i=arguments.length;l<i;l++){t=arguments[l];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)},p=function(e,t,l,i){var r,n=arguments.length,o=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,l):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,l,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(o=(n<3?r(o):n>3?r(t,l,o):r(t,l))||o);return n>3&&o&&Object.defineProperty(t,l,o),o},c=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"field",void 0),p([t.Property(null)],l.prototype,"label",void 0),p([t.Property(null)],l.prototype,"type",void 0),p([t.Property(null)],l.prototype,"values",void 0),p([t.Property(null)],l.prototype,"operators",void 0),p([t.Property()],l.prototype,"ruleTemplate",void 0),p([t.Property(null)],l.prototype,"template",void 0),p([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],l.prototype,"validation",void 0),p([t.Property(null)],l.prototype,"format",void 0),p([t.Property(null)],l.prototype,"step",void 0),p([t.Property(null)],l.prototype,"value",void 0),p([t.Property(null)],l.prototype,"category",void 0),p([t.Property(null)],l.prototype,"columns",void 0),l}(t.ChildProperty),h=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"condition",void 0),p([t.Collection([],l)],l.prototype,"rules",void 0),p([t.Property(null)],l.prototype,"field",void 0),p([t.Property(null)],l.prototype,"label",void 0),p([t.Property(null)],l.prototype,"type",void 0),p([t.Property(null)],l.prototype,"operator",void 0),p([t.Property(null)],l.prototype,"value",void 0),p([t.Property(!1)],l.prototype,"not",void 0),l}(t.ChildProperty),m=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(null)],l.prototype,"numericTextBoxModel",void 0),p([t.Property(null)],l.prototype,"multiSelectModel",void 0),p([t.Property(null)],l.prototype,"datePickerModel",void 0),p([t.Property(null)],l.prototype,"textBoxModel",void 0),p([t.Property(null)],l.prototype,"radioButtonModel",void 0),l}(t.ChildProperty),f=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),p([t.Property(!0)],l.prototype,"ruleDelete",void 0),p([t.Property(!0)],l.prototype,"groupInsert",void 0),p([t.Property(!0)],l.prototype,"groupDelete",void 0),l}(t.ChildProperty),g=function(e){function c(t,l){var r=e.call(this,t,l)||this;return r.isReadonly=!0,r.fields={text:"label",value:"field"},r.updatedRule={not:!1,condition:"and"},r.isLocale=!1,r.isRefreshed=!1,r.isNotified=!1,r.isAddSuccess=!1,r.isNotValueChange=!1,i.MultiSelect.Inject(i.CheckBoxSelection),r}return u(c,e),c.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},c.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body");e.innerHTML="",this.enableNotCondition&&t.removeClass(this.element.querySelectorAll(".e-qb-toggle"),"e-active-toggle"),e.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.rule={condition:"and",not:!1,rules:[]},this.disableRuleCondition(e.parentElement)},c.prototype.getWrapper=function(){return this.element},c.prototype.getModuleName=function(){return"query-builder"},c.prototype.GetRootColumnName=function(e){return this.separator?e.split(this.separator)[0]:e},c.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],l=[],i=void 0,r=!1,n=!1,o=void 0,s={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length){this.columnSort();for(var a=0,u=(d=this.columns).length;a<u;a++)this.updateCustomOperator(d[a]),d[a].type||(e.indexOf(d[a].field)>-1&&("string"===(i=typeof(o=this.dataColl[0][d[a].field]))?n=!isNaN(Date.parse(o)):"object"===i&&(n=o instanceof Date&&!isNaN(o.getTime()),i="string"),d[a].type=i,n=!1),i="string"),d[a].validation||(d[a].validation=s),d[a].category?r=!0:d[a].category=this.l10n.getConstant("OtherFields"),l.indexOf(d[a].category)<0&&l.push(d[a].category),d[a].operators&&!this.isLocale||(d[a].operators=this.customOperators[d[a].type+"Operator"]);r&&(l.length>1||l[0]!==this.l10n.getConstant("OtherFields"))&&(this.fields={text:"label",value:"field",groupBy:"category"}),this.updateSubFieldsFromColumns(this.columns)}else{for(var a=0,u=e.length;a<u;a++)"string"===(i=typeof(o=this.dataColl[0][e[a]]))?n=!isNaN(Date.parse(o)):"object"!==i||Object.keys(o).length||(n=o instanceof Date&&!isNaN(o.getTime()),i="string"),t[a]={field:e[a],label:e[a],type:n?"date":i,validation:s},n=!1,t[a].operators=this.customOperators[t[a].type+"Operator"],"object"===i&&this.updateSubFields(o,t[a]);this.columns=t}}else if(this.columns.length){for(var d=this.columns,a=0,u=d.length;a<u;a++)d[a].category?this.fields={text:"label",value:"field",groupBy:"category"}:d[a].category=this.l10n.getConstant("OtherFields"),this.updateCustomOperator(d[a]),d[a].operators&&!this.isLocale||(d[a].operators=this.customOperators[d[a].type+"Operator"]);this.updateSubFieldsFromColumns(this.columns)}this.trigger("dataBound",{type:"dataBound"})},c.prototype.updateSubFieldsFromColumns=function(e,t){for(var l=0;l<e.length;l++)e[l].field=t?t+this.separator+e[l].field:e[l].field,e[l].operators?this.updateCustomOperator(e[l]):e[l].type&&"object"!==e[l].type&&(e[l].operators=this.customOperators[e[l].type+"Operator"]),e[l].columns&&(e[l].type="object",this.updateSubFieldsFromColumns(e[l].columns,e[l].field))},c.prototype.updateSubFields=function(e,t,l){var i;t.columns=[];var r,n,o=Object.keys(e);l=l||this.dataColl[0];for(var s=0,a=o.length;s<a;s++){var u=t.field.split(".");n=l?l[u[u.length-1]][o[s]]:this.dataColl[0][t.field][o[s]];var d=l[t.field.split(this.separator)[t.field.split(this.separator).length-1]];r=typeof n,i={field:t.field+this.separator+o[s],label:o[s],type:r="object"!==r||isNaN(Date.parse(n))?r:"date"},"object"!==r&&(i.operators=this.customOperators[r+"Operator"]),t.columns.push(i),"object"===r&&this.updateSubFields(n,i,d)}},c.prototype.updateCustomOperator=function(e){if(e.operators)for(var t=this,l=0;l<e.operators.length;l++)!function(l){var i=Object.keys(e.operators[l]).indexOf("sqlOperator");if(i>-1){var r=e.operators[l],n=Object.keys(r),o=n.map(function(e){return r[e]}).join(",").split(","),s=n.indexOf("value");t.operators[o[s]]=o[i]}}(l)},c.prototype.focusEventHandler=function(e){this.target=e.target},c.prototype.clickEventHandler=function(e){var l,i=this,r=e.target;this.isImportRules=!1;var n;if("SPAN"===r.tagName&&(r=r.parentElement),r.className.indexOf("e-collapse-rule")>-1){var o=new t.Animation({duration:1e3,delay:0});this.element.querySelectorAll(".e-summary-content").length<1&&this.renderSummary();var s=document.getElementById(this.element.id+"_summary_content"),a=s.querySelector(".e-summary-text");o.animate(".e-query-builder",{name:"SlideLeftIn"}),(d=this.element.querySelector(".e-group-container")).style.display="none",a.textContent=this.getSqlFromRules(this.rule),s.style.display="block",a.style.height=a.scrollHeight+"px"}if("BUTTON"===r.tagName&&r.className.indexOf("e-qb-toggle")<0){if(r.className.indexOf("e-removerule")>-1)this.actionButton=r,this.deleteRule(r);else if(r.className.indexOf("e-deletegroup")>-1)this.actionButton=r,this.deleteGroup(t.closest(r,".e-group-container"));else if(r.className.indexOf("e-edit-rule")>-1)if((o=new t.Animation({duration:1e3,delay:0})).animate(".e-query-builder",{name:"SlideLeftIn"}),document.getElementById(this.element.id+"_summary_content").style.display="none",this.element.querySelectorAll(".e-group-container").length<1){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not);var u=t.extend({},this.rule,{},!0);this.setGroupRules(u),this.renderSummaryCollapse()}else{var d=this.element.querySelector(".e-group-container");d.querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),d.style.display="block"}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1||r.className.indexOf("e-qb-toggle")>-1){var p=t.closest(r,".e-group-container");if(!this.headerTemplate){var c=r.getAttribute("for"),h=void 0;c&&(h=document.getElementById(c).getAttribute("value")),n=p.id.replace(this.element.id+"_","");var m=this.getGroup(n),f=void 0;if(this.enableNotCondition)if(r.className.indexOf("e-qb-toggle")>-1){var g=p.getElementsByClassName("e-qb-toggle")[0];g.className.indexOf("e-active-toggle")>-1?(t.removeClass([g],"e-active-toggle"),f=!1):(t.addClass([g],"e-active-toggle"),f=!0),h=m.condition}else f=m.not;l={groupID:n,cancel:!1,type:"condition",value:h.toLowerCase()},this.enableNotCondition&&(l={groupID:n,cancel:!1,type:"condition",value:h.toLowerCase(),not:f})}this.isImportRules?this.beforeSuccessCallBack(l,r):this.trigger("beforeChange",l,function(e){i.beforeSuccessCallBack(e,r)}),this.target=r}},c.prototype.beforeSuccessCallBack=function(e,l){if(!e.cancel){var i=t.closest(l,".e-group-container"),r=i.id.replace(this.element.id+"_",""),n=this.getValidRules(this.rule),o=this.getParentGroup(i);o.condition=e.value,this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:r,type:"condition",value:o.condition}),this.filterRules(n,this.getValidRules(this.rule),"condition")}},c.prototype.selectBtn=function(e,l){"beforeOpen"===l.name?this.showButtons.groupInsert?this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount+1?t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.removeClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):l.element.children[0].className.indexOf("e-addrule")>-1?this.addRuleElement(t.closest(e,".e-group-container"),{}):l.element.children[0].className.indexOf("e-addgroup")>-1&&this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0)},c.prototype.appendRuleElem=function(e,l,i,r,n,o){var s,a,u,d=e.querySelector(".e-rule-list");if("change"===i?s=t.select("#"+r,e):((s=this.createElement("div",{attrs:{class:"e-rule-container"}})).setAttribute("id",e.id+"_rule"+this.ruleIdCounter),d.appendChild(s),this.ruleIdCounter++),l&&l.ruleTemplate){u={requestType:"template-initialize",ruleID:s.id,action:n,fields:this.fields,rule:o},this.trigger("actionBegin",u),this.ruleTemplateFn=this.templateParser(l.ruleTemplate);var p=this.element.id+l.field,c=void 0;if(u.fields=this.fields,u.columns=this.columns,u.operators=this.getOperators(o.field),u.operatorFields={text:"key",value:"value"},this.isReact)c=this.ruleTemplateFn(u,this,s.id,p)[0];else if(this.isAngular){var h=this.ruleTemplateFn(u,this,s.id,p);c=3===h[0].nodeType?h[1]:h[0]}else c=this.ruleTemplateFn(u,this,"Template",p)[0];(a=c).className+=" e-rule-field"}else a=this.ruleElem.querySelector(".e-rule-field").cloneNode(!0);return s.appendChild(a),l&&l.ruleTemplate&&this.renderReactTemplates(),s},c.prototype.addRuleElement=function(e,t,l,i,r,n){var o=this;if(e){var s={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"};this.isImportRules||this.isInitialLoad?(this.isInitialLoad=!1,this.addRuleSuccessCallBack(s,e,t,l,i,r,n)):this.trigger("beforeChange",s,function(s){o.addRuleSuccessCallBack(s,e,t,l,i,r,n)})}},c.prototype.addRuleSuccessCallBack=function(e,l,r,n,o,s,a){var u,p,c,h,m=this.element.className.indexOf("e-device")>-1?"250px":"200px",f=r&&r.field?this.getColumn(r.field):n||this.columns[0],g={label:"",field:"",type:"",operator:""};if(!e.cancel){if(f&&f.ruleTemplate){this.selectedColumn=f,p=this.selectedColumn.operators,g={label:f.label,field:f.field,type:f.type,operator:p[0].value};var v=Object.keys(r).length?r:g,y={requestType:"template-create",action:"insert-rule",ruleID:(h=this.appendRuleElem(l,f,o,s,"field",v)).id,fields:this.fields,rule:v};this.trigger("actionBegin",y)}else{(h=this.appendRuleElem(l,f,o,s,"field")).querySelector(".e-filter-input").setAttribute("id",h.id+"_filterkey");var C=h.querySelector("button");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?(C.textContent=this.l10n.getConstant("Remove"),t.addClass([C],"e-flat"),t.addClass([C],"e-primary")):(t.addClass([C],"e-round"),t.addClass([C],"e-icon-btn"),C.setAttribute("title",this.l10n.getConstant("DeleteRule")),C=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),h.querySelector("button").appendChild(C))}if("Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?h.className="e-rule-container e-vertical-mode":h.className="e-rule-container e-horizontal-mode",h.previousElementSibling&&h.previousElementSibling.className.indexOf("e-rule-container")>-1&&(h.className.indexOf("e-joined-rule")<0&&(h.className+=" e-joined-rule"),h.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(h.previousElementSibling.className+=" e-prev-joined-rule")),h.previousElementSibling&&h.previousElementSibling.className.indexOf("e-group-container")>-1&&h.className.indexOf("e-separate-rule")<0&&(h.className+=" e-separate-rule"),this.isImportRules||this.updateAddedRule(l,r,g,a,s),!f||f&&!f.ruleTemplate){var b=void 0,S=this.isImportRules?this.GetRootColumnName(r.field):r.field;b={dataSource:this.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?m:"auto",change:this.changeField.bind(this),value:r?S:null},this.fieldModel&&(b=d({},b,this.fieldModel)),(c=new i.DropDownList(b)).appendTo("#"+h.id+"_filterkey");var x=this.isImportRules?this.GetRootColumnName(r.field):c.value;this.selectedColumn=c.getDataByValue(x),Object.keys(r).length&&this.changeRule(r,{element:c.element,itemData:this.selectedColumn})}u=h.id.replace(this.element.id+"_",""),this.isImportRules||this.trigger("change",{groupID:l.id.replace(this.element.id+"_",""),ruleID:u,type:"insertRule"})}},c.prototype.updateAddedRule=function(e,l,i,r,n){var o,s,a,u=0;if(r){for(o=t.select("#"+n,e),s=t.closest(e,".e-group-container"),a=this.getParentGroup(s);o&&null!==o.previousElementSibling;)o=o.previousElementSibling,u++;a.rules[u]=l}else s=t.closest(e,".e-group-container"),a=this.getParentGroup(s),Object.keys(l).length?a.rules.push({field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}):a.rules.push(i);this.disableRuleCondition(e,a)},c.prototype.changeRuleTemplate=function(e,l,i,r){var n=this.selectedColumn.operators;if(!e.ruleTemplate){var o=t.closest(l,".e-group-container"),s=t.closest(l,".e-rule-container").id;if(this.previousColumn&&this.previousColumn.ruleTemplate&&(t.detach(l.closest('[id="'+s+'"]').querySelector(".e-rule-field")),this.clearQBTemplate([s])),e){var a={field:e.field,label:e.label,operator:n[0].value,value:""};this.addRuleElement(o,a,e,"change",s,!0)}}},c.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),position:"BottomCenter",cssClass:"e-querybuilder-error"});t.appendTo(e),t.open(e)},c.prototype.validateFields=function(){var e=!0;if(this.allowValidation){var l=["isnull","isnotnull","isempty","isnotempty"],i=void 0,r=void 0,n=void 0,o=void 0,s=[],a=void 0,u=void 0,d=void 0,p=void 0,c=void 0,h=this.element.querySelectorAll(".e-rule-container"),m=void 0;for(i=0,r=h.length;i<r;i++)if(a=t.closest(h[i],".e-group-container"),c=this.getParentGroup(a),u=0,o=p=h[i],d=t.getComponent(h[i].querySelector(".e-rule-field input.e-control"),"dropdownlist"),this.selectedColumn=d.getDataByValue(d.value),m=!t.isNullOrUndefined(d.index)&&this.selectedColumn.validation,n=p.querySelector(".e-rule-field input.e-control"),m&&m.isRequired){for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,u++;if(n=p.querySelector(".e-rule-operator input.e-control"),c.rules[u].operator||(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1),c.rules[u].value instanceof Array&&(s=c.rules[u].value),l.indexOf(c.rules[u].operator)<0&&t.isNullOrUndefined(c.rules[u].value)&&"date"!==c.rules[u].type||""===c.rules[u].value||c.rules[u].value instanceof Array&&s.length<1){var f=p.querySelectorAll(".e-rule-value input.e-control");e=!1;for(var g=0,v=f.length;g<v;g++){var y=f[g],C=void 0;y.parentElement.className.indexOf("e-searcher")>-1?(C=t.closest(y,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(C):f[g].parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(f[g].parentElement),g++}}}else d.element&&t.isNullOrUndefined(d.index)&&(n.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(n.parentElement),e=!1)}return e},c.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");this.levelColl[e.id]=[0];var t={groupElement:e,level:[0]};this.refreshLevel(t)},c.prototype.refreshLevel=function(e){var l,i,r=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,o=r.length,s=0;for(i=0;i<o;i++)(l=r[i]).className.indexOf("e-group-container")>-1&&(e.level.push(s),this.levelColl[l.id]=e.level.slice(),s++,e.groupElement=l,e=this.refreshLevel(e));var a=t.closest(n,".e-rule-list");return e.groupElement=a?t.closest(a,".e-group-container"):n,e.level=this.levelColl[e.groupElement.id].slice(),e},c.prototype.groupTemplate=function(){var e,t,l,i,r,n,o,s,a;return e=this.createElement("div",{attrs:{class:"e-group-container"}}),l=this.createElement("div",{attrs:{class:"e-group-header"}}),t=this.createElement("div",{attrs:{class:"e-group-body"}}),i=this.createElement("div",{attrs:{class:"e-rule-list"}}),e.appendChild(l),t.appendChild(i),e.appendChild(t),this.headerTemplate||(r=this.createElement("div",{attrs:{class:"e-lib e-btn-group"}}),this.enableNotCondition&&(n=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),r.appendChild(n)),(n=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}})).setAttribute("checked","true"),r.appendChild(n),o=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-and-lbl e-small"},innerHTML:this.l10n.getConstant("AND")}),r.appendChild(o),n=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),r.appendChild(n),o=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-or-lbl e-small"},innerHTML:this.l10n.getConstant("OR")}),r.appendChild(o),l.appendChild(r),s=this.createElement("div",{attrs:{class:"e-group-action"}}),a=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),s.appendChild(a),l.appendChild(s)),e},c.prototype.ruleTemplate=function(){var e,t,l,i,r,n;return e=this.createElement("div"),r=this.createElement("div",{attrs:{class:"e-rule-field"}}),l=this.createElement("div",{attrs:{class:"e-rule-filter"}}),t=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}}),l.appendChild(t),r.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-operator"}}),r.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value"}}),r.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),n=this.showButtons.ruleDelete?"e-removerule e-rule-delete e-css e-btn e-small":"e-removerule e-rule-delete e-css e-btn e-small e-button-hide",i=this.createElement("button",{attrs:{class:n}}),l.appendChild(i),r.appendChild(l),e.appendChild(r),e},c.prototype.addGroupElement=function(e,t,l,i,r){var n=this,o={groupID:t.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};this.isImportRules||this.isInitialLoad?(this.isInitialLoad=!1,this.addGroupSuccess(o,e,t,l,i,r)):this.trigger("beforeChange",o,function(o){n.addGroupSuccess(o,e,t,l,i,r)})},c.prototype.addGroupSuccess=function(e,i,r,n,o,a){if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var u=r,d=void 0,p=this.groupElem.cloneNode(!0);if(p.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),this.headerTemplate&&this.headerTemplateFn(p,a,n),this.groupIdCounter++,!this.headerTemplate){var c=p.querySelector(".e-btngroup-and"),h=p.querySelector(".e-btngroup-or"),m=p.querySelector(".e-btngroup-and-lbl"),f=p.querySelector(".e-btngroup-or-lbl");c.setAttribute("id",this.element.id+"_and"+this.btnGroupId),h.setAttribute("id",this.element.id+"_or"+this.btnGroupId),c.setAttribute("name",this.element.id+"_and"+this.btnGroupId),h.setAttribute("name",this.element.id+"_and"+this.btnGroupId),m.setAttribute("for",this.element.id+"_and"+this.btnGroupId),f.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++}if(i){var g=this.showButtons.groupDelete?"e-deletegroup":"e-deletegroup e-button-hide";d=this.createElement("button",{attrs:{class:g}}),new l.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(d),d.setAttribute("title",this.l10n.getConstant("DeleteGroup")),t.rippleEffect(d,{selector:".deletegroup"}),this.headerTemplate||p.querySelector(".e-group-action").appendChild(d);for(var v=u.querySelector(".e-rule-list"),y=v.children,C=0,b=0,S=y.length;b<S;b++)y[b].className.indexOf("e-group-container")>-1&&(C+=1);v.appendChild(p);var x=this.levelColl[u.id].slice(0);x.push(C),this.levelColl[p.id]=x,this.isImportRules||(this.isAddSuccess=!0,this.addGroups([],u.id.replace(this.element.id+"_","")),this.isAddSuccess=!1,o&&this.addRuleElement(p,{}))}else u.appendChild(p),this.levelColl[p.id]=[0];if(this.enableNotCondition&&!this.headerTemplate){var O=p.querySelector(".e-qb-toggle");new l.Button({content:this.l10n.getConstant("NOT"),cssClass:"e-btn e-small"}).appendTo(O),p.querySelector(".e-btngroup-and-lbl").classList.add("e-not"),this.updatedRule&&this.updatedRule.not&&t.addClass([O],"e-active-toggle")}if(this.updatedRule=null,this.headerTemplate){var E={requestType:"header-template-create",ruleID:p.id,condition:n,notCondition:this.enableNotCondition?a:void 0};this.trigger("actionBegin",E)}else{var w=p.querySelector(".e-add-btn");new s.DropDownButton({items:this.items,cssClass:"e-round e-small e-caret-hide e-addrulegroup",iconCss:"e-icons e-add-icon",beforeOpen:this.selectBtn.bind(this,w),select:this.selectBtn.bind(this,w)}).appendTo(w),w.setAttribute("title",this.l10n.getConstant("AddButton"))}if(!this.isImportRules){var N=u.id.replace(this.element.id+"_",""),q=p.id.replace(this.element.id+"_","");this.trigger("change",{groupID:N,type:"insertGroup",childGroupID:q})}}},c.prototype.headerTemplateFn=function(e,t,l){var i,r,n=this.element.id+"_header",o=e.querySelector(".e-group-header");if(this.headerTemplate){if(r={requestType:"header-template-initialize",ruleID:e.id,notCondition:this.enableNotCondition?t:void 0,condition:l},this.trigger("actionBegin",r),this.headerFn=this.templateParser(this.headerTemplate),this.isReact)i=this.headerFn(r,this,e.id,n)[0];else if(this.isAngular){var s=this.headerFn(r,this,e.id,n);i=3===s[0].nodeType?s[1]:s[0]}else i=this.headerFn(r,this,"Template",n)[0];o.appendChild(i),this.renderReactTemplates()}return e},c.prototype.notifyChange=function(e,l,i){var r=t.closest(l,".e-group-container"),n=this.getParentGroup(r),o=t.closest(l,".e-rule-container"),s=0;if("not"===i)return void(n.not=e);if("condition"===i)return void(n.condition=e);for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,s++;var a=n.rules[s],u=this.getColumn(a.field),d=this.getFormat(u.format);if("date"===u.type)if(e instanceof Date)e=this.intl.formatDate(e,d);else if(e instanceof Array)for(var p=0;p<e.length;p++)e[p]&&e[p]instanceof Date&&(e[p]=this.intl.formatDate(e[p],d));u.ruleTemplate?this.templateChange(l,e,i):(this.isNotified=!0,this.updateRules(l,e),this.isNotified=!1)},c.prototype.templateChange=function(e,l,i){for(var r=t.closest(e,".e-group-container"),n=this.getParentGroup(r),o=t.closest(e,".e-rule-container"),s=0;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,s++;var a=n.rules[s];"field"===i?this.selectedColumn=this.getColumn(l):a&&(this.selectedColumn=this.getColumn(a.field));var u;this.previousColumn=this.getColumn(a.field);var d=this.getValidRules(this.rule);this.selectedColumn&&(u=this.selectedColumn.operators?this.selectedColumn.operators:this.customOperators[this.selectedColumn.type+"Operator"]);var p,c=["in","notin","between","notbetween"];switch(i){case"field":a.field=l,a.label=this.selectedColumn.label,a.type=this.selectedColumn.type,a.value="",a.operator=u[0].value;break;case"operator":p=a.operator,a.operator=l,c.indexOf(a.operator)>-1?a.value=[]:c.indexOf(p)>-1&&(a.value="");break;case"value":a.value=l}if(this.changeRuleTemplate(this.selectedColumn,e,a,i),this.filterRules(d,this.getValidRules(this.rule),i),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"===i||"operator"===i)){var h=t.closest(e,".e-rule-container");this.destroyControls(h,!0),t.detach(h.querySelector(".e-rule-field"));var m=this.appendRuleElem(t.closest(h,".e-group-container"),this.selectedColumn,"change",h.id,i,a);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?m.className="e-rule-container e-vertical-mode":m.className="e-rule-container e-horizontal-mode",m.previousElementSibling&&m.previousElementSibling.className.indexOf("e-rule-container")>-1&&(m.className.indexOf("e-joined-rule")<0&&(m.className+=" e-joined-rule"),m.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(m.previousElementSibling.className+=" e-prev-joined-rule")),m.previousElementSibling&&m.previousElementSibling.className.indexOf("e-group-container")>-1&&m.className.indexOf("e-separate-rule")<0&&(m.className+=" e-separate-rule");var f={requestType:"template-create",action:i,ruleID:h.id,fields:this.fields,rule:a};this.trigger("actionBegin",f)}},c.prototype.changeValue=function(e,l){var i,r,n,o=this;((n=l.event?l.event.target:l.element).className.indexOf("e-day")>-1||n.className.indexOf("e-today")>-1||n.className.indexOf("e-cell")>-1)&&(n=l.element);var s=t.closest(n,".e-group-container"),a=t.closest(n,".e-rule-container");i=s&&s.id.replace(this.element.id+"_",""),r=a.id.replace(this.element.id+"_","");var u=l;u.element&&u.element.className.indexOf("e-datepicker")>-1&&(n=u.element);var d,p,c;n.className.indexOf("e-radio")>-1?(p=parseInt(n.id.split("valuekey")[1],0),c=t.getComponent(t.closest(n,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=c.getDataByValue(c.value),d=this.selectedColumn.values?this.selectedColumn.values[p]:[!0,!1][p]):d=n.className.indexOf("e-multiselect")>-1?t.getComponent(n,"multiselect").value:l.value,"input"===l.name&&this.immediateModeDelay?(window.clearInterval(this.timer),this.timer=window.setInterval(function(){o.filterValue(i,r,d,e,n)},this.immediateModeDelay)):this.filterValue(i,r,d,e,n)},c.prototype.filterValue=function(e,t,l,i,r){var n=this,o={groupID:e,ruleID:t,value:l,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(o,r,i,e,t):this.trigger("beforeChange",o,function(l){n.changeValueSuccessCallBack(l,r,i,e,t)})},c.prototype.changeValueSuccessCallBack=function(e,t,l,i,r){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules||this.trigger("change",{groupID:i,ruleID:r,value:e.value,cancel:!1,type:"value"}))},c.prototype.changeField=function(e){if(e.isInteracted){var l=t.closest(e.element,".e-rule-filter")||t.closest(e.element,".e-rule-sub-filter");this.destroySubFields(l),this.subFieldElem=null,this.isNotValueChange=!0;var i=this.getColumn(e.value);if(i&&i.ruleTemplate)this.templateChange(e.element,i.field,"field");else{for(var r=t.closest(e.element,".e-group-container"),n=this.getParentGroup(r),o=t.closest(e.element,".e-rule-container"),s=0;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,s++;this.changeRule(n.rules[s],e)}}},c.prototype.changeRule=function(e,l){if(l.itemData){var i={},r=t.closest(l.element,".e-rule-filter");r=r||t.closest(l.element,".e-rule-sub-filter");var n=t.getComponent(l.element,"dropdownlist"),o=t.closest(l.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(r,n,o,e,i,l)}},c.prototype.changeFilter=function(e,l,i,r,n,o){var s=this;if(e){var a=this.isImportRules?this.GetRootColumnName(l.value):l.value;this.selectedColumn=l.getDataByValue(a);var u=void 0;u={groupID:i,ruleID:t.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),selectedField:l.value,cancel:!1,type:"field"},this.isImportRules?this.fieldChangeSuccess(u,n,e,r,o):this.trigger("beforeChange",u,function(t){s.fieldChangeSuccess(t,n,e,r,o)})}else{var d=t.closest(o.element,".e-rule-operator");this.changeOperator(e,d,l,i,r,n,o)}},c.prototype.changeOperator=function(e,l,i,r,n,o,s){var a,u=this;l?(a={groupID:r,ruleID:t.closest(l,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:i.index,cancel:!1,type:"operator"},this.isImportRules?this.operatorChangeSuccess(a,e,o,n,s):this.trigger("beforeChange",a,function(t){u.operatorChangeSuccess(t,e,o,n,s)})):this.changeRuleValues(e,n,o,s)},c.prototype.fieldChangeSuccess=function(e,l,i,r,n){for(var o=t.closest(i,".e-rule-container"),s=t.closest(n.element,".e-rule-operator"),a=t.closest(n.element,".e-group-container").id.replace(this.element.id+"_",""),u=t.getComponent(n.element,"dropdownlist"),d=o.querySelectorAll(".e-tooltip.e-input-group"),p=0;p<d.length;p++)t.getComponent(d[p],"tooltip").destroy();if(e.cancel)this.changeOperator(i,s,u,a,r,l,n);else if(l.type=this.selectedColumn.type,o.querySelector(".e-template")&&(r.value=""),"object"===this.selectedColumn.type)for(l.type=this.selectedColumn.columns[0].type;this.selectedColumn.columns;)this.createSubFields(i,r,l,n);else this.destroySubFields(i),this.changeOperator(i,s,u,a,r,l,n)},c.prototype.destroySubFields=function(e){for(;e&&e.nextElementSibling.classList.contains("e-rule-sub-filter");)this.destroyControls(e),e.nextElementSibling.remove()},c.prototype.createSubFields=function(e,l,r,n){var o,s,a=t.closest(e,".e-rule-field");s=s||this.createElement("div",{attrs:{class:"e-rule-sub-filter",id:"subfilter"+this.subFilterCounter}}),a.insertBefore(s,a.querySelector(".e-rule-operator"));var u=t.closest(s,".e-rule-container").id;o=this.createElement("input",{attrs:{type:"text",id:u+"_subfilterkey"+this.subFilterCounter}}),s.appendChild(o);var d=this.element.className.indexOf("e-device")>-1?"250px":"200px",p=Object.keys(this.selectedColumn.columns[0]),c=new i.DropDownList({dataSource:this.selectedColumn.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:p.length>5?d:"auto",change:this.changeField.bind(this),index:0});if(c.appendTo("#"+u+"_subfilterkey"+this.subFilterCounter),this.isImportRules)for(var h=this.selectedColumn.columns,m=0;m<h.length;m++)if(l.field===h[m].field||l.field.indexOf(h[m].field)>-1){c.value=h[m].field,this.selectedColumn=h[m];break}this.subFilterCounter++,this.subFieldElem=o,n.itemData=n.itemData,this.isImportRules||(this.selectedColumn=this.selectedColumn.columns[0]),this.selectedColumn.columns||this.changeRuleValues(s,l,r,n)},c.prototype.operatorChangeSuccess=function(e,l,i,r,n){if(!e.cancel){var o=t.closest(n.element,".e-rule-operator"),s=o.nextElementSibling,a=t.getComponent(n.element,"dropdownlist"),u=r.operator?r.operator.toString().toLowerCase():"";i.operator=a.value.toString();var d=i.operator.toLowerCase();if(i.operator.toLowerCase().indexOf("between")>-1||i.operator.toLowerCase().indexOf("in")>-1&&i.operator.toLowerCase().indexOf("contains")<0?(l=o.previousElementSibling,i.type=r.type,(i.operator.toLowerCase().indexOf("in")<0||u.indexOf("in")<0)&&(r.value=[])):"object"==typeof r.value&&null!=r.value&&(r.value=r.value.length>0?r.value[0]:"number"===r.type?0:""),n.previousItemData){var p=n.previousItemData.value.toString().toLowerCase();(p.indexOf("between")>-1||(p.indexOf("in")>-1||p.indexOf("null")>-1||p.indexOf("empty")>-1)&&p.indexOf("contains")<0)&&(l=o.previousElementSibling,i.type=r.type)}if(u.indexOf("in")>-1&&u.indexOf("in")<5&&d.indexOf("in")>-1&&d.indexOf("in")<5&&(l=null),i.operator.indexOf("null")>-1||i.operator.indexOf("empty")>-1){var c=o.parentElement.querySelector(".e-rule-value"),h=c.querySelector(".e-tooltip.e-input-group");h&&t.getComponent(h,"tooltip").destroy(),t.removeClass([c],"e-show"),t.addClass([c],"e-hide")}s&&this.getColumn(r.field).template&&(l=o.previousElementSibling),this.changeRuleValues(l,r,i,n)}},c.prototype.changeRuleValues=function(e,l,r,n){var o,s,a,u=t.closest(n.element,".e-rule-operator");if(e)if(u=e.nextElementSibling,e.classList.contains("e-rule-sub-filter")&&(r.type=this.selectedColumn.type,u=u.classList.contains("e-rule-sub-filter")?u.nextElementSibling:u),t.addClass([u],"e-operator"),u.childElementCount){o=t.getComponent(u.querySelector(".e-dropdownlist"),"dropdownlist");var p=t.getComponent(e.querySelector(".e-dropdownlist"),"dropdownlist");r.operator=o.value,r.type=this.getColumn(p.value).type;var c=n.itemData;this.renderValues(u,c,n.previousItemData,!0,l,r,n.element)}else{var h=t.closest(u,".e-rule-container").id;a=this.createElement("input",{attrs:{type:"text",id:h+"_operatorkey"}}),u.appendChild(a),this.selectedColumn.operators?s=this.selectedColumn.operators:n.itemData&&(s=this.customOperators[this.selectedColumn.type+"Operator"]);var m=this.element.className.indexOf("e-device")>-1?"250px":"200px",f=s[0].value;f=l&&""!==l.operator?l.operator:f;var g=void 0;g={dataSource:s,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:s.length>5?m:"auto",change:this.changeField.bind(this),index:0,value:f},this.operatorModel&&(g=d({},g,this.operatorModel)),new i.DropDownList(g).appendTo("#"+h+"_operatorkey"),r.operator=l&&""!==l.operator&&!t.isNullOrUndefined(l.operator)?l.operator:s[0].value,this.isImportRules&&(r.type=this.selectedColumn.type,r.operator=l.operator),this.renderValues(u,this.selectedColumn,n.previousItemData,!1,l,r,n.element)}this.isImportRules||this.updateRules(n.element,n.item)},c.prototype.destroyControls=function(e,l){var i,r=l?e:e.nextElementSibling;i=r.querySelectorAll("input.e-control");var n;n=r.querySelectorAll("div.e-control:not(.e-handle)");for(var o=this.columns,s=0,a=i.length;s<a;s++){if(i[s].classList.contains("e-textbox"))t.getComponent(i[s],"textbox").destroy(),t.detach(t.select("input#"+i[s].id,r));else if(i[s].classList.contains("e-dropdownlist"))this.allowValidation&&i[s].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(i[s].parentElement,"tooltip").destroy(),t.getComponent(i[s],"dropdownlist").destroy();else if(i[s].classList.contains("e-radio"))t.getComponent(i[s],"radio").destroy();else if(i[s].classList.contains("e-numerictextbox"))t.getComponent(i[s],"numerictextbox").destroy(),t.detach(t.select("input#"+i[s].id,r));else if(i[s].classList.contains("e-datepicker"))t.getComponent(i[s],"datepicker").destroy();else if(i[s].classList.contains("e-multiselect"))t.getComponent(i[s],"multiselect").destroy();else if(i[s].className.indexOf("e-template")>-1)for(var u=i[s].className,d=0,p=o.length;d<p;d++)if(o[d].template&&u.indexOf(o[d].field)>-1){this.templateDestroy(o[d],i[s].id);break}document.getElementById(i[s].id)&&t.detach(i[s])}for(var s=0,a=n.length;s<a;s++){if(n[s].className.indexOf("e-template")>-1)for(var u=n[s].className,d=0,p=o.length;d<p;d++)if(o[d].template&&u.indexOf(o[d].field)>-1){this.templateDestroy(o[d],n[s].id);break}t.detach(n[s])}for(var c,s=0,a=(c=r.querySelectorAll(".e-template:not(.e-control)")).length;s<a;s++)t.detach(c[s])},c.prototype.templateDestroy=function(e,l){var i;if("string"!=typeof e.template||void 0===e.template.destroy){var r=(i=e.template).destroy;if(i.destroy){var n=void 0;document.getElementById(l)&&(n=t.closest(document.getElementById(l),".e-rule-field").querySelectorAll(".e-template")),"string"==typeof r?(r=t.getValue(r,window))({field:e.field,elementId:l,elements:n}):i.destroy({field:e.field,elementId:l,elements:n})}}},c.prototype.getValues=function(e){var t,l={},i=[],r=[];this.separator.length>0&&(r=e.split(this.separator));var n=this.dataColl;if(this.dataColl[1])for(var o=0,s=n.length;o<s;o++){var a={};if(r.length>1)for(var u=n[o],d=void 0,p=0,c=r.length;p<c;p++)d=r[p],r.length===p+1?(t=u[d],Number(u[d])===u[d]&&u[d]%1!=0&&(t=u[d].toString())):u=u[d];else t=n[o][e],Number(n[o][e])===n[o][e]&&n[o][e]%1!=0&&(t=n[o][e].toString());t in l||(l[t]=1,r.length>1?this.createNestedObject(a,r,t):a[e]=t,i.push(a))}return i},c.prototype.createNestedObject=function(e,t,l){for(var i,r=t.length-1,n=0;n<r;++n)(i=t[n])in e||(e[i]={}),e=e[i];e[t[r]]=l},c.prototype.getDistinctValues=function(e,t){for(var l={},i=[],r=0,n=e.length;r<n;r++){var o=e[r][t];Number(e[r][t])===e[r][t]&&e[r][t]%1!=0&&(o=e[r][t].toString());var s={};o in l||(l[o]=1,s[t]=o,i.push(s))}return i},c.prototype.renderMultiSelect=function(e,t,l,n,o){var s,a=!1,u=!1;this.dataColl[1]&&Object.keys(this.dataColl[1]).indexOf(e.field)>-1&&(a=!0,s=this.getDistinctValues(this.dataColl,e.field)),a=!e.columns&&a,!this.dataColl.length&&o.length&&(u=!0);var p;p={dataSource:u?o:a?s:this.dataManager,query:new r.Query([e.field]),fields:{text:this.selectedRule.field,value:this.selectedRule.field},placeholder:this.l10n.getConstant("SelectValue"),value:n,mode:"CheckBox",width:"100%",change:this.changeValue.bind(this,l),close:this.closePopup.bind(this,l),actionBegin:this.multiSelectOpen.bind(this,t+"_valuekey"+l)},this.valueModel&&this.valueModel.multiSelectModel&&(p=d({},p,this.valueModel.multiSelectModel));var c=new i.MultiSelect(p);c.appendTo("#"+t+"_valuekey"+l),this.updateRules(c.element,n,0)},c.prototype.multiSelectOpen=function(e,l){if(this.dataSource instanceof r.DataManager){var i=document.getElementById(e),n=t.getComponent(t.closest(i,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist");this.selectedColumn=n.getDataByValue(n.value);var o=this.selectedColumn.field,s=!1;this.dataColl[1]&&Object.keys(this.dataColl[1]).indexOf(o)>-1&&(s=!0),s||(l.cancel=!0,this.bindMultiSelectData(i,o))}},c.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},c.prototype.getMultiSelectData=function(e,l){var i,n=this,o=new r.Deferred,s=this.dataManager.executeQuery((new r.Query).select(l)),u=t.getComponent(e,"multiselect");u.hideSpinner(),this.createSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),a.showSpinner(t.closest(e,".e-multi-select-wrapper").parentElement),s.then(function(r){i=r.actual&&r.actual.result?r.actual.result:r.result,n.dataColl=t.extend(n.dataColl,i,[],!0),u.dataSource=n.getDistinctValues(n.dataColl,l),a.hideSpinner(t.closest(e,".e-multi-select-wrapper").parentElement)}).catch(function(e){o.reject(e)})},c.prototype.createSpinner=function(e){var l=this.createElement("span",{attrs:{class:"e-qb-spinner"}});e.appendChild(l),a.createSpinner({target:l,width:t.Browser.isDevice?"16px":"14px"})},c.prototype.closePopup=function(e,l){var i=document.getElementById(l.popup.element.id.replace("_popup","")),r=t.getComponent(i,"multiselect").value;this.updateRules(i,r,e)},c.prototype.processTemplate=function(e,l,i,r){var n,o=t.closest(e,".e-rule-container"),s=o.querySelectorAll(".e-template");n=t.getComponent(o.querySelector(".e-rule-filter .e-filter-input"),"dropdownlist");var a=this.getColumn(n.value);if("string"==typeof l.template||void 0===l.template.write){var u={rule:i,ruleID:o.id,operator:r.operator,field:a.field,requestType:"value-template-create"};this.trigger("actionBegin",u)}else{var d=l.template;"string"==typeof d.write?t.getValue(d.write,window)({elements:s.length>1?s:s[0],values:i.value,operator:r.operator,field:a.field,dataSource:a.values}):l.template.write({elements:s.length>1?s:s[0],values:i.value,operator:r.operator,field:a.field,dataSource:a.values})}},c.prototype.getItemData=function(e){var l=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist");return this.getColumn(l.value)},c.prototype.setDefaultValue=function(e,l,i){var r=this.getItemData(e);if(t.isNullOrUndefined(r.value))return i?l?[0,0]:0:l?[]:"";if(l){if(!(r.value instanceof Array))return[r.value]}else if(r.value instanceof Array)return r.value[0];return r.value},c.prototype.renderStringValue=function(e,t,l,i,r){var o,s,a=this.getItemData(e),u="string"==typeof a.template;if(s=this.isImportRules||this.isPublic||u?t.value:this.setDefaultValue(e,!1,!1),"in"!==l&&"notin"!==l||!this.dataColl.length&&!a.values){"in"!==l&&"notin"!==l||(s=(o=this.isImportRules?t.value:this.setDefaultValue(e,!0,!1)).join(","));var p=void 0;p={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,i)},this.valueModel&&this.valueModel.textBoxModel&&(p=d({},p,this.valueModel.textBoxModel));var c=new n.TextBox(p);c.appendTo("#"+e+"_valuekey"+i),c.value=s,c.dataBind()}else o=this.isImportRules?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(a,e,i,o,a.values),"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?r.style.width="100%":(r.style.width=null,r.style.minWidth="200px")},c.prototype.renderNumberValue=function(e,l,i,r,o,s,a){var u=this.getItemData(e),p="string"==typeof u.template,c=this.isImportRules||this.isPublic||p?l.value:this.setDefaultValue(e,!1,!0);if("in"!==i&&"notin"!==i||!this.dataColl.length&&!u.values)if("in"===i||"notin"===i){var h=(c=this.isImportRules?l.value:this.setDefaultValue(e,!0,!1)).join(","),m=void 0;m={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,r)},this.valueModel&&this.valueModel.textBoxModel&&(m=d({},m,this.valueModel.textBoxModel));var f=new n.TextBox(m);f.appendTo("#"+e+"_valuekey"+r),f.value=h,f.dataBind()}else{var g=t.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),v=(s=this.getColumn(g.value)).validation&&s.validation.min?s.validation.min:0,y=s.validation&&s.validation.max?s.validation.max:Number.MAX_VALUE,C=s.format?s.format:"n";a>1&&l&&(c=l.value[r]?l.value[r]:this.setDefaultValue(e,!0,!0));var b=void 0;b={value:c instanceof Array?c[r]:c,format:C,min:v,max:y,width:"100%",step:s.step?s.step:1,change:this.changeValue.bind(this,r)},this.valueModel&&this.valueModel.numericTextBoxModel&&(b=d({},b,this.valueModel.numericTextBoxModel)),new n.NumericTextBox(b).appendTo("#"+e+"_valuekey"+r)}else c=this.isImportRules?l.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(u,e,r,c,u.values),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?o.style.width="100%":(o.style.minWidth="200px",o.style.width=null)},c.prototype.processValueString=function(e,t){var l=[],i=e.split(",");if("string"===t)return i;for(var r=0,n=i.length;r<n;r++)l.push(Number(i[r]));return l},c.prototype.parseDate=function(e,l){var i,r;if(l){var n=this.intl.getDateParser({skeleton:"full",type:"dateTime"});i=this.getFormat(l),r=n(e),t.isNullOrUndefined(r)&&(r=this.intl.parseDate(e,i))}else r=new Date(e);return r},c.prototype.renderControls=function(e,l,i,r,n){if(t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),t.removeClass([e.parentElement.querySelector(".e-rule-value")],"e-hide"),t.addClass([e.parentElement.querySelector(".e-rule-value")],"e-show"),l.template&&(l.template.create||n))this.processTemplate(e,l,i,r);else{var s;s="boolean"===r.type?this.selectedColumn.values?this.selectedColumn.values.length:2:r.operator&&r.operator.toString().toLowerCase().indexOf("between")>-1?2:1;var a=t.closest(e,".e-rule-container").id,u=void 0,p=void 0;if(p=r.operator.toString(),e.className.indexOf("e-rule-operator")>-1||e.className.indexOf("e-rule-filter")>-1){u=e.parentElement.querySelector(".e-rule-value"),this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?u.style.width="100%":"in"!==p&&"notin"!==p?t.addClass([u],"e-custom-value"):t.removeClass([u],"e-custom-value");for(var c=0;c<s;c++)switch(r.type){case"string":this.renderStringValue(a,i,p,c,u);break;case"number":this.renderNumberValue(a,i,p,c,u,l,s);break;case"boolean":this.processBoolValues(l,i,a,c);break;case"date":var h=new Date,m=void 0,f=void 0,g=l.format,v=void 0,y=void 0,C=this.l10n.getConstant("SelectValue"),b="string"==typeof l.template;if(l.field||l.key||!l.value||(h=l.value instanceof Date?l.value:this.parseDate(l.value,l.format)),!l.format&&i&&""!==i.field&&(g=(f=this.getColumn(i.field)).format),(this.isImportRules||this.isPublic||b)&&i&&(g=(f=this.getColumn(i.field)).format,i.value?(m=s>1?i.value[c]:i.value,h=this.parseDate(m,f.format)):h=i.value),g){var S=this.getFormat(g);S.skeleton?(y={locale:this.getLocale(),value:h,placeholder:C,format:S,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y)):(y={value:h,locale:this.getLocale(),placeholder:C,format:S.format,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y))}else y={locale:this.getLocale(),value:h,placeholder:C,change:this.changeValue.bind(this,c)},this.valueModel&&this.valueModel.datePickerModel&&(y=d({},y,this.valueModel.datePickerModel)),v=new o.DatePicker(y);if(v.appendTo("#"+a+"_valuekey"+c),!i.value){var x=document.getElementById(a+"_valuekey"+c);this.updateRules(x,h,null,this.isNotValueChange),this.isNotValueChange=!1}}}}},c.prototype.processBoolValues=function(e,i,r,n){var o,s,a=!1;t.isNullOrUndefined(i.type)&&e&&(i.type=e.type);var u;if(e.values){p=e.values;"boolean"!==i.type||t.isNullOrUndefined(i.value)?e.value?a=p[n].toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=p[n].toLowerCase()===i.value.toString().toLowerCase(),s=o=u=p[n]}else{var p=[!0,!1];"boolean"!==i.type||t.isNullOrUndefined(i.value)?e.value?a=p[n].toString().toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=p[n].toString().toLowerCase()===i.value.toString().toLowerCase(),o=p[n].toString(),s=p[n],u=this.l10n.getConstant(["True","False"][n])}var c;c={label:u,name:r+"default",checked:a,value:o,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.radioButtonModel&&(c=d({},c,this.valueModel.radioButtonModel));var h=new l.RadioButton(c);h.appendTo("#"+r+"_valuekey"+n),a&&this.updateRules(h.element,s,0)},c.prototype.getOperatorIndex=function(e,t){var l,i=e.dataSource.length;for(l=0;l<i;l++)if(t.operator===e.dataSource[l].value)return l;return 0},c.prototype.getPreviousItemData=function(e,t){return t.template&&e&&Object.keys(e).length<4&&(e.template=t.template),e},c.prototype.renderValues=function(e,l,i,r,n,o,s){var a=e.previousElementSibling.getElementsByTagName("input")[0],u=t.getComponent(a,"dropdownlist"),d=this.getColumn(u.value);if(this.selectedRule=u.itemData,r){var p=t.getComponent(e.querySelector("input"),"dropdownlist");(l=s.id.indexOf("operator")>-1?l:this.selectedRule).operators&&(p.value=null,p.dataBind(),p.dataSource=l.operators,p.index=this.getOperatorIndex(p,n),p.value=o.operator=p.dataSource[p.index].value,p.dataBind())}var c=o.operator.toString(),h=!1;if(c.indexOf("null")>-1||c.indexOf("empty")>-1)(g=e.parentElement.querySelector(".e-rule-value"))&&(t.removeClass([g],"e-show"),t.addClass([g],"e-hide"));else{var m=t.closest(e,".e-rule-container").id;if((i=this.getPreviousItemData(i,d))&&i.template){this.templateDestroy(i,m+"_valuekey0");var f=t.select("#"+m+"_valuekey0",e.nextElementSibling);f&&!f.classList.contains("e-control")&&t.detach(t.select("#"+m+"_valuekey0",e.nextElementSibling)),"string"!=typeof i.template&&void 0!==i.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([m]),e.nextElementSibling.innerHTML="")}if(r&&(this.validatValue(n,t.closest(e,".e-rule-container")),this.destroyControls(e)),l.template=d.template,l.template&&(t.addClass([e.nextElementSibling],"e-template-value"),l.template=d.template,h=this.setColumnTemplate(l,m,d.field,l.value||c,e,n)),h){var g=e.parentElement.querySelector(".e-rule-value");this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode?g.style.width="100%":g.style.width="200px"}else{t.removeClass([e.nextElementSibling],"e-template-value");var v=1;v="boolean"===o.type?this.selectedColumn.values?this.selectedColumn.values.length:2:c&&c.toLowerCase().indexOf("between")>-1?2:1;for(var y=0;y<v;y++){var C=void 0;C=this.createElement("input",{attrs:{type:"text",id:m+"_valuekey"+y}}),e.nextElementSibling.appendChild(C)}}this.renderControls(e,l,n,o,h)}},c.prototype.setColumnTemplate=function(e,l,i,r,n,o){var s,a=this,u=!0;if(e.template){if("string"==typeof e.template||void 0===e.template.create)return s={requestType:"value-template-initialize",ruleID:l,field:i,operator:r,rule:o,renderTemplate:!0},this.trigger("actionBegin",s,function(t){u=a.actionBeginSuccessCallBack(t,e,l,i,n)}),u;var d=void 0,p=e.template;if((d="string"==typeof p.create?t.getValue(p.create,window)({field:i,operator:r}):p.create({field:i,operator:r}))instanceof Element)d.id=l+"_valuekey0",t.addClass([d],"e-template"),n.nextElementSibling.appendChild(d),i.indexOf(" ")<0&&t.addClass([d],"e-"+i);else if(d instanceof Array){t.addClass(d,"e-template");for(var c=0,h=d.length;c<h;c++)d[c].id=l+"_valuekey"+c,n.nextElementSibling.appendChild(d[c])}return t.addClass([n.nextElementSibling],"e-template-value"),!0}return!0},c.prototype.actionBeginSuccessCallBack=function(e,l,i,r,n){if(e.renderTemplate){var o=void 0;this.columnTemplateFn=this.templateParser(l.template);var s=this.element.id+r;if(this.isReact)o=this.columnTemplateFn(e,this,i,s)[0];else if(this.isAngular){var a=this.columnTemplateFn(e,this,i,s);o=3===a[0].nodeType?a[1]:a[0]}else o=this.columnTemplateFn(e,this,"Template",s)[0];return n.nextElementSibling.appendChild(o),t.addClass([n.nextElementSibling],"e-template-value"),this.renderReactTemplates(),!0}return!1},c.prototype.updateValues=function(e,l){var i=1;e.className.indexOf("e-template")>-1&&(i=3);var r=e.className.split(" e-")[i],n=parseInt(e.id.slice(-1),2);switch(r){case"checkbox":var o=t.getComponent(e,r).value;l.value=""!==o?o:void 0;break;case"textbox":case"dropdownlist":l.value=t.getComponent(e,r).value;break;case"radio":var s=t.getComponent(e,r);s.checked&&("boolean"==typeof l.value?l.value="true"===s.value:this.getColumn(l.field).values?l.value=s.value:l.value="true"===s.value),s.refresh();break;case"numerictextbox":l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[n]=t.getComponent(e,r).value):l.value=t.getComponent(e,r).value;break;case"datepicker":var a=this.getColumn(l.field),u=this.getFormat(a.format),d=t.getComponent(e,r).value;l.operator.indexOf("between")>-1?("string"==typeof l.value&&(l.value=[]),l.value[n]=this.intl.formatDate(d,u)):t.isNullOrUndefined(u.format)&&d?l.value=this.intl.formatDate(d):l.value=d?this.intl.formatDate(d,u):d;break;case"multiselect":l.value=t.getComponent(e,r).value}},c.prototype.updateRules=function(e,l,i,r){for(var n,o,s,a=t.closest(e,".e-group-container"),u=this.getParentGroup(a),d=t.closest(e,".e-rule-container"),p=0,c=a.id.replace(this.element.id+"_",""),h=this.getValidRules(this.rule);d&&null!==d.previousElementSibling;)d=d.previousElementSibling,p++;var m=u.rules[p].operator?u.rules[p].operator.toString():"";if(d=t.closest(e,".e-rule-container"),s=d.id.replace(this.element.id+"_",""),t.closest(e,".e-rule-filter")||t.closest(e,".e-rule-sub-filter")){this.subFieldElem&&(e=this.subFieldElem),n=t.getComponent(e,"dropdownlist");var f=this.getColumn(n.value);!this.isImportRules&&u.rules[p].field&&u.rules[p].field.toLowerCase()!==f.field.toLowerCase()&&(!d.querySelectorAll(".e-template")&&!(m.indexOf("null")>-1)||m.indexOf("empty")>-1)&&(u.rules[p].value=""),this.selectedColumn=n.getDataByValue(n.value),u.rules[p].field=this.selectedColumn.field,u.rules[p].type=this.selectedColumn.type,u.rules[p].label=this.selectedColumn.label;var g=t.closest(e,".e-rule-filter"),v=(g=g||t.closest(e,".e-rule-sub-filter")).nextElementSibling.querySelector("input.e-control");v=v||g.nextElementSibling.nextElementSibling.querySelector("input.e-control"),m=t.getComponent(v,"dropdownlist").value.toString(),u.rules[p].operator=m;var y=g.nextElementSibling.nextElementSibling,C=y.querySelectorAll("input.e-control");C.length<1&&(C=y.querySelectorAll("div.e-control")),C.length<1&&(C=y.querySelectorAll(".e-template"));for(var b=0;b<C.length;b++)o={groupID:c,ruleID:s,value:u.rules[p].field,type:"field"},m.indexOf("null")>-1||m.indexOf("empty")>-1?u.rules[p].value=null:this.updateValues(C[b],u.rules[p]);this.isImportRules||this.trigger("change",o),this.allowValidation&&u.rules[p].field&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),this.filterRules(h,this.getValidRules(this.rule),"field")}else if(t.closest(e,".e-rule-operator")){n=t.getComponent(e,"dropdownlist"),u.rules[p].operator=n.value.toString();var S=void 0;S=d.querySelectorAll(".e-rule-value input.e-control"),o={groupID:c,ruleID:s,value:n.value,type:"operator"},this.allowValidation&&u.rules[p].operator&&e.parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(e.parentElement,"tooltip").destroy(),S.length>1&&!(S[0].className.indexOf("e-template")>-1)&&(u.rules[p].value=[]);for(var x=0;x<S.length;x++)u.rules[p].operator.indexOf("null")>-1||u.rules[p].operator.indexOf("empty")>-1?u.rules[p].value=null:S[x].classList.contains("e-template")||this.updateValues(S[x],u.rules[p]);this.isImportRules||this.trigger("change",o),this.filterRules(h,this.getValidRules(this.rule),"operator")}else t.closest(e,".e-rule-value")&&(this.ruleValueUpdate(e,l,u,p,a,d,i),r||this.filterRules(h,this.getValidRules(this.rule),"value"))},c.prototype.filterRules=function(e,t,l){JSON.stringify({condition:e.condition,not:e.not,rule:e.rules})!==JSON.stringify({condition:t.condition,not:t.not,rule:t.rules})&&(this.isImportRules||this.trigger("ruleChange",{previousRule:e,rule:t,type:l}))},c.prototype.ruleValueUpdate=function(e,l,r,n,o,s,a){var u,d,p=["in","between","notin","notbetween"];if(r.rules[n].operator&&(d=r.rules[n].operator.toString().toLowerCase()),null!==l){if(e.className.indexOf("e-multiselect")>-1&&"number"===r.rules[n].type&&!this.isNotified){for(var c=[],h=l,m=0,f=h.length;m<f;m++)"string"==typeof h[m]&&c.push(parseFloat(h[m]));c.length&&(l=c)}if(this.isNotified)r.rules[n].value=l,u={groupID:o.id,ruleID:s.id,value:r.rules[n].value,type:"value"},this.isImportRules||this.trigger("change",u);else if(e.className.indexOf("e-spin")>-1||e.className.indexOf("e-numeric")>-1)p.indexOf(d)>-1?r.rules[n].value[a]=l:r.rules[n].value=l;else if(e.className.indexOf("e-radio")>-1)r.rules[n].value=l;else if(e.className.indexOf("e-multiselect")>-1)r.rules[n].value=l;else if(e.className.indexOf("e-textbox")>-1)"in"===d||"notin"===d?(r.rules[n].type,r.rules[n].value=this.processValueString(l,r.rules[n].type)):r.rules[n].value=l;else if(e.className.indexOf("e-datepicker")>-1){var g=t.getInstance(s.querySelector(".e-rule-filter input"),i.DropDownList),v=this.getFormat(this.getColumn(g.value).format);v.type&&(p.indexOf(d)>-1?("string"==typeof r.rules[n].value&&(r.rules[n].value=[]),r.rules[n].value[a]=this.intl.formatDate(l,v)):r.rules[n].value=this.intl.formatDate(l,v))}this.validatValue(r,s,n)}else e.className.indexOf("e-datepicker")>-1&&p.indexOf(d)>-1?("string"==typeof r.rules[n].value&&(r.rules[n].value=[]),r.rules[n].value[a]=l):r.rules[n].value=l},c.prototype.validatValue=function(e,l,i){t.isNullOrUndefined(i)||(e=e.rules[i]);var r="object"==typeof e.value;if(this.allowValidation&&(t.isNullOrUndefined(i)||(r?e.value.length>0:e.value))){var n=l.querySelectorAll(".e-rule-value .e-control");n.length>0&&(n[0].className.indexOf("e-tooltip")>-1?t.getComponent(n[0],"tooltip").destroy():n[0].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(n[0].parentElement,"tooltip").destroy(),n[1]&&n[1].parentElement.className.indexOf("e-tooltip")>-1&&t.getComponent(n[1].parentElement,"tooltip").destroy())}},c.prototype.getFormat=function(e){var t;return e?"string"==typeof e?(t={type:"dateTime"},"short"===e||"yMd"===e?(t.type="date",t.skeleton=e):t.format=e):t={type:"dateTime",skeleton:e.skeleton}:t={type:"date",skeleton:"yMd"},t},c.prototype.findGroupByIdx=function(e,t,l){var i=t.rules,r=[];if(!l){for(var n=0,o=i.length;n<o;n++)(t=i[n]).rules&&r.push(t);return r[e]}return t},c.prototype.destroy=function(){if(this.element){var l,i,r,n;for(e.prototype.destroy.call(this),r=(l=this.element.querySelectorAll(".e-addrulegroup")).length,i=0;i<r;i++)t.getComponent(l[i],"dropdown-btn").destroy(),t.detach(l[i]);for(n=this.element.querySelectorAll(".e-rule-filter .e-control.e-tooltip"),i=0;i<n.length;i++)t.getComponent(n[i],"tooltip").destroy();for(r=(l=this.element.querySelectorAll(".e-rule-filter .e-control:not(.e-tooltip)")).length,i=0;i<r;i++)t.getComponent(l[i],"dropdownlist").destroy(),t.detach(l[i]);for(n=this.element.querySelectorAll(".e-rule-operator .e-control.e-tooltip"),i=0;i<n.length;i++)t.getComponent(n[i],"tooltip").destroy();for(r=(l=this.element.querySelectorAll(".e-rule-operator .e-control:not(.e-tooltip)")).length,i=0;i<r;i++)t.getComponent(l[i],"dropdownlist").destroy(),t.detach(l[i]);for(n=this.element.querySelectorAll(".e-rule-value .e-control.e-tooltip"),i=0;i<n.length;i++)t.getComponent(n[i],"tooltip").destroy();this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_group0"]=[0],this.element.innerHTML="",this.portals&&this.portals.length&&this.clearQBTemplate(),t.classList(this.element,[],["e-rtl","e-responsive","e-device"])}},c.prototype.addRules=function(e,t){t=this.element.id+"_"+t,this.isPublic=!0;for(var l=0,i=e.length;l<i;l++)this.addRuleElement(document.getElementById(t),e[l]);this.isPublic=!1},c.prototype.addGroups=function(e,t){if(this.isAddSuccess||this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){t=this.element.id+"_"+t;var l=document.getElementById(t),i=this.getParentGroup(l);if(e.length){this.isPublic=!0;for(var r=0,n=e.length;r<n;r++)this.updatedRule={condition:e[r].condition,not:e[r].not},this.importRules(e[r],l,!1,e[r].not);this.isPublic=!1}else{var o="and",s=!1;this.updatedRule&&(o=this.updatedRule.condition,s=this.updatedRule.not),this.enableNotCondition?i.rules.push({condition:o,not:s,rules:[]}):i.rules.push({condition:o,rules:[]})}this.headerTemplate||this.disableRuleCondition(l,i)}},c.prototype.initWrapper=function(){if(this.isInitialLoad=!0,this.cssClass&&t.addClass([this.element],this.cssClass),this.enableRtl&&t.addClass([this.element],"e-rtl"),this.width&&(this.element.style.width=this.width),this.height&&(this.element.style.height=this.height),this.rule.rules.length?this.isImportRules=!0:this.addGroupElement(!1,this.element),t.Browser.isDevice||"Vertical"===this.displayMode?(t.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),t.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),t.addClass(this.element.querySelectorAll(".e-rule-container"),"e-vertical-mode"),this.displayMode="Vertical"):this.displayMode="Horizontal",this.summaryView)this.isImportRules?this.renderSummary():this.renderSummaryCollapse();else{if(this.columns.length&&this.isImportRules){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not);var e=t.extend({},this.rule,{},!0);this.isRefreshed=!0,this.setGroupRules(e),this.isRefreshed=!1}else this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{});this.notGroupRtl(),this.readonly&&this.enableReadonly();for(var l=this.element.querySelectorAll("label.e-btn"),i=void 0,r=0;r<l.length;r++)i=l.item(r),t.rippleEffect(i,{selector:".e-btn"})}},c.prototype.renderSummary=function(){var e=this.createElement("div",{attrs:{class:"e-summary-content",id:this.element.id+"_summary_content"}}),t=this.createElement("textarea",{attrs:{class:"e-summary-text",readonly:"true"},styles:"max-height:500px"}),l=this.createElement("button",{attrs:{class:"e-edit-rule e-css e-btn e-small e-flat e-primary"}}),i=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),l.textContent=this.l10n.getConstant("Edit"),i.appendChild(l),e.appendChild(i),this.element.appendChild(e)},c.prototype.renderSummaryCollapse=function(){var e=this.createElement("div",{attrs:{class:"e-collapse-rule e-icons",title:this.l10n.getConstant("SummaryViewTitle")}});this.element.querySelector(".e-group-header").appendChild(e)},c.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new r.DataManager(this.columns).executeLocal((new r.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new r.DataManager(this.columns).executeLocal((new r.Query).sortBy("field")))},c.prototype.onChangeNotGroup=function(){if(this.element.innerHTML="",this.groupIdCounter=0,!this.headerTemplate)if(this.enableNotCondition){if(this.enableNotCondition){var e=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}});this.groupElem.querySelector(".e-btn-group").insertBefore(e,this.groupElem.querySelector(".e-btngroup-and"))}}else this.groupElem.querySelector(".e-qb-toggle").remove();this.rule=this.checkNotGroup(this.rule),this.initWrapper()},c.prototype.notGroupRtl=function(){this.enableRtl?t.addClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl"):t.removeClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl")},c.prototype.checkNotGroup=function(e){var l;if(e.rules)for(var i=0;i<e.rules.length;i++)l=e.rules[i],l=this.checkNotGroup(l),e.rules[i]=l;return t.isNullOrUndefined(e.not)?this.enableNotCondition&&!t.isNullOrUndefined(e.condition)&&(e.not=!1):(this.enableNotCondition&&(e.not=!1),delete e.not),e},c.prototype.onPropertyChanged=function(e,l){for(var i=0,r=Object.keys(e);i<r.length;i++)switch(r[i]){case"summaryView":var n=this.element.querySelector(".e-group-container"),o=this.element.querySelector(".e-summary-content");e.summaryView?(n.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),o=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),o.style.display="block"):(n.querySelectorAll(".e-collapse-rule").length>-1&&this.renderSummaryCollapse(),n.style.display="block",o.style.display="none");break;case"displayMode":this.refresh();break;case"showButtons":e.showButtons.ruleDelete?t.removeClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"),e.showButtons.groupDelete?t.removeClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"):t.addClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide");break;case"cssClass":l.cssClass&&t.removeClass([this.element],l.cssClass.split(" ")),e.cssClass&&t.addClass([this.element],e.cssClass.split(" "));break;case"enableRtl":e.enableRtl?(t.addClass([this.element],"e-rtl"),this.notGroupRtl()):(t.removeClass([this.element],"e-rtl"),this.notGroupRtl());break;case"enablePersistence":this.enablePersistence=e.enablePersistence;break;case"dataSource":this.dataSource=e.dataSource,this.refresh();break;case"columns":this.columns=e.columns,this.columnSort();break;case"sortDirection":this.sortDirection=e.sortDirection,this.columnSort();break;case"maxGroupCount":this.maxGroupCount=e.maxGroupCount;break;case"height":this.height=e.height,this.element.style.height=this.height;break;case"rule":this.rule=e.rule,e.rule=this.getRuleCollection(this.rule,!1);break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale,this.intl=new t.Internationalization(this.locale),this.isLocale=!0,this.refresh(),this.isLocale=!1;break;case"enableNotCondition":this.onChangeNotGroup();break;case"readonly":this.isReadonly=e.readonly,this.enableReadonly()}},c.prototype.preRender=function(){this.element.id=this.element.id||t.getUniqueID("ej2-querybuilder"),this.defaultLocale={StartsWith:"Starts With",EndsWith:"Ends With",Contains:"Contains",Equal:"Equal",NotEqual:"Not Equal",LessThan:"Less Than",LessThanOrEqual:"Less Than Or Equal",GreaterThan:"Greater Than",GreaterThanOrEqual:"Greater Than Or Equal",Between:"Between",NotBetween:"Not Between",In:"In",NotIn:"Not In",Remove:"REMOVE",SelectField:"Select a field",SelectOperator:"Select operator",DeleteRule:"Remove this condition",DeleteGroup:"Delete group",AddGroup:"Add Group",AddCondition:"Add Condition",Edit:"EDIT",ValidationMessage:"This field is required",SummaryViewTitle:"Summary View",OtherFields:"Other Fields",AND:"AND",OR:"OR",NOT:"NOT",SelectValue:"Enter Value",IsEmpty:"Is Empty",IsNotEmpty:"Is Not Empty",IsNull:"Is Null",IsNotNull:"Is Not Null",True:"true",False:"false",AddButton:"Add Group/Condition"},this.l10n=new t.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new t.Internationalization(this.locale),this.groupIdCounter=0,this.subFilterCounter=0,this.ruleIdCounter=0,this.btnGroupId=0,this.isImportRules=!1,this.parser=[],this.customOperators={stringOperator:[{value:"startswith",key:this.l10n.getConstant("StartsWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")},{value:"isempty",key:this.l10n.getConstant("IsEmpty")},{value:"isnotempty",key:this.l10n.getConstant("IsNotEmpty")}],dateOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")}],booleanOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"notequal",key:this.l10n.getConstant("NotEqual")}],numberOperator:[{value:"equal",key:this.l10n.getConstant("Equal")},{value:"greaterthanorequal",key:this.l10n.getConstant("GreaterThanOrEqual")},{value:"greaterthan",key:this.l10n.getConstant("GreaterThan")},{value:"between",key:this.l10n.getConstant("Between")},{value:"lessthan",key:this.l10n.getConstant("LessThan")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")},{value:"lessthanorequal",key:this.l10n.getConstant("LessThanOrEqual")},{value:"notequal",key:this.l10n.getConstant("NotEqual")},{value:"in",key:this.l10n.getConstant("In")},{value:"notin",key:this.l10n.getConstant("NotIn")}]},this.operators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:"IN",notin:"NOT IN",lessthanorequal:"<=",startswith:"LIKE",endswith:"LIKE",between:"BETWEEN",notbetween:"NOT BETWEEN",contains:"LIKE",isnull:"IS NULL",isnotnull:"IS NOT NULL",isempty:"IS EMPTY",isnotempty:"IS NOT EMPTY",notstartswith:"NOT LIKE",notendswith:"NOT LIKE",notcontains:"NOT LIKE"},this.fields||(this.fields={text:"label",value:"field"})},c.prototype.render=function(){this.levelColl={},this.items=[{text:this.l10n.getConstant("AddGroup"),iconCss:"e-icons e-add-icon e-addgroup"},{text:this.l10n.getConstant("AddCondition"),iconCss:"e-icons e-add-icon e-addrule"}],this.ruleElem=this.ruleTemplate(),this.groupElem=this.groupTemplate();var e=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}],t=[{value:"isnull",key:this.l10n.getConstant("IsNull")},{value:"isnotnull",key:this.l10n.getConstant("IsNotNull")}];this.customOperators.stringOperator=this.customOperators.stringOperator.concat(e),this.customOperators.numberOperator=this.customOperators.numberOperator.concat(t),this.dataSource instanceof r.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new r.Query).take(1))):(this.dataManager=new r.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new r.Query),this.initControl()),this.renderComplete()},c.prototype.templateParser=function(e){if(e)try{if(document.querySelectorAll(e).length)return t.compile(document.querySelector(e).innerHTML.trim())}catch(l){return t.compile(e)}},c.prototype.executeDataManager=function(e){var t=this,l=this.dataManager.executeQuery(e),i=new r.Deferred;l.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){i.reject(e)})},c.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},c.prototype.wireEvents=function(){var e=this.getWrapper();t.EventHandler.add(e,"click",this.clickEventHandler,this),t.EventHandler.add(e,"focusout",this.focusEventHandler,this),t.EventHandler.add(e,"focusin",this.focusEventHandler,this),t.EventHandler.add(this.element,"keydown",this.keyBoardHandler,this)},c.prototype.unWireEvents=function(){var e=this.getWrapper();t.EventHandler.remove(e,"click",this.clickEventHandler),t.EventHandler.remove(e,"focusout",this.focusEventHandler),t.EventHandler.remove(e,"focusin",this.focusEventHandler),t.EventHandler.remove(this.element,"keydown",this.keyBoardHandler)},c.prototype.getParentGroup=function(e,t){for(var l=e instanceof Element?this.levelColl[e.id]:this.levelColl[e],i=t?l.length-1:l.length,r=this.rule,n=0;n<i;n++)r=this.findGroupByIdx(l[n],r,0===n);return r},c.prototype.deleteGroup=function(e){var t=this,l={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"deleteGroup"};this.isImportRules?this.deleteGroupSuccessCallBack(l,e):this.trigger("beforeChange",l,function(l){t.deleteGroupSuccessCallBack(l,e)})},c.prototype.deleteGroupSuccessCallBack=function(e,l){if(!e.cancel){var i=l,r=this.getParentGroup(i,!0),n=0,o=void 0,s=void 0,a=this.getValidRules(this.rule),u=i.nextElementSibling,d=i.previousElementSibling,p=i.querySelectorAll(".e-group-container"),c=i.querySelectorAll(".e-tooltip");for(s=c.length,o=0;o<s;o++)t.getComponent(c[o],"tooltip").destroy();for(o=0,s=p.length;o<s;o++)delete this.levelColl[p[o].id];for(;null!==i.previousElementSibling;)i=i.previousElementSibling,n++;u&&u.className.indexOf("e-separate-rule")>-1&&(t.removeClass([u],"e-separate-rule"),t.addClass([u],"e-joined-rule"),d&&d.className.indexOf("e-rule-container")>-1&&t.addClass([d],"e-prev-joined-rule"));var h=i.parentElement.parentElement.parentElement,m=[];if(this.isReact||this.isAngular){var f=r.rules[n],g=l.querySelectorAll(".e-rule-container");if(f&&f.rules)for(var v=0;v<f.rules.length;v++){var y=this.getColumn(f.rules[v].field),C=g[v].querySelector(".e-template-value");y&&(y.ruleTemplate||this.isPlatformTemplate(y)&&C)&&m.push(g[v].id)}}t.detach(l),this.headerTemplate&&this.clearQBTemplate([l.id]),m.length&&this.clearQBTemplate(m),r.rules.splice(n,1),delete this.levelColl[e.groupID],this.refreshLevelColl(),this.disableRuleCondition(h,r),this.isImportRules||this.trigger("change",e),this.filterRules(a,this.getValidRules(this.rule),"deleteGroup")}},c.prototype.isPlatformTemplate=function(e){return e.template&&("string"==typeof e.template||void 0===e.template.create)},c.prototype.deleteRule=function(e){var l,i,r=this,n={groupID:i=t.closest(e,".e-group-container").id.replace(this.element.id+"_",""),ruleID:l=t.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),cancel:!1,type:"deleteRule"};this.isImportRules?this.deleteRuleSuccessCallBack(n,e):this.trigger("beforeChange",n,function(t){r.deleteRuleSuccessCallBack(t,e)})},c.prototype.deleteRuleSuccessCallBack=function(e,l){if(!e.cancel){var i=t.closest(l,".e-group-container"),r=this.getParentGroup(i),n=t.closest(l,".e-rule-container"),o=this.getValidRules(this.rule),s=n,a=n.nextElementSibling,u=n.previousElementSibling,d=0,p=n.querySelectorAll(".e-tooltip"),c=void 0,h=p.length,m=void 0;for(c=0;c<h;c++)t.getComponent(p[c],"tooltip").destroy();for(;null!==n.previousElementSibling;)n=n.previousElementSibling,d++;(m=this.getColumn(r.rules[d].field))&&m.template&&s.querySelector(".e-template")&&this.templateDestroy(m,s.querySelector(".e-template").id),(!u||u.className.indexOf("e-rule-container")<0)&&a&&t.removeClass([a],"e-joined-rule"),(!a||a.className.indexOf("e-rule-container")<0)&&u&&t.removeClass([u],"e-prev-joined-rule");var f=s.querySelector(".e-template-value");t.detach(s),m&&m.ruleTemplate&&this.clearQBTemplate([s.id]),m&&this.isPlatformTemplate(m)&&f&&this.clearQBTemplate([s.id]),r.rules.splice(d,1),r.rules[0]&&r.rules[0].rules||this.disableRuleCondition(i,r),this.isImportRules||this.trigger("change",e),this.filterRules(o,this.getValidRules(this.rule),"deleteRule")}},c.prototype.setGroupRules=function(e){this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.rule=e,e=this.getRuleCollection(this.rule,!1),this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0),this.isImportRules=!1},c.prototype.keyBoardHandler=function(e){!this.readonly||38!==e.keyCode&&40!==e.keyCode&&13!==e.keyCode||e.preventDefault()},c.prototype.clearQBTemplate=function(e){(this.isReact||this.isAngular)&&this.clearTemplate(e)},c.prototype.disableRuleCondition=function(e,t){if(!this.headerTemplate){if(this.readonly)return;var l=e.querySelector(".e-rule-list").childElementCount,i=e.querySelector(".e-btngroup-and"),r=e.querySelector(".e-btngroup-or");l>1?(i.disabled=!1,r.disabled=!1,(r.nextElementSibling.classList.contains("e-btn-disable")||i.nextElementSibling.classList.contains("e-btn-disable"))&&(r.nextElementSibling.classList.remove("e-btn-disable"),i.nextElementSibling.classList.remove("e-btn-disable")),t&&"or"===t.condition?r.checked=!0:i.checked=!0):(i.checked=!1,i.disabled=!0,r.checked=!1,r.disabled=!0,t&&(r.nextElementSibling.classList.add("e-btn-disable"),i.nextElementSibling.classList.add("e-btn-disable")))}},c.prototype.getValidRules=function(e){e||(e=this.getRules());var l=e.condition,i=e.not,r=t.extend([],e.rules,[],!0);return this.getRuleCollection({condition:l,rules:r,not:i},!0)},c.prototype.getRuleCollection=function(e,t){var l;if(e.rules&&e.rules.length&&(Object.keys(e.rules[0]).length>6||t))for(var i=e.rules.length,r=0;r<i;r++)l=e.rules[r],l=this.getRuleCollection(l,t),e.rules[r]=l,Object.keys(l).length<1&&t&&(e.rules.splice(r,1),r--,i--);if(e.condition||""===e.condition)e=this.enableNotCondition?{condition:e.condition,rules:e.rules,not:e.not}:{condition:e.condition,rules:e.rules};else if(e.operator&&(e.operator.toString().indexOf("null")>-1||e.operator.toString().indexOf("empty")>-1)&&(e.value=null),this.isRefreshed&&this.enablePersistence||""!==this.rule.field&&""!==e.operator&&""!==e.value&&void 0!==e.value){var n=e.custom;e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value},n&&(e.custom=n)}else e={};return e},c.prototype.setRules=function(e){var l=t.extend({},e,{},!0);this.setGroupRules(l)},c.prototype.getRules=function(){return this.enableNotCondition?{condition:this.rule.condition,rules:this.rule.rules,not:this.rule.not}:{condition:this.rule.condition,rules:this.rule.rules}},c.prototype.getRule=function(e){var l,i,r=0;e instanceof HTMLElement?l=t.closest(e,".e-rule-container"):(i=this.element.id+"_"+e,l=document.getElementById(i));for(var n=t.closest(l,".e-group-container"),o=this.getParentGroup(n);null!==l.previousElementSibling;)l=l.previousElementSibling,r++;return o.rules[r]},c.prototype.getGroup=function(e){e instanceof Element&&e.className.indexOf("e-group-container")<1&&(e=t.closest(e,".e-group-container"));var l=e instanceof Element?e.id:this.element.id+"_"+e,i=this.getParentGroup(l);return this.enableNotCondition?{rules:i.rules,condition:i.condition,not:i.not}:{rules:i.rules,condition:i.condition}},c.prototype.deleteGroups=function(e){var t,l,i=e.length;for(t=0;t<i;t++)l=this.element.id+"_"+e[t],this.deleteGroup(document.getElementById(l))},c.prototype.getFilteredRecords=function(){var e,l=this.getPredicate(this.getValidRules(this.rule));return e=t.isNullOrUndefined(l)?new r.Query:(new r.Query).where(l),this.dataManager.executeQuery(e)},c.prototype.deleteRules=function(e){var t,l,i=e.length;for(t=0;t<i;t++)l=this.element.id+"_"+e[t],this.deleteRule(document.getElementById(l))},c.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),l=[],i=0,n=Object.keys(this.columns);i<n.length;i++)l.push(this.columns[i].field);return e.rules.length?(new r.Query).select(l).where(t):(new r.Query).select(l)},c.prototype.getPredicate=function(e){var l,i,n,o,s=e.rules,a=!1,u=["notcontains","notstartswith","notendswith"];if(!s)return l;for(var d=0,p=s.length;d<p;d++)if(a=!1,Object.keys(s[d]).indexOf("rules")>-1&&s[d].rules)(i=this.getPredicate(s[d]))&&(l=l?"and"===e.condition?l.and(i):l.or(i):i);else if(s[d].operator.length){var c=s[d].operator.toLowerCase(),h=!1,m=["equal","notequal","greaterthan","greaterthanorequal","lessthan","lessthanorequal"];if("string"===s[d].type&&(a=!this.matchCase),"date"===s[d].type&&m.indexOf(c)>-1&&(a=!0),o=this.getColumn(s[d].field),c.indexOf("null")>-1||c.indexOf("empty")>-1)s[d].value=null;else if("date"!==s[d].type||s[d].value instanceof Array)n=s[d].value;else{var f=this.getFormat(o.format);t.isNullOrUndefined(s[d].value)?n=null:(n=this.getDate(s[d].value,f),m.indexOf(c)>-1&&!this.isTime(s[d].value)&&(h=!0))}if(0===d)h||(c.indexOf("in")>-1||c.indexOf("between")>-1||c.indexOf("null")>-1||c.indexOf("empty")>-1)&&c.indexOf("contains")<0?l=h?this.datePredicate(s[d],n):this.arrayPredicate(s[d]):""!==(g=n)&&u.indexOf(c)<0&&(l=new r.Predicate(s[d].field,s[d].operator,n,a));else{if(u.indexOf(c)>-1)continue;if(h||(c.indexOf("in")>-1||c.indexOf("between")>-1||c.indexOf("null")>-1||c.indexOf("empty")>-1)&&c.indexOf("contains")<0)l=h?this.datePredicate(s[d],n,l,e.condition):this.arrayPredicate(s[d],l,e.condition);else if("and"===e.condition){g=n;l&&""!==g?l=l.and(s[d].field,s[d].operator,n,a):""!==g&&(l=new r.Predicate(s[d].field,s[d].operator,n,a))}else{var g=n;l&&""!==g?l=l.or(s[d].field,s[d].operator,n,a):""!==g&&(l=new r.Predicate(s[d].field,s[d].operator,n,a))}}}return l},c.prototype.getLocale=function(){var e=this.locale;return t.getValue("main."+this.locale+".dates.calendars.gregorian.days.format.short",t.cldrData)||(e="en"),e},c.prototype.getColumn=function(e,t){for(var l,i=this.columns,r=0,n=(i=t||i).length;r<n;r++){if(i[r].field===e){l=i[r];break}if(i[r].columns&&(l=this.getColumn(e,i[r].columns)))break}return l},c.prototype.getOperators=function(e){return this.getColumn(e).operators},c.prototype.setTime=function(e,t){return t?e.setHours(0,0,0):e.setHours(23,59,59),e},c.prototype.datePredicate=function(e,t,l,i){var n,o=this.setTime(new Date(t.getTime()),!0),s=this.setTime(t);switch(e.operator){case"equal":n=(n=new r.Predicate(e.field,"greaterthanorequal",o)).and(e.field,"lessthanorequal",s);break;case"notequal":n=(n=new r.Predicate(e.field,"lessthan",o)).or(e.field,"greaterthan",s);break;case"greaterthan":n=new r.Predicate(e.field,"greaterthan",s);break;case"greaterthanorequal":n=new r.Predicate(e.field,"greaterthanorequal",o);break;case"lessthan":n=new r.Predicate(e.field,"lessthan",o);break;case"lessthanorequal":n=new r.Predicate(e.field,"lessthanorequal",s)}return n&&(l?"and"===i?l=l.and(n):"or"===i&&(l=l.or(n)):l=n),l},c.prototype.arrayPredicate=function(e,t,l){var i,n,o=e.value,s=e.operator.toString(),a=e.value,u=this.getColumn(e.field);if(i=this.getFormat(u.format),s.indexOf("null")>-1||s.indexOf("empty")>-1)switch(s){case"isnull":n=new r.Predicate(e.field,"isnull",a);break;case"isnotnull":n=new r.Predicate(e.field,"notnull",a);break;case"isempty":n=new r.Predicate(e.field,"equal","");break;case"isnotempty":n=new r.Predicate(e.field,"notequal","")}if(!(s.indexOf("null")>-1||s.indexOf("empty")>-1))for(var d=0,p=o.length;d<p;d++)if(""!==o[d])if(0===d){var c="greaterthanorequal";switch(s){case"between":n="date"!==u.type?new r.Predicate(e.field,c,o[d]):new r.Predicate(e.field,c,o[d]?this.isTime(o[d])?this.getDate(o[d],i):this.setTime(this.getDate(o[d],i),!0):null);break;case"notbetween":n="date"===u.type?new r.Predicate(e.field,"lessthan",o[d]?this.isTime(o[d])?this.getDate(o[d],i):this.setTime(this.getDate(o[d],i),!0):null):new r.Predicate(e.field,"lessthan",o[d]);break;case"in":n=new r.Predicate(e.field,"equal",o[d]);break;case"notin":n=new r.Predicate(e.field,"notequal",o[d])}}else{switch(e.operator){case"between":n="date"===u.type?n.and(e.field,"lessthanorequal",o[d]?this.isTime(o[d])?this.getDate(o[d],i):this.setTime(this.getDate(o[d],i)):o[d]):n.and(e.field,"lessthanorequal",o[d]);break;case"notbetween":n="date"===u.type?n.or(e.field,"greaterthan",o[d]?this.isTime(o[d])?this.getDate(o[d],i):this.setTime(this.getDate(o[d],i)):o[d]):n.or(e.field,"greaterthan",o[d]);break;case"in":n=n.or(e.field,"equal",o[d]);break;case"notin":n=n.and(e.field,"notequal",o[d])}}return n&&(t?"and"===l?t=t.and(n):"or"===l&&(t=t.or(n)):t=n),t},c.prototype.getDate=function(e,t){var l=this.intl.parseDate(e,t);return e.indexOf(":")>-1&&e.indexOf("/")<0&&e.indexOf(",")<0&&e.indexOf("-")<0&&((l=new Date).setHours(parseInt(e.split(":")[0])),l.setMinutes(parseInt(e.split(":")[1])),e.split(":")[2]&&l.setSeconds(parseInt(e.split(":")[2]))),l},c.prototype.isTime=function(e){return!!(e&&e.indexOf(":")>-1)},c.prototype.importRules=function(e,l,i,r){if(i){if(e.rules.length>1&&!this.headerTemplate){var n=l.querySelector(".e-btngroup-or"),o=l.querySelector(".e-btngroup-and");n.disabled=!1,o.disabled=!1,"or"===e.condition?n.checked=!0:o.checked=!0}else this.disableRuleCondition(l);if(this.enableNotCondition&&!this.headerTemplate){var s=l.querySelector(".e-qb-toggle");e.not?t.addClass([s],"e-active-toggle"):t.removeClass([s],"e-active-toggle")}}else l=this.renderGroup(e.condition,l,r);var a=e.rules;if(!t.isNullOrUndefined(a))for(var u=0,d=a.length;u<d;u++){var p=Object.keys(a[u]);!t.isNullOrUndefined(a[u].rules)&&p.indexOf("rules")>-1?(l=this.renderGroup(a[u].condition,l,a[u].not),l=this.importRules(a[u],l,!0)):this.renderRule(a[u],l)}return(l=t.closest(l,".e-rule-list"))&&(l=t.closest(l,".e-group-container")),l},c.prototype.renderGroup=function(e,t,l){this.addGroupElement(!0,t,e,!1,l);var i=t.querySelectorAll(".e-group-container");return i[i.length-1]},c.prototype.renderRule=function(e,t){t.className.indexOf("e-group-container")>-1?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},c.prototype.enableReadonly=function(){for(var e=this.element.querySelectorAll(".e-dropdownlist, .e-numerictextbox, .e-textbox, .e-datepicker, .e-multiselect .e-lib, .e-radio"),r=0;r<e.length;r++)e[r].classList.contains("e-dropdownlist")?t.getInstance(e[r],i.DropDownList).readonly=this.isReadonly:e[r].classList.contains("e-numerictextbox")?t.getInstance(e[r],n.NumericTextBox).readonly=this.isReadonly:e[r].classList.contains("e-textbox")?t.getInstance(e[r],n.TextBox).readonly=this.isReadonly:e[r].classList.contains("e-datepicker")?t.getInstance(e[r],o.DatePicker).readonly=this.isReadonly:e[r].classList.contains("e-multiselect")?t.getInstance(e[r],i.MultiSelect).readonly=this.isReadonly:e[r].classList.contains("e-radio")&&(t.getInstance(e[r],l.RadioButton).checked||(this.isReadonly?e[r].parentElement.style.display="none":e[r].parentElement.style.display="inherit"));var s=this.element.querySelectorAll(".e-deletegroup"),a=this.element.querySelectorAll(".e-addrulegroup"),u=this.element.querySelectorAll(".e-removerule");!this.isReadonly&&this.ruleElem.classList.contains("e-readonly")&&this.ruleElem.classList.remove("e-readonly");for(var d=[s,a,u],r=0;r<d.length;r++)d[r].forEach(function(e){e.classList.contains("e-readonly")?e.classList.remove("e-readonly"):e.classList.add("e-readonly")});this.enableBtnGroup()},c.prototype.enableBtnGroup=function(){var e=this,t=!1;this.element.querySelectorAll(".e-btngroup-and-lbl, .e-btngroup-or-lbl, .e-qb-toggle").forEach(function(l){!l.classList.contains("e-qb-toggle")||l.classList.contains("e-active-toggle")||l.classList.contains("e-readonly")?l.classList.contains("e-qb-toggle")&&l.classList.contains("e-not-readonly")?l.classList.remove("e-not-readonly"):l.classList.contains("e-qb-toggle")&&l.classList.contains("e-readonly")?l.classList.remove("e-readonly"):l.classList.contains("e-active-toggle")?(l.classList.add("e-not-readonly"),t=!0):l.previousElementSibling.checked||l.classList.contains("e-readonly")?(l.classList.remove("e-readonly"),t?"AND"===l.textContent?l.classList.add("e-readonly-and"):l.classList.add("e-readonly-or"):("AND"===l.textContent&&e.isReadonly?(l.classList.remove("e-not"),l.classList.add("e-readonly-and")):(e.enableNotCondition&&l.classList.add("e-not"),l.classList.remove("e-readonly-and")),"OR"===l.textContent&&e.isReadonly?l.classList.add("e-readonly-or-not"):l.classList.remove("e-readonly-or-not"))):l.classList.contains("e-btn-disable")||l.classList.add("e-readonly"):(l.classList.add("e-readonly"),t=!1)})},c.prototype.isDateFunction=function(e){for(var t=["date","time","day","week","month","year","hour","minute","second","now","quarter","period","extract"],l=0,i=t.length;l<i;l++)if(e.toLowerCase().indexOf(t[l])>-1)return!0;return!1},c.prototype.getSqlString=function(e,t,l){var i=!1;l||""===l?l+="(":(l="",i=!0);var r=e.condition;e.not&&(l+=i?"NOT (":" NOT (");for(var n=0,o=e.rules.length;n<o;n++){if(e.rules[n].rules)l=this.getSqlString(e.rules[n],t,l);else{var s=e.rules[n],a="";if(s.value instanceof Array)if(s.operator.toString().indexOf("between")>-1)"date"!==s.type||this.isDateFunction(s.value[0])?a+=s.value[0]+" AND "+s.value[1]:a+='"'+s.value[0]+'" AND "'+s.value[1]+'"';else if("string"==typeof s.value[0]&&null!==s.value){a+='("'+s.value[0]+'"';for(var u=1,d=s.value.length;u<d;u++)a+=',"'+s.value[u]+'"';a+=")"}else a+="("+s.value+")";else s.operator.toString().indexOf("startswith")>-1?a+=s.value?'("'+s.value+'%")':"("+s.value+")":s.operator.toString().indexOf("endswith")>-1?a+=s.value?'("%'+s.value+'")':"("+s.value+")":s.operator.toString().indexOf("contains")>-1?a+=s.value?'("%'+s.value+'%")':"("+s.value+")":"number"===s.type||"boolean"==typeof s.value||null===s.value?a+=s.value:a+='"'+s.value+'"';s.operator.toString().indexOf("null")>-1||s.operator.toString().indexOf("empty")>-1?(t?s.field="`"+s.field+"`":s.field.indexOf(" ")>-1&&(s.field='"'+s.field+'"'),l+=s.field+" "+this.operators[s.operator]):(t?s.field="`"+s.field+"`":s.field.indexOf(" ")>-1&&(s.field='"'+s.field+'"'),l+=s.field+" "+this.operators[s.operator]+" "+a)}n!==o-1&&(l+=" "+r.toUpperCase()+" ")}return i||(l+=")"),e.not&&(l+=")"),l},c.prototype.setRulesFromSql=function(e){e=e.replace(/`/g,"");var t=this.getRulesFromSql(e);this.setRules({condition:t.condition,not:t.not,rules:t.rules})},c.prototype.getRulesFromSql=function(e){this.parser=[],this.sqlParser(e),this.rule={condition:"and",not:!1,rules:[]};var t=this.processParser(this.parser,this.rule,[0]);return this.enableNotCondition?{condition:t.condition,not:t.not,rules:t.rules}:{condition:t.condition,rules:t.rules}},c.prototype.getSqlFromRules=function(e,t){return e||(e=this.getValidRules()),e=this.getRuleCollection(e,!1),this.getSqlString(this.getValidRules(e),t).replace(/"/g,"'")},c.prototype.sqlParser=function(e){var t,l=0;do{t=e.slice(l),l+=this.parseSqlStrings(t)}while(""!==t);return this.parser},c.prototype.parseSqlStrings=function(e){for(var t,l,i=["=","!=","<=",">=","<",">"],r=["AND","OR","NOT"],n=["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN","IS NULL","IS NOT NULL","IS EMPTY","IS NOT EMPTY"],o=0,s=i.length;o<s;o++)if(t=/^\w+$/.test(i[o])?"\\b":"",new RegExp("^("+i[o]+")"+t,"ig").exec(e))return this.parser.push(["Operators",i[o].toLowerCase()]),i[o].length;var a=this.parser[this.parser.length-1];if(!a||a&&"Literal"!==a[0])for(var o=0,s=r.length;o<s;o++)if(t=/^\w+$/.test(r[o])?"\\b":"",new RegExp("^("+r[o]+")"+t,"ig").exec(e))return this.parser.push(["Conditions",r[o].toLowerCase()]),r[o].length;for(var o=0,s=n.length;o<s;o++)if(t=/^\w+$/.test(n[o])?"\\b":"",new RegExp("^("+n[o]+")"+t,"ig").exec(e))return this.parser.push(["SubOperators",n[o].toLowerCase()]),n[o].length;return/^\(/.exec(e)?(this.parser.push(["Left","("]),1):/^\)/.exec(e)?(this.parser.push(["Right",")"]),1):/^(true|false)/.exec(e)?(l=/^(true|false)/.exec(e)[0],this.parser.push(["String",l]),l.length):/^null/.exec(e)?(l=/^null/.exec(e)[0],this.parser.push(["String",null]),l.length):/^`?([a-z_][a-z0-9_.\[\]\(\)]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)?(l=/^`?([a-z_][a-z0-9_.\[\]\(\)]{0,}(\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",l]),l.length):this.checkLiteral()&&/^'?([a-z_][a-z0-9 _.\[\]\(\)]{0,}(\:(number|float|string|date|boolean))?)'?/i.exec(e)?(l=/^'?([a-z_][a-z0-9 _.\[\]\(\)]{0,}(\:(number|float|string|date|boolean))?)'?/i.exec(e)[1],this.parser.push(["Literal",l]),l.length+2):/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)?(l=/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(e)[0],this.parser.push(["String",l]),l.length):/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)?(l=/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(e)[0],this.parser.push(["DoubleString",l]),l.length):/^[0-9]+(\.[0-9]+)?/.exec(e)?(l=/^[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",l]),l.length):/^-?[0-9]+(\.[0-9]+)?/.exec(e)?(l=/^-?[0-9]+(\.[0-9]+)?/.exec(e)[0],this.parser.push(["Number",l]),l.length):1},c.prototype.checkLiteral=function(){var e=this.parser[this.parser.length-1];if(!e)return!0;var t=this.parser[this.parser.length-2];return!("Left"!==e[0]||!t||"Conditions"!==t[0])},c.prototype.getOperator=function(e,t){var l={"=":"equal","!=":"notequal","<":"lessthan",">":"greaterthan","<=":"lessthanorequal",">=":"greaterthanorequal",in:"in","not in":"notin",between:"between","not between":"notbetween","is empty":"isempty","is null":"isnull","is not null":"isnotnull","is not empty":"isnotempty"};if(e){if(0===e.indexOf("%")&&"%"===e[e.length-1])return"not like"===t?"notcontains":"contains";if(0!==e.indexOf("%")&&e.indexOf("%")===e.length-1)return"not like"===t?"notstartswith":"startswith";if(0===e.indexOf("%")&&e.indexOf("%")!==e.length-1)return"not like"===t?"notendswith":"endswith"}else{if("not like"===t)return"notequal";if("like"===t)return"equal"}return l[t]},c.prototype.getTypeFromColumn=function(e){for(var t=this.columns,l=0;l<t.length;l++)if(t[l].field===e.field){e.type=t[l].type;break}return e.type},c.prototype.processParser=function(e,t,l){for(var i,r,n,o,s,a,u,d,p,c,h=[],m=[],f=0,g=e.length;f<g;f++)if("Literal"===e[f][0]){if(n={label:e[f][1],field:e[f][1]},"SubOperators"===e[f+1][0]){if(e[f+1][1].indexOf("null")>-1||e[f+1][1].indexOf("empty")>-1)n.operator=this.getOperator(" ",e[f+1][1]),n.value=null,n.type=this.getTypeFromColumn(n);else{var v=e[f+3][1]?e[f+3][1].replace(/'/g,""):e[f+3][1];n.operator=this.getOperator(v,e[f+1][1])}for(c=e[f+1][1],i=++f+1,r=g,i=f+1;i<r;i++){if("Right"===e[i][0]){f=i;break}if(c.indexOf("null")>-1||c.indexOf("empty")>-1)break;if(c.indexOf("like")>-1&&"String"===e[i][0]){var y=e[i][1]?e[i][1].replace(/'/g,"").replace(/%/g,""):e[i][1];n.value=y,n.type="string"}else if(c.indexOf("between")>-1){if("Literal"===e[i][0]||"Left"===e[i][0])break;"Number"===e[i][0]?h.push(Number(e[i][1])):"String"===e[i][0]&&m.push(e[i][1].replace(/'/g,""))}else"Number"===e[i][0]?h.push(Number(e[i][1])):"String"===e[i][0]&&m.push(e[i][1].replace(/'/g,""));n.type=this.getTypeFromColumn(n)}c.indexOf("like")<0&&("Number"===e[i-1][0]?(n.value=h,n.type="number"):"String"===e[i-1][0]?(n.value=m,n.type="string"):c.indexOf("between")>-1&&"Conditions"===e[i-1][0]&&(n.value=h,n.type="number"),h=[],m=[],n.type=this.getTypeFromColumn(n))}else"Operators"===e[f+1][0]&&(n.operator=this.getOperator(e[f+2][1],e[f+1][1]),"Number"===e[f+2][0]?(n.type="number",n.value=Number(e[f+2][1])):(n.type="string",n.value=e[f+2][1]?e[f+2][1].replace(/'/g,""):e[f+2][1]),n.type=this.getTypeFromColumn(n));t.rules.push(n)}else{if("Left"===e[f][0]){if("Left"!==e[0][0]&&"not"===e[f-1][1])continue;for(this.parser=e.splice(f+1,g-(f+1)),o=this.enableNotCondition?{condition:"and",rules:[],not:!1}:{condition:"and",rules:[]},p=0,a=t.rules.length,s=0;s<a;s++)t.rules[s].rules&&p++;return l.push(p),t.rules.push(o),o=this.processParser(this.parser,o,l),t}if("Conditions"===e[f][0])"not"===e[f][1]?t.not=!0:t.condition=e[f][1];else if("Right"===e[f][0]){for(this.parser=e.splice(f+1,g-(f+1)),l.pop(),t=this.rule,d=l.length,u=0;u<d;u++)t=this.findGroupByIdx(l[u],t,0===u);return this.processParser(this.parser,t,l)}}return t},p([t.Event()],c.prototype,"created",void 0),p([t.Event()],c.prototype,"actionBegin",void 0),p([t.Event()],c.prototype,"beforeChange",void 0),p([t.Event()],c.prototype,"change",void 0),p([t.Event()],c.prototype,"dataBound",void 0),p([t.Event()],c.prototype,"ruleChange",void 0),p([t.Property({ruleDelete:!0,groupInsert:!0,groupDelete:!0})],c.prototype,"showButtons",void 0),p([t.Property(!1)],c.prototype,"summaryView",void 0),p([t.Property(!1)],c.prototype,"allowValidation",void 0),p([t.Property([])],c.prototype,"columns",void 0),p([t.Property(null)],c.prototype,"fieldModel",void 0),p([t.Property(null)],c.prototype,"operatorModel",void 0),p([t.Property(null)],c.prototype,"valueModel",void 0),p([t.Property()],c.prototype,"headerTemplate",void 0),p([t.Property("")],c.prototype,"cssClass",void 0),p([t.Property([])],c.prototype,"dataSource",void 0),p([t.Property("Horizontal")],c.prototype,"displayMode",void 0),p([t.Property(!1)],c.prototype,"enablePersistence",void 0),p([t.Property("Default")],c.prototype,"sortDirection",void 0),p([t.Property(5)],c.prototype,"maxGroupCount",void 0),p([t.Property("auto")],c.prototype,"height",void 0),p([t.Property("auto")],c.prototype,"width",void 0),p([t.Property(!1)],c.prototype,"matchCase",void 0),p([t.Property(0)],c.prototype,"immediateModeDelay",void 0),p([t.Property(!1)],c.prototype,"enableNotCondition",void 0),p([t.Property(!1)],c.prototype,"readonly",void 0),p([t.Property("")],c.prototype,"separator",void 0),p([t.Complex({condition:"and",rules:[]},h)],c.prototype,"rule",void 0),c=p([t.NotifyPropertyChanges],c)}(t.Component);return e.Columns=c,e.Rule=h,e.Value=m,e.ShowButtons=f,e.QueryBuilder=g,e}({},ej.base,ej.buttons,ej.dropdowns,ej.data,ej.inputs,ej.calendars,ej.splitbuttons,ej.popups),this.ejs=ej;