function vgseIsLightColor(e){e=e.replace("#","");return 170<(299*parseInt(e.substr(0,2),16)+587*parseInt(e.substr(2,2),16)+114*parseInt(e.substr(4,2),16))/1e3}function vgseRenderBackgroundCss(){var e;if("object"==typeof vgse_editor_settings.columnsBackgroundColors){for(var o in vgse_editor_settings.columnsBackgroundColors)Object.hasOwnProperty.call(vgse_editor_settings.columnsBackgroundColors,o)&&(e="bg-"+(o=vgseStripHtml(vgse_editor_settings.columnsBackgroundColors[o])).replace("#",""),jQuery("head style."+e).length||(vgseIsLightColor(o)?jQuery("head").append('<style class="wpse-column-backgrounds className">#vgse-wrapper.highlightCurrentRow .currentRow.className, #vgse-wrapper .className { background-color: colorCode !important; color: #444 !important;}#vgse-wrapper .className a {color: #222 !important;}</style>'.replace(/className/g,e).replace(/colorCode/g,o)):jQuery("head").append('<style class="wpse-column-backgrounds className">#vgse-wrapper.highlightCurrentRow .currentRow.className, #vgse-wrapper .className { background-color: colorCode !important; color: white !important;}</style>'.replace(/className/g,e).replace(/colorCode/g,o))));jQuery.isEmptyObject(vgse_editor_settings.columnsBackgroundColors)&&jQuery("head style.wpse-column-backgrounds").remove(),hot.render()}}jQuery(document).ready(function(){if(!vgse_editor_settings.is_administrator)return!0;jQuery(".modal-columns-visibility .field-type select").trigger("change"),jQuery("body").on("change",'.modal-columns-visibility .column-settings select, .modal-columns-visibility .column-settings input, .modal-columns-visibility .column-settings textarea, .modal-columns-visibility input[name="wpse_group_name"]',function(){Alpine.$data(document.querySelector('[x-data="vgseColumnsManager"]')).saveChangesInServer=!0,vgse_editor_settings.is_editor_page&&jQuery('.modal-columns-visibility input[name="wpse_auto_reload_after_saving"]').val(1)})}),jQuery(document).ready(function(){var e;return"undefined"==typeof hot||(vgseRenderBackgroundCss(),!vgse_editor_settings.is_administrator)||(void 0===(e=hot.getSettings().contextMenu).items&&(e.items={}),e.items.wpse_column_background={name:vgse_editor_settings.texts.change_background_color,callback:function(e,o,r){var n=[],a=[];o.forEach(function(e){for(var o=(e.start.col>e.end.col?e.end:e.start).col,r=(e.start.col>e.end.col?e.start:e.end).col,s=[],t=o;t<=r;t++)s.push(t);s.forEach(function(e){var o=hot.colToProp(e);o&&(n.push(o),a.push(e))})}),($colorInput=jQuery(".wpse-column-background-selector-wrapper input")).data("columnKeys",jQuery.unique(n)).data("columnIndexes",jQuery.unique(a)),$colorInput.val("#ffffff"),$colorInput.data("backgroundsBeforeOpening",jQuery.extend(!0,{},vgse_editor_settings.columnsBackgroundColors||{})),jQuery(".wpse-column-background-selector-wrapper").show()}},hot.updateSettings({contextMenu:e}),jQuery("body").on("change input",".wpse-column-background-selector-wrapper input",_throttle(function(e){e.preventDefault();var e=jQuery(this),o=e.val().toLowerCase();"object"!=typeof vgse_editor_settings.columnsBackgroundColors&&(vgse_editor_settings.columnsBackgroundColors={}),e.data("columnKeys")&&(e.data("columnKeys").forEach(function(e){"#ffffff"===o&&"string"==typeof vgse_editor_settings.columnsBackgroundColors[e]?delete vgse_editor_settings.columnsBackgroundColors[e]:"#ffffff"!==o&&(vgse_editor_settings.columnsBackgroundColors[e]=o)}),vgseRenderBackgroundCss())},500,{leading:!1,trailing:!0})),jQuery("body").on("click",".wpse-column-background-selector-wrapper .cancel-background-change",function(e){e.preventDefault();e=jQuery(this).parent().find("input");jQuery(".wpse-column-background-selector-wrapper").hide(),vgse_editor_settings.columnsBackgroundColors=e.data("backgroundsBeforeOpening"),vgseRenderBackgroundCss()}),jQuery("body").on("click",".wpse-column-background-selector-wrapper .clear-background-color",function(e){e.preventDefault();e=jQuery(this).parent().find("input");e.val("#ffffff"),e.trigger("change")}),void jQuery("body").on("click",".wpse-column-background-selector-wrapper .save-background-color",function(e){e.preventDefault(),jQuery.post(vgse_global_data.ajax_url,{action:"vgse_save_column_backgrounds",post_type:vgse_editor_settings.post_type,backgrounds:vgse_editor_settings.columnsBackgroundColors,nonce:vgse_editor_settings.nonce}),jQuery(".wpse-column-background-selector-wrapper").hide()}))});