!function(){"use strict";var e=window.wp.i18n,t=window.wp.hooks,s=window.wp.url;const o=e=>"#"===e[0]?document.getElementById(e.slice(1)):document.querySelectorAll(e);window.tp=window.tp||{},tp.made_changes=!1,tp.helpers=tp.helpers||{},tp.callbacks=tp.callbacks||{},tp.helpers.selection=tp.helpers.selection||{rows:[0],columns:[0]},tp.helpers.unsaved_changes=tp.helpers.unsaved_changes||{},tp.helpers.unsaved_changes.unload_dialog=function(e){e.preventDefault(),e.returnValue=""},tp.helpers.unsaved_changes.set=function(){tp.made_changes||(tp.made_changes=!0,window.addEventListener("beforeunload",tp.helpers.unsaved_changes.unload_dialog))},tp.helpers.unsaved_changes.unset=function(){tp.made_changes=!1,window.removeEventListener("beforeunload",tp.helpers.unsaved_changes.unload_dialog)},tp.helpers.options=tp.helpers.options||{},tp.helpers.options.load=function(){Object.keys(tp.table.options).forEach((function(e){if("last_editor"===e)return;if(""===(e=(0,t.applyFilters)("tablepress.optionsLoad",e)))return;let s=o(`#option-${e}`);s||(s=o(`#option-${e}-${tp.table.options[e]}`)),s&&(s instanceof HTMLInputElement&&"checkbox"===s.type?s.checked=tp.table.options[e]:s instanceof HTMLInputElement&&"radio"===s.type?s.checked=!0:s.value=tp.table.options[e])})),tp.table.options.use_datatables&&tp.helpers.editor.has_merged_cells()&&(tp.table.options.use_datatables=!1,o("#option-use_datatables").checked=!1),tp.helpers.options.check_dependencies()},tp.helpers.options.change=function(s){if(!s.target)return;const l=s.target.name||"";if(""===l)return;const n=s.target instanceof HTMLInputElement&&"checkbox"===s.target.type?"checked":"value";tp.table.options[l]=s.target[n],s.target instanceof HTMLInputElement&&"number"===s.target.type&&(tp.table.options[l]=parseInt(tp.table.options[l],10)),"use_datatables"===l&&tp.table.options.use_datatables&&tp.helpers.editor.has_merged_cells()&&(tp.table.options.use_datatables=!1,o("#option-use_datatables").checked=!1,window.alert((0,e.__)("You can not enable the Table Features for Site Visitors, because your table contains combined/merged cells.","tablepress"))),(0,t.doAction)("tablepress.optionsChange",l,n,s),tp.helpers.options.check_dependencies(),tp.helpers.unsaved_changes.set(),tp.editor.updateTable()},tp.helpers.options.check_dependencies=function(){o("#option-use_datatables").disabled=!tp.table.options.table_head,o("#notice-datatables-head-row").style.display=tp.table.options.table_head?"none":"block",o("#option-print_name_position").disabled=!tp.table.options.print_name,o("#option-print_description_position").disabled=!tp.table.options.print_description;const e=tp.table.options.use_datatables&&tp.table.options.table_head;o("#tablepress_edit-datatables-features").querySelectorAll(":scope input:not(#option-use_datatables), :scope textarea").forEach((t=>t.disabled=!e));const s=e&&tp.table.options.datatables_paginate;o("#option-datatables_lengthchange").disabled=!s,o("#option-datatables_paginate_entries").disabled=!s,(0,t.doAction)("tablepress.optionsCheckDependencies")},tp.helpers.options.validate_fields=function(){if(tp.table.options.datatables_paginate&&(isNaN(tp.table.options.datatables_paginate_entries)||tp.table.options.datatables_paginate_entries<1||tp.table.options.datatables_paginate_entries>9999)){window.alert((0,e.sprintf)((0,e.__)("The entered value in the “%1$s” field is invalid.","tablepress"),(0,e.__)("Pagination Entries","tablepress")));const t=o("#option-datatables_paginate_entries");return t.focus(),t.select(),!1}if(/[^A-Za-z0-9- _:]/.test(tp.table.options.extra_css_classes)){window.alert((0,e.sprintf)((0,e.__)("The entered value in the “%1$s” field is invalid.","tablepress"),(0,e.__)("Extra CSS Classes","tablepress")));const t=o("#option-extra_css_classes");return t.focus(),t.select(),!1}return(0,t.applyFilters)("tablepress.optionsValidateFields",!0)},tp.helpers.visibility=tp.helpers.visibility||{},tp.helpers.visibility.load=function(){const e=tp.table.visibility.rows.length,t=tp.table.visibility.columns.length,s={};for(let o=0;otp.table.visibility[e][s]===t))},tp.helpers.move_allowed=function(e,t){let s=tp.helpers.selection[e][0],o=0;return"down"!==t&&"right"!==t&&"bottom"!==t&&"last"!==t||(s=tp.helpers.selection[e][tp.helpers.selection[e].length-1],o="rows"===e?tp.editor.options.data.length-1:tp.editor.options.columns.length-1),o!==s},tp.helpers.cell_merge_allowed=function(t,s={}){const o="alert"===t;if(tp.table.options.table_head&&tp.table.options.use_datatables)return s.text=(0,e.sprintf)((0,e.__)("You can not combine these cells, because the “%1$s” checkbox in the “%2$s” section is checked.","tablepress"),(0,e.__)("Enable Visitor Features","tablepress"),(0,e.__)("Table Features for Site Visitors","tablepress"))+" "+(0,e.__)("The Table Features for Site Visitors are not compatible with merged cells.","tablepress"),o&&window.alert(s.text),!1;const l=tp.helpers.selection.rows[0],n=tp.helpers.selection.rows[tp.helpers.selection.rows.length-1];if(tp.table.options.table_head&&0===l&&n>0)return s.text=(0,e.sprintf)((0,e.__)("You can not combine these cells, because the “%1$s” checkbox in the “%2$s” section is checked.","tablepress"),(0,e.__)("Table Head Row","tablepress"),(0,e.__)("Table Options","tablepress")),o&&window.alert(s.text),!1;const a=tp.editor.options.data.length-1;return!(tp.table.options.table_foot&&a===n&&l{const s=/(^([+\-]?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?(?=\D|\s|$))|^0x[\da-fA-F]+$|\d+)/g,o=/^\s+|\s+$/g,l=/\s+/g,n=/^0x[0-9a-f]+$/i,a=/^0/,i=e.replace(o,"")||"",r=t.replace(o,"")||"",c=i.replace(s,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),p=r.replace(s,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),d=parseInt(i.match(n),16)||1!==c.length&&Date.parse(i),b=parseInt(r.match(n),16)||d&&r.match(/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/)&&Date.parse(r)||null,u=(e,t)=>(!e.match(a)||1===t)&&parseFloat(e)||e.replace(l," ").replace(o,"")||0;if(b){if(db)return 1}for(let e=0,t=c.length,s=p.length,o=Math.max(t,s);el)return 1}return 0})(t[1],s[1])}},tp.callbacks.editor=tp.callbacks.editor||{},tp.callbacks.editor.onselection=function(e,t,s,o,l){tp.helpers.selection={rows:[],columns:[]};for(let e=s;e<=l;e++)tp.helpers.selection.rows.push(e);for(let e=t;e<=o;e++)tp.helpers.selection.columns.push(e)},tp.callbacks.editor.onupdatetable=function(e,t,s,o,l,n,a){const i=e.jspreadsheet.options.meta[a];if(t.classList.toggle("column-hidden",Boolean(i?.column_hidden)),0===s&&(t.parentNode.classList.toggle("row-hidden",Boolean(i?.row_hidden)),t.parentNode.classList.remove("head-row","foot-row"),o===e.jspreadsheet.rows.length-1)){const t=e.jspreadsheet.content.querySelectorAll(":scope tbody tr:not(.row-hidden)");1`),o(".button-preview").forEach((e=>e.classList.add("disabled"))),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,s.buildQueryString)(n)}).then((e=>{if(!e.ok)throw new Error(`There was a problem with the server, HTTP response code ${e.status} (${e.statusText}).`);return e.json()})).then((e=>{if(null==e||"-1"===e||void 0===e.success)throw new Error("The JSON data returned from the server is unclear or incomplete.");if(!0!==e.success)throw new Error("The preview could not be loaded.");tp.callbacks.table_preview.success(e)})).catch((e=>tp.callbacks.table_preview.error(e.message))).finally((()=>{o("#spinner-table-preview").remove(),o(".button-preview").forEach((e=>e.classList.remove("disabled"))),document.body.classList.remove("wait")}))},tp.callbacks.table_preview.success=function(e){const t=o("#table-preview-iframe");t.src="",t.srcdoc=`${e.head_html}${e.body_html}`,tp.callbacks.table_preview.$dialog.wpdialog("open")},tp.callbacks.table_preview.error=function(t){t=(0,e.__)("Attention: Unfortunately, an error occurred.","tablepress")+" "+t;const s=`show-preview-${Date.now()}`;o("#spinner-table-preview").parentNode.insertAdjacentHTML("afterend",``);const l=o(`#${s}`);l.offsetWidth,l.style.opacity=0,l.addEventListener("transitionend",(()=>l.remove()))},tp.callbacks.save_changes={},tp.callbacks.save_changes.process=function(t){if(!tp.helpers.options.validate_fields())return;tp.helpers.visibility.update();const l={action:"tablepress_save_table",_ajax_nonce:tp.nonces.edit_table,tablepress:{id:tp.table.id,new_id:tp.table.new_id,name:o("#table-name").value,description:o("#table-description").value,data:JSON.stringify(tp.editor.options.data),options:JSON.stringify(tp.table.options),visibility:JSON.stringify(tp.table.visibility),number:{rows:tp.editor.options.data.length,columns:tp.editor.options.columns.length}}};t.target.parentNode.insertAdjacentHTML("beforeend",``),o(".button-save-changes").forEach((e=>e.disabled=!0)),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,s.buildQueryString)(l)}).then((e=>{if(!e.ok)throw new Error(`There was a problem with the server, HTTP response code ${e.status} (${e.statusText}).`);return e.json()})).then((t=>{if(null==t||"-1"===t||void 0===t.success)throw new Error("The JSON data returned from the server is unclear or incomplete.");if(!0!==t.success){const s=(0,e.__)("These errors were encountered:","tablepress"),o=t.error_details?`
${s}
${t.error_details}
`:"";throw new Error(`The table could not be saved to the database properly.${o}`)}tp.callbacks.save_changes.success(t)})).catch((e=>tp.callbacks.save_changes.error(e.message))).finally((()=>{o("#spinner-save-changes").remove(),o(".button-save-changes").forEach((e=>e.disabled=!1)),document.body.classList.remove("wait")}))},tp.callbacks.save_changes.success=function(t){tp.table.id!==t.table_id&&window?.history?.pushState&&window.history.pushState("","",window.location.href.replace(/table_id=[0-9a-zA-Z-_]+/gi,`table_id=${t.table_id}`)),tp.table.id=t.table_id,tp.table.new_id=t.table_id,o("#table-id").value=t.table_id;const s=o("#table-information-shortcode");s&&(s.value=`[${tp.table.shortcode} id=${t.table_id} /]`),tp.nonces.edit_table=t.new_edit_nonce,tp.nonces.preview_table=t.new_preview_nonce,tp.nonces.copy_table=t.new_copy_nonce,tp.nonces.delete_table=t.new_delete_nonce,["preview","copy","delete"].forEach((e=>{o(`.button-${e}`).forEach((s=>{s.href=s.href.replace(/item=[a-zA-Z0-9_-]+/g,`item=${t.table_id}`).replace(/&_wpnonce=[a-z0-9]+/gi,`&_wpnonce=${t[`new_${e}_nonce`]}`)}))})),o(".button-export").forEach((e=>{e.href=e.href.replace(/table_id=[a-zA-Z0-9_-]+/g,`table_id=${t.table_id}`)})),o("#last-modified").textContent=t.last_modified,o("#last-editor").textContent=t.last_editor,tp.helpers.unsaved_changes.unset();const l={};if(l.success_save=(0,e.__)("The table was saved successfully.","tablepress"),l.success_save_success_id_change=l.success_save+" "+(0,e.__)("The table ID was changed.","tablepress"),l.success_save_error_id_change=l.success_save+" "+(0,e.__)("The table ID could not be changed, probably because the new ID is already in use!","tablepress"),"success_save_error_id_change"===t.message&&t.error_details){const s=(0,e.__)("These errors were encountered:","tablepress");l.success_save_error_id_change+=`
${s}
${t.error_details}
`}const n=t.message.includes("error")?"error":"success";tp.callbacks.save_changes.after_saving_notice(n,l[t.message])},tp.callbacks.save_changes.error=function(t){t=(0,e.__)("Attention: Unfortunately, an error occurred.","tablepress")+" "+t,tp.callbacks.save_changes.after_saving_notice("error",t)},tp.callbacks.save_changes.after_saving_notice=function(e,t){const s=`save-changes-${Date.now()}`;o("#spinner-save-changes").parentNode.insertAdjacentHTML("afterend",`
`);const l=o(`#${s}`);l.offsetWidth,l.style.opacity=0,l.addEventListener("transitionend",(()=>l.remove()))},tp.callbacks.screen_options={},tp.callbacks.screen_options.update=function(e){if(e.target)return"table_editor_line_clamp"===e.target.id?(tp.editor.el.style.setProperty("--table-editor-line-clamp",parseInt(e.target.value,10)),void tp.editor.updateCornerPosition()):"table_editor_column_width"===e.target.id?(tp.screen_options.table_editor_column_width=parseInt(e.target.value,10),tp.screen_options.table_editor_column_width=Math.max(tp.screen_options.table_editor_column_width,30),tp.screen_options.table_editor_column_width=Math.min(tp.screen_options.table_editor_column_width,9999),tp.editor.colgroup.forEach((e=>e.setAttribute("width",tp.screen_options.table_editor_column_width))),void tp.editor.updateCornerPosition()):void 0},tp.callbacks.screen_options.set_was_changed=function(e){e.target&&(e.target.was_changed=!0)},tp.callbacks.screen_options.save=function(t){if(!t.target)return;if(!t.target.was_changed)return;t.target.was_changed=!1;const l={action:"tablepress_save_screen_options",_ajax_nonce:tp.nonces.screen_options,tablepress:{[t.target.id]:parseInt(t.target.value,10)}};t.target.parentNode.insertAdjacentHTML("beforeend",``),document.body.classList.add("wait"),fetch(ajaxurl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:(0,s.buildQueryString)(l)}).finally((()=>{o("#spinner-save-changes").remove(),document.body.classList.remove("wait")}))},tp.callbacks.table_id=tp.callbacks.table_id||{},tp.callbacks.table_id.sanitize=function(){this.value=this.value.replace(/[^0-9a-zA-Z-_]/g,"")},tp.callbacks.table_id.change=function(){if(""===this.value||"0"===this.value)return window.alert((0,e.__)("This table ID is invalid. Please enter a different table ID.","tablepress")),this.value=tp.table.new_id,this.focus(),void this.select();if(!window.confirm((0,e.__)("Do you really want to change the Table ID? All blocks and Shortcodes for this table in your posts and pages will have to be adjusted!","tablepress")))return void(this.value=tp.table.new_id);tp.table.new_id=this.value;const t=o("#table-information-shortcode");t&&(t.value=`[${tp.table.shortcode} id=${tp.table.new_id} /]`,t.focus(),t.select()),tp.helpers.unsaved_changes.set()},tp.callbacks.insert_duplicate=function(e,t,s="before"){const o="rows"===t,l=o?tp.editor.insertRow:tp.editor.insertColumn,n=o?tp.editor.getRowData:tp.editor.getColumnData,a="duplicate"===e;tp.editor.options[o?"oninsertrow":"oninsertcolumn"]=tp.callbacks.editor.oninsertroc.bind(null,t,e),tp.helpers.selection[t].forEach((function(e,t){const o=e+t,i=a?n(o):1;l(i,o,"before"===s)})),tp.helpers.unsaved_changes.set();const i=tp.helpers.selection[t].length;i>1&&tp.editor.updateSelectionFromCoords(tp.helpers.selection.columns[0],tp.helpers.selection.rows[0],o?tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]:tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]+i,o?tp.helpers.selection.rows[tp.helpers.selection.rows.length-1]+i:tp.helpers.selection.rows[tp.helpers.selection.rows.length-1])},tp.callbacks.remove=function(e){const t="rows"===e,s=t?tp.editor.options.columns.length:tp.editor.options.data.length,o=t?tp.editor.options.data.length-1:tp.editor.options.columns.length-1;if(tp.editor.options.meta&&tp.helpers.selection[e].forEach((function(e){for(let o=0;on(e,e+l))),tp.helpers.unsaved_changes.set(),tp.editor.updateSelectionFromCoords(s?tp.helpers.selection.columns[0]:tp.helpers.selection.columns[0]+l,s?tp.helpers.selection.rows[0]+l:tp.helpers.selection.rows[0],s?tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]:tp.helpers.selection.columns[tp.helpers.selection.columns.length-1]+l,s?tp.helpers.selection.rows[tp.helpers.selection.rows.length-1]+l:tp.helpers.selection.rows[tp.helpers.selection.rows.length-1])},tp.callbacks.sort=function(e){tp.editor.orderBy(tp.helpers.selection.columns[0],"desc"===e)},tp.callbacks.hide_unhide=function(e,t){const s="rows"===t,o=s?"row_hidden":"column_hidden",l=s?tp.editor.options.columns.length:tp.editor.options.data.length,n="hide"===e,a={};tp.helpers.selection[t].forEach((function(e){for(let t=0;t{const s=tp.editor.options.data.length,o=tp.editor.options.columns.length,l=tp.helpers.selection.rows.length,n=tp.helpers.selection.columns.length,a=window?.navigator?.platform?.includes("Mac"),i=a?(0,e._x)("⌘","keyboard shortcut modifier key on a Mac keyboard","tablepress"):(0,e._x)("Ctrl+","keyboard shortcut modifier key on a non-Mac keyboard","tablepress"),r=a?(0,e._x)("⌥","keyboard shortcut option key on a Mac keyboard","tablepress"):(0,e._x)("Alt+","keyboard shortcut Alt key on a non-Mac keyboard","tablepress"),c={text:""};return tp.helpers.visibility.update(),[{title:(0,e.__)("Undo","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sZ","keyboard shortcut for Undo","tablepress"),i),onclick:t.undo,disabled:-1===t.historyIndex},{title:(0,e.__)("Redo","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sY","keyboard shortcut for Redo","tablepress"),i),onclick:t.redo,disabled:t.historyIndex===t.history.length-1},{type:"divisor"},{title:(0,e.__)("Cut","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sX","keyboard shortcut for Cut","tablepress"),i),onclick(){if("TEXTAREA"===document.activeElement.tagName&&document.activeElement.selectionStart!==document.activeElement.selectionEnd){document.execCommand("copy");const e=document.activeElement.selectionStart;document.activeElement.value=document.activeElement.value.slice(0,document.activeElement.selectionStart)+document.activeElement.value.slice(document.activeElement.selectionEnd),document.activeElement.selectionEnd=e}else t.copy(!0),t.setValue(t.highlighted,"")}},{title:(0,e.__)("Copy","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sC","keyboard shortcut for Copy","tablepress"),i),onclick(){"TEXTAREA"===document.activeElement.tagName&&document.activeElement.selectionStart!==document.activeElement.selectionEnd?document.execCommand("copy"):t.copy(!0)}},{title:(0,e.__)("Paste","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sV","keyboard shortcut for Paste","tablepress"),i),onclick(){"TEXTAREA"===document.activeElement.tagName?window.navigator.clipboard.readText().then((e=>{if(e){const t=document.activeElement.selectionStart+e.length;document.activeElement.value=document.activeElement.value.slice(0,document.activeElement.selectionStart)+e+document.activeElement.value.slice(document.activeElement.selectionEnd),document.activeElement.selectionEnd=t}})):t.selectedCell&&window.navigator.clipboard.readText().then((e=>{e&&t.paste(t.selectedCell[0],t.selectedCell[1],e)}))},disabled:!window?.navigator?.clipboard?.readText,tooltip:window?.navigator?.clipboard?.readText?"":(0,e.__)("Your browser does not allow pasting via the context menu. Use the keyboard shortcut instead.","tablepress")},{type:"divisor"},{title:(0,e.__)("Insert Link","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sL","keyboard shortcut for Insert Link","tablepress"),i),onclick:tp.callbacks.insert_link.open_dialog.bind(null,"TEXTAREA"===document.activeElement.tagName?document.activeElement:null)},{title:(0,e.__)("Insert Image","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sI","keyboard shortcut for Insert Image","tablepress"),i),onclick:tp.callbacks.insert_image.open_dialog.bind(null,"TEXTAREA"===document.activeElement.tagName?document.activeElement:null)},{title:(0,e.__)("Advanced Editor","tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$sE","keyboard shortcut for Advanced Editor","tablepress"),i),onclick:tp.callbacks.advanced_editor.open_dialog.bind(null,"TEXTAREA"===document.activeElement.tagName?document.activeElement:null)},{type:"divisor"},{title:(0,e.__)("Duplicate …","tablepress"),submenu:[{title:(0,e._n)("Duplicate row","Duplicate rows",l,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"duplicate","rows")},{title:(0,e._n)("Duplicate column","Duplicate columns",n,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"duplicate","columns")}]},{title:(0,e.__)("Insert …","tablepress"),submenu:[{title:(0,e._n)("Insert row above","Insert rows above",l,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","rows","before")},{title:(0,e._n)("Insert row below","Insert rows below",l,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","rows","after")},{title:(0,e._n)("Insert column on the left","Insert columns on the left",n,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","columns","before")},{title:(0,e._n)("Insert column on the right","Insert columns on the right",n,"tablepress"),onclick:tp.callbacks.insert_duplicate.bind(null,"insert","columns","after")}]},{title:(0,e.__)("Append …","tablepress"),submenu:[{title:(0,e.__)("Append row","tablepress"),onclick:tp.callbacks.append.bind(null,"rows",1)},{title:(0,e.__)("Append column","tablepress"),onclick:tp.callbacks.append.bind(null,"columns",1)}]},{title:(0,e.__)("Delete …","tablepress"),submenu:[{title:(0,e._n)("Delete row","Delete rows",l,"tablepress"),onclick:tp.callbacks.remove.bind(null,"rows"),disabled:s===l,tooltip:s===l?(0,e.__)("This option is disabled.","tablepress")+" "+(0,e.__)("You can not delete all table rows!","tablepress"):""},{title:(0,e._n)("Delete column","Delete columns",n,"tablepress"),onclick:tp.callbacks.remove.bind(null,"columns"),disabled:o===n,tooltip:o===n?(0,e.__)("This option is disabled.","tablepress")+" "+(0,e.__)("You can not delete all table columns!","tablepress"):""}]},{type:"divisor"},{title:(0,e.__)("Move …","tablepress"),submenu:[{title:(0,e._n)("Move row up","Move rows up",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧↑","keyboard shortcut for Move up","tablepress"),i),onclick:tp.callbacks.move.bind(null,"up","rows"),disabled:!tp.helpers.move_allowed("rows","up")},{title:(0,e._n)("Move row down","Move rows down",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧↓","keyboard shortcut for Move down","tablepress"),i),onclick:tp.callbacks.move.bind(null,"down","rows"),disabled:!tp.helpers.move_allowed("rows","down")},{title:(0,e._n)("Move column left","Move columns left",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧←","keyboard shortcut for Move left","tablepress"),i),onclick:tp.callbacks.move.bind(null,"left","columns"),disabled:!tp.helpers.move_allowed("columns","left")},{title:(0,e._n)("Move column right","Move columns right",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s⇧→","keyboard shortcut for Move right","tablepress"),i),onclick:tp.callbacks.move.bind(null,"right","columns"),disabled:!tp.helpers.move_allowed("columns","right")},{type:"divisor"},{title:(0,e._n)("Move row to the top","Move rows to the top",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧↑","keyboard shortcut for Move to the top","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"top","rows"),disabled:!tp.helpers.move_allowed("rows","top")},{title:(0,e._n)("Move row to the bottom","Move rows to the bottom",l,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧↓","keyboard shortcut for Move to the bottom","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"bottom","rows"),disabled:!tp.helpers.move_allowed("rows","bottom")},{title:(0,e._n)("Move column to first","Move columns to first",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧←","keyboard shortcut for Move to first","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"first","columns"),disabled:!tp.helpers.move_allowed("columns","first")},{title:(0,e._n)("Move column to last","Move columns to last",n,"tablepress"),shortcut:(0,e.sprintf)((0,e._x)("%1$s%2$s⇧→","keyboard shortcut for Move to last","tablepress"),i,r),onclick:tp.callbacks.move.bind(null,"last","columns"),disabled:!tp.helpers.move_allowed("columns","last")}]},{title:(0,e.__)("Sort by column …","tablepress"),submenu:[{title:(0,e.__)("Sort by column ascending","tablepress"),onclick:tp.callbacks.sort.bind(null,"asc"),disabled:1!==n,tooltip:1!==n?(0,e.__)("This option is disabled because more than one column was selected.","tablepress"):""},{title:(0,e.__)("Sort by column descending","tablepress"),onclick:tp.callbacks.sort.bind(null,"desc"),disabled:1!==n,tooltip:1!==n?(0,e.__)("This option is disabled because more than one column was selected.","tablepress"):""}]},{type:"divisor"},{title:(0,e.__)("Hide/Show …","tablepress"),submenu:[{title:(0,e._n)("Hide row","Hide rows",l,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"hide","rows"),disabled:!tp.helpers.visibility.selection_contains("rows",1),tooltip:tp.helpers.visibility.selection_contains("rows",1)?"":(0,e.__)("This option is disabled because no visible rows were selected.","tablepress")},{title:(0,e._n)("Hide column","Hide columns",n,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"hide","columns"),disabled:!tp.helpers.visibility.selection_contains("columns",1),tooltip:tp.helpers.visibility.selection_contains("columns",1)?"":(0,e.__)("This option is disabled because no visible columns were selected.","tablepress")},{title:(0,e._n)("Show row","Show rows",l,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"unhide","rows"),disabled:!tp.helpers.visibility.selection_contains("rows",0),tooltip:tp.helpers.visibility.selection_contains("rows",0)?"":(0,e.__)("This option is disabled because no hidden rows were selected.","tablepress")},{title:(0,e._n)("Show column","Show columns",n,"tablepress"),onclick:tp.callbacks.hide_unhide.bind(null,"unhide","columns"),disabled:!tp.helpers.visibility.selection_contains("columns",0),tooltip:tp.helpers.visibility.selection_contains("columns",0)?"":(0,e.__)("This option is disabled because no hidden columns were selected.","tablepress")}]},{type:"divisor"},{title:(0,e.__)("Combine/Merge cells","tablepress"),onclick:tp.callbacks.merge_cells,disabled:1===l&&1===n||!tp.helpers.cell_merge_allowed("no-alert"),tooltip:1===l&&1===n||!tp.helpers.cell_merge_allowed("no-alert",c)?(0,e.__)("This option is disabled.","tablepress")+" "+c.text:""}]},sorting:tp.helpers.editor.sorting,onmoverow:tp.callbacks.editor.onmove,onmovecolumn:tp.callbacks.editor.onmove,onblur:tp.helpers.editor.reselect,onload:tp.helpers.editor.reselect,onchange:tp.helpers.unsaved_changes.set,onsort:tp.callbacks.editor.onsort}),tp.helpers.options.load(),o("#tablepress-page").addEventListener("click",(e=>{e.target&&(e.target.matches(".button-preview")?tp.callbacks.table_preview.process(e):e.target.matches(".button-save-changes")?tp.callbacks.save_changes.process(e):e.target.matches(".button-show-help-box")&&tp.callbacks.help_box.open_dialog(e))})),o("#tablepress-manipulation-controls").addEventListener("click",(t=>{if(t.target)if(t.target.matches(".button-append")){const s=t.target.dataset.type,l=o(`#${s}-append-number`),n=parseInt(l.value,10);if(isNaN(n)||n<1||n>99999){const s="rows"===t.target.dataset.type?(0,e.__)("The value for the number of rows is invalid!","tablepress"):(0,e.__)("The value for the number of columns is invalid!","tablepress");return window.alert(s),l.focus(),void l.select()}tp.callbacks.append(s,n)}else if("button-insert-link"!==t.target.id)if("button-insert-image"!==t.target.id)if("button-advanced-editor"!==t.target.id)if(t.target.matches(".button-insert-duplicate"))tp.callbacks.insert_duplicate(t.target.dataset.action,t.target.dataset.type);else{if(t.target.matches(".button-move"))return tp.helpers.move_allowed(t.target.dataset.type,t.target.dataset.direction)?void tp.callbacks.move(t.target.dataset.direction,t.target.dataset.type):void window.alert((0,e.__)("You can not do this move, because you reached the border of the table.","tablepress"));if(t.target.matches(".button-remove")){const s="rows"===t.target.dataset.type;if((s?tp.editor.options.data.length:tp.editor.options.columns.length)===tp.helpers.selection[t.target.dataset.type].length){const t=s?(0,e.__)("You can not delete all table rows!","tablepress"):(0,e.__)("You can not delete all table columns!","tablepress");return void window.alert(t)}tp.callbacks.remove(t.target.dataset.type)}else t.target.matches(".button-merge-unmerge")?tp.helpers.cell_merge_allowed("alert")&&tp.callbacks.merge_cells():t.target.matches(".button-hide-unhide")&&tp.callbacks.hide_unhide(t.target.dataset.action,t.target.dataset.type)}else tp.callbacks.advanced_editor.open_dialog();else tp.callbacks.insert_image.open_dialog();else tp.callbacks.insert_link.open_dialog()}));const l=o("#table-id");l.addEventListener("input",tp.callbacks.table_id.sanitize),l.addEventListener("change",tp.callbacks.table_id.change);const n=o("#table-information-shortcode");n&&n.addEventListener("focus",(function(){this.select()})),jQuery("#textarea-insert-helper").on("change",tp.helpers.editor.insert_from_helper_textarea),["#table-name","#table-description"].forEach((e=>o(e).addEventListener("change",tp.helpers.unsaved_changes.set))),(0,t.applyFilters)("tablepress.optionsMetaBoxes",["#tablepress_edit-table-options","#tablepress_edit-datatables-features"]).forEach((e=>o(e).addEventListener("change",tp.helpers.options.change))),document.querySelectorAll("#tablepress-body .button-module-help").forEach((e=>e.closest(".postbox").querySelector(".handle-actions").prepend(e)));const a=o("#tablepress-screen-options");a.addEventListener("input",tp.callbacks.screen_options.update),a.addEventListener("change",tp.callbacks.screen_options.set_was_changed),a.addEventListener("focusout",tp.callbacks.screen_options.save),window.addEventListener("keydown",tp.callbacks.keyboard_shortcuts,!0);const i=window?.navigator?.platform?.includes("Mac")?(0,e._x)("⌘","keyboard shortcut modifier key on a Mac keyboard","tablepress"):(0,e._x)("Ctrl+","keyboard shortcut modifier key on a non-Mac keyboard","tablepress");document.querySelectorAll(".button[data-shortcut]").forEach((t=>{const s=(0,e.sprintf)(t.dataset.shortcut,i);t.title=(0,e.sprintf)((0,e.__)("Keyboard Shortcut: %s","tablepress"),s)})),jQuery((function(){jQuery("#wp-link").on("focus","input",(function(e){e.stopPropagation()})),jQuery("body").on("focus",".media-modal .media-frame-content input, .media-modal .media-frame-content textarea",(function(e){e.stopPropagation()}))}))}();