egroupware/api/js/tinymce/plugins/table/plugin.min.js

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