'),components:[Js.parts()["left-edge"](gs('')),Js.parts().spectrum({dom:ms(''),components:[gs('')],behaviours:qr([ki.config({toggleClass:Mi.resolve("thumb-active")})])}),Js.parts()["right-edge"](gs('')),Js.parts().thumb({dom:ms(''),behaviours:qr([ki.config({toggleClass:Mi.resolve("thumb-active")})])})],onChange:function(n,e,t){var r=i(t);_i.set(e.element(),"background-color",r),o.onChange(n,e,r)},onDragStart:function(n,e){ki.on(e)},onDragEnd:function(n,e){ki.off(e)},onInit:function(n,e,t){var r=i(t);_i.set(e.element(),"background-color",r)},stepSize:10,min:0,max:360,getInitialValue:o.getInitialValue,sliderBehaviours:qr([Di(Js.refresh)])}))];var o,i},nf=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 Qs(n,"color",function(){return Zs(e)})},ef=Pt([ur("getInitialValue"),ur("onChange"),ur("category"),ur("sizes")]),tf=function(n){var o=nr("SizeSlider",ef,n);return Js.sketch({dom:{tag:"div",classes:[Mi.resolve("slider-"+o.category+"-size-container"),Mi.resolve("slider"),Mi.resolve("slider-size-container")]},onChange:function(n,e,t){var r;0<=(r=t)&&r'),components:[gs('')]}),Js.parts().thumb({dom:ms(''),behaviours:qr([ki.config({toggleClass:Mi.resolve("thumb-active")})])})]})},rf=["9px","10px","11px","12px","14px","16px","18px","20px","24px","32px","36px"],of=function(n){var e,t,r=n.selection.getStart(),o=fe.fromDom(r),i=fe.fromDom(n.getBody()),u=(e=function(n){return ze(i,n)},t=o,(be.isElement(t)?B.some(t):$e.parent(t)).map(function(n){return Do.closest(n,function(n){return _i.getRaw(n,"font-size").isSome()},e).bind(function(n){return _i.getRaw(n,"font-size")}).getOrThunk(function(){return _i.get(n,"font-size")})}).getOr(""));return On(rf,function(n){return u===n}).getOr("medium")},uf={candidates:E(rf),get:function(n){var e,t=of(n);return(e=t,Cn(rf,function(n){return n===e})).getOr(2)},apply:function(r,n){var e;(e=n,B.from(rf[e])).each(function(n){var e,t;t=n,of(e=r)!==t&&e.execCommand("fontSize",!1,t)})}},af=uf.candidates(),cf=function(n){return[gs(''),(e=n,tf({onChange:e.onChange,sizes:af,category:"font",getInitialValue:e.getInitialValue})),gs('')];var e},sf=function(n){var e=n.uid!==undefined&&Rt(n,"uid")?n.uid:es("memento");return{get:function(n){return n.getSystem().getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(B.none,B.some)},asSpec:function(){return C(n,{uid:e})}}};function ff(n,e){return df(document.createElement("canvas"),n,e)}function lf(n){return n.getContext("2d")}function df(n,e,t){return n.width=e,n.height=t,n}var mf={create:ff,clone:function(n){var e;return lf(e=ff(n.width,n.height)).drawImage(n,0,0),e},resize:df,get2dContext:lf,get3dContext:function(n){var e=null;try{e=n.getContext("webgl")||n.getContext("experimental-webgl")}catch(t){}return e||(e=null),e}},gf={getWidth:function(n){return n.naturalWidth||n.width},getHeight:function(n){return n.naturalHeight||n.height}},vf=window.Promise?window.Promise:function(){var n=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(u,this))},e=n.immediateFn||"function"==typeof setImmediate&&setImmediate||function(n){setTimeout(n,1)};function r(n,e){return function(){n.apply(e,arguments)}}var t=Array.isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n)};function i(r){var o=this;null!==this._state?e(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(u,this))}this._state=!0,this._value=n,a.call(this)}catch(t){u.call(this,t)}}function u(n){this._state=!1,this._value=n,a.call(this)}function a(){for(var n=0,e=this._deferreds.length;n'),components:[e.asSpec()],action:function(n){e.get(n).element().dom().click()}})},Bf=function(n){return n.dom().textContent},Ff=function(n,e){n.dom().textContent=e},Vf=function(n){return 0'),action:function(n){var e=t.get(n);Ws.setValue(e,"")}}));return{name:n,spec:Yf.sketch({dom:ms(''),components:[t.asSpec(),r.asSpec()],containerBehaviours:qr([ki.config({toggleClass:Mi.resolve("input-container-empty")}),qf.config({find:function(n){return B.some(t.get(n))}}),Wf("input-clearing",[wr(Y(),function(n){var e=t.get(n);(0"},wl=function(o,n,e){return C({"debug.sketcher":{Form:e},uid:o.uid(),dom:o.dom(),components:n,behaviours:C(qr([Ws.config({store:{mode:"manual",getValue:function(n){var e,t,r=(e=o,t=n.getSystem(),H(e.partUids(),function(n,e){return E(t.getByUid(n))}));return H(r,function(n,e){return n().bind(qf.getCurrent).map(Ws.getValue)})},setValue:function(t,n){V(n,function(e,n){Uc(t,o,n).each(function(n){qf.getCurrent(n).each(function(n){Ws.setValue(n,e)})})})}}})]),cc(o.formBehaviours())),apis:{getField:function(n,e){return Uc(n,o,e).bind(qf.getCurrent)}}})},xl=(Yc(function(n,e,t){return n.getField(e,t)}),function(n){var i,e=(i=[],{field:function(n,e){return i.push(n),t="form",r=yl(n),o=e,{uiType:pc(),owner:t,name:r,config:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o=yn(r,function(n){return Ic({name:n,pname:yl(n)})});return rs("form",bl,o,wl,t)}),Tl=function(){var e=So(B.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:function(){t(),e.set(B.none())},isSet:function(){return e.get().isSome()},set:function(n){t(),e.set(B.some(n))},run:function(n){e.get().each(n)}}},Sl=function(){var e=So(B.none());return{clear:function(){e.set(B.none())},set:function(n){e.set(B.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().each(n)}}},Ol=function(n){return{xValue:n,points:[]}},Cl=function(n,e){if(e===n.xValue)return n;var t=0'),action:function(n){ie(n,r,{direction:e})},buttonBehaviours:qr([hl.config({disableClass:Mi.resolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,o){var i=nu(n.element(),"."+Mi.resolve("serialised-dialog-screen"));ou(n.element(),"."+Mi.resolve("serialised-dialog-chain")).each(function(r){0<=u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o'),components:[Yf.sketch({dom:ms(''),components:yn(u.fields,function(n,e){return e<=u.maxFieldIndex?Yf.sketch({dom:ms(''),components:Dn([[o(-1,"previous",0'),behaviours:qr([Eu.config({highlightClass:Mi.resolve("dot-active"),itemClass:Mi.resolve("dot-item")})]),components:An(u.fields,function(n,e){return e<=u.maxFieldIndex?[gs('')]:[]})});return{dom:ms(''),components:[c.asSpec(),s.asSpec()],behaviours:qr([uc.config({mode:"special",focusIn:function(n){var e=c.get(n);uc.focusIn(e)}}),Wf("serializer-wrapper-events",[wr(L(),function(n,e){var t=e.event();u.state.dialogSwipeState.set(Ol(t.touches[0].clientX))}),wr(U(),function(n,e){var t=e.event();u.state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(Cl(n,t.raw().touches[0].clientX))})}),wr(P(),function(r){u.state.dialogSwipeState.on(function(n){var e=c.get(r),t=-1*kl(n);i(e,t)})})])])}},Dl=Z(function(t,r){return[{label:"the link group",items:[El({fields:[ol("url","Type or paste URL"),ol("text","Link text"),ol("title","Link title"),ol("target","Link target"),(n="link",{name:n,spec:Xf.sketch({dom:{tag:"span",styles:{display:"none"}},getInitialValue:function(){return B.none()}})})],maxFieldIndex:["url","text","title","target"].length-1,getInitialValue:function(){return B.some(Lf.getInfo(r))},onExecute:function(n){var e=Ws.getValue(n);Lf.applyInfo(r,e),t.restoreToolbar(),r.focus()}})]}];var n}),Al=[{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"}]}],Rl=br([(Sf=Gn(),Of=function(n,e){var t,r,o=e.event().originator(),i=e.event().target();return r=i,!(ze(t=o,n.element())&&!ze(t,r)&&(console.warn(Gn()+" did not get interpreted by the desired target. \nOriginator: "+qo(o)+"\nTarget: "+qo(i)+"\nCheck the "+Gn()+" event handlers"),1))},{key:Sf,value:pr({can:Of})})]),Ml=Object.freeze({events:Rl}),Il=h,Nl=Wr(["debugInfo","triggerFocus","triggerEvent","triggerEscape","addToWorld","removeFromWorld","addToGui","removeFromGui","build","getByUid","getByDom","broadcast","broadcastOn","isConnected"]),Bl=function(e){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+qo(e().element())+" is not in context.")}};return Nl({debugInfo:E("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"),isConnected:E(!1)})},Fl=function(n,o){var i={};return V(n,function(n,r){V(n,function(n,e){var t=Ct(e,[])(i);i[e]=t.concat([o(r,n)])})}),i},Vl=function(n,e){return 1 "):r[0].name();return Et(o,{handler:e,purpose:E(t)})})});return At(e,{})},Gl=function(n){return Qt("custom.definition",Pt([qt("dom","dom",lt(),Pt([ur("tag"),mr("styles",{}),mr("classes",[]),mr("attributes",{}),fr("value"),fr("innerHtml")])),ur("components"),ur("uid"),mr("events",{}),mr("apis",E({})),qt("eventOrder","eventOrder",(e={"alloy.execute":["disabling","alloy.base.behaviour","toggling"],"alloy.focus":["alloy.base.behaviour","focusing","keying"],"alloy.system.init":["alloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.behaviour","representing","streaming","invalidating"],"alloy.system.detached":["alloy.base.behaviour","representing"]},st.mergeWithThunk(E(e))),or()),fr("domModification"),di("originalSpec"),mr("debug.sketcher","unknown")]),n);var e},ql=function(n){var e,t={tag:n.dom().tag(),classes:n.dom().classes(),attributes:C((e=n,Et(Jc(),e.uid())),n.dom().attributes()),styles:n.dom().styles(),domChildren:yn(n.components(),function(n){return n.element()})};return Mr(C(t,n.dom().innerHtml().map(function(n){return Et("innerHtml",n)}).getOr({}),n.dom().value().map(function(n){return Et("value",n)}).getOr({})))},Yl=function(e,n){wn(n,function(n){bo.add(e,n)})},Xl=function(e,n){wn(n,function(n){bo.remove(e,n)})},Kl=function(e){if(e.domChildren().isSome()&&e.defChildren().isSome())throw new Error("Cannot specify children and child specs! Must be one or the other.\nDef: "+(n=Ir(e),Bt(n,null,2)));return e.domChildren().fold(function(){var n=e.defChildren().getOr([]);return yn(n,Ql)},function(n){return n});var n},Jl=function(n){var e=fe.fromTag(n.tag());ro.setAll(e,n.attributes().getOr({})),Yl(e,n.classes().getOr([])),_i.setAll(e,n.styles().getOr({})),_o(e,n.innerHtml().getOr(""));var t=Kl(n);return Ke(e,t),n.value().each(function(n){Kf(e,n)}),e},Ql=function(n){var e=Mr(n);return Jl(e)},Zl=function(n,e){return t=n,o=yn(r=e,function(n){return lr(n.name(),[ur("config"),mr("state",$r)])}),i=Qt("component.behaviours",_t(o),t.behaviours).fold(function(n){throw new Error(tr(n)+"\nComplete spec:\n"+Bt(t,null,2))},function(n){return n}),{list:r,data:H(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},nd=function(n){var e,t,r=(e=kt(n,"behaviours").getOr({}),t=xn(F(e),function(n){return e[n]!==undefined}),yn(t,function(n){return e[n].me}));return Zl(n,r)},ed=Wr(["getSystem","config","hasConfigured","spec","connect","disconnect","element","syncComponents","readState","components","events"]),td=function(n,e,t){var r,o,i,u,a=ql(n),c=function(e,n,t,r){var o=C({},n);wn(t,function(n){o[n.name()]=n.exhibit(e,r)});var i=Fl(o,function(n,e){return{name:function(){return n},modification:e}}),u=H(i,function(n,e){return An(n,function(e){return e.modification().fold(function(){return[]},function(n){return[e]})})}),a=j(u,function(e,t){return kt(zl,t).fold(function(){return at.error("Unknown field type: "+t)},function(n){return n(e,t)})});return At(a,{}).map(Nr)}(t,{"alloy.base.modification":(r=n,r.domModification().fold(function(){return Nr({})},Nr))},e,a).getOrDie();return i=c,u=C({tag:(o=a).tag(),classes:i.classes().getOr([]).concat(o.classes().getOr([])),attributes:D(o.attributes().getOr({}),i.attributes().getOr({})),styles:D(o.styles().getOr({}),i.styles().getOr({}))},i.innerHtml().or(o.innerHtml()).map(function(n){return Et("innerHtml",n)}).getOr({}),Br("domChildren",i.domChildren(),o.domChildren()),Br("defChildren",i.defChildren(),o.defChildren()),i.value().or(o.value()).map(function(n){return Et("value",n)}).getOr({})),Mr(u)},rd=function(n,e,t){var r,o,i,u,a,c,s={"alloy.base.behaviour":(r=n,r.events())};return(o=t,i=n.eventOrder(),u=e,a=s,c=Pl(o,u,a),$l(c,i)).getOrDie()},od=function(n){var e,t,r,o,i,u,a,c,s,f,l,d,m,g,v=Il(n),p=(e=v,t=Ct("components",[])(e),yn(t,ad)),h=C(Ml,v,Et("components",p));return at.value((r=h,i=So(Bl(o=function(){return g})),u=Zt(Gl(C(r,{behaviours:undefined}))),a=nd(r),c=a.list,s=a.data,f=td(u,c,s),l=Jl(f),d=rd(u,c,s),m=So(u.components()),g=ed({getSystem:i.get,config:function(n){if(n===Xc())return u.apis();if(b(n))throw new Error("Invalid input: only API constant is allowed");var e=s;return(w(e[n.name()])?e[n.name()]:function(){throw new Error("Could not find "+n.name()+" in "+Bt(r,null,2))})()},hasConfigured:function(n){return w(s[n.name()])},spec:E(r),readState:function(n){return s[n]().map(function(n){return n.state.readState()}).getOr("not enabled")},connect:function(n){i.set(n)},disconnect:function(){i.set(Bl(o))},element:E(l),syncComponents:function(){var n=$e.children(l),e=An(n,function(n){return i.get().getByDom(n).fold(function(){return[]},function(n){return[n]})});m.set(e)},components:m.get,events:E(d)})))},id=function(n){var e=fe.fromText(n);return ud({element:e})},ud=function(n){var t=er("external.component",Pt([ur("element"),fr("uid")]),n),e=So(Bl());t.uid().each(function(n){var e;e=t.element(),ro.set(e,Zc,n)});var r=ed({getSystem:e.get,config:B.none,hasConfigured:E(!1),connect:function(n){e.set(n)},disconnect:function(){e.set(Bl(function(){return r}))},element:E(t.element()),spec:E(n),readState:E("No state"),syncComponents:k,components:E([]),events:E({})});return qc(r)},ad=function(e){return(n=e,kt(n,$c)).fold(function(){var n=C({uid:es("")},e);return od(n).getOrDie()},function(n){return n});var n},cd=qc,sd="alloy.item-hover",fd="alloy.item-focus",ld=function(n){(Fo(n.element()).isNone()||Vi.isFocused(n))&&(Vi.isFocused(n)||Vi.focus(n),ie(n,sd,{item:n}))},dd=function(n){ie(n,fd,{item:n})},md=E(sd),gd=E(fd),vd=[ur("data"),ur("components"),ur("dom"),fr("toggling"),mr("itemBehaviours",{}),mr("ignoreFocus",!1),mr("domModification",{}),li("builder",function(n){return{dom:C(n.dom(),{attributes:{role:n.toggling().isSome()?"menuitemcheckbox":"menuitem"}}),behaviours:C(qr([n.toggling().fold(ki.revoke,function(n){return ki.config(C({aria:{mode:"checked"}},n))}),Vi.config({ignore:n.ignoreFocus(),onFocus:function(n){dd(n)}}),uc.config({mode:"execution"}),Ws.config({store:{mode:"memory",initialValue:n.data()}})]),n.itemBehaviours()),events:br([(e=Qn(),r=ue,wr(e,function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){r(e,n,t)})})),Or(_()),wr(G(),ld),wr(Kn(),Vi.focus)]),components:n.components(),domModification:n.domModification(),eventOrder:n.eventOrder()};var e,r}),mr("eventOrder",{})],pd=[ur("dom"),ur("components"),li("builder",function(n){return{dom:n.dom(),components:n.components(),events:br([(e=Kn(),wr(e,function(n,e){e.stop()}))])};var e})],hd=E([Ic({name:"widget",overrides:function(e){return{behaviours:qr([Ws.config({store:{mode:"manual",getValue:function(n){return e.data()},setValue:function(){}}})])}}})]),bd=[ur("uid"),ur("data"),ur("components"),ur("dom"),mr("autofocus",!1),mr("domModification",{}),Wc(hd()),li("builder",function(t){var n=jc(0,t,hd()),e=Lc("item-widget",t,n.internals()),r=function(n){return Uc(n,t,"widget").map(function(n){return uc.focusIn(n),n})},o=function(n,e){return Nu(e.event().target())||t.autofocus()&&e.setSource(n.element()),B.none()};return C({dom:t.dom(),components:e,domModification:t.domModification(),events:br([Dr(function(n,e){r(n).each(function(n){e.stop()})}),wr(G(),ld),wr(Kn(),function(n,e){t.autofocus()?r(n):Vi.focus(n)})]),behaviours:qr([Ws.config({store:{mode:"memory",initialValue:t.data()}}),Vi.config({onFocus:function(n){dd(n)}}),uc.config({mode:"special",focusIn:t.autofocus()?function(n){r(n)}:Jr(),onLeft:o,onRight:o,onEscape:function(n,e){return Vi.isFocused(n)||t.autofocus()?(t.autofocus()&&e.setSource(n.element()),B.none()):(Vi.focus(n),B.some(!0))}})])})})],yd=rr("type",{widget:bd,item:vd,separator:pd}),wd=E([Bc({factory:{sketch:function(n){var e=er("menu.spec item",yd,n);return e.builder()(e)}},name:"items",unit:"item",defaults:function(n,e){var t=es("");return C({uid:t},e)},overrides:function(n,e){return{type:e.type,ignoreFocus:n.fakeFocus(),domModification:{classes:[n.markers().item()]}}}})]),xd=E([ur("value"),ur("items"),ur("dom"),ur("components"),mr("eventOrder",{}),ac("menuBehaviours",[Eu,Ws,qf,uc]),gr("movement",{mode:"menu",moveOnTab:!0},rr("mode",{grid:[mi(),li("config",function(n,e){return{mode:"flatgrid",selector:"."+n.markers().item(),initSize:{numColumns:e.initSize().numColumns(),numRows:e.initSize().numRows()},focusManager:n.focusManager()}})],menu:[mr("moveOnTab",!0),li("config",function(n,e){return{mode:"menu",selector:"."+n.markers().item(),moveOnTab:e.moveOnTab(),focusManager:n.focusManager()}})]})),ar("markers",oi()),mr("fakeFocus",!1),mr("focusManager",Du()),ai("onHighlight")]),Td=E("alloy.menu-focus"),Sd=cs({name:"Menu",configFields:xd(),partFields:wd(),factory:function(n,e,t,r){return C({dom:C(n.dom(),{attributes:{role:"menu"}}),uid:n.uid(),behaviours:C(qr([Eu.config({highlightClass:n.markers().selectedItem(),itemClass:n.markers().item(),onHighlight:n.onHighlight()}),Ws.config({store:{mode:"memory",initialValue:n.value()}}),qf.config({find:B.some}),uc.config(n.movement().config()(n,n.movement()))]),cc(n.menuBehaviours())),events:br([wr(gd(),function(e,t){var n=t.event();e.getSystem().getByDom(n.target()).each(function(n){Eu.highlight(e,n),t.stop(),ie(e,Td(),{menu:e,item:n})})}),wr(md(),function(n,e){var t=e.event().item();Eu.highlight(n,t)})]),components:e,eventOrder:n.eventOrder()})}}),Od=function(n,e,t,r){var o=n.getSystem().build(r);tt(n,o,t)},Cd=function(n,e){return n.components()},kd=Object.freeze({append:function(n,e,t,r){Od(n,0,Ye.append,r)},prepend:function(n,e,t,r){Od(n,0,Ye.prepend,r)},remove:function(n,e,t,r){var o=Cd(n,e);On(o,function(n){return ze(r.element(),n.element())}).each(ot)},set:function(e,n,t,r){var o,i,u,a,c,s;i=(o=e).components(),wn(i,rt),Qe.empty(o.element()),o.syncComponents(),u=function(){var n=yn(r,e.getSystem().build);wn(n,function(n){et(e,n)})},a=e.element(),c=$e.owner(a),s=Bo(c).bind(function(e){var n=function(n){return ze(e,n)};return n(a)?B.some(a):Do.descendant(a,n)}),u(a),s.each(function(e){Bo(c).filter(function(n){return ze(n,e)}).fold(function(){Io(e)},k)})},contents:Cd}),Ed=Xr({fields:[],name:"replacing",apis:kd}),Dd=function(t,r,o,n){return kt(o,n).bind(function(n){return kt(t,n).bind(function(n){var e=Dd(t,r,o,n);return B.some([n].concat(e))})}).getOr([])},Ad=function(n,e){var t={};V(n,function(n,e){wn(n,function(n){t[n]=e})});var r=e,o=z(e,function(n,e){return{k:n,v:e}}),i=H(o,function(n,e){return[e].concat(Dd(t,r,o,e))});return H(t,function(n){return kt(i,n).getOr([n])})},Rd=function(){var i=So({}),u=So({}),a=So({}),c=So(B.none()),s=So({}),n=function(n){return kt(u.get(),n)};return{setContents:function(n,e,t,r){c.set(B.some(n)),i.set(t),u.set(e),s.set(r);var o=Ad(r,t);a.set(o)},expand:function(t){return kt(i.get(),t).map(function(n){var e=kt(a.get(),t).getOr([]);return[n].concat(e)})},refresh:function(n){return kt(a.get(),n)},collapse:function(n){return kt(a.get(),n).bind(function(n){return 1");r[t[0]]=Et(t[1],n),r[t[1]]=Et(t[0],n)}),r},createBistate:function(n,e,t){return Dt([{key:n,value:Et(e,t)},{key:e,value:Et(n,t)}])},createTristate:function(n,e,t,r){return Dt([{key:n,value:Dt([{key:e,value:r},{key:t,value:r}])},{key:e,value:Dt([{key:n,value:r},{key:t,value:r}])},{key:t,value:Dt([{key:n,value:r},{key:e,value:r}])}])}}}),Pd=Mi.resolve("scrollable"),_d={register:function(n){bo.add(n,Pd)},deregister:function(n){bo.remove(n,Pd)},scrollable:E(Pd)},Wd=function(n){return kt(n,"format").getOr(n.title)},$d=function(n,e,t,r,o){return{data:{value:n,text:e},type:"item",dom:{tag:"div",classes:o?[Mi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,toggleClass:Mi.resolve("format-matches"),selected:t},itemBehaviours:qr(o?[]:[Ei(n,function(n,e){(e?ki.on:ki.off)(n)})]),components:[{dom:{tag:"div",attributes:{style:r},innerHtml:e}}]}},Gd=function(n,e,t,r){return{value:n,dom:{tag:"div"},components:[ss.sketch({dom:{tag:"div",classes:[Mi.resolve("styles-collapser")]},components:r?[{dom:{tag:"span",classes:[Mi.resolve("styles-collapse-icon")]}},id(n)]:[id(n)],action:function(n){if(r){var e=t().get(n);Id.collapseMenu(e)}}}),{dom:{tag:"div",classes:[Mi.resolve("styles-menu-items-container")]},components:[Sd.parts().items({})],behaviours:qr([Wf("adhoc-scrollable-menu",[Cr(function(n,e){_i.set(n.element(),"overflow-y","auto"),_i.set(n.element(),"-webkit-overflow-scrolling","touch"),_d.register(n.element())}),kr(function(n){_i.remove(n.element(),"overflow-y"),_i.remove(n.element(),"-webkit-overflow-scrolling"),_d.deregister(n.element())})])])}],items:e,menuBehaviours:qr([Ud.config({initialState:"after",routes:Ud.createTristate("before","current","after",{transition:{property:"transform",transitionClass:"transitioning"}})})])}},qd=function(r){var o,i,n,e,t,u=(o=r.formats,i=function(){return a},n=Gd("Styles",[].concat(yn(o.items,function(n){return $d(Wd(n),n.title,n.isSelected(),n.getPreview(),Rt(o.expansions,Wd(n)))})),i,!1),e=H(o.menus,function(n,e){var t=yn(n,function(n){return $d(Wd(n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview():"",Rt(o.expansions,Wd(n)))});return Gd(e,t,i,!0)}),t=C(e,Et("styles",n)),{tmenu:Id.tieredData("styles",t,o.expansions)}),a=sf(Id.sketch({dom:{tag:"div",classes:[Mi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:function(n,e){var t=Ws.getValue(e);return r.handle(e,t.value),B.none()},onEscape:function(){return B.none()},onOpenMenu:function(n,e){var t=Xs(n.element());Ys(e.element(),t),Ud.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=Xs(n.element()),o=ru(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(o).getOrDie();Ys(t.element(),r),Ud.progressTo(i,"before"),Ud.jumpTo(t,"after"),Ud.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=ru(e.element(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();Ud.progressTo(o,"after"),Ud.progressTo(t,"current")},navigateOnHover:!1,openImmediately:!0,data:u.tmenu,markers:{backgroundMenu:Mi.resolve("styles-background-menu"),menu:Mi.resolve("styles-menu"),selectedMenu:Mi.resolve("styles-selected-menu"),item:Mi.resolve("styles-item"),selectedItem:Mi.resolve("styles-selected-item")}}));return a.asSpec()},Yd=function(n){return Rt(n,"items")?(t=C(St(e=n,["items"]),{menu:!0}),r=Xd(e.items),{item:t,menus:C(r.menus,Et(e.title,r.items)),expansions:C(r.expansions,Et(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e,t,r},Xd=function(n){return Tn(n,function(n,e){var t=Yd(e);return{menus:C(n.menus,t.menus),items:[t.item].concat(n.items),expansions:C(n.expansions,t.expansions)}},{menus:{},expansions:{},items:[]})},Kd={expand:Xd},Jd=function(u,n){var a=function(n){return function(){return u.formatter.match(n)}},c=function(n){return function(){return u.formatter.getCssText(n)}},e=kt(n,"style_formats").getOr(Al),s=function(n){return yn(n,function(n){if(Rt(n,"items")){var e=s(n.items);return C(C(n,{isSelected:E(!1),getPreview:E("")}),{items:e})}return Rt(n,"format")?C(i=n,{isSelected:a(i.format),getPreview:c(i.format)}):(r=bc((t=n).title),o=C(t,{format:r,isSelected:a(r),getPreview:c(r)}),u.formatter.register(r,o),o);var t,r,o,i})};return s(e)},Qd=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return An(n,function(n){return n.items!==undefined?0e.innerHeight||n.bottom()>e.innerHeight?n.bottom()-e.innerHeight+50:0;0!==t&&e.scrollTo(e.pageXOffset,e.pageYOffset+t)})})].concat(!0===wm?[]:[lm(fe.fromDom(r.win()),"blur",function(){t.getByDom(e).each(ki.off)}),lm(i,"select",n),lm(r.doc(),"selectionchange",n)]);return{destroy:function(){wn(a,function(n){n.unbind()})}}},Tm=function(n,e){var t=parseInt(ro.get(n,e),10);return isNaN(t)?0:t},Sm=(Cf=be.isText,kf="text",Ef=function(n){return Cf(n)?B.from(n.dom().nodeValue):B.none()},Df=Wn.detect().browser,{get:function(n){if(!Cf(n))throw new Error("Can only get "+kf+" value of a "+kf+" node");return Af(n).getOr("")},getOption:Af=Df.isIE()&&10===Df.version.major?function(n){try{return Ef(n)}catch(e){return B.none()}}:Ef,set:function(n,e){if(!Cf(n))throw new Error("Can only set raw "+kf+" value of a "+kf+" node");n.dom().nodeValue=e}}),Om=function(n){return Sm.getOption(n)},Cm=function(n){return"img"===be.name(n)?1:Om(n).fold(function(){return $e.children(n).length},function(n){return n.length})},km=Cm,Em=ct([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),Dm={before:Em.before,on:Em.on,after:Em.after,cata:function(n,e,t,r){return n.fold(e,t,r)},getStart:function(n){return n.fold(h,h,h)}},Am=ct([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),Rm=Te("start","soffset","finish","foffset"),Mm={domRange:Am.domRange,relative:Am.relative,exact:Am.exact,exactFromRange:function(n){return Am.exact(n.start(),n.soffset(),n.finish(),n.foffset())},range:Rm,getWin:function(n){var e=n.match({domRange:function(n){return fe.fromDom(n.startContainer)},relative:function(n,e){return Dm.getStart(n)},exact:function(n,e,t,r){return n}});return $e.defaultView(e)}},Im=function(n,e,t,r){var o=$e.owner(n).dom().createRange();return o.setStart(n.dom(),e),o.setEnd(t.dom(),r),o},Nm=function(n,e,t,r){var o=Im(n,e,t,r),i=ze(n,t)&&e===r;return o.collapsed&&!i},Bm=function(n,e){n.selectNodeContents(e.dom())},Fm=function(n){n.deleteContents()},Vm=function(n){return{left:E(n.left),top:E(n.top),right:E(n.right),bottom:E(n.bottom),width:E(n.width),height:E(n.height)}},Hm={create:function(n){return n.document.createRange()},replaceWith:function(n,e){Fm(n),n.insertNode(e.dom())},selectNodeContents:function(n,e){var t=n.document.createRange();return Bm(t,e),t},selectNodeContentsUsing:Bm,relativeToNative: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},exactToNative:function(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.setEnd(r.dom(),o),i},deleteContents:Fm,cloneFragment:function(n){var e=n.cloneContents();return fe.fromDom(e)},getFirstRect:function(n){var e=n.getClientRects(),t=0e.innerHeight||t.bottom()>e.innerHeight?Math.min(r,t.bottom()-e.innerHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),ag(e,n.innerHeight)});return ag(e,n.innerHeight),{toEditing:function(){ig(u)},destroy:function(){t.unbind()}}},lg=function(n){return B.some(fe.fromDom(n.dom().contentWindow.document.body))},dg=function(n){return B.some(fe.fromDom(n.dom().contentWindow.document))},mg=function(n){return B.from(n.dom().contentWindow)},gg=function(n){return mg(n).bind(Qm)},vg=function(n){return n.getFrame()},pg=function(n,t){return function(e){return e[n].getOrThunk(function(){var n=vg(e);return function(){return t(n)}})()}},hg=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return lm(e,r,n)}})},bg=function(n){return{left:E(n.left),top:E(n.top),right:E(n.right),bottom:E(n.bottom),width:E(n.width),height:E(n.height)}},yg={getBody:pg("getBody",lg),getDoc:pg("getDoc",dg),getWin:pg("getWin",mg),getSelection:pg("getSelection",gg),getFrame:vg,getActiveApi:function(a){var c=vg(a);return lg(c).bind(function(u){return dg(c).bind(function(i){return mg(c).map(function(o){var n=fe.fromDom(i.dom().documentElement),e=a.getCursorBox.getOrThunk(function(){return function(){return Zm(o).bind(function(n){return eg(o,n).orThunk(function(){return Qm(o).filter(function(n){return ze(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRect();return 0'),containerBehaviours:qr([ki.config({toggleClass:Mi.resolve("mask-tap-icon-selected"),toggleOnExecute:!1})])})),u=(t=n,r=200,o=null,{cancel:function(){null!==o&&(clearTimeout(o),o=null)},throttle:function(){for(var n=[],e=0;e'),components:[Yf.sketch({dom:ms(''),components:[ss.sketch({dom:ms(''),components:[i.asSpec()],action:function(n){u.throttle()},buttonBehaviours:qr([ki.config({toggleClass:Mi.resolve("mask-tap-icon-selected")})])})]})]})},Rg=_t([sr("editor",[ur("getFrame"),fr("getBody"),fr("getDoc"),fr("getWin"),fr("getSelection"),fr("setSelection"),fr("clearSelection"),fr("cursorSaver"),fr("onKeyup"),fr("onNodeChanged"),fr("getCursorBox"),ur("onDomChanged"),mr("onTouchContent",k),mr("onTapContent",k),mr("onTouchToolstrip",k),mr("onScrollToCursor",E({unbind:k})),mr("onScrollToElement",E({unbind:k})),mr("onToEditing",E({unbind:k})),mr("onToReading",E({unbind:k})),mr("onToolbarScrollStart",h)]),ur("socket"),ur("toolstrip"),ur("dropup"),ur("toolbar"),ur("container"),ur("alloy"),vr("win",function(n){return $e.owner(n.socket).dom().defaultView}),vr("body",function(n){return fe.fromDom(n.socket.dom().ownerDocument.body)}),mr("translate",h),mr("setReadOnly",k),mr("readOnlyOnInit",E(!0))]),Mg=function(n){var e=nr("Getting AndroidWebapp schema",Rg,n);_i.set(e.toolstrip,"width","100%");var t=ad(Ag(function(){e.setReadOnly(e.readOnlyOnInit()),o.enter()},e.translate));e.alloy.add(t);var r={show:function(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}};Ye.append(e.container,t.element());var o=Eg(e,r);return{setReadOnly:e.setReadOnly,refreshStructure:k,enter:o.enter,exit:o.exit,destroy:k}},Ig=E([mr("shell",!0),ac("toolbarBehaviours",[Ed])]),Ng=E([Nc({name:"groups",overrides:function(n){return{behaviours:qr([Ed.config({})])}}})]),Bg=cs({name:"Toolbar",configFields:Ig(),partFields:Ng(),factory:function(e,n,t,r){var o=function(n){return e.shell()?B.some(n):Uc(n,e,"groups")},i=e.shell()?{behaviours:[Ed.config({})],components:[]}:{behaviours:[],components:n};return{uid:e.uid(),dom:e.dom(),components:i.components,behaviours:C(qr(i.behaviours),cc(e.toolbarBehaviours())),apis:{setGroups:function(n,e){o(n).fold(function(){throw console.error("Toolbar was defined to not be a shell, but no groups container was specified in components"),new Error("Toolbar was defined to not be a shell, but no groups container was specified in components")},function(n){Ed.set(n,e)})}},domModification:{attributes:{role:"group"}}}},apis:{setGroups:function(n,e,t){n.setGroups(e,t)}}}),Fg=E([ur("items"),(Rf=["itemClass"],sr("markers",yn(Rf,ur))),ac("tgroupBehaviours",[uc])]),Vg=E([Bc({name:"items",unit:"item",overrides:function(n){return{domModification:{classes:[n.markers().itemClass()]}}}})]),Hg=cs({name:"ToolbarGroup",configFields:Fg(),partFields:Vg(),factory:function(n,e,t,r){return C({dom:{attributes:{role:"toolbar"}}},{uid:n.uid(),dom:n.dom(),components:e,behaviours:C(qr([uc.config({mode:"flow",selector:"."+n.markers().itemClass()})]),cc(n.tgroupBehaviours())),"debug.sketcher":t["debug.sketcher"]})}}),zg="data-"+Mi.resolve("horizontal-scroll"),jg=function(n){return"true"===ro.get(n,zg)?0<(t=n).dom().scrollLeft||function(n){n.dom().scrollLeft=1;var e=0!==n.dom().scrollLeft;return n.dom().scrollLeft=0,e}(t):0<(e=n).dom().scrollTop||function(n){n.dom().scrollTop=1;var e=0!==n.dom().scrollTop;return n.dom().scrollTop=0,e}(e);var e,t},Lg={exclusive:function(n,e){return lm(n,"touchmove",function(n){iu(n.target(),e).filter(jg).fold(function(){n.raw().preventDefault()},k)})},markAsHorizontal:function(n){ro.set(n,zg,"true")}};function Ug(){var e=function(n){var e=!0===n.scrollable?"${prefix}-toolbar-scrollable-group":"";return{dom:ms(''),tgroupBehaviours:qr([Wf("adhoc-scrollable-toolbar",!0===n.scrollable?[Er(function(n,e){_i.set(n.element(),"overflow-x","auto"),Lg.markAsHorizontal(n.element()),_d.register(n.element())})]:[])]),components:[Yf.sketch({components:[Hg.parts().items({})]})],markers:{itemClass:Mi.resolve("toolbar-group-item")},items:n.items}},t=ad(Bg.sketch({dom:ms(''),components:[Bg.parts().groups({})],toolbarBehaviours:qr([ki.config({toggleClass:Mi.resolve("context-toolbar"),toggleOnExecute:!1,aria:{mode:"none"}}),uc.config({mode:"cyclic"})]),shell:!0})),n=ad(Yf.sketch({dom:{classes:[Mi.resolve("toolstrip")]},components:[cd(t)],containerBehaviours:qr([ki.config({toggleClass:Mi.resolve("android-selection-context-toolbar"),toggleOnExecute:!1})])})),r=function(){Bg.setGroups(t,o.get()),ki.off(t)},o=So([]);return{wrapper:E(n),toolbar:E(t),createGroups:function(n){return yn(n,v(Hg.sketch,e))},setGroups:function(n){o.set(n),r()},setContextToolbar:function(n){ki.on(t),Bg.setGroups(t,n)},restoreToolbar:function(){ki.isOn(t)&&r()},refresh:function(){},focus:function(){uc.focusIn(t)}}}var Pg=function(n,e){Ed.append(n,cd(e))},_g=function(n,e){Ed.remove(n,e)},Wg=function(n){return ad(ss.sketch({dom:ms(''),action:function(){n.run(function(n){n.setReadOnly(!1)})}}))},$g=function(){return ad(Yf.sketch({dom:ms(''),components:[],containerBehaviours:qr([Ed.config({})])}))},Gg=function(n,e,t,r){(!0===t?To.toAlpha:To.toOmega)(r),(t?Pg:_g)(n,e)},qg=function(e,n){return n.getAnimationRoot().fold(function(){return e.element()},function(n){return n(e)})},Yg=function(n){return n.dimension().property()},Xg=function(n,e){return n.dimension().getDimension()(e)},Kg=function(n,e){var t=qg(n,e);Xl(t,[e.shrinkingClass(),e.growingClass()])},Jg=function(n,e){bo.remove(n.element(),e.openClass()),bo.add(n.element(),e.closedClass()),_i.set(n.element(),Yg(e),"0px"),_i.reflow(n.element())},Qg=function(n,e){bo.remove(n.element(),e.closedClass()),bo.add(n.element(),e.openClass()),_i.remove(n.element(),Yg(e))},Zg=function(n,e,t){t.setCollapsed(),_i.set(n.element(),Yg(e),Xg(e,n.element())),_i.reflow(n.element());var r=qg(n,e);bo.add(r,e.shrinkingClass()),Jg(n,e),e.onStartShrink()(n)},nv=function(n,e,t){var r=function(n,e){Qg(n,e);var t=Xg(e,n.element());return Jg(n,e),t}(n,e),o=qg(n,e);bo.add(o,e.growingClass()),Qg(n,e),_i.set(n.element(),Yg(e),r),t.setExpanded(),e.onStartGrow()(n)},ev=function(n,e,t){var r=qg(n,e);return!0===bo.has(r,e.growingClass())},tv=function(n,e,t){var r=qg(n,e);return!0===bo.has(r,e.shrinkingClass())},rv=Object.freeze({grow:function(n,e,t){t.isExpanded()||nv(n,e,t)},shrink:function(n,e,t){t.isExpanded()&&Zg(n,e,t)},immediateShrink:function(n,e,t){var r,o;t.isExpanded()&&(r=n,o=e,t.setCollapsed(),_i.set(r.element(),Yg(o),Xg(o,r.element())),_i.reflow(r.element()),Kg(r,o),Jg(r,o),o.onStartShrink()(r),o.onShrunk()(r))},hasGrown:function(n,e,t){return t.isExpanded()},hasShrunk:function(n,e,t){return t.isCollapsed()},isGrowing:ev,isShrinking:tv,isTransitioning:function(n,e,t){return!0===ev(n,e)||!0===tv(n,e)},toggleGrow:function(n,e,t){(t.isExpanded()?Zg:nv)(n,e,t)},disableTransitions:Kg}),ov=Object.freeze({exhibit:function(n,e){var t=e.expanded();return Nr(t?{classes:[e.openClass()],styles:{}}:{classes:[e.closedClass()],styles:Et(e.dimension().property(),"0px")})},events:function(t,r){return br([wr(J(),function(n,e){e.event().raw().propertyName===t.dimension().property()&&(Kg(n,t),r.isExpanded()&&_i.remove(n.element(),t.dimension().property()),(r.isExpanded()?t.onGrown():t.onShrunk())(n))})])}}),iv=[ur("closedClass"),ur("openClass"),ur("shrinkingClass"),ur("growingClass"),fr("getAnimationRoot"),ai("onShrunk"),ai("onStartShrink"),ai("onGrown"),ai("onStartGrow"),mr("expanded",!1),ar("dimension",rr("property",{width:[li("property","width"),li("getDimension",function(n){return Xs(n)+"px"})],height:[li("property","height"),li("getDimension",function(n){return Yi(n)+"px"})]}))],uv=Object.freeze({init:function(n){var e=So(n.expanded());return Gr({isExpanded:function(){return!0===e.get()},isCollapsed:function(){return!1===e.get()},setCollapsed:l(e.set,!1),setExpanded:l(e.set,!0),readState:function(){return"expanded: "+e.get()}})}}),av=Xr({fields:iv,name:"sliding",active:ov,apis:rv,state:uv}),cv=function(e,t){var r=ad(Yf.sketch({dom:{tag:"div",classes:[Mi.resolve("dropup")]},components:[],containerBehaviours:qr([Ed.config({}),av.config({closedClass:Mi.resolve("dropup-closed"),openClass:Mi.resolve("dropup-open"),shrinkingClass:Mi.resolve("dropup-shrinking"),growingClass:Mi.resolve("dropup-growing"),dimension:{property:"height"},onShrunk:function(n){e(),t(),Ed.set(n,[])},onGrown:function(n){e(),t()}}),Di(function(n,e){o(k)})])})),o=function(n){window.requestAnimationFrame(function(){n(),av.shrink(r)})};return{appear:function(n,e,t){!0===av.hasShrunk(r)&&!1===av.isTransitioning(r)&&window.requestAnimationFrame(function(){e(t),Ed.set(r,[n()]),av.grow(r)})},disappear:o,component:E(r),element:r.element}},sv=Wn.detect().browser.isFirefox(),fv=Pt([cr("triggerEvent"),cr("broadcastEvent"),mr("stopBackspace",!0)]),lv=function(e,n){var t,r,o,i,u=nr("Getting GUI events settings",fv,n),a=Wn.detect().deviceType.isTouch()?["touchstart","touchmove","touchend","gesturestart"]:["mousedown","mouseup","mouseover","mousemove","mouseout","click"],c=bm(u),s=yn(a.concat(["selectstart","input","contextmenu","change","transitionend","drag","dragstart","dragend","dragenter","dragleave","dragover","drop"]),function(n){return lm(e,n,function(e){c.fireIfReady(e,n).each(function(n){n&&e.kill()}),u.triggerEvent(n,e)&&e.kill()})}),f=lm(e,"keydown",function(n){var e;u.triggerEvent("keydown",n)?n.kill():!0!==u.stopBackspace||8!==(e=n).raw().which||hn(["input","textarea"],be.name(e.target()))||n.prevent()}),l=(t=e,r=function(n){u.triggerEvent("focusin",n)&&n.kill()},sv?dm(t,"focus",r):lm(t,"focusin",r)),d=(o=e,i=function(n){u.triggerEvent("focusout",n)&&n.kill(),setTimeout(function(){u.triggerEvent(qn(),n)},0)},sv?dm(o,"blur",i):lm(o,"focusout",i)),m=$e.defaultView(e),g=lm(m,"scroll",function(n){u.broadcastEvent(ee(),n)&&n.kill()});return{unbind:function(){wn(s,function(n){n.unbind()}),f.unbind(),l.unbind(),d.unbind(),g.unbind()}}},dv=function(n,e){var t=kt(n,"target").map(function(n){return n()}).getOr(e);return So(t)},mv=ct([{stopped:[]},{resume:["element"]},{complete:[]}]),gv=function(n,r,e,t,o,i){var u,a,c,s,f=n(r,t),l=(u=e,a=o,c=So(!1),s=So(!1),{stop:function(){c.set(!0)},cut:function(){s.set(!0)},isStopped:c.get,isCut:s.get,event:E(u),setSource:a.set,getSource:a.get});return f.fold(function(){return i.logEventNoHandlers(r,t),mv.complete()},function(e){var t=e.descHandler();return Ll(t)(l),l.isStopped()?(i.logEventStopped(r,e.element(),t.purpose()),mv.stopped()):l.isCut()?(i.logEventCut(r,e.element(),t.purpose()),mv.complete()):$e.parent(e.element()).fold(function(){return i.logNoParent(r,e.element(),t.purpose()),mv.complete()},function(n){return i.logEventResponse(r,e.element(),t.purpose()),mv.resume(n)})})},vv=function(e,t,r,n,o,i){return gv(e,t,r,n,o,i).fold(function(){return!0},function(n){return vv(e,t,r,n,o,i)},function(){return!1})},pv=function(n,e,t){var r,o,i=(r=e,o=So(!1),{stop:function(){o.set(!0)},cut:k,isStopped:o.get,isCut:E(!1),event:E(r),setSource:c("Cannot set source of a broadcasted event"),getSource:c("Cannot get source of a broadcasted event")});return wn(n,function(n){var e=n.descHandler();Ll(e)(i)}),i.isStopped()},hv=function(n,e,t,r,o){var i=dv(t,r);return vv(n,e,t,r,i,o)},bv=function(n,e,t){return Do.closest(n,function(n){return e(n).isSome()},t).bind(e)},yv=Te("element","descHandler"),wv=function(n,e){return{id:E(n),descHandler:E(e)}};function xv(){var i={};return{registerId:function(r,o,n){V(n,function(n,e){var t=i[e]!==undefined?i[e]:{};t[o]=jl(n,r),i[e]=t})},unregisterId:function(t){V(i,function(n,e){n.hasOwnProperty(t)&&delete n[t]})},filterByType:function(n){return kt(i,n).map(function(n){return j(n,function(n,e){return wv(e,n)})}).getOr([])},find:function(n,e,t){var o=Ot(e)(i);return bv(t,function(n){return t=o,ns(r=n).fold(function(){return B.none()},function(n){var e=Ot(n);return t.bind(e).map(function(n){return yv(r,n)})});var t,r},n)}}}function Tv(){var r=xv(),o={},i=function(r){var n=r.element();return ns(n).fold(function(){return n="uid-",e=r.element(),t=bc(Qc+n),ro.set(e,Zc,t),t;var n,e,t},function(n){return n})},u=function(n){ns(n.element()).each(function(n){o[n]=undefined,r.unregisterId(n)})};return{find:function(n,e,t){return r.find(n,e,t)},filter:function(n){return r.filterByType(n)},register:function(n){var e=i(n);Rt(o,e)&&function(n,e){var t=o[e];if(t!==n)throw new Error('The tagId "'+e+'" is already used by: '+qo(t.element())+"\nCannot use it for: "+qo(n.element())+"\nThe conflicting element is"+(xe.inBody(t.element())?" ":" not ")+"already in the DOM");u(n)}(n,e);var t=[n];r.registerId(t,e,n.events()),o[e]=n},unregister:u,getById:function(n){return Ot(n)(o)}}}var Sv=function(t){var r=function(e){return $e.parent(t.element()).fold(function(){return!0},function(n){return ze(e,n)})},o=Tv(),s=function(n,e){return o.find(r,n,e)},n=lv(t.element(),{triggerEvent:function(u,a){return ei(u,a.target(),function(n){return e=s,t=u,o=n,i=(r=a).target(),hv(e,t,r,i,o);var e,t,r,o,i})},broadcastEvent:function(n,e){var t=o.filter(n);return pv(t,e)}}),i=Nl({debugInfo:E("real"),triggerEvent:function(e,t,r){ei(e,t,function(n){hv(s,e,r,t,n)})},triggerFocus:function(a,c){ns(a).fold(function(){Io(a)},function(n){ei(Gn(),a,function(n){var e,t,r,o,i,u;e=s,t=Gn(),r={originator:E(c),kill:k,prevent:k,target:E(a)},i=n,u=dv(r,o=a),gv(e,t,r,o,u,i)})})},triggerEscape:function(n,e){i.triggerEvent("keydown",n.element(),e.event())},getByUid:function(n){return m(n)},getByDom:function(n){return g(n)},build:ad,addToGui:function(n){a(n)},removeFromGui:function(n){c(n)},addToWorld:function(n){e(n)},removeFromWorld:function(n){u(n)},broadcast:function(n){l(n)},broadcastOn:function(n,e){d(n,e)},isConnected:E(!0)}),e=function(n){n.connect(i),be.isText(n.element())||(o.register(n),wn(n.components(),e),i.triggerEvent(ne(),n.element(),{target:E(n.element())}))},u=function(n){be.isText(n.element())||(wn(n.components(),u),o.unregister(n)),n.disconnect()},a=function(n){et(t,n)},c=function(n){ot(n)},f=function(t){var n=o.filter(Yn());wn(n,function(n){var e=n.descHandler();Ll(e)(t)})},l=function(n){f({universal:E(!0),data:E(n)})},d=function(n,e){f({universal:E(!1),channels:E(n),data:E(e)})},m=function(n){return o.getById(n).fold(function(){return at.error(new Error('Could not find component with uid: "'+n+'" in system.'))},at.value)},g=function(n){var e=ns(n).getOr("not found");return m(e)};return e(t),{root:E(t),element:t.element,destroy:function(){n.unbind(),Qe.remove(t.element())},add:a,remove:c,getByUid:m,getByDom:g,addToWorld:e,removeFromWorld:u,broadcast:l,broadcastOn:d}},Ov=E(Mi.resolve("readonly-mode")),Cv=E(Mi.resolve("edit-mode"));function kv(n){var e=ad(Yf.sketch({dom:{classes:[Mi.resolve("outer-container")].concat(n.classes)},containerBehaviours:qr([To.config({alpha:Ov(),omega:Cv()})])}));return Sv(e)}var Ev=function(n,e){var t=fe.fromTag("input");_i.setAll(t,{opacity:"0",position:"absolute",top:"-1000px",left:"-1000px"}),Ye.append(n,t),Io(t),e(t),Qe.remove(t)},Dv=function(n){var e=n.getSelection();if(0Math.abs(t-o))&&(clearInterval(s),a(o))}})},t)}}},zv=function(e,t){return Ko([{width:320,height:480,keyboard:{portrait:300,landscape:240}},{width:320,height:568,keyboard:{portrait:300,landscape:240}},{width:375,height:667,keyboard:{portrait:305,landscape:240}},{width:414,height:736,keyboard:{portrait:320,landscape:240}},{width:768,height:1024,keyboard:{portrait:320,landscape:400}},{width:1024,height:1366,keyboard:{portrait:380,landscape:460}}],function(n){return e<=n.width&&t<=n.height?B.some(n.keyboard):B.none()}).getOr({portrait:t/5,landscape:e/4})},jv=function(n){var e,t=gm(n).isPortrait(),r=zv((e=n).screen.width,e.screen.height),o=t?r.portrait:r.landscape;return(t?n.screen.height:n.screen.width)-n.innerHeight>o?0:o},Lv=function(n,e){var t=$e.owner(n).dom().defaultView;return Yi(n)+Yi(e)-jv(t)},Uv=Lv,Pv=function(n,e,t){var r=Lv(e,t),o=Yi(e)+Yi(t)-r;_i.set(n,"padding-bottom",o+"px")},_v=ct([{fixed:["element","property","offsetY"]},{scroller:["element","offsetY"]}]),Wv="data-"+Mi.resolve("position-y-fixed"),$v="data-"+Mi.resolve("y-property"),Gv="data-"+Mi.resolve("scrolling"),qv="data-"+Mi.resolve("last-window-height"),Yv=function(n){return Tm(n,Wv)},Xv=function(n,e){var t=ro.get(n,$v);return _v.fixed(n,t,e)},Kv=function(n,e){return _v.scroller(n,e)},Jv=function(n){var e=Yv(n);return("true"===ro.get(n,Gv)?Kv:Xv)(n,e)},Qv=function(n,e,t){var r=$e.owner(n).dom().defaultView.innerHeight;return ro.set(n,qv,r+"px"),r-e-t},Zv=function(n){var e=nu(n,"["+Wv+"]");return yn(e,Jv)},np=function(r,o,i,u){var n,e,t,a,c,s,f,l,d=$e.owner(r).dom().defaultView,m=(l=ro.get(f=i,"style"),_i.setAll(f,{position:"absolute",top:"0px"}),ro.set(f,Wv,"0px"),ro.set(f,$v,"top"),{restore:function(){ro.set(f,"style",l||""),ro.remove(f,Wv),ro.remove(f,$v)}}),g=Yi(i),v=Yi(u),p=Qv(r,g,v),h=(t=g,a=p,s=ro.get(c=r,"style"),_d.register(c),_i.setAll(c,{position:"absolute",height:a+"px",width:"100%",top:t+"px"}),ro.set(c,Wv,t+"px"),ro.set(c,Gv,"true"),ro.set(c,$v,"top"),{restore:function(){_d.deregister(c),ro.set(c,"style",s||""),ro.remove(c,Wv),ro.remove(c,Gv),ro.remove(c,$v)}}),b=(e=ro.get(n=u,"style"),_i.setAll(n,{position:"absolute",bottom:"0px"}),ro.set(n,Wv,"0px"),ro.set(n,$v,"bottom"),{restore:function(){ro.set(n,"style",e||""),ro.remove(n,Wv),ro.remove(n,$v)}}),y=!0,w=function(){var n=d.innerHeight;return Tm(r,qv)=u.length&&r(o)}))})})},mp=function(n,c){return n.fold(function(n,e,t){return r=n,o=e,u=c+(i=t),_i.set(r,o,u+"px"),Fv.pure(i);var r,o,i,u},function(n,e){return t=n,o=c+(r=e),i=_i.getRaw(t,"top").getOr(r),u=o-parseInt(i,10),a=t.dom().scrollTop+u,ap(t,a,o);var t,r,o,i,u,a})},gp=function(n,e){var t=Zv(n),r=yn(t,function(n){return mp(n,e)});return dp(r,Fv.nu)},vp=function(e,t,n,r,o,i){var u,a,c=(u=function(n){return fp(e,t,n)},a=So(Nv.pure({})),{start:function(e){var n=Nv.nu(function(n){return u(e).get(n)});a.set(n)},idle:function(n){a.get().get(function(){n()})}}),s=Dg(function(){c.idle(function(){gp(n,r.pageYOffset).get(function(){var n;(n=og(i),B.from(n[0]).bind(function(n){var e=n.top()-t.dom().scrollTop;return e>r.innerHeight+5||e<-5?B.some({top:E(e),bottom:E(e+n.height())}):B.none()})).each(function(n){t.dom().scrollTop=t.dom().scrollTop+n.top()}),c.start(0),o.refresh()})})},1e3),f=lm(fe.fromDom(r),"scroll",function(){r.pageYOffset<0||s.throttle()});return gp(n,r.pageYOffset).get(h),{unbind:f.unbind}},pp=function(n){var t=n.cWin(),e=n.ceBody(),r=n.socket(),o=n.toolstrip(),i=n.toolbar(),u=n.contentElement(),a=n.keyboardType(),c=n.outerWindow(),s=n.dropup(),f=np(r,e,o,s),l=a(n.outerBody(),t,xe.body(),u,o,i),d=vm(c,{onChange:k,onReady:f.refresh});d.onAdjustment(function(){f.refresh()});var m=lm(fe.fromDom(c),"resize",function(){f.isExpanding()&&f.refresh()}),g=vp(o,r,n.outerBody(),c,f,t),v=function(t,e){var n=t.document,r=fe.fromTag("div");bo.add(r,Mi.resolve("unfocused-selections")),Ye.append(fe.fromDom(n.documentElement),r);var o=lm(r,"touchstart",function(n){n.prevent(),Av(t,e),u()}),i=function(n){var e=fe.fromTag("span");return Yl(e,[Mi.resolve("layer-editor"),Mi.resolve("unfocused-selection")]),_i.setAll(e,{left:n.left()+"px",top:n.top()+"px",width:n.width()+"px",height:n.height()+"px"}),e},u=function(){Qe.empty(r)};return{update:function(){u();var n=og(t),e=yn(n,i);Ke(r,e)},isActive:function(){return 0<$e.children(r).length},destroy:function(){o.unbind(),Qe.remove(r)},clear:u}}(t,u),p=function(){v.clear()};return{toEditing:function(){l.toEditing(),p()},toReading:function(){l.toReading()},onToolbarTouch:function(n){l.onToolbarTouch(n)},refreshSelection:function(){v.isActive()&&v.update()},clearSelection:p,highlightSelection:function(){v.update()},scrollIntoView:function(n,e){lp(t,r,s,n,e)},updateToolbarPadding:k,setViewportOffset:function(n){f.setViewportOffset(n),sp(r,n).get(h)},syncHeight:function(){_i.set(u,"height",u.dom().contentWindow.document.body.scrollHeight+"px")},refreshStructure:f.refresh,destroy:function(){f.restore(),d.destroy(),g.unbind(),m.unbind(),l.destroy(),v.destroy(),Ev(xe.body(),No)}}},hp=function(r,n){var o=kg(),i=Sl(),u=Sl(),a=Tl(),c=Tl();return{enter:function(){n.hide();var t=fe.fromDom(document);yg.getActiveApi(r.editor).each(function(n){i.set({socketHeight:_i.getRaw(r.socket,"height"),iframeHeight:_i.getRaw(n.frame(),"height"),outerScroll:document.body.scrollTop}),u.set({exclusives:Lg.exclusive(t,"."+_d.scrollable())}),bo.add(r.container,Mi.resolve("fullscreen-maximized")),Og(r.container,n.body()),o.maximize(),_i.set(r.socket,"overflow","scroll"),_i.set(r.socket,"-webkit-overflow-scrolling","touch"),Io(n.body());var e=De(["cWin","ceBody","socket","toolstrip","toolbar","dropup","contentElement","cursor","keyboardType","isScrolling","outerWindow","outerBody"],[]);a.set(pp(e({cWin:n.win(),ceBody:n.body(),socket:r.socket,toolstrip:r.toolstrip,toolbar:r.toolbar,dropup:r.dropup.element(),contentElement:n.frame(),cursor:k,outerBody:r.body,outerWindow:r.win,keyboardType:Rv.stubborn,isScrolling:function(){return u.get().exists(function(n){return n.socket.isScrolling()})}}))),a.run(function(n){n.syncHeight()}),c.set(Mv(n,a,r.toolstrip,r.socket,r.dropup))})},refreshStructure:function(){a.run(function(n){n.refreshStructure()})},exit:function(){o.restore(),c.clear(),a.clear(),n.show(),i.on(function(n){n.socketHeight.each(function(n){_i.set(r.socket,"height",n)}),n.iframeHeight.each(function(n){_i.set(r.editor.getFrame(),"height",n)}),document.body.scrollTop=n.scrollTop}),i.clear(),u.on(function(n){n.exclusives.unbind()}),u.clear(),bo.remove(r.container,Mi.resolve("fullscreen-maximized")),Cg(),_d.deregister(r.toolbar),_i.remove(r.socket,"overflow"),_i.remove(r.socket,"-webkit-overflow-scrolling"),No(r.editor.getFrame()),yg.getActiveApi(r.editor).each(function(n){n.clearSelection()})}}},bp=function(n){var e=nr("Getting IosWebapp schema",Rg,n);_i.set(e.toolstrip,"width","100%"),_i.set(e.container,"position","relative");var t=ad(Ag(function(){e.setReadOnly(e.readOnlyOnInit()),r.enter()},e.translate));e.alloy.add(t);var r=hp(e,{show:function(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}});return{setReadOnly:e.setReadOnly,refreshStructure:r.refreshStructure,enter:r.enter,exit:r.exit,destroy:k}},yp=tinymce.util.Tools.resolve("tinymce.EditorManager"),wp=function(n){var e=kt(n.settings,"skin_url").fold(function(){return yp.baseURL+"/skins/lightgray"},function(n){return n});return{content:e+"/content.mobile.min.css",ui:e+"/skin.mobile.min.css"}},xp=function(n,e,t){n.system().broadcastOn([jo.formatChanged()],{command:e,state:t})},Tp=function(r,n){var e=F(n.formatter.get());wn(e,function(e){n.formatter.formatChanged(e,function(n){xp(r,e,n)})}),wn(["ul","ol"],function(t){n.selection.selectorChanged(t,function(n,e){xp(r,t,n)})})},Sp=(E(["x-small","small","medium","large","x-large"]),function(n){var e=function(){n._skinLoaded=!0,n.fire("SkinLoaded")};return function(){n.initialized?e():n.on("init",e)}}),Op=E("toReading"),Cp=E("toEditing");Ho.add("mobile",function(C){return{getNotificationManagerImpl:function(){return{open:h,close:k,reposition:k,getArgs:h}},renderUI:function(n){var e=wp(C);0==(!1===C.settings.skin)?(C.contentCSS.push(e.content),Vo.DOM.styleSheetLoader.load(e.ui,Sp(C))):Sp(C)();var t,r,o,i,u,a,c,s,f,l,d,m,g,v,p=function(){C.fire("scrollIntoView")},h=fe.fromTag("div"),b=Wn.detect().os.isAndroid()?(s=p,f=kv({classes:[Mi.resolve("android-container")]}),l=Ug(),d=Tl(),m=Wg(d),g=$g(),v=cv(k,s),f.add(l.wrapper()),f.add(g),f.add(v.component()),{system:E(f),element:f.element,init:function(n){d.set(Mg(n))},exit:function(){d.run(function(n){n.exit(),Ed.remove(g,m)})},setToolbarGroups:function(n){var e=l.createGroups(n);l.setGroups(e)},setContextToolbar:function(n){var e=l.createGroups(n);l.setContextToolbar(e)},focusToolbar:function(){l.focus()},restoreToolbar:function(){l.restoreToolbar()},updateMode:function(n){Gg(g,m,n,f.root())},socket:E(g),dropup:E(v)}):(t=p,r=kv({classes:[Mi.resolve("ios-container")]}),o=Ug(),i=Tl(),u=Wg(i),a=$g(),c=cv(function(){i.run(function(n){n.refreshStructure()})},t),r.add(o.wrapper()),r.add(a),r.add(c.component()),{system:E(r),element:r.element,init:function(n){i.set(bp(n))},exit:function(){i.run(function(n){Ed.remove(a,u),n.exit()})},setToolbarGroups:function(n){var e=o.createGroups(n);o.setGroups(e)},setContextToolbar:function(n){var e=o.createGroups(n);o.setContextToolbar(e)},focusToolbar:function(){o.focus()},restoreToolbar:function(){o.restoreToolbar()},updateMode:function(n){Gg(a,u,n,r.root())},socket:E(a),dropup:E(c)}),y=fe.fromDom(n.targetNode);Ye.after(y,h),function(n,e){Ye.append(n,e.element());var t=$e.children(e.element());wn(t,function(n){e.getByDom(n).each(nt)})}(h,b.system());var w=n.targetNode.ownerDocument.defaultView,x=vm(w,{onChange:function(){b.system().broadcastOn([jo.orientationChanged()],{width:pm(w)})},onReady:k}),T=function(n,e,t,r){!1===r&&C.selection.collapse();var o=S(n,e,t);b.setToolbarGroups(!0===r?o.readOnly:o.main),C.setMode(!0===r?"readonly":"design"),C.fire(!0===r?Op():Cp()),b.updateMode(r)},S=function(n,e,t){var r=n.get(),o={readOnly:r.backToMask.concat(e.get()),main:r.backToMask.concat(t.get())};return o},O=function(n,e){return C.on(n,e),{unbind:function(){C.off(n)}}};return C.on("init",function(){b.init({editor:{getFrame:function(){return fe.fromDom(C.contentAreaContainer.querySelector("iframe"))},onDomChanged:function(){return{unbind:k}},onToReading:function(n){return O(Op(),n)},onToEditing:function(n){return O(Cp(),n)},onScrollToCursor:function(e){return C.on("scrollIntoView",function(n){e(n)}),{unbind:function(){C.off("scrollIntoView"),x.destroy()}}},onTouchToolstrip:function(){t()},onTouchContent:function(){var n,e=fe.fromDom(C.editorContainer.querySelector("."+Mi.resolve("toolbar")));(n=e,Fo(n).bind(function(n){return b.system().getByDom(n).toOption()})).each(ue),b.restoreToolbar(),t()},onTapContent:function(n){var e=n.target();"img"===be.name(e)?(C.selection.select(e.dom()),n.kill()):"a"===be.name(e)&&b.system().getByDom(fe.fromDom(C.editorContainer)).each(function(n){To.isAlpha(n)&&zo(e.dom())})}},container:fe.fromDom(C.editorContainer),socket:fe.fromDom(C.contentAreaContainer),toolstrip:fe.fromDom(C.editorContainer.querySelector("."+Mi.resolve("toolstrip"))),toolbar:fe.fromDom(C.editorContainer.querySelector("."+Mi.resolve("toolbar"))),dropup:b.dropup(),alloy:b.system(),translate:k,setReadOnly:function(n){T(c,a,u,n)},readOnlyOnInit:function(){return!1}});var t=function(){b.dropup().disappear(function(){b.system().broadcastOn([jo.dropupDismissed()],{})})},n={label:"The first group",scrollable:!1,items:[hs.forToolbar("back",function(){C.selection.collapse(),b.exit()},{})]},e={label:"Back to read only",scrollable:!1,items:[hs.forToolbar("readonly-back",function(){T(c,a,u,!0)},{})]},r=rm(b,C),o=om(C.settings,r),i={label:"The extra group",scrollable:!1,items:[]},u=So([{label:"the action group",scrollable:!0,items:o},i]),a=So([{label:"The read only mode group",scrollable:!0,items:[]},i]),c=So({backToMask:[n],backToReadOnly:[e]});Tp(b,C)}),{iframeContainer:b.socket().element().dom(),editorContainer:b.element().dom()}}}})}();