/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.0.16 (2019-09-24) */ !function(f){"use strict";function o(e){return e}var l=function(e){function n(){return t}var t=e;return{get:n,set:function(e){t=e},clone:function(){return l(n())}}},y=function(){},C=function(t,r){return function(){for(var e=[],n=0;nt.maxRow()||st.maxCol()))dt.getAt(n,l,s).filter(r).isNone()?(o=f,void 0,i=e[l].element(),u=on.fromTag("td"),Bn(u,on.fromTag("br")),(o?Bn:Oe)(i,u)):f=!0}}(r,o,i,t),function(e,n){var t=v(it.firstLayer(e,"tr"),function(e){return 0===e.dom().childElementCount});h(t,Mn),n.minCol()!==n.maxCol()&&n.minRow()!==n.maxRow()||h(it.firstLayer(e,"th,td"),function(e){K(e,"rowspan"),K(e,"colspan")}),K(e,"width"),K(e,"height"),ce(e,"width"),ce(e,"height")}(e,i),e};function pt(e){return kt.get(e)}function ht(e){return kt.getOption(e)}function vt(e,n){kt.set(e,n)}function bt(e){return"img"===j(e)?1:ht(e).fold(function(){return Se(e).length},function(e){return e.length})}function wt(e){return function(e){return ht(e).filter(function(e){return 0!==e.trim().length||-1=e.startCol()&&n.column()+n.colspan()-1<=e.finishCol()&&n.row()>=e.startRow()&&n.row()+n.rowspan()-1<=e.finishRow()}function It(e,n,t){var r=dt.findItem(e,n,he),o=dt.findItem(e,t,he);return r.bind(function(n){return o.map(function(e){return function(e,n){return Gn(Math.min(e.row(),n.row()),Math.min(e.column(),n.column()),Math.max(e.row()+e.rowspan()-1,n.row()+n.rowspan()-1),Math.max(e.column()+e.colspan()-1,n.column()+n.colspan()-1))}(n,e)})})}var kt=function Yf(t,r){var n=function(e){return t(e)?We.from(e.dom().nodeValue):We.none()};return{get:function(e){if(!t(e))throw new Error("Can only get "+r+" value of a "+r+" node");return n(e).getOr("")},getOption:n,set:function(e,n){if(!t(e))throw new Error("Can only set raw "+r+" value of a "+r+" node");e.dom().nodeValue=n}}}(tn,"text"),Pt=["img","br"],Bt=function(e,i){var u=function(e){for(var n=Se(e),t=n.length-1;0<=t;t--){var r=n[t];if(i(r))return We.some(r);var o=u(r);if(o.isSome())return o}return We.none()};return u(e)},Mt=function(i,e,u){return{row:Et(e),cell:function(e){var n=ve(e.element()),t=on.fromTag(j(e.element()),n.dom()),r=u.getOr(["strong","em","b","i","span","font","h1","h2","h3","h4","h5","h6","p","div"]),o=0=e.startCol()&&o<=e.finishRow()&&i>=e.startRow()},Lt=function(e,n){for(var t=!0,r=b(Nt,n),o=n.startRow();o<=n.finishRow();o++)for(var i=n.startCol();i<=n.finishCol();i++)t=t&&dt.getAt(e,o,i).exists(r);return t?We.some(n):We.none()},jt=It,zt=function(n,e,t){return It(n,e,t).bind(function(e){return Lt(n,e)})},Ht=function(r,e,o,i){return dt.findItem(r,e,he).bind(function(e){var n=0=n.length-1)return We.none();var e=n[t].fold(function(){var e=E(n.slice(0,t));return bo(e,function(e,n){return e.map(function(e){return{value:e,delta:n+1}})})},function(e){return We.some({value:e,delta:0})}),r=n[t+1].fold(function(){var e=n.slice(t+1);return bo(e,function(e,n){return e.map(function(e){return{value:e,delta:n+1}})})},function(e){return We.some({value:e,delta:1})});return e.bind(function(t){return r.map(function(e){var n=e.delta+t.delta;return Math.abs(e.value-t.value)/n})})}function Eo(e){var n=e.replace(/\./g,"-");return{resolve:function(e){return n+"-"+e}}}function No(e){var n=Be(e.parent(),"."+uu);h(n,Mn)}function Io(t,e,r){var o=t.origin();h(e,function(e,n){e.each(function(e){var n=r(o,e);Ro(n,uu),Bn(t.parent(),n)})})}function ko(e,n,t,r,o,i){var u=Ur(n);!function(e,n,r,o){Io(e,n,function(e,n){var t=iu(n.row(),r.left()-e.left(),n.y()-e.top(),o,7);return Ro(t,cu),t})}(e,0',r.insertBefore(o,r.firstChild)),""===u.align?Ac(t,r):Oc(t,r,u.align),t.focus(),t.addVisual()})}function Vi(n){return function(e){return We.from(e.dom.getParent(e.selection.getStart(),n)).map(on.fromDom)}}function Gi(u,c){return function(e){if(u(e)){var n=on.fromDom(e.target),t=function(){e.stopPropagation()},r=function(){e.preventDefault()},o=C(r,t),i=function(e,n,t,r,o,i,u){return{target:S(e),x:S(n),y:S(t),stop:r,prevent:o,kill:i,raw:S(u)}}(n,e.clientX,e.clientY,t,r,o,e);c(i)}}}function Yi(e,n,t,r){return function(e,n,t,r,o){var i=Gi(t,r);return e.dom().addEventListener(n,i,o),{unbind:b(la,e,n,i,o)}}(e,n,t,r,!1)}function Ki(e,n,t){return Yi(e,n,fa,t)}var Xi,$i=function(e){var n=lt(e);return dt.generate(n).grid()},Ji=function(){return(Ji=Object.assign||function(e){for(var n,t=1,r=arguments.length;t=n.length||e.column()>hu.cellLength(n[0]))return Su.error("invalid start address out of table bounds, row: "+e.row()+", column: "+e.column());var r=n.slice(e.row()),o=r[0].cells().slice(e.column()),i=hu.cellLength(t[0]),u=t.length;return Su.value({rowDelta:S(r.length-u),colDelta:S(o.length-i)})},Ru=function(e,n){var t=hu.cellLength(e[0]),r=hu.cellLength(n[0]);return{rowDelta:S(0),colDelta:S(t-r)}},Tu=function(e,n,t){var r=n.colDelta()<0?Vo:o;return(n.rowDelta()<0?qo:o)(r(e,Math.abs(n.colDelta()),t),Math.abs(n.rowDelta()),t)},Ou=function(e,n,t,r){if(0===e.length)return e;for(var o=n.startRow();o<=n.finishRow();o++)for(var i=n.startCol();i<=n.finishCol();i++)hu.mutateCell(e[o],i,Fn(r(),!1));return e},Du=function(e,n,t,r){for(var o=!0,i=0;i=e.left&&n<=e.right&&t>=e.top&&t<=e.bottom}function Ea(t,r,e,n,o){function i(e){var n=t.dom().createRange();return n.setStart(r.dom(),e),n.collapse(!0),n}var u=pt(r).length,c=function(e,n,t,r,o){if(0===o)return 0;if(n===r)return o-1;for(var i=r,u=1;un.right()}(t,e)})})}function al(n,t,e){var r=n.move(e,5),o=pf(t,n,e,r,100).getOr(r);return function(e,n,t){return e.point(n)>t.getInnerHeight()?We.some(e.point(n)-t.getInnerHeight()):e.point(n)<0?We.some(-e.point(n)):We.none()}(n,o,t).fold(function(){return t.situsFromPoint(o.left(),n.point(o))},function(e){return t.scrollBy(0,e),t.situsFromPoint(o.left(),n.point(o)-e)})}function ll(e,n){return function(e,n,t){return Xn(e,n,t).isSome()}(e,function(e){return be(e).exists(function(e){return he(e,n)})})}function fl(n,r,o,e,i){return Zn(e,"td,th",r).bind(function(t){return Zn(t,"table",r).bind(function(e){return ll(i,e)?Sf(n,r,o).bind(function(n){return Zn(n.finish(),"td,th",r).map(function(e){return{start:S(t),finish:S(e),range:S(n)}})}):We.none()})})}function sl(e,n){return Zn(e,"td,th",n)}var dl=function(n,t,e){function r(){l.stop(),u.isOn()&&(u.off(),i.trigger.stop())}var o=!1,i=aa.create({start:ca([]),stop:ca([])}),u=va(),c=function(t,r){var o=null;return{cancel:function(){null!==o&&(f.clearTimeout(o),o=null)},throttle:function(){for(var e=[],n=0;nr.left&&o.left ("+e.right()+", "+e.bottom()+")"}},ff=function(e,n,t){return nn(n)?ul(e,n).map(il):tn(n)?function(e,n,t){return 0<=t&&to.bottom()?df.retry(i):t.top()===o.bottom()?df.retry(lf.moveDown(o,1)):cl(e,n,o)?df.retry(lf.translate(i,5,0)):df.none()},move:lf.moveDown,gather:nl},pf=function(t,r,o,i,u){return 0===u?We.some(i):function(e,n,t){return e.elementFromPoint(n,t).filter(function(e){return"table"===j(e)}).isSome()}(t,i.left(),r.point(i))?function(e,n,t,r,o){return pf(e,n,t,n.move(r,5),o)}(t,r,o,i,u-1):t.situsFromPoint(i.left(),r.point(i)).bind(function(e){return e.start().fold(We.none,function(n){return sf(t,n).bind(function(e){return r.adjuster(t,n,e,o,i).fold(We.none,function(e){return pf(t,r,o,e,u-1)})}).orThunk(function(){return We.some(i)})},We.none)})},hf={tryUp:b(al,mf),tryDown:b(al,gf),ieTryUp:function(e,n){return e.situsFromPoint(n.left(),n.top()-5)},ieTryDown:function(e,n){return e.situsFromPoint(n.left(),n.bottom()+5)},getJumpSize:S(5)},vf=En.detect(),bf=function(r,o,i,u,c,a){return 0===a?We.none():Cf(r,o,i,u,c).bind(function(e){var n=r.fromSitus(e),t=nf.verify(r,i,u,n.finish(),n.foffset(),c.failure,o);return nf.cata(t,function(){return We.none()},function(){return We.some(e)},function(e){return he(i,e)&&0===u?wf(r,i,u,lf.moveUp,c):bf(r,o,e,0,c,a-1)},function(e){return he(i,e)&&u===bt(e)?wf(r,i,u,lf.moveDown,c):bf(r,o,e,bt(e),c,a-1)})})},wf=function(n,e,t,r,o){return ff(n,e,t).bind(function(e){return yf(n,o,r(e,hf.getJumpSize()))})},yf=function(e,n,t){return vf.browser.isChrome()||vf.browser.isSafari()||vf.browser.isFirefox()||vf.browser.isEdge()?n.otherRetry(e,t):vf.browser.isIE()?n.ieRetry(e,t):We.none()},Cf=function(n,e,t,r,o){return ff(n,t,r).bind(function(e){return yf(n,o,e)})},Sf=function(n,t,r){return function(o,i,u){return o.getSelection().bind(function(r){return uf(i,r.finish(),r.foffset(),u).fold(function(){return We.some(Zl(r.finish(),r.foffset()))},function(e){var n=o.fromSitus(e),t=nf.verify(o,r.finish(),r.foffset(),n.finish(),n.foffset(),u.failure,i);return cf(t)})})}(n,t,r).bind(function(e){return bf(n,t,e.element(),e.offset(),r,20).map(n.fromSitus)})},xf=En.detect(),Rf=function(e,n,t,r,o,i){return xf.browser.isIE()?We.none():i(r,n).orThunk(function(){return fl(e,n,t,r,o).map(function(e){var n=e.range();return _l.create(We.some(jl.makeSitus(n.start(),n.soffset(),n.finish(),n.foffset())),!0)})})},Tf=function(e,n,t,r,o,i,u){return fl(e,t,r,o,i).bind(function(e){return Hl.detect(n,t,e.start(),e.finish(),u)})},Of=function(e,r){return Zn(e,"tr",r).bind(function(t){return Zn(t,"table",r).bind(function(e){var n=Be(e,"tr");return he(t,n[0])?function(e,n,t){return $l(Ql,e,n,t)}(e,function(e){return Ct(e).isSome()},r).map(function(e){var n=bt(e);return _l.create(We.some(jl.makeSitus(e,n,e,n)),!0)}):We.none()})})},Df=function(e,r){return Zn(e,"tr",r).bind(function(t){return Zn(t,"table",r).bind(function(e){var n=Be(e,"tr");return he(t,n[n.length-1])?function(e,n,t){return Jl(Ql,e,n,t)}(e,function(e){return yt(e).isSome()},r).map(function(e){return _l.create(We.some(jl.makeSitus(e,0,e,0)),!0)}):We.none()})})};function Af(n){return function(e){return e===n}}function Ef(i){return{elementFromPoint:function(e,n){return on.fromPoint(on.fromDom(i.document),e,n)},getRect:function(e){return e.dom().getBoundingClientRect()},getRangedRect:function(e,n,t,r){var o=Dl.exact(e,n,t,r);return Ga(i,o).map(Mf)},getSelection:function(){return Va(i).map(function(e){return jl.convertToRange(i,e)})},fromSitus:function(e){var n=Dl.relative(e.start(),e.finish());return jl.convertToRange(i,n)},situsFromPoint:function(e,n){return Ya(i,e,n).map(function(e){return Ll(e.start(),e.soffset(),e.finish(),e.foffset())})},clearSelection:function(){!function(e){e.getSelection().removeAllRanges()}(i)},setSelection:function(e){!function(e,n,t,r,o){var i=_a(n,t,r,o);Ha(e,i)}(i,e.start(),e.soffset(),e.finish(),e.foffset())},setRelativeSelection:function(e,n){!function(e,n,t){var r=Wa(n,t);Ha(e,r)}(i,e,n)},selectContents:function(e){qa(i,e)},getInnerHeight:function(){return i.innerHeight},getScrollY:function(){return function(e){var n=e!==undefined?e.dom():f.document,t=n.body.scrollLeft||n.documentElement.scrollLeft,r=n.body.scrollTop||n.documentElement.scrollTop;return lo(t,r)}(on.fromDom(i.document)).top()},scrollBy:function(e,n){!function(e,n,t){(t!==undefined?t.dom():f.document).defaultView.scrollBy(e,n)}(e,n,on.fromDom(i.document))}}}function Nf(n,e){h(e,function(e){!function(e,n){Co(e)?e.dom().classList.remove(n):xo(e,n);To(e)}(n,e)})}var If={down:{traverse:Ce,gather:nl,relative:Tl.before,otherRetry:hf.tryDown,ieRetry:hf.ieTryDown,failure:nf.failedDown},up:{traverse:ye,gather:el,relative:Tl.before,otherRetry:hf.tryUp,ieRetry:hf.ieTryUp,failure:nf.failedUp}},kf=Af(38),Pf=Af(40),Bf={ltr:{isBackward:Af(37),isForward:Af(39)},rtl:{isBackward:Af(39),isForward:Af(37)},isUp:kf,isDown:Pf,isNavigation:function(e){return 37<=e&&e<=40}},Mf=function(e){return{left:e.left(),top:e.top(),right:e.right(),bottom:e.bottom(),width:e.width(),height:e.height()}},Wf=(En.detect().browser.isSafari(),P("rows","cols")),_f={mouse:function(e,n,t,r){var o=function c(o,i,n,u){function t(){r=We.none()}var r=We.none();return{mousedown:function(e){u.clear(i),r=sl(e.target(),n)},mouseover:function(e){r.each(function(r){u.clear(i),sl(e.target(),n).each(function(t){dr(r,t,n).each(function(e){var n=e.boxes().getOr([]);(1