const DEFAULT_VALUES={show_serial_number_column:"0",search:"1",hide_table_header:"0",sorting:"1",filters:"0",page_limit:10,exclude_column_ids:"",exclude_columns_from_search:""};function escapeAttribute(e){return null==e?"":String(e).replace(/'/g,"\\'")}export function generateShortcode(e){if(!e||!e.table_id)return"";const t=[];t.push(`table_id='${escapeAttribute(e.table_id)}'`),Object.keys(DEFAULT_VALUES).forEach((r=>{const o=e[r];null!=o&&o!==DEFAULT_VALUES[r]&&("exclude_column_ids"===r&&Array.isArray(o)||"exclude_columns_from_search"===r&&Array.isArray(o)?o.length>0&&t.push(`${r}='${escapeAttribute(o.join(","))}'`):"boolean"!=typeof o?t.push(`${r}='${escapeAttribute(o)}'`):t.push(`${r}='${o?"1":"0"}'`))}));return`[${["tablesome"].join("")} ${t.join(" ")}/]`}export function parseShortcode(e){const t={table_id:null,...DEFAULT_VALUES};if(!e||"string"!=typeof e)return t;const r=/(\w+)='([^']*)'/g;let o;for(;null!==(o=r.exec(e));){const e=o[1];let r=o[2];["show_serial_number_column","search","hide_table_header","sorting","filters"].includes(e)&&(r="1"===r?"1":"0"),"page_limit"===e&&(r=parseInt(r,10)||DEFAULT_VALUES.page_limit),"exclude_column_ids"!==e&&"exclude_columns_from_search"!==e||(r=r?r.split(",").map((e=>e.trim())):[]),"table_id"===e&&(r=parseInt(r,10)),t[e]=r}return t}export default{generateShortcode,parseShortcode,DEFAULT_VALUES};