@syncfusion/ej2-querybuilder 27.2.3 → 27.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ej2-querybuilder.min.js +2 -2
- package/dist/ej2-querybuilder.umd.min.js +2 -2
- package/dist/ej2-querybuilder.umd.min.js.map +1 -1
- package/dist/es6/ej2-querybuilder.es2015.js +23 -1
- package/dist/es6/ej2-querybuilder.es2015.js.map +1 -1
- package/dist/es6/ej2-querybuilder.es5.js +24 -1
- package/dist/es6/ej2-querybuilder.es5.js.map +1 -1
- package/dist/global/ej2-querybuilder.min.js +2 -2
- package/dist/global/ej2-querybuilder.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +9 -9
- package/src/query-builder/query-builder.js +15 -0
- package/src/query-builder/query-library.js +9 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* filename: ej2-querybuilder.umd.min.js
|
|
3
|
-
* version : 27.2.
|
|
3
|
+
* version : 27.2.5
|
|
4
4
|
* Copyright Syncfusion Inc. 2001 - 2023. All rights reserved.
|
|
5
5
|
* Use of this code is subject to the terms of our license.
|
|
6
6
|
* A copy of the current license can be obtained at any time by e-mailing
|
|
7
7
|
* licensing@syncfusion.com. Any infringement will be prosecuted under
|
|
8
8
|
* applicable laws.
|
|
9
9
|
*/
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-buttons"),require("@syncfusion/ej2-dropdowns"),require("@syncfusion/ej2-data"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-calendars"),require("@syncfusion/ej2-splitbuttons"),require("@syncfusion/ej2-popups")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-buttons","@syncfusion/ej2-dropdowns","@syncfusion/ej2-data","@syncfusion/ej2-inputs","@syncfusion/ej2-calendars","@syncfusion/ej2-splitbuttons","@syncfusion/ej2-popups"],t):t((e=e||self).ej={},e.ej2Base,e.ej2Buttons,e.ej2Dropdowns,e.ej2Data,e.ej2Inputs,e.ej2Calendars,e.ej2Splitbuttons,e.ej2Popups)}(this,function(e,N,L,y,h,c,v,R,s){"use strict";n=function(e,t){return(n=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])}))(e,t)};var n,t,l=function(e,t){function l(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(l.prototype=t.prototype,new l)},b=function(){return(b=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var i in t=arguments[l])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)},i=function(e,t,l,n){var i,o=arguments.length,r=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,l):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,l,n);else for(var s=e.length-1;0<=s;s--)(i=e[s])&&(r=(o<3?i(r):3<o?i(t,l,r):i(t,l))||r);return 3<o&&r&&Object.defineProperty(t,l,r),r},o=(t=N.ChildProperty,l(r,t),i([N.Property(null)],r.prototype,"field",void 0),i([N.Property(null)],r.prototype,"label",void 0),i([N.Property(null)],r.prototype,"type",void 0),i([N.Property(null)],r.prototype,"values",void 0),i([N.Property(null)],r.prototype,"operators",void 0),i([N.Property()],r.prototype,"ruleTemplate",void 0),i([N.Property(null)],r.prototype,"template",void 0),i([N.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),i([N.Property(null)],r.prototype,"format",void 0),i([N.Property(null)],r.prototype,"step",void 0),i([N.Property(null)],r.prototype,"value",void 0),i([N.Property(null)],r.prototype,"category",void 0),i([N.Property(null)],r.prototype,"columns",void 0),r);function r(){return null!==t&&t.apply(this,arguments)||this}a=N.ChildProperty,l(d,a),i([N.Property(null)],d.prototype,"condition",void 0),i([N.Collection([],d)],d.prototype,"rules",void 0),i([N.Property(null)],d.prototype,"field",void 0),i([N.Property(null)],d.prototype,"label",void 0),i([N.Property(null)],d.prototype,"type",void 0),i([N.Property(null)],d.prototype,"operator",void 0),i([N.Property(null)],d.prototype,"value",void 0),i([N.Property(!1)],d.prototype,"not",void 0),i([N.Property(null)],d.prototype,"isLocked",void 0);var a,u=d;function d(){return null!==a&&a.apply(this,arguments)||this}p=N.ChildProperty,l(m,p),i([N.Property(null)],m.prototype,"numericTextBoxModel",void 0),i([N.Property(null)],m.prototype,"multiSelectModel",void 0),i([N.Property(null)],m.prototype,"datePickerModel",void 0),i([N.Property(null)],m.prototype,"textBoxModel",void 0),i([N.Property(null)],m.prototype,"radioButtonModel",void 0);var p,g=m;function m(){return null!==p&&p.apply(this,arguments)||this}f=N.ChildProperty,l(S,f),i([N.Property(!1)],S.prototype,"cloneRule",void 0),i([N.Property(!1)],S.prototype,"cloneGroup",void 0),i([N.Property(!1)],S.prototype,"lockRule",void 0),i([N.Property(!1)],S.prototype,"lockGroup",void 0),i([N.Property(!0)],S.prototype,"ruleDelete",void 0),i([N.Property(!0)],S.prototype,"groupInsert",void 0),i([N.Property(!0)],S.prototype,"groupDelete",void 0);var f,C=S;function S(){return null!==f&&f.apply(this,arguments)||this}x=N.Component,l(q,x),q.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},q.prototype.reset=function(){this.isImportRules=!1;for(var e,t,l,n=this.element.querySelector(".e-group-body"),i=this.element.querySelectorAll("input.e-control"),o=0,r=i.length;o<r;o++)-1<i[o].className.indexOf("e-tooltip")?N.getComponent(i[o],"tooltip").destroy():-1<i[o].parentElement.className.indexOf("e-tooltip")&&N.getComponent(i[o].parentElement,"tooltip").destroy();n?n.innerHTML="":(e=this.createElement("div",{attrs:{class:"e-group-container"}}),t=this.createElement("div",{attrs:{class:"e-group-header"}}),l=this.createElement("div",{attrs:{class:"e-group-body"}}),e.appendChild(t).appendChild(l),this.element.appendChild(e),n=this.element.querySelector(".e-group-body")),this.headerTemplate&&this.isRoot&&(this.element.innerHTML="",this.isRoot=!1),this.enableNotCondition&&N.removeClass(this.element.querySelectorAll(".e-qb-toggle"),"e-active-toggle"),n.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0),this.disableRuleCondition(n.parentElement)},q.prototype.getWrapper=function(){return this.element},q.prototype.getModuleName=function(){return"query-builder"},q.prototype.requiredModules=function(){var e=[];return e.push({member:"query-library",args:[this]}),e},q.prototype.GetRootColumnName=function(e){return this.separator?e.split(this.separator)[0]:e},q.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],l=[],n=void 0,i=!1,o=!1,r=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],"initial"),d[a].type||(-1<e.indexOf(d[a].field)&&("string"===(n=typeof(r=this.dataColl[0][d[a].field]))?o=!isNaN(Date.parse(r)):"object"===n&&(o=r instanceof Date&&!isNaN(r.getTime()),n="string"),d[a].type=n,o=!1),n="string"),d[a].validation||(d[a].validation=s),d[a].category?i=!0:d[a].category=this.l10n.getConstant("OtherFields"),l.indexOf(d[a].category)<0&&l.push(d[a].category),(!d[a].operators||this.isLocale&&-1===this.isCustomOprCols.indexOf(d[a].field))&&(d[a].operators=this.customOperators[d[a].type+"Operator"]);i&&(1<l.length||l[0]!==this.l10n.getConstant("OtherFields"))&&(this.fields={text:"label",value:"field",groupBy:"category"}),this.updateSubFieldsFromColumns(this.columns)}else{for(a=0,u=e.length;a<u;a++)"string"===(n=typeof(r=this.dataColl[0][e[a]]))?o=!isNaN(Date.parse(r)):"object"!==n||Object.keys(r).length||(o=r instanceof Date&&!isNaN(r.getTime()),n="string"),o=!(t[a]={field:e[a],label:e[a],type:o?"date":n,validation:s}),t[a].operators=this.customOperators[t[a].type+"Operator"],"object"===n&&this.updateSubFields(r,t[a]);this.columns=t}}else if(this.columns&&this.columns.length){for(var d,a=0,u=(d=this.columns).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],"initial"),(!d[a].operators||this.isLocale&&-1===this.isCustomOprCols.indexOf(d[a].field))&&(d[a].operators=this.customOperators[d[a].type+"Operator"]);this.updateSubFieldsFromColumns(this.columns)}this.trigger("dataBound",{type:"dataBound"})},q.prototype.updateSubFieldsFromColumns=function(e,t){for(var l=0;l<e.length;l++)""!==this.separator&&e[l].field.indexOf(this.separator)<0&&(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))},q.prototype.updateSubFields=function(e,t,l){t.columns=[];var n=Object.keys(e);l=l||this.dataColl[0];for(var i=0,o=n.length;i<o;i++){var r,s=t.field.split("."),s=(l?l[s[s.length-1]]:this.dataColl[0][t.field])[n[i]],a=l[t.field.split(this.separator)[t.field.split(this.separator).length-1]],u={field:t.field+this.separator+n[i],label:n[i],type:r="object"!=(r=typeof s)||isNaN(Date.parse(s))?r:"date"};"object"!=r&&(u.operators=this.customOperators[r+"Operator"]),t.columns.push(u),"object"==r&&this.updateSubFields(s,u,a)}},q.prototype.updateCustomOperator=function(i,e){if(i.operators){this.isLocale||"initial"!==e||N.isNullOrUndefined(this.isCustomOprCols)||this.isCustomOprCols.push(i.field);for(var o=this,t=0;t<i.operators.length;t++)!function(e){var t,l,n=Object.keys(i.operators[e]).indexOf("sqlOperator");-1<n&&(t=i.operators[e],l=(e=Object.keys(t)).map(function(e){return t[""+e]}).join(",").split(","),e=e.indexOf("value"),o.operators[l[e]]=l[n])}(t)}},q.prototype.focusEventHandler=function(e){this.target=e.target},q.prototype.clickEventHandler=function(e){var t,l,n,i,o=this,r=e.target;if(this.isImportRules=!1,"string"==typeof(r="SPAN"===r.tagName?r.parentElement:r).className&&-1<r.className.indexOf("e-collapse-rule")&&(u=new N.Animation({duration:1e3,delay:0}),this.element.querySelectorAll(".e-summary-content").length<1&&this.renderSummary(),i=(e=document.getElementById(this.element.id+"_summary_content")).querySelector(".e-summary-text"),u.animate(".e-query-builder",{name:"SlideLeftIn"}),(a=this.element.querySelector(".e-group-container")).style.display="none",i.textContent=this.getSqlFromRules(this.rule),e.style.display="block",i.style.height=i.scrollHeight+"px"),"BUTTON"===r.tagName&&"string"==typeof r.className&&r.className.indexOf("e-qb-toggle")<0){var s,a,u=new N.Animation({duration:1e3,delay:0});switch(!0){case-1<r.className.indexOf("e-removerule"):this.actionButton=r,this.deleteRule(r);break;case-1<r.className.indexOf("e-clone-rule-btn"):this.actionButton=r,this.cloneRuleBtnClick=!0,this.ruleClone(r);break;case-1<r.className.indexOf("e-lock-rule-btn"):this.actionButton=r,this.ruleLock(r);break;case-1<r.className.indexOf("e-lock-grp-btn"):this.actionButton=r,this.groupLock(r);break;case-1<r.className.indexOf("e-clone-grp-btn"):this.actionButton=r,this.cloneGrpBtnClick=!0,this.groupClone(N.closest(r,".e-group-container"));break;case-1<r.className.indexOf("e-deletegroup"):this.actionButton=r,this.deleteGroup(N.closest(r,".e-group-container"));break;case-1<r.className.indexOf("e-edit-rule"):u.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),s=N.extend({},this.rule,{},!0),this.setGroupRules(s),this.renderSummaryCollapse()):((a=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),a.style.display="block")}}else("LABEL"===r.tagName&&-1<r.parentElement.className.indexOf("e-btn-group")||"string"==typeof r.className&&-1<r.className.indexOf("e-qb-toggle"))&&(e=N.closest(r,".e-group-container"),this.headerTemplate||(i=void 0,(t=r.getAttribute("for"))?i=document.getElementById(t).getAttribute("value"):this.enableSeparateConnector&&(i=r.textContent),t=e.id.replace(this.element.id+"_",""),l=this.getGroup(t),n=void 0,this.enableNotCondition&&(-1<r.className.indexOf("e-qb-toggle")?(n=-1<(e=e.getElementsByClassName("e-qb-toggle")[0]).className.indexOf("e-active-toggle")?(N.removeClass([e],"e-active-toggle"),!1):(N.addClass([e],"e-active-toggle"),!0),i=l.condition):n=l.not),l={groupID:t,cancel:!1,type:"condition",value:i.toLowerCase()},this.enableNotCondition&&(l={groupID:t,cancel:!1,type:"condition",value:i.toLowerCase(),not:n})),this.isImportRules?this.beforeSuccessCallBack(l,r):this.trigger("beforeChange",l,function(e){o.beforeSuccessCallBack(e,r)}),this.target=r)},q.prototype.beforeSuccessCallBack=function(e,t){var l,n,i,o,r;e&&!e.cancel&&(l=(o=N.closest(t,".e-group-container")).id.replace(this.element.id+"_",""),n=this.getValidRules(this.rule),i=this.getParentGroup(o),this.enableSeparateConnector?(r=(o=N.isNullOrUndefined(N.closest(t,".e-rule-container"))&&o.classList.contains("e-group-container")?null!==t.parentElement.previousElementSibling?t.parentElement.previousElementSibling:o:N.closest(t,".e-rule-container")).id.replace(this.element.id+"_",""),o.classList.contains("e-rule-container")?(i=this.getRule(o)).condition=e.value:o.classList.contains("e-group-container")&&((i=this.getGroup(o)).condition=e.value),this.enableNotCondition&&(i.not=e.not),this.isImportRules||this.trigger("change",{groupID:l,ruleID:r,type:"condition",value:i.condition})):(i.condition=e.value,this.enableNotCondition&&(i.not=e.not),this.isImportRules||this.trigger("change",{groupID:l,type:"condition",value:i.condition})),this.filterRules(n,this.getValidRules(this.rule),"condition"),this.enableSeparateConnector)&&(o=t.parentElement.querySelector(".e-btngroup-and"),r=t.parentElement.querySelector(".e-btngroup-or"),o)&&r&&("and"===e.value?(o.checked=!0,r.checked=!1):"or"===e.value&&(r.checked=!0,o.checked=!1))},q.prototype.selectBtn=function(e,t){"beforeOpen"===t.name?this.showButtons.groupInsert||N.isNullOrUndefined(this.showButtons.groupInsert)?(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount+1?N.addClass([t.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):N.removeClass([t.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"),this.enableRtl&&N.addClass([t.element.querySelector("li").parentElement],"e-rtl")):N.addClass([t.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):-1<t.element.children[0].className.indexOf("e-addrule")?this.addRuleElement(N.closest(e,".e-group-container"),{}):-1<t.element.children[0].className.indexOf("e-addgroup")&&this.addGroupElement(!0,N.closest(e,".e-group-container"),"",!0)},q.prototype.appendRuleElem=function(e,t,l,n,i,o){var r,s,a=e.querySelector(".e-rule-list");if("change"===l)r=N.select("#"+n,e);else{if((r=this.createElement("div",{attrs:{class:"e-rule-container"}})).setAttribute("id",e.id+"_rule"+this.ruleIdCounter),this.showButtons.cloneRule&&this.cloneRuleBtnClick){if(this.ruleIndex<0)a.appendChild(r);else if(this.enableSeparateConnector){for(var u=-1,d=this.ruleIndex+1,p=0;p<d&&p!==a.children.length;p++)a.children[p].classList.contains("e-rule-container")&&(d++,u++);a.insertBefore(r,a.children[this.ruleIndex+u+1])}else a.insertBefore(r,a.children[this.ruleIndex+1]);this.cloneRuleBtnClick=!1}else a.appendChild(r);this.ruleIdCounter++}return t&&t.ruleTemplate&&o?(l={requestType:"template-initialize",ruleID:r.id,action:i,fields:this.fields,rule:o},this.trigger("actionBegin",l),this.ruleTemplateFn=this.templateParser(t.ruleTemplate),n=this.element.id+t.field,l.fields=this.fields,l.columns=this.columns,""===o.field&&(o.field=t.field),l.operators=this.getOperators(o.field),l.operatorFields={text:"key",value:"value"},this.isReact?((s=this.ruleTemplateFn(l,this,r.id,n)[0]).className+=" e-rule-field",r.appendChild(s)):this.isAngular?((s=3===(e=this.ruleTemplateFn(l,this,r.id,n))[0].nodeType?e[1]:e[0]).className+=" e-rule-field",r.appendChild(s)):this.isVue3?(s=this.ruleTemplateFn(l,this,"Template",n),N.append(s,r),r.children.length&&(r.children[r.children.length-1].className+=" e-rule-field")):((s=this.ruleTemplateFn(l,this,"Template",n)[0]).className+=" e-rule-field",r.appendChild(s))):(s=this.ruleElem.querySelector(".e-rule-field").cloneNode(!0),r.appendChild(s)),this.showButtons.lockGroup&&N.removeClass(r.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.showButtons.lockRule&&N.removeClass(r.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"),this.showButtons.cloneGroup&&N.removeClass(r.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"),this.showButtons.cloneRule&&N.removeClass(r.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"),this.showButtons.ruleDelete&&N.removeClass(r.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.allowDragAndDrop&&N.removeClass(r.querySelectorAll(".e-drag-qb-rule"),"e-hidden"),t&&t.ruleTemplate&&o&&this.renderReactTemplates(),r},q.prototype.addRuleElement=function(t,l,n,i,o,r){var e,s=this;t&&(e={groupID:t.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"},this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addRuleSuccessCallBack(e,t,l,n,i,o,r)):this.trigger("beforeChange",e,function(e){s.addRuleSuccessCallBack(e,t,l,n,i,o,r)}))},q.prototype.addRuleSuccessCallBack=function(e,t,l,n,i,o,r){var s,a,u,d,p=-1<this.element.className.indexOf("e-device")?"250px":"200px",n=l&&l.field?this.getColumn(l.field):n||this.columns[0],c={label:"",field:"",type:"",operator:""};if(e.cancel||(n&&n.ruleTemplate&&l.field?(this.selectedColumn=n,e=this.selectedColumn.operators,c={label:n.label,field:n.field,type:n.type,operator:e[0].value},e=Object.keys(l).length?l:c,e={requestType:"template-create",action:"insert-rule",ruleID:(s=this.appendRuleElem(t,n,i,o,"field",e)).id,fields:this.fields,rule:e},this.trigger("actionBegin",e)):((s=this.appendRuleElem(t,n,i,o,"field")).querySelector(".e-filter-input").setAttribute("id",s.id+"_filterkey"),e=s.querySelector(".e-rule-delete"),-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?(e.textContent=this.l10n.getConstant("Remove"),N.addClass([e],"e-flat"),N.addClass([e],"e-primary")):(N.addClass([e],"e-round"),N.addClass([e],"e-icon-btn"),e.setAttribute("title",this.l10n.getConstant("DeleteRule")),i=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),s.querySelector(".e-rule-delete").appendChild(i)),this.showButtons.ruleDelete||e.classList.add("e-button-hide")),"Vertical"===this.displayMode||-1<this.element.className.indexOf("e-device")?s.className="e-rule-container e-vertical-mode":s.className="e-rule-container e-horizontal-mode",i=s.previousElementSibling,this.enableSeparateConnector?(f=g=void 0,(i=i&&i.classList.contains("e-group-container")?(f=i.querySelectorAll(".e-rule-container"))[f.length-1]:i)&&i.classList.contains("e-rule-container")&&(g=this.getRule(i)),this.headerTemplate&&i&&g?this.headerTemplateFn(i,!1,g.condition,g,i.id):N.isNullOrUndefined(i)&&s.id!==this.element.id+"_group0_rule0"&&((h=s.closest(".e-group-container"))&&h.previousElementSibling?(e=(m=h.previousElementSibling).querySelectorAll(".e-rule-container"),(m=m.classList.contains("e-group-container")?e[e.length-1]:m).classList.contains("e-rule-container")&&(e=this.getRule(m),this.headerTemplateFn(m,!1,e.condition,e,m.id,!0))):this.headerTemplateFn(s,!1,l.condition,l,s.id,!0))):i&&-1<i.className.indexOf("e-rule-container")&&(s.className.indexOf("e-joined-rule")<0&&(s.className+=" e-joined-rule"),i.className.indexOf("e-prev-joined-rule")<0)&&(i.className+=" e-prev-joined-rule"),i&&-1<i.className.indexOf("e-group-container")&&s.className.indexOf("e-separate-rule")<0&&(s.className+=" e-separate-rule"),this.isImportRules||this.updateAddedRule(t,l,c,r,o,!!this.enableSeparateConnector||null),n&&n.ruleTemplate&&l.field||("Default"===this.fieldMode?(u=a=void 0,u=this.separator&&l.field||this.autoSelectField||this.isImportRules?this.GetRootColumnName(l.field):l.field,a={dataSource:this.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:5<this.columns.length?p:"auto",close:this.fieldClose.bind(this,s.id+"_filterkey"),change:this.changeField.bind(this),value:l?u:null,open:this.popupOpen.bind(this,!0),cssClass:"qb-dropdownlist"},this.fieldModel&&(a=b({},a,this.fieldModel)),d=void(e=new y.DropDownList(a)).appendTo("#"+s.id+"_filterkey"),d=this.separator&&l.field||this.isImportRules?this.GetRootColumnName(l.field):e.value,this.selectedColumn=e.getDataByValue(d),Object.keys(l).length&&this.changeRule(l,{element:e.element,itemData:this.selectedColumn})):(this.isImportRules,u=l.field,this.dummyDropdownTreeDs=N.extend([],this.columns,[],!(a=void 0)),this.updateDropdowntreeDS(this.dummyDropdownTreeDs),a={fields:{dataSource:this.dummyDropdownTreeDs,value:"field",text:"label",child:"columns",expanded:"expanded",selectable:"selectable"},placeholder:this.l10n.getConstant("SelectField"),showClearButton:!1,popupHeight:5<this.columns.length?p:"auto",changeOnBlur:!1,change:this.changeField.bind(this),value:N.isNullOrUndefined(u)?null:[u],open:this.popupOpen.bind(this,!1),treeSettings:{expandOn:"Click"},cssClass:"e-qb-ddt",filtering:this.dropdownTreeFiltering.bind(this),close:this.dropdownTreeClose.bind(this)},this.fieldModel&&(a=b({},a,this.fieldModel)),(i=new y.DropDownTree(a)).appendTo("#"+s.id+"_filterkey"),N.isNullOrUndefined(i.value)||(c=this.getLabelFromColumn(i.value[0]),i.element.value=c),d=N.isNullOrUndefined(l.field)?i.value:this.GetRootColumnName(l.field),this.selectedColumn=this.getColumn(d),Object.keys(l).length&&this.changeRule(l,{element:i.element,itemData:this.selectedColumn}))),u=s.id.replace(this.element.id+"_",""),l&&l.isLocked&&(r=s.querySelector(".e-lock-rule-btn"),this.ruleLock(r)),this.isImportRules)||this.prvtEvtTgrDaD||this.trigger("change",{groupID:t.id.replace(this.element.id+"_",""),ruleID:u,type:"insertRule"}),this.enableSeparateConnector&&N.isNullOrUndefined(l.condition)&&u&&(l=this.getRule(u)),this.enableSeparateConnector){for(var h,g,m=s.previousElementSibling,f=void 0;m&&!m.classList.contains("e-rule-container");){if(m.classList.contains("e-group-container")){m=(f=m.querySelectorAll(".e-rule-container"))[f.length-1];break}m=m.previousElementSibling}this.headerTemplate&&m?(g=this.getRule(m),o={requestType:"rule-template-create",ruleID:m.id,condition:g.condition,notCondition:!!this.enableNotCondition||void 0},this.trigger("actionBegin",o)):N.isNullOrUndefined(m)&&s.id!==this.element.id+"_group0_rule0"&&(h=s.closest(".e-group-container"))&&h.previousElementSibling&&h.previousElementSibling.previousElementSibling&&(n=(n=h.previousElementSibling.previousElementSibling).classList.contains("e-group-container")?(e=n.querySelectorAll(".e-rule-container"))[e.length-1]:n).classList.contains("e-rule-container")&&(g=this.getRule(n),p={requestType:"rule-template-create",ruleID:n.id,condition:g.condition,notCondition:!!this.enableNotCondition||void 0},this.trigger("actionBegin",p)),this.setMultiConnector(s)}},q.prototype.dropdownTreeFiltering=function(t){var l=this,e=this,n=t.event.srcElement,n=(n.classList.contains("e-clear-icon")?n.parentElement.querySelector(".e-textbox"):n).id.split("_filterkey")[0],n=document.getElementById(n),n=(this.ddTree=N.getComponent(n.querySelector("input.e-dropdowntree"),"dropdowntree"),N.extend([],this.columns,[],!0));t.cancel=!0,""===t.text?this.changeDataSource(n):(n=n.map(function(e){return l.nestedChildFilter(t.text,e)}).filter(function(e){return null!==e}),this.changeDataSource(n),setTimeout(function(){N.isNullOrUndefined(e.ddTree)||N.isNullOrUndefined(e.ddTree.treeObj)||e.ddTree.treeObj.expandAll()},100))},q.prototype.changeDataSource=function(e){this.updateDropdowntreeDS(e),this.ddTree.treeObj.fields={dataSource:e,value:"field",text:"label",child:"columns",expanded:"expanded"},this.ddTree.treeObj.refresh()},q.prototype.nestedChildFilter=function(t,e){var l,n=this,i=e[this.ddTree.fields.child];return i?(l=i.map(function(e){return n.nestedChildFilter(t,e)}).filter(function(e){return null!==e})).length?(e[this.ddTree.fields.child]=l,e):(e[this.ddTree.fields.child]=i,this.isMatchedNode(t,e)?e:null):this.isMatchedNode(t,e)?e:null},q.prototype.isMatchedNode=function(e,t){t=t[this.ddTree.fields.text].toLowerCase();return e=e?e.toLowerCase():"",-1!==t.indexOf(e)},q.prototype.dropdownTreeClose=function(){this.ddTree&&this.changeDataSource(N.extend([],this.columns,[],!0)),this.ddTree=null},q.prototype.updateDropdowntreeDS=function(e){for(var t=0;t<e.length;t++)"object"===e[parseInt(t.toString(),10)].type?(this.isAngular&&e[parseInt(t.toString(),10)].template&&delete e[parseInt(t.toString(),10)].template,e[parseInt(t.toString(),10)].selectable=!1,this.updateDropdowntreeDS(e[parseInt(t.toString(),10)].columns)):this.isAngular&&e[parseInt(t.toString(),10)].template&&delete e[parseInt(t.toString(),10)].template},q.prototype.updateAddedRule=function(e,t,l,n,i,o){var r=0;if(n){for(s=N.select("#"+i,e),u=N.closest(e,".e-group-container"),d=this.getParentGroup(u);s&&null!==s.previousElementSibling;){var s=s.previousElementSibling,a=this.enableSeparateConnector&&(!this.headerTemplate&&!s.classList.contains("e-btn-group")||this.headerTemplate&&(s.classList.contains("e-rule-container")||s.classList.contains("e-group-container")));this.enableSeparateConnector&&!a||r++}d.rules[r]=t}else{var u=N.closest(e,".e-group-container"),d=this.getParentGroup(u),n=t.custom;Object.keys(t).length?this.ruleIndex<0?(d.rules.push({field:t.field,type:t.type,label:t.label,operator:t.operator,value:t.value}),n&&(d.rules[d.rules.length-1].custom=n),this.enableSeparateConnector&&(d.rules[d.rules.length-1].condition=t.condition||l.condition)):(d.rules.splice(this.ruleIndex+1,0,{field:t.field,type:t.type,label:t.label,operator:t.operator,value:t.value}),n&&(d.rules[this.ruleIndex+1].custom=n),this.enableSeparateConnector&&(d.rules[this.ruleIndex+1].condition=t.condition||l.condition)):(n&&(l.custom=n),this.autoSelectField&&(t.field=l.field=this.rule.rules[0].field),d.rules.push(l))}this.disableRuleCondition(e,d,o)},q.prototype.changeRuleTemplate=function(e,t){var l,n,i=this.selectedColumn.operators;e.ruleTemplate||(l=N.closest(t,".e-group-container"),n=N.closest(t,".e-rule-container").id,this.previousColumn&&this.previousColumn.ruleTemplate&&(N.detach(t.closest('[id="'+n+'"]').querySelector(".e-rule-field")),this.clearQBTemplate([n])),e&&(t={field:e.field,label:e.label,operator:i[0].value,value:""},this.addRuleElement(l,t,e,"change",n,!0)))},q.prototype.renderToolTip=function(e){var t=new s.Tooltip({content:this.l10n.getConstant("ValidationMessage"),isSticky:!0,position:"BottomCenter",cssClass:"e-querybuilder-error",afterClose:function(){t.destroy()},beforeOpen:function(e){e=e.element.querySelector(".e-tooltip-close");e&&(e.style.display="none")}});t.appendTo(e),t.open(e)},q.prototype.validateFields=function(){var e,t=!0;if(this.allowValidation)for(var l=["isnull","isnotnull","isempty","isnotempty"],n=void 0,i=void 0,o=void 0,r=[],s=void 0,a=void 0,u=void 0,d=void 0,p=this.element.querySelectorAll(".e-rule-container"),n=0,c=p.length;n<c;n++){var h=void 0,g=N.closest(p[n],".e-group-container"),d=this.getParentGroup(g),s=0;if(o=u=p[n],"DropdownTree"===this.fieldMode?(e=N.getComponent(p[n].querySelector(".e-rule-filter input.e-dropdowntree"),"dropdowntree"))&&e.value&&e.value.length&&(this.selectedColumn=this.getColumn(e.value[0]),h=this.selectedColumn.validation):(a=N.getComponent(p[n].querySelector(".e-rule-filter input.e-dropdownlist"),"dropdownlist"))&&a.value&&(this.selectedColumn=a.getDataByValue(a.value),h=!N.isNullOrUndefined(a.value)&&this.selectedColumn.validation),i=u.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;o&&null!==o.previousElementSibling;){var o=o.previousElementSibling,m=this.enableSeparateConnector&&(!this.headerTemplate&&!o.classList.contains("e-btn-group")||this.headerTemplate&&(o.classList.contains("e-rule-container")||o.classList.contains("e-group-container")));this.enableSeparateConnector&&!m||s++}if(i=u.querySelector(".e-rule-operator .e-control"),d.rules[s].operator||(i.parentElement.className.indexOf("e-tooltip")<0&&i.className.indexOf("e-tooltip")<0&&this.renderToolTip(i.parentElement),t=!1),d.rules[s].value instanceof Array&&(r=d.rules[s].value),l.indexOf(d.rules[s].operator)<-1&&N.isNullOrUndefined(d.rules[s].value)&&"date"!==d.rules[s].type||""===d.rules[s].value||null===d.rules[s].value||d.rules[s].value instanceof Array&&r.length<1){var f=u.querySelectorAll(".e-rule-value .e-control");l.indexOf(d.rules[s].operator)<0&&(t=!1);for(var y=0,v=f.length;y<v;y++){var b=f[y],C=void 0;-1<b.parentElement.className.indexOf("e-searcher")?(C=N.closest(b,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(C):f[y].parentElement.className.indexOf("e-tooltip")<0&&f[y].className.indexOf("e-tooltip")<0&&this.renderToolTip(f[y].parentElement),y++}}else if("date"===d.rules[s].type&&(null===d.rules[s].value||-1<d.rules[s].value.indexOf(null))){f=u.querySelectorAll(".e-rule-value .e-control");l.indexOf(d.rules[s].operator)<0&&(t=!1);for(y=0,v=f.length;y<v;y++)f[y].parentElement.className.indexOf("e-tooltip")<0&&f[y].className.indexOf("e-tooltip")<0&&(N.isNullOrUndefined(d.rules[s].value)||null==d.rules[s].value[y])&&this.renderToolTip(f[y].parentElement)}}else(a&&a.element&&N.isNullOrUndefined(a.value)||e&&e.element&&(N.isNullOrUndefined(e.value)||e.value.length<1))&&(i.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(i.parentElement),t=!1)}return t},q.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");e&&(this.levelColl[e.id]=[0],this.refreshLevel({groupElement:e,level:[0]}))},q.prototype.refreshLevel=function(e){for(var t,l=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,i=l.length,o=0,r=0;r<i;r++)-1<(t=l[r]).className.indexOf("e-group-container")&&(e.level.push(o),this.levelColl[t.id]=e.level.slice(),o++,e.groupElement=t,e=this.refreshLevel(e));var s=N.closest(n,".e-rule-list");return e.groupElement=s?N.closest(s,".e-group-container"):n,e.level=this.levelColl[e.groupElement.id].slice(),e},q.prototype.groupTemplate=function(e){var t,l,n=this.createElement("div",{attrs:{class:"e-group-container"}}),i=this.createElement("div",{attrs:{class:"e-group-header"}}),o=this.createElement("div",{attrs:{class:"e-group-body"}}),r=this.createElement("div",{attrs:{class:"e-rule-list"}});return n.appendChild(i),o.appendChild(r),n.appendChild(o),this.headerTemplate||(r=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden",o=this.createElement("span",{attrs:{class:r,"aria-lable":"drag handle",title:"drag handle"}}),i.appendChild(o),r=this.enableSeparateConnector&&!e?"e-lib e-btn-group e-qb-toggle-btn":"e-lib e-btn-group",o=this.createElement("div",{attrs:{class:r,role:"group"}}),this.enableSeparateConnector&&o.classList.add("e-multi-connector"),this.enableNotCondition&&(t=this.enableSeparateConnector?this.createElement("input",{attrs:{type:"checkbox",class:"e-qb-toggle"}}):this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),o.appendChild(t)),t=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}}),o.appendChild(t),e=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-and-lbl e-small"},innerHTML:this.l10n.getConstant("AND")}),o.appendChild(e),t=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),o.appendChild(t),e=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-or-lbl e-small"},innerHTML:this.l10n.getConstant("OR")}),o.appendChild(e),i.appendChild(o),r=this.createElement("div",{attrs:{class:"e-group-action"}}),l=this.enableSeparateConnector?(l=this.createElement("button",{attrs:{type:"button",class:"e-add-condition-btn"}}),r.appendChild(l),this.createElement("button",{attrs:{type:"button",class:"e-add-group-btn"}})):this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),r.appendChild(l),i.appendChild(r)),n},q.prototype.ruleTemplate=function(){var e=this.createElement("div"),t=this.createElement("div",{attrs:{class:"e-rule-field"}}),l=this.createElement("div",{attrs:{class:"e-rule-filter"}}),n=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden",n=this.createElement("span",{attrs:{class:n,"aria-lable":"drag handle",title:"drag handle"}}),n=(t.appendChild(n),this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}})),n=(l.appendChild(n),t.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-operator"}}),t.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value"}}),t.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),n=this.showButtons.cloneRule?"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn":"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn e-button-hide",o=this.showButtons.lockRule?"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneRule"),type:"button",class:n}})),i=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}}),o=(n.appendChild(i),this.createElement("button",{attrs:{title:this.l10n.getConstant("LockRule"),type:"button",class:o}})),i=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),i=(o.appendChild(i),this.showButtons.ruleDelete||N.isNullOrUndefined(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:{type:"button",class:i}});return l.appendChild(n),l.appendChild(o),l.appendChild(i),t.appendChild(l),e.appendChild(t),e},q.prototype.addGroupElement=function(t,l,n,i,o,r,s){var a=this,e={groupID:l.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addGroupSuccess(e,t,l,n,i,o,r,s)):this.trigger("beforeChange",e,function(e){a.addGroupSuccess(e,t,l,n,i,o,r,s)})},q.prototype.addGroupSuccess=function(e,t,l,n,i,o,r,s){var a=this;if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var u,d,p,e=l,l=void 0,c="",c=e.className.indexOf("e-group-container")<0?e.querySelector(".e-group-container")&&e.querySelector(".e-group-container").id:e.id,h=(this.enableSeparateConnector&&(this.groupElem=this.groupTemplate()),this.groupElem.cloneNode(!0));if(h.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),0===this.groupIdCounter&&this.allowDragAndDrop&&h.querySelector(".e-drag-qb-rule")&&(h&&h.children[0]&&h.children[0].classList.add("e-parent-header"),N.addClass([h.querySelector(".e-drag-qb-rule")],"e-hidden")),this.headerTemplate&&(r?(t=!1,h.setAttribute("id",this.element.id+"_group0"),this.headerTemplateFn(h,o,n,s,c),this.groupIdCounter=0):this.headerTemplateFn(h,o,n,s,c)),this.groupIdCounter++,this.headerTemplate||(r=h.querySelector(".e-btngroup-and"),s=h.querySelector(".e-btngroup-or"),c=h.querySelector(".e-btngroup-and-lbl"),O=h.querySelector(".e-btngroup-or-lbl"),r.setAttribute("id",this.element.id+"_and"+this.btnGroupId),s.setAttribute("id",this.element.id+"_or"+this.btnGroupId),r.setAttribute("name",this.element.id+"_and"+this.btnGroupId),s.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),O.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++),t){for(var r=void 0,r=this.showButtons.groupDelete||N.isNullOrUndefined(this.showButtons.groupDelete)?"e-deletegroup":"e-deletegroup e-button-hide",l=this.createElement("button",{attrs:{type:"button",class:r}}),s=(new L.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(l),l.setAttribute("title",this.l10n.getConstant("DeleteGroup")),N.rippleEffect(l,{selector:".deletegroup"}),e.querySelector(".e-rule-list")),g=s.children,m=0,f=0,y=g.length;f<y;f++)-1<g[f].className.indexOf("e-group-container")&&(m+=1);if(this.showButtons.cloneGroup&&this.cloneGrpBtnClick)if(this.groupIndex===g.length-1)s.appendChild(h),this.isLastGroup=!0;else{if(this.enableSeparateConnector){for(var v=0,b=this.groupIndex+1,C=0;C<b;C++)g[C].classList.contains("e-rule-container")&&(b++,v++);0<v&&v--,g[k=this.groupIndex+v+1].parentNode.insertBefore(h,g[k])}else g[k=this.groupIndex+1].parentNode.insertBefore(h,g[k]);this.isMiddleGroup=!0}else s.appendChild(h);var S,x,q,c=this.levelColl[e.id].slice(0);c.push(m),this.levelColl[h.id]=c,-1<this.groupIndex&&this.refreshLevelColl(),this.isImportRules||(this.isAddSuccess=!0,this.addGroups([],e.id.replace(this.element.id+"_","")),this.isAddSuccess=!1,i&&this.addRuleToNewGroups&&this.addRuleElement(h,{})),this.headerTemplate||(S="",S=this.showButtons.cloneGroup?"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",O=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneGroup"),type:"button",class:S}}),x=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}}),O.appendChild(x),h.querySelector(".e-group-action").appendChild(O),S=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",q=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:S}}),t=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),q.appendChild(t),h.querySelector(".e-group-action").appendChild(q),h.querySelector(".e-group-action").appendChild(l))}else this.headerTemplate||(S="",S=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",q=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:S}}),x=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),q.appendChild(x),h.querySelector(".e-group-action").appendChild(q)),e.appendChild(h),this.levelColl[h.id]=[0];if(this.enableNotCondition&&!this.headerTemplate&&(E=h.querySelector(".e-qb-toggle"),(this.enableSeparateConnector?new L.CheckBox({label:this.l10n.getConstant("NOT"),cssClass:"e-qb-toggle"}):new L.Button({content:this.l10n.getConstant("NOT"),cssClass:"e-btn e-small"})).appendTo(E),h.querySelector(".e-btngroup-and-lbl").classList.add("e-not"),this.updatedRule)&&this.updatedRule.not&&N.addClass([E],"e-active-toggle"),this.enableSeparateConnector&&!this.headerTemplate){for(var E,O,r=h.querySelector(".e-btngroup-and"),k=h.querySelector(".e-btngroup-or"),w=h.querySelector(".e-btn-group"),C=0;C<w.childNodes.length;C++)"not"===h.querySelector(".e-btn-group").childNodes[C].textContent.toLowerCase()&&this.enableNotCondition?w.childNodes[C].classList.add("e-multiconnector"):w.childNodes[C].style.display="none";h.previousElementSibling&&(N.isNullOrUndefined(this.headerTemplate)&&(h.parentElement.insertBefore(this.groupTemplate(!0).querySelector(".e-btn-group"),h),(E=h.previousElementSibling.childNodes[0]).classList.contains("e-qb-toggle"))&&(E.style.display="none"),this.isImportRules||(c=(s=h.previousElementSibling).querySelector(".e-btngroup-and"),i=s.querySelector(".e-btngroup-or"),r.checked||k.checked?this.enableSeparateConnector&&(r.checked&&(c.checked=!0),k.checked)&&(i.checked=!0):(O=h.nextElementSibling)&&O.classList.contains("e-btn-group")&&(r=O.querySelector(".e-btngroup-and"),k=O.querySelector(".e-btngroup-or"),c.checked=r.checked,i.checked=k.checked)))}this.updatedRule=null,this.headerTemplate?(t={requestType:"header-template-create",ruleID:h.id,condition:n,notCondition:this.enableNotCondition?o:void 0},this.trigger("actionBegin",t)):this.enableSeparateConnector?(u=h.querySelector(".e-add-condition-btn"),(p=new L.Button({cssClass:this.element.id+"_addConditionbtn",content:this.l10n.getConstant("AddCondition")})).appendTo(u),p.element.onclick=function(){a.addRuleElement(N.closest(u,".e-group-container"),{})},d=h.querySelector(".e-add-group-btn"),(p=new L.Button({cssClass:this.element.id+"_addGroupbtn",content:this.l10n.getConstant("AddGroup")})).appendTo(d),p.element.onclick=function(){a.addGroupElement(!0,N.closest(d,".e-group-container"),"",!0)}):(l=h.querySelector(".e-add-btn"),(p=new R.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,l),select:this.selectBtn.bind(this,l)})).appendTo(l),l.setAttribute("title",this.l10n.getConstant("AddButton"))),this.isImportRules||this.prvtEvtTgrDaD||(S=e.id.replace(this.element.id+"_",""),x=h.id.replace(this.element.id+"_",""),this.trigger("change",{groupID:S,type:"insertGroup",childGroupID:x}))}},q.prototype.setMultiConnector=function(e){var t;this.enableSeparateConnector&&!this.headerTemplate&&e.previousElementSibling&&this.groupElem.querySelector(".e-btn-group")&&(e.parentElement.insertBefore(this.groupTemplate(!0).querySelector(".e-btn-group"),e),(t=e.previousElementSibling.childNodes[0]).classList.contains("e-qb-toggle")&&(t.style.display="none"),this.addHeaderDiv(e))},q.prototype.addHeaderDiv=function(e){var t,l=e.previousElementSibling.previousElementSibling;l&&(l=-1<l.id.indexOf("rule")?this.getRule(l):this.getGroup(l),N.isNullOrUndefined(l.condition)&&(l.condition="and"),t=e.previousElementSibling.querySelector(".e-btngroup-or"),e=e.previousElementSibling.querySelector(".e-btngroup-and"),t.disabled=!1,e.disabled=!1,"or"===l.condition?t.checked=!0:e.checked=!0)},q.prototype.headerTemplateFn=function(e,t,l,n,i,o){var r=this.element.id+"_header",s=e.querySelector(".e-group-header");if(this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(s=e),this.headerTemplate){if(t={requestType:"header-template-initialize",ruleID:e.id,notCondition:this.enableNotCondition?t:void 0,condition:l,rule:this.getRuleCollection(n,!1),groupID:i},this.trigger("actionBegin",t),this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(t.requestType="rule-template-create"),this.headerFn=this.templateParser(this.headerTemplate),this.isReact)a=this.headerFn(t,this,e.id,r)[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):s.appendChild(a);else if(this.isAngular){var l=this.headerFn(t,this,e.id,r),a=3===l[0].nodeType?l[1]:l[0];this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):s.appendChild(a)}else if(this.isVue3){if(a=this.headerFn(t,this,e.id,r),this.enableSeparateConnector&&(o||-1!==e.id.indexOf("rule")))for(var u=0;u<a.length;u++)if("DIV"===a[u].nodeName){a=a[u];break}this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):N.append(a,s)}else a=this.headerFn(t,this,"Template",r)[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):s.appendChild(a);this.renderReactTemplates()}return e},q.prototype.enableSeparateConnectorInitialRule=function(e,t){var l=(e.nextElementSibling||e).closest(".e-group-container");(l=e.nextElementSibling?l:l&&(l.nextElementSibling||l))&&l.parentElement.insertBefore(t,l)},q.prototype.notifyChange=function(e,t,l){var n=N.closest(t,".e-group-container"),n=this.getParentGroup(n),i=N.closest(t,".e-rule-container"),o=0;if("not"===l)n.not=e;else if("condition"===l)this.enableSeparateConnector?(n=(i=(i=t.parentElement.previousElementSibling)&&i.classList.contains("e-group-container")?i.querySelectorAll(".e-rule-container")[i.querySelectorAll(".e-rule-container").length-1]:i)&&i.classList.contains("e-rule-container")?this.getRule(i):n).condition=e:n.condition=e;else{for(;i&&null!==i.previousElementSibling;)i=i.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!i.classList.contains("e-btn-group")||this.headerTemplate&&(i.classList.contains("e-rule-container")||i.classList.contains("e-group-container"))))&&o++;var n=n.rules[o],n=this.getColumn(n.field),r=this.getFormat(n.format);if("date"===n.type)if(e instanceof Date)e=this.intl.formatDate(e,r);else if(e instanceof Array)for(var s=0;s<e.length;s++)e[s]&&e[s]instanceof Date&&(e[s]=this.intl.formatDate(e[s],r));n.ruleTemplate?this.templateChange(t,e,l):(this.isNotified=!0,this.updateRules(t,e),this.isNotified=!1)}},q.prototype.templateChange=function(e,t,l){var n=N.closest(e,".e-group-container"),i=this.getParentGroup(n),o=N.closest(e,".e-rule-container"),r=0;for(this.allowValidation&&this.validateValue(i,o);o&&null!==o.previousElementSibling;)o=o.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!o.classList.contains("e-btn-group")||this.headerTemplate&&(o.classList.contains("e-rule-container")||o.classList.contains("e-group-container"))))&&r++;var s,a,u=i.rules[r],i=("field"===l?this.selectedColumn=this.getColumn(t):u&&(this.selectedColumn=this.getColumn(u.field)),this.previousColumn=this.getColumn(u.field),this.getValidRules(this.rule)),d=(this.selectedColumn&&(s=this.selectedColumn.operators||this.customOperators[this.selectedColumn.type+"Operator"]),["in","notin","between","notbetween"]);switch(l){case"field":u.field=t,u.label=this.selectedColumn.label,u.type=this.selectedColumn.type,u.value="",u.operator=s[0].value;break;case"operator":a=u.operator,u.operator=t,-1<d.indexOf(u.operator)?u.value=[]:-1<d.indexOf(a)&&(u.value="");break;case"value":u.value=t}this.changeRuleTemplate(this.selectedColumn,e),this.filterRules(i,this.getValidRules(this.rule),l),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"!==l&&"operator"!==l||(i=N.closest(e,".e-rule-container"),this.destroyControls(i,!0),N.detach(i.querySelector(".e-rule-field")),e=this.appendRuleElem(N.closest(i,".e-group-container"),this.selectedColumn,"change",i.id,l,u),"Vertical"===this.displayMode||-1<this.element.className.indexOf("e-device")?e.className="e-rule-container e-vertical-mode":e.className="e-rule-container e-horizontal-mode",this.enableSeparateConnector||e.previousElementSibling&&-1<e.previousElementSibling.className.indexOf("e-rule-container")&&(e.className.indexOf("e-joined-rule")<0&&(e.className+=" e-joined-rule"),e.previousElementSibling.className.indexOf("e-prev-joined-rule")<0)&&(e.previousElementSibling.className+=" e-prev-joined-rule"),e.previousElementSibling&&-1<e.previousElementSibling.className.indexOf("e-group-container")&&e.className.indexOf("e-separate-rule")<0&&(e.className+=" e-separate-rule"),e={requestType:"template-create",action:l,ruleID:i.id,fields:this.fields,rule:u},l={groupID:n.id.replace(this.element.id+"_",""),ruleID:i.id.replace(this.element.id+"_",""),value:u.field,type:"field"},this.trigger("actionBegin",e),this.trigger("change",l)))},q.prototype.changeValue=function(e,t){var l,n,i,o,r,s,a,u=this;this.isNumInput&&"number"==typeof t.value||"input"===t.type&&t.target&&t.target.classList.contains("e-numerictextbox")&&(this.selectedColumn.validation.max!==Number.MAX_VALUE||0<this.selectedColumn.validation.min)?this.isNumInput=!1:(l=t.element&&t.element.classList.contains("e-multiselect")?t.element:t.event?t.event.target:"input"===t.type&&t.target&&t.target.classList.contains("e-numerictextbox")?t.currentTarget:t.element)&&((-1<l.className.indexOf("e-day")||-1<l.className.indexOf("e-today")||-1<l.className.indexOf("e-cell"))&&(l=t.element),r=N.closest(l,".e-group-container"),a=N.closest(l,".e-rule-container"),n=r&&r.id.replace(this.element.id+"_",""),i=a.id.replace(this.element.id+"_",""),(r=t).element&&-1<r.element.className.indexOf("e-datepicker")&&(l=r.element,(s=N.getComponent(N.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"))&&(this.selectedColumn=s.getDataByValue(s.value)),s=N.getComponent(N.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"))&&(this.selectedColumn=this.getColumn(s.value[0])),-1<l.className.indexOf("e-radio")?(a=parseInt(l.id.split("valuekey")[1],10),"Default"===this.fieldMode?(s=N.getComponent(N.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=s.getDataByValue(s.value),this.selectedColumn.columns&&(s=N.getComponent(N.closest(l,".e-rule-container").querySelector(".e-rule-sub-filter .e-dropdownlist"),"dropdownlist"),this.selectedColumn=this.getColumn(s.value))):(s=N.getComponent(N.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"),this.selectedColumn=this.getColumn(s.value[0])),o=(this.selectedColumn.values||[!0,!1])[a]):-1<l.className.indexOf("e-multiselect")?o=N.getComponent(l,"multiselect").value:(o=t.value,"input"===t.type&&t.target&&t.target.classList.contains("e-numerictextbox")&&(o=Number(t.currentTarget.value),r=t.currentTarget,s=N.getInstance(r,c.NumericTextBox),a=N.getValue("decimal",N.getNumericObject(this.locale)),isNaN(o)&&-1!==r.value.indexOf(a)&&(o=this.intl.getNumberParser({format:"n"})(r.value)),isNaN(o)||(s.value=o),this.isNumInput=!0)),"input"===t.name&&this.immediateModeDelay?(window.clearInterval(this.timer),this.timer=window.setInterval(function(){u.filterValue(n,i,o,e,l)},this.immediateModeDelay)):this.filterValue(n,i,o,e,l))},q.prototype.filterValue=function(t,l,e,n,i){var o=this,e={groupID:t,ruleID:l,value:e,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(e,i,n,t,l):this.trigger("beforeChange",e,function(e){o.changeValueSuccessCallBack(e,i,n,t,l)})},q.prototype.changeValueSuccessCallBack=function(e,t,l,n,i){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules)||this.trigger("change",{groupID:n,ruleID:i,value:e.value,cancel:!1,type:"value"})},q.prototype.fieldClose=function(e){var t,l;this.isFieldChange||this.isDestroy||(this.isFieldClose=!0,l=(e=N.getComponent(e,"dropdownlist")).popupObj&&e.popupObj.element.querySelector(".e-active"),t=e.getItemData(),e.value=t.value,l={element:e.element,value:t.value,isInteracted:!0,previousItemData:this.prevItemData,previousItem:null,item:l,itemData:t,event:null,e:null},e.previousValue!==e.value&&this.changeField(l),this.isFieldChange=!1)},q.prototype.changeField=function(e){if(e.isInteracted&&!N.isNullOrUndefined(e.value)){this.isFieldChange=!0,this.prevItemData=e.itemData;var t=N.closest(e.element,".e-rule-filter")||N.closest(e.element,".e-rule-sub-filter"),l="DropdownTree"===this.fieldMode?this.getColumn(e.value[0]):this.getColumn(e.value);if("DropdownTree"===this.fieldMode&&null!==t){var n,i=t.querySelector(".e-dropdowntree.e-control"),o=N.getComponent(i,"dropdowntree");if(!l)return;if("object"===l.type)return o.value=e.oldValue,o.dataBind(),void(N.isNullOrUndefined(e.oldValue)?i.value="":(n=this.getLabelFromColumn(e.oldValue[0]),i.value=n));N.isNullOrUndefined(e.value[0])||(o.value=e.value[0],o.dataBind(),n=this.getLabelFromColumn(e.value[0]),i.value=n)}if(this.destroySubFields(t),this.subFieldElem=null,this.isNotValueChange=!0,l&&l.ruleTemplate)this.templateChange(e.element,l.field,"field");else if(l&&l.columns&&l.columns[0].ruleTemplate)this.templateChange(e.element,l.columns[0].field,"field");else{for(var o=N.closest(e.element,".e-group-container"),i=this.getParentGroup(o),r=N.closest(e.element,".e-rule-container"),s=0;r&&null!==r.previousElementSibling;)r=r.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!r.classList.contains("e-btn-group")||this.headerTemplate&&(r.classList.contains("e-rule-container")||r.classList.contains("e-group-container"))))&&s++;i.rules[s].value="",this.changeRule(i.rules[s],e)}}},q.prototype.changeRule=function(e,t){if(!t.itemData){if("DropdownTree"!==this.fieldMode)return;if(null==N.getComponent(t.element,"dropdowntree").value)return}var l=N.closest(t.element,".e-rule-filter")||N.closest(t.element,".e-rule-sub-filter"),n=N.getComponent(t.element,"dropdownlist");"DropdownTree"===this.fieldMode&&null!==l&&(n=N.getComponent(t.element,"dropdowntree"));var i=N.closest(t.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(l,n,i,e,{},t)},q.prototype.changeFilter=function(t,e,l,n,i,o){var r,s=this;t?(r=void 0,r="DropdownTree"===this.fieldMode?e.value[0]:this.isImportRules?this.GetRootColumnName(e.value):e.value,this.selectedColumn=this.getColumn(r),r={groupID:l,ruleID:N.closest(t,".e-rule-container").id.replace(this.element.id+"_",""),selectedField:"DropdownTree"===this.fieldMode?e.value[0]:e.value,cancel:!1,type:"field"},this.isImportRules||this.prvtEvtTgrDaD?this.fieldChangeSuccess(r,i,t,n,o):this.trigger("beforeChange",r,function(e){s.fieldChangeSuccess(e,i,t,n,o)})):(r=N.closest(o.element,".e-rule-operator"),this.changeOperator(t,r,e,l,n,i,o))},q.prototype.changeOperator=function(t,e,l,n,i,o,r){var s=this;e?(n={groupID:n,ruleID:N.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:l.index,cancel:!1,type:"operator"},this.isImportRules?this.operatorChangeSuccess(n,t,o,i,r):this.trigger("beforeChange",n,function(e){s.operatorChangeSuccess(e,t,o,i,r)})):this.changeRuleValues(t,i,o,r)},q.prototype.fieldChangeSuccess=function(e,t,l,n,i){for(var o=N.closest(l,".e-rule-container"),r=N.closest(i.element,".e-rule-operator"),s=N.closest(i.element,".e-group-container").id.replace(this.element.id+"_",""),a=N.getComponent(i.element,"dropdownlist"),u=o.querySelectorAll(".e-tooltip.e-input-group"),d=0;d<u.length;d++)N.getComponent(u[d],"tooltip").destroy();if(e.cancel)this.changeOperator(l,r,a,s,n,t,i);else if(!N.isNullOrUndefined(this.selectedColumn))if(t.type=this.selectedColumn.type,o.querySelector(".e-template")&&(n.value=""),"object"===this.selectedColumn.type&&"Default"===this.fieldMode)for(t.type=this.selectedColumn.columns[0].type;this.selectedColumn.columns;)this.createSubFields(l,n,t,i);else this.destroySubFields(l),this.changeOperator(l,r,a,s,n,t,i)},q.prototype.destroySubFields=function(e){for(;e&&e.nextElementSibling.classList.contains("e-rule-sub-filter");)this.destroyControls(e),e.nextElementSibling.remove()},q.prototype.createSubFields=function(e,t,l,n){var i=!1,e=N.closest(e,".e-rule-field"),o=this.createElement("div",{attrs:{class:"e-rule-sub-filter",id:"subfilter"+this.subFilterCounter}}),e=(e.insertBefore(o,e.querySelector(".e-rule-operator")),N.closest(o,".e-rule-container").id),r=this.createElement("input",{attrs:{type:"text",id:e+"_subfilterkey"+this.subFilterCounter}}),s=(o.appendChild(r),-1<this.element.className.indexOf("e-device")?"250px":"200px"),s={dataSource:this.selectedColumn.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:5<this.selectedColumn.columns.length?s:"auto",change:this.changeField.bind(this),index:0,open:this.popupOpen.bind(this,!1)},a=(this.fieldModel&&(s=b({},s,this.fieldModel)),new y.DropDownList(s));if(a.appendTo("#"+e+"_subfilterkey"+this.subFilterCounter),this.isImportRules||this.previousColumn&&this.previousColumn.ruleTemplate&&this.GetRootColumnName(t.field)===this.GetRootColumnName(this.previousColumn.field))for(var u=this.selectedColumn.columns,d=0;d<u.length;d++)if(t.field===u[d].field||-1<t.field.indexOf(u[d].field+this.separator)){a.value=u[d].field,this.selectedColumn=u[d],i=!0;break}this.subFilterCounter++,this.subFieldElem=r,n.itemData=n.itemData,!i&&this.selectedColumn.columns&&(!i&&this.isImportRules&&(a.value=null),this.selectedColumn=this.selectedColumn.columns[0]),this.previousColumn=this.selectedColumn,this.selectedColumn.columns||this.changeRuleValues(o,t,l,n)},q.prototype.operatorChangeSuccess=function(e,t,l,n,i){var o,r,s,a;e.cancel||(o=(e=N.closest(i.element,".e-rule-operator")).nextElementSibling,r=N.getComponent(i.element,"dropdownlist"),a=n.operator?n.operator.toString().toLowerCase():"",l.operator=r.value.toString(),r=l.operator.toLowerCase(),-1<l.operator.toLowerCase().indexOf("between")||-1<l.operator.toLowerCase().indexOf("in")&&l.operator.toLowerCase().indexOf("contains")<0?(t=e.previousElementSibling,l.type=n.type,(l.operator.toLowerCase().indexOf("in")<0||a.indexOf("in")<0)&&(n.value=[])):"object"==typeof n.value&&null!==n.value&&(n.value=0<n.value.length?n.value[0]:"number"===n.type?0:""),i.previousItemData&&(-1<(s=i.previousItemData.value.toString().toLowerCase()).indexOf("between")||(-1<s.indexOf("in")||-1<s.indexOf("null")||-1<s.indexOf("empty"))&&s.indexOf("contains")<0)&&(t=e.previousElementSibling,l.type=n.type),-1<a.indexOf("in")&&a.indexOf("in")<5&&-1<r.indexOf("in")&&r.indexOf("in")<5&&(t=null),(-1<l.operator.indexOf("null")||-1<l.operator.indexOf("empty"))&&((a=(s=e.parentElement.querySelector(".e-rule-value")).querySelector(".e-tooltip.e-input-group"))&&N.getComponent(a,"tooltip").destroy(),N.removeClass([s],"e-show"),N.addClass([s],"e-hide")),o&&this.getColumn(n.field).template&&(t=e.previousElementSibling),0===o.children.length&&(t=e.previousElementSibling),this.changeRuleValues(t,n,l,i))},q.prototype.changeRuleValues=function(e,t,l,n){var i,o,r,s,a,u,d=N.closest(n.element,".e-rule-operator");e&&(d=e.nextElementSibling,e.classList.contains("e-rule-sub-filter")&&(l.type=this.selectedColumn.type,d=d.classList.contains("e-rule-sub-filter")?d.nextElementSibling:d),N.addClass([d],"e-operator"),d.childElementCount?(s=N.getComponent(d.querySelector(".e-dropdownlist"),"dropdownlist"),l.operator=s.value,o=void 0,o="DropdownTree"===this.fieldMode?N.getComponent(e.querySelector(".e-dropdowntree"),"dropdowntree"):N.getComponent(e.querySelector(".e-dropdownlist"),"dropdownlist"),l.type=("DropdownTree"===this.fieldMode?this.getColumn(o.value[0]):this.getColumn(o.value)).type,e=n.itemData,""!==s.value&&this.renderValues(d,e,n.previousItemData,!0,t,l,n.element)):(o=N.closest(d,".e-rule-container").id,s=this.createElement("input",{attrs:{type:"text",id:o+"_operatorkey"}}),d.appendChild(s),this.selectedColumn.operators?i=this.selectedColumn.operators:n.itemData&&(i=this.customOperators[this.selectedColumn.type+"Operator"]),e=-1<this.element.className.indexOf("e-device")?"250px":"200px",t.operator&&i.forEach(function(e){"value"in e&&"string"==typeof e.value&&e.value.toLowerCase()===t.operator.toLowerCase()&&(r=e.value)}),s=r||i[0].value,a=0,this.autoSelectOperator||(s="",a=-1),u=void((this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.prvtEvtTgrDaD)&&(s=t&&t.operator||s)),u={dataSource:i,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:5<i.length?e:"auto",change:this.changeField.bind(this),index:a,value:s,open:this.popupOpen.bind(this,!1)},this.operatorModel&&(u=b({},u,this.operatorModel)),new y.DropDownList(u).appendTo("#"+o+"_operatorkey"),l.operator=t&&""!==t.operator&&!N.isNullOrUndefined(t.operator)?t.operator:i[0].value,this.isImportRules&&(l.type=this.selectedColumn.type,l.operator=t.operator),(!N.isNullOrUndefined(s)&&""!==s||this.autoSelectField&&this.autoSelectOperator)&&this.renderValues(d,this.selectedColumn,n.previousItemData,!1,t,l,n.element))),this.isImportRules||this.updateRules(n.element,n.item)},q.prototype.popupOpen=function(e,t){this.enableRtl&&N.addClass([t.popup.element],"e-rtl"),e&&(this.isFieldClose=!1)},q.prototype.destroyControls=function(e,t){for(var l=t?e:e.nextElementSibling,n=l.querySelectorAll("input.e-control"),i=l.querySelectorAll("div.e-control:not(.e-handle)"),o=this.columns,r=0,s=n.length;r<s;r++){if(n[r].classList.contains("e-textbox"))N.getComponent(n[r],"textbox").destroy(),N.detach(N.select("input#"+n[r].id,l));else if(n[r].classList.contains("e-dropdownlist"))this.allowValidation&&-1<n[r].parentElement.className.indexOf("e-tooltip")&&N.getComponent(n[r].parentElement,"tooltip").destroy(),N.getComponent(n[r],"dropdownlist").destroy();else if(n[r].classList.contains("e-radio"))N.getComponent(n[r],"radio").destroy();else if(n[r].classList.contains("e-numerictextbox"))N.getComponent(n[r],"numerictextbox").destroy(),N.detach(N.select("input#"+n[r].id,l));else if(n[r].classList.contains("e-datepicker"))N.getComponent(n[r],"datepicker").destroy();else if(n[r].classList.contains("e-multiselect"))N.getComponent(n[r],"multiselect").destroy();else if(-1<n[r].className.indexOf("e-template"))for(var a=n[r].className,u=0,d=o.length;u<d;u++)if(o[u].template&&-1<a.indexOf(o[u].field)){this.templateDestroy(o[u],n[r].id);break}document.getElementById(n[r].id)&&N.detach(n[r])}for(r=0,s=i.length;r<s;r++){if(-1<i[r].className.indexOf("e-template"))for(a=i[r].className,u=0,d=o.length;u<d;u++)if(o[u].template&&-1<a.indexOf(o[u].field)){this.templateDestroy(o[u],i[r].id);break}N.detach(i[r])}for(var p=l.querySelectorAll(".e-template:not(.e-control)"),r=0,s=p.length;r<s;r++)N.detach(p[r])},q.prototype.templateDestroy=function(e,t){var l,n,i;"string"==typeof e.template&&void 0!==e.template.destroy||(n=(l=e.template).destroy,l.destroy&&(i=void 0,document.getElementById(t)&&(i=N.closest(document.getElementById(t),".e-rule-field").querySelectorAll(".e-template")),"string"==typeof n?(n=N.getValue(n,window))({field:e.field,elementId:t,elements:i}):l.destroy({field:e.field,elementId:t,elements:i})))},q.prototype.getValues=function(e){var t,l={},n=[],i=[],o=(0<this.separator.length&&(i=e.split(this.separator)),this.dataColl);if(this.dataColl[1])for(var r=0,s=o.length;r<s;r++){var a={};if(1<i.length)for(var u,d=o[r],p=0,c=i.length;p<c;p++)u=i[p],i.length===p+1?(t=d[""+u],Number(d[""+u])===d[""+u]&&d[""+u]%1!=0&&(t=d[""+u].toString())):d=d[""+u];else t=o[r][""+e],Number(o[r][""+e])===o[r][""+e]&&o[r][""+e]%1!=0&&(t=o[r][""+e].toString());t in l||((l[""+t]=1)<i.length?this.createNestedObject(a,i,t):a[""+e]=t,n.push(a))}return n},q.prototype.createNestedObject=function(e,t,l){for(var n,i=t.length-1,o=0;o<i;++o)(n=t[o])in e||(e[""+n]={}),e=e[""+n];e[t[i]]=l},q.prototype.getDistinctValues=function(l,n){for(var i={},o=[],r=[],s="",a=n.indexOf(this.separator),u=this,e=0,t=l.length;e<t;e++)!function(t){0===a?s=l[t][""+n]:(r=n.split(u.separator)).forEach(function(e){s=(s||l[t])[""+e]});var e={};(s=Number(l[t][""+n])===l[t][""+n]&&l[t][""+n]%1!=0?l[t][""+n].toString():s)in i||(i[""+s]=1,0===a?e[""+n]=s:e[r[r.length-1]]=s,o.push(e))}(e);return o},q.prototype.renderMultiSelect=function(e,t,l,n,i){var o,r=!1,s=!1,i=(this.isGetNestedData=!1,this.dataColl[1]&&-1<Object.keys(this.dataColl[1]).indexOf(e.field)&&(r=!0,o=this.getDistinctValues(this.dataColl,e.field)),r=!e.columns&&r,s={dataSource:(s=!this.dataColl.length&&i.length?!0:s)?i:r?o:this.dataManager,query:new h.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),open:this.popupOpen.bind(this,!1)},this.valueModel&&this.valueModel.multiSelectModel&&(s=b({},s,this.valueModel.multiSelectModel)),new y.MultiSelect(s));i.appendTo("#"+t+"_valuekey"+l),this.updateRules(i.element,n,0)},q.prototype.multiSelectOpen=function(e,t){var l,n;this.dataSource instanceof h.DataManager&&(e=document.getElementById(e),l=N.getComponent(N.closest(e,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=l.getDataByValue(l.value),l=this.selectedColumn.field,n=!1,(n=this.dataColl[1]&&(-1<Object.keys(this.dataColl[1]).indexOf(l)&&(n=!0),0!==l.indexOf(this.separator))&&this.isGetNestedData?!0:n)||(t.cancel=!0,this.bindMultiSelectData(e,l)))},q.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},q.prototype.getMultiSelectData=function(t,l){var n,i=this,o=new h.Deferred,e=this.dataManager.executeQuery((new h.Query).select(l)),r=N.getComponent(t,"multiselect");r.hideSpinner(),this.createSpinner(N.closest(t,".e-multi-select-wrapper").parentElement),s.showSpinner(N.closest(t,".e-multi-select-wrapper").parentElement),e.then(function(e){n=(e.actual&&e.actual.result?e.actual:e).result,i.dataColl=N.extend(i.dataColl,n,[],!0),r.dataSource=i.getDistinctValues(i.dataColl,l),i.isGetNestedData=!0,s.hideSpinner(N.closest(t,".e-multi-select-wrapper").parentElement)}).catch(function(e){o.reject(e)})},q.prototype.createSpinner=function(e){var t=this.createElement("span",{attrs:{class:"e-qb-spinner"}});e.appendChild(t),s.createSpinner({target:t,width:N.Browser.isDevice?"16px":"14px"})},q.prototype.closePopup=function(e,t){var l,t=document.getElementById(t.popup.element.id.replace("_popup",""));t&&(l=N.getComponent(t,"multiselect"))&&(l=l.value,this.updateRules(t,l,e))},q.prototype.processTemplate=function(e,t,l,n){var e=N.closest(e,".e-rule-container"),i=e.querySelectorAll(".e-template"),o=e.querySelector(".e-rule-filter .e-filter-input"),o="DropdownTree"===this.fieldMode?N.getComponent(o,"dropdowntree"):N.getComponent(e.querySelector(".e-rule-filter .e-filter-input"),"dropdownlist"),o="DropdownTree"===this.fieldMode?this.getColumn(o.value[0]):this.getColumn(o.value);"string"==typeof t.template||void 0===t.template.write?(e={rule:l,ruleID:e.id,operator:n.operator,field:o.field,requestType:"value-template-create"},this.trigger("actionBegin",e)):"string"==typeof(e=t.template).write?N.getValue(e.write,window)({elements:1<i.length?i:i[0],values:l.value,operator:n.operator,field:o.field,dataSource:o.values}):"function"!=typeof t.template&&t.template.write({elements:1<i.length?i:i[0],values:l.value,operator:n.operator,field:o.field,dataSource:o.values})},q.prototype.getItemData=function(e){var t=N.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),l=this.element.querySelector("#"+e);return"DropdownTree"===this.fieldMode?t=N.getComponent(document.getElementById(e+"_filterkey"),"dropdowntree"):l&&0<(e=l.querySelectorAll(".e-rule-sub-filter")).length&&(l=e[e.length-1].querySelector(".e-dropdownlist"),t=N.getComponent(l,"dropdownlist")),"DropdownTree"===this.fieldMode?this.getColumn(t.value[0]):this.getColumn(t.value)},q.prototype.setDefaultValue=function(e,t,l){e=this.getItemData(e);if(N.isNullOrUndefined(e.value))return l?t?[0,0]:0:t?[]:"";if(t){if(!(e.value instanceof Array))return[e.value]}else if(e.value instanceof Array)return e.value[0];return e.value},q.prototype.renderStringValue=function(e,t,l,n,i){var o,r=this.getItemData(e),s="string"==typeof r.template,s=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic||s||""!==t.value?t.value:this.setDefaultValue(e,!1,!1);"in"!==l&&"notin"!==l||!this.dataColl.length&&!r.values?("in"!==l&&"notin"!==l||(s=(o=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex?t.value:this.setDefaultValue(e,!0,!1)).join(",")),l=void 0,l={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.textBoxModel&&(l=b({},l,this.valueModel.textBoxModel)),(l=new c.TextBox(l)).appendTo("#"+e+"_valuekey"+n),l.value=s,l.dataBind()):(o=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(r,e,n,o,r.values),"Vertical"===this.displayMode||-1<this.element.className.indexOf("e-device")?i.style.width="100%":(i.style.width=null,i.style.minWidth="200px"))},q.prototype.renderNumberValue=function(e,t,l,n,i,o,r){var s,a,u,d=this.getItemData(e),p="string"==typeof d.template,p=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic||p||"number"==typeof t.value?t.value:this.setDefaultValue(e,!1,!0);"in"!==l&&"notin"!==l||!this.dataColl.length&&!d.values?"in"===l||"notin"===l?(l=(p=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex?t.value:this.setDefaultValue(e,!0,!1)).join(","),s=void 0,s={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.textBoxModel&&(s=b({},s,this.valueModel.textBoxModel)),(s=new c.TextBox(s)).appendTo("#"+e+"_valuekey"+n),s.value=l,s.dataBind()):(l=(o=d).validation&&o.validation.min?o.validation.min:0,s=o.validation&&o.validation.max?o.validation.max:Number.MAX_VALUE,a=o.format||"n",u=void 0,u={value:(p=1<r&&t?t.value[n]||this.setDefaultValue(e,!0,!0):p)instanceof Array?p[n]:p,format:a,min:l,max:s,width:"100%",step:o.step||1,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.numericTextBoxModel&&(u=b({},u,this.valueModel.numericTextBoxModel)),(r=new c.NumericTextBox(u)).appendTo("#"+e+"_valuekey"+n),r.element.setAttribute("aria-label",o.label+" Value"),r.element.oninput=this.changeValue.bind(this,n)):(p=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(d,e,n,p,d.values),-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?i.style.width="100%":(i.style.minWidth="200px",i.style.width=null))},q.prototype.processValueString=function(e,t){var l=[],n=e.split(",");if("string"===t)return n;for(var i=0,o=n.length;i<o;i++)l.push(Number(n[i]));return l},q.prototype.parseDate=function(e,t){var l;return t?(l=this.intl.getDateParser({skeleton:"full",type:"dateTime"}),t=this.getFormat(t),l=l(e),N.isNullOrUndefined(l)&&(l=this.intl.parseDate(e,t))):l=new Date(e),l},q.prototype.renderControls=function(e,t,l,n,i){if(N.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),N.removeClass([e.parentElement.querySelector(".e-rule-value")],"e-hide"),N.addClass([e.parentElement.querySelector(".e-rule-value")],"e-show"),t.template&&(t.template.create||i))this.processTemplate(e,t,l,n);else{var o="boolean"===n.type?this.selectedColumn.values?this.selectedColumn.values.length:2:n.operator&&-1<n.operator.toString().toLowerCase().indexOf("between")?2:1,r=N.closest(e,".e-rule-container").id,s=void 0,a=n.operator.toString();if(-1<e.className.indexOf("e-rule-operator")||-1<e.className.indexOf("e-rule-filter")){s=e.parentElement.querySelector(".e-rule-value"),-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?s.style.width="100%":"in"!==a&&"notin"!==a?N.addClass([s],"e-custom-value"):N.removeClass([s],"e-custom-value");for(var u=0;u<o;u++)switch(n.type){case"string":this.renderStringValue(r,l,a,u,s);break;case"number":this.renderNumberValue(r,l,a,u,s,t,o);break;case"boolean":this.processBoolValues(t,l,r,u);break;case"date":var d=new Date,p=void 0,c=void 0,h=t.format,g=void 0,m=this.l10n.getConstant("SelectValue"),f="string"==typeof t.template;l.value&&!N.isNullOrUndefined(h)&&(p=1<o?l.value[u]:l.value,d=this.parseDate(p,h)||new Date),t.field||t.key||!t.value||(d=t.value instanceof Date?t.value:this.parseDate(t.value,t.format)),!t.format&&l&&""!==l.field&&(h=(c=this.getColumn(l.field)).format),(this.isImportRules||this.isPublic||f)&&l&&(h=(c=this.getColumn(l.field)).format,d=l.value&&(p=1<o?l.value[u]:l.value,this.parseDate(p,c.format))),g=h?(f=this.getFormat(h)).skeleton?{locale:this.getLocale(),value:d,placeholder:m,format:f,change:this.changeValue.bind(this,u)}:{value:d,locale:this.getLocale(),placeholder:m,format:f.format,change:this.changeValue.bind(this,u)}:{locale:this.getLocale(),value:d,placeholder:m,change:this.changeValue.bind(this,u)},this.valueModel&&this.valueModel.datePickerModel&&(g=b({},g,this.valueModel.datePickerModel)),new v.DatePicker(g).appendTo("#"+r+"_valuekey"+u),l.value||(p=document.getElementById(r+"_valuekey"+u),this.updateRules(p,d,null,this.isNotValueChange),this.isNotValueChange=!1)}}}},q.prototype.processBoolValues=function(e,t,l,n){var i,o,r,s,a=!1,t=(N.isNullOrUndefined(t.type)&&e&&(t.type=e.type),e.values?(s=e.values,"boolean"!==t.type||N.isNullOrUndefined(t.value)?e.value?a=s[n].toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=s[n].toLowerCase()===t.value.toString().toLowerCase(),o=i=r=s[n]):(s=[!0,!1],"boolean"!==t.type||N.isNullOrUndefined(t.value)?e.value?a=s[n].toString().toLowerCase()===e.value.toString().toLowerCase():0===n&&(a="boolean"!=typeof t.value||!!t.value):a=s[n].toString().toLowerCase()===t.value.toString().toLowerCase(),"boolean"==typeof t.value&&1===n&&(a=!t.value),i=s[n].toString(),o=s[n],r=this.l10n.getConstant(["True","False"][n])),e={label:r,name:l+"default",checked:a,value:i,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.radioButtonModel&&(e=b({},e,this.valueModel.radioButtonModel)),new L.RadioButton(e));t.appendTo("#"+l+"_valuekey"+n),a&&this.updateRules(t.element,o,0,!0)},q.prototype.getOperatorIndex=function(e,t){for(var l=e.dataSource.length,n=0;n<l;n++)if(t.operator===e.dataSource[n].value)return n;return 0},q.prototype.getPreviousItemData=function(e,t){return this.isFieldClose&&(e=e&&this.getColumn(e.value||e.field)),t&&t.template&&e&&Object.keys(e).length<4&&(e.template=t.template),e},q.prototype.renderValues=function(e,t,l,n,i,o,r){var s=e.previousElementSibling.getElementsByTagName("input")[0],s="DropdownTree"===this.fieldMode?N.getComponent(s,"dropdowntree"):N.getComponent(s,"dropdownlist"),s="DropdownTree"===this.fieldMode?this.getColumn(s.value[0]):this.getColumn(s.value),a=(this.selectedRule=s,N.getComponent(e.querySelector("input"),"dropdownlist")),r=(n&&(t=-1<r.id.indexOf("operator")?t:this.selectedRule).operators&&(a.value=null,a.dataBind(),a.dataSource=t.operators,a.index=this.getOperatorIndex(a,i),a.value=o.operator=a.dataSource[a.index].value,this.autoSelectOperator?a.dataBind():(a.index=-1,o.operator=a.value="")),o.operator.toString()),u=!1;if(-1<r.indexOf("null")||-1<r.indexOf("isempty")||-1<r.indexOf("isnotempty"))(c=e.parentElement.querySelector(".e-rule-value"))&&(N.removeClass([c],"e-show"),N.addClass([c],"e-hide"));else{var d,p=N.closest(e,".e-rule-container").id;if((l=this.getPreviousItemData(l,s))&&void 0===l.template?l.columns&&(l=this.getColumn(i.field)):"DropdownTree"===this.fieldMode&&void 0===l&&(l=this.getColumn(i.field)),l&&l.template&&(this.templateDestroy(l,p+"_valuekey0"),(d=N.select("#"+p+"_valuekey0",e.nextElementSibling))&&!d.classList.contains("e-control")&&N.detach(N.select("#"+p+"_valuekey0",e.nextElementSibling)),"string"!=typeof l.template&&void 0!==l.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([p]),e.nextElementSibling.innerHTML=""),this.isAngular)&&!N.isNullOrUndefined(l.key)&&"DropdownTree"===this.fieldMode&&delete l.template,n&&(this.validateValue(i,N.closest(e,".e-rule-container")),this.destroyControls(e)),this.isImportRules||a&&""!==a.value){if(s&&(t.template=s.template),t.template&&(N.addClass([e.nextElementSibling],"e-template-value"),t.template=s.template,u=this.setColumnTemplate(t,p,s.field,t.value||r,e,i)),u){var c=e.parentElement.querySelector(".e-rule-value");-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?c.style.width="100%":c.style.width="200px"}else{N.removeClass([e.nextElementSibling],"e-template-value");for(var h=1,h="boolean"===o.type?this.selectedColumn.values?this.selectedColumn.values.length:2:r&&-1<r.toLowerCase().indexOf("between")?2:1,g=0;g<h;g++){var m=this.createElement("input",{attrs:{type:"text",id:p+"_valuekey"+g}});e.nextElementSibling.appendChild(m)}}this.renderControls(e,t,i,o,u),this.isAngular&&!N.isNullOrUndefined(t.key)&&t.template&&"DropdownTree"===this.fieldMode&&delete t.template}}},q.prototype.setColumnTemplate=function(t,l,n,e,i,o){var r=this,s=!0;if(t.template){if("string"==typeof t.template||void 0===t.template.create)return this.trigger("actionBegin",{requestType:"value-template-initialize",ruleID:l,field:n,operator:e,rule:o,renderTemplate:!0},function(e){s=r.actionBeginSuccessCallBack(e,t,l,n,i)}),s;var a=void 0,o=t.template;if((a="string"==typeof o.create?N.getValue(o.create,window)({field:n,operator:e}):o.create({field:n,operator:e}))instanceof Element)a.id=l+"_valuekey0",N.addClass([a],"e-template"),i.nextElementSibling.appendChild(a),n.indexOf(" ")<0&&N.addClass([a],"e-"+n);else if(a instanceof Array){N.addClass(a,"e-template");for(var u=0,d=a.length;u<d;u++)a[u].id=l+"_valuekey"+u,i.nextElementSibling.appendChild(a[u])}N.addClass([i.nextElementSibling],"e-template-value")}return!0},q.prototype.actionBeginSuccessCallBack=function(e,t,l,n,i){var o;return!!e.renderTemplate&&(o=void 0,this.columnTemplateFn=this.templateParser((t.template,t.template)),t=this.element.id+n,this.isReact?(o=this.columnTemplateFn(e,this,l,t)[0],i.nextElementSibling.appendChild(o)):this.isAngular?(o=3===(n=this.columnTemplateFn(e,this,l,t))[0].nodeType?n[1]:n[0],i.nextElementSibling.appendChild(o)):this.isVue3?(o=this.columnTemplateFn(e,this,"Template",t),N.append(o,i.nextElementSibling)):(o=this.columnTemplateFn(e,this,"Template",t)[0],i.nextElementSibling.appendChild(o)),N.addClass([i.nextElementSibling],"e-template-value"),this.renderReactTemplates(),!0)},q.prototype.updateValues=function(e,t){var l,n,i=1,o=(-1<e.className.indexOf("e-template")&&(i=3),e.className.split(" e-")[i]),r=parseInt(e.id.slice(-1),2);switch(o){case"checkbox":n=N.getComponent(e,o).value,t.value=""!==n?n:void 0;break;case"textbox":case"dropdownlist":t.value=N.getComponent(e,o).value;break;case"radio":(n=N.getComponent(e,o)).checked&&("boolean"!=typeof t.value&&this.getColumn(t.field).values?t.value=n.value:t.value="true"===n.value),n.refresh();break;case"numerictextbox":-1<t.operator.indexOf("between")?("string"==typeof t.value&&(t.value=[]),t.value[r]=N.getComponent(e,o).value):t.value=N.getComponent(e,o).value;break;case"datepicker":n=this.getColumn(t.field),n=this.getFormat(n.format),l=N.getComponent(e,o).value,-1<t.operator.indexOf("between")?("string"==typeof t.value&&(t.value=[]),t.value[r]=this.intl.formatDate(l,n)):N.isNullOrUndefined(n.format)&&l?t.value=this.intl.formatDate(l):t.value=l&&this.intl.formatDate(l,n);break;case"multiselect":t.value=N.getComponent(e,o).value}},q.prototype.updateRules=function(e,t,l,n){for(var i=N.closest(e,".e-group-container"),o=this.getParentGroup(i),r=N.closest(e,".e-rule-container"),s=0,a=i.id.replace(this.element.id+"_",""),u=this.getValidRules(this.rule);r&&null!==r.previousElementSibling;)r=r.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!r.classList.contains("e-btn-group")||this.headerTemplate&&(r.classList.contains("e-rule-container")||r.classList.contains("e-group-container"))))&&s++;var d=o.rules[s].operator?o.rules[s].operator.toString():"",p=(r=N.closest(e,".e-rule-container")).id.replace(this.element.id+"_","");if(N.closest(e,".e-rule-filter")||N.closest(e,".e-rule-sub-filter")){this.subFieldElem&&(e=this.subFieldElem);var c="DropdownTree"===this.fieldMode?N.getComponent(e,"dropdowntree"):N.getComponent(e,"dropdownlist"),h="DropdownTree"===this.fieldMode?this.getColumn(c.value[0]):this.getColumn(c.value),h=(this.isImportRules||!o.rules[s].field||o.rules[s].field.toLowerCase()===h.field.toLowerCase()||(!(r.querySelectorAll(".e-template")||-1<d.indexOf("null"))||-1<d.indexOf("empty"))&&(o.rules[s].value=""),this.selectedColumn=this.getColumn(this.selectedColumn.field),o.rules[s].field=this.selectedColumn.field,o.rules[s].type=this.selectedColumn.type,o.rules[s].label=this.selectedColumn.label,N.closest(e,".e-rule-filter")),g=(h=h||N.closest(e,".e-rule-sub-filter")).nextElementSibling.querySelector("input.e-control")||h.nextElementSibling.nextElementSibling.querySelector("input.e-control"),d=N.getComponent(g,"dropdownlist").value.toString(),g=(o.rules[s].operator=d,h.nextElementSibling.nextElementSibling),m=g.querySelectorAll("input.e-control");(m=m.length<1?g.querySelectorAll("div.e-control"):m).length<1&&(m=g.querySelectorAll(".e-template"));for(var h={groupID:a,ruleID:p,value:o.rules[s].field,type:"field"},f=0;f<m.length;f++)-1<d.indexOf("null")||-1<d.indexOf("empty")?o.rules[s].value=null:this.updateValues(m[f],o.rules[s]);this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",h),this.allowValidation&&o.rules[s].field&&-1<e.parentElement.className.indexOf("e-tooltip")&&N.getComponent(e.parentElement,"tooltip").destroy(),this.filterRules(u,this.getValidRules(this.rule),"field")}else if(N.closest(e,".e-rule-operator")){c=N.getComponent(e,"dropdownlist"),o.rules[s].operator=c.value.toString();var y=r.querySelectorAll(".e-rule-value input.e-control");h={groupID:a,ruleID:p,value:c.value,type:"operator"},this.allowValidation&&o.rules[s].operator&&-1<e.parentElement.className.indexOf("e-tooltip")&&N.getComponent(e.parentElement,"tooltip").destroy(),1<y.length&&!(-1<y[0].className.indexOf("e-template"))&&(o.rules[s].value=[]);for(var v=0;v<y.length;v++)-1<o.rules[s].operator.indexOf("null")||-1<o.rules[s].operator.indexOf("empty")?o.rules[s].value=null:y[v].classList.contains("e-template")||this.updateValues(y[v],o.rules[s]);this.isImportRules||this.trigger("change",h),this.filterRules(u,this.getValidRules(this.rule),"operator")}else N.closest(e,".e-rule-value")&&(this.ruleValueUpdate(e,t,o,s,i,r,l),n||this.filterRules(u,this.getValidRules(this.rule),"value"))},q.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.prvtEvtTgrDaD||this.trigger("ruleChange",{previousRule:e,rule:t,type:l})},q.prototype.ruleValueUpdate=function(e,t,l,n,i,o,r){var s,a=["in","between","notin","notbetween"];if(l.rules[n].operator&&(s=l.rules[n].operator.toString().toLowerCase()),null!==t){if(-1<e.className.indexOf("e-multiselect")&&"number"===l.rules[n].type&&!this.isNotified){for(var u=[],d=t,p=0,c=d.length;p<c;p++)"string"==typeof d[p]&&u.push(parseFloat(d[p]));u.length&&(t=u)}this.isNotified?(l.rules[n].value=t,i={groupID:i.id,ruleID:o.id,value:l.rules[n].value,type:"value"},this.isImportRules||this.trigger("change",i)):-1<e.className.indexOf("e-spin")||-1<e.className.indexOf("e-numeric")?-1<a.indexOf(s)?l.rules[n].value[r]=t:l.rules[n].value=t:-1<e.className.indexOf("e-radio")||-1<e.className.indexOf("e-multiselect")?l.rules[n].value=t:-1<e.className.indexOf("e-textbox")?"in"===s||"notin"===s?(l.rules[n].type,l.rules[n].value=this.processValueString(t,l.rules[n].type)):l.rules[n].value=t:-1<e.className.indexOf("e-datepicker")&&(i=this.getFormat(this.getColumn(this.selectedColumn.field).format)).type&&(-1<a.indexOf(s)?("string"==typeof l.rules[n].value&&(l.rules[n].value=[]),l.rules[n].value[r]=this.intl.formatDate(t,i)):l.rules[n].value=this.intl.formatDate(t,i)),this.validateValue(l,o,n)}else-1<e.className.indexOf("e-datepicker")&&-1<a.indexOf(s)?("string"==typeof l.rules[n].value&&(l.rules[n].value=[]),l.rules[n].value[r]=t):l.rules[n].value=t},q.prototype.validateValue=function(e,t,l){var n="object"==typeof(e=N.isNullOrUndefined(l)?e:e.rules[l]).value;this.allowValidation&&(N.isNullOrUndefined(l)||(n?0<e.value.length:e.value))&&0<(l=t.querySelectorAll(".e-rule-value .e-control")).length&&(-1<l[0].className.indexOf("e-tooltip")?N.getComponent(l[0],"tooltip").destroy():-1<l[0].parentElement.className.indexOf("e-tooltip")&&N.getComponent(l[0].parentElement,"tooltip").destroy(),l[1]&&-1<l[1].parentElement.className.indexOf("e-tooltip")&&N.getComponent(l[1].parentElement,"tooltip").destroy(),l[2])&&-1<l[2].parentElement.className.indexOf("e-tooltip")&&N.getComponent(l[2].parentElement,"tooltip").destroy()},q.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},q.prototype.findGroupByIdx=function(e,t,l){var n=t.rules,i=[];if(l)return t;for(var o=0,r=n.length;o<r;o++)(t=n[o]).rules&&i.push(t);return i[e]},q.prototype.destroy=function(){var e,t,l,n;if(this.isDestroy=!0,this.element){for(x.prototype.destroy.call(this),l=(e=this.element.querySelectorAll(".e-addrulegroup")).length,t=0;t<l;t++)N.getComponent(e[t],"dropdown-btn").destroy(),N.detach(e[t]);for(n=this.element.querySelectorAll(".e-rule-filter .e-control.e-tooltip"),t=0;t<n.length;t++)N.getComponent(n[t],"tooltip").destroy();for(l=(e=this.element.querySelectorAll(".e-rule-filter .e-control:not(.e-tooltip)")).length,t=0;t<l;t++)(N.getComponent(e[t],"dropdownlist")?N.getComponent(e[t],"dropdownlist"):N.getComponent(e[t],"dropdowntree")).destroy(),N.detach(e[t]);for(n=this.element.querySelectorAll(".e-rule-operator .e-control.e-tooltip"),t=0;t<n.length;t++)N.getComponent(n[t],"tooltip").destroy();for(l=(e=this.element.querySelectorAll(".e-rule-operator .e-control:not(.e-tooltip)")).length,t=0;t<l;t++)N.getComponent(e[t],"dropdownlist")&&(N.getComponent(e[t],"dropdownlist").destroy(),N.detach(e[t]));for(n=this.element.querySelectorAll(".e-rule-value .e-control.e-tooltip"),t=0;t<n.length;t++)N.getComponent(n[t],"tooltip").destroy();this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_group0"]=[0],this.element.innerHTML="",this.portals&&this.portals.length&&this.clearQBTemplate();var i=document.querySelectorAll(".qb-dropdownlist.e-popup");if(i)for(t=0;t<i.length;t++)i[t].remove();N.classList(this.element,[],["e-rtl","e-responsive","e-device"]),this.isDestroy=!1}},q.prototype.addRules=function(e,t){t=this.element.id+"_"+t,this.isPublic=!0;for(var l=0,n=e.length;l<n;l++)this.addRuleElement(document.getElementById(t),e[l]);this.isPublic=!1},q.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),t=this.getParentGroup(l);if(e.length){this.isPublic=!0;for(var n=0,i=e.length;n<i;n++)this.updatedRule={isLocked:e[n].isLocked,condition:e[n].condition,not:e[n].not},this.importRules(e[n],l,!1,e[n].not);this.isPublic=!1}else{var o="and",r=!1,s=!1;this.updatedRule&&(o=this.updatedRule.condition,r=this.updatedRule.not,s=this.updatedRule.isLocked),this.groupIndex<0?this.enableNotCondition?t.rules.push({condition:o,not:r,rules:[]}):t.rules.push({condition:o,rules:[]}):this.enableNotCondition?t.rules.splice(this.groupIndex+1,0,{condition:o,not:r,rules:[],isLocked:s}):t.rules.splice(this.groupIndex+1,0,{condition:o,rules:[],isLocked:s})}this.headerTemplate||this.disableRuleCondition(l,t,null,!!this.enableSeparateConnector||null)}},q.prototype.initWrapper=function(){if(this.isInitialLoad=!0,this.cssClass&&N.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.enableSeparateConnector&&N.addClass([this.element],"e-multi-connector"),this.enableRtl&&N.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),N.Browser.isDevice||"Vertical"===this.displayMode?(N.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),N.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),N.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{this.columns&&this.columns.length&&this.isImportRules?(this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not,!1,this.rule),e=N.extend({},this.rule,{},!0),this.isRefreshed=!0,this.setGroupRules(e),this.isRefreshed=!1):this.columns&&this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{}),this.notGroupRtl(),this.readonly&&this.enableReadonly();for(var e,t,l=this.element.querySelectorAll("label.e-btn"),n=0;n<l.length;n++)t=l.item(n),N.rippleEffect(t,{selector:".e-btn"})}},q.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:{type:"button",class:"e-edit-rule e-css e-btn e-small e-flat e-primary"}}),n=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),l.textContent=this.l10n.getConstant("Edit"),n.appendChild(l),e.appendChild(n),this.element.appendChild(e)},q.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)},q.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new h.DataManager(this.columns).executeLocal((new h.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new h.DataManager(this.columns).executeLocal((new h.Query).sortBy("field")))},q.prototype.onChangeNotGroup=function(){var e;this.element.innerHTML="",this.groupIdCounter=0,this.headerTemplate||(this.enableNotCondition?(e=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),this.groupElem.querySelector(".e-btn-group")&&this.groupElem.querySelector(".e-btn-group").insertBefore(e,this.groupElem.querySelector(".e-btngroup-and"))):this.groupElem.querySelector(".e-qb-toggle").remove()),this.setProperties({rule:this.checkNotGroup(this.rule)},!0),this.initWrapper()},q.prototype.notGroupRtl=function(){this.enableRtl?N.addClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl"):N.removeClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl")},q.prototype.checkNotGroup=function(e){var t;if(e.rules)for(var l=0;l<e.rules.length;l++)t=e.rules[l],t=this.checkNotGroup(t),e.rules[l]=t;return N.isNullOrUndefined(e.not)?this.enableNotCondition&&!N.isNullOrUndefined(e.condition)&&(e.not=!1):(this.enableNotCondition&&(e.not=!1),delete e.not),e},q.prototype.onPropertyChanged=function(e,t){for(var l=Object.keys(e),n=this.element.querySelector(".e-group-container"),i=this.element.querySelector(".e-summary-content"),o=0,r=l;o<r.length;o++)switch(r[o]){case"summaryView":e.summaryView?(n.style.display="none",this.element.querySelectorAll(".e-summary-content").length<1?(this.renderSummary(),i=this.element.querySelector(".e-summary-content")):this.element.querySelector(".e-summary-text").textContent=this.getSqlFromRules(this.rule),i.style.display="block"):(-1<n.querySelectorAll(".e-collapse-rule").length&&this.renderSummaryCollapse(),n.style.display="block",i.style.display="none");break;case"displayMode":this.refresh();break;case"showButtons":N.isNullOrUndefined(e.showButtons.lockGroup)||(e.showButtons.lockGroup?N.removeClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"):N.addClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide")),N.isNullOrUndefined(e.showButtons.lockRule)||(e.showButtons.lockRule?N.removeClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"):N.addClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide")),N.isNullOrUndefined(e.showButtons.cloneGroup)||(e.showButtons.cloneGroup?N.removeClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"):N.addClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide")),N.isNullOrUndefined(e.showButtons.cloneRule)||(e.showButtons.cloneRule?N.removeClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"):N.addClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide")),N.isNullOrUndefined(e.showButtons.ruleDelete)||(e.showButtons.ruleDelete?N.removeClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"):N.addClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide")),N.isNullOrUndefined(e.showButtons.groupDelete)||(e.showButtons.groupDelete?N.removeClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"):N.addClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"));break;case"cssClass":t.cssClass&&N.removeClass([this.element],t.cssClass.split(" ")),e.cssClass&&N.addClass([this.element],e.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"enableRtl":e.enableRtl?N.addClass([this.element],"e-rtl"):N.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(),this.updateSubFieldsFromColumns(this.columns);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":0!==this.rule.rules.length||N.isNullOrUndefined(this.rule)||this.reset(),this.setProperties({rule:e.rule},!0),e.rule=this.getRuleCollection(this.rule,!1),this.setRules(this.rule);break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale,this.intl=new N.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();break;case"allowDragAndDrop":this.allowDragAndDrop=e.allowDragAndDrop,this.refresh();break;case"enableSeparateConnector":this.enableSeparateConnector=e.enableSeparateConnector,this.refresh()}},q.prototype.preRender=function(){this.element.id=this.element.id||N.getUniqueID("ej2-querybuilder"),this.defaultLocale={StartsWith:"Starts With",DoesNotStartWith:"Does Not Start With",EndsWith:"Ends With",DoesNotEndWith:"Does Not End With",Contains:"Contains",DoesNotContain:"Does Not Contain",NotLike:"Not Like",Like:"Like",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",CloneGroup:"Clone Group",LockGroup:"Lock Group",CloneRule:"Clone Rule",LockRule:"Lock Rule",UnlockRule:"Unlock Rule",UnlockGroup:"Unlock Group"},this.l10n=new N.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new N.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:"notstartswith",key:this.l10n.getConstant("DoesNotStartWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"notendswith",key:this.l10n.getConstant("DoesNotEndWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{value:"notcontains",key:this.l10n.getConstant("DoesNotContain")},{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")},{value:"between",key:this.l10n.getConstant("Between")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")}],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.sqlOperators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:this.l10n.getConstant("In").toUpperCase(),notin:this.l10n.getConstant("NotIn").toUpperCase(),lessthanorequal:"<=",startswith:this.l10n.getConstant("Like").toUpperCase(),endswith:this.l10n.getConstant("Like").toUpperCase(),between:this.l10n.getConstant("Between").toUpperCase(),notbetween:this.l10n.getConstant("NotBetween").toUpperCase(),contains:this.l10n.getConstant("Like").toUpperCase(),isnull:this.l10n.getConstant("IsNull").toUpperCase(),isnotnull:this.l10n.getConstant("IsNotNull").toUpperCase(),isempty:this.l10n.getConstant("IsEmpty").toUpperCase(),isnotempty:this.l10n.getConstant("IsNotEmpty").toUpperCase(),notstartswith:this.l10n.getConstant("NotLike").toUpperCase(),notendswith:this.l10n.getConstant("NotLike").toUpperCase(),notcontains:this.l10n.getConstant("NotLike").toUpperCase()},this.fields||(this.fields={text:"label",value:"field"})},q.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 h.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new h.Query).take(1))):(this.dataManager=new h.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new h.Query),this.initControl()),this.renderComplete(),this.allowDragAndDrop&&this.initializeDrag()},q.prototype.initializeDrag=function(){this.draggable=new N.Draggable(this.element,{dragTarget:".e-drag-qb-rule",distance:5,helper:this.helper.bind(this),dragStart:this.dragStartHandler.bind(this),drag:this.dragHandler.bind(this),dragStop:this.dragStopHandler.bind(this),isReplaceDragEle:!0,isPreventSelect:!1,abort:".e-parent-header",isDragScroll:!0})},q.prototype.helper=function(e){var t,l,n,i=this.draggable.currentStateTarget;return!(!i.classList.contains("e-drag-qb-rule")||i.classList.contains("e-drag-qb-rule")&&N.closest(i,".e-disable"))&&(t=this.createElement("div",{className:"e-cloneproperties e-draganddrop e-dragclone",styles:'height:"auto", z-index:2, width:'+this.element.offsetWidth}),(this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(l=N.closest(i,".e-group-container").cloneNode(!0),N.closest(i,".e-group-container")):(t.classList.add("e-group-body"),l=this.createElement("div",{className:"e-rule-container"}),n=N.closest(i,".e-rule-field").cloneNode(!0),l.appendChild(n),N.closest(i,".e-rule-field"))).classList.add("e-qb-dragging-rule"),t.appendChild(l),t.querySelectorAll("*").forEach(function(e){e.removeAttribute("id")}),this.element.appendChild(t),t)},q.prototype.dragStartHandler=function(e){this.draggedRule=e.target,this.isDragEventPrevent=!1,document.body.classList.add("e-prevent-select"),this.dragElement=e.dragElement;var t=N.closest(e.target,".e-rule-container"),e=N.closest(e.target,".e-group-container"),t={dragRuleID:(null!==t?t:e).id,dragGroupID:e.id,cancel:!1};this.trigger("dragStart",t),this.isDragEventPrevent=t.cancel},q.prototype.dragHandler=function(e){var t,l,n,i,o,r,s;this.isDragEventPrevent||(this.element.querySelectorAll(".e-drag-rule-bottom-line").forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),this.element.querySelectorAll(".e-drag-rule-top-line").forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),N.isNullOrUndefined(e.target))||("HTML"===e.target.nodeName||N.closest(e.target,".e-qb-dragging-rule")||N.closest(e.target,".e-group-header")||!N.closest(e.target,"#"+this.element.id)||N.closest(e.target,".e-disable")||e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")&&this.enableSeparateConnector?this.dragElement.classList.add("e-notallowedcur"):(this.dragElement.classList.remove("e-notallowedcur"),t=N.closest(e.target,".e-rule-container"),r=N.closest(e.target,".e-group-container"),t?(l=t.getBoundingClientRect(),s=(n=e.event.clientY||e.event.changedTouches[0].clientY)-l.top,i=l.bottom-n,s<(o=20)?t.classList.add("e-drag-rule-top-line"):i<o&&t.classList.add("e-drag-rule-bottom-line")):e.target.classList.contains("e-rule-list")&&0===e.target.children.length?e.target.classList.add("e-drag-rule-bottom-line"):e.target.classList.contains("e-rule-list")&&e.target.children[0].classList.contains("e-group-container")?(l=e.target.children[0].getBoundingClientRect(),(s=(n=e.event.clientY||e.event.changedTouches[0].clientY)-l.top)<(o=20)&&e.target.classList.add("e-drag-rule-top-line")):(N.closest(e.target,".e-group-container")||e.target.classList.contains("e-group-container"))&&-1<(r=r||e.target).id.indexOf("group0")&&(l=e.target.getBoundingClientRect(),n=e.event.clientY||e.event.changedTouches[0].clientY,(i=l.bottom-n)<(o=20))&&e.target.classList.add("e-drag-rule-bottom-line"),s={dragRuleID:null!==t?t.id:null!==r?r.id:null,dragGroupID:null!==r?r.id:null,cancel:!1},this.trigger("drag",s),this.isDragEventPrevent=s.cancel))},q.prototype.dragStopHandler=function(e){var t=this;if(!this.isDragEventPrevent){var l,n,i,o,r=N.closest(e.target,".e-rule-container"),s=(N.isNullOrUndefined(r)&&e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")&&this.enableSeparateConnector&&(r=N.closest(e.target.parentElement.previousElementSibling,".e-rule-container")),(l=N.isNullOrUndefined(e.helper)?l:N.closest(e.helper,".e-notallowedcur"))||(n=N.closest(e.target,".e-group-container"),n={cancel:!1,dropRuleID:null!==r?r.id:null!==n?n.id:null,dropGroupID:null!==n?n.id:null},this.trigger("drop",n),n.cancel&&(l=!0),n=this.getValidRules()),this.prvtEvtTgrDaD=!0,this.enableSeparateConnector&&e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")?e.target.parentElement.previousElementSibling:e.target);if(r&&!l){var a=r.id.split(this.element.id+"_")[1].split("_")[0];if(this.draggable.currentStateTarget.parentElement.classList.contains("e-rule-field")||this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")){var u,d=void 0;this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(N.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),(u=N.extend([],this.getGroup(r),[],!0)).properties&&(u=u.properties);(p=N.closest(r,".e-group-container")).querySelectorAll(".e-group-container").forEach(function(e){t.element.querySelector("#"+e.id)&&t.deleteGroup(e)});for(var p,c=p.querySelectorAll(".e-rule-container"),h=[],g=void 0,m=0;m<c.length;m++)(c[m].classList.contains("e-drag-rule-top-line")||c[m].classList.contains("e-drag-rule-bottom-line"))&&(g=m),h.push(c[m].id.split(this.element.id+"_")[1]);this.deleteRules(h),r.classList.contains("e-drag-rule-top-line")?u.rules.splice(g,0,d):u.rules.splice(g+1,0,d),u.rules.forEach(function(e){t.enableSeparateConnector?e.rules?t.addGroups([e],a):t.addRules([e],a):e.condition?t.addGroups([e],a):t.addRules([e],a)})}}else s.classList.contains("e-rule-list")&&0===s.children.length&&!l?(o=(p=N.closest(s,".e-group-container")).id.split(this.element.id+"_")[1].split("_")[0],d=void 0,this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(N.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),this.enableSeparateConnector?d.rules?this.addGroups([d],o):this.addRules([d],o):d.condition?this.addGroups([d],o):this.addRules([d],o)):s.classList.contains("e-rule-list")&&s.children[0].classList.contains("e-group-container")&&!l?(i=(p=N.closest(s,".e-group-container")).id.split(this.element.id+"_")[1].split("_")[0],d=void 0,this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(N.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),(u=N.extend([],this.getGroup(s),[],!0)).properties&&(u=u.properties),s.querySelectorAll(".e-group-container").forEach(function(e){t.element.querySelector("#"+e.id)&&t.deleteGroup(e)}),(c=p.querySelectorAll(".e-rule-container")).forEach(function(e){t.element.querySelector("#"+e.id)&&t.deleteRule(e)}),this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?this.addGroups([d],i):this.addRules([d],i),u.rules.forEach(function(e){t.enableSeparateConnector?e.rules?t.addGroups([e],i):t.addRules([e],i):e.condition?t.addGroups([e],i):t.addRules([e],i)})):!N.closest(e.target,".e-group-container")&&!e.target.classList.contains("e-group-container")||l||(d=void 0,"group0"===(o=(r=!(r=N.closest(e.target,".e-group-container"))&&e.target.classList.contains("e-group-container")?e.target:r).id.split(this.element.id+"_")[1].split("_")[0])&&(this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(N.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),this.enableSeparateConnector?d.rules?this.addGroups([d],o):this.addRules([d],o):d.condition?this.addGroups([d],o):this.addRules([d],o)));l||this.trigger("ruleChange",{previousRule:n,rule:this.getValidRules(),type:"drag-and-drop"}),this.prvtEvtTgrDaD=!1,document.body.classList.remove("e-prevent-select");s=this.element.querySelectorAll(".e-drag-rule-bottom-line");s.forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),(s=this.element.querySelectorAll(".e-drag-rule-top-line")).forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),(s=this.element.querySelectorAll(".e-qb-dragging-rule")).forEach(function(e){e.classList.remove("e-qb-dragging-rule")}),e.helper&&e.helper.classList.contains("e-cloneproperties")&&document.querySelector("."+e.helper.classList[0])&&N.remove(e.helper),this.enableSeparateConnector&&this.refresh()}},q.prototype.templateParser=function(t){if(t)try{return"function"!=typeof t&&document.querySelectorAll(t).length?N.compile(document.querySelector(t).innerHTML.trim()):N.compile(t)}catch(e){return N.compile(t)}},q.prototype.executeDataManager=function(e){var t=this,e=this.dataManager.executeQuery(e),l=new h.Deferred;e.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){l.reject(e)})},q.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},q.prototype.wireEvents=function(){var e=this.getWrapper();N.EventHandler.add(e,"click",this.clickEventHandler,this),N.EventHandler.add(e,"focusout",this.focusEventHandler,this),N.EventHandler.add(e,"focusin",this.focusEventHandler,this),N.EventHandler.add(this.element,"keydown",this.keyBoardHandler,this),N.EventHandler.add(document,"keydown",this.keyBoardHandler,this)},q.prototype.unWireEvents=function(){var e=this.getWrapper();N.EventHandler.remove(e,"click",this.clickEventHandler),N.EventHandler.remove(e,"focusout",this.focusEventHandler),N.EventHandler.remove(e,"focusin",this.focusEventHandler),N.EventHandler.remove(this.element,"keydown",this.keyBoardHandler),N.EventHandler.remove(document,"keydown",this.keyBoardHandler)},q.prototype.getParentGroup=function(e,t){for(var l=e instanceof Element?this.levelColl[e.id]:this.levelColl[""+e],n=t?l.length-1:l.length,i=this.rule,o=0;o<n;o++)i=this.findGroupByIdx(l[o],i,0===o);return i},q.prototype.deleteGroup=function(t){var l=this,e=t,n=("string"==typeof t?(n=this.element.id+"_"+t,t=document.getElementById(n),n):e.id).replace(this.element.id+"_","");"group0"!==n&&t&&(e={groupID:n,cancel:!1,type:"deleteGroup"},this.isImportRules||this.prvtEvtTgrDaD?this.deleteGroupSuccessCallBack(e,t):this.trigger("beforeChange",e,function(e){l.deleteGroupSuccessCallBack(e,t)}))},q.prototype.deleteGroupSuccessCallBack=function(e,t){if(!e.cancel){for(var l=t,n=this.getParentGroup(l,!0),i=0,o=void 0,r=void 0,s=this.getValidRules(this.rule),a=l.nextElementSibling,u=l.previousElementSibling,d=l.querySelectorAll(".e-group-container"),p=l.querySelectorAll(".e-tooltip"),r=p.length,o=0;o<r;o++)N.getComponent(p[o],"tooltip").destroy();for(o=0,r=d.length;o<r;o++)delete this.levelColl[d[o].id];for(;null!==l.previousElementSibling;)l=l.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!l.classList.contains("e-btn-group")||this.headerTemplate&&(l.classList.contains("e-rule-container")||l.classList.contains("e-group-container"))))&&i++;this.enableSeparateConnector||a&&-1<a.className.indexOf("e-separate-rule")&&(N.removeClass([a],"e-separate-rule"),N.addClass([a],"e-joined-rule"),u)&&-1<u.className.indexOf("e-rule-container")&&N.addClass([u],"e-prev-joined-rule");var a=l.parentElement.parentElement.parentElement,c=[];if(this.isReact||this.isAngular){var h=n.rules[i],g=t.querySelectorAll(".e-rule-container");if(h&&h.rules)for(var m=0;m<h.rules.length;m++){var f,y=this.getColumn(h.rules[m].field);g[m]&&(f=g[m].querySelector(".e-template-value"),y)&&(y.ruleTemplate||this.isPlatformTemplate(y)&&f)&&c.push(g[m].id)}}N.detach(t),this.headerTemplate&&this.clearQBTemplate([t.id]),c.length&&this.clearQBTemplate(c),n.rules.splice(i,1),delete this.levelColl[e.groupID],this.refreshLevelColl(),this.disableRuleCondition(a,n),this.enableSeparateConnector&&u&&(!this.headerTemplate&&u.classList.contains("e-btn-group")||this.headerTemplate&&u.classList.contains("e-custom-group-btn"))&&N.detach(u),this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",e),this.filterRules(s,this.getValidRules(this.rule),"deleteGroup")}},q.prototype.isPlatformTemplate=function(e){return e.template&&("string"==typeof e.template||void 0===e.template.create)},q.prototype.deleteRule=function(t){var l=this,e={groupID:N.closest(t,".e-group-container").id.replace(this.element.id+"_",""),ruleID:N.closest(t,".e-rule-container").id.replace(this.element.id+"_",""),cancel:!1,type:"deleteRule"};this.isImportRules||this.prvtEvtTgrDaD?this.deleteRuleSuccessCallBack(e,t):this.trigger("beforeChange",e,function(e){l.deleteRuleSuccessCallBack(e,t)})},q.prototype.deleteRuleSuccessCallBack=function(e,t){if(!e.cancel){for(var l=N.closest(t,".e-group-container"),n=this.getParentGroup(l),i=N.closest(t,".e-rule-container"),t=this.getValidRules(this.rule),o=i.previousElementSibling,r=0,s=i,a=i.nextElementSibling,u=i.querySelectorAll(".e-tooltip"),d=void 0,p=u.length,d=0;d<p;d++)N.getComponent(u[d],"tooltip").destroy();for(;null!==i.previousElementSibling;)i=i.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!i.classList.contains("e-btn-group")||this.headerTemplate&&(i.classList.contains("e-rule-container")||i.classList.contains("e-group-container"))))&&r++;var c,h,g=this.getColumn(n.rules[r].field),a=(g&&g.template&&s.querySelector(".e-template")&&this.templateDestroy(g,s.querySelector(".e-template").id),(!o||o.className.indexOf("e-rule-container")<0)&&a&&N.removeClass([a],"e-joined-rule"),(!a||a.className.indexOf("e-rule-container")<0)&&o&&N.removeClass([o],"e-prev-joined-rule"),s.querySelector(".e-template-value"));try{this.enableSeparateConnector&&(s.previousElementSibling||s.nextElementSibling)&&(c=s.previousElementSibling,h=s.nextElementSibling,N.isNullOrUndefined(h)&&(!this.headerTemplate&&c.classList.contains("e-btn-group")||this.headerTemplate&&c.classList.contains("e-custom-group-btn"))?(c&&c.previousElementSibling&&c.previousElementSibling.classList.contains("e-rule-container")&&(this.getRule(c.previousElementSibling).condition=null),N.detach(c)):(!this.headerTemplate&&h.classList.contains("e-btn-group")||this.headerTemplate&&h.classList.contains("e-custom-group-btn"))&&N.detach(h)),N.detach(s)}catch(e){return}g&&g.ruleTemplate&&this.clearQBTemplate([s.id]),g&&this.isPlatformTemplate(g)&&a&&this.clearQBTemplate([s.id]),n.rules.splice(r,1),n.rules[0]&&n.rules[0].rules||this.disableRuleCondition(l,n,!!this.enableSeparateConnector);for(var m=this.element.querySelectorAll(".e-tooltip"),f=0;f<m.length;f++)N.getComponent(m[f],"tooltip").refresh(m[f]);this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",e),this.filterRules(t,this.getValidRules(this.rule),"deleteRule")}},q.prototype.setGroupRules=function(e,t){this.headerTemplate&&t&&(this.isRoot=!0),this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.setProperties({rule:e},!0),e=this.getRuleCollection(this.rule,!1),this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0,this.rule.not,t),e.isLocked&&(t=this.element.querySelector(".e-group-container").querySelector(".e-lock-grp-btn"),this.groupLock(t)),this.isImportRules=!1},q.prototype.keyBoardHandler=function(e){var t;e.currentTarget!==this.element||!this.readonly||38!==e.keyCode&&40!==e.keyCode&&13!==e.keyCode?"Escape"===e.code&&this.allowDragAndDrop&&(this.isDragEventPrevent=!0,document.body.classList.remove("e-prevent-select"),this.element.querySelectorAll(".e-drag-rule-bottom-line").forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),this.element.querySelectorAll(".e-drag-rule-top-line").forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),this.element.querySelectorAll(".e-qb-dragging-rule").forEach(function(e){e.classList.remove("e-qb-dragging-rule")}),(t=this.element.querySelector(".e-cloneproperties"))&&N.remove(t),this.enableSeparateConnector)&&this.refresh():e.preventDefault()},q.prototype.clearQBTemplate=function(e){(this.isReact||this.isAngular)&&this.clearTemplate(e)},q.prototype.disableRuleCondition=function(e,t,l,n){if(!this.headerTemplate&&!this.readonly){var i=e.querySelector(".e-rule-list").childElementCount,o=e.querySelector(".e-btngroup-and"),r=e.querySelector(".e-btngroup-or");if(1<i)if(o.disabled=!1,r.disabled=!1,(r.nextElementSibling.classList.contains("e-btn-disable")||o.nextElementSibling.classList.contains("e-btn-disable"))&&(r.nextElementSibling.classList.remove("e-btn-disable"),o.nextElementSibling.classList.remove("e-btn-disable")),this.enableSeparateConnector&&!l){for(var s=0,a=void 0;;){var u=e.parentElement.querySelectorAll(".e-btngroup-and"),d=e.parentElement.querySelectorAll(".e-btngroup-or"),o=u[u.length-(1+s)],r=d[d.length-(1+s)];if(!(a=u[u.length-(1+s)])||!a.parentElement||"none"!==a.parentElement.style.display)break;s++}for(var p=e.previousElementSibling;p&&!p.classList.contains("e-rule-container");){if(p.classList.contains("e-group-container")){p=p.querySelectorAll(".e-rule-container")[p.querySelectorAll(".e-rule-container").length-1];break}p=p.previousElementSibling}n&&e.classList.contains("e-group-container")?"or"===this.getGroup(p=e).condition?r.checked=!0:o.checked=!0:p&&p.classList.contains("e-rule-container")&&(c=p.id.replace(this.element.id+"_",""),"or"===this.getRule(c).condition?r.checked=!0:o.checked=!0)}else l||(t&&"or"===t.condition?r.checked=!0:o.checked=!0);else if(this.enableSeparateConnector&&!l){for(s=0,a=void 0;;){u=e.parentElement.querySelectorAll(".e-btngroup-and"),d=e.parentElement.querySelectorAll(".e-btngroup-or");if(o=u[u.length-(1+s)],r=d[d.length-(1+s)],!(a=u[u.length-(1+s)])||!a.parentElement||"none"!==a.parentElement.style.display)break;s++}for(var c,p=void 0,h=e.previousElementSibling;h;){if((h=h.classList.contains("e-group-container")?h.querySelectorAll(".e-rule-container")[h.querySelectorAll(".e-rule-container").length-1]:h).classList.contains("e-rule-container")){p=h;break}h=h.previousElementSibling}N.isNullOrUndefined(p)&&e.querySelectorAll(".e-rule-container")[e.querySelectorAll(".e-rule-container").length-1]&&(p=e.querySelectorAll(".e-rule-container")[e.querySelectorAll(".e-rule-container").length-1]),n&&e.classList.contains("e-group-container")?"or"===this.getGroup(p=e).condition?r.checked=!0:o.checked=!0:p&&(c=p.id.replace(this.element.id+"_",""),"or"===this.getRule(c).condition&&r?r.checked=!0:o&&(o.checked=!0))}else l||N.isNullOrUndefined(o)||(o.checked=!1,o.disabled=!0,r.checked=!1,r.disabled=!0,t&&(r.nextElementSibling.classList.add("e-btn-disable"),o.nextElementSibling.classList.add("e-btn-disable")))}},q.prototype.getValidRules=function(e){this.isValueEmpty=!0;var t=(e=e||this.getRules()).condition,l=e.not,n=N.extend([],e.rules,[],!0),t=N.isNullOrUndefined(e.isLocked)?this.getRuleCollection({condition:t,rules:n,not:l},!0):this.getRuleCollection({condition:t,rules:n,not:l,isLocked:e.isLocked},!0);return this.isValueEmpty=!1,t},q.prototype.getRuleCollection=function(e,t){if(N.isNullOrUndefined(e))return null;var l;if(e.rules&&e.rules.length&&(6<Object.keys(e.rules[0]).length||t))for(var n=e.rules.length,i=0;i<n;i++)l=e.rules[i],l=this.getRuleCollection(l,t),e.rules[i]=l,Object.keys(l).length<1&&t&&(e.rules.splice(i,1),i--,n--);var o,r,s=e.custom;return e.field&&""!==e.field&&(N.isNullOrUndefined(s)||s&&"question"!==s.type&&"answer"!==s.type)?(e.operator&&(-1<e.operator.toString().indexOf("null")||-1<e.operator.toString().indexOf("empty"))&&(e.value=null),(this.isRefreshed&&this.enablePersistence||""!==e.field&&""!==e.operator&&(!this.isValueEmpty||""!==e.value)&&void 0!==e.value||s&&s.isQuestion)&&(r=e.condition,o=e.isLocked,e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value},N.isNullOrUndefined(o)||(e.isLocked=o),r&&(e.condition=r),s&&(e.custom=s),"in"!==e.operator&&"notin"!==e.operator||!e.value||0!==e.value.length)||(e={})):!s||"question"!==s.type&&"answer"!==s.type?(N.isNullOrUndefined(e.condition)&&N.isNullOrUndefined(e.rules)||(o=e.isLocked,e=this.enableNotCondition?{condition:e.condition,rules:e.rules,not:e.not}:{condition:e.condition,rules:e.rules},N.isNullOrUndefined(o)||(e.isLocked=o),s&&(e.custom=s),e.rules&&0===e.rules.length))&&(e={}):(r=e.not,(e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value,condition:e.condition,rules:e.rules}).custom=s,this.enableNotCondition&&(e.not=r)),e},q.prototype.setRules=function(e){e=N.extend({},e,{},!0);this.headerTemplate?this.setGroupRules(e,!0):this.setGroupRules(e)},q.prototype.getRules=function(){var e=this.enableNotCondition?{condition:this.rule.condition,rules:this.rule.rules,not:this.rule.not}:{condition:this.rule.condition,rules:this.rule.rules};return N.isNullOrUndefined(this.rule.isLocked)||(e.isLocked=this.rule.isLocked),this.rule.custom&&(e.custom=this.rule.custom),e},q.prototype.getRule=function(e){var t=0,l=e instanceof HTMLElement?N.closest(e,".e-rule-container"):(e=this.element.id+"_"+e,document.getElementById(e));if(N.isNullOrUndefined(l))return null;for(e=N.closest(l,".e-group-container"),e=this.getParentGroup(e);null!==l.previousElementSibling;)l=l.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!l.classList.contains("e-btn-group")||this.headerTemplate&&(l.classList.contains("e-rule-container")||l.classList.contains("e-group-container"))))&&t++;return e.rules[t]},q.prototype.getGroup=function(e){e=(e=e instanceof Element&&e.className.indexOf("e-group-container")<1?N.closest(e,".e-group-container"):e)instanceof Element?e.id:this.element.id+"_"+e;return this.getParentGroup(e)},q.prototype.deleteGroups=function(e){for(var t,l=e.length,n=0;n<l;n++)"group0"!==e[n]&&(t=this.element.id+"_"+e[n],this.deleteGroup(document.getElementById(t)))},q.prototype.getFilteredRecords=function(){var e=this.getPredicate(this.getValidRules(this.rule)),e=N.isNullOrUndefined(e)?new h.Query:(new h.Query).where(e);return this.dataManager.executeQuery(e)},q.prototype.deleteRules=function(e){for(var t,l=e.length,n=0;n<l;n++)t=this.element.id+"_"+e[n],this.deleteRule(document.getElementById(t))},q.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),l=[],n=0,i=Object.keys(this.columns);n<i.length;n++)l.push(this.columns[n].field);return e.rules.length?(new h.Query).select(l).where(t):(new h.Query).select(l)},q.prototype.getPredicate=function(e){var t,l,n=e.rules,i=!1;if(n){for(var o=0,r=n.length;o<r;o++){var s=n[o].operator;"notstartswith"===s?s="doesnotstartwith":"notendswith"===s?s="doesnotendwith":"notcontains"===s&&(s="doesnotcontain");var a,u,d,p,c,i=!1;-1<Object.keys(n[o]).indexOf("rules")&&n[o].rules?(a=this.getPredicate(n[o]))&&(t=t?"and"===e.condition?t.and(a):t.or(a):a):N.isNullOrUndefined(s)||N.isNullOrUndefined(s.length)||(a=n[o].operator.toLowerCase(),u=!1,d=["equal","notequal","greaterthan","greaterthanorequal","lessthan","lessthanorequal"],"string"===n[o].type&&(i=!this.matchCase),"date"===n[o].type&&-1<d.indexOf(a)&&(i=!0),p=this.getColumn(n[o].field),-1<a.indexOf("null")||-1<a.indexOf("empty")?n[o].value=null:"date"!==n[o].type||n[o].value instanceof Array?l=n[o].value:(p=this.getFormat(p.format),N.isNullOrUndefined(n[o].value)?l=null:(l=this.getDate(n[o].value,p),-1<d.indexOf(a)&&!this.isTime(n[o].value)&&(u=!0))),0===o?u||(-1<a.indexOf("in")||-1<a.indexOf("between")||-1<a.indexOf("null")||-1<a.indexOf("empty"))&&a.indexOf("contain")<0?t=u?this.datePredicate(n[o],l):this.arrayPredicate(n[o]):""!==(c=l)&&(t=new h.Predicate(n[o].field,s,l,i)):u||(-1<a.indexOf("in")||-1<a.indexOf("between")||-1<a.indexOf("null")||-1<a.indexOf("empty"))&&a.indexOf("contain")<0?t=u?this.datePredicate(n[o],l,t,e.condition):this.arrayPredicate(n[o],t,e.condition):"and"===e.condition?(c=l,t&&""!==c?t=t.and(n[o].field,s,l,i):""!==c&&(t=new h.Predicate(n[o].field,s,l,i))):(c=l,t&&""!==c?t=t.or(n[o].field,s,l,i):""!==c&&(t=new h.Predicate(n[o].field,s,l,i))))}this.dataSource instanceof h.DataManager&&(N.isNullOrUndefined(t)||"isnull"!==t.operator&&"isnotnull"!==t.operator||(t.operator="isnull"===t.operator?"equal":"notequal"))}return t},q.prototype.getLocale=function(){var e=this.locale;return e=N.getValue("main."+this.locale+".dates.calendars.gregorian.days.format.short",N.cldrData)?e:"en"},q.prototype.getColumn=function(e,t){for(var l,n=this.columns,i=0,o=(n=t||n).length;i<o;i++){if(n[i].field===e){l=n[i];break}if(n[i].columns){if(l=this.getColumn(e,n[i].columns))break}else if(e&&-1<e.indexOf(this.separator)&&""!==this.separator&&n[i].field===e.split(this.separator)[0]){l=n[i];break}}return l},q.prototype.getOperators=function(e){return this.getColumn(e).operators},q.prototype.setTime=function(e,t){return t?e.setHours(0,0,0):e.setHours(23,59,59),e},q.prototype.datePredicate=function(e,t,l,n){var i,o=this.setTime(new Date(t.getTime()),!0),r=this.setTime(t);switch(e.operator){case"equal":i=(i=new h.Predicate(e.field,"greaterthanorequal",o)).and(e.field,"lessthanorequal",r);break;case"notequal":i=(i=new h.Predicate(e.field,"lessthan",o)).or(e.field,"greaterthan",r);break;case"greaterthan":i=new h.Predicate(e.field,"greaterthan",r);break;case"greaterthanorequal":i=new h.Predicate(e.field,"greaterthanorequal",o);break;case"lessthan":i=new h.Predicate(e.field,"lessthan",o);break;case"lessthanorequal":i=new h.Predicate(e.field,"lessthanorequal",r)}return i&&(l?"and"===n?l=l.and(i):"or"===n&&(l=l.or(i)):l=i),l},q.prototype.arrayPredicate=function(e,t,l){var n,i=e.value,o=e.operator.toString(),r=e.value,s=this.getColumn(e.field),a=this.getFormat(s.format);if(-1<o.indexOf("null")||-1<o.indexOf("empty"))switch(o){case"isnull":n=new h.Predicate(e.field,"isnull",r);break;case"isnotnull":n=new h.Predicate(e.field,"isnotnull",r);break;case"isempty":n=new h.Predicate(e.field,"equal","");break;case"isnotempty":n=new h.Predicate(e.field,"notequal","")}if(!(-1<o.indexOf("null")||-1<o.indexOf("empty")))for(var u=0,d=i.length;u<d;u++)if(""!==i[u]||("in"===o||"notin"===o)&&"string"===s.type)if(0===u){var p="greaterthanorequal";switch(o){case"between":n="date"!==s.type?new h.Predicate(e.field,p,i[u]):new h.Predicate(e.field,p,i[u]?this.isTime(i[u])?this.getDate(i[u],a):this.setTime(this.getDate(i[u],a),!0):null);break;case"notbetween":n="date"===s.type?new h.Predicate(e.field,"lessthan",i[u]?this.isTime(i[u])?this.getDate(i[u],a):this.setTime(this.getDate(i[u],a),!0):null):new h.Predicate(e.field,"lessthan",i[u]);break;case"in":n=new h.Predicate(e.field,"equal",i[u]);break;case"notin":n=new h.Predicate(e.field,"notequal",i[u])}}else switch(e.operator){case"between":n="date"===s.type?n.and(e.field,"lessthanorequal",i[u]&&(this.isTime(i[u])?this.getDate(i[u],a):this.setTime(this.getDate(i[u],a)))):n.and(e.field,"lessthanorequal",i[u]);break;case"notbetween":n="date"===s.type?n.or(e.field,"greaterthan",i[u]&&(this.isTime(i[u])?this.getDate(i[u],a):this.setTime(this.getDate(i[u],a)))):n.or(e.field,"greaterthan",i[u]);break;case"in":n=n.or(e.field,"equal",i[u]);break;case"notin":n=n.and(e.field,"notequal",i[u])}return n&&(t?"and"===l?t=t.and(n):"or"===l&&(t=t.or(n)):t=n),t},q.prototype.getDate=function(e,t){t=this.intl.parseDate(e,t);return-1<e.indexOf(":")&&e.indexOf("/")<0&&e.indexOf(",")<0&&e.indexOf("-")<0&&((t=new Date).setHours(parseInt(e.split(":")[0],10)),t.setMinutes(parseInt(e.split(":")[1],10)),e.split(":")[2])&&t.setSeconds(parseInt(e.split(":")[2],10)),t},q.prototype.isTime=function(e){return!!(e&&-1<e.indexOf(":"))},q.prototype.importRules=function(e,t,l,n,i){if(l){if(e.rules&&1<e.rules.length&&!this.headerTemplate){var l=t.querySelector(".e-btngroup-or"),o=t.querySelector(".e-btngroup-and");if(this.enableSeparateConnector&&t.previousElementSibling&&(l=t.previousElementSibling.querySelector(".e-btngroup-or"),o=t.previousElementSibling.querySelector(".e-btngroup-and")),l.disabled=!1,o.disabled=!1,this.enableSeparateConnector){for(var r=t.previousElementSibling;r&&!r.classList.contains("e-rule-container");){if(r.classList.contains("e-group-container")){r=r.querySelectorAll(".e-rule-container")[r.querySelectorAll(".e-rule-container").length-1];break}r=r.previousElementSibling}r&&r.classList.contains("e-rule-container")&&(s=r.id.replace(this.element.id+"_",""),"or"===this.getRule(s).condition?l.checked=!0:o.checked=!0)}else"or"===e.condition?l.checked=!0:o.checked=!0}else this.disableRuleCondition(t);var s;this.headerTemplate&&i&&(t=this.renderGroup(e,e.condition,this.element,e.not,i)),this.enableNotCondition&&!this.headerTemplate&&(s=t.querySelector(".e-qb-toggle"),e.not?N.addClass([s],"e-active-toggle"):N.removeClass([s],"e-active-toggle"))}else t=this.renderGroup(e,e.condition,t,n);e.rules&&0===e.rules.length&&this.headerTemplate&&(e.rules[0]={label:"",field:"",operator:"",type:"",value:""});var a=e.rules;if(!N.isNullOrUndefined(a))for(var u=0,d=a.length;u<d;u++){var p=Object.keys(a[u]);if(!N.isNullOrUndefined(a[u].rules)&&-1<p.indexOf("rules")&&0!==a[u].rules.length){if(this.element.querySelectorAll(".e-group-container").length>this.maxGroupCount)return null;t=this.renderGroup(a[u],a[u].condition,t,a[u].not),t=this.importRules(a[u],t,!0)}else this.renderRule(a[u],t);!N.isNullOrUndefined(a[u].rules)&&a[u].isLocked&&(p=t.querySelector(".e-rule-list").children[u].querySelector(".e-lock-grp-btn"),this.groupLock(p))}return t=(t=t&&N.closest(t,".e-rule-list"))&&N.closest(t,".e-group-container")},q.prototype.renderGroup=function(e,t,l,n,i){this.addGroupElement(!0,l,t,!1,n,i,e);var t=l.querySelectorAll(".e-group-container"),o=l.querySelector(".e-rule-list").children;if(this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isMiddleGroup){this.isMiddleGroup=!1,this.cloneGrpBtnClick=!1;var r=0,s=this.groupIndex+1;if(this.enableSeparateConnector)for(var a=0;a<s;a++)o[a].classList.contains("e-rule-container")&&(s++,r++);return o[this.groupIndex+r+1]}return this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isLastGroup?(this.isLastGroup=!1,this.cloneGrpBtnClick=!1,o[o.length-1]):t[t.length-1]},q.prototype.renderRule=function(e,t){-1<t.className.indexOf("e-group-container")?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},q.prototype.enableReadonly=function(){for(var e=this.element.querySelectorAll(".e-dropdownlist, .e-dropdowntree, .e-numerictextbox, .e-textbox, .e-datepicker, .e-multiselect .e-lib, .e-radio"),t=0;t<e.length;t++)e[t].classList.contains("e-dropdownlist")?N.getInstance(e[t],y.DropDownList).readonly=this.isReadonly:e[t].classList.contains("e-dropdowntree")?N.getComponent(e[t],"dropdowntree").readonly=this.isReadonly:e[t].classList.contains("e-numerictextbox")?N.getInstance(e[t],c.NumericTextBox).readonly=this.isReadonly:e[t].classList.contains("e-textbox")?N.getInstance(e[t],c.TextBox).readonly=this.isReadonly:e[t].classList.contains("e-datepicker")?N.getInstance(e[t],v.DatePicker).readonly=this.isReadonly:e[t].classList.contains("e-multiselect")?N.getInstance(e[t],y.MultiSelect).readonly=this.isReadonly:e[t].classList.contains("e-radio")&&!N.getInstance(e[t],L.RadioButton).checked&&(this.isReadonly?e[t].parentElement.style.display="none":e[t].parentElement.style.display="inherit");for(var l=this.element.querySelectorAll(".e-deletegroup"),n=this.element.querySelectorAll(".e-addrulegroup"),i=this.element.querySelectorAll(".e-removerule"),o=(!this.isReadonly&&this.ruleElem.classList.contains("e-readonly")&&this.ruleElem.classList.remove("e-readonly"),[l,n,i]),t=0;t<o.length;t++)o[t].forEach(function(e){e.classList.contains("e-readonly")?e.classList.remove("e-readonly"):e.classList.add("e-readonly")});this.enableBtnGroup()},q.prototype.enableBtnGroup=function(){var t=this,e=this.element.querySelectorAll(".e-btngroup-and-lbl, .e-btngroup-or-lbl, .e-qb-toggle"),l=!1;e.forEach(function(e){!e.classList.contains("e-qb-toggle")||e.classList.contains("e-active-toggle")||e.classList.contains("e-readonly")?e.classList.contains("e-qb-toggle")&&e.classList.contains("e-not-readonly")?e.classList.remove("e-not-readonly"):e.classList.contains("e-qb-toggle")&&e.classList.contains("e-readonly")?e.classList.remove("e-readonly"):e.classList.contains("e-active-toggle")?(e.classList.add("e-not-readonly"),l=!0):e.previousElementSibling.checked||e.classList.contains("e-readonly")?(e.classList.remove("e-readonly"),l?"AND"===e.textContent?e.classList.add("e-readonly-and"):e.classList.add("e-readonly-or"):("AND"===e.textContent&&t.isReadonly?(e.classList.remove("e-not"),e.classList.add("e-readonly-and")):(t.enableNotCondition&&e.classList.add("e-not"),e.classList.remove("e-readonly-and")),"OR"===e.textContent&&t.isReadonly?e.classList.add("e-readonly-or-not"):e.classList.remove("e-readonly-or-not"))):e.classList.contains("e-btn-disable")||e.classList.add("e-readonly"):(e.classList.add("e-readonly"),l=!1)})},q.prototype.isDateFunction=function(e){for(var t=["date","time","day","week","month","year","hour","minute","second","now","quarter","period","extract"],l=0,n=t.length;l<n;l++)if(-1<e.toLowerCase().indexOf(t[l]))return!0;return!1},q.prototype.getSqlString=function(e,t,l,n){var i=!1,o=(l||""===l?l+="(":i=!(l=""),e.condition);if(e.not&&(l+=i?n?this.l10n.getConstant("NOT").toUpperCase()+" (":"NOT (":n?" "+this.l10n.getConstant("NOT").toUpperCase()+" (":" NOT ("),e.rules)for(var r=0,s=e.rules.length;r<s;r++){if(e.rules[r].rules)l=this.getSqlString(e.rules[r],t,l,n),this.enableSeparateConnector&&(o=e.rules[r].condition);else{var a=e.rules[r],u="",d=(n?this.sqlOperators:this.operators)[a.operator];if(a.value instanceof Array)if(-1<a.operator.toString().indexOf("between")){var p=n?" "+this.l10n.getConstant("AND").toUpperCase()+" ":" AND ";"date"!==a.type||this.isDateFunction(a.value[0])?u+=a.value[0]+p+a.value[1]:u+='"'+a.value[0]+'"'+p+'"'+a.value[1]+'"'}else if("string"==typeof a.value[0]&&null!==a.value){u+='("'+a.value[0]+'"';for(var c=1,h=a.value.length;c<h;c++)u+=',"'+a.value[c]+'"';u+=")"}else u+="("+a.value+")";else-1<a.operator.toString().indexOf("startswith")?u+=a.value?'("'+a.value+'%")':"("+a.value+")":-1<a.operator.toString().indexOf("endswith")?u+=a.value?'("%'+a.value+'")':"("+a.value+")":-1<a.operator.toString().indexOf("contains")?u+=a.value?'("%'+a.value+'%")':"("+a.value+")":"number"===a.type||"boolean"==typeof a.value||null===a.value&&a.operator.toString().indexOf("empty")<-1?u+=a.value:-1<a.operator.toString().indexOf("empty")?u+='""':u+='"'+a.value+'"';-1<a.operator.toString().indexOf("null")?(t?a.field="`"+a.field+"`":-1<a.field.indexOf(" ")&&(a.field='"'+a.field+'"'),l+=a.field+" "+d):(p=d,"isempty"===a.operator?p="=":"isnotempty"===a.operator&&(p="!="),t?a.field="`"+a.field+"`":-1<a.field.indexOf(" ")&&(a.field='"'+a.field+'"'),l+=a.field+" "+p+" "+u),a.condition&&""!==a.condition&&(o=a.condition)}r!==s-1&&(a=e.rules[r],o=""===o||a&&""!==a.condition&&a.custom&&a.custom.isCustom?a.condition:o)&&(l+=" "+(o=(n?this.l10n.getConstant(o.toUpperCase()):o).toUpperCase())+" ")}return i||(l+=")"),e.not&&(l+=")"),l},q.prototype.setRulesFromSql=function(e,t){e=e.replace(/`/g,"");e=this.getRulesFromSql(e,t);this.setRules({condition:e.condition,not:e.not,rules:e.rules})},q.prototype.getRulesFromSql=function(e,t){this.parser=[],this.sqlParser(e,t),this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0);e=this.processParser(this.parser,this.rule,[0],t);return this.enableNotCondition?{condition:e.condition,not:e.not,rules:e.rules}:{condition:e.condition,rules:e.rules}},q.prototype.getSqlFromRules=function(e,t,l){return e=e||this.getValidRules(),e=this.getRuleCollection(e,!1),this.getSqlString(this.getValidRules(e),t,null,l).replace(/"/g,"'")},q.prototype.getParameterizedSql=function(e){var t;return this.moduleLoader.loadedModules.length?(e=e||this.getValidRules(),this.notify("query-library",{prop:"getParameterSql",onPropertyChange:!(t={sql:null}),value:{rule:e,obj:t}}),t.sql):(console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),null)},q.prototype.setParameterizedSql=function(e){var t;this.moduleLoader.loadedModules.length?(this.notify("query-library",{prop:"convertParamSqlToSql",onPropertyChange:!(t={sql:null}),value:{sql:e,obj:t}}),(e=t.sql)&&(e=e.replace(/`/g,""),t=this.getRulesFromSql(e),this.setRules({condition:t.condition,not:t.not,rules:t.rules}))):console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},q.prototype.getParameterizedNamedSql=function(e){var t;return this.moduleLoader.loadedModules.length?(e=e||this.getValidRules(),this.notify("query-library",{prop:"getNamedParameterSql",onPropertyChange:!(t={sql:null}),value:{rule:e,obj:t}}),t.sql):(console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),null)},q.prototype.setParameterizedNamedSql=function(e){var t;this.moduleLoader.loadedModules.length?(this.notify("query-library",{prop:"convertNamedParamSqlToSql",onPropertyChange:!(t={sql:null}),value:{sql:e,obj:t}}),(e=t.sql)&&(e=e.replace(/`/g,""),t=this.getRulesFromSql(e),this.setRules({condition:t.condition,not:t.not,rules:t.rules}))):console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},q.prototype.setMongoQuery=function(e,t){this.moduleLoader.loadedModules.length?(this.rule={condition:"and",not:!1,rules:[]},this.notify("query-library",{prop:"mongoParser",onPropertyChange:!1,value:{mongoQuery:JSON.parse(e),rule:this.rule,mongoLocale:t}})):console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},q.prototype.getMongoQuery=function(e){var t;return this.moduleLoader.loadedModules.length?(e=e||this.getValidRules(),this.notify("query-library",{prop:"getMongoFromRules",onPropertyChange:!(t={mongoQuery:null}),value:{rule:e,mongoQuery:"",obj:t}}),t.mongoQuery):(console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),"")},q.prototype.cloneRule=function(e,t,l){var e=this.getRule(e.replace(this.element.id+"_","")),n=this.showButtons.cloneRule;t=t.replace(this.element.id+"_",""),this.ruleIndex=l,this.cloneRuleBtnClick=!0,this.showButtons.cloneRule=!0,this.addRules([{label:e.label,field:e.field,type:e.type,operator:e.operator,value:e.value,condition:e.condition}],t),this.ruleIndex=-1,this.cloneRuleBtnClick=!1,this.showButtons.cloneRule=n},q.prototype.cloneGroup=function(e,t,l){t=t.replace(this.element.id+"_","");var t=this.getGroup(t),n=this.showButtons.cloneGroup;e=e.replace(this.element.id+"_",""),this.groupIndex=l,this.cloneGrpBtnClick=!0,this.showButtons.cloneGroup=!0,this.addGroups([{condition:t.condition,not:t.not,rules:t.rules}],e),this.groupIndex=-1,this.cloneGrpBtnClick=!1,this.showButtons.cloneGroup=n},q.prototype.lockRule=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);e=document.getElementById(e).querySelectorAll(".e-lock-rule-btn")[0];this.ruleLock(e)},q.prototype.lockGroup=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);e=document.getElementById(e).querySelectorAll(".e-lock-grp-btn")[0];this.groupLock(e)},q.prototype.sqlParser=function(e,t){for(var l,n=0;l=e.slice(n),n+=this.parseSqlStrings(l,t),""!==l;);return this.parser},q.prototype.parseSqlStrings=function(e,t){for(var l,n=["=","!=","<=",">=","<",">"],i=t?[this.l10n.getConstant("AND").toUpperCase(),this.l10n.getConstant("OR").toUpperCase(),this.l10n.getConstant("NOT").toUpperCase()]:["AND","OR","NOT"],o=t?[this.l10n.getConstant("In").toUpperCase(),this.l10n.getConstant("NotIn").toUpperCase(),this.l10n.getConstant("Like").toUpperCase(),this.l10n.getConstant("NotLike").toUpperCase(),this.l10n.getConstant("Between").toUpperCase(),this.l10n.getConstant("NotBetween").toUpperCase(),this.l10n.getConstant("IsNull").toUpperCase(),this.l10n.getConstant("IsNotNull").toUpperCase(),this.l10n.getConstant("IsEmpty").toUpperCase(),this.l10n.getConstant("IsNotEmpty").toUpperCase()]:["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN","IS NULL","IS NOT NULL","IS EMPTY","IS NOT EMPTY"],r=0,s=n.length;r<s;r++){var a=/^\w+$/.test(n[r])?"\\b":"";if(new RegExp("^("+n[r]+")"+a,"ig").exec(e))return this.parser.push(["Operators",n[r].toLowerCase()]),n[r].length}var u=this.parser[this.parser.length-1];if(!u||"Literal"!==u[0])for(r=0,s=i.length;r<s;r++)if(a=/^\w+$/.test(i[r])?"\\b":"",new RegExp("^("+i[r]+")"+a,"ig").exec(e))return this.parser.push(["Conditions",i[r].toLowerCase()]),i[r].length;for(r=0,s=o.length;r<s;r++)if(a=/^\w+$/.test(o[r])?"\\b":"",new RegExp("^("+o[r]+")"+a,"ig").exec(e))return this.parser.push(["SubOperators",o[r].toLowerCase()]),o[r].length;if(/^\(/.exec(e))return this.parser.push(["Left","("]),1;if(/^\)/.exec(e))return this.parser.push(["Right",")"]),1;if(/^(true|false)/.exec(e))return l=/^(true|false)/.exec(e)[0],this.parser.push(["String",l]),l.length;if(/^null/.exec(e))return l=/^null/.exec(e)[0],this.parser.push(["String",null]),l.length;if(/^`?([a-z_][a-z0-9_.\\[\]\\(\\)]{0,}(\\:(number|float|string|date|boolean))?)`?/i.exec(e))return l=/^`?([a-z_][a-z0-9_.\\[\]\\(\\)]{0,}(\\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",l]),l.length;if(this.checkLiteral()&&/^'?([a-z_][a-z0-9 _.\\[\]\\(\\)-]{0,}(\\:(number|float|string|date|boolean))?)'?/i.exec(e))return l=/^'?([a-z_][a-z0-9 _.\\[\]\\(\\)-]{0,}(\\:(number|float|string|date|boolean))?)'?/i.exec(e)[1],this.parser.push(["Literal",l]),l.length+2;if(this.checkNumberLiteral(e,t)){u=/^[0-9]+(\.[0-9]+)$/.exec(e);if(u)return l=u[0],this.parser.push(["Literal",l]),l.length}t=this.getSingleQuoteString(e);if(""!==t){if("("===(l=t)[l.length-2])for(var d=!1,p=l.length;p<e.length&&(l+=e[p],!(d=")"===e[p]||d)||"'"!==e[p]);p++);else e[l.length]&&")"!==e[l.length]&&!this.checkCondition(e,l)&&(l=this.combineSingleQuoteString(e,l));return this.parser.push(["String",l]),l.length}u=this.getDoubleQuoteString(e);return""!==u?(this.parser.push(["DoubleString",l=u]),l.length):/^\d*\.?\d+/.exec(e)?(l=/^\d*\.?\d+/.exec(e)[0],this.parser.push(["Number",l]),l.length):/^-?\d*\.?\d+/.exec(e)?(l=/^-?\d*\.?\d+/.exec(e)[0],this.parser.push(["Number",l]),l.length):1},q.prototype.getDoubleQuoteString=function(e){var t=e.indexOf('"');if(0===t){var l=e.indexOf('"',t+1);if(-1!==l)return e.substring(t,l+1)}return""},q.prototype.checkCondition=function(e,t){return"AND"===e.slice(t.length+1,t.length+4)||"OR"===e.slice(t.length+1,t.length+3)},q.prototype.getSingleQuoteString=function(e,t){var l=e.indexOf("'");if(-1!==l&&t||0===l&&!t){t=e.indexOf("'",l+1);if(-1!==t)return e.substring(l,t+1)}return""},q.prototype.combineSingleQuoteString=function(e,t){var l;return e[t.length]&&")"!==e[t.length]&&!this.checkCondition(e,t)&&","!==e[t.length]&&(l=t.substring(0,t.length-1),l=e.replace(l,""),""!==(l=this.getSingleQuoteString(l,!0)))&&(l=l.substring(1,l.length),t=this.combineSingleQuoteString(e,t+=l)),t},q.prototype.checkLiteral=function(){var e,t,l=this.parser[this.parser.length-1];return!(l&&(e=this.parser[this.parser.length-2],t=this.parser[this.parser.length-3],"Left"!==l[0]||!e||"Conditions"!==e[0]))||!!("Conditions"===l[0]&&t&&t[1].indexOf("between")<0)},q.prototype.checkNumberLiteral=function(e,t){var l=this.parser[this.parser.length-1];if(!l)return!0;if(/^[0-9]+(?:\.[0-9]+)$/.exec(e)){var e=this.parser[this.parser.length-2],n=this.parser[this.parser.length-3];if("Left"===l[0]&&e&&"Conditions"===e[0])return!0;e=t?this.l10n.getConstant("Between").toLowerCase():"between";if("Conditions"===l[0]&&n&&n[1].indexOf(e)<0)return!0}return!1},q.prototype.getOperator=function(e,t,l){if(l){for(var n=Object.keys(this.sqlOperators),i=0;i<n.length;i++)if(this.sqlOperators[n[i]]===t.toUpperCase())return e&&0===e.indexOf("%")&&"%"===e[e.length-1]?"NOT LIKE"===t.toUpperCase()?"notcontains":"contains":e&&0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"NOT LIKE"===t.toUpperCase()?"notstartswith":"startswith":e&&0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"NOT LIKE"===t.toUpperCase()?"notendswith":"endswith":n[i];return null}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{"=":"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"}[""+t]},q.prototype.getTypeFromColumn=function(e){e=this.getColumn(e.field);return N.isNullOrUndefined(e)?null:e.type},q.prototype.getLabelFromColumn=function(e){var t="",l=0;if(""===this.separator)return this.getColumn(e).label;for(var n=e.split(this.separator),i=0;i<n.length;i++)t+=this.getLabelFromField(n,i+1),++l<n.length&&(t+=this.separator);return t},q.prototype.getLabelFromField=function(e,t){for(var l="",n=0,i=0;i<t;i++)l+=e[i],++n<t&&(l+=this.separator);return this.getColumn(l).label},q.prototype.processParser=function(e,t,l,n){for(var i,o,r,s,a,u,d,p,c=[],h=[],g=!1,m=!1,f=0,y=e.length;f<y;f++)if("Literal"===e[f][0]){var v=this.getColumn(e[f][1]),b={label:v&&v.label?v.label:e[f][1],field:e[f][1]};if("SubOperators"===e[f+1][0]){for(-1<e[f+1][1].indexOf("null")||-1<e[f+1][1].indexOf("empty")?(b.operator=this.getOperator(" ",e[f+1][1],n),b.value=null,b.type=this.getTypeFromColumn(b)):(v=e[f+3][1]&&e[f+3][1].replace(/'/g,""),b.operator=this.getOperator(v,e[f+1][1],n)),p=e[f+1][1],o=y,n&&"contains"===b.operator||"startswith"===b.operator||"endswith"===b.operator?p="like":n&&"notcontains"===b.operator||"notstartswith"===b.operator||"notendswith"===b.operator?p="not like":n&&(p=b.operator),i=i=++f+1;i<o;i++)if(p.indexOf("between")<0&&"Left"===e[i][0])g=!0;else{if("Right"===e[i][0]&&g){f=i,g=!1;break}if(-1<p.indexOf("null")||-1<p.indexOf("empty"))break;if(-1<p.indexOf("like")&&"String"===e[i][0]){var C=e[i][1];C=(C=e[i][1]&&"'"===e[i][1][0]?e[i][1].substring(1,e[i][1].length-1):C)?C.replace(/%/g,""):e[i][1],b.value=C,b.type="string"}else{if(-1<p.indexOf("between")&&("Literal"===e[i][0]||"Left"===e[i][0]))break;"Number"===e[i][0]?c.push(Number(e[i][1])):"String"===e[i][0]&&(C=e[i][1],e[i][1]&&"'"===e[i][1][0]&&(C=e[i][1].substring(1,e[i][1].length-1)),h.push(C))}b.type=this.getTypeFromColumn(b)}p.indexOf("like")<0&&("Number"===e[i-1][0]?(b.value=c,b.type="number"):"String"===e[i-1][0]?(b.value=h,b.type="string"):-1<p.indexOf("between")&&"Conditions"===e[i-1][0]&&(0!==h.length?(b.value=h,b.type="string"):(b.value=c,b.type="number")),c=[],h=[],b.type=this.getTypeFromColumn(b)),this.enableSeparateConnector&&"Conditions"===e[f+1][0]&&(b.condition=e[f+1][1])}else"Operators"===e[f+1][0]&&(b.operator=this.getOperator(e[f+2][1],e[f+1][1],n),"equal"===b.operator&&"String"===e[f+2][0]&&"''"===e[f+2][1]?b.operator="isempty":"notequal"===b.operator&&"String"===e[f+2][0]&&"''"===e[f+2][1]&&(b.operator="isnotempty"),"Number"===e[f+2][0]?(b.type="number",b.value=Number(e[f+2][1])):(b.type="string",(C=e[f+2][1])&&"'"===C[0]&&(C=C.substring(1,C.length-1)),b.value=C),this.enableSeparateConnector&&"Conditions"===e[f+3][0]&&(b.condition=e[f+3][1]),b.type=this.getTypeFromColumn(b));t.rules.push(b)}else if("Left"===e[f][0]){if("Left"===e[0][0]||!("not"===e[f-1][1]||n&&this.l10n.getConstant("NOT").toLowerCase()===e[f-1][1])){for(this.parser=e.splice(f+1,y-(f+1)),v=this.enableNotCondition?{condition:"and",rules:[],not:!1}:{condition:"and",rules:[]},s=t.rules.length,r=d=0;r<s;r++)t.rules[r].rules&&d++;return l.push(d),t.rules.push(v),v=this.processParser(this.parser,v,l,n),t}m=!0}else if("Conditions"!==e[f][0]||this.enableSeparateConnector){if("Right"===e[f][0]){if(!m||"Right"!==e[f+1][0]){for(this.parser=e.splice(f+1,y-(f+1)),l.pop(),t=this.rule,u=l.length,a=0;a<u;a++)t=this.findGroupByIdx(l[a],t,0===a);return this.processParser(this.parser,t,l,n)}m=!1}}else"not"===e[f][1]||n&&this.l10n.getConstant("NOT").toLowerCase()===e[f][1]?t.not=!0:t.condition=e[f][1];return t},q.prototype.groupClone=function(e){var t=e.closest(".e-rule-list").closest(".e-group-container"),l=e.id.replace(this.element.id+"_",""),t=t.id.replace(this.element.id+"_",""),l=this.getGroup(l);this.groupIndex=Array.prototype.indexOf.call(e.closest(".e-rule-list").children,e.closest(".e-group-container")),this.addGroups([{condition:l.condition,not:l.not,rules:l.rules}],t),this.groupIndex=-1},q.prototype.ruleClone=function(e){for(var t=N.closest(e,".e-rule-container"),l=e.closest(".e-rule-list").closest(".e-group-container"),e=this.getRule(e),n=l.id.replace(this.element.id+"_",""),i=l.querySelectorAll(".e-rule-container"),o=0,r=i.length;o<r;o++)t.id===i[o].id&&(this.ruleIndex=o);this.enableSeparateConnector?this.addRules([{label:e.label,field:e.field,type:e.type,operator:e.operator,value:e.value,condition:e.condition}],n):this.addRules([{label:e.label,field:e.field,type:e.type,operator:e.operator,value:e.value}],n),this.ruleIndex=-1},q.prototype.ruleLock=function(e){var t=N.closest(e,".e-rule-container"),l=this.getRule(t.id.replace(this.element.id+"_",""));t.classList.contains("e-disable")?(l.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==t.id}),t.classList.remove("e-disable"),this.disableRuleControls(e,t,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockRule"))):(l.isLocked=!0,this.lockItems.indexOf(t.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,t.id),t.classList.add("e-disable"),this.disableRuleControls(e,t,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockRule")))},q.prototype.groupLock=function(e){var t,l=N.closest(e,".e-group-container"),n=this.getGroup(l.id.replace(this.element.id+"_","")),i=-1<l.id.indexOf("group0");l.classList.contains("e-disable")?(i?((t={}).condition=n.condition,t.not=n.not,t.isLocked=!1,this.setProperties({rule:t},!0)):n.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==l.id}),l.classList.remove("e-disable"),this.disableHeaderControls(e,l,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockGroup")),this.updateLockItems()):(i?((t={}).condition=n.condition,t.not=n.not,t.isLocked=!0,this.setProperties({rule:t},!0)):n.isLocked=!0,this.lockItems.indexOf(l.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,l.id),l.classList.add("e-disable"),this.disableHeaderControls(e,l,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockGroup")))},q.prototype.updateLockItems=function(){for(var e,t=0;t<this.lockItems.length;t++)2<this.lockItems[t].split("_").length?(e=this.element.querySelector("#"+this.lockItems[t]).querySelector(".e-lock-rule-btn"),N.closest(e,".e-rule-container").classList.contains("e-disable")||this.ruleLock(e)):(e=this.element.querySelector("#"+this.lockItems[t]).querySelector(".e-lock-grp-btn"),N.closest(e,".e-group-container").classList.contains("e-disable")||this.groupLock(e))},q.prototype.disableHeaderControls=function(e,t,l){for(var n=t.querySelectorAll(".e-btngroup-and"),i=t.querySelectorAll(".e-btngroup-or"),o=t.querySelectorAll(".e-qb-toggle"),r=t.querySelectorAll(".e-add-btn"),s=t.querySelectorAll(".e-deletegroup"),a=t.querySelectorAll(".e-lock-grp-btn"),u=t.querySelectorAll(".e-clone-grp-btn"),d=t.querySelectorAll(".e-group-container"),p=t.querySelectorAll(".e-add-condition-btn"),c=t.querySelectorAll(".e-add-group-btn"),h=0;h<n.length;h++)l?(d[h]&&d[h].classList.contains("e-disable")&&d[h].classList.add("e-disable"),n[h].disabled=!0,i[h].disabled=!0,r[h]&&(r[h].disabled=!0),p[h]&&(p[h].disabled=!0),c[h]&&(c[h].disabled=!0),o[h]&&(o[h].disabled=!0),s[h]&&(s[h].disabled=!0),u[h]&&(u[h].disabled=!0),n[h].parentElement.classList.add("e-disabled"),a[h]&&a[h]!==e&&(a[h].disabled=!0,a[h].children[0].classList.remove("e-unlock"),a[h].children[0].classList.add("e-lock"))):(d[h]&&d[h].classList.remove("e-disable"),n[h].disabled=!1,i[h].disabled=!1,r[h]&&(r[h].disabled=!1),p[h]&&(p[h].disabled=!1),c[h]&&(c[h].disabled=!1),a[h]&&(a[h].disabled=!1),o[h]&&(o[h].disabled=!1),s[h]&&(s[h].disabled=!1),u[h]&&(u[h].disabled=!1),n[h].parentElement.classList.remove("e-disabled"),a[h]&&a[h].children[0].classList.remove("e-lock"),a[h]&&a[h].children[0].classList.add("e-unlock"));this.disableRuleControls(e,t,l)},q.prototype.disableRuleControls=function(e,t,l){for(var n=t.querySelectorAll(".e-control.e-dropdownlist"),i=t.querySelectorAll(".e-control.e-numerictextbox"),o=t.querySelectorAll(".e-control.e-textbox"),r=t.querySelectorAll(".e-control.e-datepicker"),s=t.querySelectorAll(".e-control.e-checkbox"),a=t.querySelectorAll(".e-control.e-radio"),u=t.querySelectorAll(".e-control.e-multiselect"),d=t.querySelectorAll(".e-rule-delete"),p=t.querySelectorAll(".e-lock-rule"),c=t.querySelectorAll(".e-clone-rule"),h=t.querySelectorAll(".e-rule-container"),g=0;g<d.length;g++)l?(h[g]&&h[g].classList.contains("e-disable")&&h[g].classList.add("e-disable"),d[g].disabled=!0,c[g]&&(c[g].disabled=!0),p[g]!==e&&(p[g].disabled=!0,p[g].children[0].classList.remove("e-unlock"),p[g].children[0].classList.add("e-lock"))):(h[g]&&h[g].classList.remove("e-disable"),c[g]&&(c[g].disabled=!1),d[g].disabled=!1,p[g].disabled=!1,p[g].children[0].classList.remove("e-lock"),p[g].children[0].classList.add("e-unlock"));for(g=0;g<n.length;g++)N.getComponent(n[g],"dropdownlist").enabled=!l;for(g=0;g<i.length;g++)N.getComponent(i[g],"numerictextbox").enabled=!l;for(g=0;g<o.length;g++)N.getComponent(o[g],"textbox").enabled=!l;for(g=0;g<r.length;g++)N.getComponent(r[g],"datepicker").enabled=!l;for(g=0;g<s.length;g++)N.getComponent(s[g],"checkbox").disabled=!!l;for(g=0;g<a.length;g++)N.getComponent(a[g],"radio").disabled=!!l;for(g=0;g<u.length;g++)N.getComponent(u[g],"multiselect").enabled=!l},i([N.Event()],q.prototype,"created",void 0),i([N.Event()],q.prototype,"actionBegin",void 0),i([N.Event()],q.prototype,"beforeChange",void 0),i([N.Event()],q.prototype,"change",void 0),i([N.Event()],q.prototype,"dataBound",void 0),i([N.Event()],q.prototype,"ruleChange",void 0),i([N.Event()],q.prototype,"dragStart",void 0),i([N.Event()],q.prototype,"drag",void 0),i([N.Event()],q.prototype,"drop",void 0),i([N.Complex({},C)],q.prototype,"showButtons",void 0),i([N.Property(!1)],q.prototype,"summaryView",void 0),i([N.Property(!1)],q.prototype,"allowValidation",void 0),i([N.Property("Default")],q.prototype,"fieldMode",void 0),i([N.Property([])],q.prototype,"columns",void 0),i([N.Property(null)],q.prototype,"fieldModel",void 0),i([N.Property(null)],q.prototype,"operatorModel",void 0),i([N.Property(null)],q.prototype,"valueModel",void 0),i([N.Property()],q.prototype,"headerTemplate",void 0),i([N.Property("")],q.prototype,"cssClass",void 0),i([N.Property([])],q.prototype,"dataSource",void 0),i([N.Property("Horizontal")],q.prototype,"displayMode",void 0),i([N.Property(!1)],q.prototype,"enablePersistence",void 0),i([N.Property("Default")],q.prototype,"sortDirection",void 0),i([N.Property(5)],q.prototype,"maxGroupCount",void 0),i([N.Property("auto")],q.prototype,"height",void 0),i([N.Property("auto")],q.prototype,"width",void 0),i([N.Property(!1)],q.prototype,"matchCase",void 0),i([N.Property(0)],q.prototype,"immediateModeDelay",void 0),i([N.Property(!1)],q.prototype,"enableNotCondition",void 0),i([N.Property(!1)],q.prototype,"readonly",void 0),i([N.Property(!0)],q.prototype,"addRuleToNewGroups",void 0),i([N.Property(!1)],q.prototype,"autoSelectField",void 0),i([N.Property(!0)],q.prototype,"autoSelectOperator",void 0),i([N.Property("")],q.prototype,"separator",void 0),i([N.Property(!1)],q.prototype,"enableSeparateConnector",void 0),i([N.Complex({condition:"and",rules:[]},u)],q.prototype,"rule",void 0),i([N.Property(!1)],q.prototype,"allowDragAndDrop",void 0);var x,l=i([N.NotifyPropertyChanges],q);function q(e,t){e=x.call(this,e,t)||this;return e.isReadonly=!0,e.fields={text:"label",value:"field"},e.updatedRule={not:!1,condition:"and",isLocked:!1},e.isLocale=!1,e.isRefreshed=!1,e.isNotified=!1,e.isAddSuccess=!1,e.isNotValueChange=!1,e.isFieldChange=!1,e.isFieldClose=!1,e.isDestroy=!1,e.isGetNestedData=!1,e.isCustomOprCols=[],e.groupCounter=0,e.lockItems=[],e.groupIndex=-1,e.ruleIndex=-1,e.isLastGroup=!1,e.cloneGrpBtnClick=!1,e.isMiddleGroup=!1,e.cloneRuleBtnClick=!1,e.isValueEmpty=!1,y.MultiSelect.Inject(y.CheckBoxSelection),e}E.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},E.prototype.addEventListener=function(){this.parent.isDestroyed||(this.parent.on("query-library",this.queryLibrary,this),this.parent.on("destroyed",this.destroy,this))},E.prototype.removeEventListener=function(){this.parent.off("query-library",this.queryLibrary),this.parent.off("destroyed",this.destroy)},E.prototype.queryLibrary=function(e){switch(e.prop){case"getMongoFromRules":e.value.obj.mongoQuery=this.getMongoFromRules(e.value.rule,e.value.mongoQuery);break;case"mongoParser":this.mongoParser(e.value.mongoQuery,e.value.rule,e.value.mongoLocale);break;case"getParameterSql":e.value.obj.sql=this.getParameterSql(e.value.rule);break;case"getNamedParameterSql":e.value.obj.sql=this.getNamedParameterSql(e.value.rule);break;case"convertParamSqlToSql":e.value.obj.sql=this.convertParamSqlToSql(e.value.sql);break;case"convertNamedParamSqlToSql":e.value.obj.sql=this.convertNamedParamSqlToSql(e.value.sql)}},E.prototype.getMongoFromRules=function(e,t){return t="{",t="or"===e.condition?this.convertMongoQuery(e.rules,t+='"$or":[')+"]":this.convertMongoQuery(e.rules,t+='"$and":[')+"]",t+="}"},E.prototype.getOperatorFromMongoOperator=function(e){var t;switch(e){case"$ne":t="notequal";break;case"$gt":t="greaterthan";break;case"$gte":t="greaterthanorequal";break;case"$lt":t="lessthan";break;case"$lte":t="lessthanorequal";break;case"$nin":t="notin"}return t},E.prototype.convertMongoQuery=function(i,o){var r=this,s=0;return i.forEach(function(l){s++,o+="{",void 0!==l.rules&&(o=("or"===l.condition?o+=' "$or":[':o+=' "$and":[',r.convertMongoQuery(l.rules,o)+"]"));var e,t="string"===l.type&&"in"!==l.operator&&"notin"!==l.operator&&l.value&&""!==l.value.trim()?l.value.replace(/'/g,"\\"):"",n=("string"!==l.type||"in"!==l.operator&&"notin"!==l.operator||!l.value||1!==l.value.length||(t=l.value[0].replace(/'/g,"\\")),l.field?l.field.substring(0):"");switch(l.operator){case"contains":o+='"'+n+'":{"$regex":"'+t+'"}';break;case"notcontains":o+='"'+n+'":{"$not":{"$regex":"'+l.value+'"}}';break;case"startswith":o+='"'+n+'":{"$regex":"^'+t+'"}';break;case"notstartswith":o+='"'+n+'":{"$not":{"$regex":"^'+l.value+'"}}';break;case"endswith":o+='"'+n+'":{"$regex":"'+t+'$"}';break;case"notendswith":o+='"'+n+'":{"$not":{"$regex":"'+l.value+'$"}}';break;case"isnull":o+='"'+n+'": null';break;case"isnotnull":o+='"'+n+'":{"$ne": null}';break;case"isempty":o+='"'+n+'": ""';break;case"isnotempty":o+='"'+n+'":{"$ne": ""}';break;case"equal":"string"===l.type?o+='"'+n+'":"'+t+'"':"date"===l.type?o+='"'+n+'":"'+l.value+'"':(l.type,o+='"'+n+'":'+l.value);break;case"notequal":"string"===l.type?o+='"'+n+'":{"$ne":"'+t+'"}':"date"===l.type?o+='"'+n+'":{"$ne":"'+l.value+'"}':o+='"'+n+'":{"$ne":'+l.value+"}";break;case"in":"string"===l.type?1<l.value.length?(e=(e=l.value.map(function(e,t){return t<l.value.length?'"'+e+'"':""}).toString()).endsWith(",")?e.substring(0,e.length-1):e,o+='"'+n+'": { "$in": ['+e+"]}"):o+='"'+n+'": { "$in": ["'+t+'"]}':"number"===l.type&&(1<l.value.length?o+='"'+n+'": { "$in": ['+l.value.toString()+"]}":o+='"'+n+'": { "$in": ['+l.value+"]}");break;case"notin":"string"===l.type?1<l.value.length?(e=(e=l.value.map(function(e,t){return t<l.value.length?'"'+e+'"':""}).toString()).endsWith(",")?e.substring(0,e.length-1):e,o+='"'+n+'": { "$nin": ['+e+"]}"):o+='"'+n+'": { "$nin": ["'+t+'"]}':"number"===l.type&&(1<l.value.length?o+='"'+n+'": { "$nin": ['+l.value.toString()+"]}":o+='"'+n+'": { "$nin": ['+l.value+"]}");break;case"greaterthan":"number"===l.type?o+='"'+n+'": { "$gt": '+l.value+"}":o+='"'+n+'": { "$gt": "'+l.value+'"}';break;case"greaterthanorequal":"number"===l.type?o+='"'+n+'": { "$gte": '+l.value+"}":o+='"'+n+'": { "$gte": "'+l.value+'"}';break;case"between":"number"===l.type?o+='"'+n+'": {"$gte":'+l.value[0]+', "$lte":'+l.value[1]+"}":o+='"'+n+'": {"$gte": "'+l.value[0]+'", "$lte": "'+l.value[1]+'"}';break;case"notbetween":"number"===l.type?o+='"$or":[{"'+n+'": {"$lt":'+l.value[0]+'}}, {"'+n+'": {"$gt":'+l.value[1]+"}}]":o+='"$or":[{"'+n+'": {"$lt": "'+l.value[0]+'"}}, {"'+n+'": {"$gt": "'+l.value[1]+'"}}]';break;case"lessthan":"number"===l.type?o+='"'+n+'": { "$lt": '+l.value+"}":o+='"'+n+'": { "$lt": "'+l.value+'"}';break;case"lessthanorequal":"number"===l.type?o+='"'+n+'": { "$lte": '+l.value+"}":o+='"'+n+'": { "$lte": "'+l.value+'"}'}o+="}",i.length!==s&&(o+=",")}),o},E.prototype.mongoParser=function(e,t,l){var n;-1<Object.keys(e).indexOf("$and")?(n=e.$and,t.condition="and"):-1<Object.keys(e).indexOf("$or")&&(n=e.$or,t.condition="or"),t.rules=[],this.mongoRecursion(n,t.rules,l)},E.prototype.mongoRecursion=function(e,t,l){for(var n,i,o,r,s,a,u,d,p=0,c=e.length;p<c;p++){var h=[],g=[],m=Object.keys(e[p])[0],f=e[p][m];if("$and"===m)a=this.parent.enableNotCondition?{condition:m.replace("$",""),rules:[],not:!1}:{condition:m.replace("$",""),rules:[]},t.push(a),this.mongoRecursion(e[p][m],t[t.length-1].rules,l);else if("$or"===m){var y,v,b,C,S,x=void 0;Array.isArray(f)&&2===f.length&&(C=f[(S=Object.keys(f))[0]],S=f[S[1]],"object"==typeof C)&&(y=Object.keys(C)[0],b=Object.keys(C[Object.keys(C)[0]])[0],v=Object.keys(S[Object.keys(S)[0]])[0],"$lt"===b)&&"$gt"===v&&(C=C[y][b],b=S[y][v],t.push(u={field:y,label:y,value:d=[C,b],operator:n="notbetween",type:i="number"==typeof C?"number":"date"}),x=!0),x||(a=this.parent.enableNotCondition?{condition:m.replace("$",""),rules:[],not:!1}:{condition:m.replace("$",""),rules:[]},t.push(a),this.mongoRecursion(e[p][m],t[t.length-1].rules,l))}else{if(null===(f=e[p][m])&&(n="isnull"),"boolean"==typeof f&&(n="equal",i="boolean",d=f),"number"==typeof f)d=f,i="number",n="equal";else if("object"==typeof f&&null!==f)for(var q=Object.keys(f),E=0;E<q.length;E++)r=q[E],o=f[q[E]],"$ne"===r&&N.isNullOrUndefined(o)&&(n="isnotnull",d=null),"$ne"===r&&"boolean"==typeof o&&(n="notequal",d=o,i="boolean"),2<=q.length&&q[E]?("object"==typeof o?(n="notbetween",m=Object.keys(o)[0],s=[Object.keys(o[m])[0]],h.push(o[m][s]),i="number"):(n="between",h.push(o)),"number"==typeof o&&(i="number")):"object"==typeof o&&null!==o?"$not"===r&&"$regex"===Object.keys(o)[0]?d=-1<o.$regex.indexOf("^")?(n="notstartswith",o.$regex.replace("^","")):-1<o.$regex.indexOf("$")?(n="notendswith",o.$regex.replace("$","")):(n="notcontains",o.$regex):(n="$in"===r?"in":"notin",i="number"==typeof(g=o)[0]?"number":"string"):"number"==typeof o&&(n=this.getOperatorFromMongoOperator(r),i="number",d=o),"string"==typeof o&&("$regex"===r&&(n="contains",d=o,i="string"),"$ne"===r&&(null!==o&&0<o.length&&isNaN(Date.parse(o))?(n="notequal",d=o):N.isNullOrUndefined(o)?(n="isnotnull",d=o):""===o&&(n="isnotempty",d=o),i="string"),-1<o.indexOf("^")&&(n="startswith",d=o.replace("^",""),i="string"),-1<o.indexOf("$")&&"$not"!==r&&(n="endswith",d=o.replace("$",""),i="string"),isNaN(Date.parse(o))||(n=n||this.getOperatorFromMongoOperator(r),i="date",d=o));else f&&"string"==typeof f&&!isNaN(Date.parse(f))?(n="equal",d=f,i="date"):"string"==typeof f&&""!==f&&"true"!==f&&"false"!==f?(n="equal",d=f,i="string"):"string"==typeof f&&""===f&&(n="isempty",d=f,i="string");u=h&&1<h.length?{field:m,label:m,value:h,operator:n,type:i}:g&&1<g.length?{field:m,label:m,value:g,operator:n,type:i}:{field:m,label:m,value:d,operator:n,type:i},t.push(u),n=""}}},E.prototype.convertParamSqlToSql=function(e){for(var t=e.sql,l=e.params,n=t.split("?"),i=n[0],o=0;o<l.length;o++)i+="string"==typeof l[o]?"'"+l[o]+"'"+n[o+1]:l[o]+n[o+1];return i=(i=2<=i.length&&"("===i[0]&&")"===i[i.length-1]?i.slice(1,-1):i).replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},E.prototype.convertNamedParamSqlToSql=function(e){var t=e.sql,l=e.params,n=t;return Object.keys(l).forEach(function(e){var t=l[e];n=n.replace(e=":"+e,"string"==typeof t?"'"+t+"'":String(t))}),n=(n=2<=n.length&&"("===n[0]&&")"===n[n.length-1]?n.slice(1,-1):n).replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},E.prototype.getParameterSql=function(e){var e=N.extend({},e,null,!0),t=this.updateRuleValue(e,!1);return this.getParameterSQLVal(this.parent.getSqlFromRules(e),t.ruleVal)},E.prototype.getNamedParameterSql=function(e){var e=N.extend({},e,null,!0),t=this.updateRuleValue(e,!0);return this.getNamedParameterSQLVal(this.parent.getSqlFromRules(e),t.namedRuleVal)},E.prototype.getParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},E.prototype.getNamedParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},E.prototype.updateRuleValue=function(e,t){return this.updateValue(e.rules,t,[],{},[])},E.prototype.updateValue=function(e,t,l,n,i){if(!N.isNullOrUndefined(e))for(var o=0;o<e.length;o++)if(e[o].rules)l=(a=this.updateValue(e[o].rules,t,l,n,i)).ruleVal,n=a.namedRuleVal;else{var r=void 0;if(e[o].value instanceof Array)for(var s=0;s<e[o].value.length;s++)t&&(r=this.getNamedParameter(e[o].field,i)),N.isNullOrUndefined(e[o].value[s])||("string"!==e[o].type&&e[o].type,t?n[r]=e[o].value[s]:l.push(e[o].value[s])),e[o].value[s]=t?":"+r:"?";else if(t&&(r=this.getNamedParameter(e[o].field,i)),e[o].operator.indexOf("null")<1&&("string"!==e[o].type||"string"===e[o].type&&(""!==e[o].value||0===e[o].value))){if("string"===e[o].type||"date"===e[o].type)if(e[o].operator.indexOf("empty")<1){var a=e[o].value.toString();switch(e[o].operator){case"startswith":case"notstartswith":a+="%";break;case"endswith":case"notendswith":a="%"+a;break;case"contains":case"notcontains":a="%"+a+"%"}t?n[r]=a:l.push(a)}else t?n[r]="":l.push(""),"isempty"===e[o].operator?e[o].operator="equal":e[o].operator="notequal";else N.isNullOrUndefined(e[o].value)||(t?n[r]=e[o].value:l.push(e[o].value));e[o].value=t?":"+r:"?"}}return{ruleVal:l,namedRuleVal:n}},E.prototype.getNamedParameter=function(e,t){var l=null;if(0<t.length)for(var n=t.length-1;0<=n;n--){var i=t[n];if(-1<i.indexOf(e)){l=e+"_"+(parseInt(i.split("_")[1],10)+1);t.push(l);break}}return l||t.push(l=e+"_1"),l},E.prototype.getModuleName=function(){return"query-library"};i=E;function E(e){this.parent=e,this.addEventListener()}e.Columns=o,e.QueryBuilder=l,e.QueryLibrary=i,e.Rule=u,e.ShowButtons=C,e.Value=g,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syncfusion/ej2-base"),require("@syncfusion/ej2-buttons"),require("@syncfusion/ej2-dropdowns"),require("@syncfusion/ej2-data"),require("@syncfusion/ej2-inputs"),require("@syncfusion/ej2-calendars"),require("@syncfusion/ej2-splitbuttons"),require("@syncfusion/ej2-popups")):"function"==typeof define&&define.amd?define(["exports","@syncfusion/ej2-base","@syncfusion/ej2-buttons","@syncfusion/ej2-dropdowns","@syncfusion/ej2-data","@syncfusion/ej2-inputs","@syncfusion/ej2-calendars","@syncfusion/ej2-splitbuttons","@syncfusion/ej2-popups"],t):t((e=e||self).ej={},e.ej2Base,e.ej2Buttons,e.ej2Dropdowns,e.ej2Data,e.ej2Inputs,e.ej2Calendars,e.ej2Splitbuttons,e.ej2Popups)}(this,function(e,L,N,y,h,c,v,R,s){"use strict";n=function(e,t){return(n=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])}))(e,t)};var n,t,l=function(e,t){function l(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(l.prototype=t.prototype,new l)},b=function(){return(b=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var o in t=arguments[l])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=function(e,t,l,n){var o,i=arguments.length,r=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,l):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,l,n);else for(var s=e.length-1;0<=s;s--)(o=e[s])&&(r=(i<3?o(r):3<i?o(t,l,r):o(t,l))||r);return 3<i&&r&&Object.defineProperty(t,l,r),r},i=(t=L.ChildProperty,l(r,t),o([L.Property(null)],r.prototype,"field",void 0),o([L.Property(null)],r.prototype,"label",void 0),o([L.Property(null)],r.prototype,"type",void 0),o([L.Property(null)],r.prototype,"values",void 0),o([L.Property(null)],r.prototype,"operators",void 0),o([L.Property()],r.prototype,"ruleTemplate",void 0),o([L.Property(null)],r.prototype,"template",void 0),o([L.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],r.prototype,"validation",void 0),o([L.Property(null)],r.prototype,"format",void 0),o([L.Property(null)],r.prototype,"step",void 0),o([L.Property(null)],r.prototype,"value",void 0),o([L.Property(null)],r.prototype,"category",void 0),o([L.Property(null)],r.prototype,"columns",void 0),r);function r(){return null!==t&&t.apply(this,arguments)||this}a=L.ChildProperty,l(d,a),o([L.Property(null)],d.prototype,"condition",void 0),o([L.Collection([],d)],d.prototype,"rules",void 0),o([L.Property(null)],d.prototype,"field",void 0),o([L.Property(null)],d.prototype,"label",void 0),o([L.Property(null)],d.prototype,"type",void 0),o([L.Property(null)],d.prototype,"operator",void 0),o([L.Property(null)],d.prototype,"value",void 0),o([L.Property(!1)],d.prototype,"not",void 0),o([L.Property(null)],d.prototype,"isLocked",void 0);var a,u=d;function d(){return null!==a&&a.apply(this,arguments)||this}p=L.ChildProperty,l(m,p),o([L.Property(null)],m.prototype,"numericTextBoxModel",void 0),o([L.Property(null)],m.prototype,"multiSelectModel",void 0),o([L.Property(null)],m.prototype,"datePickerModel",void 0),o([L.Property(null)],m.prototype,"textBoxModel",void 0),o([L.Property(null)],m.prototype,"radioButtonModel",void 0);var p,g=m;function m(){return null!==p&&p.apply(this,arguments)||this}f=L.ChildProperty,l(S,f),o([L.Property(!1)],S.prototype,"cloneRule",void 0),o([L.Property(!1)],S.prototype,"cloneGroup",void 0),o([L.Property(!1)],S.prototype,"lockRule",void 0),o([L.Property(!1)],S.prototype,"lockGroup",void 0),o([L.Property(!0)],S.prototype,"ruleDelete",void 0),o([L.Property(!0)],S.prototype,"groupInsert",void 0),o([L.Property(!0)],S.prototype,"groupDelete",void 0);var f,C=S;function S(){return null!==f&&f.apply(this,arguments)||this}x=L.Component,l(q,x),q.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},q.prototype.reset=function(){this.isImportRules=!1;for(var e,t,l,n=this.element.querySelector(".e-group-body"),o=this.element.querySelectorAll("input.e-control"),i=0,r=o.length;i<r;i++)-1<o[i].className.indexOf("e-tooltip")?L.getComponent(o[i],"tooltip").destroy():-1<o[i].parentElement.className.indexOf("e-tooltip")&&L.getComponent(o[i].parentElement,"tooltip").destroy();n?n.innerHTML="":(e=this.createElement("div",{attrs:{class:"e-group-container"}}),t=this.createElement("div",{attrs:{class:"e-group-header"}}),l=this.createElement("div",{attrs:{class:"e-group-body"}}),e.appendChild(t).appendChild(l),this.element.appendChild(e),n=this.element.querySelector(".e-group-body")),this.headerTemplate&&this.isRoot&&(this.element.innerHTML="",this.isRoot=!1),this.enableNotCondition&&L.removeClass(this.element.querySelectorAll(".e-qb-toggle"),"e-active-toggle"),n.appendChild(this.createElement("div",{attrs:{class:"e-rule-list"}})),this.levelColl[this.element.id+"_group0"]=[0],this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0),this.disableRuleCondition(n.parentElement)},q.prototype.getWrapper=function(){return this.element},q.prototype.getModuleName=function(){return"query-builder"},q.prototype.requiredModules=function(){var e=[];return e.push({member:"query-library",args:[this]}),e},q.prototype.GetRootColumnName=function(e){return this.separator?e.split(this.separator)[0]:e},q.prototype.initialize=function(){if(this.dataColl.length){var e=Object.keys(this.dataColl[0]),t=[],l=[],n=void 0,o=!1,i=!1,r=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],"initial"),d[a].type||(-1<e.indexOf(d[a].field)&&("string"===(n=typeof(r=this.dataColl[0][d[a].field]))?i=!isNaN(Date.parse(r)):"object"===n&&(i=r instanceof Date&&!isNaN(r.getTime()),n="string"),d[a].type=n,i=!1),n="string"),d[a].validation||(d[a].validation=s),d[a].category?o=!0:d[a].category=this.l10n.getConstant("OtherFields"),l.indexOf(d[a].category)<0&&l.push(d[a].category),(!d[a].operators||this.isLocale&&-1===this.isCustomOprCols.indexOf(d[a].field))&&(d[a].operators=this.customOperators[d[a].type+"Operator"]);o&&(1<l.length||l[0]!==this.l10n.getConstant("OtherFields"))&&(this.fields={text:"label",value:"field",groupBy:"category"}),this.updateSubFieldsFromColumns(this.columns)}else{for(a=0,u=e.length;a<u;a++)"string"===(n=typeof(r=this.dataColl[0][e[a]]))?i=!isNaN(Date.parse(r)):"object"!==n||Object.keys(r).length||(i=r instanceof Date&&!isNaN(r.getTime()),n="string"),i=!(t[a]={field:e[a],label:e[a],type:i?"date":n,validation:s}),t[a].operators=this.customOperators[t[a].type+"Operator"],"object"===n&&this.updateSubFields(r,t[a]);this.columns=t}}else if(this.columns&&this.columns.length){for(var d,a=0,u=(d=this.columns).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],"initial"),(!d[a].operators||this.isLocale&&-1===this.isCustomOprCols.indexOf(d[a].field))&&(d[a].operators=this.customOperators[d[a].type+"Operator"]);this.updateSubFieldsFromColumns(this.columns)}this.trigger("dataBound",{type:"dataBound"})},q.prototype.updateSubFieldsFromColumns=function(e,t){for(var l=0;l<e.length;l++)""!==this.separator&&e[l].field.indexOf(this.separator)<0&&(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))},q.prototype.updateSubFields=function(e,t,l){t.columns=[];var n=Object.keys(e);l=l||this.dataColl[0];for(var o=0,i=n.length;o<i;o++){var r,s=t.field.split("."),s=(l?l[s[s.length-1]]:this.dataColl[0][t.field])[n[o]],a=l[t.field.split(this.separator)[t.field.split(this.separator).length-1]],u={field:t.field+this.separator+n[o],label:n[o],type:r="object"!=(r=typeof s)||isNaN(Date.parse(s))?r:"date"};"object"!=r&&(u.operators=this.customOperators[r+"Operator"]),t.columns.push(u),"object"==r&&this.updateSubFields(s,u,a)}},q.prototype.updateCustomOperator=function(o,e){if(o.operators){this.isLocale||"initial"!==e||L.isNullOrUndefined(this.isCustomOprCols)||this.isCustomOprCols.push(o.field);for(var i=this,t=0;t<o.operators.length;t++)!function(e){var t,l,n=Object.keys(o.operators[e]).indexOf("sqlOperator");-1<n&&(t=o.operators[e],l=(e=Object.keys(t)).map(function(e){return t[""+e]}).join(",").split(","),e=e.indexOf("value"),i.operators[l[e]]=l[n])}(t)}},q.prototype.focusEventHandler=function(e){this.target=e.target},q.prototype.clickEventHandler=function(e){var t,l,n,o,i=this,r=e.target;if(this.isImportRules=!1,"string"==typeof(r="SPAN"===r.tagName?r.parentElement:r).className&&-1<r.className.indexOf("e-collapse-rule")&&(u=new L.Animation({duration:1e3,delay:0}),this.element.querySelectorAll(".e-summary-content").length<1&&this.renderSummary(),o=(e=document.getElementById(this.element.id+"_summary_content")).querySelector(".e-summary-text"),u.animate(".e-query-builder",{name:"SlideLeftIn"}),(a=this.element.querySelector(".e-group-container")).style.display="none",o.textContent=this.getSqlFromRules(this.rule),e.style.display="block",o.style.height=o.scrollHeight+"px"),"BUTTON"===r.tagName&&"string"==typeof r.className&&r.className.indexOf("e-qb-toggle")<0){var s,a,u=new L.Animation({duration:1e3,delay:0});switch(!0){case-1<r.className.indexOf("e-removerule"):this.actionButton=r,this.deleteRule(r);break;case-1<r.className.indexOf("e-clone-rule-btn"):this.actionButton=r,this.cloneRuleBtnClick=!0,this.ruleClone(r);break;case-1<r.className.indexOf("e-lock-rule-btn"):this.actionButton=r,this.ruleLock(r);break;case-1<r.className.indexOf("e-lock-grp-btn"):this.actionButton=r,this.groupLock(r);break;case-1<r.className.indexOf("e-clone-grp-btn"):this.actionButton=r,this.cloneGrpBtnClick=!0,this.groupClone(L.closest(r,".e-group-container"));break;case-1<r.className.indexOf("e-deletegroup"):this.actionButton=r,this.deleteGroup(L.closest(r,".e-group-container"));break;case-1<r.className.indexOf("e-edit-rule"):u.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),s=L.extend({},this.rule,{},!0),this.setGroupRules(s),this.renderSummaryCollapse()):((a=this.element.querySelector(".e-group-container")).querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),a.style.display="block")}}else("LABEL"===r.tagName&&-1<r.parentElement.className.indexOf("e-btn-group")||"string"==typeof r.className&&-1<r.className.indexOf("e-qb-toggle"))&&(e=L.closest(r,".e-group-container"),this.headerTemplate||(o=void 0,(t=r.getAttribute("for"))?o=document.getElementById(t).getAttribute("value"):this.enableSeparateConnector&&(o=r.textContent),t=e.id.replace(this.element.id+"_",""),l=this.getGroup(t),n=void 0,this.enableNotCondition&&(-1<r.className.indexOf("e-qb-toggle")?(n=-1<(e=e.getElementsByClassName("e-qb-toggle")[0]).className.indexOf("e-active-toggle")?(L.removeClass([e],"e-active-toggle"),!1):(L.addClass([e],"e-active-toggle"),!0),o=l.condition):n=l.not),l={groupID:t,cancel:!1,type:"condition",value:o.toLowerCase()},this.enableNotCondition&&(l={groupID:t,cancel:!1,type:"condition",value:o.toLowerCase(),not:n})),this.isImportRules?this.beforeSuccessCallBack(l,r):this.trigger("beforeChange",l,function(e){i.beforeSuccessCallBack(e,r)}),this.target=r)},q.prototype.beforeSuccessCallBack=function(e,t){var l,n,o,i,r;e&&!e.cancel&&(l=(i=L.closest(t,".e-group-container")).id.replace(this.element.id+"_",""),n=this.getValidRules(this.rule),o=this.getParentGroup(i),this.enableSeparateConnector?(r=(i=L.isNullOrUndefined(L.closest(t,".e-rule-container"))&&i.classList.contains("e-group-container")?null!==t.parentElement.previousElementSibling?t.parentElement.previousElementSibling:i:L.closest(t,".e-rule-container")).id.replace(this.element.id+"_",""),i.classList.contains("e-rule-container")?(o=this.getRule(i)).condition=e.value:i.classList.contains("e-group-container")&&((o=this.getGroup(i)).condition=e.value),this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:l,ruleID:r,type:"condition",value:o.condition})):(o.condition=e.value,this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:l,type:"condition",value:o.condition})),this.filterRules(n,this.getValidRules(this.rule),"condition"),this.enableSeparateConnector)&&(i=t.parentElement.querySelector(".e-btngroup-and"),r=t.parentElement.querySelector(".e-btngroup-or"),i)&&r&&("and"===e.value?(i.checked=!0,r.checked=!1):"or"===e.value&&(r.checked=!0,i.checked=!1))},q.prototype.selectBtn=function(e,t){"beforeOpen"===t.name?this.showButtons.groupInsert||L.isNullOrUndefined(this.showButtons.groupInsert)?(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount+1?L.addClass([t.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):L.removeClass([t.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"),this.enableRtl&&L.addClass([t.element.querySelector("li").parentElement],"e-rtl")):L.addClass([t.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):-1<t.element.children[0].className.indexOf("e-addrule")?this.addRuleElement(L.closest(e,".e-group-container"),{}):-1<t.element.children[0].className.indexOf("e-addgroup")&&this.addGroupElement(!0,L.closest(e,".e-group-container"),"",!0)},q.prototype.appendRuleElem=function(e,t,l,n,o,i){var r,s,a=e.querySelector(".e-rule-list");if("change"===l)r=L.select("#"+n,e);else{if((r=this.createElement("div",{attrs:{class:"e-rule-container"}})).setAttribute("id",e.id+"_rule"+this.ruleIdCounter),this.showButtons.cloneRule&&this.cloneRuleBtnClick){if(this.ruleIndex<0)a.appendChild(r);else if(this.enableSeparateConnector){for(var u=-1,d=this.ruleIndex+1,p=0;p<d&&p!==a.children.length;p++)a.children[p].classList.contains("e-rule-container")&&(d++,u++);a.insertBefore(r,a.children[this.ruleIndex+u+1])}else a.insertBefore(r,a.children[this.ruleIndex+1]);this.cloneRuleBtnClick=!1}else a.appendChild(r);this.ruleIdCounter++}return t&&t.ruleTemplate&&i?(l={requestType:"template-initialize",ruleID:r.id,action:o,fields:this.fields,rule:i},this.trigger("actionBegin",l),this.ruleTemplateFn=this.templateParser(t.ruleTemplate),n=this.element.id+t.field,l.fields=this.fields,l.columns=this.columns,""===i.field&&(i.field=t.field),l.operators=this.getOperators(i.field),l.operatorFields={text:"key",value:"value"},this.isReact?((s=this.ruleTemplateFn(l,this,r.id,n)[0]).className+=" e-rule-field",r.appendChild(s)):this.isAngular?((s=3===(e=this.ruleTemplateFn(l,this,r.id,n))[0].nodeType?e[1]:e[0]).className+=" e-rule-field",r.appendChild(s)):this.isVue3?(s=this.ruleTemplateFn(l,this,"Template",n),L.append(s,r),r.children.length&&(r.children[r.children.length-1].className+=" e-rule-field")):((s=this.ruleTemplateFn(l,this,"Template",n)[0]).className+=" e-rule-field",r.appendChild(s))):(s=this.ruleElem.querySelector(".e-rule-field").cloneNode(!0),r.appendChild(s)),this.showButtons.lockGroup&&L.removeClass(r.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.showButtons.lockRule&&L.removeClass(r.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"),this.showButtons.cloneGroup&&L.removeClass(r.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"),this.showButtons.cloneRule&&L.removeClass(r.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"),this.showButtons.ruleDelete&&L.removeClass(r.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.allowDragAndDrop&&L.removeClass(r.querySelectorAll(".e-drag-qb-rule"),"e-hidden"),t&&t.ruleTemplate&&i&&this.renderReactTemplates(),r},q.prototype.addRuleElement=function(t,l,n,o,i,r){var e,s=this;t&&(e={groupID:t.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"},this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addRuleSuccessCallBack(e,t,l,n,o,i,r)):this.trigger("beforeChange",e,function(e){s.addRuleSuccessCallBack(e,t,l,n,o,i,r)}))},q.prototype.addRuleSuccessCallBack=function(e,t,l,n,o,i,r){var s,a,u,d,p=-1<this.element.className.indexOf("e-device")?"250px":"200px",n=l&&l.field?this.getColumn(l.field):n||this.columns[0],c={label:"",field:"",type:"",operator:""};if(e.cancel||(n&&n.ruleTemplate&&l.field?(this.selectedColumn=n,e=this.selectedColumn.operators,c={label:n.label,field:n.field,type:n.type,operator:e[0].value},e=Object.keys(l).length?l:c,e={requestType:"template-create",action:"insert-rule",ruleID:(s=this.appendRuleElem(t,n,o,i,"field",e)).id,fields:this.fields,rule:e},this.trigger("actionBegin",e)):((s=this.appendRuleElem(t,n,o,i,"field")).querySelector(".e-filter-input").setAttribute("id",s.id+"_filterkey"),e=s.querySelector(".e-rule-delete"),-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?(e.textContent=this.l10n.getConstant("Remove"),L.addClass([e],"e-flat"),L.addClass([e],"e-primary")):(L.addClass([e],"e-round"),L.addClass([e],"e-icon-btn"),e.setAttribute("title",this.l10n.getConstant("DeleteRule")),o=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}}),s.querySelector(".e-rule-delete").appendChild(o)),this.showButtons.ruleDelete||e.classList.add("e-button-hide")),"Vertical"===this.displayMode||-1<this.element.className.indexOf("e-device")?s.className="e-rule-container e-vertical-mode":s.className="e-rule-container e-horizontal-mode",o=s.previousElementSibling,this.enableSeparateConnector?(f=g=void 0,(o=o&&o.classList.contains("e-group-container")?(f=o.querySelectorAll(".e-rule-container"))[f.length-1]:o)&&o.classList.contains("e-rule-container")&&(g=this.getRule(o)),this.headerTemplate&&o&&g?this.headerTemplateFn(o,!1,g.condition,g,o.id):L.isNullOrUndefined(o)&&s.id!==this.element.id+"_group0_rule0"&&((h=s.closest(".e-group-container"))&&h.previousElementSibling?(e=(m=h.previousElementSibling).querySelectorAll(".e-rule-container"),(m=m.classList.contains("e-group-container")?e[e.length-1]:m).classList.contains("e-rule-container")&&(e=this.getRule(m),this.headerTemplateFn(m,!1,e.condition,e,m.id,!0))):this.headerTemplateFn(s,!1,l.condition,l,s.id,!0))):o&&-1<o.className.indexOf("e-rule-container")&&(s.className.indexOf("e-joined-rule")<0&&(s.className+=" e-joined-rule"),o.className.indexOf("e-prev-joined-rule")<0)&&(o.className+=" e-prev-joined-rule"),o&&-1<o.className.indexOf("e-group-container")&&s.className.indexOf("e-separate-rule")<0&&(s.className+=" e-separate-rule"),this.isImportRules||this.updateAddedRule(t,l,c,r,i,!!this.enableSeparateConnector||null),n&&n.ruleTemplate&&l.field||("Default"===this.fieldMode?(u=a=void 0,u=this.separator&&l.field||this.autoSelectField||this.isImportRules?this.GetRootColumnName(l.field):l.field,a={dataSource:this.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:5<this.columns.length?p:"auto",close:this.fieldClose.bind(this,s.id+"_filterkey"),change:this.changeField.bind(this),value:l?u:null,open:this.popupOpen.bind(this,!0),cssClass:"qb-dropdownlist"},this.fieldModel&&(a=b({},a,this.fieldModel)),d=void(e=new y.DropDownList(a)).appendTo("#"+s.id+"_filterkey"),d=this.separator&&l.field||this.isImportRules?this.GetRootColumnName(l.field):e.value,this.selectedColumn=e.getDataByValue(d),Object.keys(l).length&&this.changeRule(l,{element:e.element,itemData:this.selectedColumn})):(this.isImportRules,u=l.field,this.dummyDropdownTreeDs=L.extend([],this.columns,[],!(a=void 0)),this.updateDropdowntreeDS(this.dummyDropdownTreeDs),a={fields:{dataSource:this.dummyDropdownTreeDs,value:"field",text:"label",child:"columns",expanded:"expanded",selectable:"selectable"},placeholder:this.l10n.getConstant("SelectField"),showClearButton:!1,popupHeight:5<this.columns.length?p:"auto",changeOnBlur:!1,change:this.changeField.bind(this),value:L.isNullOrUndefined(u)?null:[u],open:this.popupOpen.bind(this,!1),treeSettings:{expandOn:"Click"},cssClass:"e-qb-ddt",filtering:this.dropdownTreeFiltering.bind(this),close:this.dropdownTreeClose.bind(this)},this.fieldModel&&(a=b({},a,this.fieldModel)),(o=new y.DropDownTree(a)).appendTo("#"+s.id+"_filterkey"),L.isNullOrUndefined(o.value)||(c=this.getLabelFromColumn(o.value[0]),o.element.value=c),d=L.isNullOrUndefined(l.field)?o.value:this.GetRootColumnName(l.field),this.selectedColumn=this.getColumn(d),Object.keys(l).length&&this.changeRule(l,{element:o.element,itemData:this.selectedColumn}))),u=s.id.replace(this.element.id+"_",""),l&&l.isLocked&&(r=s.querySelector(".e-lock-rule-btn"),this.ruleLock(r)),this.isImportRules)||this.prvtEvtTgrDaD||this.trigger("change",{groupID:t.id.replace(this.element.id+"_",""),ruleID:u,type:"insertRule"}),this.enableSeparateConnector&&L.isNullOrUndefined(l.condition)&&u&&(l=this.getRule(u)),this.enableSeparateConnector){for(var h,g,m=s.previousElementSibling,f=void 0;m&&!m.classList.contains("e-rule-container");){if(m.classList.contains("e-group-container")){m=(f=m.querySelectorAll(".e-rule-container"))[f.length-1];break}m=m.previousElementSibling}this.headerTemplate&&m?(g=this.getRule(m),i={requestType:"rule-template-create",ruleID:m.id,condition:g.condition,notCondition:!!this.enableNotCondition||void 0},this.trigger("actionBegin",i)):L.isNullOrUndefined(m)&&s.id!==this.element.id+"_group0_rule0"&&(h=s.closest(".e-group-container"))&&h.previousElementSibling&&h.previousElementSibling.previousElementSibling&&(n=(n=h.previousElementSibling.previousElementSibling).classList.contains("e-group-container")?(e=n.querySelectorAll(".e-rule-container"))[e.length-1]:n).classList.contains("e-rule-container")&&(g=this.getRule(n),p={requestType:"rule-template-create",ruleID:n.id,condition:g.condition,notCondition:!!this.enableNotCondition||void 0},this.trigger("actionBegin",p)),this.setMultiConnector(s)}},q.prototype.dropdownTreeFiltering=function(t){var l=this,e=this,n=t.event.srcElement,n=(n.classList.contains("e-clear-icon")?n.parentElement.querySelector(".e-textbox"):n).id.split("_filterkey")[0],n=document.getElementById(n),n=(this.ddTree=L.getComponent(n.querySelector("input.e-dropdowntree"),"dropdowntree"),L.extend([],this.columns,[],!0));t.cancel=!0,""===t.text?this.changeDataSource(n):(n=n.map(function(e){return l.nestedChildFilter(t.text,e)}).filter(function(e){return null!==e}),this.changeDataSource(n),setTimeout(function(){L.isNullOrUndefined(e.ddTree)||L.isNullOrUndefined(e.ddTree.treeObj)||e.ddTree.treeObj.expandAll()},100))},q.prototype.changeDataSource=function(e){this.updateDropdowntreeDS(e),this.ddTree.treeObj.fields={dataSource:e,value:"field",text:"label",child:"columns",expanded:"expanded"},this.ddTree.treeObj.refresh()},q.prototype.nestedChildFilter=function(t,e){var l,n=this,o=e[this.ddTree.fields.child];return o?(l=o.map(function(e){return n.nestedChildFilter(t,e)}).filter(function(e){return null!==e})).length?(e[this.ddTree.fields.child]=l,e):(e[this.ddTree.fields.child]=o,this.isMatchedNode(t,e)?e:null):this.isMatchedNode(t,e)?e:null},q.prototype.isMatchedNode=function(e,t){t=t[this.ddTree.fields.text].toLowerCase();return e=e?e.toLowerCase():"",-1!==t.indexOf(e)},q.prototype.dropdownTreeClose=function(){this.ddTree&&this.changeDataSource(L.extend([],this.columns,[],!0)),this.ddTree=null},q.prototype.updateDropdowntreeDS=function(e){for(var t=0;t<e.length;t++)"object"===e[parseInt(t.toString(),10)].type?(this.isAngular&&e[parseInt(t.toString(),10)].template&&delete e[parseInt(t.toString(),10)].template,e[parseInt(t.toString(),10)].selectable=!1,this.updateDropdowntreeDS(e[parseInt(t.toString(),10)].columns)):this.isAngular&&e[parseInt(t.toString(),10)].template&&delete e[parseInt(t.toString(),10)].template},q.prototype.updateAddedRule=function(e,t,l,n,o,i){var r=0;if(n){for(s=L.select("#"+o,e),u=L.closest(e,".e-group-container"),d=this.getParentGroup(u);s&&null!==s.previousElementSibling;){var s=s.previousElementSibling,a=this.enableSeparateConnector&&(!this.headerTemplate&&!s.classList.contains("e-btn-group")||this.headerTemplate&&(s.classList.contains("e-rule-container")||s.classList.contains("e-group-container")));this.enableSeparateConnector&&!a||r++}d.rules[r]=t}else{var u=L.closest(e,".e-group-container"),d=this.getParentGroup(u),n=t.custom;Object.keys(t).length?this.ruleIndex<0?(d.rules.push({field:t.field,type:t.type,label:t.label,operator:t.operator,value:t.value}),n&&(d.rules[d.rules.length-1].custom=n),this.enableSeparateConnector&&(d.rules[d.rules.length-1].condition=t.condition||l.condition)):(d.rules.splice(this.ruleIndex+1,0,{field:t.field,type:t.type,label:t.label,operator:t.operator,value:t.value}),n&&(d.rules[this.ruleIndex+1].custom=n),this.enableSeparateConnector&&(d.rules[this.ruleIndex+1].condition=t.condition||l.condition)):(n&&(l.custom=n),this.autoSelectField&&(t.field=l.field=this.rule.rules[0].field),d.rules.push(l))}this.disableRuleCondition(e,d,i)},q.prototype.changeRuleTemplate=function(e,t){var l,n,o=this.selectedColumn.operators;e.ruleTemplate||(l=L.closest(t,".e-group-container"),n=L.closest(t,".e-rule-container").id,this.previousColumn&&this.previousColumn.ruleTemplate&&(L.detach(t.closest('[id="'+n+'"]').querySelector(".e-rule-field")),this.clearQBTemplate([n])),e&&(t={field:e.field,label:e.label,operator:o[0].value,value:""},this.addRuleElement(l,t,e,"change",n,!0)))},q.prototype.renderToolTip=function(e){var t=new s.Tooltip({content:this.l10n.getConstant("ValidationMessage"),isSticky:!0,position:"BottomCenter",cssClass:"e-querybuilder-error",afterClose:function(){t.destroy()},beforeOpen:function(e){e=e.element.querySelector(".e-tooltip-close");e&&(e.style.display="none")}});t.appendTo(e),t.open(e)},q.prototype.validateFields=function(){var e,t=!0;if(this.allowValidation)for(var l=["isnull","isnotnull","isempty","isnotempty"],n=void 0,o=void 0,i=void 0,r=[],s=void 0,a=void 0,u=void 0,d=void 0,p=this.element.querySelectorAll(".e-rule-container"),n=0,c=p.length;n<c;n++){var h=void 0,g=L.closest(p[n],".e-group-container"),d=this.getParentGroup(g),s=0;if(i=u=p[n],"DropdownTree"===this.fieldMode?(e=L.getComponent(p[n].querySelector(".e-rule-filter input.e-dropdowntree"),"dropdowntree"))&&e.value&&e.value.length&&(this.selectedColumn=this.getColumn(e.value[0]),h=this.selectedColumn.validation):(a=L.getComponent(p[n].querySelector(".e-rule-filter input.e-dropdownlist"),"dropdownlist"))&&a.value&&(this.selectedColumn=a.getDataByValue(a.value),h=!L.isNullOrUndefined(a.value)&&this.selectedColumn.validation),o=u.querySelector(".e-rule-field input.e-control"),h&&h.isRequired){for(;i&&null!==i.previousElementSibling;){var i=i.previousElementSibling,m=this.enableSeparateConnector&&(!this.headerTemplate&&!i.classList.contains("e-btn-group")||this.headerTemplate&&(i.classList.contains("e-rule-container")||i.classList.contains("e-group-container")));this.enableSeparateConnector&&!m||s++}if(o=u.querySelector(".e-rule-operator .e-control"),d.rules[s].operator||(o.parentElement.className.indexOf("e-tooltip")<0&&o.className.indexOf("e-tooltip")<0&&this.renderToolTip(o.parentElement),t=!1),d.rules[s].value instanceof Array&&(r=d.rules[s].value),l.indexOf(d.rules[s].operator)<-1&&L.isNullOrUndefined(d.rules[s].value)&&"date"!==d.rules[s].type||""===d.rules[s].value||null===d.rules[s].value||d.rules[s].value instanceof Array&&r.length<1){var f=u.querySelectorAll(".e-rule-value .e-control");l.indexOf(d.rules[s].operator)<0&&(t=!1);for(var y=0,v=f.length;y<v;y++){var b=f[y],C=void 0;-1<b.parentElement.className.indexOf("e-searcher")?(C=L.closest(b,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(C):f[y].parentElement.className.indexOf("e-tooltip")<0&&f[y].className.indexOf("e-tooltip")<0&&this.renderToolTip(f[y].parentElement),y++}}else if("date"===d.rules[s].type&&(null===d.rules[s].value||-1<d.rules[s].value.indexOf(null))){f=u.querySelectorAll(".e-rule-value .e-control");l.indexOf(d.rules[s].operator)<0&&(t=!1);for(y=0,v=f.length;y<v;y++)f[y].parentElement.className.indexOf("e-tooltip")<0&&f[y].className.indexOf("e-tooltip")<0&&(L.isNullOrUndefined(d.rules[s].value)||null==d.rules[s].value[y])&&this.renderToolTip(f[y].parentElement)}}else(a&&a.element&&L.isNullOrUndefined(a.value)||e&&e.element&&(L.isNullOrUndefined(e.value)||e.value.length<1))&&(o.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(o.parentElement),t=!1)}return t},q.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");e&&(this.levelColl[e.id]=[0],this.refreshLevel({groupElement:e,level:[0]}))},q.prototype.refreshLevel=function(e){for(var t,l=e.groupElement.querySelector(".e-rule-list").children,n=e.groupElement,o=l.length,i=0,r=0;r<o;r++)-1<(t=l[r]).className.indexOf("e-group-container")&&(e.level.push(i),this.levelColl[t.id]=e.level.slice(),i++,e.groupElement=t,e=this.refreshLevel(e));var s=L.closest(n,".e-rule-list");return e.groupElement=s?L.closest(s,".e-group-container"):n,e.level=this.levelColl[e.groupElement.id].slice(),e},q.prototype.groupTemplate=function(e){var t,l,n=this.createElement("div",{attrs:{class:"e-group-container"}}),o=this.createElement("div",{attrs:{class:"e-group-header"}}),i=this.createElement("div",{attrs:{class:"e-group-body"}}),r=this.createElement("div",{attrs:{class:"e-rule-list"}});return n.appendChild(o),i.appendChild(r),n.appendChild(i),this.headerTemplate||(r=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden",i=this.createElement("span",{attrs:{class:r,"aria-lable":"drag handle",title:"drag handle"}}),o.appendChild(i),r=this.enableSeparateConnector&&!e?"e-lib e-btn-group e-qb-toggle-btn":"e-lib e-btn-group",i=this.createElement("div",{attrs:{class:r,role:"group"}}),this.enableSeparateConnector&&i.classList.add("e-multi-connector"),this.enableNotCondition&&(t=this.enableSeparateConnector?this.createElement("input",{attrs:{type:"checkbox",class:"e-qb-toggle"}}):this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),i.appendChild(t)),t=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}}),i.appendChild(t),e=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-and-lbl e-small"},innerHTML:this.l10n.getConstant("AND")}),i.appendChild(e),t=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),i.appendChild(t),e=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-or-lbl e-small"},innerHTML:this.l10n.getConstant("OR")}),i.appendChild(e),o.appendChild(i),r=this.createElement("div",{attrs:{class:"e-group-action"}}),l=this.enableSeparateConnector?(l=this.createElement("button",{attrs:{type:"button",class:"e-add-condition-btn"}}),r.appendChild(l),this.createElement("button",{attrs:{type:"button",class:"e-add-group-btn"}})):this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),r.appendChild(l),o.appendChild(r)),n},q.prototype.ruleTemplate=function(){var e=this.createElement("div"),t=this.createElement("div",{attrs:{class:"e-rule-field"}}),l=this.createElement("div",{attrs:{class:"e-rule-filter"}}),n=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden",n=this.createElement("span",{attrs:{class:n,"aria-lable":"drag handle",title:"drag handle"}}),n=(t.appendChild(n),this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}})),n=(l.appendChild(n),t.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-operator"}}),t.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value"}}),t.appendChild(l),l=this.createElement("div",{attrs:{class:"e-rule-value-delete"}}),n=this.showButtons.cloneRule?"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn":"e-clone-rule-btn e-clone-rule e-css e-btn e-small e-round e-icon-btn e-button-hide",i=this.showButtons.lockRule?"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-rule-btn e-lock-rule e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneRule"),type:"button",class:n}})),o=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}}),i=(n.appendChild(o),this.createElement("button",{attrs:{title:this.l10n.getConstant("LockRule"),type:"button",class:i}})),o=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),o=(i.appendChild(o),this.showButtons.ruleDelete||L.isNullOrUndefined(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"),o=this.createElement("button",{attrs:{type:"button",class:o}});return l.appendChild(n),l.appendChild(i),l.appendChild(o),t.appendChild(l),e.appendChild(t),e},q.prototype.addGroupElement=function(t,l,n,o,i,r,s){var a=this,e={groupID:l.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addGroupSuccess(e,t,l,n,o,i,r,s)):this.trigger("beforeChange",e,function(e){a.addGroupSuccess(e,t,l,n,o,i,r,s)})},q.prototype.addGroupSuccess=function(e,t,l,n,o,i,r,s){var a=this;if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var u,d,p,e=l,l=void 0,c="",c=e.className.indexOf("e-group-container")<0?e.querySelector(".e-group-container")&&e.querySelector(".e-group-container").id:e.id,h=(this.enableSeparateConnector&&(this.groupElem=this.groupTemplate()),this.groupElem.cloneNode(!0));if(h.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),0===this.groupIdCounter&&this.allowDragAndDrop&&h.querySelector(".e-drag-qb-rule")&&(h&&h.children[0]&&h.children[0].classList.add("e-parent-header"),L.addClass([h.querySelector(".e-drag-qb-rule")],"e-hidden")),this.headerTemplate&&(r?(t=!1,h.setAttribute("id",this.element.id+"_group0"),this.headerTemplateFn(h,i,n,s,c),this.groupIdCounter=0):this.headerTemplateFn(h,i,n,s,c)),this.groupIdCounter++,this.headerTemplate||(r=h.querySelector(".e-btngroup-and"),s=h.querySelector(".e-btngroup-or"),c=h.querySelector(".e-btngroup-and-lbl"),O=h.querySelector(".e-btngroup-or-lbl"),r.setAttribute("id",this.element.id+"_and"+this.btnGroupId),s.setAttribute("id",this.element.id+"_or"+this.btnGroupId),r.setAttribute("name",this.element.id+"_and"+this.btnGroupId),s.setAttribute("name",this.element.id+"_and"+this.btnGroupId),c.setAttribute("for",this.element.id+"_and"+this.btnGroupId),O.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++),t){for(var r=void 0,r=this.showButtons.groupDelete||L.isNullOrUndefined(this.showButtons.groupDelete)?"e-deletegroup":"e-deletegroup e-button-hide",l=this.createElement("button",{attrs:{type:"button",class:r}}),s=(new N.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(l),l.setAttribute("title",this.l10n.getConstant("DeleteGroup")),L.rippleEffect(l,{selector:".deletegroup"}),e.querySelector(".e-rule-list")),g=s.children,m=0,f=0,y=g.length;f<y;f++)-1<g[f].className.indexOf("e-group-container")&&(m+=1);if(this.showButtons.cloneGroup&&this.cloneGrpBtnClick)if(this.groupIndex===g.length-1)s.appendChild(h),this.isLastGroup=!0;else{if(this.enableSeparateConnector){for(var v=0,b=this.groupIndex+1,C=0;C<b;C++)g[C].classList.contains("e-rule-container")&&(b++,v++);0<v&&v--,g[k=this.groupIndex+v+1].parentNode.insertBefore(h,g[k])}else g[k=this.groupIndex+1].parentNode.insertBefore(h,g[k]);this.isMiddleGroup=!0}else s.appendChild(h);var S,x,q,c=this.levelColl[e.id].slice(0);c.push(m),this.levelColl[h.id]=c,-1<this.groupIndex&&this.refreshLevelColl(),this.isImportRules||(this.isAddSuccess=!0,this.addGroups([],e.id.replace(this.element.id+"_","")),this.isAddSuccess=!1,o&&this.addRuleToNewGroups&&this.addRuleElement(h,{})),this.headerTemplate||(S="",S=this.showButtons.cloneGroup?"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-clone-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",O=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneGroup"),type:"button",class:S}}),x=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}}),O.appendChild(x),h.querySelector(".e-group-action").appendChild(O),S=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",q=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:S}}),t=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),q.appendChild(t),h.querySelector(".e-group-action").appendChild(q),h.querySelector(".e-group-action").appendChild(l))}else this.headerTemplate||(S="",S=this.showButtons.lockGroup?"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn":"e-lock-grp-btn e-css e-btn e-small e-round e-icons e-icon-btn e-button-hide",q=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:S}}),x=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),q.appendChild(x),h.querySelector(".e-group-action").appendChild(q)),e.appendChild(h),this.levelColl[h.id]=[0];if(this.enableNotCondition&&!this.headerTemplate&&(E=h.querySelector(".e-qb-toggle"),(this.enableSeparateConnector?new N.CheckBox({label:this.l10n.getConstant("NOT"),cssClass:"e-qb-toggle"}):new N.Button({content:this.l10n.getConstant("NOT"),cssClass:"e-btn e-small"})).appendTo(E),h.querySelector(".e-btngroup-and-lbl").classList.add("e-not"),this.updatedRule)&&this.updatedRule.not&&L.addClass([E],"e-active-toggle"),this.enableSeparateConnector&&!this.headerTemplate){for(var E,O,r=h.querySelector(".e-btngroup-and"),k=h.querySelector(".e-btngroup-or"),w=h.querySelector(".e-btn-group"),C=0;C<w.childNodes.length;C++)"not"===h.querySelector(".e-btn-group").childNodes[C].textContent.toLowerCase()&&this.enableNotCondition?w.childNodes[C].classList.add("e-multiconnector"):w.childNodes[C].style.display="none";h.previousElementSibling&&(L.isNullOrUndefined(this.headerTemplate)&&(h.parentElement.insertBefore(this.groupTemplate(!0).querySelector(".e-btn-group"),h),(E=h.previousElementSibling.childNodes[0]).classList.contains("e-qb-toggle"))&&(E.style.display="none"),this.isImportRules||(c=(s=h.previousElementSibling).querySelector(".e-btngroup-and"),o=s.querySelector(".e-btngroup-or"),r.checked||k.checked?this.enableSeparateConnector&&(r.checked&&(c.checked=!0),k.checked)&&(o.checked=!0):(O=h.nextElementSibling)&&O.classList.contains("e-btn-group")&&(r=O.querySelector(".e-btngroup-and"),k=O.querySelector(".e-btngroup-or"),c.checked=r.checked,o.checked=k.checked)))}this.updatedRule=null,this.headerTemplate?(t={requestType:"header-template-create",ruleID:h.id,condition:n,notCondition:this.enableNotCondition?i:void 0},this.trigger("actionBegin",t)):this.enableSeparateConnector?(u=h.querySelector(".e-add-condition-btn"),(p=new N.Button({cssClass:this.element.id+"_addConditionbtn",content:this.l10n.getConstant("AddCondition")})).appendTo(u),p.element.onclick=function(){a.addRuleElement(L.closest(u,".e-group-container"),{})},d=h.querySelector(".e-add-group-btn"),(p=new N.Button({cssClass:this.element.id+"_addGroupbtn",content:this.l10n.getConstant("AddGroup")})).appendTo(d),p.element.onclick=function(){a.addGroupElement(!0,L.closest(d,".e-group-container"),"",!0)}):(l=h.querySelector(".e-add-btn"),(p=new R.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,l),select:this.selectBtn.bind(this,l)})).appendTo(l),l.setAttribute("title",this.l10n.getConstant("AddButton"))),this.isImportRules||this.prvtEvtTgrDaD||(S=e.id.replace(this.element.id+"_",""),x=h.id.replace(this.element.id+"_",""),this.trigger("change",{groupID:S,type:"insertGroup",childGroupID:x}))}},q.prototype.setMultiConnector=function(e){var t;this.enableSeparateConnector&&!this.headerTemplate&&e.previousElementSibling&&this.groupElem.querySelector(".e-btn-group")&&(e.parentElement.insertBefore(this.groupTemplate(!0).querySelector(".e-btn-group"),e),(t=e.previousElementSibling.childNodes[0]).classList.contains("e-qb-toggle")&&(t.style.display="none"),this.addHeaderDiv(e))},q.prototype.addHeaderDiv=function(e){var t,l=e.previousElementSibling.previousElementSibling;l&&(l=-1<l.id.indexOf("rule")?this.getRule(l):this.getGroup(l),L.isNullOrUndefined(l.condition)&&(l.condition="and"),t=e.previousElementSibling.querySelector(".e-btngroup-or"),e=e.previousElementSibling.querySelector(".e-btngroup-and"),t.disabled=!1,e.disabled=!1,"or"===l.condition?t.checked=!0:e.checked=!0)},q.prototype.headerTemplateFn=function(e,t,l,n,o,i){var r=this.element.id+"_header",s=e.querySelector(".e-group-header");if(this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(s=e),this.headerTemplate){if(t={requestType:"header-template-initialize",ruleID:e.id,notCondition:this.enableNotCondition?t:void 0,condition:l,rule:this.getRuleCollection(n,!1),groupID:o},this.trigger("actionBegin",t),this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(t.requestType="rule-template-create"),this.headerFn=this.templateParser(this.headerTemplate),this.isReact)a=this.headerFn(t,this,e.id,r)[0],this.enableSeparateConnector&&i?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):s.appendChild(a);else if(this.isAngular){var l=this.headerFn(t,this,e.id,r),a=3===l[0].nodeType?l[1]:l[0];this.enableSeparateConnector&&i?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):s.appendChild(a)}else if(this.isVue3){if(a=this.headerFn(t,this,e.id,r),this.enableSeparateConnector&&(i||-1!==e.id.indexOf("rule")))for(var u=0;u<a.length;u++)if("DIV"===a[u].nodeName){a=a[u];break}this.enableSeparateConnector&&i?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):L.append(a,s)}else a=this.headerFn(t,this,"Template",r)[0],this.enableSeparateConnector&&i?this.enableSeparateConnectorInitialRule(e,a):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?s.parentElement.insertBefore(a,s.nextElementSibling):s.appendChild(a);this.renderReactTemplates()}return e},q.prototype.enableSeparateConnectorInitialRule=function(e,t){var l=(e.nextElementSibling||e).closest(".e-group-container");(l=e.nextElementSibling?l:l&&(l.nextElementSibling||l))&&l.parentElement.insertBefore(t,l)},q.prototype.notifyChange=function(e,t,l){var n=L.closest(t,".e-group-container"),n=this.getParentGroup(n),o=L.closest(t,".e-rule-container"),i=0;if("not"===l)n.not=e;else if("condition"===l)this.enableSeparateConnector?(n=(o=(o=t.parentElement.previousElementSibling)&&o.classList.contains("e-group-container")?o.querySelectorAll(".e-rule-container")[o.querySelectorAll(".e-rule-container").length-1]:o)&&o.classList.contains("e-rule-container")?this.getRule(o):n).condition=e:n.condition=e;else{for(;o&&null!==o.previousElementSibling;)o=o.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!o.classList.contains("e-btn-group")||this.headerTemplate&&(o.classList.contains("e-rule-container")||o.classList.contains("e-group-container"))))&&i++;var n=n.rules[i],n=this.getColumn(n.field),r=this.getFormat(n.format);if("date"===n.type)if(e instanceof Date)e=this.intl.formatDate(e,r);else if(e instanceof Array)for(var s=0;s<e.length;s++)e[s]&&e[s]instanceof Date&&(e[s]=this.intl.formatDate(e[s],r));n.ruleTemplate?this.templateChange(t,e,l):(this.isNotified=!0,this.updateRules(t,e),this.isNotified=!1)}},q.prototype.templateChange=function(e,t,l){var n=L.closest(e,".e-group-container"),o=this.getParentGroup(n),i=L.closest(e,".e-rule-container"),r=0;for(this.allowValidation&&this.validateValue(o,i);i&&null!==i.previousElementSibling;)i=i.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!i.classList.contains("e-btn-group")||this.headerTemplate&&(i.classList.contains("e-rule-container")||i.classList.contains("e-group-container"))))&&r++;var s,a,u=o.rules[r],o=("field"===l?this.selectedColumn=this.getColumn(t):u&&(this.selectedColumn=this.getColumn(u.field)),this.previousColumn=this.getColumn(u.field),this.getValidRules(this.rule)),d=(this.selectedColumn&&(s=this.selectedColumn.operators||this.customOperators[this.selectedColumn.type+"Operator"]),["in","notin","between","notbetween"]);switch(l){case"field":u.field=t,u.label=this.selectedColumn.label,u.type=this.selectedColumn.type,u.value="",u.operator=s[0].value;break;case"operator":a=u.operator,u.operator=t,-1<d.indexOf(u.operator)?u.value=[]:-1<d.indexOf(a)&&(u.value="");break;case"value":u.value=t}this.changeRuleTemplate(this.selectedColumn,e),this.filterRules(o,this.getValidRules(this.rule),l),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"!==l&&"operator"!==l||(o=L.closest(e,".e-rule-container"),this.destroyControls(o,!0),L.detach(o.querySelector(".e-rule-field")),e=this.appendRuleElem(L.closest(o,".e-group-container"),this.selectedColumn,"change",o.id,l,u),"Vertical"===this.displayMode||-1<this.element.className.indexOf("e-device")?e.className="e-rule-container e-vertical-mode":e.className="e-rule-container e-horizontal-mode",this.enableSeparateConnector||e.previousElementSibling&&-1<e.previousElementSibling.className.indexOf("e-rule-container")&&(e.className.indexOf("e-joined-rule")<0&&(e.className+=" e-joined-rule"),e.previousElementSibling.className.indexOf("e-prev-joined-rule")<0)&&(e.previousElementSibling.className+=" e-prev-joined-rule"),e.previousElementSibling&&-1<e.previousElementSibling.className.indexOf("e-group-container")&&e.className.indexOf("e-separate-rule")<0&&(e.className+=" e-separate-rule"),e={requestType:"template-create",action:l,ruleID:o.id,fields:this.fields,rule:u},l={groupID:n.id.replace(this.element.id+"_",""),ruleID:o.id.replace(this.element.id+"_",""),value:u.field,type:"field"},this.trigger("actionBegin",e),this.trigger("change",l)))},q.prototype.changeValue=function(e,t){var l,n,o,i,r,s,a,u=this;this.isNumInput&&"number"==typeof t.value||"input"===t.type&&t.target&&t.target.classList.contains("e-numerictextbox")&&(this.selectedColumn.validation.max!==Number.MAX_VALUE||0<this.selectedColumn.validation.min)?this.isNumInput=!1:(l=t.element&&t.element.classList.contains("e-multiselect")?t.element:t.event?t.event.target:"input"===t.type&&t.target&&t.target.classList.contains("e-numerictextbox")?t.currentTarget:t.element)&&((-1<l.className.indexOf("e-day")||-1<l.className.indexOf("e-today")||-1<l.className.indexOf("e-cell"))&&(l=t.element),r=L.closest(l,".e-group-container"),a=L.closest(l,".e-rule-container"),n=r&&r.id.replace(this.element.id+"_",""),o=a.id.replace(this.element.id+"_",""),(r=t).element&&-1<r.element.className.indexOf("e-datepicker")&&(l=r.element,(s=L.getComponent(L.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"))&&(this.selectedColumn=s.getDataByValue(s.value)),s=L.getComponent(L.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"))&&(this.selectedColumn=this.getColumn(s.value[0])),-1<l.className.indexOf("e-radio")?(a=parseInt(l.id.split("valuekey")[1],10),"Default"===this.fieldMode?(s=L.getComponent(L.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=s.getDataByValue(s.value),this.selectedColumn.columns&&(s=L.getComponent(L.closest(l,".e-rule-container").querySelector(".e-rule-sub-filter .e-dropdownlist"),"dropdownlist"),this.selectedColumn=this.getColumn(s.value))):(s=L.getComponent(L.closest(l,".e-rule-container").querySelector(".e-filter-input"),"dropdowntree"),this.selectedColumn=this.getColumn(s.value[0])),i=(this.selectedColumn.values||[!0,!1])[a]):-1<l.className.indexOf("e-multiselect")?i=L.getComponent(l,"multiselect").value:(i=t.value,"input"===t.type&&t.target&&t.target.classList.contains("e-numerictextbox")&&(i=Number(t.currentTarget.value),r=t.currentTarget,s=L.getInstance(r,c.NumericTextBox),a=L.getValue("decimal",L.getNumericObject(this.locale)),isNaN(i)&&-1!==r.value.indexOf(a)&&(i=this.intl.getNumberParser({format:"n"})(r.value)),isNaN(i)||(s.value=i),this.isNumInput=!0)),"input"===t.name&&this.immediateModeDelay?(window.clearInterval(this.timer),this.timer=window.setInterval(function(){u.filterValue(n,o,i,e,l)},this.immediateModeDelay)):this.filterValue(n,o,i,e,l))},q.prototype.filterValue=function(t,l,e,n,o){var i=this,e={groupID:t,ruleID:l,value:e,cancel:!1,type:"value"};window.clearInterval(this.timer),this.isImportRules?this.changeValueSuccessCallBack(e,o,n,t,l):this.trigger("beforeChange",e,function(e){i.changeValueSuccessCallBack(e,o,n,t,l)})},q.prototype.changeValueSuccessCallBack=function(e,t,l,n,o){e.cancel||(this.updateRules(t,e.value,l),this.isImportRules)||this.trigger("change",{groupID:n,ruleID:o,value:e.value,cancel:!1,type:"value"})},q.prototype.fieldClose=function(e){var t,l;this.isFieldChange||this.isDestroy||(this.isFieldClose=!0,l=(e=L.getComponent(e,"dropdownlist")).popupObj&&e.popupObj.element.querySelector(".e-active"),t=e.getItemData(),e.value=t.value,l={element:e.element,value:t.value,isInteracted:!0,previousItemData:this.prevItemData,previousItem:null,item:l,itemData:t,event:null,e:null},e.previousValue!==e.value&&this.changeField(l),this.isFieldChange=!1)},q.prototype.changeField=function(e){if(e.isInteracted&&!L.isNullOrUndefined(e.value)){this.isFieldChange=!0,this.prevItemData=e.itemData;var t=L.closest(e.element,".e-rule-filter")||L.closest(e.element,".e-rule-sub-filter"),l="DropdownTree"===this.fieldMode?this.getColumn(e.value[0]):this.getColumn(e.value);if("DropdownTree"===this.fieldMode&&null!==t){var n,o=t.querySelector(".e-dropdowntree.e-control"),i=L.getComponent(o,"dropdowntree");if(!l)return;if("object"===l.type)return i.value=e.oldValue,i.dataBind(),void(L.isNullOrUndefined(e.oldValue)?o.value="":(n=this.getLabelFromColumn(e.oldValue[0]),o.value=n));L.isNullOrUndefined(e.value[0])||(i.value=e.value[0],i.dataBind(),n=this.getLabelFromColumn(e.value[0]),o.value=n)}if(this.destroySubFields(t),this.subFieldElem=null,this.isNotValueChange=!0,l&&l.ruleTemplate)this.templateChange(e.element,l.field,"field");else if(l&&l.columns&&l.columns[0].ruleTemplate)this.templateChange(e.element,l.columns[0].field,"field");else{for(var i=L.closest(e.element,".e-group-container"),o=this.getParentGroup(i),r=L.closest(e.element,".e-rule-container"),s=0;r&&null!==r.previousElementSibling;)r=r.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!r.classList.contains("e-btn-group")||this.headerTemplate&&(r.classList.contains("e-rule-container")||r.classList.contains("e-group-container"))))&&s++;o.rules[s].value="",this.changeRule(o.rules[s],e)}}},q.prototype.changeRule=function(e,t){if(!t.itemData){if("DropdownTree"!==this.fieldMode)return;if(null==L.getComponent(t.element,"dropdowntree").value)return}var l=L.closest(t.element,".e-rule-filter")||L.closest(t.element,".e-rule-sub-filter"),n=L.getComponent(t.element,"dropdownlist");"DropdownTree"===this.fieldMode&&null!==l&&(n=L.getComponent(t.element,"dropdowntree"));var o=L.closest(t.element,".e-group-container").id.replace(this.element.id+"_","");this.changeFilter(l,n,o,e,{},t)},q.prototype.changeFilter=function(t,e,l,n,o,i){var r,s=this;t?(r=void 0,r="DropdownTree"===this.fieldMode?e.value[0]:this.isImportRules?this.GetRootColumnName(e.value):e.value,this.selectedColumn=this.getColumn(r),r={groupID:l,ruleID:L.closest(t,".e-rule-container").id.replace(this.element.id+"_",""),selectedField:"DropdownTree"===this.fieldMode?e.value[0]:e.value,cancel:!1,type:"field"},this.isImportRules||this.prvtEvtTgrDaD?this.fieldChangeSuccess(r,o,t,n,i):this.trigger("beforeChange",r,function(e){s.fieldChangeSuccess(e,o,t,n,i)})):(r=L.closest(i.element,".e-rule-operator"),this.changeOperator(t,r,e,l,n,o,i))},q.prototype.changeOperator=function(t,e,l,n,o,i,r){var s=this;e?(n={groupID:n,ruleID:L.closest(e,".e-rule-container").id.replace(this.element.id+"_",""),selectedIndex:l.index,cancel:!1,type:"operator"},this.isImportRules?this.operatorChangeSuccess(n,t,i,o,r):this.trigger("beforeChange",n,function(e){s.operatorChangeSuccess(e,t,i,o,r)})):this.changeRuleValues(t,o,i,r)},q.prototype.fieldChangeSuccess=function(e,t,l,n,o){for(var i=L.closest(l,".e-rule-container"),r=L.closest(o.element,".e-rule-operator"),s=L.closest(o.element,".e-group-container").id.replace(this.element.id+"_",""),a=L.getComponent(o.element,"dropdownlist"),u=i.querySelectorAll(".e-tooltip.e-input-group"),d=0;d<u.length;d++)L.getComponent(u[d],"tooltip").destroy();if(e.cancel)this.changeOperator(l,r,a,s,n,t,o);else if(!L.isNullOrUndefined(this.selectedColumn))if(t.type=this.selectedColumn.type,i.querySelector(".e-template")&&(n.value=""),"object"===this.selectedColumn.type&&"Default"===this.fieldMode)for(t.type=this.selectedColumn.columns[0].type;this.selectedColumn.columns;)this.createSubFields(l,n,t,o);else this.destroySubFields(l),this.changeOperator(l,r,a,s,n,t,o)},q.prototype.destroySubFields=function(e){for(;e&&e.nextElementSibling.classList.contains("e-rule-sub-filter");)this.destroyControls(e),e.nextElementSibling.remove()},q.prototype.createSubFields=function(e,t,l,n){var o=!1,e=L.closest(e,".e-rule-field"),i=this.createElement("div",{attrs:{class:"e-rule-sub-filter",id:"subfilter"+this.subFilterCounter}}),e=(e.insertBefore(i,e.querySelector(".e-rule-operator")),L.closest(i,".e-rule-container").id),r=this.createElement("input",{attrs:{type:"text",id:e+"_subfilterkey"+this.subFilterCounter}}),s=(i.appendChild(r),-1<this.element.className.indexOf("e-device")?"250px":"200px"),s={dataSource:this.selectedColumn.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:5<this.selectedColumn.columns.length?s:"auto",change:this.changeField.bind(this),index:0,open:this.popupOpen.bind(this,!1)},a=(this.fieldModel&&(s=b({},s,this.fieldModel)),new y.DropDownList(s));if(a.appendTo("#"+e+"_subfilterkey"+this.subFilterCounter),this.isImportRules||this.previousColumn&&this.previousColumn.ruleTemplate&&this.GetRootColumnName(t.field)===this.GetRootColumnName(this.previousColumn.field))for(var u=this.selectedColumn.columns,d=0;d<u.length;d++)if(t.field===u[d].field||-1<t.field.indexOf(u[d].field+this.separator)){a.value=u[d].field,this.selectedColumn=u[d],o=!0;break}this.subFilterCounter++,this.subFieldElem=r,n.itemData=n.itemData,!o&&this.selectedColumn.columns&&(!o&&this.isImportRules&&(a.value=null),this.selectedColumn=this.selectedColumn.columns[0]),this.previousColumn=this.selectedColumn,this.selectedColumn.columns||this.changeRuleValues(i,t,l,n)},q.prototype.operatorChangeSuccess=function(e,t,l,n,o){var i,r,s,a;e.cancel||(i=(e=L.closest(o.element,".e-rule-operator")).nextElementSibling,r=L.getComponent(o.element,"dropdownlist"),a=n.operator?n.operator.toString().toLowerCase():"",l.operator=r.value.toString(),r=l.operator.toLowerCase(),-1<l.operator.toLowerCase().indexOf("between")||-1<l.operator.toLowerCase().indexOf("in")&&l.operator.toLowerCase().indexOf("contains")<0?(t=e.previousElementSibling,l.type=n.type,(l.operator.toLowerCase().indexOf("in")<0||a.indexOf("in")<0)&&(n.value=[])):"object"==typeof n.value&&null!==n.value&&(n.value=0<n.value.length?n.value[0]:"number"===n.type?0:""),o.previousItemData&&(-1<(s=o.previousItemData.value.toString().toLowerCase()).indexOf("between")||(-1<s.indexOf("in")||-1<s.indexOf("null")||-1<s.indexOf("empty"))&&s.indexOf("contains")<0)&&(t=e.previousElementSibling,l.type=n.type),-1<a.indexOf("in")&&a.indexOf("in")<5&&-1<r.indexOf("in")&&r.indexOf("in")<5&&(t=null),(-1<l.operator.indexOf("null")||-1<l.operator.indexOf("empty"))&&((a=(s=e.parentElement.querySelector(".e-rule-value")).querySelector(".e-tooltip.e-input-group"))&&L.getComponent(a,"tooltip").destroy(),L.removeClass([s],"e-show"),L.addClass([s],"e-hide")),i&&this.getColumn(n.field).template&&(t=e.previousElementSibling),0===i.children.length&&(t=e.previousElementSibling),this.changeRuleValues(t,n,l,o))},q.prototype.changeRuleValues=function(e,t,l,n){var o,i,r,s,a,u,d=L.closest(n.element,".e-rule-operator");e&&(d=e.nextElementSibling,e.classList.contains("e-rule-sub-filter")&&(l.type=this.selectedColumn.type,d=d.classList.contains("e-rule-sub-filter")?d.nextElementSibling:d),L.addClass([d],"e-operator"),d.childElementCount?(s=L.getComponent(d.querySelector(".e-dropdownlist"),"dropdownlist"),l.operator=s.value,i=void 0,i="DropdownTree"===this.fieldMode?L.getComponent(e.querySelector(".e-dropdowntree"),"dropdowntree"):L.getComponent(e.querySelector(".e-dropdownlist"),"dropdownlist"),l.type=("DropdownTree"===this.fieldMode?this.getColumn(i.value[0]):this.getColumn(i.value)).type,e=n.itemData,""!==s.value&&this.renderValues(d,e,n.previousItemData,!0,t,l,n.element)):(i=L.closest(d,".e-rule-container").id,s=this.createElement("input",{attrs:{type:"text",id:i+"_operatorkey"}}),d.appendChild(s),this.selectedColumn.operators?o=this.selectedColumn.operators:n.itemData&&(o=this.customOperators[this.selectedColumn.type+"Operator"]),e=-1<this.element.className.indexOf("e-device")?"250px":"200px",t.operator&&o.forEach(function(e){"value"in e&&"string"==typeof e.value&&e.value.toLowerCase()===t.operator.toLowerCase()&&(r=e.value)}),s=r||o[0].value,a=0,this.autoSelectOperator||(s="",a=-1),u=void((this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.prvtEvtTgrDaD)&&(s=t&&t.operator||s)),u={dataSource:o,fields:{text:"key",value:"value"},placeholder:this.l10n.getConstant("SelectOperator"),popupHeight:5<o.length?e:"auto",change:this.changeField.bind(this),index:a,value:s,open:this.popupOpen.bind(this,!1)},this.operatorModel&&(u=b({},u,this.operatorModel)),new y.DropDownList(u).appendTo("#"+i+"_operatorkey"),l.operator=t&&""!==t.operator&&!L.isNullOrUndefined(t.operator)?t.operator:o[0].value,this.isImportRules&&(l.type=this.selectedColumn.type,l.operator=t.operator),(!L.isNullOrUndefined(s)&&""!==s||this.autoSelectField&&this.autoSelectOperator)&&this.renderValues(d,this.selectedColumn,n.previousItemData,!1,t,l,n.element))),this.isImportRules||this.updateRules(n.element,n.item)},q.prototype.popupOpen=function(e,t){this.enableRtl&&L.addClass([t.popup.element],"e-rtl"),e&&(this.isFieldClose=!1)},q.prototype.destroyControls=function(e,t){for(var l=t?e:e.nextElementSibling,n=l.querySelectorAll("input.e-control"),o=l.querySelectorAll("div.e-control:not(.e-handle)"),i=this.columns,r=0,s=n.length;r<s;r++){if(n[r].classList.contains("e-textbox"))L.getComponent(n[r],"textbox").destroy(),L.detach(L.select("input#"+n[r].id,l));else if(n[r].classList.contains("e-dropdownlist"))this.allowValidation&&-1<n[r].parentElement.className.indexOf("e-tooltip")&&L.getComponent(n[r].parentElement,"tooltip").destroy(),L.getComponent(n[r],"dropdownlist").destroy();else if(n[r].classList.contains("e-radio"))L.getComponent(n[r],"radio").destroy();else if(n[r].classList.contains("e-numerictextbox"))L.getComponent(n[r],"numerictextbox").destroy(),L.detach(L.select("input#"+n[r].id,l));else if(n[r].classList.contains("e-datepicker"))L.getComponent(n[r],"datepicker").destroy();else if(n[r].classList.contains("e-multiselect"))L.getComponent(n[r],"multiselect").destroy();else if(-1<n[r].className.indexOf("e-template"))for(var a=n[r].className,u=0,d=i.length;u<d;u++)if(i[u].template&&-1<a.indexOf(i[u].field)){this.templateDestroy(i[u],n[r].id);break}document.getElementById(n[r].id)&&L.detach(n[r])}for(r=0,s=o.length;r<s;r++){if(-1<o[r].className.indexOf("e-template"))for(a=o[r].className,u=0,d=i.length;u<d;u++)if(i[u].template&&-1<a.indexOf(i[u].field)){this.templateDestroy(i[u],o[r].id);break}L.detach(o[r])}for(var p=l.querySelectorAll(".e-template:not(.e-control)"),r=0,s=p.length;r<s;r++)L.detach(p[r])},q.prototype.templateDestroy=function(e,t){var l,n,o;"string"==typeof e.template&&void 0!==e.template.destroy||(n=(l=e.template).destroy,l.destroy&&(o=void 0,document.getElementById(t)&&(o=L.closest(document.getElementById(t),".e-rule-field").querySelectorAll(".e-template")),"string"==typeof n?(n=L.getValue(n,window))({field:e.field,elementId:t,elements:o}):l.destroy({field:e.field,elementId:t,elements:o})))},q.prototype.getValues=function(e){var t,l={},n=[],o=[],i=(0<this.separator.length&&(o=e.split(this.separator)),this.dataColl);if(this.dataColl[1])for(var r=0,s=i.length;r<s;r++){var a={};if(1<o.length)for(var u,d=i[r],p=0,c=o.length;p<c;p++)u=o[p],o.length===p+1?(t=d[""+u],Number(d[""+u])===d[""+u]&&d[""+u]%1!=0&&(t=d[""+u].toString())):d=d[""+u];else t=i[r][""+e],Number(i[r][""+e])===i[r][""+e]&&i[r][""+e]%1!=0&&(t=i[r][""+e].toString());t in l||((l[""+t]=1)<o.length?this.createNestedObject(a,o,t):a[""+e]=t,n.push(a))}return n},q.prototype.createNestedObject=function(e,t,l){for(var n,o=t.length-1,i=0;i<o;++i)(n=t[i])in e||(e[""+n]={}),e=e[""+n];e[t[o]]=l},q.prototype.getDistinctValues=function(l,n){for(var o={},i=[],r=[],s="",a=n.indexOf(this.separator),u=this,e=0,t=l.length;e<t;e++)!function(t){0===a?s=l[t][""+n]:(r=n.split(u.separator)).forEach(function(e){s=(s||l[t])[""+e]});var e={};(s=Number(l[t][""+n])===l[t][""+n]&&l[t][""+n]%1!=0?l[t][""+n].toString():s)in o||(o[""+s]=1,0===a?e[""+n]=s:e[r[r.length-1]]=s,i.push(e))}(e);return i},q.prototype.renderMultiSelect=function(e,t,l,n,o){var i,r=!1,s=!1,o=(this.isGetNestedData=!1,this.dataColl[1]&&-1<Object.keys(this.dataColl[1]).indexOf(e.field)&&(r=!0,i=this.getDistinctValues(this.dataColl,e.field)),r=!e.columns&&r,s={dataSource:(s=!this.dataColl.length&&o.length?!0:s)?o:r?i:this.dataManager,query:new h.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),open:this.popupOpen.bind(this,!1)},this.valueModel&&this.valueModel.multiSelectModel&&(s=b({},s,this.valueModel.multiSelectModel)),new y.MultiSelect(s));o.appendTo("#"+t+"_valuekey"+l),this.updateRules(o.element,n,0)},q.prototype.multiSelectOpen=function(e,t){var l,n;this.dataSource instanceof h.DataManager&&(e=document.getElementById(e),l=L.getComponent(L.closest(e,".e-rule-container").querySelector(".e-filter-input"),"dropdownlist"),this.selectedColumn=l.getDataByValue(l.value),l=this.selectedColumn.field,n=!1,(n=this.dataColl[1]&&(-1<Object.keys(this.dataColl[1]).indexOf(l)&&(n=!0),0!==l.indexOf(this.separator))&&this.isGetNestedData?!0:n)||(t.cancel=!0,this.bindMultiSelectData(e,l)))},q.prototype.bindMultiSelectData=function(e,t){this.getMultiSelectData(e,t)},q.prototype.getMultiSelectData=function(t,l){var n,o=this,i=new h.Deferred,e=this.dataManager.executeQuery((new h.Query).select(l)),r=L.getComponent(t,"multiselect");r.hideSpinner(),this.createSpinner(L.closest(t,".e-multi-select-wrapper").parentElement),s.showSpinner(L.closest(t,".e-multi-select-wrapper").parentElement),e.then(function(e){n=(e.actual&&e.actual.result?e.actual:e).result,o.dataColl=L.extend(o.dataColl,n,[],!0),r.dataSource=o.getDistinctValues(o.dataColl,l),o.isGetNestedData=!0,s.hideSpinner(L.closest(t,".e-multi-select-wrapper").parentElement)}).catch(function(e){i.reject(e)})},q.prototype.createSpinner=function(e){var t=this.createElement("span",{attrs:{class:"e-qb-spinner"}});e.appendChild(t),s.createSpinner({target:t,width:L.Browser.isDevice?"16px":"14px"})},q.prototype.closePopup=function(e,t){var l,t=document.getElementById(t.popup.element.id.replace("_popup",""));t&&(l=L.getComponent(t,"multiselect"))&&(l=l.value,this.updateRules(t,l,e))},q.prototype.processTemplate=function(e,t,l,n){var e=L.closest(e,".e-rule-container"),o=e.querySelectorAll(".e-template"),i=e.querySelector(".e-rule-filter .e-filter-input"),i="DropdownTree"===this.fieldMode?L.getComponent(i,"dropdowntree"):L.getComponent(e.querySelector(".e-rule-filter .e-filter-input"),"dropdownlist"),i="DropdownTree"===this.fieldMode?this.getColumn(i.value[0]):this.getColumn(i.value);"string"==typeof t.template||void 0===t.template.write?(e={rule:l,ruleID:e.id,operator:n.operator,field:i.field,requestType:"value-template-create"},this.trigger("actionBegin",e)):"string"==typeof(e=t.template).write?L.getValue(e.write,window)({elements:1<o.length?o:o[0],values:l.value,operator:n.operator,field:i.field,dataSource:i.values}):"function"!=typeof t.template&&t.template.write({elements:1<o.length?o:o[0],values:l.value,operator:n.operator,field:i.field,dataSource:i.values})},q.prototype.getItemData=function(e){var t=L.getComponent(document.getElementById(e+"_filterkey"),"dropdownlist"),l=this.element.querySelector("#"+e);return"DropdownTree"===this.fieldMode?t=L.getComponent(document.getElementById(e+"_filterkey"),"dropdowntree"):l&&0<(e=l.querySelectorAll(".e-rule-sub-filter")).length&&(l=e[e.length-1].querySelector(".e-dropdownlist"),t=L.getComponent(l,"dropdownlist")),"DropdownTree"===this.fieldMode?this.getColumn(t.value[0]):this.getColumn(t.value)},q.prototype.setDefaultValue=function(e,t,l){e=this.getItemData(e);if(L.isNullOrUndefined(e.value))return l?t?[0,0]:0:t?[]:"";if(t){if(!(e.value instanceof Array))return[e.value]}else if(e.value instanceof Array)return e.value[0];return e.value},q.prototype.renderStringValue=function(e,t,l,n,o){var i,r=this.getItemData(e),s="string"==typeof r.template,s=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic||s||""!==t.value?t.value:this.setDefaultValue(e,!1,!1);"in"!==l&&"notin"!==l||!this.dataColl.length&&!r.values?("in"!==l&&"notin"!==l||(s=(i=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex?t.value:this.setDefaultValue(e,!0,!1)).join(",")),"between"!==l&&"notbetween"!==l||1<s.length&&(s=s[n]),l=void 0,l={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.textBoxModel&&(l=b({},l,this.valueModel.textBoxModel)),(l=new c.TextBox(l)).appendTo("#"+e+"_valuekey"+n),l.value=s,l.dataBind()):(i=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(r,e,n,i,r.values),"Vertical"===this.displayMode||-1<this.element.className.indexOf("e-device")?o.style.width="100%":(o.style.width=null,o.style.minWidth="200px"))},q.prototype.renderNumberValue=function(e,t,l,n,o,i,r){var s,a,u,d=this.getItemData(e),p="string"==typeof d.template,p=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic||p||"number"==typeof t.value?t.value:this.setDefaultValue(e,!1,!0);"in"!==l&&"notin"!==l||!this.dataColl.length&&!d.values?"in"===l||"notin"===l?(l=(p=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex?t.value:this.setDefaultValue(e,!0,!1)).join(","),s=void 0,s={placeholder:this.l10n.getConstant("SelectValue"),input:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.textBoxModel&&(s=b({},s,this.valueModel.textBoxModel)),(s=new c.TextBox(s)).appendTo("#"+e+"_valuekey"+n),s.value=l,s.dataBind()):(l=(i=d).validation&&i.validation.min?i.validation.min:0,s=i.validation&&i.validation.max?i.validation.max:Number.MAX_VALUE,a=i.format||"n",u=void 0,u={value:(p=1<r&&t?t.value[n]||this.setDefaultValue(e,!0,!0):p)instanceof Array?p[n]:p,format:a,min:l,max:s,width:"100%",step:i.step||1,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.numericTextBoxModel&&(u=b({},u,this.valueModel.numericTextBoxModel)),(r=new c.NumericTextBox(u)).appendTo("#"+e+"_valuekey"+n),r.element.setAttribute("aria-label",i.label+" Value"),r.element.oninput=this.changeValue.bind(this,n)):(p=this.isImportRules||-1<this.ruleIndex||-1<this.groupIndex||this.isPublic?t.value:this.setDefaultValue(e,!0,!1),this.renderMultiSelect(d,e,n,p,d.values),-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?o.style.width="100%":(o.style.minWidth="200px",o.style.width=null))},q.prototype.processValueString=function(e,t){var l=[],n=e.split(",");if("string"===t)return n;for(var o=0,i=n.length;o<i;o++)l.push(Number(n[o]));return l},q.prototype.parseDate=function(e,t){var l;return t?(l=this.intl.getDateParser({skeleton:"full",type:"dateTime"}),t=this.getFormat(t),l=l(e),L.isNullOrUndefined(l)&&(l=this.intl.parseDate(e,t))):l=new Date(e),l},q.prototype.renderControls=function(e,t,l,n,o){if(L.addClass([e.parentElement.querySelector(".e-rule-value")],"e-value"),L.removeClass([e.parentElement.querySelector(".e-rule-value")],"e-hide"),L.addClass([e.parentElement.querySelector(".e-rule-value")],"e-show"),t.template&&(t.template.create||o))this.processTemplate(e,t,l,n);else{var i="boolean"===n.type?this.selectedColumn.values?this.selectedColumn.values.length:2:n.operator&&-1<n.operator.toString().toLowerCase().indexOf("between")?2:1,r=L.closest(e,".e-rule-container").id,s=void 0,a=n.operator.toString();if(-1<e.className.indexOf("e-rule-operator")||-1<e.className.indexOf("e-rule-filter")){s=e.parentElement.querySelector(".e-rule-value"),-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?s.style.width="100%":"in"!==a&&"notin"!==a?L.addClass([s],"e-custom-value"):L.removeClass([s],"e-custom-value");for(var u=0;u<i;u++)switch(n.type){case"string":this.renderStringValue(r,l,a,u,s);break;case"number":this.renderNumberValue(r,l,a,u,s,t,i);break;case"boolean":this.processBoolValues(t,l,r,u);break;case"date":var d=new Date,p=void 0,c=void 0,h=t.format,g=void 0,m=this.l10n.getConstant("SelectValue"),f="string"==typeof t.template;l.value&&!L.isNullOrUndefined(h)&&(p=1<i?l.value[u]:l.value,d=this.parseDate(p,h)||new Date),t.field||t.key||!t.value||(d=t.value instanceof Date?t.value:this.parseDate(t.value,t.format)),!t.format&&l&&""!==l.field&&(h=(c=this.getColumn(l.field)).format),(this.isImportRules||this.isPublic||f)&&l&&(h=(c=this.getColumn(l.field)).format,d=l.value&&(p=1<i?l.value[u]:l.value,this.parseDate(p,c.format))),g=h?(f=this.getFormat(h)).skeleton?{locale:this.getLocale(),value:d,placeholder:m,format:f,change:this.changeValue.bind(this,u)}:{value:d,locale:this.getLocale(),placeholder:m,format:f.format,change:this.changeValue.bind(this,u)}:{locale:this.getLocale(),value:d,placeholder:m,change:this.changeValue.bind(this,u)},this.valueModel&&this.valueModel.datePickerModel&&(g=b({},g,this.valueModel.datePickerModel)),new v.DatePicker(g).appendTo("#"+r+"_valuekey"+u),l.value||(p=document.getElementById(r+"_valuekey"+u),this.updateRules(p,d,null,this.isNotValueChange),this.isNotValueChange=!1)}}}},q.prototype.processBoolValues=function(e,t,l,n){var o,i,r,s,a=!1,t=(L.isNullOrUndefined(t.type)&&e&&(t.type=e.type),e.values?(s=e.values,"boolean"!==t.type||L.isNullOrUndefined(t.value)?e.value?a=s[n].toLowerCase()===e.value.toString().toLowerCase():0===n&&(a=!0):a=s[n].toLowerCase()===t.value.toString().toLowerCase(),i=o=r=s[n]):(s=[!0,!1],"boolean"!==t.type||L.isNullOrUndefined(t.value)?e.value?a=s[n].toString().toLowerCase()===e.value.toString().toLowerCase():0===n&&(a="boolean"!=typeof t.value||!!t.value):a=s[n].toString().toLowerCase()===t.value.toString().toLowerCase(),"boolean"==typeof t.value&&1===n&&(a=!t.value),o=s[n].toString(),i=s[n],r=this.l10n.getConstant(["True","False"][n])),e={label:r,name:l+"default",checked:a,value:o,change:this.changeValue.bind(this,n)},this.valueModel&&this.valueModel.radioButtonModel&&(e=b({},e,this.valueModel.radioButtonModel)),new N.RadioButton(e));t.appendTo("#"+l+"_valuekey"+n),a&&this.updateRules(t.element,i,0,!0)},q.prototype.getOperatorIndex=function(e,t){for(var l=e.dataSource.length,n=0;n<l;n++)if(t.operator===e.dataSource[n].value)return n;return 0},q.prototype.getPreviousItemData=function(e,t){return this.isFieldClose&&(e=e&&this.getColumn(e.value||e.field)),t&&t.template&&e&&Object.keys(e).length<4&&(e.template=t.template),e},q.prototype.renderValues=function(e,t,l,n,o,i,r){var s=e.previousElementSibling.getElementsByTagName("input")[0],s="DropdownTree"===this.fieldMode?L.getComponent(s,"dropdowntree"):L.getComponent(s,"dropdownlist"),s="DropdownTree"===this.fieldMode?this.getColumn(s.value[0]):this.getColumn(s.value),a=(this.selectedRule=s,L.getComponent(e.querySelector("input"),"dropdownlist")),r=(n&&(t=-1<r.id.indexOf("operator")?t:this.selectedRule).operators&&(a.value=null,a.dataBind(),a.dataSource=t.operators,a.index=this.getOperatorIndex(a,o),a.value=i.operator=a.dataSource[a.index].value,this.autoSelectOperator?a.dataBind():(a.index=-1,i.operator=a.value="")),i.operator.toString()),u=!1;if(-1<r.indexOf("null")||-1<r.indexOf("isempty")||-1<r.indexOf("isnotempty"))(c=e.parentElement.querySelector(".e-rule-value"))&&(L.removeClass([c],"e-show"),L.addClass([c],"e-hide"));else{var d,p=L.closest(e,".e-rule-container").id;if((l=this.getPreviousItemData(l,s))&&void 0===l.template?l.columns&&(l=this.getColumn(o.field)):"DropdownTree"===this.fieldMode&&void 0===l&&(l=this.getColumn(o.field)),l&&l.template&&(this.templateDestroy(l,p+"_valuekey0"),(d=L.select("#"+p+"_valuekey0",e.nextElementSibling))&&!d.classList.contains("e-control")&&L.detach(L.select("#"+p+"_valuekey0",e.nextElementSibling)),"string"!=typeof l.template&&void 0!==l.template.create||(e.nextElementSibling.classList.contains("e-template-value")&&this.clearQBTemplate([p]),e.nextElementSibling.innerHTML=""),this.isAngular)&&!L.isNullOrUndefined(l.key)&&"DropdownTree"===this.fieldMode&&delete l.template,n&&(this.validateValue(o,L.closest(e,".e-rule-container")),this.destroyControls(e)),this.isImportRules||a&&""!==a.value){if(s&&(t.template=s.template),t.template&&(L.addClass([e.nextElementSibling],"e-template-value"),t.template=s.template,u=this.setColumnTemplate(t,p,s.field,t.value||r,e,o)),u){var c=e.parentElement.querySelector(".e-rule-value");-1<this.element.className.indexOf("e-device")||"Vertical"===this.displayMode?c.style.width="100%":c.style.width="200px"}else{L.removeClass([e.nextElementSibling],"e-template-value");for(var h=1,h="boolean"===i.type?this.selectedColumn.values?this.selectedColumn.values.length:2:r&&-1<r.toLowerCase().indexOf("between")?2:1,g=0;g<h;g++){var m=this.createElement("input",{attrs:{type:"text",id:p+"_valuekey"+g}});e.nextElementSibling.appendChild(m)}}this.renderControls(e,t,o,i,u),this.isAngular&&!L.isNullOrUndefined(t.key)&&t.template&&"DropdownTree"===this.fieldMode&&delete t.template}}},q.prototype.setColumnTemplate=function(t,l,n,e,o,i){var r=this,s=!0;if(t.template){if("string"==typeof t.template||void 0===t.template.create)return this.trigger("actionBegin",{requestType:"value-template-initialize",ruleID:l,field:n,operator:e,rule:i,renderTemplate:!0},function(e){s=r.actionBeginSuccessCallBack(e,t,l,n,o)}),s;var a=void 0,i=t.template;if((a="string"==typeof i.create?L.getValue(i.create,window)({field:n,operator:e}):i.create({field:n,operator:e}))instanceof Element)a.id=l+"_valuekey0",L.addClass([a],"e-template"),o.nextElementSibling.appendChild(a),n.indexOf(" ")<0&&L.addClass([a],"e-"+n);else if(a instanceof Array){L.addClass(a,"e-template");for(var u=0,d=a.length;u<d;u++)a[u].id=l+"_valuekey"+u,o.nextElementSibling.appendChild(a[u])}L.addClass([o.nextElementSibling],"e-template-value")}return!0},q.prototype.actionBeginSuccessCallBack=function(e,t,l,n,o){var i;return!!e.renderTemplate&&(i=void 0,this.columnTemplateFn=this.templateParser((t.template,t.template)),t=this.element.id+n,this.isReact?(i=this.columnTemplateFn(e,this,l,t)[0],o.nextElementSibling.appendChild(i)):this.isAngular?(i=3===(n=this.columnTemplateFn(e,this,l,t))[0].nodeType?n[1]:n[0],o.nextElementSibling.appendChild(i)):this.isVue3?(i=this.columnTemplateFn(e,this,"Template",t),L.append(i,o.nextElementSibling)):(i=this.columnTemplateFn(e,this,"Template",t)[0],o.nextElementSibling.appendChild(i)),L.addClass([o.nextElementSibling],"e-template-value"),this.renderReactTemplates(),!0)},q.prototype.updateValues=function(e,t){var l,n,o=1,i=(-1<e.className.indexOf("e-template")&&(o=3),e.className.split(" e-")[o]),r=parseInt(e.id.slice(-1),2);switch(i){case"checkbox":n=L.getComponent(e,i).value,t.value=""!==n?n:void 0;break;case"textbox":case"dropdownlist":t.value=L.getComponent(e,i).value;break;case"radio":(n=L.getComponent(e,i)).checked&&("boolean"!=typeof t.value&&this.getColumn(t.field).values?t.value=n.value:t.value="true"===n.value),n.refresh();break;case"numerictextbox":-1<t.operator.indexOf("between")?("string"==typeof t.value&&(t.value=[]),t.value[r]=L.getComponent(e,i).value):t.value=L.getComponent(e,i).value;break;case"datepicker":n=this.getColumn(t.field),n=this.getFormat(n.format),l=L.getComponent(e,i).value,-1<t.operator.indexOf("between")?("string"==typeof t.value&&(t.value=[]),t.value[r]=this.intl.formatDate(l,n)):L.isNullOrUndefined(n.format)&&l?t.value=this.intl.formatDate(l):t.value=l&&this.intl.formatDate(l,n);break;case"multiselect":t.value=L.getComponent(e,i).value}},q.prototype.updateRules=function(e,t,l,n){for(var o=L.closest(e,".e-group-container"),i=this.getParentGroup(o),r=L.closest(e,".e-rule-container"),s=0,a=o.id.replace(this.element.id+"_",""),u=this.getValidRules(this.rule);r&&null!==r.previousElementSibling;)r=r.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!r.classList.contains("e-btn-group")||this.headerTemplate&&(r.classList.contains("e-rule-container")||r.classList.contains("e-group-container"))))&&s++;var d=i.rules[s].operator?i.rules[s].operator.toString():"",p=(r=L.closest(e,".e-rule-container")).id.replace(this.element.id+"_","");if(L.closest(e,".e-rule-filter")||L.closest(e,".e-rule-sub-filter")){this.subFieldElem&&(e=this.subFieldElem);var c="DropdownTree"===this.fieldMode?L.getComponent(e,"dropdowntree"):L.getComponent(e,"dropdownlist"),h="DropdownTree"===this.fieldMode?this.getColumn(c.value[0]):this.getColumn(c.value),h=(this.isImportRules||!i.rules[s].field||i.rules[s].field.toLowerCase()===h.field.toLowerCase()||(!(r.querySelectorAll(".e-template")||-1<d.indexOf("null"))||-1<d.indexOf("empty"))&&(i.rules[s].value=""),this.selectedColumn=this.getColumn(this.selectedColumn.field),i.rules[s].field=this.selectedColumn.field,i.rules[s].type=this.selectedColumn.type,i.rules[s].label=this.selectedColumn.label,L.closest(e,".e-rule-filter")),g=(h=h||L.closest(e,".e-rule-sub-filter")).nextElementSibling.querySelector("input.e-control")||h.nextElementSibling.nextElementSibling.querySelector("input.e-control"),d=L.getComponent(g,"dropdownlist").value.toString(),g=(i.rules[s].operator=d,h.nextElementSibling.nextElementSibling),m=g.querySelectorAll("input.e-control");(m=m.length<1?g.querySelectorAll("div.e-control"):m).length<1&&(m=g.querySelectorAll(".e-template"));for(var h={groupID:a,ruleID:p,value:i.rules[s].field,type:"field"},f=0;f<m.length;f++)-1<d.indexOf("null")||-1<d.indexOf("empty")?i.rules[s].value=null:this.updateValues(m[f],i.rules[s]);this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",h),this.allowValidation&&i.rules[s].field&&-1<e.parentElement.className.indexOf("e-tooltip")&&L.getComponent(e.parentElement,"tooltip").destroy(),this.filterRules(u,this.getValidRules(this.rule),"field")}else if(L.closest(e,".e-rule-operator")){c=L.getComponent(e,"dropdownlist"),i.rules[s].operator=c.value.toString();var y=r.querySelectorAll(".e-rule-value input.e-control");h={groupID:a,ruleID:p,value:c.value,type:"operator"},this.allowValidation&&i.rules[s].operator&&-1<e.parentElement.className.indexOf("e-tooltip")&&L.getComponent(e.parentElement,"tooltip").destroy(),1<y.length&&!(-1<y[0].className.indexOf("e-template"))&&(i.rules[s].value=[]);for(var v=0;v<y.length;v++)-1<i.rules[s].operator.indexOf("null")||-1<i.rules[s].operator.indexOf("empty")?i.rules[s].value=null:y[v].classList.contains("e-template")||this.updateValues(y[v],i.rules[s]);this.isImportRules||this.trigger("change",h),this.filterRules(u,this.getValidRules(this.rule),"operator")}else L.closest(e,".e-rule-value")&&(this.ruleValueUpdate(e,t,i,s,o,r,l),n||this.filterRules(u,this.getValidRules(this.rule),"value"))},q.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.prvtEvtTgrDaD||this.trigger("ruleChange",{previousRule:e,rule:t,type:l})},q.prototype.ruleValueUpdate=function(e,t,l,n,o,i,r){var s,a=["in","between","notin","notbetween"];if(l.rules[n].operator&&(s=l.rules[n].operator.toString().toLowerCase()),null!==t){if(-1<e.className.indexOf("e-multiselect")&&"number"===l.rules[n].type&&!this.isNotified){for(var u=[],d=t,p=0,c=d.length;p<c;p++)"string"==typeof d[p]&&u.push(parseFloat(d[p]));u.length&&(t=u)}this.isNotified?(l.rules[n].value=t,o={groupID:o.id,ruleID:i.id,value:l.rules[n].value,type:"value"},this.isImportRules||this.trigger("change",o)):-1<e.className.indexOf("e-spin")||-1<e.className.indexOf("e-numeric")?-1<a.indexOf(s)?l.rules[n].value[r]=t:l.rules[n].value=t:-1<e.className.indexOf("e-radio")||-1<e.className.indexOf("e-multiselect")?l.rules[n].value=t:-1<e.className.indexOf("e-textbox")?"in"===s||"notin"===s?(l.rules[n].type,l.rules[n].value=this.processValueString(t,l.rules[n].type)):"between"===s||"notbetween"===s?("string"==typeof l.rules[n].value&&(l.rules[n].value=[]),l.rules[n].value[r]=t):l.rules[n].value=t:-1<e.className.indexOf("e-datepicker")&&(o=this.getFormat(this.getColumn(this.selectedColumn.field).format)).type&&(-1<a.indexOf(s)?("string"==typeof l.rules[n].value&&(l.rules[n].value=[]),l.rules[n].value[r]=this.intl.formatDate(t,o)):l.rules[n].value=this.intl.formatDate(t,o)),this.validateValue(l,i,n)}else-1<e.className.indexOf("e-datepicker")&&-1<a.indexOf(s)?("string"==typeof l.rules[n].value&&(l.rules[n].value=[]),l.rules[n].value[r]=t):l.rules[n].value=t},q.prototype.validateValue=function(e,t,l){var n="object"==typeof(e=L.isNullOrUndefined(l)?e:e.rules[l]).value;this.allowValidation&&(L.isNullOrUndefined(l)||(n?0<e.value.length:e.value))&&0<(l=t.querySelectorAll(".e-rule-value .e-control")).length&&(-1<l[0].className.indexOf("e-tooltip")?L.getComponent(l[0],"tooltip").destroy():-1<l[0].parentElement.className.indexOf("e-tooltip")&&L.getComponent(l[0].parentElement,"tooltip").destroy(),l[1]&&-1<l[1].parentElement.className.indexOf("e-tooltip")&&L.getComponent(l[1].parentElement,"tooltip").destroy(),l[2])&&-1<l[2].parentElement.className.indexOf("e-tooltip")&&L.getComponent(l[2].parentElement,"tooltip").destroy()},q.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},q.prototype.findGroupByIdx=function(e,t,l){var n=t.rules,o=[];if(l)return t;for(var i=0,r=n.length;i<r;i++)(t=n[i]).rules&&o.push(t);return o[e]},q.prototype.destroy=function(){var e,t,l,n;if(this.isDestroy=!0,this.element){for(x.prototype.destroy.call(this),l=(e=this.element.querySelectorAll(".e-addrulegroup")).length,t=0;t<l;t++)L.getComponent(e[t],"dropdown-btn").destroy(),L.detach(e[t]);for(n=this.element.querySelectorAll(".e-rule-filter .e-control.e-tooltip"),t=0;t<n.length;t++)L.getComponent(n[t],"tooltip").destroy();for(l=(e=this.element.querySelectorAll(".e-rule-filter .e-control:not(.e-tooltip)")).length,t=0;t<l;t++)(L.getComponent(e[t],"dropdownlist")?L.getComponent(e[t],"dropdownlist"):L.getComponent(e[t],"dropdowntree")).destroy(),L.detach(e[t]);for(n=this.element.querySelectorAll(".e-rule-operator .e-control.e-tooltip"),t=0;t<n.length;t++)L.getComponent(n[t],"tooltip").destroy();for(l=(e=this.element.querySelectorAll(".e-rule-operator .e-control:not(.e-tooltip)")).length,t=0;t<l;t++)L.getComponent(e[t],"dropdownlist")&&(L.getComponent(e[t],"dropdownlist").destroy(),L.detach(e[t]));for(n=this.element.querySelectorAll(".e-rule-value .e-control.e-tooltip"),t=0;t<n.length;t++)L.getComponent(n[t],"tooltip").destroy();this.isImportRules=!1,this.unWireEvents(),this.levelColl[this.element.id+"_group0"]=[0],this.element.innerHTML="",this.portals&&this.portals.length&&this.clearQBTemplate();var o=document.querySelectorAll(".qb-dropdownlist.e-popup");if(o)for(t=0;t<o.length;t++)o[t].remove();L.classList(this.element,[],["e-rtl","e-responsive","e-device"]),this.isDestroy=!1}},q.prototype.addRules=function(e,t){t=this.element.id+"_"+t,this.isPublic=!0;for(var l=0,n=e.length;l<n;l++)this.addRuleElement(document.getElementById(t),e[l]);this.isPublic=!1},q.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),t=this.getParentGroup(l);if(e.length){this.isPublic=!0;for(var n=0,o=e.length;n<o;n++)this.updatedRule={isLocked:e[n].isLocked,condition:e[n].condition,not:e[n].not},this.importRules(e[n],l,!1,e[n].not);this.isPublic=!1}else{var i="and",r=!1,s=!1;this.updatedRule&&(i=this.updatedRule.condition,r=this.updatedRule.not,s=this.updatedRule.isLocked),this.groupIndex<0?this.enableNotCondition?t.rules.push({condition:i,not:r,rules:[]}):t.rules.push({condition:i,rules:[]}):this.enableNotCondition?t.rules.splice(this.groupIndex+1,0,{condition:i,not:r,rules:[],isLocked:s}):t.rules.splice(this.groupIndex+1,0,{condition:i,rules:[],isLocked:s})}this.headerTemplate||this.disableRuleCondition(l,t,null,!!this.enableSeparateConnector||null)}},q.prototype.initWrapper=function(){if(this.isInitialLoad=!0,this.cssClass&&L.addClass([this.element],this.cssClass.replace(/\s+/g," ").trim().split(" ")),this.enableSeparateConnector&&L.addClass([this.element],"e-multi-connector"),this.enableRtl&&L.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),L.Browser.isDevice||"Vertical"===this.displayMode?(L.Browser.isDevice&&(this.element.style.width="100%",this.element.classList.add("e-device")),L.removeClass(this.element.querySelectorAll(".e-rule-container"),"e-horizontal-mode"),L.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{this.columns&&this.columns.length&&this.isImportRules?(this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not,!1,this.rule),e=L.extend({},this.rule,{},!0),this.isRefreshed=!0,this.setGroupRules(e),this.isRefreshed=!1):this.columns&&this.columns.length&&this.addRuleElement(this.element.querySelector(".e-group-container"),{}),this.notGroupRtl(),this.readonly&&this.enableReadonly();for(var e,t,l=this.element.querySelectorAll("label.e-btn"),n=0;n<l.length;n++)t=l.item(n),L.rippleEffect(t,{selector:".e-btn"})}},q.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:{type:"button",class:"e-edit-rule e-css e-btn e-small e-flat e-primary"}}),n=this.createElement("div",{attrs:{class:"e-summary-btndiv"}});e.appendChild(t),t.textContent=this.getSqlFromRules(this.rule),l.textContent=this.l10n.getConstant("Edit"),n.appendChild(l),e.appendChild(n),this.element.appendChild(e)},q.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)},q.prototype.columnSort=function(){"descending"===this.sortDirection.toLowerCase()?this.columns=new h.DataManager(this.columns).executeLocal((new h.Query).sortByDesc("field")):"ascending"===this.sortDirection.toLowerCase()&&(this.columns=new h.DataManager(this.columns).executeLocal((new h.Query).sortBy("field")))},q.prototype.onChangeNotGroup=function(){var e;this.element.innerHTML="",this.groupIdCounter=0,this.headerTemplate||(this.enableNotCondition?(e=this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),this.groupElem.querySelector(".e-btn-group")&&this.groupElem.querySelector(".e-btn-group").insertBefore(e,this.groupElem.querySelector(".e-btngroup-and"))):this.groupElem.querySelector(".e-qb-toggle").remove()),this.setProperties({rule:this.checkNotGroup(this.rule)},!0),this.initWrapper()},q.prototype.notGroupRtl=function(){this.enableRtl?L.addClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl"):L.removeClass(this.element.querySelectorAll(".e-btn-group"),"e-rtl")},q.prototype.checkNotGroup=function(e){var t;if(e.rules)for(var l=0;l<e.rules.length;l++)t=e.rules[l],t=this.checkNotGroup(t),e.rules[l]=t;return L.isNullOrUndefined(e.not)?this.enableNotCondition&&!L.isNullOrUndefined(e.condition)&&(e.not=!1):(this.enableNotCondition&&(e.not=!1),delete e.not),e},q.prototype.onPropertyChanged=function(e,t){for(var l=Object.keys(e),n=this.element.querySelector(".e-group-container"),o=this.element.querySelector(".e-summary-content"),i=0,r=l;i<r.length;i++)switch(r[i]){case"summaryView":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"):(-1<n.querySelectorAll(".e-collapse-rule").length&&this.renderSummaryCollapse(),n.style.display="block",o.style.display="none");break;case"displayMode":this.refresh();break;case"showButtons":L.isNullOrUndefined(e.showButtons.lockGroup)||(e.showButtons.lockGroup?L.removeClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"):L.addClass(this.element.querySelectorAll(".e-lock-grp-btn"),"e-button-hide")),L.isNullOrUndefined(e.showButtons.lockRule)||(e.showButtons.lockRule?L.removeClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"):L.addClass(this.element.querySelectorAll(".e-lock-rule-btn"),"e-button-hide")),L.isNullOrUndefined(e.showButtons.cloneGroup)||(e.showButtons.cloneGroup?L.removeClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"):L.addClass(this.element.querySelectorAll(".e-clone-grp-btn"),"e-button-hide")),L.isNullOrUndefined(e.showButtons.cloneRule)||(e.showButtons.cloneRule?L.removeClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"):L.addClass(this.element.querySelectorAll(".e-clone-rule-btn"),"e-button-hide")),L.isNullOrUndefined(e.showButtons.ruleDelete)||(e.showButtons.ruleDelete?L.removeClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide"):L.addClass(this.element.querySelectorAll(".e-rule-delete"),"e-button-hide")),L.isNullOrUndefined(e.showButtons.groupDelete)||(e.showButtons.groupDelete?L.removeClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"):L.addClass(this.element.querySelectorAll(".e-deletegroup"),"e-button-hide"));break;case"cssClass":t.cssClass&&L.removeClass([this.element],t.cssClass.split(" ")),e.cssClass&&L.addClass([this.element],e.cssClass.replace(/\s+/g," ").trim().split(" "));break;case"enableRtl":e.enableRtl?L.addClass([this.element],"e-rtl"):L.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(),this.updateSubFieldsFromColumns(this.columns);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":0!==this.rule.rules.length||L.isNullOrUndefined(this.rule)||this.reset(),this.setProperties({rule:e.rule},!0),e.rule=this.getRuleCollection(this.rule,!1),this.setRules(this.rule);break;case"width":this.width=e.width,this.element.style.width=this.width;break;case"locale":this.locale=e.locale,this.intl=new L.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();break;case"allowDragAndDrop":this.allowDragAndDrop=e.allowDragAndDrop,this.refresh();break;case"enableSeparateConnector":this.enableSeparateConnector=e.enableSeparateConnector,this.refresh()}},q.prototype.preRender=function(){this.element.id=this.element.id||L.getUniqueID("ej2-querybuilder"),this.defaultLocale={StartsWith:"Starts With",DoesNotStartWith:"Does Not Start With",EndsWith:"Ends With",DoesNotEndWith:"Does Not End With",Contains:"Contains",DoesNotContain:"Does Not Contain",NotLike:"Not Like",Like:"Like",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",CloneGroup:"Clone Group",LockGroup:"Lock Group",CloneRule:"Clone Rule",LockRule:"Lock Rule",UnlockRule:"Unlock Rule",UnlockGroup:"Unlock Group"},this.l10n=new L.L10n("querybuilder",this.defaultLocale,this.locale),this.intl=new L.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:"notstartswith",key:this.l10n.getConstant("DoesNotStartWith")},{value:"endswith",key:this.l10n.getConstant("EndsWith")},{value:"notendswith",key:this.l10n.getConstant("DoesNotEndWith")},{value:"contains",key:this.l10n.getConstant("Contains")},{value:"notcontains",key:this.l10n.getConstant("DoesNotContain")},{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")},{value:"between",key:this.l10n.getConstant("Between")},{value:"notbetween",key:this.l10n.getConstant("NotBetween")}],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.sqlOperators={equal:"=",notequal:"!=",greaterthan:">",greaterthanorequal:">=",lessthan:"<",in:this.l10n.getConstant("In").toUpperCase(),notin:this.l10n.getConstant("NotIn").toUpperCase(),lessthanorequal:"<=",startswith:this.l10n.getConstant("Like").toUpperCase(),endswith:this.l10n.getConstant("Like").toUpperCase(),between:this.l10n.getConstant("Between").toUpperCase(),notbetween:this.l10n.getConstant("NotBetween").toUpperCase(),contains:this.l10n.getConstant("Like").toUpperCase(),isnull:this.l10n.getConstant("IsNull").toUpperCase(),isnotnull:this.l10n.getConstant("IsNotNull").toUpperCase(),isempty:this.l10n.getConstant("IsEmpty").toUpperCase(),isnotempty:this.l10n.getConstant("IsNotEmpty").toUpperCase(),notstartswith:this.l10n.getConstant("NotLike").toUpperCase(),notendswith:this.l10n.getConstant("NotLike").toUpperCase(),notcontains:this.l10n.getConstant("NotLike").toUpperCase()},this.fields||(this.fields={text:"label",value:"field"})},q.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 h.DataManager?(this.dataManager=this.dataSource,this.executeDataManager((new h.Query).take(1))):(this.dataManager=new h.DataManager(this.dataSource),this.dataColl=this.dataManager.executeLocal(new h.Query),this.initControl()),this.renderComplete(),this.allowDragAndDrop&&this.initializeDrag()},q.prototype.initializeDrag=function(){this.draggable=new L.Draggable(this.element,{dragTarget:".e-drag-qb-rule",distance:5,helper:this.helper.bind(this),dragStart:this.dragStartHandler.bind(this),drag:this.dragHandler.bind(this),dragStop:this.dragStopHandler.bind(this),isReplaceDragEle:!0,isPreventSelect:!1,abort:".e-parent-header",isDragScroll:!0})},q.prototype.helper=function(e){var t,l,n,o=this.draggable.currentStateTarget;return!(!o.classList.contains("e-drag-qb-rule")||o.classList.contains("e-drag-qb-rule")&&L.closest(o,".e-disable"))&&(t=this.createElement("div",{className:"e-cloneproperties e-draganddrop e-dragclone",styles:'height:"auto", z-index:2, width:'+this.element.offsetWidth}),(this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(l=L.closest(o,".e-group-container").cloneNode(!0),L.closest(o,".e-group-container")):(t.classList.add("e-group-body"),l=this.createElement("div",{className:"e-rule-container"}),n=L.closest(o,".e-rule-field").cloneNode(!0),l.appendChild(n),L.closest(o,".e-rule-field"))).classList.add("e-qb-dragging-rule"),t.appendChild(l),t.querySelectorAll("*").forEach(function(e){e.removeAttribute("id")}),this.element.appendChild(t),t)},q.prototype.dragStartHandler=function(e){this.draggedRule=e.target,this.isDragEventPrevent=!1,document.body.classList.add("e-prevent-select"),this.dragElement=e.dragElement;var t=L.closest(e.target,".e-rule-container"),e=L.closest(e.target,".e-group-container"),t={dragRuleID:(null!==t?t:e).id,dragGroupID:e.id,cancel:!1};this.trigger("dragStart",t),this.isDragEventPrevent=t.cancel},q.prototype.dragHandler=function(e){var t,l,n,o,i,r,s;this.isDragEventPrevent||(this.element.querySelectorAll(".e-drag-rule-bottom-line").forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),this.element.querySelectorAll(".e-drag-rule-top-line").forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),L.isNullOrUndefined(e.target))||("HTML"===e.target.nodeName||L.closest(e.target,".e-qb-dragging-rule")||L.closest(e.target,".e-group-header")||!L.closest(e.target,"#"+this.element.id)||L.closest(e.target,".e-disable")||e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")&&this.enableSeparateConnector?this.dragElement.classList.add("e-notallowedcur"):(this.dragElement.classList.remove("e-notallowedcur"),t=L.closest(e.target,".e-rule-container"),r=L.closest(e.target,".e-group-container"),t?(l=t.getBoundingClientRect(),s=(n=e.event.clientY||e.event.changedTouches[0].clientY)-l.top,o=l.bottom-n,s<(i=20)?t.classList.add("e-drag-rule-top-line"):o<i&&t.classList.add("e-drag-rule-bottom-line")):e.target.classList.contains("e-rule-list")&&0===e.target.children.length?e.target.classList.add("e-drag-rule-bottom-line"):e.target.classList.contains("e-rule-list")&&e.target.children[0].classList.contains("e-group-container")?(l=e.target.children[0].getBoundingClientRect(),(s=(n=e.event.clientY||e.event.changedTouches[0].clientY)-l.top)<(i=20)&&e.target.classList.add("e-drag-rule-top-line")):(L.closest(e.target,".e-group-container")||e.target.classList.contains("e-group-container"))&&-1<(r=r||e.target).id.indexOf("group0")&&(l=e.target.getBoundingClientRect(),n=e.event.clientY||e.event.changedTouches[0].clientY,(o=l.bottom-n)<(i=20))&&e.target.classList.add("e-drag-rule-bottom-line"),s={dragRuleID:null!==t?t.id:null!==r?r.id:null,dragGroupID:null!==r?r.id:null,cancel:!1},this.trigger("drag",s),this.isDragEventPrevent=s.cancel))},q.prototype.dragStopHandler=function(e){var t=this;if(!this.isDragEventPrevent){var l,n,o,i,r=L.closest(e.target,".e-rule-container"),s=(L.isNullOrUndefined(r)&&e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")&&this.enableSeparateConnector&&(r=L.closest(e.target.parentElement.previousElementSibling,".e-rule-container")),(l=L.isNullOrUndefined(e.helper)?l:L.closest(e.helper,".e-notallowedcur"))||(n=L.closest(e.target,".e-group-container"),n={cancel:!1,dropRuleID:null!==r?r.id:null!==n?n.id:null,dropGroupID:null!==n?n.id:null},this.trigger("drop",n),n.cancel&&(l=!0),n=this.getValidRules()),this.prvtEvtTgrDaD=!0,this.enableSeparateConnector&&e.target.parentElement&&e.target.parentElement.classList.contains("e-btn-group")?e.target.parentElement.previousElementSibling:e.target);if(r&&!l){var a=r.id.split(this.element.id+"_")[1].split("_")[0];if(this.draggable.currentStateTarget.parentElement.classList.contains("e-rule-field")||this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")){var u,d=void 0;this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(L.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),(u=L.extend([],this.getGroup(r),[],!0)).properties&&(u=u.properties);(p=L.closest(r,".e-group-container")).querySelectorAll(".e-group-container").forEach(function(e){t.element.querySelector("#"+e.id)&&t.deleteGroup(e)});for(var p,c=p.querySelectorAll(".e-rule-container"),h=[],g=void 0,m=0;m<c.length;m++)(c[m].classList.contains("e-drag-rule-top-line")||c[m].classList.contains("e-drag-rule-bottom-line"))&&(g=m),h.push(c[m].id.split(this.element.id+"_")[1]);this.deleteRules(h),r.classList.contains("e-drag-rule-top-line")?u.rules.splice(g,0,d):u.rules.splice(g+1,0,d),u.rules.forEach(function(e){t.enableSeparateConnector?e.rules?t.addGroups([e],a):t.addRules([e],a):e.condition?t.addGroups([e],a):t.addRules([e],a)})}}else s.classList.contains("e-rule-list")&&0===s.children.length&&!l?(i=(p=L.closest(s,".e-group-container")).id.split(this.element.id+"_")[1].split("_")[0],d=void 0,this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(L.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),this.enableSeparateConnector?d.rules?this.addGroups([d],i):this.addRules([d],i):d.condition?this.addGroups([d],i):this.addRules([d],i)):s.classList.contains("e-rule-list")&&s.children[0].classList.contains("e-group-container")&&!l?(o=(p=L.closest(s,".e-group-container")).id.split(this.element.id+"_")[1].split("_")[0],d=void 0,this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(L.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),(u=L.extend([],this.getGroup(s),[],!0)).properties&&(u=u.properties),s.querySelectorAll(".e-group-container").forEach(function(e){t.element.querySelector("#"+e.id)&&t.deleteGroup(e)}),(c=p.querySelectorAll(".e-rule-container")).forEach(function(e){t.element.querySelector("#"+e.id)&&t.deleteRule(e)}),this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?this.addGroups([d],o):this.addRules([d],o),u.rules.forEach(function(e){t.enableSeparateConnector?e.rules?t.addGroups([e],o):t.addRules([e],o):e.condition?t.addGroups([e],o):t.addRules([e],o)})):!L.closest(e.target,".e-group-container")&&!e.target.classList.contains("e-group-container")||l||(d=void 0,"group0"===(i=(r=!(r=L.closest(e.target,".e-group-container"))&&e.target.classList.contains("e-group-container")?e.target:r).id.split(this.element.id+"_")[1].split("_")[0])&&(this.draggable.currentStateTarget.parentElement.classList.contains("e-group-header")?(d=this.getGroup(this.draggedRule),this.deleteGroup(L.closest(this.draggedRule,".e-group-container"))):(d=this.getRule(this.draggedRule),this.deleteRule(this.draggedRule)),this.enableSeparateConnector?d.rules?this.addGroups([d],i):this.addRules([d],i):d.condition?this.addGroups([d],i):this.addRules([d],i)));l||this.trigger("ruleChange",{previousRule:n,rule:this.getValidRules(),type:"drag-and-drop"}),this.prvtEvtTgrDaD=!1,document.body.classList.remove("e-prevent-select");s=this.element.querySelectorAll(".e-drag-rule-bottom-line");s.forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),(s=this.element.querySelectorAll(".e-drag-rule-top-line")).forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),(s=this.element.querySelectorAll(".e-qb-dragging-rule")).forEach(function(e){e.classList.remove("e-qb-dragging-rule")}),e.helper&&e.helper.classList.contains("e-cloneproperties")&&document.querySelector("."+e.helper.classList[0])&&L.remove(e.helper),this.enableSeparateConnector&&this.refresh()}},q.prototype.templateParser=function(t){if(t)try{return"function"!=typeof t&&document.querySelectorAll(t).length?L.compile(document.querySelector(t).innerHTML.trim()):L.compile(t)}catch(e){return L.compile(t)}},q.prototype.executeDataManager=function(e){var t=this,e=this.dataManager.executeQuery(e),l=new h.Deferred;e.then(function(e){e.actual&&e.actual.result?t.dataColl=e.actual.result:t.dataColl=e.result,t.initControl()}).catch(function(e){l.reject(e)})},q.prototype.initControl=function(){this.initialize(),this.initWrapper(),this.wireEvents()},q.prototype.wireEvents=function(){var e=this.getWrapper();L.EventHandler.add(e,"click",this.clickEventHandler,this),L.EventHandler.add(e,"focusout",this.focusEventHandler,this),L.EventHandler.add(e,"focusin",this.focusEventHandler,this),L.EventHandler.add(this.element,"keydown",this.keyBoardHandler,this),L.EventHandler.add(document,"keydown",this.keyBoardHandler,this)},q.prototype.unWireEvents=function(){var e=this.getWrapper();L.EventHandler.remove(e,"click",this.clickEventHandler),L.EventHandler.remove(e,"focusout",this.focusEventHandler),L.EventHandler.remove(e,"focusin",this.focusEventHandler),L.EventHandler.remove(this.element,"keydown",this.keyBoardHandler),L.EventHandler.remove(document,"keydown",this.keyBoardHandler)},q.prototype.getParentGroup=function(e,t){for(var l=e instanceof Element?this.levelColl[e.id]:this.levelColl[""+e],n=t?l.length-1:l.length,o=this.rule,i=0;i<n;i++)o=this.findGroupByIdx(l[i],o,0===i);return o},q.prototype.deleteGroup=function(t){var l=this,e=t,n=("string"==typeof t?(n=this.element.id+"_"+t,t=document.getElementById(n),n):e.id).replace(this.element.id+"_","");"group0"!==n&&t&&(e={groupID:n,cancel:!1,type:"deleteGroup"},this.isImportRules||this.prvtEvtTgrDaD?this.deleteGroupSuccessCallBack(e,t):this.trigger("beforeChange",e,function(e){l.deleteGroupSuccessCallBack(e,t)}))},q.prototype.deleteGroupSuccessCallBack=function(e,t){if(!e.cancel){for(var l=t,n=this.getParentGroup(l,!0),o=0,i=void 0,r=void 0,s=this.getValidRules(this.rule),a=l.nextElementSibling,u=l.previousElementSibling,d=l.querySelectorAll(".e-group-container"),p=l.querySelectorAll(".e-tooltip"),r=p.length,i=0;i<r;i++)L.getComponent(p[i],"tooltip").destroy();for(i=0,r=d.length;i<r;i++)delete this.levelColl[d[i].id];for(;null!==l.previousElementSibling;)l=l.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!l.classList.contains("e-btn-group")||this.headerTemplate&&(l.classList.contains("e-rule-container")||l.classList.contains("e-group-container"))))&&o++;this.enableSeparateConnector||a&&-1<a.className.indexOf("e-separate-rule")&&(L.removeClass([a],"e-separate-rule"),L.addClass([a],"e-joined-rule"),u)&&-1<u.className.indexOf("e-rule-container")&&L.addClass([u],"e-prev-joined-rule");var a=l.parentElement.parentElement.parentElement,c=[];if(this.isReact||this.isAngular){var h=n.rules[o],g=t.querySelectorAll(".e-rule-container");if(h&&h.rules)for(var m=0;m<h.rules.length;m++){var f,y=this.getColumn(h.rules[m].field);g[m]&&(f=g[m].querySelector(".e-template-value"),y)&&(y.ruleTemplate||this.isPlatformTemplate(y)&&f)&&c.push(g[m].id)}}L.detach(t),this.headerTemplate&&this.clearQBTemplate([t.id]),c.length&&this.clearQBTemplate(c),n.rules.splice(o,1),delete this.levelColl[e.groupID],this.refreshLevelColl(),this.disableRuleCondition(a,n),this.enableSeparateConnector&&u&&(!this.headerTemplate&&u.classList.contains("e-btn-group")||this.headerTemplate&&u.classList.contains("e-custom-group-btn"))&&L.detach(u),this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",e),this.filterRules(s,this.getValidRules(this.rule),"deleteGroup")}},q.prototype.isPlatformTemplate=function(e){return e.template&&("string"==typeof e.template||void 0===e.template.create)},q.prototype.deleteRule=function(t){var l=this,e={groupID:L.closest(t,".e-group-container").id.replace(this.element.id+"_",""),ruleID:L.closest(t,".e-rule-container").id.replace(this.element.id+"_",""),cancel:!1,type:"deleteRule"};this.isImportRules||this.prvtEvtTgrDaD?this.deleteRuleSuccessCallBack(e,t):this.trigger("beforeChange",e,function(e){l.deleteRuleSuccessCallBack(e,t)})},q.prototype.deleteRuleSuccessCallBack=function(e,t){if(!e.cancel){for(var l=L.closest(t,".e-group-container"),n=this.getParentGroup(l),o=L.closest(t,".e-rule-container"),t=this.getValidRules(this.rule),i=o.previousElementSibling,r=0,s=o,a=o.nextElementSibling,u=o.querySelectorAll(".e-tooltip"),d=void 0,p=u.length,d=0;d<p;d++)L.getComponent(u[d],"tooltip").destroy();for(;null!==o.previousElementSibling;)o=o.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!o.classList.contains("e-btn-group")||this.headerTemplate&&(o.classList.contains("e-rule-container")||o.classList.contains("e-group-container"))))&&r++;var c,h,g=this.getColumn(n.rules[r].field),a=(g&&g.template&&s.querySelector(".e-template")&&this.templateDestroy(g,s.querySelector(".e-template").id),(!i||i.className.indexOf("e-rule-container")<0)&&a&&L.removeClass([a],"e-joined-rule"),(!a||a.className.indexOf("e-rule-container")<0)&&i&&L.removeClass([i],"e-prev-joined-rule"),s.querySelector(".e-template-value"));try{this.enableSeparateConnector&&(s.previousElementSibling||s.nextElementSibling)&&(c=s.previousElementSibling,h=s.nextElementSibling,L.isNullOrUndefined(h)&&(!this.headerTemplate&&c.classList.contains("e-btn-group")||this.headerTemplate&&c.classList.contains("e-custom-group-btn"))?(c&&c.previousElementSibling&&c.previousElementSibling.classList.contains("e-rule-container")&&(this.getRule(c.previousElementSibling).condition=null),L.detach(c)):(!this.headerTemplate&&h.classList.contains("e-btn-group")||this.headerTemplate&&h.classList.contains("e-custom-group-btn"))&&L.detach(h)),L.detach(s)}catch(e){return}g&&g.ruleTemplate&&this.clearQBTemplate([s.id]),g&&this.isPlatformTemplate(g)&&a&&this.clearQBTemplate([s.id]),n.rules.splice(r,1),n.rules[0]&&n.rules[0].rules||this.disableRuleCondition(l,n,!!this.enableSeparateConnector);for(var m=this.element.querySelectorAll(".e-tooltip"),f=0;f<m.length;f++)L.getComponent(m[f],"tooltip").refresh(m[f]);this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",e),this.filterRules(t,this.getValidRules(this.rule),"deleteRule")}},q.prototype.setGroupRules=function(e,t){this.headerTemplate&&t&&(this.isRoot=!0),this.reset(),this.groupIdCounter=1,this.ruleIdCounter=0,this.isImportRules=!0,this.setProperties({rule:e},!0),e=this.getRuleCollection(this.rule,!1),this.importRules(this.rule,this.element.querySelector(".e-group-container"),!0,this.rule.not,t),e.isLocked&&(t=this.element.querySelector(".e-group-container").querySelector(".e-lock-grp-btn"),this.groupLock(t)),this.isImportRules=!1},q.prototype.keyBoardHandler=function(e){var t;e.currentTarget!==this.element||!this.readonly||38!==e.keyCode&&40!==e.keyCode&&13!==e.keyCode?"Escape"===e.code&&this.allowDragAndDrop&&(this.isDragEventPrevent=!0,document.body.classList.remove("e-prevent-select"),this.element.querySelectorAll(".e-drag-rule-bottom-line").forEach(function(e){e.classList.remove("e-drag-rule-bottom-line")}),this.element.querySelectorAll(".e-drag-rule-top-line").forEach(function(e){e.classList.remove("e-drag-rule-top-line")}),this.element.querySelectorAll(".e-qb-dragging-rule").forEach(function(e){e.classList.remove("e-qb-dragging-rule")}),(t=this.element.querySelector(".e-cloneproperties"))&&L.remove(t),this.enableSeparateConnector)&&this.refresh():e.preventDefault()},q.prototype.clearQBTemplate=function(e){(this.isReact||this.isAngular)&&this.clearTemplate(e)},q.prototype.disableRuleCondition=function(e,t,l,n){if(!this.headerTemplate&&!this.readonly){var o=e.querySelector(".e-rule-list").childElementCount,i=e.querySelector(".e-btngroup-and"),r=e.querySelector(".e-btngroup-or");if(1<o)if(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")),this.enableSeparateConnector&&!l){for(var s=0,a=void 0;;){var u=e.parentElement.querySelectorAll(".e-btngroup-and"),d=e.parentElement.querySelectorAll(".e-btngroup-or"),i=u[u.length-(1+s)],r=d[d.length-(1+s)];if(!(a=u[u.length-(1+s)])||!a.parentElement||"none"!==a.parentElement.style.display)break;s++}for(var p=e.previousElementSibling;p&&!p.classList.contains("e-rule-container");){if(p.classList.contains("e-group-container")){p=p.querySelectorAll(".e-rule-container")[p.querySelectorAll(".e-rule-container").length-1];break}p=p.previousElementSibling}n&&e.classList.contains("e-group-container")?"or"===this.getGroup(p=e).condition?r.checked=!0:i.checked=!0:p&&p.classList.contains("e-rule-container")&&(c=p.id.replace(this.element.id+"_",""),"or"===this.getRule(c).condition?r.checked=!0:i.checked=!0)}else l||(t&&"or"===t.condition?r.checked=!0:i.checked=!0);else if(this.enableSeparateConnector&&!l){for(s=0,a=void 0;;){u=e.parentElement.querySelectorAll(".e-btngroup-and"),d=e.parentElement.querySelectorAll(".e-btngroup-or");if(i=u[u.length-(1+s)],r=d[d.length-(1+s)],!(a=u[u.length-(1+s)])||!a.parentElement||"none"!==a.parentElement.style.display)break;s++}for(var c,p=void 0,h=e.previousElementSibling;h;){if((h=h.classList.contains("e-group-container")?h.querySelectorAll(".e-rule-container")[h.querySelectorAll(".e-rule-container").length-1]:h).classList.contains("e-rule-container")){p=h;break}h=h.previousElementSibling}L.isNullOrUndefined(p)&&e.querySelectorAll(".e-rule-container")[e.querySelectorAll(".e-rule-container").length-1]&&(p=e.querySelectorAll(".e-rule-container")[e.querySelectorAll(".e-rule-container").length-1]),n&&e.classList.contains("e-group-container")?"or"===this.getGroup(p=e).condition?r.checked=!0:i.checked=!0:p&&(c=p.id.replace(this.element.id+"_",""),"or"===this.getRule(c).condition&&r?r.checked=!0:i&&(i.checked=!0))}else l||L.isNullOrUndefined(i)||(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")))}},q.prototype.getValidRules=function(e){this.isValueEmpty=!0;var t=(e=e||this.getRules()).condition,l=e.not,n=L.extend([],e.rules,[],!0),t=L.isNullOrUndefined(e.isLocked)?this.getRuleCollection({condition:t,rules:n,not:l},!0):this.getRuleCollection({condition:t,rules:n,not:l,isLocked:e.isLocked},!0);return this.isValueEmpty=!1,t},q.prototype.getRuleCollection=function(e,t){if(L.isNullOrUndefined(e))return null;var l;if(e.rules&&e.rules.length&&(6<Object.keys(e.rules[0]).length||t))for(var n=e.rules.length,o=0;o<n;o++)l=e.rules[o],l=this.getRuleCollection(l,t),e.rules[o]=l,Object.keys(l).length<1&&t&&(e.rules.splice(o,1),o--,n--);var i,r,s=e.custom;return e.field&&""!==e.field&&(L.isNullOrUndefined(s)||s&&"question"!==s.type&&"answer"!==s.type)?(e.operator&&(-1<e.operator.toString().indexOf("null")||-1<e.operator.toString().indexOf("empty"))&&(e.value=null),(this.isRefreshed&&this.enablePersistence||""!==e.field&&""!==e.operator&&(!this.isValueEmpty||""!==e.value)&&void 0!==e.value||s&&s.isQuestion)&&(r=e.condition,i=e.isLocked,e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value},L.isNullOrUndefined(i)||(e.isLocked=i),r&&(e.condition=r),s&&(e.custom=s),"between"!==(e="in"!==e.operator&&"notin"!==e.operator||!e.value||0!==e.value.length?e:{}).operator&&"notbetween"!==e.operator||!Array.isArray(e.value)||!(e.value.length<2||e.value.some(function(e){return""===e||null===e})))||(e={})):!s||"question"!==s.type&&"answer"!==s.type?(L.isNullOrUndefined(e.condition)&&L.isNullOrUndefined(e.rules)||(i=e.isLocked,e=this.enableNotCondition?{condition:e.condition,rules:e.rules,not:e.not}:{condition:e.condition,rules:e.rules},L.isNullOrUndefined(i)||(e.isLocked=i),s&&(e.custom=s),e.rules&&0===e.rules.length))&&(e={}):(r=e.not,(e={label:e.label,field:e.field,operator:e.operator,type:e.type,value:e.value,condition:e.condition,rules:e.rules}).custom=s,this.enableNotCondition&&(e.not=r)),e},q.prototype.setRules=function(e){e=L.extend({},e,{},!0);this.headerTemplate?this.setGroupRules(e,!0):this.setGroupRules(e)},q.prototype.getRules=function(){var e=this.enableNotCondition?{condition:this.rule.condition,rules:this.rule.rules,not:this.rule.not}:{condition:this.rule.condition,rules:this.rule.rules};return L.isNullOrUndefined(this.rule.isLocked)||(e.isLocked=this.rule.isLocked),this.rule.custom&&(e.custom=this.rule.custom),e},q.prototype.getRule=function(e){var t=0,l=e instanceof HTMLElement?L.closest(e,".e-rule-container"):(e=this.element.id+"_"+e,document.getElementById(e));if(L.isNullOrUndefined(l))return null;for(e=L.closest(l,".e-group-container"),e=this.getParentGroup(e);null!==l.previousElementSibling;)l=l.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!l.classList.contains("e-btn-group")||this.headerTemplate&&(l.classList.contains("e-rule-container")||l.classList.contains("e-group-container"))))&&t++;return e.rules[t]},q.prototype.getGroup=function(e){e=(e=e instanceof Element&&e.className.indexOf("e-group-container")<1?L.closest(e,".e-group-container"):e)instanceof Element?e.id:this.element.id+"_"+e;return this.getParentGroup(e)},q.prototype.deleteGroups=function(e){for(var t,l=e.length,n=0;n<l;n++)"group0"!==e[n]&&(t=this.element.id+"_"+e[n],this.deleteGroup(document.getElementById(t)))},q.prototype.getFilteredRecords=function(){var e=this.getPredicate(this.getValidRules(this.rule)),e=L.isNullOrUndefined(e)?new h.Query:(new h.Query).where(e);return this.dataManager.executeQuery(e)},q.prototype.deleteRules=function(e){for(var t,l=e.length,n=0;n<l;n++)t=this.element.id+"_"+e[n],this.deleteRule(document.getElementById(t))},q.prototype.getDataManagerQuery=function(e){for(var t=this.getPredicate(e),l=[],n=0,o=Object.keys(this.columns);n<o.length;n++)l.push(this.columns[n].field);return e.rules.length?(new h.Query).select(l).where(t):(new h.Query).select(l)},q.prototype.getPredicate=function(e){var t,l,n=e.rules,o=!1;if(n){for(var i=0,r=n.length;i<r;i++){var s=n[i].operator;"notstartswith"===s?s="doesnotstartwith":"notendswith"===s?s="doesnotendwith":"notcontains"===s&&(s="doesnotcontain");var a,u,d,p,c,o=!1;-1<Object.keys(n[i]).indexOf("rules")&&n[i].rules?(a=this.getPredicate(n[i]))&&(t=t?"and"===e.condition?t.and(a):t.or(a):a):L.isNullOrUndefined(s)||L.isNullOrUndefined(s.length)||(a=n[i].operator.toLowerCase(),u=!1,d=["equal","notequal","greaterthan","greaterthanorequal","lessthan","lessthanorequal"],"string"===n[i].type&&(o=!this.matchCase),"date"===n[i].type&&-1<d.indexOf(a)&&(o=!0),p=this.getColumn(n[i].field),-1<a.indexOf("null")||-1<a.indexOf("empty")?n[i].value=null:"date"!==n[i].type||n[i].value instanceof Array?l=n[i].value:(p=this.getFormat(p.format),L.isNullOrUndefined(n[i].value)?l=null:(l=this.getDate(n[i].value,p),-1<d.indexOf(a)&&!this.isTime(n[i].value)&&(u=!0))),0===i?u||(-1<a.indexOf("in")||-1<a.indexOf("between")||-1<a.indexOf("null")||-1<a.indexOf("empty"))&&a.indexOf("contain")<0?t=u?this.datePredicate(n[i],l):this.arrayPredicate(n[i]):""!==(c=l)&&(t=new h.Predicate(n[i].field,s,l,o)):u||(-1<a.indexOf("in")||-1<a.indexOf("between")||-1<a.indexOf("null")||-1<a.indexOf("empty"))&&a.indexOf("contain")<0?t=u?this.datePredicate(n[i],l,t,e.condition):this.arrayPredicate(n[i],t,e.condition):"and"===e.condition?(c=l,t&&""!==c?t=t.and(n[i].field,s,l,o):""!==c&&(t=new h.Predicate(n[i].field,s,l,o))):(c=l,t&&""!==c?t=t.or(n[i].field,s,l,o):""!==c&&(t=new h.Predicate(n[i].field,s,l,o))))}this.dataSource instanceof h.DataManager&&(L.isNullOrUndefined(t)||"isnull"!==t.operator&&"isnotnull"!==t.operator||(t.operator="isnull"===t.operator?"equal":"notequal"))}return t},q.prototype.getLocale=function(){var e=this.locale;return e=L.getValue("main."+this.locale+".dates.calendars.gregorian.days.format.short",L.cldrData)?e:"en"},q.prototype.getColumn=function(e,t){for(var l,n=this.columns,o=0,i=(n=t||n).length;o<i;o++){if(n[o].field===e){l=n[o];break}if(n[o].columns){if(l=this.getColumn(e,n[o].columns))break}else if(e&&-1<e.indexOf(this.separator)&&""!==this.separator&&n[o].field===e.split(this.separator)[0]){l=n[o];break}}return l},q.prototype.getOperators=function(e){return this.getColumn(e).operators},q.prototype.setTime=function(e,t){return t?e.setHours(0,0,0):e.setHours(23,59,59),e},q.prototype.datePredicate=function(e,t,l,n){var o,i=this.setTime(new Date(t.getTime()),!0),r=this.setTime(t);switch(e.operator){case"equal":o=(o=new h.Predicate(e.field,"greaterthanorequal",i)).and(e.field,"lessthanorequal",r);break;case"notequal":o=(o=new h.Predicate(e.field,"lessthan",i)).or(e.field,"greaterthan",r);break;case"greaterthan":o=new h.Predicate(e.field,"greaterthan",r);break;case"greaterthanorequal":o=new h.Predicate(e.field,"greaterthanorequal",i);break;case"lessthan":o=new h.Predicate(e.field,"lessthan",i);break;case"lessthanorequal":o=new h.Predicate(e.field,"lessthanorequal",r)}return o&&(l?"and"===n?l=l.and(o):"or"===n&&(l=l.or(o)):l=o),l},q.prototype.arrayPredicate=function(e,t,l){var n,o=e.value,i=e.operator.toString(),r=e.value,s=this.getColumn(e.field),a=this.getFormat(s.format);if(-1<i.indexOf("null")||-1<i.indexOf("empty"))switch(i){case"isnull":n=new h.Predicate(e.field,"isnull",r);break;case"isnotnull":n=new h.Predicate(e.field,"isnotnull",r);break;case"isempty":n=new h.Predicate(e.field,"equal","");break;case"isnotempty":n=new h.Predicate(e.field,"notequal","")}if(!(-1<i.indexOf("null")||-1<i.indexOf("empty")))for(var u=0,d=o.length;u<d;u++)if(""!==o[u]||("in"===i||"notin"===i)&&"string"===s.type)if(0===u){var p="greaterthanorequal";switch(i){case"between":n="date"!==s.type?new h.Predicate(e.field,p,o[u]):new h.Predicate(e.field,p,o[u]?this.isTime(o[u])?this.getDate(o[u],a):this.setTime(this.getDate(o[u],a),!0):null);break;case"notbetween":n="date"===s.type?new h.Predicate(e.field,"lessthan",o[u]?this.isTime(o[u])?this.getDate(o[u],a):this.setTime(this.getDate(o[u],a),!0):null):new h.Predicate(e.field,"lessthan",o[u]);break;case"in":n=new h.Predicate(e.field,"equal",o[u]);break;case"notin":n=new h.Predicate(e.field,"notequal",o[u])}}else switch(e.operator){case"between":n="date"===s.type?n.and(e.field,"lessthanorequal",o[u]&&(this.isTime(o[u])?this.getDate(o[u],a):this.setTime(this.getDate(o[u],a)))):n.and(e.field,"lessthanorequal",o[u]);break;case"notbetween":n="date"===s.type?n.or(e.field,"greaterthan",o[u]&&(this.isTime(o[u])?this.getDate(o[u],a):this.setTime(this.getDate(o[u],a)))):n.or(e.field,"greaterthan",o[u]);break;case"in":n=n.or(e.field,"equal",o[u]);break;case"notin":n=n.and(e.field,"notequal",o[u])}return n&&(t?"and"===l?t=t.and(n):"or"===l&&(t=t.or(n)):t=n),t},q.prototype.getDate=function(e,t){t=this.intl.parseDate(e,t);return-1<e.indexOf(":")&&e.indexOf("/")<0&&e.indexOf(",")<0&&e.indexOf("-")<0&&((t=new Date).setHours(parseInt(e.split(":")[0],10)),t.setMinutes(parseInt(e.split(":")[1],10)),e.split(":")[2])&&t.setSeconds(parseInt(e.split(":")[2],10)),t},q.prototype.isTime=function(e){return!!(e&&-1<e.indexOf(":"))},q.prototype.importRules=function(e,t,l,n,o){if(l){if(e.rules&&1<e.rules.length&&!this.headerTemplate){var l=t.querySelector(".e-btngroup-or"),i=t.querySelector(".e-btngroup-and");if(this.enableSeparateConnector&&t.previousElementSibling&&(l=t.previousElementSibling.querySelector(".e-btngroup-or"),i=t.previousElementSibling.querySelector(".e-btngroup-and")),l.disabled=!1,i.disabled=!1,this.enableSeparateConnector){for(var r=t.previousElementSibling;r&&!r.classList.contains("e-rule-container");){if(r.classList.contains("e-group-container")){r=r.querySelectorAll(".e-rule-container")[r.querySelectorAll(".e-rule-container").length-1];break}r=r.previousElementSibling}r&&r.classList.contains("e-rule-container")&&(s=r.id.replace(this.element.id+"_",""),"or"===this.getRule(s).condition?l.checked=!0:i.checked=!0)}else"or"===e.condition?l.checked=!0:i.checked=!0}else this.disableRuleCondition(t);var s;this.headerTemplate&&o&&(t=this.renderGroup(e,e.condition,this.element,e.not,o)),this.enableNotCondition&&!this.headerTemplate&&(s=t.querySelector(".e-qb-toggle"),e.not?L.addClass([s],"e-active-toggle"):L.removeClass([s],"e-active-toggle"))}else t=this.renderGroup(e,e.condition,t,n);e.rules&&0===e.rules.length&&this.headerTemplate&&(e.rules[0]={label:"",field:"",operator:"",type:"",value:""});var a=e.rules;if(!L.isNullOrUndefined(a))for(var u=0,d=a.length;u<d;u++){var p=Object.keys(a[u]);if(!L.isNullOrUndefined(a[u].rules)&&-1<p.indexOf("rules")&&0!==a[u].rules.length){if(this.element.querySelectorAll(".e-group-container").length>this.maxGroupCount)return null;t=this.renderGroup(a[u],a[u].condition,t,a[u].not),t=this.importRules(a[u],t,!0)}else this.renderRule(a[u],t);!L.isNullOrUndefined(a[u].rules)&&a[u].isLocked&&(p=t.querySelector(".e-rule-list").children[u].querySelector(".e-lock-grp-btn"),this.groupLock(p))}return t=(t=t&&L.closest(t,".e-rule-list"))&&L.closest(t,".e-group-container")},q.prototype.renderGroup=function(e,t,l,n,o){this.addGroupElement(!0,l,t,!1,n,o,e);var t=l.querySelectorAll(".e-group-container"),i=l.querySelector(".e-rule-list").children;if(this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isMiddleGroup){this.isMiddleGroup=!1,this.cloneGrpBtnClick=!1;var r=0,s=this.groupIndex+1;if(this.enableSeparateConnector)for(var a=0;a<s;a++)i[a].classList.contains("e-rule-container")&&(s++,r++);return i[this.groupIndex+r+1]}return this.showButtons.cloneGroup&&this.cloneGrpBtnClick&&this.isLastGroup?(this.isLastGroup=!1,this.cloneGrpBtnClick=!1,i[i.length-1]):t[t.length-1]},q.prototype.renderRule=function(e,t){-1<t.className.indexOf("e-group-container")?this.addRuleElement(t,e):this.addRuleElement(t.querySelector(".e-group-container"),e)},q.prototype.enableReadonly=function(){for(var e=this.element.querySelectorAll(".e-dropdownlist, .e-dropdowntree, .e-numerictextbox, .e-textbox, .e-datepicker, .e-multiselect .e-lib, .e-radio"),t=0;t<e.length;t++)e[t].classList.contains("e-dropdownlist")?L.getInstance(e[t],y.DropDownList).readonly=this.isReadonly:e[t].classList.contains("e-dropdowntree")?L.getComponent(e[t],"dropdowntree").readonly=this.isReadonly:e[t].classList.contains("e-numerictextbox")?L.getInstance(e[t],c.NumericTextBox).readonly=this.isReadonly:e[t].classList.contains("e-textbox")?L.getInstance(e[t],c.TextBox).readonly=this.isReadonly:e[t].classList.contains("e-datepicker")?L.getInstance(e[t],v.DatePicker).readonly=this.isReadonly:e[t].classList.contains("e-multiselect")?L.getInstance(e[t],y.MultiSelect).readonly=this.isReadonly:e[t].classList.contains("e-radio")&&!L.getInstance(e[t],N.RadioButton).checked&&(this.isReadonly?e[t].parentElement.style.display="none":e[t].parentElement.style.display="inherit");for(var l=this.element.querySelectorAll(".e-deletegroup"),n=this.element.querySelectorAll(".e-addrulegroup"),o=this.element.querySelectorAll(".e-removerule"),i=(!this.isReadonly&&this.ruleElem.classList.contains("e-readonly")&&this.ruleElem.classList.remove("e-readonly"),[l,n,o]),t=0;t<i.length;t++)i[t].forEach(function(e){e.classList.contains("e-readonly")?e.classList.remove("e-readonly"):e.classList.add("e-readonly")});this.enableBtnGroup()},q.prototype.enableBtnGroup=function(){var t=this,e=this.element.querySelectorAll(".e-btngroup-and-lbl, .e-btngroup-or-lbl, .e-qb-toggle"),l=!1;e.forEach(function(e){!e.classList.contains("e-qb-toggle")||e.classList.contains("e-active-toggle")||e.classList.contains("e-readonly")?e.classList.contains("e-qb-toggle")&&e.classList.contains("e-not-readonly")?e.classList.remove("e-not-readonly"):e.classList.contains("e-qb-toggle")&&e.classList.contains("e-readonly")?e.classList.remove("e-readonly"):e.classList.contains("e-active-toggle")?(e.classList.add("e-not-readonly"),l=!0):e.previousElementSibling.checked||e.classList.contains("e-readonly")?(e.classList.remove("e-readonly"),l?"AND"===e.textContent?e.classList.add("e-readonly-and"):e.classList.add("e-readonly-or"):("AND"===e.textContent&&t.isReadonly?(e.classList.remove("e-not"),e.classList.add("e-readonly-and")):(t.enableNotCondition&&e.classList.add("e-not"),e.classList.remove("e-readonly-and")),"OR"===e.textContent&&t.isReadonly?e.classList.add("e-readonly-or-not"):e.classList.remove("e-readonly-or-not"))):e.classList.contains("e-btn-disable")||e.classList.add("e-readonly"):(e.classList.add("e-readonly"),l=!1)})},q.prototype.isDateFunction=function(e){for(var t=["date","time","day","week","month","year","hour","minute","second","now","quarter","period","extract"],l=0,n=t.length;l<n;l++)if(-1<e.toLowerCase().indexOf(t[l]))return!0;return!1},q.prototype.getSqlString=function(e,t,l,n){var o=!1,i=(l||""===l?l+="(":o=!(l=""),e.condition);if(e.not&&(l+=o?n?this.l10n.getConstant("NOT").toUpperCase()+" (":"NOT (":n?" "+this.l10n.getConstant("NOT").toUpperCase()+" (":" NOT ("),e.rules)for(var r=0,s=e.rules.length;r<s;r++){if(e.rules[r].rules)l=this.getSqlString(e.rules[r],t,l,n),this.enableSeparateConnector&&(i=e.rules[r].condition);else{var a=e.rules[r],u="",d=(n?this.sqlOperators:this.operators)[a.operator];if(a.value instanceof Array)if(-1<a.operator.toString().indexOf("between")){var p=n?" "+this.l10n.getConstant("AND").toUpperCase()+" ":" AND ";"date"!==a.type||this.isDateFunction(a.value[0])?u+=a.value[0]+p+a.value[1]:u+='"'+a.value[0]+'"'+p+'"'+a.value[1]+'"'}else if("string"==typeof a.value[0]&&null!==a.value){u+='("'+a.value[0]+'"';for(var c=1,h=a.value.length;c<h;c++)u+=',"'+a.value[c]+'"';u+=")"}else u+="("+a.value+")";else-1<a.operator.toString().indexOf("startswith")?u+=a.value?'("'+a.value+'%")':"("+a.value+")":-1<a.operator.toString().indexOf("endswith")?u+=a.value?'("%'+a.value+'")':"("+a.value+")":-1<a.operator.toString().indexOf("contains")?u+=a.value?'("%'+a.value+'%")':"("+a.value+")":"number"===a.type||"boolean"==typeof a.value||null===a.value&&a.operator.toString().indexOf("empty")<-1?u+=a.value:-1<a.operator.toString().indexOf("empty")?u+='""':u+='"'+a.value+'"';-1<a.operator.toString().indexOf("null")?(t?a.field="`"+a.field+"`":-1<a.field.indexOf(" ")&&(a.field='"'+a.field+'"'),l+=a.field+" "+d):(p=d,"isempty"===a.operator?p="=":"isnotempty"===a.operator&&(p="!="),t?a.field="`"+a.field+"`":-1<a.field.indexOf(" ")&&(a.field='"'+a.field+'"'),l+=a.field+" "+p+" "+u),a.condition&&""!==a.condition&&(i=a.condition)}r!==s-1&&(a=e.rules[r],i=""===i||a&&""!==a.condition&&a.custom&&a.custom.isCustom?a.condition:i)&&(l+=" "+(i=(n?this.l10n.getConstant(i.toUpperCase()):i).toUpperCase())+" ")}return o||(l+=")"),e.not&&(l+=")"),l},q.prototype.setRulesFromSql=function(e,t){e=e.replace(/`/g,"");e=this.getRulesFromSql(e,t);this.setRules({condition:e.condition,not:e.not,rules:e.rules})},q.prototype.getRulesFromSql=function(e,t){this.parser=[],this.sqlParser(e,t),this.setProperties({rule:{condition:"and",not:!1,rules:[]}},!0);e=this.processParser(this.parser,this.rule,[0],t);return this.enableNotCondition?{condition:e.condition,not:e.not,rules:e.rules}:{condition:e.condition,rules:e.rules}},q.prototype.getSqlFromRules=function(e,t,l){return e=e||this.getValidRules(),e=this.getRuleCollection(e,!1),this.getSqlString(this.getValidRules(e),t,null,l).replace(/"/g,"'")},q.prototype.getParameterizedSql=function(e){var t;return this.moduleLoader.loadedModules.length?(e=e||this.getValidRules(),this.notify("query-library",{prop:"getParameterSql",onPropertyChange:!(t={sql:null}),value:{rule:e,obj:t}}),t.sql):(console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),null)},q.prototype.setParameterizedSql=function(e){var t;this.moduleLoader.loadedModules.length?(this.notify("query-library",{prop:"convertParamSqlToSql",onPropertyChange:!(t={sql:null}),value:{sql:e,obj:t}}),(e=t.sql)&&(e=e.replace(/`/g,""),t=this.getRulesFromSql(e),this.setRules({condition:t.condition,not:t.not,rules:t.rules}))):console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},q.prototype.getParameterizedNamedSql=function(e){var t;return this.moduleLoader.loadedModules.length?(e=e||this.getValidRules(),this.notify("query-library",{prop:"getNamedParameterSql",onPropertyChange:!(t={sql:null}),value:{rule:e,obj:t}}),t.sql):(console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),null)},q.prototype.setParameterizedNamedSql=function(e){var t;this.moduleLoader.loadedModules.length?(this.notify("query-library",{prop:"convertNamedParamSqlToSql",onPropertyChange:!(t={sql:null}),value:{sql:e,obj:t}}),(e=t.sql)&&(e=e.replace(/`/g,""),t=this.getRulesFromSql(e),this.setRules({condition:t.condition,not:t.not,rules:t.rules}))):console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},q.prototype.setMongoQuery=function(e,t){this.moduleLoader.loadedModules.length?(this.rule={condition:"and",not:!1,rules:[]},this.notify("query-library",{prop:"mongoParser",onPropertyChange:!1,value:{mongoQuery:JSON.parse(e),rule:this.rule,mongoLocale:t}})):console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.')},q.prototype.getMongoQuery=function(e){var t;return this.moduleLoader.loadedModules.length?(e=e||this.getValidRules(),this.notify("query-library",{prop:"getMongoFromRules",onPropertyChange:!(t={mongoQuery:null}),value:{rule:e,mongoQuery:"",obj:t}}),t.mongoQuery):(console.warn('[WARNING] :: Module "query-library" is not available in QueryBuilder component! You either misspelled the module name or forgot to load it.'),"")},q.prototype.cloneRule=function(e,t,l){var e=this.getRule(e.replace(this.element.id+"_","")),n=this.showButtons.cloneRule;t=t.replace(this.element.id+"_",""),this.ruleIndex=l,this.cloneRuleBtnClick=!0,this.showButtons.cloneRule=!0,this.addRules([{label:e.label,field:e.field,type:e.type,operator:e.operator,value:e.value,condition:e.condition}],t),this.ruleIndex=-1,this.cloneRuleBtnClick=!1,this.showButtons.cloneRule=n},q.prototype.cloneGroup=function(e,t,l){t=t.replace(this.element.id+"_","");var t=this.getGroup(t),n=this.showButtons.cloneGroup;e=e.replace(this.element.id+"_",""),this.groupIndex=l,this.cloneGrpBtnClick=!0,this.showButtons.cloneGroup=!0,this.addGroups([{condition:t.condition,not:t.not,rules:t.rules}],e),this.groupIndex=-1,this.cloneGrpBtnClick=!1,this.showButtons.cloneGroup=n},q.prototype.lockRule=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);e=document.getElementById(e).querySelectorAll(".e-lock-rule-btn")[0];this.ruleLock(e)},q.prototype.lockGroup=function(e){e.indexOf(this.element.id)<0&&(e=this.element.id+"_"+e);e=document.getElementById(e).querySelectorAll(".e-lock-grp-btn")[0];this.groupLock(e)},q.prototype.sqlParser=function(e,t){for(var l,n=0;l=e.slice(n),n+=this.parseSqlStrings(l,t),""!==l;);return this.parser},q.prototype.parseSqlStrings=function(e,t){for(var l,n=["=","!=","<=",">=","<",">"],o=t?[this.l10n.getConstant("AND").toUpperCase(),this.l10n.getConstant("OR").toUpperCase(),this.l10n.getConstant("NOT").toUpperCase()]:["AND","OR","NOT"],i=t?[this.l10n.getConstant("In").toUpperCase(),this.l10n.getConstant("NotIn").toUpperCase(),this.l10n.getConstant("Like").toUpperCase(),this.l10n.getConstant("NotLike").toUpperCase(),this.l10n.getConstant("Between").toUpperCase(),this.l10n.getConstant("NotBetween").toUpperCase(),this.l10n.getConstant("IsNull").toUpperCase(),this.l10n.getConstant("IsNotNull").toUpperCase(),this.l10n.getConstant("IsEmpty").toUpperCase(),this.l10n.getConstant("IsNotEmpty").toUpperCase()]:["IN","NOT IN","LIKE","NOT LIKE","BETWEEN","NOT BETWEEN","IS NULL","IS NOT NULL","IS EMPTY","IS NOT EMPTY"],r=0,s=n.length;r<s;r++){var a=/^\w+$/.test(n[r])?"\\b":"";if(new RegExp("^("+n[r]+")"+a,"ig").exec(e))return this.parser.push(["Operators",n[r].toLowerCase()]),n[r].length}var u=this.parser[this.parser.length-1];if(!u||"Literal"!==u[0])for(r=0,s=o.length;r<s;r++)if(a=/^\w+$/.test(o[r])?"\\b":"",new RegExp("^("+o[r]+")"+a,"ig").exec(e))return this.parser.push(["Conditions",o[r].toLowerCase()]),o[r].length;for(r=0,s=i.length;r<s;r++)if(a=/^\w+$/.test(i[r])?"\\b":"",new RegExp("^("+i[r]+")"+a,"ig").exec(e))return this.parser.push(["SubOperators",i[r].toLowerCase()]),i[r].length;if(/^\(/.exec(e))return this.parser.push(["Left","("]),1;if(/^\)/.exec(e))return this.parser.push(["Right",")"]),1;if(/^(true|false)/.exec(e))return l=/^(true|false)/.exec(e)[0],this.parser.push(["String",l]),l.length;if(/^null/.exec(e))return l=/^null/.exec(e)[0],this.parser.push(["String",null]),l.length;if(/^`?([a-z_][a-z0-9_.\\[\]\\(\\)]{0,}(\\:(number|float|string|date|boolean))?)`?/i.exec(e))return l=/^`?([a-z_][a-z0-9_.\\[\]\\(\\)]{0,}(\\:(number|float|string|date|boolean))?)`?/i.exec(e)[1],this.parser.push(["Literal",l]),l.length;if(this.checkLiteral()&&/^'?([a-z_][a-z0-9 _.\\[\]\\(\\)-]{0,}(\\:(number|float|string|date|boolean))?)'?/i.exec(e))return l=/^'?([a-z_][a-z0-9 _.\\[\]\\(\\)-]{0,}(\\:(number|float|string|date|boolean))?)'?/i.exec(e)[1],this.parser.push(["Literal",l]),l.length+2;if(this.checkNumberLiteral(e,t)){u=/^[0-9]+(\.[0-9]+)$/.exec(e);if(u)return l=u[0],this.parser.push(["Literal",l]),l.length}t=this.getSingleQuoteString(e);if(""!==t){if("("===(l=t)[l.length-2])for(var d=!1,p=l.length;p<e.length&&(l+=e[p],!(d=")"===e[p]||d)||"'"!==e[p]);p++);else e[l.length]&&")"!==e[l.length]&&!this.checkCondition(e,l)&&(l=this.combineSingleQuoteString(e,l));return this.parser.push(["String",l]),l.length}u=this.getDoubleQuoteString(e);return""!==u?(this.parser.push(["DoubleString",l=u]),l.length):/^\d*\.?\d+/.exec(e)?(l=/^\d*\.?\d+/.exec(e)[0],this.parser.push(["Number",l]),l.length):/^-?\d*\.?\d+/.exec(e)?(l=/^-?\d*\.?\d+/.exec(e)[0],this.parser.push(["Number",l]),l.length):1},q.prototype.getDoubleQuoteString=function(e){var t=e.indexOf('"');if(0===t){var l=e.indexOf('"',t+1);if(-1!==l)return e.substring(t,l+1)}return""},q.prototype.checkCondition=function(e,t){return"AND"===e.slice(t.length+1,t.length+4)||"OR"===e.slice(t.length+1,t.length+3)},q.prototype.getSingleQuoteString=function(e,t){var l=e.indexOf("'");if(-1!==l&&t||0===l&&!t){t=e.indexOf("'",l+1);if(-1!==t)return e.substring(l,t+1)}return""},q.prototype.combineSingleQuoteString=function(e,t){var l;return e[t.length]&&")"!==e[t.length]&&!this.checkCondition(e,t)&&","!==e[t.length]&&(l=t.substring(0,t.length-1),l=e.replace(l,""),""!==(l=this.getSingleQuoteString(l,!0)))&&(l=l.substring(1,l.length),t=this.combineSingleQuoteString(e,t+=l)),t},q.prototype.checkLiteral=function(){var e,t,l=this.parser[this.parser.length-1];return!(l&&(e=this.parser[this.parser.length-2],t=this.parser[this.parser.length-3],"Left"!==l[0]||!e||"Conditions"!==e[0]))||!!("Conditions"===l[0]&&t&&t[1].indexOf("between")<0)},q.prototype.checkNumberLiteral=function(e,t){var l=this.parser[this.parser.length-1];if(!l)return!0;if(/^[0-9]+(?:\.[0-9]+)$/.exec(e)){var e=this.parser[this.parser.length-2],n=this.parser[this.parser.length-3];if("Left"===l[0]&&e&&"Conditions"===e[0])return!0;e=t?this.l10n.getConstant("Between").toLowerCase():"between";if("Conditions"===l[0]&&n&&n[1].indexOf(e)<0)return!0}return!1},q.prototype.getOperator=function(e,t,l){if(l){for(var n=Object.keys(this.sqlOperators),o=0;o<n.length;o++)if(this.sqlOperators[n[o]]===t.toUpperCase())return e&&0===e.indexOf("%")&&"%"===e[e.length-1]?"NOT LIKE"===t.toUpperCase()?"notcontains":"contains":e&&0!==e.indexOf("%")&&e.indexOf("%")===e.length-1?"NOT LIKE"===t.toUpperCase()?"notstartswith":"startswith":e&&0===e.indexOf("%")&&e.indexOf("%")!==e.length-1?"NOT LIKE"===t.toUpperCase()?"notendswith":"endswith":n[o];return null}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{"=":"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"}[""+t]},q.prototype.getTypeFromColumn=function(e){e=this.getColumn(e.field);return L.isNullOrUndefined(e)?null:e.type},q.prototype.getLabelFromColumn=function(e){var t="",l=0;if(""===this.separator)return this.getColumn(e).label;for(var n=e.split(this.separator),o=0;o<n.length;o++)t+=this.getLabelFromField(n,o+1),++l<n.length&&(t+=this.separator);return t},q.prototype.getLabelFromField=function(e,t){for(var l="",n=0,o=0;o<t;o++)l+=e[o],++n<t&&(l+=this.separator);return this.getColumn(l).label},q.prototype.processParser=function(e,t,l,n){for(var o,i,r,s,a,u,d,p,c=[],h=[],g=!1,m=!1,f=0,y=e.length;f<y;f++)if("Literal"===e[f][0]){var v=this.getColumn(e[f][1]),b={label:v&&v.label?v.label:e[f][1],field:e[f][1]};if("SubOperators"===e[f+1][0]){for(-1<e[f+1][1].indexOf("null")||-1<e[f+1][1].indexOf("empty")?(b.operator=this.getOperator(" ",e[f+1][1],n),b.value=null,b.type=this.getTypeFromColumn(b)):(v=e[f+3][1]&&e[f+3][1].replace(/'/g,""),b.operator=this.getOperator(v,e[f+1][1],n)),p=e[f+1][1],i=y,n&&"contains"===b.operator||"startswith"===b.operator||"endswith"===b.operator?p="like":n&&"notcontains"===b.operator||"notstartswith"===b.operator||"notendswith"===b.operator?p="not like":n&&(p=b.operator),o=o=++f+1;o<i;o++)if(p.indexOf("between")<0&&"Left"===e[o][0])g=!0;else{if("Right"===e[o][0]&&g){f=o,g=!1;break}if(-1<p.indexOf("null")||-1<p.indexOf("empty"))break;if(-1<p.indexOf("like")&&"String"===e[o][0]){var C=e[o][1];C=(C=e[o][1]&&"'"===e[o][1][0]?e[o][1].substring(1,e[o][1].length-1):C)?C.replace(/%/g,""):e[o][1],b.value=C,b.type="string"}else{if(-1<p.indexOf("between")&&("Literal"===e[o][0]||"Left"===e[o][0]))break;"Number"===e[o][0]?c.push(Number(e[o][1])):"String"===e[o][0]&&(C=e[o][1],e[o][1]&&"'"===e[o][1][0]&&(C=e[o][1].substring(1,e[o][1].length-1)),h.push(C))}b.type=this.getTypeFromColumn(b)}p.indexOf("like")<0&&("Number"===e[o-1][0]?(b.value=c,b.type="number"):"String"===e[o-1][0]?(b.value=h,b.type="string"):-1<p.indexOf("between")&&"Conditions"===e[o-1][0]&&(0!==h.length?(b.value=h,b.type="string"):(b.value=c,b.type="number")),c=[],h=[],b.type=this.getTypeFromColumn(b)),this.enableSeparateConnector&&"Conditions"===e[f+1][0]&&(b.condition=e[f+1][1])}else"Operators"===e[f+1][0]&&(b.operator=this.getOperator(e[f+2][1],e[f+1][1],n),"equal"===b.operator&&"String"===e[f+2][0]&&"''"===e[f+2][1]?b.operator="isempty":"notequal"===b.operator&&"String"===e[f+2][0]&&"''"===e[f+2][1]&&(b.operator="isnotempty"),"Number"===e[f+2][0]?(b.type="number",b.value=Number(e[f+2][1])):(b.type="string",(C=e[f+2][1])&&"'"===C[0]&&(C=C.substring(1,C.length-1)),b.value=C),this.enableSeparateConnector&&"Conditions"===e[f+3][0]&&(b.condition=e[f+3][1]),b.type=this.getTypeFromColumn(b));t.rules.push(b)}else if("Left"===e[f][0]){if("Left"===e[0][0]||!("not"===e[f-1][1]||n&&this.l10n.getConstant("NOT").toLowerCase()===e[f-1][1])){for(this.parser=e.splice(f+1,y-(f+1)),v=this.enableNotCondition?{condition:"and",rules:[],not:!1}:{condition:"and",rules:[]},s=t.rules.length,r=d=0;r<s;r++)t.rules[r].rules&&d++;return l.push(d),t.rules.push(v),v=this.processParser(this.parser,v,l,n),t}m=!0}else if("Conditions"!==e[f][0]||this.enableSeparateConnector){if("Right"===e[f][0]){if(!m||"Right"!==e[f+1][0]){for(this.parser=e.splice(f+1,y-(f+1)),l.pop(),t=this.rule,u=l.length,a=0;a<u;a++)t=this.findGroupByIdx(l[a],t,0===a);return this.processParser(this.parser,t,l,n)}m=!1}}else"not"===e[f][1]||n&&this.l10n.getConstant("NOT").toLowerCase()===e[f][1]?t.not=!0:t.condition=e[f][1];return t},q.prototype.groupClone=function(e){var t=e.closest(".e-rule-list").closest(".e-group-container"),l=e.id.replace(this.element.id+"_",""),t=t.id.replace(this.element.id+"_",""),l=this.getGroup(l);this.groupIndex=Array.prototype.indexOf.call(e.closest(".e-rule-list").children,e.closest(".e-group-container")),this.addGroups([{condition:l.condition,not:l.not,rules:l.rules}],t),this.groupIndex=-1},q.prototype.ruleClone=function(e){for(var t=L.closest(e,".e-rule-container"),l=e.closest(".e-rule-list").closest(".e-group-container"),e=this.getRule(e),n=l.id.replace(this.element.id+"_",""),o=l.querySelectorAll(".e-rule-container"),i=0,r=o.length;i<r;i++)t.id===o[i].id&&(this.ruleIndex=i);this.enableSeparateConnector?this.addRules([{label:e.label,field:e.field,type:e.type,operator:e.operator,value:e.value,condition:e.condition}],n):this.addRules([{label:e.label,field:e.field,type:e.type,operator:e.operator,value:e.value}],n),this.ruleIndex=-1},q.prototype.ruleLock=function(e){var t=L.closest(e,".e-rule-container"),l=this.getRule(t.id.replace(this.element.id+"_",""));t.classList.contains("e-disable")?(l.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==t.id}),t.classList.remove("e-disable"),this.disableRuleControls(e,t,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockRule"))):(l.isLocked=!0,this.lockItems.indexOf(t.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,t.id),t.classList.add("e-disable"),this.disableRuleControls(e,t,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockRule")))},q.prototype.groupLock=function(e){var t,l=L.closest(e,".e-group-container"),n=this.getGroup(l.id.replace(this.element.id+"_","")),o=-1<l.id.indexOf("group0");l.classList.contains("e-disable")?(o?((t={}).condition=n.condition,t.not=n.not,t.isLocked=!1,this.setProperties({rule:t},!0)):n.isLocked=!1,this.lockItems=this.lockItems.filter(function(e){return e!==l.id}),l.classList.remove("e-disable"),this.disableHeaderControls(e,l,!1),e.children[0].classList.add("e-unlock"),e.children[0].classList.remove("e-lock"),e.setAttribute("title",this.l10n.getConstant("LockGroup")),this.updateLockItems()):(o?((t={}).condition=n.condition,t.not=n.not,t.isLocked=!0,this.setProperties({rule:t},!0)):n.isLocked=!0,this.lockItems.indexOf(l.id)<0&&this.lockItems.splice(this.lockItems.length-1,0,l.id),l.classList.add("e-disable"),this.disableHeaderControls(e,l,!0),e.children[0].classList.add("e-lock"),e.children[0].classList.remove("e-unlock"),e.setAttribute("title",this.l10n.getConstant("UnlockGroup")))},q.prototype.updateLockItems=function(){for(var e,t=0;t<this.lockItems.length;t++)2<this.lockItems[t].split("_").length?(e=this.element.querySelector("#"+this.lockItems[t]).querySelector(".e-lock-rule-btn"),L.closest(e,".e-rule-container").classList.contains("e-disable")||this.ruleLock(e)):(e=this.element.querySelector("#"+this.lockItems[t]).querySelector(".e-lock-grp-btn"),L.closest(e,".e-group-container").classList.contains("e-disable")||this.groupLock(e))},q.prototype.disableHeaderControls=function(e,t,l){for(var n=t.querySelectorAll(".e-btngroup-and"),o=t.querySelectorAll(".e-btngroup-or"),i=t.querySelectorAll(".e-qb-toggle"),r=t.querySelectorAll(".e-add-btn"),s=t.querySelectorAll(".e-deletegroup"),a=t.querySelectorAll(".e-lock-grp-btn"),u=t.querySelectorAll(".e-clone-grp-btn"),d=t.querySelectorAll(".e-group-container"),p=t.querySelectorAll(".e-add-condition-btn"),c=t.querySelectorAll(".e-add-group-btn"),h=0;h<n.length;h++)l?(d[h]&&d[h].classList.contains("e-disable")&&d[h].classList.add("e-disable"),n[h].disabled=!0,o[h].disabled=!0,r[h]&&(r[h].disabled=!0),p[h]&&(p[h].disabled=!0),c[h]&&(c[h].disabled=!0),i[h]&&(i[h].disabled=!0),s[h]&&(s[h].disabled=!0),u[h]&&(u[h].disabled=!0),n[h].parentElement.classList.add("e-disabled"),a[h]&&a[h]!==e&&(a[h].disabled=!0,a[h].children[0].classList.remove("e-unlock"),a[h].children[0].classList.add("e-lock"))):(d[h]&&d[h].classList.remove("e-disable"),n[h].disabled=!1,o[h].disabled=!1,r[h]&&(r[h].disabled=!1),p[h]&&(p[h].disabled=!1),c[h]&&(c[h].disabled=!1),a[h]&&(a[h].disabled=!1),i[h]&&(i[h].disabled=!1),s[h]&&(s[h].disabled=!1),u[h]&&(u[h].disabled=!1),n[h].parentElement.classList.remove("e-disabled"),a[h]&&a[h].children[0].classList.remove("e-lock"),a[h]&&a[h].children[0].classList.add("e-unlock"));this.disableRuleControls(e,t,l)},q.prototype.disableRuleControls=function(e,t,l){for(var n=t.querySelectorAll(".e-control.e-dropdownlist"),o=t.querySelectorAll(".e-control.e-numerictextbox"),i=t.querySelectorAll(".e-control.e-textbox"),r=t.querySelectorAll(".e-control.e-datepicker"),s=t.querySelectorAll(".e-control.e-checkbox"),a=t.querySelectorAll(".e-control.e-radio"),u=t.querySelectorAll(".e-control.e-multiselect"),d=t.querySelectorAll(".e-rule-delete"),p=t.querySelectorAll(".e-lock-rule"),c=t.querySelectorAll(".e-clone-rule"),h=t.querySelectorAll(".e-rule-container"),g=0;g<d.length;g++)l?(h[g]&&h[g].classList.contains("e-disable")&&h[g].classList.add("e-disable"),d[g].disabled=!0,c[g]&&(c[g].disabled=!0),p[g]!==e&&(p[g].disabled=!0,p[g].children[0].classList.remove("e-unlock"),p[g].children[0].classList.add("e-lock"))):(h[g]&&h[g].classList.remove("e-disable"),c[g]&&(c[g].disabled=!1),d[g].disabled=!1,p[g].disabled=!1,p[g].children[0].classList.remove("e-lock"),p[g].children[0].classList.add("e-unlock"));for(g=0;g<n.length;g++)L.getComponent(n[g],"dropdownlist").enabled=!l;for(g=0;g<o.length;g++)L.getComponent(o[g],"numerictextbox").enabled=!l;for(g=0;g<i.length;g++)L.getComponent(i[g],"textbox").enabled=!l;for(g=0;g<r.length;g++)L.getComponent(r[g],"datepicker").enabled=!l;for(g=0;g<s.length;g++)L.getComponent(s[g],"checkbox").disabled=!!l;for(g=0;g<a.length;g++)L.getComponent(a[g],"radio").disabled=!!l;for(g=0;g<u.length;g++)L.getComponent(u[g],"multiselect").enabled=!l},o([L.Event()],q.prototype,"created",void 0),o([L.Event()],q.prototype,"actionBegin",void 0),o([L.Event()],q.prototype,"beforeChange",void 0),o([L.Event()],q.prototype,"change",void 0),o([L.Event()],q.prototype,"dataBound",void 0),o([L.Event()],q.prototype,"ruleChange",void 0),o([L.Event()],q.prototype,"dragStart",void 0),o([L.Event()],q.prototype,"drag",void 0),o([L.Event()],q.prototype,"drop",void 0),o([L.Complex({},C)],q.prototype,"showButtons",void 0),o([L.Property(!1)],q.prototype,"summaryView",void 0),o([L.Property(!1)],q.prototype,"allowValidation",void 0),o([L.Property("Default")],q.prototype,"fieldMode",void 0),o([L.Property([])],q.prototype,"columns",void 0),o([L.Property(null)],q.prototype,"fieldModel",void 0),o([L.Property(null)],q.prototype,"operatorModel",void 0),o([L.Property(null)],q.prototype,"valueModel",void 0),o([L.Property()],q.prototype,"headerTemplate",void 0),o([L.Property("")],q.prototype,"cssClass",void 0),o([L.Property([])],q.prototype,"dataSource",void 0),o([L.Property("Horizontal")],q.prototype,"displayMode",void 0),o([L.Property(!1)],q.prototype,"enablePersistence",void 0),o([L.Property("Default")],q.prototype,"sortDirection",void 0),o([L.Property(5)],q.prototype,"maxGroupCount",void 0),o([L.Property("auto")],q.prototype,"height",void 0),o([L.Property("auto")],q.prototype,"width",void 0),o([L.Property(!1)],q.prototype,"matchCase",void 0),o([L.Property(0)],q.prototype,"immediateModeDelay",void 0),o([L.Property(!1)],q.prototype,"enableNotCondition",void 0),o([L.Property(!1)],q.prototype,"readonly",void 0),o([L.Property(!0)],q.prototype,"addRuleToNewGroups",void 0),o([L.Property(!1)],q.prototype,"autoSelectField",void 0),o([L.Property(!0)],q.prototype,"autoSelectOperator",void 0),o([L.Property("")],q.prototype,"separator",void 0),o([L.Property(!1)],q.prototype,"enableSeparateConnector",void 0),o([L.Complex({condition:"and",rules:[]},u)],q.prototype,"rule",void 0),o([L.Property(!1)],q.prototype,"allowDragAndDrop",void 0);var x,l=o([L.NotifyPropertyChanges],q);function q(e,t){e=x.call(this,e,t)||this;return e.isReadonly=!0,e.fields={text:"label",value:"field"},e.updatedRule={not:!1,condition:"and",isLocked:!1},e.isLocale=!1,e.isRefreshed=!1,e.isNotified=!1,e.isAddSuccess=!1,e.isNotValueChange=!1,e.isFieldChange=!1,e.isFieldClose=!1,e.isDestroy=!1,e.isGetNestedData=!1,e.isCustomOprCols=[],e.groupCounter=0,e.lockItems=[],e.groupIndex=-1,e.ruleIndex=-1,e.isLastGroup=!1,e.cloneGrpBtnClick=!1,e.isMiddleGroup=!1,e.cloneRuleBtnClick=!1,e.isValueEmpty=!1,y.MultiSelect.Inject(y.CheckBoxSelection),e}E.prototype.destroy=function(){this.parent.isDestroyed||this.removeEventListener()},E.prototype.addEventListener=function(){this.parent.isDestroyed||(this.parent.on("query-library",this.queryLibrary,this),this.parent.on("destroyed",this.destroy,this))},E.prototype.removeEventListener=function(){this.parent.off("query-library",this.queryLibrary),this.parent.off("destroyed",this.destroy)},E.prototype.queryLibrary=function(e){switch(e.prop){case"getMongoFromRules":e.value.obj.mongoQuery=this.getMongoFromRules(e.value.rule,e.value.mongoQuery);break;case"mongoParser":this.mongoParser(e.value.mongoQuery,e.value.rule,e.value.mongoLocale);break;case"getParameterSql":e.value.obj.sql=this.getParameterSql(e.value.rule);break;case"getNamedParameterSql":e.value.obj.sql=this.getNamedParameterSql(e.value.rule);break;case"convertParamSqlToSql":e.value.obj.sql=this.convertParamSqlToSql(e.value.sql);break;case"convertNamedParamSqlToSql":e.value.obj.sql=this.convertNamedParamSqlToSql(e.value.sql)}},E.prototype.getMongoFromRules=function(e,t){return t="{",t="or"===e.condition?this.convertMongoQuery(e.rules,t+='"$or":[')+"]":this.convertMongoQuery(e.rules,t+='"$and":[')+"]",t+="}"},E.prototype.getOperatorFromMongoOperator=function(e){var t;switch(e){case"$ne":t="notequal";break;case"$gt":t="greaterthan";break;case"$gte":t="greaterthanorequal";break;case"$lt":t="lessthan";break;case"$lte":t="lessthanorequal";break;case"$nin":t="notin"}return t},E.prototype.convertMongoQuery=function(o,i){var r=this,s=0;return o.forEach(function(l){s++,i+="{",void 0!==l.rules&&(i=("or"===l.condition?i+=' "$or":[':i+=' "$and":[',r.convertMongoQuery(l.rules,i)+"]"));var e,t="string"===l.type&&"in"!==l.operator&&"notin"!==l.operator&&l.value&&""!==l.value.trim()?l.value.replace(/'/g,"\\"):"",n=("string"!==l.type||"in"!==l.operator&&"notin"!==l.operator||!l.value||1!==l.value.length||(t=l.value[0].replace(/'/g,"\\")),l.field?l.field.substring(0):"");switch(l.operator){case"contains":i+='"'+n+'":{"$regex":"'+t+'"}';break;case"notcontains":i+='"'+n+'":{"$not":{"$regex":"'+l.value+'"}}';break;case"startswith":i+='"'+n+'":{"$regex":"^'+t+'"}';break;case"notstartswith":i+='"'+n+'":{"$not":{"$regex":"^'+l.value+'"}}';break;case"endswith":i+='"'+n+'":{"$regex":"'+t+'$"}';break;case"notendswith":i+='"'+n+'":{"$not":{"$regex":"'+l.value+'$"}}';break;case"isnull":i+='"'+n+'": null';break;case"isnotnull":i+='"'+n+'":{"$ne": null}';break;case"isempty":i+='"'+n+'": ""';break;case"isnotempty":i+='"'+n+'":{"$ne": ""}';break;case"equal":"string"===l.type?i+='"'+n+'":"'+t+'"':"date"===l.type?i+='"'+n+'":"'+l.value+'"':(l.type,i+='"'+n+'":'+l.value);break;case"notequal":"string"===l.type?i+='"'+n+'":{"$ne":"'+t+'"}':"date"===l.type?i+='"'+n+'":{"$ne":"'+l.value+'"}':i+='"'+n+'":{"$ne":'+l.value+"}";break;case"in":"string"===l.type?1<l.value.length?(e=(e=l.value.map(function(e,t){return t<l.value.length?'"'+e+'"':""}).toString()).endsWith(",")?e.substring(0,e.length-1):e,i+='"'+n+'": { "$in": ['+e+"]}"):i+='"'+n+'": { "$in": ["'+t+'"]}':"number"===l.type&&(1<l.value.length?i+='"'+n+'": { "$in": ['+l.value.toString()+"]}":i+='"'+n+'": { "$in": ['+l.value+"]}");break;case"notin":"string"===l.type?1<l.value.length?(e=(e=l.value.map(function(e,t){return t<l.value.length?'"'+e+'"':""}).toString()).endsWith(",")?e.substring(0,e.length-1):e,i+='"'+n+'": { "$nin": ['+e+"]}"):i+='"'+n+'": { "$nin": ["'+t+'"]}':"number"===l.type&&(1<l.value.length?i+='"'+n+'": { "$nin": ['+l.value.toString()+"]}":i+='"'+n+'": { "$nin": ['+l.value+"]}");break;case"greaterthan":"number"===l.type?i+='"'+n+'": { "$gt": '+l.value+"}":i+='"'+n+'": { "$gt": "'+l.value+'"}';break;case"greaterthanorequal":"number"===l.type?i+='"'+n+'": { "$gte": '+l.value+"}":i+='"'+n+'": { "$gte": "'+l.value+'"}';break;case"between":"number"===l.type?i+='"'+n+'": {"$gte":'+l.value[0]+', "$lte":'+l.value[1]+"}":i+='"'+n+'": {"$gte": "'+l.value[0]+'", "$lte": "'+l.value[1]+'"}';break;case"notbetween":"number"===l.type?i+='"$or":[{"'+n+'": {"$lt":'+l.value[0]+'}}, {"'+n+'": {"$gt":'+l.value[1]+"}}]":i+='"$or":[{"'+n+'": {"$lt": "'+l.value[0]+'"}}, {"'+n+'": {"$gt": "'+l.value[1]+'"}}]';break;case"lessthan":"number"===l.type?i+='"'+n+'": { "$lt": '+l.value+"}":i+='"'+n+'": { "$lt": "'+l.value+'"}';break;case"lessthanorequal":"number"===l.type?i+='"'+n+'": { "$lte": '+l.value+"}":i+='"'+n+'": { "$lte": "'+l.value+'"}'}i+="}",o.length!==s&&(i+=",")}),i},E.prototype.mongoParser=function(e,t,l){var n;-1<Object.keys(e).indexOf("$and")?(n=e.$and,t.condition="and"):-1<Object.keys(e).indexOf("$or")&&(n=e.$or,t.condition="or"),t.rules=[],this.mongoRecursion(n,t.rules,l)},E.prototype.mongoRecursion=function(e,t,l){for(var n,o,i,r,s,a,u,d,p,c=0,h=e.length;c<h;c++){var g=[],m=[],f=Object.keys(e[c])[0],y=e[c][f];if("$and"===f)u=this.parent.enableNotCondition?{condition:f.replace("$",""),rules:[],not:!1}:{condition:f.replace("$",""),rules:[]},t.push(u),this.mongoRecursion(e[c][f],t[t.length-1].rules,l);else if("$or"===f){var v,b,C,S,x,q=void 0;Array.isArray(y)&&2===y.length&&(S=y[(x=Object.keys(y))[0]],x=y[x[1]],"object"==typeof S)&&(v=Object.keys(S)[0],C=Object.keys(S[Object.keys(S)[0]])[0],b=Object.keys(x[Object.keys(x)[0]])[0],"$lt"===C)&&"$gt"===b&&(S=S[v][C],C=x[v][b],t.push(d={field:v,label:v,value:p=[S,C],operator:n="notbetween",type:o="number"==typeof S?"number":"date"}),q=!0),q||(u=this.parent.enableNotCondition?{condition:f.replace("$",""),rules:[],not:!1}:{condition:f.replace("$",""),rules:[]},t.push(u),this.mongoRecursion(e[c][f],t[t.length-1].rules,l))}else{if(null===(y=e[c][f])&&(n="isnull"),"boolean"==typeof y&&(n="equal",o="boolean",p=y),"number"==typeof y)p=y,o="number",n="equal";else if("object"==typeof y&&null!==y){for(var E=Object.keys(y),O=0;O<E.length;O++)if(r=E[O],i=y[E[O]],"$ne"===r&&L.isNullOrUndefined(i)&&(n="isnotnull",p=null),"$ne"===r&&"boolean"==typeof i&&(n="notequal",p=i,o="boolean"),2<=E.length&&E[O]?("object"==typeof i?(n="notbetween",f=Object.keys(i)[0],s=[Object.keys(i[f])[0]],g.push(i[f][s]),o="number"):(n="between",g.push(i)),"number"==typeof i&&(o="number")):"object"==typeof i&&null!==i?"$not"===r&&"$regex"===Object.keys(i)[0]?p=-1<i.$regex.indexOf("^")?(n="notstartswith",i.$regex.replace("^","")):-1<i.$regex.indexOf("$")?(n="notendswith",i.$regex.replace("$","")):(n="notcontains",i.$regex):(n="$in"===r?"in":"notin",o="number"==typeof(m=i)[0]?"number":"string"):"number"==typeof i&&(n=this.getOperatorFromMongoOperator(r),o="number",p=i),"string"==typeof i){"$regex"===r&&(n="contains",p=i,o="string"),"$ne"===r&&(null!==i&&0<i.length&&isNaN(Date.parse(i))?(n="notequal",p=i):L.isNullOrUndefined(i)?(n="isnotnull",p=i):""===i&&(n="isnotempty",p=i),o="string"),-1<i.indexOf("^")&&(n="startswith",p=i.replace("^",""),o="string"),-1<i.indexOf("$")&&"$not"!==r&&(n="endswith",p=i.replace("$",""),o="string");for(var k=0,w=this.parent.columns;k<w.length;k++){var N=w[k];if(N.field===f){a=N.type;break}}isNaN(Date.parse(i))&&"date"!==a||(n=n||this.getOperatorFromMongoOperator(r),o="date",p=i)}}else y&&"string"==typeof y&&!isNaN(Date.parse(y))?(n="equal",p=y,o="date"):"string"==typeof y&&""!==y&&"true"!==y&&"false"!==y?(n="equal",p=y,o="string"):"string"==typeof y&&""===y&&(n="isempty",p=y,o="string");d=g&&1<g.length?{field:f,label:f,value:g,operator:n,type:o}:m&&1<m.length?{field:f,label:f,value:m,operator:n,type:o}:{field:f,label:f,value:p,operator:n,type:o},t.push(d),n=""}}},E.prototype.convertParamSqlToSql=function(e){for(var t=e.sql,l=e.params,n=t.split("?"),o=n[0],i=0;i<l.length;i++)o+="string"==typeof l[i]?"'"+l[i]+"'"+n[i+1]:l[i]+n[i+1];return o=(o=2<=o.length&&"("===o[0]&&")"===o[o.length-1]?o.slice(1,-1):o).replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},E.prototype.convertNamedParamSqlToSql=function(e){var t=e.sql,l=e.params,n=t;return Object.keys(l).forEach(function(e){var t=l[e];n=n.replace(e=":"+e,"string"==typeof t?"'"+t+"'":String(t))}),n=(n=2<=n.length&&"("===n[0]&&")"===n[n.length-1]?n.slice(1,-1):n).replace(/!= ''(?! =)/g,"IS NOT EMPTY").replace(/= ''/g,"IS EMPTY")},E.prototype.getParameterSql=function(e){var e=L.extend({},e,null,!0),t=this.updateRuleValue(e,!1);return this.getParameterSQLVal(this.parent.getSqlFromRules(e),t.ruleVal)},E.prototype.getNamedParameterSql=function(e){var e=L.extend({},e,null,!0),t=this.updateRuleValue(e,!0);return this.getNamedParameterSQLVal(this.parent.getSqlFromRules(e),t.namedRuleVal)},E.prototype.getParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},E.prototype.getNamedParameterSQLVal=function(e,t){return{sql:"("+e.replace(/[%']/g,"")+")",params:t}},E.prototype.updateRuleValue=function(e,t){return this.updateValue(e.rules,t,[],{},[])},E.prototype.updateValue=function(e,t,l,n,o){if(!L.isNullOrUndefined(e))for(var i=0;i<e.length;i++)if(e[i].rules)l=(a=this.updateValue(e[i].rules,t,l,n,o)).ruleVal,n=a.namedRuleVal;else{var r=void 0;if(e[i].value instanceof Array)for(var s=0;s<e[i].value.length;s++)t&&(r=this.getNamedParameter(e[i].field,o)),L.isNullOrUndefined(e[i].value[s])||("string"!==e[i].type&&e[i].type,t?n[r]=e[i].value[s]:l.push(e[i].value[s])),e[i].value[s]=t?":"+r:"?";else if(t&&(r=this.getNamedParameter(e[i].field,o)),e[i].operator.indexOf("null")<1&&("string"!==e[i].type||"string"===e[i].type&&(""!==e[i].value||0===e[i].value))){if("string"===e[i].type||"date"===e[i].type)if(e[i].operator.indexOf("empty")<1){var a=e[i].value.toString();switch(e[i].operator){case"startswith":case"notstartswith":a+="%";break;case"endswith":case"notendswith":a="%"+a;break;case"contains":case"notcontains":a="%"+a+"%"}t?n[r]=a:l.push(a)}else t?n[r]="":l.push(""),"isempty"===e[i].operator?e[i].operator="equal":e[i].operator="notequal";else L.isNullOrUndefined(e[i].value)||(t?n[r]=e[i].value:l.push(e[i].value));e[i].value=t?":"+r:"?"}}return{ruleVal:l,namedRuleVal:n}},E.prototype.getNamedParameter=function(e,t){var l=null;if(0<t.length)for(var n=t.length-1;0<=n;n--){var o=t[n];if(-1<o.indexOf(e)){l=e+"_"+(parseInt(o.split("_")[1],10)+1);t.push(l);break}}return l||t.push(l=e+"_1"),l},E.prototype.getModuleName=function(){return"query-library"};o=E;function E(e){this.parent=e,this.addEventListener()}e.Columns=i,e.QueryBuilder=l,e.QueryLibrary=o,e.Rule=u,e.ShowButtons=C,e.Value=g,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
11
11
|
//# sourceMappingURL=ej2-querybuilder.umd.min.js.map
|