jQuery(document).ready(function(){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(){if("undefined"==typeof hot)return!0;var e=hot.getSettings().contextMenu;function r(){var e,o;if("object"==typeof vgse_editor_settings.columnsBackgroundColors){for(var r in vgse_editor_settings.columnsBackgroundColors)Object.hasOwnProperty.call(vgse_editor_settings.columnsBackgroundColors,r)&&(e="bg-"+(r=vgseStripHtml(vgse_editor_settings.columnsBackgroundColors[r])).replace("#",""),jQuery("head style."+e).length||(o=(o=r).replace("#",""),170<(299*parseInt(o.substr(0,2),16)+587*parseInt(o.substr(2,2),16)+114*parseInt(o.substr(4,2),16))/1e3?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,r)):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,r))));jQuery.isEmptyObject(vgse_editor_settings.columnsBackgroundColors)&&jQuery("head style.wpse-column-backgrounds").remove(),hot.render()}}void 0===e.items&&(e.items={}),e.items.wpse_column_background={name:vgse_editor_settings.texts.change_background_color,callback:function(e,o,r){var s=[],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,t=[],n=o;n<=r;n++)t.push(n);t.forEach(function(e){var o=hot.colToProp(e);o&&(s.push(o),a.push(e))})}),($colorInput=jQuery(".wpse-column-background-selector-wrapper input")).data("columnKeys",jQuery.unique(s)).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)}),r())},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"),r()}),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")}),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()}),r()});