plugin.min.js 132 KB

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