!function(){var n={dependencyControls:{},init:function(){var n=this;_.each(window.kirkiControlDependencies,(function(t,e){var i=wp.customize.control(e);i&&(t=n.addSettingLink(t),wp.customize.control(e).params.required=t,n.showKirkiControl(i))})),_.each(n.dependencyControls,(function(t,e){_.each(t.childrens,(function(e){wp.customize(t.settingLink,(function(t){wp.customize.control(e,(function(i){var r,o;o=function(){return n.showKirkiControl(wp.customize.control(e))},(r=function(){i.active.set(o())})(),t.bind(r),i.active.validate=o}))}))}))}))},getSettingLink:function(n){var t=document.querySelector('[data-kirki-setting="'+n+'"]'),e=n;return t&&n!==t.dataset.kirkiSettingLink&&(e=t.dataset.kirkiSettingLink),e},addSettingLink:function(n){var t=this;return n.forEach((function(e,i){e.setting?n[i].settingLink=t.getSettingLink(e.setting):e.length&&(n[i]=t.addSettingLink(n[i]))})),n},showKirkiControl:function(n){var t,e=!0;if(_.isString(n)&&(n=wp.customize.control(n)),void 0===n||n.params&&_.isEmpty(n.params.required))return!0;for(t=0;t<n.params.required.length;t++)this.checkCondition(n.params.required[t],n,"AND")||(e=!1);return e},checkCondition:function(n,t,e){var i,r,o,s=this,c="AND"===e?"OR":"AND";if(void 0!==n[0]&&void 0===n.setting){for(i=[],o=0;o<n.length;o++)i.push(s.checkCondition(n[o],t,c));return"OR"===c?-1!==i.indexOf(!0):-1===i.indexOf(!1)}return void 0===wp.customize.control(n.setting)||(s.dependencyControls[n.setting]||(s.dependencyControls[n.setting]={settingLink:n.settingLink,childrens:[]}),s.dependencyControls[n.setting].childrens.includes(t.id)||s.dependencyControls[n.setting].childrens.push(t.id),n.settingLink||(console.log(s.dependencyControls),console.log("--------")),r=wp.customize(n.settingLink).get(),wp.customize.control(n.setting).setting&&(r=wp.customize.control(n.setting).setting._value),s.evaluate(n.value,r,n.operator,n.choice))},evaluate:function(n,t,e,i){var r=!1;if(i&&"object"==typeof t&&(t=t[i]),"==="===e)return n===t;if("=="===e||"="===e||"equals"===e||"equal"===e)return n==t;if("!=="===e)return n!==t;if("!="===e||"not equal"===e)return n!=t;if(">="===e||"greater or equal"===e||"equal or greater"===e)return t>=n;if("<="===e||"smaller or equal"===e||"equal or smaller"===e)return t<=n;if(">"===e||"greater"===e)return t>n;if("<"===e||"smaller"===e)return t<n;if("contains"===e||"in"===e){if(_.isArray(n)&&_.isArray(t))return _.each(t,(function(t){if(n.includes(t))return r=!0,!1})),r;if(_.isArray(t))return _.each(t,(function(t){t==n&&(r=!0)})),r;if(_.isObject(t))return _.isUndefined(t[n])||(r=!0),_.each(t,(function(t){n===t&&(r=!0)})),r;if(_.isString(t))return _.isString(n)?-1<n.indexOf(t)&&-1<t.indexOf(n):-1<n.indexOf(t)}return"does not contain"===e||"not in"===e?!this.evaluate(n,t,"contains",i):n==t}};jQuery(document).ready((function(){n.init()}))}();
//# sourceMappingURL=control.js.map
