/** * 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.9 (2019-06-26) */ !function(v){"use strict";var y=function(){return(y=Object.assign||function(n){for(var e,t=1,r=arguments.length;tc[0]&&n[1] "+r.toString()},function(n,e){return"state("+n+")"})}).join("\n")+"}"},toDsl:function(){return er.objOf(kn(c,function(n){return n.fold(function(n,e,t,r){return tr.field(n,t,r)},function(n,e){return tr.state(n)})}))}}},gr=function(t,i){var u=function(n,e){return(o=lr(t),{extract:function(t,r,n){var e=kn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return nr(e)},toString:function(){return"array("+o.toString()+")"},toDsl:function(){return er.arrOf(o)}}).extract(n,w,e);var o};return{extract:function(t,r,o){var n=I(o),e=u(t,n);return qt(e,function(n){var e=kn(n,function(n){return cr.field(n,n,Ot(),i)});return mr(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"},toDsl:function(){return er.setOf(t,i)}}},pr=h(lr(Ut)),vr=cr.state,hr=cr.field,br=function(t,e,r,o,i){return At(o,i).fold(function(){return n=o,e=i,ur(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+ir(n)});var n,e},function(n){return mr(n).extract(t.concat(["branch: "+i]),e,r)})},yr=function(o,i){return{extract:function(e,t,r){return At(r,o).fold(function(){return n=o,ur(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return br(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+I(i)},toDsl:function(){return er.choiceOf(o,i)}}},xr=lr(Ut),wr=function(e){return lr(function(n){return e(n).fold(Xt,Ut)})},Sr=function(e,n){return gr(function(n){return $t(e(n))},n)},Or=function(n,e,t){return _t((r=n,o=w,i=t,u=e.extract([r],o,i),Jt(u,function(n){return{input:i,errors:n}})));var r,o,i,u},Tr=function(n){return n.fold(function(n){throw new Error(Er(n))},w)},kr=function(n,e,t){return Tr(Or(n,e,t))},Er=function(n){return"Errors: \n"+(e=n.errors,t=10 ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+ir(n.input);var e,t},Cr=function(n,e){return yr(n,e)},Dr=h(xr),Mr=(Ht=yn,Pt="function",lr(function(n){var e=typeof n;return Ht(n)?Ut(n):Xt("Expected type: "+Pt+" but got: "+e)})),Ir=function(n){return hr(n,n,Ot(),pr())},Rr=function(n,e){return hr(n,n,Ot(),e)},Br=function(n,e){return hr(n,n,Ot(),mr(e))},Ar=function(n){return hr(n,n,Tt(),pr())},Fr=function(n,e){return hr(n,n,Tt(),e)},Vr=function(n,e){return Fr(n,mr(e))},Nr=function(n,e){return Fr(n,dr(e))},jr=function(n,e){return hr(n,n,St(e),pr())},Hr=function(n,e,t){return hr(n,n,St(e),t)},Pr=function(n,e){return vr(n,e)},zr=function(n,e){return qe(n.element(),e.event().target())},Lr=function(n){if(!jt(n,"can")&&!jt(n,"abort")&&!jt(n,"run"))throw new Error("EventHandler defined by: "+or(n,null,2)+" does not have can, abort, or run!");return kr("Extracting event.handler",dr([jr("can",h(!0)),jr("abort",h(!1)),jr("run",x)]),n)},Gr=function(t){var e,r,o,i,n=(e=t,r=function(n){return n.can},function(){for(var t=[],n=0;n"}),Dr()),qa=Pr("schema",function(){return[Ar("preprocess")]}),Ya=jr("defaults",h({})),Ka=jr("overrides",h({})),Ja=mr([_a,Ua,Wa,Xa,Ya,Ka]),Qa=mr([_a,Ua,Wa,Xa,Ya,Ka]),Za=mr([_a,qa,Wa,Ir("unit"),Xa,Ya,Ka]),nf=function(n){var e=function(n){return n.name};return n.fold(e,e,e,e)},ef=function(t,r){return function(n){var e=kr("Converting part type",r,n);return t(e)}},tf=ef($a.required,Ja),rf=ef($a.optional,Qa),of=ef($a.group,Za),uf=h("entirety"),cf=function(n,e,t,r){return yt(e.defaults(n,t,r),t,{uid:n.partUids[e.name]},e.overrides(n,t,r))},af=function(o,n){var i={};return En(n,function(n){var e;(e=n,e.fold(M.some,M.none,M.some,M.some)).each(function(t){var r=ff(o,t.pname);i[t.name]=function(n){var e=kr("Part: "+t.name+" in "+o,mr(t.schema),n);return y({},r,{config:n,validated:e})}})}),i},ff=function(n,e){return{uiType:za(),owner:n,name:e}},sf=function(n,e,t){return{uiType:za(),owner:n,name:e,config:t,validated:{}}},lf=function(n){return Nn(n,function(n){return n.fold(M.none,M.some,M.none,M.none).map(function(n){return Br(n.name,n.schema.concat([Ci(uf())]))}).toArray()})},df=function(n){return kn(n,nf)},mf=function(n,e,t){return r=e,i={},o={},En(t,function(n){n.fold(function(r){i[r.pname]=Ha(!0,function(n,e,t){return r.factory.sketch(cf(n,r,e,t))})},function(n){var e=r.parts[n.name];o[n.name]=h(n.factory.sketch(cf(r,n,e[uf()]),e))},function(r){i[r.pname]=Ha(!1,function(n,e,t){return r.factory.sketch(cf(n,r,e,t))})},function(o){i[o.pname]=Pa(!0,function(e,n,t){var r=e[o.name];return kn(r,function(n){return o.factory.sketch(yt(o.defaults(e,n,t),n,o.overrides(e,n)))})})})}),{internals:h(i),externals:h(o)};var r,i,o},gf=function(n,e,t){return ja(M.some(n),e,e.components,t)},pf=function(n,e,t){var r=e.partUids[t];return n.getSystem().getByUid(r).toOption()},vf=function(n,e,t){return pf(n,e,t).getOrDie("Could not find part: "+t)},hf=function(n,e){var t=n.getSystem();return A(e.partUids,function(n,e){return h(t.getByUid(n))})},bf=function(e,n){var t=df(n);return Vt(kn(t,function(n){return{key:n,value:e+"-"+n}}))},yf=function(e){return hr("partUids","partUids",Et(function(n){return bf(n.uid,e)}),Dr())},xf=Ga("alloy-premade"),wf=function(n){return Ft(xf,n)},Sf=function(n){return At(n,xf)},Of=function(r){return n=function(n){for(var e=[],t=1;t')},function(n){return Lf(''+n+"")})},Uf=function(n,e,t,r){return Hf.sketch({dom:_f(n,r),action:e,buttonBehaviours:yt(xo([Pf.config({})]),t)})},Wf={forToolbar:Uf,forToolbarCommand:function(n,e){return Uf(e,function(){n.execCommand(e)},{},n)},forToolbarStateAction:function(n,e,t,r){var o=$f(t);return Uf(e,r,o,n)},forToolbarStateCommand:function(n,e){var t=$f(e);return Uf(e,function(){n.execCommand(e)},t,n)},getToolbarIconButton:_f},Xf=Jn.detect().deviceType.isTouch(),qf=rf({schema:[Ir("dom")],name:"label"}),Yf=function(n){return rf({name:n+"-edge",overrides:function(r){return r.model.manager.edgeActions[n].fold(function(){return{}},function(t){var n=Yr([Zr(j(),t,[r])]),e=Yr([Zr(z(),t,[r]),Zr(L(),function(n,e){e.mouseIsDown.get()&&t(n,e)},[r])]);return{events:Xf?n:e}})}})},Kf=Yf("top-left"),Jf=Yf("top"),Qf=Yf("top-right"),Zf=Yf("right"),ns=Yf("bottom-right"),es=Yf("bottom"),ts=Yf("bottom-left"),rs=[qf,Yf("left"),Zf,Jf,es,Kf,Qf,ts,ns,tf({name:"thumb",defaults:h({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:Yr([to(j(),n,"spectrum"),to(H(),n,"spectrum"),to(P(),n,"spectrum"),to(z(),n,"spectrum"),to(L(),n,"spectrum"),to(G(),n,"spectrum")])}}}),tf({schema:[Pr("mouseIsDown",function(){return _o(!1)})],name:"spectrum",overrides:function(t){var r=t.model.manager,o=function(e,n){return r.getValueFromEvent(n).map(function(n){return r.setValueFrom(e,t,n)})},n=Yr([Qr(j(),o),Qr(H(),o)]),e=Yr([Qr(z(),o),Qr(L(),function(n,e){t.mouseIsDown.get()&&o(n,e)})]);return{behaviours:xo(Xf?[]:[Ca.config({mode:"special",onLeft:function(n){return r.onLeft(n,t)},onRight:function(n){return r.onRight(n,t)},onUp:function(n){return r.onUp(n,t)},onDown:function(n){return r.onDown(n,t)}}),Qi.config({})]),events:Xf?n:e}}})],os=function(n,e,t){e.store.manager.onLoad(n,e,t)},is=function(n,e,t){e.store.manager.onUnload(n,e,t)},us=/* */Object.freeze({onLoad:os,onUnload:is,setValue:function(n,e,t,r){e.store.manager.setValue(n,e,t,r)},getValue:function(n,e,t){return e.store.manager.getValue(n,e,t)},getState:function(n,e,t){return t}}),cs=/* */Object.freeze({events:function(t,r){var n=t.resetOnDom?[uo(function(n,e){os(n,t,r)}),co(function(n,e){is(n,t,r)})]:[go(t,r,os)];return Yr(n)}}),as=function(){var n=_o(null);return yo({set:n.set,get:n.get,isNotSet:function(){return null===n.get()},clear:function(){n.set(null)},readState:function(){return{mode:"memory",value:n.get()}}})},fs=function(){var i=_o({}),u=_o({});return yo({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return At(i.get(),n).orThunk(function(){return At(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};En(n,function(e){r[e.value]=e,At(e,"meta").each(function(n){At(n,"text").each(function(n){o[n]=e})})}),i.set(y({},e,r)),u.set(y({},t,o))},clear:function(){i.set({}),u.set({})}})},ss=/* */Object.freeze({memory:as,dataset:fs,manual:function(){return yo({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),ls=function(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)},ds=[Ar("initialValue"),Ir("getFallbackEntry"),Ir("getDataKey"),Ir("setValue"),Ei("manager",{setValue:ls,getValue:function(n,e,t){var r=e.store,o=r.getDataKey(n);return t.lookup(o).fold(function(){return r.getFallbackEntry(o)},function(n){return n})},onLoad:function(e,t,r){t.store.initialValue.each(function(n){ls(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:fs})],ms=[Ir("getValue"),jr("setValue",x),Ar("initialValue"),Ei("manager",{setValue:function(n,e,t,r){e.store.setValue(n,r),e.onSetValue(n,r)},getValue:function(n,e,t){return e.store.getValue(n)},onLoad:function(e,t,n){t.store.initialValue.each(function(n){t.store.setValue(e,n)})},onUnload:x,state:bo.init})],gs=[Ar("initialValue"),Ei("manager",{setValue:function(n,e,t,r){t.set(r),e.onSetValue(n,r)},getValue:function(n,e,t){return t.get()},onLoad:function(n,e,t){e.store.initialValue.each(function(n){t.isNotSet()&&t.set(n)})},onUnload:function(n,e,t){t.clear()},state:as})],ps=[Hr("store",{mode:"memory"},Cr("mode",{memory:gs,manual:ms,dataset:ds})),Si("onSetValue"),jr("resetOnDom",!1)],vs=So({fields:ps,name:"representing",active:cs,apis:us,extra:{setValueFrom:function(n,e){var t=vs.getValue(e);vs.setValue(n,t)}},state:ss}),hs=function(t,r){return{left:h(t),top:h(r),translate:function(n,e){return hs(t+n,r+e)}}},bs=hs,ys=Jn.detect().deviceType.isTouch(),xs=h("slider.change.value"),ws=function(n){var e=n.event().raw();if(ys){var t=e;return t.touches!==undefined&&1===t.touches.length?M.some(t.touches[0]).map(function(n){return bs(n.clientX,n.clientY)}):M.none()}var r=e;return r.clientX!==undefined?M.some(r).map(function(n){return bs(n.clientX,n.clientY)}):M.none()},Ss=function(n,e,t,r){return n'),components:[Yl.parts()["left-edge"](Gf('
')),Yl.parts().spectrum({dom:Lf('
'),components:[Gf('
')],behaviours:xo([Gi.config({toggleClass:Xi.resolve("thumb-active")})])}),Yl.parts()["right-edge"](Gf('
')),Yl.parts().thumb({dom:Lf('
'),behaviours:xo([Gi.config({toggleClass:Xi.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());tu(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){Gi.on(e)},onDragEnd:function(n,e){Gi.off(e)},onInit:function(n,e,t,r){var o=i(r.x());tu(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:xo([_i(Yl.refresh)])}))];var o,i},Ql=function(n,r){var e={onChange:function(n,e,t){r.undoManager.transact(function(){r.formatter.apply("forecolor",{value:t}),r.nodeChanged()})},getInitialValue:function(){return-1}};return Kl(n,"color-levels",function(){return Jl(e)},r)},Zl=dr([Ir("getInitialValue"),Ir("onChange"),Ir("category"),Ir("sizes")]),nd=function(n){var i=kr("SizeSlider",Zl,n);return Yl.sketch({dom:{tag:"div",classes:[Xi.resolve("slider-"+i.category+"-size-container"),Xi.resolve("slider"),Xi.resolve("slider-size-container")]},onChange:function(n,e,t){var r,o=t.x();0<=(r=o)&&r'),components:[Gf('
')]}),Yl.parts().thumb({dom:Lf('
'),behaviours:xo([Gi.config({toggleClass:Xi.resolve("thumb-active")})])})]})},ed=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],td=function(n){var e,t,r=n.selection.getStart(),o=xe.fromDom(r),i=xe.fromDom(n.getBody()),u=(e=function(n){return qe(i,n)},(Ce(t=o)?M.some(t):Ke(t)).map(function(n){return Wr(n,function(n){return uu(n,"font-size").isSome()},e).bind(function(n){return uu(n,"font-size")}).getOrThunk(function(){return ou(n,"font-size")})}).getOr(""));return Rn(ed,function(n){return u===n}).getOr("medium")},rd={candidates:h(ed),get:function(n){var e,t=td(n);return(e=t,Bn(ed,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,M.from(ed[e])).each(function(n){var e,t;t=n,td(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},od=rd.candidates(),id=function(n){return[Gf(''),(e=n,nd({onChange:e.onChange,sizes:od,category:"font",getInitialValue:e.getInitialValue})),Gf('')];var e},ud=function(n){var e=function t(n){return n.uid!==undefined}(n)&&jt(n,"uid")?n.uid:If("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(M.none,M.some)},asSpec:function(){return y({},n,{uid:e})}}};var cd=window.Promise?window.Promise:function(){var i=function(n){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof n)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],s(n,r(o,this),r(c,this))},n=i.immediateFn||"function"==typeof window.setImmediate&&window.setImmediate||function(n){v.setTimeout(n,1)};function r(n,e){return function(){return n.apply(e,arguments)}}var t=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};function u(r){var o=this;null!==this._state?n(function(){var n=o._state?r.onFulfilled:r.onRejected;if(null!==n){var e;try{e=n(o._value)}catch(t){return void r.reject(t)}r.resolve(e)}else(o._state?r.resolve:r.reject)(o._value)}):this._deferreds.push(r)}function o(n){try{if(n===this)throw new TypeError("A promise cannot be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){var e=n.then;if("function"==typeof e)return void s(r(e,n),r(o,this),r(c,this))}this._state=!0,this._value=n,a.call(this)}catch(t){c.call(this,t)}}function c(n){this._state=!1,this._value=n,a.call(this)}function a(){for(var n=0,e=this._deferreds;n'),action:function(n){var e=t.get(n);vs.setValue(e,"")}}));return{name:n,spec:Td.sketch({dom:Lf('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:xo([Gi.config({toggleClass:Xi.resolve("input-container-empty")}),Od.config({find:function(n){return M.some(t.get(n))}}),xd("input-clearing",[Qr(W(),function(n){var e=t.get(n);(0"},Qd=function(r,n,e){return{uid:r.uid,dom:r.dom,components:n,behaviours:Ia(r.formBehaviours,[vs.config({store:{mode:"manual",getValue:function(n){var e=hf(n,r);return A(e,function(n,e){return n().bind(function(n){var e,t=Od.getCurrent(n);return e="missing current",t.fold(function(){return pt.error(e)},pt.value)}).map(vs.getValue)})},setValue:function(t,n){B(n,function(e,n){pf(t,r,n).each(function(n){Od.getCurrent(n).each(function(n){vs.setValue(n,e)})})})}}})]),apis:{getField:function(n,e){return pf(n,r,e).bind(Od.getCurrent)}}}},Zd=(Of(function(n,e,t){return n.getField(e,t)}),function(n){var t,e=(t=[],{field:function(n,e){return t.push(n),sf("form",Jd(n),e)},record:function(){return t}}),r=n(e),o=e.record(),i=kn(o,function(n){return tf({name:n,pname:Jd(n)})});return Bf("form",Kd,i,Qd,r)}),nm=function(){var e=_o(M.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(M.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(M.some(n))},run:function(n){e.get().each(n)}}},em=function(){var e=_o(M.none());return{clear:function(){e.set(M.none())},set:function(n){e.set(M.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},tm=function(n){return{xValue:n,points:[]}},rm=function(n,e){if(e===n.xValue)return n;var t=0'),action:function(n){pe(n,r,{direction:e})},buttonBehaviours:xo([Yd.config({disableClass:Xi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=yu(n.element(),"."+Xi.resolve("serialised-dialog-screen"));Su(n.element(),"."+Xi.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[Td.sketch({dom:Lf('
'),components:kn(u.fields,function(n,e){return e<=u.maxFieldIndex?Td.sketch({dom:Lf('
'),components:[o(-1,"previous",0'),behaviours:xo([Xu.config({highlightClass:Xi.resolve("dot-active"),itemClass:Xi.resolve("dot-item")})]),components:Nn(u.fields,function(n,e){return e<=u.maxFieldIndex?[Gf('
')]:[]})});return{dom:Lf('
'),components:[a.asSpec(),f.asSpec()],behaviours:xo([Ca.config({mode:"special",focusIn:function(n){var e=a.get(n);Ca.focusIn(e)}}),xd("serializer-wrapper-events",[Qr(j(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(tm(t.raw().touches[0].clientX))}),Qr(H(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(rm(n,t.raw().touches[0].clientX))})}),Qr(P(),function(r){u.state.dialogSwipeState.on(function(n){var e=a.get(r),t=-1*om(n);i(e,t)})})])])}},um=J(function(t,r){return[{label:"the link group",items:[im({fields:[Vd("url","Type or paste URL"),Vd("text","Link text"),Vd("title","Link title"),Vd("target","Link target"),(n="link",{name:n,spec:kd.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return M.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return M.some(vd.getInfo(r))},onExecute:function(n){var e=vs.getValue(n);vd.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),cm=[{title:"Headings",items:[{title:"Heading 1",format:"h1"},{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Heading 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6"}]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Italic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"underline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{title:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",icon:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{title:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:"blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Alignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",format:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}],am=Yr([Jr(Zn(),function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(qe(t=o,n.element())&&!qe(t,r))||(v.console.warn(Zn()+" did not get interpreted by the desired target. \nOriginator: "+ri(o)+"\nTarget: "+ri(i)+"\nCheck the "+Zn()+" event handlers"),!1)})]),fm=/* */Object.freeze({events:am}),sm=w,lm=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+ri(e().element())+" is not in context.")}};return{debugInfo:h("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocus"),triggerEscape:n("triggerEscape"),build:n("build"),addToWorld:n("addToWorld"),removeFromWorld:n("removeFromWorld"),addToGui:n("addToGui"),removeFromGui:n("removeFromGui"),getByUid:n("getByUid"),getByDom:n("getByDom"),broadcast:n("broadcast"),broadcastOn:n("broadcastOn"),broadcastEvent:n("broadcastEvent"),isConnected:h(!1)}},dm=lm(),mm=function(n,o){var i={};return B(n,function(n,r){B(n,function(n,e){var t=Bt(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},gm=function(n,e){return t=d.apply(undefined,[n.handler].concat(e)),r=n.purpose(),{cHandler:t,purpose:h(r)};var t,r},pm=function(n){return n.cHandler},vm=function(n,e){return{name:h(n),handler:h(e)}},hm=function(n,e,t){var r,o,i=y({},t,(r=n,o={},En(e,function(n){o[n.name()]=n.handlers(r)}),o));return mm(i,vm)},bm=function(n){var e,i=yn(e=n)?{can:h(!0),abort:h(!1),run:e}:e;return function(n,e){for(var t=[],r=2;r "):r[0].name();return Ft(o,{handler:e,purpose:h(t)})})});return Nt(e,{})},wm=function(n){return Or("custom.definition",mr([hr("dom","dom",Ot(),mr([Ir("tag"),jr("styles",{}),jr("classes",[]),jr("attributes",{}),Ar("value"),Ar("innerHtml")])),Ir("components"),Ir("uid"),jr("events",{}),jr("apis",{}),hr("eventOrder","eventOrder",(e={"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"]},wt.mergeWithThunk(h(e))),Dr()),Ar("domModification")]),n);var e},Sm=function(e,n){En(n,function(n){jo(e,n)})},Om=function(e,n){En(n,function(n){Ho(e,n)})},Tm=function(n,e){return t=n,o=kn(r=e,function(n){return Vr(n.name(),[Ir("config"),jr("state",bo)])}),i=Or("component.behaviours",mr(o),t.behaviours).fold(function(n){throw new Error(Er(n)+"\nComplete spec:\n"+or(t,null,2))},function(n){return n}),{list:r,data:A(i,function(n){var e=n.map(function(n){return{config:n.config,state:n.state.init(n.config)}});return function(){return e}})};var t,r,o,i},km=function(n){var e,t,r,o=(e=n,t=Bt("behaviours",{})(e),r=Dn(I(t),function(n){return t[n]!==undefined}),kn(r,function(n){return t[n].me}));return Tm(n,o)},Em=function(n,e,t){var r,o,i,u=y({},(r=n).dom,{uid:r.uid,domChildren:kn(r.components,function(n){return n.element()})}),c=n.domModification.fold(function(){return mo({})},mo),a={"alloy.base.modification":c},f=0");r[t[0]]=Ft(t[1],n),r[t[1]]=Ft(t[0],n)}),r},createBistate:function(n,e,t){return Vt([{key:n,value:Ft(e,t)},{key:e,value:Ft(n,t)}])},createTristate:function(n,e,t,r){return Vt([{key:n,value:Vt([{key:e,value:r},{key:t,value:r}])},{key:e,value:Vt([{key:n,value:r},{key:t,value:r}])},{key:t,value:Vt([{key:n,value:r},{key:e,value:r}])}])}}}),pg=Xi.resolve("scrollable"),vg={register:function(n){jo(n,pg)},deregister:function(n){Ho(n,pg)},scrollable:h(pg)},hg=function(n){return At(n,"format").getOr(n.title)},bg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[Xi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Xi.resolve("format-matches"),selected:t},itemBehaviours:xo(o?[]:[$i(n,function(n,e){(e?Gi.on:Gi.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},yg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[Hf.sketch({dom:{tag:"div",classes:[Xi.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Xi.resolve("styles-collapse-icon")]}},Im(n)]:[Im(n)],action:function(n){if(r){var e=t().get(n);ig.collapseMenu(e)}}}),{dom:{tag:"div",classes:[Xi.resolve("styles-menu-items-container")]},components:[Ym.parts().items({})],behaviours:xo([xd("adhoc-scrollable-menu",[uo(function(n,e){tu(n.element(),"overflow-y","auto"),tu(n.element(),"-webkit-overflow-scrolling","touch"),vg.register(n.element())}),co(function(n){cu(n.element(),"overflow-y"),cu(n.element(),"-webkit-overflow-scrolling"),vg.deregister(n.element())})])])}],items:e,menuBehaviours:xo([gg.config({initialState:"after",routes:gg.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},xg=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return c},n=yg("Styles",[].concat(kn(o.items,function(n){return bg(hg(n),n.title,n.isSelected(),n.getPreview(),jt(o.expansions,hg(n)))})),i,!1),e=A(o.menus,function(n,e){var t=kn(n,function(n){return bg(hg(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",jt(o.expansions,hg(n)))});return yg(e,t,i,!0)}),t=yt(e,Ft("styles",n)),{tmenu:ig.tieredData("styles",t,o.expansions)}),c=ud(ig.sketch({dom:{tag:"div",classes:[Xi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=vs.getValue(e);return r.handle(e,t.value),M.none()},onEscape:function(){return M.none()},onOpenMenu:function(n,e){var t=Ms(n.element());Ds(e.element(),t),gg.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=Ms(n.element()),o=wu(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Ds(t.element(),r),gg.progressTo(i,"before"),gg.jumpTo(t,"after"),gg.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=wu(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();gg.progressTo(o,"after"),gg.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:u.tmenu,markers:{backgroundMenu:Xi.resolve("styles-background-menu"),menu:Xi.resolve("styles-menu"),selectedMenu:Xi.resolve("styles-selected-menu"),item:Xi.resolve("styles-item"),selectedItem:Xi.resolve("styles-selected-item")}}));return c.asSpec()},wg=function(n){return jt(n,"items")?(t=yt(It(e=n,["items"]),{menu:!0}),r=Sg(e.items),{item:t,menus:yt(r.menus,Ft(e.title,r.items)),expansions:yt(r.expansions,Ft(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,r},Sg=function(n){return Mn(n,function(n,e){var t=wg(e);return{menus:yt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:yt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Og={expand:Sg},Tg=function(u,n){var c=function(n){return function(){return u.formatter.match(n)}},a=function(n){return function(){return u.formatter.getCssText(n)}},e=At(n,"style_formats").getOr(cm),f=function(n){return kn(n,function(n){if(jt(n,"items")){var e=f(n.items);return yt(yt(n,{isSelected:h(!1),getPreview:h("")}),{items:e})}return jt(n,"format")?yt(i=n,{isSelected:c(i.format),getPreview:a(i.format)}):(r=Ga((t=n).title),o=yt(t,{format:r,isSelected:c(r),getPreview:a(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return f(e)},kg=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return Nn(n,function(n){return n.items===undefined?!jt(n,"format")||e.formatter.canApply(n.format)?[n]:[]:0e.innerHeight||n.bottom()>e.innerHeight?n.bottom()-e.innerHeight+50:0;0!==t&&e.scrollTo(e.pageXOffset,e.pageYOffset+t)})})].concat(!0===Wg?[]:[Ng(xe.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Gi.off)}),Ng(i,"select",n),Ng(r.doc(),"selectionchange",n)]);return{destroy:function(){En(c,function(n){n.unbind()})}}},qg=function(n,e){var t=parseInt(Mo(n,e),10);return isNaN(t)?0:t};var Yg,Kg=function wb(t,r){var o=function(n){return t(n)?M.from(n.dom().nodeValue):M.none()},n=Jn.detect().browser,e=n.isIE()&&10===n.version.major?function(n){try{return o(n)}catch(e){return M.none()}}:o;return{get:function(n){if(!t(n))throw new Error("Can only get "+r+" value of a "+r+" node");return e(n).getOr("")},getOption:e,set:function(n,e){if(!t(n))throw new Error("Can only set raw "+r+" value of a "+r+" node");n.dom().nodeValue=e}}}(De,"text"),Jg=function(n){return Kg.getOption(n)},Qg=["img","br"],Zg=function(n){return Jg(n).filter(function(n){return 0!==n.trim().length||-1=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom},dp=function(t,r,n,e,o){var i,u=function(n){var e=t.dom().createRange();return e.setStart(r.dom(),n),e.collapse(!0),e},c=(i=r,Kg.get(i)).length,a=function(n,e,t,r,o){if(0===o)return 0;if(e===r)return o-1;for(var i=r,u=1;ue.innerHeight||t.bottom()>e.innerHeight?Math.min(r,t.bottom()-e.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),jp(e,n.innerHeight)});jp(e,n.innerHeight);return{toEditing:function(){Vp(u)},destroy:function(){t.unbind()}}},Lp=function(n){return M.some(xe.fromDom(n.dom().contentWindow.document.body))},Gp=function(n){return M.some(xe.fromDom(n.dom().contentWindow.document))},$p=function(n){return M.from(n.dom().contentWindow)},_p=function(n){return $p(n).bind(Mp)},Up=function(n){return n.getFrame()},Wp=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=Up(e);return function(){return t(n)}})()}},Xp=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return Ng(e,r,n)}})},qp=function(n){return{left:h(n.left),top:h(n.top),right:h(n.right),bottom:h(n.bottom),width:h(n.width),height:h(n.height)}},Yp={getBody:Wp("getBody",Lp),getDoc:Wp("getDoc",Gp),getWin:Wp("getWin",$p),getSelection:Wp("getSelection",_p),getFrame:Up,getActiveApi:function(c){var a=Up(c);return Lp(a).bind(function(u){return Gp(a).bind(function(i){return $p(a).map(function(o){var n=xe.fromDom(i.dom().documentElement),e=c.getCursorBox.getOrThunk(function(){return function(){return(n=o,Mp(n).map(function(n){return op.exact(n.start(),n.soffset(),n.finish(),n.foffset())})).bind(function(n){return Ip(o,n).orThunk(function(){return Mp(o).filter(function(n){return qe(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0