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