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