egroupware/api/js/tinymce/plugins/table/plugin.min.js
Hadi Nategh 16fe435de4 W.I.P. implementing TinyMCE editor and deprecating CKEditor:
- Fix language setting
- Update TinyMCE
2018-10-25 18:18:47 +02:00

1 line
125 KiB
JavaScript

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