/** * 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.5 (2019-05-09) */ !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 Jt.objOf(Tn(c,function(n){return n.fold(function(n,e,t,r){return Qt.field(n,t,r)},function(n,e){return Qt.state(n)})}))}}},sr=function(t,i){var u=function(n,e){return(o=cr(t),{extract:function(t,r,n){var e=Tn(n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return Kt(e)},toString:function(){return"array("+o.toString()+")"},toDsl:function(){return Jt.arrOf(o)}}).extract(n,w,e);var o};return{extract:function(t,r,o){var n=I(o),e=u(t,n);return Ut(e,function(n){var e=Tn(n,function(n){return rr.field(n,n,xt(),i)});return fr(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"},toDsl:function(){return Jt.setOf(t,i)}}},lr=b(cr(Lt)),dr=rr.state,mr=rr.field,gr=function(t,e,r,o,i){return Mt(o,i).fold(function(){return n=o,e=i,tr(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: '+er(n)});var n,e},function(n){return fr(n).extract(t.concat(["branch: "+i]),e,r)})},pr=function(o,i){return{extract:function(e,t,r){return Mt(r,o).fold(function(){return n=o,tr(e,function(){return'Choice schema did not contain choice key: "'+n+'"'});var n},function(n){return gr(e,t,r,i,n)})},toString:function(){return"chooseOn("+o+"). Possible values: "+I(i)},toDsl:function(){return Jt.choiceOf(o,i)}}},vr=cr(Lt),hr=function(e){return cr(function(n){return e(n).fold($t,Lt)})},br=function(e,n){return sr(function(n){return Pt(e(n))},n)},yr=function(n,e,t){return zt((r=n,o=w,i=t,u=e.extract([r],o,i),Xt(u,function(n){return{input:i,errors:n}})));var r,o,i,u},xr=function(n){return n.fold(function(n){throw new Error(Sr(n))},w)},wr=function(n,e,t){return xr(yr(n,e,t))},Sr=function(n){return"Errors: \n"+(e=n.errors,t=10 ")+")\n"+n.getErrorInfo()}))+"\n\nInput object: "+er(n.input);var e,t},Or=function(n,e){return pr(n,e)},Tr=b(vr),kr=(Ft=yn,Vt="function",cr(function(n){var e=typeof n;return Ft(n)?Lt(n):$t("Expected type: "+Vt+" but got: "+e)})),Er=function(n){return mr(n,n,xt(),lr())},Cr=function(n,e){return mr(n,n,xt(),e)},Dr=function(n,e){return mr(n,n,xt(),fr(e))},Mr=function(n){return mr(n,n,wt(),lr())},Ir=function(n,e){return mr(n,n,wt(),e)},Ar=function(n,e){return Ir(n,fr(e))},Br=function(n,e){return Ir(n,ar(e))},Rr=function(n,e){return mr(n,n,yt(e),lr())},Fr=function(n,e,t){return mr(n,n,yt(e),t)},Vr=function(n,e){return dr(n,e)},Nr=function(n,e){return _e(n.element(),e.event().target())},jr=function(n){if(!Rt(n,"can")&&!Rt(n,"abort")&&!Rt(n,"run"))throw new Error("EventHandler defined by: "+nr(n,null,2)+" does not have can, abort, or run!");return wr("Extracting event.handler",ar([Rr("can",b(!0)),Rr("abort",b(!1)),Rr("run",x)]),n)},Hr=function(t){var e,r,o,i,n=(e=t,r=function(n){return n.can},function(){for(var t=[],n=0;n"}),Tr()),Ua=Vr("schema",function(){return[Mr("preprocess")]}),_a=Rr("defaults",b({})),Wa=Rr("overrides",b({})),Xa=fr([za,La,Ga,$a,_a,Wa]),qa=fr([za,La,Ga,$a,_a,Wa]),Ya=fr([za,Ua,Ga,Er("unit"),$a,_a,Wa]),Ka=function(n){var e=function(n){return n.name};return n.fold(e,e,e,e)},Ja=function(t,r){return function(n){var e=wr("Converting part type",r,n);return t(e)}},Qa=Ja(Pa.required,Xa),Za=Ja(Pa.optional,qa),nf=Ja(Pa.group,Ya),ef=b("entirety"),tf=function(n,e,t,r){return vt(e.defaults(n,t,r),t,{uid:n.partUids[e.name]},e.overrides(n,t,r))},rf=function(o,n){var i={};return kn(n,function(n){var e;(e=n,e.fold(M.some,M.none,M.some,M.some)).each(function(t){var r=of(o,t.pname);i[t.name]=function(n){var e=wr("Part: "+t.name+" in "+o,fr(t.schema),n);return y({},r,{config:n,validated:e})}})}),i},of=function(n,e){return{uiType:Na(),owner:n,name:e}},uf=function(n,e,t){return{uiType:Na(),owner:n,name:e,config:t,validated:{}}},cf=function(n){return Vn(n,function(n){return n.fold(M.none,M.some,M.none,M.none).map(function(n){return Dr(n.name,n.schema.concat([Oi(ef())]))}).toArray()})},af=function(n){return Tn(n,Ka)},ff=function(n,e,t){return r=e,i={},o={},kn(t,function(n){n.fold(function(r){i[r.pname]=Fa(!0,function(n,e,t){return r.factory.sketch(tf(n,r,e,t))})},function(n){var e=r.parts[n.name];o[n.name]=b(n.factory.sketch(tf(r,n,e[ef()]),e))},function(r){i[r.pname]=Fa(!1,function(n,e,t){return r.factory.sketch(tf(n,r,e,t))})},function(o){i[o.pname]=Va(!0,function(e,n,t){var r=e[o.name];return Tn(r,function(n){return o.factory.sketch(vt(o.defaults(e,n,t),n,o.overrides(e,n)))})})})}),{internals:b(i),externals:b(o)};var r,i,o},sf=function(n,e,t){return Ra(M.some(n),e,e.components,t)},lf=function(n,e,t){var r=e.partUids[t];return n.getSystem().getByUid(r).toOption()},df=function(n,e,t){return lf(n,e,t).getOrDie("Could not find part: "+t)},mf=function(n,e){var t=n.getSystem();return R(e.partUids,function(n,e){return b(t.getByUid(n))})},gf=function(e,n){var t=af(n);return At(Tn(t,function(n){return{key:n,value:e+"-"+n}}))},pf=function(e){return mr("partUids","partUids",Ot(function(n){return gf(n.uid,e)}),Tr())},vf=Ha("alloy-premade"),hf=function(n){return It(vf,n)},bf=function(n){return Mt(n,vf)},yf=function(r){return n=function(n){for(var e=[],t=1;t')},function(n){return jf(''+n+"")})},Lf=function(n,e,t,r){return Ff.sketch({dom:zf(n,r),action:e,buttonBehaviours:vt(vo([Vf.config({})]),t)})},Gf={forToolbar:Lf,forToolbarCommand:function(n,e){return Lf(e,function(){n.execCommand(e)},{},n)},forToolbarStateAction:function(n,e,t,r){var o=Pf(t);return Lf(e,r,o,n)},forToolbarStateCommand:function(n,e){var t=Pf(e);return Lf(e,function(){n.execCommand(e)},t,n)},getToolbarIconButton:zf},$f=Jn.detect().deviceType.isTouch(),Uf=Za({schema:[Er("dom")],name:"label"}),_f=function(n){return Za({name:n+"-edge",overrides:function(r){return r.model.manager.edgeActions[n].fold(function(){return{}},function(t){var n=_r([Yr(j(),t,[r])]),e=_r([Yr(z(),t,[r]),Yr(L(),function(n,e){e.mouseIsDown.get()&&t(n,e)},[r])]);return{events:$f?n:e}})}})},Wf=_f("top-left"),Xf=_f("top"),qf=_f("top-right"),Yf=_f("right"),Kf=_f("bottom-right"),Jf=_f("bottom"),Qf=_f("bottom-left"),Zf=[Uf,_f("left"),Yf,Xf,Jf,Wf,qf,Qf,Kf,Qa({name:"thumb",defaults:b({dom:{styles:{position:"absolute"}}}),overrides:function(n){return{events:_r([Qr(j(),n,"spectrum"),Qr(H(),n,"spectrum"),Qr(P(),n,"spectrum"),Qr(z(),n,"spectrum"),Qr(L(),n,"spectrum"),Qr(G(),n,"spectrum")])}}}),Qa({schema:[Vr("mouseIsDown",function(){return zo(!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=_r([qr(j(),o),qr(H(),o)]),e=_r([qr(z(),o),qr(L(),function(n,e){t.mouseIsDown.get()&&o(n,e)})]);return{behaviours:vo($f?[]:[Oa.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:$f?n:e}}})],ns=function(n,e,t){e.store.manager.onLoad(n,e,t)},es=function(n,e,t){e.store.manager.onUnload(n,e,t)},ts=/* */Object.freeze({onLoad:ns,onUnload:es,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}}),rs=/* */Object.freeze({events:function(t,r){var n=t.resetOnDom?[to(function(n,e){ns(n,t,r)}),ro(function(n,e){es(n,t,r)})]:[fo(t,r,ns)];return _r(n)}}),os=function(){var n=zo(null);return po({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()}}})},is=function(){var i=zo({}),u=zo({});return po({readState:function(){return{mode:"dataset",dataByValue:i.get(),dataByText:u.get()}},lookup:function(n){return Mt(i.get(),n).orThunk(function(){return Mt(u.get(),n)})},update:function(n){var e=i.get(),t=u.get(),r={},o={};kn(n,function(e){r[e.value]=e,Mt(e,"meta").each(function(n){Mt(n,"text").each(function(n){o[n]=e})})}),i.set(y({},e,r)),u.set(y({},t,o))},clear:function(){i.set({}),u.set({})}})},us=/* */Object.freeze({memory:os,dataset:is,manual:function(){return po({readState:function(){}})},init:function(n){return n.store.manager.state(n)}}),cs=function(n,e,t,r){var o=e.store;t.update([r]),o.setValue(n,r),e.onSetValue(n,r)},as=[Mr("initialValue"),Er("getFallbackEntry"),Er("getDataKey"),Er("setValue"),Si("manager",{setValue:cs,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){cs(e,t,r,n)})},onUnload:function(n,e,t){t.clear()},state:is})],fs=[Er("getValue"),Rr("setValue",x),Mr("initialValue"),Si("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:go.init})],ss=[Mr("initialValue"),Si("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:os})],ls=[Fr("store",{mode:"memory"},Or("mode",{memory:ss,manual:fs,dataset:as})),bi("onSetValue"),Rr("resetOnDom",!1)],ds=bo({fields:ls,name:"representing",active:rs,apis:ts,extra:{setValueFrom:function(n,e){var t=ds.getValue(e);ds.setValue(n,t)}},state:us}),ms=function(t,r){return{left:b(t),top:b(r),translate:function(n,e){return ms(t+n,r+e)}}},gs=ms,ps=Jn.detect().deviceType.isTouch(),vs=b("slider.change.value"),hs=function(n){var e=n.event().raw();if(ps){var t=e;return t.touches!==undefined&&1===t.touches.length?M.some(t.touches[0]).map(function(n){return gs(n.clientX,n.clientY)}):M.none()}var r=e;return r.clientX!==undefined?M.some(r).map(function(n){return gs(n.clientX,n.clientY)}):M.none()},bs=function(n,e,t,r){return n'),components:[_l.parts()["left-edge"](Hf('
')),_l.parts().spectrum({dom:jf('
'),components:[Hf('
')],behaviours:vo([Hi.config({toggleClass:$i.resolve("thumb-active")})])}),_l.parts()["right-edge"](Hf('
')),_l.parts().thumb({dom:jf('
'),behaviours:vo([Hi.config({toggleClass:$i.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t.x());Qi(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){Hi.on(e)},onDragEnd:function(n,e){Hi.off(e)},onInit:function(n,e,t,r){var o=i(r.x());Qi(e.element(),"background-color",o)},stepSize:10,model:{mode:"x",minX:0,maxX:360,getInitialValue:function(){return{x:function(){return o.getInitialValue()}}}},sliderBehaviours:vo([zi(_l.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 Wl(n,"color-levels",function(){return Xl(e)},r)},Yl=ar([Er("getInitialValue"),Er("onChange"),Er("category"),Er("sizes")]),Kl=function(n){var i=wr("SizeSlider",Yl,n);return _l.sketch({dom:{tag:"div",classes:[$i.resolve("slider-"+i.category+"-size-container"),$i.resolve("slider"),$i.resolve("slider-size-container")]},onChange:function(n,e,t){var r,o=t.x();0<=(r=o)&&r'),components:[Hf('
')]}),_l.parts().thumb({dom:jf('
'),behaviours:vo([Hi.config({toggleClass:$i.resolve("thumb-active")})])})]})},Jl=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],Ql=function(n){var e,t,r=n.selection.getStart(),o=xe.fromDom(r),i=xe.fromDom(n.getBody()),u=(e=function(n){return _e(i,n)},(Ce(t=o)?M.some(t):Xe(t)).map(function(n){return Gr(n,function(n){return tu(n,"font-size").isSome()},e).bind(function(n){return tu(n,"font-size")}).getOrThunk(function(){return nu(n,"font-size")})}).getOr(""));return In(Jl,function(n){return u===n}).getOr("medium")},Zl={candidates:b(Jl),get:function(n){var e,t=Ql(n);return(e=t,An(Jl,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,M.from(Jl[e])).each(function(n){var e,t;t=n,Ql(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},nd=Zl.candidates(),ed=function(n){return[Hf(''),(e=n,Kl({onChange:e.onChange,sizes:nd,category:"font",getInitialValue:e.getInitialValue})),Hf('')];var e},td=function(n){var e=function t(n){return n.uid!==undefined}(n)&&Rt(n,"uid")?n.uid:Ef("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})}}},rd=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);ds.setValue(e,"")}}));return{name:n,spec:wd.sketch({dom:jf('
'),components:[t.asSpec(),r.asSpec()],containerBehaviours:vo([Hi.config({toggleClass:$i.resolve("input-container-empty")}),xd.config({find:function(n){return M.some(t.get(n))}}),hd("input-clearing",[qr(W(),function(n){var e=t.get(n);(0"},Yd=function(r,n,e){return{uid:r.uid,dom:r.dom,components:n,behaviours:Ea(r.formBehaviours,[ds.config({store:{mode:"manual",getValue:function(n){var e=mf(n,r);return R(e,function(n,e){return n().bind(function(n){var e,t=xd.getCurrent(n);return e="missing current",t.fold(function(){return dt.error(e)},dt.value)}).map(ds.getValue)})},setValue:function(t,n){B(n,function(e,n){lf(t,r,n).each(function(n){xd.getCurrent(n).each(function(n){ds.setValue(n,e)})})})}}})]),apis:{getField:function(n,e){return lf(n,r,e).bind(xd.getCurrent)}}}},Kd=(yf(function(n,e,t){return n.getField(e,t)}),function(n){var t,e=(t=[],{field:function(n,e){return t.push(n),uf("form",qd(n),e)},record:function(){return t}}),r=n(e),o=e.record(),i=Tn(o,function(n){return Qa({name:n,pname:qd(n)})});return Df("form",Xd,i,Yd,r)}),Jd=function(){var e=zo(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)}}},Qd=function(){var e=zo(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)}}},Zd=function(n){return{xValue:n,points:[]}},nm=function(n,e){if(e===n.xValue)return n;var t=0'),action:function(n){pe(n,r,{direction:e})},buttonBehaviours:vo([Wd.config({disableClass:$i.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=pu(n.element(),"."+$i.resolve("serialised-dialog-screen"));bu(n.element(),"."+$i.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[wd.sketch({dom:jf('
'),components:Tn(u.fields,function(n,e){return e<=u.maxFieldIndex?wd.sketch({dom:jf('
'),components:[o(-1,"previous",0'),behaviours:vo([$u.config({highlightClass:$i.resolve("dot-active"),itemClass:$i.resolve("dot-item")})]),components:Vn(u.fields,function(n,e){return e<=u.maxFieldIndex?[Hf('
')]:[]})});return{dom:jf('
'),components:[a.asSpec(),f.asSpec()],behaviours:vo([Oa.config({mode:"special",focusIn:function(n){var e=a.get(n);Oa.focusIn(e)}}),hd("serializer-wrapper-events",[qr(j(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(Zd(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(nm(n,t.raw().touches[0].clientX))})}),qr(P(),function(r){u.state.dialogSwipeState.on(function(n){var e=a.get(r),t=-1*em(n);i(e,t)})})])])}},rm=J(function(t,r){return[{label:"the link group",items:[tm({fields:[Bd("url","Type or paste URL"),Bd("text","Link text"),Bd("title","Link title"),Bd("target","Link target"),(n="link",{name:n,spec:Sd.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return M.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return M.some(md.getInfo(r))},onExecute:function(n){var e=ds.getValue(n);md.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),om=[{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"}]}],im=_r([Xr(Zn(),function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(_e(t=o,n.element())&&!_e(t,r)&&(v.console.warn(Zn()+" did not get interpreted by the desired target. \nOriginator: "+Zo(o)+"\nTarget: "+Zo(i)+"\nCheck the "+Zn()+" event handlers"),1))})]),um=/* */Object.freeze({events:im}),cm=w,am=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+Zo(e().element())+" is not in context.")}};return{debugInfo:b("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:b(!1)}},fm=am(),sm=function(n,o){var i={};return B(n,function(n,r){B(n,function(n,e){var t=Dt(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},lm=function(n,e){return t=l.apply(undefined,[n.handler].concat(e)),r=n.purpose(),{cHandler:t,purpose:b(r)};var t,r},dm=function(n){return n.cHandler},mm=function(n,e){return{name:b(n),handler:b(e)}},gm=function(n,e,t){var r,o,i=y({},t,(r=n,o={},kn(e,function(n){o[n.name()]=n.handlers(r)}),o));return sm(i,mm)},pm=function(n){var e,i=yn(e=n)?{can:b(!0),abort:b(!1),run:e}:e;return function(n,e){for(var t=[],r=2;r "):r[0].name();return It(o,{handler:e,purpose:b(t)})})});return Bt(e,{})},bm=function(n){return yr("custom.definition",fr([mr("dom","dom",xt(),fr([Er("tag"),Rr("styles",{}),Rr("classes",[]),Rr("attributes",{}),Mr("value"),Mr("innerHtml")])),Er("components"),Er("uid"),Rr("events",{}),Rr("apis",{}),mr("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"]},bt.mergeWithThunk(b(e))),Tr()),Mr("domModification")]),n);var e},ym=function(e,n){kn(n,function(n){Ro(e,n)})},xm=function(e,n){kn(n,function(n){Fo(e,n)})},wm=function(n,e){return t=n,o=Tn(r=e,function(n){return Ar(n.name(),[Er("config"),Rr("state",go)])}),i=yr("component.behaviours",fr(o),t.behaviours).fold(function(n){throw new Error(Sr(n)+"\nComplete spec:\n"+nr(t,null,2))},function(n){return n}),{list:r,data:R(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},Sm=function(n){var e,t,r,o=(e=n,t=Dt("behaviours",{})(e),r=Cn(I(t),function(n){return t[n]!==undefined}),Tn(r,function(n){return t[n].me}));return wm(n,o)},Om=function(n,e,t){var r,o,i,u=y({},(r=n).dom,{uid:r.uid,domChildren:Tn(r.components,function(n){return n.element()})}),c=n.domModification.fold(function(){return ao({})},ao),a={"alloy.base.modification":c},f=0");r[t[0]]=It(t[1],n),r[t[1]]=It(t[0],n)}),r},createBistate:function(n,e,t){return At([{key:n,value:It(e,t)},{key:e,value:It(n,t)}])},createTristate:function(n,e,t,r){return At([{key:n,value:At([{key:e,value:r},{key:t,value:r}])},{key:e,value:At([{key:n,value:r},{key:t,value:r}])},{key:t,value:At([{key:n,value:r},{key:e,value:r}])}])}}}),dg=$i.resolve("scrollable"),mg={register:function(n){Ro(n,dg)},deregister:function(n){Fo(n,dg)},scrollable:b(dg)},gg=function(n){return Mt(n,"format").getOr(n.title)},pg=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[$i.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:$i.resolve("format-matches"),selected:t},itemBehaviours:vo(o?[]:[Pi(n,function(n,e){(e?Hi.on:Hi.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},vg=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[Ff.sketch({dom:{tag:"div",classes:[$i.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[$i.resolve("styles-collapse-icon")]}},Cm(n)]:[Cm(n)],action:function(n){if(r){var e=t().get(n);tg.collapseMenu(e)}}}),{dom:{tag:"div",classes:[$i.resolve("styles-menu-items-container")]},components:[Wm.parts().items({})],behaviours:vo([hd("adhoc-scrollable-menu",[to(function(n,e){Qi(n.element(),"overflow-y","auto"),Qi(n.element(),"-webkit-overflow-scrolling","touch"),mg.register(n.element())}),ro(function(n){ru(n.element(),"overflow-y"),ru(n.element(),"-webkit-overflow-scrolling"),mg.deregister(n.element())})])])}],items:e,menuBehaviours:vo([lg.config({initialState:"after",routes:lg.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},hg=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return c},n=vg("Styles",[].concat(Tn(o.items,function(n){return pg(gg(n),n.title,n.isSelected(),n.getPreview(),Rt(o.expansions,gg(n)))})),i,!1),e=R(o.menus,function(n,e){var t=Tn(n,function(n){return pg(gg(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Rt(o.expansions,gg(n)))});return vg(e,t,i,!0)}),t=vt(e,It("styles",n)),{tmenu:tg.tieredData("styles",t,o.expansions)}),c=td(tg.sketch({dom:{tag:"div",classes:[$i.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=ds.getValue(e);return r.handle(e,t.value),M.none()},onEscape:function(){return M.none()},onOpenMenu:function(n,e){var t=ks(n.element());Ts(e.element(),t),lg.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=ks(n.element()),o=hu(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Ts(t.element(),r),lg.progressTo(i,"before"),lg.jumpTo(t,"after"),lg.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=hu(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();lg.progressTo(o,"after"),lg.progressTo(t,"current")},navigateOnHover:!1,highlightImmediately:!0,data:u.tmenu,markers:{backgroundMenu:$i.resolve("styles-background-menu"),menu:$i.resolve("styles-menu"),selectedMenu:$i.resolve("styles-selected-menu"),item:$i.resolve("styles-item"),selectedItem:$i.resolve("styles-selected-item")}}));return c.asSpec()},bg=function(n){return Rt(n,"items")?(i=vt((mt([{bothErrors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]},{bothValues:["value1","value2"]}]),e=o=n,t=["items"],r={},B(e,function(n,e){Sn(t,e)||(r[e]=n)}),r),{menu:!0}),u=yg(o.items),{item:i,menus:vt(u.menus,It(o.title,u.items)),expansions:vt(u.expansions,It(o.title,o.title))}):{item:n,menus:{},expansions:{}};var e,t,r,o,i,u},yg=function(n){return Dn(n,function(n,e){var t=bg(e);return{menus:vt(n.menus,t.menus),items:[t.item].concat(n.items),expansions:vt(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},xg={expand:yg},wg=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=Mt(n,"style_formats").getOr(om),f=function(n){return Tn(n,function(n){if(Rt(n,"items")){var e=f(n.items);return vt(vt(n,{isSelected:b(!1),getPreview:b("")}),{items:e})}return Rt(n,"format")?vt(i=n,{isSelected:c(i.format),getPreview:a(i.format)}):(r=Ha((t=n).title),o=vt(t,{format:r,isSelected:c(r),getPreview:a(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return f(e)},Sg=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return Vn(n,function(n){return n.items===undefined?!Rt(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===$g?[]:[Rg(xe.fromDom(r.win()),"blur",function(){t.getByDom(e).each(Hi.off)}),Rg(i,"select",n),Rg(r.doc(),"selectionchange",n)]);return{destroy:function(){kn(c,function(n){n.unbind()})}}},_g=function(n,e){var t=parseInt(ko(n,e),10);return isNaN(t)?0:t},Wg=function tb(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"),Xg=function(n){return Wg.getOption(n)},qg=mt([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Yg={before:qg.before,on:qg.on,after:qg.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(w,w,w)}},Kg=mt([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Jg=Be("start","soffset","finish","foffset"),Qg=Kg.relative,Zg=Kg.exact,np=function(n,e,t,r){var o,i,u,c,a,f=(i=e,u=t,c=r,(a=We(o=n).dom().createRange()).setStart(o.dom(),i),a.setEnd(u.dom(),c),a),s=_e(n,t)&&e===r;return f.collapsed&&!s},ep=function(n,e,t){var r,o,i=n.document.createRange();return r=i,e.fold(function(n){r.setStartBefore(n.dom())},function(n,e){r.setStart(n.dom(),e)},function(n){r.setStartAfter(n.dom())}),o=i,t.fold(function(n){o.setEndBefore(n.dom())},function(n,e){o.setEnd(n.dom(),e)},function(n){o.setEndAfter(n.dom())}),i},tp=function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},rp=function(n){return{left:b(n.left),top:b(n.top),right:b(n.right),bottom:b(n.bottom),width:b(n.width),height:b(n.height)}},op=mt([{ltr:["start","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]}]),ip=function(n,e,t){return e(xe.fromDom(t.startContainer),t.startOffset,xe.fromDom(t.endContainer),t.endOffset)},up=function(n,e){var o,t,r,i=(o=n,e.match({domRange:function(n){return{ltr:b(n),rtl:M.none}},relative:function(n,e){return{ltr:J(function(){return ep(o,n,e)}),rtl:J(function(){return M.some(ep(o,e,n))})}},exact:function(n,e,t,r){return{ltr:J(function(){return tp(o,n,e,t,r)}),rtl:J(function(){return M.some(tp(o,t,r,n,e))})}}}));return(r=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).map(function(n){return op.rtl(xe.fromDom(n.endContainer),n.endOffset,xe.fromDom(n.startContainer),n.startOffset)}).getOrThunk(function(){return ip(0,op.ltr,r)}):ip(0,op.ltr,r)},cp=(document.caretPositionFromPoint||document.caretRangeFromPoint,function(n,e){var t=Te(n);return"input"===t?Yg.after(n):Sn(["br","img"],t)?0===e?Yg.before(n):Yg.after(n):Yg.on(n,e)}),ap=function(n,e,t,r,o){var i,u,c=tp(n,e,t,r,o);i=n,u=c,M.from(i.getSelection()).each(function(n){n.removeAllRanges(),n.addRange(u)})},fp=function(n,e,t,r,o){var i,u,c,a,l,f=(i=r,u=o,c=cp(e,t),a=cp(i,u),Qg(c,a));up(l=n,f).match({ltr:function(n,e,t,r){ap(l,n,e,t,r)},rtl:function(n,e,t,r){var o,i,u,c,a,f=l.getSelection();if(f.setBaseAndExtent)f.setBaseAndExtent(n.dom(),e,t.dom(),r);else if(f.extend)try{i=n,u=e,c=t,a=r,(o=f).collapse(i.dom(),u),o.extend(c.dom(),a)}catch(s){ap(l,t,r,n,e)}else ap(l,t,r,n,e)}})},sp=function(n){var e=xe.fromDom(n.anchorNode),t=xe.fromDom(n.focusNode);return np(e,n.anchorOffset,t,n.focusOffset)?M.some(Jg(e,n.anchorOffset,t,n.focusOffset)):function(n){if(0e.innerHeight||t.bottom()>e.innerHeight?Math.min(r,t.bottom()-e.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),yp(e,n.innerHeight)});return yp(e,n.innerHeight),{toEditing:function(){hp(u)},destroy:function(){t.unbind()}}},Op=function(n){return M.some(xe.fromDom(n.dom().contentWindow.document.body))},Tp=function(n){return M.some(xe.fromDom(n.dom().contentWindow.document))},kp=function(n){return M.from(n.dom().contentWindow)},Ep=function(n){return kp(n).bind(lp)},Cp=function(n){return n.getFrame()},Dp=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=Cp(e);return function(){return t(n)}})()}},Mp=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return Rg(e,r,n)}})},Ip=function(n){return{left:b(n.left),top:b(n.top),right:b(n.right),bottom:b(n.bottom),width:b(n.width),height:b(n.height)}},Ap={getBody:Dp("getBody",Op),getDoc:Dp("getDoc",Tp),getWin:Dp("getWin",kp),getSelection:Dp("getSelection",Ep),getFrame:Cp,getActiveApi:function(c){var a=Cp(c);return Op(a).bind(function(u){return Tp(a).bind(function(i){return kp(a).map(function(o){var n=xe.fromDom(i.dom().documentElement),e=c.getCursorBox.getOrThunk(function(){return function(){return(n=o,lp(n).map(function(n){return Zg(n.start(),n.soffset(),n.finish(),n.foffset())})).bind(function(n){return dp(o,n).orThunk(function(){return lp(o).filter(function(n){return _e(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0