text: /*
   Textbox.io JavaScript Library
   Copyright (c) 2013-2017 Ephox Corp. All rights reserved.
   This software is provided "AS IS," without a warranty of any kind.
  
   Version: 2.4.2.83
   Client Build: 2.4.2.131
  */
  (function(){function Ux(){return{major:"2",minor:"4",full:"2.4.2.83"}}function cT(){var a=g.none(),b=function(b){a=g.some(b.api)};return{add:function(c){var d=u(b,c);a.isNone()&&b(c);c.api.events.focus.addListener(d)},get:function(){return a},remove:function(b){a.is(b.api)&&(a=g.none())}}}function dT(a,b,c){var d=g.from(a.ui.editorName).map(J.error);c=c.map(J.value);d=d.or(c).getOrThunk(function(){return J.value(eT())});c=Vx.toolbar(a.platform.toolbar,b);b=Vx.mentions(a.mentions,b);return oa(a,{ui:{editorName:d},
  platform:{toolbar:c},mentions:b})}function fT(){var a=[];return{get:function(b){return qa(a,function(a){return a.is(b)})},findAll:function(b){var c=Ia.all(b);return ka(a,function(a){return Xa(c,a.is)})},add:function(b){a.push(b)},remove:function(b){Gc(a,b).each(function(b){a.splice(b,1)})}}}function Wx(a,b,c,d,e){return a(c,d)?g.some(c):qb(e)&&e(c)?g.none():b(c,d,e)}function Tb(a,b){z(b,function(b,d){if(d>a.length-1){if(b.required())throw Error('missing parameter "'+b.name()+'"');}else b.validate(a[d])})}
  function gT(a){var b=Ol.create(),c=eb(a,function(a){var c=hT.create();b.bind(a,c.eventTrigger);return c});a=eb(c,function(a){return a.eventRegistry});c=eb(c,function(a){return a.eventTrigger});return{registry:a,trigger:c,destroy:function(){b.unbindAll()}}}function iT(){var a={};return{getOrSetIndexed:function(b,c){if(void 0!==a[b])return a[b];c=c();return a[b]=c},waitForLoad:function(){var b=Ze(a);return Pl(b,Ea.nu)}}}function Xx(){var a=iT(),b=function(){return a.waitForLoad()};return{preload:function(){b().get(ca)},
  addStylesheet:function(b,d){return a.getOrSetIndexed(b,function(){return jT.download(b,d)})},addScript:function(b,d){return a.getOrSetIndexed(b,function(){return kT.download(b).map(d)})},waitForLoad:b}}function lT(a){var b=function(b,c,f){Tb(arguments,[ba.func("filter"),ba.string("selector"),ba.func("callback")]);var d=b(c,Yx(f));a.filter().customFilters().addFilter(d)},c=function(b,c,f){Tb(arguments,[ba.func("filter"),ba.func("predicate"),ba.func("callback")]);var d=b(mT(c),Yx(f));a.filter().customFilters().addFilter(d)};
  return{selector:{addInput:u(b,hj.inputSelector),addOutput:u(b,hj.outputSelector)},predicate:{addInput:u(c,hj.inputPredicate),addOutput:u(c,hj.outputPredicate)}}}function yq(a,b,c,d){return{term:function(){return new RegExp(a,d.getOr("g"))},prefix:b,suffix:c}}function nT(a,b,c){var d=Cb.sanitise(a),e=Cb.sanitise(b);return{patterns:function(){return[new RegExp(d+"(.*?)"+e,"gi")]},useCursor:Jb,generate:function(a,b){return c.generate(a,b.key(),b.value())},derive:function(a){var b=a[1];return c.get(b).map(function(c){return{startIndex:k(a.index),
  finishIndex:k(a.index+a[0].length),key:k(b),value:k(c)}})}}}function Zx(a,b,c){return nT(a,b,{get:function(a){a=c(a);return g.some(a)},generate:function(a,b,c){a=qe.fromHtml(c,a.dom());return Zd.species({elements:k(a),cursor:g.none,dictation:g.none,notify:g.none})}})}function $x(a,b){var c=function(a){try{return d(a)}catch(l){return g.none()}},d=function(b){return a(b)?g.from(b.dom().nodeValue):g.none()},e=aa.detect().browser,f=e.isIE()&&10===e.version.major?c:d;return{get:function(c){if(!a(c))throw Error("Can only get "+
  b+" value of a "+b+" node");return f(c).getOr("")},getOption:f,set:function(c,d){if(!a(c))throw Error("Can only set raw "+b+" value of a "+b+" node");c.dom().nodeValue=d}}}function nb(){return{up:k({selector:L.ancestor,closest:L.closest,predicate:Ja.ancestor,all:A.parents}),down:k({selector:Y.descendants,predicate:cd.descendants}),styles:k({get:v.get,getRaw:v.getRaw,set:v.set,remove:v.remove}),attrs:k({get:m.get,set:m.set,remove:m.remove,copyTo:function(a,b){a=m.clone(a);m.setAll(b,a)}}),insert:k({before:y.before,
  after:y.after,afterAll:P.after,append:y.append,appendAll:P.append,prepend:y.prepend,wrap:y.wrap}),remove:k({unwrap:F.unwrap,remove:F.remove}),create:k({nu:p.fromTag,clone:function(a){return p.fromDom(a.dom().cloneNode(!1))},text:p.fromText}),query:k({comparePosition:function(a,b){return a.dom().compareDocumentPosition(b.dom())},prevSibling:A.prevSibling,nextSibling:A.nextSibling}),property:k({children:A.children,name:D.name,parent:A.parent,isText:D.isText,isComment:D.isComment,isElement:D.isElement,
  getText:Ya.get,setText:Ya.set,isBoundary:function(a){return D.isElement(a)?"body"===D.name(a)?!0:U(oT,D.name(a)):!1},isEmptyTag:function(a){return D.isElement(a)?U(["br","img","hr","input"],D.name(a)):!1}}),eq:N.eq,is:N.is}}function pT(a,b,c){var d=gT({loaded:a.events.loaded,focus:a.events.focus,change:a.events.change,dirty:a.events.dirty,internal:a.events.internal}),e=function(a,b){var c=A.owner(a);a=A.defaultView(a);c=Za.get(c);b=b();a.dom().scrollTo(c.left(),c.top());return b},f=u(zq.getText,a),
  h=Ql.makeReadOnly({content:{documentElement:u(Fd.documentElement,a),insertHtmlAtCursor:u(Fd.insertHtmlAtCursor,a),uploadImages:u(Fd.uploadImages,a),get:u(Fd.get,a),set:u(Fd.set,a),isDirty:u(Fd.isDirty,a),setDirty:u(Fd.setDirty,a),selection:{findTagAtCursor:u(zq.findTagAtCursor,a),getText:f,getHtml:u(zq.getHtml,a)},getSelectedText:f},mode:{set:u(ay.set,a),get:u(ay.get,a)},filters:lT(a),macros:{addSimpleMacro:u(by.addSimpleMacro,a),removeMacro:u(by.removeMacro,a)},message:u(qT.message,a),events:d.registry,
  element:function(){return a.element().dom()},focus:a.focus,restore:Zb(function(){return e(a.element(),function(){rT.blur();var b=Fd.get(a);d.destroy();a.destroy();return c.restore(b)})})});z(b,function(a){Aq.hookup(h,a)});return h}function sT(){var a=cT(),b=fT(),c=function(a){return a.api},d=function(c,d){var e=dT(d.options(),function(){return f.getOrDie("Internal Error")},g.from(m.get(c,"id"))),f=tT.one(c,d.constructors(),e).map(function(d){var f=pT(d.polish,e&&e.plugins?e.plugins:[],{restore:function(c){b.remove(h);
  a.remove(h);return d.restore(c).dom()}}),h={is:function(a){return N.eq(c,a)},api:f};b.add(h);a.add(h);return f});return f};return{getOrCreate:function(a,f){return b.get(a).map(c).orThunk(function(){return d(a,f)})},get:function(a){a=b.findAll(a);return E(a,c)},getActiveEditor:a.get}}function Bq(a,b,c){var d=c||!1,e=function(){b();d=!0},f=function(){a();d=!1};return{on:e,off:f,toggle:function(){(d?f:e)()},isOn:function(){return d}}}function r(a){var b=O.apply(null,a),c=[];return{bind:function(a){if(void 0===
  a)throw"Event bind error: undefined handler";c.push(a)},unbind:function(a){c=ka(c,function(b){return b!==a})},trigger:function(){var a=b.apply(null,arguments);z(c,function(b){b(a)})}}}function cy(a,b){var c=function(c){var d=b(c);return 0>=d||null===d?(c=v.get(c,a),parseFloat(c)||0):d},d=function(a,b){return hb(b,function(b,c){c=v.get(a,c);c=void 0===c?0:parseInt(c,10);return isNaN(c)?b:b+c},0)};return{set:function(b,c){if(!$e(c)&&!c.match(/^[0-9]+$/))throw a+".set accepts only positive integer values. Value was "+
  c;b=b.dom();af.isSupported(b)&&(b.style[a]=c+"px")},get:c,getOuter:c,aggregate:d,max:function(a,b,c){a=d(a,c);return b>a?b-a:0}}}function Gd(a){return uT(a,function(){return{bind:t,unbind:t}})}function dy(a){a=na(a.dirty);var b=a.get,c=a.set,d=H.create({dirty:r([]),clean:r([])}),e=Hd.tap(function(a){var f=b();a!==f&&(c(a),!0===a?d.trigger.dirty():(e.control.block(),d.trigger.clean(),e.control.unblock()))});return{events:d.registry,isDirty:b,setDirty:e.instance,state:function(){return{dirty:b()}}}}
  function ey(a,b,c){var d=[],e=u(b,"input"),f=u(b,"output"),h=u(c,"input"),l=u(c,"output");b=function(a){hj.cata(a,e,f,h,l);d.push(a)};z(a.customs,b);return{state:function(){return{customs:d.slice(0)}},addFilter:b}}function Cq(a){var b={};Ma(a,function(a,d){b[d]=a});return{get:function(){return Ze(b)},add:function(a){var c=Fa("macro");b[c]=a;return c},remove:function(a){delete b[a]},state:function(){return ua({},b)}}}function vT(){var a=t;return Dq({setAutocorrect:t,setSpelling:t,events:Gd(["analytics"]),
  init:function(b){b.body().each(function(b){m.set(b,"spellcheck","false");a=function(){m.remove(b,"spellcheck")}})},ui:g.none,check:t,scanView:t,situation:Ig.noSituation,hasDropdown:k(!1),hasAutocorrect:k(!1),handle:t,assign:t,lock:xb,destroy:function(){a()},state:k({}),lookup:k(g.none()),name:k("spelling-disabled")})}function Q(a,b){var c=r(a),d=0,e=function(b){var d=E(a,function(a){return b[a]()});c.trigger.apply(null,d)};return{bind:function(a){c.bind(a);d++;1===d&&b.bind(e)},unbind:function(a){c.unbind(a);
  d--;0===d&&b.unbind(e)},trigger:yb("Cannot trigger a source event.")}}function fy(a,b,c){var d=Sa.state(c),e=g.none(),f=g.none(),h=H.create({loaded:r([]),focus:r([]),dirty:Q([],d.laundry.events.dirty),change:r([]),internal:r(["command","data"]),paint:r(["dimensions"])}),l=T.div();ma.add(l,[B.resolve("source-container"),"ephox-textbox-font",B.resolve("layer-editor")]);c=function(){return l};var q=function(){return f.getOrDie("CodeMirror not added to DOM")},C=function(a){return V()?gy.beautify(a):a},
  w=function(a){var b=q().doc;a=C(a);b.setValue(a);b.clearHistory()},I=function(a){var b=p.fromDom(a.getWrapperElement()),c=-1;a.on("changes",function(){var d=a.doc.lineCount();d!=c&&(c=d,d=a.getScrollInfo(),d=hy({width:Ga.get(b),docWidth:d.width,height:d.height,docHeight:d.height}),h.trigger.paint(d))})},G=function(){q().focus()},V=function(){return!0===a.content.prettyprint};return jj.internal({activateInline:Id.activateInline,blur:yb("blur is not supported in the API."),communication:Sa.communication,
  connect:function(c){if(a.content&&!0===a.content.autoresize){var d=c.dom().clientHeight;sa.set(l,d)}y.append(c,l);b.updateUi(l);kj.detect(l);c=Rl.use.codemirror()(l.dom(),{mode:"text/html",extraKeys:{"Ctrl-Space":"autocomplete"},lineWrapping:!0});c.on("focus",function(){h.trigger.focus()});f=g.some(c);h.trigger.loaded();I(c);return!0},content:k({body:k(g.none()),doc:yb("content.doc is not supported in code view"),execCommand:yb("content.execCommand is not supported in code view"),getSelectedText:function(){var a=
  q().getSelection();return void 0!==a&&null!==a&&0<a.length?g.some(a):g.none()},focus:G,isInline:k(!1)}),deactivateInline:Id.deactivateInline,destroy:function(){F.remove(l);F.empty(l);f=g.none()},element:c,events:h.registry,filter:d.filter,focus:G,fromTransfer:function(a){var b=function(a){w(a);e=g.some(a);f.each(function(a){a.on("changes",function(a,b){d.laundry.setDirty(!0);h.trigger.change()})})};Jf.cata(a,b,b)},fullscreen:Sa.fullscreen,getContent:function(){return q().doc.getValue()},getMode:hc.code,
  insertHtmlAtCursor:function(a){q().replaceSelection(a)},isDirty:d.laundry.isDirty,isPrettyPrinting:V,keyboard:Id.keyboard,macros:d.macros,operations:Id.operations,setContent:function(a){w(a);d.laundry.setDirty(!1)},setDirty:d.laundry.setDirty,smartview:Id.smartview,state:function(){return d.getState({content:{}})},toTransfer:function(){var a=q().doc.getValue();return e.filter(function(b){return C(b)===a}).fold(function(){return Jf.changed(a)},Jf.unchanged)},ui:Id.ui,undo:k(Sa.undo()),uploader:k(Sa.uploader()),
  viewport:c})}function xT(a){var b=T.span();n.add(b,va.resolve("toolbar-group"));var c=E(a,function(a){return a.component()});P.append(b,c);return iy.group({component:function(){return b},isVisible:function(){return Xa(c,lj.isShowing)},refreshUi:function(){z(a,function(a){a.refreshUi()})},destroy:function(){z(a,function(a){a.destroy()})}})}function Fq(a,b,c){n.add(a,lb.resolve("button"));var d=yT.disable(a);b=b.getOr(a);var e=null,f=n.toggler(a,lb.resolve("button-disabled")),h=function(){f.isOn()||
  q.trigger.click()},l=K.bind(b,"click",h),q=H.create({click:r([])});return{element:function(){return a},name:function(){return c},destroy:function(){l.unbind();d.unbind();F.remove(a)},content:function(b){null!==e&&F.remove(e.element());y.append(a,b.element());e=b},enable:f.off,disable:f.on,disabled:f.isOn,click:h,events:q.registry}}function Nc(a){var b=p.fromTag("span");n.add(b,lb.resolve("independent-button"));return Fq(b,g.none(),a)}function bf(a){var b=T.span();m.set(b,"aria-hidden",!0);ma.add(b,
  [lb.resolve("icon-content")].concat(a));return{element:function(){return b},destroy:function(){F.remove(b)}}}function Gq(a){var b=T.span();n.add(b,lb.resolve("statebutton"));var c=Fq(T.span(),g.some(b),a);n.add(c.element(),lb.resolve("dependent-button"));y.append(b,c.element());a=n.toggler(b,lb.resolve("statebutton-selected"));var d=n.toggler(b,lb.resolve("statebutton-disabled"));return{element:function(){return b},destroy:function(){c.destroy();F.remove(b)},name:c.name,content:c.content,enable:function(){d.off();
  c.enable()},disable:function(){d.on();c.disable()},disabled:function(){return d.isOn()&&c.disabled()},click:c.click,events:c.events,select:a.on,deselect:a.off,selected:a.isOn}}function $d(a){var b=Gq(a),c=H.create({click:r([])}),d=function(){b.selected()?b.deselect():b.select();c.trigger.click()};b.events.click.bind(d);return{element:b.element,name:b.name,content:b.content,destroy:function(){b.events.click.unbind(d);b.destroy()},enable:b.enable,disable:b.disable,disabled:b.disabled,click:b.click,
  events:c.registry,select:b.select,deselect:b.deselect,selected:b.selected}}function zT(a){var b=T.span();n.add(b,lb.resolve("dropbutton"));var c=T.span();n.add(c,lb.resolve("dropbutton-button"));var d=T.span();n.add(d,lb.resolve("dropbutton-arrow"));P.append(b,[c,d]);var e=Nc(),f=$d();f.content(bf(["ephox-pastry-arrow-icon"]));y.append(c,e.element());y.append(d,f.element());var h=H.create({click:r([]),open:r([]),close:r([])}),l=function(){h.trigger.click()},q=function(){(f.selected()?h.trigger.open:
  h.trigger.close)()};e.events.click.bind(l);f.events.click.bind(q);return{element:function(){return b},name:function(){return a},content:e.content,events:h.registry,open:function(){f.select();h.trigger.open()},close:function(){f.deselect();h.trigger.close()},destroy:function(){e.events.click.unbind(l);f.events.click.unbind(q);e.destroy();f.destroy();F.remove(b)},isOpen:function(){return f.selected()}}}function AT(a){var b=T.span();n.add(b,lb.resolve("dropbutton"));var c=T.span();n.add(c,lb.resolve("dropbutton-button"));
  var d=T.span();n.add(d,lb.resolve("dropbutton-arrow"));P.append(b,[c,d]);var e=$d(),f=$d();f.content(bf(["ephox-pastry-arrow-icon"]));y.append(c,e.element());y.append(d,f.element());var h=H.create({click:r([]),open:r([]),close:r([])}),l=function(){h.trigger.click()},q=function(){(f.selected()?h.trigger.open:h.trigger.close)()};e.events.click.bind(l);f.events.click.bind(q);return{element:k(b),name:k(a),content:e.content,events:h.registry,open:function(){f.select();h.trigger.open()},close:function(){f.deselect();
  h.trigger.close()},destroy:function(){e.events.click.unbind(l);f.events.click.unbind(q);e.destroy();f.destroy();F.remove(b)},isOpen:function(){return f.selected()},click:e.click,enable:e.enable,disable:e.disable,disabled:e.disabled,select:e.select,deselect:e.deselect,selected:e.selected}}function Qc(a){var b=T.span();n.add(b,lb.resolve("text-content"));y.append(b,p.fromText(a));return{element:function(){return b},destroy:function(){F.remove(b)}}}function Sl(a){var b=re.resolve(a);return{set:function(a){n.add(a,
  b)},up:function(a){return n.has(a,b)?g.some(a):L.ancestor(a,"."+b)},all:function(a){return Y.descendants(a,"."+b)},first:function(a){return L.descendant(a,"."+b)},is:function(a){return n.has(a,b)}}}function jy(a,b){b=void 0!==b?b:"info";var c=T.div();ma.add(c,[B.resolve("banner"),B.resolve("banner-"+b)]);b=T.div();n.add(b,B.resolve("banner-message"));y.append(b,p.fromText(a));var d=T.div();n.add(d,B.resolve("banner-buttons"));a=p.fromTag("span");n.add(a,B.resolve("banner-close"));y.append(d,a);S.button(a,
  x.translate("banner.close"));P.append(c,[b,d]);var e=K.bind(a,"click",function(){f.trigger.close()}),f=H.create({close:r([])});return{element:function(){return c},action:function(a){y.prepend(d,a.element())},destroy:function(){e.unbind();F.remove(c)},events:f.registry}}function mj(a,b){b=void 0!==b?b:"error";var c=a.description();a=a.link();var d=jy(c,b),e=g.none(),f=function(a,b){return K.bind(a,"click",function(a){a.kill();window.open(b.url())})};b=function(a){var b=p.fromTag("a");m.set(b,"href",
  a.url());m.set(b,"target","_blank");var c=p.fromText(a.text());e=g.some(f(b,a));y.append(b,c);d.action({element:k(b)})};null!==a&&a.url()&&a.text()&&b(a);return{element:d.element,action:d.action,destroy:function(){d.destroy();e.each(function(a){a.unbind()})},events:d.events}}function BT(a,b){var c=H.create({populate:r(["items"])}),d=function(b){var c=a(b.textkey);c=zb.item(CT,b.name+"-menu-trigger",c);n.add(c,va.resolve("menu-more"));b=nj.generate("ephox-chameleon-"+b.name);P.prepend(c,b);S.menuItem(c,
  g.none(),g.some(!0));return c}(b),e=function(a){a=p.fromText(a);f(a)},f=function(a){L.child(d,".ephox-gopher-item-text").each(function(b){F.empty(b);y.append(b,a);n.remove(b,ky)})},h=Eh.control(d);return{element:k(d),populate:function(a){c.trigger.populate(a)},select:function(c){L.child(d,ib.tokenSelector()).each(F.remove);var f=ib.describe(d,b.describe(c));y.append(d,f);c=a(c.textkey());e(c)},selectElement:f,disable:h.disable,enable:h.enable,clear:function(){e(a(b.textkey));L.child(d,".ephox-gopher-item-text").each(function(a){n.add(a,
  ky)})},destroy:function(){F.remove(d)},events:c.registry}}function DT(a,b){var c=b?a.slice(0):[],d=b,e=b?E(Ze(R),function(a){return a()}):[];return{swallowShortcuts:function(a){c=a.slice(0)},yieldShortcuts:function(a){c=Hq(c,a)},swallowChars:function(){d=!0},yieldChars:function(){d=!1},swallowKeys:function(a){e=a.slice(0)},yieldKeys:function(a){e=Hq(e,a)},process:function(a,b){a.fold(function(a){U(c,a)&&b()},function(a){U(e,a)&&b()},function(){d&&b()})}}}function ET(a,b){var c=!1,d=DT(a,b);return{on:function(){c=
  !0},off:function(){c=!1},isOn:function(){return c},handle:function(a){return function(b){c&&a(b.raw())}},stop:function(b){var c=FT.identify(b,a);d.process(c,u(ly.stop,b))},swallowShortcuts:d.swallowShortcuts,yieldShortcuts:d.yieldShortcuts,swallowChars:d.swallowChars,yieldChars:d.yieldChars,swallowKeys:d.swallowKeys,yieldKeys:d.yieldKeys}}function oj(a){var b=ua({shortcuts:[],swallow:!1},a),c=H.create({character:r(["character"]),space:r(["shift","stopper"]),left:r(["shift","stopper"]),right:r(["shift",
  "stopper"]),backspace:r(["shift","stopper"]),tab:r(["shift","stopper"]),enter:r(["shift","stopper"]),capslock:r(["shift","stopper"]),escape:r(["shift","stopper"]),pageup:r(["shift","stopper"]),pagedown:r(["shift","stopper"]),end:r(["shift","stopper"]),home:r(["shift","stopper"]),down:r(["shift","stopper"]),up:r(["shift","stopper"]),insert:r(["shift","stopper"]),del:r(["shift","stopper"]),command:r(["command"])}),d=ET(b.shortcuts,b.swallow),e=function(a){return qa(b.shortcuts,function(b){return my.isCommand(a,
  b)})},f=function(a,b,d){l(a);c.trigger[b].apply(void 0,d)},h=function(a){return function(){d.isOn()&&ly.stop(a)}};a=d.handle(function(a){e(a).fold(function(){var b=Jg.getSpecial(a.keyCode);Jg.noModifiers(a)&&null!==b&&(b=b.toLowerCase(),f(a,b,[a.shiftKey,h(a)]))},function(b){f(a,"command",[b])})});var l=function(a){d.isOn()&&d.stop(a)},q=d.handle(function(a){if(Jg.noModifiers(a))Jg.isCharCode(a)||null===Jg.getSpecial(a.keyCode)?e(a).isSome()?l(a):a.which&&f(a,"character",[String.fromCharCode(a.which)]):
  l(a);else return!1});return{off:d.off,on:d.on,events:c.registry,swallowShortcuts:d.swallowShortcuts,yieldShortcuts:d.yieldShortcuts,swallowChars:d.swallowChars,yieldChars:d.yieldChars,swallowKeys:d.swallowKeys,yieldKeys:d.yieldKeys,keypress:q,keydown:a}}function GT(a){var b=H.create({mouseover:r(["item"]),click:r(["item"])}),c=[],d=oj({shortcuts:a.shortcuts,swallow:a.swallow});a=a.tabs?[R.TAB()]:[];d.swallowKeys([R.UP(),R.DOWN(),R.ENTER(),R.SPACE(),R.ESCAPE()].concat(a));var e=function(){z(c,function(a){a.mouseover().unbind();
  a.click().unbind();a.keydown().unbind()});c=[];d.off()};return{destroy:function(){e()},attach:function(a){e();c=E(a,function(a){var c=K.bind(a,"mouseover",function(a){Hc.up(a.target()).each(b.trigger.mouseover)}),e=K.bind(a,"click",function(a){Hc.up(a.target()).each(b.trigger.click)});a=K.bind(a,"keydown",function(a){d.keydown(a)});return{mouseover:k(c),click:k(e),keydown:k(a)}});d.on()},detach:e,simulateKey:function(a){d.keydown(a)},events:b.registry,keys:d.events}}function HT(a,b){var c=H.create({select:r(["item"]),
  active:r(["item"]),show:r(["menu"]),hide:r(["menu"]),collapse:r(["menu"]),expand:r(["menu","trigger"]),escaped:r([])}),d=GT({shortcuts:[],swallow:[],tabs:b.tabs}),e={},f=function(b){Jd.activate(a,b)},h=function(){var b=Jd.inactive(a);z(b,function(a){Kf.submenu().is(a)&&c.trigger.hide(a)})},l=function(b){Hc.isEnabled(b)&&Jd.submenu(a,e,b).each(function(a){c.trigger.expand(a,b)})},q=function(a){Jd.up(a).each(function(b){f(b);Kd.selectAll(b,[a]);c.trigger.active(a)})},C=function(b){Jd.active(a).bind(function(a){Kd.selected(a).orThunk(function(){return Iq.first(a)}).each(function(c){b(a,
  c)})})},w=function(a){C(function(b,c){Hc.isEnabled(c)&&a(b,c)})},g=function(b){C(function(d,f){b(d,f).each(function(b){N.eq(f,b)||(Jd.submenu(a,e,f).each(c.trigger.collapse),c.trigger.active(b))})})},G=u(g,Iq.prev),V=u(g,Iq.next),X=function(){Kf.main().first(a).each(function(a){f(a);Kd.selected(a).each(c.trigger.active)})},dd=function(b){Z.active().fold(b.stopper(),function(a){!1===U(["input"],D.name(a))&&b.stopper()()});w(function(b,d){Jd.submenu(a,e,d).fold(function(){Kf.submenu().is(b)&&(c.trigger.collapse(b),
  X())},function(a){c.trigger.expand(a,d);Kd.none(a);Kd.first(a).each(c.trigger.active);f(a)})})};g=function(a){Z.active().fold(a.stopper(),function(b){!1===U(["input"],D.name(b))&&a.stopper()()});w(function(a,b){Kf.submenu().is(a)&&(c.trigger.collapse(a),X())})};var m=function(a){w(function(b,d){b=Hc.get(d);e.hasOwnProperty(b)&&void 0!==e[b]?dd(a):c.trigger.select(d)})},n=function(a){a.shift()?G(a):V(a)};d.keys.up.bind(G);d.keys.down.bind(V);b.tabs&&d.keys.tab.bind(n);d.keys.enter.bind(m);d.keys.space.bind(m);
  d.keys.escape.bind(function(a){a.stopper()();C(function(a,b){Kf.submenu().is(a)?(c.trigger.collapse(a),X()):c.trigger.escaped()})});"ltr"===ae.getDirection(a)?(d.keys.left.bind(g),d.keys.right.bind(dd)):(d.keys.right.bind(g),d.keys.left.bind(dd));d.events.mouseover.bind(function(b){b=b.item();Kd.is(b)&&Jd.submenu(a,e,b).forall(sc.isVisible)||(q(b),h(),l(b))});d.events.click.bind(function(a){a=a.item();var b=Hc.get(a);e.hasOwnProperty(b)&&void 0!==e[b]||!Hc.isEnabled(a)||c.trigger.select(a)});return{destroy:function(){d.destroy()},
  populate:function(a){e=ua({},a)},on:function(a){a=void 0!==a?a:[p.fromDom(document)];d.attach(a)},off:function(){d.detach()},selectFirst:function(){Jd.active(a).each(function(a){Kd.none(a);Kd.first(a).each(c.trigger.active)})},select:function(a){q(a);h()},setActiveMenu:f,simulateKey:d.simulateKey,state:function(){return Jd.active(a).bind(function(a){return Kd.selected(a).map(function(b){return{menu:k(a),item:k(b)}})})},events:c.registry}}function Jq(a,b,c){var d=T.div();n.add(d,va.resolve("menu-"+
  b()+"-sandbox"));m.set(d,"tabindex",-1);y.append(a(),d);var e=g.none(),f=HT(d,{tabs:!0}),h=na({}),l=function(){f.off();w();C.trigger.close()},q=function(a){var b=Lf(h.get(),O("submenu","item")),c=m.get(a,"data-ephox-gopher-menu-value");return qa(b,function(a){return a.submenu()===c}).bind(function(b){return L.descendant(d,"[data-ephox-gopher-item-value="+b.item()+"]").map(function(b){return{menu:k(a),item:k(b)}})})};a=function(a){var b=q(a.menu()).map(function(a){return a.item()});C.trigger.collapse(a.menu(),
  b)};var C=H.create({open:r([]),close:r([]),itemAction:r(["value","item"]),itemHover:Q(["item"],f.events.active),reveal:Q(["menu","trigger"],f.events.expand),collapse:r(["menu","item"]),escaped:Q([],f.events.escaped)});f.events.hide.bind(a);f.events.collapse.bind(a);f.events.escaped.bind(function(){f.state().fold(l,function(a){q(a.menu()).fold(function(){l()},function(a){C.trigger.collapse(a.menu(),g.some(a.item()));f.select(a.item())})})});f.events.select.bind(function(a){a=a.item();var b=m.get(a,
  "data-ephox-gopher-item-value");C.trigger.itemAction(b,a)});f.events.active.bind(function(a){c.focusActive()&&Z.focusInside(a.item())});var w=function(){Ma(h.get(),function(a,b){L.descendant(d,'[data-ephox-gopher-menu-value="'+a+'"]').each(function(a){var c=L.descendant(d,'[data-ephox-gopher-item-value="'+b+'"]');C.trigger.collapse(a,c)})})};return{update:function(a){h.set(a);f.populate(a)},setActiveMenu:function(a){e=g.from(a);f.setActiveMenu(a);f.selectFirst()},getActiveMenu:function(){return e},
  structure:h,destroy:function(){l();f.destroy()},open:function(a,b){Z.focus(b);f.on(a);C.trigger.open()},close:l,events:C.registry,sandbox:k(d),select:f.select,simulateKey:f.simulateKey}}function Fh(a,b){return{southeast:k(Qa(-a,b)),southwest:k(Qa(a,b)),northeast:k(Qa(-a,-b)),northwest:k(Qa(a,-b))}}function Tl(){return{northwest:function(){return Qa(-2,1)},northeast:function(){return Qa(0,1)},southwest:function(){return Qa(-2,-2)},southeast:function(){return Qa(0,-2)}}}function ny(a,b,c){c=c||[p.fromDom(document)];
  var d=[],e=function(c){var d=b();c=c.target();N.member(c,d)||IT.anyAncestor(c,d)||a(c)};return{on:function(){z(c,function(a){d.push(K.bind(a,"mousedown",e).unbind)})},off:function(){z(d,xb)},mousedown:e}}function JT(a){var b=ua({layerClass:null,zindex:null},a),c=T.div();n.add(c,lb.resolve("panel"));v.setAll(c,{position:"fixed",display:"none",top:"0px"});b.zindex&&v.set(c,"z-index",b.zindex);b.layerClass&&n.add(c,b.layerClass);a=void 0!==a.container?a.container:L.first("body").getOrDie();y.append(a,
  c);a=sc.displayToggler(c,"block");return{element:function(){return c},destroy:function(){F.remove(c)},content:function(a){F.empty(c);y.append(c,a)},show:a.on,hide:a.off,toggle:a.toggle}}function pj(a,b,c,d,e){var f=[],h=function(){var a=E(f,function(a){return a.popup().panel()}).concat(d);z(f,function(b){b.popup().setComponents(a)})},l=function(a){var b=Ul.get(f,a,Vl(a)).fold(function(){return C(a)},function(a){return a.popup()});h();f=Ul.put(f,a,b,oy,Vl(a));return b},q=function(a){Ul.get(f,a,Vl(a)).each(function(a){a.popup().close()});
  v.set(a,"display","none")},C=function(b){var c=KT.create(a,e);c.setContent(b);f=Ul.put(f,b,c,oy,Vl(b));h();return c};return{initMenu:C,registerMenus:function(a){f=LT.triage(f);return E(a,l)},hideAll:function(){z(f,function(a){q(a.menu())})},hideMenu:q,expandMenu:function(d,e){var f=l(d),h=Db.descendant(d,"."+Wl.styles())?cf.expandable():cf.anchored();e=Kg.submenu(a,b,k(e),c.uiDirection(),h);v.set(d,"display","block");f.open();e.recalculate(f);return{popup:f,anchorage:e}}}}function py(a,b){var c=T.span();
  ma.add(c,[lb.resolve("righticon-content"),b]);y.append(c,a);return{element:function(){return c},destroy:function(){F.remove(c)}}}function MT(a,b){var c=Qc(a),d=py(c.element(),b);return{element:d.element,destroy:function(){c.destroy();d.destroy()}}}function NT(a,b,c,d,e,f,h,l,q,C){var w=$d(c);h=Kq.control(w);ma.add(w.element(),[va.resolve("dropdown-button"),va.resolve(c+"-dropdown-button")]);m.set(w.element(),"title",l(d));S.toolbarButton(w.element(),l(d),!0,q);var g=Jq(a.uiContainer,k("dropdown-"+
  c),qj.menu({focusActive:!0})),G=p.fromDom(document),V=zb.mainmenu(G,c+"-menu",[]),X=pj(g.sandbox,a.bounds,b,[w.element()],C).initMenu(V);c=Tl();var dd=Kg.main(a.uiContainer,a.bounds,w.element,c,b.uiDirection(),cf.anchored());S.menu(V,l(e));var Eq=Fa("menu-control");m.set(V,"id",Eq);S.controls(w.element(),Eq);var ij=T.span();n.add(ij,va.resolve("dropdown-viewport"));w.content({element:k(ij)});var Dh=function(a,b){b=b.map(nj.generate).getOr([]);P.prepend(a,b)};b=function(){v(l(d))};var v=function(a){F.empty(ij);
  y.append(ij,MT(a,"ephox-pastry-arrow-righticon").element())},x=function(){w.deselect();q&&ra.pressed(w);ra.collapsed(w.element());S.disown(w.element());X.close();g.close()},A=function(){w.select();q&&ra.pressed(w);ra.expanded(w.element());S.owns(w.element(),Eq);X.open();var b=[a.uiContainer()];g.open(b,w.element())},qy=H.create({select:Q(["value","item"],g.events.itemAction),itemHover:Q(["item"],g.events.itemHover),escaped:Q([],g.events.escaped),open:r(["menu","popup","anchor"]),close:Q([],g.events.close)});
  w.events.click.bind(function(){(w.selected()?A:x)()});X.events.close.bind(x);g.events.open.bind(function(){qy.trigger.open(V,X,dd);g.update({});OT()||g.setActiveMenu(V)});g.events.escaped.bind(x);b();return{element:k(w.element()),menu:X.element,list:k(V),click:w.click,populate:function(a){F.empty(V);z(a,function(a){a.label().each(function(a){a=Xl.generateSeparator(G,a,l);y.append(V,a)});z(a.items(),function(a){var b=Xl.generateItem(G,a,f,l);S.menuItemCheckbox(b);Dh(b,a.icon());y.append(V,b)})})},
  enable:h.enable,disable:h.disable,close:x,uiStale:X.uiStale,recalculate:function(){dd.recalculate(X)},clear:b,select:function(a){v(l(a.textkey()));Dh(ij,a.icon())},selectElement:function(a){a=py(a,"ephox-pastry-arrow-righticon");w.content({element:a.element,destroy:t})},tick:u(Gh.tick,V),untick:u(Gh.untick,V),activate:u(Gh.activate,w.element()),deactivate:u(Gh.deactivate,w.element()),destroy:function(){g.destroy();w.destroy()},events:qy.registry}}function PT(a){var b=ry.menu(a);return{widget:b.widget,
  menu:b.menu,general:b.general,"inline-widget":function(a){return b["inline-widget"]({instance:function(){return a.instance(Lq.menu())}})},"split-widget":b["split-widget"],dropdown:b.dropdown,palette:b.palette}}function QT(a,b,c,d,e,f,h){var l=ry.toolbar(f,c,h,Lg.editorContainer()),q=function(q){return u(q,l,a,b,c,d,e,f,h)};return{widget:q(Mq.widget),"inline-widget":q(Mq.inlineWidget),"split-widget":q(Mq.splitWidget),cards:l.cards,general:q(RT.init),dropdown:q(ST.init),menu:q(TT.init),palette:l.palette}}
  function UT(a){var b=Gq("overflower");n.add(b.element(),va.resolve("more-button"));b.content(Qc(a("toolbar.more")));var c=Mf.onButton(b);m.set(b.element(),"tabindex","-1");a=a("aria.label.more");m.set(b.element(),"title",a);var d=Mg.aria(b,a,!0,!0),e=Nq.toolbar([{component:b.element,destroy:b.destroy,refreshUi:t}]);return{group:e.component,select:function(){b.select();d.press()},deselect:function(){d.release();b.deselect()},focus:function(){Z.focus(b.element())},destroy:function(){c.unbind();d.destroy();
  e.destroy()},events:b.events}}function sy(a){var b=[];return{add:function(c,d){d=d?a.indexOf(b,d).getOrDie():b.length;b.splice(d,0,c);return ty(c,d)},remove:function(c){var d=a.resolve(b,c).getOrDie();return Gc(b,d).bind(function(a){b.splice(a,1);return ty(d,a)})},get:function(){return b.slice(0)},itemAt:function(c){return a.resolve(b,c)}}}function uy(a){var b=function(a,b){return $e(b)?c(a,b):xa(b)?d(a,b):ic(b)?e(a,b):J.error("Unsupported specifier type: "+b)},c=function(a,b){return 0===a.length?
  J.error("Items is empty"):0>b||b>=a.length?J.error("Item index: "+b+" is out of range (0-"+(a.length-1)+")"):J.value(a[b])},d=function(b,c){return qa(b,function(b){return a(b)===c}).fold(function(){return J.error("No item with value: ["+c+"]")},function(a){return J.value(a)})},e=function(a,b){return Gc(a,b).fold(function(){return J.error("Specified object is not a registered item: "+b)},function(a){return J.value(b)})};return{resolve:b,indexOf:function(a,c){return b(a,c).bind(function(b){return Gc(a,
  b).fold(function(){return J.error("Item not found: "+c)},function(a){return J.value(a)})})},index:c,value:d,item:e}}function VT(a,b){b=H.create({grow:r([]),shrink:r([]),exit:r([])});var c=sy(uy(ca)),d=p.fromTag("div");v.set(d,"overflow-x","auto");n.add(d,va.resolve("toolstrip"));S.toolbarGroup(d);var e=p.fromTag("div");ma.add(e,[va.resolve("toolbar"),va.resolve("toolbar-primary")]);var f=p.fromTag("div");ma.add(f,[va.resolve("toolbar"),va.resolve("toolbar-more")]);y.append(d,e);y.append(d,f);var h=
  function(){var a=c.get();return ia(a,function(a){return a.isVisible()?[a.component()]:[]})},l=function(){var b=h();b=a.build(b);F.empty(e);F.empty(f);P.append(e,b);v.reflow(e)};return{element:function(){return d},main:k(e),mores:k(f),destroy:function(){var a=c.get();z(a,function(a){a.destroy()})},focused:ed,enter:t,restore:t,refocus:t,refresh:u(Hh.preserve,l,d),repaint:u(Hh.preserve,l,d),add:function(a){c.add(a)},events:b.registry}}function vy(a){Oq(a);var b=!1,c=K.bind(a,"transitionend",function(c){"height"===
  c.raw().propertyName&&(ma.remove(a,[wy,xy]),b&&v.remove(a,"height"))});return{visible:function(){return b},hide:function(){b=!1;Pq(a,sa.get(a));n.add(a,xy);Oq(a)},show:function(){yy(a);var c=sa.get(a);Oq(a);n.add(a,wy);yy(a);Pq(a,c);b=!0},destroy:function(){c.unbind()}}}function WT(a,b){var c=H.create({grow:r([]),shrink:r([]),exit:r([])}),d=sy(uy(ca)),e=p.fromTag("div");S.toolbarGroup(e);n.add(e,va.resolve("toolstrip"));var f=p.fromTag("div");ma.add(f,[va.resolve("toolbar"),va.resolve("toolbar-primary")]);
  var h=p.fromTag("div");ma.add(h,[va.resolve("toolbar"),va.resolve("toolbar-more")]);y.append(e,f);y.append(e,h);var l=vy(h);b.events.click.bind(function(){l.visible()?(l.hide(),b.deselect(),c.trigger.shrink()):(l.show(),b.select(),c.trigger.grow())});var q=function(){var a=d.get();return ia(a,function(a){return a.isVisible()?[a.component()]:[]})},C=function(){a.update();var c=q();c=a.build(c);v.set(f,"visibility","hidden");a.clearWidth();F.empty(f);P.append(f,c);var d=a.width(f);y.append(f,b.group());
  c=XT.partition(d,c,Ga.getOuter,b.group());d=c.extra();var e=c.within();F.empty(f);F.empty(h);P.append(f,e);P.append(h,d);a.updateWidth(b,c);v.remove(f,"visibility")},w=function(){Hh.preserve(C,e)};return{element:function(){return e},main:k(f),mores:k(h),destroy:function(){var a=d.get();z(a,function(a){a.destroy()});b.destroy();l.destroy()},focused:ed,enter:t,restore:t,refocus:t,refresh:w,repaint:function(){a.shouldRefresh()&&w()},add:function(a){d.add(a)},events:c.registry}}function Nf(a,b,c){var d=
  K.bind(a,"keydown",c.getOr(function(a){qa(b,function(b){return b.matches(a)}).each(function(b){b.run(a).each(function(b){a.kill()})})})),e=H.create({enter:r([]),exit:r([])});return fd({isFocused:u(fb.isFocused,a),element:k(a),clear:t,enter:function(){fb.set(a);e.trigger.enter()},refresh:t,isEnabled:Jb,exit:function(){e.trigger.exit()},events:e.registry,destroy:function(){d.unbind()}})}function Qq(a,b){var c=Nf(a,[ea.rule(ea.inSet(R.SPACE().concat(R.ENTER())),function(){b.execute()(a);return g.some(!0)})],
  b.process());return fd({element:c.element,destroy:c.destroy,clear:c.clear,isFocused:c.isFocused,isEnabled:Jb,refresh:t,enter:c.enter,exit:c.exit})}function rj(a,b){var c=u(b,-1,0),d=u(b,1,0),e=ae.onDirection(c,d);d=ae.onDirection(d,c);c=u(b,0,-1);b=u(b,0,1);var f=function(b){return b(a)()};e=u(f,e);d=u(f,d);return{west:e,east:d,north:c,south:b}}function YT(a,b){var c=UT(b),d=aa.detect().deviceType.isTouch()?VT(a,c):WT(a,c);S.toolbar(d.main(),b("aria.label.toolbar"));S.group(d.mores());var e=H.create({drawer:Q(["delta",
  "total"],d.events.drawer),grow:Q([],d.events.grow),shrink:r([]),transitionend:r(["property"]),exit:r([])}),f=K.bind(d.element(),"transitionend",function(a){e.trigger.transitionend(a.raw().propertyName)}),h=g.none();a=Ba.sectors({first:g.none,trigger:Mf.trigger});var l=ha.sectors(d.element(),ZT,a);l.events.exit.bind(function(){h=g.none();e.trigger.exit()});l.events.active.bind(function(a){h=g.some(a.element())});var q=function(){return l.isFocused()},C=function(){h.each(Z.focus)};d.events.shrink.bind(function(){Z.search(d.mores()).isSome()&&
  c.focus();e.trigger.shrink()});return{element:d.element,refresh:d.refresh,repaint:d.repaint,add:d.add,enter:function(){l.enter()},destroy:function(){l.exit();h=g.none();f.unbind();d.destroy();l.destroy()},focused:q,restore:C,refocus:function(){q()&&C()},events:e.registry}}function $T(){var a=T.div();n.add(a,B.resolve("bannerarium"));n.add(a,B.resolve("layer-above-editor"));var b=g.some([]),c=Ol.create(),d=function(a){b=b.bind(function(b){b=ka(b,function(b){return b!==a});return g.some(b)});e(a)},
  e=function(a){a.destroy();c.unbind(a.events.close);F.remove(a.element())},f=H.create({close:r(["banner"])});return{element:function(){return a},display:function(e){b.fold(function(){e.destroy()},function(b){b.push(e);c.bind(e.events.close,function(){d(e);f.trigger.close(e)});y.append(a,e.element())})},hide:d,destroy:function(){F.remove(a);b=b.bind(function(a){z(a,e);return g.none()})},events:f.registry}}function zy(){var a=$T();a.events.close.bind(function(){b.trigger.resize()});var b=H.create({resize:r([])});
  return{element:a.element,display:function(c){a.display(c);b.trigger.resize()},hide:function(c){a.hide(c);b.trigger.resize()},destroy:a.destroy,events:b.registry}}function Ay(a,b,c){var d=-1;return{shouldRefresh:function(){return Ga.getOuter(b)!==d},updateWidth:u(function(a,b,c){d=Ga.getOuter(a)},b),updateHeight:t,clearWidth:t,build:ca,update:t,width:Ga.getOuter,init:function(a,b,c,d,q,C){a.refresh()},state:k({toolbar:{drag:g.none()}}),integrate:function(a,b,c,d,q){var e=T.div();ma.add(e,[B.resolve("sticky-container"),
  B.resolve("layer-above-editor")]);P.append(e,[b.element(),c.element(),q]);P.append(a,[e,d])},destroy:t,events:Gd(["changed","dock","undock"])}}function aU(a){a=ua({layerClass:By.resolve("blocker")},a);var b=p.fromTag("div");m.set(b,"role","presentation");v.setAll(b,{position:"fixed",left:"0px",top:"0px",width:"100%",height:"100%"});n.add(b,By.resolve("blocker"));n.add(b,a.layerClass);return{element:function(){return b},destroy:function(){F.remove(b)}}}function bU(){var a=g.none(),b=function(b,c){var d=
  a.map(function(a){return b.compare(a,c)});a=g.some(c);return d},c=H.create({move:r(["info"])});return{onEvent:function(a,e){e.extract(a).each(function(a){b(e,a).each(function(a){c.trigger.move(a)})})},reset:function(){a=g.none()},events:c.registry}}function cU(a){return{onEvent:function(a,c){},reset:t}}function dU(){var a=cU(),b=bU(),c=a;return{on:function(){c.reset();c=b},off:function(){c.reset();c=a},isOn:function(){return c===b},onEvent:function(a,b){c.onEvent(a,b)},events:b.events}}function eU(a,
  b){var c=H.create({relocate:r(["x","y","deltaX","deltaY"]),dragend:r([])}),d=fU.both(a),e=sj.transform(d),f=K.bind(a,"mousedown",function(a){0!==a.raw().button||Db.closest(a.target(),b)||(e.on(),e.go(p.fromDom(document.body)))});e.events.stop.bind(function(){c.trigger.dragend();e.off()});d.events.relocate.bind(function(a){c.trigger.relocate(a.x(),a.y(),a.deltaX(),a.deltaY())});return{blocker:e.element,destroy:function(){f.unbind();e.destroy()},events:c.registry}}function gU(){var a=H.create({dock:r([]),
  undock:r([])}),b=function(a,b,e,f,h,l){if("true"===m.get(e,"data-ephox-snap")){var c=bb.absolute(h),d=c.top()+l.top;if(Cy.isAllInside(b,d,d+f()))return c=a.locationToAbsolute(e,c.left(),d),g.some({position:"absolute",left:l.left+c.left()+"px",top:c.top()+"px"});a=l.top+c.top()-f()<=b.y()?b.fy():b.fy()+b.h()-f();h=bb.viewport(h).left()-c.left();l=l.left+c.left()+h;return g.some({position:"fixed",left:l+"px",top:a+"px"})}return g.none()};return{update:function(c,d,e,f,h,l){b(c,d,e,f,h,l).each(function(b){var c=
  v.get(e,"position");v.setAll(e,b);"absolute"===b.position&&c!==b.position?a.trigger.dock():"fixed"===b.position&&c!==b.position&&a.trigger.undock()})},getState:function(a){return"true"===m.get(a,"data-ephox-snap")},events:a.registry}}function hU(a){var b=function(a,b,c){a=A.owner(a);a=Za.get(a);b-=a.left();c-=a.top();return Qa(b,c)},c=function(a,b,c){a=A.owner(a);a=Za.get(a);b+=a.left();c+=a.top();return Qa(b,c)};return{locationToFixed:b,fixedToLocation:c,absoluteToFixed:function(b,c,f){var d=a();
  b=A.owner(b);b=Za.get(b);c-=b.left();return Qa(c,d.top()-f)},locationToAbsolute:function(b,c,f){b=a();return Qa(c,f).translate(-b.left(),-b.top())},absoluteToLocation:function(b,c,f){b=a();return Qa(c,f).translate(b.left(),b.top())},fromFixed:function(a,b,f){var d=Qa(b,f);a=c(a,b,f);return Dy(d,a)},fromLocation:function(a,c,f){a=b(a,c,f);c=Qa(c,f);return Dy(a,c)},boundToFixed:function(a,b,c,h,l,q,C){b=c<a.x()?a.fx():c>a.x()+a.w()?a.fx()+a.w():l;a=h<a.y()?a.fy():h+C>a.y()+a.h()?a.fy()+a.h()-C:q;return Qa(b,
  a)}}}function Ey(a,b){var c=a.isInline()?a.element():b;return iU(function(){var a=Za.get();return{x:a.left,y:a.top,w:k(window.innerWidth),h:k(window.innerHeight),fx:k(0),fy:k(0)}},function(){return a.isInline()?Qa(0,0):bb.absolute(c)},function(){var a=L.descendant(b,".ephox-chameleon-toolbar").getOr(b);return sa.getOuter(a)},c)}function jU(a,b,c){var d=T.div();v.set(d,"position","relative");n.add(d,B.resolve("dragging-container"));var e=T.div();n.add(e,B.resolve("draggable-container"));var f=a.isInline()?
  b:e;c=Ey(a,f);var h=Fy.transitions,l=Gy.except([".ephox-pastry-button","."+B.resolve("banner-buttons")+" *",".ephox-polish-ui-container",".ephox-polish-socket",".ephox-polish-widget-container"]),q=Hy.register(c,f,l,h),C=H.create({changed:Q([],q.events.dragend),dock:Q([],q.events.dock),undock:Q([],q.events.undock),appear:r(["container","wrapper"]),disappear:r(["container","wrapper"])});pd.initFade(e);q.events.appear.bind(function(){C.trigger.appear(f,e)});q.events.disappear.bind(function(){C.trigger.disappear(f,
  e)});n.add(e,B.resolve("layer-above-editor"));ma.add(q.blocker(),[B.resolve("above-outside"),B.resolve("dragging")]);var w=T.span();S.hidden(w,!0);ma.add(w,[B.resolve("toolbar-drag-handle"),B.resolve("general-drag-handle"),"ephox-textbox-font",B.resolve("icon")]);c=aa.detect();c.browser.isIE()&&10===c.browser.version.major&&n.add(w,B.resolve("ie10"));return{shouldRefresh:k(!0),updateWidth:u(pd.updateWidth,f),updateHeight:t,clearWidth:u(pd.clearWidth,f),build:function(a){return[w].concat(a)},width:u(pd.width,
  f),init:function(b,c,d,h,l,C){var w=v.preserve(f,function(){v.set(f,"visibility","hidden");v.remove(f,"display");b.refresh();return sa.get(b.element())});C.toolbar.drag.fold(function(){var b=pd.offsetFrom(a,f,w,l);q.init(b.left,b.top,g.from(l.toolbar.offset).getOr({top:-1*w,left:0}))},q.setState);P.append(e,[b.element(),c.element()])},update:function(){q.update()},state:function(){return{toolbar:{drag:q.state()}}},integrate:function(c,f,h,l,q){y.append(e,f.element());a.isInline()?(P.append(d,[e,q,
  l]),y.append(b,d)):P.append(b,[e,q,l])},destroy:function(){q.destroy()},events:C.registry}}function kU(a,b,c){var d=T.div();v.set(d,"position","relative");n.add(d,B.resolve("floating-container"));!0===c.toolbar.sticky&&n.add(d,B.resolve("floating-container-sticky"));!0===c.autoresize&&n.add(d,B.resolve("floating-container-autoresize"));c=T.div();n.add(c,B.resolve("draggable-container"));var e=a.isInline()?b:c;c=Ey(a,a.isInline()?e:d);var f=Hy.register(c,e,Gy.none,Fy.transitions),h=H.create({changed:Q([],
  f.events.dragend),dock:Q([],f.events.dock),undock:Q([],f.events.undock),appear:r(["container","wrapper"]),disappear:r(["container","wrapper"])});pd.initFade(e);f.events.appear.bind(function(){h.trigger.appear(e,e)});f.events.disappear.bind(function(){h.trigger.disappear(e,e)});n.add(e,B.resolve("layer-toolbar"));var l=function(){f.update()},q=function(){if(v.getRaw(e,"position").is("fixed")){var b=bb.absolute(a.element());v.getRaw(e,"left").is(b.left()+"px")||v.set(e,"left",b.left()+"px")}b=Ga.get(a.element());
  (v.getRaw(e,"width").isNone()||b!==Ga.get(e))&&v.set(e,"width",b+"px");return b},C=function(){var b=sa.get(e)+"px";v.getRaw(a.element(),"margin-top").is(b)||v.set(a.element(),"margin-top",b)};return{shouldRefresh:function(){return!0},updateWidth:function(b,c){a.isInline()?pd.updateWidth(e,b,c):(q(),C(),l())},updateHeight:function(){a.isInline()||C()},clearWidth:function(){a.isInline()&&pd.clearWidth(e)},build:ca,width:function(b){return a.isInline()?pd.width(e,b):Ga.get(a.element())},init:function(b,
  c,d,h,l,k){k=v.preserve(e,function(){v.set(e,"visibility","hidden");v.remove(e,"display");b.refresh();return sa.get(b.element())});d=pd.offsetFrom(a,e,k,l);a.isInline()||(q(),C());l=l.toolbar.sticky?{top:0,left:0}:g.from(l.toolbar.offset).getOr({top:-1*k,left:0});f.init(d.left,d.top,l);P.append(e,[b.element(),c.element(),h])},update:l,state:k({toolbar:{drag:g.none()}}),integrate:function(c,f,h,l,q){y.append(e,f.element());a.isInline()?P.append(d,[q,l]):P.append(d,[e,l]);y.append(b,d)},destroy:function(){f.destroy()},
  events:h.registry}}function lU(a,b,c,d,e,f){var h=aa.detect(),l=p.fromTag("div"),q=c.uiContainer(),C=T.div();Iy(d,l);n.add(l,B.resolve("editor-main"));!0===e.autoresize&&n.add(l,be.autoresize());a.isInline()||h.deviceType.isTouch()?y.append(l,q):(Iy(d,C),n.add(C,B.resolve("external-ui")),d=ja.body(),y.append(d,C),y.append(C,q));var w=mU.setup(a,l,e,f),g=df.toolbar(w,x.translate);!1===e.toolbar.visible&&n.add(l,"ephox-polish-no-toolbar");b.events.toolbar.bind(g.enter);g.events.exit.bind(a.focus);var G=
  zy(),V=T.div();n.add(V,B.resolve("socket"));var X=T.div();n.add(X,B.resolve("widget-container"));w.integrate(l,g,G,V,X);Jy.build(l,e.sideBar,e.bottomBar);var m=a.isInline()?function(){v.set(G.element(),"min-width",Ga.getOuter(a.element())+"px")}:t;a.events.paint.bind(function(a){g.repaint();c.refresh();m()});w.events.changed.bind(function(){g.refresh()});a.isInline()||!0!==e.toolbar.sticky||(w.events.dock.bind(function(){v.set(q,"position","absolute");c.refresh()}),w.events.undock.bind(function(){v.set(q,
  "position","fixed");c.refresh()}));if(a.isInline()||!0===e.toolbar.sticky)w.events.appear.bind(function(b){var c=a.isInline()?[b.container()]:[b.container(),q];pd.fadeIn(c,b.wrapper())}),w.events.disappear.bind(function(b){var c=a.isInline()?[b.container()]:[b.container(),q];pd.fadeOut(c,b.wrapper())});g.events.transitionend.bind(w.updateHeight);return{element:k(l),socket:function(a){a.connect(V)},viewport:k(V),uiContainerParent:k(C),connect:function(a){y.append(a,l);kj.detect(l);return!0},destroy:function(){g.destroy();
  w.destroy();G.destroy();F.remove(l);F.remove(C)},toolbar:g,position:function(){m();w.init(g,G,V,X,e,f)},refresh:function(){w.update();g.refresh()},banners:G.element,displayBanner:G.display,hideBanner:G.hide,state:w.state,dialogContainer:k(X)}}function nU(a){var b=g.none(),c=function(b){return function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];d=a.get()[b];if(null===d||void 0===d)throw"can't find instance method: "+b;return d.apply(null,c)}},d=function(){var a=b.getOrDie("Cannot reconnect the editor before it has been connected the first time.");
  c("connect")(a)&&e.trigger.connected()},e=H.create({connected:r([])});return jj.external({activateInline:c("activateInline"),deactivateInline:c("deactivateInline"),content:c("content"),keyboard:c("keyboard"),smartview:c("smartview"),macros:c("macros"),ui:c("ui"),filter:c("filter"),undo:c("undo"),operations:c("operations"),getMode:c("getMode"),element:c("element"),connect:function(a){b=g.some(a);d()},reconnect:function(){var c=b.getOrDie("Cannot reconnect the editor before it has been connected the first time."),
  e=v.getRaw(c,"height");a.get().events.loaded.bind(function(){e.fold(function(){v.remove(c,"height")},function(a){v.set(c,"height",a)})});var l=v.get(c,"height");v.set(c,"height",l);d()},focus:c("focus"),getContent:c("getContent"),setContent:c("setContent"),insertHtmlAtCursor:c("insertHtmlAtCursor"),state:c("state"),communication:c("communication"),uploader:c("uploader"),isDirty:c("isDirty"),setDirty:c("setDirty"),isPrettyPrinting:c("isPrettyPrinting"),events:e.registry})}function Ky(a){var b=Pb(J.error,
  a);return{invalidError:b,different:function(a,d,e,f,h){return 0===d.length?b(f):d===e?b(h):J.value(a)}}}function oU(a){var b=Ky(a);return{changeAlt:function(a,d,e,f){var c=m.get(a,"src");return b.different(a,d,c,e,f).map(function(a){m.set(a,"alt",d);return a})}}}function Rc(a,b,c,d){var e=N.eq(a,c)&&b===d;return{startContainer:k(a),startOffset:k(b),endContainer:k(c),endOffset:k(d),collapsed:k(e)}}function Ly(a){var b=function(b){return a(b).isRtl()?Yl.rtl:Yl.ltr};return{delta:function(a,d){return b(d).delta(a,
  d)},edge:function(a){return b(a).edge(a)},positions:function(a,d){return b(d).positions(a,d)}}}function pU(a){var b=Ky(a);return{changeCaption:function(a,d,e,f){var c=m.get(a,"summary");return b.different(a,d,c,e,f).map(function(a){Of.setCaption(a,d);return a})},changeSummary:function(a,d,e,f){var c=L.descendant(a,"caption").map(Ha.get).getOr("");return b.different(a,d,c,e,f).map(function(a){Of.setSummary(a,d);return a})},setHeaders:function(a,d,e,f){return(!0===e&&!0===f?Of.addBothHeaders:!0===e?
  Of.addRowHeader:!0===f?Of.addColumnHeader:k(b.invalidError("a11y.t4b.repair.errors.none")))(a,d)},setScope:function(a,b){m.set(a,"scope",b);return J.value(a)}}}function qU(a){var b=Aa("id description prompts element severity url repair".split(" "),[]),c=Aa(["ui","repair"],[]),d=oU(a),e=pU(a),f={I1:g.some(c({ui:[jc.field("image-alt","a11y.i1.repair.info",k(""))],repair:function(a,b,c){return d.changeAlt(b.element(),c["image-alt"](),"a11y.i1.repair.errors.empty","a11y.i1.repair.errors.duplicate")}})),
  I2:g.some(c({ui:[jc.field("image-alt","a11y.i2.repair.info",function(a){return m.get(a.element(),"alt")})],repair:function(a,b,c){return d.changeAlt(b.element(),c["image-alt"](),"a11y.i2.repair.errors.empty","a11y.i2.repair.errors.duplicate")}})),T1:g.some(c({ui:[jc.field("table-caption","a11y.t1.repair.info",k(""))],repair:function(a,b,c){return e.changeCaption(b.element(),c["table-caption"](),"a11y.t1.repair.errors.empty","a11y.t1.repair.errors.duplicate")}})),T2:g.some(c({ui:[jc.field("table-summary",
  "a11y.t2.repair.info",k(""))],repair:function(a,b,c){return e.changeSummary(b.element(),c["table-summary"](),"a11y.t2.repair.errors.empty","a11y.t2.repair.errors.duplicate")}})),T3:g.some(c({ui:[jc.field("table-caption","a11y.t3.repair.info",function(a){return m.get(a.element(),"summary")})],repair:function(a,b,c){return e.changeCaption(b.element(),c["table-caption"](),"a11y.t3.repair.errors.empty","a11y.t3.repair.errors.duplicate")}})),T4A:g.none(),T4B:g.some(c({ui:[jc.toggles("table-headers","a11y.t4b.repair.info",
  [jc.toggle("row-header","ephox-polish-row-header","a11y.t4b.repair.row"),jc.toggle("col-header","ephox-polish-column-header","a11y.t4b.repair.column")])],repair:function(a,b,c){var d=c["row-header"]();c=c["col-header"]();return e.setHeaders(a,b.element(),d,c)}})),T4C:g.some(c({ui:[jc.select("scope-type","a11y.t4c.repair.info",[jc.pair("row","a11y.t4c.repair.scope.row"),jc.pair("col","a11y.t4c.repair.scope.col"),jc.pair("rowgroup","a11y.t4c.repair.scope.rowgroup"),jc.pair("colgroup","a11y.t4c.repair.scope.colgroup")])],
  repair:function(a,b,c){return e.setScope(b.element(),c["scope-type"]())}})),D1:g.some(c({ui:[jc.select("heading-type","a11y.d1.repair.info",[jc.pair("h1","a11y.d1.repair.block.h1"),jc.pair("h2","a11y.d1.repair.block.h2"),jc.pair("h3","a11y.d1.repair.block.h3"),jc.pair("h4","a11y.d1.repair.block.h4"),jc.pair("h5","a11y.d1.repair.block.h5"),jc.pair("h6","a11y.d1.repair.block.h6")])],repair:function(a,b,c){return My.convertToHeading(b.element(),c["heading-type"]())}})),D2:g.none(),D3:g.some(c({ui:[],
  repair:function(a,b,c){return My.joinLinks(a.content().isRoot,b.element())}})),D4:g.none(),D5:g.none(),O1:g.none(),O2:g.none()};return{convert:function(a,c){var d=function(b){var c=b.repair();return function(b,d){return a.undo().transaction(function(){return c(a,b,d)})}};return E(c,function(a){var c=a.rule(),e=c.id().toUpperCase(),h=void 0!==f[e]?f[e]:g.none(),l=c.desckey();return b({id:e,description:l,prompts:h.map(function(a){return a.ui()}),element:p.fromDom(a.element()),url:c.url(),severity:c.severity(),
  repair:h.map(d).getOr(function(){return J.error("no repair")})})})}}}function rU(a){return{audit:function(b){return sU.audit(b,a.rules())}}}function tU(){var a=na([]),b=na(0),c=O("index","total","detail"),d=function(d){var e=a.get();if(0===e.length)return g.none();var h=b.get();var l=e.length-1;d=h+d;l=d>l?0:0>d?l:d;b.set(l);return g.some(c(l,e.length,e[l]))};return{load:function(d){if(0===d.length)return g.none();b.set(0);a.set(d);return g.some(c(b.get(),d.length,d[0]))},backwards:function(){return d(-1)},
  current:function(){var d=a.get();return 0===d.length?g.none():g.some(c(b.get(),d.length,d[b.get()]))},resolve:function(){var d=a.get();if(0===d.length)return g.none();d=d.slice(0,b.get()).concat(d.slice(b.get()+1));var f=Math.min(d.length-1,b.get());b.set(f);a.set(d);return 0===d.length?g.none():g.some(c(b.get(),d.length,d[b.get()]))},forwards:function(){return d(1)}}}function uU(a,b){var c=T.div();n.add(c,$a.resolve(b,"assistance"));var d=$a.resolve(b,"assistance-invalid"),e=g.none(),f=p.fromTag("p");
  n.add(f,$a.resolve(b,"repair-error"));m.set(f,"aria-live","polite");var h=function(){n.remove(c,d);F.remove(f)},l=H.create({execute:r([])}),q=ha.dynamic(c,Ba.dynamic({})),C=[q];return{element:k(c),keylayouts:k(C),markInvalid:function(a){n.add(c,d);ib.shout(c,a);Ha.set(f,a);y.append(c,f)},markValid:h,getChange:function(){return e.map(function(a){return a.get()})},destroy:function(){e.each(function(a){a.destroy()})},update:function(d){h();d=d.detail();var f=d.prompts();e.each(function(a){a.destroy()});
  d=vU.generate(a,f,d,b);e=g.some(d);F.empty(c);P.prepend(c,d.elements());d.events.execute.bind(function(){l.trigger.execute()});q.set(d.keylayouts())},events:l.registry}}function wU(a,b){var c=T.div();n.add(c,$a.resolve(b,"commands"));var d=T.div();n.add(d,$a.resolve(b,"commands-buttons"));var e=ef.defaultActionButton(a,[$a.resolve(b,"repair")],Sc.repairLabel(),Sc.repairText(),b),f=ef.normalButton(a,[$a.resolve(b,"ignore")],Sc.ignoreLabel(),Sc.ignoreText(),b),h=ef.defaultActionButton(a,[$a.resolve(b,
  "ok")],Sc.okLabel(),Sc.okText(),b),l=function(){P.append(d,[f.element(),e.element()])};l();a=Ba.button({execute:function(a){a.dom().click()}});a=[ha.button(f.element(),a),ha.button(e.element(),a),ha.button(h.element(),a)];y.append(c,d);var q=H.create({repair:Q([],e.events.click),ignore:Q([],f.events.click),done:Q([],h.events.click)});return{element:k(c),destroy:function(){e.destroy();f.destroy();h.destroy()},keylayouts:k(a),focus:function(){var a=e.disabled()?e.element():f.element();Z.focus(a)},update:function(a){F.remove(h.element());
  a=a.detail();sc.isVisible(f.element())||l();a.prompts().fold(function(){e.disable();ra.disable(e.element())},function(a){e.enable();ra.enable(e.element());ib.speak(ja.body(),$a.translate(b,Sc.repairAvailable()))})},zero:function(a){F.empty(d);y.append(d,h.element());Z.focus(h.element())},events:q.registry}}function xU(a,b){var c=T.div();n.add(c,$a.resolve(b,"information"));m.set(c,"data-severity","info");a=T.div();n.add(a,$a.resolve(b,"icon"));var d=T.div();n.add(d,$a.resolve(b,"description"));y.append(d,
  p.fromText(""));var e=p.fromTag("a");n.add(e,$a.resolve(b,"help-icon"));m.set(e,"href","javascript:void(0)");P.append(c,[a,d,e]);var f=K.bind(e,"click",function(){var a=m.get(e,"data-url");window.open(a,"","height=700,width=820,resizable=yes,scrollbars=yes")});a=[ha.single(e,[],g.none())];return{element:k(c),destroy:function(){f.unbind()},keylayouts:k(a),update:function(a){a=a.detail();var f=a.severity();m.set(c,"data-severity",f);ib.speak(ja.body(),$a.translate(b,Sc.severity(f)));f=$a.translate(b,
  a.description());Ha.set(d,f);ib.speak(ja.body(),f);m.set(e,"title",$a.translate(b,Sc.issueHelp()));m.set(e,"data-url",a.url());y.after(d,e)},zero:function(){m.set(c,"data-severity","success");var a=$a.translate(b,Sc.noIssue());Ha.set(d,a);ib.speak(ja.body(),a);F.remove(e)}}}function yU(a,b){a=T.div();var c=T.span();n.add(c,$a.resolve(b,"spin"));n.add(a,$a.resolve(b,"loading"));y.append(a,c);return{element:k(a),destroy:t}}function zU(a,b){var c=Zl("titlebar",g.none(),b),d=Zl("title",g.none(),b),e=
  Zl("title-text",g.some(Sc.title()),b),f=Zl("issue",g.some(Sc.running()),b);P.append(d,[e,f]);var h=T.div();n.add(h,$a.resolve(b,"navigation"));e=ef.icon(a,$a.resolve(b,"previous"),Sc.previous(),b);a=ef.icon(a,$a.resolve(b,"next"),Sc.next(),b);var l=[e,a];a=H.create({previous:Q([],e.events.click),next:Q([],a.events.click)});P.append(h,E(l,function(a){return a.element()}));y.append(c,d);var q=Ba.button({execute:function(a){a.dom().click()}});e=E(l,function(a){return ha.button(a.element(),q)});var C=
  function(a){a.disable();ra.disable(a.element())},w=function(a){a.enable();ra.enable(a.element())},I=function(){z(l,C)},G=function(){z(l,w)},V=function(){Hh.preserve(function(){y.after(d,h)},h)};return{element:k(c),update:function(a){var c=a.index()+1;a=a.total();c=$a.translate(b,Sc.issueCounter(),c,a);Ha.set(f,c);ib.speak(ja.body(),c);(1===a?I:G)();V()},zero:function(){Ha.set(f,"&nbsp;");V();I()},keylayouts:k(e),destroy:function(){z(l,function(a){a.destroy()})},events:a.registry}}function AU(a,b){var c=
  T.div();n.add(c,$a.resolve(b,"widget"));var d=$a.resolve(b,"loading");n.add(c,d);var e=zU(a,b),f=xU(a,b),h=uU(a,b),l=wU(a,b),q=yU(a,b);P.append(c,[e.element(),q.element()]);var C=H.create({showcase:r(["detail"]),ignored:r(["detail"]),solved:r(["detail"]),done:r([])}),g=function(a){z([e,f,h,l],function(b){b.update(a)});C.trigger.showcase(a.detail());Hh.preserve(function(){y.after(e.element(),f.element());y.after(f.element(),h.element());y.after(h.element(),l.element())},c)},I=function(a){a.fold(function(){y.after(e.element(),
  f.element());y.after(f.element(),l.element());F.remove(h.element());e.zero();f.zero();l.zero()},g)},G=na(tU());e.events.previous.bind(function(){G.get().backwards().each(g)});e.events.next.bind(function(){G.get().forwards().each(g)});a=function(){var a=h.getChange().getOr({});G.get().current().each(function(b){var c=b.detail();c.repair()(c,a).fold(function(a){h.markInvalid(a)},function(a){h.markValid();a=G.get().resolve();C.trigger.solved(c);I(a);l.focus()})})};h.events.execute.bind(a);l.events.repair.bind(a);
  l.events.ignore.bind(function(){G.get().current().each(function(a){var b=G.get().resolve();C.trigger.ignored(a.detail());I(b)})});l.events.done.bind(function(){C.trigger.done()});a=Qb([e.keylayouts(),f.keylayouts(),h.keylayouts(),l.keylayouts()]);return{element:k(c),destroy:function(){z([e,f,h,l],function(a){a.destroy()})},load:function(a){F.remove(q.element());n.remove(c,d);a=G.get().load(a);I(a)},open:function(){y.append(c,q.element());n.add(c,d)},skip:function(){var a=G.get().resolve();I(a)},keylayouts:k(a),
  events:C.registry}}function BU(a){var b=Rq.ignoreAttr(),c={prefix:k("accessibility-check"),translate:Ny.translate,tnames:k("a11y")},d=AU(CU,c);c=DU.all();c=EU({rules:c});var e=rU(c),f=qU(Ny.translate),h=Rq.manager(a.content()),l=function(c){c=e.audit(c.dom());c=f.convert(a,c);return ka(c,function(a){var c=a.element();c=ff.read(c,b);return!U(c,a.id())})};d.events.showcase.bind(function(b){a.content().body().each(function(c){c=b.detail().element();ja.inBody(c)?(h.moveTo(c,b.detail().severity()),Ng.elementIntoView(a.content(),
  c)):d.skip()})});d.events.ignored.bind(function(a){a=a.detail();h.ignore(a.element(),a.id(),a.severity())});d.events.solved.bind(function(a){a=a.detail();h.solve(a.element(),a.id(),a.severity())});c=H.create({done:Q([],d.events.done)});return{element:d.element,anchorName:k("a11y-widget-anchor"),textkey:k("action.a11ycheck"),dialogTextkey:k("a11y.widget.title"),destroy:function(){d.destroy()},keylayouts:d.keylayouts,openWidget:function(){a.content().hideInlineSelection();d.open();a.content().body().each(function(a){a=
  l(a);h.start(a);d.load(a)})},closeWidget:function(){h.stop()},events:c.registry}}function FU(a,b){var c=H.create({open:r([]),close:r([])}),d=p.fromTag("div");n.add(d,va.resolve("layer-menus"));n.add(d,va.resolve("toolstrip"));y.append(a(),d);a=function(){v.getRaw(d,"opacity").isNone()&&(e.cancel(),v.remove(d,"display"),c.trigger.close())};var e=tj(a,1E3),f=K.bind(d,"transitionend",a);return{element:function(){return d},destroy:function(){f.unbind();F.remove(d)},open:function(){v.set(d,"display","block");
  v.reflow(d);c.trigger.open();v.set(d,"opacity","1")},close:function(){v.remove(d,"opacity");e.throttle()},setContent:function(a){y.append(d,a)},events:c.registry}}function Oy(a,b,c,d){var e=a.content(),f=a.ui().tabstrip.element(),h=[b.element()],l="."+B.resolve(c)+", ."+va.resolve("more-button"),q=function(){var a=Y.descendants(f,l);return h.concat(a)},C=gd.api(),g=H.create({abort:r([]),open:r([]),close:r([])}),k=function(){e.events.mousedown.unbind(G);C.clear();V.off()},G=function(){C.isSet()&&(b.closeWidget(),
  C.run(function(a){a.close()}))},V=ny(G,q);b.events.done.bind(function(){G()});var X=ha.multiple(b.element(),b.keylayouts());X.events.exit.bind(function(){g.trigger.abort()});return{destroy:function(){k();X.destroy();b.destroy();V.off()},events:g.registry,open:function(){V.on();b.openWidget();var c=FU(a.ui().dialogContainer,q);c.setContent(b.element());n.add(c.element(),d);var f=c.element();ma.add(f,[B.resolve(b.anchorName()),B.resolve("side-widget-anchor")]);S.dialog(f,x.translate(b.dialogTextkey()));
  c.open();c.events.close.bind(function(){e.focus();g.trigger.close();k()});C.set(c);X.enter();g.trigger.open();e.events.mousedown.bind(G)},close:G,isOpen:C.isSet}}function GU(a){var b=a.filter();Rq.configure(b);var c=gd.api(),d=function(){var b=BU(a);b=Oy(a,b,"a11y-check",HU);b.events.abort.bind(b.close);b.events.close.bind(f);c.set(b);b.open()},e=function(){c.run(function(a){a.close()})},f=function(){c.clear()};return{ui:vb.ui({"a11ycheck.general":{toggle:!1,hasPopup:!1,value:"a11y-check",textkey:x.key("action.a11ycheck"),
  action:function(){(c.isSet()?e:d)()},updateGeneral:function(a){n.add(a.element(),B.resolve("a11y-check"))},icon:!0,tooltip:rb.get}}),destroy:f}}function Sq(a){return{change:function(b,c){return(a.directionAt(b).isRtl()?Py.rtl:Py.ltr).change(b,c)}}}function IU(a){var b=a.property(),c=function(a,c){return b.parent(a).map(b.name).map(function(a){return!U(c,a)}).getOr(!1)};return{validateText:function(a){return b.isText(a)&&c(a,JU)}}}function KU(a,b){return{is:function(c){return v.get(c,a)===b},remove:function(b){v.remove(b,
  a)},set:function(c){v.set(c,a,b)}}}function LU(a){var b=a.content(),c=a.keyboard(),d=a.shortcuts(),e=a.context(),f=H.create({analytics:r(["message","properties"])}),h=u(ce.indent,a),l=u(ce.outdent,a),q=u(ce.blockquote,a);d.events.indent.bind(h);d.events.outdent.bind(l);d.events.blockquote.bind(q);var C=function(a){var c=a.stopper();$l.context(b).bind(function(b){$l.cata(b,t,function(b){(a.shift()?l:h)();c()})})},w=c.editor();w.on();w.events.tab.bind(C);e.events.preLinebreak.bind(function(b){Tq.atQuoteBreak(a.content()).each(function(c){ce.breakQuote(a,
  c.quote(),c.element());b.handler().handle()})});var I=O("value","icon","textkey");c=I("justifyleft",g.some(va.resolve("justifyleft")),x.key("alignment.left"));d=I("justifycenter",g.some(va.resolve("justifycenter")),x.key("alignment.center"));e=I("justifyright",g.some(va.resolve("justifyright")),x.key("alignment.right"));var G=I("justifyfull",g.some(va.resolve("justifyfull")),x.key("alignment.justify")),V=I("justifyleft",g.some(va.resolve("justifyleft")),x.key("alignment.left")),X=I("justifycenter",
  g.some(va.resolve("justifycenter")),x.key("alignment.center"));I=I("justifyright",g.some(va.resolve("justifyright")),x.key("alignment.right"));var m=[c,d,e,G],n=[V,X,I],p=function(){return vc.detect(b.getSelection()).fold(function(){return m},function(a){return n})},Dh={justifyleft:u(ce.imageLeft),justifycenter:u(ce.imageCentre),justifyright:u(ce.imageRight)},v={justifyleft:ce.justifyLeft,justifycenter:ce.justifyCentre,justifyright:ce.justifyRight,justifyfull:ce.justifyFull},z=function(a){return a.toLowerCase()},
  y=g.none();return{ui:vb.ui({"indent.general":{value:"indent",textkey:x.key("action.indent"),action:h,updateGeneral:ca,tooltip:rb.get,toggle:!1},"outdent.general":{value:"outdent",textkey:x.key("action.outdent"),action:l,updateGeneral:ca,tooltip:rb.get,toggle:!1},"blockquote.general":{value:"blockquote",textkey:x.key("action.blockquote"),action:q,updateGeneral:function(a){Tq.read(b).quoted().fold(a.deselect,t,a.select)},tooltip:rb.get,toggle:!0},"alignment.dropdown":{name:"alignment",textkey:x.key("alignment.toolbar"),
  menuTextkey:x.key("alignment.menu"),action:function(c){var d=vc.detect(b.getSelection()).fold(k(v),k(Dh));(void 0!==d[c]?d[c]:t)(a)},updateDropdown:function(a){var c=p(),d=Tq.read(b).alignment().fold(function(){return 0<c.length?Da.on(c[0].value()):Da.off()},Da.unchanged,Da.on);a.populate([{label:g.none,items:k(c)}]);am.updateMenu(a,d.map(z),Da.on(),c,y)},values:m,render:y,tooltip:rb.get,toggle:!1,describe:function(a){return x.translate("alignment.describe",x.get(a.textkey()))}}}),events:f.registry,
  destroy:function(){w.off();w.events.tab.unbind(C);w.destroy()}}}function MU(a,b){var c=function(a,b,c){var d=p.fromText(b);a(c,d);return g.some({element:k(d),cleanup:function(){F.remove(d)},splits:k([])})},d=function(a){return{none:g.none,start:u(c,y.before,a),end:u(c,y.after,a),middle:function(b,d,e){return c(y.after,a,d)}}},e=function(a){var b=function(a){return function(b,c){y.appendAt(b,c,a)}};return{prepend:u(c,y.prepend,a),before:u(c,y.before,a),after:u(c,y.after,a),insertAt:function(d,e){return c(b(e),
  a,d)},append:u(c,y.append,a)}};return{before:{text:d(a),element:{hasPrevious:e(a).insertAt,first:e(a).prepend,empty:e(a).before,otherwise:e(a).append}},after:{text:d(b),element:{hasNext:e(b).insertAt,rightEdge:e(b).append,empty:e(b).after,otherwise:e(b).append}},general:{insertBefore:e(a).before,insertAfter:e(b).after}}}function Qy(a,b,c,d){c=[b].concat(c);var e=u(Uq.nuTag,b),f=u(Og.relatedTags,c),h=Ic.tagList(c),l=Og.queriesTag(b),q={nu:e,matches:f,purifiers:k(h)},C=function(a){var b=p.fromText(mb());
  bm.atStartOf(a.startContainer(),a.startOffset(),b);return Ub.hare(b,0,b,1)},w=function(a,b,c){return D.isText(b)&&c===Ya.get(b).length?wc.after(b,a).fold(function(){return W.point(b,c)},function(a){return W.point(a,0)}):W.point(b,c)},I=function(a,b,c){return D.isText(b)&&0===c?wc.before(b,a).fold(function(){return W.point(b,c)},function(a){return W.point(a,wa.getEnd(a))}):W.point(b,c)},G=function(a,b){return b.map(function(b){var c=w(a,b.start(),b.soffset());b=I(a,b.finish(),b.foffset());return Ub.fussy(c.element(),
  c.offset(),b.element(),b.offset())})};c={nu:e,purifiers:k(h),isStyled:k(!0)};var V=["font-size"],X=function(a){return a.getSelection().map(function(a){var c=cb(d);c=Hq(c,V);return ob(c,function(c){return Og.queryStyleOn(c,d[c],[b],a)})}).getOr(!1)};return{run:function(a,c){var d=c.doc();return Vq.detect(c,l.queryOn).fold(function(){return g.none()},function(b){b=C(b);de.doRemoveUpto(a,h,b,f);return g.some(Ub.fromHare(b))},function(a){a=C(a);var c=p.fromTag(b,d.dom());n.add(c,Rb.styleSpan());y.wrap(a.startContainer(),
  c);return g.some(Ub.fussy(a.startContainer(),1,a.startContainer(),1))},function(b){b=de.doRemoveUpto(a,h,b,f);return G(a,b)},function(b){return Wq.run(c.doc(),a,b,q)})},query:function(a){return l.query(a)||X(a)},deferred:k(c),name:k(a)}}function Ry(a,b){return{element:k(b),wrap:function(c){a.insert().append(b,c)}}}function cm(a,b,c,d,e,f){var h=u(Uq.nu,d,e,b),l=u(Og.relatedStyle,d,e,c),q=Ic.cssAndTag(c,d,e),C=Og.queriesStyle(d,e,c),w=k(!0),I=function(b,c){gf.generic(b,t,w,function(b){n.add(b,Rb.styleSpan());
  v.set(b,d,c);m.set(b,Rb.overrideSpan(),a);v.reflow(b)});return g.none()};b={nu:h,purifiers:k(q),isStyled:function(a){return"span"===D.name(a)&&uj.rawState(a,d,e)},matches:l};return{run:function(a,b){return Vq.detect(b,C.queryOn).fold(function(){return g.none()},function(a){return I(b,f)},function(a){return I(b,e)},function(b){return de.doRemoveUpto(a,q,b,l)},function(c){return Wq.run(b.doc(),a,c,{nu:h,matches:l,purifiers:k(q)})})},query:function(b){var c="["+Rb.overrideSpan()+'="'+a+'"]';return b.getSelection().bind(function(a){return L.closest(a.startContainer(),
  c).bind(function(b){return L.closest(a.endContainer(),c).bind(function(a){return N.eq(b,a)?v.getRaw(b,d).map(function(a){return a===e}):g.none()})})}).getOrThunk(function(){return C.query(b)})},deferred:k(b),name:k(a)}}function NU(a){var b=a.content(),c=a.shortcuts(),d=a.undo(),e=H.create({analytics:r(["message","properties"])}),f=function(a,c){var d=OU.read(b);(void 0!==d[a]?d[a]():Da.unchanged()).fold(c.deselect,t,c.select)},h=function(c){var e=function(a){return c(b.isRoot,a)};return function(){$b.cata(a.selections().get(),
  t,dm.multiple(b,d,e),dm.single(b,d,e));b.uiChanged()}},l=h(qd.bold),q=h(qd.italic),C=h(qd.underline),g=h(qd.strikethrough),k=h(qd.subscript),G=h(qd.superscript);h=h(qd.removeformat);c.events.bold.bind(l);c.events.italic.bind(q);c.events.underline.bind(C);return{ui:vb.ui({"bold.general":{toggle:!0,value:"bold",textkey:x.key("action.bold"),action:l,updateGeneral:u(f,"bold"),icon:!0,tooltip:rb.get},"italic.general":{toggle:!0,value:"italic",textkey:x.key("action.italic"),action:q,updateGeneral:u(f,"italic"),
  icon:!0,tooltip:rb.get},"underline.general":{toggle:!0,value:"underline",textkey:x.key("action.underline"),action:C,updateGeneral:u(f,"underline"),icon:!0,tooltip:rb.get},"strikethrough.general":{toggle:!0,value:"strikethrough",textkey:x.key("action.strikethrough"),action:g,updateGeneral:u(f,"strikethrough"),icon:!0,tooltip:rb.get},"removeformat.general":{toggle:!1,value:"removeformat",textkey:x.key("action.removeformat"),action:h,updateGeneral:ca,icon:!0,tooltip:rb.get},"subscript.general":{toggle:!0,
  value:"subscript",textkey:x.key("action.subscript"),action:k,updateGeneral:u(f,"subscript"),icon:!0,tooltip:rb.get},"superscript.general":{toggle:!0,value:"superscript",textkey:x.key("action.superscript"),action:G,updateGeneral:u(f,"superscript"),icon:!0,tooltip:rb.get}}),events:e.registry,destroy:t}}function Sy(a){var b=function(b,d,e,f){var c=e.join(",");b=a.up().closest(b,c,f);d=a.up().closest(d,c,f);return b.isSome()&&d.isSome()?(f=b.getOrDie("Just checked it was some."),d=d.getOrDie("Just checked it was some."),
  a.eq(f,d)?qa(e,u(a.is,f)):g.none()):g.none()};return{query:function(a,d,e){d=d.concat(PU.tags());return b(a.startContainer(),a.endContainer(),d,e)},queryAll:b}}function Ty(a,b){var c=O("base","value","textkey","icon","styles","tag"),d=a.styles;a=b.map(u(QU,a.showDocumentStyles)).getOr([]);d=d.concat(a);d=E(d,function(a){return{name:a.rule,text:g.from(a.text).map(x.raw),style:void 0===a.style?{}:a.style}});var e={};z(d,function(a){RU.decipher(a).each(function(b){e[a.name]=b})});d=Jb;a=ed;b=function(a,
  b,c,d){return function(e){return Pf.cata(e,a,b,c,d)}};var f=Ze(e),h=ka(f,b(a,a,a,d)),l=ka(f,b(a,a,d,a)),q=ka(f,b(a,d,a,a)),C=ka(f,b(d,a,a,a));d=function(){var a=h.concat(q).concat(l).concat(C);return E(a,function(a){return Pf.cata(a,function(a,b,c){return"."+a},function(a,b,c,d){return a+"."+b},function(a,b,c){return a},function(a,b,c,d){return a+"."+b})})}();var w=function(a){return void 0!==e[a]?g.some(e[a]):g.none()},I=function(a){return Pf.cata(a,function(a,b,d){return c("span","."+a,b,g.none(),
  d,"span")},function(a,b,d,e){return c(a,a+"."+b,d,g.none(),e,"span")},function(a,b,d){return c(a,a,b,g.none(),d,a)},function(a,b,d,e){return c(a,a+"."+b,d,g.none(),e,a)})};a=function(){var a=Ze(e);return E(a,I)}();return{candidateByName:function(a){return w(a).map(I)},toCandidate:I,ruleByName:w,divisions:function(){return{classblocks:k(h),blocks:k(l),objects:k(q),inlines:k(C)}},backup:function(a){return c(a,a,x.key("block."+a),g.none(),{},"span")},selectors:k(d),everything:k(a)}}function SU(a,b,c){var d=
  c(void 0===b||"default"===b?g.none():g.some(b)),e=p.fromTag("div");n.add(e,B.resolve("list-style-option"));c=void 0===b||"default"===b?TU(e,"ul"===a?"list.unordered.default":"list.ordered.default"):UU(a,b);y.append(e,c);a=x.translate(("ul"===a?"list.unordered.":"list.ordered.")+b);m.set(e,"title",a);S.label(e,a);S.menuItemCheckbox(e);var f=ib.describe(e,x.translate("aria.widget.navigation"));y.append(e,f);var h=H.create({action:r(["type","element"])}),l=function(){ra.checked(e,!0);n.add(e,B.resolve("list-style-selected"))},
  q=function(){ra.checked(e,!1);n.remove(e,B.resolve("list-style-selected"))},C=K.bind(e,"click",function(a){h.trigger.action(d,g.some(e))});return{element:k(e),instance:d,style:b,update:function(a){(d.query(a)&&d.queryStyle(a)?Da.on(!0):Da.off()).fold(q,t,l)},select:l,deselect:q,events:h.registry,destroy:function(){C.unbind();F.remove(e);F.remove(f)}}}function VU(a,b,c){var d=H.create({action:r(["type"])}),e=T.div();n.add(e,B.resolve("list-style-palette"));var f=E(a,function(a){return SU("bullist"===
  b?"ul":"ol",a,c)});z(f,function(a){a.events.action.bind(function(a){a.element().each(l);d.trigger.action(a.type())});y.append(e,a.element())});var h=function(){var a=Math.floor(f.length/4)+(0<f.length%4?1:0);return ha.grid(e,{cell:k("."+B.resolve("list-style-option"))},a,4,Ba.grid({trigger:function(a){a.dom().click();return g.some(a)}}))}(),l=function(a){L.sibling(a,"["+em+'="default"]').filter(function(b){return b!==a}).each(function(b){m.remove(b,em);m.set(a,em,"default")})};return{enter:h.enter,
  element:k(e),update:function(a){z(f,function(b){b.update(a)})},events:d.registry,destroy:function(a){h.isFocused()&&h.exit();h.destroy();z(f,function(a){a.destroy()});F.remove(e)},findDefault:function(){return qa(f,function(a){return m.has(a.element(),em)}).map(function(a){return a.instance})}}}function Uy(a){var b=a.region(),c=a.content(),d=a.undo(),e=a.keyboard(),f=a.listConstructor(),h=a.type(),l=a.styles(),q=a.textkey(),C=a.menuTextkey(),g=f("default"),I=aa.detect(),G=e.all();G.swallowKeys([R.ESCAPE()]);
  var V=H.create({abort:r([]),done:r([]),close:r([]),analytics:r(["message"])});G.events.escape.bind(function(a){V.trigger.abort()});var X=function(e,f){var h=Ih.list(function(a,c,d,h,l){return e.apply(a,c,d,h,l,Sq(b),f)},b,c,d,a.selections());V.trigger.done();c.focus();return h},m=function(){L.descendant(n.element(),'[data-ephox-polish-list-style="default"]').each(function(a){Z.focus(a)})},n=VU(l,h,f);n.events.action.bind(function(a){X(a.type(),!1)});return{action:function(){var a=n.findDefault().getOr(g);
  X(a,!0)},element:n.element,shortcut:!1,textkey:k(q),menuTextkey:k(C),label:k(!1),name:k(h),tooltip:rb.get,toggle:!0,value:h,updateWidget:function(a){c.getSelection().each(function(b){var c=g.query(b)?Da.on(!0):Da.off();c.fold(a.deselect,t,a.select);c.fold(a.release,t,a.press);n.update(b)})},open:function(){I.deviceType.isTouch()||m();G.on()},close:function(){G.off();V.trigger.close()},icon:!0,events:V.registry,enter:n.enter,destroy:function(){G.off();G.destroy();n.destroy()}}}function WU(a,b,c){var d=
  function(b){if("p"===D.name(b))return Vy.replace(a,b,"li");var c=p.fromTag("li");y.before(b,c);y.append(c,b);return c},e=function(a){var d=p.fromTag(b);c.each(function(a){v.set(d,"list-style-type",a)});y.before(a[0],d);P.append(d,a);g.from(m.get(a[0],"dir")).each(function(a){m.set(d,"dir",a)});return d},f=function(a){var d=Oc.mutate(a,b);c.fold(function(){v.remove(d,"list-style-type")},function(a){v.set(d,"list-style-type",a)});return d},h=function(a){var b=k(!0),c=k(!1);return a.fold(b,c,c)},l=function(a,
  b){return function(c){return vj.cata(c,function(c){var d=Y.descendants(c,"li");return 0<d.length?(c=d[0],d=d[d.length-1],c=kc.first(c).getOr(c),d=kc.last(d).getOr(d),Xq.outdent(a,c,0,d,wa.getEnd(d),b).map(function(a){return a.all()})):g.none()},g.none,g.none).getOr([])}},q=function(a){return vj.cata(a,function(a){return[a]},function(a){return[f(a)]},function(a){a=E(a,d);e(a);return a})};return{apply:function(a,d,e){e=XU.categorise(e,b,c);a=ob(e,h)?l(a,d):q;return ia(e,a)}}}function YU(a,b){var c=
  H.create({analytics:r(["message"])}),d=Ty(b,g.none()),e=a.region(),f=a.content(),h=a.undo();f.events.stylesheetLoad.bind(function(a){d=Ty(b,g.some(a.sheets()));f.uiChanged()});var l=g.some(Wy.format),q=f.isRoot,C=function(a){ZU.deviceType.isiOS()&&z(fm(ee(E(a,function(a){return L.ancestor(a,"ul,ol",q)})),function(a){return a.dom()}),function(a){var b=v.get(a[0],"list-style-type");v.set(a[0],"list-style-type","none");setTimeout(function(){v.set(a[0],"list-style-type",b)},0)})},w=function(){return $b.cata(a.selections().get(),
  k([]),function(a){return 0<a.length?Xy.groups(d,a[0]):[]},function(a,b){return Xy.groups(d,a.startContainer(),q)})},I=function(a){var b=se.hasSelection(f),c=$U.read(f,d),e=w();a.populate(e);am.updateMenu(a,c.tag(),b.content(),d.everything(),g.none())},G=function(b){d.ruleByName(b).each(function(b){Pf.cata(b,function(b,c,d){Ih.inline(e,f,h,a.selections(),b)},function(b,c,d,l){Ih.setClass(e,f,h,a.selections(),b,c)},function(b,c,d){Ih.transform(e,f,h,a.selections(),b).each(function(a){z(a,function(a){m.remove(a,
  "class")});C(a)})},function(b,c,d,l){Ih.transform(e,f,h,a.selections(),b).each(function(a){z(a,function(a){m.set(a,"class",c)});C(a)})});f.uiChanged()})},V=Aa("region content undo selections keyboard listConstructor type styles textkey menuTextkey".split(" "),[]),X=V({region:e,content:f,undo:h,selections:a.selections(),keyboard:a.keyboard(),listConstructor:u(gm.unordered,q),type:"bullist",styles:["default","disc","circle","square"],textkey:x.key("action.bullist"),menuTextkey:x.key("list.unordered.menu")});
  V=V({region:e,content:f,undo:h,selections:a.selections(),keyboard:a.keyboard(),listConstructor:u(gm.ordered,q),type:"numlist",styles:"default decimal upper-alpha lower-alpha upper-roman lower-roman lower-greek".split(" "),textkey:x.key("action.numlist"),menuTextkey:x.key("list.ordered.menu")});var dd=function(a){return x.translate("block.describe",x.get(a.textkey()))};X=u(Uy,X);V=u(Uy,V);return{ui:vb.ui({"blocktag.dropdown":function(){return{name:"blocktag",textkey:x.key("block.styles"),menuTextkey:x.key("block.menu"),
  updateDropdown:I,action:G,values:d.everything(),render:l,tooltip:rb.get,toggle:!1,describe:dd}},"bullist.widget":X,"numlist.widget":V,"bullist.general":k(Yy.ul(a)),"numlist.general":k(Yy.ol(a))},ca),events:c.registry,destroy:t}}function jb(a,b,c,d){return{context:a,profile:b,action:c,label:k(d)}}function aV(a){var b=a.content(),c=gd.destroyable();return{ui:vb.ui({"bookmark.general":{toggle:!1,value:"bookmark",textkey:x.key("insert.bookmark"),action:function(){b.getSelection().each(function(a){var c=
  p.fromTag("span"),d=b.getSelectedText().fold(function(){return hm.generate("textbox-bookmark")},function(a){a=50<a.length?a.substr(0,50):a;return hm.generate(Ld.getAnchorValue(a,"textbox-bookmark"))});m.set(c,"id",d);a=hd.after(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset())?Rc(a.endContainer(),a.endOffset(),a.endContainer(),a.endOffset()):Rc(a.startContainer(),a.startOffset(),a.startContainer(),a.startOffset());var h=p.fromText(mb());rd.insertAt(b,a,[c,h]).each(function(a){var c=
  A.nextSibling(a.element()).filter(function(a){return wa.isCursorPosition(a)&&!N.eq(h,a)}).getOrThunk(function(){var b=p.fromText(" ");y.after(a.element(),b);return b});b.win().each(function(a){Wa.setExact(a,c,0,c,0)})})})},updateGeneral:t,icon:!0,shortcut:!1,hasPopup:!1,hasDialog:!0}}),destroy:function(){c.clear()}}}function bV(a,b){return{is:function(c){return m.get(c,a)===b},remove:function(b){m.remove(b,a)},set:function(c){m.set(c,a,b)}}}function cV(a){var b=a.content(),c=H.create({analytics:r(["message",
  "properties"])}),d=function(a,c){Zy.readDir(b).map(function(b){return b[a]}).fold(Da.unchanged,xb).fold(c.deselect,t,c.select)};return{ui:vb.ui({"ltrdir.general":{value:"ltrdir",textkey:x.key("directionality.ltrdir"),action:u($y.dirLtr,a),updateGeneral:u(d,"ltrdir"),toggle:!0},"rtldir.general":{value:"rtldir",textkey:x.key("directionality.rtldir"),action:u($y.dirRtl,a),updateGeneral:u(d,"rtldir"),toggle:!0}}),events:c.registry,destroy:t}}function az(a,b){return bz(document.createElement("canvas"),
  a,b)}function cz(a){return a.getContext("2d")}function bz(a,b,c){a.width=b;a.height=c;return a}function dz(a,b){return new (Jc.getOrDie("Blob"))(a,b)}function Yq(){return new (Jc.getOrDie("FileReader"))}function ez(a){return new (Jc.getOrDie("Uint8Array"))(a)}function fz(a){return new Md(function(b,c){function d(){l();b(h)}function e(){l();c("Unable to load data of type "+a.type+": "+f)}var f=URL.createObjectURL(a),h=new Image,l=function(){h.removeEventListener("load",d);h.removeEventListener("error",
  e)};h.addEventListener("load",d);h.addEventListener("error",e);h.src=f;h.complete&&d()})}function gz(a){return new Md(function(b,c){var d=new XMLHttpRequest;d.open("GET",a,!0);d.responseType="blob";d.onload=function(){200==this.status&&b(this.response)};d.onerror=function(){if(0===this.status){var a=Error("No access to download image");a.code=18;a.name="SecurityError"}else a=Error("Error "+this.status+" downloading image");c(a)};d.send()})}function hz(a){var b=a.split(",");a=/data:([^;]+)/.exec(b[0]);
  if(!a)return g.none();a=a[1];b=im.atob(b[1]);for(var c=b.length,d=Math.ceil(c/1024),e=Array(d),f=0;f<d;++f){for(var h=1024*f,l=Math.min(h+1024,c),q=Array(l-h),C=0;h<l;++C,++h)q[C]=b[h].charCodeAt(0);e[f]=ez(q)}return g.some(dz(e,{type:a}))}function Zq(a){return new Md(function(b,c){hz(a).fold(function(){c("uri is not base64: "+a)},b)})}function iz(a){return new Md(function(b){var c=new Yq;c.onloadend=function(){b(c.result)};c.readAsDataURL(a)})}function $q(a,b,c){function d(b,c){return a.then(function(a){return id.canvasToDataURL(a,
  b,c)})}return{getType:k(b.type),toBlob:function(){return Md.resolve(b)},toDataURL:function(){return c},toBase64:function(){return c.split(",")[1]},toAdjustedBlob:function(b,c){return a.then(function(a){return id.canvasToBlob(a,b,c)})},toAdjustedDataURL:d,toAdjustedBase64:function(a,b){return d(a,b).then(function(a){return a.split(",")[1]})},toCanvas:function(){return a.then(Tc.clone)}}}function jz(a){return id.blobToDataUri(a).then(function(b){return $q(id.blobToCanvas(a),a,b)})}function dV(a){var b=
  H.create({insertAssets:r(["assets"]),insertHtml:r(["html"])}),c=a.content(),d=g.none(),e=function(a){c.win().each(function(b){Wa.getAtPoint(b,a.x(),a.y()).each(function(a){Wa.setExact(b,a.start(),a.soffset(),a.finish(),a.foffset())})})},f=function(a){e(a);b.trigger.insertAssets(a.assets())},h=function(b){e(b);b=b.html();a.undo().save();b=qe.fromHtml(b);rd.insertAtCursor(c,b)};c.events.ready.bind(function(a){var b=g.none();d=g.some(eV.forImages(a.api().canvas(),b,!0));d.each(function(a){a.events.dragndropimages.bind(f);
  a.events.dragndrophtml.bind(h)})});return{events:b.registry,destroy:function(a){d.each(function(a){a.destroy()})}}}function jm(a,b){var c=void 0!==b?b:36E5,d=O("result","timestamp"),e={},f=function(a,b,c){e[a]=d(b,c)};b=function(a){var b=wj.now();eb(a,function(a,d){b-a.timestamp<c&&f(d,a.result,a.timestamp)})};ic(a)&&b(a);return{set:f,get:function(a,b){return g.from(e[b]).filter(function(b){return a-b.timestamp()<c}).map(function(a){return a.result()})},dump:function(){return eb(e,function(a){return{result:a.result(),
  timestamp:a.timestamp()}})}}}function fV(a){return Ea.nu(function(b){var c=Yq();c.onload=function(a){b(a.target.result)};c.readAsText(a)})}function gV(a,b,c){var d=jm(c),e=km.get("ephox.media.service.one",ar.requestOne(),a+"/1/embed?url=${url}&maxWidth=${maxWidth}",b);return{checkOne:function(a,b,c){var f=wj.now();c=lm.single(function(c,d){return e.execute({url:encodeURIComponent(a),maxWidth:b,fresh:d})},d,b+"&"+a,f,void 0!==c?c:!1);return hf.foldSync(c,kz.failed,kz.success)},dumpCache:d.dump}}function hV(a,
  b,c){var d=br.embedChecking(),e=a.internalevents(),f=a.communication(),h=gV(c.url,f.newHeaders(),b.cache),l=a.undo(),q=a.content();a=a.filter();br.configure(a);var C=["img","video","audio"],g=function(a,b){y.after(a,b);F.remove(a)},k=function(a,b){n.add(a,d);var e=h.checkOne(b,400);hf.handle(e,function(b){n.remove(a,d)},function(e){n.remove(a,d);l.save();var f=iV(e.recommended().html().trim());U(C,D.name(f))||m.set(f,"data-ephox-embed-iri",b);var h=p.fromTag("div");y.append(h,f);c.inlineStyles&&q.doc().each(function(a){lz.inlinePrefixedStyles(a,
  h,".ephox-summary-card")});q.getSelection().fold(function(){g(a,f)},function(b){var c=N.eq(b.startContainer(),a)||N.contains(a,b.startContainer());g(a,f);var d=A.nextSibling(f).filter(wa.isCursorPosition).getOrThunk(function(){var a=p.fromTag("br");y.after(f,a);return a});(c||A.parent(f).filter(function(a){return b.collapsed()&&(N.eq(b.startContainer(),a)||N.contains(a,b.startContainer()))}).isSome())&&q.setSelection(d,0,d,0)})})},G=function(a){var b=a.command(),c=a.data();m.has(c,sb.bookmarkAnchorDataAttr())||
  "insertLink"!==b&&"updateLink"!==b||A.parent(c).each(function(a){var b=Vb.get(a).replace(mb(),""),d=m.get(c,"href");if(b===d||"http://"+b===d)k(c,d);else{var e=A.children(a),f=qa(jd(e),function(a){return"br"===D.name(a)&&mm.documentPositionPreceding(c.dom(),a.dom())}).map(function(a){a=Gc(e,a).getOr(-1);return e.slice(a+1,e.length)}).getOr(e);a=qa(e,function(a){return"br"===D.name(a)&&mm.documentPositionPreceding(a.dom(),c.dom())}).map(function(a){a=Gc(f,a).getOr(0);return f.slice(0,a)}).getOr(f);
  a=hb(a,function(a,b){return a+Vb.get(b)},"").replace(mb(),"");a!==d&&"http://"+a!==d||k(c,d)}})};e.events.internal.bind(G);return{destroy:function(){e.events.internal.unbind(G)},state:function(){return{cache:h.dumpCache()}}}}function mz(a){var b=function(){return null===a.project.apiKey?{}:{"textbox-api-key":a.project.apiKey}},c=function(a){var b=a+(-1===a.indexOf("?")?"?":"&")+"url=";return function(a){return g.some(b+encodeURIComponent(a))}};c=void 0===a.imageEdit.proxy?g.none:c(a.imageEdit.proxy);
  return{headers:function(){return{headers:b(),xhrFields:{withCredentials:!0}}},newHeaders:b,proxy:c,destroy:t}}function jV(a){var b="true"===m.get(a,"contenteditable");m.set(a,"contenteditable","true");var c=K.bind(a,"keydown",function(a){A.trigger.keydown(a)}),d=K.bind(a,"keyup",function(a){A.trigger.keyup(a)}),e=K.bind(a,"keypress",function(a){A.trigger.keypress(a)}),f=K.bind(a,"mousedown",function(a){A.trigger.mousedown(a)}),h=K.bind(a,"mouseout",function(a){A.trigger.mouseout(a)}),l=K.bind(a,"mouseup",
  function(a){A.trigger.mouseup(a)}),q=K.bind(a,"contextmenu",function(a){A.trigger.contextmenu(a)}),C=K.bind(a,"cut",function(a){A.trigger.cut(a)}),w=K.bind(a,"copy",function(a){A.trigger.copy(a)}),I=K.bind(a,"paste",function(a){A.trigger.paste(a)}),G=K.bind(p.fromDom(document),"selectionchange",function(a){A.trigger.selectionchange(a)}),V=function(){A.trigger.paint()},X=K.capture(a,"load",V);nz.bind(a,V);var dd=oz.browser.isFirefox()?"focus":"focusin",u=K.bind(a,dd,function(a){A.trigger.focus(a)}),
  v=K.bind(a,"focusout",function(a){A.trigger.focusOut(a)}),y=K.bind(a,"dblclick",function(a){A.trigger.dblclick(a)}),x=function(b){return N.eq(a,b)};dd={loaded:Ea.pure(J.error("no iframe in inline mode")),stylesheetLoad:Ea.pure(g.none())};var A=H.create({keydown:r(["original"]),keyup:r(["original"]),keypress:r(["original"]),mousedown:r(["original"]),mouseup:r(["original"]),mouseout:r(["original"]),contextmenu:r(["original"]),cut:r(["original"]),copy:r(["original"]),paste:r(["original"]),focus:r(["original"]),
  dblclick:r(["original"]),focusOut:r(["original"]),selectionchange:r(["original"]),paint:r([])});return{win:k(window),doc:k(p.fromDom(document)),body:k(a),get:function(){return Ha.get(a)},set:function(b){Ha.set(a,b)},focus:function(){oz.browser.isIE()?a.dom().setActive(!0):Z.focus(a)},focused:function(){return document.activeElement===a.dom()},blur:function(){a.dom().blur()},destroy:function(){b||m.remove(a,"contenteditable");z([c,d,e,f,l,h,q,C,w,I,u,v,y,G,X],function(a){a.unbind()});nz.unbind(a,V)},
  events:A.registry,futures:dd,background:t,foreground:t,hasRange:function(a){return Ja.closest(a.startContainer(),x).isSome()&&Ja.closest(a.endContainer(),x).isSome()},isActive:function(){return n.has(a,be.active())}}}function pz(a,b,c){var d=u(N.eq,b),e=function(c){var e=kb.freefallRtl(b).element();return L.ancestor(e,"table",d).filter(kV(a,c)).map(qz.above)},f=function(b,d,e,f,g){b.kill();Wa.setExact(a,d,e,f,g);c()};return function(c){var h=c.y();e(h).orThunk(function(){var c=kb.freefallLtr(b).element();
  return L.ancestor(c,"table",d).filter(lV(a,h)).map(qz.below)}).fold(function(){if("html"===D.name(c.target())){var e=c.x(),h=c.y();Wa.getAtPoint(a,e,h).each(function(a){var e=function(a){return L.closest(a,'[contenteditable="false"]',d).isSome()},h=e(a.start());e=e(a.finish());(h||e)&&nm.browser.isIE()||Z.focus(b);if(nm.browser.isIE()&&1===A.childNodesCount(b)&&(h=A.children(b)[0],"p"===D.name(h)&&0===A.childNodesCount(h))){y.append(h,p.fromTag("br"));f(c,h,0,h,0);return}f(c,a.start(),a.soffset(),
  a.finish(),a.foffset())})}},function(a){var b=p.fromHtml("<p><br /></p>");a.fold(function(a){y.after(a,b)},function(a){y.before(a,b)});f(c,b,0,b,0)})}}function rz(a){var b=null,c=function(){b=null;ac.get(a.win()).each(function(b){b.collapsed()&&a.focused()&&d.trigger.loiter(b.startContainer(),b.startOffset())})},d=H.create({loiter:r(["node","offset"])});return{reset:function(){null!==b&&(clearTimeout(b),b=null);b=setTimeout(c,1E3)},destroy:function(){null!==b&&(clearTimeout(b),b=null)},events:d.registry}}
  function sz(a,b){var c=g.none(),d=Hd.tap(function(){d.control.block();var f=a();f.filter(function(a){return ja.inBody(a.startContainer())}).each(function(a){var d=function(){e.trigger.nodeChanged(a.startContainer(),a.startOffset(),c.map(function(a){return a.startContainer()}))};c.fold(d,function(c){var e=N.eq,f=a.startContainer(),h=a.endContainer(),l=c.startContainer(),q=c.endContainer(),g=c.startOffset()!==a.startOffset();c=c.endOffset()!==a.endOffset();(!e(l,f)||!e(q,h)||!D.isText(f)&&g||!D.isText(h)&&
  c)&&!1===mV([a.startContainer()],b)&&d()})});c=f;d.control.unblock()}),e=H.create({nodeChanged:r(["node","offset","prev"])});return{update:function(){d.instance()},clear:function(){c=g.none()},destroy:function(){c=g.none();d.control.block()},events:e.registry}}function nV(){var a=g.none();return{get:function(){return a},restore:function(b){a.each(b)},update:function(b){a=b.or(a)},clear:function(){a=g.none()}}}function oV(a,b){var c=function(){return V().orThunk(f.get)},d=K.bind(a.body(),"click",pz(a.win(),
  a.body(),t)),e=sz(c,b),f=nV(),h=function(){e.update();G()},l=function(){f.restore(function(a){X(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset())})};e.events.nodeChanged.bind(function(a){x.trigger.nodeChanged(a.node(),a.offset(),a.prev());x.trigger.uiStale()});a.events.keyup.bind(function(a){x.trigger.keyup(a.original());h();q.reset();x.trigger.interaction()});a.events.mouseout.bind(function(a){G()});a.events.mouseup.bind(function(a){x.trigger.mouseup(a.original());h();q.reset();
  x.trigger.interaction()});var q=rz(a);q.events.loiter.bind(function(a){x.trigger.loiter(a.node(),a.offset())});var C=function(){V().isNone()?l():G()},g=function(){a.isActive()&&(C(),tz.focus(a,c,n))},k=function(){x.trigger.domChanged()},G=function(){var a=V();f.update(a)},V=function(){return ac.get(window).filter(a.hasRange)},X=function(a,b,c,d){try{ac.setExact(window,a,b,c,d)}catch(Eoa){console.log("Skipping restoring invalid cursor position")}},m=function(b){v(function(c){a.isActive()&&b();h()},
  cr.build(a.focused,C,g,p.fromDom(document)))},n=function(a,b,c,d){m(function(){X(a,b,c,d)})},u=function(a,b){var c=ac.get(window);l();a=a(b);b.toOld();c.each(function(a){X(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset());pV.browser.isEdge()&&(b.isSet()||b.toOld())});return a},v=function(a,b){a=a(b);b.toOld();return a},z=function(b){var c=cr.build(a.focused,C,g,p.fromDom(document));return(V().isSome()?v:u)(b,c)};b=function(a){return function(){var b=arguments;return z(function(c){c.toEditor();
  return a(b)})}}(function(a){document.execCommand.apply(document,a);G()});var y=function(a,b){return Qa(a,b)},x=H.create({nodeChanged:r(["node","offset","prev"]),loiter:r(["node","offset"]),uiStale:r([]),domChanged:r([]),interaction:r([]),keyup:r(["original"]),mouseup:r(["original"]),keydown:Q(["original"],a.events.keydown),keypress:Q(["original"],a.events.keypress),mousedown:Q(["original"],a.events.mousedown),contextmenu:Q(["original"],a.events.contextmenu),cut:Q(["original"],a.events.cut),copy:Q(["original"],
  a.events.copy),paste:Q(["original"],a.events.paste),focus:Q(["original"],a.events.focus),focusOut:Q(["original"],a.events.focusOut),dblclick:Q(["original"],a.events.dblclick),selectionchange:r(["original"]),paint:Q([],a.events.paint)});a.events.selectionchange.bind(function(a){V().each(function(){x.trigger.selectionchange(a.original())})});return{win:a.win,doc:a.doc,body:a.body,canvas:a.body,getContent:a.get,setContent:a.set,resetContent:function(b){a.set(b);f.clear();e.clear();b=kb.freefallLtr(a.body());
  n(b.element(),b.offset(),b.element(),b.offset());k()},blur:a.blur,focus:function(){cr.toEditor(a.focused,C,g,p.fromDom(document))},uiChanged:function(){z(function(){x.trigger.uiStale()})},domChanged:k,clearSelection:function(){ac.clearAll(window)},getSelection:c,setSelection:n,setRelativeSelection:function(a,b){m(function(){ac.setRelative(window,a,b)})},backupSelection:G,replaceSelection:function(a){V().fold(function(){l();V().each(function(){ac.replace(window,a);h()})},function(b){ac.replace(window,
  a);h()})},execCommand:b,destroy:function(){a.destroy();q.destroy();d.unbind();e.destroy()},events:x.registry,futures:a.futures,background:a.background,foreground:a.foreground,translateScreen:y,translateLocation:y}}function dr(){var a=null,b=[],c=function(){return null!==a},d=function(){z(b,function(a){e(a)})},e=function(b){setTimeout(function(){b.apply(null,a)},0)};return{get:function(a){c()?e(a):b.push(a)},set:function(){a=Array.prototype.slice.call(arguments);d();b=[]},isSet:c}}function qV(a,b,
  c){var d=p.fromTag("div");S.presentation(d);v.set(d,"display","none");var e=Ha.get(a);(function(b){var c=A.owner(a);z(b,function(a){rV.addLinkIfMissing(c,a)})})(b);b=dr();var f=jV(a),h=oV(f,c);b.set(h);return{element:function(){return a},onCanvas:function(a){a(h.canvas())},initial:k(e),placeholder:function(){return d},tabindex:function(b){m.set(a,"tabindex",b)},destroy:function(){F.remove(d);h.destroy()},loaded:b.get,isInline:k(!0)}}function sV(a,b){var c=a.doc();return{execCommand:function(a){var d=
  arguments,f=a.toLowerCase(),h=yb("This should not be in hare.");h={fontsize:h,forecolor:h,fontname:h,bgcolor:h,inserthtml:h,blockquote:h};(void 0!==h[f]?h[f]:function(){c.dom().execCommand.apply(c.dom(),d)})();b.update()}}}function tV(a){var b=function(){return ac.get(a.win())},c=function(b,c,f,h){b=Rc(b,c,f,h);ac.set(a.win(),b)};return{clearSelection:function(){ac.clearAll(a.win())},getSelection:b,replaceSelection:function(b){ac.replace(a.win(),b)},setSelection:c,setRelativeSelection:function(b,
  c){ac.setRelative(a.win(),b,c)},restore:t,backup:t,nativeCall:xb,focus:function(){tz.focus(a,b,c)},destroy:t,clear:t}}function uV(a,b){var c=g.none(),d=K.bind(b,"blur",function(a){f()}),e=function(){c=g.none()},f=function(){ac.get(a.win()).fold(t,function(a){c=g.some(a)})},h=function(b,d){try{d(a.win(),b),c=g.some(b)}catch(G){uz()}},l=function(a){h(a,ac.set)},q=function(){c.each(l)},C=function(a){var b=document.activeElement;a=a();null!==b&&void 0!==b&&b!==document.activeElement&&void 0!==b.focus&&
  b.focus();return a};return{clearSelection:function(){Z.hasFocus(b)&&ac.clearAll(a.win())},getSelection:function(){return Z.hasFocus(b)?ac.get(a.win()):c},replaceSelection:function(c){Z.hasFocus(b)||q();ac.replace(a.win(),c)},setSelection:function(a,c,d,e){C(function(){var f=Rc(a,c,d,e);Z.hasFocus(b)?l(f):h(f,t)})},setRelativeSelection:function(b,c){C(function(){e();try{ac.setRelative(a.win(),b,c)}catch(G){uz()}f()})},restore:q,backup:f,nativeCall:function(a){return C(function(){Z.hasFocus(b)||q();
  return a()})},focus:function(){if(document.activeElement!==b.dom()){var d=c;a.focus();d.each(l)}else ac.get(a.win()).fold(q,t)},destroy:function(){d.unbind()},clear:e}}function vV(a,b,c){var d=aa.detect(),e=d.browser.isIE()||d.browser.isEdge()?uV(a,b):tV(a),f=K.bind(a.doc(),"click",pz(a.win(),a.body(),e.backup)),h=function(){return e.getSelection()},l=sz(h,c),q=sV(a,l);(d.browser.isChrome()||d.browser.isSafari())&&q.execCommand("defaultParagraphSeparator",!1,"p");l.events.nodeChanged.bind(function(a){X.trigger.nodeChanged(a.node(),
  a.offset(),a.prev());X.trigger.uiStale()});a.events.keyup.bind(function(a){e.backup();l.update(a)});var C=jf(l.update,300);a.events.mouseup.bind(function(a){e.backup();C.throttle(a)});var g=rz(a);g.events.loiter.bind(function(a){X.trigger.loiter(a.node(),a.offset())});c=function(){g.reset();X.trigger.interaction()};a.events.keyup.bind(c);a.events.mouseup.bind(c);a.events.paint.bind(function(a){return X.trigger.paint()});var k=function(){X.trigger.domChanged()},G=function(a,b,c,d){e.setSelection(a,
  b,c,d);l.update()},V=function(a,c){return bb.absolute(b).translate(a,c)},X=H.create({nodeChanged:r(["node","offset","prev"]),loiter:r(["node","offset"]),uiStale:r([]),domChanged:r([]),interaction:r([]),keydown:Q(["original"],a.events.keydown),keyup:Q(["original"],a.events.keyup),keypress:Q(["original"],a.events.keypress),mousedown:Q(["original"],a.events.mousedown),mouseup:Q(["original"],a.events.mouseup),contextmenu:Q(["original"],a.events.contextmenu),cut:Q(["original"],a.events.cut),copy:Q(["original"],
  a.events.copy),paste:Q(["original"],a.events.paste),focus:Q(["original"],a.events.focus),focusOut:Q(["original"],a.events.focusOut),dblclick:Q(["original"],a.events.dblclick),selectionchange:Q(["original"],a.events.selectionchange),paint:r([])});return{win:a.win,doc:a.doc,body:a.body,canvas:a.doc,getContent:a.get,setContent:a.set,resetContent:function(b){a.set(b);e.clear();l.clear();b=kb.freefallLtr(a.body());G(b.element(),b.offset(),b.element(),b.offset());k()},blur:a.blur,focus:function(){e.focus()},
  uiChanged:function(){X.trigger.uiStale()},domChanged:k,clearSelection:function(){e.clearSelection()},getSelection:h,setSelection:G,setRelativeSelection:function(a,b){e.setRelativeSelection(a,b);l.update()},backupSelection:function(){e.backup()},replaceSelection:function(a){e.replaceSelection(a);l.update()},execCommand:function(){var a=arguments;e.nativeCall(function(){q.execCommand.apply(null,a);X.trigger.uiStale()})},destroy:function(){e.destroy();a.destroy();g.destroy();f.unbind();l.destroy()},
  events:X.registry,futures:a.futures,background:a.background,foreground:a.foreground,translateScreen:V,translateLocation:function(b,c){var d=Za.get(a.doc());return V(b,c).translate(-d.left(),-d.top())}}}function wV(a){return{background:t,foreground:t,focus:t,keydown:t,mousedown:g.some,mouseup:g.some,selectionchange:function(a){return jf(a,300).throttle}}}function xV(a,b){return{background:t,foreground:t,focus:function(a,d,e){Za.preserve(p.fromDom(document),function(){Za.preserve(A.owner(e),function(){b.browser.isEdge()&&
  window.getSelection().removeAllRanges();e.dom().focus()})})},keydown:t,mousedown:g.some,mouseup:g.some,selectionchange:k(t)}}function yV(a){var b=function(a){return"body"===D.name(a.target())||"html"===D.name(a.target())?g.none():g.some(a)};return{background:function(a,b,e){A.owner(b).dom().defaultView.focus()},foreground:function(a,b,e){void 0!==a.focus&&a.focus()},focus:t,keydown:function(a){void 0!==a.focus&&a.focus()},mousedown:function(a){return b(a)},mouseup:function(a){return b(a)},selectionchange:k(t)}}
  function zV(a,b){var c=a.dom().contentWindow,d=vz.doc(a),e=L.descendant(d,"body").getOrDie();ma.add(e,[be.base(),be.active()]);b.autoresize&&n.add(A.documentElement(e),be.autoresize());var f=AV.browser.isFirefox(),h=H.create({keydown:r(["original"]),keyup:r(["original"]),keypress:r(["original"]),mousedown:r(["original"]),mouseup:r(["original"]),contextmenu:r(["original"]),cut:r(["original"]),copy:r(["original"]),paste:r(["original"]),focus:r(["original"]),dblclick:r(["original"]),focusOut:r(["original"]),
  paint:r([]),selectionchange:r(["original"])}),l=BV.get(h),q=function(){return ka(d.dom().styleSheets,function(a){try{return 0<=a.cssRules.length}catch(Foa){return b.needStyles&&console.warn("Unable to access rules from "+a.href),!1}})},C={stylesheetLoad:Ea.nu(function(a){var b=0,d=setInterval(function(){50<b||0>=c.stillToLoad?(clearInterval(d),a(g.some(q()))):b++},100)})},w=K.bind(d,"keydown",function(a){l.keydown(c);h.trigger.keydown(a)}),I=K.bind(d,"keyup",function(a){h.trigger.keyup(a)}),G=K.bind(d,
  "keypress",function(a){h.trigger.keypress(a)}),V=K.bind(d,"mousedown",function(a){l.mousedown(a).fold(function(){a.kill()},h.trigger.mousedown)}),X=K.bind(d,"mouseup",function(a){l.mouseup(a).fold(function(){a.kill()},h.trigger.mouseup)}),m=K.bind(d,"contextmenu",function(a){h.trigger.contextmenu(a)}),p=K.bind(d,"cut",function(a){h.trigger.cut(a)}),t=K.bind(d,"copy",function(a){h.trigger.copy(a)}),u=K.bind(d,"paste",function(a){h.trigger.paste(a)}),v=K.bind(d,f?"focus":"focusin",function(a){h.trigger.focus(a)}),
  x=K.bind(d,"focusout",function(a){h.trigger.focusOut(a)}),y=K.bind(d,"dblclick",function(a){h.trigger.dblclick(a)}),B=l.selectionchange(function(a){h.trigger.mouseup(a)}),D=K.bind(d,"selectionchange",function(a){B(a);h.trigger.selectionchange(a)}),E=K.bind(d,"touchstart",function(a){h.trigger.mousedown(a)}),F=K.bind(d,"touchend",function(a){h.trigger.mouseup(a);O()}),J=function(){h.trigger.paint()},M=K.capture(d,"load",J),N=function(){c.addEventListener("resize",J,!1);return{unbind:function(){c.removeEventListener&&
  c.removeEventListener("resize",J,!1)}}}(),O=function(){l.foreground(c,a,e)};return{win:k(c),doc:k(d),body:k(e),get:function(){return Ha.get(e)},set:function(a){Ha.set(e,a)},focus:function(){l.focus(c,a,e)},focused:function(){return document.activeElement===a.dom()},blur:function(){e.dom().blur()},destroy:function(){z([w,I,G,V,X,m,p,t,u,v,x,D,y,E,F,M,N],function(a){a.unbind()})},events:h.registry,futures:C,background:function(){l.background(c,a,e)},foreground:O}}function CV(a){var b=p.fromTag("iframe");
  n.add(b,DV.resolve("content-iframe"));var c=g.none(),d=dr(),e=K.bind(b,"load",function(){e.unbind();var f=EV(a);wz.write(b,f);f=xz.onShow(b,function(){c.each(xb);c=g.none();ja.inBody(b)&&d.set(zV(b,a))});c=g.some(f)});return{element:function(){return b},tabindex:function(a){m.set(b,"tabindex",a)},destroy:function(){F.remove(b);e.unbind();c.each(xb)},loaded:d.get}}function FV(a,b){var c=CV(a),d=dr(),e=t;c.loaded(function(f){var h=aa.detect().browser.isIE(),l=vV(f,c.element(),b),q=c.element(),C=A.parent(q).fold(function(){return 0},
  function(a){return parseInt(v.get(a,"min-height"))}),g=function(a){v.remove(l.body(),"min-height");a=sa.get(A.documentElement(l.body()));var b=sa.get(q);a!==b&&(b=parseInt(v.get(q,"margin-top")),b=C-b,a=a>b?a:b,v.set(q,"min-height",a+"px"),150>a?v.set(q,"height",a+"px"):v.remove(q,"height"))},k=function(a){a=sa.get(l.body());var b=sa.get(c.element());a!==b&&sa.set(l.body(),b)},G=tj(g,0);h=h?G.throttle:g;h=a.autoresize?h:k;g=a.autoresize?g:k;l.events.uiStale.bind(u(h,"uiStale"));l.events.domChanged.bind(u(h,
  "domChanged"));l.events.paint.bind(u(h,"paint"));f.events.keyup.bind(u(g,"keyup"));f.events.mouseup.bind(u(g,"mouseup"));setTimeout(function(){d.set(l);e=l.destroy},0)});return{element:c.element,onCanvas:function(a){d.get(function(b){a(b.canvas())})},initial:k(""),placeholder:c.element,tabindex:c.tabindex,destroy:function(){e();c.destroy()},loaded:d.get,isInline:k(!1)}}function GV(a){var b=g.none(),c=g.none(),d=function(){b.each(function(b){a.setSelection(b.startContainer(),b.startOffset(),b.endContainer(),
  b.endOffset())});c.each(function(a){a.restore()})},e=function(){b=g.none();c=g.none()};return{restore:function(){d();e()},save:function(){b=a.getSelection();c=a.doc().map(Za.capture)},get:function(){return b},clear:e,attempt:function(a){b=a.or(b)}}}function er(){var a=H.create({fail:r(["url","image"]),success:r(["url","image"]),start:r(["url"])}),b=function(a,b,c){var d=a.dom();d.addEventListener(b,c,!1);return{unbind:function(){d.removeEventListener(b,c,!1)}}},c=function(c){var d=m.get(c,"src"),
  f=b(c,"load",function(){f.unbind();h.unbind();(!0===c.dom().complete?a.trigger.success:a.trigger.fail)(d,c)}),h=b(c,"error",function(){f.unbind();h.unbind();a.trigger.fail(d,c)})};return{go:function(b){a.trigger.start(b);var d=new Image;d.src=b;c(p.fromDom(d))},monitor:c,events:a.registry}}function HV(a){var b=na({}),c=na([]),d={},e=g.none();return{structure:b.get,all:c.get,main:function(){return c.get()[0]},update:function(f){z(c.get(),function(a){F.remove(a)});e=g.some(f);var h=cb(d);Ma(d,function(a){a.assign(e)});
  var l=eb(d,function(a,b){return a.situation(f)}),q=IV.derive(a,h,l),C=JV.derive(a,h,l);h=Eb(h,function(a,b){return ua(a,l[b].submenus())},{});if(0===q.length)c.set([]);else{var w=zb.mainmenu(a,B.resolve("main-context-menu"),[]);P.append(w,q);S.menu(w,x.translate("aria.context.menu.generic"));q=[w].concat(C);z(q,function(a){n.add(a,B.resolve("layer-menus"))});c.set(q);b.set(h)}},handle:function(a){var b=fr.type(a);b=d[b];void 0!==b&&b.handle(a)},register:function(a,b){d[a]=b}}}function KV(a,b,c,d,
  e,f){var h=[],l={register:function(a,b){h=h.concat([{name:a,feature:b}])},destroy:t};b.events.ready.bind(function(q){l=LV(a,b,c,d,e,f);z(h,function(a){l.register(a.name,a.feature)})});return{register:function(a,b){l.register(a,b)},destroy:function(){l.destroy()}}}function MV(a,b,c,d){var e=function(c){b.get().fold(t,function(b){c.stopper();d.transaction(function(){z(b,NV)});a.domChanged();a.toEditing();qa(b,function(a){return Ia.is(a,te.lastSelectedSelector())}).bind(kc.first).each(function(b){a.setSelection(b,
  0,b,0)})},t)},f=c.editor();f.events.del.bind(e);f.events.backspace.bind(e);f.on();return{destroy:function(){f.off()}}}function OV(){var a=!0;return{isHandled:function(){return a},handle:function(){a=!1}}}function PV(a,b){var c=H.create({preLinebreak:r(["handler"]),postLinebreak:r([])});QV.listen(a);var d=function(d){b.save();a.getSelection().each(function(b){var e=OV();c.trigger.preLinebreak(e);a.getSelection().each(function(b){e.isHandled()&&(yz.preLinebreak(a),(d?zz.soft:zz.hard)(b,a.isRoot).each(function(b){a.setRelativeSelection(b.start(),
  b.finish());a.domChanged();a.cursorIntoView()}));c.trigger.postLinebreak()})})},e=se.isTextArea;a.events.keydown.bind(function(a){fe.isEnter(a)&&!e(a.original().target())&&(a.original().raw().preventDefault(),d(a.original().raw().shiftKey))});return{linebreak:d,destroy:t,events:c.registry}}function gr(a,b){return{find:function(b){return Y.descendants(b,a)},cleaner:b}}function RV(){var a=[];return{add:function(b){a.push(b)},get:function(){return a.slice(0)}}}function SV(){var a={},b=function(b){return g.from(a[b])};
  return{get:b,getOrInit:function(b){var c=a[b];void 0===c&&(a[b]=RV(),c=a[b]);return c},filterDom:function(a,d){b(a).each(function(a){om.filterDom(d,a.get())})},filterHtml:function(a,d){return b(a).fold(function(){return d},function(a){return om.filterHtml(d,a.get())})}}}function TV(a,b){return{find:function(b){return cd.descendants(b,a)},cleaner:b}}function UV(a){var b=SV(),c=k("output"),d=k("input"),e=k("history"),f=k("internal"),h=k("paste"),l=[],q=function(a,c,d){a=b.getOrInit(a);c=gr(c,d);a.add(c)},
  C=function(a,c,d){a=b.getOrInit(a);c=TV(c,d);a.add(c)};a=ey(a,q,C);return{add:function(a,b,c){q(a,"."+b,c)},addSelector:q,addPredicate:C,filterHtml:b.filterHtml,filterDom:b.filterDom,internal:f,output:c,input:d,paste:h,history:e,customFilters:k(a),state:a.state,destroy:t,addExcludedContext:function(a){l=l.concat(a)},includeContext:function(a){return!Xa(l,u(Ia.is,a))}}}function VV(a,b,c){var d=!1,e=H.create({maximize:r(["layout"]),restore:r(["layout"]),analytics:r(["message"]),select:r([]),deselect:r([])}),
  f=function(){e.trigger.maximize(c.alternate)},h=function(){e.trigger.restore(c.alternate)},l=function(a){d?a.select():a.deselect()},q=function(){e.trigger.analytics("fullscreen_"+(d?"off":"on"));a.focus();(d?h:f)()},C=function(a,b){a=x.key(d?"action.toggle.fullscreen":"action.fullscreen");return rb.get(a,b)};b.events.fullscreen.bind(q);b=vb.ui({"fullscreen.general":function(){return{toggle:!0,value:"fullscreen",textkey:x.key("action.fullscreen"),tooltip:C,action:q,updateGeneral:l,icon:!0,shortcut:!0,
  selected:d}}},ca);var g=vb.actions({maximize:f,restore:h});return{ui:b,actions:g,select:function(){d=!0},deselect:function(){d=!1},destroy:t,events:e.registry}}function WV(){var a={inputLinks:"insertLink"},b=H.create({internal:r(["command","data"])}),c=function(c,e){g.from(a[c]).fold(function(){throw Error("invalid internal event: "+c);},function(a){z(e,function(c){b.trigger.internal(a,c)})})};return{input:function(a){a=Ld.many(a);c("inputLinks",a)},destroy:t,events:b.registry}}function XV(a,b,c){var d=
  oj(),e=[K.bind(b,"keydown",d.keydown),K.bind(b,"keypress",d.keypress),K.bind(c,"keydown",d.keydown),K.bind(c,"keypress",d.keypress)],f=function(a){d.keydown(a.original())},h=function(a){d.keypress(a.original())};a.events.keydown.bind(f);a.events.keypress.bind(h);return{off:d.off,on:d.on,swallowShortcuts:d.swallowShortcuts,yieldShortcuts:d.yieldShortcuts,swallowChars:d.swallowChars,yieldChars:d.yieldChars,swallowKeys:d.swallowKeys,yieldKeys:d.yieldKeys,destroy:function(){z(e,function(a){a.unbind()});
  a.events.keydown.unbind(f);a.events.keypress.unbind(h)},events:d.events}}function YV(a){var b=oj(),c=function(a){b.keydown(a.original())},d=function(a){b.keypress(a.original())};a.events.keydown.bind(c);a.events.keypress.bind(d);return{off:b.off,on:b.on,swallowShortcuts:b.swallowShortcuts,yieldShortcuts:b.yieldShortcuts,swallowChars:b.swallowChars,yieldChars:b.yieldChars,swallowKeys:b.swallowKeys,yieldKeys:b.yieldKeys,events:b.events,destroy:function(){a.events.keydown.unbind(c);a.events.keypress.unbind(d)}}}
  function ZV(a){var b=oj(),c=K.bind(a,"keydown",b.keydown),d=K.bind(a,"keypress",b.keypress);return{off:b.off,on:b.on,swallowShortcuts:b.swallowShortcuts,yieldShortcuts:b.yieldShortcuts,swallowChars:b.swallowChars,yieldChars:b.yieldChars,swallowKeys:b.swallowKeys,yieldKeys:b.yieldKeys,destroy:function(){c.unbind();d.unbind()},events:b.events}}function $V(a,b){return{all:function(){return XV(a,b.element(),b.uiContainerParent())},container:function(a){return ZV(a)},editor:function(){return YV(a)},destroy:t}}
  function Az(a){return{backup:ca,restore:k(g.none()),element:k(a)}}function aW(a,b){var c=B.resolve("ops-eph-cursor");a.add(a.internal(),c,Ta.remove);a.add(a.output(),c,Ta.remove);a.addExcludedContext(["."+c]);var d=function(a){var d=function(d){d=Bz.diagnose(b.isRoot,d)(c,a);d.cursor().each(function(a){ja.inBody(a.startContainer())&&ja.inBody(a.endContainer())&&b.getSelection().each(function(c){b.setSelection(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset())})});return d.result()};
  return function(){return b.getSelection().fold(a,d)}};return{destroy:t,run:function(a){return d(a)()}}}function bW(a,b){var c=aW(a,b),d=function(a,c){a=a();var d=Cz.handle(c);b.getSelection().forall(function(a){return!N.eq(a.startContainer(),d.startContainer())||!N.eq(a.endContainer(),d.endContainer())||a.startOffset()!==d.startOffset()||a.endOffset()!==d.endOffset()})&&b.setSelection(d.startContainer(),d.startOffset(),d.endContainer(),d.endOffset());return a},e=function(a){return D.isText(a)||"br"===
  D.name(a)};return{destroy:function(){},run:c.run,preserve:u(Ng.preserve,b),lightweightWith:function(a,b){return e(b.startContainer())&&e(b.endContainer())||vc.detect(g.some(b)).isSome()?d(a,b):c.run(a)},adapt:function(a){b.getSelection().each(function(b){c.run(function(){a(b.startContainer(),b.endContainer())})})},pure:function(a){b.getSelection().each(function(b){a(b.startContainer(),b.endContainer())})},atomic:function(a){return c.run(a)}}}function Dz(){var a=H.create({back:r([]),abort:r([])});
  return{ui:vb.ui({"back.general":{toggle:!1,value:"mobile-back",textkey:x.key("toolbar.backbutton"),action:function(){a.trigger.back()},updateGeneral:t,icon:!0,label:!0}}),events:a.registry,destroy:t}}function kf(a,b){return J.error({small:k(a),big:k(b)})}function cW(a,b,c,d,e){var f=function(a,b){return a()?b:{feature:g.none()}};c=f(function(){return!a&&xc.isLargeDesktop()},{feature:c.ui(),command:"fullscreen",type:"general",unsupported:"Fullscreen is not supported in inline mode"});e=xc.choice([xj(xc.isLargeDesktop,
  {feature:d.fileupload().ui(),command:"fileupload",type:"general"}),xj(xc.isLargeTouch,{feature:d.fileupload().ui(),command:"fileupload",type:"menu"})],hr.make({feature:d.fileupload().ui(),command:"fileupload"},e.allowLocalImages?["camera"]:[]));var h=f(xc.isLargeDesktop,{feature:d.accessibility().ui(),command:"a11ycheck",type:"general"});f=f(xc.isLarge,{feature:d.specialchar().ui(),command:"specialchar",type:"general"});var l=xc.choice([xj(xc.isLarge,{feature:d.blocktag().ui(),command:"bullist",type:"split-widget"})],
  {feature:d.blocktag().ui(),command:"bullist",type:"general"}),q=xc.choice([xj(xc.isLarge,{feature:d.blocktag().ui(),command:"numlist",type:"split-widget"})],{feature:d.blocktag().ui(),command:"numlist",type:"general"}),C={feature:d.formatting().ui(),command:"superscript",type:"general"},w={feature:d.formatting().ui(),command:"subscript",type:"general"},k={feature:d.formatting().ui(),command:"strikethrough",type:"general"},G={feature:d.font().ui(),command:"fontface",type:"dropdown"},V=xc.choice([xj(xc.isTouch,
  {feature:d.font().ui(),command:"fontsize",type:"general"})],{feature:d.font().ui(),command:"fontsize",type:"inline-widget"}),X={feature:d.font().ui(),command:"fontcolor",type:"widget"},m={feature:d.spelling().hasAutocorrect()?d.macros().ui():g.none(),command:"autocorrect",type:"general"},n={feature:d.spelling().ui(),command:"spelling",type:d.spelling().hasDropdown()?"dropdown":"general"},p={feature:d.macros().ui(),command:"capitalisation",type:"general"},r={feature:d.help().ui(),command:"help",type:"general"},
  t={feature:d.wordcount().ui(),command:"wordcount",type:"general"};return{link:{feature:d.link().ui(),command:"link",type:"general"},wordcount:t,media:{feature:d.media().ui(),command:"media",type:"general"},hr:{feature:d.horizontalrule().ui(),command:"horizontalrule",type:"general"},specialchar:f,fileupload:e,table:{feature:d.table().ui(),command:"table",type:"widget"},undo:{feature:b.ui(),command:"undo",type:"general"},redo:{feature:b.ui(),command:"redo",type:"general"},styles:{feature:d.blocktag().ui(),
  command:"blocktag",type:"dropdown"},language:{feature:d.parlance().ui(),command:"parlance",type:"dropdown"},ltrdir:{feature:d.directionality().ui(),command:"ltrdir",type:"general"},rtldir:{feature:d.directionality().ui(),command:"rtldir",type:"general"},bold:{feature:d.formatting().ui(),command:"bold",type:"general"},italic:{feature:d.formatting().ui(),command:"italic",type:"general"},underline:{feature:d.formatting().ui(),command:"underline",type:"general"},bookmark:{feature:d.bookmark().ui(),command:"bookmark",
  type:"general"},strikethrough:k,superscript:C,subscript:w,ul:l,ol:q,removeformat:{feature:d.formatting().ui(),command:"removeformat",type:"general"},alignment:{feature:d.alignindent().ui(),command:"alignment",type:"dropdown"},outdent:{feature:d.alignindent().ui(),command:"outdent",type:"general"},indent:{feature:d.alignindent().ui(),command:"indent",type:"general"},blockquote:{feature:d.alignindent().ui(),command:"blockquote",type:"general"},"font-menu":{name:"font",textkey:x.key("font.menu-button"),
  menuTextkey:x.key("font.menu"),type:"submenu",contentFocus:!0,commands:[{category:"Font-menu",items:[G,V,X,C,w,k]}]},"font-face":G,"font-size":V,"font-color":X,fullscreen:c,find:{feature:d.findreplace().ui(),command:"find",type:"general"},accessibility:h,usersettings:{name:"usersettings",textkey:x.key("cog.menu-button"),menuTextkey:x.key("cog.menu"),type:"submenu",flatten:hr.never(),contentFocus:!0,commands:[{category:"a",items:[t]},{category:"b",items:[n,m,p]},{caetgory:"",items:[r]}]}}}function Ez(){var a=
  {id:"insert",label:x.key("insert.menu-button"),menuLabel:x.key("insert.menu"),items:[["link","bookmark","fileupload","media","table"],["specialchar","hr"]]};return{undo:{label:x.key("category.undo"),items:["undo","redo"]},insert:{label:x.key("category.insert"),items:[a]},style:{label:x.key("category.style"),items:["styles"]},language:{label:x.key("category.language"),items:["language","ltrdir","rtldir"]},emphasis:{label:x.key("category.emphasis"),items:["bold","italic","underline"]},align:{label:x.key("category.align"),
  items:["alignment"]},listindent:{label:x.key("category.listindent"),items:["ul","ol","outdent","indent","blockquote"]},format:{label:x.key("category.format"),items:["font-menu","removeformat"]},tools:{label:x.key("category.tools"),items:["find","accessibility","fullscreen","usersettings"]},"table-tools":{label:x.key("category.table"),items:["table-tools"]},"image-tools":{label:x.key("category.image"),items:["image-tools","crop-tools"]}}}function pm(a){return{closeMenus:function(b){b=b?b.target():
  a;Fz.target(b,"mousedown")}}}function dW(a){return function(b,c){var d=K.bind(a,"touchmove",b.move),e=K.bind(a,"touchend",b.drop);return{element:k(a),start:t,stop:t,destroy:function(){d.unbind();e.unbind()}}}}function Gz(a,b,c,d){var e=na(g.none());c=qm.mode({compare:ir.compare,extract:ir.extract,sink:c,mutate:function(a,c){e.get().each(function(a){ir.resize(b,a,c)})}});var f=sj.transform({},{mode:c}),h=K.bind(a,"touchstart",function(a){"img"===D.name(a.target())&&2===a.raw().touches.length&&(e.set(g.some(a.target())),
  f.on(),f.go(b))});f.events.stop.bind(function(){e.get().each(function(a){v.remove(a,"transform")});d()});return{destroy:function(){h.unbind();f.destroy()}}}function eW(a,b,c){var d=c.toolbar.element(),e=Hz.tag(),f=[],h=p.fromDom(document),l=pm(d),q=null,C=gd.api(),w=g.none(),k=function(){C.run(function(a){a.toEditing()})},G=function(){l.closeMenus()},V=function(){a.getSelection().each(function(a){a=a.collapsed()?"0px":"23px";v.set(d,"margin-top",a)})},X=function(a){v.set(d,"margin-top","0px")},m=
  function(){var c=[K.bind(d,"touchmove",l.closeMenus)];f=a.doc().map(function(a){return b||!0===fW?[]:[K.bind(a,"selectionchange",V),K.bind(h,"focusin",X)]}).getOr([]).concat(c)},r=function(){z(f,function(a){a.unbind()})};return{enter:function(){a.body().each(function(b){a.doc().each(function(c){a.win().each(function(d){Z.focus(b);q=Jh.onChange();var e=dW(c);e=Gz(c,b,e,t);w=g.some(e);d=gW.setup(window,d);C.set(d);a.events.toEditing.bind(k);q.events.change.bind(G)})})});n.add(d,"ephox-polish-mobile-show");
  c.toolbar.refresh();e.maximize();m()},exit:function(){C.clear();a.events.toEditing.unbind(k);q.events.change.unbind(G);null!==q&&q.destroy();e.restore();r()},destroy:function(){w.each(function(a){a.destroy()});r()}}}function Iz(){var a=p.fromTag("div");n.add(a,B.resolve("disabled-mask"));var b=!1,c=T.div();n.add(c,B.resolve("content-container"));var d=T.div();S.hidden(d,!0);n.add(d,B.resolve("tap-icon"));y.append(c,d);var e=T.div();n.add(e,B.resolve("disclosure"));y.append(e,p.fromText(x.translate("taptoedit")));
  y.append(c,e);y.append(a,c);S.textButton(a,c);var f=H.create({fullscreen:r([])}),h=function(b){var c=a.dom().getClientRects()[0];return ob(b,function(a){return a.pageY>=c.top&&a.pageY<=c.top+c.height&&a.pageX>=c.left&&a.pageX<=c.left+c.width})},l=[K.bind(a,"touchmove",function(a){b=!0}),K.bind(a,"touchend",function(a){var c=a.raw().changedTouches;h(c)&&!b&&(a.kill(),f.trigger.fullscreen())}),K.bind(a,"touchstart",function(a){b=!1}),K.bind(a,"click",function(a){a.kill();f.trigger.fullscreen()})];return{element:k(a),
  events:f.registry,destroy:function(){z(l,function(a){a.unbind()});F.remove(d);F.remove(e);F.remove(c);F.remove(a)},show:function(){v.remove(a,"display")},hide:function(){v.set(a,"display","none")}}}function Jz(a,b,c,d,e,f){var h=f.element(),l=eW(a,e.fillscreen,f),q=function(){l.enter();d.actions().maximize()},C=function(){var a=Iz();y.append(f.element(),a.element());a.events.fullscreen.bind(function(a){d.actions().maximize()})};return{init:function(){f.socket(a);a.events.scrollToCursor.bind(function(){Ng.cursorIntoView(a)})},
  loaded:function(){var a=!0===e.fillscreen;(n.has(h,B.resolve("fullscreen-maximized"))||a?q:C)()},restoreEditor:function(){d.actions().restore();l.exit()},destroy:function(){a.body().each(Z.blur)}}}function hW(a,b,c,d,e){var f=d.toolbar.items,h=function(h){var l=Jz(a,b,c,e,d,h),C=Dz();h=yj.config({items:[["back"]].concat(f),contextual:[]},{back:{feature:C.ui(),command:"back",type:"general"}},{allowLocalImages:d.allowLocalImages});C.events.back.bind(function(){l.restoreEditor()});return{init:l.init,
  loaded:l.loaded,config:h,destroy:function(){l.destroy();C.destroy()}}};return{tabbed:h,full:h,destroy:t}}function iW(a,b,c,d,e){var f=d.toolbar.items,h=function(h){var l=Jz(a,b,c,e,d,h);h=yj.config({items:f,contextual:[]},{},{allowLocalImages:d.allowLocalImages});return{init:l.init,loaded:l.loaded,config:h,destroy:function(){l.destroy()}}};return{tabbed:h,full:h,destroy:t}}function jW(a,b,c,d){b=function(b){return{init:function(){b.socket(a);a.events.scrollToCursor.bind(function(){Ng.cursorIntoView(a)});
  a.events.toEditing.bind(a.focus)},loaded:t,config:yj.config(d.toolbar,{},{allowLocalImages:d.allowLocalImages}),destroy:t}};return{tabbed:b,full:b,destroy:t}}function kW(a,b){var c=Hz.tag(),d=g.none(),e=Iz();return{maximize:function(){d=g.some(document.body.scrollTop);v.set(e.element(),"display","none");n.add(a,B.resolve("fullscreen-maximized"));Kz.clobberStyles(a,b);c.maximize()},restore:function(){Kz.restoreStyles();n.remove(a,B.resolve("fullscreen-maximized"));c.restore();v.remove(e.element(),
  "display");d=d.bind(function(a){document.body.scrollTop=a;return g.none()})},destroy:function(){e.destroy()},mask:k(e)}}function lW(a,b){var c=a.document,d=p.fromTag("div");n.add(d,ue.resolve("unfocused-selections"));y.append(p.fromDom(c.documentElement),d);var e=K.bind(d,"touchstart",function(c){c.prevent();jr.resume(a,b);h()}),f=function(a){var b=p.fromTag("span");ma.add(b,[ue.resolve("layer-editor"),ue.resolve("unfocused-selection")]);v.setAll(b,{left:a.left+"px",top:a.top+"px",width:a.width+"px",
  height:a.height+"px"});return b},h=function(){F.empty(d)};return{update:function(){h();var b=kr.getRectangles(a);b=E(b,f);P.append(d,b)},isActive:function(){return 0<A.children(d).length},destroy:function(){e.unbind();F.remove(d)},clear:h}}function mW(a){var b=na(lf.pure({}));return{start:function(c){var d=lf.nu(function(b){return a(c).get(b)});d.get(ca);b.set(d)},idle:function(a){b.get().get(function(){a()})}}}function nW(a){return function(b,c){var d=K.bind(a,"touchmove",b.move),e=K.bind(a,"touchend",
  b.drop),f=K.bind(a,"gesturestart",function(a){"img"===D.name(a.target())&&a.prevent()});return{element:k(a),start:t,stop:t,destroy:function(){d.unbind();e.unbind();f.unbind()}}}}function oW(a,b,c,d,e,f,h,l){var q=[],C=f.toolbar.element(),k=f.banners(),I=f.viewport(),G=g.none(),V=pm(C),X=null,m=gd.api(),r=g.none(),t=Uc.event(I),u=Aa("cWin ceBody socket toolstrip toolbar contentElement cursor keyboardType isScrolling".split(" "),[]),x=function(){m.run(function(a){a.highlightSelection()})},y=function(){m.run(function(a){a.refreshSelection()})},
  A=function(a){var b=bb.absolute(a).top()-I.dom().scrollTop;m.run(function(c){c.scrollIntoView(b,b+sa.get(a))})},D=function(){Lz.insertAtCursor(d,a,function(a){var b=a.absolute().top()-I.dom().scrollTop;m.run(function(c){c.scrollIntoView(b,b+a.height())})})},E=function(a){D();m.run(function(a){a.syncHeight()})},F=function(a){var b=sa.get(C);m.run(function(a){a.setViewportOffset(b)});y();E()},H=function(a){A(a.element())},J=jf(E,300),M=function(){V.closeMenus()},O=function(){U();var a=setInterval(function(){0===
  window.pageYOffset&&(clearInterval(a),E())},100)},P=function(){m.run(function(a){a.clearSelection()})},Q=function(){P();J.throttle()},S=function(){m.run(function(a){a.toEditing()})},R=function(){m.run(function(a){a.toReading()})},T=function(a){m.run(function(b){b.onToolbarTouch(a)})},U=function(){(Jh.get().isPortrait()?n.remove:n.add)(f.element(),B.resolve("mobile-landscape"))},W=function(a){var b=v.get(a,"background-color");void 0!==b&&""!==b&&v.set(a,"-webkit-tap-highlight-color",b)},Y=function(b){var c=
  a.win().getOrDie(),d=function(a){Z.focus(b);a=a.raw().changedTouches[0];Wa.getAtPoint(c,a.pageX,a.pageY).each(function(a){Wa.setExact(c,a.start(),a.soffset(),a.finish(),a.foffset())})},e=a.doc().map(function(a){var c=nW(a);c=Gz(a,b,c,E);r=g.some(c);var e=p.fromDom(a.dom().documentElement);return[K.bind(a,"touchend",function(a){(N.eq(e,a.target())||N.eq(b,a.target()))&&d(a)})]}).getOr([]),f=[K.capture(C,"touchstart",function(a){x();T(a)}),K.bind(b,"touchstart",P),rm.handle(b,aa),K.bind(C,"touchmove",
  V.closeMenus)];q=e.concat(f)},aa=function(a){a.kill()};return{exit:function(){a.body().each(function(b){v.remove(k,"display");v.set(f.viewport(),"overflow","hidden");G=G.bind(function(a){a.unbind();return g.none()});n.remove(C,B.resolve("mobile-show"));m.clear();Z.blur(b);v.remove(b,"padding-top");z(q,function(a){a.unbind()});h.restore();a.events.keyup.unbind(Q);a.events.domChanged.unbind(J.throttle);a.events.scrollToCursor.unbind(J.throttle);a.events.scrollToElement.unbind(H);a.events.domChanged.unbind(y);
  a.events.nodeChanged.unbind(y);a.events.toEditing.unbind(S);a.events.toReading.unbind(R);X.events.change.unbind(M);X.events.ready.unbind(O);f.toolbar.events.transitionend.unbind(F);null!==X&&X.destroy()})},enter:function(b){a.body().each(function(b){a.win().each(function(d){X=Jh.onChange();h.maximize();Y(b);Z.focus(b);G=g.some(Mz.exclusive(c,"."+Uc.scrollable()));v.getRaw(C,"overflow-x").is("auto")&&L.descendant(C,".ephox-chameleon-toolbar").each(function(a){Mz.markAsHorizontal(a);Uc.register(a)});
  W(b);U();document.body.scrollTop=0;n.add(C,B.resolve("mobile-show"));f.toolbar.refresh();v.set(k,"display","block");L.descendant(C,".ephox-chameleon-toolbar").each(function(c){m.set(pW.setup(u({cWin:d,ceBody:b,socket:I,toolstrip:C,toolbar:c,contentElement:a.element(),cursor:a.cursor(),keyboardType:qW.stubborn,isScrolling:t.isScrolling})))});a.events.keyup.bind(Q);a.events.domChanged.bind(J.throttle);a.events.scrollToCursor.bind(J.throttle);a.events.scrollToElement.bind(H);a.events.domChanged.bind(y);
  a.events.nodeChanged.bind(y);a.events.toEditing.bind(S);a.events.toReading.bind(R);X.events.change.bind(M);X.events.ready.bind(O);f.toolbar.events.transitionend.bind(F);E()})})},destroy:function(){r.each(function(a){a.destroy()});G.each(function(a){a.unbind()});t.destroy()}}}function Nz(a,b,c,d,e){var f=kW(e.element(),a),h=p.fromDom(document),l=a.element(),q=k(!0===d.fillscreen),C=oW(a,b,h,c,l,e,f,q),g=function(a){var b=A.children(a),c;if(!(c=0===b.length)){if(b=1===b.length)b=Ha.get(a),b=10===b.charCodeAt(0)&&
  10===b.charCodeAt(1);c=b}c&&(b=p.fromHtml("<p><br></p>"),y.append(a,b));C.enter()},I=function(a){y.append(e.element(),f.mask().element());f.mask().events.fullscreen.bind(function(a){C.enter()})},G=function(a){(q()?g:I)(a)};return{init:function(){e.socket(a)},loaded:function(){a.body().each(G)},restoreEditor:function(){a.body().each(Z.blur);a.element().dom().focus();a.element().dom().blur();C.exit();Z.focus(f.mask().element())},destroy:function(){a.body().each(Z.blur);C.destroy();f.destroy()}}}function rW(a,
  b,c,d){var e=d.toolbar.items;return{tabbed:function(f){var h=Nz(a,b,c,d,f),l=Dz();f=yj.config({items:[["back"]].concat(e),contextual:[]},{back:{feature:l.ui(),command:"back",type:"general"}},{allowLocalImages:d.allowLocalImages});l.events.back.bind(function(){h.restoreEditor()});return{init:h.init,loaded:h.loaded,config:f,destroy:function(){h.destroy();l.destroy()}}},full:yb("mobile does not support fullscreen layout"),destroy:t}}function sW(a,b,c,d){var e=d.toolbar.items;return{tabbed:function(f){var h=
  Nz(a,b,c,d,f);f=yj.config({items:e,contextual:[]},{},{allowLocalImages:d.allowLocalImages});return{init:h.init,loaded:h.loaded,config:f,destroy:function(){h.restoreEditor();h.destroy()}}},full:yb("mobile does not support fullscreen layout"),destroy:t}}function tW(a,b,c,d,e){return(Oz.deviceType.isiOS()?!0===e.fillscreen?sW:rW:Oz.deviceType.isAndroid()?!0===e.fillscreen?iW:hW:jW)(a,b,c,e,d)}function zj(a,b){b=sm.readOr(a,b);var c=na(b),d=function(a){c.set(a)};return{setAndCache:function(b){d(b);sm.write(a,
  b)},set:d,get:function(){return c.get()}}}function uW(a){var b=zj("native.spelling",a.nativeSpelling),c=zj("spelling",a.spelling),d=zj("autocorrect",a.autocorrect),e=zj("linkpreviews",a.linkpreviews),f=zj("capitalisation",a.capitalisation);return{spelling:k(c),nativeSpelling:k(b),autocorrect:k(d),linkpreviews:k(e),capitalisation:k(f),state:function(){return{nativeSpelling:b.get(),spelling:c.get(),autocorrect:d.get(),linkpreviews:e.get(),capitalisation:f.get()}},destroy:t}}function vW(a,b,c){var d=
  b.all();d.on();var e=[];d.events.backspace.bind(function(){lr.get(a,e,Aj.left).each(F.remove)});b=function(b){var d=b.stopper();lr.get(a,e,Aj.left).each(function(b){d();Pz.upOrLeft(a,c,b)})};d.events.right.bind(function(b){var d=b.stopper();lr.get(a,e,Aj.right).each(function(b){d();Pz.right(a,c,b)})});d.events.left.bind(b);d.events.up.bind(b);return{registerSkip:function(a){e.push(a)},destroy:function(){d.destroy()}}}function wW(a,b){(b.error?g.some(b.error):g.none()).map(function(a){return mj(mf.get(a.name,
  [a]))}).each(a.displayBanner);return{destroy:t}}function Qz(a){return{elementFromPoint:function(b,c){return p.fromPoint(p.fromDom(a.document),b,c)},getRect:function(a){return a.dom().getBoundingClientRect()},getRangedRect:function(b,c,d,e){b=Kc.exact(b,c,d,e);return Wa.getFirstRect(a,b).map(function(a){return eb(a,xb)})},getSelection:function(){return Wa.get(a).map(function(b){return Kh.convertToRange(a,b)})},fromSitus:function(b){b=Kc.relative(b.start(),b.finish());return Kh.convertToRange(a,b)},
  situsFromPoint:function(b,c){return Wa.getAtPoint(a,b,c).map(function(a){return{start:k(la.on(a.start(),a.soffset())),finish:k(la.on(a.finish(),a.foffset()))}})},clearSelection:function(){Wa.clear(a)},setSelection:function(b){Wa.setExact(a,b.start(),b.soffset(),b.finish(),b.foffset())},setRelativeSelection:function(b,c){Wa.setRelative(a,b,c)},selectContents:function(b){Wa.setToElement(a,b)},getInnerHeight:function(){return a.innerHeight},getScrollY:function(){return Za.get(p.fromDom(a.document)).top()},
  scrollBy:function(b,c){Za.by(b,c,p.fromDom(a.document))}}}function xW(a,b,c,d){var e=g.none(),f=function(){e=g.none()};return{mousedown:function(a){d.clear(b);e=Rz(a.target(),c)},mouseover:function(f){e.each(function(e){d.clear(b);Rz(f.target(),c).each(function(f){Qf.identify(e,f,c).each(function(c){var h=c.boxes().getOr([]);if(1<h.length||1===h.length&&!N.eq(e,f))d.selectRange(b,h,c.start(),c.finish()),a.selectContents(f)})})})},mouseup:function(){e.each(f)}}}function yW(a){var b=function(b){return!a.isRoot(b)&&
  (Bj.isBlock(b)||"li"===D.name(b))},c=function(a){return D.isText(a)&&0===Ya.get(a).trim().length},d=function(b,c,d,e){return Ja.closest(b,function(b){return A.parent(b).exists(a.isRoot)},a.isRoot).fold(function(){return W.point(b,c)},function(a){return d(a,b,c)?e(a):W.point(b,c)})},e=function(a,b){return"p"===D.name(a)&&1===A.childNodesCount(a)&&A.firstChild(a).filter(function(a){return"br"===D.name(a)}).isSome()?W.point(a,b):kb.toLeaf(a,b)},f=function(e,f){var h=function(b){return wc.before(b,a.isRoot).fold(function(){return W.point(e,
  f)},function(a){return c(a)?h(a):W.point(a,wa.getEnd(a))})};return Ja.closest(e,function(a){return b(a)&&A.prevSibling(a).isSome()},a.isRoot).fold(function(){return d(e,f,Pg.isAtLeftEdge,h)},function(a){return b(e)||Pg.isAtLeftEdge(a,e,f)?h(a):W.point(e,f)})},h=function(e,f){var h=function(b){return wc.after(b,a.isRoot).fold(function(){return W.point(e,f)},function(a){return c(a)?h(a):W.point(a,0)})};return Ja.closest(e,function(a){return b(a)&&A.nextSibling(a).isSome()},a.isRoot).fold(function(){return d(e,
  f,Pg.isAtRightEdge,h)},function(a){return b(e)||Pg.isAtRightEdge(a,e,f)?h(a):W.point(e,f)})},l=function(a,b){return N.eq(a.element(),b.element())?a.offset()<=b.offset():hd.after(a.element(),a.offset(),b.element(),b.offset())};return{getSelection:function(a){return a.getSelection().bind(function(a){var b=a.startContainer();var c=a.endContainer();N.eq(b,c)?(c=A.child(b,a.startOffset()),b=A.child(b,a.endOffset()),b=c.filter(pa.isList).isSome()||b.filter(pa.isList).isSome()):b=!0;if(b){if(hd.after(a.startContainer(),
  a.startOffset(),a.endContainer(),a.endOffset()))return b=e(a.startContainer(),a.startOffset()),a=e(a.endContainer(),a.endOffset()),b=wa.isStart(b.element(),b.offset())?f(b.element(),b.offset()):W.point(b.element(),b.offset()),a=wa.isEnd(a.element(),a.offset())?h(a.element(),a.offset()):W.point(a.element(),a.offset()),a=l(b,a)?g.some(Rc(b.element(),b.offset(),a.element(),a.offset())):g.some(Rc(a.element(),a.offset(),b.element(),b.offset())),a;b=e(a.startContainer(),a.startOffset());a=e(a.endContainer(),
  a.endOffset());b=wa.isEnd(b.element(),b.offset())?h(b.element(),b.offset()):W.point(b.element(),b.offset());a=wa.isStart(a.element(),a.offset())?f(a.element(),a.offset()):W.point(a.element(),a.offset());a=l(b,a)?g.some(Rc(a.element(),a.offset(),b.element(),b.offset())):g.some(Rc(b.element(),b.offset(),a.element(),a.offset()));return a}return g.some(a)})}}}function zW(a,b,c){AW.configure(b);var d=yW(c),e=H.create({beforeScan:r([]),afterScan:r([])}),f=Sz.byClass(te);b=function(){c.body().each(function(a){c.getSelection().each(function(b){nf.sharedOne(tb.table,
  [b.startContainer(),b.endContainer()]).fold(function(){f.clear(a)},t)})})};(Tz.browser.isChrome()||Tz.browser.isSafari())&&c.events.contextmenu.bind(b);c.events.nodeChanged.bind(b);var h=na([]);c.runOrOnLoaded(function(b){var d=A.defaultView(b).dom(),l=Uz.mouse(d,b,c.isRoot,f),q=Uz.keyboard(d,b,c.isRoot,f);h.set([tm.leftDown.bind(b,l.mousedown),tm.leftPressedOver.bind(b,l.mouseover),tm.leftUp.bind(b,l.mouseup),K.bind(b,"keyup",function(a){a.raw().shiftKey&&Nd.isNavigation(a.raw().which)&&c.getSelection().each(function(b){q.keyup(a,
  b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset()).each(function(b){g(a,b)})},t)}),K.bind(b,"keydown",function(b){c.getSelection().each(function(c){e.trigger.beforeScan();var d=a.directionAt(c.endContainer()).isRtl()?Nd.rtl:Nd.ltr;q.keydown(b,c.startContainer(),c.startOffset(),c.endContainer(),c.endOffset(),d).each(function(a){g(b,a)});e.trigger.afterScan()})})]);var g=function(a,b){b.kill()&&a.kill();b.selection().each(function(a){c.setRelativeSelection(a.start(),a.finish())})}});
  var l=function(a){return{win:a.win,doc:a.doc,execCommand:a.execCommand,getSelection:function(){return d.getSelection(a)},setSelection:a.setSelection,setRelativeSelection:a.setRelativeSelection,focus:a.focus}},q=function(a,b){return{doc:b.doc,win:b.win,execCommand:b.execCommand,focus:b.focus,setSelection:t,setRelativeSelection:t,getSelection:function(){return g.some(C(a))}}},C=function(a){return{startContainer:k(a),startOffset:k(0),endContainer:k(a),endOffset:k(wa.getEnd(a))}};return{get:function(){return c.on(function(a){return c.body().fold($b.none,
  function(b){return Vz.retrieve(b,te.selectedSelector()).fold(function(){return a.getSelection().fold($b.none,function(b){b=d.getSelection(a).getOr(b);return $b.single(b,l(a))})},function(b){var c=E(b,function(b){return q(b,a)});return $b.multiple(b,c)})})}).getOrThunk($b.none)},surround:C,events:e.registry,destroy:function(){var a=h.get();z(a,function(a){a.unbind()})}}}function BW(a){a=ua({scopes:[p.fromDom(document)],shortcuts:[],swallow:!1},a);var b=oj(a),c=[],d=[];z(a.scopes,function(a){c.push(K.bind(a,
  "keydown",b.keydown).unbind);d.push(K.bind(a,"keypress",b.keypress).unbind)});return{off:b.off,on:b.on,destroy:function(){z(c,xb);z(d,xb)},events:b.events,swallowShortcuts:b.swallowShortcuts,yieldShortcuts:b.yieldShortcuts,swallowChars:b.swallowChars,yieldChars:b.yieldChars,swallowKeys:b.swallowKeys,yieldKeys:b.yieldKeys}}function CW(a,b){var c=H.create({undo:r([]),redo:r([]),context:r([]),toolbar:r([]),plaincode:r([]),bold:r([]),italic:r([]),underline:r([]),indent:r([]),outdent:r([]),link:r([]),
  blockquote:r([]),search:r([]),help:r([]),fullscreen:r([])}),d=DW(c),e=[d.undo,d.redo,d.context,d.toolbar];d=[d.plaincode,d.bold,d.italic,d.underline,d.indent,d.outdent,d.link,d.search,d.blockquote,d.help,d.fullscreen];e=(b=!0===b.features)?e.concat(d):e;var f=ia(e,function(a){return a.keys()}),h=E(e,function(a){return EW(a.keys(),a.trigger())}),l=g.none();a.onCanvas(function(a){a=BW({scopes:[a],shortcuts:f});l=g.some(a);a.swallowShortcuts(f);a.events.command.bind(function(a){var b=a.command();yc(h,
  function(a){return a(b)}).each(xb)});a.on()});return{isHelpShortcutEnabled:k(b),events:c.registry,destroy:function(){l.each(function(a){a.destroy()})}}}function FW(){var a=[],b=function(){a=ka(a,function(a){return sc.isVisible(a.popup().panel())})};return{recalculate:function(){b();E(a,function(a){a.anchor().recalculate(a.popup())})},dismiss:function(){b();E(a,function(a){a.anchor().isAnchored()||a.popup().close()})},update:function(b,d){a=GW.put(a,b,d,HW,function(a){return a.popup()===b})},destroy:function(){}}}
  function IW(a,b,c,d){var e=FW(),f=a.isInline()?t:Zb(function(){var b=function(b){e.dismiss();a.focus()},c=!0===d.autoresize?p.fromDom(document):a.doc().getOrDie();h=Wz.bind(c,b);!0!==d.autoresize&&!0===d.toolbar.sticky&&(l=Wz.bind(p.fromDom(document),b))}),h=null,l=null,q=T.div();ma.add(q,[B.resolve("ui-container"),B.resolve("layer-above-editor")]);d.editorName.each(function(a){m.set(q,"data-ephox-editor",a)});var g=K.bind(q,"keydown",function(a){var b;if(b=U(R.BACKSPACE(),a.raw().which))b=a.target(),
  b=u(Ia.is,b),b=!Xa(["textarea","input",'[contenteditable="true"]'],b);b&&a.kill()});return{uiContainer:k(q),uiOrigin:function(){return Lh.relativeOrigin(q)},refresh:e.recalculate,bounds:b,show:function(a,b){f();e.update(a,b);b.place(a)},destroy:function(){null!==h&&h.unbind();null!==l&&h.unbind();e.destroy();g.unbind();F.remove(q)}}}function JW(a,b,c){a=jy(c,a);c=function(){var a=setTimeout(function(){clearTimeout(a);d.trigger.expired()},b);return{clear:function(){clearTimeout(a)}}};var d=H.create({expired:r([]),
  close:r([])}),e=0<b?c():{clear:t};a.events.close.bind(function(){e.clear();d.trigger.close()});return{element:a.element,action:a.action,destroy:a.destroy,events:d.registry}}function KW(a,b,c,d,e,f,h,l){var q=h.layout.build(a,b,c,d,e,f,h,l);b=function(a){Db.closest(a.target(),'input,div[contenteditable="true"],textarea,.ephox-polish-dialog.ephox-polish-help-modal,select,.ephox-polish-bottom-bar,.ephox-polish-side-bar')||a.prevent()};var g=[K.bind(q.element(),"mousedown",b),K.bind(c.uiContainer(),"mousedown",
  b)];(function(){var b=n.toggler(q.element(),B.resolve("content-ltr")),c=n.toggler(q.element(),B.resolve("content-rtl")),d=n.toggler(q.uiContainerParent(),B.resolve("content-ltr")),e=n.toggler(q.uiContainerParent(),B.resolve("content-rtl")),h=function(){b.off();d.off()},l=function(){b.on();d.on()},g=function(){c.off();e.off()},C=function(){c.on();e.on()},k=function(){var a=f.uiDirection().isRtl(),b=a?C:g;(a?h:l)();b()};a.events.uiStale.bind(function(){Zy.readDir(a).fold(k,function(a){a.ltrdir().fold(h,
  t,l);a.rtldir().fold(g,t,C);b.isOn()===c.isOn()&&k()})})})();return{element:q.element,connect:q.connect,viewport:q.viewport,uiContainerParent:q.uiContainerParent,socket:q.socket,showMessage:function(a,b,c){a=JW(a,b,c);b=u(q.hideBanner,a);a.events.expired.bind(b);q.displayBanner(a);return b},displayBanner:q.displayBanner,hideBanner:q.hideBanner,init:q.init,refocus:q.tabstrip.refocus,tabstrip:q.tabstrip,refresh:q.refresh,position:q.position,state:q.state,destroy:function(){q.destroy();z(g,function(a){a.unbind()})},
  dialogContainer:q.dialogContainer}}function Cj(a){var b=void 0!==a?a.slice(0):[];return{pop:function(){return g.from(b.pop())},push:function(a){b.push(a)},peek:function(){return g.from(b[b.length-1])},pushAll:function(a){b=b.concat(a)},clear:function(){b=[]},isEmpty:function(){return 0===b.length},size:function(){return b.length},state:function(){return b.slice(0)}}}function Xz(a){var b=H.create({changed:r([]),reset:r([])}),c=a.initial,d=Cj(a.undo),e=Cj(a.redo),f=function(a){d.isEmpty()&&d.push(c);
  d.push(a);b.trigger.changed()},h=function(a,b){b(d.peek().getOr(c),a)?(d.pop(),d.push(a)):(f(a),e.clear())};return{save:h,checkChanged:function(a,b){return!b(d.peek().getOr(c),a)},undo:function(a,c){h(a,c);return d.pop().bind(function(a){d.isEmpty()||(e.push(a),b.trigger.changed());return d.peek()})},redo:function(a,b){b(d.peek().getOr(c),a)||e.clear();return e.pop().bind(function(a){f(a);return d.peek()})},reset:function(a){c=a;d.clear();e.clear();b.trigger.reset()},state:function(){return{initial:c,
  undo:d.state(),redo:e.state()}},rewrite:function(a){var f=a(c),h=E(d.state(),a);a=E(e.state(),a);c=f;d=Cj(h);e=Cj(a);d.isEmpty()&&e.isEmpty()||b.trigger.changed()},events:b.registry}}function LW(a,b,c,d,e){var f=MW.fromState(Yz(e,NW)),h=H.create({changed:Q([],f.events.changed),reset:Q([],f.events.reset),undo:r([]),redo:r([])}),l=function(b,c){var d;(d=""===b.raw()&&OW.isDefaultEmpty(c.raw()))||(b=a.filterHtml(a.internal(),b.raw()),c=a.filterHtml(a.internal(),c.raw()),d=b===c);return d},q=function(){var c=
  a.filterHtml(a.history(),b.getContent()),d=a.filterHtml(a.history(),b.serialize());return um(c,d)},g=function(a){return b.deserialize(a.marked())};e=function(){var a=q();f.undo(a,l).each(g);b.domChanged();b.toEditing();h.trigger.undo()};var w=function(){var a=q();f.redo(a,l).each(g);b.domChanged();b.toEditing();h.trigger.redo()},I=Hd.tap(function(a,b){a()&&(a=q(),f.save(a,b))}),G=function(){I.instance(function(){return b.getSelectionStart().exists(ja.inBody)},l)},V=function(a){var b=I.control.isBlocked();
  I.control.block();a=a();b||I.control.unblock();return a},m=c.editor();m.events.enter.bind(G);m.on();d.events.undo.bind(e);d.events.redo.bind(w);b.events.undoChanged.bind(G);b.events.loiter.bind(G);c=vb.ui({"undo.general":{toggle:!1,value:"undo",textkey:x.key("action.undo"),action:e,shortcut:!0,updateGeneral:ca,tooltip:rb.get},"redo.general":{toggle:!1,value:"redo",textkey:x.key("action.redo"),action:w,shortcut:!0,updateGeneral:ca,tooltip:rb.get}});return{undo:e,redo:w,save:G,checkChanged:function(){var a=
  q();return f.checkChanged(a,l)},reset:function(a){f.reset(um(a,a))},destroy:function(){m.off();m.destroy()},state:function(){return Yz(f.state(),PW)},rewrite:function(a,b){f.rewrite(function(c){return um(c.raw().replace(a,b),c.marked().replace(a,b))})},transaction:function(a){G();a=V(a);G();return a},disable:V,replaceTop:function(){I.instance(k(!0),k(!0))},ui:c,events:h.registry}}function QW(a,b){var c=gd.unbindable(),d=H.create({onChange:r([])}),e=tj(function(){d.trigger.onChange()},1E3),f=function(){a.runOrOnLoaded(function(d){(b?
  g.some(p.fromDom(document)):a.doc()).each(function(a){c.set(K.bind(a,"scroll",function(a){e.throttle()}));e.throttle()})})};a.isInline()||f();var h=function(){return a.body().bind(function(c){return(b?g.some(window):a.win()).map(function(d){var e=a.element().dom().getBoundingClientRect(),f=d.innerHeight,h=A.children(c);return Va(h,function(a){if(!D.isElement(a))return!1;a=a.dom().getBoundingClientRect();var c=b?a.bottom+e.top:a.bottom;return(b?a.top+e.top:a.top)<f&&0<c}).map(function(a){var c=Va(h.slice(a+
  1),function(a){if(!D.isElement(a))return!1;a=a.dom().getBoundingClientRect();var c=b?a.bottom+e.top:a.bottom;return!((b?a.top+e.top:a.top)<f&&0<c)}).map(function(b){return a+1+b}).getOr(h.length);return h.slice(a,c)}).getOr([c])})}).getOr([])};return{sections:function(){return h()},setOn:f,setOff:function(){c.clear()},viewport:function(){return{assess:function(b){if(!D.isElement(b))return Qg.inView(b);var c=a.win().map(function(a){return a.innerHeight}).getOr(0),d=b.dom().getBoundingClientRect();
  c=0>d.bottom?Qg.aboveView:d.top>c?Qg.belowView:Qg.inView;return c(b)}}},destroy:function(){c.clear();e.cancel()},events:d.registry}}function Zz(){var a=$z.single(),b=H.create({upload:r(["assets"])});a.events.upload.bind(function(a){ve.multiple(a.files()).get(function(a){b.trigger.upload(a)})});return{element:a.element,open:a.open,destroy:a.destroy,events:b.registry}}function mr(a){var b=g.none(),c=function(c){d();c=mj(c);c.events.close.bind(function(){b=g.none()});b=g.some(c);a().displayBanner(c)},
  d=function(){b.each(a().hideBanner);b=g.none()};return{show:c,showKey:function(a){var b=mf.get.apply(void 0,arguments);c(b)},hide:d,reset:function(){b=g.none()}}}function aA(a,b){a=ua({layerClass:void 0,zindex:void 0,padding:"0px"},a);var c=H.create({exiting:r([])}),d=p.fromTag("div");S.presentation(d);n.add(d,lc.resolve("modal"));n.add(d,lc.resolve("modal-hidden"));v.setAll(d,{position:"fixed",left:a.padding,top:a.padding,right:a.padding,bottom:a.padding});void 0!==a.background&&v.set(d,"background",
  a.background);void 0!==a.zindex&&v.set(d,"z-index",a.zindex);void 0!==a.layerClass&&n.add(d,a.layerClass);var e=void 0!==b?b:L.first("body").getOrDie();y.append(e,d);return{element:function(){return d},content:function(a){F.empty(d);y.append(d,a)},show:function(){n.add(e,lc.resolve("modal-active"));n.remove(d,lc.resolve("modal-hidden"));n.add(d,lc.resolve("modal-show"))},hide:function(){n.remove(e,lc.resolve("modal-active"));n.add(d,lc.resolve("modal-hidden"));n.remove(d,lc.resolve("modal-show"))},
  destroy:function(){F.remove(d);n.remove(e,lc.resolve("modal-active"))},events:c.registry}}function RW(a,b){var c=Jh.onChange(),d=H.create({exiting:r([])});a=ua({layerClass:null,zindex:null,padding:"0px",background:"rgba(0, 0, 0, 0.5)"},a);var e=p.fromTag("div");S.presentation(e);n.add(e,lc.resolve("moodal"));n.add(e,lc.resolve("moodal-hidden"));v.setAll(e,{left:a.padding,top:a.padding,right:a.padding,bottom:a.padding});a.background&&v.set(e,"background",a.background);a.zindex&&v.set(e,"z-index",a.zindex);
  a.layerClass&&n.add(e,a.layerClass);var f=void 0!==b?b:L.first("body").getOrDie();y.append(f,e);var h=p.fromTag("div");S.presentation(h);n.add(h,lc.resolve("moodal-flexor"));y.append(e,h);var l=function(){v.setAll(h,{top:window.scrollY+"px",height:window.innerHeight+"px"})},q=function(){g.unbind();c.destroy();F.remove(e);n.remove(f,lc.resolve("modal-active"))},g=K.bind(e,"click",function(){d.trigger.exiting();q()});c.events.ready.bind(function(){l()});return{element:k(e),content:function(a){F.empty(h);
  y.append(h,a)},show:function(){n.add(f,lc.resolve("moodal-active"));n.remove(e,lc.resolve("moodal-hidden"));n.add(e,lc.resolve("moodal-show"));l()},hide:function(){n.remove(f,lc.resolve("moodal-active"));n.add(e,lc.resolve("moodal-hidden"));n.remove(e,lc.resolve("moodal-show"))},destroy:q,events:d.registry}}function SW(a){var b=oa({layerClass:void 0,zindex:void 0,modal:{}},a);a=void 0!==a.container?a.container:L.first("body").getOrDie();var c=(aa.detect().os.isiOS()?RW:aA)(b.modal,a),d=c.element(),
  e=H.create({exiting:Q([],c.events.exiting)});void 0!==b.zindex&&v.set(d,"z-index",b.zindex);void 0!==b.layerClass&&n.add(d,b.layerClass);n.add(d,lc.resolve("centered-dialog"));y.append(a,d);return{content:c.content,show:function(){c.show()},hide:function(){c.hide()},destroy:function(){F.remove(d);c.destroy()},events:e.registry}}function TW(){var a=function(a,b){n.add(a,B.resolve(b));return a},b=a(T.div(),"dialog"),c=a(T.div(),"top"),d=a(T.span(),"dialog-title"),e=a(T.span(),"dialog-close"),f=a(T.div(),
  "dialog-content"),h=a(T.div(),"dialog-controls");m.set(b,"tabindex",-1);m.set(e,"tabindex",-1);S.button(e,x.translate("button.close"));var l=K.bind(e,"click",function(){q.trigger.close()});P.append(b,[c,f,h]);P.append(c,[d,e]);var q=H.create({close:r([])});return{element:function(){return b},focus:function(){Z.focus(b)},setTitle:function(a){F.empty(d);y.append(d,p.fromText(a));UW||(S.dialog(b,a),a=Fa("ephox-aria"),m.set(d,"id",a),S.labelledBy(b,a))},setContent:function(a){F.empty(f);y.append(f,a);
  a=Fa("ephox-aria");m.set(f,"id",a);S.describedBy(b,a)},setControls:function(a){F.empty(h);y.append(h,a)},close:function(){q.trigger.close()},destroy:function(){F.remove(b);l.unbind()},events:q.registry}}function we(a){var b=TW(),c=g.none(),d=SW({container:a,layerClass:B.resolve("layer-dialog"),modal:{layerClass:B.resolve("layer-below-dialog")}});d.content(b.element());d.events.exiting.bind(function(){Uc.unlock([ja.body()]);b.close()});var e=function(){d.hide();Uc.unlock([ja.body()])};return{element:b.element,
  destroy:function(){b.destroy();c.each(function(a){a.unbind()});e();d.destroy()},setTitle:b.setTitle,setContent:b.setContent,setControls:b.setControls,show:function(){d.content(b.element());d.show();b.focus();VW.deviceType.isTouch()&&(c=g.some(K.bind(b.element(),"click",function(a){a.stop()})));Uc.lock([ja.body()])},hide:e,events:b.events}}function bA(a,b,c,d,e,f){var h=sd.okCancel("file-upload"),l=d(e),q=null,g=aa.detect(),k=H.create({close:r([]),analytics:r(["message"]),escaped:r([]),insertAssets:r(["assets"]),
  opened:r([])}),I=function(){q.unbind();V.hide();k.trigger.close();k.trigger.analytics("insert_image_closed");G()},G=function(){l.reset();h.ok().disable()},V=we(c);V.setTitle(x.translate("fileupload.title"));V.setContent(l.element());V.setControls(h.element());V.events.close.bind(I);n.add(V.element(),B.resolve("imageupload-dialog"));var m=f(V.element(),l.keylayouts(),Ba.dialog({cancel:h.cancel().element(),ok:h.ok().element(),execute:Kb.click,index:0}));l.events.upload.bind(function(a){k.trigger.insertAssets(a.assets());
  I()});l.events.dragndrop.bind(function(a){k.trigger.insertAssets(a.assets());I()});l.events.success.bind(function(a){h.ok().enable()});l.events.lookup.bind(function(a){h.ok().disable()});l.events.setActive.bind(function(a){G()});h.events.ok.bind(function(){l.selected().each(function(a){k.trigger.insertAssets([a]);I()})});h.events.cancel.bind(I);G();return{show:function(){g.deviceType.isiOS()&&(S.hidden(b.element(),!0),setTimeout(function(){l.focus();S.hidden(b.element(),!1)},250));V.show();m.enter();
  k.trigger.analytics("insert_image_opened");k.trigger.opened();var c=p.fromDom(window);q=K.bind(c,"orientationchange",function(){a.foreground()})},element:V.element,events:k.registry,destroy:function(){m.exit();m.destroy();V.hide();V.destroy();l.destroy();h.destroy()}}}function WW(a){var b=H.create({success:r(["assets"]),invalidUrl:r(["url"]),empty:r([]),lookup:r([])}),c=[],d=T.div(),e=n.toggler(d,Sb.resolve("url-indicator-loading")),f=er();f.events.start.bind(function(){e.on()});f.events.fail.bind(function(a){e.off();
  b.trigger.invalidUrl(a.url());c=[]});f.events.success.bind(function(a){e.off();var d=fa.get(C);a.url()===d?ve.fromImages([a.image()]).get(function(a){c=a;b.trigger.success(c)}):f.go(d)});var h=T.div();n.add(h,Sb.resolve("url-selector"));var l=p.fromTag("label");a=p.fromText(a("fileupload.web.url"));var q=Fa(Sb.resolve("input-id"));m.set(l,"for",q);n.add(l,Sb.resolve("url-input-label"));y.append(l,a);var C=p.fromTag("input");m.setAll(C,{id:q,type:"url",placeholder:"http://www.example.com/image.jpg"});
  n.add(C,Sb.resolve("url-input"));cA.os.isAndroid()&&m.set(C,"autofocus","true");cA.browser.isSafari()&&m.setAll(C,{autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false"});S.required(C);a=p.fromHtml("<span role=presentation>*</span>");n.add(a,Sb.resolve("url-input-required"));y.append(l,a);P.append(h,[l,C,d]);var w=jf(function(a){""!==a&&f.go(a)},1E3),I=K.bind(C,"input",function(){var a=fa.get(C);""===a.trim()?(b.trigger.empty(),w.throttle("")):(b.trigger.lookup(),w.throttle(a))});
  return{element:k(h),input:k(C),events:b.registry,reset:function(){e.off();fa.set(C,"")},focus:function(){Z.focus(C)},selected:function(){return g.from(c[0])},destroy:function(){I.unbind()}}}function dA(a){var b=H.create({lookup:r([]),success:r([])}),c=T.span(),d=p.fromHtml('<div role=presentation><span role=presentation class="'+Sb.resolve("url-input-required")+'">*</span> '+a("fileupload.weburlhelp")+"</div>"),e=Fa(Sb.resolve("help-message"));m.set(d,"id",e);n.add(d,Sb.resolve("fileupload-weburl-help"));
  var f=p.fromHtml("<div role=presentation><div role=presentation>"+a("fileupload.invalid1")+"</div><div role=presentation>"+a("fileupload.invalid2")+"</div><div role=presentation>"+a("fileupload.invalid3")+"</div></div>");n.add(f,Sb.resolve("fileupload-weburl-help"));n.add(f,Sb.resolve("fileupload-weburl-help-invalid"));var h=function(a){F.empty(w);y.append(w,a)},l=function(a){var b=p.fromTag("img");y.append(w,b);XW.previewAsset(a,b)},q=T.div();n.add(q,Sb.resolve("web-url-container"));var g=WW(a),
  w=T.div();n.add(w,Sb.resolve("image-preview-container"));a=Fa("ephox-hermes-url-state");S.live(w,a,"polite");S.controls(g.input(),a);S.describedBy(g.input(),e);e=T.div();n.add(e,Sb.resolve("hbox"));P.append(e,[g.element(),w,d]);y.append(q,e);g.events.lookup.bind(function(a){b.trigger.lookup();F.empty(w)});g.events.success.bind(function(a){z(a.assets(),l);b.trigger.success()});g.events.invalidUrl.bind(function(){h(f)});g.events.empty.bind(function(){h(c)});h(c);return{element:k(q),selected:g.selected,
  input:g.input,events:b.registry,focus:g.focus,reset:function(){h(c);g.reset()},destroy:function(){g.destroy()}}}function YW(a){a=T.div();var b=dA(x.translate),c=H.create({upload:r(["assets"]),dragndrop:r(["assets"]),dragover:r([]),dragleave:r([]),drop:r([]),setActive:r(["item"]),lookup:Q([],b.events.lookup),success:Q([],b.events.success)}),d=[function(){var a=b.input();return ha.input(a,Ba.input({}))}()];y.append(a,b.element());return{element:k(a),events:c.registry,keylayouts:k(d),reset:function(){b.reset()},
  focus:b.focus,selected:b.selected,destroy:function(){b.destroy()}}}function ZW(a,b,c,d,e){var f=H.create({insertAsset:r(["asset"]),open:r([]),done:r([]),abort:r([])}),h=p.fromDom(document);d=zb.mainmenu(h,"file-upload-menu",[]);var l=function(a,b){a=zb.item(h,a,x.get(b)+"...");S.menuItem(a,g.some(x.get(b)),g.none());return a},q=l("from-url",x.key("image.from-url"));l=l("from-camera",x.key("image.from-camera"));q=!0===e.allowLocalImages?[q,l]:[q];var C=Zz();C.events.upload.bind(function(a){g.from(a.assets()[0]).each(function(a){I();
  f.trigger.insertAsset(a)})});var w=function(a){a=a.assets();z(a,function(a){f.trigger.insertAsset(a)})},I=function(){Fz.target(c.uiContainer(),"mousedown")};P.append(d,q);d={name:"image",textkey:x.key("image.menu-button"),menuTextkey:x.key("image.menu"),icon:g.none,tooltip:rb.get,contentFocus:!1,toggle:!1};q=[[{handlers:k({"from-url":function(d){f.trigger.open();var h=bA(a,b,c.uiContainer(),YW,e,ha.dialog);h.events.insertAssets.bind(w);d=function(){a.focus();h.destroy()};h.events.opened.bind(I);h.events.close.bind(d);
  h.events.escaped.bind(d);h.show()},"from-camera":function(){f.trigger.open();C.open()}}),destroyer:t,refreshMenu:t,structure:k({}),submenus:k([]),items:k(q),events:f.registry}]];d=df.menu(d,q,x.get,qj.menu({focusActive:!0}));q={label:k(!1),hasDialog:!0};return ua(d,q)}function $W(a){var b=p.fromTag("button");m.set(b,"type","button");n.add(b,lb.resolve("independent-button"));return Fq(b,g.none(),a)}function aX(a){var b=$z.multiple(),c=T.div();n.add(c,Sb.resolve("drop-container"));var d=eA.register(c,
  g.some(Sb.resolve("drop-active")),!1),e=$W();e.content(Qc(a("fileupload.chooseimage")));n.add(e.element(),Sb.resolve("default-action"));n.add(e.element(),Sb.resolve("file-selector-trigger"));var f=p.fromTag("p");n.add(f,Sb.resolve("help-text-drop-icon"));var h=p.fromTag("p");n.add(h,Sb.resolve("help-text-drop"));ra.disable(h);y.append(h,p.fromText(a("fileupload.dropimages")));P.append(c,[f,h,e.element(),b.element()]);return{container:k(c),dropper:k(d),picker:k(b),button:k(e),focus:function(){Z.focus(e.element())},
  destroy:function(){b.destroy();d.destroy();e.destroy()}}}function bX(a){var b=aX(a);a=b.picker();var c=b.container(),d=b.dropper(),e=b.button(),f=H.create({upload:r(["assets"]),dragndrop:r(["assets"]),dragover:Q([],d.events.dragover),dragleave:Q([],d.events.dragleave),drop:Q([],d.events.drop)}),h=function(a){return function(b){ve.multiple(b.files()).get(function(b){a(b)})}};a.events.upload.bind(h(f.trigger.upload));d.events.dragndropimages.bind(h(f.trigger.dragndrop));e.events.click.bind(a.open);
  return{element:k(c),button:k(e),input:a.element,focus:b.focus,events:f.registry,destroy:function(){b.destroy()}}}function fA(a,b,c){var d=[],e=O("view","item","container"),f=H.create({setActive:r(["item"])}),h=T.div();n.add(h,lb.resolve("tablayout-wrapper"));n.add(h,lb.resolve("tablayout-wrapper-"+a));void 0!==c&&n.add(h,c);var l=T.div();n.add(l,lb.resolve("tablayout-body"));var q=p.fromTag("div");n.add(q,lb.resolve("tablayout-menu"));P.append(h,[q,l]);var g=function(a){var b=Gq(a);b.content(Qc(a));
  n.add(b.element(),lb.resolve("tablayout-item"));return b},w=[],I=E(b,function(a){var b=g(a.heading());m.set(b.element(),"data-ephox-pastry-tablayout-tab",a.heading());y.append(q,b.element());var c=p.fromTag("div");n.add(c,lb.resolve("tablayout-content"));m.set(c,"data-ephox-pastry-tablayout-view",a.heading());y.append(l,c);w.push(c);var f=e(a,b,c);d.push(f);b.events.click.bind(function(){G(f)});return b}),G=function(a){z(d,function(b){var c=b.view(),d=b.item(),e=b.container();b===a?(n.add(e,lb.resolve("tablayout-active")),
  d.select(),c.renderer().render(e),f.trigger.setActive(d)):(n.remove(e,lb.resolve("tablayout-active")),d.deselect())})};G(d[0]);return{element:function(){return h},tabs:k(I),body:k(l),menu:k(q),tabContent:k(w),destroy:function(){z(I,function(a){a.destroy()})},events:f.registry}}function gA(a){return{render:function(b){F.empty(b);y.append(b,a)}}}function cX(a){var b=T.div(),c=bX(x.translate),d=dA(x.translate),e=function(a,b){a=x.translate(a);b=gA(b);return Rg(a,b)},f=e("fileupload.tabweburl",d.element());
  a=(a.allowLocalImages?[e("fileupload.tablocal",c.element())]:[]).concat(f);var h=fA(nr.top(),a,"file-upload");S.hidden(c.input(),!0);e=function(){var a=c.button();n.add(a.element(),B.resolve("dialog-button-default"));var b=aa.detect().browser.isFirefox(),d={execute:Kb.button};b=b?ua(d,{process:t}):d;b=Ba.button(b);return ha.button(a.element(),b)}();S.tabList(h.menu());f=function(){var a=d.input();return ha.input(a,Ba.input({}))}();var l=ha.flow(h.menu(),{item:k(".ephox-pastry-statebutton")},Ba.flow({trigger:Kb.button,
  executeOnArrow:!0}));e=[l].concat(e).concat(f);var q=h.tabs();z(h.tabContent(),function(a){S.tabPanel(a)});z(a,function(a,b){var c=q[b];S.tabButton(c.element(),a.heading());n.add(c.element(),B.resolve("tab-button"));c.events.click.bind(function(){l.clickFocus(c.element())})});z(h.tabContent(),function(a,b){b=q[b];var c=Fa("ephox-aria");m.set(b.element(),"id",c);S.labelledBy(a,c)});a=H.create({upload:Q(["assets"],c.events.upload),dragndrop:Q(["assets"],c.events.dragndrop),dragover:Q([],c.events.dragover),
  dragleave:Q([],c.events.dragleave),drop:Q([],c.events.drop),lookup:Q([],d.events.lookup),success:Q([],d.events.success),setActive:Q(["item"],h.events.setActive)});h.events.setActive.bind(function(a){a=m.get(a.item().element(),"data-ephox-pastry-tablayout-tab");a===x.translate("fileupload.tablocal")?c.focus():a===x.translate("fileupload.tabweburl")&&d.focus()});y.append(b,h.element());return{element:k(b),events:a.registry,focus:d.focus,keylayouts:k(e),reset:function(){d.reset()},selected:d.selected,
  destroy:function(){h.destroy();c.destroy();d.destroy()}}}function ge(a,b,c){a=parseFloat(a);a>c?a=c:a<b&&(a=b);return a}function Rf(a,b){var c,d,e,f,h=[],l=Array(10);for(c=0;5>c;c++){for(d=0;5>d;d++)h[d]=b[d+5*c];for(d=0;5>d;d++){for(e=f=0;5>e;e++)f+=a[d+5*e]*h[e];l[d+5*c]=f}}return l}function or(a,b){b=ge(b,0,1);return a.map(function(a,d){a=0===d%6?1-(1-a)*b:a*b;return ge(a,0,1)})}function vm(a,b){return a.toCanvas().then(function(c){var d=a.getType(),e=Tc.get2dContext(c),f=e.getImageData(0,0,c.width,
  c.height),h=f.data,l,q=b[0],g=b[1],k=b[2],I=b[3],G=b[4],V=b[5],m=b[6],n=b[7],p=b[8],r=b[9],t=b[10],u=b[11],v=b[12],z=b[13],y=b[14],x=b[15],A=b[16],B=b[17],D=b[18],E=b[19];for(l=0;l<h.length;l+=4){var F=h[l];var H=h[l+1];var J=h[l+2];var K=h[l+3];h[l]=F*q+H*g+J*k+K*I+G;h[l+1]=F*V+H*m+J*n+K*p+r;h[l+2]=F*t+H*u+J*v+K*z+y;h[l+3]=F*x+H*A+J*B+K*D+E}e.putImageData(f,0,0);return xe.fromCanvas(c,d)})}function hA(a,b){return a.toCanvas().then(function(c){return dX(c,a.getType(),b)})}function dX(a,b,c){var d=
  Tc.get2dContext(a);var e=d.getImageData(0,0,a.width,a.height);var f=d.getImageData(0,0,a.width,a.height);f=function(a,b,c){function d(a,b,c){a>c?a=c:a<b&&(a=b);return a}var e,f,h,l,q,g;var k=Math.round(Math.sqrt(c.length));var m=Math.floor(k/2);var n=a.data;var p=b.data;var r=a.width;var t=a.height;for(e=0;e<t;e++)for(a=0;a<r;a++){for(g=f=h=l=0;g<k;g++)for(q=0;q<k;q++){var u=d(a+q-m,0,r-1);var v=d(e+g-m,0,t-1);u=4*(v*r+u);v=c[g*k+q];f+=n[u]*v;h+=n[u+1]*v;l+=n[u+2]*v}u=4*(e*r+a);p[u]=d(f,0,255);p[u+
  1]=d(h,0,255);p[u+2]=d(l,0,255)}return b}(e,f,c);d.putImageData(f,0,0);return xe.fromCanvas(a,b)}function iA(a){return function(b,c){return b.toCanvas().then(function(d){var e=b.getType(),f=Tc.get2dContext(d),h,l=Array(256);for(h=0;h<l.length;h++)l[h]=a(h,c);h=f.getImageData(0,0,d.width,d.height);var q=h.data,g;for(g=0;g<q.length;g+=4)q[g]=l[q[g]],q[g+1]=l[q[g+1]],q[g+2]=l[q[g+2]];f.putImageData(h,0,0);return xe.fromCanvas(d,e)})}}function Mh(a){return function(b,c){return vm(b,a(of.identity(),c))}}
  function jA(a){return function(b){return hA(b,a)}}function kA(a,b,c){var d=Nh.getWidth(a),e=Nh.getHeight(a);d=b/d;var f=c/e;e=!1;if(.5>d||2<d)d=.5>d?.5:2,e=!0;if(.5>f||2<f)f=.5>f?.5:2,e=!0;a=eX(a,d,f);return e?a.then(function(a){return kA(a,b,c)}):a}function eX(a,b,c){return new Md(function(d){var e=Nh.getWidth(a),f=Nh.getHeight(a),h=Math.floor(e*b),l=Math.floor(f*c),q=Tc.create(h,l);Tc.get2dContext(q).drawImage(a,0,0,e,f,0,0,h,l);d(q)})}function fX(a,b,c,d,e){var f=a.content(),h=a.smartview(),l=
  a.ui().tabstrip,q=mr(a.ui),g=Dj.processResults(q.showKey),w=function(d){a.undo().save();d=gX.validate(d);(d.failure()?u(q.showKey,"fileupload.invalidimages"):q.hide)();c.assets(d.assets()).bind(lA.maybeDoRotate).map(g).get(function(a){pr.insertAssets(f,b,a)})},I=function(a){w(a.assets())};d.events.insertAssets.bind(function(a){e.allowLocalImages?w(a.assets()):mf.getOrLog("errors.dragdrop.images.disallowed")});var G=f.cursor();d=H.create({analytics:r(["message"])});return{ui:vb.ui({"fileupload.general":k({value:"image",
  textkey:x.key("insert.image"),icon:!0,updateGeneral:ca,action:function(){var b=bA(f,l,h.uiContainer(),cX,e,ha.dialog);b.events.insertAssets.bind(I);b.events.close.bind(function(){f.focus();b.destroy()});b.events.escaped.bind(function(){f.focus();b.destroy()});a.content().hideInlineSelection();b.show()},hasDialog:!0}),"fileupload.menu":function(){var c=ZW(f,l,h,a.ui(),e);c.events.insertAsset.bind(function(a){G.get().bind(function(c){pr.insertMobileAssets(f,c,b,[a.asset()])})});c.events.open.bind(function(a){f.getSelection().each(G.save)});
  return c},"camera.general":function(){var a=Zz();a.events.upload.bind(function(a){G.get().bind(function(c){pr.insertMobileAssets(f,c,b,a.assets())})});return{value:"image",textkey:x.key("image.from-camera"),icon:!0,updateGeneral:ca,action:function(){f.getSelection().each(G.save);f.toReading();a.open()},hasDialog:!0}}},ca),events:d.registry,destroy:function(){}}}function mA(a,b,c){var d=function(){b.counter.update(0,0)},e=function(e){e.all.fold(d,function(d){b.counter.update(e.pos+1,d.length);d=d[e.pos][0];
  a.setSelection(d,0,d,0);c.element(d)})},f=function(){c.cursor();d()},h=function(a,b,c){pf.clear(a);pf.search(a,b,c).fold(f,e);return g.some(b)},l=function(a,b){a=(!0===b?pf.prev:pf.next)(a);a.fold(f,e);return a},q=function(b){a.body().each(function(c){pf.replace(c,b).fold(f,e);a.domChanged();a.undoChanged()})},C=g.none(),w=function(){C=g.none()};b.events.search.bind(function(b){a.body().each(function(a){h(a,b.term(),b.matchcase())})});b.events.next.bind(function(){a.body().each(function(a){l(a,!1)})});
  b.events.prev.bind(function(){a.body().each(function(a){l(a,!0)})});b.events.replace.bind(function(a){q(a.value())});b.events.replaceAll.bind(function(b){a.body().each(function(c){pf.replaceAll(c,b.value()).fold(f,e);a.undoChanged()})});b.events.interactive.bind(function(b){a.body().each(function(a){C=h(a,b.term(),b.matchcase())})});b.events.encase.bind(function(b){a.body().each(function(a){C.each(function(c){h(a,c,b.matchcase())})})});b.events.clear.bind(function(b){a.body().each(function(a){pf.clear(a);
  w()})});return{zeroCount:d,updateMatch:e,enterSearchAction:function(c,d){a.body().each(function(a){var e=b.getCase();C=C.filter(function(a){return c===a}).fold(function(){return h(a,c,e)},function(b){return l(a,d.isShift()).fold(function(){return h(a,c,e)},k(C))})});(0===c.length?b.counter.hide:b.counter.show)()},enterReplaceAction:q,clearLastSearch:w}}function nA(a){var b=a.content();a=function(a){b.elementIntoView(a)};var c=function(){b.cursorIntoView()};a={element:oA?a:u(Ng.elementIntoView,b),
  cursor:oA?c:u(Ng.cursorIntoView,b)};return{get:k(a)}}function pA(){var a=T.div();n.add(a,B.resolve("search-widget"));var b=wm.searchField(),c=(xc.isSmallTouch()?wm.dummyCounter:wm.counter)(b.input()),d=wm.replaceDrawer(),e=d.element(),f=H.create({next:Q([],b.events.next),prev:Q([],b.events.previous),replace:r(["value"]),replaceAll:r(["value"]),search:r(["term","matchcase","isShift"]),interactive:r(["term","matchcase"]),encase:r(["matchcase"]),clear:r([])});ra.setPressed(d.matchcase.element(),d.matchcase.selected());
  var h=vy(e);S.linkElements(b.moreToggle.element(),e);qA(h.visible(),b.moreToggle.element(),e);b.moreToggle.events.click.bind(function(){(h.visible()?h.hide:h.show)()});b.events.input.bind(function(){var a=fa.get(b.input()),d=sa.get(b.element());v.set(c.element(),"height",d+"px");3<=a.length?q.throttle(a):(f.trigger.clear(),c.hide(),c.update(0,0))});d.replace.events.click.bind(function(){var a=fa.get(d.input.element());f.trigger.replace(a)});d.replaceAll.events.click.bind(function(){var a=fa.get(d.input.element());
  f.trigger.replaceAll(a)});d.matchcase.events.click.bind(function(){ra.setPressed(d.matchcase.element(),d.matchcase.selected());f.trigger.encase(l())});var l=function(){return d.matchcase.selected()},q=jf(function(a){c.show();f.trigger.interactive(a,l())},500),g=K.bind(e,"transitionend",function(a){"opacity"===a.raw().propertyName&&n.remove(e,"ephox-chameleon-toolbar-more-open");qA(h.visible(),b.moreToggle.element(),e)});P.append(a,[c.element(),b.element(),d.element()]);return{element:k(a),search:b,
  focus:function(){b.focus()},drawer:d,counter:c,getCase:l,destroy:function(){g.unbind();b.destroy();d.destroy();c.destroy();h.destroy();F.remove(a)},events:f.registry}}function hX(a){var b=a.content(),c=pA();a=nA(a);var d=mA(b,c,a.get()),e=function(a){var c=a.endContainer();a=a.endOffset();b.setSelection(c,a,c,a)};a=Ba.button({execute:Kb.button});a=[ha.input(c.search.input(),Ba.input({execute:function(a,b){d.enterSearchAction(a,b)}})),ha.button(c.search.previous(),a),ha.button(c.search.next(),a),ha.button(c.search.moreToggle.element(),
  a),ha.input(c.drawer.input.element(),Ba.input({execute:function(a,b){d.enterReplaceAction(a)}})),ha.button(c.drawer.matchcase.element(),a),ha.button(c.drawer.replace.element(),a),ha.button(c.drawer.replaceAll.element(),a)];var f=H.create({done:r([])});return{element:c.element,anchorName:k("search-widget-anchor"),textkey:k("action.search"),dialogTextkey:k("search.menu"),destroy:function(){c.destroy()},keylayouts:k(a),openWidget:function(){d.enterSearchAction(fa.get(c.search.input()),Od.shiftKeyState(!1))},
  closeWidget:function(){b.body().each(function(a){b.getSelection().each(e);pf.clear(a)});d.clearLastSearch()},events:f.registry}}function iX(a,b){var c=a.content(),d=pA();a=nA(a);var e=mA(c,d,a.get());a=H.create({toEditor:r([])});b=Ej.text(d.search.element(),d.search.input());return{element:d.element,addEscape:function(a){y.append(d.search.element(),a.element())},open:function(){e.enterSearchAction(fa.get(d.search.input()),Od.shiftKeyState(!1));setTimeout(d.focus,250)},close:function(){c.body().each(function(a){pf.clear(a).fold(e.zeroCount,
  e.updateMatch)});e.clearLastSearch()},execute:function(a){if(Z.hasFocus(d.search.input())){a=Od.shiftKeyState(!0===a.raw().shiftKey);var b=fa.get(d.search.input());e.enterSearchAction(b,a)}else a=fa.get(d.drawer.input.element()),e.enterReplaceAction(a)},type:k(b),events:a.registry,destroy:function(){d.destroy()}}}function xm(a,b){jX(b);var c=a.content(),d=a.ui().tabstrip.element();n.add(b.element(),B.resolve("slick-widget"));kX.browser.isSafari()&&z(Y.descendants(b.element(),"input,textarea"),function(a){m.setAll(a,
  {autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false"})});var e=function(){var a=Y.descendants(b.element(),"input,textarea");Va(a,Z.hasFocus).each(function(b){b=(b+1)%a.length;0<=b&&b<a.length&&Z.focus(a[b])})},f=Ej.cata(b.type(),function(a,c){n.add(a,B.resolve("slick-widget-field"));n.add(c,B.resolve("slick-widget-input"));var d=K.bind(b.element(),"keydown",function(a){var c={original:k(a)};fe.isEnter(c)?(b.execute(a),a.kill()):fe.isTab(c)?(e(),a.kill()):fe.isEscape(c)&&(w(),
  a.kill())}),f=K.bind(c,"blur",function(a){g.from(a.raw().relatedTarget).each(function(a){!0===Ja.ancestor(p.fromDom(a),function(a){return n.has(a,"ephox-polish-mobile-toolbar-hide")}).isSome()&&qr.refreshInput(c)})});return{destroy:function(){d.unbind();f.unbind()}}});a=Nc("shizniz");var h=x.translate("toolbar.backbutton"),l=bf([va.resolve("icon")]);a.content(l);m.set(a.element(),"title",h);S.toolbarButton(a.element(),h,!1,!1);b.addEscape(a);var q=na(!1);y.prepend(d,b.element());var C=H.create({done:r([]),
  abort:r([]),open:r([]),close:r([])}),w=function(){G();c.toEditing()};b.events.toEditor.bind(w);var I=Zb(function(a){return Y.children(d,"."+va.resolve("toolbar"))}),G=function(){b.close();q.set(!1);z(I(),function(a){n.remove(a,B.resolve("mobile-toolbar-hide"))});n.remove(b.element(),B.resolve("mobile-toolbar-show"));n.add(b.element(),B.resolve("mobile-toolbar-hide"));C.trigger.close()};c.events.mousedown.bind(G);G();a.events.click.bind(function(){w();C.trigger.abort()});return{element:b.element,destroy:function(){c.events.mousedown.unbind(G);
  f.destroy();b.destroy()},events:C.registry,open:function(){var a=K.bind(d,"transitionend",function(){b.open();C.trigger.open();a.unbind()});q.set(!0);z(I(),function(a){n.remove(a,B.resolve("mobile-toolbar-show"));n.add(a,B.resolve("mobile-toolbar-hide"))});n.remove(b.element(),B.resolve("mobile-toolbar-hide"));n.add(b.element(),B.resolve("mobile-toolbar-show"))},close:G,isOpen:function(){return q.get()}}}function lX(a){var b=a.filter();Od.configure(b);var c=H.create({analytics:r(["message"])}),d=
  Zb(function(){var b=mX(a);b.events.open.bind(function(){c.trigger.analytics("search_tool_open")});b.events.abort.bind(b.close);return b});b=function(){var a=d();(a.isOpen()?a.close:a.open)()};a.shortcuts().events.search.bind(b);return{ui:vb.ui({"find.general":{toggle:!1,hasPopup:!1,value:"search",textkey:x.key("action.search"),action:b,updateGeneral:function(a){n.add(a.element(),B.resolve("search"))},icon:!0,tooltip:rb.get}}),events:c.registry,destroy:function(){d().destroy()}}}function Fj(a,b){var c=
  Nc();ma.add(c.element(),a);S.button(c.element(),x.translate(b));m.set(c.element(),"title",x.translate(b));return c}function nX(a,b){var c=oX(ym.configuration()),d=c.i18nNamespace(),e=c.cssNamespace();b=T.div();n.add(b,B.resolve("fontsize-widget"));var f=T.span();n.add(f,B.resolve("fontsize-widget-field"));var h=T.div();n.add(h,B.resolve("fontsize-widget-exit"));var l=p.fromTag("input");n.add(l,B.resolve("fontsize-widget-input"));S.label(l,x.translate(d+".stepper.input"));var q=function(b){n.remove(l,
  B.resolve("slick-widget-invalid-input"));S.invalid(l,!1);fa.set(l,b);Sf.partialSize(a.content(),a.undo(),a.selections(),b);ib.speak(ja.body(),b)},g=function(){n.add(l,B.resolve("slick-widget-invalid-input"));S.invalid(l,!0);ib.speak(ja.body(),x.translate("aria.input.invalid"));Z.focus(l)},w=function(a){return function(){var b=fa.get(l);b=a(c.specials(),b);Tf.validate(b,c.tag(),c.property()).fold(g,q)}},I=w(zm.decrease);w=w(zm.increase);var G=function(a,b){return Fj([B.resolve(e+a),B.resolve("stepper-button")],
  d+b)},m=G("-stepper-decrease",".stepper.decrease");G=G("-stepper-increase",".stepper.increase");m.events.click.bind(I);G.events.click.bind(w);P.append(f,[m.element(),l,G.element()]);y.append(b,f);y.append(b,h);f=Ej.text(f,l);var X=H.create({toEditor:r([]),size:r(["value"])}),dd=function(){fa.set(l,"")},u=function(a){a=Tf.sanitise(a);Tf.validate(a,c.tag(),c.property()).fold(g,function(a){n.remove(l,B.resolve("slick-widget-invalid-input"));S.invalid(l,!1)});fa.set(l,a)};return{element:k(b),addEscape:function(a){y.append(h,
  a.element())},open:function(){Z.focus(l)},close:t,execute:function(){var a=fa.get(l);Tf.validate(a,c.tag(),c.property()).fold(g,function(a){q(a);X.trigger.toEditor()})},destroy:t,type:k(f),represent:function(a){a.fold(dd,u,u)},events:X.registry}}function pX(a,b){var c=a.content(),d=na(g.none()),e=function(){var c=nX(a,b),e=xm(a,c);c={represent:c.represent,refreshValue:c.refreshValue,open:e.open,close:e.close,isOpen:e.isOpen};d.set(g.some(c));return c},f={toggle:!1,value:"size",textkey:x.key("font.size"),
  action:function(){var b=d.get().getOrThunk(e);if(b.isOpen())b.close();else{var f=Am.getState(a.selections(),c);b.open();b.represent(f.readState.size())}},updateGeneral:t,icon:!0,shortcut:!1,hasPopup:!1,hasDialog:!1};return{general:k(f)}}function rA(a){var b=a.hex(),c=p.fromTag("span");n.add(c,B.resolve("palette-detail-action"));m.set(c,"title",x.get(a.name()));S.option(c,x.get(a.name()),!1,!1);var d=H.create({selected:r(["value"])}),e=K.bind(c,"click",function(){Z.focus(c);d.trigger.selected(b)});
  return{element:function(){return c},value:k(b),destroy:function(){e.unbind();F.remove(c)},events:d.registry}}function qX(){var a=[],b=T.div(),c=p.fromTag("span");S.listBox(c);n.add(c,B.resolve("palette-detail-actions"));n.add(c,B.resolve("palette-color-options"));S.label(c,x.translate("aria.font.palette"));y.append(b,c);var d=Ol.create(),e=H.create({selected:r(["value"])});return{element:function(){return b},add:function(b){a.push(b.destroy);y.append(c,b.element());d.bind(b.events.selected,function(a){e.trigger.selected(a.value())})},
  remove:function(a){F.remove(a.element());d.unbind(a.events.selected)},show:function(){n.add(b,B.resolve("palette-detail-active"));ra.showPanel(b);v.remove(b,"display")},hide:function(){n.remove(b,B.resolve("palette-detail-active"));ra.hidePanel(b);v.set(b,"display","none")},count:function(){return a.length},destroy:function(){z(a,xb);F.remove(b);a=[]},events:e.registry}}function Bm(a){var b=Gj.makeLayout(a,".ephox-polish-palette-detail-action.ephox-polish-palette-color-option:not(.ephox-polish-palette-color-option-spacer)",
  {isValid:sA}),c=b.layout();return{isFocused:c.isFocused,enterGrid:c.enter,grid:c,refresh:b.refresh,destroy:c.destroy,clear:c.clear,isActive:function(){return sA(a)}}}function rX(){var a=p.fromTag("div");sX()?S.presentation(a):S.menuItem(a,g.none(),g.none());n.add(a,B.resolve("color-widget"));var b=p.fromTag("div");n.add(b,B.resolve("color-widget-controls"));S.tabList(b);var c=p.fromTag("div");n.add(c,B.resolve("color-widget-palettes"));S.toolbarGroup(c);var d=$d("text-color");n.add(d.element(),B.resolve("tab-button"));
  d.content(Qc(x.translate("font.color")));S.tabButton(d.element(),x.translate("aria.font.color"));var e=$d("highlight-color");n.add(e.element(),B.resolve("tab-button"));e.content(Qc(x.translate("font.highlight")));S.tabButton(e.element(),x.translate("aria.font.highlight"));y.append(b,d.element());y.append(b,e.element());y.append(a,b);y.append(a,c);return{element:k(a),colorToggle:k(d),highlightToggle:k(e),content:k(c),controls:k(b),destroy:function(){d.destroy();e.destroy();F.remove(c);F.remove(b)}}}
  function tX(a,b){var c=null;return{cancel:function(){null!==c&&(rr(c),c=null)},schedule:function(){for(var d=[],e=0;e<arguments.length;e++)d[e]=arguments[e];c=Sg(function(){a.apply(null,d);c=null},b)}}}function uX(){var a={},b=function(a,b){return Hj(b).fold(function(){return g.none()},function(c){c=Ij(c);return a.bind(c).map(function(a){return vX(b,a)})})};return{registerId:function(b,d,e){Ma(e,function(c,e){var f=void 0!==a[e]?a[e]:{};var h=u.apply(void 0,[c.handler].concat(b));c=c.purpose();h=
  {cHandler:h,purpose:k(c)};f[d]=h;a[e]=f})},unregisterId:function(b){Ma(a,function(a,c){a.hasOwnProperty(b)&&delete a[b]})},filterByType:function(b){return zc(a,b).map(function(a){return Lf(a,function(a,b){return{id:k(b),descHandler:k(a)}})}).getOr([])},find:function(c,d,e){var f=Ij(d)(a);return wX(e,function(a){return b(f,a)},c)}}}function xX(){var a=uX(),b={},c=function(a){var b=a.element();return Hj(b).fold(function(){var b=a.element(),c=Fa(yX+"uid-");m.set(b,tA,c);return c},function(a){return a})},
  d=function(c){Hj(c.element()).each(function(c){b[c]=void 0;a.unregisterId(c)})};return{find:function(b,c,d){return a.find(b,c,d)},filter:function(b){return a.filterByType(b)},register:function(e){var f=c(e);if(ye(b,f)){var h=b[f];if(h===e)d(e);else throw Error('The tagId "'+f+'" is already used by: '+Tg(h.element())+"\nCannot use it for: "+Tg(e.element())+"\nThe conflicting element is"+(ja.inBody(h.element())?" ":" not ")+"already in the DOM");}a.registerId([e],f,e.events());b[f]=e},unregister:d,
  getById:function(a){return Ij(a)(b)}}}function zX(a){var b=H.create({color:r(["color"]),close:r([])}),c=we(a),d=sd.okCancel("custom-color"),e=p.fromTag("div");S.presentation(e);n.add(c.element(),B.resolve("dialog-narrow"));c.setTitle(x.translate("font.coloroption"));c.setContent(e);c.setControls(d.element());a=AX();var f=Lb.create("ephox-acid"),h=function(a){return f.resolve(a)},l=BX.makeFactory(x.translate,h),q=Cm(l.sketch({dom:{tag:"div",classes:[h("color-picker-container")],attributes:{role:"presentation"}},
  onValidHex:function(){d.ok().enable()},onInvalidHex:function(){d.ok().disable()}}));a.add(q);CX(e,a);e=Y.descendants(e,"input");h=e[e.length-1];e=[ha.input(e[0],Ba.input({})),ha.input(h,Ba.input({}))];var g=Kb.setup(c,d,e),k=function(){b.trigger.close();g.exit()};c.events.close.bind(function(){k()});d.events.ok.bind(function(){ze.getCurrent(q).fold(function(){console.error("Could not find colour picker hex.")},function(a){Wb.getValue(a).hex.each(function(a){b.trigger.color("#"+a)})});k()});d.events.cancel.bind(k);
  return{element:a.element,events:b.registry,open:function(){c.show();g.enter()},destroy:function(){c.destroy();d.destroy();g.destroy()},close:k}}function DX(a,b){var c=zX(b),d=H.create({color:Q(["color"],c.events.color),close:r([])}),e=function(){d.trigger.close();f();a.focus()},f=function(){c.events.close.unbind(e);c.destroy()};c.events.close.bind(e);return{show:function(){a.toReading();c.open()},close:e,destroy:f,events:d.registry}}function EX(a,b,c){var d=Gj.create(c.colors.buttons),e=Gj.create(c.colors.buttons),
  f=(c.colors.custom?Dm.create:Dm.stub)(a,b),h=H.create({color:r(["value"]),highlight:r(["value"]),abort:r([]),menuDone:Q([],f.events.menuDone)});d.events.selected.bind(function(a){h.trigger.color(a.value())});e.events.selected.bind(function(a){h.trigger.highlight(a.value())});var l=rX();f.events.selected.bind(function(a){a=a.color();I.isActive()?h.trigger.highlight(a):h.trigger.color(a)});var q=l.colorToggle(),g=l.highlightToggle();S.linkTabToPanel(q.element(),d.element());S.linkTabToPanel(g.element(),
  e.element());y.append(l.content(),d.element());y.append(l.content(),e.element());P.append(l.content(),f.elements);var w=Bm(d.element()),I=Bm(e.element()),G=ha.flow(l.controls(),{item:k(".ephox-pastry-statebutton")},Ba.flow({trigger:function(a,b){return L.descendant(a,".ephox-pastry-button").map(function(a){a.dom().click();return a})},executeOnArrow:!0})),m=ha.multiple(l.element(),[G,w.grid,I.grid].concat(f.layouts));m.events.exit.bind(function(a){h.trigger.abort()});var X=function(){e.hide();q.select();
  g.deselect();ra.tabSelected(q.element(),[g.element()]);w.refresh();I.refresh();d.show()};q.events.click.bind(function(){G.clickFocus(q.element());X()});g.events.click.bind(function(){G.clickFocus(g.element());d.hide();q.deselect();ra.tabSelected(g.element(),[q.element()]);e.show()});return{element:l.element,destroy:function(){f.destroy();d.destroy();m.destroy();e.destroy();l.destroy()},open:function(){f.refresh();m.clear();m.refresh();q.click();X();m.enter()},close:function(){m.exit()},events:h.registry}}
  function FX(){var a=g.none(),b=function(b){a.each(function(a){a[b]()})};return{enter:u(b,"enter"),exit:u(b,"exit"),destroy:u(b,"destroy"),set:function(b){a=g.some(b)}}}function GX(a,b){var c=b.i18nNamespace();b=b.cssNamespace();var d=H.create({plus:r([]),minus:r([]),validate:r([]),abort:r([])}),e=Nc(),f=Nc(),h=T.div(),l=T.div(),q=p.fromTag("input");S.label(q,x.translate(c+".stepper.input"));S.toolbarButton(e.element(),x.translate(c+".stepper.increase"),!1,!1);S.toolbarButton(f.element(),x.translate(c+
  ".stepper.decrease"),!1,!1);m.set(q,"tabindex","-1");m.set(e.element(),"tabindex","-1");m.set(f.element(),"tabindex","-1");n.add(l,B.resolve(b+"-stepper-input"));n.add(h,B.resolve(b+"-stepper-options"));n.add(e.element(),B.resolve("stepper-button"));e.content(bf([B.resolve(b+"-stepper-increase")]));n.add(f.element(),B.resolve("stepper-button"));f.content(bf([B.resolve(b+"-stepper-decrease")]));y.append(l,q);P.append(h,[e.element(),f.element()]);P.append(a,[l,h]);e.events.click.bind(function(){Z.focus(e.element());
  d.trigger.plus()});f.events.click.bind(function(){Z.focus(f.element());d.trigger.minus()});var C=function(){q.dom().setSelectionRange(0,fa.get(q).length)},w=K.capture(a,"click",function(a){N.eq(a.target(),l)&&I.enter()}),I=FX(),G=n.toggler(q,B.resolve("invalid-"+b+"-size"));return{destroy:function(){e.destroy();f.destroy();I.destroy();w.unbind();F.remove(q)},highlight:function(){G.on();m.set(q,"title",x.translate("aria.stepper.input.invalid"));ib.shout(q,x.translate("aria.stepper.input.invalid"))},
  dehighlight:function(){G.off();m.remove(q,"title")},input:k(q),focus:function(){Z.focus(q);C()},enter:I.enter,exit:I.exit,initLayout:function(){var b=ha.single(q,[ea.basic(R.ENTER()[0],function(){d.trigger.validate();return g.some(!0)})],g.none());b.events.enter.bind(C);var c=Ba.button({execute:function(a){a.dom().click();Z.focus(a);return g.some(a)}});b=ha.multiple(a,[b,ha.button(e.element(),c),ha.button(f.element(),c)]);b.events.exit.bind(function(){A.parent(l).each(Z.focus);d.trigger.abort()});
  I.set(b)},events:d.registry}}function Em(a){var b=HX(a),c=T.div(),d=GX(c,b);n.add(c,B.resolve(b.cssNamespace()+"-size-widget"));var e=function(){return fa.get(d.input())},f=function(a){var b=e();a=a(b);a=Tf.sanitise(a);fa.set(d.input(),a);h.trigger.action(a);d.dehighlight()};d.events.validate.bind(function(a){a=e();Tf.validate(a,b.tag(),b.property()).fold(function(){d.highlight()},function(a){fa.set(d.input(),a);h.trigger.action(a);d.dehighlight();h.trigger.close()})});d.events.plus.bind(function(a){f(u(zm.increase,
  b.specials()))});d.events.minus.bind(function(a){f(u(zm.decrease,b.specials()))});var h=H.create({close:r([]),action:r(["value"]),abort:Q([],d.events.abort)}),l=K.bind(c,"click",function(a){(N.eq(a.target(),c)||N.eq(a.target(),d.input()))&&d.enter()});return{element:k(c),input:d.input,getCurrentValue:e,focus:d.focus,enter:d.enter,initLayout:d.initLayout,destroy:function(){l.unbind();d.destroy();F.remove(c)},updateInlineWidget:function(a,e){var f=function(a){Tf.validate(a,b.tag(),b.property()).each(function(a){fa.set(d.input(),
  a);d.dehighlight()})};a.size().fold(function(){f(e);n.add(c,B.resolve("default-"+b.cssNamespace()+"-size"))},t,function(a){f(a);n.remove(c,B.resolve("default-"+b.cssNamespace()+"-size"))})},open:t,close:t,events:h.registry}}function IX(a,b,c,d){var e=c();c=sd.okCancel("font-size");var f=we(b),h=null,l=H.create({close:r([]),open:r([]),analytics:r(["message"]),ok:r(["value"])});b=function(){h.unbind();f.hide();l.trigger.close()};f.setTitle(x.translate("font.size"));f.setContent(e.element());f.setControls(c.element());
  f.events.close.bind(b);c.events.ok.bind(function(){l.trigger.ok(e.getCurrentValue())});c.events.cancel.bind(b);n.add(f.element(),B.resolve("widget-dialog"));return{show:function(){f.show();var b=p.fromDom(window);h=K.bind(b,"orientationchange",function(){a.foreground()});l.trigger.open()},element:f.element,contents:e,events:l.registry,destroy:function(){f.hide();f.destroy();e.destroy()}}}function JX(a,b){var c=a.content(),d=a.undo(),e={},f=function(a){return E(a.split(/,\s?/g),function(a){return a.trim().replace(/^['"](.*)['"]$/,
  "$1")}).join(",")},h=(0===b.faces.length?g.none():g.some(b.faces)).fold(uA.faces,function(a){return E(a,function(a){var b=f(a.value);e[b]=a.value;return Oh.face(x.raw(a.text),b,g.none())})}),l=aa.detect().deviceType.isiOS(),q=H.create({analytics:r(["message","properties"])}),C=g.some(Wy.face),w=function(a){var b=f(a);a=qa(h,function(a){return a.value()===b});var c=Oh.face(x.raw(b),b,g.none());return a.getOr(c)},I=l?KX:LX;l=pX(a,b);return{ui:vb.ui({"fontface.dropdown":k({name:"fontface",textkey:x.key("font.face"),
  menuTextkey:x.key("font.menu"),updateDropdown:function(b){var c=MX.face(a.selections()).map(w);b.populate([{label:g.none,items:k(h)}]);am.updateMenu(b,c,Da.on(),h,C)},action:function(b){b=e.hasOwnProperty(b)?e[b]:b;Sf.face(c,d,a.selections(),b)},values:h,render:C,describe:function(a){return x.translate("font.describe",x.get(a.textkey()))},hasPopup:!0}),"fontcolor.widget":function(c){return NX.widget(a,b)},"fontsize.widget":function(b){return I.widget(a,b)},"fontsize.general":l.general},ca),events:q.registry,
  destroy:t}}function vA(a,b,c){var d=fA(a,b,c);S.tabList(d.menu());E(d.tabs(),function(a){var b='.ephox-pastry-tablayout-content[data-ephox-pastry-tablayout-view="'+a.name()+'"]';m.set(a.element(),"tabindex","-1");n.add(a.element(),B.resolve("tab-button"));L.descendant(d.body(),b).each(function(b){var c=Fa("ephox-aria");m.set(a.element(),"id",c);S.tabButton(a.element(),a.name());S.tabPanel(b);S.linkTabToPanel(a.element(),b);S.labelledBy(b,c)})});return{element:d.element,tabs:d.tabs,body:d.body,menu:d.menu,
  destroy:d.destroy,events:d.events}}function OX(a){var b=2===cb(a.integration).length,c=Uf.aboutTags(b,a.integration);return{content:function(a){return hb(c,function(a,b){return a.replace(b.str(),b.replace())},a)},dom:b?function(a){L.descendant(a,".ephox-polish-help-integration").each(function(a){v.set(a,"display","block")})}:t}}function Jj(a,b,c){var d=g.none(),e=g.none(),f=PX(c),h=function(a,c){c=b.content(c.trim());d=g.some(c);l(a,c)},l=function(a,c){c=p.fromHtml(c.trim());b.dom(c);F.empty(a);n.remove(a,
  B.resolve("tablayout-loading"));q(c);var d=p.fromTag("div");S.document(d);y.append(d,c);y.append(a,d)},q=function(a){w();e=L.descendant(a,".ephox-license-link").map(function(a){return K.bind(a,"click",function(a){window.open(f,"","height=700,width=620,resizable=yes,scrollbars=yes")})})},k=function(b){a.get(function(a){a.fold(function(a){b("&nbsp;");console.error("Unable to download help article",a)},b)})},w=function(){e.each(function(a){a.unbind()})};return{render:function(a){d.fold(function(){n.add(a,
  B.resolve("tablayout-loading"));k(u(h,a))},function(b){l(a,b)})},destroy:function(){w()}}}function QX(a){var b={content:ca,dom:t},c=aa.detect();if(!0===a.source){var d=a.baseUrl+"/help/"+qf.get()+"/";d={about:Ae.get(d+"about.html",Be.text(),he.xhr()),accessibility:Ae.get(d+"accessibility.html",Be.text(),he.xhr()),a11ycheck:Ae.get(d+"a11ycheck.html",Be.text(),he.xhr()),markdown:Ae.get(d+"markdown.html",Be.text(),he.xhr()),shortcuts:Ae.get(d+"shortcuts.html",Be.text(),he.xhr())}}else d=RX(a.baseUrl+
  "/help_"+qf.get()+".js?"+Uf.resourceParam());c=!c.deviceType.isTouch();a=[Kj(c,Rg(x.translate("help.dialog.shortcuts"),Jj(d.shortcuts,b,a))),Kj(c,Rg(x.translate("help.dialog.accessibility"),Jj(d.accessibility,b,a))),Kj(!0,Rg(x.translate("help.dialog.markdown"),Jj(d.markdown,b,a))),Kj(c,Rg(x.translate("help.dialog.a11ycheck"),Jj(d.a11ycheck,b,a))),Kj(!0,Rg(x.translate("help.dialog.about"),Jj(d.about,OX(a),a)))];return ee(a)}function SX(a,b){var c=H.create({close:r([])}),d=we(a),e=QX(b),f=vA(nr.left(),
  e,"help");m.set(f.body(),"tabindex","-1");n.add(d.element(),B.resolve("help-modal"));a=A.children(f.element());z(a,Uc.register);d.setTitle(x.translate("cog.help"));d.setContent(f.element());var h=TX(f);a=UX(f);var l=ha.multiple(d.element(),[h,a]);f.events.setActive.bind(function(a){h.clickFocus(a.item().element())});var q=function(){d.hide()};d.events.close.bind(function(){l.exit();q()});l.events.exit.bind(function(){q();c.trigger.close()});return{element:d.element,open:function(){d.show();l.enter()},
  destroy:function(){f.destroy();d.destroy();l.destroy();z(e,function(a){a.renderer().destroy()})},hide:q,events:c.registry}}function VX(a,b){var c=SX(a,b),d=function(){e.trigger.analytics("help_screen_hide");e.trigger.close();f()},e=H.create({close:r([]),analytics:r(["message"])});c.events.close.bind(d);var f=function(){c.events.close.unbind(d);c.destroy()};return{show:function(){e.trigger.analytics("help_screen_show");c.open()},destroy:f,events:e.registry}}function WX(a,b){var c=a.content(),d=a.smartview(),
  e=a.shortcuts(),f=H.create({analytics:r(["message"])}),h=gd.destroyable(),l=function(){var e=VX(d.uiContainer(),b);h.set(e);e.events.close.bind(function(){c.toEditing();h.clear()});e.events.analytics.bind(function(a){f.trigger.analytics(a.message())});c.toReading();a.content().hideInlineSelection();e.show()};e.events.help.bind(l);return{ui:vb.ui({"help.general":{toggle:!1,value:"help",textkey:x.key("cog.help"),action:l,updateGeneral:t,icon:!0,hasPopup:!1,hasDialog:!0,tooltip:rb.get}}),events:f.registry,
  destroy:function(){h.clear()}}}function XX(a,b,c){var d=a.filter(),e=a.content(),f=a.operations();rf.configure(d);var h=void 0===c.external?[]:E(c.external,function(a){return YX(a.prefix,a.suffix,a.style)});z(h,function(a){var c=Zx(a.prefix(),a.suffix(),function(b){var c=p.fromTag("span");ma.add(c,[rf.highlightClass()]);v.setAll(c,a.style());var d=p.fromTag("div");y.append(c,p.fromText(a.prefix()+b+a.suffix()));y.append(d,c);return Ha.get(d)});b.customMacros().add(c)});a=function(a){e.getSelection().each(function(b){a.prev().each(function(a){L.ancestor(a,
  "."+rf.placeholderClass()).each(function(a){wA.rehighlight(f,h,a)})});L.ancestor(b.startContainer(),"."+rf.highlightClass()).each(function(a){wA.unhighlight(f,a)})})};return 0<h.length?(e.events.nodeChanged.bind(a),{run:function(){ZX.run(e,h)},destroy:t}):{run:t,destroy:t}}function $X(a){var b=a.content();return{ui:vb.ui({"horizontalrule.general":{toggle:!1,value:"horizontalrule",textkey:x.key("insert.horizontalrule"),action:function(){rd.insertAtCursor(b,[p.fromTag("hr")]).each(function(a){a=la.after(a.element());
  b.setRelativeSelection(a,a);b.toEditing()})},updateGeneral:t,icon:!0,shortcut:!1,hasPopup:!1}}),destroy:t}}function xA(a){var b=B.resolve("dialog-float-selected"),c=p.fromTag("fieldset");m.set(c,"role","radiogroup");a=p.fromHtml("<legend>"+x.translate(a)+"</legend>");var d=Fa("ephox-aria");m.set(a,"id",d);m.set(c,"aria-labelledby",d);var e=T.div();n.add(e,B.resolve("dialog-float-options"));P.append(c,[a,e]);var f=function(){z(h,function(a){n.remove(a.element(),b);ra.checked(a.element(),!1)})},h=E(["none",
  "center","left","right"],function(a){var c=Nc(),d=x.translate("align."+a);m.setAll(c.element(),{tabindex:"-1","data-float-value":a,title:d,"aria-label":d,role:"radio"});a=T.div();d=T.div();var e=T.div(),h=T.div();S.hidden(a,!0);n.add(d,B.resolve("dialog-float-icon-inner-left"));n.add(e,B.resolve("dialog-float-icon-inner-center"));n.add(h,B.resolve("dialog-float-icon-inner-right"));P.append(a,[d,e,h]);c.events.click.bind(function(){f();n.add(c.element(),b);ra.checked(c.element(),!0);Z.focus(c.element())});
  n.add(c.element(),B.resolve("dialog-float-container"));n.add(a,B.resolve("dialog-float-icon"));y.append(c.element(),a);return c});P.append(e,E(h,function(a){return a.element()}));var l=Kb.radio(c,"."+B.resolve("dialog-float-container"),"."+B.resolve("dialog-float-selected"));return{element:function(){return c},get:function(){return L.child(e,"."+b).map(function(a){return m.get(a,"data-float-value")})},select:function(a){f();a.each(function(a){L.child(e,'span[data-float-value="'+a+'"]').or(A.firstChild(e)).each(function(a){n.add(a,
  b);ra.checked(a,!0)})});l.refresh()},keylayout:k(l),destroy:function(){z(h,function(a){a.destroy()})}}}function aY(){var a=T.div(),b=T.div(),c=T.div(),d=T.div();n.add(c,B.resolve("image-url-controls"));n.add(d,B.resolve("image-size-controls"));var e=xA("image.dialog.fields.align"),f=Vc.input("image-url","image.dialog.fields.url"),h=Vc.input("image-alt","image.dialog.fields.alt"),l=Vc.input("image-width","image.dialog.fields.width"),q=Vc.input("image-height","image.dialog.fields.height"),C=p.fromTag("input");
  m.set(C,"type","hidden");var w=$d("lock");n.add(w.element(),B.resolve("dialog-button"));var I=bf([B.resolve("icon"),B.resolve("image-lock-button")]);m.set(w.element(),"title",x.translate("image.dialog.fields.constrain.on"));S.toolbarButton(w.element(),x.translate("image.dialog.fields.constrain.label"),!1,!0);ra.press(w.element());w.select();w.content(I);w.events.click.bind(function(){Z.focus(w.element());var a=w.selected()?"on":"off";m.set(w.element(),"title",x.translate("image.dialog.fields.constrain."+
  a));(w.selected()?ra.press:ra.release)(w.element())});I=T.div();n.add(I,B.resolve("form-group"));n.add(I,B.resolve("form-group-lock"));var G=p.fromHtml("<label>"+x.translate("image.dialog.fields.constrain.label")+"</label>"),V="constrain"+Fa("");m.set(w.element(),"id",V);m.set(G,"for",V);var X=function(a){a.isLocal()?(m.set(f.input(),"disabled","disabled"),fa.set(f.input(),x.translate("image.dialog.fields.urllocal"))):(m.remove(f.input(),"disabled"),fa.set(f.input(),a.url()))},r=function(a,b,c){var d=
  parseFloat(fa.get(C));a=fa.get(a);fa.set(b,c(d,a).getOrThunk(function(){return fa.get(b)}));Lc.dehighlight(b)};V=function(a){Lc.validateField(a.target(),"width",g.some("px")).fold(function(){Lc.highlight(a.target())},function(b){Lc.dehighlight(a.target());b=a.target();w.selected()&&(N.eq(b,l.input())?r(l.input(),q.input(),sr.fromWidth):N.eq(b,q.input())&&r(q.input(),l.input(),sr.fromHeight))})};var t=function(a){if(m.has(a.target(),"placeholder")){var b=m.get(a.target(),"placeholder");""===fa.get(a.target())&&
  fa.set(a.target(),b)}},v=K.bind(l.input(),"input",V),z=K.bind(q.input(),"input",V),y=K.bind(l.input(),"focus",t),A=K.bind(q.input(),"focus",t);P.append(I,[G,w.element()]);P.append(b,[e.element()]);P.append(c,[f.element(),h.element()]);P.append(d,[l.element(),q.element(),I]);P.append(a,[c,d,b]);b=[ha.input(f.input(),Ba.input({})),ha.input(h.input(),Ba.input({})),ha.input(l.input(),Ba.input({})),ha.input(q.input(),Ba.input({})),ha.button(w.element(),Ba.button({execute:Kb.button})),e.keylayout()];return{element:k(a),
  destroy:function(){w.destroy();v.unbind();z.unbind();y.unbind();A.unbind();e.destroy()},dehighlight:u(Lc.clearHighlights,a),highlight:Lc.highlight,keylayouts:k(b),set:function(a){X(a);fa.set(h.input(),a.alt());fa.set(l.input(),a.width());fa.set(q.input(),a.height());var b=a.computedWidth().bind(function(b){return a.computedHeight().bind(function(a){return sr.calculate(b,a)})}).getOr(1);a.computedWidth().each(u(m.set,l.input(),"placeholder"));a.computedHeight().each(u(m.set,q.input(),"placeholder"));
  fa.set(C,b);e.select(a.align())},get:function(){return Lc.validate([Lc.rule(l.input(),"width",g.some("px")),Lc.rule(q.input(),"height",g.some("px"))]).map(function(a){return Fm.properties({url:fa.get(f.input()),alt:fa.get(h.input()),width:a.width(),height:a.height(),isLocal:m.has(f.input(),"disabled"),align:e.get()})})}}}function bY(a){var b=H.create({ok:r(["image","properties"]),close:r([])}),c=na(g.none()),d=we(a),e=sd.okCancel("image-properties"),f=aY();d.setContent(f.element());n.add(d.element(),
  B.resolve("dialog-narrow"));a=function(){var a=f.get();f.dehighlight();a.fold(function(a){f.highlight(a)},function(a){c.get().each(function(c){b.trigger.ok(c,a)})})};e.events.ok.bind(a);e.events.cancel.bind(function(){d.hide();b.trigger.close()});d.setTitle(x.translate("image.dialog.title"));d.setControls(e.element());d.events.close.bind(function(){b.trigger.close()});var h=Kb.setup(d,e,f.keylayouts());return{element:d.element,open:function(){d.show();h.enter()},hide:function(){h.exit();d.hide()},
  destroy:function(){d.destroy();h.destroy();e.destroy();f.destroy()},represent:function(a){var b=Fm.divine(a);c.set(g.some(a));f.set(b)},execute:a,events:b.registry}}function cY(a,b){b=yA.image(a.content());var c=H.create({changed:r(["image"]),contextmenu:Q(["image"],b.events.contextmenu)}),d=function(b){var d=a.content(),e=bY(a.smartview().uiContainer()),l=zA.generate(a.keyboard(),e,["image","properties"]);l.events.ok.bind(function(a){Fm.apply(a.image(),a.properties());c.trigger.changed(a.image());
  l.destroy();d.domChanged();d.focus();d.uiChanged()});l.events.close.bind(function(a){l.destroy();d.focus()});l.represent(b);l.open()};b.events.properties.bind(function(a){d(a.image())});return{destroy:t,situation:b.situation,handle:b.handle,assign:b.assign,events:c.registry}}function dY(a){var b=function(b){return Ae.get(b,Be.blob(),he.xhr(),a.newHeaders())},c=function(a){return!(tr.local(a)||tr.sameDomain(a,String(Vf.location)))};return{getImage:function(d){var e=m.get(d,"src");return(c(e)?a.proxy(e):
  g.none()).fold(function(){return Ua.fromPromise(Lj.imageToBlob(d.dom()))},b)}}}function eY(a,b,c){var d=g.none();return{setTarget:function(a){d=g.some(a)},clearTarget:function(){d=g.none()},mutate:function(e,f){d.each(function(d){var h=Fb.delta({top:f,left:e}),q=Ug.updatePosition(c,function(b){return d(a,b,h)});Ug.drawAtOrigin(c,a);b.update(q)})}}}function fY(a){var b=H.create({reposition:r(["direction","delta"])}),c=Wf("top","n",g.none()),d=Wf("bottom","s",g.none()),e=Wf("right","e",g.none()),f=
  Wf("left","w",g.none()),h=Wf("top-left","nw",g.some(a("image.crop.handle.nw"))),l=Wf("top-right","ne",g.some(a("image.crop.handle.ne"))),q=Wf("bottom-right","se",g.some(a("image.crop.handle.se"))),C=Wf("bottom-left","sw",g.some(a("image.crop.handle.sw"))),w=lf.nu(function(a){setTimeout(function(){v.reflow(c);var b=Ga.get(c),d=sa.get(c);a(k(3*b+2*d))},0)}),I=b.trigger.reposition;a=[c,d,e,f,l,h,q,C];I=[ha.single(h,Mj.navigation("nw",I),g.none()),ha.single(l,Mj.navigation("ne",I),g.none()),ha.single(q,
  Mj.navigation("se",I),g.none()),ha.single(C,Mj.navigation("sw",I),g.none())];return{elements:k(a),keylayouts:k(I),events:b.registry,refresh:function(a,b){a=AA.calculate(a,b);Xf(c,a.n());Xf(d,a.s());Xf(e,a.e());Xf(f,a.w());Xf(h,a.nw());Xf(C,a.sw());Xf(q,a.se());Xf(l,a.ne());w.get(function(a){BA([c,d],b.width,a);BA([e,f],b.height,a)})}}}function gY(){var a=Gm("left"),b=Gm("top"),c=Gm("right"),d=Gm("bottom");return{elements:k([a,b,c,d]),refresh:function(e,f){e=hY.derive(e,f);Hm(a,e.leftRim());Hm(b,e.topRim());
  Hm(c,e.rightRim());Hm(d,e.bottomRim())}}}function iY(a,b,c,d){var e=p.fromTag("div");n.add(e,CA.magicBox());Vg.base(e,d("image.crop.begin"));Im.effect(e,"execute");var f=p.fromTag("div");m.set(f,"role","row");var h=gY(),l=fY(d),q=function(a){v.setAll(e,{top:a.top()+"px",left:a.left()+"px"})};d=function(b){var c=a();q(c);h.refresh(c,b);l.refresh(c,b);C.trigger.updated(b)};P.append(f,Qb([h.elements(),[b],l.elements()]));y.append(e,f);var C=H.create({updated:r(["newBounds"]),reposition:Q(["direction",
  "delta"],l.events.reposition)});d(c);b=l.keylayouts();return{element:k(e),bitsbox:k(f),keylayouts:k(b),move:q,update:d,destroy:function(){F.remove(e)},events:C.registry,tryMovement:function(a){return L.closest(a,"."+ub.resolve("corner-wrapper")).bind(function(a){a=m.get(a,"data-"+ub.resolve("direction"));return void 0!==Jm[a]?g.some(Jm[a]):g.none()})}}}function jY(a,b,c,d){var e=p.fromTag("div");ma.add(e,[ub.resolve("panel-central"),ub.resolve("side-panel")]);m.set(e,"tabindex","-1");Vg.cell(e,d("image.crop.handle.shade"));
  Im.grab(e,!1);var f=kY(a());Ug.writePosition(e,f);Ug.drawAtOrigin(e);var h=iY(a,e,f,d);y.append(b,h.element());var l=eY(a(),h,e),q=sj.transform(l),C=K.bind(e,"dblclick",function(){t.trigger.apply()}),w=lY.bind(h.element(),function(a){h.tryMovement(a).orThunk(function(){return L.closest(a,"."+ub.resolve("panel-central")).map(function(){return Jm.translate})}).each(I)}),I=function(a){q.off();l.clearTarget();l.setTarget(a);q.on();q.go(c)},G=function(b,c){var d=Ug.updatePosition(e,function(d){return Jm[b](a(),
  d,c)});Ug.drawAtOrigin(e);h.update(d)};d=Qb([h.keylayouts(),[ha.single(e,Mj.navigation("translate",G),g.none())]]);var V=function(){var c=a();return K.bind(A.defaultView(b),"resize",function(){var b=a();if(b.height()!==c.height()||b.width()!==c.width())t.trigger.cancel();else if(b.top()!==c.top()||b.left()!==c.left())h.move(b),c=b})}();f=function(a){return function(){Z.active(A.owner(b)).each(function(b){Im.grab(b,a)})}};var X=f("true"),n=f("false");z(d,function(a){a.events.enter.bind(X);a.events.exit.bind(n)});
  h.events.reposition.bind(function(a){G(a.direction(),a.delta())});var t=H.create({updated:Q(["newBounds"],h.events.updated),apply:r([]),cancel:r([])});return{element:h.element,keylayouts:k(d),destroy:function(){q.destroy();V.unbind();w.unbind();C.unbind();h.destroy()},boxes:function(){return{box:a,magic:h.element,shade:k(e)}},get:function(){return Ug.readPosition(e)},events:t.registry}}function mY(a,b,c,d,e){var f=u(nY,a),h=jY(f,b,c,e);return{element:h.element,keylayouts:h.keylayouts,crop:function(){var b=
  h.get();var c=Ga.get(a),e=sa.get(a);b=oY({cropX:b.left(),cropY:b.top(),cropWidth:b.width(),cropHeight:b.height(),displayWidth:c,displayHeight:e});return d.animate(h.boxes().magic(),a,h.boxes(),b)},destroy:function(){h.destroy()},events:h.events}}function pY(a){var b=a.content(),c=H.create({ok:r(["cropAction","image","cleanup"])}),d=gd.value(),e=gd.value(),f=function(a){var f=b.body().getOrDie();ib.speak(ja.body(),x.translate("image.crop.announce"));var h=A.documentElement(a),g=mY(a,h,h,qY.slide(),
  x.translate),k=jf(function(a,b){ib.speak(ja.body(),x.translate("aria.image.crop.size",a,b))},500);g.events.updated.bind(function(a){a=a.newBounds();k.throttle(a.width(),a.height())});var I=function(){d.clear();p.exit();p.destroy();t.unbindAll();r.clear()},G=function(){I();e.clear();g.destroy()},m=function(){G();ie.select(b,a)},X=function(){I();g.crop().get(function(b){r.clear();ib.speak(ja.body(),x.translate("image.crop.apply"));var d=Wg.crop(b.cropX(),b.cropY(),b.cropWidth(),b.cropHeight()),e=ur.changedBounds(a);
  c.trigger.ok(function(a){return Dj.resampleAction(e,a,d)},a,function(a){G();return a})})};d.set(X);e.set(G);rY(b,a);var n=function(){ib.speak(ja.body(),x.translate("image.crop.cancel"));m()},r=gd.unbindable();setTimeout(function(){r.set(K.bind(f,"focus",function(a){n()}))});var p=ha.inlineDialog(h,g.keylayouts(),Ba.inlineDialog({ok:X,cancel:n}));p.enter();var t=Ol.create();t.bind(b.events.domChanged,m);t.bind(b.events.nodeChanged,function(a){ja.inBody(a.node())&&m()});t.bind(g.events.apply,X);t.bind(g.events.cancel,
  m)};return{apply:function(){d.on(xb)},open:function(){vc.detect(b.getSelection()).each(function(a){f(a.image())})},destroy:function(){e.on(xb)},isActive:d.isSet,events:c.registry}}function sY(a){a=tY.parse(a.preferredWidth,a.preferredHeight);var b=a.fold(uY,Dj.instance),c=a.fold(vY,function(){return wY(b)});return{assets:function(a){return Ce(a,b)},correlated:function(a){return Ce(a,c)}}}function xY(a,b,c){var d=dY(a.communication()),e=mr(a.ui),f=a.content(),h=function(c){return function(d){d.fold(function(a){a=
  vr.diagnoseImageEdit(a,m.get(c,"src"));e.show(a.bannerMessage());console.error("Image edit operation failed: ",a.consoleMessage())},function(c){b.uploadAssets([c]);f.focus();a.undo().save();f.domChanged()});ie.select(f,c);return d}},l=function(b,c){a.undo().save();var e=wr.applyEdit(b);return wr.run(d,c,e)(b)},q=pY(a);q.events.ok.bind(function(a){var b=a.image(),c=a.cropAction();a=a.cleanup();var d=sf.updater(sf.keepCrop,b);l(b,c).map(d).map(a).get(h(b))});var g=function(){return vc.detectForEditing(f.getSelection(),
  f.imageExcludes)},w=function(a,b){return function(){g().each(function(c){c=c.image();var d=ca,e=sf.updater(b,c);l(c,a).map(e).map(d).get(h(c))})}},I=[Ph.make("crop-begin","image.crop.begin",q.open),Ph.make("rotate-left","image.toolbar.rotateleft",w(Wg.rotateLeft,sf.keepRotate)),Ph.make("rotate-right","image.toolbar.rotateright",w(Wg.rotateRight,sf.keepRotate)),Ph.make("flip-horizontal","image.toolbar.fliphorizontal",w(Wg.flipHorizontal,sf.keepFlip)),Ph.make("flip-vertical","image.toolbar.flipvertical",
  w(Wg.flipVertical,sf.keepFlip))],G=[Ph.make("crop-apply","image.crop.apply",q.apply)];w=vb.ui({"edit.palette":u(DA.edit,a.ui().refresh,g,q.isActive,I),"crop.palette":u(DA.crop,a.ui().refresh,q.isActive,G)},ca);I=yA.imageEdit(q.isActive,G,I,f.imageExcludes);c=sY(c);return{destroy:function(){q.destroy()},ui:w,insertResample:k(c),situation:I.situation,handle:I.handle,assign:I.assign,name:k("imageEdit")}}function yY(a,b){var c=B.resolve("cursor-pointer"),d=b.os.isOSX(),e=g.none(),f=function(b){return a.isInline()?
  bb.absolute(b).top():0},h=function(b){var c=m.get(b,"href");if("top"===m.get(b,sb.bookmarkAnchorDataAttr()))a.doc().each(function(b){a.body().each(function(a){var c=Za.get(b);Za.to(c.left(),f(a),b)})});else if("bottom"===m.get(b,sb.bookmarkAnchorDataAttr()))a.win().each(function(b){a.doc().each(function(c){a.body().each(function(a){var d=f(a),e=Za.get(c);a=d+sa.get(a)-b.innerHeight;Za.to(e.left(),a,c)})})});else if(/^#/.test(c)){var d=c.substr(1);a.body().each(function(b){Ld.anchorTarget(b,d).each(function(b){a.win().each(function(a){Za.setToElement(a,
  b)})})})}else window.open(c)},l=function(a,b){var c=d?R.META():R.CTRL();U(c,a)&&b()};b=p.fromDom(window);var q=g.none();a.events.ready.bind(function(a){a=a.api().body();var b=rm.handle(a,function(a){var b=a.target();(d?a.raw().metaKey:a.raw().ctrlKey)&&L.closest(b,"a[href]").each(function(b){a.prevent();h(b)})});q=g.some(b);e=g.some(n.toggler(a,c))});var k=function(){e.each(function(a){a.on()})},w=function(){e.each(function(a){a.off()})},I=function(a){l(a.original().raw().which,w)};a.events.keyup.bind(I);
  var G=K.bind(b,"keyup",function(a){l(a.raw().which,w)}),V=function(a){l(a.original().raw().which,k)};a.events.keydown.bind(V);var X=K.bind(b,"keydown",function(a){l(a.raw().which,k)});return{follow:h,destroy:function(){q.each(function(a){a.unbind()});a.events.keyup.unbind(I);a.events.keydown.unbind(V);G.unbind();X.unbind()}}}function zY(a,b,c,d){var e=p.fromTag("div");S.dialog(e,x.get(d));ma.add(e,[B.resolve("expandable-inline-popup")]);d=T.div();n.add(d,B.resolve("inline-popup-content"));var f=T.div();
  ma.add(f,[B.resolve("inline-popup-content-expand"),Nj]);var h=T.div();n.add(h,B.resolve("inline-popup-controls"));var l=T.div();n.add(l,B.resolve("inline-popup-expand-button-wrapper"));var q=p.fromTag("span");ma.add(q,[B.resolve("inline-popup-expand-button"),B.resolve("icon")]);var g=x.translate("aria.label.more");m.set(q,"title",g);S.button(q,g);S.group(f);S.linkElements(q,f);y.append(l,q);g=T.div();n.add(g,B.resolve("inline-popup-body"));P.append(g,[d,f,l]);P.append(e,[g,h]);P.append(d,a);P.append(f,
  b);P.append(h,c);n.add(e,Nj);var w="0px",I=function(){n.remove(e,Nj);n.add(f,B.resolve("expand-close"));S.hidden(f,!0);v.setAll(f,{opacity:"0",height:"0px",visibility:"hidden"});ra.collapsed(q)},G=K.bind(f,"transitionend",function(a){ma.remove(f,[B.resolve("expand-close"),B.resolve("expand-open")])}),V=K.bind(q,"click",function(a){n.has(e,Nj)?I():(n.add(e,Nj),n.add(f,B.resolve("expand-open")),S.hidden(f,!1),v.setAll(f,{opacity:"1",height:w,visibility:"visible"}),ra.expanded(q))});a=[ha.button(q,Ba.button({execute:Kb.click}))];
  return{element:k(e),keylayouts:k(a),destroy:function(){F.remove(e);V.unbind();G.unbind()},show:function(){w=sa.getOuter(f)+"px";I();v.reflow(e);n.add(e,B.resolve("enable-transition"))}}}function AY(a){var b=BY();a.url().each(function(a){fa.set(b.input(),a)});var c=Vc.input("text-to-display","link.properties.text.label"),d=na(!1);n.add(c.element(),B.resolve("text-to-display"));m.setAll(c.input(),{placeholder:x.translate("link.properties.text.placeholder"),autocomplete:"off",autocorrect:"off"});a.text().each(function(a){fa.set(c.input(),
  a)});var e=Vc.input("title-text","link.properties.title.label");n.add(e.element(),B.resolve("title-container"));m.setAll(e.input(),{placeholder:x.translate("link.properties.title.placeholder"),autocomplete:"off",autocorrect:"off"});a.title().each(function(a){fa.set(e.input(),a)});var f=CY.target(a),h=K.bind(c.input(),"input",function(){d.set(!0)});return{url:k(b),text:k(c),textChanged:d.get,title:k(e),target:k(f),keylayouts:function(){return[ha.input(b.input(),Ba.input({})),ha.input(c.input(),Ba.input({})),
  ha.input(e.input(),Ba.input({})),ha.button(f.input(),Ba.button({execute:Kb.click,process:t}))]},destroy:function(){h.unbind()}}}function DY(a){var b=$e(a)?a:1E4,c=sm.access("local.linkCache");a=c.read();var d=function(a){return 0>b-a.length?a.slice(0,b):a}(Mb(a)?a:[]),e=function(a){d.splice(a,1)},f=function(){return d.slice(0)};return{add:function(a){"#"!==a.charAt(0)&&(d.length>=b&&d.pop(),Gc(d,a).each(e),d.unshift(a))},state:f,destroy:function(){c.write(f())}}}function EY(a,b){return{position:function(c,
  d){c=c.isRtl()?Qh.allRtl():Qh.all();var e=Fh(0,0);d=Lh.element(a,d);Km.simple(d,b,e,c,{})}}}function FY(a,b,c,d){var e=H.create({change:r([])}),f=function(){var a=b.body().map(Ld.all).getOr([]);a=ia(a,function(a){var b=m.get(a,"href");return Gb(b,"#")||m.has(a,sb.bookmarkAnchorDataAttr())?[]:[b]});a=d.state().concat(a);a=GY(a);return E(a,function(a){var b=g.none();return HY(a,k(!1),b,t)})},h=function(a,b,c){var d=Ld.getAnchorValue(a,hm.generate("textbox-heading"));return g.some(EA("#"+d,c,function(){m.set(b,
  "id",d)}))},l=function(a){var b="h1"!==D.name(a),c=Vb.get(a);return m.has(a,"id")||m.has(a,"name")?(a=m.has(a,"id")?m.get(a,"id"):m.get(a,"name"),g.some(EA("#"+a,b,t))):0===c.trim().length?g.none():h(c,a,b)},q=function(a){m.remove(a,sb.bookmarkAnchorDataAttr())},C=function(a){var b=sb.reservedUrls()[a.toLowerCase()];return function(a){m.set(a,sb.bookmarkAnchorDataAttr(),b)}},w=function(){var a=b.body().map(Ld.findLinkTargets).getOr([]),c=1E3<a.length;a=E(a,function(a){return l(a).map(function(b){var d=
  (c?Ld.linkTargetFastText:Ld.linkTargetText)(50,a);return xr(b.url(),b.indent(),b.action(),d.before(),d.innerText(),d.after())})});a=ee(a);var d=C(sb.topAnchorUrl());d=xr(sb.topAnchorUrl(),!1,d,"","\u2014 "+sb.topAnchorUrl()+" \u2014","");var e=C(sb.bottomAnchorUrl());e=xr(sb.bottomAnchorUrl(),!1,e,"","\u2014 "+sb.bottomAnchorUrl()+" \u2014","");return[d].concat(a).concat([e])};return{predict:function(b,d,h){var l=Zb(function(){var a=f(),d=w();a=Lm.config({container:c,translate:x.translate,sections:[Lm.section({id:"recent",
  highlight:"strong",contentLimit:50,items:a,itemLimit:10,render:FA.anchors,extractors:[Oj.title,Oj.url]}),Lm.section({id:"anchors",highlight:"strong",contentLimit:50,items:d,render:FA.standard,extractors:[Oj.innerText,Oj.url]})]});var e=Lm.init(b,a);ma.add(e.element(),[B.resolve("layer-menus"),B.resolve("tarot-inline")]);e.events.click.bind(function(a){e.hide();I(b,a.item())});a=Ga.get(b);v.setAll(e.element(),{"min-width":a+"px","box-sizing":"border-box"});return e}),k=na(g.none()),I=function(a,b){var c=
  b.url();fa.set(a,c);IY&&a.dom().click();k.set(g.some(b));e.trigger.change()},G=h.container(b);G.swallowKeys([R.UP(),R.DOWN()]);G.events.up.bind(function(a){a.stopper()();a=l();m(a);a.moveup()});G.events.down.bind(function(a){a.stopper()();a=l();m(a);a.movedown()});G.events.escape.bind(function(a){var b=l();b.isShowing()&&(b.hide(),a.stopper()())});G.events.enter.bind(function(a){l().getSelectedData().each(function(c){a.stopper()();var d=l();d.hide();d.reset();I(b,c)})});G.on();var m=function(c){if(!c.isShowing()){var d=
  fa.get(b);""===d?c.resetFull():c.filter(d);c.isShowing()||c.show(a.uiDirection())}},V=[K.bind(b,"input",function(c){e.trigger.change();c=l();k.set(g.none());var d=fa.get(b);0<d.length?(c.filter(d),c.isShowing()||c.show(a.uiDirection())):(c.reset(),c.hide())}),K.bind(b,"focus",function(a){l()}),K.bind(b,"blur",function(a){var c=l().hide;Z.active().fold(c,function(a){N.eq(a,b)||c()})}),K.bind(c,"click",function(a){l().hide()}),K.bind(d,"click",function(a){a.stop();a=l();a.isShowing()?a.hide():m(a)})];
  return{destroy:function(){l().destroy();G.destroy();z(V,function(a){a.unbind()})},getSelectedValue:function(){return k.get().fold(function(){var a=fa.get(b),c=sb.isReservedUrl(a)?C(a):q;return GA(a,c)},function(a){return GA(a.url(),a.action())})}}},events:e.registry}}function JY(a,b,c,d,e,f,h){var l=DY(1337),q=AY(f),k=h();h=[q.url().element()];var w=[q.text().element(),q.title().element(),q.target().element()],I=zY(h,w,k.elements(),k.dialogTitle());n.add(I.element(),B.resolve("inline-link-dialog"));
  var G=df.popup(d.uiContainer,d.bounds,a,[],Lg.editorContainer()).initMenu(I.element());n.add(G.element(),B.resolve("bubble-box"));h=G.element();h=FY(a,c,h,l);var V=h.predict(q.url().input(),q.url().dropArrow(),b);f.invalid()&&(q.url().showInvalid(),h.events.change.bind(function(){q.url().hideInvalid()}));var X={before:function(){v.set(G.panel(),"visibility","hidden");G.open()},after:function(){v.remove(G.panel(),"visibility");v.remove(G.panel(),"display")}},p=H.create({remove:Q([],k.events().remove),
  cancel:r([]),execute:Q([],k.events().execute)}),u=function(a){var b=a.command();a=a.data();m.has(a,sb.bookmarkAnchorDataAttr())||"insertLink"!==b&&"updateLink"!==b||(b=m.get(a,"href"),l.add(b))};e.events.internal.bind(u);b=function(){p.trigger.cancel()};k.events().cancel.bind(b);G.events.close.bind(b);b=Qb([q.keylayouts(),I.keylayouts(),k.keylayouts()]);var z=ha.inlineDialog(I.element(),b,Ba.inlineDialog({ok:k.execute.click,cancel:t}));z.events.exit.bind(function(){G.close();p.trigger.cancel()});
  return{showPopup:function(b){X.before();Hh.preserve(function(){b.showExpandable(a,c,d,G,I);X.after();I.show();z.enter()},I.element())},hide:function(){G.closed()||z.exit()},getValues:function(){var a=V.getSelectedValue(),b=fa.get(q.text().input()).trim(),c=fa.get(q.title().input());return Rh.properties({url:""===a.url()?g.none():g.some(a.url()),textChanged:q.textChanged(),text:g.some(b),title:g.some(c),target:yr.getValue(q.target().input()),action:g.some(a.action()),invalid:!1})},destroy:function(){l.destroy();
  e.events.internal.unbind(u);V.destroy();q.destroy();z.destroy();k.destroy();G.destroy();I.destroy()},events:p.registry}}function KY(a,b){var c=a.filter(),d=a.content(),e=a.smartview(),f=HA.enabled(d),h=a.internalevents(),l=aa.detect();Rh.configure(c);var q=yY(d,l);c=function(){d.getSelection().each(function(a){d.setSelection(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset())})};var k=l.browser.isIE()?c:t,w=H.create({insert:r(["properties"]),update:r(["properties"]),unlink:r([])}),
  I=gd.destroyable(),G=function(b,c){b=JY(a.region(),a.keyboard(),d,e,h,b,c);b.events.remove.bind(function(a){w.trigger.unlink();V()});b.events.cancel.bind(function(a){d.focus();V();k()});I.set(b);d.events.mousedown.bind(V);return b},V=function(){I.clear();d.events.mousedown.unbind(V)},X=function(a){var b=G(a,IA.update);b.events.execute.bind(function(a){w.trigger.update(b.getValues());V()});b.showPopup(zr)};f.events.properties.bind(function(a){a=a.link();var b=m.has(a,sb.bookmarkAnchorDataAttr())?sb.getReservedUrl(m.get(a,
  sb.bookmarkAnchorDataAttr())):m.get(a,"href"),c=g.from(Vb.get(a).trim());a=Rh.properties({url:g.from(b),textChanged:!1,text:c,title:g.from(m.get(a,"title")),target:g.from(m.get(a,"target")),action:g.none(),invalid:n.has(a,De.validationHighlight())});X(a)});f.events.follow.bind(function(a){d.focus();setTimeout(function(){q.follow(a.link())},0)});f.events.ignore.bind(function(a){b.ignore(a.link())});f.events.remove.bind(function(){w.trigger.unlink()});return{showContext:X,showInsert:function(a){var b=
  G(a,IA.insert);b.events.execute.bind(function(a){w.trigger.insert(b.getValues());V()});b.showPopup(zr)},situation:f.situation,handle:f.handle,assign:f.assign,events:w.registry,destroy:function(){V();q.destroy()}}}function LY(a){var b=na(g.none());a=T.div();n.add(a,B.resolve("link-widget"));var c=T.span();n.add(c,B.resolve("link-widget-field"));var d=p.fromTag("input");n.add(d,B.resolve("link-widget-input"));S.label(d,x.translate("link.properties.url.placeholder"));y.append(c,d);m.set(d,"type","url");
  m.set(d,"placeholder",x.translate("link.dialog.tooltip"));var e=Ej.text(c,d),f=Fj([B.resolve("link-widget-insert")],"insert.link"),h=Fj([B.resolve("link-widget-update")],"link.dialog.update"),l=Fj([B.resolve("link-widget-remove")],"link.dialog.remove");y.append(a,c);var q=H.create({insert:r(["properties"]),update:r(["properties"]),unlink:r([]),toEditor:r([])}),C=function(a,b){return Rh.properties({url:g.some(a),textChanged:b.isSome(),text:b,title:g.none(),target:g.none(),action:g.none(),invalid:!1})},
  w=function(){var a=fa.get(d),c=b.get().fold(function(){return C(a,a)},function(b){return b.text().fold(function(){return C(a,g.some(a))},function(b){b=g.from(b).filter(function(a){return""!==a.trim()});return C(a,b)})});q.trigger.insert(c);b.set(g.none());q.trigger.toEditor()},I=function(){var a=fa.get(d);q.trigger.update(C(a,g.none()));b.set(g.none());q.trigger.toEditor()};f.events.click.bind(w);h.events.click.bind(I);l.events.click.bind(function(){q.trigger.unlink();q.trigger.toEditor()});return{element:k(a),
  addEscape:function(a){y.append(c,a.element())},type:k(e),execute:function(){sc.isVisible(f.element())?w():sc.isVisible(h.element())&&I()},open:function(){Z.focus(d)},close:t,destroy:t,represent:function(a){z([f.element(),h.element(),l.element()],F.remove);a.url().fold(function(){fa.set(d,"http://");y.after(d,f.element())},function(a){P.after(d,[h.element(),l.element()]);fa.set(d,a)});b.set(g.some(a))},events:q.registry}}function MY(a){var b=LY(a),c=xm(a,b);a=HA.disabled();var d=H.create({insert:r(["properties"]),
  update:r(["properties"]),unlink:r([])});b.events.insert.bind(function(a){d.trigger.insert(a.properties())});b.events.update.bind(function(a){d.trigger.update(a.properties())});b.events.unlink.bind(function(a){d.trigger.unlink()});return{showContext:function(a){b.represent(a);c.open()},showInsert:function(a){b.represent(a);c.open()},situation:a.situation,handle:a.handle,assign:a.assign,events:d.registry,destroy:function(){c.close();c.destroy()}}}function NY(a,b){var c=a.content(),d=a.undo(),e=a.shortcuts(),
  f=aa.detect().deviceType.isTouch()?MY(a):KY(a,b),h=H.create({analytics:r(["message"])});f.events.insert.bind(function(b){d.transaction(function(){var d=Ar.insert(c,b.properties());a.internalevents().input(d)});c.domChanged();c.cursorIntoView();h.trigger.analytics("link_inserted")});f.events.update.bind(function(a){d.transaction(function(){var b=a.properties();Ar.update(c,b)});c.domChanged();c.cursorIntoView()});f.events.unlink.bind(function(a){d.save();Ar.unlink(c);c.domChanged();c.cursorIntoView()});
  b=function(){c.getSelection().each(function(a){Ld.sharedLinkOrClosest(a,c.isRoot).fold(function(){c.selectWord();var a=c.getSelectedText().map(function(a){return a.trim()});f.showInsert(Rh.properties({url:g.none(),textChanged:!1,text:a,title:g.none(),target:g.none(),action:g.none(),invalid:!1}))},function(a){var b=g.from(Vb.get(a).trim());f.showContext(Rh.properties({url:g.from(m.get(a,"href")),textChanged:!1,text:b,title:g.from(m.get(a,"title")),target:g.from(m.get(a,"target")),action:g.none(),invalid:n.has(a,
  De.validationHighlight())}))})})};var l=vb.ui({"link.general":{toggle:!1,value:"link",textkey:x.key("insert.link"),action:b,updateGeneral:t,icon:!0,shortcut:!0,hasPopup:!1,hasDialog:!0}});e.events.link.bind(b);return{ui:l,situation:f.situation,handle:f.handle,assign:f.assign,events:h.registry,destroy:function(){f.destroy()}}}function OY(a,b,c){var d=jm(c),e=km.get("ephox.link.service.one",JA.one(),a+"/1/check?url=${url}&fresh=${fresh}",b),f=km.post("ephox.link.service.many",JA.many(),a+"/1/check",
  b),h=function(a){return{url:a.url,result:KA.derive(a.url,a.result)}};return{checkOne:function(a,b){var c=wj.now();b=lm.single(function(b,c){return e.execute({url:encodeURIComponent(a),fresh:c})},d,a,c,void 0!==b?b:!1);return hf.mapSync(b,h)},checkMany:function(a,b){var c=wj.now();a=lm.multiple(function(a,b){return f.execute({urls:a})},d,a,function(a){return PY(a.results,"url")},function(a){return a.url},c,void 0!==b?b:!1);return hf.mapSync(a,function(a){return eb(a,h)})},dumpCache:d.dump}}function QY(a){var b=
  a.slice(0),c=function(a){var c=m.get(a,"href");if(Gb(c,"#")||m.has(a,sb.bookmarkAnchorDataAttr()))a=J.error(a);else{var d=A.owner(a).dom().baseURI;d=g.from(d).getOr(window.location);d=LA.resolve(d,a.dom().href);if(U(b,d))a=J.error(a);else{var h=Sh.parse(d).protocol;a="https"===h||"http"===h?J.value(RY(c,d)):J.error(a)}}return a};return{extract:c,ignore:function(a){c(a).each(function(a){b.push(a.resolved())})},state:function(){return b.slice(0)}}}function SY(a,b,c){var d=a.content(),e=a.filter(),f=
  a.communication(),h=a.undo(),l=a.viewablearea(),q=l.viewport(),k=QY(b.ignore),w=De.validationHighlight(),I=De.invalidLink(),G=De.unknownLink();De.configure(e);var m=OY(c.url,f.newHeaders(),b.cache),X=function(a){a=E(a,function(a){return Qg.cata(q.assess(a),g.none,Pb(g.some,k.extract),g.none)});a=ee(a);a=Pj.partition(a);z(a.errors,y);var b=TY.generate(a.values);a=cb(b);a=E(a,function(a){return{url:a}});a=m.checkMany(a);r(a,function(a){Ma(a,function(a){var c=b[a.url];void 0===c?console.warn("Link validator response from server was unknown: ",
  a.url,a.result):z(c,function(b){A(a.result,b)})})})};a=function(){var a=l.sections();a=Ld.many(a);a=ka(a,function(a){return!n.has(a,br.embedChecking())});X(a)};var p=jf(a,500).throttle;l.events.onChange.bind(p);d.events.domChanged.bind(p);var r=function(a,b){hf.handle(a,function(a){console.error("Link Validation server failure: ",a)},function(a){b(a)})},u=function(a){return d.body().map(function(b){return Ld.hrefUrl(b,a)})},v=function(a,b){u(a).each(function(a){z(a,function(a){n.has(a,De.validationHighlight())||
  ma.add(a,[w,b])})})},y=function(a){n.has(a,De.validationHighlight())&&ma.remove(a,De.allClasses())},x=function(a){u(a).each(function(a){z(a,y)})},A=function(a,b){KA.cata(a,function(a){v(b,I)},function(a){v(b,G)},function(a){x(b)})};h.events.undo.bind(a);h.events.redo.bind(a);return{destroy:t,refresh:p,ignore:function(a){h.save();k.ignore(a);p();d.focus();d.domChanged();d.cursorIntoView()},state:function(){return{ignore:k.state(),cache:m.dumpCache()}}}}function UY(a,b,c){return{patterns:function(){return[/(\W)(\w+)(\W*)$/gi,
  /(^)(\w+)(\W*)$/gi]},useCursor:k(!0),generate:function(a,b){a=p.fromText(b.text());return Zd.species({elements:k([a]),cursor:g.none,dictation:k(g.some(function(){return c(b.text())})),notify:g.none})},derive:function(a){var c=a.index+a[1].length,d=c+a[2].length;return b(a[2]).map(function(a){return{startIndex:k(c),finishIndex:k(d),text:k(a)}})},label:a}}function Br(a,b){var c=Cb.sanitise(a);return{patterns:function(){return[new RegExp("("+c+")","gi")]},useCursor:k(!0),generate:function(a,c){a=p.fromTag("span",
  a.dom());a.dom().innerHTML=b;return Zd.species({elements:k([a]),cursor:g.none,dictation:g.none,notify:g.none})},derive:function(a){var b=a.index;a=b+a[0].length;return g.some({startIndex:k(b),finishIndex:k(a)})}}}function Xg(a,b,c){var d=Cb.sanitise(b);return{patterns:function(){return[new RegExp("^("+d+"\\s)(.+)","gi")]},useCursor:ed,generate:function(b,d){var e=p.fromTag(a,b.dom());v.set(e,"list-style-type",c);var f=p.fromTag("li",b.dom()),q=p.fromTag("li",b.dom());y.append(q,p.fromTag("br",b.dom()));
  P.append(e,[f,q]);P.append(f,d.clones());return Zd.species({elements:k([e]),cursor:k(g.some(W.point(q,0))),dictation:g.none,notify:g.none})},derive:function(a){var b=a[1];return g.some({startIndex:k(a.index),finishIndex:k(a.index+b.length)})}}}function Mm(a,b,c,d){var e=Cb.sanitise(b),f=Cb.sanitise(c);return{patterns:function(){return[new RegExp(e+"([^\\s].*?[^\\s])"+f,"gi"),new RegExp(e+"([^\\s])"+f,"gi")]},useCursor:Jb,generate:function(a,b){a=p.fromTag(d,a.dom());b=p.fromText(b.text());y.append(a,
  b);return Zd.species({elements:k([a]),cursor:g.none,dictation:g.none,notify:g.none})},derive:function(a){return g.some({startIndex:k(a.index),finishIndex:k(a.index+a[0].length),text:k(a[1])})}}}function VY(a,b){var c=Cb.sanitise(a);return{patterns:function(){return[new RegExp("("+c+")","gi")]},useCursor:Jb,generate:function(a,c){return Zd.species({elements:k([p.fromTag(b,a.dom())]),cursor:g.none,dictation:g.none,notify:g.none})},derive:function(a){return g.some({startIndex:k(a.index),finishIndex:k(a.index+
  a[0].length)})}}}function WY(a,b,c){var d=c.allowed.fold(XY,function(a){return function(b,c){return U(a,b)?c:[]}}),e=function(a){return{derive:a.derive,generate:a.generate,patterns:a.patterns,useCursor:a.useCursor,allowed:k(!0)}},f=function(a,b){return{derive:a.derive,generate:a.generate,patterns:a.patterns,useCursor:a.useCursor,allowed:function(a){return!1===Db.closest(a,b)}}};c=d("headings",[e(Th.spaced("######","h6")),e(Th.spaced("#####","h5")),e(Th.spaced("####","h4")),e(Th.spaced("###","h3")),
  e(Th.spaced("##","h2")),e(Th.spaced("#","h1"))]);var h=d("lists",[e(Xg("ul","*","disc")),e(Xg("ol","1.","decimal")),e(Xg("ol","a.","lower-alpha")),e(Xg("ol","i.","lower-roman")),e(Xg("ol","1)","decimal")),e(Xg("ol","a)","lower-alpha")),e(Xg("ol","i)","lower-roman"))]),l=d("semantics",[e(Mm("bold","**","**","strong")),e(Mm("bold","__","__","strong")),e(Mm("italic","*","*","em")),e(Mm("italic","_","_","em"))]),q=d("entities",[e(Br("(c)","&copy;")),e(Br("--","&mdash;")),e(Br("-","&mdash;"))]),g=[e(MA.normalise()),
  e(MA.capitalise())],w=function(a){return x.translate("aria.autocorrect.announce",a)};a=a.hasAutocorrect()?[e(UY("autocorrect",a.lookup,w))]:[];w=d("hr",[e(VY("---","hr"))]);var I=Zb(function(a){a.runOrOnLoaded(function(b){var c=Zb(function(){A.owner(b).dom().execCommand("AutoUrlDetect",!1,!1)});a.events.focus.bind(function(){c()})});return d("link",[f(YY,"a")])});return{headings:k(c),semantics:k(l),entities:k(q),cases:k(g),lists:k(h),dynCustoms:function(){var a=b.get();return E(a,e)},link:I,hr:k(w),
  corrections:k(a)}}function ZY(a,b,c,d,e,f,h,l){var q=g.none(),k=g.none(),w=WY(e,f,l),I=Qb([w.link(b),w.hr(),w.semantics(),w.entities()]),G=function(){return Qb([I,a.autocorrect().get()?w.corrections():[],a.capitalisation().get()?w.cases():[],w.dynCustoms()])},m=w.headings().concat(w.lists()),X=function(a,b,c,d){var e=NA.descend(b,c),f=$Y.get(e.element(),e.offset());c=ka(d,function(a){return a.allowed(b)});return yc(c,function(b){return a(f,b,e.element(),e.offset())})},n=function(a,c){b.undoOperation(function(){a(function(){return c.execute(b,
  h)}).each(function(a){b.setSelection(a.element(),a.offset(),a.element(),a.offset())});b.domChanged()})};return{spaceDown:function(){b.getSelection().map(function(a){a.collapsed()&&(q=X(Cr.inline,a.startContainer(),a.startOffset(),G()))})},spaceUp:function(){var a=u(n,d.run);q.each(a);q=g.none()},enterDown:function(){b.getSelection().map(function(a){a.collapsed()&&(k=X(Cr.block,a.startContainer(),a.startOffset(),m.concat()));k=k.orThunk(function(){return X(Cr.inline,a.startContainer(),a.startOffset(),
  G())})})},enterUp:function(){var a=u(n,xb);k.each(a);k=g.none()}}}function aZ(a,b,c,d){var e=a.profile(),f=a.content(),h=a.undo(),l=a.context(),q=a.operations(),g=a.internalevents(),w=H.create({analytics:r(["message"])}),I=Cq(c.customs),G=ZY(e,f,h,q,b,I,g,d);f.events.keydown.bind(function(a){fe.isSpace(a)&&G.spaceDown()});f.events.keyup.bind(function(a){fe.isSpace(a)&&G.spaceUp()});l.events.preLinebreak.bind(function(a){G.enterDown()});l.events.postLinebreak.bind(function(a){G.enterUp()});var m=function(a){return function(){var b=
  a.get();a.setAndCache(!b)}},X=function(a){return function(b){(!0===a.get()?b.select:b.deselect)()}};b=function(a,b,c){return{toggle:!0,value:a,textkey:x.key(b),action:m(c),updateGeneral:X(c),icon:!1,tooltip:rb.get}};return{ui:vb.ui({"capitalisation.general":b("capitalisation","cog.capitalisation",a.profile().capitalisation()),"autocorrect.general":b("autocorrect","cog.autocorrect",a.profile().autocorrect())}),destroy:t,events:w.registry,customMacros:k(I),state:function(){return{customs:I.state()}}}}
  function bZ(){var a=H.create({insert:r(["embed"]),input:r(["raw"])}),b=p.fromTag("span"),c=Vc.textarea("media-embed","media.embed"),d=x.translate("media.placeholder"),e=ib.describe(c.textarea(),d);y.append(c.element(),e);e=T.span();S.hidden(e,!0);n.add(e,B.resolve("media-icon"));m.set(e,"alt",x.translate("media.insert"));var f=Nc(),h=x.translate("media.insert");f.content(Qc(h));n.add(f.element(),B.resolve("media-insert"));sd.makeDefault(f.element());S.button(f.element(),h);m.set(c.textarea(),"placeholder",
  d);OA(f);a.registry.input.bind(function(){var a=fa.get(c.textarea());f.disabled()?""!==a&&(f.enable(),ra.enable(f.element())):""===a&&OA(f)});var l=K.bind(c.textarea(),"input",a.trigger.input);P.append(b,[e,c.element(),f.element()]);var q=function(){var b=fa.get(c.textarea());a.trigger.insert(b);cZ&&Z.blur(c.textarea())};d=[ha.input(c.textarea(),Ba.input({})),ha.button(f.element(),Ba.button({execute:Kb.click}))];f.events.click.bind(function(){q()});return{element:k(b),execute:q,empty:function(){fa.set(c.textarea(),
  "")},keylayouts:k(d),events:a.registry,destroy:function(){l.unbind();f.destroy();F.remove(b)}}}function dZ(a){var b=a.region(),c=a.content(),d=a.smartview(),e=bZ(),f=ha.inlineDialog(e.element(),e.keylayouts(),Ba.inlineDialog({ok:e.execute,cancel:t}));S.dialog(e.element(),x.translate("insert.media"));var h=df.popup(d.uiContainer,d.bounds,b,[],Lg.editorContainer()).initMenu(e.element());ma.add(e.element(),[B.resolve("media-embed-dialog"),B.resolve("inline-dialog")]);f.events.exit.bind(function(){l()});
  var l=function(){h.closed()||(h.close(),e.empty(),c.focus(),f.exit())};a=H.create({insert:Q(["embed"],e.events.insert)});return{element:e.element,showPopup:function(a){h.open();a.show(b,c,d,h,e);f.enter()},isClosed:h.closed,events:a.registry,destroy:function(){l();f.destroy();e.destroy();h.destroy()}}}function eZ(a){a=T.div();n.add(a,B.resolve("media-widget"));var b=T.span();n.add(b,B.resolve("media-widget-field"));var c=p.fromTag(xc.isLarge()?"textarea":"input");n.add(c,B.resolve("media-widget-input"));
  var d=x.translate("media.placeholder");m.set(c,"placeholder",d);m.set(c,"title",d);y.append(b,c);d=Fj([B.resolve("media-widget-insert")],"insert.media");y.append(b,d.element());y.append(a,b);var e=Ej.text(b,c),f=H.create({insert:r(["embed"]),toEditor:r([])}),h=function(){var a=fa.get(c);a=fZ?a.replace(/=\u201c([^\u201d]*)\u201d/g,'="$1"'):a;f.trigger.insert(a);f.trigger.toEditor()};d.events.click.bind(function(){h()});return{element:k(a),addEscape:function(a){y.append(b,a.element())},open:function(){fa.set(c,
  "");Z.focus(c)},close:t,execute:function(){h()},destroy:t,type:k(e),events:f.registry}}function gZ(a){var b=a.content(),c=function(){var c=gd.destroyable(),d=function(){c.clear();b.events.mousedown.unbind(d)};return{open:function(){var e=dZ(a);e.events.insert.bind(function(c){c=c.embed();a.insertFilteredHtmlAtCursor(c);b.cursorIntoView();d()});e.showPopup(zr);b.events.mousedown.bind(d);c.set(e)},destroy:function(){d()}}},d=function(){var c=eZ(a);c.events.insert.bind(function(c){c=c.embed();a.insertFilteredHtmlAtCursor(c);
  b.cursorIntoView()});return xm(a,c)},e=(aa.detect().deviceType.isTouch()?d:c)();return{ui:vb.ui({"media.general":{toggle:!1,value:"media",textkey:x.key("insert.media"),action:e.open,updateGeneral:t,icon:!0,shortcut:!1,hasPopup:!1,hasDialog:!0}}),destroy:function(){e.destroy()}}}function hZ(a,b){var c=p.fromTag("div");n.add(c,B.resolve("mentions-business-card"));var d=a.initMenu(c),e=null,f=function(a,b,e){F.empty(c);y.append(c,e);d.open();a(b,d)};return{showFull:function(a){return function(b,c){clearTimeout(e);
  e=setTimeout(function(){f(a,b,c)},500)}}(b.showUnder),showMini:u(f,b.showAtSide),hide:function(){clearTimeout(e);d.close()},destroy:function(){clearTimeout(e);d.destroy()}}}function iZ(a){var b=g.none();return{fetch:function(b,d){a.fetch(b,function(a,b){a=PA("fetch()",a,b);d(a)})},fetchExtra:function(b,d,e){a.menuExtra(b,d,function(a,b){a=PA("menuExtra()",a,b);e(a)})},menuHover:function(c,d){b=g.some(c.userid);a.menuHover(c,function(a){a=Dr("menuHover() callback",a);b.is(c.userid)&&d(a)})},hover:function(b,
  d){a.hover(b.dom(),function(a){a=Dr("hover() callback",a);d(a)})},menuComplete:function(b){b=a.menuComplete(b);return Dr("menuComplete result",b)},hoverSelector:function(){return a.hoverSelector},isTrigger:function(a){return 64===a}}}function jZ(a){var b=zb.mainmenu(p.fromDom(document),B.resolve("mentions-list"),[]),c=na({}),d=function(a){return a.userid},e=function(a){return a.name},f=function(a,b){L.child(a,".ephox-gopher-item-text").each(function(a){Ha.set(a,b)})},h=function(a){return E(a,function(a){var b=
  zb.item(p.fromDom(document),a.userid,a.name);f(b,a.name);return b})},l=function(a){return Eb(a,function(a,b){var c={};c[b.userid]=b;return ua(a,c)},{})},q=function(a,b){a=h(a);b=E(b,function(a){return zb.item(p.fromDom(document),a.key,a.value)});return a.concat(b)},C=function(a){var b=m.get(a,"data-ephox-gopher-item-value"),d=c.get();return void 0!==d[b]?Er.fetched(d[b].userid,d[b].name,d[b].rawname,d[b],a):U([QA,RA],b)?Er.none(a):Er.extra(b,a)};return{element:k(b),selected:function(){return L.descendant(b,
  ".ephox-gopher-item-selected")},setData:function(d,e){var f=l(d);c.set(ua(c.get(),f));d=0===d.length?[{userid:RA,name:a.get("mentions.lookahead.noresults")}]:d;e=q(d,e);F.empty(b);P.append(b,e)},getInfo:C,getUserId:function(a){return C(a).fold(g.none,g.none,Pb(g.some,d))},setLoading:function(){var c=[{userid:QA,name:a.get("mentions.lookahead.searching")}];c=q(c,[]);F.empty(b);P.append(b,c)},getName:function(a){return C(a).fold(g.none,g.none,Pb(g.some,e))},refind:function(a){a=m.get(a,"data-ephox-gopher-item-value");
  return void 0!==a&&null!==a?L.descendant(b,'[data-ephox-gopher-item-value="'+a+'"]'):g.none()},isOpen:function(){return sc.isVisible(b)}}}function kZ(a,b,c){var d=function(a){ib.speak(ja.body(),a)},e=jZ(c);a.setView(e.element());var f=na(""),h=function(b){q(b.rawData(),b.extra());a.reposition(g.none())},l=function(a){var b=e.selected();a();return b.bind(e.refind)},q=function(b,f){d(c.get("mentions.lookahead.open"));a.updateItems(l,function(){e.setData(b,f)})},k=function(a){return e.isOpen()&&2<=a.length?
  Fr.refetch(a):2<=a.length?Fr.open(a):Fr.nothing()},w=function(a){a.fold(G,h)},I=H.create({accept:r(["information"]),menuHover:r(["element","info"]),none:r([])}),G=function(){a.cancel()};return{setData:q,isOpen:function(){return e.isOpen()},lookup:function(c,d){c=Gb(c,"@")?c.substring(1):c;f.set(c);var h=t;k(c).fold(h,function(a){b.fetch(a,w)},function(c){e.setLoading();a.open(d);b.fetch(c,w)})},close:function(){a.close()},onClick:function(a){e.getInfo(a).fold(function(){I.trigger.none()},function(a,
  c){b.fetchExtra(a,f.get(),w)},function(a,b,d,e,f){ib.speak(ja.body(),c.get("mentions.lookahead.selected",d));I.trigger.accept(e)})},onHover:function(a){d(Vb.get(a));e.getInfo(a).fold(t,t,function(a,b,c,d,e){I.trigger.menuHover(e,d)})},events:I.registry}}function lZ(a,b,c,d){var e=p.fromTag("div");n.add(e,B.resolve("mentions-lookahead-container"));var f=c.initMenu(e),h=na(g.none()),l=H.create({close:r([])}),q=function(){return sc.isVisible(e)};c=function(){h.set(g.none());f.close()};f.events.close.bind(function(){b.close();
  l.trigger.close()});a.events.mousedown.bind(c);return{element:k(e),destroy:function(){h.set(g.none());f.destroy()},setView:function(a){F.empty(e);y.append(e,a)},updateItems:function(a,c){a(c).fold(function(){b.setActiveMenu(e)},function(a){b.select(a)})},reposition:function(a){a.isSome()&&h.set(a);q()&&h.get().each(function(a){d.showUnder(a,f)})},open:function(c){a.body().each(function(a){f.open();d.showUnder(c,f);h.set(g.some(c));b.open([b.sandbox()],a)})},isOpen:q,cancel:function(){h.set(g.none());
  l.trigger.close()},close:c,events:l.registry}}function mZ(a,b,c,d,e,f){var h=lZ(a,b,c,d),l=kZ(h,e,f);a=H.create({menuHover:Q(["element","info"],l.events.menuHover),accept:Q(["information"],l.events.accept),close:Q([],h.events.close)});l.events.none.bind(h.close);return{onHover:l.onHover,onClick:l.onClick,close:function(){l.isOpen()&&l.close();h.isOpen()&&h.cancel()},isOpen:h.isOpen,lookup:function(a,b){h.reposition(g.some(b));l.lookup(a,b)},destroy:function(){h.destroy()},events:a.registry}}function nZ(a,
  b){var c=na([]),d=null,e=null,f=H.create({contentHover:r(["target"]),stopHover:r([]),menuHover:r(["info"])});a.runOrOnLoaded(function(a){c.set([K.bind(a,"mouseover",function(a){k(a)}),K.bind(ja.body(),"mouseover",function(a){L.closest(a.target(),Gr).each(l)}),K.bind(a,"mouseout",function(a){w(a)}),K.bind(ja.body(),"mouseout",function(a){I(a)})])});var h=function(a){clearTimeout(d);clearTimeout(e);d=setTimeout(function(){f.trigger.contentHover(a)},300)},l=function(){clearTimeout(e)},q=function(){clearTimeout(d);
  e=setTimeout(function(){f.trigger.stopHover()},300)},k=function(a){L.closest(a.target(),b).each(function(a){h(a);f.trigger.contentHover(a)})},w=function(a){if(!Db.closest(a.target(),b))return!1;g.from(a.raw().relatedTarget||a.raw().toElement).map(p.fromDom).filter(function(a){return Db.closest(a,b)}).isNone()&&q()},I=function(a){if(!Db.closest(a.target(),Gr))return!1;g.from(a.raw().relatedTarget||a.raw().toElement).map(p.fromDom).filter(function(a){return Db.closest(a,Gr)}).isNone()&&q()};return{destroy:function(){z(c.get(),
  function(a){a.unbind()})},events:f.registry}}function oZ(a){return{get:function(b){var c=a[b];return xa(c)?pZ(c,Array.prototype.slice.call(arguments,1)):x.translate.apply(void 0,arguments)}}}function SA(a){return{show:function(b,c,d,e,f){c=Fh(0,0);b=b.directionAt(a);b=Nm.mainmenu(d,k(a),c,b);d.show(e,b);e.setComponents([a,f.element()])},showWith:function(b,c,d,e,f){b=b.directionAt(a);b=Nm.submenu(d,k(a),b);d.show(e,b);e.setComponents([a,f.element()])}}}function qZ(a,b,c,d){return{showAtSide:function(d,
  f){SA(d).showWith(a,b,c,f,{element:k(f.element())})},showUnder:function(d,f){SA(d).show(a,b,c,f,{element:k(f.element())})}}}function rZ(a,b){var c=oZ(b.aria),d=a.content(),e=a.smartview(),f=a.region(),h=a.operations(),l=iZ(b),q=df.menuSystem(e.uiContainer,k("mentions"),qj.menu({focusActive:!1}));v.set(q.sandbox(),"z-index",String(void 0!==b.zIndex?b.zIndex:1E6));b=df.popup(q.sandbox,e.bounds,f,[],Lg.editorContainer());e=qZ(f,d,e,q.sandbox());var g=mZ(d,q,b,e,l,c),w=hZ(b,e);sZ.configure(a.filter());
  var I=nZ(d,l.hoverSelector());g.events.menuHover.bind(function(a){l.menuHover(a.info(),function(b){b.fold(t,function(b){sc.isVisible(a.element())&&w.showMini(a.element(),b)})})});I.events.contentHover.bind(function(a){l.hover(a.target(),function(b){b.fold(t,function(b){g.close();w.showFull(a.target(),b)})})});I.events.stopHover.bind(function(a){w.hide()});q.events.itemHover.bind(function(a){a=a.item();g.onHover(a);d.backupSelection();Z.focus(a);d.focus()});q.events.itemAction.bind(function(a){g.onClick(a.item())});
  d.events.nodeChanged.bind(function(a){d.getSelection().each(function(b){b.collapsed()&&(Uh.detectOn(b,l).fold(g.close,g.close,t,g.close),a.prev().each(function(a){Hr.validatePrevious(a,b.startContainer())}))})});d.events.keyup.bind(function(a){d.getSelection().each(function(b){b.collapsed()&&(U(m,a.original().raw().which)||Uh.withinIncomplete(b.startContainer()).each(function(a){var b=cd.descendants(a,D.isText);b=E(b,Ya.get).join("");g.lookup(b,a);w.hide()}))})});d.events.keypress.bind(function(a){var b=
  a.original();l.isTrigger(b.raw().which)&&d.getSelection().each(function(a){TA.isValidMention(a.startContainer(),a.startOffset())&&(a=function(){var a=Hr.create();rd.insertAtCursor(d,[a]).each(function(a){d.setSelection(a.element(),a.offset(),a.element(),a.offset())});b.kill();ib.speak(ja.body(),c.get("mentions.initiated"))},Uh.detect(d,l).fold(a,a,t,t))})});var m=Qb([R.ENTER(),R.DOWN(),R.UP()]);a.context().events.preLinebreak.bind(function(a){V(function(b,c){g.isOpen()?a.handler().handle():r()},t)});
  d.events.keydown.bind(function(a){var b=a.original().raw().which;U(R.ESCAPE(),b)?V(function(){r();a.original().kill()},t):U(m,b)&&g.isOpen()&&(q.simulateKey(a.original()),a.original().kill())});var V=function(a,b){Uh.detect(d,l).fold(b,b,a,b)},X=function(a){V(function(b,c){l.menuComplete(a).each(function(a){y.after(c,a);F.remove(c);var b=p.fromText(mb());y.after(a,b);d.setRelativeSelection(la.after(b),la.after(b));n()})},n)},n=function(){w.hide();g.close()},r=function(){V(function(a,b){ib.speak(ja.body(),
  c.get("mentions.lookahead.cancelled"));h.atomic(function(){Hr.cancel(b)});n()},n)};g.events.close.bind(r);g.events.accept.bind(function(a){X(a.information())});return{destroy:function(){g.destroy();w.destroy();I.destroy();q.destroy()}}}function tZ(a){var b=function(a){var b={zh:"zh_cn",pt:"pt_br"};b=void 0===b[a]?a:b[a];b=x.has("parlance."+b)?x.key("parlance."+b):x.raw(b);return uZ(b,a,g.none())},c=E(a.languages,b);return{build:function(d){return d.filter(function(b){return!U(a.languages,b)}).fold(function(){return c},
  function(a){return c.concat([b(a)])})}}}function vZ(a,b,c){var d=a.content(),e=a.undo(),f=tZ(c),h=function(){return d.on(function(a){return Yg.language(a).fold(Da.off,Da.on)}).getOrThunk(Da.unchanged)};return{ui:vb.ui({"parlance.dropdown":k({name:"parlance",textkey:x.key("parlance.set"),menuTextkey:x.key("parlance.menu"),updateDropdown:function(a){var b=h(),c=b.fold(g.none,g.none,g.some);c=f.build(c);a.populate([{label:g.none,items:k(c)}]);b.fold(a.deactivate,t,a.activate);b.fold(a.untick,t,a.tick)},
  action:function(c){var f=function(a){return qd.language(d.isRoot,a,c)};b.lock(function(){$b.cata(a.selections().get(),t,dm.multiple(d,e,f),dm.single(d,e,f));d.getSelection().each(function(a){b.check(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset())})});setTimeout(function(){d.uiChanged()},0)},values:f.build(g.none()),render:g.none(),toggle:!1,describe:function(){return x.key("parlance.set")}})},ca),destroy:t}}function wZ(){var a=p.fromTag("textarea");S.label(a,x.translate("plaincode.dialog.editor"));
  S.textarea(a);return{element:k(a)}}function xZ(a){var b=H.create({execute:r(["html"]),close:r([])}),c=we(a);n.add(c.element(),B.resolve("plaincode-modal"));c.setTitle(x.translate("plaincode.dialog.title"));var d=function(){e();b.trigger.close()},e=function(){c.hide()},f=wZ();c.setContent(f.element());a=sd.okCancel("plaincode");a.events.ok.bind(function(){b.trigger.execute(fa.get(f.element()));d()});a.events.cancel.bind(function(){d()});c.events.close.bind(function(){h.exit();d()});c.setControls(a.element());
  var h=Kb.setup(c,a,[ha.single(f.element(),[ea.rule(ea.is(R.ENTER()[0]),function(a){a.raw().stopPropagation();return g.none()})],g.none())]);return{element:c.element,open:function(){c.show();h.enter()},setHtml:function(a){fa.set(f.element(),a)},destroy:function(){c.destroy();h.destroy()},hide:e,events:b.registry}}function yZ(a){var b=xZ(a),c=function(){d.trigger.close();b.events.close.unbind(c);b.events.execute.unbind(e);b.destroy()},d=H.create({execute:r(["html"]),close:r([])}),e=function(a){d.trigger.execute(a.html())};
  b.events.close.bind(c);b.events.execute.bind(e);return{show:function(){b.open()},setHtml:b.setHtml,events:d.registry}}function zZ(a,b){var c=a.content(),d=a.shortcuts(),e=a.smartview(),f=b.setContent,h=b.getContent;d.events.plaincode.bind(function(){l()});var l=function(){var a=yZ(e.uiContainer());a.events.close.bind(function(){c.toEditing()});a.events.execute.bind(function(a){f(a.html())});c.toReading();a.setHtml(h());a.show()};return{destroy:t}}function AZ(){var a=H.create({grow:r(["x","y"])}),
  b=1,c=1,d=g.none(),e=function(a){return v.getRaw(a,"width").bind(function(a){return je(a,"px")?g.some(parseInt(a,10)):g.none()}).getOrThunk(function(){return Ga.get(a)})};return{setTarget:function(a){d=g.some(a);c=Ga.get(a)/(sa.get(a)+0)},setMultiplier:function(a){b=a},clearTarget:function(){d=g.none()},mutate:function(f,h){d.each(function(d){var l=e(d)+b*f,g=1===l?1:Math.floor(l/c);5<=l&&5<=g&&(Ga.set(d,l),sa.set(d,g));a.trigger.grow(f,h)})},events:a.registry,destroy:t}}function BZ(a){var b=g.none(),
  c=AZ();c.events.grow.bind(function(){f()});var d=sj.transform(c,{layerClass:B.resolve("layer-below-dialog")});n.add(d.element(),B.resolve("resize-eph-block"));var e=CZ.create();e.events.click.bind(function(e){b.each(function(b){c.setMultiplier(e.multiplier());a.body().each(function(a){d.go(A.documentElement(a));var c=function(){d.events.stop.unbind(c);h.trigger.stop(b)};d.events.stop.bind(c)})})});var f=function(){e.clear();b.each(Ir.clean);b=g.none()},h=H.create({stop:r(["target"])});return{showHandles:function(a){var f=
  A.documentElement(a);c.setTarget(a);b=g.some(a);d.on();e.refresh(f,a)},hideHandles:f,handlesShowing:function(){return b.isSome()},events:h.registry,destroy:function(){e.destroy();c.destroy();d.destroy();b=g.none()}}}function DZ(a){var b=a.content(),c=a.undo();a=a.filter();Ir.configure(a);var d=BZ(b),e=function(a){vc.detect(b.getSelection()).each(function(d){c.save();ie.remove(b,d.image());b.domChanged();c.save();a.original().kill()})},f=function(a){vc.detect(b.getSelection()).each(function(c){b.setRelativeSelection(la.before(c.image()),
  la.before(c.image()));a.original().kill()})},h=function(a){vc.detect(b.getSelection()).each(function(c){b.setRelativeSelection(la.after(c.image()),la.after(c.image()));a.original().kill()})},l=function(){vc.detectForEditing(b.getSelection(),b.imageExcludes).fold(function(){d.hideHandles()},function(a){a=a.image();d.showHandles(a);ie.reselect(b,a)})};b.events.loaded.bind(l);b.events.domChanged.bind(l);b.events.paint.bind(l);b.events.nodeChanged.bind(l);b.events.selectionchange.bind(function(a){vc.detect(b.getSelection()).fold(l,
  function(){EZ||d.handlesShowing()||l()})});var q=g.none();b.events.ready.bind(function(a){a=a.api().body();q=g.some(rm.handle(a,function(a){"img"===D.name(a.target())&&ie.select(b,a.target())}))});b.events.mousedown.bind(function(a){a=a.original().target();"img"===D.name(a)&&Ir.disableNativeResize(a)});b.events.keydown.bind(function(a){fe.isDel(a)||fe.isBackspace(a)?e(a):fe.isLeftOrUp(a)?f(a):fe.isRightOrDown(a)&&h(a)});d.events.stop.bind(function(a){a=a.target();FZ?(d.showHandles(a),ie.select(b,
  a)):(d.showHandles(a),ie.reselect(b,a))});return{destroy:function(){d.destroy();q.each(function(a){a.unbind()})}}}function GZ(a,b){var c=a.content(),d=a.filter(),e=a.selections(),f=u(d.filterDom,d.output());c.events.ready.bind(function(a){a=a.api();var b=HZ(a,d),h=function(a,h){$b.cata(e.get(),t,function(c){IZ(c,f).each(function(d){b(a,d.text,d.html,u(h,function(){JZ(c)}))})},function(e,f){KZ(e,f,d).each(function(d){b(a,d.text,d.html,u(h,function(){c.insertHtmlAtCursor("")}))})})};a.events.cut.bind(function(a){h(a.original(),
  xb)});a.events.copy.bind(function(a){h(a.original(),t)})});return{destroy:t}}function LZ(a,b){var c=function(a,b,c){a(c,b);return g.some({element:k(b),cleanup:function(){F.remove(b)},splits:k([])})},d=function(a){return{none:g.none,start:u(c,y.before,a),end:u(c,y.after,a),middle:function(b,d,e){return c(y.after,a,d)}}},e=function(a){var b=function(a){return function(b,c){y.appendAt(b,c,a)}};return{prepend:u(c,y.prepend,a),before:u(c,y.before,a),after:u(c,y.after,a),insertAt:function(d,e){return c(b(e),
  a,d)},append:u(c,y.append,a)}};return{before:{text:d(a),element:{hasPrevious:e(a).insertAt,first:e(a).prepend,empty:e(a).before,otherwise:e(a).append}},after:{text:d(b),element:{hasNext:e(b).insertAt,rightEdge:e(b).append,empty:e(b).after,otherwise:e(b).append}},general:{insertBefore:e(a).before,insertAfter:e(b).after}}}function MZ(a){var b=Om.fromUnsafe(a),c=p.fromTag("span"),d=p.fromTag("span");z([c,d],a.markAsEphemeral);var e=LZ(c,d);return{backup:function(){a.getSelection().each(function(f){f.collapsed()?
  (rd.insertAtCursor(a,[c]),F.unwrap(d),b.begin()):UA.both(e,f.startContainer(),f.startOffset(),f.endContainer(),f.endOffset())})},insert:function(e,h,l){a.setRelativeSelection(la.after(c),ja.inBody(d)?la.before(d):la.after(c));rd.insertAtCursorWith(a,e,h,l).each(function(b){!Db.ancestor(b.element(),"table")||"td"!==D.name(b.element())&&"th"!==D.name(b.element())?a.setRelativeSelection(la.after(b.element()),la.after(b.element())):a.setSelection(b.element(),0,b.element(),0)});b.end();Ng.cursorIntoView(a);
  z([c,d],F.unwrap)},cancel:function(){z([c,d],F.unwrap)}}}function VA(a,b,c){return function(c,e,f){var d=function(a){c.receive(a)},l=function(a,b,c){c=void 0!==c?c:a.type()===Ab.END_ELEMENT_TYPE;return Ab.token(b,c,{})},g={emit:d,emitTokens:function(a){z(a,d)},receive:function(b){a(g,b,l)},document:window.document};b(g);return g}}function Jr(a,b,c){return{pred:a,action:b,label:k(c)}}function WA(a,b,c){var d=XA(a+" :: FALLBACK --- ",c);c=function(c,f,h){qa(b,function(a){return a.pred(f,h)}).fold(k(d),
  function(b){var c=b.label();return void 0===c?b.action:XA(a+" :: "+c,b.action)})(c,f,h)};c.toString=function(){return"Handlers for "+a};return c}function NZ(a,b){var c=mc.state(0,void 0,[],[]),d=function(c){z(c.result(),function(c){c=c(b);a.emit(c)})};return{closeAllLists:function(){var a=YA.closeAllLists(c,0);c=a.state();d(a)},openItem:function(a,b,h){h&&("UL"===h.tag&&OZ[a-1]===h.type&&(h={tag:"UL"}),a=YA.openItem(c,a,b,h),c=a.state(),d(a))},getCurrentListType:function(){return c.type()},getCurrentLevel:function(){return c.level()}}}
  function ZA(a,b){var c=H.create({cancel:r([]),error:r(["message"]),insert:r(["elements","assets","correlated","isInternal"])}),d=function(d,e,l){d=$A.choose(a,b,d);d.capture()&&l();l=E(d.steps(),function(a){return a(e)});$A.run(l,d.input()).get(function(a){var b=a.bundle().isInternal().getOr(!1);db.cata(a.response(),function(a){c.trigger.error(a)},function(a,d){c.trigger.insert(a,aB(d),d,b)},function(){c.trigger.cancel()},function(a,d,e){c.trigger.insert(a,aB(d),d,b);c.trigger.error(e)})})},e=Hd.tap(function(a){Wa.getExact(a.target.ownerDocument.defaultView).each(function(b){n.has(b.start(),
  bB.bin())||(b=PZ.fromEvent(a),cB.willBlock()&&(e.control.block(),a.preventDefault()),d(b,e.control,function(){a.preventDefault()}))})});return{paste:e.instance,pasteCustom:function(a){var b=Hd.tap(t);d(a,b.control,t)},isBlocked:e.control.isBlocked,destroy:t,events:c.registry}}function Qj(){return function(a,b){return La.sync(function(a){var c=function(){La.call(a,{response:b.response(),bundle:b.bundle()})},e=function(c,d){Ce(c,QZ).get(function(c){La.call(a,{response:d(c),bundle:b.bundle()})})};db.cata(b.response(),
  c,function(a,b){e(b,function(b){return db.paste(a,b)})},c,function(a,b,c){e(b,function(b){return db.incomplete(a,b,c)})})})}}function Kr(a){return function(b,c){return La.sync(function(b){var d=function(){La.call(b,{response:c.response(),bundle:c.bundle()})},f=function(a){var d=RZ(a),e=Ce(d,function(a){return a.asset()}),f=E(d,function(a){return a.image()});e.get(function(d){d=tf.updateSources(d,f);La.call(b,{response:db.paste(a,d),bundle:c.bundle()})})},h=function(e,h,g){!1===a.allowLocalImages?
  (h=ka(dB(e),eB),z(h,F.remove),La.call(b,{response:0<h.length?SZ(e):c.response(),bundle:c.bundle()})):0===h.length?f(e):d()};db.cata(c.response(),d,h,d,h)})}}function fB(a){var b=a.translations,c=H.create({insert:r(["elements","correlated"]),incomplete:r(["elements","correlated","message"])});return{events:c.registry,processRtf:function(a,e,f,h){f=uf.images(f);var d=Rj.find(a);TZ.convert(d,f,function(b,d){var f=A.children(a);b=b.concat(e);d?c.trigger.incomplete(f,b,"errors.imageimport.failed"):c.trigger.insert(f,
  b);h()},b)}}}function UZ(a,b){var c=H.create({insert:r(["elements","correlated"]),incomplete:r(["elements","correlated","message"])}),d=fB(b);d.events.incomplete.bind(function(a){c.trigger.incomplete(a.elements(),a.correlated(),a.message())});d.events.insert.bind(function(a){c.trigger.insert(a.elements(),a.correlated())});return{events:c.registry,gordon:function(e,f){var h=function(a){d.processRtf(e,f,a.rtf(),a.hide())},l=function(a){var b=Rj.find(e);z(b,F.remove);c.trigger.incomplete(A.children(e),
  f,a)},g=function(){var a=Rj.find(e);z(a,F.remove);c.trigger.insert(A.children(e),f)},k=function(a){l(a.message())};if(!0===b.allowLocalImages&&!0===b.enableFlashImport){var w=a(b);w.events.response.bind(h);w.events.cancel.bind(g);w.events.failed.bind(k);w.events.error.bind(k);w.open()}else l("errors.local.images.disallowed")}}}function gB(a,b){var c=UZ(a,b),d=na(g.none()),e=function(a){d.get().each(function(b){La.call(b,{response:a,bundle:Xb.nu({})})})};c.events.insert.bind(function(a){e(db.paste(a.elements(),
  a.correlated()))});c.events.incomplete.bind(function(a){e(db.incomplete(a.elements(),a.correlated(),a.message()))});return function(a,b){return La.sync(function(a){var e=function(){La.call(a,{response:b.response(),bundle:b.bundle()})},f=function(b,f,h){d.set(g.some(a));var l=p.fromTag("div");P.append(l,b);Rj.exists(l)?c.gordon(l,f,h):e()};db.cata(b.response(),e,f,e,f)})}}function VZ(a,b){var c=b.translations,d=function(a,b,c){c(g.some(ua(b,{officeStyles:a,htmlStyles:a})))},e=function(b,e){var f=p.fromTag("div");
  n.add(f,td.resolve("styles-dialog-content"));var h=p.fromTag("p"),k=qe.fromHtml(c("cement.dialog.paste.instructions"));P.append(h,k);y.append(f,h);h={text:c("cement.dialog.paste.clean"),tabindex:0,className:td.resolve("clean-styles"),click:function(){w.destroy();d(!1,b,e)}};k={text:c("cement.dialog.paste.merge"),tabindex:1,className:td.resolve("merge-styles"),click:function(){w.destroy();d(!0,b,e)}};var w=a(!0);w.setTitle(c("cement.dialog.paste.title"));w.setContent(f);w.setButtons([h,k]);w.events.close.bind(function(){e(g.none());
  w.destroy()});w.show()};return{get:function(a,c){a=b[a?"officeStyles":"htmlStyles"];"clean"===a?d(!1,b,c):"merge"===a?d(!0,b,c):e(b,c)},destroy:t}}function WZ(a){return{play:function(b,c,d){var e=p.fromTag("div"),f=p.fromTag("iframe");v.setAll(e,{display:"none"});var h=K.bind(f,"load",function(){h.unbind();wz.write(f,b);var a=f.dom().contentWindow.document;if(void 0===a)throw"sandbox iframe load event did not fire correctly";var g=p.fromDom(a);a=a.body;if(void 0===a)throw"sandbox iframe does not have a body";
  a=p.fromDom(a);g=c(g,a);F.remove(e);setTimeout(u(d,g),0)});y.append(e,f);y.append(a,e)}}}function XZ(a,b,c,d,e){return function(f,h){var l=Wc.asEvent(f).getOrDie("Must pass through event type").nativeEvent(),g=e(),k=h.response();return La.sync(function(e){var f=a(c);f.events.after.bind(function(a){a=a.container();if(Lr.browser.isSafari()&&Db.descendant(a,'img[src^="webkit-fake-url"]'))a=Lr.deviceType.isWebView()?"webview.imagepaste":"safari.imagepaste",La.call(e,{response:db.error(a),bundle:Xb.nu({})});
  else{b(a);n.add(a,hB.binStyle());var c=YZ.isWord(Lr,a),f=A.children(a),h=d.findClipboardTags(f).isSome();f=ZZ(f);La.call(e,{response:k,bundle:Xb.nu({isWord:c,isGoogleDocs:f,isInternal:h,proxyBin:a,backgroundAssets:g})})}});g.convert(l);f.run()})}}function $Z(a,b){var c=fB(a),d=na(g.none()),e=function(a){d.get().each(function(b){La.call(b,{response:a,bundle:Xb.nu({})})})};c.events.insert.bind(function(a){e(db.paste(a.elements(),a.correlated()))});c.events.incomplete.bind(function(a){e(db.incomplete(a.elements(),
  a.correlated(),a.message()))});return function(f,h){var l=Wc.asWord(f).getOrDie("Word input required for rtf data"),q=function(a){return La.sync(function(b){var f=function(){La.call(b,{response:h.response(),bundle:h.bundle()})},l=function(f,h){d.set(g.some(b));var l=p.fromTag("div");P.append(l,f);a.fold(function(){var a=function(){z(c,F.remove);var a=A.children(l);e(db.incomplete(a,h,"errors.local.images.disallowed"))},b=function(){var a=A.children(l);e(db.paste(a,h))},c=Rj.find(l);return 0<c.length?
  a():b()},function(a){c.processRtf(l,h,a,t)})};db.cata(h.response(),f,l,f,l)})};return Pm.match(l.rtf(),{getFromFlash:function(a){return b(f,h)},disabled:function(){return q(g.none())},fromClipboard:function(b){return q(!0===a.allowLocalImages?g.some(b.rtf()):g.none())}})}}function a_(a,b,c){var d=function(a){return ob(b,function(b){return qb(a[b])})},e=!0,f=Mr(function(){var b=a.dom();qb(b.PercentLoaded)&&100===b.PercentLoaded()&&d(b)&&(h(),c())},500),h=function(){e&&(Vh(f),e=!1)};return{stop:h}}
  function b_(a){var b=H.create({response:r(["rtf"]),spin:r([]),cancel:r([]),error:r(["message"]),reset:r([]),hide:r([]),failed:r(["message"])}),c=!1,d=p.fromTag("div");n.add(d,td.resolve("flashbin-target"));var e=c_.responsive();e.events.crashed.bind(function(){b.trigger.failed("flash.crashed")});e.events.timeout.bind(function(){b.trigger.failed("flash.crashed")});var f=function(){m.stop();if(!c){c=!0;try{var a=w.dom();Ma(k,function(b,c){var d=a[c];if(void 0===d)throw'Flash object does not have the method "'+
  c+'"';d.call(a,b)});b.trigger.reset();rr(X);n.remove(d,td.resolve("flash-activate"));I();V()}catch(Dh){ud.log("Flash dialog - Error during load: ",Dh)}}},h=Yf.permanent(f),l=function(){return!ja.inBody(w)},g=function(){return!w.dom().SetVariable},k={setSpinCallback:Yf.permanent(function(){e.start(1E3,10,l,g);b.trigger.spin()}),setPasteCallback:Yf.permanent(function(a){e.stop();Sg(function(){""===a?b.trigger.error("flash.crashed"):b.trigger.response(unescape(a))},0)}),setEscapeCallback:Yf.permanent(b.trigger.cancel),
  setErrorCallback:Yf.permanent(function(a){e.stop();b.trigger.error(a)}),setStartPasteCallback:Yf.permanent(t)},w=function(){var b=a.replace(/^https?:\/\//,"//"),c='    <param name="allowscriptaccess" value="always">    <param name="wmode" value="opaque">    <param name="FlashVars" value="onLoad='+h+'">';if(Nr.browser.isIE()&&10===Nr.browser.version.major){var d=Fa("flash-bin");return p.fromHtml('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="'+d+'"><param name="movie" value="'+b+
  '">'+c+"</object>")}return p.fromHtml('<object type="application/x-shockwave-flash" data="'+b+'">'+c+"</object>")}(),I=function(){v.setAll(w,{width:"2px",height:"2px"})};I();var m=a_(w,cb(k),f);y.append(d,w);var V=function(){Nr.browser.isFirefox()&&Zg.getSelection().removeAllRanges();Z.focus(w)},X=null,u=function(){n.add(d,td.resolve("flash-activate"));v.remove(w,"height");v.remove(w,"width");b.trigger.hide()},x=function(){v.set(d,"display","none");d_.each(function(a){z(a,function(a){a.unbind()})})};
  return{focus:V,element:function(){return d},activate:function(){X=Sg(u,3E3);b.trigger.spin();v.set(d,"display","block");V()},deactivate:x,destroy:function(){x();z(Ze(k),function(a){Yf.unregister(a)});Yf.unregister(h);m.stop()},events:b.registry}}function e_(a,b,c){var d=p.fromTag("div"),e="flashbin-wrapper-"+(f_.os.isOSX()?"cmd":"ctrl");n.add(d,td.resolve(e));try{var f=void 0!==g_.plugins["Shockwave Flash"]}catch(h){f=!1}a=(f?h_:i_)(d,a,b,c.translations);return{element:k(d),reset:a.reset}}function j_(a,
  b){var c=b.translations,d=H.create({response:r(["rtf","hide"]),cancel:r([]),error:r(["message"]),failed:r(["message"])});return{open:function(){var e=b_(b.swf);e.deactivate();var f=p.fromDom(Zg),h=K.bind(f,"mouseup",e.focus),l=function(){w()};f=function(){w();d.trigger.cancel()};e.events.cancel.bind(f);e.events.response.bind(function(a){d.trigger.response(a.rtf(),l)});e.events.error.bind(function(a){w();d.trigger.error(a.message())});e.events.failed.bind(function(a){w();d.trigger.failed(a.message())});
  var g=a();g.setTitle(c("cement.dialog.flash.title"));var k=e_(e,g.reflow,b);k.reset();g.setContent(k.element());g.events.close.bind(f);g.show();e.activate();var w=function(){h.unbind();e.destroy();g.destroy()}},events:d.registry}}function Or(a,b,c,d){var e=N.eq(a,c)&&b===d;return{startContainer:k(a),startOffset:k(b),endContainer:k(c),endOffset:k(d),collapsed:k(e)}}function k_(a){var b=p.fromTag("br"),c=g.none();return{cleanup:function(){F.remove(b)},toOn:function(b,e){var d=A.owner(e).dom().defaultView;
  c.each(function(c){var e=A.childNodesCount(b),f=N.eq(b,c.startContainer())&&e<c.startOffset()?e:c.startOffset;e=N.eq(b,c.endContainer())&&e<c.endOffset()?e:c.endOffset;c=Or(c.startContainer(),f,c.endContainer(),e);a.set(d,c)})},toOff:function(d,e){d=A.owner(e).dom().defaultView;y.append(e,b);c=a.get(d,Or);a.set(d,Or(b,0,b,0))}}}function l_(a,b){var c=p.fromTag("div");m.setAll(c,b);m.setAll(c,{contenteditable:"true","aria-hidden":"true"});v.setAll(c,{position:"fixed",top:"0px",width:"100px",height:"100px",
  overflow:"hidden",opacity:"0"});ma.add(c,[iB,jB]);var d=function(a){return n.has(a,jB)};return{attach:function(a){F.empty(c);v.set(c,"left",m_(a));y.append(a,c)},focus:function(){L.ancestor(c,"body").each(function(b){a.toOff(b,c)})},contents:function(){n_.consolidate(c,d);var a=O("elements","html","container"),b=A.children(c),h=Ha.get(c);return a(b,h,c)},container:function(){return c},detach:function(){F.remove(c)}}}function o_(a,b,c){var d=l_(a,c),e=function(){a.cleanup();var b=d.contents();d.detach();
  h.trigger.after(b.elements(),b.html(),d.container())},f=Hd.tap(function(){h.trigger.before();d.attach(b);d.focus();cB.run(A.owner(b),f,e)}),h=H.create({before:r([]),after:r(["elements","html","container"])});c=t;return{instance:k(function(){f.instance()}),destroy:c,events:h.registry}}function p_(a){return function(b){var c=H.create({after:r(["container"])}),d=k_(q_),e=o_(d,b,a);e.events.after.bind(function(a){d.toOn(b,a.container());c.trigger.after(a.container())});return{run:function(){e.instance()()},
  events:c.registry}}}function r_(){return ZA([Zf.text()],Zf.none())}function s_(a,b){return function(c){var d=H.create({close:r([])}),e=we(a);e.events.close.bind(function(){d.trigger.close()});n.add(e.element(),B.resolve("external-dialog"));c&&n.add(e.element(),B.resolve("dialog-vertical-controls"));var f=p.fromTag("div"),h=na([]),l=function(a){var b=Nc();if(void 0===a.text)throw"dialog button did not specify text";b.content(Qc(a.text));S.button(b.element(),a.text);void 0!==a.tabindex&&m.set(b.element(),
  "tabindex",a.tabindex);void 0!==a.className&&n.add(b.element(),a.className);void 0!==a.click&&b.events.click.bind(a.click);n.add(b.element(),B.resolve("dialog-button"));return b};return{element:e.element,events:d.registry,setTitle:e.setTitle,setContent:e.setContent,setButtons:function(a){F.empty(f);a=E(a,l);P.append(f,E(a,function(a){return a.element()}));h.set(a);e.setControls(f)},reflow:t,show:function(){b.hideInlineSelection();e.show();var a=E(h.get(),function(a){return ha.button(a.element(),Ba.button({execute:Kb.click}))}),
  c=ha.multipleAll(e.element(),a);c.events.exit.bind(function(){d.trigger.close()});setTimeout(function(){c.enter()},0)},destroy:function(){z(h.get(),function(a){a.destroy()});h.set([]);e.destroy()}}}}function t_(a,b,c){var d={"errors.imageimport.unsupported":"errors.images.import.unsupported","errors.imageimport.invalid":"errors.images.import.invalid"};return{baseUrl:c.baseUrl,enableFlashImport:c.enableFlashImport,swf:c.swf,officeStyles:c.officeStyles,htmlStyles:c.htmlStyles,translations:function(b){var c=
  Array.prototype.slice.call(arguments,1);return a.translate.apply(void 0,[void 0!==d[b]?d[b]:b].concat(c))},allowLocalImages:c.allowLocalImages,intraFlag:b}}function u_(a,b,c,d){var e=a.filter(),f=a.content(),h=a.undo(),l=a.smartview(),q=a.region(),k=a.internalevents(),w=!0===d.forceText?r_:v_(l,e,d,f),I=g.none(),G=H.create({analytics:r(["message"])}),n=function(a){var b=U(["flash.clipboard.no.rtf","safari.imagepaste"],a.message())?"info":"error";X(a.message(),b)},X=function(b,c){mf.getOrLog(b,[]).each(function(b){b=
  mj(b,c);a.ui().displayBanner(b)});t()},t=function(){Uc.unblock();f.focus()};e.add(e.history(),hB.binStyle(),Ta.remove);e.addSelector(e.history(),"[data-ephox-polish-cement-inserted]",Ta.removeAttr("data-ephox-polish-cement-inserted"));f.events.ready.bind(function(a){var d=Pr.get(f,l,a.api().doc()),C=w_.rules(f,q,d),V=MZ(f),r=a.api(),u=w(r.body());I=g.some(u);r.events.paste.bind(function(a){r.getSelection().filter(function(a){return ob(Sj.ignoreSelectors(),function(b){return!1===Db.closest(a.startContainer(),
  b,f.isRoot)})}).each(function(b){u.isBlocked()||(V.backup(),Uc.block());u.paste(a.original().raw())})});u.events.cancel.bind(function(){t();V.cancel()});var v=Dj.processResults(X);u.events.error.bind(n);u.events.insert.bind(function(a){c.correlated(a.correlated()).bind(lA.maybeDoRotate).map(v).get(function(c){t();h.save();var d=p.fromTag("div");P.append(d,a.elements());e.filterDom(e.input(),d);d=A.children(d);z(d,function(a){D.isElement(a)&&m.set(a,"data-ephox-polish-cement-inserted",!0)});V.insert(d,
  [C.collapsed()],[C.ranged()]);f.body().each(function(a){a=Y.descendants(a,"[data-ephox-polish-cement-inserted]");z(a,function(a){m.remove(a,"data-ephox-polish-cement-inserted")});k.input(a)});f.domChanged();G.trigger.analytics("paste_action");b.pasteUpload();b.uploadAssets(c)})})});return{destroy:function(){I.each(function(a){a.destroy()})},events:G.registry}}function x_(a,b,c,d){var e=GZ(a,d.copy),f=u_(a,b,c,d.paste);return{destroy:function(){e.destroy();f.destroy()}}}function y_(){var a={latin:[{start:"A",
  finish:"Z"},{start:"a",finish:"z"},{start:"\u00c0",finish:"\u00ff"}],punctuation:[{start:"!",finish:"/"},{start:":",finish:"@"},{start:"[",finish:"`"},{start:"{",finish:"~"},{start:"\u00a1",finish:"\u00bf"},{start:"\u2010",finish:"\u2027"},{start:"\u2030",finish:"\u205e"}],currency:[$f("$"),{start:"\u00a2",finish:"\u00a5"},{start:"\u20a0",finish:"\u20bd"},$f("\u5186"),$f("\u5143"),$f("\u5713"),$f("\u5706")],"extended-latin-a":[{start:"\u0100",finish:"\u017f"}],"extended-latin-b":[{start:"\u0180",
  finish:"\u024f"}],arrows:[{start:"\u2190",finish:"\u21ff"},$f("\u2794"),{start:"\u2798",finish:"\u27af"},{start:"\u27b1",finish:"\u27be"}],mathematical:[{start:"\u2795",finish:"\u2797"},{start:"\u2200",finish:"\u22ff"}],miscellaneous:[{start:"\u2701",finish:"\u275e"},{start:"\u2761",finish:"\u2793"},$f("\u27b0"),$f("\u27bf")]},b={};Ma(a,function(a,d,e){b[d]=ia(a,z_)});return b}function A_(a){var b=H.create({insert:r(["string"]),close:r([])}),c=we(a);a=y_();a=B_.generateItems(a);var d=Vc.input("specialchar",
  "specialchar.selects"),e=vA(nr.left(),a,B.resolve("specialchars"));n.add(e.body(),B.resolve("specialchar-body"));n.add(c.element(),B.resolve("specialchar-dialog"));z(A.children(e.element()),Uc.register);var f=K.bind(c.element(),"click",function(a){a=a.target();L.closest(a,"[data-ephox-polish-special-char]").each(function(a){Z.focus(a);a=m.get(a,"data-ephox-polish-special-char");var b=d.input(),c=fa.get(b);fa.set(b,c+a)})}),h=C_.controls("specialchar");c.setTitle(x.translate("specialchar.dialog"));
  c.setContent(e.element());c.setControls(h.element());y.after(e.element(),d.element());a=function(){c.hide();fa.set(d.input(),"");b.trigger.close()};var l=D_(e),g=E_(e),k=Kb.setup(c,h,[l,g,ha.input(d.input(),Ba.input({}))]);e.events.setActive.bind(function(a){l.clickFocus(a.item().element())});c.events.close.bind(function(){k.exit();b.trigger.close()});h.events.cancel.bind(a);c.events.close.bind(a);h.events.insert.bind(function(){b.trigger.insert(fa.get(d.input()))});return{element:c.element(),events:b.registry,
  open:function(){c.show();k.enter()},destroy:function(){f.unbind();c.destroy();e.destroy();h.destroy();k.destroy()},close:function(){c.hide();fa.set(d.input(),"")}}}function F_(a,b){var c=A_(b),d=H.create({insert:Q(["string"],c.events.insert),close:r([])}),e=function(){d.trigger.close();c.close()};c.events.close.bind(e);return{show:function(){a.toReading();c.open()},close:e,destroy:function(){c.events.close.unbind(e);c.destroy()},events:d.registry}}function G_(a){var b=a.content(),c=a.smartview(),
  d=function(a){a=p.fromText(a.string());rd.insertAtCursor(b,[a]).each(function(a){a=la.after(a.element());b.setRelativeSelection(a,a);b.focus();b.toEditing()})},e=gd.destroyable(),f=function(){e.clear()};return{ui:vb.ui({"specialchar.general":{toggle:!1,value:"specialchar",textkey:x.key("specialchar.open"),action:function(){var h=F_(b,c.uiContainer());e.set(h);h.events.close.bind(function(){b.focus();f()});h.events.insert.bind(function(a){d(a);f()});a.content().hideInlineSelection();h.show()},updateGeneral:t,
  icon:!0,shortcut:!1,hasPopup:!1,hasDialog:!0}}),destroy:f}}function H_(a,b,c,d,e){var f=a.content(),h=a.profile().nativeSpelling(),l=function(a){m.set(a,"spellcheck","false")},q=function(a){m.set(a,"spellcheck","true")};f.runOrOnLoaded(function(){var a=h.get()?q:l;f.body().each(a)});a=vb.ui({"spelling.general":{toggle:!0,value:"spellcheck",textkey:x.key("cog.spellcheck"),action:function(){var a=!h.get();h.setAndCache(a);a=a?q:l;f.body().each(a)},updateGeneral:function(a){(h.get()?a.select:a.deselect)()},
  icon:!0,tooltip:rb.get}});return Dq({events:Gd(["analytics"]),init:t,hasDropdown:k(!1),hasAutocorrect:k(!1),check:t,scanView:t,lock:xb,situation:Ig.noSituation,handle:t,assign:t,destroy:function(){f.body().each(function(a){m.remove(a,"spellcheck")})},state:k({}),ui:a,lookup:k(g.none()),name:k("spelling-disabled")})}function I_(a,b,c){var d=H.create({change:r(["language"])});a=c?J_(a,d):K_(a,b,d);return{ui:vb.ui(a),hasDropdown:k(c),events:d.registry}}function L_(){var a=[],b=!1,c=function(){b=!0;g.from(a.shift()).fold(function(){b=
  !1},function(a){a.f()(a.area(),c)})};return{enqueue:function(d,e){a.push(M_(d,e));b||c()},destroy:function(){a=[]}}}function N_(a,b){var c=na(a),d=L_(),e=function(a,d,e,g){e=Qm.cata(e,function(a){return ja.inBody(a)?Rm.single(a,c.get(),b):Rm.empty()},function(a,d,e,f){return ja.inBody(a)&&ja.inBody(e)?Rm.range(a,d,e,f,c.get(),b):Rm.empty()});d(a,e,c.get(),g)};return{run:function(a,b,c){e(a,b,c,ca)},setLang:c.set,schedule:function(a,b,c,g){d.enqueue(c,function(c,d){void 0!==g&&g()?d():e(a,b,c,d)})},
  destroy:function(){d.destroy()}}}function O_(a,b){var c=function(b){return E(b,function(b){var c=kB.getInCache(a,b.lang(),b.words());return{zone:k(b),words:k(c),lang:b.lang}})},d=function(a,b,c){z(b,function(b){P_.highlight(a,b.zone(),b.words(),c)})};return{local:function(a,b,h,l){b=b.zones();b=c(b);d(a,b,h);l()},remote:function(c,f,h,l){f=f.zones();Q_.scan(a,b,f).get(function(a){d(c,a,h);l()})},destroy:t}}function R_(a,b,c){var d=lB.initCaches(c),e=km.post("ephox.spelling.service.many",S_.many(),
  a,b);return{checkMany:function(a,b,c){c=wj.now();return lB.execute(e,d,a,b,c)},dumpCache:function(){return eb(d,function(a){return a.dump()})}}}function T_(a,b,c,d,e){var f=U_.spelling(b),h=R_(f+"correction",a.newHeaders(),e),l=H.create({failed:r(["resource"])}),g=Ae.get(f+"autocorrect?language="+c,Be.json(),he.xhr(),a.newHeaders()),C=lf.nu(function(a){g.get(function(b){b.fold(function(){a(b)},function(b){h.checkMany(c,["startup"],!0).get(a)})})});C.get(function(a){a.fold(function(a){console.error("Unable to communicate with the spelling service:",
  vr.consoleMessage(a));l.trigger.failed(b)},t)});return{correction:function(a,b,e,f){C.get(function(l){l.fold(f,function(){h.checkMany(d?b:c,a.words).get(function(a){a.fold(function(a){console.error("Error response from the spelling service:",vr.consoleMessage(a));f(a)},function(a){e(a)})})})})},autocorrect:k(g),events:l.registry,state:function(){return h.dumpCache()}}}function V_(a){var b=a.content(),c=a.profile(),d=T_(a.communication(),a.url(),a.language(),a.multilingual(),a.fromServiceState()),
  e=a.autocorrectOn()?mB.active(d):mB.inactive(),f=H.create({failed:r(["resource"])}),h=function(a){f.trigger.failed(a.resource())};d.events.failed.bind(h);var l=N_(a.language(),a.viewable().viewport()),g=O_(a.cache(),d),k=function(a){b.body().each(function(b){om.filterDom(b,[gr("."+a,Ta.unwrap)])})},w=function(){return!vf.isOn(c.spelling().get())},I=function(){k("ephox-cram-annotation-wrap")};return{run:function(a,b){var d=c.spelling().get();vf.isOn(d)&&(l.setLang(d),l.run(a,g.local,b),l.schedule(a,
  g.remote,b,w))},refresh:function(){var a=c.spelling().get();vf.isOn(a)||I()},clear:I,lookup:e.lookup,destroy:function(){d.events.failed.unbind(h);l.destroy();g.destroy()},state:d.state,events:f.registry}}function W_(){var a=H.create({incorrect:r(["substitution"])}),b=g.none(),c={};c[Ee.spelling()]=function(c){b.each(function(b){b=Qr.substitute(b,m.get(c,Ee.value()));a.trigger.incorrect(b)})};return{assign:function(a){b=a},run:function(a){var b=m.get(a,Ee.type());b=c[b];void 0!==b&&b(a)},events:a.registry}}
  function X_(a,b,c){var d=W_();d.events.incorrect.bind(function(c){b.save();a.focus();a.domChanged();c.substitution().each(function(b){nB.selectEnd(a,b)})});var e=u(function(a,b,c,d){return a.marker(d).bind(a.detail).bind(function(a){return c(a).map(function(a){return E(a,function(a){var c={};c[Ee.type()]=b;c[Ee.value()]=a;return Y_(a,a,c)})})})},Qr,Ee.spelling(),function(a){return c.suggestions(a.lang(),a.word())});return{assign:d.assign,handle:function(a){d.run(a)},situation:function(a){a=e(a).getOr([]);
  return Z_.generate(a,4)},destroy:t}}function $_(a,b){var c=H.create({lookup:r(["element"])}),d=function(){a.getSelection().each(function(a){c.trigger.lookup(a.startContainer())})};a.events.keyup.bind(function(a){fe.isSpace(a)&&d()});a.events.nodeChanged.bind(function(a){a.prev().each(c.trigger.lookup)});return{events:c.registry,destroy:t}}function a0(a,b,c,d,e,f,h,l,g){var q=X_(b,e,l),k=$_(b,c),I=function(a){b.getSelection().each(function(b){var c=kb.toLeaf(b.endContainer(),b.endOffset()),e=kb.toLeaf(b.startContainer(),
  b.startOffset()),f;(f=b.collapsed())||(f=!oB.isIE())||(f=hd.after(b.endContainer(),b.endOffset(),b.startContainer(),b.startOffset()));b=f&&!oB.isFirefox()?Rc(e.element(),e.offset(),c.element(),c.offset()):b;return(f?d.lightweightWith:xb)(a,b)})},m=Hd.tap(function(a){a=a.element();"body"!==D.name(a)&&(a=Qm.single(a),n(a))});k.events.lookup.bind(function(a){m.instance(a)});var n=function(a){g.run(I,a)};return{destroy:function(){q.destroy();k.destroy()},scan:n,situation:q.situation,lock:function(a){var b=
  m.control.isBlocked();m.control.block();a();b||m.control.unblock()},assign:q.assign,handle:q.handle}}function b0(a,b,c,d,e){e=b.language.getOr(e);var f=a.communication(),h=a.profile(),l=a.filter(),q=a.content(),C=a.operations(),w=a.undo(),I=a.smartview(),G=a.shortcuts(),n=a.context(),X=a.viewablearea();Rr.configure(l);a.profile().spelling().set(e);var p=c0(b.words),u=V_(d0({communication:f,profile:h,content:q,undo:w,viewable:X,cache:p,url:c.url,autocorrectOn:c.autocorrect,language:d,fromServiceState:b.service,
  multilingual:c.multilingual})),v=g.none();b=H.create({analytics:r(["message"])});u.events.failed.bind(function(b){b=mf.get("error.code.spelling.not.found",[b.resource()]);b=mj(b);a.ui().displayBanner(b)});q.events.ready.bind(function(a){q.body().each(function(a){m.set(a,"spellcheck",!1)});a=a.api().doc();a=a0(a,q,n,C,w,G,I,p,u);u.refresh();v=g.some(a)});d=I_(a,d,c.menu);d.events.change.bind(function(a){(vf.isOn(a.language())?x:u.clear)();q.uiChanged();q.domChanged()});var y=function(a){z(a,function(a){a=
  Qm.single(a);B(a)})},x=c.scanView?function(){var a=X.sections();y(a)}:u.clear;c.scanView&&X.events.onChange.bind(x);var B=function(a){v.each(function(b){b.scan(a)})};return Dq({events:b.registry,destroy:function(){q.body().each(function(a){m.remove(a,"spellcheck")});v.each(function(a){a.destroy()});p.destroy();u.destroy()},state:function(){return{words:p.state(),service:u.state(),language:g.some(a.profile().spelling().get())}},init:t,hasDropdown:d.hasDropdown,hasAutocorrect:k(c.autocorrect),ui:d.ui,
  check:function(a,b,c,d){a=Rr.isWrap(a)?kb.toLeaf(a,b):W.point(a,b);c=Rr.isWrap(c)?kb.toLeaf(c,d):W.point(c,d);c=Qm.range(a.element(),a.offset(),c.element(),c.offset());B(c)},scanView:x,situation:function(a){var b={primary:k([]),secondary:k([]),submenus:k({})};return v.fold(k(b),function(b){return b.situation(a)})},lock:function(a){return v.fold(function(){return a()},function(b){return b.lock(a)})},assign:function(a){v.each(function(b){b.assign(a.bind(A.firstChild).or(a))})},handle:function(a){v.each(function(b){b.handle(a)})},
  lookup:u.lookup,name:k("spelling")})}function e0(a,b,c,d,e){return(!0===c.service?b0:H_)(a,b,c,d,e)}function pB(a){var b=$d(a);n.add(b.element(),B.resolve("choice-button"));var c=T.span();m.set(b.element(),"title",x.translate("table."+a));m.set(b.element(),"tabindex","-1");S.button(b.element(),x.translate("table."+a),!1);var d=ib.describe(b.element(),x.translate("aria.table.headerdescription"));y.append(b.element(),d);b.events.click.bind(function(){Z.focus(b.element());ra.pressed(b)});ma.add(c,[B.resolve(a),
  "ephox-pastry-icon-content","ephox-polish-icon"]);b.content({element:k(c)});return b}function f0(a,b){var c=!1,d=function(a,b,c){var d=c.full();d.row()===b.rows()&&d.column()===b.columns()||a.setSize(d.row(),d.column());a=a.setSelection(c.selection().row(),c.selection().column());Z.focus(a)};return{on:function(){c=!0},off:function(){c=!1},mousemove:function(e,f,h,l){if(c){var g=Ga.get(e.element());var k=sa.get(e.element());g=Na.dimensions(g,k);k=bb.absolute(e.element());k=Na.coords(k.left(),k.top());
  h=Na.coords(h,l);h=a.pickerCell(k,g,f,h);h=qB.resize(h,b);d(e,f,h)}},manual:function(a,f,h,l){c&&(h=qB.grow(f,h,l,b),d(a,f,h))}}}function g0(a,b,c){var d=H.create({select:r(["rows","cols","rowHeaders","columnHeaders"])}),e=p.fromTag("table");S.presentation(e);S.hidden(e,!0);n.add(e,$g.table());var f=p.fromTag("tbody");y.append(e,f);var h=0,l=0,g=function(a,b){h=b;l=a;C()},C=function(){F.empty(f);var a=c.ids();ke.repeat(l,function(b){var c=p.fromTag("tr");n.add(c,$g.row());var d=ke.repeat(h,function(c){var d=
  p.fromTag("td");n.add(d,vd.resolve("cell-"+c+"-"+b));n.add(d,$g.cell());var e=p.fromTag("button");m.set(e,"type","button");m.set(e,"aria-labelledby",a[b][c]);n.add(e,$g.button());y.append(d,e);return d});P.append(c,d);y.append(f,c)})},w=function(a,b){var c=ag.cells(e);z(c,function(a){n.remove(a,vd.resolve("picker-selected"))});c=ag.rows(e).slice(0,a);z(c,function(a,c){a=ag.cells(a).slice(0,b);z(a,function(a,b){var d=ag.grid(e,"data-picker-header-row","data-picker-header-col");b=c<d.rows()||b<d.columns()?
  [vd.resolve("picker-selected"),vd.resolve("picker-header")]:[vd.resolve("picker-selected")];ma.add(a,b)})});m.set(e,"data-picker-col",b-1);m.set(e,"data-picker-row",a-1);a=ag.cells(c[c.length-1]).slice(0,b);return ag.button(a[a.length-1])},I=function(){var a=parseInt(m.get(e,"data-picker-col"),10)+1,b=parseInt(m.get(e,"data-picker-row"),10)+1;return Na.grid(b,a)},G={element:k(e),setSelection:w,setSize:g},V=f0(a,b),X=K.bind(e,"mousemove",function(a){V.mousemove(G,Na.grid(l,h),a.raw().pageX,a.raw().pageY)}),
  t=function(a,b){V.manual(G,I(),a,b)},v=tm.realClick.bind(e,function(a){x();a.raw().preventDefault()}),x=function(){var a=ag.grid(e,"data-picker-row","data-picker-col"),b=ag.grid(e,"data-picker-header-row","data-picker-header-col");d.trigger.select(a.rows()+1,a.columns()+1,b.rows(),b.columns())};return{element:function(){return e},destroy:function(){v.unbind();X.unbind();F.remove(e)},setSize:g,setHeaders:function(a,b){m.set(e,"data-picker-header-row",a);m.set(e,"data-picker-header-col",b)},setSelection:w,
  on:V.on,off:V.off,reset:function(){g(b.minRows,b.minCols);var a=w(1,1);Z.focus(a)},refresh:function(){var a=I();C();return w(a.rows(),a.columns())},events:d.registry,sendLeft:u(t,a.isRtl()?1:-1,0),sendRight:u(t,a.isRtl()?-1:1,0),sendUp:u(t,0,-1),sendDown:u(t,0,1),sendExecute:x}}function h0(a,b){var c=Vg.createHelp(b.maxRows,b.maxCols,{row:function(a){return x.translate("table.picker.rows",a)},col:function(a){return x.translate("table.picker.cols",a)}}),d=g0(a,b,c);S.label(d.element(),x.translate("table.picker.label"));
  b=ib.describe(d.element(),x.translate("table.picker.describepicker"));var e=p.fromTag("div");m.set(e,"tabIndex","-1");S.group(e);ma.add(e,[B.resolve("insert-table"),B.resolve("toolbar-menu")]);a=p.fromTag("div");n.add(a,B.resolve("table-controls"));S.toolbarGroup(a,x.translate("table.picker.header"));var f=pB("row-header"),h=pB("column-header");P.append(a,[f.element(),h.element()]);P.append(e,[a,d.element(),b,c.help()]);var l=function(){d.setHeaders(f.selected()?1:0,h.selected()?1:0);var a=Z.active(),
  b=d.refresh();a.each(function(a){Z.hasFocus(a)||Z.focus(b)})};c=function(a,b){return function(){b();return g.some(!0)}};c=ha.single(d.element(),[ea.basic(R.LEFT()[0],c("left",d.sendLeft)),ea.basic(R.RIGHT()[0],c("right",d.sendRight)),ea.basic(R.UP()[0],c("up",d.sendUp)),ea.basic(R.DOWN()[0],c("down",d.sendDown)),ea.rule(ea.inSet(R.SPACE().concat(R.ENTER())),c("execute",d.sendExecute))],g.none());c.events.enter.bind(function(){Z.focus(d.element())});var q=ha.flow(a,{item:k(".ephox-pastry-statebutton")},
  Ba.flow({trigger:function(a){return L.descendant(a,".ephox-pastry-button").map(function(a){a.dom().click();return a})}})),C=ha.multiple(e,[c,q]);f.events.click.bind(function(){q.clickFocus(f.element());l()});h.events.click.bind(function(){q.clickFocus(h.element());l()});c=H.create({select:Q(["rows","cols","rowHeaders","columnHeaders"],d.events.select),exit:Q([],C.events.exit)});return{element:function(){return e},destroy:function(){C.destroy();f.destroy();h.destroy();d.destroy()},setSize:d.setSize,
  setSelection:d.setSelection,on:function(){d.on();C.enter()},off:function(){d.off();C.isFocused()&&C.exit()},reset:function(){d.setHeaders(0,0);f.deselect();ra.release(f.element());h.deselect();ra.release(h.element());d.reset()},events:c.registry}}function i0(a,b){var c=H.create({enabled:r(["enabled"]),select:r(["rows","cols","rowHeaders","columnHeaders"]),insert:r(["table"]),done:r([]),abort:r([])});b=ua({minCols:7,maxCols:10,minRows:4,maxRows:10},b);var d=h0(a,b);d.events.select.bind(function(a){aa.detect().browser.isIE()?
  (c.trigger.select(a.rows(),a.cols(),a.rowHeaders(),a.columnHeaders()),c.trigger.done(),e()):(e(),c.trigger.done(),c.trigger.select(a.rows(),a.cols(),a.rowHeaders(),a.columnHeaders()))});d.events.exit.bind(function(){e();c.trigger.abort()});var e=function(){d.off()};return{element:d.element,open:function(){d.reset();d.on()},close:e,destroy:function(){d.destroy()},events:c.registry}}function j0(){var a=p.fromTag("fieldset"),b=p.fromHtml("<legend>"+x.translate("table.border")+"</legend>");y.append(a,
  b);var c=Fa("");b=function(a){var b=p.fromTag("input");m.setAll(b,{type:"radio",id:"tableborder"+a+c,value:a,name:c});return b};var d=b("1"),e=b("0");P.append(a,[d,p.fromHtml('<label for="tableborder1'+c+'">'+x.translate("border.on")+"</label>"),e,p.fromHtml('<label for="tableborder0'+c+'">'+x.translate("border.off")+"</label>")]);var f=Kb.radio(a,'input[type="radio"]',"input:checked");return{element:function(){return a},get:function(){return Tj.find(a).map(function(a){return fa.get(a)})},select:function(a){Tj.set(e,
  !1);Tj.set(d,!1);a.each(function(a){"0"===a?Tj.set(e,!0):"1"===a&&Tj.set(d,!0)});f.refresh()},keylayout:k(f),destroy:function(){F.remove(a)}}}function k0(){var a=T.div();n.add(a,B.resolve("table-size-controls"));var b=Vc.input("table-width","table.width"),c=Vc.input("table-height","table.height");E([b,c],function(a){m.set(a.input(),"placeholder","Auto")});P.append(a,[b.element(),c.element()]);var d=[ha.input(b.input(),Ba.input({})),ha.input(c.input(),Ba.input({}))],e=function(a){var b=a.target();
  Lc.validateField(b,"width",g.some("px")).fold(function(){Lc.highlight(b)},function(a){Lc.dehighlight(b)})},f=[K.bind(b.input(),"input",e),K.bind(c.input(),"input",e)];return{element:function(){return a},get:function(){return Lc.validate([Lc.rule(b.input(),"width",g.some("px")),Lc.rule(c.input(),"height",g.some("px"))])},set:function(a){a.width().bind(u(fa.set,b.input()));a.height().bind(u(fa.set,c.input()))},keylayouts:k(d),highlight:Lc.highlight,dehighlight:u(Lc.clearHighlights,a),destroy:function(){F.remove(a);
  z(f,function(a){a.unbind()})}}}function l0(a,b){var c=H.create({ok:r(["properties"]),close:r([])}),d=we(b);d.setTitle(x.translate("table.dialog"));n.add(d.element(),B.resolve("dialog-narrow"));b=T.div();var e=xA("table.float"),f=Vc.input("tablesummary","table.summary"),h=Vc.input("tablecaption","table.caption"),l=k0(),q=j0();P.append(b,[h.element(),f.element(),q.element(),l.element(),e.element()]);var C=sd.okCancel("table");C.events.ok.bind(function(){G()});C.events.cancel.bind(function(){d.hide();
  c.trigger.close()});d.events.close.bind(function(){d.hide();c.trigger.close()});d.setContent(b);d.setControls(C.element());var w=Kb.setup(d,C,[ha.input(h.input(),Ba.input({})),ha.input(f.input(),Ba.input({})),q.keylayout()].concat(l.keylayouts()).concat([e.keylayout()])),m=function(){return l.get().map(function(a){a={width:k(g.some(a.width())),height:k(g.some(a.height()))};return Sr.properties({floatval:e.get(),caption:fa.get(h.input()).trim(),summary:fa.get(f.input()).trim(),border:q.get(),dimensions:a})})},
  G=function(){m().fold(function(a){l.highlight(a)},function(a){c.trigger.ok(a)})};return{element:d.element,events:c.registry,open:function(){d.show();w.enter()},represent:function(b){b=Sr.divine(a,b);e.select(b.floatval());void 0!==b.summary()&&fa.set(f.input(),b.summary());void 0!==b.caption()&&fa.set(h.input(),b.caption());l.set(b.dimensions());q.select(b.border())},execute:G,destroy:function(){e.destroy();l.destroy();q.destroy();C.destroy();d.destroy();w.destroy()},hide:function(){w.exit();d.hide()}}}
  function m0(a,b,c,d,e,f,h,l){var q=g.none(),C={"tablemenu-delete-table":Ac.erase,"delete-row":Ac.execute(b,nc.eraseRows,t,l),"delete-column":Ac.execute(b,nc.eraseColumns,t,l),"make-header-column":Ac.execute(b,nc.makeColumnHeader,t,l),"make-header-row":Ac.execute(b,nc.makeRowHeader,t,l),"unmake-header-column":Ac.execute(b,nc.unmakeColumnHeader,t,l),"unmake-header-row":Ac.execute(b,nc.unmakeRowHeader,t,l),"insert-row-before":Ac.execute(b,nc.insertRowBefore,t,l),"insert-row-after":Ac.execute(b,nc.insertRowAfter,
  t,l),"insert-column-before":Ac.execute(b,nc.insertColumnBefore,Tr.halve,l),"insert-column-after":Ac.execute(b,nc.insertColumnAfter,Tr.halve,l),"tablemenu-table-properties":function(b,d,l){b=l0(a,h);var k=zA.generate(e,b,["properties"]);k.events.ok.bind(function(a){c.activate();q.each(function(b){tb.table(b.element(),c.isRoot).each(function(b){Pd.runTransaction(c,f,function(){Sr.apply(b,a.properties())})})});k.destroy()});k.events.close.bind(function(a){k.destroy();c.activate();c.focus()});c.deactivate();
  k.represent(d);k.open();return g.none()},"cell-merge":Ac.execute(b,nc.mergeCells,t,l),"cell-unmerge":Ac.execute(b,nc.unmergeCells,t,l),"cell-split-cols":Ac.execute(b,nc.splitCellIntoColumns,Tr.halve,l),"cell-split-rows":Ac.execute(b,nc.splitCellIntoRows,t,l)},w=O("value","text","attrs"),I=Sz.byClass(te);return{handle:function(a){c.doc().each(function(b){q.each(function(b){var d=b.element();tb.table(d,c.isRoot).each(function(d){var e=m.get(a,"data-ephox-gopher-item-value"),h=C[e];void 0!==h&&Pd.runTransaction(c,
  f,function(){h(c,d,b).each(function(a){c.setSelection(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset());I.clear(d)})})})})})},assign:function(a){q=a.bind(function(a){return tb.cell(a,c.isRoot).bind(function(a){return L.ancestor(a,"table").map(function(b){return Sm.forMenu(d,b,a)})}).orThunk(function(){return tb.notCell(a,c.isRoot).map(function(a){return Sm.notCell(a)})})})},situation:function(a){a=q.map(function(a){var b=a.element();b=tb.cell(b,c.isRoot).isSome();return Qb([b?[w("tablemenu-row",
  x.translate("table.context.row.menu"),{})]:[],b?[w("tablemenu-column",x.translate("table.context.column.menu"),{})]:[],[w("tablemenu-table",x.translate("table.context.table.menu"),{})],a.mergable().isSome()?[w("cell-merge",x.translate("table.context.cell.merge"),{})]:[],a.unmergable().isSome()?[w("cell-unmerge",x.translate("table.context.cell.unmerge"),{})]:[],b&&1===a.selection().length&&a.mergable().isNone()&&a.unmergable().isNone()?[w("cell-split-cols",x.translate("table.context.cell.split-cols"),
  {}),w("cell-split-rows",x.translate("table.context.cell.split-rows"),{})]:[]])}).getOr([]);var b=q.map(function(a){var b=a.element();a=function(a,c,d){var e=a+"-menu",f="th"===D.name(b)?"unmake":"make",h="make"===f?"header":"normal";c=[w("insert-"+a+"-before",x.translate("table.context."+a+"."+c),{}),w("insert-"+a+"-after",x.translate("table.context."+a+"."+d),{}),w("delete-"+a,x.translate("table.context.common.delete"),{}),w(f+"-header-"+a,x.translate("table.context.common."+h),{})];return{textkey:k(x.key("table.context."+
  a+".title")),value:k(e),items:k(c)}};var c={textkey:k(x.key("table.context.table.title")),value:k("table-menu"),items:k([w("tablemenu-table-properties",x.translate("table.context.table.properties"),{}),w("tablemenu-delete-table",x.translate("table.context.common.delete"),{})])};return Qb([[a("row","insertabove","insertbelow")],[a("column","insertleft","insertright")],[c]])}).getOr([]);return{primary:k(a),secondary:k(b),submenus:k({"tablemenu-row":"row-menu","tablemenu-column":"column-menu","tablemenu-table":"table-menu"})}},
  destroy:t}}function n0(){var a=H.create({drag:r(["xDelta","yDelta"])});return{mutate:function(b,c){a.trigger.drag(b,c)},events:a.registry}}function o0(){var a=H.create({drag:r(["xDelta","yDelta","target"])}),b=g.none(),c=n0();c.events.drag.bind(function(c){b.each(function(b){a.trigger.drag(c.xDelta(),c.yDelta(),b)})});return{assign:function(a){b=g.some(a)},get:function(){return b},mutate:c.mutate,events:a.registry}}function p0(a,b,c){var d=o0(),e=sj.transform(d,{}),f=g.none(),h=function(a,b){return g.from(m.get(a,
  b))};d.events.drag.bind(function(a){h(a.target(),"data-row").each(function(b){b=Qd.getInt(a.target(),"top");v.set(a.target(),"top",b+a.yDelta()+"px")});h(a.target(),"data-column").each(function(b){b=Qd.getInt(a.target(),"left");v.set(a.target(),"left",b+a.xDelta()+"px")})});var l=function(a,b){var c=Qd.getInt(a,b);a=parseInt(m.get(a,"data-initial-"+b),10);return c-a};e.events.stop.bind(function(){d.get().each(function(d){f.each(function(e){h(d,"data-row").each(function(a){var b=l(d,"top");m.remove(d,
  "data-initial-top");G.trigger.adjustHeight(e,b,parseInt(a,10))});h(d,"data-column").each(function(a){var b=l(d,"left");m.remove(d,"data-initial-left");G.trigger.adjustWidth(e,b,parseInt(a,10))});Fe.refresh(a,e,c,b)})})});var q=function(b,c){G.trigger.startAdjust();d.assign(b);m.set(b,"data-initial-"+c,parseInt(v.get(b,c),10));n.add(b,q0);v.set(b,"opacity","0.2");e.go(a.parent())},k=K.bind(a.parent(),"mousedown",function(a){Fe.isRowBar(a.target())&&q(a.target(),"top");Fe.isColBar(a.target())&&q(a.target(),
  "left")}),w=function(b){return N.eq(b,a.view())},I=K.bind(a.view(),"mouseover",function(d){"table"===D.name(d.target())||Db.closest(d.target(),"table",w)?(f="table"===D.name(d.target())?g.some(d.target()):L.ancestor(d.target(),"table",w),f.each(function(d){Fe.refresh(a,d,c,b)})):ja.inBody(d.target())&&Fe.destroy(a)}),G=H.create({adjustHeight:r(["table","delta","row"]),adjustWidth:r(["table","delta","column"]),startAdjust:r([])});return{destroy:function(){k.unbind();I.unbind();e.destroy();Fe.destroy(a)},
  refresh:function(d){Fe.refresh(a,d,c,b)},on:e.on,off:e.off,hideBars:u(Fe.hide,a),showBars:u(Fe.show,a),events:G.registry}}function r0(a,b){var c=Uj.height;a=p0(a,b,c);var d=H.create({beforeResize:r(["table"]),afterResize:r(["table"]),startDrag:r([])});a.events.adjustHeight.bind(function(a){d.trigger.beforeResize(a.table());var b=c.delta(a.delta(),a.table());Ur.adjustHeight(a.table(),b,a.row(),c);d.trigger.afterResize(a.table())});a.events.startAdjust.bind(function(a){d.trigger.startDrag()});a.events.adjustWidth.bind(function(a){d.trigger.beforeResize(a.table());
  var c=b.delta(a.delta(),a.table());Ur.adjustWidth(a.table(),c,a.column(),b);d.trigger.afterResize(a.table())});return{on:a.on,off:a.off,hideBars:a.hideBars,showBars:a.showBars,destroy:a.destroy,events:d.registry}}function s0(a,b){var c=a.content(),d=a.keyboard(),e=a.undo(),f=a.smartview(),h=function(){return v.getOr(Vr.only(c.element()))},l=m0(a.filter(),a.region(),c,a.selections(),d,e,f.uiContainer(),h),q=function(a,b,d){e.save();z(b,function(b){a(b,d)});e.save();c.focus()},C=u(q,rB.setBackgroundColor);
  q=u(q,rB.setBorderColor);b=vb.ui({"table.widget":u(t0.widget,a,b),"cell.palette":k({items:[{type:"widget",build:u(sB.widget,a,b,{action:C,shortname:"background",name:"cellbackgroundcolor",textkey:"table.cell.color.background",menuTextkey:"table.cell.color.background"})},{type:"widget",build:u(sB.widget,a,b,{action:q,shortname:"border",name:"cellbordercolor",textkey:"table.cell.color.border",menuTextkey:"table.cell.color.border"})},{type:"widget",build:u(u0.widget,a)},{type:"dropdown",build:u(v0.widget,
  a)}],updatePalette:function(b){var d=wf.selectedCells(a.selections(),c.isRoot),e=u(b.show,g.some(x.translate("table.context.palette.show")));b=u(b.hide,g.some(x.translate("table.context.palette.hide")));(0<d.length?e:b)()&&a.ui().refresh()}})},ca);var w=function(b){var d=b.stopper();$l.context(c).bind(function(e){$l.cata(e,function(e){tb.cell(e.startContainer(),c.isRoot).each(function(e){(b.shift()?tB.backward:tB.forward)(a.region(),c,e,h).fold(d,function(a){d();c.setSelection(a.startContainer(),
  a.startOffset(),a.endContainer(),a.endOffset())})})},t)})},m=function(a){uB.upOrLeft(c)},G=function(a){uB.right(c)},n=d.editor();n.on();n.events.tab.bind(w);n.events.left.bind(m);n.events.up.bind(m);n.events.right.bind(G);var p=c.cursor(),r=g.none(),v=g.none();c.events.ready.bind(function(b){b=Pr.get(c,f,b.api().doc());v=g.some(b);var d=Ly(a.region().directionAt),h=r0(b,d);h.events.beforeResize.bind(e.save);h.events.afterResize.bind(function(){c.focus();e.save();c.domChanged();p.restore()});h.on();
  h.events.startDrag.bind(p.save);r=g.some(h);b=a.selections();b.events.beforeScan.bind(function(){h.hideBars()});b.events.afterScan.bind(function(){h.showBars()})});return{ui:b,destroy:function(){l.destroy();r.each(function(a){a.destroy()});n.off();n.events.tab.unbind(w);n.events.left.unbind(m);n.events.up.unbind(m);n.events.right.unbind(G);n.destroy()},handle:l.handle,assign:l.assign,situation:l.situation,name:k("table")}}function w0(){var a=H.create({pasteUpload:r([]),uploadAssets:r(["assets"])});
  return{destroy:t,events:a.registry,pasteUpload:a.trigger.pasteUpload,uploadAssets:a.trigger.uploadAssets}}function x0(a,b){a=a().uiContainer();var c=H.create({close:r([])}),d=we(a);d.setTitle(x.translate("wordcount.dialog"));ma.add(d.element(),[B.resolve("dialog-wordcount"),B.resolve("dialog-narrow")]);var e=b().body().getOrDie();a=Wh.toText(e,k(!1));e=Vb.get(e);b=b().getSelectedText().getOr("");a=vB.count(a);e=e.length;b=vB.count(b);var f=p.fromHtml(wB('<table class="ephox-polish-tabular ephox-polish-wordcount-table" tabindex="-1">    <thead>        <tr>            <th scope="col"> ${headerCounts}&nbsp;</th>            <th scope="col"> ${headerDocument}&nbsp;</th>            <th scope="col"> ${headerSelection}&nbsp;</th>        </tr>    </thead>    <tbody>        <tr>            <td>${wordCountLabel}&nbsp;</td>            <td class="ephox-polish-wordcount-document-words">${documentCountWords}&nbsp;</td>            <td class="ephox-polish-wordcount-selection-words">${selectionCountWords}&nbsp;</td>        </tr>        <tr>            <td>${wordCountCharsNoSpacesLabel}&nbsp;</td>            <td class="ephox-polish-wordcount-document-charsnospaces">${documentCharactersNoSpaces}&nbsp;</td>            <td class="ephox-polish-wordcount-selection-charsnospaces">${selectionCharactersNoSpaces}&nbsp;</td>        </tr>        <tr>            <td>${wordcountCharsLabel}&nbsp;</td>            <td class="ephox-polish-wordcount-document-chars">${documentCountCharsWithSpaces}&nbsp;</td>            <td class="ephox-polish-wordcount-selection-chars">${selectionCountCharsWithSpaces}&nbsp;</td>        </tr>    </tbody></table>',
  {headerCounts:x.translate("wordcount.counts"),headerDocument:x.translate("wordcount.document"),headerSelection:x.translate("wordcount.selection"),wordCountLabel:x.translate("wordcount.words"),wordCountCharsNoSpacesLabel:x.translate("wordcount.charactersnospaces"),wordcountCharsLabel:x.translate("wordcount.characters"),documentCountWords:a.words(),selectionCountWords:b.words(),documentCharactersNoSpaces:a.characters().withoutSpaces(),selectionCharactersNoSpaces:b.characters().withoutSpaces(),documentCountCharsWithSpaces:e,
  selectionCountCharsWithSpaces:b.characters().withSpaces()}));d.setContent(f);var h=ha.multiple(d.element(),[]);b=function(){l();c.trigger.close()};var l=function(){d.hide()};d.events.close.bind(b);h.events.exit.bind(b);return{element:d.element,events:c.registry,open:function(){d.show();h.enter();Z.focus(f)},destroy:function(){h.destroy();d.destroy()},hide:l}}function y0(a,b){var c=x0(a,b),d=H.create({close:r([])});c.events.close.bind(function(){d.trigger.close();c.destroy()});return{show:function(){c.open()},
  events:d.registry}}function z0(a){var b=a.content,c=a.smartview;return{ui:vb.ui({"wordcount.general":{toggle:!1,value:"wordcount",textkey:x.key("wordcount.open"),action:function(){var d=y0(c,b);d.events.close.bind(function(){a.ui().tabstrip.focused()||b().focus()});a.content().hideInlineSelection();d.show()},updateGeneral:t,icon:!0,shortcut:!1,hasPopup:!1,hasDialog:!0}}),destroy:t}}function Tm(a,b,c){var d=function(a,b,c,d){return b.bundled?a.apply(void 0,d.concat([b])):c()},e=A0(a,b,c);b=d(NU,a.formatting,
  Sa.basic,[e]);var f=d(LU,a.alignindent,Sa.basic,[e]),h=d(aV,a.bookmark,Sa.basic,[e]),l=d(cV,a.directionality,Sa.basic,[e]),q=d(s0,a.table,Sa.table,[e]),C=d(YU,a.blocktag,Sa.basic,[e]),w=d(JX,a.font,Sa.basic,[e]),I=d(z0,a.wordcount,Sa.basic,[e]),G=d(gZ,a.media,Sa.basic,[e]),n=d(G_,a.specialchar,Sa.basic,[e]),p=d(SY,a.linkvalidator,Sa.linkvalidator,[e,c.linkvalidator]),u=d(NY,a.link,Sa.basic,[e,p]),v=d($X,a.horizontalrule,Sa.basic,[e]),x=d(WX,a.help,Sa.dialog,[e]),y=function(b,c,d,f){var h=a.ui.locale.code;
  h=void 0!==h?h:qf.get();return(!0===c.bundled?vf.determine(h):g.none()).fold(function(){return d()},function(a){var d=e.profile().spelling().get(),h=!0===c.menu||d===vf.offKey();return b.apply(void 0,f.concat([c,a,h&&!1!==d?d:a]))})}(e0,a.spelling,Sa.spelling,[e,c.spelling]),B=d(vZ,a.parlance,Sa.basic,[e,y]),D=d(DZ,a.resize,Sa.basic,[e]),F=d(aZ,a.macros,Sa.macros,[e,y,c.macros]),J=d(XX,a.highlighter,Sa.highlighter,[e,F]),K=d(dV,a.draganddrop,Sa.draganddrop,[e]),L=w0(),M=d(xY,a.imageEdit,Sa.imageEdit,
  [e,L]),N=d(cY,a.image,Sa.image,[e]),O=d(fX,a.fileupload,Sa.dialog,[e,L,M.insertResample(),K]),P=d(x_,a.smartclipboard,Sa.basic,[e,L,M.insertResample()]),S=d(rZ,a.mentions,Sa.basic,[e]),R=d(lX,a.findreplace,Sa.basic,[e]),T=d(GU,a.accessibility,Sa.basic,[e]),U=d(hV,a.embed,Sa.basic,[e,c.embed]);c=function(){var a=e.content();return a.body().fold(a.getContent,function(a){a=Oc.deep(a);return Vj.output(e.filter(),a)})};var W=function(a){var b=e.filter(),c=e.content();a=b.filterHtml(b.input(),a);c.resetContent(a);
  J.run();p.refresh();y.scanView();return a};d=d(zZ,{getContent:c,setContent:W,bundled:a.plaincodeview.bundled},Sa.basic,[e]);e.contextmenu().register("table",q);e.contextmenu().register("imageEdit",M);e.contextmenu().register("image",N);e.contextmenu().register("spelling",y);e.contextmenu().register("link",u);var Z=B0({formatting:b,alignindent:f,bookmark:h,directionality:l,table:q,font:w,imageEdit:M,parlance:B,blocktag:C,wordcount:I,specialchar:n,media:G,link:u,linkvalidator:p,horizontalrule:v,help:x,
  fileupload:O,findreplace:R,accessibility:T,plaincodeview:d,macros:F,spelling:y});e.content().events.ready.bind(function(){e.ui().init(e.keyboard(),e.undo(),Z);y.init(e.content());J.run();p.refresh()});e.content().events.loaded.bind(function(){setTimeout(function(){Y.trigger.loaded();aa()},0)});var Y=H.create({loaded:r([]),ready:Q([],e.content().events.ready),focus:r([]),change:r([]),dirty:Q([],e.laundry().events.dirty),internal:r(["command","data"]),paint:r(["dimensions"])}),aa=e.content().isInline()?
  t:function(){e.content().body().each(function(a){a=A.documentElement(a);var b=e.content().element();Y.trigger.paint(hy({width:Ga.get(b),docWidth:Ga.get(a),height:sa.get(b),docHeight:sa.get(a)}))})};e.undo().events.changed.bind(function(){Y.trigger.change()});e.undo().events.reset.bind(function(){Y.trigger.change()});e.content().events.paint.bind(aa);e.content().events.nodeChanged.bind(aa);e.content().events.focus.bind(function(){Y.trigger.focus()});e.internalevents().events.internal.bind(function(a){var b=
  a.command();"insertLink"===b&&(a=m.get(a.data(),"href"),Y.trigger.internal(b,a))});d=e.content().isInline()?function(){var a=e.ui(),b=e.content(),c=a.state();c=void 0!==c.toolbar&&void 0!==c.toolbar.drag?c.toolbar.drag.isSome():!1;b.activate();b.focus();e.viewablearea().setOn();c||a.position();a.refresh()}:t;b=e.content().isInline()?function(){e.content().deactivate();e.content().blur();e.viewablearea().setOff()}:t;return jj.internal({activateInline:d,deactivateInline:b,element:e.ui().element,viewport:e.ui().viewport,
  connect:e.ui().connect,focus:e.content().focus,blur:e.content().blur,getContent:c,toTransfer:Pb(Jf.changed,c),setContent:function(a){var b=e.undo();b.disable(function(){var c=W(a);b.reset(c)});e.laundry().setDirty(!1)},insertHtmlAtCursor:e.insertFilteredHtmlAtCursor,isDirty:e.laundry().isDirty,setDirty:e.laundry().setDirty,fromTransfer:function(a){var b=e.undo();Jf.cata(a,function(a){b.disable(function(){W(a)});b.replaceTop()},function(a){W(a);b.save()})},uploader:k(L),state:function(){var a=e.state();
  return ua(a,{spelling:y.state(),macros:F.state(),filters:e.filter().customFilters().state(),linkvalidator:p.state(),embed:U.state()})},destroy:function(){e.content().deactivate();var a=E(Ze(Z),xb);z(a.concat([U,N,M,y,D,F,J,L,P,S,e,K]),function(a){a.destroy()})},events:Y.registry,communication:e.communication,fullscreen:e.fullscreen,content:e.content,ui:e.ui,undo:e.undo,smartview:e.smartview,keyboard:e.keyboard,filter:e.filter,operations:e.operations,macros:k(F),getMode:hc.pencil,isPrettyPrinting:function(){return!0===
  a.content.prettyprint}})}function C0(a,b){var c=Sa.state(b),d=na(null),e=p.fromTag("div"),f=function(){Ha.set(e,'<div class="e-p-s-img"></div>');h()},h=void 0===a.content.inline?t:function(){if(!1===a.ui.toolbar.visible)v.set(e,"display","none");else{var b={isInline:k(!0),element:k(a.content.inline)};b=pd.offsetFrom(b,e,sa.get(e),a.ui);v.setAll(e,{position:"absolute",left:b.left+"px",top:b.top-4+"px"})}},l=null;b=yb("API unavailable while the editor is loading");var q={body:k(g.none()),doc:b,execCommand:b,
  getSelectedText:b,focus:b,deactivate:t,blur:t},C=void 0===a.content.inline?d.get:function(){return Ha.get(a.content.inline)};return jj.internal({activateInline:h,blur:b,communication:k(mz(a)),connect:function(a){l=setTimeout(f,1E3);y.append(a,e);Wr.add();return!1},content:k(q),deactivateInline:t,destroy:function(){clearTimeout(l);Wr.remove();F.remove(e)},element:k(e),events:Id.events(),failure:function(){clearTimeout(l);Wr.remove();Ha.set(e,"<p>Unable to load editor. See browser console for details.</p>")},
  filter:c.filter,focus:b,fromTransfer:function(a){Jf.cata(a,d.set,d.set)},fullscreen:Sa.fullscreen,getContent:C,getMode:b,insertHtmlAtCursor:b,isDirty:c.laundry.isDirty,isPrettyPrinting:function(){return!0===a.content.prettyprint},keyboard:Id.keyboard,macros:c.macros,operations:Id.operations,setContent:function(b){void 0===a.content.inline?d.set(b):Ha.set(a.content.inline,b);c.laundry.setDirty(!1)},setDirty:c.laundry.setDirty,smartview:Id.smartview,state:function(){var a=xf.isEmpty(C())?{}:{content:{}};
  return c.getState(a)},toTransfer:Pb(Jf.unchanged,C),ui:Id.ui,undo:k(Sa.undo()),uploader:k(Sa.uploader()),viewport:k(e)})}function D0(a,b){return(!0===b.bundled?E0:F0)(a,b)}function G0(a,b){var c=H.create({change:r(["type"])}),d=yf.removeClasses([B.resolve(hc.none()),B.resolve(hc.wait()),B.resolve(hc.pencil()),B.resolve(hc.code())]),e=T.div();S.hidden(e,"true");ma.add(e,[B.resolve("html-switch-wrapper"),B.resolve("layer-editor")]);var f=T.div();ma.add(f,[B.resolve("html-switch"),B.resolve("icon")]);
  y.append(e,f);var h=function(a){d(f);n.add(f,B.resolve(a));m.set(f,"data-icon",a);m.remove(f,"title")},l=function(a,b){var c=m.get(f,"data-icon");a!==c&&(p=c,h(a),m.set(f,"title",b))},g=function(a){b.showButton&&a!==hc.none()?l(a,x.translate("toolbar.switch-"+a)):h(hc.none());w.control.unblock()},k=gd.unbindable(),w=Hd.tap(function(){c.trigger.change(m.get(f,"data-icon"))});b.showButton&&k.set(K.bind(e,"click",w.instance));var I=function(a){y.append(a,e)},G=ae.onDirection("right","left"),p=hc.none();
  g(p);return{render:I,destroy:function(){F.remove(e);k.clear()},switchto:g,spin:function(){l(hc.wait(),x.translate("loading.wait"));w.control.block()},stopSpin:function(){"spin"!==p&&g(p)},init:function(b){var c=a.get();I(c.viewport());c.events.paint.bind(function(a){var b=a.dimensions();a=G(c.element());b="left"===a&&(xB.isFirefox()||xB.isChrome())?0:b.width()-b.docWidth();v.set(e,a,b+"px")});g(hc.none())},events:c.registry}}function H0(a,b,c,d,e,f){var h=p.fromTag("div"),l=c.uiContainer(),g=T.div();
  d.updateUi(h);d=[Lg.editorContainer(),"ephox-textbox-font",B.resolve("layer-editor"),B.resolve("editor-main"),B.resolve("fullscreen-maximized")];ma.add(h,d);m.set(h,"lang",qf.get());Xr.addClasses(h);y.append(h,l);var C=Ay(a,h,{}),w=df.toolbar(C,x.translate);b.events.toolbar.bind(w.enter);w.events.exit.bind(a.focus);var I=zy(),G=ja.body(),r=T.div();n.add(r,B.resolve("socket"));var X=E(["dragover","drop"],function(a){return K.bind(r,a,function(a){a.kill()})}),t=T.div();n.add(t,B.resolve("widget-container"));
  C.integrate(h,w,I,r,t);Jy.build(h,e.sideBar,e.bottomBar);var u=aA({layerClass:B.resolve("layer-below-editor"),background:"rgba(255, 255, 255, 0.92)"}),v=B.resolve("body-fullscreen");a.events.paint.bind(function(a){w.repaint();c.refresh()});return{element:k(h),socket:function(a){y.append(r,a.element())},viewport:k(r),uiContainerParent:k(g),connect:function(a){u.show();n.add(G,v);y.append(a,h);kj.detect(h);return!0},destroy:function(){z(X,function(a){a.unbind()});w.destroy();n.remove(G,v);F.remove(h);
  F.remove(g);u.destroy();I.destroy()},banners:I.element,displayBanner:I.display,hideBanner:I.hide,position:function(){C.init(w,I,r,t,e,f)},refresh:function(){C.update();w.refresh()},toolbar:w,dialogContainer:k(t)}}function I0(a){var b=g.none(),c=g.none(),d=H.create({maximize:r([]),restore:r([])}),e=function(c){b=A.parent(a.get().element());b.getOrDie("maximize called on editor that is not in the DOM.");a.swap(Tm,{ui:{layout:J0,isFullScreen:!0,autoresize:!1},fullscreen:{layout:void 0!==c.layout()?c.layout():
  Yr},content:{autoresize:!1}}).destroy();var e=a.get();e.fullscreen().select();e.connect(ja.body());e.events.ready.bind(function(){e.focus();d.trigger.maximize()})},f=function(c){a.swap(Tm,{ui:{layout:void 0!==c.layout()?c.layout():Yr,isFullScreen:!1}}).destroy();var e=a.get();e.fullscreen().deselect();c=b.getOrDie("restore called on editor that was not previously in the DOM.");a.get().connect(c);e.events.ready.bind(function(){e.focus();d.trigger.restore()})};return{init:function(b){if(Um.goingToDesign(b)){b=
  a.get();var d=a.get().element();c.each(function(a){if(N.eq(a,d))throw"Fullscreen init called twice on the same instance";});c=g.some(d);b.fullscreen().events.maximize.bind(e);b.fullscreen().events.restore.bind(f)}},destroy:function(){},events:d.registry}}function K0(){var a=[];return{setCallback:function(b){qb(b)&&a.push(b)},done:function(b){z(a,function(a){a.apply(null,[b])});a=[]}}}function L0(a){var b=function(){var b=a.url,c=b.lastIndexOf("/");b=0<c?b.substr(0,c):b;b=void 0===a.basePath?b:a.basePath;
  return je(b,"/")?b:b+"/"}(),c=function(c,e,f){var d=Wj.getFilename(c,e);e=!0===a.credentials?he.xhr():he.none();c=yB.file(Wj.buildData("image",c,d));Ae.post(a.url,c,Be.text(),e).map(function(a){a.fold(function(a){f(J.error(Wj.failureObject(a.message(),a.status(),a.responseText())))},function(a){try{var c=Nb.parse(a);if(xa(c.location))var e=c.location;else{f(J.error(Wj.failureObject("JSON response did not contain a string location",500,a)));return}}catch(I){e=a}a=e.split(/\s+/);a=LA.resolve(b,1===
  a.length&&""!==a[0]?a[0]:d);f(J.value({location:a}))})})};return{upload:function(a,b,f){a=a.imageresult();Xc.imageResultToBlob(a).then(function(a){c(a,b,f)})}}}function M0(a){var b=function(b,d,e,f){var c=function(a){f(J.error(a))},l=function(a){xa(a)?f(J.value({location:a})):(console.error("Image upload result was not a string"),c(""))},g=Wj.getFilename(b,e),k=N0(e,g,b,d);setTimeout(function(){a(k,l,c)},0)};return{upload:function(a,d,e){var c=a.imageresult();Xc.imageResultToBlob(c).then(function(a){b(a,
  Xc.imageResultToDataURL(c),d,e)})}}}function O0(){var a={},b=function(a){bg.revokeObjectURL(a.objurl())};return{add:function(b,d,e){d=P0(b,d,e);return a[b]=d},get:function(b){return g.from(a[b])},remove:function(c){var d=a[c];delete a[c];void 0!==d&&b(d)},lookupByData:function(b){return Q0(a,function(a){return Xc.imageResultToDataURL(a.imageresult())===b})},destroy:function(){Ma(a,b);a={}}}}function R0(){var a=[],b=[],c=H.create({complete:r(["response"])}),d=function(d){a=ka(a,function(a,b){return a!==
  d});!1===e()&&(c.trigger.complete(b),b=[])},e=function(){return 0<a.length};return{findById:S0,findAll:T0,register:function(b,c){m.set(b,Vm,c);a.push(c)},report:function(a,c,e){z(c,function(a){m.remove(a,Vm);b.push({success:e,element:a.dom()})});d(a)},inProgress:e,isActive:function(b){return U(a,b)},events:c.registry}}function U0(a,b){var c=O0(),d=K0(),e=R0(),f=mr(a.ui),h=V0.choose(b,f,a.communication()),l=h.uploader(),q=h.errors(),k=W0.instance(b,c),w=H.create({begin:r([]),finish:r([])}),m=function(a){w.trigger.finish();
  d.done(a)};e.events.complete.bind(function(a){m(a.response())});var G=function(a,b,d,f){Xj.handleUpload(l,e,c,a,b,d,function(a){a.fold(function(a){f(a)},p)})},n=function(d){a.content().body().each(function(a){var e=q.instance(),f=Xj.registerAssets(c,a,d.assets());f=Pj.partition(f);z(f.errors,function(a){console.error(a)});0<f.values.length&&!0===b.immediate&&(w.trigger.begin(),z(f.values,function(b){t(a,b,e)}))})},p=function(b,c,d){a.undo().rewrite(d.objurl(),b.location)},t=function(a,c,d){!1!==b.bundled&&
  Xj.prepareForUpload(e,c.blobInfo().id(),c.image()).each(function(b){G(a,b,c.blobInfo(),d)})},u=function(a){z(a,function(a){e.report(a,g.none(),!1)})},v=function(a,b){b=Pj.partition(b);var c=b.values;u(b.errors);var d=q.instance();k(c).get(function(b){b=Pj.partition(b);0<b.errors.length&&(f.showKey("imageedit.generic"),console.error("Image resample on upload errors: ",b.errors),u(b.errors));z(b.values,function(b){t(a,b,d)})})},y=function(f){qb(f)&&d.setCallback(f);w.trigger.begin();!0!==b.bundled?
  m([]):a.content().body().fold(function(){m([])},function(a){var b=Xj.findBlobs(e,c,a);0!==b.length||e.inProgress()?v(a,b):m([])})};return{init:function(d){Um.goingToDesign(d)&&(d=a.filter(),X0.configure(d,c),a.uploader().events.uploadAssets.bind(n),a.uploader().events.pasteUpload.bind(function(){!0===b.immediate&&y()}));f.reset()},events:w.registry,reconstitute:y,destroy:function(){c.destroy()}}}function Y0(a,b,c,d){var e=I0(a),f=U0(b,c.imageupload),h=D0(a,c.codeview),l=G0(a,c.codeview),g=[e,f,l],
  k=g.concat([h]);e.events.restore.bind(function(){d.restore();m(k,hc.code())});e.events.maximize.bind(function(){d.save();m(g,hc.code())});f.events.begin.bind(l.spin);f.events.finish.bind(l.stopSpin);h.events.change.bind(function(c){a.get().events.loaded.bind(function(){b.focus()});b.reconnect()});l.events.change.bind(function(a){w(a.type())});h.events.ready.bind(function(a){l.switchto(a.type())});var w=function(b){f.reconstitute(function(){a.get().getMode()!==b&&(l.spin(),h.setMode(b))})},m=function(a,
  b){z(a,function(a){a.init(b)})};b.events.connected.bind(function(){m(k,Um.alternate(b.getMode()))});return{setMode:w,uploadImages:f.reconstitute,destroy:function(){l.destroy();a.destroy();z(k,function(a){a.destroy()})}}}function Z0(a){var b=$0(a);return{directionAt:function(a){return"rtl"===(D.isText(a)?A.parent(a):g.some(a)).map(ae.getDirection).getOr("ltr")?zB:AB},uiDirection:function(){return b?zB:AB},updateUi:function(a){m.set(a,"dir",b?"rtl":"ltr")},destroy:t}}function a1(a,b){var c=H.create({create:r(["instance"]),
  loaded:r([]),focus:r([]),dirty:r([]),change:r([]),internal:r(["command","data"])}),d=Zb(function(){c.trigger.loaded()}),e=function(a){a.events.focus.bind(function(){c.trigger.focus()});a.events.dirty.bind(function(){c.trigger.dirty()});a.events.change.bind(function(){c.trigger.change()});a.events.internal.bind(function(a){c.trigger.internal(a.command(),a.data())});a.events.loaded.bind(d)};e(a);var f=a,h=Pb(Z0,qf.get);return{get:function(){return f},swap:function(a,d){var l=f;d=oa(b,d);var g=l.state();
  a=a(d,h(),g);e(a);c.trigger.create(a);f=a;return{old:k(l),nu:k(a),destroy:function(){l.destroy()}}},destroy:function(){f.destroy()},events:c.registry}}function Zr(a,b){var c=b1(a);Yj.setLanguage(c.ui.locale.code);a=oa(BB.state(),b);b=Uc.capture(p.fromDom(document),window);var d=C0(c,a),e=a1(d,c),f=nU(e);a=Y0(e,f,c,b);b=H.create({loaded:Q([],e.events.loaded),focus:Q([],e.events.focus),dirty:Q([],e.events.dirty),change:Q([],e.events.change),connected:Q([],f.events.connected),internal:Q(["command","data"],
  e.events.internal)});Yj.waitForLoad().get(function(a){a=Yj.getFailures(a);if(0===a.length){a=e.swap("code"===c.codeview.mode?fy:Tm);f.reconnect();var b=function(a){xf.isEmpty(a)||f.setContent(a)},h=a.old().toTransfer();Jf.cata(h,b,b);a.destroy()}else z(a,function(a){console.error(a)}),console.error("Required resources are not available. Cancelling editor load."),d.failure()});return jj.external({activateInline:f.activateInline,communication:Id.communication,connect:f.connect,content:f.content,deactivateInline:f.deactivateInline,
  element:f.element,events:b.registry,filter:f.filter,focus:f.focus,getContent:f.getContent,getMode:f.getMode,insertHtmlAtCursor:f.insertHtmlAtCursor,isDirty:f.isDirty,isPrettyPrinting:f.isPrettyPrinting,keyboard:f.keyboard,macros:f.macros,operations:f.operations,setContent:f.setContent,setDirty:f.setDirty,smartview:f.smartview,state:f.state,ui:f.ui,undo:f.undo,setMode:a.setMode,uploadImages:a.uploadImages,destroy:a.destroy})}function c1(a,b,c){n.add(b,be.base());return{toolbarShow:function(){n.add(b,
  be.active());v.set(a(),"display","block")},toolbarHide:function(){n.remove(b,be.active());v.set(a(),"display","none")},isVisible:function(){return n.has(b,be.active())},restore:function(){ma.remove(b,[be.base(),be.active()]);m.setAll(b,c)}}}function d1(a){var b=!1;return{submit:function(){b=!0;a.submit[0]?a.submit[0].click():a.submit.click?a.submit.click():a.submit();b=!1},inprogress:function(){return b}}}function e1(a){var b=function(b,d){var c=Zb(function(){var b=oa,c=void 0!==d?d:{};var e=oa;var g=
  f1(c),k=void 0===c.privateapi?{}:c.privateapi;c=Ob(k.ui,[ba.func("bounds"),ba.bool("showHelpHint"),ba.domElement("bottomBar"),ba.domElement("sideBar")]);var w=Ob(k.integration,[ba.string("type"),ba.string("version")]),m=Ob(void 0===k.content?{}:k.content,[ba.string("base"),ba.arrayOfStrings("imageExcludes")]),G=CB.paramList(),n=Ob(k.mentions,G),p=cb(n).length;k=Ob(k.output,[ba.bool("prettyprint")]);if(0<p){if(p!==G.length)throw Error("Missing @mentions configuration. Expected "+G.length+" objects, was "+
  p);n.bundled=!0}c={ui:c,help:{integration:w},content:ua(m,k),mentions:n};e=e(g,c);b=b(e,a);return DB.setupResources(b)});return{constructors:k(b),options:c}};return{classic:function(a){return b(g1,a)},inline:function(a){a=oa({ui:{toolbar:{draggable:!0}}},a);return b(h1,a)}}}function i1(a){var b=sT(),c=e1(a),d=function(a,c){a=xa(a)?Ia.one(a).getOrThunk(yb("Selector did not match any elements: "+a)):p.fromDom(a);return b.getOrCreate(a,c)},e=function(a,b){xa(a)?console.error("Selector did not match a "+
  b+": ",a):console.error("Element was not a "+b+": ",a);throw Error("Unable to create textbox.io editor");},f=aa.detect(),h=function(a){xa(a)||Tb(a,[ba.domElement("element")]);return xa(a)?Ia.all(a):E(a,p.fromDom)},l=function(a,c){a=h(a);a=E(a,function(a){return b.getOrCreate(a,c)});return ee(a)};return Ql.makeReadOnly({replace:function(a,b){Tb(arguments,[ba.stringOrDom("element"),Wm.object("options")]);return d(a,c.classic(b)).getOrThunk(u(e,a,"div or textarea"))},replaceAll:function(a,b){Tb(arguments,
  [ba.stringOrArray("elements"),Wm.object("options")]);return l(a,c.classic(b))},inline:function(a,b){if(f.deviceType.isTouch())throw Error("Mobile does not not support inline editing");Tb(arguments,[ba.stringOrDom("element"),Wm.object("options")]);return d(a,c.inline(b)).getOrThunk(u(e,a,"supported tag for inline editing"))},inlineAll:function(a,b){if(f.deviceType.isTouch())throw Error("Mobile does not not support inline editing");Tb(arguments,[ba.stringOrArray("elements"),Wm.object("options")]);return l(a,
  c.inline(b))},get:function(a){Tb(arguments,[ba.string("selector")]);return b.get(a)},getActiveEditor:function(){return b.getActiveEditor().getOr(null)},definePlugin:function(a,b){Tb(arguments,[ba.string("namespace"),ba.object("code")]);Aq.get(a).each(function(){throw Error("namespace "+a+" is already defined");});if(void 0===b.initialize||!qb(b.initialize))throw Error("plugin does not have an initialize function");return Aq.register(a,b)},version:Ux,isSupported:Jb})}var t=function(){for(var a=0;a<
  arguments.length;a++);},Pb=function(a,b){return function(){for(var c=0;c<arguments.length;c++);return a(b.apply(null,arguments))}},k=function(a){return function(){return a}},ca=function(a){return a},u=function(a){for(var b=1;b<arguments.length;b++);var c=Array(arguments.length-1);for(b=1;b<arguments.length;b++)c[b-1]=arguments[b];return function(){for(var b=0;b<arguments.length;b++);b=Array(arguments.length);for(var e=0;e<b.length;e++)b[e]=arguments[e];b=c.concat(b);return a.apply(null,b)}},zf=function(a){return function(){for(var b=
  0;b<arguments.length;b++);return!a.apply(null,arguments)}},yb=function(a){return function(){throw Error(a);}},xb=function(a){return a()},ed=k(!1),Jb=k(!0),Zj=ed,$r=Jb,ah=function(){return as},as=function(){var a=function(a){return a.isNone()},b=function(a){return a()},c=function(a){return a};a={fold:function(a,b){return a()},is:Zj,isSome:Zj,isNone:$r,getOr:c,getOrThunk:b,getOrDie:function(a){throw Error(a||"error: getOrDie called on none.");},getOrNull:function(){return null},getOrUndefined:function(){},
  or:c,orThunk:b,map:ah,ap:ah,each:function(){},bind:ah,flatten:ah,exists:Zj,forall:$r,filter:ah,equals:a,equals_:a,toArray:function(){return[]},toString:k("none()")};Object.freeze&&Object.freeze(a);return a}(),Xm=function(a){var b=function(){return a},c=function(){return e},d=function(b){return b(a)},e={fold:function(b,c){return c(a)},is:function(b){return a===b},isSome:$r,isNone:Zj,getOr:b,getOrThunk:b,getOrDie:b,getOrNull:b,getOrUndefined:b,or:c,orThunk:c,map:function(b){return Xm(b(a))},ap:function(b){return b.fold(ah,
  function(b){return Xm(b(a))})},each:function(b){b(a)},bind:d,flatten:b,exists:d,forall:d,filter:function(b){return b(a)?e:as},equals:function(b){return b.is(a)},equals_:function(b,c){return b.fold(Zj,function(b){return c(a,b)})},toArray:function(){return[a]},toString:function(){return"some("+a+")"}};return e},g={some:Xm,none:ah,from:function(a){return null===a||void 0===a?as:Xm(a)}},Xh=function(a){return function(b){if(null===b)b="null";else{var c=typeof b;b="object"===c&&Array.prototype.isPrototypeOf(b)?
  "array":"object"===c&&String.prototype.isPrototypeOf(b)?"string":c}return b===a}},xa=Xh("string"),ic=Xh("object"),Mb=Xh("array"),Ym=Xh("boolean"),qb=Xh("function"),$e=Xh("number"),EB=function(){var a=Array.prototype.indexOf,b=function(b,c){return a.call(b,c)},c=function(a,b){a:{for(var c=0,d=a.length;c<d;++c)if(a[c]===b){a=c;break a}a=-1}return a};return void 0===a?c:b}(),Gc=function(a,b){a=EB(a,b);return-1===a?g.none():g.some(a)},U=function(a,b){return-1<EB(a,b)},Xa=function(a,b){return Va(a,b).isSome()},
  j1=function(a,b){for(var c=[],d=0;d<a;d++)c.push(b(d));return c},k1=function(a,b){for(var c=[],d=0;d<a.length;d+=b){var e=a.slice(d,d+b);c.push(e)}return c},E=function(a,b){for(var c=a.length,d=Array(c),e=0;e<c;e++)d[e]=b(a[e],e,a);return d},z=function(a,b){for(var c=0,d=a.length;c<d;c++)b(a[c],c,a)},l1=function(a,b){for(var c=a.length-1;0<=c;c--)b(a[c],c,a)},m1=function(a,b){for(var c=[],d=[],e=0,f=a.length;e<f;e++){var h=a[e];(b(h,e,a)?c:d).push(h)}return{pass:c,fail:d}},ka=function(a,b){for(var c=
  [],d=0,e=a.length;d<e;d++){var f=a[d];b(f,d,a)&&c.push(f)}return c},fm=function(a,b){if(0===a.length)return[];for(var c=b(a[0]),d=[],e=[],f=0,h=a.length;f<h;f++){var l=a[f],g=b(l);g!==c&&(d.push(e),e=[]);c=g;e.push(l)}0!==e.length&&d.push(e);return d},Eb=function(a,b,c){l1(a,function(a){c=b(c,a)});return c},hb=function(a,b,c){z(a,function(a){c=b(c,a)});return c},qa=function(a,b){for(var c=0,d=a.length;c<d;c++){var e=a[c];if(b(e,c,a))return g.some(e)}return g.none()},Va=function(a,b){for(var c=0,d=
  a.length;c<d;c++)if(b(a[c],c,a))return g.some(c);return g.none()},n1=Array.prototype.push,Qb=function(a){for(var b=[],c=0,d=a.length;c<d;++c){if(!Array.prototype.isPrototypeOf(a[c]))throw Error("Arr.flatten item "+c+" was not an array, input: "+a);n1.apply(b,a[c])}return b},ia=function(a,b){a=E(a,b);return Qb(a)},ob=function(a,b){for(var c=0,d=a.length;c<d;++c)if(!0!==b(a[c],c,a))return!1;return!0},FB=Array.prototype.slice,jd=function(a){a=FB.call(a,0);a.reverse();return a},Hq=function(a,b){return ka(a,
  function(a){return!U(b,a)})},uT=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},GB=function(a){return[a]},bs=qb(Array.from)?Array.from:function(a){return FB.call(a)},Vf="undefined"!==typeof window?window:Function("return this;")(),bh=function(a,b){a=a.split(".");b=void 0!==b&&null!==b?b:Vf;for(var c=0;c<a.length&&void 0!==b&&null!==b;++c)b=b[a[c]];return b},cs=function(a,b){a=a.split(".");var c=void 0!==b?b:Vf;for(b=0;b<a.length;++b){var d=a[b];if(void 0===
  c[d]||null===c[d])c[d]={};c=c[d]}return c},Jc={getOrDie:function(a,b){b=bh(a,b);if(void 0===b||null===b)throw a+" not available on this browser";return b}},ak={isPrototypeOf:function(a){var b=bh("ownerDocument.defaultView",a);return Jc.getOrDie("HTMLElement",b).prototype.isPrototypeOf(a)}},bk=function(a,b,c,d,e,f){return{name:k(a),output:k(f||a),required:k(d),validate:function(d){if(!c(d))throw d=e(a,b),Error(d);}}},ck=function(a,b){return'value of "'+a+'" is not a '+b},ch=function(a,b){return'value of "'+
  a+'" is not an '+b},Af=function(a,b,c){return function(d,e){return bk(d,a,b,!0,c,e)}},HB=function(a){return ak.isPrototypeOf(a)},o1=function(a){return xa(a)||Mb(a)||ic(a)},ds=Af("array",Mb,ch),p1=Af("boolean",Ym,ck),q1=Af("function",qb,ck),r1=Af("number",$e,ck),s1=Af("object",ic,ch),t1=Af("string",xa,ck),u1=Af("DOM element",HB,ck),v1=Af("string or an array",function(a){return xa(a)||Mb(a)},ch),w1=Af("string or a DOM element",function(a){return xa(a)||HB(a)},ch),ba={arrayOfStrings:function(a){return bk(a,
  "array of strings",function(b){ds(a,void 0).validate(b);return ob(b,xa)},!0,ch,void 0)},arrayOfObjects:function(a){return bk(a,"array of objects",function(b){ds(a,void 0).validate(b);return ob(b,ic)},!0,ch,void 0)},arrayOfToolbarGroups:function(a){return bk(a,"array of toolbar groups",function(b){ds(a,void 0).validate(b);return ob(b,o1)},!0,ch,void 0)},bool:p1,domElement:u1,func:q1,number:r1,object:s1,string:t1,stringOrArray:v1,stringOrDom:w1,param:bk},CB={paramList:function(){return[ba.object("aria"),
  ba.func("fetch"),ba.func("menuComplete"),ba.func("menuExtra"),ba.func("menuHover"),ba.string("hoverSelector"),ba.func("hover")]},encodeWithEditorApi:function(){return["menuComplete"]}},x1=Object.prototype.hasOwnProperty,IB=function(a){return function(){for(var b=Array(arguments.length),c=0;c<b.length;c++)b[c]=arguments[c];if(0===b.length)throw Error("Can't merge zero objects");c={};for(var d=0;d<b.length;d++){var e=b[d],f;for(f in e)x1.call(e,f)&&(c[f]=a(c[f],e[f]))}return c}},oa=IB(function(a,b){return ic(a)&&
  ic(b)?oa(a,b):b}),ua=IB(function(a,b){return b}),cb=Object.keys,Ma=function(a,b){for(var c=cb(a),d=0,e=c.length;d<e;d++){var f=c[d];b(a[f],f,a)}},eb=function(a,b){return y1(a,function(a,d,e){return{k:d,v:b(a,d,e)}})},y1=function(a,b){var c={};Ma(a,function(d,e){d=b(d,e,a);c[d.k]=d.v});return c},Lf=function(a,b){var c=[];Ma(a,function(a,e){c.push(b(a,e))});return c},Q0=function(a,b){for(var c=cb(a),d=0,e=c.length;d<e;d++){var f=c[d],h=a[f];if(b(h,f,a))return g.some(h)}return g.none()},Ze=function(a){return Lf(a,
  function(a){return a})},es=function(a,b,c){return E(a,function(a){return b(a,c)})},fs=function(a,b){if(xa(a))return a;if(Mb(a))return es(a,fs,b);if(ic(a)&&void 0!==a.action)return b=Pb(a.action,b),ua(a,{action:b});b=es(a.items,fs,b);return oa(a,{items:b})},Vx={mentions:function(a,b){var c=CB.encodeWithEditorApi();return eb(a,function(a,e){return U(c,e)?function(c){return a(b(),c)}:a})},toolbar:function(a,b){return void 0===a.items?a:{items:es(a.items,fs,b)}}},Zm=function(a){return{is:function(b){return a===
  b},isValue:Jb,isError:ed,getOr:k(a),getOrThunk:k(a),getOrDie:k(a),or:function(b){return Zm(a)},orThunk:function(b){return Zm(a)},fold:function(b,c){return c(a)},map:function(b){return Zm(b(a))},each:function(b){b(a)},bind:function(b){return b(a)},exists:function(b){return b(a)},forall:function(b){return b(a)},toOption:function(){return g.some(a)}}},gs=function(a){return{is:ed,isValue:ed,isError:Jb,getOr:ca,getOrThunk:function(a){return a()},getOrDie:function(){return yb(String(a))()},or:function(a){return a},
  orThunk:function(a){return a()},fold:function(b,c){return b(a)},map:function(b){return gs(a)},each:t,bind:function(b){return gs(a)},exists:ed,forall:Jb,toOption:g.none}},J={value:Zm,error:gs},eT=function(){var a=(new Date).getTime();return String(a).slice(-6)},$m=window.Node,z1=window.URL,A1=window.Window,Hb=window.document,g_=window.navigator,Zg=window.window,Vh=window.clearInterval,rr=window.clearTimeout,Mr=window.setInterval,Sg=window.setTimeout,ud=window.console,dk=function(a){if(null===a||void 0===
  a)throw Error("Node cannot be null or undefined");return{dom:k(a)}},p={fromHtml:function(a,b){b=(b||Hb).createElement("div");b.innerHTML=a;if(!b.hasChildNodes()||1<b.childNodes.length)throw ud.error("HTML does not have a single root node",a),"HTML must have a single root node";return dk(b.childNodes[0])},fromTag:function(a,b){a=(b||Hb).createElement(a);return dk(a)},fromText:function(a,b){a=(b||Hb).createTextNode(a);return dk(a)},fromDom:dk,fromPoint:function(a,b,c){a=a.dom();return g.from(a.elementFromPoint(b,
  c)).map(dk)}},JB=$m.COMMENT_NODE,hs=$m.DOCUMENT_NODE,ek=$m.ELEMENT_NODE,KB=$m.TEXT_NODE,Ia={all:function(a,b){b=void 0===b?Hb:b.dom();return b.nodeType!==ek&&b.nodeType!==hs||0===b.childElementCount?[]:E(b.querySelectorAll(a),p.fromDom)},is:function(a,b){a=a.dom();if(a.nodeType!==ek)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");},one:function(a,b){b=void 0===b?Hb:b.dom();return b.nodeType!==ek&&b.nodeType!==hs||0===b.childElementCount?g.none():g.from(b.querySelector(a)).map(p.fromDom)}},LB=function(a){return a.dom().nodeName.toLowerCase()},is=function(a){return a.dom().nodeType},js=function(a){return function(b){return is(b)===a}},B1=js(ek),C1=js(KB),D1=js(hs),D={name:LB,type:is,value:function(a){return a.dom().nodeValue},isElement:B1,isText:C1,isDocument:D1,isComment:function(a){return is(a)===
  JB||"#comment"===LB(a)}},tT={one:function(a,b,c){var d=D.name(a);return g.from(b[d]).map(function(b){return b.replace(a,c)})}},mm={documentPositionPreceding:function(a,b){var c=Jc.getOrDie("Node").DOCUMENT_POSITION_PRECEDING;return 0!==(a.compareDocumentPosition(b)&c)},documentPositionContainedBy:function(a,b){var c=Jc.getOrDie("Node").DOCUMENT_POSITION_CONTAINED_BY;return 0!==(a.compareDocumentPosition(b)&c)}},Zb=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}},MB=function(){return ks(0,0)},ks=function(a,b){return{major:a,minor:b}},an={nu:ks,detect:function(a,b){b=String(b).toLowerCase();if(0===a.length)a=MB();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?ks(Number(b.replace(a,"$1")),Number(b.replace(a,"$2"))):{major:0,minor:0}}return a},unknown:MB},Yh=function(a,b){return function(){return b===a}},NB=function(a){var b=a.current;return{current:b,version:a.version,
  isEdge:Yh("Edge",b),isChrome:Yh("Chrome",b),isIE:Yh("IE",b),isOpera:Yh("Opera",b),isFirefox:Yh("Firefox",b),isSafari:Yh("Safari",b)}},E1=function(){return NB({current:void 0,version:an.unknown()})};k("Edge");k("Chrome");k("IE");k("Opera");k("Firefox");k("Safari");var dh=function(a,b){return function(){return b===a}},OB=function(a){var b=a.current;return{current:b,version:a.version,isWindows:dh("Windows",b),isiOS:dh("iOS",b),isAndroid:dh("Android",b),isOSX:dh("OSX",b),isLinux:dh("Linux",b),isSolaris:dh("Solaris",
  b),isFreeBSD:dh("FreeBSD",b)}},F1=function(){return OB({current:void 0,version:an.unknown()})};k("Windows");k("iOS");k("Android");k("Linux");k("OSX");k("Solaris");k("FreeBSD");var PB=function(a,b){var c=String(b).toLowerCase();return qa(a,function(a){return a.search(c)})},QB={detectBrowser:function(a,b){return PB(a,b).map(function(a){var c=an.detect(a.versionRegexes,b);return{current:a.name,version:c}})},detectOs:function(a,b){return PB(a,b).map(function(a){var c=an.detect(a.versionRegexes,b);return{current:a.name,
  version:c}})}},G1=function(a){return""===a?g.none():g.some(a.substr(0,1))},H1=function(a){return""===a?g.none():g.some(a.substring(1))},RB=function(a,b,c){return""===b?!0:a.length<b.length?!1:a.substr(c,c+b.length)===b},wB=function(a,b){return a.replace(/\$\{([^{}]*)\}/g,function(a,d){d=b[d];var c=typeof d;return"string"===c||"number"===c?d.toString():a})},fk=function(a,b){return Gb(a,b)?a.substring(b.length):a},gk=function(a,b){return je(a,b)?a.substring(0,a.length-b.length):a},Bb=function(a,b){return-1!==
  a.indexOf(b)},ls=function(a){return G1(a).bind(function(b){return H1(a).map(function(a){return b.toUpperCase()+a})}).getOr(a)},Gb=function(a,b){return RB(a,b,0)},je=function(a,b){return RB(a,b,a.length-b.length)},Zh=function(a){return a.replace(/^\s+|\s+$/g,"")},ms=/.*?version\/ ?([0-9]+)\.([0-9]+).*/,cg=function(a){return function(b){return Bb(b,a)}},I1=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(a){return Bb(a,"edge/")&&Bb(a,"chrome")&&Bb(a,"safari")&&Bb(a,"applewebkit")}},
  {name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,ms],search:function(a){return Bb(a,"chrome")&&!Bb(a,"chromeframe")}},{name:"IE",versionRegexes:[/.*?msie ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],search:function(a){return Bb(a,"msie")||Bb(a,"trident")}},{name:"Opera",versionRegexes:[ms,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:cg("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/ ?([0-9]+)\.([0-9]+).*/],search:cg("firefox")},{name:"Safari",versionRegexes:[ms,/.*?cpu os ([0-9]+)_([0-9]+).*/],
  search:function(a){return(Bb(a,"safari")||Bb(a,"mobile/"))&&Bb(a,"applewebkit")}}],J1=[{name:"Windows",search:cg("win"),versionRegexes:[/.*?windows nt ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:function(a){return Bb(a,"iphone")||Bb(a,"ipad")},versionRegexes:[/.*?version\/ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:cg("android"),versionRegexes:[/.*?android ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:cg("os x"),versionRegexes:[/.*?os x ?([0-9]+)_([0-9]+).*/]},
  {name:"Linux",search:cg("linux"),versionRegexes:[]},{name:"Solaris",search:cg("sunos"),versionRegexes:[]},{name:"FreeBSD",search:cg("freebsd"),versionRegexes:[]}],SB={browsers:k(I1),oses:k(J1)},K1={detect:function(a){var b=SB.browsers(),c=SB.oses();b=QB.detectBrowser(b,a).fold(E1,NB);c=QB.detectOs(c,a).fold(F1,OB);var d=c.isiOS()&&!0===/ipad/i.test(a),e=c.isiOS()&&!d,f=c.isAndroid()&&3===c.version.major,h=c.isAndroid()&&4===c.version.major;f=d||f||h&&!0===/mobile/i.test(a);var l=(h=c.isiOS()||c.isAndroid())&&
  !f;a=b.isSafari()&&c.isiOS()&&!1===/safari/i.test(a);a={isiPad:k(d),isiPhone:k(e),isTablet:k(f),isPhone:k(l),isTouch:k(h),isAndroid:c.isAndroid,isiOS:c.isiOS,isWebView:k(a)};return{browser:b,os:c,deviceType:a}}},aa={detect:Zb(function(){return K1.detect(navigator.userAgent)})},TB=function(a,b){return a.dom()===b.dom()},L1=function(a,b){a=a.dom();b=b.dom();return a===b?!1:a.contains(b)},M1=function(a,b){return mm.documentPositionContainedBy(a.dom(),b.dom())},N1=aa.detect().browser.isIE()?M1:L1,N={eq:TB,
  isEqualNode:function(a,b){return a.dom().isEqualNode(b.dom())},member:function(a,b){return Xa(b,u(TB,a))},contains:N1,is:Ia.is},UB=function(a){a=a.dom().body;if(null===a||void 0===a)throw"Body is not available yet";return p.fromDom(a)},ja={body:Zb(function(){return UB(p.fromDom(Hb))}),getBody:UB,inBody:function(a){a=D.isText(a)?a.dom().parentNode:a.dom();return void 0!==a&&null!==a&&a.ownerDocument.body.contains(a)}},VB=function(a,b,c){a=a.dom();for(c=qb(c)?c:k(!1);a.parentNode;){a=a.parentNode;var d=
  p.fromDom(a);if(b(d))return g.some(d);if(c(d))break}return g.none()},WB=function(a,b){return qa(a.dom().childNodes,Pb(b,p.fromDom)).map(p.fromDom)},XB=function(a,b){var c=function(a){for(var d=0;d<a.childNodes.length;d++){if(b(p.fromDom(a.childNodes[d])))return g.some(p.fromDom(a.childNodes[d]));var f=c(a.childNodes[d]);if(f.isSome())return f}return g.none()};return c(a.dom())},Ja={first:function(a){return XB(ja.body(),a)},ancestor:VB,closest:function(a,b,c){return Wx(function(a){return b(a)},VB,
  a,b,c)},sibling:function(a,b){var c=a.dom();return c.parentNode?WB(p.fromDom(c.parentNode),function(c){return!N.eq(a,c)&&b(c)}):g.none()},child:WB,descendant:XB},wd={any:function(a){return Ja.first(a).isSome()},ancestor:function(a,b,c){return Ja.ancestor(a,b,c).isSome()},closest:function(a,b,c){return Ja.closest(a,b,c).isSome()},sibling:function(a,b){return Ja.sibling(a,b).isSome()},child:function(a,b){return Ja.child(a,b).isSome()},descendant:function(a,b){return Ja.descendant(a,b).isSome()}},O=
  function(){for(var a=[],b=0;b<arguments.length;b++)a[b]=arguments[b];return function(){for(var b=[],d=0;d<arguments.length;d++)b[d]=arguments[d];if(a.length!==b.length)throw Error('Wrong number of arguments to struct. Expected "['+a.length+']", got '+b.length+" arguments");var e={};z(a,function(a,c){e[a]=k(b[c])});return e}},YB=function(a,b){throw Error("All required keys ("+a.slice(0).sort().join(", ")+") were not specified. Specified keys were: "+b.slice(0).sort().join(", ")+".");},ZB=function(a){throw Error("Unsupported keys for object: "+
  a.slice(0).sort().join(", "));},ns=function(a,b){if(!Mb(b))throw Error("The "+a+" fields must be an array. Was: "+b+".");z(b,function(b){if(!xa(b))throw Error("The value "+b+" in the "+a+" fields was not a string.");})},$B=function(a){var b=a.slice(0).sort();qa(b,function(a,d){return d<b.length-1&&a===b[d+1]}).each(function(a){throw Error("The field: "+a+" occurs more than once in the combined fields: ["+b.join(", ")+"].");})},Aa=function(a,b){var c=a.concat(b);if(0===c.length)throw Error("You must specify at least one required or optional field.");
  ns("required",a);ns("optional",b);$B(c);return function(d){var e=cb(d);ob(a,function(a){return U(e,a)})||YB(a,e);var f=ka(e,function(a){return!U(c,a)});0<f.length&&ZB(f);var h={};z(a,function(a){h[a]=k(d[a])});z(b,function(a){h[a]=k(Object.prototype.hasOwnProperty.call(d,a)?g.some(d[a]):g.none())});return h}},aC={toArray:function(a,b){var c=[],d=function(a){c.push(a);return b(a)};a=b(a);do a=a.bind(d);while(a.isSome());return c}},os=function(a){a=a.dom();return g.from(a.parentNode).map(p.fromDom)},
  bC=function(a){a=a.dom();return g.from(a.previousSibling).map(p.fromDom)},cC=function(a){a=a.dom();return g.from(a.nextSibling).map(p.fromDom)},bn=function(a){a=a.dom();return E(a.childNodes,p.fromDom)},ps=function(a,b){a=a.dom().childNodes;return g.from(a[b]).map(p.fromDom)},dC=O("element","offset"),A={owner:function(a){return p.fromDom(a.dom().ownerDocument)},defaultView:function(a){a=a.dom().ownerDocument.defaultView;return p.fromDom(a)},documentElement:function(a){return p.fromDom(a.dom().ownerDocument.documentElement)},
  parent:os,findIndex:function(a){return os(a).bind(function(b){b=bn(b);return Va(b,function(b){return N.eq(a,b)})})},parents:function(a,b){b=qb(b)?b:k(!1);var c=a.dom();for(a=[];null!==c.parentNode&&void 0!==c.parentNode;){c=c.parentNode;var d=p.fromDom(c);a.push(d);if(!0===b(d))break}return a},siblings:function(a){return os(a).map(bn).map(function(b){return ka(b,function(b){return!N.eq(a,b)})}).getOr([])},prevSibling:bC,offsetParent:function(a){a=a.dom();return g.from(a.offsetParent).map(p.fromDom)},
  prevSiblings:function(a){return jd(aC.toArray(a,bC))},nextSibling:cC,nextSiblings:function(a){return aC.toArray(a,cC)},children:bn,child:ps,firstChild:function(a){return ps(a,0)},lastChild:function(a){return ps(a,a.dom().childNodes.length-1)},childNodesCount:function(a){return a.dom().childNodes.length},hasChildNodes:function(a){return a.dom().hasChildNodes()},leaf:function(a,b){var c=bn(a);return 0<c.length&&b<c.length?dC(c[b],0):dC(a,b)}},eC=function(a){a.dom().focus()},qs=function(a){a=void 0!==
  a?a.dom():Hb;return g.from(a.activeElement).map(p.fromDom)},Z={hasFocus:function(a){var b=A.owner(a).dom();return a.dom()===b.activeElement},focus:eC,blur:function(a){a.dom().blur()},active:qs,search:function(a){return qs(A.owner(a)).filter(function(b){return a.dom().contains(b.dom())})},focusInside:function(a){var b=A.owner(a);qs(b).filter(function(b){return wd.closest(b,u(N.eq,a))}).fold(function(){eC(a)},t)}},cn=function(a,b){A.parent(a).each(function(c){c.dom().insertBefore(b.dom(),a.dom())})},
  hk=function(a,b){a.dom().appendChild(b.dom())},y={before:cn,after:function(a,b){A.nextSibling(a).fold(function(){A.parent(a).each(function(a){hk(a,b)})},function(a){cn(a,b)})},prepend:function(a,b){A.firstChild(a).fold(function(){hk(a,b)},function(c){a.dom().insertBefore(b.dom(),c.dom())})},append:hk,appendAt:function(a,b,c){A.child(a,c).fold(function(){hk(a,b)},function(a){cn(a,b)})},wrap:function(a,b){cn(a,b);hk(b,a)}},P={before:function(a,b){z(b,function(b){y.before(a,b)})},after:function(a,b){z(b,
  function(c,d){y.after(0===d?a:b[d-1],c)})},prepend:function(a,b){z(b.slice().reverse(),function(b){y.prepend(a,b)})},append:function(a,b){z(b,function(b){y.append(a,b)})}},rs=function(a){a=a.dom();null!==a.parentNode&&a.parentNode.removeChild(a)},F={empty:function(a){a.dom().textContent="";z(A.children(a),function(a){rs(a)})},remove:rs,unwrap:function(a){var b=A.children(a);0<b.length&&P.before(a,b);rs(a)}},fC=function(a,b,c){if(xa(c)||Ym(c)||$e(c))a.setAttribute(b,c+"");else throw ud.error("Invalid call to Attr.set. Key ",
  b,":: Value ",c,":: Element ",a),Error("Attribute value was not simple");},gC=function(a,b,c){fC(a.dom(),b,c)},hC=function(a,b){a=a.dom().getAttribute(b);return null===a?void 0:a},ss=function(a,b){return(a=a.dom())&&a.hasAttribute?a.hasAttribute(b):!1},m={clone:function(a){return hb(a.dom().attributes,function(a,c){a[c.name]=c.value;return a},{})},set:gC,setAll:function(a,b){var c=a.dom();Ma(b,function(a,b){fC(c,b,a)})},get:hC,has:ss,remove:function(a,b){a.dom().removeAttribute(b)},hasNone:function(a){a=
  a.dom().attributes;return void 0===a||null===a||0===a.length},transfer:function(a,b,c){D.isElement(a)&&D.isElement(b)&&z(c,function(c){ss(a,c)&&!ss(b,c)&&gC(b,c,hC(a,c))})}},af={isSupported:function(a){return void 0!==a.style}},ts=function(a,b,c){if(!xa(c))throw ud.error("Invalid call to CSS.set. Property ",b,":: Value ",c,":: Element ",a),Error("CSS value must be a string: "+c);af.isSupported(a)&&a.style.setProperty(b,c)},us=function(a,b,c){a=a.dom();ts(a,b,c)},iC=function(a,b){return af.isSupported(a)?
  a.style.getPropertyValue(b):""},dn=function(a,b){a=a.dom();b=iC(a,b);return g.from(b).filter(function(a){return 0<a.length})},O1=function(a,b,c){dn(a,c).each(function(a){dn(b,c).isNone()&&us(b,c,a)})},v={copy:function(a,b){a=a.dom();b=b.dom();af.isSupported(a)&&af.isSupported(b)&&(b.style.cssText=a.style.cssText)},set:us,preserve:function(a,b){var c=m.get(a,"style");b=b(a);(void 0===c?m.remove:m.set)(a,"style",c);return b},setAll:function(a,b){var c=a.dom();Ma(b,function(a,b){ts(c,b,a)})},setOptions:function(a,
  b){var c=a.dom();Ma(b,function(a,b){a.fold(function(){af.isSupported(c)&&c.style.removeProperty(b)},function(a){ts(c,b,a)})})},remove:function(a,b){var c=a.dom();af.isSupported(c)&&c.style.removeProperty(b);m.has(a,"style")&&""===Zh(m.get(a,"style"))&&m.remove(a,"style")},get:function(a,b){var c=a.dom(),d=Zg.getComputedStyle(c).getPropertyValue(b);a=""!==d||ja.inBody(a)?d:iC(c,b);return null===a?void 0:a},getRaw:dn,getAllRaw:function(a){var b={};a=a.dom();if(af.isSupported(a))for(var c=0;c<a.style.length;c++){var d=
  a.style.item(c);b[d]=a.style[d]}return b},isValidValue:function(a,b,c){a=p.fromTag(a);us(a,b,c);return dn(a,b).isSome()},reflow:function(a){return a.dom().offsetWidth},transfer:function(a,b,c){D.isElement(a)&&D.isElement(b)&&z(c,function(c){O1(a,b,c)})}},rT={blur:function(){var a=p.fromHtml('<input type="text" />');v.setAll(a,{"z-index":"-666",background:"transparent",border:"0px",height:"50px",position:"absolute",top:"25%",left:"50%"});y.append(p.fromDom(Hb.body),a);Z.focus(a);F.remove(a)}},P1=function(a){return[eb(a,
  function(a){return a()})]},hT={create:function(){var a=[];return{eventRegistry:{addListener:function(b){Tb(arguments,[ba.func("handler")]);a.push(b)},removeListener:function(b){Gc(a,b).each(function(b){a.splice(b,1)})}},eventTrigger:function(b){z(a,function(a){var c=P1(b);a.apply(null,c)})}}}},Ol={create:function(){var a=[],b=[];return{bind:function(c,d){if(U(a,c))throw"Invalid key, key already exists.";a.push(c);b.push(d);c.bind(d)},unbind:function(c){Gc(a,c).fold(function(){throw"Invalid key, does not exist.";
  },function(d){a.splice(d,1);d=b.splice(d,1)[0];c.unbind(d)})},unbindAll:function(){z(a,function(a,d){a.unbind(b[d])});a.splice(0,a.length);b.splice(0,b.length)}}}},jC=function(a){Object.freeze(a);Ma(a,function(a){ic(a)&&jC(a)});return a},Ql={makeReadOnly:jC},vs=function(a){var b=g.none(),c=[],d=function(a){e()?f(a):c.push(a)},e=function(){return b.isSome()},f=function(a){b.each(function(b){setTimeout(function(){a(b)},0)})};a(function(a){b=g.some(a);z(c,f);c=[]});return{get:d,map:function(a){return vs(function(b){d(function(c){b(a(c))})})},
  isReady:e}},lf={nu:vs,pure:function(a){return vs(function(b){b(a)})}},Q1=function(a){return function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];var d=this;setTimeout(function(){a.apply(d,b)},0)}},ik=function(a){var b=function(b){a(Q1(b))};return{map:function(a){return ik(function(c){b(function(b){b=a(b);c(b)})})},bind:function(a){return ik(function(c){b(function(b){a(b).get(c)})})},anonBind:function(a){return ik(function(c){b(function(b){a.get(c)})})},toLazy:function(){return lf.nu(b)},
  get:b}},Ea={nu:ik,pure:function(a){return ik(function(b){b(a)})}},Pl=function(a,b){return b(function(b){var c=[],e=0,f=function(d){return function(f){c[d]=f;e++;e>=a.length&&b(c)}};0===a.length?b([]):z(a,function(a,b){a.get(f(b))})})},Ce=function(a,b){a=E(a,b);return Pl(a,Ea.nu)},kC={install:function(a){var b=u(cs,a);cs("callbacks",b());var c=function(a){var b=void 0===a.count?0:a.count;a.count=b+1;return"callback_"+b},d=function(d,h){var f=b(),g=c(f);f.callbacks[g]=function(){h||e(g);d.apply(null,
  arguments)};return a+".callbacks."+g},e=function(a){a=a.substring(a.lastIndexOf(".")+1);var c=b();void 0!==c.callbacks[a]&&delete c.callbacks[a]};return{ephemeral:function(a){return d(a,!1)},permanent:function(a){return d(a,!0)},unregister:e}}},R1=function(a,b,c,d,e,f,h){return{target:k(a),x:k(b),y:k(c),stop:d,prevent:e,kill:f,raw:k(h)}},S1=function(a,b){return function(c){if(a(c)){var d=p.fromDom(c.target),e=function(){c.stopPropagation()},f=function(){c.preventDefault()},h=Pb(f,e);d=R1(d,c.clientX,
  c.clientY,e,f,h,c);b(d)}}},lC=function(a,b,c,d,e){c=S1(c,d);a.dom().addEventListener(b,c,e);return{unbind:u(T1,a,b,c,e)}},T1=function(a,b,c,d){a.dom().removeEventListener(b,c,d)},ws={bind:function(a,b,c,d){return lC(a,b,c,d,!1)},capture:function(a,b,c,d){return lC(a,b,c,d,!0)}},mC=k(!0),K={bind:function(a,b,c){return ws.bind(a,b,mC,c)},capture:function(a,b,c){return ws.capture(a,b,mC,c)}},U1=kC.install("ephox.henchman.features"),kT={download:function(a){return lf.nu(function(b){var c=function(){e.unbind();
  f.unbind()},d=p.fromTag("script");m.set(d,"src",a);m.set(d,"type","text/javascript");m.set(d,"async","async");m.set(d,"data-main",U1.ephemeral(function(a){b(J.value(a))}));var e=K.bind(d,"error",function(){c();b(J.error("Error loading external script tag "+a))}),f=K.bind(d,"load",c);y.append(p.fromDom(document.head),d)})}},nC={addStylesheet:function(a,b){var c=b||p.fromDom(Hb);b=p.fromTag("link",c.dom());m.setAll(b,{rel:"stylesheet",type:"text/css",href:a});a=p.fromDom(c.dom().head);y.append(a,b);
  return b}},jT={download:function(a,b){return lf.nu(function(c){var d=function(b){z(f,function(a){a.unbind()});c(b.fold(function(b){return J.error(b+'Unable to download editor stylesheets from "'+a+'"')},J.value))},e=nC.addStylesheet(a),f=[K.bind(e,"load",function(a){a:{try{var c=a.target().dom().sheet.cssRules;var e=ic(c)&&0===c.length;break a}catch(C){}e=!1}e?d(J.error("")):b(d)}),K.bind(e,"error",u(d,J.error("")))]})}},oC=Xx(),en={addStylesheet:function(a,b){return oC.addStylesheet(a,b)},addScript:function(a,
  b){return oC.addScript(a,b)}},fn=O("str","replace"),pC=function(a,b){return"2.4.2"!==a?g.some(b+(void 0===a?"":" version "+a)+" appears to be cached, as it does not match editor version 2.4.2."):g.none()},Uf={aboutTags:function(a,b){var c=[fn("@@FULL_VERSION@@","2.4.2.83"),fn("@@CLIENT_VERSION@@","2.4.2.131")];a=a?[fn("@@INTEGRATION_TYPE@@",b.type),fn("@@INTEGRATION_VERSION@@",b.version)]:[];return Qb([c,a])},strictMatch:pC,weakMatch:function(a,b){return pC(a,b).map(function(a){return a+" This may produce unexpected results."})},
  resourceParam:k("version=2.4.2"),fullParam:k("version=2.4.2.83")},na=function(a){var b=a;return{get:function(){return b},set:function(a){b=a},clone:function(){return na(b)}}},V1=function(a){a.each(function(a){Uf.weakMatch(a.version,"Code view").each(function(a){console.warn(a)});qC.set(a.codemirror());rC.set(a.jsbeautify())});return a},qC=na(null),rC=na(null),Rl={use:{codemirror:qC.get,jsbeautify:rC.get},load:{codeview:function(a){a=a+"/codeview.js?"+Uf.resourceParam();return en.addScript(a,V1)}}},
  gy={beautify:function(a){return Rl.use.jsbeautify().html(a,{indent_size:"2",indent_char:" ",max_preserve_newlines:"5",preserve_newlines:!0,keep_array_indentation:!1,break_chained_methods:!1,indent_scripts:"normal",brace_style:"collapse",space_before_conditional:!0,unescape_strings:!1,jslint_happy:!1,end_with_newline:!1,wrap_line_length:0,indent_inner_html:!1,comma_first:!1,e4x:!1})}},W1=function(a){return a.map(function(a){return a.dom()}).getOr(null)},Fd={documentElement:function(a){if(a.content().isInline())throw Error("documentElement called on inline mode");
  return W1(a.content().doc())},insertHtmlAtCursor:function(a,b){Tb(arguments,[ba.object("polish"),ba.string("html")]);a.content().focus();a.insertHtmlAtCursor(b)},uploadImages:function(a,b){Tb(arguments,[ba.object("polish"),ba.func("callback")]);return a.uploadImages(b)},get:function(a){var b=null!==Rl.use.jsbeautify()&&a.isPrettyPrinting();a=a.getContent();return b?gy.beautify(a):a},set:function(a,b){Tb(arguments,[ba.object("polish"),ba.string("html")]);a.setContent(b)},isDirty:function(a){Tb(arguments,
  [ba.object("polish")]);return a.isDirty()},setDirty:function(a,b){Tb(arguments,[ba.object("polish"),ba.bool("state")]);a.setDirty(b)}},ta={generate:function(a){if(!Mb(a))throw Error("cases must be an array");if(0===a.length)throw Error("there must be at least one case");var b=[],c={};z(a,function(d,e){var f=cb(d);if(1!==f.length)throw Error("one and only one name per case");var h=f[0],l=d[h];if(void 0!==c[h])throw Error("duplicate key detected:"+h);if("cata"===h)throw Error("cannot have a case named cata (sorry)");
  if(!Mb(l))throw Error("case arguments must be an array");b.push(h);c[h]=function(){var c=arguments.length;if(c!==l.length)throw Error("Wrong number of arguments to case "+h+". Expected "+l.length+" ("+l+"), got "+c);var d=Array(c);for(c=0;c<d.length;c++)d[c]=arguments[c];return{fold:function(){if(arguments.length!==a.length)throw Error("Wrong number of arguments to fold. Expected "+a.length+", got "+arguments.length);return arguments[e].apply(null,d)},match:function(a){var c=cb(a);if(b.length!==c.length)throw Error("Wrong number of arguments to match. Expected: "+
  b.join(",")+"\nActual: "+c.join(","));if(!ob(b,function(a){return U(c,a)}))throw Error("Not all branches were specified when using match. Specified: "+c.join(", ")+"\nRequired: "+b.join(", "));return a[h].apply(null,d)},log:function(a){console.log(a,{constructors:b,constructor:h,params:d})}}}});return c}},X1=ta.generate([{inputSelector:["selector","callback"]},{outputSelector:["selector","callback"]},{inputPredicate:["predicate","callback"]},{outputPredicate:["predicate","callback"]}]),hj=ua(X1,{cata:function(a,
  b,c,d,e){return a.fold(b,c,d,e)}}),Yx=function(a){return function(b){b=E(b,function(a){return a.dom()});a(b)}},mT=function(a){return function(b){return a(b.dom())}},mb=function(){return"\ufeff"},xs="\\w'\\-\\u0100-\\u017F\\u00C0-\\u00FF"+mb()+"\\u2018\\u2019",Y1="[^"+xs+"]",Z1="["+xs+"]",jk={chars:k(xs),wordbreak:k(Y1),wordchar:k(Z1)},gn={token:function(a){return yq(a,k(0),k(0),g.none())},word:function(a){a="((?:^'?)|(?:"+jk.wordbreak()+"+'?))"+a+"((?:'?$)|(?:'?"+jk.wordbreak()+"+))";return yq(a,
  function(a){return 1<a.length?a[1].length:0},function(a){return 2<a.length?a[2].length:0},g.none())}},ys=function(a){return a.replace(/[-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")},zs={sanitise:ys,word:function(a){a=ys(a);return gn.word(a)},token:function(a){a=ys(a);return gn.token(a)}},Cb={safeword:function(a){return zs.word(a)},safetoken:function(a){return zs.token(a)},custom:function(a,b,c,d){return yq(a,b,c,d)},unsafeword:function(a){return gn.word(a)},unsafetoken:function(a){return gn.token(a)},sanitise:function(a){return zs.sanitise(a)},
  chars:function(){return jk.chars()},wordbreak:function(){return jk.wordbreak()},wordchar:function(){return jk.wordchar()}},eh=function(a,b){return sC(a,b,{validate:qb,label:"function"})},sC=function(a,b,c){if(0===b.length)throw Error("You must specify at least one required field.");ns("required",b);$B(b);return function(d){var e=cb(d);ob(b,function(a){return U(e,a)})||YB(b,e);a(b,e);var f=ka(b,function(a){return!c.validate(d[a],a)});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}},$1=function(a,b){b=ka(b,function(b){return!U(a,b)});0<b.length&&ZB(b)},fh=t,xd=function(a){return eh($1,a)},hn=function(a,b){return sC(fh,a,b)},a2=eh(fh,["elements","cursor","dictation","notify"]),b2=eh(fh,["elements","cursor","dictation","range","notify"]),Zd={species:a2,applicator:b2},qe={fromHtml:function(a,b){b=(b||Hb).createElement("div");b.innerHTML=a;return A.children(p.fromDom(b))},fromTags:function(a,b){return E(a,function(a){return p.fromTag(a,
  b)})},fromText:function(a,b){return E(a,function(a){return p.fromText(a,b)})},fromDom:function(a){return E(a,p.fromDom)}},by={addSimpleMacro:function(a,b,c,d){Tb(arguments,[ba.object("polish"),ba.string("startString"),ba.string("endString"),ba.func("callback")]);var e=Zx(b,c,d);return a.macros().customMacros().add(e)},removeMacro:function(a,b){a.macros().customMacros().remove(b)}},tC=["error","info","warning"],qT={message:function(a,b,c,d){if(!U(tC,b))throw'Message level: "'+b+'" is not supported. Supported levels are: ['+
  tC.join(", ")+"].";Tb(arguments,[ba.object("polish"),ba.string("level"),ba.number("timeout"),ba.string("msg")]);var e=a.ui().showMessage(b,c,d);return{hide:function(){e()}}}},c2=k("pencil"),d2=k("code"),e2=k("spin"),f2=k("none"),hc={pencil:c2,code:d2,wait:e2,none:f2},ay={get:function(a){return a.getMode()===hc.pencil()?"design":"code"},set:function(a,b){Tb(arguments,[ba.object("polish"),ba.string("mode")]);var c=b.toLowerCase();if("code"!==c&&"design"!==c)throw Error('Editor mode "'+b+'" not supported. Must be either design or code.');
  a.setMode("design"===c?hc.pencil():hc.code())}},oT="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(" "),As=function(a,b){var c=[];z(A.children(a),function(a){b(a)&&(c=c.concat([a]));c=c.concat(As(a,b))});return c},cd={all:function(a){return As(ja.body(),a)},ancestors:function(a,b,c){return ka(A.parents(a,c),b)},siblings:function(a,b){return ka(A.siblings(a),b)},children:function(a,
  b){return ka(A.children(a),b)},descendants:As},Y={all:function(a){return Ia.all(a)},ancestors:function(a,b,c){return cd.ancestors(a,function(a){return Ia.is(a,b)},c)},siblings:function(a,b){return cd.siblings(a,function(a){return Ia.is(a,b)})},children:function(a,b){return cd.children(a,function(a){return Ia.is(a,b)})},descendants:function(a,b){return Ia.all(b,a)}},uC=function(a,b,c){return Ja.ancestor(a,function(a){return Ia.is(a,b)},c)},L={first:function(a){return Ia.one(a)},ancestor:uC,sibling:function(a,
  b){return Ja.sibling(a,function(a){return Ia.is(a,b)})},child:function(a,b){return Ja.child(a,function(a){return Ia.is(a,b)})},descendant:function(a,b){return Ia.one(b,a)},closest:function(a,b,c){return Wx(Ia.is,uC,a,b,c)}},Bs=$x(D.isText,"text"),Ya={get:function(a){return Bs.get(a)},getOption:function(a){return Bs.getOption(a)},set:function(a,b){Bs.set(a,b)}},g2=O("element","offset"),h2=O("element","deltaOffset"),i2=O("element","start","finish"),j2=O("begin","end"),k2=O("element","text"),W={point:g2,
  delta:h2,range:i2,points:j2,text:k2},jn=k(!1),l2=k(!0),Cs=function(a){return{isBoundary:function(){return a(l2,jn,jn)},fold:a,toText:function(){return a(g.none,g.none,function(a,c){return g.some(a)})},is:function(b){return a(jn,jn,function(a,d){return d.eq(a,b)})},len:function(){return a(k(0),k(1),function(a,c){return c.property().getText(a).length})}}},kn={text:function(a,b){return Cs(function(c,d,e){return e(a,b)})},boundary:function(a,b){return Cs(function(c,d,e){return c(a,b)})},empty:function(a,
  b){return Cs(function(c,d,e){return d(a,b)})},cata:function(a,b,c,d){return a.fold(b,c,d)}},m2={boundAt:function(a,b,c,d){b=Va(a,u(d,b)).getOr(0);c=Va(a,u(d,c)).map(function(a){return a+1}).getOr(a.length);return a.slice(b,c)}},n2={sliceby:function(a,b){b=Va(a,b).getOr(-1);return a.slice(0,b)}},Ds=ta.generate([{include:["item"]},{excludeWith:["item"]},{excludeWithout:["item"]}]),$h={include:Ds.include,excludeWith:Ds.excludeWith,excludeWithout:Ds.excludeWithout,cata:function(a,b,c,d){return a.fold(b,
  c,d)}},vC=function(a,b){var c=[],d=[];z(a,function(a){var e=b(a);$h.cata(e,function(){d.push(a)},function(){0<d.length&&c.push(d);c.push([a]);d=[]},function(){0<d.length&&c.push(d);d=[]})});0<d.length&&c.push(d);return c},wC={splitby:function(a,b){return vC(a,function(a){return b(a)?$h.excludeWithout(a):$h.include(a)})},splitbyAdv:vC},xC={splitby:function(a,b){return wC.splitby(a,b)},splitbyAdv:function(a,b){return wC.splitbyAdv(a,b)},sliceby:function(a,b){return n2.sliceby(a,b)},boundAt:function(a,
  b,c,d){return m2.boundAt(a,b,c,d)}},ln={count:function(a){return Eb(a,function(a,c){return c.len()+a},0)},dropUntil:function(a,b){return xC.sliceby(a,function(a){return a.is(b)})},gen:function(a,b){return a.fold(g.none,function(a){return g.some(W.range(a,b,b+1))},function(c){return g.some(W.range(c,b,b+a.len()))})},justText:function(a){return ia(a,function(a){return a.fold(k([]),k([]),function(a){return[a]})})}},mn=function(a,b,c){if(a.property().isText(b))return[kn.text(b,a)];if(a.property().isEmptyTag(b))return[kn.empty(b,
  a)];if(a.property().isElement(b)){var d=a.property().children(b),e=a.property().isBoundary(b)?[kn.boundary(b,a)]:[];b=void 0!==c&&c(b)?[]:ia(d,function(b){return mn(a,b,c)});return e.concat(b).concat(e)}return[]},yC=function(a,b,c,d,e){a=mn(a,d,e);b=ln.dropUntil(a,b);b=ln.count(b);return W.point(d,b+c)},ai={typed:mn,items:function(a,b,c){a=mn(a,b,c);var d=function(a,b){return a};return E(a,function(a){return a.fold(d,d,d)})},extractTo:function(a,b,c,d,e){return a.up().predicate(b,d).fold(function(){return W.point(b,
  c)},function(d){return yC(a,b,c,d,e)})},extract:function(a,b,c,d){return a.property().parent(b).fold(function(){return W.point(b,c)},function(e){return yC(a,b,c,e,d)})}},o2=function(a,b){return"img"===b.property().name(a)?" ":"\n"},p2={from:function(a,b,c){b=ai.typed(a,b,c);return E(b,function(b){return b.fold(k("\n"),o2,a.property().getText)}).join("")}},q2={make:function(a,b,c){return hb(a,function(a,c){return b(c,a.len).fold(k(a),function(b){return{len:b.finish(),list:a.list.concat([b])}})},{len:void 0!==
  c?c:0,list:[]}).list}},zC=function(a,b){return b>=a.start()&&b<=a.finish()},AC=function(a,b){return Va(a,function(a){return a.start()===b})},r2=function(a,b){return a[a.length-1]&&a[a.length-1].finish()===b?a.length+1:-1},nn={get:function(a,b){return qa(a,function(a){return zC(a,b)})},find:function(a,b){return qa(a,b)},inUnit:zC,sublist:function(a,b,c){b=AC(a,b);var d=AC(a,c);return b.bind(function(b){var e=d.getOr(r2(a,c));return-1<e?g.some(a.slice(b,e)):g.none()}).getOr([])}},BC={translate:function(a,
  b){return E(a,function(a){return ua(a,{start:k(a.start()+b),finish:k(a.finish()+b)})})}},s2=function(a,b,c){b=c(a,b);return BC.translate(b,a.start())},t2={splits:function(a,b,c){return 0===b.length?a:ia(a,function(a){var d=ia(b,function(b){return nn.inUnit(a,b)?[b-a.start()]:[]});return 0<d.length?s2(a,d,c):[a]})}},Rd={generate:function(a,b,c){return q2.make(a,b,c)},get:function(a,b){return nn.get(a,b)},find:function(a,b){return nn.find(a,b)},splits:function(a,b,c){return t2.splits(a,b,c)},translate:function(a,
  b){return BC.translate(a,b)},sublist:function(a,b,c){return nn.sublist(a,b,c)}},u2={find:function(a,b,c,d){a=ai.typed(a,b,d);a=Rd.generate(a,ln.gen);return Rd.get(a,c).map(function(a){return W.point(a.element(),c-a.start())})}},dg={extract:function(a,b,c,d){return ai.extract(a,b,c,d)},extractTo:function(a,b,c,d,e){return ai.extractTo(a,b,c,d,e)},all:function(a,b,c){return ai.items(a,b,c)},from:function(a,b,c){return ai.typed(a,b,c)},find:function(a,b,c,d){return u2.find(a,b,c,d)},toText:function(a,
  b,c){return p2.from(a,b,c)}},bi=nb(),Wh={extract:function(a,b,c){return dg.extract(bi,a,b,c)},extractTo:function(a,b,c,d){return dg.extractTo(bi,a,b,c,d)},all:function(a,b){return dg.all(bi,a,b)},from:function(a,b){return dg.from(bi,a,b)},find:function(a,b,c){return dg.find(bi,a,b,c)},toText:function(a,b){return dg.toText(bi,a,b)}},CC=function(a){var b=Object.create(null);Ma(a,function(a,d){b[d]=a});return b},v2=CC({img:!0,br:!0,hr:!0,input:!0}),w2=CC({script:!0,style:!0,noscript:!0}),x2=/[<>&\u00A0]/g,
  y2={"<":"&lt;",">":"&gt;","&":"&amp;","\u00a0":"&nbsp;"},z2=/["<>&]/g,A2={'"':"&quot;","<":"&lt;",">":"&gt;","&":"&amp;"},DC=function(a,b,c){return a.replace(b,function(a){return c[a]||a})},EC=function(a){for(var b="",c=0;c<a.length;c++){var d=a[c];d.specified&&"_moz_dirty"!==d.name&&(b+=" "+d.name+'="'+DC(d.value,z2,A2)+'"')}return b},GC=function(a){var b="";z(a,function(a){b+=FC(a)});return b},B2=function(a){var b="";z(a,function(a){b+=a.textContent});return b},FC=function(a){var b=a.nodeType;if(b===
  ek){b=a.nodeName.toLowerCase();var c=a.childNodes;a=a.attributes;0===c.length&&v2[b]?b="<"+b+EC(a)+" />":(c=w2[b]?B2(c):GC(c),b="<"+b+EC(a)+">"+c+"</"+b+">");return b}if(b===KB)return DC(a.textContent,x2,y2);if(b==JB)return"\x3c!--"+a.data+"--\x3e";throw"unsupported node type "+a.nodeType;},on={writeNode:function(a){if(!ic(a))throw"sugarNode parameter must be an object";return FC(a.dom())},writeChildren:function(a){if(!ic(a))throw"sugarNode parameter must be an object";return GC(a.dom().childNodes)}},
  HC=function(a){var b=new RegExp(mb(),"g");return a.replace(b,"")},Vj={output:function(a,b){a.filterDom(a.output(),b);a=on.writeChildren(b);return HC(a)},zeroWidth:HC},pn={toText:function(a){a=E(a,function(a){return Wh.toText(a,k(!1))}).join("");return Vj.zeroWidth(a.trim())},toHtml:function(a){a=E(a,on.writeNode).join("");return Vj.zeroWidth(a)}},IC=function(a){return a.dom().innerHTML},Ha={get:IC,set:function(a,b){var c=A.owner(a).dom(),d=p.fromDom(c.createDocumentFragment());b=qe.fromHtml(b,c);
  P.append(d,b);F.empty(a);y.append(a,d)},getOuter:function(a){var b=p.fromTag("div");a=p.fromDom(a.dom().cloneNode(!0));y.append(b,a);return IC(b)}},Vb={get:function(a){return a.dom().textContent},set:function(a,b){a.dom().textContent=b}},JC=function(a,b){return Ql.makeReadOnly({getAttributes:function(){return Ql.makeReadOnly(a.getFilteredAttributes(b))},setAttributes:function(c){Tb(arguments,[ba.object("attributes")]);Ma(c,function(a,b){if(!xa(a))throw Error("attribute key "+b+" does not have a string value: "+
  a);});m.setAll(b,c);a.domChanged();a.undoChanged()},getText:function(){return pn.toText([b])},setText:function(a){Tb(arguments,[ba.string("text")]);Vb.set(b,a)},getHtml:function(){return a.getFilteredContents(b)},setHtml:function(a){Tb(arguments,[ba.string("html")]);Ha.set(b,a)},replaceElement:function(c){Tb(arguments,[ba.string("html")]);var d=qe.fromHtml(c);if(1!==d.length)throw Error("replacement html must be a single node");d=d[0];a.replaceElement(b,d);return JC(a,d)}})},zq={getText:function(a){return a.content().getSelectedText().getOr("")},
  getHtml:function(a){return a.content().getSelectedHtml().getOr("")},findTagAtCursor:function(a,b){var c=a.content();return c.findTagAtCursor(b).map(function(a){return JC(c,a)}).getOr(null)}},KC={},LC=function(a){return g.from(KC[a])},Aq={get:LC,register:function(a,b){return KC[a]=b},hookup:function(a,b){LC(b).fold(function(){console&&console.error&&console.error('textbox.io Could not find plugin "'+b+'". Have you declared it?')},function(b){a.events.loaded.addListener(function(){b.initialize(a)})})}},
  MC={attached:function(a,b){b=b||p.fromDom(Hb.documentElement);return Ja.ancestor(a,u(N.eq,b)).isSome()},windowOf:function(a){var b=a.dom();return b===b.window&&a instanceof A1?a:D.isDocument(a)?b.defaultView||b.parentWindow:null}},NC=function(a,b){return{left:k(a),top:k(b),translate:function(c,d){return NC(a+c,b+d)}}},Qa=NC,qn=function(a,b){return void 0!==a?a:void 0!==b?b:0},OC=function(a){var b=a.dom(),c=b.ownerDocument,d=c.body;c=p.fromDom(c.documentElement);if(d===b)return Qa(d.offsetLeft,d.offsetTop);
  if(!MC.attached(a,c))return Qa(0,0);a=b.getBoundingClientRect();return Qa(a.left,a.top)},bb={absolute:function(a){var b=a.dom().ownerDocument,c=b.body,d=MC.windowOf(p.fromDom(b)),e=b.documentElement;b=qn(d.pageYOffset,e.scrollTop);d=qn(d.pageXOffset,e.scrollLeft);var f=qn(e.clientTop,c.clientTop);c=qn(e.clientLeft,c.clientLeft);return OC(a).translate(d-c,b-f)},relative:function(a){a=a.dom();return Qa(a.offsetLeft,a.offsetTop)},viewport:OC},C2=aa.detect().browser.isSafari(),rn=function(a){a=void 0!==
  a?a.dom():Hb;return Qa(a.body.scrollLeft||a.documentElement.scrollLeft,a.body.scrollTop||a.documentElement.scrollTop)},sn=function(a,b,c){(void 0!==c?c.dom():Hb).defaultView.scrollTo(a,b)},Es=function(a,b){C2&&qb(a.dom().scrollIntoViewIfNeeded)?a.dom().scrollIntoViewIfNeeded(!1):a.dom().scrollIntoView(b)},Za={get:rn,to:sn,by:function(a,b,c){(void 0!==c?c.dom():Hb).defaultView.scrollBy(a,b)},preserve:function(a,b){var c=rn(a);b();b=rn(a);c.top()===b.top()&&c.left()===b.left()||sn(c.left(),c.top(),
  a)},capture:function(a){var b=g.none(),c=function(){b=g.some(rn(a))};c();return{save:c,restore:function(){b.each(function(b){sn(b.left(),b.top(),a)})}}},intoView:Es,intoViewIfNeeded:function(a,b){b=b.dom().getBoundingClientRect();var c=a.dom().getBoundingClientRect();c.top<b.top?Es(a,!0):c.bottom>b.bottom&&Es(a,!1)},setToElement:function(a,b){b=bb.absolute(b);a=p.fromDom(a.document);sn(b.left(),b.top(),a)},scrollBarWidth:function(){var a=p.fromHtml('<div style="width: 100px; height: 100px; overflow: scroll; position: absolute; top: -9999px;"></div>');
  y.after(ja.body(),a);var b=a.dom().offsetWidth-a.dom().clientWidth;F.remove(a);return b}},PC={withOptions:function(a,b){return m.has(a,"tabindex")?oa(b,{content:{tabindex:m.get(a,"tabindex")}}):b}},QC=aa.detect(),D2=QC.browser.isIE()&&10===QC.browser.version.major,Fs=function(a,b){var c=v.getRaw(a,b).getOrThunk(function(){return v.get(a,b)});return D2&&"0px"===c?"auto":c},kk=function(a,b,c){a=Fs(a,b);return void 0===a?c:g.some(a)},E2=function(a){return{width:kk(a,"width",g.none()),"max-width":kk(a,
  "max-width",g.some("none")),"min-width":kk(a,"min-width",g.some("none")),"max-height":kk(a,"max-height",g.some("none")),"min-height":kk(a,"min-height",g.some("1em"))}},tn=function(a,b,c){var d=v.getRaw(b,"display"),e=Fs(b,"height");v.set(b,"display","none");var f=Fs(b,"height"),h=E2(b);d.fold(function(){v.remove(b,"display")},function(a){v.set(b,"display",a)});Ma(h,function(a,b){a.each(function(a){v.set(c,b,a)})});d="auto"===f?e:f;void 0!==d&&(!0===a?(v.set(c,"min-height",d),v.remove(c,"height")):
  v.set(c,"height",d));v.set(c,"display","flex")},F2=u(tn,!1),G2=u(tn,!0),H2=function(a){tn(!1,a,a)},I2=function(a){tn(!0,a,a)},RC=function(a){return a.replace(/\./g,"-")},Lb={create:function(a){var b=RC(a);return{resolve:function(a){a=a.split(" ");return E(a,function(a){return b+"-"+a}).join(" ")}}},cssNamespace:RC,cssClass:function(a,b){return a+"-"+b}},SC=Lb.create("ephox-elder"),un={resolve:SC.resolve,scrollable:u(SC.resolve,"scrollable")},Gs=function(a,b){a=m.get(a,b);return void 0===a||""===a?
  []:a.split(" ")},ff={read:Gs,add:function(a,b,c){c=Gs(a,b).concat([c]);m.set(a,b,c.join(" "));return!0},remove:function(a,b,c){var d=ka(Gs(a,b),function(a){return a!==c});0<d.length?m.set(a,b,d.join(" ")):m.remove(a,b);return!1}},TC=function(a){return ff.read(a,"class")},UC=function(a,b){return ff.add(a,"class",b)},VC=function(a,b){return ff.remove(a,"class",b)},kd={get:TC,add:UC,remove:VC,toggle:function(a,b){return U(TC(a),b)?VC(a,b):UC(a,b)},supports:function(a){return void 0!==a.dom().classList}},
  WC=function(a,b){return kd.supports(a)&&a.dom().classList.contains(b)},n={add:function(a,b){kd.supports(a)?a.dom().classList.add(b):kd.add(a,b)},remove:function(a,b){kd.supports(a)?a.dom().classList.remove(b):kd.remove(a,b);0===(kd.supports(a)?a.dom().classList:kd.get(a)).length&&m.remove(a,"class")},toggle:function(a,b){return kd.supports(a)?a.dom().classList.toggle(b):kd.toggle(a,b)},toggler:function(a,b){var c=kd.supports(a),d=a.dom().classList;return Bq(function(){c?d.remove(b):kd.remove(a,b)},
  function(){c?d.add(b):kd.add(a,b)},WC(a,b))},has:WC},ma={add:function(a,b){z(b,function(b){n.add(a,b)})},remove:function(a,b){z(b,function(b){n.remove(a,b)})},toggle:function(a,b){z(b,function(b){n.toggle(a,b)})},hasAll:function(a,b){return ob(b,function(b){return n.has(a,b)})},hasAny:function(a,b){return Xa(b,function(b){return n.has(a,b)})},get:function(a){if(kd.supports(a)){a=a.dom().classList;for(var b=Array(a.length),c=0;c<a.length;c++)b[c]=a.item(c);a=b}else a=kd.get(a);return a}},yf={addClass:function(a){return function(b){n.add(b,
  a)}},removeClass:function(a){return function(b){n.remove(b,a)}},removeClasses:function(a){return function(b){ma.remove(b,a)}},hasClass:function(a){return function(b){return n.has(b,a)}}},vn=g.none(),XC=un.resolve("modal-scroll-lock"),YC=function(a,b){z(b,function(b){a(b)})},J2=u(YC,yf.addClass(XC)),K2=u(YC,yf.removeClass(XC)),jf=function(a,b){var c=null,d=null;return{cancel:function(){null!==c&&(clearTimeout(c),d=c=null)},throttle:function(){for(var e=[],f=0;f<arguments.length;f++)e[f]=arguments[f];
  d=e;null===c&&(c=setTimeout(function(){a.apply(null,d);d=c=null},b))}}},tj=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)}}},H={create:function(a){var b=eb(a,function(a){return{bind:a.bind,unbind:a.unbind}});a=eb(a,function(a){return a.trigger});return{registry:b,trigger:a}}},Uc={register:function(a){n.add(a,
  un.scrollable())},deregister:function(a){n.remove(a,un.scrollable())},scrollable:un.scrollable,preserve:Za.preserve,capture:Za.capture,block:function(){if(vn.isNone()){var a=Za.get(),b=K.bind(p.fromDom(window),"scroll",function(b){b=Za.get();b.left()===a.left()&&b.top()===a.top()||window.scrollTo(a.left(),a.top())});vn=g.some(b)}},unblock:function(){vn.each(function(a){a.unbind();vn=g.none()})},lock:J2,unlock:K2,event:function(a){var b=!1,c=H.create({started:r([]),stopped:r([])}),d=tj(function(){!0===
  b&&(b=!1,c.trigger.stopped())},250),e=K.bind(a,"scroll",function(){!1===b&&c.trigger.started();b=!0;d.throttle()});return{events:c.registry,destroy:function(){e.unbind()},isScrolling:function(){return b}}}},xf={isEmpty:function(a){return null===a||void 0===a||""===a||Mb(a)&&0===a.length}},wn=Xx(),Hs={preload:function(){wn.preload()},addStylesheet:function(a,b){return wn.addStylesheet(a,b)},addScript:function(a,b){return wn.addScript(a,b)},waitForLoad:function(){return wn.waitForLoad()}},ZC=function(){return{zh_hk:"zh_tw",
  iw:"he",no:"nb",nn:"nb",en:"en",ar:"ar",ca:"ca",cs:"cs",da:"da",de:"de",el:"el",es:"es",fa:"fa",fi:"fi",fr:"fr",he:"he",hr:"hr",hu:"hu",it:"it",ja:"ja",kk:"kk",ko:"ko",nl:"nl",nb:"nb",pl:"pl",pt:"pt",pt_pt:"pt_pt",ro:"ro",ru:"ru",sl:"sl",sk:"sk",sv:"sv",th:"th",tr:"tr",uk:"uk",zh:"zh",zh_tw:"zh_tw"}},$C=function(a){a=a.toLowerCase().replace("-","_");var b=a.indexOf(";");a=-1<b?a.substring(0,b):a;a=Zh(a);b=a.indexOf("_");b=-1<b?a.substring(0,b):a;return{full:a,languageCode:b}},aD=function(a,b){a=a.split(",");
  a=E(a,function(a){a=$C(a);return b[a.full]||b[a.languageCode]||""});return qa(a,function(a){return""!==a})},Is={extract:$C,determine:function(a){var b=ZC();return aD(a,b)},determineFrom:aD,localeList:ZC},ee=function(a){for(var b=[],c=function(a){b.push(a)},d=0;d<a.length;d++)a[d].each(c);return b},yc=function(a,b){for(var c=0;c<a.length;c++){var d=b(a[c],c);if(d.isSome())return d}return g.none()},bD=function(){var a=bh("navigator")||{};return a.userLanguage||a.language||"en"}(),cD=g.none(),qf={determine:function(a){var b=
  void 0!==a?[a,bD]:[bD];return yc(b,Is.determine).fold(function(){console.warn("WARNING: locales not supported: "+b.join(", "));return"en"},ca)},get:function(){return cD.getOrDie("locale used before it has been set")},set:function(a){cD=g.from(a)}},L2={font:{arial:"Arial",courier:"Courier New",comicsans:"Comic Sans MS",consolas:"Consolas",georgia:"Georgia",impact:"Impact",tahoma:"Tahoma",timesnr:"Times New Roman",trebuchet:"Trebuchet MS",verdana:"Verdana"},error:{duplicate:{code:"That snippet code is already taken.",
  uuid:"That snippet uuid is already taken."},unknown:{uuid:"The snippet uuid cannot be found"},code:{duplicate:"That snippet code is already taken."}},cog:{login:"Log in",logout:"Log out","not-logged-in":"Not logged in",user:"User: {0}"},banner:{"logged-in":"Logged in as: {0}"}},dD={},eD="",Js={},fD=function(a){return bh(a,Js)||bh(a,dD)||bh(a,L2)},gh={loadEnglish:function(a){dD=a},load:function(a,b){eD=a;Js=b;qf.set(a)},isLoaded:function(a){return eD===a&&0<cb(Js).length},get:function(a){var b=fD(a);
  if(xa(b))return b;throw Error("key "+a+" does not exist");},has:function(a){if(!xa(a))throw a.fold?console.error("object details were",a.fold(ca,ca,ca)):console.error("object key was",a),"key was an object";return xa(fD(a))}},Ks=g.none(),Ls={set:function(a){Ks.fold(function(){Ks=g.some(a)},function(b){b!==a&&console.error('Only one base URL supported per page. Requested value "'+a+'", already using "'+b+'"')})},get:function(){return Ks.getOrDie("Must begin loading with a base URL")}},M2={execute:function(a){if("complete"===
  Hb.readyState||"interactive"===Hb.readyState)a();else var b=K.bind(p.fromDom(Hb),"DOMContentLoaded",function(){a();b.unbind()})}},xn=cy("width",function(a){return a.dom().offsetWidth}),Ga={set:function(a,b){xn.set(a,b)},get:function(a){return xn.get(a)},getOuter:function(a){return xn.getOuter(a)},setMax:function(a,b){b=xn.max(a,b,"margin-left border-left-width padding-left padding-right border-right-width margin-right".split(" "));v.set(a,"max-width",b+"px")}},gD=function(){var a=p.fromTag("div");
  n.add(a,"ephox-textbox-font");var b=p.fromTag("span");n.add(b,"ephox-chameleon-icon");y.append(a,b);y.append(ja.body(),a);var c=Ga.get(b);b=v.get(b,"font-family");F.remove(a);return 0<c&&void 0!==b&&Bb(b,"Textbox Icons")},N2=function(a){var b=0,c=setInterval(function(){b+=250;gD()?(clearInterval(c),a(!0)):2E3<b&&(clearInterval(c),a(!1))},250)},O2={wait:Zb(function(){return lf.nu(function(a){M2.execute(function(){gD()?a(!0):N2(a)})})})},P2=function(a){O2.wait().get(function(b){a(b?J.value(!0):J.error("Stylesheet loaded, but did not contain Textbox.io styles"))})},
  hD=function(a,b){a=a+"/i18n/tbio_"+b+".js?"+Uf.resourceParam();return Hs.addScript(a,function(a){return a.bind(function(a){return Uf.strictMatch(a.version,"Language strings").fold(function(){return J.value(a.strings())},J.error)})})},iD=function(a){var b="/textboxio.css?"+Uf.fullParam();Hs.addStylesheet(a+b,P2)},Yj={load:function(a){Ls.set(a);a=Ls.get();iD(a+"/css");hD(a,"en").get(function(a){a.each(gh.loadEnglish)});return a},devLoad:iD,setLanguage:function(a){var b=qf.determine(a);gh.isLoaded(b)||
  (a=Ls.get(),hD(a,b).get(function(a){a.each(function(a){gh.load(b,a)})}))},waitForLoad:function(){return Hs.waitForLoad()},getFailures:function(a){return ia(a,function(a){return a.fold(function(a){return[a]},k([]))})}},T={span:function(a){a=p.fromTag("span",a);m.set(a,"role","presentation");return a},div:function(a){a=p.fromTag("div",a);m.set(a,"role","presentation");return a},tag:function(a,b){a=p.fromTag(a,b);m.set(a,"role","presentation");return a}},B={resolve:Lb.create("ephox-polish").resolve},
  Db={any:function(a){return L.first(a).isSome()},ancestor:function(a,b,c){return L.ancestor(a,b,c).isSome()},sibling:function(a,b){return L.sibling(a,b).isSome()},child:function(a,b){return L.child(a,b).isSome()},descendant:function(a,b){return L.descendant(a,b).isSome()},closest:function(a,b,c){return L.closest(a,b,c).isSome()}},Ms=B.resolve("highcontrast-mode"),Q2=function(a){var b=p.fromTag("div");n.add(b,B.resolve("highcontrast-detect"));y.append(a,b);v.reflow(b);(!0===("none"===v.get(b,"background-image")?
  !0:!1)?n.add:n.remove)(a,Ms);F.remove(b)},R2=function(a){var b=p.fromDom(document.documentElement);(!0===(m.has(b,"hc")&&m.has(b,"hcx"))?n.add:n.remove)(a,Ms)},S2=t,kj={detect:function(a){var b=aa.detect();b.os.isWindows()&&(b.browser.isIE()||b.browser.isEdge()||b.browser.isFirefox()?Q2:b.browser.isChrome()?R2:S2)(a)},isHighContrast:function(a){return Db.ancestor(a.uiContainer(),"."+Ms)}},hy=Aa(["width","docWidth","height","docHeight"],[]),jD=ta.generate([{unchanged:["html"]},{changed:["html"]}]),
  Jf={unchanged:jD.unchanged,changed:jD.changed,cata:function(a,b,c){return a.fold(b,c)}},kD=function(){return{validate:function(a,b){return qb(a)||"events"===b&&ic(a)},label:"Function (or events)"}}(),lD="activateInline communication connect content deactivateInline element events filter focus getContent getMode insertHtmlAtCursor isDirty isPrettyPrinting keyboard macros operations setContent setDirty smartview state ui undo".split(" "),T2=hn(lD.concat([]),kD),U2=hn(lD.concat("blur destroy fromTransfer fullscreen uploader toTransfer viewport".split(" ")),
  kD),jj={external:T2,internal:U2},V2={create:function(){var a=!1;return{isBlocked:function(){return a},block:function(){a=!0},unblock:function(){a=!1}}}},W2={create:function(a,b){return{control:a,instance:b}}},Hd={tap:function(a){var b=V2.create();return W2.create(b,function(){b.isBlocked()||a.apply(null,arguments)})}},mD=0,Fa=function(a){var b=(new Date).getTime(),c=Math.floor(1E9*Math.random());mD++;return a+"_"+c+mD+String(b)},nD={isFunctionOrEvents:function(a){var b=function(b){return!0===ob(a,
  function(a){return void 0!==b[a]&&void 0!==b[a].bind&&qb(b[a].bind)})?!0:!1};return{validate:function(a,d){return qb(a)||"events"===d&&ic(a)&&b(a)},label:"Function (or events)"}}},Dq=hn("events init ui check scanView situation hasDropdown hasAutocorrect handle assign lock destroy state lookup name".split(" "),nD.isFunctionOrEvents(["analytics"])),Ig={noSituation:function(){return{primary:k([]),secondary:k([]),submenus:k({})}},basic:function(){return{destroy:t,ui:g.none,state:k({}),events:Gd(["analytics"])}}},
  oD=function(a,b){var c={};Ma(a,function(a,b){var d=b.split(".");if(1>=d.length)c[b]={finalvalue:a};else{var e=c;cs(b,c);for(b=0;b<d.length-1;b++)e=e[d[b]];e[d[d.length-1]]={finalvalue:a}}});var d=function(a){var c={},e=cb(a);z(e,function(e){c[e]=void 0!==a[e].finalvalue?b(a[e].finalvalue):k(d(a[e]))});return c};return d(c)},vb={ui:function(a,b){a=oD(a,void 0!==b?b:k);return k(g.some(a))},actions:function(a){a=oD(a,ca);return k(a)}},Sa={basic:Ig.basic,draganddrop:function(){return{events:Gd(["insertAssets",
  "insertHtml"]),destroy:t}},communication:function(){return{headers:k({}),destroy:t}},fullscreen:function(){return{ui:g.none,actions:vb.actions({maximize:t,restore:t}),select:t,deselect:t,destroy:t,events:Gd(["analytics","maximize","restore"])}},dialog:function(){return{destroy:t,ui:g.none,events:Gd(["analytics"]),actions:vb.actions({show:t})}},spelling:function(){return vT()},editorcontext:function(){return{events:Gd(["blockChanged","enterDown","enterUp"]),destroy:t}},highlighter:function(){return{destroy:t,
  run:t}},linkvalidator:function(){return{destroy:t,refresh:t,ignore:t,state:k({ignore:[],cache:{}})}},macros:function(){return{events:Gd(["analytics"]),state:k({}),customMacros:k(Cq({})),destroy:t}},table:function(){return{ui:g.none,state:k({}),events:Gd(["analytics"]),situation:Ig.noSituation,handle:t,assign:t,destroy:t,name:k("table-disabled")}},image:function(){return{events:Gd(["changed","contextmenu"]),situation:Ig.noSituation,handle:t,assign:t,destroy:t,name:k("image-disabled")}},imageEdit:function(){var a=
  function(a,b){return Ea.pure(E(b,Pb(J.value,a)))},b=u(a,ca);a=u(a,function(a){return a.asset()});return{situation:Ig.noSituation,handle:t,assign:t,ui:g.none,destroy:t,insertResample:k({assets:b,correlated:a,destroy:t}),name:k("imageEdit-disabled")}},mobile:function(){return{ui:g.none,events:Gd(["fullscreen"]),destroy:t}},noAnalytics:function(){return{log:t,register:t}},state:function(a){var b=dy(a.laundry),c=ey(a.filters,t,t),d=Cq(a.macros.customs);return{filter:k({customFilters:k(c)}),macros:k({customMacros:k(d)}),
  laundry:b,getState:function(e){return ua(a,void 0===e?{}:e,{laundry:b.state(),filters:c.state(),macros:{customs:d.state()}})}}},uploader:function(){var a=H.create({reconstitute:r([]),uploadAssets:r(["assets"])});return{destroy:t,events:a.registry,reconstitute:t,uploadAssets:t}},undo:function(){return{reset:t,disable:xb,save:t}}},Id={activateInline:t,deactivateInline:t,communication:Sa.communication,events:function(){return H.create({loaded:r([]),focus:r([]),dirty:r([]),change:r([]),internal:r(["command",
  "data"]),paint:r([])}).registry},keyboard:yb("the keyboard feature is not implemented in this mode"),operations:yb("the operations feature is not implemented in this mode"),smartview:yb("the smartview feature is not implemented in this mode"),ui:yb("the ui feature is not implemented in this mode")},yn=cy("height",function(a){var b=a.dom();return ja.inBody(a)?b.getBoundingClientRect().height:b.offsetHeight}),sa={set:function(a,b){yn.set(a,b)},get:function(a){return yn.get(a)},getOuter:function(a){return yn.getOuter(a)},
  setMax:function(a,b){b=yn.max(a,b,"margin-top border-top-width padding-top padding-bottom border-bottom-width margin-bottom".split(" "));v.set(a,"max-height",b+"px")}},X2="undo insert style emphasis align listindent format tools".split(" "),eg=O("x","y","width","height"),Y2={intersect:function(a,b){var c=Math.max(a.x(),b.x()),d=Math.max(a.y(),b.y()),e=Math.min(a.x()+a.width(),b.x()+b.width());e=Math.max(0,e-c);a=Math.min(a.y()+a.height(),b.y()+b.height());return eg(c,d,e,Math.max(0,a-d))}},Ge=ta.generate([{unbundled:[]},
  {unsupported:["message"]},{item:["info","blueprint"]},{customMenu:["info","groups","blueprint"]},{textboxMenu:["info","blueprint"]},{palette:["info","children","blueprint"]}]),pD={create:function(a){var b=function(a,b){return a.feature.fold(function(){return void 0!==a.unsupported?[Ge.unsupported(a.unsupported)]:[Ge.unbundled()]},function(c){if(void 0===c[a.command])return console.warn("unknown command: "+a.command),[];c=c[a.command]();return[b(c)]})},c=function(a,c){return b(c,function(b){return U(["widget",
  "inline-widget","split-widget"],c.type)?Ge.item({instance:b.widget},a[c.type]):Ge.item(b[c.type](),a[c.type])})},d={dropdown:c,general:c,widget:c,"split-widget":c,"inline-widget":c,palette:function(a,c){return b(c,function(b){b=b.palette();var c=E(b.items,function(b){return U(["widget","inline-widget","split-widget"],b.type)?Ge.item({instance:b.build},a[b.type]):U(["dropdown"],b.type)?Ge.item(b.build(),a[b.type]):Ge.item(b.spec,a[b.type])});return Ge.palette(b,c,a.palette)})},submenu:function(b,c){var d=
  E(c.commands,a);return[Ge.customMenu(c,d,b.menu)]},menu:function(a,c){return b(c,function(b){return Ge.textboxMenu(b[c.type](),a[c.type])})}};return{classify:function(a,b){var c=d[b.type];return void 0!==c?c(a,b):[]}}},cata:function(a,b,c,d,e,f,h){return a.fold(b,c,d,e,f,h)}},Z2={fromConfig:function(a,b,c){var d=function(a,b){a=u(e.classify,a);a=ia(b.items,a);return{category:b.category,books:a}};a=u(d,a);b=u(d,b);var e=pD.create(b);return E(c,a)}},va={resolve:Lb.create("ephox-chameleon").resolve},
  lj={show:function(a){v.remove(a,"display")},hide:function(a){v.set(a,"display","none")},isShowing:function(a){return v.getRaw(a,"display").isNone()},isHiding:function(a){return v.getRaw(a,"display").is("none")}},iy={group:eh(fh,["component","isVisible","refreshUi","destroy"])},Nq={menu:function(a,b){var c=H.create({done:r([]),abort:r(["item"])}),d=function(a){a.done.bind(function(){c.trigger.done()});a.abort.bind(function(a){c.trigger.abort(a.item())});return ua(a,{done:c.registry.done,abort:c.registry.abort})},
  e=Eb(b,function(a,b){var c=ua(b.structure(),a.structures),e=b.submenus().concat(a.submenus),f=ua(b.handlers(),a.actions),h=[b.refreshMenu].concat(a.refreshMenu);a=[b.destroyer].concat(a.destroyers);b=d(b.events);return{structures:c,submenus:e,refreshMenu:h,actions:f,destroyers:a,events:b}},{structures:{},submenus:[],actions:{},refreshMenu:[],destroyers:[],events:{}});return{structure:k(e.structures),init:function(a){z(e.refreshMenu,xb)},name:k(a),handlers:k(e.actions),submenus:k(e.submenus),events:e.events,
  destroy:function(){z(e.destroyers,xb)}}},toolbar:function(a){a=xT(a);var b=H.create({escaped:r([]),executed:r([])});return iy.group({component:a.component,isVisible:a.isVisible,refreshUi:a.refreshUi,destroy:a.destroy,events:b.registry})}},qD=function(a,b){n.add(a,va.resolve("user-icon"));v.setAll(a,{"background-image":"url("+b+")"})},zn={setUrl:qD,findAndSetUrl:function(a,b){L.descendant(a,".ephox-pastry-icon-content").each(function(a){qD(a,b)})}},An=function(a,b){m.set(a,"aria-pressed",b?"true":
  "false")},ra={expanded:function(a){m.set(a,"aria-expanded","true")},collapsed:function(a){m.set(a,"aria-expanded","false")},checked:function(a,b){m.set(a,"aria-checked",String(b))},setPressed:An,press:function(a){An(a,!0)},release:function(a){An(a,!1)},pressed:function(a){An(a.element(),a.selected())},enable:function(a){m.set(a,"aria-disabled","false")},disable:function(a){m.set(a,"aria-disabled","true")},tabSelected:function(a,b){m.setAll(a,{"aria-selected":"true","aria-pressed":"true"});z(b,function(a){m.setAll(a,
  {"aria-selected":"false","aria-pressed":"false"})})},showPanel:function(a){m.set(a,"aria-selected","true");m.set(a,"aria-hidden","false")},hidePanel:function(a){m.set(a,"aria-selected","false");m.set(a,"aria-hidden","true")}},$2=function(a){a.enable();ra.enable(a.element())},a3=function(a){a.disable();ra.disable(a.element())},Kq={control:function(a){return{enable:u($2,a),disable:u(a3,a)}},ariaPressed:function(a){return{press:u(ra.press,a.element()),release:u(ra.release,a.element())}}},Bn=function(a){var b=
  a.replace(/\./g,"-");return{resolve:function(a){return b+"-"+a}}},lk={resolve:Bn("ephox-echo").resolve},b3=lk.resolve("aria-help"),c3=lk.resolve("aria-help-visible"),Cn=function(a){m.set(a,"role","presentation")},rD=function(a,b){m.setAll(a,{role:"application","aria-label":b})},sD=function(a){m.set(a,"role","button")},Ns=function(a,b){m.set(a,"aria-owns",b)},tD=function(a,b){m.set(a,"aria-controls",b)},uD=function(a,b){var c=Fa("ephox-aria");m.set(b,"id",c);tD(a,c)},vD=function(a,b){m.set(a,"aria-describedby",
  b)},wD=function(a,b){m.set(a,"aria-labelledby",b)},Dn=function(a,b){m.set(a,"aria-label",b)},S={document:function(a){m.set(a,"role","document")},presentation:Cn,region:function(a){m.set(a,"role","region")},controls:tD,owns:Ns,disown:function(a){m.remove(a,"aria-owns")},editor:function(a,b,c,d,e){rD(a,c);d.each(function(c){var d=p.fromTag("span");Cn(d);y.append(d,p.fromText(c));c=Fa("ephox-aria");m.set(d,"id",c);vD(b,c);n.add(d,b3);!0===e&&n.add(d,c3);y.append(a,d)});return{destroy:function(){m.remove(b,
  "aria-describedby")}}},inline:function(a,b,c,d,e){rD(a,c);var f=[];m.has(b,"id")?Ns(a,m.get(b,"id")):(c=Fa("ephox-aria-content"),m.set(b,"id",c),Ns(a,c),f.push(function(){m.remove(b,"id")}));d.each(function(a){if(m.has(b,"aria-label")){var c=m.get(b,"aria-label");Dn(b,a);f.push(function(){Dn(b,c)})}else Dn(b,a),f.push(function(){m.remove(b,"aria-label")})});return{destroy:function(){z(f,xb)}}},group:function(a){m.set(a,"role","group")},toolbar:function(a,b){m.setAll(a,{role:"group","aria-label":b})},
  toolbarGroup:function(a,b){m.set(a,"role","toolbar");null===b||void 0===b||""===b||Mb(b)&&0===b.length||m.set(a,"aria-label",b)},toolbarButton:function(a,b,c,d){m.setAll(a,{role:"button","aria-label":b,"aria-haspopup":""+c});d&&m.set(a,"aria-pressed","false");c&&m.set(a,"aria-expanded","false")},textButton:function(a,b){sD(a);Cn(b)},menu:function(a,b){m.setAll(a,{"aria-label":b,role:"menu"})},menuItem:function(a,b,c){b=b.map(function(a){return{"aria-label":a}}).getOr({});m.setAll(a,ua(b,{role:"menuitem",
  "aria-haspopup":c.getOr(!1)}))},menuItemCheckbox:function(a){m.setAll(a,{role:"menuitemcheckbox","aria-checked":!1})},checkbox:function(a,b){m.setAll(a,{role:"checkbox","aria-label":b,"aria-checked":!1})},dialog:function(a,b){m.setAll(a,{role:"dialog","aria-label":b})},buttonRole:sD,button:function(a,b){m.setAll(a,{"aria-label":b,role:"button"})},labelledField:function(a,b,c){var d=p.fromTag("div");Cn(d);b+=Fa("");var e=Fa("label");c=p.fromHtml("<label>"+c+"</label>");m.set(c,"for",b);m.set(c,"id",
  e);m.set(a,"id",b);wD(a,e);P.append(d,[c,a]);return{element:k(d),field:k(a)}},multiline:function(a){m.set(a,"aria-multiline","true")},textarea:function(a){m.setAll(a,{"aria-multiline":"true",role:"textbox"})},label:Dn,widget:function(a){m.set(a,"role","widget")},option:function(a){m.set(a,"role","option")},listBox:function(a){m.set(a,"role","listbox")},live:function(a,b,c){m.setAll(a,{"aria-live":c?c:"polite",id:b})},tabList:function(a){m.set(a,"role","tablist")},tabButton:function(a,b){m.setAll(a,
  {"aria-label":b,role:"tab"})},tabPanel:function(a){m.setAll(a,{role:"tabpanel"})},linkElements:uD,linkTabToPanel:function(a,b){uD(a,b)},describedBy:vD,labelledBy:wD,required:function(a){m.set(a,"aria-required","true")},hidden:function(a,b){b?m.set(a,"aria-hidden",b):m.remove(a,"aria-hidden")},invalid:function(a,b){!0===b?m.set(a,"aria-invalid","true"):m.remove(a,"aria-invalid")}},yT={disable:function(a){m.set(a,"unselectable","on");v.setAll(a,{"-webkit-user-select":"none","user-select":"none","-ms-user-select":"none"});
  a.dom().style.setProperty("-moz-user-select","-moz-none");return K.bind(a,"onselectstart",function(){return!1})}},lb={resolve:Lb.create("ephox-pastry").resolve},xD=function(a,b,c,d){S.toolbarButton(a.element(),b,c,d);b=Kq.control(a);c=Kq.ariaPressed(a);return{enable:b.enable,disable:b.disable,press:c.press,release:c.release,destroy:function(){a.destroy()}}},Os=function(a,b,c,d,e,f,h,l){h=g.from(h).fold(function(){return l(e)},function(a){return a(e,b)});f=g.from(f).getOr(!1);a=a(b);c=bf([va.resolve("icon"),
  va.resolve(c)]);f=!0===f?[Qc(l(e)).element()]:[];P.append(c.element(),f);a.content(c);a.events.click.bind(function(){d()});m.set(a.element(),"title",h);a.initAria=xD;return a},yD=function(a,b){L.descendant(a,b).each(function(a){S.hidden(a,"true")})},zD=function(a,b,c,d,e,f,h,l){a=Os(a,b,c,d,e,f,h,l);n.add(a.element(),va.resolve("split-"+b));yD(a.element(),".ephox-pastry-dropbutton-arrow");yD(a.element(),".ephox-pastry-dropbutton-button");L.descendant(a.element(),".ephox-pastry-dropbutton-arrow .ephox-pastry-icon-content").each(function(a){n.add(a,
  va.resolve("icon"));n.add(a,va.resolve("arrow-"+b))});return a},Mg={aria:xD,typical:function(a,b,c,d,e,f,h){return Os(Nc,a,b,c,d,e,f,h)},toggle:function(a,b,c,d,e,f,h){return Os($d,a,b,c,d,e,f,h)},splitToggle:function(a,b,c,d,e,f,h){return zD(AT,a,b,c,d,e,f,h)},split:function(a,b,c,d,e,f,h){return zD(zT,a,b,c,d,e,f,h)}},re={resolve:Lb.create("ephox-gopher").resolve},Ps=Sl("item"),Qs=re.resolve("disabled-item"),AD="data-"+re.resolve("item-value"),Hc={set:function(a,b){Ps.set(a);m.set(a,AD,b)},get:function(a){return m.get(a,
  AD)},up:Ps.up,all:Ps.all,disable:function(a){n.add(a,Qs)},enable:function(a){n.remove(a,Qs)},isEnabled:function(a){return!n.has(a,Qs)}},mk=Sl("menu"),BD="data-"+re.resolve("menu-value"),En=re.resolve("active-menu"),Jd={set:function(a,b){mk.set(a);m.set(a,BD,b)},active:function(a){return L.descendant(a,"."+En)},inactive:function(a){a=mk.all(a);return ka(a,function(a){return!n.has(a,En)})},activate:function(a,b){a=mk.all(a);z(a,function(a){n.remove(a,En)});n.add(b,En)},up:mk.up,all:mk.all,submenu:function(a,
  b,c){c=Hc.get(c);return(b.hasOwnProperty(c)?g.from(b[c]):g.none()).bind(function(b){return L.descendant(a,"["+BD+'="'+b+'"]')})}},d3=Sl("submenu"),e3=Sl("main-menu"),Kf={main:k(e3),submenu:k(d3)},CD=function(a,b,c){Hc.set(c,b);m.set(c,"tabindex",-1);return c},ED=function(a,b,c){return DD(a,b,c,!1)},DD=function(a,b,c,d){var e=p.fromTag("li",a.dom()),f=T.span();n.add(f,re.resolve("item-text"));!0===d&&n.add(f,re.resolve("item-ellipsis"));y.append(f,p.fromText(c));y.append(e,f);CD(a,b,e);return e},FD=
  function(a){a=p.fromTag("li",a.dom());n.add(a,re.resolve("separator"));return a},f3=function(a,b){return"-"!==b.value()?ED(a,b.value(),b.text()):FD(a)},GD=function(a,b,c){var d=p.fromTag("ol",a.dom());Jd.set(d,b);a=E(c,u(f3,a));P.append(d,a);return d},HD=function(a,b){a=p.fromTag("div",a.dom());Jd.set(a,b);return a},zb={item:ED,ellipsisItem:function(a,b,c){return DD(a,b,c,!0)},mainmenu:function(a,b,c){a=GD(a,b,c);Kf.main().set(a);return a},submenu:function(a,b,c){a=GD(a,b,c);Kf.submenu().set(a);return a},
  widget:HD,widgetSubmenu:function(a,b){a=HD(a,b);Kf.submenu().set(a);return a},separator:FD,custom:CD,enableItem:Hc.enable,disableItem:Hc.disable},ID=function(a,b){if(void 0===a)throw Error("Cannot intersperse undefined");if(1>=a.length)return a;var c=[];c.push(a[0]);for(var d=1;d<a.length;d++)c.push(b()),c.push(a[d]);return c},g3={css:function(a){var b=/^[a-zA-Z]/.test(a)?"":"e";a=a.replace(/[^\w]/gi,"-");return b+a}},h3={splits:function(a,b){if(0===b.length)return[a];var c=hb(b,function(b,c){if(0===
  c)return b;var d=a.substring(b.prev,c);return{prev:c,values:b.values.concat([d])}},{prev:0,values:[]});b=b[b.length-1];return b<a.length?c.values.concat(a.substring(b)):c.values}},Fn={cssSanitise:function(a){return g3.css(a)},splits:function(a,b){return h3.splits(a,b)}},i3=function(a,b){b=Qb(b);return Nq.menu(a,b)},j3=function(a){return E(a,function(a){a=E(a,function(a){return a.items()});return Qb(a)})},JD={create:function(a,b,c){var d=a.name,e=a.textkey,f=a.menuTextkey,h=a.tooltip,l=a.label,q=g.from(a.icon),
  C=k(void 0!==a.contentFocus?a.contentFocus:!1),w=p.fromDom(document),m=xa(e)?Fn.cssSanitise(d):d,G=c(e);f=c(f);var n=zb.mainmenu(w,m+"-menu",[]),r=Mg.toggle(d,m,ca,e,l,h,c);q.filter(xa).each(function(a){zn.findAndSetUrl(r.element(),a)});var u=r.initAria(r,G,!0,a.toggle);a=j3(b);var v=i3(m,b);b=ID(a,function(){return[zb.separator(w)]});S.menu(n,f);P.append(n,Qb(b));return{button:k(r),contentFocus:C,destroy:function(){r.destroy();v.destroy();u.destroy()},element:k(n),events:v.events,handlers:v.handlers,
  icon:k(q),init:v.init,label:k(G),name:v.name,structure:v.structure,submenus:v.submenus,textkey:k(e),menuTextkey:k(f),updateMenu:t,enable:u.enable,disable:u.disable}}},k3=function(a,b){return g.some(b(a))},l3=function(a,b){return g.some(b(a,[]))},KD=function(a,b){var c=u(KD,a);return pD.cata(b,g.none,g.none,k3,function(b,e,f){e=E(e,function(a){return ia(a.books,c)});b=JD.create(b,e,a);return g.some(f(b,[]))},l3,function(a,b,f){b=ia(b,c);return g.some(f(a,b))}).toArray()},m3={build:function(a,b){return{items:ia(a.books,
  function(a){return KD(b,a)}),category:a.category}}},n3={build:function(a,b,c){var d=c.translations();a=Z2.fromConfig(b.toolbar(),b.menu(),a);a=E(a,function(a){return m3.build(a,d)});return E(a,function(a){var b=Nq.toolbar(a.items);a=a.category;S.toolbarGroup(b.component(),d(a));return b})}},o3=O("toolbar","menu"),p3=O("smartview","translations"),LD=function(a){return function(){return a.apply(null,arguments)}},MD={blueprints:LD(o3),env:LD(p3)},ND=function(){return/(?:(?:[A-Za-z]{3,9}:(?:\/\/))(?:[-.~*+=!&;:'%@?^${}(),\w]+@)?[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*|(?:www\.|[-;:&=+$,.\w]+@)[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*)(?::[0-9]+)?(?:\/[-+~%.()\/\w]*)?(?:\?(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?(?:#(?:[-.~*+=!&;:'%@?^${}(),\/\w]+))?/g},
  Gn={tokens:function(a,b){return a.replace(/\{(\d+)\}/g,function(c,d,e,f){d=parseInt(d,10);if(void 0===b[d])throw"No value for token: "+c+" in translation: "+a;return b[d]})},link:ND,autolink:function(){var a=ND().source;return new RegExp("("+a+")[-.~*+=!&;:'%@?#^${}(),]*","g")}},Rs=ta.generate([{raw:["text"]},{key:["key"]},{pkey:["key","params"]}]),Ss=function(a){var b=gh.get(a);if(1<arguments.length||/\{(\d+)\}/.test(b)){for(var c=Array(arguments.length-1),d=1;d<arguments.length;d++)c[d-1]=arguments[d];
  return Gn.tokens(b,c)}return b},x={get:function(a){if(xa(a))throw"string passed to I18n.get:"+a;return a.fold(ca,Ss,Ss)},has:gh.has,translate:Ss,raw:Rs.raw,key:function(a){gh.get(a);return Rs.key(a)},pkey:function(a,b){gh.get(a);return Rs.pkey(a,b)},cata:function(a,b,c,d){return a.fold(b,c,d)}},He={dropdown:xd("enable disable select clear selectElement populate tick untick activate deactivate".split(" ")),menu:xd(["enable","disable"]),general:xd("enable disable select deselect selected element".split(" ")),
  widget:xd("enable disable select deselect press release".split(" ")),palette:xd(["show","hide"])},Xl={generateItem:function(a,b,c,d){return c.fold(function(){return zb.item(a,b.value(),d(b.textkey()))},function(c){c=c(b);var d=p.fromTag("li",a.dom());y.append(d,c);return zb.custom(a,b.value(),d)})},generateSeparator:function(a,b,c){var d=zb.separator(a);y.append(d,p.fromText(c(b),a.dom()));return d}},q3=function(a,b){a=qa(a,function(a){return a.value()===b});return g.from(a)},OD=function(a){a=Y.children(a,
  ".ephox-pastry-toggle-list-item-selected");z(a,function(a){n.remove(a,"ephox-pastry-toggle-list-item-selected");ra.checked(a,!1)})},Gh={updateDropdown:function(a,b,c,d,e){b.fold(a.clear,t,function(b){e.fold(function(){(xa(b)?q3(d,b):g.some(b)).each(a.select)},function(c){c=c(b);var d=lb.resolve("arrow-righticon");n.add(c,d);a.selectElement(c)})});c.fold(a.disable,t,a.enable)},tick:function(a,b){OD(a);a=Y.descendants(a,".ephox-gopher-item");qa(a,function(a){return m.get(a,"data-ephox-gopher-item-value")===
  b}).each(function(a){n.add(a,"ephox-pastry-toggle-list-item-selected");ra.checked(a,!0)})},untick:OD,activate:function(a){n.add(a,"ephox-pastry-statebutton-selected")},deactivate:function(a){n.remove(a,"ephox-pastry-statebutton-selected")}},Ts=lb.resolve("toggle-list-item-selected"),r3=function(a){zb.enableItem(a);ra.enable(a)},s3=function(a){zb.disableItem(a);ra.disable(a)},t3=function(a){n.remove(a,Ts);ra.checked(a,!1)},u3=function(a){n.add(a,Ts);ra.checked(a,!0)},Eh={control:function(a){return{enable:u(r3,
  a),disable:u(s3,a)}},selected:function(a){return{deselect:u(t3,a),select:u(u3,a),selected:u(n.has,a,Ts)}}},PD=function(a){var b=T.span();S.hidden(b,!0);ma.add(b,["ephox-pastry-icon-content","ephox-chameleon-icon"].concat([a]));return[b]},v3=function(a){var b=T.span();S.hidden(b,!0);ma.add(b,["ephox-pastry-icon-content","ephox-chameleon-"+a.value]);zn.setUrl(b,a.icon);return[b]},w3=function(a){return PD(!0===a.icon?"ephox-chameleon-"+a.value:a.icon)},nj={generate:PD,generateFrom:function(a){return void 0===
  a.icon?[]:(xa(a.icon)?v3:w3)(a)}},x3=aa.detect().browser.isFirefox(),y3={position:"absolute",left:"-9999px"},QD=function(a,b){var c=p.fromTag("span",a.dom());S.presentation(c);a=p.fromText(b,a.dom());y.append(c,a);return c},RD=function(a,b){var c=Fa("ephox-echo-voice");m.set(b,"id",c);m.set(a,"aria-describedby",c)},SD=function(a,b,c){var d=A.owner(b),e=QD(d,c);x3&&RD(b,e);m.setAll(e,a(c));v.setAll(e,y3);y.append(b,e);setTimeout(function(){m.remove(e,"aria-live");F.remove(e)},1E3)},z3=u(SD,function(a){return{"aria-live":"polite",
  "aria-atomic":"true","aria-label":a}}),A3=u(SD,k({"aria-live":"assertive","aria-atomic":"true",role:"alert"})),ib={describe:function(a,b){var c=A.owner(a);b=QD(c,b);v.set(b,"display","none");S.hidden(b,!0);RD(a,b);return b},speak:z3,shout:A3,tokenSelector:function(){return'span[id^="ephox-echo-voice"]'}},CT=p.fromDom(document),ky=va.resolve("label-default"),Us=p.fromDom(document),B3="data-"+re.resolve("item-value"),C3=function(a){a=zb.submenu(Us,a+"-menu",[]);n.remove(a,"ephox-gopher-main-menu");
  n.add(a,"ephox-gopher-submenu");return a},D3=function(a,b){b=m.get(b,"data-ephox-gopher-menu-value");var c={};c[a.name+"-menu-trigger"]=b;return c},E3=function(a,b){var c=C3(b.name);S.menu(c,a(b.textkey,!1));var d=D3(b,c),e=BT(a,b),f=function(d){d=ia(d,function(c){var d=E(c.items(),function(c){c=Xl.generateItem(Us,c,b.render,a);S.menuItemCheckbox(c);return c});return c.label().fold(k(d),function(b){return[Xl.generateSeparator(Us,b,a)].concat(d)})});F.empty(c);P.append(c,d)},h=H.create({done:r([]),
  abort:r(["item"])}),l={};z(b.values,function(a){l[a.value()]=function(a){a=m.get(a,B3);b.action(a);h.trigger.done()}});e.events.populate.bind(function(a){f(a.items())});return{items:k([e.element()]),structure:k(d),submenus:k([c]),refreshMenu:function(){b.updateDropdown(He.dropdown({enable:e.enable,disable:e.disable,select:e.select,clear:e.clear,selectElement:e.selectElement,populate:e.populate,tick:u(Gh.tick,c),untick:u(Gh.untick,c),activate:t,deactivate:t}))},destroyer:function(){e.destroy()},handlers:k(l),
  events:h.registry}},F3=p.fromDom(document),G3=function(a,b){a=a(b.textkey);var c=(!0===b.hasDialog?zb.ellipsisItem:zb.item)(F3,b.value,a),d=Eh.control(c),e=!0===b.toggle?Eh.selected(c):{select:t,deselect:t,selected:k(!1)};!0===b.toggle?S.menuItemCheckbox(c):S.menuItem(c,g.some(a),g.some(!1));var f=function(){b.updateGeneral(He.general({disable:d.disable,enable:d.enable,select:e.select,deselect:e.deselect,selected:e.selected,element:k(c)}))},h=H.create({done:r([]),abort:r(["item"])});a={};a[b.value]=
  function(){h.trigger.done();b.action();f()};var l=nj.generateFrom(b);P.prepend(c,l);return{items:k([c]),structure:k({}),submenus:k([]),refreshMenu:f,handlers:k(a),destroyer:ca,events:h.registry}},H3=p.fromDom(document),I3=function(a){return{submenu:function(b){var c=b.textkey();b=b.element();S.menu(b,a(c));n.remove(b,"ephox-gopher-main-menu");n.add(b,"ephox-gopher-submenu");return b},item:function(b){var c=b.textkey();c=a(c);b=zb.item(H3,b.name()+"-menu-trigger",c);n.add(b,va.resolve("menu-more"));
  S.menuItem(b,g.some(c),g.some(!0));return b}}},J3=function(a,b,c){c=I3(a);a=c.submenu(b);var d=m.get(a,"data-ephox-gopher-menu-value");c=c.item(b);var e={};e[b.name()+"-menu-trigger"]=d;d=ua(e,b.structure());var f=nj.generate("ephox-chameleon-"+b.name());P.prepend(c,f);b.icon().each(function(a){0<f.length&&zn.setUrl(f[0],a)});var h=Eh.control(c);e=void 0!==b.destroyer?b.destroyer:void 0!==b.destroy?b.destroy:t;return{items:k([c]),structure:k(d),submenus:k([a].concat(b.submenus())),refreshMenu:function(){b.updateMenu({enable:h.enable,
  disable:h.disable})},destroyer:e,handlers:b.handlers,events:b.events}},Vs=p.fromDom(document),TD=va.resolve("menu-widget"),K3=function(a,b){b=zb.widgetSubmenu(Vs,b);y.append(b,a.element());ma.add(a.element(),[TD,"ephox-gopher-item"]);return b},L3=function(a,b,c){a=a(b.textkey());a=zb.item(Vs,c,a);n.add(a,va.resolve("menu-more"));c=nj.generate(va.resolve(c));P.prepend(a,c);return a},UD=function(a,b){var c=b.instance();b=c.name();var d=b+"-submenu",e=K3(c,d),f=L3(a,c,b);S.menu(e,a(c.menuTextkey()));
  S.menuItem(f,g.some(a(c.textkey())),g.some(!0));var h=Eh.control(f);a={};a[b]=d;var l=H.create({done:Q([],c.events.done),abort:r(["item"])});c.events.abort.bind(function(){l.trigger.abort(f)});return{items:k([f]),structure:k(a),submenus:k([e]),refreshMenu:function(){c.updateWidget(He.widget({enable:h.enable,disable:h.disable,select:t,deselect:t,press:t,release:t}))},destroyer:c.destroy,handlers:k({}),events:l.registry}},Wl={widget:UD,inline:function(a,b){var c=b.instance();b=c.name();n.add(c.element(),
  va.resolve("menu-inline-widget"));var d=p.fromTag("li");y.append(d,c.element());var e=zb.custom(Vs,b,d),f=Eh.control(e);S.menuItem(e,g.some(a(c.textkey())),g.some(!1));a={};a[b]=function(a){var b=Z.active().filter(function(b){return wd.ancestor(b,u(N.eq,a))});c.element().dom().click();b.each(Z.focus)};var h=H.create({done:Q([],c.events.done),abort:r(["item"])});c.events.abort.bind(function(){h.trigger.abort(e)});return{items:k([e]),structure:k({}),submenus:k([]),refreshMenu:function(){c.updateInlineWidget(He.widget({enable:f.enable,
  disable:f.disable,select:t,deselect:t,press:t,release:t}))},destroyer:c.destroy,handlers:k(a),events:h.registry}},split:UD,styles:k(TD)},VD=va.resolve("keyfocus"),WD=function(a,b){var c=T.span();v.set(c,"display","none");n.add(c,VD);y.append(a,c);return K.bind(c,"click",function(a){b();a.kill()})},Mf={onButton:function(a){return WD(a.element(),a.click)},custom:WD,trigger:function(a){var b="."+VD;a=Ia.is(a,b)?g.some(a):L.descendant(a,b);a.each(function(a){a.dom().click()});return a}},qj={menu:Aa(["focusActive"],
  [])},ci=re.resolve("item-selected"),Ws=function(a,b){n.add(b,ci)},XD=function(a,b){n.remove(b,ci)},Kd={is:function(a){return n.has(a,ci)},none:function(a){var b=Hc.all(a);z(b,function(b){XD(a,b)})},selectAll:function(a,b){a=Hc.all(a);z(a,function(a){n.remove(a,ci)});z(b,function(a){n.add(a,ci)})},select:Ws,deselect:XD,selected:function(a){return L.descendant(a,"."+ci)},first:function(a){var b=Hc.all(a);return g.from(b[0]).map(function(b){Ws(a,b);return b})},last:function(a){var b=Hc.all(a);return g.from(b[b.length-
  1]).map(function(b){Ws(a,b);return b})}},M3=function(a,b){var c=Hc.all(a);return Va(c,function(a){return N.eq(b,a)}).map(function(a){return{index:k(a),all:k(c)}})},N3=function(a,b){return 0===b?a.length-1:b-1},O3=function(a,b){return b===a.length-1?0:b+1},YD=function(a,b,c){return M3(a,b).map(function(d){var e=c(d.all(),d.index());d=d.all()[e];Kd.deselect(a,b);Kd.select(a,d);return d})},Iq={first:function(a){var b=Hc.all(a);return g.from(b[0]).map(function(b){Kd.select(a,b);return b})},prev:function(a,
  b){return YD(a,b,N3)},next:function(a,b){return YD(a,b,O3)}},bc=function(a){return function(){return a}},R={BACKSPACE:bc([8]),TAB:bc([9]),ENTER:bc([13]),SHIFT:bc([16]),CTRL:bc([17]),ALT:bc([18]),CAPSLOCK:bc([20]),ESCAPE:bc([27]),SPACE:bc([32]),PAGEUP:bc([33]),PAGEDOWN:bc([34]),END:bc([35]),HOME:bc([36]),LEFT:bc([37]),UP:bc([38]),RIGHT:bc([39]),DOWN:bc([40]),INSERT:bc([45]),DEL:bc([46]),META:bc([91,93,224]),F10:bc([121])},my={isCommand:function(a,b){var c=[];z(b,function(a){a="string"===typeof a?[a.toUpperCase().charCodeAt(0)]:
  a;c=c.concat(a)});b=function(a){return 0<ka(c,function(b){return U(R[a](),b)}).length};if(!!a.altKey!==b("ALT")||!!a.shiftKey!==b("SHIFT")||!!a.ctrlKey!==b("CTRL")||!!a.metaKey!==b("META"))return!1;b=null!==a.charCode&&void 0!==a.charCode&&0!==a.charCode?String.fromCharCode(a.charCode).toUpperCase().charCodeAt(0):a.which;var d=R.CTRL().concat(R.ALT()).concat(R.SHIFT()).concat(R.META()),e=ka(c,function(a){return!U(d,a)});return 1<e.length?!1:0===e.length&&void 0===a.which||e[0]===b}},ly={stop:function(a){a.preventDefault();
  a.stopPropagation&&a.stopPropagation()}},P3={BACKSPACE:R.BACKSPACE,TAB:R.TAB,ENTER:R.ENTER,CAPSLOCK:R.CAPSLOCK,ESCAPE:R.ESCAPE,SPACE:R.SPACE,PAGEUP:R.PAGEUP,PAGEDOWN:R.PAGEDOWN,END:R.END,HOME:R.HOME,LEFT:R.LEFT,UP:R.UP,DOWN:R.DOWN,RIGHT:R.RIGHT,INSERT:R.INSERT,DEL:R.DEL},Jg={getSpecial:function(a){var b=null;Ma(P3,function(c,d){U(c(),a)&&(b=d)});return b},noModifiers:function(a){return!(a.metaKey||a.altKey||a.ctrlKey)},isCharCode:function(a){return a.charCode===a.keyCode}},ZD=function(a,b){return qa(b,
  function(b){return my.isCommand(a,b)})},$D=function(a){return Jg.isCharCode(a)?g.none():g.from(Jg.getSpecial(a.keyCode))},FT={identify:function(a,b){return{fold:function(c,d,e){ZD(a,b).fold(function(){$D(a).fold(function(){e(a.which&&String.fromCharCode(a.which))},function(a){d(R[a]())})},c)}}},shortcut:ZD,special:$D},aE=function(a){return"rtl"===v.get(a,"direction")?"rtl":"ltr"},ae={onDirection:function(a,b){return function(c){return"rtl"===aE(c)?b:a}},getDirection:aE},bE=function(a,b,c,d){var e=
  v.get(a,b);void 0===e&&(e="");c=e===c?d:c;e=u(v.set,a,b,e);a=u(v.set,a,b,c);return Bq(e,a,!1)},sc={toggler:function(a){return bE(a,"visibility","hidden","visible")},displayToggler:function(a,b){return bE(a,"display","none",b)},isVisible:function(a){a=a.dom();return!(0>=a.offsetWidth&&0>=a.offsetHeight)}},Hn=ta.generate([{southeast:[]},{southwest:[]},{northeast:[]},{northwest:[]}]),yd={southeast:Hn.southeast,southwest:Hn.southwest,northeast:Hn.northeast,northwest:Hn.northwest,cata:function(a,b,c,d,
  e){return a.fold(b,c,d,e)}},cE=function(a,b){return a.view(b).fold(k([]),function(b){var c=a.owner(b);c=cE(a,c);return[b].concat(c)})},Q3={pathTo:function(a,b){a=b.owner(a);b=cE(b,a);return g.some(b)}},R3={view:function(a){return(a.dom()===document?g.none():g.from(a.dom().defaultView.frameElement)).map(p.fromDom)},owner:function(a){return A.owner(a)}},nk={find:function(a){var b=p.fromDom(document),c=Za.get(b);return Q3.pathTo(a,R3).fold(u(bb.absolute,a),function(b){var d=bb.viewport(a);b=Eb(b,function(a,
  b){b=bb.viewport(b);return{left:a.left+b.left(),top:a.top+b.top()}},{left:0,top:0});return Qa(b.left+d.left()+c.left(),b.top+d.top()+c.top())})}},Bf={absolute:function(a){var b=nk.find(a),c=Ga.getOuter(a);a=sa.getOuter(a);return eg(b.left(),b.top(),c,a)},view:function(){return eg(0,0,window.innerWidth,window.innerHeight)}},dE=function(a,b,c){var d=Qa(b,c);b=function(){var a=Za.get();return d.translate(-a.left(),-a.top())};return a.fold(k(d),b,b)},Xs={toBox:function(a,b){var c=nk.find(b);a=dE(a,c.left(),
  c.top());c=Ga.getOuter(b);b=sa.getOuter(b);return eg(a.left(),a.top(),c,b)},viewport:function(a,b){return b.fold(function(){return a.fold(Bf.view,Bf.view,eg)},function(b){return a.fold(b,b,eg)})},translate:dE},S3=Aa("x y width height maxHeight direction classes label candidateYforTest".split(" "),[]),T3=O("position","left","top","right","bottom"),hh={decision:S3,css:T3},Ys=ta.generate([{none:[]},{relative:["x","y","width","height"]},{fixed:["x","y","width","height"]}]),eE=function(a,b,c,d,e,f){c=
  b.x()-c;d=b.y()-d;var h=b.width(),l=b.height();e-=c+h;f-=d+l;var k=g.some(c),C=g.some(d),w=g.some(e),m=g.some(f),G=g.none();return yd.cata(b.direction(),function(){return hh.css(a,k,C,G,G)},function(){return hh.css(a,G,C,w,G)},function(){return hh.css(a,k,G,G,m)},function(){return hh.css(a,G,G,w,m)})},Ie={none:Ys.none,relative:Ys.relative,fixed:Ys.fixed,reposition:function(a,b){return a.fold(function(){return hh.css("absolute",g.some(b.x()),g.some(b.y()),g.none(),g.none())},function(a,d,e,f){return eE("absolute",
  b,a,d,e,f)},function(a,d,e,f){return eE("fixed",b,a,d,e,f)})},viewport:function(a,b){return Xs.viewport(a,b)},toBox:function(a,b){return Xs.toBox(a,b)},translate:function(a,b,c){return Xs.translate(a,b,c)},cata:function(a,b,c,d){return a.fold(b,c,d)}},fE=O("anchorBox","origin"),Lh={box:function(a,b){return fE(a,b)},element:function(a,b){a=Ie.toBox(b,a);return fE(a,b)},relativeOrigin:function(a){a=a.dom().getBoundingClientRect();return Ie.relative(a.left,a.top,a.width,a.height)}},ok={resolve:Lb.create("ephox-repartee").resolve},
  gE=ok.resolve("caret-top-align"),hE=ok.resolve("caret-bottom-align"),iE=ok.resolve("caret-right-align"),jE=ok.resolve("caret-left-align"),kE=ok.resolve("caret-middle-align"),cc={east:k(jE),south:k(gE),west:k(iE),north:k(hE),middle:k(kE),all:k([gE,hE,jE,iE,kE])},Je=O("x","y","bubble","direction","anchors","label"),lE=function(a,b){return a.x()+a.width()-b.width()/2},mE=function(a,b){return a.x()+a.width()-b.width()},Zs=function(a,b){return a.y()-b.height()},$s=function(a){return a.y()+a.height()},
  at=function(a,b,c){return Je(a.x(),$s(a),c.southeast(),yd.southeast(),[cc.south(),cc.east()],"layout-se")},bt=function(a,b,c){return Je(mE(a,b),$s(a),c.southwest(),yd.southwest(),[cc.south(),cc.west()],"layout-sw")},ct=function(a,b,c){return Je(a.x(),Zs(a,b),c.northeast(),yd.northeast(),[cc.north(),cc.east()],"layout-ne")},dt=function(a,b,c){return Je(mE(a,b),Zs(a,b),c.northwest(),yd.northwest(),[cc.north(),cc.west()],"layout-nw")},et=function(a,b,c){return Je(lE(a,b),Zs(a,b),c.northeast(),yd.northeast(),
  [cc.north(),cc.middle()],"layout-nm")},ft=function(a,b,c){return Je(lE(a,b),$s(a),c.southeast(),yd.southeast(),[cc.south(),cc.middle()],"layout-sm")},Qh={southeast:at,northeast:ct,southwest:bt,northwest:dt,southmiddle:ft,northmiddle:et,all:function(){return[at,bt,ct,dt,ft,et]},allRtl:function(){return[bt,at,dt,ct,ft,et]}},nE=function(a){return a.x()+a.width()},oE=function(a,b){return a.y()-b.height()+a.height()},gt=function(a,b,c){return Je(nE(a),a.y(),c.southeast(),yd.southeast(),[cc.south(),cc.east()],
  "link-layout-se")},ht=function(a,b,c){b=a.x()-b.width();return Je(b,a.y(),c.southwest(),yd.southwest(),[cc.south(),cc.west()],"link-layout-sw")},it=function(a,b,c){return Je(nE(a),oE(a,b),c.northeast(),yd.northeast(),[cc.north(),cc.east()],"link-layout-ne")},jt=function(a,b,c){var d=a.x()-b.width();return Je(d,oE(a,b),c.northwest(),yd.northwest(),[cc.north(),cc.west()],"link-layout-nw")},U3={southeast:gt,northeast:it,southwest:ht,northwest:jt,all:function(){return[gt,ht,it,jt]},allRtl:function(){return[ht,
  gt,jt,it]}},cf={anchored:k(function(a,b){sa.setMax(a,Math.floor(b));v.setAll(a,{"overflow-x":"hidden","overflow-y":"auto"})}),expandable:k(function(a,b){sa.setMax(a,Math.floor(b))})},ih=ta.generate([{fit:["reposition"]},{nofit:["reposition","deltaW","deltaH"]}]),V3=function(a,b,c,d){var e=a.x(),f=a.y(),h=a.bubble().left(),l=a.bubble().top(),g=d.x(),C=d.y(),w=d.width(),m=d.height();h=e+h;e=f+l;var G=h>=g,n=e>=C;f=G&&n;l=h+b<=g+w&&e+c<=C+m;g=G?Math.min(b,g+w-h):Math.abs(g-(h+b));w=n?Math.min(c,C+m-
  e):Math.abs(C-(e+c));b=d.width()-b;b=Math.min(Math.max(0,h),b);c=n?e:e+(c-w);d=k(c+w-C);C=k(C+m-c);C=yd.cata(a.direction(),C,C,d,d);a=hh.decision({x:b,y:c,width:g,height:w,maxHeight:C,direction:a.direction(),classes:a.anchors(),label:a.label(),candidateYforTest:e});return f&&l?ih.fit(a):ih.nofit(a,g,w)},W3={attempts:function(a,b,c,d,e){var f=c.width(),h=c.height(),l=function(a,l,g,k){a=a(b,c,d);return V3(a,f,h,e).fold(ih.fit,function(a,b,c){return b>g||c>k?ih.nofit(a,b,c):ih.nofit(l,g,k)})};return hb(a,
  function(a,b){b=u(l,b);return a.fold(ih.fit,b)},ih.nofit(hh.decision({x:b.x(),y:b.y(),width:c.width(),height:c.height(),maxHeight:c.height(),direction:yd.southeast(),classes:[],label:"none",candidateYforTest:b.y()}),-1,-1)).fold(ca,ca)}},X3={measure:function(a){var b=p.fromTag("div");v.setAll(b,{position:"fixed",opacity:"0",top:"0",left:"0",bottom:"0",right:"0"});y.prepend(a,b);a=bb.viewport(b);var c=Ga.get(b),d=sa.get(b);F.remove(b);return{top:a.top,left:a.left,width:k(c),height:k(d)}}},In={layout:function(a,
  b,c,d){v.remove(b,"max-height");b={width:k(Ga.getOuter(b)),height:k(sa.getOuter(b))};return W3.attempts(d.preference(),a,b,c,d.bounds())},setClasses:function(a,b){ma.remove(a,cc.all());ma.add(a,b.classes())},setHeight:function(a,b,c){c.maxHeightFunction()(a,b.maxHeight())},position:function(a,b,c){var d=function(a){return a+"px"};c=c.origin();var e=k(c);c=c.fold(e,e,function(){var b=X3.measure(a);return Ie.fixed(b.left(),b.top(),b.width(),b.height())});b=Ie.reposition(c,b,a);v.setOptions(a,{position:g.some(b.position()),
  left:b.left().map(d),top:b.top().map(d),right:b.right().map(d),bottom:b.bottom().map(d)})}},pE=Aa(["bounds","origin","preference","maxHeightFunction"],[]),pk=function(a,b,c){return void 0===a[b]?c:a[b]},qE=function(a,b,c,d){a=In.layout(a,b,c,d);In.position(b,a,d);In.setClasses(b,a);In.setHeight(b,a,d)},Km={simple:function(a,b,c,d,e){var f=pk(e,"maxHeightFunction",cf.anchored());e=a.anchorBox();a=a.origin();d=pE({bounds:Ie.viewport(a,g.none()),origin:a,preference:d,maxHeightFunction:f});qE(e,b,c,d)},
  detailed:function(a,b,c,d){d=void 0!==d?d:{};d=pE({bounds:pk(d,"bounds",Bf.view()),origin:pk(d,"origin",Ie.none()),preference:pk(d,"preference",Qh.all()),maxHeightFunction:pk(d,"maxHeightFunction",cf.anchored())});qE(a,b,c,d)}},Y3=function(a,b,c,d,e,f,h){return function(a){var l=Ie.none();var k=Ie.viewport(l,g.some(b));var w=Ie.toBox(l,c());k={bounds:k,origin:l,preference:e.isRtl()?f.allRtl():f.all(),maxHeightFunction:h};a=a.panel();Km.detailed(w,a,d,k)}},Z3=function(a,b,c,d,e,f,h){return function(b){var l=
  e.isRtl()?f.allRtl():f.all(),g={maxHeightFunction:h},k=Lh.element(c(),Lh.relativeOrigin(a()));b=b.panel();Km.simple(k,b,d,l,g)}},rE=aa.detect().deviceType.isiOS()?Y3:Z3,Kg={main:function(a,b,c,d,e,f){a=rE(a,b,c,d,e,Qh,f);return{recalculate:a,isAnchored:Jb,place:a}},submenu:function(a,b,c,d,e){a=rE(a,b,c,Fh(3,-2),d,U3,e);return{recalculate:a,isAnchored:Jb,place:a}}},sE=function(a){return function(b){return b.key()===a}},$3=O("key","value"),Ul={put:function(a,b,c,d,e){var f=void 0!==d?d:$3,h=void 0!==
  e?e:sE(b);a=hb(a,function(a,d){var e=h(d)?f(b,c):d;return{updated:h(d)||a.updated,acc:a.acc.concat([e])}},{updated:!1,acc:[]});return a.updated?a.acc:a.acc.concat([f(b,c)])},get:function(a,b,c){b=void 0!==c?c:sE(b);return qa(a,b)}},LT={triage:function(a){a=Eb(a,function(a,c){var b=ja.inBody(c.menu());return{keep:b?[c].concat(a.keep):a.keep,throwaway:!1===b?[c].concat(a.throwaway):a.throwaway}},{throwaway:[],keep:[]});z(a.throwaway,function(a){a.popup().destroy()});return a.keep}},tE=function(a,b){return wd.ancestor(a,
  u(N.eq,b))},IT={ancestor:tE,anyAncestor:function(a,b){return Xa(b,function(b){return tE(a,b)})},sibling:function(a,b){return wd.sibling(a,u(N.eq,b))},child:function(a,b){return wd.child(a,u(N.eq,b))},descendant:function(a,b){return wd.descendant(a,u(N.eq,b))}},KT={create:function(a,b){var c=H.create({open:r([]),close:r([]),uistale:r([])});if(void 0===a)throw"uicontainer not specified";var d=JT({layerClass:va.resolve("layer-menus"),container:a()}),e=T.div();n.add(e,va.resolve("popup-container"));d.content(e);
  var f=!1,h=function(){f&&(g.off(),d.hide(),f=!1,k.control.block(),c.trigger.close())},l=[e],g=ny(function(a){!1===!f&&(h(),L.ancestor(a,"."+b).fold(function(){Z.focus(a)},t))},function(){return l}),k=Hd.tap(function(){c.trigger.uistale()});k.control.block();return{element:function(){return e},panel:d.element,destroy:function(){d.hide();d.destroy();g.off()},open:function(){f||(k.control.unblock(),v.set(d.element(),"opacity","0"),d.show(),v.reflow(d.element()),g.on(),f=!0,c.trigger.open(),v.set(d.element(),
  "opacity","1"))},close:h,closed:function(){return!f},mousedown:function(a){g.mousedown(a.original())},uiStale:function(){k.instance()},setContent:function(a){y.append(e,a)},setComponents:function(a){l=a.concat([e])},events:c.registry}}},oy=O("menu","popup"),Vl=function(a){return function(b){return N.eq(b.menu(),a)}},OT=aa.detect().deviceType.isiOS,a4=function(a,b,c,d,e){var f=NT(a,b,e.name,e.textkey,e.menuTextkey,e.render,e.layout,c,e.toggle,d);a=function(){e.updateDropdown(He.dropdown({enable:f.enable,
  disable:f.disable,select:f.select,clear:f.clear,selectElement:f.selectElement,populate:f.populate,tick:f.tick,untick:f.untick,activate:f.activate,deactivate:f.deactivate}))};var h=Mf.onButton(f);f.events.select.bind(function(a){e.action(a.value());f.close()});var l=H.create({select:Q(["value","item"],f.events.select),itemHover:Q(["item"],f.events.itemHover),escaped:Q([],f.events.escaped),open:Q(["menu","popup","anchor"],f.events.open),close:Q([],f.events.close)});a();m.set(f.element(),"tabindex",
  "-1");return{dropdown:function(){return{events:l.registry,close:f.close,uiStale:f.uiStale,enable:f.enable,disable:f.disable,list:f.list,menu:f.menu,recalculate:f.recalculate}},component:f.element,refreshUi:a,destroy:function(){h.unbind();f.destroy()}}},b4=function(a,b){b=Mg.typical(a.value,a.value,a.action,a.textkey,a.label,a.tooltip,b);a.setup&&a.setup(b,a);return b},c4=function(a,b){b=Mg.toggle(a.value,a.value,a.action,a.textkey,a.label,a.tooltip,b);a.setup&&a.setup(b,a);a.selected&&b.select();
  return b},d4=function(a,b){var c=!0===b.hasPopup,d=(!0===b.toggle?c4:b4)(b,a);xa(b.icon)&&zn.findAndSetUrl(d.element(),b.icon);var e=d.initAria(d,a(b.textkey),c,b.toggle);m.set(d.element(),"tabindex","-1");var f=function(){!0===b.toggle&&ra.pressed(d)},h=Mf.onButton(d);d.events.click.bind(function(){f()});var l=!0===b.toggle?d.select:t,g=!0===b.toggle?d.deselect:t,C=!0===b.toggle?d.selected:k(!1);f();var w=H.create({click:Q([],d.events.click)});return{generals:function(){return{events:w.registry,
  enableButton:d.enable,disableButton:d.disable}},component:d.element,refreshUi:function(){b.updateGeneral(He.general({disable:e.disable,enable:e.enable,select:l,deselect:g,selected:C,element:d.element}));f()},destroy:function(){h.unbind();d.destroy();e.destroy()}}},e4=aa.detect().deviceType.isiOS,f4=function(a,b,c,d,e,f){var h=e.button(),l=Mf.onButton(h),g=Jq(a.uiContainer,e.name,qj.menu({focusActive:!0}));m.set(h.element(),"tabindex","-1");var k=T.div();n.add(k,va.resolve("menu-system-main"));var w=
  pj(g.sandbox,a.bounds,b,[h.element()],d),I=w.initMenu(k);c=Tl();var G=Kg.main(a.uiContainer,a.bounds,h.element,c,b.uiDirection(),cf.anchored()),p=function(){G.recalculate(I)},t=function(){var a=A.children(g.sandbox());z(a,function(a){v.set(a,"display","none")})},u=function(a){g.update(a.structure());F.empty(k);y.append(k,a.element());a=w.registerMenus(a.submenus());a=E(a,function(a){return a.panel()});F.empty(g.sandbox());P.append(g.sandbox(),[I.panel()].concat(a));t()},x=function(a){e.init(a)},B=
  H.create({open:r(["menu","popup","anchor"]),close:Q([],g.events.close),itemAction:Q(["value","item"],g.events.itemAction),itemHover:Q(["item"],g.events.itemHover),reveal:r(["menu","trigger","popup","anchor"]),collapse:Q(["menu","item"],g.events.collapse),escaped:Q([],g.events.escaped)});h.events.click.bind(function(){return(h.selected()?I.open:I.close)()});e.events.done.bind(function(){g.close()});e.events.abort.bind(function(a){g.select(a.item());Z.focus(a.item())});I.events.uistale.bind(function(){g.getActiveMenu().bind(function(a){x(a)})});
  I.events.close.bind(function(){g.close();ra.collapsed(h.element())});I.events.open.bind(function(){var a=void 0!==f?f:[];a=[g.sandbox()].concat(a);u(e);x(e);v.set(I.panel(),"display","block");v.set(k,"display","block");g.open(a,k);ra.expanded(h.element())});g.events.open.bind(function(){B.trigger.open(e.element(),I,G);e4()||g.setActiveMenu(e.element())});g.events.close.bind(function(){w.hideAll();h.deselect()});g.events.itemAction.bind(function(a){var b=e.handlers();if(void 0!==b[a.value()])(0,b[a.value()])(a.item())});
  g.events.reveal.bind(function(a){ra.expanded(a.trigger());var b=w.expandMenu(a.menu(),a.trigger(),I);B.trigger.reveal(a.menu(),a.trigger(),b.popup,b.anchorage)});g.events.collapse.bind(function(a){w.hideMenu(a.menu());a.item().each(ra.collapsed)});return{menus:function(){return{events:B.registry,enable:e.enable,disable:e.disable,close:I.close,uiStale:I.uiStale,mousedown:I.mousedown,contentFocus:e.contentFocus,menu:I.element,refreshMenus:x,recalculate:p}},component:h.element,refreshUi:function(){e.updateMenu({enable:e.enable,
  disable:e.disable})},destroy:function(){l.unbind();g.destroy();e.destroy();I.destroy()}}},g4=function(a,b){var c=T.span();n.add(c,va.resolve("palette-group"));var d=u(ib.speak,ja.body()),e=function(a){var b=lj.isShowing(c);lj.hide(c);b&&a.each(d);return b},f=He.palette({show:function(a){var b=lj.isHiding(c);lj.show(c);b&&a.each(d);return b},hide:e});e(g.none());P.append(c,E(b,function(a){return a.component()}));return{component:k(c),destroy:function(){z(b,function(a){a.destroy()})},refreshUi:function(){z(b,
  function(a){a.refreshUi()});a.updatePalette(f)}}},h4=function(a,b,c,d,e){var f=e.instance();e=p.fromDom(document);var h=(f.toggle?Mg.splitToggle:Mg.split)(f.name(),f.name(),ca,f.textkey(),f.label(),f.tooltip,c),l=Mf.custom(h.element(),function(){h.open();f.enter()});m.set(h.element(),"tabindex","-1");var g=h.initAria(h,c(f.textkey()),!0,f.toggle);d=pj(a.uiContainer,a.bounds,b,[h.element()],d);var k=Tl(),w=zb.widget(e,f.name());e=Fa("menu-control");m.set(w,"id",e);S.controls(h.element(),e);S.owns(h.element(),
  e);S.menu(w,c(f.menuTextkey()));y.append(w,f.element());var I=d.initMenu(w),G=Kg.main(a.uiContainer,a.bounds,h.element,k,b.uiDirection(),cf.expandable()),n=function(){G.recalculate(I)};I.events.open.bind(function(){ra.expanded(h.element());f.open();t.trigger.open(w,I,G)});I.events.close.bind(function(){ra.collapsed(h.element());f.close();h.close()});f.events.done.bind(function(){I.close();h.close()});f.events.abort.bind(function(){I.close();h.close();t.trigger.abort()});h.events.open.bind(function(){I.open();
  G.recalculate(I)});h.events.close.bind(function(){f.close();I.close()});h.events.click.bind(function(){f.action()});var t=H.create({abort:r([]),close:Q([],f.events.close),open:r(["menu","popup","anchor"])});return{widgets:function(){return{events:t.registry,open:h.open,isOpen:h.isOpen,close:h.close,recalculate:n}},component:h.element,refreshUi:function(){f.updateWidget(He.widget({select:h.select,deselect:h.deselect,enable:h.enable,disable:h.disable,press:g.press,release:g.release}))},destroy:function(){l.unbind();
  g.destroy();I.destroy();f.destroy();h.destroy()}}},i4=function(a,b,c,d,e){var f=e.instance(),h=Mg.toggle(f.name(),f.name(),ca,f.textkey(),f.label(),f.tooltip,c),l=Mf.onButton(h),g=h.initAria(h,c(f.textkey()),!0,!0);c=pj(a.uiContainer,a.bounds,b,[h.element()],d);d=Tl();var k=c.initMenu(f.element()),w=Kg.main(a.uiContainer,a.bounds,h.element,d,b.uiDirection(),cf.expandable());m.set(h.element(),"tabindex","-1");n.add(k.element(),va.resolve("toolbar-widget"));var I=function(){w.recalculate(k)};k.events.open.bind(function(){ra.expanded(h.element());
  f.open();G.trigger.open(f.element(),k,w)});k.events.close.bind(function(){ra.collapsed(h.element());f.close()});f.events.done.bind(function(){k.close();h.deselect()});f.events.abort.bind(function(){k.close();h.deselect();G.trigger.abort()});h.events.click.bind(function(){h.selected()?(k.open(),w.recalculate(k)):k.close();ra.pressed(h)});var G=H.create({abort:r([]),open:r(["menu","popup","anchor"])}),p=function(){h.deselect();k.close()};return{widgets:function(){return{events:G.registry,close:p,recalculate:I}},
  component:h.element,refreshUi:function(){f.updateWidget(He.widget({select:t,deselect:t,enable:g.enable,disable:g.disable,press:t,release:t}))},destroy:function(){l.unbind();g.destroy();k.destroy();f.destroy();h.destroy()}}},j4=function(a,b){var c=b.instance(),d=Mf.custom(c.element(),function(){c.element().dom().click()});m.remove(c.element(),"tabindex");n.add(c.element(),va.resolve("toolbar-inline-widget"));S.toolbarButton(c.element(),a(c.textkey()),!1);var e=H.create({abort:r([]),open:r(["menu",
  "popup","anchor"])});return{widgets:function(){return{events:e.registry,recalculate:t,close:t}},component:c.element,refreshUi:function(){c.updateInlineWidget(He.widget({select:t,deselect:t,enable:u(ra.enable,c.element()),disable:u(ra.disable,c.element()),press:t,release:t}))},destroy:function(){d.unbind();c.destroy()}}},ry={menu:function(a){return{general:u(G3,a),menu:u(J3,a),dropdown:u(E3,a),widget:u(Wl.widget,a),"split-widget":u(Wl.split,a),"inline-widget":u(Wl.inline,a),palette:yb("No palettes for menus yet")}},
  toolbar:function(a,b,c,d){var e=function(e){return u(e,a,b,c,d)};return{menu:e(f4),dropdown:e(a4),widget:e(i4),"split-widget":e(h4),"inline-widget":u(j4,c),general:u(d4,c),palette:g4}}},uE=ta.generate([{toolbar:[]},{menu:[]}]),Lq={toolbar:uE.toolbar,menu:uE.menu,cata:function(a,b,c){return a.fold(b,c)}},k4=function(a,b,c,d){a.events.escaped.bind(function(a){c.focused()&&Z.focus(d.component())});a.events.close.bind(function(a){b.focus()})},l4=function(a,b,c,d){a.events.open.bind(function(a){Uc.register(a.popup().panel())})},
  ST={init:function(a,b,c,d,e,f,h,l,g){var k=a.dropdown(g),q=k.dropdown();a=c.toolbar;(aa.detect().deviceType.isTouch()?l4:k4)(q,e,a,k);var m=!1;q.events.open.bind(function(a){e.toReading();h.show(a.popup(),a.anchor());m=!0});q.events.close.bind(function(){m=!1});q.events.escaped.bind(function(){Z.focus(k.component())});e.events.mousedown.bind(function(){m&&q.close()});e.events.uiStale.bind(q.uiStale);c.toolbar.events.transitionend.bind(function(a){U(["top","height"],a.property())&&q.recalculate()});
  return{component:k.component,refreshUi:k.refreshUi,destroy:k.destroy}}},RT={init:function(a,b,c,d,e,f,h,l,g){a=a.general(g);b=a.generals();a.refreshUi();return{generals:b,component:a.component,refreshUi:a.refreshUi,destroy:a.destroy}}},vE=function(a){var b=g.none(),c=function(){b=g.none()};return{begin:function(){b=g.from(Za.capture(a))},end:function(){b.each(function(a){a.restore()});c()},destroy:c}},Om={fromSafe:function(a){return vE(a.doc())},fromUnsafe:function(a){a=a.doc().getOrDie();return vE(a)}},
  TT={init:function(a,b,c,d,e,f,h,l,k){var q=a.menu(k,[]),w=q.menus(),m=Om.fromUnsafe(e);w.events.open.bind(function(a){e.toReading();w.refreshMenus(a.menu());h.show(a.popup(),a.anchor())});w.events.close.bind(function(){e.focus();m.end()});w.events.escaped.bind(function(){Z.focus(q.component())});w.events.reveal.bind(function(a){k.init(a.menu());h.show(a.popup(),a.anchor())});w.events.itemAction.bind(function(a){m.end()});w.events.itemHover.bind(function(a){m.begin();if(null!==document.activeElement&&
  void 0!==document.activeElement){var b=p.fromDom(document.activeElement),c=A.owner(a.item());"input"!==D.name(b)&&Uc.preserve(c,u(Z.focusInside,a.item()))}else e.backupSelection(),Z.focus(a.item())});e.events.mousedown.bind(w.mousedown);e.events.uiStale.bind(w.uiStale);e.events.focus.bind(w.enable);var G=!e.isInline()&&k.contentFocus();G&&w.disable();return{component:q.component,refreshUi:function(){q.refreshUi();var a=G?g.none():g.some(!0);e.getSelection().or(a).fold(w.disable,w.enable)},destroy:function(){m.destroy();
  e.events.mousedown.unbind(w.mousedown);e.events.uiStale.unbind(w.update);q.destroy()}}}},kt=function(a,b,c,d,e,f,h,l,g,k,w){var q=c[b]({instance:a(w.instance)});a=q.widgets();e=e.toolbar;a.events.open.bind(function(a){h.toReading();g.show(a.popup(),a.anchor())});a.events.abort.bind(function(){Z.focus(q.component())});h.events.mousedown.bind(a.close);return(aa.detect().deviceType.isTouch()&&"split-widget"===b?m4:n4)(a,h,e,q)},n4=function(a,b,c,d){return d},m4=function(a,b,c,d){var e=K.capture(d.component(),
  "click",function(b){b.kill();n.add(d.component(),lb.resolve("statebutton-selected"));a.isOpen()?a.close():a.open()});a.events.close.bind(function(){n.remove(d.component(),lb.resolve("statebutton-selected"))});return{widgets:d.widgets,component:d.component,refreshUi:d.refreshUi,destroy:function(){e.unbind();d.destroy()}}},Mq={widget:u(kt,ca,"widget"),inlineWidget:u(kt,function(a){return function(){return a(Lq.toolbar())}},"inline-widget"),splitWidget:u(kt,ca,"split-widget")},o4=B.resolve("editor-container"),
  Lg={editorContainer:k(o4)},Jn=O("key","link"),wE=O("url","text"),xE=function(a,b,c){return function(d){var e=wE(b,x.translate(c));return Jn(x.pkey(a,d),g.some(e))}},oc=function(a){return function(b){return Jn(x.pkey(a,b),g.none())}},lt=function(a){return function(b){var c=a(b);b=wE(b[0].websiteUrl,x.translate("cloud.dashboard"));return Jn(c.key(),g.some(b))}},p4={"no.api.key":lt(oc("cloud.error.apikey")),"domain.not.supported":lt(function(a){return Jn(x.pkey("cloud.error.domain",[a[0].details.domain]),
  g.none())}),"plan.exceeded":lt(oc("cloud.error.plan")),"error.code.invalid.toolbar":oc("errors.toolbar.invalid"),"error.code.spelling.not.found":oc("errors.spelling.missing.service"),"error.code.images.not.found":oc("errors.images.missing.service"),"safari.imagepaste":xE("errors.safari.image","https://support.ephox.com/entries/88543243-Safari-Direct-paste-of-images-does-not-work","errors.safari.url"),"webview.imagepaste":oc("errors.webview.image"),"flash.clipboard.no.rtf":function(a){return(aa.detect().browser.isSafari()?
  xE("errors.safari.browser-settings","https://support.ephox.com/entries/59328357-Safari-6-1-and-7-Flash-Sandboxing","errors.safari.rtf"):oc("errors.images.missing.flash"))(a)},"fileupload.invalidimages":oc("errors.images.upload.invalid"),"error.imageupload":oc("errors.images.upload.failed"),"error.imageupload.generic":oc("errors.images.upload.unknown"),"error.imageupload.cors":oc("errors.images.upload.cors"),"errors.paste.word.notready":oc("errors.paste.notready"),"errors.paste.process.failure":oc("errors.paste.generic"),
  "flash.crashed":oc("errors.flash.crashed"),"errors.imageimport.failed":oc("errors.images.import.failed"),"errors.imageimport.unsupported":oc("errors.images.import.unsupported"),"errors.imageimport.invalid":oc("errors.images.import.invalid"),"imageedit.needsproxy":oc("errors.images.edit.needsproxy"),"imageedit.proxyerror":oc("errors.images.edit.proxyerror"),"imageedit.generic":oc("errors.images.edit.generic")},q4={"errors.local.images.disallowed":"Removing pasted images from content. Local image insert has been disabled.",
  "errors.dragdrop.images.disallowed":"Blocking image drop operation. Local image insert has been disabled."},yE=function(a,b){a=(0,p4[a])(b);return{description:k(x.get(a.key())),link:k(a.link().getOr(null))}},mf={get:yE,getOrLog:function(a,b){return g.from(q4[a]).fold(function(){var c=yE(a,b);return g.some(c)},function(a){console.warn(a);return g.none()})}},r4=function(a,b){var c=function(b){var c=mf.get("error.code.invalid.toolbar",[b.small()]);c=mj(c);a.displayBanner(c);z(b.big(),function(a){console.error(a)})};
  return b.fold(function(a){c(a);return[]},ca)},zE={setup:function(a,b,c,d,e,f){f=r4(a,f);var h=function(a){a=xa(a)?x.has(a)?x.key(a):x.raw(a):a;return x.get(a)};n.add(a.toolbar.element(),B.resolve("layer-above-editor"));b=MD.blueprints(QT(e.uiContainer,a,b,c,d,e,h),PT(h));e=MD.env(e.uiContainer,h);e=n3.build(f,b,e);z(e,a.toolbar.add);a.position();z(e,function(a){c.events.uiStale.bind(function(){a.refreshUi()})})}},Hh={preserve:function(a,b){var c=A.owner(b),d=Z.active(c).bind(function(a){var c=function(b){return N.eq(a,
  b)};return c(b)?g.some(b):Ja.descendant(b,c)});a=a(b);d.each(function(a){Z.active(c).filter(function(b){return N.eq(b,a)}).isNone()&&Z.focus(a)});return a}},ty=O("component","index"),ZT={item:k('.ephox-chameleon-toolbar-group [tabindex="-1"]'),group:k(".ephox-chameleon-toolbar-group"),sector:k(".ephox-chameleon-toolstrip > *")},AE=va.resolve("toolbar-more-closed"),BE=va.resolve("toolbar-more-open"),xy=va.resolve("toolbar-more-hide"),wy=va.resolve("toolbar-more-show"),Pq=function(a,b){v.set(a,"height",
  b+"px");v.reflow(a)},Oq=function(a){n.remove(a,BE);n.add(a,AE);Pq(a,0)},yy=function(a){n.remove(a,AE);n.add(a,BE);v.remove(a,"height")},mt=O("within","extra","withinWidth"),CE=function(a,b,c){var d=Rd.generate(a,function(a,b){var d=c(a);return g.some({element:k(a),start:k(b),finish:k(b+d),width:k(d)})});a=ka(d,function(a){return a.finish()<b});var e=Eb(a,function(a,b){return a+b.width()},0);d=d.slice(a.length);return{within:k(a),extra:k(d),withinWidth:k(e)}},Kn=function(a){return E(a,function(a){return a.element()})},
  s4=function(a,b,c){a=Kn(a.concat(b));return mt(a,[],c)},t4=function(a,b,c,d){a=Kn(a).concat([c]);return mt(a,Kn(b),d)},u4=function(a,b,c){return mt(Kn(a),[],c)},v4=function(a,b,c){a=CE(b,a,c);return 0===a.extra().length?g.some(a):g.none()},XT={partition:function(a,b,c,d){var e=v4(a,b,c).getOrThunk(function(){return CE(b,a-c(d),c)}),f=e.within(),h=e.extra();e=e.withinWidth();return 1===h.length&&h[0].width()<=c(d)?s4(f,h,e):1<=h.length?t4(f,h,d,e):u4(f,h,e)}},Ba={grid:Aa(["trigger"],["isValid","first"]),
  flow:Aa(["trigger"],["first","executeOnArrow"]),sectors:Aa(["trigger","first"],[]),radio:Aa(["one"],[]),input:Aa([],["execute"]),button:Aa(["execute"],["process"]),dialog:Aa(["execute","ok","cancel"],["index"]),inlineDialog:Aa(["ok","cancel"],["index"]),page:Aa(["trigger"],["first"]),tabular:Aa(["trigger"],["first","isValid"]),dynamic:Aa([],["execute"])},fd=eh(fh,["enter","exit","destroy"]),DE=function(a){return function(b){return b.raw().which===a}},ea={inSet:function(a){return function(b){return U(a,
  b.raw().which)}},and:function(a){return function(b){return ob(a,function(a){return a(b)})}},is:DE,isShift:function(a){return!0===a.raw().shiftKey},basic:function(a,b){return{matches:DE(a),run:b}},rule:function(a,b){return{matches:a,run:b}}},nt=function(a){m.has(a,"tabIndex")||m.set(a,"tabIndex","-1")},fb={set:function(a){nt(a);Z.focus(a)},find:function(a){return Z.search(a)},isFocused:Z.hasFocus,mark:nt,markSelectors:function(a,b){z(b,function(b){b=Y.descendants(a,b);z(b,nt)})}},Ke={adjust:function(a,
  b,c,d){a+=b;return a>d?c:a<c?d:a},findPrev:function(a,b,c){var d=jd(a.slice(0,b));a=jd(a.slice(b+1));return qa(d.concat(a),c)},findNext:function(a,b,c){var d=a.slice(0,b);a=a.slice(b+1);return qa(a.concat(d),c)}},EE=function(a){return qa(a,Ln)},Ln=function(a){return sc.isVisible(a.element())&&a.isEnabled()&&"hidden"!==v.get(a.element(),"visibility")},ya={exit:function(a){z(a,function(a){a.clear();a.exit()})},clear:function(a){z(a,function(a){a.clear()})},refresh:function(a){z(a,function(a){a.refresh()})},
  first:EE,enterFirst:function(a,b){b.index().bind(function(b){return g.from(a[b]).filter(Ln)}).orThunk(function(){return EE(a)}).each(function(a){a.enter()})},isEnabled:function(a){return Xa(a,function(a){return a.isEnabled()})},locate:function(a,b){return qa(a,function(a){var c=b.target();a=a.element();return wd.closest(c,u(N.eq,a))}).getOr(void 0)},next:function(a,b){var c=Gc(a,b).getOr(-1);return Ke.findNext(a,c,Ln).getOr(b)},prev:function(a,b){var c=Gc(a,b).getOr(-1);return Ke.findPrev(a,c,Ln).getOr(b)},
  prevNoCycle:function(a,b){b=Gc(a,b).getOr(-1);return 0<b?g.some(a[b-1]):g.none()},nextNoCycle:function(a,b){b=Gc(a,b).getOr(-1);return b+1<a.length?g.some(a[b+1]):g.none()},progress:function(a,b){a.exit();b.enter()},destroy:function(a){z(a,function(a){a.destroy()})}},w4=Aa(["index","focused","group","items"],[]),x4=Aa(["index","sectors","sector"],[]),y4=Aa(["index","candidates"],[]),jh={ofFocus:function(a,b,c){return fb.find(a).bind(function(a){return L.closest(a,b).bind(function(b){var d=Y.descendants(b,
  c),e=ka(d,sc.isVisible);return Va(e,u(N.eq,a)).map(function(c){return w4({index:c,focused:a,group:b,items:e})})})})},ofSector:function(a,b,c){var d=Y.descendants(a,b);return L.closest(c,b).bind(function(a){return Va(d,u(N.eq,a)).map(function(b){return x4({index:b,sectors:d,sector:a})})})},within:function(a,b,c){var d=Y.descendants(a,c);return Va(d,u(N.eq,b)).map(function(a){return y4({index:a,candidates:d})})}},FE={horizontal:function(a,b,c,d){return jh.within(a,c,b).bind(function(a){var b=a.index();
  a=a.candidates();b=Ke.adjust(b,d,0,a.length-1);return g.from(a[b])})}},Mn={delegate:function(a,b,c){return Nf(a,[ea.basic(R.LEFT()[0],b.west),ea.basic(R.RIGHT()[0],b.east),ea.basic(R.UP()[0],b.north),ea.basic(R.DOWN()[0],b.south),ea.rule(ea.inSet(R.SPACE().concat(R.ENTER())),function(){return fb.find(a).bind(c.trigger()).map(Jb)})],g.none())},findRecent:function(a,b,c,d){return d.isValid().fold(k(c),function(a){return c.filter(a)}).orThunk(function(){return d.first().bind(function(a){return a()}).orThunk(function(){return L.descendant(a,
  b)})})}},z4=O("row","column"),fa={set:function(a,b){if(void 0===b)throw Error("Value.set was undefined");a.dom().value=b},get:function(a){return a.dom().value}},A4={move:function(a,b,c){var d=O("row","col"),e=a.length-1,f=a[b.row()]-1;e=Ke.adjust(b.row(),c.dr(),0,e);a=a[e]-1;f=Math.max(f,a);b=Math.min(a,Ke.adjust(b.col(),c.dc(),0,f));return d(e,b)}},GE={single:Nf,multiple:function(a,b){var c=K.bind(a,"keydown",function(a){var c=ya.locate(b,a);if(ea.is(R.ESCAPE()[0])(a))d(),a.kill();else if(void 0!==
  c&&null!==c&&ea.is(R.TAB()[0])(a)){var e=(ea.isShift(a)?ya.prev:ya.next)(b,c);ya.progress(c,e);a.kill()}}),d=function(){ya.exit(b);e.trigger.exit()},e=H.create({enter:r([]),exit:r([])});return fd({enter:function(){ya.first(b).each(function(a){a.enter()})},exit:d,clear:u(ya.clear,b),refresh:u(ya.refresh,b),isEnabled:u(ya.isEnabled,b),isFocused:u(fb.isFocused,a),destroy:function(){ya.destroy(b);c.unbind()},events:e.registry})},multipleAll:function(a,b){var c=K.bind(a,"keydown",function(a){var c=ya.locate(b,
  a);if(ea.is(R.ESCAPE()[0])(a))d(),a.kill();else if(void 0!==c&&null!==c)if(ea.is(R.UP()[0])(a))ya.progress(c,ya.prev(b,c)),a.kill();else if(ea.is(R.DOWN()[0])(a))ya.progress(c,ya.next(b,c)),a.kill();else if(ea.is(R.TAB()[0])(a)){var e=(ea.isShift(a)?ya.prev:ya.next)(b,c);ya.progress(c,e);a.kill()}}),d=function(){ya.exit(b);e.trigger.exit()},e=H.create({enter:r([]),exit:r([])});return fd({enter:function(){ya.first(b).each(function(a){a.enter()})},exit:d,clear:u(ya.clear,b),refresh:u(ya.refresh,b),
  isEnabled:u(ya.isEnabled,b),isFocused:u(fb.isFocused,a),events:e.registry,destroy:function(){ya.destroy(b);c.unbind()}})},flow:function(a,b,c){var d=g.none();fb.markSelectors(a,[b.item()]);var e=function(c){return fb.find(a).bind(function(d){return FE.horizontal(a,b.item(),d,c)})},f=rj(a,function(a){return e(a).bind(function(a){q(a);return c.executeOnArrow().fold(function(){return g.some(!0)},h)})}),h=function(){return fb.find(a).bind(c.trigger()).map(Jb)},l=Nf(a,[ea.rule(ea.inSet(R.LEFT().concat(R.UP())),
  f.west),ea.rule(ea.inSet(R.RIGHT().concat(R.DOWN())),f.east),ea.rule(ea.inSet(R.SPACE().concat(R.ENTER())),h)],g.none()),q=function(a){d=g.some(a);fb.set(a)};return fd({element:l.element,destroy:l.destroy,clickFocus:function(a){Ia.is(a,b.item())&&q(a)},clear:function(){d=g.none()},isFocused:l.isFocused,isEnabled:k(!0),refresh:t,enter:function(){l.enter();d.orThunk(function(){return c.first().fold(function(){return L.descendant(a,b.item())},xb)}).each(q)},exit:l.exit})},grid:function(a,b,c,d,e){var f=
  c,h=d;fb.markSelectors(a,[b.cell()]);var l=na(g.none()),k=function(a){return A.findIndex(a).map(function(a){return z4(Math.floor(a/h),a%h)})},C=function(c,d){return fb.find(a).bind(function(e){return k(e).bind(function(e){var l=Ke.adjust(e.row(),d,0,f-1),k=Ke.adjust(e.column(),c,0,h-1);e=Y.descendants(a,b.cell());var q=e.length-1;l*=h;l=l+k>q?0<c?l:q:l+k;return 0<=l&&l<e.length?g.some(e[l]):g.none()})})};c=rj(a,function(a,b){return C(a,b).bind(function(a){fb.set(a);l.set(g.some(a));return g.some(!0)})});
  var w=Mn.delegate(a,c,e);return fd({element:w.element,destroy:w.destroy,clear:function(){l.set(g.none())},isFocused:w.isFocused,isEnabled:Jb,refresh:t,enter:function(){w.enter();l.set(Mn.findRecent(a,b.cell(),l.get(),e));l.get().each(Z.focus)},exit:w.exit,resize:function(a,b){f=a;h=b}})},sectors:function(a,b,c){fb.markSelectors(a,[b.sector(),b.group(),b.item()]);var d=function(a){return Ja.descendant(a,function(a){return Ia.is(a,b.item())&&k(a)})},e=function(a){return Ja.child(a,m)},f=function(a){a=
  cd.children(a,m);return 0<a.length?g.some(a[a.length-1]):g.none()},h=rj(a,function(c){return jh.ofFocus(a,b.group(),b.item()).bind(function(a){var b=a.items();a=Ke.adjust(a.index(),c,0,b.length-1);return g.from(b[a])})}),l=function(c){return jh.ofFocus(a,b.group(),b.item()).bind(function(a){return c(a.group()).bind(d)})},k=function(a){return 0<sa.get(a)},C=function(c){return jh.ofSector(a,b.sector(),c).map(function(a){return Ke.findPrev(a.sectors(),a.index(),k).getOr(a.sector())})},w=function(c){return jh.ofSector(a,
  b.sector(),c).map(function(a){return Ke.findNext(a.sectors(),a.index(),k).getOr(a.sector())})},m=function(a){var c;if(c=Ia.is(a,b.group()))a=Y.descendants(a,b.item()),c=Xa(a,sc.isVisible);return c},G=function(a){return function(){return a().map(function(a){fb.set(a);n.trigger.active(a);return a})}},n=H.create({enter:r([]),exit:r([]),active:r(["element"])}),p=Nf(a,[ea.rule(ea.inSet(R.ESCAPE()),function(){p.exit();n.trigger.exit();return g.some(!0)}),ea.rule(ea.inSet(R.RIGHT().concat(R.DOWN())),G(h.east)),
  ea.rule(ea.inSet(R.LEFT().concat(R.UP())),G(h.west)),ea.rule(ea.and([ea.isShift,ea.inSet(R.TAB())]),G(u(l,function(a){return A.prevSibling(a).filter(m).orThunk(function(){return C(a).bind(f)})}))),ea.rule(ea.inSet(R.TAB()),G(u(l,function(a){return A.nextSibling(a).filter(m).orThunk(function(){return w(a).bind(e)})}))),ea.rule(ea.inSet(R.SPACE().concat(R.ENTER())),function(){return fb.find(a).bind(c.trigger()).map(Jb)})],g.none());return fd({element:p.element,clear:t,isFocused:p.isFocused,enter:function(){p.enter();
  n.trigger.enter();c.first()().orThunk(function(){return d(a)}).each(function(a){fb.set(a);n.trigger.active(a)})},refresh:t,isEnabled:Jb,exit:p.exit,destroy:p.destroy,events:n.registry})},radio:function(a,b,c){var d=function(c){return fb.find(a).bind(function(d){return FE.horizontal(a,b.item(),d,c)})},e=rj(a,function(b){return d(b).bind(function(b){fb.set(b);c.one()(a,b);return g.some(!0)})}),f=Nf(a,[ea.rule(ea.inSet(R.LEFT().concat(R.UP())),e.west),ea.rule(ea.inSet(R.RIGHT().concat(R.DOWN())),e.east),
  ea.rule(ea.inSet(R.SPACE()),u(g.some,!0))],g.none());return fd({element:f.element,destroy:f.destroy,clear:t,refresh:function(){f.isFocused()&&L.descendant(a,b.selected()).each(fb.set)},isFocused:f.isFocused,isEnabled:Jb,enter:function(){f.enter();L.descendant(a,b.selected()).orThunk(function(){return L.descendant(a,b.item())}).each(function(d){Ia.is(d,b.selected())||c.one()(a,d);fb.set(d)})},exit:f.exit})},input:function(a,b){var c=Nf(a,[ea.basic(R.ENTER()[0],function(c){return b.execute().map(function(b){var d=
  {isShift:k(ea.isShift(c))},e=fa.get(a);b(e,d);return!0})})],g.none());return fd({element:c.element,destroy:c.destroy,clear:c.clear,isFocused:c.isFocused,isEnabled:function(){return!m.has(a,"disabled")},refresh:t,enter:function(){c.enter();a.dom().setSelectionRange(0,fa.get(a).length)},exit:c.exit})},dialog:function(a,b,c){var d=c.execute(),e=Ba.button({execute:d}),f=b.slice(0).concat([Qq(c.cancel(),e),Qq(c.ok(),e)]),h=K.bind(a,"keydown",function(a){var b=ya.locate(f,a);if(void 0!==b&&null!==b){var e=
  ea.isShift(a);ea.is(R.TAB()[0])(a)?(e=(e?ya.prev:ya.next)(f,b),ya.progress(b,e),a.kill()):ea.is(R.ESCAPE()[0])(a)?(l(),a.kill(),d(c.cancel())):"button"===D.name(b.element())||e||!ea.is(R.ENTER()[0])(a)?(b=[R.UP()[0],R.DOWN()[0]],e=["textarea","select","input"],ea.inSet(b)(a)&&!1===U(e,D.name(a.target()))&&a.kill()):(d(c.ok()),a.kill())}}),l=function(){ya.exit(f);g.trigger.exit()},g=H.create({enter:r([]),exit:r([])});return fd({enter:function(){ya.enterFirst(f,c)},exit:l,clear:u(ya.clear,f),refresh:u(ya.refresh,
  f),isEnabled:u(ya.isEnabled,f),isFocused:u(fb.isFocused,a),events:g.registry,destroy:function(){ya.destroy(f);h.unbind()}})},button:Qq,inlineDialog:function(a,b,c){var d=c.ok(),e=c.cancel(),f=K.bind(a,"keydown",function(a){var c=ya.locate(b,a);if(void 0!==c&&null!==c){var f=ea.isShift(a);ea.is(R.TAB()[0])(a)?(f=(f?ya.prev:ya.next)(b,c),ya.progress(c,f),a.kill()):ea.is(R.ESCAPE()[0])(a)?(h(),a.kill(),e(a.target())):!f&&ea.is(R.ENTER()[0])(a)?(d(a.target()),a.kill()):(c=[R.UP()[0],R.DOWN()[0]],f=["textarea",
  "select","input"],ea.inSet(c)(a)&&!1===U(f,D.name(a.target()))&&a.kill())}}),h=function(){ya.exit(b);l.trigger.exit()},l=H.create({enter:r([]),exit:r([])});return fd({enter:function(){ya.enterFirst(b,c)},exit:h,clear:u(ya.clear,b),refresh:u(ya.refresh,b),isEnabled:u(ya.isEnabled,b),isFocused:u(fb.isFocused,a),events:l.registry,destroy:function(){ya.destroy(b);f.unbind()}})},tabular:function(a,b,c){var d=b.row(),e=b.cell();fb.markSelectors(a,[d,e]);var f=na(g.none()),h=rj(a,function(a,b){return G(a,
  b).bind(function(a){fb.set(a);f.set(g.some(a));return g.some(!0)})}),l=O("row","col"),k=O("dc","dr"),C=function(a){a=Y.descendants(a,d);return E(a,function(a){return Y.descendants(a,e).length})},w=function(b){return L.closest(b,d).bind(function(c){return jh.within(a,c,d).bind(function(a){return jh.within(c,b,e).map(function(b){return l(a.index(),b.index())})})})},m=function(b){var c=Y.descendants(a,d);return g.from(c[b.row()]).bind(function(a){a=Y.descendants(a,e);return g.from(a[b.col()])})},G=function(b,
  c){return fb.find(a).bind(function(d){return w(d).bind(function(d){var e=C(a);d=A4.move(e,d,k(b,c));return m(d)})})},n=Mn.delegate(a,h,c);return fd({element:n.element,destroy:n.destroy,clear:function(){f.set(g.none())},isFocused:n.isFocused,isEnabled:Jb,refresh:t,enter:function(){n.enter();f.set(Mn.findRecent(a,b.cell(),f.get(),c));f.get().each(fb.set)},exit:n.exit})},page:function(a,b,c){var d=b.stops().join(","),e=function(){return c.first().bind(function(b){return L.descendant(a,b)}).getOr(a)},
  f=function(a){var b=e();return(Z.hasFocus(b)?g.some:fb.find)(b).bind(function(b){var c=e();if(N.eq(c,b)&&0>a)c=g.none();else{var f=Y.descendants(c,d);b=Va(f,u(N.eq,b)).getOr(-1)+a;c=b>=f.length?g.none():0>b?g.some(c):0<=b&&b<f.length?g.some(f[b]):g.none()}return c})};b=function(a){return f(a).bind(function(a){fb.set(a);return g.some(!0)})};var h=Nf(a,[ea.rule(ea.and([ea.isShift,ea.inSet(R.TAB())]),u(b,-1)),ea.rule(ea.inSet(R.TAB()),u(b,1)),ea.rule(ea.inSet(R.SPACE().concat(R.ENTER())),function(){return fb.find(a).bind(c.trigger()).map(Jb)})],
  g.none());return fd({element:h.element,destroy:h.destroy,clear:t,isFocused:h.isFocused,isEnabled:Jb,refresh:t,enter:function(){h.enter();fb.set(e())},exit:h.exit})},dynamic:function(a){var b=na([]),c=function(a,c){ea.is(R.TAB()[0])(c)&&(ea.isShift(c)?ya.prevNoCycle:ya.nextNoCycle)(b.get(),a).each(function(b){ya.progress(a,b);c.kill()})},d=K.bind(a,"keydown",function(a){var d=ya.locate(b.get(),a);void 0!==d&&null!==d&&c(d,a)}),e=H.create({enter:r([]),exit:r([])}),f=function(a){return function(){return a(b.get())}};
  return fd({element:k(a),enter:function(){ya.first(b.get()).each(function(a){a.enter()})},exit:function(){ya.exit(b.get());e.trigger.exit()},set:function(a){ya.destroy(b.get());b.set(a)},clear:f(ya.clear),refresh:f(ya.refresh),isEnabled:f(ya.isEnabled),isFocused:u(fb.isFocused,a),destroy:function(){ya.destroy(b.get());d.unbind()},events:e.registry})}},B4={grid:function(a,b,c,d,e){fb.markSelectors(a,[b.cell()])}},C4=function(a,b){var c=g.from(B4[b]).getOr(t);return function(){c.apply(null,arguments);
  return{element:t,clear:t,isFocused:t,isEnabled:t,refresh:t,enter:t,exit:t,events:H.create({enter:r([]),exit:r([]),active:r([])}).registry,destroy:t,set:t,clickFocus:t,resize:t}}},ha=aa.detect().deviceType.isTouch()?eb(GE,C4):GE,df={toolbar:function(a,b){return YT(a,b)},menu:function(a,b,c){return JD.create(a,b,c)},popup:function(a,b,c,d,e){return pj(a,b,c,d,e)},menuSystem:function(a,b,c){return Jq(a,b,c)}},be={styleSpan:k("ephox-hare-style-span"),base:k("ephox-candy-mountain"),active:k("ephox-candy-mountain-active"),
  autoresize:k("ephox-candy-mountain-autoresize")},HE=aa.detect(),Nn=HE.deviceType.isTouch,D4=HE.deviceType.isAndroid,On=function(a,b){return Zg.screen.width>=a&&Zg.screen.height>=b},IE=function(){return!On(620,700)&&Nn()},xc={isTouch:Nn,choice:function(a,b){return hb(a,function(a,b){return a.orThunk(function(){return b.predicate()?g.some(b.value()):g.none()})},g.none()).getOr(b)},isLarge:function(){return On(620,700)},isLargeTouch:function(){return On(620,700)&&Nn()},isSmallTouch:IE,isLargeDesktop:function(){return On(620,
  700)&&!Nn()},isSmallAndroid:function(){return IE()&&D4()}},kh=aa.detect(),E4={"ephox-platform-desktop":!kh.deviceType.isTouch(),"ephox-platform-touch":kh.deviceType.isTouch(),"ephox-platform-small-touch":xc.isSmallTouch(),"ephox-platform-android":kh.deviceType.isAndroid(),"ephox-platform-ios":kh.deviceType.isiOS(),"ephox-platform-ie":kh.browser.isIE()||kh.browser.isEdge(),"ephox-platform-firefox":kh.browser.isFirefox()},JE=[];Ma(E4,function(a,b){!0===a&&JE.push(b)});var Xr={addClasses:function(a){ma.add(a,
  JE)}},KE=function(a,b){var c=p.fromTag("div");n.add(c,B.resolve(b));y.append(c,a);return c},Jy={build:function(a,b,c){g.from(b).filter(ak.isPrototypeOf).map(p.fromDom).each(function(b){var c=p.fromTag("div");n.add(c,B.resolve("flex-row"));var d=p.fromTag("div");n.add(d,B.resolve("flex-column"));P.append(d,A.children(a));y.append(a,c);y.append(c,d);y.append(c,KE(b,"side-bar"))});g.from(c).filter(ak.isPrototypeOf).map(p.fromDom).each(function(b){y.append(a,KE(b,"bottom-bar"))})}},F4=xd(["compare","extract",
  "mutate","sink"]),G4=xd(["element","start","stop","destroy"]),H4=xd(["forceDrop","drop","move","delayDrop"]),qm={mode:F4,sink:G4,api:H4},By={resolve:Bn("ephox-dragster").resolve},I4=qm.mode({compare:function(a,b){return Qa(b.left()-a.left(),b.top()-a.top())},extract:function(a){return g.some(Qa(a.x(),a.y()))},sink:function(a,b){var c=aU(b),d=K.bind(c.element(),"mousedown",a.forceDrop),e=K.bind(c.element(),"mouseup",a.drop),f=K.bind(c.element(),"mousemove",a.move),h=K.bind(c.element(),"mouseout",a.delayDrop);
  return qm.sink({element:c.element,start:function(a){y.append(a,c.element())},stop:function(){F.remove(c.element())},destroy:function(){c.destroy();e.unbind();f.unbind();h.unbind();d.unbind()}})},mutate:function(a,b){a.mutate(b.left(),b.top())}}),J4={setup:function(a,b,c){var d=!1,e=H.create({start:r([]),stop:r([])}),f=dU(),h=function(){k.stop();f.isOn()&&(f.off(),e.trigger.stop())},l=tj(h,200);f.events.move.bind(function(c){b.mutate(a,c.info())});var g=function(a){return function(){var b=Array.prototype.slice.call(arguments,
  0);if(d)return a.apply(null,b)}},k=b.sink(qm.api({forceDrop:h,drop:g(h),move:g(function(a,c){l.cancel();f.onEvent(a,b)}),delayDrop:g(l.throttle)}),c);return{element:k.element,go:function(a){k.start(a);f.on();e.trigger.start()},on:function(){d=!0},off:function(){d=!1},destroy:function(){k.destroy()},events:e.registry}}},sj={transform:function(a,b){var c=void 0!==b?b:{};return J4.setup(a,void 0!==c.mode?c.mode:I4,b)}},fU={both:function(a){var b=H.create({relocate:r(["x","y","deltaX","deltaY"])});return{mutate:function(c,
  d){var e=bb.absolute(a),f=e.left()+c;e=e.top()+d;b.trigger.relocate(f,e,c,d)},events:b.registry}}},LE=O("hx","hy","position","x","y"),K4=function(a,b,c,d,e,f){f=b.x();b=b.y()-c;return(b>=a.y()&&b<=a.y()+a.h()?[LE(f,b,"absolute",f,b)]:[]).concat([LE(e,a.y(),"fixed",e-d.left(),a.fy())])},L4={detect:function(a,b,c,d,e,f){a=K4(a,b,e,f,c,d);return qa(a,function(a){return 10>Math.abs(d-a.hy())&&38>Math.abs(c-a.hx())})}},ME={box:function(a){var b=bb.absolute(a),c=Ga.getOuter(a);a=sa.getOuter(a);var d=b.left();
  b=b.top();return{x:k(d),y:k(b),width:k(c),height:k(a),right:k(d+c),bottom:k(b+a)}}},ot={resolve:Lb.create("ephox-ego").resolve},Pn=function(a){var b="data-"+ot.resolve(a+"-left"),c="data-"+ot.resolve(a+"-top"),d="data-"+ot.resolve(a+"-position");return{get:function(a){var e=parseInt(m.get(a,b),10),h=parseInt(m.get(a,c),10);a=m.get(a,d);return isNaN(e)||isNaN(h)?g.none():g.some({left:k(e),top:k(h),position:k(a)})},set:function(a,f,h,l){m.set(a,d,f);m.set(a,b,h+"px");m.set(a,c,l+"px")},clear:function(a){m.remove(a,
  d);m.remove(a,b);m.remove(a,c)}}}("pre-snap"),M4=function(a,b,c,d,e,f){return Pn.get(b).fold(function(){return a.fromLocation(b,c,d)},function(c){return a.fromFixed(b,c.left()+e,c.top()+f)})},N4=function(a,b,c,d){var e=A.owner(b);e=Za.get(e);b=ME.box(b);c=c.loc();return L4.detect(a,b,c.left(),c.top(),d,e)},pt=function(a,b,c,d){return{attrs:{"data-ephox-snap":"absolute"===b?"true":"false"},styles:{position:b,left:a.left+c+"px",top:a.top+d+"px"}}},qk={move:function(a,b,c,d,e,f){var h=a.graph(),l=a.lazyTheatre(),
  g=a.lazyHeight();c=M4(h,b,c,d,e,f);var k=c.loc(),w=c.fixed(),m={top:0,left:0};return N4(l,a.container(),c,g).fold(function(){var a=h.boundToFixed(l,b,k.left(),k.top(),w.left(),w.top(),g);Pn.set(b,"fixed",a.left(),a.top());return pt(m,"fixed",a.left(),a.top())},function(c){var d=h.boundToFixed(l,b,k.left(),k.top(),w.left(),w.top(),g);Pn.set(b,"fixed",d.left(),d.top());d="absolute"===c.position()?h.locationToAbsolute(b,c.x(),c.y()):Qa(c.x(),c.y());a.resetOffset();return pt(m,c.position(),d.left(),d.top())})},
  getSnapAttrs:pt,forget:function(a){Pn.clear(a)}},Gy={none:function(a,b){var c=H.create({dragend:r([]),moved:r([])});return{blocker:yb("no blocker"),setState:t,getState:k({}),init:function(d,e){d=qk.getSnapAttrs(a.getOffset(),"absolute",d,e);v.setAll(b,d.styles);m.setAll(b,d.attrs);c.trigger.moved()},update:t,destroy:t,events:c.registry}},except:function(a){return function(b,c){var d=eU(c,a.join(",")),e=H.create({dragend:Q([],d.events.dragend),moved:r([])});d.events.relocate.bind(function(a){var d=
  a.x(),e=a.y(),f=a.deltaX();a=a.deltaY();d=qk.move(b,c,d,e,f,a);v.setAll(c,d.styles);m.setAll(c,d.attrs)});d.events.dragend.bind(function(){e.trigger.moved()});return{blocker:d.blocker,setState:function(a){v.setAll(c,a.styles);m.setAll(c,a.attrs)},getState:function(){var a=bb.viewport(c);return qk.getSnapAttrs(b.getOffset(),"absolute",a.left(),a.top())},init:function(a,d){a=qk.getSnapAttrs(b.getOffset(),"absolute",a,d);v.setAll(c,a.styles);m.setAll(c,a.attrs);e.trigger.moved()},update:function(){qk.forget(c)},
  destroy:function(){d.destroy()},events:e.registry}}}},Cy={isInside:function(a,b,c,d){return!(b>a.y()+a.h()||c-d<a.y())},isAllInside:function(a,b,c){return b>a.y()&&b<a.y()+a.h()&&c>a.y()&&c<a.y()+a.h()}},Hy={register:function(a,b,c,d){var e=a.container(),f=c(a,b),h=d(a,b),l=gU();c=H.create({dragend:Q([],f.events.dragend),appear:Q(["element"],h.events.appear),disappear:Q(["element"],h.events.disappear),dock:Q([],l.events.dock),undock:Q([],l.events.undock)});f.events.moved.bind(function(){C();k=!0});
  h.events.scrolled.bind(function(){C()});h.events.appear.bind(function(){var c=a.lazyTheatre(),d=a.graph();l.update(d,c,b,a.lazyHeight,e,a.getOffset())});var k=!1,C=function(){if(sc.isVisible(b)){f.update();h.update();var c=a.lazyTheatre(),d=bb.absolute(b);c=Math.max(0,c.x()+c.w()-d.left());v.set(b,"max-width",c+"px")}};return{blocker:f.blocker,setState:function(a){f.setState(a);C();k=!0},state:function(){return k?g.some(f.getState()):g.none()},init:function(b,c,d){a.setOffset(d);f.init(b,c);C()},
  update:C,destroy:function(){h.destroy();f.destroy()},events:c.registry}}},Fy={transitions:function(a,b){var c=a.container(),d=A.defaultView(b),e=H.create({appear:r(["element"]),disappear:r(["element"]),scrolled:r([])}),f=K.bind(d,"scroll",function(){e.trigger.scrolled()});return{update:function(){var d=a.lazyTheatre(),f=a.lazyHeight(),g=ME.box(c);Cy.isInside(d,g.y(),g.bottom(),f)?e.trigger.appear(b):e.trigger.disappear(b)},destroy:function(){f.unbind()},events:e.registry}}},Dy=O("fixed","loc"),iU=
  function(a,b,c,d){b=hU(b);var e={top:0,left:0},f=function(a){e.top=a.top;e.left=a.left};return{lazyTheatre:a,graph:k(b),lazyHeight:c,container:k(d),setOffset:f,resetOffset:function(){f({top:-1*c(),left:0})},getOffset:function(){return e}}},qt=B.resolve("drag-show"),NE=B.resolve("fade-container"),pd={width:function(a,b){return v.getRaw(a,"max-width").fold(function(){return A.owner(b).dom().defaultView.innerWidth-bb.absolute(b).left()},function(a){return parseInt(a,10)})},updateWidth:function(a,b,c){b=
  0===c.extra().length?c.withinWidth():c.withinWidth()+Ga.getOuter(b.group());0<b&&v.set(a,"width",b+"px")},clearWidth:function(a){v.remove(a,"width")},offsetFrom:function(a,b,c,d){b=void 0!==d.toolbar.offset?d.toolbar.offset:d.toolbar.sticky?{left:0,top:0}:{left:0,top:-1*c};c=bb.absolute(a.element());a=a.isInline()?{left:c.left(),top:c.top()}:{left:0,top:0};return{left:a.left+b.left,top:a.top+b.top}},initFade:function(a){n.add(a,qt)},fadeIn:function(a,b){z(a,function(a){n.remove(a,NE)});n.add(b,qt)},
  fadeOut:function(a,b){z(a,function(a){n.add(a,NE)});n.remove(b,qt)}},mU={setup:function(a,b,c,d){return(!0===c.toolbar.draggable?jU:!0===c.toolbar.sticky||void 0!==c.toolbar.offset||a.isInline()?kU:Ay)(a,b,c)}};aa.detect();var Iy=function(a,b){a.updateUi(b);a=[Lg.editorContainer(),"ephox-textbox-font",B.resolve("layer-editor")];ma.add(b,a);m.set(b,"lang",qf.get());Xr.addClasses(b)},O4=function(a){a=Bf.absolute(a);var b=Bf.view();a=Y2.intersect(a,b);return eg(a.x(),a.y(),a.width(),a.height())},Yr=
  {build:function(a,b,c,d,e,f,h,l){var g=lU(a,b,c,f,h,l),k=d.tabbed(g);k.init();return{element:g.element,socket:g.socket,viewport:g.viewport,uiContainerParent:g.uiContainerParent,init:function(b,d,h){d=k.config(a.isInline(),d,e,h);zE.setup(g,f,a,b,c,d);k.loaded()},connect:g.connect,destroy:function(){g.destroy();k.destroy()},displayBanner:g.displayBanner,hideBanner:g.hideBanner,position:g.position,refresh:g.refresh,tabstrip:g.toolbar,state:g.state,dialogContainer:g.dialogContainer}},bounds:function(){var a=
  function(a){var b=function(){return g.from(a.bounds()).filter(ak.isPrototypeOf).map(p.fromDom).map(O4).getOrThunk(Bf.view)};return qb(a.bounds)?b:Bf.view};return aa.detect().deviceType.isTouch()?k(Bf.view):a}()},BB={settings:function(a){return{onprem:!0,blocktag:{styles:[{rule:"p"},{rule:"h1"},{rule:"h2"},{rule:"h3"},{rule:"h4"},{rule:"div"},{rule:"pre"}],showDocumentStyles:!1,bundled:!0},image:{bundled:!0},imageEdit:{bundled:!0},imageupload:{immediate:!1,bundled:!1},content:{imageExcludes:[],css:a+
  "/css",tabindex:null,stylesheets:[],documentStyles:"",prettyprint:!0,showDocumentStyles:!1,autoresize:!1},ui:{layout:Yr,isFullScreen:!1,toolbar:{draggable:!1,sticky:!1},locale:{},editorName:J.value("debug"),bounds:null,showHelpHint:!1,autoresize:!1},shortcuts:{features:!0},spelling:{bundled:!0,autocorrect:!0,scanView:!0,multilingual:!0,menu:!0},specialchar:{bundled:!0},fileupload:{bundled:!0,allowLocalImages:!0},horizontalrule:{bundled:!0},media:{bundled:!0},mentions:{bundled:!1},registration:{bundled:!1},
  help:{baseUrl:a+"/html",integration:{},bundled:!0},draganddrop:{bundled:!0},wordcount:{bundled:!0},formatting:{bundled:!0},alignindent:{bundled:!0},directionality:{bundled:!0},parlance:{bundled:!0,languages:"en_us en_gb es fr de pt zh".split(" ")},font:{faces:[],colors:{custom:!0,buttons:[]},bundled:!0},lists:{bundled:!0},link:{bundled:!0},linkvalidator:{bundled:!1},bookmark:{bundled:!0},removeformat:{bundled:!0},fullscreen:{bundled:!0},editorcontext:{bundled:!0},macros:{allowed:g.none(),bundled:!0},
  highlighter:{external:[],bundled:!0},table:{colors:{custom:!0,buttons:[]},bundled:!0},contextmenu:{bundled:!0},project:{apiKey:null},smartclipboard:{bundled:!0,copy:{},paste:{forceText:!1,baseUrl:a+"/js",swf:a+"/flash/textboxpaste.swf",officeStyles:"prompt",htmlStyles:"merge",allowLocalImages:!0,enableFlashImport:!0}},resize:{bundled:!0},platform:{toolbar:{items:X2,contextual:["table-tools","image-tools"]},allowLocalImages:!0,fillscreen:!1},codeview:{bundled:!0,showButton:!0,mode:"pencil",css:a+"/css",
  js:a+"/js"},findreplace:{bundled:!0},accessibility:{bundled:!0},plaincodeview:{bundled:!0},embed:{inlineStyles:!0,bundled:!1}}},state:function(){return{spelling:{words:{},language:g.none()},undo:{initial:{raw:"",marked:""},undo:[],redo:[]},profile:{spelling:!1,nativeSpelling:!0,autocorrect:!0,capitalisation:!1,linkpreviews:!1},content:{raw:"",marked:""},ui:{toolbar:{drag:g.none()}},macros:{customs:{}},filters:{customs:[]},laundry:{dirty:!1},linkvalidator:{ignore:[],cache:{}},embed:{cache:{}}}}},rt=
  O("item","mode"),st=function(a,b,c,d){var e=void 0!==d?d:rk;return a.property().parent(b).map(function(a){return rt(a,e)})},rk=function(a,b,c,d){var e=void 0!==d?d:di;return c.sibling(a,b).map(function(a){return rt(a,e)})},di=function(a,b,c,d){var e=void 0!==d?d:di;a=a.property().children(b);return c.first(a).map(function(a){return rt(a,e)})},P4=[{current:st,next:rk,fallback:g.none()},{current:rk,next:di,fallback:g.some(st)},{current:di,next:di,fallback:g.some(rk)}],OE=function(a,b,c,d,e){e=void 0!==
  e?e:P4;return qa(e,function(a){return a.current===c}).bind(function(c){return c.current(a,b,d,c.next).orThunk(function(){return c.fallback.bind(function(c){return OE(a,b,c,d)})})})},lh={backtrack:st,sidestep:rk,advance:di,go:OE},Qn={left:function(){return{sibling:function(a,b){return a.query().prevSibling(b)},first:function(a){return 0<a.length?g.some(a[a.length-1]):g.none()}}},right:function(){return{sibling:function(a,b){return a.query().nextSibling(b)},first:function(a){return 0<a.length?g.some(a[0]):
  g.none()}}}},tt=function(a,b,c,d,e,f){return lh.go(a,b,d,e).bind(function(b){return f(b.item())?g.none():c(b.item())?g.some(b.item()):tt(a,b.item(),c,b.mode(),e,f)})},Rn={left:function(a,b,c,d){return tt(a,b,c,lh.sidestep,Qn.left(),d)},right:function(a,b,c,d){return tt(a,b,c,lh.sidestep,Qn.right(),d)}},PE=function(a,b){return 0===a.property().children(b).length},QE=function(a,b,c,d){return Rn.left(a,b,c,d)},RE=function(a,b,c,d){return Rn.right(a,b,c,d)},Ca={before:function(a,b,c){return QE(a,b,u(PE,
  a),c)},after:function(a,b,c){return RE(a,b,u(PE,a),c)},seekLeft:QE,seekRight:RE,walkers:function(){return{left:Qn.left,right:Qn.right}},walk:function(a,b,c,d,e){return lh.go(a,b,c,d,e)},backtrack:lh.backtrack,sidestep:lh.sidestep,advance:lh.advance},ei=nb(),wc={gather:function(a,b,c){return Ca.gather(ei,a,b,c)},before:function(a,b){return Ca.before(ei,a,b)},after:function(a,b){return Ca.after(ei,a,b)},seekLeft:function(a,b,c){return Ca.seekLeft(ei,a,b,c)},seekRight:function(a,b,c){return Ca.seekRight(ei,
  a,b,c)},walkers:function(){return Ca.walkers()},walk:function(a,b,c,d){return Ca.walk(ei,a,b,c,d)}},SE=function(a){return p.fromDom(a.dom().cloneNode(!0))},ut=function(a,b){b=p.fromTag(b);a=m.clone(a);m.setAll(b,a);return b},Oc={shallow:function(a){return p.fromDom(a.dom().cloneNode(!1))},shallowAs:ut,deep:SE,copy:function(a,b){b=ut(a,b);a=A.children(SE(a));P.append(b,a);return b},mutate:function(a,b){b=ut(a,b);y.before(a,b);var c=A.children(a);P.append(b,c);F.remove(a);return b}},My={convertToHeading:function(a,
  b){var c=A.owner(a);b=p.fromTag(b,c.dom());c=A.children(a);c=E(c,Oc.deep);P.append(b,c);c=Y.descendants(b,"b,strong");z(c,F.unwrap);y.before(a,b);F.remove(a);return J.value(b)},joinLinks:function(a,b){return wc.seekLeft(b,function(a){return"a"===D.name(a)},a).fold(function(){return J.value(b)},function(a){var c=A.children(b);P.append(a,c);F.remove(b);return J.value(a)})}},TE=O("row","y"),UE=O("col","x"),VE=function(a){return bb.absolute(a).left()+Ga.getOuter(a)},WE=function(a){return bb.absolute(a).left()},
  XE=function(a,b){return UE(a,WE(b))},YE=function(a,b){return UE(a,VE(b))},vt=function(a){return bb.absolute(a).top()},wt=function(a,b,c){if(0===c.length)return[];var d=E(c.slice(1),function(b,c){return b.map(function(b){return a(c,b)})}),e=c[c.length-1].map(function(a){return b(c.length-1,a)});return d.concat([e])},Q4={delta:ca,positions:u(wt,function(a,b){return TE(a,vt(b))},function(a,b){return TE(a,vt(b)+sa.getOuter(b))}),edge:vt},R4={delta:ca,edge:WE,positions:u(wt,XE,YE)},S4={delta:function(a,
  b){return-a},edge:VE,positions:u(wt,YE,XE)},Uj={height:Q4,rtl:S4,ltr:R4},Yl={ltr:Uj.ltr,rtl:Uj.rtl},ZE=function(a){return"img"===D.name(a)?1:Ya.getOption(a).fold(function(){return A.children(a).length},function(a){return a.length})},T4=function(a){return Ya.getOption(a).filter(function(a){return 0!==a.trim().length||-1<a.indexOf("\u00a0")}).isSome()},U4=["img","br"],wa={getEnd:ZE,isEnd:function(a,b){return ZE(a)===b},isStart:function(a,b){return 0===b},isCursorPosition:function(a){return T4(a)||U(U4,
  D.name(a))}},V4=function(a,b){var c=function(a){a=A.children(a);for(var d=a.length-1;0<=d;d--){var f=a[d];if(b(f))return g.some(f);f=c(f);if(f.isSome())return f}return g.none()};return c(a)},kc={first:function(a){return Ja.descendant(a,wa.isCursorPosition)},last:function(a){return V4(a,wa.isCursorPosition)}},xt=function(){var a=p.fromTag("td");y.append(a,p.fromTag("br"));return a},W4=function(a,b,c){var d=Oc.copy(a,b);Ma(c,function(a,b){null===a?m.remove(d,b):m.set(d,b,a)});return d},X4=function(a){return a},
  $E=function(a){return function(){return p.fromTag("tr",a.dom())}},Y4=function(a,b,c){return kc.first(a).map(function(d){var e=c.join(",");d=Y.ancestors(d,e,function(b){return N.eq(b,a)});return Eb(d,function(a,b){b=Oc.shallow(b);m.remove(b,"contenteditable");y.append(a,b);return b},b)}).getOr(b)},aF={cellOperations:function(a,b,c){return{row:$E(b),cell:function(b){var d=A.owner(b.element());d=p.fromTag(D.name(b.element()),d.dom());var f=c.getOr("strong em b i span font h1 h2 h3 h4 h5 h6 p div".split(" "));
  f=0<f.length?Y4(b.element(),d,f):d;y.append(f,p.fromTag("br"));v.copy(b.element(),d);v.remove(d,"height");1!==b.colspan()&&v.remove(b.element(),"width");a(b.element(),d);return d},replace:W4,gap:xt}},paste:function(a){return{row:$E(a),cell:xt,replace:X4,gap:xt}}},Ac={erase:function(a,b,c,d){a=p.fromText("");y.after(b,a);F.remove(b);return g.some(Rc(a,0,a,0))},execute:function(a,b,c,d){return function(e,f,h){var l=d(),k=e.doc().getOrDie();e=Ly(a.directionAt);var C=g.some([]);k=aF.cellOperations(c,
  k,C);return b(l,f,h,k,e,t,t).bind(function(a){return a.cursor().map(function(a){return Rc(a,0,a,0)})})}}},Vr={only:function(a){var b=g.from(a.dom().documentElement).map(p.fromDom).getOr(a);return{parent:k(b),view:k(a),origin:k(Qa(0,0))}},detached:function(a,b){var c=u(bb.absolute,b);return{parent:k(b),view:k(a),origin:c}},body:function(a,b){return{parent:k(b),view:k(a),origin:k(Qa(0,0))}}},bF=function(a,b,c){return a.isInline()?Vr.detached(a.element(),b.uiContainer()):Vr.only(c)},Pr={get:bF,fromEngine:function(a){var b=
  a.content(),c=a.smartview();return b.doc().map(function(a){return bF(b,c,a)})}},Z4=O("width","height"),$4=O("rows","columns"),a5=O("row","column"),b5=O("x","y"),c5=O("element","rowspan","colspan"),d5=O("element","rowspan","colspan","isNew"),e5=O("element","rowspan","colspan","row","column"),f5=O("element","cells","section"),g5=O("element","isNew"),h5=O("element","cells","section","isNew"),i5=O("cells","section"),j5=O("details","section"),k5=O("startRow","startCol","finishRow","finishCol"),Na={dimensions:Z4,
  grid:$4,address:a5,coords:b5,extended:e5,detail:c5,detailnew:d5,rowdata:f5,elementnew:g5,rowdatanew:h5,rowcells:i5,rowdetails:j5,bounds:k5},yt=function(a,b,c){return ia(A.children(a),function(a){return Ia.is(a,b)?c(a)?[a]:[]:yt(a,b,c)})},sk={firstLayer:function(a,b){return yt(a,b,k(!0))},filterFirstLayer:yt},zt=function(a,b,c){var d=void 0!==c?c:k(!1);return d(b)?g.none():U(a,D.name(b))?g.some(b):L.ancestor(b,a.join(","),function(a){return Ia.is(a,"table")||d(a)})},cF=function(a,b){return A.parent(b).map(function(b){return Y.children(b,
  a)})},l5=u(cF,"th,td"),m5=u(cF,"tr"),At=function(a,b){return parseInt(m.get(a,b),10)},tb={cell:function(a,b){return zt(["td","th"],a,b)},firstCell:function(a){return L.descendant(a,"th,td")},cells:function(a){return sk.firstLayer(a,"th,td")},neighbourCells:l5,table:function(a,b){return L.closest(a,"table",b)},row:function(a,b){return zt(["tr"],a,b)},rows:function(a){return sk.firstLayer(a,"tr")},notCell:function(a,b){return zt(["caption","tr","tbody","tfoot","thead"],a,b)},neighbourRows:m5,attr:At,
  grid:function(a,b,c){b=At(a,b);a=At(a,c);return Na.grid(b,a)}},fg={fromTable:function(a){a=tb.rows(a);return E(a,function(a){var b=A.parent(a).map(function(a){a=D.name(a);return"tfoot"===a||"thead"===a||"tbody"===a?a:"tbody"}).getOr("tbody"),d=E(tb.cells(a),function(a){var b=m.has(a,"rowspan")?parseInt(m.get(a,"rowspan"),10):1,c=m.has(a,"colspan")?parseInt(m.get(a,"colspan"),10):1;return Na.detail(a,b,c)});return Na.rowdata(a,d,b)})},fromPastedRows:function(a,b){return E(a,function(a){var c=E(tb.cells(a),
  function(a){var b=m.has(a,"rowspan")?parseInt(m.get(a,"rowspan"),10):1,c=m.has(a,"colspan")?parseInt(m.get(a,"colspan"),10):1;return Na.detail(a,b,c)});return Na.rowdata(a,c,b.section())})}},dF=function(a,b){a=ia(a.all(),function(a){return a.cells()});return ka(a,b)},Ib={generate:function(a){var b={},c=[],d=a.length,e=0;z(a,function(a,d){var f=[];z(a.cells(),function(a,c){for(c=0;void 0!==b[d+","+c];)c++;for(var h=Na.extended(a.element(),a.rowspan(),a.colspan(),d,c),l=0;l<a.colspan();l++)for(var g=
  0;g<a.rowspan();g++){var k=c+l;b[d+g+","+k]=h;e=Math.max(e,k+1)}f.push(h)});c.push(Na.rowdata(a.element(),f,a.section()))});a=Na.grid(d,e);return{grid:k(a),access:k(b),all:k(c)}},getAt:function(a,b,c){a=a.access()[b+","+c];return void 0!==a?g.some(a):g.none()},findItem:function(a,b,c){a=dF(a,function(a){return c(b,a.element())});return 0<a.length?g.some(a[0]):g.none()},filterItems:dF,justCells:function(a){a=E(a.all(),function(a){return a.cells()});return Qb(a)}},ke={repeat:function(a,b){for(var c=
  [],d=0;d<a;d++)c.push(b(d));return c},range:function(a,b){for(var c=[];a<b;a++)c.push(a);return c},unique:function(a,b){var c=[];z(a,function(d,e){e<a.length-1&&!b(d,a[e+1])?c.push(d):e===a.length-1&&c.push(d)});return c},deduce:function(a,b){if(0>b||b>=a.length-1)return g.none();var c=a[b].fold(function(){var c=jd(a.slice(0,b));return yc(c,function(a,b){return a.map(function(a){return{value:a,delta:b+1}})})},function(a){return g.some({value:a,delta:0})}),d=a[b+1].fold(function(){var c=a.slice(b+
  1);return yc(c,function(a,b){return a.map(function(a){return{value:a,delta:b+1}})})},function(a){return g.some({value:a,delta:1})});return c.bind(function(a){return d.map(function(b){return Math.abs(b.value-a.value)/(b.delta+a.delta)})})}},eF=function(a,b,c){var d=a();return qa(d,b).orThunk(function(){return g.from(d[0]).orThunk(c)}).map(function(a){return a.element()})},Sn={columns:function(a){var b=a.grid(),c=ke.range(0,b.columns()),d=ke.range(0,b.rows());return E(c,function(b){return eF(function(){return ia(d,
  function(c){return Ib.getAt(a,c,b).filter(function(a){return a.column()===b}).fold(k([]),function(a){return[a]})})},function(a){return 1===a.colspan()},function(){return Ib.getAt(a,0,b)})})},rows:function(a){var b=a.grid(),c=ke.range(0,b.rows()),d=ke.range(0,b.columns());return E(c,function(b){return eF(function(){return ia(d,function(c){return Ib.getAt(a,b,c).filter(function(a){return a.row()===b}).fold(k([]),function(a){return[a]})})},function(a){return 1===a.rowspan()},function(){return Ib.getAt(a,
  b,0)})})}},fF=aa.detect(),fi=function(a,b,c){a=v.get(a,b);a=parseFloat(a);return isNaN(a)?c:a},n5={getWidth:function(a){return fi(a,"width",Ga.get(a))},getHeight:function(a){if(fF.browser.isIE()||fF.browser.isEdge()){var b=fi(a,"padding-top",0),c=fi(a,"padding-bottom",0),d=fi(a,"border-top-width",0),e=fi(a,"border-bottom-width",0),f=a.dom().getBoundingClientRect().height;a="border-box"===v.get(a,"box-sizing")?f:f-b-c-(d+e)}else a=fi(a,"height",sa.get(a));return a}},gF=/(\d+(\.\d+)?)(\w|%)*/,tk=/(\d+(\.\d+)?)%/,
  Bt=/(\d+(\.\d+)?)px|em/,hF=function(a,b){v.set(a,"height",b+"px")},o5=function(a){return v.getRaw(a,"height").getOrThunk(function(){return n5.getHeight(a)+"px"})},p5=function(a,b,c,d){var e=tb.table(a).map(function(a){a=c(a);return Math.floor(b/100*a)}).getOr(b);d(a,e);return e},Tn=function(a){return v.getRaw(a,"width").fold(function(){return g.from(m.get(a,"width"))},function(a){return g.some(a)})},pc={percentageBasedSizeRegex:k(tk),pixelBasedSizeRegex:k(Bt),setPixelWidth:function(a,b){v.set(a,"width",
  b+"px")},setPercentageWidth:function(a,b){v.set(a,"width",b+"%")},setHeight:hF,getPixelWidth:function(a,b){return Tn(a).fold(function(){return Ga.get(a)},function(c){Bt.test(c)?(c=Bt.exec(c),c=parseInt(c[1],10)):tk.test(c)?(c=tk.exec(c),c=parseFloat(c[1])/100*b.pixelWidth()):c=Ga.get(a);return c})},getPercentageWidth:function(a,b){return Tn(a).fold(function(){return Ga.get(a)/b.pixelWidth()*100},function(c){tk.test(c)?(c=tk.exec(c),c=parseFloat(c[1])):c=Ga.get(a)/b.pixelWidth()*100;return c})},getGenericWidth:function(a){return Tn(a).bind(function(a){return gF.test(a)?
  (a=gF.exec(a),g.some({width:k(a[1]),unit:k(a[3])})):g.none()})},setGenericWidth:function(a,b,c){v.set(a,"width",b+c)},getHeight:function(a){var b;if(b=o5(a)){var c=sa.get,d=parseInt(b,10);b=je(b,"%")&&"table"!==D.name(a)?p5(a,d,c,hF):d}else b=sa.get(a);a=m.has(a,"rowspan")?parseInt(m.get(a,"rowspan"),10):1;return b/a},getRawWidth:Tn},iF=function(a,b){return m.has(a,b)&&1<parseInt(m.get(a,b),10)},Qd={hasColspan:function(a){return iF(a,"colspan")},hasRowspan:function(a){return iF(a,"rowspan")},minWidth:k(10),
  minHeight:k(10),getInt:function(a,b){return parseInt(v.get(a,b),10)}},jF=function(a,b,c){return v.getRaw(a,b).fold(function(){return c(a)+"px"},function(a){return a})},q5=function(a){return jF(a,"width",pc.getPixelWidth)},r5=function(a){return jF(a,"height",pc.getHeight)},Ct=function(a,b,c,d,e){a=Sn.columns(a);var f=E(a,function(a){return a.map(b.edge)});return E(a,function(a,b){return a.filter(zf(Qd.hasColspan)).fold(function(){var a=ke.deduce(f,b);return d(a)},function(a){return c(a,e)})})},kF=
  function(a){return a.map(function(a){return a+"px"}).getOr("")},lF=function(a,b,c,d){a=Sn.rows(a);var e=E(a,function(a){return a.map(b.edge)});return E(a,function(a,b){return a.filter(zf(Qd.hasRowspan)).fold(function(){var a=ke.deduce(e,b);return d(a)},function(a){return c(a)})})},uk={getRawWidths:function(a,b){return Ct(a,b,q5,kF)},getPixelWidths:function(a,b,c){return Ct(a,b,pc.getPixelWidth,function(a){return a.getOrThunk(c.minCellWidth)},c)},getPercentageWidths:function(a,b,c){return Ct(a,b,pc.getPercentageWidth,
  function(a){return a.fold(function(){return c.minCellWidth()},function(a){return a/c.pixelWidth()*100})},c)},getPixelHeights:function(a,b){return lF(a,b,pc.getHeight,function(a){return a.getOrThunk(Qd.minHeight)})},getRawHeights:function(a,b){return lF(a,b,r5,kF)}},Un=ta.generate([{invalid:["raw"]},{pixels:["value"]},{percent:["value"]}]),mF=function(a,b,c){a=c.substring(0,c.length-a.length);var d=parseFloat(a);return a===d.toString()?b(d):Un.invalid(c)},mh=function(a){return je(a,"%")?mF("%",Un.percent,
  a):je(a,"px")?mF("px",Un.pixels,a):Un.invalid(a)},s5=function(a,b){return E(a,function(a){return mh(a).fold(function(){return a},function(a){return a/b*100+"%"},function(a){return a+"%"})})},t5=function(a,b,c){var d=c/b;return E(a,function(a){return mh(a).fold(function(){return a},function(a){return a*d+"px"},function(a){return a/100*c+"px"})})},u5=function(a,b){a=a.fold(function(){return k("")},function(a){return k(a/b+"px")},function(a){return k(a/b+"px")});return ke.repeat(b,a)},v5=function(a,
  b,c){return a.fold(function(){return b},function(a){return t5(b,c,a)},function(a){return s5(b,c)})},nF=function(a,b){var c=Math.floor(a);return{value:c+b,remainder:a-c}},w5=function(a,b){return mh(a).fold(k(a),function(a){return a+b+"px"},function(a){return a+b+"%"})},oF=function(a){if(0===a.length)return a;a=Eb(a,function(a,b){var c=mh(b).fold(function(){return{value:b,remainder:0}},function(a){return nF(a,"px")},function(a){return nF(a,"%")});return{output:[c.value].concat(a.output),remainder:a.remainder+
  c.remainder}},{output:[],remainder:0});var b=a.output;return b.slice(0,b.length-1).concat([w5(b[b.length-1],Math.round(a.remainder))])},vk={validate:mh,redistribute:function(a,b,c){c=mh(c);a=ob(a,function(a){return"0px"===a})?u5(c,a.length):v5(c,a,b);return oF(a)},sum:function(a,b){return 0===a.length?b:Eb(a,function(a,b){return mh(b).fold(k(0),ca,ca)+a},0)},toIntegers:oF},x5=function(a,b,c){z(b,function(b){var d=a.slice(b.column(),b.colspan()+b.column());d=vk.sum(d,Qd.minWidth());v.set(b.element(),
  "width",d+c)})},y5=function(a,b,c,d){z(c,function(b){var c=a.slice(b.row(),b.rowspan()+b.row());c=vk.sum(c,Qd.minHeight());v.set(b.element(),"height",c+d)});z(b,function(b,c){v.set(b.element(),"height",a[c])})},pF=function(a){return vk.validate(a).fold(k("px"),k("px"),k("%"))},z5={redistribute:function(a,b,c,d){var e=fg.fromTable(a),f=Ib.generate(e),h=f.all(),l=Ib.justCells(f);b.each(function(b){var c=pF(b),e=Ga.get(a),h=uk.getRawWidths(f,d);e=vk.redistribute(h,e,b);x5(e,l,c);v.set(a,"width",b)});
  c.each(function(b){var c=pF(b),d=sa.get(a),e=uk.getRawHeights(f,Uj.height);d=vk.redistribute(e,d,b);y5(d,h,l,c);v.set(a,"height",b)})}},A5=function(a){var b=m.has(a,"colspan")?parseInt(m.get(a,"colspan"),10):1,c=m.has(a,"rowspan")?parseInt(m.get(a,"rowspan"),10):1;return{element:k(a),colspan:k(b),rowspan:k(c)}},Dt=xd(["cell","row","replace","gap"]),dc={modification:function(a,b){Dt(a);var c=na(g.none()),d=void 0!==b?b:A5,e=function(b){var e=d(b);e=a.cell(e);c.get().isNone()&&c.set(g.some(e));f=g.some({item:b,
  replacement:e});return e},f=g.none();return{getOrInit:function(a,b){return f.fold(function(){return e(a)},function(c){return b(a,c.item)?c.replacement:e(a)})},cursor:c.get}},transform:function(a,b){return function(c){var d=na(g.none());Dt(c);var e=[],f=function(a,b){return qa(e,function(c){return b(c.item,a)})},h=function(f){var h=c.replace(f,b,{scope:a});e.push({item:f,sub:h});d.get().isNone()&&d.set(g.some(h));return h};return{replaceOrInit:function(a,b){return f(a,b).fold(function(){return h(a)},
  function(c){return b(a,c.item)?c.sub:h(a)})},cursor:d.get}}},merging:function(a){Dt(a);var b=na(g.none());return{combine:function(c){b.get().isNone()&&b.set(g.some(c));return function(){var b=a.cell({element:k(c),colspan:k(1),rowspan:k(1)});v.remove(b,"width");v.remove(c,"width");return b}},cursor:b.get}}},B5="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(" "),qF=function(a,b){a=a.property().name(b);
  return U(B5,a)},rF=function(a,b){return U(["br","img","hr","input"],a.property().name(b))},Mc={isBlock:qF,isList:function(a,b){a=a.property().name(b);return U(["ol","ul"],a)},isFormatting:function(a,b){a=a.property().name(b);return U("address pre p h1 h2 h3 h4 h5 h6".split(" "),a)},isHeading:function(a,b){a=a.property().name(b);return U("h1 h2 h3 h4 h5 h6".split(" "),a)},isContainer:function(a,b){return U("div li td th blockquote body caption".split(" "),a.property().name(b))},isEmptyTag:rF,isFrame:function(a,
  b){return"iframe"===a.property().name(b)},isInline:function(a,b){return!(qF(a,b)||rF(a,b))&&"li"!==a.property().name(b)}},gg=nb(),pa={isBlock:function(a){return Mc.isBlock(gg,a)},isList:function(a){return Mc.isList(gg,a)},isFormatting:function(a){return Mc.isFormatting(gg,a)},isHeading:function(a){return Mc.isHeading(gg,a)},isContainer:function(a){return Mc.isContainer(gg,a)},isEmptyTag:function(a){return Mc.isEmptyTag(gg,a)},isFrame:function(a){return Mc.isFrame(gg,a)},isInline:function(a){return Mc.isInline(gg,
  a)}},C5={merge:function(a){var b=function(a){return ob(a,function(a){return"br"===D.name(a)||D.isText(a)&&0===Ya.get(a).trim().length})},c=function(a){return A.nextSibling(a).map(function(a){if(pa.isBlock(a))return!0;if(pa.isEmptyTag(a))return"img"===D.name(a)?!1:!0}).getOr(!1)},d=function(a){return kc.last(a).bind(function(b){var d=c(b);return A.parent(b).map(function(c){var e;(e=!0===d)||(e="li"===D.name(c)||Ja.ancestor(c,pa.isList).isSome());return e||"br"===D.name(b)||pa.isBlock(c)&&!N.eq(a,c)?
  []:[p.fromTag("br")]})}).getOr([])},e=function(){var c=ia(a,function(a){var c=A.children(a);return b(c)?[]:c.concat(d(a))});return 0===c.length?[p.fromTag("br")]:c}();F.empty(a[0]);P.append(a[0],e)}},sF=function(a,b){return Na.rowcells(b,a.section())},tF=function(a,b){return a.cells()[b]},Ka={addCell:function(a,b,c){var d=a.cells(),e=d.slice(0,b);b=d.slice(b);c=e.concat([c]).concat(b);return sF(a,c)},setCells:sF,mutateCell:function(a,b,c){a.cells()[b]=c},getCell:tF,getCellElement:function(a,b){return tF(a,
  b).element()},mapCells:function(a,b){var c=a.cells();b=E(c,b);return Na.rowcells(b,a.section())},cellLength:function(a){return a.cells().length}},D5=function(a,b){return E(a,function(a){return Ka.getCell(a,b)})},uF=function(a,b){if(0===a.length)return 0;var c=a[0];return Va(a,function(a){return!b(c.element(),a.element())}).fold(function(){return a.length},function(a){return a})},E5={subgrid:function(a,b,c,d){var e=a[b].cells().slice(c);e=uF(e,d);a=D5(a,c).slice(b);d=uF(a,d);return{colspan:k(e),rowspan:k(d)}}},
  Vn={toDetails:function(a,b){var c=E(a,function(a,b){return E(a.cells(),function(a,b){return!1})});return E(a,function(d,e){var f=ia(d.cells(),function(d,f){if(!1===c[e][f]){for(var h=E5.subgrid(a,e,f,b),l=h.rowspan(),g=h.colspan(),k=e;k<e+l;k++)for(var m=f;m<f+g;m++)c[k][m]=!0;return[Na.detailnew(d.element(),h.rowspan(),h.colspan(),d.isNew())]}return[]});return Na.rowdetails(f,d.section())})},toGrid:function(a,b,c){for(var d=[],e=0;e<a.grid().rows();e++){for(var f=[],h=0;h<a.grid().columns();h++){var l=
  Ib.getAt(a,e,h).map(function(a){return Na.elementnew(a.element(),c)}).getOrThunk(function(){return Na.elementnew(b.gap(),!0)});f.push(l)}f=Na.rowcells(f,a.all()[e].section());d.push(f)}return d}},Wn=function(a,b,c,d){c===d?m.remove(a,b):m.set(a,b,c)},F5={render:function(a,b){var c=[],d=[],e=function(b,e){var f=L.child(a,e).getOrThunk(function(){var b=p.fromTag(e,A.owner(a).dom());y.append(a,b);return b});F.empty(f);b=E(b,function(a){a.isNew()&&c.push(a.element());var b=a.element();F.empty(b);z(a.cells(),
  function(a){a.isNew()&&d.push(a.element());Wn(a.element(),"colspan",a.colspan(),1);Wn(a.element(),"rowspan",a.rowspan(),1);y.append(b,a.element())});return b});P.append(f,b)},f=function(b,c){0<b.length?e(b,c):L.child(a,c).each(F.remove)},h=[],l=[],g=[];z(b,function(a){switch(a.section()){case "thead":h.push(a);break;case "tbody":l.push(a);break;case "tfoot":g.push(a)}});f(h,"thead");f(l,"tbody");f(g,"tfoot");return{newRows:k(c),newCells:k(d)}},copy:function(a){return E(a,function(a){var b=Oc.shallow(a.element());
  z(a.cells(),function(a){var c=Oc.deep(a.element());Wn(c,"colspan",a.colspan(),1);Wn(c,"rowspan",a.rowspan(),1);y.append(b,c)});return b})}},vF={col:function(a,b,c,d,e){var f=p.fromTag("div");v.setAll(f,{position:"absolute",left:b-d/2+"px",top:c+"px",height:e+"px",width:d+"px"});m.setAll(f,{"data-column":a,role:"presentation"});return f},row:function(a,b,c,d,e){var f=p.fromTag("div");v.setAll(f,{position:"absolute",left:b+"px",top:c-e/2+"px",height:e+"px",width:d+"px"});m.setAll(f,{"data-row":a,role:"presentation"});
  return f}},vd={resolve:Bn("ephox-snooker").resolve},Et=vd.resolve("resizer-bar"),wF=vd.resolve("resizer-rows"),xF=vd.resolve("resizer-cols"),yF=function(a){a=Y.descendants(a.parent(),"."+Et);z(a,F.remove)},zF=function(a,b,c){var d=a.origin();z(b,function(b,f){b.each(function(b){b=c(d,b);n.add(b,Et);y.append(a.parent(),b)})})},G5=function(a,b,c,d){zF(a,b,function(a,b){a=vF.col(b.col(),b.x()-a.left(),c.top()-a.top(),7,d);n.add(a,xF);return a})},H5=function(a,b,c,d){zF(a,b,function(a,b){a=vF.row(b.row(),
  c.left()-a.left(),b.y()-a.top(),d,7);n.add(a,wF);return a})},AF=function(a,b){a=Y.descendants(a.parent(),"."+Et);z(a,b)},Fe={refresh:function(a,b,c,d){yF(a);var e=fg.fromTable(b);e=Ib.generate(e);var f=Sn.rows(e),h=Sn.columns(e);e=bb.absolute(b);c=0<f.length?c.positions(f,b):[];H5(a,c,e,Ga.getOuter(b));d=0<h.length?d.positions(h,b):[];G5(a,d,e,sa.getOuter(b))},hide:function(a){AF(a,function(a){v.set(a,"display","none")})},show:function(a){AF(a,function(a){v.set(a,"display","block")})},destroy:yF,
  isRowBar:function(a){return n.has(a,wF)},isColBar:function(a){return n.has(a,xF)}},I5=function(a,b){var c=function(a){return yc(a,function(a){return A.parent(a.element()).map(function(a){var b=A.parent(a).isNone();return Na.elementnew(a,b)})}).getOrThunk(function(){return Na.elementnew(b.row(),!0)})};return E(a,function(a){var b=c(a.details());return Na.rowdatanew(b.element(),a.details(),a.section(),b.isNew())})},BF=function(a,b){a=Vn.toDetails(a,N.eq);return I5(a,b)},Xn=function(a,b){a=Qb(E(a.all(),
  function(a){return a.cells()}));return qa(a,function(a){return N.eq(b,a.element())})},Oa={run:function(a,b,c,d,e){return function(f,h,l,q,C){var w=fg.fromTable(h),m=Ib.generate(w);return b(m,l).map(function(b){var c=Vn.toGrid(m,q,!1);b=a(c,b,N.eq,e(q));c=BF(b.grid(),q);return{grid:k(c),cursor:b.cursor}}).fold(function(){return g.none()},function(a){var b=F5.render(h,a.grid());c(h,a.grid(),C);d(h);Fe.refresh(f,h,Uj.height,C);return g.some({cursor:a.cursor,newRows:b.newRows,newCells:b.newCells})})}},
  toDetailList:BF,onCell:function(a,b){return tb.cell(b.element()).bind(function(b){return Xn(a,b)})},onCells:function(a,b){b=E(b.selection(),function(b){return tb.cell(b).bind(function(b){return Xn(a,b)})});b=ee(b);return 0<b.length?g.some(b):g.none()},onPaste:function(a,b){return tb.cell(b.element()).bind(function(c){return Xn(a,c).map(function(a){return ua(a,{generators:b.generators,clipboard:b.clipboard})})})},onPasteRows:function(a,b){var c=E(b.selection(),function(b){return tb.cell(b).bind(function(b){return Xn(a,
  b)})});c=ee(c);return 0<c.length?g.some(ua({cells:c},{generators:b.generators,clipboard:b.clipboard})):g.none()},onMergable:function(a,b){return b.mergable()},onUnmergable:function(a,b){return b.unmergable()}},CF=function(a,b){return E(a,function(){return Na.elementnew(b.cell(),!0)})},J5=function(a,b,c){return a.concat(ke.repeat(b,function(b){return Ka.setCells(a[a.length-1],CF(a[a.length-1].cells(),c))}))},K5=function(a,b,c){return E(a,function(a){return Ka.setCells(a,a.cells().concat(CF(ke.range(0,
  b),c)))})},gi={measure:function(a,b,c){if(a.row()>=b.length||a.column()>Ka.cellLength(b[0]))return J.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());var d=Ka.cellLength(c[0]);return J.value({rowDelta:k(b.length-c.length),colDelta:k(a.length-d)})},measureWidth:function(a,b){a=Ka.cellLength(a[0]);b=Ka.cellLength(b[0]);return{rowDelta:k(0),colDelta:k(a-b)}},tailor:function(a,b,c){var d=0>b.colDelta()?K5:ca,
  e=0>b.rowDelta()?J5:ca;a=d(a,Math.abs(b.colDelta()),c);return e(a,Math.abs(b.rowDelta()),c)}},L5=function(a,b){return hb(a,function(a,d){return Xa(a,function(a){return b(a.element(),d.element())})?a:a.concat([d])},[])},Yn={merge:function(a,b,c,d){if(0===a.length)return a;for(c=b.startRow();c<=b.finishRow();c++)for(var e=b.startCol();e<=b.finishCol();e++)Ka.mutateCell(a[c],e,Na.elementnew(d(),!1));return a},unmerge:function(a,b,c,d){for(var e=!0,f=0;f<a.length;f++)for(var h=0;h<Ka.cellLength(a[0]);h++){var l=
  Ka.getCellElement(a[f],h);l=c(l,b);!0===l&&!1===e?Ka.mutateCell(a[f],h,Na.elementnew(d(),!0)):!0===l&&(e=!1)}return a},splitRows:function(a,b,c,d){if(0<b&&b<a.length){var e=a[b-1].cells();e=L5(e,c);z(e,function(e){for(var f=g.none(),l=b;l<a.length;l++)for(var k=0;k<Ka.cellLength(a[0]);k++){var C=a[l].cells()[k];c(C.element(),e.element())&&(f.isNone()&&(f=g.some(d())),f.each(function(b){Ka.mutateCell(a[l],k,Na.elementnew(b,!0))}))}})}return a}},Ft={merge:function(a,b,c,d,e){return gi.measure(a,b,c).map(function(f){f=
  gi.tailor(b,f,d);var h=a.row(),l=a.column(),g=c.length,k=Ka.cellLength(c[0]);g=h+g;k=l+k;for(var w=h;w<g;w++)for(var m=l;m<k;m++){var G=f,n=w,p=m,r=e,t=Ka.getCell(G[n],p);r=u(r,t.element());t=G[n];1<G.length&&1<Ka.cellLength(t)&&(0<p&&r(Ka.getCellElement(t,p-1))||p<t.length-1&&r(Ka.getCellElement(t,p+1))||0<n&&r(Ka.getCellElement(G[n-1],p))||n<G.length-1&&r(Ka.getCellElement(G[n+1],p)))&&Yn.unmerge(f,Ka.getCellElement(f[w],m),e,d.cell);G=Ka.getCellElement(c[w-h],m-l);G=d.replace(G);Ka.mutateCell(f[w],
  m,Na.elementnew(G,!0))}return f})},insert:function(a,b,c,d,e){Yn.splitRows(b,a,e,d.cell);e=gi.measureWidth(c,b);c=gi.tailor(c,e,d);e=gi.measureWidth(b,c);b=gi.tailor(b,e,d);return b.slice(0,a).concat(c).concat(b.slice(a,b.length))}},Sd={insertRowAt:function(a,b,c,d,e){var f=a.slice(0,b),h=a.slice(b);c=Ka.mapCells(a[c],function(c,f){return 0<b&&b<a.length&&d(Ka.getCellElement(a[b-1],f),Ka.getCellElement(a[b],f))?Ka.getCell(a[b],f):Na.elementnew(e(c.element(),d),!0)});return f.concat([c]).concat(h)},
  insertColumnAt:function(a,b,c,d,e){return E(a,function(a){var f=0<b&&b<Ka.cellLength(a)&&d(Ka.getCellElement(a,b-1),Ka.getCellElement(a,b))?Ka.getCell(a,b):Na.elementnew(e(Ka.getCellElement(a,c),d),!0);return Ka.addCell(a,b,f)})},splitCellIntoColumns:function(a,b,c,d,e){var f=c+1;return E(a,function(a,l){l=l===b?Na.elementnew(e(Ka.getCellElement(a,c),d),!0):Ka.getCell(a,c);return Ka.addCell(a,f,l)})},splitCellIntoRows:function(a,b,c,d,e){var f=b+1,h=a.slice(0,f);f=a.slice(f);a=Ka.mapCells(a[b],function(a,
  b){return b===c?Na.elementnew(e(a.element(),d),!0):a});return h.concat([a]).concat(f)},deleteRowsAt:function(a,b,c){return a.slice(0,b).concat(a.slice(c+1))},deleteColumnsAt:function(a,b,c){a=E(a,function(a){var d=a.cells().slice(0,b).concat(a.cells().slice(c+1));return Na.rowcells(d,a.section())});return ka(a,function(a){return 0<a.cells().length})}},DF=function(a,b,c,d){var e=function(a){return Xa(b,function(b){return c(a.element(),b.element())})};return E(a,function(a){return Ka.mapCells(a,function(a){return e(a)?
  Na.elementnew(d(a.element(),c),!0):a})})},EF=function(a,b,c,d){return void 0!==Ka.getCellElement(a[b],c)&&0<b&&d(Ka.getCellElement(a[b-1],c),Ka.getCellElement(a[b],c))},FF=function(a,b,c){return 0<b&&c(Ka.getCellElement(a,b-1),Ka.getCellElement(a,b))},Zn={replaceColumn:function(a,b,c,d){var e=ia(a,function(d,e){return EF(a,e,b,c)||FF(d,b,c)?[]:[Ka.getCell(d,b)]});return DF(a,e,c,d)},replaceRow:function(a,b,c,d){var e=a[b],f=ia(e.cells(),function(d,f){return EF(a,b,f,c)||FF(e,f,c)?[]:[d]});return DF(a,
  f,c,d)}},hi={none:function(){return{fold:function(a,b,c,d,e){return a()}}},only:function(a){return{fold:function(b,c,d,e,f){return c(a)}}},left:function(a,b){return{fold:function(c,d,e,f,h){return e(a,b)}}},middle:function(a,b,c){return{fold:function(d,e,f,h,l){return h(a,b,c)}}},right:function(a,b){return{fold:function(c,d,e,f,h){return h(a,b)}}}},M5=function(a,b){return 0===a.length?hi.none():1===a.length?hi.only(0):0===b?hi.left(0,1):b===a.length-1?hi.right(b-1,b):0<b&&b<a.length-1?hi.middle(b-
  1,b,b+1):hi.none()},N5={determine:function(a,b,c,d){var e=a.slice(0);a=M5(a,b);var f=function(a){return E(a,k(0))};b=k(f(e));var h=function(a,b){if(0<=c){var h=Math.max(d.minCellWidth(),e[b]-c);return f(e.slice(0,a)).concat([c,h-e[b]]).concat(f(e.slice(b+1)))}h=Math.max(d.minCellWidth(),e[a]+c);var l=e[a]-h;return f(e.slice(0,a)).concat([h-e[a],l]).concat(f(e.slice(b+1)))};return a.fold(b,function(a){return d.singleColumnWidth(e[a],c)},h,function(a,b,c){return h(b,c)},function(a,b){if(0<=c)return f(e.slice(0,
  b)).concat([c]);a=Math.max(d.minCellWidth(),e[b]+c);return f(e.slice(0,b)).concat([a-e[b]])})}},GF=function(a,b,c){for(var d=0;a<b;a++)d+=void 0!==c[a]?c[a]:0;return d},$n={recalculateWidth:function(a,b){a=Ib.justCells(a);return E(a,function(a){var c=GF(a.column(),a.column()+a.colspan(),b);return{element:a.element,width:k(c),colspan:a.colspan}})},recalculateHeight:function(a,b){a=Ib.justCells(a);return E(a,function(a){var c=GF(a.row(),a.row()+a.rowspan(),b);return{element:a.element,height:k(c),rowspan:a.rowspan}})},
  matchRowHeight:function(a,b){return E(a.all(),function(a,d){return{element:a.element,height:k(b[d])}})}},O5=function(a,b){var c=parseFloat(a),d=Ga.get(b);return{width:k(c),pixelWidth:k(d),getWidths:uk.getPercentageWidths,getCellDelta:function(a){return a/d*100},singleColumnWidth:function(a,b){return[100-a]},minCellWidth:function(){return Qd.minWidth()/d*100},setElementWidth:pc.setPercentageWidth,setTableWidth:function(a,b,d){pc.setPercentageWidth(a,c+d)}}},Gt=function(a){a=parseInt(a,10);var b=ca;
  return{width:k(a),pixelWidth:k(a),getWidths:uk.getPixelWidths,getCellDelta:b,singleColumnWidth:function(a,b){return[Math.max(Qd.minWidth(),a+b)-a]},minCellWidth:Qd.minWidth,setElementWidth:pc.setPixelWidth,setTableWidth:function(a,b,e){b=Eb(b,function(a,b){return a+b},0);pc.setPixelWidth(a,b)}}},HF={getTableSize:function(a){return pc.getRawWidth(a).fold(function(){var b=Ga.get(a);return Gt(b)},function(b){pc.percentageBasedSizeRegex().test(b)?(b=pc.percentageBasedSizeRegex().exec(b),b=O5(b[1],a)):
  pc.pixelBasedSizeRegex().test(b)?(b=pc.pixelBasedSizeRegex().exec(b),b=Gt(b[1])):(b=Ga.get(a),b=Gt(b));return b})}},P5=function(a){return Eb(a,function(a,c){return a+c},0)},IF=function(a){a=fg.fromTable(a);return Ib.generate(a)},Ur={adjustWidth:function(a,b,c,d){var e=HF.getTableSize(a);b=e.getCellDelta(b);var f=IF(a),h=e.getWidths(f,d,e);d=N5.determine(h,c,b,e);d=E(d,function(a,b){return a+h[b]});var l=$n.recalculateWidth(f,d);z(l,function(a){e.setElementWidth(a.element(),a.width())});c===f.grid().columns()-
  1&&e.setTableWidth(a,d,b)},adjustHeight:function(a,b,c,d){var e=IF(a);d=uk.getPixelHeights(e,d);d=E(d,function(a,d){return c===d?Math.max(b+a,Qd.minHeight()):a});var f=$n.recalculateHeight(e,d);e=$n.matchRowHeight(e,d);z(e,function(a){pc.setHeight(a.element(),a.height())});z(f,function(a){pc.setHeight(a.element(),a.height())});e=P5(d);pc.setHeight(a,e)},adjustWidthTo:function(a,b,c){var d=HF.getTableSize(a);b=Ib.generate(b);c=d.getWidths(b,c,d);b=$n.recalculateWidth(b,c);z(b,function(a){d.setElementWidth(a.element(),
  a.width())});c=Eb(c,function(a,b){return b+a},0);0<b.length&&d.setElementWidth(a,c)}},JF=function(a){0===tb.cells(a).length&&F.remove(a)},Cf=O("grid","cursor"),wk=function(a,b,c){return Ht(a,b,c).orThunk(function(){return Ht(a,0,0)})},Ht=function(a,b,c){return g.from(a[b]).bind(function(a){return g.from(a.cells()[c]).bind(function(a){return g.from(a.element())})})},ld=function(a,b,c){return Cf(a,Ht(a,b,c))},It=function(a){return hb(a,function(a,c){return Xa(a,function(a){return a.row()===c.row()})?
  a:a.concat([c])},[]).sort(function(a,c){return a.row()-c.row()})},Jt=function(a){return hb(a,function(a,c){return Xa(a,function(a){return a.column()===c.column()})?a:a.concat([c])},[]).sort(function(a,c){return a.column()-c.column()})},KF=function(a,b,c){a=fg.fromPastedRows(a,c);a=Ib.generate(a);return Vn.toGrid(a,b,!0)},hg=Ur.adjustWidthTo,nc={insertRowBefore:Oa.run(function(a,b,c,d){var e=b.row(),f=b.row();a=Sd.insertRowAt(a,f,e,c,d.getOrInit);return ld(a,f,b.column())},Oa.onCell,t,t,dc.modification),
  insertRowsBefore:Oa.run(function(a,b,c,d){var e=b[0].row(),f=b[0].row(),h=It(b);a=hb(h,function(a,b){return Sd.insertRowAt(a,f,e,c,d.getOrInit)},a);return ld(a,f,b[0].column())},Oa.onCells,t,t,dc.modification),insertRowAfter:Oa.run(function(a,b,c,d){var e=b.row(),f=b.row()+b.rowspan();a=Sd.insertRowAt(a,f,e,c,d.getOrInit);return ld(a,f,b.column())},Oa.onCell,t,t,dc.modification),insertRowsAfter:Oa.run(function(a,b,c,d){var e=It(b),f=e[e.length-1].row(),h=e[e.length-1].row()+e[e.length-1].rowspan();
  a=hb(e,function(a,b){return Sd.insertRowAt(a,h,f,c,d.getOrInit)},a);return ld(a,h,b[0].column())},Oa.onCells,t,t,dc.modification),insertColumnBefore:Oa.run(function(a,b,c,d){var e=b.column(),f=b.column();a=Sd.insertColumnAt(a,f,e,c,d.getOrInit);return ld(a,b.row(),f)},Oa.onCell,hg,t,dc.modification),insertColumnsBefore:Oa.run(function(a,b,c,d){var e=Jt(b),f=e[0].column(),h=e[0].column();a=hb(e,function(a,b){return Sd.insertColumnAt(a,h,f,c,d.getOrInit)},a);return ld(a,b[0].row(),h)},Oa.onCells,hg,
  t,dc.modification),insertColumnAfter:Oa.run(function(a,b,c,d){var e=b.column(),f=b.column()+b.colspan();a=Sd.insertColumnAt(a,f,e,c,d.getOrInit);return ld(a,b.row(),f)},Oa.onCell,hg,t,dc.modification),insertColumnsAfter:Oa.run(function(a,b,c,d){var e=b[b.length-1].column(),f=b[b.length-1].column()+b[b.length-1].colspan(),h=Jt(b);a=hb(h,function(a,b){return Sd.insertColumnAt(a,f,e,c,d.getOrInit)},a);return ld(a,b[0].row(),f)},Oa.onCells,hg,t,dc.modification),splitCellIntoColumns:Oa.run(function(a,
  b,c,d){a=Sd.splitCellIntoColumns(a,b.row(),b.column(),c,d.getOrInit);return ld(a,b.row(),b.column())},Oa.onCell,hg,t,dc.modification),splitCellIntoRows:Oa.run(function(a,b,c,d){a=Sd.splitCellIntoRows(a,b.row(),b.column(),c,d.getOrInit);return ld(a,b.row(),b.column())},Oa.onCell,t,t,dc.modification),eraseColumns:Oa.run(function(a,b,c,d){c=Jt(b);a=Sd.deleteColumnsAt(a,c[0].column(),c[c.length-1].column());b=wk(a,b[0].row(),b[0].column());return Cf(a,b)},Oa.onCells,hg,JF,dc.modification),eraseRows:Oa.run(function(a,
  b,c,d){c=It(b);a=Sd.deleteRowsAt(a,c[0].row(),c[c.length-1].row());b=wk(a,b[0].row(),b[0].column());return Cf(a,b)},Oa.onCells,t,JF,dc.modification),makeColumnHeader:Oa.run(function(a,b,c,d){a=Zn.replaceColumn(a,b.column(),c,d.replaceOrInit);return ld(a,b.row(),b.column())},Oa.onCell,t,t,dc.transform("row","th")),unmakeColumnHeader:Oa.run(function(a,b,c,d){a=Zn.replaceColumn(a,b.column(),c,d.replaceOrInit);return ld(a,b.row(),b.column())},Oa.onCell,t,t,dc.transform(null,"td")),makeRowHeader:Oa.run(function(a,
  b,c,d){a=Zn.replaceRow(a,b.row(),c,d.replaceOrInit);return ld(a,b.row(),b.column())},Oa.onCell,t,t,dc.transform("col","th")),unmakeRowHeader:Oa.run(function(a,b,c,d){a=Zn.replaceRow(a,b.row(),c,d.replaceOrInit);return ld(a,b.row(),b.column())},Oa.onCell,t,t,dc.transform(null,"td")),mergeCells:Oa.run(function(a,b,c,d){d=b.cells();C5.merge(d);a=Yn.merge(a,b.bounds(),c,k(d[0]));return Cf(a,g.from(d[0]))},Oa.onMergable,t,t,dc.merging),unmergeCells:Oa.run(function(a,b,c,d){a=Eb(b,function(a,b){return Yn.unmerge(a,
  b,c,d.combine(b))},a);return Cf(a,g.from(b[0]))},Oa.onUnmergable,hg,t,dc.merging),pasteCells:Oa.run(function(a,b,c,d){d=function(a,b){a=fg.fromTable(a);a=Ib.generate(a);return Vn.toGrid(a,b,!0)}(b.clipboard(),b.generators());var e=Na.address(b.row(),b.column());return Ft.merge(e,a,d,b.generators(),c).fold(function(){return Cf(a,g.some(b.element()))},function(a){var c=wk(a,b.row(),b.column());return Cf(a,c)})},Oa.onPaste,hg,t,dc.modification),pasteRowsBefore:Oa.run(function(a,b,c,d){var e=a[b.cells[0].row()];
  d=b.cells[0].row();e=KF(b.clipboard(),b.generators(),e);a=Ft.insert(d,a,e,b.generators(),c);b=wk(a,b.cells[0].row(),b.cells[0].column());return Cf(a,b)},Oa.onPasteRows,t,t,dc.modification),pasteRowsAfter:Oa.run(function(a,b,c,d){var e=a[b.cells[0].row()];d=b.cells[b.cells.length-1].row()+b.cells[b.cells.length-1].rowspan();e=KF(b.clipboard(),b.generators(),e);a=Ft.insert(d,a,e,b.generators(),c);b=wk(a,b.cells[0].row(),b.cells[0].column());return Cf(a,b)},Oa.onPasteRows,t,t,dc.modification)},Kt=function(a){return function(b,
  c){return hb(a,function(a,e){return a.bind(function(a){return Q5(c,function(a){return R5(e,b,c,a)})})},J.value(c))}},S5=Kt([nc.makeRowHeader,nc.makeColumnHeader]),T5=Kt([nc.makeRowHeader]),U5=Kt([nc.makeColumnHeader]),R5=function(a,b,c,d){return Pr.fromEngine(b).bind(function(e){e=k(e);var f=t;return Ac.execute(b.region(),a,f,e)(b.content(),c,{element:k(d)})})},Q5=function(a,b){return L.descendant(a,"td,th").bind(function(a){return b(a)}).fold(function(){return J.error("Could not run the operation on table")},
  function(b){return J.value(a)})},Of={setCaption:function(a,b){var c=L.child(a,"caption").fold(function(){return p.fromTag("caption")},function(a){F.empty(a);return a});Ha.set(c,b);y.prepend(a,c)},setSummary:function(a,b){m.set(a,"summary",b)},setDimensions:function(a,b){z5.redistribute(a,b.width(),b.height(),"rtl"===m.get(a,"dir")?Yl.rtl:Yl.ltr)},addBothHeaders:S5,addRowHeader:T5,addColumnHeader:U5},Lt=ta.generate([{field:["name","textkey","f"]},{select:["name","textkey","values"]},{toggles:["name",
  "textkey","options"]}]),V5=O("value","text"),W5=O("value","icon","textkey"),jc={field:Lt.field,select:Lt.select,toggles:Lt.toggles,pair:V5,toggle:W5,cata:function(a,b,c,d){return a.fold(b,c,d)}},X5=function(a,b){z(a,function(a){b.get(a.severity()).fold(function(){console.warn("unknown severity for accessibility rule: ",a.id(),a.severity())},function(c){ma.add(a.element(),[b.violation(),c.style()]);ff.add(a.element(),c.attribute(),a.id())})});g.from(a[0]).each(function(a){var c=a.element(),e=b.currentAttr();
  a=a.severity();m.set(c,e,a)})},Y5=function(a,b,c,d){a=Y.descendants(a,"["+b+"]");z(a,function(a){m.remove(a,b)});m.set(c,b,d)},Z5=function(a,b){a=Y.descendants(a,"."+b.violation());z(a,function(a){n.remove(a,b.violation());m.remove(a,b.currentAttr());z(b.all(),function(b){n.remove(a,b.style());m.remove(a,b.attribute())})})},LF=function(a,b,c){var d=function(b){return 0===ff.read(a,b.attribute()).length};b.get(c).each(function(b){d(b)&&n.remove(a,b.style())});ob(b.all(),d)&&n.remove(a,b.violation())},
  $5=function(a,b,c,d){b.get(d).each(function(d){ff.remove(a,d.attribute(),c);ff.add(a,b.ignoreAttr(),c);d=b.currentAttr();m.remove(a,d)})},a6=function(a,b,c,d){b.get(d).each(function(d){ff.remove(a,d.attribute(),c);d=b.currentAttr();m.remove(a,d)})},b6={manager:function(a){var b=a.content();return{start:function(b){X5(b,a)},moveTo:function(c,d){b.body().each(function(b){Y5(b,a.currentAttr(),c,d)})},stop:function(){b.body().each(function(b){Z5(b,a)})},ignore:function(b,d,e){$5(b,a,d,e);LF(b,a,e)},solve:function(b,
  d,e){a6(b,a,d,e);LF(b,a,e)}}}},ii=function(a){return function(b){z(b,a)}},c6=ii(F.remove),d6=ii(function(a){m.set(a,"class","")}),e6=ii(function(a){var b=A.children(a);P.before(a,b);F.remove(a)}),f6=mb(),g6=function(a){return D.isText(a)?(a=Vb.get(a),""===a||a===f6):!1},h6=ii(function(a){if(D.isElement(a)){var b=A.childNodesCount(a);b=0===b||1===b&&A.child(a,0).exists(g6)}else b=!1;b&&m.hasNone(a)&&F.remove(a)}),Ta={remove:c6,clearClasses:d6,removeClass:function(a){return ii(function(b){n.remove(b,
  a)})},removeAttr:function(a){return ii(function(b){m.remove(b,a)})},unwrap:e6,removeIfEmpty:h6},xk=function(a){return"data-"+B.resolve(a)},MF=xk("a11y-current-violation"),NF=B.resolve("a11y-violation"),OF=B.resolve("a11y-severity-info"),PF=B.resolve("a11y-severity-warn"),QF=B.resolve("a11y-severity-error"),ao=xk("a11y-ignore"),RF=xk("a11y-error"),SF=xk("a11y-warning"),TF=xk("a11y-info"),Mt=Aa(["style","attribute"],[]),UF=Mt({style:QF,attribute:RF}),VF=Mt({style:PF,attribute:SF}),WF=Mt({style:OF,attribute:TF}),
  i6=function(a){return"error"===a?g.some(UF):"warning"===a?g.some(VF):"info"===a?g.some(WF):g.none()},Rq={configure:function(a){a.addSelector(a.output(),"["+ao+"]",Ta.removeAttr(ao));z([a.output(),a.input(),a.history(),a.internal()],function(b){z([NF,OF,PF,QF],function(c){a.add(b,c,Ta.removeClass(c))});z([MF,RF,SF,TF],function(c){a.addSelector(b,"["+c+"]",Ta.removeAttr(c))})})},ignoreAttr:k(ao),manager:function(a){return b6.manager({content:k(a),violation:k(NF),currentAttr:k(MF),ignoreAttr:k(ao),get:i6,
  all:k([UF,VF,WF])})}},XF=B.resolve("highlight-common"),Nt=B.resolve("highlight-placeholder"),rf={configure:function(a){a.add(a.output(),XF,Ta.unwrap);a.add(a.history(),Nt,Ta.unwrap);a.add(a.output(),Nt,Ta.unwrap);a.add(a.output(),"ephox-custom-highlight",Ta.unwrap);a.add(a.history(),"ephox-custom-highlight",Ta.unwrap)},highlightClass:k(XF),customHighlightClass:k("ephox-custom-highlight"),placeholderClass:k(Nt)},YF=function(){return Ot(function(a,b,c){return a()},"off")},ZF=function(){return Ot(function(a,
  b,c){return b()},"unchanged")},$F=function(a){return Ot(function(b,c,d){return d(a)},"on")},Ot=function(a,b){return{fold:a,map:function(b){return a(YF,ZF,function(a){return $F(b(a))})},label:k(b)}},Da={off:YF,unchanged:ZF,on:$F},aG=O("content"),se={hasSelection:function(a){return a.getSelection().fold(function(){return aG(Da.off())},function(){return aG(Da.on(!0))})},isAnnotation:function(a){return n.has(a,"ephox-cram-annotation-wrap")||n.has(a,rf.customHighlightClass())},isEmptyText:function(a){return D.isText(a)&&
  0===Ya.get(a).length},isTextArea:function(a){return"textarea"===D.name(a)}},NA={descend:function(a,b){var c=A.children(a);if(0===c.length||se.isTextArea(a))return W.point(a,b);if(b<c.length&&!se.isTextArea(c[b]))return W.point(c[b],0);c=c[c.length-1];if(se.isTextArea(c))return W.point(a,b);a=D.isText(c)?Ya.get(c).length:"img"===D.name(c)?1:A.children(c).length;return W.point(c,a)}},Pt=ta.generate([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),la={before:Pt.before,on:Pt.on,after:Pt.after,
  cata:function(a,b,c,d){return a.fold(b,c,d)},getStart:function(a){return a.fold(ca,ca,ca)}},bo=ta.generate([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),j6=O("start","soffset","finish","foffset"),k6=function(a){return a.match({domRange:function(a){return p.fromDom(a.startContainer)},relative:function(a,c){return la.getStart(a)},exact:function(a,c,d,e){return a}})},Kc={domRange:bo.domRange,relative:bo.relative,exact:bo.exact,exactFromRange:function(a){return bo.exact(a.start(),
  a.soffset(),a.finish(),a.foffset())},range:j6,getWin:function(a){a=k6(a);return A.defaultView(a)}},bG=function(a,b,c,d){var e=A.owner(a).dom().createRange();e.setStart(a.dom(),b);e.setEnd(c.dom(),d);return e},hd={after:function(a,b,c,d){var e=bG(a,b,c,d);a=N.eq(a,c)&&b===d;return e.collapsed&&!a},commonAncestorContainer:function(a,b,c,d){a=bG(a,b,c,d);return p.fromDom(a.commonAncestorContainer)}},l6={fromElements:function(a,b){var c=(b||Hb).createDocumentFragment();z(a,function(a){c.appendChild(a.dom())});
  return p.fromDom(c)}},cG=function(a,b){a.selectNodeContents(b.dom())},m6=function(a,b){b.fold(function(b){a.setStartBefore(b.dom())},function(b,d){a.setStart(b.dom(),d)},function(b){a.setStartAfter(b.dom())})},n6=function(a,b){b.fold(function(b){a.setEndBefore(b.dom())},function(b,d){a.setEnd(b.dom(),d)},function(b){a.setEndAfter(b.dom())})},dG=function(a){a.deleteContents()},eG=function(a){return{left:k(a.left),top:k(a.top),right:k(a.right),bottom:k(a.bottom),width:k(a.width),height:k(a.height)}},
  tc={create:function(a){return a.document.createRange()},replaceWith:function(a,b){dG(a);a.insertNode(b.dom())},selectNodeContents:function(a,b){a=a.document.createRange();cG(a,b);return a},selectNodeContentsUsing:cG,relativeToNative:function(a,b,c){a=a.document.createRange();m6(a,b);n6(a,c);return a},exactToNative:function(a,b,c,d,e){a=a.document.createRange();a.setStart(b.dom(),c);a.setEnd(d.dom(),e);return a},deleteContents:dG,cloneFragment:function(a){a=a.cloneContents();return p.fromDom(a)},getFirstRect:function(a){var b=
  a.getClientRects();a=0<b.length?b[0]:a.getBoundingClientRect();return 0<a.width||0<a.height?g.some(a).map(eG):g.none()},getBounds:function(a){a=a.getBoundingClientRect();return 0<a.width||0<a.height?g.some(a).map(eG):g.none()},isWithin:function(a,b){return 1>b.compareBoundaryPoints(a.END_TO_START,a)&&-1<b.compareBoundaryPoints(a.START_TO_END,a)},toString:function(a){return a.toString()}},yk=ta.generate([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),fG=
  function(a,b,c){return b(p.fromDom(c.startContainer),c.startOffset,p.fromDom(c.endContainer),c.endOffset)},o6=function(a,b){return b.match({domRange:function(a){return{ltr:k(a),rtl:g.none}},relative:function(b,d){return{ltr:Zb(function(){return tc.relativeToNative(a,b,d)}),rtl:Zb(function(){return g.some(tc.relativeToNative(a,d,b))})}},exact:function(b,d,e,f){return{ltr:Zb(function(){return tc.exactToNative(a,b,d,e,f)}),rtl:Zb(function(){return g.some(tc.exactToNative(a,e,f,b,d))})}}})},p6=function(a,
  b){var c=b.ltr();return c.collapsed?b.rtl().filter(function(a){return!1===a.collapsed}).map(function(a){return yk.rtl(p.fromDom(a.endContainer),a.endOffset,p.fromDom(a.startContainer),a.startOffset)}).getOrThunk(function(){return fG(a,yk.ltr,c)}):fG(a,yk.ltr,c)},gG=function(a,b){b=o6(a,b);return p6(a,b)},Le={ltr:yk.ltr,rtl:yk.rtl,diagnose:gG,asLtrRange:function(a,b){return gG(a,b).match({ltr:function(b,d,e,f){var c=a.document.createRange();c.setStart(b.dom(),d);c.setEnd(e.dom(),f);return c},rtl:function(b,
  d,e,f){var c=a.document.createRange();c.setStart(e.dom(),f);c.setEnd(b.dom(),d);return c}})}},Qt={inRect:function(a,b,c){return b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom},searchForPoint: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 h=a(f),l=Math.abs(b-h.left);if(c<=h.bottom){if(c<h.top||l>d)return f-1;d=l}}return 0}},q6=function(a,b,c,d,e){var f=function(c){var d=a.dom().createRange();d.setStart(b.dom(),c);d.collapse(!0);return d},h=Ya.get(b).length;c=Qt.searchForPoint(function(a){return f(a).getBoundingClientRect()},
  c,d,e.right,h);return f(c)},hG=function(a,b,c,d){var e=a.dom().createRange();e.selectNode(b.dom());e=e.getClientRects();return yc(e,function(a){return Qt.inRect(a,c,d)?g.some(a):g.none()}).map(function(e){return q6(a,b,c,d,e)})},iG=function(a,b,c,d){var e=a.dom().createRange();b=A.children(b);return yc(b,function(b){e.selectNode(b.dom());return Qt.inRect(e.getBoundingClientRect(),c,d)?(D.isText(b)?hG:iG)(a,b,c,d):g.none()})},r6={locate: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));return(D.isText(b)?hG:iG)(a,b,c,d)}},jG=function(a,b,c){a=a.dom().createRange();a.selectNode(b.dom());a.collapse(c);return a},s6=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?kc.first:kc.last)(b).map(function(b){return jG(a,b,e)})},t6=function(a,b,c){var d=b.dom().getBoundingClientRect();return g.some(jG(a,
  b,c-d.left<d.right-c?!0:!1))},u6={search:function(a,b,c){return(0===A.children(b).length?t6:s6)(a,b,c)}},v6=function(a,b,c){return g.from(a.dom().caretPositionFromPoint(b,c)).bind(function(b){if(null===b.offsetNode)return g.none();var c=a.dom().createRange();c.setStart(b.offsetNode,b.offset);c.collapse();return g.some(c)})},w6=function(a,b,c){return g.from(a.dom().caretRangeFromPoint(b,c))},x6=function(a,b,c,d){var e=a.dom().createRange();e.selectNode(b.dom());e=e.getBoundingClientRect();return r6.locate(a,
  b,Math.max(e.left,Math.min(e.right,c)),Math.max(e.top,Math.min(e.bottom,d)))},y6=function(a,b,c){return p.fromPoint(a,b,c).bind(function(d){var e=function(){return u6.search(a,d,b)};return 0===A.children(d).length?e():x6(a,d,b,c).orThunk(e)})},z6=document.caretPositionFromPoint?v6:document.caretRangeFromPoint?w6:y6,A6={fromPoint:function(a,b,c){a=p.fromDom(a.document);return z6(a,b,c).map(function(a){return Kc.range(p.fromDom(a.startContainer),a.startOffset,p.fromDom(a.endContainer),a.endOffset)})}},
  B6=function(a,b,c,d){var e=tc.create(a);a=(Ia.is(b,d)?[b]:[]).concat(Y.descendants(b,d));return ka(a,function(a){tc.selectNodeContentsUsing(e,a);return tc.isWithin(c,e)})},C6={find:function(a,b,c){b=Le.asLtrRange(a,b);var d=p.fromDom(b.commonAncestorContainer);return D.isElement(d)?B6(a,d,b,c):[]}},zk=function(a,b){var c=D.name(a);return"input"===c?la.after(a):U(["br","img"],c)?0===b?la.before(a):la.after(a):la.on(a,b)},kG=function(a,b){a=a.fold(la.before,zk,la.after);b=b.fold(la.before,zk,la.after);
  return Kc.relative(a,b)},Rt=function(a,b,c,d){a=zk(a,b);c=zk(c,d);return Kc.relative(a,c)},St={beforeSpecial:zk,preprocess:function(a){return a.match({domRange:function(a){var b=p.fromDom(a.startContainer),d=p.fromDom(a.endContainer);return Rt(b,a.startOffset,d,a.endOffset)},relative:kG,exact:Rt})},preprocessRelative:kG,preprocessExact:Rt},co=function(a,b){g.from(a.getSelection()).each(function(a){a.removeAllRanges();a.addRange(b)})},lG=function(a,b){return Le.diagnose(a,b).match({ltr:function(b,
  d,e,f){b=tc.exactToNative(a,b,d,e,f);co(a,b)},rtl:function(b,d,e,f){var c=a.getSelection();if(c.setBaseAndExtent)c.setBaseAndExtent(b.dom(),d,e.dom(),f);else if(c.extend)try{c.collapse(b.dom(),d),c.extend(e.dom(),f)}catch(l){b=tc.exactToNative(a,e,f,b,d),co(a,b)}else b=tc.exactToNative(a,e,f,b,d),co(a,b)}})},D6=function(a){var b=p.fromDom(a.anchorNode),c=p.fromDom(a.focusNode);hd.after(b,a.anchorOffset,c,a.focusOffset)?a=g.some(Kc.range(p.fromDom(a.anchorNode),a.anchorOffset,p.fromDom(a.focusNode),
  a.focusOffset)):0<a.rangeCount?(b=a.getRangeAt(0),a=a.getRangeAt(a.rangeCount-1),a=g.some(Kc.range(p.fromDom(b.startContainer),b.startOffset,p.fromDom(a.endContainer),a.endOffset))):a=g.none();return a},mG=function(a){return g.from(a.getSelection()).filter(function(a){return 0<a.rangeCount}).bind(D6)},Wa={setExact:function(a,b,c,d,e){b=St.preprocessExact(b,c,d,e);lG(a,b)},getExact:mG,get:function(a){return mG(a).map(function(a){return Kc.exact(a.start(),a.soffset(),a.finish(),a.foffset())})},setRelative:function(a,
  b,c){b=St.preprocessRelative(b,c);lG(a,b)},toNative:function(a){var b=Kc.getWin(a).dom(),c=function(a,c,f,h){return tc.exactToNative(b,a,c,f,h)};a=St.preprocess(a);return Le.diagnose(b,a).match({ltr:c,rtl:c})},setToElement:function(a,b){b=tc.selectNodeContents(a,b);co(a,b)},clear:function(a){a.getSelection().removeAllRanges()},clone:function(a,b){a=Le.asLtrRange(a,b);return tc.cloneFragment(a)},replace:function(a,b,c){b=Le.asLtrRange(a,b);a=l6.fromElements(c,a.document);tc.replaceWith(b,a)},deleteAt:function(a,
  b){a=Le.asLtrRange(a,b);tc.deleteContents(a)},forElement:function(a,b){a=tc.selectNodeContents(a,b);return Kc.range(p.fromDom(a.startContainer),a.startOffset,p.fromDom(a.endContainer),a.endOffset)},getFirstRect:function(a,b){a=Le.asLtrRange(a,b);return tc.getFirstRect(a)},getBounds:function(a,b){a=Le.asLtrRange(a,b);return tc.getBounds(a)},getAtPoint:function(a,b,c){return A6.fromPoint(a,b,c)},findWithin:function(a,b,c){return C6.find(a,b,c)},getAsString:function(a,b){a=Le.asLtrRange(a,b);return tc.toString(a)},
  isCollapsed:function(a,b,c,d){return N.eq(a,c)&&b===d}},nG=function(a,b){return ja.inBody(a)?g.some(Math.max(0,Math.min(b,wa.getEnd(a)))):g.none()},Tt={findDescendants:function(a,b,c,d,e){var f=A.defaultView(a);return nG(a,b).bind(function(b){return nG(c,d).map(function(d){d=Kc.exact(a,b,c,d);return Wa.findWithin(f.dom(),d,e)})}).getOr([])},findAncestors:function(a,b,c){return L.ancestor(a,c).fold(function(){return L.ancestor(b,c).toArray()},function(a){return L.ancestor(b,c).fold(k([a]),function(b){return N.eq(a,
  b)?[a]:[a,b]})})}},E6=aa.detect().browser.isFirefox(),eo=function(a){return a.filter(function(a){return"img"===D.name(a)})},F6=function(a){var b=eo(A.child(a.startContainer(),a.startOffset()));return eo(A.nextSibling(a.startContainer())).orThunk(function(){return b}).bind(function(c){return eo(A.prevSibling(a.endContainer())).bind(function(d){d=N.eq(c,d);var e=a.startContainer().dom().length===a.startOffset(),f=0===a.endOffset();return d&&(e||b.isSome())&&f?g.some(c):g.none()})})},G6=function(a){var b=
  a.startContainer();if(!N.eq(b,a.endContainer()))return g.none();if("img"===D.name(b))return g.some(b);var c=Math.min(a.startOffset(),a.endOffset());a=Math.max(a.startOffset(),a.endOffset());b=eo(A.child(b,c));return a===c||a===c+1?b:E6&&a===c+2?b.filter(function(a){return A.nextSibling(a).filter(se.isEmptyText).isSome()}):g.none()},oG=O("image"),pG=function(a){return a.filter(function(a){return!a.collapsed()}).bind(function(a){return G6(a).orThunk(function(){return F6(a)})})},qG=function(a,b){return!Xa(b,
  function(b){return Ia.is(a,b)})},vc={allowedForEditing:qG,detect:function(a){return pG(a).map(oG)},detectForEditing:function(a,b){return pG(a).filter(function(a){return qG(a,b)}).map(oG)}},rG=aa.detect().browser.isFirefox(),H6=function(a,b){return vc.detect(g.some(a)).filter(function(a){return N.eq(a.image(),b)}).isSome()},sG=function(a,b){var c=function(){a.setRelativeSelection(la.before(b),la.after(b))},d=rG?function(){a.getSelection().fold(c,function(c){I6(a,c,b)})}:c;a.focus();d()},I6=function(a,
  b,c){2===Math.abs(b.startOffset()-b.endOffset())&&H6(b,c)||(b=A.nextSibling(c).filter(se.isEmptyText).getOrThunk(function(){var a=p.fromText("");y.after(c,a);return a}),a.setRelativeSelection(la.before(c),la.after(b)))},ie={selectionContains:function(a){a=Tt.findDescendants(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset(),"img");return 1===a.length?g.some(a[0]):g.none()},remove:function(a,b){a.setRelativeSelection(la.before(b),la.before(b));F.remove(b)},select:sG,reselect:rG?sG:t},
  Ut=function(a,b){var c=bb.absolute(a),d=sa.get(a);return{element:k(a),bottom:k(c.top()+d),pos:k(c),cleanup:b}},J6=function(a,b){a=NA.descend(a,b);b=p.fromText(mb());var c=p.fromTag("span");y.append(c,b);y.before(a.element(),c);return Ut(c,function(){F.remove(c)})},uG=function(a,b){a.getSelection().each(function(c){tG(a,function(d,e){K6(a,b,c)},c)})},K6=function(a,b,c){a.body().each(function(d){a.doc().each(function(a){v.reflow(d);var e=Za.get(a).top(),h=J6(c.startContainer(),c.startOffset());b(a,
  e,h);h.cleanup()})})},vG=function(a,b,c){a.doc().each(function(a){var d=Za.get(a).top();c(a,d,b)})},wG=function(a,b,c){var d=a.dom().defaultView.innerHeight,e=c.pos();c.bottom()>d+b?(b=e.top()-d+1.5*sa.get(c.element()),Za.to(e.left(),b,a)):e.top()<b&&Za.to(e.left(),e.top(),a)},xG=function(a,b,c,d){a.body().each(function(e){var f=sa.get(a.element()),h=e.dom();var l=Math.max(h.offsetHeight,h.scrollHeight);h=d.pos();d.bottom()>l?v.set(e,"min-height",d.bottom()+"px"):v.remove(e,"min-height");h.top()<
  c?Za.to(h.left(),h.top(),b):h.top()>f+c&&(e=h.top()-f+(d.bottom()-h.top()),Za.to(h.left(),e,b));e=nk.find(d.element());f=Za.get().top();h=window.innerHeight+f;e.top()<f?Za.intoView(d.element(),!0):e.top()>h&&Za.intoView(d.element(),!1)})},L6=function(a){uG(a,wG)},M6=function(a,b){vG(a,Ut(b,t),wG)},N6=function(a){uG(a,u(xG,a))},O6=function(a,b){vG(a,Ut(b,t),u(xG,a))},tG=function(a,b,c){var d=c.startContainer(),e=c.startOffset(),f=c.endContainer();c=c.endOffset();b(d,f);a.setSelection(d,e,f,c);vc.detect(a.getSelection()).each(function(b){ie.select(a,
  b.image())})},Ng={cursorIntoView:function(a){(a.isInline()?L6:N6)(a)},elementIntoView:function(a,b){(a.isInline()?M6:O6)(a,b)},preserve:function(a,b){a.getSelection().each(function(c){tG(a,b,c)})}},P6=aa.detect(),Vt=function(a,b,c){a=p.fromTag(a);c=x.translate(c);return yG(a,b,c)},yG=function(a,b,c){c=S.labelledField(a,b,c);n.add(c.element(),B.resolve("form-group"));n.add(c.element(),B.resolve(b));"select"===D.name(a)&&(a=T.div(),n.add(a,B.resolve("select-wrap")),y.append(a,c.field()),y.append(c.element(),
  a));return c},Vc={input:function(a,b){a=Vt("input",a,b);P6.browser.isSafari()&&m.setAll(a.field(),{autocomplete:"off",autocorrect:"off",autocapitalize:"off",spellcheck:"false"});m.setAll(a.field(),{type:"text"});return{element:a.element,input:a.field}},textarea:function(a,b){a=Vt("textarea",a,b);S.multiline(a.field());return{element:a.element,textarea:a.field}},common:Vt,commonWith:yG,comboBox:function(a,b,c){var d=p.fromTag("input"),e=x.translate(b);b=T.div();var f=a+Fa("");e=p.fromHtml("<label>"+
  e+"</label>");m.set(e,"for",f);m.set(d,"id",f);n.add(b,B.resolve("form-group"));n.add(b,B.resolve(a));a=T.span();S.hidden(a,!0);f=T.span();S.hidden(f,!0);ma.add(f,["ephox-textbox-font",B.resolve("icon"),B.resolve("combo-drop-arrow-icon")]);n.add(a,B.resolve("combo-drop-arrow"));y.append(a,f);var h=T.div();n.add(h,B.resolve("label-wrap"));c.each(function(a){y.append(h,a)});y.append(h,e);c=T.div();n.add(c,B.resolve("combo-wrap"));P.append(c,[d,a]);m.set(d,"type","text");P.append(b,[h,c]);return{element:k(b),
  input:k(d),dropArrow:k(a)}}},zG=function(a){n.add(a,B.resolve("dialog-button-default"))},AG=function(a){n.add(a,B.resolve("dialog-button"))},Wt=function(a,b,c){var d=Nc(a+b);n.add(d.element(),B.resolve("dialog-"+b));a=Qc(x.translate(c));d.content(a);m.set(d.element(),"tabindex","-1");S.textButton(d.element(),a.element());return{enable:function(){d.enable();ra.enable(d.element())},disable:function(){d.disable();ra.disable(d.element())},element:d.element,name:d.name,destroy:d.destroy,content:d.content,
  disabled:d.disabled,click:d.click,events:d.events}},Q6=function(a){a=Wt(a,"ok","button.ok");zG(a.element());return a},R6=function(a){a=Wt(a,"cancel","button.cancel");AG(a.element());return a},sd={button:Wt,okCancel:function(a){var b=void 0!==a?a+"-":"";a=T.div();n.add(a,B.resolve(b+"dialog-controls"));var c=R6(b),d=Q6(b);P.append(a,[c.element(),d.element()]);b=H.create({ok:Q([],d.events.click),cancel:Q([],c.events.click)});return{element:k(a),ok:k(d),cancel:k(c),destroy:function(){d.destroy();c.destroy()},
  events:b.registry}},makeNormal:AG,makeDefault:zG},Xt=function(a,b){a=a();var c=a.element();S.button(c,b);m.set(c,"tabindex","-1");a.events.click.bind(function(){Z.focus(c)});return a},BG=function(a,b){var c=Xt(Nc,b);c.content(bf([a,B.resolve("icon")]));m.set(c.element(),"title",b);return c},CU={setDefaultAction:function(a){sd.makeDefault(a)},setNormalButton:function(a){sd.makeNormal(a)},makeTextButton:function(a,b,c){b=Xt(Nc,b);ma.add(b.element(),a);b.content(Qc(c));return b},makeIconToggle:function(a,
  b,c){var d=Xt($d,c);d.content(bf([b,B.resolve("icon")]));n.add(d.element(),B.resolve("choice-button"));m.set(d.element(),"data-value",a);m.set(d.element(),"title",c);return d},makeField:function(a,b,c){return Vc.commonWith(a,b,c)},makeIconButton:BG,makeIconStepperButton:function(a,b){a=BG(a,b);n.add(a.element(),B.resolve("stepper-button"));return a}},Yt={"a11y.widget.ok.label":"button.ok","a11y.widget.ok.text":"button.ok","a11y.widget.ignore.label":"a11y.widget.ignore","a11y.widget.ignore.text":"a11y.widget.ignore",
  "a11y.widget.repair.label":"a11y.widget.repair","a11y.widget.repair.text":"a11y.widget.repair","a11y.widget.repair.available":"a11y.widget.available","a11y.i1.description":"a11y.image.alttext.empty","a11y.i1.repair.info":"a11y.image.alttext.set","a11y.i1.repair.errors.empty":"a11y.image.alttext.validation.empty","a11y.i1.repair.errors.duplicate":"a11y.image.alttext.validation.filenameduplicate","a11y.i2.description":"a11y.image.alttext.filenameduplicate","a11y.i2.repair.info":"a11y.image.alttext.set",
  "a11y.i2.repair.errors.empty":"a11y.image.alttext.validation.empty","a11y.i2.repair.errors.duplicate":"a11y.image.alttext.validation.filenameduplicate","a11y.t1.description":"a11y.table.caption.empty","a11y.t1.repair.info":"a11y.table.caption.set","a11y.t1.repair.errors.empty":"a11y.table.caption.validation.empty","a11y.t1.repair.errors.duplicate":"a11y.table.caption.validation.summaryduplicate","a11y.t2.description":"a11y.table.summary.empty","a11y.t2.repair.info":"a11y.table.summary.set","a11y.t2.repair.errors.empty":"a11y.table.summary.validation.empty",
  "a11y.t2.repair.errors.duplicate":"a11y.table.summary.validation.captionduplicate","a11y.t3.description":"a11y.table.caption.summaryduplicate","a11y.t3.repair.info":"a11y.table.caption.set","a11y.t3.repair.errors.empty":"a11y.table.caption.validation.empty","a11y.t3.repair.errors.duplicate":"a11y.table.caption.validation.summaryduplicate","a11y.t4a.description":"a11y.table.rowscells.none","a11y.t4b.description":"a11y.table.headers.none","a11y.t4b.repair.info":"a11y.table.headers.set","a11y.t4b.repair.row":"table.row-header",
  "a11y.t4b.repair.column":"table.column-header","a11y.t4b.repair.errors.none":"a11y.table.headers.validation.none","a11y.t4c.description":"a11y.table.headerscope.none","a11y.t4c.repair.info":"a11y.table.headerscope.set","a11y.t4c.repair.scope.row":"a11y.table.headerscope.scope.row","a11y.t4c.repair.scope.col":"a11y.table.headerscope.scope.col","a11y.t4c.repair.scope.rowgroup":"a11y.table.headerscope.scope.rowgroup","a11y.t4c.repair.scope.colgroup":"a11y.table.headerscope.scope.colgroup","a11y.d1.description":"a11y.heading.paragraphmisuse",
  "a11y.d1.repair.info":"a11y.heading.set","a11y.d1.repair.block.h1":"block.h1","a11y.d1.repair.block.h2":"block.h2","a11y.d1.repair.block.h3":"block.h3","a11y.d1.repair.block.h4":"block.h4","a11y.d1.repair.block.h5":"block.h5","a11y.d1.repair.block.h6":"block.h6","a11y.d2.description":"a11y.heading.nonsequential","a11y.d3.description":"a11y.link.adjacent","a11y.d4.description":"a11y.list.paragraphmisuse","a11y.d5a.description":"a11y.contrast.largetext","a11y.d5b.description":"a11y.contrast.smalltext"},
  Ny={get:function(a){return g.from(Yt[a])},translate:function(a){var b=Array.prototype.slice.call(arguments,1);return x.translate.apply(void 0,[void 0!==Yt[a]?Yt[a]:a].concat(b))}},EU=Aa(["rules"],[]),CG=Aa(["rule","element"],[]),S6=function(a,b){return ia(b,function(b){return b.check()(a)?[CG({rule:b,element:a})]:[]})},T6=function(a,b){return ia(b,function(b){return E(b.check()(a),function(a){return CG({rule:b,element:a})})})},sU={audit:function(a,b){var c=[],d=m1(b,function(a){return a.walkable()});
  b=d.pass;d=d.fail;for(var e=document.createTreeWalker(a,Jc.getOrDie("NodeFilter").SHOW_ELEMENT,null,!1);e.nextNode();)c=c.concat(S6(e.currentNode,b));a=T6(a,d);c=c.concat(a);c.sort(function(a,b){a=a.element();b=b.element();return a===b?0:mm.documentPositionPreceding(a,b)?1:-1});return c}},Yc=Aa("id wcag severity desckey url walkable check".split(" "),[]),Zc={error:k("error"),warning:k("warning"),info:k("info")},nh={match:function(a,b){return a.matches?a.matches(b):a.webkitMatchesSelector?a.webkitMatchesSelector(b):
  a.mozMatchesSelector?a.mozMatchesSelector(b):a.msMatchesSelector?a.msMatchesSelector(b):!1}},U6=function(a){return ob(a.childNodes,function(a){return/^(b|strong)$/i.test(a.nodeName)})},V6=Yc({id:"D1",wcag:"1.3.1",severity:Zc.warning(),desckey:"a11y.d1.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",walkable:!0,check:function(a){return nh.match(a,"p")?U6(a):!1}}),W6=Yc({id:"D2",wcag:"1.3.1",severity:Zc.error(),desckey:"a11y.d2.description",
  url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",walkable:!1,check:function(a){a=a.querySelectorAll("h1, h2, h3, h4, h5, h6");var b,c=[];z(a,function(a){var d=parseInt(a.tagName.slice(1),10);b&&1<d-b&&c.push(a);b=d});return c}}),X6=Yc({id:"D3",wcag:"2.4.4",severity:Zc.error(),desckey:"a11y.d3.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/navigation-mechanisms-refs.html",walkable:!1,check:function(a){return ka(a.querySelectorAll("a + a"),
  function(a){return a.href===a.previousSibling.href})}}),DG=function(a){var b=a.nodeName;for(a=a.nextSibling;null!==a&&("#text"===a.nodeName||"BR"===a.nodeName);)a=a.nextSibling;return null!==a&&a.nodeName===b?a:!1},EG={check:function(a,b){a=a.querySelectorAll("p,h1,h2,h3,h4,h5,h6");for(var c=[],d=0;d<a.length;){var e=a[d];var f=b;var h=DG(e);for(e=f(e)?[e]:[];!1!==h&&f(h);)e.push(h),h=DG(h);f=e;if(1<f.length){c.push(f[0]);f=f[f.length-1];h=-1;for(e=0;e<a.length;e++)if(a[e]===f){h=e;break}f=h;d=-1===
  f?d+1:f}else d++}return c}},Y6=function(a){return a.textContent.match(/^\s{0,}([a-z1-9]|i+)\s{0,}[.)-]/gmi)},Z6=Yc({id:"D4o",wcag:"1.3.1",severity:Zc.error(),desckey:"a11y.d4.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",walkable:!1,check:function(a){return EG.check(a,Y6)}}),$6=function(a){return a.textContent.match(/^\s{0,}(\*|-)\s{0,}/gmi)},a7=Yc({id:"D4u",wcag:"1.3.1",severity:Zc.error(),desckey:"a11y.d4.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",
  walkable:!1,check:function(a){return EG.check(a,$6)}}),FG=O("red","green","blue","alpha"),Ak={rgbaColour:FG,white:function(){return FG(255,255,255,1)}},ji={calculateContrastRatio:function(a,b){return(Math.max(a,b)+.05)/(Math.min(a,b)+.05)},calculateLuminance:function(a){var b=function(a){return.03928>=a?a/12.92:Math.pow((a+.055)/1.055,2.4)},c=a.red()/255,d=a.green()/255;a=a.blue()/255;c=b(c);d=b(d);b=b(a);return.2126*c+.7152*d+.0722*b},composeColour:function(a,b){var c=a.alpha()+b.alpha()*(1-a.alpha()),
  d=(a.red()*a.alpha()+b.red()*b.alpha()*(1-a.alpha()))/c,e=(a.green()*a.alpha()+b.green()*b.alpha()*(1-a.alpha()))/c;a=(a.blue()*a.alpha()+b.blue()*b.alpha()*(1-a.alpha()))/c;return Ak.rgbaColour(Math.ceil(d),Math.ceil(e),Math.ceil(a),c)}},GG={parseColour:function(a){var b=function(a,b,c,h){a=parseInt(a,10);b=parseInt(b,10);c=parseInt(c,10);h=parseFloat(h);return g.some(Ak.rgbaColour(a,b,c,h))};if("transparent"===a)return b(0,0,0,0);var c=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(null!==c)return b(c[1],
  c[2],c[3],1);a=a.match(/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(\d?(?:\.\d+)?)\)/);return null!==a?b(a[1],a[2],a[3],a[4]):g.none()}},HG=function(a,b){a=parseFloat(v.get(a,"opacity"));return 1>a?Ak.rgbaColour(b.red(),b.green(),b.blue(),b.alpha()*a):b},IG={getBackgroundColor:function(a){var b=A.owner(a),c=ja.getBody(b);a=[a].concat(A.parents(a,function(a){return N.eq(a,c)}));a=hb(a,function(a,b){if(1===a.alpha())return a;var c=v.get(b,"background-color");return GG.parseColour(c).bind(function(c){c=HG(b,
  c);return 0<c.alpha()?g.some(ji.composeColour(a,c)):g.none()}).getOr(a)},Ak.rgbaColour(0,0,0,0));return 1>a.alpha()?ji.composeColour(a,Ak.white()):a},getForegroundColor:function(a,b){var c=v.get(a,"color");return GG.parseColour(c).bind(function(c){c=HG(a,c);c=1>c.alpha()?ji.composeColour(c,b):c;return g.some(c)})}},JG=function(a){var b=IG.getBackgroundColor(a);return IG.getForegroundColor(a,b).map(function(a){var c=ji.calculateLuminance(b);a=ji.calculateLuminance(a);return ji.calculateContrastRatio(a,
  c)})},KG={check:function(a,b){return JG(a).filter(function(a){return a<b}).isSome()},getRatio:JG},b7=function(a){a=v.get(a,"font-weight");return"bold"===a||"bolder"===a?!0:/^[0-9]*$/.test(a)?700<=parseInt(a,10):!1},LG=function(a){var b=v.get(a,"font-size");a=/.*px/.test(b);b=b.match(/(\d*\.?\d*)(.*)/);return a&&null!==b?g.some(Number(b[1])):g.none()},MG={isLargeFont:function(a){var b=b7(a),c=A.owner(a);c=ja.getBody(c);var d=LG(c);return LG(a).fold(ed,function(a){return d.fold(function(){return 24<=
  a||b&&19<=a},function(c){return a>=1.5*c||b&&a>=1.2*c})})}},NG={hasNonEmptyTextChild:function(a){a=A.children(a);return 0<ka(a,function(a){return D.isText(a)&&0<D.value(a).trim().length}).length}},c7=Yc({id:"D5a",wcag:"1.4.3",severity:Zc.error(),desckey:"a11y.d5a.description",url:"https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html",walkable:!0,check:function(a){a=p.fromDom(a);return NG.hasNonEmptyTextChild(a)&&MG.isLargeFont(a)&&KG.check(a,3)}}),d7=Yc({id:"D5b",wcag:"1.4.3",
  severity:Zc.error(),desckey:"a11y.d5b.description",url:"https://www.w3.org/TR/UNDERSTANDING-WCAG20/visual-audio-contrast-contrast.html",walkable:!0,check:function(a){a=p.fromDom(a);return NG.hasNonEmptyTextChild(a)&&!MG.isLargeFont(a)&&KG.check(a,4.5)}}),e7=Yc({id:"I1",wcag:"1.1.1",severity:Zc.error(),desckey:"a11y.i1.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/text-equiv-all.html",walkable:!0,check:function(a){return nh.match(a,"img")&&(!1===a.hasAttribute("alt")||""===a.getAttribute("alt").trim())}}),
  f7=Yc({id:"I2",wcag:"1.1.1",severity:Zc.error(),desckey:"a11y.i2.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/text-equiv-all.html",walkable:!0,check:function(a){return nh.match(a,"img[alt][src]")&&a.src.split("/").pop()===a.alt.split("/").pop()}}),g7=Yc({id:"T1",wcag:"1.3.1",severity:Zc.error(),desckey:"a11y.t1.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",walkable:!0,check:function(a){return nh.match(a,"table")?(a=a.querySelector("caption"))?
  nh.match(a,":empty"):!0:!1}}),h7=Yc({id:"T2",wcag:"1.3.1",severity:Zc.warning(),desckey:"a11y.t2.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",walkable:!0,check:function(a){return nh.match(a,"table")&&(a.querySelector("[rowspan]")||a.querySelector("[colspan]"))&&!a.hasAttribute("summary")}}),i7=Yc({id:"T3",wcag:"1.3.1",severity:Zc.error(),desckey:"a11y.t3.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",
  walkable:!0,check:function(a){return nh.match(a,"table")&&a.hasAttribute("summary")&&0<a.querySelectorAll("caption").length&&a.getAttribute("summary")===a.querySelector("caption").innerHTML}}),j7=Yc({id:"T4b",wcag:"1.3.1",severity:Zc.error(),desckey:"a11y.t4b.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",walkable:!0,check:function(a){return"table"===a.nodeName.toLowerCase()&&0===a.querySelectorAll("th").length}}),k7=Yc({id:"T4c",wcag:"1.3.1",
  severity:Zc.error(),desckey:"a11y.t4c.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",walkable:!0,check:function(a){if("th"===a.nodeName.toLowerCase()){var b=!1===a.hasAttribute("scope");a=!1===/row|col|rowgroup|colgroup/i.test(a.getAttribute("scope"));b=b||a}else b=!1;return b}}),l7=Yc({id:"T4a",wcag:"1.3.1",severity:Zc.error(),desckey:"a11y.t4a.description",url:"http://www.w3.org/TR/UNDERSTANDING-WCAG20/content-structure-separation-programmatic.html",
  walkable:!0,check:function(a){return"table"===a.nodeName.toLowerCase()?0===a.querySelectorAll("tr").length||0===a.querySelectorAll("td").length:!1}}),OG=[V6,W6,X6,Z6,a7,c7,d7,e7,f7,g7,h7,i7,k7,l7,j7],PG={get:function(a){return qa(OG,function(b){return b.name()===a})},all:k(OG)},DU={get:function(a){return PG.get(a)},all:function(){return PG.all().slice()}},m7={resolve:Lb.create("ephox-wheel").resolve},$a={resolve:function(a,b){return m7.resolve(a.prefix()+"-"+b)},translate:function(a,b){var c=[(Gb(b,
  a.tnames())?"":a.tnames()+".")+b].concat(Array.prototype.slice.call(arguments,2));return a.translate.apply(null,c)}},Zt=function(a,b,c,d,e){c=$a.translate(e,c);d=$a.translate(e,d);return a.makeTextButton(b,c,d)},ef={defaultActionButton:function(a,b,c,d,e){b=Zt(a,b,c,d,e);a.setDefaultAction(b.element());return b},normalButton:function(a,b,c,d,e){b=Zt(a,b,c,d,e);a.setNormalButton(b.element());return b},button:Zt,toggleButton:function(a,b,c,d,e){d=$a.translate(e,d);return a.makeIconToggle(b,c,d)},field:function(a,
  b,c,d,e){d=$a.translate(e,d);return a.makeField(b,c,d)},icon:function(a,b,c,d){c=$a.translate(d,c);return a.makeIconStepperButton(b,c)}},n7=function(a,b,c,d,e,f){var h=p.fromTag("input");a=ef.field(a,h,c,d,f);n.add(h,$a.resolve(f,"input"));b=[ha.input(h,Ba.input({execute:b}))];return{element:a.element,get:function(){var a={};a[c]=fa.get(h);return a},update:function(a){a=e(a);fa.set(h,a)},keylayouts:k(b),destroy:t}},o7=function(a,b,c,d,e){var f=p.fromTag("select");a=ef.field(a,f,b,c,e);d=E(d,function(a){var b=
  p.fromTag("option");fa.set(b,a.value());Ha.set(b,$a.translate(e,a.text()));return b});P.append(f,d);d=[ha.single(f,[],g.none())];return{element:a.element,get:function(){var a={};a[b]=fa.get(f);return a},update:t,keylayouts:k(d),destroy:t}},p7=function(a,b,c,d,e){var f=T.div();n.add(f,$a.resolve(e,"flow"));var h=E(d,function(b){return ef.toggleButton(a,b.value(),b.icon(),b.textkey(),e)});d=E(h,function(a){return a.element()});P.append(f,d);d=[ha.flow(f,{item:k(".ephox-pastry-statebutton")},Ba.flow({trigger:function(a){return L.descendant(a,
  ".ephox-pastry-button").map(function(a){a.dom().click();return a})}}))];return{element:ef.field(a,f,b,c,e).element,get:function(){return Eb(h,function(a,b){var c={};c[m.get(b.element(),"data-value")]=b.selected();return oa(a,c)},{})},update:t,keylayouts:k(d),destroy:function(){z(h,function(a){a.destroy()})}}},vU={generate:function(a,b,c,d){b=b.getOr([]);var e=ia(b,function(a){return a.fold(function(a,b,c){return[a]},function(a,b,c){return[a]},function(a,b,c){return E(c,function(a){return a.value()})})}),
  f=0<e.length?Aa(e,[]):k({}),h=H.create({execute:r([])}),l=function(){h.trigger.execute()},g=E(b,function(b){return b.fold(function(b,c,e){return n7(a,l,b,c,e,d)},function(b,c,e){return o7(a,b,c,e,d)},function(b,c,e){return p7(a,b,c,e,d)})});z(g,function(a){a.update(c)});b=E(g,function(a){return a.element()});var C=ia(g,function(a){return a.keylayouts()});return{elements:k(b),get:function(){var a=Eb(g,function(a,b){return oa(a,b.get())},{});return f(a)},keylayouts:k(C),destroy:function(){z(g,function(a){a.destroy()});
  z(C,function(a){a.destroy()})},events:h.registry}}},Sc={title:k("widget.title"),running:k("widget.running"),previous:k("widget.previous"),next:k("widget.next"),issueCounter:k("widget.issue.counter"),issueHelp:k("widget.issue.help"),noIssue:k("widget.issue.none"),severity:function(a){return"severity."+a},repairLabel:k("widget.repair.label"),repairText:k("widget.repair.text"),repairAvailable:k("widget.repair.available"),ignoreLabel:k("widget.ignore.label"),ignoreText:k("widget.ignore.text"),okLabel:k("widget.ok.label"),
  okText:k("widget.ok.text")},Zl=function(a,b,c){var d=T.div();n.add(d,$a.resolve(c,a));b.each(function(a){y.append(d,p.fromText($a.translate(c,a)))});return d},QG=function(a){var b=na(g.none());return{clear:function(){b.get().each(a);b.set(g.none())},isSet:function(){return b.get().isSome()},set:function(c){b.get().each(a);b.set(g.some(c))}}},gd={destroyable:function(){return QG(function(a){a.destroy()})},unbindable:function(){return QG(function(a){a.unbind()})},api:function(){var a=na(g.none()),b=
  function(){a.get().each(function(a){a.destroy()})};return{clear:function(){b();a.set(g.none())},isSet:function(){return a.get().isSome()},set:function(c){b();a.set(g.some(c))},run:function(b){a.get().each(b)}}},value:function(){var a=na(g.none());return{clear:function(){a.set(g.none())},set:function(b){a.set(g.some(b))},isSet:function(){return a.get().isSome()},on:function(b){a.get().each(b)}}}},RG=aa.detect(),fo=RG.os.isOSX(),$c=fo?"\u2318":"Ctrl",go=fo?"\u21e7":"Shift",SG={blockquote:[$c,go,"9"],
  bold:[$c,"B"],italic:[$c,"I"],underline:[$c,"U"],link:[$c,"K"],help:[$c,"?"],fullscreen:[$c,go,"F"],indent:[$c,"]"],outdent:[$c,"["],undo:[$c,"Z"],redo:fo?[$c,go,"Z"]:[$c,"Y"],search:[$c,"F"]},q7="fr nl sv ru de es it".split(" "),r7=ua(SG,{indent:[$c,"M"],outdent:[$c,go,"M"]}),TG=function(a){var b=qf.get();return U(q7,b)?r7[a]:SG[a]},s7=function(a){a=TG(a);return void 0===a?"":" "+a.join("")},t7=function(a){a=TG(a);return void 0===a?"":" ("+a.join(" ")+")"},u7=fo?s7:t7,rb={get:function(a,b){return RG.os.isiOS()?
  x.get(a):x.get(a)+u7(b)}},HU=B.resolve("inverted-dialog-widget"),UG=function(a,b,c){var d=v.get(b,a);c=parseInt(d,10)+40*c;(0<c?v.set:v.remove)(b,a,c+"px")},v7={change:u(UG,"margin-right")},Py={ltr:{change:u(UG,"margin-left")},rtl:v7},Pd={runTransaction:function(a,b,c,d){d=void 0!==d?d:t;b.save();a.focus();c=c();setTimeout(function(){a.domChanged();a.uiChanged()},0);d();b.save();return c}},$t=O("startContainer","startOffset","endContainer","endOffset"),au=function(a,b){if(a.property().isText(b))return W.point(b,
  a.property().getText(b).length);var c=a.property().children(b);return 0<c.length?au(a,c[c.length-1]):W.point(b,c.length)},VG=function(a,b,c){var d=a.property().children(b);return 0<d.length&&c<d.length?VG(a,d[c],0):0<d.length&&a.property().isElement(b)&&d.length===c?au(a,d[d.length-1]):W.point(b,c)},bu=function(a,b,c){return a.property().isText(b)&&0===a.property().getText(b).trim().length||a.property().isComment(b)?c(b).bind(function(b){return bu(a,b,c).orThunk(function(){return g.some(b)})}):g.none()},
  WG=function(a,b){b=bu(a,b,a.query().nextSibling).getOr(b);if(a.property().isText(b))return W.point(b,0);var c=a.property().children(b);return 0<c.length?WG(a,c[0]):W.point(b,0)},XG=function(a,b){return a.property().isText(b)?a.property().getText(b).length:a.property().children(b).length},YG=function(a,b){b=bu(a,b,a.query().prevSibling).getOr(b);if(a.property().isText(b))return W.point(b,XG(a,b));var c=a.property().children(b);return 0<c.length?YG(a,c[c.length-1]):W.point(b,XG(a,b))},ig={toLast:au,
  toLeaf:VG,toLower:function(a,b){a=a.property().isText(b)?a.property().getText(b).length:a.property().children(b).length;return W.point(b,a)},freefallLtr:WG,freefallRtl:YG},ad={toLeaf:function(a,b,c){return ig.toLeaf(a,b,c)},freefallLtr:function(a,b){return ig.freefallLtr(a,b)},freefallRtl:function(a,b){return ig.freefallRtl(a,b)}},cu=nb(),kb={toLeaf:function(a,b){return ad.toLeaf(cu,a,b)},freefallLtr:function(a){return ad.freefallLtr(cu,a)},freefallRtl:function(a){return ad.freefallRtl(cu,a)}},ZG=
  function(a,b){return ja.inBody(a)&&0<=b&&b<A.children(a).length},ho={multiple:function(a,b,c){return function(d,e){d=a.getSelection();var f=d.map(function(a){return{left:A.parent(a.startContainer()).getOrDie(),right:A.parent(a.endContainer()).getOrDie()}}),h=Pd.runTransaction(a,b,function(){return ia(e,function(a){return a.getSelection().bind(function(a){return c(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset()).map(function(a){return a.all()})}).getOr([])})},a.toEditing);d=d.filter(function(a){return ZG(a.startContainer(),
  a.startOffset())&&ZG(a.endContainer(),a.endOffset())}).getOrThunk(function(){var a=kb.freefallLtr(0<h.length?h[0]:f.getOrDie().left),b=kb.freefallRtl(0<h.length?h[h.length-1]:f.getOrDie().right);return $t(a.element(),a.offset(),b.element(),b.offset())});a.setSelection(d.startContainer(),d.startOffset(),d.endContainer(),d.endOffset());return h}},single:function(a,b,c,d,e){return function(f,h){var g=d(a,f.startContainer(),f.startOffset()),k=d(a,f.endContainer(),f.endOffset());h=Pd.runTransaction(a,
  b,function(){return c(g.element(),g.offset(),k.element(),k.offset())},a.toEditing);return e(a,h,g,k,f)}}},io={multiple:function(a,b,c){return function(d,e){return Pd.runTransaction(a,b,function(){return ia(e,function(a){return a.getSelection().bind(function(a){return c(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset()).map(function(a){return a.all()})}).getOr([])})},a.toEditing)}},single:function(a,b,c,d,e){return function(f,h){var g=d(a,f.startContainer(),f.startOffset()),k=d(a,f.endContainer(),
  f.endOffset());h=Pd.runTransaction(a,b,function(){return c(g.element(),g.offset(),k.element(),k.offset())},a.toEditing);return e(a,h,g,k,f)}}},Bk=function(a,b,c,d,e){return b.map(function(b){a.setSelection(b.start(),b.soffset(),b.finish(),b.foffset());return b.all()}).getOr([])},Ck=function(a,b,c){return W.point(b,c)},du=ta.generate([{none:[]},{multiple:["elements","environments"]},{single:["selection","environment"]}]),$b={cata:function(a,b,c,d){return a.fold(b,c,d)},none:du.none,multiple:du.multiple,
  single:du.single,toSelection:function(a){return a.fold(g.none,function(a,c){return g.from(c[0]).bind(function(a){return a.getSelection()})},g.some)}},$G=O("left","right"),aH=function(a,b,c){var d=a.property().children(b);return Va(d,u(a.eq,c)).map(function(a){return{before:k(d.slice(0,a)),after:k(d.slice(a+1))}})},Dk={breakToLeft:function(a,b,c){return aH(a,b,c).map(function(d){var e=a.create().clone(b);a.insert().appendAll(e,d.before().concat([c]));a.insert().appendAll(b,d.after());a.insert().before(b,
  e);return $G(e,b)})},breakToRight:function(a,b,c){return aH(a,b,c).map(function(c){var d=a.create().clone(b);a.insert().appendAll(d,c.after());a.insert().after(b,d);return $G(b,d)})},breakPath:function(a,b,c,d){var e=O("first","second","splits"),f=function(b,l,k){var h=e(b,g.none(),k);return c(b)?e(b,l,k):a.property().parent(b).bind(function(e){return d(a,e,b).map(function(a){var b=[{first:a.left,second:a.right}],d=c(e)?e:a.left();return f(d,g.some(a.right()),k.concat(b))}).getOr(h)})};return f(b,
  g.none(),[])}},x7=function(a,b,c,d){c=b(a,c);return Eb(d,function(c,d){d=b(a,d);return w7(a,c,d)},c)},w7=function(a,b,c){return b.bind(function(b){return c.filter(u(a.eq,b))})},y7={oneAll:function(a,b,c){if(0<c.length){var d=c[0];c=c.slice(1);a=x7(a,b,d,c)}else a=g.none();return a}},z7=function(a,b,c,d){var e=a.property().children(b);if(a.eq(b,c[0]))return g.some([c[0]]);if(a.eq(b,d[0]))return g.some([d[0]]);var f=function(c){c=jd(c);var d=Va(c,u(a.eq,b)).getOr(-1);return Va(e,u(a.eq,d<c.length-1?
  c[d+1]:c[d]))};c=f(c);var h=f(d);return c.bind(function(a){return h.map(function(b){return e.slice(Math.min(a,b),Math.max(a,b)+1)})})},bH=function(a,b,c,d){var e=void 0!==d?d:k(!1);b=[b].concat(a.up().all(b));c=[c].concat(a.up().all(c));d=function(a){return Va(a,e).fold(function(){return a},function(b){return a.slice(0,b+1)})};b=d(b);var f=d(c);c=qa(b,function(b){return Xa(f,u(a.eq,b))});return{firstpath:k(b),secondpath:k(f),shared:k(c)}},eu={subset:function(a,b,c){var d=bH(a,b,c);return d.shared().bind(function(b){return z7(a,
  b,d.firstpath(),d.secondpath())})},ancestors:bH},zd={sharedOne:function(a,b,c){return y7.oneAll(a,b,c)},subset:function(a,b,c){return eu.subset(a,b,c)},ancestors:function(a,b,c,d){return eu.ancestors(a,b,c,d)},breakToLeft:function(a,b,c){return Dk.breakToLeft(a,b,c)},breakToRight:function(a,b,c){return Dk.breakToRight(a,b,c)},breakPath:function(a,b,c,d){return Dk.breakPath(a,b,c,d)}},ki=nb(),nf={sharedOne:function(a,b){return zd.sharedOne(ki,function(b,d){return a(d)},b)},subset:function(a,b){return zd.subset(ki,
  a,b)},ancestors:function(a,b,c){return zd.ancestors(ki,a,b,c)},breakToLeft:function(a,b){return zd.breakToLeft(ki,a,b)},breakToRight:function(a,b){return zd.breakToRight(ki,a,b)},breakPath:function(a,b,c){return zd.breakPath(ki,a,b,function(a,b,f){return c(b,f)})}},jo=function(a,b,c,d,e){return d(a).fold(function(){return!0},function(a){return N.eq(b,a)&&e(b,c)})},Pg={isLeft:function(a,b){return jo(a,b.startContainer(),b.startOffset(),kc.first,wa.isStart)},isAtLeftEdge:function(a,b,c){return jo(a,
  b,c,kc.first,wa.isStart)},isRight:function(a,b){return jo(a,b.startContainer(),b.startOffset(),kc.last,wa.isEnd)},isAtRightEdge:function(a,b,c){return jo(a,b,c,kc.last,wa.isEnd)}},A7=function(a){a=D.name(a);return"td"===a||"th"===a},fu=function(a){return"li"===D.name(a)||pa.isBlock(a)},cH=function(a){return"a"===D.name(a)},dH=function(a,b,c){return Ja.closest(a,b,c).filter(zf(c)).filter(zf(A7))},ec={stopAt:function(a){return u(N.eq,a)},isList:function(a){a=D.name(a);return"ol"===a||"ul"===a},isAnchor:cH,
  isHeading:function(a,b){b=Mb(b)?b:[];b="h1 h2 h3 h4 h5 h6".split(" ").concat(b);a=D.name(a);return U(b,a)},isCollapsed:function(a){return N.eq(a.startContainer(),a.endContainer())&&a.startOffset()===a.endOffset()},isRightEdge:function(a,b,c){var d=O("startContainer","startOffset");return Pg.isRight(a,d(b,c))},isBlockOrList:fu,exitList:function(a){return 0===cd.descendants(a,function(a){return D.isText(a)&&0<Ya.get(a).length&&0<Zh(Ya.get(a)).length||D.isElement(a)&&U("hr img input video iframe picture audio embed map object".split(" "),
  D.name(a))}).length},findBlock:function(a,b){return Ja.closest(a,fu,b)},findValidHardBreak:function(a,b){return dH(a,fu,b)},findAnchorBreak:function(a,b){return dH(a,cH,b)}},gu={forceAddBr:function(a,b){if("br"!==D.name(a)){var c=p.fromTag("br");D.isText(a)?(y.after(a,c),N.eq(b,a)||F.remove(a)):ec.isBlockOrList(a)?y.append(a,c):(b=p.fromText(mb()),y.prepend(a,b),y.after(a,c))}},rootBr:function(a,b){y.before(a,p.fromTag("br"))}},eH=function(a,b,c){var d=[];z(A.children(a),function(a){b(a)&&(d=d.concat([a]));
  d=c(a)?d:d.concat(eH(a,b,c))});return d},fH=function(a,b){var c=A.children(a);return 0<c.length?(c=c[0],b(c)||"textarea"===D.name(c)?a:fH(c,b)):a},ko={descendants:eH,plunge:fH},lo=function(a){if(!D.isText(a))return!1;a=Ya.get(a).trim();return 0===a.length||0===a.replace(mb(),"").length},mo=function(a){if(D.isText(a))return lo(a);var b=Ha.get(a);a=A.children(a);return""===Zh(b)||ob(a,lo)},li={vacant:function(a){a=Y.descendants(a,"span,a");return ka(a,function(a){if("span"===D.name(a)){var b=m.has(a,
  "class")&&0<m.get(a,"class").length,d=m.has(a,"id");a=!b&&!d&&!m.has(a,"style")&&mo(a)}else a=mo(a);return a})},isEmpty:mo,hasCursor:function(a,b){b=void 0!==b?b:"hr br img input textarea iframe".split(" ");return D.isText(a)?!1===lo(a):U(b,D.name(a))},isVacantText:lo,hasNoContent:mo},gH=function(a){var b="li"===D.name(a)?ec.isList:k(!1);return 0<ko.descendants(a,li.hasCursor,b).length?g.none():g.some(ko.plunge(a,b))},hH=function(a){a=li.vacant(a);z(a,F.remove)},iH=function(a,b){a=Y.descendants(b,
  a);a=ka(a,li.isEmpty);z(a,F.remove);li.isEmpty(b)&&F.remove(b)},Df={vacate:hH,emptyStyles:function(a){!0===m.has(a,"style")&&0===m.get(a,"style").length&&m.remove(a,"style")},needsCursor:gH,postprocess:function(a,b,c){hH(a);gH(a).each(function(a){gu.forceAddBr(a,b)})},lists:u(iH,"ul,ol"),blockquotes:u(iH,"blockquote")},B7=function(a,b){a=nf.breakToRight(a,b);a.each(function(a){a=a.right();z(["id"],u(m.remove,a));Df.emptyStyles(a)});return a},no={breakPath:function(a,b){return nf.breakPath(a,b,B7)}},
  C7={breakQuote:function(a,b){var c=no.breakPath(b,ec.stopAt(a));return c.second().map(function(a){var d=c.first();y.before(a,b);z([d,a],Df.blockquotes);return{start:k(la.on(b,0)),finish:k(la.on(b,0))}})}},jH=function(a){return D.isElement(a)?a:A.parent(a).getOr(a)},kH={bothMatch:function(a,b,c){a=jH(a);b=jH(b);return c(a)&&c(b)}},oo={isRootOrCell:function(a){return function(b){return a(b)||Ia.is(b,"td,th")}},isRootOrContainer:function(a){return function(b){return a(b)||pa.isContainer(b)}}},lH=function(a,
  b){return 0===a.length?!0:0===b.length?!1:a[0]<b[0]?!0:b[0]<a[0]?!1:lH(a.slice(1),b.slice(1))},jg={head:function(a){return 0<a.length?g.some(a[0]):g.none()},tail:function(a){return 0<a.length?g.some(a.slice(1)):g.none()},toLast:function(a){return 0<a.length?g.some(a[a.length-1]):g.none()},box:function(a){return[a]},isBefore:lH},po=ta.generate([{quasi:["elements"]},{block:["element"]},{container:["element","children"]},{fixture:["element"]}]),mH=function(a){return a.fold(function(a){return"@q["+E(a,
  function(a){return a.dom().outerHTML||'"'+a.dom().nodeValue+'"'}).join(",")+"]"},function(a){return"@"+a.dom().nodeName.toLowerCase()+"("+a.dom().innerHTML+")"},function(a,c){return"#"+a.dom().nodeName.toLowerCase()+"("+E(c,mH).join(",")+")"},function(a){return a.dom().nodeName.toLowerCase()})},nH=function(a){var b=function(a){return[a]};return a.fold(ca,b,b,b)},qo=k(!0),kg=k(!1),Bc={cata:function(a,b,c,d,e){return a.fold(b,c,d,e)},quasi:po.quasi,block:po.block,container:po.container,fixture:po.fixture,
  isQuasi:function(a){return a.fold(qo,kg,kg,kg)},isFixture:function(a){return a.fold(kg,kg,kg,qo)},isQuasiOrFixture:function(a){return a.fold(qo,kg,kg,qo)},toTarget:nH,toString:mH,toLastTarget:function(a){return jg.toLast(nH(a))}},Ek=function(a,b){return{fold:a,label:k(b)}},lg={before:function(a){return Ek(function(b,c,d,e,f){return b(a)},"before")},after:function(a){return Ek(function(b,c,d,e,f){return c(a)},"after")},rest:function(a){return Ek(function(b,c,d,e,f){return d(a)},"rest")},last:function(a){return Ek(function(b,
  c,d,e,f){return e(a)},"last")},invalid:function(a,b){return Ek(function(c,d,e,f,h){return h(a,b)},"invalid")}},oH={subdivide:function(a,b,c){var d=a.property().getText(b);c=ka(Fn.splits(d,c),function(a){return 0<a.length});if(1>=c.length)return[W.range(b,0,d.length)];a.property().setText(b,c[0]);d=Rd.generate(c.slice(1),function(b,c){var d=a.create().text(b);b=W.range(d,c,c+b.length);return g.some(b)},c[0].length);var e=E(d,function(a){return a.element()});a.insert().afterAll(b,e);return[W.range(b,
  0,c[0].length)].concat(d)}},ro=function(a,b){return{fold:a,label:k(b)}},so={none:function(){return ro(function(a,b,c,d){return a()},"none")},start:function(a){return ro(function(b,c,d,e){return c(a)},"start")},middle:function(a,b){return ro(function(c,d,e,f){return e(a,b)},"middle")},end:function(a){return ro(function(b,c,d,e){return e(a)},"end")}},D7={determine:function(a){return a.before().fold(function(){return a.after().fold(function(){return so.none()},function(a){return so.start(a)})},function(b){return a.after().fold(function(){return so.end(b)},
  function(a){return so.middle(b,a)})})}},E7={group:function(a,b,c){b=ia(b,function(b){return dg.from(a,b,c)});b=xC.splitbyAdv(b,function(a){return kn.cata(a,function(){return $h.excludeWithout(a)},function(){return $h.excludeWith(a)},function(){return $h.include(a)})});return ka(b,function(a){return 0<a.length})}},F7={common:function(a,b,c){b=[b].concat(a.up().all(b));var d=[c].concat(a.up().all(c));return qa(b,function(b){return Xa(d,function(c){return a.eq(c,b)})})}},JU="table tbody thead tfoot tr ul ol".split(" "),
  G7={range:function(a,b,c,d,e){return a.eq(b,d)?[b]:F7.common(a,b,d).fold(function(){return[]},function(f){var h=[f].concat(dg.all(a,f,k(!1)));f=Va(h,u(a.eq,b));var g=Va(h,u(a.eq,d));f=f.bind(function(a){return g.map(function(b){return a<b?h.slice(a+c,b+e):h.slice(b+e,a+c)})}).getOr([]);var q=IU(a);return ka(f,q.validateText)})}},pH={range:function(a,b,c,d,e){return G7.range(a,b,c,d,e)},group:function(a,b,c){return E7.group(a,b,c)}},hu=O("before","after"),qH=function(a,b,c){a=a.property().getText(b);
  return Fn.splits(a,c)},rH=function(a,b,c,d){if(!a.property().isText(b)||c===d)return b;if(c>d)return rH(a,b,d,c);var e=a.property().getText(b).length;if(0===c&&d===e)return b;d=qH(a,b,[c,d]);a.property().setText(b,d[0]);d=E(d.slice(1),function(b){return a.create().text(b)});e=d[0];a.insert().afterAll(b,d);return 0===c?b:e},Fk={split:function(a,b,c){if(!a.property().isText(b)||0>=c)return hu(g.none(),g.some(b));if(c>=a.property().getText(b).length)return hu(g.some(b),g.none());c=qH(a,b,[c]);a.property().setText(b,
  c[0]);c=a.create().text(c[1]);a.insert().after(b,c);return hu(g.some(b),g.some(c))},splitByPair:rH},H7=function(a,b,c,d,e){c=Fk.split(a,b,c).after().fold(function(){return W.delta(b,1)},function(a){return W.delta(a,0)});e=Fk.split(a,d,e).before().fold(function(){return W.delta(d,0)},function(a){return W.delta(a,1)});return pH.range(a,c.element(),c.deltaOffset(),e.element(),e.deltaOffset())},I7=function(a,b,c,d,e){return[Fk.splitByPair(a,b,c,e)]},J7={nodes:function(a,b,c,d,e){return(a.eq(b,d)?I7:H7)(a,
  b,c,d,e)}},Td={split:function(a,b,c){return Fk.split(a,b,c)},splitByPair:function(a,b,c,d){return Fk.splitByPair(a,b,c,d)},range:function(a,b,c,d,e){return J7.nodes(a,b,c,d,e)},subdivide:function(a,b,c){return oH.subdivide(a,b,c)},position:function(a,b){return D7.determine(b)}},K7=function(a,b,c){var d=Td.split(a,b,c);return Td.position(a,d).fold(function(){return lg.invalid(b,c)},lg.before,lg.after,lg.after)},L7=function(a,b,c){var d=a.property().children(b);return a.property().isEmptyTag(b)?lg.before(b):
  c===d.length?lg.last(b):c<d.length?lg.rest(d[c]):lg.invalid(b,c)},M7={atStartOf:function(a,b,c,d){var e=function(b){a.insert().before(b,d)};(a.property().isText(b)?K7:L7)(a,b,c).fold(e,function(b){a.insert().after(b,d)},e,function(b){a.insert().append(b,d)},t)}},iu={atStartOf:function(a,b,c,d){M7.atStartOf(a,b,c,d)}},N7=ta.generate([{none:[]},{root:["target","block"]},{created:["target","block"]},{actual:["target","block"]}]),mg=ua(N7,{toString:function(a){return a.fold(function(){return["block.none"]},
  function(a,c){return["block.root",a,c]},function(a,c){return["block.created",a,c]},function(a,c){return["block.actual",a,c]})},cata:function(a,b,c,d,e){return a.fold(b,c,d,e)},extract:function(a){var b=k([]),c=function(a,b){return[b]};return a.fold(b,b,c,c)},extractEvenRoot:function(a){var b=k([]),c=function(a,b){return[b]};return a.fold(b,c,c,c)}}),sH=function(a,b){return function(c){return a.eq(c,b)||a.property().parent(c).map(function(c){return a.eq(c,b)}).getOr(!1)}},O7=function(a,b,c){return a.eq(b,
  c)?g.none():a.property().isBoundary(c)?a.query().nextSibling(c):a.property().isEmptyTag(c)?(b=sH(a,b),b(c)?a.query().nextSibling(c):zd.breakPath(a,c,b,zd.breakToRight).second()):g.none()},P7=function(a,b,c){if(a.eq(b,c))return g.none();if(a.property().isBoundary(c))return a.query().prevSibling(c);if(a.property().isEmptyTag(c)){var d=sH(a,b);return d(c)?a.query().prevSibling(c):a.query().prevSibling(c).map(function(b){return zd.breakPath(a,b,d,zd.breakToRight).first()})}return g.none()},tH=function(a,
  b,c,d){return c(a,b,d).bind(function(c){var d=a.property().children(b);return Va(d,function(b){return a.eq(b,c)})})},ju=function(a,b){return a.property().isEmptyTag(b)||a.property().isBoundary(b)},ku={create:function(a,b,c){if(ju(a,c)||ju(a,ad.toLeaf(a,c,0).element()))return[c];var d=u(ju,a),e=u(a.eq,b),f=Ca.seekLeft(a,c,d,e).bind(function(c){return tH(a,b,O7,c)}).getOr(0),h=a.property().children(b);c=Ca.seekRight(a,c,d,e).bind(function(c){return tH(a,b,P7,c)}).getOr(h.length-1);return a.property().children(b).slice(f,
  c+1)}},Q7=function(a,b,c,d){return c(b)||d(b)?g.some(b):a.up().predicate(b,c,d)},uH=function(a,b,c){c=c();a.insert().wrap(b,c);return mg.created(b,c)},R7=function(a,b,c,d){var e=d();a.insert().before(c[0],e);z(c,function(b){a.insert().append(e,b)});return mg.created(b,e)},S7=function(a,b,c,d,e,f,h){if(f(c)){var g=a.property().children(b);if(d<g.length&&h(g[d]))return mg.actual(c,g[d])}return e(b).fold(function(){return mg.root(c,b)},function(e){if(f(c)){var h=e(),g=a.property().children(b),l=g[d];
  void 0!==l&&(e=ku.create(a,b,l,e),a.insert().appendAll(h,0<e.length?e:[l]));iu.atStartOf(a,b,Math.min(g.count,d),h);return mg.created(b,h)}a.property().isEmptyTag(c)?e=uH(a,c,e):(h=ku.create(a,b,c),e=0<h.length?R7(a,c,h,e):uH(a,c,e));return e})},T7={single:function(a,b,c,d,e,f){return Q7(a,c,b,f).fold(mg.none,function(h){return f(h)?S7(a,h,c,d,e,f,b):mg.actual(c,h)})}},vH={resolve:Lb.create("ephox-soldier").resolve},mi=vH.resolve("quasi-block"),wH=function(a){a=A.children(a);return 1===a.length&&
  "br"===D.name(a[0])},xH=function(a){return n.has(a,mi)&&!wH(a)},to={condense:function(a){a=ka(a,function(a,c){if(!D.isElement(a))return!0;n.has(a,mi)&&wH(a)&&(A.prevSibling(a).exists(xH)||A.nextSibling(a).exists(xH))?(F.remove(a),a=!1):a=!0;return a});return E(a,function(a){var b=D.isElement(a)?[a].concat(Y.descendants(a,"."+mi)):[];z(b,function(a){n.remove(a,mi)});return a})},register:function(a){return function(b){return a(b).map(function(a){return function(){var b=a();n.add(b,mi);return b}})}},
  style:k(mi)},U7=nb(),Bj={single:function(a,b,c,d,e){return T7.single(U7,a,b,c,to.register(d),e)},isBlock:function(a){return U("ol p div ul table caption td th h1 h2 h3 h4 h5 h6 body blockquote pre".split(" "),D.name(a))}},Gk={tag:function(){return"p"},nu:function(a){return u(a.create().nu,"p")}},lu=function(a){return 0<a.length?g.some(a[0]):g.none()},Hk=ta.generate([{descend:["index"]},{leftOf:["rindex"]},{bounded:["lindex","rindex"]},{rightOf:["lindex"]},{all:[]}]),yH={derive:function(a,b){return a.bind(lu).fold(function(){return b.bind(lu).fold(function(){return Hk.all()},
  function(a){return Hk.leftOf(a)})},function(a){return b.bind(lu).fold(function(){return Hk.rightOf(a)},function(b){return a===b?Hk.descend(a):Hk.bounded(a,b)})})},cata:function(a,b,c,d,e,f){return a.fold(b,c,d,e,f)}},zH=function(a,b,c){return g.from(a.property().children(b)[c])},V7=function(a,b,c){var d=a.property().children(c),e=zH(a,c,0).bind(function(e){return zH(a,c,d.length-1).map(function(d){return mu(a,b,c,e,d)})}).getOr([]);return Bc.container(c,e)},mu=function(a,b,c,d,e){var f=AH(a,c,b,d);
  return Bc.toLastTarget(f).filter(function(b){return!a.eq(e,b)}).bind(function(d){return Ca.walk(a,d,Ca.sidestep,Ca.walkers().right()).bind(function(d){if(a.eq(c,d.item()))return g.none();d=mu(a,b,c,d.item(),e);return g.some([f].concat(d))})}).getOrThunk(function(){return[f]})},AH=function(a,b,c,d){if(Mc.isFormatting(a,d))return Bc.block(d);if(Mc.isEmptyTag(a,d))return Bc.fixture(d);if(Mc.isBlock(a,d)||Mc.isContainer(a,d))return V7(a,c,d);a=ku.create(a,b,d);return Bc.quasi(0<a.length?a:[d])},BH=function(a,
  b,c){return AH(a,c,b,c)},nu=function(a,b,c,d,e,f,h,l){c=c.map(function(c){return Ik(a,b,c,h.bind(jg.tail),g.none())}).getOr([]);e=e.map(function(c){return Ik(a,b,c,g.none(),l.bind(jg.tail))}).getOr([]);d=0===d.length?[]:mu(a,b,f,d[0],d[d.length-1]);return[Bc.container(f,c.concat(d).concat(e))]},Ik=function(a,b,c,d,e){var f=a.property().children(c);d.bind(jg.head).getOr(0);e.bind(jg.head).getOr(f.length-1);var h=yH.derive(d,e);return yH.cata(h,function(c){return Ik(a,b,f[c],d.bind(jg.tail),e.bind(jg.tail))},
  function(h){return nu(a,b,g.none(),f.slice(0,h),g.from(f[h]),c,d,e)},function(h,k){return nu(a,b,g.from(f[h]),f.slice(h+1,k),g.from(f[k]),c,d,e)},function(h){return nu(a,b,g.from(f[h]),f.slice(h+1),g.none(),c,d,e)},function(){return[BH(a,b,c)]})},CH={categorise:BH,within:function(a,b,c,d,e){return!0===jg.isBefore(d,e)?Ik(a,b,c,g.some(d),g.some(e)):Ik(a,b,c,g.some(e),g.some(d))}},ou=function(a,b){if("li"!==D.name(a))return!1;a=hb(b,function(a,b){return 1<a.quasi||0<a.nonlist?a:Bc.cata(b,function(){return{quasi:1+
  a.quasi,nonlist:a.nonlist}},function(){return{quasi:a.quasi,nonlist:1+a.nonlist}},function(b){return{quasi:a.quasi,nonlist:(U(["ul","ol"],D.name(b))?0:1)+a.nonlist}},function(){return{quasi:1+a.quasi,nonlist:a.nonlist}})},{quasi:0,nonlist:0});return 1>=a.quasi&&0===a.nonlist},pu=function(a,b,c){return 0>=c.length?!0:U(a,D.name(b))?2<c.length?!1:1===c.length?Bc.isQuasiOrFixture(c[0]):Bc.isQuasiOrFixture(c[0])&&Bc.isQuasiOrFixture(c[1])&&!ob(c,Bc.isFixture):!1},Ud={wrap:function(a){if(0===a.length||
  1===a.length&&D.isText(a[0])&&0===Ya.get(a[0]).trim().length)return[];var b=p.fromTag(Gk.tag());n.add(b,to.style());y.before(a[0],b);P.append(b,a);return[b]},handleContainer:function(a,b,c,d){if(pu(a,b,c))return[b];var e=ou(b,c)?[b]:[];return e.concat(ia(c,function(a){return d(a,0<e.length)}))},hasSimpleContent:pu,isNestedList:ou,handleRoot:function(a,b){b=CH.categorise(nb(),u(N.eq,b),b,b,b);var c=function(){return g.some(Gk.nu(nb()))},d=g.none;return Bc.cata(b,c,d,function(b,f){return pu(a,b,f)||
  ou(b,f)?d():c()},c)}},uo=["li","td","th","caption"],DH=function(a,b){return Bc.cata(a,function(a){return!0===b?[]:Ud.wrap(a)},function(a){return[a]},function(a,b){return Ud.handleContainer(uo,a,b,DH)},function(a){return!0===b?[]:Ud.wrap([a])})},W7={isRootContainer:oo.isRootOrContainer,extract:function(a){return DH(a,!1)},isCapable:function(a){return Bj.isBlock(a)||U(uo,D.name(a))},canUse:function(a){return pa.isFormatting(a)||U(uo,D.name(a))},quasi:u(Ud.handleRoot,uo),ascend:ca},EH=Aa(["start","soffset",
  "finish","foffset","all"],[]),FH=Aa(["start","soffset","finish","foffset"],[]),ni={block:EH,inline:FH,blockFrom:function(a){return 0<a.length?g.some(EH({start:a[0],soffset:0,finish:a[a.length-1],foffset:wa.getEnd(a[a.length-1]),all:a})):g.none()},inlineFrom:function(a){return a.map(function(a){return FH({start:a.start(),soffset:a.soffset(),finish:a.finish(),foffset:a.foffset()})})}},vo=function(a){return Ia.is(a,"td,th")},GH=function(a){return N.eq(a.startContainer(),a.endContainer())&&a.startOffset()===
  a.endOffset()},HH=function(a,b){return a(b.startContainer())?g.some(kb.freefallLtr(b.startContainer())):g.none()},IH=function(a,b){return(a(b.endContainer())?g.some(kb.freefallRtl(b.endContainer())):g.none()).map(function(a){return Ia.is(a.element(),"br")&&!1===GH(b)?W.point(a.element(),1):a})},Vd={is:vo,isCollapsed:GH,isWholeCell:function(a){return vo(a.startContainer())&&N.eq(a.startContainer(),a.endContainer())&&0===a.startOffset()&&a.endOffset()===wa.getEnd(a.endContainer())},left:u(HH,vo),leftWith:HH,
  right:u(IH,vo),rightWith:IH},qu=O("startContainer","startOffset","endContainer","endOffset"),ru=O("start","soffset","finish","foffset"),Ub={hare:qu,fussy:ru,fromHare:function(a){return ru(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset())},fromFussy:function(a){return qu(a.start(),a.soffset(),a.finish(),a.foffset())},fussyFromElements:function(a){if(0===a.length)return g.none();var b=a[0];a=a[a.length-1];b=A.firstChild(b).getOr(b);a=A.lastChild(a).getOr(a);return g.some(ru(b,0,a,wa.getEnd(a)))},
  hareFromElement:function(a){return qu(a,0,a,wa.getEnd(a))}},JH=function(a,b){return b(a)?g.some([]):A.parent(a).bind(function(c){return A.findIndex(a).bind(function(a){return JH(c,b).map(function(b){return b.concat([a])})})})},KH=function(a,b){return 0===b.length?g.some(a):A.child(a,b[0]).bind(function(a){return KH(a,b.slice(1))})},oi={path:function(a,b){var c=u(N.eq,a);return N.eq(a,b)?g.some([]):JH(b,c)},follow:KH},LH=O("ancestor","startPath","finishPath"),X7=function(a,b,c){return nf.ancestors(b,
  c,a).shared().bind(function(a){return oi.path(a,b).bind(function(b){return oi.path(a,c).map(function(c){return LH(a,b,c)})})})},MH=function(a,b,c,d){var e=b.isRootContainer(a);c=Bj.single(b.isCapable,c,d,b.quasi,e);c=mg.extractEvenRoot(c);return 1===c.length?g.some(c[0]).map(function(c){return b.ascend(c,a)}):g.none()},NH=function(a,b,c,d){if(!1===b(c))return W.point(c,d);d<wa.getEnd(c)||a.isCapable(c)&&a.canUse(c)?c=kb.toLeaf(c,d):(a=p.fromTag("br"),y.append(c,a),c=W.point(a,0));return c},Y7={branch:function(a,
  b,c,d,e,f){var h=b.isRootContainer(a),l=Ub.hare(c,d,e,f),q=k(!0===Vd.isWholeCell(l)),C=Vd.left(l).filter(q).getOrThunk(function(){return NH(b,h,c,d)}),w=Vd.right(l).filter(q).getOrThunk(function(){return NH(b,h,e,f)});return MH(a,b,C.element(),C.offset()).bind(function(c){return(N.eq(C.element(),w.element())&&C.offset()===w.offset()?g.some(c):MH(a,b,w.element(),w.offset())).bind(function(b){return N.eq(c,b)?g.some(LH(c,[],[])):X7(a,c,b)})})}},OH=function(a,b,c,d,e,f,h){a=b.isRootContainer(a)(c);b=
  !a&&ja.inBody(c)?W.point(c,d):a||!b.isCapable(c)||ja.inBody(c)?ja.inBody(e.element())&&U(["td","th"],D.name(c))?e:!ja.inBody(c)&&ja.inBody(f.element())&&"br"==D.name(f.element())?f:kb.toLeaf(h,0):W.point(h,d);wa.getEnd(b.element());return b.offset()<=wa.getEnd(b.element())?g.some(b):g.none()},pi={applyOn:function(a,b,c,d,e,f,h){var l=hd.after(c,d,e,f),k=b.isRootContainer(a)(c)?kb.toLeaf(c,d):W.point(c,d),C=b.isRootContainer(a)(e)?kb.toLeaf(e,f):W.point(e,f),w=kb.toLeaf(c,d),m=kb.toLeaf(e,f),n=Y7.branch(a,
  b,c,d,e,f).map(function(b){return CH.within(nb(),a,b.ancestor(),b.startPath(),b.finishPath())}).getOr([]);n=ia(n,b.extract);z(n,function(a){0===A.children(a).length&&pa.isFormatting(a)&&y.append(a,p.fromTag("br"))});n=to.condense(n);var r=h(n);return 0===r.length?g.none():OH(a,b,c,d,k,w,r[l?r.length-1:0]).bind(function(c){return OH(a,b,e,f,C,m,r[l?0:r.length-1]).map(function(a){return ni.block({start:c.element(),soffset:c.offset(),finish:a.element(),foffset:a.offset(),all:r})})})}},su=function(a){return function(b){return a}},
  PH={start:ae.onDirection("left","right"),end:ae.onDirection("right","left"),justify:su("justify"),center:su("center"),"match-parent":su("match-parent")},Z7={hasAlignment:function(a,b,c){D.isText(a)?a=!1:(b=v.get(a,b),a=(void 0!==PH[b]?PH[b](a):b)===c);return a}},$7=function(a,b,c){return Z7.hasAlignment(c,a,b)},wo=function(a,b,c){var d=KU(b,c);return{run:function(a,b,c,g,k){return pi.applyOn(a,W7,b,c,g,k,function(a){var b=ob(a,d.is)?d.remove:d.set;z(a,b);return a})},query:function(a,d){var e=u($7,
  b,c);return kH.bothMatch(a,d,e)},name:k(a)}},a8=wo("JustifyLeft","text-align","left"),b8=wo("JustifyCenter","text-align","center"),c8=wo("JustifyRight","text-align","right"),d8=wo("JustifyFull","text-align","justify"),le={justifyleft:k(a8),justifycentre:k(b8),justifyright:k(c8),justifyfull:k(d8)},QH=function(a){a=a.dom();if(af.isSupported(a)){var b=a.style.marginLeft;return"auto"===a.style.marginRight&&"auto"===b}return!1},tu={isCentered:QH,divine:function(a){if(QH(a))return g.some("center");var b=
  v.getRaw(a,"float").getOrThunk(function(){return v.get(a,"float")});return void 0!==b&&null!==b&&0<b.length?g.some(b):g.none()},getRaw:function(a){return v.getRaw(a,"float").getOr(null)},setCentered:function(a){v.setAll(a,{"margin-left":"auto","margin-right":"auto"})}},e8={left:{"float":"left",margin:""},right:{"float":"right",margin:""},none:{"float":"none",margin:""},center:{"float":"",margin:"0 auto"}},RH={none:{display:""},left:{display:""},right:{display:""},center:{display:"block"}},SH=function(a,
  b){return tu.divine(a).is(b)},TH=function(a,b){var c="img"===D.name(a)&&void 0!==RH[b]?RH[b]:{};g.from(e8[b]).each(function(b){v.setAll(a,b);v.setAll(a,c)})},xo=function(a,b){return{run:function(a){TH(a,b);return g.none()},query:function(a){return SH(a,b)},name:k(a)}},f8=xo("JustifyLeft","left"),g8=xo("JustifyCenter","center"),h8=xo("JustifyRight","right"),i8=xo("FloatNone","none"),oh={floatnone:k(i8),floatleft:k(f8),floatcentre:k(g8),floatright:k(h8),queryIsFloat:SH,runFloat:TH},UH=function(a){return Bc.cata(a,
  function(a){return Ud.wrap(a)},function(a){return[a]},function(a,c){return ia(c,UH)},function(a){return Ud.wrap([a])})},VH={isRootContainer:oo.isRootOrContainer,extract:UH,isCapable:function(a){return Bj.isBlock(a)||"li"===D.name(a)},canUse:function(a){return pa.isFormatting(a)},quasi:function(a){return g.some(Gk.nu(nb()))},ascend:ca},uu=O("level","content","cruft","list","item"),yo={level:function(a,b){return uu(a.level()+b,a.content(),a.cruft(),a.list(),a.item())},list:function(a,b){return uu(a.level(),
  a.content(),a.cruft(),b,a.item())}},WH=O("elements","elementsTransformed"),j8=O("original","replaced"),ph=O("result","items"),zo={answer:WH,write:function(a,b){var c=[],d=function(b){var c=a.create().nu("p");a.insert().appendAll(c,b);return c},e=function(a){if(0===a.length)throw"Cannot get tail of an empty array";return a.slice(1)},f=function(b,c){for(var d=a.create().clone(c[0].list()),g=[],l=c[0];0<c.length&&c[0].level()>=b&&a.property().name(l.list())===a.property().name(c[0].list());){if(c[0].level()===
  b){var k=b;var q=c[0];var m=q;var n=m.item(),p=n;p=a.property().children(p);z(p,a.remove().remove);a.insert().appendAll(n,m.content());m=n;q=q.cruft();for(c=e(c);0<c.length&&c[0].level()>k;)c=f(k+1,c),n=[c.result()].filter(u(h,["li"])),c=c.items(),a.insert().appendAll(m,n);a.insert().appendAll(m,q);k=ph(m,c);c=[k.result()].filter(u(h,["li"]));k=ph(c,k.items())}else k=f(b+1,c),c=[k.result()].filter(u(h,["ul","ol"])),q=a.create().nu("li"),a.styles().set(q,"list-style-type","none"),a.attrs().remove(d,
  "id"),a.insert().appendAll(q,c),k=ph([q],k.items());c=k.items();g=g.concat(k.result())}a.insert().appendAll(d,g);return ph(d,c)},h=function(b,c){return!(U(b,a.property().name(c))&&0===a.property().children(c).length)};b=function(b){for(var g=[];0<b.length;){var l=b[0];if(0===l.level()){var k=b[0],m=k.content();m=1===m.length&&Mc.isBlock(a,m[0])?m[0]:d(m);c.push(j8(k.item(),m));b=ph(m,e(b));k=[b.result()].filter(u(h,["p"]));0===k.length&&c.pop();b=b.items();g=g.concat(k);m=b;for(b=[];0<m.length&&0<
  m[0].level();)m=f(1,m),k=[m.result()].filter(u(h,["ul","ol"])),m=m.items(),b=b.concat(k);k=ph(b,m);b=k.items();g=g.concat(k.result());0<l.cruft().length&&(g=g.concat([d(l.cruft())]))}else b=f(1,b),l=[b.result()].filter(u(h,["ul","ol"])),b=b.items(),g=g.concat(l)}return ph(g,b)}(b);if(0!==b.items().length)throw"Error - there should not be any remaining items to parse";return WH(b.result(),c)}},XH=function(a){return hb(a,function(a,c){var b=a.elements().concat(c.elements());a=a.elementsTransformed().concat(c.elementsTransformed());
  return zo.answer(b,a)},zo.answer([],[]))},k8={combine:XH,write:function(a,b){b=fm(b,function(b){return a.property().name(b.list())+"-"+a.styles().getRaw(b.list(),"list-style-type").getOr("default")});b=E(b,function(b){return zo.write(a,b)});return XH(b)}},YH=nb(),ZH=function(a){return k8.write(YH,a)},l8=function(a){return zo.write(YH,a)},$H=function(a,b,c){return L.closest(a,"li",c).bind(function(a){return b(a,c).map(function(b){return{item:k(a),outerlist:k(b)}})})},aI=function(a,b){return Va(a,function(a){return N.eq(a,
  b)})},m8=function(a,b,c){return aI(a,b).bind(function(b){return aI(a,c).map(function(c){return a.slice(Math.min(b,c),Math.max(b,c)+1)})})},qi={context:function(a,b,c,d,e){return $H(a,c,e).bind(function(f){return $H(b,c,e).bind(function(c){if(N.eq(f.outerlist(),c.outerlist())){if(N.eq(a,b))var e=[f.item()];else{var h=f.outerlist();e=f.item();var m=c.item();h=Y.descendants(h,"li");e=m8(h,e,m).getOr([])}c=g.some({outerlist:f.outerlist,startItem:f.item,finishItem:c.item,writer:k(d),selected:k(e)})}else c=
  g.none();return c})})},immediate:function(a,b){return L.closest(a,"ul,ol",b)},topmost:function(a,b){var c=cd.ancestors(a,function(a){return pa.isList(a)||pa.isContainer(a)},b);return Va(c,function(a){return!U(["li","ol","ul"],D.name(a))}).map(function(a){return 0<a&&a-1<c.length?g.some(c[a-1]):0<c.length?g.some(c[c.length-1]):g.none()}).getOrThunk(function(){return 0<c.length?g.some(c[c.length-1]):g.none()})}},vu={context:function(a,b,c){return qi.context(a,b,qi.topmost,l8,c)},indent:function(a){return yo.level(a,
  1)},outdent:function(a){return yo.level(a,-1)}},n8=function(a,b){return Xa(a,function(a){return N.eq(b,a)})},o8={operate:function(a,b,c){return E(b,function(b){return n8(c,b.item())?a(b):b})}},bI=O("before","on","after"),p8=function(a,b){var c=g.from(E(b,function(b){return a[b]})),d=a.slice(0,b[0]);b=a.slice(b[b.length-1]+1);return bI(d,c,b)},q8={refine:function(a,b){var c=E(a,function(a,c){return b(a)?g.some(c):g.none()});c=ee(c);var d=bI(a,g.none(),[]);return 0===c.length?d:p8(a,c)}},wu=function(a,
  b){var c=Y.children(a,"li,ol,ul");return ia(c,function(c){return"li"===D.name(c)?r8(a,c,b):wu(c,b+1)})},r8=function(a,b,c){var d=s8(b),e=[uu(c,d.before(),d.after(),a,b)];return d.on().fold(function(){return e},function(a){a=ia(a,function(a){return wu(a,c+1)});return e.concat(a)})},t8=function(a){return Ia.is(a,"ol,ul")},s8=function(a){a=A.children(a);return q8.refine(a,t8)},u8={read:function(a){return wu(a,1)}},v8=function(a){a=a.elementsTransformed();z(a,function(a){v.transfer(a.original(),a.replaced(),
  ["text-align"]);m.transfer(a.original(),a.replaced(),["dir"])})},cI=function(a,b){return qa(b,function(b){return N.eq(b.original(),a)}).map(function(a){return a.replaced()}).getOr(a)},dI=function(a,b,c,d,e,f){if(0===a.selected().length)return g.none();var h=a.writer(),l=a.outerlist();a=a.selected();var k=u8.read(l);f=f(a);f=o8.operate(f,k,a);h=h(f);v8(h);P.before(l,h.elements());F.remove(l);l=h.elementsTransformed();b=cI(b,l);d=cI(d,l);return g.some(ni.block({start:b,soffset:c,finish:d,foffset:e,
  all:h.elements()}))},eI={execute:function(a,b,c,d,e,f){return dI(a,b,c,d,e,k(f))},executeUsing:dI},w8=function(a,b,c,d,e,f,h){return pi.applyOn(a,VH,b,c,d,e,function(a){z(a,function(a){h.change(a,f)});return a})},fI=function(a,b){return function(c,d,e,f,h,g){var l=oo.isRootOrCell(c);return vu.context(d,f,c).fold(function(){return w8(l,d,e,f,h,a,g)},function(a){return eI.execute(a,d,e,f,h,b)})}},Xq={indent:function(a,b,c,d,e,f){return fI(1,vu.indent)(a,b,c,d,e,f)},outdent:function(a,b,c,d,e,f){return fI(-1,
  vu.outdent)(a,b,c,d,e,f)}},x8={isRootContainer:function(a){return function(b){return a(b)||U(["td","th","caption"],D.name(b))}},extract:function(a){return Bc.cata(a,function(a){return[a]},function(a){return[a]},function(a,c){return U(["ol","ul"],D.name(a))?[a]:ia(c,Bc.toTarget)},function(a){return[a]})},isCapable:function(a){return pa.isBlock(a)},canUse:k(!1),quasi:function(a){return g.some(Gk.nu(nb()))},ascend:ca},xu=function(a){return Vd.is(a)?L.descendant(a,"blockquote"):L.closest(a,"blockquote")},
  gI=function(a){return nf.sharedOne(xu,a)},y8=function(a,b,c,d,e){return pi.applyOn(a,x8,b,c,d,e,function(a){var b=p.fromTag("blockquote");0<a.length&&(y.before(a[0],b),P.append(b,a),b=Y.descendants(b,"blockquote"),E(b,F.unwrap));return a})},yu={toggle:function(a,b,c,d,e){return(N.eq(b,d)?xu(b):gI([b,d])).fold(function(){return y8(a,b,c,d,e)},function(a){F.unwrap(a);return g.some(ni.block({start:b,soffset:c,finish:d,foffset:e,all:[]}))})},queryPoint:xu,queryAll:gI},hI=function(a,b,c,d){var e=a.content(),
  f=a.undo();$b.cata(a.selections().get(),t,ho.multiple(e,a.undo(),d),ho.single(e,f,d,b,c))},iI=function(a){return function(b){var c=0<a?Xq.indent:Xq.outdent,d=Sq(b.region()),e=b.content();hI(b,Ck,Bk,function(a,b,g,k){return c(e.isRoot,a,b,g,k,d)})}},Ao=function(a){return function(b){var c=b.content(),d=function(b,d,h,g){return a.run(c.isRoot,b,d,h,g)};$b.cata(b.selections().get(),t,io.multiple(c,b.undo(),d),io.single(c,b.undo(),d,Ck,Bk))}},Bo=function(a){return function(b){vc.detect(b.content().getSelection()).each(function(c){Pd.runTransaction(b.content(),
  b.undo(),function(){(a.query(c.image())?oh.floatnone():a).run(c.image())},b.content().toEditing)})}},ce={indent:iI(1),outdent:iI(-1),blockquote:function(a){var b=a.content();hI(a,Ck,Bk,function(a,d,e,f){return yu.toggle(b.isRoot,a,d,e,f)})},justifyLeft:Ao(le.justifyleft()),justifyCentre:Ao(le.justifycentre()),justifyRight:Ao(le.justifyright()),justifyFull:Ao(le.justifyfull()),imageNone:Bo(oh.floatnone()),imageLeft:Bo(oh.floatleft()),imageCentre:Bo(oh.floatcentre()),imageRight:Bo(oh.floatright()),
  breakQuote:function(a,b,c){C7.breakQuote(b,c).each(function(b){a.content().setRelativeSelection(b.start(),b.finish());a.content().uiChanged()})}},z8=function(a,b){return qa(a,function(a){return a.value()===b})},am={updateMenu:function(a,b,c,d,e){b.fold(a.clear,t,function(b){(xa(b)?z8(d,b):g.some(b)).each(a.select);e.each(function(c){c=c(b);a.selectElement(c)})});c.fold(a.disable,t,a.enable);b.fold(a.untick,t,function(b){b=xa(b)?b:b.value();a.tick(b)})}},zu=ta.generate([{table:["selection"]},{list:["selection"]}]),
  A8=function(a,b){return a.isRoot(b)||U(["table","ul","ol"],D.name(b))},$l={context:function(a){return a.getSelection().bind(function(b){if(b.collapsed())return L.closest(b.startContainer(),"td,th,li",u(A8,a)).map(function(a){return"li"===D.name(a)?zu.list(b):zu.table(b)});var c=hd.commonAncestorContainer(b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset());return L.closest(c,"ol,ul",a.isRoot).map(function(a){return zu.list(b)})})},cata:function(a,b,c){return a.fold(b,c)}},ri={attr:function(a,
  b,c){var d=u(m.set,a,b,c);a=u(m.remove,a,b);0<c.length?d():a()},css:function(a,b,c){var d=u(v.set,a,b,c);a=u(v.remove,a,b);0<c.length?d():a()}},Au={resolve:Lb.create("ephox-salmon").resolve},B8=Au.resolve("upload-image-in-progress"),C8="data-"+Au.resolve("image-blob"),D8="data-"+Au.resolve("image-upload"),uc={uploadInProgress:k(B8),blobId:k(C8),trackedImage:k(D8)},jI=Aa("url alt width height isLocal align".split(" "),["computedWidth","computedHeight"]),kI=function(a,b){a=m.get(a,b);return void 0!==
  a?a:""},Fm={divine:function(a){var b=v.getRaw(a,"width").getOr(""),c=v.getRaw(a,"height").getOr(""),d=v.getRaw(a,"width").getOrThunk(function(){return Ga.get(a)+"px"}),e=v.getRaw(a,"height").getOrThunk(function(){return sa.get(a)+"px"}),f=tu.divine(a);return jI({url:kI(a,"src"),alt:kI(a,"alt"),width:b,height:c,computedWidth:d,computedHeight:e,isLocal:m.has(a,uc.blobId()),align:f})},properties:jI,apply:function(a,b){m.get(a,"src")===b.url()||b.isLocal()||m.set(a,"src",b.url());ri.attr(a,"alt",b.alt());
  ri.css(a,"width",b.width());ri.css(a,"height",b.height());b.align().each(function(b){oh.runFloat(a,b)})}},E8={hasNoContent:function(a){var b=A.children(a);return D.isElement(a)&&(0===b.length||1===b.length&&"br"===D.name(b[0]))}},F8=O("alignment","quoted"),lI=function(a){return a.getSelection().fold(function(){return!1},function(a){var b=a.startContainer();a=a.endContainer();return N.eq(b,a)?yu.queryPoint(b).isSome():yu.queryAll([b,a]).isSome()})},G8=[le.justifyleft(),le.justifycentre(),le.justifyright(),
  le.justifyfull()],mI=function(a){return vc.detect(a.getSelection()).fold(function(){return a.getSelection().bind(function(a){return qa(G8,function(b){return b.query(a.startContainer(),a.endContainer())}).map(function(a){return a.name()})}).fold(Da.off,Da.on)},function(a){return Fm.divine(a.image()).align().fold(Da.off,function(a){return"center"===a?Da.on(le.justifycentre().name()):"right"===a?Da.on(le.justifyright().name()):Da.on(le.justifyleft().name())})})},Tq={read:function(a){var b=mI(a);a=lI(a)?
  Da.on({}):Da.off();return F8(b,a)},alignment:mI,inQuote:lI,atQuoteBreak:function(a){return a.getSelection().bind(function(a){var b=a.startContainer();return a.collapsed()?L.closest(b,"blockquote").bind(function(a){return E8.hasNoContent(b)?g.some({quote:k(a),element:k(b)}):g.none()}):g.none()})}},dm={multiple:function(a,b,c){return function(d,e){Pd.runTransaction(a,b,function(){z(e,c)},a.toEditing)}},single:function(a,b,c){return function(d,e){Pd.runTransaction(a,b,function(){c(e).each(function(b){a.setSelection(b.start(),
  b.soffset(),b.finish(),b.foffset())});a.backupSelection()},a.toEditing)}}},H8=nb(),bm={atStartOf:function(a,b,c){iu.atStartOf(H8,a,b,c)}},I8=vH.resolve("style-marker"),Rb={styleSpan:k(I8),overrideSpan:k("data-ephox-override"),quasiBlock:to.style},Jk=ta.generate([{none:[]},{tempIn:["selection"]},{tempOut:["selection"]},{rangedIn:["selection"]},{rangedOut:["selection"]}]),Vq={detect:function(a,b){return a.getSelection().fold(function(){return Jk.none()},function(a){var c=b(a);return Wa.isCollapsed(a.startContainer(),
  a.startOffset(),a.endContainer(),a.endOffset())?c?Jk.tempIn(a):Jk.tempOut(a):c?Jk.rangedIn(a):Jk.rangedOut(a)})}},nI=function(a,b){return p.fromTag(a,b.dom())},oI=function(a,b,c){c=p.fromTag("span",c.dom());v.set(c,a,b);return c},Uq={nu:function(a,b,c,d){return"span"===c?oI(a,b,d):nI(c,d)},nuTag:nI,nuAttr:function(a,b,c){c=p.fromTag("span",c.dom());m.set(c,a,b);return c},nuStyle:oI},pI={"font-weight":{700:"bold",400:"normal"}},qI=function(a,b){if(a===b&&""!==b&&void 0!==b)return!0;a=a.toLowerCase();
  b=b.toLowerCase().split(" ");return U(b,a)},rI=function(a,b){return void 0!==pI[a]?(a=pI[a][b],void 0!==a?a:b):b},sI=function(a,b){a=J8(a,b);return rI(b,a)},J8=function(a,b){return(D.isText(a)?A.parent(a):g.some(a)).map(function(a){return v.get(a,b)}).getOr(void 0)},uj={state:function(a,b,c){a=sI(a,b);return"text-decoration"===b?qI(c,a):c===a&&""!==a&&void 0!==a},rawState:function(a,b,c){a=rI(b,v.getRaw(a,b).getOr(void 0));return"text-decoration"===b?qI(c,a):c===a&&""!==a&&void 0!==a},value:sI},tI=
  {"text-decoration":function(a,b,c,d){var e=function(d){return Ja.closest(d,function(d){return D.isElement(d)&&(U(c,D.name(d))||v.getRaw(d,a).exists(function(a){return-1!==a.indexOf(b)}))}).toArray()};d=e(d.startContainer()).concat(e(d.endContainer()));return Xa(d,function(d){return U(c,D.name(d))?!0:v.getRaw(d,a).exists(function(a){return b===a})})}},K8={handle:function(a,b,c){return void 0!==tI[a]?g.some(tI[a]):g.none()}},uI=function(a,b){return b.getSelection().map(function(b){return a(b)}).getOr(!1)},
  Bu=function(a,b,c,d){var e=Vd.leftWith(pa.isBlock,d).getOrThunk(function(){return W.point(d.startContainer(),d.startOffset())}),f=Vd.rightWith(pa.isBlock,d).getOrThunk(function(){return W.point(d.endContainer(),d.endOffset())});return K8.handle(a,b).fold(function(){var c=uj.state(e.element(),a,b),d=uj.state(f.element(),a,b);return c||d},function(d){return d(a,b,c,Ub.hare(e.element(),e.offset(),f.element(),f.offset()))})},L8=function(a,b,c,d){return uI(u(Bu,a,b,c),d)},vI=function(a,b){return M8(a,
  b)},N8=function(a,b){return uI(u(vI,a),b)},M8=function(a,b){var c=Vd.leftWith(pa.isBlock,b).fold(b.startContainer,function(a){return a.element()});b=Vd.rightWith(pa.isBlock,b).fold(b.endContainer,function(a){return a.element()});c=Db.closest(c,a);a=Db.closest(b,a);return c||a},wI=function(a,b){return U(a,D.name(b))},O8=function(a,b){var c="["+a+"]";return L.closest(b.startContainer(),c).bind(function(d){return L.closest(b.endContainer(),c).bind(function(b){var c=m.get(d,a);b=m.get(b,a);c=c.toLowerCase();
  b=b.toLowerCase();return c===b?g.some(c):g.none()})})},Og={queriesStyle:function(a,b,c){return{queryOn:u(Bu,a,b,c),query:u(L8,a,b,c)}},queryStyleOn:Bu,queriesTag:function(a){return{queryOn:u(vI,a),query:u(N8,a)}},relatedStyle:function(a,b,c,d){(c=wI(c,d))||(c="span"===D.name(d)&&uj.state(d,a,b));return c},relatedTags:wI,queryAttrSame:function(a,b){return b.getSelection().bind(function(b){return O8(a,b)})},queryAttrIs:function(a,b,c){var d=b.toLowerCase(),e=function(b){return m.get(b,a).toLowerCase()===
  d};return L.closest(c.startContainer(),"["+a+"]").filter(e).orThunk(function(){return L.closest(c.endContainer(),"["+a+"]").filter(e)}).isSome()}},Co=ta.generate([{none:["last","mode"]},{running:["next","mode"]},{split:["boundary","last","mode"]},{finished:["element","mode"]}]),Cu=O("start","soffset","finish","foffset"),xI=function(a,b,c){c=ad.toLeaf(a,c,0);return Du(a,c.element())?Eu(a,b,c.element()).map(function(a){return W.point(a,0)}).getOr(c):c},Kk=function(a,b){return Mc.isFrame(a,b)||Mc.isBlock(a,
  b)||U(["li"],a.property().name(b))},Eu=function(a,b,c){return Ca.seekRight(a,c,function(b){return!Du(a,b)&&!Kk(a,b)},b)},Du=function(a,b){return a.property().isText(b)?a.property().parent(b).exists(function(b){return U("table tbody thead tfoot tr ul ol".split(" "),a.property().name(b))}):!1},P8=function(a,b,c,d,e){return Ca.walk(a,d,c,Ca.walkers().right()).fold(function(){return Co.none(d,Ca.sidestep)},function(b){return a.eq(b.item(),e)?Co.finished(e,b.mode()):Kk(a,b.item())?Co.split(b.item(),d,
  b.mode()):Co.running(b.item(),b.mode())})},zI=function(a,b,c,d){return Eu(a,b,c).fold(function(){return g.none()},function(e){return a.eq(e,d)?g.some(d):yI(a,c,e)?zI(a,b,e,d):Kk(a,e)?(e=xI(a,b,e),g.some(e.element())):g.some(e)})},yI=function(a,b,c){return a.property().parent(b).exists(function(b){return a.eq(b,c)})},Fu=function(a,b,c,d,e,f){return P8(a,b,c,e,f).fold(function(a,b){return[{start:d,finish:a}]},function(c,e){return Fu(a,b,e,d,c,f)},function(c,l,k){var h={start:d,finish:l};return(yI(a,
  e,c)?zI(a,b,c,f):function(){var d=xI(a,b,c);return a.eq(d.element(),c)?Ca.walk(a,c,Ca.advance,Ca.walkers().right()).map(function(a){return a.item()}):g.some(d.element())}()).fold(function(){return[h]},function(c){return a.eq(c,f)?[h].concat({start:f,finish:f}):[h].concat(Fu(a,b,Ca.advance,c,c,f))})},function(a,b){return[{start:d,finish:a}]})},Gu=function(a,b,c){if(Kk(a,b)){var d=a.property().children(b);return 0<=c&&c<d.length?Gu(a,d[c],0):c===d.length?Gu(a,d[d.length-1],0):b}return b},AI=function(a,
  b,c,d){c=Gu(a,c,d);return Du(a,c)?Eu(a,b,c).getOr(c):c},Q8=function(a,b,c,d,e,f){var h=AI(a,b,c,d),g=AI(a,b,e,f);b=Fu(a,b,Ca.sidestep,h,h,g);return E(b,function(b,h){h=a.eq(b.start,c)?d:0;if(a.eq(b.finish,e))var g=f;else g=b.finish,g=a.property().isText(g)?a.property().getText(g).length:a.property().children(g).length;return Cu(b.start,h,b.finish,g)})},BI=function(a,b,c,d,e,f){a.eq(c,e)?Kk(a,c)?(d=ad.toLeaf(a,c,d),f=ad.toLeaf(a,c,f),a=a.eq(d.element(),c)&&a.eq(f.element(),c)?[Cu(d.element(),d.offset(),
  f.element(),f.offset())]:BI(a,b,d.element(),d.offset(),f.element(),f.offset())):a=[Cu(c,d,c,f)]:a=Q8(a,b,c,d,e,f);return a},R8={collect:BI},Ef=ta.generate([{leftEdge:["element"]},{between:["before","after"]},{rightEdge:["element"]}]),S8=function(a,b,c){c=Td.split(a,b,c);var d=function(){return Ef.rightEdge(b)};return Td.position(a,c).fold(d,function(){return Ef.leftEdge(b)},Ef.between,d)},CI=function(a,b,c,d){if(a.property().isText(b))return S8(a,b,c);if(a.property().isEmptyTag(b))return d(b);a=a.property().children(b);
  b=0===c?Ef.leftEdge(b):c===a.length?Ef.rightEdge(b):0<c&&c<a.length?Ef.between(a[c-1],a[c]):Ef.rightEdge(b);return b},DI={toLeft:function(a,b,c,d){return CI(a,c,d,Ef.leftEdge).fold(function(a){return a},function(a,b){return b},function(c){return Ca.after(a,c,b).getOr(c)})},toRight:function(a,b,c,d){return CI(a,c,d,Ef.rightEdge).fold(function(c){return Ca.before(a,c,b).getOr(c)},function(a,b){return a},function(a){return a})}},T8=function(a,b,c,d){var e=a.property().children(b);b=function(b){return Va(e,
  u(a.eq,b))};c=c.bind(b).getOr(0);d=d.bind(b).getOr(e.length-1);return-1<c&&-1<d?g.some(e.slice(c,d+1)):g.none()},EI=function(a,b,c,d){return zd.breakPath(a,b,function(b){return a.property().parent(b).fold(k(!0),u(a.eq,c))},d)},FI=function(a,b,c,d){a.eq(b,d)?d=g.none():(d=EI(a,d,b,Dk.breakToRight),d=g.some(d.first()));if(a.eq(b,c))c=g.none();else{var e=EI(a,c,b,Dk.breakToLeft);0<e.splits().length&&a.insert().prepend(e.splits()[0].second(),c);c=g.some(e.second().getOr(c))}return T8(a,b,c,d)},U8=function(a,
  b,c,d,e){return eu.ancestors(a,c,d,b).shared().orThunk(function(){return zd.sharedOne(a,function(c,d){return b(d)?g.some(d):a.up().predicate(d,b)},[c,d])}).map(e)},V8=function(a,b,c,d,e){return U8(a,b,c,d,e).bind(function(b){return FI(a,b,c,d)})},GI={fracture:function(a,b,c,d,e){e=void 0!==e?e:ca;a.eq(c,d)?(b=e(c),a=a.eq(b,c)?g.some([c]):FI(a,b,c,c)):a=V8(a,b,c,d,e);return a}},HI=function(a,b,c,d,e,f,h){a.property().isText(c)&&a.eq(c,e)?(c=Td.splitByPair(a,c,d,f),a=GI.fracture(a,b,c,c,h)):(e=DI.toRight(a,
  b,e,f),c=DI.toLeft(a,b,c,d),a=GI.fracture(a,b,c,e,h));return a},II={fractures:function(a,b,c,d,e,f,h){c=R8.collect(a,b,c,d,e,f);return ia(c,function(c,d){return HI(a,b,c.start(),c.soffset(),c.finish(),c.foffset(),h).toArray()})},fracture:HI},JI=nb(),W8={fractures:function(a,b,c,d,e,f){return II.fractures(JI,a,b,c,d,e,f)},fracture:function(a,b,c,d,e,f){return II.fracture(JI,a,b,c,d,e,f)}},qh={makeTo:function(a,b,c){var d=A.owner(a).dom().createRange();d.setStart(a.dom(),b);d.setEndBefore(c.dom());
  return d},makeFrom:function(a,b,c){var d=A.owner(b).dom().createRange();d.setStartAfter(a.dom());d.setEnd(b.dom(),c);return d},leftEdge:function(a,b,c,d){return hd.after(a,b,c,d)?W.point(c,d):W.point(a,b)},rightEdge:function(a,b,c,d){return hd.after(a,b,c,d)?W.point(a,b):W.point(c,d)}},X8=function(a,b){b=cb(b).join(",");return(Ia.is(a,b)?[a]:[]).concat(Y.descendants(a,b))},KI={cleanse:function(a,b){a=X8(a,b);z(a,function(a){var c=D.name(a);(void 0!==b[c]?b[c]:t)(a)})}},Y8={onlyEphox:function(a){var b=
  ma.get(a);b=ka(b,function(a,b,e){return!Gb(a,"ephox-")});z(b,function(b){n.remove(a,b)})}},Lk=function(a){F.unwrap(a)},LI=function(a,b){v.remove(a,b);m.hasNone(a)&&Lk(a)},MI=function(a){var b={};z(a,function(a){b[a]=rh(Lk)});return b},rh=function(a){return function(b){m.has(b,"data-ignore")||a.apply(null,arguments)}},Ic={cssAndTag:function(a,b,c){a=MI(a);c=function(a){LI(a,b)};return ua(a,{span:rh(c),font:rh(c)})},tagList:MI,removeStyle:rh(LI),removeAttribute:rh(function(a,b){m.remove(a,b);m.hasNone(a)&&
  Lk(a)}),unwrap:rh(Lk),unstyle:rh(function(a){Y8.onlyEphox(a);m.remove(a,"style");m.hasNone(a)&&Lk(a)}),normal:function(a){m.remove(a,"data-ignore")},ignore:function(a){m.set(a,"data-ignore","true")}},Do=function(a,b){var c=A.children(a);z(c,function(a){Do(a,b)});b(a)},NI=function(a){return D.isElement(a)&&!pa.isEmptyTag(a)&&!pa.isFrame(a)&&0===Ha.get(a).replace(mb(),"").length},si={wipeout:Do,onEmpty:function(a){Do(a,function(a){!D.isElement(a)||pa.isFrame(a)||pa.isEmptyTag(a)||0!==Ha.get(a).length?
  NI(a)&&F.unwrap(a):F.remove(a)})},onQuasiEmpty:function(a){Do(a,function(a){NI(a)&&F.remove(a)})}},OI=function(a){return A.parent(a).fold(k([]),function(a){return pa.isBlock(a)?[a]:[a].concat(OI(a))})},Z8=function(a,b){var c=[b].concat(OI(b)),d=jd(c);return Va(d,a).map(function(a){return 0===a?d[0]:d[a-1]}).getOr(b)},$8=function(a,b){z(b,function(b){KI.cleanse(b,a);si.onQuasiEmpty(b)})},Wq={run:function(a,b,c,d){var e=Vd.left(c).getOrThunk(function(){return qh.leftEdge(c.startContainer(),c.startOffset(),
  c.endContainer(),c.endOffset())}),f=Vd.right(c).getOrThunk(function(){return qh.rightEdge(c.startContainer(),c.startOffset(),c.endContainer(),c.endOffset())}),h=u(Z8,d.matches);b=W8.fractures(b,e.element(),e.offset(),f.element(),f.offset(),h);b=ia(b,function(b){if(0<b.length){var c=d.purifiers();var e=(0,d.nu)(a);Ic.ignore(e);g.from(b[0]).bind(A.prevSibling).each(si.onQuasiEmpty);g.from(b[b.length-1]).bind(A.nextSibling).each(si.onQuasiEmpty);z(b,si.onQuasiEmpty);b=ka(b,ja.inBody);0<b.length?(y.before(b[0],
  e),P.append(e,b),$8(c,b),c=[e]):c=[]}else c=[];return c});z(b,Ic.normal);return Ub.fussyFromElements(b)}},Hu=function(a,b){return N.eq(a,b)?[]:A.parent(a).fold(function(){return[]},function(c){c=Hu(c,b);var d=A.findIndex(a).toArray();return c.concat(d)})},a9=function(a,b){return a.slice(b+1)},b9=function(a,b){return a.slice(0,b)},Iu=function(a,b,c,d){if(0===d.length)b(c);else{var e=d[0],f=d.slice(1);A.child(c,e).each(function(c){Iu(a,b,c,f)});c=A.children(c);e=a(c,e);z(e,b)}},PI={one:function(a,b){a(b)},
  across:function(a,b,c,d){c=Hu(c,b);d=Hu(d,b);b=A.children(b);var e=b.slice(0<c.length?c[0]+1:0,0<d.length?d[0]:b.length-1);z(e,a);0<c.length&&Iu(a9,a,b[c[0]],c.slice(1));0<d.length&&Iu(b9,a,b[d[0]],d.slice(1))}},Mk=nb(),ti={split:function(a,b){return Td.split(Mk,a,b)},splitByPair:function(a,b,c){return Td.splitByPair(Mk,a,b,c)},range:function(a,b,c,d){return Td.range(Mk,a,b,c,d)},subdivide:function(a,b){return Td.subdivide(Mk,a,b)},position:function(a){return Td.position(Mk,a)}},QI=function(a,b,c){var d=
  A.children(b),e=0===c,f=c===d.length,h=0<d.length;return void 0!==a.empty&&U(["br","hr","img"],D.name(b))?a.empty:void 0!==a.hasPrevious&&h&&0<c&&c<d.length?a.hasPrevious:void 0!==a.hasNext&&h&&c<d.length-1?a.hasNext:void 0!==a.rightEdge&&h&&f?a.rightEdge:void 0!==a.first&&e?a.first:a.otherwise},c9=function(a,b,c){return QI(a.before.element,b,c)(b,c)},d9=function(a,b,c){return QI(a.after.element,b,c)(b,c)},RI=function(a,b,c){c=ti.split(b,c);var d=function(a){return function(){var c=Array.prototype.slice.call(arguments,
  0);c=[b].concat(c);return a.apply(null,c)}};return ti.position(c).fold(d(a.none),d(a.start),d(a.middle),d(a.end))},e9=function(a,b,c){return RI(a.before.text,b,c)},f9=function(a,b,c){return RI(a.after.text,b,c)},Eo={prefix:function(a,b,c){return(D.isText(b)?e9:c9)(a,b,c)},postfix:function(a,b,c,d,e){b=qh.rightEdge(b,c,d,e);return(D.isText(b.element())?f9:d9)(a,b.element(),b.offset())}},Ju=function(a,b){return a.bind(function(a){return b.map(function(b){return{left:k(a),right:k(b)}})})},g9=function(a,
  b,c,d){b=ti.splitByPair(b,c,d);return Ju(a.general.insertBefore(b),a.general.insertAfter(b))},h9=function(a,b,c,d){c=A.child(b,c);var e=d<A.children(b).length?A.child(b,d):A.lastChild(b);return c.bind(function(b){return e.bind(function(c){return Ju(a.general.insertBefore(b),a.general.insertAfter(c))})})},UA={both:function(a,b,c,d,e){if(N.eq(b,d)){var f=D.isText(b)?g9:h9;return c>e?f(a,b,e,c):f(a,b,c,e)}f=qh.leftEdge(b,c,d,e);b=Eo.postfix(a,b,c,d,e);a=Eo.prefix(a,f.element(),f.offset());return Ju(a,
  b)}},Fo=O("inside","outside"),SI=function(a,b){return A.parent(b).fold(k(!0),function(b){return a(b)})},TI=function(a,b){var c=nb();a=[a].concat(c.up().all(a));var d=[b].concat(c.up().all(b));return qa(a,function(a){return Xa(d,u(N.eq,a))})},UI=function(a){return Fo(a.second(),g.some(a.first()))},VI=function(a){return Fo(g.some(a.first()),a.second())},WI=function(a){return Fo(g.some(a),g.none())},Ku=function(a,b,c){c=u(SI,c);c=c(a)?a:Ja.ancestor(a,c).getOr(a);return N.eq(a,c)?WI(a):XI(a,b,c)},XI=
  function(a,b,c){a=no.breakPath(a,u(N.eq,c));return b(a)},i9={bridge:function(a,b,c){var d=Ku(a,UI,c),e=Ku(b,VI,c);return d.inside().bind(function(a){return e.inside().bind(function(b){return TI(a,b).map(function(c){return{common:k(c),left:k(a),right:k(b),wipeout:function(){d.outside().each(si.onEmpty);e.outside().each(si.onEmpty)}}})})})},edge:Fo,isSplit:SI,getCommon:TI,onLeft:UI,onRight:VI,onInside:WI,splitFrom:Ku,breaker:XI},j9=O("start","soffset","finish","foffset"),Go=k(!1),Lu=function(a,b){return pa.isBlock(b)||
  pa.isContainer(b)||a(b)},YI=function(a,b){return A.parents(b,u(Lu,a))},ZI=function(a,b,c){return D.isElement(c)&&!b(c)?(a=YI(a,c),!Xa(a,b)):!1},$I=function(a,b){return function(c){return Lu(a,c)||ZI(a,b,c)}},k9=function(a,b,c,d,e,f){var h=Wa.isCollapsed(b,c,d,e);b=kb.toLeaf(b,c);d=kb.toLeaf(d,e);var g=Wh.extractTo(b.element(),b.offset(),f,Go),k=Wh.extractTo(d.element(),d.offset(),f,Go),m=function(b){return h||b.offset()!==wa.getEnd(b.element())?b:wc.after(b.element(),a).map(function(a){return W.point(a,
  0)}).getOr(b)},w=function(b){return h||0!==b.offset()?b:wc.before(b.element(),a).map(function(a){return W.point(a,wa.getEnd(a))}).getOr(b)};return function(){return Wh.find(g.element(),g.offset(),Go).map(m).bind(function(a){return Wh.find(k.element(),k.offset(),Go).map(w).map(function(b){return j9(a.element(),a.offset(),b.element(),b.offset())})})}},l9={applyTo:function(a,b,c,d,e,f,h){var g=$I(a,h),k=k9(a,c,d,e,f,g);a=MU(mb(),mb());return UA.both(a,c,d,e,f).bind(function(a){return i9.bridge(a.left().element(),
  a.right().element(),g).bind(function(c){b(c.common(),c.left(),c.right());a.left().cleanup();a.right().cleanup();c.wipeout();return k()})})},blockRoot:Lu,pathToTop:YI,isEnclosingInline:ZI,isStopper:$I},aJ=function(a,b,c,d){var e=function(a){KI.cleanse(a,b)};return l9.applyTo(a,function(a,b,c,d){if(N.eq(b,c))PI.one(e,b);else PI.across(e,a,b,c)},c.startContainer(),c.startOffset(),c.endContainer(),c.endOffset(),d)},de={doRemoveAll:function(a,b,c){return aJ(a,b,c,Jb)},doRemoveUpto:aJ,allRules:{b:Ic.unwrap,
  strong:Ic.unwrap,i:Ic.unwrap,em:Ic.unwrap,u:Ic.unwrap,strike:Ic.unwrap,del:Ic.unwrap,s:Ic.unwrap,sup:Ic.unwrap,sub:Ic.unwrap,small:t,span:Ic.unstyle,font:Ic.unstyle}},m9=function(a,b,c){return{groups:0<a.current.length?a.groups.concat({parent:a.parent,children:a.current}):a.groups,current:[c],parent:b}},n9=function(a,b,c){return{groups:a.groups,current:a.current.concat([c]),parent:b}},o9=function(a,b,c){return g.from(b.current[b.current.length-1]).bind(a.query().nextSibling).bind(function(b){return a.eq(b,
  c)?g.some(n9):g.none()}).getOr(m9)},p9={textnodes:function(a,b){b=hb(b,function(b,d){return a.property().parent(d).fold(function(){return b},function(c){return o9(a,b,d)(b,c,d)})},{groups:[],current:[],parent:null});return 0<b.current.length?b.groups.concat({parent:b.parent,children:b.current}):b.groups}},cJ=function(a,b,c,d,e,f){b=Td.range(a,b,c,d,e);return bJ(a,b,f)},bJ=function(a,b,c){if(0===b.length)return b;b=ka(b,function(b){return a.property().isText(b)&&0<a.property().getText(b).length});
  return E(b,function(b){var d=c();a.insert().before(b,d.element());d.wrap(b);return d.element()})},q9=function(a,b){return g.from(b[0]).map(function(c){var d=ig.toLower(a,b[b.length-1]);return W.points(W.point(c,0),W.point(d.element(),d.offset()))})},Nk={wrapWith:cJ,wrapper:bJ,leaves:function(a,b,c,d,e,f){b=ig.toLeaf(a,b,c);d=ig.toLeaf(a,d,e);f=cJ(a,b.element(),b.offset(),d.element(),d.offset(),f);return q9(a,f)},reuse:function(a,b,c,d,e,f,h){b=ig.toLeaf(a,b,c);d=ig.toLeaf(a,d,e);d=Td.range(a,b.element(),
  b.offset(),d.element(),d.offset());d=p9.textnodes(a,d);var g=function(a){return a.parent},k=function(b){var c=h();a.insert().before(b.children[0],c.element());z(b.children,c.wrap);return c.element()};return E(d,function(b){return(a.property().children(b.parent).length===b.children.length&&f(b.parent)?g:k)(b)})}},s9=function(a,b,c,d,e,f){a=r9(a,b,c,d,e,f);b=a.cursor();b=W.points(W.point(b.element(),b.offset()),W.point(b.element(),b.offset()));return g.some({range:k(b),temporary:a.temporary,wrappers:a.wrappers})},
  t9=function(a,b,c,d,e){d=b.dom().ownerDocument;var f=a.create().nu("span",d);d=a.create().text(mb(),d);a.insert().append(f,d);(a.property().isEmptyTag(b)?a.property().parent(b):g.some(b)).each(function(b){iu.atStartOf(a,b,c,f)});return{cursor:k(W.point(d,1)),wrappers:k([f]),temporary:k(!0)}},r9=function(a,b,c,d,e,f){return a.property().parent(b).bind(function(d){var e=W.point(b,c),h;if(h=dJ(a,f,d)&&1===a.property().children(d).length)h=a.property().isText(b)&&a.property().getText(b)===mb();return h?
  g.some({cursor:k(e),temporary:k(!1),wrappers:k([d])}):g.none()}).getOrThunk(function(){return t9(a,b,c,d,e)})},dJ=function(a,b,c){return"span"===a.property().name(c)&&!1===b(c)},u9=function(a,b,c,d,e,f){var h=b.dom().ownerDocument,l=Nk.reuse(a,b,c,d,e,u(dJ,a,f),function(){return Ry(a,a.create().nu("span",h))});return g.from(l[l.length-1]).map(function(b){var c=a.property().children(b).length;b=W.points(W.point(l[0],0),W.point(b,c));return{wrappers:k(l),temporary:k(!1),range:k(b)}})},v9={spans:function(a,
  b,c,d,e,f){f=void 0!==f?f:k(!1);return(a.eq(b,d)&&c===e?s9:u9)(a,b,c,d,e,f)}},ui={nu:function(a,b){return Ry(a,b)},wrapWith:function(a,b,c,d,e,f){return Nk.wrapWith(a,b,c,d,e,f)},wrapper:function(a,b,c){return Nk.wrapper(a,b,c)},leaves:function(a,b,c,d,e,f){return Nk.leaves(a,b,c,d,e,f)},reuse:function(a,b,c,d,e,f,h){return Nk.reuse(a,b,c,d,e,f,h)},spans:function(a,b,c,d,e,f){return v9.spans(a,b,c,d,e,f)}},vi=nb(),wi={nu:function(a){return ui.nu(vi,a)},wrapWith:function(a,b,c,d,e){return ui.wrapWith(vi,
  a,b,c,d,e)},wrapper:function(a,b){return ui.wrapper(vi,a,b)},leaves:function(a,b,c,d,e){return ui.leaves(vi,a,b,c,d,e)},reuse:function(a,b,c,d,e,f){return ui.reuse(vi,a,b,c,d,e,f)},spans:function(a,b,c,d,e){return ui.spans(vi,a,b,c,d,e)}},w9=function(a,b,c){a.getSelection().each(function(d){var e=Vd.left(d).getOrThunk(function(){return W.point(d.startContainer(),d.startOffset())}),f=Vd.right(d).getOrThunk(function(){return W.point(d.endContainer(),d.endOffset())});wi.spans(e.element(),e.offset(),
  f.element(),f.offset(),c).each(function(c){var d=c.temporary()?[Rb.styleSpan()]:[],e=c.range();z(c.wrappers(),function(a){ma.add(a,d);b(a)});c=e.begin();e=e.end();a.setSelection(c.element(),c.offset(),e.element(),e.offset())})})},eJ=function(a,b,c,d){b(a);w9(a,d,c)},gf={style:function(a,b,c,d){return eJ(a,c,d,function(a){v.setAll(a,b)})},generic:eJ},fJ=cm("bold","strong",["strong","b"],"font-weight","bold","normal"),gJ=cm("italic","em",["em","i"],"font-style","italic","normal"),hJ=cm("underline",
  "span",["u"],"text-decoration","underline","none"),iJ=cm("strikethrough","span",["s","strike","del"],"text-decoration","line-through","none"),jJ=function(a,b){var c=function(a,c){return Uq.nuAttr(b,a,c)},d=function(a){return"span"===D.name(a)&&m.has(a,b)},e={span:function(a){Ic.removeAttribute(a,b)}},f=function(a,c){return Og.queryAttrIs(b,a,c)},h=function(a,c){gf.generic(c,t,void 0,function(c){n.add(c,Rb.styleSpan());m.set(c,b,a)});return g.none()};return{run:function(a,q,m){return Vq.detect(q,u(f,
  m)).fold(function(){return g.none()},function(a){var c=["[",b,'="',m,'"]'].join("");L.closest(a.startContainer(),c).each(F.unwrap);return g.none()},function(a){return h(m,q)},function(b){return de.doRemoveAll(a,e,b)},function(b){return Wq.run(q.doc(),a,b,{nu:u(c,m),matches:d,purifiers:k(e)})})},queryValue:function(a){return Og.queryAttrSame(b,a)},name:k(a)}}("language","lang"),kJ=Qy("superscript","sup",["sup","sub"],{"font-size":"smaller","vertical-align":"super"}),lJ=Qy("subscript","sub",["sub",
  "sup"],{"font-size":"smaller","vertical-align":"sub"}),mJ={bold:fJ,italic:gJ,underline:hJ,strikethrough:iJ,language:jJ,superscript:kJ,subscript:lJ},bd={bold:k(fJ),italic:k(gJ),underline:k(hJ),strikethrough:k(iJ),language:k(jJ),superscript:k(kJ),subscript:k(lJ),search:function(a){return void 0!==mJ[a]?g.some(mJ[a]):g.none()}},xi=function(a,b){return a.query(b)},Yg={bold:u(xi,bd.bold()),italic:u(xi,bd.italic()),underline:u(xi,bd.underline()),strikethrough:u(xi,bd.strikethrough()),superscript:u(xi,bd.superscript()),
  subscript:u(xi,bd.subscript()),language:u(function(a,b){return a.queryValue(b)},bd.language())},x9=O("bold","italic","underline","strikethrough","superscript","subscript"),yi=function(a,b){return a.on(function(a){return b(a)?Da.on(!0):Da.off()}).getOrThunk(Da.off)},OU={read:function(a){return x9(yi(a,Yg.bold),yi(a,Yg.italic),yi(a,Yg.underline),yi(a,Yg.strikethrough),yi(a,Yg.superscript),yi(a,Yg.subscript))}},Ho=O("startContainer","startOffset","endContainer","endOffset"),Io=O("item","start","finish",
  "text"),Jo=O("items","abort"),nJ=function(a,b){a=a.property().getText(b);return Io(b,0,a.length,a)},Mu=function(a,b,c){return Jo([],!0)},y9=function(a,b,c){return Jo([],!1)},z9=function(a,b,c){var d=a.property().getText(b);return c(d).fold(function(){return Jo([Io(b,0,d.length,d)],!1)},function(a){a=a[0]===a[1]?[]:[Io(b,a[0],a[1],d.substring(a[0],a[1]))];return Jo(a,!0)})},Ff={detail:nJ,fromItem:function(a,b){return a.property().isText(b)?nJ(a,b):Io(b,0,0,"")},decide:function(a,b,c,d){return(a.property().isBoundary(b)?
  Mu:a.property().isEmptyTag(b)?Mu:d(a,b)?Mu:a.property().isText(b)?z9:y9)(a,b,c)}},oJ={all:function(a,b){for(var c=b.term(),d=[],e=c.exec(a);e;){var f=e.index+b.prefix(e);e=e[0].length-b.prefix(e)-b.suffix(e);d.push({start:k(f),finish:k(f+e)});c.lastIndex=f+e;e=c.exec(a)}return d}},A9=function(a){a=Array.prototype.slice.call(a,0);a.sort(function(a,c){return a.start()<c.start()?-1:c.start()<a.start()?1:0});return a},B9={search:function(a,b){b=ia(b,function(b){var c=oJ.all(a,b.pattern());return E(c,
  function(a){return ua(b,{start:a.start,finish:a.finish})})});return A9(b)}},Ko={findall:function(a,b){return oJ.all(a,b)},findmany:function(a,b){return B9.search(a,b)}},C9=new RegExp(Cb.wordbreak()+"+","g"),pJ=k(0),qJ=function(a){a=Ko.findall(a,Cb.custom(Cb.wordbreak(),pJ,pJ,g.none()));return g.from(a[a.length-1]).map(function(a){return a.start()})},Nu=function(a){a=a.search(C9);return-1<a?g.some(a):g.none()},Ok={firstWord:function(a){return Nu(a).map(function(b){return a.substring(0,b+1)})},lastWord:function(a){return qJ(a).map(function(b){return a.substring(b)})},
  leftBreak:qJ,rightBreak:Nu,hasBreak:function(a){return Nu(a).isSome()}},rJ=Ca.walkers(),sJ=rJ.left(),tJ=rJ.right(),D9={sibling:sJ.sibling,first:sJ.first,slicer:function(a){return Ok.leftBreak(a).map(function(b){return[b+1,a.length]})}},E9={sibling:tJ.sibling,first:tJ.first,slicer:function(a){return Ok.rightBreak(a).map(function(a){return[0,a]})}},Ou=function(a,b,c,d,e){b=Ca.walk(a,b,c,d).map(function(b){var c=Ff.decide(a,b.item(),d.slicer,e);b=c.abort()?[]:Ou(a,b.item(),b.mode(),d,e);return c.items().concat(b)}).getOr([]);
  return ka(b,function(a){return 0<a.text().trim().length})},Pk={creepLeft:function(a,b,c){return Ou(a,b,Ca.sidestep,D9,c)},creepRight:function(a,b,c){return Ou(a,b,Ca.sidestep,E9,c)},flatten:function(a,b){return a.property().isText(b)?[Ff.detail(a,b)]:E(a.down().predicate(b,a.property().isText),function(b){return Ff.detail(a,b)})},isEmpty:function(a,b){return a.property().isText(b)?!1:0===a.down().predicate(b,a.property().isText).length}},Pu=function(a,b){return a.up().closest(b,"[lang]",k(!1)).map(function(b){return a.attrs().get(b,
  "lang")})},zi={nu:function(a){var b=[],c=[],d=[],e=a,f=function(a){a.each(function(a){b.push(a)})},h=function(a){a.each(function(a){b=b.slice(0,b.length-1)})},l=function(){0<d.length&&c.push({lang:k(e),details:k(d)})},q=function(a){l();d=[];e=a},m=function(c){return c.or(g.from(b[b.length-1])).getOr(a)};return{openInline:function(a,b){b=m(a);b!==e&&q(b);f(a)},closeInline:function(a,b){h(a)},addDetail:function(a){var b=m(g.none());b!==e&&q(b);d.push(a)},addEmpty:function(a){a=m(g.none());q(a)},openBoundary:function(a,
  b){f(a);a=m(a);q(a)},closeBoundary:function(a,b){h(a);a=m(a);q(a)},done:function(){l();return c.slice(0)}}},calculate:Pu,softBounder:function(a){return function(b,c){b=Pu(b,c);return!a.equals(b)}},strictBounder:function(a,b){return function(c,d){c=Pu(c,d).getOr(a);return b!==c}}},uJ=function(a,b,c,d){var e=Pk.creepLeft(a,b,d);d=Pk.creepRight(a,c,d);b=0<e.length?e[e.length-1]:Ff.fromItem(a,b);a=0<d.length?d[d.length-1]:Ff.fromItem(a,c);e=0===e.length&&0===d.length;return{left:k(b),right:k(a),isEmpty:k(e)}},
  Qk={byBoundary:function(a,b){var c=k(!1);c=uJ(a,b,b,c);a=c.isEmpty()&&Pk.isEmpty(a,b);return{left:c.left,right:c.right,isEmpty:k(a)}},getEdges:uJ,byLanguage:function(a,b){var c=zi.calculate(a,b),d=zi.softBounder(c),e=Pk.creepLeft(a,b,d);d=Pk.creepRight(a,b,d);a=a.property().isText(b)?[Ff.detail(a,b)]:[];b=jd(e).concat(a).concat(d);return{all:k(b),left:k(e),middle:k(a),right:k(d),lang:k(c)}}},Qu=function(a,b,c,d){d=a.property().getText(b);var e=ka(d.substring(0,c),function(a){return a!==mb()}).length,
  f=ka(d.substring(c,d.length),function(a){return a===mb()}).length;a=Qk.byLanguage(a,b);b=0===e&&0===a.left().length;c=c+f===d.length&&0===a.right().length;return{all:a.all,leftEdge:k(b),rightEdge:k(c),text:k(d)}},Lo={before:function(a,b,c,d,e){a=Qu(a,b,c,e);a.rightEdge()?b=g.none():(a=a.all(),0===a.length?b=g.none():(a=a[a.length-1],b=g.some(Ho(b,d,a.item(),a.finish()))));return b},after:function(a,b,c,d,e){a=Qu(a,b,c,e);a.leftEdge()?b=g.none():(a=a.all(),0===a.length?b=g.none():(a=a[0],b=g.some(Ho(a.item(),
  a.start(),b,d))));return b},both:function(a,b,c,d,e,f){return d===e?g.none():g.some(Ho(b,d,b,e))},neither:function(a,b,c,d){a=Qu(a,b,c,d);a.leftEdge()||a.rightEdge()?a=g.none():(b=a.all(),0===b.length?a=g.none():(a=b[0],b=b[b.length-1],a=g.some(Ho(a.item(),a.start(),b.item(),b.finish()))));return a}},vJ=O("before","after"),F9={around:function(a,b){var c=a.substring(0,b),d=Ok.leftBreak(c).map(function(a){return a+1});a=a.substring(b);a=Ok.rightBreak(a).map(function(a){return b+a});var e=vJ(d,a),f=
  vJ(g.some(b),g.some(b));return a.bind(function(a){return b===a?g.some(f):g.none()}).getOrThunk(function(){return d.bind(function(a){return b===a?g.some(f):g.none()}).getOr(e)})}},G9={word:function(a,b,c,d){if(!a.property().isText(b))return g.none();var e=a.property().getText(b),f=F9.around(e,c);return f.before().fold(function(){return f.after().fold(function(){return Lo.neither(a,b,c,d)},function(e){return Lo.after(a,b,c,e,d)})},function(e){return f.after().fold(function(){return Lo.before(a,b,c,
  e,d)},function(f){return Lo.both(a,b,c,e,f,d)})})}},H9={word:function(a,b,c,d){return G9.word(a,b,c,d)}},I9=nb(),J9={word:function(a,b,c){return H9.word(I9,a,b,c)}},wJ=function(a,b,c){J9.word(b,c,k(!1)).each(function(b){a.setSelection(b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset())})},Ad={expand:function(a){a.getSelection().each(function(b){Wa.isCollapsed(b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset())&&wJ(a,b.startContainer(),b.startOffset())})},expandWord:wJ},
  yJ=function(a,b){var c=Ub.fussy(b,0,b,A.children(b).length-1);xJ(a,b,c)},Ru=function(a){a=A.children(a);return 1===a.length&&D.isText(a[0])&&Ya.get(a[0])===mb()},zJ=function(a,b){return L.closest(a,"."+Rb.styleSpan()).bind(function(a){return L.closest(b,"."+Rb.styleSpan()).filter(function(b){return N.eq(a,b)})})},xJ=function(a,b,c){n.remove(b,Rb.styleSpan());return m.has(b,Rb.overrideSpan())?AJ(a,b,c):g.some(c)},AJ=function(a,b,c){return K9(b).bind(function(d){if(d.isStyled(b)){d=d.nu;var e=A.owner(b);
  e=d(e);y.before(b,e);P.append(e,A.children(b));F.remove(b);d=N.eq(b,c.start())?e:c.start();e=N.eq(b,c.finish())?e:c.finish();d=g.some(Ub.fussy(d,c.soffset(),e,c.foffset()))}else d=L9(a,b,d.purifiers(),c,d.matches);return d})},K9=function(a){a=m.get(a,Rb.overrideSpan());return bd.search(a).map(function(a){return a.deferred()})},L9=function(a,b,c,d,e){b=A.owner(b);var f=Ub.fromFussy(d);de.doRemoveUpto(a,c,f,e);a="["+Rb.overrideSpan()+"]";return Ia.one(a,b).bind(function(a){F.unwrap(a);return ja.inBody(d.start())&&
  ja.inBody(d.finish())?g.some(d):g.none()})},ng={clean:function(a,b){Ru(b)?F.unwrap(b):yJ(a,b)},cleanNonEmpty:yJ,isTransient:Ru,withinTransient:zJ,handleOverride:AJ,apply:function(a,b,c,d,e){var f=Ub.fussy(b,c,d,e);return zJ(b,d).bind(function(b){if(Ru(b)){var c=A.children(b);c=N.eq(b,f.start())?Ub.fussy(c[0],0,c[0],wa.getEnd(c[0])):f;F.unwrap(b);b=g.some(c)}else b=xJ(a,b,f);return b})}},Mo=function(a,b){return a.action().run(a.isRoot(),a.environment())},og=function(a,b){var c=a.temp();ng.handleOverride(a.isRoot(),
  c,Ub.fussy(c,0,c,wa.getEnd(c)));return g.some(b)},M9=function(a,b){y.after(a.temp(),a.cursor());return g.some(b)},BJ=function(a,b){y.before(a.temp(),a.cursor());return g.some(b)},Su=function(a,b){var c=a.original();bm.atStartOf(c.startContainer(),c.startOffset(),a.cursor());return g.some(b)},CJ=function(a,b){var c=a.action().deferred().isStyled(a.temp()),d=a.cursor(),e=g.some(Ub.fussy(d,1,d,1));c?a=e:(a.environment().setSelection(d,0,d,0),a=Mo(a,b));return a},N9=function(a,b){b=a.cursor();var c=a.action().deferred();
  de.doRemoveUpto(a.isRoot(),c.purifiers(),Ub.hare(b,0,b,1),c.matches);return g.some(Ub.fussy(b,1,b,1))},Tu=function(a,b){var c=a.cursor();a.environment().setSelection(c,0,c,1);Mo(a,b);return g.some(Ub.fussy(c,1,c,1))},DJ=function(a,b){b=a.environment();a=a.original();b.setSelection(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset());Ad.expand(b);return b.getSelection().map(Ub.fromHare)},O9=function(a,b){var c=a.action().deferred();return de.doRemoveUpto(a.isRoot(),c.purifiers(),Ub.fromFussy(b),
  c.matches)},P9=function(a,b){a.action().deferred().isStyled(a.temp())?a=g.some(b):(a.environment().setSelection(b.start(),b.soffset(),b.finish(),b.foffset()),a=Mo(a,b));return a},Q9=function(a,b){a=a.temp();b=A.children(a);F.unwrap(a);return 0===b.length?g.none():g.some(Ub.fussy(b[0],0,b[b.length-1],wa.getEnd(b[b.length-1])))},R9=O("environment","isRoot","cursor","temp","action","original"),S9=function(a,b){return kc.last(a).fold(k(!0),function(a){return N.eq(a,b.startContainer())&&wa.getEnd(a)===
  b.startOffset()})},T9=function(a,b){return kc.first(a).fold(k(!0),function(a){return N.eq(a,b.startContainer())&&0===b.startOffset()})},U9=function(a,b,c,d,e){var f=m.get(d,Rb.overrideSpan()),h=e.collapsed(),l=p.fromText(mb()),k=S9(d,e),C=T9(d,e);f=a.name()===f;var w=R9(c,b,l,d,a,e);a=f&&ng.isTransient(d)?[Q9]:h&&f&&k?[M9,og,CJ]:h&&f&&C?[BJ,og,CJ]:h&&f?[Su,og,N9]:h&&k?[Su,og,Tu]:h&&C?[BJ,og,Tu]:h?[Su,og,Tu]:f?[og,DJ,O9,P9]:[og,DJ,Mo];return hb(a,function(a,b){return a.bind(function(a){return b(w,
  a)})},g.some(Ub.fromHare(e)))},Ai=function(a,b,c){Ad.expand(c);var d=c.getSelection().bind(function(d){return ng.withinTransient(d.startContainer(),d.endContainer()).filter(function(a){return m.has(a,Rb.overrideSpan())}).fold(function(){return a.run(b,c)},function(e){return U9(a,b,c,e,d)})});return ni.inlineFrom(d)},qd={bold:u(Ai,bd.bold()),italic:u(Ai,bd.italic()),underline:u(Ai,bd.underline()),strikethrough:u(Ai,bd.strikethrough()),superscript:u(Ai,bd.superscript()),subscript:u(Ai,bd.subscript()),
  removeformat:function(a,b){Ad.expand(b);b=b.getSelection().bind(function(b){return de.doRemoveAll(a,de.allRules,b)});return ni.inlineFrom(b)},language:u(function(a,b,c,d){c.getSelection().each(function(a){ng.apply(b,a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset()).each(function(a){c.setSelection(a.start(),a.soffset(),a.finish(),a.foffset())})});Ad.expand(c);a=a.run(b,c,d);return ni.inlineFrom(a)},bd.language()),cleanup:ng.clean,cleanupNonEmpty:ng.cleanNonEmpty,isTransient:ng.isTransient,
  withinTransient:ng.withinTransient},No={multiple:function(a,b,c,d){return function(e,f){Pd.runTransaction(a,b,function(){z(f,c)},d)}},single:function(a,b,c,d){return function(e,f){Pd.runTransaction(a,b,function(){c(f)},d)}}},EJ=function(a,b,c){c=a.create().nu(c);var d=a.property().children(b);a.insert().append(b,c);a.insert().appendAll(c,d);return c},FJ=function(a,b,c){c=a.create().nu(c);var d=a.property().children(b);a.attrs().copyTo(b,c);a.insert().before(b,c);a.insert().appendAll(c,d);a.remove().remove(b);
  return c},Vy={blockTransform:function(a,b,c){return(Mc.isFormatting(a,b)?FJ:EJ)(a,b,c)},nest:EJ,replace:FJ},PU={tags:k("address article aside audio blockquote canvas dd div dl fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 header hgroup hr li noscript ol output p pre section table tbody td tfoot th thead tr ul video".split(" "))},V9=nb(),W9=Sy(V9),X9={div:!0},GJ={query:function(a,b,c){return W9.query(a,b,c)},apply:function(a,b,c,d,e,f){return pi.applyOn(a,VH,b,c,d,e,function(b){return E(b,
  function(b){if(!X9[f]){var c=Ub.hareFromElement(b);de.doRemoveAll(a,de.allRules,c)}return Vy.blockTransform(nb(),b,f)})})}},Bi={background:function(a,b,c){gf.style(a,{"background-color":b},Ad.expand,c)},addClass:function(a,b,c){gf.generic(a,Ad.expand,c,function(a){n.add(a,b)})},setClass:function(a,b,c){gf.generic(a,Ad.expand,c,function(a){m.set(a,"class",b)})},foreground:function(a,b,c){gf.style(a,{color:b},Ad.expand,c)},addAttribute:function(a){return function(b,c,d){gf.generic(b,Ad.expand,d,function(b){m.set(b,
  a,c)})}},face:function(a,b,c){gf.style(a,{"font-family":b},Ad.expand,c)},size:function(a,b,c){gf.style(a,{"font-size":b},Ad.expand,c)}},HJ=function(a,b,c,d,e){b=function(b,d,e,f){return a(c.isRoot,b,d,e,f)};var f=ho.multiple(c,d,b),h=ho.single(c,d,b,Ck,Bk);return $b.cata(e.get(),g.none,function(a,b){return g.some(f(a,b))},function(a,b){return g.some(h(a,b))})},Ih={transform:function(a,b,c,d,e){return HJ(function(a,b,c,d,g){return GJ.apply(a,b,c,d,g,e)},a,b,c,d)},setClass:function(a,b,c,d,e,f){var h=
  function(a){L.closest(a,e).each(function(a){Pd.runTransaction(b,c,function(){m.set(a,"class",f)},b.toEditing)})};$b.cata(d.get(),t,function(a,b){z(a,h)},function(a,b){h(a.startContainer())})},inline:function(a,b,c,d,e){a=function(a){Bi.setClass(a,e,se.isAnnotation)};$b.cata(d.get(),t,No.multiple(b,c,a,b.toEditing),No.single(b,c,a,b.toEditing))},list:function(a,b,c,d,e){return HJ(a,b,c,d,e)}},IJ=O("label","items"),Ci=function(a,b){return 0<b.length?[IJ(g.some(x.key(a)),b)]:[]},Xy={groups:function(a,
  b,c){var d=a.divisions(),e=E(d.blocks().concat(d.classblocks()),a.toCandidate),f=E(d.inlines(),a.toCandidate);a=E(d.objects(),a.toCandidate);a=Eb(a,function(a,d){if(Db.closest(b,d.base(),c)){var e=d.base();a=U(["a"],e)?ua(a,{link:a.link.concat([d])}):U(["embed","img","object"],e)?ua(a,{media:a.media.concat([d])}):U(["hr"],e)?ua(a,{line:a.line.concat([d])}):U(["li","ol","ul"],e)?ua(a,{list:a.list.concat([d])}):U(["table","tr","td","th"],e)?ua(a,{table:a.table.concat([d])}):a}return a},{link:[],media:[],
  line:[],list:[],table:[]});return Qb([[IJ(g.none(),e)],Ci("block.label.inline",f),Ci("block.label.link",a.link),Ci("block.label.media",a.media),Ci("block.label.line",a.line),Ci("block.label.list",a.list),Ci("block.label.table",a.table)])}},Oo=function(a,b){return{fold:b}},Pf={inline:function(a,b,c){return Oo("inline",function(d,e,f,h){return d(a,b,c)})},object:function(a,b,c,d){return Oo("object",function(e,f,h,g){return f(a,b,c,d)})},block:function(a,b,c){return Oo("block",function(d,e,f,h){return f(a,
  b,c)})},classblock:function(a,b,c,d){return Oo("classed block",function(e,f,h,g){return g(a,b,c,d)})},cata:function(a,b,c,d,e){return a.fold(b,c,d,e)}},JJ="h1 h2 h3 h4 h5 h6 div p pre".split(" "),Y9="a embed hr img li object ol table td tr ul th".split(" "),Z9=function(a){var b=a.match(/[\[\]* !#%=+>:~,\^\$]/),c=a.indexOf(".");-1<c&&null===b?(b=a.substring(0,c),a=a.substring(c+1),a=-1===a.indexOf(".")?g.some({tag:k(b),clazz:k(a)}):g.none()):a=g.none();return a},a$=function(a,b){var c=a.tag(),d=a.clazz(),
  e=U(JJ,c),f=U(Y9,c);return(e?J.value(Pf.classblock):f?J.value(Pf.object):J.error("Rule must have object tag or block tag.")).map(function(e){var f=$9(b,a);return e(c,d,f,b.style)})},b$=function(a){return a.text.getOrThunk(function(){return x.key("block."+a.name)})},c$=function(a,b){return a.text.getOrThunk(function(){return x.pkey("tag.inline.class",[b])})},$9=function(a,b){return a.text.getOrThunk(function(){var a="block."+b.tag(),d="tag."+b.tag();a=(x.has(a)?x.translate(a):x.has(d)?x.translate(d):
  b.tag())+" ("+b.clazz()+")";return x.raw(a)})},RU={decipher:function(a){return Z9(a.name).fold(function(){return U(JJ,a.name)?J.value(Pf.block(a.name,b$(a),a.style)):J.error("Invalid style name: "+a.name)},function(b){return 0<b.tag().length?a$(b,a):J.value(Pf.inline(b.clazz(),c$(a,b.clazz()),a.style))})}},QU=function(a,b){return ia(b,function(b){if(Xa(bs(b.cssRules),function(a){return/ephox-candy-mountain/i.test(a.selectorText)}))return[];var c={};z(bs(b.cssRules),function(b){if(b.type===CSSRule.STYLE_RULE){var d=
  b.selectorText,e=d.match(/(.*)\[ephox-data\](.*)/i);null===e?(c.hasOwnProperty(d)||(c[d]={}),c[d].rule=d,c[d].visibility=a):(d=e[1]+e[2],c.hasOwnProperty(d)||(c[d]={}),e=b.style.visibility,"hidden"===e?c[d].visibility=!1:"visible"===e&&(c[d].visibility=!0),b=b.style.content,xf.isEmpty(b)||(c[d].text=b.replace(/["']/g,"")))}});return ka(Ze(c),function(a){return a.hasOwnProperty("rule")&&!1!==a.visibility})})},d$={text:function(a){var b=x.get(a.textkey()),c=x.cata(a.textkey(),k(!0),k(!1),k(!1));a=c&&
  void 0===b?a.value():b;return{text:k(a),unknown:k(c)}}},Wy={format:function(a){var b=p.fromText(x.get(a.textkey())),c=T.div();n.add(c,B.resolve("format-element-"+a.tag()));v.setAll(c,a.styles());a=T.div();n.add(a,B.resolve("format-element-container"));y.append(c,b);y.append(a,c);return a},face:function(a){var b=d$.text(a),c=b.text();c=Qc(c).element();v.setAll(c,{"font-family":a.value()});a=b.unknown()?[B.resolve("font-face-unknown")]:[];ma.add(c,a);return c}},UU=function(a,b){a=p.fromTag(a);S.hidden(a,
  !0);v.set(a,"list-style-type",b);b=B.resolve("list-style-content");for(var c=0;3>c;c++){var d=p.fromTag("li"),e=T.span();n.add(e,b);y.append(d,e);y.append(a,d)}return a},TU=function(a,b){b=x.translate(b);var c=p.fromText(b),d=T.span();n.add(d,B.resolve("list-style-default"));m.set(a,"data-"+B.resolve("list-style"),"default");m.set(a,"title",b);y.append(d,c);return d},em="data-"+B.resolve("list-style"),e$=ta.generate([{mine:["element"]},{other:["element"]},{paragraphs:["elements"]}]),vj=ua(e$,{cata:function(a,
  b,c,d){return a.fold(b,c,d)}}),f$=function(a,b,c){var d=D.name(a);return v.getRaw(a,"list-style-type").fold(function(){return d===b&&c.isNone()},function(a){return c.exists(function(c){return d===b&&a===c})})},XU={categorise:function(a,b,c){a=fm(a,function(a){return pa.isList(a)?!0:A.parent(a).map(function(a){return a.dom()}).getOr(!1)});return ia(a,function(a){return ob(a,pa.isList)?E(a,function(a){return f$(a,b,c)?vj.mine(a):vj.other(a)}):[vj.paragraphs(a)]})}},KJ=function(a){return Bc.cata(a,function(a){return Ud.wrap(a)},
  function(a){return[a]},function(a,c){return pa.isList(a)?[a]:ia(c,KJ)},function(a){return Ud.wrap([a])})},g$={isRootContainer:function(a){return function(b){return a(b)||pa.isContainer(b)&&"li"!==D.name(b)}},extract:KJ,isCapable:pa.isBlock,canUse:k(!1),quasi:function(){return g.some(Gk.nu(nb()))},ascend:function(a,b){return L.closest(a,"ol,ul",b).getOr(a)}},h$=function(a,b,c){var d=p.fromTag(b);c.each(function(a){v.set(d,"list-style-type",a)});return yo.list(a,d)},sh={hasSameType:function(a,b){return D.name(a)===
  b},hasSameStyle:function(a,b){var c=v.getRaw(a,"list-style-type");return b.fold(function(){return c.isNone()},function(a){return c.is(a)})},convertOr:function(a,b,c,d,e){return function(f){return d(f.list(),a)&&e(f.list(),b)?c(f):h$(f,a,b)}},topContext:function(a,b,c){return qi.context(a,b,qi.topmost,ZH,c)},context:function(a,b,c){return qi.context(a,b,qi.immediate,ZH,c)},unapply:function(a){return yo.level(a,-1*a.level())}},Rk=nb(),i$=Sy(Rk),j$=function(a){a=E(a,function(a){return L.ancestor(a,"ul,ol")});
  var b=E(a,function(a){return a.fold(function(){return"-"},function(a){return D.name(a)+"-"+v.get(a,"list-style-type")})}),c=b[0];return ob(b.slice(1),function(a){return a===c})?a[0]:g.none()},LJ=function(a,b,c){var d=WU(Rk,a,c),e=function(a,b,c,e,f,g){return pi.applyOn(a,g$,b,c,e,f,function(b){return d.apply(a,g,b)})},f=function(b,d,e){b=b.selected();return 0<b.length&&j$(b).map(function(b){return d(b,a)&&e(b,c)}).getOr(!1)};return{query:function(c){return i$.queryAll(c.startContainer(),c.endContainer(),
  ["ul","ol"],b).exists(function(b){return b===a})},queryStyle:function(a){var d=c.fold(function(){return":not([style])"},function(a){return'[style*="list-style-type: '+a+';"]'});return Rk.up().closest(a.startContainer(),"ol, ul",b).exists(function(c){return Rk.up().closest(a.endContainer(),"ol, ul",b).exists(function(a){return c.dom()===a.dom()?Rk.is(c,d):!1})})},apply:function(b,d,g,m,w,n,p){var h=p?k(!0):sh.hasSameStyle,l=function(){return e(b,d,g,m,w,n)},q=function(b,e){return eI.executeUsing(b,
  d,g,m,w,function(){return sh.convertOr(a,c,e,sh.hasSameType,h)})},C=function(){return sh.topContext(d,m,b).fold(l,function(a){return q(a,sh.unapply)})};return sh.context(d,m,b).fold(l,function(a){return f(a,sh.hasSameType,h)?C():q(a,ca)})}}},gm={unordered:u(LJ,"ul"),ordered:u(LJ,"ol")},MJ=function(a,b,c,d){return function(c){var e=d(c.content().isRoot,g.none());return{toggle:!0,value:a,textkey:x.key(b),icon:!0,tooltip:rb.get,updateGeneral:function(a){c.content().getSelection().each(function(b){(e.query(b)?
  Da.on(!0):Da.off()).fold(a.deselect,t,a.select)})},action:function(){Ih.list(function(a,b,d,f,g){return e.apply(a,b,d,f,g,Sq(c.region()))},c.region(),c.content(),c.undo(),c.selections());c.content().focus()}}}},k$=MJ("bullist","action.bullist","ul",gm.unordered),Yy={ol:MJ("numlist","action.numlist","ol",gm.ordered),ul:k$},l$=O("tag"),NJ=function(a,b){return U(["label","li","td","th","normal"],b)?Da.on(a.backup(b)):Da.off()},m$=function(a,b,c){return GJ.query(a,b.selectors(),c).fold(function(){return a.collapsed()?
  NJ(b,"normal"):Da.off()},function(a){return b.candidateByName(a).map(Da.on).getOrThunk(function(){return NJ(b,a)})})},$U={read:function(a,b){var c=a.getSelection().fold(function(){return Da.off()},function(c){return m$(c,b,a.isRoot)});return l$(c)}},ZU=aa.detect(),OJ={resolve:Lb.create("ephox-arcade").resolve},Uu="data-"+OJ.resolve("no-merge"),Vu="data-"+OJ.resolve("atomic"),pg={doNotMerge:function(a){D.isElement(a)&&m.set(a,Uu,"true")},shouldMerge:function(a){return D.isElement(a)&&!1===m.has(a,
  Uu)},setAtomic:function(a){D.isElement(a)&&m.set(a,Vu,"true")},isAtomic:function(a){return D.isElement(a)&&"true"===m.get(a,Vu)},clear:function(a){D.isElement(a)&&z([Uu,Vu],function(b){m.remove(a,b)})}},n$=function(a){var b=A.owner(a);a=Y.descendants(a,"td,th");z(a,function(a){Df.needsCursor(a).each(function(c){y.append(a,p.fromTag("br",b.dom()))})})},o$=function(a){Df.vacate(a);Df.needsCursor(a).each(function(b){F.remove(a)})},p$=function(a){("table"===D.name(a)?n$:o$)(a)},PJ=function(a,b){a=q$(a);
  b=ka(a,b);z(b,p$)},q$=function(a){var b=function(a){return[a]},c=A.prevSibling(a).map(b).getOr([]);b=A.nextSibling(a).map(b).getOr([]);return c.concat([a]).concat(b)},Di={purge:function(a){PJ(a,pa.isBlock)},purgeBy:PJ},QJ=function(a){Di.purgeBy(a,function(a){var b=pa.isBlock(a)||"li"===D.name(a)||"ol"===D.name(a)||"ul"===D.name(a);if("li"===D.name(a)){var d;if(!(d=0===Y.descendants(a,"ul,ol").length)){d=Y.descendants(a,"ul,ol,li");var e=Y.descendants(a,"*");a=cd.descendants(a,D.isText);d=d.length===
  e.length&&0===a.length}a=d}else a=!0;return b&&a})},Wu=function(a){var b=Y.descendants(a,"ol,ul,li");z([a].concat(b),QJ)},RJ=function(a){a=("li"===D.name(a)?[a]:[]).concat(Y.descendants(a,"li"));z(a,function(a){var b=A.children(a);Xa(b,function(a){return D.isText(a)?0<Ya.get(a).length:!U(["ol","ul"],D.name(a))})||v.set(a,"list-style-type","none")})},Po=function(a,b){var c=p.fromText(mb());a(b,c);return g.some({element:k(c),cleanup:function(){F.remove(c)},splits:k([])})},Ei=function(a,b){return a.map(function(a){return{element:k(a),
  cleanup:t,splits:k(b)}})},SJ=function(a,b){return Po(y.before,a)},TJ=function(a,b){return Po(y.after,a)},Xu=function(a,b){return Po(y.append,a)},Yu=function(a,b){return Po(y.prepend,a)},UJ=function(a,b){return function(c,d){return a(c,d).fold(function(){return b(c,d)},g.some)}},Zu=function(a,b,c){return Ei(g.some(b),void 0!==b&&void 0!==c?[{first:b.dom(),second:c.dom()}]:[])},VJ={before:{text:{none:g.none,start:UJ(function(a,b){return Ei(A.prevSibling(a),[])},SJ),middle:Zu,end:Zu},element:{hasPrevious:function(a,
  b){return Ei(A.child(a,b-1),[])},rightEdge:Xu,first:Yu,empty:SJ,otherwise:Yu}},after:{text:{none:g.none,start:Zu,middle:function(a,b,c){return Ei(g.some(c),void 0!==b&&void 0!==c?[{first:b.dom(),second:c.dom()}]:[])},end:UJ(function(a,b){return Ei(A.nextSibling(a),[])},TJ)},element:{hasNext:function(a,b){return Ei(A.child(a,b+1),[])},rightEdge:Xu,first:Yu,empty:TJ,otherwise:Xu}}},Qo={prefix:u(Eo.prefix,VJ),postfix:u(Eo.postfix,VJ)},r$=function(a){return!wd.descendant(a,function(a){return li.hasCursor(a,
  ["hr","img"])})},s$=function(a){var b=a.second();if(ec.isHeading(b)&&r$(b)){var c=Oc.shallowAs(b,"p");y.before(b,c);F.remove(b);b=g.some(c)}else b=g.none();b=b.getOr(a.second());return{first:a.first,second:k(b),mark:a.mark,splits:a.splits}},t$=function(a){return D.isElement(a)&&pa.isInline(a)&&0===A.children(a).length},u$=function(a){var b=p.fromText(mb());y.append(a,b);return b},WJ=function(a,b,c){return Qo.prefix(b,c).bind(function(b){var c=no.breakPath(b.element(),ec.stopAt(a));return c.second().map(function(d){return{first:k(a),
  second:k(d),mark:k(b),splits:k(c.splits().concat(b.splits()))}})})},Me={soft:function(a,b,c){var d=function(c){if(D.isText(c)){var e=Ya.get(c);e=-1===e.indexOf("\u00a0")&&0===e.trim().length}else e=!1;return e?A.nextSibling(c).forall(d):!wa.isStart(a,b)&&pa.isBlock(c)},e=p.fromTag("br");bm.atStartOf(a,b,e);A.nextSibling(e).fold(function(){return wa.getEnd(a)===b&&ec.findBlock(a,c).bind(kc.last).fold(k(!1),function(b){var c="br"===D.name(b)?e:a;return N.eq(c,b)})},d)&&y.after(e,p.fromTag("br"));return g.some({start:k(la.after(e)),
  finish:k(la.after(e))})},hard:function(a,b,c,d,e){return WJ(a,b,c).map(s$).map(function(a){z([d.getOr(a.first()),a.second()],function(b){Df.postprocess(b,a.mark().element(),e)});ec.findValidHardBreak(a.second(),e).isNone()&&gu.rootBr(a.second(),a.mark().element());var b=ko.plunge(a.second(),k(!1));b=t$(b)?u$(b):b;a.mark().cleanup();return{start:k(la.on(b,0)),finish:k(la.on(b,0))}})},rupture:WJ},XJ=function(a){return g.some({start:k(a),finish:k(a)})},v$={doubleBr:function(a){y.after(a,p.fromTag("br"));
  var b=p.fromTag("br");y.after(a,b);return XJ(la.after(b))},emptyParagraph:function(a){var b=p.fromTag("p"),c=p.fromTag("br");y.append(b,c);y.after(a,b);return XJ(la.on(c,0))}},YJ=function(a){return[a]},w$={processes:function(a){return{stopper:ec.stopAt(a),wrapper:YJ,post:t}}},y$=function(a,b,c){g.from(c[c.length-1]).each(function(a){P.append(a,x$(A.children(b)));F.empty(b)})},x$=function(a){return ka(a,function(a){return!(D.isElement(a)&&ec.isList(a)&&0===A.children(a).length)})},z$={processes:function(a){return{stopper:ec.stopAt(a),
  wrapper:YJ,post:y$}}},A$=function(a,b){F.remove(a);return b},B$=function(a,b){var c=p.fromTag("p");P.append(c,b);y.before(a,c);F.remove(a);Df.needsCursor(c).each(function(a){gu.forceAddBr(a,p.fromTag("span"))});return[c]},C$=function(a){var b=A.children(a);b=(wd.descendant(a,pa.isFormatting)?A$:B$)(a,b);z(b,function(b){D.isElement(b)&&(m.transfer(a,b,["dir"]),v.transfer(a,b,["text-align"]))});return b},D$={processes:function(a){return{stopper:ec.stopAt(a),wrapper:C$,post:t}}},E$={exit:function(a,
  b){return L.ancestor(a,"ol,ul",b).bind(function(c){var d=L.ancestor(c,"li,ol,ul",b).fold(function(){return D$.processes(c)},function(a){return"li"===D.name(a)?z$.processes(a):w$.processes(c)}),e=no.breakPath(a,d.stopper);return e.second().map(function(b){var c=e.first(),f=d.wrapper(a);P.before(b,f);d.post(c,b,f);z([c,b],Df.lists);b=ko.plunge(f[0],k(!1));b=k(la.on(b,0));return{start:b,finish:b}})})}},F$=function(a,b,c,d){return L.closest(b,"li",d).fold(function(){return Me.hard(a,b,c,g.none(),d)},
  function(a){a=ec.exitList(a)?E$.exit(a,d):Me.hard(a,b,c,g.some(a),d);return a})},$u={hard:function(a,b,c){return ec.findValidHardBreak(a,c).fold(function(){return ec.findAnchorBreak(a,c).fold(function(){return Me.soft(a,b,c)},function(d){return!0===ec.isRightEdge(d,a,b)?v$.doubleBr(d):Me.hard(d,a,b,g.none(),c)})},function(d){return F$(d,a,b,c)})},soft:Me.soft,rupture:Me.rupture},av=O("cursor","blocks"),Ro=function(a,b,c,d){return Qo.postfix(a,b,c,d).map(function(e){var f=qh.leftEdge(a,b,c,d);qh.makeTo(f.element(),
  f.offset(),e.element()).deleteContents();return{start:k(la.before(e.element())),finish:k(la.before(e.element())),mark:e.element}})},bv=function(a,b,c,d,e){return Ro(a,b,c,d).bind(function(a){return Me.soft(a.mark(),0,e)})},G$=function(a,b,c,d,e){return Ro(a,b,c,d).bind(function(a){return ec.findValidHardBreak(a.mark(),e).bind(function(b){return Me.hard(b,a.mark(),0,g.none(),e)})})},H$=function(a,b){z(a,function(a){Df.postprocess(a,b)})},cv={soft:bv,hard:function(a,b,c,d,e){var f=ec.findValidHardBreak(a,
  e),h=ec.findValidHardBreak(c,e),g=f.fold(function(){var f=bv(a,b,c,d,e);return av(f,[])},function(f){return h.fold(function(){var h=bv(a,b,c,d,e);return av(h,[f])},function(h){var g=N.eq(f,h)?G$(a,b,c,d,e):Ro(a,b,c,d);return av(g,[f,h])})});return g.cursor().map(function(a){H$(g.blocks(),a.start().fold(ca,ca,ca));return a})},rupture:function(a,b,c,d,e){return Ro(a,b,c,d).bind(function(a){return ec.findValidHardBreak(a.mark(),e).bind(function(b){return Me.rupture(b,a.mark(),0)})})}},dv={point:function(a,
  b,c){return $u.rupture(a,b,c)},range:function(a,b,c,d,e){return cv.rupture(a,b,c,d,e)},ruptureUntil:function(a,b,c,d,e,f){var h=Qo.postfix(a,b,c,d);return function(a,b){return ec.findValidHardBreak(a,e).map(f).bind(function(c){return Me.rupture(c,a,b)})}(a,b).bind(function(a){return h.map(function(b){var c=document.createRange();c.setStartAfter(a.first().dom());c.setEndBefore(b.element().dom());c.deleteContents();b.cleanup();a.mark().cleanup();return a.first()})})}},Sk=function(a,b,c){if(0<a.length){var d=
  a[0],e=a.slice(1);bm.atStartOf(b,c,d);P.after(d,e);return g.some(a[a.length-1])}return g.none()},Bd={split:function(a,b,c){var d=void 0===c?Di.purge:c;return dv.point(a.block(),a.element(),a.offset()).bind(function(a){var c=b.all();P.before(a.second(),c);a.mark().cleanup();d(a.first());d(a.second());z([a.first(),a.second()],RJ);a=jd(c);return qa(a,function(a){return A.parent(a).isSome()})})},merge:function(a,b){b=A.children(b.single());return Sk(b,a.element(),a.offset())},nest:function(a,b){return Sk(b.all(),
  a.element(),a.offset())},insertMany:Sk,insertChildren:function(a,b){a=A.children(a);return Sk(a,b.element(),b.offset())},fallback:function(a,b,c){return Sk(c,b.startContainer(),b.startOffset())}},ZJ={lists:function(a){return Eb(a,function(a,c){return a.bind(function(a){return L.closest(c,"ol,ul").map(function(b){return[b].concat(a)})})},g.some([])).map(function(a){return{all:k(a)}})},from:function(a){return{all:k(a)}}},$J=O("left","right"),I$=function(a){return pa.isFormatting(a)||pa.isContainer(a)},
  aK=function(a,b,c,d){return Ja.closest(c,a,b)},bK=function(a){return function(b,c,d){return a(b,c.element(),c.offset()).bind(function(c){return a(b,d.element(),d.offset()).map(function(a){return $J(c,a)})})}},cK=function(a){var b=bK(a);return function(a,d,e){return b(a,d,e).filter(function(a){return N.eq(a.left(),a.right())})}},ab={inline:function(a,b,c){return Ja.closest(b,I$,a).fold(function(){return g.some(b)},function(c){return a(c)?g.some(b):g.none()})},formatter:u(aK,pa.isFormatting),container:function(a,
  b,c){return Ja.closest(b,pa.isContainer,a).filter(zf(a))},inListItem:function(a,b,c){return L.closest(b,"li",a)},inList:function(a,b,c){return L.closest(b,"ol,ul",a)},inTableCell:function(a,b,c){return L.closest(b,"td,th",a)},setBlock:function(a,b){return oa(a,{block:k(b)})},both:bK,shared:cK,sharedPredicate:function(a){a=u(aK,a);return cK(a)},entireRoot:function(a,b,c){return Ja.closest(b.element(),a).filter(function(c){var d=function(a){return N.eq(a,b.element())};return a(b.element())&&0===b.offset()||
  D.isText(b.element())&&0===b.offset()&&kc.first(c).map(d).getOr(!1)}).filter(function(b){var d=function(a){return N.eq(a,c.element())};return a(c.element())&&c.offset()>=A.children(b).length-1||D.isText(c.element())&&c.offset()>=Ya.get(c.element()).length&&kc.last(b).map(d).getOr(!1)}).map(function(a){return $J(a,a)})}},dK=function(a){return function(b){return(1===b.length?g.some(b[0]):g.none()).filter(a).map(function(a){return{single:k(a)}})}},eK=function(a){return function(b){return(Xa(b,a)?g.some(b):
  g.none()).map(function(a){return{all:k(a)}})}},fc={oneOf:dK,anyOf:eK,noneOf:function(a){return function(b){return(Xa(b,a)?g.none():g.some(b)).map(function(a){return{all:k(a)}})}},allOf:function(a){return function(b){return ob(b,a)?g.some({all:k(b)}):g.none()}},any:g.some,oneOfTag:function(a){return dK(function(b){return D.name(b)===a})},anyOfTag:function(a){return eK(function(b){return D.name(b)===a})},single:function(a){return g.some({single:k(a)})},all:function(a){return g.some({all:k(a)})}},So=
  function(a){return 1===a.length?L.closest(a[0],"ol,ul").map(function(a){return{single:k(a)}}):g.none()},fK=function(a){return So(a).bind(function(a){a=Y.descendants(a.single(),"li");return 1===a.length?g.some({single:k(a[0])}):g.none()})},gK=function(a){if(2!==a.length)return g.none();var b=a[0],c=a[1];return pa.isFormatting(b)||pa.isContainer(b)||U(["ol","ul","li"],D.name(b))||!U(["ol","ul"],D.name(c))?g.none():g.some({all:k(a),list:k(c),inline:k(b)})},Fi=ab.formatter,hK=ab.inline,J$=ab.container,
  iK=function(a){return pa.isFormatting(a)&&!1===pg.shouldMerge(a)},K$=[jb(ab.inListItem,So,function(a,b){b=Y.children(b.single(),"li");return 1!==b.length||Db.descendant(b[0],"ol,ul")?Bd.split(a,ZJ.from(b),QJ):Bd.insertChildren(b[0],a)},"List"),jb(ab.inListItem,ZJ.lists,function(a,b){return L.ancestor(a.block(),"ol,ul",a.isRoot).bind(function(c){c=ab.setBlock(a,c);return Bd.split(c,b,Wu)})},"Many lists"),jb(hK,fc.anyOf(iK),Bd.nest,"Copying formatting (NO MERGE) into root"),jb(hK,fc.oneOf(pa.isFormatting),
  Bd.merge,"Copying formatting into root"),jb(Fi,fc.anyOfTag("hr"),Bd.split,"insert hr into formatter"),jb(Fi,fc.anyOf(iK),Bd.split,"Copying one formatting block (NO MERGE) into formatting"),jb(Fi,fc.oneOf(pa.isFormatting),Bd.merge,"Copying one formatting block into formatting"),jb(Fi,fc.anyOf(pa.isFormatting),Bd.split,"Copying many formatting blocks into formatting"),jb(Fi,fc.anyOfTag("table"),function(a){return function(b,c){var d=c.all();b=a(b,c);g.from(d[d.length-1]).each(function(a){A.nextSibling(a).fold(function(){var b=
  p.fromTag("p");y.append(b,p.fromTag("br"));y.after(a,b)},t)});return b}}(Bd.split),"Copying tables into formatting"),jb(Fi,fc.anyOf(pa.isContainer),Bd.split,"Copying container blocks into formatting"),jb(J$,fc.all,Bd.nest,"Fallback pasting into container.")],L$={context:function(a,b,c){return b.context(a.isRoot,c.startContainer(),c.startOffset()).map(function(b){return{block:k(b),element:c.startContainer,offset:c.startOffset,isRoot:a.isRoot}})},rules:k(K$),fallback:Bd.fallback},M$={force:function(a){var b=
  hd.after(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset()),c=b?W.point(a.endContainer(),a.endOffset()):W.point(a.startContainer(),a.startOffset());a=b?W.point(a.startContainer(),a.startOffset()):W.point(a.endContainer(),a.endOffset());return{left:k(c),right:k(a)}}},N$=function(a,b){var c=a.original(),d=Qo.postfix(c.left().element(),c.left().offset(),c.right().element(),c.right().offset()),e=b.all();return d.bind(function(b){qh.makeTo(c.left().element(),c.left().offset(),b.element()).deleteContents();
  b.cleanup();P.append(a.left(),e);b=A.children(a.right());P.append(a.left(),b);F.remove(a.right());return g.from(e[e.length-1])})},jK=function(a,b){if(!N.eq(a.left(),a.right()))throw"replaceContents used in the wrong context";a=a.left();F.empty(a);b=b.all();P.append(a,b);return kc.last(a).or(g.from(b[b.length-1]))},Cd={replace:function(a,b){return N.eq(a.left(),a.right())?(b=b.all(),a.replaceSelection(b),g.from(b[b.length-1])):N$(a,b)},replaceContents:jK,replaceContentsWrapP:function(a,b){var c=p.fromTag("p");
  P.append(c,b.all());return jK(a,{all:k([c])})},replaceWhole:function(a,b){b=b.all();P.after(a.left(),b);F.remove(a.left());return g.from(b[b.length-1])},merge:function(a,b){b=A.children(b.single());a.replaceSelection(b);return g.from(b[b.length-1])},split:function(a,b,c){var d=void 0===c?Di.purge:c;c=a.original().left();var e=a.original().right();return dv.range(c.element(),c.offset(),e.element(),e.offset(),a.isRoot).bind(function(a){var c=b.all();P.before(a.second(),c);a.mark().cleanup();z([a.first(),
  a.second()],d);return g.from(c[c.length-1])})},fallback:function(a,b,c){a.replaceSelection(c);g.from(c[0]).each(Di.purge);g.from(c[c.length-1]).each(Di.purge);return g.from(c[c.length-1])}},kK=function(a,b,c,d){d=void 0!==d?d:ca;var e=b.original(),f=e.left();e=e.right();return dv.ruptureUntil(f.element(),f.offset(),e.element(),e.offset(),b.isRoot,d).bind(function(b){var d=a(b,c);O$(b);return d},void 0!==d?d:ca)},O$=function(a){var b=Y.ancestors(a,"ol,ul");0<b.length&&z([Wu,RJ],function(a){a(b[b.length-
  1])})},To=function(a,b,c){return kK(a,b,c,ca)},Tk=ab.formatter,P$=u(To,function(a,b){y.after(a,b.single());return g.some(b.single())}),lK=u(function(a,b,c){return kK(a,b,c,function(a){return A.parent(a).getOr(a)})},function(a,b){b=b.all();P.after(a,b);return g.from(b[b.length-1])}),Q$=u(To,function(a,b){b=A.children(b.single());P.after(a,b);return g.some(b[b.length-1])}),R$=u(To,function(a,b){var c=p.fromTag("li");P.append(c,[b.inline(),b.list()]);y.after(a,c);return g.some(b.list())}),S$=u(To,function(a,
  b){var c=p.fromTag("li");P.append(c,[b.inline(),b.list()]);var d=L.ancestor(a,"ol,ul").fold(function(){var a=p.fromTag(D.name(b.list()));y.append(a,c);return a},function(){return c});y.after(a,d);return g.some(b.list())}),T$=[jb(ab.sharedPredicate(pg.isAtomic),fc.all,Cd.replaceWhole,"selection: inside something atomic, so just replace the whole thing"),jb(ab.shared(ab.inListItem),fK,function(a,b){return Cd.merge(a,b)},"selection: same item, paste: singleton"),jb(ab.shared(ab.inListItem),So,function(a,
  b){return Cd.split(a,{all:k(A.children(b.single()))},Wu)},"selection: same item, paste: single list"),jb(ab.shared(ab.inListItem),gK,S$,"selection: same item, paste: partial"),jb(ab.shared(ab.inListItem),fc.noneOf(pa.isBlock),Cd.replace,"selection: same item, paste: no blocks"),jb(ab.shared(ab.inListItem),fc.anyOf(pa.isHeading),function(a,b){a=Cd.replace(a,b);z(b.all(),function(a){Di.purgeBy(a,li.isVacantText)});return a},"selection: same item, paste: heading"),jb(ab.shared(ab.inListItem),fc.all,
  lK,"selection: same item, paste: any"),jb(ab.both(ab.inListItem),fK,P$,"selection: diff items, paste: singleton"),jb(ab.both(ab.inListItem),So,Q$,"selection: diff items, paste: single list"),jb(ab.both(ab.inListItem),gK,R$,"selection: diff items, paste: partial"),jb(ab.both(ab.inListItem),fc.all,lK,"selection: diff items, paste: any"),jb(ab.both(Tk),fc.anyOfTag("hr"),Cd.split,"selection: inside formatter, paste: split"),jb(ab.both(Tk),fc.noneOf(pa.isBlock),Cd.replace,"range no blocks"),jb(ab.both(Tk),
  fc.anyOf(function(a){return pa.isFormatting(a)&&!1===pg.shouldMerge(a)}),Cd.split,"range 1 formatting block"),jb(ab.both(Tk),fc.oneOf(pa.isFormatting),Cd.merge,"range 1 formatting block"),jb(ab.both(Tk),fc.all,Cd.split,"range anything > formatters"),jb(ab.entireRoot,fc.noneOf(pa.isBlock),Cd.replaceContentsWrapP,"complete body, not inserting a block: wrap in P and replace the contents"),jb(ab.entireRoot,fc.all,Cd.replaceContents,"complete body: replace the contents")],U$={context:function(a,b,c){var d=
  M$.force(c);return b.context(a.isRoot,d.left(),d.right()).map(function(b){return{left:b.left,right:b.right,original:k(d),isRoot:a.isRoot,replaceSelection:a.replaceSelection}})},rules:k(T$),fallback:Cd.fallback},V$=function(a,b,c,d,e){return hb(a,function(a,h){return a.orThunk(function(){return d(b,h,c).bind(function(a){return h.profile(e).map(function(b){return{action:h.action,target:k(b),ctx:k(a)}})})})},g.none())},mK=function(a,b,c,d,e,f){var h={getSelection:a,replaceSelection:b,isRoot:c},k=function(a,
  b){return a.fold(function(){if(0===d.length){var a=b.startContainer(),c=b.startOffset();c=D.isText(a)?Math.min(c,a.dom().length):c;return g.some(W.point(a,c))}return g.none()},function(a){var b=wa.getEnd(a);return g.some(W.point(a,b))})};return h.getSelection().bind(function(a){var b=a.collapsed()?L$:U$,c=a.collapsed()?e.concat(b.rules()):f.concat(b.rules());c=V$(c,h,a,b.context,d).fold(function(){return b.fallback(h,a,d)},function(a){return a.action(a.ctx(),a.target())});return k(c,a)})},W$={insertAtCursor:function(a,
  b,c,d){return mK(a,b,c,d,[],[])},insertAtCursorWith:mK},X$=function(a){return D.isElement(a)&&"false"===m.get(a,"contenteditable")},Y$=function(a){return a().map(function(a){a=E([a.startContainer(),a.endContainer()],function(a){return Ja.closest(a,X$)});return ee(a)}).getOr([])},nK=function(a,b,c){z(a,b);b=c();z(a,pg.clear);return b},Z$=function(a,b){return nK(a,pg.setAtomic,b)},oK=function(a,b,c,d,e,f){var h=Y$(a);return Z$(h,function(){return W$.insertAtCursorWith(a,b,c,d,e,f)})},pK=function(a,
  b,c,d){b=oK(a.getSelection,a.replaceSelection,a.isRoot,b,c,d);a.domChanged();a.undoChanged();return b},qK=function(a,b){return pK(a,b,[],[])},rd={insertAtCursorWith:pK,insertAtCursor:qK,insertAtCursorWithInstructions:function(a,b,c){return nK(c,a,function(){return qK(b,c)})},insertAt:function(a,b,c){c=oK(function(){return g.some(b)},function(c){a.win().each(function(a){var d=Kc.relative(la.on(b.startContainer(),b.startOffset()),la.on(b.endContainer(),b.endOffset()));Wa.replace(a,d,c)})},a.isRoot,
  c,[],[]);a.domChanged();a.undoChanged();return c}},hm={generate:function(a){return a+"-"+Math.floor(99999*Math.random()).toString()}},$$=O("ch","offset"),rK=function(a,b){return $$(a.charAt(b),b)},Uo={previous:function(a,b){for(b=b.getOr(a.length)-1;0<=b;b--)if(a.charAt(b)!==mb())return g.some(rK(a,b));return g.none()},next:function(a,b){for(b=b.getOr(0)+1;b<a.length;b++)if(a.charAt(b)!==mb())return g.some(rK(a,b));return g.none()},rfind:function(a,b){b.lastIndex=-1;a=jd(a).join("");b=a.match(b);
  return void 0!==b&&null!==b&&0<=b.index?g.some(a.length-1-b.index):g.none()},lfind:function(a,b){b.lastIndex=-1;a=a.match(b);return void 0!==a&&null!==a&&0<=a.index?g.some(a.index):g.none()}},aaa=Ca.walkers().left(),baa=Ca.walkers().right(),caa=ta.generate([{abort:[]},{kontinue:[]},{finish:["info"]}]),ev=ta.generate([{aborted:[]},{edge:["element"]},{success:["info"]}]),sK=function(a,b){return Mc.isEmptyTag(a,b)||a.property().isBoundary(b)},fv=function(a,b,c,d,e,f,h){var k=function(){return h.fold(ev.aborted,
  ev.edge)},q=function(d){return Ca.walk(a,b,c,f).fold(k,function(b){return fv(a,b.item(),b.mode(),g.none(),e,f,d)})};if(sK(a,b))return k();if(a.property().isText(b)){var m=a.property().getText(b);return e(a,caa,b,m,d).fold(k,function(){return q(g.some(b))},ev.success)}return q(h)},daa=function(a,b,c,d){c=ad.toLeaf(a,b,c);return a.property().isText(b)?g.none():Rn.left(a,c.element(),a.property().isText,d).map(function(b){return W.point(b,a.property().getText(b).length)})},eaa=function(a,b,c,d){c=ad.toLeaf(a,
  b,c);return a.property().isText(b)?g.none():Rn.right(a,c.element(),a.property().isText,d).map(function(a){return W.point(a,0)})},tK=function(a,b,c){var d=u(sK,a);return daa(a,b,c,d).orThunk(function(){return eaa(a,b,c,d)}).getOr(W.point(b,c))},uK={repeatLeft:function(a,b,c,d){b=tK(a,b,c);return fv(a,b.element(),Ca.sidestep,g.some(b.offset()),d,aaa,g.none())},repeatRight:function(a,b,c,d){b=tK(a,b,c);return fv(a,b.element(),Ca.sidestep,g.some(b.offset()),d,baa,g.none())}},vK=xd(["regex","attempt"]),
  wK=function(a,b,c,d){return uK.repeatLeft(a,b,c,d)},xK=function(a,b,c,d){return uK.repeatRight(a,b,c,d)},yK=function(a,b,c){var d=k(!1);if(!a.property().isText(b))return g.none();var e=a.property().getText(b);return c<=e.length?g.some(W.point(b,c)):Ca.seekRight(a,b,a.property().isText,d).bind(function(b){return yK(a,b,c-e.length)})},th={previousChar:function(a,b){return Uo.previous(a,b)},nextChar:function(a,b){return Uo.next(a,b)},repeatLeft:wK,repeatRight:xK,expandLeft:function(a,b,c,d){var e=vK(d);
  return wK(a,b,c,function(a,b,c,d,g){a=g.getOr(d.length);return Uo.rfind(d.substring(0,a),e.regex()).fold(function(){return b.kontinue()},function(a){return e.attempt(b,c,d,a)})})},expandRight:function(a,b,c,d){var e=vK(d);return xK(a,b,c,function(a,b,c,d,g){var f=g.getOr(0);return Uo.lfind(d.substring(f),e.regex()).fold(function(){return b.kontinue()},function(a){return e.attempt(b,c,d,f+a)})})},scanRight:yK},Uk=nb(),uh={previousChar:function(a,b){return th.previousChar(a,b)},nextChar:function(a,
  b){return th.nextChar(a,b)},repeatLeft:function(a,b,c){return th.repeatLeft(Uk,a,b,c)},repeatRight:function(a,b,c){return th.repeatRight(Uk,a,b,c)},expandLeft:function(a,b,c){return th.expandLeft(Uk,a,b,c)},expandRight:function(a,b,c){return th.expandRight(Uk,a,b,c)},scanRight:function(a,b){return th.scanRight(Uk,a,b)}},Gi=O("before","after"),iv=function(a,b,c,d,e){return Vo(c).fold(function(){var c=zK(a,b,d);return Gi(c,e)},function(f){var h=Hi(c,f);return h.length>a?Gi(d,e):gv(b).fold(function(){var b=
  hv(a-h.length,f,e+h);return Gi(d,b)},function(c){var g=Hi(c,b);return g.length>a-h.length?Gi(d,e+h):iv(a-h.length-g.length,c,f,g+d,e+h)})})},AK=function(a,b,c,d){return a.finish(W.point(b,d))},BK={regex:function(){return new RegExp(Cb.wordchar(),"i")},attempt:AK},CK={regex:function(){return new RegExp(Cb.wordbreak(),"i")},attempt:AK},DK=function(a,b){return a.offset()===b.offset()&&N.eq(a.element(),b.element())},EK=function(a){return W.point(a,D.value(a).length)},FK=function(a){return W.point(a,0)},
  jv=function(a,b,c){var d=function(b){b=c(b);return DK(a,b)?g.none():g.some(b)};return b(a.element(),a.offset(),BK).fold(g.none,d,function(a){return b(a.element(),a.offset(),CK).fold(g.none,d,function(a){return g.some(a)})})},Vo=function(a){return jv(a,uh.expandRight,EK)},gv=function(a){return jv(a,uh.expandLeft,FK)},Wo=function(a,b,c,d,e,f){return a(c).fold(k(d),function(h){var g=e(c,h);return g.length+d.length>b||0===g.length?d:Wo(a,b,h,f(d,g),e,f)})},hv=function(a,b,c){return Wo(Vo,a,b,c,Hi,function(a,
  b){return a+b})},zK=function(a,b,c){return Wo(gv,a,b,c,function(a,b){return Hi(b,a)},function(a,b){return b+a})},Hi=function(a,b){var c=A.defaultView(a.element()).dom();a=Kc.exact(a.element(),a.offset(),b.element(),b.offset());return Wa.getAsString(c,a)},GK={beforeAfter:Gi,anchorText:function(a,b){var c=kb.freefallLtr(b);return Vo(c).map(function(b){var d=Hi(c,b);return d+hv(a-d.length,b,"")}).getOr("")},flankingText:function(a,b){if(0===a)return Gi("","");var c=kb.freefallLtr(b);b=kb.freefallRtl(b);
  return iv(a,c,b,"","")},extendRightAndLeft:iv,extendWordsSearch:Wo,extendWordsRight:hv,extendWordsLeft:zK,wordSearch:jv,wordLeft:gv,wordRight:Vo,pointEq:DK,boundaryPointRight:EK,boundaryPointLeft:FK,textBetweenPoints:Hi,wordSeeker:BK,wordBreakSeeker:CK},HK=function(a,b){try{return a()}catch(c){if(12===c.code)return b();throw c;}},kv=function(a){return L.closest(a,"a[href]")},lv=function(a,b){return kv(a).bind(function(a){return kv(b).filter(function(b){return N.eq(a,b)})})},faa=O("element","innerText",
  "before","after"),mv=function(a,b,c,d){b=xf.isEmpty(b)&&xf.isEmpty(c)&&xf.isEmpty(d)?"#"+m.get(a,"id"):b;return faa(a,b,c,d)},nv=function(a){return Ia.is(a,"a[href]")?[a]:Ia.all("a[href]",a)},Ld={contentLink:function(a){var b=a.getSelection();return vc.detect(b).fold(function(){return b.bind(function(a){return lv(a.startContainer(),a.endContainer())})},function(a){return g.some(a.image()).bind(kv)})},sharedLink:lv,sharedLinkOrClosest:function(a,b){var c=kb.toLeaf(a.startContainer(),a.startOffset());
  a=kb.toLeaf(a.endContainer(),a.endOffset());return lv(c.element(),a.element()).orThunk(function(){return L.closest(c.element(),"a[href]",b)})},findLinkTargets:function(a){return Ia.all("h1,h2,h3,h4,h5,h6,div[id],p[id],span[id],a[id],a[name]",a)},linkTargetText:function(a,b){var c=Vb.get(b).length,d=Oc.deep(b);c=GK.anchorText(c,d);if(pa.isBlock(b))return mv(b,c,"","");a=GK.flankingText(Math.max(0,a-c.length),b);return mv(b,c,a.before(),a.after())},linkTargetFastText:function(a,b){var c=Vb.get(b);a=
  c.length>a?c.substr(0,a):c;return mv(b,a,"","")},all:nv,many:function(a){return ia(a,nv)},hrefUrl:function(a,b){return HK(function(){return Ia.all('a[href="'+b+'"]',a)},function(){var c=nv(a);return ka(c,function(a){return m.get(a,"href")===b})})},anchorTarget:function(a,b){return HK(function(){return Ia.one("#"+b+',a[name="'+b+'"]',a)},function(){var c=A.owner(a).dom();return g.from(c.getElementById(b)).map(p.fromDom).orThunk(function(){var c=Ia.all("[name]",a);return qa(c,function(a){return m.get(a,
  "id")===b||m.get(a,"name")===b})})})},getAnchorValue:function(a,b){a=a.replace(/[^0-9a-zA-Z$_.+*(),-]/g,"");return 0<a.length?a:b}},Xo=["li"],IK=function(a,b){return Bc.cata(a,function(a){return!0===b?[]:Ud.wrap(a)},function(a){return[a]},function(a,b){return"table"===D.name(a)?[a]:Ud.handleContainer(Xo,a,b,IK)},function(a){return!0===b?[]:Ud.wrap([a])})},gaa={isRootContainer:oo.isRootOrContainer,extract:function(a){return IK(a,!1)},isCapable:function(a){return Bj.isBlock(a)||U(Xo,D.name(a))},canUse:function(a){return pa.isFormatting(a)||
  U(Xo,D.name(a))},quasi:u(Ud.handleRoot,Xo),ascend:ca},haa=function(a,b){return L.closest(b,'[dir="rtl"],[dir="ltr"]').filter(a).isSome()},JK=function(a,b,c){var d=bV(b,c),e=function(a){d.set(a);v.reflow(a)},f=function(a){return ae.getDirection(a)===c};return{run:function(a,b,c,d,f){return pi.applyOn(a,gaa,b,c,d,f,function(a){z(a,e);return a})},query:function(a,b){return kH.bothMatch(a,b,u(haa,f))},name:k(a)}},iaa=JK("DirRtl","dir","rtl"),jaa=JK("DirLtr","dir","ltr"),Yo={dirLtr:k(jaa),dirRtl:k(iaa)},
  KK=function(a){return function(b){var c=function(c,e,f,h){return a.run(b.content().isRoot,c,e,f,h)};$b.cata(b.selections().get(),t,io.multiple(b.content(),b.undo(),c),io.single(b.content(),b.undo(),c,Ck,Bk));setTimeout(function(){b.content().uiChanged()},0)}},$y={dirRtl:KK(Yo.dirRtl()),dirLtr:KK(Yo.dirLtr())},kaa=O("ltrdir","rtldir"),LK=function(a,b){return b.query(a.startContainer(),a.endContainer())?Da.on(!0):Da.off()},laa=function(a){return L.closest(a.startContainer(),"[dir]").isSome()||L.closest(a.endContainer(),
  "[dir]").isSome()},Zy={readDir:function(a){return a.getSelection().filter(laa).map(function(a){return kaa(LK(a,Yo.dirLtr()),LK(a,Yo.dirRtl()))})}},maa=ta.generate([{blob:["id","imageresult","objurl"]},{url:["id","url","raw"]}]),Pc=ua(maa,{cata:function(a,b,c){return a.fold(b,c)}}),Tc={create:az,clone:function(a){var b=az(a.width,a.height);cz(b).drawImage(a,0,0);return b},resize:bz,get2dContext:cz,get3dContext:function(a){var b=null;try{b=a.getContext("webgl")||a.getContext("experimental-webgl")}catch(c){}b||
  (b=null);return b}},Nh={getWidth:function(a){return a.naturalWidth||a.width},getHeight:function(a){return a.naturalHeight||a.height}},naa=function(){function a(a,b){return function(){a.apply(b,arguments)}}function b(a){var b=this;null===this._state?this._deferreds.push(a):k(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)(b._state?a.resolve:a.reject)(b._value);else{try{var d=c(b._value)}catch(X){a.reject(X);return}a.resolve(d)}})}function c(b){try{if(b===this)throw new TypeError("A promise cannot be resolved with itself.");
  if(b&&("object"===typeof b||"function"===typeof b)){var f=b.then;if("function"===typeof f){h(a(f,b),a(c,this),a(d,this));return}}this._state=!0;this._value=b;e.call(this)}catch(G){d.call(this,G)}}function d(a){this._state=!1;this._value=a;e.call(this)}function e(){for(var a=0,c=this._deferreds.length;a<c;a++)b.call(this,this._deferreds[a]);this._deferreds=null}function f(a,b,c,d){this.onFulfilled="function"===typeof a?a:null;this.onRejected="function"===typeof b?b:null;this.resolve=c;this.reject=
  d}function h(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(X){d||(d=!0,c(X))}}var g=function(b){if("object"!==typeof this)throw new TypeError("Promises must be constructed via new");if("function"!==typeof b)throw new TypeError("not a function");this._value=this._state=null;this._deferreds=[];h(b,a(c,this),a(d,this))},k=g.immediateFn||"function"===typeof setImmediate&&setImmediate||function(a){setTimeout(a,1)},m=Array.isArray||function(a){return"[object Array]"===
  Object.prototype.toString.call(a)};g.prototype["catch"]=function(a){return this.then(null,a)};g.prototype.then=function(a,c){var d=this;return new g(function(e,h){b.call(d,new f(a,c,e,h))})};g.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&m(arguments[0])?arguments[0]:arguments);return new g(function(b,c){function d(f,h){try{if(h&&("object"===typeof h||"function"===typeof h)){var g=h.then;if("function"===typeof g){g.call(h,function(a){d(f,a)},c);return}}a[f]=h;0===--e&&b(a)}catch(wT){c(wT)}}
  if(0===a.length)return b([]);for(var e=a.length,f=0;f<a.length;f++)d(f,a[f])})};g.resolve=function(a){return a&&"object"===typeof a&&a.constructor===g?a:new g(function(b){b(a)})};g.reject=function(a){return new g(function(b,c){c(a)})};g.race=function(a){return new g(function(b,c){for(var d=0,e=a.length;d<e;d++)a[d].then(b,c)})};return g},Md=window.Promise?window.Promise:naa(),im={atob:function(a){return Jc.getOrDie("atob")(a)},requestAnimationFrame:function(a){Jc.getOrDie("requestAnimationFrame")(a)}},
  id={blobToImage:fz,imageToBlob:function(a){a=a.src;return 0===a.indexOf("data:")?Zq(a):gz(a)},blobToArrayBuffer:function(a){return new Md(function(b){var c=new Yq;c.onloadend=function(){b(c.result)};c.readAsArrayBuffer(a)})},blobToDataUri:iz,blobToBase64:function(a){return iz(a).then(function(a){return a.split(",")[1]})},dataUriToBlobSync:hz,canvasToBlob:function(a,b,c){b=b||"image/png";return HTMLCanvasElement.prototype.toBlob?new Md(function(d){a.toBlob(function(a){d(a)},b,c)}):Zq(a.toDataURL(b,
  c))},canvasToDataURL:function(a,b,c){b=b||"image/png";return a.then(function(a){return a.toDataURL(b,c)})},blobToCanvas:function(a){return fz(a).then(function(a){URL.revokeObjectURL(a.src);var b=Tc.create(Nh.getWidth(a),Nh.getHeight(a));Tc.get2dContext(b).drawImage(a,0,0);return b})},uriToBlob:function(a){return 0===a.indexOf("blob:")?gz(a):0===a.indexOf("data:")?Zq(a):null}},Lj={blobToImage:function(a){return id.blobToImage(a)},imageToBlob:function(a){return id.imageToBlob(a)},blobToDataUri:function(a){return id.blobToDataUri(a)},
  blobToBase64:function(a){return id.blobToBase64(a)},dataUriToBlobSync:function(a){return id.dataUriToBlobSync(a)},uriToBlob:function(a){return g.from(id.uriToBlob(a))}},xe={fromBlob:jz,fromCanvas:function(a,b){return id.canvasToBlob(a,b).then(function(b){return $q(Md.resolve(a),b,a.toDataURL())})},fromImage:function(a){return id.imageToBlob(a).then(function(a){return jz(a)})},fromBlobAndUrlSync:function(a,b){return $q(id.blobToCanvas(a),a,b)}},MK=function(a){return a.toBlob()},Xc={blobToImageResult:function(a){return xe.fromBlob(a)},
  fromBlobAndUrlSync:function(a,b){return xe.fromBlobAndUrlSync(a,b)},imageToImageResult:function(a){return xe.fromImage(a)},imageResultToBlob:function(a,b,c){return void 0===b&&void 0===c?MK(a):a.toAdjustedBlob(b,c)},imageResultToOriginalBlob:MK,imageResultToDataURL:function(a){return a.toDataURL()}},bg={createObjectURL:function(a){return Jc.getOrDie("URL").createObjectURL(a)},revokeObjectURL:function(a){Jc.getOrDie("URL").revokeObjectURL(a)}},Vk=aa.detect(),OK=function(a){var b=bg.createObjectURL(a);
  return NK(a,b)},NK=function(a,b){return Ea.nu(function(c){Lj.blobToDataUri(a).then(function(d){d=Xc.fromBlobAndUrlSync(a,d);var e=Fa("image");d=Pc.blob(e,d,b);c(d)})})},oaa=function(a){return 1===a.length&&U(a,"Files")},paa=function(a){return!U(a,"text/_moz_htmlcontext")},qaa=function(a){return U(a,"Files")},raa=function(a){return!0},ve={multiple:function(a){return 0===a.length?Ea.pure([]):Ce(a,OK)},toFiles:function(a){return a.raw().target.files||a.raw().dataTransfer.files},isFiles:Vk.browser.isChrome()||
  Vk.browser.isSafari()||Vk.browser.isOpera()?qaa:Vk.browser.isFirefox()?paa:Vk.browser.isIE()?oaa:raa,fromImages:function(a){a=E(a,function(a){var b=Fa("image");return Pc.url(b,m.get(a,"src"),a)});return Ea.pure(a)},single:OK,singleWithUrl:NK},eA={register:function(a,b,c){var d=H.create({dragover:r(["original"]),dragleave:r(["original"]),drop:r(["original"]),dragndropimages:r(["original","files"]),dragndrophtml:r(["original"])});b.each(function(b){var c=function(c){return function(){c(a,b)}};d.registry.dragover.bind(c(n.add));
  d.registry.dragleave.bind(c(n.remove));d.registry.drop.bind(c(n.remove))});var e=K.bind(a,"dragover",function(a){!0===c?(a.prevent(),d.trigger.dragover(a)):a.kill()}),f=K.bind(a,"dragleave",d.trigger.dragleave),h=K.bind(a,"drop",function(a){d.trigger.drop(a);a.kill();if(ve.isFiles(a.raw().dataTransfer.types)){var b=ve.toFiles(a);d.trigger.dragndropimages(a,b)}else U(a.raw().dataTransfer.types,"text/html")&&d.trigger.dragndrophtml(a)});return{destroy:function(){e.unbind();f.unbind();h.unbind()},events:d.registry}}},
  eV={forImages:function(a,b,c){a=eA.register(a,b,c);var d=H.create({dragover:r(["original"]),dragleave:r(["original"]),drop:r(["original"]),dragndropimages:r(["assets","x","y"]),dragndrophtml:r(["html","x","y"])});b=function(a,b){a.bind(function(a){b(a.original())})};a.events.dragndropimages.bind(function(a){var b=a.original();ve.multiple(a.files()).get(function(a){d.trigger.dragndropimages(a,b.x(),b.y())})});a.events.dragndrophtml.bind(function(a){a=a.original();var b=a.raw().dataTransfer.getData("text/html");
  d.trigger.dragndrophtml(b,a.x(),a.y())});b(a.events.dragover,d.trigger.dragover);b(a.events.dragleave,d.trigger.dragleave);b(a.events.drop,d.trigger.drop);return{destroy:a.destroy,events:d.registry}}},saa=Pb(Ea.pure,J.value),taa=Pb(Ea.pure,J.error),hf={pure:saa,failed:taa,foldSync:function(a,b,c){return a.map(function(a){return a.fold(b,c)})},bindSync:function(a,b){return a.map(function(a){return a.bind(b)})},bindAsync:function(a,b){return a.bind(function(a){return a.bind(b)})},mapSync:function(a,
  b){return a.map(function(a){return a.map(b)})},handle:function(a,b,c){return a.get(function(a){return a.fold(b,c)})}},wj={now:function(){return(new Date).getTime()}},Ne=ta.generate([{strict:[]},{defaultedThunk:["fallbackThunk"]},{asOption:[]},{asDefaultedOptionThunk:["fallbackThunk"]},{mergeWithThunk:["baseThunk"]}]),qg=Ne.strict,Wk=Ne.asOption,uaa=Ne.defaultedThunk,vaa=Ne.mergeWithThunk;ta.generate([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},
  {bothValues:["value1","value2"]}]);var PK=function(a){var b=[],c=[];z(a,function(a){a.fold(function(a){b.push(a)},function(a){c.push(a)})});return{errors:b,values:c}},QK=function(a){return Pb(J.error,Qb)(a)},ov={consolidateObj:function(a,b){a=PK(a);return 0<a.errors.length?QK(a.errors):J.value(oa.apply(void 0,[b].concat(a.values)))},consolidateArr:function(a){a=PK(a);return 0<a.errors.length?QK(a.errors):J.value(a.values)}},PY=function(a,b){var c={};z(a,function(a){c[a[b]]=a});return c},waa=function(a,
  b){var c={};Ma(a,function(a,e){U(b,e)||(c[e]=a)});return c},Ij=function(a){return function(b){return b.hasOwnProperty(a)?g.from(b[a]):g.none()}},RK=function(a,b){return function(c){return Ij(a)(c).getOr(b)}},zc=function(a,b){return Ij(b)(a)},ye=function(a,b){return a.hasOwnProperty(b)&&void 0!==a[b]&&null!==a[b]},gc=function(a,b){var c={};c[a]=b;return c},pb=function(a){var b={};z(a,function(a){b[a.key]=a.value});return b},SK=function(a,b){return zc(a,b)},pv=function(a,b){return gc(a,b)},qv=function(a,
  b){return ov.consolidateObj(a,b)},Xk=ta.generate([{setOf:["validator","valueType"]},{arrOf:["valueType"]},{objOf:["fields"]},{itemOf:["validator"]},{choiceOf:["key","branches"]},{thunk:["description"]},{func:["args","outputSchema"]}]),TK=ta.generate([{field:["name","presence","type"]},{state:["name"]}]),Nb={parse:function(a){return Jc.getOrDie("JSON").parse(a)},stringify:function(a,b,c){return Jc.getOrDie("JSON").stringify(a,b,c)}},rv=function(a){return ic(a)&&100<cb(a).length?" removed due to size":
  Nb.stringify(a,null,2)},xaa=function(a){a=10<a.length?a.slice(0,10).concat([{path:[],getErrorInfo:function(){return"... (only showing first ten failures)"}}]):a;return E(a,function(a){return"Failed path: ("+a.path.join(" > ")+")\n"+a.getErrorInfo()})},Yk=function(a,b){return J.error([{path:a,getErrorInfo:b}])},yaa=function(a,b,c){return Yk(a,function(){return'Could not find valid *strict* value for "'+b+'" in '+rv(c)})},zaa=function(a,b){return Yk(a,function(){return'Choice schema did not contain choice key: "'+
  b+'"'})},Aaa=function(a,b,c){return Yk(a,function(){return'The chosen schema: "'+c+'" did not exist in branches: '+rv(b)})},Baa=function(a,b){return Yk(a,function(){return"There are unsupported fields: ["+b.join(", ")+"] specified"})},Caa=function(a,b){return Yk(a,function(){return b})},sv=ta.generate([{field:["key","okey","presence","prop"]},{state:["okey","instantiator"]}]),Daa=function(a,b,c){return zc(b,c).fold(function(){return yaa(a,c,b)},J.value)},UK=function(a,b,c){b=zc(a,b).fold(function(){return c(a)},
  ca);return J.value(b)},Eaa=function(a,b,c){b=zc(a,b).map(function(b){return!0===b?c(a):b});return J.value(b)},Faa=function(a,b,c,d){return c.fold(function(c,f,h,l){var e=function(b){return l.extract(a.concat([c]),d,b).map(function(a){return gc(f,d(a))})},m=function(b){return b.fold(function(){var a=gc(f,d(g.none()));return J.value(a)},function(b){return l.extract(a.concat([c]),d,b).map(function(a){return gc(f,d(g.some(a)))})})};return function(){return h.fold(function(){return Daa(a,b,c).bind(e)},
  function(a){return UK(b,c,a).bind(e)},function(){return J.value(zc(b,c)).bind(m)},function(a){return Eaa(b,c,a).bind(m)},function(a){var d=a(b);return UK(b,c,k({})).map(function(a){return oa(d,a)}).bind(e)})}()},function(a,c){c=c(b);return J.value(gc(a,d(c)))})},Gaa=function(a,b,c,d){c=E(c,function(c){return Faa(a,b,c,d)});return ov.consolidateObj(c,{})},Ii=function(a){return{extract:function(b,c,d){return a(d,c).fold(function(a){return Caa(b,a)},J.value)},toString:function(){return"val"},toDsl:function(){return Xk.itemOf(a)}}},
  Haa=function(a){var b=cb(a);return ka(b,function(b){return ye(a,b)})},md=function(a){var b=Cc(a),c=Eb(a,function(a,b){return b.fold(function(b){return oa(a,gc(b,!0))},k(a))},{});return{extract:function(a,e,f){var d=Ym(f)?[]:Haa(f);d=ka(d,function(a){return!ye(c,a)});return 0===d.length?b.extract(a,e,f):Baa(a,d)},toString:b.toString,toDsl:b.toDsl}},Cc=function(a){return{extract:function(b,c,d){return Gaa(b,d,a,c)},toString:function(){return"obj{\n"+E(a,function(a){return a.fold(function(a,b,e,f){return a+
  " -> "+f.toString()},function(a,b){return"state("+a+")"})}).join("\n")+"}"},toDsl:function(){return Xk.objOf(E(a,function(a){return a.fold(function(a,b,e,f){return TK.field(a,e,f)},function(a,b){return TK.state(a)})}))}}},VK=function(a){return{extract:function(b,c,d){d=E(d,function(d,f){return a.extract(b.concat(["["+f+"]"]),c,d)});return ov.consolidateArr(d)},toString:function(){return"array("+a.toString()+")"},toDsl:function(){return Xk.arrOf(a)}}},tv=k(Ii(J.value)),Iaa=Pb(VK,Cc),Zk=sv.state,Dc=
  sv.field,Jaa=function(a,b,c,d,e){return zc(d,e).fold(function(){return Aaa(a,d,e)},function(d){return Cc(d).extract(a.concat(["branch: "+e]),b,c)})},WK=function(a,b){return{extract:function(c,d,e){return zc(e,a).fold(function(){return zaa(c,a)},function(a){return Jaa(c,d,e,b,a)})},toString:function(){return"chooseOn("+a+"). Possible values: "+cb(b)},toDsl:function(){return Xk.choiceOf(a,b)}}},Kaa=Ii(J.value),XK=function(a){return Ii(function(b){return a(b)})},YK=function(a,b,c,d){return b.extract([a],
  c,d).fold(function(a){return J.error({input:d,errors:a})},J.value)},rg=function(a,b,c){return YK(a,b,k,c)},Ji=function(a){return a.fold(function(a){throw Error(Zo(a));},ca)},Oe=function(a,b,c){return Ji(YK(a,b,ca,c))},Zo=function(a){return"Errors: \n"+xaa(a.errors)+"\n\nInput object: "+rv(a.input)},ZK=function(a,b){return WK(a,b)},$o=k(Kaa),$K=function(a,b){return Ii(function(c){var d=typeof c;return a(c)?J.value(c):J.error("Expected type: "+b+" but got: "+d)})},Laa=$K(xa,"string"),aL=$K(qb,"function"),
  ap=ta.generate([{get:[]},{post:[]},{put:[]},{del:[]}]),bp={get:ap.get,post:ap.post,put:ap.put,del:ap.del},Maa={generate:function(a,b,c,d){a=a.bind(function(a){return a.match({file:function(){return g.none()},form:function(){return g.some("application/x-www-form-urlencoded; charset=UTF-8")},json:function(){return g.some("application/json")},plain:function(){return g.some("text/plain")},html:function(){return g.some("text/html")}})});c=c.match({none:g.none,xhr:k(g.some(!0))});var e=b.match({json:g.none,
  blob:k(g.some("blob")),xml:k(g.some("document")),html:k(g.some("document")),text:k(g.some("text"))});b=b.match({json:k("application/json, text/javascript"),blob:k("application/octet-stream"),text:k("text/plain"),html:k("text/html"),xml:k("application/xml, text/xml")})+", */*; q=0.01";return{contentType:k(a),credentials:k(c),responseType:k(e),accept:k(b),headers:k(d)}}},Naa={mutate:function(a,b){b.contentType().each(function(b){a.setRequestHeader("Content-Type",b)});var c=b.accept();a.setRequestHeader("Accept",
  c);b.credentials().each(function(b){a.withCredentials=b});b.responseType().each(function(b){a.responseType=b});b=b.headers();Ma(b,function(b,c){xa(c)||xa(b)?a.setRequestHeader(c,b):console.error("Request header data was not a string: ",c," -> ",b)})}},bL={parse:function(a){try{var b=Nb.parse(a);return J.value(b)}catch(c){return J.error("Response was not JSON")}}},cL=Aa(["message","status","responseText"],[]),dL={handle:function(a,b,c){var d=function(){return Ea.pure(c.response)};return b.match({json:function(){return bL.parse(c.response).fold(d,
  Ea.pure)},blob:function(){return g.from(c.response).map(fV).getOr(Ea.pure("no response content"))},text:d,html:d,xml:d}).map(function(b){return cL({message:0===c.status?"Unknown HTTP error (possible cross-domain request)":'Could not load url "'+a+'": '+c.statusText,status:c.status,responseText:b})})},nu:cL},Oaa=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},Pe=function(a){return Oaa({},
  a,{bindFuture:function(b){return Pe(a.bind(function(c){return c.fold(function(){return a},function(a){return b(a)})}))},bindResult:function(b){return Pe(a.map(function(a){return a.bind(b)}))},mapResult:function(b){return Pe(a.map(function(a){return a.map(b)}))},foldResult:function(b,c){return a.map(function(a){return a.fold(b,c)})},withTimeout:function(b,c){return Pe(Ea.nu(function(d){var e=!1,f=window.setTimeout(function(){e=!0;d(J.error(c()))},b);a.get(function(a){e||(window.clearTimeout(f),d(a))})}))}})},
  eL=function(a){return Pe(Ea.nu(a))},fL=function(a){return Pe(Ea.pure(J.value(a)))},$k={nu:eL,wrap:Pe,pure:fL,value:fL,error:function(a){return Pe(Ea.pure(J.error(a)))},fromResult:function(a){return Pe(Ea.pure(a))},fromFuture:function(a){return Pe(a.map(J.value))},fromPromise:function(a){return eL(function(b){a.then(function(a){b(J.value(a))},function(a){b(J.error(a))})})}},Paa={validate:function(a,b){var c=function(){return $k.pure(b.response)};return a.match({json:function(){return bL.parse(b.response).fold(function(a){return $k.error(dL.nu({message:a,
  status:b.status,responseText:b.responseText}))},$k.pure)},blob:c,text:c,html:c,xml:function(a,b){return function(){return b().bindResult(function(b){return null===b?J.error(a):J.value(b)})}}("Invalid XML document",c)})}},cp=function(a,b,c,d,e,f){var h=void 0!==f?f:{};return $k.nu(function(f){var g=b.match({get:k("get"),put:k("put"),post:k("post"),del:k("delete")}),l=new (Jc.getOrDie("XMLHttpRequest"));l.open(g,a,!0);g=Maa.generate(c,d,e,h);Naa.mutate(l,g);var m=function(){dL.handle(a,d,l).get(function(a){f(J.error(a))})};
  l.onload=function(){0!==l.status||Gb(a,"file:")?100>l.status||400<=l.status?m():Paa.validate(d,l).get(f):m()};l.onerror=m;c.fold(function(){l.send()},function(a){a=a.match({file:ca,form:ca,json:Nb.stringify,plain:ca,html:ca});l.send(a)})}).toLazy()},Ae={get:function(a,b,c,d){var e=bp.get();return cp(a,e,g.none(),b,c,d)},post:function(a,b,c,d,e){var f=bp.post();return cp(a,f,g.some(b),c,d,e)},put:function(a,b,c,d,e){var f=bp.put();return cp(a,f,g.some(b),c,d,e)},del:function(a,b,c,d){var e=bp.del();
  return cp(a,e,g.none(),b,c,d)}},al=ta.generate([{file:["data"]},{form:["data"]},{json:["data"]},{plain:["data"]},{html:["data"]}]),yB={file:al.file,form:al.form,json:al.json,plain:al.plain,html:al.html},gL=ta.generate([{none:[]},{xhr:[]}]),he={none:gL.none,xhr:gL.xhr},bl=ta.generate([{json:[]},{blob:[]},{text:[]},{html:[]},{xml:[]}]),Be={json:bl.json,blob:bl.blob,text:bl.text,html:bl.html,xml:bl.xml,cata:function(a,b,c,d,e,f){return a.match({json:b,blob:c,text:d,html:e,xml:f})}},hL=function(a,b){var c=
  -1===a.indexOf("?")?"?":"&";return b?a+c+"apiKey="+encodeURIComponent(b):a},iL=function(a){return a.hasOwnProperty("tiny-api-key")?a["tiny-api-key"]:a.hasOwnProperty("tinymce-api-key")?a["tinymce-api-key"]:a["textbox-api-key"]},jL=function(a){return a.fold(function(a){var b=a.responseText();a=ic(b)?b:a.message();return J.error(a)},J.value)},km={get:function(a,b,c,d){var e=iL(d);return{execute:function(f){f=Oe(a+".ajax.service.get",b,f);f=eb(f,function(a){return Ym(a)?String(a):a});f=hL(wB(c,f),e);
  return Ae.get(f,Be.json(),he.xhr(),d).map(jL)}}},post:function(a,b,c,d){var e=iL(d);return{execute:function(f){f=Oe(a+".ajax.service.post",b,f);return Ae.post(hL(c,e),yB.json(f),Be.json(),he.xhr(),d).map(jL)}}}},Qaa={partition:function(a,b,c,d,e){return!0===e?{known:{},unknown:c}:hb(c,function(c,e){var f=d(e);return a(b,f).fold(function(){return{known:c.known,unknown:c.unknown.concat([e])}},function(a){a=gc(f,a);return{known:ua(c.known,a),unknown:c.unknown}})},{known:{},unknown:[]})}},Raa=function(a,
  b,c,d,e,f,h){a=a(d,h);return hf.mapSync(a,function(a){a=e(a);Ma(a,function(a,c){b.set(c,a,f)});return oa(c,a)})},lm={single:function(a,b,c,d,e){return(!0===e?g.none():b.get(d,c)).fold(function(){return a(c,e).map(function(a){return a.map(function(a){b.set(c,a,d);return a})})},function(a){return hf.pure(a)})},multiple:function(a,b,c,d,e,f,h){c=Qaa.partition(b.get,f,c,e,h);return 0===c.unknown.length?hf.pure(c.known):Raa(a,b,c.known,c.unknown,d,f,h)}},za=function(a){return Dc(a,a,qg(),tv())},dp=function(a,
  b){return Dc(a,a,qg(),b)},Saa=function(a,b){return Dc(a,a,Wk(),Ii(function(c){return J.error("The field: "+a+" is forbidden. "+b)}))},cl=function(a,b){return Dc(a,a,qg(),Cc(b))},Dd=function(a){return Dc(a,a,Wk(),tv())},kL=function(a,b){return Dc(a,a,Wk(),b)},dl=function(a,b){return Dc(a,a,Wk(),Cc(b))},da=function(a,b){return Dc(a,a,Ne.defaultedThunk(k(b)),tv())},Taa=function(a,b,c){return Dc(a,a,Ne.defaultedThunk(k(b)),Cc(c))},sg=function(a,b){return Zk(a,b)},ep=function(a){return"["+a.join(", ")+
  "]"},lL=["iframely","oembed","fallback"],fp=function(a,b,c){return Xa(b,function(b){return U(a,b)})?J.error("Embed response source: "+ep(a)+" contains more than one of "+ep(lL)):J.value(c)},Uaa={iframely:k("iframely"),oembed:k("oembed"),fallback:k("fallback"),identify:function(a){return U(a,"iframely")?fp(a,["oembed","fallback","wikipedia"],"iframely"):U(a,"oembed")?fp(a,["iframely","fallback","wikipedia"],"oembed"):U(a,"fallback")?fp(a,["iframely","oembed","wikipedia"],"fallback"):U(a,"wikipedia")?
  fp(a,["iframely","oembed","fallback"],"wikipedia"):J.error("Embed response source: "+ep(a)+" did not contain any of: "+ep(lL))}},Vaa=Cc([za("url"),za("maxWidth"),da("fresh",!1)]),Waa=Cc([za("status_code"),za("sub_code"),za("msg")]),Xaa=Cc([za("html"),cl("rels",[Dc("source","source",qg(),XK(function(a){return Mb(a)?Uaa.identify(a):J.error("Sources was not an array: "+a)}))])]),ar={requestOne:k(Vaa),responseFailed:k(Waa),responseSucceeded:k(Xaa)},kz={failed:function(a){return rg("EmbedResponse.failure",
  ar.responseFailed(),a).fold(function(a){return J.error({code:k(600),subcode:k(0),msg:k(Zo(a))})},function(a){return J.error({code:a.status_code,subcode:a.sub_code,msg:a.msg})})},success:function(a){return rg("EmbedResponse.success",ar.responseSucceeded(),a).fold(function(a){return J.error({code:k(601),subcode:k(0),msg:k(Zo(a))})},function(a){return J.value({recommended:k({html:a.html,source:a.rels().source})})})}},Gf=B.resolve("embed-checking"),br={configure:function(a){a.add(a.input(),Gf,Ta.removeClass(Gf));
  a.add(a.output(),Gf,Ta.removeClass(Gf));a.add(a.history(),Gf,Ta.removeClass(Gf));a.add(a.internal(),Gf,Ta.removeClass(Gf))},embedChecking:k(Gf)},uv=function(){return x.translate("link.anchor.top")},vv=function(){return x.translate("link.anchor.bottom")},mL=function(){var a={};a[uv().toLowerCase()]="top";a[vv().toLowerCase()]="bottom";return a},sb={bookmarkDataAttr:k("data-textbox-bookmark"),bookmarkAnchorDataAttr:k("data-textbox-bookmark-anchor"),bookmarkBookmarkDataAttr:k("data-textbox-user-bookmark"),
  topAnchorUrl:uv,bottomAnchorUrl:vv,top:k("top"),bottom:k("bottom"),reservedUrls:mL,isReservedUrl:function(a){return mL().hasOwnProperty(a.toLowerCase())},getReservedUrl:function(a){var b={};b.top=uv();b.bottom=vv();return b[a.toLowerCase()]}},Yaa={setCss:function(a,b,c){a.dom().styleSheet?a.dom().styleSheet.cssText=b:y.append(a,c)}},Zaa={escape:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}},nL=function(a,b,c){b=new RegExp("url\\(\\s*['\"]?"+Zaa.escape(b)+"(.*?)['\"]?\\s*\\)","g");
  return a.replace(b,'url("'+c+'$1")')},$aa={replace:nL,replaceMany:function(a,b){var c=a;Ma(b,function(a,b){console.log("rm css",c);c=nL(c,b,a)});return c}},oL={stylesheets:function(a){a=a.dom().styleSheets;return Array.prototype.slice.call(a)},inject:function(a,b,c){var d=p.fromTag("style",c.dom());m.set(d,"type","text/css");a=void 0===b?a:$aa.replaceMany(a,b);Yaa.setCss(d,a,p.fromText(a,c.dom()));c=L.descendant(c,"head").getOrDie();y.append(c,d)}},aba=O("selector","style","raw"),wv=function(a){return ia(a.cssRules,
  function(a){if(a.type===CSSRule.IMPORT_RULE)return wv(a.styleSheet);if(a.type===CSSRule.STYLE_RULE){var b=a.selectorText,d=a.style.cssText;if(void 0===d)throw"WARNING: Browser does not support cssText property";return[aba(b,d,a.style)]}return[]})},pL={extract:wv,extractAll:function(a){return ia(a,wv)}},qL={},rL={exports:qL};(function(a,b,c,d){(function(d){"object"===typeof b&&"undefined"!==typeof c?c.exports=d():"function"===typeof a&&a.amd?a([],d):("undefined"!==typeof window?window:"undefined"!==
  typeof global?global:"undefined"!==typeof self?self:this).EphoxContactWrapper=d()})(function(){return function(){function a(b,c,e){function f(g,k){if(!c[g]){if(!b[g]){var l="function"==typeof d&&d;if(!k&&l)return l(g,!0);if(h)return h(g,!0);k=Error("Cannot find module '"+g+"'");throw k.code="MODULE_NOT_FOUND",k;}k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){return f(b[g][1][a]||a)},k,k.exports,a,b,c,e)}return c[g].exports}for(var h="function"==typeof d&&d,g=0;g<e.length;g++)f(e[g]);return f}
  return a}()({1:[function(a,b,c){a=function(){var a=function(a){var b=a,c={a:0,b:0,c:0},d=[];var e=function(e,f){var h;if(e.test(b)){e=b.match(e);var g=0;for(h=e.length;g<h;g+=1){c[f]+=1;var k=e[g];var l=b.indexOf(k);var q=k.length;d.push({selector:a.substr(l,q),type:f,index:l,length:q});b=b.replace(k,Array(q+1).join(" "))}}};(function(){var a=function(a){var c;if(a.test(b)){a=b.match(a);var d=0;for(c=a.length;d<c;d+=1){var e=a[d];b=b.replace(e,Array(e.length+1).join("A"))}}};a(/\\[0-9A-Fa-f]{6}\s?/g);
  a(/\\[0-9A-Fa-f]{1,5}\s/g);a(/\\./g)})();(function(){var a=/:not\(([^\)]*)\)/g;a.test(b)&&(b=b.replace(a,"     $1 "))})();(function(){var a=/{[^]*/gm,c;if(a.test(b)){a=b.match(a);var d=0;for(c=a.length;d<c;d+=1){var e=a[d];b=b.replace(e,Array(e.length+1).join(" "))}}})();e(/(\[[^\]]+\])/g,"b");e(/(#[^#\s\+>~\.\[:]+)/g,"a");e(/(\.[^\s\+>~\.\[:]+)/g,"b");e(/(::[^\s\+>~\.\[:]+|:first-line|:first-letter|:before|:after)/gi,"c");e(/(:[\w-]+\([^\)]*\))/gi,"b");e(/(:[^\s\+>~\.\[:]+)/g,"b");b=b.replace(/[\*\s\+>~]/g,
  " ");b=b.replace(/[#\.]/g," ");e(/([^\s\+>~\.\[:]+)/g,"c");d.sort(function(a,b){return a.index-b.index});return{selector:a,specificity:"0,"+c.a.toString()+","+c.b.toString()+","+c.c.toString(),specificityArray:[0,c.a,c.b,c.c],parts:d}};return{calculate:function(b){var c,d=[];b=b.split(",");var e=0;for(c=b.length;e<c;e+=1){var f=b[e];0<f.length&&d.push(a(f))}return d},compare:function(b,c){var d;if("string"===typeof b){if(-1!==b.indexOf(","))throw"Invalid CSS selector";b=a(b).specificityArray}else if(Array.isArray(b)){if(4!==
  b.filter(function(a){return"number"===typeof a}).length)throw"Invalid specificity array";}else throw"Invalid CSS selector or specificity array";if("string"===typeof c){if(-1!==c.indexOf(","))throw"Invalid CSS selector";c=a(c).specificityArray}else if(Array.isArray(c)){if(4!==c.filter(function(a){return"number"===typeof a}).length)throw"Invalid specificity array";}else throw"Invalid CSS selector or specificity array";for(d=0;4>d;d+=1){if(b[d]<c[d])return-1;if(b[d]>c[d])return 1}return 0}}}();"undefined"!==
  typeof c&&(c.calculate=a.calculate,c.compare=a.compare)},{}],2:[function(a,b,c){a=a("specificity");b.exports={boltExport:a}},{specificity:1}]},{},[2])(2)})})(void 0,qL,rL,void 0);var bba=rL.exports.boltExport,sL=O("selector","raw"),cba=function(a,b){var c={};z(a,function(d){if(void 0!==a[d]){var e=b.dom().style;U(e,d)||(c[d]=a[d])}});return c},dba=function(a,b){b=ia(b,function(b){var c=Y.descendants(a,b.selector());z(c,function(a){var c=cba(b.raw(),a);v.setAll(a,c)});return c});z(b,function(a){m.remove(a,
  "class")})},tL=function(a,b){var c=function(a){return-1!==a.selector().indexOf(",")},d=ia(ka(a,c),function(a){var b=a.selector().split(",");return E(b,function(b){b=b.trim();return sL(b,a.raw())})});a=ka(a,function(a){return!c(a)}).concat(d);a.sort(function(a,b){return bba.compare(a.selector(),b.selector())}).reverse();dba(b,a)},uL={inlineStyles:function(a,b,c){a=oL.stylesheets(a);a=pL.extractAll(a).map(function(a){var b=a.selector();b=c.hasOwnProperty(b)?c[b]:b;return sL(b,a.raw())});tL(a,b)},inlinePrefixedStyles:function(a,
  b,c){a=oL.stylesheets(a);a=pL.extractAll(a);a=ka(a,function(a){return Gb(a.selector(),c)});tL(a,b)}},lz={inlineStyles:function(a,b,c){uL.inlineStyles(a,b,c)},inlinePrefixedStyles:function(a,b,c){uL.inlinePrefixedStyles(a,b,c)}},iV=function(a){a=qe.fromHtml(a);if(1===a.length)return a[0];var b=p.fromTag("div");P.append(b,a);return b},rm={handle:function(a,b){return K.bind(a,"click",b)}},eba={editor:function(a,b){b=u(x.translate,b?"aria.label.fullscreen":"aria.label.editor");return a.fold(ca,b)}},fba=
  function(a,b){var c=Mr(b,500);return function(){Vh(c)}},gba=function(a,b){var c=new window.MutationObserver(b);c.observe(A.owner(a).dom(),{attributes:!0,subtree:!0,childList:!0,attributeFilter:["style","class"]});return function(){c.disconnect()}},hba=void 0!==window.MutationObserver&&null!==window.MutationObserver?gba:fba,xz={onShow:function(a,b){if(sc.isVisible(a))return im.requestAnimationFrame(b),t;var c=jf(function(){sc.isVisible(a)&&(d(),im.requestAnimationFrame(b))},100),d=hba(a,c.throttle);
  return d}},el=[],xv=function(a){return Va(el,function(b){return N.eq(b.element,a)}).getOr(-1)},yv={begin:function(a,b){-1===xv(a)&&(b=b(),el.push({element:a,unbind:b}))},query:function(a){a=xv(a);return-1===a?g.none():g.some(el[a])},end:function(a){a=xv(a);if(-1!==a){var b=el[a];el.splice(a,1);b.unbind()}}},iba=function(a){return{element:a,handlers:[],lastWidth:Ga.get(a),lastHeight:sa.get(a)}},Hf=[],vL=function(a){return Va(Hf,function(b){return N.eq(b.element,a)}).getOr(-1)},wL=function(a){var b=
  Ga.get(a.element),c=sa.get(a.element);if(b!==a.lastWidth||c!==a.lastHeight)a.lastWidth=b,a.lastHeight=c,z(a.handlers,xb)},xL=function(a){var b=a.element;sc.isVisible(b)?wL(a):yv.begin(b,function(){return xz.onShow(b,function(){yv.end(b);wL(a)})})},zv=!1,jba=function(){zv=!1;z(Hf,xL)},kba=function(){zv||(zv=!0,im.requestAnimationFrame(jba))},gp=g.none(),lba=function(){gp.each(function(a){a.unbind();gp=g.none()})},nz={bind:function(a,b){var c=qa(Hf,function(b){return N.eq(b.element,a)}).getOr(void 0);
  void 0===c&&(c=iba(a),Hf.push(c));c.handlers.push(b);gp.isNone()&&(gp=g.some(K.bind(p.fromDom(Zg),"resize",kba)));Sg(function(){-1!==vL(c.element)&&xL(c)},100)},unbind:function(a,b){yv.end(a);a=vL(a);-1!==a&&(b=Gc(Hf[a].handlers,b),b.isNone()||(Hf[a].handlers.splice(b.getOr(0),1),0===Hf[a].handlers.length&&Hf.splice(a,1),0===Hf.length&&lba()))}},oz=aa.detect(),mba=k(!1),nm=aa.detect(),yL=nm.browser.isIE()||nm.browser.isEdge()?2:5,qz=ta.generate([{above:["element"]},{below:["element"]}]),zL=function(a,
  b,c){return function(b){b=Wa.forElement(a,b);b=Kc.exactFromRange(b);return Wa.getBounds(a,b).fold(mba,c)}},kV=function(a,b){return zL(a,b,function(a){return b>a.top()+a.height()-yL})},lV=function(a,b){return zL(a,b,function(a){return b<a.top()+yL})},ac={clearAll:function(a){Wa.clear(a)},get:function(a){return Wa.getExact(a).map(function(a){return Rc(a.start(),a.soffset(),a.finish(),a.foffset())})},set:function(a,b){Wa.setExact(a,b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset())},
  setExact:function(a,b,c,d,e){Wa.setExact(a,b,c,d,e)},setRelative:function(a,b,c){Wa.setRelative(a,b,c)},replace:function(a,b){Wa.get(a).each(function(c){Wa.replace(a,c,b)})}},mV=function(a,b){var c=u(N.eq,ja.body()),d=b.join(", ");return yc(a,function(a){return Ja.ancestor(a,function(a){return Ia.is(a,d)},c)}).isSome()},nba=function(a,b){return{toEditor:a,toOld:u(Z.focus,b),isSet:function(){return Z.active().exists(function(a){return N.eq(a,b)})}}},AL=function(a,b,c,d){d=d.dom().activeElement;return a()?
  {toEditor:b,toOld:t,isSet:k(!0)}:void 0===d||null===d?{toEditor:c,toOld:t,isSet:k(!1)}:nba(c,p.fromDom(d))},cr={build:AL,toEditor:function(a,b,c,d){AL(a,b,c,d).toEditor()}},oba=function(a){return Db.closest(a.startContainer(),'[contenteditable="false"]')&&Db.closest(a.endContainer(),'[contenteditable="false"]')},tz={focus:function(a,b,c){b=b().filter(oba);b.each(function(b){L.closest(b.endContainer(),'[contenteditable="false"]').each(function(b){ac.setRelative(a.win(),la.after(b),la.after(b))})});
  a.focus();b.each(function(a){c(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset())})}},pV=aa.detect(),pba=O("doc","href"),rV=function(){var a=[],b=function(a,b){return function(c){return N.eq(a,c.doc())&&b===c.href()}};return{addLinkIfMissing:function(c,d){Xa(a,b(c,d))||(a.push(pba(c,d)),nC.addStylesheet(d,c))}}}(),uz=function(){console.log("The previous selection could not be restored. Defaulting to the current selection.")},Av=aa.detect(),qba=Av.deviceType.isiOS()?yV:Av.deviceType.isAndroid()?
  wV:xV,BV={get:function(a){return qba(a,Av)}},rba=function(a){a=a.dom();try{var b=a.contentWindow?a.contentWindow.document:a.contentDocument;return void 0!==b&&null!==b?g.some(p.fromDom(b)):g.none()}catch(c){return console.log("Error reading iframe: ",a),console.log("Error was: "+c),g.none()}},vz={doc:function(a){return rba(a).fold(function(){return a},function(a){return a})}},AV=aa.detect(),DV={resolve:Lb.create("ephox-hare").resolve},wz={write:function(a,b){if(!ja.inBody(a))throw"Internal error: attempted to write to an iframe that is not in the DOM";
  a=vz.doc(a).dom();a.open("text/html","replace");a.writeln(b);a.close()}},EV=function(a){var b=a.base.fold(k(""),function(a){return'<base href="'+a+'" />'}),c=a.editorStyles.concat(a.stylesheets),d=E(c,function(a){return'<link rel="stylesheet" type="text/css" href="'+a+'" onload="styleLoaded()" onerror="styleLoaded()" />'});a=0===a.documentStyles.length?"":'<style type="text/css">'+a.documentStyles+"</style>";return"<!doctype html>\n<html>\n  <head>\n    "+b+'\n    <script type="text/javascript">\n      var stillToLoad = '+
  c.length+";\n      function styleLoaded() {\n        stillToLoad--;\n      }\n    \x3c/script>\n    "+d.join("")+"\n    "+a+'\n  </head>\n  <body contenteditable="true" spellcheck="false"></body>\n</html>'},BL=function(a){var b=g.none(),c=Hd.tap(function(a,b,c){n.trigger.nodeChanged(a,b,c)});a.loaded(function(a){var d=function(){try{return null!==a.win().window&&void 0!==a.win().window}catch(X){return!1}};if(d()){b=g.some(a);if(aa.detect().browser.isFirefox()){try{a.execCommand("enableObjectResizing",
  !1,!1)}catch(X){}try{a.execCommand("enableInlineTableEditing",!1,!1)}catch(X){}}a.events.nodeChanged.bind(function(a){c.instance(a.node(),a.offset(),a.prev())});a.events.loiter.bind(function(a){n.trigger.loiter(a.node(),a.offset())});a.events.uiStale.bind(function(){n.trigger.uiStale()});a.events.domChanged.bind(function(){n.trigger.domChanged()});a.events.interaction.bind(function(){n.trigger.interaction()});a.events.keyup.bind(function(a){n.trigger.keyup(a.original())});a.events.keydown.bind(function(a){n.trigger.keydown(a.original())});
  a.events.keypress.bind(function(a){n.trigger.keypress(a.original())});a.events.mousedown.bind(function(a){n.trigger.mousedown(a.original())});a.events.mouseup.bind(function(a){n.trigger.mouseup(a.original())});a.events.contextmenu.bind(function(a){n.trigger.contextmenu(a.original())});a.events.cut.bind(function(a){n.trigger.cut(a.original())});a.events.copy.bind(function(a){n.trigger.copy(a.original())});a.events.paste.bind(function(a){n.trigger.paste(a.original())});a.events.focus.bind(function(a){n.trigger.focus(a.original())});
  a.events.focusOut.bind(function(a){n.trigger.focusOut(a.original())});a.events.dblclick.bind(function(a){n.trigger.dblclick(a.original())});a.events.selectionchange.bind(function(a){n.trigger.selectionchange(a.original())});a.futures.stylesheetLoad.get(function(a){a.each(function(a){n.trigger.stylesheetLoad(a)})});a.events.paint.bind(function(){n.trigger.paint()});a.resetContent(f);d()&&(n.trigger.ready(a),n.trigger.loaded(),a.uiChanged())}else a.destroy()});var d=function(){return b.map(function(a){return a.win()})},
  e=function(){return b.map(function(a){return a.doc()})},f=a.initial(),h=function(){b.each(function(a){a.focus()})},l=function(){return b.bind(function(a){return a.getSelection()})},q=function(a,c,d,e){b.each(function(b){b.setSelection(a,c,d,e)})},m=function(a,c){b.each(function(b){b.setRelativeSelection(a,c)})},w=function(){var a=arguments;b.each(function(b){b.execCommand.apply(null,a)})},n=H.create({nodeChanged:r(["node","offset","prev"]),loiter:r(["node","offset"]),uiStale:r([]),domChanged:r([]),
  interaction:r([]),keydown:r(["original"]),keyup:r(["original"]),keypress:r(["original"]),mousedown:r(["original"]),mouseup:r(["original"]),contextmenu:r(["original"]),cut:r(["original"]),copy:r(["original"]),paste:r(["original"]),focus:r(["original"]),focusOut:r(["original"]),dblclick:r(["original"]),selectionchange:r(["original"]),paint:r([]),ready:r(["api"]),loaded:r([]),stylesheetLoad:r(["sheets"])});return{element:a.element,tabindex:a.tabindex,onCanvas:a.onCanvas,win:d,doc:e,body:function(){return b.map(function(a){return a.body()})},
  getContent:function(){return b.fold(function(){return f},function(a){return a.getContent()})},setContent:function(a){b.fold(function(){f=a},function(b){b.setContent(a)})},resetContent:function(a){b.fold(function(){f=a},function(b){b.resetContent(a)})},blur:function(){b.each(function(a){a.blur()})},focus:h,uiChanged:function(){b.each(function(a){a.uiChanged()})},domChanged:function(){b.each(function(a){a.domChanged()})},clearSelection:function(){b.each(function(a){a.clearSelection()})},getSelection:l,
  setSelection:q,setRelativeSelection:m,backupSelection:function(){b.each(function(a){a.backupSelection()})},replaceSelection:function(a){b.each(function(b){b.replaceSelection(a)})},execCommand:w,lockdown:function(a){var b=c.control.isBlocked();c.control.block();a();b||c.control.unblock()},destroy:function(){a.destroy();b=g.none()},events:n.registry,background:function(){b.each(function(a){a.background()})},foreground:function(){b.each(function(a){a.foreground()})},on:function(a){return d().bind(function(b){return e().map(function(c){return a({win:k(b),
  doc:k(c),execCommand:w,getSelection:l,setSelection:q,setRelativeSelection:m,focus:h})})})},translateScreen:function(a,c){return b.fold(function(){return Qa(a,c)},function(b){return b.translateScreen(a,c)})},translateLocation:function(a,c){return b.fold(function(){return Qa(a,c)},function(b){return b.translateLocation(a,c)})},placeholder:a.placeholder,isInline:a.isInline}},CL={frame:function(a,b){a=FV(a,b);return BL(a)},detached:function(a,b,c){a=qV(a,b,c);return BL(a)}},DL=aa.detect(),EL=DL.browser,
  sba=!(EL.isEdge()&&16>EL.version.major||DL.deviceType.isiOS()),tba=function(a,b){if(sba&&void 0!==a&&qb(a.setData))try{return Ma(b,function(b,d){a.setData(d,b())}),!0}catch(c){return!1}else return!1},uba=function(a,b,c){var d=p.fromTag("div",a.doc().dom());v.setAll(d,{position:"absolute",top:"-1000px"});b=b["text/html"]();Ha.set(d,b);b=Ia.all("a,img",d);var e=function(a,b,c){b=m.get(a,b);Bb(b,"://")||m.set(a,c,b)};z(b,function(a){"a"===D.name(a)&&m.has(a,"href")?e(a,"href","data-ephox-href"):"img"===
  D.name(a)&&m.has(a,"src")&&e(a,"src","data-ephox-src")});y.append(a.body(),d);var f=a.getSelection();Wa.setToElement(a.win(),d);setTimeout(function(){F.remove(d);f.each(function(b){a.setSelection(b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset())});setTimeout(c,0)},0)},vba=function(a){return function(b,c,d){var e=b.raw();if(!xa(e.type)||"copy"!==e.type.toLowerCase()&&"cut"!==e.type.toLowerCase())throw"Can only set the clipboard with a cut or copy event";if(!qb(c["text/html"]))throw"Must provide at least text/html data function when setting clipboard contents";
  tba(e.clipboardData,c)?(b.kill(),setTimeout(d,0)):a(c,d)}},wba=xd(["doc","win","body","getSelection","setSelection"]),Bv={register:function(a){wba(a);a=u(uba,a);return{setClipboard:vba(a)}},textMime:k("text/plain"),htmlMime:k("text/html")},Cv=$x(D.isComment,"comment"),Dv={get:function(a){return Cv.get(a)},getOption:function(a){return Cv.getOption(a)},set:function(a,b){Cv.set(a,b)}},Sj={intraFlag:k({findClipboardTags:function(a){a=ee(E(a,function(a){if(D.isComment(a)){var b=Dv.get(a);if(Bb(b,"x-textbox/html"))return g.some(a)}return g.none()}));
  return 0===a.length?g.none():g.some(a)}}),buildClipboardContents:function(a,b){var c={};c[Bv.textMime()]=Zb(a);c[Bv.htmlMime()]=Zb(function(){return"\x3c!-- x-textbox/html --\x3e"+b()});return c},ignoreSelectors:k([".ephox-sloth-bin"])},FL=function(a,b){return{editable:k(a),connect:b}},xba=function(a,b){var c=CL.frame(b,Sj.ignoreSelectors());c.events.ready.bind(function(b){b=b.api().body();a.updateUi(b)});return FL(c,function(a){y.append(a,c.element())})},yba=function(a,b){0!==b.stylesheets.length&&
  console.log("You have attempted to declare the following stylesheets for use in textbox.io: ["+b.stylesheets.join(", ")+"]. User stylesheets are not used in inline editing mode and have been ignored.");0!==b.documentStyles.length&&console.log('You have attempted to declare the following document styles for use in textbox.io: "'+b.documentStyles+'". Document styles are not used in inline editing mode and have been ignored.');b.base.fold(t,function(a){console.log('You have attempted to declare the following content base URL for use in textbox.io: "'+
  a+'". Content base URL is not used in inline editing mode and has been ignored.')});var c=CL.detached(b.inline,b.editorStyles,Sj.ignoreSelectors());return FL(c,function(a){y.append(a,c.placeholder());a=L.ancestor(a,".ephox-polish-editor-container").getOr(a);v.set(c.placeholder(),"display","none");ma.add(a,[B.resolve("inline-editor-container"),B.resolve("layer-editor")])})},zba={build:function(a,b){return(void 0!==b.inline?yba:xba)(a,b)}},Aba=aa.detect().browser.isFirefox(),Bba=function(a){z(a,function(a){A.nextSibling(a).isNone()&&
  y.after(a,p.fromText(mb()))})},Cba={configure:function(a){Aba&&a.addSelector(a.input(),"a",Bba)}},hp=B.resolve("content-eph-wrapper"),ip=B.resolve("content-eph-extra"),jp=B.resolve("content-eph-general"),Dba=function(a){z(a,function(a){n.remove(a,Rb.styleSpan());m.remove(a,Rb.overrideSpan());m.hasNone(a)?F.unwrap(a):qd.isTransient(a)&&F.remove(a)})},GL=function(a){z(a,function(a){n.remove(a,Rb.quasiBlock())})},HL=function(a){z(a,function(a){var b=m.get(a,"style");m.set(a,"style",b.replace(/"/g,"'"))})},
  Eba=function(a){return wa.isCursorPosition(a)||pa.isBlock(a)||wa.isCursorPosition(kb.freefallLtr(a).element())},IL=function(a){z(a,function(a){if(0===ka(A.children(a),Eba).length){var b=p.fromTag("br");y.append(a,b)}})},kp={configure:function(a){a.add(a.internal(),hp,Ta.unwrap);a.add(a.internal(),ip,Ta.remove);a.add(a.internal(),jp,Ta.remove);a.add(a.internal(),Rb.quasiBlock(),GL);a.add(a.output(),hp,Ta.unwrap);a.add(a.output(),ip,Ta.remove);a.add(a.output(),jp,Ta.remove);a.add(a.output(),Rb.styleSpan(),
  Dba);a.add(a.output(),Rb.quasiBlock(),GL);a.addExcludedContext(["."+hp,"."+ip,"."+jp,"."+Rb.styleSpan()]);a.addSelector(a.input(),"[style]",HL);a.addSelector(a.input(),"td,th,p",IL);a.addSelector(a.paste(),"[style]",HL);a.addSelector(a.paste(),"td,th,p",IL);a.addSelector(a.output(),"strong,b,em,i,u,s,strike,del,sup,sub",Ta.removeIfEmpty);Cba.configure(a)},markerWrapper:k(hp),markerExtra:k(ip),markerGeneral:k(jp)},tg={resolve:Lb.create("ephox-cereal").resolve},Ev=tg.resolve("start-cursor"),Fv=tg.resolve("finish-cursor"),
  Gv="data-"+tg.resolve("start-offset"),Hv="data-"+tg.resolve("finish-offset"),JL=function(a){m.remove(a,Gv);m.remove(a,Hv);ma.remove(a,[Ev,Fv]);""===m.get(a,"class")&&m.remove(a,"class")},KL=function(a,b){a=m.get(a,b);return parseInt(a,10)},Ki={setInfo:function(a,b,c,d){z([a,b],JL);n.add(a,Ev);n.add(b,Fv);m.set(a,Gv,c);m.set(b,Hv,d)},clearInfo:JL,findStart:function(a){return L.descendant(a,"."+Ev).map(function(a){return{token:k(a),offset:k(KL(a,Gv))}})},findFinish:function(a){return L.descendant(a,
  "."+Fv).map(function(a){return{token:k(a),offset:k(KL(a,Hv))}})}},LL=O("token","remove","extra"),ML={use:function(a,b){return LL(b,t,[])},extract:function(a){return{remove:u(Ki.clearInfo,a),element:k(a)}}},NL=tg.resolve("pre-cursor-token"),OL=tg.resolve("post-cursor-token"),PL=tg.resolve("first-cursor-token"),Iv=function(){var a=p.fromTag("span");v.set(a,"display","none");return a},Jv=function(a){var b=u(F.remove,a);return LL(a,b,[a])},Fba=function(a){return n.has(a,NL)?A.nextSibling(a):n.has(a,OL)?
  A.prevSibling(a):n.has(a,PL)?A.parent(a):g.none()},vh={pre:function(a,b){a=Iv();y.before(b,a);n.add(a,NL);return Jv(a)},post:function(a,b){a=Iv();y.after(b,a);n.add(a,OL);return Jv(a)},first:function(a,b){b=Iv();y.prepend(a,b);n.add(b,PL);return Jv(b)},extract:function(a){return Fba(a).map(function(b){return{remove:u(F.remove,a),element:k(b)}})}},Gba=O("element","offset"),Hba=O("startContainer","startOffset","endContainer","endOffset"),Iba={point:Gba,range:Hba},Kv=tg.resolve("text-node-wrapper"),
  QL=function(a){return n.has(a,Kv)},ug={create:function(){var a=p.fromTag("span");n.add(a,Kv);return a},findIn:function(a){return Y.children(a,"."+Kv)},isWrap:QL,inWrap:function(a){return A.parent(a).fold(k(!1),function(a){return QL(a)})},child:function(a){return A.child(a,0).fold(function(){var b=p.fromText("");y.append(a,b);return b},ca)}},Jba=function(a){a=ug.findIn(a);z(a,function(a){0===A.children(a).length&&y.before(a,p.fromText(""));F.unwrap(a)})},Kba=function(a){A.parent(a).each(F.unwrap)},
  RL=function(a){(ug.inWrap(a)?Kba:Jba)(a)},Lv=function(a,b,c,d){return N.eq(a,b)?vh.first(a,b):D.isElement(b)&&!d(b)?ML.use(a,b):c(a,b)},Mv={extractFrom:function(a,b){a.remove();b.remove();var c=function(a){var b=ug.isWrap(a)?F.unwrap:RL,c=ug.isWrap(a)?ug.child(a):a;return{target:k(c),unwrap:u(b,a)}},d=c(a.element()),e=c(b.element()),f=Iba.range(d.target(),a.offset(),e.target(),b.offset());return{remove:function(){d.unwrap();e.unwrap()},getSelection:function(){return f}}},same:function(a,b,c,d,e){a=
  Lv(a,b,vh.pre,e);Ki.setInfo(a.token(),a.token(),c,d);return[a]},diff:function(a,b,c,d,e,f){var h=hd.after(b,c,d,e),g=h?vh.pre:vh.post;b=Lv(a,b,h?vh.post:vh.pre,f);a=Lv(a,d,g,f);Ki.setInfo(b.token(),a.token(),c,e);return[b,a]}},Lba=function(a){return A.parent(a).fold(k(!1),function(a){return ug.isWrap(a)})},Mba=function(a){return Eb(a,function(a,c){if(D.isText(c)&&!Lba(c)){var b=ug.create();y.wrap(c,b);return[b].concat(a)}return a},[])},Nba=function(a){var b=A.children(a);b=0<b.length?b:[a];return ug.isWrap(a)?
  []:Mba(b)},Oba=function(a){a.remove()},SL={combine:function(a,b){var c=ia(a,Nba),d=ia(b,function(a){return a.extra()});return{extra:k(d),wrappers:k(c),remove:function(){z(b,function(a){Ki.clearInfo(a.token())});z(a,RL);z(b,Oba)}}}},Pba=function(a,b,c,d,e,f){var h=[b,d];a=Mv.diff(a,b,c,d,e,f);return SL.combine(h,a)},Qba=function(a,b,c,d,e,f){d=[b];a=Mv.same(a,b,c,e,f);return SL.combine(d,a)},TL=function(a,b){return b(a).map(function(a){var b=vh.extract(a.token()).getOrThunk(function(){return ML.extract(a.token())});
  return{remove:b.remove,offset:a.offset,element:b.element}})},Rba=function(a){return TL(a,Ki.findStart).bind(function(b){return TL(a,Ki.findFinish).map(function(a){return{startMarker:k(b),finishMarker:k(a)}})})},UL={insertAt:function(a,b,c,d,e,f){return(N.eq(b,d)?Qba:Pba)(a,b,c,d,e,f)},extract:function(a){return Rba(a).map(function(a){return Mv.extractFrom(a.startMarker(),a.finishMarker())})}},VL={insert:function(a,b,c){a=UL.insertAt(a,b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset(),
  c);return{extra:a.extra,wrappers:a.wrappers,remove:a.remove}},extract:function(a){return UL.extract(a).map(function(a){return{remove:a.remove,getSelection:a.getSelection}})}},WL=function(a,b){z(a,function(a){n.add(a,b)})},Sba=function(a){var b=function(){return A.parent(a).map(function(a){return"false"===m.get(a,"contenteditable")}).getOr(!1)};return"false"===m.get(a,"contenteditable")||b()},lp={extract:function(a){return VL.extract(a)},getSelection:function(a){var b=a.getSelection();a=b.startContainer();
  var c=b.startOffset(),d=b.endContainer();b=b.endOffset();var e=wa.getEnd(a),f=wa.getEnd(d);return 0<=c&&c<=e&&0<=b&&b<=f?{start:k(la.on(a,c)),finish:k(la.on(d,b))}:{start:k(la.before(a)),finish:k(la.before(a))}},remove:function(a){a.remove()},serialise:function(a,b){return oi.path(a,b.startContainer()).bind(function(c){return oi.path(a,b.endContainer()).bind(function(d){var e=Oc.deep(a);return oi.follow(e,c).bind(function(a){return oi.follow(e,d).map(function(c){c={startContainer:k(a),startOffset:k(b.startOffset()),
  endContainer:k(c),endOffset:k(b.endOffset())};c=VL.insert(e,c,Sba);WL(c.wrappers(),kp.markerWrapper());WL(c.extra(),kp.markerExtra());return on.writeChildren(e)})})})})}},mp=O("word","left","right"),XL=["'","\u2018","\u2019"],Tba=ia(XL,function(a){return E(["twas"],function(b){return a+b})}),Uba=function(a){var b=a.word();return mp(b.substring(1),g.some(b.charAt(0)),a.right())},np=function(a){return U(XL,a)},Vba=function(a){var b=a.word(),c=Xa(Tba,function(a){return-1<b.indexOf(a)})?2:1,d=b.substring(0,
  c);return ob(d,np)&&!np(b.charAt(c))?Uba(a):a},YL=function(a){var b=a.word();2<=b.length&&np(b.charAt(b.length-1))&&!np(b.charAt(b.length-2))&&(b=a.word(),a=mp(b.substring(0,b.length-1),a.left(),g.some(b.charAt(b.length-1))));return Vba(a)},Wba={scope:YL,text:function(a){a=mp(a,g.none(),g.none());return YL(a).word()}},ZL={words:function(a){var b=Cb.unsafetoken(Cb.wordchar()+"+");b=Ko.findall(a,b);var c=a.length;return E(b,function(b){var d=b.start(),f=b.finish();b=a.substring(d,f);d=0<d?g.some(a.charAt(d-
  1)):g.none();f=f<c?g.some(a.charAt(f)):g.none();b=mp(b,d,f);return Wba.scope(b)})}},$L={identify:function(a){return ZL.words(a)},isWord:function(a,b){return!Ok.hasBreak(b)}},Xba=nb(),Yba={identify:function(a){return $L.identify(a)},isWord:function(a){return $L.isWord(Xba,a)}},Zba=aa.detect(),aM=function(a,b){return D.isText(a)?g.some(W.point(a,b)):0===A.children(a).length?g.none():A.child(a,b).bind(function(a){return aM(a,0)})},$ba=function(a,b,c){a.on(function(a){Ad.expandWord(a,b,c)})},aca=function(a,
  b){a=a.dom().createRange();a.setStart(b.startContainer().dom(),b.startOffset());a.setEnd(b.endContainer().dom(),b.endOffset());return Yba.isWord(a.cloneContents().textContent)},bM={correct:function(a){a.getSelection().each(function(b){a.doc().each(function(c){aca(c,b)&&aM(b.startContainer(),b.startOffset()).each(function(c){(!b.collapsed()||a.isInline()&&Zba.browser.isIE())&&$ba(a,c.element(),c.offset())})})})},expand:function(a){a.on(Ad.expand);a.backupSelection()}},cM=function(a,b){return a.bind(function(a){return a.fold(function(){return Ea.pure(a)},
  function(a){return b(a)})})},dM=function(a){return Ea.pure(J.value(a))},eM=function(a){return Ea.nu(function(b){a.then(function(a){b(J.value(a))},function(a){b(J.error(a))})})},fM=function(a){return a.map(J.value)},Ua={fromPromise:eM,error:function(a){return Ea.pure(J.error(a))},map:function(a,b){return a.map(function(a){return a.map(b)})},bind:cM,pure:dM,fromChain:function(a){return function(b){return hb(a,function(a,b){return cM(a,function(a){return b(a)})},dM(b))}},fromFuture:fM,pToFR:function(a){return Pb(eM,
  a)},fToFR:function(a){return Pb(fM,a)},effect:function(a){return function(b){b.each(function(){a()});return b}}},bca=function(a){return Ea.nu(function(b){if(!0===a.dom().complete)b(J.value(a));else{var c=er();gM(c,b);c.monitor(a)}})},gM=function(a,b){a.events.success.bind(function(a){b(J.value(a.image()))});a.events.fail.bind(function(a){b(J.error("Unable to download image "+a.url()))})},op={load:function(a){return Ea.nu(function(b){var c=er();gM(c,b);c.go(a)})},loadIfNeeded:function(a){return!0===
  a.dom().complete||void 0===m.get(a,"src")?Ua.pure(a):bca(a)}},Li={text:function(a){a=A.children(a);return pn.toText(a)},html:function(a,b){var c=p.fromTag("div");y.append(c,a);return Vj.output(b,c)},fragment:function(a,b){if(b.collapsed())return g.none();b=Kc.exact(b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset());a=Wa.clone(a,b);return g.some(a)}},hM=aa.detect(),cca=function(a,b,c,d,e){kp.configure(a);var f=g.none(),h={inline:c.inline,base:g.from(c.base),editorStyles:[c.css+"/content.css"],
  stylesheets:c.stylesheets,documentStyles:c.documentStyles,needStyles:c.showDocumentStyles,autoresize:c.autoresize};d=zba.build(d,h);var l=d.editable();null!==c.tabindex&&l.tabindex(c.tabindex);void 0!==e.raw&&l.setContent(e.raw);l.events.ready.bind(function(){if(void 0!==e.raw){var a=l.getContent();e.raw===a&&e.marked!==e.raw&&C(e.marked,!1)}a=l.body().getOrDie();f=g.some(K.bind(a,"dblclick",function(a){bM.correct(l)}))});l.events.ready.bind(function(a){Xr.addClasses(a.api().body())});var q=function(){return l.getSelection().bind(function(a){var b=
  l.body().getOrDie("content should not return a selection if body is not yet available");return lp.serialise(b,a)}).getOr(l.getContent())},C=function(a,b){l.body().each(function(c){l.setContent(a);lp.extract(c).fold(function(){var a=kb.freefallLtr(c);l.setSelection(a.element(),a.offset(),a.element(),a.offset())},function(a){var b=lp.getSelection(a);lp.remove(a);l.setRelativeSelection(b.start(),b.finish())});if(!hM.deviceType.isiOS()){var d=Y.descendants(c,"img");b?Ce(d,op.loadIfNeeded).get(function(){x()}):
  x()}})},w=H.create({nodeChanged:r(["node","offset","prev"]),undoChanged:r([]),loiter:Q(["node","offset"],l.events.loiter),uiStale:Q([],l.events.uiStale),domChanged:Q([],l.events.domChanged),interaction:Q([],l.events.interaction),keydown:Q(["original"],l.events.keydown),keyup:Q(["original"],l.events.keyup),keypress:Q(["original"],l.events.keypress),mousedown:Q(["original"],l.events.mousedown),mouseup:Q(["original"],l.events.mouseup),contextmenu:Q(["original"],l.events.contextmenu),copy:Q(["original"],
  l.events.copy),paste:Q(["original"],l.events.paste),focus:Q(["original"],l.events.focus),focusOut:Q(["original"],l.events.focusOut),dblclick:Q(["original"],l.events.dblclick),selectionchange:Q(["original"],l.events.selectionchange),paint:Q([],l.events.paint),ready:Q(["api"],l.events.ready),loaded:Q([],l.events.loaded),stylesheetLoad:Q(["sheets"],l.events.stylesheetLoad),background:r([]),foreground:r([]),scrollToCursor:r([]),scrollToElement:r(["element"]),toEditing:r([]),toReading:r([])});l.events.nodeChanged.bind(function(a){w.trigger.nodeChanged(a.node(),
  a.offset(),a.prev());a.prev().fold(v,function(b){Ja.ancestor(b,pa.isBlock).each(function(b){Ja.ancestor(a.node(),pa.isBlock).each(function(a){N.eq(a,b)||v()})})})});var t=Hd.tap(function(){w.trigger.undoChanged()}),v=function(){t.instance()},z=function(a){t.instance();var b=t.control.isBlocked();t.control.block();a=a();b||t.control.unblock();t.instance();return a},x=function(){w.trigger.scrollToCursor()},B=Hd.tap(function(){l.focus()});h=function(a){return function(){var b=arguments;A.parent(l.element()).fold(function(){a.apply(null,
  b)},function(c){var d=c.dom().scrollTop;a.apply(null,b);c.dom().scrollTop=d})}}(l.execCommand);var E=function(a){return D.isText(a)&&(hM.browser.isSafari()||0===Ya.get(a).length)||D.isElement(a)&&!pa.isEmptyTag(a)&&!pa.isBlock(a)},J=function(a){var b=p.fromText(mb());y.after(a,b);return b},L=function(a,b){var c=A.children(a);if(b>=c.length)return W.point(a,b);var d=c[b];return D.isElement(d)&&!pa.isEmptyTag(d)?L(c[b],0):W.point(a,b)},M=function(a){a=E(a)?J(a):a;l.setRelativeSelection(la.after(a),
  la.after(a));l.getSelection().each(function(a){a=L(a.startContainer(),a.startOffset());l.setSelection(a.element(),a.offset(),a.element(),a.offset())})},O=function(){return P.getSelection().bind(function(a){return P.win().bind(function(b){return Li.fragment(b,a)})})},P={onCanvas:l.onCanvas,element:l.element,isInline:l.isInline,win:l.win,doc:l.doc,body:l.body,getContent:l.getContent,setContent:l.setContent,resetContent:l.resetContent,focus:function(){B.instance()},blur:l.blur,uiChanged:l.uiChanged,
  domChanged:l.domChanged,undoChanged:v,clearSelection:l.clearSelection,getSelection:l.getSelection,getSelectionStart:function(){return l.getSelection().map(function(a){return a.startContainer()})},setSelection:l.setSelection,setRelativeSelection:l.setRelativeSelection,backupSelection:l.backupSelection,replaceSelection:l.replaceSelection,replaceElement:function(a,b){var c=P.getSelection().filter(function(b){var c=u(N.eq,a);return Ja.closest(b.startContainer(),c)||Ja.closest(b.endContainer(),c)}).isSome();
  y.before(a,b);F.remove(a);c&&M(b);P.domChanged();v()},findTagAtCursor:function(b){var c=function(b,c,d){b=A.child(b,c).getOr(b);return Ja.closest(b,function(b){return Ia.is(b,d)&&a.includeContext(b)})};return P.getSelection().bind(function(a){return c(a.startContainer(),a.startOffset(),b).orThunk(function(){return c(a.endContainer(),a.endOffset(),b)})})},getFilteredAttributes:function(b){b=Oc.shallow(b);var c=p.fromTag("div");y.append(c,b);a.filterDom(a.output(),c);return m.clone(b)},execCommand:h,
  insertHtmlAtCursor:function(a){var c=qe.fromHtml(a);z(function(){rd.insertAtCursorWithInstructions(pg.doNotMerge,P,c).each(function(a){if(0===c.length)l.setSelection(a.element(),a.offset(),a.element(),a.offset());else{var d=a.element();A.parent(d).each(function(a){M(d);b.input(c)})}})})},on:l.on,destroy:function(){f.each(function(a){a.unbind()});l.destroy()},events:w.registry,state:function(){return{raw:l.getContent(),marked:q()}},serialize:q,deserialize:function(a){C(a,!0)},background:function(){l.background();
  w.trigger.background()},foreground:function(){l.foreground();w.trigger.foreground()},isRoot:function(a){return l.body().fold(k(!1),function(b){return N.eq(b,a)})},selectWord:function(){bM.expand(l)},cursor:function(){return GV(l)},activate:function(){B.control.unblock()},deactivate:function(){B.control.block()},cursorIntoView:x,elementIntoView:function(a){w.trigger.scrollToElement(a)},placeholder:l.placeholder,connect:d.connect,translateScreen:l.translateScreen,translateLocation:l.translateLocation,
  runOrOnLoaded:function(a){l.body().fold(function(){l.events.ready.bind(function(b){a(b.api().body())})},function(b){a(b)})},getSelectedText:function(){return O().map(Li.text)},getSelectedHtml:function(){return O().map(function(b){return Li.html(b,a)})},getFilteredContents:function(b){return Vj.output(a,b)},toEditing:function(){w.trigger.toEditing()},toReading:function(){w.trigger.toReading()},undoOperation:z,markAsEphemeral:function(a){n.add(a,kp.markerGeneral())},hideInlineSelection:function(){l.isInline()&&
  (l.backupSelection(),l.clearSelection())},imageExcludes:c.imageExcludes};return P},dca={get:k({onShortcut:function(a,b){a.bind(b)}})},iM="data-"+B.resolve("context-type"),fr={nu:function(a,b,c){a=zb.item(a,c.value(),c.text());m.set(a,iM,b);m.setAll(a,c.attrs());return a},type:function(a){return m.get(a,iM)}},IV={derive:function(a,b,c){b=E(b,function(b){var d=c[b],f=d.primary(),h=d.submenus();return E(f,function(c){var d=fr.nu(a,b,c),e=h.hasOwnProperty(c.value())&&void 0!==h[c.value()]?[va.resolve("menu-more")]:
  [],f=void 0!==h[c.value()];S.menuItem(d,g.some(c.text()),g.some(f));ma.add(d,e);return d})});b=ka(b,function(a){return 0<a.length});return Qb(ID(b,function(){return[zb.separator(a)]}))}},JV={derive:function(a,b,c){return ia(b,function(b){var d=c[b].secondary();return E(d,function(c){var d=zb.submenu(a,c.value(),[]);S.menu(d,x.get(c.textkey()));c=E(c.items(),function(c){var d=fr.nu(a,b,c);S.menuItem(d,g.some(c.text()),g.none());return d});P.append(d,c);return d})})}},jM={mainmenu:function(a,b,c,d,
  e,f){return Kg.main(a,b,c,d,e,f)},submenu:function(a,b,c,d,e){return Kg.submenu(a,b,c,d,e)}},Nm={makeshift:function(a,b,c,d,e,f,h,g,q){return{recalculate:t,isAnchored:k(!1),place:function(k){var l=b.uiOrigin(),m=a.isInline()?Qa(c,d):Ie.translate(l,c,d),C=eg(m.left(),m.top(),e,f);m=h.isRtl()?Qh.allRtl():Qh.all();l=Lh.box(C,l);k=k.panel();Km.simple(l,k,g,m,void 0===q?{}:q)}}},mainmenu:function(a,b,c,d){return jM.mainmenu(a.uiContainer,a.bounds,b,c,d)},submenu:function(a,b,c){return jM.submenu(a.uiContainer,
  a.bounds,b,c)}},kM=O("target","x","y"),lM=aa.detect().browser,LV=function(a,b,c,d,e,f){c=b.doc().getOrDie();var h=HV(c),l=Qa(0,0);c=dca.get();var q=Om.fromUnsafe(b),m=df.menuSystem(e.uiContainer,k("context"),qj.menu({focusActive:!0})),w=df.popup(m.sandbox,e.bounds,a,[],Lg.editorContainer());f=T.div();var n=w.initMenu(f),p=function(a){h.update(a.target());var b=y(),c=[m.sandbox()];if(0<b.all.length){var d=a.x(),e=a.y();l=Qa(d,e);n.setContent(b.main);u(n);n.open();m.open(c,b.main);return g.some(a)}return g.none()},
  r=function(a){return b.getSelection().bind(function(a){return function(){return ie.selectionContains(a).fold(function(){return D.isText(a.startContainer())?A.parent(a.startContainer()):g.some(a.startContainer())},function(a){return g.some(a)})}().map(function(a){var c=bb.viewport(a);c=b.translateScreen(c.left(),c.top());return kM(a,c.left(),c.top())})})},t=function(a){var c=a.original();c=lM.isIE()&&10>=lM.version.major?Qa(c.raw().clientX,c.raw().clientY):Qa(c.x(),c.y());c=b.translateScreen(c.left(),
  c.top());return kM(a.original().target(),c.left(),c.top())},u=function(c){var d=Fh(14,10);d=Nm.makeshift(b,e,l.left(),l.top(),0,0,a.uiDirection(),d);e.show(c,d)},x=function(){n.close();var a=y();z(a.all,function(a){v.set(a,"display","none")});q.end()};n.events.close.bind(function(){m.close()});var y=function(){var a=h.all();return{all:a,main:a[0],submenus:a.slice(1)}};b.events.contextmenu.bind(function(a){var b=t(a);p(b).orThunk(function(){return r().bind(p)}).each(function(b){a.original().raw().preventDefault()})});
  c.onShortcut(d.events.context,function(){r().each(p)});m.events.open.bind(function(){var a=h.structure(),b=y();m.update(a);w.registerMenus(b.submenus);u(n);m.setActiveMenu(b.main)});m.events.itemAction.bind(function(a){h.handle(a.item())});m.events.itemHover.bind(function(a){q.begin()});m.events.reveal.bind(function(a){ra.expanded(a.trigger());w.expandMenu(a.menu(),a.trigger(),n);u(n)});m.events.collapse.bind(function(a){w.hideMenu(a.menu());a.item().each(ra.collapsed)});m.events.itemAction.bind(x);
  m.events.escaped.bind(function(){x();b.focus()});b.events.mousedown.bind(x);return{register:h.register,destroy:function(){n.destroy();m.destroy()}}},Nv={resolve:Bn("ephox-darwin").resolve},mM=Nv.resolve("selected"),eca="."+mM,nM=Nv.resolve("first-selected"),fca="."+nM,oM=Nv.resolve("last-selected"),gca="."+oM,te={selected:k(mM),selectedSelector:k(eca),firstSelected:k(nM),firstSelectedSelector:k(fca),lastSelected:k(oM),lastSelectedSelector:k(gca)},NV=function(a){F.empty(a);y.append(a,p.fromTag("br"))},
  hca=aa.detect().browser,pp=function(a){var b=p.fromHtml("<p><br></p>");y.append(a,b);return g.some(b)},ica=function(a){var b=A.children(a);return 0===b.length?pp(a):1===b.length&&"br"===D.name(b[0])||1===b.length&&D.isText(b[0])&&""===D.value(b[0])?(F.empty(a),pp(a)):g.none()},jca=function(a){return 1===a.dom().childNodes.length?A.firstChild(a).fold(k(!1),function(a){return"br"===D.name(a)&&m.has(a,"_moz_editor_bogus_node")}):!1},kca=function(a){return ica(a).orThunk(function(){if(hca.isFirefox()&&
  jca(a)){F.empty(a);var b=pp(a)}else b=g.none();return b})},QV={listen:function(a){a.events.nodeChanged.bind(function(b){var c=b.node();a.body().each(function(b){var d=A.children(b);(a.isRoot(c)||1===d.length)&&kca(b).each(function(b){a.setSelection(b,0,b,0)})})})}},yz={onNodeChange:function(a,b){a.events.nodeChanged.bind(function(c){c.prev().each(function(c){qd.withinTransient(c,c).each(function(c){b.atomic(function(){qd.cleanup(a.isRoot,c)})})})});return{destroy:t}},preLinebreak:function(a){a.getSelection().each(function(b){A.parent(b.startContainer()).each(function(b){qd.withinTransient(b,
  b).each(function(b){qd.cleanupNonEmpty(a.isRoot,b)})})})}},vg=function(a,b){b=b.original();b=b.raw().which||b.raw().keycode;return U(a,b)},lca=u(vg,R.ENTER()),mca=u(vg,R.SPACE()),nca=u(vg,R.BACKSPACE()),oca=u(vg,R.DEL()),pca=u(vg,R.LEFT().concat(R.UP())),qca=u(vg,R.RIGHT().concat(R.DOWN())),rca=u(vg,R.TAB()),sca=u(vg,R.ESCAPE()),fe={isEnter:lca,isSpace:mca,isBackspace:nca,isDel:oca,isTab:rca,isLeftOrUp:pca,isRightOrDown:qca,isEscape:sca},pM=function(a,b,c,d){return ec.isCollapsed(a)?b(a.startContainer(),
  a.startOffset(),d):c(a.startContainer(),a.startOffset(),a.endContainer(),a.endOffset(),d)},zz={soft:function(a,b){return pM(a,$u.soft,cv.soft,b)},hard:function(a,b){return pM(a,$u.hard,cv.hard,b)}},qM=function(a,b){z(b,function(b){var c=b.find(a);b.cleaner(c,a)})},om={filterHtml:function(a,b){var c=p.fromTag("div");c.dom().innerHTML=a;qM(c,b);return on.writeChildren(c)},filterDom:qM},rM=function(a,b){var c=W.point(a,b);return D.isText(a)?uh.scanRight(a,b).getOr(c):c},Cz={handle:function(a){var b=
  rM(a.startContainer(),a.startOffset());a=rM(a.endContainer(),a.endOffset());return Rc(b.element(),b.offset(),a.element(),a.offset())}},wh=ta.generate([{onText:["element","offset"]},{firstText:["parent","child","offset"]},{beforeText:["parent","child","offset"]},{afterText:["parent","child"," offset"]},{lastText:["parent","child","offset"]},{onElement:["element","offset"]}]),sM={detect:function(a,b){if(D.isText(a))return wh.onText(a,b);var c=A.children(a);return 0===c.length?wh.onElement(a,b):0===
  b&&D.isText(c[0])?(0,wh.firstText)(a,c[0],0):b===c.length&&D.isText(c[c.length-1])?(b=c[b-1],(0,wh.lastText)(a,b,wa.getEnd(b))):b<c.length&&D.isText(c[b])?(0,wh.beforeText)(a,c[b],0):0<b&&D.isText(c[b-1])?(b=c[b],(0,wh.afterText)(a,b,wa.getEnd(b))):wh.onElement(a,b)},cata:function(a,b,c,d,e,f,h){return a.fold(b,c,d,e,f,h)}},xh=O("startContainer","startOffset","endContainer","endOffset"),tM={resolve:Lb.create("ephox-newt").resolve}.resolve("cursor-marker"),fl={generator:function(a){var b=null;return{getOrInit:function(){if(null===
  b){var c=p.fromTag("span",a.dom());n.add(c,tM);v.set(c,"display","none")}else c=b;return b=c}}},isCursor:function(a){return n.has(a,tM)}},uM=function(a,b){return{element:k(b),backup:ca,restore:function(){var b=xh(a,0,a,0);return g.some(b)}}},vM=function(a){a=A.children(a);return ka(a,zf(fl.isCursor))},tca=function(a,b){return{element:k(b),backup:ca,restore:function(){var b=vM(a).length;b=xh(a,b,a,b);return g.some(b)}}},uca=function(a){return A.parent(a).bind(function(b){var c=vM(b);return Va(c,function(b){return N.eq(a,
  b)}).map(function(a){return xh(b,a,b,a)})})},vca=function(a,b){return{backup:function(){y.before(a,b)},restore:function(){var a=A.nextSibling(b);F.remove(b);return a.map(function(a){return uca(a).getOrThunk(function(){return xh(a,0,a,0)})})},element:k(b)}},wca={place:function(a,b,c){var d=A.children(a);return 0===d.length?uM(a,c):d.length===b?tca(a,c):0===b?uM(a,c):b>d.length?Az(c):vca(d[b],c)}},wM=function(a,b){return b().fold(function(){return fl.generator(a).getOrInit()},function(a){return a.element()})},
  qp=function(a){a=a();a.backup();return g.some(a)},xM=function(a,b){var c=a.or(b),d=b.or(a);return c.bind(function(a){return d.map(function(b){return xh(a.startContainer(),a.startOffset(),b.startContainer(),b.startOffset())})})},xca=function(a,b,c){var d=g.none(),e=g.none();return{backup:function(){e=qp(b);d=qp(c)},restore:function(){return d.bind(function(a){return e.bind(function(b){var c=a.restore();b=b.restore();return xM(c,b)})})},element:u(wM,a,function(){return e})}},yca=function(a,b,c){var d=
  g.none(),e=g.none();return{backup:function(){d=qp(c);e=qp(b)},restore:function(){return e.bind(function(a){return d.bind(function(b){var c=a.restore();b=b.restore();return xM(b,c)})})},element:u(wM,a,function(){return d})}},zca=function(a,b,c){return{backup:function(){y.before(b,c)},restore:function(){var b=wc.after(c,a).map(function(a){return xh(a,0,a,0)});F.remove(c);return b},element:k(c)}},yM=function(a,b,c){return{backup:function(){y.after(b,c)},restore:function(){var b=wc.before(c,a).map(function(a){var b=
  wa.getEnd(a);return xh(a,b,a,b)});F.remove(c);return b},element:k(c)}},zM={place:function(a,b,c,d){b=ti.split(b,c);return ti.position(b).fold(function(){return Az(d)},function(b){return zca(a,b,d)},function(b,c){return yM(a,b,d)},function(b){return yM(a,b,d)})}},Ov=O("result","cursor"),Aca=function(a,b,c){var d=function(b,d,h){return zM.place(a,d,h,c)};return sM.cata(b,function(b,d){return zM.place(a,b,d,c)},d,d,d,d,function(a,b){return wca.place(a,b,c)})},Pv=function(a,b,c,d){d=d.getOrInit();b=sM.detect(b,
  c);return Aca(a,b,d)},AM=function(a,b){a.backup();b=b(a.element());return Ov(b,a.restore())},rp={inspect:Pv,runOnRange:function(a,b,c,d,e,f){var h=A.owner(b),g=(hd.after(b,c,d,e)?yca:xca)(h,function(){return Pv(a,d,e,fl.generator(h))},function(){return Pv(a,b,c,fl.generator(h))});return AM(g,f)},runOnCursor:AM},Bca=function(a,b,c,d,e,f){return rp.runOnRange(a,b,e>c?c:e,b,e>c?e:c,f)},Cca=rp.runOnRange,BM={point:function(a,b,c,d){var e=A.owner(b);e=fl.generator(e);a=rp.inspect(a,b,c,e);return rp.runOnCursor(a,
  d)},range:function(a,b,c){return(N.eq(b.startContainer(),b.endContainer())?Bca:Cca)(a,b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset(),c)}},Dca=function(a,b){return function(a,d){a=d(b);return Ov(a,g.none())}},Eca=function(a,b){return function(c,d){return BM.point(a,b.startContainer(),b.startOffset(),CM(c,d))}},Fca=function(a,b){return function(c,d){return BM.range(a,b,CM(c,d))}},CM=function(a,b){return function(c){n.add(c,a);return b(c)}},Bz={diagnose:function(a,b){var c=b.startContainer(),
  d=b.endContainer(),e=A.owner(c);return ja.inBody(c)&&ja.inBody(d)&&Z.active(e).forall(ja.inBody)?b.collapsed()?Eca(a,b):Fca(a,b):Dca(a,b.startContainer())}},Qv={fold:function(a,b){return Eb(a,function(a,d){return a.bind(function(a){return b(d).map(function(b){return[b].concat(a)})})},J.value([]))}},DM=function(a,b,c){ic(a)&&b.hasOwnProperty(a.label)&&c(b[a.label]);return a},EM={mapGroup:function(a,b){return DM(a,b,function(b){return a.label=b})},mapMenu:function(a,b){return DM(a,b,function(b){b.hasOwnProperty("label")&&
  (a.label=b.label);b.hasOwnProperty("menuLabel")&&(a.menuLabel=b.menuLabel)})}},Gca=function(a,b,c){b=b.groups();return b.hasOwnProperty(a)?J.value(b[a]):kf("Unknown group: "+a,["No binding for group: "+a+". Known groups: "+cb(b)])},Hca=function(a,b,c){a=EM.mapGroup(a,c.groupMappings());a=Mb(a)?{label:"",items:a}:a;return J.value(a)},Ica=function(a,b,c,d,e,f){return Qv.fold(b,function(a){return e.item(a,c,d,e,f)}).map(function(b){return{category:a,items:b}})},Jca=function(a,b,c,d,e){b=b.commands();
  return b.hasOwnProperty(a)?J.value(b[a]):kf("Unknown command: "+a,["No binding for command: "+a+". Known commands: "+cb(b)])},Lca=function(a,b,c,d,e){return(void 0===a.items?Kca:d.menu)(a,b,c,d,e)},Kca=function(a,b,c,d,e){return void 0===c?kf("You need a custom action factory to use this",[]):c(a)},Mca=function(a){return ob(a,Mb)?J.value(a):Xa(a,Mb)?kf("Menu items must be a single array or an array where every element is an array",["Menu items must be a single array or an array where every element is an array.",
  "Contents of menu: "+Nb.stringify(a)]):J.value([a])},FM=eb({group:function(a,b,c,d,e){return(xa(a)?Gca:Hca)(a,b,e).bind(function(a){return Ica(a.label,a.items,b,c,d,e)})},item:function(a,b,c,d,e){return(xa(a)?Jca:Lca)(a,b,c,d,e)},menu:function(a,b,c,d,e){if(void 0===a.label||void 0===a.items||0===a.items.length)return kf("Invalid toolbar configuration for menu",["Invalid menu. Must be an object containing label and items.","Contents of menu: "+Nb.stringify(a)]);var f=EM.mapMenu(a,e.menuMappings()),
  h=f.menuLabel?f.menuLabel:f.label;return Mca(f.items).bind(function(a){return Qv.fold(a,function(a){return d.group(a,b,c,d,e)})}).map(function(b){return{name:a.id,textkey:a.label,menuTextkey:h,type:"submenu",contentFocus:!1,enabled:!0,icon:a.icon,commands:b}})}},function(a,b){return function(){if(5!==arguments.length)throw"Incorrect usage of builder ["+b+"]. Only given: "+arguments.length;return a.apply(null,arguments)}}),Nca=function(a){if(void 0===a.items)return kf("Invalid group, no items specified",
  ["Invalid group, no items specified: "+a.label]);var b=a.items;return Mb(b)?(a=ia(b,function(a,b){return xa(a)||Mb(a)||void 0!==a.label&&Mb(a.items)?[]:["Invalid group at index: "+b+". Must be either a string, an array or an object containing label and items. Was: "+Nb.stringify(a)]}),0===a.length?J.value(b):kf("Invalid toolbar configuration for groups",a)):kf("Invalid toolbar, items is not an array",["Invalid toolbar, items is not an array: "+Nb.stringify(a)])},GM={build:function(a,b,c,d){return Nca(a).bind(function(a){return Qv.fold(a,
  function(a){return FM.group(a,b,c,FM,d)})})}},HM=function(){return xc.isSmallTouch()},IM=function(a,b){return{feature:a.feature,command:a.command,type:"pre_flatmenu",items:b}},hr={shouldFlatten:HM,never:k("never_flatten"),streamline:function(a){var b=function(a){return ia(a,function(a){return"never_flatten"===a.flatten?[a]:"submenu"===a.type?ia(a.commands,function(a){return b(a.items)}):"pre_flatmenu"===a.type?E(a.items,function(b){return{feature:a.feature,type:"general",command:b}}):[a]})};return E(a,
  function(a){var c=b(a.items);return{category:a.category,items:c}})},setup:function(a,b){b=IM(a,b);return xc.choice([{predicate:HM,value:k(b)}],a)},make:IM},xj=function(a,b){return{predicate:a,value:k(b)}},JM=function(){return{make:function(a){var b=function(b){return kf(x.translate("errors.toolbar.missing.custom.string",b),['The required property "'+b+'" for a custom command must be a string. It was: '+Nb.stringify(a[b]),"Properties specified in custom command: "+cb(a).join(", "),"Definition specified for custom command: "+
  Nb.stringify(a)])};if(!xa(a.id))return b("id");if(!xa(a.text))return b("text");b={};b[a.id]=k({general:function(){return{toggle:!1,value:Fn.cssSanitise(a.id),textkey:x.raw(a.text),action:a.action,updateGeneral:ca,icon:void 0!==a.icon?a.icon:!1}}});return J.value({feature:g.some(b),command:a.id,type:"general"})}}}(),Oca=function(a,b){return a.bind(function(a){return b.map(function(b){return a.concat(b)})})},KM={groupMappings:k({"group.undo":"category.undo","group.insert":"category.insert","group.style":"category.style",
  "group.language":"category.language","group.emphasis":"category.emphasis","group.align":"category.align","group.listindent":"category.listindent","group.format":"category.format","group.tools":"category.tools","group.table":"category.table","group.image":"category.image"}),menuMappings:k({"menu.insert":{label:"insert.menu-button",menuLabel:"insert.menu"},"menu.font":{label:"font.menu-button",menuLabel:"font.menu"}})},yj={config:function(a,b,c){return function(d,e,f,h){d=cW(d,e,f,h,c);d=oa(d,b);h=
  {"table-tools":{feature:h.table().ui(),command:"cell",type:"palette"},"image-tools":{feature:h.imageEdit().ui(),command:"edit",type:"palette"},"crop-tools":{feature:h.imageEdit().ui(),command:"crop",type:"palette"}};d={forItems:k({commands:k(d),groups:Ez}),forContextual:k({commands:k(h),groups:Ez})};h=GM.build({items:a.items},d.forItems(),JM.make,KM);d=GM.build({items:a.contextual},d.forContextual(),JM.make,KM);e=aa.detect().deviceType.isTouch()?hr.streamline:ca;return Oca(h,d).map(e)}}},Pca=function(a){return function(a){setTimeout(function(){a()},
  0)}},Qca={resume:function(a){a.focus();var b=p.fromDom(a.document.body);(Z.active().exists(function(a){return U(["input","textarea"],D.name(a))})?Pca(b):xb)(function(){Z.active().each(Z.blur);Z.focus(b)})}},sp={safeParse:function(a,b){a=parseInt(m.get(a,b),10);return isNaN(a)?0:a}},Rca=function(a){return{left:a.left,top:a.top,width:2,height:a.height}},Sca=function(a){if(a.collapsed){var b=p.fromDom(a.startContainer);return A.parent(b).bind(function(c){c=Kc.exact(b,a.startOffset,c,wa.getEnd(c));return Wa.getFirstRect(a.startContainer.ownerDocument.defaultView,
  c).map(function(a){return eb(a,xb)}).map(Rca).map(GB)}).getOr([])}return a.getClientRects()},kr={getRectangles:function(a){a=a.getSelection();return void 0!==a&&0<a.rangeCount?Sca(a.getRangeAt(0)):[]}},ue={resolve:Lb.create("ephox-nomad").resolve},Rv="data-"+ue.resolve("last-outer-height"),Tca=function(a){return{top:k(a.top),bottom:k(a.top+a.height)}},Uca=function(a){a=kr.getRectangles(a);return 0<a.length?g.some(a[0]).map(Tca):g.none()},Vca=function(a){a=sp.safeParse(a,Rv);var b=window.innerHeight;
  return a>b?g.some(a-b):g.none()},gW={setup:function(a,b){var c=p.fromDom(b.document.body),d=K.bind(p.fromDom(a),"resize",function(){Vca(c).each(function(a){Uca(b).each(function(c){c=c.top()>b.innerHeight||c.bottom()>b.innerHeight?Math.min(a,c.bottom()-b.innerHeight+50):0;0!==c&&b.scrollTo(b.pageXOffset,b.pageYOffset+c)})});m.set(c,Rv,window.innerHeight)});m.set(c,Rv,window.innerHeight);return{toEditing:function(){Qca.resume(b)},destroy:function(){d.unbind()}}}},LM=function(a){var b=new (Jc.getOrDie("Event"))("Event");
  b.initEvent(a,!0,!0);return b},Fz={event:function(a,b){b=LM(b);a.target().dom().dispatchEvent(b)},target:function(a,b){b=LM(b);a.dom().dispatchEvent(b)}},MM=function(){var a=window.matchMedia("(orientation: portrait)").matches;return{isPortrait:k(a)}},Jh={get:MM,onChange:function(){var a=H.create({ready:r(["orientation"]),change:r(["orientation"])}),b=p.fromDom(window),c=null,d=K.bind(b,"orientationchange",function(){clearInterval(c);var b=MM();a.trigger.change(b);e(function(){a.trigger.ready(b)})}),
  e=function(a){clearInterval(c);var b=window.innerHeight,d=0;c=setInterval(function(){b!==window.innerHeight?(clearInterval(c),a(g.some(window.innerHeight))):20<d&&(clearInterval(c),a(g.none()));d++},50)};return{onAdjustment:e,events:a.registry,destroy:function(){d.unbind()}}}},Hz={tag:function(){var a=L.first("head").getOrDie(),b=L.first('meta[name="viewport"]').getOrThunk(function(){var b=p.fromTag("meta");m.set(b,"name","viewport");y.append(a,b);return b}),c=m.get(b,"content");return{maximize:function(){m.set(b,
  "content","width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0")},restore:function(){void 0!==c&&null!==c&&0<c.length?m.set(b,"content",c):m.remove(b,"content")}}}},NM=function(a,b){a=Ga.get(a);return Math.floor(b/100*a)},OM=function(a,b){return L.ancestor(b,"td,th").fold(function(){return NM(a,98)},function(a){return NM(a,94)})},Wca=function(a,b,c){var d=b.dom().width;a=OM(a,b);return Math.max(0,Math.min(a,d+c))},Xca=function(a,b,c){return b.dom().height+c},ir={compare:function(a,
  b){var c=b.deltaX()-a.deltaX(),d=b.deltaY()-a.deltaY();a=b.deltaDistance()-a.deltaDistance();return{deltaX:k(c),deltaY:k(d),deltaDistance:k(a)}},extract:function(a){var b=a.raw().touches;if(2>b.length)return g.none();a=Math.abs(b[0].clientX-b[1].clientX);b=Math.abs(b[0].clientY-b[1].clientY);var c=Math.sqrt(Math.pow(a,2)+Math.pow(b,2));return g.some({deltaX:k(a),deltaY:k(b),deltaDistance:k(c)})},resize:function(a,b,c){var d=v.getRaw(b,"height"),e=v.getRaw(b,"width"),f=0<c.deltaDistance()?1:-1,h=f*
  Math.abs(c.deltaX()),g=f*Math.abs(c.deltaY());c=Wca(a,b,h);f=Xca(a,b,g);h=Math.abs(h)>Math.abs(g);v.setAll(b,{height:h?"auto":f+"px",width:h?c+"px":"auto",transform:"translate3d(0, 0, 0)"});Ga.get(b)>OM(a,b)&&(d.each(function(a){v.set(b,"height",a)}),e.each(function(a){v.set(b,"width",a)}))}},fW=6<=aa.detect().os.version.major,Yca=function(a){return a.body().map(function(a){a=v.get(a,"background-color");return void 0!==a&&""!==a?"background-color:"+a+"!important":"background-color:rgb(255,255,255)!important;"}).getOr("background-color:rgb(255,255,255)!important;")},
  Kz={clobberStyles:function(a,b){var c=function(a){return function(b){var c=m.get(b,"style");c=void 0===c?"no-styles":c.trim();c!==a&&(m.set(b,"data-ephox-mobile-fullscreen-style",c),m.set(b,"style",a))}};a=Y.ancestors(a,"*");var d=ia(a,function(a){return Y.siblings(a,"*")});b=Yca(b);z(d,c("display:none!important;"));z(a,c("position:absolute!important;top:0!important;left:0!important;margin:0!important;padding:0!important;width:100%!important;height:100%!important;overflow:visible!important;"+b))},
  restoreStyles:function(){var a=Y.all("[data-ephox-mobile-fullscreen-style]");z(a,function(a){var b=m.get(a,"data-ephox-mobile-fullscreen-style");"no-styles"!==b?m.set(a,"style",b):m.remove(a,"style");m.remove(a,"data-ephox-mobile-fullscreen-style")})}},PM={input:function(a,b){var c=p.fromTag("input");v.setAll(c,{opacity:"0",position:"absolute",top:"-1000px",left:"-1000px"});y.append(a,c);Z.focus(c);b(c);F.remove(c)}},qr={refreshInput:function(a){var b=a.dom().selectionStart,c=a.dom().selectionEnd,
  d=a.dom().selectionDirection;setTimeout(function(){a.dom().setSelectionRange(b,c,d);Z.focus(a)},50)},refresh:function(a){var b=a.getSelection();if(0<b.rangeCount){var c=b.getRangeAt(0);a=a.document.createRange();a.setStart(c.startContainer,c.startOffset);a.setEnd(c.endContainer,c.endOffset);b.removeAllRanges();b.addRange(a)}}},jr={resume:function(a,b){Z.active().each(function(a){N.eq(a,b)||Z.blur(a)});a.focus();Z.focus(p.fromDom(a.document.body));qr.refresh(a)}},qW={stubborn:function(a,b,c,d,e){var f=
  pm(e),h=function(){jr.resume(a,c)},g=K.bind(b,"keydown",function(a){U(["input","textarea"],D.name(a.target()))||(f.closeMenus(void 0),h())});return{toReading:function(){PM.input(ja.body(),Z.blur)},toEditing:h,onToolbarTouch:function(a){},destroy:function(){g.unbind()}}},timid:function(a,b,c,d,e){return{toReading:function(){Z.blur(c)},toEditing:function(){jr.resume(a,c)},onToolbarTouch:function(){Z.blur(c)},destroy:t}}},Zca={touch:function(a){var b=H.create({touchstart:r(["raw"]),touchend:r(["raw"])}),
  c=!1,d=g.none(),e=K.capture(a,"touchstart",function(e){c=!0;d=g.some(K.capture(a,"touchend",function(a){c=!1;b.trigger.touchend(a.raw());f()}));b.trigger.touchstart(e.raw())}),f=function(){d.each(function(a){a.unbind()})};return{isTouching:function(){return c},events:b.registry,destroy:function(){e.unbind();f()}}}},$ca=function(a){a=A.documentElement(a);var b=ue.resolve("unfocused-selection");return L.descendant(a,"."+b).map(function(a){return bb.absolute(a).top})},Sv={toFake:function(a,b,c){var d=
  c.isActive,e=!1;return{on:function(){d()||(e=!1,c.update(),b.save(),Wa.clear(a))},off:function(){d()&&!e&&(c.clear(),b.restore())},fakeOut:function(){e=!0;PM.input(ja.body(),b.restore)}}},inView:function(a,b,c){return function(){return $ca(b).map(function(b){var c=a.dom().scrollTop;return 0<b()-c})}},onScroll:function(a,b,c,d){var e=function(){a()||f()},f=function(){d.events.touchend.unbind(e);d.isTouching()?d.events.touchend.bind(e):(c().getOr(!0)?b.off:b.fakeOut)()};return{start:function(){d.events.touchend.unbind(e);
  b.on()},stop:f,destroy:function(){d.events.touchend.unbind(e)}}}},QM=function(a,b){return yc([{width:320,height:480,keyboard:{portrait:300,landscape:240}},{width:320,height:568,keyboard:{portrait:300,landscape:240}},{width:375,height:667,keyboard:{portrait:305,landscape:240}},{width:414,height:736,keyboard:{portrait:320,landscape:240}},{width:768,height:1024,keyboard:{portrait:320,landscape:400}},{width:1024,height:1366,keyboard:{portrait:380,landscape:460}}],function(c){return a<=c.width&&b<=c.height?
  g.some(c.keyboard):g.none()}).getOr({portrait:b/5,landscape:a/4})}(window.screen.width,window.screen.height),RM=function(a){a=sa.get(a);var b=Jh.get().isPortrait(),c=b?QM.portrait:QM.landscape;return a-((b?window.screen.height:window.screen.width)-window.innerHeight>c?0:c)},Tv={getGreenzone:RM,updatePadding:function(a,b){var c=RM(b);b=sa.get(b)-c;v.set(a,"padding-bottom",b+"px")}},SM=ta.generate([{fixed:["element","offsetY"]},{scroller:["element","offsetY"]}]),wg="data-"+ue.resolve("position-y-fixed"),
  Uv="data-"+ue.resolve("scrolling"),TM="data-"+ue.resolve("last-window-height"),UM=function(a){return sp.safeParse(a,wg)},ada=function(a){var b=UM(a);return("true"===m.get(a,Uv)?SM.scroller:SM.fixed)(a,b)},bda=function(a){var b=m.get(a,"style");v.setAll(a,{position:"absolute",top:"0px"});m.set(a,wg,"0px");return{restore:function(){m.set(a,"style",b||"");m.remove(a,wg)}}},cda=function(a,b,c){var d=m.get(c,"style");Uc.register(c);v.setAll(c,{position:"absolute",height:b+"px",width:"100%",top:a+"px"});
  m.set(c,wg,a+"px");m.set(c,Uv,"true");return{restore:function(){Uc.deregister(c);m.set(c,"style",d||"");m.remove(c,wg);m.remove(c,Uv)}}},VM=function(a,b){var c=window.innerHeight;m.set(a,TM,c+"px");return c-b},Vv={findFixtures:function(a){a=Y.descendants(a,"["+wg+"]");return E(a,ada)},takeover:function(a,b,c){var d=bda(c),e=sa.get(c),f=VM(a,e),h=cda(e,f,a);e=function(){var b=window.innerHeight,c=sp.safeParse(a,TM);return b>c};var g=function(){var d=sa.get(c),e=VM(a,d);m.set(a,wg,d+"px");v.set(a,"height",
  e+"px");Tv.updatePadding(b,a)};Tv.updatePadding(b,a);return{setViewportOffset:function(b){m.set(a,wg,b+"px");g()},isExpanding:e,isShrinking:zf(e),refresh:g,restore:function(){d.restore();h.restore()}}},getYFixedData:UM},dda=function(a,b,c){return Math.abs(a-b)<=c?g.none():a<b?g.some(a+c):g.some(a-c)},tp=function(){var a=null;return{animate:function(b,c,d,e,f,h){clearInterval(a);var g=function(b){clearInterval(a);f(b)};a=setInterval(function(){var h=b();dda(h,c,d).fold(function(){clearInterval(a);
  f(c)},function(d){e(d,g);var k=b();if(k!==d||Math.abs(k-c)>Math.abs(h-c))clearInterval(a),f(c)})},h)}}}(),up="data-"+ue.resolve("last-scroll-top"),WM=function(a){return v.getRaw(a,"top").map(function(a){return parseInt(a,10)}).getOr(0)},XM=function(a){return parseInt(a.dom().scrollTop,10)},YM=function(a,b){b=b+Vv.getYFixedData(a)+"px";v.set(a,"top",b)},gl={moveScrollAndTop:function(a,b,c){return Ea.nu(function(d){var e=u(XM,a);tp.animate(e,b,15,function(b){a.dom().scrollTop=b;v.set(a,"top",WM(a)+
  15+"px")},function(e){a.dom().scrollTop=b;v.set(a,"top",c+"px");d(b)},10)})},moveOnlyScroll:function(a,b){return Ea.nu(function(c){var d=u(XM,a);m.set(a,up,d());var e=Math.abs(b-d());tp.animate(d,b,Math.ceil(e/10),function(b,c){sp.safeParse(a,up)!==a.dom().scrollTop?c(a.dom().scrollTop):(a.dom().scrollTop=b,m.set(a,up,b))},function(d){a.dom().scrollTop=b;m.set(a,up,b);c(b)},10)})},moveOnlyTop:function(a,b){return Ea.nu(function(c){var d=u(WM,a),e=function(b){v.set(a,"top",b+"px")},f=Math.abs(b-d());
  tp.animate(d,b,Math.ceil(f/10),e,function(a){e(b);c(b)},10)})},moveWindowScroll:function(a,b,c){return Ea.nu(function(d){var e=function(c){YM(a,c);YM(b,c);window.scrollTo(0,c)};tp.animate(function(){return window.pageYOffset},c,15,e,function(a){e(a);d(a)},10)})}},eda={scrollIntoView:function(a,b,c,d){var e=Tv.getGreenzone(b);a=u(qr.refresh,a);c>e||d>e?gl.moveOnlyScroll(b,b.dom().scrollTop-e+d).get(a):0>c&&gl.moveOnlyScroll(b,b.dom().scrollTop+c).get(a)}},fda=function(a,b){return a.fold(function(a,
  d){v.set(a,"top",b+d+"px");return Ea.pure(d)},function(a,d){var c=b+d;d=v.getRaw(a,"top").getOr(d);d=c-parseInt(d,10);d=a.dom().scrollTop+d;return gl.moveScrollAndTop(a,d,c)})},ZM={updatePositions:function(a,b){a=Vv.findFixtures(a);a=E(a,function(a){return fda(a,b)});return Pl(a,Ea.nu)}},gda=function(a,b,c,d,e,f){var h=mW(function(c){return gl.moveWindowScroll(a,b,c)}),l=function(){var a=kr.getRectangles(f);return g.from(a[0]).bind(function(a){var c=a.top-b.dom().scrollTop;return c>window.innerHeight+
  5||-5>c?g.some({top:k(c),bottom:k(c+a.height)}):g.none()})},q=jf(function(){h.idle(function(){ZM.updatePositions(c,d.pageYOffset).get(function(a){l().each(function(a){b.dom().scrollTop=b.dom().scrollTop+a.top()});h.start(0);e.refresh()})})},1E3),m=K.bind(p.fromDom(d),"scroll",function(){0>d.pageYOffset||q.throttle()});ZM.updatePositions(c,d.pageYOffset).get(ca);return{unbind:m.unbind}},pW={setup:function(a){var b=a.cWin(),c=a.ceBody(),d=a.socket(),e=a.toolstrip(),f=a.toolbar(),h=a.contentElement(),
  g=a.cursor(),k=a.keyboardType();a=a.isScrolling();var m=Vv.takeover(d,c,e),w=k(b,ja.body(),h,e,f),n=Jh.onChange();n.events.ready.bind(m.refresh);n.onAdjustment(function(){m.refresh()});var r=K.bind(p.fromDom(window),"resize",function(){m.isExpanding()&&m.refresh()}),u=gda(e,d,ja.body(),window,m,b),x=lW(b,h),y=function(){x.clear()};e=Sv.toFake(b,g,x);c=Sv.inView(d,c,f);var z=Zca.touch(p.fromDom(b)),A=Sv.onScroll(a,e,c,z);return{toEditing:function(){w.toEditing();y()},toReading:function(){w.toReading()},
  onToolbarTouch:function(a){w.onToolbarTouch(a)},refreshSelection:function(){x.isActive()&&x.update()},clearSelection:y,highlightSelection:function(){x.update()},scrollIntoView:function(a,c){eda.scrollIntoView(b,d,a,c)},updateToolbarPadding:t,setViewportOffset:function(a){m.setViewportOffset(a);gl.moveOnlyTop(d,a).get(ca)},syncHeight:function(){v.set(h,"height",h.dom().contentWindow.document.body.scrollHeight+"px")},selectionScrollStarted:function(){A.start()},selectionScrollStopped:function(){A.stop()},
  destroy:function(){m.restore();n.destroy();u.unbind();r.unbind();w.destroy();A.destroy();z.destroy();x.destroy()}}}},$M="data-"+ue.resolve("horizontal-scroll"),hda=function(a){var b;(b=0<a.dom().scrollTop)||(a.dom().scrollTop=1,b=0!==a.dom().scrollTop,a.dom().scrollTop=0);return b},ida=function(a){var b;(b=0<a.dom().scrollLeft)||(a.dom().scrollLeft=1,b=0!==a.dom().scrollLeft,a.dom().scrollLeft=0);return b},aN={markAsHorizontal:function(a){m.set(a,$M,"true")},hasScroll:function(a){return"true"===m.get(a,
  $M)?ida:hda}},jda=function(a){var b=a.dom().scrollTop,c=a.dom().scrollHeight;a=a.dom().offsetHeight;return 0>=b?g.some(1):b+a>=c?g.some(c-a-1):g.none()},bN=function(a){jda(a).each(function(b){a.dom().scrollTop=b})},Wv=function(a,b){return K.bind(a,"touchstart",function(a){b(a.target()).each(bN)})},Mz={fixEdges:bN,exclusive:function(a,b){return K.bind(a,"touchmove",function(a){L.closest(a.target(),b).filter(aN.hasScroll).fold(function(){a.raw().preventDefault()},t)})},link:function(a,b){return Wv(a,
  k(b))},ancestor:function(a,b){return Wv(a,function(a){return L.closest(a,b)})},indirect:Wv,markAsHorizontal:function(a){aN.markAsHorizontal(a)}},cN=function(a){return p.fromText(mb(),a.dom())},dN={runAndRemove:function(a,b){var c=A.owner(a),d=p.fromTag("span",c.dom());y.append(d,cN(c));y.prepend(a,d);a=b(d);F.remove(d);return a},enrichAndRemove:function(a,b){var c=cN(A.owner(a));y.append(a,c);a=b(a);F.remove(c);return a}},vp=O("left","top","width","height","direction","absolute"),eN=function(a){return{position:k(nk.find(a)),
  width:k(Ga.getOuter(a)),height:k(sa.getOuter(a))}},kda=function(a){var b=v.get(a,"display");return{backup:function(){v.set(a,"display","inline-block")},restore:function(){v.set(a,"display",b)}}},lda={backup:t,restore:t},mda=function(a){return D.isElement(a.startContainer())?g.some(a.startContainer()):D.isElement(a.endContainer())?g.some(a.endContainer()):A.parent(a.startContainer()).filter(D.isElement).orThunk(function(){return A.parent(a.endContainer()).filter(D.isElement)})},nda=function(a,b){return mda(b).fold(function(){return vp(0,
  0,0,a.uiDirection(),Qa(0,0))},function(b){var c=nk.find(b),e=Ga.get(b),f=sa.get(b),h=bb.absolute(b);return vp(c.left(),c.top(),e,f,a.directionAt(b),h)})},oda=function(a,b,c,d){return Bz.diagnose(a,c)(d,function(a){var d=sc.isVisible(a)||"br"===D.name(a)?lda:kda(a);d.backup();if(ja.inBody(a)){var e=dN.enrichAndRemove(a,eN);var g=e.position();var k=e.width();e=e.height();var m=b.directionAt(a);a=bb.absolute(a);g=vp(g.left(),g.top(),k,e,m,a)}else g=nda(b,c);d.restore();return g})},pda=function(a,b,c,
  d){var e=c.startContainer(),f=c.startOffset();if("body"===D.name(e)&&0===f){var h=c.startContainer();a=parseInt(v.get(h,"padding-top"),10);d=parseInt(v.get(h,"padding-left"),10);var k=dN.runAndRemove(h,eN);e=k.position();f=k.width();k=k.height();b=b.directionAt(h);h=bb.absolute(h);c=Ov(vp(e.left()+d,e.top()+a,f,k,b,h),g.some(c))}else c=oda(a,b,c,d);return c},fN=function(a,b,c,d,e){b.focus();a=pda(b.isRoot,a,c,e);a.cursor().each(function(a){b.setSelection(a.startContainer(),a.startOffset(),a.endContainer(),
  a.endOffset())});a=a.result();d(a)},Lz={insertAt:fN,insertAtCursor:function(a,b,c,d){b.getSelection().each(function(e){fN(a,b,e,c,d)})}},Oz=aa.detect(),gN=function(){try{var a=Vf.localStorage;a.setItem("__storage_test__","__storage_test__");a.removeItem("__storage_test__");return g.some(a)}catch(b){return g.none()}}().fold(function(){var a={};return{getItem:function(b){return a[b]},setItem:function(b,c){a[b]=c}}},function(a){return{getItem:function(b){return a.getItem("ephox.textboxio."+b)},setItem:function(b,
  c){a.setItem("ephox.textboxio."+b,c)}}}),hN=function(a,b){return g.from(gN.getItem(a)).map(Nb.parse).getOr(b)},iN=function(a){return hN(a,{})},jN=function(a,b){b=Nb.stringify(b);gN.setItem(a,b)},sm={read:iN,readOr:hN,write:jN,access:function(a){return{read:u(iN,a),write:u(jN,a)}}},kN=function(a,b,c){b.body().each(function(d){c.save();var e=p.fromHtml(mb());a(d,e);b.setSelection(e,0,e,0)})},Pz={upOrLeft:function(a,b,c){a.setRelativeSelection(la.before(c),la.before(c));a.getSelection().fold(function(){kN(y.prepend,
  a,b)},t)},right:function(a,b,c){a.setRelativeSelection(la.after(c),la.after(c));a.getSelection().fold(function(){kN(y.append,a,b)},t)}},Aj={left:function(a,b,c){return a(b)&&wa.isStart(b,c)?g.none():wa.isStart(b,c)?wc.before(b,a).filter(function(a){return!Db.ancestor(a,"head")}):a(b)&&0<c?A.child(b,c-1):g.none()},right:function(a,b,c){return a(b)&&wa.isEnd(b,c)?g.none():wa.isEnd(b,c)?wc.after(b,a).filter(function(b){return a(b)||Db.ancestor(b,"body")}):a(b)&&c<wa.getEnd(b)?A.child(b,c+1):g.none()},
  isFirstInContent:function(a,b){return a.body().map(function(a){a=A.children(a);return N.eq(a[0],b)}).getOr(!1)},isLastInContent:function(a,b){return a.body().map(function(a){a=A.children(a);return 0<a.length&&N.eq(a[a.length-1],b)}).getOr(!1)}},qda=function(a,b){return a.getSelection().bind(function(c){return c.collapsed()?b(a.isRoot,c.startContainer(),c.startOffset()):g.none()})},rda=function(a,b){return Eb(a,function(a,d){return d(b).or(a)},g.none())},lr={get:function(a,b,c){return qda(a,c).bind(function(a){return rda(b,
  a)})}},Mi={response:O("selection","kill")},Ni=function(a){return function(b){return b===a}},sda=Ni(38),tda=Ni(40),Nd={ltr:{isBackward:Ni(37),isForward:Ni(39)},rtl:{isBackward:Ni(39),isForward:Ni(37)},isUp:sda,isDown:tda,isNavigation:function(a){return 37<=a&&40>=a}},Kh={convertToRange:function(a,b){a=Le.asLtrRange(a,b);return{start:k(p.fromDom(a.startContainer)),soffset:k(a.startOffset),finish:k(p.fromDom(a.endContainer)),foffset:k(a.endOffset)}},makeSitus:function(a,b,c,d){return{start:k(la.on(a,
  b)),finish:k(la.on(c,d))}}},lN=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()},mN={inSelection:function(a,b){var c=b.column(),d=b.column()+b.colspan()-1,e=b.row();b=b.row()+b.rowspan()-1;return c<=a.finishCol()&&d>=a.startCol()&&e<=a.finishRow()&&b>=a.startRow()},isWithin:lN,isRectangular:function(a,b){for(var c=!0,d=u(lN,b),e=b.startRow();e<=b.finishRow();e++)for(var f=b.startCol();f<=b.finishCol();f++)c=
  c&&Ib.getAt(a,e,f).exists(d);return c?g.some(b):g.none()}},nN=function(a,b,c){b=Ib.findItem(a,b,N.eq);var d=Ib.findItem(a,c,N.eq);return b.bind(function(a){return d.map(function(b){return Na.bounds(Math.min(a.row(),b.row()),Math.min(a.column(),b.column()),Math.max(a.row()+a.rowspan()-1,b.row()+b.rowspan()-1),Math.max(a.column()+a.colspan()-1,b.column()+b.colspan()-1))})})},oN={getAnyBox:nN,getBox:function(a,b,c){return nN(a,b,c).bind(function(b){return mN.isRectangular(a,b)})}},hl={moveBy:function(a,
  b,c,d){return Ib.findItem(a,b,N.eq).bind(function(b){var e=0<c?b.row()+b.rowspan()-1:b.row();b=0<d?b.column()+b.colspan()-1:b.column();return Ib.getAt(a,e+c,b+d).map(function(a){return a.element()})})},intercepts:function(a,b,c){return oN.getAnyBox(a,b,c).map(function(b){b=Ib.filterItems(a,u(mN.inSelection,b));return E(b,function(a){return a.element()})})},parentCell:function(a,b){return Ib.findItem(a,b,function(a,b){return N.contains(b,a)}).bind(function(a){return a.element()})}},wp=function(a){a=
  fg.fromTable(a);return Ib.generate(a)},Oi={moveBy:function(a,b,c){return tb.table(a).bind(function(d){d=wp(d);return hl.moveBy(d,a,b,c)})},intercepts:function(a,b,c){a=wp(a);return hl.intercepts(a,b,c)},nestedIntercepts:function(a,b,c,d,e){var f=wp(a);b=N.eq(a,c)?b:hl.parentCell(f,b);a=N.eq(a,e)?d:hl.parentCell(f,d);return hl.intercepts(f,b,a)},getBox:function(a,b,c){a=wp(a);return oN.getBox(a,b,c)}},Xv=function(a,b){return L.ancestor(a,"table")},il=Aa(["boxes","start","finish"],[]),pN=function(a,
  b,c){var d=function(a){return function(b){return c(b)||N.eq(b,a)}};return N.eq(a,b)?g.some(il({boxes:g.some([a]),start:a,finish:b})):Xv(a,c).bind(function(e){return Xv(b,c).bind(function(f){if(N.eq(e,f))return g.some(il({boxes:Oi.intercepts(e,a,b),start:a,finish:b}));if(N.contains(e,f)){var h=Y.ancestors(b,"td,th",d(e));h=0<h.length?h[h.length-1]:b;return g.some(il({boxes:Oi.nestedIntercepts(e,a,e,b,f),start:a,finish:h}))}return N.contains(f,e)?(h=Y.ancestors(a,"td,th",d(f)),h=0<h.length?h[h.length-
  1]:a,g.some(il({boxes:Oi.nestedIntercepts(f,a,e,b,f),start:a,finish:h}))):nf.ancestors(a,b).shared().bind(function(h){return L.closest(h,"table",c).bind(function(c){var h=Y.ancestors(b,"td,th",d(c));h=0<h.length?h[h.length-1]:b;var k=Y.ancestors(a,"td,th",d(c));k=0<k.length?k[k.length-1]:a;return g.some(il({boxes:Oi.nestedIntercepts(c,a,e,b,f),start:k,finish:h}))})})})})},uda=function(a,b){return qa(a,function(a){return Ia.is(a,b)})},vda=function(a,b){return L.ancestor(a,"table").bind(function(c){return L.descendant(c,
  b).bind(function(b){return pN(b,a).bind(function(a){return a.boxes().map(function(b){return{boxes:k(b),start:k(a.start()),finish:k(a.finish())}})})})})},Qf={identify:pN,retrieve:function(a,b){a=Y.descendants(a,b);return 0<a.length?g.some(a):g.none()},shiftSelection:function(a,b,c,d,e){return uda(a,e).bind(function(a){return Oi.moveBy(a,b,c).bind(function(a){return vda(a,d)})})},getEdges:function(a,b,c){return L.descendant(a,b).bind(function(b){return L.descendant(a,c).bind(function(a){return nf.sharedOne(Xv,
  [b,a]).map(function(c){return{first:k(b),last:k(a),table:k(c)}})})})}},qN=function(a,b,c,d,e){return N.eq(c,d)?g.none():Qf.identify(c,d,b).bind(function(b){var d=b.boxes().getOr([]);return 0<d.length?(e(a,d,b.start(),b.finish()),g.some(Mi.response(g.some(Kh.makeSitus(c,0,c,wa.getEnd(c))),!0))):g.none()})},Yv={sync:function(a,b,c,d,e,f,h){return N.eq(c,e)&&d===f?g.none():L.closest(c,"td,th",b).bind(function(c){return L.closest(e,"td,th",b).bind(function(d){return qN(a,b,c,d,h)})})},detect:qN,update:function(a,
  b,c,d,e){return Qf.shiftSelection(d,a,b,e.firstSelectedSelector(),e.lastSelectedSelector()).map(function(a){e.clear(c);e.selectRange(c,a.boxes(),a.start(),a.finish());return a.boxes()})}},Pi=Aa(["left","top","right","bottom"],[]),Ed={nu:Pi,moveUp:function(a,b){return Pi({left:a.left(),top:a.top()-b,right:a.right(),bottom:a.bottom()-b})},moveDown:function(a,b){return Pi({left:a.left(),top:a.top()+b,right:a.right(),bottom:a.bottom()+b})},moveBottomTo:function(a,b){var c=a.bottom()-a.top();return Pi({left:a.left(),
  top:b-c,right:a.right(),bottom:b})},moveTopTo:function(a,b){var c=a.bottom()-a.top();return Pi({left:a.left(),top:b,right:a.right(),bottom:b+c})},getTop:function(a){return a.top()},getBottom:function(a){return a.bottom()},translate:function(a,b,c){return Pi({left:a.left()+b,top:a.top()+c,right:a.right()+b,bottom:a.bottom()+c})},toString:function(a){return"("+a.left()+", "+a.top()+") -> ("+a.right()+", "+a.bottom()+")"}},xp=function(a){return Ed.nu({left:a.left,top:a.top,right:a.right,bottom:a.bottom})},
  yp={getBoxAt:function(a,b,c){return D.isElement(b)?g.some(a.getRect(b)).map(xp):D.isText(b)?(a=0<=c&&c<wa.getEnd(b)?a.getRangedRect(b,c,b,c+1):0<c?a.getRangedRect(b,c-1,b,c):g.none(),a.map(xp)):g.none()},getEntireBox:function(a,b){return D.isElement(b)?g.some(a.getRect(b)).map(xp):D.isText(b)?a.getRangedRect(b,0,b,wa.getEnd(b)).map(xp):g.none()}},Qe=ta.generate([{none:[]},{retry:["caret"]}]),rN=function(a,b,c){return Ja.closest(b,pa.isBlock).fold(k(!1),function(b){return yp.getEntireBox(a,b).exists(function(a){return c.left()<
  a.left()||1>Math.abs(a.right()-c.left())||c.left()>a.right()})})},wda={point:Ed.getBottom,adjuster:function(a,b,c,d,e){var f=Ed.moveDown(e,5);return 1>Math.abs(c.bottom()-d.bottom())?Qe.retry(f):c.top()>e.bottom()?Qe.retry(f):c.top()===e.bottom()?Qe.retry(Ed.moveDown(e,1)):rN(a,b,e)?Qe.retry(Ed.translate(f,5,0)):Qe.none()},move:Ed.moveDown,gather:wc.after},xda=function(a,b,c){return a.elementFromPoint(b,c).filter(function(a){return"table"===D.name(a)}).isSome()},yda=function(a,b,c,d,e){return Zv(a,
  b,c,b.move(d,5),e)},Zv=function(a,b,c,d,e){return 0===e?g.some(d):xda(a,d.left(),b.point(d))?yda(a,b,c,d,e-1):a.situsFromPoint(d.left(),b.point(d)).bind(function(f){return f.start().fold(g.none,function(f,k){return yp.getEntireBox(a,f,k).bind(function(h){return b.adjuster(a,f,h,c,d).fold(g.none,function(d){return Zv(a,b,c,d,e-1)})}).orThunk(function(){return g.some(d)})},g.none)})},zda=function(a,b,c){return a.point(b)>c.getInnerHeight()?g.some(a.point(b)-c.getInnerHeight()):0>a.point(b)?g.some(-a.point(b)):
  g.none()},sN=function(a,b,c){var d=a.move(c,5),e=Zv(b,a,c,d,100).getOr(d);return zda(a,e,b).fold(function(){return b.situsFromPoint(e.left(),a.point(e))},function(c){b.scrollBy(0,c);return b.situsFromPoint(e.left(),a.point(e)-c)})},jl={tryUp:u(sN,{point:Ed.getTop,adjuster:function(a,b,c,d,e){var f=Ed.moveUp(e,5);return 1>Math.abs(c.top()-d.top())?Qe.retry(f):c.bottom()<e.top()?Qe.retry(f):c.bottom()===e.top()?Qe.retry(Ed.moveUp(e,1)):rN(a,b,e)?Qe.retry(Ed.translate(f,5,0)):Qe.none()},move:Ed.moveUp,
  gather:wc.before}),tryDown:u(sN,wda),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:k(5)},zp=ta.generate([{none:["message"]},{success:[]},{failedUp:["cell"]},{failedDown:["cell"]}]),Ada=function(a){return L.closest(a,"tr")},Qi={verify:function(a,b,c,d,e,f,h){return L.closest(d,"td,th",h).bind(function(c){return L.closest(b,"td,th",h).map(function(b){return N.eq(c,b)?N.eq(d,c)&&wa.getEnd(c)===e?
  f(b):zp.none("in same cell"):nf.sharedOne(Ada,[c,b]).fold(function(){var d=a.getRect(b),e=a.getRect(c);return e.right>d.left&&e.left<d.right?zp.success():f(b)},function(a){return f(b)})})}).getOr(zp.none("default"))},cata:function(a,b,c,d,e){return a.fold(b,c,d,e)},adt:zp},Bda=O("ancestor","descendants","element","index"),tN=O("parent","children","element","index"),Ap=function(a,b){return Va(a,u(N.eq,b))},Cda={childOf:function(a,b){return Ja.closest(a,function(a){return A.parent(a).exists(function(a){return N.eq(a,
  b)})})},indexOf:Ap,indexInParent:function(a){return A.parent(a).bind(function(b){var c=A.children(b);return Ap(c,a).map(function(d){return tN(b,c,a,d)})})},selectorsInParent:function(a,b){return A.parent(a).bind(function(c){var d=Y.children(c,b);return Ap(d,a).map(function(b){return tN(c,d,a,b)})})},descendantsInAncestor:function(a,b,c){return L.closest(a,b).bind(function(b){var d=Y.descendants(b,c);return Ap(d,a).map(function(c){return Bda(b,d,a,c)})})}},$v=function(a){return"br"===D.name(a)},aw=
  function(a,b,c){return b(a,c).bind(function(a){return D.isText(a)&&0===Ya.get(a).trim().length?aw(a,b,c):g.some(a)})},Dda=function(a,b,c){return c.traverse(b).orThunk(function(){return aw(b,c.gather,a)}).map(c.relative)},Eda=function(a,b){return A.child(a,b).filter($v).orThunk(function(){return A.child(a,b-1).filter($v)})},Fda=function(a,b,c,d){return Eda(b,c).bind(function(b){return d.traverse(b).fold(function(){return aw(b,d.gather,a).map(d.relative)},function(a){return Cda.indexInParent(a).map(function(a){return la.on(a.parent(),
  a.index())})})})},uN={tryBr:function(a,b,c,d){return($v(b)?Dda(a,b,d):Fda(a,b,c,d)).map(function(a){return{start:k(a),finish:k(a)}})},process:function(a){return Qi.cata(a,function(a){return g.none()},function(){return g.none()},function(a){return g.some(W.point(a,0))},function(a){return g.some(W.point(a,wa.getEnd(a)))})}},kl=aa.detect(),Gda=function(a,b,c){return a.getSelection().bind(function(d){return uN.tryBr(b,d.finish(),d.foffset(),c).fold(function(){return g.some(W.point(d.finish(),d.foffset()))},
  function(e){e=a.fromSitus(e);e=Qi.verify(a,d.finish(),d.foffset(),e.finish(),e.foffset(),c.failure,b);return uN.process(e)})})},bw=function(a,b,c,d,e,f){return 0===f?g.none():Hda(a,b,c,d,e).bind(function(h){var k=a.fromSitus(h);k=Qi.verify(a,c,d,k.finish(),k.foffset(),e.failure,b);return Qi.cata(k,function(){return g.none()},function(){return g.some(h)},function(h){return N.eq(c,h)&&0===d?vN(a,c,d,Ed.moveUp,e):bw(a,b,h,0,e,f-1)},function(h){return N.eq(c,h)&&d===wa.getEnd(h)?vN(a,c,d,Ed.moveDown,
  e):bw(a,b,h,wa.getEnd(h),e,f-1)})})},vN=function(a,b,c,d,e){return yp.getBoxAt(a,b,c).bind(function(b){return wN(a,e,d(b,jl.getJumpSize()))})},wN=function(a,b,c){return kl.browser.isChrome()||kl.browser.isSafari()||kl.browser.isFirefox()||kl.browser.isEdge()?b.otherRetry(a,c):kl.browser.isIE()?b.ieRetry(a,c):g.none()},Hda=function(a,b,c,d,e){return yp.getBoxAt(a,c,d).bind(function(b){return wN(a,e,b)})},Ida={handle:function(a,b,c){return Gda(a,b,c).bind(function(d){return bw(a,b,d.element(),d.offset(),
  c,20).map(a.fromSitus)})}},Jda=aa.detect(),Kda=function(a,b){return wd.ancestor(a,function(a){return A.parent(a).exists(function(a){return N.eq(a,b)})})},xN=function(a,b,c,d,e){return L.closest(d,"td,th",b).bind(function(d){return L.closest(d,"table",b).bind(function(f){return Kda(e,f)?Ida.handle(a,b,c).bind(function(a){return L.closest(a.finish(),"td,th",b).map(function(b){return{start:k(d),finish:k(b),range:k(a)}})}):g.none()})})},yN=function(a,b,c,d,e,f){return Jda.browser.isIE()?g.none():f(d,
  b).orThunk(function(){return xN(a,b,c,d,e).map(function(a){a=a.range();return Mi.response(g.some(Kh.makeSitus(a.start(),a.soffset(),a.finish(),a.foffset())),!0)})})},zN=function(a,b,c,d,e,f,h){return xN(a,c,d,e,f).bind(function(a){return Yv.detect(b,c,a.start(),a.finish(),h)})},Lda=function(a,b){return L.closest(a,"tr",b).bind(function(a){return L.closest(a,"table",b).bind(function(c){var d=Y.descendants(c,"tr");return N.eq(a,d[0])?wc.seekLeft(c,function(a){return kc.last(a).isSome()},b).map(function(a){var b=
  wa.getEnd(a);return Mi.response(g.some(Kh.makeSitus(a,b,a,b)),!0)}):g.none()})})},Mda=function(a,b){return L.closest(a,"tr",b).bind(function(a){return L.closest(a,"table",b).bind(function(c){var d=Y.descendants(c,"tr");return N.eq(a,d[d.length-1])?wc.seekRight(c,function(a){return kc.first(a).isSome()},b).map(function(a){return Mi.response(g.some(Kh.makeSitus(a,0,a,0)),!0)}):g.none()})})},Rz=function(a,b){return L.closest(a,"td,th",b)},AN={traverse:A.nextSibling,gather:wc.after,relative:la.before,
  otherRetry:jl.tryDown,ieRetry:jl.ieTryDown,failure:Qi.adt.failedDown},BN={traverse:A.prevSibling,gather:wc.before,relative:la.before,otherRetry:jl.tryUp,ieRetry:jl.ieTryUp,failure:Qi.adt.failedUp},Ri=O("rows","cols"),Uz={mouse:function(a,b,c,d){a=Qz(a);b=xW(a,b,c,d);return{mousedown:b.mousedown,mouseover:b.mouseover,mouseup:b.mouseup}},keyboard:function(a,b,c,d){var e=Qz(a),f=function(){d.clear(b);return g.none()};return{keydown:function(a,k,q,m,w,n){var h=a.raw().which,l=!0===a.raw().shiftKey;return Qf.retrieve(b,
  d.selectedSelector()).fold(function(){return Nd.isDown(h)&&l?u(zN,e,b,c,AN,m,k,d.selectRange):Nd.isUp(h)&&l?u(zN,e,b,c,BN,m,k,d.selectRange):Nd.isDown(h)?u(yN,e,c,AN,m,k,Mda):Nd.isUp(h)?u(yN,e,c,BN,m,k,Lda):g.none},function(a){var c=function(c){return function(){return yc(c,function(c){return Yv.update(c.rows(),c.cols(),b,a,d)}).fold(function(){return Qf.getEdges(b,d.firstSelectedSelector(),d.lastSelectedSelector()).map(function(a){var c=Nd.isDown(h)||n.isForward(h)?la.after:la.before;e.setRelativeSelection(la.on(a.first(),
  0),c(a.table()));d.clear(b);return Mi.response(g.none(),!0)})},function(a){return g.some(Mi.response(g.none(),!0))})}};return Nd.isDown(h)&&l?c([Ri(1,0)]):Nd.isUp(h)&&l?c([Ri(-1,0)]):n.isBackward(h)&&l?c([Ri(0,-1),Ri(-1,0)]):n.isForward(h)&&l?c([Ri(0,1),Ri(1,0)]):Nd.isNavigation(h)&&!1===l?f:g.none})()},keyup:function(a,e,f,k,m){return Qf.retrieve(b,d.selectedSelector()).fold(function(){var h=a.raw().which;return!0===a.raw().shiftKey===!1?g.none():Nd.isNavigation(h)?Yv.sync(b,c,e,f,k,m,d.selectRange):
  g.none()},g.none)}}}},Sz={byClass:function(a){var b=yf.addClass(a.selected()),c=yf.removeClasses([a.selected(),a.lastSelected(),a.firstSelected()]),d=function(b){b=Y.descendants(b,a.selectedSelector());z(b,c)};return{clear:d,selectRange:function(c,f,h,g){d(c);z(f,b);n.add(h,a.firstSelected());n.add(g,a.lastSelected())},selectedSelector:a.selectedSelector,firstSelectedSelector:a.firstSelectedSelector,lastSelectedSelector:a.lastSelectedSelector}},byAttr:function(a){var b=function(b){m.remove(b,a.selected());
  m.remove(b,a.firstSelected());m.remove(b,a.lastSelected())},c=function(b){m.set(b,a.selected(),"1")},d=function(c){c=Y.descendants(c,a.selectedSelector());z(c,b)};return{clear:d,selectRange:function(b,f,h,g){d(b);z(f,c);m.set(h,a.firstSelected(),"1");m.set(g,a.lastSelected(),"1")},selectedSelector:a.selectedSelector,firstSelectedSelector:a.firstSelectedSelector,lastSelectedSelector:a.lastSelectedSelector}}},Vz={retrieve:function(a,b){return Qf.retrieve(a,b)},retrieveBox:function(a,b,c){return Qf.getEdges(a,
  b,c).bind(function(b){var c=function(b){return N.eq(a,b)},d=L.ancestor(b.first(),"thead,tfoot,tbody,table",c),h=L.ancestor(b.last(),"thead,tfoot,tbody,table",c);return d.bind(function(a){return h.bind(function(c){return N.eq(a,c)?Oi.getBox(b.table(),b.first(),b.last()):g.none()})})})}},AW={configure:function(a){z([a.output(),a.internal()],function(b){var c=[te.lastSelected(),te.firstSelected(),te.selected()],d=E(c,function(a){return"."+a}).join(",");a.addSelector(b,d,function(a){z(a,yf.removeClasses(c))})})}},
  CN=function(a){return 0===a.button},Bp=function(a,b){return{bind:function(c,d){return ws.bind(c,a,b,d)}}},tm={realClick:Bp("click",function(a){return 6===a.mozInputSource||0===a.mozInputSource?!1:void 0!==a.isTrusted&&!0!==a.isTrusted?!1:!0}),leftDown:Bp("mousedown",CN),leftPressedOver:Bp("mouseover",function(a){return void 0===a.buttons?!0:0!==(a.buttons&1)}),leftUp:Bp("mouseup",CN)},Tz=aa.detect(),DW=function(a){var b=aa.detect(),c=b.os.isOSX(),d=b.os.isLinux(),e=c?R.META():R.CTRL();b=[[e,"Z"]];
  var f=c?[[R.META(),R.SHIFT(),"Z"]]:d?[[R.CTRL(),"Y"],[R.CTRL(),R.SHIFT(),"Z"]]:[[R.CTRL(),"Y"]],h=[[R.SHIFT(),121]],g=c?[[R.ALT(),121]]:[[121]],k=[[e,R.SHIFT(),"F"]];d=c?[[R.META(),R.ALT(),"U"]]:d?[[R.CTRL(),R.ALT(),"U"]]:[[R.CTRL(),R.SHIFT(),"U"]];c=c?[[R.CTRL(),R.ALT(),"H"]]:[[R.CTRL(),R.SHIFT(),"H"]];var m=[[e,"B"]],w=[[e,"I"]],n=[[e,"U"]],p=[[e,221],[e,"M"]],r=[[e,219],[e,R.SHIFT(),"M"]],t=[[e,R.SHIFT(),"9"]],u=[[e,"K"]];e=[[e,"F"]];var v=O("keys","trigger");return{undo:v(b,a.trigger.undo),redo:v(f,
  a.trigger.redo),context:v(h,a.trigger.context),toolbar:v(g,a.trigger.toolbar),bold:v(m,a.trigger.bold),italic:v(w,a.trigger.italic),underline:v(n,a.trigger.underline),indent:v(p,a.trigger.indent),outdent:v(r,a.trigger.outdent),link:v(u,a.trigger.link),search:v(e,a.trigger.search),blockquote:v(t,a.trigger.blockquote),help:v(c,a.trigger.help),fullscreen:v(k,a.trigger.fullscreen),plaincode:v(d,a.trigger.plaincode)}},EW=function(a,b){return function(c){return U(a,c)?g.some(b):g.none()}},DN=function(a){return function(b){return b.key()===
  a}},Nda=O("key","value"),GW={put:function(a,b,c,d,e){var f=void 0!==d?d:Nda,h=void 0!==e?e:DN(b);a=hb(a,function(a,d){var e=h(d)?f(b,c):d;return{updated:h(d)||a.updated,acc:a.acc.concat([e])}},{updated:!1,acc:[]});return a.updated?a.acc:a.acc.concat([f(b,c)])},get:function(a,b,c){b=void 0!==c?c:DN(b);return qa(a,b)}},HW=O("popup","anchor"),Wz={bind:function(a,b){var c=Za.get(a);return{unbind:K.bind(a,"scroll",function(d){d=Za.get(a);d.top()===c.top()&&d.left()===c.left()||b(d);c=d}).unbind}}},OW=
  {isDefaultEmpty:function(a){return/^\s*<p>\s*<br\s?\/?>\s*<\/p>\s*$/.test(a)}},MW={fromInitial:function(a){return Xz({initial:a,undo:[],redo:[]})},fromState:function(a){return Xz(a)}},um=O("raw","marked"),NW=function(a){return um(a.raw,a.marked)},Yz=function(a,b){return{initial:b(a.initial),undo:E(a.undo,b),redo:E(a.redo,b)}},PW=function(a){return{raw:a.raw(),marked:a.marked()}},cw=ta.generate([{aboveView:["item"]},{inView:["item"]},{belowView:["item"]}]),Qg={aboveView:cw.aboveView,inView:cw.inView,
  belowView:cw.belowView,cata:function(a,b,c,d){return a.fold(b,c,d)}},A0=function(a,b,c){var d=mz(a),e=uW(c.profile),f=UV(c.filters),h=WV(),l=cca(f,h,a.content,b,c.content),m=zW(b,f,l),n=CW(l,a.shortcuts),w=a.ui.layout.bounds(a.ui),p=IW(l,w,b,a.ui),r=!1!==a.fullscreen.bundled?VV(l,n,a.fullscreen):Sa.fullscreen(),t=tW(l,p,b,r,a.platform),u=KW(l,n,p,t,r,b,a.ui,c.ui),v=$V(l,u),y=LW(f,l,v,n,c.undo),A=MV(l,m,v,y),B=vW(l,v,y),D=bW(f,l),F=PV(l,y,a.editorcontext),E=QW(l,a.ui.autoresize),H=wW(u,a.registration),
  J=KV(b,l,v,n,p,a.contextmenu),K=yz.onNodeChange(l,D),M=dy(c.laundry);y.events.changed.bind(function(){M.setDirty(!0)});M.events.clean.bind(function(){l.undoChanged()});l.events.interaction.bind(function(a){!M.isDirty()&&y.checkChanged()&&M.setDirty(!0)});var N=aa.detect(),O=N.deviceType.isTouch();w=n.isHelpShortcutEnabled();c=!l.isInline()&&!O&&a.ui.showHelpHint;a=eba.editor(a.ui.editorName,a.ui.isFullScreen);N=x.translate(N.os.isOSX()?"aria.help.mac":"aria.help.ctrl");w=w?g.some(N):g.none();var P=
  (l.isInline()?S.inline:S.editor)(u.element(),l.element(),a,w,c),Q=g.none();l.runOrOnLoaded(function(a){var b=rm.handle(a,function(a){L.closest(a.target(),"a").each(function(b){L.closest(b,'[contenteditable="false"]').each(a.kill)})});Q=g.some(b);O&&(S.label(a,x.translate("aria.label.content")),S.region(u.viewport()),S.region(u.tabstrip.element()))});return{region:k(b),communication:k(d),profile:k(e),filter:k(f),internalevents:k(h),content:k(l),keyboard:k(v),shortcuts:k(n),smartview:k(p),undo:k(y),
  del:k(A),proximity:k(B),operations:k(D),context:k(F),fullscreen:k(r),platform:k(t),registration:k(H),contextmenu:k(J),ui:k(u),selections:k(m),insertFilteredHtmlAtCursor:function(a){a=f.filterHtml(f.input(),a);l.insertHtmlAtCursor(a)},viewablearea:k(E),laundry:k(M),state:function(){return{ui:u.state(),undo:y.state(),content:l.state(),profile:e.state(),laundry:M.state()}},destroy:function(){Q.each(function(a){a.unbind()});z([l,E,K,J,H,t,r,F,D,B,y,A,p,n,v,m,f,e,d,u],function(a){a.destroy?a.destroy():
  console.log("Feature missing destroy method: ",a)});P.destroy()}}},Sb={resolve:Lb.create("ephox-hermes").resolve},EN=function(){var a=H.create({upload:r(["files"])}),b=p.fromTag("input");n.add(b,Sb.resolve("hidden"));n.add(b,Sb.resolve("file-selector-input"));m.setAll(b,{type:"file",accept:"image/*"});var c=K.bind(b,"change",function(b){b=ve.toFiles(b);a.trigger.upload(b)});return{element:k(b),open:function(){fa.set(b,"");b.dom().click()},destroy:function(){c.unbind()},events:a.registry}},$z={single:EN,
  multiple:function(){var a=EN();m.set(a.element(),"multiple","multiple");return{element:a.element,open:a.open,destroy:a.destroy,events:a.events}}},FN=function(a,b){return E(b,function(b){var c=p.fromTag("img"),e=K.bind(c,"load",function(){e.unbind();a.domChanged()});b=Pc.cata(b,function(a,b,c){return c},function(a,b,c){return b});m.set(c,"src",b);return c})},pr={insertMobileAssets:function(a,b,c,d){var e=FN(a,d);return a.undoOperation(function(){var f=rd.insertAt(a,b,e);c.uploadAssets(d);return f})},
  insertAssets:function(a,b,c){var d=FN(a,c);a.focus();a.undoOperation(function(){rd.insertAtCursor(a,d).each(function(b){a.setSelection(b.element(),b.offset(),b.element(),b.offset())});b.uploadAssets(c)})}},lc={resolve:Lb.create("ephox-gel").resolve},UW=aa.detect().deviceType.isiOS(),VW=aa.detect(),GN=function(a){a.dom().click();return g.some(a)},Kb={setup:function(a,b,c){b=Ba.dialog({execute:function(a){a.dom().click()},ok:b.ok().element(),cancel:b.cancel().element()});a=ha.dialog(a.element(),c,b);
  return{enter:a.enter,exit:a.exit,destroy:a.destroy}},button:function(a){return(Ia.is(a,".ephox-pastry-button")?g.some(a):L.descendant(a,".ephox-pastry-button")).bind(GN)},click:GN,radio:function(a,b,c){b={item:k(b),selected:k(c)};return ha.radio(a,b,Ba.radio({one:function(a,b){b.dom().click()}}))}},XW={previewAsset:function(a,b){Pc.cata(a,yb("asset should not be a file type"),function(a,d,e){n.add(b,Sb.resolve("fluid-image"));m.set(b,"src",d)})}},cA=aa.detect(),Rg=O("heading","renderer"),nr={left:k("left"),
  top:k("top")},Oda=["image"],Pda=function(a,b,c){return Xa(Oda,function(a){return xa(b.getType())&&-1<b.getType().indexOf(a)})},gX={validate:function(a){a=hb(a,function(a,c){return!1===Pc.cata(c,Pda,k(!0))?{assets:a.assets,failure:!0}:{assets:a.assets.concat([c]),failure:a.failure}},{assets:[],failure:!1});return{assets:k(a.assets),failure:k(a.failure)}}},Re={multiple:function(a){return ve.multiple(a)},single:function(a){return ve.single(a)},singleWithUrl:function(a,b){return ve.singleWithUrl(a,b)}},
  dw=[0,.01,.02,.04,.05,.06,.07,.08,.1,.11,.12,.14,.15,.16,.17,.18,.2,.21,.22,.24,.25,.27,.28,.3,.32,.34,.36,.38,.4,.42,.44,.46,.48,.5,.53,.56,.59,.62,.65,.68,.71,.74,.77,.8,.83,.86,.89,.92,.95,.98,1,1.06,1.12,1.18,1.24,1.3,1.36,1.42,1.48,1.54,1.6,1.66,1.72,1.78,1.84,1.9,1.96,2,2.12,2.25,2.37,2.5,2.62,2.75,2.87,3,3.2,3.4,3.6,3.8,4,4.3,4.7,4.9,5,5.5,6,6.5,6.8,7,7.3,7.5,7.8,8,8.4,8.7,9,9.4,9.6,9.8,10],of={identity:function(){return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]},adjust:or,multiply:Rf,
  adjustContrast:function(a,b){b=ge(b,-1,1);b*=100;if(0>b)var c=127+b/100*127;else c=b%1,c=0===c?dw[b]:dw[Math.floor(b)]*(1-c)+dw[Math.floor(b)+1]*c,c=127*c+127;return Rf(a,[c/127,0,0,0,.5*(127-c),0,c/127,0,0,.5*(127-c),0,0,c/127,0,.5*(127-c),0,0,0,1,0,0,0,0,0,1])},adjustBrightness:function(a,b){b=ge(255*b,-255,255);return Rf(a,[1,0,0,0,b,0,1,0,0,b,0,0,1,0,b,0,0,0,1,0,0,0,0,0,1])},adjustSaturation:function(a,b){b=ge(b,-1,1);b=1+(0<b?3*b:b);return Rf(a,[.3086*(1-b)+b,.6094*(1-b),.082*(1-b),0,0,.3086*
  (1-b),.6094*(1-b)+b,.082*(1-b),0,0,.3086*(1-b),.6094*(1-b),.082*(1-b)+b,0,0,0,0,0,1,0,0,0,0,0,1])},adjustHue:function(a,b){b=ge(b,-180,180)/180*Math.PI;var c=Math.cos(b);b=Math.sin(b);return Rf(a,[.213+.787*c+-.213*b,.715+-.715*c+-.715*b,.072+-.072*c+.928*b,0,0,.213+-.213*c+.143*b,.715+c*(1-.715)+.14*b,.072+-.072*c+-.283*b,0,0,.213+-.213*c+-.787*b,.715+-.715*c+.715*b,.072+.928*c+.072*b,0,0,0,0,0,1,0,0,0,0,0,1])},adjustColors:function(a,b,c,d){b=ge(b,0,2);c=ge(c,0,2);d=ge(d,0,2);return Rf(a,[b,0,0,
  0,0,0,c,0,0,0,0,0,d,0,0,0,0,0,1,0,0,0,0,0,1])},adjustSepia:function(a,b){b=ge(b,0,1);return Rf(a,or([.393,.769,.189,0,0,.349,.686,.168,0,0,.272,.534,.131,0,0,0,0,0,1,0,0,0,0,0,1],b))},adjustGrayscale:function(a,b){b=ge(b,0,1);return Rf(a,or([.33,.34,.33,0,0,.33,.34,.33,0,0,.33,.34,.33,0,0,0,0,0,1,0,0,0,0,0,1],b))}},Wd={invert:function(a){return function(b){return vm(b,a)}}([-1,0,0,0,255,0,-1,0,0,255,0,0,-1,0,255,0,0,0,1,0]),brightness:Mh(of.adjustBrightness),hue:Mh(of.adjustHue),saturate:Mh(of.adjustSaturation),
  contrast:Mh(of.adjustContrast),grayscale:Mh(of.adjustGrayscale),sepia:Mh(of.adjustSepia),colorize:function(a,b,c,d){return vm(a,of.adjustColors(of.identity(),b,c,d))},sharpen:jA([0,-1,0,-1,5,-1,0,-1,0]),emboss:jA([-2,-1,0,-1,1,1,0,1,2]),gamma:iA(function(a,b){return 255*Math.pow(a/255,1-b)}),exposure:iA(function(a,b){return 255*(1-Math.exp(-(a/255)*b))}),colorFilter:vm,convoluteFilter:hA},Qda={scale:kA},Cp={rotate:function(a,b){return a.toCanvas().then(function(c){var d=a.getType(),e=b,f=Tc.create(c.width,
  c.height),h=Tc.get2dContext(f),g=0,k=0;e=0>e?360+e:e;90!=e&&270!=e||Tc.resize(f,f.height,f.width);if(90==e||180==e)g=f.width;if(270==e||180==e)k=f.height;h.translate(g,k);h.rotate(e*Math.PI/180);h.drawImage(c,0,0);return xe.fromCanvas(f,d)})},flip:function(a,b){return a.toCanvas().then(function(c){var d=a.getType(),e=Tc.create(c.width,c.height),f=Tc.get2dContext(e);"v"==b?(f.scale(1,-1),f.drawImage(c,0,-e.height)):(f.scale(-1,1),f.drawImage(c,-e.width,0));return xe.fromCanvas(e,d)})},crop:function(a,
  b,c,d,e){return a.toCanvas().then(function(f){var h=a.getType(),g=Tc.create(d,e);Tc.get2dContext(g).drawImage(f,-b,-c);return xe.fromCanvas(g,h)})},resize:function(a,b,c){return a.toCanvas().then(function(d){return Qda.scale(d,b,c).then(function(b){return xe.fromCanvas(b,a.getType())})})}},HN=function(){function a(a){this.littleEndian=!1;this._dv=new DataView(a)}a.prototype.readByteAt=function(a){return this._dv.getUint8(a)};a.prototype.read=function(a,c){if(a+c>this.length())return null;for(var b=
  this.littleEndian?0:-8*(c-1),e=0,f=0;e<c;e++)f|=this.readByteAt(a+e)<<Math.abs(b+8*e);return f};a.prototype.BYTE=function(a){return this.read(a,1)};a.prototype.SHORT=function(a){return this.read(a,2)};a.prototype.LONG=function(a){return this.read(a,4)};a.prototype.SLONG=function(a){a=this.read(a,4);return 2147483647<a?a-4294967296:a};a.prototype.CHAR=function(a){return String.fromCharCode(this.read(a,1))};a.prototype.STRING=function(a,c){return this.asArray("CHAR",a,c).join("")};a.prototype.SEGMENT=
  function(a,c){var b=this._dv.buffer;switch(arguments.length){case 2:return b.slice(a,a+c);case 1:return b.slice(a);default:return b}};a.prototype.asArray=function(a,c,d){for(var b=[],f=0;f<d;f++)b[f]=this[a](c+f);return b};a.prototype.length=function(){return this._dv?this._dv.byteLength:0};return a}(),Rda={274:"Orientation",270:"ImageDescription",271:"Make",272:"Model",305:"Software",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer"},Sda={36864:"ExifVersion",40961:"ColorSpace",40962:"PixelXDimension",
  40963:"PixelYDimension",36867:"DateTimeOriginal",33434:"ExposureTime",33437:"FNumber",34855:"ISOSpeedRatings",37377:"ShutterSpeedValue",37378:"ApertureValue",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37386:"FocalLength",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",41988:"DigitalZoomRatio",41992:"Contrast",41993:"Saturation",41994:"Sharpness"},Tda={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude"},Uda={513:"JPEGInterchangeFormat",
  514:"JPEGInterchangeFormatLength"},IN={ColorSpace:{1:"sRGB",0:"Uncalibrated"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{1:"Daylight",2:"Fliorescent",3:"Tungsten",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 -5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",
  18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",
  29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",
  89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},ExposureMode:{0:"Auto exposure",1:"Manual exposure",2:"Auto bracket"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},
  Sharpness:{0:"Normal",1:"Soft",2:"Hard"},GPSLatitudeRef:{N:"North latitude",S:"South latitude"},GPSLongitudeRef:{E:"East longitude",W:"West longitude"}},Vda=function(){function a(a){this._offsets={tiffHeader:10,IFD0:null,IFD1:null,exifIFD:null,gpsIFD:null};this._tiffTags={};this._reader=new HN(a);this._idx=this._offsets.tiffHeader;if(65505!==this.SHORT(0)||"EXIF\x00"!==this.STRING(4,5).toUpperCase())throw Error("Exif data cannot be read or not available.");this._reader.littleEndian=18761==this.SHORT(this._idx);
  if(42!==this.SHORT(this._idx+=2))throw Error("Invalid Exif data.");this._offsets.IFD0=this._offsets.tiffHeader+this.LONG(this._idx+=2);this._tiffTags=this.extractTags(this._offsets.IFD0,Rda);"ExifIFDPointer"in this._tiffTags&&(this._offsets.exifIFD=this._offsets.tiffHeader+this._tiffTags.ExifIFDPointer,delete this._tiffTags.ExifIFDPointer);"GPSInfoIFDPointer"in this._tiffTags&&(this._offsets.gpsIFD=this._offsets.tiffHeader+this._tiffTags.GPSInfoIFDPointer,delete this._tiffTags.GPSInfoIFDPointer);
  if(a=this.LONG(this._offsets.IFD0+12*this.SHORT(this._offsets.IFD0)+2))this._offsets.IFD1=this._offsets.tiffHeader+a}a.prototype.BYTE=function(a){return this._reader.BYTE(a)};a.prototype.SHORT=function(a){return this._reader.SHORT(a)};a.prototype.LONG=function(a){return this._reader.LONG(a)};a.prototype.SLONG=function(a){return this._reader.SLONG(a)};a.prototype.CHAR=function(a){return this._reader.CHAR(a)};a.prototype.STRING=function(a,c){return this._reader.STRING(a,c)};a.prototype.SEGMENT=function(a,
  c){return this._reader.SEGMENT(a,c)};a.prototype.asArray=function(a,c,d){for(var b=[],f=0;f<d;f++)b[f]=this[a](c+f);return b};a.prototype.length=function(){return this._reader.length()};a.prototype.UNDEFINED=function(){return this.BYTE.apply(this,arguments)};a.prototype.RATIONAL=function(a){return this.LONG(a)/this.LONG(a+4)};a.prototype.SRATIONAL=function(a){return this.SLONG(a)/this.SLONG(a+4)};a.prototype.ASCII=function(a){return this.CHAR(a)};a.prototype.TIFF=function(){return this._tiffTags};
  a.prototype.EXIF=function(){var a=null;if(this._offsets.exifIFD){try{a=this.extractTags(this._offsets.exifIFD,Sda)}catch(e){return null}if(a.ExifVersion&&Array.isArray(a.ExifVersion)){for(var c=0,d="";c<a.ExifVersion.length;c++)d+=String.fromCharCode(a.ExifVersion[c]);a.ExifVersion=d}}return a};a.prototype.GPS=function(){var a=null;if(this._offsets.gpsIFD){try{a=this.extractTags(this._offsets.gpsIFD,Tda)}catch(c){return null}a.GPSVersionID&&Array.isArray(a.GPSVersionID)&&(a.GPSVersionID=a.GPSVersionID.join("."))}return a};
  a.prototype.thumb=function(){if(this._offsets.IFD1)try{var a=this.extractTags(this._offsets.IFD1,Uda);if("JPEGInterchangeFormat"in a)return this.SEGMENT(this._offsets.tiffHeader+a.JPEGInterchangeFormat,a.JPEGInterchangeFormatLength)}catch(c){}return null};a.prototype.extractTags=function(a,c){var b,e={},f={1:"BYTE",7:"UNDEFINED",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",9:"SLONG",10:"SRATIONAL"},h={BYTE:1,UNDEFINED:1,ASCII:1,SHORT:2,LONG:4,RATIONAL:8,SLONG:4,SRATIONAL:8};var g=this.SHORT(a);for(b=
  0;b<g;b++){var k=a+2+12*b;var m=c[this.SHORT(k)];if(void 0!==m){var w=f[this.SHORT(k+=2)];var n=this.LONG(k+=2);var p=h[w];if(!p)throw Error("Invalid Exif data.");k+=4;4<p*n&&(k=this.LONG(k)+this._offsets.tiffHeader);if(k+p*n>=this.length())throw Error("Invalid Exif data.");"ASCII"===w?e[m]=this.STRING(k,n).replace(/\0$/,"").trim():(w=this.asArray(w,k,n),n=1==n?w[0]:w,IN.hasOwnProperty(m)&&"object"!=typeof n?e[m]=IN[m][n]:e[m]=n)}}return e};return a}(),Wda=function(a){var b=[],c;for(c=2;c<=a.length();){var d=
  a.SHORT(c);if(65488<=d&&65495>=d)c+=2;else{if(65498===d||65497===d)break;var e=a.SHORT(c+2)+2;65505<=d&&65519>=d&&b.push({hex:d,name:"APP"+(d&15),start:c,length:e,segment:a.SEGMENT(c,e)});c+=e}}return b},Xda=function(a){return id.blobToArrayBuffer(a).then(function(b){try{var c=new HN(b);if(65496===c.SHORT(0)){var d=Wda(c),e=d.filter(function(a){return"APP1"===a.name});b={};if(e.length){var f=new Vda(e[0].segment);b={tiff:f.TIFF(),exif:f.EXIF(),gps:f.GPS(),thumb:f.thumb()}}else return Md.reject("Headers did not include required information");
  b.rawHeaders=d;return b}return Md.reject("Image was not a jpeg")}catch(h){return Md.reject("Unsupported format or not an image: "+a.type+" (Exception: "+h.message+")")}})},Dp=function(a,b){return Cp.rotate(a,b)},Si={invert:function(a){return Wd.invert(a)},sharpen:function(a){return Wd.sharpen(a)},emboss:function(a){return Wd.emboss(a)},brightness:function(a,b){return Wd.brightness(a,b)},hue:function(a,b){return Wd.hue(a,b)},saturate:function(a,b){return Wd.saturate(a,b)},contrast:function(a,b){return Wd.contrast(a,
  b)},grayscale:function(a,b){return Wd.grayscale(a,b)},sepia:function(a,b){return Wd.sepia(a,b)},colorize:function(a,b,c,d){return Wd.colorize(a,b,c,d)},gamma:function(a,b){return Wd.gamma(a,b)},exposure:function(a,b){return Wd.exposure(a,b)},flip:function(a,b){return Cp.flip(a,b)},crop:function(a,b,c,d,e){return Cp.crop(a,b,c,d,e)},resize:function(a,b,c){return Cp.resize(a,b,c)},rotate:Dp,exifRotate:function(a){return a.toBlob().then(Xda).then(function(b){switch(b.tiff.Orientation){case 6:return Dp(a,
  90);case 3:return Dp(a,180);case 8:return Dp(a,270);default:return a}},function(){return a})}},ll=function(a){return function(b){return Xc.blobToImageResult(b).then(function(b){return a(b)}).then(Xc.imageResultToOriginalBlob)}},JN=function(a){return ll(function(b){return Si.rotate(b,a)})},KN=function(a){return ll(function(b){return Si.flip(b,a)})},Yda=function(a){return ll(function(b){return Si.resize(b,a.width(),a.height())})},Zda=Ua.pToFR(ll(Si.sharpen)),$da=Ua.pToFR(JN(-90)),aea=Ua.pToFR(JN(90)),
  bea=Ua.pToFR(KN("v")),cea=Ua.pToFR(KN("h")),Wg={rotateLeft:$da,rotateRight:aea,flipVertical:bea,flipHorizontal:cea,sharpen:Zda,crop:function(a,b,c,d){return Ua.pToFR(ll(function(e){return Si.crop(e,a,b,c,d)}))},resizeTo:function(a){return Ua.pToFR(Yda(a))},doExifRotate:function(a){return Ua.fromPromise(Si.exifRotate(a))}},LN={mapIfSet:function(a,b){return Ua.map(a,function(a){return a.map(b)})},applyIfSet:function(a){return function(b){return Ua.bind(a,function(a){return a.fold(function(){return Ua.pure(b)},
  function(a){return a(b)})})}}},Pj={partition:function(a){var b=[],c=[];z(a,function(a){a.fold(function(a){b.push(a)},function(a){c.push(a)})});return{errors:b,values:c}}},Ep=O("width","height"),MN=ta.generate([{special:["size"]},{regular:["value","size","unit"]}]),Fp={identify:function(a){a=a.match(/(\d*\.?\d*)(.*)/);return""!==a[1]?MN.regular(a[0],Number(a[1]),a[2]):MN.special(a[0])}},dea=function(a,b){return v.getRaw(a,b).orThunk(function(){return m.has(a,b)?g.some(m.get(a,b)):g.none()}).bind(function(a){return Fp.identify(a).fold(function(a){return g.none()},
  function(a,b,c){switch(c){case "":case "px":return g.some(parseInt(b,10));default:return g.none()}})})},ew=function(a,b,c){b=b(a);return 0<b?g.some(b):dea(a,c)},eea={get:function(a){return ew(a,Ga.get,"width").bind(function(b){return ew(a,sa.get,"height").map(function(a){return Ep(b,a)})})},measure:ew},NN=function(a,b){a=b/a;return 1>a?a:1},fea=function(a,b){var c=NN(a.height,b.height);return 1===c?a:{width:a.width*c,height:b.height}},gea=function(a,b){var c=NN(a.width,b.width);return 1===c?a:{width:b.width,
  height:a.height*c}},hea={max:function(a,b){var c=0<b.height?b.height:0;b=0<b.width?b.width:0;if(!(a.height>c||a.width>b)||c===b&&0===c)return a;c={width:b,height:c};b=a.width>a.height;var d=0<c.height,e=(d?a.height/c.height:0)>(0<c.width?a.width/c.width:0);return(c.width===c.height&&b||!d||!e?gea:fea)(a,c)}},iea=function(a){var b=bg.createObjectURL(a);return Ua.map(op.load(b),function(a){a=ON(a);bg.revokeObjectURL(b);return a})},ON=function(a){return Ep(a.dom().naturalWidth,a.dom().naturalHeight)},
  jea=function(a){var b=ON(a);return eea.get(a).filter(function(a){return a.width()!==b.width()||a.height()!==b.height()})},ur={restrain:function(a){var b=a.width(),c=a.height(),d=function(a){var d=hea.max({width:a.width(),height:a.height()},{width:b,height:c});return a.height()>c||a.width()>b?g.some(Ep(d.width,d.height)):g.none()};return function(a){a=iea(a);return Ua.map(a,d)}},changedBounds:function(a){return Ua.map(op.loadIfNeeded(a),jea)}},kea=function(a){a=LN.mapIfSet(a,Wg.resizeTo);return LN.applyIfSet(a)},
  PN=function(a,b,c){return Ua.fromChain([kea(a),c])(b)},Dj={instance:function(a){var b=ur.restrain(a);return function(a){return Pc.cata(a,function(c,e,f){c=Ua.fromPromise(Xc.imageResultToOriginalBlob(e));return Ua.bind(c,function(c){var d=b(c);return PN(d,c,function(b){if(b===c)return Ua.pure(a);bg.revokeObjectURL(f);return Ua.fromFuture(Re.single(b))})})},function(){return Ua.pure(a)})}},processResults:function(a){return function(b){b=Pj.partition(b);0<b.errors.length&&(a("imageedit.generic"),console.error("Image resample errors: ",
  b.errors));return b.values}},resampleAction:PN},lA={maybeDoRotate:function(a){return Ce(a,function(a){return a.fold(function(a){return Ua.error(a)},function(a){return Pc.cata(a,function(b,c,f){b=Wg.doExifRotate(c);return Ua.bind(b,function(b){if(b===c)return Ua.pure(a);b=Ua.fromPromise(Xc.imageResultToOriginalBlob(b));return Ua.bind(b,function(a){URL.revokeObjectURL(f);return Ua.fromFuture(Re.single(a))})})},function(){return Ua.pure(a)})})})}},QN=B.resolve("find-match"),RN=B.resolve("find-mark"),
  fw="."+QN+", ."+RN,Od={configure:function(a){a.addSelector(a.output(),fw,Ta.unwrap);a.addSelector(a.history(),fw,Ta.unwrap);a.addSelector(a.internal(),fw,Ta.unwrap)},matchClass:k(QN),markClass:k(RN),findIdAttr:k("data-ephox-find-id"),shiftKeyState:function(a){return{isShift:k(a)}}},Gp={created:function(a){return{fold:function(b,c){return c(a)}}},preserved:function(a){return{fold:function(b,c){return b(a)}}}},lea=O("id","match","current"),gw={resolve:Lb.create("data.ephox.cram").resolve},hw={resolve:Lb.create("ephox-cram").resolve},
  SN=gw.resolve("highlight-id"),mea=hw.resolve("highlight-wrap"),TN=function(a,b){return L.closest(a,"."+b)},UN=function(a){return g.from(m.get(a,SN))},xg={marker:TN,idMarker:function(a){return TN(a,mea)},id:UN,set:function(a,b){m.set(a,SN,b);n.add(a,b)},all:function(a){return UN(a).fold(k([a]),function(b){var c=A.owner(a);return Y.descendants(c,"."+b)})}},iw=O("word","pattern"),nea={separate:function(a,b,c){var d=ia(c,function(a){return[a.start(),a.finish()]}),e=Rd.splits(b,d,function(b,c){return oH.subdivide(a,
  b.element(),c)});return E(c,function(b){var c=Rd.sublist(e,b.start(),b.finish());c=E(c,function(a){return a.element()});var d=E(c,a.property().getText).join("");return{elements:k(c),word:b.word,exact:k(d)}})}},oea=function(a,b){return Rd.generate(b,function(b,d){var c=d+a.property().getText(b).length;return g.from(W.range(b,d,c))})},jw=function(a,b,c,d){b=pH.group(a,b,d);return ia(b,function(b){b=ln.justText(b);var d=E(b,a.property().getText).join("");d=Ko.findmany(d,c);b=oea(a,b);return nea.separate(a,
  b,d)})},kw={safeWords:function(a,b,c,d){c=E(c,function(a){var b=Cb.safeword(a);return iw(a,b)});return jw(a,b,c,d)},safeToken:function(a,b,c,d){c=iw(c,Cb.safetoken(c));return jw(a,b,[c],d)},run:jw},lw={safeWords:function(a,b,c,d){return kw.safeWords(a,b,c,d)},safeToken:function(a,b,c,d){return kw.safeToken(a,b,c,d)},run:function(a,b,c,d){return kw.run(a,b,c,d)}},mw=nb(),Hp={safeWords:function(a,b,c){return lw.safeWords(mw,a,b,c)},safeToken:function(a,b,c){return lw.safeToken(mw,a,b,c)},run:function(a,
  b,c){return lw.run(mw,a,b,c)}},pea=function(a,b){var c=ia(a.elements(),function(a){return xg.marker(a,b).fold(k([]),function(a){return[a]})}),d=Fa("ephox-cram");return lea(d,a,g.from(c[0]))},ml={matchWords:function(a,b,c){return Hp.safeWords(a,b,c)},matchToken:function(a,b,c){return Hp.safeToken(a,b,c)},matchPattern:function(a,b,c){return Hp.run(a,[b],c)},annotates:function(a,b){return E(a,function(a){return pea(a,b)})}},VN=function(a,b,c,d){b=ml.annotates(d,c.label());return ia(b,function(b){return b.current().fold(function(){var d=
  b.match();if(a.ignore(d))return[];d=wi.wrapper(d.elements(),c.nu)||[];z(d,u(c.tag,b));return[Gp.created(d)]},function(a){return[Gp.preserved(a)]})})},qea={highlight:function(a,b,c,d){c=ml.matchToken(b,c,a.optimise);return VN(a,b,d,c)},highlightPattern:function(a,b,c,d){c=ml.matchPattern(b,c,a.optimise);return VN(a,b,d,c)}},rea=function(a,b){return D.isElement(b)&&pa.isBlock(b)?0>Vb.get(b).toLowerCase().indexOf(a):!1},sea=function(a){return{ignore:k(!1),optimise:u(rea,a.toLowerCase())}},Ip=k("."+Od.matchClass()),
  tea={label:Od.matchClass,tag:function(a,b){n.add(b,Od.matchClass());m.set(b,Od.findIdAttr(),a.id())},nu:function(){var a=p.fromTag("span");return{element:k(a),wrap:u(y.append,a)}}},WN=function(a){z(a,function(a){n.add(a,Od.markClass())})},uea=function(a){z(a,function(a){n.remove(a,Od.markClass())})},nw=function(a,b){a=fm(Y.descendants(a,b),function(a){return m.get(a,Od.findIdAttr())});return 0===a.length?g.none():g.some(a)},XN=function(a,b){b=Cb.custom(Cb.sanitise(a),k(0),k(0),b);return iw(a,b)},
  ow=function(a,b,c){return nw(a,Ip()).map(function(d){var e=ka(d,function(a){return n.has(a[0],Od.markClass())}),f=Va(d,function(a){return U(e,a)}).getOr(-1);return{pos:c(d,Qb(e),f,b(f,d.length)),all:nw(a,Ip())}})},pw=function(a,b,c,d){uea(b);WN(a[d]);return d},YN=function(a,b){return a===b-1?0:a+1},vea=function(a,b){return 0===a?b-1:a-1},ZN=function(a,b){return ow(a,YN,function(a,d,e,f){pw(a,d,e,f);y.before(d[0],p.fromText(b));z(d,F.remove);return 0===f?f:e})},pf={search:function(a,b,c){if(0===b.length)return g.none();
  var d=sea(b),e=A.children(a);b=!0===c?XN(b,g.none()):XN(b,g.some("gi"));qea.highlightPattern(d,e,b,tea);return nw(a,Ip()).map(function(a){WN(a[0]);return{all:g.some(a),pos:0}})},clear:function(a){a=Y.descendants(a,Ip());z(a,F.unwrap);return g.none()},next:function(a){return ow(a,YN,pw)},prev:function(a){return ow(a,vea,pw)},replace:ZN,replaceAll:function(a,b){for(;ZN(a,b).isSome(););return g.none()}},oA=aa.detect().deviceType.isiOS(),qw=function(a,b,c){a=a();var d=a.element();ma.add(d,b);S.button(d,
  c);m.set(d,"tabindex","-1");a.events.click.bind(function(){Z.focus(d)});return a},rw=function(a,b){a=qw(Nc,a,b);m.set(a.element(),"title",b);return a},$N=function(a,b){var c=B.resolve("inline-main-button");a=a.concat([c]);a=qw(Nc,a,b);a.content(Qc(b));return a},aO=function(a,b,c){var d=B.resolve("inline-main-button-toggle");a=a.concat([d]);c=qw($d,a,c);m.set(c.element(),"title",b);return c},sw=function(a,b,c){var d=p.fromTag("input");ma.add(d,a);m.set(d,"placeholder",b);S.label(d,c);return{element:k(d),
  destroy:u(F.remove,d)}},wm={counter:function(a){var b=T.div(),c=T.span();n.add(b,B.resolve("search-widget-counter"));n.add(c,B.resolve("search-widget-counter-text"));y.append(b,c);return{element:k(b),update:function(a,b){a=x.translate("units.amount-of-total",a,b);F.empty(c);y.append(c,p.fromText(a));sc.isVisible(c)&&ib.speak(ja.body(),a)},hide:function(){v.set(b,"display","none")},show:function(){v.remove(b,"display")},destroy:function(){F.remove(c);F.remove(b)}}},dummyCounter:function(a){a=T.div();
  n.add(a,B.resolve("search-widget-counter"));return{element:k(a),update:t,hide:t,show:t,destroy:u(F.remove,a)}},searchField:function(){var a=T.span(),b=rw([B.resolve("stepper-button"),B.resolve("search-widget-previous")],x.translate("search.previous")),c=rw([B.resolve("stepper-button"),B.resolve("search-widget-next")],x.translate("search.next")),d=aO([B.resolve("search-widget-more")],x.translate("aria.label.more"),x.translate("aria.label.more"));n.add(a,B.resolve("search-widget-searchField"));var e=
  sw([B.resolve("search-widget-input"),B.resolve("search-widget-input-search")].concat(xc.isSmallTouch()?[B.resolve("search-widget-small-touch")]:[]),x.translate("search.search"),x.translate("search.field.search")),f=H.create({next:Q([],c.events.click),previous:Q([],b.events.click),more:Q([],d.events.click),input:r(["raw"])}),h=K.bind(e.element(),"input",f.trigger.input);P.append(a,[e.element(),b.element(),c.element(),d.element()]);return{events:f.registry,element:k(a),input:e.element,focus:function(){Z.focus(e.element())},
  previous:b.element,next:c.element,moreToggle:d,destroy:function(){h.unbind();e.destroy();b.destroy();c.destroy();d.destroy()}}},replaceDrawer:function(){var a=sw([B.resolve("search-widget-input"),B.resolve("search-widget-input-replace")],x.translate("search.replace"),x.translate("search.field.replace")),b=aO([B.resolve("search-widget-matchcase")],x.translate("search.matchcase"),x.translate("search.matchcase")),c=$N([B.resolve("search-widget-replace")],x.translate("search.replace")),d=$N([B.resolve("search-widget-replace-all")],
  x.translate("search.replace-all")),e=p.fromTag("div");S.group(e);var f=T.div();n.add(e,B.resolve("search-widget-replace-drawer"));n.add(f,B.resolve("search-widget-replace-drawer-tools"));P.append(f,[b.element(),c.element(),d.element()]);P.append(e,[a.element(),f]);return{element:k(e),replace:c,replaceAll:d,input:a,matchcase:b,destroy:function(){b.destroy();c.destroy();d.destroy();F.remove(f);F.remove(e)}}},button:rw,input:sw},qA=function(a,b,c){a?(ra.expanded(b),S.hidden(c,!1)):(ra.collapsed(b),S.hidden(c,
  !0))},Ej={text:ta.generate([{text:["field","input"]}]).text,cata:function(a,b){return a.fold(b)}},kX=aa.detect(),jX=hn("element addEscape open close execute type events destroy".split(" "),nD.isFunctionOrEvents(["toEditor"])),bO=B.resolve("toolbar-dialog"),wea=function(a){var b=hX(a);return Oy(a,b,"search",bO)},xea=function(a){var b=iX(a);return xm(a,b,bO)},mX=function(a){return(aa.detect().deviceType.isTouch()?xea:wea)(a)},yea=function(a){return se.isAnnotation(a)||m.has(a,Rb.overrideSpan())},cO=
  function(a,b,c,d,e,f){var h=function(b){a(b,e,yea)};$b.cata(d.get(),t,No.multiple(b,c,h,f),No.single(b,c,h,f))},Jp=function(a,b,c,d,e){cO(a,b,c,d,e,b.toEditing)},Sf={face:u(Jp,Bi.face),background:u(Jp,Bi.background),foreground:u(Jp,Bi.foreground),size:u(Jp,Bi.size),partialSize:u(function(a,b,c,d,e){cO(a,b,c,d,e,t)},Bi.size)},Oh={color:O("hex","name"),face:O("textkey","value","icon"),size:O("name","size")},qc=Oh.color,Se=Oh.face,uA={colors:function(){return[qc("#FFF",x.key("color.white")),qc("#000",
  x.key("color.black")),qc("#444",x.key("color.gray")),qc("#777",x.key("color.metal")),qc("#CCC",x.key("color.smoke")),qc("#FC1D00",x.key("color.red")),qc("#C81500",x.key("color.darkred")),qc("#FF8C00",x.key("color.darkorange")),qc("#FEBE00",x.key("color.orange")),qc("#FFFC00",x.key("color.yellow")),qc("#22AE50",x.key("color.green")),qc("#006400",x.key("color.darkgreen")),qc("#3CB371",x.key("color.mediumseagreen")),qc("#8FCD4E",x.key("color.lightgreen")),qc("#00FF00",x.key("color.lime")),qc("#0000CD",
  x.key("color.mediumblue")),qc("#002360",x.key("color.navy")),qc("#0173C1",x.key("color.blue")),qc("#14B2F2",x.key("color.lightblue")),qc("#ee82ee",x.key("color.violet"))]},faces:function(){return[Se(x.key("font.arial"),"Arial",g.none()),Se(x.key("font.comicsans"),"Comic Sans MS",g.none()),Se(x.key("font.consolas"),"Consolas",g.none()),Se(x.key("font.courier"),"Courier",g.none()),Se(x.key("font.georgia"),"Georgia",g.none()),Se(x.key("font.impact"),"Impact",g.none()),Se(x.key("font.tahoma"),"Tahoma",
  g.none()),Se(x.key("font.timesnr"),"Times New Roman",g.none()),Se(x.key("font.trebuchet"),"Trebuchet MS",g.none()),Se(x.key("font.verdana"),"Verdana",g.none())]}},ym={configuration:k({i18nNamespace:"font",cssNamespace:"font",property:"font-size",tag:"span",specials:["xx-small x-small small medium large x-large xx-large".split(" ")]})},zea=function(a){var b=!isNaN(parseFloat(a))&&isFinite(a);return a+(b?"px":"")},Aea=function(a,b,c){return(v.isValidValue(a,b,c)?g.some(c):g.none()).fold(function(){return J.error("Invalid value: "+
  c)},function(a){return a===c?J.value(c):J.error("Invalid value: "+c)})},dO=function(a){return Fp.identify(a).fold(function(a){return a},function(a,c,d){return Math.round(10*c)/10+d})},Tf={identify:Fp.identify,validate:function(a,b,c){return(xf.isEmpty(a)?J.error("can not use empty value for font size."):J.value(a)).map(zea).map(dO).bind(u(Aea,b,c))},sanitise:function(a){return dO(a)}},Kp={px:1,em:.1,"%":10,pt:1,rem:"0.1"},Bea=function(a,b,c){return qa(b,function(a){return U(a,c)}).bind(function(b){return Gc(b,
  c).bind(function(c){return g.from(b[a(c,b)])})}).getOr(c)},eO=function(a,b,c,d){return Tf.identify(d).fold(function(b){return Bea(a,c,b)},function(a,c,d){a=void 0!==Kp[d]?Kp[d]:1;var e=b*(void 0!==Kp[d]?Kp[d]:1);return($e(c)&&0<=c?Math.max(a,c+e):a)+d})},zm={decrease:u(eO,function(a,b){return Math.max(0,a-1)},-1),increase:u(eO,function(a,b){return Math.min(b.length-1,a+1)},1)},oX=Aa(["i18nNamespace","cssNamespace","property","tag","specials"],[]),Cea=O("size"),Eea=function(a){a=$b.toSelection(a.get()).fold(Da.off,
  function(a){a=U(["td","th"],D.name(a.startContainer()))?kb.freefallLtr(a.startContainer()).element():a.startContainer();a=Dea(a);return Da.on(a)});return Cea(a)},Fea=function(a){return a.body().bind(function(a){a=v.get(a,"font-size");return g.from(a)})},fO=function(a){var b=a.dom();if(!b.style)return!1;b=b.style.fontSize;return"body"!==D.name(a)&&!xf.isEmpty(b)},Dea=function(a){var b=D.isText(a)?A.parent(a).getOrDie():a;return(fO(b)?g.some(b):Ja.ancestor(b,fO)).fold(function(){return v.get(b,"font-size")},
  function(a){return a.dom().style.fontSize})},Am={getState:function(a,b){return{readState:Eea(a),fallbackSize:Fea(b).getOr("12px")}}},Gea=function(a){a.dom().click();return g.some(a)},Hea=function(a,b){var c=Y.descendants(a,b);if(0<sa.get(a)&&0<c.length){var d=bb.absolute(c[0]).top();return Va(c.slice(1),function(a){return bb.absolute(a).top()!==d}).map(function(a){return{rows:k(Math.ceil(c.length/(a+1))),columns:k(a+1)}})}return g.none()},Iea=function(a){return E(a,function(a){var b=a.text;b=x.has("color."+
  b)?x.key("color."+b):x.raw(b);return Oh.color(a.value,b)})},Gj={create:function(a){var b=0<a.length?Iea(a):uA.colors();a=qX();var c=E(b,function(a){var b=rA(a);m.set(b.element(),"tabIndex","-1");n.add(b.element(),B.resolve("palette-color-option"));v.set(b.element(),"background-color",a.hex());return b});z(c,a.add);b=b.length%5;if(0!==b%5)for(b=5-b,c=0;c<b;c++){var d=rA(Oh.color("#FFF",x.key("color.white")));n.add(d.element(),B.resolve("palette-color-option"));n.add(d.element(),B.resolve("palette-color-option-spacer"));
  a.add(d)}return a},makeLayout:function(a,b,c){c=Ba.grid(oa({trigger:Gea},c));var d=ha.grid(a,{cell:k(b)},4,5,c);return{layout:k(d),refresh:function(){d.clear();Hea(a,b).each(function(a){d.resize(a.rows(),a.columns())})}}}},Jea="."+B.resolve("palette-detail-active"),sA=function(a){return Db.closest(a,Jea)},sX=aa.detect().deviceType.isTouch,Kea=function(a){var b=na(g.none());return{clear:function(){b.get().each(a);b.set(g.none())},isSet:function(){return b.get().isSome()},set:function(c){b.get().each(a);
  b.set(g.some(c))}}},Lea=function(){return Kea(function(a){a.destroy()})},nl=k("touchstart"),tw=k("touchmove"),uw=k("touchend"),ol=k("mousedown"),vw=k("mousemove"),gO=k("mouseup"),Mea=k("keydown");k("click");var Nea=k("alloy.tap"),yh=k("alloy.focus"),Oea=k("alloy.blur.post"),hO=k("alloy.receive"),iO=k("alloy.execute");aa.detect().deviceType.isTouch();var Pea=k("alloy.longpress"),ww=k("alloy.system.init"),Qea=k("alloy.system.scroll"),jO=k("alloy.system.attached"),kO=k("alloy.system.detached"),Tg=function(a){a=
  Oc.shallow(a);return Ha.getOuter(a)},lO=[],Rea=["alloy/data/Fields","alloy/debugging/Debugging"],Sea=function(){var a=Error();return void 0!==a.stack?(a=a.stack.split("\n"),qa(a,function(a){return 0<a.indexOf("alloy")&&!Xa(Rea,function(b){return-1<a.indexOf(b)})}).getOr("unknown")):"unknown"},Tea={logEventCut:t,logEventStopped:t,logNoParent:t,logEventNoHandlers:t,logEventResponse:t,write:t},xw=function(a,b,c){var d="*"===lO||U(lO,a)?function(){var c=[];return{logEventCut:function(a,b,d){c.push({outcome:"cut",
  target:b,purpose:d})},logEventStopped:function(a,b,d){c.push({outcome:"stopped",target:b,purpose:d})},logNoParent:function(a,b,d){c.push({outcome:"no-parent",target:b,purpose:d})},logEventNoHandlers:function(a,b){c.push({outcome:"no-handlers-left",target:b})},logEventResponse:function(a,b,d){c.push({outcome:"response",purpose:d,target:b})},write:function(){U(["mousemove","mouseover","mouseout",ww()],a)||ud.log(a,{event:a,target:b.dom(),sequence:E(c,function(a){return U(["cut","stopped","response"],
  a.outcome)?"{"+a.purpose+"} "+a.outcome+" at ("+Tg(a.target)+")":a.outcome})})}}}():Tea;c=c(d);d.write();return c},mO=function(a){a=a.raw();return void 0===a.touches||1!==a.touches.length?g.none():g.some(a.touches[0])},Uea=function(a){var b=na(g.none()),c=tX(function(c){b.set(g.none());a.triggerEvent(Pea(),c)},400),d=pb([{key:nl(),value:function(a){mO(a).each(function(d){c.cancel();d={x:k(d.clientX),y:k(d.clientY),target:a.target};c.schedule(a);b.set(g.some(d))});return g.none()}},{key:tw(),value:function(a){c.cancel();
  mO(a).each(function(a){b.get().each(function(c){var d=Math.abs(a.clientX-c.x());c=Math.abs(a.clientY-c.y());(5<d||5<c)&&b.set(g.none())})});return g.none()}},{key:uw(),value:function(d){c.cancel();return b.get().filter(function(a){return N.eq(a.target(),d.target())}).map(function(b){return a.triggerEvent(Nea(),d)})}}]);return{fireIfReady:function(a,b){return zc(d,b).bind(function(b){return b(a)})}}},nO=aa.detect().browser.isFirefox(),Vea=md([dp("triggerEvent",aL),dp("broadcastEvent",aL),da("stopBackspace",
  !0)]),Wea=function(a,b){return nO?K.capture(a,"focus",b):K.bind(a,"focusin",b)},Xea=function(a,b){return nO?K.capture(a,"blur",b):K.bind(a,"focusout",b)},Yea=function(a,b){var c=Oe("Getting GUI events settings",Vea,b);b=aa.detect().deviceType.isTouch()?["touchstart","touchmove","touchend","gesturestart"]:"mousedown mouseup mouseover mousemove mouseout click".split(" ");var d=Uea(c),e=E(b.concat("selectstart input contextmenu change transitionend drag dragstart dragend dragenter dragleave dragover drop".split(" ")),
  function(b){return K.bind(a,b,function(a){d.fireIfReady(a,b).each(function(b){b&&a.kill()});c.triggerEvent(b,a)&&a.kill()})}),f=K.bind(a,"keydown",function(a){if(c.triggerEvent("keydown",a))a.kill();else{var b;if(b=!0===c.stopBackspace)b=8===a.raw().which&&!U(["input","textarea"],D.name(a.target()));b&&a.prevent()}}),h=Wea(a,function(a){c.triggerEvent("focusin",a)&&a.kill()}),g=Xea(a,function(a){c.triggerEvent("focusout",a)&&a.kill();Sg(function(){c.triggerEvent(Oea(),a)},0)});b=A.defaultView(a);
  var k=K.bind(b,"scroll",function(a){c.broadcastEvent(Qea(),a)&&a.kill()});return{unbind:function(){z(e,function(a){a.unbind()});f.unbind();h.unbind();g.unbind();k.unbind()}}},yw=function(a,b){a=zc(a,"target").map(function(a){return a()}).getOr(b);return na(a)},Zea=function(a,b){var c=na(!1),d=na(!1);return{stop:function(){c.set(!0)},cut:function(){d.set(!0)},isStopped:c.get,isCut:d.get,event:k(a),setSource:b.set,getSource:b.get}},$ea=function(a){var b=na(!1);return{stop:function(){b.set(!0)},cut:t,
  isStopped:b.get,isCut:k(!1),event:k(a),setSource:yb("Cannot set source of a broadcasted event"),getSource:yb("Cannot get source of a broadcasted event")}},pl=ta.generate([{stopped:[]},{resume:["element"]},{complete:[]}]),oO=function(a,b,c,d,e,f){a=a(b,d);var h=Zea(c,e);return a.fold(function(){f.logEventNoHandlers(b,d);return pl.complete()},function(a){var c=a.descHandler(),d=c.cHandler;d(h);return h.isStopped()?(f.logEventStopped(b,a.element(),c.purpose()),pl.stopped()):h.isCut()?(f.logEventCut(b,
  a.element(),c.purpose()),pl.complete()):A.parent(a.element()).fold(function(){f.logNoParent(b,a.element(),c.purpose());return pl.complete()},function(d){f.logEventResponse(b,a.element(),c.purpose());return pl.resume(d)})})},zw=function(a,b,c,d,e,f){return oO(a,b,c,d,e,f).fold(function(){return!0},function(d){return zw(a,b,c,d,e,f)},function(){return!1})},afa=function(a,b,c){var d=$ea(b);z(a,function(a){a=a.descHandler().cHandler;a(d)});return d.isStopped()},wX=function(a,b,c){return Ja.closest(a,
  function(a){return b(a).isSome()},c).bind(b)},bfa=k("alloy-id-"),pO=k("data-alloy-id"),yX=bfa(),tA=pO(),Hj=function(a){a=D.isElement(a)?m.get(a,tA):null;return g.from(a)},vX=O("element","descHandler"),ql=function(a){if(!ye(a,"can")&&!ye(a,"abort")&&!ye(a,"run"))throw Error("EventHandler defined by: "+Nb.stringify(a,null,2)+" does not have can, abort, or run!");return Oe("Extracting event.handler",md([da("can",k(!0)),da("abort",k(!1)),da("run",t)]),a)},cfa=function(a,b){return function(){for(var c=
  [],d=0;d<arguments.length;d++)c[d]=arguments[d];return hb(a,function(a,d){return a&&b(d).apply(void 0,c)},!0)}},dfa=function(a,b){return function(){for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];return hb(a,function(a,d){return a||b(d).apply(void 0,c)},!1)}},efa=function(a){return qb(a)?{can:k(!0),abort:k(!1),run:a}:a},ffa=function(a){var b=cfa(a,function(a){return a.can}),c=dfa(a,function(a){return a.abort});return ql({can:b,abort:c,run:function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=
  arguments[c];z(a,function(a){a.run.apply(void 0,b)})}})},Te=function(a,b,c){Lp(a,a.element(),b,c)},Lp=function(a,b,c,d){d=oa({target:b},d);a.getSystem().triggerEvent(c,b,eb(d,k))},Yb=function(a,b){return{key:a,value:ql({run:b})}},Aw=function(a,b,c){return{key:a,value:ql({run:function(a){b.apply(void 0,[a].concat(c))}})}},Bw=function(a){return function(b){return{key:a,value:ql({run:function(a,d){N.eq(a.element(),d.event().target())&&b(a,d)}})}}},gfa=function(a,b){return Yb(a,function(c,d){c.getSystem().getByUid(b).each(function(b){var c=
  b.element();b.getSystem().triggerEvent(a,c,d.event())})})},Ti=function(a,b,c){b=b.partUids()[c];return gfa(a,b)},Mp=Bw(jO()),hfa=Bw(kO()),ifa=Bw(ww());(function(a){return function(b){return Yb(a,b)}})(iO());var jfa=pb([function(a,b){return{key:a,value:ql({can:b})}}(yh(),function(a,b){var c=b.event().originator();b=b.event().target();return N.eq(c,a.element())&&!N.eq(c,b)?(ud.warn(yh()+" did not get interpreted by the desired target. \nOriginator: "+Tg(c)+"\nTarget: "+Tg(b)+"\nCheck the "+yh()+" event handlers"),
  !1):!0})]),kfa=Object.freeze({events:jfa}),lfa=ca,qO=xd("debugInfo triggerFocus triggerEvent triggerEscape addToWorld removeFromWorld addToGui removeFromGui build getByUid getByDom broadcast broadcastOn isConnected".split(" ")),rO=function(a){var b=function(b){return function(){throw Error("The component must be in a context to send: "+b+"\n"+Tg(a().element())+" is not in context.");}};return qO({debugInfo:k("fake"),triggerEvent:b("triggerEvent"),triggerFocus:b("triggerFocus"),triggerEscape:b("triggerEscape"),
  build:b("build"),addToWorld:b("addToWorld"),removeFromWorld:b("removeFromWorld"),addToGui:b("addToGui"),removeFromGui:b("removeFromGui"),getByUid:b("getByUid"),getByDom:b("getByDom"),broadcast:b("broadcast"),broadcastOn:b("broadcastOn"),isConnected:k(!1)})},mfa=function(a,b,c){c=c.toString();var d=c.indexOf(")")+1,e=c.indexOf("("),f=c.substring(e+1,d-1).split(/,\s*/);a.toFunctionAnnotation=function(){return{name:b,parameters:Cw(f.slice(0,1).concat(f.slice(3)))}};return a},Cw=function(a){return E(a,
  function(a){return je(a,"/*")?a.substring(0,a.length-2):a})},Dw=function(a,b){var c=a.toString(),d=c.indexOf(")")+1,e=c.indexOf("("),f=c.substring(e+1,d-1).split(/,\s*/);a.toFunctionAnnotation=function(){return{name:b,parameters:Cw(f)}};return a},nfa=function(a,b){b=b.toString();var c=b.indexOf(")")+1,d=b.indexOf("("),e=b.substring(d+1,c-1).split(/,\s*/);a.toFunctionAnnotation=function(){return{name:"OVERRIDE",parameters:Cw(e.slice(1))}};return a},ofa=Fa("alloy-premade"),sO=Fa("api"),Ew=function(a){return nfa(function(b){for(var c=
  [],d=1;d<arguments.length;d++)c[d-1]=arguments[d];d=b.config(sO);return a.apply(void 0,[d].concat([b].concat(c)))},a)},pfa=k(sO),me={init:function(){return rl({readState:function(){return"No State required"}})}},rl=function(a){eh(fh,["readState"])(a);return a},qfa=function(a,b){var c=E(b,function(a){return dl(a.name(),[za("config"),da("state",me)])});c=rg("component.behaviours",Cc(c),a.behaviours).fold(function(b){throw Error(Zo(b)+"\nComplete spec:\n"+Nb.stringify(a,null,2));},function(a){return a});
  return{list:b,data:eb(c,function(a){var b=a().map(function(a){return{config:a.config(),state:a.state().init(a.config())}});return function(){return b}})}},tO=function(a,b){var c={};Ma(a,function(a,e){Ma(a,function(a,d){var f=RK(d,[])(c);c[d]=f.concat([b(e,a)])})});return c},Fw=Aa(["tag"],"classes attributes styles value innerHtml domChildren defChildren".split(" ")),sfa=function(a){a=rfa(a);return Nb.stringify(a,null,2)},rfa=function(a){return{tag:a.tag(),classes:a.classes().getOr([]),attributes:a.attributes().getOr({}),
  styles:a.styles().getOr({}),value:a.value().getOr("<none>"),innerHtml:a.innerHtml().getOr("<none>"),defChildren:a.defChildren().fold(function(){return"<none>"},function(a){return Nb.stringify(a,null,2)}),domChildren:a.domChildren().fold(function(){return"<none>"},function(a){return 0===a.length?"0 children, but still specified":String(a.length)})}},Ui=Aa([],"classes attributes styles value innerHtml defChildren domChildren".split(" ")),uO=function(a,b,c){return b.fold(function(){return c.fold(function(){return{}},
  function(b){return gc(a,b)})},function(b){return c.fold(function(){return gc(a,b)},function(b){return gc(a,b)})})},tfa=function(a,b){a=oa({tag:a.tag(),classes:b.classes().getOr([]).concat(a.classes().getOr([])),attributes:ua(a.attributes().getOr({}),b.attributes().getOr({})),styles:ua(a.styles().getOr({}),b.styles().getOr({}))},b.innerHtml().or(a.innerHtml()).map(function(a){return gc("innerHtml",a)}).getOr({}),uO("domChildren",b.domChildren(),a.domChildren()),uO("defChildren",b.defChildren(),a.defChildren()),
  b.value().or(a.value()).map(function(a){return gc("value",a)}).getOr({}));return Fw(a)},Np=function(a,b){return 1<a.length?J.error('Multiple behaviours have tried to change DOM "'+b+'". The guilty behaviours are: '+Nb.stringify(E(a,function(a){return a.name()}))+". At this stage, this is not supported. Future releases might provide strategies for resolving this."):0===a.length?J.value({}):J.value(a[0].modification().fold(function(){return{}},function(a){return gc(b,a)}))},ufa=function(a,b,c,d){return J.error("Mulitple behaviours have tried to change the _"+
  b+'_ "'+a+'". The guilty behaviours are: '+Nb.stringify(ia(d,function(a){return void 0!==a.modification().getOr({})[b]?[a.name()]:[]}),null,2)+". This is not currently supported.")},vO=function(a,b){return hb(a,function(c,d){var e=d.modification().getOr({});return c.bind(function(c){var d=Lf(e,function(d,f){return void 0!==c[f]?ufa(b,f,e,a):J.value(gc(f,d))});return qv(d,c)})},J.value({})).map(function(a){return gc(b,a)})},vfa={classes:function(a,b){a=ia(a,function(a){return a.modification().getOr([])});
  return J.value(gc(b,a))},attributes:vO,styles:vO,domChildren:Np,defChildren:Np,innerHtml:Np,value:Np},wfa=function(a,b,c,d){var e=oa({},b);z(c,function(b){e[b.name()]=b.exhibit(a,d)});b=tO(e,function(a,b){return{name:function(){return a},modification:b}});b=eb(b,function(a,b){return ia(a,function(a){return a.modification().fold(function(){return[]},function(b){return[a]})})});b=Lf(b,function(a,b){return zc(vfa,b).fold(function(){return J.error("Unknown field type: "+b)},function(c){return c(a,b)})});
  return qv(b,{}).map(Ui)},xfa=function(a,b,c,d){c=c.slice(0);try{var e=c.sort(function(c,e){c=c[b]();e=e[b]();var f=d.indexOf(c),h=d.indexOf(e);if(-1===f)throw Error("The ordering for "+a+" does not have an entry for "+c+".\nOrder specified: "+Nb.stringify(d,null,2));if(-1===h)throw Error("The ordering for "+a+" does not have an entry for "+e+".\nOrder specified: "+Nb.stringify(d,null,2));return f<h?-1:h<f?1:0});return J.value(e)}catch(f){return J.error([f])}},yfa=function(a,b){return{name:k(a),handler:k(b)}},
  zfa=function(a,b){var c={};z(a,function(a){c[a.name()]=a.handlers(b)});return c},Afa=function(a){var b=efa(a);return function(a,d){for(var c=[],f=2;f<arguments.length;f++)c[f-2]=arguments[f];c=[a,d].concat(c);b.abort.apply(void 0,c)?d.stop():b.can.apply(void 0,c)&&b.run.apply(void 0,c)}},Bfa=function(a,b){return J.error(["The event ("+a+') has more than one behaviour that listens to it.\nWhen this occurs, you must specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that can trigger it are: '+
  Nb.stringify(E(b,function(a){return a.name()}),null,2)])},Cfa=function(a,b,c){return(b=b[c])?xfa("Event: "+c,"name",a,b).map(function(a){a=E(a,function(a){return a.handler()});return ffa(a)}):Bfa(c,a)},Dfa=function(a,b){a=Lf(a,function(a,d){return(1===a.length?J.value(a[0].handler()):Cfa(a,b,d)).map(function(c){c=Afa(c);var e=1<a.length?ka(b,function(b){return U(a,function(a){return a.name()===b})}).join(" > "):a[0].name();return pv(d,{handler:c,purpose:k(e)})})});return qv(a,{})},Efa=k([za("menu"),
  za("selectedMenu")]),wO=k([za("item"),za("selectedItem")]);k(md(wO().concat(Efa())));k(md(wO()));var Ffa=cl("initSize",[za("numColumns"),za("numRows")]),Gw=function(a,b,c){Sea();return Dc(b,b,c,XK(function(a){return J.value(function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];return a.apply(void 0,b)})}))},yg=function(a){return Gw("onHandler",a,Ne.defaultedThunk(k(t)))},Xd=function(a){return Gw("onKeyboardHandler",a,Ne.defaultedThunk(k(g.none)))},zg=function(a,b){return sg(a,k(b))},
  Gfa=k(Ffa),Hfa=function(a){return rg("custom.definition",md([Dc("dom","dom",qg(),md([za("tag"),da("styles",{}),da("classes",[]),da("attributes",{}),Dd("value"),Dd("innerHtml")])),za("components"),za("uid"),da("events",{}),da("apis",k({})),Dc("eventOrder","eventOrder",Ne.mergeWithThunk(k({"alloy.execute":["disabling","alloy.base.behaviour","toggling"],"alloy.focus":["alloy.base.behaviour","focusing","keying"],"alloy.system.init":["alloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.behaviour",
  "representing","streaming","invalidating"],"alloy.system.detached":["alloy.base.behaviour","representing"],mousedown:["focusing","alloy.base.behaviour","item-type-events"]})),$o()),Dd("domModification"),Zk("originalSpec",ca),da("debug.sketcher","unknown")]),a)},Ifa=function(a){return pv(pO(),a.uid())},Jfa=function(a){var b={tag:a.dom().tag(),classes:a.dom().classes(),attributes:oa(Ifa(a),a.dom().attributes()),styles:a.dom().styles(),domChildren:E(a.components(),function(a){return a.element()})};return Fw(oa(b,
  a.dom().innerHtml().map(function(a){return gc("innerHtml",a)}).getOr({}),a.dom().value().map(function(a){return gc("value",a)}).getOr({})))},Kfa=function(a){return a.domModification().fold(function(){return Ui({})},Ui)},Mfa=function(a){if(a.domChildren().isSome()&&a.defChildren().isSome())throw Error("Cannot specify children and child specs! Must be one or the other.\nDef: "+sfa(a));return a.domChildren().fold(function(){var b=a.defChildren().getOr([]);return E(b,Lfa)},function(a){return a})},xO=
  function(a){var b=p.fromTag(a.tag());m.setAll(b,a.attributes().getOr({}));ma.add(b,a.classes().getOr([]));v.setAll(b,a.styles().getOr({}));Ha.set(b,a.innerHtml().getOr(""));var c=Mfa(a);P.append(b,c);a.value().each(function(a){fa.set(b,a)});return b},Lfa=function(a){a=Fw(a);return xO(a)},Nfa=function(a){var b=zc(a,"behaviours").getOr({});a=ka(cb(b),function(a){return void 0!==b[a]});return E(a,function(a){return b[a].me})},Ofa=function(a){var b=Nfa(a);return qfa(a,b)},Pfa=xd("getSystem config hasConfigured spec connect disconnect element syncComponents readState components events".split(" ")),
  Qfa=function(a,b,c){var d=Jfa(a);a={"alloy.base.modification":Kfa(a)};b=wfa(c,a,b,d).getOrDie();return tfa(d,b)},Rfa=function(a,b,c){var d={"alloy.base.behaviour":a.events()};a=a.eventOrder();b=oa(d,zfa(b,c));b=tO(b,yfa);return Dfa(b,a).getOrDie()},Sfa=function(a){var b=function(){return n},c=na(rO(b)),d=Ji(Hfa(oa(a,{behaviours:void 0}))),e=Ofa(a),f=e.list,h=e.data;e=Qfa(d,f,h);var g=xO(e);f=Rfa(d,f,h);var m=na(d.components()),n=Pfa({getSystem:c.get,config:function(b){if(b===pfa())return d.apis();
  if(xa(b))throw Error("Invalid input: only API constant is allowed");return(qb(h[b.name()])?h[b.name()]:function(){throw Error("Could not find "+b.name()+" in "+Nb.stringify(a,null,2));})()},hasConfigured:function(a){return qb(h[a.name()])},spec:k(a),readState:function(a){return h[a]().map(function(a){return a.state.readState()}).getOr("not enabled")},connect:function(a){c.set(a)},disconnect:function(){c.set(rO(b))},element:k(g),syncComponents:function(){var a=A.children(g);a=ia(a,function(a){return c.get().getByDom(a).fold(function(){return[]},
  function(a){return[a]})});m.set(a)},components:m.get,events:k(f)});return n},Cm=function(a){return zc(a,ofa).fold(function(){var b=oa({uid:Fa("")},a);b=lfa(b);var c=RK("components",[])(b);c=E(c,Cm);b=oa(kfa,b,gc("components",c));return J.value(Sfa(b)).getOrDie()},function(a){return a})},sl=function(a,b){return Taa(a,{},E(b,function(b){return Saa(b.name(),"Cannot configure "+b.name()+" for "+a)}).concat([Zk("dump",ca)]))},Op=ta.generate([{single:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),
  Tfa=function(a,b,c,d){return a.exists(function(a){return a!==c.owner})?Op.single(!0,k(c)):zc(d,c.name).fold(function(){throw Error("Unknown placeholder component: "+c.name+"\nKnown: ["+cb(d)+"]\nNamespace: "+a.getOr("none")+"\nSpec: "+Nb.stringify(c,null,2));},function(a){return a.replace()})},Ufa=function(a,b,c,d){return"placeholder"===c.uiType?Tfa(a,b,c,d):Op.single(!1,k(c))},yO=function(a,b,c,d){return Ufa(a,b,c,d).fold(function(e,f){e=f(b,c.config,c.validated);f=zc(e,"components").getOr([]);f=
  ia(f,function(c){return yO(a,b,c,d)});return[oa(e,{components:f})]},function(a,d){return d(b,c.config,c.validated)})},Vfa=function(a,b,c,d){return ia(c,function(c){return yO(a,b,c,d)})},Wfa=function(a,b){var c=!1;return{name:k(a),required:function(){return b.fold(function(a,b){return a},function(a,b){return a})},used:function(){return c},replace:function(){if(!0===c)throw Error("Trying to use the same placeholder more than once: "+a);c=!0;return b}}},Xfa=function(a,b,c,d){d=eb(d,function(a,b){return Wfa(b,
  a)});c=Vfa(a,b,c,d);Ma(d,function(c){if(!1===c.used()&&c.required())throw Error("Placeholder: "+c.name()+" was not found in components list\nNamespace: "+a.getOr("none")+"\nComponents: "+Nb.stringify(b.components(),null,2));});return c},zO=Op.single,Yfa=Op.multiple,AO=k("placeholder"),BO=ta.generate([{required:["data"]},{external:["data"]},{optional:["data"]},{group:["data"]}]),Hw=da("factory",{sketch:ca}),Iw=da("schema",[]),Jw=za("name"),Kw=Dc("pname","pname",uaa(function(a){return"<alloy."+Fa(a.name)+
  ">"}),$o()),Lw=da("defaults",k({})),Mw=da("overrides",k({})),Zfa=Cc([Hw,Iw,Jw,Kw,Lw,Mw]),$fa=Cc([Hw,Iw,Jw,Kw,Lw,Mw]);Cc([Hw,Iw,Jw,za("unit"),Kw,Lw,Mw]);var aga=function(a){var b=function(a){return a.name()};return a.fold(b,b,b,b)},CO=function(a,b){return function(c){c=Ji(rg("Converting part type",b,c));return a(c)}},Pp=CO(BO.required,Zfa),Nw=CO(BO.optional,$fa),DO=k("entirety"),Ow=function(a,b,c,d){return oa(b.defaults()(a,c,d),c,{uid:a.partUids()[b.name()]},b.overrides()(a,c,d),{"debug.sketcher":pv("part-"+
  b.name(),c)})},bga=function(a,b,c){var d={},e={};z(c,function(a){a.fold(function(a){d[a.pname()]=zO(!0,function(b,c,d){return a.factory().sketch(Ow(b,a,c,d))})},function(a){var c=b.parts()[a.name()]();e[a.name()]=k(Ow(b,a,c[DO()]()))},function(a){d[a.pname()]=zO(!1,function(b,c,d){return a.factory().sketch(Ow(b,a,c,d))})},function(a){d[a.pname()]=Yfa(!0,function(b,c,d){c=b[a.name()]();return E(c,function(c){return a.factory().sketch(oa(a.defaults()(b,c),c,a.overrides()(b,c)))})})})});return{internals:k(d),
  externals:k(e)}},dga=function(a,b){var c={};z(b,function(b){b.fold(g.some,g.none,g.some,g.some).each(function(b){var d=cga(a,b.pname());c[b.name()]=function(c){var e=Oe("Part: "+b.name()+" in "+a,Cc(b.schema()),c);return oa(d,{config:c,validated:e})}})});return c},cga=function(a,b){return{uiType:AO(),owner:a,name:b}},ega=function(a){return ia(a,function(a){return a.fold(g.none,g.some,g.none,g.none).map(function(a){return cl(a.name(),a.schema().concat([Zk(DO(),ca)]))}).toArray()})},ne=function(a,b,
  c){b=b.partUids()[c];return a.getSystem().getByUid(b).toOption()},EO=function(a,b,c){return ne(a,b,c).getOrDie("Could not find part: "+c)},fga=function(a,b,c){var d={},e=b.partUids(),f=a.getSystem();z(c,function(a){d[a]=f.getByUid(e[a])});return eb(d,k)},gga=function(a,b){var c=a.getSystem();return eb(b.partUids(),function(a,b){return k(c.getByUid(a))})},hga=function(a,b){b=E(b,aga);return pb(E(b,function(b){return{key:b,value:a+"-"+b}}))},iga=function(a){return Dc("partUids","partUids",vaa(function(b){return hga(b.uid,
  a)}),$o())},FO=function(a,b,c,d,e){d=(0<d.length?[cl("parts",d)]:[]).concat([za("uid"),da("dom",{}),da("components",[]),Zk("originalSpec",ca),da("debug.sketcher",{})]).concat(e);b=md(d.concat(b));return Ji(rg(a+" [SpecSchema]",b,c))},HO=function(a,b,c,d,e){var f=GO(e),h=ega(c),k=iga(c);b=FO(a,b,f,h,[k]);c=bga(a,b,c);h=c.internals();h=Xfa(g.some(a),b,b.components(),h);return oa(d(b,h,f,c.externals()),{"debug.sketcher":gc(a,e)})},GO=function(a){return oa({uid:Fa("uid")},a)},jga=md([za("name"),za("factory"),
  za("configFields"),da("apis",{}),da("extraApis",{})]),kga=md([za("name"),za("factory"),za("configFields"),za("partFields"),da("apis",{}),da("extraApis",{})]),tl=function(a){var b=Oe("Sketcher for "+a.name,jga,a);a=eb(b.apis,Ew);var c=eb(b.extraApis,function(a,b){return Dw(a,b)});return oa({name:k(b.name),partFields:k([]),configFields:k(b.configFields),sketch:function(a){var c=b.name,d=b.configFields,h=b.factory,g=GO(a);d=FO(c,d,g,[],[]);return oa(h(d,g),{"debug.sketcher":gc(c,a)})}},a,c)},IO=function(a){var b=
  Oe("Sketcher for "+a.name,kga,a);a=dga(b.name,b.partFields);var c=eb(b.apis,Ew),d=eb(b.extraApis,function(a,b){return Dw(a,b)});return oa({name:k(b.name),partFields:k(b.partFields),configFields:k(b.configFields),sketch:function(a){return HO(b.name,b.configFields,b.partFields,b.factory,a)},parts:k(a)},c,d)},lga=tl({name:"Container",factory:function(a){return{uid:a.uid(),dom:oa({tag:"div",attributes:{role:"presentation"}},a.dom()),components:a.components(),behaviours:a.containerBehaviours().dump(),
  events:a.events(),domModification:a.domModification(),eventOrder:a.eventOrder()}},configFields:[da("components",[]),sl("containerBehaviours",[]),da("events",{}),da("domModification",{}),da("eventOrder",{})]}),JO=function(a){var b=kO();Lp(a,a.element(),b,{});a=a.components();z(a,JO)},Pw=function(a){var b=a.components();z(b,Pw);b=jO();Lp(a,a.element(),b,{})},mga=function(a){JO(a);F.remove(a.element());a.getSystem().removeFromWorld(a)},KO=function(a){var b=A.parent(a.element()).bind(function(b){return a.getSystem().getByDom(b).fold(g.none,
  g.some)});mga(a);b.each(function(a){a.syncComponents()})},CX=function(a,b){y.append(a,b.element());a=A.children(b.element());z(a,function(a){b.getByDom(a).each(Pw)})},AX=function(){var a=Cm(lga.sketch({dom:{tag:"div"}}));return nga(a)},nga=function(a){var b=function(b){return A.parent(a.element()).fold(function(){return!0},function(a){return N.eq(b,a)})},c=xX(),d=function(a,d){return c.find(b,a,d)},e=Yea(a.element(),{triggerEvent:function(a,b){return xw(a,b.target(),function(c){var e=b.target(),f=
  yw(b,e);return zw(d,a,b,e,f,c)})},broadcastEvent:function(a,b){a=c.filter(a);return afa(a,b)}}),f=qO({debugInfo:k("real"),triggerEvent:function(a,b,c){xw(a,b,function(e){var f=yw(c,b);zw(d,a,c,b,f,e)})},triggerFocus:function(a,b){Hj(a).fold(function(){Z.focus(a)},function(c){xw(yh(),a,function(c){var e=yh(),f={originator:k(b),kill:t,prevent:t,target:k(a)},h=yw(f,a);oO(d,e,f,a,h,c)})})},triggerEscape:function(a,b){f.triggerEvent("keydown",a.element(),b.event())},getByUid:function(a){return r(a)},getByDom:function(a){return u(a)},
  build:Cm,addToGui:function(a){m(a)},removeFromGui:function(a){KO(a)},addToWorld:function(a){h(a)},removeFromWorld:function(a){g(a)},broadcast:function(a){w(a)},broadcastOn:function(a,b){p(a,b)},isConnected:k(!0)}),h=function(a){a.connect(f);D.isText(a.element())||(c.register(a),z(a.components(),h),f.triggerEvent(ww(),a.element(),{target:k(a.element())}))},g=function(a){D.isText(a.element())||(z(a.components(),g),c.unregister(a));a.disconnect()},m=function(b){var c=y.append;a.getSystem().addToWorld(b);
  c(a.element(),b.element());ja.inBody(a.element())&&Pw(b);a.syncComponents()},n=function(a){var b=c.filter(hO());z(b,function(b){b=b.descHandler().cHandler;b(a)})},w=function(a){n({universal:k(!0),data:k(a)})},p=function(a,b){n({universal:k(!1),channels:k(a),data:k(b)})},r=function(a){return c.getById(a).fold(function(){return J.error(Error('Could not find component with uid: "'+a+'" in system.'))},J.value)},u=function(a){a=Hj(a).getOr("not found");return r(a)};h(a);return{root:k(a),element:a.element,
  destroy:function(){e.unbind();F.remove(a.element())},add:m,remove:function(a){KO(a)},getByUid:r,getByDom:u,addToWorld:h,removeFromWorld:g,broadcast:w,broadcastOn:p}},oga=function(a,b,c){return ifa(function(d,e){c(d,a,b)})},pga=function(a,b,c){return mfa(function(d){for(var e=[],f=1;f<arguments.length;f++)e[f-1]=arguments[f];var h=[d].concat(e);return d.config({name:k(a)}).fold(function(){throw Error("We could not find any behaviour configuration for: "+a+". Using API: "+c);},function(a){var c=Array.prototype.slice.call(h,
  1);return b.apply(void 0,[d,a.config,a.state].concat(c))})},c,b)},qga=function(a){return{key:a,value:void 0}},LO=function(a,b,c,d,e,f,h){var k=function(a){return ye(a,c)?a[c]():g.none()};e=eb(e,function(a,b){return pga(c,a,b)});f=eb(f,function(a,b){return Dw(a,b)});var m=oa(f,e,{revoke:u(qga,c),config:function(b){var d=Ji(rg(c+"-config",a,b));return{key:c,value:{config:d,me:m,configAsRaw:Zb(function(){return Oe(c+"-config",a,b)}),initialConfig:b,state:h}}},schema:function(){return b},exhibit:function(a,
  b){return k(a).bind(function(a){return zc(d,"exhibit").map(function(c){return c(b,a.config,a.state)})}).getOr(Ui({}))},name:function(){return c},handlers:function(a){return k(a).bind(function(a){return zc(d,"events").map(function(b){return b(a.config,a.state)})}).getOr({})}});return m},rga=md([za("fields"),za("name"),da("active",{}),da("apis",{}),da("state",me),da("extra",{})]),Ag=function(a){var b=Oe("Creating behaviour: "+a.name,rga,a),c=b.fields;a=b.name;var d=b.active,e=b.apis,f=b.extra;b=b.state;
  var h=md(c);c=Dc("config","config",Wk(),md(c));c=dl(a,[c]);return LO(h,c,a,d,e,f,b)},sga=md([za("branchKey"),za("branches"),za("name"),da("active",{}),da("apis",{}),da("state",me),da("extra",{})]),tga=function(a,b,c){var d=jd(a.slice(0,b));a=jd(a.slice(b+1));return qa(d.concat(a),c)},uga=function(a,b,c){a=jd(a.slice(0,b));return qa(a,c)},vga=function(a,b,c){var d=a.slice(0,b);a=a.slice(b+1);return qa(a.concat(d),c)},wga=function(a,b,c){a=a.slice(b+1);return qa(a,c)},Pa=function(a){return function(b){b=
  b.raw();return U(a,b.which)}},oe=function(a){return function(b){return ob(a,function(a){return a(b)})}},Vi=function(a){return!0===a.raw().shiftKey},xga=function(a){return!0===a.raw().ctrlKey},ul=zf(Vi),Ra=function(a,b){return{matches:a,classification:b}},yga=function(a,b){return qa(a,function(a){return a.matches(b)}).map(function(a){return a.classification})},Wi=function(a,b,c,d){a+=b;return a>d?c:a<c?d:a},vl=function(a,b,c){return a<=b?b:a>=c?c:a},MO=function(a,b,c){c=Y.descendants(a.element(),"."+
  b.highlightClass());z(c,function(c){n.remove(c,b.highlightClass());a.getSystem().getByDom(c).each(function(c){b.onDehighlight()(a,c)})})},wl=function(a,b,c,d){var e=Qw(a,b,c,d);MO(a,b,c);n.add(d.element(),b.highlightClass());e||b.onHighlight()(a,d)},Qw=function(a,b,c,d){return n.has(d.element(),b.highlightClass())},zga=function(a,b,c,d){b=Y.descendants(a.element(),"."+b.itemClass());return g.from(b[d]).fold(function(){return J.error("No element found with index "+d)},a.getSystem().getByDom)},NO=function(a,
  b,c){return L.descendant(a.element(),"."+b.itemClass()).bind(function(b){return a.getSystem().getByDom(b).toOption()})},OO=function(a,b,c){b=Y.descendants(a.element(),"."+b.itemClass());return(0<b.length?g.some(b[b.length-1]):g.none()).bind(function(b){return a.getSystem().getByDom(b).toOption()})},PO=function(a,b,c,d){var e=Y.descendants(a.element(),"."+b.itemClass());return Va(e,function(a){return n.has(a,b.highlightClass())}).bind(function(b){b=Wi(b,d,0,e.length-1);return a.getSystem().getByDom(e[b]).toOption()})},
  QO=function(a,b,c){b=Y.descendants(a.element(),"."+b.itemClass());return ee(E(b,function(b){return a.getSystem().getByDom(b).toOption()}))},Aga=Object.freeze({dehighlightAll:MO,dehighlight:function(a,b,c,d){c=Qw(a,b,c,d);n.remove(d.element(),b.highlightClass());c&&b.onDehighlight()(a,d)},highlight:wl,highlightFirst:function(a,b,c){NO(a,b,c).each(function(d){wl(a,b,c,d)})},highlightLast:function(a,b,c){OO(a,b,c).each(function(d){wl(a,b,c,d)})},highlightAt:function(a,b,c,d){zga(a,b,c,d).fold(function(a){throw Error(a);
  },function(d){wl(a,b,c,d)})},highlightBy:function(a,b,c,d){var e=QO(a,b,c);qa(e,d).each(function(d){wl(a,b,c,d)})},isHighlighted:Qw,getHighlighted:function(a,b,c){return L.descendant(a.element(),"."+b.highlightClass()).bind(function(b){return a.getSystem().getByDom(b).toOption()})},getFirst:NO,getLast:OO,getPrevious:function(a,b,c){return PO(a,b,c,-1)},getNext:function(a,b,c){return PO(a,b,c,1)},getCandidates:QO}),Bga=[za("highlightClass"),za("itemClass"),yg("onHighlight"),yg("onDehighlight")];Ag({fields:Bga,
  name:"highlighting",apis:Aga});var Cga=function(){return{get:function(a){return Z.search(a.element())},set:function(a,b){a.getSystem().triggerFocus(b,a.element())}}},zh=function(a,b,c,d,e,f){var h=function(a,b,d,e){var f=c(a,b,d,e);return yga(f,b.event()).bind(function(c){return c(a,b,d,e)})},g={schema:function(){return a.concat([da("focusManager",Cga()),zg("handler",g),zg("state",b)])},processKey:h,toEvents:function(a,b){var c=d(a,b),e=pb(f.map(function(c){return Yb(yh(),function(d,e){c(d,a,b,e);
  e.stop()})}).toArray().concat([Yb(Mea(),function(c,d){h(c,d,a,b).each(function(a){d.stop()})})]));return oa(c,e)},toApis:e};return g},RO=function(a){a=[Dd("onEscape"),Dd("onEnter"),da("selector",'[data-alloy-tabstop="true"]'),da("firstTabstop",0),da("useTabstopAt",k(!0)),Dd("visibilitySelector")].concat([a]);var b=function(a,b){a=a.visibilitySelector().bind(function(a){return L.closest(b,a)}).getOr(b);return 0<sa.get(a)},c=function(a,c){a=Y.descendants(a.element(),c.selector());a=ka(a,function(a){return b(c,
  a)});return g.from(a[c.firstTabstop()])},d=function(a,b){return b.focusManager().get(a).bind(function(a){return L.closest(a,b.selector())})},e=function(a,c,d,e,f){return f(c,d,function(a){return b(e,a)&&e.useTabstopAt()(a)}).fold(function(){return e.cyclic()?g.some(!0):g.none()},function(b){e.focusManager().set(a,b);return g.some(!0)})},f=function(a,b,c,f){var h=Y.descendants(a.element(),c.selector());return d(a,c).bind(function(b){return Va(h,u(N.eq,b)).bind(function(b){return e(a,h,b,c,f)})})},
  h=k([Ra(oe([Vi,Pa([9])]),function(a,b,c,d){d=c.cyclic()?tga:uga;return f(a,b,c,d)}),Ra(Pa([9]),function(a,b,c,d){d=c.cyclic()?vga:wga;return f(a,b,c,d)}),Ra(Pa([27]),function(a,b,c,d){return c.onEscape().bind(function(c){return c(a,b)})}),Ra(oe([ul,Pa([13])]),function(a,b,c,d){return c.onEnter().bind(function(c){return c(a,b)})})]),l=k({}),m=k({});return zh(a,me.init,h,l,m,g.some(function(a,b){c(a,b).each(function(c){b.focusManager().set(a,c)})}))},Dga=RO(sg("cyclic",k(!1))),Ega=RO(sg("cyclic",k(!0))),
  SO=function(a){return"input"===D.name(a)&&"radio"!==m.get(a,"type")||"textarea"===D.name(a)},xl=function(a,b,c){SO(c)&&Pa([32])(b.event())?a=g.none():(b=iO(),Lp(a,c,b,{}),a=g.some(!0));return a},Fga=[da("execute",xl),da("useSpace",!1),da("useEnter",!0),da("useControlEnter",!1),da("useDown",!1)],TO=function(a,b,c){return c.execute()(a,b,a.element())},Gga=k({}),Hga=k({}),Iga=zh(Fga,me.init,function(a,b,c,d){a=c.useSpace()&&!SO(a.element())?[32]:[];b=c.useEnter()?[13]:[];d=c.useDown()?[40]:[];a=a.concat(b).concat(d);
  return[Ra(Pa(a),TO)].concat(c.useControlEnter()?[Ra(oe([xga,Pa([13])]),TO)]:[])},Gga,Hga,g.none()),UO=function(a){var b=na(g.none());return rl({readState:k({}),setGridSize:function(a,d){b.set(g.some({numRows:k(a),numColumns:k(d)}))},getNumRows:function(){return b.get().map(function(a){return a.numRows()})},getNumColumns:function(){return b.get().map(function(a){return a.numColumns()})}})},Jga=Object.freeze({flatgrid:UO,init:function(a){return a.state()(a)}}),WO=function(a){return function(b,c,d,e){var f=
  a(b.element());return VO(f,b,c,d,e)}},Rw=function(a,b){a=ae.onDirection(a,b);return WO(a)},Sw=function(a,b){a=ae.onDirection(b,a);return WO(a)},Bg=function(a){return function(b,c,d,e){return VO(a,b,c,d,e)}},VO=function(a,b,c,d,e){return d.focusManager().get(b).bind(function(c){return a(b.element(),c,d,e)}).map(function(a){d.focusManager().set(b,a);return!0})},Kga=Aa(["index","candidates"],[]),Lga=function(a,b){return Va(a,b).map(function(b){return Kga({index:b,candidates:a})})},XO=function(a,b,c){b=
  u(N.eq,b);a=Y.descendants(a,c);a=ka(a,sc.isVisible);return Lga(a,b)},YO=function(a,b){return Va(a,function(a){return N.eq(b,a)})},ZO=function(a,b,c,d){return d(Math.floor(b/c),b%c).bind(function(b){b=b.row()*c+b.column();return 0<=b&&b<a.length?g.some(a[b]):g.none()})},$O=function(a,b,c,d,e){return ZO(a,b,d,function(b,h){h=Wi(h,e,0,(b===c-1?a.length-b*d:d)-1);return g.some({row:k(b),column:k(h)})})},aP=function(a,b,c,d,e){return ZO(a,b,d,function(b,h){b=Wi(b,e,0,c-1);h=vl(h,0,(b===c-1?a.length-b*
  d:d)-1);return g.some({row:k(b),column:k(h)})})},Mga=[za("selector"),da("execute",xl),Xd("onEscape"),da("captureTab",!1),Gfa()],Nga=function(a,b){return b.focusManager().get(a).bind(function(a){return L.closest(a,b.selector())})},Qp=function(a){return function(b,c,d,e){return XO(b,c,d.selector()).bind(function(b){return a(b.candidates(),b.index(),e.getNumRows().getOr(d.initSize().numRows()),e.getNumColumns().getOr(d.initSize().numColumns()))})}},bP=function(a,b,c,d){return c.captureTab()?g.some(!0):
  g.none()},cP=Qp(function(a,b,c,d){return $O(a,b,c,d,-1)}),dP=Qp(function(a,b,c,d){return $O(a,b,c,d,1)}),Oga=Qp(function(a,b,c,d){return aP(a,b,c,d,-1)}),Pga=Qp(function(a,b,c,d){return aP(a,b,c,d,1)}),Qga=k([Ra(Pa([37]),Rw(cP,dP)),Ra(Pa([39]),Sw(cP,dP)),Ra(Pa([38]),Bg(Oga)),Ra(Pa([40]),Bg(Pga)),Ra(oe([Vi,Pa([9])]),bP),Ra(oe([ul,Pa([9])]),bP),Ra(Pa([27]),function(a,b,c,d){return c.onEscape()(a,b)}),Ra(Pa([32].concat([13])),function(a,b,c,d){return Nga(a,c).bind(function(d){return c.execute()(a,b,
  d)})})]),Rga=k({}),Sga=zh(Mga,UO,Qga,Rga,{},g.some(function(a,b,c){L.descendant(a.element(),b.selector()).each(function(c){b.focusManager().set(a,c)})})),Rp=function(a,b,c,d){return XO(a,c,b).bind(function(a){var b=a.index();a=a.candidates();b=Wi(b,d,0,a.length-1);return g.from(a[b])})},Tga=[za("selector"),da("getInitial",g.none),da("execute",xl),Xd("onEscape"),da("executeOnMove",!1),da("allowVertical",!0)],Uga=function(a,b){return b.focusManager().get(a).bind(function(a){return L.closest(a,b.selector())})},
  Tw=function(a,b,c){return Uga(a,c).bind(function(d){return c.execute()(a,b,d)})},eP=function(a,b,c){return Rp(a,c.selector(),b,-1)},fP=function(a,b,c){return Rp(a,c.selector(),b,1)},gP=function(a){return function(b,c,d){return a(b,c,d).bind(function(){return d.executeOnMove()?Tw(b,c,d):g.some(!0)})}},Vga=function(a,b,c,d){return c.onEscape()(a,b)},Wga=k({}),Xga=k({}),Yga=zh(Tga,me.init,function(a,b,c,d){a=[37].concat(c.allowVertical()?[38]:[]);c=[39].concat(c.allowVertical()?[40]:[]);return[Ra(Pa(a),
  gP(Rw(eP,fP))),Ra(Pa(c),gP(Sw(eP,fP))),Ra(Pa([13]),Tw),Ra(Pa([32]),Tw),Ra(Pa([27]),Vga)]},Wga,Xga,g.some(function(a,b){b.getInitial()(a).or(L.descendant(a.element(),b.selector())).each(function(c){b.focusManager().set(a,c)})})),Zga=Aa(["rowIndex","columnIndex","cell"],[]),Sp=function(a,b,c){return g.from(a[b]).bind(function(a){return g.from(a[c]).map(function(a){return Zga({rowIndex:b,columnIndex:c,cell:a})})})},hP=function(a,b,c,d){c=Wi(c,d,0,a[b].length-1);return Sp(a,b,c)},iP=function(a,b,c,d){c=
  Wi(c,d,0,a.length-1);b=vl(b,0,a[c].length-1);return Sp(a,c,b)},jP=function(a,b,c,d){c=vl(c+d,0,a[b].length-1);return Sp(a,b,c)},kP=function(a,b,c,d){c=vl(c+d,0,a.length-1);b=vl(b,0,a[c].length-1);return Sp(a,c,b)},$ga=[cl("selectors",[za("row"),za("cell")]),da("cycles",!0),da("previousSelector",g.none),da("execute",xl)],aha=function(a,b){return E(a,function(a){return Y.descendants(a,b.selectors().cell())})},Tp=function(a,b){return function(c,d,e){var f=e.cycles()?a:b;return L.closest(d,e.selectors().row()).bind(function(a){var b=
  Y.descendants(a,e.selectors().cell());return YO(b,d).bind(function(b){var d=Y.descendants(c,e.selectors().row());return YO(d,a).bind(function(a){var c=aha(d,e);return f(c,a,b).map(function(a){return a.cell()})})})})}},lP=Tp(function(a,b,c){return hP(a,b,c,-1)},function(a,b,c){return jP(a,b,c,-1)}),mP=Tp(function(a,b,c){return hP(a,b,c,1)},function(a,b,c){return jP(a,b,c,1)}),bha=Tp(function(a,b,c){return iP(a,c,b,-1)},function(a,b,c){return kP(a,c,b,-1)}),cha=Tp(function(a,b,c){return iP(a,c,b,1)},
  function(a,b,c){return kP(a,c,b,1)}),dha=k([Ra(Pa([37]),Rw(lP,mP)),Ra(Pa([39]),Sw(lP,mP)),Ra(Pa([38]),Bg(bha)),Ra(Pa([40]),Bg(cha)),Ra(Pa([32].concat([13])),function(a,b,c){return Z.search(a.element()).bind(function(d){return c.execute()(a,b,d)})})]),eha=k({}),fha=k({}),gha=zh($ga,me.init,dha,eha,fha,g.some(function(a,b){b.previousSelector()(a).orThunk(function(){var c=b.selectors();return L.descendant(a.element(),c.cell())}).each(function(c){b.focusManager().set(a,c)})})),hha=[za("selector"),da("execute",
  xl),da("moveOnTab",!1)],nP=function(a,b,c){return c.focusManager().get(a).bind(function(d){return c.execute()(a,b,d)})},oP=function(a,b,c){return Rp(a,c.selector(),b,-1)},pP=function(a,b,c){return Rp(a,c.selector(),b,1)},iha=k([Ra(Pa([38]),Bg(oP)),Ra(Pa([40]),Bg(pP)),Ra(oe([Vi,Pa([9])]),function(a,b,c){return c.moveOnTab()?Bg(oP)(a,b,c):g.none()}),Ra(oe([ul,Pa([9])]),function(a,b,c){return c.moveOnTab()?Bg(pP)(a,b,c):g.none()}),Ra(Pa([13]),nP),Ra(Pa([32]),nP)]),jha=k({}),kha=k({}),lha=zh(hha,me.init,
  iha,jha,kha,g.some(function(a,b){L.descendant(a.element(),b.selector()).each(function(c){b.focusManager().set(a,c)})})),mha=[Xd("onSpace"),Xd("onEnter"),Xd("onShiftEnter"),Xd("onLeft"),Xd("onRight"),Xd("onTab"),Xd("onShiftTab"),Xd("onUp"),Xd("onDown"),Xd("onEscape"),Dd("focusIn")],nha=zh(mha,me.init,function(a,b,c){return[Ra(Pa([32]),c.onSpace()),Ra(oe([ul,Pa([13])]),c.onEnter()),Ra(oe([Vi,Pa([13])]),c.onShiftEnter()),Ra(oe([Vi,Pa([9])]),c.onShiftTab()),Ra(oe([ul,Pa([9])]),c.onTab()),Ra(Pa([38]),
  c.onUp()),Ra(Pa([40]),c.onDown()),Ra(Pa([37]),c.onLeft()),Ra(Pa([39]),c.onRight()),Ra(Pa([32]),c.onSpace()),Ra(Pa([27]),c.onEscape())]},function(){return{}},function(){return{}},g.some(function(a,b){return b.focusIn().bind(function(c){return c(a,b)})})),oha=Dga.schema(),pha=Ega.schema(),qha=Yga.schema(),rha=Sga.schema(),sha=gha.schema(),tha=Iga.schema(),uha=lha.schema(),vha=nha.schema(),yl=function(a){var b=Oe("Creating behaviour: "+a.name,sga,a);a=WK(b.branchKey,b.branches);var c=b.name,d=b.active,
  e=b.apis,f=b.extra;b=b.state;var h=dl(c,[kL("config",a)]);return LO(a,h,c,d,e,f,b)}({branchKey:"mode",branches:Object.freeze({acyclic:oha,cyclic:pha,flow:qha,flatgrid:rha,matrix:sha,execution:tha,menu:uha,special:vha}),name:"keying",active:{events:function(a,b){return a.handler().toEvents(a,b)}},apis:{focusIn:function(a){a.getSystem().triggerFocus(a.element(),a.element())},setGridSize:function(a,b,c,d,e){ye(c,"setGridSize")?c.setGridSize(d,e):ud.error("Layout does not support setGridSize")}},state:Jga}),
  wha=Object.freeze({getCurrent:function(a,b,c){return b.find()(a)}}),xha=[za("find")],ze=Ag({fields:xha,name:"composing",apis:wha}),qP=function(a,b){b.ignore()||(Z.focus(a.element()),b.onFocus()(a))},yha=Object.freeze({focus:qP,blur:function(a,b){b.ignore()||Z.blur(a.element())},isFocused:function(a){return Z.hasFocus(a.element())}}),zha=Object.freeze({exhibit:function(a,b){a=b.ignore()?{}:{attributes:{tabindex:"-1"}};return Ui(a)},events:function(a){return pb([Yb(yh(),function(b,c){qP(b,a);c.stop()})].concat(a.stopMousedown()?
  [Yb(ol(),function(a,c){c.event().prevent()})]:[]))}}),Aha=[yg("onFocus"),da("stopMousedown",!1),da("ignore",!1)],Xi=Ag({fields:Aha,name:"focusing",active:zha,apis:yha}),Uw=aa.detect().deviceType.isTouch(),Cg=function(a){return Nw({name:""+a+"-edge",overrides:function(b){return b.model().manager().edgeActions()[a].fold(function(){return{}},function(a){var c=pb([Aw(nl(),a,[b])]),e=pb([Aw(ol(),a,[b]),Aw(vw(),function(b,c){c.mouseIsDown().get()&&a(b,c)},[b])]);return{events:Uw?c:e}})}})},Bha=Cg("top-left"),
  Cha=Cg("top"),Dha=Cg("top-right"),Eha=Cg("right"),Fha=Cg("bottom-right"),Gha=Cg("bottom"),Hha=Cg("bottom-left"),Iha=Cg("left"),Jha=Pp({name:"thumb",defaults:k({dom:{styles:{position:"absolute"}}}),overrides:function(a){return{events:pb([Ti(nl(),a,"spectrum"),Ti(tw(),a,"spectrum"),Ti(uw(),a,"spectrum"),Ti(ol(),a,"spectrum"),Ti(vw(),a,"spectrum"),Ti(gO(),a,"spectrum")])}}}),Kha=Pp({schema:[sg("mouseIsDown",function(){return na(!1)})],name:"spectrum",overrides:function(a){var b=a.model().manager(),c=
  function(c,d){return b.getValueFromEvent(d).map(function(d){return b.setValueFrom(c,a,d)})},d=pb([Yb(nl(),c),Yb(tw(),c)]),e=pb([Yb(ol(),c),Yb(vw(),function(b,d){a.mouseIsDown().get()&&c(b,d)})]);return{behaviours:pb(Uw?[]:[yl.config({mode:"special",onLeft:function(c){return b.onLeft(c,a)},onRight:function(c){return b.onRight(c,a)},onUp:function(c){return b.onUp(c,a)},onDown:function(c){return b.onDown(c,a)}}),Xi.config({})]),events:Uw?d:e}}}),Lha=[Iha,Eha,Cha,Gha,Bha,Dha,Hha,Fha,Jha,Kha],Vw=function(a,
  b,c){b.store().manager().onLoad(a,b,c)},rP=function(a,b,c){b.store().manager().onUnload(a,b,c)},Mha=Object.freeze({onLoad:Vw,onUnload:rP,setValue:function(a,b,c,d){b.store().manager().setValue(a,b,c,d)},getValue:function(a,b,c){return b.store().manager().getValue(a,b,c)},getState:function(a,b,c){return c}}),Nha=Object.freeze({events:function(a,b){var c=a.resetOnDom()?[Mp(function(c,e){Vw(c,a,b)}),hfa(function(c,e){rP(c,a,b)})]:[oga(a,b,Vw)];return pb(c)}}),sP=function(){var a=na(null);return rl({set:a.set,
  get:a.get,isNotSet:function(){return null===a.get()},clear:function(){a.set(null)},readState:function(){return{mode:"memory",value:a.get()}}})},tP=function(){var a=na({}),b=na({});return rl({readState:function(){return{mode:"dataset",dataByValue:a.get(),dataByText:b.get()}},lookup:function(c){return SK(a.get(),c).orThunk(function(){return SK(b.get(),c)})},update:function(c){var d=a.get(),e=b.get(),f={},h={};z(c,function(a){f[a.value]=a;h[a.text]=a});a.set(oa(d,f));b.set(oa(e,h))},clear:function(){a.set({});
  b.set({})}})},Oha=Object.freeze({memory:sP,dataset:tP,manual:function(){return rl({readState:function(){}})},init:function(a){return a.store().manager().state(a)}}),uP=function(a,b,c,d){var e=b.store();c.update([d]);e.setValue()(a,d);b.onSetValue()(a,d)},Pha=[Dd("initialValue"),za("getFallbackEntry"),za("getDataKey"),za("setValue"),zg("manager",{setValue:uP,getValue:function(a,b,c){var d=b.store(),e=d.getDataKey()(a);return c.lookup(e).fold(function(){return d.getFallbackEntry()(e)},function(a){return a})},
  onLoad:function(a,b,c){b.store().initialValue().each(function(d){uP(a,b,c,d)})},onUnload:function(a,b,c){c.clear()},state:tP})],Qha=[za("getValue"),da("setValue",t),Dd("initialValue"),zg("manager",{setValue:function(a,b,c,d){b.store().setValue()(a,d);b.onSetValue()(a,d)},getValue:function(a,b,c){return b.store().getValue()(a)},onLoad:function(a,b,c){b.store().initialValue().each(function(c){b.store().setValue()(a,c)})},onUnload:t,state:me.init})],Rha=[Dd("initialValue"),zg("manager",{setValue:function(a,
  b,c,d){c.set(d);b.onSetValue()(a,d)},getValue:function(a,b,c){return c.get()},onLoad:function(a,b,c){b.store().initialValue().each(function(a){c.isNotSet()&&c.set(a)})},onUnload:function(a,b,c){c.clear()},state:sP})],Sha=[function(a,b,c){return Dc(a,a,Ne.defaultedThunk(k(b)),c)}("store",{mode:"memory"},ZK("mode",{memory:Rha,manual:Qha,dataset:Pha})),yg("onSetValue"),da("resetOnDom",!1)],Wb=Ag({fields:Sha,name:"representing",active:Nha,apis:Mha,extra:{setValueFrom:function(a,b){b=Wb.getValue(b);Wb.setValue(a,
  b)}},state:Oha}),Tha=aa.detect().deviceType.isTouch(),zl=k("slider.change.value"),Ww=function(a){a=a.event().raw();return Tha?void 0!==a.touches&&1===a.touches.length?g.some(a.touches[0]).map(function(a){return Qa(a.clientX,a.clientY)}):g.none():void 0!==a.clientX?g.some(a).map(function(a){return Qa(a.clientX,a.clientY)}):g.none()},Xw=function(a,b,c,d){return a<b?a:a>c?c:a===b?b-1:Math.max(b,a-d)},Yw=function(a,b,c,d){return a>c?a:a<b?b:a===c?c+1:Math.min(c,a+d)},Uha=function(a,b,c,d,e){return e.fold(function(){return Math.max(b-
  1,Math.min(c+1,b+Math.round((a-b)/d)*d))},function(b){return Math.max(b,b+Math.min(Math.floor((c-b)/d),Math.floor((a-b)/d)+Math.round((a-b)%d/d))*d)})},vP=function(a){var b=a.min,c=a.max,d=a.value,e=a.step,f=a.snapStart,h=a.rounded,g=a.minBound,k=a.maxBound,m=a.hasMinEdge?b-1:b,n=a.hasMaxEdge?c+1:c;if(d<g)return m;if(d>k)return n;d=Math.max(m,Math.min(n,(Math.min(k,Math.max(d,g))-g)/a.screenRange*a.range+b));return a.snap&&d>=b&&d<=c?Uha(d,b,c,e,f):h?Math.round(d):d},wP=function(a){var b=a.min,c=
  a.max,d=a.range,e=a.value,f=a.hasMinEdge,h=a.hasMaxEdge,g=a.maxBound,k=a.maxOffset,m=a.centerMinEdge;a=a.centerMaxEdge;return e<b?f?0:m:e>c?h?g:a:(e-b)/d*k},Ue=function(a){return a.model().minX()},Ve=function(a){return a.model().minY()},We=function(a){return a.model().maxX()},Xe=function(a){return a.model().maxY()},Dg=function(a,b,c){return b(a)-c(a)},Eg=function(a,b){return void 0!==a[b+"-edge"]},If=function(a){return a.model().value().get()},Fg=function(a,b){return{x:k(a),y:k(b)}},Yd=function(a,
  b){Te(a,zl(),{value:b})},rc=function(a){return a.element().dom().getBoundingClientRect()},xP=function(a,b){a=rc(a);b=rc(b);return(a.left+a.right)/2-b.left},yP=function(a,b){a=rc(a);b=rc(b);return(a.top+a.bottom)/2-b.top},Up=function(a,b){Te(a,zl(),{value:b})},Zw=function(a,b,c){a={min:Ue(b),max:We(b),range:Dg(b,We,Ue),value:c,step:b.stepSize(),snap:b.snapToGrid(),snapStart:b.snapStart(),rounded:b.rounded(),hasMinEdge:Eg(b,"left"),hasMaxEdge:Eg(b,"right"),minBound:rc(a).left,maxBound:rc(a).right,screenRange:rc(a).width};
  return vP(a)},Vha=function(a,b,c){a=(0<a?Yw:Xw)(If(c).x(),Ue(c),We(c),c.stepSize());Up(b,{x:k(a)});return g.some(a)},zP=function(a){return function(b,c){return Vha(a,b,c).map(function(){return!0})}},Wha=function(a,b,c,d,e){var f=rc(a).width;d=d.bind(function(b){return g.some(xP(b,a))}).getOr(0);e=e.bind(function(b){return g.some(xP(b,a))}).getOr(f);b={min:Ue(b),max:We(b),range:Dg(b,We,Ue),value:c,hasMinEdge:Eg(b,"left"),hasMaxEdge:Eg(b,"right"),minBound:rc(a).left,minOffset:0,maxBound:rc(a).right,
  maxOffset:f,centerMinEdge:d,centerMaxEdge:e};return wP(b)},$w=function(a,b,c,d,e,f){c=Wha(b,f,c,d,e);return rc(b).left-rc(a).left+c},Xha=zP(-1),Yha=zP(1),Zha=g.none,$ha=g.none,aia=k({"top-left":g.none(),top:g.none(),"top-right":g.none(),right:g.some(function(a,b){Yd(a,{x:k(b.model().maxX()+1)})}),"bottom-right":g.none(),bottom:g.none(),"bottom-left":g.none(),left:g.some(function(a,b){Yd(a,{x:k(b.model().minX()-1)})})}),bia=Object.freeze({setValueFrom:function(a,b,c){b=Zw(a,b,c);c={x:k(b)};Up(a,c);
  return b},setToMin:function(a,b){b=Ue(b);Up(a,{x:k(b)})},setToMax:function(a,b){b=We(b);Up(a,{x:k(b)})},findValueOfOffset:Zw,getValueFromEvent:function(a){return Ww(a).map(function(a){return a.left()})},findPositionOfValue:$w,setPositionFromValue:function(a,b,c,d){var e=If(c);a=$w(a,d.getSpectrum(a),e.x(),d.getLeftEdge(a),d.getRightEdge(a),c);c=Ga.get(b.element())/2;v.set(b.element(),"left",a-c+"px")},onLeft:Xha,onRight:Yha,onUp:Zha,onDown:$ha,edgeActions:aia}),Vp=function(a,b){Te(a,zl(),{value:b})},
  ax=function(a,b,c){a={min:Ve(b),max:Xe(b),range:Dg(b,Xe,Ve),value:c,step:b.stepSize(),snap:b.snapToGrid(),snapStart:b.snapStart(),rounded:b.rounded(),hasMinEdge:Eg(b,"top"),hasMaxEdge:Eg(b,"bottom"),minBound:rc(a).top,maxBound:rc(a).bottom,screenRange:rc(a).height};return vP(a)},cia=function(a,b,c){a=(0<a?Yw:Xw)(If(c).y(),Ve(c),Xe(c),c.stepSize());Vp(b,{y:k(a)});return g.some(a)},AP=function(a){return function(b,c){return cia(a,b,c).map(function(){return!0})}},dia=function(a,b,c,d,e){var f=rc(a).height;
  d=d.bind(function(b){return g.some(yP(b,a))}).getOr(0);e=e.bind(function(b){return g.some(yP(b,a))}).getOr(f);b={min:Ve(b),max:Xe(b),range:Dg(b,Xe,Ve),value:c,hasMinEdge:Eg(b,"top"),hasMaxEdge:Eg(b,"bottom"),minBound:rc(a).top,minOffset:0,maxBound:rc(a).bottom,maxOffset:f,centerMinEdge:d,centerMaxEdge:e};return wP(b)},bx=function(a,b,c,d,e,f){c=dia(b,f,c,d,e);return rc(b).top-rc(a).top+c},eia=g.none,fia=g.none,gia=AP(-1),hia=AP(1),iia=k({"top-left":g.none(),top:g.some(function(a,b){Yd(a,{y:k(b.model().minY()-
  1)})}),"top-right":g.none(),right:g.none(),"bottom-right":g.none(),bottom:g.some(function(a,b){Yd(a,{y:k(b.model().maxY()+1)})}),"bottom-left":g.none(),left:g.none()}),jia=Object.freeze({setValueFrom:function(a,b,c){b=ax(a,b,c);c={y:k(b)};Vp(a,c);return b},setToMin:function(a,b){b=Ve(b);Vp(a,{y:k(b)})},setToMax:function(a,b){b=Xe(b);Vp(a,{y:k(b)})},findValueOfOffset:ax,getValueFromEvent:function(a){return Ww(a).map(function(a){return a.top()})},findPositionOfValue:bx,setPositionFromValue:function(a,
  b,c,d){var e=If(c);a=bx(a,d.getSpectrum(a),e.y(),d.getTopEdge(a),d.getBottomEdge(a),c);c=sa.get(b.element())/2;v.set(b.element(),"top",a-c+"px")},onLeft:eia,onRight:fia,onUp:gia,onDown:hia,edgeActions:iia}),Wp=function(a,b){Te(a,zl(),{value:b})},Xp=function(a,b){return{x:k(a),y:k(b)}},kia=function(a,b,c,d){var e=0<a?Yw:Xw;a=b?If(d).x():e(If(d).x(),Ue(d),We(d),d.stepSize());b=b?e(If(d).y(),Ve(d),Xe(d),d.stepSize()):If(d).y();Wp(c,Xp(a,b));return g.some(a)},Yp=function(a,b){return function(c,d){return kia(a,
  b,c,d).map(function(){return!0})}},lia=Yp(-1,!1),mia=Yp(1,!1),nia=Yp(-1,!0),oia=Yp(1,!0),pia=k({"top-left":g.some(function(a,b){Yd(a,Fg(b.model().minX()-1,b.model().minY()-1))}),top:g.some(function(a,b){Yd(a,Fg(Dg(b,We,Ue)/2,b.model().minY()-1))}),"top-right":g.some(function(a,b){Yd(a,Fg(b.model().maxX()+1,b.model().minY()-1))}),right:g.some(function(a,b){Yd(a,Fg(b.model().maxX()+1,Dg(b,Xe,Ve)/2))}),"bottom-right":g.some(function(a,b){Yd(a,Fg(b.model().maxX()+1,b.model().maxY()+1))}),bottom:g.some(function(a,
  b){Yd(a,Fg(Dg(b,We,Ue)/2,b.model().maxY()+1))}),"bottom-left":g.some(function(a,b){Yd(a,Fg(b.model().minX()-1,b.model().maxY()+1))}),left:g.some(function(a,b){Yd(a,Fg(b.model().minX()-1,Dg(b,Xe,Ve)/2))})}),qia=Object.freeze({setValueFrom:function(a,b,c){var d=Zw(a,b,c.left());b=ax(a,b,c.top());d=Xp(d,b);Wp(a,d);return d},setToMin:function(a,b){var c=Ue(b);b=Ve(b);Wp(a,Xp(c,b))},setToMax:function(a,b){var c=We(b);b=Xe(b);Wp(a,Xp(c,b))},getValueFromEvent:function(a){return Ww(a)},setPositionFromValue:function(a,
  b,c,d){var e=If(c),f=$w(a,d.getSpectrum(a),e.x(),d.getLeftEdge(a),d.getRightEdge(a),c);a=bx(a,d.getSpectrum(a),e.y(),d.getTopEdge(a),d.getBottomEdge(a),c);c=Ga.get(b.element())/2;d=sa.get(b.element())/2;v.set(b.element(),"left",f-c+"px");v.set(b.element(),"top",a-d+"px")},onLeft:lia,onRight:mia,onUp:nia,onDown:oia,edgeActions:pia}),ria=aa.detect().deviceType.isTouch(),sia=[da("stepSize",1),da("onChange",t),da("onInit",t),da("onDragStart",t),da("onDragEnd",t),da("snapToGrid",!1),da("rounded",!0),Dd("snapStart"),
  dp("model",ZK("mode",{x:[da("minX",0),da("maxX",100),sg("value",function(a){return na(a.mode.minX)}),za("getInitialValue"),zg("manager",bia)],y:[da("minY",0),da("maxY",100),sg("value",function(a){return na(a.mode.minY)}),za("getInitialValue"),zg("manager",jia)],xy:[da("minX",0),da("maxX",100),da("minY",0),da("maxY",100),sg("value",function(a){return na({x:k(a.mode.minX),y:k(a.mode.minY)})}),za("getInitialValue"),zg("manager",qia)]})),sl("sliderBehaviours",[yl,Wb])].concat(ria?[]:[sg("mouseIsDown",
  function(){return na(!1)})]),tia=function(a,b){return b.universal()?a:ka(a,function(a){return U(b.channels(),a)})},uia=Object.freeze({events:function(a){return pb([Yb(hO(),function(b,c){var d=a.channels(),e=cb(d);e=tia(e,c);z(e,function(a){var e=d[a](),f=e.schema();a="channel["+a+"] data\nReceiver: "+Tg(b.element());var g=c.data();f=Ji(rg(a,f,g));e.onReceive()(b,f)})})])}}),via=[dp("channels",function(a,b){var c=function(b,c){return VK(Ii(a)).extract(b,ca,c)};return{extract:function(a,e,f){var d=
  cb(f);return c(a,d).bind(function(c){c=E(c,function(a){return sv.field(a,a,qg(),b)});return Cc(c).extract(a,e,f)})},toString:function(){return"setOf("+b.toString()+")"},toDsl:function(){return Xk.setOf(a,b)}}}(J.value,md([Gw("onHandler","onReceive",qg()),da("schema",$o())])))],wia=Ag({fields:via,name:"receiving",active:uia}),BP=aa.detect().deviceType.isTouch(),Yi=IO({name:"Slider",configFields:sia,partFields:Lha,factory:function(a,b,c,d){var e=function(b){return EO(b,a,"thumb")},f=function(b){return EO(b,
  a,"spectrum")},h=function(b){return ne(b,a,"left-edge")},l=function(b){return ne(b,a,"right-edge")},m=function(b){return ne(b,a,"top-edge")},n=function(b){return ne(b,a,"bottom-edge")},w=a.model(),p=w.manager(),r=function(b,c){p.setPositionFromValue(b,c,a,{getLeftEdge:h,getRightEdge:l,getTopEdge:m,getBottomEdge:n,getSpectrum:f})},t=function(b,c){w.value().set(c);var d=e(b);r(b,d);a.onChange()(b,d,c);return g.some(!0)};c=[Yb(nl(),function(b,c){a.onDragStart()(b,e(b))}),Yb(uw(),function(b,c){a.onDragEnd()(b,
  e(b))})];d=[Yb(ol(),function(b,c){c.stop();a.onDragStart()(b,e(b));a.mouseIsDown().set(!0)}),Yb(gO(),function(b,c){a.onDragEnd()(b,e(b));a.mouseIsDown().set(!1)})];c=BP?c:d;return{uid:a.uid(),dom:a.dom(),components:b,behaviours:oa(pb(Qb([BP?[]:[yl.config({mode:"special",focusIn:function(b){return ne(b,a,"spectrum").map(yl.focusIn).map(k(!0))}})],[Wb.config({store:{mode:"manual",getValue:function(b){return a.model().value().get()}}}),wia.config({channels:{"mouse.released":{onReceive:function(b,c){a.mouseIsDown().set(!1)}}}})]])),
  a.sliderBehaviours().dump()),events:pb([Yb(zl(),function(a,b){t(a,b.event().value())}),Mp(function(b,c){c=w.getInitialValue();w.value().set(c());c=e(b);r(b,c);var d=f(b);a.onInit()(b,c,d,w.value().get())})].concat(c)),apis:{resetToMin:function(b){p.setToMin(b,a)},resetToMax:function(b){p.setToMax(b,a)},changeValue:t,refresh:r},domModification:{styles:{position:"relative"}}}},apis:{resetToMin:function(a,b){a.resetToMin(b)},resetToMax:function(a,b){a.resetToMax(b)},refresh:function(a,b){a.refresh(b)}}}),
  CP=/^#?([a-f\d])([a-f\d])([a-f\d])$/i,DP=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i,xia=function(a){return CP.test(a)||DP.test(a)},yia=function(a){a=a.value().replace(CP,function(a,c,d,e){return c+c+d+d+e+e});return{value:k(a)}},cx=function(a){a=a.toString(16);return 1==a.length?"0"+a:a},dx=function(a){a=cx(a.red())+cx(a.green())+cx(a.blue());return{value:k(a)}},EP=Math.min,FP=Math.max,Zp=Math.round,Al=function(a,b,c,d){return{red:k(a),green:k(b),blue:k(c),alpha:k(d)}},ex=function(a){var b=parseInt(a,
  10);return b.toString()===a&&0<=b&&255>=b},GP=function(a){var b;var c=(a.hue()||0)%360;var d=a.saturation()/100;a=a.value()/100;d=FP(0,EP(d,1));a=FP(0,EP(a,1));if(0===d){var e=b=d=Zp(255*a);return Al(e,b,d,1)}e=c/60;d*=a;c=d*(1-Math.abs(e%2-1));a-=d;switch(Math.floor(e)){case 0:e=d;b=c;d=0;break;case 1:e=c;b=d;d=0;break;case 2:e=0;b=d;d=c;break;case 3:e=0;b=c;break;case 4:e=c;b=0;break;case 5:e=d;b=0;d=c;break;default:e=b=d=0}e=Zp(255*(e+a));b=Zp(255*(b+a));d=Zp(255*(d+a));return Al(e,b,d,1)},fx=
  function(a){a=yia(a);var b=DP.exec(a.value());a=parseInt(b[1],16);var c=parseInt(b[2],16);b=parseInt(b[3],16);return Al(a,c,b,1)},HP=function(a){return"rgba("+a.red()+","+a.green()+","+a.blue()+","+a.alpha()+")"},IP=k(Al(255,0,0,1)),zia=k(Fa("rgb-hex-update")),JP=k(Fa("slider-update")),KP=k(Fa("palette-update")),Aia={paletteFactory:function(a,b){var c=Yi.parts().spectrum({dom:{tag:"canvas",attributes:{role:"presentation"},classes:[b("sv-palette-spectrum")]}}),d=Yi.parts().thumb({dom:{tag:"div",attributes:{role:"presentation"},
  classes:[b("sv-palette-thumb")],innerHtml:"<div class="+b("sv-palette-inner-thumb")+' role="presentation"></div>'}}),e=function(a,b){var c=a.width,d=a.height;a=a.getContext("2d");a.fillStyle=b;a.fillRect(0,0,c,d);b=a.createLinearGradient(0,0,c,0);b.addColorStop(0,"rgba(255,255,255,1)");b.addColorStop(1,"rgba(255,255,255,0)");a.fillStyle=b;a.fillRect(0,0,c,d);b=a.createLinearGradient(0,0,0,d);b.addColorStop(0,"rgba(0,0,0,0)");b.addColorStop(1,"rgba(0,0,0,1)");a.fillStyle=b;a.fillRect(0,0,c,d)};return tl({factory:function(a){a=
  k({x:k(0),y:k(0)});var f=pb([ze.config({find:g.some}),Xi.config({})]);return Yi.sketch({dom:{tag:"div",attributes:{role:"presentation"},classes:[b("sv-palette")]},model:{mode:"xy",getInitialValue:a},rounded:!1,components:[c,d],onChange:function(a,b,c){Te(a,KP(),{value:c})},onInit:function(a,b,c,d){e(c.element().dom(),HP(IP()))},sliderBehaviours:f})},name:"SaturationBrightnessPalette",configFields:[],apis:{setRgba:function(a,b,c){a=b.components()[0].element().dom();e(a,HP(c))}},extraApis:{}})}},Bia=
  {sliderFactory:function(a,b){a=Yi.parts().spectrum({dom:{tag:"div",classes:[b("hue-slider-spectrum")],attributes:{role:"presentation"}}});var c=Yi.parts().thumb({dom:{tag:"div",classes:[b("hue-slider-thumb")],attributes:{role:"presentation"}}});return Yi.sketch({dom:{tag:"div",classes:[b("hue-slider")],attributes:{role:"presentation"}},rounded:!1,model:{mode:"y",getInitialValue:k({y:k(0)})},components:[a,c],sliderBehaviours:pb([Xi.config({})]),onChange:function(a,b,c){Te(a,JP(),{value:c})}})}},gx=
  function(a){var b=void 0!==a.uid&&ye(a,"uid")?a.uid:Fa("memento");return{get:function(a){return a.getSystem().getByUid(b).getOrDie()},getOpt:function(a){return a.getSystem().getByUid(b).fold(g.none,g.some)},asSpec:function(){return oa(a,{uid:b})}}},LP=function(a,b){b=pb(b);b=Ag({fields:[za("enabled")],name:a,active:{events:k(b)}});return{key:a,value:{config:{},me:b,configAsRaw:k({}),initialConfig:{},state:me}}},Cia=[sl("formBehaviours",[Wb])],Dia=function(a,b){return a.fold(function(){return J.error(b)},
  J.value)},Eia=function(a,b,c){return oa({"debug.sketcher":{Form:c},uid:a.uid(),dom:a.dom(),components:b,behaviours:oa(pb([Wb.config({store:{mode:"manual",getValue:function(b){b=gga(b,a);return eb(b,function(a,b){return a().bind(function(a){a=ze.getCurrent(a);return Dia(a,"missing current")}).map(Wb.getValue)})},setValue:function(b,c){Ma(c,function(c,d){ne(b,a,d).each(function(a){ze.getCurrent(a).each(function(a){Wb.setValue(a,c)})})})}}})]),a.formBehaviours().dump()),apis:{getField:function(b,c){return ne(b,
  a,c).bind(ze.getCurrent)}}})},MP={getField:Ew(function(a,b,c){return a.getField(b,c)}),sketch:function(a){var b=function(){var a=[];return{field:function(b,c){a.push(b);b="<alloy.field."+b+">";return{uiType:AO(),owner:"form",name:b,config:c,validated:{}}},record:function(){return a}}}();a=a(b);b=b.record();b=E(b,function(a){return Pp({name:a,pname:"<alloy.field."+a+">"})});return HO("form",Cia,b,Eia,a)}},Fia=k([da("prefix","form-field"),sl("fieldBehaviours",[ze,Wb])]),Gia=k([Nw({schema:[za("dom")],
  name:"label"}),Nw({factory:{sketch:function(a){return{uid:a.uid,dom:{tag:"span",styles:{display:"none"},attributes:{"aria-hidden":"true"},innerHtml:a.text}}}},schema:[za("text")],name:"aria-descriptor"}),Pp({factory:{sketch:function(a){var b=waa(a,["factory"]);return a.factory.sketch(b)}},schema:[za("factory")],name:"field"})]),Ah=IO({name:"FormField",configFields:Fia(),partFields:Gia(),factory:function(a,b,c,d){c=oa(pb([ze.config({find:function(b){return ne(b,a,"field")}}),Wb.config({store:{mode:"manual",
  getValue:function(a){return ze.getCurrent(a).bind(Wb.getValue)},setValue:function(a,b){ze.getCurrent(a).each(function(a){Wb.setValue(a,b)})}}})]),a.fieldBehaviours().dump());d=pb([Mp(function(b,c){var d=fga(b,a,["label","field","aria-descriptor"]);d.field().each(function(b){var c=Fa(a.prefix());d.label().each(function(a){m.set(a.element(),"for",c);m.set(b.element(),"id",c)});d["aria-descriptor"]().each(function(c){var d=Fa(a.prefix());m.set(c.element(),"id",d);m.set(b.element(),"aria-labelledby",
  d)})})})]);return{uid:a.uid(),dom:a.dom(),components:b,behaviours:c,events:d,apis:{getField:function(b){return ne(b,a,"field")},getLabel:function(b){return ne(b,a,"label")}}}},apis:{getField:function(a,b){return a.getField(b)},getLabel:function(a,b){return a.getLabel(b)}}}),Hia=k([Dd("data"),da("inputAttributes",{}),da("inputStyles",{}),da("type","input"),da("tag","input"),da("inputClasses",[]),yg("onSetValue"),da("styles",{}),Dd("placeholder"),da("eventOrder",{}),sl("inputBehaviours",[Wb,Xi]),da("selectOnFocus",
  !0)]),Iia=function(a){return pb([Xi.config({onFocus:!1===a.selectOnFocus()?t:function(a){a=a.element();var b=fa.get(a);a.dom().setSelectionRange(0,b.length)}})])},Jia=function(a){return oa(pb([Wb.config({store:{mode:"manual",initialValue:a.data().getOr(void 0),getValue:function(a){return fa.get(a.element())},setValue:function(a,c){fa.get(a.element())!==c&&fa.set(a.element(),c)}},onSetValue:a.onSetValue()})]),Iia(a),a.inputBehaviours().dump())},Kia=function(a){return{tag:a.tag(),attributes:oa(pb([{key:"type",
  value:a.type()}].concat(a.placeholder().map(function(a){return{key:"placeholder",value:a}}).toArray())),a.inputAttributes()),styles:a.inputStyles(),classes:a.inputClasses()}},Lia=tl({name:"Input",configFields:Hia(),factory:function(a,b){return{uid:a.uid(),dom:Kia(a),components:[],behaviours:Jia(a),eventOrder:a.eventOrder()}}}),Mia=aa.detect().browser.isFirefox(),Nia={position:"absolute",left:"-9999px"},Oia=function(a,b){var c=p.fromTag("span",a.dom());m.set(c,"role","presentation");a=p.fromText(b,
  a.dom());y.append(c,a);return c},Pia=function(a,b){var c=Fa("ephox-alloy-aria-voice");m.set(b,"id",c);m.set(a,"aria-describedby",c)},Qia=function(a,b,c){var d=A.owner(b),e=Oia(d,c);Mia&&Pia(b,e);m.setAll(e,a(c));v.setAll(e,Nia);y.append(b,e);Sg(function(){m.remove(e,"aria-live");F.remove(e)},1E3)},Ria=function(a){return{"aria-live":"assertive","aria-atomic":"true",role:"alert"}},Sia=function(a,b){return Qia(Ria,a,b)},Tia=["input","textarea"],NP=function(a){a=D.name(a);return U(Tia,a)},OP=function(a,
  b){var c=b.getRoot()(a).getOr(a.element());n.remove(c,b.invalidClass());b.notify().each(function(b){NP(a.element())&&m.remove(c,"title");b.getContainer()(a).each(function(a){Ha.set(a,b.validHtml())});b.onValid()(a)})},PP=function(a,b,c,d){c=b.getRoot()(a).getOr(a.element());n.add(c,b.invalidClass());b.notify().each(function(b){NP(a.element())&&m.set(a.element(),"title",d);Sia(ja.body(),d);b.getContainer()(a).each(function(a){Ha.set(a,d)});b.onInvalid()(a,d)})},QP=function(a,b,c){return b.validator().fold(function(){return Ea.pure(J.value(!0))},
  function(b){return b.validate()(a)})},hx=function(a,b,c){b.notify().each(function(b){b.onValidate()(a)});return QP(a,b,c).map(function(d){return a.getSystem().isConnected()?d.fold(function(d){PP(a,b,c,d);return J.error(d)},function(c){OP(a,b);return J.value(c)}):J.error("No longer in system")})},Uia=Object.freeze({markValid:OP,markInvalid:PP,query:QP,run:hx,isInvalid:function(a,b){a=b.getRoot()(a).getOr(a.element());return n.has(a,b.invalidClass())}}),Via=Object.freeze({events:function(a,b){return a.validator().map(function(c){return pb([Yb(c.onEvent(),
  function(c){hx(c,a,b).get(ca)})].concat(c.validateOnLoad()?[Mp(function(c){hx(c,a,b).get(t)})]:[]))}).getOr({})}}),Wia=[za("invalidClass"),da("getRoot",g.none),dl("notify",[da("aria","alert"),da("getContainer",g.none),da("validHtml",""),yg("onValid"),yg("onInvalid"),yg("onValidate")]),dl("validator",[za("validate"),da("onEvent","input"),da("validateOnLoad",!0)])],$p=Ag({fields:Wia,name:"invalidating",active:Via,apis:Uia,extra:{validation:function(a){return function(b){b=Wb.getValue(b);return Ea.pure(a(b))}}}}),
  Xia=Object.freeze({exhibit:function(a,b){return Ui({attributes:pb([{key:b.tabAttr(),value:"true"}])})}}),Yia=[da("tabAttr","data-alloy-tabstop")],Zia=Ag({fields:Yia,name:"tabstopping",active:Xia}),RP=Fa("valid-input"),SP=Fa("invalid-input"),TP=Fa("validating-input"),$ia={rgbFormFactory:function(a,b,c,d){var e=function(c,d){return $p.config({invalidClass:b("invalid"),notify:{onValidate:function(a){Te(a,TP,{type:c})},onValid:function(a){Te(a,RP,{type:c,value:Wb.getValue(a)})},onInvalid:function(a){Te(a,
  SP,{type:c,value:Wb.getValue(a)})}},validator:{validate:function(b){b=Wb.getValue(b);b=d(b)?J.value(!0):J.error(a("aria.input.invalid"));return Ea.pure(b)},validateOnLoad:!1}})},f=function(b,c,d,f,h){var g=a("colorcustom.rgb.range");d=Ah.parts().label({dom:{tag:"label",innerHtml:d,attributes:{"aria-label":f}}});b=Ah.parts().field({data:h,factory:Lia,inputAttributes:{type:"text"},inputBehaviours:pb([e(c,b),Zia.config({})]),onSetValue:function(a){$p.isInvalid(a)&&$p.run(a).get(t)}});b=[d,b];c="hex"!==
  c?[Ah.parts()["aria-descriptor"]({text:g})]:[];return{dom:{tag:"div",attributes:{role:"presentation"}},components:b.concat(c)}},h=function(a,b){var c=dx(b);MP.getField(a,"hex").each(function(b){Xi.isFocused(b)||Wb.setValue(a,{hex:c.value()})});return c},l=function(a,b){var c=b.red(),d=b.green();b=b.blue();Wb.setValue(a,{red:c,green:d,blue:b})},m=gx({dom:{tag:"div",classes:[b("rgba-preview")],styles:{"background-color":"white"},attributes:{role:"presentation"}}}),n=function(a,b){m.getOpt(a).each(function(a){v.set(a.element(),
  "background-color","#"+b.value())})};return tl({factory:function(e){var q={red:k(na(g.some(255))),green:k(na(g.some(255))),blue:k(na(g.some(255))),hex:k(na(g.some("ffffff")))},p=function(a,b){q[a]().set(b)},w=function(){return q.red().get().bind(function(a){return q.green().get().bind(function(b){return q.blue().get().map(function(c){return Al(a,b,c,1)})})})},r=function(a){var b=a.red(),c=a.green();a=a.blue();p("red",g.some(b));p("green",g.some(c));p("blue",g.some(a))},t=function(a,b){b=b.event();
  "hex"!==b.type()?p(b.type(),g.none()):d(a)},C=function(a,b,c){c=parseInt(c,10);p(b,g.some(c));w().each(function(b){b=h(a,b);n(a,b)})},u=function(a,b){b=b.event();if("hex"===b.type()){var d=b.value();c(a);b={value:k(d)};p("hex",g.some(d));d=fx(b);l(a,d);r(d);Te(a,zia(),{hex:b});n(a,b)}else C(a,b.type(),b.value())};e=function(b){return{label:a("colorcustom.rgb."+b+".label"),description:a("colorcustom.rgb."+b+".description")}};var v=e("red"),y=e("green"),x=e("blue"),z=e("hex");return oa(MP.sketch(function(c){return{dom:{tag:"form",
  classes:[b("rgb-form")],attributes:{"aria-label":a("aria.color.picker")}},components:[c.field("red",Ah.sketch(f(ex,"red",v.label,v.description,255))),c.field("green",Ah.sketch(f(ex,"green",y.label,y.description,255))),c.field("blue",Ah.sketch(f(ex,"blue",x.label,x.description,255))),c.field("hex",Ah.sketch(f(xia,"hex",z.label,z.description,"ffffff"))),m.asSpec()],formBehaviours:pb([$p.config({invalidClass:b("form-invalid")}),LP("rgb-form-events",[Yb(RP,u),Yb(SP,t),Yb(TP,t)])])}}),{apis:{updateHex:function(a,
  b){Wb.setValue(a,{hex:b.value()});var c=fx(b);l(a,c);r(c);n(a,b)}}})},name:"RgbForm",configFields:[],apis:{updateHex:function(a,b,c){a.updateHex(b,c)}},extraApis:{}})}},aq=function(a,b,c){return{hue:k(a),saturation:k(b),value:k(c)}},BX={makeFactory:function(a,b){return tl({name:"ColourPicker",configFields:[da("onValidHex",t),da("onInvalidHex",t),kL("formChangeEvent",Laa)],factory:function(c){var d=$ia.rgbFormFactory(a,b,c.onValidHex(),c.onInvalidHex()),e=Aia.paletteFactory(a,b),f={paletteRgba:k(na(IP()))},
  h=gx(e.sketch({})),g=gx(d.sketch({})),m=function(a,b){h.getOpt(a).each(function(a){var c=fx(b);f.paletteRgba().set(c);e.setRgba(a,c)})},n=function(a,b){g.getOpt(a).each(function(a){d.updateHex(a,b)})},p=function(a,b,c){z(c,function(c){c(a,b)})};return{uid:c.uid(),dom:c.dom(),components:[h.asSpec(),Bia.sliderFactory(a,b),g.asSpec()],behaviours:pb([LP("colour-picker-events",[Yb(KP(),function(){var a=[n];return function(b,c){c=c.event().value();var d=f.paletteRgba().get();var e=d.red()/255;var h=d.green()/
  255;d=d.blue()/255;var g=Math.min(e,Math.min(h,d));var k=Math.max(e,Math.max(h,d));e=g===k?aq(0,0,100*g):aq(Math.round(60*((e===g?3:d===g?1:5)-(e===g?h-d:d===g?e-h:d-e)/(k-g))),Math.round((k-g)/k*100),Math.round(100*k));c=aq(e.hue(),c.x(),100-c.y());c=GP(c);c=dx(c);p(b,c,a)}}()),Yb(JP(),function(){var a=[m,n];return function(b,c){c=c.event().value().y();c=aq(360*(100-c/100),100,100);c=GP(c);c=dx(c);p(b,c,a)}}())]),ze.config({find:function(a){return g.getOpt(a)}}),yl.config({mode:"acyclic"})])}}})}},
  UP=function(a){var b=$e(a)?a:10,c=sm.access("local.customColors");a=c.read();var d=function(){return j1(b,function(){return"#ffffff"})},e=function(a){return 0>b-a.length?a.slice(0,b):a}(Mb(a)?a:d()),f=function(a){e.splice(a,1)};return{add:function(a){Gc(e,a).each(f);e.unshift(a);e.length>=b&&e.pop();c.write(e)},state:function(){return e.slice(0)}}}(10),Dm={create:function(a,b){var c=H.create({selected:r(["color"]),menuDone:r([])}),d=p.fromTag("div"),e=Nc(),f=x.translate("font.colorcustom");S.button(e.element(),
  f);e.events.click.bind(function(){c.trigger.menuDone();a.hideInlineSelection();var d=DX(a,b);d.events.color.bind(function(a){UP.add(a.color());c.trigger.selected(a.color());d.destroy()});d.show()});e.content(Qc(f));n.add(e.element(),B.resolve("color-picker-custom"));S.presentation(d);var h=Bm(d),g=ha.button(e.element(),Ba.button({execute:Kb.click})),k=Lea();return{elements:[e.element(),d],layouts:[g,h.grid],events:c.registry,refresh:function(){var a=E(UP.state(),function(a){return{text:a,value:a}});
  a=Gj.create(a);k.set(a);F.empty(d);y.append(d,a.element());a.events.selected.bind(function(a){c.trigger.selected(a.value())});a.show();h.refresh()},destroy:function(){h.destroy();g.destroy();k.clear()}}},stub:function(a,b){return{elements:[],layouts:[],events:H.create({selected:r([])}).registry,refresh:t,destroy:t}}},NX={widget:function(a,b){var c=a.content(),d=a.undo(),e=a.selections(),f=a.smartview().uiContainer(),h=EX(c,f,b),g=H.create({color:Q(["value"],h.events.color),highlight:Q(["value"],h.events.highlight),
  done:r([]),abort:Q([],h.events.abort)});h.events.color.bind(function(a){g.trigger.done();Sf.foreground(c,d,e,a.value());c.toEditing()});h.events.highlight.bind(function(a){g.trigger.done();Sf.background(c,d,e,a.value());c.toEditing()});h.events.menuDone.bind(function(){return g.trigger.done()});return{element:h.element,name:k("color"),textkey:k(x.key("font.coloroption")),menuTextkey:k(x.key("aria.color.menu")),open:h.open,close:h.close,updateWidget:function(b){kj.isHighContrast(a.smartview())?b.disable():
  h.open()},ability:t,destroy:h.destroy,events:g.registry,label:k(!1)}}},HX=Aa(["i18nNamespace","cssNamespace","property","tag","specials"],[]),LX={widget:function(a,b){b=Lq.cata(b,k(t),k(function(a){a.initLayout()}));var c=a.content(),d=a.undo(),e=Em(ym.configuration());b(e);var f=H.create({done:r([]),abort:Q([],e.events.abort)});e.events.close.bind(function(a){f.trigger.done()});e.events.action.bind(function(b){var e=Z.active();c.focus();Sf.size(c,d,a.selections(),b.value());e.each(Z.focus)});return{element:e.element,
  item:e.item,name:k("size"),textkey:k(x.key("font.size")),open:e.open,close:e.close,updateInlineWidget:function(){var b=Am.getState(a.selections(),c);e.updateInlineWidget(b.readState,b.fallbackSize)},ability:t,destroy:e.destroy,events:f.registry}}},KX={widget:function(a,b){var c=a.content(),d=a.smartview().uiContainer();b=a.ui().tabstrip.element;var e=a.undo(),f=Em(ym.configuration()),h=f.input(),g=pm(b());m.set(h,"disabled","true");var q=K.bind(h,"touchstart",function(b){b.kill();g.closeMenus();var f=
  IX(c,d,u(Em,ym.configuration()));f.show();b=f.contents;var h=Am.getState(a.selections(),c),k=function(){f.destroy();c.cursorIntoView()};b.updateInlineWidget(h.readState,h.fallbackSize);b.events.close.bind(k);b.events.action.bind(function(b){Sf.size(c,e,a.selections(),b.value())});f.events.close.bind(f.destroy);f.events.ok.bind(function(b){Sf.size(c,e,a.selections(),b.value());k()})}),n=H.create({done:r([]),abort:Q([],f.events.abort)});f.events.close.bind(function(a){n.trigger.done()});f.events.action.bind(function(b){Sf.size(c,
  e,a.selections(),b.value())});return{element:f.element,item:f.item,name:k("size"),textkey:k(x.key("font.size")),open:f.open,close:f.close,updateInlineWidget:function(){var b=Am.getState(a.selections(),c);f.updateInlineWidget(b.readState,b.fallbackSize)},ability:t,destroy:function(){q.unbind();f.destroy()},events:n.registry}}},MX={face:function(a){return $b.toSelection(a.get()).map(function(a){a=U(["td","th"],D.name(a.startContainer()))?kb.freefallLtr(a.startContainer()).element():a.startContainer();
  a=uj.value(a,"font-family");return xf.isEmpty(a)?Da.off():Da.on(a)}).getOrThunk(Da.unchanged)}},PX=function(a){var b=a.baseUrl;!0===a.source&&(b+="/licenses");return b+"/textbox-licenses.html"},Bl=function(a,b){return a.map(function(a){return a.bind(function(a){var c=a[b];return void 0===c?J.error("Cannot find method "+b+" in help article list: "+cb(a)):qb(c)?J.value(c()):J.error("Key "+b+" in help article list was not a function")})})},RX=function(a){a=en.addScript(a,ca);a.get(function(a){a.each(function(a){Uf.weakMatch(a.version,
  "Help articles").each(function(a){console.warn(a)})})});return{about:Bl(a,"about"),accessibility:Bl(a,"accessibility"),a11ycheck:Bl(a,"a11ycheck"),markdown:Bl(a,"markdown"),shortcuts:Bl(a,"shortcuts")}},Kj=function(a,b){return a?g.some(b):g.none()},TX=function(a){var b={item:k(".ephox-pastry-statebutton.ephox-pastry-tablayout-item")},c=Ba.flow({trigger:Kb.button,executeOnArrow:!0});return ha.flow(a.menu(),b,c)},UX=function(a){var b={stops:k(["a"])},c=Ba.page({trigger:Kb.click,first:".ephox-pastry-tablayout-active"});
  return ha.page(a.body(),b,c)},YX=O("prefix","suffix","style"),wA={rehighlight:function(a,b,c){var d=A.children(c),e=E(d,function(a){return D.isText(a)?Ya.get(a):""}).join("");qa(b,function(a){return Gb(e,a.prefix())&&je(e,a.suffix())}).fold(function(){a.preserve(function(){F.unwrap(c)})},function(b){var e=p.fromTag("span");ma.add(e,[rf.highlightClass()]);v.setAll(e,b.style());a.preserve(function(){y.before(c,e);P.append(e,d);F.remove(c)})})},unhighlight:function(a,b){var c=A.children(b),d=p.fromTag("span");
  ma.add(d,[rf.placeholderClass()]);a.preserve(function(){y.before(b,d);F.unwrap(b);P.append(d,c)})}},aja=function(a,b){b=E(b,function(a){var b=Cb.sanitise(a.prefix()),c=Cb.sanitise(a.suffix());b=Cb.unsafetoken(b+"[^"+c+"]*"+c);return{pattern:k(b),style:a.style}});return Ko.findmany(a,b)},bja=gr("."+rf.highlightClass(),Ta.unwrap),ZX={run:function(a,b){a.body().each(function(a){om.filterDom(a,[bja]);a=cd.descendants(a,D.isText);z(a,function(a){var c=Ya.get(a);c=aja(c,b);var d=ia(c,function(a){return[a.start(),
  a.finish()]}),h=ti.subdivide(a,d);z(c,function(a){var b=Rd.sublist(h,a.start(),a.finish());b=E(b,function(a){return a.element()});wi.wrapper(b,function(){var b=p.fromTag("span");ma.add(b,[rf.highlightClass()]);v.setAll(b,a.style());return wi.nu(b)})})})})}},ix=B.resolve("input-invalid-field"),cja=function(a){return parseInt(a,10).toString()===a&&0<=parseInt(a,10)},VP=function(a,b,c){var d=fa.get(a);if(""===d)return J.value("");var e=p.fromTag("img");c=cja(d)?d+c.getOr(""):d;v.set(e,b,c);c=v.getRaw(e,
  b);v.remove(e,b);return c.fold(function(){return J.error(a)},J.value)},WP=function(a){n.remove(a,ix)},Lc={highlight:function(a){ib.shout(a,x.translate("aria.input.invalid"));n.add(a,ix)},dehighlight:WP,clearHighlights:function(a){a=Y.descendants(a,"."+ix);z(a,WP)},validate:function(a){return Eb(a,function(a,c){return a.bind(function(a){return VP(c.input(),c.property(),c.defaultUnit()).map(function(b){fa.set(c.input(),b);var d={};d[c.property()]=k(b);return oa(d,a)})})},J.value({}))},validateField:VP,
  rule:O("input","property","defaultUnit")},dja=O("size","unit"),bq=function(a){return Fp.identify(a).fold(g.none,function(a,c,d){return g.some(dja(c,d))})},sr={fromHeight:function(a,b){return bq(b).map(function(b){return Math.ceil(a*b.size())+b.unit()})},fromWidth:function(a,b){return bq(b).map(function(b){return Math.ceil(1/a*b.size())+b.unit()})},calculate:function(a,b){return bq(a).fold(g.none,function(a){return bq(b).fold(g.none,function(b){return g.some((a.size()+0)/(b.size()+0))})})}},eja=aa.detect(),
  XP=O("value","text","attrs"),YP=function(a){return"img"===D.name(a)},ZP=function(a){return 0===a.length?Jb:function(b){return vc.allowedForEditing(b,a)}},yA={image:function(a){var b=ZP(a.imageExcludes),c=g.none(),d=H.create({properties:r(["image"]),contextmenu:r(["image"])});return{situation:function(a){a=c.map(function(a){return[XP("imagemenu-properties",x.translate("image.context.properties"),{})]}).getOr([]);return{primary:k(a),secondary:k([]),submenus:k([])}},handle:function(a){c.each(function(a){d.trigger.properties(a)})},
  assign:function(e){c=e.filter(YP).filter(b);c.each(function(b){eja.browser.isFirefox()||ie.select(a,b);d.trigger.contextmenu(b)})},events:d.registry}},imageEdit:function(a,b,c,d){var e=ZP(d),f=g.none(),h=function(a){return E(a,function(a){return XP(a.spec.value,x.get(a.spec.textkey),{})})};return{situation:function(a){a=f.map(h).getOr([]);return{primary:k(a),secondary:k([]),submenus:k([])}},handle:function(a){f.each(function(b){var c=m.get(a,"data-ephox-gopher-item-value");qa(b,function(a){return a.spec.value===
  c}).each(function(a){a.spec.action()})})},assign:function(d){f=a()?g.some(b):d.filter(YP).filter(e).map(k(c))}}}},zA={generate:function(a,b,c){a=function(){e();d.trigger.close()};var d=H.create({ok:Q(c,b.events.ok),close:r([])});b.events.close.bind(a);var e=function(){b.destroy()};return{open:function(){b.open()},hide:a,destroy:e,represent:b.represent,events:d.registry}}},$P=ta.generate([{html:["key","value"]},{css:["key","value"]}]),aQ=function(a,b){return Qb(Lf(a,function(a,d){var c=[];if(m.has(b,
  d)){var f=m.get(b,d);c.push($P.html(a,f))}v.getRaw(b,d).each(function(b){c.push($P.css(a,b))});return c}))},fja=function(a){v.remove(a,"width");v.remove(a,"height");m.remove(a,"width");m.remove(a,"height")},gja=u(aQ,{width:"width",height:"height"}),hja=u(aQ,{width:"height",height:"width"}),bQ=k([]),sf={keepCrop:bQ,keepFlip:gja,keepRotate:hja,keepResample:bQ,updater:function(a,b){var c=a(b);return Ua.effect(function(){fja(b);z(c,function(a){a.fold(function(a,c){m.set(b,a,c)},function(a,c){v.set(b,
  a,c)})})})}},ija={strictMode:!1,key:"source protocol authority userInfo user password host port relative path directory file query anchor".split(" "),q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}},
  jja=function(a,b){a=b.parser[b.strictMode?"strict":"loose"].exec(a);for(var c={},d=14;d--;)c[b.key[d]]=a[d]||"";c[b.q.name]={};c[b.key[12]].replace(b.q.parser,function(a,d,h){d&&(c[b.q.name][d]=h)});return c},Sh={parse:function(a,b){b=ua(ija,b);return jja(a,b)}},cQ=function(a){return""!==a.trim()&&!Bb(a,"://")},tr={local:function(a){return Gb(a,"data:")||Gb(a,"blob:")||Gb(a,"file:")},relative:cQ,sameDomain:function(a,b){if(""===a.trim()||""===b.trim())return!1;if(cQ(a))return!0;b=Sh.parse(b);a=Sh.parse(a);
  return b.host===a.host&&b.port===a.port}},kja=O("bannerMessage","consoleMessage"),dQ=function(a){return qb(a.message)&&qb(a.status)&&qb(a.responseText)},eQ=function(a){if(dQ(a)){var b=a.responseText();return a.message()+". Response code "+a.status()+(0===b.length?".":". Error details: "+b)}return a},vr={diagnoseImageEdit:function(a,b){var c=18===a.code||"SecurityError"===a.name?"imageedit.needsproxy":dQ(a)&&0===a.status()?"imageedit.proxyerror":"imageedit.generic",d=Sh.parse(b);b=""===d.host||tr.relative(b)?
  b:""===d.port?d.host:d.host+":"+d.port;c=mf.get(c,[b]);return kja(c,eQ(a))},consoleMessage:eQ},Ph={make:function(a,b,c){return{type:"general",spec:{value:a,textkey:x.key(b),action:c,updateGeneral:t,icon:!0,hasPopup:!1,toggle:!1,tooltip:rb.get}}}},lja=k(4),ub={resolve:Lb.create("ephox-clipper").resolve,CORNER_SIZE:lja},mja=function(a,b){a={left:"0px",top:"0px",width:a.width()+"px",height:a.height()+"px"};b={left:v.get(b,"left"),top:v.get(b,"top"),width:v.get(b,"width"),height:v.get(b,"height")};return{outside:k(a),
  inside:k(b)}},nja={snap:function(a,b){var c=mja(a,b),d=p.fromTag("div");n.add(d,ub.resolve("dynamic-box"));v.setAll(d,c.outside());var e=p.fromTag("div");n.add(e,ub.resolve("opaque-box"));v.setAll(e,c.outside());var f=function(a,b){return 2<Math.abs(parseInt(a,10)-parseInt(b,10))},h=function(a){return Ea.nu(function(b){b(a)})},g=function(a,b){return Ea.nu(function(c){var d=K.bind(a,"transitionend",function(){d.unbind();c(a)});v.setAll(a,b.inside())})};return{prepare:function(a,c,f){var h=m.get(c,
  "src"),g=v.get(c,"width");c=v.get(c,"height");v.setAll(b,{"background-image":"url("+h+")","background-size":g+" "+c,"background-position-x":-f.left()+"px","background-position-y":-f.top()+"px"});n.add(b,ub.resolve("snapshot"));n.add(d,ub.resolve("dynamic-box-animate"));P.append(a,[d,e]);v.reflow(a)},showcase:function(){var a=c.outside(),b=c.inside();return f(a.left,b.left)||f(a.top,b.top)||f(a.right,b.right)||f(a.bottom,b.bottom)?g(d,c):h(d)}}}},qY={slide:function(){return{animate:function(a,b,c,
  d){c=nja.snap(c.box(),c.shade());c.prepare(a,b,{left:d.cropX,top:d.cropY,width:d.cropWidth,height:d.cropHeight});return c.showcase().map(k(d))}}},none:function(){return{animate:function(a,b,c,d){return Ea.pure(d)}}}},oY=Aa("displayWidth displayHeight cropX cropY cropWidth cropHeight".split(" "),[]),lY={bind:function(a,b){return K.bind(a,"mousedown",function(a){a.kill();var c=a.target(),e=!1,f=K.bind(c,"mouseup",function(){e=!0;f.unbind()});setTimeout(function(){e||(f.unbind(),b(c))},250)})}},oja=
  Aa(["top","left","width","height"],[]),pja=Aa(["top","left"],[]),qja=Aa(["top","left"],[]),Fb={boxModel:oja,delta:pja,cornersMovements:qja},jx=function(a,b){b=Math.min(a.top()+a.height(),Math.max(0,a.top()+b.top()));var c=b-a.top();a=a.height()-c;return{top:b,height:a}},kx=function(a,b,c){a=Math.min(a.width(),Math.max(b.left(),b.left()+b.width()+c.left()))-b.left()-b.width();return{width:b.width()+a}},lx=function(a,b,c){return Math.min(a.height(),Math.max(b.top(),b.top()+c.top()+b.height()))-b.top()},
  mx=function(a,b){b=Math.min(a.width()+a.left(),Math.max(0,a.left()+b.left()));var c=b-a.left();a=a.width()-c;return{left:b,width:a}},Jm={nw:function(a,b,c){a=jx(b,c);b=mx(b,c);return Fb.boxModel({left:b.left,width:b.width,top:a.top,height:a.height})},n:function(a,b,c){a=jx(b,c);return Fb.boxModel({left:b.left(),width:b.width(),top:a.top,height:a.height})},ne:function(a,b,c){var d=jx(b,c);a=kx(a,b,c);return Fb.boxModel({left:b.left(),width:a.width,top:d.top,height:d.height})},e:function(a,b,c){a=kx(a,
  b,c);return Fb.boxModel({left:b.left(),width:a.width,top:b.top(),height:b.height()})},se:function(a,b,c){var d=kx(a,b,c);a=lx(a,b,c);return Fb.boxModel({left:b.left(),width:d.width,top:b.top(),height:a})},s:function(a,b,c){a=lx(a,b,c);return Fb.boxModel({left:b.left(),width:b.width(),top:b.top(),height:a})},sw:function(a,b,c){a=lx(a,b,c);c=mx(b,c);return Fb.boxModel({left:c.left,width:c.width,top:b.top(),height:a})},w:function(a,b,c){a=mx(b,c);return Fb.boxModel({left:a.left,width:a.width,top:b.top(),
  height:b.height()})},translate:function(a,b,c){var d=Math.min(Math.max(0,b.top()+c.top()),Math.max(0,a.height()-b.height()));a=Math.min(Math.max(0,b.left()+c.left()),Math.max(0,a.width()-b.width()));return Fb.boxModel({top:d,left:a,width:b.width(),height:b.height()})}},Mj={navigation:function(a,b){var c=function(a,c,f){return function(){b(a,Qa(c,f));return g.some(!0)}};return[ea.rule(ea.and([ea.isShift,ea.inSet(R.LEFT())]),c(a,-1,0)),ea.rule(ea.and([ea.isShift,ea.inSet(R.RIGHT())]),c(a,1,0)),ea.rule(ea.and([ea.isShift,
  ea.inSet(R.UP())]),c(a,0,-1)),ea.rule(ea.and([ea.isShift,ea.inSet(R.DOWN())]),c(a,0,1)),ea.basic(R.LEFT()[0],c(a,-10,0)),ea.basic(R.RIGHT()[0],c(a,10,0)),ea.basic(R.UP()[0],c(a,0,-10)),ea.basic(R.DOWN()[0],c(a,0,10))]}},fQ=function(a,b,c){var d=b.top(),e=b.left()+b.width()/2-c.middle(),f=d+b.height()/2-c.middle(),h=b.left()+b.width()-c.right();a=b.left()-c.left();c=d+b.height()-c.bottom();b=Fb.cornersMovements({top:d,left:e});e=Fb.cornersMovements({top:c,left:e});var g=Fb.cornersMovements({top:f,
  left:h});f=Fb.cornersMovements({top:f,left:a});var m=Fb.cornersMovements({top:d,left:a});d=Fb.cornersMovements({top:d,left:h});h=Fb.cornersMovements({top:c,left:h});a=Fb.cornersMovements({top:c,left:a});return{n:k(b),s:k(e),e:k(g),w:k(f),nw:k(m),ne:k(d),se:k(h),sw:k(a)}},AA={calculate:function(a,b){var c={middle:k(2*ub.CORNER_SIZE()+1),right:k(ub.CORNER_SIZE()),left:k(0),bottom:k(ub.CORNER_SIZE())};return fQ(a,b,c)},limitBounds:function(a,b){var c={};if(20>b.width()){var d=20-b.width();c.width=b.width()+
  d;c.left=b.left()===a.left()?a.left():b.left()-d}20>b.height()&&(d=20-b.height(),c.height=b.height()+d,c.top=b.top()===a.top()?a.top():b.top()-d);return ua(b,eb(c,k))},doCalculate:fQ},nx=function(a){return Fb.boxModel({left:parseInt(m.get(a,"data-"+ub.resolve("image-left")),10),top:parseInt(m.get(a,"data-"+ub.resolve("image-top")),10),width:parseInt(m.get(a,"data-"+ub.resolve("image-width")),10),height:parseInt(m.get(a,"data-"+ub.resolve("image-height")),10)})},gQ=function(a,b){m.set(a,"data-"+ub.resolve("image-left"),
  b.left());m.set(a,"data-"+ub.resolve("image-top"),b.top());m.set(a,"data-"+ub.resolve("image-width"),b.width());m.set(a,"data-"+ub.resolve("image-height"),b.height())},Ug={readPosition:nx,writePosition:gQ,updatePosition:function(a,b){var c=nx(a);b=b(c);c=AA.limitBounds(c,b);gQ(a,c);return c},drawAtOrigin:function(a){var b=nx(a);v.setAll(a,{left:b.left()+"px",top:b.top()+"px",width:b.width()+"px",height:b.height()+"px"})}},rja=ub.resolve("magic-box"),CA={magicBox:k(rja)},Im={grab:function(a,b){m.set(a,
  "aria-grabbed",b)},effect:function(a,b){m.set(a,"aria-dropeffect",b)}},sja=O("help","ids"),hQ=function(a){m.set(a,"role","gridcell")},Vg={base:function(a,b){m.setAll(a,{role:"grid","aria-label":b})},row:function(a){m.set(a,"role","row")},cell:function(a,b){hQ(a);m.set(a,"aria-label",b)},gridcell:hQ,createHelp:function(a,b,c){var d=p.fromTag("div");S.presentation(d);n.add(d,lk.resolve("aria-help"));for(var e=[],f=0;f<b;f++){var h=Fa("ephox-aria"),g=p.fromTag("span");S.presentation(g);m.set(g,"id",
  h);n.add(g,lk.resolve("aria-help"));y.append(g,p.fromText(c.col(f+1)));y.append(d,g);e[f]=h}f=[];for(h=0;h<a;h++){g=Fa("ephox-aria");var k=p.fromTag("span");S.presentation(k);m.set(k,"id",g);n.add(k,lk.resolve("aria-help"));y.append(k,p.fromText(c.row(h+1)));y.append(d,k);f[h]=[];for(k=0;k<b;k++)f[h][k]=e[k]+" "+g}return sja(d,f)}},Wf=function(a,b,c){var d=p.fromTag("div");v.set(d,"position","absolute");var e=p.fromTag("div");y.append(d,e);c.each(function(a){Vg.cell(d,a);Im.grab(d,!1)});ma.add(d,
  [ub.resolve("corner-wrapper"),ub.resolve("corner-wrapper-"+b)]);ma.add(e,[ub.resolve("corner-element"),ub.resolve("corner-"+a)]);m.set(d,"data-"+ub.resolve("direction"),b);return d},Xf=function(a,b){v.setAll(a,{top:b.top()+"px",left:b.left()+"px"})},BA=function(a,b,c){var d=b()<c()?0:1;z(a,function(a){v.set(a,"opacity",String(d))})},hY={derive:function(a,b){return{leftRim:function(){var c=b.left(),d=a.height();return Fb.boxModel({top:0,left:0,width:c,height:d})},topRim:function(){var c=b.left(),d=
  a.width()-b.left(),e=b.top();return Fb.boxModel({top:0,left:c,width:d,height:e})},rightRim:function(){return Fb.boxModel({top:b.top(),left:b.left()+b.width(),width:a.width()-b.width()-b.left(),height:a.height()-b.top()})},bottomRim:function(){return Fb.boxModel({top:b.top()+b.height(),left:b.left(),width:b.width(),height:a.height()-b.height()-b.top()})},shadeBox:k(b)}}},Gm=function(a){var b=p.fromTag("div");ma.add(b,[ub.resolve("panel-"+a),ub.resolve("side-panel")]);return b},Hm=function(a,b){v.setAll(a,
  {top:b.top()+"px",left:b.left()+"px",width:b.width()+"px",height:b.height()+"px"})},kY=function(a){var b=a.width();a=a.height();var c=Math.floor(.125*a),d=Math.floor(.125*b);return Fb.boxModel({top:c,left:d,width:b-2*d,height:a-2*c})},nY=function(a){var b=bb.absolute(a),c=b.top(),d=sa.get(a);b=b.left();a=Ga.get(a);return Fb.boxModel({top:c,left:b,width:a,height:d})},rY=function(a,b){vc.detect(a.getSelection()).fold(function(){a.setRelativeSelection(la.before(b),la.before(b))},function(b){a.setRelativeSelection(la.on(b.image(),
  0),la.on(b.image(),0))})},iQ=function(a,b,c,d){return a(function(a){var e=K.bind(b,c,function(b){rr(h);e.unbind();a(J.value(b))}),h=Sg(function(){e.unbind();a(J.error("Event "+c+" did not fire within "+d+"ms"))},d)})},tja={cWaitFor:function(a,b,c){return iQ(lf.nu,a,b,c)},waitFor:function(a,b,c){return iQ(Ea.nu,a,b,c)}},uja=Ua.fToFR(Re.single),wr={run:function(a,b,c){return Ua.fromChain([a.getImage,b,uja,c])},applyEdit:function(a){return function(b){var c=Pc.cata(b,function(a,b,c){return c},function(a,
  b,c){return b});m.set(a,"src",c);b=Ua.pure(b);return a.dom().loaded?b:Ua.bind(tja.waitFor(a,"load",1E3),k(b))}}},vja=function(a){return 20<=a},ox=function(a){return g.from(a).filter(vja)},tY={ensureMin:ox,parse:function(a,b){a=ox(a).getOr(0);b=ox(b).getOr(0);return 0===a&&0===b?g.none():g.some(Ep(a,b))}},wY=function(a){return function(b){var c=b.image(),d=b.asset(),e=function(a){a.fold(function(){m.remove(c,"src")},function(a){Pc.cata(a,function(a,b,d){m.set(c,"src",d)},t)})};return op.loadIfNeeded(c).bind(function(){return a(d).map(function(a){e(a);
  return a})})}},uY=k(Ua.pure),vY=k(function(a){return Ua.pure(a.asset())}),DA={edit:function(a,b,c,d){return{items:d,updatePalette:function(d){if(c())d.hide(g.none())&&a();else{var e=u(d.show,g.some(x.translate("image.context.palette.show")));d=u(d.hide,g.some(x.translate("image.context.palette.hide")));(b().isSome()?e:d)()&&a()}}}},crop:function(a,b,c){return{items:c,updatePalette:function(c){(b()?c.show:c.hide)(g.none())&&a()}}}},jQ=function(a){var b=Gb(a,"www.")?"http://"+a:a;return{text:k(a),href:k(b)}},
  px={preprocess:jQ,auto:function(a){return jQ(a).href()}},kQ=function(a,b){a.setRelativeSelection(la.after(b),la.after(b))},wja=function(a,b,c,d){var e=a.getSelection();return vc.detect(e).fold(function(){return e.fold(function(){return[]},function(a){return(a.collapsed()?c:d)(a)})},function(a){return b(a.image())})},xja=function(a,b,c){var d=p.fromTag("a");cq(d,oa(b,{text:k(g.none())}));y.wrap(c,d);ie.select(a,c);return[d]},cq=function(a,b){b.url().each(function(b){b=px.auto(b);ri.attr(a,"href",b)});
  b.title().each(function(b){ri.attr(a,"title",b)});b.target().each(function(b){ri.attr(a,"target",b)});b.action().each(function(b){b(a)});return b.text().filter(b.textChanged).map(function(b){Vb.set(a,b);return!0}).getOr(!1)},yja=function(a){return function(b){return{link:b,properties:a}}},zja=function(a){return function(b){return{link:b,properties:oa(a,{text:k(g.some(Vb.get(b)))})}}},Aja=function(a){return function(b){var c=Tt.findDescendants(b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset(),
  "a");b=0<c.length?c:Tt.findAncestors(b.startContainer(),b.endContainer(),"a");return E(b,1===b.length?yja(a):zja(a))}},Bja=function(a,b){return wja(a,u(xja,a,b),function(c){var d=p.fromTag("a");cq(d,b);rd.insertAtCursor(a,[d]);b.action().each(function(a){a(d)});kQ(a,d);return[d]},function(c){a.execCommand("CreateLink",!1,px.auto(b.url().getOr("")));c=a.getSelection().map(Aja(b)).getOr([]);z(c,function(c){cq(c.link,c.properties);b.action().each(function(a){a(c.link)});kQ(a,c.link)});return E(c,function(a){return a.link})})},
  qx={hyperlink:function(a,b){var c=b.text().fold(k(b),function(a){return oa(b,{text:k(g.some(0<a.trim().length?a:b.url().getOr(""))),textChanged:0<a.trim().length?b.textChanged:k(!0)})});a.focus();return c.url().fold(k([]),function(b){return 0<b.trim().length?Bja(a,c):[]})},setProperties:cq},lQ=function(a,b){var c=wa.getEnd(b);a.setSelection(b,c,b,c)},mQ=function(a,b){a.setSelection(b,0,b,0)},nB={selectEnd:lQ,moveToEnd:function(a){a.getSelection().each(function(b){lQ(a,b.endContainer());a.focus()})},
  selectStart:mQ,moveToStart:function(a){a.getSelection().each(function(b){mQ(a,b.endContainer());a.focus()})}},nQ=function(a,b){return a.getSelection().bind(function(c){return Ld.sharedLinkOrClosest(c,a.isRoot).map(function(a){b(a);return a})})},Ar={insert:qx.hyperlink,update:function(a,b){return nQ(a,function(c){b.text().fold(function(){qx.setProperties(c,b)},function(d){""===d&&""!==Vb.get(c)?(a.setRelativeSelection(la.before(c),la.before(c)),F.remove(c)):qx.setProperties(c,b)&&(d=A.children(c).length,
  a.setRelativeSelection(la.on(c,d),la.on(c,d)))});a.focus()})},unlink:function(a){nQ(a,function(b){a.setSelection(b,0,b,A.children(b).length);var c=A.lastChild(b);F.unwrap(b);c.each(function(b){nB.selectEnd(a,b)});a.focus()})}},Cja=function(a){return a.getSelection().bind(function(b){return a.win().bind(function(a){var c=Kc.exact(b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset());return Wa.getFirstRect(a,c).map(function(a){a={left:a.left(),top:a.top(),right:a.right(),bottom:a.bottom(),
  width:a.width(),height:a.height()};return{bounds:k(a),element:k(b.startContainer())}})})})},oQ=function(a,b,c){Cja(b).fold(function(){Lz.insertAtCursor(a,b,c)},function(d){var e=d.bounds();d=d.element();(D.isText(d)?A.parent(d):g.some(d)).each(function(d){d=a.directionAt(d);var f=b.translateScreen(e.left,e.top);c({left:f.left,top:f.top,height:k(e.height),width:k(e.width),direction:k(d)})})})},pQ=function(a,b,c,d,e,f,h){var g=e.direction();a=Nm.makeshift(a,b,e.left(),e.top(),e.width(),e.height(),g,
  f,h);b.show(c,a);c.setComponents([d.element()])},zr={show:function(a,b,c,d,e){oQ(a,b,function(a){pQ(b,c,d,e,a,Fh(0,0))})},showExpandable:function(a,b,c,d,e){oQ(a,b,function(a){n.add(d.panel(),B.resolve("expandable-popup"));var f=Fh(22,14),g={maxHeightFunction:cf.expandable()};pQ(b,c,d,e,a,f,g)})}},rx=function(a,b,c){a=Nc(a);b=x.translate(b);a.content(Qc(b));n.add(a.element(),B.resolve(c));S.button(a.element(),b);return a},qQ=function(a){var b=T.div();n.add(b,B.resolve("main-controls"));P.append(b,
  a);return b},rQ=function(a,b,c){var d=rx("remove","link.dialog.remove","link-remove"),e=rx("cancel","button.cancel","link-cancel"),f=rx(a,b,c);a=H.create({remove:Q([],d.events.click),cancel:Q([],e.events.click),execute:Q([],f.events.click)});b=[ha.button(d.element(),Ba.button({execute:Kb.click})),ha.button(e.element(),Ba.button({execute:Kb.click})),ha.button(f.element(),Ba.button({execute:Kb.click}))];return{remove:d,cancel:e,execute:f,keylayouts:b,events:a.registry,destroy:function(){d.destroy();
  e.destroy();f.destroy()}}},IA={insert:function(){var a=rQ("insert","link.dialog.insert","link-insert"),b=qQ([a.cancel.element(),a.execute.element()]);a.remove.disable();ra.disable(a.remove.element());return{dialogTitle:k(x.key("link.dialog.aria.insert")),elements:k([a.remove.element(),b]),events:k(a.events),keylayouts:k(a.keylayouts),execute:a.execute,destroy:a.destroy}},update:function(){var a=rQ("update","link.dialog.update","link-update"),b=qQ([a.cancel.element(),a.execute.element()]);return{dialogTitle:k(x.key("link.dialog.aria.update")),
  elements:k([a.remove.element(),b]),events:k(a.events),keylayouts:k(a.keylayouts),execute:a.execute,destroy:a.destroy}}},sQ=B.resolve("link-validation-highlight"),tQ=B.resolve("link-validation-invalid"),uQ=B.resolve("link-validation-unknown"),vQ=k([sQ,tQ,uQ]),De={configure:function(a){z(vQ(),function(b){a.add(a.output(),b,Ta.removeClass(b));a.add(a.internal(),b,Ta.removeClass(b))})},allClasses:vQ,invalidLink:k(tQ),unknownLink:k(uQ),validationHighlight:k(sQ)},HA={enabled:function(a){var b=g.none(),
  c=O("value","text","attrs"),d=H.create({properties:r(["link"]),follow:r(["link"]),ignore:r(["link"]),remove:r(["link"])}),e={"linkmenu-properties":d.trigger.properties,"linkmenu-follow":d.trigger.follow,"linkmenu-ignore":d.trigger.ignore,"linkmenu-remove":d.trigger.remove};return{situation:function(a){a=b.map(function(a){var b=[c("linkmenu-properties",x.translate("link.context.edit"),{}),c("linkmenu-follow",x.translate("link.context.follow"),{}),c("linkmenu-remove",x.translate("link.context.remove"),
  {})];a=n.has(a,De.validationHighlight())?[c("linkmenu-ignore",x.translate("link.context.ignore"),{})]:[];return b.concat(a)}).getOr([]);return{primary:k(a),secondary:k([]),submenus:k([])}},handle:function(a){b.each(function(b){var c=m.get(a,"data-ephox-gopher-item-value");c=e[c];void 0!==c&&c(b)})},assign:function(c){b=c.bind(function(b){return L.closest(b,"a[href]",a.isRoot)})},events:d.registry}},disabled:function(){var a=Ig.noSituation(),b=H.create({properties:r(["link"])});return{situation:a,
  handle:t,assign:t,events:b.registry}}},dq=B.resolve("link-eph-cursor"),Dja=function(a){z(a,F.remove)},Eja=function(a,b){wQ("textbox-bookmark-top",a,y.prepend,b,sb.top())},Fja=function(a,b){wQ("textbox-bookmark-bottom",a,y.append,b,sb.bottom())},wQ=function(a,b,c,d,e){var f=hm.generate(a);z(b,function(a){m.set(a,"href","#"+f)});a=Y.children(d,"["+sb.bookmarkDataAttr()+'="'+e+'"]');z(a,F.remove);0<b.length&&(b=p.fromTag("span"),m.setAll(b,{id:f,style:"visibility: hidden;"}),m.set(b,sb.bookmarkDataAttr(),
  e),c(d,b))},Rh={configure:function(a){a.add(a.internal(),dq,Ta.remove);a.add(a.output(),dq,Ta.remove);a.addExcludedContext(["."+dq]);a.addSelector(a.input(),"["+sb.bookmarkDataAttr()+"]",Dja);a.addSelector(a.output(),"["+sb.bookmarkAnchorDataAttr()+'="'+sb.top()+'"]',Eja);a.addSelector(a.output(),"["+sb.bookmarkAnchorDataAttr()+'="'+sb.bottom()+'"]',Fja)},properties:Aa("url textChanged text title target action invalid".split(" "),[]),insertCursor:k(dq)},Nj=B.resolve("inline-popup-expanded"),Gja={setValue:function(a,
  b,c){a=a.dom();a.value=b;a.text=c}},xQ=function(a,b){a.dom().add(b.dom())},yr={getValue:function(a){var b=a.dom();a=b.selectedIndex;b=b.options[a];return void 0===b||-1===a?g.none():g.from(b.value)},add:xQ,addAll:function(a,b){z(b,function(b){xQ(a,b)})},setSelected:function(a,b){a.dom().selectedIndex=b}},yQ=[{value:"",i18nKey:"link.properties.target.none"},{value:"_blank",i18nKey:"link.properties.target.blank"},{value:"_top",i18nKey:"link.properties.target.top"},{value:"_self",i18nKey:"link.properties.target.self"},
  {value:"_parent",i18nKey:"link.properties.target.parent"}],CY={target:function(a){var b=Vc.common("select","target-container","link.properties.target.label"),c=E(yQ,function(a){var b=p.fromTag("option");Gja.setValue(b,a.value,x.translate(a.i18nKey));return b});yr.addAll(b.field(),c);var d=a.target().getOr("");a=Va(yQ,function(a){return a.value===d}).getOr(0);yr.setSelected(b.field(),a);return{element:b.element,input:b.field}}},BY=function(){var a=T.div();n.add(a,B.resolve("invalid-link-info"));var b=
  Vc.comboBox("href-url-value","link.properties.url.label",g.some(a));m.setAll(b.input(),{placeholder:x.translate("link.properties.url.placeholder"),autocomplete:"off",autocorrect:"off"});var c=n.toggler(b.element(),B.resolve("link-is-invalid"));return{input:b.input,element:b.element,dropArrow:b.dropArrow,showInvalid:function(){c.on();var d=T.span();ma.add(d,[B.resolve("icon"),B.resolve("invalid-link-icon")]);y.append(a,d);var e=x.translate("link.properties.url.invalid");m.set(d,"title",e);d=ib.describe(b.input(),
  e);m.set(d,"aria-live","assertive");y.append(a,d)},hideInvalid:function(){c.off();F.empty(a);m.remove(b.input(),"aria-describedby")}}},GY=function(a){var b={};z(a,function(a){b[a]={}});return cb(b)},Oj={url:function(a){return g.some(a.url())},title:function(a){return a.title()},innerText:function(a){a=a.innerText();return 0<a.length?g.some(a):g.none()}},Ec={resolve:Lb.create("ephox-tarot").resolve},zQ=function(a,b,c,d,e){var f=p.fromText(a.substr(0,b));b=p.fromText(a.substr(b,c));a=p.fromText(a.substr(d));
  e=p.fromTag(e);y.append(e,b);return[f,e,a]},AQ=function(a,b,c,d){var e=T.tag(b);P.append(e,c);d.each(function(a){n.add(e,a)});return{item:k(a),marked:k(g.some(e))}},BQ=function(a,b,c,d){var e=a.text,f=a.marker.start(),h=a.marker.length(),k=0;0<d-(f+h)||0===f||(k=h>d?f-10:f-Math.floor((d-h)/2));d=e.substr(k);f-=k;b=zQ(d,f,h,f+h,b);e=d.length===e.length?g.none():g.some(Ec.resolve("anchor-before"));return AQ(a.item(),c,b,e)},sx=function(a,b){var c=T.span();n.add(c,b);P.append(c,a);return c},CQ=function(a,
  b,c){var d=[];b=sx(b,Ec.resolve("content-innertext"));0<a.length&&(a=sx([p.fromText(a)],Ec.resolve("anchor-before")),d.push(a));d.push(b);0<c.length&&(c=sx([p.fromText(c)],Ec.resolve("anchor-after")),d.push(c));return d},tx={contentMarker:function(a,b,c,d){var e=a.item().before(),f=a.item().after(),h=a.text;if(0===e.length&&0===f.length&&h.length>d)return BQ(a,b,c,d);d=a.marker.start();var k=a.marker.length();b=zQ(h,d,k,d+k,b);e=CQ(e,b,f);return AQ(a.item(),c,e,g.none())},contentUnderlined:CQ,attrMarker:BQ},
  DQ=function(a,b,c){a=T.tag(b);y.append(a,p.fromText(c));return a},FA={anchors:function(a,b){var c=b.item(),d=c.url(),e=T.div();n.add(e,Ec.resolve("item-line"));var f=c.title().getOr(d);m.set(e,"title",f);b=b.marked().fold(function(){return DQ(a,"div",f)},function(a){return a});n.add(b,Ec.resolve("item-main-label"));d=g.from(d).map(function(b){return b!==f?(b=DQ(a,"div",b),n.add(b,Ec.resolve("item-secondary-label")),[b]):[]}).getOr([]);d=[b].concat(d);P.append(e,d);return e},standard:function(a,b){var c=
  b.item();a=T.div();n.add(a,Ec.resolve("item-line"));n.add(a,Ec.resolve("bookmark-icon"));var d=[c.before(),c.innerText(),c.after()].join("");m.set(a,"title",d);b=b.marked().fold(function(){var a=tx.contentUnderlined(c.before(),[p.fromText(c.innerText())],c.after()),b=T.div();P.append(b,a);return b},function(a){return a});n.add(b,Ec.resolve("item-main-label"));c.indent()&&n.add(b,Ec.resolve("indent"));y.append(a,b);return a},error:function(a,b){a=T.span();b=p.fromText(b);y.append(a,b);return a}},Hja=
  O("matchFunction","start","length"),Ija=function(a,b,c){for(var d=0,e=[],f=function(a){e.push(a);d++},h=0,g=a.length;h<g&&d<b;h++)c(a[h]).each(f);return e},ux={unmarked:function(a,b){b=b.getOr(1E3);a=a.length>b?a.slice(0,b):a;return E(a,function(a){return{item:k(a),marked:g.none}})},match:function(a,b,c,d){var e=c.toLowerCase();c=d.getOr(1E3);return Ija(a,c,function(a){return yc(b,function(b){return b(a).bind(function(c){var d=c.toLowerCase().indexOf(e);if(-1<d){var f=e.length;return g.some({item:k(a),
  marked:g.none,text:c,marker:Hja(b,d,f)})}return g.none()})})})},mark:function(a,b,c,d){return E(a,function(a){return(a.marker.matchFunction()===Oj.innerText?tx.contentMarker:tx.attrMarker)(a,b,c,d)})}},EQ="data"+Ec.resolve("section-id"),vx={create:function(a,b){var c=p.fromTag("ol");m.set(c,EQ,b.id());var d=function(){F.empty(c)};return{element:k(c),clear:d,add:function(a){var b=p.fromTag("li");y.append(b,a);y.append(c,b);return b},spec:k(b),destroy:function(){d()}}},dataIdAttribute:k(EQ)},Jja=Aa(["container",
  "sections","translate"],["doc"]),Kja=Aa("id highlight contentLimit items render extractors".split(" "),["itemLimit"]),wx="data"+Ec.resolve("item-id"),Lm={init:function(a,b){var c=b.doc().getOr(p.fromDom(document)),d=b.translate(),e={},f=Cj(),h=T.div();n.add(h,Ec.resolve("predictive-menu"));S.hidden(h,!0);var l=EY(a,h),q=function(){z(f.state(),function(a){u(a,[])})},u=function(a,b){F.remove(a.element());a.clear();var d={};0<b.length&&(z(b,function(b){var e=a.spec().render()(c,b);e=a.add(e);var f=Fa("");
  m.set(e,wx,f);d[f]={gui:k(e),item:k(b.item())}}),y.append(h,a.element()));e[a.spec().id()]=d},w=function(){return A.parent(h).isSome()},v=function(a){n.add(a,Ec.resolve("selected"));J().bind(P).each(function(a){ib.speak(ja.body(),a.item().url())})},x=function(a){v(a);Za.intoViewIfNeeded(a,h)},B=function(a){n.remove(a,Ec.resolve("selected"))},D=function(){L.descendant(h,"li").each(x)},E=function(){Ia.one("ol:last-child li:last-child",h).each(x)},J=function(){return L.descendant(h,"li."+Ec.resolve("selected"))},
  M=function(){return J().bind(P).map(function(a){a=a.item();ib.speak(ja.body(),d("link.dialog.autocomplete.accept",a.url()));return a})},N=function(a){0===A.children(a).length?A.nextSibling(a).fold(D,N):A.firstChild(a).fold(E,x)},O=function(a){0===A.children(a).length?A.prevSibling(a).fold(E,O):A.lastChild(a).fold(D,x)},P=function(a){a=L.closest(a,"["+wx+"]");var b=a.bind(function(a){return L.closest(a,"["+vx.dataIdAttribute()+"]")}),c=a.map(function(a){return m.get(a,wx)});return b.map(function(a){return m.get(a,
  vx.dataIdAttribute())}).bind(function(a){return g.from(e[a])}).bind(function(a){return c.bind(function(b){return g.from(a[b])})})},Q=K.capture(h,"mouseover",function(a){a=a.target();Db.closest(a,"li."+Ec.resolve("selected"))||P(a).fold(t,function(a){J().each(function(a){B(a)});v(a.gui())})}),R=K.capture(h,"click",function(a){M().each(U.trigger.click)}),U=H.create({click:r(["item"])}),W=eh(fh,["url","indent"]);z(b.sections(),function(a){z(a.items(),W);a=vx.create(c,a);f.push(a)});q();return{element:k(h),
  events:U.registry,reset:q,resetFull:function(){z(f.state(),function(a){a.clear();var b=a.spec().items(),c=a.spec().itemLimit();b=ux.unmarked(b,c);u(a,b)})},filter:function(a){0<a.length?(e={},z(f.state(),function(b){var c=b.spec(),d=ux.match(c.items(),c.extractors(),a,c.itemLimit());c=ux.mark(d,c.highlight(),"div",c.contentLimit());u(b,c)})):q()},show:function(a){var c=b.container();y.append(c,h);l.position(a,Lh.relativeOrigin(c));ib.speak(ja.body(),d("link.dialog.autocomplete.open"))},isShowing:w,
  hide:function(){w()&&ib.speak(ja.body(),d("link.dialog.autocomplete.close"));F.remove(h);J().each(B)},getSelectedData:M,moveup:function(){J().fold(E,function(a){B(a);A.prevSibling(a).fold(function(){A.parent(a).bind(A.prevSibling).fold(E,O)},x)})},movedown:function(){J().fold(D,function(a){B(a);A.nextSibling(a).fold(function(){A.parent(a).bind(A.nextSibling).fold(D,N)},x)})},destroy:function(){Q.unbind();R.unbind();z(f,function(a){a.destroy()});F.remove(h)}}},config:Jja,section:Kja},IY=aa.detect().browser.isSafari(),
  xr=O("url","indent","action","before","innerText","after"),HY=O("url","indent","title","action"),GA=O("url","action"),EA=O("url","indent","action"),xx=ta.generate([{invalid:["invalidUrl"]},{unknown:["unknownUrl"]},{valid:["validUrl"]}]),KA={cata:function(a,b,c,d){return a.fold(b,c,d)},derive:function(a,b){return"VALID"===b?xx.valid(a):"INVALID"===b?xx.invalid(a):xx.unknown(a)}},FQ=[za("url"),da("fresh",!1)],Lja=Cc(FQ),Mja=Cc([Dc("urls","urls",qg(),Iaa(FQ))]),JA={one:k(Lja),many:k(Mja)},Nja={recompose:function(a){var b=
  "";""!==a.protocol&&(b+=a.protocol,b+=":");""!==a.authority&&(b=b+"//"+a.authority);b+=a.path;""!==a.query&&(b=b+"?"+a.query);""!==a.anchor&&(b=b+"#"+a.anchor);return b}},eq={remove:function(a){for(var b="";""!==a;)if(Gb(a,"../"))a=fk(a,"../");else if(Gb(a,"./"))a=fk(a,"./");else if(Gb(a,"/./"))a="/"+fk(a,"/./");else if("/."===a)a="/";else if(Gb(a,"/../"))a="/"+fk(a,"/../"),b=gk(b,b.substring(b.lastIndexOf("/")));else if("/.."===a)a="/",b=gk(b,b.substring(b.lastIndexOf("/")));else if("."===a||".."===
  a)a="";else{var c=a.match(/(^\/?.*?)(\/|$)/)[1];a=fk(a,c);b+=c}return b}},Oja={merge:function(a,b,c){if(""!==c&&""===a)return"/"+b;c=a.substring(a.lastIndexOf("/")+1);return gk(a,c)+b}},Pja={transform:function(a,b){var c={strictMode:!0},d=Sh.parse(a,c);b=Sh.parse(b,c);c={};""!==b.protocol?(c.protocol=b.protocol,c.authority=b.authority,c.path=eq.remove(b.path),c.query=b.query):(""!==b.authority?(c.authority=b.authority,c.path=eq.remove(b.path),c.query=b.query):(""===b.path?(c.path=d.path,c.query=""!==
  b.query?b.query:d.query):(Gb(b.path,"/")?c.path=eq.remove(b.path):(c.path=Oja.merge(d.path,b.path,a.authority),c.path=eq.remove(c.path)),c.query=b.query),c.authority=d.authority),c.protocol=d.protocol);c.anchor=b.anchor;return c}},LA={resolve:function(a,b){a=Pja.transform(a,b);return Nja.recompose(a)}},RY=O("href","resolved"),TY={generate:function(a){var b={};z(a,function(a){var c=a.resolved();a=a.href();b.hasOwnProperty(c)?U(b[c],a)||b[c].push(a):b[c]=[a]});return b}},Qja={rules:[{current:Ca.backtrack,
  next:Ca.sidestep,fallback:g.none()},{current:Ca.sidestep,next:Ca.sidestep,fallback:g.some(Ca.backtrack)},{current:Ca.advance,next:Ca.sidestep,fallback:g.some(Ca.sidestep)}],inclusion:function(a,b,c){return!a.property().parent(c).exists(function(c){return a.eq(c,b.item())})}},Rja=Ca.walkers(),GQ=function(a,b,c,d){return Ca.walk(a,b,c,Rja.left(),d.rules).map(function(c){return a.property().isEmptyTag(c.item())||a.property().isBoundary(c.item())?[]:(d.inclusion(a,c,b)?[c.item()]:[]).concat(GQ(a,c.item(),
  c.mode(),d))}).getOr([])},HQ=function(a,b,c){a=GQ(b,c,Ca.sidestep,a);return jd(a).concat([c])},IQ={top:u(HQ,Qja),all:u(HQ,{rules:void 0,inclusion:function(a,b,c){return a.property().isText(b.item())}})},JQ=nb(),KQ={top:function(a){return IQ.top(JQ,a)},all:function(a){return IQ.all(JQ,a)}},Sja=function(a,b){b=Rd.generate(b,function(b,c){return a.property().isText(b)?g.some(W.range(b,c,c+a.property().getText(b).length)):g.none()});var c=Eb(b,function(b,c){return a.property().getText(c.element())+b},
  "");return{list:k(b),text:k(c)}},Tja=function(a,b,c,d){var e=Rd.find(b.list(),function(b){return a.eq(b.element(),c)}).map(function(a){return a.start()+d});return{list:b.list,text:b.text,cursor:k(e)}},Uja={from:function(a,b,c,d){b=Sja(a,b);return Tja(a,b,c,d)}},Vja=nb(),Wja={from:function(a,b,c){return Uja.from(Vja,a,b,c)}},$Y={get:function(a,b){var c=KQ.all(a),d=Wja.from(c,a,b);b=d.cursor().orThunk(function(){return D.isText(a)?g.none():g.some(d.text().length)});return{list:d.list,text:d.text,cursor:k(b)}}},
  LQ=function(a,b){return{patterns:function(){return[new RegExp("^("+a+")(.+)","gi")]},useCursor:ed,generate:function(a,d){a=p.fromTag(b,a.dom());P.append(a,d.clones());return Zd.species({elements:k([a]),cursor:g.none,dictation:g.none,notify:g.none})},derive:function(a){var b=a[1];return g.some({startIndex:k(a.index),finishIndex:k(a.index+b.length)})}}},Th={normal:function(a,b){a=Cb.sanitise(a);return LQ(a,b)},spaced:function(a,b){a=Cb.sanitise(a)+"\\s";return LQ(a,b)}},MQ=function(a,b){return Zd.species({elements:k([p.fromText(b.text())]),
  cursor:g.none,dictation:g.none,notify:g.none})},Xja=function(){return{patterns:function(){return[/([^.?!][.?!]\s+)([a-z][^\s]*)/g,/^()([a-z][^\s]*)/g]},useCursor:k(!0),generate:MQ,derive:function(a){var b=a.index,c=b+a[0].length;a=a[1]+ls(a[2]);return g.some({startIndex:k(b),finishIndex:k(c),text:k(a)})}}}(),Yja=function(){return{patterns:function(){return[/([A-Z][A-Z]+)([a-z]+)/g]},useCursor:k(!1),generate:MQ,derive:function(a){var b=a[2];b=ls(a[1].toLowerCase())+b.toLowerCase();var c=a.index;a=
  c+a[0].length;return g.some({startIndex:k(c),finishIndex:k(a),text:k(b)})}}}(),MA={capitalise:k(Xja),normalise:k(Yja)},YY={patterns:function(){return[Gn.autolink()]},useCursor:k(!0),generate:function(a,b){a=p.fromTag("a");m.set(a,"href",b.href());y.append(a,p.fromText(b.text()));return Zd.species({elements:k([a]),cursor:g.none,dictation:g.none,notify:u(g.some,[a])})},derive:function(a){var b=px.preprocess(a[1]),c=b.text();b=b.href();return-1<c.indexOf("@")?g.none():g.some({startIndex:k(a.index),finishIndex:k(a.index+
  c.length),text:k(c),href:k(b)})}},XY=k(function(a,b){return b}),Zja={cloneAfter:function(a,b,c){var d=b;return E(a,function(a){var b=Oc.deep(a);D.isText(a)&&N.eq(c.endContainer(),a)&&Ya.get(a).length>c.endOffset()&&Ya.set(b,Ya.get(b).substring(0,c.endOffset()));if(D.isText(b)&&0<d){var e=Ya.get(b);a=Math.min(e.length,d);e=e.substring(a);Ya.set(b,e);d-=a}return b})}},NQ={matcher:function(a,b,c){var d=function(a){return c.fold(function(){return a&&1<a.length},function(b){return a&&0<a.length&&a.index+
  a[0].length===b})};return yc(a,function(a){a:{if(!a.global)throw"Macro matching only works with global regexes: "+a;for(var c=a.exec(b);c;){if(d(c)){a=g.some(c);break a}c=a.exec(b)}a=g.none()}return a})}},$ja=function(a,b,c,d){b=Zja.cloneAfter(b,d.finishIndex(),c);var e=ua(d,{clones:k(b)});return{build:function(b){b=a.generate(b,e);return Zd.applicator({elements:b.elements,cursor:b.cursor,range:k(c),dictation:b.dictation,notify:b.notify})}}},aka=function(a,b,c){b=Rd.get(a,b);var d=Rd.get(a,c);return b.bind(function(a){return d.map(function(b){return{start:k(a),
  finish:k(b)}})})},bka=function(a,b){return b(a.start().element())&&b(a.finish().element())?g.some(a):g.none()},cka=function(a,b,c){return b.doc().bind(function(d){d=a.build(d);var e=d.elements();E(e,pg.doNotMerge);var f=Cz.handle(d.range());rd.insertAt(b,f,e);E(e,pg.clear);d.dictation().each(function(a){ib.shout(ja.body(),a())});d.notify().each(function(){c.input(e)});return d.cursor()})},OQ=function(a,b,c,d,e){return a.detect(b,c,d,e).map(function(a){return{execute:u(cka,a)}})},Cr={block:u(OQ,{detect:function(a,
  b,c,d){var e=b.patterns(),f=a.cursor().filter(b.useCursor);return NQ.matcher(e,a.text(),f).bind(b.derive).bind(function(a){var e=KQ.top(c);if(0<e.length){var f=$t(e[0],0,c,d);return g.some($ja(b,e,f,a))}return g.none()})}}),inline:u(OQ,{detect:function(a,b,c,d){c=b.patterns();d=a.cursor().filter(b.useCursor);return NQ.matcher(c,a.text(),d).bind(b.derive).bind(function(c){return aka(a.list(),c.startIndex(),c.finishIndex()).bind(function(a){return bka(a,b.allowed).map(function(a){var d=c.startIndex()-
  a.start().start(),e=c.finishIndex()-a.finish().start(),f=$t(a.start().element(),d,a.finish().element(),e);return{build:function(a){a=b.generate(a,c);return Zd.applicator({elements:a.elements,cursor:a.cursor,range:k(f),dictation:a.dictation,notify:a.notify})}}})})})}})},cZ=aa.detect().deviceType.isTouch(),OA=function(a){a.disable();ra.disable(a.element())},fZ=aa.detect().deviceType.isiOS(),dka=O("rawData","extra"),PA=function(a,b,c){if(Mb(b)&&Mb(c))return J.value(dka(b,c));console.error(a+" callback parameters were not both arrays",
  b,c);return J.error(a+" callback parameters were not both arrays")},Dr=function(a,b){if(ak.isPrototypeOf(b))return J.value(p.fromDom(b));console.error(a+" was not a DOM element",b);return J.error(a+" was not a DOM element")},sZ={configure:function(a){var b=[a.internal(),a.history(),a.output()];z(b,function(b){a.addSelector(b,"span.ephox-polish-incomplete-mention",Ta.unwrap)});a.addExcludedContext(["span.ephox-polish-incomplete-mention"])}},RA=B.resolve("no-results"),QA=B.resolve("loading-results"),
  Er=ta.generate([{none:["item"]},{extra:["value","item"]},{fetched:["userId","name","rawname","info","item"]}]),Fr=ta.generate([{nothing:[]},{refetch:["term"]},{open:["term"]}]),PQ=function(){return new RegExp(Cb.wordbreak(),"i")},eka=function(a,b,c){return uh.repeatLeft(a,c,function(a,b,c,h,g){return uh.previousChar(h,g).fold(function(){return b.kontinue()},function(a){return b.finish(a.ch())})}).fold(g.none,g.none,g.some)},fka=function(a,b,c,d){return 0<=d&&"@"===c.charAt(d)?a.finish(W.point(b,d)):
  a.abort()},gka=function(a,b,c,d){return a.finish(W.point(b,d))},hka=function(a){return g.some(W.point(a,wa.getEnd(a)))},TA={isValidMention:function(a,b){return eka(a,Ca.sidestep,b).fold(k(!0),function(a){return null===a.match(/[0-9a-zA-Z]/)})},scan:function(a,b){return uh.expandLeft(a,b,{regex:PQ,attempt:fka}).fold(g.none,g.none,g.some).bind(function(c){return uh.expandRight(a,b,{regex:PQ,attempt:gka}).fold(g.none,hka,g.some).map(function(a){return{start:c.element,soffset:c.offset,finish:a.element,
  foffset:a.offset}})})}},Zi=ta.generate([{none:[]},{bare:["text","start","soffset","finish","foffset"]},{incomplete:["text","element"]},{complete:["text","element"]}]),QQ=B.resolve("incomplete-mention"),ika=function(a,b){return TA.scan(a,b).map(function(a){return Zi.bare("",a.start(),a.soffset(),a.finish(),a.foffset())})},RQ=function(a){if(D.isText(a))return Ya.get(a);a=cd.descendants(a,D.isText);return E(a,Ya.get).join("")},SQ=function(a,b){return a.collapsed()?L.closest(a.startContainer(),b.hoverSelector()).fold(function(){return L.closest(a.startContainer(),
  "."+QQ).fold(function(){return ika(a.startContainer(),a.startOffset())},function(a){return g.some(Zi.incomplete(RQ(a),a))})},function(a){return g.some(Zi.complete(RQ(a),a))}).getOrThunk(Zi.none):Zi.none()},Uh={detect:function(a,b){return a.getSelection().map(function(a){return SQ(a,b)}).getOrThunk(Zi.none)},detectOn:SQ,withinIncomplete:function(a){return L.closest(a,"."+QQ)}},TQ=function(a){n.remove(a,B.resolve("incomplete-mention"));F.unwrap(a)},Hr={cancel:TQ,create:function(){var a=p.fromTag("span");
  n.add(a,B.resolve("incomplete-mention"));var b=p.fromText("@");y.append(a,b);return a},validatePrevious:function(a,b){Uh.withinIncomplete(a).filter(function(a){return Uh.withinIncomplete(b).forall(function(b){return!N.eq(a,b)})}).each(TQ)}},Gr="."+B.resolve("mentions-business-card"),pZ=function(a,b){return 1<arguments.length||/\{(\d+)\}/.test(a)?Gn.tokens.call(void 0,a,b):a},uZ=O("textkey","value","icon"),jka=function(){return{configure:function(a){var b=[a.internal(),a.history(),a.output(),a.paste()];
  z(b,function(b){a.addSelector(b,"[unselectable]",Ta.removeAttr("unselectable"))})},clean:function(a){m.remove(a,"unselectable")},disableNativeResize:function(a){m.set(a,"unselectable","on")}}},kka=function(){return{configure:t,clean:function(a){A.nextSibling(a).filter(se.isEmptyText).each(F.remove)},disableNativeResize:t}},UQ=aa.detect().browser,Ir=UQ.isIE()?jka():UQ.isFirefox()?kka():{configure:t,clean:t,disableNativeResize:t},lka=aa.detect().browser.isChrome(),VQ="data-"+B.resolve("resize-direction"),
  fq=function(a,b){var c=p.fromTag("span");ma.add(c,[B.resolve(a),B.resolve("resize-eph-resizer")]);m.set(c,VQ,b);return c},CZ={create:function(){var a=fq("element-se-resize","1"),b=fq("element-ne-resize","1"),c=fq("element-sw-resize","-1"),d=fq("element-nw-resize","-1"),e=p.fromTag("div");n.add(e,B.resolve("resize-wrapper"));P.append(e,[a,b,c,d]);var f=function(){F.remove(e)},h=H.create({click:r(["multiplier"])}),g=K.bind(e,"mousedown",function(a){n.has(a.target(),B.resolve("resize-eph-resizer"))&&
  (lka||a.prevent(),a=m.get(a.target(),VQ),a=void 0!==a?parseInt(a,10):1,h.trigger.click(a))});return{refresh:function(f,h){y.append(f,e);f=bb.absolute(h);var g=sa.get(h);h=Ga.get(h);h={top:f.top,height:k(g),left:f.left,width:k(h)};f=Ga.get(c)/2;v.setAll(c,{top:h.top()+h.height()-f+"px",left:h.left()-f+"px"});v.setAll(a,{top:h.top()+h.height()-f+"px",left:h.width()+h.left()-f+"px"});v.setAll(b,{top:h.top()-f+"px",left:h.width()+h.left()-f+"px"});v.setAll(d,{top:h.top()-f+"px",left:h.left()-f+"px"})},
  clear:f,events:h.registry,destroy:function(){g.unbind();f()}}}},WQ=aa.detect().browser,FZ=WQ.isChrome(),EZ=WQ.isFirefox(),mka=O("minRow","minCol","maxRow","maxCol"),nka=function(a,b){var c=a.grid().columns(),d=a.grid().rows(),e=c,f=0,h=0;Ma(a.access(),function(a){if(b(a)){var c=a.row(),g=c+a.rowspan()-1,k=a.column();a=k+a.colspan()-1;c<d?d=c:g>f&&(f=g);k<e?e=k:a>h&&(h=a)}});return mka(d,e,f,h)},oka=function(a,b,c,d){for(var e=b.grid().columns(),f=b.grid().rows(),h=0;h<f;h++)for(var g=!1,k=0;k<e;k++)if(!(h<
  c.minRow()||h>c.maxRow()||k<c.minCol()||k>c.maxCol()))if(Ib.getAt(b,h,k).filter(d).isNone()){var m=g,n=a[h].element(),r=p.fromTag("td");y.append(r,p.fromTag("br"));(m?y.append:y.prepend)(n,r)}else g=!0},pka=function(a,b){var c=ka(sk.firstLayer(a,"tr"),function(a){return 0===a.dom().childElementCount});z(c,F.remove);b.minCol()!==b.maxCol()&&b.minRow()!==b.maxRow()||z(sk.firstLayer(a,"th,td"),function(a){m.remove(a,"rowspan");m.remove(a,"colspan")});m.remove(a,"width");m.remove(a,"height");v.remove(a,
  "width");v.remove(a,"height")},qka={extract:function(a,b){var c=function(a){return Ia.is(a.element(),b)},d=fg.fromTable(a),e=Ib.generate(d),f=nka(e,c),h="th:not("+b+"),td:not("+b+")",g=sk.filterFirstLayer(a,"th,td",function(a){return Ia.is(a,h)});z(g,F.remove);oka(d,e,f,c);pka(a,f);return a}},JZ=function(a){z(a,function(a){F.empty(a);y.append(a,p.fromTag("br"))})},rka=function(a){return tb.table(a[0]).map(Oc.deep).map(function(a){return[qka.extract(a,te.selectedSelector())]})},HZ=function(a,b){var c=
  Bv.register({doc:a.doc,win:a.win,body:a.body,getSelection:a.getSelection,setSelection:a.setSelection});return function(b,e,f,h){e=Sj.buildClipboardContents(e,f);h();var d=Om.fromSafe(a);d.begin();c.setClipboard(b,e,function(){d.end()})}},IZ=function(a,b){return rka(a).map(function(a){z(a,b);var c=u(pn.toText,a);a=u(pn.toHtml,a);return{text:c,html:a}})},KZ=function(a,b,c){return Li.fragment(b.win(),a).map(function(a){var b=u(Li.text,a);a=u(Li.html,a,c);return{text:b,html:a}})},td={resolve:Lb.create("ephox-cement").resolve},
  ska=td.resolve("smartpaste-eph-bin"),hB={binStyle:k(ska)},XQ=function(a,b){return $b.cata(b.get(),k([]),ca,k([a]))},yx={mergable:function(a,b){return $b.cata(b.get(),g.none,function(b,d){return 0===b.length?g.none():Vz.retrieveBox(a,te.firstSelectedSelector(),te.lastSelectedSelector()).bind(function(a){return 1<b.length?g.some({bounds:k(a),cells:k(b)}):g.none()})},g.none)},unmergable:function(a,b){var c=function(a){return m.has(a,"rowspan")&&1<parseInt(m.get(a,"rowspan"),10)||m.has(a,"colspan")&&
  1<parseInt(m.get(a,"colspan"),10)};a=XQ(a,b);return 0<a.length&&ob(a,c)?g.some(a):g.none()},selection:XQ},YQ=function(a){return{element:k(a),mergable:g.none,unmergable:g.none,selection:k([])}},tka=O("element","clipboard","generators"),Sm={noMenu:YQ,forMenu:function(a,b,c){return{element:k(c),mergable:k(yx.mergable(b,a)),unmergable:k(yx.unmergable(c,a)),selection:k(yx.selection(c,a))}},notCell:function(a){return YQ(a)},paste:tka},uka=function(a){return"table"===D.name(a)||0===Vb.get(a).trim().length},
  ZQ=function(a){var b=ka(a,function(a){return"table"===D.name(a)});return 1!==b.length?g.none():ob(a,uka)?g.from(b[0]):g.none()},w_={rules:function(a,b,c){var d=t,e=function(e,f){return tb.table(e,a.isRoot).bind(function(h){var g=a.doc().getOrDie();g=aF.paste(g);g=Sm.paste(e,f,g);var l=k(c);return Ac.execute(b,nc.pasteCells,d,l)(a,h,g).map(function(a){return a.startContainer()})})},f=function(a){return ZQ(a).map(function(a){return{single:k(a)}})};return{collapsed:k(jb(function(a,b,c){return tb.cell(b,
  a)},f,function(a,b){return e(a.element(),b.single())},"custom arcade table insert collapsed")),ranged:k(jb(function(a,b,c){return tb.cell(b.element(),a).map(function(a){return{left:k(a),right:k(a)}})},f,function(a,b){return e(a.left(),b.single())},"custom arcade table insert ranged"))}},extractTable:ZQ},$Q="officeStyles htmlStyles isWord isGoogleDocs proxyBin isInternal backgroundAssets".split(" "),aR=Aa([],$Q),Xb={nu:aR,merge:function(a,b){var c={};z($Q,function(d){b[d]().or(a[d]()).each(function(a){c[d]=
  a})});return aR(c)}},Cl=ta.generate([{error:["message"]},{paste:["elements","correlated"]},{cancel:[]},{incomplete:["elements","correlated","message"]}]),zx=function(a,b,c,d,e){return a.fold(b,c,d,e)},db={error:Cl.error,paste:Cl.paste,cancel:Cl.cancel,incomplete:Cl.incomplete,cata:zx,carry:function(a,b){return zx(a,g.none,g.none,g.none,function(a,d,e){return zx(b,g.none,function(a,b){return g.some(Cl.incomplete(a,b,e))},g.none,g.none)}).getOr(b)}},Ax=Aa(["response","bundle"],[]),Dl=function(a){return Bx(function(b){var c=
  Ax(a);b(c)})},Bx=function(a){var b=Bx;return{get:function(b){a(b)},map:function(c){return b(function(b){a(function(a){a=c(a);b(a)})})},bind:function(c){return b(function(b){a(function(a){c(a).get(b)})})}}},La={call:function(a,b){a(Ax(b))},sync:Bx,pure:Dl,pass:function(a){return Dl({response:a.response(),bundle:a.bundle()})},done:Ax,error:function(a){return Dl({response:db.error(a),bundle:Xb.nu({})})},initial:function(){return Dl({response:db.paste([],[]),bundle:Xb.nu({})})},cancel:function(){return Dl({response:db.cancel(),
  bundle:Xb.nu({})})}},bR=O("steps","input","label","capture"),vka=function(a,b){return yc(a,function(a){return a.getAvailable(b).map(function(b){return bR(a.steps(),b,a.label(),a.capture())})})},wka=function(a,b){var c=u(La.pass,a),d=function(){return b().map(function(b){var c=Xb.merge(a.bundle(),b.bundle());b=db.carry(a.response(),b.response());return La.done({response:b,bundle:c})})};return db.cata(a.response(),c,d,c,d)},$A={choose:function(a,b,c){return vka(a,c).getOrThunk(function(){var a=b.getAvailable(c);
  return bR(b.steps(),a,b.label(),b.capture())})},run:function(a,b){return hb(a,function(a,d){return a.bind(function(a){return wka(a,function(){return d(b,a)})})},La.initial())}},xka=function(a,b){a=D.value(a);var c=p.fromTag("div"),d=a.indexOf("]>");c.dom().innerHTML=a.substr(d+2);return Ja.descendant(c,function(a){return D.name(a)===b})},yka=function(a){return D.isComment(a)?xka(a,"v:shape"):g.none()},zka=function(a){if("img"===D.name(a)){var b=m.get(a,"src");if(void 0!==b&&null!==b&&Gb(b,"file://"))return a=
  Oc.shallow(a),b=b.split(/[\/\\]/),m.set(a,"data-image-id",b[b.length-1]),m.remove(a,"src"),m.set(a,"data-image-type","local"),n.add(a,"rtf-data-image"),g.some(a)}return g.none()},Aka=function(a){return yka(a).map(function(a){var b=m.get(a,"o:spid");b=void 0===b?m.get(a,"id"):b;var d=p.fromTag("img");n.add(d,"rtf-data-image");m.set(d,"data-image-id",b.substr(7));m.set(d,"data-image-type","code");v.setAll(d,{width:v.get(a,"width"),height:v.get(a,"height")});return d})},cR={validStyles:function(){return/^(mso-.*|tab-stops|tab-interval|language|text-underline|text-effect|text-line-through|font-color|horiz-align|list-image-[0-9]+|separator-image|table-border-color-(dark|light)|vert-align|vnd\..*)$/},
  specialInline:function(){return/^(font|em|strong|samp|acronym|cite|code|dfn|kbd|tt|b|i|u|s|sub|sup|ins|del|var|span)$/}},$i=ta.generate([{starts:["value","f"]},{pattern:["regex","f"]},{contains:["value","f"]},{exact:["value","f"]},{all:[]},{not:["stringMatch"]}]),dR=function(a,b){return a.fold(function(a,d){return 0===d(b).indexOf(d(a))},function(a,d){return a.test(d(b))},function(a,d){return 0<=d(b).indexOf(d(a))},function(a,d){return d(b)===d(a)},function(){return!0},function(a){return!dR(a,b)})},
  M={starts:$i.starts,pattern:$i.pattern,contains:$i.contains,exact:$i.exact,all:$i.all,not:$i.not,cata:function(a,b,c,d,e,f,g){return a.fold(b,c,d,e,f,g)},matches:dR,caseSensitive:function(a){return a},caseInsensitive:function(a){return a.toLowerCase()}},gq={keyval:function(a,b,c,d){var e=d.name,f=void 0!==d.condition?d.condition:k(!0);d=void 0!==d.value?d.value:M.all();return M.matches(e,c)&&M.matches(d,b)&&f(a)},name:function(a,b){var c=D.name(a),d=b.name;b=void 0!==b.condition?b.condition:k(!0);
  return M.matches(d,c)&&b(a)}},Bka=function(a,b,c){z(b,function(b){m.remove(a,b)});Ma(c,function(b,c){m.set(a,c,b)})},eR={filter:function(a,b){var c={};z(a.dom().attributes,function(a){b(a.value,a.name)||(c[a.name]=a.value)});return c},clobber:function(a,b,c){c=E(a.dom().attributes,function(a){return a.name});cb(b).length!==c.length&&Bka(a,c,b)},scan:k({})},Cka=function(a){var b={};a=void 0!==a&&null!==a?a.split(";"):[];z(a,function(a){a=a.split(":");2===a.length&&(b[Zh(a[0])]=Zh(a[1]))});return b},
  fR=function(a){var b=cb(a);return E(b,function(b){return b+": "+a[b]}).join("; ")},Gg={filter:function(a,b){var c=a.dom().style,d={};z(void 0===c||null===c?[]:c,function(c){var e=a.dom().style.getPropertyValue(c);b(e,c)||(d[c]=e)});return d},clobber:function(a,b,c){m.set(a,"style","");var d=cb(b).length,e=cb(c).length;0===d&&0===e?m.remove(a,"style"):0===d?m.set(a,"style",fR(c)):(Ma(b,function(b,c){v.set(a,c,b)}),b=m.get(a,"style"),c=0<e?fR(c)+"; ":"",m.set(a,"style",c+b))},scan:function(a,b,c){a=
  a.dom().getAttribute("style");var d=Cka(a),e={};z(b,function(a){var b=d[a];void 0===b||c(b,a)||(e[a]=b)});return e}},Dka=["mso-list"],gR=function(a,b){var c=Gg.scan(a,Dka,b);b=Gg.filter(a,b);Gg.clobber(a,b,c)},hR=function(a,b){b=eR.filter(a,b);eR.clobber(a,b,{})},hq={style:gR,attribute:hR,styleDom:function(a,b){gR(p.fromDom(a),b)},attributeDom:function(a,b){hR(p.fromDom(a),b)},validateStyles:function(a){var b=Gg.filter(a,k(!1));Gg.clobber(a,b,{})}},iR=function(a,b,c){a(c,function(a,e){return Xa(b,
  function(b){return gq.keyval(c,a,e,b)})})},iq={remover:function(a,b){var c=ua({styles:[],attributes:[],classes:[],tags:[]},b);b=Y.descendants(a,"*");z(b,function(a){iR(hq.style,c.styles,a);iR(hq.attribute,c.attributes,a);z(c.classes,function(b){var c=m.has(a,"class")?ma.get(a):[];z(c,function(c){M.matches(b.name,c)&&n.remove(a,c)})})});a=Y.descendants(a,"*");z(a,function(a){Xa(c.tags,u(gq.name,a))&&F.remove(a)})},unwrapper:function(a,b){var c=ua({tags:[]},b);a=Y.descendants(a,"*");z(a,function(a){Xa(c.tags,
  u(gq.name,a))&&F.unwrap(a)})},transformer:function(a,b){var c=ua({tags:[]},b);a=Y.descendants(a,"*");z(a,function(a){qa(c.tags,u(gq.name,a)).each(function(b){b.mutate(a)})})},validator:function(a){a=Y.descendants(a,"*");z(a,function(a){hq.validateStyles(a)})}},El=function(a,b,c){var d=p.fromDom(a);switch(a.nodeType){case 1:if(b)var e="endElement";else e="startElement",v.setAll(d,c||{});var f="HTML"!==a.scopeName&&a.scopeName&&a.tagName&&0>=a.tagName.indexOf(":")?(a.scopeName+":"+a.tagName).toUpperCase():
  a.tagName;break;case 3:e="text";var g=a.nodeValue;break;case 8:e="comment";g=a.nodeValue;break;default:console.log("WARNING: Unsupported node type encountered: "+a.nodeType)}return{getNode:function(){return a},tag:function(){return f},type:function(){return e},text:function(){return g}}},jR=function(a,b){return El(b.createElement(a),!0)},Ab={START_ELEMENT_TYPE:"startElement",END_ELEMENT_TYPE:"endElement",TEXT_TYPE:"text",COMMENT_TYPE:"comment",FINISHED:jR("HTML",window.document),token:El,createStartElement:function(a,
  b,c,d){var e=d.createElement(a);Ma(b,function(a,b){e.setAttribute(b,a)});return El(e,!1,c)},createEndElement:jR,createComment:function(a,b){return El(b.createComment(a),!1)},createText:function(a,b){return El(b.createTextNode(a))}},Eka={create:function(a){var b=a.createDocumentFragment(),c=b;return{dom:c,receive:function(d){var e=function(a){a=a.getNode().cloneNode(!1);b.appendChild(a);b=a},f=function(c,d){c=a.createTextNode(c.text());b.appendChild(c)};switch(d.type()){case Ab.START_ELEMENT_TYPE:e(d);
  break;case Ab.TEXT_TYPE:f(d);break;case Ab.END_ELEMENT_TYPE:b=b.parentNode;null===b&&(b=c);break;case Ab.COMMENT_TYPE:break;default:throw{message:"Unsupported token type: "+d.type()};}},label:"SERIALISER"}}},Fka={tokenise:function(a,b){b=b||window.document;var c=b.createElement("div");b.body.appendChild(c);c.style.position="absolute";c.style.left="-10000px";c.innerHTML=a;var d=c.firstChild||Ab.FINISHED,e=[],f=!1;return{hasNext:function(){return void 0!==d},next:function(){var a=d,g=f;!f&&d.firstChild?
  (e.push(d),d=d.firstChild):f||1!==d.nodeType?d.nextSibling?(d=d.nextSibling,f=!1):(d=e.pop(),f=!0):f=!0;a===Ab.FINISHED||d||(b.body.removeChild(c),d=Ab.FINISHED);a=a===Ab.FINISHED?a:a?Ab.token(a,g):void 0;return a}}}},kR=function(a,b,c){var d=c;for(c=b.length-1;0<=c;c--)d=b[c](d,{},a);return d},Gka={build:kR,run:function(a,b,c){var d=Eka.create(a);b=Fka.tokenise(b,a);for(a=kR(a,c,d);b.hasNext();)c=b.next(),a.receive(c);return d.dom}},gb={removal:function(a){return function(b){iq.remover(b,a)}},unwrapper:function(a){return function(b){iq.unwrapper(b,
  a)}},transformer:function(a){return function(b){iq.transformer(b,a)}},validate:function(){return function(a){iq.validator(a)}},pipeline:function(a){return function(b){var c=Ha.get(b),d=A.owner(b);c=Gka.run(d.dom(),c,a);F.empty(b);b.dom().appendChild(c)}},isWordContent:function(a,b){return 0<=a.indexOf("<o:p>")||b.browser.isEdge()&&0<=a.indexOf('v:shapes="')||b.browser.isEdge()&&0<=a.indexOf("mso-")||0<=a.indexOf("mso-list")||0<=a.indexOf("p.MsoNormal, li.MsoNormal, div.MsoNormal")||0<=a.indexOf("MsoListParagraphCxSpFirst")||
  0<=a.indexOf("<w:WordDocument>")},go:function(a,b,c){var d=p.fromTag("div",a.dom());d.dom().innerHTML=b;z(c,function(a){a(d)});return Ha.get(d)}},Cx={getAttribute:function(a,b){a=p.fromDom(a.getNode());return m.get(a,b)},getStyle:function(a,b){a=p.fromDom(a.getNode());return v.get(a,b)},isWhitespace:function(a){return a.type()===Ab.TEXT_TYPE&&/^[\s\u00A0]*$/.test(a.text())},getMsoList:function(a){a=p.fromDom(a.getNode());return Gg.scan(a,["mso-list"],k(!1))["mso-list"]}},lR=function(a,b,c){return a===
  b||a&&b&&a.tag===b.tag&&a.type===b.type&&(c||a.variant===b.variant)},mR={guessFrom:function(a,b){return qa(a,function(a){return"UL"===a.tag||b&&lR(a,b,!0)}).orThunk(function(){return 0===a.length?g.none():g.some(a[0])})},eqListType:lR},Dx=function(a,b){if(void 0===a||void 0===b)throw console.trace(),"brick";a.nextFilter.set(b)},nR=function(a,b,c){b.nextFilter.get()(a,b,c)},jq={next:Dx,go:nR,jump:function(a){return function(b,c,d){Dx(c,a);nR(b,c,d)}},isNext:function(a,b){return a.nextFilter.get()===
  b},setNext:function(a){return function(b,c,d){Dx(c,a)}}},Hka=O("level","token","type"),Ika=function(a,b,c,d){a=c.getCurrentListType();c=c.getCurrentLevel()==d.level()?a:null;return mR.guessFrom(d.emblems(),c).filter(function(a){if(a="OL"===a.tag)a=!U(["P"],b.tag())||/^MsoHeading/.test(Cx.getAttribute(b,"class"));return!a})},oR={predicate:function(a,b){return m.has(p.fromDom(b.getNode()),"data-list-level")},action:function(a){return function(b,c,d){b=p.fromDom(d.getNode());var e=parseInt(m.get(b,"data-list-level"),
  10),f=m.get(b,"data-list-emblems");f=JSON.parse(f);m.remove(b,"data-list-level");m.remove(b,"data-list-emblems");b={level:k(e),emblems:k(f)};b.level();c.originalToken.set(d);Ika(c.listType.get(),d,c.emitter,b).each(c.listType.set);d=Hka(b.level(),c.originalToken.get(),c.listType.get());c.emitter.openItem(d.level(),d.token(),d.type());jq.next(c,a.inside())}}},XA=function(a,b){return function(a,d,e){return b(a,d,e)}},pR={inside:function(a){return WA("Inside.List.Item",[Jr(function(a,c){return c.type()===
  Ab.END_ELEMENT_TYPE&&a.originalToken.get()&&c.tag()===a.originalToken.get().tag()},function(b,c,d){jq.next(c,a.outside())},"Closing open tag")],function(a,c,d){a.emit(d)})},outside:function(a){return WA("Outside.List.Item",[Jr(oR.predicate,oR.action(a),"Data List ****"),Jr(function(a,c){return c.type()===Ab.TEXT_TYPE&&Cx.isWhitespace(c)},function(a,c,d){a.emit(d)},"Whitespace")],function(b,c,d){c.emitter.closeAllLists();b.emit(d);jq.next(c,a.outside())})}},Jka=O("state","result"),Kka=O("state","value"),
  mc={state:O("level","type","types","items"),value:Kka,result:Jka},Ex={start:function(a,b){var c=a.items().slice(0);b=void 0!==b&&"P"!==b?g.some(b):g.none();b.fold(function(){c.push("P")},function(a){c.push(a)});a=mc.state(a.level(),a.type(),a.types(),c);return mc.value(a,b)},finish:function(a){var b=a.items().slice(0);if(0<b.length&&"P"!==b[b.length-1]){var c=b[b.length-1];b[b.length-1]="P";a=mc.state(a.level(),a.type(),a.types(),b);return mc.value(a,g.some(c))}return mc.value(a,g.none())}},Fx=function(a,
  b,c){for(var d=[];b(a);){var e=c(a);a=e.state();d=d.concat(e.result())}return mc.result(a,d)},qR={moveRight:function(a,b,c){return Fx(a,function(a){return a.level()<b},c)},moveLeft:function(a,b,c){return Fx(a,function(a){return a.level()>b},c)},moveUntil:Fx},Lka={from:function(a){var b={"list-style-type":"none"};a?(a=Cx.getStyle(a,"margin-left"),a=void 0!==a&&"0px"!==a?{"margin-left":a}:{}):a=b;return a}},rR=function(a,b,c){var d=b.start&&1<b.start?{start:b.start}:{},e=a.level()+1,f=a.types().concat([b]);
  c=[u(Ab.createStartElement,b.tag,d,c)];a=mc.state(e,b,f,a.items());return mc.result(a,c)},sR=function(a){var b=a.types().slice(0),c=[u(Ab.createEndElement,b.pop().tag)],d=a.level()-1;a=mc.state(d,b[b.length-1],b,a.items());return mc.result(a,c)},Mka=function(a,b){a=sR(a);b=rR(a.state(),b,b.type?{"list-style-type":b.type}:{});return mc.result(b.state(),a.result().concat(b.result()))},aj={open:rR,openItem:function(a,b,c){var d=Lka.from(b);a=a.type()&&!mR.eqListType(a.type(),c)?Mka(a,c):mc.result(a,
  []);d=[u(Ab.createStartElement,"LI",{},d)];c=Ex.start(a.state(),b&&b.tag());var e=c.value().map(function(a){hq.styleDom(b.getNode(),k(!0));return[k(b)]}).getOr([]);return mc.result(c.state(),a.result().concat(d).concat(e))},close:sR,closeItem:function(a){var b=u(Ab.createEndElement,"LI");a=Ex.finish(a);var c=a.value().fold(function(){return[b]},function(a){return[u(Ab.createEndElement,a),b]});return mc.result(a.state(),c)}},kq=function(a){if(0===a.length)throw"Compose must have at least one element in the list";
  var b=a[a.length-1];a=ia(a,function(a){return a.result()});return mc.result(b.state(),a)},Nka=function(a){a=aj.closeItem(a);var b=aj.close(a.state());return kq([a,b])},Oka=function(a,b,c,d){return qR.moveRight(a,c,function(a){var e=a.level()===c-1&&b.type?{"list-style-type":b.type}:{};a=aj.open(a,b,e);e=aj.openItem(a.state(),a.state().level()==c?d:void 0,b);return kq([a,e])})},tR=function(a,b){return qR.moveLeft(a,b,Nka)},Pka=function(a,b,c,d){var e=1<c?Ex.finish(a):mc.value(a,g.none());a=e.value().map(function(a){return[u(Ab.createEndElement,
  a)]}).getOr([]);e.state().level();b=Oka(e.state(),b,c,d);return mc.result(b.state(),a.concat(b.result()))},YA={openItem:function(a,b,c,d){a=a.level()>b?tR(a,b):mc.result(a,[]);a.state().level()===b?(b=a.state(),b=0<b.level()?aj.closeItem(b):mc.result(b,[]),c=aj.openItem(b.state(),c,d),c=kq([b,c])):c=Pka(a.state(),d,b,c);return kq([a,c])},closeAllLists:tR},OZ=["disc","circle","square"],Qka={getCurrentListType:function(){return Fl().getCurrentListType()},getCurrentLevel:function(){return Fl().getCurrentLevel()},
  closeAllLists:function(){return Fl().closeAllLists.apply(void 0,arguments)},openItem:function(){return Fl().openItem.apply(void 0,arguments)}},Fl=function(){return{getCurrentListType:k({}),getCurrentLevel:k(1),closeAllLists:ca,openItem:ca}},vR={inside:function(){return Rka},outside:function(){return uR}},Ska=function(){var a=!1,b="";return{check:function(c){return a&&c.type()===Ab.TEXT_TYPE?(b+=c.text(),!0):c.type()===Ab.START_ELEMENT_TYPE&&"STYLE"===c.tag()?a=!0:c.type()===Ab.END_ELEMENT_TYPE&&"STYLE"===
  c.tag()?(a=!1,!0):!1}}}(),Rka=pR.inside(vR),uR=pR.outside(vR),wR=function(a){var b=na(a),c=na(null),d=na(null);return{reset:function(e){b.set(a);c.set(null);d.set(null);e=NZ(e,e.document);Fl=k(e)},nextFilter:b,originalToken:c,listType:d,emitter:Qka}}(uR),Tka=VA(function(a,b,c){Ska.check(b)||jq.go(a,wR,b)},wR.reset,"list.filters"),Uka=[{regex:/^\(?[dc][\.\)]$/,type:{tag:"OL",type:"lower-alpha"}},{regex:/^\(?[DC][\.\)]$/,type:{tag:"OL",type:"upper-alpha"}},{regex:/^\(?M*(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})[\.\)]$/,
  type:{tag:"OL",type:"upper-roman"}},{regex:/^\(?m*(cm|cd|d?c{0,3})(xc|xl|l?x{0,3})(ix|iv|v?i{0,3})[\.\)]$/,type:{tag:"OL",type:"lower-roman"}},{regex:/^\(?[0-9]+[\.\)]$/,type:{tag:"OL"}},{regex:/^([0-9]+\.)*[0-9]+\.?$/,type:{tag:"OL",variant:"outline"}},{regex:/^\(?[a-z]+[\.\)]$/,type:{tag:"OL",type:"lower-alpha"}},{regex:/^\(?[A-Z]+[\.\)]$/,type:{tag:"OL",type:"upper-alpha"}}],xR={"\u2022":{tag:"UL",type:"disc"},"\u00b7":{tag:"UL",type:"disc"},"\u00a7":{tag:"UL",type:"square"}},yR={o:{tag:"UL",type:"circle"},
  "-":{tag:"UL",type:"disc"},"\u25cf":{tag:"UL",type:"disc"},"\ufffd":{tag:"UL",type:"circle"}},Vka={extract:function(a,b){var c=yR[a]?[yR[a]]:[];b=b&&xR[a]?[xR[a]]:b?[{tag:"UL",variant:a}]:[];var d=ia(Uka,function(b){if(b.regex.test(a)){var c=b.type;var d=a.split(".");if(0===d.length)d=a;else{var e=d[d.length-1];d=0===e.length&&1<d.length?d[d.length-2]:e}d=parseInt(d,10);d=isNaN(d)?{}:{start:d};b=b.type;b=void 0!==b.variant?b.variant:"("===a.charAt(0)?"()":")"===a.charAt(a.length-1)?")":".";c=[ua(c,
  d,{variant:b})]}else c=[];return c});c=c.concat(b).concat(d);return E(c,function(b){return void 0!==b.variant?b:ua(b,{variant:a})})}},zR=function(a){return Gg.scan(a,["mso-list"],k(!1))["mso-list"]},AR=function(a){return D.isElement(a)&&v.getRaw(a,"font-family").exists(function(a){return U(["wingdings","symbol"],a.toLowerCase())})},Fc={getMsoList:zR,extractLevel:function(a){a=zR(a);return(a=/ level([0-9]+)/.exec(a))&&a[1]?g.some(parseInt(a[1],10)):g.none()},extractEmblem:function(a,b){a=Vb.get(a).trim();
  b=Vka.extract(a,b);return 0<b.length?g.some(b):g.none()},extractSymSpan:function(a){return Ja.child(a,AR)},extractMsoIgnore:function(a){return Ja.descendant(a,function(a){return!!(D.isElement(a)?Gg.scan(a,["mso-list"],k(!1)):[])["mso-list"]})},extractCommentSpan:function(a){return Ja.child(a,D.isComment).bind(A.nextSibling).filter(function(a){return"span"===D.name(a)})},isSymbol:AR,deduceLevel:function(a){return v.getRaw(a,"margin-left").bind(function(a){a=parseInt(a,10);return isNaN(a)?g.none():
  g.some(Math.max(1,Math.ceil(a/18)))})}},BR=function(a){for(var b=[];null!==a.nextNode();)b.push(p.fromDom(a.currentNode));return b},Wka=function(a){try{return BR(a)}catch(b){return[]}},CR=aa.detect().browser,Xka=CR.isIE()||CR.isEdge()?Wka:BR,Yka=k(k(!0)),Zka={find:function(a,b){b=b.fold(Yka,function(a){return function(b){return a(b.nodeValue)}});b.acceptNode=b;a=Hb.createTreeWalker(a.dom(),Jc.getOrDie("NodeFilter").SHOW_COMMENT,b,!1);return Xka(a)}},Gl=function(a,b,c,d){m.set(a,"data-list-level",
  b);b=JSON.stringify(c);m.set(a,"data-list-emblems",b);b=Zka.find(a,g.none());z(b,F.remove);z(d,F.remove);m.remove(a,"style");m.remove(a,"class")},$ka=function(a){return Fc.extractLevel(a).bind(function(b){return Fc.extractSymSpan(a).bind(function(c){return Fc.extractEmblem(c,!0).map(function(d){return{mutate:function(){Gl(a,b,d,[c])}}})})})},ala=function(a){return Fc.extractLevel(a).bind(function(b){return Fc.extractCommentSpan(a).bind(function(c){return Fc.extractEmblem(c,Fc.isSymbol(c)).map(function(d){return{mutate:function(){Gl(a,
  b,d,[c])}}})})})},bla=function(a){return Fc.extractLevel(a).bind(function(b){return Fc.extractCommentSpan(a).bind(function(c){return Fc.extractEmblem(c,Fc.isSymbol(c)).map(function(d){return{mutate:function(){Gl(a,b,d,[c])}}})})})},cla=function(a){return"p"!==D.name(a)?g.none():Fc.extractLevel(a).bind(function(b){return Fc.extractMsoIgnore(a).bind(function(c){return Fc.extractEmblem(c,!1).map(function(d){return{mutate:function(){Gl(a,b,d,[A.parent(c).getOr(c)])}}})})})},dla=function(a){return"p"!==
  D.name(a)?g.none():Fc.extractMsoIgnore(a).bind(function(b){var c=A.parent(b).getOr(b),d=Fc.isSymbol(c);return Fc.extractEmblem(b,d).bind(function(b){return Fc.deduceLevel(a).map(function(d){return{mutate:function(){Gl(a,d,b,[c])}}})})})},ela={find:function(a){return $ka(a).orThunk(function(){return ala(a)}).orThunk(function(){return bla(a)}).orThunk(function(){return cla(a)}).orThunk(function(){return dla(a)})}},fla=gb.transformer({tags:[{name:M.pattern(/^(p|h\d+)$/,M.caseInsensitive),mutate:function(a){ela.find(a).each(function(a){a.mutate()})}}]}),
  gla=function(a){var b=a.dom().attributes;b=void 0!==b&&null!==b&&0<b.length;return"span"===D.name(a)?b:!0},lq=function(a){return void 0===a.dom().attributes||null===a.dom().attributes?!0:0===a.dom().attributes.length||1===a.dom().attributes.length&&"style"===a.dom().attributes[0].name},DR=function(a,b){var c=p.fromTag(a);y.before(b,c);a=b.dom().attributes;z(a,function(a){c.dom().setAttribute(a.name,a.value)});a=A.children(b);P.append(c,a);F.remove(b);return c},ER=function(a){return A.prevSibling(a).bind(function(a){return D.isText(a)&&
  0===Ya.get(a).trim().length?ER(a):"li"===D.name(a)?g.some(a):g.none()})},Bh={changeTag:DR,addBrTag:function(a){0===Ha.get(a).length&&y.append(a,p.fromTag("br"))},properlyNest:function(a){A.parent(a).each(function(b){b=D.name(b);U(["ol","ul"],b)&&ER(a).fold(function(){var b=p.fromTag("li");v.set(b,"list-style-type","none");y.wrap(a,b)},function(b){y.append(b,a)})})},fontToSpan:function(a){var b=DR("span",a),c={"font-size":{1:"8pt",2:"10pt",3:"12pt",4:"14pt",5:"18pt",6:"24pt",7:"36pt"}};Ma({face:"font-family",
  size:"font-size",color:"color"},function(a,e){if(m.has(b,e)){var d=m.get(b,e);v.set(b,a,void 0!==c[a]&&void 0!==c[a][d]?c[a][d]:d);m.remove(b,e)}})}},hla=gb.unwrapper({tags:[{name:M.pattern(/^([OVWXP]|U[0-9]+|ST[0-9]+):/i,M.caseInsensitive)}]}),ila=gb.removal({attributes:[{name:M.exact("id",M.caseInsensitive),value:M.starts("docs-internal-guid",M.caseInsensitive)}]}),jla=[gb.pipeline([Tka])],kla=gb.removal({attributes:[{name:M.pattern(/^v:/,M.caseInsensitive)},{name:M.exact("href",M.caseInsensitive),
  value:M.contains("#_toc",M.caseInsensitive)},{name:M.exact("href",M.caseInsensitive),value:M.contains("#_mso",M.caseInsensitive)},{name:M.pattern(/^xmlns(:|$)/,M.caseInsensitive)},{name:M.exact("type",M.caseInsensitive),condition:function(a){return"ol"===D.name(a)||"ul"===D.name(a)}}]}),lla=gb.removal({tags:[{name:M.exact("script",M.caseInsensitive)},{name:M.exact("link",M.caseInsensitive)},{name:M.exact("style",M.caseInsensitive),condition:function(a){return 0===Ha.get(a).length}}],attributes:[{name:M.starts("on",
  M.caseInsensitive)},{name:M.exact('"',M.caseInsensitive)},{name:M.exact("lang",M.caseInsensitive)},{name:M.exact("language",M.caseInsensitive)}],styles:[{name:M.all(),value:M.pattern(/OLE_LINK/i,M.caseInsensitive)}]}),FR=gb.removal({tags:[{name:M.exact("meta",M.caseInsensitive)}]}),mla=gb.removal({tags:[{name:M.exact("style",M.caseInsensitive)}]}),nla=gb.removal({styles:[{name:M.not(M.pattern(/width|height|list-style-type/,M.caseInsensitive)),condition:function(a){return!n.has(a,"ephox-limbo-transform")}},
  {name:M.pattern(/width|height/,M.caseInsensitive),condition:function(a){return"img"!==D.name(a)}}]}),ola=gb.removal({classes:[{name:M.not(M.exact("rtf-data-image",M.caseInsensitive))}]}),pla=gb.removal({styles:[{name:M.pattern(cR.validStyles(),M.caseInsensitive)}]}),qla=gb.removal({classes:[{name:M.pattern(/mso/i,M.caseInsensitive)}]}),rla=gb.unwrapper({tags:[{name:M.exact("img",M.caseInsensitive),condition:function(a){a=m.get(a,"src");return/^file:/.test(a)}},{name:M.exact("a",M.caseInsensitive),
  condition:lq}]}),sla=gb.unwrapper({tags:[{name:M.exact("a",M.caseInsensitive),condition:lq}]}),tla=gb.removal({attributes:[{name:M.exact("style",M.caseInsensitive),value:M.exact("",M.caseInsensitive),debug:!0}]}),ula=gb.removal({attributes:[{name:M.exact("class",M.caseInsensitive),value:M.exact("",M.caseInsensitive),debug:!0}]}),vla=gb.unwrapper({tags:[{name:M.pattern(cR.specialInline(),M.caseInsensitive),condition:zf(function(a){return lq(a)?gla(a)&&wd.descendant(a,function(a){var b=!lq(a),d=!U("font em strong samp acronym cite code dfn kbd tt b i u s sub sup ins del var span".split(" "),
  D.name(a));return D.isText(a)||b||d}):!0})}]}),wla=gb.unwrapper({tags:[{name:M.exact("p",M.caseInsensitive),condition:function(a){return function(b){return A.parent(b).exists(function(b){return D.name(b)===a&&1===A.children(b).length})}}("li")}]}),xla=gb.transformer({tags:[{name:M.exact("p",M.caseInsensitive),mutate:Bh.addBrTag}]}),yla=gb.transformer({tags:[{name:M.pattern(/ol|ul/,M.caseInsensitive),mutate:Bh.properlyNest}]}),zla=gb.transformer({tags:[{name:M.exact("b",M.caseInsensitive),mutate:u(Bh.changeTag,
  "strong")},{name:M.exact("i",M.caseInsensitive),mutate:u(Bh.changeTag,"em")},{name:M.exact("u",M.caseInsensitive),mutate:function(a){a=Bh.changeTag("span",a);n.add(a,"ephox-limbo-transform");v.set(a,"text-decoration","underline")}},{name:M.exact("s",M.caseInsensitive),mutate:u(Bh.changeTag,"strike")},{name:M.exact("font",M.caseInsensitive),mutate:Bh.fontToSpan,debug:!0}]}),Ala=gb.removal({classes:[{name:M.exact("ephox-limbo-transform",M.caseInsensitive)}]}),Bla=gb.removal({tags:[{name:M.exact("br",
  M.caseInsensitive),condition:yf.hasClass("Apple-interchange-newline")}]}),Cla=gb.removal({styles:[{name:M.pattern(/^-/,M.caseInsensitive)},{name:M.all(),value:M.exact("initial",M.caseInsensitive)},{name:M.exact("background-color",M.caseInsensitive),value:M.exact("transparent",M.caseInsensitive)},{name:M.exact("font-style",M.caseInsensitive),value:M.exact("normal",M.caseInsensitive)},{name:M.pattern(/font-variant.*/,M.caseInsensitive)},{name:M.exact("letter-spacing",M.caseInsensitive)},{name:M.exact("font-weight",
  M.caseInsensitive),value:M.pattern(/400|normal/,M.caseInsensitive)},{name:M.exact("orphans",M.caseInsensitive)},{name:M.exact("text-decoration",M.caseInsensitive),value:M.exact("none",M.caseInsensitive)},{name:M.exact("text-size-adjust",M.caseInsensitive)},{name:M.exact("text-indent",M.caseInsensitive),value:M.exact("0px",M.caseInsensitive)},{name:M.exact("text-transform",M.caseInsensitive),value:M.exact("none",M.caseInsensitive)},{name:M.exact("white-space",M.caseInsensitive),value:M.exact("normal",
  M.caseInsensitive)},{name:M.exact("widows",M.caseInsensitive)},{name:M.exact("word-spacing",M.caseInsensitive),value:M.exact("0px",M.caseInsensitive)},{name:M.exact("text-align",M.caseInsensitive),value:M.pattern(/start|end/,M.caseInsensitive)},{name:M.exact("font-weight",M.caseInsensitive),value:M.pattern(/700|bold/,M.caseInsensitive),condition:function(a){return/^h\d$/.test(D.name(a))}}]}),Dla=function(){var a=function(a,b){return function(c){return a(c).filter(function(a){return D.isText(c)&&b(Vb.get(a),
  " ")}).isSome()}},b=a(A.prevSibling,je),c=a(A.nextSibling,Gb);return gb.transformer({tags:[{name:M.exact("span",M.caseInsensitive),condition:yf.hasClass("Apple-converted-space"),mutate:function(a){"\u00a0"===Vb.get(a)&&(b(a)||c(a)?F.unwrap(a):(y.before(a,p.fromText(" ")),F.remove(a)))}}]})}(),Ela=function(){var a=/^file:\/\/\/[^#]+(#[^#]+)$/;return gb.transformer({tags:[{name:M.exact("a",M.caseInsensitive),condition:function(b){return(b=m.get(b,"href"))?a.test(b):!1},mutate:function(b){var c=m.get(b,
  "href");m.set(b,"href",c.replace(a,"$1"))}}]})}(),Fla=gb.removal({attributes:[{name:M.exact("href",M.caseInsensitive),value:M.starts("file:///",M.caseInsensitive),debug:!0}]}),GR=function(){var a=function(a,c,d){return{name:M.exact(a,M.caseInsensitive),condition:function(a){return m.has(a,c)},mutate:function(a){var b=m.get(a,c);m.set(a,d,b);m.remove(a,c)}}};return gb.transformer({tags:[a("a","data-ephox-href","href"),a("img","data-ephox-src","src")]})}(),Gla=function(a){var b="table thead tbody tfoot th tr td ul ol li".split(" "),
  c=cd.descendants(a,D.isComment),d=qa(c,function(a){return Bb(Dv.get(a),"StartFragment")}),e=qa(c,function(a){return Bb(Dv.get(a),"EndFragment")});d.each(function(c){e.each(function(d){var e=c,f=[];for(d=hd.commonAncestorContainer(c,0,d,0);void 0!==d&&!N.eq(d,a);)U(b,D.name(d))?e=d:f.push(d),d=A.parent(d).getOr(void 0);z(f,F.unwrap);z(A.prevSiblings(e),F.remove)});F.remove(c)});e.each(F.remove)},mq=t,nq=function(a){return a.browser.isIE()&&11<=a.browser.version.major},Hla=function(a,b,c){var d=p.fromDom(a.getNode());
  return b(d).fold(function(){return[a]},function(b){var d=a.type()===Ab.END_ELEMENT_TYPE,e=[Ab.token(b.dom(),d)];!d&&c&&e.push(Ab.token(b.dom(),!0));return e})},Ila=function(a,b){return VA(function(c,d){d=Hla(d,a,b);z(d,c.emit)},t,"image filters")},Jla={derive:function(a,b,c){var d;var e=(d=c.browser.isFirefox()||c.browser.isEdge())?zka:Aka;var f=!d;e=nq(c)?mq:gb.pipeline([Ila(e,f)]);e=[a?e:mq];d=[d?mq:rla];f=nq(c)||!a?[]:[fla];var g=[zla];if(a){var k=[hla];var m=nq(c)?[]:jla;k=k.concat(m).concat([kla])}else k=
  [mq];m=[ila];var n=[yla],p=[lla],r=[FR];var t=[pla,qla];var u=[nla,ola];t=b?t:u;u=[Ela,Fla,sla,GR];var v=[tla],x=[ula],y=[vla],z=[Bla];b=!a&&b?[Cla]:[];var A=[Dla],B=[xla];a=nq(c)&&a?[wla]:[];return Qb([f,e,g,k,m,n,p,r,d,t,u,v,x,y,z,b,A,B,a,[Ala],[mla]])}},Kla=Gn.link().source,Lla=function(a){var b=O("word","pattern"),c=Cb.unsafetoken(Kla);b=b("__INTERNAL__",c);return Hp.run(a,[b])},Mla=function(a){return!Db.closest(a,"a")},Nla=function(a){return g.from(a[0]).filter(Mla).map(function(b){var c=p.fromTag("a");
  y.before(b,c);P.append(c,a);m.set(c,"href",Vb.get(c));return c})},Ola=function(a){a=Lla(a);z(a,function(a){var b=a.exact(),d;(d=0>b.indexOf("@"))||(b=b.indexOf("://"),d=3<=b&&9>=b);d&&Nla(a.elements())})},Pla=function(a){z(a,function(a){D.isElement(a)&&v.getRaw(a,"position").isSome()&&v.remove(a,"position")})},Qla=function(a){var b=ka(a,function(a){return"li"===D.name(a)});if(0<b.length){var c=A.prevSiblings(b[0]),d=p.fromTag("ul");y.before(a[0],d);0<c.length&&(a=p.fromTag("li"),y.append(d,a),P.append(a,
  c));P.append(d,b)}},HR=function(a){var b=A.children(a);z([Ola,Pla,Qla],function(a){a(b)})},oq={go:function(a,b,c,d,e){HR(c);c=Ha.get(c);b=Jla.derive(e,d,b);return gb.go(a,c,b)},preprocess:HR,internal:function(a,b){b=Ha.get(b);return gb.go(a,b,[FR,GR])},clean:function(a,b){b=Ha.get(b);return gb.go(a,b,[Gla])}},Hl=Fa("simple-adt"),IR={generate:function(a){var b=function(a){return 0===a.indexOf(Hl)?a.substring(Hl.length+1):a},c=cb(a),d={};z(c,function(a){d["as"+ls(a)]=function(b){return b._simpleAdt===
  Hl+"_"+a?g.some(b.data):g.none()}});var e={};Ma(a,function(a,b){e[b]=function(c){var d=Hl+"_"+b;var e=0===a.length?{}:Aa(a,[])(c);return{_simpleAdt:d,data:e,_simpleAdt_data:c}}});return oa(d,{constructors:e,match:function(a,d){var e=cb(d);if(e.length!==c.length)throw Error("Partial match");return yc(e,function(b){return a._simpleAdt===Hl+"_"+b?g.some(d[b]):g.none()}).getOrDie("Must find branch for constructor: "+b(a._simpleAdt))(a.data)}})}},pq=IR.generate({getFromFlash:[],disabled:[],fromClipboard:["rtf"]}),
  Pm={getFromFlash:pq.constructors.getFromFlash,disabled:pq.constructors.disabled,fromClipboard:pq.constructors.fromClipboard,match:pq.match},JR=function(a,b){var c=new RegExp(b,"i");return yc(a,function(a){return null!==a.match(c)?g.some({type:a,flavor:b}):g.none()})},Gx={isValidData:function(a){return void 0!==a&&void 0!==a.types&&null!==a.types},getPreferredFlavor:function(a,b){return yc(a,function(a){return JR(b,a)})},getFlavor:JR},Wc=IR.generate({event:["nativeEvent"],html:["container"],word:["html",
  "rtf"],text:["text"],images:["images"]}),Hx=aa.detect().browser,Rla=!(Hx.isIE()||Hx.isEdge()&&16>Hx.version.major),Sla=["^image/","file"],Tla=function(a){return Bb(a,"<html")&&(Bb(a,'xmlns:o="urn:schemas-microsoft-com:office:office"')||Bb(a,'xmlns:x="urn:schemas-microsoft-com:office:excel"'))},Ula=function(a){return Bb(a,"<meta")&&Bb(a,'id="docs-internal-guid')},Vla=function(a){return 0<a.length},KR=function(a,b){return Gx.getFlavor(a.types,b).map(function(b){return a.getData(b.type)}).filter(Vla)},
  Ix=function(a){return KR(a,"html")},Wla=function(a){return Ix(a).filter(Ula)},bj=function(a){return Rla?g.some(a.clipboardData).filter(Gx.isValidData):g.none()},LR=function(a){var b=p.fromTag("div");Ha.set(b,a);a=oq.clean(A.owner(b),b);b=p.fromTag("div");Ha.set(b,a);return Wc.constructors.html({container:b})},PZ={fromEvent:function(a){var b=function(a){return void 0===a.items?g.none():Gx.getPreferredFlavor(Sla,a.types).map(function(b){return Wc.constructors.images({images:a.items})})},c=function(a){return yc(a.types,
  function(b){return"text/plain"===b?g.some(a.getData(b)).map(function(a){return Wc.constructors.text({text:a})}):g.none()})};return{getWordData:function(){return bj(a).bind(function(a){return Ix(a).filter(Tla).map(function(b){var c=KR(a,"rtf");return Wc.constructors.word({html:b,rtf:c.fold(Pm.getFromFlash,function(a){return Pm.fromClipboard({rtf:a})})})})})},getGoogleDocsData:function(){return bj(a).bind(Wla).map(LR)},getImage:function(){return bj(a).bind(b)},getText:function(){return bj(a).fold(function(){var a=
  Zg.clipboardData;return void 0!==a?g.some(Wc.constructors.text({text:a.getData("text")})):g.none()},c)},getHtml:function(){return bj(a).bind(Ix).map(LR)},getOnlyText:function(){return bj(a).bind(function(a){var b=a.types;return 1===b.length&&"text/plain"===b[0]?c(a):g.none()})},getNative:function(){return Wc.constructors.event({nativeEvent:a})}}},fromHtml:function(a){return{getWordData:function(){return g.some(Wc.constructors.word({html:a,rtf:Pm.disabled()}))},getGoogleDocsData:g.none,getImage:g.none,
  getHtml:g.none,getText:g.none,getNative:yb("There is no native event"),getOnlyText:g.none}},fromText:function(a){return{getWordData:g.none,getGoogleDocsData:g.none,getImage:g.none,getHtml:g.none,getText:function(){return g.some(Wc.constructors.text({text:a}))},getNative:yb("There is no native event"),getOnlyText:g.none}}},Xla={resolve:Lb.create("ephox-sloth").resolve}.resolve("bin"),bB={bin:k(Xla)},MR=aa.detect(),Yla=function(a,b,c){b.control.block();a.dom().execCommand("paste");c();b.control.unblock()},
  Zla=function(a,b,c){setTimeout(c,1)},NR=MR.browser.isIE()&&10>=MR.browser.version.major,$la=NR?Yla:Zla,cB={willBlock:k(NR),run:function(a,b,c){return $la(a,b,c)}},aB=function(a){return E(a,function(a){return a.asset()})},Il=O("asset","image"),OR=function(a,b){return Pc.cata(a,function(a,d,e,f){m.set(b,"src",e);return!0},ed)},tf={assetImage:Il,createImages:function(a){var b=[],c=[];z(a,function(a){return Pc.cata(a,function(d,f,g,k){d=p.fromTag("img");m.set(d,"src",g);b.push(d);c.push(Il(a,d))},function(a,
  b,c){ud.error("Internal error: Paste operation produced an image URL instead of a Data URI: ",b)})});return db.paste(b,c)},findImages:function(a,b){var c=[],d=ia(a,function(a){return"img"===D.name(a)?[a]:Y.descendants(a,"img")});z(b,function(a){Pc.cata(a,function(b,e,g,k){z(d,function(b){m.get(b,"src")===g&&c.push(Il(a,b))})},t)});return c},updateSource:OR,updateSources:function(a,b){var c=[];z(a,function(a,e){e=b[e];OR(a,e)&&c.push(Il(a,e))});return c},browserBlobs:function(a){return Ce(a,function(a){return Ea.nu(function(b){var c=
  a.dom();Xc.imageToImageResult(c).then(function(d){d.toBlob().then(function(e){e=Gb(c.src,"blob:")?c.src:z1.createObjectURL(e);var f=Fa("image");e=Pc.blob(f,d,e);b(Il(e,a))})})})})}},ama=function(a){return Ea.nu(function(b){var c=Xc.imageResultToBlob(a,"image/png").then(function(a){Re.single(a).map(g.some).get(b)});return c["catch"].call(c,function(a){ud.warn(a);b(g.none())})})},QZ=function(a){var b=function(){return Ea.pure(a)};return Pc.cata(a.asset(),function(c,d,e){return/tiff$/.test(d.getType())?
  ama(d).map(function(b){return b.map(function(b){var c=a.image();bg.revokeObjectURL(e);tf.updateSource(b,c);return tf.assetImage(b,c)}).getOr(a)}):b()},b)},wb={blocking:function(a){return function(b){return function(c,d){b.block();return a(c,d).map(function(a){b.unblock();return a})}}},normal:function(a){return k(a)}},bma={convert:function(a){var b=bh("window.clipboardData.files"),c=void 0!==a.convertURL?a.convertURL:void 0!==a.msConvertURL?a.msConvertURL:void 0;return void 0!==b&&void 0!==c&&0<b.length?
  (b=Ce(b,function(b){var d=bg.createObjectURL(b);c.apply(a,[b,"specified",d]);return Re.singleWithUrl(b,d)}),g.some(b)):g.none()}},cma=function(){var a=g.none();return{convert:function(b){a=bma.convert(b)},listen:function(b){return a.fold(function(){return Ea.nu(function(a){a([])})},function(a){return a}).get(b)},clear:function(){a=g.none()}}},dma=function(a,b){return Lj.dataUriToBlobSync(b).map(function(b){return tf.assetImage(Re.single(b),a)})},ema=function(a,b){return Lj.uriToBlob(b).map(function(b){var c=
  Ea.nu(function(a){b.then(function(b){Re.single(b).get(a)})});return tf.assetImage(c,a)})},dB=function(a){var b=p.fromTag("div");P.append(b,a);return Y.descendants(b,"img[src]")},PR=function(a){return 0===a.indexOf("data:")&&-1<a.indexOf("base64")},eB=function(a){a=m.get(a,"src");return PR(a)||0===a.indexOf("blob:")},RZ=function(a){return ia(dB(a),function(a){var b=m.get(a,"src");return PR(b)?dma(a,b).toArray():0===b.indexOf("blob:")?ema(a,b).toArray():[]})},SZ=function(a){a=ka(a,function(a){return"img"!==
  D.name(a)||!eB(a)});return db.incomplete(a,[],"errors.local.images.disallowed")},fma={convert:function(a,b){if(0===a.length)throw"Zero length content passed to Hex conversion";for(var c=Array(a.length/2),d=0;d<a.length;d+=2){var e=a.substr(d,2);c[Math.floor(d/2)]=parseInt(e,16)}a=ez(c);return dz([a],{type:b})}},QR=ta.generate([{unsupported:["id","message","isEquation"]},{supported:["id","contentType","blob","isEquation"]}]),cj={unsupported:QR.unsupported,supported:QR.supported,cata:function(a,b,c){return a.fold(b,
  c)}},RR=function(a,b,c,d,e,f){return-1===a||-1===b?g.none():g.some({start:a,end:b,bower:c,regex:d,idRef:e,isEquation:f})},qq=function(a,b){if(-1===b)return b;var c=0,d=a.length;do{var e=a.indexOf("{",b);var f=a.indexOf("}",b);f>e&&-1!==e?(b=e+1,++c):(e>f||0>e)&&-1!==f&&(b=f+1,--c);if(b>d||-1===f)return-1}while(0<c);return b},gma=function(a,b,c,d,e){a=a.substring(c,d);return RR(c,d,a,/[^a-fA-F0-9]([a-fA-F0-9]+)\}$/,"i",e)},hma=function(a,b,c,d,e){a=a.substring(c,d);return RR(c,d,a,/([a-fA-F0-9]{64,})(?:\}.*)/,
  "s",e)},ima={identify:function(a,b){var c=a.indexOf("{\\pict{",b),d=qq(a,c),e=a.indexOf("{\\shp{",b),f=qq(a,e),h=a.indexOf("{\\mmathPict{",b),k=qq(a,h);k=-1!==h&&(h<c&&k>d||h<e&&k>f);h=u(hma,a,b,e,f,k);a=u(gma,a,b,c,d,k);return-1===c&&-1===e?g.none():-1===c?h():-1===e?a():e<c&&f>d?a():c<e&&d>f?h():c<e?a():e<c?h():g.none()},endBracket:qq},SR=function(a,b){return ima.identify(a,b)},TR=function(a){return 0<=a.indexOf("\\pngblip")?J.value("image/png"):0<=a.indexOf("\\jpegblip")?J.value("image/jpeg"):
  J.error("errors.imageimport.unsupported")},UR=function(a,b){return(a=a.match(b))&&a[1]&&0===a[1].length%2?J.value(a[1]):J.error("errors.imageimport.invalid")},VR=function(a){a=a.match(/\\shplid(\d+)/);return null!==a?g.some(a[1]):g.none()},jma=function(a){var b=a.bower,c=a.regex,d=a.isEquation;return VR(b).map(function(e){var f=a.idRef+e;return TR(b).fold(function(a){return cj.unsupported(f,a,d)},function(a){return UR(b,c).fold(function(a){return cj.unsupported(f,a,d)},function(b){return cj.supported(f,
  a,fma.convert(b,a),d)})})})},kma=function(a){for(var b=[],c=function(){return a.length},d=function(a){var c=jma(a);b=b.concat(c.toArray());return a.end},e=0;e<a.length;)e=SR(a,e).fold(c,d);return b},lma={nextBower:SR,extractId:VR,extractContentType:TR,extractHex:UR,images:function(a){a=a.replace(/\r/g,"").replace(/\n/g,"");return kma(a)}},uf={images:function(a){return lma.images(a)},toId:function(a){return cj.cata(a,function(a,c,d){return a},function(a,c,d,e){return a})},isEquation:function(a){return cj.cata(a,
  function(a,c,d){return d},function(a,c,d,e){return e})},toBlob:function(a){return cj.cata(a,function(a,c,d){return J.error(c)},function(a,c,d,e){return J.value(d)})}},mma=function(a){return hb(a,function(a,c){var b=uf.toId(c),e=uf.isEquation(c);return Va(a,function(a){return uf.toId(a)===b&&uf.isEquation(a)===e}).fold(function(){return a.concat([c])},function(b){return uf.toBlob(a[b]).isValue()?a:a.slice(0,b).concat(a.slice(b+1)).concat([c])})},[])},TZ={convert:function(a,b,c,d){var e=mma(b),f=[],
  g=!1;a=ia(a,function(a,b){var c=m.get(a,"data-image-id"),h="true"===m.get(a,"data-ms-equation");m.remove(a,"rtf-data-image");m.remove(a,"data-image-id");m.remove(a,"data-ms-equation");return"unsupported"===c?(g=!0,m.set(a,"alt",d("errors.imageimport.unsupported")),[]):qa(e,function(a){return uf.toId(a)===c&&uf.isEquation(a)===h}).fold(function(){ud.log("WARNING: unable to find data for image ",a.dom());return[]},function(b){return uf.toBlob(b).fold(function(b){g=!0;m.set(a,"alt",d(b));return[]},function(b){f.push(a);
  return[b]})})});Re.multiple(a).get(function(a){a=tf.updateSources(a,f);c(a,g)})}},WR=function(a){return Y.descendants(a,"[rtf-data-image]")},Rj={exists:function(a){return 0<WR(a).length},find:WR},XR=function(a){return a.officeStyles().getOr(!0)},YR=function(a){return a.htmlStyles().getOr(!1)},ZR=function(a){return a.isWord().getOr(!1)},pe={proxyBin:function(a){return{handle:function(b,c){return a.proxyBin().fold(function(){ud.error(b);return La.pure({response:db.cancel(),bundle:Xb.nu({})})},c)}}},
  backgroundAssets:function(a){return Ea.nu(function(b){a.backgroundAssets().fold(function(){b([])},function(a){a.listen(b)})})},merging:function(a){var b=ZR(a);return b&&XR(a)||!b&&YR(a)},mergeOffice:XR,mergeNormal:YR,isWord:ZR,isGoogleDocs:function(a){return a.isGoogleDocs().getOr(!1)},isInternal:function(a){return a.isInternal().getOr(!1)}},$R=function(a,b){var c=VZ(a,b);return function(a,b){var d=b.bundle(),e=b.response();return La.sync(function(a){c.get(pe.isWord(d),function(c){c=c.fold(function(){return{response:db.cancel(),
  bundle:b.bundle()}},function(a){return{response:e,bundle:Xb.nu({officeStyles:a.officeStyles,htmlStyles:a.htmlStyles})}});La.call(a,c)})})}},Jx={fixed:function(a,b){return function(c,d){return La.pure({response:d.response(),bundle:Xb.nu({officeStyles:a,htmlStyles:b})})}},fromConfig:$R,fromConfigIfNotForced:function(a,b){return function(c,d){var e=function(a){return La.pure({response:d.response(),bundle:Xb.nu({officeStyles:a,htmlStyles:a})})};return pe.isInternal(d.bundle())?e(!0):pe.isGoogleDocs(d.bundle())?
  e(!1):$R(a,b)(c,d)}}},nma={p:"p, li[data-converted-paragraph]"},oma=function(a){var b=function(){var b=p.fromTag("span");y.prepend(a,b);return b}();return{convertToPx:function(a){v.set(b,"margin-left",a);return parseFloat(v.get(b,"margin-left").match(/-?\d+\.?\d*/)[0])},destroy:function(){return F.remove(b)}}},pma=t,rma=function(a,b){var c=function(a){m.remove(a,"data-list-level");m.remove(a,"data-text-indent-alt");m.remove(a,"data-border-margin");v.remove(a,"margin-left");v.remove(a,"text-indent");
  Ma(v.getAllRaw(a),function(b,c){!c.startsWith("border")||"border-image"!==c&&"none"!==b.trim()&&"initial"!==b.trim()||v.remove(a,c)})},d=Y.descendants(a,"li[data-converted-paragraph]");z(d,function(a){m.remove(a,"data-converted-paragraph")});b&&(b=Y.descendants(a,"li"),z(b,function(b){var d=oma(a);var e=m.has(a,"data-tab-interval")?m.get(a,"data-tab-interval"):"36pt";e=d.convertToPx(e);e=qma(b,e,d).getOr({});c(b);d.destroy();v.setAll(b,e)}),b=Y.descendants(a,"ol,ul"),z(b,function(a){var b=Y.descendants(a,
  "li");v.getRaw(a,"margin-top").isNone()&&g.from(b[0]).each(function(b){v.set(a,"margin-top",v.get(b,"margin-top"))});v.getRaw(a,"margin-bottom").isNone()&&g.from(b[b.length-1]).each(function(b){v.set(a,"margin-bottom",v.get(b,"margin-bottom"))})}));m.remove(a,"data-tab-interval")},qma=function(a,b,c){var d=function(a){return m.has(a,"data-list-level")?parseInt(m.get(a,"data-list-level"),10):1};return v.getRaw(a,"text-indent").bind(function(e){return v.getRaw(a,"margin-left").map(function(f){var g=
  v.getRaw(a,"list-style").exists(function(a){return Bb(a,"none")}),k=m.has(a,"data-border-margin")?m.get(a,"data-border-margin"):"0px";g=g?d(a)+1:d(a);f=c.convertToPx(f)+c.convertToPx(k);g*=b;var q=m.has(a,"data-text-indent-alt")?c.convertToPx(m.get(a,"data-text-indent-alt")):c.convertToPx(e);k={};q=b/2*-1-q;0<q&&(k["text-indent"]=q+"px");f=f-g-q;k["margin-left"]=0<f?f+"px":"0px";return k})})},sma={process:function(a,b,c){c=c.mergeInline();(c?lz.inlineStyles:pma)(a,b,nma);rma(b,c)}},tma=function(a){var b=
  WZ(p.fromDom(Hb.body));return function(c,d){b.play(c,function(b,c){sma.process(b,c,{mergeInline:k(a)});return Ha.get(c)},d)}},uma=function(a,b,c,d){var e=function(b){La.call(a,{response:b,bundle:Xb.nu({})})};tma(b)(c,function(a){var b=qe.fromHtml(a);a=function(a){e(db.paste(b,a))};var c=p.fromTag("div");P.append(c,b);var f=Ia.all("img[src]",c);0===f.length?a([]):d?tf.browserBlobs(f).get(a):(z(f,F.remove),a=A.children(c),e(db.incomplete(a,[],"errors.local.images.disallowed")))})},vma={handle:function(a,
  b,c,d){var e=a.html();return La.sync(function(a){c.cleanDocument(e,b).get(function(c){c.fold(function(b){La.call(a,{response:db.error("errors.paste.process.failure"),bundle:Xb.nu({})})},function(c){void 0===c||null===c||0===c.length?La.call(a,{response:db.paste([],[]),bundle:Xb.nu({})}):uma(a,b,c,d)})})})}},wma={handle:function(a){a=ka(a,function(a){return"file"===a.kind&&/image/.test(a.type)});var b=E(a,function(a){return a.getAsFile()});return La.sync(function(a){Re.multiple(b).get(function(b){b=
  tf.createImages(b);La.call(a,{response:b,bundle:Xb.nu({})})})})}},xma=aa.detect(),aS=function(a){try{var b=a(),c=void 0!==b&&null!==b&&0<b.length?qe.fromHtml(b):[];return J.value(c)}catch(d){return ud.error(d),J.error("errors.paste.process.failure")}},bS=function(a){return a.fold(function(a){return La.error(a)},function(a){return La.pure({response:db.paste(a,[]),bundle:Xb.nu({})})})},cS=function(a,b,c,d){return aS(function(){return oq.go(a,xma,b,c,d)})},rq={direct:function(a,b,c){a=cS(a,b,c,!1);return bS(a)},
  internal:function(a,b){var c=aS(function(){return oq.internal(a,b)});return bS(c)},transfer:function(a,b,c,d,e){return cS(a,b,d,c).fold(function(a){return La.error(a)},function(a){return La.sync(function(b){e.get(function(c){c=tf.findImages(a,c);La.call(b,{response:db.paste(a,c),bundle:Xb.nu({})})})})})}},dS={internal:function(a,b,c){b=b.findClipboardTags(A.children(c)).getOr([]);z(b,F.remove);b=Ea.nu(function(a){a([])});return rq.transfer(a,c,!1,!0,b)},external:function(a,b,c,d,e){return rq.transfer(a,
  b,d,c,e)}},eS={encode:function(a){var b=p.fromTag("div");Vb.set(b,a);return Ha.get(b)},convert:function(a){a=a.trim().split(/\n{2,}|(?:\r\n){2,}/);a=E(a,function(a){return a.split(/\n|\r\n/).join("<br />")});return 1===a.length?a[0]:E(a,function(a){return"<p>"+a+"</p>"}).join("")}},yma={handle:function(a){var b=Wc.asText(a).getOrDie("Required text input for Text Handler");return La.sync(function(a){if(0<b.text().length){var c=b.text();c=eS.encode(c);c=eS.convert(c);c=qe.fromHtml(c);c=db.paste(c,[])}else c=
  db.cancel();La.call(a,{response:c,bundle:Xb.nu({})})})}},nd={plain:function(a,b,c){return yma.handle(a)},autolink:function(a,b){a=function(a,c){var d=p.fromTag("div");P.append(d,a);oq.preprocess(d);a=A.children(d);return La.pure({response:db.paste(a,c),bundle:b.bundle()})};var c=u(La.pass,b);return db.cata(b.response(),c,a,c,a)},noImages:function(){return function(a,b){return La.error("errors.local.images.disallowed")}},images:function(){return function(a,b){a=Wc.asImages(a).getOrDie("Must have image data for images handler");
  return wma.handle(a.images())}},handleInternal:function(a){return function(b,c){b=Wc.asHtml(b).getOrDie("Wrong input type for HTML handler");b=a.findClipboardTags(A.children(b.container()));b.each(function(a){z(a,F.remove)});b=b.isSome();return La.pure({response:c.response(),bundle:Xb.nu({isInternal:b})})}},nativeHtml:function(a,b){return function(c,d){c=Wc.asHtml(c).getOrDie("Wrong input type for HTML handler").container();var e=A.owner(b);d=d.bundle();if(pe.isInternal(d))return rq.internal(e,c);
  a(c);d=pe.merging(d);return rq.direct(e,c,d)}},external:function(a,b){return function(c,d){var e=d.bundle();return pe.proxyBin(e).handle("There was no proxy bin setup. Ensure you have run proxyStep first.",function(c){var d=pe.merging(e),f=pe.isWord(e),g=pe.isInternal(e),k=pe.backgroundAssets(e),m=A.owner(a);return g?dS.internal(m,b,c):dS.external(m,c,d,f,k)})}},wordimport:function(a,b){return function(c,d){c=Wc.asWord(c).getOrDie("Wrong input type for Word Import handler");d=pe.mergeOffice(d.bundle());
  return vma.handle(c,d,a,b)}},setBundle:function(a){return function(b,c){b=Xb.merge(c.bundle(),Xb.nu(a));return La.pure({response:c.response(),bundle:b})}},none:function(a,b){return La.cancel()}},zma=function(a,b){return wd.descendant(a,function(a){return m.has(a,"style")?-1<m.get(a,"style").indexOf("mso-"):!1})},Ama=function(a,b){a=Ha.get(a);return gb.isWordContent(a,b)},YZ={isWord:function(a,b){var c=a.browser;return(c.isIE()&&11<=c.version.major?zma:Ama)(b,a)}},Lr=aa.detect(),ZZ=function(a){return Xa(a,
  function(a){return m.has(a,"id")&&Gb(m.get(a,"id"),"docs-internal-guid")})},Bma=function(a,b){return a.isSupported()?b.getWordData():g.none()},Cma=function(a){return a.getNative()},Dma=function(a){return a.getImage()},Ema=function(a){return a.getHtml()},Fma=function(a){return a.getText()},Gma=function(a){return a.getOnlyText()},Hma=function(a){return a.getGoogleDocsData()},Hg=function(a,b,c,d){return{_label:a,label:k(a),getAvailable:b,steps:k(c),capture:k(d)}},Zf={wordimport:function(a,b,c,d){return Hg("Word Import pasting",
  u(Bma,a),[wb.normal(nd.setBundle({isWord:!0})),wb.normal(Jx.fromConfig(b,c)),wb.normal(nd.wordimport(a,c.allowLocalImages)),wb.blocking($Z(c,gB(d,c))),wb.normal(Qj())],!0)},googledocs:function(a,b,c){return Hg(" pasting",Hma,[wb.normal(nd.setBundle({officeStyles:!1,htmlStyles:!1})),wb.normal(nd.nativeHtml(b,c)),wb.normal(Kr(a)),wb.normal(Qj())],!0)},image:function(a){return Hg("Image pasting",Dma,[wb.normal(!1===a.allowLocalImages?nd.noImages():nd.images()),wb.normal(Qj())],!0)},nativeHtml:function(a,
  b,c,d){return Hg("Outside of Textbox.io pasting HTML5 API (could be internal)",Ema,[wb.normal(nd.handleInternal(b.intraFlag)),wb.normal(Jx.fromConfigIfNotForced(a,b)),wb.normal(nd.nativeHtml(c,d)),wb.normal(Kr(b)),wb.normal(Qj())],!0)},text:function(){return Hg("Plain text pasting",Fma,[wb.normal(nd.plain),wb.normal(nd.autolink)],!0)},onlyText:function(){return Hg("Only plain text is available to paste",Gma,[wb.normal(nd.plain),wb.normal(nd.autolink)],!0)},none:function(){return Hg("There is no valid way to paste",
  g.some,[wb.normal(nd.none)],!1)},fallback:function(a,b,c,d,e,f){return Hg("Outside of Textbox.io pasting offscreen (could be internal)",Cma,[wb.normal(XZ(d,c,e,b.intraFlag,cma)),wb.normal(Jx.fromConfigIfNotForced(a,b)),wb.normal(nd.external(e,b.intraFlag)),wb.blocking(gB(f,b)),wb.normal(Kr(b)),wb.normal(Qj())],!1)}},c_={responsive:function(){var a=na(g.none()),b=H.create({crashed:r([]),timeout:r([])});return{start:function(c,d,e,f){var h=d,k=Mr(function(){e()?Vh(k):0>=h?(b.trigger.timeout(),Vh(k)):
  f()&&(Vh(k),b.trigger.crashed());h--},c);a.set(g.some(k))},stop:function(){a.get().each(function(a){Vh(a)})},events:b.registry}}},Yf=kC.install("ephox.flash"),Nr=aa.detect(),d_=g.none(),fS=function(a){return p.fromHtml("<p>"+a("cement.dialog.flash.press-escape")+"</p>")},Kx={paste:function(a){var b=p.fromTag("div");n.add(b,td.resolve("flashbin-helpcopy"));var c=aa.detect().os.isOSX()?["\u2318"]:["Ctrl"];var d=p.fromHtml("<p>"+a("cement.dialog.flash.trigger-paste")+"</p>");c=p.fromHtml('<div><span class="ephox-polish-help-kbd">'+
  c+'</span> + <span class="ephox-polish-help-kbd">V</span></div>');n.add(c,td.resolve("flashbin-helpcopy-kbd"));P.append(b,[d,c,fS(a)]);return b},noflash:function(a){var b=p.fromTag("div");n.add(b,td.resolve("flashbin-helpcopy"));var c=p.fromHtml("<p>"+a("cement.dialog.flash.missing")+"</p>");P.append(b,[c,fS(a)]);return b},indicator:function(a){var b=p.fromTag("div");n.add(b,td.resolve("flashbin-loading"));var c=p.fromTag("div");n.add(c,td.resolve("flashbin-loading-spinner"));var d=p.fromTag("p");
  a=a("loading.wait");Ha.set(d,a);m.set(d,"aria-label",a);P.append(b,[c,d]);return b}},f_=aa.detect(),i_=function(a,b,c,d){b=Kx.noflash(d);y.append(a,b);return{reset:t}},h_=function(a,b,c,d){var e=Kx.paste(d),f=Kx.indicator(d);P.append(a,[f,e,b.element()]);a=function(){v.set(e,"display","block");v.set(f,"display","none");c()};b.events.spin.bind(function(){v.set(e,"display","none");v.set(f,"display","block");v.remove(f,"height");v.remove(f,"padding");c()});b.events.reset.bind(a);b.events.hide.bind(function(){v.setAll(f,
  {height:"0",padding:"0"})});return{reset:a}},gS=aa.detect(),Ima=gS.deviceType.isiOS()||gS.deviceType.isAndroid(),Jma=function(a){var b=en.addScript(a+"/wordimport.js",ca);b.get(function(a){a.fold(function(a){ud.error("Unable to load word import: ",a)},t)});return{isSupported:k(!0),cleanDocument:function(a,d){return b.map(function(b){return b.map(function(b){return b.cleanDocument(a,d)})})}}},Kma=k({isSupported:k(!1),cleanDocument:k($k.error("not supported"))}),Lma=Ima?Kma:Jma,Mma="b i u sub sup strike".split(" "),
  Nma=function(a){z(A.children(a),function(a){D.isElement(a)&&!A.hasChildNodes(a)&&U(Mma,D.name(a))&&F.remove(a)})},Oma=function(a,b){a=A.children(a);z(a,function(a){if(b(a)){var c=A.children(a),e=p.fromTag("div",A.owner(a).dom());P.append(e,c);y.before(a,e);F.remove(a)}})},n_={consolidate:function(a,b){A.nextSibling(a).filter(b).each(function(b){var c=A.children(b);P.append(a,c);F.remove(b)});Oma(a,b);Nma(a)}},iB=bB.bin(),jB=iB+Fa(""),m_=ae.onDirection("-100000px","100000px"),Pma=function(a){return{startContainer:a.start,
  startOffset:a.soffset,endContainer:a.finish,endOffset:a.foffset}},q_={set:function(a,b){Wa.setExact(a,b.startContainer(),b.startOffset(),b.endContainer(),b.endOffset())},get:function(a,b){return Wa.getExact(a).map(Pma)}},v_=function(a,b,c,d){var e=s_(a.uiContainer(),d),f=function(a){b.filterDom(b.paste(),a)},g=t_(x,Sj.intraFlag(),c);return function(a){var b=Lma(g.baseUrl),c=u(j_,e),d=p_(void 0!==g.pasteBinAttrs?g.pasteBinAttrs:{});b=[Zf.onlyText(),Zf.wordimport(b,e,g,c),Zf.googledocs(g,f,a),Zf.nativeHtml(e,
  g,f,a),Zf.image(g)];a=Zf.fallback(e,g,f,d,a,c);return ZA(b,a)}},z_=function(a){for(var b=[],c=a.start.charCodeAt(0);c<=a.finish.charCodeAt(0);c++)b.push(String.fromCharCode(c));return b},$f=function(a){return{start:a,finish:a}},C_={controls:function(a){var b=a+"-";a=T.div();n.add(a,B.resolve(b+"dialog-controls"));var c=sd.button(b,"cancel","button.cancel"),d=sd.button(b,"insert","specialchar.insert");sd.makeNormal(c.element());sd.makeDefault(d.element());P.append(a,[c.element(),d.element()]);b=H.create({insert:Q([],
  d.events.click),cancel:Q([],c.events.click)});return{element:k(a),ok:k(d),cancel:k(c),destroy:function(){d.destroy();c.destroy()},events:b.registry}}},Qma=function(a){var b=p.fromTag("span");n.add(b,B.resolve("special-char"));var c=p.fromHtml(a);m.setAll(b,{"data-ephox-polish-special-char":a,"data-ephox-polish-char-code":a.charCodeAt(0).toString(16),tabindex:"-1"});Vg.gridcell(b);y.append(b,c);return b},Rma=function(a,b){var c=p.fromTag("div");ma.add(c,[B.resolve("special-char-row"),B.resolve("special-char-row-"+
  b)]);Vg.row(c);z(a,function(a){y.append(c,Qma(a))});return c},Sma=function(a,b,c){var d=p.fromTag("div");n.add(d,B.resolve(b));Vg.base(d,x.translate("specialchar.grid"));a=k1(a,c);a=E(a,function(a){return Rma(a,b)});P.append(d,a);return d},B_={generateItems:function(a){var b=600>=Math.min(window.innerWidth,window.innerHeight)?12:16;return Lf(a,function(a,d){a=Sma(a,d,b);return Rg(x.translate("specialchar."+d),gA(a))})}},D_=function(a){var b={item:k(".ephox-pastry-statebutton.ephox-pastry-tablayout-item")},
  c=Ba.flow({trigger:Kb.button,executeOnArrow:!0});return ha.flow(a.menu(),b,c)},Tma=function(a){return Db.closest(a,".ephox-pastry-tablayout-active")},E_=function(a){var b={row:k(".ephox-pastry-tablayout-active ."+B.resolve("special-char-row")),cell:k(".ephox-pastry-tablayout-active ."+B.resolve("special-char"))},c=Ba.tabular({trigger:Kb.click,isValid:Tma});return ha.tabular(a.body(),b,c)},hS=ta.generate([{single:["element"]},{range:["start","soffset","finish","foffset"]}]),Qm={cata:function(a,b,c){return a.fold(b,
  c)},single:hS.single,range:function(a,b,c,d){var e=hd.after(c,d,a,b),f=e?W.point(a,b):W.point(c,d);a=e?W.point(c,d):W.point(a,b);return hS.range(f.element(),f.offset(),a.element(),a.offset())}},iS=O("suggestions","ignore"),dj=function(a){var b=new RegExp(mb(),"g");return a.replace(b,"").replace(/[\u2018\u2019]/g,"'")},c0=function(a){var b={},c=function(a){return b.hasOwnProperty(a)&&void 0!==b[a]?b[a]:{}},d=function(a,d){var e=c(a);d(e);b[a]=e},e=function(a,b){a=c(a);return b(a)},f=function(a,b,c){d(a,
  function(a){var d=dj(b);a.hasOwnProperty(d)&&void 0!==a[d]||(a[d]=iS(g.some(c),!1))})},h=function(a,b){d(a,function(a){var c=dj(b),d=a.hasOwnProperty(c)?a[c]:void 0;d=void 0!==d?d.suggestions():g.none();d=iS(d,!0);a[c]=d})};Ma(void 0!==a?a:{},function(a,b){Ma(a,function(a,c){!0===a.ignore&&h(b,c);void 0!==a.suggestions&&f(b,c,a.suggestions)})});return{add:f,get:function(a,b){return e(a,function(a){var c=dj(b);return a.hasOwnProperty(c)?g.from(a[c]):g.none()})},ignore:h,suggestions:function(a,b){return e(a,
  function(a){var c=dj(b);return(a.hasOwnProperty(c)?g.from(a[c]):g.none()).bind(function(a){return a.suggestions()})})},state:function(){return eb(b,function(a,b){return eb(a,function(a,b){return{ignore:a.ignore(),suggestions:a.suggestions().getOr([])}})})},destroy:function(){b={}}}},Rr={configure:function(a){a.add(a.internal(),"ephox-cram-annotation-wrap",Ta.unwrap);a.add(a.output(),"ephox-cram-annotation-wrap",Ta.unwrap);a.add(a.paste(),"ephox-cram-annotation-wrap",Ta.unwrap);a.addExcludedContext([".ephox-cram-annotation-wrap"])},
  isWrap:function(a){return n.has(a,"ephox-cram-annotation-wrap")}},Uma={en_au:"en_gb",en_bz:"en_gb",en_ca:"en_gb",en_gb:"en_gb",en_ie:"en_gb",en_in:"en_gb",en_jm:"en_gb",en_my:"en_gb",en_nz:"en_gb",en_ph:"en_gb",en_sg:"en_gb",en_tt:"en_gb",en_za:"en_gb",en_zw:"en_gb",en_us:"en_us",en:"en_us"},Vma="da de en en_au en_br en_gb en_uk en_us es fi fr it nb nl pt pt_pt sv".split(" "),od=function(a,b){return{value:k(a),textkey:k(b),icon:g.none}},Wma=function(a){var b=ua(Is.localeList(),Uma);return Is.determineFrom(a,
  b).filter(function(a){return U(Vma,a)})},vf={determine:function(a){return"no.language"===a?g.some(a):Wma(a)},get:function(){return[od("no.language",x.key("spelling.none")),od("en_us",x.key("parlance.en_us")),od("en_gb",x.key("parlance.en_gb")),od("da",x.key("parlance.da")),od("de",x.key("parlance.de")),od("es",x.key("parlance.es")),od("fi",x.key("parlance.fi")),od("fr",x.key("parlance.fr")),od("it",x.key("parlance.it")),od("nb",x.key("parlance.no")),od("nl",x.key("parlance.nl")),od("pt",x.key("parlance.pt_br")),
  od("pt_pt",x.key("parlance.pt_pt")),od("sv",x.key("parlance.sv"))]},isOn:function(a){return"no.language"!==a},offKey:k("no.language")},J_=function(a,b){var c=vf.get();return{"spelling.dropdown":{name:"spellcheck",textkey:x.key("spelling.menu"),menuTextkey:"",updateDropdown:function(b){b.populate([{label:g.none,items:k(c)}]);var d=a.profile().spelling().get();Da.on(d).fold(b.untick,t,b.tick)},action:function(c){a.profile().spelling().setAndCache(c);Gb(c,"en")||a.profile().autocorrect().set(!1);b.trigger.change(c)},
  values:c,render:g.none(),describe:function(a){return x.key("spelling.menu")},hasPopup:!0,toggle:!1}}},K_=function(a,b,c){var d=a.profile().spelling().get()!==vf.offKey();return{"spelling.general":{toggle:!0,value:"spellcheck",textkey:x.key("cog.spellcheck"),action:function(){var e=(d=!d)?b:vf.offKey();a.profile().spelling().setAndCache(e);c.trigger.change(e)},updateGeneral:function(a){d?a.select():a.deselect()},icon:!1}}},M_=O("area","f"),Jl={stop:k("trampoline.stop"),run:function(a){for(;"trampoline.stop"!==
  a;)a=a()}},ej=ta.generate([{inline:["item","mode","lang"]},{text:["item","mode"]},{empty:["item","mode"]},{boundary:["item","mode","lang"]},{concluded:["item","mode"]}]),jS=function(a,b,c,d){var e=a.property().isElement(b)?g.from(a.attrs().get(b,"lang")):g.none();return a.property().isText(b)?ej.text(b,c):d(b,c)?ej.concluded(b,c):a.property().isBoundary(b)?ej.boundary(b,c,e):a.property().isEmptyTag(b)?ej.empty(b,c):ej.inline(b,c,e)},Xma=function(a,b,c,d){return Ca.walk(a,b,c,Ca.walkers().right(),
  void 0).fold(function(){return ej.concluded(b,c)},function(b){return jS(a,b.item(),b.mode(),d)})},kS=function(a,b,c,d,e,f){return function(){return b.fold(function(b,g,k){(g===Ca.advance?d.openInline:d.closeInline)(k,b);return Kl(a,b,g,c,d,e,f)},function(b,g){var h=e(a,b);d.addDetail(h);return c(b,g)?Jl.stop():Kl(a,b,g,c,d,e,f)},function(b,g){d.addEmpty(b);return Kl(a,b,g,c,d,e,f)},function(b,g,k){var h=f.assess(b);return Qg.cata(h,function(h){return g!==Ca.backtrack?Kl(a,b,Ca.sidestep,c,d,e,f):Jl.stop()},
  function(h){(g===Ca.advance?d.openBoundary:d.closeBoundary)(k,b);return Kl(a,b,g,c,d,e,f)},function(a){return Jl.stop()})},function(a,b){return Jl.stop()})}},Kl=function(a,b,c,d,e,f,g){b=Xma(a,b,c,d);return kS(a,b,d,e,f,g)},Yma={walk:function(a,b,c,d,e,f){var g=function(b,d){return a.eq(b,c)&&(d!==Ca.advance||a.property().isText(b)||0===a.property().children(b).length)},k=zi.nu(d),m=jS(a,b,Ca.advance,g);Jl.run(function(){return kS(a,m,g,k,e,f)});return k.done()}},Zma=Aa(["elements","lang","words"],
  []),$ma={fromWalking:function(a,b){a=E(b,function(a){var b=a.details();a=a.lang();var c=E(b,function(a){return a.text()}).join("");b=E(b,function(a){return a.item()});c=ZL.words(c);return Zma({lang:a,words:c,elements:b})});return{zones:k(a)}}},ana=function(a,b,c,d,e,f){return(a.eq(b,c)?g.some(b):a.property().parent(b)).map(function(g){g=zi.calculate(a,g).getOr(d);return Yma.walk(a,b,c,g,e,f)})},sq=function(a,b,c,d,e,f){b=zd.subset(a,b,c).bind(function(b){return 0===b.length?g.none():ana(a,b[0],b[b.length-
  1],d,e,f)}).getOr([]);return $ma.fromWalking(a,b)},Lx=function(a,b){return function(c,d){return c.eq(d,a.item())?a:c.eq(d,b.item())?b:Ff.detail(c,d)}},lS=function(){return{zones:k([])}},Ch={fromRange:function(a,b,c,d,e){b=Qk.getEdges(a,b,c,k(!1));c=Lx(b.left(),b.right());return sq(a,b.left().item(),b.right().item(),d,c,e)},transformEdges:Lx,fromBounded:function(a,b,c,d,e){return sq(a,b,c,d,Ff.detail,e)},fromBoundedWith:sq,fromInline:function(a,b,c,d){b=Qk.byBoundary(a,b);var e=Lx(b.left(),b.right());
  return b.isEmpty()?lS():sq(a,b.left().item(),b.right().item(),c,e,d)},empty:lS},nS=function(a,b,c,d){return a.property().isBoundary(b)?Ch.fromBounded(a,b,b,c,d):a.property().isEmptyTag(b)?mS():Ch.fromInline(a,b,c,d)},mS=function(){return Ch.empty()},Mx={single:nS,range:function(a,b,c,d,e,f,g){b=ad.toLeaf(a,b,c);d=ad.toLeaf(a,d,e);return a.eq(b.element(),d.element())?nS(a,b.element(),f,g):Ch.fromRange(a,b.element(),d.element(),f,g)},empty:mS},oS=nb(),Rm={single:function(a,b,c){return Mx.single(oS,
  a,b,c)},range:function(a,b,c,d,e,f){return Mx.range(oS,a,b,c,d,e,f)},empty:function(){return Mx.empty()}},kB={update:function(a,b,c){var d=cb(c);z(d,function(d){a.add(b,d,c[d])});return d},getInCache:function(a,b,c){return ka(c,function(c){return a.get(b,c.word()).fold(k(!1),function(a){return a.suggestions().isSome()})})}},bna={anything:k({assess:Qg.inView})}.anything(),Nx=function(a,b,c,d,e,f){a=Ch.fromBoundedWith(a,b,c,d,f,bna).zones();1===a.length?(a=a[0],e=a.lang()===e?g.some(a):g.none()):e=
  g.none();return e},pS=function(a,b,c,d,e){return Nx(a,b,c,d,e,Ff.detail)},tq={fromRange:function(a,b,c,d,e){var f=zi.strictBounder(d,e);b=Qk.getEdges(a,b,c,f);c=Ch.transformEdges(b.left(),b.right());return Nx(a,b.left().item(),b.right().item(),d,e,c)},fromBounded:pS,fromInline:function(a,b,c,d){var e=zi.strictBounder(c,d);e=Qk.getEdges(a,b,b,e);var f=Ch.transformEdges(e.left(),e.right());e.isEmpty()?(f=a.property().isText(b)?a.property().getText(b):a.property().children(b).length,e=ad.toLeaf(a,b,
  0),b=ad.toLeaf(a,b,f),a=pS(a,e.element(),b.element(),c,d)):a=Nx(a,e.left().item(),e.right().item(),c,d,f);return a},empty:function(){return g.none()}},qS=function(a,b,c,d){return a.property().isBoundary(b)?tq.fromBounded(a,b,b,c,d):a.property().isEmptyTag(b)?tq.empty():tq.fromInline(a,b,c,d)},rS={single:qS,range:function(a,b,c,d,e,f,g){b=ad.toLeaf(a,b,c);d=ad.toLeaf(a,d,e);return a.eq(b.element(),d.element())?qS(a,b.element(),f,g):tq.fromRange(a,b.element(),d.element(),f,g)}},sS=nb(),cna={single:function(a,
  b,c){return rS.single(sS,a,b,c)},range:function(a,b,c,d,e,f){return rS.range(sS,a,b,c,d,e,f)}},tS=function(a){return ia(a,function(a){return cd.descendants(a,D.isText)})},uq={textnodes:tS,text:function(a){a=tS(a);return E(a,function(a){return D.isText(a)?Ya.get(a):""}).join("")},parsed:function(a,b,c){return g.from(a[0]).bind(function(a){return cna.single(a,b,c).bind(function(a){a=a.words();return 1===a.length?g.some(a[0]).map(function(a){return a.word()}):g.none()})})},children:function(a){return ia(a,
  A.children)}},dna={clobber:function(a,b){var c=uq.children(a),d=uq.textnodes(a);return g.from(a[0]).bind(function(e){P.before(e,c);e=g.from(d[0]);e.each(function(a){Ya.set(a,b)});z(d.slice(1),function(a){Ya.set(a,"")});z(a,F.remove);return e})}},uS=gw.resolve("annotation"),vS=gw.resolve("lingo"),wS=hw.resolve("annotation-wrap"),fj={nu:function(){var a=p.fromTag("span");n.add(a,wS);m.set(a,"aria-invalid","spelling");return wi.nu(a)},set:function(a,b,c){m.set(a,uS,c);m.set(a,vS,b)},label:k(wS),detail:function(a){return xg.id(a).bind(function(b){return g.from(m.get(a,
  uS)).bind(function(c){return g.from(m.get(a,vS)).map(function(a){return{id:k(b),word:k(c),lang:k(a)}})})})}},ena=hw.resolve("wrap-disabled"),fna=function(a){a=xg.all(a);z(a,function(a){n.remove(a,ena)})},gna=O("id","elements","word","lang"),xS={success:function(a){return{fold:function(b,c){c(a)}}},fail:function(a){return{fold:function(b,c){b(a)}}}},hna=function(a,b){var c={};z(a,function(a){xg.marker(a,b.label()).filter(ja.inBody).each(function(a){b.detail(a).each(function(b){var d=b.id(),e=b.word();
  b=b.lang();var f=xg.all(a);0<f.length&&(c[d]=gna(d,f,e,b))})})});return c},yS=function(a,b,c,d){var e=uq.text(a);a=uq.parsed(a,c,d);return e===b&&a.is(b)},ina=function(a,b,c){a=Ze(a);return E(a,function(a){return a.lang()===c&&yS(a.elements(),a.word(),b,a.lang())?xS.success(a):xS.fail(a)})},jna={validate:yS,verify:function(a,b,c,d,e){b=hna(a.elements(),b);a=ina(b,e,a.lang());z(a,function(a){var b=function(a){return function(b){z(b.elements(),a)}};a.fold(b(d),b(c))})}},zS=function(a){return xg.marker(a,
  fj.label())},Qr={highlight:function(a,b,c,d){jna.verify(b,fj,fna,F.unwrap,a.lang());c=ml.matchWords(b.elements(),c,d);c=ml.annotates(c,fj.label());return ia(c,function(c){return c.current().fold(function(){var d=c.match(),e=d.word();if(a.ignore(d))return[];d=wi.wrapper(d.elements(),fj.nu)||[];z(d,function(a){xg.set(a,c.id());fj.set(a,b.lang(),e)});return[Gp.created(d)]},function(a){return[Gp.preserved(a)]})})},marker:zS,substitute:function(a,b){a=zS(a).fold(k([]),xg.all);return dna.clobber(a,b)},
  detail:function(a){return fj.detail(a)}},P_={highlight:function(a,b,c,d){var e={operation:a,internal:a,ignore:k(!1),lang:k(d)},f=E(c,function(a){return a.word()}),g=ka(f,function(a,b){return Gc(f,a).filter(function(a){return a===b}).isSome()});e.operation(function(){Qr.highlight(e,b,g,k(!1))})}},kna=function(a,b){return Ea.nu(function(c){var d={words:E(a.words(),function(a){return dj(a.word())})};b.correction(d,a.lang(),function(b){b=J.value({spelling:k(b),zone:k(a)});c(b)},function(a){a=J.error(Error(a));
  c(a)})})},Q_={scan:function(a,b,c){var d=function(b){var c=b.zone(),d=kB.update(a,c.lang(),b.spelling());b=ka(c.words(),function(a){a=dj(a.word());return U(d,a)});return{zone:k(c),words:k(b)}};c=E(c,function(a){return kna(a,b)});return Pl(c,Ea.nu).map(function(a){a=ia(a,function(a){return a.fold(k([]),GB)});return E(a,d)})}},mB={active:function(a){var b={};a.autocorrect().get(function(a){a.fold(function(a){console.log("Error loading autocorrect list")},function(a){b=a.corrections})});return{lookup:function(a){return b.hasOwnProperty(a)?
  g.from(b[a]):g.none()}}},inactive:function(){return{lookup:g.none}}},lna=Cc([za("language"),za("words")]),S_={many:k(lna)},mna=function(a,b){return zc(a,b).getOrThunk(function(){return jm()})},Ox=Fa("good-spelling"),lB={execute:function(a,b,c,d,e,f){var g=mna(b,c);f=lm.multiple(function(b,d){return a.execute({language:c,words:b})},g,d,function(a){return a.spell},ca,e,void 0!==f?f:!1);b[c]=g;return hf.mapSync(f,function(a){z(d,function(b){ye(a,b)||g.set(b,Ox,e)});var b={};Ma(a,function(a,c){g.get(e,
  c).is(Ox)||(b[c]=a)});return b})},initCaches:function(a){var b={};Ma(void 0!==a?a:{},function(a,d){b[d]=jm(a)});return b},correct:k(Ox)},nna={image:k("1"),spelling:k("1")},AS=function(a,b){return(je(a,"/")?a:a+"/")+b},U_={corsQuery:function(a){return AS(a,"version")},spelling:function(a){return AS(a,nna.spelling())+"/"}},Ll=function(a){a="data-"+B.resolve(a);return k(a)},Ee={value:Ll("spelling-value"),type:Ll("spelling-type"),overflow:Ll("spelling-overflow"),overflowMenu:Ll("spelling-overflow-menu"),
  spelling:Ll("spelling-suggestion")},BS=O("primary","secondary","submenus"),ona=O("value","text","attrs"),pna=O("textkey","value","items"),Z_={generate:function(a,b){if(a.length>b){var c=a.slice(0,b);var d=ona(Ee.overflow(),x.translate("spelling.context.more"),{});b=a.slice(b);a={};a[Ee.overflow()]=Ee.overflowMenu();b=pna(x.key("spelling.context.morelabel"),Ee.overflowMenu(),b);c=BS(c.concat([d]),[b],a)}else c=BS(a,[],{});return c}},Y_=O("value","text","attrs"),oB=aa.detect().browser,d0=Aa("communication profile content undo viewable cache url autocorrectOn language fromServiceState multilingual".split(" "),
  []),CS=function(a){a=p.fromTag(a);var b=p.fromText(mb());y.append(a,b);n.add(a,Rb.styleSpan());return a},DS=function(a,b,c,d){var e=CS(d);A.firstChild(e).each(function(d){a(c,e);b.setSelection(d,0,d,0)})},ES={nu:CS,insertAfter:u(DS,y.after),insertBefore:u(DS,y.before)},FS=aa.detect().browser,GS=function(a,b){return kb.toLeaf(a,b)},qna=function(a){return D.isText(a)&&0!==Ya.get(a).trim().length},rna=function(a){return D.isElement(a)&&"br"===D.name(a)},sna=function(a){return Xa([qna,rna],function(b){return b(a)})},
  tna=function(a){return D.isText(a.element())&&0===a.offset()||D.isElement(a.element())},una=function(a,b,c){var d=k(a);return(!1===b&&tna(a)?g.some(!0):g.none()).fold(d,function(b){return wc.seekLeft(a.element(),sna,c).fold(d,function(a){return W.point(a,D.isText(a)?Ya.get(a).length:0)})})},vna=function(a,b){return N.eq(a.element(),b.element())},wf={context:function(a){return a.getSelection().bind(function(b){if(b.collapsed()){var c=b.startContainer();return tb.cell(c,a.isRoot).bind(function(d){return tb.table(c,
  a.isRoot).map(function(a){return{cell:k(d),table:k(a),start:k(c),selection:k(b)}})})}return g.none()})},selectedCells:function(a,b){return $b.cata(a.get(),k([]),ca,function(a){var c=FS.isFirefox()?GS(a.startContainer(),a.startOffset()):W.point(a.startContainer(),a.startOffset()),e=FS.isFirefox()?GS(a.endContainer(),a.endOffset()):W.point(a.endContainer(),a.endOffset());a=una(e,a.collapsed()||vna(c,e),b);return nf.sharedOne(function(a){return tb.cell(a,b)},[c.element(),a.element()]).toArray()})}},
  gj={none:function(a){return{fold:function(b,c,d,e){return b(a)}}},first:function(a){return{fold:function(b,c,d,e){return c(a)}}},middle:function(a,b){return{fold:function(c,d,e,f){return e(a,b)}}},last:function(a){return{fold:function(b,c,d,e){return e(a)}}}},HS=function(a,b){return tb.table(a,b).bind(function(b){var c=tb.cells(b);return Va(c,function(b){return N.eq(a,b)}).map(function(a){return{index:k(a),all:k(c)}})})},vq={next:function(a,b){return HS(a,b).fold(function(){return gj.none(a)},function(b){return b.index()+
  1<b.all().length?gj.middle(a,b.all()[b.index()+1]):gj.last(a)})},prev:function(a,b){return HS(a,b).fold(function(){return gj.none()},function(b){return 0<=b.index()-1?gj.middle(a,b.all()[b.index()-1]):gj.first(a)})}},uB={upOrLeft:function(a){wf.context(a).each(function(b){vq.prev(b.cell()).fold(t,function(){Aj.isFirstInContent(a,b.table())&&Pg.isLeft(b.cell(),b.selection())&&ES.insertBefore(a,b.table(),"p")},t,t)})},right:function(a){wf.context(a).each(function(b){vq.next(b.cell()).fold(t,t,t,function(){Aj.isLastInContent(a,
  b.table())&&Pg.isRight(b.cell(),b.selection())&&ES.insertAfter(a,b.table(),"p")})})}},v0={widget:function(a){var b=a.content(),c=O("value","icon","textkey"),d=c("aligntop",g.some(va.resolve("aligntop")),x.key("table.cell.alignment.top")),e=c("alignmiddle",g.some(va.resolve("alignmiddle")),x.key("table.cell.alignment.middle"));c=c("alignbottom",g.some(va.resolve("alignbottom")),x.key("table.cell.alignment.bottom"));var f=[d,e,c];d=function(a){return function(b){v.set(b,"vertical-align",a)}};var h=
  {aligntop:d("top"),alignmiddle:d("middle"),alignbottom:d("bottom")},l=g.none(),m=function(a,b){a.enable();return v.getRaw(b,"vertical-align").fold(function(){return Da.on("aligntop")},function(a){return"middle"===a?Da.on("alignmiddle"):"bottom"===a?Da.on("alignbottom"):Da.on("aligntop")})};return{name:"cell-alignment",textkey:x.key("table.cell.alignment.toolbar"),menuTextkey:x.key("table.cell.alignment.toolbar"),action:function(c){b.focus();var d=wf.selectedCells(a.selections(),b.isRoot);z(d,h[c]);
  b.uiChanged()},updateDropdown:function(c){var d=wf.selectedCells(a.selections(),b.isRoot);0<d.length?d=m(c,d[0]):(c.disable(),d=Da.off());c.populate([{label:g.none,items:k(f)}]);am.updateMenu(c,d,Da.on(),f,l)},values:f,render:l,tooltip:rb.get,toggle:!1,describe:function(a){return x.translate("alignment.describe",x.get(a.textkey()))}}}},wna={cssNamespace:"table-cell-border",i18nNamespace:"table.cell.border",property:"border-width",tag:"table",specials:[["thin","medium","thick"]]},u0={widget:function(a){var b=
  a.content(),c=Em(wna);c.initLayout();S.dialog(c.element(),x.translate("aria.table.cell.border.size"));var d=H.create({done:r([]),abort:Q([],c.events.abort)});c.events.close.bind(function(a){d.trigger.done();b.focus()});c.events.action.bind(function(c){var d=Z.active();b.focus();var e=wf.selectedCells(a.selections(),b.isRoot);z(e,function(a){v.set(a,"border-width",c.value());v.getRaw(a,"border-style").fold(function(){v.set(a,"border-style","solid")},t)});b.domChanged();d.each(Z.focus)});var e=function(){c.enter();
  c.open()};return{element:c.element,destroy:c.destroy,name:k("cellborderwidth"),textkey:k(x.key("table.cell.border.width")),tooltip:rb.get,label:k(!1),updateWidget:function(d){var f=wf.selectedCells(a.selections(),b.isRoot);0<f.length?(d.enable(),d=v.getRaw(f[0],"border-width").fold(Da.off,Da.on),c.updateInlineWidget({size:k(d)},"1px")):d.disable();e()},events:d.registry,open:e,close:c.close}}},xna=Aa(["name","textkey","menuTextkey","action","shortname"],[]),sB={widget:function(a,b,c){var d=xna(c),
  e=a.content();c=T.div();S.label(c,x.translate(d.textkey()));ma.add(c,[B.resolve("palette-cell-colors"),B.resolve(d.shortname()+"-cell-colors")]);var f=Gj.create(b.colors.buttons);y.append(c,f.element());var g=function(b){var c=wf.selectedCells(a.selections(),e.isRoot);d.action()(c,b);n.trigger.done()},l=Bm(f.element()),m=(b.colors.custom?Dm.create:Dm.stub)(e,a.smartview().uiContainer());P.append(c,m.elements);m.events.selected.bind(function(a){g(a.color())});var n=H.create({done:r([]),abort:r([])});
  f.events.selected.bind(function(a){a=a.value();g(a)});var p=function(){m.refresh();t.enter();l.refresh()},t=ha.multiple(c,[l.grid].concat(m.layouts));t.events.exit.bind(function(){n.trigger.abort()});return{element:k(c),destroy:function(){t.destroy();f.destroy();m.destroy()},name:k(d.name()),textkey:k(x.key(d.textkey())),tooltip:rb.get,label:k(!1),updateWidget:function(b){kj.isHighContrast(a.smartview())?b.disable():(0===wf.selectedCells(a.selections(),e.isRoot).length?b.disable():b.enable(),p())},
  events:n.registry,open:p,close:function(){n.trigger.done()}}}},yna={styles:{"border-collapse":"collapse",width:"100%"},attributes:{border:"1"},percentages:!0},zna=function(a,b,c,d,e){void 0===e&&(e=yna);var f=p.fromTag("table");v.setAll(f,e.styles);m.setAll(f,e.attributes);var g=p.fromTag("tbody");y.append(f,g);for(var k=[],n=0;n<a;n++){for(var r=p.fromTag("tr"),t=0;t<b;t++){var u=n<c||t<d?p.fromTag("th"):p.fromTag("td");t<d&&m.set(u,"scope","row");n<c&&m.set(u,"scope","col");y.append(u,p.fromTag("br"));
  e.percentages&&v.set(u,"width",100/b+"%");y.append(r,u)}k.push(r)}P.append(g,k);return f},Ana={insert:function(a,b,c,d,e){return a.getSelection().bind(function(f){var h=zna(b,c,d,e);rd.insertAtCursor(a,[h]).each(function(b){tb.firstCell(h).each(function(b){a.setSelection(b,0,b,0)})});return g.some(h)})}},Bna=vd.resolve("table-picker"),Cna=vd.resolve("table-picker-row"),Dna=vd.resolve("table-picker-cell"),Ena=vd.resolve("table-picker-button"),$g={table:k(Bna),row:k(Cna),cell:k(Dna),button:k(Ena)},
  Fna="."+$g.cell(),Gna="."+$g.row(),ag={cells:function(a){return Y.descendants(a,Fna)},rows:function(a){return Y.descendants(a,Gna)},grid:function(a,b,c){b=parseInt(m.get(a,b),10);a=parseInt(m.get(a,c),10);return Na.grid(b,a)},button:function(a){return L.child(a,"."+$g.button()).getOr(a)}},IS=function(a,b,c,d,e){d=Math.max(d,Math.min(e,a.row()));a=Math.max(b,Math.min(c,a.column()));return Na.address(d,a)},JS=function(a,b){a=IS(a,1,b.maxCols,1,b.maxRows);var c=Na.address(a.row()+1,a.column()+1);b=IS(c,
  b.minCols,b.maxCols,b.minRows,b.maxRows);return{selection:k(a),full:k(b)}},qB={resize:function(a,b){a=Na.address(a.row()+1,a.column()+1);return JS(a,b)},grow:function(a,b,c,d){a=Na.address(a.rows()+c,a.columns()+b);return JS(a,d)}},KS=function(a,b,c,d){var e=a.width()/b.columns();a=a.height()/b.rows();return Na.address(Math.floor(d/a),Math.floor(c/e))},Hna={pickerCell:function(a,b,c,d){var e=d.x()-a.x();a=d.y()-a.y();return KS(b,c,e,a)},isRtl:k(!1)},Ina={pickerCell:function(a,b,c,d){var e=a.x()+b.width()-
  d.x();a=d.y()-a.y();return KS(b,c,e,a)},isRtl:k(!0)},t0={widget:function(a,b){var c=a.content(),d=i0(a.region().uiDirection().isRtl()?Ina:Hna,b),e=a.undo();a=H.create({done:Q([],d.events.done),abort:Q([],d.events.abort)});d.events.select.bind(function(a){e.save();Ana.insert(c,a.rows(),a.cols(),a.rowHeaders(),a.columnHeaders()).each(function(a){e.save();c.domChanged()});c.toEditing()});return{element:d.element,name:k("table"),textkey:k(x.key("insert.table")),menuTextkey:k(x.key("table.menu")),tooltip:rb.get,
  label:k(!1),updateWidget:function(a){c.getSelection().each(function(b){a.enable()});d.open()},destroy:d.destroy,events:a.registry,open:d.open,close:d.close}}},Tj={set:function(a,b){a.dom().checked=b},find:function(a){return L.descendant(a,"input:checked")}},LS=Aa(["floatval","caption","summary","border","dimensions"],[]),Jna=function(a){a=m.get(a,"border");return"0"===a||"1"===a?g.some(a):g.none()},Kna=function(a){var b=v.getRaw(a,"width");a=v.getRaw(a,"height");return{width:k(b),height:k(a)}},Sr=
  {divine:function(a,b){var c=tu.divine(b),d=m.get(b,"summary"),e=L.child(b,"caption").map(function(b){b=Ha.get(b);return a.filterHtml(a.output(),b)}).getOr(""),f=Jna(b);b=Kna(b);return LS({floatval:c,caption:e,summary:d,border:f,dimensions:b})},properties:LS,apply:function(a,b){b.floatval().each(function(b){oh.runFloat(a,b)});b.border().each(function(b){m.set(a,"border",b)});""===b.summary()?m.remove(a,"summary"):Of.setSummary(a,b.summary());""===b.caption()?L.child(a,"caption").each(F.remove):Of.setCaption(a,
  b.caption());Of.setDimensions(a,b.dimensions())}},Tr={halve:function(a,b){pc.getGenericWidth(a).each(function(c){var d=c.width()/2;pc.setGenericWidth(a,d,c.unit());pc.setGenericWidth(b,d,c.unit())})}},MS=function(a,b,c,d){return c.fold(g.none,g.none,function(a,b){return kc.first(b).bind(function(a){return g.some(Rc(a,0,a,0))})},function(c){return tb.table(c,b.isRoot).bind(function(e){Ac.execute(a,nc.insertRowAfter,t,d)(b,e,Sm.noMenu(c));e=Y.descendants(e,"tr");if(0<e.length)return L.descendant(e[e.length-
  1],"td,th").map(function(a){return Rc(a,0,a,0)})})})},tB={forward:function(a,b,c,d){return MS(a,b,vq.next(c),d)},backward:function(a,b,c,d){return MS(a,b,vq.prev(c),d)}},rB={setBorderColor:function(a,b){v.set(a,"border-color",b);v.getRaw(a,"border-style").fold(function(){v.set(a,"border-style","solid")},t)},setBackgroundColor:function(a,b){v.set(a,"background-color",b)},setHeight:function(a,b){v.set(a,"height",b)},setWidth:function(a,b){v.set(a,"width",b)},setType:function(a,b){b=Oc.copy(a,b);y.after(a,
  b);F.remove(a)},setScope:function(a,b){m.set(a,"scope",b)},setStyle:function(a,b){m.set(a,"style",b)},setClass:function(a,b){m.set(a,"class",b)}},q0=vd.resolve("resizer-bar-dragging"),Lna=O("withSpaces","withoutSpaces"),Mna=function(a){return ka(a.split(/[\.,-\/#!$%\^&\*;:{}=\-_`~()\s\u00A0]/gim),function(a){return 0<a.length}).length},vB={count:function(a){return{words:k(Mna(a)),characters:k(Lna(a.length,a.replace(/[\s\u00A0]/gim,"").length))}}},B0=Aa("accessibility formatting alignindent bookmark directionality table font parlance media imageEdit blocktag specialchar wordcount link linkvalidator horizontalrule help fileupload findreplace plaincodeview macros spelling".split(" "),
  []),wq=0,Px=g.none(),Wr={add:function(){if(0===wq){var a=p.fromTag("style");Vb.set(a,'/*\n * Keep this file as small as possible.\n * It is injected into the JavaScript, so it needs to be tiny.\n */\n\n/*\n * Animate from 0 to 359, not 0 to 360, as they are the same and FireFox does nothing\n *\n * Until we have token replacement, manual shorthand for "ephox-polish-spin"\n */\n\n@keyframes e-p-spin {\n  0% {\n    transform: rotate(0deg);\n  }\n  100% {\n    transform: rotate(359deg);\n  }\n}\n\n/* Until we have token replacement, manual shorthand for "ephox-polish-spinner-img" */\n\n.e-p-s-img {\n  animation: e-p-spin 2s infinite linear;\n  width: 30px;\n  height: 30px;\n  margin: 2px 2em 0 auto;\n  background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAIVBMVEUAAABAQEBDQ0NERERERERCQkJDQ0NERERDQ0NEREREREQTPu3mAAAACnRSTlMAENDPwGBwsKB/qy4kVgAAAFpJREFUCNdjAAImAwYI4FoApooFuBYwWgAZXoZMCsJLgAyhpQwMUYpABmMiA4OYAAMCaC2GklqLwIxFMAmoYkmQYmGQdkOQgYpMBkIgA4tAVmggLAU7QwFIAADjyQ3FWhtneAAAAABJRU5ErkJggg==") 0/cover;\n}');
  y.append(ja.body(),a);Px=g.some(a)}wq++},remove:function(){0!==wq&&0===--wq&&(Px.each(F.remove),Px=g.none())}},Nna=hc.pencil(),xq=hc.code(),NS=function(a){var b=a.old().toTransfer();a.nu().fromTransfer(b)},Ona={transition:NS,factory:fy,style:hc.pencil},Pna={transition:NS,factory:Tm,style:hc.code},Um={goingToDesign:function(a){return a===xq},alternate:function(a){return a===xq?Nna:xq},detect:function(a){return a===xq?Ona:Pna}},F0=function(a,b){return{destroy:t,init:t,setMode:yb("Code view is not enabled, cannot switch modes"),
  events:H.create({change:r([]),ready:r([])}).registry}},E0=function(a,b){var c=b.css+"/codemirror.css",d=H.create({change:r([]),ready:r(["type"])}),e=g.none(),f=function(){var a=Rl.load.codeview(b.js).map(function(a){return a.map(k(!0))});e=g.some(a)},h=function(a){a(J.value(!0))};return{init:function(a){e.fold(function(){en.addStylesheet(c,h).get(function(b){b.fold(function(a){console.error(a);console.error("Code View disabled due to error loading stylesheet")},function(){f();d.trigger.ready(a)})})},
  function(b){d.trigger.ready(a)})},setMode:function(b){return e.fold(function(){throw"Cannot set mode before Code View has loaded";},function(c){c.get(function(c){c.fold(function(a){d.trigger.ready(b);console.error(a);console.error("Code View non-functional due to error downloading script file")},function(){var c=Um.detect(b),e=a.swap(c.factory,{},{});d.trigger.change();c.transition(e);e.destroy()})})})},events:d.registry,destroy:t}},xB=aa.detect().browser,J0={build:function(a,b,c,d,e,f,g,l){var h=
  H0(a,b,c,f,g,l),m=d.full(h);m.init();return{element:h.element,socket:h.socket,viewport:h.viewport,uiContainerParent:h.uiContainerParent,init:function(b,d,g){d=m.config(a.isInline(),d,e,g);zE.setup(h,f,a,b,c,d);m.loaded()},connect:h.connect,destroy:function(){h.destroy();m.destroy()},displayBanner:h.displayBanner,hideBanner:h.hideBanner,position:t,refresh:h.refresh,tabstrip:h.toolbar,state:k(l),dialogContainer:h.dialogContainer}},bounds:function(){return Bf.view}},OS={blobTob64:function(a,b){var c=
  m.get(b,uc.blobId());m.remove(b,uc.blobId());a.get(c).each(function(a){m.remove(b,uc.blobId());m.set(b,"src",Xc.imageResultToDataURL(a.imageresult()))})},b64ToBlob:function(a,b){var c=m.get(b,"src"),d=function(){return Lj.dataUriToBlobSync(c).map(function(b){var d=Xc.fromBlobAndUrlSync(b,c);b=bg.createObjectURL(b);var e=Fa("image");return a.add(e,d,b)})};try{a.lookupByData(c).fold(d,g.some).each(function(a){m.set(b,uc.blobId(),a.id());m.set(b,"src",a.objurl())})}catch(e){console.warn("Unable to read Base64 image data: ",
  e,c)}}},X0={configure:function(a,b){var c=uc.blobId(),d="img["+c+"]";a.addSelector(a.internal(),d,Ta.removeAttr(c));a.addSelector(a.output(),d,function(a){z(a,function(a){OS.blobTob64(b,a)})});a.addSelector(a.input(),"img:not(["+c+"])[src]",function(a){z(a,function(a){OS.b64ToBlob(b,a)})});c=Ta.removeClass(uc.uploadInProgress());a.add(a.output(),uc.uploadInProgress(),c);a.add(a.history(),uc.uploadInProgress(),c);a.add(a.internal(),uc.uploadInProgress(),c);d=uc.trackedImage();c="img["+d+"]";d=Ta.removeAttr(d);
  a.addSelector(a.output(),c,d);a.addSelector(a.internal(),c,d)},blobId:uc.blobId},PS=O("image","blobInfo"),Qx=ta.generate([{failure:["error"]},{success:["result","images","blob"]}]),Rna=function(a,b,c,d){z(b,function(a){m.set(a,"src",d.location);m.remove(a,uc.blobId())});return Qna(a,c)},QS=function(a,b,c,d,e){var f=Xc.imageResultToDataURL(c);f=a.lookupByData(f).getOrThunk(function(){return a.add(b,c,d)});m.set(e,uc.blobId(),f.id());return PS(e,f)},Sna=function(a,b){var c=m.get(b,uc.blobId());return a.get(c).fold(function(){return J.error(c)},
  function(a){return J.value(PS(b,a))})},Qna=function(a,b){return a.get(b).fold(function(){return J.error("Internal error with blob cache")},function(c){a.remove(b);return J.value(c)})},Xj={prepareForUpload:function(a,b,c){var d=a.isActive(b);a.register(c,b);n.add(c,uc.uploadInProgress());return d?g.none():g.some(b)},handleUpload:function(a,b,c,d,e,f,g){var h=function(){console.error("Internal error with blob cache",e);g(Qx.failure({status:k(666)}))};a.upload(f,e,function(a){var f=b.findById(d,e);z(f,
  yf.removeClass(uc.uploadInProgress()));a.fold(function(a){g(Qx.failure(a))},function(a){Rna(c,f,e,a).fold(h,function(b){g(Qx.success(a,f,b))})});b.report(e,f,a.isValue())})},registerAssets:function(a,b,c){return ia(c,function(c){return Pc.cata(c,function(c,d,g){return L.descendant(b,'img[src="'+g+'"]').fold(function(){return[J.error("Image that was just inserted could not be found: "+g)]},function(b){return[J.value(QS(a,c,d,g,b))]})},k([]))})},registerBlob:QS,findBlobs:function(a,b,c){c=a.findAll(c);
  return a.inProgress()?[]:E(c,function(a){return Sna(b,a)})}},Tna=function(a){var b=function(b){var c=b.image(),e=b.blobInfo(),f=ur.changedBounds(c);e=Ua.fromPromise(Xc.imageResultToOriginalBlob(e.imageresult()));return Ua.bind(e,function(d){return Dj.resampleAction(f,d,function(e){if(e===d)return Ua.pure(b);var f=sf.updater(sf.keepResample,c),g=wr.applyEdit(c);e=Re.single(e).bind(g).map(f);return Ua.map(e,function(d){return Pc.cata(d,function(b,d,e){return Xj.registerBlob(a,b,d,e,c)},function(a,c,
  d){return b})})})})};return function(a){return Ce(a,b)}},Una=function(a){a=E(a,J.value);return Ea.pure(a)},W0={instance:function(a,b){return!0===a.immediate?Una:Tna(b)}},Vna={400:"errors.http.400",401:"errors.http.401",403:"errors.http.403",404:"errors.http.404",407:"errors.http.407",409:"errors.http.409",413:"errors.http.413",415:"errors.http.415",500:"errors.http.500",501:"errors.http.501"},Wna={get:function(a,b){return g.from(Vna[a]).map(function(a){return x.translate(a,b)})}},Xna=function(a){return xa(a)&&
  ""!==a.trim()?{description:k(a),link:k(null)}:mf.get("error.imageupload.generic")},Yna=function(a,b){var c=b.status();return Wna.get(c,a).fold(function(){var b=0===c?"error.imageupload.cors":400<=c&&500>c?"error.code.images.not.found":"error.imageupload";return mf.get(b,[a])},function(a){return{description:k(a),link:k(null)}})},RS=function(a,b){return{instance:function(){return Zb(function(c){c=b(c);a.show(c)})}}},SS={simple:function(a){return RS(a,Xna)},url:function(a,b){return RS(a,u(Yna,b))}},
  Zna=["jpg","png","gif","jpeg"],Wj={failureObject:O("message","status","contents"),getFilename:function(a,b){xa(a.name)&&!je(a.name,".tmp")?b=a.name:xa(a.type)&&Gb(a.type,"image/")&&(a=a.type.substr(6),b=U(Zna,a)?b+"."+a:b);return b},buildData:function(a,b,c){var d=new (Jc.getOrDie("FormData"));d.append(a,b,c);return d}},N0=O("id","filename","blob","base64"),TS={direct:function(a){return L0(a)},custom:function(a){return M0(a)}},Rx=O("uploader","errors"),V0={choose:function(a,b,c){return!0!==a.bundled?
  Rx({upload:yb},{instance:k(yb("Image Upload is disabled"))}):qb(a.handler)?Rx(TS.custom(a.handler),SS.simple(b)):Rx(TS.direct(a.direct),SS.url(b,a.direct.url))}},P0=O("id","imageresult","objurl"),Vm=uc.trackedImage(),S0=function(a,b){return Y.descendants(a,"img["+Vm+'="'+b+'"]')},T0=function(a){return Y.descendants(a,"img:not(["+Vm+"])["+uc.blobId()+"]")},$na={settings:function(a){var b={ui:{toolbar:{display:!1}},spelling:{bundled:!1},highlighter:{bundled:!1},table:{bundled:!1},resize:{bundled:!1},
  codeview:{bundled:!1},imageEdit:{bundled:!1},imageupload:{immediate:!0},linkvalidator:{bundled:!1}};b=aa.detect().deviceType.isTouch()?b:{};return oa(b,void 0===a.content||void 0===a.content.inline?{}:{fullscreen:{bundled:!1},codeview:{bundled:!1},plaincodeview:{bundled:!1}})}},AB={isRtl:k(!1)},zB={isRtl:k(!0)},$0=function(a){return Xa(["ar","fa","he"],function(b){return Gb(a,b)})},b1=function(a){return oa(BB.settings(a.resources),a,$na.settings(a))},US=function(a,b,c){var d=PC.withOptions(a,c);d.content&&
  d.content.tabindex&&(0,m.remove)(a,"tabindex",d.content.tabindex);c=Zr(d,{});var e=Ha.get(a),f=m.get(a,"style");b(a);Ha.set(a,"");c.connect(a);Fd.set(c,e);return{polish:c,restore:function(b){Ha.set(a,b);null!==f&&void 0!==f&&0<f.length?m.set(a,"style",f):m.remove(a,"style");d.content&&d.content.tabindex&&(0,m.set)(a,"tabindex",d.content.tabindex);return a}}},VS={replace:function(a,b){return US(a,b.content&&!0===b.content.autoresize?I2:H2,b)},takeover:function(a,b){return US(a,t,b)}},Ob=function(a,
  b){var c={};if(void 0===a)return c;z(b,function(b){var d=b.name();d=a[d];void 0!==d&&(b.validate(d),c[b.output()]=Mb(b.contents)?Ob(d,b.contents):d)});return c},aoa=function(a){return E(void 0===a?[]:a,function(a){var b=Ob,d=ba.string("prefix"),e=ba.string("suffix");var f=[ba.string("color"),ba.string("background-color")];f=ua(ba.object("style"),{contents:f});return b(a,[d,e,f])})},boa=function(a){if(void 0===a||void 0===a.url)return{service:!1};var b=WS(a,"autocorrect",!0);if(xa(a.url))return{url:a.url,
  service:!0,autocorrect:b};throw Error("Spelling URL was not a string");},coa=function(a){if(void 0===a||void 0===a.validation||void 0===a.validation.url)return{};if(xa(a.validation.url))return{url:a.validation.url,bundled:!0};throw Error("Link Validation URL was not a string");},doa=function(a){if(void 0===a||void 0===a.embed||void 0===a.embed.url)return{};if(xa(a.embed.url))return{url:a.embed.url,bundled:!0};throw Error("Link Embed URL was not a string");},eoa=function(a,b){b=!1===b?!0:!1;a=(void 0===
  a?{}:a).upload;if(void 0!==a){if(void 0!==a.handler){if(!qb(a.handler))throw Error("Image Upload Handler was not a function");return{handler:a.handler,immediate:b,bundled:!0}}if(!xa(a.url))throw Error("Image Upload URL was not a string");return{direct:Ob(a,[ba.string("url"),ba.string("basePath"),ba.bool("credentials")]),immediate:b,bundled:!0}}return{}},foa=function(a){a=Ob((void 0===a?{}:a).editing,[ba.bool("enabled"),ba.string("proxy"),ba.number("preferredWidth"),ba.number("preferredHeight")]);
  void 0!==a.enabled&&(a.bundled=a.enabled);return a},WS=function(a,b,c){if(void 0===a[b])return c;ba.bool(b).validate(a[b]);return a[b]},goa=function(a){return Ob((void 0===a?{}:a).toolbar,[ba.arrayOfToolbarGroups("items"),ba.arrayOfStrings("contextual")])},hoa=function(a){if(void 0===a)return{};if(void 0===a.toolbar)var b={};else{var c=a.toolbar;if(void 0!==c.offset){c=c.offset;if(!ic(c)||void 0===c.top||void 0===c.left)throw Error("toolbar offset must be an object with left and top");if(!$e(c.top)&&
  !$e(c.left))throw Error("toolbar offset values must be numbers");b={draggable:!0,offset:{left:c.left,top:c.top}}}else b={}}c=Ob(a.toolbar,[ba.bool("visible"),ba.bool("draggable"),ba.bool("sticky")]);b=oa(b,c);return void 0===c.sticky&&!0===a.autoresize?oa(b,{sticky:!0}):b},ioa=function(a){if(void 0!==a){if(!xa(a))throw Error("The basePath configuration value was not a string");return gk(a,"/")}},joa=function(a){if(void 0===a||void 0===a.fonts)return[];a=a.fonts;if(!Mb(a))throw Error("The fonts configuration was not an array");
  var b=function(a,b){console.error(a+" :",b);throw Error(a);};return E(a,function(a){if(xa(a))return{value:a,text:a};ic(a)||b("The fonts array value was not a string or object",a);void 0!==a.value&&xa(a.value)||b("The font value configuration was not a string or is undefined",a);void 0===a.text||xa(a.text)||b("The font text configuration was not a string",a);return{value:a.value,text:a.text&&0<a.text.length?a.text:a.value}})},loa=function(a){if(void 0===a||void 0===a.colors)return{};var b=Ob(a.colors,
  [ba.bool("custom")]);void 0!==a.colors.buttons&&(b.buttons=koa(a.colors.buttons));return b},koa=function(a){if(!Mb(a))throw Error("The colors button configuration was not an array");var b=function(a,b){console.error(a+" :",b);throw Error(a);};return E(a,function(a){if(xa(a))return{value:a,text:a};ic(a)||b("A buttons array value was not a string or object",a);void 0!==a.value&&xa(a.value)||b("The color button value configuration was not a string or is undefined",a);void 0===a.text||xa(a.text)||b("The color button text configuration was not a string",
  a);return{value:a.value,text:a.text&&0<a.text.length?a.text:a.value}})},moa=function(a){a=Ob(void 0===a?{}:a,[ba.bool("enabled"),ba.bool("showButton")]);return{bundled:void 0===a.enabled||!0===a.enabled,showButton:void 0===a.showButton||!0===a.showButton}},noa=function(a){a=ua({allowLocal:!0},void 0===a?{}:a);ba.bool("allowLocal").validate(a.allowLocal);return a.allowLocal},ooa=function(a){a=Ob(void 0===a?{}:a,[ba.arrayOfStrings("languages")]);return void 0===a.languages?{}:{languages:E(a.languages,
  function(a){return a.toLowerCase()})}},poa=function(a){void 0!==a.styles&&(a.styles=ka(a.styles,function(a){a=a.rule;return!(void 0===a||"."===a||0<=a.indexOf("..")||0<=a.indexOf("#"))}))},qoa=function(a,b,c){return"plain"===a?{forceText:!0}:{officeStyles:"retain"===a?"merge":void 0!==a?a:"prompt",htmlStyles:"retain"===a?"merge":void 0!==a?a:"merge",allowLocalImages:c,enableFlashImport:!1===b?!1:!0}},roa=function(a){a=Ob(a.macros,[ba.arrayOfStrings("allowed")]);void 0!==a.allowed&&(a.allowed=g.some(a.allowed));
  return a},f1=function(a){var b=Ob(a,[ba.arrayOfStrings("plugins")]);b=void 0===b.plugins?[]:b.plugins;var c=Ob(a.ui,[ba.string("locale","code")]),d=WS(a,"autosubmit",!0),e=Ob(a.content,[ba.arrayOfObjects("highlighters")]),f=Ob(a.paste,[ba.string("style"),ba.bool("enableFlashImport")]),g=function(){var b=Ob(a.css,[ba.arrayOfStrings("stylesheets"),ba.string("documentStyles"),ba.bool("showDocumentStyles")]),c=Ob(a.ui,[ba.bool("autoresize")]);return ua(b,c)}(),k=Ob(a.css,[ba.arrayOfObjects("styles"),
  ba.bool("showDocumentStyles")]);poa(k);var m=Ob(a.ui,[ba.bool("shortcuts","features")]),n=ooa(a.ui),p=moa(a.codeview),r=boa(a.spelling),t=coa(a.links),u=doa(a.links),v=noa(a.images),x=foa(a.images),y=v?eoa(a.images,x.bundled):{},z=goa(a.ui),A=hoa(a.ui),B=ioa(a.basePath),D=joa(a.ui),E=loa(a.ui),F=function(){var b=Ob(a.ui,[ba.string("aria-label","editorName"),ba.bool("autoresize")]);return ua(b,{locale:c,toolbar:A})}(),H=roa(a);return{resources:B,plugins:b,spelling:r,linkvalidator:t,embed:u,font:{faces:D,
  colors:E},table:{colors:E},macros:H,ui:F,shortcuts:m,autosubmit:d,highlighter:{external:aoa(e.highlighters)},smartclipboard:{paste:qoa(f.style,f.enableFlashImport,v)},parlance:n,content:g,imageEdit:x,imageupload:y,blocktag:k,fileupload:{allowLocalImages:v},platform:{toolbar:z,allowLocalImages:v},plaincodeview:{bundled:p.bundled},codeview:p}},soa={getPath:function(a){var b=document.getElementsByTagName("script");return qa(bs(b),function(b){return b.src.indexOf(a)===b.src.length-a.length}).map(function(b){return b.src.substring(0,
  b.src.indexOf(a))}).getOr(void 0)}},XS=Zb(function(){return g.from(soa.getPath("textboxio.js")).map(function(a){return gk(a,"/")})}),YS=function(a){return a+"/resources"},DB={setupResources:function(a){return g.from(a.resources).orThunk(XS).map(YS).fold(yb("basePath auto detection failed, please provide one in the editor configuration"),function(b){b=Yj.load(b);return oa(a,{resources:b})})},speculate:function(a){g.from(a).orThunk(XS).map(YS).each(Yj.load)}},toa=function(a,b,c){var d=function(){var a=
  p.fromDom(Hb.activeElement);b(a)&&c()};return K.bind(a,"blur",function(){setTimeout(d,200)})},uoa=function(a,b,c){return K.bind(a,"focusout",function(a){ZS(a,b)&&c()})},voa=function(a,b,c){return K.bind(a,"blur",function(a){ZS(a,b)&&c()})},woa=function(){var a=aa.detect();return a.browser.isFirefox()?toa:a.browser.isIE()?uoa:voa}(),ZS=function(a,b){a=g.from(a.raw().relatedTarget).getOr(Hb.activeElement);return b(p.fromDom(a))},xoa={register:function(a,b,c,d){var e=K.bind(a,"focus",function(a){Z.hasFocus(a.target())&&
  c()}),f=woa(a,function(c){return!wd.closest(c,function(c){return N.eq(a,c)||N.eq(b(),c)||n.has(c,CA.magicBox())})},d);return{destroy:function(){e.unbind();f.unbind()}}}},Ye={replace:function(a,b){b=oa(b,{content:{inline:a}});var c=m.clone(a),d=Zr(b),e=c1(d.element,a,c),f=Bq(e.toolbarHide,e.toolbarShow,!1),g=function(){var a=e.isVisible();f.on();!1===a&&d.activateInline()},k=function(){d.deactivateInline();f.off()},n=xoa.register(a,d.element,g,k);b=function(){Z.active().each(function(b){N.eq(b,a)||
  k()})};b();d.events.connected.bind(b);d.events.loaded.bind(function(){d.content().getSelection().bind(g)});var p=d.focus;b={polish:ua(d,{focus:function(){g();p()}}),restore:function(b){n.destroy();e.restore();Ha.set(a,b);return a}};d.connect(ja.body());Fd.set(d,Ha.get(a));return b}},yoa={attach:function(a,b,c,d){if(4!==arguments.length)throw"requires 4 parameters";var e=function(b){return function(){var c=p.fromTag("input");m.setAll(c,{type:"hidden",name:b});a.append(c.dom());return function(a){c.val(a)}}},
  f=c.getOrThunk(e(b)),g=d.getOrThunk(e(b+"_styles"));return function(a){f(a.content);g(a.styles)}}},$S=function(a,b){var c=a.onsubmit,d=d1(a);a.onsubmit=function(e){if(d.inprogress())return!0;b(function(){c&&!1===c.apply(a)||setTimeout(d.submit,0)});return!1};return{unbind:function(){a.onsubmit=c}}},zoa={attachToFormSubmit:$S,attachToParentFormSubmit:function(a,b,c,d,e){if(5!==arguments.length)throw"requires 5 parameters";var f=a.parents("form:first");if(0!==f.size()){var g=f.get(0),k=yoa.attach(f,
  b,d,e);$S(g,function(a){k(c());a()})}}},Boa=function(a,b,c,d){v.set(b,"display","none");var e=Zr(PC.withOptions(b,d)),f=fa.get(b);e.connect(a);Fd.set(e,f);var h=!0===d.autosubmit?Aoa(b,e):g.none();return{polish:e,restore:function(d){h.each(function(a){a.unbind()});fa.set(b,d);c.fold(function(){v.remove(b,"display")},function(a){v.set(b,"display",a)});F.remove(a);return b}}},Aoa=function(a,b){return L.closest(a,"form").map(function(c){return zoa.attachToFormSubmit(c.dom(),function(c){b.uploadImages(function(){fa.set(a,
  Fd.get(b));c()})})})},g1={textarea:{replace:function(a,b){var c=v.getRaw(a,"display");return A.parent(a).fold(function(){return null},function(){var d=m.get(a,"id");d=d?"ephox_"+d:Fa("ephox");var e=p.fromTag("div");m.set(e,"id",d);v.copy(a,e);(b.content&&!0===b.content.autoresize?G2:F2)(a,e);y.before(a,e);return Boa(e,a,c,b)})}},div:VS,body:{replace:function(a,b){b=oa(b,{platform:{fillscreen:!0}});a=VS.takeover(a,b);return{polish:a.polish,restore:a.restore}}}},h1={div:Ye,blockquote:Ye,article:Ye,
  aside:Ye,figure:Ye,figcaption:Ye,footer:Ye,header:Ye,nav:Ye,section:Ye},Ml=function(a){return{name:a.name,required:ed,validate:a.validate}},Wm={bool:Pb(Ml,ba.bool),func:Pb(Ml,ba.func),number:Pb(Ml,ba.number),object:Pb(Ml,ba.object),string:Pb(Ml,ba.string)},Sx=function(a){return J.error("ERROR: Textbox.io requires "+a+" or above")},Tx=aa.detect().os,Nl=aa.detect().browser,aT="CSS1Compat"===Hb.compatMode||Hb.doctype&&"html"===Hb.doctype.name,Coa={supported:function(){if(Nl.isIE()&&11>Nl.version.major)return Sx("Internet Explorer 11");
  if(Tx.isOSX()&&Nl.isSafari()&&9>Nl.version.major)return Sx("Safari 9");if(Tx.isiOS()&&9>Tx.version.major)return Sx("iOS 9");if(!aT&&Nl.isIE())return J.error("ERROR: Document is not in standards mode. Textbox.io requires standards mode on Internet Explorer.");aT||void 0===console.warn||console.warn("WARNING: Document is not in standards mode. Textbox.io may experience user interface issues.");return J.value(void 0)}},bT=function(a){Vf.textboxio=a},Doa=Pb(bT,function(a){a=yb(a);return{replace:a,replaceAll:a,
  inline:a,inlineAll:a,get:a,getActiveEditor:a,definePlugin:a,version:Ux,isSupported:ed}});(function(){var a=Vf.install;Vf.install=function(b,c){Vf.install=a;Coa.supported().fold(Doa,function(){var a=null===c||void 0===c?{onprem:!0}:c;a=null===b||void 0===b?a:oa(a,{resources:b});bT(i1(a));DB.speculate(a.resources)})}})()})();
  install();
  