!function(){"use strict";function e(e,s){(null==s||s>e.length)&&(s=e.length);for(var t=0,o=Array(s);t<s;t++)o[t]=e[t];return o}function s(s,t){return function(e){if(Array.isArray(e))return e}(s)||function(e,s){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var o,r,a,n,c=[],l=!0,i=!1;try{if(a=(t=t.call(e)).next,0===s){if(Object(t)!==t)return;l=!1}else for(;!(l=(o=a.call(t)).done)&&(c.push(o.value),c.length!==s);l=!0);}catch(e){i=!0,r=e}finally{try{if(!l&&null!=t.return&&(n=t.return(),Object(n)!==n))return}finally{if(i)throw r}}return c}}(s,t)||function(s,t){if(s){if("string"==typeof s)return e(s,t);var o={}.toString.call(s).slice(8,-1);return"Object"===o&&s.constructor&&(o=s.constructor.name),"Map"===o||"Set"===o?Array.from(s):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?e(s,t):void 0}}(s,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}!function(e){var t={ajaxurl:cosmoswpCustomizerData.ajaxurl,nonce:cosmoswpCustomizerData.wpnonce,controlGroups:cosmoswpCustomizerData.controlGroups,elements:{}};Object.keys(cosmoswpCustomizerData.elements).forEach(function(s){t.elements[s]=e(cosmoswpCustomizerData.elements[s])});var o=function(s,o){var a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=0,c=a.updateCss,l=void 0!==c&&c,i=a.updateFonts,u=void 0!==i&&i,p=a.updateClasses,d=void 0!==p&&p;return function(a){wp.customize(a,function(c){c.bind(function(){e.ajax({type:"POST",url:t.ajaxurl,data:{action:s,control_id:a,security:t.nonce},beforeSend:function(){n++,o.addClass("customize-partial-refreshing")}}).done(function(e){u&&e.data.google_font_url&&t.elements.googleFonts.attr("href",e.data.google_font_url),d&&e.data&&r(e.data),l&&e.data&&t.elements.dynamicCSS.html(e.data.dynamic_css||e.data)}).fail(function(e,s,t){console.log("AJAX Error:",s,t)}).always(function(){0===--n&&o.removeClass("customize-partial-refreshing")})})})}},r=function(e){e.body_class&&t.elements.body.removeClass().addClass(e.body_class),e.cosmoswp_main_wrap_classes&&t.elements.mainWrap.removeClass().addClass(e.cosmoswp_main_wrap_classes),e.cosmoswp_header_wrap_classes&&t.elements.headerWrap.removeClass().addClass(e.cosmoswp_header_wrap_classes),e.cosmoswp_vertical_header_main_wrap_classes&&t.elements.verticalHeader.removeClass().addClass(e.cosmoswp_vertical_header_main_wrap_classes)},a=o("cosmoswp_head_ajax_dynamic_css",t.elements.body,{updateCss:!0}),n=o("general_partial_ajax_typography",t.elements.body,{updateCss:!0,updateFonts:!0}),c=o("general_header_multiple_class_refresh",t.elements.headerWrap,{updateClasses:!0});t.controlGroups.css_refresh&&t.controlGroups.css_refresh.forEach(a),t.controlGroups.typography_refresh&&t.controlGroups.typography_refresh.forEach(n),t.controlGroups.header_class_refresh&&t.controlGroups.header_class_refresh.forEach(c),t.controlGroups.class_toggles&&Object.entries(t.controlGroups.class_toggles).forEach(function(o){var r=s(o,2),a=r[0],n=r[1];wp.customize(a,function(s){s.bind(function(s){("body"===n.target?t.elements.body:e(n.target)).removeClass(n.classes.join(" ")).addClass(s)})})}),t.controlGroups.text_updates&&Object.entries(t.controlGroups.text_updates).forEach(function(t){var o=s(t,2),r=o[0],a=o[1];wp.customize(r,function(s){s.bind(function(s){return e(a).text(s)})})}),t.controlGroups.special_cases&&Object.entries(t.controlGroups.special_cases).forEach(function(o){var r=s(o,2),a=r[0],n=r[1];if("footer-sidebar-*-content-align"===a)for(var c=function(s){var t="footer-sidebar-".concat(s,"-content-align");wp.customize(t,function(t){t.bind(function(t){e(".cwp-footer-sidebar-".concat(s)).removeClass("cwp-text-left cwp-text-center cwp-text-right").addClass(t)})})},l=1;l<=n.count;l++)c(l);else"toggle_class"===n.type?wp.customize(a,function(s){s.bind(function(s){e(n.selector).toggleClass(n.class,s===n.value)})}):"menu_sidebar"===n.type&&wp.customize(a,function(s){s.bind(function(s){var o=e(".cwp-header-menu-sidebar"),r=t.elements.menuWrapper;o.removeClass("cwp-left-menu-slide cwp-right-menu-slide cwp-left-menu-push cwp-right-menu-push").addClass(s),r.removeClass("cwp-left-push cwp-right-push"),"cwp-left-menu-push"===s?r.addClass("cwp-left-push"):"cwp-right-menu-push"===s&&r.addClass("cwp-right-push")})})}),t.controlGroups.css_refresh||console.log("cosmoswpCustomizerData.controlGroups.css_refresh is not defined"),t.controlGroups.typography_refresh||console.log("cosmoswpCustomizerData.controlGroups.typography_refresh is not defined")}(jQuery),jQuery,wp.customize.bind("preview-ready",function(){wp.customize.selectiveRefresh.bind("partial-content-rendered",function(e){"cwp_popupmodal"===e.partial.id&&document.body.classList.remove("open-popup")})})}();