BookStack/public/libs/tinymce/plugins/table/plugin.min.js
2019-04-21 13:49:46 +01:00

1 line
118 KiB
JavaScript

!function(m){"use strict";var e=tinymce.util.Tools.resolve("tinymce.PluginManager"),y=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t]},x=function(n,r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n(r.apply(null,e))}},C=function(e){return function(){return e}},o=function(e){return e};function b(r){for(var o=[],e=1;e<arguments.length;e++)o[e-1]=arguments[e];return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=o.concat(e);return r.apply(null,n)}}var t,n,r,i,u,g=function(n){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return!n.apply(null,e)}},c=function(e){return e()},a=C(!1),l=C(!0),f=a,s=l,d=function(){return h},h=(i={fold:function(e,t){return e()},is:f,isSome:f,isNone:s,getOr:r=function(e){return e},getOrThunk:n=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:r,orThunk:n,map:d,ap:d,each:function(){},bind:d,flatten:d,exists:f,forall:s,filter:d,equals:t=function(e){return e.isNone()},equals_:t,toArray:function(){return[]},toString:C("none()")},Object.freeze&&Object.freeze(i),i),p=function(n){var e=function(){return n},t=function(){return o},r=function(e){return e(n)},o={fold:function(e,t){return t(n)},is:function(e){return n===e},isSome:s,isNone:f,getOr:e,getOrThunk:e,getOrDie:e,getOrNull:e,getOrUndefined:e,or:t,orThunk:t,map:function(e){return p(e(n))},ap:function(e){return e.fold(d,function(e){return p(e(n))})},each:function(e){e(n)},bind:r,flatten:e,exists:r,forall:r,filter:function(e){return e(n)?o:h},equals:function(e){return e.is(n)},equals_:function(e,t){return e.fold(f,function(e){return t(n,e)})},toArray:function(){return[n]},toString:function(){return"some("+n+")"}};return o},S={some:p,none:d,from:function(e){return null===e||e===undefined?h:p(e)}},v=function(t){return function(e){return function(e){if(null===e)return"null";var t=typeof e;return"object"===t&&Array.prototype.isPrototypeOf(e)?"array":"object"===t&&String.prototype.isPrototypeOf(e)?"string":t}(e)===t}},w=v("string"),R=v("array"),T=v("boolean"),D=v("function"),O=v("number"),N=(u=Array.prototype.indexOf)===undefined?function(e,t){return j(e,t)}:function(e,t){return u.call(e,t)},E=function(e,t){return-1<N(e,t)},A=function(e,t){return L(e,t).isSome()},k=function(e,t){for(var n=e.length,r=new Array(n),o=0;o<n;o++){var i=e[o];r[o]=t(i,o,e)}return r},P=function(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n,e)},I=function(e,t){for(var n=[],r=0,o=e.length;r<o;r++){var i=e[r];t(i,r,e)&&n.push(i)}return n},B=function(e,t){if(0===e.length)return[];for(var n=t(e[0]),r=[],o=[],i=0,u=e.length;i<u;i++){var a=e[i],c=t(a);c!==n&&(r.push(o),o=[]),n=c,o.push(a)}return 0!==o.length&&r.push(o),r},W=function(e,t,n){return function(e,t){for(var n=e.length-1;0<=n;n--)t(e[n],n,e)}(e,function(e){n=t(n,e)}),n},M=function(e,t,n){return P(e,function(e){n=t(n,e)}),n},_=function(e,t){for(var n=0,r=e.length;n<r;n++){var o=e[n];if(t(o,n,e))return S.some(o)}return S.none()},L=function(e,t){for(var n=0,r=e.length;n<r;n++)if(t(e[n],n,e))return S.some(n);return S.none()},j=function(e,t){for(var n=0,r=e.length;n<r;++n)if(e[n]===t)return n;return-1},F=Array.prototype.push,z=function(e){for(var t=[],n=0,r=e.length;n<r;++n){if(!Array.prototype.isPrototypeOf(e[n]))throw new Error("Arr.flatten item "+n+" was not an array, input: "+e);F.apply(t,e[n])}return t},H=function(e,t){var n=k(e,t);return z(n)},U=function(e,t){for(var n=0,r=e.length;n<r;++n)if(!0!==t(e[n],n,e))return!1;return!0},q=Array.prototype.slice,V=function(e){var t=q.call(e,0);return t.reverse(),t},G=function(e,t){var n=q.call(e,0);return n.sort(t),n},Y=(D(Array.from)&&Array.from,Object.keys),X=function(e,t){for(var n=Y(e),r=0,o=n.length;r<o;r++){var i=n[r];t(e[i],i,e)}},K=function(e,r){return J(e,function(e,t,n){return{k:t,v:r(e,t,n)}})},J=function(r,o){var i={};return X(r,function(e,t){var n=o(e,t,r);i[n.k]=n.v}),i},$=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];if(t.length!==n.length)throw new Error('Wrong number of arguments to struct. Expected "['+t.length+']", got '+n.length+" arguments");var r={};return P(t,function(e,t){r[e]=C(n[t])}),r}},Q=function(e){return e.slice(0).sort()},Z=function(e,t){throw new Error("All required keys ("+Q(e).join(", ")+") were not specified. Specified keys were: "+Q(t).join(", ")+".")},ee=function(e){throw new Error("Unsupported keys for object: "+Q(e).join(", "))},te=function(t,e){if(!R(e))throw new Error("The "+t+" fields must be an array. Was: "+e+".");P(e,function(e){if(!w(e))throw new Error("The value "+e+" in the "+t+" fields was not a string.")})},ne=function(e){var n=Q(e);_(n,function(e,t){return t<n.length-1&&e===n[t+1]}).each(function(e){throw new Error("The field: "+e+" occurs more than once in the combined fields: ["+n.join(", ")+"].")})},re=function(o,i){var u=o.concat(i);if(0===u.length)throw new Error("You must specify at least one required or optional field.");return te("required",o),te("optional",i),ne(u),function(t){var n=Y(t);U(o,function(e){return E(n,e)})||Z(o,n);var e=I(n,function(e){return!E(u,e)});0<e.length&&ee(e);var r={};return P(o,function(e){r[e]=C(t[e])}),P(i,function(e){r[e]=C(Object.prototype.hasOwnProperty.call(t,e)?S.some(t[e]):S.none())}),r}},oe=(m.Node.ATTRIBUTE_NODE,m.Node.CDATA_SECTION_NODE,m.Node.COMMENT_NODE),ie=m.Node.DOCUMENT_NODE,ue=(m.Node.DOCUMENT_TYPE_NODE,m.Node.DOCUMENT_FRAGMENT_NODE,m.Node.ELEMENT_NODE),ae=m.Node.TEXT_NODE,ce=(m.Node.PROCESSING_INSTRUCTION_NODE,m.Node.ENTITY_REFERENCE_NODE,m.Node.ENTITY_NODE,m.Node.NOTATION_NODE,function(e){return e.dom().nodeName.toLowerCase()}),le=function(e){return e.dom().nodeType},fe=function(t){return function(e){return le(e)===t}},se=function(e){return le(e)===oe||"#comment"===ce(e)},de=fe(ue),me=fe(ae),ge=fe(ie),he=function(e,t,n){if(!(w(n)||T(n)||O(n)))throw m.console.error("Invalid call to Attr.set. Key ",t,":: Value ",n,":: Element ",e),new Error("Attribute value was not simple");e.setAttribute(t,n+"")},pe=function(e,t,n){he(e.dom(),t,n)},ve=function(e,t){var n=e.dom();X(t,function(e,t){he(n,t,e)})},be=function(e,t){var n=e.dom().getAttribute(t);return null===n?undefined:n},we=function(e,t){var n=e.dom();return!(!n||!n.hasAttribute)&&n.hasAttribute(t)},ye=function(e,t){e.dom().removeAttribute(t)},xe=function(e){return M(e.dom().attributes,function(e,t){return e[t.name]=t.value,e},{})},Ce=function(e,t){return-1!==e.indexOf(t)},Se=function(e){return e.style!==undefined},Re=function(n){var r,o=!1;return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return o||(o=!0,r=n.apply(null,e)),r}},Te=function(e){if(null===e||e===undefined)throw new Error("Node cannot be null or undefined");return{dom:C(e)}},De={fromHtml:function(e,t){var n=(t||m.document).createElement("div");if(n.innerHTML=e,!n.hasChildNodes()||1<n.childNodes.length)throw m.console.error("HTML does not have a single root node",e),new Error("HTML must have a single root node");return Te(n.childNodes[0])},fromTag:function(e,t){var n=(t||m.document).createElement(e);return Te(n)},fromText:function(e,t){var n=(t||m.document).createTextNode(e);return Te(n)},fromDom:Te,fromPoint:function(e,t,n){var r=e.dom();return S.from(r.elementFromPoint(t,n)).map(Te)}},Oe=function(e){var t=me(e)?e.dom().parentNode:e.dom();return t!==undefined&&null!==t&&t.ownerDocument.body.contains(t)},Ne=Re(function(){return Ee(De.fromDom(m.document))}),Ee=function(e){var t=e.dom().body;if(null===t||t===undefined)throw new Error("Body is not available yet");return De.fromDom(t)},Ae=function(e,t,n){if(!w(n))throw m.console.error("Invalid call to CSS.set. Property ",t,":: Value ",n,":: Element ",e),new Error("CSS value must be a string: "+n);Se(e)&&e.style.setProperty(t,n)},ke=function(e,t,n){var r=e.dom();Ae(r,t,n)},Pe=function(e,t){var n=e.dom();X(t,function(e,t){Ae(n,t,e)})},Ie=function(e,t){var n=e.dom(),r=m.window.getComputedStyle(n).getPropertyValue(t),o=""!==r||Oe(e)?r:Be(n,t);return null===o?undefined:o},Be=function(e,t){return Se(e)?e.style.getPropertyValue(t):""},We=function(e,t){var n=e.dom(),r=Be(n,t);return S.from(r).filter(function(e){return 0<e.length})},Me=function(e,t){var n,r,o=e.dom();r=t,Se(n=o)&&n.style.removeProperty(r),we(e,"style")&&""===be(e,"style").replace(/^\s+|\s+$/g,"")&&ye(e,"style")},_e="undefined"!=typeof m.window?m.window:Function("return this;")(),Le=function(e,t){return function(e,t){for(var n=t!==undefined&&null!==t?t:_e,r=0;r<e.length&&n!==undefined&&null!==n;++r)n=n[e[r]];return n}(e.split("."),t)},je=function(e,t){var n=Le(e,t);if(n===undefined||null===n)throw e+" not available on this browser";return n},Fe=function(){return je("Node")},ze=function(e,t,n){return 0!=(e.compareDocumentPosition(t)&n)},He=function(e,t){return ze(e,t,Fe().DOCUMENT_POSITION_CONTAINED_BY)},Ue=function(e,t){var n=function(e,t){for(var n=0;n<e.length;n++){var r=e[n];if(r.test(t))return r}return undefined}(e,t);if(!n)return{major:0,minor:0};var r=function(e){return Number(t.replace(n,"$"+e))};return Ve(r(1),r(2))},qe=function(){return Ve(0,0)},Ve=function(e,t){return{major:e,minor:t}},Ge={nu:Ve,detect:function(e,t){var n=String(t).toLowerCase();return 0===e.length?qe():Ue(e,n)},unknown:qe},Ye="Firefox",Xe=function(e,t){return function(){return t===e}},Ke=function(e){var t=e.current;return{current:t,version:e.version,isEdge:Xe("Edge",t),isChrome:Xe("Chrome",t),isIE:Xe("IE",t),isOpera:Xe("Opera",t),isFirefox:Xe(Ye,t),isSafari:Xe("Safari",t)}},Je={unknown:function(){return Ke({current:undefined,version:Ge.unknown()})},nu:Ke,edge:C("Edge"),chrome:C("Chrome"),ie:C("IE"),opera:C("Opera"),firefox:C(Ye),safari:C("Safari")},$e="Windows",Qe="Android",Ze="Solaris",et="FreeBSD",tt=function(e,t){return function(){return t===e}},nt=function(e){var t=e.current;return{current:t,version:e.version,isWindows:tt($e,t),isiOS:tt("iOS",t),isAndroid:tt(Qe,t),isOSX:tt("OSX",t),isLinux:tt("Linux",t),isSolaris:tt(Ze,t),isFreeBSD:tt(et,t)}},rt={unknown:function(){return nt({current:undefined,version:Ge.unknown()})},nu:nt,windows:C($e),ios:C("iOS"),android:C(Qe),linux:C("Linux"),osx:C("OSX"),solaris:C(Ze),freebsd:C(et)},ot=function(e,t){var n=String(t).toLowerCase();return _(e,function(e){return e.search(n)})},it=function(e,n){return ot(e,n).map(function(e){var t=Ge.detect(e.versionRegexes,n);return{current:e.name,version:t}})},ut=function(e,n){return ot(e,n).map(function(e){var t=Ge.detect(e.versionRegexes,n);return{current:e.name,version:t}})},at=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,ct=function(t){return function(e){return Ce(e,t)}},lt=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(e){return Ce(e,"edge/")&&Ce(e,"chrome")&&Ce(e,"safari")&&Ce(e,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,at],search:function(e){return Ce(e,"chrome")&&!Ce(e,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(e){return Ce(e,"msie")||Ce(e,"trident")}},{name:"Opera",versionRegexes:[at,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:ct("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:ct("firefox")},{name:"Safari",versionRegexes:[at,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(e){return(Ce(e,"safari")||Ce(e,"mobile/"))&&Ce(e,"applewebkit")}}],ft=[{name:"Windows",search:ct("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(e){return Ce(e,"iphone")||Ce(e,"ipad")},versionRegexes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:ct("android"),versionRegexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:ct("os x"),versionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:ct("linux"),versionRegexes:[]},{name:"Solaris",search:ct("sunos"),versionRegexes:[]},{name:"FreeBSD",search:ct("freebsd"),versionRegexes:[]}],st={browsers:C(lt),oses:C(ft)},dt=function(e){var t,n,r,o,i,u,a,c,l,f,s,d=st.browsers(),m=st.oses(),g=it(d,e).fold(Je.unknown,Je.nu),h=ut(m,e).fold(rt.unknown,rt.nu);return{browser:g,os:h,deviceType:(n=g,r=e,o=(t=h).isiOS()&&!0===/ipad/i.test(r),i=t.isiOS()&&!o,u=t.isAndroid()&&3===t.version.major,a=t.isAndroid()&&4===t.version.major,c=o||u||a&&!0===/mobile/i.test(r),l=t.isiOS()||t.isAndroid(),f=l&&!c,s=n.isSafari()&&t.isiOS()&&!1===/safari/i.test(r),{isiPad:C(o),isiPhone:C(i),isTablet:C(c),isPhone:C(f),isTouch:C(l),isAndroid:t.isAndroid,isiOS:t.isiOS,isWebView:C(s)})}},mt={detect:Re(function(){var e=m.navigator.userAgent;return dt(e)})},gt=ue,ht=ie,pt=function(e,t){var n=e.dom();if(n.nodeType!==gt)return!1;if(n.matches!==undefined)return n.matches(t);if(n.msMatchesSelector!==undefined)return n.msMatchesSelector(t);if(n.webkitMatchesSelector!==undefined)return n.webkitMatchesSelector(t);if(n.mozMatchesSelector!==undefined)return n.mozMatchesSelector(t);throw new Error("Browser lacks native selectors")},vt=function(e){return e.nodeType!==gt&&e.nodeType!==ht||0===e.childElementCount},bt=function(e,t){return e.dom()===t.dom()},wt=mt.detect().browser.isIE()?function(e,t){return He(e.dom(),t.dom())}:function(e,t){var n=e.dom(),r=t.dom();return n!==r&&n.contains(r)},yt=pt,xt=function(e){return De.fromDom(e.dom().ownerDocument)},Ct=function(e){var t=e.dom();return S.from(t.parentNode).map(De.fromDom)},St=function(e,t){for(var n=D(t)?t:C(!1),r=e.dom(),o=[];null!==r.parentNode&&r.parentNode!==undefined;){var i=r.parentNode,u=De.fromDom(i);if(o.push(u),!0===n(u))break;r=i}return o},Rt=function(e){var t=e.dom();return S.from(t.previousSibling).map(De.fromDom)},Tt=function(e){var t=e.dom();return S.from(t.nextSibling).map(De.fromDom)},Dt=function(e){var t=e.dom();return k(t.childNodes,De.fromDom)},Ot=function(e,t){var n=e.dom().childNodes;return S.from(n[t]).map(De.fromDom)},Nt=($("element","offset"),function(t,n){Ct(t).each(function(e){e.dom().insertBefore(n.dom(),t.dom())})}),Et=function(e,t){Tt(e).fold(function(){Ct(e).each(function(e){kt(e,t)})},function(e){Nt(e,t)})},At=function(t,n){Ot(t,0).fold(function(){kt(t,n)},function(e){t.dom().insertBefore(n.dom(),e.dom())})},kt=function(e,t){e.dom().appendChild(t.dom())},Pt=function(e,t){Nt(e,t),kt(t,e)},It=function(r,o){P(o,function(e,t){var n=0===t?r:o[t-1];Et(n,e)})},Bt=function(t,e){P(e,function(e){kt(t,e)})},Wt=function(e){e.dom().textContent="",P(Dt(e),function(e){Mt(e)})},Mt=function(e){var t=e.dom();null!==t.parentNode&&t.parentNode.removeChild(t)},_t=function(e){var t,n=Dt(e);0<n.length&&(t=e,P(n,function(e){Nt(t,e)})),Mt(e)},Lt=$("width","height"),jt=$("rows","columns"),Ft=$("row","column"),zt=$("x","y"),Ht=$("element","rowspan","colspan"),Ut=$("element","rowspan","colspan","isNew"),qt={dimensions:Lt,grid:jt,address:Ft,coords:zt,extended:$("element","rowspan","colspan","row","column"),detail:Ht,detailnew:Ut,rowdata:$("element","cells","section"),elementnew:$("element","isNew"),rowdatanew:$("element","cells","section","isNew"),rowcells:$("cells","section"),rowdetails:$("details","section"),bounds:$("startRow","startCol","finishRow","finishCol")},Vt=function(e,t){var n=[];return P(Dt(e),function(e){t(e)&&(n=n.concat([e])),n=n.concat(Vt(e,t))}),n},Gt=function(e,t,n){return r=function(e){return pt(e,t)},I(St(e,n),r);var r},Yt=function(e,t){return n=function(e){return pt(e,t)},I(Dt(e),n);var n},Xt=function(e,t){return n=t,o=(r=e)===undefined?m.document:r.dom(),vt(o)?[]:k(o.querySelectorAll(n),De.fromDom);var n,r,o};function Kt(e,t,n,r,o){return e(n,r)?S.some(n):D(o)&&o(n)?S.none():t(n,r,o)}var Jt,$t,Qt,Zt,en,tn=function(e,t,n){for(var r=e.dom(),o=D(n)?n:C(!1);r.parentNode;){r=r.parentNode;var i=De.fromDom(r);if(t(i))return S.some(i);if(o(i))break}return S.none()},nn=function(e,t,n){return tn(e,function(e){return pt(e,t)},n)},rn=function(e,t){return n=function(e){return pt(e,t)},_(e.dom().childNodes,x(n,De.fromDom)).map(De.fromDom);var n},on=function(e,t){return n=t,o=(r=e)===undefined?m.document:r.dom(),vt(o)?S.none():S.from(o.querySelector(n)).map(De.fromDom);var n,r,o},un=function(e,t,n){return Kt(pt,nn,e,t,n)},an=function(e,t,n){return H(Dt(e),function(e){return pt(e,t)?n(e)?[e]:[]:an(e,t,n)})},cn={firstLayer:function(e,t){return an(e,t,C(!0))},filterFirstLayer:an},ln=function(e,t,n){var r=n!==undefined?n:C(!1);return r(t)?S.none():E(e,ce(t))?S.some(t):nn(t,e.join(","),function(e){return pt(e,"table")||r(e)})},fn=function(t,e){return Ct(e).map(function(e){return Yt(e,t)})},sn=b(fn,"th,td"),dn=b(fn,"tr"),mn=function(e,t){return parseInt(be(e,t),10)},gn={cell:function(e,t){return ln(["td","th"],e,t)},firstCell:function(e){return on(e,"th,td")},cells:function(e){return cn.firstLayer(e,"th,td")},neighbourCells:sn,table:function(e,t){return un(e,"table",t)},row:function(e,t){return ln(["tr"],e,t)},rows:function(e){return cn.firstLayer(e,"tr")},notCell:function(e,t){return ln(["caption","tr","tbody","tfoot","thead"],e,t)},neighbourRows:dn,attr:mn,grid:function(e,t,n){var r=mn(e,t),o=mn(e,n);return qt.grid(r,o)}},hn=function(e){var t=gn.rows(e);return k(t,function(e){var t=e,n=Ct(t).map(function(e){var t=ce(e);return"tfoot"===t||"thead"===t||"tbody"===t?t:"tbody"}).getOr("tbody"),r=k(gn.cells(e),function(e){var t=we(e,"rowspan")?parseInt(be(e,"rowspan"),10):1,n=we(e,"colspan")?parseInt(be(e,"colspan"),10):1;return qt.detail(e,t,n)});return qt.rowdata(t,r,n)})},pn=function(e,n){return k(e,function(e){var t=k(gn.cells(e),function(e){var t=we(e,"rowspan")?parseInt(be(e,"rowspan"),10):1,n=we(e,"colspan")?parseInt(be(e,"colspan"),10):1;return qt.detail(e,t,n)});return qt.rowdata(e,t,n.section())})},vn=function(e,t){return e+","+t},bn=function(e,t){var n=H(e.all(),function(e){return e.cells()});return I(n,t)},wn={generate:function(e){var f={},t=[],n=e.length,s=0;P(e,function(e,c){var l=[];P(e.cells(),function(e,t){for(var n=0;f[vn(c,n)]!==undefined;)n++;for(var r=qt.extended(e.element(),e.rowspan(),e.colspan(),c,n),o=0;o<e.colspan();o++)for(var i=0;i<e.rowspan();i++){var u=n+o,a=vn(c+i,u);f[a]=r,s=Math.max(s,u+1)}l.push(r)}),t.push(qt.rowdata(e.element(),l,e.section()))});var r=qt.grid(n,s);return{grid:C(r),access:C(f),all:C(t)}},getAt:function(e,t,n){var r=e.access()[vn(t,n)];return r!==undefined?S.some(r):S.none()},findItem:function(e,t,n){var r=bn(e,function(e){return n(t,e.element())});return 0<r.length?S.some(r[0]):S.none()},filterItems:bn,justCells:function(e){var t=k(e.all(),function(e){return e.cells()});return z(t)}},yn=$("minRow","minCol","maxRow","maxCol"),xn=function(e,t){var n,i,r,u,a,c,l,o,f,s,d=function(e){return pt(e.element(),t)},m=hn(e),g=wn.generate(m),h=(i=d,r=(n=g).grid().columns(),u=n.grid().rows(),a=r,l=c=0,X(n.access(),function(e){if(i(e)){var t=e.row(),n=t+e.rowspan()-1,r=e.column(),o=r+e.colspan()-1;t<u?u=t:c<n&&(c=n),r<a?a=r:l<o&&(l=o)}}),yn(u,a,c,l)),p="th:not("+t+"),td:not("+t+")",v=cn.filterFirstLayer(e,"th,td",function(e){return pt(e,p)});return P(v,Mt),function(e,t,n,r){for(var o,i,u,a=t.grid().columns(),c=t.grid().rows(),l=0;l<c;l++)for(var f=!1,s=0;s<a;s++)l<n.minRow()||l>n.maxRow()||s<n.minCol()||s>n.maxCol()||(wn.getAt(t,l,s).filter(r).isNone()?(o=f,i=e[l].element(),u=De.fromTag("td"),kt(u,De.fromTag("br")),(o?kt:At)(i,u)):f=!0)}(m,g,h,d),o=e,f=h,s=I(cn.firstLayer(o,"tr"),function(e){return 0===e.dom().childElementCount}),P(s,Mt),f.minCol()!==f.maxCol()&&f.minRow()!==f.maxRow()||P(cn.firstLayer(o,"th,td"),function(e){ye(e,"rowspan"),ye(e,"colspan")}),ye(o,"width"),ye(o,"height"),Me(o,"width"),Me(o,"height"),e},Cn=(Jt=me,$t="text",Qt=function(e){return Jt(e)?S.from(e.dom().nodeValue):S.none()},Zt=mt.detect().browser,{get:function(e){if(!Jt(e))throw new Error("Can only get "+$t+" value of a "+$t+" node");return en(e).getOr("")},getOption:en=Zt.isIE()&&10===Zt.version.major?function(e){try{return Qt(e)}catch(t){return S.none()}}:Qt,set:function(e,t){if(!Jt(e))throw new Error("Can only set raw "+$t+" value of a "+$t+" node");e.dom().nodeValue=t}}),Sn=function(e){return Cn.get(e)},Rn=function(e){return Cn.getOption(e)},Tn=function(e,t){Cn.set(e,t)},Dn=function(e){return"img"===ce(e)?1:Rn(e).fold(function(){return Dt(e).length},function(e){return e.length})},On=["img","br"],Nn=function(e){return Rn(e).filter(function(e){return 0!==e.trim().length||-1<e.indexOf("\xa0")}).isSome()||E(On,ce(e))},En=function(e){return r=Nn,(o=function(e){for(var t=0;t<e.childNodes.length;t++){if(r(De.fromDom(e.childNodes[t])))return S.some(De.fromDom(e.childNodes[t]));var n=o(e.childNodes[t]);if(n.isSome())return n}return S.none()})(e.dom());var r,o},An=function(e){return kn(e,Nn)},kn=function(e,i){var u=function(e){for(var t=Dt(e),n=t.length-1;0<=n;n--){var r=t[n];if(i(r))return S.some(r);var o=u(r);if(o.isSome())return o}return S.none()};return u(e)},Pn=function(e,t){return De.fromDom(e.dom().cloneNode(t))},In=function(e){return Pn(e,!1)},Bn=function(e){return Pn(e,!0)},Wn=function(e,t){var n,r,o,i,u=(n=e,r=t,o=De.fromTag(r),i=xe(n),ve(o,i),o),a=Dt(Bn(e));return Bt(u,a),u},Mn=function(){var e=De.fromTag("td");return kt(e,De.fromTag("br")),e},_n=function(e,t,n){var r=Wn(e,t);return X(n,function(e,t){null===e?ye(r,t):pe(r,t,e)}),r},Ln=function(e){return e},jn=function(e){return function(){return De.fromTag("tr",e.dom())}},Fn=function(d,e,m){return{row:jn(e),cell:function(e){var r,o,i,t,n,u,a,c=xt(e.element()),l=De.fromTag(ce(e.element()),c.dom()),f=m.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),s=0<f.length?(r=e.element(),o=l,i=f,En(r).map(function(e){var t=i.join(","),n=Gt(e,t,function(e){return bt(e,r)});return W(n,function(e,t){var n=In(t);return ye(n,"contenteditable"),kt(e,n),n},o)}).getOr(o)):l;return kt(s,De.fromTag("br")),t=e.element(),n=l,u=t.dom(),a=n.dom(),Se(u)&&Se(a)&&(a.style.cssText=u.style.cssText),Me(l,"height"),1!==e.colspan()&&Me(e.element(),"width"),d(e.element(),l),l},replace:_n,gap:Mn}},zn=function(e){return{row:jn(e),cell:Mn,replace:Ln,gap:Mn}},Hn=["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"];function Un(){return{up:C({selector:nn,closest:un,predicate:tn,all:St}),down:C({selector:Xt,predicate:Vt}),styles:C({get:Ie,getRaw:We,set:ke,remove:Me}),attrs:C({get:be,set:pe,remove:ye,copyTo:function(e,t){var n=xe(e);ve(t,n)}}),insert:C({before:Nt,after:Et,afterAll:It,append:kt,appendAll:Bt,prepend:At,wrap:Pt}),remove:C({unwrap:_t,remove:Mt}),create:C({nu:De.fromTag,clone:function(e){return De.fromDom(e.dom().cloneNode(!1))},text:De.fromText}),query:C({comparePosition:function(e,t){return e.dom().compareDocumentPosition(t.dom())},prevSibling:Rt,nextSibling:Tt}),property:C({children:Dt,name:ce,parent:Ct,document:function(e){return e.dom().ownerDocument},isText:me,isComment:se,isElement:de,getText:Sn,setText:Tn,isBoundary:function(e){return!!de(e)&&("body"===ce(e)||E(Hn,ce(e)))},isEmptyTag:function(e){return!!de(e)&&E(["br","img","hr","input"],ce(e))}}),eq:bt,is:yt}}var qn=$("left","right"),Vn=function(e,t,n){var r=e.property().children(t);return L(r,b(e.eq,n)).map(function(e){return{before:C(r.slice(0,e)),after:C(r.slice(e+1))}})},Gn=function(n,r,o){return Vn(n,r,o).map(function(e){var t=n.create().clone(r);return n.insert().appendAll(t,e.before().concat([o])),n.insert().appendAll(r,e.after()),n.insert().before(r,t),qn(t,r)})},Yn=function(n,r,e){return Vn(n,r,e).map(function(e){var t=n.create().clone(r);return n.insert().appendAll(t,e.after()),n.insert().after(r,t),qn(r,t)})},Xn=function(i,e,u,a){var r=$("first","second","splits"),c=function(e,t,o){var n=r(e,S.none(),o);return u(e)?r(e,t,o):i.property().parent(e).bind(function(r){return a(i,r,e).map(function(e){var t=[{first:e.left,second:e.right}],n=u(r)?r:e.left();return c(n,S.some(e.right()),o.concat(t))}).getOr(n)})};return c(e,S.none(),[])},Kn=function(r,o,e,t){var n=o(r,e);return W(t,function(e,t){var n=o(r,t);return Jn(r,e,n)},n)},Jn=function(t,e,n){return e.bind(function(e){return n.filter(b(t.eq,e))})},$n=function(e,t,n){return 0<n.length?Kn(e,t,(r=n)[0],r.slice(1)):S.none();var r},Qn=function(e,t){return b(e.eq,t)},Zn=function(t,e,n,r){var o=r!==undefined?r:C(!1),i=[e].concat(t.up().all(e)),u=[n].concat(t.up().all(n)),a=function(t){return L(t,o).fold(function(){return t},function(e){return t.slice(0,e+1)})},c=a(i),l=a(u),f=_(c,function(e){return A(l,Qn(t,e))});return{firstpath:C(c),secondpath:C(l),shared:C(f)}},er=function(t,e,n){var r=Zn(t,e,n);return r.shared().bind(function(e){return function(o,i,e,t){var u=o.property().children(i);if(o.eq(i,e[0]))return S.some([e[0]]);if(o.eq(i,t[0]))return S.some([t[0]]);var n=function(e){var t=V(e),n=L(t,Qn(o,i)).getOr(-1),r=n<t.length-1?t[n+1]:t[n];return L(u,Qn(o,r))},r=n(e),a=n(t);return r.bind(function(r){return a.map(function(e){var t=Math.min(r,e),n=Math.max(r,e);return u.slice(t,n+1)})})}(t,e,r.firstpath(),r.secondpath())})},tr=Zn,nr=function(e,t,n){return $n(e,t,n)},rr=function(e,t,n){return er(e,t,n)},or=function(e,t,n,r){return tr(e,t,n,r)},ir=function(e,t,n){return Gn(e,t,n)},ur=function(e,t,n){return Yn(e,t,n)},ar=function(e,t,n,r){return Xn(e,t,n,r)},cr=Un(),lr={sharedOne:function(n,e){return nr(cr,function(e,t){return n(t)},e)},subset:function(e,t){return rr(cr,e,t)},ancestors:function(e,t,n){return or(cr,e,t,n)},breakToLeft:function(e,t){return ir(cr,e,t)},breakToRight:function(e,t){return ur(cr,e,t)},breakPath:function(e,t,r){return ar(cr,e,t,function(e,t,n){return r(t,n)})}},fr=function(e,t){return t.column()>=e.startCol()&&t.column()+t.colspan()-1<=e.finishCol()&&t.row()>=e.startRow()&&t.row()+t.rowspan()-1<=e.finishRow()},sr=function(e,t){var n=t.column(),r=t.column()+t.colspan()-1,o=t.row(),i=t.row()+t.rowspan()-1;return n<=e.finishCol()&&r>=e.startCol()&&o<=e.finishRow()&&i>=e.startRow()},dr=function(e,t){for(var n=!0,r=b(fr,t),o=t.startRow();o<=t.finishRow();o++)for(var i=t.startCol();i<=t.finishCol();i++)n=n&&wn.getAt(e,o,i).exists(r);return n?S.some(t):S.none()},mr=function(e,t,n){var r=wn.findItem(e,t,bt),o=wn.findItem(e,n,bt);return r.bind(function(r){return o.map(function(e){return t=r,n=e,qt.bounds(Math.min(t.row(),n.row()),Math.min(t.column(),n.column()),Math.max(t.row()+t.rowspan()-1,n.row()+n.rowspan()-1),Math.max(t.column()+t.colspan()-1,n.column()+n.colspan()-1));var t,n})})},gr=mr,hr=function(t,e,n){return mr(t,e,n).bind(function(e){return dr(t,e)})},pr=function(r,e,o,i){return wn.findItem(r,e,bt).bind(function(e){var t=0<o?e.row()+e.rowspan()-1:e.row(),n=0<i?e.column()+e.colspan()-1:e.column();return wn.getAt(r,t+o,n+i).map(function(e){return e.element()})})},vr=function(n,e,t){return gr(n,e,t).map(function(e){var t=wn.filterItems(n,b(sr,e));return k(t,function(e){return e.element()})})},br=function(e,t){return wn.findItem(e,t,function(e,t){return wt(t,e)}).bind(function(e){return e.element()})},wr=function(e){var t=hn(e);return wn.generate(t)},yr=function(n,r,o){return gn.table(n).bind(function(e){var t=wr(e);return pr(t,n,r,o)})},xr=function(e,t,n){var r=wr(e);return vr(r,t,n)},Cr=function(e,t,n,r,o){var i=wr(e),u=bt(e,n)?t:br(i,t),a=bt(e,o)?r:br(i,r);return vr(i,u,a)},Sr=function(e,t,n){var r=wr(e);return hr(r,t,n)},Rr=function(e,t){return nn(e,"table")},Tr=re(["boxes","start","finish"],[]),Dr=function(a,c,r){var l=function(t){return function(e){return r(e)||bt(e,t)}};return bt(a,c)?S.some(Tr({boxes:S.some([a]),start:a,finish:c})):Rr(a).bind(function(u){return Rr(c).bind(function(i){if(bt(u,i))return S.some(Tr({boxes:xr(u,a,c),start:a,finish:c}));if(wt(u,i)){var e=0<(t=Gt(c,"td,th",l(u))).length?t[t.length-1]:c;return S.some(Tr({boxes:Cr(u,a,u,c,i),start:a,finish:e}))}if(wt(i,u)){var t,n=0<(t=Gt(a,"td,th",l(i))).length?t[t.length-1]:a;return S.some(Tr({boxes:Cr(i,a,u,c,i),start:a,finish:n}))}return lr.ancestors(a,c).shared().bind(function(e){return un(e,"table",r).bind(function(e){var t=Gt(c,"td,th",l(e)),n=0<t.length?t[t.length-1]:c,r=Gt(a,"td,th",l(e)),o=0<r.length?r[r.length-1]:a;return S.some(Tr({boxes:Cr(e,a,u,c,i),start:o,finish:n}))})})})})},Or=Dr,Nr=function(e,t){var n=Xt(e,t);return 0<n.length?S.some(n):S.none()},Er=function(e,t,n,r,o){return(i=e,u=o,_(i,function(e){return pt(e,u)})).bind(function(e){return yr(e,t,n).bind(function(e){return n=r,nn(t=e,"table").bind(function(e){return on(e,n).bind(function(e){return Dr(e,t).bind(function(t){return t.boxes().map(function(e){return{boxes:C(e),start:C(t.start()),finish:C(t.finish())}})})})});var t,n})});var i,u},Ar=function(e,t,r){return on(e,t).bind(function(n){return on(e,r).bind(function(t){return lr.sharedOne(Rr,[n,t]).map(function(e){return{first:C(n),last:C(t),table:C(e)}})})})},kr=function(e,t){return Nr(e,t)},Pr=function(o,e,t){return Ar(o,e,t).bind(function(n){var e=function(e){return bt(o,e)},t=nn(n.first(),"thead,tfoot,tbody,table",e),r=nn(n.last(),"thead,tfoot,tbody,table",e);return t.bind(function(t){return r.bind(function(e){return bt(t,e)?Sr(n.table(),n.first(),n.last()):S.none()})})})},Ir="data-mce-selected",Br="data-mce-first-selected",Wr="data-mce-last-selected",Mr={selected:C(Ir),selectedSelector:C("td[data-mce-selected],th[data-mce-selected]"),attributeSelector:C("[data-mce-selected]"),firstSelected:C(Br),firstSelectedSelector:C("td[data-mce-first-selected],th[data-mce-first-selected]"),lastSelected:C(Wr),lastSelectedSelector:C("td[data-mce-last-selected],th[data-mce-last-selected]")},_r=function(u){if(!R(u))throw new Error("cases must be an array");if(0===u.length)throw new Error("there must be at least one case");var a=[],n={};return P(u,function(e,r){var t=Y(e);if(1!==t.length)throw new Error("one and only one name per case");var o=t[0],i=e[o];if(n[o]!==undefined)throw new Error("duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case named cata (sorry)");if(!R(i))throw new Error("case arguments must be an array");a.push(o),n[o]=function(){var e=arguments.length;if(e!==i.length)throw new Error("Wrong number of arguments to case "+o+". Expected "+i.length+" ("+i+"), got "+e);for(var n=new Array(e),t=0;t<n.length;t++)n[t]=arguments[t];return{fold:function(){if(arguments.length!==u.length)throw new Error("Wrong number of arguments to fold. Expected "+u.length+", got "+arguments.length);return arguments[r].apply(null,n)},match:function(e){var t=Y(e);if(a.length!==t.length)throw new Error("Wrong number of arguments to match. Expected: "+a.join(",")+"\nActual: "+t.join(","));if(!U(a,function(e){return E(t,e)}))throw new Error("Not all branches were specified when using match. Specified: "+t.join(", ")+"\nRequired: "+a.join(", "));return e[o].apply(null,n)},log:function(e){m.console.log(e,{constructors:a,constructor:o,params:n})}}}}),n},Lr=_r([{none:[]},{multiple:["elements"]},{single:["selection"]}]),jr={cata:function(e,t,n,r){return e.fold(t,n,r)},none:Lr.none,multiple:Lr.multiple,single:Lr.single},Fr=function(e,t){return jr.cata(t.get(),C([]),o,C([e]))},zr=function(n,e){return jr.cata(e.get(),S.none,function(t,e){return 0===t.length?S.none():Pr(n,Mr.firstSelectedSelector(),Mr.lastSelectedSelector()).bind(function(e){return 1<t.length?S.some({bounds:C(e),cells:C(t)}):S.none()})},S.none)},Hr=function(e,t){var n=Fr(e,t);return 0<n.length&&U(n,function(e){return we(e,"rowspan")&&1<parseInt(be(e,"rowspan"),10)||we(e,"colspan")&&1<parseInt(be(e,"colspan"),10)})?S.some(n):S.none()},Ur=Fr,qr=function(e){return{element:C(e),mergable:S.none,unmergable:S.none,selection:C([e])}},Vr=$("element","clipboard","generators"),Gr={noMenu:qr,forMenu:function(e,t,n){return{element:C(n),mergable:C(zr(t,e)),unmergable:C(Hr(n,e)),selection:C(Ur(n,e))}},notCell:function(e){return qr(e)},paste:Vr,pasteRows:function(e,t,n,r,o){return{element:C(n),mergable:S.none,unmergable:S.none,selection:C(Ur(n,e)),clipboard:C(r),generators:C(o)}}},Yr=function(f,e,s,d){f.on("BeforeGetContent",function(n){!0===n.selection&&jr.cata(e.get(),y,function(e){var t;n.preventDefault(),(t=e,gn.table(t[0]).map(Bn).map(function(e){return[xn(e,Mr.attributeSelector())]})).each(function(e){var t;n.content="text"===n.format?k(e,function(e){return e.dom().innerText}).join(""):(t=f,k(e,function(e){return t.selection.serializer.serialize(e.dom(),{})}).join(""))})},y)}),f.on("BeforeSetContent",function(l){!0===l.selection&&!0===l.paste&&S.from(f.dom.getParent(f.selection.getStart(),"th,td")).each(function(e){var c=De.fromDom(e);gn.table(c).each(function(t){var e,n,r,o=I((e=l.content,(r=(n||m.document).createElement("div")).innerHTML=e,Dt(De.fromDom(r))),function(e){return"meta"!==ce(e)});if(1===o.length&&"table"===ce(o[0])){l.preventDefault();var i=De.fromDom(f.getDoc()),u=zn(i),a=Gr.paste(c,o[0],u);s.pasteCells(t,a).each(function(e){f.selection.setRng(e),f.focus(),d.clear(t)})}})})})};function Xr(r,o){var e=function(e){var t=o(e);if(t<=0||null===t){var n=Ie(e,r);return parseFloat(n)||0}return t},i=function(o,e){return M(e,function(e,t){var n=Ie(o,t),r=n===undefined?0:parseInt(n,10);return isNaN(r)?e:e+r},0)};return{set:function(e,t){if(!O(t)&&!t.match(/^[0-9]+$/))throw new Error(r+".set accepts only positive integer values. Value was "+t);var n=e.dom();Se(n)&&(n.style[r]=t+"px")},get:e,getOuter:e,aggregate:i,max:function(e,t,n){var r=i(e,n);return r<t?t-r:0}}}var Kr=Xr("height",function(e){var t=e.dom();return Oe(e)?t.getBoundingClientRect().height:t.offsetHeight}),Jr=function(e){return Kr.get(e)},$r=function(e){return Kr.getOuter(e)},Qr=Xr("width",function(e){return e.dom().offsetWidth}),Zr=function(e){return Qr.get(e)},eo=function(e){return Qr.getOuter(e)},to=mt.detect(),no=function(e,t,n){return r=Ie(e,t),o=n,i=parseFloat(r),isNaN(i)?o:i;var r,o,i},ro=function(e){return to.browser.isIE()||to.browser.isEdge()?(n=no(t=e,"padding-top",0),r=no(t,"padding-bottom",0),o=no(t,"border-top-width",0),i=no(t,"border-bottom-width",0),u=t.dom().getBoundingClientRect().height,"border-box"===Ie(t,"box-sizing")?u:u-n-r-(o+i)):no(e,"height",Jr(e));var t,n,r,o,i,u},oo=/(\d+(\.\d+)?)(\w|%)*/,io=/(\d+(\.\d+)?)%/,uo=/(\d+(\.\d+)?)px|em/,ao=function(e,t){ke(e,"height",t+"px")},co=function(e,t,n,r){var o,i,u,a,c,l,f,s,d,m=parseInt(e,10);return s=l="%",d=(f=e).length-l.length,""!==s&&(f.length<s.length||f.substr(d,d+s.length)!==s)||"table"===ce(t)?m:(o=t,i=m,u=n,a=r,c=gn.table(o).map(function(e){var t=u(e);return Math.floor(i/100*t)}).getOr(i),a(o,c),c)},lo=function(e){var t,n=We(t=e,"height").getOrThunk(function(){return ro(t)+"px"});return n?co(n,e,Jr,ao):Jr(e)},fo=function(e,t){return we(e,t)?parseInt(be(e,t),10):1},so=function(e){return We(e,"width").fold(function(){return S.from(be(e,"width"))},function(e){return S.some(e)})},mo=function(e,t){return e/t.pixelWidth()*100},go={percentageBasedSizeRegex:C(io),pixelBasedSizeRegex:C(uo),setPixelWidth:function(e,t){ke(e,"width",t+"px")},setPercentageWidth:function(e,t){ke(e,"width",t+"%")},setHeight:ao,getPixelWidth:function(t,n){return so(t).fold(function(){return Zr(t)},function(e){return function(e,t,n){if(uo.test(t)){var r=uo.exec(t);return parseInt(r[1],10)}if(io.test(t)){var o=io.exec(t),i=parseFloat(o[1]);return i/100*n.pixelWidth()}return Zr(e)}(t,e,n)})},getPercentageWidth:function(t,n){return so(t).fold(function(){var e=Zr(t);return mo(e,n)},function(e){return function(e,t,n){if(io.test(t)){var r=io.exec(t);return parseFloat(r[1])}var o=Zr(e);return mo(o,n)}(t,e,n)})},getGenericWidth:function(e){return so(e).bind(function(e){if(oo.test(e)){var t=oo.exec(e);return S.some({width:C(t[1]),unit:C(t[3])})}return S.none()})},setGenericWidth:function(e,t,n){ke(e,"width",t+n)},getHeight:function(e){return n="rowspan",lo(t=e)/fo(t,n);var t,n},getRawWidth:so},ho=function(n,r){go.getGenericWidth(n).each(function(e){var t=e.width()/2;go.setGenericWidth(n,t,e.unit()),go.setGenericWidth(r,t,e.unit())})},po=function(n,r){return{left:C(n),top:C(r),translate:function(e,t){return po(n+e,r+t)}}},vo=po,bo=function(e,t){return e!==undefined?e:t!==undefined?t:0},wo=function(e){var t,n,r=e.dom().ownerDocument,o=r.body,i=(t=De.fromDom(r),(n=t.dom())===n.window&&t instanceof m.Window?t:ge(t)?n.defaultView||n.parentWindow:null),u=r.documentElement,a=bo(i.pageYOffset,u.scrollTop),c=bo(i.pageXOffset,u.scrollLeft),l=bo(u.clientTop,o.clientTop),f=bo(u.clientLeft,o.clientLeft);return yo(e).translate(c-f,a-l)},yo=function(e){var t,n,r,o=e.dom(),i=o.ownerDocument,u=i.body,a=De.fromDom(i.documentElement);return u===o?vo(u.offsetLeft,u.offsetTop):(t=e,n=a||De.fromDom(m.document.documentElement),tn(t,b(bt,n)).isSome()?(r=o.getBoundingClientRect(),vo(r.left,r.top)):vo(0,0))},xo=$("row","y"),Co=$("col","x"),So=function(e){return wo(e).left()+eo(e)},Ro=function(e){return wo(e).left()},To=function(e,t){return Co(e,Ro(t))},Do=function(e,t){return Co(e,So(t))},Oo=function(e){return wo(e).top()},No=function(n,t,r){if(0===r.length)return[];var e=k(r.slice(1),function(e,t){return e.map(function(e){return n(t,e)})}),o=r[r.length-1].map(function(e){return t(r.length-1,e)});return e.concat([o])},Eo={delta:o,positions:b(No,function(e,t){return xo(e,Oo(t))},function(e,t){return xo(e,Oo(t)+$r(t))}),edge:Oo},Ao={delta:o,edge:Ro,positions:b(No,To,Do)},ko={height:Eo,rtl:{delta:function(e,t){return-e},edge:So,positions:b(No,Do,To)},ltr:Ao},Po={ltr:ko.ltr,rtl:ko.rtl};function Io(t){var n=function(e){return t(e).isRtl()?Po.rtl:Po.ltr};return{delta:function(e,t){return n(t).delta(e,t)},edge:function(e){return n(e).edge(e)},positions:function(e,t){return n(t).positions(e)}}}var Bo,Wo=function(e){var t=hn(e);return wn.generate(t).grid()},Mo=Object.prototype.hasOwnProperty,_o=(Bo=function(e,t){return t},function(){for(var e=new Array(arguments.length),t=0;t<e.length;t++)e[t]=arguments[t];if(0===e.length)throw new Error("Can't merge zero objects");for(var n={},r=0;r<e.length;r++){var o=e[r];for(var i in o)Mo.call(o,i)&&(n[i]=Bo(n[i],o[i]))}return n}),Lo=function(e){for(var t=[],n=function(e){t.push(e)},r=0;r<e.length;r++)e[r].each(n);return t},jo=function(e,t){for(var n=0;n<e.length;n++){var r=t(e[n],n);if(r.isSome())return r}return S.none()},Fo=function(e,t,n,r){n===r?ye(e,t):pe(e,t,n)},zo=function(o,e){var i=[],u=[],t=function(e,t){0<e.length?function(e,t){var n=rn(o,t).getOrThunk(function(){var e=De.fromTag(t,xt(o).dom());return kt(o,e),e});Wt(n);var r=k(e,function(e){e.isNew()&&i.push(e.element());var t=e.element();return Wt(t),P(e.cells(),function(e){e.isNew()&&u.push(e.element()),Fo(e.element(),"colspan",e.colspan(),1),Fo(e.element(),"rowspan",e.rowspan(),1),kt(t,e.element())}),t});Bt(n,r)}(e,t):rn(o,t).each(Mt)},n=[],r=[],a=[];return P(e,function(e){switch(e.section()){case"thead":n.push(e);break;case"tbody":r.push(e);break;case"tfoot":a.push(e)}}),t(n,"thead"),t(r,"tbody"),t(a,"tfoot"),{newRows:C(i),newCells:C(u)}},Ho=function(e){return k(e,function(e){var n=In(e.element());return P(e.cells(),function(e){var t=Bn(e.element());Fo(t,"colspan",e.colspan(),1),Fo(t,"rowspan",e.rowspan(),1),kt(n,t)}),n})},Uo=function(e,t){var n=be(e,t);return n===undefined||""===n?[]:n.split(" ")},qo=function(e){return e.dom().classList!==undefined},Vo=function(e,t){return o=t,i=Uo(n=e,r="class").concat([o]),pe(n,r,i.join(" ")),!0;var n,r,o,i},Go=function(e,t){return o=t,0<(i=I(Uo(n=e,r="class"),function(e){return e!==o})).length?pe(n,r,i.join(" ")):ye(n,r),!1;var n,r,o,i},Yo=function(e,t){qo(e)?e.dom().classList.add(t):Vo(e,t)},Xo=function(e){0===(qo(e)?e.dom().classList:Uo(e,"class")).length&&ye(e,"class")},Ko=function(e,t){return qo(e)&&e.dom().classList.contains(t)},Jo=function(e,t){for(var n=[],r=0;r<e;r++)n.push(t(r));return n},$o=function(e,t){for(var n=[],r=e;r<t;r++)n.push(r);return n},Qo=function(t,n){if(n<0||n>=t.length-1)return S.none();var e=t[n].fold(function(){var e=V(t.slice(0,n));return jo(e,function(e,t){return e.map(function(e){return{value:e,delta:t+1}})})},function(e){return S.some({value:e,delta:0})}),r=t[n+1].fold(function(){var e=t.slice(n+1);return jo(e,function(e,t){return e.map(function(e){return{value:e,delta:t+1}})})},function(e){return S.some({value:e,delta:1})});return e.bind(function(n){return r.map(function(e){var t=e.delta+n.delta;return Math.abs(e.value-n.value)/t})})},Zo=function(e,t,n){var r=e();return _(r,t).orThunk(function(){return S.from(r[0]).orThunk(n)}).map(function(e){return e.element()})},ei=function(n){var e=n.grid(),t=$o(0,e.columns()),r=$o(0,e.rows());return k(t,function(t){return Zo(function(){return H(r,function(e){return wn.getAt(n,e,t).filter(function(e){return e.column()===t}).fold(C([]),function(e){return[e]})})},function(e){return 1===e.colspan()},function(){return wn.getAt(n,0,t)})})},ti=function(n){var e=n.grid(),t=$o(0,e.rows()),r=$o(0,e.columns());return k(t,function(t){return Zo(function(){return H(r,function(e){return wn.getAt(n,t,e).filter(function(e){return e.row()===t}).fold(C([]),function(e){return[e]})})},function(e){return 1===e.rowspan()},function(){return wn.getAt(n,t,0)})})},ni=function(e){var t=e.replace(/\./g,"-");return{resolve:function(e){return t+"-"+e}}},ri={resolve:ni("ephox-snooker").resolve},oi=function(e,t,n,r,o){var i=De.fromTag("div");return Pe(i,{position:"absolute",left:t-r/2+"px",top:n+"px",height:o+"px",width:r+"px"}),ve(i,{"data-column":e,role:"presentation"}),i},ii=function(e,t,n,r,o){var i=De.fromTag("div");return Pe(i,{position:"absolute",left:t+"px",top:n-o/2+"px",height:o+"px",width:r+"px"}),ve(i,{"data-row":e,role:"presentation"}),i},ui=ri.resolve("resizer-bar"),ai=ri.resolve("resizer-rows"),ci=ri.resolve("resizer-cols"),li=function(e){var t=Xt(e.parent(),"."+ui);P(t,Mt)},fi=function(n,e,r){var o=n.origin();P(e,function(e,t){e.each(function(e){var t=r(o,e);Yo(t,ui),kt(n.parent(),t)})})},si=function(e,t,n,r,o,i){var u,a,c,l,f=wo(t),s=0<n.length?o.positions(n,t):[];u=e,a=s,c=f,l=eo(t),fi(u,a,function(e,t){var n=ii(t.row(),c.left()-e.left(),t.y()-e.top(),l,7);return Yo(n,ai),n});var d,m,g,h,p=0<r.length?i.positions(r,t):[];d=e,m=p,g=f,h=$r(t),fi(d,m,function(e,t){var n=oi(t.col(),t.x()-e.left(),g.top()-e.top(),7,h);return Yo(n,ci),n})},di=function(e,t){var n=Xt(e.parent(),"."+ui);P(n,t)},mi={refresh:function(e,t,n,r){li(e);var o=hn(t),i=wn.generate(o),u=ti(i),a=ei(i);si(e,t,u,a,n,r)},hide:function(e){di(e,function(e){ke(e,"display","none")})},show:function(e){di(e,function(e){ke(e,"display","block")})},destroy:li,isRowBar:function(e){return Ko(e,ai)},isColBar:function(e){return Ko(e,ci)}},gi=function(e,t){return qt.rowcells(t,e.section())},hi=function(e,t){return e.cells()[t]},pi={addCell:function(e,t,n){var r=e.cells(),o=r.slice(0,t),i=r.slice(t),u=o.concat([n]).concat(i);return gi(e,u)},setCells:gi,mutateCell:function(e,t,n){e.cells()[t]=n},getCell:hi,getCellElement:function(e,t){return hi(e,t).element()},mapCells:function(e,t){var n=e.cells(),r=k(n,t);return qt.rowcells(r,e.section())},cellLength:function(e){return e.cells().length}},vi=function(e,t){if(0===e.length)return 0;var n=e[0];return L(e,function(e){return!t(n.element(),e.element())}).fold(function(){return e.length},function(e){return e})},bi=function(e,t,n,r){var o,i,u,a,c=(o=e,i=t,o[i]).cells().slice(n),l=vi(c,r),f=(u=e,a=n,k(u,function(e){return pi.getCell(e,a)})).slice(t),s=vi(f,r);return{colspan:C(l),rowspan:C(s)}},wi=function(o,i){var u=k(o,function(e,t){return k(e.cells(),function(e,t){return!1})});return k(o,function(e,r){var t=H(e.cells(),function(e,t){if(!1===u[r][t]){var n=bi(o,r,t,i);return function(e,t,n,r){for(var o=e;o<e+n;o++)for(var i=t;i<t+r;i++)u[o][i]=!0}(r,t,n.rowspan(),n.colspan()),[qt.detailnew(e.element(),n.rowspan(),n.colspan(),e.isNew())]}return[]});return qt.rowdetails(t,e.section())})},yi=function(e,t,n){for(var r=[],o=0;o<e.grid().rows();o++){for(var i=[],u=0;u<e.grid().columns();u++){var a=wn.getAt(e,o,u).map(function(e){return qt.elementnew(e.element(),n)}).getOrThunk(function(){return qt.elementnew(t.gap(),!0)});i.push(a)}var c=qt.rowcells(i,e.all()[o].section());r.push(c)}return r},xi=function(e,r){return k(e,function(e){var t,n=(t=e.details(),jo(t,function(e){return Ct(e.element()).map(function(e){var t=Ct(e).isNone();return qt.elementnew(e,t)})}).getOrThunk(function(){return qt.elementnew(r.row(),!0)}));return qt.rowdatanew(n.element(),e.details(),e.section(),n.isNew())})},Ci=function(e,t){var n=wi(e,bt);return xi(n,t)},Si=function(e,t){var n=z(k(e.all(),function(e){return e.cells()}));return _(n,function(e){return bt(t,e.element())})},Ri=function(a,c,l,f,s){return function(n,r,e,o,i){var t=hn(r),u=wn.generate(t);return c(u,e).map(function(e){var t=yi(u,o,!1),n=a(t,e,bt,s(o)),r=Ci(n.grid(),o);return{grid:C(r),cursor:n.cursor}}).fold(function(){return S.none()},function(e){var t=zo(r,e.grid());return l(r,e.grid(),i),f(r),mi.refresh(n,r,ko.height,i),S.some({cursor:e.cursor,newRows:t.newRows,newCells:t.newCells})})}},Ti=Ci,Di=function(t,e){return gn.cell(e.element()).bind(function(e){return Si(t,e)})},Oi=function(t,e){var n=k(e.selection(),function(e){return gn.cell(e).bind(function(e){return Si(t,e)})}),r=Lo(n);return 0<r.length?S.some(r):S.none()},Ni=function(t,n){return gn.cell(n.element()).bind(function(e){return Si(t,e).map(function(e){return _o(e,{generators:n.generators,clipboard:n.clipboard})})})},Ei=function(t,e){var n=k(e.selection(),function(e){return gn.cell(e).bind(function(e){return Si(t,e)})}),r=Lo(n);return 0<r.length?S.some(_o({cells:r},{generators:e.generators,clipboard:e.clipboard})):S.none()},Ai=function(e,t){return t.mergable()},ki=function(e,t){return t.unmergable()},Pi=function(n){return{is:function(e){return n===e},isValue:l,isError:a,getOr:C(n),getOrThunk:C(n),getOrDie:C(n),or:function(e){return Pi(n)},orThunk:function(e){return Pi(n)},fold:function(e,t){return t(n)},map:function(e){return Pi(e(n))},mapError:function(e){return Pi(n)},each:function(e){e(n)},bind:function(e){return e(n)},exists:function(e){return e(n)},forall:function(e){return e(n)},toOption:function(){return S.some(n)}}},Ii=function(n){return{is:a,isValue:a,isError:l,getOr:o,getOrThunk:function(e){return e()},getOrDie:function(){return e=String(n),function(){throw new Error(e)}();var e},or:function(e){return e},orThunk:function(e){return e()},fold:function(e,t){return e(n)},map:function(e){return Ii(n)},mapError:function(e){return Ii(e(n))},each:y,bind:function(e){return Ii(n)},exists:a,forall:l,toOption:S.none}},Bi={value:Pi,error:Ii},Wi=function(e,t){return k(e,function(){return qt.elementnew(t.cell(),!0)})},Mi=function(t,e,n){return t.concat(Jo(e,function(e){return pi.setCells(t[t.length-1],Wi(t[t.length-1].cells(),n))}))},_i=function(e,t,n){return k(e,function(e){return pi.setCells(e,e.cells().concat(Wi($o(0,t),n)))})},Li=function(e,t,n){if(e.row()>=t.length||e.column()>pi.cellLength(t[0]))return Bi.error("invalid start address out of table bounds, row: "+e.row()+", column: "+e.column());var r=t.slice(e.row()),o=r[0].cells().slice(e.column()),i=pi.cellLength(n[0]),u=n.length;return Bi.value({rowDelta:C(r.length-u),colDelta:C(o.length-i)})},ji=function(e,t){var n=pi.cellLength(e[0]),r=pi.cellLength(t[0]);return{rowDelta:C(0),colDelta:C(n-r)}},Fi=function(e,t,n){var r=t.colDelta()<0?_i:o;return(t.rowDelta()<0?Mi:o)(r(e,Math.abs(t.colDelta()),n),Math.abs(t.rowDelta()),n)},zi=function(e,t,n,r){if(0===e.length)return e;for(var o=t.startRow();o<=t.finishRow();o++)for(var i=t.startCol();i<=t.finishCol();i++)pi.mutateCell(e[o],i,qt.elementnew(r(),!1));return e},Hi=function(e,t,n,r){for(var o=!0,i=0;i<e.length;i++)for(var u=0;u<pi.cellLength(e[0]);u++){var a=n(pi.getCellElement(e[i],u),t);!0===a&&!1===o?pi.mutateCell(e[i],u,qt.elementnew(r(),!0)):!0===a&&(o=!1)}return e},Ui=function(i,n,u,a){if(0<n&&n<i.length){var e=i[n-1].cells(),t=(r=u,M(e,function(e,t){return A(e,function(e){return r(e.element(),t.element())})?e:e.concat([t])},[]));P(t,function(r){for(var o=S.none(),e=function(n){for(var e=function(t){var e=i[n].cells()[t];u(e.element(),r.element())&&(o.isNone()&&(o=S.some(a())),o.each(function(e){pi.mutateCell(i[n],t,qt.elementnew(e,!0))}))},t=0;t<pi.cellLength(i[0]);t++)e(t)},t=n;t<i.length;t++)e(t)})}var r;return i},qi=function(n,r,o,i,u){return Li(n,r,o).map(function(e){var t=Fi(r,e,i);return function(e,t,n,r,o){for(var i,u,a,c,l,f=e.row(),s=e.column(),d=f+n.length,m=s+pi.cellLength(n[0]),g=f;g<d;g++)for(var h=s;h<m;h++){i=t,u=g,a=h,c=void 0,c=b(o,pi.getCell(i[u],a).element()),l=i[u],1<i.length&&1<pi.cellLength(l)&&(0<a&&c(pi.getCellElement(l,a-1))||a<l.length-1&&c(pi.getCellElement(l,a+1))||0<u&&c(pi.getCellElement(i[u-1],a))||u<i.length-1&&c(pi.getCellElement(i[u+1],a)))&&Hi(t,pi.getCellElement(t[g],h),o,r.cell);var p=pi.getCellElement(n[g-f],h-s),v=r.replace(p);pi.mutateCell(t[g],h,qt.elementnew(v,!0))}return t}(n,t,o,i,u)})},Vi=function(e,t,n,r,o){Ui(t,e,o,r.cell);var i=ji(n,t),u=Fi(n,i,r),a=ji(t,u),c=Fi(t,a,r);return c.slice(0,e).concat(u).concat(c.slice(e,c.length))},Gi=function(n,r,e,o,i){var t=n.slice(0,r),u=n.slice(r),a=pi.mapCells(n[e],function(e,t){return 0<r&&r<n.length&&o(pi.getCellElement(n[r-1],t),pi.getCellElement(n[r],t))?pi.getCell(n[r],t):qt.elementnew(i(e.element(),o),!0)});return t.concat([a]).concat(u)},Yi=function(e,n,r,o,i){return k(e,function(e){var t=0<n&&n<pi.cellLength(e)&&o(pi.getCellElement(e,n-1),pi.getCellElement(e,n))?pi.getCell(e,n):qt.elementnew(i(pi.getCellElement(e,r),o),!0);return pi.addCell(e,n,t)})},Xi=function(e,r,o,i,u){var a=o+1;return k(e,function(e,t){var n=t===r?qt.elementnew(u(pi.getCellElement(e,o),i),!0):pi.getCell(e,o);return pi.addCell(e,a,n)})},Ki=function(e,t,n,r,o){var i=t+1,u=e.slice(0,i),a=e.slice(i),c=pi.mapCells(e[t],function(e,t){return t===n?qt.elementnew(o(e.element(),r),!0):e});return u.concat([c]).concat(a)},Ji=function(e,t,n){return e.slice(0,t).concat(e.slice(n+1))},$i=function(e,n,r){var t=k(e,function(e){var t=e.cells().slice(0,n).concat(e.cells().slice(r+1));return qt.rowcells(t,e.section())});return I(t,function(e){return 0<e.cells().length})},Qi=function(e){return e.dom().textContent},Zi=function(e,n,r,o){return k(e,function(e){return pi.mapCells(e,function(e){return t=e,A(n,function(e){return r(t.element(),e.element())})?qt.elementnew(o(e.element(),r),!0):e;var t})})},eu=function(e,t,n,r){return pi.getCellElement(e[t],n)!==undefined&&0<t&&r(pi.getCellElement(e[t-1],n),pi.getCellElement(e[t],n))},tu=function(e,t,n){return 0<t&&n(pi.getCellElement(e,t-1),pi.getCellElement(e,t))},nu=function(n,r,o,e){var t=H(n,function(e,t){return eu(n,t,r,o)||tu(e,r,o)?[]:[pi.getCell(e,r)]});return Zi(n,t,o,e)},ru=function(n,r,o,e){var i=n[r],t=H(i.cells(),function(e,t){return eu(n,r,t,o)||tu(i,t,o)?[]:[e]});return Zi(n,t,o,e)},ou=function(e,r,o,i){var t=B(e,function(e){return ce(pi.getCell(e,r).element())});return H(t,function(e){return"th"===ce(pi.getCell(e[0],r).element())?e:(t=k(e,function(e){var t=pi.getCell(e,r);return{row:e,text:Qi(t.element())}}),n=G(t,function(e,t){var n=o(e.text,t.text);return i?n:-1*n}),k(n,function(e){return e.row}));var t,n})},iu=function(e,t,o,i){var n=e[t].cells(),r=k(n,function(e){return Qi(e.element())}),u=k(e,function(e){return{zippedCells:k(e.cells(),function(e,t){return{cell:e,reference:n[t],referenceText:r[t]}}),section:e.section()}});return k(u,function(e){var t=B(e.zippedCells,function(e){return ce(e.reference.element())}),n=H(t,function(e){return"th"===ce(e[0].reference.element())?e:G(e,function(e,t){var n=o(e.referenceText,t.referenceText);return i?n:-1*n})}),r=k(n,function(e){return e.cell});return qt.rowcells(r,e.section)})},uu=function(e){return{fold:e}},au=function(){return uu(function(e,t,n,r,o){return e()})},cu=function(i){return uu(function(e,t,n,r,o){return t(i)})},lu=function(i,u){return uu(function(e,t,n,r,o){return n(i,u)})},fu=function(i,u,a){return uu(function(e,t,n,r,o){return r(i,u,a)})},su=function(i,u){return uu(function(e,t,n,r,o){return o(i,u)})},du=function(e,t,i,u){var n,r,a=e.slice(0),o=(r=t,0===(n=e).length?au():1===n.length?cu(0):0===r?lu(0,1):r===n.length-1?su(r-1,r):0<r&&r<n.length-1?fu(r-1,r,r+1):au()),c=function(e){return k(e,C(0))},l=C(c(a)),f=function(e,t){if(0<=i){var n=Math.max(u.minCellWidth(),a[t]-i);return c(a.slice(0,e)).concat([i,n-a[t]]).concat(c(a.slice(t+1)))}var r=Math.max(u.minCellWidth(),a[e]+i),o=a[e]-r;return c(a.slice(0,e)).concat([r-a[e],o]).concat(c(a.slice(t+1)))},s=f;return o.fold(l,function(e){return u.singleColumnWidth(a[e],i)},s,function(e,t,n){return f(t,n)},function(e,t){if(0<=i)return c(a.slice(0,t)).concat([i]);var n=Math.max(u.minCellWidth(),a[t]+i);return c(a.slice(0,t)).concat([n-a[t]])})},mu=function(e,t){return we(e,t)&&1<parseInt(be(e,t),10)},gu={hasColspan:function(e){return mu(e,"colspan")},hasRowspan:function(e){return mu(e,"rowspan")},minWidth:C(10),minHeight:C(10),getInt:function(e,t){return parseInt(Ie(e,t),10)}},hu=function(e,t,n){return We(e,t).fold(function(){return n(e)+"px"},function(e){return e})},pu=function(e){return hu(e,"width",go.getPixelWidth)},vu=function(e){return hu(e,"height",go.getHeight)},bu=function(e,t,n,r,o){var i=ei(e),u=k(i,function(e){return e.map(t.edge)});return k(i,function(e,t){return e.filter(g(gu.hasColspan)).fold(function(){var e=Qo(u,t);return r(e)},function(e){return n(e,o)})})},wu=function(e){return e.map(function(e){return e+"px"}).getOr("")},yu=function(e,t,n,r){var o=ti(e),i=k(o,function(e){return e.map(t.edge)});return k(o,function(e,t){return e.filter(g(gu.hasRowspan)).fold(function(){var e=Qo(i,t);return r(e)},function(e){return n(e)})})},xu={getRawWidths:function(e,t){return bu(e,t,pu,wu)},getPixelWidths:function(e,t,n){return bu(e,t,go.getPixelWidth,function(e){return e.getOrThunk(n.minCellWidth)},n)},getPercentageWidths:function(e,t,n){return bu(e,t,go.getPercentageWidth,function(e){return e.fold(function(){return n.minCellWidth()},function(e){return e/n.pixelWidth()*100})},n)},getPixelHeights:function(e,t){return yu(e,t,go.getHeight,function(e){return e.getOrThunk(gu.minHeight)})},getRawHeights:function(e,t){return yu(e,t,vu,wu)}},Cu=function(e,t,n){for(var r=0,o=e;o<t;o++)r+=n[o]!==undefined?n[o]:0;return r},Su=function(e,n){var t=wn.justCells(e);return k(t,function(e){var t=Cu(e.column(),e.column()+e.colspan(),n);return{element:e.element,width:C(t),colspan:e.colspan}})},Ru=function(e,n){var t=wn.justCells(e);return k(t,function(e){var t=Cu(e.row(),e.row()+e.rowspan(),n);return{element:e.element,height:C(t),rowspan:e.rowspan}})},Tu=function(e,n){return k(e.all(),function(e,t){return{element:e.element,height:C(n[t])}})},Du=function(e){var t=parseInt(e,10),n=o;return{width:C(t),pixelWidth:C(t),getWidths:xu.getPixelWidths,getCellDelta:n,singleColumnWidth:function(e,t){return[Math.max(gu.minWidth(),e+t)-e]},minCellWidth:gu.minWidth,setElementWidth:go.setPixelWidth,setTableWidth:function(e,t,n){var r=W(t,function(e,t){return e+t},0);go.setPixelWidth(e,r)}}},Ou=function(e,t){if(go.percentageBasedSizeRegex().test(t)){var n=go.percentageBasedSizeRegex().exec(t);return o=n[1],i=e,u=parseFloat(o),a=Zr(i),{width:C(u),pixelWidth:C(a),getWidths:xu.getPercentageWidths,getCellDelta:function(e){return e/a*100},singleColumnWidth:function(e,t){return[100-e]},minCellWidth:function(){return gu.minWidth()/a*100},setElementWidth:go.setPercentageWidth,setTableWidth:function(e,t,n){var r=u+n;go.setPercentageWidth(e,r)}}}if(go.pixelBasedSizeRegex().test(t)){var r=go.pixelBasedSizeRegex().exec(t);return Du(r[1])}var o,i,u,a,c=Zr(e);return Du(c)},Nu=function(t){return go.getRawWidth(t).fold(function(){var e=Zr(t);return Du(e)},function(e){return Ou(t,e)})},Eu=function(e){return wn.generate(e)},Au=function(e){var t=hn(e);return Eu(t)},ku=function(e,t,n,r){var o=Nu(e),i=o.getCellDelta(t),u=Au(e),a=o.getWidths(u,r,o),c=du(a,n,i,o),l=k(c,function(e,t){return e+a[t]}),f=Su(u,l);P(f,function(e){o.setElementWidth(e.element(),e.width())}),n===u.grid().columns()-1&&o.setTableWidth(e,l,i)},Pu=function(e,n,r,t){var o=Au(e),i=xu.getPixelHeights(o,t),u=k(i,function(e,t){return r===t?Math.max(n+e,gu.minHeight()):e}),a=Ru(o,u),c=Tu(o,u);P(c,function(e){go.setHeight(e.element(),e.height())}),P(a,function(e){go.setHeight(e.element(),e.height())});var l=W(u,function(e,t){return e+t},0);go.setHeight(e,l)},Iu=function(e,t,n){var r=Nu(e),o=Eu(t),i=r.getWidths(o,n,r),u=Su(o,i);P(u,function(e){r.setElementWidth(e.element(),e.width())});var a=W(i,function(e,t){return t+e},0);0<u.length&&r.setTableWidth(e,a)},Bu=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return Bu(n())}}},Wu=function(r,o,i){if(0===o.length)throw new Error("You must specify at least one required field.");return te("required",o),ne(o),function(t){var n=Y(t);U(o,function(e){return E(n,e)})||Z(o,n),r(o,n);var e=I(o,function(e){return!i.validate(t[e],e)});return 0<e.length&&function(e,t){throw new Error("All values need to be of type: "+t+". Keys ("+Q(e).join(", ")+") were not.")}(e,i.label),t}},Mu=function(t,e){var n=I(e,function(e){return!E(t,e)});0<n.length&&ee(n)},_u=function(e){return Wu(Mu,e,{validate:D,label:"function"})},Lu=function(e){var t=we(e,"colspan")?parseInt(be(e,"colspan"),10):1,n=we(e,"rowspan")?parseInt(be(e,"rowspan"),10):1;return{element:C(e),colspan:C(t),rowspan:C(n)}},ju=_u(["cell","row","replace","gap"]),Fu=function(r,e){ju(r);var n=Bu(S.none()),o=e!==undefined?e:Lu,i=function(e){var t,n=o(e);return t=n,r.cell(t)},u=function(e){var t=i(e);return n.get().isNone()&&n.set(S.some(t)),a=S.some({item:e,replacement:t}),t},a=S.none();return{getOrInit:function(t,n){return a.fold(function(){return u(t)},function(e){return n(t,e.item)?e.replacement:u(t)})},cursor:n.get}},zu=function(o,a){return function(n){var r=Bu(S.none());ju(n);var i=[],u=function(e){var t=n.replace(e,a,{scope:o});return i.push({item:e,sub:t}),r.get().isNone()&&r.set(S.some(t)),t};return{replaceOrInit:function(t,n){return(r=t,o=n,_(i,function(e){return o(e.item,r)})).fold(function(){return u(t)},function(e){return n(t,e.item)?e.sub:u(t)});var r,o},cursor:r.get}}},Hu=function(n){ju(n);var e=Bu(S.none());return{combine:function(t){return e.get().isNone()&&e.set(S.some(t)),function(){var e=n.cell({element:C(t),colspan:C(1),rowspan:C(1)});return Me(e,"width"),Me(t,"width"),e}},cursor:e.get}},Uu=["body","p","div","article","aside","figcaption","figure","footer","header","nav","section","ol","ul","table","thead","tfoot","tbody","caption","tr","td","th","h1","h2","h3","h4","h5","h6","blockquote","pre","address"],qu=function(e,t){var n=e.property().name(t);return E(Uu,n)},Vu=function(e,t){return E(["br","img","hr","input"],e.property().name(t))},Gu=qu,Yu=function(e,t){var n=e.property().name(t);return E(["ol","ul"],n)},Xu=Vu,Ku=Un(),Ju=function(e){return Gu(Ku,e)},$u=function(e){return Yu(Ku,e)},Qu=function(e){return Xu(Ku,e)},Zu=function(e){var t,i=function(e){return"br"===ce(e)},n=function(o){return An(o).bind(function(n){var r=Tt(n).map(function(e){return!!Ju(e)||(Qu(e)?"img"!==ce(e):void 0)}).getOr(!1);return Ct(n).map(function(e){return!0===r||"li"===ce(t=e)||tn(t,$u).isSome()||i(n)||Ju(e)&&!bt(o,e)?[]:[De.fromTag("br")];var t})}).getOr([])},r=0===(t=H(e,function(e){var t=Dt(e);return U(t,function(e){return i(e)||me(e)&&0===Sn(e).trim().length})?[]:t.concat(n(e))})).length?[De.fromTag("br")]:t;Wt(e[0]),Bt(e[0],r)},ea=function(e){0===gn.cells(e).length&&Mt(e)},ta=$("grid","cursor"),na=function(e,t,n){return ra(e,t,n).orThunk(function(){return ra(e,0,0)})},ra=function(e,t,n){return S.from(e[t]).bind(function(e){return S.from(e.cells()[n]).bind(function(e){return S.from(e.element())})})},oa=function(e,t,n){return ta(e,ra(e,t,n))},ia=function(e){return M(e,function(e,t){return A(e,function(e){return e.row()===t.row()})?e:e.concat([t])},[]).sort(function(e,t){return e.row()-t.row()})},ua=function(e){return M(e,function(e,t){return A(e,function(e){return e.column()===t.column()})?e:e.concat([t])},[]).sort(function(e,t){return e.column()-t.column()})},aa=function(e,t,n){var r=pn(e,n),o=wn.generate(r);return yi(o,t,!0)},ca=function(a){return function(e,t,n,r,o,i,u){return Ri(function(e,t,n,r){return a(e,t,i,u)},Di,y,y,Fu)(e,t,n,r,o)}},la=Iu,fa={insertRowBefore:Ri(function(e,t,n,r){var o=t.row(),i=t.row(),u=Gi(e,i,o,n,r.getOrInit);return oa(u,i,t.column())},Di,y,y,Fu),insertRowsBefore:Ri(function(e,t,n,r){var o=t[0].row(),i=t[0].row(),u=ia(t),a=M(u,function(e,t){return Gi(e,i,o,n,r.getOrInit)},e);return oa(a,i,t[0].column())},Oi,y,y,Fu),insertRowAfter:Ri(function(e,t,n,r){var o=t.row(),i=t.row()+t.rowspan(),u=Gi(e,i,o,n,r.getOrInit);return oa(u,i,t.column())},Di,y,y,Fu),insertRowsAfter:Ri(function(e,t,n,r){var o=ia(t),i=o[o.length-1].row(),u=o[o.length-1].row()+o[o.length-1].rowspan(),a=M(o,function(e,t){return Gi(e,u,i,n,r.getOrInit)},e);return oa(a,u,t[0].column())},Oi,y,y,Fu),insertColumnBefore:Ri(function(e,t,n,r){var o=t.column(),i=t.column(),u=Yi(e,i,o,n,r.getOrInit);return oa(u,t.row(),i)},Di,la,y,Fu),insertColumnsBefore:Ri(function(e,t,n,r){var o=ua(t),i=o[0].column(),u=o[0].column(),a=M(o,function(e,t){return Yi(e,u,i,n,r.getOrInit)},e);return oa(a,t[0].row(),u)},Oi,la,y,Fu),insertColumnAfter:Ri(function(e,t,n,r){var o=t.column(),i=t.column()+t.colspan(),u=Yi(e,i,o,n,r.getOrInit);return oa(u,t.row(),i)},Di,la,y,Fu),insertColumnsAfter:Ri(function(e,t,n,r){var o=t[t.length-1].column(),i=t[t.length-1].column()+t[t.length-1].colspan(),u=ua(t),a=M(u,function(e,t){return Yi(e,i,o,n,r.getOrInit)},e);return oa(a,t[0].row(),i)},Oi,la,y,Fu),splitCellIntoColumns:Ri(function(e,t,n,r){var o=Xi(e,t.row(),t.column(),n,r.getOrInit);return oa(o,t.row(),t.column())},Di,la,y,Fu),splitCellIntoRows:Ri(function(e,t,n,r){var o=Ki(e,t.row(),t.column(),n,r.getOrInit);return oa(o,t.row(),t.column())},Di,y,y,Fu),eraseColumns:Ri(function(e,t,n,r){var o=ua(t),i=$i(e,o[0].column(),o[o.length-1].column()),u=na(i,t[0].row(),t[0].column());return ta(i,u)},Oi,la,ea,Fu),eraseRows:Ri(function(e,t,n,r){var o=ia(t),i=Ji(e,o[0].row(),o[o.length-1].row()),u=na(i,t[0].row(),t[0].column());return ta(i,u)},Oi,y,ea,Fu),makeColumnHeader:Ri(function(e,t,n,r){var o=nu(e,t.column(),n,r.replaceOrInit);return oa(o,t.row(),t.column())},Di,y,y,zu("row","th")),unmakeColumnHeader:Ri(function(e,t,n,r){var o=nu(e,t.column(),n,r.replaceOrInit);return oa(o,t.row(),t.column())},Di,y,y,zu(null,"td")),makeRowHeader:Ri(function(e,t,n,r){var o=ru(e,t.row(),n,r.replaceOrInit);return oa(o,t.row(),t.column())},Di,y,y,zu("col","th")),unmakeRowHeader:Ri(function(e,t,n,r){var o=ru(e,t.row(),n,r.replaceOrInit);return oa(o,t.row(),t.column())},Di,y,y,zu(null,"td")),mergeCells:Ri(function(e,t,n,r){var o=t.cells();Zu(o);var i=zi(e,t.bounds(),n,C(o[0]));return ta(i,S.from(o[0]))},Ai,y,y,Hu),unmergeCells:Ri(function(e,t,n,r){var o=W(t,function(e,t){return Hi(e,t,n,r.combine(t))},e);return ta(o,S.from(t[0]))},ki,la,y,Hu),pasteCells:Ri(function(e,n,t,r){var o,i,u,a,c=(o=n.clipboard(),i=n.generators(),u=hn(o),a=wn.generate(u),yi(a,i,!0)),l=qt.address(n.row(),n.column());return qi(l,e,c,n.generators(),t).fold(function(){return ta(e,S.some(n.element()))},function(e){var t=na(e,n.row(),n.column());return ta(e,t)})},Ni,la,y,Fu),pasteRowsBefore:Ri(function(e,t,n,r){var o=e[t.cells[0].row()],i=t.cells[0].row(),u=aa(t.clipboard(),t.generators(),o),a=Vi(i,e,u,t.generators(),n),c=na(a,t.cells[0].row(),t.cells[0].column());return ta(a,c)},Ei,y,y,Fu),pasteRowsAfter:Ri(function(e,t,n,r){var o=e[t.cells[0].row()],i=t.cells[t.cells.length-1].row()+t.cells[t.cells.length-1].rowspan(),u=aa(t.clipboard(),t.generators(),o),a=Vi(i,e,u,t.generators(),n),c=na(a,t.cells[0].row(),t.cells[0].column());return ta(a,c)},Ei,y,y,Fu),sortRows:ca(function(e,t,n,r){var o=ou(e,t.column(),n,r);return oa(o,t.row(),t.column())}),sortColumns:ca(function(e,t,n,r){var o=iu(e,t.row(),n,r);return oa(o,t.row(),t.column())})},sa=function(e){return De.fromDom(e.getBody())},da=function(e){return e.getBoundingClientRect().width},ma=function(e){return e.getBoundingClientRect().height},ga=function(t){return function(e){return bt(e,sa(t))}},ha=function(e){return/^[0-9]+$/.test(e)&&(e+="px"),e},pa=function(e){var t=Xt(e,"td[data-mce-style],th[data-mce-style]");ye(e,"data-mce-style"),P(t,function(e){ye(e,"data-mce-style")})},va={isRtl:C(!1)},ba={isRtl:C(!0)},wa={directionAt:function(e){return"rtl"==("rtl"===Ie(e,"direction")?"rtl":"ltr")?ba:va}},ya=["tableprops","tabledelete","|","tableinsertrowbefore","tableinsertrowafter","tabledeleterow","|","tableinsertcolbefore","tableinsertcolafter","tabledeletecol"],xa={"border-collapse":"collapse",width:"100%"},Ca={border:"1"},Sa=function(e){return e.getParam("table_cell_advtab",!0,"boolean")},Ra=function(e){return e.getParam("table_row_advtab",!0,"boolean")},Ta=function(e){return e.getParam("table_advtab",!0,"boolean")},Da=function(e){return e.getParam("table_style_by_css",!1,"boolean")},Oa=function(e){return e.getParam("table_cell_class_list",[],"array")},Na=function(e){return e.getParam("table_row_class_list",[],"array")},Ea=function(e){return e.getParam("table_class_list",[],"array")},Aa=function(e){return!1===e.getParam("table_responsive_width")},ka=function(e,t){return e.fire("newrow",{node:t})},Pa=function(e,t){return e.fire("newcell",{node:t})},Ia=function(e,t,n,r){e.fire("ObjectResizeStart",{target:t,width:n,height:r})},Ba=function(e,t,n,r){e.fire("ObjectResized",{target:t,width:n,height:r})},Wa=function(f,e){var t,n=function(e){return"table"===ce(sa(e))},s=(t=f.getParam("table_clone_elements"),w(t)?S.some(t.split(/[ ,]/)):Array.isArray(t)?S.some(t):S.none()),r=function(u,a,c,l){return function(e,t){pa(e);var n=l(),r=De.fromDom(f.getDoc()),o=Io(wa.directionAt),i=Fn(c,r,s);return a(e)?u(n,e,t,i,o).bind(function(e){return P(e.newRows(),function(e){ka(f,e.dom())}),P(e.newCells(),function(e){Pa(f,e.dom())}),e.cursor().map(function(e){var t=f.dom.createRng();return t.setStart(e.dom(),0),t.setEnd(e.dom(),0),t})}):S.none()}};return{deleteRow:r(fa.eraseRows,function(e){var t=Wo(e);return!1===n(f)||1<t.rows()},y,e),deleteColumn:r(fa.eraseColumns,function(e){var t=Wo(e);return!1===n(f)||1<t.columns()},y,e),insertRowsBefore:r(fa.insertRowsBefore,l,y,e),insertRowsAfter:r(fa.insertRowsAfter,l,y,e),insertColumnsBefore:r(fa.insertColumnsBefore,l,ho,e),insertColumnsAfter:r(fa.insertColumnsAfter,l,ho,e),mergeCells:r(fa.mergeCells,l,y,e),unmergeCells:r(fa.unmergeCells,l,y,e),pasteRowsBefore:r(fa.pasteRowsBefore,l,y,e),pasteRowsAfter:r(fa.pasteRowsAfter,l,y,e),pasteCells:r(fa.pasteCells,l,y,e)}},Ma=function(e,t,r){var n=hn(e),o=wn.generate(n);return Oi(o,t).map(function(e){var t=yi(o,r,!1).slice(e[0].row(),e[e.length-1].row()+e[e.length-1].rowspan()),n=Ti(t,r);return Ho(n)})},_a=tinymce.util.Tools.resolve("tinymce.util.Tools"),La=function(e,t,n){n&&e.formatter.apply("align"+n,{},t)},ja=function(e,t,n){n&&e.formatter.apply("valign"+n,{},t)},Fa=function(t,n){_a.each("left center right".split(" "),function(e){t.formatter.remove("align"+e,{},n)})},za=function(t,n){_a.each("top middle bottom".split(" "),function(e){t.formatter.remove("valign"+e,{},n)})},Ha=function(o,e,i){var t;return t=function(e,t){for(var n=0;n<t.length;n++){var r=o.getStyle(t[n],i);if(void 0===e&&(e=r),e!==r)return""}return e}(t,o.select("td,th",e))},Ua=function(e,t){var n=e.dom,r=t.control.rootControl,o=r.toJSON(),i=n.parseStyle(o.style);i["border-style"]=o.borderStyle,i["border-color"]=o.borderColor,i["background-color"]=o.backgroundColor,i.width=o.width?ha(o.width):"",i.height=o.height?ha(o.height):"",r.find("#style").value(n.serializeStyle(n.parseStyle(n.serializeStyle(i))))},qa=function(e,t){var n=e.dom,r=t.control.rootControl,o=r.toJSON(),i=n.parseStyle(o.style);r.find("#borderStyle").value(i["border-style"]||""),r.find("#borderColor").value(i["border-color"]||""),r.find("#backgroundColor").value(i["background-color"]||""),r.find("#width").value(i.width||""),r.find("#height").value(i.height||"")},Va={createStyleForm:function(n){var e=function(){var e=n.getParam("color_picker_callback");if(e)return function(t){return e.call(n,function(e){t.control.value(e).fire("change")},t.control.value())}};return{title:"Advanced",type:"form",defaults:{onchange:b(Ua,n)},items:[{label:"Style",name:"style",type:"textbox",onchange:b(qa,n)},{type:"form",padding:0,formItemDefaults:{layout:"grid",alignH:["start","right"]},defaults:{size:7},items:[{label:"Border style",type:"listbox",name:"borderStyle",width:90,onselect:b(Ua,n),values:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},{text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]},{label:"Border color",type:"colorbox",name:"borderColor",onaction:e()},{label:"Background color",type:"colorbox",name:"backgroundColor",onaction:e()}]}]}},buildListItems:function(e,r,t){var o=function(e,n){return n=n||[],_a.each(e,function(e){var t={text:e.text||e.title};e.menu?t.menu=o(e.menu):(t.value=e.value,r&&r(t)),n.push(t)}),n};return o(e,t||[])},updateStyleField:Ua,extractAdvancedStyles:function(e,t){var n=e.parseStyle(e.getAttrib(t,"style")),r={};return n["border-style"]&&(r.borderStyle=n["border-style"]),n["border-color"]&&(r.borderColor=n["border-color"]),n["background-color"]&&(r.backgroundColor=n["background-color"]),r.style=e.serializeStyle(n),r},updateAdvancedFields:qa,syncAdvancedStyleFields:function(e,t){t.control.rootControl.find("#style")[0].getEl().isEqualNode(m.document.activeElement)?qa(e,t):Ua(e,t)}},Ga=function(r,o,e){var i,u=r.dom;function a(e,t,n){(1===o.length||n)&&u.setAttrib(e,t,n)}function c(e,t,n){(1===o.length||n)&&u.setStyle(e,t,n)}Sa(r)&&Va.syncAdvancedStyleFields(r,e),i=e.control.rootControl.toJSON(),r.undoManager.transact(function(){_a.each(o,function(e){var t,n;a(e,"scope",i.scope),1===o.length?a(e,"style",i.style):(t=e,n=i.style,delete t.dataset.mceStyle,t.style.cssText+=";"+n),a(e,"class",i["class"]),c(e,"width",ha(i.width)),c(e,"height",ha(i.height)),i.type&&e.nodeName.toLowerCase()!==i.type&&(e=u.rename(e,i.type)),1===o.length&&(Fa(r,e),za(r,e)),i.align&&La(r,e,i.align),i.valign&&ja(r,e,i.valign)}),r.focus()})},Ya=function(t){var e,n,r,o=[];if(o=t.dom.select("td[data-mce-selected],th[data-mce-selected]"),e=t.dom.getParent(t.selection.getStart(),"td,th"),!o.length&&e&&o.push(e),e=e||o[0]){var i,u,a,c;1<o.length?n={width:"",height:"",scope:"","class":"",align:"",valign:"",style:"",type:e.nodeName.toLowerCase()}:(u=e,a=(i=t).dom,c={width:a.getStyle(u,"width")||a.getAttrib(u,"width"),height:a.getStyle(u,"height")||a.getAttrib(u,"height"),scope:a.getAttrib(u,"scope"),"class":a.getAttrib(u,"class"),type:u.nodeName.toLowerCase(),style:"",align:"",valign:""},_a.each("left center right".split(" "),function(e){i.formatter.matchNode(u,"align"+e)&&(c.align=e)}),_a.each("top middle bottom".split(" "),function(e){i.formatter.matchNode(u,"valign"+e)&&(c.valign=e)}),Sa(i)&&_a.extend(c,Va.extractAdvancedStyles(a,u)),n=c),0<Oa(t).length&&(r={name:"class",type:"listbox",label:"Class",values:Va.buildListItems(Oa(t),function(e){e.value&&(e.textStyle=function(){return t.formatter.getCssText({block:"td",classes:[e.value]})})})});var l={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",layout:"grid",columns:2,labelGapCalc:!1,padding:0,defaults:{type:"textbox",maxWidth:50},items:[{label:"Width",name:"width",onchange:b(Va.updateStyleField,t)},{label:"Height",name:"height",onchange:b(Va.updateStyleField,t)},{label:"Cell type",name:"type",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{label:"Scope",name:"scope",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{label:"H Align",name:"align",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"V Align",name:"valign",type:"listbox",text:"None",minWidth:90,maxWidth:null,values:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}]},r]};Sa(t)?t.windowManager.open({title:"Cell properties",bodyType:"tabpanel",data:n,body:[{title:"General",type:"form",items:l},Va.createStyleForm(t)],onsubmit:b(Ga,t,o)}):t.windowManager.open({title:"Cell properties",data:n,body:l,onsubmit:b(Ga,t,o)})}};function Xa(f,s,d,e){var m=f.dom;function g(e,t,n){(1===s.length||n)&&m.setAttrib(e,t,n)}Ra(f)&&Va.syncAdvancedStyleFields(f,e);var h=e.control.rootControl.toJSON();f.undoManager.transact(function(){_a.each(s,function(e){var t,n,r,o,i,u,a,c,l;g(e,"scope",h.scope),g(e,"style",h.style),g(e,"class",h["class"]),t=e,n="height",r=ha(h.height),(1===s.length||r)&&m.setStyle(t,n,r),h.type!==e.parentNode.nodeName.toLowerCase()&&(o=f.dom,i=e,u=h.type,a=o.getParent(i,"table"),c=i.parentNode,(l=o.select(u,a)[0])||(l=o.create(u),a.firstChild?"CAPTION"===a.firstChild.nodeName?o.insertAfter(l,a.firstChild):a.insertBefore(l,a.firstChild):a.appendChild(l)),l.appendChild(i),c.hasChildNodes()||o.remove(c)),h.align!==d.align&&(Fa(f,e),La(f,e,h.align))}),f.focus()})}var Ka=function(t){var e,n,r,o,i,u,a,c,l,f,s=t.dom,d=[];e=s.getParent(t.selection.getStart(),"table"),n=s.getParent(t.selection.getStart(),"td,th"),_a.each(e.rows,function(t){_a.each(t.cells,function(e){if(s.getAttrib(e,"data-mce-selected")||e===n)return d.push(t),!1})}),(r=d[0])&&(1<d.length?i={height:"",scope:"",style:"","class":"",align:"",type:r.parentNode.nodeName.toLowerCase()}:(c=r,l=(a=t).dom,f={height:l.getStyle(c,"height")||l.getAttrib(c,"height"),scope:l.getAttrib(c,"scope"),"class":l.getAttrib(c,"class"),align:"",style:"",type:c.parentNode.nodeName.toLowerCase()},_a.each("left center right".split(" "),function(e){a.formatter.matchNode(c,"align"+e)&&(f.align=e)}),Ra(a)&&_a.extend(f,Va.extractAdvancedStyles(l,c)),i=f),0<Na(t).length&&(o={name:"class",type:"listbox",label:"Class",values:Va.buildListItems(Na(t),function(e){e.value&&(e.textStyle=function(){return t.formatter.getCssText({block:"tr",classes:[e.value]})})})}),u={type:"form",columns:2,padding:0,defaults:{type:"textbox"},items:[{type:"listbox",name:"type",label:"Row type",text:"Header",maxWidth:null,values:[{text:"Header",value:"thead"},{text:"Body",value:"tbody"},{text:"Footer",value:"tfoot"}]},{type:"listbox",name:"align",label:"Alignment",text:"None",maxWidth:null,values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height"},o]},Ra(t)?t.windowManager.open({title:"Row properties",data:i,bodyType:"tabpanel",body:[{title:"General",type:"form",items:u},Va.createStyleForm(t)],onsubmit:b(Xa,t,d,i)}):t.windowManager.open({title:"Row properties",data:i,body:u,onsubmit:b(Xa,t,d,i)}))},Ja=tinymce.util.Tools.resolve("tinymce.Env"),$a={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},percentages:!0},Qa=function(e,t,n,r,o){void 0===o&&(o=$a);var i=De.fromTag("table");Pe(i,o.styles),ve(i,o.attributes);var u=De.fromTag("tbody");kt(i,u);for(var a=[],c=0;c<e;c++){for(var l=De.fromTag("tr"),f=0;f<t;f++){var s=c<n||f<r?De.fromTag("th"):De.fromTag("td");f<r&&pe(s,"scope","row"),c<n&&pe(s,"scope","col"),kt(s,De.fromTag("br")),o.percentages&&ke(s,"width",100/t+"%"),kt(l,s)}a.push(l)}return Bt(u,a),i},Za=function(e,t){e.selection.select(t.dom(),!0),e.selection.collapse(!0)},ec=function(r,e,t){var n,o,i=r.getParam("table_default_styles",xa,"object"),u={styles:i,attributes:(o=r,o.getParam("table_default_attributes",Ca,"object")),percentages:(n=i.width,w(n)&&-1!==n.indexOf("%")&&!Aa(r))},a=Qa(t,e,0,0,u);pe(a,"data-mce-id","__mce");var c,l,f,s=(c=a,l=De.fromTag("div"),f=De.fromDom(c.dom().cloneNode(!0)),kt(l,f),l.dom().innerHTML);return r.insertContent(s),on(sa(r),'table[data-mce-id="__mce"]').map(function(e){var t,n;return Aa(r)&&ke(e,"width",Ie(e,"width")),ye(e,"data-mce-id"),t=r,P(Xt(e,"tr"),function(e){ka(t,e.dom()),P(Xt(e,"th,td"),function(e){Pa(t,e.dom())})}),n=r,on(e,"td,th").each(b(Za,n)),e.dom()}).getOr(null)};function tc(e,t,n,r){if("TD"===t.tagName||"TH"===t.tagName)e.setStyle(t,n,r);else if(t.children)for(var o=0;o<t.children.length;o++)tc(e,t.children[o],n,r)}var nc=function(e,t,n){var r,o,i=e.dom;Ta(e)&&Va.syncAdvancedStyleFields(e,n),!1===(o=n.control.rootControl.toJSON())["class"]&&delete o["class"],e.undoManager.transact(function(){t||(t=ec(e,o.cols||1,o.rows||1)),function(e,t,n){var r,o=e.dom,i={},u={};if(i["class"]=n["class"],u.height=ha(n.height),o.getAttrib(t,"width")&&!Da(e)?i.width=(r=n.width)?r.replace(/px$/,""):"":u.width=ha(n.width),Da(e)?(u["border-width"]=ha(n.border),u["border-spacing"]=ha(n.cellspacing),_a.extend(i,{"data-mce-border-color":n.borderColor,"data-mce-cell-padding":n.cellpadding,"data-mce-border":n.border})):_a.extend(i,{border:n.border,cellpadding:n.cellpadding,cellspacing:n.cellspacing}),Da(e)&&t.children)for(var a=0;a<t.children.length;a++)tc(o,t.children[a],{"border-width":ha(n.border),"border-color":n.borderColor,padding:ha(n.cellpadding)});n.style?_a.extend(u,o.parseStyle(n.style)):u=_a.extend({},o.parseStyle(o.getAttrib(t,"style")),u),i.style=o.serializeStyle(u),o.setAttribs(t,i)}(e,t,o),(r=i.select("caption",t)[0])&&!o.caption&&i.remove(r),!r&&o.caption&&((r=i.create("caption")).innerHTML=Ja.ie?"\xa0":'<br data-mce-bogus="1"/>',t.insertBefore(r,t.firstChild)),Fa(e,t),o.align&&La(e,t,o.align),e.focus(),e.addVisual()})},rc=function(t,e){var n,r,o,i,u,a,c,l,f,s,d=t.dom,m={};!0===e?(n=d.getParent(t.selection.getStart(),"table"))&&(c=n,l=(a=t).dom,f={width:l.getStyle(c,"width")||l.getAttrib(c,"width"),height:l.getStyle(c,"height")||l.getAttrib(c,"height"),cellspacing:l.getStyle(c,"border-spacing")||l.getAttrib(c,"cellspacing"),cellpadding:l.getAttrib(c,"data-mce-cell-padding")||l.getAttrib(c,"cellpadding")||Ha(a.dom,c,"padding"),border:l.getAttrib(c,"data-mce-border")||l.getAttrib(c,"border")||Ha(a.dom,c,"border"),borderColor:l.getAttrib(c,"data-mce-border-color"),caption:!!l.select("caption",c)[0],"class":l.getAttrib(c,"class")},_a.each("left center right".split(" "),function(e){a.formatter.matchNode(c,"align"+e)&&(f.align=e)}),Ta(a)&&_a.extend(f,Va.extractAdvancedStyles(l,c)),m=f):(r={label:"Cols",name:"cols"},o={label:"Rows",name:"rows"}),0<Ea(t).length&&(m["class"]&&(m["class"]=m["class"].replace(/\s*mce\-item\-table\s*/g,"")),i={name:"class",type:"listbox",label:"Class",values:Va.buildListItems(Ea(t),function(e){e.value&&(e.textStyle=function(){return t.formatter.getCssText({block:"table",classes:[e.value]})})})}),u={type:"form",layout:"flex",direction:"column",labelGapCalc:"children",padding:0,items:[{type:"form",labelGapCalc:!1,padding:0,layout:"grid",columns:2,defaults:{type:"textbox",maxWidth:50},items:(s=t,s.getParam("table_appearance_options",!0,"boolean")?[r,o,{label:"Width",name:"width",onchange:b(Va.updateStyleField,t)},{label:"Height",name:"height",onchange:b(Va.updateStyleField,t)},{label:"Cell spacing",name:"cellspacing"},{label:"Cell padding",name:"cellpadding"},{label:"Border",name:"border"},{label:"Caption",name:"caption",type:"checkbox"}]:[r,o,{label:"Width",name:"width",onchange:b(Va.updateStyleField,t)},{label:"Height",name:"height",onchange:b(Va.updateStyleField,t)}])},{label:"Alignment",name:"align",type:"listbox",text:"None",values:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},i]},Ta(t)?t.windowManager.open({title:"Table properties",data:m,bodyType:"tabpanel",body:[{title:"General",type:"form",items:u},Va.createStyleForm(t)],onsubmit:b(nc,t,n)}):t.windowManager.open({title:"Table properties",data:m,body:u,onsubmit:b(nc,t,n)})},oc=_a.each,ic=function(a,t,c,l,n){var r=ga(a),e=function(e){return function(){return S.from(a.dom.getParent(a.selection.getStart(),e)).map(De.fromDom)}},o=e("caption"),f=e("th,td"),s=function(e){return gn.table(e,r)},d=function(e){return{width:da(e.dom()),height:da(e.dom())}},i=function(n){f().each(function(t){s(t).each(function(i){var e=Gr.forMenu(l,i,t),u=d(i);n(i,e).each(function(e){var t,n,r,o;t=a,n=u,o=d(r=i),n.width===o.width&&n.height===o.height||(Ia(t,r.dom(),n.width,n.height),Ba(t,r.dom(),o.width,o.height)),a.selection.setRng(e),a.focus(),c.clear(i),pa(i)})})})},u=function(e){return f().bind(function(o){return s(o).bind(function(e){var t=De.fromDom(a.getDoc()),n=Gr.forMenu(l,e,o),r=Fn(y,t,S.none());return Ma(e,n,r)})})},m=function(u){n.get().each(function(e){var i=k(e,function(e){return Bn(e)});f().each(function(o){s(o).each(function(t){var e=De.fromDom(a.getDoc()),n=zn(e),r=Gr.pasteRows(l,t,o,i,n);u(t,r).each(function(e){a.selection.setRng(e),a.focus(),c.clear(t)})})})})};oc({mceTableSplitCells:function(){i(t.unmergeCells)},mceTableMergeCells:function(){i(t.mergeCells)},mceTableInsertRowBefore:function(){i(t.insertRowsBefore)},mceTableInsertRowAfter:function(){i(t.insertRowsAfter)},mceTableInsertColBefore:function(){i(t.insertColumnsBefore)},mceTableInsertColAfter:function(){i(t.insertColumnsAfter)},mceTableDeleteCol:function(){i(t.deleteColumn)},mceTableDeleteRow:function(){i(t.deleteRow)},mceTableCutRow:function(e){n.set(u()),i(t.deleteRow)},mceTableCopyRow:function(e){n.set(u())},mceTablePasteRowBefore:function(e){m(t.pasteRowsBefore)},mceTablePasteRowAfter:function(e){m(t.pasteRowsAfter)},mceTableDelete:function(){f().orThunk(o).each(function(e){gn.table(e,r).filter(g(r)).each(function(e){var t=De.fromText("");Et(e,t),Mt(e);var n=a.dom.createRng();n.setStart(t.dom(),0),n.setEnd(t.dom(),0),a.selection.setRng(n)})})}},function(e,t){a.addCommand(t,e)}),oc({mceInsertTable:b(rc,a),mceTableProps:b(rc,a,!0),mceTableRowProps:b(Ka,a),mceTableCellProps:b(Ya,a)},function(n,e){a.addCommand(e,function(e,t){n(t)})})},uc=function(e){var t=S.from(e.dom().documentElement).map(De.fromDom).getOr(e);return{parent:C(t),view:C(e),origin:C(vo(0,0))}},ac=function(e,t){return{parent:C(t),view:C(e),origin:C(vo(0,0))}};function cc(e){var n=$.apply(null,e),r=[];return{bind:function(e){if(e===undefined)throw"Event bind error: undefined handler";r.push(e)},unbind:function(t){r=I(r,function(e){return e!==t})},trigger:function(){var t=n.apply(null,arguments);P(r,function(e){e(t)})}}}var lc={create:function(e){return{registry:K(e,function(e){return{bind:e.bind,unbind:e.unbind}}),trigger:K(e,function(e){return e.trigger})}}},fc={mode:_u(["compare","extract","mutate","sink"]),sink:_u(["element","start","stop","destroy"]),api:_u(["forceDrop","drop","move","delayDrop"])},sc={resolve:ni("ephox-dragster").resolve},dc=function(m,g){return function(e){if(m(e)){var t,n,r,o,i,u,a,c=De.fromDom(e.target),l=function(){e.stopPropagation()},f=function(){e.preventDefault()},s=x(f,l),d=(t=c,n=e.clientX,r=e.clientY,o=l,i=f,u=s,a=e,{target:C(t),x:C(n),y:C(r),stop:o,prevent:i,kill:u,raw:C(a)});g(d)}}},mc=function(e,t,n,r){return o=e,i=t,u=!1,a=dc(n,r),o.dom().addEventListener(i,a,u),{unbind:b(gc,o,i,a,u)};var o,i,u,a},gc=function(e,t,n,r){e.dom().removeEventListener(t,n,r)},hc=C(!0),pc=function(e,t,n){return mc(e,t,hc,n)},vc=fc.mode({compare:function(e,t){return vo(t.left()-e.left(),t.top()-e.top())},extract:function(e){return S.some(vo(e.x(),e.y()))},sink:function(e,t){var n,r,o,i=(n=t,r=_o({layerClass:sc.resolve("blocker")},n),o=De.fromTag("div"),pe(o,"role","presentation"),Pe(o,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"}),Yo(o,sc.resolve("blocker")),Yo(o,r.layerClass),{element:function(){return o},destroy:function(){Mt(o)}}),u=pc(i.element(),"mousedown",e.forceDrop),a=pc(i.element(),"mouseup",e.drop),c=pc(i.element(),"mousemove",e.move),l=pc(i.element(),"mouseout",e.delayDrop);return fc.sink({element:i.element,start:function(e){kt(e,i.element())},stop:function(){Mt(i.element())},destroy:function(){i.destroy(),a.unbind(),c.unbind(),l.unbind(),u.unbind()}})},mutate:function(e,t){e.mutate(t.left(),t.top())}});function bc(){var i=S.none(),u=lc.create({move:cc(["info"])});return{onEvent:function(e,o){o.extract(e).each(function(e){var t,n,r;(t=o,n=e,r=i.map(function(e){return t.compare(e,n)}),i=S.some(n),r).each(function(e){u.trigger.move(e)})})},reset:function(){i=S.none()},events:u.registry}}function wc(){var e={onEvent:function(e,t){},reset:y},t=bc(),n=e;return{on:function(){n.reset(),n=t},off:function(){n.reset(),n=e},isOn:function(){return n===t},onEvent:function(e,t){n.onEvent(e,t)},events:t.events}}var yc=function(t,n,e){var r,o,i,u=!1,a=lc.create({start:cc([]),stop:cc([])}),c=wc(),l=function(){d.stop(),c.isOn()&&(c.off(),a.trigger.stop())},f=(r=l,o=200,i=null,{cancel:function(){null!==i&&(m.clearTimeout(i),i=null)},throttle:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];null!==i&&m.clearTimeout(i),i=m.setTimeout(function(){r.apply(null,e),i=null},o)}});c.events.move.bind(function(e){n.mutate(t,e.info())});var s=function(t){return function(){var e=Array.prototype.slice.call(arguments,0);if(u)return t.apply(null,e)}},d=n.sink(fc.api({forceDrop:l,drop:s(l),move:s(function(e,t){f.cancel(),c.onEvent(e,n)}),delayDrop:s(f.throttle)}),e);return{element:d.element,go:function(e){d.start(e),c.on(),a.trigger.start()},on:function(){u=!0},off:function(){u=!1},destroy:function(){d.destroy()},events:a.registry}},xc={transform:function(e,t){var n=t!==undefined?t:{},r=n.mode!==undefined?n.mode:vc;return yc(e,r,t)}},Cc=function(e,t,n){return un(e,t,n).isSome()};function Sc(){var n,r=lc.create({drag:cc(["xDelta","yDelta","target"])}),o=S.none(),e={mutate:function(e,t){n.trigger.drag(e,t)},events:(n=lc.create({drag:cc(["xDelta","yDelta"])})).registry};return e.events.drag.bind(function(t){o.each(function(e){r.trigger.drag(t.xDelta(),t.yDelta(),e)})}),{assign:function(e){o=S.some(e)},get:function(){return o},mutate:e.mutate,events:r.registry}}var Rc=ri.resolve("resizer-bar-dragging");function Tc(e,n){var r=ko.height,t=function(o,t,i){var n=Sc(),r=xc.transform(n,{}),u=S.none(),e=function(e,t){return S.from(be(e,t))};n.events.drag.bind(function(n){e(n.target(),"data-row").each(function(e){var t=gu.getInt(n.target(),"top");ke(n.target(),"top",t+n.yDelta()+"px")}),e(n.target(),"data-column").each(function(e){var t=gu.getInt(n.target(),"left");ke(n.target(),"left",t+n.xDelta()+"px")})});var a=function(e,t){return gu.getInt(e,t)-parseInt(be(e,"data-initial-"+t),10)};r.events.stop.bind(function(){n.get().each(function(r){u.each(function(n){e(r,"data-row").each(function(e){var t=a(r,"top");ye(r,"data-initial-top"),d.trigger.adjustHeight(n,t,parseInt(e,10))}),e(r,"data-column").each(function(e){var t=a(r,"left");ye(r,"data-initial-left"),d.trigger.adjustWidth(n,t,parseInt(e,10))}),mi.refresh(o,n,i,t)})})});var c=function(e,t){d.trigger.startAdjust(),n.assign(e),pe(e,"data-initial-"+t,parseInt(Ie(e,t),10)),Yo(e,Rc),ke(e,"opacity","0.2"),r.go(o.parent())},l=pc(o.parent(),"mousedown",function(e){mi.isRowBar(e.target())&&c(e.target(),"top"),mi.isColBar(e.target())&&c(e.target(),"left")}),f=function(e){return bt(e,o.view())},s=pc(o.view(),"mouseover",function(e){"table"===ce(e.target())||Cc(e.target(),"table",f)?(u="table"===ce(e.target())?S.some(e.target()):nn(e.target(),"table",f)).each(function(e){mi.refresh(o,e,i,t)}):Oe(e.target())&&mi.destroy(o)}),d=lc.create({adjustHeight:cc(["table","delta","row"]),adjustWidth:cc(["table","delta","column"]),startAdjust:cc([])});return{destroy:function(){l.unbind(),s.unbind(),r.destroy(),mi.destroy(o)},refresh:function(e){mi.refresh(o,e,i,t)},on:r.on,off:r.off,hideBars:b(mi.hide,o),showBars:b(mi.show,o),events:d.registry}}(e,n,r),o=lc.create({beforeResize:cc(["table"]),afterResize:cc(["table"]),startDrag:cc([])});return t.events.adjustHeight.bind(function(e){o.trigger.beforeResize(e.table());var t=r.delta(e.delta());Pu(e.table(),t,e.row(),r),o.trigger.afterResize(e.table())}),t.events.startAdjust.bind(function(e){o.trigger.startDrag()}),t.events.adjustWidth.bind(function(e){o.trigger.beforeResize(e.table());var t=n.delta(e.delta(),e.table());ku(e.table(),t,e.column(),n),o.trigger.afterResize(e.table())}),{on:t.on,off:t.off,hideBars:t.hideBars,showBars:t.showBars,destroy:t.destroy,events:o.registry}}var Dc=function(e,t){return e.inline?ac(sa(e),(n=De.fromTag("div"),Pe(n,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"}),kt(Ne(),n),n)):uc(De.fromDom(e.getDoc()));var n},Oc=function(e,t){e.inline&&Mt(t.parent())},Nc=function(u){var a,c,o=S.none(),i=S.none(),l=S.none(),f=/(\d+(\.\d+)?)%/,s=function(e){return"TABLE"===e.nodeName};return u.on("init",function(){var e,t=Io(wa.directionAt),n=Dc(u);if(l=S.some(n),("table"===(e=u.getParam("object_resizing",!0))||e)&&u.getParam("table_resize_bars",!0,"boolean")){var r=Tc(n,t);r.on(),r.events.startDrag.bind(function(e){o=S.some(u.selection.getRng())}),r.events.beforeResize.bind(function(e){var t=e.table().dom();Ia(u,t,da(t),ma(t))}),r.events.afterResize.bind(function(e){var t=e.table(),n=t.dom();pa(t),o.each(function(e){u.selection.setRng(e),u.focus()}),Ba(u,n,da(n),ma(n)),u.undoManager.add()}),i=S.some(r)}}),u.on("ObjectResizeStart",function(e){var t,n=e.target;s(n)&&(a=e.width,t=n,c=u.dom.getStyle(t,"width")||u.dom.getAttrib(t,"width"))}),u.on("ObjectResized",function(e){var t=e.target;if(s(t)){var n=t;if(f.test(c)){var r=parseFloat(f.exec(c)[1]),o=e.width*r/a;u.dom.setStyle(n,"width",o+"%")}else{var i=[];_a.each(n.rows,function(e){_a.each(e.cells,function(e){var t=u.dom.getStyle(e,"width",!0);i.push({cell:e,width:t})})}),_a.each(i,function(e){u.dom.setStyle(e.cell,"width",e.width),u.dom.setAttrib(e.cell,"width",null)})}}}),{lazyResize:function(){return i},lazyWire:function(){return l.getOr(uc(De.fromDom(u.getBody())))},destroy:function(){i.each(function(e){e.destroy()}),l.each(function(e){Oc(u,e)})}}},Ec=function(e){return{fold:e}},Ac=function(o){return Ec(function(e,t,n,r){return e(o)})},kc=function(o){return Ec(function(e,t,n,r){return t(o)})},Pc=function(o,i){return Ec(function(e,t,n,r){return n(o,i)})},Ic=function(o){return Ec(function(e,t,n,r){return r(o)})},Bc=function(n,e){return gn.table(n,e).bind(function(e){var t=gn.cells(e);return L(t,function(e){return bt(n,e)}).map(function(e){return{index:C(e),all:C(t)}})})},Wc=function(t,e){return Bc(t,e).fold(function(){return Ac(t)},function(e){return e.index()+1<e.all().length?Pc(t,e.all()[e.index()+1]):Ic(t)})},Mc=function(t,e){return Bc(t,e).fold(function(){return Ac()},function(e){return 0<=e.index()-1?Pc(t,e.all()[e.index()-1]):kc(t)})},_c=_r([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Lc={before:_c.before,on:_c.on,after:_c.after,cata:function(e,t,n,r){return e.fold(t,n,r)},getStart:function(e){return e.fold(o,o,o)}},jc=_r([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Fc=$("start","soffset","finish","foffset"),zc=function(e){var t,n=e.match({domRange:function(e){return De.fromDom(e.startContainer)},relative:function(e,t){return Lc.getStart(e)},exact:function(e,t,n,r){return e}});return t=n.dom().ownerDocument.defaultView,De.fromDom(t)},Hc=jc.relative,Uc=jc.exact,qc=function(e,t,n,r){var o,i,u,a,c,l=(i=t,u=n,a=r,(c=xt(o=e).dom().createRange()).setStart(o.dom(),i),c.setEnd(u.dom(),a),c),f=bt(e,n)&&t===r;return l.collapsed&&!f},Vc=function(e,t){e.selectNodeContents(t.dom())},Gc=function(e,t,n){var r,o,i=e.document.createRange();return r=i,t.fold(function(e){r.setStartBefore(e.dom())},function(e,t){r.setStart(e.dom(),t)},function(e){r.setStartAfter(e.dom())}),o=i,n.fold(function(e){o.setEndBefore(e.dom())},function(e,t){o.setEnd(e.dom(),t)},function(e){o.setEndAfter(e.dom())}),i},Yc=function(e,t,n,r,o){var i=e.document.createRange();return i.setStart(t.dom(),n),i.setEnd(r.dom(),o),i},Xc=function(e){return{left:C(e.left),top:C(e.top),right:C(e.right),bottom:C(e.bottom),width:C(e.width),height:C(e.height)}},Kc=_r([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Jc=function(e,t,n){return t(De.fromDom(n.startContainer),n.startOffset,De.fromDom(n.endContainer),n.endOffset)},$c=function(e,t){var o,n,r,i=(o=e,t.match({domRange:function(e){return{ltr:C(e),rtl:S.none}},relative:function(e,t){return{ltr:Re(function(){return Gc(o,e,t)}),rtl:Re(function(){return S.some(Gc(o,t,e))})}},exact:function(e,t,n,r){return{ltr:Re(function(){return Yc(o,e,t,n,r)}),rtl:Re(function(){return S.some(Yc(o,n,r,e,t))})}}}));return(r=(n=i).ltr()).collapsed?n.rtl().filter(function(e){return!1===e.collapsed}).map(function(e){return Kc.rtl(De.fromDom(e.endContainer),e.endOffset,De.fromDom(e.startContainer),e.startOffset)}).getOrThunk(function(){return Jc(0,Kc.ltr,r)}):Jc(0,Kc.ltr,r)},Qc=function(i,e){return $c(i,e).match({ltr:function(e,t,n,r){var o=i.document.createRange();return o.setStart(e.dom(),t),o.setEnd(n.dom(),r),o},rtl:function(e,t,n,r){var o=i.document.createRange();return o.setStart(n.dom(),r),o.setEnd(e.dom(),t),o}})},Zc=function(e,t,n){return t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom},el=function(n,r,e,t,o){var i=function(e){var t=n.dom().createRange();return t.setStart(r.dom(),e),t.collapse(!0),t},u=Sn(r).length,a=function(e,t,n,r,o){if(0===o)return 0;if(t===r)return o-1;for(var i=r,u=1;u<o;u++){var a=e(u),c=Math.abs(t-a.left);if(n<=a.bottom){if(n<a.top||i<c)return u-1;i=c}}return 0}(function(e){return i(e).getBoundingClientRect()},e,t,o.right,u);return i(a)},tl=function(t,n,r,o){var e=t.dom().createRange();e.selectNode(n.dom());var i=e.getClientRects();return jo(i,function(e){return Zc(e,r,o)?S.some(e):S.none()}).map(function(e){return el(t,n,r,o,e)})},nl=function(t,e,n,r){var o=t.dom().createRange(),i=Dt(e);return jo(i,function(e){return o.selectNode(e.dom()),Zc(o.getBoundingClientRect(),n,r)?rl(t,e,n,r):S.none()})},rl=function(e,t,n,r){return(me(t)?tl:nl)(e,t,n,r)},ol=function(e,t){return t-e.left<e.right-t},il=function(e,t,n){var r=e.dom().createRange();return r.selectNode(t.dom()),r.collapse(n),r},ul=function(t,e,n){var r=t.dom().createRange();r.selectNode(e.dom());var o=r.getBoundingClientRect(),i=ol(o,n);return(!0===i?En:An)(e).map(function(e){return il(t,e,i)})},al=function(e,t,n){var r=t.dom().getBoundingClientRect(),o=ol(r,n);return S.some(il(e,t,o))},cl=function(e,t,n,r){var o=e.dom().createRange();o.selectNode(t.dom());var i=o.getBoundingClientRect();return function(e,t,n,r){var o=e.dom().createRange();o.selectNode(t.dom());var i=o.getBoundingClientRect(),u=Math.max(i.left,Math.min(i.right,n)),a=Math.max(i.top,Math.min(i.bottom,r));return rl(e,t,u,a)}(e,t,Math.max(i.left,Math.min(i.right,n)),Math.max(i.top,Math.min(i.bottom,r)))},ll=document.caretPositionFromPoint?function(n,e,t){return S.from(n.dom().caretPositionFromPoint(e,t)).bind(function(e){if(null===e.offsetNode)return S.none();var t=n.dom().createRange();return t.setStart(e.offsetNode,e.offset),t.collapse(),S.some(t)})}:document.caretRangeFromPoint?function(e,t,n){return S.from(e.dom().caretRangeFromPoint(t,n))}:function(o,i,t){return De.fromPoint(o,i,t).bind(function(r){var e=function(){return e=o,n=i,(0===Dt(t=r).length?al:ul)(e,t,n);var e,t,n};return 0===Dt(r).length?e():cl(o,r,i,t).orThunk(e)})},fl=function(e,t){var n=ce(e);return"input"===n?Lc.after(e):E(["br","img"],n)?0===t?Lc.before(e):Lc.after(e):Lc.on(e,t)},sl=function(e,t){var n=e.fold(Lc.before,fl,Lc.after),r=t.fold(Lc.before,fl,Lc.after);return Hc(n,r)},dl=function(e,t,n,r){var o=fl(e,t),i=fl(n,r);return Hc(o,i)},ml=function(e,t){S.from(e.getSelection()).each(function(e){e.removeAllRanges(),e.addRange(t)})},gl=function(e,t,n,r,o){var i=Yc(e,t,n,r,o);ml(e,i)},hl=function(s,e){return $c(s,e).match({ltr:function(e,t,n,r){gl(s,e,t,n,r)},rtl:function(e,t,n,r){var o,i,u,a,c,l=s.getSelection();if(l.setBaseAndExtent)l.setBaseAndExtent(e.dom(),t,n.dom(),r);else if(l.extend)try{i=e,u=t,a=n,c=r,(o=l).collapse(i.dom(),u),o.extend(a.dom(),c)}catch(f){gl(s,n,r,e,t)}else gl(s,n,r,e,t)}})},pl=function(e){var o=zc(e).dom(),t=function(e,t,n,r){return Yc(o,e,t,n,r)},n=e.match({domRange:function(e){var t=De.fromDom(e.startContainer),n=De.fromDom(e.endContainer);return dl(t,e.startOffset,n,e.endOffset)},relative:sl,exact:dl});return $c(o,n).match({ltr:t,rtl:t})},vl=function(e){var t=De.fromDom(e.anchorNode),n=De.fromDom(e.focusNode);return qc(t,e.anchorOffset,n,e.focusOffset)?S.some(Fc(t,e.anchorOffset,n,e.focusOffset)):function(e){if(0<e.rangeCount){var t=e.getRangeAt(0),n=e.getRangeAt(e.rangeCount-1);return S.some(Fc(De.fromDom(t.startContainer),t.startOffset,De.fromDom(n.endContainer),n.endOffset))}return S.none()}(e)},bl=function(e,t){var n,r,o=(n=t,r=e.document.createRange(),Vc(r,n),r);ml(e,o)},wl=function(e){return(t=e,S.from(t.getSelection()).filter(function(e){return 0<e.rangeCount}).bind(vl)).map(function(e){return Uc(e.start(),e.soffset(),e.finish(),e.foffset())});var t},yl=function(e,t){var n,r,o,i=Qc(e,t);return r=(n=i).getClientRects(),0<(o=0<r.length?r[0]:n.getBoundingClientRect()).width||0<o.height?S.some(o).map(Xc):S.none()},xl=function(e,t,n){return r=e,o=t,i=n,u=De.fromDom(r.document),ll(u,o,i).map(function(e){return Fc(De.fromDom(e.startContainer),e.startOffset,De.fromDom(e.endContainer),e.endOffset)});var r,o,i,u},Cl=tinymce.util.Tools.resolve("tinymce.util.VK"),Sl=function(e,t,n,r){return Ol(e,t,Wc(n),r)},Rl=function(e,t,n,r){return Ol(e,t,Mc(n),r)},Tl=function(e,t){var n=Uc(t,0,t,0);return pl(n)},Dl=function(e,t){var n,r=Xt(t,"tr");return(n=r,0===n.length?S.none():S.some(n[n.length-1])).bind(function(e){return on(e,"td,th").map(function(e){return Tl(0,e)})})},Ol=function(r,e,t,o,n){return t.fold(S.none,S.none,function(e,t){return En(t).map(function(e){return Tl(0,e)})},function(n){return gn.table(n,e).bind(function(e){var t=Gr.noMenu(n);return r.undoManager.transact(function(){o.insertRowsAfter(e,t)}),Dl(0,e)})})},Nl=["table","li","dl"],El=function(t,n,r,o){if(t.keyCode===Cl.TAB){var i=sa(n),u=function(e){var t=ce(e);return bt(e,i)||E(Nl,t)},e=n.selection.getRng();if(e.collapsed){var a=De.fromDom(e.startContainer);gn.cell(a,u).each(function(e){t.preventDefault(),(t.shiftKey?Rl:Sl)(n,u,e,r,o).each(function(e){n.selection.setRng(e)})})}}},Al={response:$("selection","kill")},kl=function(t){return function(e){return e===t}},Pl=kl(38),Il=kl(40),Bl={ltr:{isBackward:kl(37),isForward:kl(39)},rtl:{isBackward:kl(39),isForward:kl(37)},isUp:Pl,isDown:Il,isNavigation:function(e){return 37<=e&&e<=40}},Wl=function(e,t){var n=Qc(e,t);return{start:C(De.fromDom(n.startContainer)),soffset:C(n.startOffset),finish:C(De.fromDom(n.endContainer)),foffset:C(n.endOffset)}},Ml=function(e,t,n,r){return{start:C(Lc.on(e,t)),finish:C(Lc.on(n,r))}};function _l(a){return{elementFromPoint:function(e,t){return De.fromPoint(De.fromDom(a.document),e,t)},getRect:function(e){return e.dom().getBoundingClientRect()},getRangedRect:function(e,t,n,r){var o=Uc(e,t,n,r);return yl(a,o).map(function(e){return K(e,c)})},getSelection:function(){return wl(a).map(function(e){return Wl(a,e)})},fromSitus:function(e){var t=Hc(e.start(),e.finish());return Wl(a,t)},situsFromPoint:function(e,t){return xl(a,e,t).map(function(e){return{start:C(Lc.on(e.start(),e.soffset())),finish:C(Lc.on(e.finish(),e.foffset()))}})},clearSelection:function(){a.getSelection().removeAllRanges()},setSelection:function(e){var t,n,r,o,i,u;t=a,n=e.start(),r=e.soffset(),o=e.finish(),i=e.foffset(),u=dl(n,r,o,i),hl(t,u)},setRelativeSelection:function(e,t){var n,r;n=a,r=sl(e,t),hl(n,r)},selectContents:function(e){bl(a,e)},getInnerHeight:function(){return a.innerHeight},getScrollY:function(){var e,t,n,r;return(e=De.fromDom(a.document),t=e!==undefined?e.dom():m.document,n=t.body.scrollLeft||t.documentElement.scrollLeft,r=t.body.scrollTop||t.documentElement.scrollTop,vo(n,r)).top()},scrollBy:function(e,t){var n,r,o;n=e,r=t,((o=De.fromDom(a.document))!==undefined?o.dom():m.document).defaultView.scrollBy(n,r)}}}mt.detect().browser.isSafari();var Ll=function(n,e,r,t,o){return bt(r,t)?S.none():Or(r,t,e).bind(function(e){var t=e.boxes().getOr([]);return 0<t.length?(o(n,t,e.start(),e.finish()),S.some(Al.response(S.some(Ml(r,0,r,Dn(r))),!0))):S.none()})},jl={sync:function(n,r,e,t,o,i,u){return bt(e,o)&&t===i?S.none():un(e,"td,th",r).bind(function(t){return un(o,"td,th",r).bind(function(e){return Ll(n,r,t,e,u)})})},detect:Ll,update:function(e,t,n,r,o){return Er(r,e,t,o.firstSelectedSelector(),o.lastSelectedSelector()).map(function(e){return o.clear(n),o.selectRange(n,e.boxes(),e.start(),e.finish()),e.boxes()})}},Fl=re(["left","top","right","bottom"],[]),zl={nu:Fl,moveUp:function(e,t){return Fl({left:e.left(),top:e.top()-t,right:e.right(),bottom:e.bottom()-t})},moveDown:function(e,t){return Fl({left:e.left(),top:e.top()+t,right:e.right(),bottom:e.bottom()+t})},moveBottomTo:function(e,t){var n=e.bottom()-e.top();return Fl({left:e.left(),top:t-n,right:e.right(),bottom:t})},moveTopTo:function(e,t){var n=e.bottom()-e.top();return Fl({left:e.left(),top:t,right:e.right(),bottom:t+n})},getTop:function(e){return e.top()},getBottom:function(e){return e.bottom()},translate:function(e,t,n){return Fl({left:e.left()+t,top:e.top()+n,right:e.right()+t,bottom:e.bottom()+n})},toString:function(e){return"("+e.left()+", "+e.top()+") -> ("+e.right()+", "+e.bottom()+")"}},Hl=function(e){return zl.nu({left:e.left,top:e.top,right:e.right,bottom:e.bottom})},Ul=function(e,t){return S.some(e.getRect(t))},ql=function(e,t,n){return de(t)?Ul(e,t).map(Hl):me(t)?(r=e,o=t,i=n,0<=i&&i<Dn(o)?r.getRangedRect(o,i,o,i+1):0<i?r.getRangedRect(o,i-1,o,i):S.none()).map(Hl):S.none();var r,o,i},Vl=function(e,t){return de(t)?Ul(e,t).map(Hl):me(t)?e.getRangedRect(t,0,t,Dn(t)).map(Hl):S.none()},Gl=$("item","mode"),Yl=function(e,t,n,r){return void 0===r&&(r=Xl),e.property().parent(t).map(function(e){return Gl(e,r)})},Xl=function(e,t,n,r){return void 0===r&&(r=Kl),n.sibling(e,t).map(function(e){return Gl(e,r)})},Kl=function(e,t,n,r){void 0===r&&(r=Kl);var o=e.property().children(t);return n.first(o).map(function(e){return Gl(e,r)})},Jl=[{current:Yl,next:Xl,fallback:S.none()},{current:Xl,next:Kl,fallback:S.some(Yl)},{current:Kl,next:Kl,fallback:S.some(Xl)}],$l=function(t,n,r,o,e){return void 0===e&&(e=Jl),_(e,function(e){return e.current===r}).bind(function(e){return e.current(t,n,o,e.next).orThunk(function(){return e.fallback.bind(function(e){return $l(t,n,e,o)})})})},Ql=function(){return{sibling:function(e,t){return e.query().prevSibling(t)},first:function(e){return 0<e.length?S.some(e[e.length-1]):S.none()}}},Zl=function(){return{sibling:function(e,t){return e.query().nextSibling(t)},first:function(e){return 0<e.length?S.some(e[0]):S.none()}}},ef=function(t,e,n,r,o,i){return $l(t,e,r,o).bind(function(e){return i(e.item())?S.none():n(e.item())?S.some(e.item()):ef(t,e.item(),n,e.mode(),o,i)})},tf=function(t){return function(e){return 0===t.property().children(e).length}},nf=function(e,t,n,r){return ef(e,t,n,Xl,Ql(),r)},rf=function(e,t,n,r){return ef(e,t,n,Xl,Zl(),r)},of=Un(),uf=function(e,t){return r=t,nf(n=of,e,tf(n),r);var n,r},af=function(e,t){return r=t,rf(n=of,e,tf(n),r);var n,r},cf=_r([{none:[]},{retry:["caret"]}]),lf=function(t,e,r){return(n=e,o=Ju,Kt(function(e){return o(e)},tn,n,o,i)).fold(C(!1),function(e){return Vl(t,e).exists(function(e){return n=e,(t=r).left()<n.left()||Math.abs(n.right()-t.left())<1||t.left()>n.right();var t,n})});var n,o,i},ff={point:zl.getTop,adjuster:function(e,t,n,r,o){var i=zl.moveUp(o,5);return Math.abs(n.top()-r.top())<1?cf.retry(i):n.bottom()<o.top()?cf.retry(i):n.bottom()===o.top()?cf.retry(zl.moveUp(o,1)):lf(e,t,o)?cf.retry(zl.translate(i,5,0)):cf.none()},move:zl.moveUp,gather:uf},sf={point:zl.getBottom,adjuster:function(e,t,n,r,o){var i=zl.moveDown(o,5);return Math.abs(n.bottom()-r.bottom())<1?cf.retry(i):n.top()>o.bottom()?cf.retry(i):n.top()===o.bottom()?cf.retry(zl.moveDown(o,1)):lf(e,t,o)?cf.retry(zl.translate(i,5,0)):cf.none()},move:zl.moveDown,gather:af},df=function(n,r,o,i,u){return 0===u?S.some(i):(c=n,l=i.left(),f=r.point(i),c.elementFromPoint(l,f).filter(function(e){return"table"===ce(e)}).isSome()?(t=i,a=u-1,df(n,e=r,o,e.move(t,5),a)):n.situsFromPoint(i.left(),r.point(i)).bind(function(e){return e.start().fold(S.none,function(t,e){return Vl(n,t,e).bind(function(e){return r.adjuster(n,t,e,o,i).fold(S.none,function(e){return df(n,r,o,e,u-1)})}).orThunk(function(){return S.some(i)})},S.none)}));var e,t,a,c,l,f},mf=function(t,n,e){var r,o,i,u=t.move(e,5),a=df(n,t,e,u,100).getOr(u);return(r=t,o=a,i=n,r.point(o)>i.getInnerHeight()?S.some(r.point(o)-i.getInnerHeight()):r.point(o)<0?S.some(-r.point(o)):S.none()).fold(function(){return n.situsFromPoint(a.left(),t.point(a))},function(e){return n.scrollBy(0,e),n.situsFromPoint(a.left(),t.point(a)-e)})},gf={tryUp:b(mf,ff),tryDown:b(mf,sf),ieTryUp:function(e,t){return e.situsFromPoint(t.left(),t.top()-5)},ieTryDown:function(e,t){return e.situsFromPoint(t.left(),t.bottom()+5)},getJumpSize:C(5)},hf=_r([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),pf=function(e){return un(e,"tr")},vf={verify:function(a,e,t,n,r,c,o){return un(n,"td,th",o).bind(function(u){return un(e,"td,th",o).map(function(i){return bt(u,i)?bt(n,u)&&Dn(u)===r?c(i):hf.none("in same cell"):lr.sharedOne(pf,[u,i]).fold(function(){return t=i,n=u,r=(e=a).getRect(t),(o=e.getRect(n)).right>r.left&&o.left<r.right?hf.success():c(i);var e,t,n,r,o},function(e){return c(i)})})}).getOr(hf.none("default"))},cata:function(e,t,n,r,o){return e.fold(t,n,r,o)},adt:hf},bf=$("element","offset"),wf=($("element","deltaOffset"),$("element","start","finish"),$("begin","end"),$("element","text"),$("ancestor","descendants","element","index"),$("parent","children","element","index")),yf=function(e,t){return L(e,b(bt,t))},xf=function(e){return"br"===ce(e)},Cf=function(e,t,n){return t(e,n).bind(function(e){return me(e)&&0===Sn(e).trim().length?Cf(e,t,n):S.some(e)})},Sf=function(t,e,n,r){return(o=e,i=n,Ot(o,i).filter(xf).orThunk(function(){return Ot(o,i-1).filter(xf)})).bind(function(e){return r.traverse(e).fold(function(){return Cf(e,r.gather,t).map(r.relative)},function(e){return(r=e,Ct(r).bind(function(t){var n=Dt(t);return yf(n,r).map(function(e){return wf(t,n,r,e)})})).map(function(e){return Lc.on(e.parent(),e.index())});var r})});var o,i},Rf=function(e,t,n,r){var o,i,u;return(xf(t)?(o=e,i=t,(u=r).traverse(i).orThunk(function(){return Cf(i,u.gather,o)}).map(u.relative)):Sf(e,t,n,r)).map(function(e){return{start:C(e),finish:C(e)}})},Tf=function(e){return vf.cata(e,function(e){return S.none()},function(){return S.none()},function(e){return S.some(bf(e,0))},function(e){return S.some(bf(e,Dn(e)))})},Df=mt.detect(),Of=function(r,o,i,u,a,c){return 0===c?S.none():Af(r,o,i,u,a).bind(function(e){var t=r.fromSitus(e),n=vf.verify(r,i,u,t.finish(),t.foffset(),a.failure,o);return vf.cata(n,function(){return S.none()},function(){return S.some(e)},function(e){return bt(i,e)&&0===u?Nf(r,i,u,zl.moveUp,a):Of(r,o,e,0,a,c-1)},function(e){return bt(i,e)&&u===Dn(e)?Nf(r,i,u,zl.moveDown,a):Of(r,o,e,Dn(e),a,c-1)})})},Nf=function(t,e,n,r,o){return ql(t,e,n).bind(function(e){return Ef(t,o,r(e,gf.getJumpSize()))})},Ef=function(e,t,n){return Df.browser.isChrome()||Df.browser.isSafari()||Df.browser.isFirefox()||Df.browser.isEdge()?t.otherRetry(e,n):Df.browser.isIE()?t.ieRetry(e,n):S.none()},Af=function(t,e,n,r,o){return ql(t,n,r).bind(function(e){return Ef(t,o,e)})},kf=function(t,n,r){return(o=t,i=n,u=r,o.getSelection().bind(function(r){return Rf(i,r.finish(),r.foffset(),u).fold(function(){return S.some(bf(r.finish(),r.foffset()))},function(e){var t=o.fromSitus(e),n=vf.verify(o,r.finish(),r.foffset(),t.finish(),t.foffset(),u.failure,i);return Tf(n)})})).bind(function(e){return Of(t,n,e.element(),e.offset(),r,20).map(t.fromSitus)});var o,i,u},Pf=mt.detect(),If=function(e,t){return tn(e,function(e){return Ct(e).exists(function(e){return bt(e,t)})},n).isSome();var n},Bf=function(t,r,o,e,i){return un(e,"td,th",r).bind(function(n){return un(n,"table",r).bind(function(e){return If(i,e)?kf(t,r,o).bind(function(t){return un(t.finish(),"td,th",r).map(function(e){return{start:C(n),finish:C(e),range:C(t)}})}):S.none()})})},Wf=function(e,t,n,r,o,i){return Pf.browser.isIE()?S.none():i(r,t).orThunk(function(){return Bf(e,t,n,r,o).map(function(e){var t=e.range();return Al.response(S.some(Ml(t.start(),t.soffset(),t.finish(),t.foffset())),!0)})})},Mf=function(e,t,n,r,o,i,u){return Bf(e,n,r,o,i).bind(function(e){return jl.detect(t,n,e.start(),e.finish(),u)})},_f=function(e,u){return un(e,"tr",u).bind(function(i){return un(i,"table",u).bind(function(e){var t,n,r,o=Xt(e,"tr");return bt(i,o[0])?(t=e,n=function(e){return An(e).isSome()},r=u,nf(of,t,n,r)).map(function(e){var t=Dn(e);return Al.response(S.some(Ml(e,t,e,t)),!0)}):S.none()})})},Lf=function(e,u){return un(e,"tr",u).bind(function(i){return un(i,"table",u).bind(function(e){var t,n,r,o=Xt(e,"tr");return bt(i,o[o.length-1])?(t=e,n=function(e){return En(e).isSome()},r=u,rf(of,t,n,r)).map(function(e){return Al.response(S.some(Ml(e,0,e,0)),!0)}):S.none()})})},jf=function(e,t){return un(e,"td,th",t)},Ff={down:{traverse:Tt,gather:af,relative:Lc.before,otherRetry:gf.tryDown,ieRetry:gf.ieTryDown,failure:vf.adt.failedDown},up:{traverse:Rt,gather:uf,relative:Lc.before,otherRetry:gf.tryUp,ieRetry:gf.ieTryUp,failure:vf.adt.failedUp}},zf=$("rows","cols"),Hf={mouse:function(e,t,n,r){var o,i,u,a,c,l,f=_l(e),s=(o=f,i=t,u=n,a=r,c=S.none(),l=function(){c=S.none()},{mousedown:function(e){a.clear(i),c=jf(e.target(),u)},mouseover:function(e){c.each(function(r){a.clear(i),jf(e.target(),u).each(function(n){Or(r,n,u).each(function(e){var t=e.boxes().getOr([]);(1<t.length||1===t.length&&!bt(r,n))&&(a.selectRange(i,t,e.start(),e.finish()),o.selectContents(n))})})})},mouseup:function(){c.each(l)}});return{mousedown:s.mousedown,mouseover:s.mouseover,mouseup:s.mouseup}},keyboard:function(e,c,l,f){var s=_l(e),d=function(){return f.clear(c),S.none()};return{keydown:function(e,t,n,r,o,i){var u=e.raw().which,a=!0===e.raw().shiftKey;return Nr(c,f.selectedSelector()).fold(function(){return Bl.isDown(u)&&a?b(Mf,s,c,l,Ff.down,r,t,f.selectRange):Bl.isUp(u)&&a?b(Mf,s,c,l,Ff.up,r,t,f.selectRange):Bl.isDown(u)?b(Wf,s,l,Ff.down,r,t,Lf):Bl.isUp(u)?b(Wf,s,l,Ff.up,r,t,_f):S.none},function(t){var e=function(e){return function(){return jo(e,function(e){return jl.update(e.rows(),e.cols(),c,t,f)}).fold(function(){return Ar(c,f.firstSelectedSelector(),f.lastSelectedSelector()).map(function(e){var t=Bl.isDown(u)||i.isForward(u)?Lc.after:Lc.before;return s.setRelativeSelection(Lc.on(e.first(),0),t(e.table())),f.clear(c),Al.response(S.none(),!0)})},function(e){return S.some(Al.response(S.none(),!0))})}};return Bl.isDown(u)&&a?e([zf(1,0)]):Bl.isUp(u)&&a?e([zf(-1,0)]):i.isBackward(u)&&a?e([zf(0,-1),zf(-1,0)]):i.isForward(u)&&a?e([zf(0,1),zf(1,0)]):Bl.isNavigation(u)&&!1===a?d:S.none})()},keyup:function(t,n,r,o,i){return Nr(c,f.selectedSelector()).fold(function(){var e=t.raw().which;return 0==(!0===t.raw().shiftKey)?S.none():Bl.isNavigation(e)?jl.sync(c,l,n,r,o,i,f.selectRange):S.none()},S.none)}}}},Uf=function(r,e){P(e,function(e){var t,n;n=e,qo(t=r)?t.dom().classList.remove(n):Go(t,n),Xo(t)})},qf={byClass:function(o){var t,n,i=(t=o.selected(),function(e){Yo(e,t)}),r=(n=[o.selected(),o.lastSelected(),o.firstSelected()],function(e){Uf(e,n)}),u=function(e){var t=Xt(e,o.selectedSelector());P(t,r)};return{clear:u,selectRange:function(e,t,n,r){u(e),P(t,i),Yo(n,o.firstSelected()),Yo(r,o.lastSelected())},selectedSelector:o.selectedSelector,firstSelectedSelector:o.firstSelectedSelector,lastSelectedSelector:o.lastSelectedSelector}},byAttr:function(o){var n=function(e){ye(e,o.selected()),ye(e,o.firstSelected()),ye(e,o.lastSelected())},i=function(e){pe(e,o.selected(),"1")},u=function(e){var t=Xt(e,o.selectedSelector());P(t,n)};return{clear:u,selectRange:function(e,t,n,r){u(e),P(t,i),pe(n,o.firstSelected(),"1"),pe(r,o.lastSelected(),"1")},selectedSelector:o.selectedSelector,firstSelectedSelector:o.firstSelectedSelector,lastSelectedSelector:o.lastSelectedSelector}}},Vf=function(e){return!1===Ko(De.fromDom(e.target),"ephox-snooker-resizer-bar")};function Gf(h,p){var v=re(["mousedown","mouseover","mouseup","keyup","keydown"],[]),b=S.none(),w=qf.byAttr(Mr);return h.on("init",function(e){var r=h.getWin(),o=sa(h),t=ga(h),n=Hf.mouse(r,o,t,w),a=Hf.keyboard(r,o,t,w),c=function(e,t){!0===e.raw().shiftKey&&(t.kill()&&e.kill(),t.selection().each(function(e){var t=Hc(e.start(),e.finish()),n=Qc(r,t);h.selection.setRng(n)}))},i=function(e){var t=f(e);if(t.raw().shiftKey&&Bl.isNavigation(t.raw().which)){var n=h.selection.getRng(),r=De.fromDom(n.startContainer),o=De.fromDom(n.endContainer);a.keyup(t,r,n.startOffset,o,n.endOffset).each(function(e){c(t,e)})}},u=function(e){var t=f(e);p().each(function(e){e.hideBars()});var n=h.selection.getRng(),r=De.fromDom(h.selection.getStart()),o=De.fromDom(n.startContainer),i=De.fromDom(n.endContainer),u=wa.directionAt(r).isRtl()?Bl.rtl:Bl.ltr;a.keydown(t,o,n.startOffset,i,n.endOffset,u).each(function(e){c(t,e)}),p().each(function(e){e.showBars()})},l=function(e){return e.hasOwnProperty("x")&&e.hasOwnProperty("y")},f=function(e){var t=De.fromDom(e.target),n=function(){e.stopPropagation()},r=function(){e.preventDefault()},o=x(r,n);return{target:C(t),x:C(l(e)?e.x:null),y:C(l(e)?e.y:null),stop:n,prevent:r,kill:o,raw:C(e)}},s=function(e){return 0===e.button},d=function(e){s(e)&&Vf(e)&&n.mousedown(f(e))},m=function(e){var t;(t=e).buttons!==undefined&&0==(1&t.buttons)||!Vf(e)||n.mouseover(f(e))},g=function(e){s(e)&&Vf(e)&&n.mouseup(f(e))};h.on("mousedown",d),h.on("mouseover",m),h.on("mouseup",g),h.on("keyup",i),h.on("keydown",u),h.on("nodechange",function(){var e=h.selection,t=De.fromDom(e.getStart()),n=De.fromDom(e.getEnd());lr.sharedOne(gn.table,[t,n]).fold(function(){w.clear(o)},y)}),b=S.some(v({mousedown:d,mouseover:m,mouseup:g,keyup:i,keydown:u}))}),{clear:w.clear,destroy:function(){b.each(function(e){})}}}var Yf=_a.each,Xf=function(t){var n=[];function e(e){return function(){t.execCommand(e)}}Yf("inserttable tableprops deletetable | cell row column".split(" "),function(e){"|"===e?n.push({text:"-"}):n.push(t.menuItems[e])}),t.addButton("table",{type:"menubutton",title:"Table",menu:n}),t.addButton("tableprops",{title:"Table properties",onclick:e("mceTableProps"),icon:"table"}),t.addButton("tabledelete",{title:"Delete table",onclick:e("mceTableDelete")}),t.addButton("tablecellprops",{title:"Cell properties",onclick:e("mceTableCellProps")}),t.addButton("tablemergecells",{title:"Merge cells",onclick:e("mceTableMergeCells")}),t.addButton("tablesplitcells",{title:"Split cell",onclick:e("mceTableSplitCells")}),t.addButton("tableinsertrowbefore",{title:"Insert row before",onclick:e("mceTableInsertRowBefore")}),t.addButton("tableinsertrowafter",{title:"Insert row after",onclick:e("mceTableInsertRowAfter")}),t.addButton("tabledeleterow",{title:"Delete row",onclick:e("mceTableDeleteRow")}),t.addButton("tablerowprops",{title:"Row properties",onclick:e("mceTableRowProps")}),t.addButton("tablecutrow",{title:"Cut row",onclick:e("mceTableCutRow")}),t.addButton("tablecopyrow",{title:"Copy row",onclick:e("mceTableCopyRow")}),t.addButton("tablepasterowbefore",{title:"Paste row before",onclick:e("mceTablePasteRowBefore")}),t.addButton("tablepasterowafter",{title:"Paste row after",onclick:e("mceTablePasteRowAfter")}),t.addButton("tableinsertcolbefore",{title:"Insert column before",onclick:e("mceTableInsertColBefore")}),t.addButton("tableinsertcolafter",{title:"Insert column after",onclick:e("mceTableInsertColAfter")}),t.addButton("tabledeletecol",{title:"Delete column",onclick:e("mceTableDeleteCol")})},Kf=function(t){var e,n=""===(e=t.getParam("table_toolbar",ya))||!1===e?[]:w(e)?e.split(/[ ,]/):R(e)?e:[];0<n.length&&t.addContextToolbar(function(e){return t.dom.is(e,"table")&&t.getBody().contains(e)},n.join(" "))},Jf=function(o,n){var r=S.none(),i=[],u=[],a=[],c=[],l=function(e){e.disabled(!0)},f=function(e){e.disabled(!1)},e=function(){var t=this;i.push(t),r.fold(function(){l(t)},function(e){f(t)})},t=function(){var t=this;u.push(t),r.fold(function(){l(t)},function(e){f(t)})};o.on("init",function(){o.on("nodechange",function(e){var t=S.from(o.dom.getParent(o.selection.getStart(),"th,td"));(r=t.bind(function(e){var t=De.fromDom(e);return gn.table(t).map(function(e){return Gr.forMenu(n,e,t)})})).fold(function(){P(i,l),P(u,l),P(a,l),P(c,l)},function(t){P(i,f),P(u,f),P(a,function(e){e.disabled(t.mergable().isNone())}),P(c,function(e){e.disabled(t.unmergable().isNone())})})})});var s=function(e,t,n,r){var o,i,u,a,c,l=r.getEl().getElementsByTagName("table")[0],f=r.isRtl()||"tl-tr"===r.parent().rel;for(l.nextSibling.innerHTML=t+1+" x "+(n+1),f&&(t=9-t),i=0;i<10;i++)for(o=0;o<10;o++)a=l.rows[i].childNodes[o].firstChild,c=(f?t<=o:o<=t)&&i<=n,e.dom.toggleClass(a,"mce-active",c),c&&(u=a);return u.parentNode},d=!1===o.getParam("table_grid",!0,"boolean")?{text:"Table",icon:"table",context:"table",onclick:m("mceInsertTable")}:{text:"Table",icon:"table",context:"table",ariaHideMenu:!0,onclick:function(e){e.aria&&(this.parent().hideAll(),e.stopImmediatePropagation(),o.execCommand("mceInsertTable"))},onshow:function(){s(o,0,0,this.menu.items()[0])},onhide:function(){var e=this.menu.items()[0].getEl().getElementsByTagName("a");o.dom.removeClass(e,"mce-active"),o.dom.addClass(e[0],"mce-active")},menu:[{type:"container",html:function(){var e="";e='<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">';for(var t=0;t<10;t++){e+="<tr>";for(var n=0;n<10;n++)e+='<td role="gridcell" tabindex="-1"><a id="mcegrid'+(10*t+n)+'" href="#" data-mce-x="'+n+'" data-mce-y="'+t+'"></a></td>';e+="</tr>"}return e+="</table>",e+='<div class="mce-text-center" role="presentation">1 x 1</div>'}(),onPostRender:function(){this.lastX=this.lastY=0},onmousemove:function(e){var t,n,r=e.target;"A"===r.tagName.toUpperCase()&&(t=parseInt(r.getAttribute("data-mce-x"),10),n=parseInt(r.getAttribute("data-mce-y"),10),(this.isRtl()||"tl-tr"===this.parent().rel)&&(t=9-t),t===this.lastX&&n===this.lastY||(s(o,t,n,e.control),this.lastX=t,this.lastY=n))},onclick:function(e){var t=this;"A"===e.target.tagName.toUpperCase()&&(e.preventDefault(),e.stopPropagation(),t.parent().cancel(),o.undoManager.transact(function(){ec(o,t.lastX+1,t.lastY+1)}),o.addVisual())}}]};function m(e){return function(){o.execCommand(e)}}var g={text:"Table properties",context:"table",onPostRender:e,onclick:m("mceTableProps")},h={text:"Delete table",context:"table",onPostRender:e,cmd:"mceTableDelete"},p={text:"Row",context:"table",menu:[{text:"Insert row before",onclick:m("mceTableInsertRowBefore"),onPostRender:t},{text:"Insert row after",onclick:m("mceTableInsertRowAfter"),onPostRender:t},{text:"Delete row",onclick:m("mceTableDeleteRow"),onPostRender:t},{text:"Row properties",onclick:m("mceTableRowProps"),onPostRender:t},{text:"-"},{text:"Cut row",onclick:m("mceTableCutRow"),onPostRender:t},{text:"Copy row",onclick:m("mceTableCopyRow"),onPostRender:t},{text:"Paste row before",onclick:m("mceTablePasteRowBefore"),onPostRender:t},{text:"Paste row after",onclick:m("mceTablePasteRowAfter"),onPostRender:t}]},v={text:"Column",context:"table",menu:[{text:"Insert column before",onclick:m("mceTableInsertColBefore"),onPostRender:t},{text:"Insert column after",onclick:m("mceTableInsertColAfter"),onPostRender:t},{text:"Delete column",onclick:m("mceTableDeleteCol"),onPostRender:t}]},b={separator:"before",text:"Cell",context:"table",menu:[{text:"Cell properties",onclick:m("mceTableCellProps"),onPostRender:t},{text:"Merge cells",onclick:m("mceTableMergeCells"),onPostRender:function(){var t=this;a.push(t),r.fold(function(){l(t)},function(e){t.disabled(e.mergable().isNone())})}},{text:"Split cell",onclick:m("mceTableSplitCells"),onPostRender:function(){var t=this;c.push(t),r.fold(function(){l(t)},function(e){t.disabled(e.unmergable().isNone())})}}]};o.addMenuItem("inserttable",d),o.addMenuItem("tableprops",g),o.addMenuItem("deletetable",h),o.addMenuItem("row",p),o.addMenuItem("column",v),o.addMenuItem("cell",b)},$f=function(n,r){return{insertTable:function(e,t){return ec(n,e,t)},setClipboardRows:function(e){return t=r,n=k(e,De.fromDom),void t.set(S.from(n));var t,n},getClipboardRows:function(){return r.get().fold(function(){},function(e){return k(e,function(e){return e.dom()})})}}};e.add("table",function(t){var n,r=Nc(t),e=Gf(t,r.lazyResize),o=Wa(t,r.lazyWire),i=(n=t,{get:function(){var e=sa(n);return kr(e,Mr.selectedSelector()).fold(function(){return n.selection.getStart()===undefined?jr.none():jr.single(n.selection)},function(e){return jr.multiple(e)})}}),u=Bu(S.none());return ic(t,o,e,i,u),Yr(t,i,o,e),Jf(t,i),Xf(t),Kf(t),t.on("PreInit",function(){t.serializer.addTempAttr(Mr.firstSelected()),t.serializer.addTempAttr(Mr.lastSelected())}),t.getParam("table_tab_navigation",!0,"boolean")&&t.on("keydown",function(e){El(e,t,o,r.lazyWire)}),t.on("remove",function(){r.destroy(),e.destroy()}),$f(t,u)})}(window);