/** * Copyright (c) Tiny Technologies, Inc. All rights reserved. * Licensed under the LGPL or a commercial license. * For LGPL see License.txt in the project root for license information. * For commercial licenses see https://www.tiny.cloud/ * * Version: 5.0.4 (2019-04-23) */ !function(x){"use strict";var Q=function(){for(var t=[],n=0;na[0]&&t[1] "+o.toString()},function(t,n){return"state("+t+")"})}).join("\n")+"}"},toDsl:function(){return Fo.objOf(_(a,function(t){return t.fold(function(t,n,e,o){return Io.field(t,e,o)},function(t,n){return Io.state(t)})}))}}},Xo=function(r){return{extract:function(e,o,t){var n=_(t,function(t,n){return r.extract(e.concat(["["+n+"]"]),o,t)});return Mo(n)},toString:function(){return"array("+r.toString()+")"},toDsl:function(){return Fo.arrOf(r)}}},Yo=function(a,c){return{extract:function(e,o,r){var t,n,i=et(r),u=(t=e,n=i,Xo(Uo(a)).extract(t,d,n));return To(u,function(t){var n=_(t,function(t){return Po.field(t,t,go(),c)});return Go(n).extract(e,o,r)})},toString:function(){return"setOf("+c.toString()+")"},toDsl:function(){return Fo.setOf(a,c)}}},qo=Z(Uo(ko)),Ko=p(Xo,Go),Jo=Po.state,$o=Po.field,Qo=function(e,n,o,r,i){return Tt(r,i).fold(function(){return t=r,n=i,No(e,function(){return'The chosen schema: "'+n+'" did not exist in branches: '+Ho(t)});var t,n},function(t){return Go(t).extract(e.concat(["branch: "+i]),n,o)})},Zo=function(r,i){return{extract:function(n,e,o){return Tt(o,r).fold(function(){return t=r,No(n,function(){return'Choice schema did not contain choice key: "'+t+'"'});var t},function(t){return Qo(n,e,o,i,t)})},toString:function(){return"chooseOn("+r+"). Possible values: "+et(i)},toDsl:function(){return Fo.choiceOf(r,i)}}},tr=Uo(ko),nr=function(t){return Ko(t)},er=function(){return Xo(tr)},or=function(n){return Uo(function(t){return n(t).fold(Oo,ko)})},rr=function(n,t){return Yo(function(t){return wo(n(t))},t)},ir=function(t,n,e,o){var r=n.extract([t],e,o);return Ao(r,function(t){return{input:o,errors:t}})},ur=function(t,n,e){return So(ir(t,n,d,e))},ar=function(t){return t.fold(function(t){throw new Error(sr(t))},d)},cr=function(t,n,e){return ar(ur(t,n,e))},sr=function(t){return"Errors: \n"+(n=t.errors,e=10 ")+")\n"+t.getErrorInfo()}))+"\n\nInput object: "+Ho(t.input);var n,e},fr=function(t,n){return Zo(t,n)},lr=Z(tr),dr=function(e,o){return Uo(function(t){var n=typeof t;return e(t)?ko(t):Oo("Expected type: "+o+" but got: "+n)})},mr=dr(D,"number"),gr=dr(S,"string"),pr=dr(C,"boolean"),hr=dr(b,"function"),vr=function(n){return or(function(t){return T(n,t)?vt.value(t):vt.error('Unsupported value: "'+t+'", choose one of "'+n.join(", ")+'".')})},br=function(t){return $o(t,t,go(),qo())},yr=function(t,n){return $o(t,t,go(),n)},xr=function(t){return yr(t,gr)},wr=function(t,n){return $o(t,t,go(),vr(n))},Sr=function(t){return yr(t,hr)},kr=function(t,n){return $o(t,t,go(),Go(n))},Cr=function(t,n){return $o(t,t,go(),Ko(n))},Or=function(t,n){return $o(t,t,go(),Xo(n))},Tr=function(t){return $o(t,t,po(),qo())},Er=function(t,n){return $o(t,t,po(),n)},Br=function(t){return Er(t,mr)},Ar=function(t){return Er(t,gr)},Dr=function(t){return Er(t,hr)},_r=function(t,n){return Er(t,Go(n))},Mr=function(t,n){return $o(t,t,mo(n),qo())},Fr=function(t,n,e){return $o(t,t,mo(n),e)},Ir=function(t,n){return Fr(t,n,mr)},Vr=function(t,n){return Fr(t,n,gr)},Rr=function(t,n,e){return Fr(t,n,vr(e))},Hr=function(t,n){return Fr(t,n,pr)},Nr=function(t,n){return Fr(t,n,hr)},Pr=function(t,n,e){return Fr(t,n,Go(e))},zr=function(t,n){return Jo(t,n)},Lr=function(t,n){return he(t.element(),n.event().target())},jr=function(t){if(!Dt(t,"can")&&!Dt(t,"abort")&&!Dt(t,"run"))throw new Error("EventHandler defined by: "+Ro(t,null,2)+" does not have can, abort, or run!");return cr("Extracting event.handler",Wo([Mr("can",Z(!0)),Mr("abort",Z(!1)),Mr("run",Q)]),t)},Ur=function(e){var n,o,r,i,t=(n=e,o=function(t){return t.can},function(){for(var e=[],t=0;t "):o[0].name();return Et(r,{handler:n,purpose:Z(e)})})});return At(n,{})},$i=function(t){return ur("custom.definition",Go([$o("dom","dom",go(),Go([br("tag"),Mr("styles",{}),Mr("classes",[]),Mr("attributes",{}),Tr("value"),Tr("innerHtml")])),br("components"),br("uid"),Mr("events",{}),Mr("apis",{}),$o("eventOrder","eventOrder",(n={"alloy.execute":["disabling","alloy.base.behaviour","toggling","typeaheadevents"],"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","item-events","tooltipping"],mousedown:["focusing","alloy.base.behaviour","item-type-events"],mouseover:["item-type-events","tooltipping"]},lo.mergeWithThunk(Z(n))),lr()),Tr("domModification")]),t);var n},Qi=function(t,n){var e=Ue(t,n);return e===undefined||""===e?[]:e.split(" ")},Zi=function(t){return t.dom().classList!==undefined},tu=function(t){return Qi(t,"class")},nu=function(t,n){return r=n,i=Qi(e=t,o="class").concat([r]),Le(e,o,i.join(" ")),!0;var e,o,r,i},eu=function(t,n){return r=n,0<(i=V(Qi(e=t,o="class"),function(t){return t!==r})).length?Le(e,o,i.join(" ")):Ge(e,o),!1;var e,o,r,i},ou=function(t,n){Zi(t)?t.dom().classList.add(n):nu(t,n)},ru=function(t,n){var e;Zi(t)?t.dom().classList.remove(n):eu(t,n),0===(Zi(e=t)?e.dom().classList:tu(e)).length&&Ge(e,"class")},iu=function(t,n){return Zi(t)&&t.dom().classList.contains(n)},uu=function(n,t){M(t,function(t){ou(n,t)})},au=function(n,t){M(t,function(t){ru(n,t)})},cu=function(t){return t.style!==undefined},su=function(t,n,e){if(!S(e))throw x.console.error("Invalid call to CSS.set. Property ",n,":: Value ",e,":: Element ",t),new Error("CSS value must be a string: "+e);cu(t)&&t.style.setProperty(n,e)},fu=function(t,n){cu(t)&&t.style.removeProperty(n)},lu=function(t,n,e){var o=t.dom();su(o,n,e)},du=function(t,n){var e=t.dom();rt(n,function(t,n){su(e,n,t)})},mu=function(t,n){var e=t.dom();rt(n,function(t,n){t.fold(function(){fu(e,n)},function(t){su(e,n,t)})})},gu=function(t,n){var e=t.dom(),o=x.window.getComputedStyle(e).getPropertyValue(n),r=""!==o||Qr(t)?o:pu(e,n);return null===r?undefined:r},pu=function(t,n){return cu(t)?t.style.getPropertyValue(n):""},hu=function(t,n){var e=t.dom(),o=pu(e,n);return tt.from(o).filter(function(t){return 0"}),lr()),bf=zr("schema",function(){return[Tr("preprocess")]}),yf=Mr("defaults",Z({})),xf=Mr("overrides",Z({})),wf=Go([gf,pf,hf,vf,yf,xf]),Sf=Go([gf,pf,hf,yf,xf]),kf=Go([gf,pf,hf,vf,yf,xf]),Cf=Go([gf,bf,hf,br("unit"),vf,yf,xf]),Of=function(t){return t.fold(tt.some,tt.none,tt.some,tt.some)},Tf=function(t){var n=function(t){return t.name};return t.fold(n,n,n,n)},Ef=function(e,o){return function(t){var n=cr("Converting part type",o,t);return e(n)}},Bf=Ef(mf.required,wf),Af=Ef(mf.external,Sf),Df=Ef(mf.optional,kf),_f=Ef(mf.group,Cf),Mf=Z("entirety"),Ff=/* */Object.freeze({required:Bf,external:Af,optional:Df,group:_f,asNamedPart:Of,name:Tf,asCommon:function(t){return t.fold(d,d,d,d)},original:Mf}),If=function(t,n,e,o){return wt(n.defaults(t,e,o),e,{uid:t.partUids[n.name]},n.overrides(t,e,o))},Vf=function(r,t){var n={};return M(t,function(t){Of(t).each(function(e){var o=Rf(r,e.pname);n[e.name]=function(t){var n=cr("Part: "+e.name+" in "+r,Go(e.schema),t);return ao({},o,{config:t,validated:n})}})}),n},Rf=function(t,n){return{uiType:df(),owner:t,name:n}},Hf=function(t,n,e){return{uiType:df(),owner:t,name:n,config:e,validated:{}}},Nf=function(t){return j(t,function(t){return t.fold(tt.none,tt.some,tt.none,tt.none).map(function(t){return kr(t.name,t.schema.concat([$u(Mf())]))}).toArray()})},Pf=function(t){return _(t,Tf)},zf=function(t,n,e){return o=n,i={},r={},M(e,function(t){t.fold(function(o){i[o.pname]=ff(!0,function(t,n,e){return o.factory.sketch(If(t,o,n,e))})},function(t){var n=o.parts[t.name];r[t.name]=Z(t.factory.sketch(If(o,t,n[Mf()]),n))},function(o){i[o.pname]=ff(!1,function(t,n,e){return o.factory.sketch(If(t,o,n,e))})},function(r){i[r.pname]=lf(!0,function(n,t,e){var o=n[r.name];return _(o,function(t){return r.factory.sketch(wt(r.defaults(n,t,e),t,r.overrides(n,t)))})})})}),{internals:Z(i),externals:Z(r)};var o,i,r},Lf=function(t,n,e){return sf(tt.some(t),n,n.components,e)},jf=function(t,n,e){var o=n.partUids[e];return t.getSystem().getByUid(o).toOption()},Uf=function(t,n,e){return jf(t,n,e).getOrDie("Could not find part: "+e)},Wf=function(t,n,e){var o={},r=n.partUids,i=t.getSystem();return M(e,function(t){o[t]=i.getByUid(r[t])}),it(o,Z)},Gf=function(t,n){var e=t.getSystem();return it(n.partUids,function(t,n){return Z(e.getByUid(t))})},Xf=function(t){return et(t.partUids)},Yf=function(t,n,e){var o={},r=n.partUids,i=t.getSystem();return M(e,function(t){o[t]=i.getByUid(r[t]).getOrDie()}),it(o,Z)},qf=function(n,t){var e=Pf(t);return Bt(_(e,function(t){return{key:t,value:n+"-"+t}}))},Kf=function(n){return $o("partUids","partUids",vo(function(t){return qf(t.uid,n)}),lr())},Jf=/* */Object.freeze({generate:Vf,generateOne:Hf,schemas:Nf,names:Pf,substitutes:zf,components:Lf,defaultUids:qf,defaultUidsSchema:Kf,getAllParts:Gf,getAllPartNames:Xf,getPart:jf,getPartOrDie:Uf,getParts:Wf,getPartsOrDie:Yf}),$f=function(t,n,e,o,r){var i,u,a=(u=r,(0<(i=o).length?[kr("parts",i)]:[]).concat([br("uid"),Mr("dom",{}),Mr("components",[]),$u("originalSpec"),Mr("debug.sketcher",{})]).concat(u));return cr(t+" [SpecSchema]",Wo(a.concat(n)),e)},Qf=function(t,n,e,o,r){var i=Zf(r),u=Nf(e),a=Kf(e),c=$f(t,n,i,u,[a]),s=zf(0,c,e);return o(c,Lf(t,c,s.internals()),i,s.externals())},Zf=function(t){return t.hasOwnProperty("uid")?t:ao({},t,{uid:Di("uid")})};function tl(t){return t.uid!==undefined}var nl,el,ol=Wo([br("name"),br("factory"),br("configFields"),Mr("apis",{}),Mr("extraApis",{})]),rl=Wo([br("name"),br("factory"),br("configFields"),br("partFields"),Mr("apis",{}),Mr("extraApis",{})]),il=function(t){var i=cr("Sketcher for "+t.name,ol,t),n=it(i.apis,Pi),e=it(i.extraApis,function(t,n){return Vi(t,n)});return ao({name:Z(i.name),partFields:Z([]),configFields:Z(i.configFields),sketch:function(t){return n=i.name,e=i.configFields,o=i.factory,r=Zf(t),o($f(n,e,r,[],[]),r);var n,e,o,r}},n,e)},ul=function(t){var n=cr("Sketcher for "+t.name,rl,t),e=Vf(n.name,n.partFields),o=it(n.apis,Pi),r=it(n.extraApis,function(t,n){return Vi(t,n)});return ao({name:Z(n.name),partFields:Z(n.partFields),configFields:Z(n.configFields),sketch:function(t){return Qf(n.name,n.configFields,n.partFields,n.factory,t)},parts:Z(e)},o,r)},al=function(t){return"input"===Fe(t)&&"radio"!==Ue(t,"type")||"textarea"===Fe(t)},cl=/* */Object.freeze({getCurrent:function(t,n,e){return n.find(t)}}),sl=[br("find")],fl=ua({fields:sl,name:"composing",apis:cl}),ll=function(t,n,e,o){var r=t+n;return o=t.minChars&&t.matches.getOr(Rg)(e.range,a,e.text)});return{lookupData:Vg.all(_(t,function(n){return n.fetch(e.text,n.maxResults).then(function(t){return{items:t,columns:n.columns,onAction:n.onAction}})})),triggerChar:e.triggerChar,range:e.range}})},Ng=Go([zr("type",function(){return"autocompleteitem"}),zr("active",function(){return!1}),zr("disabled",function(){return!1}),Mr("meta",{}),xr("value"),Ar("text"),Ar("icon")]),Pg=Go([xr("type"),xr("ch"),Ir("minChars",1),Mr("columns",1),Ir("maxResults",10),Dr("matches"),Sr("fetch"),Sr("onAction")]),zg=function(t){var n,e,o=t.ui.registry.getAll().popups,r=it(o,function(t){return(n=t,ur("Autocompleter",Pg,n)).fold(function(t){throw new Error(sr(t))},function(t){return t});var n}),i=(n=at(r,function(t){return t.ch}),e={},M(n,function(t){e[t]={}}),et(e)),u=st(r);return{dataset:r,triggerChars:i,lookupByChar:function(n){return V(u,function(t){return t.ch===n})}}},Lg=[Hr("disabled",!1),Ar("text"),Ar("shortcut"),$o("value","value",ho(function(){return io("menuitem-value")}),lr()),Mr("meta",{})],jg=Go([xr("type"),Nr("onSetup",function(){return Q}),Nr("onAction",Q),Ar("icon")].concat(Lg)),Ug=Go([xr("type"),Sr("getSubmenuItems"),Nr("onSetup",function(){return Q}),Ar("icon")].concat(Lg)),Wg=Go([xr("type"),Hr("active",!1),Nr("onSetup",function(){return Q}),Sr("onAction")].concat(Lg)),Gg=Go([xr("type"),Hr("active",!1),Ar("icon")].concat(Lg)),Xg=Go([xr("type"),Ar("text")]),Yg=Go([xr("type"),wr("fancytype",["inserttable"]),Nr("onAction",Q)]),qg=function(t,o,n){var r=Yc(t.element(),"."+n);if(0o}).getOr(r.length);return tt.some({numColumns:e,numRows:Math.ceil(r.length/e)})}return tt.none()},Kg=function(t,n){return ra([rg(t,n)])},Jg=function(t){return Kg(io("unnamed-events"),t)},$g=[br("lazySink"),br("tooltipDom"),Mr("exclusive",!0),Mr("tooltipComponents",[]),Mr("delay",300),Rr("mode","normal",["normal","follow-highlight"]),Mr("anchor",function(t){return{anchor:"hotspot",hotspot:t,layouts:{onLtr:Z([kc,Sc,bc,xc,yc,wc]),onRtl:Z([kc,Sc,bc,xc,yc,wc])}}}),Xu("onHide"),Xu("onShow")],Qg=/* */Object.freeze({init:function(){var e=_t(tt.none()),n=_t(tt.none()),o=function(){e.get().each(function(t){x.clearTimeout(t)})},t=Z("not-implemented");return Li({getTooltip:function(){return n.get()},isShowing:function(){return n.get().isSome()},setTooltip:function(t){n.set(tt.some(t))},clearTooltip:function(){n.set(tt.none())},clearTimer:o,resetTimer:function(t,n){o(),e.set(tt.some(x.setTimeout(function(){t()},n)))},readState:t})}}),Zg=io("tooltip.exclusive"),tp=io("tooltip.show"),np=io("tooltip.hide"),ep=function(t,n,e){t.getSystem().broadcastOn([Zg],{})},op=/* */Object.freeze({hideAllExclusive:ep,setComponents:function(t,n,e,o){e.getTooltip().each(function(t){t.getSystem().isConnected()&&wm.set(t,o)})}}),rp=ua({fields:$g,name:"tooltipping",active:/* */Object.freeze({events:function(o,r){var e=function(n){r.getTooltip().each(function(t){Ms(t),o.onHide(n,t),r.clearTooltip()}),r.clearTimer()};return ii(L([[si(tp,function(t){r.resetTimer(function(){!function(n){if(!r.isShowing()){ep(n);var t=o.lazySink(n).getOrDie(),e=n.getSystem().build({dom:o.tooltipDom,components:o.tooltipComponents,events:ii("normal"===o.mode?[si(Wt(),function(t){Wr(n,tp)}),si(jt(),function(t){Wr(n,np)})]:[]),behaviours:ra([wm.config({})])});r.setTooltip(e),As(t,e),o.onShow(n,e),Ts.position(t,o.anchor(n),e)}}(t)},o.delay)}),si(np,function(t){r.resetTimer(function(){e(t)},o.delay)}),si(Mn(),function(t,n){T(n.channels(),Zg)&&e(t)}),yi(function(t){e(t)})],"normal"===o.mode?[si(Gt(),function(t){Wr(t,tp)}),si(Dn(),function(t){Wr(t,np)}),si(Wt(),function(t){Wr(t,tp)}),si(jt(),function(t){Wr(t,np)})]:[si(Jn(),function(t,n){Wr(t,tp)}),si($n(),function(t){Wr(t,np)})]]))}}),state:Qg,apis:op}),ip=function(t){var n,e,o,r=Zn.fromHtml(t),i=we(r),u=(e=(n=r).dom().attributes!==undefined?n.dom().attributes:[],U(e,function(t,n){var e;return"class"===n.name?t:ao({},t,((e={})[n.name]=n.value,e))},{})),a=(o=r,Array.prototype.slice.call(o.dom().classList,0)),c=0===i.length?{}:{innerHtml:De(r)};return ao({tag:Fe(r),classes:a,attributes:u},c)},up=tinymce.util.Tools.resolve("tinymce.util.I18n"),ap="tox-menu-nav__js",cp="tox-collection__item",sp="tox-swatch",fp={normal:ap,color:sp},lp="tox-collection__item--enabled",dp="tox-collection__item-icon",mp="tox-collection__item-label",gp="tox-collection__item--active",pp=function(t){return Tt(fp,t).getOr(ap)},hp=tinymce.util.Tools.resolve("tinymce.Env"),vp=function(t){var e=hp.mac?{alt:"⌥",ctrl:"⌃",shift:"⇧",meta:"⌘",access:"⌃⌥"}:{meta:"Ctrl",access:"Shift+Alt"},n=t.split("+"),o=_(n,function(t){var n=t.toLowerCase().trim();return lt(e,n)?e[n]:t});return hp.mac?o.join(""):o.join("+")},bp=function(t){return{dom:{tag:"div",classes:[dp],innerHtml:t}}},yp=function(t){return{dom:{tag:"div",classes:[mp]},components:[Bu(up.translate(t))]}},xp=function(t,n){return{dom:{tag:"div",classes:[mp]},components:[{dom:{tag:t.tag,attributes:{style:t.styleAttr}},components:[Bu(up.translate(n))]}]}},wp=function(t){return{dom:{tag:"div",classes:["tox-collection__item-accessory"],innerHtml:vp(t)}}},Sp=function(t){return{dom:{tag:"div",classes:[dp,"tox-collection__item-checkmark"],innerHtml:Cg("checkmark",t)}}},kp=function(t,r,n,i){void 0===i&&(i=tt.none());var e,o,u,a,c,s,f,l,d,m,g,p=t.iconContent.map(function(t){return n=t,e=r.icons,o=i,tt.from(e()[n]).or(o).getOrThunk(function(){return kg(e)});var n,e,o}),h=tt.from(t.meta).fold(function(){return yp},function(t){return lt(t,"style")?v(xp,t.style):yp});return"color"===t.presets?(s=t.ariaLabel,f=t.value,l=r,{dom:(d=sp,m=p.getOr(""),g=s.map(function(t){return' title="'+l.translate(t)+'"'}).getOr(""),ip("custom"===f?'":"remove"===f?'
"+m+"
":'
")),optComponents:[]}):(e=t,o=p,u=h,a=n?e.checkMark.orThunk(function(){return o.or(tt.some("")).map(bp)}):tt.none(),c=e.ariaLabel.map(function(t){return{attributes:{title:up.translate(t)}}}).getOr({}),{dom:St({tag:"div",classes:[ap,cp]},c),optComponents:[a,e.textContent.map(u),e.shortcutContent.map(wp),e.caret]})},Cp=["input","button","textarea"],Op=function(t,n,e){n.disabled&&_p(t,n,e)},Tp=function(t){return T(Cp,Fe(t.element()))},Ep=function(t){Le(t.element(),"disabled","disabled")},Bp=function(t){Ge(t.element(),"disabled")},Ap=function(t){Le(t.element(),"aria-disabled","true")},Dp=function(t){Le(t.element(),"aria-disabled","false")},_p=function(n,t,e){t.disableClass.each(function(t){ou(n.element(),t)}),(Tp(n)?Ep:Ap)(n)},Mp=function(n,t,e){t.disableClass.each(function(t){ru(n.element(),t)}),(Tp(n)?Bp:Dp)(n)},Fp=function(t){return Tp(t)?We(t.element(),"disabled"):"true"===Ue(t.element(),"aria-disabled")},Ip=/* */Object.freeze({enable:Mp,disable:_p,isDisabled:Fp,onLoad:Op,set:function(t,n,e,o){(o?_p:Mp)(t,n,e)}}),Vp=/* */Object.freeze({exhibit:function(t,n,e){return Ui({classes:n.disabled?n.disableClass.map(q).getOr([]):[]})},events:function(t,n){return ii([ui(Fn(),function(t,n){return Fp(t)}),Zu(t,n,Op)])}}),Rp=[Mr("disabled",!1),Tr("disableClass")],Hp=ua({fields:Rp,name:"disabling",active:Vp,apis:Ip}),Np=function(t){return Hp.config({disabled:t,disableClass:"tox-collection__item--state-disabled"})},Pp=function(t){return Hp.config({disabled:t})},zp=function(t){return Hp.config({disabled:t,disableClass:"tox-tbtn--disabled"})},Lp=function(t,n){var e=t.getApi(n);return function(t){t(e)}},jp=function(e,o){return bi(function(t){Lp(e,t)(function(t){var n=e.onSetup(t);null!==n&&n!==undefined&&o.set(n)})})},Up=function(n,e){return yi(function(t){return Lp(n,t)(e.get())})};(Dg=Ag||(Ag={}))[Dg.CLOSE_ON_EXECUTE=0]="CLOSE_ON_EXECUTE",Dg[Dg.BUBBLE_TO_SANDBOX=1]="BUBBLE_TO_SANDBOX";var Wp,Gp,Xp=Ag,Yp={"alloy.execute":["disabling","alloy.base.behaviour","toggling","item-events"]},qp=function(t){return j(t,function(t){return t.toArray()})},Kp=function(t,n,e){var o,r,i=_t(Q);return{type:"item",dom:n.dom,components:qp(n.optComponents),data:t.data,eventOrder:Yp,hasSubmenu:t.triggersSubmenu,itemBehaviours:ra([rg("item-events",[(o=t,r=e,wi(function(t,n){Lp(o,t)(o.onAction),o.triggersSubmenu||r!==Xp.CLOSE_ON_EXECUTE||(Wr(t,Nn()),n.stop())})),jp(t,i),Up(t,i)]),Np(t.disabled),wm.config({})].concat(t.itemBehaviours))}},Jp=function(t){return{value:t.value,meta:St({text:t.text.getOr("")},t.meta)}},$p=Z(Vf("item-widget",ag())),Qp=io("cell-over"),Zp=io("cell-execute"),th=function(n,e,t){var o,r=function(t){return Gr(t,Zp,{row:n,col:e})};return _u({dom:{tag:"div",attributes:(o={role:"button"},o["aria-labelledby"]=t,o)},behaviours:ra([rg("insert-table-picker-cell",[si(Wt(),Pm.focus),si(Fn(),r),si(Rn(),r)]),$m.config({toggleClass:"tox-insert-table-picker__selected",toggleOnExecute:!1}),Pm.config({onFocus:function(t){return Gr(t,Qp,{row:n,col:e})}})])})},nh={inserttable:function QD(o){var t,n=io("size-label"),a=function(t,n,e){for(var o=[],r=0;r=r.minChars){var o=fl.getCurrent(e).bind(function(t){return kl.getHighlighted(t).map(Im.getValue)});r.previewing.set(!0),Hv(r,u(t),t,e,i,function(t){fl.getCurrent(e).each(function(t){o.fold(function(){r.model.selectsOver&&kl.highlightFirst(t)},function(n){kl.highlightBy(t,function(t){return Im.getValue(t).value===n.value}),kl.getHighlighted(t).orThunk(function(){return kl.highlightFirst(t),tt.none()})})})},iv.HighlightFirst).get(Q)}},cancelEvent:Pn()}),hm.config({mode:"special",onDown:function(t,n){return e(t,n,kl.highlightFirst),tt.some(!0)},onEscape:function(t){var n=Cv.getCoupled(t,"sandbox");return Gs.isOpen(n)?(Gs.close(n),tt.some(!0)):tt.none()},onUp:function(t,n){return e(t,n,kl.highlightLast),tt.some(!0)},onEnter:function(n){var t=Cv.getCoupled(n,"sandbox"),e=Gs.isOpen(t);if(e&&!r.previewing.get())return fl.getCurrent(t).bind(function(t){return kl.getHighlighted(t)}).map(function(t){return Gr(n,Jv(),{item:t}),!0});var o=Im.getValue(n);return Wr(n,Pn()),r.onExecute(t,n,o),e&&Gs.close(t),tt.some(!0)}}),$m.config({toggleClass:r.markers.openClass,aria:{mode:"pressed",syncWithExpanded:!0}}),Cv.config({others:{sandbox:function(t){return jv(r,t,{onOpen:d,onClose:d})}}}),rg("typeaheadevents",[wi(function(t){var n=Q;Pv(r,u(t),t,i,n,iv.HighlightFirst).get(Q)}),si(Jv(),function(t,n){var e=Cv.getCoupled(t,"sandbox");Uv(r.model,t,n.event().item()),Wr(t,Pn()),r.onItemExecute(t,e,n.event().item(),Im.getValue(t)),Gs.close(e),Gv(t)})].concat(r.dismissOnBlur?[si(Dn(),function(t){var n=Cv.getCoupled(t,"sandbox");Hl(n.element()).isNone()&&Gs.close(n)})]:[]))];return{uid:r.uid,dom:Kv(r),behaviours:ao({},o,Zs(r.typeaheadBehaviours,a)),eventOrder:r.eventOrder}}}),nb=function(t,n,e){var o=ob(t,n,e);return wv.sketch(o)},eb=function(t,n){return nb(t,n,[])},ob=function(t,n,e){return{dom:rb(e),components:t.toArray().concat([n])}},rb=function(t){return{tag:"div",classes:["tox-form__group"].concat(t)}},ib=function(t,n){return wv.parts().label({dom:{tag:"label",classes:["tox-label"],innerHtml:n.translate(t)}})},ub=function(t){return"separator"===t.type},ab={type:"separator"},cb=function(t,e){var n=U(t,function(t,n){return S(n)?""===n?t:"|"===n?0n&&r.pop(),Kb.setItem(Jb,JSON.stringify(r))},state:function(){return r.slice(0)}}}(10),ty=function(t){var n,e=[];for(n=0;n"},hw=function(o,t,n){return{uid:o.uid,dom:o.dom,components:t,behaviours:Zs(o.formBehaviours,[Im.config({store:{mode:"manual",getValue:function(t){var n=Gf(t,o);return it(n,function(t,n){return t().bind(function(t){var n,e=fl.getCurrent(t);return n="missing current",e.fold(function(){return vt.error(n)},vt.value)}).map(Im.getValue)})},setValue:function(e,t){rt(t,function(n,t){jf(e,o,t).each(function(t){fl.getCurrent(t).each(function(t){Im.setValue(t,n)})})})}}})]),apis:{getField:function(t,n){return jf(t,o,n).bind(fl.getCurrent)}}}},vw={getField:Pi(function(t,n,e){return t.getField(n,e)}),sketch:function(t){var e,n=(e=[],{field:function(t,n){return e.push(t),Hf("form",pw(t),n)},record:function(){return e}}),o=t(n),r=n.record(),i=_(r,function(t){return Bf({name:t,pname:pw(t)})});return Qf("form",gw,i,hw,o)}},bw=io("valid-input"),yw=io("invalid-input"),xw=io("validating-input"),ww="colorcustom.rgb.",Sw=function(d,m,g,p){var h=function(t,n,e,o,r){var i,u,a=d(ww+"range"),c=[wv.parts().label({dom:{tag:"label",innerHtml:e,attributes:{"aria-label":o}}}),wv.parts().field({data:r,factory:db,inputAttributes:ao({type:"text"},"hex"===n?{"aria-live":"polite"}:{}),inputClasses:[m("textfield")],inputBehaviours:ra([(i=n,u=t,Tb.config({invalidClass:m("invalid"),notify:{onValidate:function(t){Gr(t,xw,{type:i})},onValid:function(t){Gr(t,bw,{type:i,value:Im.getValue(t)})},onInvalid:function(t){Gr(t,yw,{type:i,value:Im.getValue(t)})}},validator:{validate:function(t){var n=Im.getValue(t),e=u(n)?vt.value(!0):vt.error(d("aria.input.invalid"));return Fv.pure(e)},validateOnLoad:!1}})),Ab.config({})]),onSetValue:function(t){Tb.isInvalid(t)&&Tb.run(t).get(Q)}})],s="hex"!==n?[wv.parts()["aria-descriptor"]({text:a})]:[];return{dom:{tag:"div",attributes:{role:"presentation"}},components:c.concat(s)}},v=function(t,n){var e=n.red(),o=n.green(),r=n.blue();Im.setValue(t,{red:e,green:o,blue:r})},b=Sg({dom:{tag:"div",classes:[m("rgba-preview")],styles:{"background-color":"white"},attributes:{role:"presentation"}}}),y=function(t,n){b.getOpt(t).each(function(t){lu(t.element(),"background-color","#"+n.value())})};return il({factory:function(){var e={red:Z(_t(tt.some(255))),green:Z(_t(tt.some(255))),blue:Z(_t(tt.some(255))),hex:Z(_t(tt.some("ffffff")))},o=function(t){return e[t]().get()},i=function(t,n){e[t]().set(n)},r=function(t){var n=t.red(),e=t.green(),o=t.blue();i("red",tt.some(n)),i("green",tt.some(e)),i("blue",tt.some(o))},n=function(t,n){var e=n.event();"hex"!==e.type()?i(e.type(),tt.none()):p(t)},u=function(r,t,n){var e=parseInt(n,10);i(t,tt.some(e)),o("red").bind(function(e){return o("green").bind(function(n){return o("blue").map(function(t){return jb(e,n,t,1)})})}).each(function(t){var n,e,o=(n=r,e=Rb(t),vw.getField(n,"hex").each(function(t){Pm.isFocused(t)||Im.setValue(n,{hex:e.value()})}),e);y(r,o)})},a=function(t,n){var e=n.event();"hex"===e.type()?function(t,n){g(t);var e=Db(n);i("hex",tt.some(n));var o=Gb(e);v(t,o),r(o),Gr(t,Oy(),{hex:e}),y(t,e)}(t,e.value()):u(t,e.type(),e.value())},t=function(t){return{label:d(ww+t+".label"),description:d(ww+t+".description")}},c=t("red"),s=t("green"),f=t("blue"),l=t("hex");return wt(vw.sketch(function(t){return{dom:{tag:"form",classes:[m("rgb-form")],attributes:{"aria-label":d("aria.color.picker")}},components:[t.field("red",wv.sketch(h(Ub,"red",c.label,c.description,255))),t.field("green",wv.sketch(h(Ub,"green",s.label,s.description,255))),t.field("blue",wv.sketch(h(Ub,"blue",f.label,f.description,255))),t.field("hex",wv.sketch(h(Fb,"hex",l.label,l.description,"ffffff"))),b.asSpec()],formBehaviours:ra([Tb.config({invalidClass:m("form-invalid")}),rg("rgb-form-events",[si(bw,a),si(yw,n),si(xw,n)])])}}),{apis:{updateHex:function(t,n){var e,o;Im.setValue(t,{hex:n.value()}),e=t,o=Gb(n),v(e,o),r(o),y(t,n)}}})},name:"RgbForm",configFields:[],apis:{updateHex:function(t,n,e){t.updateHex(n,e)}},extraApis:{}})},kw=function(t,o){var r=dw.parts().spectrum({dom:{tag:"canvas",attributes:{role:"presentation"},classes:[o("sv-palette-spectrum")]}}),i=dw.parts().thumb({dom:{tag:"div",attributes:{role:"presentation"},classes:[o("sv-palette-thumb")],innerHtml:"'}}),u=function(t,n){var e=t.width,o=t.height,r=t.getContext("2d");if(null!==r){r.fillStyle=n,r.fillRect(0,0,e,o);var i=r.createLinearGradient(0,0,e,0);i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(1,"rgba(255,255,255,0)"),r.fillStyle=i,r.fillRect(0,0,e,o);var u=r.createLinearGradient(0,0,0,o);u.addColorStop(0,"rgba(0,0,0,0)"),u.addColorStop(1,"rgba(0,0,0,1)"),r.fillStyle=u,r.fillRect(0,0,e,o)}};return il({factory:function(t){var n=Z({x:Z(0),y:Z(0)}),e=ra([fl.config({find:tt.some}),Pm.config({})]);return dw.sketch({dom:{tag:"div",attributes:{role:"presentation"},classes:[o("sv-palette")]},model:{mode:"xy",getInitialValue:n},rounded:!1,components:[r,i],onChange:function(t,n,e){Gr(t,Ey(),{value:e})},onInit:function(t,n,e,o){u(e.element().dom(),Yb(qb()))},sliderBehaviours:e})},name:"SaturationBrightnessPalette",configFields:[],apis:{setRgba:function(t,n,e){var o,r;o=e,r=n.components()[0].element().dom(),u(r,Yb(o))}},extraApis:{}})},Cw=function(c,s){return il({name:"ColourPicker",configFields:[br("dom"),Mr("onValidHex",Q),Mr("onInvalidHex",Q)],factory:function(t){var a,v,e=Sw(c,s,t.onValidHex,t.onInvalidHex),o=kw(c,s),b={paletteRgba:Z(_t(qb()))},n=Sg(o.sketch({})),r=Sg(e.sketch({})),i=function(t,e){n.getOpt(t).each(function(t){var n=Gb(e);b.paletteRgba().set(n),o.setRgba(t,n)})},u=function(t,n){r.getOpt(t).each(function(t){e.updateHex(t,n)})},y=function(n,e,t){M(t,function(t){t(n,e)})};return{uid:t.uid,dom:t.dom,components:[n.asSpec(),mw(c,s),r.asSpec()],behaviours:ra([rg("colour-picker-events",[si(Ey(),(v=[u],function(t,n){var e,o,r,i,u,a,c,s,f,l=n.event().value(),d=b.paletteRgba().get(),m=(i=r=0,u=(e=d).red()/255,a=e.green()/255,c=e.blue()/255,s=Math.min(u,Math.min(a,c)),f=Math.max(u,Math.max(a,c)),s===f?Cy(0,0,100*(i=s)):(r=60*((r=u===s?3:c===s?1:5)-(u===s?a-c:c===s?u-a:c-u)/(f-s)),o=(f-s)/f,i=f,Cy(Math.round(r),Math.round(100*o),Math.round(100*i)))),g=Cy(m.hue(),l.x(),100-l.y()),p=Wb(g),h=Rb(p);y(t,h,v)})),si(Ty(),(a=[i,u],function(t,n){var e,o,r,i=n.event().value(),u=(e=i.y(),o=Cy((100-e)/100*360,100,100),r=Wb(o),Rb(r));y(t,u,a)}))]),fl.config({find:function(t){return r.getOpt(t)}}),hm.config({mode:"acyclic"})])}}})},Ow=function(){return fl.config({find:tt.some})},Tw=function(t){return fl.config({find:t.getOpt})},Ew=function(t){return fl.config({find:function(n){return Se(n.element(),t).bind(function(t){return n.getSystem().getByDom(t).toOption()})}})},Bw={"colorcustom.rgb.red.label":"R","colorcustom.rgb.red.description":"Red component","colorcustom.rgb.green.label":"G","colorcustom.rgb.green.description":"Green component","colorcustom.rgb.blue.label":"B","colorcustom.rgb.blue.description":"Blue component","colorcustom.rgb.hex.label":"#","colorcustom.rgb.hex.description":"Hex color code","colorcustom.rgb.range":"Range 0 to 255","colorcustom.sb.saturation":"Saturation","colorcustom.sb.brightness":"Brightness","colorcustom.sb.picker":"Saturation and Brightness Picker","colorcustom.sb.palette":"Saturation and Brightness Palette","colorcustom.sb.instructions":"Use arrow keys to select saturation and brightness, on x and y axes","colorcustom.hue.hue":"Hue","colorcustom.hue.slider":"Hue Slider","colorcustom.hue.palette":"Hue Palette","colorcustom.hue.instructions":"Use arrow keys to select a hue","aria.color.picker":"Color Picker","aria.input.invalid":"Invalid input"},Aw=function(t){return Bw[t]},Dw=Go([Mr("preprocess",d),Mr("postprocess",d)]),_w=function(t,n,e){return Im.config(wt({store:{mode:"manual",getValue:n,setValue:e}},t.map(function(t){return{store:{initialValue:t}}}).getOr({})))},Mw=function(t,n,e){return _w(t,function(t){return n(t.element())},function(t,n){return e(t.element(),n)})},Fw=function(r,t){var i=cr("RepresentingConfigs.memento processors",Dw,t);return Im.config({store:{mode:"manual",getValue:function(t){var n=r.get(t),e=Im.getValue(n);return i.postprocess(e)},setValue:function(t,n){var e=i.preprocess(n),o=r.get(t);Im.setValue(o,e)}}})},Iw=_w,Vw=function(t){return Mw(t,De,Me)},Rw=function(t){return Im.config({store:{mode:"memory",initialValue:t}})},Hw=function(r,n){var e=function(t,n){n.stop()},o=function(t){return function(n,e){M(t,function(t){t(n,e)})}},i=function(t,n){if(!Hp.isDisabled(t)){var e=n.event().raw();a(t,e.dataTransfer.files)}},u=function(t,n){var e=n.event().raw().target.files;a(t,e)},a=function(t,n){var e,o;Im.setValue(t,(e=n,o=new RegExp("("+".jpg,.jpeg,.png,.gif".split(/\s*,\s*/).join("|")+")$","i"),V(nt(e),function(t){return o.test(t.name)}))),Gr(t,fv,{name:r.name})},c=Sg({dom:{tag:"input",attributes:{type:"file",accept:"image/*"},styles:{display:"none"}},behaviours:ra([rg("input-file-events",[pi(Rn())])])}),t=r.label.map(function(t){return ib(t,n)}),s=wv.parts().field({factory:{sketch:function(t){return{uid:t.uid,dom:{tag:"div",classes:["tox-dropzone-container"]},behaviours:ra([Rw([]),Ow(),Hp.config({}),$m.config({toggleClass:"dragenter",toggleOnExecute:!1}),rg("dropzone-events",[si("dragenter",o([e,$m.toggle])),si("dragleave",o([e,$m.toggle])),si("dragover",e),si("drop",o([e,i])),si(Jt(),u)])]),components:[{dom:{tag:"div",classes:["tox-dropzone"],styles:{}},components:[{dom:{tag:"p",innerHtml:n.translate("Drop an image here")}},wg.sketch({dom:{tag:"button",innerHtml:n.translate("Browse for an image"),styles:{position:"relative"},classes:["tox-button","tox-button--secondary"]},components:[c.asSpec()],action:function(t){c.get(t).element().dom().click()},buttonBehaviours:ra([Ab.config({})])})]}]}}}});return nb(t,s,["tox-form__group--stretched"])},Nw=io("alloy-fake-before-tabstop"),Pw=io("alloy-fake-after-tabstop"),zw=function(t){return{dom:{tag:"div",styles:{width:"1px",height:"1px",outline:"none"},attributes:{tabindex:"0"},classes:t},behaviours:ra([Pm.config({ignore:!0}),Ab.config({})])}},Lw=function(t,n){Gr(t,Yt(),{raw:{which:9,shiftKey:n}})},jw=function(t){return Fh(t,["."+Nw,"."+Pw].join(","),Z(!1))},Uw=function(t,n){var e=n.element();iu(e,Nw)?Lw(t,!0):iu(e,Pw)&&Lw(t,!1)},Ww=function(t){return{dom:{tag:"div",classes:["tox-navobj"]},components:[zw([Nw]),t,zw([Pw])],behaviours:ra([Ew(1)])}},Gw=!(En.detect().browser.isIE()||En.detect().browser.isEdge()),Xw=function(t,n){var o,r,e=Gw&&t.sandboxed,i=ao({},t.label.map(function(t){return{title:t}}).getOr({}),e?{sandbox:"allow-scripts allow-same-origin"}:{}),u=(o=e,r=_t(""),{getValue:function(t){return r.get()},setValue:function(t,n){if(o)Le(t.element(),"src","data:text/html;charset=utf-8,"+encodeURIComponent(n));else{Le(t.element(),"src","javascript:''");var e=t.element().dom().contentWindow.document;e.open(),e.write(n),e.close()}r.set(n)}}),a=t.label.map(function(t){return ib(t,n)}),c=wv.parts().field({factory:{sketch:function(t){return Ww({uid:t.uid,dom:{tag:"iframe",attributes:i},behaviours:ra([Ab.config({}),Pm.config({}),Iw(tt.none(),u.getValue,u.setValue)])})}}});return nb(a,c,["tox-form__group--stretched"])};function Yw(t,n){return Kw(x.document.createElement("canvas"),t,n)}function qw(t){return t.getContext("2d")}function Kw(t,n,e){return t.width=n,t.height=e,t}var Jw={create:Yw,clone:function t_(t){var n;return qw(n=Yw(t.width,t.height)).drawImage(t,0,0),n},resize:Kw,get2dContext:qw,get3dContext:function n_(t){var n=null;try{n=t.getContext("webgl")||t.getContext("experimental-webgl")}catch(e){}return n||(n=null),n}},$w={getWidth:function e_(t){return t.naturalWidth||t.width},getHeight:function o_(t){return t.naturalHeight||t.height}},Qw=window.Promise?window.Promise:function(){var t=function(t){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],s(t,o(r,this),o(u,this))},n=t.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(t){x.setTimeout(t,1)};function o(t,n){return function(){t.apply(n,arguments)}}var e=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(o){var r=this;null!==this._state?n(function(){var t=r._state?o.onFulfilled:o.onRejected;if(null!==t){var n;try{n=t(r._value)}catch(e){return void o.reject(e)}o.resolve(n)}else(r._state?o.resolve:o.reject)(r._value)}):this._deferreds.push(o)}function r(t){try{if(t===this)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==typeof t||"function"==typeof t)){var n=t.then;if("function"==typeof n)return void s(o(n,t),o(r,this),o(u,this))}this._state=!0,this._value=t,a.call(this)}catch(e){u.call(this,e)}}function u(t){this._state=!1,this._value=t,a.call(this)}function a(){for(var t=0,n=this._deferreds.length;tthis.length())return null;for(var e=this.littleEndian?0:-8*(n-1),o=0,r=0;o").css({position:"absolute",top:0,left:0,width:o.width,height:o.height,zIndex:2147483647,opacity:1e-4,cursor:e}).appendTo(d.body),uk(d).on("mousemove touchmove",c).on("mouseup touchend",a),r.start(t)},c=function(t){if(lk(t),t.button!==u)return a(t);t.deltaX=t.screenX-f,t.deltaY=t.screenY-l,t.preventDefault(),r.drag(t)},a=function(t){lk(t),uk(d).off("mousemove touchmove",c).off("mouseup touchend",a),i.remove(),r.stop&&r.stop(t)},this.destroy=function(){uk(m).off()},uk(m).on("mousedown touchstart",n)}var mk,gk,pk,hk=0,vk=function(n){var f=Sg({dom:{tag:"div",classes:["tox-image-tools__image-bg"],attributes:{role:"presentation"}}}),l=_t(1),d=_t(tt.none()),m=_t({x:0,y:0,w:1,h:1}),c=_t({x:0,y:0,w:1,h:1}),s=function(t,s){g.getOpt(t).each(function(t){var e=l.get(),o=Sa(t.element()),r=Oa(t.element()),i=s.dom().naturalWidth*e,u=s.dom().naturalHeight*e,a=Math.max(0,o/2-i/2),c=Math.max(0,r/2-u/2),n={left:a.toString()+"px",top:c.toString()+"px",width:i.toString()+"px",height:u.toString()+"px",position:"absolute"};du(s,n),f.getOpt(t).each(function(t){du(t.element(),n)}),d.get().each(function(t){var n=m.get();t.setRect({x:n.x*e+a,y:n.y*e+c,w:n.w*e,h:n.h*e}),t.setClampRect({x:a,y:c,w:i,h:u}),t.setViewPortRect({x:0,y:0,w:o,h:r})})})},e=function(t,n){var e,a=Zn.fromTag("img");return Le(a,"src",n),(e=a.dom(),new Vg(function(t){var n=function(){e.removeEventListener("load",n),t(e)};e.complete?t(e):e.addEventListener("load",n)})).then(function(){return g.getOpt(t).map(function(t){var n=Au({element:a});wm.replaceAt(t,1,tt.some(n));var e=c.get(),o={x:0,y:0,w:a.dom().naturalWidth,h:a.dom().naturalHeight};c.set(o);var r,u,i=ak.inflate(o,-20,-20);return m.set(i),e.w===o.w&&e.h===o.h||(r=t,u=a,g.getOpt(r).each(function(t){var n=Sa(t.element()),e=Oa(t.element()),o=u.dom().naturalWidth,r=u.dom().naturalHeight,i=Math.min(n/o,e/r);1<=i?l.set(1):l.set(i)})),s(t,a),a})})},t=Qh.sketch({dom:{tag:"div",classes:["tox-image-tools__image"]},components:[f.asSpec(),{dom:{tag:"img",attributes:{src:n}}},{dom:{tag:"div"},behaviours:ra([rg("image-panel-crop-events",[bi(function(t){g.getOpt(t).each(function(t){var n=function S(s,e,f,o,r){var l,u,n,i,a="tox-",c="tox-crid-"+hk++;function d(t,n){return{x:n.x-t.x,y:n.y-t.y,w:n.w,h:n.h}}function m(t,n,e,o){var r,i,u,a,c;r=n.x,i=n.y,u=n.w,a=n.h,r+=e*t.deltaX,i+=o*t.deltaY,(u+=e*t.deltaW)<20&&(u=20),(a+=o*t.deltaH)<20&&(a=20),c=s=ak.clamp({x:r,y:i,w:u,h:a},f,"move"===t.name),c=d(f,c),l.fire("updateRect",{rect:c}),h(c)}function g(n){function t(t,n){n.h<0&&(n.h=0),n.w<0&&(n.w=0),uk("#"+c+"-"+t,o).css({left:n.x,top:n.y,width:n.w,height:n.h})}sk.each(u,function(t){uk("#"+c+"-"+t.name,o).css({left:n.w*t.xMul+n.x,top:n.h*t.yMul+n.y})}),t("top",{x:e.x,y:e.y,w:e.w,h:n.y-e.y}),t("right",{x:n.x+n.w,y:n.y,w:e.w-n.x-n.w+e.x,h:n.h}),t("bottom",{x:e.x,y:n.y+n.h,w:e.w,h:e.h-n.y-n.h+e.y}),t("left",{x:e.x,y:n.y,w:n.x-e.x,h:n.h}),t("move",n)}function p(t){g(s=t)}function h(t){p(function e(t,n){return{x:n.x+t.x,y:n.y+t.y,w:n.w,h:n.h}}(f,t))}return u=[{name:"move",xMul:0,yMul:0,deltaX:1,deltaY:1,deltaW:0,deltaH:0,label:"Crop Mask"},{name:"nw",xMul:0,yMul:0,deltaX:1,deltaY:1,deltaW:-1,deltaH:-1,label:"Top Left Crop Handle"},{name:"ne",xMul:1,yMul:0,deltaX:0,deltaY:1,deltaW:1,deltaH:-1,label:"Top Right Crop Handle"},{name:"sw",xMul:0,yMul:1,deltaX:1,deltaY:0,deltaW:-1,deltaH:1,label:"Bottom Left Crop Handle"},{name:"se",xMul:1,yMul:1,deltaX:0,deltaY:0,deltaW:1,deltaH:1,label:"Bottom Right Crop Handle"}],i=["top","right","bottom","left"],function v(){uk('
').appendTo(o),sk.each(i,function(t){uk("#"+c,o).append(''),components:[],behaviours:ra([HO.config({channel:aD,initialData:t,updateState:function(t,n){var r=_(n.buttons,function(t){var n,e,o=Sg((e=i,WS(n=t,n.type,e)));return{name:t.name,align:t.align,memento:o}});return tt.some({lookupByName:function(t,n){return e=t,o=n,H(r,function(t){return t.name===o}).bind(function(t){return t.memento.getOpt(e)});var e,o},footerButtons:r})},renderComponents:mD})])}},pD=function(t,n){return KB.parts().footer(gD(t,n))},hD=function(n,e){if(n.getRoot().getSystem().isConnected()){var o=fl.getCurrent(n.getFormWrapper()).getOr(n.getFormWrapper());return vw.getField(o,e).fold(function(){var t=n.getFooter();return HO.getState(t).get().bind(function(t){return t.lookupByName(o,e)})},function(t){return tt.some(t)})}return tt.none()},vD=function(c,o){var t=function(t){var n=c.getRoot();n.getSystem().isConnected()&&t(n)},s={getData:function(){var t=c.getRoot(),n=t.getSystem().isConnected()?c.getFormWrapper():t;return Im.getValue(n)},setData:function(a){t(function(t){var n,e,o=s.getData(),r=St(o,a),i=(n=r,e=c.getRoot(),HO.getState(e).get().map(function(t){return ar(ur("data",t.dataValidator,n))}).getOr(n)),u=c.getFormWrapper();Im.setValue(u,i)})},disable:function(t){hD(c,t).each(Hp.disable)},enable:function(t){hD(c,t).each(Hp.enable)},focus:function(t){hD(c,t).each(Pm.focus)},block:function(n){if(!S(n))throw new Error("The dialogInstanceAPI.block function should be passed a blocking message of type string as an argument");t(function(t){Gr(t,pv,{message:n})})},unblock:function(){t(function(t){Wr(t,hv)})},showTab:function(e){t(function(t){var n=c.getBody();HO.getState(n).get().exists(function(t){return t.isTabPanel()})&&fl.getCurrent(n).each(function(t){ZA.showTab(t,e)})})},redial:function(e){t(function(t){var n=o(e);t.getSystem().broadcastOn([rD],n),t.getSystem().broadcastOn([iD],n.internalDialog),t.getSystem().broadcastOn([uD],n.internalDialog),t.getSystem().broadcastOn([aD],n.internalDialog),s.setData(n.initialData)})},close:function(){t(function(t){Wr(t,lv)})}};return s},bD=function(t){return wg.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":t.translate("Close"),title:t.translate("Close")}},components:[{dom:{tag:"div",classes:["tox-icon"],innerHtml:''}}],action:function(t){Wr(t,dv)}})},yD=function(t,n,e){var o=function(t){return[Bu(e.translate(t.title))]};return{dom:{tag:"div",classes:["tox-dialog__title"],attributes:ao({},n.map(function(t){return{id:t}}).getOr({}))},components:o(t),behaviours:ra([HO.config({channel:iD,renderComponents:o})])}},xD=function(t,n){return e={title:n.shared.providers.translate(t),draggable:!0},o=n.shared.providers,r=KB.parts().title(yD(e,tt.none(),o)),i=KB.parts().draghandle({dom:ip('
')}),u=KB.parts().close(bD(o)),a=[r].concat(e.draggable?[i]:[]).concat([u]),Qh.sketch({dom:ip('
'),components:a});var e,o,r,i,u,a},wD=function(t,n){return{onClose:function(){return n.closeWindow()},onBlock:function(e){KB.setBusy(t(),function(t,n){return{dom:{tag:"div",classes:["tox-dialog__busy-spinner"],attributes:{"aria-label":e.message()},styles:{left:"0px",right:"0px",bottom:"0px",top:"0px",position:"absolute"}},behaviours:n,components:[{dom:ip('
')}]}})},onUnblock:function(){KB.setIdle(t())}}},SD=function(t,n,e,o){var r;return _u(KB.sketch({lazySink:o.shared.getSink,onEscape:function(t){return Wr(t,dv),tt.some(!0)},useTabstopAt:function(t){return!jw(t)&&("button"!==Fe(t)||"disabled"!==Ue(t,"disabled"))},modalBehaviours:ra([HO.config({channel:rD,updateState:function(t,n){return tt.some(n)},initialData:n}),Rw({}),Pm.config({}),rg("execute-on-form",e.concat([vi(Gt(),function(t,n){hm.focusIn(t)})])),rg("scroll-lock",[bi(function(){ou(Zr(),"tox-dialog__disable-scroll")}),yi(function(){ru(Zr(),"tox-dialog__disable-scroll")})])].concat(t.extraBehaviours)),eventOrder:(r={},r[Fn()]=["execute-on-form"],r[Mn()]=["reflecting","receiving"],r[Un()]=["scroll-lock","reflecting","messages","execute-on-form","alloy.base.behaviour"],r[Wn()]=["alloy.base.behaviour","execute-on-form","messages","reflecting","scroll-lock"],r),dom:{tag:"div",classes:["tox-dialog"].concat(t.extraClasses),styles:ao({position:"relative"},t.extraStyles)},components:[t.header,t.body].concat(t.footer.toArray()),dragBlockClass:"tox-dialog-wrap",parts:{blocker:{dom:ip('
'),components:[{dom:{tag:"div",classes:["tox-dialog-wrap__backdrop"]}}]}}}))},kD=function(t,n,e){var o,r,i,u=xD(t.internalDialog.title,e),a=(o={body:t.internalDialog.body},r=e,i=sD(o,tt.none(),r,!1),KB.parts().body(i)),c=pD({buttons:t.internalDialog.buttons},e.shared.providers),s=dD(function(){return m},wD(function(){return d},n)),f="normal"!==t.internalDialog.size?"large"===t.internalDialog.size?["tox-dialog--width-lg"]:["tox-dialog--width-md"]:[],l={header:u,body:a,footer:tt.some(c),extraClasses:f,extraBehaviours:[],extraStyles:{}},d=SD(l,t,s,e),m=vD({getRoot:function(){return d},getBody:function(){return KB.getBody(d)},getFooter:function(){return KB.getFooter(d)},getFormWrapper:function(){var t=KB.getBody(d);return fl.getCurrent(t).getOr(t)}},n.redial);return{dialog:d,instanceApi:m}},CD=tinymce.util.Tools.resolve("tinymce.util.URI"),OD=["insertContent","setContent","execCommand","close","block","unblock"],TD=function(t){return k(t)&&-1!==OD.indexOf(t.mceAction)},ED=function(o,t,r,n){var e,i,u,a,c=xD(o.title,n),s=(i={dom:{tag:"div",classes:["tox-dialog__content-js"]},components:[{dom:{tag:"div",classes:["tox-dialog__body-iframe"]},components:[Ww({dom:{tag:"iframe",attributes:{src:o.url}},behaviours:ra([Ab.config({}),Pm.config({})])})]}],behaviours:ra([hm.config({mode:"acyclic",useTabstopAt:w(jw)})])},KB.parts().body(i)),f=o.buttons.bind(function(t){return 0===t.length?tt.none():tt.some(pD({buttons:t},n.shared.providers))}),l=lD(function(){return y},wD(function(){return b},t)),d=ao({},o.height.fold(function(){return{}},function(t){return{height:t+"px","max-height":t+"px"}}),o.width.fold(function(){return{}},function(t){return{width:t+"px","max-width":t+"px"}})),m=o.width.isNone()&&o.height.isNone()?["tox-dialog--width-lg"]:[],g=new CD(o.url,{base_uri:new CD(x.window.location.href)}),p=g.protocol+"://"+g.host+(g.port?":"+g.port:""),h=_t(tt.none()),v=[rg("messages",[bi(function(){var t=_h(Zn.fromDom(x.window),"message",function(t){if(g.isSameOrigin(new CD(t.raw().origin))){var n=t.raw().data;TD(n)?function(t,n,e){switch(e.mceAction){case"insertContent":t.insertContent(e.content);break;case"setContent":t.setContent(e.content);break;case"execCommand":var o=!!C(e.ui)&&e.ui;t.execCommand(e.cmd,o,e.value);break;case"close":n.close();break;case"block":n.block(e.message);break;case"unblock":n.unblock()}}(r,y,n):!TD(e=n)&&k(e)&<(e,"mceAction")&&o.onMessage(y,n)}var e});h.set(tt.some(t))}),yi(function(){h.get().each(function(t){return t.unbind()})})]),da.config({channels:(e={},e[cD]={onReceive:function(t,n){Vu(t.element(),"iframe").each(function(t){t.dom().contentWindow.postMessage(n,p)})}},e)})],b=SD({header:c,body:s,footer:f,extraClasses:m,extraBehaviours:v,extraStyles:d},o,l,n),y=(u=b,a=function(t){u.getSystem().isConnected()&&t(u)},{block:function(n){if(!S(n))throw new Error("The urlDialogInstanceAPI.block function should be passed a blocking message of type string as an argument");a(function(t){Gr(t,pv,{message:n})})},unblock:function(){a(function(t){Wr(t,hv)})},close:function(){a(function(t){Wr(t,lv)})},sendMessage:function(n){a(function(t){t.getSystem().broadcastOn([cD],n)})}});return{dialog:b,instanceApi:y}},BD=function(t,n,e,o){var r,i,u,a,c,s,f,l,d,m,g,p=io("dialog-label"),h=io("dialog-content"),v=Sg((u={title:t.internalDialog.title,draggable:!0},a=p,c=e.shared.providers,Qh.sketch({dom:ip('
'),components:[yD(u,tt.some(a),c),bD(c)],containerBehaviours:ra([SB.config({mode:"mouse",blockerClass:"blocker",getTarget:function(t){return Ru(t,'[role="dialog"]').getOrDie()},snaps:{getSnapPoints:function(){return[]},leftAttr:"data-drag-left",topAttr:"data-drag-top"}})])}))),b=Sg((s={body:t.internalDialog.body},f=h,l=e,d=o,sD(s,tt.some(f),l,d))),y=Sg((m={buttons:t.internalDialog.buttons},g=e.shared.providers,gD(m,g))),x=dD(function(){return S},{onBlock:function(){},onUnblock:function(){},onClose:function(){return n.closeWindow()}}),w=_u({dom:{tag:"div",classes:["tox-dialog"],attributes:(r={role:"dialog"},r["aria-labelledby"]=p,r["aria-describedby"]=""+h,r)},eventOrder:(i={},i[Mn()]=[HO.name(),da.name()],i[Fn()]=["execute-on-form"],i[Un()]=["reflecting","execute-on-form"],i),behaviours:ra([hm.config({mode:"cyclic",onEscape:function(t){return Wr(t,lv),tt.some(!0)},useTabstopAt:function(t){return!jw(t)&&("button"!==Fe(t)||"disabled"!==Ue(t,"disabled"))}}),HO.config({channel:rD,updateState:function(t,n){return tt.some(n)},initialData:t}),rg("execute-on-form",x),Rw({})]),components:[v.asSpec(),b.asSpec(),y.asSpec()]}),S=vD({getRoot:function(){return w},getFooter:function(){return y.get(w)},getBody:function(){return b.get(w)},getFormWrapper:function(){var t=b.get(w);return fl.getCurrent(t).getOr(t)}},n.redial);return{dialog:w,instanceApi:S}},AD=function(t,n){return KB.parts().close(wg.sketch({dom:{tag:"button",classes:["tox-button","tox-button--icon","tox-button--naked"],attributes:{type:"button","aria-label":n.translate("Close")}},action:t,buttonBehaviours:ra([Ab.config({})])}))},DD=function(){return KB.parts().title({dom:{tag:"div",classes:["tox-dialog__title"],innerHtml:"",styles:{display:"none"}}})},_D=function(t,n){return KB.parts().body({dom:{tag:"div",classes:["tox-dialog__body","todo-tox-fit"]},components:[{dom:ip("

"+n.translate(t)+"

")}]})},MD=function(t){return KB.parts().footer({dom:{tag:"div",classes:["tox-dialog__footer"]},components:t})},FD=function(t,n){return[Qh.sketch({dom:{tag:"div",classes:["tox-dialog__footer-start"]},components:t}),Qh.sketch({dom:{tag:"div",classes:["tox-dialog__footer-end"]},components:n})]},ID=function(e){return KB.sketch({lazySink:e.lazySink,onEscape:function(){return e.onCancel(),tt.some(!0)},dom:{tag:"div",classes:["tox-dialog"].concat(e.extraClasses)},components:[{dom:{tag:"div",classes:["tox-dialog__header"]},components:[e.partSpecs.title,e.partSpecs.close]},e.partSpecs.body,e.partSpecs.footer],parts:{blocker:{dom:ip('
'),components:[{dom:{tag:"div",classes:["tox-dialog-wrap__backdrop"]}}]}},modalBehaviours:ra([rg("basic-dialog-events",[si(dv,function(t,n){e.onCancel()}),si(gv,function(t,n){e.onSubmit()})])])})},VD=function(s){var u,a,e=(u=s.backstage.shared,{open:function(t,n){var e=function(){KB.hide(r),n()},o=Sg(WS({name:"close-alert",text:"OK",primary:!0,icon:tt.none()},"cancel",u.providers)),r=_u(ID({lazySink:function(){return u.getSink()},partSpecs:{title:DD(),close:AD(function(){e()},u.providers),body:_D(t,u.providers),footer:MD(FD([],[o.asSpec()]))},onCancel:function(){return e()},onSubmit:Q,extraClasses:["tox-alert-dialog"]}));KB.show(r);var i=o.get(r);Pm.focus(i)}}),o=(a=s.backstage.shared,{open:function(t,n){var e=function(t){KB.hide(i),n(t)},o=Sg(WS({name:"yes",text:"Yes",primary:!0,icon:tt.none()},"submit",a.providers)),r=WS({name:"no",text:"No",primary:!0,icon:tt.none()},"cancel",a.providers),i=_u(ID({lazySink:function(){return a.getSink()},partSpecs:{title:DD(),close:AD(function(){e(!1)},a.providers),body:_D(t,a.providers),footer:MD(FD([],[r,o.asSpec()]))},onCancel:function(){return e(!1)},onSubmit:function(){return e(!0)},extraClasses:["tox-confirm-dialog"]}));KB.show(i);var u=o.get(i);Pm.focus(u)}}),r=function(t,e){return LA.openUrl(function(t){var n=ED(t,{closeWindow:function(){KB.hide(n.dialog),e(n.instanceApi)}},s.editor,s.backstage);return KB.show(n.dialog),n.instanceApi},t)},i=function(t,i){return LA.open(function(t,n,e){var o=n,r=kD({dataValidator:e,initialData:o,internalDialog:t},{redial:LA.redial,closeWindow:function(){KB.hide(r.dialog),i(r.instanceApi)}},s.backstage);return KB.show(r.dialog),r.instanceApi.setData(o),r.instanceApi},t)},c=function(t,u,a,c){return LA.open(function(t,n,e){var o=ar(ur("data",e,n)),r=BD({dataValidator:e,initialData:o,internalDialog:t},{redial:LA.redial,closeWindow:function(){yg.hide(i),a(r.instanceApi)}},s.backstage,c),i=_u(yg.sketch({lazySink:s.backstage.shared.getSink,dom:{tag:"div",classes:[]},fireDismissalEventInstead:{},inlineBehaviours:ra([rg("window-manager-inline-events",[si(Gn(),function(t,n){Wr(r.dialog,dv)})])])}));return yg.showAt(i,u,Mu(r.dialog)),r.instanceApi.setData(o),hm.focusIn(r.dialog),r.instanceApi},t)};return{open:function(t,n,e){return n!==undefined&&"toolbar"===n.inline?c(t,s.backstage.shared.anchors.toolbar(),e,n.ariaAttrs):n!==undefined&&"cursor"===n.inline?c(t,s.backstage.shared.anchors.cursor(),e,n.ariaAttrs):i(t,e)},openUrl:function(t,n){return r(t,n)},alert:function(t,n){e.open(t,function(){n()})},close:function(t){t.close()},confirm:function(t,n){o.open(t,function(t){n(t)})}}};uo.add("silver",function(t){var n=IB(t),e=n.mothership,o=n.uiMothership,r=n.backstage,i=n.renderUI,u=n.getUi;WB(t,r),eo(io("silver-demo"),e),eo(io("silver-ui-demo"),o),Th(t,r.shared);var a=VD({editor:t,backstage:r});return{renderUI:i,getWindowManagerImpl:Z(a),getNotificationManagerImpl:function(){return Bg(t,{backstage:r},o)},ui:u()}}),function E_(){}}(window);