plugin.min.js 155.0 KB
Newer Older
Five-菜鸟级's avatar
init  
Five-菜鸟级 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
/**
 * tpTable (Enhancement 1.4v)
 * The tinymce-plugins is used to set up the conversion table (Enhancement)
 * 
 * https://github.com/Five-great/tinymce-plugins
 * 
 * Copyright 2021, Five(Li Hailong) The Chengdu, China https://www.fivecc.cn/
 *
 * Licensed under MIT
 */
 (function(Cd){function Q(x,D){D=D||{};xc(D);return Promise.resolve(x).then(function(B){return ub(B,D.filter,!0)}).then(Dd).then(C).then(function(B){D.bgcolor&&(B.style.backgroundColor=D.bgcolor);D.width&&(B.style.width=D.width+"px");D.height&&(B.style.height=D.height+"px");D.style&&Object.keys(D.style).forEach(function(v){B.style[v]=D.style[v]});return B}).then(function(B){return Ed(B,D.width||O.width(x),D.height||O.height(x))})}function xc(x){S.impl.options.imagePlaceholder="undefined"===typeof x.imagePlaceholder?
 yc.imagePlaceholder:x.imagePlaceholder;S.impl.options.cacheBust="undefined"===typeof x.cacheBust?yc.cacheBust:x.cacheBust}function vb(x,D){return Q(x,D).then(O.makeImage).then(O.delay(100)).then(function(B){var v=document.createElement("canvas");v.width=D.width||O.width(x);v.height=D.height||O.height(x);if(D.bgcolor){var k=v.getContext("2d");k.fillStyle=D.bgcolor;k.fillRect(0,0,v.width,v.height)}v.getContext("2d").drawImage(B,0,0);return v})}function ub(x,D,B){function v(A,E,J){A=A.childNodes;return 0===
 A.length?Promise.resolve(E):function(K,pa,qa){var Na=Promise.resolve();pa.forEach(function(ta){Na=Na.then(function(){return ub(ta,qa)}).then(function(Ca){Ca&&K.appendChild(Ca)})});return Na}(E,O.asArray(A),J).then(function(){return E})}function k(A,E){return E instanceof Element?Promise.resolve().then(function(){(function(J,K){function pa(qa,Na){O.asArray(qa).forEach(function(ta){Na.setProperty(ta,qa.getPropertyValue(ta),qa.getPropertyPriority(ta))})}J.cssText?K.cssText=J.cssText:pa(J,K)})(window.getComputedStyle(A),
 E.style)}).then(function(){function J(K){var pa=window.getComputedStyle(A,K),qa=pa.getPropertyValue("content");if(""!==qa&&"none"!==qa){qa=O.uid();E.className=E.className+" "+qa;var Na=document.createElement("style");Na.appendChild(function(ta,Ca,Va){function zc(db){var R=db.getPropertyValue("content");return db.cssText+" content: "+R+";"}function Fd(db){return O.asArray(db).map(function(R){return R+": "+db.getPropertyValue(R)+(db.getPropertyPriority(R)?" !important":"")}).join("; ")+";"}ta="."+ta+
 ":"+Ca;Va=Va.cssText?zc(Va):Fd(Va);return document.createTextNode(ta+"{"+Va+"}")}(qa,K,pa));E.appendChild(Na)}}[":before",":after"].forEach(function(K){J(K)})}).then(function(){A instanceof HTMLTextAreaElement&&(E.innerHTML=A.value);A instanceof HTMLInputElement&&E.setAttribute("value",A.value)}).then(function(){E instanceof SVGElement&&(E.setAttribute("xmlns","http://www.w3.org/2000/svg"),E instanceof SVGRectElement&&["width","height"].forEach(function(J){var K=E.getAttribute(J);K&&E.style.setProperty(J,
 K)}))}).then(function(){return E}):E}return B||!D||D(x)?Promise.resolve(x).then(function(A){return A instanceof HTMLCanvasElement?O.makeImage(A.toDataURL()):A.cloneNode(!1)}).then(function(A){return v(x,A,D)}).then(function(A){return k(x,A)}):Promise.resolve()}function Dd(x){return ca.resolveAll().then(function(D){var B=document.createElement("style");x.appendChild(B);B.appendChild(document.createTextNode(D));return x})}function C(x){return Oa.inlineAll(x).then(function(){return x})}function Ed(x,
 D,B){return Promise.resolve(x).then(function(v){v.setAttribute("xmlns","http://www.w3.org/1999/xhtml");return(new XMLSerializer).serializeToString(v)}).then(O.escapeXhtml).then(function(v){return'<foreignObject x="0" y="0" width="100%" height="100%">'+v+"</foreignObject>"}).then(function(v){return'<svg xmlns="http://www.w3.org/2000/svg" width="'+D+'" height="'+B+'">'+v+"</svg>"}).then(function(v){return"data:image/svg+xml;charset=utf-8,"+v})}var O=function(){function x(v){return(v=/\.([^\.\/]*?)$/g.exec(v))?
 v[1]:""}function D(v){return new Promise(function(k){for(var A=window.atob(v.toDataURL().split(",")[1]),E=A.length,J=new Uint8Array(E),K=0;K<E;K++)J[K]=A.charCodeAt(K);k(new Blob([J],{type:"image/png"}))})}function B(v,k){v=window.getComputedStyle(v).getPropertyValue(k);return parseFloat(v.replace("px",""))}return{escape:function(v){return v.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1")},parseExtension:x,mimeType:function(v){return{woff:"application/font-woff",woff2:"application/font-woff",ttf:"application/font-truetype",
 eot:"application/vnd.ms-fontobject",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"}[x(v).toLowerCase()]||""},dataAsUrl:function(v,k){return"data:"+k+";base64,"+v},isDataUrl:function(v){return-1!==v.search(/^(data:)/)},canvasToBlob:function(v){return v.toBlob?new Promise(function(k){v.toBlob(k)}):D(v)},resolveUrl:function(v,k){var A=document.implementation.createHTMLDocument(),E=A.createElement("base");A.head.appendChild(E);var J=A.createElement("a");
 A.body.appendChild(J);E.href=k;J.href=v;return J.href},getAndEncode:function(v){S.impl.options.cacheBust&&(v+=(/\?/.test(v)?"&":"?")+(new Date).getTime());return new Promise(function(k){var A=new XMLHttpRequest;A.onreadystatechange=function(){if(4===A.readyState)if(200!==A.status)E?k(E):(console.error("cannot fetch resource: "+v+", status: "+A.status),k(""));else{var K=new FileReader;K.onloadend=function(){var pa=K.result.split(/,/)[1];k(pa)};K.readAsDataURL(A.response)}};A.ontimeout=function(){E?
 k(E):(console.error("timeout of 30000ms occured while fetching resource: "+v),k(""))};A.responseType="blob";A.timeout=3E4;A.open("GET",v,!0);A.send();var E;if(S.impl.options.imagePlaceholder){var J=S.impl.options.imagePlaceholder.split(/,/);J&&J[1]&&(E=J[1])}})},uid:function(){var v=0;return function(){return"u"+("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).slice(-4)+v++}}(),delay:function(v){return function(k){return new Promise(function(A){setTimeout(function(){A(k)},v)})}},asArray:function(v){for(var k=
 [],A=v.length,E=0;E<A;E++)k.push(v[E]);return k},escapeXhtml:function(v){return v.replace(/#/g,"%23").replace(/\n/g,"%0A")},makeImage:function(v){return new Promise(function(k,A){var E=new Image;E.onload=function(){k(E)};E.onerror=A;E.src=v})},width:function(v){var k=B(v,"border-left-width"),A=B(v,"border-right-width");return v.scrollWidth+k+A},height:function(v){var k=B(v,"border-top-width"),A=B(v,"border-bottom-width");return v.scrollHeight+k+A}}}(),w=function(){function x(k){return-1!==k.search(v)}
 function D(k){for(var A=[],E;null!==(E=v.exec(k));)A.push(E[1]);return A.filter(function(J){return!O.isDataUrl(J)})}function B(k,A,E,J){return Promise.resolve(A).then(function(K){return E?O.resolveUrl(K,E):K}).then(J||O.getAndEncode).then(function(K){return O.dataAsUrl(K,O.mimeType(A))}).then(function(K){return k.replace(new RegExp("(url\\(['\"]?)("+O.escape(A)+")(['\"]?\\))","g"),"$1"+K+"$3")})}var v=/url\(['"]?([^'"]+?)['"]?\)/g;return{inlineAll:function(k,A,E){return x(k)?Promise.resolve(k).then(D).then(function(J){var K=
 Promise.resolve(k);J.forEach(function(pa){K=K.then(function(qa){return B(qa,pa,A,E)})});return K}):Promise.resolve(k)},shouldProcess:x,impl:{readUrls:D,inline:B}}}(),ca=function(){function x(){function D(B){return{resolve:function(){return w.inlineAll(B.cssText,(B.parentStyleSheet||{}).href)},src:function(){return B.style.getPropertyValue("src")}}}return Promise.resolve(O.asArray(document.styleSheets)).then(function(B){var v=[];B.forEach(function(k){try{O.asArray(k.cssRules||[]).forEach(v.push.bind(v))}catch(A){console.log("Error while reading CSS rules from "+
 k.href,A.toString())}});return v}).then(function(B){return B.filter(function(v){return v.type===CSSRule.FONT_FACE_RULE}).filter(function(v){return w.shouldProcess(v.style.getPropertyValue("src"))})}).then(function(B){return B.map(D)})}return{resolveAll:function(){return x(document).then(function(D){return Promise.all(D.map(function(B){return B.resolve()}))}).then(function(D){return D.join("\n")})},impl:{readAll:x}}}(),Oa=function(){function x(B){return{inline:function(v){return O.isDataUrl(B.src)?
 Promise.resolve():Promise.resolve(B.src).then(v||O.getAndEncode).then(function(k){return O.dataAsUrl(k,O.mimeType(B.src))}).then(function(k){return new Promise(function(A,E){B.onload=A;B.onerror=E;B.src=k})})}}}function D(B){return B instanceof Element?function(v){var k=v.style.getPropertyValue("background");return k?w.inlineAll(k).then(function(A){v.style.setProperty("background",A,v.style.getPropertyPriority("background"))}).then(function(){return v}):Promise.resolve(v)}(B).then(function(){return B instanceof
 HTMLImageElement?x(B).inline():Promise.all(O.asArray(B.childNodes).map(function(v){return D(v)}))}):Promise.resolve(B)}return{inlineAll:D,impl:{newImage:x}}}(),yc={imagePlaceholder:void 0,cacheBust:!1},S={toSvg:Q,toPng:function(x,D){return vb(x,D||{}).then(function(B){return B.toDataURL()})},toJpeg:function(x,D){D=D||{};return vb(x,D).then(function(B){return B.toDataURL("image/jpeg",D.quality||1)})},toBlob:function(x,D){return vb(x,D||{}).then(O.canvasToBlob)},toPixelData:function(x,D){return vb(x,
 D||{}).then(function(B){return B.getContext("2d").getImageData(0,0,O.width(x),O.height(x)).data})},impl:{fontFaces:ca,images:Oa,util:O,inliner:w,options:{}}};Cd.domtoimage=S})(window);
 (function(Cd){function Q(a){for(var b=[],c=1;c<arguments.length;c++)b[c-1]=arguments[c];return function(){for(var d=[],e=0;e<arguments.length;e++)d[e]=arguments[e];d=b.concat(d);return a.apply(null,d)}}function xc(){for(var a=0,b=0,c=arguments.length;b<c;b++)a+=arguments[b].length;a=Array(a);var d=0;for(b=0;b<c;b++)for(var e=arguments[b],f=0,g=e.length;f<g;f++,d++)a[d]=e[f];return a}function vb(a,b,c,d,e){return a(c,d)?k.some(c):Ca(e)&&e(c)?k.none():b(c,d,e)}function ub(){return{up:w({selector:wb,
 closest:da,predicate:Yb,all:of}),down:w({selector:Gd,predicate:pf}),styles:w({get:Da,getRaw:Ja,set:ea,remove:eb}),attrs:w({get:ha,set:fa,remove:T,copyTo:function(a,b){a=qf(a);Zb(b,a)}}),insert:w({before:Ac,after:fb,afterAll:ui,append:U,appendAll:gb,prepend:Hd,wrap:vi}),remove:w({unwrap:wi,remove:ua}),create:w({nu:u.fromTag,clone:function(a){return u.fromDom(a.dom.cloneNode(!1))},text:u.fromText}),query:w({comparePosition:function(a,b){return a.dom.compareDocumentPosition(b.dom)},prevSibling:rf,nextSibling:Bc}),
 property:w({children:ra,name:L,parent:Wa,document:function(a){return Id(a).dom},isText:hb,isComment:xi,isElement:ib,isSpecial:function(a){a=L(a);return R("script noscript iframe noframes noembed title style textarea xmp".split(" "),a)},getText:Cc,setText:yi,isBoundary:function(a){return ib(a)?"body"===L(a)?!0:R(zi,L(a)):!1},isEmptyTag:function(a){return ib(a)?R(["br","img","hr","input"],L(a)):!1},isNonEditable:function(a){return ib(a)&&"false"===ha(a,"contenteditable")}}),eq:M,is:Ai}}function Dd(a,
 b,c){var d=Bi.byAttr(Xa,function(e,f,g){c.targets().each(function(h){N(f).each(function(l){var n=sf(a);n=Jd(C,u.fromDom(a.getDoc()),n);l=Ci(l,h,n);a.fire("TableSelectionChange",{cells:e,start:f,finish:g,otherCells:l})})})},function(){a.fire("TableSelectionClear")});a.on("init",function(e){var f=a.getWin(),g=jb(a);e=Kd(a);var h=Di(f,g,e,d),l=Ei(f,g,e,d),n=Fi(f,g,e,d);a.on("TableSelectorChange",function(m){return n(m.start,m.finish)});var p=function(m,r){!0===m.raw.shiftKey&&(r.kill&&m.kill(),r.selection.each(function(t){t=
 kb.relative(t.start,t.finish);t=Ld(f,t);a.selection.setRng(t)}))};e=function(){var m=Aa(u.fromDom(g)),r=Aa(0);return{touchEnd:function(t){var q=u.fromDom(t.target);if("td"===L(q)||"th"===L(q)){var y=m.get(),H=r.get();M(y,q)&&300>t.timeStamp-H&&(t.preventDefault(),n(q,q))}m.set(q);r.set(t.timeStamp)}}}();a.on("dragstart",function(m){h.clearstate()});a.on("mousedown",function(m){0===m.button&&Md(m)&&h.mousedown($b(m))});a.on("mouseover",function(m){var r=void 0===m.buttons?!0:tf.browser.isEdge()&&0===
 m.buttons?!0:0!==(m.buttons&1);r&&Md(m)&&h.mouseover($b(m))});a.on("mouseup",function(m){0===m.button&&Md(m)&&h.mouseup($b(m))});a.on("touchend",e.touchEnd);a.on("keyup",function(m){var r=$b(m);if(r.raw.shiftKey&&Nd(r.raw.which)){m=a.selection.getRng();var t=u.fromDom(m.startContainer),q=u.fromDom(m.endContainer);l.keyup(r,t,m.startOffset,q,m.endOffset).each(function(y){p(r,y)})}});a.on("keydown",function(m){var r=$b(m);b().each(function(H){return H.hideBars()});m=a.selection.getRng();var t=u.fromDom(m.startContainer),
 q=u.fromDom(m.endContainer),y=uf(Gi,Hi)(u.fromDom(a.selection.getStart()));l.keydown(r,t,m.startOffset,q,m.endOffset,y).each(function(H){p(r,H)});b().each(function(H){return H.showBars()})});a.on("NodeChange",function(){var m=a.selection,r=u.fromDom(m.getStart());m=u.fromDom(m.getEnd());Od(N,[r,m]).fold(function(){return d.clear(g)},C)})});return{clear:d.clear}}var C=function(){},Ed=function(a,b){return function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return a(b.apply(null,c))}},
 O=function(a,b){return function(c){return a(b(c))}},w=function(a){return function(){return a}},ca=function(a){return a},Oa=function(a){return function(b){return!a(b)}},yc=function(a){return function(){throw Error(a);}},S=w(!1),x=w(!0),D=function(){return B},B=function(){var a=function(d){return d.isNone()},b=function(d){return d()},c=function(d){return d};return{fold:function(d,e){return d()},is:S,isSome:S,isNone:x,getOr:c,getOrThunk:b,getOrDie:function(d){throw Error(d||"error: getOrDie called on none.");
 },getOrNull:w(null),getOrUndefined:w(void 0),or:c,orThunk:b,map:D,each:C,bind:D,exists:S,forall:x,filter:D,equals:a,equals_:a,toArray:function(){return[]},toString:w("none()")}}(),v=function(a){var b=w(a),c=function(){return e},d=function(f){return f(a)},e={fold:function(f,g){return g(a)},is:function(f){return a===f},isSome:x,isNone:S,getOr:b,getOrThunk:b,getOrDie:b,getOrNull:b,getOrUndefined:b,or:c,orThunk:c,map:function(f){return v(f(a))},each:function(f){f(a)},bind:d,exists:d,forall:d,filter:function(f){return f(a)?
 e:B},toArray:function(){return[a]},toString:function(){return"some("+a+")"},equals:function(f){return f.is(a)},equals_:function(f,g){return f.fold(S,function(h){return g(a,h)})}};return e},k={some:v,none:D,from:function(a){return null===a||void 0===a?B:v(a)}},A=function(a){return function(b){var c=typeof b;return(null===b?"null":"object"===c&&(Array.prototype.isPrototypeOf(b)||b.constructor&&"Array"===b.constructor.name)?"array":"object"===c&&(String.prototype.isPrototypeOf(b)||b.constructor&&"String"===
 b.constructor.name)?"string":c)===a}},E=function(a){return function(b){return typeof b===a}},J=A("string"),K=A("object"),pa=A("array"),qa=E("boolean"),Na=function(a){return function(b){return a===b}}(void 0),ta=function(a){return null===a||void 0===a},Ca=E("function"),Va=E("number"),zc=Array.prototype.slice,Fd=Array.prototype.indexOf,db=Array.prototype.push,R=function(a,b){return-1<Fd.call(a,b)},la=function(a,b){for(var c=0,d=a.length;c<d;c++)if(b(a[c],c))return!0;return!1},Ea=function(a,b){for(var c=
 [],d=0;d<a;d++)c.push(b(d));return c},z=function(a,b){for(var c=a.length,d=Array(c),e=0;e<c;e++)d[e]=b(a[e],e);return d},F=function(a,b){for(var c=0,d=a.length;c<d;c++)b(a[c],c)},Ii=function(a,b){for(var c=a.length-1;0<=c;c--)b(a[c],c)},Ji=function(a,b){for(var c=[],d=[],e=0,f=a.length;e<f;e++){var g=a[e];(b(g,e)?c:d).push(g)}return{pass:c,fail:d}},Y=function(a,b){for(var c=[],d=0,e=a.length;d<e;d++){var f=a[d];b(f,d)&&c.push(f)}return c},Ka=function(a,b,c){Ii(a,function(d){c=b(c,d)});return c},ma=
 function(a,b,c){F(a,function(d){c=b(c,d)});return c},Fa=function(a,b){a:{for(var c=0,d=a.length;c<d;c++){var e=a[c];if(b(e,c)){a=k.some(e);break a}else if(S(e,c))break}a=k.none()}return a},Dc=function(a,b){for(var c=0,d=a.length;c<d;c++)if(b(a[c],c))return k.some(c);return k.none()},vf=function(a){for(var b=[],c=0,d=a.length;c<d;++c){if(!pa(a[c]))throw Error("Arr.flatten item "+c+" was not an array, input: "+a);db.apply(b,a[c])}return b},na=function(a,b){return vf(z(a,b))},lb=function(a,b){for(var c=
 0,d=a.length;c<d;++c)if(!0!==b(a[c],c))return!1;return!0},Ki=function(a){a=zc.call(a,0);a.reverse();return a},Pd=function(a,b){for(var c={},d=0,e=a.length;d<e;d++){var f=a[d];c[String(f)]=b(f,d)}return c},Li=function(a){return[a]},Mi=function(a,b){a=zc.call(a,0);a.sort(b);return a},Qd=function(a,b){return 0<=b&&b<a.length?k.some(a[b]):k.none()},Rd=function(a){return Qd(a,a.length-1)},mb=function(a,b){for(var c=0;c<a.length;c++){var d=b(a[c],c);if(d.isSome())return d}return k.none()},I=function(){I=
 Object.assign||function(a){for(var b,c=1,d=arguments.length;c<d;c++){b=arguments[c];for(var e in b)Object.prototype.hasOwnProperty.call(b,e)&&(a[e]=b[e])}return a};return I.apply(this,arguments)},Gb=function(a){var b=!1,c;return function(){for(var d=[],e=0;e<arguments.length;e++)d[e]=arguments[e];b||(b=!0,c=a.apply(null,d));return c}},wf=function(){return Sd(0,0)},Sd=function(a,b){return{major:a,minor:b}},Ec={nu:Sd,detect:function(a,b){b=String(b).toLowerCase();if(0===a.length)a=wf();else{a:{for(var c=
 0;c<a.length;c++){var d=a[c];if(d.test(b)){a=d;break a}}a=void 0}a=a?Sd(Number(b.replace(a,"$1")),Number(b.replace(a,"$2"))):{major:0,minor:0}}return a},unknown:wf},xf=function(a,b){var c=String(b).toLowerCase();return Fa(a,function(d){return d.search(c)})},yf={detectBrowser:function(a,b){return xf(a,b).map(function(c){var d=Ec.detect(c.versionRegexes,b);return{current:c.name,version:d}})},detectOs:function(a,b){return xf(a,b).map(function(c){var d=Ec.detect(c.versionRegexes,b);return{current:c.name,
 version:d}})}},Fc=function(a,b,c){return""===b||a.length>=b.length&&a.substr(c,c+b.length)===b},va=function(a,b){return-1!==a.indexOf(b)},Gc=function(a,b){return Fc(a,b,a.length-b.length)},Ni=function(a){return function(b){return b.replace(a,"")}}(/^\s+|\s+$/g),Oi=function(a){return 0<a.length},Td=/.*?version\/ ?([0-9]+)\.([0-9]+).*/,Ya=function(a){return function(b){return va(b,a)}},Pi=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(a){return va(a,"edge/")&&va(a,"chrome")&&
 va(a,"safari")&&va(a,"applewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Td],search:function(a){return va(a,"chrome")&&!va(a,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(a){return va(a,"msie")||va(a,"trident")}},{name:"Opera",versionRegexes:[Td,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:Ya("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/ ?([0-9]+)\.([0-9]+).*/],search:Ya("firefox")},{name:"Safari",
 versionRegexes:[Td,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function(a){return(va(a,"safari")||va(a,"mobile/"))&&va(a,"applewebkit")}}],Qi=[{name:"Windows",search:Ya("win"),versionRegexes:[/.*?windows nt ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(a){return va(a,"iphone")||va(a,"ipad")},versionRegexes:[/.*?version\/ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Ya("android"),versionRegexes:[/.*?android ?([0-9]+)\.([0-9]+).*/]},
 {name:"OSX",search:Ya("mac os x"),versionRegexes:[/.*?mac os x ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Ya("linux"),versionRegexes:[]},{name:"Solaris",search:Ya("sunos"),versionRegexes:[]},{name:"FreeBSD",search:Ya("freebsd"),versionRegexes:[]},{name:"ChromeOS",search:Ya("cros"),versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/]}],zf={browsers:w(Pi),oses:w(Qi)},Af=function(a){var b=a.current,c=function(d){return function(){return b===d}};return{current:b,version:a.version,isEdge:c("Edge"),isChrome:c("Chrome"),
 isIE:c("IE"),isOpera:c("Opera"),isFirefox:c("Firefox"),isSafari:c("Safari")}},Ri=function(){return Af({current:void 0,version:Ec.unknown()})};w("Edge");w("Chrome");w("IE");w("Opera");w("Firefox");w("Safari");var Bf=function(a){var b=a.current,c=function(d){return function(){return b===d}};return{current:b,version:a.version,isWindows:c("Windows"),isiOS:c("iOS"),isAndroid:c("Android"),isOSX:c("OSX"),isLinux:c("Linux"),isSolaris:c("Solaris"),isFreeBSD:c("FreeBSD"),isChromeOS:c("ChromeOS")}},Si=function(){return Bf({current:void 0,
 version:Ec.unknown()})};w("Windows");w("iOS");w("Android");w("Linux");w("OSX");w("Solaris");w("FreeBSD");w("ChromeOS");var Ti={detect:function(a,b){var c=zf.browsers(),d=zf.oses();c=yf.detectBrowser(c,a).fold(Ri,Af);d=yf.detectOs(d,a).fold(Si,Bf);var e=d.isiOS()&&!0===/ipad/i.test(a),f=d.isiOS()&&!e,g=d.isiOS()||d.isAndroid(),h=g||b("(pointer:coarse)");b=e||!f&&g&&b("(min-device-width:768px)");g=f||g&&!b;a=c.isSafari()&&d.isiOS()&&!1===/safari/i.test(a);var l=!g&&!b&&!a;a={isiPad:w(e),isiPhone:w(f),
 isTablet:w(b),isPhone:w(g),isTouch:w(h),isAndroid:d.isAndroid,isiOS:d.isiOS,isWebView:w(a),isDesktop:w(l)};return{browser:c,os:d,deviceType:a}}},Ui=function(a){return window.matchMedia(a).matches},Hc=Gb(function(){return Ti.detect(navigator.userAgent,Ui)}),ac=function(a){if(null===a||void 0===a)throw Error("Node cannot be null or undefined");return{dom:a}},u={fromHtml:function(a,b){b=(b||document).createElement("div");b.innerHTML=a;if(!b.hasChildNodes()||1<b.childNodes.length)throw console.error("HTML does not have a single root node",
 a),Error("HTML must have a single root node");return ac(b.childNodes[0])},fromTag:function(a,b){a=(b||document).createElement(a);return ac(a)},fromText:function(a,b){a=(b||document).createTextNode(a);return ac(a)},fromDom:ac,fromPoint:function(a,b,c){return k.from(a.dom.elementFromPoint(b,c)).map(ac)}},Ga=function(a,b){a=a.dom;if(1!==a.nodeType)return!1;if(void 0!==a.matches)return a.matches(b);if(void 0!==a.msMatchesSelector)return a.msMatchesSelector(b);if(void 0!==a.webkitMatchesSelector)return a.webkitMatchesSelector(b);
 if(void 0!==a.mozMatchesSelector)return a.mozMatchesSelector(b);throw Error("Browser lacks native selectors");},Cf=function(a){return 1!==a.nodeType&&9!==a.nodeType&&11!==a.nodeType||0===a.childElementCount},Za=function(a,b){b=void 0===b?document:b.dom;return Cf(b)?[]:z(b.querySelectorAll(a),u.fromDom)},Hb=function(a,b){b=void 0===b?document:b.dom;return Cf(b)?k.none():k.from(b.querySelector(a)).map(u.fromDom)},M=function(a,b){return a.dom===b.dom},Ud=function(a,b){if(Hc().browser.isIE()){var c=Node.DOCUMENT_POSITION_CONTAINED_BY;
 b=0!==(a.dom.compareDocumentPosition(b.dom)&c)}else a=a.dom,b=b.dom,b=a===b?!1:a.contains(b);return b},Ai=Ga,wa=Object.keys,xb=Object.hasOwnProperty,sa=function(a,b){for(var c=wa(a),d=0,e=c.length;d<e;d++){var f=c[d];b(a[f],f)}},Df=function(a,b){return Vi(a,function(c,d){return{k:d,v:b(c,d)}})},Vi=function(a,b){var c={};sa(a,function(d,e){d=b(d,e);c[d.k]=d.v});return c},Wi=function(a){return function(b,c){a[c]=b}},Xi=function(a,b,c,d){sa(a,function(e,f){(b(e,f)?c:d)(e,f)});return{}},Ib=function(a,
 b){var c={};Xi(a,b,Wi(c),C);return c},Ef=function(a,b){var c=[];sa(a,function(d,e){c.push(b(d,e))});return c},Yi=function(a){return Ef(a,function(b){return b})},Pa=function(a,b){return xb.call(a,b)?k.from(a[b]):k.none()},Ff=function(a,b){return xb.call(a,b)&&void 0!==a[b]&&null!==a[b]},Zi=function(a){for(var b in a)if(xb.call(a,b))return!1;return!0},$i=["tfoot","thead","tbody","colgroup"],Vd=function(a,b,c){return{element:a,cells:b,section:c}},xa=function(a,b,c){return{element:a,isNew:b,isLocked:c}},
 Jb=function(a,b){return{cells:a,section:b}};"undefined"!==typeof window||Function("return this;")();var L=function(a){return a.dom.nodeName.toLowerCase()},Ic=function(a){return function(b){return b.dom.nodeType===a}},xi=function(a){return 8===a.dom.nodeType||"#comment"===L(a)},ib=Ic(1),hb=Ic(3),aj=Ic(9),bj=Ic(11),Gf=function(a){return function(b){return ib(b)&&L(b)===a}},Kb=function(a){return u.fromDom(a.dom.ownerDocument)},Id=function(a){return aj(a)?a:Kb(a)},Wa=function(a){return k.from(a.dom.parentNode).map(u.fromDom)},
 of=function(a,b){b=Ca(b)?b:S;var c=a.dom;for(a=[];null!==c.parentNode&&void 0!==c.parentNode;){c=c.parentNode;var d=u.fromDom(c);a.push(d);if(!0===b(d))break}return a},rf=function(a){return k.from(a.dom.previousSibling).map(u.fromDom)},Bc=function(a){return k.from(a.dom.nextSibling).map(u.fromDom)},ra=function(a){return z(a.dom.childNodes,u.fromDom)},Wd=function(a,b){return k.from(a.dom.childNodes[b]).map(u.fromDom)},Hf=Ca(Element.prototype.attachShadow)&&Ca(Node.prototype.getRootNode),cj=w(Hf),dj=
 Hf?function(a){return u.fromDom(a.dom.getRootNode())}:Id,ej=function(a){a=dj(a);return bj(a)&&!ta(a.dom.host)?k.some(a):k.none()},fj=function(a){return u.fromDom(a.dom.host)},gj=function(a){if(cj()&&!ta(a.target)){var b=u.fromDom(a.target);if(ib(b)&&!ta(b.dom.shadowRoot)&&a.composed&&a.composedPath&&(b=a.composedPath()))return Qd(b,0)}return k.from(a.target)},bc=function(a){var b=hb(a)?a.dom.parentNode:a.dom;if(void 0===b||null===b||null===b.ownerDocument)return!1;var c=b.ownerDocument;return ej(u.fromDom(b)).fold(function(){return c.body.contains(b)},
 O(bc,fj))},If=function(a){a=a.dom.body;if(null===a||void 0===a)throw Error("Body is not available yet");return u.fromDom(a)},hj=function(a,b,c){return Y(of(a,c),b)},ij=function(a,b){return Y(ra(a),b)},pf=function(a,b){var c=[];F(ra(a),function(d){b(d)&&(c=c.concat([d]));c=c.concat(pf(d,b))});return c},cc=function(a,b,c){return hj(a,function(d){return Ga(d,b)},c)},dc=function(a,b){return ij(a,function(c){return Ga(c,b)})},Gd=function(a,b){return Za(b,a)},Yb=function(a,b,c){a=a.dom;for(c=Ca(c)?c:S;a.parentNode;){a=
 a.parentNode;var d=u.fromDom(a);if(b(d))return k.some(d);if(c(d))break}return k.none()},jj=function(a,b,c){return vb(function(d,e){return e(d)},Yb,a,b,c)},kj=function(a,b){return Fa(a.dom.childNodes,function(c){return b(u.fromDom(c))}).map(u.fromDom)},lj=function(a,b){var c=function(d){for(var e=0;e<d.childNodes.length;e++){var f=u.fromDom(d.childNodes[e]);if(b(f))return k.some(f);f=c(d.childNodes[e]);if(f.isSome())return f}return k.none()};return c(a.dom)},wb=function(a,b,c){return Yb(a,function(d){return Ga(d,
 b)},c)},Jf=function(a,b){return kj(a,function(c){return Ga(c,b)})},mj=function(a,b){return Hb(b,a)},da=function(a,b,c){return vb(function(d,e){return Ga(d,e)},wb,a,b,c)},Kf=function(a,b,c){if(J(c)||qa(c)||Va(c))a.setAttribute(b,c+"");else throw console.error("Invalid call to Attribute.set. Key ",b,":: Value ",c,":: Element ",a),Error("Attribute value was not simple");},fa=function(a,b,c){Kf(a.dom,b,c)},Zb=function(a,b){var c=a.dom;sa(b,function(d,e){Kf(c,e,d)})},ha=function(a,b){a=a.dom.getAttribute(b);
 return null===a?void 0:a},T=function(a,b){a.dom.removeAttribute(b)},qf=function(a){return ma(a.dom.attributes,function(b,c){b[c.name]=c.value;return b},{})},Lb=function(a){return void 0!==a.style&&Ca(a.style.getPropertyValue)},Lf=function(a,b,c){if(!J(c))throw console.error("Invalid call to CSS.set. Property ",b,":: Value ",c,":: Element ",a),Error("CSS value must be a string: "+c);Lb(a)&&a.style.setProperty(b,c)},ea=function(a,b,c){Lf(a.dom,b,c)},ec=function(a,b){var c=a.dom;sa(b,function(d,e){Lf(c,
 e,d)})},Da=function(a,b){var c=a.dom,d=window.getComputedStyle(c).getPropertyValue(b);return""!==d||bc(a)?d:Mf(c,b)},Mf=function(a,b){return Lb(a)?a.style.getPropertyValue(b):""},Ja=function(a,b){a=Mf(a.dom,b);return k.from(a).filter(function(c){return 0<c.length})},eb=function(a,b){var c=a.dom;Lb(c)&&c.style.removeProperty(b);k.from(ha(a,"style")).map(Ni).is("")&&T(a,"style")},La=function(a,b,c){void 0===c&&(c=0);return k.from(ha(a,b)).map(function(d){return parseInt(d,10)}).getOr(c)},nj=function(a){return 1<
 La(a,"colspan",1)},oj=function(a){return 1<La(a,"rowspan",1)},fc=w(10),Xd=w(10),nb=function(a,b,c){return na(ra(a),function(d){return Ga(d,b)?c(d)?[d]:[]:nb(d,b,c)})},Jc=function(a,b,c){void 0===c&&(c=S);return c(b)?k.none():R(a,L(b))?k.some(b):wb(b,a.join(","),function(d){return Ga(d,"table")||c(d)})},Mb=function(a){return nb(a,"th,td",x)},Yd=function(a){return Ga(a,"colgroup")?dc(a,"col"):na(Nf(a),function(b){return dc(b,"col")})},N=function(a,b){return da(a,"table",b)},Nf=function(a){return N(a).fold(w([]),
 function(b){return dc(b,"colgroup")})},Of=function(a,b){return z(a,function(c){if("colgroup"===L(c)){var d=z(Yd(c),function(e){var f=La(e,"span",1);return{element:e,rowspan:1,colspan:f}});return Vd(c,d,"colgroup")}d=z(Mb(c),function(e){var f=La(e,"rowspan",1),g=La(e,"colspan",1);return{element:e,rowspan:f,colspan:g}});return Vd(c,d,b(c))})},pj=function(a){return Wa(a).map(function(b){b=L(b);return R($i,b)?b:"tbody"}).getOr("tbody")},Pf=function(a){var b=nb(a,"tr",x);a=Nf(a);b=xc(a,b);return Of(b,
 pj)},qj=function(a,b){return Of(a,function(){return b})},Kc=function(a,b,c){var d=a.cells,e=d.slice(0,b);b=d.slice(b);c=e.concat(c).concat(b);return Jb(c,a.section)},Qf=function(a,b){b=z(a.cells,b);return Jb(b,a.section)},ya=function(a,b){return a.cells[b].element},oa=function(a){a=Ji(a,function(b){return"colgroup"===b.section});return{rows:a.fail,cols:a.pass}},rj=function(a){return k.from(ha(a,"data-snooker-locked-cols")).bind(function(b){return k.from(b.match(/\d+/g))}).map(function(b){return Pd(b,
 x)})},yb=function(a){a=ma(oa(a).rows,function(b,c){F(c.cells,function(d,e){d.isLocked&&(b[e]=!0)});return b},{});a=Ef(a,function(b,c){return parseInt(c,10)});return Mi(a)},Rf=function(a,b){a=na(a.all,function(c){return c.cells});return Y(a,b)},sj=function(a){var b={},c=0;F(a.cells,function(d){var e=d.colspan;Ea(e,function(f){f=c+f;b[f]={element:d.element,colspan:e,column:f}});c+=e});return b},Sf=function(a){var b={},c=[],d={},e=Qd(a,0).map(function(l){return l.element}).bind(N).bind(rj).getOr({}),
 f=0,g=0,h=0;F(a,function(l){if("colgroup"===l.section)d=sj(l);else{var n=[];F(l.cells,function(p){for(var m=0;void 0!==b[h+","+m];)m++;var r=Ff(e,m.toString());r={element:p.element,rowspan:p.rowspan,colspan:p.colspan,row:h,column:m,isLocked:r};for(var t=0;t<p.colspan;t++)for(var q=0;q<p.rowspan;q++){var y=m+t;b[h+q+","+y]=r;g=Math.max(g,y+1)}n.push(r)});f++;c.push(Vd(l.element,n,l.section));h++}});return{grid:{rows:f,columns:g},access:b,all:c,columns:d}},G={fromTable:function(a){a=Pf(a);return Sf(a)},
 generate:Sf,getAt:function(a,b,c){a=a.access[b+","+c];return void 0!==a?k.some(a):k.none()},findItem:function(a,b,c){a=Rf(a,function(d){return c(b,d.element)});return 0<a.length?k.some(a[0]):k.none()},filterItems:Rf,justCells:function(a){return na(a.all,function(b){return b.cells})},justColumns:function(a){return Yi(a.columns)},hasColumns:function(a){return 0<wa(a.columns).length},getColumnAt:function(a,b){return k.from(a.columns[b])}},tj=function(a,b){var c=b.column+b.colspan-1,d=b.row,e=b.row+b.rowspan-
 1;return b.column<=a.finishCol&&c>=a.startCol&&d<=a.finishRow&&e>=a.startRow},uj=function(a,b){return b.column>=a.startCol&&b.column+b.colspan-1<=a.finishCol&&b.row>=a.startRow&&b.row+b.rowspan-1<=a.finishRow},Tf=function(a,b,c){b=G.findItem(a,b,M);var d=G.findItem(a,c,M);return b.bind(function(e){return d.map(function(f){return{startRow:Math.min(e.row,f.row),startCol:Math.min(e.column,f.column),finishRow:Math.max(e.row+e.rowspan-1,f.row+f.rowspan-1),finishCol:Math.max(e.column+e.colspan-1,f.column+
 f.colspan-1)}})})},vj=function(a,b,c){return Tf(a,b,c).bind(function(d){for(var e=!0,f=Q(uj,d),g=d.startRow;g<=d.finishRow;g++)for(var h=d.startCol;h<=d.finishCol;h++)e=e&&G.getAt(a,g,h).exists(f);return e?k.some(d):k.none()})},wj=function(a,b,c,d){return G.findItem(a,b,M).bind(function(e){return G.getAt(a,(0<c?e.row+e.rowspan-1:e.row)+c,(0<d?e.column+e.colspan-1:e.column)+d).map(function(f){return f.element})})},Uf=function(a,b,c){return Tf(a,b,c).map(function(d){d=G.filterItems(a,Q(tj,d));return z(d,
 function(e){return e.element})})},Vf=function(a,b){return G.findItem(a,b,function(c,d){return Ud(d,c)}).map(function(c){return c.element})},xj=function(a,b,c){return N(a).bind(function(d){d=Lc(d);return wj(d,a,b,c)})},yj=function(a,b,c){a=Lc(a);return Uf(a,b,c)},Zd=function(a,b,c,d,e){var f=Lc(a);b=M(a,c)?k.some(b):Vf(f,b);var g=M(a,e)?k.some(d):Vf(f,d);return b.bind(function(h){return g.bind(function(l){return Uf(f,h,l)})})},Lc=G.fromTable,Ac=function(a,b){Wa(a).each(function(c){c.dom.insertBefore(b.dom,
 a.dom)})},fb=function(a,b){Bc(a).fold(function(){Wa(a).each(function(c){U(c,b)})},function(c){Ac(c,b)})},Hd=function(a,b){Wd(a,0).fold(function(){U(a,b)},function(c){a.dom.insertBefore(b.dom,c.dom)})},U=function(a,b){a.dom.appendChild(b.dom)},vi=function(a,b){Ac(a,b);U(b,a)},zj=function(a,b){F(b,function(c){Ac(a,c)})},ui=function(a,b){F(b,function(c,d){fb(0===d?a:b[d-1],c)})},gb=function(a,b){F(b,function(c){U(a,c)})},$d=function(a){a.dom.textContent="";F(ra(a),function(b){ua(b)})},ua=function(a){a=
 a.dom;null!==a.parentNode&&a.parentNode.removeChild(a)},wi=function(a){var b=ra(a);0<b.length&&zj(a,b);ua(a)},Mc=function(a,b){var c=function(d){return a(d)?k.from(d.dom.nodeValue):k.none()};return{get:function(d){if(!a(d))throw Error("Can only get "+b+" value of a "+b+" node");return c(d).getOr("")},getOption:c,set:function(d,e){if(!a(d))throw Error("Can only set raw "+b+" value of a "+b+" node");d.dom.nodeValue=e}}}(hb,"text"),Cc=function(a){return Mc.get(a)},yi=function(a,b){return Mc.set(a,b)},
 zi="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".split(" "),Bj=function(a,b,c,d){c=b(a,c);return Ka(d,function(e,f){f=b(a,f);return Aj(a,e,f)},c)},Aj=function(a,b,c){return b.bind(function(d){return c.filter(Q(a.eq,d))})},Cj=function(a,b,c){if(0<c.length){var d=c[0];c=c.slice(1);a=Bj(a,b,d,c)}else a=k.none();return a},Dj=function(a,b,c,d){void 0===d&&(d=S);b=[b].concat(a.up().all(b));
 c=[c].concat(a.up().all(c));var e=function(g){return Dc(g,d).fold(function(){return g},function(h){return g.slice(0,h+1)})};b=e(b);var f=e(c);c=Fa(b,function(g){return la(f,Q(a.eq,g))});return{firstpath:b,secondpath:f,shared:c}},Wf=ub(),Od=function(a,b){return Cj(Wf,function(c,d){return a(d)},b)},ae=function(a){return wb(a,"table")},Nc=function(a,b,c){var d=function(e){return function(f){return void 0!==c&&c(f)||M(f,e)}};return M(a,b)?k.some({boxes:k.some([a]),start:a,finish:b}):ae(a).bind(function(e){return ae(b).bind(function(f){if(M(e,
 f))return k.some({boxes:yj(e,a,b),start:a,finish:b});if(Ud(e,f)){var g=cc(b,"td,th",d(e));g=0<g.length?g[g.length-1]:b;return k.some({boxes:Zd(e,a,e,b,f),start:a,finish:g})}return Ud(f,e)?(g=cc(a,"td,th",d(f)),g=0<g.length?g[g.length-1]:a,k.some({boxes:Zd(f,a,e,b,f),start:a,finish:g})):Dj(Wf,a,b,void 0).shared.bind(function(h){return da(h,"table",c).bind(function(l){var n=cc(b,"td,th",d(l));n=0<n.length?n[n.length-1]:b;var p=cc(a,"td,th",d(l));p=0<p.length?p[p.length-1]:a;return k.some({boxes:Zd(l,
 a,e,b,f),start:p,finish:n})})})})})},Oc=function(a,b){a=Za(b,a);return 0<a.length?k.some(a):k.none()},Ej=function(a,b){return Fa(a,function(c){return Ga(c,b)})},Xf=function(a,b,c){return Hb(b,a).bind(function(d){return Hb(c,a).bind(function(e){return Od(ae,[d,e]).map(function(f){return{first:d,last:e,table:f}})})})},Fj=function(a,b){return wb(a,"table").bind(function(c){return Hb(b,c).bind(function(d){return Nc(d,a).bind(function(e){return e.boxes.map(function(f){return{boxes:f,start:e.start,finish:e.finish}})})})})},
 Gj=function(a,b,c,d,e){return Ej(a,e).bind(function(f){return xj(f,b,c).bind(function(g){return Fj(g,d)})})},Hj=function(a,b){return Oc(a,b)},Ij=function(a,b,c){return Xf(a,b,c).bind(function(d){var e=function(h){return M(a,h)},f=wb(d.first,"thead,tfoot,tbody,table",e),g=wb(d.last,"thead,tfoot,tbody,table",e);return f.bind(function(h){return g.bind(function(l){if(M(h,l)){l=d.first;var n=d.last,p=Lc(d.table);l=vj(p,l,n)}else l=k.none();return l})})})},$a={generate:function(a){if(!pa(a))throw Error("cases must be an array");
 if(0===a.length)throw Error("there must be at least one case");var b=[],c={};F(a,function(d,e){var f=wa(d);if(1!==f.length)throw Error("one and only one name per case");var g=f[0],h=d[g];if(void 0!==c[g])throw Error("duplicate key detected:"+g);if("cata"===g)throw Error("cannot have a case named cata (sorry)");if(!pa(h))throw Error("case arguments must be an array");b.push(g);c[g]=function(){for(var l=[],n=0;n<arguments.length;n++)l[n]=arguments[n];n=l.length;if(n!==h.length)throw Error("Wrong number of arguments to case "+
 g+". Expected "+h.length+" ("+h+"), got "+n);return{fold:function(){for(var p=[],m=0;m<arguments.length;m++)p[m]=arguments[m];if(p.length!==a.length)throw Error("Wrong number of arguments to fold. Expected "+a.length+", got "+p.length);return p[e].apply(null,l)},match:function(p){var m=wa(p);if(b.length!==m.length)throw Error("Wrong number of arguments to match. Expected: "+b.join(",")+"\nActual: "+m.join(","));if(!lb(b,function(r){return R(m,r)}))throw Error("Not all branches were specified when using match. Specified: "+
 m.join(", ")+"\nRequired: "+b.join(", "));return p[g].apply(null,l)},log:function(p){console.log(p,{constructors:b,constructor:g,params:l})}}}});return c}},be=$a.generate([{none:[]},{multiple:["elements"]},{single:["element"]}]),ce=function(a,b,c,d){return a.fold(b,c,d)},Jj=be.none,Kj=be.multiple,Lj=be.single,Mj=function(a,b,c){return{get:function(){return Hj(a(),c).fold(function(){return b().map(Lj).getOrThunk(Jj)},function(d){return Kj(d)})}}},Nj=tinymce.util.Tools.resolve("tinymce.PluginManager"),
 ob=function(a,b){return u.fromDom(a.dom.cloneNode(b))},Oj=function(a,b){b=u.fromTag(b);var c=qf(a);Zb(b,c);a=ra(ob(a,!0));gb(b,a);return b},Yf=function(a){for(var b=[],c=function(e){b.push(e)},d=0;d<a.length;d++)a[d].each(c);return b},Pj=function(a,b,c){return a.isSome()&&b.isSome()?k.some(c(a.getOrDie(),b.getOrDie())):k.none()},Qj=function(a,b){return void 0!==a&&null!==a?b(a):k.none()},Zf=function(a,b){var c=function(e){var f=b(e);return 0>=f||null===f?(e=Da(e,a),parseFloat(e)||0):f},d=function(e,
 f){return ma(f,function(g,h){h=Da(e,h);h=void 0===h?0:parseInt(h,10);return isNaN(h)?g:g+h},0)};return{set:function(e,f){if(!Va(f)&&!f.match(/^[0-9]+$/))throw Error(a+".set accepts only positive integer values. Value was "+f);e=e.dom;Lb(e)&&(e.style[a]=f+"px")},get:c,getOuter:c,aggregate:d,max:function(e,f,g){e=d(e,g);return f>e?f-e:0}}},$f=Zf("width",function(a){return a.dom.offsetWidth}),Ba=function(a){return $f.get(a)},de=function(a){return $f.getOuter(a)},ee=function(a,b){void 0===b&&(b=x);var c=
 a.grid,d=Ea(c.columns,ca),e=Ea(c.rows,ca);return z(d,function(f){return ag(function(){return na(e,function(g){return G.getAt(a,g,f).filter(function(h){return h.column===f}).toArray()})},function(g){return 1===g.colspan&&b(g.element)},function(){return G.getAt(a,0,f)})})},ag=function(a,b,c){var d=a();return Fa(d,b).orThunk(function(){return k.from(d[0]).orThunk(c)}).map(function(e){return e.element})},bg=function(a){var b=a.grid,c=Ea(b.rows,ca),d=Ea(b.columns,ca);return z(c,function(e){return ag(function(){return na(d,
 function(f){return G.getAt(a,e,f).filter(function(g){return g.row===e}).fold(w([]),function(g){return[g]})})},function(f){return 1===f.rowspan},function(){return G.getAt(a,e,0)})})},Rj=function(a,b){if(0>b||b>=a.length-1)return k.none();var c=a[b].fold(function(){var e=Ki(a.slice(0,b));return mb(e,function(f,g){return f.map(function(h){return{value:h,delta:g+1}})})},function(e){return k.some({value:e,delta:0})}),d=a[b+1].fold(function(){var e=a.slice(b+1);return mb(e,function(f,g){return f.map(function(h){return{value:h,
 delta:g+1}})})},function(e){return k.some({value:e,delta:1})});return c.bind(function(e){return d.map(function(f){return Math.abs(f.value-e.value)/(f.delta+e.delta)})})},uf=function(a,b){return function(c){return"rtl"===("rtl"===Da(c,"direction")?"rtl":"ltr")?b:a}},fe=Zf("height",function(a){var b=a.dom;return bc(a)?b.getBoundingClientRect().height:b.offsetHeight}),Pc=function(a){return fe.get(a)},cg=function(a,b){return{left:a,top:b,translate:function(c,d){return cg(a+c,b+d)}}},ab=cg,Qc=function(a,
 b){return void 0!==a?a:void 0!==b?b:0},gc=function(a){var b=a.dom.ownerDocument,c=b.body,d=b.defaultView,e=b.documentElement;if(c===a.dom)return ab(c.offsetLeft,c.offsetTop);b=Qc(null===d||void 0===d?void 0:d.pageYOffset,e.scrollTop);d=Qc(null===d||void 0===d?void 0:d.pageXOffset,e.scrollLeft);var f=Qc(e.clientTop,c.clientTop);c=Qc(e.clientLeft,c.clientLeft);e=a.dom;var g=e.ownerDocument.body;g===e?a=ab(g.offsetLeft,g.offsetTop):bc(a)?(a=e.getBoundingClientRect(),a=ab(a.left,a.top)):a=ab(0,0);return a.translate(d-
 c,b-f)},dg=function(a){return gc(a).left+de(a)},eg=function(a){return gc(a).left},fg=function(a,b){b=eg(b);return{col:a,x:b}},gg=function(a,b){b=dg(b);return{col:a,x:b}},ge=function(a){return gc(a).top},Sj=function(a,b){b=ge(b);return{row:a,y:b}},Tj=function(a,b){b=ge(b)+fe.getOuter(b);return{row:a,y:b}},he=function(a,b,c){if(0===c.length)return[];var d=z(c.slice(1),function(f,g){return f.map(function(h){return a(g,h)})}),e=c[c.length-1].map(function(f){return b(c.length-1,f)});return d.concat([e])},
 Rc={delta:ca,positions:function(a){return he(Sj,Tj,a)},edge:ge},ie=uf({delta:ca,edge:eg,positions:function(a){return he(fg,gg,a)}},{delta:function(a){return-a},edge:dg,positions:function(a){return he(gg,fg,a)}}),Sc={delta:function(a,b){return ie(b).delta(a,b)},positions:function(a,b){return ie(b).positions(a,b)},edge:function(a){return ie(a).edge(a)}},Uj={unsupportedLength:"em ex cap ch ic rem lh rlh vw vh vi vb vmin vmax cm mm Q in pc pt px".split(" "),fixed:["px","pt"],relative:["%"],empty:[""]},
 Vj=/^([+-]?(?:Infinity|[0-9]+\.(?:[0-9]+)?(?:[eE][+-]?[0-9]+)?|\.[0-9]+(?:[eE][+-]?[0-9]+)?|[0-9]+(?:[eE][+-]?[0-9]+)?))(.*)$/,Wj=function(a,b){return la(b,function(c){return la(Uj[c],function(d){return a===d})})},Xj=function(a,b){return k.from(Vj.exec(a)).bind(function(c){var d=Number(c[1]);c=c[2];return Wj(c,b)?k.some({value:d,unit:c}):k.none()})},hg=function(){var a=Hc().browser;return a.isIE()||a.isEdge()},Qa=function(a,b,c){a=Da(a,b);a=parseFloat(a);return isNaN(a)?c:a},je=function(a){if(hg()){var b=
 a.dom.getBoundingClientRect().width;if("border-box"!==Da(a,"box-sizing")){var c=Qa(a,"padding-left",0),d=Qa(a,"padding-right",0),e=Qa(a,"border-left-width",0);a=Qa(a,"border-right-width",0);b=b-c-d-(e+a)}}else b=Qa(a,"width",Ba(a));return b},Tc=/(\d+(\.\d+)?)%/,ke=/(\d+(\.\d+)?)px|em/,ig=function(a,b){ea(a,"width",b+"px")},jg=function(a,b){ea(a,"width",b+"%")},Uc=function(a,b){ea(a,"height",b+"px")},Yj=function(a){return Ja(a,"height").getOrThunk(function(){if(hg()){var b=a.dom.getBoundingClientRect().height;
 if("border-box"!==Da(a,"box-sizing")){var c=Qa(a,"padding-top",0),d=Qa(a,"padding-bottom",0),e=Qa(a,"border-top-width",0),f=Qa(a,"border-bottom-width",0);b=b-c-d-(e+f)}}else b=Qa(a,"height",Pc(a));return b+"px"})},Zj=function(a,b,c,d){var e=N(a).map(function(f){f=c(f);return Math.floor(b/100*f)}).getOr(b);d(a,e);return e},pb=function(a){return Ja(a,"width").fold(function(){return k.from(ha(a,"width"))},function(b){return k.some(b)})},ak=function(a,b){return pb(a).fold(function(){return Ba(a)/b.pixelWidth()*
 100},function(c){c=Tc.exec(c);c=null!==c?parseFloat(c[1]):je(a)/b.pixelWidth()*100;return c})},kg=function(a,b){return pb(a).fold(function(){return je(a)},function(c){var d=ke.exec(c);null!==d?c=parseInt(d[1],10):(c=Tc.exec(c),c=null!==c?parseFloat(c[1])/100*b.pixelWidth():je(a));return c})},lg=function(a){var b;if(b=Yj(a)){var c=parseInt(b,10);b=Gc(b,"%")&&"table"!==L(a)?Zj(a,c,Pc,Uc):c}else b=Pc(a);a=La(a,"rowspan",1);return b/a},bk=function(a){return pb(a).bind(function(b){return Xj(b,["fixed",
 "relative","empty"])})},mg=function(a){var b=k.from(a.dom.offsetParent).map(u.fromDom).getOr(If(Kb(a)));return Ba(a)/Ba(b)*100+"%"},ck=w(Tc),dk=w(ke),ng=Gf("col"),og=function(a,b,c){return Ja(a,b).fold(function(){return c(a)+"px"},function(d){return d})},ek=function(a,b){return og(a,"width",function(c){return ng(c)?Ba(c):kg(c,b)})},fk=function(a){return og(a,"height",lg)},gk=function(a){return z(G.justColumns(a),function(b){return k.from(b.element)})},hk=function(a){return!ng(a)||Ja(a,"width").isSome()},
 le=function(a,b,c,d,e,f){return a.filter(d).fold(function(){return f(Rj(c,b))},function(g){return e(g)})},me=function(a,b,c,d,e){var f=ee(a,function(l){return Ja(l,"width").isSome()});a=G.hasColumns(a)?gk(a):f;var g=[k.some(Sc.edge(b))].concat(z(Sc.positions(f,b),function(l){return l.map(function(n){return n.x})})),h=Oa(nj);return z(a,function(l,n){return le(l,n,g,h,function(p){if(hk(p))return c(p,e);p=Qj(f[n],ca);return le(p,n,g,h,function(m){return d(k.some(Ba(m)))},d)},d)})},pg=function(a){return a.map(function(b){return b+
 "px"}).getOr("")},ik=function(a,b,c){return me(a,b,ak,function(d){return d.fold(function(){return c.minCellWidth()},function(e){return e/c.pixelWidth()*100})},c)},ne=function(a,b,c){return me(a,b,kg,function(d){return d.getOrThunk(c.minCellWidth)},c)},qg=function(a,b,c,d,e){a=bg(a);var f=[k.some(c.edge(b))].concat(z(c.positions(a,b),function(g){return g.map(function(h){return h.y})}));return z(a,function(g,h){return le(g,h,f,Oa(oj),d,e)})},jk=function(a,b,c){return qg(a,b,c,lg,function(d){return d.getOrThunk(Xd)})},
 Aa=function(a){var b=a;return{get:function(){return b},set:function(c){b=c}}},rg=function(a){var b=function(){return Ba(a)},c=w(0);return{width:b,pixelWidth:b,getWidths:function(d,e){return ne(d,a,e)},getCellDelta:c,singleColumnWidth:w([0]),minCellWidth:c,setElementWidth:C,adjustTableWidth:C,isRelative:!0,label:"none"}},sg=function(a,b){var c=Aa(parseFloat(a)),d=Aa(Ba(b));return{width:c.get,pixelWidth:d.get,getWidths:function(e,f){return ik(e,b,f)},getCellDelta:function(e){return e/d.get()*100},singleColumnWidth:function(e,
 f){return[100-e]},minCellWidth:function(){return fc()/d.get()*100},setElementWidth:jg,adjustTableWidth:function(e){var f=c.get();e=f+e/100*f;jg(b,e);c.set(e);d.set(Ba(b))},isRelative:!0,label:"percent"}},oe=function(a,b){var c=Aa(a),d=c.get;return{width:d,pixelWidth:d,getWidths:function(e,f){return ne(e,b,f)},getCellDelta:ca,singleColumnWidth:function(e,f){return[Math.max(fc(),e+f)-e]},minCellWidth:fc,setElementWidth:ig,adjustTableWidth:function(e){e=d()+e;ig(b,e);c.set(e)},isRelative:!1,label:"pixel"}},
 Nb={getTableSize:function(a){return pb(a).fold(function(){return rg(a)},function(b){var c=ck().exec(b);null!==c?b=sg(c[1],a):(b=dk().exec(b),null!==b?(b=parseInt(b[1],10),b=oe(b,a)):(b=Ba(a),b=oe(b,a)));return b})},pixelSize:oe,percentageSize:sg,noneSize:rg},kk=function(a,b){var c=a.grid.rows,d=a.grid.columns,e=0,f=0,g=[],h=[];sa(a.access,function(l){g.push(l);if(b(l)){h.push(l);var n=l.row,p=n+l.rowspan-1,m=l.column;l=m+l.colspan-1;n<c?c=n:p>e&&(e=p);m<d?d=m:l>f&&(f=l)}});return{minRow:c,minCol:d,
 maxRow:e,maxCol:f,allCells:g,selectedCells:h}},lk=function(a,b,c,d){for(var e=b.grid.columns,f=b.grid.rows,g=0;g<f;g++)for(var h=!1,l=0;l<e;l++)if(!(g<c.minRow||g>c.maxRow||l<c.minCol||l>c.maxCol))if(G.getAt(b,g,l).filter(d).isNone()){var n=h,p=a[g].element,m=u.fromTag("td");U(m,u.fromTag("br"));(n?U:Hd)(p,m)}else h=!0},mk=function(a,b,c,d){sa(c.columns,function(e){(e.column<b.minCol||e.column>b.maxCol)&&ua(e.element)});c=Y(nb(a,"tr",x),function(e){return 0===e.dom.childElementCount});F(c,ua);b.minCol!==
 b.maxCol&&b.minRow!==b.maxRow||F(nb(a,"th,td",x),function(e){T(e,"rowspan");T(e,"colspan")});T(a,"data-snooker-locked-cols");T(a,"data-snooker-col-series");Nb.getTableSize(a).adjustTableWidth(d)},nk=function(a,b,c,d){if(0===d.minCol&&b.grid.columns===d.maxCol+1)return 0;a=ne(b,a,c);b=ma(a,function(e,f){return e+f},0);d=ma(a.slice(d.minCol,d.maxCol+1),function(e,f){return e+f},0)/b*c.pixelWidth()-c.pixelWidth();return c.getCellDelta(d)},ok=function(a,b){var c=function(p){return Ga(p.element,b)},d=
 ob(a,!0),e=Pf(d),f=Nb.getTableSize(a),g=G.generate(e),h=kk(g,c),l="th:not("+b+"),td:not("+b+")",n=nb(d,"th,td",function(p){return Ga(p,l)});F(n,ua);lk(e,g,h,c);c=G.fromTable(a);a=nk(a,c,f,h);mk(d,h,g,a);return d},qb=function(a){return"img"===L(a)?1:Mc.getOption(a).fold(function(){return ra(a).length},function(b){return b.length})},pk=function(a){return Mc.getOption(a).filter(function(b){return 0!==b.trim().length||-1<b.indexOf("\u00a0")}).isSome()},qk=["img","br"],tg=function(a){return pk(a)||R(qk,
 L(a))},Vc=function(a){return lj(a,tg)},pe=function(a){return rk(a,tg)},rk=function(a,b){var c=function(d){d=ra(d);for(var e=d.length-1;0<=e;e--){var f=d[e];if(b(f))return k.some(f);f=c(f);if(f.isSome())return f}return k.none()};return c(a)},sk={scope:["row","col"]},qe=function(){var a=u.fromTag("td");U(a,u.fromTag("br"));return a},tk=function(){return u.fromTag("col")},ug=function(){return u.fromTag("colgroup")},uk=function(a,b,c){var d=Oj(a,b);sa(c,function(e,f){null===e?T(d,f):fa(d,f,e)});return d},
 vk=function(a){return a},vg=function(a){return function(){return u.fromTag("tr",a.dom)}},wk=function(a,b,c){return Vc(a).map(function(d){var e=c.join(",");d=cc(d,e,function(f){return M(f,a)});return Ka(d,function(f,g){g=ob(g,!1);T(g,"contenteditable");U(f,g);return g},b)}).getOr(b)},xk=function(a,b){sa(sk,function(c,d){return k.from(ha(a,d)).filter(function(e){return R(c,e)}).each(function(e){return fa(b,d,e)})})},Jd=function(a,b,c){var d=function(e,f){var g=e.element.dom,h=f.dom;Lb(g)&&Lb(h)&&(h.style.cssText=
 g.style.cssText);eb(f,"height");1!==e.colspan&&eb(f,"width")};return{col:function(e){var f=Kb(e.element);f=u.fromTag(L(e.element),f.dom);d(e,f);a(e.element,f);return f},colgroup:ug,row:vg(b),cell:function(e){var f=Kb(e.element);f=u.fromTag(L(e.element),f.dom);var g=c.getOr("strong em b i span font h1 h2 h3 h4 h5 h6 p div".split(" "));g=0<g.length?wk(e.element,f,g):f;U(g,u.fromTag("br"));d(e,f);xk(e.element,f);a(e.element,f);return f},replace:uk,gap:qe}},wg=function(a){return{col:tk,colgroup:ug,row:vg(a),
 cell:qe,replace:vk,gap:qe}},yk=function(a,b){b=(b||document).createElement("div");b.innerHTML=a;return ra(u.fromDom(b))},jb=function(a){return u.fromDom(a.getBody())},Kd=function(a){return function(b){return M(b,jb(a))}},Ra=function(a){return/^\d+(\.\d+)?$/.test(a)?a+"px":a},zb=function(a){T(a,"data-mce-style");var b=function(c){return T(c,"data-mce-style")};F(Mb(a),b);F(Yd(a),b)},xg=function(a,b){a=a.dom.getStyle(b,"width")||a.dom.getAttrib(b,"width");return k.from(a).filter(Oi)},yg=function(a){return/^(\d+(\.\d+)?)%$/.test(a)},
 W=function(a){return u.fromDom(a.selection.getStart())},Wc=function(a){return ce(a.get(),w([]),ca,Li)},zk=function(a){var b=function(d,e){return k.from(ha(d,e)).exists(function(f){return 1<parseInt(f,10)})},c=function(d){return b(d,"rowspan")||b(d,"colspan")};a=Wc(a);return 0<a.length&&lb(a,c)?k.some(a):k.none()},Ak=function(a,b,c){return ce(b.get(),k.none,function(d){return 1>=d.length?k.none():Ij(a,c.firstSelectedSelector,c.lastSelectedSelector).map(function(e){return{bounds:e,cells:d}})},k.none)},
 Xa={selected:"data-mce-selected",selectedSelector:"td[data-mce-selected],th[data-mce-selected]",firstSelected:"data-mce-first-selected",firstSelectedSelector:"td[data-mce-first-selected],th[data-mce-first-selected]",lastSelected:"data-mce-last-selected",lastSelectedSelector:"td[data-mce-last-selected],th[data-mce-last-selected]"},zg=function(a){return{element:a,mergable:k.none(),unmergable:k.none(),selection:[a]}},hc=function(a,b,c){return{element:c,mergable:Ak(b,a,Xa),unmergable:zk(a),selection:Wc(a)}},
 Bk=function(a){return N(a[0]).map(function(b){b=ok(b,"[data-mce-selected]");zb(b);return[b]})},Ck=function(a,b){return z(b,function(c){return a.selection.serializer.serialize(c.dom,{})}).join("")},Dk=function(a){return z(a,function(b){return b.dom.innerText}).join("")},Ek=function(a,b,c,d){a.on("BeforeGetContent",function(e){var f=function(g){e.preventDefault();Bk(g).each(function(h){e.content="text"===e.format?Dk(h):Ck(a,h)})};!0===e.selection&&ce(b.get(),C,f,C)});a.on("BeforeSetContent",function(e){!0===
 e.selection&&!0===e.paste&&k.from(a.dom.getParent(a.selection.getStart(),"th,td")).each(function(f){var g=u.fromDom(f);N(g).each(function(h){var l=Y(yk(e.content),function(p){return"meta"!==L(p)});if(1===l.length&&"table"===L(l[0])){e.preventDefault();var n=u.fromDom(a.getDoc());n=wg(n);c.pasteCells(h,{element:g,clipboard:l[0],generators:n}).each(function(p){a.selection.setRng(p.rng);a.focus();d.clear(h)})}})})})},Fk=$a.generate([{none:[]},{only:["index"]},{left:["index","next"]},{middle:["prev",
 "index","next"]},{right:["prev","index"]}]),Ob=I({},Fk),Gk=function(a,b){return 0===a.length?Ob.none():1===a.length?Ob.only(0):0===b?Ob.left(0,1):b===a.length-1?Ob.right(b-1,b):0<b&&b<a.length-1?Ob.middle(b-1,b,b+1):Ob.none()},Hk=function(a,b,c,d,e){var f=a.slice(0);a=Gk(a,b);b=w(z(f,w(0)));return a.fold(b,function(g){return d.singleColumnWidth(f[g],c)},function(g,h){return e.calcLeftEdgeDeltas(f,g,h,c,d.minCellWidth(),d.isRelative)},function(g,h,l){return e.calcMiddleDeltas(f,g,h,l,c,d.minCellWidth(),
 d.isRelative)},function(g,h){return e.calcRightEdgeDeltas(f,g,h,c,d.minCellWidth(),d.isRelative)})},Ag=function(a,b,c){for(var d=0;a<b;a++)d+=void 0!==c[a]?c[a]:0;return d},Ik=function(a,b){a=G.justCells(a);return z(a,function(c){var d=Ag(c.column,c.column+c.colspan,b);return{element:c.element,width:d,colspan:c.colspan}})},Jk=function(a,b){a=G.justColumns(a);return z(a,function(c,d){return{element:c.element,width:b[d],colspan:c.colspan}})},Kk=function(a,b){a=G.justCells(a);return z(a,function(c){var d=
 Ag(c.row,c.row+c.rowspan,b);return{element:c.element,height:d,rowspan:c.rowspan}})},Lk=function(a,b){return z(a.all,function(c,d){return{element:c.element,height:b[d]}})},Mk=function(a){return Ka(a,function(b,c){return b+c},0)},Nk=function(a,b){return G.hasColumns(a)?Jk(a,b):Ik(a,b)},re=function(a,b,c){a=Nk(a,b);F(a,function(d){c.setElementWidth(d.element,d.width)})},Bg=function(a,b,c,d,e){a=G.fromTable(a);var f=e.getCellDelta(b),g=e.getWidths(a,e);b=c===a.grid.columns-1;f=d.clampTableDelta(g,c,f,
 e.minCellWidth(),b);c=Hk(g,c,f,e,d);c=z(c,function(h,l){return h+g[l]});re(a,c,e);d.resizeTable(e.adjustTableWidth,f,b)},Ok=function(a,b,c,d){var e=G.fromTable(a);d=jk(e,a,d);d=z(d,function(g,h){return c===h?Math.max(b+g,Xd()):g});var f=Kk(e,d);e=Lk(e,d);F(e,function(g){Uc(g.element,g.height)});F(f,function(g){Uc(g.element,g.height)});e=Mk(d);Uc(a,e)},Cg=function(a){return function(b,c,d,e){return a(d)?(b=Math.abs(Math.max(e,b[c]-Math.abs(d))-b[c]),0<=d?b:-b):d}},Xc=Cg(function(a){return 0>a}),Pk=
 Cg(x),se=function(){var a=function(c,d,e,f){var g=(100+e)/100,h=Math.max(f,(c[d]+e)/g);return z(c,function(l,n){return(n===d?h:l/g)-l})},b=function(c,d,e,f,g,h){if(h)return a(c,d,f,g);f=Xc(c,d,f,g);e+=1;f=[f,0];return z(c.slice(0,d),w(0)).concat(f).concat(z(c.slice(e),w(0)))};return{resizeTable:function(c,d){return c(d)},clampTableDelta:Xc,calcLeftEdgeDeltas:b,calcMiddleDeltas:function(c,d,e,f,g,h,l){return b(c,e,f,g,h,l)},calcRightEdgeDeltas:function(c,d,e,f,g,h){if(h)return a(c,e,f,g);d=Xc(c,e,
 f,g);return z(c.slice(0,e),w(0)).concat([d])},calcRedestributedWidths:function(c,d,e,f){if(f){var g=(d+e)/d;c=z(c,function(h){return h/g});return{delta:100*g-100,newSizes:c}}return{delta:e,newSizes:c}}}},Yc=function(){var a=function(b,c,d,e,f){e=Pk(b,0<=e?d:c,e,f);d+=1;e=[e,-e];return z(b.slice(0,c),w(0)).concat(e).concat(z(b.slice(d),w(0)))};return{resizeTable:function(b,c,d){d&&b(c)},clampTableDelta:function(b,c,d,e,f){if(f){if(0<=d)return d;b=ma(b,function(g,h){return g+h-e},0);return Math.max(-b,
 d)}return Xc(b,c,d,e)},calcLeftEdgeDeltas:a,calcMiddleDeltas:function(b,c,d,e,f,g){return a(b,d,e,f,g)},calcRightEdgeDeltas:function(b,c,d,e,f,g){return g?z(b,w(0)):z(b,w(e/b.length))},calcRedestributedWidths:function(b,c,d,e){return{delta:0,newSizes:b}}}},te={only:function(a,b){var c=k.from(a.dom.documentElement).map(u.fromDom).getOr(a);return{parent:w(c),view:w(a),origin:w(ab(0,0)),isResizable:b}},detached:function(a,b,c){return{parent:w(b),view:w(a),origin:function(){return gc(b)},isResizable:c}},
 body:function(a,b,c){return{parent:w(b),view:w(a),origin:w(ab(0,0)),isResizable:c}}},ic=$a.generate([{invalid:["raw"]},{pixels:["value"]},{percent:["value"]}]),Dg=function(a,b,c){a=c.substring(0,c.length-a.length);var d=parseFloat(a);return a===d.toString()?b(d):ic.invalid(c)},Ab=I(I({},ic),{from:function(a){return Gc(a,"%")?Dg("%",ic.percent,a):Gc(a,"px")?Dg("px",ic.pixels,a):ic.invalid(a)}}),Qk=function(a,b){return z(a,function(c){return Ab.from(c).fold(function(){return c},function(d){return d/
 b*100+"%"},function(d){return d+"%"})})},Rk=function(a,b,c){var d=c/b;return z(a,function(e){return Ab.from(e).fold(function(){return e},function(f){return f*d+"px"},function(f){return f/100*c+"px"})})},Sk=function(a,b){a=a.fold(function(){return w("")},function(c){return w(c/b+"px")},function(){return w(100/b+"%")});return Ea(b,a)},Tk=function(a,b,c){return a.fold(function(){return b},function(d){return Rk(b,c,d)},function(d){return Qk(b,c)})},Eg=function(a,b,c){c=Ab.from(c);a=lb(a,function(d){return"0px"===
 d})?Sk(c,a.length):Tk(c,a,b);return Uk(a)},ue=function(a,b){return 0===a.length?b:Ka(a,function(c,d){return Ab.from(d).fold(w(0),ca,ca)+c},0)},Vk=function(a,b){return Ab.from(a).fold(w(a),function(c){return c+b+"px"},function(c){return c+b+"%"})},Uk=function(a){if(0===a.length)return a;a=Ka(a,function(c,d){var e=Ab.from(d).fold(function(){return{value:d,remainder:0}},function(f){var g=Math.floor(f);return{value:g+"px",remainder:f-g}},function(f){return{value:f+"%",remainder:0}});return{output:[e.value].concat(c.output),
 remainder:c.remainder+e.remainder}},{output:[],remainder:0});var b=a.output;return b.slice(0,b.length-1).concat([Vk(b[b.length-1],Math.round(a.remainder))])},Fg=Ab.from,Wk=function(a,b,c){F(b,function(d){var e=a.slice(d.column,d.colspan+d.column);e=ue(e,fc());ea(d.element,"width",e+c)})},Xk=function(a,b,c){F(b,function(d,e){e=ue([a[e]],fc());ea(d.element,"width",e+c)})},Yk=function(a,b,c,d){F(c,function(e){var f=a.slice(e.row,e.rowspan+e.row);f=ue(f,Xd());ea(e.element,"height",f+d)});F(b,function(e,
 f){ea(e.element,"height",a[f])})},Gg=function(a,b,c,d){var e=G.fromTable(a),f=e.all,g=G.justCells(e),h=G.justColumns(e);b.each(function(l){var n=Fg(l).fold(w("px"),w("px"),w("%")),p=Ba(a),m=me(e,a,ek,pg,d);p=Eg(m,p,l);G.hasColumns(e)?Xk(p,h,n):Wk(p,g,n);ea(a,"width",l)});c.each(function(l){var n=Fg(l).fold(w("px"),w("px"),w("%")),p=Pc(a),m=qg(e,a,Rc,fk,pg);p=Eg(m,p,l);Yk(p,f,g,n);ea(a,"height",l)})},Hg=function(a){return pb(a).exists(function(b){return Tc.test(b)})},Ig=function(a){return pb(a).exists(function(b){return ke.test(b)})},
 Ha=function(a){var b=[];return{bind:function(c){if(void 0===c)throw Error("Event bind error: undefined handler");b.push(c)},unbind:function(c){b=Y(b,function(d){return d!==c})},trigger:function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];var e={};F(a,function(f,g){e[f]=c[g]});F(b,function(f){f(e)})}}},Bb=function(a){var b=Df(a,function(c){return{bind:c.bind,unbind:c.unbind}});a=Df(a,function(c){return c.trigger});return{registry:b,trigger:a}},Zk=function(a,b){var c=null;return{cancel:function(){null!==
 c&&(clearTimeout(c),c=null)},throttle:function(){for(var d=[],e=0;e<arguments.length;e++)d[e]=arguments[e];null!==c&&clearTimeout(c);c=setTimeout(function(){a.apply(null,d);c=null},b)}}},$k=function(a,b){throw Error("All required keys ("+a.slice(0).sort().join(", ")+") were not specified. Specified keys were: "+b.slice(0).sort().join(", ")+".");},al=function(a,b){if(!pa(b))throw Error("The "+a+" fields must be an array. Was: "+b+".");F(b,function(c){if(!J(c))throw Error("The value "+c+" in the "+
 a+" fields was not a string.");})},bl=function(a){var b=a.slice(0).sort();Fa(b,function(c,d){return d<b.length-1&&c===b[d+1]}).each(function(c){throw Error("The field: "+c+" occurs more than once in the combined fields: ["+b.join(", ")+"].");})},ve=function(a,b){return cl(a,b,{validate:Ca,label:"function"})},cl=function(a,b,c){if(0===b.length)throw Error("You must specify at least one required field.");al("required",b);bl(b);return function(d){var e=wa(d);lb(b,function(g){return R(e,g)})||$k(b,e);
 a(b,e);var f=Y(b,function(g){return!c.validate(d[g],g)});if(0<f.length)throw Error("All values need to be of type: "+c.label+". Keys ("+f.slice(0).sort().join(", ")+") were not.");return d}},we=function(a,b){b=Y(b,function(c){return!R(a,c)});if(0<b.length)throw Error("Unsupported keys for object: "+b.slice(0).sort().join(", "));},dl=ve(we,["compare","extract","mutate","sink"]),el=ve(we,["element","start","stop","destroy"]),fl=ve(we,["forceDrop","drop","move","delayDrop"]),gl=function(){var a=k.none(),
 b=function(d,e){var f=a.map(function(g){return d.compare(g,e)});a=k.some(e);return f},c=Bb({move:Ha(["info"])});return{onEvent:function(d,e){e.extract(d).each(function(f){b(e,f).each(function(g){c.trigger.move(g)})})},reset:function(){a=k.none()},events:c.registry}},hl=function(){var a=Bb({move:Ha(["info"])});return{onEvent:C,reset:C,events:a.registry}},il=function(){var a=hl(),b=gl(),c=a;return{on:function(){c.reset();c=b},off:function(){c.reset();c=a},isOn:function(){return c===b},onEvent:function(d,
 e){c.onEvent(d,e)},events:b.events}},jl=function(a,b,c){var d=!1,e=Bb({start:Ha([]),stop:Ha([])}),f=il(),g=function(){n.stop();f.isOn()&&(f.off(),e.trigger.stop())},h=Zk(g,200);f.events.move.bind(function(p){b.mutate(a,p.info)});var l=function(p){return function(){for(var m=[],r=0;r<arguments.length;r++)m[r]=arguments[r];d&&p.apply(null,m)}},n=b.sink(fl({forceDrop:g,drop:l(g),move:l(function(p){h.cancel();f.onEvent(p,b)}),delayDrop:l(h.throttle)}),c);return{element:n.element,go:function(p){n.start(p);
 f.on();e.trigger.start()},on:function(){d=!0},off:function(){d=!1},destroy:function(){n.destroy()},events:e.registry}},Jg=function(a){var b=u.fromDom(gj(a).getOr(a.target)),c=function(){return a.stopPropagation()},d=function(){return a.preventDefault()},e=Ed(d,c);return{target:b,x:a.clientX,y:a.clientY,stop:c,prevent:d,kill:e,raw:a}},kl=function(a,b){return function(c){a(c)&&b(Jg(c))}},ll=function(a,b,c,d){a.dom.removeEventListener(b,c,d)},Pb=function(a,b,c){c=kl(x,c);a.dom.addEventListener(b,c,!1);
 return{unbind:Q(ll,a,b,c,!1)}},$b=Jg,xe=function(a,b){a=ha(a,b);return void 0===a||""===a?[]:a.split(" ")},ml=function(a,b,c){var d=Y(xe(a,b),function(e){return e!==c});0<d.length?fa(a,b,d.join(" ")):T(a,b);return!1},Zc=function(a){return void 0!==a.dom.classList},bb=function(a,b){Zc(a)?a.dom.classList.add(b):(b=xe(a,"class").concat([b]),fa(a,"class",b.join(" ")))},ye=function(a,b){return Zc(a)&&a.dom.classList.contains(b)},Kg=function(a){var b=a.replace(/\./g,"-");return{resolve:function(c){return b+
 "-"+c}}},Lg=Kg("ephox-dragster").resolve,nl=function(a){a=I({layerClass:Lg("blocker")},a);var b=u.fromTag("div");fa(b,"role","presentation");ec(b,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"});bb(b,Lg("blocker"));bb(b,a.layerClass);return{element:function(){return b},destroy:function(){ua(b)}}},ol=dl({compare:function(a,b){return ab(b.left-a.left,b.top-a.top)},extract:function(a){return k.some(ab(a.x,a.y))},sink:function(a,b){var c=nl(b),d=Pb(c.element(),"mousedown",a.forceDrop),
 e=Pb(c.element(),"mouseup",a.drop),f=Pb(c.element(),"mousemove",a.move),g=Pb(c.element(),"mouseout",a.delayDrop);return el({element:c.element,start:function(h){U(h,c.element())},stop:function(){ua(c.element())},destroy:function(){c.destroy();e.unbind();f.unbind();g.unbind();d.unbind()}})},mutate:function(a,b){a.mutate(b.left,b.top)}}),pl=function(a,b){void 0===b&&(b={});return jl(a,void 0!==b.mode?b.mode:ol,b)},ql=function(a){return"true"===ha(a,"contenteditable")},$c=Kg("ephox-snooker").resolve,
 rl=function(){var a=Bb({drag:Ha(["xDelta","yDelta"])});return{mutate:function(b,c){a.trigger.drag(b,c)},events:a.registry}},sl=function(){var a=Bb({drag:Ha(["xDelta","yDelta","target"])}),b=k.none(),c=rl();c.events.drag.bind(function(d){b.each(function(e){a.trigger.drag(d.xDelta,d.yDelta,e)})});return{assign:function(d){b=k.some(d)},get:function(){return b},mutate:c.mutate,events:a.registry}},ze=$c("resizer-bar"),Mg=$c("resizer-rows"),Ng=$c("resizer-cols"),tl=function(a,b){return na(a.all,function(c,
 d){return b(c.element)?[d]:[]})},ul=function(a,b){var c=[];Ea(a.grid.columns,function(d){G.getColumnAt(a,d).map(function(e){return e.element}).forall(b)&&c.push(d)});return Y(c,function(d){var e=G.filterItems(a,function(f){return f.column===d});return lb(e,function(f){return b(f.element)})})},Ae=function(a){a=Gd(a.parent(),"."+ze);F(a,ua)},Og=function(a,b,c){var d=a.origin();F(b,function(e){e.each(function(f){f=c(d,f);bb(f,ze);U(a.parent(),f)})})},vl=function(a,b,c,d){Og(a,b,function(e,f){var g=f.col;
 f=f.x-e.left;e=c.top-e.top;var h=u.fromTag("div");ec(h,{position:"absolute",left:f-3.5+"px",top:e+"px",height:d+"px",width:"7px"});Zb(h,{"data-column":g,role:"presentation"});bb(h,Ng);return h})},wl=function(a,b,c,d){Og(a,b,function(e,f){var g=f.row,h=c.left-e.left;e=f.y-e.top;f=u.fromTag("div");ec(f,{position:"absolute",left:h+"px",top:e-3.5+"px",height:"7px",width:d+"px"});Zb(f,{"data-row":g,role:"presentation"});bb(f,Mg);return f})},xl=function(a,b,c,d,e){var f=gc(c),g=b.isResizable;d=0<d.length?
 Rc.positions(d,c):[];var h=0<d.length?tl(a,g):[];d=Y(d,function(n,p){return la(h,function(m){return p===m})});wl(b,d,f,de(c));e=0<e.length?Sc.positions(e,c):[];var l=0<e.length?ul(a,g):[];a=Y(e,function(n,p){return la(l,function(m){return p===m})});vl(b,a,f,fe.getOuter(c))},ad=function(a,b){Ae(a);if(a.isResizable(b)){var c=G.fromTable(b),d=bg(c),e=ee(c);xl(c,a,b,d,e)}},Pg=function(a,b){a=Gd(a.parent(),"."+ze);F(a,b)},yl=function(a){Pg(a,function(b){ea(b,"display","none")})},zl=function(a){Pg(a,function(b){ea(b,
 "display","block")})},Al=$c("resizer-bar-dragging"),Bl=function(a){var b=sl(),c=pl(b,{}),d=k.none();b.events.drag.bind(function(m){k.from(ha(m.target,"data-row")).each(function(r){r=parseInt(Da(m.target,"top"),10);ea(m.target,"top",r+m.yDelta+"px")});k.from(ha(m.target,"data-column")).each(function(r){r=parseInt(Da(m.target,"left"),10);ea(m.target,"left",r+m.xDelta+"px")})});var e=function(m,r){var t=parseInt(Da(m,r),10);m=La(m,"data-initial-"+r,0);return t-m};c.events.stop.bind(function(){b.get().each(function(m){d.each(function(r){k.from(ha(m,
 "data-row")).each(function(t){var q=e(m,"top");T(m,"data-initial-top");p.trigger.adjustHeight(r,q,parseInt(t,10))});k.from(ha(m,"data-column")).each(function(t){var q=e(m,"left");T(m,"data-initial-left");p.trigger.adjustWidth(r,q,parseInt(t,10))});ad(a,r)})})});var f=function(m,r){p.trigger.startAdjust();b.assign(m);fa(m,"data-initial-"+r,parseInt(Da(m,r),10));bb(m,Al);ea(m,"opacity","0.2");c.go(a.parent())},g=Pb(a.parent(),"mousedown",function(m){ye(m.target,Mg)&&f(m.target,"top");ye(m.target,Ng)&&
 f(m.target,"left")}),h=function(m){return M(m,a.view())},l=function(m){return da(m,"table",h).filter(function(r){return da(r,"[contenteditable]",h).exists(ql)})},n=Pb(a.view(),"mouseover",function(m){l(m.target).fold(function(){bc(m.target)&&Ae(a)},function(r){d=k.some(r);ad(a,r)})}),p=Bb({adjustHeight:Ha(["table","delta","row"]),adjustWidth:Ha(["table","delta","column"]),startAdjust:Ha([])});return{destroy:function(){g.unbind();n.unbind();c.destroy();Ae(a)},refresh:function(m){ad(a,m)},on:c.on,off:c.off,
 hideBars:Q(yl,a),showBars:Q(zl,a),events:p.registry}},Cl={create:function(a,b,c){a=Bl(a);var d=Bb({beforeResize:Ha(["table","type"]),afterResize:Ha(["table","type"]),startDrag:Ha([])});a.events.adjustHeight.bind(function(e){var f=e.table;d.trigger.beforeResize(f,"row");var g=Rc.delta(e.delta,f);Ok(f,g,e.row,Rc);d.trigger.afterResize(f,"row")});a.events.startAdjust.bind(function(e){d.trigger.startDrag()});a.events.adjustWidth.bind(function(e){var f=e.table;d.trigger.beforeResize(f,"col");var g=Sc.delta(e.delta,
 f),h=c(f);Bg(f,g,e.column,b,h);d.trigger.afterResize(f,"col")});return{on:a.on,off:a.off,hideBars:a.hideBars,showBars:a.showBars,destroy:a.destroy,events:d.registry}}},Dl=function(a,b,c,d,e){a.fire("ObjectResized",{target:b,width:c,height:d,origin:e})},rb=function(a,b,c){a.fire("TableModified",I(I({},c),{table:b}))},Qg={structure:!1,style:!0},ia={structure:!0,style:!1},Be={"border-collapse":"collapse",width:"100%"},El=function(a){return jc(a)?(a=a.getBody().offsetWidth,I(I({},Be),{width:a+"px"})):
 bd(a)?Ib(Be,function(b,c){return"width"!==c}):Be},Fl={border:"1"},Ce=function(a){return a.getParam("table_sizing_mode","auto")},De=function(a){return a.getParam("table_default_attributes",Fl,"object")},Ee=function(a){return a.getParam("table_default_styles",El(a),"object")},Fe=function(a){return a.getParam("table_cell_advtab",!0,"boolean")},Ge=function(a){return a.getParam("table_row_advtab",!0,"boolean")},Cb=function(a){return a.getParam("table_advtab",!0,"boolean")},kc=function(a){return a.getParam("table_style_by_css",
 !1,"boolean")},cd=function(a){return"relative"===Ce(a)||!0===a.getParam("table_responsive_width")},jc=function(a){return"fixed"===Ce(a)||!1===a.getParam("table_responsive_width")},bd=function(a){return"responsive"===Ce(a)},Rg=function(a){a=a.getParam("table_header_type","section","string");return R(["section","cells","sectionCells","auto"],a)?a:"section"},dd=function(a){var b=a.getParam("table_column_resizing","preservetable","string");return Fa(["preservetable","resizetable"],function(c){return c===
 b}).getOr("preservetable")},He=function(a){return"preservetable"===dd(a)},sf=function(a){a=a.getParam("table_clone_elements");return J(a)?k.some(a.split(/[ ,]/)):Array.isArray(a)?k.some(a):k.none()},Gl=function(a){a=a.getParam("object_resizing",!0);return J(a)?"table"===a:a},ed=function(a,b){return cd(a)?(a=xg(a,b.dom).filter(yg).getOrThunk(function(){return mg(b)}),Nb.percentageSize(a,b)):jc(a)?Nb.pixelSize(Ba(b),b):Nb.getTableSize(b)},fd=function(a){T(a,"width")},lc=function(a,b){a=ed(a,b);var c=
 mg(b);Gg(b,k.some(c),k.none(),a);fd(b)},Ie=function(a,b){a=ed(a,b);var c=Ba(b)+"px";Gg(b,k.some(c),k.none(),a);fd(b)},Sg=function(a){eb(a,"width");var b=Yd(a);b=0<b.length?b:Mb(a);F(b,function(c){eb(c,"width");fd(c)});fd(a)},Hl=function(a){var b=G.fromTable(a);G.hasColumns(b)||F(Mb(a),function(c){var d=Da(c,"width");ea(c,"width",d);T(c,"width")})},Il=function(){var a=u.fromTag("div");ec(a,{position:"static",height:"0",width:"0",padding:"0",margin:"0",border:"0"});U(If(u.fromDom(document)),a);return a},
 Jl=function(a,b){return a.inline?te.body(jb(a),Il(),b):te.only(u.fromDom(a.getDoc()),b)},Tg=function(a){return"false"!==ha(a,"data-mce-resize")},Kl=function(a){var b=k.none(),c=k.none(),d=k.none(),e,f,g=function(h){return ed(a,h)};a.on("init",function(){var h=Jl(a,Tg);d=k.some(h);if(Gl(a)&&a.getParam("table_resize_bars",!0,"boolean")){var l=He(a)?Yc():se();h=Cl.create(h,l,g);h.on();h.events.startDrag.bind(function(n){b=k.some(a.selection.getRng())});h.events.beforeResize.bind(function(n){var p=n.table.dom,
 m=p.getBoundingClientRect().width,r=p.getBoundingClientRect().height;a.fire("ObjectResizeStart",{target:p,width:m,height:r,origin:"bar-"+n.type})});h.events.afterResize.bind(function(n){var p=n.table,m=p.dom;zb(p);b.each(function(r){a.selection.setRng(r);a.focus()});Dl(a,m,m.getBoundingClientRect().width,m.getBoundingClientRect().height,"bar-"+n.type);a.undoManager.add()});c=k.some(h)}});a.on("ObjectResizeStart",function(h){var l=h.target;if("TABLE"===l.nodeName){var n=u.fromDom(l);F(a.dom.select(".mce-clonedresizable"),
 function(p){a.dom.addClass(p,"mce-"+dd(a)+"-columns")});!Ig(n)&&jc(a)?Ie(a,n):!Hg(n)&&cd(a)&&lc(a,n);pb(n).isNone()&&Fc(h.origin,"bar-",0)&&lc(a,n);e=h.width;f=bd(a)?"":xg(a,l).getOr("")}});a.on("ObjectResized",function(h){var l=h.target;if("TABLE"===l.nodeName){l=u.fromDom(l);var n=h.origin;if(Fc(n,"corner-",0)){h=h.width;var p=Gc(n,"e");""===f&&lc(a,l);if(h!==e&&""!==f){ea(l,"width",f);n=He(a)?Yc():se();var m=g(l);p=He(a)||p?G.fromTable(l).grid.columns-1:0;Bg(l,h-e,p,n,m)}else yg(f)&&(n=parseFloat(f.replace("%",
 "")),ea(l,"width",h*n/e+"%"));/^(\d+(\.\d+)?)px$/.test(f)&&Hl(l)}zb(l);rb(a,l.dom,Qg)}});a.on("SwitchMode",function(){c.each(function(h){a.mode.isReadOnly()?h.hideBars():h.showBars()})});return{lazyResize:function(){return c},lazyWire:function(){return d.getOr(te.only(u.fromDom(a.getBody()),Tg))},destroy:function(){c.each(function(h){h.destroy()});d.each(function(h){a.inline&&ua(h.parent())})}}},mc=function(a,b){return{element:a,offset:b}},Ug=function(a,b,c){return a.property().isText(b)&&0===a.property().getText(b).trim().length||
 a.property().isComment(b)?c(b).bind(function(d){return Ug(a,d,c).orThunk(function(){return k.some(d)})}):k.none()},Vg=function(a,b){return a.property().isText(b)?a.property().getText(b).length:a.property().children(b).length},Wg=function(a,b){b=Ug(a,b,a.query().prevSibling).getOr(b);if(a.property().isText(b))return mc(b,Vg(a,b));var c=a.property().children(b);return 0<c.length?Wg(a,c[c.length-1]):mc(b,Vg(a,b))},Ll=Wg,Ml=ub(),Nl=function(a,b){1===La(a,"colspan",1)&&bk(a).each(function(c){var d=c.value/
 2;ea(a,"width",d+c.unit);ea(b,"width",d+c.unit)})},nc=function(a,b,c,d){c===d?T(a,b):fa(a,b,c)},Xg=function(a,b,c){Rd(dc(a,b)).fold(function(){return Hd(a,c)},function(d){return fb(d,c)})},Ol=function(a,b){var c=Jf(a,b).getOrThunk(function(){var d=u.fromTag(b,Kb(a).dom);"thead"===b?Xg(a,"caption,colgroup",d):"colgroup"===b?Xg(a,"caption",d):U(a,d);return d});$d(c);return c},Pl=function(a,b){var c=[],d=[],e=function(m){return z(m,function(r){r.isNew&&c.push(r.element);var t=r.element;$d(t);F(r.cells,
 function(q){q.isNew&&d.push(q.element);nc(q.element,"colspan",q.colspan,1);nc(q.element,"rowspan",q.rowspan,1);U(t,q.element)});return t})},f=function(m){return na(m,function(r){return z(r.cells,function(t){nc(t.element,"span",t.colspan,1);return t.element})})},g=function(m,r){if(0<m.length){var t=Ol(a,r);m=("colgroup"===r?f:e)(m);gb(t,m)}else Jf(a,r).each(ua)},h=[],l=[],n=[],p=[];F(b,function(m){switch(m.section){case "thead":h.push(m);break;case "tbody":l.push(m);break;case "tfoot":n.push(m);break;
 case "colgroup":p.push(m)}});g(p,"colgroup");g(h,"thead");g(l,"tbody");g(n,"tfoot");return{newRows:c,newCells:d}},Ql=function(a){return z(a,function(b){var c=ob(b.element,!1);F(b.cells,function(d){var e=ob(d.element,!0);nc(e,"colspan",d.colspan,1);nc(e,"rowspan",d.rowspan,1);U(c,e)});return c})},Rl=function(a,b){return z(a,function(c){return c.cells[b]})},Yg=function(a,b){if(0===a.length)return 0;var c=a[0];return Dc(a,function(d){return!b(c.element,d.element)}).fold(function(){return a.length},function(d){return d})},
 Sl=function(a,b){var c=z(a,function(d){return z(d.cells,S)});return z(a,function(d,e){return{details:na(d.cells,function(f,g){if(!1===c[e][g]){var h=a[e].cells.slice(g);h=Yg(h,b);var l=Rl(a,g).slice(e);l=Yg(l,b);for(var n=e;n<e+l;n++)for(var p=g;p<g+h;p++)c[n][p]=!0;return[{element:f.element,rowspan:l,colspan:h,isNew:f.isNew}]}return[]}),section:d.section}})},oc=function(a,b,c){var d=[];if(G.hasColumns(a)){var e=z(G.justColumns(a),function(l){return xa(l.element,c,!1)});d.push(Jb(e,"colgroup"))}for(e=
 0;e<a.grid.rows;e++){for(var f=[],g=0;g<a.grid.columns;g++){var h=G.getAt(a,e,g).map(function(l){return xa(l.element,c,l.isLocked)}).getOrThunk(function(){return xa(b.gap(),!0,!1)});f.push(h)}f=Jb(f,a.all[e].section);d.push(f)}return d},Tl=function(a,b){var c=function(d){return mb(d,function(e){return Wa(e.element).map(function(f){var g=Wa(f).isNone();return xa(f,g,!1)})}).getOrThunk(function(){return xa(b.row(),!0,!1)})};return z(a,function(d){var e=c(d.details);return{element:e.element,cells:d.details,
 section:d.section,isNew:e.isNew}})},gd=function(a,b){a=Sl(a,M);return Tl(a,b)},hd=function(a,b){return mb(a.all,function(c){return Fa(c.cells,function(d){return M(b,d.element)})})},Je=function(a,b,c){b=z(b.selection,function(d){return Jc(["td","th"],d,void 0).bind(function(e){return hd(a,e)}).filter(c)});b=Yf(b);return 0<b.length?k.some(b):k.none()},Z=function(a,b,c,d,e){return function(f,g,h,l,n,p){var m=G.fromTable(g);return b(m,h).map(function(r){var t=oc(m,l,!1);t=a(t,r,M,e(l));var q=yb(t.grid),
 y=gd(t.grid,l);return{info:r,grid:y,cursor:t.cursor,lockedColumns:q}}).bind(function(r){var t=Pl(g,r.grid),q=k.from(n).getOrThunk(function(){return Nb.getTableSize(g)}),y=k.from(p).getOrThunk(Yc);c(g,r.grid,r.info,q,y);d(g);ad(f,g);T(g,"data-snooker-locked-cols");0<r.lockedColumns.length&&fa(g,"data-snooker-locked-cols",r.lockedColumns.join(","));return k.some({cursor:r.cursor,newRows:t.newRows,newCells:t.newCells})})}},Ke=function(a,b){return Jc(["td","th"],b.element,void 0).bind(function(c){return hd(a,
 c)})},Le=function(a,b){return Je(a,b,x).map(function(c){return{cells:c,generators:b.generators,clipboard:b.clipboard}})},Sa=function(a,b){return Je(a,b,x)},Zg=function(a,b){return Ke(a,b).filter(function(c){return!c.isLocked})},id=function(a,b){return Je(a,b,function(c){return!c.isLocked})},Ul=function(a,b){return hd(a,b).exists(function(c){return!c.isLocked})},$g=function(a,b){return lb(b,function(c){return Ul(a,c)})},ah=function(a,b){return b.mergable.filter(function(c){return $g(a,c.cells)})},
 bh=function(a,b){return b.unmergable.filter(function(c){return $g(a,c)})},ch=function(a,b,c,d){for(var e=oa(a).rows,f=!0,g=0;g<e.length;g++)for(var h=0;h<e[0].cells.length;h++){var l=e[g],n=l.cells[h],p=c(n.element,b);!0===p&&!1===f?(n=xa(d(),!0,n.isLocked),l.cells[h]=n):!0===p&&(f=!1)}return a},Vl=function(a,b){return ma(a,function(c,d){return la(c,function(e){return b(e.element,d.element)})?c:c.concat([d])},[])},Wl=function(a,b,c,d){0<b&&b<a[0].cells.length&&F(a,function(e){var f=e.cells[b];c(f.element,
 e.cells[b-1].element)&&(f=xa(d(),!0,f.isLocked),e.cells[b]=f)});return a},Xl=function(a,b,c,d){var e=oa(a).rows;if(0<b&&b<e.length){var f=Vl(e[b-1].cells,c);F(f,function(g){for(var h=k.none(),l=b;l<e.length;l++)for(var n=function(m){var r=e[l],t=r.cells[m];c(t.element,g.element)&&(h.isNone()&&(h=k.some(d())),h.each(function(q){q=xa(q,!0,t.isLocked);r.cells[m]=q}))},p=0;p<e[0].cells.length;p++)n(p)})}return a},Qb=function(a){return{is:function(b){return a===b},isValue:x,isError:S,getOr:w(a),getOrThunk:w(a),
 getOrDie:w(a),or:function(b){return Qb(a)},orThunk:function(b){return Qb(a)},fold:function(b,c){return c(a)},map:function(b){return Qb(b(a))},mapError:function(b){return Qb(a)},each:function(b){b(a)},bind:function(b){return b(a)},exists:function(b){return b(a)},forall:function(b){return b(a)},toOptional:function(){return k.some(a)}}},pc=function(a){return{is:S,isValue:S,isError:x,getOr:ca,getOrThunk:function(b){return b()},getOrDie:function(){return yc(String(a))()},or:function(b){return b},orThunk:function(b){return b()},
 fold:function(b,c){return b(a)},map:function(b){return pc(a)},mapError:function(b){return pc(b(a))},each:C,bind:function(b){return pc(a)},exists:S,forall:x,toOptional:k.none}},dh={value:Qb,error:pc,fromOption:function(a,b){return a.fold(function(){return pc(b)},Qb)}},Yl=function(a,b,c){if(a.row>=b.length||a.column>b[0].cells.length)return dh.error("invalid start address out of table bounds, row: "+a.row+", column: "+a.column);b=b.slice(a.row);a=b[0].cells.slice(a.column);return dh.value({rowDelta:b.length-
 c.length,colDelta:a.length-c[0].cells.length})},Me=function(a,b,c,d){var e="colgroup"===b.section?c.col:c.cell;return Ea(a,function(f){return xa(e(),!0,d(f))})},Zl=function(a,b,c,d){return a.concat(Ea(b,function(){var e=a[a.length-1],f=Me(e.cells.length,e,c,function(g){return xb.call(d,g.toString())});return Jb(f,e.section)}))},$l=function(a,b,c,d){return z(a,function(e){var f=Me(b,e,c,S);return Kc(e,d,f)})},am=function(a,b,c){return z(a,function(d){return ma(c,function(e,f){var g=Me(1,d,b,x)[0];
 return Kc(e,f,[g])},d)})},qc=function(a,b,c){var d=0>b.colDelta?$l:ca,e=0>b.rowDelta?Zl:ca,f=yb(a),g=a[0].cells.length;f=la(f,function(h){return h===g-1});a=d(a,Math.abs(b.colDelta),c,f?g-1:g);d=yb(a);return e(a,Math.abs(b.rowDelta),c,Pd(d,x))},bm=function(a,b,c){b=b[0].cells.length;var d=Ea(b-a.column,function(e){return e+a.column});b=Fa(d,function(e){return lb(c,function(f){return f!==e})}).getOr(b-1);return I(I({},a),{column:b})},eh=function(a,b,c){return Y(c,function(d){return d>=a.column&&d<=
 b[0].cells.length+a.column})},cm=function(a,b,c,d,e){var f=yb(b),g=bm(a,b,f),h=eh(g,c,f);return Yl(g,b,c).map(function(l){l=I(I({},l),{colDelta:l.colDelta-h.length});l=qc(b,l,d);var n=yb(l),p=eh(g,c,n);n=g.row;var m=g.column,r=n+c.length,t=m+c[0].cells.length+p.length;p=Pd(p,x);for(var q=n;q<r;q++)for(var y=0,H=m;H<t;H++)if(p[H])y++;else{var P=l,X=q,ja=H,V=Q(e,P[X].cells[ja].element),aa=P[X];1<P.length&&1<aa.cells.length&&(0<ja&&V(ya(aa,ja-1))||ja<aa.cells.length-1&&V(ya(aa,ja+1))||0<X&&V(ya(P[X-
 1],ja))||X<P.length-1&&V(ya(P[X+1],ja)))&&ch(l,ya(l[q],H),e,d.cell);P=c[q-n].cells[H-m-y];X=d.replace(P.element);P=xa(X,!0,P.isLocked);l[q].cells[H]=P}return l})},fh=function(a,b,c,d,e){Wl(b,a,e,d.cell);var f=qc(c,{rowDelta:c.length-b.length,colDelta:0},d);b=qc(b,{rowDelta:b.length-f.length,colDelta:0},d);return z(b,function(g,h){return Kc(g,a,f[h].cells)})},gh=function(a,b,c,d,e){Xl(b,a,e,d.cell);e=yb(b);var f={rowDelta:0,colDelta:b[0].cells.length-c[0].cells.length};e=I(I({},f),{colDelta:f.colDelta-
 e.length});var g=qc(b,e,d);f=oa(g);e=f.cols;f=f.rows;g=yb(g);b={rowDelta:0,colDelta:c[0].cells.length-b[0].cells.length};b=I(I({},b),{colDelta:b.colDelta+g.length});c=am(c,d,g);d=qc(c,b,d);return e.concat(f.slice(0,a)).concat(d).concat(f.slice(a,f.length))},hh=function(a,b,c,d,e){a=oa(a);var f=a.rows;a=a.cols;var g=f.slice(0,b),h=f.slice(b);c=Qf(f[c],function(l,n){return 0<b&&b<f.length&&d(ya(f[b-1],n),ya(f[b],n))?f[b].cells[n]:xa(e(l.element,d),!0,l.isLocked)});return a.concat(g).concat([c]).concat(h)},
 ih=function(a,b,c,d,e){return z(a,function(f){var g=0<b&&b<f.cells.length&&d(ya(f,b-1),ya(f,b));g="colgroup"!==f.section&&g?f.cells[b]:xa(e(f.cells[c].element,d),!0,!1);return Kc(f,b,[g])})},dm=function(a,b){return na(a,function(c){var d=Ka(b,function(e,f){return 0<=f&&f<e.length?e.slice(0,f).concat(e.slice(f+1)):e},c.cells);return 0<d.length?[Jb(d,c.section)]:[]})},jh=function(a,b,c,d){var e=function(f){return la(b,function(g){return c(f.element,g.element)})};return z(a,function(f){return Qf(f,function(g){return e(g)?
 xa(d(g.element,c),!0,g.isLocked):g})})},kh=function(a,b,c,d){return void 0!==ya(a[b],c)&&0<b&&d(ya(a[b-1],c),ya(a[b],c))},lh=function(a,b,c){return 0<b&&c(ya(a,b-1),ya(a,b))},jd=function(a,b,c,d){var e=oa(a).rows;e=na(e,function(f,g){return kh(a,g,b,c)||lh(f,b,c)?[]:[f.cells[b]]});return jh(a,e,c,d)},kd=function(a,b,c,d){var e=oa(a).rows,f=e[b],g=na(f.cells,function(h,l){return kh(e,b,l,c)||lh(f,l,c)?[]:[h]});return jh(a,g,c,d)},Rb=function(a){return ma(a,function(b,c){return la(b,function(d){return d.column===
 c.column})?b:b.concat([c])},[]).sort(function(b,c){return b.column-c.column})},em=function(a){var b=La(a,"colspan",1),c=La(a,"rowspan",1);return{element:a,colspan:b,rowspan:c}},mh=function(a){return k.from(ha(a,"scope")).map(function(b){return b.substr(0,3)})},ba={modification:function(a,b){void 0===b&&(b=em);var c=Aa(k.none()),d=function(f){a:{var g=b(f);switch(L(g.element)){case "col":g=a.col(g);break a;default:g=a.cell(g)}}c.get().isNone()&&c.set(k.some(g));e=k.some({item:f,replacement:g});return g},
 e=k.none();return{getOrInit:function(f,g){return e.fold(function(){return d(f)},function(h){return g(f,h.item)?h.replacement:d(f)})},cursor:c.get}},transform:function(a,b){return function(c){var d=Aa(k.none()),e=[],f=function(h,l){return Fa(e,function(n){return l(n.item,h)})},g=function(h){var l=c.replace(h,b,{scope:a});e.push({item:h,sub:l});d.get().isNone()&&d.set(k.some(l));return l};return{replaceOrInit:function(h,l){return"col"===L(h)?h:f(h,l).fold(function(){return g(h)},function(n){return l(h,
 n.item)?n.sub:g(h)})},cursor:d.get}}},merging:function(a){var b=Aa(k.none());return{unmerge:function(c){b.get().isNone()&&b.set(k.some(c));var d=mh(c);d.each(function(e){return fa(c,"scope",e)});return function(){var e=a.cell({element:c,colspan:1,rowspan:1});eb(e,"width");eb(c,"width");d.each(function(f){return fa(e,"scope",f)});return e}},merge:function(c){eb(c[0],"width");(function(){var d=Yf(z(c,mh));if(0===d.length)return k.none();var e=d[0],f=["row","col"];return la(d,function(g){return g!==
 e&&R(f,g)})?k.none():k.from(e)})().fold(function(){return T(c[0],"scope")},function(d){return fa(c[0],"scope",d+"group")});return w(c[0])},cursor:b.get}}},fm="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".split(" "),Ne=ub(),Oe=function(a){a=Ne.property().name(a);return R(fm,a)},gm=function(a){a=Ne.property().name(a);return R(["ol","ul"],a)},hm=function(a){var b=function(f){return lb(f,function(g){return"br"===
 L(g)||hb(g)&&0===Cc(g).trim().length})},c=function(f){return Bc(f).map(function(g){return Oe(g)?!0:R(["br","img","hr","input"],Ne.property().name(g))?"img"===L(g)?!1:!0:!1}).getOr(!1)},d=function(f){return pe(f).bind(function(g){var h=c(g);return Wa(g).map(function(l){var n;(n=!0===h)||(n="li"===L(l)||Yb(l,gm).isSome());return n||"br"===L(g)||Oe(l)&&!M(f,l)?[]:[u.fromTag("br")]})}).getOr([])},e=function(){var f=na(a,function(g){var h=ra(g);return b(h)?[]:h.concat(d(g))});return 0===f.length?[u.fromTag("br")]:
 f}();$d(a[0]);gb(a[0],e)},nh=function(a){0===Mb(a).length&&ua(a)},Ma=function(a,b){return{grid:a,cursor:b}},Db=function(a,b,c){var d=oa(a).rows;return Pe(d,b,c).orThunk(function(){return Pe(d,0,0)})},Pe=function(a,b,c){return k.from(a[b]).bind(function(d){return k.from(d.cells[c]).bind(function(e){return k.from(e.element)})})},Ia=function(a,b,c){var d=oa(a).rows;return Ma(a,Pe(d,b,c))},rc=function(a){return ma(a,function(b,c){return la(b,function(d){return d.row===c.row})?b:b.concat([c])},[]).sort(function(b,
 c){return b.row-c.row})},ld=function(a,b,c){a=qj(a,c.section);a=G.generate(a);return oc(a,b,!0)},oh=function(a,b){b=Y(a,b);return 0===b.length?k.some("td"):b.length===a.length?k.some("th"):k.none()},Qe=function(a,b,c,d){a=G.generate(b);b=d.getWidths(a,d);re(a,b,d)},Re=function(a,b,c,d,e){a=G.generate(b);b=d.getWidths(a,d);var f=d.pixelWidth();c=e.calcRedestributedWidths(b,f,c.pixelDelta,d.isRelative);e=c.delta;re(a,c.newSizes,d);d.adjustTableWidth(e)},ph=function(a,b){return la(b,function(c){return 0===
 c.column&&c.isLocked})},qh=function(a,b){return la(b,function(c){return c.column+c.colspan>=a.grid.columns&&c.isLocked})},rh=function(a,b){var c=ee(a);a=Rb(b);return ma(a,function(d,e){e=c[e.column].map(de).getOr(0);return d+e},0)},sh=function(a){return function(b,c){return Sa(b,c).filter(function(d){return!(a?ph:qh)(b,d)}).map(function(d){return{details:d,pixelDelta:rh(b,d)}})}},th=function(a){return function(b,c){return Le(b,c).filter(function(d){return!(a?ph:qh)(b,d.cells)})}},im=Z(function(a,
 b,c,d){var e=b[0].row,f=rc(b);a=Ka(f,function(g,h){return{grid:hh(g.grid,e,h.row+g.delta,c,d.getOrInit),delta:g.delta+1}},{grid:a,delta:0}).grid;return Ia(a,e,b[0].column)},Sa,C,C,ba.modification),jm=Z(function(a,b,c,d){var e=rc(b),f=e[e.length-1],g=f.row+f.rowspan;a=Ka(e,function(h,l){return hh(h,g,l.row,c,d.getOrInit)},a);return Ia(a,g,b[0].column)},Sa,C,C,ba.modification),km=Z(function(a,b,c,d){b=b.details;var e=Rb(b),f=e[0].column;a=Ka(e,function(g,h){return{grid:ih(g.grid,f,h.column+g.delta,
 c,d.getOrInit),delta:g.delta+1}},{grid:a,delta:0}).grid;return Ia(a,b[0].row,f)},sh(!0),Re,C,ba.modification),lm=Z(function(a,b,c,d){b=b.details;var e=b[b.length-1],f=e.column+e.colspan;e=Rb(b);a=Ka(e,function(g,h){return ih(g,f,h.column,c,d.getOrInit)},a);return Ia(a,b[0].row,f)},sh(!1),Re,C,ba.modification),mm=Z(function(a,b,c,d){b=Rb(b.details);a=dm(a,z(b,function(e){return e.column}));b=Db(a,b[0].row,b[0].column);return Ma(a,b)},function(a,b){return id(a,b).map(function(c){return{details:c,pixelDelta:-rh(a,
 c)}})},Re,nh,ba.modification),nm=Z(function(a,b,c,d){d=rc(b);c=d[0].row;d=d[d.length-1].row;a=oa(a);var e=a.rows;a=a.cols.concat(e.slice(0,c)).concat(e.slice(d+1));b=Db(a,b[0].row,b[0].column);return Ma(a,b)},Sa,C,nh,ba.modification);Z(function(a,b,c,d){a=jd(a,b.column,c,d.replaceOrInit);return Ia(a,b.row,b.column)},Zg,C,C,ba.transform("row","th"));var om=Z(function(a,b,c,d){var e=Rb(b);a=ma(e,function(f,g){return jd(f,g.column,c,d.replaceOrInit)},a);return Ia(a,b[0].row,b[0].column)},id,C,C,ba.transform("row",
 "th"));Z(function(a,b,c,d){a=jd(a,b.column,c,d.replaceOrInit);return Ia(a,b.row,b.column)},Zg,C,C,ba.transform(null,"td"));var pm=Z(function(a,b,c,d){var e=Rb(b);a=ma(e,function(f,g){return jd(f,g.column,c,d.replaceOrInit)},a);return Ia(a,b[0].row,b[0].column)},id,C,C,ba.transform(null,"td"));Z(function(a,b,c,d){a=kd(a,b.row,c,d.replaceOrInit);return Ia(a,b.row,b.column)},Ke,C,C,ba.transform("col","th"));Z(function(a,b,c,d){var e=rc(b);a=ma(e,function(f,g){return kd(f,g.row,c,d.replaceOrInit)},a);
 return Ia(a,b[0].row,b[0].column)},Sa,C,C,ba.transform("col","th"));Z(function(a,b,c,d){a=kd(a,b.row,c,d.replaceOrInit);return Ia(a,b.row,b.column)},Ke,C,C,ba.transform(null,"td"));Z(function(a,b,c,d){var e=rc(b);a=ma(e,function(f,g){return kd(f,g.row,c,d.replaceOrInit)},a);return Ia(a,b[0].row,b[0].column)},Sa,C,C,ba.transform(null,"td"));var qm=Z(function(a,b,c,d){c=b.cells;hm(c);b=b.bounds;d=d.merge(c);var e=oa(a).rows;if(0!==e.length)for(var f=b.startRow;f<=b.finishRow;f++)for(var g=b.startCol;g<=
 b.finishCol;g++){var h=e[f],l=h.cells[g].isLocked;l=xa(d(),!1,l);h.cells[g]=l}return Ma(a,k.from(c[0]))},ah,Qe,C,ba.merging),rm=Z(function(a,b,c,d){a=Ka(b,function(e,f){return ch(e,f,c,d.unmerge(f))},a);return Ma(a,k.from(b[0]))},bh,Qe,C,ba.merging),sm=Z(function(a,b,c,d){d=function(e,f){e=G.fromTable(e);return oc(e,f,!0)}(b.clipboard,b.generators);return cm({row:b.row,column:b.column},a,d,b.generators,c).fold(function(){return Ma(a,k.some(b.element))},function(e){var f=Db(e,b.row,b.column);return Ma(e,
 f)})},function(a,b){return Jc(["td","th"],b.element,void 0).bind(function(c){return hd(a,c).map(function(d){return I(I({},d),{generators:b.generators,clipboard:b.clipboard})})})},Qe,C,ba.modification),tm=Z(function(a,b,c,d){var e=oa(a).rows;d=b.cells[0].column;e=ld(b.clipboard,b.generators,e[b.cells[0].row]);a=fh(d,a,e,b.generators,c);b=Db(a,b.cells[0].row,b.cells[0].column);return Ma(a,b)},th(!0),C,C,ba.modification),um=Z(function(a,b,c,d){var e=oa(a).rows;d=b.cells[b.cells.length-1].column+b.cells[b.cells.length-
 1].colspan;e=ld(b.clipboard,b.generators,e[b.cells[0].row]);a=fh(d,a,e,b.generators,c);b=Db(a,b.cells[0].row,b.cells[0].column);return Ma(a,b)},th(!1),C,C,ba.modification),vm=Z(function(a,b,c,d){var e=oa(a).rows;d=b.cells[0].row;e=ld(b.clipboard,b.generators,e[d]);a=gh(d,a,e,b.generators,c);b=Db(a,b.cells[0].row,b.cells[0].column);return Ma(a,b)},Le,C,C,ba.modification),wm=Z(function(a,b,c,d){var e=oa(a).rows;d=b.cells[b.cells.length-1].row+b.cells[b.cells.length-1].rowspan;e=ld(b.clipboard,b.generators,
 e[b.cells[0].row]);a=gh(d,a,e,b.generators,c);b=Db(a,b.cells[0].row,b.cells[0].column);return Ma(a,b)},Le,C,C,ba.modification),xm=function(a,b){var c=G.fromTable(a);return Sa(c,b).bind(function(d){var e=d[d.length-1],f=d[0].column,g=e.column+e.colspan;d=vf(z(c.all,function(h){return Y(h.cells,function(l){return l.column>=f&&l.column<g})}));return oh(d,function(h){return"th"===L(h.element)})}).getOr("")},ym=function(a){return"thead"===a?"header":"tfoot"===a?"footer":"body"},uh=function(a,b){a="thead"===
 b.parentNode.nodeName.toLowerCase();b=!la(b.cells,function(c){return"th"!==c.nodeName.toLowerCase()});return a||b?k.some({thead:a,ths:b}):k.none()},vh=function(a,b){return ym(uh(a,b).fold(function(){return b.parentNode.nodeName.toLowerCase()},function(c){return"thead"}))},wh=function(a,b,c){var d=a.getParent(b,"table"),e=b.parentNode,f=e.nodeName.toLowerCase();if(c!==f){var g=a.select(c,d)[0];if(!g){g=a.create(c);var h=d.firstChild;"thead"===c?Rd(dc(u.fromDom(d),"caption,colgroup")).fold(function(){return d.insertBefore(g,
 h)},function(l){return a.insertAfter(g,l.dom)}):d.appendChild(g)}"tbody"===c&&"thead"===f&&g.firstChild?g.insertBefore(b,g.firstChild):g.appendChild(b);e.hasChildNodes()||a.remove(e)}},xh=function(a,b,c,d){var e=a.dom;ta(c)||b.nodeName.toLowerCase()===c?a=b:(b=a.dom.rename(b,c),a.fire("newcell",{node:b}),a=b);Na(d)||e.setAttrib(a,"scope",d);return a},Se=function(a,b,c,d){return F(b,function(e){return xh(a,e,c,d)})},yh=function(a,b,c){var d=function(){var f=N(u.fromDom(b.cells[0])).map(function(g){return nb(g,
 "tr",x)}).getOr([]);return mb(f,function(g){return uh(a,g.dom)}).map(function(g){return g.thead&&g.ths?"sectionCells":g.thead?"section":"cells"}).getOr("section")},e=a.dom;"header"===c?(c=Rg(a),d="auto"===c?d():c,Se(a,b.cells,"section"===d?"td":"th","col"),wh(e,b,"cells"===d?"tbody":"thead")):(Se(a,b.cells,"td",null),wh(e,b,"footer"===c?"tfoot":"tbody"))},zm=function(a){return N(a).bind(function(b){return Oc(b,Xa.firstSelectedSelector)}).fold(function(){return a},function(b){return b[0]})},zh=function(a){return function(b){var c=
 L(b);b="col"===c||"colgroup"===c?zm(b):b;return da(b,a)}},Eb=zh("th,td"),sb=zh("th,td,caption"),md=function(a,b){return Eb(a).map(function(c){return Wc(b)}).getOr([])},Te=function(a,b){a=Eb(a);var c=a.bind(function(d){return N(d)}).map(function(d){return nb(d,"tr",x)});return Pj(a,c,function(d,e){return Y(e,function(f){return la(z(f.dom.cells,u.fromDom),function(g){return"1"===ha(g,b)||M(g,d)})})}).getOr([])},Em=function(a,b,c){var d=sf(a),e="resizetable"===dd(a)?C:Nl,f=function(V,aa,za,cb,sc){return function(nd,
 Am){zb(nd);var Bm=cb(),Ue=u.fromDom(a.getDoc());Ue=Jd(za,Ue,d);var Cm=ed(a,nd),Dm="resizetable"===dd(a)?se():Yc();return aa(nd)?V(Bm,nd,Am,Ue,Cm,Dm).bind(function(Ve){F(Ve.newRows,function(Ta){a.fire("newrow",{node:Ta.dom})});F(Ve.newCells,function(Ta){a.fire("newcell",{node:Ta.dom})});return Ve.cursor.map(function(Ta){Ta=Ll(Ml,Ta);var We=a.dom.createRng();We.setStart(Ta.element.dom,Ta.offset);We.setEnd(Ta.element.dom,Ta.offset);return{rng:We,effect:sc}})}):k.none()}},g=f(nm,function(V){return"table"===
 L(jb(a))===!1||1<G.fromTable(V).grid.rows},C,b,ia),h=f(mm,function(V){return"table"===L(jb(a))===!1||1<G.fromTable(V).grid.columns},C,b,ia),l=f(im,x,C,b,ia),n=f(jm,x,C,b,ia),p=f(km,x,e,b,ia);e=f(lm,x,e,b,ia);var m=f(qm,x,C,b,ia),r=f(rm,x,C,b,ia),t=f(tm,x,C,b,ia),q=f(um,x,C,b,ia),y=f(vm,x,C,b,ia),H=f(wm,x,C,b,ia),P=f(sm,x,C,b,ia),X=function(V,aa){return Pa(V,"type").filter(function(za){return R(aa,za)})},ja=f(om,x,C,b,ia);b=f(pm,x,C,b,ia);return{deleteRow:g,deleteColumn:h,insertRowsBefore:l,insertRowsAfter:n,
 insertColumnsBefore:p,insertColumnsAfter:e,mergeCells:m,unmergeCells:r,pasteColsBefore:t,pasteColsAfter:q,pasteRowsBefore:y,pasteRowsAfter:H,pasteCells:P,setTableCellType:function(V,aa){return X(aa,["td","th"]).each(function(za){var cb=z(md(W(V),c),function(sc){return sc.dom});Se(V,cb,za,null)})},setTableRowType:function(V,aa){return X(aa,["header","body","footer"]).each(function(za){z(Te(W(V),Xa.selected),function(cb){return yh(V,cb.dom,za)})})},makeColumnsHeader:ja,unmakeColumnsHeader:b,getTableRowType:function(V){var aa=
 Te(W(V),Xa.selected);if(0<aa.length){var za=z(aa,function(sc){return vh(V,sc.dom)});aa=R(za,"header");var cb=R(za,"footer");return aa||cb?(za=R(za,"body"),!aa||za||cb?aa||za||!cb?"":"footer":"header"):"body"}},getTableCellType:function(V){return oh(md(W(V),c),function(aa){return"th"===L(aa)}).getOr("")},getTableColType:xm}},Fm={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},colGroups:!1},Gm=function(a){var b=u.fromTag("colgroup");Ea(a,function(){return U(b,u.fromTag("col"))});
 return b},Ah=function(a,b,c,d){return Ea(a,function(e){for(var f=u.fromTag("tr"),g=0;g<b;g++){var h=e<c||g<d?u.fromTag("th"):u.fromTag("td");g<d&&fa(h,"scope","row");e<c&&fa(h,"scope","col");U(h,u.fromTag("br"));U(f,h)}return f})},Hm=function(a,b){a.selection.select(b.dom,!0);a.selection.collapse(!0)},Im=function(a,b){F(Za("tr",b),function(c){a.fire("newrow",{node:c.dom});F(Za("th,td",c),function(d){a.fire("newcell",{node:d.dom})})})},Bh=function(a,b,c,d,e){var f=Ee(a),g={styles:f,attributes:De(a),
 colGroups:a.getParam("table_use_colgroups",!1,"boolean")};a.undoManager.ignore(function(){var h=Rg(a),l=g;void 0===l&&(l=Fm);var n=u.fromTag("table"),p="cells"!==h;ec(n,l.styles);Zb(n,l.attributes);l.colGroups&&U(n,Gm(b));l=Math.min(c,e);if(p&&0<e){var m=u.fromTag("thead");U(n,m);h=Ah(e,b,"sectionCells"===h?l:0,d);gb(m,h)}h=u.fromTag("tbody");U(n,h);p=Ah(p?c-l:c,b,p?0:e,d);gb(h,p);fa(n,"data-mce-id","__mce");p=u.fromTag("div");n=u.fromDom(n.dom.cloneNode(!0));U(p,n);a.insertContent(p.dom.innerHTML);
 a.addVisual()});return mj(jb(a),'table[data-mce-id="__mce"]').map(function(h){if(jc(a))Ie(a,h);else if(bd(a))Sg(h);else{var l;(l=cd(a))||(l=f.width,l=J(l)&&-1!==l.indexOf("%"));l&&lc(a,h)}zb(h);T(h,"data-mce-id");Im(a,h);Hb("td,th",h).each(Q(Hm,a));return h.dom}).getOr(null)},Ch=function(a,b,c,d,e){void 0===d&&(d={});var f=function(g){return Va(g)&&0<g};if(f(b)&&f(c))return Bh(a,c,b,d.headerColumns||0,d.headerRows||0);console.error(e);return null},Dh=function(a){return function(){return a().fold(function(){return[]},
 function(b){return z(b,function(c){return c.dom})})}},Eh=function(a){return function(b){b=0<b.length?k.some(z(b,u.fromDom)):k.none();a(b)}},Jm=function(a){return function(b,c,d){void 0===d&&(d={});b=Ch(a,c,b,d,"Invalid values for insertTable - rows and columns values are required to insert a table.");a.undoManager.add();return b}},Km=function(a,b,c,d){return{insertTable:Jm(a),setClipboardRows:Eh(b.setRows),getClipboardRows:Dh(b.getRows),setClipboardCols:Eh(b.setColumns),getClipboardCols:Dh(b.getColumns),
 resizeHandler:c,selectionTargets:d}},Fh=function(a,b,c){var d=La(a,b,1);1===c||1>=d?T(a,b):fa(a,b,Math.min(c,d))},Lm=function(a,b,c){if(G.hasColumns(a)){a=Y(G.justColumns(a),function(e){return e.column>=b&&e.column<c});a=z(a,function(e){e=ob(e.element,!0);Fh(e,"span",c-b);return e});var d=u.fromTag("colgroup");gb(d,a);return[d]}return[]},Mm=function(a,b,c){return z(a.all,function(d){d=Y(d.cells,function(f){return f.column>=b&&f.column<c});d=z(d,function(f){f=ob(f.element,!0);Fh(f,"colspan",c-b);return f});
 var e=u.fromTag("tr");gb(e,d);return e})},Nm=function(a,b){var c=G.fromTable(a);return id(c,b).map(function(d){var e=d[d.length-1];d=d[0].column;var f=e.column+e.colspan;e=Lm(c,d,f);d=Mm(c,d,f);return xc(e,d)})},Om=function(a,b,c){var d=G.fromTable(a);return Sa(d,b).bind(function(e){var f=oc(d,c,!1);e=oa(f).rows.slice(e[0].row,e[e.length-1].row+e[e.length-1].rowspan);e=na(e,function(g){var h=Y(g.cells,function(l){return!l.isLocked});return 0<h.length?[I(I({},g),{cells:h})]:[]});e=gd(e,c);return 0<
 e.length?k.some(e):k.none()}).map(function(e){return Ql(e)})},Gh=tinymce.util.Tools.resolve("tinymce.util.Tools"),Xe=function(a,b,c){b=a.select("td,th",b);a:{for(var d=void 0,e=0;e<b.length;e++){var f=a.getStyle(b[e],c);"undefined"===typeof d&&(d=f);if(d!==f){a="";break a}}a=d}return a},Ye=function(a,b,c){c&&a.formatter.apply("align"+c,{},b)},Pm=function(a,b,c){c&&a.formatter.apply("valign"+c,{},b)},Ze=function(a,b){Gh.each(["left","center","right"],function(c){a.formatter.remove("align"+c,{},b)})},
 Qm=function(a,b){Gh.each(["top","middle","bottom"],function(c){a.formatter.remove("valign"+c,{},b)})},od=function(a,b){return function(c,d){return d.concat(z(c,function(e){var f=e.text||e.title;return Ff(e,"menu")?{text:f,items:od(e.menu)}:{text:f,value:e.value}}))}(a,b||[])},pd=function(a){return function(b){return Fc(b,"rgb",0)?a.toHex(b):b}},$e=function(a,b){b=u.fromDom(b);return{borderwidth:Ja(b,"border-width").getOr(""),borderstyle:Ja(b,"border-style").getOr(""),bordercolor:Ja(b,"border-color").map(pd(a)).getOr(""),
 backgroundcolor:Ja(b,"background-color").map(pd(a)).getOr("")}},Hh=function(a){var b=a[0];a=a.slice(1);F(a,function(c){F(wa(b),function(d){sa(c,function(e,f){var g=b[d];""!==g&&d===f&&g!==e&&(b[d]="")})})});return b},af=function(a){var b=[{name:"borderstyle",type:"listbox",label:"Border style",items:[{text:"Select...",value:""},{text:"Solid",value:"solid"},{text:"Dotted",value:"dotted"},{text:"Dashed",value:"dashed"},{text:"Double",value:"double"},{text:"Groove",value:"groove"},{text:"Ridge",value:"ridge"},
 {text:"Inset",value:"inset"},{text:"Outset",value:"outset"},{text:"None",value:"none"},{text:"Hidden",value:"hidden"}]},{name:"bordercolor",type:"colorinput",label:"Border color"},{name:"backgroundcolor",type:"colorinput",label:"Background color"}],c={name:"borderwidth",type:"input",label:"Border width"};return{title:"Advanced",name:"advanced",items:"cell"===a?[c].concat(b):b}},Ih=function(a,b,c,d){return Fa(a,function(e){return c.formatter.matchNode(d,b+e)}).getOr("")},bf=Q(Ih,["left","center","right"],
 "align"),Rm=Q(Ih,["top","middle","bottom"],"valign"),Sm=function(a,b){var c=Ee(a),d=De(a),e=function(f){return{borderstyle:Pa(c,"border-style").getOr(""),bordercolor:pd(f)(Pa(c,"border-color").getOr("")),backgroundcolor:pd(f)(Pa(c,"background-color").getOr(""))}};b=b?e(a.dom):{};return I(I(I(I(I(I({},{height:"",width:"100%",cellspacing:"",cellpadding:"",caption:!1,class:"",align:"",border:""}),c),d),b),function(){var f=c["border-width"];return kc(a)&&f?{border:f}:Pa(d,"border").fold(function(){return{}},
 function(g){return{border:g}})}()),function(){var f=Pa(c,"border-spacing").or(Pa(d,"cellspacing")).fold(function(){return{}},function(h){return{cellspacing:h}}),g=Pa(c,"border-padding").or(Pa(d,"cellpadding")).fold(function(){return{}},function(h){return{cellpadding:h}});return I(I({},f),g)}())},Tm=function(a,b,c,d){var e=a.dom;d=d.getOr(b);var f=function(g,h){return e.getStyle(g,h)||e.getAttrib(g,h)};return I({width:f(d,"width"),height:f(b,"height"),scope:e.getAttrib(b,"scope"),celltype:b.nodeName.toLowerCase(),
 class:e.getAttrib(b,"class",""),halign:bf(a,b),valign:Rm(a,b)},c?$e(e,b):{})},Jh=function(a){a=od(a.getParam("table_cell_class_list",[],"array"));return 0<a.length?k.some({name:"class",type:"listbox",label:"Class",items:a}):k.none()},Kh=[{name:"width",type:"input",label:"Width"},{name:"height",type:"input",label:"Height"},{name:"celltype",type:"listbox",label:"Cell type",items:[{text:"Cell",value:"td"},{text:"Header cell",value:"th"}]},{name:"scope",type:"listbox",label:"Scope",items:[{text:"None",
 value:""},{text:"Row",value:"row"},{text:"Column",value:"col"},{text:"Row group",value:"rowgroup"},{text:"Column group",value:"colgroup"}]},{name:"halign",type:"listbox",label:"H Align",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{name:"valign",type:"listbox",label:"V Align",items:[{text:"None",value:""},{text:"Top",value:"top"},{text:"Middle",value:"middle"},{text:"Bottom",value:"bottom"}]}],Lh=function(a){return function(b,
 c){var d=b.dom;return{setAttrib:function(e,f){a&&!f||d.setAttrib(c,e,f)},setStyle:function(e,f){a&&!f||d.setStyle(c,e,f)},setFormat:function(e,f){if(!a||f)""===f?b.formatter.remove(e,{value:null},c,!0):b.formatter.apply(e,{value:f},c)}}}},Fb={normal:Lh(!1),ifTruthy:Lh(!0)},Mh=function(a){return N(a[0]).map(function(b){var c=G.fromTable(b);b=G.justCells(c);b=Y(b,function(d){return la(a,function(e){return M(d.element,e)})});return z(b,function(d){return{element:d.element.dom,column:G.getColumnAt(c,
 d.column).map(function(e){return e.element.dom})}})})},Um=function(a,b,c){a.setAttrib("scope",c.scope);a.setAttrib("class",c.class);a.setStyle("height",Ra(c.height));b.setStyle("width",Ra(c.width))},Vm=function(a,b){a.setFormat("tablecellbackgroundcolor",b.backgroundcolor);a.setFormat("tablecellbordercolor",b.bordercolor);a.setFormat("tablecellborderstyle",b.borderstyle);a.setFormat("tablecellborderwidth",Ra(b.borderwidth))},Wm=function(a,b,c,d){var e=1===b.length,f=Ib(d,function(l,n){return c[n]!==
 l});if(0<wa(f).length&&1<=b.length){var g=N(b[0]);Mh(b).each(function(l){F(l,function(n){var p=xh(a,n.element,d.celltype),m=e?Fb.normal(a,p):Fb.ifTruthy(a,p);n=n.column.map(function(r){return e?Fb.normal(a,r):Fb.ifTruthy(a,r)}).getOr(m);Um(m,n,d);Fe(a)&&Vm(m,d);e&&(Ze(a,p),Qm(a,p));d.halign&&Ye(a,p,d.halign);d.valign&&Pm(a,p,d.valign)})});var h=0<wa(Ib(f,function(l,n){return"scope"!==n&&"celltype"!==n})).length;g.each(function(l){return rb(a,l.dom,{structure:xb.call(f,"celltype"),style:h})})}},Xm=
 function(a,b,c,d){var e=d.getData();d.close();a.undoManager.transact(function(){Wm(a,b,c,e);a.focus()})},Ym=function(a,b){b=Mh(b).map(function(c){return z(c,function(d){return Tm(a,d.element,Fe(a),d.column)})});return Hh(b.getOrDie())},Zm=function(a,b){b=md(W(a),b);if(0!==b.length){var c=Ym(a,b),d={type:"tabpanel",tabs:[{title:"General",name:"general",items:Kh.concat(Jh(a).toArray())},af("cell")]},e={type:"panel",items:[{type:"grid",columns:2,items:Kh.concat(Jh(a).toArray())}]};a.windowManager.open({title:"Cell Properties",
 size:"normal",body:Fe(a)?d:e,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:c,onSubmit:Q(Xm,a,b,c)})}},Nh=function(a){a=od(a.getParam("table_row_class_list",[],"array"));return 0<a.length?k.some({name:"class",type:"listbox",label:"Class",items:a}):k.none()},Oh=[{type:"listbox",name:"type",label:"Row type",items:[{text:"Header",value:"header"},{text:"Body",value:"body"},{text:"Footer",value:"footer"}]},{type:"listbox",name:"align",
 label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]},{label:"Height",name:"height",type:"input"}],$m=function(a,b,c,d){var e=1===b.length,f=Ib(d,function(l,n){return c[n]!==l});if(0<wa(f).length){F(b,function(l){d.type!==l.parentNode.nodeName.toLowerCase()&&yh(a,l,d.type);var n=e?Fb.normal(a,l):Fb.ifTruthy(a,l);n.setAttrib("class",d.class);n.setStyle("height",Ra(d.height));Ge(a)&&(n.setStyle("background-color",d.backgroundcolor),
 n.setStyle("border-color",d.bordercolor),n.setStyle("border-style",d.borderstyle));d.align!==c.align&&(Ze(a,l),Ye(a,l,d.align))});var g=xb.call(f,"type"),h=g?1<wa(f).length:!0;N(u.fromDom(b[0])).each(function(l){return rb(a,l.dom,{structure:g,style:h})})}},an=function(a,b,c,d){var e=d.getData();d.close();a.undoManager.transact(function(){$m(a,b,c,e);a.focus()})},bn=function(a){var b=Te(W(a),Xa.selected);if(0!==b.length){var c=z(b,function(f){f=f.dom;var g=Ge(a),h=a.dom;return I({height:h.getStyle(f,
 "height")||h.getAttrib(f,"height"),class:h.getAttrib(f,"class",""),type:vh(a,f),align:bf(a,f)},g?$e(h,f):{})});c=Hh(c);var d={type:"tabpanel",tabs:[{title:"General",name:"general",items:Oh.concat(Nh(a).toArray())},af("row")]},e={type:"panel",items:[{type:"grid",columns:2,items:Oh.concat(Nh(a).toArray())}]};a.windowManager.open({title:"Row Properties",size:"normal",body:Ge(a)?d:e,buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:c,
 onSubmit:Q(an,a,z(b,function(f){return f.dom}),c)})}},tf=tinymce.util.Tools.resolve("tinymce.Env"),cf=function(a,b,c,d){if("TD"===b.tagName||"TH"===b.tagName)J(c)?a.setStyle(b,c,d):a.setStyle(b,c);else if(b.children)for(var e=0;e<b.children.length;e++)cf(a,b.children[e],c,d)},cn=function(a,b,c,d){var e=a.dom,f,g=d.getData(),h=Ib(g,function(l,n){return c[n]!==l});d.close();""===g.class&&delete g.class;a.undoManager.transact(function(){if(!b){var l=parseInt(g.cols,10)||1,n=parseInt(g.rows,10)||1;b=
 Bh(a,l,n,0,0)}if(0<wa(h).length){l=b;n=a.dom;var p={},m={};p.class=g.class;m.height=Ra(g.height);if(n.getAttrib(l,"width")&&!kc(a)){var r=(r=g.width)?r.replace(/px$/,""):"";p.width=r}else m.width=Ra(g.width);kc(a)?(m["border-width"]=Ra(g.border),m["border-spacing"]=Ra(g.cellspacing)):(p.border=g.border,p.cellpadding=g.cellpadding,p.cellspacing=g.cellspacing);if(kc(a)&&l.children)for(r=0;r<l.children.length;r++)cf(n,l.children[r],{"border-width":Ra(g.border),padding:Ra(g.cellpadding)}),Cb(a)&&cf(n,
 l.children[r],{"border-color":g.bordercolor});Cb(a)&&(m["background-color"]=g.backgroundcolor,m["border-color"]=g.bordercolor,m["border-style"]=g.borderstyle);p.style=n.serializeStyle(I(I({},Ee(a)),m));n.setAttribs(l,I(I({},De(a)),p));(f=e.select("caption",b)[0])&&!g.caption&&e.remove(f);!f&&g.caption&&(f=e.create("caption"),f.innerHTML=tf.ie?"\u00a0":'<br data-mce-bogus="1"/>',b.insertBefore(f,b.firstChild));""===g.align?Ze(a,b):Ye(a,b,g.align)}a.focus();a.addVisual();0<wa(h).length&&(n=(l=xb.call(h,
 "caption"))?1<wa(h).length:!0,rb(a,b,{structure:l,style:n}))})},Ph=function(a,b){var c=a.dom,d,e=Sm(a,Cb(a));if(!1===b)if(d=c.getParent(a.selection.getStart(),"table")){e=d;c=Cb(a);var f=a.dom,g=I,h=f.getStyle(e,"width")||f.getAttrib(e,"width"),l=f.getStyle(e,"height")||f.getAttrib(e,"height"),n=f.getStyle(e,"border-spacing")||f.getAttrib(e,"cellspacing"),p=f.getAttrib(e,"cellpadding")||Xe(a.dom,e,"padding");var m=Ja(u.fromDom(e),"border-width");m=kc(a)&&m.isSome()?m.getOr(""):f.getAttrib(e,"border")||
 Xe(a.dom,e,"border-width")||Xe(a.dom,e,"border");e=g({width:h,height:l,cellspacing:n,cellpadding:p,border:m,caption:!!f.select("caption",e)[0],class:f.getAttrib(e,"class",""),align:bf(a,e)},c?$e(f,e):{})}else Cb(a)&&(e.borderstyle="",e.bordercolor="",e.backgroundcolor="");else e.cols="1",e.rows="1",Cb(a)&&(e.borderstyle="",e.bordercolor="",e.backgroundcolor="");c=od(a.getParam("table_class_list",[],"array"));0<c.length&&e.class&&(e.class=e.class.replace(/\s*mce\-item\-table\s*/g,""));b=b?[{type:"input",
 name:"cols",label:"Cols",inputMode:"numeric"},{type:"input",name:"rows",label:"Rows",inputMode:"numeric"}]:[];f=a.getParam("table_appearance_options",!0,"boolean")?[{type:"input",name:"cellspacing",label:"Cell spacing",inputMode:"numeric"},{type:"input",name:"cellpadding",label:"Cell padding",inputMode:"numeric"},{type:"input",name:"border",label:"Border width"},{type:"label",label:"Caption",items:[{type:"checkbox",name:"caption",label:"Show caption"}]}]:[];c=0<c.length?[{type:"listbox",name:"class",
 label:"Class",items:c}]:[];b={type:"grid",columns:2,items:b.concat([{type:"input",name:"width",label:"Width"},{type:"input",name:"height",label:"Height"}]).concat(f).concat([{type:"listbox",name:"align",label:"Alignment",items:[{text:"None",value:""},{text:"Left",value:"left"},{text:"Center",value:"center"},{text:"Right",value:"right"}]}]).concat(c)};b=Cb(a)?{type:"tabpanel",tabs:[{title:"General",name:"general",items:[b]},af("table")]}:{type:"panel",items:[b]};a.windowManager.open({title:"Table Properties",
 size:"normal",body:b,onSubmit:Q(cn,a,d,e),buttons:[{type:"cancel",name:"cancel",text:"Cancel"},{type:"submit",name:"save",text:"Save",primary:!0}],initialData:e})},dn=function(a,b,c,d,e){var f=Kd(a),g=function(t){return sb(W(a)).each(function(q){bd(a)||jc(a)||cd(a)||N(q,f).each(function(y){"relative"!==t||Hg(y)?"fixed"!==t||Ig(y)?"responsive"!==t||pb(y).isNone()||Sg(y):Ie(a,y):lc(a,y);zb(y);rb(a,y.dom,ia)})})},h=function(t){return function(q){a.selection.setRng(q.rng);a.focus();c.clear(t);zb(t);rb(a,
 t.dom,q.effect)}},l=function(t){return Eb(W(a)).each(function(q){N(q,f).each(function(y){var H=hc(d,y,q);t(y,H).each(h(y))})})},n=function(){return Eb(W(a)).map(function(t){return N(t,f).bind(function(q){var y=hc(d,q,t),H=Jd(C,u.fromDom(a.getDoc()),k.none());return Om(q,y,H)})})},p=function(){return Eb(W(a)).map(function(t){return N(t,f).bind(function(q){var y=hc(d,q,t);return Nm(q,y)})})},m=function(t,q){return q().each(function(y){var H=z(y,function(P){return ob(P,!0)});Eb(W(a)).each(function(P){return N(P,
 f).each(function(X){var ja=wg(u.fromDom(a.getDoc()));ja={selection:Wc(d),clipboard:H,generators:ja};t(X,ja).each(h(X))})})})};sa({mceTableSplitCells:function(){return l(b.unmergeCells)},mceTableMergeCells:function(){return l(b.mergeCells)},mceTableInsertRowBefore:function(){return l(b.insertRowsBefore)},mceTableInsertRowAfter:function(){return l(b.insertRowsAfter)},mceTableInsertColBefore:function(){return l(b.insertColumnsBefore)},mceTableInsertColAfter:function(){return l(b.insertColumnsAfter)},
 mceTableDeleteCol:function(){return l(b.deleteColumn)},mceTableDeleteRow:function(){return l(b.deleteRow)},mceTableCutCol:function(t){return p().each(function(q){e.setColumns(q);l(b.deleteColumn)})},mceTableCutRow:function(t){return n().each(function(q){e.setRows(q);l(b.deleteRow)})},mceTableCopyCol:function(t){return p().each(function(q){return e.setColumns(q)})},mceTableCopyRow:function(t){return n().each(function(q){return e.setRows(q)})},mceTablePasteColBefore:function(t){return m(b.pasteColsBefore,
 e.getColumns)},mceTablePasteColAfter:function(t){return m(b.pasteColsAfter,e.getColumns)},mceTablePasteRowBefore:function(t){return m(b.pasteRowsBefore,e.getRows)},mceTablePasteRowAfter:function(t){return m(b.pasteRowsAfter,e.getRows)},mceTableDelete:function(){return sb(W(a)).each(function(t){N(t,f).filter(Oa(f)).each(function(q){var y=u.fromText("");fb(q,y);ua(q);a.dom.isEmpty(a.getBody())?(a.setContent(""),a.selection.setCursorLocation()):(q=a.dom.createRng(),q.setStart(y.dom,0),q.setEnd(y.dom,
 0),a.selection.setRng(q),a.nodeChanged())})})},mceTableAlignLeft:function(){sb(W(a)).each(function(t){N(t,f).filter(Oa(f)).each(function(q){var y=u.fromText("");fb(q,y);a.formatter.apply("alignleft",{},q.dom);a.dom.isEmpty(a.getBody())?(a.setContent(""),a.selection.setCursorLocation()):(q=a.dom.createRng(),q.setStart(y.dom,0),q.setEnd(y.dom,0),a.selection.setRng(q),a.nodeChanged())})})},mceTableAlignCenter:function(){sb(W(a)).each(function(t){N(t,f).filter(Oa(f)).each(function(q){var y=u.fromText("");
 fb(q,y);a.dom.setStyle(q.dom,"float","none");a.formatter.apply("aligncenter",{},q.dom);a.dom.isEmpty(a.getBody())?(a.setContent(""),a.selection.setCursorLocation()):(q=a.dom.createRng(),q.setStart(y.dom,0),q.setEnd(y.dom,0),a.selection.setRng(q),a.nodeChanged())})})},mceTableAlignRight:function(){sb(W(a)).each(function(t){N(t,f).filter(Oa(f)).each(function(q){var y=u.fromText("");fb(q,y);a.formatter.apply("alignright",{},q.dom);a.dom.isEmpty(a.getBody())?(a.setContent(""),a.selection.setCursorLocation()):
 (q=a.dom.createRng(),q.setStart(y.dom,0),q.setEnd(y.dom,0),a.selection.setRng(q),a.nodeChanged())})})},mceTableToImg:function(){sb(W(a)).each(function(t){N(t,f).filter(Oa(f)).each(function(q){var y=u.fromText("");fb(q,y);console.log(q);a.dom.setStyle(q.dom,"width",q.dom.offsetWidth);a.dom.setStyle(q.dom,"height",q.dom.offsetHeight);Cd.toBlob(q.dom).then(function(H){var P=a.getParam("images_upload_handler",void 0,"function");H.lastModifiedDate=new Date;H.name="toimg"+(new Date).getTime()+".png";P({file:null,
 blob:function(){return H}},function(X){ua(q);if(a.dom.isEmpty(a.getBody()))a.setContent(""),a.selection.setCursorLocation();else{var ja=a.dom.createRng();ja.setStart(y.dom,0);ja.setEnd(y.dom,0);a.selection.setRng(ja);a.nodeChanged()}a.insertContent('<img src="'+X+'" />')},function(X){console.log(X)})}).catch(function(H){console.error("oops, something went wrong!",H)})})})},mceTableSizingMode:function(t,q){return g(q)}},function(t,q){return a.addCommand(q,t)});var r=function(t,q){q.each(function(y){rb(t,
 y.dom,ia)})};sa({mceTableCellType:function(t,q){t=N(W(a),f);b.setTableCellType(a,q);r(a,t)},mceTableRowType:function(t,q){t=N(W(a),f);b.setTableRowType(a,q);r(a,t)}},function(t,q){return a.addCommand(q,t)});a.addCommand("mceTableColType",function(t,q){return Pa(q,"type").each(function(y){return l("th"===y?b.makeColumnsHeader:b.unmakeColumnsHeader)})});sa({mceTableProps:Q(Ph,a,!1),mceTableRowProps:Q(bn,a),mceTableCellProps:Q(Zm,a,d)},function(t,q){return a.addCommand(q,function(){return t()})});a.addCommand("mceTpable",
 function(t,q){K(q)&&0<wa(q).length?Ch(a,q.rows,q.columns,q.options,"Invalid values for mceTpable - rows and columns values are required to insert a table."):Ph(a,!0)});a.addCommand("mceTableApplyCellStyle",function(t,q){if(K(q)){var y=md(W(a),d);0!==y.length&&(t=Ib(q,function(H,P){return a.formatter.has("tablecell"+P.toLowerCase().replace("-",""))&&J(H)}),Zi(t)||(sa(t,function(H,P){F(y,function(X){Fb.normal(a,X.dom).setFormat("tablecell"+P.toLowerCase().replace("-",""),H)})}),N(y[0],f).each(function(H){return rb(a,
 H.dom,Qg)})))}})},en=function(a,b,c){var d=Kd(a);sa({mceTableRowType:function(){return b.getTableRowType(a)},mceTableCellType:function(){return b.getTableCellType(a)},mceTableColType:function(){return Eb(W(a)).bind(function(e){return N(e,d).map(function(f){var g=hc(c,f,e);return b.getTableColType(f,g)})}).getOr("")}},function(e,f){return a.addQueryValueHandler(f,e)})},fn=function(){var a=Aa(k.none()),b=Aa(k.none()),c=function(d){d.set(k.none())};return{getRows:a.get,setRows:function(d){a.set(d);c(b)},
 clearRows:function(){return c(a)},getColumns:b.get,setColumns:function(d){b.set(d);c(a)},clearColumns:function(){return c(b)}}},gn={tablecellbackgroundcolor:{selector:"td,th",styles:{backgroundColor:"%value"},remove_similar:!0},tablecellbordercolor:{selector:"td,th",styles:{borderColor:"%value"},remove_similar:!0},tablecellborderstyle:{selector:"td,th",styles:{borderStyle:"%value"},remove_similar:!0},tablecellborderwidth:{selector:"td,th",styles:{borderWidth:"%value"},remove_similar:!0}},Qh=$a.generate([{none:["current"]},
 {first:["current"]},{middle:["current","target"]},{last:["current"]}]),Sb=I(I({},Qh),{none:function(a){void 0===a&&(a=void 0);return Qh.none(a)}}),Rh=function(a,b){return N(a,b).bind(function(c){var d=Mb(c);return Dc(d,function(e){return M(a,e)}).map(function(e){return{index:e,all:d}})})},hn=function(a,b){return Rh(a,b).fold(function(){return Sb.none(a)},function(c){return c.index+1<c.all.length?Sb.middle(a,c.all[c.index+1]):Sb.last(a)})},jn=function(a,b){return Rh(a,b).fold(function(){return Sb.none()},
 function(c){return 0<=c.index-1?Sb.middle(a,c.all[c.index-1]):Sb.first(a)})},tc={create:function(a,b,c,d){return{start:a,soffset:b,finish:c,foffset:d}}},df=$a.generate([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),ka={before:df.before,on:df.on,after:df.after,cata:function(a,b,c,d){return a.fold(b,c,d)},getStart:function(a){return a.fold(ca,ca,ca)}},qd=$a.generate([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),kn=function(a){return a.match({domRange:function(b){return u.fromDom(b.startContainer)},
 relative:function(b,c){return ka.getStart(b)},exact:function(b,c,d,e){return b}})},kb={domRange:qd.domRange,relative:qd.relative,exact:qd.exact,exactFromRange:function(a){return qd.exact(a.start,a.soffset,a.finish,a.foffset)},getWin:function(a){a=kn(a);return u.fromDom(Id(a).dom.defaultView)},range:tc.create},ln=function(a,b){b.fold(function(c){a.setStartBefore(c.dom)},function(c,d){a.setStart(c.dom,d)},function(c){a.setStartAfter(c.dom)})},mn=function(a,b){b.fold(function(c){a.setEndBefore(c.dom)},
 function(c,d){a.setEnd(c.dom,d)},function(c){a.setEndAfter(c.dom)})},Sh=function(a,b,c){a=a.document.createRange();ln(a,b);mn(a,c);return a},Tb=function(a,b,c,d,e){a=a.document.createRange();a.setStart(b.dom,c);a.setEnd(d.dom,e);return a},nn=function(a){return{left:a.left,top:a.top,right:a.right,bottom:a.bottom,width:a.width,height:a.height}},ef=$a.generate([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),Th=function(a,b,c){return b(u.fromDom(c.startContainer),
 c.startOffset,u.fromDom(c.endContainer),c.endOffset)},on=function(a,b){return b.match({domRange:function(c){return{ltr:w(c),rtl:k.none}},relative:function(c,d){return{ltr:Gb(function(){return Sh(a,c,d)}),rtl:Gb(function(){return k.some(Sh(a,d,c))})}},exact:function(c,d,e,f){return{ltr:Gb(function(){return Tb(a,c,d,e,f)}),rtl:Gb(function(){return k.some(Tb(a,e,f,c,d))})}}})},pn=function(a,b){var c=b.ltr();return c.collapsed?b.rtl().filter(function(d){return!1===d.collapsed}).map(function(d){return ef.rtl(u.fromDom(d.endContainer),
 d.endOffset,u.fromDom(d.startContainer),d.startOffset)}).getOrThunk(function(){return Th(a,ef.ltr,c)}):Th(a,ef.ltr,c)},ff=function(a,b){b=on(a,b);return pn(a,b)},Ld=function(a,b){return ff(a,b).match({ltr:function(c,d,e,f){var g=a.document.createRange();g.setStart(c.dom,d);g.setEnd(e.dom,f);return g},rtl:function(c,d,e,f){var g=a.document.createRange();g.setStart(e.dom,f);g.setEnd(c.dom,d);return g}})},qn=function(a,b,c,d,e){if(0===e)return 0;if(b===d)return e-1;for(var f=1;f<e;f++){var g=a(f),h=
 Math.abs(b-g.left);if(c<=g.bottom){if(c<g.top||h>d)return f-1;d=h}}return 0},Uh=function(a,b,c){return b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom},rn=function(a,b,c,d,e){var f=function(h){var l=a.dom.createRange();l.setStart(b.dom,h);l.collapse(!0);return l},g=Cc(b).length;c=qn(function(h){return f(h).getBoundingClientRect()},c,d,e.right,g);return f(c)},sn=function(a,b,c,d){var e=a.dom.createRange();e.selectNode(b.dom);e=e.getClientRects();return mb(e,function(f){return Uh(f,c,d)?k.some(f):k.none()}).map(function(f){return rn(a,
 b,c,d,f)})},tn=function(a,b,c,d){var e=a.dom.createRange();b=ra(b);return mb(b,function(f){e.selectNode(f.dom);return Uh(e.getBoundingClientRect(),c,d)?Vh(a,f,c,d):k.none()})},Vh=function(a,b,c,d){return hb(b)?sn(a,b,c,d):tn(a,b,c,d)},Wh=function(a,b,c){a=a.dom.createRange();a.selectNode(b.dom);a.collapse(c);return a},un=function(a,b,c){var d=a.dom.createRange();d.selectNode(b.dom);d=d.getBoundingClientRect();var e=c-d.left<d.right-c?!0:!1;return(!0===e?Vc:pe)(b).map(function(f){return Wh(a,f,e)})},
 vn=function(a,b,c){var d=b.dom.getBoundingClientRect();return k.some(Wh(a,b,c-d.left<d.right-c?!0:!1))},wn=function(a,b,c){return k.from(a.dom.caretPositionFromPoint(b,c)).bind(function(d){if(null===d.offsetNode)return k.none();var e=a.dom.createRange();e.setStart(d.offsetNode,d.offset);e.collapse();return k.some(e)})},xn=function(a,b,c){return k.from(a.dom.caretRangeFromPoint(b,c))},yn=function(a,b,c,d){var e=a.dom.createRange();e.selectNode(b.dom);e=e.getBoundingClientRect();c=Math.max(e.left,Math.min(e.right,
 c));d=Math.max(e.top,Math.min(e.bottom,d));e=a.dom.createRange();e.selectNode(b.dom);e=e.getBoundingClientRect();return Vh(a,b,Math.max(e.left,Math.min(e.right,c)),Math.max(e.top,Math.min(e.bottom,d)))},zn=function(a,b,c){return u.fromPoint(a,b,c).bind(function(d){var e=function(){return(0===ra(d).length?vn:un)(a,d,b)};return 0===ra(d).length?e():yn(a,d,b,c).orThunk(e)})},An=document.caretPositionFromPoint?wn:document.caretRangeFromPoint?xn:zn,Bn=function(a,b,c){a=u.fromDom(a.document);return An(a,
 b,c).map(function(d){return tc.create(u.fromDom(d.startContainer),d.startOffset,u.fromDom(d.endContainer),d.endOffset)})},rd=function(a,b){var c=L(a);return"input"===c?ka.after(a):R(["br","img"],c)?0===b?ka.before(a):ka.after(a):ka.on(a,b)},gf=function(a,b){a=a.fold(ka.before,rd,ka.after);b=b.fold(ka.before,rd,ka.after);return kb.relative(a,b)},sd=function(a,b,c,d){a=rd(a,b);c=rd(c,d);return kb.relative(a,c)},Cn=function(a){return a.match({domRange:function(b){var c=u.fromDom(b.startContainer),d=
 u.fromDom(b.endContainer);return sd(c,b.startOffset,d,b.endOffset)},relative:gf,exact:sd})},td=function(a,b){k.from(a.getSelection()).each(function(c){c.removeAllRanges();c.addRange(b)})},ud=function(a,b){return ff(a,b).match({ltr:function(c,d,e,f){c=Tb(a,c,d,e,f);td(a,c)},rtl:function(c,d,e,f){k.from(a.getSelection()).each(function(g){if(g.setBaseAndExtent)g.setBaseAndExtent(c.dom,d,e.dom,f);else if(g.extend)try{g.collapse(c.dom,d),g.extend(e.dom,f)}catch(h){g=Tb(a,e,f,c,d),td(a,g)}else g=Tb(a,e,
 f,c,d),td(a,g)})}})},Dn=function(a){var b=kb.getWin(a).dom,c=function(d,e,f,g){return Tb(b,d,e,f,g)};a=Cn(a);return ff(b,a).match({ltr:c,rtl:c})},Xh=function(a){if(0<a.rangeCount){var b=a.getRangeAt(0);a=a.getRangeAt(a.rangeCount-1);return k.some(tc.create(u.fromDom(b.startContainer),b.startOffset,u.fromDom(a.endContainer),a.endOffset))}return k.none()},En=function(a){if(null===a.anchorNode||null===a.focusNode)return Xh(a);var b=u.fromDom(a.anchorNode),c=u.fromDom(a.focusNode),d=a.anchorOffset,e=
 a.focusOffset,f=Kb(b).dom.createRange();f.setStart(b.dom,d);f.setEnd(c.dom,e);d=M(b,c)&&d===e;return f.collapsed&&!d?k.some(tc.create(b,a.anchorOffset,c,a.focusOffset)):Xh(a)},Fn=function(a){return k.from(a.getSelection()).filter(function(b){return 0<b.rangeCount}).bind(En)},Yh=function(a){return Fn(a).map(function(b){return kb.exact(b.start,b.soffset,b.finish,b.foffset)})},Gn=function(a){k.from(a.getSelection()).each(function(b){return b.removeAllRanges()})},Hn=tinymce.util.Tools.resolve("tinymce.util.VK"),
 In=function(a,b,c,d){return Zh(a,b,hn(c),d)},Jn=function(a,b,c,d){return Zh(a,b,jn(c),d)},$h=function(a,b){a=kb.exact(b,0,b,0);return Dn(a)},Kn=function(a,b){b=Za("tr",b);return Rd(b).bind(function(c){return Hb("td,th",c).map(function(d){return $h(a,d)})})},Zh=function(a,b,c,d){return c.fold(k.none,k.none,function(e,f){return Vc(f).map(function(g){return $h(a,g)})},function(e){return N(e,b).bind(function(f){var g=zg(e);a.undoManager.transact(function(){d.insertRowsAfter(f,g)});return Kn(a,f)})})},
 Ln=["table","li","dl"],Mn=function(a,b,c){if(a.keyCode===Hn.TAB){var d=jb(b),e=function(g){var h=L(g);return M(g,d)||R(Ln,h)},f=b.selection.getRng();f.collapsed&&(f=u.fromDom(f.startContainer),Jc(["td","th"],f,e).each(function(g){a.preventDefault();(a.shiftKey?Jn:In)(b,e,g,c).each(function(h){b.selection.setRng(h)})}))}},Ub={create:function(a,b){return{selection:a,kill:b}}},ai={create:function(a,b,c,d){return{start:ka.on(a,b),finish:ka.on(c,d)}}},bi=function(a,b){a=Ld(a,b);return tc.create(u.fromDom(a.startContainer),
 a.startOffset,u.fromDom(a.endContainer),a.endOffset)},vd=ai.create,Nn=function(a,b,c,d,e,f,g){return M(c,e)&&d===f?k.none():da(c,"td,th",b).bind(function(h){return da(e,"td,th",b).bind(function(l){return ci(a,b,h,l,g)})})},ci=function(a,b,c,d,e){return M(c,d)?k.none():Nc(c,d,b).bind(function(f){var g=f.boxes.getOr([]);return 0<g.length?(e(a,g,f.start,f.finish),k.some(Ub.create(k.some(vd(c,0,c,qb(c))),!0))):k.none()})},On=function(a,b,c,d,e){return Gj(d,a,b,e.firstSelectedSelector,e.lastSelectedSelector).map(function(f){e.clearBeforeUpdate(c);
 e.selectRange(c,f.boxes,f.start,f.finish);return f.boxes})},di=function(a,b,c,d){void 0===d&&(d=tb);return a.property().parent(b).map(function(e){return{item:e,mode:d}})},tb=function(a,b,c,d){void 0===d&&(d=uc);return c.sibling(a,b).map(function(e){return{item:e,mode:d}})},uc=function(a,b,c,d){void 0===d&&(d=uc);a=a.property().children(b);return c.first(a).map(function(e){return{item:e,mode:d}})},Pn=[{current:di,next:tb,fallback:k.none()},{current:tb,next:uc,fallback:k.some(di)},{current:uc,next:uc,
 fallback:k.some(tb)}],ei=function(a,b,c,d,e){void 0===e&&(e=Pn);return Fa(e,function(f){return f.current===c}).bind(function(f){return f.current(a,b,d,f.next).orThunk(function(){return f.fallback.bind(function(g){return ei(a,b,g,d)})})})},wd={left:function(){return{sibling:function(a,b){return a.query().prevSibling(b)},first:function(a){return 0<a.length?k.some(a[a.length-1]):k.none()}}},right:function(){return{sibling:function(a,b){return a.query().nextSibling(b)},first:function(a){return 0<a.length?
 k.some(a[0]):k.none()}}}},vc=function(a,b,c,d,e,f){return ei(a,b,d,e).bind(function(g){return f(g.item)?k.none():c(g.item)?k.some(g.item):vc(a,g.item,c,g.mode,e,f)})},fi=function(a){return function(b){return 0===a.property().children(b).length}},Vb=ub(),gi=function(a,b){var c=fi(Vb);return vc(Vb,a,c,tb,wd.left(),b)},hi=function(a,b){var c=fi(Vb);return vc(Vb,a,c,tb,wd.right(),b)},Qn=function(a,b,c){return vc(Vb,a,b,tb,wd.left(),c)},Rn=function(a,b,c){return vc(Vb,a,b,tb,wd.right(),c)},Sn=function(a,
 b,c){return Yb(a,b,c).isSome()},xd=$a.generate([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),Tn=function(a){return da(a,"tr")},Wb=I(I({},xd),{verify:function(a,b,c,d,e,f,g){return da(d,"td,th",g).bind(function(h){return da(b,"td,th",g).map(function(l){return M(h,l)?M(d,h)&&qb(h)===e?f(l):xd.none("in same cell"):Od(Tn,[h,l]).fold(function(){var n=a.getRect(l),p=a.getRect(h);return p.right>n.left&&p.left<n.right?xd.success():f(l)},function(n){return f(l)})})}).getOr(xd.none("default"))},
 cata:function(a,b,c,d,e){return a.fold(b,c,d,e)}}),Un=function(a){return Wa(a).bind(function(b){var c=ra(b);return Dc(c,Q(M,a)).map(function(d){return{parent:b,children:c,element:a,index:d}})})},hf=function(a){return"br"===L(a)},jf=function(a,b,c){return b(a,c).bind(function(d){return hb(d)&&0===Cc(d).trim().length?jf(d,b,c):k.some(d)})},Vn=function(a,b,c){return c.traverse(b).orThunk(function(){return jf(b,c.gather,a)}).map(c.relative)},Wn=function(a,b){return Wd(a,b).filter(hf).orThunk(function(){return Wd(a,
 b-1).filter(hf)})},Xn=function(a,b,c,d){return Wn(b,c).bind(function(e){return d.traverse(e).fold(function(){return jf(e,d.gather,a).map(d.relative)},function(f){return Un(f).map(function(g){return ka.on(g.parent,g.index)})})})},Yn=function(a,b,c,d){return(hf(b)?Vn(a,b,d):Xn(a,b,c,d)).map(function(e){return{start:e,finish:e}})},Zn=function(a){return Wb.cata(a,function(b){return k.none()},function(){return k.none()},function(b){return k.some(mc(b,0))},function(b){return k.some(mc(b,qb(b)))})},yd=function(a,
 b){return{left:a.left,top:a.top+b,right:a.right,bottom:a.bottom+b}},zd=function(a,b){return{left:a.left,top:a.top-b,right:a.right,bottom:a.bottom-b}},ii=function(a,b,c){return{left:a.left+b,top:a.top+c,right:a.right+b,bottom:a.bottom+c}},Ad=function(a){return{left:a.left,top:a.top,right:a.right,bottom:a.bottom}},ji=function(a,b,c){return ib(b)?k.some(a.getRect(b)).map(Ad):hb(b)?(a=0<=c&&c<qb(b)?a.getRangedRect(b,c,b,c+1):0<c?a.getRangedRect(b,c-1,b,c):k.none(),a.map(Ad)):k.none()},ki=function(a,b){return ib(b)?
 k.some(a.getRect(b)).map(Ad):hb(b)?a.getRangedRect(b,0,b,qb(b)).map(Ad):k.none()},Ua=$a.generate([{none:[]},{retry:["caret"]}]),li=function(a,b,c){return jj(b,Oe).fold(S,function(d){return ki(a,d).exists(function(e){return c.left<e.left||1>Math.abs(e.right-c.left)||c.left>e.right})})},$n={point:function(a){return a.bottom},adjuster:function(a,b,c,d,e){var f=yd(e,5);return 1>Math.abs(c.bottom-d.bottom)?Ua.retry(f):c.top>e.bottom?Ua.retry(f):c.top===e.bottom?Ua.retry(yd(e,1)):li(a,b,e)?Ua.retry(ii(f,
 5,0)):Ua.none()},move:yd,gather:hi},ao=function(a,b,c){return a.elementFromPoint(b,c).filter(function(d){return"table"===L(d)}).isSome()},bo=function(a,b,c,d,e){return kf(a,b,c,b.move(d,5),e)},kf=function(a,b,c,d,e){return 0===e?k.some(d):ao(a,d.left,b.point(d))?bo(a,b,c,d,e-1):a.situsFromPoint(d.left,b.point(d)).bind(function(f){return f.start.fold(k.none,function(g){return ki(a,g).bind(function(h){return b.adjuster(a,g,h,c,d).fold(k.none,function(l){return kf(a,b,c,l,e-1)})}).orThunk(function(){return k.some(d)})},
 k.none)})},co=function(a,b,c){return a.point(b)>c.getInnerHeight()?k.some(a.point(b)-c.getInnerHeight()):0>a.point(b)?k.some(-a.point(b)):k.none()},mi=function(a,b,c){var d=a.move(c,5),e=kf(b,a,c,d,100).getOr(d);return co(a,e,b).fold(function(){return b.situsFromPoint(e.left,a.point(e))},function(f){b.scrollBy(0,f);return b.situsFromPoint(e.left,a.point(e)-f)})},wc={tryUp:Q(mi,{point:function(a){return a.top},adjuster:function(a,b,c,d,e){var f=zd(e,5);return 1>Math.abs(c.top-d.top)?Ua.retry(f):c.bottom<
 e.top?Ua.retry(f):c.bottom===e.top?Ua.retry(zd(e,1)):li(a,b,e)?Ua.retry(ii(f,5,0)):Ua.none()},move:zd,gather:gi}),tryDown:Q(mi,$n),ieTryUp:function(a,b){return a.situsFromPoint(b.left,b.top-5)},ieTryDown:function(a,b){return a.situsFromPoint(b.left,b.bottom+5)},getJumpSize:w(5)},eo=function(a,b,c){return a.getSelection().bind(function(d){return Yn(b,d.finish,d.foffset,c).fold(function(){return k.some(mc(d.finish,d.foffset))},function(e){e=a.fromSitus(e);e=Wb.verify(a,d.finish,d.foffset,e.finish,e.foffset,
 c.failure,b);return Zn(e)})})},lf=function(a,b,c,d,e,f){return 0===f?k.none():fo(a,b,c,d,e).bind(function(g){var h=a.fromSitus(g);h=Wb.verify(a,c,d,h.finish,h.foffset,e.failure,b);return Wb.cata(h,function(){return k.none()},function(){return k.some(g)},function(l){return M(c,l)&&0===d?ni(a,c,d,zd,e):lf(a,b,l,0,e,f-1)},function(l){return M(c,l)&&d===qb(l)?ni(a,c,d,yd,e):lf(a,b,l,qb(l),e,f-1)})})},ni=function(a,b,c,d,e){return ji(a,b,c).bind(function(f){return oi(a,e,d(f,wc.getJumpSize()))})},oi=function(a,
 b,c){var d=Hc().browser;return d.isChrome()||d.isSafari()||d.isFirefox()||d.isEdge()?b.otherRetry(a,c):d.isIE()?b.ieRetry(a,c):k.none()},fo=function(a,b,c,d,e){return ji(a,c,d).bind(function(f){return oi(a,e,f)})},go=function(a,b,c){return eo(a,b,c).bind(function(d){return lf(a,b,d.element,d.offset,c,20).map(a.fromSitus)})},ho=function(a,b){return Sn(a,function(c){return Wa(c).exists(function(d){return M(d,b)})})},pi=function(a,b,c,d,e){return da(d,"td,th",b).bind(function(f){return da(f,"table",
 b).bind(function(g){return ho(e,g)?go(a,b,c).bind(function(h){return da(h.finish,"td,th",b).map(function(l){return{start:f,finish:l,range:h}})}):k.none()})})},qi=function(a,b,c,d,e,f){return Hc().browser.isIE()?k.none():f(d,b).orThunk(function(){return pi(a,b,c,d,e).map(function(g){g=g.range;return Ub.create(k.some(vd(g.start,g.soffset,g.finish,g.foffset)),!0)})})},io=function(a,b){return da(a,"tr",b).bind(function(c){return da(c,"table",b).bind(function(d){var e=Za("tr",d);return M(c,e[0])?Qn(d,
 function(f){return pe(f).isSome()},b).map(function(f){var g=qb(f);return Ub.create(k.some(vd(f,g,f,g)),!0)}):k.none()})})},jo=function(a,b){return da(a,"tr",b).bind(function(c){return da(c,"table",b).bind(function(d){var e=Za("tr",d);return M(c,e[e.length-1])?Rn(d,function(f){return Vc(f).isSome()},b).map(function(f){return Ub.create(k.some(vd(f,0,f,0)),!0)}):k.none()})})},ri=function(a,b,c,d,e,f,g){return pi(a,c,d,e,f).bind(function(h){return ci(b,c,h.start,h.finish,g)})},ko=function(){var a=Aa(k.none());
 return{clear:function(){return a.set(k.none())},set:function(b){return a.set(k.some(b))},isSet:function(){return a.get().isSome()},on:function(b){return a.get().each(b)}}},lo=function(a,b,c,d){var e=ko(),f=e.clear,g=function(h){e.on(function(l){d.clearBeforeUpdate(b);da(h.target,"td,th",c).each(function(n){Nc(l,n,c).each(function(p){var m=p.boxes.getOr([]);if(1<m.length||1===m.length&&!M(l,n))d.selectRange(b,m,p.start,p.finish),a.selectContents(n)})})})};return{clearstate:f,mousedown:function(h){d.clear(b);
 da(h.target,"td,th",c).each(e.set)},mouseover:function(h){g(h)},mouseup:function(h){g(h);f()}}},si={traverse:Bc,gather:hi,relative:ka.before,otherRetry:wc.tryDown,ieRetry:wc.ieTryDown,failure:Wb.failedDown},ti={traverse:rf,gather:gi,relative:ka.before,otherRetry:wc.tryUp,ieRetry:wc.ieTryUp,failure:Wb.failedUp},Xb=function(a){return function(b){return b===a}},mf=Xb(38),Bd=Xb(40),Nd=function(a){return 37<=a&&40>=a},Gi={isBackward:Xb(37),isForward:Xb(39)},Hi={isBackward:Xb(39),isForward:Xb(37)},nf=function(a){return{elementFromPoint:function(b,
 c){return u.fromPoint(u.fromDom(a.document),b,c)},getRect:function(b){return b.dom.getBoundingClientRect()},getRangedRect:function(b,c,d,e){b=kb.exact(b,c,d,e);b=Ld(a,b);c=b.getClientRects();b=0<c.length?c[0]:b.getBoundingClientRect();return 0<b.width||0<b.height?k.some(b).map(nn):k.none()},getSelection:function(){return Yh(a).map(function(b){return bi(a,b)})},fromSitus:function(b){b=kb.relative(b.start,b.finish);return bi(a,b)},situsFromPoint:function(b,c){return Bn(a,b,c).map(function(d){return ai.create(d.start,
 d.soffset,d.finish,d.foffset)})},clearSelection:function(){Gn(a)},collapseSelection:function(b){void 0===b&&(b=!1);Yh(a).each(function(c){return c.fold(function(d){return d.collapse(b)},function(d,e){d=b?d:e;d=gf(d,d);ud(a,d)},function(d,e,f,g){d=b?d:f;e=b?e:g;e=sd(d,e,d,e);ud(a,e)})})},setSelection:function(b){b=sd(b.start,b.soffset,b.finish,b.foffset);ud(a,b)},setRelativeSelection:function(b,c){b=gf(b,c);ud(a,b)},selectContents:function(b){var c=a.document.createRange();c.selectNodeContents(b.dom);
 td(a,c)},getInnerHeight:function(){return a.innerHeight},getScrollY:function(){var b=u.fromDom(a.document);b=void 0!==b?b.dom:document;return ab(b.body.scrollLeft||b.documentElement.scrollLeft,b.body.scrollTop||b.documentElement.scrollTop).top},scrollBy:function(b,c){var d=u.fromDom(a.document);(d=(void 0!==d?d.dom:document).defaultView)&&d.scrollBy(b,c)}}},Di=function(a,b,c,d){a=nf(a);b=lo(a,b,c,d);return{clearstate:b.clearstate,mousedown:b.mousedown,mouseover:b.mouseover,mouseup:b.mouseup}},Ei=
 function(a,b,c,d){var e=nf(a),f=function(){d.clear(b);return k.none()};return{keydown:function(g,h,l,n,p,m){g=g.raw;var r=g.which,t=!0===g.shiftKey;return Oc(b,d.selectedSelector).fold(function(){return Bd(r)&&t?Q(ri,e,b,c,si,n,h,d.selectRange):mf(r)&&t?Q(ri,e,b,c,ti,n,h,d.selectRange):Bd(r)?Q(qi,e,c,si,n,h,jo):mf(r)?Q(qi,e,c,ti,n,h,io):k.none},function(q){var y=function(H){return function(){return mb(H,function(P){return On(P.rows,P.cols,b,q,d)}).fold(function(){return Xf(b,d.firstSelectedSelector,
 d.lastSelectedSelector).map(function(P){var X=Bd(r)||m.isForward(r)?ka.after:ka.before;e.setRelativeSelection(ka.on(P.first,0),X(P.table));d.clear(b);return Ub.create(k.none(),!0)})},function(P){return k.some(Ub.create(k.none(),!0))})}};return Bd(r)&&t?y([{rows:1,cols:0}]):mf(r)&&t?y([{rows:-1,cols:0}]):m.isBackward(r)&&t?y([{rows:0,cols:-1},{rows:-1,cols:0}]):m.isForward(r)&&t?y([{rows:0,cols:1},{rows:1,cols:0}]):Nd(r)&&!1===t?f:k.none})()},keyup:function(g,h,l,n,p){return Oc(b,d.selectedSelector).fold(function(){var m=
 g.raw,r=m.which;return!0===m.shiftKey===!1?k.none():Nd(r)?Nn(b,c,h,l,n,p,d.selectRange):k.none()},k.none)}}},Fi=function(a,b,c,d){var e=nf(a);return function(f,g){d.clearBeforeUpdate(b);Nc(f,g,c).each(function(h){var l=h.boxes.getOr([]);d.selectRange(b,l,h.start,h.finish);e.selectContents(g);e.collapseSelection()})}},mo=function(a,b){F(b,function(c){Zc(a)?a.dom.classList.remove(c):ml(a,"class",c);0===(Zc(a)?a.dom.classList:xe(a,"class")).length&&T(a,"class")})},no=function(a){return function(b){bb(b,
 a)}},oo=function(a){return function(b){mo(b,a)}},Bi={byClass:function(a){var b=no(a.selected),c=oo([a.selected,a.lastSelected,a.firstSelected]),d=function(e){e=Za(a.selectedSelector,e);F(e,c)};return{clearBeforeUpdate:d,clear:d,selectRange:function(e,f,g,h){d(e);F(f,b);bb(g,a.firstSelected);bb(h,a.lastSelected)},selectedSelector:a.selectedSelector,firstSelectedSelector:a.firstSelectedSelector,lastSelectedSelector:a.lastSelectedSelector}},byAttr:function(a,b,c){var d=function(h){T(h,a.selected);T(h,
 a.firstSelected);T(h,a.lastSelected)},e=function(h){fa(h,a.selected,"1")},f=function(h){g(h);c()},g=function(h){h=Za(a.selectedSelector,h);F(h,d)};return{clearBeforeUpdate:g,clear:f,selectRange:function(h,l,n,p){f(h);F(l,e);fa(n,a.firstSelected,"1");fa(p,a.lastSelected,"1");b(l,n,p)},selectedSelector:a.selectedSelector,firstSelectedSelector:a.firstSelectedSelector,lastSelectedSelector:a.lastSelectedSelector}}},po=function(a,b,c){a=a.slice(0,b[b.length-1].row+1);c=gd(a,c);return na(c,function(d){d=
 d.cells.slice(0,b[b.length-1].column+1);return z(d,function(e){return e.element})})},qo=function(a,b,c){a=a.slice(b[0].row+b[0].rowspan-1,a.length);c=gd(a,c);return na(c,function(d){d=d.cells.slice(b[0].column+b[0].colspan-1,d.cells.length);return z(d,function(e){return e.element})})},Ci=function(a,b,c){var d=G.fromTable(a);return Sa(d,b).map(function(e){var f=oc(d,c,!1),g=po(f,e,c);e=qo(f,e,c);return{upOrLeftCells:g,downOrRightCells:e}})},Md=function(a){return!1===ye(u.fromDom(a.target),"ephox-snooker-resizer-bar")},
 ro=function(a,b){var c=Aa(k.none()),d=Aa([]),e=k.none(),f=Gf("caption"),g=function(r){return e.forall(function(t){return!t[r]})},h=function(){return sb(W(a)).bind(function(r){return N(r).map(function(t){return f(r)?zg(r):hc(b,t,r)})})},l=function(r){return N(r.element).map(function(t){var q=G.fromTable(t);t=Sa(q,r).getOr([]);t=ma(t,function(y,H){H.isLocked&&(y.onAny=!0,0===H.column?y.onFirst=!0:H.column+H.colspan>=q.grid.columns&&(y.onLast=!0));return y},{onAny:!1,onFirst:!1,onLast:!1});return{mergeable:ah(q,
 r).isSome(),unmergeable:bh(q,r).isSome(),locked:t}})},n=function(){c.set(Gb(h)());e=c.get().bind(l);F(d.get(),function(r){return r()})},p=function(r,t){var q=function(){return c.get().fold(function(){r.setDisabled(!0)},function(y){r.setDisabled(t(y))})};q();d.set(d.get().concat([q]));return function(){d.set(Y(d.get(),function(y){return y!==q}))}},m=function(r){return e.exists(function(t){return t.locked[r]})};a.on("NodeChange ExecCommand TableSelectorChange",n);return{onSetupTable:function(r){return p(r,
 function(t){return!1})},onSetupCellOrRow:function(r){return p(r,function(t){return f(t.element)})},onSetupColumn:function(r){return function(t){return p(t,function(q){return f(q.element)||m(r)})}},onSetupPasteable:function(r){return function(t){return p(t,function(q){return f(q.element)||r().isNone()})}},onSetupPasteableColumn:function(r,t){return function(q){return p(q,function(y){return f(y.element)||r().isNone()||m(t)})}},onSetupMergeable:function(r){return p(r,function(t){return g("mergeable")})},
 onSetupUnmergeable:function(r){return p(r,function(t){return g("unmergeable")})},resetTargets:n,targets:function(){return c.get()}}},so=function(a,b,c){a.ui.registry.addMenuButton("tpTable",{tooltip:"Table",icon:"table",fetch:function(e){return e("inserttable | cell row column | advtablesort | tableprops deletetable")}});var d=function(e){return function(){return a.execCommand(e)}};a.ui.registry.addButton("tablealignleft",{tooltip:"\u8868\u683c\u5c45\u5de6",onAction:d("mceTableAlignLeft"),icon:"align-left-table",
 onSetup:b.onSetupTable});a.ui.registry.addButton("tablealigncenter",{tooltip:"\u8868\u683c\u5c45\u4e2d",onAction:d("mceTableAlignCenter"),icon:"align-center-table",onSetup:b.onSetupTable});a.ui.registry.addButton("tableToimg",{tooltip:"\u8868\u683c\u8f6c\u4e3a\u56fe\u7247",onAction:d("mceTableToImg"),icon:"table-to-img",onSetup:b.onSetupTable});a.ui.registry.addButton("tablealignright",{tooltip:"\u8868\u683c\u5c45\u53f3",onAction:d("mceTableAlignRight"),icon:"align-right-table",onSetup:b.onSetupTable});
 a.ui.registry.addButton("tableprops",{tooltip:"Table properties",onAction:d("mceTableProps"),icon:"table",onSetup:b.onSetupTable});a.ui.registry.addButton("tabledelete",{tooltip:"Delete table",onAction:d("mceTableDelete"),icon:"table-delete-table",onSetup:b.onSetupTable});a.ui.registry.addButton("tablecellprops",{tooltip:"Cell properties",onAction:d("mceTableCellProps"),icon:"table-cell-properties",onSetup:b.onSetupCellOrRow});a.ui.registry.addButton("tablemergecells",{tooltip:"Merge cells",onAction:d("mceTableMergeCells"),
 icon:"table-merge-cells",onSetup:b.onSetupMergeable});a.ui.registry.addButton("tablesplitcells",{tooltip:"Split cell",onAction:d("mceTableSplitCells"),icon:"table-split-cells",onSetup:b.onSetupUnmergeable});a.ui.registry.addButton("tableinsertrowbefore",{tooltip:"Insert row before",onAction:d("mceTableInsertRowBefore"),icon:"table-insert-row-above",onSetup:b.onSetupCellOrRow});a.ui.registry.addButton("tableinsertrowafter",{tooltip:"Insert row after",onAction:d("mceTableInsertRowAfter"),icon:"table-insert-row-after",
 onSetup:b.onSetupCellOrRow});a.ui.registry.addButton("tabledeleterow",{tooltip:"Delete row",onAction:d("mceTableDeleteRow"),icon:"table-delete-row",onSetup:b.onSetupCellOrRow});a.ui.registry.addButton("tablerowprops",{tooltip:"Row properties",onAction:d("mceTableRowProps"),icon:"table-row-properties",onSetup:b.onSetupCellOrRow});a.ui.registry.addButton("tableinsertcolbefore",{tooltip:"Insert column before",onAction:d("mceTableInsertColBefore"),icon:"table-insert-column-before",onSetup:b.onSetupColumn("onFirst")});
 a.ui.registry.addButton("tableinsertcolafter",{tooltip:"Insert column after",onAction:d("mceTableInsertColAfter"),icon:"table-insert-column-after",onSetup:b.onSetupColumn("onLast")});a.ui.registry.addButton("tabledeletecol",{tooltip:"Delete column",onAction:d("mceTableDeleteCol"),icon:"table-delete-column",onSetup:b.onSetupColumn("onAny")});a.ui.registry.addButton("tablecutrow",{tooltip:"Cut row",icon:"cut-row",onAction:d("mceTableCutRow"),onSetup:b.onSetupCellOrRow});a.ui.registry.addButton("tablecopyrow",
 {tooltip:"Copy row",icon:"duplicate-row",onAction:d("mceTableCopyRow"),onSetup:b.onSetupCellOrRow});a.ui.registry.addButton("tablepasterowbefore",{tooltip:"Paste row before",icon:"paste-row-before",onAction:d("mceTablePasteRowBefore"),onSetup:b.onSetupPasteable(c.getRows)});a.ui.registry.addButton("tablepasterowafter",{tooltip:"Paste row after",icon:"paste-row-after",onAction:d("mceTablePasteRowAfter"),onSetup:b.onSetupPasteable(c.getRows)});a.ui.registry.addButton("tablecutcol",{tooltip:"Cut column",
 icon:"cut-column",onAction:d("mceTableCutCol"),onSetup:b.onSetupColumn("onAny")});a.ui.registry.addButton("tablecopycol",{tooltip:"Copy column",icon:"duplicate-column",onAction:d("mceTableCopyCol"),onSetup:b.onSetupColumn("onAny")});a.ui.registry.addButton("tablepastecolbefore",{tooltip:"Paste column before",icon:"paste-column-before",onAction:d("mceTablePasteColBefore"),onSetup:b.onSetupPasteableColumn(c.getColumns,"onFirst")});a.ui.registry.addButton("tablepastecolafter",{tooltip:"Paste column after",
 icon:"paste-column-after",onAction:d("mceTablePasteColAfter"),onSetup:b.onSetupPasteableColumn(c.getColumns,"onLast")});a.ui.registry.addButton("tableinsertdialog",{tooltip:"Insert table",onAction:d("mceTpable"),icon:"table"})},to=function(a){var b=function(d){return a.dom.is(d,"table")&&a.getBody().contains(d)},c=a.getParam("table_toolbar","tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablealignleft tablealigncenter tablealignright tabletoimg tableprops tabledelete");
 0<c.length&&a.ui.registry.addContextToolbar("tpTable",{predicate:b,items:c,scope:"node",position:"node"})},uo=function(a,b,c){var d=function(n){return function(){return a.execCommand(n)}},e=function(n){a.execCommand("mceTpable",!1,{rows:n.numRows,columns:n.numColumns})},f={text:"Table properties",onSetup:b.onSetupTable,onAction:d("mceTableProps")},g={text:"Delete table",icon:"table-delete-table",onSetup:b.onSetupTable,onAction:d("mceTableDelete")};a.ui.registry.addMenuItem("tableinsertrowbefore",
 {text:"Insert row before",icon:"table-insert-row-above",onAction:d("mceTableInsertRowBefore"),onSetup:b.onSetupCellOrRow});a.ui.registry.addMenuItem("tableinsertrowafter",{text:"Insert row after",icon:"table-insert-row-after",onAction:d("mceTableInsertRowAfter"),onSetup:b.onSetupCellOrRow});a.ui.registry.addMenuItem("tabledeleterow",{text:"Delete row",icon:"table-delete-row",onAction:d("mceTableDeleteRow"),onSetup:b.onSetupCellOrRow});a.ui.registry.addMenuItem("tablerowprops",{text:"Row properties",
 icon:"table-row-properties",onAction:d("mceTableRowProps"),onSetup:b.onSetupCellOrRow});a.ui.registry.addMenuItem("tablecutrow",{text:"Cut row",icon:"cut-row",onAction:d("mceTableCutRow"),onSetup:b.onSetupCellOrRow});a.ui.registry.addMenuItem("tablecopyrow",{text:"Copy row",icon:"duplicate-row",onAction:d("mceTableCopyRow"),onSetup:b.onSetupCellOrRow});a.ui.registry.addMenuItem("tablepasterowbefore",{text:"Paste row before",icon:"paste-row-before",onAction:d("mceTablePasteRowBefore"),onSetup:b.onSetupPasteable(c.getRows)});
 a.ui.registry.addMenuItem("tablepasterowafter",{text:"Paste row after",icon:"paste-row-after",onAction:d("mceTablePasteRowAfter"),onSetup:b.onSetupPasteable(c.getRows)});a.ui.registry.addMenuItem("tableinsertcolumnbefore",{text:"Insert column before",icon:"table-insert-column-before",onAction:d("mceTableInsertColBefore"),onSetup:b.onSetupColumn("onFirst")});a.ui.registry.addMenuItem("tableinsertcolumnafter",{text:"Insert column after",icon:"table-insert-column-after",onAction:d("mceTableInsertColAfter"),
 onSetup:b.onSetupColumn("onLast")});a.ui.registry.addMenuItem("tabledeletecolumn",{text:"Delete column",icon:"table-delete-column",onAction:d("mceTableDeleteCol"),onSetup:b.onSetupColumn("onAny")});a.ui.registry.addMenuItem("tablecutcolumn",{text:"Cut column",icon:"cut-column",onAction:d("mceTableCutCol"),onSetup:b.onSetupColumn("onAny")});a.ui.registry.addMenuItem("tablecopycolumn",{text:"Copy column",icon:"duplicate-column",onAction:d("mceTableCopyCol"),onSetup:b.onSetupColumn("onAny")});a.ui.registry.addMenuItem("tablepastecolumnbefore",
 {text:"Paste column before",icon:"paste-column-before",onAction:d("mceTablePasteColBefore"),onSetup:b.onSetupPasteableColumn(c.getColumns,"onFirst")});a.ui.registry.addMenuItem("tablepastecolumnafter",{text:"Paste column after",icon:"paste-column-after",onAction:d("mceTablePasteColAfter"),onSetup:b.onSetupPasteableColumn(c.getColumns,"onLast")});a.ui.registry.addMenuItem("tablecellprops",{text:"Cell properties",icon:"table-cell-properties",onAction:d("mceTableCellProps"),onSetup:b.onSetupCellOrRow});
 a.ui.registry.addMenuItem("tablemergecells",{text:"Merge cells",icon:"table-merge-cells",onAction:d("mceTableMergeCells"),onSetup:b.onSetupMergeable});a.ui.registry.addMenuItem("tablesplitcells",{text:"Split cell",icon:"table-split-cells",onAction:d("mceTableSplitCells"),onSetup:b.onSetupUnmergeable});!1===a.getParam("table_grid",!0,"boolean")?a.ui.registry.addMenuItem("inserttable",{text:"Table",icon:"table",onAction:d("mceTpable")}):a.ui.registry.addNestedMenuItem("inserttable",{text:"Table",icon:"table",
 getSubmenuItems:function(){return[{type:"fancymenuitem",fancytype:"inserttable",onAction:e}]}});a.ui.registry.addMenuItem("inserttabledialog",{text:"Insert table",icon:"table",onAction:d("mceTpable")});c={"align-right-table":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm6 4h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2zm-6-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',"align-left-table":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',
 "align-center-table":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm3 4h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 1 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2zm-3-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',"table-to-img":'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path fill-rule="evenodd" d="M794.4448 85.41696a20.79232 20.79232 0 0 0-29.35296-1.84832l-81.96608 72.50432-0.12288 0.14848c-1.44384 1.31584-2.70848 2.816-3.75808 4.46976-0.46592 0.7424-0.64 1.62816-0.98816 2.39104a20.93568 20.93568 0 0 0-2.06336 10.26048v0.04096c0.19968 2.40128 0.92672 4.77184 1.95072 6.9632 0.08192 0.1536 0.08192 0.42496 0.16384 0.60416l43.86304 87.68512a20.81792 20.81792 0 0 0 37.20192-18.60608l-28.00128-55.96672c54.85056 5.22752 96.62976 22.41536 124.53376 51.44064 38.272 39.7568 37.05344 89.59488 37.08928 90.00448-0.48128 11.20256 8.51456 21.09952 19.968 21.53984a20.7616 20.7616 0 0 0 21.55008-19.83488c0.07168-2.70848 2.26816-67.02592-48.05632-119.85408-32.70656-34.31424-79.31904-55.29088-138.624-63.02208l44.78464-39.6288 0.06656-0.0512a20.72576 20.72576 0 0 0 1.76128-29.24032zM497.59744 334.39232c31.54432-0.0256 57.1136-25.59488 57.1392-57.1392-0.0256-31.54944-25.59488-57.1136-57.1392-57.1392-31.54432 0.0256-57.1136 25.59488-57.1392 57.1392 0.0256 31.54944 25.58976 57.1136 57.1392 57.1392z m0-83.1232a25.984 25.984 0 1 1 0 51.92704 25.97888 25.97888 0 0 1-24.87296-27.04896 25.97376 25.97376 0 0 1 24.87296-24.87808z" p-id="34952" fill="#2c2c2c"></path><path d="M946.33472 519.02976c-8.44288-37.59104-44.98432-65.9456-88.6528-65.9456h-207.95904l-0.4608-231.49056c0-45.55264-40.62208-82.60096-90.54208-82.60096h-393.4208c-49.92512 0-90.5472 37.04832-90.5472 82.60096v307.8144c0 45.55264 40.61696 82.58048 90.5472 82.58048h208.39424v231.56224c0 5.64224 0.66048 11.2384 1.8432 16.5888 8.46336 37.63712 45.00992 65.99168 88.6784 65.99168h393.4464c49.92 0 90.5216-37.0688 90.5216-82.58048v-307.8144a73.64608 73.64608 0 0 0-1.84832-16.70656zM116.3264 221.568c0-22.61504 21.95968-41.05216 48.96768-41.05216h393.44128c27.008 0 48.96768 18.432 48.96768 41.05216v231.49056h-101.7856c-11.60704-20.22912-14.1568-24.23296-19.29728-31.9488-0.72704-1.18272-1.52576-2.98496-2.50368-5.05344-6.64576-13.952-19.0464-39.86944-45.37344-44.32896-18.0224-3.02592-36.75136 5.21216-55.79776 24.50944-28.98944 29.37856-35.04128 23.39328-41.3696 17.13664a42.46528 42.46528 0 0 0-3.13856-2.93376c-2.02752-2.43712-7.5776-12.53888-12.0576-20.66432-20.95616-38.13888-49.69984-90.3424-87.08608-91.49952l-0.77312-0.02048c-30.40256 0-78.30016 57.82016-122.19904 122.10688V221.568z m790.30272 412.47232v209.4592c0 22.5792-21.98528 41.03168-48.93184 41.03168H464.23552c-27.008 0-48.96768-18.45248-48.96768-41.03168v-307.80928c0-22.64064 21.9392-41.05216 48.96768-41.05216h393.4464c27.008 0 48.96768 18.41152 48.96768 41.05216v98.35008h-0.02048z" p-id="34953" fill="#2c2c2c"></path><path d="M658.64192 591.19104a20.78208 20.78208 0 0 1-20.80256 20.75136H471.60832a20.79232 20.79232 0 0 1 0-41.5488h166.23104a20.81792 20.81792 0 0 1 20.80256 20.79744z m-41.53344 173.11744a20.80256 20.80256 0 0 1-20.80256 20.80256h-124.672a20.77696 20.77696 0 0 1 0-41.55392h124.67712c11.4432 0.00512 20.79744 9.33376 20.79744 20.75136z m145.4336-86.53312a20.74112 20.74112 0 0 1-20.78208 20.70528H471.63392a20.70528 20.70528 0 0 1-20.77696-20.63872v-0.06656a20.7872 20.7872 0 0 1 20.77696-20.80256h270.12608a20.82304 20.82304 0 0 1 20.78208 20.80256z"></path></svg>'};
 d=a.getParam("table_icons",{"align-right-table":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm6 4h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1h-8a1 1 0 0 1 0-2zm-6-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',"align-left-table":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm0 4h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2zm0-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',
 "align-center-table":'<svg width="24" height="24"><path d="M5 5h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 1 1 0-2zm3 4h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 1 1 0-2zm0 8h8c.6 0 1 .4 1 1s-.4 1-1 1H8a1 1 0 0 1 0-2zm-3-4h14c.6 0 1 .4 1 1s-.4 1-1 1H5a1 1 0 0 1 0-2z" fill-rule="evenodd"></path></svg>',"table-to-img":'<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="24" height="24"><path fill-rule="evenodd" d="M794.4448 85.41696a20.79232 20.79232 0 0 0-29.35296-1.84832l-81.96608 72.50432-0.12288 0.14848c-1.44384 1.31584-2.70848 2.816-3.75808 4.46976-0.46592 0.7424-0.64 1.62816-0.98816 2.39104a20.93568 20.93568 0 0 0-2.06336 10.26048v0.04096c0.19968 2.40128 0.92672 4.77184 1.95072 6.9632 0.08192 0.1536 0.08192 0.42496 0.16384 0.60416l43.86304 87.68512a20.81792 20.81792 0 0 0 37.20192-18.60608l-28.00128-55.96672c54.85056 5.22752 96.62976 22.41536 124.53376 51.44064 38.272 39.7568 37.05344 89.59488 37.08928 90.00448-0.48128 11.20256 8.51456 21.09952 19.968 21.53984a20.7616 20.7616 0 0 0 21.55008-19.83488c0.07168-2.70848 2.26816-67.02592-48.05632-119.85408-32.70656-34.31424-79.31904-55.29088-138.624-63.02208l44.78464-39.6288 0.06656-0.0512a20.72576 20.72576 0 0 0 1.76128-29.24032zM497.59744 334.39232c31.54432-0.0256 57.1136-25.59488 57.1392-57.1392-0.0256-31.54944-25.59488-57.1136-57.1392-57.1392-31.54432 0.0256-57.1136 25.59488-57.1392 57.1392 0.0256 31.54944 25.58976 57.1136 57.1392 57.1392z m0-83.1232a25.984 25.984 0 1 1 0 51.92704 25.97888 25.97888 0 0 1-24.87296-27.04896 25.97376 25.97376 0 0 1 24.87296-24.87808z" p-id="34952" fill="#2c2c2c"></path><path d="M946.33472 519.02976c-8.44288-37.59104-44.98432-65.9456-88.6528-65.9456h-207.95904l-0.4608-231.49056c0-45.55264-40.62208-82.60096-90.54208-82.60096h-393.4208c-49.92512 0-90.5472 37.04832-90.5472 82.60096v307.8144c0 45.55264 40.61696 82.58048 90.5472 82.58048h208.39424v231.56224c0 5.64224 0.66048 11.2384 1.8432 16.5888 8.46336 37.63712 45.00992 65.99168 88.6784 65.99168h393.4464c49.92 0 90.5216-37.0688 90.5216-82.58048v-307.8144a73.64608 73.64608 0 0 0-1.84832-16.70656zM116.3264 221.568c0-22.61504 21.95968-41.05216 48.96768-41.05216h393.44128c27.008 0 48.96768 18.432 48.96768 41.05216v231.49056h-101.7856c-11.60704-20.22912-14.1568-24.23296-19.29728-31.9488-0.72704-1.18272-1.52576-2.98496-2.50368-5.05344-6.64576-13.952-19.0464-39.86944-45.37344-44.32896-18.0224-3.02592-36.75136 5.21216-55.79776 24.50944-28.98944 29.37856-35.04128 23.39328-41.3696 17.13664a42.46528 42.46528 0 0 0-3.13856-2.93376c-2.02752-2.43712-7.5776-12.53888-12.0576-20.66432-20.95616-38.13888-49.69984-90.3424-87.08608-91.49952l-0.77312-0.02048c-30.40256 0-78.30016 57.82016-122.19904 122.10688V221.568z m790.30272 412.47232v209.4592c0 22.5792-21.98528 41.03168-48.93184 41.03168H464.23552c-27.008 0-48.96768-18.45248-48.96768-41.03168v-307.80928c0-22.64064 21.9392-41.05216 48.96768-41.05216h393.4464c27.008 0 48.96768 18.41152 48.96768 41.05216v98.35008h-0.02048z" p-id="34953" fill="#2c2c2c"></path><path d="M658.64192 591.19104a20.78208 20.78208 0 0 1-20.80256 20.75136H471.60832a20.79232 20.79232 0 0 1 0-41.5488h166.23104a20.81792 20.81792 0 0 1 20.80256 20.79744z m-41.53344 173.11744a20.80256 20.80256 0 0 1-20.80256 20.80256h-124.672a20.77696 20.77696 0 0 1 0-41.55392h124.67712c11.4432 0.00512 20.79744 9.33376 20.79744 20.75136z m145.4336-86.53312a20.74112 20.74112 0 0 1-20.78208 20.70528H471.63392a20.70528 20.70528 0 0 1-20.77696-20.63872v-0.06656a20.7872 20.7872 0 0 1 20.77696-20.80256h270.12608a20.82304 20.82304 0 0 1 20.78208 20.80256z"></path></svg>'});
 for(var h in c)a.ui.registry.addIcon(h,c[h]);for(var l in d)a.ui.registry.addIcon(l,d[l]);a.ui.registry.addMenuItem("tableprops",f);a.ui.registry.addMenuItem("deletetable",g);a.ui.registry.addNestedMenuItem("row",{type:"nestedmenuitem",text:"Row",getSubmenuItems:function(){return"tableinsertrowbefore tableinsertrowafter tabledeleterow tablerowprops | tablecutrow tablecopyrow tablepasterowbefore tablepasterowafter"}});a.ui.registry.addNestedMenuItem("column",{type:"nestedmenuitem",text:"Column",getSubmenuItems:function(){return"tableinsertcolumnbefore tableinsertcolumnafter tabledeletecolumn | tablecutcolumn tablecopycolumn tablepastecolumnbefore tablepastecolumnafter"}});
 a.ui.registry.addNestedMenuItem("cell",{type:"nestedmenuitem",text:"Cell",getSubmenuItems:function(){return"tablecellprops tablemergecells tablesplitcells"}});a.ui.registry.addContextMenu("tpTable",{update:function(){b.resetTargets();return b.targets().fold(function(){return""},function(n){return"caption"===L(n.element)?"tableprops deletetable":"cell row column | advtablesort | tableprops deletetable"})}})};Nj.add("tpTable",function(a){var b=Mj(function(){return jb(a)},function(){return sb(W(a))},
 Xa.selectedSelector),c=ro(a,b),d=Kl(a),e=Dd(a,d.lazyResize,c),f=Em(a,d.lazyWire,b),g=fn();dn(a,f,e,b,g);en(a,f,b);Ek(a,b,f,e);uo(a,c,g);so(a,c,g);to(a);a.on("PreInit",function(){a.serializer.addTempAttr(Xa.firstSelected);a.serializer.addTempAttr(Xa.lastSelected);a.formatter.register(gn)});if(a.getParam("table_tab_navigation",!0,"boolean"))a.on("keydown",function(h){Mn(h,a,f)});a.on("remove",function(){d.destroy()});return Km(a,g,d,c)})})(domtoimage);