opentiny 6.9.24 → 6.9.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opentiny",
3
- "version": "6.9.24",
3
+ "version": "6.9.26",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/mild-blue/opentiny"
@@ -41,7 +41,7 @@
41
41
  });
42
42
  });
43
43
  };
44
- const isValidId = id => /^[A-Za-z][A-Za-z0-9\-:._]*$/.test(id);
44
+ const isValidId = id => /^[A-Za-z][A-Za-z0-9\-_]*$/.test(id);
45
45
  const getNamedAnchor = editor => editor.dom.getParent(editor.selection.getStart(), namedAnchorSelector);
46
46
  const getId = editor => {
47
47
  const anchor = getNamedAnchor(editor);
@@ -86,7 +86,7 @@
86
86
 
87
87
  const insertAnchor = (editor, newId) => {
88
88
  if (!isValidId(newId)) {
89
- editor.windowManager.alert('ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores.');
89
+ editor.windowManager.alert('ID should start with a letter, followed only by letters, numbers, dashes or underscores.');
90
90
  return false;
91
91
  } else {
92
92
  insert(editor, newId);
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * TinyMCE version 7.0.0 (TBD)
3
3
  */
4
- !function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),n=tinymce.util.Tools.resolve("tinymce.util.Tools");const o=e=>e.options.get("allow_html_in_named_anchor");const a="a:not([href])",r=e=>!e,i=e=>e.getAttribute("id")||e.getAttribute("name")||"",l=e=>(e=>"a"===e.nodeName.toLowerCase())(e)&&!e.getAttribute("href")&&""!==i(e),s=e=>e.dom.getParent(e.selection.getStart(),a),c=(e,a)=>{const r=s(e);r?((e,t,n)=>{n.removeAttribute("name"),n.id=t,e.addVisual(),e.undoManager.add()})(e,a,r):((e,a)=>{e.undoManager.transact(()=>{o(e)||e.selection.collapse(!0),e.selection.isCollapsed()?e.insertContent(e.dom.createHTML("a",{id:a})):((e=>{const o=e.dom;t(o).walk(e.selection.getRng(),e=>{n.each(e,e=>{var t;l(t=e)&&!t.firstChild&&o.remove(e,!1)})})})(e),e.formatter.remove("namedAnchor",void 0,void 0,!0),e.formatter.apply("namedAnchor",{value:a}),e.addVisual())})})(e,a),e.focus()};var d=tinymce.util.Tools.resolve("tinymce.util.I18n");const m=e=>(e=>r(e.attr("href"))&&!r(e.attr("id")||e.attr("name")))(e)&&!e.firstChild,h=e=>t=>{for(let n=0;n<t.length;n++){const o=t[n];m(o)&&o.attr("contenteditable",e)}},u=e=>t=>{const n=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",n),n(),()=>{e.off("NodeChange",n)}};e.add("anchor",e=>{(e=>{(0,e.options.register)("allow_html_in_named_anchor",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreInit",()=>{e.parser.addNodeFilter("a",h("false")),e.serializer.addNodeFilter("a",h(null))})})(e),(e=>{e.addCommand("mceAnchor",()=>{(e=>{const t=(e=>{const t=s(e);return t?i(t):""})(e);e.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{type:"htmlpanel",html:'<p style="font-size: 14px; margin-bottom: 10px;">'+d.translate("The anchor tool is used to create a link that allows the user to jump to a specific part of the document marked by the anchor. For example, you can link to an image or a specific section of text (e.g., a heading or a paragraph)")+"<br><br>"+d.translate('Enter an anchor identifier in the "ID" field (e.g., "anchor1") > click Save > Insert > Link > select the anchor in the "Anchors" field > the "Link URL" and "Link Text" fields will auto-fill > adjust the "Link Title" as needed.')+"</p>"},{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:t},onSubmit:t=>{((e,t)=>/^[A-Za-z][A-Za-z0-9\-:._]*$/.test(t)?(c(e,t),!0):(e.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes, dots, colons or underscores."),!1))(e,t.getData().id)&&t.close()}})})(e)})})(e),(e=>{const t=()=>e.execCommand("mceAnchor");e.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:t,onSetup:t=>{const n=e.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind,o=u(e)(t);return()=>{n(),o()}}}),e.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:t,onSetup:u(e)})})(e),e.on("PreInit",()=>{(e=>{e.formatter.register("namedAnchor",{inline:"a",selector:a,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(e,t,n)=>l(e)})})(e)})})}();
4
+ !function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),t=tinymce.util.Tools.resolve("tinymce.dom.RangeUtils"),n=tinymce.util.Tools.resolve("tinymce.util.Tools");const o=e=>e.options.get("allow_html_in_named_anchor");const a="a:not([href])",r=e=>!e,i=e=>e.getAttribute("id")||e.getAttribute("name")||"",l=e=>(e=>"a"===e.nodeName.toLowerCase())(e)&&!e.getAttribute("href")&&""!==i(e),s=e=>e.dom.getParent(e.selection.getStart(),a),c=(e,a)=>{const r=s(e);r?((e,t,n)=>{n.removeAttribute("name"),n.id=t,e.addVisual(),e.undoManager.add()})(e,a,r):((e,a)=>{e.undoManager.transact(()=>{o(e)||e.selection.collapse(!0),e.selection.isCollapsed()?e.insertContent(e.dom.createHTML("a",{id:a})):((e=>{const o=e.dom;t(o).walk(e.selection.getRng(),e=>{n.each(e,e=>{var t;l(t=e)&&!t.firstChild&&o.remove(e,!1)})})})(e),e.formatter.remove("namedAnchor",void 0,void 0,!0),e.formatter.apply("namedAnchor",{value:a}),e.addVisual())})})(e,a),e.focus()};var d=tinymce.util.Tools.resolve("tinymce.util.I18n");const m=e=>(e=>r(e.attr("href"))&&!r(e.attr("id")||e.attr("name")))(e)&&!e.firstChild,h=e=>t=>{for(let n=0;n<t.length;n++){const o=t[n];m(o)&&o.attr("contenteditable",e)}},u=e=>t=>{const n=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",n),n(),()=>{e.off("NodeChange",n)}};e.add("anchor",e=>{(e=>{(0,e.options.register)("allow_html_in_named_anchor",{processor:"boolean",default:!1})})(e),(e=>{e.on("PreInit",()=>{e.parser.addNodeFilter("a",h("false")),e.serializer.addNodeFilter("a",h(null))})})(e),(e=>{e.addCommand("mceAnchor",()=>{(e=>{const t=(e=>{const t=s(e);return t?i(t):""})(e);e.windowManager.open({title:"Anchor",size:"normal",body:{type:"panel",items:[{type:"htmlpanel",html:'<p style="font-size: 14px; margin-bottom: 10px;">'+d.translate("The anchor tool is used to create a link that allows the user to jump to a specific part of the document marked by the anchor. For example, you can link to an image or a specific section of text (e.g., a heading or a paragraph)")+"<br><br>"+d.translate('Enter an anchor identifier in the "ID" field (e.g., "anchor1") > click Save > Insert > Link > select the anchor in the "Anchors" field > the "Link URL" and "Link Text" fields will auto-fill > adjust the "Link Title" as needed.')+"</p>"},{name:"id",type:"input",label:"ID",placeholder:"example"}]},buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:{id:t},onSubmit:t=>{((e,t)=>/^[A-Za-z][A-Za-z0-9\-_]*$/.test(t)?(c(e,t),!0):(e.windowManager.alert("ID should start with a letter, followed only by letters, numbers, dashes or underscores."),!1))(e,t.getData().id)&&t.close()}})})(e)})})(e),(e=>{const t=()=>e.execCommand("mceAnchor");e.ui.registry.addToggleButton("anchor",{icon:"bookmark",tooltip:"Anchor",onAction:t,onSetup:t=>{const n=e.selection.selectorChangedWithUnbind("a:not([href])",t.setActive).unbind,o=u(e)(t);return()=>{n(),o()}}}),e.ui.registry.addMenuItem("anchor",{icon:"bookmark",text:"Anchor...",onAction:t,onSetup:u(e)})})(e),e.on("PreInit",()=>{(e=>{e.formatter.register("namedAnchor",{inline:"a",selector:a,remove:"all",split:!0,deep:!0,attributes:{id:"%value"},onmatch:(e,t,n)=>l(e)})})(e)})})}();
@@ -1710,8 +1710,26 @@
1710
1710
  if (allowed.length === 0) {
1711
1711
  return '';
1712
1712
  }
1713
- const allowedSet = new Set(allowed);
1714
- const filteredGroups = menu.split('|').map(group => group.trim()).map(group => group.length === 0 ? [] : group.split(/\s+/).filter(item => allowedSet.has(item))).filter(items => items.length > 0).map(items => items.join(' '));
1713
+ const menuItems = bind(menu.split('|'), group => group.trim().split(/\s+/).filter(item => item.length > 0));
1714
+ const validItems = new Set(menuItems);
1715
+ const groups = [];
1716
+ let current = [];
1717
+ each(allowed, item => {
1718
+ if (item === '|') {
1719
+ if (current.length > 0) {
1720
+ groups.push(current);
1721
+ current = [];
1722
+ } else {
1723
+ groups.push([]);
1724
+ }
1725
+ } else if (validItems.has(item)) {
1726
+ current.push(item);
1727
+ }
1728
+ });
1729
+ if (current.length > 0) {
1730
+ groups.push(current);
1731
+ }
1732
+ const filteredGroups = bind(groups, group => group.length > 0 ? [group.join(' ')] : []);
1715
1733
  return filteredGroups.join(' | ');
1716
1734
  };
1717
1735
  const flattenContextMenu = (menu, replacements) => {
@@ -3109,10 +3127,12 @@
3109
3127
  };
3110
3128
  const getTableMenuItems = editor => {
3111
3129
  const menu = 'inserttable | cell row column | advtablesort | tableprops deletetable';
3112
- const filteredMenu = isTableContextMenuSet(editor) ? filterContextMenu(menu, [
3130
+ const contextItems = getTableContextMenu(editor);
3131
+ const tableContextMenu = contextItems.length > 0 ? [
3113
3132
  'inserttable',
3114
- ...getTableContextMenu(editor)
3115
- ]) : menu;
3133
+ ...contextItems
3134
+ ].join(' ') : '';
3135
+ const filteredMenu = isTableContextMenuSet(editor) ? tableContextMenu : menu;
3116
3136
  if (isTableContextMenuFlatten(editor) && filteredMenu.length > 0) {
3117
3137
  return flattenContextMenu(filteredMenu, {
3118
3138
  cell: getFilteredCellMenuItems(editor),
@@ -3574,14 +3594,15 @@
3574
3594
  editor.ui.registry.addContextMenu('table', {
3575
3595
  update: () => {
3576
3596
  selectionTargets.resetTargets();
3577
- const menu = selectionTargets.targets().fold(constant(''), targets => {
3597
+ const defaultMenu = selectionTargets.targets().fold(constant(''), targets => {
3578
3598
  if (name(targets.element) === 'caption') {
3579
3599
  return 'tableprops deletetable';
3580
3600
  } else {
3581
3601
  return 'cell row column | advtablesort | tableprops deletetable';
3582
3602
  }
3583
3603
  });
3584
- const filteredMenu = isTableContextMenuSet(editor) ? filterContextMenu(menu, getTableContextMenu(editor)) : menu;
3604
+ const tableContextMenu = getTableContextMenu(editor).join(' ');
3605
+ const filteredMenu = isTableContextMenuSet(editor) ? tableContextMenu : defaultMenu;
3585
3606
  if (isTableContextMenuFlatten(editor) && filteredMenu.length > 0) {
3586
3607
  return flattenContextMenu(filteredMenu, {
3587
3608
  cell: filteredCellMenuItems,
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * TinyMCE version 7.0.0 (TBD)
3
3
  */
4
- !function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=l=e,(n=String).prototype.isPrototypeOf(o)||(null===(r=l.constructor)||void 0===r?void 0:r.name)===n.name)?"string":t;var o,l,n,r})(t)===e,o=e=>t=>typeof t===e,l=t("string"),n=t("array"),r=o("boolean"),a=e=>void 0===e;const s=e=>!(e=>null==e)(e),c=o("function"),i=o("number"),m=()=>{},d=e=>()=>e,u=e=>e,p=(e,t)=>e===t;function b(e,...t){return(...o)=>{const l=t.concat(o);return e.apply(null,l)}}const g=e=>{e()},h=d(!1),f=d(!0);class y{constructor(e,t){this.tag=e,this.value=t}static some(e){return new y(!0,e)}static none(){return y.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?y.some(e(this.value)):y.none()}bind(e){return this.tag?e(this.value):y.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:y.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return s(e)?y.some(e):y.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}y.singletonNone=new y(!1);const w=Object.keys,S=Object.hasOwnProperty,C=(e,t)=>{const o=w(e);for(let l=0,n=o.length;l<n;l++){const n=o[l];t(e[n],n)}},v=(e,t)=>{const o={};var l;return((e,t,o,l)=>{C(e,(e,n)=>{(t(e,n)?o:l)(e,n)})})(e,t,(l=o,(e,t)=>{l[t]=e}),m),o},x=e=>w(e).length,T=(e,t)=>_(e,t)?y.from(e[t]):y.none(),_=(e,t)=>S.call(e,t),A=(e,t)=>_(e,t)&&void 0!==e[t]&&null!==e[t],R=Array.prototype.indexOf,O=Array.prototype.push,D=(e,t)=>((e,t)=>R.call(e,t))(e,t)>-1,I=(e,t)=>{for(let o=0,l=e.length;o<l;o++)if(t(e[o],o))return!0;return!1},N=(e,t)=>{const o=[];for(let l=0;l<e;l++)o.push(t(l));return o},k=(e,t)=>{const o=e.length,l=new Array(o);for(let n=0;n<o;n++){const o=e[n];l[n]=t(o,n)}return l},M=(e,t)=>{for(let o=0,l=e.length;o<l;o++)t(e[o],o)},P=(e,t)=>{const o=[];for(let l=0,n=e.length;l<n;l++){const n=e[l];t(n,l)&&o.push(n)}return o},E=(e,t,o)=>(M(e,(e,l)=>{o=t(o,e,l)}),o),B=(e,t)=>((e,t,o)=>{for(let l=0,n=e.length;l<n;l++){const n=e[l];if(t(n,l))return y.some(n);if(o(n,l))break}return y.none()})(e,t,h),F=(e,t)=>(e=>{const t=[];for(let o=0,l=e.length;o<l;++o){if(!n(e[o]))throw new Error("Arr.flatten item "+o+" was not an array, input: "+e);O.apply(t,e[o])}return t})(k(e,t)),j=(e,t)=>{for(let o=0,l=e.length;o<l;++o)if(!0!==t(e[o],o))return!1;return!0},q=(e,t)=>t>=0&&t<e.length?y.some(e[t]):y.none(),L=(e,t)=>{for(let o=0;o<e.length;o++){const l=t(e[o],o);if(l.isSome())return l}return y.none()},H=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},V={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return H(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return H(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return H(o)},fromDom:H,fromPoint:(e,t,o)=>y.from(e.dom.elementFromPoint(t,o)).map(H)},$=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},W=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,z=(e,t)=>e.dom===t.dom,U=$;"undefined"!=typeof window?window:Function("return this;")();const G=e=>e.dom.nodeName.toLowerCase(),K=e=>e.dom.nodeType,J=e=>t=>K(t)===e,Q=J(1),X=J(3),Y=J(9),Z=J(11),ee=e=>t=>Q(t)&&G(t)===e,te=e=>Y(e)?e:V.fromDom(e.dom.ownerDocument),oe=e=>y.from(e.dom.parentNode).map(V.fromDom),le=e=>y.from(e.dom.nextSibling).map(V.fromDom),ne=e=>k(e.dom.childNodes,V.fromDom),re=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?e=>V.fromDom(e.dom.getRootNode()):te,ae=e=>V.fromDom(e.dom.host),se=e=>{const t=X(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=re(e);return Z(o=t)&&s(o.dom.host)?y.some(t):y.none();var o})(V.fromDom(t)).fold(()=>o.body.contains(t),(l=se,n=ae,e=>l(n(e))));var l,n};var ce=(e,t,o,l,n)=>e(o,l)?y.some(o):c(n)&&n(o)?y.none():t(o,l,n);const ie=(e,t,o)=>{let l=e.dom;const n=c(o)?o:h;for(;l.parentNode;){l=l.parentNode;const e=V.fromDom(l);if(t(e))return y.some(e);if(n(e))break}return y.none()},me=(e,t,o)=>ie(e,e=>$(e,t),o),de=(e,t)=>(e=>B(e.dom.childNodes,e=>{return o=V.fromDom(e),$(o,t);var o}).map(V.fromDom))(e),ue=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return W(o)?y.none():y.from(o.querySelector(e)).map(V.fromDom)})(t,e),pe=(e,t,o)=>ce((e,t)=>$(e,t),me,e,t,o),be=(e,t=!1)=>{return se(e)?e.dom.isContentEditable:(o=e,pe(o,"[contenteditable]")).fold(d(t),e=>"true"===ge(e));var o},ge=e=>e.dom.contentEditable,he=e=>t=>z(t,(e=>V.fromDom(e.getBody()))(e)),fe=e=>/^\d+(\.\d+)?$/.test(e)?e+"px":e,ye=e=>V.fromDom(e.selection.getStart()),we=(e,t)=>{let o=[];return M(ne(e),e=>{t(e)&&(o=o.concat([e])),o=o.concat(we(e,t))}),o},Se=(e,t)=>(e=>P(ne(e),e=>$(e,t)))(e),Ce=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return W(o)?[]:k(o.querySelectorAll(e),V.fromDom)})(t,e),ve=(e,t,o)=>{if(!(l(o)||r(o)||i(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},xe=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},Te=(e,t)=>y.from(xe(e,t)),_e=(e,t)=>{e.dom.removeAttribute(t)},Ae=(e,t,o=p)=>e.exists(e=>o(e,t)),Re=(e,t,o)=>e.isSome()&&t.isSome()?y.some(o(e.getOrDie(),t.getOrDie())):y.none(),Oe=(e,t)=>((e,t)=>""===t||e.length>=t.length&&e.substr(0,0+t.length)===t)(e,t),De=(Ie=/^\s+|\s+$/g,e=>e.replace(Ie,""));var Ie;const Ne=e=>e.length>0,ke=(e,t=10)=>{const o=parseInt(e,t);return isNaN(o)?y.none():y.some(o)},Me=e=>void 0!==e.style&&c(e.style.getPropertyValue),Pe=(e,t)=>{const o=e.dom,l=window.getComputedStyle(o).getPropertyValue(t);return""!==l||se(e)?l:Ee(o,t)},Ee=(e,t)=>Me(e)?e.style.getPropertyValue(t):"",Be=(e,t)=>{const o=e.dom,l=Ee(o,t);return y.from(l).filter(e=>e.length>0)},Fe=(e,t,o=0)=>Te(e,t).map(e=>parseInt(e,10)).getOr(o),je=(e,t)=>qe(e,t,f),qe=(e,t,o)=>F(ne(e),e=>$(e,t)?o(e)?[e]:[]:qe(e,t,o)),Le=["tfoot","thead","tbody","colgroup"],He=(e,t,o)=>({element:e,rowspan:t,colspan:o}),Ve=(e,t,o)=>({element:e,cells:t,section:o}),$e=(e,t)=>pe(e,"table",t),We=e=>je(e,"tr"),ze=e=>$e(e).fold(d([]),e=>Se(e,"colgroup")),Ue=e=>oe(e).map(e=>{const t=G(e);return(e=>D(Le,e))(t)?t:"tbody"}).getOr("tbody"),Ge=e=>Te(e,"data-snooker-locked-cols").bind(e=>y.from(e.match(/\d+/g))).map(e=>((e,t)=>{const o={};for(let l=0,n=e.length;l<n;l++){const n=e[l];o[String(n)]=t(n,l)}return o})(e,f)),Ke=(e,t)=>e+","+t,Je=e=>{const t={},o=[];var l;const n=(l=e,q(l,0)).map(e=>e.element).bind($e).bind(Ge).getOr({});let r=0,a=0,s=0;const{pass:c,fail:i}=((e,t)=>{const o=[],l=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];(t(r)?o:l).push(r)}return{pass:o,fail:l}})(e,e=>"colgroup"===e.section);M(i,e=>{const l=[];M(e.cells,e=>{let o=0;for(;void 0!==t[Ke(s,o)];)o++;const r=A(n,o.toString()),c=((e,t,o,l,n,r)=>({element:e,rowspan:t,colspan:o,row:l,column:n,isLocked:r}))(e.element,e.rowspan,e.colspan,s,o,r);for(let l=0;l<e.colspan;l++)for(let n=0;n<e.rowspan;n++){const e=o+l,r=Ke(s+n,e);t[r]=c,a=Math.max(a,e+1)}l.push(c)}),r++,o.push(Ve(e.element,l,e.section)),s++});const{columns:m,colgroups:d}=(e=>q(e,e.length-1))(c).map(e=>{const t=(e=>{const t={};let o=0;return M(e.cells,e=>{const l=e.colspan;N(l,n=>{const r=o+n;t[r]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,l,r)}),o+=l}),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,((e,t)=>{const o=[];return C(e,(e,l)=>{o.push(t(e,l))}),o})(t,u));return{colgroups:[o],columns:t}}).getOrThunk(()=>({colgroups:[],columns:{}})),p=((e,t)=>({rows:e,columns:t}))(r,a);return{grid:p,access:t,all:o,columns:m,colgroups:d}},Qe=e=>{const t=(e=>{const t=We(e);return((e,t)=>k(e,e=>{if("colgroup"===G(e)){const t=k((e=>$(e,"colgroup")?Se(e,"col"):F(ze(e),e=>Se(e,"col")))(e),e=>{const t=Fe(e,"span",1);return He(e,1,t)});return Ve(e,t,"colgroup")}{const o=k((e=>je(e,"th,td"))(e),e=>{const t=Fe(e,"rowspan",1),o=Fe(e,"colspan",1);return He(e,t,o)});return Ve(e,o,t(e))}}))([...ze(e),...t],Ue)})(e);return Je(t)},Xe=(e,t,o)=>y.from(e.access[Ke(t,o)]),Ye=(e,t,o)=>{const l=((e,t)=>{const o=F(e.all,e=>e.cells);return P(o,t)})(e,e=>o(t,e.element));return l.length>0?y.some(l[0]):y.none()},Ze=(e,t)=>y.from(e.columns[t]);var et=tinymce.util.Tools.resolve("tinymce.util.Tools");const tt=(e,t,o)=>{const l=e.select("td,th",t);let n;for(let t=0;t<l.length;t++){const r=e.getStyle(l[t],o);if(a(n)&&(n=r),n!==r)return""}return n},ot=(e,t,o)=>{et.each("left center right".split(" "),l=>{l!==o&&e.formatter.remove("align"+l,{},t)}),o&&e.formatter.apply("align"+o,{},t)},lt=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},nt=(e,t,o)=>((e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?y.none():y.some(t)})(e).getOr(t))(Pe(e,t),o),rt=e=>((e,t)=>{const o=e.dom,l=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?l:((e,t,o,l)=>t-nt(e,`padding-${o}`,0)-nt(e,`padding-${l}`,0)-nt(e,`border-${o}-width`,0)-nt(e,`border-${l}-width`,0))(e,l,"left","right")})(e,"content-box");var at=tinymce.util.Tools.resolve("tinymce.Env");const st=N(5,e=>{const t=`${e+1}px`;return{title:t,value:t}}),ct=k(["None","Solid","Dotted","Dashed","Double","Groove","Ridge","Inset","Outset","Hidden"],e=>({title:e,value:e.toLowerCase()})),it="100%",mt=e=>{var t;const o=e.dom,l=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return rt(V.fromDom(l))+"px"},dt=e=>t=>t.options.get(e),ut=dt("table_sizing_mode"),pt=dt("table_border_widths"),bt=dt("table_border_styles"),gt=dt("table_cell_advtab"),ht=dt("table_row_advtab"),ft=dt("table_advtab"),yt=dt("table_cell_inputs"),wt=dt("table_row_inputs"),St=dt("table_inputs"),Ct=dt("table_grid"),vt=dt("table_style_by_css"),xt=dt("table_cell_class_list"),Tt=dt("table_row_class_list"),_t=dt("table_class_list"),At=dt("table_toolbar"),Rt=dt("table_contextmenu"),Ot=dt("table_contextmenu_flatten"),Dt=dt("table_row_contextmenu"),It=dt("table_column_contextmenu"),Nt=dt("table_cell_contextmenu"),kt=dt("table_background_color_map"),Mt=dt("table_border_color_map"),Pt=e=>"fixed"===ut(e),Et=e=>"responsive"===ut(e),Bt=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>Et(e)||!vt(e)?t:Pt(e)?{...t,width:mt(e)}:{...t,width:it})(e,o)},Ft=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>Et(e)||vt(e)?t:Pt(e)?{...t,width:mt(e)}:{...t,width:it})(e,o)},jt=e=>e.options.isSet("table_contextmenu"),qt=e=>Ot(e),Lt=e=>e.options.isSet("table_row_contextmenu"),Ht=e=>e.options.isSet("table_column_contextmenu"),Vt=e=>e.options.isSet("table_cell_contextmenu"),$t=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,Wt=(e,t,o)=>((e,t,o)=>{const l=Ye(e,t,z),n=Ye(e,o,z);return l.bind(e=>n.map(t=>{return o=e,l=t,{startRow:Math.min(o.row,l.row),startCol:Math.min(o.column,l.column),finishRow:Math.max(o.row+o.rowspan-1,l.row+l.rowspan-1),finishCol:Math.max(o.column+o.colspan-1,l.column+l.colspan-1)};var o,l}))})(e,t,o).bind(t=>((e,t)=>{let o=!0;const l=b($t,t);for(let n=t.startRow;n<=t.finishRow;n++)for(let r=t.startCol;r<=t.finishCol;r++)o=o&&Xe(e,n,r).exists(l);return o?y.some(t):y.none()})(e,t)),zt=Qe,Ut=(e,t)=>{oe(e).each(o=>{o.dom.insertBefore(t.dom,e.dom)})},Gt=(e,t)=>{le(e).fold(()=>{oe(e).each(e=>{Kt(e,t)})},e=>{Ut(e,t)})},Kt=(e,t)=>{e.dom.appendChild(t.dom)},Jt=(e,t)=>{M(t,(o,l)=>{const n=0===l?e:t[l-1];Gt(n,o)})},Qt=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Xt=(e=>{const t=t=>e(t)?y.from(t.dom.nodeValue):y.none();return{get:o=>{if(!e(o))throw new Error("Can only get text value of a text node");return t(o).getOr("")},getOption:t,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(X);var Yt=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"];const Zt=(e,t,o,l)=>{const n=t(e,o);return r=(o,l)=>{const n=t(e,l);return eo(e,o,n)},a=n,((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(l,(e,t)=>{a=r(a,e)}),a;var r,a},eo=(e,t,o)=>t.bind(t=>o.filter(b(e.eq,t))),to={up:d({selector:me,closest:pe,predicate:ie,all:(e,t)=>{const o=c(t)?t:h;let l=e.dom;const n=[];for(;null!==l.parentNode&&void 0!==l.parentNode;){const e=l.parentNode,t=V.fromDom(e);if(n.push(t),!0===o(t))break;l=e}return n}}),down:d({selector:Ce,predicate:we}),styles:d({get:Pe,getRaw:Be,set:(e,t,o)=>{((e,t,o)=>{if(!l(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Me(e)&&e.style.setProperty(t,o)})(e.dom,t,o)},remove:(e,t)=>{((e,t)=>{Me(e)&&e.style.removeProperty(t)})(e.dom,t),Ae(Te(e,"style").map(De),"")&&_e(e,"style")}}),attrs:d({get:xe,set:(e,t,o)=>{ve(e.dom,t,o)},remove:_e,copyTo:(e,t)=>{((e,t)=>{const o=e.dom;C(t,(e,t)=>{ve(o,t,e)})})(t,E(e.dom.attributes,(e,t)=>(e[t.name]=t.value,e),{}))}}),insert:d({before:Ut,after:Gt,afterAll:Jt,append:Kt,appendAll:(e,t)=>{M(t,t=>{Kt(e,t)})},prepend:(e,t)=>{(e=>(e=>{const t=e.dom.childNodes;return y.from(t[0]).map(V.fromDom)})(e))(e).fold(()=>{Kt(e,t)},o=>{e.dom.insertBefore(t.dom,o.dom)})},wrap:(e,t)=>{Ut(e,t),Kt(t,e)}}),remove:d({unwrap:e=>{const t=ne(e);t.length>0&&Jt(e,t),Qt(e)},remove:Qt}),create:d({nu:V.fromTag,clone:e=>V.fromDom(e.dom.cloneNode(!1)),text:V.fromText}),query:d({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:e=>y.from(e.dom.previousSibling).map(V.fromDom),nextSibling:le}),property:d({children:ne,name:G,parent:oe,document:e=>te(e).dom,isText:X,isComment:e=>8===K(e)||"#comment"===G(e),isElement:Q,isSpecial:e=>{const t=G(e);return D(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>Q(e)?Te(e,"lang"):y.none(),getText:e=>Xt.get(e),setText:(e,t)=>Xt.set(e,t),isBoundary:e=>!!Q(e)&&("body"===G(e)||D(Yt,G(e))),isEmptyTag:e=>!!Q(e)&&D(["br","img","hr","input"],G(e)),isNonEditable:e=>Q(e)&&"false"===xe(e,"contenteditable")}),eq:z,is:U},oo=e=>me(e,"table"),lo=(e,t,o)=>ue(e,t).bind(t=>ue(e,o).bind(e=>{return(o=oo,l=[t,e],((e,t,o)=>o.length>0?((e,t,o,l)=>l(e,t,o[0],o.slice(1)))(e,t,o,Zt):y.none())(to,(e,t)=>o(t),l)).map(o=>({first:t,last:e,table:o}));var o,l})),no=e=>k(e,V.fromDom),ro="data-mce-selected",ao="data-mce-first-selected",so="data-mce-last-selected",co={selected:ro,selectedSelector:"td["+ro+"],th["+ro+"]",firstSelected:ao,firstSelectedSelector:"td["+ao+"],th["+ao+"]",lastSelected:so,lastSelectedSelector:"td["+so+"],th["+so+"]"},io=e=>(t,o)=>{const l=G(t),n="col"===l||"colgroup"===l?$e(r=t).bind(e=>((e,t)=>((e,t)=>{const o=Ce(e,t);return o.length>0?y.some(o):y.none()})(e,t))(e,co.firstSelectedSelector)).fold(d(r),e=>e[0]):t;var r;return pe(n,e,o)},mo=io("th,td,caption"),uo=io("th,td"),po=e=>no(e.model.table.getSelectedCells()),bo=(e,t)=>{const o=uo(e),l=o.bind(e=>$e(e)).map(e=>We(e));return Re(o,l,(e,o)=>P(o,o=>I(no(o.dom.cells),o=>"1"===xe(o,t)||z(o,e)))).getOr([])},go=[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}],ho=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,fo=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,yo=e=>{return(t=e,Oe(t,"#")?(e=>e.substring(1))(t):t).toUpperCase();var t},wo=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},So=e=>{return t=wo(e.red)+wo(e.green)+wo(e.blue),{value:yo(t)};var t},Co=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,vo=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,xo=(e,t,o,l)=>({red:e,green:t,blue:o,alpha:l}),To=(e,t,o,l)=>{const n=parseInt(e,10),r=parseInt(t,10),a=parseInt(o,10),s=parseFloat(l);return xo(n,r,a,s)},_o=e=>{if("transparent"===e)return y.some(xo(0,0,0,0));const t=Co.exec(e);if(null!==t)return y.some(To(t[1],t[2],t[3],"1"));const o=vo.exec(e);return null!==o?y.some(To(o[1],o[2],o[3],o[4])):y.none()},Ao=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Ro=(e,t,o)=>l=>{const n=(e=>{const t=Ao(y.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(y.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(y.some(e))}}})(e=>e.unbind()),r=!Ne(o),a=()=>{const a=po(e),s=l=>e.formatter.match(t,{value:o},l.dom,r);r?(l.setActive(!I(a,s)),n.set(e.formatter.formatChanged(t,e=>l.setActive(!e),!0))):(l.setActive(j(a,s)),n.set(e.formatter.formatChanged(t,l.setActive,!1,{value:o})))};return e.initialized?a():e.on("init",a),n.clear},Oo=e=>A(e,"menu"),Do=e=>k(e,e=>{const t=e.text||e.title||"";return Oo(e)?{text:t,items:Do(e.menu)}:{text:t,value:e.value}}),Io=e=>e.length?y.some(Do([{text:"Select...",value:"mce-no-match"},...e])):y.none(),No=(e,t,o,l)=>k(t,t=>{const n=t.text||t.title;return Oo(t)?{type:"nestedmenuitem",text:n,getSubmenuItems:()=>No(e,t.menu,o,l)}:{text:n,type:"togglemenuitem",onAction:()=>l(t.value),onSetup:Ro(e,o,t.value)}}),ko=(e,t)=>o=>{e.execCommand("mceTableApplyCellStyle",!1,{[t]:o})},Mo=e=>F(e,e=>Oo(e)?[{...e,menu:Mo(e.menu)}]:Ne(e.value)?[e]:[]),Po=(e,t)=>{if(0===t.length)return"";const o=new Set(t);return e.split("|").map(e=>e.trim()).map(e=>0===e.length?[]:e.split(/\s+/).filter(e=>o.has(e))).filter(e=>e.length>0).map(e=>e.join(" ")).join(" | ")},Eo=(e,t)=>{const o=e.split("|").map(e=>e.trim()).filter(e=>e.length>0),l=[],n=e=>{e.length>0&&l.push(e.join(" "))};return M(o,e=>{const o=e.split(/\s+/).filter(e=>e.length>0);let l=[];M(o,e=>{const o=t[e];if(void 0===o)l.push(e);else{if(0===o.length)return;{const e=o.split("|").map(e=>e.trim()).filter(e=>e.length>0);1===e.length?l=l.concat(e[0].split(/\s+/).filter(e=>e.length>0)):(n(l),l=[],M(e,e=>{n(e.split(/\s+/).filter(e=>e.length>0))}))}}}),n(l)}),l.join(" | ")},Bo=(e,t,o,l)=>n=>n(No(e,t,o,l)),Fo=(e,t,o)=>{const l=k(t,e=>{return{text:e.title,value:"#"+(o=e.value,(t=o,(e=>ho.test(e)||fo.test(e))(t)?y.some({value:yo(t)}):y.none()).orThunk(()=>_o(o).map(So)).getOrThunk(()=>{const e=document.createElement("canvas");e.height=1,e.width=1;const t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),t.fillStyle="#FFFFFF",t.fillStyle=o,t.fillRect(0,0,1,1);const l=t.getImageData(0,0,1,1).data,n=l[0],r=l[1],a=l[2],s=l[3];return So(xo(n,r,a,s))})).value,type:"choiceitem"};var t,o});return[{type:"fancymenuitem",fancytype:"colorswatch",initData:{colors:l.length>0?l:void 0,allowCustomColors:!1},onAction:t=>{const l="remove"===t.value?"":t.value;e.execCommand("mceTableApplyCellStyle",!1,{[o]:l})}}]},jo=e=>()=>{const t="header"===e.queryCommandValue("mceTableRowType")?"body":"header";e.execCommand("mceTableRowType",!1,{type:t})},qo=e=>()=>{const t="th"===e.queryCommandValue("mceTableColType")?"td":"th";e.execCommand("mceTableColType",!1,{type:t})},Lo=[{name:"width",type:"input",label:"Width",tooltip:"Cell width in pixels or percentage (e.g., 50px or 10%)."},{name:"height",type:"input",label:"Height",tooltip:"Row height in pixels (e.g., 20px). If the height change does not apply to the row, remove the table height in Table Properties and try again."},{name:"backgroundcolor",type:"colorinput",label:"Background color",tooltip:"Background color of the cell."},{name:"celltype",type:"listbox",label:"Cell type",tooltip:"Select the type of cell to apply formatting or styling to.",items:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{name:"scope",type:"listbox",label:"Scope",tooltip:"Defines the scope of the header cell to specify its relationship to rows or columns.",items:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{name:"halign",type:"listbox",label:"Horizontal align",tooltip:"Horizontal alignment of the cell content.",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"valign",type:"listbox",label:"Vertical align",tooltip:"Vertical alignment of the cell content.",items:go}],Ho=e=>{const t=yt(e).split(" "),o=Lo.concat((e=>Io(xt(e)).map(e=>({name:"class",type:"listbox",label:"Class",items:e})))(e).toArray());return o.filter(e=>"name"in e&&t.includes(e.name)).sort((e,o)=>{const l="name"in e?e.name:"",n="name"in o?o.name:"";return t.indexOf(l)-t.indexOf(n)})},Vo=e=>`Style of the outer border of the ${e}.`,$o=e=>{switch(e){case"table":return"Color of the border for the entire table and individual cells.";case"row":case"cell":return`Color of the outer border of the ${e}.`}},Wo=e=>{switch(e){case"table":return"Width of the border for the entire table and individual cells.";case"row":return;case"cell":return"Width of the outer border of the cell."}},zo=(e,t)=>{const o=Bt(e)["border-style"],l=bt(e).some(e=>"none"===e.value),n=[{name:"borderstyle",type:"listbox",label:"Border style",tooltip:Vo(t),items:(o||l?[]:[{text:"None",value:"none"}]).concat(Do(bt(e)))},{name:"bordercolor",type:"colorinput",label:"Border color",tooltip:$o(t)}],r={name:"cell"===t?"borderwidth":"border",type:"input",label:"Border width",tooltip:Wo(t)};return{title:"Border",name:"advanced",items:"cell"===t||"table"===t?[r].concat(n):n}},Uo=(e,t)=>{const o=e.dom;return{setAttrib:(e,l)=>{o.setAttrib(t,e,l)},setStyle:(e,l)=>{o.setStyle(t,e,l)},setFormat:(o,l)=>{""===l?e.formatter.remove(o,{value:null},t,!0):e.formatter.apply(o,{value:l},t)}}},Go=ee("th"),Ko=(e,t)=>e&&t?"sectionCells":e?"section":"cells",Jo=e=>{const t=k(e,e=>(e=>{const t="thead"===e.section,o=Ae((e=>{const t=P(e,e=>Go(e.element));return 0===t.length?y.some("td"):t.length===e.length?y.some("th"):y.none()})(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:Ko(t,o)}:{type:"body"}})(e).type),o=D(t,"header"),l=D(t,"footer");if(o||l){const e=D(t,"body");return!o||e||l?o||e||!l?y.none():y.some("footer"):y.some("header")}return y.some("body")},Qo=(e,t)=>L(e.all,e=>B(e.cells,e=>z(t,e.element))),Xo=(e,t,o)=>{const l=(e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(o);return t})(k(t.selection,t=>{return(l=t,((e,t,o=h)=>o(t)?y.none():D(e,G(t))?y.some(t):me(t,e.join(","),e=>$(e,"table")||o(e)))(["td","th"],l,n)).bind(t=>Qo(e,t)).filter(o);var l,n})).map(e=>({...e,elementRect:e.element.dom.getBoundingClientRect()}));return n=l,l.length>0?y.some(n):y.none();var n},Yo=(e,t)=>Xo(e,t,f),Zo=(e,t)=>j(t,t=>((e,t)=>Qo(e,t).exists(e=>!e.isLocked))(e,t)),el=(e,t)=>((e,t)=>t.mergable)(0,t).filter(t=>Zo(e,t.cells)),tl=(e,t)=>((e,t)=>t.unmergable)(0,t).filter(t=>Zo(e,t)),ol=((e=>{if(!n(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};M(e,(l,r)=>{const a=w(l);if(1!==a.length)throw new Error("one and only one name per case");const s=a[0],c=l[s];if(void 0!==o[s])throw new Error("duplicate key detected:"+s);if("cata"===s)throw new Error("cannot have a case named cata (sorry)");if(!n(c))throw new Error("case arguments must be an array");t.push(s),o[s]=(...o)=>{const l=o.length;if(l!==c.length)throw new Error("Wrong number of arguments to case "+s+". Expected "+c.length+" ("+c+"), got "+l);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const l=w(e);if(t.length!==l.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+l.join(","));if(!j(t,e=>D(l,e)))throw new Error("Not all branches were specified when using match. Specified: "+l.join(", ")+"\nRequired: "+t.join(", "));return e[s].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:s,params:o})}}}})})([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}]),(e,t)=>{const o=Qe(e);return Yo(o,t).bind(e=>{const t=e[e.length-1],l=e[0].row,n=t.row+t.rowspan,r=o.all.slice(l,n);return Jo(r)}).getOr("")}),ll=e=>{return Oe(e,"rgb")?_o(t=e).map(So).map(e=>"#"+e.value).getOr(t):e;var t},nl=e=>{const t=V.fromDom(e);return{borderwidth:Be(t,"border-width").getOr(""),borderstyle:Be(t,"border-style").getOr(""),bordercolor:Be(t,"border-color").map(ll).getOr(""),backgroundcolor:Be(t,"background-color").map(ll).getOr("")}},rl=e=>{const t=e[0],o=e.slice(1);return M(o,e=>{M(w(t),o=>{C(e,(e,l)=>{const n=t[o];""!==n&&o===l&&n!==e&&(t[o]="class"===o?"mce-no-match":"")})})}),t},al=(e,t,o,l)=>B(e,e=>!a(o.formatter.matchNode(l,t+e))).getOr(""),sl=b(al,["left","center","right"],"align"),cl=b(al,["top","middle","bottom"],"valign"),il=e=>$e(V.fromDom(e)).map(t=>{const o={selection:no(e.cells)};return ol(t,o)}).getOr(""),ml=(e,t)=>{if(!t||"double"!==t)return e;const o=parseFloat(e);return void 0!==o&&(0===o||o>=3)?e:"3px"},dl=(e,t)=>{const o=Qe(e),l=(e=>F(e.all,e=>e.cells))(o),n=P(l,e=>I(t,t=>z(e.element,t)));return k(n,e=>({element:e.element.dom,column:Ze(o,e.column).map(e=>e.element.dom)}))},ul=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact(()=>{((e,t,o,l)=>{const n=v(l,(e,t)=>o[t]!==e);x(n)>0&&t.length>=1&&$e(t[0]).each(o=>{const r=dl(o,t),a=x(v(n,(e,t)=>"scope"!==t&&"celltype"!==t))>0,s=_(n,"celltype");(a||_(n,"scope"))&&((e,t,o,l)=>{const n=1===t.length,r=new Set;M(t,t=>{const a=t.element,s=n?f:l,c=Uo(e,a);if(((e,t,o,l)=>{l("scope")&&e.setAttrib("scope",o.scope),l("class")&&"mce-no-match"!==o.class&&e.setAttrib("class",o.class),l("width")&&t.setStyle("width",fe(o.width))})(c,t.column.map(t=>Uo(e,t)).getOr(c),o,s),gt(e)&&((e,t,o)=>{if(o("backgroundcolor")&&e.setFormat("tablecellbackgroundcolor",t.backgroundcolor),o("bordercolor")&&e.setFormat("tablecellbordercolor",t.bordercolor),o("borderstyle")&&e.setFormat("tablecellborderstyle",t.borderstyle),o("borderwidth")||"double"===t.borderstyle){const o=ml(t.borderwidth,t.borderstyle);e.setFormat("tablecellborderwidth",fe(o))}})(c,o,s),s("height")){const t=a.parentElement;null===t||r.has(t)||(r.add(t),e.dom.setStyle(t,"height",fe(o.height)),l("height")&&Array.from(t.cells).forEach(t=>e.dom.setStyle(t,"height",null)))}l("halign")&&ot(e,a,o.halign),l("valign")&&((e,t,o)=>{et.each("top middle bottom".split(" "),l=>{l!==o&&e.formatter.remove("valign"+l,{},t)}),o&&e.formatter.apply("valign"+o,{},t)})(e,a,o.valign)})})(e,r,l,b(_,n)),s&&((e,t)=>{e.execCommand("mceTableCellType",!1,{type:t.celltype,no_events:!0})})(e,l),lt(e,o.dom,{structure:s,style:a})})})(e,t,o,n),e.focus()})},pl=e=>{const t=po(e);if(0===t.length)return;const o=((e,t)=>{const o=$e(t[0]).map(o=>k(dl(o,t),t=>((e,t,o,l)=>{const n=e.dom,r=l.getOr(t),a=t.parentElement;return{width:(c=r,i="width",n.getStyle(c,i)||n.getAttrib(c,i)),height:a?n.getStyle(a,"height")||n.getAttrib(a,"height"):"",scope:n.getAttrib(t,"scope"),celltype:(s=t,s.nodeName.toLowerCase()),class:n.getAttrib(t,"class",""),halign:sl(e,t),valign:cl(e,t),...o?nl(t):{}};var s,c,i})(e,t.element,gt(e),t.column)));return rl(o.getOrDie())})(e,t),l={type:"tabpanel",tabs:[{title:"General",name:"general",items:Ho(e)},zo(e,"cell")]},n={type:"panel",items:[{type:"grid",columns:2,items:Ho(e)}]};e.windowManager.open({title:"Cell Properties",size:"normal",body:gt(e)?l:n,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:o,onSubmit:b(ul,e,t,o)})},bl=[{type:"listbox",name:"type",label:"Row type",tooltip:"Select the type of row to apply formatting or styling to.",items:[{text:"Header",value:"header"},{text:"Body",value:"body"},{text:"Footer",value:"footer"}]},{type:"listbox",name:"align",label:"Alignment",tooltip:"Alignment of the content within the cells in the row.",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"backgroundcolor",type:"colorinput",label:"Background color",tooltip:"Changes the background color of all cells in the row, except for those set individually through Cell Properties."}],gl=e=>{const t=wt(e).split(" "),o=bl.concat((e=>Io(Tt(e)).map(e=>({name:"class",type:"listbox",label:"Class",items:e})))(e).toArray());return o.filter(e=>"name"in e&&t.includes(e.name)).sort((e,o)=>{const l="name"in e?e.name:"",n="name"in o?o.name:"";return t.indexOf(l)-t.indexOf(n)})},hl=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact(()=>{((e,t,o,l)=>{const n=v(l,(e,t)=>o[t]!==e);if(x(n)>0){const o=_(n,"type"),r=!o||x(n)>1;r&&((e,t,o,l)=>{const n=1===t.length?f:l;M(t,t=>{const r=Uo(e,t);((e,t,o)=>{o("class")&&"mce-no-match"!==t.class&&e.setAttrib("class",t.class)})(r,o,n),ht(e)&&((e,t,o)=>{o("backgroundcolor")&&e.setStyle("background-color",t.backgroundcolor),o("bordercolor")&&e.setStyle("border-color",t.bordercolor),o("borderstyle")&&e.setStyle("border-style",t.borderstyle)})(r,o,n),l("align")&&ot(e,t,o.align)})})(e,t,l,b(_,n)),o&&((e,t)=>{e.execCommand("mceTableRowType",!1,{type:t.type,no_events:!0})})(e,l),$e(V.fromDom(t[0])).each(t=>lt(e,t.dom,{structure:o,style:r}))}})(e,t,o,n),e.focus()})},fl=e=>{const t=bo(ye(e),co.selected);if(0===t.length)return;const o=k(t,t=>((e,t,o)=>({class:e.dom.getAttrib(t,"class",""),type:il(t),align:sl(e,t),...o?nl(t):{}}))(e,t.dom,ht(e))),l=rl(o),n={type:"tabpanel",tabs:[{title:"General",name:"general",items:gl(e)},zo(e,"row")]},r={type:"panel",items:[{type:"grid",columns:2,items:gl(e)}]};e.windowManager.open({title:"Row Properties",size:"normal",body:ht(e)?n:r,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:l,onSubmit:b(hl,e,k(t,e=>e.dom),l)})},yl=(e,t,o)=>{const l=o?[{type:"input",name:"cols",label:"Cols",inputMode:"numeric"},{type:"input",name:"rows",label:"Rows",inputMode:"numeric"}]:[],n=[{type:"input",name:"width",label:"Width",tooltip:"Total width of the table in pixels or percentage (e.g., 500px or 100%)."},{type:"input",name:"height",label:"Height",tooltip:"Total height of the table in pixels (e.g., 500px)."},{type:"input",name:"cellspacing",label:"Cell spacing",inputMode:"numeric",tooltip:"The space between individual table cells, measured in pixels (e.g., 5px)."},{type:"input",name:"cellpadding",label:"Cell padding",inputMode:"numeric",tooltip:"Inner text padding in cells, e.g., 0px 5px (where 0px is vertical padding, and 5px is horizontal padding)."},{name:"backgroundcolor",type:"colorinput",label:"Background color",tooltip:"Changes the background color of all cells in the table, except for those set individually through Cell Properties or Row Properties."},{type:"label",label:"Caption",name:"caption",tooltip:"Adds a caption above the table, which can be edited.",items:[{type:"checkbox",name:"caption",label:"Show caption"}]},{type:"listbox",name:"align",label:"Alignment",tooltip:"Alignment of the entire table (not the content within the table).",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}];t.length>0&&n.push({name:"class",type:"listbox",label:"Class",items:t});const r=St(e).split(" "),a=n.filter(e=>"name"in e&&r.includes(e.name)).sort((e,t)=>{const o="name"in e?e.name:"",l="name"in t?t.name:"";return r.indexOf(o)-r.indexOf(l)});return l.concat(a)},wl=(e,t,o,n)=>{if("TD"===t.tagName||"TH"===t.tagName)l(o)&&s(n)?e.setStyle(t,o,n):e.setStyles(t,o);else if(t.children)for(let l=0;l<t.children.length;l++)wl(e,t.children[l],o,n)},Sl=(e,t,o,l)=>{const n=e.dom,r=l.getData(),s=v(r,(e,t)=>o[t]!==e);l.close(),e.undoManager.transact(()=>{if(!t){const o=ke(r.cols).getOr(1),l=ke(r.rows).getOr(1);e.execCommand("mceInsertTable",!1,{rows:l,columns:o}),t=uo(ye(e),he(e)).bind(t=>$e(t,he(e))).map(e=>e.dom).getOrDie()}if(x(s)>0){const o={border:_(s,"border"),bordercolor:_(s,"bordercolor"),cellpadding:_(s,"cellpadding")};((e,t,o,l)=>{const n=e.dom,r={},s={},c=vt(e),i=ft(e),m=0===parseFloat(o.border),d=ml(o.border,o.borderstyle);if(a(o.class)||"mce-no-match"===o.class||(r.class=o.class),s.height=fe(o.height),c?s.width=fe(o.width):n.getAttrib(t,"width")&&(r.width=(e=>e?e.replace(/px$/,""):"")(o.width)),c?(m?(r.border=0,s["border-width"]=""):(s["border-width"]=fe(d),r.border=1),s["border-spacing"]=fe(o.cellspacing)):(r.border=m?0:d,r.cellpadding=o.cellpadding,r.cellspacing=o.cellspacing),c&&t.children){const e={};if(m?e["border-width"]="":l.border&&(e["border-width"]=fe(d)),l.cellpadding&&(e.padding=fe(o.cellpadding)),i&&l.bordercolor&&(e["border-color"]=o.bordercolor),!(e=>{for(const t in e)if(S.call(e,t))return!1;return!0})(e))for(let o=0;o<t.children.length;o++)wl(n,t.children[o],e)}if(i){const e=o;s["background-color"]=e.backgroundcolor,s["border-color"]=e.bordercolor,s["border-style"]=e.borderstyle}n.setStyles(t,{...Bt(e),...s}),n.setAttribs(t,{...Ft(e),...r})})(e,t,r,o);const l=n.select("caption",t)[0];(l&&!r.caption||!l&&r.caption)&&e.execCommand("mceTableToggleCaption"),ot(e,t,r.align)}if(e.focus(),e.addVisual(),x(s)>0){const o=_(s,"caption"),l=!o||x(s)>1;lt(e,t,{structure:o,style:l})}})},Cl=(e,t)=>{const o=e.dom;let l,n=((e,t)=>{const o=Bt(e),l=Ft(e),n=t?{borderstyle:T(o,"border-style").getOr(""),bordercolor:ll(T(o,"border-color").getOr("")),backgroundcolor:ll(T(o,"background-color").getOr(""))}:{};return{height:"",width:"100%",cellspacing:"",cellpadding:"",caption:!1,class:"",align:"",border:"",...o,...l,...n,...(()=>{const t=o["border-width"];return vt(e)&&t?{border:t}:T(l,"border").fold(()=>({}),e=>({border:e}))})(),...{...T(o,"border-spacing").or(T(l,"cellspacing")).fold(()=>({}),e=>({cellspacing:e})),...T(o,"border-padding").or(T(l,"cellpadding")).fold(()=>({}),e=>({cellpadding:e}))}}})(e,ft(e));t?(n.cols="1",n.rows="1",ft(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor="")):(l=o.getParent(e.selection.getStart(),"table",e.getBody()),l?n=((e,t,o)=>{const l=e.dom,n=vt(e)?l.getStyle(t,"border-spacing")||l.getAttrib(t,"cellspacing"):l.getAttrib(t,"cellspacing")||l.getStyle(t,"border-spacing"),r=vt(e)?tt(l,t,"padding")||l.getAttrib(t,"cellpadding"):l.getAttrib(t,"cellpadding")||tt(l,t,"padding");return{width:l.getStyle(t,"width")||l.getAttrib(t,"width"),height:l.getStyle(t,"height")||l.getAttrib(t,"height"),cellspacing:null!=n?n:"",cellpadding:null!=r?r:"",border:((t,o)=>{const l=Be(V.fromDom(o),"border-width");return vt(e)&&l.isSome()?l.getOr(""):t.getAttrib(o,"border")||tt(e.dom,o,"border-width")||tt(e.dom,o,"border")||""})(l,t),caption:!!l.select("caption",t)[0],class:l.getAttrib(t,"class",""),align:sl(e,t),...o?nl(t):{}}})(e,l,ft(e)):ft(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor=""));const r=Io(_t(e));r.isSome()&&n.class&&(n.class=n.class.replace(/\s*mce\-item\-table\s*/g,""));const a={type:"grid",columns:2,items:yl(e,r.getOr([]),t)},s=ft(e)?{type:"tabpanel",tabs:[{title:"General",name:"general",items:[a]},zo(e,"table")]}:{type:"panel",items:[a]};e.windowManager.open({title:"Table Properties",size:"normal",body:s,onSubmit:b(Sl,e,l,n),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:n})},vl=e=>{C({mceTableProps:b(Cl,e,!1),mceTableRowProps:b(fl,e),mceTableCellProps:b(pl,e),mceInsertTableDialog:b(Cl,e,!0)},(t,o)=>e.addCommand(o,()=>{return o=t,void((e=>{return(t=e,o=ee("table"),ce((e,t)=>t(e),ie,t,o,void 0)).forall(be);var t,o})(ye(e))&&o());var o}))},xl=u,Tl=e=>{const t=(e,t)=>Te(e,t).exists(e=>parseInt(e,10)>1);return e.length>0&&j(e,e=>t(e,"rowspan")||t(e,"colspan"))?y.some(e):y.none()},_l=(e,t,o)=>{return t.length<=1?y.none():(l=e,n=o.firstSelectedSelector,r=o.lastSelectedSelector,lo(l,n,r).bind(e=>{const t=e=>z(l,e),o="thead,tfoot,tbody,table",n=me(e.first,o,t),r=me(e.last,o,t);return n.bind(t=>r.bind(o=>z(t,o)?((e,t,o)=>{const l=zt(e);return Wt(l,t,o)})(e.table,e.first,e.last):y.none()))})).map(e=>({bounds:e,cells:t}));var l,n,r},Al=e=>{const t=Ao(y.none()),o=Ao([]);let l=y.none();const n=ee("caption"),r=e=>l.forall(t=>!t[e]),a=()=>mo(ye(e),he(e)).bind(t=>{return o=Re($e(t),mo((e=>V.fromDom(e.selection.getEnd()))(e),he(e)).bind($e),(o,l)=>z(o,l)?n(t)?y.some((e=>({element:e,mergable:y.none(),unmergable:y.none(),selection:[e]}))(t)):y.some(((e,t,o)=>({element:o,mergable:_l(t,e,co),unmergable:Tl(e),selection:xl(e)}))(po(e),o,t)):y.none()),o.bind(u);var o}),s=e=>$e(e.element).map(t=>{const o=Qe(t),l=Yo(o,e).getOr([]),n=E(l,(e,t)=>(t.isLocked&&(e.onAny=!0,0===t.column?e.onFirst=!0:t.column+t.colspan>=o.grid.columns&&(e.onLast=!0)),e),{onAny:!1,onFirst:!1,onLast:!1});return{mergeable:el(o,e).isSome(),unmergeable:tl(o,e).isSome(),locked:n}}),c=()=>{t.set((e=>{let t,o=!1;return(...l)=>(o||(o=!0,t=e.apply(null,l)),t)})(a)()),l=t.get().bind(s),M(o.get(),g)},i=e=>(e(),o.set(o.get().concat([e])),()=>{o.set(P(o.get(),t=>t!==e))}),m=(o,l)=>i(()=>t.get().fold(()=>{o.setEnabled(!1)},t=>{o.setEnabled(!l(t)&&e.selection.isEditable())})),d=(o,l,n)=>i(()=>t.get().fold(()=>{o.setEnabled(!1),o.setActive(!1)},t=>{o.setEnabled(!l(t)&&e.selection.isEditable()),o.setActive(n(t))})),p=e=>l.exists(t=>t.locked[e]),b=(t,o)=>l=>d(l,e=>n(e.element),()=>e.queryCommandValue(t)===o),f=b("mceTableRowType","header"),w=b("mceTableColType","th");return e.on("NodeChange ExecCommand TableSelectorChange",c),{onSetupTable:e=>m(e,e=>!1),onSetupCellOrRow:e=>m(e,e=>n(e.element)),onSetupColumn:e=>t=>m(t,t=>n(t.element)||p(e)),onSetupPasteable:e=>t=>m(t,t=>n(t.element)||e().isNone()),onSetupPasteableColumn:(e,t)=>o=>m(o,o=>n(o.element)||e().isNone()||p(t)),onSetupMergeable:e=>m(e,e=>r("mergeable")),onSetupUnmergeable:e=>m(e,e=>r("unmergeable")),resetTargets:c,onSetupTableWithCaption:t=>d(t,h,t=>$e(t.element,he(e)).exists(e=>de(e,"caption").isSome())),onSetupTableRowHeaders:f,onSetupTableColumnHeaders:w,targets:t.get}};var Rl=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const Ol="x-tinymce/dom-table-",Dl=Ol+"rows",Il=Ol+"columns",Nl=e=>{var t;const o=null!==(t=Rl.read())&&void 0!==t?t:[];return L(o,t=>y.from(t.getType(e)))},kl=()=>Nl(Dl),Ml=()=>Nl(Il),Pl=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}},El=e=>{const t="tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter";return Lt(e)?Po(t,Dt(e)):t},Bl=e=>{const t="tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter";return Ht(e)?Po(t,It(e)):t},Fl=e=>{const t="tablecellprops tablemergecells tablesplitcells";return Vt(e)?Po(t,Nt(e)):t},jl=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("table",e=>{const t=Al(e);(e=>{const t=e.options.register;t("table_border_widths",{processor:"object[]",default:st}),t("table_border_styles",{processor:"object[]",default:ct}),t("table_cell_advtab",{processor:"boolean",default:!0}),t("table_row_advtab",{processor:"boolean",default:!0}),t("table_advtab",{processor:"boolean",default:!0}),t("table_cell_inputs",{processor:"string",default:"width height celltype scope halign valign backgroundcolor class"}),t("table_row_inputs",{processor:"string",default:"type align backgroundcolor class"}),t("table_inputs",{processor:"string",default:"width height cellspacing cellpadding backgroundcolor caption align class"}),t("table_grid",{processor:"boolean",default:!at.deviceType.isTouch()}),t("table_cell_class_list",{processor:"object[]",default:[]}),t("table_row_class_list",{processor:"object[]",default:[]}),t("table_class_list",{processor:"object[]",default:[]}),t("table_toolbar",{processor:"string",default:"tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"}),t("table_contextmenu",{processor:"string[]",default:[]}),t("table_contextmenu_flatten",{processor:"boolean",default:!1}),t("table_row_contextmenu",{processor:"string[]",default:[]}),t("table_column_contextmenu",{processor:"string[]",default:[]}),t("table_cell_contextmenu",{processor:"string[]",default:[]}),t("table_background_color_map",{processor:"object[]",default:[]}),t("table_border_color_map",{processor:"object[]",default:[]})})(e),vl(e),((e,t)=>{const o=t=>()=>e.execCommand(t),l=(t,l)=>!!e.queryCommandSupported(l.command)&&(e.ui.registry.addMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)}),!0),n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},r=t=>{e.execCommand("mceInsertTable",!1,{rows:t.numRows,columns:t.numColumns})},a=[l("tableinsertrowbefore",{text:"Insert row before",icon:"table-insert-row-above",command:"mceTableInsertRowBefore",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{text:"Insert row after",icon:"table-insert-row-after",command:"mceTableInsertRowAfter",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{text:"Delete row",icon:"table-delete-row",command:"mceTableDeleteRow",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{text:"Row properties",icon:"table-row-properties",command:"mceTableRowProps",onSetup:t.onSetupCellOrRow}),l("tablecutrow",{text:"Cut row",icon:"cut-row",command:"mceTableCutRow",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{text:"Copy row",icon:"duplicate-row",command:"mceTableCopyRow",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{text:"Paste row before",icon:"paste-row-before",command:"mceTablePasteRowBefore",onSetup:t.onSetupPasteable(kl)}),l("tablepasterowafter",{text:"Paste row after",icon:"paste-row-after",command:"mceTablePasteRowAfter",onSetup:t.onSetupPasteable(kl)})],s=[l("tableinsertcolumnbefore",{text:"Insert column before",icon:"table-insert-column-before",command:"mceTableInsertColBefore",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolumnafter",{text:"Insert column after",icon:"table-insert-column-after",command:"mceTableInsertColAfter",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecolumn",{text:"Delete column",icon:"table-delete-column",command:"mceTableDeleteCol",onSetup:t.onSetupColumn("onAny")}),l("tablecutcolumn",{text:"Cut column",icon:"cut-column",command:"mceTableCutCol",onSetup:t.onSetupColumn("onAny")}),l("tablecopycolumn",{text:"Copy column",icon:"duplicate-column",command:"mceTableCopyCol",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolumnbefore",{text:"Paste column before",icon:"paste-column-before",command:"mceTablePasteColBefore",onSetup:t.onSetupPasteableColumn(Ml,"onFirst")}),l("tablepastecolumnafter",{text:"Paste column after",icon:"paste-column-after",command:"mceTablePasteColAfter",onSetup:t.onSetupPasteableColumn(Ml,"onLast")})],i=[l("tablecellprops",{text:"Cell properties",icon:"table-cell-properties",command:"mceTableCellProps",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{text:"Merge cells",icon:"table-merge-cells",command:"mceTableMergeCells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{text:"Split cell",icon:"table-split-cells",command:"mceTableSplitCells",onSetup:t.onSetupUnmergeable})];Ct(e)?e.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"inserttable",onAction:r}],onSetup:jl(e)}):e.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:o("mceInsertTableDialog"),onSetup:jl(e)}),e.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:o("mceInsertTableDialog"),onSetup:jl(e)}),l("tableprops",{text:"Table properties",onSetup:t.onSetupTable,command:"mceTableProps"}),l("deletetable",{text:"Delete table",icon:"table-delete-table",onSetup:t.onSetupTable,command:"mceTableDelete"});const m="tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter",u=Lt(e)?Po(m,Dt(e)):m;D(a,!0)&&u.length>0&&e.ui.registry.addNestedMenuItem("row",{type:"nestedmenuitem",text:"Row",getSubmenuItems:d(u)});const p="tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter",b=Ht(e)?Po(p,It(e)):p;D(s,!0)&&b.length>0&&e.ui.registry.addNestedMenuItem("column",{type:"nestedmenuitem",text:"Column",getSubmenuItems:d(b)});const g="tablecellprops tablemergecells tablesplitcells",h=Vt(e)?Po(g,Nt(e)):g;D(i,!0)&&h.length>0&&e.ui.registry.addNestedMenuItem("cell",{type:"nestedmenuitem",text:"Cell",getSubmenuItems:d(h)}),e.ui.registry.addContextMenu("table",{update:()=>{t.resetTargets();const o=t.targets().fold(d(""),e=>"caption"===G(e.element)?"tableprops deletetable":"cell row column | advtablesort | tableprops deletetable"),l=jt(e)?Po(o,Rt(e)):o;return qt(e)&&l.length>0?Eo(l,{cell:h,row:u,column:b}):l}});const f=Mo(_t(e));0!==f.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addNestedMenuItem("tableclass",{icon:"table-classes",text:"Table styles",getSubmenuItems:()=>No(e,f,"tableclass",t=>e.execCommand("mceTableToggleClass",!1,t)),onSetup:t.onSetupTable});const y=Mo(xt(e));0!==y.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addNestedMenuItem("tablecellclass",{icon:"table-cell-classes",text:"Cell styles",getSubmenuItems:()=>No(e,y,"tablecellclass",t=>e.execCommand("mceTableCellToggleClass",!1,t)),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addNestedMenuItem("tablecellvalign",{icon:"vertical-align",text:"Vertical align",getSubmenuItems:()=>No(e,go,"tablecellverticalalign",ko(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderwidth",{icon:"border-width",text:"Border width",getSubmenuItems:()=>No(e,pt(e),"tablecellborderwidth",ko(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderstyle",{icon:"border-style",text:"Border style",getSubmenuItems:()=>No(e,bt(e),"tablecellborderstyle",ko(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbackgroundcolor",{icon:"cell-background-color",text:"Background color",getSubmenuItems:()=>Fo(e,kt(e),"background-color"),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbordercolor",{icon:"cell-border-color",text:"Border color",getSubmenuItems:()=>Fo(e,Mt(e),"border-color"),onSetup:t.onSetupCellOrRow})),n("tablecaption",{icon:"table-caption",text:"Table caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{text:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:jo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{text:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:qo(e),onSetup:t.onSetupTableRowHeaders})})(e,t),((e,t)=>{e.ui.registry.addMenuButton("table",{tooltip:"Table",icon:"table",onSetup:Pl(e),fetch:t=>t((e=>{const t="inserttable | cell row column | advtablesort | tableprops deletetable",o=jt(e)?Po(t,["inserttable",...Rt(e)]):t;return qt(e)&&o.length>0?Eo(o,{cell:Fl(e),row:El(e),column:Bl(e)}):o})(e))});const o=t=>()=>e.execCommand(t),l=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})};l("tableprops",{tooltip:"Table properties",command:"mceTableProps",icon:"table",onSetup:t.onSetupTable}),l("tabledelete",{tooltip:"Delete table",command:"mceTableDelete",icon:"table-delete-table",onSetup:t.onSetupTable}),l("tablecellprops",{tooltip:"Cell properties",command:"mceTableCellProps",icon:"table-cell-properties",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{tooltip:"Merge cells",command:"mceTableMergeCells",icon:"table-merge-cells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{tooltip:"Split cell",command:"mceTableSplitCells",icon:"table-split-cells",onSetup:t.onSetupUnmergeable}),l("tableinsertrowbefore",{tooltip:"Insert row before",command:"mceTableInsertRowBefore",icon:"table-insert-row-above",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{tooltip:"Insert row after",command:"mceTableInsertRowAfter",icon:"table-insert-row-after",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{tooltip:"Delete row",command:"mceTableDeleteRow",icon:"table-delete-row",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{tooltip:"Row properties",command:"mceTableRowProps",icon:"table-row-properties",onSetup:t.onSetupCellOrRow}),l("tableinsertcolbefore",{tooltip:"Insert column before",command:"mceTableInsertColBefore",icon:"table-insert-column-before",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolafter",{tooltip:"Insert column after",command:"mceTableInsertColAfter",icon:"table-insert-column-after",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecol",{tooltip:"Delete column",command:"mceTableDeleteCol",icon:"table-delete-column",onSetup:t.onSetupColumn("onAny")}),l("tablecutrow",{tooltip:"Cut row",command:"mceTableCutRow",icon:"cut-row",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{tooltip:"Copy row",command:"mceTableCopyRow",icon:"duplicate-row",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{tooltip:"Paste row before",command:"mceTablePasteRowBefore",icon:"paste-row-before",onSetup:t.onSetupPasteable(kl)}),l("tablepasterowafter",{tooltip:"Paste row after",command:"mceTablePasteRowAfter",icon:"paste-row-after",onSetup:t.onSetupPasteable(kl)}),l("tablecutcol",{tooltip:"Cut column",command:"mceTableCutCol",icon:"cut-column",onSetup:t.onSetupColumn("onAny")}),l("tablecopycol",{tooltip:"Copy column",command:"mceTableCopyCol",icon:"duplicate-column",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolbefore",{tooltip:"Paste column before",command:"mceTablePasteColBefore",icon:"paste-column-before",onSetup:t.onSetupPasteableColumn(Ml,"onFirst")}),l("tablepastecolafter",{tooltip:"Paste column after",command:"mceTablePasteColAfter",icon:"paste-column-after",onSetup:t.onSetupPasteableColumn(Ml,"onLast")}),l("tableinsertdialog",{tooltip:"Insert table",command:"mceInsertTableDialog",icon:"table",onSetup:Pl(e)});const r=Mo(_t(e));0!==r.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addMenuButton("tableclass",{icon:"table-classes",tooltip:"Table styles",fetch:Bo(e,r,"tableclass",t=>e.execCommand("mceTableToggleClass",!1,t)),onSetup:t.onSetupTable});const a=Mo(xt(e));0!==a.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addMenuButton("tablecellclass",{icon:"table-cell-classes",tooltip:"Cell styles",fetch:Bo(e,a,"tablecellclass",t=>e.execCommand("mceTableCellToggleClass",!1,t)),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addMenuButton("tablecellvalign",{icon:"vertical-align",tooltip:"Vertical align",fetch:Bo(e,go,"tablecellverticalalign",ko(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderwidth",{icon:"border-width",tooltip:"Border width",fetch:Bo(e,pt(e),"tablecellborderwidth",ko(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderstyle",{icon:"border-style",tooltip:"Border style",fetch:Bo(e,bt(e),"tablecellborderstyle",ko(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbackgroundcolor",{icon:"cell-background-color",tooltip:"Background color",fetch:t=>t(Fo(e,kt(e),"background-color")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbordercolor",{icon:"cell-border-color",tooltip:"Border color",fetch:t=>t(Fo(e,Mt(e),"border-color")),onSetup:t.onSetupCellOrRow})),n("tablecaption",{tooltip:"Table caption",icon:"table-caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{tooltip:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:jo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{tooltip:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:qo(e),onSetup:t.onSetupTableColumnHeaders})})(e,t),(e=>{const t=At(e);t.length>0&&e.ui.registry.addContextToolbar("table",{predicate:t=>e.dom.is(t,"table")&&e.getBody().contains(t)&&e.dom.isEditable(t.parentNode),items:t,scope:"node",position:"node"})})(e)})}();
4
+ !function(){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager");const t=e=>t=>(e=>{const t=typeof e;return null===e?"null":"object"===t&&Array.isArray(e)?"array":"object"===t&&(o=l=e,(n=String).prototype.isPrototypeOf(o)||(null===(r=l.constructor)||void 0===r?void 0:r.name)===n.name)?"string":t;var o,l,n,r})(t)===e,o=e=>t=>typeof t===e,l=t("string"),n=t("array"),r=o("boolean"),a=e=>void 0===e;const s=e=>!(e=>null==e)(e),c=o("function"),i=o("number"),m=()=>{},d=e=>()=>e,u=e=>e,p=(e,t)=>e===t;function b(e,...t){return(...o)=>{const l=t.concat(o);return e.apply(null,l)}}const g=e=>{e()},h=d(!1),f=d(!0);class y{constructor(e,t){this.tag=e,this.value=t}static some(e){return new y(!0,e)}static none(){return y.singletonNone}fold(e,t){return this.tag?t(this.value):e()}isSome(){return this.tag}isNone(){return!this.tag}map(e){return this.tag?y.some(e(this.value)):y.none()}bind(e){return this.tag?e(this.value):y.none()}exists(e){return this.tag&&e(this.value)}forall(e){return!this.tag||e(this.value)}filter(e){return!this.tag||e(this.value)?this:y.none()}getOr(e){return this.tag?this.value:e}or(e){return this.tag?this:e}getOrThunk(e){return this.tag?this.value:e()}orThunk(e){return this.tag?this:e()}getOrDie(e){if(this.tag)return this.value;throw new Error(null!=e?e:"Called getOrDie on None")}static from(e){return s(e)?y.some(e):y.none()}getOrNull(){return this.tag?this.value:null}getOrUndefined(){return this.value}each(e){this.tag&&e(this.value)}toArray(){return this.tag?[this.value]:[]}toString(){return this.tag?`some(${this.value})`:"none()"}}y.singletonNone=new y(!1);const w=Object.keys,S=Object.hasOwnProperty,C=(e,t)=>{const o=w(e);for(let l=0,n=o.length;l<n;l++){const n=o[l];t(e[n],n)}},v=(e,t)=>{const o={};var l;return((e,t,o,l)=>{C(e,(e,n)=>{(t(e,n)?o:l)(e,n)})})(e,t,(l=o,(e,t)=>{l[t]=e}),m),o},x=e=>w(e).length,T=(e,t)=>_(e,t)?y.from(e[t]):y.none(),_=(e,t)=>S.call(e,t),A=(e,t)=>_(e,t)&&void 0!==e[t]&&null!==e[t],R=Array.prototype.indexOf,O=Array.prototype.push,D=(e,t)=>((e,t)=>R.call(e,t))(e,t)>-1,I=(e,t)=>{for(let o=0,l=e.length;o<l;o++)if(t(e[o],o))return!0;return!1},N=(e,t)=>{const o=[];for(let l=0;l<e;l++)o.push(t(l));return o},k=(e,t)=>{const o=e.length,l=new Array(o);for(let n=0;n<o;n++){const o=e[n];l[n]=t(o,n)}return l},M=(e,t)=>{for(let o=0,l=e.length;o<l;o++)t(e[o],o)},P=(e,t)=>{const o=[];for(let l=0,n=e.length;l<n;l++){const n=e[l];t(n,l)&&o.push(n)}return o},E=(e,t,o)=>(M(e,(e,l)=>{o=t(o,e,l)}),o),B=(e,t)=>((e,t,o)=>{for(let l=0,n=e.length;l<n;l++){const n=e[l];if(t(n,l))return y.some(n);if(o(n,l))break}return y.none()})(e,t,h),F=(e,t)=>(e=>{const t=[];for(let o=0,l=e.length;o<l;++o){if(!n(e[o]))throw new Error("Arr.flatten item "+o+" was not an array, input: "+e);O.apply(t,e[o])}return t})(k(e,t)),j=(e,t)=>{for(let o=0,l=e.length;o<l;++o)if(!0!==t(e[o],o))return!1;return!0},q=(e,t)=>t>=0&&t<e.length?y.some(e[t]):y.none(),L=(e,t)=>{for(let o=0;o<e.length;o++){const l=t(e[o],o);if(l.isSome())return l}return y.none()},H=e=>{if(null==e)throw new Error("Node cannot be null or undefined");return{dom:e}},V={fromHtml:(e,t)=>{const o=(t||document).createElement("div");if(o.innerHTML=e,!o.hasChildNodes()||o.childNodes.length>1){const t="HTML does not have a single root node";throw console.error(t,e),new Error(t)}return H(o.childNodes[0])},fromTag:(e,t)=>{const o=(t||document).createElement(e);return H(o)},fromText:(e,t)=>{const o=(t||document).createTextNode(e);return H(o)},fromDom:H,fromPoint:(e,t,o)=>y.from(e.dom.elementFromPoint(t,o)).map(H)},$=(e,t)=>{const o=e.dom;if(1!==o.nodeType)return!1;{const e=o;if(void 0!==e.matches)return e.matches(t);if(void 0!==e.msMatchesSelector)return e.msMatchesSelector(t);if(void 0!==e.webkitMatchesSelector)return e.webkitMatchesSelector(t);if(void 0!==e.mozMatchesSelector)return e.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")}},W=e=>1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType||0===e.childElementCount,z=(e,t)=>e.dom===t.dom,U=$;"undefined"!=typeof window?window:Function("return this;")();const G=e=>e.dom.nodeName.toLowerCase(),K=e=>e.dom.nodeType,J=e=>t=>K(t)===e,Q=J(1),X=J(3),Y=J(9),Z=J(11),ee=e=>t=>Q(t)&&G(t)===e,te=e=>Y(e)?e:V.fromDom(e.dom.ownerDocument),oe=e=>y.from(e.dom.parentNode).map(V.fromDom),le=e=>y.from(e.dom.nextSibling).map(V.fromDom),ne=e=>k(e.dom.childNodes,V.fromDom),re=c(Element.prototype.attachShadow)&&c(Node.prototype.getRootNode)?e=>V.fromDom(e.dom.getRootNode()):te,ae=e=>V.fromDom(e.dom.host),se=e=>{const t=X(e)?e.dom.parentNode:e.dom;if(null==t||null===t.ownerDocument)return!1;const o=t.ownerDocument;return(e=>{const t=re(e);return Z(o=t)&&s(o.dom.host)?y.some(t):y.none();var o})(V.fromDom(t)).fold(()=>o.body.contains(t),(l=se,n=ae,e=>l(n(e))));var l,n};var ce=(e,t,o,l,n)=>e(o,l)?y.some(o):c(n)&&n(o)?y.none():t(o,l,n);const ie=(e,t,o)=>{let l=e.dom;const n=c(o)?o:h;for(;l.parentNode;){l=l.parentNode;const e=V.fromDom(l);if(t(e))return y.some(e);if(n(e))break}return y.none()},me=(e,t,o)=>ie(e,e=>$(e,t),o),de=(e,t)=>(e=>B(e.dom.childNodes,e=>{return o=V.fromDom(e),$(o,t);var o}).map(V.fromDom))(e),ue=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return W(o)?y.none():y.from(o.querySelector(e)).map(V.fromDom)})(t,e),pe=(e,t,o)=>ce((e,t)=>$(e,t),me,e,t,o),be=(e,t=!1)=>{return se(e)?e.dom.isContentEditable:(o=e,pe(o,"[contenteditable]")).fold(d(t),e=>"true"===ge(e));var o},ge=e=>e.dom.contentEditable,he=e=>t=>z(t,(e=>V.fromDom(e.getBody()))(e)),fe=e=>/^\d+(\.\d+)?$/.test(e)?e+"px":e,ye=e=>V.fromDom(e.selection.getStart()),we=(e,t)=>{let o=[];return M(ne(e),e=>{t(e)&&(o=o.concat([e])),o=o.concat(we(e,t))}),o},Se=(e,t)=>(e=>P(ne(e),e=>$(e,t)))(e),Ce=(e,t)=>((e,t)=>{const o=void 0===t?document:t.dom;return W(o)?[]:k(o.querySelectorAll(e),V.fromDom)})(t,e),ve=(e,t,o)=>{if(!(l(o)||r(o)||i(o)))throw console.error("Invalid call to Attribute.set. Key ",t,":: Value ",o,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,o+"")},xe=(e,t)=>{const o=e.dom.getAttribute(t);return null===o?void 0:o},Te=(e,t)=>y.from(xe(e,t)),_e=(e,t)=>{e.dom.removeAttribute(t)},Ae=(e,t,o=p)=>e.exists(e=>o(e,t)),Re=(e,t,o)=>e.isSome()&&t.isSome()?y.some(o(e.getOrDie(),t.getOrDie())):y.none(),Oe=(e,t)=>((e,t)=>""===t||e.length>=t.length&&e.substr(0,0+t.length)===t)(e,t),De=(Ie=/^\s+|\s+$/g,e=>e.replace(Ie,""));var Ie;const Ne=e=>e.length>0,ke=(e,t=10)=>{const o=parseInt(e,t);return isNaN(o)?y.none():y.some(o)},Me=e=>void 0!==e.style&&c(e.style.getPropertyValue),Pe=(e,t)=>{const o=e.dom,l=window.getComputedStyle(o).getPropertyValue(t);return""!==l||se(e)?l:Ee(o,t)},Ee=(e,t)=>Me(e)?e.style.getPropertyValue(t):"",Be=(e,t)=>{const o=e.dom,l=Ee(o,t);return y.from(l).filter(e=>e.length>0)},Fe=(e,t,o=0)=>Te(e,t).map(e=>parseInt(e,10)).getOr(o),je=(e,t)=>qe(e,t,f),qe=(e,t,o)=>F(ne(e),e=>$(e,t)?o(e)?[e]:[]:qe(e,t,o)),Le=["tfoot","thead","tbody","colgroup"],He=(e,t,o)=>({element:e,rowspan:t,colspan:o}),Ve=(e,t,o)=>({element:e,cells:t,section:o}),$e=(e,t)=>pe(e,"table",t),We=e=>je(e,"tr"),ze=e=>$e(e).fold(d([]),e=>Se(e,"colgroup")),Ue=e=>oe(e).map(e=>{const t=G(e);return(e=>D(Le,e))(t)?t:"tbody"}).getOr("tbody"),Ge=e=>Te(e,"data-snooker-locked-cols").bind(e=>y.from(e.match(/\d+/g))).map(e=>((e,t)=>{const o={};for(let l=0,n=e.length;l<n;l++){const n=e[l];o[String(n)]=t(n,l)}return o})(e,f)),Ke=(e,t)=>e+","+t,Je=e=>{const t={},o=[];var l;const n=(l=e,q(l,0)).map(e=>e.element).bind($e).bind(Ge).getOr({});let r=0,a=0,s=0;const{pass:c,fail:i}=((e,t)=>{const o=[],l=[];for(let n=0,r=e.length;n<r;n++){const r=e[n];(t(r)?o:l).push(r)}return{pass:o,fail:l}})(e,e=>"colgroup"===e.section);M(i,e=>{const l=[];M(e.cells,e=>{let o=0;for(;void 0!==t[Ke(s,o)];)o++;const r=A(n,o.toString()),c=((e,t,o,l,n,r)=>({element:e,rowspan:t,colspan:o,row:l,column:n,isLocked:r}))(e.element,e.rowspan,e.colspan,s,o,r);for(let l=0;l<e.colspan;l++)for(let n=0;n<e.rowspan;n++){const e=o+l,r=Ke(s+n,e);t[r]=c,a=Math.max(a,e+1)}l.push(c)}),r++,o.push(Ve(e.element,l,e.section)),s++});const{columns:m,colgroups:d}=(e=>q(e,e.length-1))(c).map(e=>{const t=(e=>{const t={};let o=0;return M(e.cells,e=>{const l=e.colspan;N(l,n=>{const r=o+n;t[r]=((e,t,o)=>({element:e,colspan:t,column:o}))(e.element,l,r)}),o+=l}),t})(e),o=((e,t)=>({element:e,columns:t}))(e.element,((e,t)=>{const o=[];return C(e,(e,l)=>{o.push(t(e,l))}),o})(t,u));return{colgroups:[o],columns:t}}).getOrThunk(()=>({colgroups:[],columns:{}})),p=((e,t)=>({rows:e,columns:t}))(r,a);return{grid:p,access:t,all:o,columns:m,colgroups:d}},Qe=e=>{const t=(e=>{const t=We(e);return((e,t)=>k(e,e=>{if("colgroup"===G(e)){const t=k((e=>$(e,"colgroup")?Se(e,"col"):F(ze(e),e=>Se(e,"col")))(e),e=>{const t=Fe(e,"span",1);return He(e,1,t)});return Ve(e,t,"colgroup")}{const o=k((e=>je(e,"th,td"))(e),e=>{const t=Fe(e,"rowspan",1),o=Fe(e,"colspan",1);return He(e,t,o)});return Ve(e,o,t(e))}}))([...ze(e),...t],Ue)})(e);return Je(t)},Xe=(e,t,o)=>y.from(e.access[Ke(t,o)]),Ye=(e,t,o)=>{const l=((e,t)=>{const o=F(e.all,e=>e.cells);return P(o,t)})(e,e=>o(t,e.element));return l.length>0?y.some(l[0]):y.none()},Ze=(e,t)=>y.from(e.columns[t]);var et=tinymce.util.Tools.resolve("tinymce.util.Tools");const tt=(e,t,o)=>{const l=e.select("td,th",t);let n;for(let t=0;t<l.length;t++){const r=e.getStyle(l[t],o);if(a(n)&&(n=r),n!==r)return""}return n},ot=(e,t,o)=>{et.each("left center right".split(" "),l=>{l!==o&&e.formatter.remove("align"+l,{},t)}),o&&e.formatter.apply("align"+o,{},t)},lt=(e,t,o)=>{e.dispatch("TableModified",{...o,table:t})},nt=(e,t,o)=>((e,t)=>(e=>{const t=parseFloat(e);return isNaN(t)?y.none():y.some(t)})(e).getOr(t))(Pe(e,t),o),rt=e=>((e,t)=>{const o=e.dom,l=o.getBoundingClientRect().width||o.offsetWidth;return"border-box"===t?l:((e,t,o,l)=>t-nt(e,`padding-${o}`,0)-nt(e,`padding-${l}`,0)-nt(e,`border-${o}-width`,0)-nt(e,`border-${l}-width`,0))(e,l,"left","right")})(e,"content-box");var at=tinymce.util.Tools.resolve("tinymce.Env");const st=N(5,e=>{const t=`${e+1}px`;return{title:t,value:t}}),ct=k(["None","Solid","Dotted","Dashed","Double","Groove","Ridge","Inset","Outset","Hidden"],e=>({title:e,value:e.toLowerCase()})),it="100%",mt=e=>{var t;const o=e.dom,l=null!==(t=o.getParent(e.selection.getStart(),o.isBlock))&&void 0!==t?t:e.getBody();return rt(V.fromDom(l))+"px"},dt=e=>t=>t.options.get(e),ut=dt("table_sizing_mode"),pt=dt("table_border_widths"),bt=dt("table_border_styles"),gt=dt("table_cell_advtab"),ht=dt("table_row_advtab"),ft=dt("table_advtab"),yt=dt("table_cell_inputs"),wt=dt("table_row_inputs"),St=dt("table_inputs"),Ct=dt("table_grid"),vt=dt("table_style_by_css"),xt=dt("table_cell_class_list"),Tt=dt("table_row_class_list"),_t=dt("table_class_list"),At=dt("table_toolbar"),Rt=dt("table_contextmenu"),Ot=dt("table_contextmenu_flatten"),Dt=dt("table_row_contextmenu"),It=dt("table_column_contextmenu"),Nt=dt("table_cell_contextmenu"),kt=dt("table_background_color_map"),Mt=dt("table_border_color_map"),Pt=e=>"fixed"===ut(e),Et=e=>"responsive"===ut(e),Bt=e=>{const t=e.options,o=t.get("table_default_styles");return t.isSet("table_default_styles")?o:((e,t)=>Et(e)||!vt(e)?t:Pt(e)?{...t,width:mt(e)}:{...t,width:it})(e,o)},Ft=e=>{const t=e.options,o=t.get("table_default_attributes");return t.isSet("table_default_attributes")?o:((e,t)=>Et(e)||vt(e)?t:Pt(e)?{...t,width:mt(e)}:{...t,width:it})(e,o)},jt=e=>e.options.isSet("table_contextmenu"),qt=e=>Ot(e),Lt=e=>e.options.isSet("table_row_contextmenu"),Ht=e=>e.options.isSet("table_column_contextmenu"),Vt=e=>e.options.isSet("table_cell_contextmenu"),$t=(e,t)=>t.column>=e.startCol&&t.column+t.colspan-1<=e.finishCol&&t.row>=e.startRow&&t.row+t.rowspan-1<=e.finishRow,Wt=(e,t,o)=>((e,t,o)=>{const l=Ye(e,t,z),n=Ye(e,o,z);return l.bind(e=>n.map(t=>{return o=e,l=t,{startRow:Math.min(o.row,l.row),startCol:Math.min(o.column,l.column),finishRow:Math.max(o.row+o.rowspan-1,l.row+l.rowspan-1),finishCol:Math.max(o.column+o.colspan-1,l.column+l.colspan-1)};var o,l}))})(e,t,o).bind(t=>((e,t)=>{let o=!0;const l=b($t,t);for(let n=t.startRow;n<=t.finishRow;n++)for(let r=t.startCol;r<=t.finishCol;r++)o=o&&Xe(e,n,r).exists(l);return o?y.some(t):y.none()})(e,t)),zt=Qe,Ut=(e,t)=>{oe(e).each(o=>{o.dom.insertBefore(t.dom,e.dom)})},Gt=(e,t)=>{le(e).fold(()=>{oe(e).each(e=>{Kt(e,t)})},e=>{Ut(e,t)})},Kt=(e,t)=>{e.dom.appendChild(t.dom)},Jt=(e,t)=>{M(t,(o,l)=>{const n=0===l?e:t[l-1];Gt(n,o)})},Qt=e=>{const t=e.dom;null!==t.parentNode&&t.parentNode.removeChild(t)},Xt=(e=>{const t=t=>e(t)?y.from(t.dom.nodeValue):y.none();return{get:o=>{if(!e(o))throw new Error("Can only get text value of a text node");return t(o).getOr("")},getOption:t,set:(t,o)=>{if(!e(t))throw new Error("Can only set raw text value of a text node");t.dom.nodeValue=o}}})(X);var Yt=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","li","table","thead","tbody","tfoot","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"];const Zt=(e,t,o,l)=>{const n=t(e,o);return r=(o,l)=>{const n=t(e,l);return eo(e,o,n)},a=n,((e,t)=>{for(let o=e.length-1;o>=0;o--)t(e[o],o)})(l,(e,t)=>{a=r(a,e)}),a;var r,a},eo=(e,t,o)=>t.bind(t=>o.filter(b(e.eq,t))),to={up:d({selector:me,closest:pe,predicate:ie,all:(e,t)=>{const o=c(t)?t:h;let l=e.dom;const n=[];for(;null!==l.parentNode&&void 0!==l.parentNode;){const e=l.parentNode,t=V.fromDom(e);if(n.push(t),!0===o(t))break;l=e}return n}}),down:d({selector:Ce,predicate:we}),styles:d({get:Pe,getRaw:Be,set:(e,t,o)=>{((e,t,o)=>{if(!l(o))throw console.error("Invalid call to CSS.set. Property ",t,":: Value ",o,":: Element ",e),new Error("CSS value must be a string: "+o);Me(e)&&e.style.setProperty(t,o)})(e.dom,t,o)},remove:(e,t)=>{((e,t)=>{Me(e)&&e.style.removeProperty(t)})(e.dom,t),Ae(Te(e,"style").map(De),"")&&_e(e,"style")}}),attrs:d({get:xe,set:(e,t,o)=>{ve(e.dom,t,o)},remove:_e,copyTo:(e,t)=>{((e,t)=>{const o=e.dom;C(t,(e,t)=>{ve(o,t,e)})})(t,E(e.dom.attributes,(e,t)=>(e[t.name]=t.value,e),{}))}}),insert:d({before:Ut,after:Gt,afterAll:Jt,append:Kt,appendAll:(e,t)=>{M(t,t=>{Kt(e,t)})},prepend:(e,t)=>{(e=>(e=>{const t=e.dom.childNodes;return y.from(t[0]).map(V.fromDom)})(e))(e).fold(()=>{Kt(e,t)},o=>{e.dom.insertBefore(t.dom,o.dom)})},wrap:(e,t)=>{Ut(e,t),Kt(t,e)}}),remove:d({unwrap:e=>{const t=ne(e);t.length>0&&Jt(e,t),Qt(e)},remove:Qt}),create:d({nu:V.fromTag,clone:e=>V.fromDom(e.dom.cloneNode(!1)),text:V.fromText}),query:d({comparePosition:(e,t)=>e.dom.compareDocumentPosition(t.dom),prevSibling:e=>y.from(e.dom.previousSibling).map(V.fromDom),nextSibling:le}),property:d({children:ne,name:G,parent:oe,document:e=>te(e).dom,isText:X,isComment:e=>8===K(e)||"#comment"===G(e),isElement:Q,isSpecial:e=>{const t=G(e);return D(["script","noscript","iframe","noframes","noembed","title","style","textarea","xmp"],t)},getLanguage:e=>Q(e)?Te(e,"lang"):y.none(),getText:e=>Xt.get(e),setText:(e,t)=>Xt.set(e,t),isBoundary:e=>!!Q(e)&&("body"===G(e)||D(Yt,G(e))),isEmptyTag:e=>!!Q(e)&&D(["br","img","hr","input"],G(e)),isNonEditable:e=>Q(e)&&"false"===xe(e,"contenteditable")}),eq:z,is:U},oo=e=>me(e,"table"),lo=(e,t,o)=>ue(e,t).bind(t=>ue(e,o).bind(e=>{return(o=oo,l=[t,e],((e,t,o)=>o.length>0?((e,t,o,l)=>l(e,t,o[0],o.slice(1)))(e,t,o,Zt):y.none())(to,(e,t)=>o(t),l)).map(o=>({first:t,last:e,table:o}));var o,l})),no=e=>k(e,V.fromDom),ro="data-mce-selected",ao="data-mce-first-selected",so="data-mce-last-selected",co={selected:ro,selectedSelector:"td["+ro+"],th["+ro+"]",firstSelected:ao,firstSelectedSelector:"td["+ao+"],th["+ao+"]",lastSelected:so,lastSelectedSelector:"td["+so+"],th["+so+"]"},io=e=>(t,o)=>{const l=G(t),n="col"===l||"colgroup"===l?$e(r=t).bind(e=>((e,t)=>((e,t)=>{const o=Ce(e,t);return o.length>0?y.some(o):y.none()})(e,t))(e,co.firstSelectedSelector)).fold(d(r),e=>e[0]):t;var r;return pe(n,e,o)},mo=io("th,td,caption"),uo=io("th,td"),po=e=>no(e.model.table.getSelectedCells()),bo=(e,t)=>{const o=uo(e),l=o.bind(e=>$e(e)).map(e=>We(e));return Re(o,l,(e,o)=>P(o,o=>I(no(o.dom.cells),o=>"1"===xe(o,t)||z(o,e)))).getOr([])},go=[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}],ho=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,fo=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,yo=e=>{return(t=e,Oe(t,"#")?(e=>e.substring(1))(t):t).toUpperCase();var t},wo=e=>{const t=e.toString(16);return(1===t.length?"0"+t:t).toUpperCase()},So=e=>{return t=wo(e.red)+wo(e.green)+wo(e.blue),{value:yo(t)};var t},Co=/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)\s*$/i,vo=/^\s*rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d?(?:\.\d+)?)\s*\)\s*$/i,xo=(e,t,o,l)=>({red:e,green:t,blue:o,alpha:l}),To=(e,t,o,l)=>{const n=parseInt(e,10),r=parseInt(t,10),a=parseInt(o,10),s=parseFloat(l);return xo(n,r,a,s)},_o=e=>{if("transparent"===e)return y.some(xo(0,0,0,0));const t=Co.exec(e);if(null!==t)return y.some(To(t[1],t[2],t[3],"1"));const o=vo.exec(e);return null!==o?y.some(To(o[1],o[2],o[3],o[4])):y.none()},Ao=e=>{let t=e;return{get:()=>t,set:e=>{t=e}}},Ro=(e,t,o)=>l=>{const n=(e=>{const t=Ao(y.none()),o=()=>t.get().each(e);return{clear:()=>{o(),t.set(y.none())},isSet:()=>t.get().isSome(),get:()=>t.get(),set:e=>{o(),t.set(y.some(e))}}})(e=>e.unbind()),r=!Ne(o),a=()=>{const a=po(e),s=l=>e.formatter.match(t,{value:o},l.dom,r);r?(l.setActive(!I(a,s)),n.set(e.formatter.formatChanged(t,e=>l.setActive(!e),!0))):(l.setActive(j(a,s)),n.set(e.formatter.formatChanged(t,l.setActive,!1,{value:o})))};return e.initialized?a():e.on("init",a),n.clear},Oo=e=>A(e,"menu"),Do=e=>k(e,e=>{const t=e.text||e.title||"";return Oo(e)?{text:t,items:Do(e.menu)}:{text:t,value:e.value}}),Io=e=>e.length?y.some(Do([{text:"Select...",value:"mce-no-match"},...e])):y.none(),No=(e,t,o,l)=>k(t,t=>{const n=t.text||t.title;return Oo(t)?{type:"nestedmenuitem",text:n,getSubmenuItems:()=>No(e,t.menu,o,l)}:{text:n,type:"togglemenuitem",onAction:()=>l(t.value),onSetup:Ro(e,o,t.value)}}),ko=(e,t)=>o=>{e.execCommand("mceTableApplyCellStyle",!1,{[t]:o})},Mo=e=>F(e,e=>Oo(e)?[{...e,menu:Mo(e.menu)}]:Ne(e.value)?[e]:[]),Po=(e,t)=>{if(0===t.length)return"";const o=F(e.split("|"),e=>e.trim().split(/\s+/).filter(e=>e.length>0)),l=new Set(o),n=[];let r=[];return M(t,e=>{"|"===e?r.length>0?(n.push(r),r=[]):n.push([]):l.has(e)&&r.push(e)}),r.length>0&&n.push(r),F(n,e=>e.length>0?[e.join(" ")]:[]).join(" | ")},Eo=(e,t)=>{const o=e.split("|").map(e=>e.trim()).filter(e=>e.length>0),l=[],n=e=>{e.length>0&&l.push(e.join(" "))};return M(o,e=>{const o=e.split(/\s+/).filter(e=>e.length>0);let l=[];M(o,e=>{const o=t[e];if(void 0===o)l.push(e);else{if(0===o.length)return;{const e=o.split("|").map(e=>e.trim()).filter(e=>e.length>0);1===e.length?l=l.concat(e[0].split(/\s+/).filter(e=>e.length>0)):(n(l),l=[],M(e,e=>{n(e.split(/\s+/).filter(e=>e.length>0))}))}}}),n(l)}),l.join(" | ")},Bo=(e,t,o,l)=>n=>n(No(e,t,o,l)),Fo=(e,t,o)=>{const l=k(t,e=>{return{text:e.title,value:"#"+(o=e.value,(t=o,(e=>ho.test(e)||fo.test(e))(t)?y.some({value:yo(t)}):y.none()).orThunk(()=>_o(o).map(So)).getOrThunk(()=>{const e=document.createElement("canvas");e.height=1,e.width=1;const t=e.getContext("2d");t.clearRect(0,0,e.width,e.height),t.fillStyle="#FFFFFF",t.fillStyle=o,t.fillRect(0,0,1,1);const l=t.getImageData(0,0,1,1).data,n=l[0],r=l[1],a=l[2],s=l[3];return So(xo(n,r,a,s))})).value,type:"choiceitem"};var t,o});return[{type:"fancymenuitem",fancytype:"colorswatch",initData:{colors:l.length>0?l:void 0,allowCustomColors:!1},onAction:t=>{const l="remove"===t.value?"":t.value;e.execCommand("mceTableApplyCellStyle",!1,{[o]:l})}}]},jo=e=>()=>{const t="header"===e.queryCommandValue("mceTableRowType")?"body":"header";e.execCommand("mceTableRowType",!1,{type:t})},qo=e=>()=>{const t="th"===e.queryCommandValue("mceTableColType")?"td":"th";e.execCommand("mceTableColType",!1,{type:t})},Lo=[{name:"width",type:"input",label:"Width",tooltip:"Cell width in pixels or percentage (e.g., 50px or 10%)."},{name:"height",type:"input",label:"Height",tooltip:"Row height in pixels (e.g., 20px). If the height change does not apply to the row, remove the table height in Table Properties and try again."},{name:"backgroundcolor",type:"colorinput",label:"Background color",tooltip:"Background color of the cell."},{name:"celltype",type:"listbox",label:"Cell type",tooltip:"Select the type of cell to apply formatting or styling to.",items:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{name:"scope",type:"listbox",label:"Scope",tooltip:"Defines the scope of the header cell to specify its relationship to rows or columns.",items:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{name:"halign",type:"listbox",label:"Horizontal align",tooltip:"Horizontal alignment of the cell content.",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"valign",type:"listbox",label:"Vertical align",tooltip:"Vertical alignment of the cell content.",items:go}],Ho=e=>{const t=yt(e).split(" "),o=Lo.concat((e=>Io(xt(e)).map(e=>({name:"class",type:"listbox",label:"Class",items:e})))(e).toArray());return o.filter(e=>"name"in e&&t.includes(e.name)).sort((e,o)=>{const l="name"in e?e.name:"",n="name"in o?o.name:"";return t.indexOf(l)-t.indexOf(n)})},Vo=e=>`Style of the outer border of the ${e}.`,$o=e=>{switch(e){case"table":return"Color of the border for the entire table and individual cells.";case"row":case"cell":return`Color of the outer border of the ${e}.`}},Wo=e=>{switch(e){case"table":return"Width of the border for the entire table and individual cells.";case"row":return;case"cell":return"Width of the outer border of the cell."}},zo=(e,t)=>{const o=Bt(e)["border-style"],l=bt(e).some(e=>"none"===e.value),n=[{name:"borderstyle",type:"listbox",label:"Border style",tooltip:Vo(t),items:(o||l?[]:[{text:"None",value:"none"}]).concat(Do(bt(e)))},{name:"bordercolor",type:"colorinput",label:"Border color",tooltip:$o(t)}],r={name:"cell"===t?"borderwidth":"border",type:"input",label:"Border width",tooltip:Wo(t)};return{title:"Border",name:"advanced",items:"cell"===t||"table"===t?[r].concat(n):n}},Uo=(e,t)=>{const o=e.dom;return{setAttrib:(e,l)=>{o.setAttrib(t,e,l)},setStyle:(e,l)=>{o.setStyle(t,e,l)},setFormat:(o,l)=>{""===l?e.formatter.remove(o,{value:null},t,!0):e.formatter.apply(o,{value:l},t)}}},Go=ee("th"),Ko=(e,t)=>e&&t?"sectionCells":e?"section":"cells",Jo=e=>{const t=k(e,e=>(e=>{const t="thead"===e.section,o=Ae((e=>{const t=P(e,e=>Go(e.element));return 0===t.length?y.some("td"):t.length===e.length?y.some("th"):y.none()})(e.cells),"th");return"tfoot"===e.section?{type:"footer"}:t||o?{type:"header",subType:Ko(t,o)}:{type:"body"}})(e).type),o=D(t,"header"),l=D(t,"footer");if(o||l){const e=D(t,"body");return!o||e||l?o||e||!l?y.none():y.some("footer"):y.some("header")}return y.some("body")},Qo=(e,t)=>L(e.all,e=>B(e.cells,e=>z(t,e.element))),Xo=(e,t,o)=>{const l=(e=>{const t=[],o=e=>{t.push(e)};for(let t=0;t<e.length;t++)e[t].each(o);return t})(k(t.selection,t=>{return(l=t,((e,t,o=h)=>o(t)?y.none():D(e,G(t))?y.some(t):me(t,e.join(","),e=>$(e,"table")||o(e)))(["td","th"],l,n)).bind(t=>Qo(e,t)).filter(o);var l,n})).map(e=>({...e,elementRect:e.element.dom.getBoundingClientRect()}));return n=l,l.length>0?y.some(n):y.none();var n},Yo=(e,t)=>Xo(e,t,f),Zo=(e,t)=>j(t,t=>((e,t)=>Qo(e,t).exists(e=>!e.isLocked))(e,t)),el=(e,t)=>((e,t)=>t.mergable)(0,t).filter(t=>Zo(e,t.cells)),tl=(e,t)=>((e,t)=>t.unmergable)(0,t).filter(t=>Zo(e,t)),ol=((e=>{if(!n(e))throw new Error("cases must be an array");if(0===e.length)throw new Error("there must be at least one case");const t=[],o={};M(e,(l,r)=>{const a=w(l);if(1!==a.length)throw new Error("one and only one name per case");const s=a[0],c=l[s];if(void 0!==o[s])throw new Error("duplicate key detected:"+s);if("cata"===s)throw new Error("cannot have a case named cata (sorry)");if(!n(c))throw new Error("case arguments must be an array");t.push(s),o[s]=(...o)=>{const l=o.length;if(l!==c.length)throw new Error("Wrong number of arguments to case "+s+". Expected "+c.length+" ("+c+"), got "+l);return{fold:(...t)=>{if(t.length!==e.length)throw new Error("Wrong number of arguments to fold. Expected "+e.length+", got "+t.length);return t[r].apply(null,o)},match:e=>{const l=w(e);if(t.length!==l.length)throw new Error("Wrong number of arguments to match. Expected: "+t.join(",")+"\nActual: "+l.join(","));if(!j(t,e=>D(l,e)))throw new Error("Not all branches were specified when using match. Specified: "+l.join(", ")+"\nRequired: "+t.join(", "));return e[s].apply(null,o)},log:e=>{console.log(e,{constructors:t,constructor:s,params:o})}}}})})([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev","index","next"]},{right:["prev","index"]}]),(e,t)=>{const o=Qe(e);return Yo(o,t).bind(e=>{const t=e[e.length-1],l=e[0].row,n=t.row+t.rowspan,r=o.all.slice(l,n);return Jo(r)}).getOr("")}),ll=e=>{return Oe(e,"rgb")?_o(t=e).map(So).map(e=>"#"+e.value).getOr(t):e;var t},nl=e=>{const t=V.fromDom(e);return{borderwidth:Be(t,"border-width").getOr(""),borderstyle:Be(t,"border-style").getOr(""),bordercolor:Be(t,"border-color").map(ll).getOr(""),backgroundcolor:Be(t,"background-color").map(ll).getOr("")}},rl=e=>{const t=e[0],o=e.slice(1);return M(o,e=>{M(w(t),o=>{C(e,(e,l)=>{const n=t[o];""!==n&&o===l&&n!==e&&(t[o]="class"===o?"mce-no-match":"")})})}),t},al=(e,t,o,l)=>B(e,e=>!a(o.formatter.matchNode(l,t+e))).getOr(""),sl=b(al,["left","center","right"],"align"),cl=b(al,["top","middle","bottom"],"valign"),il=e=>$e(V.fromDom(e)).map(t=>{const o={selection:no(e.cells)};return ol(t,o)}).getOr(""),ml=(e,t)=>{if(!t||"double"!==t)return e;const o=parseFloat(e);return void 0!==o&&(0===o||o>=3)?e:"3px"},dl=(e,t)=>{const o=Qe(e),l=(e=>F(e.all,e=>e.cells))(o),n=P(l,e=>I(t,t=>z(e.element,t)));return k(n,e=>({element:e.element.dom,column:Ze(o,e.column).map(e=>e.element.dom)}))},ul=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact(()=>{((e,t,o,l)=>{const n=v(l,(e,t)=>o[t]!==e);x(n)>0&&t.length>=1&&$e(t[0]).each(o=>{const r=dl(o,t),a=x(v(n,(e,t)=>"scope"!==t&&"celltype"!==t))>0,s=_(n,"celltype");(a||_(n,"scope"))&&((e,t,o,l)=>{const n=1===t.length,r=new Set;M(t,t=>{const a=t.element,s=n?f:l,c=Uo(e,a);if(((e,t,o,l)=>{l("scope")&&e.setAttrib("scope",o.scope),l("class")&&"mce-no-match"!==o.class&&e.setAttrib("class",o.class),l("width")&&t.setStyle("width",fe(o.width))})(c,t.column.map(t=>Uo(e,t)).getOr(c),o,s),gt(e)&&((e,t,o)=>{if(o("backgroundcolor")&&e.setFormat("tablecellbackgroundcolor",t.backgroundcolor),o("bordercolor")&&e.setFormat("tablecellbordercolor",t.bordercolor),o("borderstyle")&&e.setFormat("tablecellborderstyle",t.borderstyle),o("borderwidth")||"double"===t.borderstyle){const o=ml(t.borderwidth,t.borderstyle);e.setFormat("tablecellborderwidth",fe(o))}})(c,o,s),s("height")){const t=a.parentElement;null===t||r.has(t)||(r.add(t),e.dom.setStyle(t,"height",fe(o.height)),l("height")&&Array.from(t.cells).forEach(t=>e.dom.setStyle(t,"height",null)))}l("halign")&&ot(e,a,o.halign),l("valign")&&((e,t,o)=>{et.each("top middle bottom".split(" "),l=>{l!==o&&e.formatter.remove("valign"+l,{},t)}),o&&e.formatter.apply("valign"+o,{},t)})(e,a,o.valign)})})(e,r,l,b(_,n)),s&&((e,t)=>{e.execCommand("mceTableCellType",!1,{type:t.celltype,no_events:!0})})(e,l),lt(e,o.dom,{structure:s,style:a})})})(e,t,o,n),e.focus()})},pl=e=>{const t=po(e);if(0===t.length)return;const o=((e,t)=>{const o=$e(t[0]).map(o=>k(dl(o,t),t=>((e,t,o,l)=>{const n=e.dom,r=l.getOr(t),a=t.parentElement;return{width:(c=r,i="width",n.getStyle(c,i)||n.getAttrib(c,i)),height:a?n.getStyle(a,"height")||n.getAttrib(a,"height"):"",scope:n.getAttrib(t,"scope"),celltype:(s=t,s.nodeName.toLowerCase()),class:n.getAttrib(t,"class",""),halign:sl(e,t),valign:cl(e,t),...o?nl(t):{}};var s,c,i})(e,t.element,gt(e),t.column)));return rl(o.getOrDie())})(e,t),l={type:"tabpanel",tabs:[{title:"General",name:"general",items:Ho(e)},zo(e,"cell")]},n={type:"panel",items:[{type:"grid",columns:2,items:Ho(e)}]};e.windowManager.open({title:"Cell Properties",size:"normal",body:gt(e)?l:n,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:o,onSubmit:b(ul,e,t,o)})},bl=[{type:"listbox",name:"type",label:"Row type",tooltip:"Select the type of row to apply formatting or styling to.",items:[{text:"Header",value:"header"},{text:"Body",value:"body"},{text:"Footer",value:"footer"}]},{type:"listbox",name:"align",label:"Alignment",tooltip:"Alignment of the content within the cells in the row.",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"backgroundcolor",type:"colorinput",label:"Background color",tooltip:"Changes the background color of all cells in the row, except for those set individually through Cell Properties."}],gl=e=>{const t=wt(e).split(" "),o=bl.concat((e=>Io(Tt(e)).map(e=>({name:"class",type:"listbox",label:"Class",items:e})))(e).toArray());return o.filter(e=>"name"in e&&t.includes(e.name)).sort((e,o)=>{const l="name"in e?e.name:"",n="name"in o?o.name:"";return t.indexOf(l)-t.indexOf(n)})},hl=(e,t,o,l)=>{const n=l.getData();l.close(),e.undoManager.transact(()=>{((e,t,o,l)=>{const n=v(l,(e,t)=>o[t]!==e);if(x(n)>0){const o=_(n,"type"),r=!o||x(n)>1;r&&((e,t,o,l)=>{const n=1===t.length?f:l;M(t,t=>{const r=Uo(e,t);((e,t,o)=>{o("class")&&"mce-no-match"!==t.class&&e.setAttrib("class",t.class)})(r,o,n),ht(e)&&((e,t,o)=>{o("backgroundcolor")&&e.setStyle("background-color",t.backgroundcolor),o("bordercolor")&&e.setStyle("border-color",t.bordercolor),o("borderstyle")&&e.setStyle("border-style",t.borderstyle)})(r,o,n),l("align")&&ot(e,t,o.align)})})(e,t,l,b(_,n)),o&&((e,t)=>{e.execCommand("mceTableRowType",!1,{type:t.type,no_events:!0})})(e,l),$e(V.fromDom(t[0])).each(t=>lt(e,t.dom,{structure:o,style:r}))}})(e,t,o,n),e.focus()})},fl=e=>{const t=bo(ye(e),co.selected);if(0===t.length)return;const o=k(t,t=>((e,t,o)=>({class:e.dom.getAttrib(t,"class",""),type:il(t),align:sl(e,t),...o?nl(t):{}}))(e,t.dom,ht(e))),l=rl(o),n={type:"tabpanel",tabs:[{title:"General",name:"general",items:gl(e)},zo(e,"row")]},r={type:"panel",items:[{type:"grid",columns:2,items:gl(e)}]};e.windowManager.open({title:"Row Properties",size:"normal",body:ht(e)?n:r,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:l,onSubmit:b(hl,e,k(t,e=>e.dom),l)})},yl=(e,t,o)=>{const l=o?[{type:"input",name:"cols",label:"Cols",inputMode:"numeric"},{type:"input",name:"rows",label:"Rows",inputMode:"numeric"}]:[],n=[{type:"input",name:"width",label:"Width",tooltip:"Total width of the table in pixels or percentage (e.g., 500px or 100%)."},{type:"input",name:"height",label:"Height",tooltip:"Total height of the table in pixels (e.g., 500px)."},{type:"input",name:"cellspacing",label:"Cell spacing",inputMode:"numeric",tooltip:"The space between individual table cells, measured in pixels (e.g., 5px)."},{type:"input",name:"cellpadding",label:"Cell padding",inputMode:"numeric",tooltip:"Inner text padding in cells, e.g., 0px 5px (where 0px is vertical padding, and 5px is horizontal padding)."},{name:"backgroundcolor",type:"colorinput",label:"Background color",tooltip:"Changes the background color of all cells in the table, except for those set individually through Cell Properties or Row Properties."},{type:"label",label:"Caption",name:"caption",tooltip:"Adds a caption above the table, which can be edited.",items:[{type:"checkbox",name:"caption",label:"Show caption"}]},{type:"listbox",name:"align",label:"Alignment",tooltip:"Alignment of the entire table (not the content within the table).",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}];t.length>0&&n.push({name:"class",type:"listbox",label:"Class",items:t});const r=St(e).split(" "),a=n.filter(e=>"name"in e&&r.includes(e.name)).sort((e,t)=>{const o="name"in e?e.name:"",l="name"in t?t.name:"";return r.indexOf(o)-r.indexOf(l)});return l.concat(a)},wl=(e,t,o,n)=>{if("TD"===t.tagName||"TH"===t.tagName)l(o)&&s(n)?e.setStyle(t,o,n):e.setStyles(t,o);else if(t.children)for(let l=0;l<t.children.length;l++)wl(e,t.children[l],o,n)},Sl=(e,t,o,l)=>{const n=e.dom,r=l.getData(),s=v(r,(e,t)=>o[t]!==e);l.close(),e.undoManager.transact(()=>{if(!t){const o=ke(r.cols).getOr(1),l=ke(r.rows).getOr(1);e.execCommand("mceInsertTable",!1,{rows:l,columns:o}),t=uo(ye(e),he(e)).bind(t=>$e(t,he(e))).map(e=>e.dom).getOrDie()}if(x(s)>0){const o={border:_(s,"border"),bordercolor:_(s,"bordercolor"),cellpadding:_(s,"cellpadding")};((e,t,o,l)=>{const n=e.dom,r={},s={},c=vt(e),i=ft(e),m=0===parseFloat(o.border),d=ml(o.border,o.borderstyle);if(a(o.class)||"mce-no-match"===o.class||(r.class=o.class),s.height=fe(o.height),c?s.width=fe(o.width):n.getAttrib(t,"width")&&(r.width=(e=>e?e.replace(/px$/,""):"")(o.width)),c?(m?(r.border=0,s["border-width"]=""):(s["border-width"]=fe(d),r.border=1),s["border-spacing"]=fe(o.cellspacing)):(r.border=m?0:d,r.cellpadding=o.cellpadding,r.cellspacing=o.cellspacing),c&&t.children){const e={};if(m?e["border-width"]="":l.border&&(e["border-width"]=fe(d)),l.cellpadding&&(e.padding=fe(o.cellpadding)),i&&l.bordercolor&&(e["border-color"]=o.bordercolor),!(e=>{for(const t in e)if(S.call(e,t))return!1;return!0})(e))for(let o=0;o<t.children.length;o++)wl(n,t.children[o],e)}if(i){const e=o;s["background-color"]=e.backgroundcolor,s["border-color"]=e.bordercolor,s["border-style"]=e.borderstyle}n.setStyles(t,{...Bt(e),...s}),n.setAttribs(t,{...Ft(e),...r})})(e,t,r,o);const l=n.select("caption",t)[0];(l&&!r.caption||!l&&r.caption)&&e.execCommand("mceTableToggleCaption"),ot(e,t,r.align)}if(e.focus(),e.addVisual(),x(s)>0){const o=_(s,"caption"),l=!o||x(s)>1;lt(e,t,{structure:o,style:l})}})},Cl=(e,t)=>{const o=e.dom;let l,n=((e,t)=>{const o=Bt(e),l=Ft(e),n=t?{borderstyle:T(o,"border-style").getOr(""),bordercolor:ll(T(o,"border-color").getOr("")),backgroundcolor:ll(T(o,"background-color").getOr(""))}:{};return{height:"",width:"100%",cellspacing:"",cellpadding:"",caption:!1,class:"",align:"",border:"",...o,...l,...n,...(()=>{const t=o["border-width"];return vt(e)&&t?{border:t}:T(l,"border").fold(()=>({}),e=>({border:e}))})(),...{...T(o,"border-spacing").or(T(l,"cellspacing")).fold(()=>({}),e=>({cellspacing:e})),...T(o,"border-padding").or(T(l,"cellpadding")).fold(()=>({}),e=>({cellpadding:e}))}}})(e,ft(e));t?(n.cols="1",n.rows="1",ft(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor="")):(l=o.getParent(e.selection.getStart(),"table",e.getBody()),l?n=((e,t,o)=>{const l=e.dom,n=vt(e)?l.getStyle(t,"border-spacing")||l.getAttrib(t,"cellspacing"):l.getAttrib(t,"cellspacing")||l.getStyle(t,"border-spacing"),r=vt(e)?tt(l,t,"padding")||l.getAttrib(t,"cellpadding"):l.getAttrib(t,"cellpadding")||tt(l,t,"padding");return{width:l.getStyle(t,"width")||l.getAttrib(t,"width"),height:l.getStyle(t,"height")||l.getAttrib(t,"height"),cellspacing:null!=n?n:"",cellpadding:null!=r?r:"",border:((t,o)=>{const l=Be(V.fromDom(o),"border-width");return vt(e)&&l.isSome()?l.getOr(""):t.getAttrib(o,"border")||tt(e.dom,o,"border-width")||tt(e.dom,o,"border")||""})(l,t),caption:!!l.select("caption",t)[0],class:l.getAttrib(t,"class",""),align:sl(e,t),...o?nl(t):{}}})(e,l,ft(e)):ft(e)&&(n.borderstyle="",n.bordercolor="",n.backgroundcolor=""));const r=Io(_t(e));r.isSome()&&n.class&&(n.class=n.class.replace(/\s*mce\-item\-table\s*/g,""));const a={type:"grid",columns:2,items:yl(e,r.getOr([]),t)},s=ft(e)?{type:"tabpanel",tabs:[{title:"General",name:"general",items:[a]},zo(e,"table")]}:{type:"panel",items:[a]};e.windowManager.open({title:"Table Properties",size:"normal",body:s,onSubmit:b(Sl,e,l,n),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:n})},vl=e=>{C({mceTableProps:b(Cl,e,!1),mceTableRowProps:b(fl,e),mceTableCellProps:b(pl,e),mceInsertTableDialog:b(Cl,e,!0)},(t,o)=>e.addCommand(o,()=>{return o=t,void((e=>{return(t=e,o=ee("table"),ce((e,t)=>t(e),ie,t,o,void 0)).forall(be);var t,o})(ye(e))&&o());var o}))},xl=u,Tl=e=>{const t=(e,t)=>Te(e,t).exists(e=>parseInt(e,10)>1);return e.length>0&&j(e,e=>t(e,"rowspan")||t(e,"colspan"))?y.some(e):y.none()},_l=(e,t,o)=>{return t.length<=1?y.none():(l=e,n=o.firstSelectedSelector,r=o.lastSelectedSelector,lo(l,n,r).bind(e=>{const t=e=>z(l,e),o="thead,tfoot,tbody,table",n=me(e.first,o,t),r=me(e.last,o,t);return n.bind(t=>r.bind(o=>z(t,o)?((e,t,o)=>{const l=zt(e);return Wt(l,t,o)})(e.table,e.first,e.last):y.none()))})).map(e=>({bounds:e,cells:t}));var l,n,r},Al=e=>{const t=Ao(y.none()),o=Ao([]);let l=y.none();const n=ee("caption"),r=e=>l.forall(t=>!t[e]),a=()=>mo(ye(e),he(e)).bind(t=>{return o=Re($e(t),mo((e=>V.fromDom(e.selection.getEnd()))(e),he(e)).bind($e),(o,l)=>z(o,l)?n(t)?y.some((e=>({element:e,mergable:y.none(),unmergable:y.none(),selection:[e]}))(t)):y.some(((e,t,o)=>({element:o,mergable:_l(t,e,co),unmergable:Tl(e),selection:xl(e)}))(po(e),o,t)):y.none()),o.bind(u);var o}),s=e=>$e(e.element).map(t=>{const o=Qe(t),l=Yo(o,e).getOr([]),n=E(l,(e,t)=>(t.isLocked&&(e.onAny=!0,0===t.column?e.onFirst=!0:t.column+t.colspan>=o.grid.columns&&(e.onLast=!0)),e),{onAny:!1,onFirst:!1,onLast:!1});return{mergeable:el(o,e).isSome(),unmergeable:tl(o,e).isSome(),locked:n}}),c=()=>{t.set((e=>{let t,o=!1;return(...l)=>(o||(o=!0,t=e.apply(null,l)),t)})(a)()),l=t.get().bind(s),M(o.get(),g)},i=e=>(e(),o.set(o.get().concat([e])),()=>{o.set(P(o.get(),t=>t!==e))}),m=(o,l)=>i(()=>t.get().fold(()=>{o.setEnabled(!1)},t=>{o.setEnabled(!l(t)&&e.selection.isEditable())})),d=(o,l,n)=>i(()=>t.get().fold(()=>{o.setEnabled(!1),o.setActive(!1)},t=>{o.setEnabled(!l(t)&&e.selection.isEditable()),o.setActive(n(t))})),p=e=>l.exists(t=>t.locked[e]),b=(t,o)=>l=>d(l,e=>n(e.element),()=>e.queryCommandValue(t)===o),f=b("mceTableRowType","header"),w=b("mceTableColType","th");return e.on("NodeChange ExecCommand TableSelectorChange",c),{onSetupTable:e=>m(e,e=>!1),onSetupCellOrRow:e=>m(e,e=>n(e.element)),onSetupColumn:e=>t=>m(t,t=>n(t.element)||p(e)),onSetupPasteable:e=>t=>m(t,t=>n(t.element)||e().isNone()),onSetupPasteableColumn:(e,t)=>o=>m(o,o=>n(o.element)||e().isNone()||p(t)),onSetupMergeable:e=>m(e,e=>r("mergeable")),onSetupUnmergeable:e=>m(e,e=>r("unmergeable")),resetTargets:c,onSetupTableWithCaption:t=>d(t,h,t=>$e(t.element,he(e)).exists(e=>de(e,"caption").isSome())),onSetupTableRowHeaders:f,onSetupTableColumnHeaders:w,targets:t.get}};var Rl=tinymce.util.Tools.resolve("tinymce.FakeClipboard");const Ol="x-tinymce/dom-table-",Dl=Ol+"rows",Il=Ol+"columns",Nl=e=>{var t;const o=null!==(t=Rl.read())&&void 0!==t?t:[];return L(o,t=>y.from(t.getType(e)))},kl=()=>Nl(Dl),Ml=()=>Nl(Il),Pl=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}},El=e=>{const t="tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter";return Lt(e)?Po(t,Dt(e)):t},Bl=e=>{const t="tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter";return Ht(e)?Po(t,It(e)):t},Fl=e=>{const t="tablecellprops tablemergecells tablesplitcells";return Vt(e)?Po(t,Nt(e)):t},jl=e=>t=>{const o=()=>{t.setEnabled(e.selection.isEditable())};return e.on("NodeChange",o),o(),()=>{e.off("NodeChange",o)}};e.add("table",e=>{const t=Al(e);(e=>{const t=e.options.register;t("table_border_widths",{processor:"object[]",default:st}),t("table_border_styles",{processor:"object[]",default:ct}),t("table_cell_advtab",{processor:"boolean",default:!0}),t("table_row_advtab",{processor:"boolean",default:!0}),t("table_advtab",{processor:"boolean",default:!0}),t("table_cell_inputs",{processor:"string",default:"width height celltype scope halign valign backgroundcolor class"}),t("table_row_inputs",{processor:"string",default:"type align backgroundcolor class"}),t("table_inputs",{processor:"string",default:"width height cellspacing cellpadding backgroundcolor caption align class"}),t("table_grid",{processor:"boolean",default:!at.deviceType.isTouch()}),t("table_cell_class_list",{processor:"object[]",default:[]}),t("table_row_class_list",{processor:"object[]",default:[]}),t("table_class_list",{processor:"object[]",default:[]}),t("table_toolbar",{processor:"string",default:"tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol"}),t("table_contextmenu",{processor:"string[]",default:[]}),t("table_contextmenu_flatten",{processor:"boolean",default:!1}),t("table_row_contextmenu",{processor:"string[]",default:[]}),t("table_column_contextmenu",{processor:"string[]",default:[]}),t("table_cell_contextmenu",{processor:"string[]",default:[]}),t("table_background_color_map",{processor:"object[]",default:[]}),t("table_border_color_map",{processor:"object[]",default:[]})})(e),vl(e),((e,t)=>{const o=t=>()=>e.execCommand(t),l=(t,l)=>!!e.queryCommandSupported(l.command)&&(e.ui.registry.addMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)}),!0),n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleMenuItem(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},r=t=>{e.execCommand("mceInsertTable",!1,{rows:t.numRows,columns:t.numColumns})},a=[l("tableinsertrowbefore",{text:"Insert row before",icon:"table-insert-row-above",command:"mceTableInsertRowBefore",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{text:"Insert row after",icon:"table-insert-row-after",command:"mceTableInsertRowAfter",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{text:"Delete row",icon:"table-delete-row",command:"mceTableDeleteRow",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{text:"Row properties",icon:"table-row-properties",command:"mceTableRowProps",onSetup:t.onSetupCellOrRow}),l("tablecutrow",{text:"Cut row",icon:"cut-row",command:"mceTableCutRow",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{text:"Copy row",icon:"duplicate-row",command:"mceTableCopyRow",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{text:"Paste row before",icon:"paste-row-before",command:"mceTablePasteRowBefore",onSetup:t.onSetupPasteable(kl)}),l("tablepasterowafter",{text:"Paste row after",icon:"paste-row-after",command:"mceTablePasteRowAfter",onSetup:t.onSetupPasteable(kl)})],s=[l("tableinsertcolumnbefore",{text:"Insert column before",icon:"table-insert-column-before",command:"mceTableInsertColBefore",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolumnafter",{text:"Insert column after",icon:"table-insert-column-after",command:"mceTableInsertColAfter",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecolumn",{text:"Delete column",icon:"table-delete-column",command:"mceTableDeleteCol",onSetup:t.onSetupColumn("onAny")}),l("tablecutcolumn",{text:"Cut column",icon:"cut-column",command:"mceTableCutCol",onSetup:t.onSetupColumn("onAny")}),l("tablecopycolumn",{text:"Copy column",icon:"duplicate-column",command:"mceTableCopyCol",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolumnbefore",{text:"Paste column before",icon:"paste-column-before",command:"mceTablePasteColBefore",onSetup:t.onSetupPasteableColumn(Ml,"onFirst")}),l("tablepastecolumnafter",{text:"Paste column after",icon:"paste-column-after",command:"mceTablePasteColAfter",onSetup:t.onSetupPasteableColumn(Ml,"onLast")})],i=[l("tablecellprops",{text:"Cell properties",icon:"table-cell-properties",command:"mceTableCellProps",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{text:"Merge cells",icon:"table-merge-cells",command:"mceTableMergeCells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{text:"Split cell",icon:"table-split-cells",command:"mceTableSplitCells",onSetup:t.onSetupUnmergeable})];Ct(e)?e.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",getSubmenuItems:()=>[{type:"fancymenuitem",fancytype:"inserttable",onAction:r}],onSetup:jl(e)}):e.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:o("mceInsertTableDialog"),onSetup:jl(e)}),e.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:o("mceInsertTableDialog"),onSetup:jl(e)}),l("tableprops",{text:"Table properties",onSetup:t.onSetupTable,command:"mceTableProps"}),l("deletetable",{text:"Delete table",icon:"table-delete-table",onSetup:t.onSetupTable,command:"mceTableDelete"});const m="tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter",u=Lt(e)?Po(m,Dt(e)):m;D(a,!0)&&u.length>0&&e.ui.registry.addNestedMenuItem("row",{type:"nestedmenuitem",text:"Row",getSubmenuItems:d(u)});const p="tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter",b=Ht(e)?Po(p,It(e)):p;D(s,!0)&&b.length>0&&e.ui.registry.addNestedMenuItem("column",{type:"nestedmenuitem",text:"Column",getSubmenuItems:d(b)});const g="tablecellprops tablemergecells tablesplitcells",h=Vt(e)?Po(g,Nt(e)):g;D(i,!0)&&h.length>0&&e.ui.registry.addNestedMenuItem("cell",{type:"nestedmenuitem",text:"Cell",getSubmenuItems:d(h)}),e.ui.registry.addContextMenu("table",{update:()=>{t.resetTargets();const o=t.targets().fold(d(""),e=>"caption"===G(e.element)?"tableprops deletetable":"cell row column | advtablesort | tableprops deletetable"),l=Rt(e).join(" "),n=jt(e)?l:o;return qt(e)&&n.length>0?Eo(n,{cell:h,row:u,column:b}):n}});const f=Mo(_t(e));0!==f.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addNestedMenuItem("tableclass",{icon:"table-classes",text:"Table styles",getSubmenuItems:()=>No(e,f,"tableclass",t=>e.execCommand("mceTableToggleClass",!1,t)),onSetup:t.onSetupTable});const y=Mo(xt(e));0!==y.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addNestedMenuItem("tablecellclass",{icon:"table-cell-classes",text:"Cell styles",getSubmenuItems:()=>No(e,y,"tablecellclass",t=>e.execCommand("mceTableCellToggleClass",!1,t)),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addNestedMenuItem("tablecellvalign",{icon:"vertical-align",text:"Vertical align",getSubmenuItems:()=>No(e,go,"tablecellverticalalign",ko(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderwidth",{icon:"border-width",text:"Border width",getSubmenuItems:()=>No(e,pt(e),"tablecellborderwidth",ko(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellborderstyle",{icon:"border-style",text:"Border style",getSubmenuItems:()=>No(e,bt(e),"tablecellborderstyle",ko(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbackgroundcolor",{icon:"cell-background-color",text:"Background color",getSubmenuItems:()=>Fo(e,kt(e),"background-color"),onSetup:t.onSetupCellOrRow}),e.ui.registry.addNestedMenuItem("tablecellbordercolor",{icon:"cell-border-color",text:"Border color",getSubmenuItems:()=>Fo(e,Mt(e),"border-color"),onSetup:t.onSetupCellOrRow})),n("tablecaption",{icon:"table-caption",text:"Table caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{text:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:jo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{text:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:qo(e),onSetup:t.onSetupTableRowHeaders})})(e,t),((e,t)=>{e.ui.registry.addMenuButton("table",{tooltip:"Table",icon:"table",onSetup:Pl(e),fetch:t=>t((e=>{const t=Rt(e),o=t.length>0?["inserttable",...t].join(" "):"",l=jt(e)?o:"inserttable | cell row column | advtablesort | tableprops deletetable";return qt(e)&&l.length>0?Eo(l,{cell:Fl(e),row:El(e),column:Bl(e)}):l})(e))});const o=t=>()=>e.execCommand(t),l=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})},n=(t,l)=>{e.queryCommandSupported(l.command)&&e.ui.registry.addToggleButton(t,{...l,onAction:c(l.onAction)?l.onAction:o(l.command)})};l("tableprops",{tooltip:"Table properties",command:"mceTableProps",icon:"table",onSetup:t.onSetupTable}),l("tabledelete",{tooltip:"Delete table",command:"mceTableDelete",icon:"table-delete-table",onSetup:t.onSetupTable}),l("tablecellprops",{tooltip:"Cell properties",command:"mceTableCellProps",icon:"table-cell-properties",onSetup:t.onSetupCellOrRow}),l("tablemergecells",{tooltip:"Merge cells",command:"mceTableMergeCells",icon:"table-merge-cells",onSetup:t.onSetupMergeable}),l("tablesplitcells",{tooltip:"Split cell",command:"mceTableSplitCells",icon:"table-split-cells",onSetup:t.onSetupUnmergeable}),l("tableinsertrowbefore",{tooltip:"Insert row before",command:"mceTableInsertRowBefore",icon:"table-insert-row-above",onSetup:t.onSetupCellOrRow}),l("tableinsertrowafter",{tooltip:"Insert row after",command:"mceTableInsertRowAfter",icon:"table-insert-row-after",onSetup:t.onSetupCellOrRow}),l("tabledeleterow",{tooltip:"Delete row",command:"mceTableDeleteRow",icon:"table-delete-row",onSetup:t.onSetupCellOrRow}),l("tablerowprops",{tooltip:"Row properties",command:"mceTableRowProps",icon:"table-row-properties",onSetup:t.onSetupCellOrRow}),l("tableinsertcolbefore",{tooltip:"Insert column before",command:"mceTableInsertColBefore",icon:"table-insert-column-before",onSetup:t.onSetupColumn("onFirst")}),l("tableinsertcolafter",{tooltip:"Insert column after",command:"mceTableInsertColAfter",icon:"table-insert-column-after",onSetup:t.onSetupColumn("onLast")}),l("tabledeletecol",{tooltip:"Delete column",command:"mceTableDeleteCol",icon:"table-delete-column",onSetup:t.onSetupColumn("onAny")}),l("tablecutrow",{tooltip:"Cut row",command:"mceTableCutRow",icon:"cut-row",onSetup:t.onSetupCellOrRow}),l("tablecopyrow",{tooltip:"Copy row",command:"mceTableCopyRow",icon:"duplicate-row",onSetup:t.onSetupCellOrRow}),l("tablepasterowbefore",{tooltip:"Paste row before",command:"mceTablePasteRowBefore",icon:"paste-row-before",onSetup:t.onSetupPasteable(kl)}),l("tablepasterowafter",{tooltip:"Paste row after",command:"mceTablePasteRowAfter",icon:"paste-row-after",onSetup:t.onSetupPasteable(kl)}),l("tablecutcol",{tooltip:"Cut column",command:"mceTableCutCol",icon:"cut-column",onSetup:t.onSetupColumn("onAny")}),l("tablecopycol",{tooltip:"Copy column",command:"mceTableCopyCol",icon:"duplicate-column",onSetup:t.onSetupColumn("onAny")}),l("tablepastecolbefore",{tooltip:"Paste column before",command:"mceTablePasteColBefore",icon:"paste-column-before",onSetup:t.onSetupPasteableColumn(Ml,"onFirst")}),l("tablepastecolafter",{tooltip:"Paste column after",command:"mceTablePasteColAfter",icon:"paste-column-after",onSetup:t.onSetupPasteableColumn(Ml,"onLast")}),l("tableinsertdialog",{tooltip:"Insert table",command:"mceInsertTableDialog",icon:"table",onSetup:Pl(e)});const r=Mo(_t(e));0!==r.length&&e.queryCommandSupported("mceTableToggleClass")&&e.ui.registry.addMenuButton("tableclass",{icon:"table-classes",tooltip:"Table styles",fetch:Bo(e,r,"tableclass",t=>e.execCommand("mceTableToggleClass",!1,t)),onSetup:t.onSetupTable});const a=Mo(xt(e));0!==a.length&&e.queryCommandSupported("mceTableCellToggleClass")&&e.ui.registry.addMenuButton("tablecellclass",{icon:"table-cell-classes",tooltip:"Cell styles",fetch:Bo(e,a,"tablecellclass",t=>e.execCommand("mceTableCellToggleClass",!1,t)),onSetup:t.onSetupCellOrRow}),e.queryCommandSupported("mceTableApplyCellStyle")&&(e.ui.registry.addMenuButton("tablecellvalign",{icon:"vertical-align",tooltip:"Vertical align",fetch:Bo(e,go,"tablecellverticalalign",ko(e,"vertical-align")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderwidth",{icon:"border-width",tooltip:"Border width",fetch:Bo(e,pt(e),"tablecellborderwidth",ko(e,"border-width")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellborderstyle",{icon:"border-style",tooltip:"Border style",fetch:Bo(e,bt(e),"tablecellborderstyle",ko(e,"border-style")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbackgroundcolor",{icon:"cell-background-color",tooltip:"Background color",fetch:t=>t(Fo(e,kt(e),"background-color")),onSetup:t.onSetupCellOrRow}),e.ui.registry.addMenuButton("tablecellbordercolor",{icon:"cell-border-color",tooltip:"Border color",fetch:t=>t(Fo(e,Mt(e),"border-color")),onSetup:t.onSetupCellOrRow})),n("tablecaption",{tooltip:"Table caption",icon:"table-caption",command:"mceTableToggleCaption",onSetup:t.onSetupTableWithCaption}),n("tablerowheader",{tooltip:"Row header",icon:"table-top-header",command:"mceTableRowType",onAction:jo(e),onSetup:t.onSetupTableRowHeaders}),n("tablecolheader",{tooltip:"Column header",icon:"table-left-header",command:"mceTableColType",onAction:qo(e),onSetup:t.onSetupTableColumnHeaders})})(e,t),(e=>{const t=At(e);t.length>0&&e.ui.registry.addContextToolbar("table",{predicate:t=>e.dom.is(t,"table")&&e.getBody().contains(t)&&e.dom.isEditable(t.parentNode),items:t,scope:"node",position:"node"})})(e)})}();
@@ -10250,6 +10250,75 @@
10250
10250
  items: menu.items
10251
10251
  }));
10252
10252
  };
10253
+ const filterContextMenu = (menu, allowed) => {
10254
+ if (allowed.length === 0) {
10255
+ return '';
10256
+ }
10257
+ const allowedSet = new Set(allowed);
10258
+ const filteredGroups = menu.split('|').map(group => group.trim()).map(group => group.length === 0 ? [] : group.split(/\s+/).filter(item => allowedSet.has(item))).filter(items => items.length > 0).map(items => items.join(' '));
10259
+ return filteredGroups.join(' | ');
10260
+ };
10261
+ const flattenContextMenu = (menu, replacements) => {
10262
+ const groups = menu.split('|').map(group => group.trim()).filter(group => group.length > 0);
10263
+ const flattened = [];
10264
+ const addGroup = items => {
10265
+ if (items.length > 0) {
10266
+ flattened.push(items.join(' '));
10267
+ }
10268
+ };
10269
+ each$1(groups, group => {
10270
+ const tokens = group.split(/\s+/).filter(token => token.length > 0);
10271
+ let current = [];
10272
+ each$1(tokens, token => {
10273
+ const replacement = replacements[token];
10274
+ if (replacement === undefined) {
10275
+ current.push(token);
10276
+ } else if (replacement.length === 0) {
10277
+ return;
10278
+ } else {
10279
+ const replacementGroups = replacement.split('|').map(repGroup => repGroup.trim()).filter(repGroup => repGroup.length > 0);
10280
+ if (replacementGroups.length === 1) {
10281
+ current = current.concat(replacementGroups[0].split(/\s+/).filter(item => item.length > 0));
10282
+ } else {
10283
+ addGroup(current);
10284
+ current = [];
10285
+ each$1(replacementGroups, repGroup => {
10286
+ addGroup(repGroup.split(/\s+/).filter(item => item.length > 0));
10287
+ });
10288
+ }
10289
+ }
10290
+ });
10291
+ addGroup(current);
10292
+ });
10293
+ return flattened.join(' | ');
10294
+ };
10295
+ const getFilteredTableMenuItems = (editor, menu) => {
10296
+ var _a, _b, _c, _d;
10297
+ if (!editor.options.isRegistered('table_contextmenu')) {
10298
+ return menu;
10299
+ }
10300
+ const isTableContextMenuSet = editor.options.isSet('table_contextmenu');
10301
+ const contextItems = (_a = editor.options.get('table_contextmenu')) !== null && _a !== void 0 ? _a : [];
10302
+ const tableContextMenu = contextItems.length > 0 ? [
10303
+ 'inserttable',
10304
+ ...contextItems
10305
+ ] : [];
10306
+ const filteredMenu = isTableContextMenuSet ? tableContextMenu.join(' ') : menu;
10307
+ if (!editor.options.get('table_contextmenu_flatten') || filteredMenu.length === 0) {
10308
+ return filteredMenu;
10309
+ }
10310
+ const rowMenuItems = 'tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter';
10311
+ const columnMenuItems = 'tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter';
10312
+ const cellMenuItems = 'tablecellprops tablemergecells tablesplitcells';
10313
+ const filteredRowMenuItems = editor.options.isSet('table_row_contextmenu') ? filterContextMenu(rowMenuItems, (_b = editor.options.get('table_row_contextmenu')) !== null && _b !== void 0 ? _b : []) : rowMenuItems;
10314
+ const filteredColumnMenuItems = editor.options.isSet('table_column_contextmenu') ? filterContextMenu(columnMenuItems, (_c = editor.options.get('table_column_contextmenu')) !== null && _c !== void 0 ? _c : []) : columnMenuItems;
10315
+ const filteredCellMenuItems = editor.options.isSet('table_cell_contextmenu') ? filterContextMenu(cellMenuItems, (_d = editor.options.get('table_cell_contextmenu')) !== null && _d !== void 0 ? _d : []) : cellMenuItems;
10316
+ return flattenContextMenu(filteredMenu, {
10317
+ cell: filteredCellMenuItems,
10318
+ row: filteredRowMenuItems,
10319
+ column: filteredColumnMenuItems
10320
+ });
10321
+ };
10253
10322
 
10254
10323
  var Options = /*#__PURE__*/Object.freeze({
10255
10324
  __proto__: null,
@@ -10305,7 +10374,8 @@
10305
10374
  getPasteAsText: getPasteAsText,
10306
10375
  getSidebarShow: getSidebarShow,
10307
10376
  useHelpAccessibility: useHelpAccessibility,
10308
- getDefaultFontStack: getDefaultFontStack
10377
+ getDefaultFontStack: getDefaultFontStack,
10378
+ getFilteredTableMenuItems: getFilteredTableMenuItems
10309
10379
  });
10310
10380
 
10311
10381
  const setup$e = (api, editor) => {
@@ -23400,9 +23470,10 @@
23400
23470
  });
23401
23471
  const menus = map$2(validMenus, menuName => {
23402
23472
  const menuData = rawMenuData[menuName];
23473
+ const items = menuName === 'table' ? parseItemsString(getFilteredTableMenuItems(editor, menuData.items)) : parseItemsString(menuData.items);
23403
23474
  return make({
23404
23475
  title: menuData.title,
23405
- items: parseItemsString(menuData.items)
23476
+ items
23406
23477
  }, registry, editor);
23407
23478
  });
23408
23479
  return filter$2(menus, menu => {