UNPKG

@syncfusion/ej2-querybuilder

Version:
1 lines 176 kB
this.ej=this.ej||{},this.ej.querybuilder=function(e,t,l,n,r,i,o,s,a){"use strict";var u=function(){var e=function(t,l){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var l in t)t.hasOwnProperty(l)&&(e[l]=t[l])})(t,l)};return function(t,l){function n(){this.constructor=t}e(t,l),t.prototype=null===l?Object.create(l):(n.prototype=l.prototype,new n)}}(),d=function(){return(d=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++){t=arguments[l];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)},c=function(e,t,l,n){var r,i=arguments.length,o=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,l):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,l,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(o=(i<3?r(o):i>3?r(t,l,o):r(t,l))||o);return i>3&&o&&Object.defineProperty(t,l,o),o},p=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(null)],l.prototype,"field",void 0),c([t.Property(null)],l.prototype,"label",void 0),c([t.Property(null)],l.prototype,"type",void 0),c([t.Property(null)],l.prototype,"values",void 0),c([t.Property(null)],l.prototype,"operators",void 0),c([t.Property()],l.prototype,"ruleTemplate",void 0),c([t.Property(null)],l.prototype,"template",void 0),c([t.Property({isRequired:!0,min:0,max:Number.MAX_VALUE})],l.prototype,"validation",void 0),c([t.Property(null)],l.prototype,"format",void 0),c([t.Property(null)],l.prototype,"step",void 0),c([t.Property(null)],l.prototype,"value",void 0),c([t.Property(null)],l.prototype,"category",void 0),c([t.Property(null)],l.prototype,"columns",void 0),l}(t.ChildProperty),h=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(null)],l.prototype,"condition",void 0),c([t.Collection([],l)],l.prototype,"rules",void 0),c([t.Property(null)],l.prototype,"field",void 0),c([t.Property(null)],l.prototype,"label",void 0),c([t.Property(null)],l.prototype,"type",void 0),c([t.Property(null)],l.prototype,"operator",void 0),c([t.Property(null)],l.prototype,"value",void 0),c([t.Property(!1)],l.prototype,"not",void 0),c([t.Property(null)],l.prototype,"isLocked",void 0),l}(t.ChildProperty),m=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(null)],l.prototype,"numericTextBoxModel",void 0),c([t.Property(null)],l.prototype,"multiSelectModel",void 0),c([t.Property(null)],l.prototype,"datePickerModel",void 0),c([t.Property(null)],l.prototype,"textBoxModel",void 0),c([t.Property(null)],l.prototype,"radioButtonModel",void 0),l}(t.ChildProperty),g=function(e){function l(){return null!==e&&e.apply(this,arguments)||this}return u(l,e),c([t.Property(!1)],l.prototype,"cloneRule",void 0),c([t.Property(!1)],l.prototype,"cloneGroup",void 0),c([t.Property(!1)],l.prototype,"lockRule",void 0),c([t.Property(!1)],l.prototype,"lockGroup",void 0),c([t.Property(!0)],l.prototype,"ruleDelete",void 0),c([t.Property(!0)],l.prototype,"groupInsert",void 0),c([t.Property(!0)],l.prototype,"groupDelete",void 0),l}(t.ChildProperty),f=function(e){function p(t,l){var r=e.call(this,t,l)||this;return r.isReadonly=!0,r.fields={text:"label",value:"field"},r.updatedRule={not:!1,condition:"and",isLocked:!1},r.isLocale=!1,r.isRefreshed=!1,r.isNotified=!1,r.isAddSuccess=!1,r.isNotValueChange=!1,r.isFieldChange=!1,r.isFieldClose=!1,r.isDestroy=!1,r.isGetNestedData=!1,r.isCustomOprCols=[],r.groupCounter=0,r.lockItems=[],r.groupIndex=-1,r.ruleIndex=-1,r.isLastGroup=!1,r.cloneGrpBtnClick=!1,r.isMiddleGroup=!1,r.cloneRuleBtnClick=!1,r.isValueEmpty=!1,r.isPropChange=!1,r.isRuleClicked=!1,r.groupCloned=!1,n.MultiSelect.Inject(n.CheckBoxSelection),r}return u(p,e),p.prototype.getPersistData=function(){return this.addOnPersist(["rule"])},p.prototype.reset=function(){this.isImportRules=!1;var e=this.element.querySelector(".e-group-body"),l=this.element.querySelectorAll("input.e-control"),n=0,r=function(){for(var e=Math.min(n+20,l.length),i=n;i<e;i++){var o=l[i];try{if(o.className.indexOf("e-tooltip")>-1)(s=t.getComponent(o,"tooltip"))&&s.destroy();else if(o.parentElement&&o.parentElement.className.indexOf("e-tooltip")>-1){var s=t.getComponent(o.parentElement,"tooltip");s&&s.destroy()}}catch(e){console.warn("Error destroying tooltip:",e)}}(n=e)<l.length&&requestAnimationFrame(r)};if(l.length>0&&r(),e)e.textContent="";else{var i=document.createDocumentFragment(),o=this.createElement("div",{attrs:{class:"e-group-container"}}),s=this.createElement("div",{attrs:{class:"e-group-header"}}),a=this.createElement("div",{attrs:{class:"e-group-body"}});o.appendChild(s),o.appendChild(a),i.appendChild(o),this.element.appendChild(i),e=this.element.querySelector(".e-group-body")}if(this.headerTemplate&&this.isRoot&&(this.element.textContent="",this.isRoot=!1),this.enableNotCondition)for(var u=this.element.querySelectorAll(".e-qb-toggle"),d=0;d<u.length;d++)t.removeClass([u[d]],"e-active-toggle");e&&e.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),e&&e.parentElement&&this.disableRuleCondition(e.parentElement)},p.prototype.getWrapper=function(){return this.element},p.prototype.getModuleName=function(){return"query-builder"},p.prototype.requiredModules=function(){var e=[];return e.push({member:"query-library",args:[this]}),e},p.prototype.GetRootColumnName=function(e){return t.isNullOrUndefined(e)?"":this.separator?e.split(this.separator)[0]:e},p.prototype.initialize=function(){var e=this;if(this.dataColl.length){var t,l,n=Object.keys(this.dataColl[0]),r=[],i=[],o=!1,s=!1,a={isRequired:!0,min:0,max:Number.MAX_VALUE};if(this.columns.length)this.columnSort(),this.columns.forEach(function(r){e.updateCustomOperator(r,"initial"),r.type||(n.indexOf(r.field)>-1&&(l=e.dataColl[0][r.field],"string"===(t=typeof l)?s=!isNaN(Date.parse(l)):"object"===t&&(s=l instanceof Date&&!isNaN(l.getTime()),t="string"),r.type=t,s=!1),t="string"),r.validation||(r.validation=a),r.category?o=!0:r.category=e.l10n.getConstant("OtherFields"),i.indexOf(r.category)<0&&i.push(r.category),(!r.operators||e.isLocale&&-1===e.isCustomOprCols.indexOf(r.field))&&(r.operators=e.customOperators[r.type+"Operator"])}),o&&(i.length>1||i[0]!==this.l10n.getConstant("OtherFields"))&&(this.fields={text:"label",value:"field",groupBy:"category"}),this.updateSubFieldsFromColumns(this.columns);else{for(var u=0,d=n.length;u<d;u++)l=this.dataColl[0][n[u]],"string"===(t=typeof l)?s=!isNaN(Date.parse(l)):"object"!==t||Object.keys(l).length||(s=l instanceof Date&&!isNaN(l.getTime()),t="string"),r[u]={field:n[u],label:n[u],type:s?"date":t,validation:a},s=!1,r[u].operators=this.customOperators[r[u].type+"Operator"],"object"===t&&this.updateSubFields(l,r[u]);this.columns=r}}else this.columns&&this.columns.length&&("Default"!==this.sortDirection&&this.columnSort(),this.processColumnsInBatches(),this.columns.length>50?setTimeout(function(){e.updateSubFieldsFromColumns(e.columns)},0):this.updateSubFieldsFromColumns(this.columns));this.trigger("dataBound",{type:"dataBound"})},p.prototype.processColumnsInBatches=function(){var e=this,t=this.columns,l=0,n=function(){for(var r=Math.min(l+10,t.length),i=l;i<r;i++)t[i].category&&t[i].category!==e.l10n.getConstant("OtherFields")?e.fields={text:"label",value:"field",groupBy:"category"}:t[i].category=e.l10n.getConstant("OtherFields"),e.updateCustomOperator(t[i],"initial"),(!t[i].operators||e.isLocale&&-1===e.isCustomOprCols.indexOf(t[i].field))&&(t[i].operators=e.customOperators[t[i].type+"Operator"]);(l=r)<t.length&&requestAnimationFrame(n)};n()},p.prototype.updateSubFieldsFromColumns=function(e,t){if(e.length>50)return void this.updateSubFieldsLarge(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))},p.prototype.updateSubFieldsLarge=function(e,t){var l=this,n=0,r=e.length,i=function(){for(var o=Math.min(n+10,r);n<o;n++)""!==l.separator&&e[n].field.indexOf(l.separator)<0&&(e[n].field=t?t+l.separator+e[n].field:e[n].field),e[n].operators?l.updateCustomOperator(e[n]):e[n].type&&"object"!==e[n].type&&(e[n].operators=l.customOperators[e[n].type+"Operator"]);n<r?requestAnimationFrame(i):setTimeout(function(){for(var t=0;t<r;t++)e[t].columns&&(e[t].type="object",l.updateSubFieldsFromColumns(e[t].columns,e[t].field))},0)};i()},p.prototype.updateSubFields=function(e,t,l){var n;t.columns=[];var r,i,o=Object.keys(e);l=l||this.dataColl[0];for(var s=0,a=o.length;s<a;s++){var u=t.field.split(".");i=l?l[u[u.length-1]][o[s]]:this.dataColl[0][t.field][o[s]];var d=l[t.field.split(this.separator)[t.field.split(this.separator).length-1]];r=typeof i,n={field:t.field+this.separator+o[s],label:o[s],type:r="object"!==r||isNaN(Date.parse(i))?r:"date"},"object"!==r&&(n.operators=this.customOperators[r+"Operator"]),t.columns.push(n),"object"===r&&this.updateSubFields(i,n,d)}},p.prototype.updateCustomOperator=function(e,l){if(e.operators){this.isLocale||"initial"!==l||t.isNullOrUndefined(this.isCustomOprCols)||this.isCustomOprCols.push(e.field);for(var n=this,r=0;r<e.operators.length;r++)!function(t){var l=Object.keys(e.operators[t]).indexOf("sqlOperator");if(l>-1){var r=e.operators[t],i=Object.keys(r),o=i.map(function(e){return r[""+e]}).join(",").split(","),s=i.indexOf("value");n.operators[o[s]]=o[l]}}(r)}},p.prototype.focusEventHandler=function(e){this.target=e.target},p.prototype.clickEventHandler=function(e){var l,n=this,r=e.target;this.isImportRules=!1;var i;if("SPAN"===r.tagName&&(r=r.parentElement),"string"==typeof r.className&&r.className.indexOf("e-collapse-rule")>-1){a=new t.Animation({duration:1e3,delay:0});this.element.querySelectorAll(".e-summary-content").length<1&&this.renderSummary();var o=document.getElementById(this.element.id+"_summary_content"),s=o.querySelector(".e-summary-text");a.animate(".e-query-builder",{name:"SlideLeftIn"}),(d=this.element.querySelector(".e-group-container")).style.display="none",s.textContent=this.getSqlFromRules(this.rule),o.style.display="block",s.style.height=s.scrollHeight+"px"}if("BUTTON"===r.tagName&&"string"==typeof r.className&&r.className.indexOf("e-qb-toggle")<0){var a=new t.Animation({duration:1e3,delay:0});switch(!0){case r.className.indexOf("e-removerule")>-1:this.actionButton=r,this.deleteRule(r);break;case r.className.indexOf("e-clone-rule-btn")>-1:this.actionButton=r,this.cloneRuleBtnClick=!0,this.isRuleClicked=!0,this.ruleClone(r);break;case r.className.indexOf("e-lock-rule-btn")>-1:this.actionButton=r,this.ruleLock(r);break;case r.className.indexOf("e-lock-grp-btn")>-1:this.actionButton=r,this.groupLock(r);break;case r.className.indexOf("e-clone-grp-btn")>-1:this.actionButton=r,this.cloneGrpBtnClick=this.groupCloned=!0,this.isRuleClicked=!0,this.groupClone(t.closest(r,".e-group-container"));break;case r.className.indexOf("e-deletegroup")>-1:this.actionButton=r,this.deleteGroup(t.closest(r,".e-group-container"));break;case r.className.indexOf("e-edit-rule")>-1:if(a.animate(".e-query-builder",{name:"SlideLeftIn"}),document.getElementById(this.element.id+"_summary_content").style.display="none",this.element.querySelectorAll(".e-group-container").length<1){this.addGroupElement(!1,this.element,this.rule.condition,!1,this.rule.not);var u=t.extend({},this.rule,{},!0);this.setGroupRules(u),this.renderSummaryCollapse()}else{var d=this.element.querySelector(".e-group-container");d.querySelectorAll(".e-collapse-rule").length<1&&this.renderSummaryCollapse(),d.style.display="block"}}}else if("LABEL"===r.tagName&&r.parentElement.className.indexOf("e-btn-group")>-1||"string"==typeof r.className&&r.className.indexOf("e-qb-toggle")>-1){var c=t.closest(r,".e-group-container");if(!this.headerTemplate){var p=r.getAttribute("for"),h=void 0;p?h=document.getElementById(p).getAttribute("value"):this.enableSeparateConnector&&(h=r.classList.contains("e-btngroup-or-lbl")?"or":r.classList.contains("e-btngroup-and-lbl")?"and":r.textContent),i=c.id.replace(this.element.id+"_","");var m=this.getGroup(i),g=void 0;if(this.enableNotCondition)if(r.className.indexOf("e-qb-toggle")>-1){var f=c.getElementsByClassName("e-qb-toggle")[0];f.className.indexOf("e-active-toggle")>-1?(t.removeClass([f],"e-active-toggle"),g=!1):(t.addClass([f],"e-active-toggle"),g=!0),h=m.condition}else g=m.not;l={groupID:i,cancel:!1,type:"condition",value:h.toLowerCase()},this.enableNotCondition&&(l={groupID:i,cancel:!1,type:"condition",value:h.toLowerCase(),not:g})}this.isImportRules?this.beforeSuccessCallBack(l,r):this.trigger("beforeChange",l,function(e){n.beforeSuccessCallBack(e,r)}),this.target=r}},p.prototype.beforeSuccessCallBack=function(e,l){if(e&&!e.cancel){var n=t.closest(l,".e-group-container"),r=n.id.replace(this.element.id+"_",""),i=this.getValidRules(this.rule),o=this.getParentGroup(n);if(this.enableSeparateConnector){var s=(n=t.isNullOrUndefined(t.closest(l,".e-rule-container"))&&n.classList.contains("e-group-container")?null!==l.parentElement.previousElementSibling?l.parentElement.previousElementSibling:n:t.closest(l,".e-rule-container")).id.replace(this.element.id+"_","");n.classList.contains("e-rule-container")?(o=this.getRule(n)).condition=e.value:n.classList.contains("e-group-container")&&((o=this.getGroup(n)).condition=e.value),this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:r,ruleID:s,type:"condition",value:o.condition})}else o.condition=e.value,this.enableNotCondition&&(o.not=e.not),this.isImportRules||this.trigger("change",{groupID:r,type:"condition",value:o.condition});if(this.filterRules(i,this.getValidRules(this.rule),"condition"),this.enableSeparateConnector){var a=l.parentElement.querySelector(".e-btngroup-and"),u=l.parentElement.querySelector(".e-btngroup-or");a&&u&&("and"===e.value?(a.checked=!0,u.checked=!1):"or"===e.value&&(u.checked=!0,a.checked=!1))}}},p.prototype.selectBtn=function(e,l){"beforeOpen"===l.name?this.showButtons.groupInsert||t.isNullOrUndefined(this.showButtons.groupInsert)?(this.element.querySelectorAll(".e-group-container").length>=this.maxGroupCount+1?t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):t.removeClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"),this.enableRtl&&t.addClass([l.element.querySelector("li").parentElement],"e-rtl")):t.addClass([l.element.querySelector("li span.e-addgroup").parentElement],"e-button-hide"):l.element.children[0].className.indexOf("e-addrule")>-1?(this.isRuleClicked=!0,this.addRuleElement(t.closest(e,".e-group-container"),{})):l.element.children[0].className.indexOf("e-addgroup")>-1&&(this.isRuleClicked=!0,this.addGroupElement(!0,t.closest(e,".e-group-container"),"",!0))},p.prototype.appendRuleElem=function(e,l,n,r,i,o){var s,a,u,d=e&&e.querySelector(".e-rule-list");if("change"===n)s=t.select("#"+r,e);else{if((s=this.createElement("div",{attrs:{class:"e-rule-container"}})).setAttribute("id",e.id+"_rule"+this.ruleIdCounter),this.showButtons.cloneRule&&this.cloneRuleBtnClick){if(this.ruleIndex<0)d.appendChild(s);else if(this.enableSeparateConnector){for(var c=-1,p=this.ruleIndex+1,h=0;h<p&&h!==d.children.length;h++)d.children[h].classList.contains("e-rule-container")&&(p++,c++);d.insertBefore(s,d.children[this.ruleIndex+c+1])}else d.insertBefore(s,d.children[this.ruleIndex+1]);this.cloneRuleBtnClick=!1}else d.appendChild(s);this.ruleIdCounter++}if(l&&l.ruleTemplate&&o){u={requestType:"template-initialize",ruleID:s.id,action:i,fields:this.fields,rule:o},this.trigger("actionBegin",u),this.ruleTemplateFn=this.templateParser(l.ruleTemplate);var m=this.element.id+l.field;if(u.fields=this.fields,u.columns=this.columns,""===o.field&&(o.field=l.field),u.operators=this.getOperators(o.field),u.operatorFields={text:"key",value:"value"},this.isReact)(a=this.ruleTemplateFn(u,this,s.id,m)[0]).className+=" e-rule-field",s.appendChild(a);else if(this.isAngular){var g=this.ruleTemplateFn(u,this,s.id,m);(a=3===g[0].nodeType?g[1]:g[0]).className+=" e-rule-field",s.appendChild(a)}else this.isVue3?(a=this.ruleTemplateFn(u,this,"Template",m),t.append(a,s),s.children.length&&(s.children[s.children.length-1].className+=" e-rule-field")):((a=this.ruleTemplateFn(u,this,"Template",m)[0]).className+=" e-rule-field",s.appendChild(a))}else a=this.ruleElem.querySelector(".e-rule-field").cloneNode(!0),s.appendChild(a);return this.showButtons.lockGroup&&t.removeClass(s.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.showButtons.lockRule&&t.removeClass(s.querySelectorAll(".e-lock-rule-btn"),"e-button-hide"),this.showButtons.cloneGroup&&t.removeClass(s.querySelectorAll(".e-clone-grp-btn"),"e-button-hide"),this.showButtons.cloneRule&&t.removeClass(s.querySelectorAll(".e-clone-rule-btn"),"e-button-hide"),this.showButtons.ruleDelete&&t.removeClass(s.querySelectorAll(".e-lock-grp-btn"),"e-button-hide"),this.allowDragAndDrop&&t.removeClass(s.querySelectorAll(".e-drag-qb-rule"),"e-hidden"),l&&l.ruleTemplate&&o&&this.renderReactTemplates(),s},p.prototype.addRuleElement=function(e,t,l,n,r,i){var o=this;if(e){var s={groupID:e.id.replace(this.element.id+"_",""),cancel:!1,type:"insertRule"};this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addRuleSuccessCallBack(s,e,t,l,n,r,i)):this.trigger("beforeChange",s,function(s){o.addRuleSuccessCallBack(s,e,t,l,n,r,i)})}},p.prototype.addRuleSuccessCallBack=function(e,l,n,r,i,o,s){var a,u,d,c=this,p=this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode,h=p?"250px":"200px",m=n&&n.field?this.getColumn(n.field):r||this.columns[0],g={label:"",field:"",type:"",operator:""};if(!e.cancel){if(m&&m.ruleTemplate&&n.field){this.selectedColumn=m,u=this.selectedColumn.operators,g={label:m.label,field:m.field,type:m.type,operator:u[0].value};var f=Object.keys(n).length?n:g,v={requestType:"template-initialize",ruleID:(d=this.appendRuleElem(l,m,i,o,"field",f)).id,action:"insert-rule",fields:this.fields,rule:f};this.trigger("actionBegin",v),setTimeout(function(){var e={requestType:"template-create",ruleID:d.id,action:"insert-rule",fields:c.fields,rule:f};c.trigger("actionBegin",e)},0)}else{(d=this.appendRuleElem(l,m,i,o,"field")).querySelector(".e-filter-input").setAttribute("id",d.id+"_filterkey");var y=d.querySelector(".e-rule-delete");if(this.element.className.indexOf("e-device")>-1||"Vertical"===this.displayMode)y.textContent=this.l10n.getConstant("Remove"),t.addClass([y],"e-flat"),t.addClass([y],"e-primary");else{t.addClass([y],"e-round"),t.addClass([y],"e-icon-btn"),y.setAttribute("title",this.l10n.getConstant("DeleteRule"));var b=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-delete-icon"}});y.appendChild(b)}this.showButtons.ruleDelete||y.classList.add("e-button-hide")}d.className="e-rule-container "+(p?"e-vertical-mode":"e-horizontal-mode");var C=d.previousElementSibling;this.processAdjacentElements(d,C,n),this.isImportRules||this.updateAddedRule(l,n,g,s,o,!!this.enableSeparateConnector||null),""===this.rule.condition&&(this.isRuleClicked||this.rule.rules.length>1)&&(this.rule.condition="and"),this.isRuleClicked=!1;var S=this.rule.rules.length;if(m&&(!m||m.ruleTemplate)&&n.field||(S>20?setTimeout(function(){c.applyFieldComponent(d,n,h)},0):this.applyFieldComponent(d,n,h)),a=d.id.replace(this.element.id+"_",""),n&&n.isLocked){var E=d.querySelector(".e-lock-rule-btn");this.ruleLock(E)}this.isImportRules||this.prvtEvtTgrDaD||this.trigger("change",{groupID:l.id.replace(this.element.id+"_",""),ruleID:a,type:"insertRule"})}this.enableSeparateConnector&&t.isNullOrUndefined(n.condition)&&a&&(n=this.getRule(a)),this.enableSeparateConnector&&this.processConnectorElements(d)},p.prototype.processAdjacentElements=function(e,l,n){if(this.enableSeparateConnector){if(l&&l.classList.contains("e-group-container")){var r=l.querySelectorAll(".e-rule-container");l=r[r.length-1]}if(l&&l.classList.contains("e-rule-container")){var i=this.getRule(l);this.headerTemplate&&this.headerTemplateFn(l,!1,i.condition,i,l.id)}else t.isNullOrUndefined(l)&&e.id!==this.element.id+"_group0_rule0"&&this.handleOrphanedRuleElement(e,n)}else l&&l.className.indexOf("e-rule-container")>-1&&(e.classList.add("e-joined-rule"),l.classList.add("e-prev-joined-rule"));l&&l.className.indexOf("e-group-container")>-1&&e.className.indexOf("e-separate-rule")<0&&(e.className+=" e-separate-rule")},p.prototype.handleOrphanedRuleElement=function(e,t){var l=e.closest(".e-group-container");if(l&&l.previousElementSibling){var n=l.previousElementSibling,r=n.querySelectorAll(".e-rule-container");if(n.classList.contains("e-group-container")&&(n=r[r.length-1]),n.classList.contains("e-rule-container")){var i=this.getRule(n);this.headerTemplateFn(n,!1,i.condition,i,n.id,!0)}}else this.headerTemplateFn(e,!1,t.condition,t,e.id,!0)},p.prototype.processConnectorElements=function(e){for(var l,n=e.previousElementSibling;n&&!n.classList.contains("e-rule-container");){if(n.classList.contains("e-group-container")){n=(l=n.querySelectorAll(".e-rule-container"))[l.length-1];break}n=n.previousElementSibling}if(this.headerTemplate&&n){var r=this.getRule(n),i={requestType:"rule-template-create",ruleID:n.id,condition:r.condition,notCondition:!!this.enableNotCondition||void 0};this.trigger("actionBegin",i)}else t.isNullOrUndefined(n)&&e.id!==this.element.id+"_group0_rule0"&&this.handleOrphanedConnectorElement(e);this.setMultiConnector(e)},p.prototype.handleOrphanedConnectorElement=function(e){var t=e.closest(".e-group-container");if(t&&t.previousElementSibling&&t.previousElementSibling.previousElementSibling){var l=t.previousElementSibling.previousElementSibling;if(l.classList.contains("e-group-container")){var n=l.querySelectorAll(".e-rule-container");l=n[n.length-1]}if(l.classList.contains("e-rule-container")){var r=this.getRule(l),i={requestType:"rule-template-create",ruleID:l.id,condition:r.condition,notCondition:!!this.enableNotCondition||void 0};this.trigger("actionBegin",i)}}},p.prototype.applyFieldComponent=function(e,t,l){"Default"===this.fieldMode?this.applyDropdownListComponent(e,t,l):this.applyDropdownTreeComponent(e,t,l)},p.prototype.applyDropdownListComponent=function(e,t,l){var r,i;i=this.separator&&t.field?this.GetRootColumnName(t.field):this.autoSelectField?this.GetRootColumnName(t.field):this.isImportRules?this.GetRootColumnName(t.field):t.field,r={dataSource:this.columns,fields:this.fields,placeholder:this.l10n.getConstant("SelectField"),popupHeight:this.columns.length>5?l:"auto",close:this.fieldClose.bind(this,e.id+"_filterkey"),change:this.changeField.bind(this),value:t?i:null,open:this.popupOpen.bind(this,!0),cssClass:"qb-dropdownlist"},this.fieldModel&&(r=d({},r,this.fieldModel));var o=new n.DropDownList(r);o.appendTo("#"+e.id+"_filterkey");var s;s=this.separator&&t.field?this.GetRootColumnName(t.field):this.isImportRules?this.GetRootColumnName(t.field):o.value,this.selectedColumn=o.getDataByValue(s),Object.keys(t).length&&this.changeRule(t,{element:o.element,itemData:this.selectedColumn})},p.prototype.applyDropdownTreeComponent=function(e,l,r){var i,o=(this.isImportRules,l.field);this.dummyDropdownTreeDs=t.extend([],this.columns,[],!0),this.updateDropdowntreeDS(this.dummyDropdownTreeDs),i={fields:{dataSource:this.dummyDropdownTreeDs,value:"field",text:"label",child:"columns",expanded:"expanded",selectable:"selectable"},placeholder:this.l10n.getConstant("SelectField"),showClearButton:!1,popupHeight:this.columns.length>5?r:"auto",changeOnBlur:!1,change:this.changeField.bind(this),value:t.isNullOrUndefined(o)?null:[o],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&&(i=d({},i,this.fieldModel));var s=new n.DropDownTree(i);if(s.appendTo("#"+e.id+"_filterkey"),!t.isNullOrUndefined(s.value)){var a=this.getLabelFromColumn(s.value[0]);s.element.value=a}var u=t.isNullOrUndefined(l.field)?s.value:this.GetRootColumnName(l.field);this.selectedColumn=this.getColumn(u),Object.keys(l).length&&this.changeRule(l,{element:s.element,itemData:this.selectedColumn})},p.prototype.dropdownTreeFiltering=function(e){var l=this,n=this,r="",i=e.event.srcElement;r=(i.classList.contains("e-clear-icon")?i.parentElement.querySelector(".e-textbox"):i).id.split("_filterkey")[0];var o=document.getElementById(r);this.ddTree=t.getComponent(o.querySelector("input.e-dropdowntree"),"dropdowntree");var s=t.extend([],this.columns,[],!0);if(e.cancel=!0,""===e.text)this.changeDataSource(s);else{var a=s.map(function(t){return l.nestedChildFilter(e.text,t)}).filter(function(e){return null!==e});this.changeDataSource(a),setTimeout(function(){t.isNullOrUndefined(n.ddTree)||t.isNullOrUndefined(n.ddTree.treeObj)||n.ddTree.treeObj.expandAll()},100)}},p.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()},p.prototype.nestedChildFilter=function(e,t){var l=this,n=t[this.ddTree.fields.child];if(!n)return this.isMatchedNode(e,t)?t:null;var r=n.map(function(t){return l.nestedChildFilter(e,t)}).filter(function(e){return null!==e});return r.length?(t[this.ddTree.fields.child]=r,t):(t[this.ddTree.fields.child]=n,this.isMatchedNode(e,t)?t:null)},p.prototype.isMatchedNode=function(e,t){var l=t[this.ddTree.fields.text].toLowerCase();return e=e?e.toLowerCase():"",-1!==l.indexOf(e)},p.prototype.dropdownTreeClose=function(){this.ddTree&&this.changeDataSource(t.extend([],this.columns,[],!0)),this.ddTree=null},p.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},p.prototype.updateAddedRule=function(e,l,n,r,i,o){var s,a,u,d=0;if(r){for(s=t.select("#"+i,e),a=t.closest(e,".e-group-container"),u=this.getParentGroup(a);s&&null!==s.previousElementSibling;){s=s.previousElementSibling;var c=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&&!c||d++}u.rules[d]=l}else{a=t.closest(e,".e-group-container"),u=this.getParentGroup(a);var p=l.custom;Object.keys(l).length?this.ruleIndex<0?(u.rules.push({field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}),p&&(u.rules[u.rules.length-1].custom=p),this.enableSeparateConnector&&(u.rules[u.rules.length-1].condition=l.condition?l.condition:n.condition)):(u.rules.splice(this.ruleIndex+1,0,{field:l.field,type:l.type,label:l.label,operator:l.operator,value:l.value}),p&&(u.rules[this.ruleIndex+1].custom=p),this.enableSeparateConnector&&(u.rules[this.ruleIndex+1].condition=l.condition?l.condition:n.condition)):(p&&(n.custom=p),this.autoSelectField&&(l.field=n.field=this.rule.rules[0].field),u.rules.push(n))}this.disableRuleCondition(e,u,o)},p.prototype.changeRuleTemplate=function(e,l){if(!e||!e.ruleTemplate){var n=t.closest(l,".e-group-container"),r=t.closest(l,".e-rule-container").id;if(this.previousColumn&&this.previousColumn.ruleTemplate&&(t.detach(l.closest('[id="'+r+'"]').querySelector(".e-rule-field")),this.clearQBTemplate([r])),e){var i=this.selectedColumn.operators,o={field:e.field,label:e.label,operator:i[0].value,value:""};this.addRuleElement(n,o,e,"change",r,!0)}else{o={field:"",label:"",operator:"",value:""};this.addRuleElement(n,o,e,"change",r,!0)}}},p.prototype.renderToolTip=function(e){var t=new a.Tooltip({content:this.l10n.getConstant("ValidationMessage"),isSticky:!0,position:"BottomCenter",cssClass:"e-querybuilder-error",afterClose:function(){t.destroy()},beforeOpen:function(e){var t=e.element.querySelector(".e-tooltip-close");t&&(t.style.display="none")}});t.appendTo(e),t.open(e)},p.prototype.validateFields=function(){var e,l=!0;if(this.allowValidation){var n=["isnull","isnotnull","isempty","isnotempty"],r=void 0,i=void 0,o=void 0,s=void 0,a=[],u=void 0,d=void 0,c=void 0,p=void 0,h=void 0,m=this.element.querySelectorAll(".e-rule-container");for(r=0,i=m.length;r<i;r++){var g=void 0;if(u=t.closest(m[r],".e-group-container"),h=this.getParentGroup(u),d=0,s=p=m[r],"DropdownTree"===this.fieldMode?(e=t.getComponent(m[r].querySelector(".e-rule-filter input.e-dropdowntree"),"dropdowntree"))&&e.value&&e.value.length&&(this.selectedColumn=this.getColumn(e.value[0]),g=this.selectedColumn.validation):(c=t.getComponent(m[r].querySelector(".e-rule-filter input.e-dropdownlist"),"dropdownlist"))&&c.value&&(this.selectedColumn=c.getDataByValue(c.value),g=!t.isNullOrUndefined(c.value)&&this.selectedColumn.validation),o=p.querySelector(".e-rule-field input.e-control"),g&&g.isRequired){for(;s&&null!==s.previousElementSibling;){s=s.previousElementSibling;var f=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&&!f||d++}if(o=p.querySelector(".e-rule-operator .e-control"),h.rules[d].operator||(o.parentElement.className.indexOf("e-tooltip")<0&&o.className.indexOf("e-tooltip")<0&&this.renderToolTip(o.parentElement),l=!1),h.rules[d].value instanceof Array&&(a=h.rules[d].value),n.indexOf(h.rules[d].operator)<-1&&t.isNullOrUndefined(h.rules[d].value)&&"date"!==h.rules[d].type||""===h.rules[d].value||null===h.rules[d].value||h.rules[d].value instanceof Array&&a.length<1){S=p.querySelectorAll(".e-rule-value .e-control");n.indexOf(h.rules[d].operator)<0&&(l=!1);for(var v=0,y=S.length;v<y;v++){var b=S[v],C=void 0;b.parentElement.className.indexOf("e-searcher")>-1?(C=t.closest(b,".e-multi-select-wrapper")).className.indexOf("e-tooltip")<0&&this.renderToolTip(C):S[v].parentElement.className.indexOf("e-tooltip")<0&&S[v].className.indexOf("e-tooltip")<0&&this.renderToolTip(S[v].parentElement),v++}}else if("date"===h.rules[d].type&&(null===h.rules[d].value||h.rules[d].value.indexOf(null)>-1)){var S=p.querySelectorAll(".e-rule-value .e-control");n.indexOf(h.rules[d].operator)<0&&(l=!1);for(var v=0,y=S.length;v<y;v++)S[v].parentElement.className.indexOf("e-tooltip")<0&&S[v].className.indexOf("e-tooltip")<0&&(t.isNullOrUndefined(h.rules[d].value)||null==h.rules[d].value[v])&&this.renderToolTip(S[v].parentElement)}}else(c&&c.element&&t.isNullOrUndefined(c.value)||e&&e.element&&(t.isNullOrUndefined(e.value)||e.value.length<1))&&(o.parentElement.className.indexOf("e-tooltip")<0&&this.renderToolTip(o.parentElement),l=!1)}}return l},p.prototype.refreshLevelColl=function(){this.levelColl={};var e=this.element.querySelector(".e-group-container");if(e){this.levelColl[e.id]=[0];var t={groupElement:e,level:[0]};this.refreshLevel(t)}},p.prototype.refreshLevel=function(e){var l,n,r=e.groupElement.querySelector(".e-rule-list").children,i=e.groupElement,o=r.length,s=0;for(n=0;n<o;n++)(l=r[n]).className.indexOf("e-group-container")>-1&&(e.level.push(s),this.levelColl[l.id]=e.level.slice(),s++,e.groupElement=l,e=this.refreshLevel(e));var a=t.closest(i,".e-rule-list");return e.groupElement=a?t.closest(a,".e-group-container"):i,e.level=this.levelColl[e.groupElement.id].slice(),e},p.prototype.groupTemplate=function(e){var t,l,n,r,i,o,s=this.createElement("div",{attrs:{class:"e-group-container"}}),a=this.createElement("div",{attrs:{class:"e-group-header"}}),u=this.createElement("div",{attrs:{class:"e-group-body"}}),d=this.createElement("div",{attrs:{class:"e-rule-list"}});if(s.appendChild(a),u.appendChild(d),s.appendChild(u),!this.headerTemplate){n=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden";var c=this.createElement("span",{attrs:{class:n,"aria-label":"drag handle",title:"drag handle"}});a.appendChild(c);var p=this.enableSeparateConnector&&!e?"e-lib e-btn-group e-qb-toggle-btn":"e-lib e-btn-group";t=this.createElement("div",{attrs:{class:p,role:"group"}}),this.enableSeparateConnector&&t.classList.add("e-multi-connector"),this.enableNotCondition&&(l=this.enableSeparateConnector?this.createElement("input",{attrs:{type:"checkbox",class:"e-qb-toggle"}}):this.createElement("button",{attrs:{type:"button",class:"e-qb-toggle"}}),t.appendChild(l)),l=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-and",value:"AND"}}),t.appendChild(l),r=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-and-lbl e-small"},innerHTML:this.l10n.getConstant("AND")}),t.appendChild(r),l=this.createElement("input",{attrs:{type:"radio",class:"e-btngroup-or",value:"OR"}}),t.appendChild(l),r=this.createElement("label",{attrs:{class:"e-lib e-btn e-btngroup-or-lbl e-small"},innerHTML:this.l10n.getConstant("OR")}),t.appendChild(r),a.appendChild(t),i=this.createElement("div",{attrs:{class:"e-group-action"}}),this.enableSeparateConnector?(o=this.createElement("button",{attrs:{type:"button",class:"e-add-condition-btn"}}),i.appendChild(o),o=this.createElement("button",{attrs:{type:"button",class:"e-add-group-btn"}}),i.appendChild(o)):(o=this.createElement("button",{attrs:{type:"button",class:"e-add-btn"}}),i.appendChild(o)),a.appendChild(i)}return s},p.prototype.ruleTemplate=function(){var e,l,n,r,i,o=this.createElement("div"),s=this.createElement("div",{attrs:{class:"e-rule-field"}});e=this.createElement("div",{attrs:{class:"e-rule-filter"}}),i=this.allowDragAndDrop?"e-icons e-drag-qb-rule":"e-icons e-drag-qb-rule e-hidden";var a=this.createElement("span",{attrs:{class:i,"aria-label":"drag handle",title:"drag handle"}});s.appendChild(a);var u=this.createElement("input",{attrs:{type:"text",class:"e-filter-input"}});e.appendChild(u),s.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-operator"}}),s.appendChild(e),e=this.createElement("div",{attrs:{class:"e-rule-value"}}),s.appendChild(e),e=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",r=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";var d=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneRule"),type:"button",class:n}}),c=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}});d.appendChild(c);var p=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockRule"),type:"button",class:r}});c=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}}),p.appendChild(c),l=this.showButtons.ruleDelete||t.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";var h=this.createElement("button",{attrs:{type:"button",class:l}});return e.appendChild(d),e.appendChild(p),e.appendChild(h),s.appendChild(e),o.appendChild(s),o},p.prototype.addGroupElement=function(e,t,l,n,r,i,o){var s=this,a={groupID:t.id.replace(this.element.id+"_",""),cancel:!1,type:"insertGroup"};this.isImportRules||this.isInitialLoad||this.prvtEvtTgrDaD?(this.isInitialLoad=!1,this.addGroupSuccess(a,e,t,l,n,r,i,o)):this.trigger("beforeChange",a,function(a){s.addGroupSuccess(a,e,t,l,n,r,i,o)})},p.prototype.addGroupSuccess=function(e,n,r,i,o,a,u,d){var c=this;if(!e.cancel&&this.element.querySelectorAll(".e-group-container").length<=this.maxGroupCount){var p=r,h=void 0,m="";m=p.className.indexOf("e-group-container")<0?p.querySelector(".e-group-container")&&p.querySelector(".e-group-container").id:p.id,this.enableSeparateConnector&&(this.groupElem=this.groupTemplate());var g=this.groupElem.cloneNode(!0);if(g.setAttribute("id",this.element.id+"_group"+this.groupIdCounter),0===this.groupIdCounter&&this.allowDragAndDrop&&g.querySelector(".e-drag-qb-rule")&&(g&&g.children[0]&&g.children[0].classList.add("e-parent-header"),t.addClass([g.querySelector(".e-drag-qb-rule")],"e-hidden")),this.headerTemplate&&(u?(n=!1,g.setAttribute("id",this.element.id+"_group0"),this.headerTemplateFn(g,a,i,d,m),this.groupIdCounter=0):this.headerTemplateFn(g,a,i,d,m)),this.groupIdCounter++,!this.headerTemplate){var f=g.querySelector(".e-btngroup-and"),v=g.querySelector(".e-btngroup-or"),y=g.querySelector(".e-btngroup-and-lbl"),b=g.querySelector(".e-btngroup-or-lbl");f.setAttribute("id",this.element.id+"_and"+this.btnGroupId),v.setAttribute("id",this.element.id+"_or"+this.btnGroupId),f.setAttribute("name",this.element.id+"_and"+this.btnGroupId),v.setAttribute("name",this.element.id+"_and"+this.btnGroupId),y.setAttribute("for",this.element.id+"_and"+this.btnGroupId),b.setAttribute("for",this.element.id+"_or"+this.btnGroupId),this.btnGroupId++}if(n){var C=void 0;C=this.showButtons.groupDelete||t.isNullOrUndefined(this.showButtons.groupDelete)?"e-deletegroup":"e-deletegroup e-button-hide",h=this.createElement("button",{attrs:{type:"button",class:C}}),new l.Button({iconCss:"e-icons e-delete-icon",cssClass:"e-small e-round"}).appendTo(h),h.setAttribute("title",this.l10n.getConstant("DeleteGroup")),t.rippleEffect(h,{selector:".deletegroup"});for(var S=p.querySelector(".e-rule-list"),E=S.children,x=0,q=0,O=E.length;q<O;q++)E[q].className.indexOf("e-group-container")>-1&&(x+=1);if(this.showButtons.cloneGroup&&this.cloneGrpBtnClick)if(this.groupIndex===E.length-1)S.appendChild(g),this.isLastGroup=!0;else{if(this.enableSeparateConnector){for(var k=0,w=this.groupIndex+1,N=0;N<w;N++)E[N].classList.contains("e-rule-container")&&(w++,k++);k>0&&k--,E[L=this.groupIndex+k+1].parentNode.insertBefore(g,E[L])}else{var L=this.groupIndex+1;E[L].parentNode.insertBefore(g,E[L])}this.isMiddleGroup=!0}else S.appendChild(g);var R=this.levelColl[p.id].slice(0);if(R.push(x),this.levelColl[g.id]=R,this.groupIndex>-1&&this.refreshLevelColl(),this.isImportRules||(this.isAddSuccess=!0,this.addGroups([],p.id.replace(this.element.id+"_","")),this.isAddSuccess=!1,o&&this.addRuleToNewGroups&&this.addRuleElement(g,{})),!this.headerTemplate){A="";A=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";var D=this.createElement("button",{attrs:{title:this.l10n.getConstant("CloneGroup"),type:"button",class:A}}),T=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-copy"}});D.appendChild(T),g.querySelector(".e-group-action").appendChild(D),A=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";var I=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:A}}),B=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}});I.appendChild(B),g.querySelector(".e-group-action").appendChild(I),g.querySelector(".e-group-action").appendChild(h)}}else{if(!this.headerTemplate){var A="";A=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";var I=this.createElement("button",{attrs:{title:this.l10n.getConstant("LockGroup"),type:"button",class:A}}),T=this.createElement("span",{attrs:{class:"e-btn-icon e-icons e-unlock"}});I.appendChild(T),g.querySelector(".e-group-action").appendChild(I)}p.appendChild(g),this.levelColl[g.id]=[0]}if(this.enableNotCondition&&!this.headerTemplate){var P=g.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(P),g.querySelector(".e-btngroup-and-lbl").classList.add("e-not"),this.updatedRule&&this.updatedRule.not&&t.addClass([P],"e-active-toggle")}if(this.enableSeparateConnector&&!this.headerTemplate){for(var M=g.querySelector(".e-btngroup-and"),G=g.querySelector(".e-btngroup-or"),V=g.querySelector(".e-btn-group"),N=0;N<V.childNodes.length;N++)"not"===g.querySelector(".e-btn-group").childNodes[N].textContent.toLowerCase()&&this.enableNotCondition?V.childNodes[N].classList.add("e-multiconnector"):V.childNodes[N].style.display="none";if(g.previousElementSibling&&(t.isNullOrUndefined(this.headerTemplate)&&(g.parentElement.insertBefore(this.groupTemplate(!0).querySelector(".e-btn-group"),g),(P=g.previousElementSibling.childNodes[0]).classList.contains("e-qb-toggle")&&(P.style.display="none")),!this.isImportRules)){var F=g.previousElementSibling,U=F.querySelector(".e-btngroup-and"),_=F.querySelector(".e-btngroup-or");if(M.checked||G.checked)this.enableSeparateConnector&&(M.checked&&(U.checked=!0),G.checked&&(_.checked=!0));else{var j=g.nextElementSibling;j&&j.classList.contains("e-btn-group")&&(M=j.querySelector(".e-btngroup-and"),G=j.querySelector(".e-btngroup-or"),U.checked=M.checked,_.checked=G.checked)}}}if(this.updatedRule=null,this.headerTemplate){var $={requestType:"header-template-create",ruleID:g.id,condition:i,notCondition:this.enableNotCondition?a:void 0};this.trigger("actionBegin",$)}else if(this.enableSeparateConnector){var Q=g.querySelector(".e-add-condition-btn");(z=new l.Button({cssClass:this.element.id+"_addConditionbtn",content:this.l10n.getConstant("AddCondition")})).appendTo(Q),z.element.onclick=function(){c.addRuleElement(t.closest(Q,".e-group-container"),{})};var H=g.querySelector(".e-add-group-btn");(z=new l.Button({cssClass:this.element.id+"_addGroupbtn",content:this.l10n.getConstant("AddGroup")})).appendTo(H),z.element.onclick=function(){c.addGroupElement(!0,t.closest(H,".e-group-container"),"",!0)}}else{var W=g.querySelector(".e-add-btn"),z=new s.DropDownButton({items:this.items,cssClass:"e-round e-small e-caret-hide e-addrulegroup",iconCss:"e-icons e-add-icon",beforeOpen:this.selectBtn.bind(this,W),select:this.selectBtn.bind(this,W)});z.appendTo(W),W.setAttribute("title",this.l10n.getConstant("AddButton"))}if(!this.isImportRules&&!this.prvtEvtTgrDaD){var Y=p.id.replace(this.element.id+"_",""),K=g.id.replace(this.element.id+"_","");this.trigger("change",{groupID:Y,type:"insertGroup",childGroupID:K})}}},p.prototype.setMultiConnector=function(e){if(this.enableSeparateConnector&&!this.headerTemplate&&e.previousElementSibling){var t=this.groupTemplate(!0).querySelector(".e-btn-group");if(t){e.parentElement.insertBefore(t,e);var l=e.previousElementSibling.childNodes[0];l.classList.contains("e-qb-toggle")&&(l.style.display="none"),this.addHeaderDiv(e)}}},p.prototype.addHeaderDiv=function(e){var l,n=e.previousElementSibling.previousElementSibling;if(n){l=n.id.indexOf("rule")>-1?this.getRule(n):this.getGroup(n),!t.isNullOrUndefined(l)&&t.isNullOrUndefined(l.condition)&&(l.condition="and");var r=e.previousElementSibling.querySelector(".e-btngroup-or"),i=e.previousElementSibling.querySelector(".e-btngroup-and");r.disabled=!1,i.disabled=!1,t.isNullOrUndefined(l)||"or"!==l.condition?i.checked=!0:r.checked=!0}},p.prototype.headerTemplateFn=function(e,l,n,r,i,o){var s,a,u=this.element.id+"_header",d=e.querySelector(".e-group-header");if(this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(d=e),this.headerTemplate){if(a={requestType:"header-template-initialize",ruleID:e.id,notCondition:this.enableNotCondition?l:void 0,condition:n,rule:this.getRuleCollection(r,!1),groupID:i},this.trigger("actionBegin",a),this.enableSeparateConnector&&-1!==e.id.indexOf("rule")&&(a.requestType="rule-template-create"),this.headerFn=this.templateParser(this.headerTemplate),this.isReact)s=this.headerFn(a,this,e.id,u)[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):d.appendChild(s);else if(this.isAngular){var c=this.headerFn(a,this,e.id,u);s=3===c[0].nodeType?c[1]:c[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):d.appendChild(s)}else if(this.isVue3){if(s=this.headerFn(a,this,e.id,u),this.enableSeparateConnector&&(o||-1!==e.id.indexOf("rule")))for(var p=0;p<s.length;p++)if("DIV"===s[p].nodeName){s=s[p];break}this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):t.append(s,d)}else s=this.headerFn(a,this,"Template",u)[0],this.enableSeparateConnector&&o?this.enableSeparateConnectorInitialRule(e,s):this.enableSeparateConnector&&-1!==e.id.indexOf("rule")?d.parentElement.insertBefore(s,d.nextElementSibling):d.appendChild(s);this.renderReactTemplates()}return e},p.prototype.enableSeparateConnectorInitialRule=function(e,t){var l=(e.nextElementSibling?e.nextElementSibling:e).closest(".e-group-container");!e.nextElementSibling&&l&&(l=l.nextElementSibling?l.nextElementSibling:l),l&&l.parentElement.insertBefore(t,l)},p.prototype.notifyChange=function(e,l,n){var r=t.closest(l,".e-group-container"),i=this.getParentGroup(r),o=t.closest(l,".e-rule-container"),s=0;if("not"===n)return void(i.not=e);if("condition"===n)return void(this.enableSeparateConnector?((o=l.parentElement.previousElementSibling)&&o.classList.contains("e-group-container")&&(o=o.querySelectorAll(".e-rule-container")[o.querySelectorAll(".e-rule-container").length-1]),o&&o.classList.contains("e-rule-container")&&(i=this.getRule(o)),i.condition=e):i.condition=e);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"))))&&s++;var a=i.rules[s],u=this.getColumn(a.field),d=this.getFormat(u.format);if("date"===u.type)if(e instanceof Date)e=this.intl.formatDate(e,d);else if(e instanceof Array)for(var c=0;c<e.length;c++)e[c]&&e[c]instanceof Date&&(e[c]=this.intl.formatDate(e[c],d));u.ruleTemplate?this.templateChange(l,e,n):(this.isNotified=!0,this.updateRules(l,e),this.isNotified=!1)},p.prototype.templateChange=function(e,l,n){var r,i=t.closest(e,".e-group-container"),o=i&&this.getParentGroup(i),s=t.closest(e,".e-rule-container"),a=0;for(this.allowValidation&&this.validateValue(o,s);s&&null!==s.previousElementSibling;)s=s.previousElementSibling,(!this.enableSeparateConnector||this.enableSeparateConnector&&(!this.headerTemplate&&!s.classList.contains("e-btn-group")||this.headerTemplate&&(s.classList.contains("e-rule-container")||s.classList.contains("e-group-container"))))&&a++;var u=o&&o.rules[a];"field"===n?this.selectedColumn=this.getColumn(l):u&&(this.selectedColumn=this.getColumn(u.field));var d;this.previousColumn=u&&this.getColumn(u.field);var c=this.getValidRules(this.rule);this.selectedColumn&&(d=this.selectedColumn.operators?this.selectedColumn.operators:this.customOperators[this.selectedColumn.type+"Operator"]);var p,h=["in","notin","between","notbetween"];switch(n){case"field":if(t.isNullOrUndefined(l)){if(t.isNullOrUndefined(u))return;u.field="",u.label="",u.type="",u.value="",u.operator=""}else u.field=l,u.label=this.selectedColumn.label,u.type=this.selectedColumn.type,u.value="",u.operator=d[0].value;break;case"operator":p=u.operator,u.operator=l,h.indexOf(u.operator)>-1?u.value=[]:h.indexOf(p)>-1&&(u.value="");break;case"value":u.value=l}if(this.changeRuleTemplate(this.selectedColumn,e),this.filterRules(c,this.getValidRules(this.rule),n),this.selectedColumn&&this.selectedColumn.ruleTemplate&&("field"===n||"operator"===n)){var m=t.closest(e,".e-rule-container");this.destroyControls(m,!0),t.detach(m.querySelector(".e-rule-field"));var g=this.appendRuleElem(t.closest(m,".e-group-container"),this.selectedColumn,"change",m.id,n,u);"Vertical"===this.displayMode||this.element.className.indexOf("e-device")>-1?g.className="e-rule-container e-vertical-mode":g.className="e-rule-container e-horizontal-mode",this.enableSeparateConnector||g.previousElementSibling&&g.previousElementSibling.className.indexOf("e-rule-container")>-1&&(g.className.indexOf("e-joined-rule")<0&&(g.className+=" e-joined-rule"),g.previousElementSibling.className.indexOf("e-prev-joined-rule")<0&&(g.previousElementSibling.className+=" e-prev-joined-rule")),g.previousElementSibling&&g.previousElementSibling.className.indexOf("e-group-container")>-1&&g.className.indexOf("e-separate-rule")<0&&(g.className+=" e-separate-rule");var f={requestType:"template-create",action:n,ruleID:m.id,fields:this.fields,rule:u};r={groupID:i.id.replace(this.element.id+"_",""),ruleID:m.id.replace(this.element.id+"_",""),value:u.field,type:"field"},this.trigger("actionBegin",f),this.trigger("change",r)}},p.prototype.changeValue=function(e,l){var n,r=this;if(this.isNumInput&&"number"==typeof l.value||"input"===l.type&&l.target&&l.target.classList.contains("e-numerictextbox")&&this.selectedColumn.validation&&(this.selectedColumn.validation.max!==Number.MAX_VALUE||this.selectedColumn.validation.min>0))return void(this.isNumInput=!1);if(n=l.element&&l.element.classList.contains("e-multiselect")?l.element:l.event?l.event.target:"input"===l.type&&l.target