window.awbStudioPreview={onReady:function(){var e=this;this.colorPalette=this.getColorPallete(),this.typoSets=this.getTypoSets(),this.invertedColorPaletter=this.getInvertedColorPalette(this.colorPalette),jQuery("body").on("change",'.awb-import-style input[name="overwrite-type"], .awb-import-inversion input[name="invert"]',function(t){t.preventDefault(),e.triggerPreviewChanges()}),jQuery(window).on("awb-studio-update-preview",function(t){t.preventDefault(),e.triggerPreviewChanges()}),jQuery(window).on("awb-studio-update-palettes",function(t){t.preventDefault(),e.colorPalette=e.getColorPallete(),e.typoSets=e.getTypoSets(),e.invertedColorPaletter=e.getInvertedColorPalette(e.colorPalette)})},getColorPallete:function(){var e=jQuery("#awb-global-colors").html();return void 0!==window.awbSetupWizard&&"object"==typeof window.awbSetupWizard.colors?this.getSetupWizardColors():void 0!==e&&e.length?(e=this.cleanData(e),e=this.ConvertToKeyValuePair(e)):{}},getSetupWizardColors:function(){var e,t,o={};for(e=0;e<=Object.keys(window.awbSetupWizard.colors).length;e++)void 0!==window.awbSetupWizard.colors["color"+e]&&(t=jQuery.Color(window.awbSetupWizard.colors["color"+e].color),o["--awb-color"+e]=window.awbSetupWizard.colors["color"+e].color,o["--awb-color"+e+"-h"]=t.hue(),o["--awb-color"+e+"-s"]=100*t.saturation()+"%",o["--awb-color"+e+"-l"]=100*t.lightness()+"%",o["--awb-color"+e+"-a"]=100*t.alpha()+"%");return o},getTypoSets:function(){var e,t,o,a=jQuery("#awb-global-typography").html(),r=jQuery(".awb-import-options").attr("data-awb-headings-typographies");if(void 0!==window.awbSetupWizard&&"object"==typeof window.awbSetupWizard.activeTypoSetData)return this.getSetupWizardTypography();if(void 0!==a&&a.length){if(a=this.cleanData(a),a=this.ConvertToKeyValuePair(a),r)for(e in r=JSON.parse(r))if("object"==typeof r[e])for(t in r[e])(o=r[e][t])&&(a["--"+e+"-"+t]=o);return a}},getSetupWizardTypography:function(){var e,t=jQuery("#pyre_sizing_type").val(),o=parseFloat(jQuery('input[name="base_size"]').val()),a={},r=["font-family","font-size","font-weight","font-style","line-height","letter-spacing","text-transform"];for(void 0!==t&&""!==t||(t=1.33),void 0!==o&&""!==o||(o=16),jQuery.each({small:"--awb-typography5",body:"--awb-typography4",lead:"--awb-typography3",subheadings:"--awb-typography2",headings:"--awb-typography1"},function(e,i){r.forEach(function(r){var n,l=r.replace("-","_");void 0!==window.awbSetupWizard.activeTypoSetData[e]&&(n=window.awbSetupWizard.activeTypoSetData[e][l],"font_size"===l&&("body"===e||"lead"===e?n=parseFloat(o).toFixed(2)+"px":"small"===e?n=parseFloat(.8125*o).toFixed(2)+"px":"subheadings"===e?n=parseFloat(1.5*o).toFixed(2)+"px":"headings"===e&&(n=parseFloat(o*Math.pow(t,5)).toFixed(2)+"px")),a[i+"-"+r]=n)})}),e=1;6>=e;e++)a["--h"+e+"_typography-font-size"]=(o*Math.pow(t,6-e)).toFixed(2)+"px";return a},cleanData:function(e){return e=(e=(e=e.replace(/^\s*\:root\s*{\s*/,"")).replace(/\s*}\s*$/,"")).split(";")},ConvertToKeyValuePair:function(e){var t={},o=["--primary_color"];for(let a=0;a<=e.length;a++){let r=e[a];"string"==typeof r&&""!==r&&(r=r.split(":"),this.valueExists(r[0])&&this.valueExists(r[1])&&!o.includes(r[0])&&(t[r[0]]=r[1]))}return t},getInvertedColorPalette:function(e){var t,o,a={};for(t=1,o=8;8>=t;t++,o--)void 0!==e["--awb-color"+o]&&(a["--awb-color"+t]=e["--awb-color"+o],a["--awb-color"+t+"-h"]=e["--awb-color"+o+"-h"],a["--awb-color"+t+"-s"]=e["--awb-color"+o+"-s"],a["--awb-color"+t+"-l"]=e["--awb-color"+o+"-l"],a["--awb-color"+t+"-a"]=e["--awb-color"+o+"-a"]);return a},valueExists:function(e){return void 0!==e&&""!==e},triggerPreviewChanges:function(){var e=jQuery('.awb-import-options input[name="overwrite-type"]:checked').val(),t=jQuery('.awb-import-options input[name="invert"]:checked').val(),o={color_palette:{},typo_sets:{},shouldInvert:t};"inherit"===e&&(o.color_palette="do-invert"===t?this.invertedColorPaletter:this.colorPalette,o.typo_sets=this.typoSets),"undefined"!=typeof awbStudio?document.getElementsByTagName("iframe")[0].contentWindow.postMessage(o,"*"):jQuery(".awb-studio-preview-frame")[0].contentWindow.postMessage(o,"*")}},function(e){"use strict";e(document).ready(function(){e(document).ready(function(){window.awbStudioPreview.onReady()})})}(jQuery);