/**
 * Minified by jsDelivr using Terser v5.19.2.
 * Original file: /npm/jQuery-QueryBuilder@3.0.0/dist/js/query-builder.standalone.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
/*!
 * jQuery.extendext 1.0.0
 *
 * Copyright 2014-2019 Damien "Mistic" Sorel (http://www.strangeplanet.fr)
 * Licensed under MIT (http://opensource.org/licenses/MIT)
 * 
 * Based on jQuery.extend by jQuery Foundation, Inc. and other contributors
 */
!function(e,t){"function"==typeof define&&define.amd?define("jquery-extendext",["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,(function(e){"use strict";e.extendext=function(){var t,r,n,i,o,l,s=arguments[0]||{},a=1,u=arguments.length,p=!1,d="default";for("boolean"==typeof s&&(p=s,s=arguments[a++]||{}),"string"==typeof s&&("concat"!==(d=s.toLowerCase())&&"replace"!==d&&"extend"!==d&&(d="default"),s=arguments[a++]||{}),"object"==typeof s||e.isFunction(s)||(s={}),a===u&&(s=this,a--);a<u;a++)if(null!==(t=arguments[a]))if(e.isArray(t)&&"default"!==d)switch(l=s&&e.isArray(s)?s:[],d){case"concat":s=l.concat(e.extend(p,[],t));break;case"replace":s=e.extend(p,[],t);break;case"extend":t.forEach((function(t,r){if("object"==typeof t){var n=e.isArray(t)?[]:{};l[r]=e.extendext(p,d,l[r]||n,t)}else-1===l.indexOf(t)&&l.push(t)})),s=l}else for(r in t)i=t[r],"__proto__"!==r&&s!==i&&(p&&i&&(e.isPlainObject(i)||(o=e.isArray(i)))?(n=s[r],l=o&&!Array.isArray(n)?[]:o||e.isPlainObject(n)?n:{},o=!1,s[r]=e.extendext(p,d,l,i)):void 0!==i&&(s[r]=i));return s}})),
/*!
 * jQuery QueryBuilder 3.0.0
 * Copyright 2014-2024 Damien "Mistic" Sorel (http://www.strangeplanet.fr)
 * Licensed under MIT (https://opensource.org/licenses/MIT)
 */
function(e,t){"function"==typeof define&&define.amd?define("query-builder",["jquery","jquery-extendext"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery"),require("jquery-extendext")):t(e.jQuery)}(this,(function(e){"use strict";var t=function(i,o){i[0].queryBuilder=this,this.$el=i,this.settings=e.extendext(!0,"replace",{},t.DEFAULTS,o),this.model=new n,this.status={id:null,generated_id:!1,group_id:0,rule_id:0,has_optgroup:!1,has_operator_optgroup:!1},this.filters=this.settings.filters,this.icons=this.settings.icons,this.operators=this.settings.operators,this.templates=this.settings.templates,this.plugins=this.settings.plugins,this.lang=null,void 0===t.regional.en&&r.error("Config",'"i18n/en.js" not loaded.'),this.lang=e.extendext(!0,"replace",{},t.regional.en,t.regional[this.settings.lang_code],this.settings.lang),!1===this.settings.allow_groups?this.settings.allow_groups=0:!0===this.settings.allow_groups&&(this.settings.allow_groups=-1),Object.keys(this.templates).forEach((function(e){if(this.templates[e]||(this.templates[e]=t.templates[e]),"function"!=typeof this.templates[e])throw new Error(`Template ${e} must be a function`)}),this),this.$el.attr("id")||(this.$el.attr("id","qb_"+Math.floor(99999*Math.random())),this.status.generated_id=!0),this.status.id=this.$el.attr("id"),this.$el.addClass("query-builder"),this.filters=this.checkFilters(this.filters),this.operators=this.checkOperators(this.operators),this.bindEvents(),this.initPlugins()};e.extend(t.prototype,{trigger:function(t){var r=new e.Event(this._tojQueryEvent(t),{builder:this});return this.$el.triggerHandler(r,Array.prototype.slice.call(arguments,1)),r},change:function(t,r){var n=new e.Event(this._tojQueryEvent(t,!0),{builder:this,value:r});return this.$el.triggerHandler(n,Array.prototype.slice.call(arguments,2)),n.value},on:function(e,t){return this.$el.on(this._tojQueryEvent(e),t),this},off:function(e,t){return this.$el.off(this._tojQueryEvent(e),t),this},once:function(e,t){return this.$el.one(this._tojQueryEvent(e),t),this},_tojQueryEvent:function(e,t){return e.split(" ").map((function(e){return e+".queryBuilder"+(t?".filter":"")})).join(" ")}}),t.types={string:"string",integer:"number",double:"number",date:"datetime",time:"datetime",datetime:"datetime",boolean:"boolean"},t.inputs=["text","number","textarea","radio","checkbox","select"],t.modifiable_options=["display_errors","allow_groups","allow_empty","default_condition","default_filter"],t.selectors={group_container:".rules-group-container",rule_container:".rule-container",filter_container:".rule-filter-container",operator_container:".rule-operator-container",value_container:".rule-value-container",error_container:".error-container",condition_container:".rules-group-header .group-conditions",rule_header:".rule-header",group_header:".rules-group-header",group_actions:".group-actions",rule_actions:".rule-actions",rules_list:".rules-group-body>.rules-list",group_condition:".rules-group-header [name$=_cond]",rule_filter:".rule-filter-container [name$=_filter]",rule_operator:".rule-operator-container [name$=_operator]",rule_value:".rule-value-container [name*=_value_]",add_rule:"[data-add=rule]",delete_rule:"[data-delete=rule]",add_group:"[data-add=group]",delete_group:"[data-delete=group]"},t.templates={},t.regional={},t.OPERATORS={equal:{type:"equal",nb_inputs:1,multiple:!1,apply_to:["string","number","datetime","boolean"]},not_equal:{type:"not_equal",nb_inputs:1,multiple:!1,apply_to:["string","number","datetime","boolean"]},in:{type:"in",nb_inputs:1,multiple:!0,apply_to:["string","number","datetime"]},not_in:{type:"not_in",nb_inputs:1,multiple:!0,apply_to:["string","number","datetime"]},less:{type:"less",nb_inputs:1,multiple:!1,apply_to:["number","datetime"]},less_or_equal:{type:"less_or_equal",nb_inputs:1,multiple:!1,apply_to:["number","datetime"]},greater:{type:"greater",nb_inputs:1,multiple:!1,apply_to:["number","datetime"]},greater_or_equal:{type:"greater_or_equal",nb_inputs:1,multiple:!1,apply_to:["number","datetime"]},between:{type:"between",nb_inputs:2,multiple:!1,apply_to:["number","datetime"]},not_between:{type:"not_between",nb_inputs:2,multiple:!1,apply_to:["number","datetime"]},begins_with:{type:"begins_with",nb_inputs:1,multiple:!1,apply_to:["string"]},not_begins_with:{type:"not_begins_with",nb_inputs:1,multiple:!1,apply_to:["string"]},contains:{type:"contains",nb_inputs:1,multiple:!1,apply_to:["string"]},not_contains:{type:"not_contains",nb_inputs:1,multiple:!1,apply_to:["string"]},ends_with:{type:"ends_with",nb_inputs:1,multiple:!1,apply_to:["string"]},not_ends_with:{type:"not_ends_with",nb_inputs:1,multiple:!1,apply_to:["string"]},is_empty:{type:"is_empty",nb_inputs:0,multiple:!1,apply_to:["string"]},is_not_empty:{type:"is_not_empty",nb_inputs:0,multiple:!1,apply_to:["string"]},is_null:{type:"is_null",nb_inputs:0,multiple:!1,apply_to:["string","number","datetime","boolean"]},is_not_null:{type:"is_not_null",nb_inputs:0,multiple:!1,apply_to:["string","number","datetime","boolean"]}},t.DEFAULTS={filters:[],plugins:[],sort_filters:!1,display_errors:!0,allow_groups:-1,allow_empty:!1,conditions:["AND","OR"],default_condition:"AND",inputs_separator:" , ",select_placeholder:"------",display_empty_filter:!0,default_filter:null,optgroups:{},default_rule_flags:{filter_readonly:!1,operator_readonly:!1,value_readonly:!1,no_delete:!1},default_group_flags:{condition_readonly:!1,no_add_rule:!1,no_add_group:!1,no_delete:!1},templates:{group:null,rule:null,filterSelect:null,operatorSelect:null,ruleValueSelect:null},lang_code:"en",lang:{},operators:["equal","not_equal","in","not_in","less","less_or_equal","greater","greater_or_equal","between","not_between","begins_with","not_begins_with","contains","not_contains","ends_with","not_ends_with","is_empty","is_not_empty","is_null","is_not_null"],icons:{add_group:"bi-plus-circle-fill",add_rule:"bi-plus-lg",remove_group:"bi-x-lg",remove_rule:"bi-x-lg",error:"bi-exclamation-triangle"}},t.plugins={},t.defaults=function(r){if("object"!=typeof r)return"string"==typeof r?"object"==typeof t.DEFAULTS[r]?e.extend(!0,{},t.DEFAULTS[r]):t.DEFAULTS[r]:e.extend(!0,{},t.DEFAULTS);e.extendext(!0,"replace",t.DEFAULTS,r)},t.define=function(e,r,n){t.plugins[e]={fct:r,def:n||{}}},t.extend=function(r){e.extend(t.prototype,r)},t.prototype.initPlugins=function(){if(this.plugins){if(e.isArray(this.plugins)){var n={};this.plugins.forEach((function(e){n[e]=null})),this.plugins=n}Object.keys(this.plugins).forEach((function(n){n in t.plugins?(this.plugins[n]=e.extend(!0,{},t.plugins[n].def,this.plugins[n]||{}),t.plugins[n].fct.call(this,this.plugins[n])):r.error("Config",'Unable to find plugin "{0}"',n)}),this)}},t.prototype.getPluginOptions=function(e,n){var i;if(this.plugins&&this.plugins[e]?i=this.plugins[e]:t.plugins[e]&&(i=t.plugins[e].def),i)return n?i[n]:i;r.error("Config",'Unable to find plugin "{0}"',e)},t.prototype.init=function(e){this.trigger("afterInit"),e?(this.setRules(e),delete this.settings.rules):this.setRoot(!0)},t.prototype.checkFilters=function(e){var n=[];if(e&&0!==e.length||r.error("Config","Missing filters list"),e.forEach((function(e,i){switch(e.id||r.error("Config","Missing filter {0} id",i),-1!=n.indexOf(e.id)&&r.error("Config",'Filter "{0}" already defined',e.id),n.push(e.id),e.type?t.types[e.type]||r.error("Config",'Invalid type "{0}"',e.type):e.type="string",e.input?"function"!=typeof e.input&&-1==t.inputs.indexOf(e.input)&&r.error("Config",'Invalid input "{0}"',e.input):e.input="number"===t.types[e.type]?"number":"text",e.operators&&e.operators.forEach((function(e){"string"!=typeof e&&r.error("Config","Filter operators must be global operators types (string)")})),e.field||(e.field=e.id),e.label||(e.label=e.field),e.optgroup?(this.status.has_optgroup=!0,this.settings.optgroups[e.optgroup]||(this.settings.optgroups[e.optgroup]=e.optgroup)):e.optgroup=null,e.input){case"radio":case"checkbox":(!e.values||e.values.length<1)&&r.error("Config",'Missing filter "{0}" values',e.id);break;case"select":var o=[];e.has_optgroup=!1,r.iterateOptions(e.values,function(t,r,n){o.push({value:t,label:r,optgroup:n||null}),n&&(e.has_optgroup=!0,this.settings.optgroups[n]||(this.settings.optgroups[n]=n))}.bind(this)),e.has_optgroup?e.values=r.groupSort(o,"optgroup"):e.values=o,e.placeholder&&(void 0===e.placeholder_value&&(e.placeholder_value=-1),e.values.forEach((function(t){t.value==e.placeholder_value&&r.error("Config",'Placeholder of filter "{0}" overlaps with one of its values',e.id)})))}}),this),this.settings.sort_filters)if("function"==typeof this.settings.sort_filters)e.sort(this.settings.sort_filters);else{var i=this;e.sort((function(e,t){return i.translate(e.label).localeCompare(i.translate(t.label))}))}return this.status.has_optgroup&&(e=r.groupSort(e,"optgroup")),e},t.prototype.checkOperators=function(n){var i=[];return n.forEach((function(o,l){"string"==typeof o?(t.OPERATORS[o]||r.error("Config",'Unknown operator "{0}"',o),n[l]=o=e.extendext(!0,"replace",{},t.OPERATORS[o])):(o.type||r.error("Config",'Missing "type" for operator {0}',l),t.OPERATORS[o.type]&&(n[l]=o=e.extendext(!0,"replace",{},t.OPERATORS[o.type],o)),void 0!==o.nb_inputs&&void 0!==o.apply_to||r.error("Config",'Missing "nb_inputs" and/or "apply_to" for operator "{0}"',o.type)),-1!=i.indexOf(o.type)&&r.error("Config",'Operator "{0}" already defined',o.type),i.push(o.type),o.optgroup?(this.status.has_operator_optgroup=!0,this.settings.optgroups[o.optgroup]||(this.settings.optgroups[o.optgroup]=o.optgroup)):o.optgroup=null}),this),this.status.has_operator_optgroup&&(n=r.groupSort(n,"optgroup")),n},t.prototype.bindEvents=function(){var r=this,n=t.selectors;this.$el.on("change.queryBuilder",n.group_condition,(function(){if(e(this).is(":checked")){var t=e(this).closest(n.group_container);r.getModel(t).condition=e(this).val()}})),this.$el.on("change.queryBuilder",n.rule_filter,(function(){var t=e(this).closest(n.rule_container);r.getModel(t).filter=r.getFilterById(e(this).val())})),this.$el.on("change.queryBuilder",n.rule_operator,(function(){var t=e(this).closest(n.rule_container);r.getModel(t).operator=r.getOperatorByType(e(this).val())})),this.$el.on("click.queryBuilder",n.add_rule,(function(){var t=e(this).closest(n.group_container);r.addRule(r.getModel(t))})),this.$el.on("click.queryBuilder",n.delete_rule,(function(){var t=e(this).closest(n.rule_container);r.deleteRule(r.getModel(t))})),0!==this.settings.allow_groups&&(this.$el.on("click.queryBuilder",n.add_group,(function(){var t=e(this).closest(n.group_container);r.addGroup(r.getModel(t))})),this.$el.on("click.queryBuilder",n.delete_group,(function(){var t=e(this).closest(n.group_container);r.deleteGroup(r.getModel(t))}))),this.model.on({drop:function(e,t){t.$el.remove(),r.refreshGroupsConditions()},add:function(e,n,i,o){0===o?i.$el.prependTo(n.$el.find(">"+t.selectors.rules_list)):i.$el.insertAfter(n.rules[o-1].$el),r.refreshGroupsConditions()},move:function(e,n,i,o){n.$el.detach(),0===o?n.$el.prependTo(i.$el.find(">"+t.selectors.rules_list)):n.$el.insertAfter(i.rules[o-1].$el),r.refreshGroupsConditions()},update:function(e,t,n,i,o){if(t instanceof l)switch(n){case"error":r.updateError(t);break;case"flags":r.applyRuleFlags(t);break;case"filter":r.updateRuleFilter(t,o);break;case"operator":r.updateRuleOperator(t,o);break;case"value":r.updateRuleValue(t,o)}else switch(n){case"error":r.updateError(t);break;case"flags":r.applyGroupFlags(t);break;case"condition":r.updateGroupCondition(t,o)}}})},t.prototype.setRoot=function(t,r,n){t=void 0===t||!0===t;var i=this.nextGroupId(),l=e(e.parseHTML(this.getGroupTemplate(i,1)));return this.$el.append(l),this.model.root=new o(null,l),this.model.root.model=this.model,this.model.root.data=r,this.model.root.flags=e.extend({},this.settings.default_group_flags,n),this.model.root.condition=this.settings.default_condition,this.trigger("afterAddGroup",this.model.root),t&&this.addRule(this.model.root),this.model.root},t.prototype.addGroup=function(t,r,n,i){r=void 0===r||!0===r;var o=t.level+1;if(this.trigger("beforeAddGroup",t,r,o).isDefaultPrevented())return null;var l=this.nextGroupId(),s=e(this.getGroupTemplate(l,o)),a=t.addGroup(s);return a.data=n,a.flags=e.extend({},this.settings.default_group_flags,i),a.condition=this.settings.default_condition,this.trigger("afterAddGroup",a),this.trigger("rulesChanged"),r&&this.addRule(a),a},t.prototype.deleteGroup=function(e){if(e.isRoot())return!1;if(this.trigger("beforeDeleteGroup",e).isDefaultPrevented())return!1;var t=!0;return e.each("reverse",(function(e){t&=this.deleteRule(e)}),(function(e){t&=this.deleteGroup(e)}),this),t&&(e.drop(),this.trigger("afterDeleteGroup"),this.trigger("rulesChanged")),t},t.prototype.updateGroupCondition=function(r,n){r.$el.find(">"+t.selectors.group_condition).each((function(){var t=e(this);t.prop("checked",t.val()===r.condition),t.parent().toggleClass("active",t.val()===r.condition)})),this.trigger("afterUpdateGroupCondition",r,n),this.trigger("rulesChanged")},t.prototype.refreshGroupsConditions=function(){!function e(r){(!r.flags||r.flags&&!r.flags.condition_readonly)&&r.$el.find(">"+t.selectors.group_condition).prop("disabled",r.rules.length<=1).parent().toggleClass("disabled",r.rules.length<=1),r.each(null,(function(t){e(t)}),this)}(this.model.root)},t.prototype.addRule=function(t,r,n){if(this.trigger("beforeAddRule",t).isDefaultPrevented())return null;var i=this.nextRuleId(),o=e(e.parseHTML(this.getRuleTemplate(i))),l=t.addRule(o);return l.data=r,l.flags=e.extend({},this.settings.default_rule_flags,n),this.trigger("afterAddRule",l),this.trigger("rulesChanged"),this.createRuleFilters(l),!this.settings.default_filter&&this.settings.display_empty_filter||(l.filter=this.change("getDefaultFilter",this.getFilterById(this.settings.default_filter||this.filters[0].id),l)),l},t.prototype.deleteRule=function(e){return!e.flags.no_delete&&(!this.trigger("beforeDeleteRule",e).isDefaultPrevented()&&(e.drop(),this.trigger("afterDeleteRule"),this.trigger("rulesChanged"),!0))},t.prototype.createRuleFilters=function(r){var n=this.change("getRuleFilters",this.filters,r),i=e(e.parseHTML(this.getRuleFilterSelect(r,n)));r.$el.find(t.selectors.filter_container).html(i),this.trigger("afterCreateRuleFilters",r),this.applyRuleFlags(r)},t.prototype.createRuleOperators=function(r){var n=r.$el.find(t.selectors.operator_container).empty();if(r.filter){var i=this.getOperators(r.filter),o=e(e.parseHTML(this.getRuleOperatorSelect(r,i)));n.html(o),r.filter.default_operator?r.__.operator=this.getOperatorByType(r.filter.default_operator):r.__.operator=i[0],r.$el.find(t.selectors.rule_operator).val(r.operator.type),this.trigger("afterCreateRuleOperators",r,i),this.applyRuleFlags(r)}},t.prototype.createRuleInput=function(r){var n=r.$el.find(t.selectors.value_container).empty();if(r.__.value=void 0,r.filter&&r.operator&&0!==r.operator.nb_inputs){for(var i=this,o=e(),l=r.filter,s=0;s<r.operator.nb_inputs;s++){var a=e(e.parseHTML(e.trim(this.getRuleInput(r,s))));s>0&&n.append(this.settings.inputs_separator),n.append(a),o=o.add(a)}n.css("display",""),o.on("change "+(l.input_event||""),(function(){r._updating_input||(r._updating_value=!0,r.value=i.getRuleInputValue(r),r._updating_value=!1)})),l.plugin&&o[l.plugin](l.plugin_config||{}),this.trigger("afterCreateRuleInput",r),void 0!==l.default_value?r.value=l.default_value:(r._updating_value=!0,r.value=i.getRuleInputValue(r),r._updating_value=!1),this.applyRuleFlags(r)}},t.prototype.updateRuleFilter=function(e,r){this.createRuleOperators(e),this.createRuleInput(e),e.$el.find(t.selectors.rule_filter).val(e.filter?e.filter.id:"-1"),r&&e.filter&&r.id!==e.filter.id&&(e.data=void 0),this.trigger("afterUpdateRuleFilter",e,r),this.trigger("rulesChanged")},t.prototype.updateRuleOperator=function(e,r){var n=e.$el.find(t.selectors.value_container);e.operator&&0!==e.operator.nb_inputs?(n.css("display",""),!n.is(":empty")&&r&&e.operator.nb_inputs===r.nb_inputs&&e.operator.optgroup===r.optgroup||this.createRuleInput(e)):(n.hide(),e.__.value=void 0),e.operator&&(e.$el.find(t.selectors.rule_operator).val(e.operator.type),e.__.value=this.getRuleInputValue(e)),this.trigger("afterUpdateRuleOperator",e,r),this.trigger("rulesChanged")},t.prototype.updateRuleValue=function(e,t){e._updating_value||this.setRuleInputValue(e,e.value),this.trigger("afterUpdateRuleValue",e,t),this.trigger("rulesChanged")},t.prototype.applyRuleFlags=function(e){var r=e.flags,n=t.selectors;e.$el.find(n.rule_filter).prop("disabled",r.filter_readonly),e.$el.find(n.rule_operator).prop("disabled",r.operator_readonly),e.$el.find(n.rule_value).prop("disabled",r.value_readonly),r.no_delete&&e.$el.find(n.delete_rule).remove(),this.trigger("afterApplyRuleFlags",e)},t.prototype.applyGroupFlags=function(e){var r=e.flags,n=t.selectors;e.$el.find(">"+n.group_condition).prop("disabled",r.condition_readonly).parent().toggleClass("readonly",r.condition_readonly),r.no_add_rule&&e.$el.find(n.add_rule).remove(),r.no_add_group&&e.$el.find(n.add_group).remove(),r.no_delete&&e.$el.find(n.delete_group).remove(),this.trigger("afterApplyGroupFlags",e)},t.prototype.clearErrors=function(e){(e=e||this.model.root)&&(e.error=null,e instanceof o&&e.each((function(e){e.error=null}),(function(e){this.clearErrors(e)}),this))},t.prototype.updateError=function(e){if(this.settings.display_errors)if(null===e.error)e.$el.removeClass("has-error");else{var n=this.translate("errors",e.error[0]);n=r.fmt(n,e.error.slice(1)),n=this.change("displayError",n,e.error,e),e.$el.addClass("has-error").find(t.selectors.error_container).eq(0).attr("title",n)}},t.prototype.triggerValidationError=function(t,r,n){e.isArray(r)||(r=[r]),this.trigger("validationError",t,r,n).isDefaultPrevented()||(t.error=r)},t.prototype.destroy=function(){this.trigger("beforeDestroy"),this.status.generated_id&&this.$el.removeAttr("id"),this.clear(),this.model=null,this.$el.off(".queryBuilder").removeClass("query-builder").removeData("queryBuilder"),delete this.$el[0].queryBuilder},t.prototype.reset=function(){this.trigger("beforeReset").isDefaultPrevented()||(this.status.group_id=1,this.status.rule_id=0,this.model.root.empty(),this.model.root.data=void 0,this.model.root.flags=e.extend({},this.settings.default_group_flags),this.model.root.condition=this.settings.default_condition,this.addRule(this.model.root),this.trigger("afterReset"),this.trigger("rulesChanged"))},t.prototype.clear=function(){this.trigger("beforeClear").isDefaultPrevented()||(this.status.group_id=0,this.status.rule_id=0,this.model.root&&(this.model.root.drop(),this.model.root=null),this.trigger("afterClear"),this.trigger("rulesChanged"))},t.prototype.setOptions=function(r){e.each(r,function(e,r){-1!==t.modifiable_options.indexOf(e)&&(this.settings[e]=r)}.bind(this))},t.prototype.getModel=function(t){return t?t instanceof i?t:e(t).data("queryBuilderModel"):this.model.root},t.prototype.validate=function(t){t=e.extend({skip_empty:!1},t),this.clearErrors();var r=this,n=function e(n){var i=0,o=0;return n.each((function(e){if(e.filter||!t.skip_empty){if(!e.filter)return r.triggerValidationError(e,"no_filter",null),void o++;if(!e.operator)return r.triggerValidationError(e,"no_operator",null),void o++;if(0!==e.operator.nb_inputs){var n=r.validateValue(e,e.value);if(!0!==n)return r.triggerValidationError(e,n,e.value),void o++}i++}}),(function(t){var r=e(t);!0===r?i++:!1===r&&o++})),!(o>0)&&(0===i&&!n.isRoot()&&t.skip_empty?null:!!(0!==i||r.settings.allow_empty&&n.isRoot())||(r.triggerValidationError(n,"empty_group",null),!1))}(this.model.root);return this.change("validate",n)},t.prototype.getRules=function(t){t=e.extend({get_flags:!1,allow_invalid:!1,skip_empty:!1},t);var r=this.validate(t);if(!r&&!t.allow_invalid)return null;var n=this,i=function r(i){var o={condition:i.condition,rules:[]};if(i.data&&(o.data=e.extendext(!0,"replace",{},i.data)),t.get_flags){var l=n.getGroupFlags(i.flags,"all"===t.get_flags);e.isEmptyObject(l)||(o.flags=l)}return i.each((function(r){if(r.filter||!t.skip_empty){var i=null;r.operator&&0===r.operator.nb_inputs||(i=r.value);var l={id:r.filter?r.filter.id:null,field:r.filter?r.filter.field:null,type:r.filter?r.filter.type:null,input:r.filter?r.filter.input:null,operator:r.operator?r.operator.type:null,value:i};if((r.filter&&r.filter.data||r.data)&&(l.data=e.extendext(!0,"replace",{},r.filter?r.filter.data:{},r.data)),t.get_flags){var s=n.getRuleFlags(r.flags,"all"===t.get_flags);e.isEmptyObject(s)||(l.flags=s)}o.rules.push(n.change("ruleToJson",l,r))}}),(function(e){var n=r(e);0===n.rules.length&&t.skip_empty||o.rules.push(n)}),this),n.change("groupToJson",o,i)}(this.model.root);return i.valid=r,this.change("getRules",i)},t.prototype.setRules=function(t,n){n=e.extend({allow_invalid:!1},n),e.isArray(t)&&(t={condition:this.settings.default_condition,rules:t}),t&&t.rules&&(0!==t.rules.length||this.settings.allow_empty)||r.error("RulesParse","Incorrect data object passed"),this.clear(),this.setRoot(!1,t.data,this.parseGroupFlags(t)),t=this.change("setRules",t,n);var i=this;!function e(t,o){null!==o&&(void 0===t.condition?t.condition=i.settings.default_condition:-1==i.settings.conditions.indexOf(t.condition)&&(r.error(!n.allow_invalid,"UndefinedCondition",'Invalid condition "{0}"',t.condition),t.condition=i.settings.default_condition),o.condition=t.condition,t.rules.forEach((function(t){var l;if(void 0!==t.rules)if(-1!==i.settings.allow_groups&&i.settings.allow_groups<o.level)r.error(!n.allow_invalid,"RulesParse","No more than {0} groups are allowed",i.settings.allow_groups),i.reset();else{if(null===(l=i.addGroup(o,!1,t.data,i.parseGroupFlags(t))))return;e(t,l)}else{if(t.empty||(void 0===t.id&&(r.error(!n.allow_invalid,"RulesParse","Missing rule field id"),t.empty=!0),void 0===t.operator&&(t.operator="equal")),null===(l=i.addRule(o,t.data,i.parseRuleFlags(t))))return;t.empty||(l.filter=i.getFilterById(t.id,!n.allow_invalid)),l.filter&&(l.operator=i.getOperatorByType(t.operator,!n.allow_invalid),l.operator||(l.operator=i.getOperators(l.filter)[0])),l.operator&&0!==l.operator.nb_inputs&&(void 0!==t.value?l.value=t.value:void 0!==l.filter.default_value&&(l.value=l.filter.default_value)),i.change("jsonToRule",l,t)!=l&&r.error("RulesParse","Plugin tried to change rule reference")}})),i.change("jsonToGroup",o,t)!=o&&r.error("RulesParse","Plugin tried to change group reference"))}(t,this.model.root),this.trigger("afterSetRules")},t.prototype.validateValue=function(e,t){var r=e.filter.validation||{},n=!0;return n=r.callback?r.callback.call(this,t,e):this._validateValue(e,t),this.change("validateValue",n,t,e)},t.prototype._validateValue=function(n,i){var o,l,s=n.filter,a=n.operator,u=s.validation||{},p=!0;1===n.operator.nb_inputs&&(i=[i]);for(var d=0;d<a.nb_inputs;d++){if(!a.multiple&&e.isArray(i[d])&&i[d].length>1){p=["operator_not_multiple",a.type,this.translate("operators",a.type)];break}switch(s.input){case"radio":if(void 0===i[d]||0===i[d].length){u.allow_empty_value||(p=["radio_empty"]);break}break;case"checkbox":if(void 0===i[d]||0===i[d].length){u.allow_empty_value||(p=["checkbox_empty"]);break}break;case"select":if(void 0===i[d]||0===i[d].length||s.placeholder&&i[d]==s.placeholder_value){u.allow_empty_value||(p=["select_empty"]);break}break;default:l=e.isArray(i[d])?i[d]:[i[d]];for(var c=0;c<l.length;c++){switch(t.types[s.type]){case"string":if(void 0===l[c]||0===l[c].length){u.allow_empty_value||(p=["string_empty"]);break}if(void 0!==u.min&&l[c].length<parseInt(u.min)){p=[this.getValidationMessage(u,"min","string_exceed_min_length"),u.min];break}if(void 0!==u.max&&l[c].length>parseInt(u.max)){p=[this.getValidationMessage(u,"max","string_exceed_max_length"),u.max];break}if(u.format&&("string"==typeof u.format&&(u.format=new RegExp(u.format)),!u.format.test(l[c]))){p=[this.getValidationMessage(u,"format","string_invalid_format"),u.format];break}break;case"number":if(void 0===l[c]||0===l[c].length){u.allow_empty_value||(p=["number_nan"]);break}if(isNaN(l[c])){p=["number_nan"];break}if("integer"==s.type){if(parseInt(l[c])!=l[c]){p=["number_not_integer"];break}}else if(parseFloat(l[c])!=l[c]){p=["number_not_double"];break}if(void 0!==u.min&&l[c]<parseFloat(u.min)){p=[this.getValidationMessage(u,"min","number_exceed_min"),u.min];break}if(void 0!==u.max&&l[c]>parseFloat(u.max)){p=[this.getValidationMessage(u,"max","number_exceed_max"),u.max];break}if(void 0!==u.step&&"any"!==u.step){var f=(l[c]/u.step).toPrecision(14);if(parseInt(f)!=f){p=[this.getValidationMessage(u,"step","number_wrong_step"),u.step];break}}break;case"datetime":if(void 0===l[c]||0===l[c].length){u.allow_empty_value||(p=["datetime_empty"]);break}if(u.format){"moment"in window||r.error("MissingLibrary","MomentJS is required for Date/Time validation. Get it here http://momentjs.com");var g=moment(l[c],u.format);if(!g.isValid()){p=[this.getValidationMessage(u,"format","datetime_invalid"),u.format];break}if(u.min&&g<moment(u.min,u.format)){p=[this.getValidationMessage(u,"min","datetime_exceed_min"),u.min];break}if(u.max&&g>moment(u.max,u.format)){p=[this.getValidationMessage(u,"max","datetime_exceed_max"),u.max];break}}break;case"boolean":if(void 0===l[c]||0===l[c].length){u.allow_empty_value||(p=["boolean_not_valid"]);break}if("true"!==(o=(""+l[c]).trim().toLowerCase())&&"false"!==o&&"1"!==o&&"0"!==o&&1!==l[c]&&0!==l[c]){p=["boolean_not_valid"];break}}if(!0!==p)break}}if(!0!==p)break}if(("between"===n.operator.type||"not_between"===n.operator.type)&&2===i.length)switch(t.types[s.type]){case"number":i[0]>i[1]&&(p=["number_between_invalid",i[0],i[1]]);break;case"datetime":u.format&&("moment"in window||r.error("MissingLibrary","MomentJS is required for Date/Time validation. Get it here http://momentjs.com"),moment(i[0],u.format).isAfter(moment(i[1],u.format))&&(p=["datetime_between_invalid",i[0],i[1]]))}return p},t.prototype.nextGroupId=function(){return this.status.id+"_group_"+this.status.group_id++},t.prototype.nextRuleId=function(){return this.status.id+"_rule_"+this.status.rule_id++},t.prototype.getOperators=function(e){"string"==typeof e&&(e=this.getFilterById(e));for(var r=[],n=0,i=this.operators.length;n<i;n++){if(e.operators){if(-1==e.operators.indexOf(this.operators[n].type))continue}else if(-1==this.operators[n].apply_to.indexOf(t.types[e.type]))continue;r.push(this.operators[n])}return e.operators&&r.sort((function(t,r){return e.operators.indexOf(t.type)-e.operators.indexOf(r.type)})),this.change("getOperators",r,e)},t.prototype.getFilterById=function(e,t){if("-1"==e)return null;for(var n=0,i=this.filters.length;n<i;n++)if(this.filters[n].id==e)return this.filters[n];return r.error(!1!==t,"UndefinedFilter",'Undefined filter "{0}"',e),null},t.prototype.getOperatorByType=function(e,t){if("-1"==e)return null;for(var n=0,i=this.operators.length;n<i;n++)if(this.operators[n].type==e)return this.operators[n];return r.error(!1!==t,"UndefinedOperator",'Undefined operator "{0}"',e),null},t.prototype.getRuleInputValue=function(n){var i=n.filter,o=n.operator,l=[];if(i.valueGetter)l=i.valueGetter.call(this,n);else{for(var s=n.$el.find(t.selectors.value_container),a=0;a<o.nb_inputs;a++){var u,p=r.escapeElementId(n.id+"_value_"+a);switch(i.input){case"radio":l.push(s.find("[name="+p+"]:checked").val());break;case"checkbox":u=[],s.find("[name="+p+"]:checked").each((function(){u.push(e(this).val())})),l.push(u);break;case"select":i.multiple?(u=[],s.find("[name="+p+"] option:selected").each((function(){u.push(e(this).val())})),l.push(u)):l.push(s.find("[name="+p+"] option:selected").val());break;default:l.push(s.find("[name="+p+"]").val())}}l=l.map((function(t){return o.multiple&&i.value_separator&&"string"==typeof t&&(t=t.split(i.value_separator)),e.isArray(t)?t.map((function(e){return r.changeType(e,i.type)})):r.changeType(t,i.type)})),1===o.nb_inputs&&(l=l[0]),i.valueParser&&(l=i.valueParser.call(this,n,l))}return this.change("getRuleValue",l,n)},t.prototype.setRuleInputValue=function(n,i){var o=n.filter,l=n.operator;if(o&&l){if(n._updating_input=!0,o.valueSetter)o.valueSetter.call(this,n,i);else{var s=n.$el.find(t.selectors.value_container);1==l.nb_inputs&&(i=[i]);for(var a=0;a<l.nb_inputs;a++){var u=r.escapeElementId(n.id+"_value_"+a);switch(o.input){case"radio":s.find("[name="+u+'][value="'+i[a]+'"]').prop("checked",!0).trigger("change");break;case"checkbox":e.isArray(i[a])||(i[a]=[i[a]]),i[a].forEach((function(e){s.find("[name="+u+'][value="'+e+'"]').prop("checked",!0).trigger("change")}));break;default:l.multiple&&o.value_separator&&e.isArray(i[a])&&(i[a]=i[a].join(o.value_separator)),s.find("[name="+u+"]").val(i[a]).trigger("change")}}}n._updating_input=!1}},t.prototype.parseRuleFlags=function(t){var r=e.extend({},this.settings.default_rule_flags);return t.readonly&&e.extend(r,{filter_readonly:!0,operator_readonly:!0,value_readonly:!0,no_delete:!0}),t.flags&&e.extend(r,t.flags),this.change("parseRuleFlags",r,t)},t.prototype.getRuleFlags=function(t,r){if(r)return e.extend({},t);var n={};return e.each(this.settings.default_rule_flags,(function(e,r){t[e]!==r&&(n[e]=t[e])})),n},t.prototype.parseGroupFlags=function(t){var r=e.extend({},this.settings.default_group_flags);return t.readonly&&e.extend(r,{condition_readonly:!0,no_add_rule:!0,no_add_group:!0,no_delete:!0}),t.flags&&e.extend(r,t.flags),this.change("parseGroupFlags",r,t)},t.prototype.getGroupFlags=function(t,r){if(r)return e.extend({},t);var n={};return e.each(this.settings.default_group_flags,(function(e,r){t[e]!==r&&(n[e]=t[e])})),n},t.prototype.translate=function(e,t){var r;return t||(t=e,e=void 0),r="object"==typeof t?t[this.settings.lang_code]||t.en:(e?this.lang[e]:this.lang)[t]||t,this.change("translate",r,t,e)},t.prototype.getValidationMessage=function(e,t,r){return e.messages&&e.messages[t]||r},t.templates.group=({group_id:e,level:t,conditions:r,icons:n,settings:i,translate:o,builder:l})=>`\n<div id="${e}" class="rules-group-container">\n  <div class="rules-group-header">\n    <div class="btn-group float-end group-actions">\n      <button type="button" class="btn btn-sm btn-success" data-add="rule">\n        <i class="${n.add_rule}"></i> ${o("add_rule")}\n      </button>\n      ${-1===i.allow_groups||i.allow_groups>=t?`\n        <button type="button" class="btn btn-sm btn-success" data-add="group">\n          <i class="${n.add_group}"></i> ${o("add_group")}\n        </button>\n      `:""}\n      ${t>1?`\n        <button type="button" class="btn btn-sm btn-danger" data-delete="group">\n          <i class="${n.remove_group}"></i> ${o("delete_group")}\n        </button>\n      `:""}\n    </div>\n    <div class="btn-group group-conditions">\n      ${r.map((t=>`\n        <label class="btn btn-sm btn-primary">\n          <input type="radio" name="${e}_cond" value="${t}"> ${o("conditions",t)}\n        </label>\n      `)).join("\n")}\n    </div>\n    ${i.display_errors?`\n      <div class="error-container"><i class="${n.error}"></i></div>\n    `:""}\n  </div>\n  <div class=rules-group-body>\n    <div class=rules-list></div>\n  </div>\n</div>`,t.templates.rule=({rule_id:e,icons:t,settings:r,translate:n,builder:i})=>`\n<div id="${e}" class="rule-container">\n  <div class="rule-header">\n    <div class="btn-group float-end rule-actions">\n      <button type="button" class="btn btn-sm btn-danger" data-delete="rule">\n        <i class="${t.remove_rule}"></i> ${n("delete_rule")}\n      </button>\n    </div>\n  </div>\n  ${r.display_errors?`\n    <div class="error-container"><i class="${t.error}"></i></div>\n  `:""}\n  <div class="rule-filter-container"></div>\n  <div class="rule-operator-container"></div>\n  <div class="rule-value-container"></div>\n</div>`,t.templates.filterSelect=({rule:e,filters:t,icons:r,settings:n,translate:i,builder:o})=>{let l=null;return`\n<select class="form-select" name="${e.id}_filter">\n  ${n.display_empty_filter?`\n    <option value="-1">${n.select_placeholder}</option>\n  `:""}\n  ${t.map((e=>`\n    ${l!==e.optgroup?`\n      ${null!==l?"</optgroup>":""}\n      ${null!==(l=e.optgroup)?`\n        <optgroup label="${i(n.optgroups[l])}">\n      `:""}\n    `:""}\n    <option value="${e.id}" ${e.icon?`data-icon="${e.icon}"`:""}>${i(e.label)}</option>\n  `)).join("")}\n  ${null!==l?"</optgroup>":""}\n</select>`},t.templates.operatorSelect=({rule:e,operators:t,icons:r,settings:n,translate:i,builder:o})=>{let l=null;return`\n${1===t.length?`\n<span>\n${i("operators",t[0].type)}\n</span>\n`:""}\n<select class="form-select ${1===t.length?"d-none":""}" name="${e.id}_operator">\n  ${t.map((e=>`\n    ${l!==e.optgroup?`\n      ${null!==l?"</optgroup>":""}\n      ${null!==(l=e.optgroup)?`\n        <optgroup label="${i(n.optgroups[l])}">\n      `:""}\n    `:""}\n    <option value="${e.type}" ${e.icon?`data-icon="${e.icon}"`:""}>${i("operators",e.type)}</option>\n  `)).join("")}\n  ${null!==l?"</optgroup>":""}\n</select>`},t.templates.ruleValueSelect=({name:e,rule:t,icons:r,settings:n,translate:i,builder:o})=>{let l=null;return`\n<select class="form-select" name="${e}" ${t.filter.multiple?"multiple":""}>\n  ${t.filter.placeholder?`\n    <option value="${t.filter.placeholder_value}" disabled selected>${t.filter.placeholder}</option>\n  `:""}\n  ${t.filter.values.map((e=>`\n    ${l!==e.optgroup?`\n      ${null!==l?"</optgroup>":""}\n      ${null!==(l=e.optgroup)?`\n        <optgroup label="${i(n.optgroups[l])}">\n      `:""}\n    `:""}\n    <option value="${e.value}">${e.label}</option>\n  `)).join("")}\n  ${null!==l?"</optgroup>":""}\n</select>`},t.prototype.getGroupTemplate=function(e,t){var r=this.templates.group({builder:this,group_id:e,level:t,conditions:this.settings.conditions,icons:this.icons,settings:this.settings,translate:this.translate.bind(this)}).trim();return this.change("getGroupTemplate",r,t)},t.prototype.getRuleTemplate=function(e){var t=this.templates.rule({builder:this,rule_id:e,icons:this.icons,settings:this.settings,translate:this.translate.bind(this)}).trim();return this.change("getRuleTemplate",t)},t.prototype.getRuleFilterSelect=function(e,t){var r=this.templates.filterSelect({builder:this,rule:e,filters:t,icons:this.icons,settings:this.settings,translate:this.translate.bind(this)}).trim();return this.change("getRuleFilterSelect",r,e,t)},t.prototype.getRuleOperatorSelect=function(e,t){var r=this.templates.operatorSelect({builder:this,rule:e,operators:t,icons:this.icons,settings:this.settings,translate:this.translate.bind(this)}).trim();return this.change("getRuleOperatorSelect",r,e,t)},t.prototype.getRuleValueSelect=function(e,t){var r=this.templates.ruleValueSelect({builder:this,name:e,rule:t,icons:this.icons,settings:this.settings,translate:this.translate.bind(this)}).trim();return this.change("getRuleValueSelect",r,e,t)},t.prototype.getRuleInput=function(e,t){var n=e.filter,i=e.filter.validation||{},o=e.id+"_value_"+t,l=n.vertical?" class=block":"",s="",a=Array.isArray(n.placeholder)?n.placeholder[t]:n.placeholder;if("function"==typeof n.input)s=n.input.call(this,e,o);else switch(n.input){case"radio":case"checkbox":r.iterateOptions(n.values,(function(e,t){s+="<label"+l+'><input type="'+n.input+'" name="'+o+'" value="'+e+'"> '+t+"</label> "}));break;case"select":s=this.getRuleValueSelect(o,e);break;case"textarea":s+='<textarea class="form-control" name="'+o+'"',n.size&&(s+=' cols="'+n.size+'"'),n.rows&&(s+=' rows="'+n.rows+'"'),void 0!==i.min&&(s+=' minlength="'+i.min+'"'),void 0!==i.max&&(s+=' maxlength="'+i.max+'"'),a&&(s+=' placeholder="'+a+'"'),s+="></textarea>";break;case"number":s+='<input class="form-control" type="number" name="'+o+'"',void 0!==i.step&&(s+=' step="'+i.step+'"'),void 0!==i.min&&(s+=' min="'+i.min+'"'),void 0!==i.max&&(s+=' max="'+i.max+'"'),a&&(s+=' placeholder="'+a+'"'),n.size&&(s+=' size="'+n.size+'"'),s+=">";break;default:s+='<input class="form-control" type="text" name="'+o+'"',a&&(s+=' placeholder="'+a+'"'),"string"===n.type&&void 0!==i.min&&(s+=' minlength="'+i.min+'"'),"string"===n.type&&void 0!==i.max&&(s+=' maxlength="'+i.max+'"'),n.size&&(s+=' size="'+n.size+'"'),s+=">"}return this.change("getRuleInput",s,e,o)};var r={};function n(){this.root=null,this.$=e(this)}t.utils=r,r.iterateOptions=function(t,r){t&&(e.isArray(t)?t.forEach((function(t){e.isPlainObject(t)?"value"in t?r(t.value,t.label||t.value,t.optgroup):e.each(t,(function(e,t){return r(e,t),!1})):r(t,t)})):e.each(t,(function(e,t){r(e,t)})))},r.fmt=function(e,t){return Array.isArray(t)||(t=Array.prototype.slice.call(arguments,1)),e.replace(/{([0-9]+)}/g,(function(e,r){return t[parseInt(r)]}))},r.error=function(){var e=0,t="boolean"!=typeof arguments[e]||arguments[e++],n=arguments[e++],i=arguments[e++],o=Array.isArray(arguments[e])?arguments[e]:Array.prototype.slice.call(arguments,e);if(t){var l=new Error(r.fmt(i,o));throw l.name=n+"Error",l.args=o,l}console.error(n+"Error: "+r.fmt(i,o))},r.changeType=function(e,t){if(""!==e&&void 0!==e)switch(t){case"integer":return"string"!=typeof e||/^-?\d+$/.test(e)?parseInt(e):e;case"double":return"string"!=typeof e||/^-?\d+\.?\d*$/.test(e)?parseFloat(e):e;case"boolean":return"string"!=typeof e||/^(0|1|true|false){1}$/i.test(e)?!0===e||1===e||"true"===e.toLowerCase()||"1"===e:e;default:return e}},r.escapeString=function(e,t){if("string"!=typeof e)return e;var r=e.replace(/[\0\n\r\b\\\'\"]/g,(function(e){switch(e){case"\0":return"\\0";case"\n":return"\\n";case"\r":return"\\r";case"\b":return"\\b";case"'":return"''";default:return"\\"+e}})).replace(/\t/g,"\\t").replace(/\x1a/g,"\\Z");return t&&(r=r.replace(new RegExp("["+t+"]","g"),(function(e){return"\\"+e}))),r},r.escapeRegExp=function(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")},r.escapeElementId=function(e){return e?e.replace(/(\\)?([:.\[\],])/g,(function(e,t,r){return t?e:"\\"+r})):e},r.groupSort=function(e,t){var r=[],n=[];return e.forEach((function(e){var i;e[t]?-1==(i=r.lastIndexOf(e[t]))?i=r.length:i++:i=r.length,r.splice(i,0,e[t]),n.splice(i,0,e)})),n},r.defineModelProperties=function(t,r){r.forEach((function(r){Object.defineProperty(t.prototype,r,{enumerable:!0,get:function(){return this.__[r]},set:function(t){var n=null!==this.__[r]&&"object"==typeof this.__[r]?e.extend({},this.__[r]):this.__[r];this.__[r]=t,null!==this.model&&this.model.trigger("update",this,r,t,n)}})}))},e.extend(n.prototype,{trigger:function(t){var r=new e.Event(t);return this.$.triggerHandler(r,Array.prototype.slice.call(arguments,1)),r},on:function(){return this.$.on.apply(this.$,Array.prototype.slice.call(arguments)),this},off:function(){return this.$.off.apply(this.$,Array.prototype.slice.call(arguments)),this},once:function(){return this.$.one.apply(this.$,Array.prototype.slice.call(arguments)),this}});var i=function(e,t){if(!(this instanceof i))return new i(e,t);Object.defineProperty(this,"__",{value:{}}),t.data("queryBuilderModel",this),this.__.level=1,this.__.error=null,this.__.flags={},this.__.data=void 0,this.$el=t,this.id=t[0].id,this.model=null,this.parent=e};r.defineModelProperties(i,["level","error","data","flags"]),Object.defineProperty(i.prototype,"parent",{enumerable:!0,get:function(){return this.__.parent},set:function(e){this.__.parent=e,this.level=null===e?1:e.level+1,this.model=null===e?null:e.model}}),i.prototype.isRoot=function(){return 1===this.level},i.prototype.getPos=function(){return this.isRoot()?-1:this.parent.getNodePos(this)},i.prototype.drop=function(){var e=this.model;this.parent&&this.parent.removeNode(this),this.$el.removeData("queryBuilderModel"),null!==e&&e.trigger("drop",this)},i.prototype.moveAfter=function(e){this.isRoot()||this.move(e.parent,e.getPos()+1)},i.prototype.moveAtBegin=function(e){this.isRoot()||(void 0===e&&(e=this.parent),this.move(e,0))},i.prototype.moveAtEnd=function(e){this.isRoot()||(void 0===e&&(e=this.parent),this.move(e,0===e.length()?0:e.length()-1))},i.prototype.move=function(e,t){this.isRoot()||("number"==typeof e&&(t=e,e=this.parent),this.parent.removeNode(this),e.insertNode(this,t,!1),null!==this.model&&this.model.trigger("move",this,e,t))};var o=function(e,t){if(!(this instanceof o))return new o(e,t);i.call(this,e,t),this.rules=[],this.__.condition=null};o.prototype=Object.create(i.prototype),o.prototype.constructor=o,r.defineModelProperties(o,["condition"]),o.prototype.empty=function(){this.each("reverse",(function(e){e.drop()}),(function(e){e.drop()}))},o.prototype.drop=function(){this.empty(),i.prototype.drop.call(this)},o.prototype.length=function(){return this.rules.length},o.prototype.insertNode=function(e,t,r){return void 0===t&&(t=this.length()),this.rules.splice(t,0,e),e.parent=this,r&&null!==this.model&&this.model.trigger("add",this,e,t),e},o.prototype.addGroup=function(e,t){return this.insertNode(new o(this,e),t,!0)},o.prototype.addRule=function(e,t){return this.insertNode(new l(this,e),t,!0)},o.prototype.removeNode=function(e){var t=this.getNodePos(e);-1!==t&&(e.parent=null,this.rules.splice(t,1))},o.prototype.getNodePos=function(e){return this.rules.indexOf(e)},o.prototype.each=function(e,t,r,n){"boolean"!=typeof e&&"string"!=typeof e&&(n=r,r=t,t=e,e=!1),n=void 0===n?null:n;for(var i=e?this.rules.length-1:0,l=e?0:this.rules.length-1,s=e?-1:1,a=!1;(e?i>=l:i<=l)&&(this.rules[i]instanceof o?r&&(a=!1===r.call(n,this.rules[i])):t&&(a=!1===t.call(n,this.rules[i])),!a);i+=s);return!a},o.prototype.contains=function(e,t){return-1!==this.getNodePos(e)||!!t&&!this.each((function(){return!0}),(function(t){return!t.contains(e,!0)}))};var l=function(e,t){if(!(this instanceof l))return new l(e,t);i.call(this,e,t),this._updating_value=!1,this._updating_input=!1,this.__.filter=null,this.__.operator=null,this.__.value=void 0};function s(e,r,n){var i,o,s=t.selectors;(i=r.closest(s.rule_container)).length&&(o="moveAfter"),o||(i=r.closest(s.group_header)).length&&(i=r.closest(s.group_container),o="moveAtBegin"),o||(i=r.closest(s.group_container)).length&&(o="moveAtEnd"),o&&(e[o](n.getModel(i)),n&&e instanceof l&&n.setRuleInputValue(e,e.value))}function a(e){var t=e.match(/(question_mark|numbered|named)(?:\((.)\))?/);return t||(t=[null,"question_mark",void 0]),t}return l.prototype=Object.create(i.prototype),l.prototype.constructor=l,r.defineModelProperties(l,["filter","operator","value"]),l.prototype.isRoot=function(){return!1},t.Group=o,t.Rule=l,e.fn.queryBuilder=function(e){0===this.length&&r.error("Config","No target defined"),this.length>1&&r.error("Config","Unable to initialize on multiple target");var n=this.data("queryBuilder"),i="object"==typeof e&&e||{};if(!n&&"destroy"==e)return this;if(!n){var o=new t(this,i);this.data("queryBuilder",o),o.init(i.rules)}return"string"==typeof e?n[e].apply(n,Array.prototype.slice.call(arguments,1)):this},e.fn.queryBuilder.constructor=t,e.fn.queryBuilder.defaults=t.defaults,e.fn.queryBuilder.extend=t.extend,e.fn.queryBuilder.define=t.define,e.fn.queryBuilder.regional=t.regional,t.define("bt-checkbox",(function(e){"bootstrap-icons"===e.font&&this.$el.addClass("bt-checkbox-bootstrap-icons"),this.on("getRuleInput.filter",(function(t,n,i){var o=n.filter;if(("radio"===o.input||"checkbox"===o.input)&&!o.plugin){t.value="",o.colors||(o.colors={}),o.color&&(o.colors._def_=o.color);var l=o.vertical?' style="display:block"':"",s=0;r.iterateOptions(o.values,(function(r,n){var a=o.colors[r]||o.colors._def_||e.color,u=i+"_"+s++;t.value+=`<div ${l} class="${o.input} ${o.input}-${a} form-check form-check-inline"> <input class="form-check-input" type="${o.input}" name="${i}" id="${u}" value="${r}"> <label class="form-check-label" for="${u}">${n}</label></div>`}))}}))}),{font:"bootstrap-icons",color:"default"}),t.define("bt-tooltip-errors",(function(n){"function"===(bootstrap.Tooltip,!1)&&(alert(typeof bootstrap.Tooltip),r.error("MissingLibrary",'Bootstrap Popper is required to use "bt-tooltip-errors" plugin. Get it here: http://getbootstrap.com'));var i=this;this.on("getRuleTemplate.filter getGroupTemplate.filter",(function(r){var n=e(e.parseHTML(r.value));n.find(t.selectors.error_container).attr("data-bs-toggle","tooltip"),r.value=n.prop("outerHTML")})),this.model.on("update",(function(e,r,o){"error"==o&&i.settings.display_errors&&r.$el.find(t.selectors.error_container).eq(0).attr("data-bs-original-title",n).attr("data-bs-title",n).tooltip()}))}),{placement:"right"}),t.extend({setFilters:function(e,n){var i=this;void 0===n&&(n=e,e=!1),n=this.checkFilters(n);var o=(n=this.change("setFilters",n)).map((function(e){return e.id}));if(e||function e(t){t.each((function(e){e.filter&&-1===o.indexOf(e.filter.id)&&r.error("ChangeFilter",'A rule is using filter "{0}"',e.filter.id)}),e)}(this.model.root),this.filters=n,function e(r){r.each(!0,(function(e){e.filter&&-1===o.indexOf(e.filter.id)?(e.drop(),i.trigger("rulesChanged")):(i.createRuleFilters(e),e.$el.find(t.selectors.rule_filter).val(e.filter?e.filter.id:"-1"),i.trigger("afterUpdateRuleFilter",e))}),e)}(this.model.root),this.settings.plugins&&(this.settings.plugins["unique-filter"]&&this.updateDisabledFilters(),this.settings.plugins["bt-selectpicker"]&&this.$el.find(t.selectors.rule_filter).selectpicker("render")),this.settings.default_filter)try{this.getFilterById(this.settings.default_filter)}catch(e){this.settings.default_filter=null}this.trigger("afterSetFilters",n)},addFilter:function(t,r){void 0===r||"#end"==r?r=this.filters.length:"#start"==r&&(r=0),e.isArray(t)||(t=[t]);var n=e.extend(!0,[],this.filters);parseInt(r)==r||this.filters.some((function(e,t){if(e.id==r)return r=t+1,!0}))?Array.prototype.splice.apply(n,[r,0].concat(t)):Array.prototype.push.apply(n,t),this.setFilters(n)},removeFilter:function(t,r){var n=e.extend(!0,[],this.filters);"string"==typeof t&&(t=[t]),n=n.filter((function(e){return-1===t.indexOf(e.id)})),this.setFilters(r,n)}}),t.define("chosen-selectpicker",(function(n){e.fn.chosen||r.error("MissingLibrary",'chosen is required to use "chosen-selectpicker" plugin. Get it here: https://github.com/harvesthq/chosen'),this.settings.plugins["bt-selectpicker"]&&r.error("Conflict","bt-selectpicker is already selected as the dropdown plugin. Please remove chosen-selectpicker from the plugin list");var i=t.selectors;this.on("afterCreateRuleFilters",(function(e,t){t.$el.find(i.rule_filter).removeClass("form-control").chosen(n)})),this.on("afterCreateRuleOperators",(function(e,t){e.builder.getOperators(t.filter).length>1&&t.$el.find(i.rule_operator).removeClass("form-control").chosen(n)})),this.on("afterUpdateRuleFilter",(function(e,t){t.$el.find(i.rule_filter).trigger("chosen:updated")})),this.on("afterUpdateRuleOperator",(function(e,t){t.$el.find(i.rule_operator).trigger("chosen:updated")})),this.on("beforeDeleteRule",(function(e,t){t.$el.find(i.rule_filter).chosen("destroy"),t.$el.find(i.rule_operator).chosen("destroy")}))})),t.define("filter-description",(function(n){"inline"===n.mode?this.on("afterUpdateRuleFilter afterUpdateRuleOperator",(function(t,r){var i=r.$el.find("p.filter-description"),o=t.builder.getFilterDescription(r.filter,r);o?(0===i.length?(i=e(e.parseHTML('<p class="filter-description"></p>'))).appendTo(r.$el):i.css("display",""),i.html('<i class="'+n.icon+'"></i> '+o)):i.hide()})):"popover"===n.mode?(e.fn.popover&&e.fn.popover.Constructor&&e.fn.popover.Constructor.prototype.fixTitle||r.error("MissingLibrary",'Bootstrap Popover is required to use "filter-description" plugin. Get it here: http://getbootstrap.com'),this.on("afterUpdateRuleFilter afterUpdateRuleOperator",(function(r,i){var o=i.$el.find("button.filter-description"),l=r.builder.getFilterDescription(i.filter,i);if(l){if(0===o.length){(o=e(e.parseHTML('<button type="button" class="btn btn-sm btn-info filter-description" data-bs-toggle="popover"><i class="'+n.icon+'"></i></button>'))).prependTo(i.$el.find(t.selectors.rule_actions));const r=new bootstrap.Popover(o.get(0),{placement:"left",container:"body",html:!0});o.on("mouseout",(function(){r("hide")}))}else o.css("display","");o.data("bs-popover").options.content=l,o.attr("aria-describedby")&&o.popover("show")}else o.hide(),o.data("bs-popover")&&o.popover("hide")}))):"bootbox"===n.mode&&("bootbox"in window||r.error("MissingLibrary",'Bootbox is required to use "filter-description" plugin. Get it here: http://bootboxjs.com'),this.on("afterUpdateRuleFilter afterUpdateRuleOperator",(function(r,i){var o=i.$el.find("button.filter-description"),l=r.builder.getFilterDescription(i.filter,i);l?(0===o.length?((o=e(e.parseHTML('<button type="button" class="btn btn-sm btn-info filter-description" data-bs-toggle="bootbox"><i class="'+n.icon+'"></i></button>'))).prependTo(i.$el.find(t.selectors.rule_actions)),o.on("click",(function(){bootbox.alert(o.data("description"))}))):o.css("display",""),o.data("description",l)):o.hide()})))}),{icon:"bi-info-circle-fill",mode:"popover"}),t.extend({getFilterDescription:function(e,t){return e?"function"==typeof e.description?e.description.call(this,t):e.description:void 0}}),t.define("invert",(function(r){var n=this,i=t.selectors;this.on("afterInit",(function(){n.$el.on("click.queryBuilder","[data-invert=group]",(function(){var t=e(this).closest(i.group_container);n.invert(n.getModel(t),r)})),r.display_rules_button&&r.invert_rules&&n.$el.on("click.queryBuilder","[data-invert=rule]",(function(){var t=e(this).closest(i.rule_container);n.invert(n.getModel(t),r)}))})),r.disable_template||(this.on("getGroupTemplate.filter",(function(t){var o=e(e.parseHTML(t.value));o.find(i.condition_container).after('<button type="button" class="btn btn-sm btn-default" data-invert="group"><i class="'+r.icon+'"></i> '+n.translate("invert")+"</button>"),t.value=o.prop("outerHTML")})),r.display_rules_button&&r.invert_rules&&this.on("getRuleTemplate.filter",(function(t){var o=e(e.parseHTML(t.value));o.find(i.rule_actions).prepend('<button type="button" class="btn btn-sm btn-default" data-invert="rule"><i class="'+r.icon+'"></i> '+n.translate("invert")+"</button>"),t.value=o.prop("outerHTML")})))}),{icon:"bi-shuffle",recursive:!0,invert_rules:!0,display_rules_button:!1,silent_fail:!1,disable_template:!1}),t.defaults({operatorOpposites:{equal:"not_equal",not_equal:"equal",in:"not_in",not_in:"in",less:"greater_or_equal",less_or_equal:"greater",greater:"less_or_equal",greater_or_equal:"less",between:"not_between",not_between:"between",begins_with:"not_begins_with",not_begins_with:"begins_with",contains:"not_contains",not_contains:"contains",ends_with:"not_ends_with",not_ends_with:"ends_with",is_empty:"is_not_empty",is_not_empty:"is_empty",is_null:"is_not_null",is_not_null:"is_null"},conditionOpposites:{AND:"OR",OR:"AND"}}),t.extend({invert:function(t,n){if(!(t instanceof i)){if(!this.model.root)return;n=t,t=this.model.root}if("object"!=typeof n&&(n={}),void 0===n.recursive&&(n.recursive=!0),void 0===n.invert_rules&&(n.invert_rules=!0),void 0===n.silent_fail&&(n.silent_fail=!1),void 0===n.trigger&&(n.trigger=!0),t instanceof o){if(this.settings.conditionOpposites[t.condition]?t.condition=this.settings.conditionOpposites[t.condition]:n.silent_fail||r.error("InvertCondition",'Unknown inverse of condition "{0}"',t.condition),n.recursive){var s=e.extend({},n,{trigger:!1});t.each((function(e){n.invert_rules&&this.invert(e,s)}),(function(e){this.invert(e,s)}),this)}}else if(t instanceof l&&t.operator&&!t.filter.no_invert)if(this.settings.operatorOpposites[t.operator.type]){var a=this.settings.operatorOpposites[t.operator.type];t.filter.operators&&-1==t.filter.operators.indexOf(a)||(t.operator=this.getOperatorByType(a))}else n.silent_fail||r.error("InvertOperator",'Unknown inverse of operator "{0}"',t.operator.type);n.trigger&&(this.trigger("afterInvert",t,n),this.trigger("rulesChanged"))}}),t.defaults({mongoOperators:{equal:function(e){return e[0]},not_equal:function(e){return{$ne:e[0]}},in:function(e){return{$in:e}},not_in:function(e){return{$nin:e}},less:function(e){return{$lt:e[0]}},less_or_equal:function(e){return{$lte:e[0]}},greater:function(e){return{$gt:e[0]}},greater_or_equal:function(e){return{$gte:e[0]}},between:function(e){return{$gte:e[0],$lte:e[1]}},not_between:function(e){return{$lt:e[0],$gt:e[1]}},begins_with:function(e){return{$regex:"^"+r.escapeRegExp(e[0])}},not_begins_with:function(e){return{$regex:"^(?!"+r.escapeRegExp(e[0])+")"}},contains:function(e){return{$regex:r.escapeRegExp(e[0])}},not_contains:function(e){return{$regex:"^((?!"+r.escapeRegExp(e[0])+").)*$",$options:"s"}},ends_with:function(e){return{$regex:r.escapeRegExp(e[0])+"$"}},not_ends_with:function(e){return{$regex:"(?<!"+r.escapeRegExp(e[0])+")$"}},is_empty:function(e){return""},is_not_empty:function(e){return{$ne:""}},is_null:function(e){return null},is_not_null:function(e){return{$ne:null}}},mongoRuleOperators:{$eq:function(e){return{val:e,op:null===e?"is_null":""===e?"is_empty":"equal"}},$ne:function(e){return{val:e=e.$ne,op:null===e?"is_not_null":""===e?"is_not_empty":"not_equal"}},$regex:function(e){return"^(?!"==(e=e.$regex).slice(0,4)&&")"==e.slice(-1)?{val:e.slice(4,-1),op:"not_begins_with"}:"^((?!"==e.slice(0,5)&&").)*$"==e.slice(-5)?{val:e.slice(5,-5),op:"not_contains"}:"(?<!"==e.slice(0,4)&&")$"==e.slice(-2)?{val:e.slice(4,-2),op:"not_ends_with"}:"$"==e.slice(-1)?{val:e.slice(0,-1),op:"ends_with"}:"^"==e.slice(0,1)?{val:e.slice(1),op:"begins_with"}:{val:e,op:"contains"}},between:function(e){return{val:[e.$gte,e.$lte],op:"between"}},not_between:function(e){return{val:[e.$lt,e.$gt],op:"not_between"}},$in:function(e){return{val:e.$in,op:"in"}},$nin:function(e){return{val:e.$nin,op:"not_in"}},$lt:function(e){return{val:e.$lt,op:"less"}},$lte:function(e){return{val:e.$lte,op:"less_or_equal"}},$gt:function(e){return{val:e.$gt,op:"greater"}},$gte:function(e){return{val:e.$gte,op:"greater_or_equal"}}}}),t.extend({getMongo:function(e){if(!(e=void 0===e?this.getRules():e))return null;var t=this;return function e(n){if(n.condition||(n.condition=t.settings.default_condition),-1===["AND","OR"].indexOf(n.condition.toUpperCase())&&r.error("UndefinedMongoCondition",'Unable to build MongoDB query with condition "{0}"',n.condition),!n.rules)return{};var i=[];n.rules.forEach((function(n){if(n.rules&&n.rules.length>0)i.push(e(n));else{var o=t.settings.mongoOperators[n.operator],l=t.getOperatorByType(n.operator);void 0===o&&r.error("UndefinedMongoOperator",'Unknown MongoDB operation for operator "{0}"',n.operator),0!==l.nb_inputs&&(n.value instanceof Array||(n.value=[n.value]));var s={};s[t.change("getMongoDBField",n.field,n)]=o.call(t,n.value),i.push(t.change("ruleToMongo",s,n,n.value,o))}}));var o={};return o["$"+n.condition.toLowerCase()]=i,t.change("groupToMongo",o,n)}(e)},getRulesFromMongo:function(e){if(null==e)return null;var t=this;if("rules"in(e=t.change("parseMongoNode",e))&&"condition"in e)return e;if("id"in e&&"operator"in e&&"value"in e)return{condition:this.settings.default_condition,rules:[e]};var n=t.getMongoCondition(e);return n||r.error("MongoParse","Invalid MongoDB query format"),function e(n,i){var o=n[i],l=[];return o.forEach((function(n){if("rules"in(n=t.change("parseMongoNode",n))&&"condition"in n)l.push(n);else if("id"in n&&"operator"in n&&"value"in n)l.push(n);else{var i=t.getMongoCondition(n);if(i)l.push(e(n,i));else{var o=Object.keys(n)[0],s=n[o],a=t.getMongoOperator(s);void 0===a&&r.error("MongoParse","Invalid MongoDB query format");var u=t.settings.mongoRuleOperators[a];void 0===u&&r.error("UndefinedMongoOperator",'JSON Rule operation unknown for operator "{0}"',a);var p=u.call(t,s),d=t.getMongoDBFieldID(o,s),c=t.change("mongoToRule",{id:d,field:o,operator:p.op,value:p.val},n);l.push(c)}}})),t.change("mongoToGroup",{condition:i.replace("$","").toUpperCase(),rules:l},n)}(e,n)},setRulesFromMongo:function(e){this.setRules(this.getRulesFromMongo(e))},getMongoDBFieldID:function(e,t){var r=this.filters.filter((function(t){return t.field===e}));return 1===r.length?r[0].id:this.change("getMongoDBFieldID",e,t)},getMongoOperator:function(e){if(null===e||"object"!=typeof e)return"$eq";if(void 0!==e.$gte&&void 0!==e.$lte)return"between";if(void 0!==e.$lt&&void 0!==e.$gt)return"not_between";var t=Object.keys(e).filter(function(e){return!!this.settings.mongoRuleOperators[e]}.bind(this));return 1===t.length?t[0]:void 0},getMongoCondition:function(e){for(var t=Object.keys(e),r=0,n=t.length;r<n;r++)if("$or"===t[r].toLowerCase()||"$and"===t[r].toLowerCase())return t[r]}}),t.define("not-group",(function(r){var n=this;this.on("afterInit",(function(){n.$el.on("click.queryBuilder","[data-not=group]",(function(){var r=e(this).closest(t.selectors.group_container),i=n.getModel(r);i.not=!i.not})),n.model.on("update",(function(e,t,r){t instanceof o&&"not"===r&&n.updateGroupNot(t)}))})),this.on("afterAddGroup",(function(e,t){t.__.not=!1})),r.disable_template||this.on("getGroupTemplate.filter",(function(i){var o=e(e.parseHTML(i.value));o.find(t.selectors.condition_container).prepend('<button type="button" class="btn btn-sm btn-default" data-not="group"><i class="'+r.icon_unchecked+'"></i> '+n.translate("NOT")+"</button>"),i.value=o.prop("outerHTML")})),this.on("groupToJson.filter",(function(e,t){e.value.not=t.not})),this.on("jsonToGroup.filter",(function(e,t){e.value.not=!!t.not})),this.on("groupToSQL.filter",(function(e,t){t.not&&(e.value="NOT ( "+e.value+" )")})),this.on("parseSQLNode.filter",(function(e){e.value.name&&"NOT"==e.value.name.toUpperCase()&&(e.value=e.value.arguments.value[0],-1===["AND","OR"].indexOf(e.value.operation.toUpperCase())&&(e.value=new SQLParser.nodes.Op(n.settings.default_condition,e.value,null)),e.value.not=!0)})),this.on("sqlGroupsDistinct.filter",(function(e,t,r,n){r.not&&n>0&&(e.value=!0)})),this.on("sqlToGroup.filter",(function(e,t){e.value.not=!!t.not})),this.on("groupToMongo.filter",(function(e,t){var r="$"+t.condition.toLowerCase();t.not&&e.value[r]&&(e.value={$nor:[e.value]})})),this.on("parseMongoNode.filter",(function(e){var t=Object.keys(e.value);"$nor"==t[0]&&(e.value=e.value[t[0]][0],e.value.not=!0)})),this.on("mongoToGroup.filter",(function(e,t){e.value.not=!!t.not}))}),{icon_unchecked:"bi-square",icon_checked:"bi-check2-square",disable_template:!1}),r.defineModelProperties(o,["not"]),t.selectors.group_not=t.selectors.group_header+" [data-not=group]",t.extend({updateGroupNot:function(e){var r=this.plugins["not-group"];e.$el.find(">"+t.selectors.group_not).toggleClass("active",e.not).find("i").attr("class",e.not?r.icon_checked:r.icon_unchecked),this.trigger("afterUpdateGroupNot",e),this.trigger("rulesChanged")}}),t.define("sortable",(function(n){var i,l,a,u;"interact"in window||r.error("MissingLibrary",'interact.js is required to use "sortable" plugin. Get it here: http://interactjs.io'),void 0!==n.default_no_sortable&&(r.error(!1,"Config",'Sortable plugin : "default_no_sortable" options is deprecated, use standard "default_rule_flags" and "default_group_flags" instead'),this.settings.default_rule_flags.no_sortable=this.settings.default_group_flags.no_sortable=n.default_no_sortable),interact.dynamicDrop(!0),interact.pointerMoveTolerance(10),this.on("afterAddRule afterAddGroup",(function(r,p){if(p!=i){var d=r.builder;n.inherit_no_sortable&&p.parent&&p.parent.flags.no_sortable&&(p.flags.no_sortable=!0),n.inherit_no_drop&&p.parent&&p.parent.flags.no_drop&&(p.flags.no_drop=!0),p.flags.no_sortable||interact(p.$el[0]).draggable({allowFrom:t.selectors.drag_handle,onstart:function(t){u=!1,a=d.getModel(t.target),l=a.$el.clone().appendTo(a.$el.parent()).width(a.$el.outerWidth()).addClass("dragging");var r=e(e.parseHTML('<div class="rule-placeholder">&nbsp;</div>')).height(a.$el.outerHeight());i=a.parent.addRule(r,a.getPos()),a.$el.hide()},onmove:function(e){l[0].style.top=e.clientY-15+"px",l[0].style.left=e.clientX-15+"px"},onend:function(t){t.dropzone&&(s(a,e(t.relatedTarget),d),u=!0),l.remove(),l=void 0,i.drop(),i=void 0,a.$el.css("display",""),d.trigger("afterMove",a),d.trigger("rulesChanged")}}),p.flags.no_drop||(interact(p.$el[0]).dropzone({accept:t.selectors.rule_and_group_containers,ondragenter:function(t){s(i,e(t.target),d)},ondrop:function(t){u||s(a,e(t.target),d)}}),p instanceof o&&interact(p.$el.find(t.selectors.group_header)[0]).dropzone({accept:t.selectors.rule_and_group_containers,ondragenter:function(t){s(i,e(t.target),d)},ondrop:function(t){u||s(a,e(t.target),d)}}))}})),this.on("beforeDeleteRule beforeDeleteGroup",(function(e,r){e.isDefaultPrevented()||(interact(r.$el[0]).unset(),r instanceof o&&interact(r.$el.find(t.selectors.group_header)[0]).unset())})),this.on("afterApplyRuleFlags afterApplyGroupFlags",(function(e,t){t.flags.no_sortable&&t.$el.find(".drag-handle").remove()})),n.disable_template||(this.on("getGroupTemplate.filter",(function(r,i){if(i>1){var o=e(e.parseHTML(r.value));o.find(t.selectors.condition_container).after('<div class="drag-handle"><i class="'+n.icon+'"></i></div>'),r.value=o.prop("outerHTML")}})),this.on("getRuleTemplate.filter",(function(r){var i=e(e.parseHTML(r.value));i.find(t.selectors.rule_header).after('<div class="drag-handle"><i class="'+n.icon+'"></i></div>'),r.value=i.prop("outerHTML")})))}),{inherit_no_sortable:!0,inherit_no_drop:!0,icon:"bi-sort-down",disable_template:!1}),t.selectors.rule_and_group_containers=t.selectors.rule_container+", "+t.selectors.group_container,t.selectors.drag_handle=".drag-handle",t.defaults({default_rule_flags:{no_sortable:!1,no_drop:!1},default_group_flags:{no_sortable:!1,no_drop:!1}}),t.define("sql-support",(function(e){}),{boolean_as_integer:!0}),t.defaults({sqlOperators:{equal:{op:"= ?"},not_equal:{op:"!= ?"},in:{op:"IN(?)",sep:", "},not_in:{op:"NOT IN(?)",sep:", "},less:{op:"< ?"},less_or_equal:{op:"<= ?"},greater:{op:"> ?"},greater_or_equal:{op:">= ?"},between:{op:"BETWEEN ?",sep:" AND "},not_between:{op:"NOT BETWEEN ?",sep:" AND "},begins_with:{op:"LIKE ?",mod:"{0}%",escape:"%_"},not_begins_with:{op:"NOT LIKE ?",mod:"{0}%",escape:"%_"},contains:{op:"LIKE ?",mod:"%{0}%",escape:"%_"},not_contains:{op:"NOT LIKE ?",mod:"%{0}%",escape:"%_"},ends_with:{op:"LIKE ?",mod:"%{0}",escape:"%_"},not_ends_with:{op:"NOT LIKE ?",mod:"%{0}",escape:"%_"},is_empty:{op:"= ''"},is_not_empty:{op:"!= ''"},is_null:{op:"IS NULL"},is_not_null:{op:"IS NOT NULL"}},sqlRuleOperator:{"=":function(e){return{val:e,op:""===e?"is_empty":"equal"}},"!=":function(e){return{val:e,op:""===e?"is_not_empty":"not_equal"}},LIKE:function(e){return"%"==e.slice(0,1)&&"%"==e.slice(-1)?{val:e.slice(1,-1),op:"contains"}:"%"==e.slice(0,1)?{val:e.slice(1),op:"ends_with"}:"%"==e.slice(-1)?{val:e.slice(0,-1),op:"begins_with"}:void r.error("SQLParse",'Invalid value for LIKE operator "{0}"',e)},"NOT LIKE":function(e){return"%"==e.slice(0,1)&&"%"==e.slice(-1)?{val:e.slice(1,-1),op:"not_contains"}:"%"==e.slice(0,1)?{val:e.slice(1),op:"not_ends_with"}:"%"==e.slice(-1)?{val:e.slice(0,-1),op:"not_begins_with"}:void r.error("SQLParse",'Invalid value for NOT LIKE operator "{0}"',e)},IN:function(e){return{val:e,op:"in"}},"NOT IN":function(e){return{val:e,op:"not_in"}},"<":function(e){return{val:e,op:"less"}},"<=":function(e){return{val:e,op:"less_or_equal"}},">":function(e){return{val:e,op:"greater"}},">=":function(e){return{val:e,op:"greater_or_equal"}},BETWEEN:function(e){return{val:e,op:"between"}},"NOT BETWEEN":function(e){return{val:e,op:"not_between"}},IS:function(e){return null!==e&&r.error("SQLParse","Invalid value for IS operator"),{val:null,op:"is_null"}},"IS NOT":function(e){return null!==e&&r.error("SQLParse","Invalid value for IS operator"),{val:null,op:"is_not_null"}}},sqlStatements:{question_mark:function(){var e=[];return{add:function(t,r){return e.push(r),"?"},run:function(){return e}}},numbered:function(e){(!e||e.length>1)&&(e="$");var t=0,r=[];return{add:function(n,i){return r.push(i),t++,e+t},run:function(){return r}}},named:function(e){(!e||e.length>1)&&(e=":");var t={},r={};return{add:function(n,i){t[n.field]||(t[n.field]=1);var o=n.field+"_"+t[n.field]++;return r[o]=i,e+o},run:function(){return r}}}},sqlRuleStatement:{question_mark:function(e){var t=0;return{parse:function(r){return"?"==r?e[t++]:r},esc:function(e){return e.replace(/\?/g,"'?'")}}},numbered:function(e,t){(!t||t.length>1)&&(t="$");var r=new RegExp("^\\"+t+"[0-9]+$"),n=new RegExp("\\"+t+"([0-9]+)","g");return{parse:function(t){return r.test(t)?e[t.slice(1)-1]:t},esc:function(e){return e.replace(n,"'"+("$"==t?"$$":t)+"$1'")}}},named:function(e,t){(!t||t.length>1)&&(t=":");var r=new RegExp("^\\"+t),n=new RegExp("\\"+t+"("+Object.keys(e).join("|")+")\\b","g");return{parse:function(t){return r.test(t)?e[t.slice(1)]:t},esc:function(e){return e.replace(n,"'"+("$"==t?"$$":t)+"$1'")}}}}}),t.extend({getSQL:function(e,t,n){if(!(n=void 0===n?this.getRules():n))return null;t=t?"\n":" ";var i=this.getPluginOptions("sql-support","boolean_as_integer");if(!0===e&&(e="question_mark"),"string"==typeof e){var o=a(e);e=this.settings.sqlStatements[o[1]](o[2])}var l=this,s=function n(o){if(o.condition||(o.condition=l.settings.default_condition),-1===["AND","OR"].indexOf(o.condition.toUpperCase())&&r.error("UndefinedSQLCondition",'Unable to build SQL query with condition "{0}"',o.condition),!o.rules)return"";var s=[];o.rules.forEach((function(o){if(o.rules&&o.rules.length>0)s.push("("+t+n(o)+t+")"+t);else{var a=l.settings.sqlOperators[o.operator],u=l.getOperatorByType(o.operator),p="";void 0===a&&r.error("UndefinedSQLOperator",'Unknown SQL operation for operator "{0}"',o.operator),0!==u.nb_inputs&&(o.value instanceof Array||(o.value=[o.value]),o.value.forEach((function(t,n){n>0&&(p+=a.sep),"boolean"==o.type&&i?t=t?1:0:e||"integer"===o.type||"double"===o.type||"boolean"===o.type||(t=r.escapeString(t,a.escape)),a.mod&&(t=r.fmt(a.mod,t)),e?p+=e.add(o,t):("string"==typeof t&&(t="'"+t+"'"),p+=t)})));var d=function(e){return a.op.replace("?",(function(){return e}))},c=l.change("getSQLField",o.field,o)+" "+d(p);s.push(l.change("ruleToSQL",c,o,p,d))}}));var a=s.join(" "+o.condition+t);return l.change("groupToSQL",a,o)}(n);return e?{sql:s,params:e.run()}:{sql:s}},getRulesFromSQL:function(t,n){"SQLParser"in window||r.error("MissingLibrary","SQLParser is required to parse SQL queries. Get it here https://github.com/mistic100/sql-parser");var i=this;if("string"==typeof t&&(t={sql:t}),!0===n&&(n="question_mark"),"string"==typeof n){var o=a(n);n=this.settings.sqlRuleStatement[o[1]](t.params,o[2])}n&&(t.sql=n.esc(t.sql)),0!==t.sql.toUpperCase().indexOf("SELECT")&&(t.sql="SELECT * FROM table WHERE "+t.sql);var l=SQLParser.parse(t.sql);l.where||r.error("SQLParse","No WHERE clause found");var s=i.change("parseSQLNode",l.where.conditions);if("rules"in s&&"condition"in s)return s;if("id"in s&&"operator"in s&&"value"in s)return{condition:this.settings.default_condition,rules:[s]};var u=i.change("sqlToGroup",{condition:this.settings.default_condition,rules:[]},s),p=u;return function t(o,l){if(null!==o)if("rules"in(o=i.change("parseSQLNode",o))&&"condition"in o)p.rules.push(o);else if("id"in o&&"operator"in o&&"value"in o)p.rules.push(o);else if("left"in o&&"right"in o&&"operation"in o||r.error("SQLParse","Unable to parse WHERE clause"),-1!==["AND","OR"].indexOf(o.operation.toUpperCase())){if(i.change("sqlGroupsDistinct",l>0&&p.condition!=o.operation.toUpperCase(),p,o,l)){var s=i.change("sqlToGroup",{condition:i.settings.default_condition,rules:[]},o);p.rules.push(s),p=s}p.condition=o.operation.toUpperCase(),l++;var a=p;t(o.left,l),p=a,t(o.right,l)}else{var u;e.isPlainObject(o.right.value)&&r.error("SQLParse","Value format not supported for {0}.",o.left.value),u=e.isArray(o.right.value)?o.right.value.map((function(e){return e.value})):o.right.value,n&&(u=e.isArray(u)?u.map(n.parse):n.parse(u));var d=o.operation.toUpperCase();"<>"==d&&(d="!=");var c=i.settings.sqlRuleOperator[d];void 0===c&&r.error("UndefinedSQLOperator",'Invalid SQL operation "{0}".',o.operation);var f,g=c.call(this,u,o.operation);"values"in o.left?f=o.left.values.join("."):"value"in o.left?f=o.left.value:r.error("SQLParse","Cannot find field name in {0}",JSON.stringify(o.left));var h=g.val,_=i.settings.sqlOperators[g.op];if(!n&&_&&_.escape){var v=_.escape.split("").map((function(e){return"\\\\"+e})).join("|");h=h.replace(new RegExp("("+v+")","g"),(function(e){return e[1]}))}var m=i.getSQLFieldID(f,u),y=i.change("sqlToRule",{id:m,field:f,operator:g.op,value:h},o);p.rules.push(y)}}(s,0),u},setRulesFromSQL:function(e,t){this.setRules(this.getRulesFromSQL(e,t))},getSQLFieldID:function(e,t){var r=this.filters.filter((function(t){return t.field.toLowerCase()===e.toLowerCase()}));return 1===r.length?r[0].id:this.change("getSQLFieldID",e,t)}}),t.define("unique-filter",(function(){this.status.used_filters={},this.on("afterUpdateRuleFilter",this.updateDisabledFilters),this.on("afterDeleteRule",this.updateDisabledFilters),this.on("afterCreateRuleFilters",this.applyDisabledFilters),this.on("afterReset",this.clearDisabledFilters),this.on("afterClear",this.clearDisabledFilters),this.on("getDefaultFilter.filter",(function(e,t){var n=e.builder;(n.updateDisabledFilters(),e.value.id in n.status.used_filters)&&(n.filters.some((function(r){if(!(r.id in n.status.used_filters)||n.status.used_filters[r.id].length>0&&-1===n.status.used_filters[r.id].indexOf(t.parent))return e.value=r,!0}))||(r.error(!1,"UniqueFilter","No more non-unique filters available"),e.value=void 0))}))})),t.extend({updateDisabledFilters:function(e){var t=e?e.builder:this;t.status.used_filters={},t.model&&(!function e(r){r.each((function(e){e.filter&&e.filter.unique&&(t.status.used_filters[e.filter.id]||(t.status.used_filters[e.filter.id]=[]),"group"==e.filter.unique&&t.status.used_filters[e.filter.id].push(e.parent))}),(function(t){e(t)}))}(t.model.root),t.applyDisabledFilters(e))},clearDisabledFilters:function(e){var t=e?e.builder:this;t.status.used_filters={},t.applyDisabledFilters(e)},applyDisabledFilters:function(r){var n=r?r.builder:this;n.$el.find(t.selectors.filter_container+" option").prop("disabled",!1),e.each(n.status.used_filters,(function(e,r){0===r.length?n.$el.find(t.selectors.filter_container+' option[value="'+e+'"]:not(:selected)').prop("disabled",!0):r.forEach((function(r){r.each((function(r){r.$el.find(t.selectors.filter_container+' option[value="'+e+'"]:not(:selected)').prop("disabled",!0)}))}))})),n.settings.plugins&&n.settings.plugins["bt-selectpicker"]&&n.$el.find(t.selectors.rule_filter).selectpicker("render")}}),
/*!
 * jQuery QueryBuilder 3.0.0
 * Locale: English (en)
 * Author: Damien "Mistic" Sorel, http://www.strangeplanet.fr
 * Licensed under MIT (https://opensource.org/licenses/MIT)
 */
t.regional.en={__locale:"English (en)",__author:'Damien "Mistic" Sorel, http://www.strangeplanet.fr',add_rule:"Add rule",add_group:"Add group",delete_rule:"Delete",delete_group:"Delete",conditions:{AND:"AND",OR:"OR"},operators:{equal:"equal",not_equal:"not equal",in:"in",not_in:"not in",less:"less",less_or_equal:"less or equal",greater:"greater",greater_or_equal:"greater or equal",between:"between",not_between:"not between",begins_with:"begins with",not_begins_with:"doesn't begin with",contains:"contains",not_contains:"doesn't contain",ends_with:"ends with",not_ends_with:"doesn't end with",is_empty:"is empty",is_not_empty:"is not empty",is_null:"is null",is_not_null:"is not null"},errors:{no_filter:"No filter selected",empty_group:"The group is empty",radio_empty:"No value selected",checkbox_empty:"No value selected",select_empty:"No value selected",string_empty:"Empty value",string_exceed_min_length:"Must contain at least {0} characters",string_exceed_max_length:"Must not contain more than {0} characters",string_invalid_format:"Invalid format ({0})",number_nan:"Not a number",number_not_integer:"Not an integer",number_not_double:"Not a real number",number_exceed_min:"Must be greater than {0}",number_exceed_max:"Must be lower than {0}",number_wrong_step:"Must be a multiple of {0}",number_between_invalid:"Invalid values, {0} is greater than {1}",datetime_empty:"Empty value",datetime_invalid:"Invalid date format ({0})",datetime_exceed_min:"Must be after {0}",datetime_exceed_max:"Must be before {0}",datetime_between_invalid:"Invalid values, {0} is greater than {1}",boolean_not_valid:"Not a boolean",operator_not_multiple:'Operator "{1}" cannot accept multiple values'},invert:"Invert",NOT:"NOT"},t.defaults({lang_code:"en"}),t}));
//# sourceMappingURL=/sm/00cca53f01bba687b9b4aec94f9b55111c0c592becc3d6b526c533454d6f75b3.map