"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/tiny_mce/lib/themes/mobile/theme.min.js" between
glpi-9.3.3.tgz and glpi-9.4.0.tgz

About: GLPI is an IT and asset management software (Information Resource Manager).

theme.min.js  (glpi-9.3.3.tgz):theme.min.js  (glpi-9.4.0.tgz)
!function(){"use strict";var n,e,t,o,r,i,u,a,c,s=function(n){return function(){r eturn n}},f=s(!1),l=s(!0),O={noop:function(){for(var n=[],e=0;e<arguments.length ;e++)n[e]=arguments[e]},noarg:function(t){return function(){for(var n=[],e=0;e<a rguments.length;e++)n[e]=arguments[e];return t()}},compose:function(t,o){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t(o. apply(null,arguments))}},constant:s,identity:function(n){return n},tripleEquals: function(n,e){return n===e},curry:function(i){for(var n=[],e=1;e<arguments.lengt h;e++)n[e-1]=arguments[e];for(var u=new Array(arguments.length-1),t=1;t<argument s.length;t++)u[t-1]=arguments[t];return function(){for(var n=[],e=0;e<arguments. length;e++)n[e]=arguments[e];for(var t=new Array(arguments.length),o=0;o<t.lengt h;o++)t[o]=arguments[o];var r=u.concat(t);return i.apply(null,r)}},not:function( t){return function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];r eturn!t.apply(null,arguments)}},die:function(n){return function(){throw new Erro r(n)}},apply:function(n){return n()},call:function(n){n()},never:f,always:l},d=f unction(e){return function(n){return function(n){if(null===n)return"null";var e= typeof n;return"object"===e&&Array.prototype.isPrototypeOf(n)?"array":"object"== =e&&String.prototype.isPrototypeOf(n)?"string":e}(n)===e}},E={isString:d("string "),isObject:d("object"),isArray:d("array"),isNull:d("null"),isBoolean:d("boolean "),isUndefined:d("undefined"),isFunction:d("function"),isNumber:d("number")},m=f unction(u){return function(){for(var n=new Array(arguments.length),e=0;e<n.lengt h;e++)n[e]=arguments[e];if(0===n.length)throw new Error("Can't merge zero object s");for(var t={},o=0;o<n.length;o++){var r=n[o];for(var i in r)r.hasOwnProperty( i)&&(t[i]=u(t[i],r[i]))}return t}},g=m(function(n,e){return E.isObject(n)&&E.isO bject(e)?g(n,e):e}),p=m(function(n,e){return e}),D={deepMerge:g,merge:p},h=O.nev er,v=O.always,y=function(){return b},b=(o={fold:function(n,e){return n()},is:h,i sSome:h,isNone:v,getOr:t=function(n){return n},getOrThunk:e=function(n){return n ()},getOrDie:function(n){throw new Error(n||"error: getOrDie called on none.")}, or:t,orThunk:e,map:y,ap:y,each:function(){},bind:y,flatten:y,exists:h,forall:v,f ilter:y,equals:n=function(n){return n.isNone()},equals_:n,toArray:function(){ret urn[]},toString:O.constant("none()")},Object.freeze&&Object.freeze(o),o),w=funct ion(t){var n=function(){return t},e=function(){return r},o=function(n){return n( t)},r={fold:function(n,e){return e(t)},is:function(n){return t===n},isSome:v,isN one:h,getOr:n,getOrThunk:n,getOrDie:n,or:e,orThunk:e,map:function(n){return w(n( t))},ap:function(n){return n.fold(y,function(n){return w(n(t))})},each:function( n){n(t)},bind:o,flatten:n,exists:o,forall:o,filter:function(n){return n(t)?r:b}, equals:function(n){return n.is(t)},equals_:function(n,e){return n.fold(h,functio n(n){return e(t,n)})},toArray:function(){return[t]},toString:function(){return"s ome("+t+")"}};return r},x={some:w,none:y,from:function(n){return null===n||n===u ndefined?b:w(n)}},T=(r=Object.keys)===undefined?function(n){var e=[];for(var t i n n)n.hasOwnProperty(t)&&e.push(t);return e}:r,S=function(n,e){for(var t=T(n),o= 0,r=t.length;o<r;o++){var i=t[o];e(n[i],i,n)}},k=function(o,r){var i={};return S (o,function(n,e){var t=r(n,e,o);i[t.k]=t.v}),i},C=function(n,t){var o=[];return S(n,function(n,e){o.push(t(n,e))}),o},A=function(n){return C(n,function(n){retur n n})},M={bifilter:function(n,t){var o={},r={};return S(n,function(n,e){(t(n,e)? o:r)[e]=n}),{t:o,f:r}},each:S,map:function(n,o){return k(n,function(n,e,t){retur n{k:e,v:o(n,e,t)}})},mapToArray:C,tupleMap:k,find:function(n,e){for(var t=T(n),o =0,r=t.length;o<r;o++){var i=t[o],u=n[i];if(e(u,i,n))return x.some(u)}return x.n one()},keys:T,values:A,size:function(n){return A(n).length}},B=(O.constant("cont extmenu"),O.constant("touchstart")),R=O.constant("touchmove"),I=O.constant("touc hend"),F=(O.constant("gesturestart"),O.constant("mousedown")),N=O.constant("mous emove"),V=(O.constant("mouseout"),O.constant("mouseup")),H=O.constant("mouseover "),j=(O.constant("focusin"),O.constant("keydown")),z=O.constant("input"),L=O.con stant("change"),P=(O.constant("focus"),O.constant("click")),W=O.constant("transi tionend"),U=O.constant("selectstart"),G=function(n){var e,t=!1;return function() {return t||(t=!0,e=n.apply(null,arguments)),e}},$=function(n,e){var t=function(n ,e){for(var t=0;t<n.length;t++){var o=n[t];if(o.test(e))return o}return undefine d}(n,e);if(!t)return{major:0,minor:0};var o=function(n){return Number(e.replace( t,"$"+n))};return _(o(1),o(2))},q=function(){return _(0,0)},_=function(n,e){retu rn{major:n,minor:e}},K={nu:_,detect:function(n,e){var t=String(e).toLowerCase(); return 0===n.length?q():$(n,t)},unknown:q},X="Firefox",Y=function(n,e){return fu nction(){return e===n}},J=function(n){var e=n.current;return{current:e,version:n .version,isEdge:Y("Edge",e),isChrome:Y("Chrome",e),isIE:Y("IE",e),isOpera:Y("Ope ra",e),isFirefox:Y(X,e),isSafari:Y("Safari",e)}},Q={unknown:function(){return J( {current:undefined,version:K.unknown()})},nu:J,edge:O.constant("Edge"),chrome:O. constant("Chrome"),ie:O.constant("IE"),opera:O.constant("Opera"),firefox:O.const ant(X),safari:O.constant("Safari")},Z="Windows",nn="Android",en="Solaris",tn="Fr eeBSD",on=function(n,e){return function(){return e===n}},rn=function(n){var e=n. current;return{current:e,version:n.version,isWindows:on(Z,e),isiOS:on("iOS",e),i sAndroid:on(nn,e),isOSX:on("OSX",e),isLinux:on("Linux",e),isSolaris:on(en,e),isF reeBSD:on(tn,e)}},un={unknown:function(){return rn({current:undefined,version:K. unknown()})},nu:rn,windows:O.constant(Z),ios:O.constant("iOS"),android:O.constan t(nn),linux:O.constant("Linux"),osx:O.constant("OSX"),solaris:O.constant(en),fre ebsd:O.constant(tn)},an=(i=Array.prototype.indexOf)===undefined?function(n,e){re turn gn(n,e)}:function(n,e){return i.call(n,e)},cn=function(n,e){return-1<an(n,e )},sn=function(n,e){for(var t=n.length,o=new Array(t),r=0;r<t;r++){var i=n[r];o[ r]=e(i,r,n)}return o},fn=function(n,e){for(var t=0,o=n.length;t<o;t++)e(n[t],t,n )},ln=function(n,e){for(var t=n.length-1;0<=t;t--)e(n[t],t,n)},dn=function(n,e){ for(var t=[],o=0,r=n.length;o<r;o++){var i=n[o];e(i,o,n)&&t.push(i)}return t},mn =function(n,e){for(var t=0,o=n.length;t<o;t++)if(e(n[t],t,n))return x.some(t);re turn x.none()},gn=function(n,e){for(var t=0,o=n.length;t<o;++t)if(n[t]===e)retur n t;return-1},pn=Array.prototype.push,hn=function(n){for(var e=[],t=0,o=n.length ;t<o;++t){if(!Array.prototype.isPrototypeOf(n[t]))throw new Error("Arr.flatten i tem "+t+" was not an array, input: "+n);pn.apply(e,n[t])}return e},vn=function(n ,e){for(var t=0,o=n.length;t<o;++t)if(!0!==e(n[t],t,n))return!1;return!0},yn=Arr ay.prototype.slice,bn=E.isFunction(Array.from)?Array.from:function(n){return yn. call(n)},wn={map:sn,each:fn,eachr:ln,partition:function(n,e){for(var t=[],o=[],r =0,i=n.length;r<i;r++){var u=n[r];(e(u,r,n)?t:o).push(u)}return{pass:t,fail:o}}, filter:dn,groupBy:function(n,e){if(0===n.length)return[];for(var t=e(n[0]),o=[], r=[],i=0,u=n.length;i<u;i++){var a=n[i],c=e(a);c!==t&&(o.push(r),r=[]),t=c,r.pus h(a)}return 0!==r.length&&o.push(r),o},indexOf:function(n,e){var t=an(n,e);retur n-1===t?x.none():x.some(t)},foldr:function(n,e,t){return ln(n,function(n){t=e(t, n)}),t},foldl:function(n,e,t){return fn(n,function(n){t=e(t,n)}),t},find:functio n(n,e){for(var t=0,o=n.length;t<o;t++){var r=n[t];if(e(r,t,n))return x.some(r)}r eturn x.none()},findIndex:mn,flatten:hn,bind:function(n,e){var t=sn(n,e);return hn(t)},forall:vn,exists:function(n,e){return mn(n,e).isSome()},contains:cn,equal :function(n,t){return n.length===t.length&&vn(n,function(n,e){return n===t[e]})} ,reverse:function(n){var e=yn.call(n,0);return e.reverse(),e},chunk:function(n,e ){for(var t=[],o=0;o<n.length;o+=e){var r=n.slice(o,o+e);t.push(r)}return t},dif ference:function(n,e){return dn(n,function(n){return!cn(e,n)})},mapToObject:func tion(n,e){for(var t={},o=0,r=n.length;o<r;o++){var i=n[o];t[String(i)]=e(i,o)}re turn t},pure:function(n){return[n]},sort:function(n,e){var t=yn.call(n,0);return t.sort(e),t},range:function(n,e){for(var t=[],o=0;o<n;o++)t.push(e(o));return t },head:function(n){return 0===n.length?x.none():x.some(n[0])},last:function(n){r eturn 0===n.length?x.none():x.some(n[n.length-1])},from:bn},xn=function(n,e){var t=String(e).toLowerCase();return wn.find(n,function(n){return n.search(t)})},Tn =function(n,t){return xn(n,t).map(function(n){var e=K.detect(n.versionRegexes,t) ;return{current:n.name,version:e}})},Sn=function(n,t){return xn(n,t).map(functio n(n){var e=K.detect(n.versionRegexes,t);return{current:n.name,version:e}})},kn=f unction(n,e){return e+n},Cn=function(n,e){return n+e},On=function(n,e){return n. substring(e)},En=function(n,e){return n.substring(0,n.length-e)},Dn=function(n){ return""===n?x.none():x.some(n.substr(0,1))},An=function(n){return""===n?x.none( ):x.some(n.substring(1))},Mn=function(n,e,t){return""===e||!(n.length<e.length)& &n.substr(t,t+e.length)===e},Bn=function(n,e){return Mn(n,e,0)},Rn=function(n,e) {return Mn(n,e,n.length-e.length)},In={supplant:function(n,r){return n.replace(/ \${([^{}]*)}/g,function(n,e){var t,o=r[e];return"string"==(t=typeof o)||"number" ===t?o:n})},startsWith:Bn,removeLeading:function(n,e){return Bn(n,e)?On(n,e.leng th):n},removeTrailing:function(n,e){return Rn(n,e)?En(n,e.length):n},ensureLeadi ng:function(n,e){return Bn(n,e)?n:kn(n,e)},ensureTrailing:function(n,e){return R n(n,e)?n:Cn(n,e)},endsWith:Rn,contains:function(n,e){return-1!==n.indexOf(e)},tr im:function(n){return n.replace(/^\s+|\s+$/g,"")},lTrim:function(n){return n.rep lace(/^\s+/g,"")},rTrim:function(n){return n.replace(/\s+$/g,"")},capitalize:fun ction(n){return Dn(n).bind(function(e){return An(n).map(function(n){return e.toU pperCase()+n})}).getOr(n)}},Fn=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,Nn=function (e){return function(n){return In.contains(n,e)}},Vn=[{name:"Edge",versionRegexes :[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],search:function(n){return In.contains(n,"edg e/")&&In.contains(n,"chrome")&&In.contains(n,"safari")&&In.contains(n,"applewebk it")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/,Fn],sear ch:function(n){return In.contains(n,"chrome")&&!In.contains(n,"chromeframe")}},{ name:"IE",versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0- 9]+).*/],search:function(n){return In.contains(n,"msie")||In.contains(n,"trident ")}},{name:"Opera",versionRegexes:[Fn,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:N n("opera")},{name:"Firefox",versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).* /],search:Nn("firefox")},{name:"Safari",versionRegexes:[Fn,/.*?cpu os ([0-9]+)_( [0-9]+).*/],search:function(n){return(In.contains(n,"safari")||In.contains(n,"mo bile/"))&&In.contains(n,"applewebkit")}}],Hn=[{name:"Windows",search:Nn("win"),v ersionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]},{name:"iOS",search:func tion(n){return In.contains(n,"iphone")||In.contains(n,"ipad")},versionRegexes:[/ .*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cpu iphon e os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:Nn("android"),versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:Nn("os x"),versionRege xes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:Nn("linux"),version Regexes:[]},{name:"Solaris",search:Nn("sunos"),versionRegexes:[]},{name:"FreeBSD ",search:Nn("freebsd"),versionRegexes:[]}],jn={browsers:O.constant(Vn),oses:O.co nstant(Hn)},zn=function(n){var e,t,o,r,i,u,a,c,s,f,l,d=jn.browsers(),m=jn.oses() ,g=Tn(d,n).fold(Q.unknown,Q.nu),p=Sn(m,n).fold(un.unknown,un.nu);return{browser: g,os:p,deviceType:(t=g,o=n,r=(e=p).isiOS()&&!0===/ipad/i.test(o),i=e.isiOS()&&!r ,u=e.isAndroid()&&3===e.version.major,a=e.isAndroid()&&4===e.version.major,c=r|| u||a&&!0===/mobile/i.test(o),s=e.isiOS()||e.isAndroid(),f=s&&!c,l=t.isSafari()&& e.isiOS()&&!1===/safari/i.test(o),{isiPad:O.constant(r),isiPhone:O.constant(i),i sTablet:O.constant(c),isPhone:O.constant(f),isTouch:O.constant(s),isAndroid:e.is Android,isiOS:e.isiOS,isWebView:O.constant(l)})}},Ln={detect:G(function(){var n= navigator.userAgent;return zn(n)})},Pn={tap:O.constant("alloy.tap")},Wn=O.consta nt("alloy.focus"),Un=O.constant("alloy.blur.post"),Gn=O.constant("alloy.receive" ),$n=O.constant("alloy.execute"),qn=O.constant("alloy.focus.item"),_n=Pn.tap,Kn= Ln.detect().deviceType.isTouch()?Pn.tap:P,Xn=O.constant("alloy.longpress"),Yn=(O .constant("alloy.sandbox.close"),O.constant("alloy.system.init")),Jn=O.constant( "alloy.system.scroll"),Qn=O.constant("alloy.system.attached"),Zn=O.constant("all oy.system.detached"),ne=(O.constant("alloy.change.tab"),O.constant("alloy.dismis s.tab"),function(n,e){re(n,n.element(),e,{})}),ee=function(n,e,t){re(n,n.element (),e,t)},te=function(n){ne(n,$n())},oe=function(n,e,t){re(n,e,t,{})},re=function (n,e,t,o){var r=D.deepMerge({target:e},o);n.getSystem().triggerEvent(t,e,M.map(r ,O.constant))},ie=function(n){if(null===n||n===undefined)throw new Error("Node c annot be null or undefined");return{dom:O.constant(n)}},ue={fromHtml:function(n, e){var t=(e||document).createElement("div");if(t.innerHTML=n,!t.hasChildNodes()| |1<t.childNodes.length)throw console.error("HTML does not have a single root nod e",n),"HTML must have a single root node";return ie(t.childNodes[0])},fromTag:fu nction(n,e){var t=(e||document).createElement(n);return ie(t)},fromText:function (n,e){var t=(e||document).createTextNode(n);return ie(t)},fromDom:ie,fromPoint:f unction(n,e,t){return x.from(n.dom().elementFromPoint(e,t)).map(ie)}},ae=8,ce=9, se=1,fe=3,le=function(n){return n.dom().nodeName.toLowerCase()},de=function(n){r eturn n.dom().nodeType},me=function(e){return function(n){return de(n)===e}},ge= me(se),pe=me(fe),he=me(ce),ve={name:le,type:de,value:function(n){return n.dom(). nodeValue},isElement:ge,isText:pe,isDocument:he,isComment:function(n){return de( n)===ae||"#comment"===le(n)}},ye=G(function(){return be(ue.fromDom(document))}), be=function(n){var e=n.dom().body;if(null===e||e===undefined)throw"Body is not a vailable yet";return ue.fromDom(e)},we={body:ye,getBody:be,inBody:function(n){va r e=ve.isText(n)?n.dom().parentNode:n.dom();return e!==undefined&&null!==e&&e.ow nerDocument.body.contains(e)}},xe=function(n){return n.slice(0).sort()},Te=funct ion(n,e){throw new Error("All required keys ("+xe(n).join(", ")+") were not spec ified. Specified keys were: "+xe(e).join(", ")+".")},Se=function(n){throw new Er ror("Unsupported keys for object: "+xe(n).join(", "))},ke=function(e,n){if(!E.is Array(n))throw new Error("The "+e+" fields must be an array. Was: "+n+".");wn.ea ch(n,function(n){if(!E.isString(n))throw new Error("The value "+n+" in the "+e+" fields was not a string.")})},Ce=function(n,e){throw new Error("All values need to be of type: "+e+". Keys ("+xe(n).join(", ")+") were not.")},Oe=function(n){v ar t=xe(n);wn.find(t,function(n,e){return e<t.length-1&&n===t[e+1]}).each(functi on(n){throw new Error("The field: "+n+" occurs more than once in the combined fi elds: ["+t.join(", ")+"].")})},Ee={immutable:function(){for(var e=[],n=0;n<argum ents.length;n++)e[n]=arguments[n];return function(){for(var t=[],n=0;n<arguments .length;n++)t[n]=arguments[n];if(e.length!==t.length)throw new Error('Wrong numb er of arguments to struct. Expected "['+e.length+']", got '+t.length+" arguments ");var o={};return wn.each(e,function(n,e){o[n]=O.constant(t[e])}),o}},immutable Bag:function(r,i){var u=r.concat(i);if(0===u.length)throw new Error("You must sp ecify at least one required or optional field.");return ke("required",r),ke("opt ional",i),Oe(u),function(e){var t=M.keys(e);wn.forall(r,function(n){return wn.co ntains(t,n)})||Te(r,t);var n=wn.filter(t,function(n){return!wn.contains(u,n)});0 <n.length&&Se(n);var o={};return wn.each(r,function(n){o[n]=O.constant(e[n])}),w n.each(i,function(n){o[n]=O.constant(Object.prototype.hasOwnProperty.call(e,n)?x .some(e[n]):x.none())}),o}}},De=function(n,e){for(var t=[],o=function(n){return t.push(n),e(n)},r=e(n);(r=r.bind(o)).isSome(););return t},Ae="undefined"!=typeof window?window:Function("return this;")(),Me=function(n,e){for(var t=e!==undefin ed&&null!==e?e:Ae,o=0;o<n.length&&t!==undefined&&null!==t;++o)t=t[n[o]];return t },Be=function(n,e){var t=n.split(".");return Me(t,e)},Re={getOrDie:function(n,e) {var t=Be(n,e);if(t===undefined||null===t)throw n+" not available on this browse r";return t}},Ie=se,Fe=ce,Ne=function(n){return n.nodeType!==Ie&&n.nodeType!==Fe ||0===n.childElementCount},Ve={all:function(n,e){var t=e===undefined?document:e. dom();return Ne(t)?[]:wn.map(t.querySelectorAll(n),ue.fromDom)},is:function(n,e) {var t=n.dom();if(t.nodeType!==Ie)return!1;if(t.matches!==undefined)return t.mat ches(e);if(t.msMatchesSelector!==undefined)return t.msMatchesSelector(e);if(t.we bkitMatchesSelector!==undefined)return t.webkitMatchesSelector(e);if(t.mozMatche sSelector!==undefined)return t.mozMatchesSelector(e);throw new Error("Browser la cks native selectors")},one:function(n,e){var t=e===undefined?document:e.dom();r eturn Ne(t)?x.none():x.from(t.querySelector(n)).map(ue.fromDom)}},He=function(n, e){return n.dom()===e.dom()},je=(Ln.detect().browser.isIE(),He),ze=function(n){r eturn ue.fromDom(n.dom().ownerDocument)},Le=function(n){var e=n.dom();return x.f rom(e.parentNode).map(ue.fromDom)},Pe=function(n){var e=n.dom();return x.from(e. previousSibling).map(ue.fromDom)},We=function(n){var e=n.dom();return x.from(e.n extSibling).map(ue.fromDom)},Ue=function(n){var e=n.dom();return wn.map(e.childN odes,ue.fromDom)},Ge=function(n,e){var t=n.dom().childNodes;return x.from(t[e]). map(ue.fromDom)},$e=Ee.immutable("element","offset"),qe={owner:ze,defaultView:fu nction(n){var e=n.dom().ownerDocument.defaultView;return ue.fromDom(e)},document Element:function(n){var e=ze(n);return ue.fromDom(e.dom().documentElement)},pare nt:Le,findIndex:function(t){return Le(t).bind(function(n){var e=Ue(n);return wn. findIndex(e,function(n){return je(t,n)})})},parents:function(n,e){for(var t=E.is Function(e)?e:O.constant(!1),o=n.dom(),r=[];null!==o.parentNode&&o.parentNode!== undefined;){var i=o.parentNode,u=ue.fromDom(i);if(r.push(u),!0===t(u))break;o=i} return r},siblings:function(e){return Le(e).map(Ue).map(function(n){return wn.fi lter(n,function(n){return!je(e,n)})}).getOr([])},prevSibling:Pe,offsetParent:fun ction(n){var e=n.dom();return x.from(e.offsetParent).map(ue.fromDom)},prevSiblin gs:function(n){return wn.reverse(De(n,Pe))},nextSibling:We,nextSiblings:function (n){return De(n,We)},children:Ue,child:Ge,firstChild:function(n){return Ge(n,0)} ,lastChild:function(n){return Ge(n,n.dom().childNodes.length-1)},childNodesCount :function(n){return n.dom().childNodes.length},hasChildNodes:function(n){return n.dom().hasChildNodes()},leaf:function(n,e){var t=Ue(n);return 0<t.length&&e<t.l ength?$e(t[e],0):$e(n,e)}},_e=function(e,t){qe.parent(e).each(function(n){n.dom( ).insertBefore(t.dom(),e.dom())})},Ke=function(n,e){n.dom().appendChild(e.dom()) },Xe={before:_e,after:function(n,e){qe.nextSibling(n).fold(function(){qe.parent( n).each(function(n){Ke(n,e)})},function(n){_e(n,e)})},prepend:function(e,t){qe.f irstChild(e).fold(function(){Ke(e,t)},function(n){e.dom().insertBefore(t.dom(),n .dom())})},append:Ke,appendAt:function(n,e,t){qe.child(n,t).fold(function(){Ke(n ,e)},function(n){_e(n,e)})},wrap:function(n,e){_e(n,e),Ke(e,n)}},Ye=function(e,n ){wn.each(n,function(n){Xe.before(e,n)})},Je=function(e,n){wn.each(n,function(n) {Xe.append(e,n)})},Qe=function(n){var e=n.dom();null!==e.parentNode&&e.parentNod e.removeChild(e)},Ze={empty:function(n){n.dom().textContent="",wn.each(qe.childr en(n),function(n){Qe(n)})},remove:Qe,unwrap:function(n){var e=qe.children(n);0<e .length&&Ye(n,e),Qe(n)}},nt=function(n){ne(n,Zn());var e=n.components();wn.each( e,nt)},et=function(n){var e=n.components();wn.each(e,et),ne(n,Qn())},tt=function (n,e){ot(n,e,Xe.append)},ot=function(n,e,t){n.getSystem().addToWorld(e),t(n.elem ent(),e.element()),we.inBody(n.element())&&et(e),n.syncComponents()},rt=function (n){nt(n),Ze.remove(n.element()),n.getSystem().removeFromWorld(n)},it=function(e ){var n=qe.parent(e.element()).bind(function(n){return e.getSystem().getByDom(n) .fold(x.none,x.some)});rt(e),n.each(function(n){n.syncComponents()})},ut=functio n(t){return{is:function(n){return t===n},isValue:O.always,isError:O.never,getOr: O.constant(t),getOrThunk:O.constant(t),getOrDie:O.constant(t),or:function(n){ret urn ut(t)},orThunk:function(n){return ut(t)},fold:function(n,e){return e(t)},map :function(n){return ut(n(t))},each:function(n){n(t)},bind:function(n){return n(t )},exists:function(n){return n(t)},forall:function(n){return n(t)},toOption:func tion(){return x.some(t)}}},at=function(t){return{is:O.never,isValue:O.never,isEr ror:O.always,getOr:O.identity,getOrThunk:function(n){return n()},getOrDie:functi on(){return O.die(String(t))()},or:function(n){return n},orThunk:function(n){ret urn n()},fold:function(n,e){return n(t)},map:function(n){return at(t)},each:O.no op,bind:function(n){return at(t)},exists:O.never,forall:O.always,toOption:x.none }},ct={value:ut,error:at},st=function(u){if(!E.isArray(u))throw new Error("cases must be an array");if(0===u.length)throw new Error("there must be at least one case");var a=[],t={};return wn.each(u,function(n,o){var e=M.keys(n);if(1!==e.len gth)throw new Error("one and only one name per case");var r=e[0],i=n[r];if(t[r]! ==undefined)throw new Error("duplicate key detected:"+r);if("cata"===r)throw new Error("cannot have a case named cata (sorry)");if(!E.isArray(i))throw new Error ("case arguments must be an array");a.push(r),t[r]=function(){var n=arguments.le ngth;if(n!==i.length)throw new Error("Wrong number of arguments to case "+r+". E xpected "+i.length+" ("+i+"), got "+n);for(var t=new Array(n),e=0;e<t.length;e++ )t[e]=arguments[e];return{fold:function(){if(arguments.length!==u.length)throw n ew Error("Wrong number of arguments to fold. Expected "+u.length+", got "+argume nts.length);return arguments[o].apply(null,t)},match:function(n){var e=M.keys(n) ;if(a.length!==e.length)throw new Error("Wrong number of arguments to match. Exp ected: "+a.join(",")+"\nActual: "+e.join(","));if(!wn.forall(a,function(n){retur n wn.contains(e,n)}))throw new Error("Not all branches were specified when using match. Specified: "+e.join(", ")+"\nRequired: "+a.join(", "));return n[r].apply (null,t)},log:function(n){console.log(n,{constructors:a,constructor:r,params:t}) }}}}),t},ft=st([{strict:[]},{defaultedThunk:["fallbackThunk"]},{asOption:[]},{as DefaultedOptionThunk:["fallbackThunk"]},{mergeWithThunk:["baseThunk"]}]),lt=func tion(n){return ft.defaultedThunk(O.constant(n))},dt=ft.strict,mt=ft.asOption,gt= ft.defaultedThunk,pt=(ft.asDefaultedOptionThunk,ft.mergeWithThunk),ht=(st([{both Errors:["error1","error2"]},{firstError:["error1","value2"]},{secondError:["valu e1","error2"]},{bothValues:["value1","value2"]}]),function(n){var e=[],t=[];retu rn wn.each(n,function(n){n.fold(function(n){e.push(n)},function(n){t.push(n)})}) ,{errors:e,values:t}}),vt=function(n){return O.compose(ct.error,wn.flatten)(n)}, yt=function(n,e){var t,o,r=ht(n);return 0<r.errors.length?vt(r.errors):(t=r.valu es,o=e,ct.value(D.deepMerge.apply(undefined,[o].concat(t))))},bt=function(n){var e=ht(n);return 0<e.errors.length?vt(e.errors):ct.value(e.values)},wt=function(e ){return function(n){return n.hasOwnProperty(e)?x.from(n[e]):x.none()}},xt=funct ion(n,e){return wt(e)(n)},Tt=function(n,e){var t={};return t[n]=e,t},St=function (n,e){return t=n,o=e,r={},wn.each(o,function(n){t[n]!==undefined&&t.hasOwnProper ty(n)&&(r[n]=t[n])}),r;var t,o,r},kt=function(n,e){return t=n,o=e,r={},M.each(t, function(n,e){wn.contains(o,e)||(r[e]=n)}),r;var t,o,r},Ct=function(n){return wt (n)},Ot=function(n,e){return t=n,o=e,function(n){return wt(t)(n).getOr(o)};var t ,o},Et=function(n,e){return xt(n,e)},Dt=function(n,e){return Tt(n,e)},At=functio n(n){return e=n,t={},wn.each(e,function(n){t[n.key]=n.value}),t;var e,t},Mt=func tion(n,e){return yt(n,e)},Bt=function(n,e){return o=e,(t=n).hasOwnProperty(o)&&t [o]!==undefined&&null!==t[o];var t,o},Rt=st([{setOf:["validator","valueType"]},{ arrOf:["valueType"]},{objOf:["fields"]},{itemOf:["validator"]},{choiceOf:["key", "branches"]},{thunk:["description"]},{func:["args","outputSchema"]}]),It=st([{fi eld:["name","presence","type"]},{state:["name"]}]),Ft=function(){return Re.getOr Die("JSON")},Nt=function(n,e,t){return Ft().stringify(n,e,t)},Vt=function(n){ret urn E.isObject(n)&&100<M.keys(n).length?" removed due to size":Nt(n,null,2)},Ht= function(n,e){return ct.error([{path:n,getErrorInfo:e}])},jt=st([{field:["key"," okey","presence","prop"]},{state:["okey","instantiator"]}]),zt=function(t,o,r){r eturn xt(o,r).fold(function(){return n=r,e=o,Ht(t,function(){return'Could not fi nd valid *strict* value for "'+n+'" in '+Vt(e)});var n,e},ct.value)},Lt=function (n,e,t){var o=xt(n,e).fold(function(){return t(n)},O.identity);return ct.value(o )},Pt=function(r,a,n,c){return n.fold(function(i,e,n,t){var o=function(n){return t.extract(r.concat([i]),c,n).map(function(n){return Tt(e,c(n))})},u=function(n) {return n.fold(function(){var n=Tt(e,c(x.none()));return ct.value(n)},function(n ){return t.extract(r.concat([i]),c,n).map(function(n){return Tt(e,c(x.some(n)))} )})};return n.fold(function(){return zt(r,a,i).bind(o)},function(n){return Lt(a, i,n).bind(o)},function(){return(n=a,e=i,ct.value(xt(n,e))).bind(u);var n,e},func tion(n){return(e=a,t=i,o=n,r=xt(e,t).map(function(n){return!0===n?o(e):n}),ct.va lue(r)).bind(u);var e,t,o,r},function(n){var e=n(a);return Lt(a,i,O.constant({}) ).map(function(n){return D.deepMerge(e,n)}).bind(o)})},function(n,e){var t=e(a); return ct.value(Tt(n,c(t)))})},Wt=function(o){return{extract:function(t,n,e){ret urn o(e,n).fold(function(n){return e=n,Ht(t,function(){return e});var e},ct.valu e)},toString:function(){return"val"},toDsl:function(){return Rt.itemOf(o)}}},Ut= function(n){var c=Gt(n),s=wn.foldr(n,function(e,n){return n.fold(function(n){ret urn D.deepMerge(e,Dt(n,!0))},O.constant(e))},{});return{extract:function(n,e,t){ var o,r,i,u=E.isBoolean(t)?[]:(o=t,r=M.keys(o),wn.filter(r,function(n){return Bt (o,n)})),a=wn.filter(u,function(n){return!Bt(s,n)});return 0===a.length?c.extrac t(n,e,t):(i=a,Ht(n,function(){return"There are unsupported fields: ["+i.join(", ")+"] specified"}))},toString:c.toString,toDsl:c.toDsl}},Gt=function(c){return{e xtract:function(n,e,t){return o=n,r=t,i=c,u=e,a=wn.map(i,function(n){return Pt(o ,r,n,u)}),yt(a,{});var o,r,i,u,a},toString:function(){return"obj{\n"+wn.map(c,fu nction(n){return n.fold(function(n,e,t,o){return n+" -> "+o.toString()},function (n,e){return"state("+n+")"})}).join("\n")+"}"},toDsl:function(){return Rt.objOf( wn.map(c,function(n){return n.fold(function(n,e,t,o){return It.field(n,t,o)},fun ction(n,e){return It.state(n)})}))}}},$t=function(r){return{extract:function(t,o ,n){var e=wn.map(n,function(n,e){return r.extract(t.concat(["["+e+"]"]),o,n)});r eturn bt(e)},toString:function(){return"array("+r.toString()+")"},toDsl:function (){return Rt.arrOf(r)}}},qt=function(u,a){return{extract:function(t,o,r){var n,e ,i=M.keys(r);return(n=t,e=i,$t(Wt(u)).extract(n,O.identity,e)).bind(function(n){ var e=wn.map(n,function(n){return jt.field(n,n,dt(),a)});return Gt(e).extract(t, o,r)})},toString:function(){return"setOf("+a.toString()+")"},toDsl:function(){re turn Rt.setOf(u,a)}}},_t=O.constant(Wt(ct.value)),Kt=(O.compose($t,Gt),jt.state) ,Xt=jt.field,Yt=function(t,e,o,r,i){return Et(r,i).fold(function(){return n=r,e= i,Ht(t,function(){return'The chosen schema: "'+e+'" did not exist in branches: ' +Vt(n)});var n,e},function(n){return Gt(n).extract(t.concat(["branch: "+i]),e,o) })},Jt=function(r,i){return{extract:function(e,t,o){return Et(o,r).fold(function (){return n=r,Ht(e,function(){return'Choice schema did not contain choice key: " '+n+'"'});var n},function(n){return Yt(e,t,o,i,n)})},toString:function(){return" chooseOn("+r+"). Possible values: "+M.keys(i)},toDsl:function(){return Rt.choice Of(r,i)}}},Qt=Wt(ct.value),Zt=function(n,e,t,o){return e.extract([n],t,o).fold(f unction(n){return ct.error({input:o,errors:n})},ct.value)},no=function(n,e,t){re turn Zt(n,e,O.constant,t)},eo=function(n){return n.fold(function(n){throw new Er ror(ro(n))},O.identity)},to=function(n,e,t){return eo((o=t,Zt(n,e,O.identity,o)) );var o},oo=function(n,e,t){return eo(no(n,e,t))},ro=function(n){return"Errors: \n"+(e=n.errors,t=10<e.length?e.slice(0,10).concat([{path:[],getErrorInfo:functi on(){return"... (only showing first ten failures)"}}]):e,wn.map(t,function(n){re turn"Failed path: ("+n.path.join(" > ")+")\n"+n.getErrorInfo()}))+"\n\nInput obj ect: "+Vt(n.input);var e,t},io=function(n,e){return Jt(n,e)},uo=O.constant(Qt),a o=(u=E.isFunction,a="function",Wt(function(n){var e=typeof n;return u(n)?ct.valu e(n):ct.error("Expected type: "+a+" but got: "+e)})),co=function(n){return Xt(n, n,dt(),_t())},so=function(n,e){return Xt(n,n,dt(),e)},fo=function(n){return so(n ,ao)},lo=function(n,e){return Xt(n,n,dt(),Gt(e))},mo=function(n){return Xt(n,n,m t(),_t())},go=function(n,e){return Xt(n,n,mt(),Gt(e))},po=function(n,e){return X t(n,n,mt(),Ut(e))},ho=function(n,e){return Xt(n,n,lt(e),_t())},vo=function(n,e,t ){return Xt(n,n,lt(e),t)},yo=function(n,e){return Kt(n,e)},bo=function(n){if(!Bt (n,"can")&&!Bt(n,"abort")&&!Bt(n,"run"))throw new Error("EventHandler defined by : "+Nt(n,null,2)+" does not have can, abort, or run!");return to("Extracting eve nt.handler",Ut([ho("can",O.constant(!0)),ho("abort",O.constant(!1)),ho("run",O.n oop)]),n)},wo=function(n){var e,o,r,i,t=(e=n,o=function(n){return n.can},functio n(){var t=Array.prototype.slice.call(arguments,0);return wn.foldl(e,function(n,e ){return n&&o(e).apply(undefined,t)},!0)}),u=(r=n,i=function(n){return n.abort}, function(){var t=Array.prototype.slice.call(arguments,0);return wn.foldl(r,funct ion(n,e){return n||i(e).apply(undefined,t)},!1)});return bo({can:t,abort:u,run:f unction(){var e=Array.prototype.slice.call(arguments,0);wn.each(n,function(n){n. run.apply(undefined,e)})}})},xo=At,To=function(n,e){return{key:n,value:bo({abort :e})}},So=function(n,e){return{key:n,value:bo({run:e})}},ko=function(n,e,t){retu rn{key:n,value:bo({run:function(n){e.apply(undefined,[n].concat(t))}})}},Co=func tion(n){return function(o){return{key:n,value:bo({run:function(n,e){var t;t=e,je (n.element(),t.event().target())&&o(n,e)}})}}},Oo=function(n,e,t){var u,o,r=e.pa rtUids()[t];return o=r,So(u=n,function(n,i){n.getSystem().getByUid(o).each(funct ion(n){var e,t,o,r;t=(e=n).element(),o=u,r=i,e.getSystem().triggerEvent(o,t,r.ev ent())})})},Eo=function(n){return So(n,function(n,e){e.cut()})},Do=Co(Qn()),Ao=C o(Zn()),Mo=Co(Yn()),Bo=(c=$n(),function(n){return So(c,n)}),Ro=function(n){retur n wn.map(n,function(n){return In.endsWith(n,"/*")?n.substring(0,n.length-"/*".le ngth):n})},Io=function(n,e){var t=n.toString(),o=t.indexOf(")")+1,r=t.indexOf("( "),i=t.substring(r+1,o-1).split(/,\s*/);return n.toFunctionAnnotation=function() {return{name:e,parameters:Ro(i)}},n},Fo=Ee.immutableBag(["tag"],["classes","attr ibutes","styles","value","innerHtml","domChildren","defChildren"]),No=function(n ){return{tag:n.tag(),classes:n.classes().getOr([]),attributes:n.attributes().get Or({}),styles:n.styles().getOr({}),value:n.value().getOr("<none>"),innerHtml:n.i nnerHtml().getOr("<none>"),defChildren:n.defChildren().getOr("<none>"),domChildr en:n.domChildren().fold(function(){return"<none>"},function(n){return 0===n.leng th?"0 children, but still specified":String(n.length)})}},Vo=Ee.immutableBag([], ["classes","attributes","styles","value","innerHtml","defChildren","domChildren" ]),Ho=function(e,n,t){return n.fold(function(){return t.fold(function(){return{} },function(n){return Dt(e,n)})},function(n){return t.fold(function(){return Dt(e ,n)},function(n){return Dt(e,n)})})},jo=function(t,o,r){return Mo(function(n,e){ r(n,t,o)})},zo=function(n,e,t,o,r,i){var u,a,c=n,s=go(e,[(u="config",a=n,Xt(u,u, mt(),a))]);return Wo(c,s,e,t,o,r,i)},Lo=function(n,r,e){var t,o,i,u,a,c;return t =function(t){var o=arguments;return t.config({name:O.constant(n)}).fold(function (){throw new Error("We could not find any behaviour configuration for: "+n+". Us ing API: "+e)},function(n){var e=Array.prototype.slice.call(o,1);return r.apply( undefined,[t,n.config,n.state].concat(e))})},o=e,i=r.toString(),u=i.indexOf(")") +1,a=i.indexOf("("),c=i.substring(a+1,u-1).split(/,\s*/),t.toFunctionAnnotation= function(){return{name:o,parameters:Ro(c.slice(0,1).concat(c.slice(3)))}},t},Po= function(n){return{key:n,value:undefined}},Wo=function(t,n,o,r,e,i,u){var a=func tion(n){return Bt(n,o)?n[o]():x.none()},c=M.map(e,function(n,e){return Lo(o,n,e) }),s=M.map(i,function(n,e){return Io(n,e)}),f=D.deepMerge(s,c,{revoke:O.curry(Po ,o),config:function(n){var e=oo(o+"-config",t,n);return{key:o,value:{config:e,me :f,configAsRaw:G(function(){return to(o+"-config",t,n)}),initialConfig:n,state:u }}},schema:function(){return n},exhibit:function(n,t){return a(n).bind(function( e){return Et(r,"exhibit").map(function(n){return n(t,e.config,e.state)})}).getOr (Vo({}))},name:function(){return o},handlers:function(n){return a(n).bind(functi on(e){return Et(r,"events").map(function(n){return n(e.config,e.state)})}).getOr ({})}});return f},Uo=function(n,e){return Go(n,e,{validate:E.isFunction,label:"f unction"})},Go=function(o,r,i){if(0===r.length)throw new Error("You must specify at least one required field.");return ke("required",r),Oe(r),function(e){var t= M.keys(e);wn.forall(r,function(n){return wn.contains(t,n)})||Te(r,t),o(r,t);var n=wn.filter(r,function(n){return!i.validate(e[n],n)});return 0<n.length&&Ce(n,i. label),e}},$o=O.noop,qo={exactly:O.curry(Uo,function(e,n){var t=wn.filter(n,func tion(n){return!wn.contains(e,n)});0<t.length&&Se(t)}),ensure:O.curry(Uo,$o),ensu reWith:O.curry(Go,$o)},_o=qo.ensure(["readState"]),Ko=function(){return _o({read State:function(){return"No State required"}})},Xo=Object.freeze({init:Ko}),Yo=fu nction(n){return At(n)},Jo=Ut([co("fields"),co("name"),ho("active",{}),ho("apis" ,{}),ho("extra",{}),ho("state",Xo)]),Qo=function(n){var e,t,o,r,i,u,a,c,s=to("Cr eating behaviour: "+n.name,Jo,n);return e=s.fields,t=s.name,o=s.active,r=s.apis, i=s.extra,u=s.state,a=Ut(e),c=go(t,[po("config",e)]),Wo(a,c,t,o,r,i,u)},Zo=Ut([c o("branchKey"),co("branches"),co("name"),ho("active",{}),ho("apis",{}),ho("extra ",{}),ho("state",Xo)]),nr=O.constant(undefined),er=(O.constant({}),O.constant({} ),O.constant({}),O.constant(Xo));function tr(n,e,t){var o=t||!1,r=function(){e() ,o=!0},i=function(){n(),o=!1};return{on:r,off:i,toggle:function(){(o?i:r)()},isO n:function(){return o}}}var or=function(n,e,t){if(!(E.isString(t)||E.isBoolean(t )||E.isNumber(t)))throw console.error("Invalid call to Attr.set. Key ",e,":: Val ue ",t,":: Element ",n),new Error("Attribute value was not simple");n.setAttribu te(e,t+"")},rr=function(n,e,t){or(n.dom(),e,t)},ir=function(n,e){var t=n.dom().g etAttribute(e);return null===t?undefined:t},ur=function(n,e){var t=n.dom();retur n!(!t||!t.hasAttribute)&&t.hasAttribute(e)},ar={clone:function(n){return wn.fold l(n.dom().attributes,function(n,e){return n[e.name]=e.value,n},{})},set:rr,setAl l:function(n,e){var t=n.dom();M.each(e,function(n,e){or(t,e,n)})},get:ir,has:ur, remove:function(n,e){n.dom().removeAttribute(e)},hasNone:function(n){var e=n.dom ().attributes;return e===undefined||null===e||0===e.length},transfer:function(r, i,n){ve.isElement(r)&&ve.isElement(i)&&wn.each(n,function(n){var e,t,o;t=i,ur(e= r,o=n)&&!ur(t,o)&&rr(t,o,ir(e,o))})}},cr=function(n,e){var t=ar.get(n,e);return t===undefined||""===t?[]:t.split(" ")},sr=cr,fr=function(n,e,t){var o=cr(n,e).co ncat([t]);ar.set(n,e,o.join(" "))},lr=function(n,e,t){var o=wn.filter(cr(n,e),fu nction(n){return n!==t});0<o.length?ar.set(n,e,o.join(" ")):ar.remove(n,e)},dr=f unction(n){return sr(n,"class")},mr=function(n,e){return fr(n,"class",e)},gr=fun ction(n,e){return lr(n,"class",e)},pr=dr,hr=mr,vr=gr,yr=function(n,e){wn.contain s(dr(n),e)?gr(n,e):mr(n,e)},br=function(n){return n.dom().classList!==undefined} ,wr=function(n,e){return br(n)&&n.dom().classList.contains(e)},xr={add:function( n,e){br(n)?n.dom().classList.add(e):hr(n,e)},remove:function(n,e){var t;br(n)?n. dom().classList.remove(e):vr(n,e),0===(br(t=n)?t.dom().classList:pr(t)).length&& ar.remove(t,"class")},toggle:function(n,e){return br(n)?n.dom().classList.toggle (e):yr(n,e)},toggler:function(n,e){var t=br(n),o=n.dom().classList;return tr(fun ction(){t?o.remove(e):vr(n,e)},function(){t?o.add(e):hr(n,e)},wr(n,e))},has:wr}, Tr=function(n,e,t){xr.remove(n,t),xr.add(n,e)},Sr=Object.freeze({toAlpha:functio n(n,e,t){Tr(n.element(),e.alpha(),e.omega())},toOmega:function(n,e,t){Tr(n.eleme nt(),e.omega(),e.alpha())},isAlpha:function(n,e,t){return xr.has(n.element(),e.a lpha())},isOmega:function(n,e,t){return xr.has(n.element(),e.omega())},clear:fun ction(n,e,t){xr.remove(n.element(),e.alpha()),xr.remove(n.element(),e.omega())}} ),kr=[co("alpha"),co("omega")],Cr=Qo({fields:kr,name:"swapping",apis:Sr}),Or=fun ction(n){var e=n,t=function(){return e};return{get:t,set:function(n){e=n},clone: function(){return Or(t())}}};function Er(n,e,t,o,r){return n(t,o)?x.some(t):E.is Function(r)&&r(t)?x.none():e(t,o,r)}var Dr=function(n,e,t){for(var o=n.dom(),r=E .isFunction(t)?t:O.constant(!1);o.parentNode;){o=o.parentNode;var i=ue.fromDom(o );if(e(i))return x.some(i);if(r(i))break}return x.none()},Ar=function(n,e){retur n wn.find(n.dom().childNodes,O.compose(e,ue.fromDom)).map(ue.fromDom)},Mr=functi on(n,o){var r=function(n){for(var e=0;e<n.childNodes.length;e++){if(o(ue.fromDom (n.childNodes[e])))return x.some(ue.fromDom(n.childNodes[e]));var t=r(n.childNod es[e]);if(t.isSome())return t}return x.none()};return r(n.dom())},Br={first:func tion(n){return Mr(we.body(),n)},ancestor:Dr,closest:function(n,e,t){return Er(fu nction(n){return e(n)},Dr,n,e,t)},sibling:function(e,t){var n=e.dom();return n.p arentNode?Ar(ue.fromDom(n.parentNode),function(n){return!je(e,n)&&t(n)}):x.none( )},child:Ar,descendant:Mr},Rr=function(n){n.dom().focus()},Ir=function(n){var e= n!==undefined?n.dom():document;return x.from(e.activeElement).map(ue.fromDom)},F r=function(n){var e=qe.owner(n).dom();return n.dom()===e.activeElement},Nr=Rr,Vr =function(n){n.dom().blur()},Hr=Ir,jr=function(e){return Ir(qe.owner(e)).filter( function(n){return e.dom().contains(n.dom())})},zr=tinymce.util.Tools.resolve("t inymce.dom.DOMUtils"),Lr=tinymce.util.Tools.resolve("tinymce.ThemeManager"),Pr=f unction(n){var e=document.createElement("a");e.target="_blank",e.href=n.href,e.r el="noreferrer noopener";var t=document.createEvent("MouseEvents");t.initMouseEv ent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),document.body.appendChild (e),e.dispatchEvent(t),document.body.removeChild(e)},Wr={formatChanged:O.constan t("formatChanged"),orientationChanged:O.constant("orientationChanged"),dropupDis missed:O.constant("dropupDismissed")},Ur=function(n,e){var t=(e||document).creat eElement("div");return t.innerHTML=n,qe.children(ue.fromDom(t))},Gr=function(n){ return n.dom().innerHTML},$r=Gr,qr=function(n,e){var t=qe.owner(n).dom(),o=ue.fr omDom(t.createDocumentFragment()),r=Ur(e,t);Je(o,r),Ze.empty(n),Xe.append(n,o)}, _r=function(n){var e=ue.fromTag("div"),t=ue.fromDom(n.dom().cloneNode(!0));retur n Xe.append(e,t),Gr(e)},Kr=function(n,e){return ue.fromDom(n.dom().cloneNode(e)) },Xr=function(n){return Kr(n,!1)},Yr=function(n){return e=Xr(n),_r(e);var e},Jr= Object.freeze({events:function(a){return xo([So(Gn(),function(r,i){var n,e,u=a.c hannels(),t=M.keys(u),o=(n=t,(e=i).universal()?n:wn.filter(n,function(n){return wn.contains(e.channels(),n)}));wn.each(o,function(n){var e=u[n](),t=e.schema(),o =oo("channel["+n+"] data\nReceiver: "+Yr(r.element()),t,i.data());e.onReceive()( r,o)})})])}}),Qr=function(n){for(var e=[],t=function(n){e.push(n)},o=0;o<n.lengt h;o++)n[o].each(t);return e},Zr=function(n,e){for(var t=0;t<n.length;t++){var o= e(n[t],t);if(o.isSome())return o}return x.none()},ni="unknown",ei=[],ti=["alloy/ data/Fields","alloy/debugging/Debugging"],oi={logEventCut:O.noop,logEventStopped :O.noop,logNoParent:O.noop,logEventNoHandlers:O.noop,logEventResponse:O.noop,wri te:O.noop},ri=function(n,e,t){var o,r="*"===ei||wn.contains(ei,n)?(o=[],{logEven tCut:function(n,e,t){o.push({outcome:"cut",target:e,purpose:t})},logEventStopped :function(n,e,t){o.push({outcome:"stopped",target:e,purpose:t})},logNoParent:fun ction(n,e,t){o.push({outcome:"no-parent",target:e,purpose:t})},logEventNoHandler s:function(n,e){o.push({outcome:"no-handlers-left",target:e})},logEventResponse: function(n,e,t){o.push({outcome:"response",purpose:t,target:e})},write:function( ){wn.contains(["mousemove","mouseover","mouseout",Yn()],n)||console.log(n,{event :n,target:e.dom(),sequence:wn.map(o,function(n){return wn.contains(["cut","stopp ed","response"],n.outcome)?"{"+n.purpose+"} "+n.outcome+" at ("+Yr(n.target)+")" :n.outcome})})}}):oi,i=t(r);return r.write(),i},ii=(O.constant(oi),O.constant(!0 ),O.constant([co("menu"),co("selectedMenu")])),ui=O.constant([co("item"),co("sel ectedItem")]),ai=(O.constant(Ut(ui().concat(ii()))),O.constant(Ut(ui()))),ci=lo( "initSize",[co("numColumns"),co("numRows")]),si=function(n,e,t){var o;return fun ction(){var n=new Error;if(n.stack!==undefined){var e=n.stack.split("\n");wn.fin d(e,function(e){return 0<e.indexOf("alloy")&&!wn.exists(ti,function(n){return-1< e.indexOf(n)})}).getOr(ni)}}(),Xt(e,e,t,(o=function(n){return ct.value(function( ){return n.apply(undefined,arguments)})},Wt(function(n){return o(n)})))},fi=func tion(n){return si(0,n,lt(O.noop))},li=function(n){return si(0,n,lt(x.none))},di= function(n){return si(0,n,dt())},mi=function(n){return si(0,n,dt())},gi=function (n,e){return yo(n,O.constant(e))},pi=function(n){return yo(n,O.identity)},hi=O.c onstant(ci),vi=[so("channels",qt(ct.value,Ut([di("onReceive"),ho("schema",uo())] )))],yi=Qo({fields:vi,name:"receiving",active:Jr}),bi=function(n,e){var t=Si(n,e ),o=e.aria();o.update()(n,o,t)},wi=function(n,e,t){xr.toggle(n.element(),e.toggl eClass()),bi(n,e)},xi=function(n,e,t){xr.add(n.element(),e.toggleClass()),bi(n,e )},Ti=function(n,e,t){xr.remove(n.element(),e.toggleClass()),bi(n,e)},Si=functio n(n,e){return xr.has(n.element(),e.toggleClass())},ki=function(n,e,t){(e.selecte d()?xi:Ti)(n,e,t)},Ci=Object.freeze({onLoad:ki,toggle:wi,isOn:Si,on:xi,off:Ti}), Oi=Object.freeze({exhibit:function(n,e,t){return Vo({})},events:function(n,e){va r t,o,r,i=(t=n,o=e,r=wi,Bo(function(n){r(n,t,o)})),u=jo(n,e,ki);return xo(wn.fla tten([n.toggleOnExecute()?[i]:[],[u]]))}}),Ei=function(n,e,t){ar.set(n.element() ,"aria-expanded",t)},Di=[ho("selected",!1),co("toggleClass"),ho("toggleOnExecute ",!0),vo("aria",{mode:"none"},io("mode",{pressed:[ho("syncWithExpanded",!1),gi(" update",function(n,e,t){ar.set(n.element(),"aria-pressed",t),e.syncWithExpanded( )&&Ei(n,e,t)})],checked:[gi("update",function(n,e,t){ar.set(n.element(),"aria-ch ecked",t)})],expanded:[gi("update",Ei)],selected:[gi("update",function(n,e,t){ar .set(n.element(),"aria-selected",t)})],none:[gi("update",O.noop)]}))],Ai=Qo({fie lds:Di,name:"toggling",active:Oi,apis:Ci}),Mi=function(t,o){return yi.config({ch annels:Dt(Wr.formatChanged(),{onReceive:function(n,e){e.command===t&&o(n,e.state )}})})},Bi=function(n){return yi.config({channels:Dt(Wr.orientationChanged(),{on Receive:n})})},Ri=function(n,e){return{key:n,value:{onReceive:e}}},Ii="tinymce-m obile",Fi={resolve:function(n){return Ii+"-"+n},prefix:O.constant(Ii)},Ni=functi on(n,e){e.ignore()||(Nr(n.element()),e.onFocus()(n))},Vi=Object.freeze({focus:Ni ,blur:function(n,e){e.ignore()||Vr(n.element())},isFocused:function(n){return Fr (n.element())}}),Hi=Object.freeze({exhibit:function(n,e){return e.ignore()?Vo({} ):Vo({attributes:{tabindex:"-1"}})},events:function(t){return xo([So(Wn(),functi on(n,e){Ni(n,t),e.stop()})])}}),ji=[fi("onFocus"),ho("ignore",!1)],zi=Qo({fields :ji,name:"focusing",active:Hi,apis:Vi}),Li=function(n){return n.style!==undefine d},Pi=function(n,e,t){if(!E.isString(t))throw console.error("Invalid call to CSS .set. Property ",e,":: Value ",t,":: Element ",n),new Error("CSS value must be a string: "+t);Li(n)&&n.style.setProperty(e,t)},Wi=function(n,e){Li(n)&&n.style.r emoveProperty(e)},Ui=function(n,e,t){var o=n.dom();Pi(o,e,t)},Gi=function(n,e){r eturn Li(n)?n.style.getPropertyValue(e):""},$i=function(n,e){var t=n.dom(),o=Gi( t,e);return x.from(o).filter(function(n){return 0<n.length})},qi={copy:function( n,e){var t=n.dom(),o=e.dom();Li(t)&&Li(o)&&(o.style.cssText=t.style.cssText)},se t:Ui,preserve:function(n,e){var t=ar.get(n,"style"),o=e(n);return(t===undefined? ar.remove:ar.set)(n,"style",t),o},setAll:function(n,e){var t=n.dom();M.each(e,fu nction(n,e){Pi(t,e,n)})},setOptions:function(n,e){var t=n.dom();M.each(e,functio n(n,e){n.fold(function(){Wi(t,e)},function(n){Pi(t,e,n)})})},remove:function(n,e ){var t=n.dom();Wi(t,e),ar.has(n,"style")&&""===In.trim(ar.get(n,"style"))&&ar.r emove(n,"style")},get:function(n,e){var t=n.dom(),o=window.getComputedStyle(t).g etPropertyValue(e),r=""!==o||we.inBody(n)?o:Gi(t,e);return null===r?undefined:r} ,getRaw:$i,getAllRaw:function(n){var e={},t=n.dom();if(Li(t))for(var o=0;o<t.sty le.length;o++){var r=t.style.item(o);e[r]=t.style[r]}return e},isValidValue:func tion(n,e,t){var o=ue.fromTag(n);return Ui(o,e,t),$i(o,e).isSome()},reflow:functi on(n){return n.dom().offsetWidth},transfer:function(o,r,n){ve.isElement(o)&&ve.i sElement(r)&&wn.each(n,function(n){var e,t;e=r,$i(o,t=n).each(function(n){$i(e,t ).isNone()&&Ui(e,t,n)})})}};function _i(o,r){var n=function(n){var e=r(n);if(e<= 0||null===e){var t=qi.get(n,o);return parseFloat(t)||0}return e},i=function(r,n) {return wn.foldl(n,function(n,e){var t=qi.get(r,e),o=t===undefined?0:parseInt(t, 10);return isNaN(o)?n:n+o},0)};return{set:function(n,e){if(!E.isNumber(e)&&!e.ma tch(/^[0-9]+$/))throw o+".set accepts only positive integer values. Value was "+ e;var t=n.dom();Li(t)&&(t.style[o]=e+"px")},get:n,getOuter:n,aggregate:i,max:fun ction(n,e,t){var o=i(n,t);return o<e?e-o:0}}}var Ki,Xi,Yi=_i("height",function(n ){return we.inBody(n)?n.dom().getBoundingClientRect().height:n.dom().offsetHeigh t}),Ji=function(n){return Yi.get(n)},Qi=function(n,e,t){return wn.filter(qe.pare nts(n,t),e)},Zi=function(n,e){return wn.filter(qe.siblings(n),e)},nu=function(n) {return Ve.all(n)},eu=function(n,e,t){return Qi(n,function(n){return Ve.is(n,e)} ,t)},tu=function(n,e){return Zi(n,function(n){return Ve.is(n,e)})},ou=function(n ,e){return Ve.all(e,n)},ru=function(n,e,t){return Br.ancestor(n,function(n){retu rn Ve.is(n,e)},t)},iu=function(n){return Ve.one(n)},uu=ru,au=function(n,e){retur n Ve.one(e,n)},cu=function(n,e,t){return Er(Ve.is,ru,n,e,t)},su={BACKSPACE:O.con stant([8]),TAB:O.constant([9]),ENTER:O.constant([13]),SHIFT:O.constant([16]),CTR L:O.constant([17]),ALT:O.constant([18]),CAPSLOCK:O.constant([20]),ESCAPE:O.const ant([27]),SPACE:O.constant([32]),PAGEUP:O.constant([33]),PAGEDOWN:O.constant([34 ]),END:O.constant([35]),HOME:O.constant([36]),LEFT:O.constant([37]),UP:O.constan t([38]),RIGHT:O.constant([39]),DOWN:O.constant([40]),INSERT:O.constant([45]),DEL :O.constant([46]),META:O.constant([91,93,224]),F10:O.constant([121])},fu=functio n(n,e,t){var o=wn.reverse(n.slice(0,e)),r=wn.reverse(n.slice(e+1));return wn.fin d(o.concat(r),t)},lu=function(n,e,t){var o=wn.reverse(n.slice(0,e));return wn.fi nd(o,t)},du=function(n,e,t){var o=n.slice(0,e),r=n.slice(e+1);return wn.find(r.c oncat(o),t)},mu=function(n,e,t){var o=n.slice(e+1);return wn.find(o,t)},gu=funct ion(e){return function(n){return wn.contains(e,n.raw().which)}},pu=function(n){r eturn function(e){return wn.forall(n,function(n){return n(e)})}},hu=function(n){ return!0===n.raw().shiftKey},vu=function(n){return!0===n.raw().ctrlKey},yu=(O.no t(vu),O.not(hu)),bu=function(n,e){return{matches:n,classification:e}},wu=functio n(n,e,t,o){var r=n+e;return o<r?t:r<t?o:r},xu=function(n,e,t){return n<=e?e:t<=n ?t:n},Tu=function(e,t,n){var o=ou(e.element(),"."+t.highlightClass());wn.each(o, function(n){xr.remove(n,t.highlightClass()),e.getSystem().getByDom(n).each(funct ion(n){t.onDehighlight()(e,n)})})},Su=function(n,e,t,o){var r=ku(n,e,t,o);Tu(n,e ),xr.add(o.element(),e.highlightClass()),r||e.onHighlight()(n,o)},ku=function(n, e,t,o){return xr.has(o.element(),e.highlightClass())},Cu=function(n,e,t,o){var r =ou(n.element(),"."+e.itemClass());return x.from(r[o]).fold(function(){return ct .error("No element found with index "+o)},n.getSystem().getByDom)},Ou=function(n ,e,t){return au(n.element(),"."+e.itemClass()).bind(n.getSystem().getByDom)},Eu= function(n,e,t){var o=ou(n.element(),"."+e.itemClass());return(0<o.length?x.some (o[o.length-1]):x.none()).bind(n.getSystem().getByDom)},Du=function(t,e,n,o){var r=ou(t.element(),"."+e.itemClass());return wn.findIndex(r,function(n){return xr .has(n,e.highlightClass())}).bind(function(n){var e=wu(n,o,0,r.length-1);return t.getSystem().getByDom(r[e])})},Au=Object.freeze({dehighlightAll:Tu,dehighlight: function(n,e,t,o){var r=ku(n,e,t,o);xr.remove(o.element(),e.highlightClass()),r& &e.onDehighlight()(n,o)},highlight:Su,highlightFirst:function(e,t,o){Ou(e,t,o).e ach(function(n){Su(e,t,o,n)})},highlightLast:function(e,t,o){Eu(e,t,o).each(func tion(n){Su(e,t,o,n)})},highlightAt:function(e,t,o,n){Cu(e,t,o,n).fold(function(n ){throw new Error(n)},function(n){Su(e,t,o,n)})},highlightBy:function(e,t,o,n){v ar r=ou(e.element(),"."+t.itemClass()),i=Qr(wn.map(r,function(n){return e.getSys tem().getByDom(n).toOption()}));wn.find(i,n).each(function(n){Su(e,t,o,n)})},isH ighlighted:ku,getHighlighted:function(n,e,t){return au(n.element(),"."+e.highlig htClass()).bind(n.getSystem().getByDom)},getFirst:Ou,getLast:Eu,getPrevious:func tion(n,e,t){return Du(n,e,0,-1)},getNext:function(n,e,t){return Du(n,e,0,1)}}),M u=[co("highlightClass"),co("itemClass"),fi("onHighlight"),fi("onDehighlight")],B u=Qo({fields:Mu,name:"highlighting",apis:Au}),Ru=function(){return{get:function( n){return jr(n.element())},set:function(n,e){n.getSystem().triggerFocus(e,n.elem ent())}}},Iu=function(n,e,a,t,o,i){var u=function(e,t,o,r){var n,i,u=a(e,t,o,r); return(n=u,i=t.event(),wn.find(n,function(n){return n.matches(i)}).map(function( n){return n.classification})).bind(function(n){return n(e,t,o,r)})},r={schema:fu nction(){return n.concat([ho("focusManager",Ru()),gi("handler",r),gi("state",e)] )},processKey:u,toEvents:function(o,r){var n=t(o,r),e=xo(i.map(function(t){retur n So(Wn(),function(n,e){t(n,o,r,e),e.stop()})}).toArray().concat([So(j(),functio n(n,e){u(n,e,o,r).each(function(n){e.stop()})})]));return D.deepMerge(n,e)},toAp is:o};return r},Fu=function(n){var e=[mo("onEscape"),mo("onEnter"),ho("selector" ,'[data-alloy-tabstop="true"]'),ho("firstTabstop",0),ho("useTabstopAt",O.constan t(!0)),mo("visibilitySelector")].concat([n]),a=function(n,e){var t=n.visibilityS elector().bind(function(n){return cu(e,n)}).getOr(e);return 0<Ji(t)},c=function( e,n,t,o,r){return r(n,t,function(n){return a(e=o,t=n)&&e.useTabstopAt()(t);var e ,t}).fold(function(){return o.cyclic()?x.some(!0):x.none()},function(n){return o .focusManager().set(e,n),x.some(!0)})},i=function(e,n,t,o){var r,i,u=ou(e.elemen t(),t.selector());return(r=e,i=t,i.focusManager().get(r).bind(function(n){return cu(n,i.selector())})).bind(function(n){return wn.findIndex(u,O.curry(je,n)).bin d(function(n){return c(e,u,n,t,o)})})},t=O.constant([bu(pu([hu,gu(su.TAB())]),fu nction(n,e,t,o){var r=t.cyclic()?fu:lu;return i(n,0,t,r)}),bu(gu(su.TAB()),funct ion(n,e,t,o){var r=t.cyclic()?du:mu;return i(n,0,t,r)}),bu(gu(su.ESCAPE()),funct ion(e,t,n,o){return n.onEscape().bind(function(n){return n(e,t)})}),bu(pu([yu,gu (su.ENTER())]),function(e,t,n,o){return n.onEnter().bind(function(n){return n(e, t)})})]),o=O.constant({}),r=O.constant({});return Iu(e,Ko,t,o,r,x.some(function( e,t,n){var o,r,i,u;(o=e,r=t,i=ou(o.element(),r.selector()),u=wn.filter(i,functio n(n){return a(r,n)}),x.from(u[r.firstTabstop()])).each(function(n){t.focusManage r().set(e,n)})}))},Nu=Fu(yo("cyclic",O.constant(!1))),Vu=Fu(yo("cyclic",O.consta nt(!0))),Hu=function(n){return"input"===ve.name(n)&&"radio"!==ar.get(n,"type")|| "textarea"===ve.name(n)},ju=function(n,e,t){return Hu(t)&&gu(su.SPACE())(e.event ())?x.none():(oe(n,t,$n()),x.some(!0))},zu=[ho("execute",ju),ho("useSpace",!1),h o("useEnter",!0),ho("useControlEnter",!1),ho("useDown",!1)],Lu=function(n,e,t,o) {return t.execute()(n,e,n.element())},Pu=O.constant({}),Wu=O.constant({}),Uu=Iu( zu,Ko,function(n,e,t,o){var r=t.useSpace()&&!Hu(n.element())?su.SPACE():[],i=t.u seEnter()?su.ENTER():[],u=t.useDown()?su.DOWN():[],a=r.concat(i).concat(u);retur n[bu(gu(a),Lu)].concat(t.useControlEnter()?[bu(pu([vu,gu(su.ENTER())]),Lu)]:[])} ,Pu,Wu,x.none()),Gu=function(n){var t=Or(x.none());return _o({readState:O.consta nt({}),setGridSize:function(n,e){t.set(x.some({numRows:O.constant(n),numColumns: O.constant(e)}))},getNumRows:function(){return t.get().map(function(n){return n. numRows()})},getNumColumns:function(){return t.get().map(function(n){return n.nu mColumns()})}})},$u=Object.freeze({flatgrid:Gu,init:function(n){return n.state() (n)}}),qu=function(n){return"rtl"===qi.get(n,"direction")?"rtl":"ltr"},_u=functi on(e,t){return function(n){return"rtl"===qu(n)?t:e}},Ku=function(i){return funct ion(n,e,t,o){var r=i(n.element());return Qu(r,n,e,t,o)}},Xu=function(n,e){var t= _u(n,e);return Ku(t)},Yu=function(n,e){var t=_u(e,n);return Ku(t)},Ju=function(r ){return function(n,e,t,o){return Qu(r,n,e,t,o)}},Qu=function(e,t,n,o,r){return o.focusManager().get(t).bind(function(n){return e(t.element(),n,o,r)}).map(funct ion(n){return o.focusManager().set(t,n),!0})},Zu=Ju,na=Ju,ea=Ju,ta=function(n){v ar e,t=n.dom();return!((e=t).offsetWidth<=0&&e.offsetHeight<=0)},oa=Ee.immutable Bag(["index","candidates"],[]),ra=function(n,e,t){return ia(n,e,t,ta)},ia=functi on(n,e,t,o){var r,i,u=O.curry(je,e),a=ou(n,t),c=wn.filter(a,ta);return r=c,i=u,w n.findIndex(r,i).map(function(n){return oa({index:n,candidates:r})})},ua=functio n(n,e){return wn.findIndex(n,function(n){return je(e,n)})},aa=function(t,n,o,e){ return e(Math.floor(n/o),n%o).bind(function(n){var e=n.row()*o+n.column();return 0<=e&&e<t.length?x.some(t[e]):x.none()})},ca=function(r,n,i,u,a){return aa(r,n, u,function(n,e){var t=n===i-1?r.length-n*u:u,o=wu(e,a,0,t-1);return x.some({row: O.constant(n),column:O.constant(o)})})},sa=function(i,n,u,a,c){return aa(i,n,a,f unction(n,e){var t=wu(n,c,0,u-1),o=t===u-1?i.length-t*a:a,r=xu(e,0,o-1);return x .some({row:O.constant(t),column:O.constant(r)})})},fa=[co("selector"),ho("execut e",ju),li("onEscape"),ho("captureTab",!1),hi()],la=function(r){return function(n ,e,t,o){return ra(n,e,t.selector()).bind(function(n){return r(n.candidates(),n.i ndex(),o.getNumRows().getOr(t.initSize().numRows()),o.getNumColumns().getOr(t.in itSize().numColumns()))})}},da=function(n,e,t,o){return t.captureTab()?x.some(!0 ):x.none()},ma=la(function(n,e,t,o){return ca(n,e,t,o,-1)}),ga=la(function(n,e,t ,o){return ca(n,e,t,o,1)}),pa=la(function(n,e,t,o){return sa(n,e,t,o,-1)}),ha=la (function(n,e,t,o){return sa(n,e,t,o,1)}),va=O.constant([bu(gu(su.LEFT()),Xu(ma, ga)),bu(gu(su.RIGHT()),Yu(ma,ga)),bu(gu(su.UP()),Zu(pa)),bu(gu(su.DOWN()),na(ha) ),bu(pu([hu,gu(su.TAB())]),da),bu(pu([yu,gu(su.TAB())]),da),bu(gu(su.ESCAPE()),f unction(n,e,t,o){return t.onEscape()(n,e)}),bu(gu(su.SPACE().concat(su.ENTER())) ,function(e,t,o,n){return(r=e,i=o,i.focusManager().get(r).bind(function(n){retur n cu(n,i.selector())})).bind(function(n){return o.execute()(e,t,n)});var r,i})]) ,ya=O.constant({}),ba=Iu(fa,Gu,va,ya,{},x.some(function(e,t,n){au(e.element(),t. selector()).each(function(n){t.focusManager().set(e,n)})})),wa=function(n,e,t,r) {return ra(n,t,e).bind(function(n){var e=n.index(),t=n.candidates(),o=wu(e,r,0,t .length-1);return x.from(t[o])})},xa=[co("selector"),ho("getInitial",x.none),ho( "execute",ju),ho("executeOnMove",!1)],Ta=function(e,t,o){return(n=e,r=o,r.focusM anager().get(n).bind(function(n){return cu(n,r.selector())})).bind(function(n){r eturn o.execute()(e,t,n)});var n,r},Sa=function(n,e,t){return wa(n,t.selector(), e,-1)},ka=function(n,e,t){return wa(n,t.selector(),e,1)},Ca=function(o){return f unction(n,e,t){return o(n,e,t).bind(function(){return t.executeOnMove()?Ta(n,e,t ):x.some(!0)})}},Oa=O.constant({}),Ea=O.constant({}),Da=Iu(xa,Ko,function(n){ret urn[bu(gu(su.LEFT().concat(su.UP())),Ca(Xu(Sa,ka))),bu(gu(su.RIGHT().concat(su.D OWN())),Ca(Yu(Sa,ka))),bu(gu(su.ENTER()),Ta),bu(gu(su.SPACE()),Ta)]},Oa,Ea,x.som e(function(e,t){t.getInitial()(e).or(au(e.element(),t.selector())).each(function (n){t.focusManager().set(e,n)})})),Aa=Ee.immutableBag(["rowIndex","columnIndex", "cell"],[]),Ma=function(n,e,t){return x.from(n[e]).bind(function(n){return x.fro m(n[t]).map(function(n){return Aa({rowIndex:e,columnIndex:t,cell:n})})})},Ba=fun ction(n,e,t,o){var r=n[e].length,i=wu(t,o,0,r-1);return Ma(n,e,i)},Ra=function(n ,e,t,o){var r=wu(t,o,0,n.length-1),i=n[r].length,u=xu(e,0,i-1);return Ma(n,r,u)} ,Ia=function(n,e,t,o){var r=n[e].length,i=xu(t+o,0,r-1);return Ma(n,e,i)},Fa=fun ction(n,e,t,o){var r=xu(t+o,0,n.length-1),i=n[r].length,u=xu(e,0,i-1);return Ma( n,r,u)},Na=[lo("selectors",[co("row"),co("cell")]),ho("cycles",!0),ho("previousS elector",x.none),ho("execute",ju)],Va=function(n,e){return function(t,o,u){var a =u.cycles()?n:e;return cu(o,u.selectors().row()).bind(function(n){var e=ou(n,u.s electors().cell());return ua(e,o).bind(function(r){var i=ou(t,u.selectors().row( ));return ua(i,n).bind(function(n){var e,t,o=(e=i,t=u,wn.map(e,function(n){retur n ou(n,t.selectors().cell())}));return a(o,n,r).map(function(n){return n.cell()} )})})})}},Ha=Va(function(n,e,t){return Ba(n,e,t,-1)},function(n,e,t){return Ia(n ,e,t,-1)}),ja=Va(function(n,e,t){return Ba(n,e,t,1)},function(n,e,t){return Ia(n ,e,t,1)}),za=Va(function(n,e,t){return Ra(n,t,e,-1)},function(n,e,t){return Fa(n ,t,e,-1)}),La=Va(function(n,e,t){return Ra(n,t,e,1)},function(n,e,t){return Fa(n ,t,e,1)}),Pa=O.constant([bu(gu(su.LEFT()),Xu(Ha,ja)),bu(gu(su.RIGHT()),Yu(Ha,ja) ),bu(gu(su.UP()),Zu(za)),bu(gu(su.DOWN()),na(La)),bu(gu(su.SPACE().concat(su.ENT ER())),function(e,t,o){return jr(e.element()).bind(function(n){return o.execute( )(e,t,n)})})]),Wa=O.constant({}),Ua=O.constant({}),Ga=Iu(Na,Ko,Pa,Wa,Ua,x.some(f unction(e,t){t.previousSelector()(e).orThunk(function(){var n=t.selectors();retu rn au(e.element(),n.cell())}).each(function(n){t.focusManager().set(e,n)})})),$a =[co("selector"),ho("execute",ju),ho("moveOnTab",!1)],qa=function(e,t,o){return o.focusManager().get(e).bind(function(n){return o.execute()(e,t,n)})},_a=functio n(n,e,t){return wa(n,t.selector(),e,-1)},Ka=function(n,e,t){return wa(n,t.select or(),e,1)},Xa=O.constant([bu(gu(su.UP()),ea(_a)),bu(gu(su.DOWN()),ea(Ka)),bu(pu( [hu,gu(su.TAB())]),function(n,e,t){return t.moveOnTab()?ea(_a)(n,e,t):x.none()}) ,bu(pu([yu,gu(su.TAB())]),function(n,e,t){return t.moveOnTab()?ea(Ka)(n,e,t):x.n one()}),bu(gu(su.ENTER()),qa),bu(gu(su.SPACE()),qa)]),Ya=O.constant({}),Ja=O.con stant({}),Qa=Iu($a,Ko,Xa,Ya,Ja,x.some(function(e,t,n){au(e.element(),t.selector( )).each(function(n){t.focusManager().set(e,n)})})),Za=[li("onSpace"),li("onEnter "),li("onShiftEnter"),li("onLeft"),li("onRight"),li("onTab"),li("onShiftTab"),li ("onUp"),li("onDown"),li("onEscape"),mo("focusIn")],nc=O.constant({}),ec=O.const ant({}),tc=Iu(Za,Ko,function(n,e,t){return[bu(gu(su.SPACE()),t.onSpace()),bu(pu( [yu,gu(su.ENTER())]),t.onEnter()),bu(pu([hu,gu(su.ENTER())]),t.onShiftEnter()),b u(pu([hu,gu(su.TAB())]),t.onShiftTab()),bu(pu([yu,gu(su.TAB())]),t.onTab()),bu(g u(su.UP()),t.onUp()),bu(gu(su.DOWN()),t.onDown()),bu(gu(su.LEFT()),t.onLeft()),b u(gu(su.RIGHT()),t.onRight()),bu(gu(su.SPACE()),t.onSpace()),bu(gu(su.ESCAPE()), t.onEscape())]},nc,ec,x.some(function(e,t){return t.focusIn().bind(function(n){r eturn n(e,t)})})),oc={acyclic:Nu.schema(),cyclic:Vu.schema(),flow:Da.schema(),fl atgrid:ba.schema(),matrix:Ga.schema(),execution:Uu.schema(),menu:Qa.schema(),spe cial:tc.schema()},rc=(Xi=to("Creating behaviour: "+(Ki={branchKey:"mode",branche s:oc,name:"keying",active:{events:function(n,e){return n.handler().toEvents(n,e) }},apis:{focusIn:function(n){n.getSystem().triggerFocus(n.element(),n.element()) },setGridSize:function(n,e,t,o,r){Bt(t,"setGridSize")?t.setGridSize(o,r):console .error("Layout does not support setGridSize")}},state:$u}).name,Zo,Ki),zo(io(Xi. branchKey,Xi.branches),Xi.name,Xi.active,Xi.apis,Xi.extra,Xi.state)),ic=function (o,n){return e=o,t={},r=wn.map(n,function(n){return e=n.name(),t="Cannot configu re "+n.name()+" for "+o,Xt(e,e,mt(),Wt(function(n){return ct.error("The field: " +e+" is forbidden. "+t)}));var e,t}).concat([yo("dump",O.identity)]),Xt(e,e,lt(t ),Gt(r));var e,t,r},uc=function(n){return n.dump()},ac="placeholder",cc=st([{sin gle:["required","valueThunk"]},{multiple:["required","valueThunks"]}]),sc=functi on(n,e,t,o){return t.uiType===ac?(i=t,u=o,(r=n).exists(function(n){return n!==i. owner})?cc.single(!0,O.constant(i)):Et(u,i.name).fold(function(){throw new Error ("Unknown placeholder component: "+i.name+"\nKnown: ["+M.keys(u)+"]\nNamespace: "+r.getOr("none")+"\nSpec: "+Nt(i,null,2))},function(n){return n.replace()})):cc .single(!1,O.constant(t));var r,i,u},fc=function(i,u,a,c){return sc(i,0,a,c).fol d(function(n,e){var t=e(u,a.config,a.validated),o=Et(t,"components").getOr([]),r =wn.bind(o,function(n){return fc(i,u,n,c)});return[D.deepMerge(t,{components:r}) ]},function(n,e){return e(u,a.config,a.validated)})},lc=function(e,t,n,o){var r, i,u,a,c=M.map(o,function(n,e){return t=e,o=n,r=!1,{name:O.constant(t),required:f unction(){return o.fold(function(n,e){return n},function(n,e){return n})},used:f unction(){return r},replace:function(){if(!0===r)throw new Error("Trying to use the same placeholder more than once: "+t);return r=!0,o}};var t,o,r}),s=(r=e,i=t ,u=n,a=c,wn.bind(u,function(n){return fc(r,i,n,a)}));return M.each(c,function(n) {if(!1===n.used()&&n.required())throw new Error("Placeholder: "+n.name()+" was n ot found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+Nt(t. components(),null,2))}),s},dc=cc.single,mc=cc.multiple,gc=O.constant(ac),pc=0,hc =function(n){var e=(new Date).getTime();return n+"_"+Math.floor(1e9*Math.random( ))+ ++pc+String(e)},vc=st([{required:["data"]},{external:["data"]},{optional:["d ata"]},{group:["data"]}]),yc=ho("factory",{sketch:O.identity}),bc=ho("schema",[] ),wc=co("name"),xc=Xt("pname","pname",gt(function(n){return"<alloy."+hc(n.name)+ ">"}),uo()),Tc=ho("defaults",O.constant({})),Sc=ho("overrides",O.constant({})),k c=Gt([yc,bc,wc,xc,Tc,Sc]),Cc=Gt([yc,bc,wc,Tc,Sc]),Oc=Gt([yc,bc,wc,xc,Tc,Sc]),Ec= Gt([yc,bc,wc,co("unit"),xc,Tc,Sc]),Dc=function(n){var e=function(n){return n.nam e()};return n.fold(e,e,e,e)},Ac=function(t,o){return function(n){var e=oo("Conve rting part type",o,n);return t(e)}},Mc=Ac(vc.required,kc),Bc=(Ac(vc.external,Cc) ,Ac(vc.optional,Oc)),Rc=Ac(vc.group,Ec),Ic=O.constant("entirety"),Fc=function(n, e,t,o){var r=t;return D.deepMerge(e.defaults()(n,t,o),t,{uid:n.partUids()[e.name ()]},e.overrides()(n,t,o),{"debug.sketcher":Dt("part-"+e.name(),r)})},Nc=functio n(r,n){var i={};return wn.each(n,function(n){var e;(e=n,e.fold(x.some,x.none,x.s ome,x.some)).each(function(t){var o=Vc(r,t.pname());i[t.name()]=function(n){var e=to("Part: "+t.name()+" in "+r,Gt(t.schema()),n);return D.deepMerge(o,{config:n ,validated:e})}})}),i},Vc=function(n,e){return{uiType:gc(),owner:n,name:e}},Hc=f unction(n,e,t){return o=e,r=t,i={},u={},wn.each(r,function(n){n.fold(function(o) {i[o.pname()]=dc(!0,function(n,e,t){return o.factory().sketch(Fc(n,o,e,t))})},fu nction(n){var e=o.parts()[n.name()]();u[n.name()]=O.constant(Fc(o,n,e[Ic()]()))} ,function(o){i[o.pname()]=dc(!1,function(n,e,t){return o.factory().sketch(Fc(n,o ,e,t))})},function(r){i[r.pname()]=mc(!0,function(e,n,t){var o=e[r.name()]();ret urn wn.map(o,function(n){return r.factory().sketch(D.deepMerge(r.defaults()(e,n) ,n,r.overrides()(e,n)))})})})}),{internals:O.constant(i),externals:O.constant(u) };var o,r,i,u},jc=function(n,e,t){return lc(x.some(n),e,e.components(),t)},zc=fu nction(n,e,t){var o=e.partUids()[t];return n.getSystem().getByUid(o).toOption()} ,Lc=function(n,e,t){return zc(n,e,t).getOrDie("Could not find part: "+t)},Pc=fun ction(e,n){var t,o=(t=n,wn.map(t,Dc));return At(wn.map(o,function(n){return{key: n,value:e+"-"+n}}))},Wc=function(e){return Xt("partUids","partUids",pt(function( n){return Pc(n.uid,e)}),uo())},Uc=hc("alloy-premade"),Gc=hc("api"),$c=function(n ){return Dt(Uc,n)},qc=function(o){return n=function(n){var e=Array.prototype.sli ce.call(arguments,0),t=n.config(Gc);return o.apply(undefined,[t].concat(e))},e=o .toString(),t=e.indexOf(")")+1,r=e.indexOf("("),i=e.substring(r+1,t-1).split(/,\ s*/),n.toFunctionAnnotation=function(){return{name:"OVERRIDE",parameters:Ro(i.sl ice(1))}},n;var n,e,t,r,i},_c=O.constant(Gc),Kc=O.constant("alloy-id-"),Xc=O.con stant("data-alloy-id"),Yc=Kc(),Jc=Xc(),Qc=function(n){var e=ve.isElement(n)?ar.g et(n,Jc):null;return x.from(e)},Zc=function(n){return hc(n)},ns=(O.constant(Jc), function(n,e,t,o,r){var i,u,a=(u=r,(0<(i=o).length?[lo("parts",i)]:[]).concat([c o("uid"),ho("dom",{}),ho("components",[]),pi("originalSpec"),ho("debug.sketcher" ,{})]).concat(u));return oo(n+" [SpecSchema]",Ut(a.concat(e)),t)}),es=function(n ,e,t,o,r){var i,u=ts(r),a=(i=t,wn.bind(i,function(n){return n.fold(x.none,x.some ,x.none,x.none).map(function(n){return lo(n.name(),n.schema().concat([pi(Ic())]) )}).toArray()})),c=Wc(t),s=ns(n,e,u,a,[c]),f=Hc(0,s,t),l=jc(n,s,f.internals());r eturn D.deepMerge(o(s,l,u,f.externals()),{"debug.sketcher":Dt(n,r)})},ts=functio n(n){return D.deepMerge({uid:Zc("uid")},n)},os=Ut([co("name"),co("factory"),co(" configFields"),ho("apis",{}),ho("extraApis",{})]),rs=Ut([co("name"),co("factory" ),co("configFields"),co("partFields"),ho("apis",{}),ho("extraApis",{})]),is=func tion(n){var a=to("Sketcher for "+n.name,os,n),e=M.map(a.apis,qc),t=M.map(a.extra Apis,function(n,e){return Io(n,e)});return D.deepMerge({name:O.constant(a.name), partFields:O.constant([]),configFields:O.constant(a.configFields),sketch:functio n(n){return e=a.name,t=a.configFields,o=a.factory,i=ts(r=n),u=ns(e,t,i,[],[]),D. deepMerge(o(u,i),{"debug.sketcher":Dt(e,r)});var e,t,o,r,i,u}},e,t)},us=function (n){var e=to("Sketcher for "+n.name,rs,n),t=Nc(e.name,e.partFields),o=M.map(e.ap is,qc),r=M.map(e.extraApis,function(n,e){return Io(n,e)});return D.deepMerge({na me:O.constant(e.name),partFields:O.constant(e.partFields),configFields:O.constan t(e.configFields),sketch:function(n){return es(e.name,e.configFields,e.partField s,e.factory,n)},parts:O.constant(t)},o,r)},as=is({name:"Button",factory:function (n,e){var t,o,r,i=(t=n.action(),o=function(n,e){e.stop(),te(n)},r=Ln.detect().de viceType.isTouch()?[So(_n(),o)]:[So(P(),o),So(F(),function(n,e){e.cut()})],xo(wn .flatten([t.map(function(t){return So($n(),function(n,e){t(n),e.stop()})}).toArr ay(),r]))),u=Et(n.dom(),"attributes").bind(Ct("type")),a=Et(n.dom(),"tag");retur n{uid:n.uid(),dom:n.dom(),components:n.components(),events:i,behaviours:D.deepMe rge(Yo([zi.config({}),rc.config({mode:"execution",useSpace:!0,useEnter:!0})]),uc (n.buttonBehaviours())),domModification:{attributes:D.deepMerge(u.fold(function( ){return a.is("button")?{type:"button"}:{}},function(n){return{}}),{role:n.role( ).getOr("button")})},eventOrder:n.eventOrder()}},configFields:[ho("uid",undefine d),co("dom"),ho("components",[]),ic("buttonBehaviours",[zi,rc]),mo("action"),mo( "role"),ho("eventOrder",{})]}),cs=Object.freeze({events:function(n){return xo([T o(U(),O.constant(!0))])},exhibit:function(n,e){return Vo({styles:{"-webkit-user- select":"none","user-select":"none","-ms-user-select":"none","-moz-user-select": "-moz-none"},attributes:{unselectable:"on"}})}}),ss=Qo({fields:[],name:"unselect ing",active:cs}),fs=function(n){var e,t,o,r=ue.fromHtml(n),i=qe.children(r),u=(t =(e=r).dom().attributes!==undefined?e.dom().attributes:[],wn.foldl(t,function(n, e){return"class"===e.name?n:D.deepMerge(n,Dt(e.name,e.value))},{})),a=(o=r,Array .prototype.slice.call(o.dom().classList,0)),c=0===i.length?{}:{innerHtml:$r(r)}; return D.deepMerge({tag:ve.name(r),classes:a,attributes:u},c)},ls=function(n){va r e=In.supplant(n,{prefix:Fi.prefix()});return fs(e)},ds=function(n){return{dom: ls(n)}},ms=function(n){return Yo([Ai.config({toggleClass:Fi.resolve("toolbar-but ton-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),Mi(n,function(n,e){(e? Ai.on:Ai.off)(n)})])},gs=function(n,e,t){return as.sketch({dom:ls('<span class=" ${prefix}-toolbar-button ${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:e ,buttonBehaviours:D.deepMerge(Yo([ss.config({})]),t)})},ps={forToolbar:gs,forToo lbarCommand:function(n,e){return gs(e,function(){n.execCommand(e)},{})},forToolb arStateAction:function(n,e,t,o){var r=ms(t);return gs(e,o,r)},forToolbarStateCom mand:function(n,e){var t=ms(e);return gs(e,function(){n.execCommand(e)},t)}},hs= function(n,e,t){return Math.max(e,Math.min(t,n))},vs=function(n,e,t,o,r,i,u){var a=t-e;if(o<n.left)return e-1;if(o>n.right)return t+1;var c,s,f,l,d=Math.min(n.r ight,Math.max(o,n.left))-n.left,m=hs(d/n.width*a+e,e-1,t+1),g=Math.round(m);retu rn i&&e<=m&&m<=t?(c=m,s=e,f=t,l=r,u.fold(function(){var n=c-s,e=Math.round(n/l)* l;return hs(s+e,s-1,f+1)},function(n){var e=(c-n)%l,t=Math.round(e/l),o=Math.flo or((c-n)/l),r=Math.floor((f-n)/l),i=n+Math.min(r,o+t)*l;return Math.max(n,i)})): g},ys="slider.change.value",bs=Ln.detect().deviceType.isTouch(),ws=function(n){v ar e;return(e=n.event().raw(),bs&&e.touches!==undefined&&1===e.touches.length?x. some(e.touches[0]):bs&&e.touches!==undefined?x.none():bs||e.clientX===undefined? x.none():x.some(e)).map(function(n){return n.clientX})},xs=function(n,e){ee(n,ys ,{value:e})},Ts=function(i,u,a,n){return ws(n).map(function(n){var e,t,o,r;retur n e=i,o=n,r=vs(a,(t=u).min(),t.max(),o,t.stepSize(),t.snapToGrid(),t.snapStart() ),xs(e,r),n})},Ss=function(n,e){var t,o,r,i,u=(t=e.value().get(),o=e.min(),r=e.m ax(),i=e.stepSize(),t<o?t:r<t?r:t===o?o-1:Math.max(o,t-i));xs(n,u)},ks=function( n,e){var t,o,r,i,u=(t=e.value().get(),o=e.min(),r=e.max(),i=e.stepSize(),r<t?t:t <o?o:t===r?r+1:Math.min(r,t+i));xs(n,u)},Cs=O.constant(ys),Os=Ln.detect().device Type.isTouch(),Es=function(n,o){return Bc({name:n+"-edge",overrides:function(n){ var e=xo([ko(B(),o,[n])]),t=xo([ko(F(),o,[n]),ko(N(),function(n,e){e.mouseIsDown ().get()&&o(n,e)},[n])]);return{events:Os?e:t}}})},Ds=[Es("left",function(n,e){x s(n,e.min()-1)}),Es("right",function(n,e){xs(n,e.max()+1)}),Mc({name:"thumb",def aults:O.constant({dom:{styles:{position:"absolute"}}}),overrides:function(n){ret urn{events:xo([Oo(B(),n,"spectrum"),Oo(R(),n,"spectrum"),Oo(I(),n,"spectrum")])} }}),Mc({schema:[yo("mouseIsDown",function(){return Or(!1)})],name:"spectrum",ove rrides:function(o){var t=function(n,e){var t=n.element().dom().getBoundingClient Rect();Ts(n,o,t,e)},n=xo([So(B(),t),So(R(),t)]),e=xo([So(F(),t),So(N(),function( n,e){o.mouseIsDown().get()&&t(n,e)})]);return{behaviours:Yo(Os?[]:[rc.config({mo de:"special",onLeft:function(n){return Ss(n,o),x.some(!0)},onRight:function(n){r eturn ks(n,o),x.some(!0)}}),zi.config({})]),events:Os?n:e}}})],As=function(n,e,t ){e.store().manager().onLoad(n,e,t)},Ms=function(n,e,t){e.store().manager().onUn load(n,e,t)},Bs=Object.freeze({onLoad:As,onUnload:Ms,setValue:function(n,e,t,o){ e.store().manager().setValue(n,e,t,o)},getValue:function(n,e,t){return e.store() .manager().getValue(n,e,t)}}),Rs=Object.freeze({events:function(t,o){var n=t.res etOnDom()?[Do(function(n,e){As(n,t,o)}),Ao(function(n,e){Ms(n,t,o)})]:[jo(t,o,As )];return xo(n)}}),Is=function(){var n=Or(null);return _o({set:n.set,get:n.get,i sNotSet:function(){return null===n.get()},clear:function(){n.set(null)},readStat e:function(){return{mode:"memory",value:n.get()}}})},Fs=function(){var n=Or({}); return _o({readState:function(){return{mode:"dataset",dataset:n.get()}},set:n.se t,get:n.get})},Ns=Object.freeze({memory:Is,dataset:Fs,manual:function(){return _ o({readState:function(){}})},init:function(n){return n.store().manager().state(n )}}),Vs=function(n,e,t,o){e.store().getDataKey(),t.set({}),e.store().setData()(n ,o),e.onSetValue()(n,o)},Hs=[mo("initialValue"),co("getFallbackEntry"),co("getDa taKey"),co("setData"),gi("manager",{setValue:Vs,getValue:function(n,e,t){var o=e .store().getDataKey()(n),r=t.get();return Et(r,o).fold(function(){return e.store ().getFallbackEntry()(o)},function(n){return n})},onLoad:function(e,t,o){t.store ().initialValue().each(function(n){Vs(e,t,o,n)})},onUnload:function(n,e,t){t.set ({})},state:Fs})],js=[co("getValue"),ho("setValue",O.noop),mo("initialValue"),gi ("manager",{setValue:function(n,e,t,o){e.store().setValue()(n,o),e.onSetValue()( n,o)},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)})},onU nload:O.noop,state:Ko})],zs=[mo("initialValue"),gi("manager",{setValue:function( n,e,t,o){t.set(o),e.onSetValue()(n,o)},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:Is})],Ls=[vo("store",{mode: "memory"},io("mode",{memory:zs,manual:js,dataset:Hs})),fi("onSetValue"),ho("rese tOnDom",!1)],Ps=Qo({fields:Ls,name:"representing",active:Rs,apis:Bs,extra:{setVa lueFrom:function(n,e){var t=Ps.getValue(e);Ps.setValue(n,t)}},state:Ns}),Ws=Ln.d etect().deviceType.isTouch(),Us=[co("min"),co("max"),ho("stepSize",1),ho("onChan ge",O.noop),ho("onInit",O.noop),ho("onDragStart",O.noop),ho("onDragEnd",O.noop), ho("snapToGrid",!1),mo("snapStart"),co("getInitialValue"),ic("sliderBehaviours", [rc,Ps]),yo("value",function(n){return Or(n.min)})].concat(Ws?[]:[yo("mouseIsDow n",function(){return Or(!1)})]),Gs=_i("width",function(n){return n.dom().offsetW idth}),$s=function(n,e){Gs.set(n,e)},qs=function(n){return Gs.get(n)},_s=Ln.dete ct().deviceType.isTouch(),Ks=us({name:"Slider",configFields:Us,partFields:Ds,fac tory:function(c,n,e,t){var s=c.max()-c.min(),f=function(n){var e=n.element().dom ().getBoundingClientRect();return(e.left+e.right)/2},r=function(n){return Lc(n,c ,"thumb")},i=function(n){var e,t,o,r,i=Lc(n,c,"spectrum").element().dom().getBou ndingClientRect(),u=n.element().dom().getBoundingClientRect(),a=(e=n,t=i,(r=(o=c ).value().get())<o.min()?zc(e,o,"left-edge").fold(function(){return 0},function( n){return f(n)-t.left}):r>o.max()?zc(e,o,"right-edge").fold(function(){return t. width},function(n){return f(n)-t.left}):(o.value().get()-o.min())/s*t.width);ret urn i.left-u.left+a},u=function(n){var e=i(n),t=r(n),o=qs(t.element())/2;qi.set( t.element(),"left",e-o+"px")},o=function(n,e){var t=c.value().get(),o=r(n);retur n t!==e||qi.getRaw(o.element(),"left").isNone()?(c.value().set(e),u(n),c.onChang e()(n,o,e),x.some(!0)):x.none()},a=_s?[So(B(),function(n,e){c.onDragStart()(n,r( n))}),So(I(),function(n,e){c.onDragEnd()(n,r(n))})]:[So(F(),function(n,e){e.stop (),c.onDragStart()(n,r(n)),c.mouseIsDown().set(!0)}),So(V(),function(n,e){c.onDr agEnd()(n,r(n)),c.mouseIsDown().set(!1)})];return{uid:c.uid(),dom:c.dom(),compon ents:n,behaviours:D.deepMerge(Yo(wn.flatten([_s?[]:[rc.config({mode:"special",fo cusIn:function(n){return zc(n,c,"spectrum").map(rc.focusIn).map(O.constant(!0))} })],[Ps.config({store:{mode:"manual",getValue:function(n){return c.value().get() }}})]])),uc(c.sliderBehaviours())),events:xo([So(Cs(),function(n,e){o(n,e.event( ).value())}),Do(function(n,e){c.value().set(c.getInitialValue()());var t=r(n);u( n),c.onInit()(n,t,c.value().get())})].concat(a)),apis:{resetToMin:function(n){o( n,c.min())},resetToMax:function(n){o(n,c.max())},refresh:u},domModification:{sty les:{position:"relative"}}}},apis:{resetToMin:function(n,e){n.resetToMin(e)},res etToMax:function(n,e){n.resetToMax(e)},refresh:function(n,e){n.refresh(e)}}}),Xs =function(e,t,o){return ps.forToolbar(t,function(){var n=o();e.setContextToolbar ([{label:t+" group",items:n}])},{})},Ys=function(n){return[(r=n,i=function(n){re turn n<0?"black":360<n?"white":"hsl("+n+", 100%, 50%)"},Ks.sketch({dom:ls('<div class="${prefix}-slider ${prefix}-hue-slider-container"></div>'),components:[Ks. parts()["left-edge"](ds('<div class="${prefix}-hue-slider-black"></div>')),Ks.pa rts().spectrum({dom:ls('<div class="${prefix}-slider-gradient-container"></div>' ),components:[ds('<div class="${prefix}-slider-gradient"></div>')],behaviours:Yo ([Ai.config({toggleClass:Fi.resolve("thumb-active")})])}),Ks.parts()["right-edge "](ds('<div class="${prefix}-hue-slider-white"></div>')),Ks.parts().thumb({dom:l s('<div class="${prefix}-slider-thumb"></div>'),behaviours:Yo([Ai.config({toggle Class:Fi.resolve("thumb-active")})])})],onChange:function(n,e,t){var o=i(t);qi.s et(e.element(),"background-color",o),r.onChange(n,e,o)},onDragStart:function(n,e ){Ai.on(e)},onDragEnd:function(n,e){Ai.off(e)},onInit:function(n,e,t){var o=i(t) ;qi.set(e.element(),"background-color",o)},stepSize:10,min:0,max:360,getInitialV alue:r.getInitialValue,sliderBehaviours:Yo([Bi(Ks.refresh)])}))];var r,i},Js=fun ction(n,o){var e={onChange:function(n,e,t){o.undoManager.transact(function(){o.f ormatter.apply("forecolor",{value:t}),o.nodeChanged()})},getInitialValue:functio n(){return-1}};return Xs(n,"color",function(){return Ys(e)})},Qs=Ut([co("getInit ialValue"),co("onChange"),co("category"),co("sizes")]),Zs=function(n){var r=to(" SizeSlider",Qs,n);return Ks.sketch({dom:{tag:"div",classes:[Fi.resolve("slider-" +r.category+"-size-container"),Fi.resolve("slider"),Fi.resolve("slider-size-cont ainer")]},onChange:function(n,e,t){var o;0<=(o=t)&&o<r.sizes.length&&r.onChange( t)},onDragStart:function(n,e){Ai.on(e)},onDragEnd:function(n,e){Ai.off(e)},min:0 ,max:r.sizes.length-1,stepSize:1,getInitialValue:r.getInitialValue,snapToGrid:!0 ,sliderBehaviours:Yo([Bi(Ks.refresh)]),components:[Ks.parts().spectrum({dom:ls(' <div class="${prefix}-slider-size-container"></div>'),components:[ds('<div class ="${prefix}-slider-size-line"></div>')]}),Ks.parts().thumb({dom:ls('<div class=" ${prefix}-slider-thumb"></div>'),behaviours:Yo([Ai.config({toggleClass:Fi.resolv e("thumb-active")})])})]})},nf=function(n,e,t){for(var o=n.dom(),r=E.isFunction( t)?t:O.constant(!1);o.parentNode;){o=o.parentNode;var i=ue.fromDom(o),u=e(i);if( u.isSome())return u;if(r(i))break}return x.none()},ef=function(n,e,t){return e(n ).orThunk(function(){return t(n)?x.none():nf(n,e,t)})},tf=["9px","10px","11px"," 12px","14px","16px","18px","20px","24px","32px","36px"],of=function(n){var e,t,o =n.selection.getStart(),r=ue.fromDom(o),i=ue.fromDom(n.getBody()),u=(e=function( n){return je(i,n)},t=r,(ve.isElement(t)?x.some(t):qe.parent(t)).map(function(n){ return ef(n,function(n){return qi.getRaw(n,"font-size")},e).getOrThunk(function( ){return qi.get(n,"font-size")})}).getOr(""));return wn.find(tf,function(n){retu rn u===n}).getOr("medium")},rf={candidates:O.constant(tf),get:function(n){var e, t=of(n);return(e=t,wn.findIndex(tf,function(n){return n===e})).getOr(2)},apply:f unction(o,n){var e;(e=n,x.from(tf[e])).each(function(n){var e,t;t=n,of(e=o)!==t& &e.execCommand("fontSize",!1,t)})}},uf=rf.candidates(),af=function(n){return[ds( '<span class="${prefix}-toolbar-button ${prefix}-icon-small-font ${prefix}-icon" ></span>'),(e=n,Zs({onChange:e.onChange,sizes:uf,category:"font",getInitialValue :e.getInitialValue})),ds('<span class="${prefix}-toolbar-button ${prefix}-icon-l arge-font ${prefix}-icon"></span>')];var e},cf=function(n){var e=n.uid!==undefin ed&&Bt(n,"uid")?n.uid:Zc("memento");return{get:function(n){return n.getSystem(). getByUid(e).getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold (x.none,x.some)},asSpec:function(){return D.deepMerge(n,{uid:e})}}};function sf( n,e){return lf(document.createElement("canvas"),n,e)}function ff(n){return n.get Context("2d")}function lf(n,e,t){return n.width=e,n.height=t,n}var df={create:sf ,clone:function(n){var e;return ff(e=sf(n.width,n.height)).drawImage(n,0,0),e},r esize:lf,get2dContext:ff,get3dContext:function(n){var e=null;try{e=n.getContext( "webgl")||n.getContext("experimental-webgl")}catch(t){}return e||(e=null),e}},mf ={getWidth:function(n){return n.naturalWidth||n.width},getHeight:function(n){ret urn n.naturalHeight||n.height}},gf=window.Promise?window.Promise:function(){var n=function(n){if("object"!=typeof this)throw new TypeError("Promises must be con structed via new");if("function"!=typeof n)throw new TypeError("not a function") ;this._state=null,this._value=null,this._deferreds=[],s(n,o(r,this),o(u,this))}, e=n.immediateFn||"function"==typeof setImmediate&&setImmediate||function(n){setT imeout(n,1)};function o(n,e){return function(){n.apply(e,arguments)}}var t=Array .isArray||function(n){return"[object Array]"===Object.prototype.toString.call(n) };function i(o){var r=this;null!==this._state?e(function(){var n=r._state?o.onFu lfilled:o.onRejected;if(null!==n){var e;try{e=n(r._value)}catch(t){return void o .reject(t)}o.resolve(e)}else(r._state?o.resolve:o.reject)(r._value)}):this._defe rreds.push(o)}function r(n){try{if(n===this)throw new TypeError("A promise canno t be resolved with itself.");if(n&&("object"==typeof n||"function"==typeof n)){v ar e=n.then;if("function"==typeof e)return void s(o(e,n),o(r,this),o(u,this))}th is._state=!0,this._value=n,a.call(this)}catch(t){u.call(this,t)}}function u(n){t his._state=!1,this._value=n,a.call(this)}function a(){for(var n=0,e=this._deferr eds.length;n<e;n++)i.call(this,this._deferreds[n]);this._deferreds=null}function c(n,e,t,o){this.onFulfilled="function"==typeof n?n:null,this.onRejected="functi on"==typeof e?e:null,this.resolve=t,this.reject=o}function s(n,e,t){var o=!1;try {n(function(n){o||(o=!0,e(n))},function(n){o||(o=!0,t(n))})}catch(r){if(o)return ;o=!0,t(r)}}return n.prototype["catch"]=function(n){return this.then(null,n)},n. prototype.then=function(t,o){var r=this;return new n(function(n,e){i.call(r,new c(t,o,n,e))})},n.all=function(){var c=Array.prototype.slice.call(1===arguments.l ength&&t(arguments[0])?arguments[0]:arguments);return new n(function(r,i){if(0== =c.length)return r([]);var u=c.length;function a(e,n){try{if(n&&("object"==typeo f n||"function"==typeof n)){var t=n.then;if("function"==typeof t)return void t.c all(n,function(n){a(e,n)},i)}c[e]=n,0==--u&&r(c)}catch(o){i(o)}}for(var n=0;n<c. length;n++)a(n,c[n])})},n.resolve=function(e){return e&&"object"==typeof e&&e.co nstructor===n?e:new n(function(n){n(e)})},n.reject=function(t){return new n(func tion(n,e){e(t)})},n.race=function(r){return new n(function(n,e){for(var t=0,o=r. length;t<o;t++)r[t].then(n,e)})},n}();function pf(){return new(Re.getOrDie("File Reader"))}var hf={atob:function(n){return Re.getOrDie("atob")(n)},requestAnimati onFrame:function(n){Re.getOrDie("requestAnimationFrame")(n)}};function vf(a){ret urn new gf(function(n,e){var t=URL.createObjectURL(a),o=new Image,r=function(){o .removeEventListener("load",i),o.removeEventListener("error",u)};function i(){r( ),n(o)}function u(){r(),e("Unable to load data of type "+a.type+": "+t)}o.addEve ntListener("load",i),o.addEventListener("error",u),o.src=t,o.complete&&i()})}fun ction yf(o){return new gf(function(n,t){var e=new XMLHttpRequest;e.open("GET",o, !0),e.responseType="blob",e.onload=function(){200==this.status&&n(this.response) },e.onerror=function(){var n,e=this;t(0===this.status?((n=new Error("No access t o download image")).code=18,n.name="SecurityError",n):new Error("Error "+e.statu s+" downloading image"))},e.send()})}function bf(n){var e=n.split(","),t=/data:( [^;]+)/.exec(e[0]);if(!t)return x.none();for(var o,r,i,u=t[1],a=e[1],c=hf.atob(a ),s=c.length,f=Math.ceil(s/1024),l=new Array(f),d=0;d<f;++d){for(var m=1024*d,g= Math.min(m+1024,s),p=new Array(g-m),h=m,v=0;h<g;++v,++h)p[v]=c[h].charCodeAt(0); l[d]=(o=p,new(Re.getOrDie("Uint8Array"))(o))}return x.some((r=l,i={type:u},new(R e.getOrDie("Blob"))(r,i)))}function wf(t){return new gf(function(n,e){bf(t).fold (function(){e("uri is not base64: "+t)},n)})}function xf(t){return new gf(functi on(n){var e=new pf;e.onloadend=function(){n(e.result)},e.readAsDataURL(t)})}var Tf,Sf,kf,Cf,Of,Ef,Df,Af,Mf={blobToImage:vf,imageToBlob:function(n){var e=n.src;r eturn 0===e.indexOf("data:")?wf(e):yf(e)},blobToArrayBuffer:function(t){return n ew gf(function(n){var e=new pf;e.onloadend=function(){n(e.result)},e.readAsArray Buffer(t)})},blobToDataUri:xf,blobToBase64:function(n){return xf(n).then(functio n(n){return n.split(",")[1]})},dataUriToBlobSync:bf,canvasToBlob:function(n,t,o) {return t=t||"image/png",HTMLCanvasElement.prototype.toBlob?new gf(function(e){n .toBlob(function(n){e(n)},t,o)}):wf(n.toDataURL(t,o))},canvasToDataURL:function( n,e,t){return e=e||"image/png",n.then(function(n){return n.toDataURL(e,t)})},blo bToCanvas:function(n){return vf(n).then(function(n){var e,t;return e=n,URL.revok eObjectURL(e.src),t=df.create(mf.getWidth(n),mf.getHeight(n)),df.get2dContext(t) .drawImage(n,0,0),t})},uriToBlob:function(n){return 0===n.indexOf("blob:")?yf(n) :0===n.indexOf("data:")?wf(n):null}},Bf=function(n){return Mf.blobToBase64(n)},R f=function(u){var e=cf({dom:{tag:"input",attributes:{accept:"image/*",type:"file ",title:""},styles:{visibility:"hidden",position:"absolute"}},events:xo([Eo(P()) ,So(L(),function(n,e){var t,o,r;(t=e,o=t.event(),r=o.raw().target.files||o.raw() .dataTransfer.files,x.from(r[0])).each(function(n){var r,i;r=u,Bf(i=n).then(func tion(o){r.undoManager.transact(function(){var n=r.editorUpload.blobCache,e=n.cre ate(hc("mceu"),i,o);n.add(e);var t=r.dom.createHTML("img",{src:e.blobUri()});r.i nsertContent(t)})})})})])});return as.sketch({dom:ls('<span class="${prefix}-too lbar-button ${prefix}-icon-image ${prefix}-icon"></span>'),components:[e.asSpec( )],action:function(n){e.get(n).element().dom().click()}})},If=function(n){return n.dom().textContent},Ff=function(n,e){n.dom().textContent=e},Nf=function(n){ret urn 0<n.length},Vf=function(n){return n===undefined||null===n?"":n},Hf=function( e,t,n){return n.text.filter(Nf).fold(function(){return ar.get(n=e,"href")===If(n )?x.some(t):x.none();var n},x.some)},jf=function(n){var e=ue.fromDom(n.selection .getStart());return cu(e,"a")},zf={getInfo:function(n){return jf(n).fold(functio n(){return{url:"",text:n.selection.getContent({format:"text"}),title:"",target:" ",link:x.none()}},function(n){return t=If(e=n),o=ar.get(e,"href"),r=ar.get(e,"ti tle"),i=ar.get(e,"target"),{url:Vf(o),text:t!==o?Vf(t):"",title:Vf(r),target:Vf( i),link:x.some(e)};var e,t,o,r,i})},applyInfo:function(r,i){i.url.filter(Nf).fol d(function(){var e;e=r,i.link.bind(O.identity).each(function(n){e.execCommand("u nlink")})},function(t){var n,e,o=(n=i,(e={}).href=t,n.title.filter(Nf).each(func tion(n){e.title=n}),n.target.filter(Nf).each(function(n){e.target=n}),e);i.link. bind(O.identity).fold(function(){var n=i.text.filter(Nf).getOr(t);r.insertConten t(r.dom.createHTML("a",o,r.dom.encode(n)))},function(e){var n=Hf(e,t,i);ar.setAl l(e,o),n.each(function(n){Ff(e,n)})})})},query:jf},Lf=Ln.detect(),Pf=function(n, e){var t=e.selection.getRng();n(),e.selection.setRng(t)},Wf=function(n,e){(Lf.os .isAndroid()?Pf:O.apply)(e,n)},Uf=function(n,e){var t,o;return{key:n,value:{conf ig:{},me:(t=n,o=xo(e),Qo({fields:[co("enabled")],name:t,active:{events:O.constan t(o)}})),configAsRaw:O.constant({}),initialConfig:{},state:er()}}},Gf=Object.fre eze({getCurrent:function(n,e,t){return e.find()(n)}}),$f=[co("find")],qf=Qo({fie lds:$f,name:"composing",apis:Gf}),_f=is({name:"Container",factory:function(n,e){ return{uid:n.uid(),dom:D.deepMerge({tag:"div",attributes:{role:"presentation"}}, n.dom()),components:n.components(),behaviours:uc(n.containerBehaviours()),events :n.events(),domModification:n.domModification(),eventOrder:n.eventOrder()}},conf igFields:[ho("components",[]),ic("containerBehaviours",[]),ho("events",{}),ho("d omModification",{}),ho("eventOrder",{})]}),Kf=is({name:"DataField",factory:funct ion(t,n){return{uid:t.uid(),dom:t.dom(),behaviours:D.deepMerge(Yo([Ps.config({st ore:{mode:"memory",initialValue:t.getInitialValue()()}}),qf.config({find:x.some} )]),uc(t.dataBehaviours())),events:xo([Do(function(n,e){Ps.setValue(n,t.getIniti alValue()())})])}},configFields:[co("uid"),co("dom"),co("getInitialValue"),ic("d ataBehaviours",[Ps,qf])]}),Xf=function(n,e){if(e===undefined)throw new Error("Va lue.set was undefined");n.dom().value=e},Yf=function(n){return n.dom().value},Jf =O.constant([mo("data"),ho("inputAttributes",{}),ho("inputStyles",{}),ho("type", "input"),ho("tag","input"),ho("inputClasses",[]),fi("onSetValue"),ho("styles",{} ),mo("placeholder"),ho("eventOrder",{}),ic("inputBehaviours",[Ps,zi]),ho("select OnFocus",!0)]),Qf=is({name:"Input",configFields:Jf(),factory:function(n,e){retur n{uid:n.uid(),dom:(o=n,{tag:o.tag(),attributes:D.deepMerge(At([{key:"type",value :o.type()}].concat(o.placeholder().map(function(n){return{key:"placeholder",valu e:n}}).toArray())),o.inputAttributes()),styles:o.inputStyles(),classes:o.inputCl asses()}),components:[],behaviours:(t=n,D.deepMerge(Yo([Ps.config({store:{mode:" manual",initialValue:t.data().getOr(undefined),getValue:function(n){return Yf(n. element())},setValue:function(n,e){Yf(n.element())!==e&&Xf(n.element(),e)}},onSe tValue:t.onSetValue()}),zi.config({onFocus:!1===t.selectOnFocus()?O.noop:functio n(n){var e=n.element(),t=Yf(e);e.dom().setSelectionRange(0,t.length)}})]),uc(t.i nputBehaviours()))),eventOrder:n.eventOrder()};var t,o}}),Zf=Object.freeze({exhi bit:function(n,e){return Vo({attributes:At([{key:e.tabAttr(),value:"true"}])})}} ),nl=[ho("tabAttr","data-alloy-tabstop")],el=Qo({fields:nl,name:"tabstopping",ac tive:Zf}),tl=function(n,e){var t=cf(Qf.sketch({placeholder:e,onSetValue:function (n,e){ne(n,z())},inputBehaviours:Yo([qf.config({find:x.some}),el.config({}),rc.c onfig({mode:"execution"})]),selectOnFocus:!1})),o=cf(as.sketch({dom:ls('<button class="${prefix}-input-container-x ${prefix}-icon-cancel-circle ${prefix}-icon"> </button>'),action:function(n){var e=t.get(n);Ps.setValue(e,"")}}));return{name: n,spec:_f.sketch({dom:ls('<div class="${prefix}-input-container"></div>'),compon ents:[t.asSpec(),o.asSpec()],containerBehaviours:Yo([Ai.config({toggleClass:Fi.r esolve("input-container-empty")}),qf.config({find:function(n){return x.some(t.ge t(n))}}),Uf("input-clearing",[So(z(),function(n){var e=t.get(n);(0<Ps.getValue(e ).length?Ai.off:Ai.on)(n)})])])})}},ol=["input","button","textarea"],rl=function (n,e,t){e.disabled()&&fl(n,e,t)},il=function(n){return wn.contains(ol,ve.name(n. element()))},ul=function(n){ar.set(n.element(),"disabled","disabled")},al=functi on(n){ar.remove(n.element(),"disabled")},cl=function(n){ar.set(n.element(),"aria -disabled","true")},sl=function(n){ar.set(n.element(),"aria-disabled","false")}, fl=function(e,n,t){n.disableClass().each(function(n){xr.add(e.element(),n)}),(il (e)?ul:cl)(e)},ll=function(n){return il(n)?ar.has(n.element(),"disabled"):"true" ===ar.get(n.element(),"aria-disabled")},dl=Object.freeze({enable:function(e,n,t) {n.disableClass().each(function(n){xr.remove(e.element(),n)}),(il(e)?al:sl)(e)}, disable:fl,isDisabled:ll,onLoad:rl}),ml=Object.freeze({exhibit:function(n,e,t){r eturn Vo({classes:e.disabled()?e.disableClass().map(wn.pure).getOr([]):[]})},eve nts:function(n,e){return xo([To($n(),function(n,e){return ll(n)}),jo(n,e,rl)])}} ),gl=[ho("disabled",!1),mo("disableClass")],pl=Qo({fields:gl,name:"disabling",ac tive:ml,apis:dl}),hl=[ic("formBehaviours",[Ps])],vl=function(n){return"<alloy.fi eld."+n+">"},yl=function(r,n,e){return D.deepMerge({"debug.sketcher":{Form:e},ui d:r.uid(),dom:r.dom(),components:n,behaviours:D.deepMerge(Yo([Ps.config({store:{ mode:"manual",getValue:function(n){var e,t,o=(e=r,t=n.getSystem(),M.map(e.partUi ds(),function(n,e){return O.constant(t.getByUid(n))}));return M.map(o,function(n ,e){return n().bind(qf.getCurrent).map(Ps.getValue)})},setValue:function(t,n){M. each(n,function(e,n){zc(t,r,n).each(function(n){qf.getCurrent(n).each(function(n ){Ps.setValue(n,e)})})})}}})]),uc(r.formBehaviours())),apis:{getField:function(n ,e){return zc(n,r,e).bind(qf.getCurrent)}}})},bl=(qc(function(n,e,t){return n.ge tField(e,t)}),function(n){var i,e=(i=[],{field:function(n,e){return i.push(n),t= "form",o=vl(n),r=e,{uiType:gc(),owner:t,name:o,config:r,validated:{}};var t,o,r} ,record:function(){return i}}),t=n(e),o=e.record(),r=wn.map(o,function(n){return Mc({name:n,pname:vl(n)})});return es("form",hl,r,yl,t)}),wl=function(){var e=Or (x.none()),t=function(){e.get().each(function(n){n.destroy()})};return{clear:fun ction(){t(),e.set(x.none())},isSet:function(){return e.get().isSome()},set:funct ion(n){t(),e.set(x.some(n))},run:function(n){e.get().each(n)}}},xl=function(){va r e=Or(x.none());return{clear:function(){e.set(x.none())},set:function(n){e.set( x.some(n))},isSet:function(){return e.get().isSome()},on:function(n){e.get().eac h(n)}}},Tl=function(n){return{xValue:n,points:[]}},Sl=function(n,e){if(e===n.xVa lue)return n;var t=0<e-n.xValue?1:-1,o={direction:t,xValue:e};return{xValue:e,po ints:(0===n.points.length?[]:n.points[n.points.length-1].direction===t?n.points. slice(0,n.points.length-1):n.points).concat([o])}},kl=function(n){if(0===n.point s.length)return 0;var e=n.points[0].direction,t=n.points[n.points.length-1].dire ction;return-1===e&&-1===t?-1:1===e&&1===t?1:0},Cl=function(n){var o="navigateEv ent",e=Gt([co("fields"),ho("maxFieldIndex",n.fields.length-1),co("onExecute"),co ("getInitialValue"),yo("state",function(){return{dialogSwipeState:xl(),currentSc reen:Or(0)}})]),u=to("SerialisedDialog",e,n),r=function(e,n,t){return as.sketch( {dom:ls('<span class="${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:func tion(n){ee(n,o,{direction:e})},buttonBehaviours:Yo([pl.config({disableClass:Fi.r esolve("toolbar-navigation-disabled"),disabled:!t})])})},i=function(n,r){var i=o u(n.element(),"."+Fi.resolve("serialised-dialog-screen"));au(n.element(),"."+Fi. resolve("serialised-dialog-chain")).each(function(o){0<=u.state.currentScreen.ge t()+r&&u.state.currentScreen.get()+r<i.length&&(qi.getRaw(o,"left").each(functio n(n){var e=parseInt(n,10),t=qs(i[0]);qi.set(o,"left",e-r*t+"px")}),u.state.curre ntScreen.set(u.state.currentScreen.get()+r))})},a=function(o){var n=ou(o.element (),"input");x.from(n[u.state.currentScreen.get()]).each(function(n){o.getSystem( ).getByDom(n).each(function(n){var e,t;e=o,t=n.element(),e.getSystem().triggerFo cus(t,e.element())})});var e=s.get(o);Bu.highlightAt(e,u.state.currentScreen.get ())},c=cf(bl(function(t){return{dom:ls('<div class="${prefix}-serialised-dialog" ></div>'),components:[_f.sketch({dom:ls('<div class="${prefix}-serialised-dialog -chain" style="left: 0px; position: absolute;"></div>'),components:wn.map(u.fiel ds,function(n,e){return e<=u.maxFieldIndex?_f.sketch({dom:ls('<div class="${pref ix}-serialised-dialog-screen"></div>'),components:wn.flatten([[r(-1,"previous",0 <e)],[t.field(n.name,n.spec)],[r(1,"next",e<u.maxFieldIndex)]])}):t.field(n.name ,n.spec)})})],formBehaviours:Yo([Bi(function(n,e){var t;t=e,au(n.element(),"."+F i.resolve("serialised-dialog-chain")).each(function(n){qi.set(n,"left",-u.state. currentScreen.get()*t.width+"px")})}),rc.config({mode:"special",focusIn:function (n){a(n)},onTab:function(n){return i(n,1),x.some(!0)},onShiftTab:function(n){ret urn i(n,-1),x.some(!0)}}),Uf("form-events",[Do(function(e,n){u.state.currentScre en.set(0),u.state.dialogSwipeState.clear();var t=s.get(e);Bu.highlightFirst(t),u .getInitialValue(e).each(function(n){Ps.setValue(e,n)})}),Bo(u.onExecute),So(W() ,function(n,e){"left"===e.event().raw().propertyName&&a(n)}),So(o,function(n,e){ var t=e.event().direction();i(n,t)})])])}})),s=cf({dom:ls('<div class="${prefix} -dot-container"></div>'),behaviours:Yo([Bu.config({highlightClass:Fi.resolve("do t-active"),itemClass:Fi.resolve("dot-item")})]),components:wn.bind(u.fields,func tion(n,e){return e<=u.maxFieldIndex?[ds('<div class="${prefix}-dot-item ${prefix }-icon-full-dot ${prefix}-icon"></div>')]:[]})});return{dom:ls('<div class="${pr efix}-serializer-wrapper"></div>'),components:[c.asSpec(),s.asSpec()],behaviours :Yo([rc.config({mode:"special",focusIn:function(n){var e=c.get(n);rc.focusIn(e)} }),Uf("serializer-wrapper-events",[So(B(),function(n,e){u.state.dialogSwipeState .set(Tl(e.event().raw().touches[0].clientX))}),So(R(),function(n,e){u.state.dial ogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeState.set(Sl( n,e.event().raw().touches[0].clientX))})}),So(I(),function(o){u.state.dialogSwip eState.on(function(n){var e=c.get(o),t=-1*kl(n);i(e,t)})})])])}},Ol=G(function(t ,o){return[{label:"the link group",items:[Cl({fields:[tl("url","Type or paste UR L"),tl("text","Link text"),tl("title","Link title"),tl("target","Link target"),( n="link",{name:n,spec:Kf.sketch({dom:{tag:"span",styles:{display:"none"}},getIni tialValue:function(){return x.none()}})})],maxFieldIndex:["url","text","title"," target"].length-1,getInitialValue:function(){return x.some(zf.getInfo(o))},onExe cute:function(n){var e=Ps.getValue(n);zf.applyInfo(o,e),t.restoreToolbar(),o.foc us()}})]}];var n}),El=[{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:"und erline"},{title:"Strikethrough",icon:"strikethrough",format:"strikethrough"},{ti tle:"Superscript",icon:"superscript",format:"superscript"},{title:"Subscript",ic on:"subscript",format:"subscript"},{title:"Code",icon:"code",format:"code"}]},{t itle:"Blocks",items:[{title:"Paragraph",format:"p"},{title:"Blockquote",format:" blockquote"},{title:"Div",format:"div"},{title:"Pre",format:"pre"}]},{title:"Ali gnment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Center ",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",form at:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]}], Dl={events:xo([(Tf=Wn(),Sf=function(n,e){var t,o,r=e.event().originator(),i=e.ev ent().target();return o=i,!(je(t=r,n.element())&&!je(t,o)&&(console.warn(Wn()+" did not get interpreted by the desired target. \nOriginator: "+Yr(r)+"\nTarget: "+Yr(i)+"\nCheck the "+Wn()+" event handlers"),1))},{key:Tf,value:bo({can:Sf})}) ])},Al=O.identity,Ml=qo.exactly(["debugInfo","triggerFocus","triggerEvent","trig gerEscape","addToWorld","removeFromWorld","addToGui","removeFromGui","build","ge tByUid","getByDom","broadcast","broadcastOn","isConnected"]),Bl=function(e){var n=function(n){return function(){throw new Error("The component must be in a cont ext to send: "+n+"\n"+Yr(e().element())+" is not in context.")}};return Ml({debu gInfo:O.constant("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerF ocus"),triggerEscape:n("triggerEscape"),build:n("build"),addToWorld:n("addToWorl d"),removeFromWorld:n("removeFromWorld"),addToGui:n("addToGui"),removeFromGui:n( "removeFromGui"),getByUid:n("getByUid"),getByDom:n("getByDom"),broadcast:n("broa dcast"),broadcastOn:n("broadcastOn"),isConnected:O.constant(!1)})},Rl=function(e ,n){var t=wn.map(n,function(n){return Xt(n.name(),n.name(),mt(),Gt([co("config") ,ho("state",Xo)]))}),o=no("component.behaviours",Gt(t),e.behaviours).fold(functi on(n){throw new Error(ro(n)+"\nComplete spec:\n"+Nt(e,null,2))},O.identity);retu rn{list:n,data:M.map(o,function(n){var e=n();return O.constant(e.map(function(n) {return{config:n.config(),state:n.state().init(n.config())}}))})}},Il=function(n ){return n.list},Fl=function(n){return n.data},Nl=function(n,r){var i={};return M.each(n,function(n,o){M.each(n,function(n,e){var t=Ot(e,[])(i);i[e]=t.concat([r (o,n)])})}),i},Vl=function(n,e){return{name:O.constant(n),modification:e}},Hl=fu nction(n,e,t){return 1<n.length?ct.error('Multiple behaviours have tried to chan ge DOM "'+e+'". The guilty behaviours are: '+Nt(wn.map(n,function(n){return n.na me()}))+". At this stage, this is not supported. Future releases might provide s trategies for resolving this."):0===n.length?ct.value({}):ct.value(n[0].modifica tion().fold(function(){return{}},function(n){return Dt(e,n)}))},jl=function(u,a) {return wn.foldl(u,function(n,e){var t=e.modification().getOr({});return n.bind( function(i){var n=M.mapToArray(t,function(n,e){return i[e]!==undefined?(t=a,o=e, r=u,ct.error("Mulitple behaviours have tried to change the _"+o+'_ "'+t+'". The guilty behaviours are: '+Nt(wn.bind(r,function(n){return n.modification().getOr( {})[o]!==undefined?[n.name()]:[]}),null,2)+". This is not currently supported.") ):ct.value(Dt(e,n));var t,o,r});return Mt(n,i)})},ct.value({})).map(function(n){ return Dt(a,n)})},zl={classes:function(n,e){var t=wn.bind(n,function(n){return n .modification().getOr([])});return ct.value(Dt(e,t))},attributes:jl,styles:jl,do mChildren:Hl,defChildren:Hl,innerHtml:Hl,value:Hl},Ll=function(u,a,n,c){var e=n. slice(0);try{var t=e.sort(function(n,e){var t=n[a](),o=e[a](),r=c.indexOf(t),i=c .indexOf(o);if(-1===r)throw new Error("The ordering for "+u+" does not have an e ntry for "+t+".\nOrder specified: "+Nt(c,null,2));if(-1===i)throw new Error("The ordering for "+u+" does not have an entry for "+o+".\nOrder specified: "+Nt(c,n ull,2));return r<i?-1:i<r?1:0});return ct.value(t)}catch(o){return ct.error([o]) }},Pl=function(n,e){return{handler:O.curry.apply(undefined,[n.handler].concat(e) ),purpose:n.purpose}},Wl=function(n){return n.handler},Ul=function(n,e){return{n ame:O.constant(n),handler:O.constant(e)}},Gl=function(n,e,t){var o,r,i,u=D.deepM erge(t,(o=e,r=n,i={},wn.each(o,function(n){i[n.name()]=n.handlers(r)}),i));retur n Nl(u,Ul)},$l=function(n){var e,o=(e=n,E.isFunction(e)?{can:O.constant(!0),abor t:O.constant(!1),run:e}:e);return function(n,e){var t=Array.prototype.slice.call (arguments,0);o.abort.apply(undefined,t)?e.stop():o.can.apply(undefined,t)&&o.ru n.apply(undefined,t)}},ql=function(n,e,t){var o,r,i=e[t];return i?Ll("Event: "+t ,"name",n,i).map(function(n){var e=wn.map(n,function(n){return n.handler()});ret urn wo(e)}):(o=t,r=n,ct.error(["The event ("+o+') has more than one behaviour th at listens to it.\nWhen this occurs, you must specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that c an trigger it are: '+Nt(wn.map(r,function(n){return n.name()}),null,2)]))},_l=fu nction(n,u){var e=M.mapToArray(n,function(r,i){return(1===r.length?ct.value(r[0] .handler()):ql(r,u,i)).map(function(n){var e,t=$l(n),o=1<r.length?wn.filter(u,fu nction(e){return wn.contains(r,function(n){return n.name()===e})}).join(" > "):r [0].name();return Dt(i,(e=o,{handler:t,purpose:O.constant(e)}))})});return Mt(e, {})},Kl=function(n){return no("custom.definition",Ut([Xt("dom","dom",dt(),Ut([co ("tag"),ho("styles",{}),ho("classes",[]),ho("attributes",{}),mo("value"),mo("inn erHtml")])),co("components"),co("uid"),ho("events",{}),ho("apis",O.constant({})) ,Xt("eventOrder","eventOrder",(e={"alloy.execute":["disabling","alloy.base.behav iour","toggling"],"alloy.focus":["alloy.base.behaviour","focusing","keying"],"al loy.system.init":["alloy.base.behaviour","disabling","toggling","representing"], input:["alloy.base.behaviour","representing","streaming","invalidating"],"alloy. system.detached":["alloy.base.behaviour","representing"]},ft.mergeWithThunk(O.co nstant(e))),uo()),mo("domModification"),pi("originalSpec"),ho("debug.sketcher"," unknown")]),n);var e},Xl=function(n){var e,t={tag:n.dom().tag(),classes:n.dom(). classes(),attributes:D.deepMerge((e=n,Dt(Xc(),e.uid())),n.dom().attributes()),st yles:n.dom().styles(),domChildren:wn.map(n.components(),function(n){return n.ele ment()})};return Fo(D.deepMerge(t,n.dom().innerHtml().map(function(n){return Dt( "innerHtml",n)}).getOr({}),n.dom().value().map(function(n){return Dt("value",n)} ).getOr({})))},Yl=function(e,n){wn.each(n,function(n){xr.add(e,n)})},Jl=function (e,n){wn.each(n,function(n){xr.remove(e,n)})},Ql=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=No(e),Nt(n,null,2)));return e. domChildren().fold(function(){var n=e.defChildren().getOr([]);return wn.map(n,nd )},function(n){return n});var n},Zl=function(n){var e=ue.fromTag(n.tag());ar.set All(e,n.attributes().getOr({})),Yl(e,n.classes().getOr([])),qi.setAll(e,n.styles ().getOr({})),qr(e,n.innerHtml().getOr(""));var t=Ql(n);return Je(e,t),n.value() .each(function(n){Xf(e,n)}),e},nd=function(n){var e=Fo(n);return Zl(e)},ed=funct ion(n){var e,t,o,r=(t=Et(e=n,"behaviours").getOr({}),o=wn.filter(M.keys(t),funct ion(n){return t[n]!==undefined}),wn.map(o,function(n){return e.behaviours[n].me} ));return Rl(n,r)},td=qo.exactly(["getSystem","config","hasConfigured","spec","c onnect","disconnect","element","syncComponents","readState","components","events "]),od=function(t){var n,e,o,r,i,u,a,c,s,f,l=function(){return C},d=Or(Bl(l)),m= eo(Kl(D.deepMerge(t,{behaviours:undefined}))),g=ed(t),p=Il(g),h=Fl(g),v=Xl(m),y= {"alloy.base.modification":(n=m,n.domModification().fold(function(){return Vo({} )},Vo))},b=function(e,n,t,o){var r=D.deepMerge({},n);wn.each(t,function(n){r[n.n ame()]=n.exhibit(e,o)});var i=Nl(r,Vl),u=M.map(i,function(n,e){return wn.bind(n, function(e){return e.modification().fold(function(){return[]},function(n){return [e]})})}),a=M.mapToArray(u,function(e,t){return Et(zl,t).fold(function(){return ct.error("Unknown field type: "+t)},function(n){return n(e,t)})});return Mt(a,{} ).map(Vo)}(h,y,p,v).getOrDie(),w=(e=v,o=b,r=D.deepMerge({tag:e.tag(),classes:o.c lasses().getOr([]).concat(e.classes().getOr([])),attributes:D.merge(e.attributes ().getOr({}),o.attributes().getOr({})),styles:D.merge(e.styles().getOr({}),o.sty les().getOr({}))},o.innerHtml().or(e.innerHtml()).map(function(n){return Dt("inn erHtml",n)}).getOr({}),Ho("domChildren",o.domChildren(),e.domChildren()),Ho("def Children",o.defChildren(),e.defChildren()),o.value().or(e.value()).map(function( n){return Dt("value",n)}).getOr({})),Fo(r)),x=Zl(w),T={"alloy.base.behaviour":(i =m,i.events())},S=(u=h,a=m.eventOrder(),c=p,s=T,f=Gl(u,c,s),_l(f,a)).getOrDie(), k=Or(m.components()),C=td({getSystem:d.get,config:function(n){if(n===_c())return m.apis();var e=h;return(E.isFunction(e[n.name()])?e[n.name()]:function(){throw new Error("Could not find "+n.name()+" in "+Nt(t,null,2))})()},hasConfigured:fun ction(n){return E.isFunction(h[n.name()])},spec:O.constant(t),readState:function (n){return h[n]().map(function(n){return n.state.readState()}).getOr("not enable d")},connect:function(n){d.set(n)},disconnect:function(){d.set(Bl(l))},element:O .constant(x),syncComponents:function(){var n=qe.children(x),e=wn.bind(n,function (n){return d.get().getByDom(n).fold(function(){return[]},function(n){return[n]}) });k.set(e)},components:k.get,events:O.constant(S)});return C},rd=function(n){va r e,t,o=Al(n),r=(e=o,t=Ot("components",[])(e),wn.map(t,ad)),i=D.deepMerge(Dl,o,D t("components",r));return ct.value(od(i))},id=function(n){var e=ue.fromText(n);r eturn ud({element:e})},ud=function(n){var t=oo("external.component",Ut([co("elem ent"),mo("uid")]),n),e=Or(Bl());t.uid().each(function(n){var e;e=t.element(),ar. set(e,Jc,n)});var o=td({getSystem:e.get,config:x.none,hasConfigured:O.constant(! 1),connect:function(n){e.set(n)},disconnect:function(){e.set(Bl(function(){retur n o}))},element:O.constant(t.element()),spec:O.constant(n),readState:O.constant( "No state"),syncComponents:O.noop,components:O.constant([]),events:O.constant({} )});return $c(o)},ad=function(e){return(n=e,Et(n,Uc)).fold(function(){var n=D.de epMerge({uid:Zc("")},e);return rd(n).getOrDie()},function(n){return n});var n},c d=$c,sd="alloy.item-hover",fd="alloy.item-focus",ld=function(n){(jr(n.element()) .isNone()||zi.isFocused(n))&&(zi.isFocused(n)||zi.focus(n),ee(n,sd,{item:n}))},d d=function(n){ee(n,fd,{item:n})},md=O.constant(sd),gd=O.constant(fd),pd=[co("dat a"),co("components"),co("dom"),mo("toggling"),ho("itemBehaviours",{}),ho("ignore Focus",!1),ho("domModification",{}),gi("builder",function(n){return{dom:D.deepMe rge(n.dom(),{attributes:{role:n.toggling().isSome()?"menuitemcheckbox":"menuitem "}}),behaviours:D.deepMerge(Yo([n.toggling().fold(Ai.revoke,function(n){return A i.config(D.deepMerge({aria:{mode:"checked"}},n))}),zi.config({ignore:n.ignoreFoc us(),onFocus:function(n){dd(n)}}),rc.config({mode:"execution"}),Ps.config({store :{mode:"memory",initialValue:n.data()}})]),n.itemBehaviours()),events:xo([(e=Kn( ),o=te,So(e,function(e,t){e.getSystem().getByDom(t.event().target()).each(functi on(n){o(e,n,t)})})),Eo(F()),So(H(),ld),So(qn(),zi.focus)]),components:n.componen ts(),domModification:n.domModification(),eventOrder:n.eventOrder()};var e,o}),ho ("eventOrder",{})],hd=[co("dom"),co("components"),gi("builder",function(n){retur n{dom:n.dom(),components:n.components(),events:xo([(e=qn(),So(e,function(n,e){e. stop()}))])};var e})],vd=O.constant("item-widget"),yd=O.constant([Mc({name:"widg et",overrides:function(e){return{behaviours:Yo([Ps.config({store:{mode:"manual", getValue:function(n){return e.data()},setValue:function(){}}})])}}})]),bd=[co("u id"),co("data"),co("components"),co("dom"),ho("autofocus",!1),ho("domModificatio n",{}),Wc(yd()),gi("builder",function(t){var n=Hc(vd(),t,yd()),e=jc(vd(),t,n.int ernals()),o=function(n){return zc(n,t,"widget").map(function(n){return rc.focusI n(n),n})},r=function(n,e){return Hu(e.event().target())||t.autofocus()&&e.setSou rce(n.element()),x.none()};return D.deepMerge({dom:t.dom(),components:e,domModif ication:t.domModification(),events:xo([Bo(function(n,e){o(n).each(function(n){e. stop()})}),So(H(),ld),So(qn(),function(n,e){t.autofocus()?o(n):zi.focus(n)})]),b ehaviours:Yo([Ps.config({store:{mode:"memory",initialValue:t.data()}}),zi.config ({onFocus:function(n){dd(n)}}),rc.config({mode:"special",focusIn:t.autofocus()?f unction(n){o(n)}:nr(),onLeft:r,onRight:r,onEscape:function(n,e){return zi.isFocu sed(n)||t.autofocus()?(t.autofocus()&&e.setSource(n.element()),x.none()):(zi.foc us(n),x.some(!0))}})])})})],wd=io("type",{widget:bd,item:pd,separator:hd}),xd=O. constant([Rc({factory:{sketch:function(n){var e=oo("menu.spec item",wd,n);return e.builder()(e)}},name:"items",unit:"item",defaults:function(n,e){var t=Zc("");r eturn D.deepMerge({uid:t},e)},overrides:function(n,e){return{type:e.type,ignoreF ocus:n.fakeFocus(),domModification:{classes:[n.markers().item()]}}}})]),Td=O.con stant([co("value"),co("items"),co("dom"),co("components"),ho("eventOrder",{}),ic ("menuBehaviours",[Bu,Ps,qf,rc]),vo("movement",{mode:"menu",moveOnTab:!0},io("mo de",{grid:[hi(),gi("config",function(n,e){return{mode:"flatgrid",selector:"."+n. markers().item(),initSize:{numColumns:e.initSize().numColumns(),numRows:e.initSi ze().numRows()},focusManager:n.focusManager()}})],menu:[ho("moveOnTab",!0),gi("c onfig",function(n,e){return{mode:"menu",selector:"."+n.markers().item(),moveOnTa b:e.moveOnTab(),focusManager:n.focusManager()}})]})),so("markers",ai()),ho("fake Focus",!1),ho("focusManager",Ru()),fi("onHighlight")]),Sd=(O.constant("menu"),O. constant("alloy.menu-focus")),kd=us({name:"Menu",configFields:Td(),partFields:xd (),factory:function(n,e,t,o){return D.deepMerge({dom:D.deepMerge(n.dom(),{attrib utes:{role:"menu"}}),uid:n.uid(),behaviours:D.deepMerge(Yo([Bu.config({highlight Class:n.markers().selectedItem(),itemClass:n.markers().item(),onHighlight:n.onHi ghlight()}),Ps.config({store:{mode:"memory",initialValue:n.value()}}),qf.config( {find:O.identity}),rc.config(n.movement().config()(n,n.movement()))]),uc(n.menuB ehaviours())),events:xo([So(gd(),function(e,t){var n=t.event();e.getSystem().get ByDom(n.target()).each(function(n){Bu.highlight(e,n),t.stop(),ee(e,Sd(),{menu:e, item:n})})}),So(md(),function(n,e){var t=e.event().item();Bu.highlight(n,t)})]), components:e,eventOrder:n.eventOrder()})}}),Cd=function(n,e,t,o){var r=n.getSyst em().build(o);ot(n,r,t)},Od=function(n,e){return n.components()},Ed=Object.freez e({append:function(n,e,t,o){Cd(n,0,Xe.append,o)},prepend:function(n,e,t,o){Cd(n, 0,Xe.prepend,o)},remove:function(n,e,t,o){var r=Od(n,e);wn.find(r,function(n){re turn je(o.element(),n.element())}).each(it)},set:function(e,n,t,o){var r,i,u,a,c ,s;i=(r=e).components(),wn.each(i,rt),Ze.empty(r.element()),r.syncComponents(),u =function(){var n=wn.map(o,e.getSystem().build);wn.each(n,function(n){tt(e,n)})} ,a=e.element(),c=qe.owner(a),s=Hr(c).bind(function(e){var n=function(n){return j e(e,n)};return n(a)?x.some(a):Br.descendant(a,n)}),u(a),s.each(function(e){Hr(c) .filter(function(n){return je(n,e)}).orThunk(function(){Nr(e)})})},contents:Od}) ,Dd=Qo({fields:[],name:"replacing",apis:Ed}),Ad=function(t,o,r,n){return Et(r,n) .bind(function(n){return Et(t,n).bind(function(n){var e=Ad(t,o,r,n);return x.som e([n].concat(e))})}).getOr([])},Md=function(n,e){var t={};M.each(n,function(n,e) {wn.each(n,function(n){t[n]=e})});var o,r=e,i=(o=e,M.tupleMap(o,function(n,e){re turn{k:n,v:e}})),u=M.map(i,function(n,e){return[e].concat(Ad(t,r,i,e))});return M.map(t,function(n){return Et(u,n).getOr([n])})},Bd=O.constant("collapse-item"), Rd=is({name:"TieredMenu",configFields:[mi("onExecute"),mi("onEscape"),di("onOpen Menu"),di("onOpenSubmenu"),fi("onCollapseMenu"),ho("openImmediately",!0),lo("dat a",[co("primary"),co("menus"),co("expansions")]),ho("fakeFocus",!1),fi("onHighli ght"),fi("onHover"),lo("markers",[co("backgroundMenu")].concat(ii()).concat(ui() )),co("dom"),ho("navigateOnHover",!0),ho("stayInDom",!1),ic("tmenuBehaviours",[r c,Bu,qf,Dd]),ho("eventOrder",{})],apis:{collapseMenu:function(n,e){n.collapseMen u(e)}},factory:function(u,r){var a,c,s,f,l,n,i=function(o,n){return M.map(n,func tion(n,e){var t=kd.sketch(D.deepMerge(n,{value:e,items:n.items,markers:St(r.mark ers,["item","selectedItem"]),fakeFocus:u.fakeFocus(),onHighlight:u.onHighlight() ,focusManager:u.fakeFocus()?{get:function(n){return Bu.getHighlighted(n).map(fun ction(n){return n.element()})},set:function(e,n){e.getSystem().getByDom(n).fold( O.noop,function(n){Bu.highlight(e,n)})}}:Ru()}));return o.getSystem().build(t)}) },d=(a=Or({}),c=Or({}),s=Or({}),f=Or(x.none()),l=Or(O.constant([])),{setContents :function(n,e,t,o){f.set(x.some(n)),a.set(t),c.set(e),l.set(o);var r=o(e),i=Md(r ,t);s.set(i)},expand:function(t){return Et(a.get(),t).map(function(n){var e=Et(s .get(),t).getOr([]);return[n].concat(e)})},refresh:function(n){return Et(s.get() ,n)},collapse:function(n){return Et(s.get(),n).bind(function(n){return 1<n.lengt h?x.some(n.slice(1)):x.none()})},lookupMenu:n=function(n){return Et(c.get(),n)}, otherMenus:function(n){var e=l.get()(c.get());return wn.difference(M.keys(e),n)} ,getPrimary:function(){return f.get().bind(n)},getMenus:function(){return c.get( )},clear:function(){a.set({}),c.set({}),s.set({}),f.set(x.none())},isClear:funct ion(){return f.get().isNone()}}),m=function(n){return Ps.getValue(n).value},g=fu nction(n,e){return M.map(u.data().menus(),function(n,e){return wn.bind(n.items,f unction(n){return"separator"===n.type?[]:[n.data.value]})})},p=function(e,n){Bu. highlight(e,n),Bu.getHighlighted(n).orThunk(function(){return Bu.getFirst(n)}).e ach(function(n){oe(e,n.element(),qn())})},h=function(n,e){return Qr(wn.map(e,n.l ookupMenu))},v=function(o,r,i){return x.from(i[0]).bind(r.lookupMenu).map(functi on(n){var e=h(r,i.slice(1));wn.each(e,function(n){xr.add(n.element(),u.markers() .backgroundMenu())}),we.inBody(n.element())||Dd.append(o,cd(n)),Jl(n.element(),[ u.markers().backgroundMenu()]),p(o,n);var t=h(r,r.otherMenus(i));return wn.each( t,function(n){Jl(n.element(),[u.markers().backgroundMenu()]),u.stayInDom()||Dd.r emove(o,n)}),n})},y=function(e,t){var n=m(t);return d.expand(n).bind(function(n) {return x.from(n[0]).bind(d.lookupMenu).each(function(n){we.inBody(n.element())| |Dd.append(e,cd(n)),u.onOpenSubmenu()(e,t,n),Bu.highlightFirst(n)}),v(e,d,n)})}, o=function(e,t){var n=m(t);return d.collapse(n).bind(function(n){return v(e,d,n) .map(function(n){return u.onCollapseMenu()(e,t,n),n})})},e=function(t){return fu nction(e,n){return cu(n.getSource(),"."+u.markers().item()).bind(function(n){ret urn e.getSystem().getByDom(n).bind(function(n){return t(e,n)})})}},t=xo([So(Sd() ,function(n,e){var t=e.event().menu();Bu.highlight(n,t)}),Bo(function(e,n){var t =n.event().target();return e.getSystem().getByDom(t).bind(function(n){return 0== =m(n).indexOf("collapse-item")?o(e,n):y(e,n).orThunk(function(){return u.onExecu te()(e,n)})})}),Do(function(e,n){var t,o;(t=e,o=i(t,u.data().menus()),d.setConte nts(u.data().primary(),o,u.data().expansions(),function(n){return g(t,n)}),d.get Primary()).each(function(n){Dd.append(e,cd(n)),u.openImmediately()&&(p(e,n),u.on OpenMenu()(e,n))})})].concat(u.navigateOnHover()?[So(md(),function(n,e){var t,o, r=e.event().item();t=n,o=m(r),d.refresh(o).bind(function(n){return v(t,d,n)}),y( n,r),u.onHover()(n,r)})]:[]));return{uid:u.uid(),dom:u.dom(),behaviours:D.deepMe rge(Yo([rc.config({mode:"special",onRight:e(function(n,e){return Hu(e.element()) ?x.none():y(n,e)}),onLeft:e(function(n,e){return Hu(e.element())?x.none():o(n,e) }),onEscape:e(function(n,e){return o(n,e).orThunk(function(){return u.onEscape() (n,e)})}),focusIn:function(e,n){d.getPrimary().each(function(n){oe(e,n.element() ,qn())})}}),Bu.config({highlightClass:u.markers().selectedMenu(),itemClass:u.mar kers().menu()}),qf.config({find:function(n){return Bu.getHighlighted(n)}}),Dd.co nfig({})]),uc(u.tmenuBehaviours())),eventOrder:u.eventOrder(),apis:{collapseMenu :function(e){Bu.getHighlighted(e).each(function(n){Bu.getHighlighted(n).each(fun ction(n){o(e,n)})})}},events:t}},extraApis:{tieredData:function(n,e,t){return{pr imary:n,menus:e,expansions:t}},singleData:function(n,e){return{primary:n,menus:D t(n,e),expansions:{}}},collapseItem:function(n){return{value:hc(Bd()),text:n}}}} ),Id=function(n,e,t,o){return Et(e.routes(),o.start()).map(O.apply).bind(functio n(n){return Et(n,o.destination()).map(O.apply)})},Fd=function(n,e,t,o){return Id (0,e,0,o).bind(function(e){return e.transition().map(function(n){return{transiti on:O.constant(n),route:O.constant(e)}})})},Nd=function(t,o,n){var e,r,i;(e=t,r=o ,i=n,Vd(e,r,i).bind(function(n){return Fd(e,r,i,n)})).each(function(n){var e=n.t ransition();xr.remove(t.element(),e.transitionClass()),ar.remove(t.element(),o.d estinationAttr())})},Vd=function(n,e,t){var o=n.element();return ar.has(o,e.dest inationAttr())?x.some({start:O.constant(ar.get(n.element(),e.stateAttr())),desti nation:O.constant(ar.get(n.element(),e.destinationAttr()))}):x.none()},Hd=functi on(n,e,t,o){Nd(n,e,t),ar.has(n.element(),e.stateAttr())&&ar.get(n.element(),e.st ateAttr())!==o&&e.onFinish()(n,o),ar.set(n.element(),e.stateAttr(),o)},jd=Object .freeze({findRoute:Id,disableTransition:Nd,getCurrentRoute:Vd,jumpTo:Hd,progress To:function(t,o,r,i){var n,e;e=o,ar.has((n=t).element(),e.destinationAttr())&&(a r.set(n.element(),e.stateAttr(),ar.get(n.element(),e.destinationAttr())),ar.remo ve(n.element(),e.destinationAttr()));var u,a,c,s=(u=t,a=o,c=i,{start:O.constant( ar.get(u.element(),a.stateAttr())),destination:O.constant(c)});Fd(t,o,r,s).fold( function(){Hd(t,o,r,i)},function(n){Nd(t,o,r);var e=n.transition();xr.add(t.elem ent(),e.transitionClass()),ar.set(t.element(),o.destinationAttr(),i)})},getState :function(n,e,t){var o=n.element();return ar.has(o,e.stateAttr())?x.some(ar.get( o,e.stateAttr())):x.none()}}),zd=Object.freeze({events:function(r,i){return xo([ So(W(),function(t,n){var o=n.event().raw();Vd(t,r,i).each(function(e){Id(0,r,0,e ).each(function(n){n.transition().each(function(n){o.propertyName===n.property() &&(Hd(t,r,i,e.destination()),r.onTransition()(t,e))})})})}),Do(function(n,e){Hd( n,r,i,r.initialState())})])}}),Ld=[ho("destinationAttr","data-transitioning-dest ination"),ho("stateAttr","data-transitioning-state"),co("initialState"),fi("onTr ansition"),fi("onFinish"),so("routes",qt(ct.value,qt(ct.value,Ut([po("transition ",[co("property"),co("transitionClass")])]))))],Pd=Qo({fields:Ld,name:"transitio ning",active:zd,apis:jd,extra:{createRoutes:function(n){var o={};return M.each(n ,function(n,e){var t=e.split("<->");o[t[0]]=Dt(t[1],n),o[t[1]]=Dt(t[0],n)}),o},c reateBistate:function(n,e,t){return At([{key:n,value:Dt(e,t)},{key:e,value:Dt(n, t)}])},createTristate:function(n,e,t,o){return At([{key:n,value:At([{key:e,value :o},{key:t,value:o}])},{key:e,value:At([{key:n,value:o},{key:t,value:o}])},{key: t,value:At([{key:n,value:o},{key:e,value:o}])}])}}}),Wd=Fi.resolve("scrollable") ,Ud={register:function(n){xr.add(n,Wd)},deregister:function(n){xr.remove(n,Wd)}, scrollable:O.constant(Wd)},Gd=function(n){return Et(n,"format").getOr(n.title)}, $d=function(n,e,t,o,r){return{data:{value:n,text:e},type:"item",dom:{tag:"div",c lasses:r?[Fi.resolve("styles-item-is-menu")]:[]},toggling:{toggleOnExecute:!1,to ggleClass:Fi.resolve("format-matches"),selected:t},itemBehaviours:Yo(r?[]:[Mi(n, function(n,e){(e?Ai.on:Ai.off)(n)})]),components:[{dom:{tag:"div",attributes:{st yle:o},innerHtml:e}}]}},qd=function(n,e,t,o){return{value:n,dom:{tag:"div"},comp onents:[as.sketch({dom:{tag:"div",classes:[Fi.resolve("styles-collapser")]},comp onents:o?[{dom:{tag:"span",classes:[Fi.resolve("styles-collapse-icon")]}},id(n)] :[id(n)],action:function(n){if(o){var e=t().get(n);Rd.collapseMenu(e)}}}),{dom:{ tag:"div",classes:[Fi.resolve("styles-menu-items-container")]},components:[kd.pa rts().items({})],behaviours:Yo([Uf("adhoc-scrollable-menu",[Do(function(n,e){qi. set(n.element(),"overflow-y","auto"),qi.set(n.element(),"-webkit-overflow-scroll ing","touch"),Ud.register(n.element())}),Ao(function(n){qi.remove(n.element(),"o verflow-y"),qi.remove(n.element(),"-webkit-overflow-scrolling"),Ud.deregister(n. element())})])])}],items:e,menuBehaviours:Yo([Pd.config({initialState:"after",ro utes:Pd.createTristate("before","current","after",{transition:{property:"transfo rm",transitionClass:"transitioning"}})})])}},_d=function(o){var r,i,n,e,t,u=(r=o .formats,i=function(){return a},n=qd("Styles",[].concat(wn.map(r.items,function( n){return $d(Gd(n),n.title,n.isSelected(),n.getPreview(),Bt(r.expansions,Gd(n))) })),i,!1),e=M.map(r.menus,function(n,e){var t=wn.map(n,function(n){return $d(Gd( n),n.title,n.isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.g etPreview():"",Bt(r.expansions,Gd(n)))});return qd(e,t,i,!0)}),t=D.deepMerge(e,D t("styles",n)),{tmenu:Rd.tieredData("styles",t,r.expansions)}),a=cf(Rd.sketch({d om:{tag:"div",classes:[Fi.resolve("styles-menu")]},components:[],fakeFocus:!0,st ayInDom:!0,onExecute:function(n,e){var t=Ps.getValue(e);o.handle(e,t.value)},onE scape:function(){},onOpenMenu:function(n,e){var t=qs(n.element());$s(e.element() ,t),Pd.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var o=qs(n.element()), r=uu(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().getByDom(r). getOrDie();$s(t.element(),o),Pd.progressTo(i,"before"),Pd.jumpTo(t,"after"),Pd.p rogressTo(t,"current")},onCollapseMenu:function(n,e,t){var o=uu(e.element(),'[ro le="menu"]').getOrDie("hacky"),r=n.getSystem().getByDom(o).getOrDie();Pd.progres sTo(r,"after"),Pd.progressTo(t,"current")},navigateOnHover:!1,openImmediately:!0 ,data:u.tmenu,markers:{backgroundMenu:Fi.resolve("styles-background-menu"),menu: Fi.resolve("styles-menu"),selectedMenu:Fi.resolve("styles-selected-menu"),item:F i.resolve("styles-item"),selectedItem:Fi.resolve("styles-selected-item")}}));ret urn a.asSpec()},Kd=function(n){return Bt(n,"items")?(e=n,t=D.deepMerge(kt(e,["it ems"]),{menu:!0}),o=Xd(e.items),{item:t,menus:D.deepMerge(o.menus,Dt(e.title,o.i tems)),expansions:D.deepMerge(o.expansions,Dt(e.title,e.title))}):{item:n,menus: {},expansions:{}};var e,t,o},Xd=function(n){return wn.foldr(n,function(n,e){var t=Kd(e);return{menus:D.deepMerge(n.menus,t.menus),items:[t.item].concat(n.items) ,expansions:D.deepMerge(n.expansions,t.expansions)}},{menus:{},expansions:{},ite ms:[]})},Yd={expand:Xd},Jd=function(a,n){var c=function(n){return function(){ret urn a.formatter.match(n)}},s=function(n){return function(){return a.formatter.ge tCssText(n)}},e=Et(n,"style_formats").getOr(El),f=function(n){return wn.map(n,fu nction(n){if(Bt(n,"items")){var e=f(n.items);return D.deepMerge((u=n,D.deepMerge (u,{isSelected:O.constant(!1),getPreview:O.constant("")})),{items:e})}return Bt( n,"format")?(i=n,D.deepMerge(i,{isSelected:c(i.format),getPreview:s(i.format)})) :(o=hc((t=n).title),r=D.deepMerge(t,{format:o,isSelected:c(o),getPreview:s(o)}), a.formatter.register(o,r),r);var t,o,r,i,u})};return f(e)},Qd=function(t,n,o){va r e,r,i,u=(e=t,i=(r=function(n){return wn.bind(n,function(n){return n.items!==un defined?0<r(n.items).length?[n]:[]:!Bt(n,"format")||e.formatter.canApply(n.forma t)?[n]:[]})})(n),Yd.expand(i));return _d({formats:u,handle:function(n,e){t.undoM anager.transact(function(){Ai.isOn(n)?t.formatter.remove(e):t.formatter.apply(e) }),o()}})},Zd=["undo","bold","italic","link","image","bullist","styleselect"],nm =function(n){var e=n.replace(/\|/g," ").trim();return 0<e.length?e.split(/\s+/): []},em=function(n){return wn.bind(n,function(n){return E.isArray(n)?em(n):nm(n)} )},tm=function(n){var e=n.toolbar!==undefined?n.toolbar:Zd;return E.isArray(e)?e m(e):nm(e)},om=function(o,r){var n=function(n){return function(){return ps.forTo olbarCommand(r,n)}},e=function(n){return function(){return ps.forToolbarStateCom mand(r,n)}},t=function(n,e,t){return function(){return ps.forToolbarStateAction( r,n,e,t)}},i=n("undo"),u=n("redo"),a=e("bold"),c=e("italic"),s=e("underline"),f= n("removeformat"),l=t("unlink","link",function(){r.execCommand("unlink",null,!1) }),d=t("unordered-list","ul",function(){r.execCommand("InsertUnorderedList",null ,!1)}),m=t("ordered-list","ol",function(){r.execCommand("InsertOrderedList",null ,!1)}),g=Jd(r,r.settings),p=function(){return Qd(r,g,function(){r.fire("scrollIn toView")})},h=function(n,e){return{isSupported:function(){return n.forall(functi on(n){return Bt(r.buttons,n)})},sketch:e}};return{undo:h(x.none(),i),redo:h(x.no ne(),u),bold:h(x.none(),a),italic:h(x.none(),c),underline:h(x.none(),s),removefo rmat:h(x.none(),f),link:h(x.none(),function(){return e=o,t=r,ps.forToolbarStateA ction(t,"link","link",function(){var n=Ol(e,t);e.setContextToolbar(n),Wf(t,funct ion(){e.focusToolbar()}),zf.query(t).each(function(n){t.selection.select(n.dom() )})});var e,t}),unlink:h(x.none(),l),image:h(x.none(),function(){return Rf(r)}), bullist:h(x.some("bullist"),d),numlist:h(x.some("numlist"),m),fontsizeselect:h(x .none(),function(){return e=r,n={onChange:function(n){rf.apply(e,n)},getInitialV alue:function(){return rf.get(e)}},Xs(o,"font-size",function(){return af(n)});va r e,n}),forecolor:h(x.none(),function(){return Js(o,r)}),styleselect:h(x.none(), function(){return ps.forToolbar("style-formats",function(n){r.fire("toReading"), o.dropup().appear(p,Ai.on,n)},Yo([Ai.config({toggleClass:Fi.resolve("toolbar-but ton-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),yi.config({channels:At ([Ri(Wr.orientationChanged(),Ai.off),Ri(Wr.dropupDismissed(),Ai.off)])})]))})}}, rm=function(n,t){var e=tm(n),o={};return wn.bind(e,function(n){var e=!Bt(o,n)&&B t(t,n)&&t[n].isSupported()?[t[n].sketch()]:[];return o[n]=!0,e})},im=function(m, g){return function(n){if(m(n)){var e,t,o,r,i,u,a,c=ue.fromDom(n.target),s=functi on(){n.stopPropagation()},f=function(){n.preventDefault()},l=O.compose(f,s),d=(e =c,t=n.clientX,o=n.clientY,r=s,i=f,u=l,a=n,{target:O.constant(e),x:O.constant(t) ,y:O.constant(o),stop:r,prevent:i,kill:u,raw:O.constant(a)});g(d)}}},um=function (n,e,t,o,r){var i=im(t,o);return n.dom().addEventListener(e,i,r),{unbind:O.curry (am,n,e,i,r)}},am=function(n,e,t,o){n.dom().removeEventListener(e,t,o)},cm=funct ion(n,e,t,o){return um(n,e,t,o,!1)},sm=function(n,e,t,o){return um(n,e,t,o,!0)}, fm=O.constant(!0),lm=function(n,e,t){return cm(n,e,fm,t)},dm=function(n,e,t){ret urn sm(n,e,fm,t)},mm=function(n){var e=n.matchMedia("(orientation: portrait)").m atches;return{isPortrait:O.constant(e)}},gm=mm,pm=function(o,e){var n=ue.fromDom (o),r=null,t=lm(n,"orientationchange",function(){clearInterval(r);var n=mm(o);e. onChange(n),i(function(){e.onReady(n)})}),i=function(n){clearInterval(r);var e=o .innerHeight,t=0;r=setInterval(function(){e!==o.innerHeight?(clearInterval(r),n( x.some(o.innerHeight))):20<t&&(clearInterval(r),n(x.none())),t++},50)};return{on Adjustment:i,destroy:function(){t.unbind()}}},hm=function(n){var e=Ln.detect().o s.isiOS(),t=mm(n).isPortrait();return e&&!t?n.screen.height:n.screen.width},vm=f unction(n){return n.raw().touches===undefined||1!==n.raw().touches.length?x.none ():x.some(n.raw().touches[0])},ym=function(t){var o,r,i,u=Or(x.none()),a=(o=func tion(n){u.set(x.none()),t.triggerEvent(Xn(),n)},r=400,i=null,{cancel:function(){ null!==i&&(clearTimeout(i),i=null)},schedule:function(){for(var n=[],e=0;e<argum ents.length;e++)n[e]=arguments[e];var t=arguments;i=setTimeout(function(){o.appl y(null,t),i=null},r)}}),c=At([{key:B(),value:function(t){return vm(t).each(funct ion(n){a.cancel();var e={x:O.constant(n.clientX),y:O.constant(n.clientY),target: t.target};a.schedule(t),u.set(x.some(e))}),x.none()}},{key:R(),value:function(n) {return a.cancel(),vm(n).each(function(i){u.get().each(function(n){var e,t,o,r;e =i,t=n,o=Math.abs(e.clientX-t.x()),r=Math.abs(e.clientY-t.y()),(5<o||5<r)&&u.set (x.none())})}),x.none()}},{key:I(),value:function(e){return a.cancel(),u.get().f ilter(function(n){return je(n.target(),e.target())}).map(function(n){return t.tr iggerEvent(_n(),e)})}}]);return{fireIfReady:function(e,n){return Et(c,n).bind(fu nction(n){return n(e)})}}},bm=function(t){var e=ym({triggerEvent:function(n,e){t .onTapContent(e)}});return{fireTouchstart:function(n){e.fireIfReady(n,"touchstar t")},onTouchend:function(){return lm(t.body(),"touchend",function(n){e.fireIfRea dy(n,"touchend")})},onTouchmove:function(){return lm(t.body(),"touchmove",functi on(n){e.fireIfReady(n,"touchmove")})}}},wm=6<=Ln.detect().os.version.major,xm=fu nction(o,e,t){var r=bm(o),i=qe.owner(e),u=function(n){return!je(n.start(),n.fini sh())||n.soffset()!==n.foffset()},n=function(){var n=o.doc().dom().hasFocus()&&o .getSelection().exists(u);t.getByDom(e).each(!0===(n||Hr(i).filter(function(n){r eturn"input"===ve.name(n)}).exists(function(n){return n.dom().selectionStart!==n .dom().selectionEnd}))?Ai.on:Ai.off)},a=[lm(o.body(),"touchstart",function(n){o. onTouchContent(),r.fireTouchstart(n)}),r.onTouchmove(),r.onTouchend(),lm(e,"touc hstart",function(n){o.onTouchToolstrip()}),o.onToReading(function(){Vr(o.body()) }),o.onToEditing(O.noop),o.onScrollToCursor(function(n){n.preventDefault(),o.get CursorBox().each(function(n){var e=o.win(),t=n.top()>e.innerHeight||n.bottom()>e .innerHeight?n.bottom()-e.innerHeight+50:0;0!==t&&e.scrollTo(e.pageXOffset,e.pag eYOffset+t)})})].concat(!0===wm?[]:[lm(ue.fromDom(o.win()),"blur",function(){t.g etByDom(e).each(Ai.off)}),lm(i,"select",n),lm(o.doc(),"selectionchange",n)]);ret urn{destroy:function(){wn.each(a,function(n){n.unbind()})}}},Tm=function(n,e){va r t=parseInt(ar.get(n,e),10);return isNaN(t)?0:t},Sm=(kf=ve.isText,Cf="text",Of= function(n){return kf(n)?x.from(n.dom().nodeValue):x.none()},Ef=Ln.detect().brow ser,{get:function(n){if(!kf(n))throw new Error("Can only get "+Cf+" value of a " +Cf+" node");return Df(n).getOr("")},getOption:Df=Ef.isIE()&&10===Ef.version.maj or?function(n){try{return Of(n)}catch(e){return x.none()}}:Of,set:function(n,e){ if(!kf(n))throw new Error("Can only set raw "+Cf+" value of a "+Cf+" node");n.do m().nodeValue=e}}),km=function(n){return Sm.getOption(n)},Cm=function(n){return" img"===ve.name(n)?1:km(n).fold(function(){return qe.children(n).length},function (n){return n.length})},Om=Cm,Em=st([{before:["element"]},{on:["element","offset" ]},{after:["element"]}]),Dm={before:Em.before,on:Em.on,after:Em.after,cata:funct ion(n,e,t,o){return n.fold(e,t,o)},getStart:function(n){return n.fold(O.identity ,O.identity,O.identity)}},Am=st([{domRange:["rng"]},{relative:["startSitu","fini shSitu"]},{exact:["start","soffset","finish","foffset"]}]),Mm=Ee.immutable("star t","soffset","finish","foffset"),Bm={domRange:Am.domRange,relative:Am.relative,e xact:Am.exact,exactFromRange:function(n){return Am.exact(n.start(),n.soffset(),n .finish(),n.foffset())},range:Mm,getWin:function(n){var e=n.match({domRange:func tion(n){return ue.fromDom(n.startContainer)},relative:function(n,e){return Dm.ge tStart(n)},exact:function(n,e,t,o){return n}});return qe.defaultView(e)}},Rm=fun ction(n,e,t,o){var r=qe.owner(n).dom().createRange();return r.setStart(n.dom(),e ),r.setEnd(t.dom(),o),r},Im=function(n,e,t,o){var r=Rm(n,e,t,o),i=je(n,t)&&e===o ;return r.collapsed&&!i},Fm=function(n,e){n.selectNodeContents(e.dom())},Nm=func tion(n){n.deleteContents()},Vm=function(n){return{left:O.constant(n.left),top:O. constant(n.top),right:O.constant(n.right),bottom:O.constant(n.bottom),width:O.co nstant(n.width),height:O.constant(n.height)}},Hm={create:function(n){return n.do cument.createRange()},replaceWith:function(n,e){Nm(n),n.insertNode(e.dom())},sel ectNodeContents:function(n,e){var t=n.document.createRange();return Fm(t,e),t},s electNodeContentsUsing:Fm,relativeToNative:function(n,e,t){var o,r,i=n.document. createRange();return o=i,e.fold(function(n){o.setStartBefore(n.dom())},function( n,e){o.setStart(n.dom(),e)},function(n){o.setStartAfter(n.dom())}),r=i,t.fold(fu nction(n){r.setEndBefore(n.dom())},function(n,e){r.setEnd(n.dom(),e)},function(n ){r.setEndAfter(n.dom())}),i},exactToNative:function(n,e,t,o,r){var i=n.document .createRange();return i.setStart(e.dom(),t),i.setEnd(o.dom(),r),i},deleteContent s:Nm,cloneFragment:function(n){var e=n.cloneContents();return ue.fromDom(e)},get FirstRect:function(n){var e=n.getClientRects(),t=0<e.length?e[0]:n.getBoundingCl ientRect();return 0<t.width||0<t.height?x.some(t).map(Vm):x.none()},getBounds:fu nction(n){var e=n.getBoundingClientRect();return 0<e.width||0<e.height?x.some(e) .map(Vm):x.none()},isWithin:function(n,e){return e.compareBoundaryPoints(n.END_T O_START,n)<1&&-1<e.compareBoundaryPoints(n.START_TO_END,n)},toString:function(n) {return n.toString()}},jm=st([{ltr:["start","soffset","finish","foffset"]},{rtl: ["start","soffset","finish","foffset"]}]),zm=function(n,e,t){return e(ue.fromDom (t.startContainer),t.startOffset,ue.fromDom(t.endContainer),t.endOffset)},Lm=fun ction(n,e){var r,t,o,i=(r=n,e.match({domRange:function(n){return{ltr:O.constant( n),rtl:x.none}},relative:function(n,e){return{ltr:G(function(){return Hm.relativ eToNative(r,n,e)}),rtl:G(function(){return x.some(Hm.relativeToNative(r,e,n))})} },exact:function(n,e,t,o){return{ltr:G(function(){return Hm.exactToNative(r,n,e, t,o)}),rtl:G(function(){return x.some(Hm.exactToNative(r,t,o,n,e))})}}}));return (o=(t=i).ltr()).collapsed?t.rtl().filter(function(n){return!1===n.collapsed}).ma p(function(n){return jm.rtl(ue.fromDom(n.endContainer),n.endOffset,ue.fromDom(n. startContainer),n.startOffset)}).getOrThunk(function(){return zm(0,jm.ltr,o)}):z m(0,jm.ltr,o)},Pm=(jm.ltr,jm.rtl,Lm),Wm=function(i,n){return Lm(i,n).match({ltr: function(n,e,t,o){var r=i.document.createRange();return r.setStart(n.dom(),e),r. setEnd(t.dom(),o),r},rtl:function(n,e,t,o){var r=i.document.createRange();return r.setStart(t.dom(),o),r.setEnd(n.dom(),e),r}})},Um=(document.caretPositionFromP oint||document.caretRangeFromPoint,function(n,e){var t=ve.name(n);return"input"= ==t?Dm.after(n):wn.contains(["br","img"],t)?0===e?Dm.before(n):Dm.after(n):Dm.on (n,e)}),Gm=function(n,e,t,o){var r=Um(n,e),i=Um(t,o);return Bm.relative(r,i)},$m =Gm,qm=function(n,e){x.from(n.getSelection()).each(function(n){n.removeAllRanges (),n.addRange(e)})},_m=function(n,e,t,o,r){var i=Hm.exactToNative(n,e,t,o,r);qm( n,i)},Km=function(i,n){return Pm(i,n).match({ltr:function(n,e,t,o){_m(i,n,e,t,o) },rtl:function(n,e,t,o){var r=i.getSelection();r.setBaseAndExtent?r.setBaseAndEx tent(n.dom(),e,t.dom(),o):r.extend?(r.collapse(n.dom(),e),r.extend(t.dom(),o)):_ m(i,t,o,n,e)}})},Xm=function(n){var e=ue.fromDom(n.anchorNode),t=ue.fromDom(n.fo cusNode);return Im(e,n.anchorOffset,t,n.focusOffset)?x.some(Bm.range(ue.fromDom( n.anchorNode),n.anchorOffset,ue.fromDom(n.focusNode),n.focusOffset)):function(n) {if(0<n.rangeCount){var e=n.getRangeAt(0),t=n.getRangeAt(n.rangeCount-1);return x.some(Bm.range(ue.fromDom(e.startContainer),e.startOffset,ue.fromDom(t.endConta iner),t.endOffset))}return x.none()}(n)},Ym=function(n){return x.from(n.getSelec tion()).filter(function(n){return 0<n.rangeCount}).bind(Xm)},Jm=function(n,e,t,o ,r){var i=$m(e,t,o,r);Km(n,i)},Qm=Ym,Zm=function(n){return Ym(n).map(function(n) {return Bm.exact(n.start(),n.soffset(),n.finish(),n.foffset())})},ng=function(n) {n.getSelection().removeAllRanges()},eg=function(n,e){var t=Wm(n,e);return Hm.ge tFirstRect(t)},tg=function(n){return{left:n.left,top:n.top,right:n.right,bottom: n.bottom,width:O.constant(2),height:n.height}},og=function(n){return{left:O.cons tant(n.left),top:O.constant(n.top),right:O.constant(n.right),bottom:O.constant(n .bottom),width:O.constant(n.width),height:O.constant(n.height)}},rg=function(n){ var e=n.getSelection();return e!==undefined&&0<e.rangeCount?function(t){if(t.col lapsed){var o=ue.fromDom(t.startContainer);return qe.parent(o).bind(function(n){ var e=Bm.exact(o,t.startOffset,n,Om(n));return eg(t.startContainer.ownerDocument .defaultView,e).map(tg).map(wn.pure)}).getOr([])}return wn.map(t.getClientRects( ),og)}(e.getRangeAt(0)):[]},ig=function(n){n.focus();var e=ue.fromDom(n.document .body);(Hr().exists(function(n){return wn.contains(["input","textarea"],ve.name( n))})?function(n){setTimeout(function(){n()},0)}:O.apply)(function(){Hr().each(V r),Nr(e)})},ug="data-"+Fi.resolve("last-outer-height"),ag=function(n,e){ar.set(n ,ug,e)},cg=function(n){return{top:O.constant(n.top()),bottom:O.constant(n.top()+ n.height())}},sg=function(n,e){var t=Tm(e,ug),o=n.innerHeight;return o<t?x.some( t-o):x.none()},fg=function(n,u){var e=ue.fromDom(u.document.body),t=lm(ue.fromDo m(n),"resize",function(){sg(n,e).each(function(i){var n,e;(n=u,e=rg(n),0<e.lengt h?x.some(e[0]).map(cg):x.none()).each(function(n){var e,t,o,r=(e=u,o=i,(t=n).top ()>e.innerHeight||t.bottom()>e.innerHeight?Math.min(o,t.bottom()-e.innerHeight+5 0):0);0!==r&&u.scrollTo(u.pageXOffset,u.pageYOffset+r)})}),ag(e,n.innerHeight)}) ;return ag(e,n.innerHeight),{toEditing:function(){ig(u)},destroy:function(){t.un bind()}}},lg=function(n){return x.some(ue.fromDom(n.dom().contentWindow.document .body))},dg=function(n){return x.some(ue.fromDom(n.dom().contentWindow.document) )},mg=function(n){return x.from(n.dom().contentWindow)},gg=function(n){return mg (n).bind(Qm)},pg=function(n){return n.getFrame()},hg=function(n,t){return functi on(e){return e[n].getOrThunk(function(){var n=pg(e);return function(){return t(n )}})()}},vg=function(n,e,t,o){return n[t].getOrThunk(function(){return function( n){return lm(e,o,n)}})},yg=function(n){return{left:O.constant(n.left),top:O.cons tant(n.top),right:O.constant(n.right),bottom:O.constant(n.bottom),width:O.consta nt(n.width),height:O.constant(n.height)}},bg={getBody:hg("getBody",lg),getDoc:hg ("getDoc",dg),getWin:hg("getWin",mg),getSelection:hg("getSelection",gg),getFrame :pg,getActiveApi:function(a){var c=pg(a);return lg(c).bind(function(u){return dg (c).bind(function(i){return mg(c).map(function(r){var n=ue.fromDom(i.dom().docum entElement),e=a.getCursorBox.getOrThunk(function(){return function(){return Zm(r ).bind(function(n){return eg(r,n).orThunk(function(){return Qm(r).filter(functio n(n){return je(n.start(),n.finish())&&n.soffset()===n.foffset()}).bind(function( n){var e=n.start().dom().getBoundingClientRect();return 0<e.width||0<e.height?x. some(e).map(yg):x.none()})})})}}),t=a.setSelection.getOrThunk(function(){return function(n,e,t,o){Jm(r,n,e,t,o)}}),o=a.clearSelection.getOrThunk(function(){retu rn function(){ng(r)}});return{body:O.constant(u),doc:O.constant(i),win:O.constan t(r),html:O.constant(n),getSelection:O.curry(gg,c),setSelection:t,clearSelection :o,frame:O.constant(c),onKeyup:vg(a,i,"onKeyup","keyup"),onNodeChanged:vg(a,i,"o nNodeChanged","selectionchange"),onDomChanged:a.onDomChanged,onScrollToCursor:a. onScrollToCursor,onScrollToElement:a.onScrollToElement,onToReading:a.onToReading ,onToEditing:a.onToEditing,onToolbarScrollStart:a.onToolbarScrollStart,onTouchCo ntent:a.onTouchContent,onTapContent:a.onTapContent,onTouchToolstrip:a.onTouchToo lstrip,getCursorBox:e}})})})}},wg="data-ephox-mobile-fullscreen-style",xg="posit ion:absolute!important;",Tg="top:0!important;left:0!important;margin:0!important ;padding:0!important;width:100%!important;",Sg=Ln.detect().os.isAndroid(),kg=fun ction(n,e){var t,o,r=function(o){return function(n){var e=ar.get(n,"style"),t=e= ==undefined?"no-styles":e.trim();t!==o&&(ar.set(n,wg,t),ar.set(n,"style",o))}},i =eu(n,"*"),u=wn.bind(i,function(n){return tu(n,"*")}),a=(t=e,(o=qi.get(t,"backgr ound-color"))!==undefined&&""!==o?"background-color:"+o+"!important":"background -color:rgb(255,255,255)!important;");wn.each(u,r("display:none!important;")),wn. each(i,r(xg+Tg+a)),r((!0===Sg?"":xg)+Tg+a)(n)},Cg=function(){var n=nu("["+wg+"]" );wn.each(n,function(n){var e=ar.get(n,wg);"no-styles"!==e?ar.set(n,"style",e):a r.remove(n,"style"),ar.remove(n,wg)})},Og=function(){var e=iu("head").getOrDie() ,n=iu('meta[name="viewport"]').getOrThunk(function(){var n=ue.fromTag("meta");re turn ar.set(n,"name","viewport"),Xe.append(e,n),n}),t=ar.get(n,"content");return {maximize:function(){ar.set(n,"content","width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0")},restore:function(){t!==undefined&&null!== t&&0<t.length?ar.set(n,"content",t):ar.set(n,"content","user-scalable=yes")}}},E g=function(e,n){var t=Og(),o=wl(),r=wl();return{enter:function(){n.hide(),xr.add (e.container,Fi.resolve("fullscreen-maximized")),xr.add(e.container,Fi.resolve(" android-maximized")),t.maximize(),xr.add(e.body,Fi.resolve("android-scroll-reloa d")),o.set(fg(e.win,bg.getWin(e.editor).getOrDie("no"))),bg.getActiveApi(e.edito r).each(function(n){kg(e.container,n.body()),r.set(xm(n,e.toolstrip,e.alloy))})} ,exit:function(){t.restore(),n.show(),xr.remove(e.container,Fi.resolve("fullscre en-maximized")),xr.remove(e.container,Fi.resolve("android-maximized")),Cg(),xr.r emove(e.body,Fi.resolve("android-scroll-reload")),r.clear(),o.clear()}}},Dg=func tion(e,t){var o=null;return{cancel:function(){null!==o&&(clearTimeout(o),o=null) },throttle:function(){var n=arguments;null===o&&(o=setTimeout(function(){e.apply (null,n),n=o=null},t))}}},Ag=function(e,t){var o=null;return{cancel:function(){n ull!==o&&(clearTimeout(o),o=null)},throttle:function(){var n=arguments;null!==o& &clearTimeout(o),o=setTimeout(function(){e.apply(null,n),n=o=null},t)}}},Mg=func tion(n,e){var t=cf(_f.sketch({dom:ls('<div aria-hidden="true" class="${prefix}-m ask-tap-icon"></div>'),containerBehaviours:Yo([Ai.config({toggleClass:Fi.resolve ("mask-tap-icon-selected"),toggleOnExecute:!1})])})),o=Dg(n,200);return _f.sketc h({dom:ls('<div class="${prefix}-disabled-mask"></div>'),components:[_f.sketch({ dom:ls('<div class="${prefix}-content-container"></div>'),components:[as.sketch( {dom:ls('<div class="${prefix}-content-tap-section"></div>'),components:[t.asSpe c()],action:function(n){o.throttle()},buttonBehaviours:Yo([Ai.config({toggleClas s:Fi.resolve("mask-tap-icon-selected")})])})]})]})},Bg=Gt([lo("editor",[co("getF rame"),mo("getBody"),mo("getDoc"),mo("getWin"),mo("getSelection"),mo("setSelecti on"),mo("clearSelection"),mo("cursorSaver"),mo("onKeyup"),mo("onNodeChanged"),mo ("getCursorBox"),co("onDomChanged"),ho("onTouchContent",O.noop),ho("onTapContent ",O.noop),ho("onTouchToolstrip",O.noop),ho("onScrollToCursor",O.constant({unbind :O.noop})),ho("onScrollToElement",O.constant({unbind:O.noop})),ho("onToEditing", O.constant({unbind:O.noop})),ho("onToReading",O.constant({unbind:O.noop})),ho("o nToolbarScrollStart",O.identity)]),co("socket"),co("toolstrip"),co("dropup"),co( "toolbar"),co("container"),co("alloy"),yo("win",function(n){return qe.owner(n.so cket).dom().defaultView}),yo("body",function(n){return ue.fromDom(n.socket.dom() .ownerDocument.body)}),ho("translate",O.identity),ho("setReadOnly",O.noop),ho("r eadOnlyOnInit",O.constant(!0))]),Rg=function(n){var e=to("Getting AndroidWebapp schema",Bg,n);qi.set(e.toolstrip,"width","100%");var t=ad(Mg(function(){e.setRea dOnly(e.readOnlyOnInit()),r.enter()},e.translate));e.alloy.add(t);var o={show:fu nction(){e.alloy.add(t)},hide:function(){e.alloy.remove(t)}};Xe.append(e.contain er,t.element());var r=Eg(e,o);return{setReadOnly:e.setReadOnly,refreshStructure: O.noop,enter:r.enter,exit:r.exit,destroy:O.noop}},Ig=O.constant([ho("shell",!0), ic("toolbarBehaviours",[Dd])]),Fg=O.constant([Bc({name:"groups",overrides:functi on(n){return{behaviours:Yo([Dd.config({})])}}})]),Ng=(O.constant("Toolbar"),us({ name:"Toolbar",configFields:Ig(),partFields:Fg(),factory:function(e,n,t,o){var r =function(n){return e.shell()?x.some(n):zc(n,e,"groups")},i=e.shell()?{behaviour s:[Dd.config({})],components:[]}:{behaviours:[],components:n};return{uid:e.uid() ,dom:e.dom(),components:i.components,behaviours:D.deepMerge(Yo(i.behaviours),uc( e.toolbarBehaviours())),apis:{setGroups:function(n,e){r(n).fold(function(){throw console.error("Toolbar was defined to not be a shell, but no groups container w as specified in components"),new Error("Toolbar was defined to not be a shell, b ut no groups container was specified in components")},function(n){Dd.set(n,e)})} },domModification:{attributes:{role:"group"}}}},apis:{setGroups:function(n,e,t){ n.setGroups(e,t)}}})),Vg=O.constant([co("items"),(Af=["itemClass"],lo("markers", wn.map(Af,co))),ic("tgroupBehaviours",[rc])]),Hg=O.constant([Rc({name:"items",un it:"item",overrides:function(n){return{domModification:{classes:[n.markers().ite mClass()]}}}})]),jg=(O.constant("ToolbarGroup"),us({name:"ToolbarGroup",configFi elds:Vg(),partFields:Hg(),factory:function(n,e,t,o){return D.deepMerge({dom:{att ributes:{role:"toolbar"}}},{uid:n.uid(),dom:n.dom(),components:e,behaviours:D.de epMerge(Yo([rc.config({mode:"flow",selector:"."+n.markers().itemClass()})]),uc(n .tgroupBehaviours())),"debug.sketcher":t["debug.sketcher"]})}})),zg="data-"+Fi.r esolve("horizontal-scroll"),Lg=function(n){return 0<n.dom().scrollTop||function( n){n.dom().scrollTop=1;var e=0!==n.dom().scrollTop;return n.dom().scrollTop=0,e} (n)},Pg=function(n){return 0<n.dom().scrollLeft||function(n){n.dom().scrollLeft= 1;var e=0!==n.dom().scrollLeft;return n.dom().scrollLeft=0,e}(n)},Wg=function(n) {return"true"===ar.get(n,zg)?Pg:Lg},Ug={exclusive:function(n,e){return lm(n,"tou chmove",function(n){cu(n.target(),e).filter(Wg).fold(function(){n.raw().preventD efault()},O.noop)})},markAsHorizontal:function(n){ar.set(n,zg,"true")}};function Gg(){var e=function(n){var e=!0===n.scrollable?"${prefix}-toolbar-scrollable-gr oup":"";return{dom:ls('<div aria-label="'+n.label+'" class="${prefix}-toolbar-gr oup '+e+'"></div>'),tgroupBehaviours:Yo([Uf("adhoc-scrollable-toolbar",!0===n.sc rollable?[Mo(function(n,e){qi.set(n.element(),"overflow-x","auto"),Ug.markAsHori zontal(n.element()),Ud.register(n.element())})]:[])]),components:[_f.sketch({com ponents:[jg.parts().items({})]})],markers:{itemClass:Fi.resolve("toolbar-group-i tem")},items:n.items}},t=ad(Ng.sketch({dom:ls('<div class="${prefix}-toolbar"></ div>'),components:[Ng.parts().groups({})],toolbarBehaviours:Yo([Ai.config({toggl eClass:Fi.resolve("context-toolbar"),toggleOnExecute:!1,aria:{mode:"none"}}),rc. config({mode:"cyclic"})]),shell:!0})),n=ad(_f.sketch({dom:{classes:[Fi.resolve(" toolstrip")]},components:[cd(t)],containerBehaviours:Yo([Ai.config({toggleClass: Fi.resolve("android-selection-context-toolbar"),toggleOnExecute:!1})])})),o=func tion(){Ng.setGroups(t,r.get()),Ai.off(t)},r=Or([]);return{wrapper:O.constant(n), toolbar:O.constant(t),createGroups:function(n){return wn.map(n,O.compose(jg.sket ch,e))},setGroups:function(n){r.set(n),o()},setContextToolbar:function(n){Ai.on( t),Ng.setGroups(t,n)},restoreToolbar:function(){Ai.isOn(t)&&o()},refresh:functio n(){},focus:function(){rc.focusIn(t)}}}var $g=function(n,e){Dd.append(n,cd(e))}, qg=function(n,e){Dd.remove(n,e)},_g=function(n){return ad(as.sketch({dom:ls('<di v class="${prefix}-mask-edit-icon ${prefix}-icon"></div>'),action:function(){n.r un(function(n){n.setReadOnly(!1)})}}))},Kg=function(){return ad(_f.sketch({dom:l s('<div class="${prefix}-editor-socket"></div>'),components:[],containerBehaviou rs:Yo([Dd.config({})])}))},Xg=function(n,e,t,o){(!0===t?Cr.toAlpha:Cr.toOmega)(o ),(t?$g:qg)(n,e)},Yg=function(e,n){return n.getAnimationRoot().fold(function(){r eturn e.element()},function(n){return n(e)})},Jg=function(n){return n.dimension( ).property()},Qg=function(n,e){return n.dimension().getDimension()(e)},Zg=functi on(n,e){var t=Yg(n,e);Jl(t,[e.shrinkingClass(),e.growingClass()])},np=function(n ,e){xr.remove(n.element(),e.openClass()),xr.add(n.element(),e.closedClass()),qi. set(n.element(),Jg(e),"0px"),qi.reflow(n.element())},ep=function(n,e){xr.remove( n.element(),e.closedClass()),xr.add(n.element(),e.openClass()),qi.remove(n.eleme nt(),Jg(e))},tp=function(n,e,t){t.setCollapsed(),qi.set(n.element(),Jg(e),Qg(e,n .element())),qi.reflow(n.element());var o=Yg(n,e);xr.add(o,e.shrinkingClass()),n p(n,e),e.onStartShrink()(n)},op=function(n,e,t){var o=function(n,e){ep(n,e);var t=Qg(e,n.element());return np(n,e),t}(n,e),r=Yg(n,e);xr.add(r,e.growingClass()), ep(n,e),qi.set(n.element(),Jg(e),o),t.setExpanded(),e.onStartGrow()(n)},rp=funct ion(n,e,t){var o=Yg(n,e);return!0===xr.has(o,e.growingClass())},ip=function(n,e, t){var o=Yg(n,e);return!0===xr.has(o,e.shrinkingClass())},up=Object.freeze({grow :function(n,e,t){t.isExpanded()||op(n,e,t)},shrink:function(n,e,t){t.isExpanded( )&&tp(n,e,t)},immediateShrink:function(n,e,t){var o,r;t.isExpanded()&&(o=n,r=e,t .setCollapsed(),qi.set(o.element(),Jg(r),Qg(r,o.element())),qi.reflow(o.element( )),Zg(o,r),np(o,r),r.onStartShrink()(o),r.onShrunk()(o))},hasGrown:function(n,e, t){return t.isExpanded()},hasShrunk:function(n,e,t){return t.isCollapsed()},isGr owing:rp,isShrinking:ip,isTransitioning:function(n,e,t){return!0===rp(n,e)||!0== =ip(n,e)},toggleGrow:function(n,e,t){(t.isExpanded()?tp:op)(n,e,t)},disableTrans itions:Zg}),ap=Object.freeze({exhibit:function(n,e){var t=e.expanded();return Vo (t?{classes:[e.openClass()],styles:{}}:{classes:[e.closedClass()],styles:Dt(e.di mension().property(),"0px")})},events:function(t,o){return xo([So(W(),function(n ,e){e.event().raw().propertyName===t.dimension().property()&&(Zg(n,t),o.isExpand ed()&&qi.remove(n.element(),t.dimension().property()),(o.isExpanded()?t.onGrown( ):t.onShrunk())(n,e))})])}}),cp=[co("closedClass"),co("openClass"),co("shrinking Class"),co("growingClass"),mo("getAnimationRoot"),fi("onShrunk"),fi("onStartShri nk"),fi("onGrown"),fi("onStartGrow"),ho("expanded",!1),so("dimension",io("proper ty",{width:[gi("property","width"),gi("getDimension",function(n){return qs(n)+"p x"})],height:[gi("property","height"),gi("getDimension",function(n){return Ji(n) +"px"})]}))],sp=Object.freeze({init:function(n){var e=Or(n.expanded());return _o ({isExpanded:function(){return!0===e.get()},isCollapsed:function(){return!1===e. get()},setCollapsed:O.curry(e.set,!1),setExpanded:O.curry(e.set,!0),readState:fu nction(){return"expanded: "+e.get()}})}}),fp=Qo({fields:cp,name:"sliding",active :ap,apis:up,state:sp}),lp=function(e,t){var o=ad(_f.sketch({dom:{tag:"div",class es:Fi.resolve("dropup")},components:[],containerBehaviours:Yo([Dd.config({}),fp. config({closedClass:Fi.resolve("dropup-closed"),openClass:Fi.resolve("dropup-ope n"),shrinkingClass:Fi.resolve("dropup-shrinking"),growingClass:Fi.resolve("dropu p-growing"),dimension:{property:"height"},onShrunk:function(n){e(),t(),Dd.set(n, [])},onGrown:function(n){e(),t()}}),Bi(function(n,e){r(O.noop)})])})),r=function (n){window.requestAnimationFrame(function(){n(),fp.shrink(o)})};return{appear:fu nction(n,e,t){!0===fp.hasShrunk(o)&&!1===fp.isTransitioning(o)&&window.requestAn imationFrame(function(){e(t),Dd.set(o,[n()]),fp.grow(o)})},disappear:r,component :O.constant(o),element:o.element}},dp=Ln.detect().browser.isFirefox(),mp=Ut([fo( "triggerEvent"),fo("broadcastEvent"),ho("stopBackspace",!0)]),gp=function(e,n){v ar t,o,r,i,u=to("Getting GUI events settings",mp,n),a=Ln.detect().deviceType.isT ouch()?["touchstart","touchmove","touchend","gesturestart"]:["mousedown","mouseu p","mouseover","mousemove","mouseout","click"],c=ym(u),s=wn.map(a.concat(["selec tstart","input","contextmenu","change","transitionend","dragstart","dragover","d rop"]),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){va r e;u.triggerEvent("keydown",n)?n.kill():!0!==u.stopBackspace||(e=n).raw().which !==su.BACKSPACE()[0]||wn.contains(["input","textarea"],ve.name(e.target()))||n.p revent()}),l=(t=e,o=function(n){u.triggerEvent("focusin",n)&&n.kill()},dp?dm(t," focus",o):lm(t,"focusin",o)),d=(r=e,i=function(n){u.triggerEvent("focusout",n)&& n.kill(),setTimeout(function(){u.triggerEvent(Un(),n)},0)},dp?dm(r,"blur",i):lm( r,"focusout",i)),m=qe.defaultView(e),g=lm(m,"scroll",function(n){u.broadcastEven t(Jn(),n)&&n.kill()});return{unbind:function(){wn.each(s,function(n){n.unbind()} ),f.unbind(),l.unbind(),d.unbind(),g.unbind()}}},pp=function(n,e){var t=Et(n,"ta rget").map(function(n){return n()}).getOr(e);return Or(t)},hp=st([{stopped:[]},{ resume:["element"]},{complete:[]}]),vp=function(n,o,e,t,r,i){var u,a,c,s,f=n(o,t ),l=(u=e,a=r,c=Or(!1),s=Or(!1),{stop:function(){c.set(!0)},cut:function(){s.set( !0)},isStopped:c.get,isCut:s.get,event:O.constant(u),setSource:a.set,getSource:a .get});return f.fold(function(){return i.logEventNoHandlers(o,t),hp.complete()}, function(e){var t=e.descHandler();return Wl(t)(l),l.isStopped()?(i.logEventStopp ed(o,e.element(),t.purpose()),hp.stopped()):l.isCut()?(i.logEventCut(o,e.element (),t.purpose()),hp.complete()):qe.parent(e.element()).fold(function(){return i.l ogNoParent(o,e.element(),t.purpose()),hp.complete()},function(n){return i.logEve ntResponse(o,e.element(),t.purpose()),hp.resume(n)})})},yp=function(e,t,o,n,r,i) {return vp(e,t,o,n,r,i).fold(function(){return!0},function(n){return yp(e,t,o,n, r,i)},function(){return!1})},bp=function(n,e,t){var o,r,i=(o=e,r=Or(!1),{stop:fu nction(){r.set(!0)},cut:O.noop,isStopped:r.get,isCut:O.constant(!1),event:O.cons tant(o),setTarget:O.die("Cannot set target of a broadcasted event"),getTarget:O. die("Cannot get target of a broadcasted event")});return wn.each(n,function(n){v ar e=n.descHandler();Wl(e)(i)}),i.isStopped()},wp=function(n,e,t,o,r){var i=pp(t ,o);return yp(n,e,t,o,i,r)},xp=function(n,e,t){return Br.closest(n,function(n){r eturn e(n).isSome()},t).bind(e)},Tp=Ee.immutable("element","descHandler"),Sp=fun ction(n,e){return{id:O.constant(n),descHandler:O.constant(e)}};function kp(){var i={};return{registerId:function(o,r,n){M.each(n,function(n,e){var t=i[e]!==unde fined?i[e]:{};t[r]=Pl(n,o),i[e]=t})},unregisterId:function(t){M.each(i,function( n,e){n.hasOwnProperty(t)&&delete n[t]})},filterByType:function(n){return Et(i,n) .map(function(n){return M.mapToArray(n,function(n,e){return Sp(e,n)})}).getOr([] )},find:function(n,e,t){var r=Ct(e)(i);return xp(t,function(n){return t=r,Qc(o=n ).fold(function(){return x.none()},function(n){var e=Ct(n);return t.bind(e).map( function(n){return Tp(o,n)})});var t,o},n)}}}function Cp(){var o=kp(),r={},i=fun ction(o){var n=o.element();return Qc(n).fold(function(){return n="uid-",e=o.elem ent(),t=hc(Yc+n),ar.set(e,Jc,t),t;var n,e,t},function(n){return n})},u=function( n){Qc(n.element()).each(function(n){r[n]=undefined,o.unregisterId(n)})};return{f ind:function(n,e,t){return o.find(n,e,t)},filter:function(n){return o.filterByTy pe(n)},register:function(n){var e=i(n);Bt(r,e)&&function(n,e){var t=r[e];if(t!== n)throw new Error('The tagId "'+e+'" is already used by: '+Yr(t.element())+"\nCa nnot use it for: "+Yr(n.element())+"\nThe conflicting element is"+(we.inBody(t.e lement())?" ":" not ")+"already in the DOM");u(n)}(n,e);var t=[n];o.registerId(t ,e,n.events()),r[e]=n},unregister:u,getById:function(n){return Ct(n)(r)}}}var Op =function(t){var o=function(e){return qe.parent(t.element()).fold(function(){ret urn!0},function(n){return je(e,n)})},r=Cp(),s=function(n,e){return r.find(o,n,e) },n=gp(t.element(),{triggerEvent:function(u,a){return ri(u,a.target(),function(n ){return e=s,t=u,r=n,i=(o=a).target(),wp(e,t,o,i,r);var e,t,o,r,i})},broadcastEv ent:function(n,e){var t=r.filter(n);return bp(t,e)}}),i=Ml({debugInfo:O.constant ("real"),triggerEvent:function(e,t,o){ri(e,t,function(n){wp(s,e,o,t,n)})},trigge rFocus:function(a,c){Qc(a).fold(function(){Nr(a)},function(n){ri(Wn(),a,function (n){var e,t,o,r,i,u;e=s,t=Wn(),o={originator:O.constant(c),target:O.constant(a)} ,i=n,u=pp(o,r=a),vp(e,t,o,r,u,i)})})},triggerEscape:function(n,e){i.triggerEvent ("keydown",n.element(),e.event())},getByUid:function(n){return m(n)},getByDom:fu nction(n){return g(n)},build:ad,addToGui:function(n){a(n)},removeFromGui:functio n(n){c(n)},addToWorld:function(n){e(n)},removeFromWorld:function(n){u(n)},broadc ast:function(n){l(n)},broadcastOn:function(n,e){d(n,e)},isConnected:O.constant(! 0)}),e=function(n){n.connect(i),ve.isText(n.element())||(r.register(n),wn.each(n .components(),e),i.triggerEvent(Yn(),n.element(),{target:O.constant(n.element()) }))},u=function(n){ve.isText(n.element())||(wn.each(n.components(),u),r.unregist er(n)),n.disconnect()},a=function(n){tt(t,n)},c=function(n){it(n)},f=function(t) {var n=r.filter(Gn());wn.each(n,function(n){var e=n.descHandler();Wl(e)(t)})},l= function(n){f({universal:O.constant(!0),data:O.constant(n)})},d=function(n,e){f( {universal:O.constant(!1),channels:O.constant(n),data:O.constant(e)})},m=functio n(n){return r.getById(n).fold(function(){return ct.error(new Error('Could not fi nd component with uid: "'+n+'" in system.'))},ct.value)},g=function(n){var e=Qc( n).getOr("not found");return m(e)};return e(t),{root:O.constant(t),element:t.ele ment,destroy:function(){n.unbind(),Ze.remove(t.element())},add:a,remove:c,getByU id:m,getByDom:g,addToWorld:e,removeFromWorld:u,broadcast:l,broadcastOn:d}},Ep=O. constant(Fi.resolve("readonly-mode")),Dp=O.constant(Fi.resolve("edit-mode"));fun ction Ap(n){var e=ad(_f.sketch({dom:{classes:[Fi.resolve("outer-container")].con cat(n.classes)},containerBehaviours:Yo([Cr.config({alpha:Ep(),omega:Dp()})])})); return Op(e)}var Mp=function(n,e){var t=ue.fromTag("input");qi.setAll(t,{opacity :"0",position:"absolute",top:"-1000px",left:"-1000px"}),Xe.append(n,t),Nr(t),e(t ),Ze.remove(t)},Bp=function(n){var e=n.getSelection();if(0<e.rangeCount){var t=e .getRangeAt(0),o=n.document.createRange();o.setStart(t.startContainer,t.startOff set),o.setEnd(t.endContainer,t.endOffset),e.removeAllRanges(),e.addRange(o)}},Rp =function(n,e){Hr().each(function(n){je(n,e)||Vr(n)}),n.focus(),Nr(ue.fromDom(n. document.body)),Bp(n)},Ip={stubborn:function(n,e,t,o){var r=function(){Rp(e,o)}, i=lm(t,"keydown",function(n){wn.contains(["input","textarea"],ve.name(n.target() ))||r()});return{toReading:function(){Mp(n,Vr)},toEditing:r,onToolbarTouch:funct ion(){},destroy:function(){i.unbind()}}},timid:function(n,e,t,o){var r=function( ){Vr(o)};return{toReading:function(){r()},toEditing:function(){Rp(e,o)},onToolba rTouch:function(){r()},destroy:O.noop}}},Fp=function(t,o,r,i,n){var u=function() {o.run(function(n){n.refreshSelection()})},e=function(n,e){var t=n-i.dom().scrol lTop;o.run(function(n){n.scrollIntoView(t,t+e)})},a=function(){o.run(function(n) {n.clearSelection()})},c=function(){t.getCursorBox().each(function(n){e(n.top(), n.height())}),o.run(function(n){n.syncHeight()})},s=bm(t),f=Ag(c,300),l=[t.onKey up(function(){a(),f.throttle()}),t.onNodeChanged(u),t.onDomChanged(f.throttle),t .onDomChanged(u),t.onScrollToCursor(function(n){n.preventDefault(),f.throttle()} ),t.onScrollToElement(function(n){n.element(),e(o,i)}),t.onToEditing(function(){ o.run(function(n){n.toEditing()})}),t.onToReading(function(){o.run(function(n){n .toReading()})}),lm(t.doc(),"touchend",function(n){je(t.html(),n.target())||je(t .body(),n.target())}),lm(r,"transitionend",function(n){var e;"height"===n.raw(). propertyName&&(e=Ji(r),o.run(function(n){n.setViewportOffset(e)}),u(),c())}),dm( r,"touchstart",function(n){var e;o.run(function(n){n.highlightSelection()}),e=n, o.run(function(n){n.onToolbarTouch(e)}),t.onTouchToolstrip()}),lm(t.body(),"touc hstart",function(n){a(),t.onTouchContent(),s.fireTouchstart(n)}),s.onTouchmove() ,s.onTouchend(),lm(t.body(),"click",function(n){n.kill()}),lm(r,"touchmove",func tion(){t.onToolbarScrollStart()})];return{destroy:function(){wn.each(l,function( n){n.unbind()})}}},Np=function(n){var t=x.none(),e=[],o=function(n){r()?u(n):e.p ush(n)},r=function(){return t.isSome()},i=function(n){wn.each(n,u)},u=function(e ){t.each(function(n){setTimeout(function(){e(n)},0)})};return n(function(n){t=x. some(n),i(e),e=[]}),{get:o,map:function(t){return Np(function(e){o(function(n){e (t(n))})})},isReady:r}},Vp={nu:Np,pure:function(e){return Np(function(n){n(e)})} },Hp=function(t){return function(){var n=Array.prototype.slice.call(arguments),e =this;setTimeout(function(){t.apply(e,n)},0)}},jp=function(e){var n=function(n){ e(Hp(n))};return{map:function(o){return jp(function(t){n(function(n){var e=o(n); t(e)})})},bind:function(t){return jp(function(e){n(function(n){t(n).get(e)})})}, anonBind:function(t){return jp(function(e){n(function(n){t.get(e)})})},toLazy:fu nction(){return Vp.nu(n)},get:n}},zp={nu:jp,pure:function(e){return jp(function( n){n(e)})}},Lp=function(n,e,t){return Math.abs(n-e)<=t?x.none():n<e?x.some(n+t): x.some(n-t)},Pp=function(){var s=null;return{animate:function(o,r,n,i,e,t){var u =!1,a=function(n){u=!0,e(n)};clearInterval(s);var c=function(n){clearInterval(s) ,a(n)};s=setInterval(function(){var t=o();Lp(t,r,n).fold(function(){clearInterva l(s),a(r)},function(n){if(i(n,c),!u){var e=o();(e!==n||Math.abs(e-r)>Math.abs(t- r))&&(clearInterval(s),a(r))}})},t)}}},Wp=function(e,t){return Zr([{width:320,he ight:480,keyboard:{portrait:300,landscape:240}},{width:320,height:568,keyboard:{ portrait:300,landscape:240}},{width:375,height:667,keyboard:{portrait:305,landsc ape:240}},{width:414,height:736,keyboard:{portrait:320,landscape:240}},{width:76 8,height:1024,keyboard:{portrait:320,landscape:400}},{width:1024,height:1366,key board:{portrait:380,landscape:460}}],function(n){return e<=n.width&&t<=n.height? x.some(n.keyboard):x.none()}).getOr({portrait:t/5,landscape:e/4})},Up=function(n ){var e,t=gm(n).isPortrait(),o=Wp((e=n).screen.width,e.screen.height),r=t?o.port rait:o.landscape;return(t?n.screen.height:n.screen.width)-n.innerHeight>r?0:r},G p=function(n,e){var t=qe.owner(n).dom().defaultView;return Ji(n)+Ji(e)-Up(t)},$p =Gp,qp=function(n,e,t){var o=Gp(e,t),r=Ji(e)+Ji(t)-o;qi.set(n,"padding-bottom",r +"px")},_p=st([{fixed:["element","property","offsetY"]},{scroller:["element","of fsetY"]}]),Kp="data-"+Fi.resolve("position-y-fixed"),Xp="data-"+Fi.resolve("y-pr operty"),Yp="data-"+Fi.resolve("scrolling"),Jp="data-"+Fi.resolve("last-window-h eight"),Qp=function(n){return Tm(n,Kp)},Zp=function(n,e){var t=ar.get(n,Xp);retu rn _p.fixed(n,t,e)},nh=function(n,e){return _p.scroller(n,e)},eh=function(n){var e=Qp(n);return("true"===ar.get(n,Yp)?nh:Zp)(n,e)},th=function(n,e,t){var o=qe.o wner(n).dom().defaultView.innerHeight;return ar.set(n,Jp,o+"px"),o-e-t},oh=funct ion(n){var e=ou(n,"["+Kp+"]");return wn.map(e,eh)},rh=function(o,r,i,u){var n,e, t,a,c,s,f,l,d=qe.owner(o).dom().defaultView,m=(l=ar.get(f=i,"style"),qi.setAll(f ,{position:"absolute",top:"0px"}),ar.set(f,Kp,"0px"),ar.set(f,Xp,"top"),{restore :function(){ar.set(f,"style",l||""),ar.remove(f,Kp),ar.remove(f,Xp)}}),g=Ji(i),p =Ji(u),h=th(o,g,p),v=(t=g,a=h,s=ar.get(c=o,"style"),Ud.register(c),qi.setAll(c,{ position:"absolute",height:a+"px",width:"100%",top:t+"px"}),ar.set(c,Kp,t+"px"), ar.set(c,Yp,"true"),ar.set(c,Xp,"top"),{restore:function(){Ud.deregister(c),ar.s et(c,"style",s||""),ar.remove(c,Kp),ar.remove(c,Yp),ar.remove(c,Xp)}}),y=(e=ar.g et(n=u,"style"),qi.setAll(n,{position:"absolute",bottom:"0px"}),ar.set(n,Kp,"0px "),ar.set(n,Xp,"bottom"),{restore:function(){ar.set(n,"style",e||""),ar.remove(n ,Kp),ar.remove(n,Xp)}}),b=!0,w=function(){var n=d.innerHeight;return Tm(o,Jp)<n} ,x=function(){if(b){var n=Ji(i),e=Ji(u),t=th(o,n,e);ar.set(o,Kp,n+"px"),qi.set(o ,"height",t+"px"),qi.set(u,"bottom",-(n+t+e)+"px"),qp(r,o,u)}};return qp(r,o,u), {setViewportOffset:function(n){ar.set(o,Kp,n+"px"),x()},isExpanding:w,isShrinkin g:O.not(w),refresh:x,restore:function(){b=!1,m.restore(),v.restore(),y.restore() }}},ih=Qp,uh=Pp(),ah="data-"+Fi.resolve("last-scroll-top"),ch=function(n){var e= qi.getRaw(n,"top").getOr(0);return parseInt(e,10)},sh=function(n){return parseIn t(n.dom().scrollTop,10)},fh=function(n,e){var t=e+ih(n)+"px";qi.set(n,"top",t)}, lh=function(t,o,r){return zp.nu(function(n){var e=O.curry(sh,t);uh.animate(e,o,1 5,function(n){t.dom().scrollTop=n,qi.set(t,"top",ch(t)+15+"px")},function(){t.do m().scrollTop=o,qi.set(t,"top",r+"px"),n(o)},10)})},dh=function(r,i){return zp.n u(function(n){var e=O.curry(sh,r);ar.set(r,ah,e());var t=Math.abs(i-e()),o=Math. ceil(t/10);uh.animate(e,i,o,function(n,e){Tm(r,ah)!==r.dom().scrollTop?e(r.dom() .scrollTop):(r.dom().scrollTop=n,ar.set(r,ah,n))},function(){r.dom().scrollTop=i ,ar.set(r,ah,i),n(i)},10)})},mh=function(i,u){return zp.nu(function(n){var e=O.c urry(ch,i),t=function(n){qi.set(i,"top",n+"px")},o=Math.abs(u-e()),r=Math.ceil(o /10);uh.animate(e,u,r,t,function(){t(u),n(u)},10)})},gh=function(e,t,o){var r=qe .owner(e).dom().defaultView;return zp.nu(function(n){fh(e,o),fh(t,o),r.scrollTo( 0,o),n(o)})},ph=function(n,e,t,o,r){var i=$p(e,t),u=O.curry(Bp,n);i<o||i<r?dh(e, e.dom().scrollTop-i+r).get(u):o<0&&dh(e,e.dom().scrollTop+o).get(u)},hh=function (u,n){return n(function(o){var r=[],i=0;0===u.length?o([]):wn.each(u,function(n, e){var t;n.get((t=e,function(n){r[t]=n,++i>=u.length&&o(r)}))})})},vh=function(n ){return hh(n,zp.nu)},yh=vh,bh=function(n,c){return n.fold(function(n,e,t){retur n o=n,r=e,u=c+(i=t),qi.set(o,r,u+"px"),zp.pure(i);var o,r,i,u},function(n,e){ret urn t=n,r=c+(o=e),i=qi.getRaw(t,"top").getOr(o),u=r-parseInt(i,10),a=t.dom().scr ollTop+u,lh(t,a,r);var t,o,r,i,u,a})},wh=function(n,e){var t=oh(n),o=wn.map(t,fu nction(n){return bh(n,e)});return yh(o)},xh=function(e,t,n,o,r,i){var u,a,c=(u=f unction(n){return gh(e,t,n)},a=Or(Vp.pure({})),{start:function(e){var n=Vp.nu(fu nction(n){return u(e).get(n)});a.set(n)},idle:function(n){a.get().get(function() {n()})}}),s=Ag(function(){c.idle(function(){wh(n,o.pageYOffset).get(function(){v ar n;(n=rg(i),x.from(n[0]).bind(function(n){var e=n.top()-t.dom().scrollTop;retu rn e>o.innerHeight+5||e<-5?x.some({top:O.constant(e),bottom:O.constant(e+n.heigh t())}):x.none()})).each(function(n){t.dom().scrollTop=t.dom().scrollTop+n.top()} ),c.start(0),r.refresh()})})},1e3),f=lm(ue.fromDom(o),"scroll",function(){o.page YOffset<0||s.throttle()});return wh(n,o.pageYOffset).get(O.identity),{unbind:f.u nbind}},Th=function(n){var t=n.cWin(),e=n.ceBody(),o=n.socket(),r=n.toolstrip(), i=n.toolbar(),u=n.contentElement(),a=n.keyboardType(),c=n.outerWindow(),s=n.drop up(),f=rh(o,e,r,s),l=a(n.outerBody(),t,we.body(),u,r,i),d=pm(c,{onChange:O.noop, onReady:f.refresh});d.onAdjustment(function(){f.refresh()});var m=lm(ue.fromDom( c),"resize",function(){f.isExpanding()&&f.refresh()}),g=xh(r,o,n.outerBody(),c,f ,t),p=function(t,e){var n=t.document,o=ue.fromTag("div");xr.add(o,Fi.resolve("un focused-selections")),Xe.append(ue.fromDom(n.documentElement),o);var r=lm(o,"tou chstart",function(n){n.prevent(),Rp(t,e),u()}),i=function(n){var e=ue.fromTag("s pan");return Yl(e,[Fi.resolve("layer-editor"),Fi.resolve("unfocused-selection")] ),qi.setAll(e,{left:n.left()+"px",top:n.top()+"px",width:n.width()+"px",height:n .height()+"px"}),e},u=function(){Ze.empty(o)};return{update:function(){u();var n =rg(t),e=wn.map(n,i);Je(o,e)},isActive:function(){return 0<qe.children(o).length },destroy:function(){r.unbind(),Ze.remove(o)},clear:u}}(t,u),h=function(){p.clea r()};return{toEditing:function(){l.toEditing(),h()},toReading:function(){l.toRea ding()},onToolbarTouch:function(n){l.onToolbarTouch(n)},refreshSelection:functio n(){p.isActive()&&p.update()},clearSelection:h,highlightSelection:function(){p.u pdate()},scrollIntoView:function(n,e){ph(t,o,s,n,e)},updateToolbarPadding:O.noop ,setViewportOffset:function(n){f.setViewportOffset(n),mh(o,n).get(O.identity)},s yncHeight:function(){qi.set(u,"height",u.dom().contentWindow.document.body.scrol lHeight+"px")},refreshStructure:f.refresh,destroy:function(){f.restore(),d.destr oy(),g.unbind(),m.unbind(),l.destroy(),p.destroy(),Mp(we.body(),Vr)}}},Sh=functi on(o,n){var r=Og(),i=xl(),u=xl(),a=wl(),c=wl();return{enter:function(){n.hide(); var t=ue.fromDom(document);bg.getActiveApi(o.editor).each(function(n){i.set({soc ketHeight:qi.getRaw(o.socket,"height"),iframeHeight:qi.getRaw(n.frame(),"height" ),outerScroll:document.body.scrollTop}),u.set({exclusives:Ug.exclusive(t,"."+Ud. scrollable())}),xr.add(o.container,Fi.resolve("fullscreen-maximized")),kg(o.cont ainer,n.body()),r.maximize(),qi.set(o.socket,"overflow","scroll"),qi.set(o.socke t,"-webkit-overflow-scrolling","touch"),Nr(n.body());var e=Ee.immutableBag(["cWi n","ceBody","socket","toolstrip","toolbar","dropup","contentElement","cursor","k eyboardType","isScrolling","outerWindow","outerBody"],[]);a.set(Th(e({cWin:n.win (),ceBody:n.body(),socket:o.socket,toolstrip:o.toolstrip,toolbar:o.toolbar,dropu p:o.dropup.element(),contentElement:n.frame(),cursor:O.noop,outerBody:o.body,out erWindow:o.win,keyboardType:Ip.stubborn,isScrolling:function(){return u.get().ex ists(function(n){return n.socket.isScrolling()})}}))),a.run(function(n){n.syncHe ight()}),c.set(Fp(n,a,o.toolstrip,o.socket,o.dropup))})},refreshStructure:functi on(){a.run(function(n){n.refreshStructure()})},exit:function(){r.restore(),c.cle ar(),a.clear(),n.show(),i.on(function(n){n.socketHeight.each(function(n){qi.set( o.socket,"height",n)}),n.iframeHeight.each(function(n){qi.set(o.editor.getFrame( ),"height",n)}),document.body.scrollTop=n.scrollTop}),i.clear(),u.on(function(n) {n.exclusives.unbind()}),u.clear(),xr.remove(o.container,Fi.resolve("fullscreen- maximized")),Cg(),Ud.deregister(o.toolbar),qi.remove(o.socket,"overflow"),qi.rem ove(o.socket,"-webkit-overflow-scrolling"),Vr(o.editor.getFrame()),bg.getActiveA pi(o.editor).each(function(n){n.clearSelection()})}}},kh=function(n){var e=to("G etting IosWebapp schema",Bg,n);qi.set(e.toolstrip,"width","100%"),qi.set(e.conta iner,"position","relative");var t=ad(Mg(function(){e.setReadOnly(e.readOnlyOnIni t()),o.enter()},e.translate));e.alloy.add(t);var o=Sh(e,{show:function(){e.alloy .add(t)},hide:function(){e.alloy.remove(t)}});return{setReadOnly:e.setReadOnly,r efreshStructure:o.refreshStructure,enter:o.enter,exit:o.exit,destroy:O.noop}},Ch =tinymce.util.Tools.resolve("tinymce.EditorManager"),Oh=function(n){var e=Et(n.s ettings,"skin_url").fold(function(){return Ch.baseURL+"/skins/lightgray"},functi on(n){return n});return{content:e+"/content.mobile.min.css",ui:e+"/skin.mobile.m in.css"}},Eh=function(n,e,t){n.system().broadcastOn([Wr.formatChanged()],{comman d:e,state:t})},Dh=function(o,n){var e=M.keys(n.formatter.get());wn.each(e,functi on(e){n.formatter.formatChanged(e,function(n){Eh(o,e,n)})}),wn.each(["ul","ol"], function(t){n.selection.selectorChanged(t,function(n,e){Eh(o,t,n)})})},Ah=(O.con stant(["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)}}),Mh=O.constant("toReading"),Bh=O.constant("toEditing");Lr.add("mo bile",function(C){return{getNotificationManagerImpl:function(){return{open:O.ide ntity,close:O.noop,reposition:O.noop,getArgs:O.identity}},renderUI:function(n){v ar e=Oh(C);0==(!1===C.settings.skin)?(C.contentCSS.push(e.content),zr.DOM.styleS heetLoader.load(e.ui,Ah(C))):Ah(C)();var t,o,r,i,u,a,c,s,f,l,d,m,g,p,h=function( ){C.fire("scrollIntoView")},v=ue.fromTag("div"),y=Ln.detect().os.isAndroid()?(s= h,f=Ap({classes:[Fi.resolve("android-container")]}),l=Gg(),d=wl(),m=_g(d),g=Kg() ,p=lp(O.noop,s),f.add(l.wrapper()),f.add(g),f.add(p.component()),{system:O.const ant(f),element:f.element,init:function(n){d.set(Rg(n))},exit:function(){d.run(fu nction(n){n.exit(),Dd.remove(g,m)})},setToolbarGroups:function(n){var e=l.create Groups(n);l.setGroups(e)},setContextToolbar:function(n){var e=l.createGroups(n); l.setContextToolbar(e)},focusToolbar:function(){l.focus()},restoreToolbar:functi on(){l.restoreToolbar()},updateMode:function(n){Xg(g,m,n,f.root())},socket:O.con stant(g),dropup:O.constant(p)}):(t=h,o=Ap({classes:[Fi.resolve("ios-container")] }),r=Gg(),i=wl(),u=_g(i),a=Kg(),c=lp(function(){i.run(function(n){n.refreshStruc ture()})},t),o.add(r.wrapper()),o.add(a),o.add(c.component()),{system:O.constant (o),element:o.element,init:function(n){i.set(kh(n))},exit:function(){i.run(funct ion(n){Dd.remove(a,u),n.exit()})},setToolbarGroups:function(n){var e=r.createGro ups(n);r.setGroups(e)},setContextToolbar:function(n){var e=r.createGroups(n);r.s etContextToolbar(e)},focusToolbar:function(){r.focus()},restoreToolbar:function( ){r.restoreToolbar()},updateMode:function(n){Xg(a,u,n,o.root())},socket:O.consta nt(a),dropup:O.constant(c)}),b=ue.fromDom(n.targetNode);Xe.after(b,v),function(n ,e){Xe.append(n,e.element());var t=qe.children(e.element());wn.each(t,function(n ){e.getByDom(n).each(et)})}(v,y.system());var w=n.targetNode.ownerDocument.defau ltView,x=pm(w,{onChange:function(){y.system().broadcastOn([Wr.orientationChanged ()],{width:hm(w)})},onReady:O.noop}),T=function(n,e,t,o){!1===o&&C.selection.col lapse();var r=S(n,e,t);y.setToolbarGroups(!0===o?r.readOnly:r.main),C.setMode(!0 ===o?"readonly":"design"),C.fire(!0===o?Mh():Bh()),y.updateMode(o)},S=function(n ,e,t){var o=n.get(),r={readOnly:o.backToMask.concat(e.get()),main:o.backToMask.c oncat(t.get())};return r},k=function(n,e){return C.on(n,e),{unbind:function(){C. off(n)}}};return C.on("init",function(){y.init({editor:{getFrame:function(){retu rn ue.fromDom(C.contentAreaContainer.querySelector("iframe"))},onDomChanged:func tion(){return{unbind:O.noop}},onToReading:function(n){return k(Mh(),n)},onToEdit ing:function(n){return k(Bh(),n)},onScrollToCursor:function(e){return C.on("scro llIntoView",function(n){e(n)}),{unbind:function(){C.off("scrollIntoView"),x.dest roy()}}},onTouchToolstrip:function(){t()},onTouchContent:function(){var n,e=ue.f romDom(C.editorContainer.querySelector("."+Fi.resolve("toolbar")));(n=e,jr(n).bi nd(function(n){return y.system().getByDom(n).toOption()})).each(te),y.restoreToo lbar(),t()},onTapContent:function(n){var e=n.target();"img"===ve.name(e)?(C.sele ction.select(e.dom()),n.kill()):"a"===ve.name(e)&&y.system().getByDom(ue.fromDom (C.editorContainer)).each(function(n){Cr.isAlpha(n)&&Pr(e.dom())})}},container:u e.fromDom(C.editorContainer),socket:ue.fromDom(C.contentAreaContainer),toolstrip :ue.fromDom(C.editorContainer.querySelector("."+Fi.resolve("toolstrip"))),toolba r:ue.fromDom(C.editorContainer.querySelector("."+Fi.resolve("toolbar"))),dropup: y.dropup(),alloy:y.system(),translate:O.noop,setReadOnly:function(n){T(c,a,u,n)} ,readOnlyOnInit:function(){return!1}});var t=function(){y.dropup().disappear(fun ction(){y.system().broadcastOn([Wr.dropupDismissed()],{})})},n={label:"The first group",scrollable:!1,items:[ps.forToolbar("back",function(){C.selection.collaps e(),y.exit()},{})]},e={label:"Back to read only",scrollable:!1,items:[ps.forTool bar("readonly-back",function(){T(c,a,u,!0)},{})]},o=om(y,C),r=rm(C.settings,o),i ={label:"The extra group",scrollable:!1,items:[]},u=Or([{label:"the action group ",scrollable:!0,items:r},i]),a=Or([{label:"The read only mode group",scrollable: !0,items:[]},i]),c=Or({backToMask:[n],backToReadOnly:[e]});Dh(y,C)}),{iframeCont ainer:y.socket().element().dom(),editorContainer:y.element().dom()}}}})}(); !function(){"use strict";var I=function(){for(var n=[],e=0;e<arguments.length;e+ +)n[e]=arguments[e]},v=function(t,r){return function(){for(var n=[],e=0;e<argume nts.length;e++)n[e]=arguments[e];return t(r.apply(null,n))}},A=function(n){retur n function(){return n}},h=function(n){return n};function l(r){for(var o=[],n=1;n <arguments.length;n++)o[n-1]=arguments[n];return function(){for(var n=[],e=0;e<a rguments.length;e++)n[e]=arguments[e];var t=o.concat(n);return r.apply(null,t)}} var n,e,t,r,o,i,u,a,S=function(t){return function(){for(var n=[],e=0;e<arguments .length;e++)n[e]=arguments[e];return!t.apply(null,n)}},c=function(n){return func tion(){throw new Error(n)}},s=function(n){return n()},f=A(!1),d=A(!0),m=function (e){return function(n){return function(n){if(null===n)return"null";var e=typeof n;return"object"===e&&Array.prototype.isPrototypeOf(n)?"array":"object"===e&&Str ing.prototype.isPrototypeOf(n)?"string":e}(n)===e}},b=m("string"),g=m("object"), p=m("array"),y=m("boolean"),w=m("function"),x=m("number"),T=Object.prototype.has OwnProperty,O=function(u){return function(){for(var n=new Array(arguments.length ),e=0;e<n.length;e++)n[e]=arguments[e];if(0===n.length)throw new Error("Can't me rge zero objects");for(var t={},r=0;r<n.length;r++){var o=n[r];for(var i in o)T. call(o,i)&&(t[i]=u(t[i],o[i]))}return t}},k=O(function(n,e){return g(n)&&g(e)?k( n,e):e}),C=O(function(n,e){return e}),E=f,D=d,M=function(){return B},B=(r={fold: function(n,e){return n()},is:E,isSome:E,isNone:D,getOr:t=function(n){return n},g etOrThunk:e=function(n){return n()},getOrDie:function(n){throw new Error(n||"err or: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined :function(){return undefined},or:t,orThunk:e,map:M,ap:M,each:function(){},bind:M ,flatten:M,exists:E,forall:D,filter:M,equals:n=function(n){return n.isNone()},eq uals_:n,toArray:function(){return[]},toString:A("none()")},Object.freeze&&Object .freeze(r),r),R=function(t){var n=function(){return t},e=function(){return o},r= function(n){return n(t)},o={fold:function(n,e){return e(t)},is:function(n){retur n t===n},isSome:D,isNone:E,getOr:n,getOrThunk:n,getOrDie:n,getOrNull:n,getOrUnde fined:n,or:e,orThunk:e,map:function(n){return R(n(t))},ap:function(n){return n.f old(M,function(n){return R(n(t))})},each:function(n){n(t)},bind:r,flatten:n,exis ts:r,forall:r,filter:function(n){return n(t)?o:B},equals:function(n){return n.is (t)},equals_:function(n,e){return n.fold(E,function(n){return e(t,n)})},toArray: function(){return[t]},toString:function(){return"some("+t+")"}};return o},F={som e:R,none:M,from:function(n){return null===n||n===undefined?B:R(n)}},N=Object.key s,V=function(n,e){for(var t=N(n),r=0,o=t.length;r<o;r++){var i=t[r];e(n[i],i,n)} },H=function(n,r){return z(n,function(n,e,t){return{k:e,v:r(n,e,t)}})},z=functio n(r,o){var i={};return V(r,function(n,e){var t=o(n,e,r);i[t.k]=t.v}),i},j=functi on(n,t){var r=[];return V(n,function(n,e){r.push(t(n,e))}),r},L=A("touchstart"), U=A("touchmove"),P=A("touchend"),$=A("mousedown"),W=A("mousemove"),G=A("mouseup" ),_=A("mouseover"),q=A("keydown"),Y=A("input"),K=A("change"),X=A("click"),J=A("t ransitionend"),Q=A("selectstart"),Z=function(t){var r,o=!1;return function(){for (var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return o||(o=!0,r=t.apply (null,n)),r}},nn=function(n,e){var t=function(n,e){for(var t=0;t<n.length;t++){v ar r=n[t];if(r.test(e))return r}return undefined}(n,e);if(!t)return{major:0,mino r:0};var r=function(n){return Number(e.replace(t,"$"+n))};return tn(r(1),r(2))}, en=function(){return tn(0,0)},tn=function(n,e){return{major:n,minor:e}},rn={nu:t n,detect:function(n,e){var t=String(e).toLowerCase();return 0===n.length?en():nn (n,t)},unknown:en},on="Firefox",un=function(n,e){return function(){return e===n} },an=function(n){var e=n.current;return{current:e,version:n.version,isEdge:un("E dge",e),isChrome:un("Chrome",e),isIE:un("IE",e),isOpera:un("Opera",e),isFirefox: un(on,e),isSafari:un("Safari",e)}},cn={unknown:function(){return an({current:und efined,version:rn.unknown()})},nu:an,edge:A("Edge"),chrome:A("Chrome"),ie:A("IE" ),opera:A("Opera"),firefox:A(on),safari:A("Safari")},sn="Windows",fn="Android",l n="Solaris",dn="FreeBSD",mn=function(n,e){return function(){return e===n}},gn=fu nction(n){var e=n.current;return{current:e,version:n.version,isWindows:mn(sn,e), isiOS:mn("iOS",e),isAndroid:mn(fn,e),isOSX:mn("OSX",e),isLinux:mn("Linux",e),isS olaris:mn(ln,e),isFreeBSD:mn(dn,e)}},vn={unknown:function(){return gn({current:u ndefined,version:rn.unknown()})},nu:gn,windows:A(sn),ios:A("iOS"),android:A(fn), linux:A("Linux"),osx:A("OSX"),solaris:A(ln),freebsd:A(dn)},pn=(o=Array.prototype .indexOf)===undefined?function(n,e){return kn(n,e)}:function(n,e){return o.call( n,e)},hn=function(n,e){return-1<pn(n,e)},bn=function(n,e){for(var t=n.length,r=n ew Array(t),o=0;o<t;o++){var i=n[o];r[o]=e(i,o,n)}return r},yn=function(n,e){for (var t=0,r=n.length;t<r;t++)e(n[t],t,n)},wn=function(n,e){for(var t=[],r=0,o=n.l ength;r<o;r++){var i=n[r];e(i,r,n)&&t.push(i)}return t},xn=function(n,e,t){retur n function(n,e){for(var t=n.length-1;0<=t;t--)e(n[t],t,n)}(n,function(n){t=e(t,n )}),t},Sn=function(n,e,t){return yn(n,function(n){t=e(t,n)}),t},Tn=function(n,e) {for(var t=0,r=n.length;t<r;t++){var o=n[t];if(e(o,t,n))return F.some(o)}return F.none()},On=function(n,e){for(var t=0,r=n.length;t<r;t++)if(e(n[t],t,n))return F.some(t);return F.none()},kn=function(n,e){for(var t=0,r=n.length;t<r;++t)if(n[ t]===e)return t;return-1},Cn=Array.prototype.push,En=function(n){for(var e=[],t= 0,r=n.length;t<r;++t){if(!Array.prototype.isPrototypeOf(n[t]))throw new Error("A rr.flatten item "+t+" was not an array, input: "+n);Cn.apply(e,n[t])}return e},D n=function(n,e){var t=bn(n,e);return En(t)},In=function(n,e){for(var t=0,r=n.len gth;t<r;++t)if(!0!==e(n[t],t,n))return!1;return!0},An=Array.prototype.slice,Mn=f unction(n){var e=An.call(n,0);return e.reverse(),e},Bn=function(n){return[n]},Rn =(w(Array.from)&&Array.from,function(n,e){var t=String(e).toLowerCase();return T n(n,function(n){return n.search(t)})}),Fn=function(n,t){return Rn(n,t).map(funct ion(n){var e=rn.detect(n.versionRegexes,t);return{current:n.name,version:e}})},N n=function(n,t){return Rn(n,t).map(function(n){var e=rn.detect(n.versionRegexes, t);return{current:n.name,version:e}})},Vn=function(n,e){return-1!==n.indexOf(e)} ,Hn=/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,zn=function(e){return function(n){retu rn Vn(n,e)}},jn=[{name:"Edge",versionRegexes:[/.*?edge\/ ?([0-9]+)\.([0-9]+)$/], search:function(n){return Vn(n,"edge/")&&Vn(n,"chrome")&&Vn(n,"safari")&&Vn(n,"a pplewebkit")}},{name:"Chrome",versionRegexes:[/.*?chrome\/([0-9]+)\.([0-9]+).*/, Hn],search:function(n){return Vn(n,"chrome")&&!Vn(n,"chromeframe")}},{name:"IE", versionRegexes:[/.*?msie\ ?([0-9]+)\.([0-9]+).*/,/.*?rv:([0-9]+)\.([0-9]+).*/],s earch:function(n){return Vn(n,"msie")||Vn(n,"trident")}},{name:"Opera",versionRe gexes:[Hn,/.*?opera\/([0-9]+)\.([0-9]+).*/],search:zn("opera")},{name:"Firefox", versionRegexes:[/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],search:zn("firefox")},{na me:"Safari",versionRegexes:[Hn,/.*?cpu os ([0-9]+)_([0-9]+).*/],search:function( n){return(Vn(n,"safari")||Vn(n,"mobile/"))&&Vn(n,"applewebkit")}}],Ln=[{name:"Wi ndows",search:zn("win"),versionRegexes:[/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/] },{name:"iOS",search:function(n){return Vn(n,"iphone")||Vn(n,"ipad")},versionReg exes:[/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,/.*cpu os ([0-9]+)_([0-9]+).*/,/.*cp u iphone os ([0-9]+)_([0-9]+).*/]},{name:"Android",search:zn("android"),versionR egexes:[/.*?android\ ?([0-9]+)\.([0-9]+).*/]},{name:"OSX",search:zn("os x"),vers ionRegexes:[/.*?os\ x\ ?([0-9]+)_([0-9]+).*/]},{name:"Linux",search:zn("linux"), versionRegexes:[]},{name:"Solaris",search:zn("sunos"),versionRegexes:[]},{name:" FreeBSD",search:zn("freebsd"),versionRegexes:[]}],Un={browsers:A(jn),oses:A(Ln)} ,Pn=function(n){var e,t,r,o,i,u,a,c,s,f,l,d=Un.browsers(),m=Un.oses(),g=Fn(d,n). fold(cn.unknown,cn.nu),v=Nn(m,n).fold(vn.unknown,vn.nu);return{browser:g,os:v,de viceType:(t=g,r=n,o=(e=v).isiOS()&&!0===/ipad/i.test(r),i=e.isiOS()&&!o,u=e.isAn droid()&&3===e.version.major,a=e.isAndroid()&&4===e.version.major,c=o||u||a&&!0= ==/mobile/i.test(r),s=e.isiOS()||e.isAndroid(),f=s&&!c,l=t.isSafari()&&e.isiOS() &&!1===/safari/i.test(r),{isiPad:A(o),isiPhone:A(i),isTablet:A(c),isPhone:A(f),i sTouch:A(s),isAndroid:e.isAndroid,isiOS:e.isiOS,isWebView:A(l)})}},$n={detect:Z( function(){var n=navigator.userAgent;return Pn(n)})},Wn={tap:A("alloy.tap")},Gn= A("alloy.focus"),_n=A("alloy.blur.post"),qn=A("alloy.receive"),Yn=A("alloy.execu te"),Kn=A("alloy.focus.item"),Xn=Wn.tap,Jn=$n.detect().deviceType.isTouch()?Wn.t ap:X,Qn=A("alloy.longpress"),Zn=A("alloy.system.init"),ne=A("alloy.system.scroll "),ee=A("alloy.system.attached"),te=A("alloy.system.detached"),re=function(n,e){ ae(n,n.element(),e,{})},oe=function(n,e,t){ae(n,n.element(),e,t)},ie=function(n) {re(n,Yn())},ue=function(n,e,t){ae(n,e,t,{})},ae=function(n,e,t,r){var o=k({targ et:e},r);n.getSystem().triggerEvent(t,e,H(o,A))},ce=function(n){if(null===n||n== =undefined)throw new Error("Node cannot be null or undefined");return{dom:A(n)}} ,se={fromHtml:function(n,e){var t=(e||document).createElement("div");if(t.innerH TML=n,!t.hasChildNodes()||1<t.childNodes.length)throw console.error("HTML does n ot have a single root node",n),"HTML must have a single root node";return ce(t.c hildNodes[0])},fromTag:function(n,e){var t=(e||document).createElement(n);return ce(t)},fromText:function(n,e){var t=(e||document).createTextNode(n);return ce(t )},fromDom:ce,fromPoint:function(n,e,t){var r=n.dom();return F.from(r.elementFro mPoint(e,t)).map(ce)}},fe=(Node.ATTRIBUTE_NODE,Node.CDATA_SECTION_NODE,Node.COMM ENT_NODE,Node.DOCUMENT_NODE),le=(Node.DOCUMENT_TYPE_NODE,Node.DOCUMENT_FRAGMENT_ NODE,Node.ELEMENT_NODE),de=Node.TEXT_NODE,me=(Node.PROCESSING_INSTRUCTION_NODE,N ode.ENTITY_REFERENCE_NODE,Node.ENTITY_NODE,Node.NOTATION_NODE,function(n){return n.dom().nodeName.toLowerCase()}),ge=function(e){return function(n){return n.dom ().nodeType===e}},ve=ge(le),pe=ge(de),he=function(n){var e=pe(n)?n.dom().parentN ode:n.dom();return e!==undefined&&null!==e&&e.ownerDocument.body.contains(e)},be =Z(function(){return ye(se.fromDom(document))}),ye=function(n){var e=n.dom().bod y;if(null===e||e===undefined)throw"Body is not available yet";return se.fromDom( e)},we=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];retu rn function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];if(e.len gth!==t.length)throw new Error('Wrong number of arguments to struct. Expected "[ '+e.length+']", got '+t.length+" arguments");var r={};return yn(e,function(n,e){ r[n]=A(t[e])}),r}},xe=function(n){return n.slice(0).sort()},Se=function(n,e){thr ow new Error("All required keys ("+xe(n).join(", ")+") were not specified. Speci fied keys were: "+xe(e).join(", ")+".")},Te=function(n){throw new Error("Unsuppo rted keys for object: "+xe(n).join(", "))},Oe=function(e,n){if(!p(n))throw new E rror("The "+e+" fields must be an array. Was: "+n+".");yn(n,function(n){if(!b(n) )throw new Error("The value "+n+" in the "+e+" fields was not a string.")})},ke= function(n){var t=xe(n);Tn(t,function(n,e){return e<t.length-1&&n===t[e+1]}).eac h(function(n){throw new Error("The field: "+n+" occurs more than once in the com bined fields: ["+t.join(", ")+"].")})},Ce=function(o,i){var u=o.concat(i);if(0== =u.length)throw new Error("You must specify at least one required or optional fi eld.");return Oe("required",o),Oe("optional",i),ke(u),function(e){var t=N(e);In( o,function(n){return hn(t,n)})||Se(o,t);var n=wn(t,function(n){return!hn(u,n)}); 0<n.length&&Te(n);var r={};return yn(o,function(n){r[n]=A(e[n])}),yn(i,function( n){r[n]=A(Object.prototype.hasOwnProperty.call(e,n)?F.some(e[n]):F.none())}),r}} ,Ee="undefined"!=typeof window?window:Function("return this;")(),De=function(n,e ){return function(n,e){for(var t=e!==undefined&&null!==e?e:Ee,r=0;r<n.length&&t! ==undefined&&null!==t;++r)t=t[n[r]];return t}(n.split("."),e)},Ie={getOrDie:func tion(n,e){var t=De(n,e);if(t===undefined||null===t)throw n+" not available on th is browser";return t}},Ae=le,Me=fe,Be=function(n,e){var t=n.dom();if(t.nodeType! ==Ae)return!1;if(t.matches!==undefined)return t.matches(e);if(t.msMatchesSelecto r!==undefined)return t.msMatchesSelector(e);if(t.webkitMatchesSelector!==undefin ed)return t.webkitMatchesSelector(e);if(t.mozMatchesSelector!==undefined)return t.mozMatchesSelector(e);throw new Error("Browser lacks native selectors")},Re=fu nction(n){return n.nodeType!==Ae&&n.nodeType!==Me||0===n.childElementCount},Fe=f unction(n,e){var t=e===undefined?document:e.dom();return Re(t)?[]:bn(t.querySele ctorAll(n),se.fromDom)},Ne=function(n,e){var t=e===undefined?document:e.dom();re turn Re(t)?F.none():F.from(t.querySelector(n)).map(se.fromDom)},Ve=function(n,e) {return n.dom()===e.dom()},He=($n.detect().browser.isIE(),function(n){return se. fromDom(n.dom().ownerDocument)}),ze=function(n){var e=n.dom();return F.from(e.pa rentNode).map(se.fromDom)},je=function(n){var e=n.dom();return bn(e.childNodes,s e.fromDom)},Le=function(n){return e=0,t=n.dom().childNodes,F.from(t[e]).map(se.f romDom);var e,t},Ue=(we("element","offset"),function(e,t){Le(e).fold(function(){ Pe(e,t)},function(n){e.dom().insertBefore(t.dom(),n.dom())})}),Pe=function(n,e){ n.dom().appendChild(e.dom())},$e=function(e,n){yn(n,function(n){Pe(e,n)})},We=fu nction(n){n.dom().textContent="",yn(je(n),function(n){Ge(n)})},Ge=function(n){va r e=n.dom();null!==e.parentNode&&e.parentNode.removeChild(e)},_e=function(n){re( n,te());var e=n.components();yn(e,_e)},qe=function(n){var e=n.components();yn(e, qe),re(n,ee())},Ye=function(n,e){Ke(n,e,Pe)},Ke=function(n,e,t){n.getSystem().ad dToWorld(e),t(n.element(),e.element()),he(n.element())&&qe(e),n.syncComponents() },Xe=function(n){_e(n),Ge(n.element()),n.getSystem().removeFromWorld(n)},Je=func tion(e){var n=ze(e.element()).bind(function(n){return e.getSystem().getByDom(n). fold(F.none,F.some)});Xe(e),n.each(function(n){n.syncComponents()})},Qe=function (t){return{is:function(n){return t===n},isValue:d,isError:f,getOr:A(t),getOrThun k:A(t),getOrDie:A(t),or:function(n){return Qe(t)},orThunk:function(n){return Qe( t)},fold:function(n,e){return e(t)},map:function(n){return Qe(n(t))},each:functi on(n){n(t)},bind:function(n){return n(t)},exists:function(n){return n(t)},forall :function(n){return n(t)},toOption:function(){return F.some(t)}}},Ze=function(t) {return{is:f,isValue:f,isError:d,getOr:h,getOrThunk:function(n){return n()},getO rDie:function(){return c(String(t))()},or:function(n){return n},orThunk:function (n){return n()},fold:function(n,e){return n(t)},map:function(n){return Ze(t)},ea ch:I,bind:function(n){return Ze(t)},exists:f,forall:d,toOption:F.none}},nt={valu e:Qe,error:Ze},et=function(u){if(!p(u))throw new Error("cases must be an array") ;if(0===u.length)throw new Error("there must be at least one case");var a=[],t={ };return yn(u,function(n,r){var e=N(n);if(1!==e.length)throw new Error("one and only one name per case");var o=e[0],i=n[o];if(t[o]!==undefined)throw new Error(" duplicate key detected:"+o);if("cata"===o)throw new Error("cannot have a case na med cata (sorry)");if(!p(i))throw new Error("case arguments must be an array");a .push(o),t[o]=function(){var n=arguments.length;if(n!==i.length)throw new Error( "Wrong number of arguments to case "+o+". Expected "+i.length+" ("+i+"), got "+n );for(var t=new Array(n),e=0;e<t.length;e++)t[e]=arguments[e];return{fold:functi on(){if(arguments.length!==u.length)throw new Error("Wrong number of arguments t o fold. Expected "+u.length+", got "+arguments.length);return arguments[r].apply (null,t)},match:function(n){var e=N(n);if(a.length!==e.length)throw new Error("W rong number of arguments to match. Expected: "+a.join(",")+"\nActual: "+e.join(" ,"));if(!In(a,function(n){return hn(e,n)}))throw new Error("Not all branches wer e specified when using match. Specified: "+e.join(", ")+"\nRequired: "+a.join(", "));return n[o].apply(null,t)},log:function(n){console.log(n,{constructors:a,co nstructor:o,params:t})}}}}),t},tt=et([{strict:[]},{defaultedThunk:["fallbackThun k"]},{asOption:[]},{asDefaultedOptionThunk:["fallbackThunk"]},{mergeWithThunk:[" baseThunk"]}]),rt=function(n){return tt.defaultedThunk(A(n))},ot=tt.strict,it=tt .asOption,ut=tt.defaultedThunk,at=tt.mergeWithThunk,ct=(et([{bothErrors:["error1 ","error2"]},{firstError:["error1","value2"]},{secondError:["value1","error2"]}, {bothValues:["value1","value2"]}]),function(n){var e=[],t=[];return yn(n,functio n(n){n.fold(function(n){e.push(n)},function(n){t.push(n)})}),{errors:e,values:t} }),st=function(n){return v(nt.error,En)(n)},ft=function(n,e){var t,r,o=ct(n);ret urn 0<o.errors.length?st(o.errors):(t=o.values,r=e,nt.value(k.apply(undefined,[r ].concat(t))))},lt=function(n){var e=ct(n);return 0<e.errors.length?st(e.errors) :nt.value(e.values)},dt=function(e){return function(n){return n.hasOwnProperty(e )?F.from(n[e]):F.none()}},mt=function(n,e){return dt(e)(n)},gt=function(n,e){var t={};return t[n]=e,t},vt=function(n,e){return t=n,r={},yn(e,function(n){t[n]!== undefined&&t.hasOwnProperty(n)&&(r[n]=t[n])}),r;var t,r},pt=function(n,e){return t=e,r={},V(n,function(n,e){hn(t,e)||(r[e]=n)}),r;var t,r},ht=function(n){return dt(n)},bt=function(n,e){return t=n,r=e,function(n){return dt(t)(n).getOr(r)};va r t,r},yt=function(n,e){return mt(n,e)},wt=function(n,e){return gt(n,e)},xt=func tion(n){return e={},yn(n,function(n){e[n.key]=n.value}),e;var e},St=function(n,e ){return ft(n,e)},Tt=function(n,e){return r=e,(t=n).hasOwnProperty(r)&&t[r]!==un defined&&null!==t[r];var t,r},Ot=et([{setOf:["validator","valueType"]},{arrOf:[" valueType"]},{objOf:["fields"]},{itemOf:["validator"]},{choiceOf:["key","branche s"]},{thunk:["description"]},{func:["args","outputSchema"]}]),kt=et([{field:["na me","presence","type"]},{state:["name"]}]),Ct=function(){return Ie.getOrDie("JSO N")},Et=function(n,e,t){return Ct().stringify(n,e,t)},Dt=function(n){return g(n) &&100<N(n).length?" removed due to size":Et(n,null,2)},It=function(n,e){return n t.error([{path:n,getErrorInfo:e}])},At=et([{field:["key","okey","presence","prop "]},{state:["okey","instantiator"]}]),Mt=function(t,r,o){return mt(r,o).fold(fun ction(){return n=o,e=r,It(t,function(){return'Could not find valid *strict* valu e for "'+n+'" in '+Dt(e)});var n,e},nt.value)},Bt=function(n,e,t){var r=mt(n,e). fold(function(){return t(n)},h);return nt.value(r)},Rt=function(o,a,n,c){return n.fold(function(i,e,n,t){var r=function(n){return t.extract(o.concat([i]),c,n).m ap(function(n){return gt(e,c(n))})},u=function(n){return n.fold(function(){var n =gt(e,c(F.none()));return nt.value(n)},function(n){return t.extract(o.concat([i] ),c,n).map(function(n){return gt(e,c(F.some(n)))})})};return n.fold(function(){r eturn Mt(o,a,i).bind(r)},function(n){return Bt(a,i,n).bind(r)},function(){return (n=a,e=i,nt.value(mt(n,e))).bind(u);var n,e},function(n){return(e=a,t=i,r=n,o=mt (e,t).map(function(n){return!0===n?r(e):n}),nt.value(o)).bind(u);var e,t,r,o},fu nction(n){var e=n(a);return Bt(a,i,A({})).map(function(n){return k(e,n)}).bind(r )})},function(n,e){var t=e(a);return nt.value(gt(n,c(t)))})},Ft=function(r){retu rn{extract:function(t,n,e){return r(e,n).fold(function(n){return e=n,It(t,functi on(){return e});var e},nt.value)},toString:function(){return"val"},toDsl:functio n(){return Ot.itemOf(r)}}},Nt=function(n){var c=Vt(n),s=xn(n,function(e,n){retur n n.fold(function(n){return k(e,wt(n,!0))},A(e))},{});return{extract:function(n, e,t){var r,o,i,u=y(t)?[]:(o=N(r=t),wn(o,function(n){return Tt(r,n)})),a=wn(u,fun ction(n){return!Tt(s,n)});return 0===a.length?c.extract(n,e,t):(i=a,It(n,functio n(){return"There are unsupported fields: ["+i.join(", ")+"] specified"}))},toStr ing:c.toString,toDsl:c.toDsl}},Vt=function(a){return{extract:function(n,e,t){ret urn r=n,o=t,i=e,u=bn(a,function(n){return Rt(r,o,n,i)}),ft(u,{});var r,o,i,u},to String:function(){return"obj{\n"+bn(a,function(n){return n.fold(function(n,e,t,r ){return n+" -> "+r.toString()},function(n,e){return"state("+n+")"})}).join("\n" )+"}"},toDsl:function(){return Ot.objOf(bn(a,function(n){return n.fold(function( n,e,t,r){return kt.field(n,t,r)},function(n,e){return kt.state(n)})}))}}},Ht=fun ction(t,i){var e=function(n,e){return(o=Ft(t),{extract:function(t,r,n){var e=bn( n,function(n,e){return o.extract(t.concat(["["+e+"]"]),r,n)});return lt(e)},toSt ring:function(){return"array("+o.toString()+")"},toDsl:function(){return Ot.arrO f(o)}}).extract(n,h,e);var o};return{extract:function(t,r,o){var n=N(o);return e (t,n).bind(function(n){var e=bn(n,function(n){return At.field(n,n,ot(),i)});retu rn Vt(e).extract(t,r,o)})},toString:function(){return"setOf("+i.toString()+")"}, toDsl:function(){return Ot.setOf(t,i)}}},zt=A(Ft(nt.value)),jt=At.state,Lt=At.fi eld,Ut=function(t,e,r,o,i){return yt(o,i).fold(function(){return n=o,e=i,It(t,fu nction(){return'The chosen schema: "'+e+'" did not exist in branches: '+Dt(n)}); var n,e},function(n){return Vt(n).extract(t.concat(["branch: "+i]),e,r)})},Pt=fu nction(o,i){return{extract:function(e,t,r){return yt(r,o).fold(function(){return n=o,It(e,function(){return'Choice schema did not contain choice key: "'+n+'"'}) ;var n},function(n){return Ut(e,t,r,i,n)})},toString:function(){return"chooseOn( "+o+"). Possible values: "+N(i)},toDsl:function(){return Ot.choiceOf(o,i)}}},$t= Ft(nt.value),Wt=function(n,e,t,r){return e.extract([n],t,r).fold(function(n){ret urn nt.error({input:r,errors:n})},nt.value)},Gt=function(n,e,t){return Wt(n,e,A, t)},_t=function(n){return n.fold(function(n){throw new Error(Kt(n))},h)},qt=func tion(n,e,t){return _t(Wt(n,e,h,t))},Yt=function(n,e,t){return _t(Gt(n,e,t))},Kt= function(n){return"Errors: \n"+(e=n.errors,t=10<e.length?e.slice(0,10).concat([{ path:[],getErrorInfo:function(){return"... (only showing first ten failures)"}}] ):e,bn(t,function(n){return"Failed path: ("+n.path.join(" > ")+")\n"+n.getErrorI nfo()}))+"\n\nInput object: "+Dt(n.input);var e,t},Xt=function(n,e){return Pt(n, e)},Jt=A($t),Qt=(i=w,u="function",Ft(function(n){var e=typeof n;return i(n)?nt.v alue(n):nt.error("Expected type: "+u+" but got: "+e)})),Zt=function(n){return Lt (n,n,ot(),zt())},nr=function(n,e){return Lt(n,n,ot(),e)},er=function(n){return n r(n,Qt)},tr=function(n,e){return Lt(n,n,ot(),Vt(e))},rr=function(n){return Lt(n, n,it(),zt())},or=function(n,e){return Lt(n,n,it(),Vt(e))},ir=function(n,e){retur n Lt(n,n,it(),Nt(e))},ur=function(n,e){return Lt(n,n,rt(e),zt())},ar=function(n, e,t){return Lt(n,n,rt(e),t)},cr=function(n,e){return jt(n,e)},sr=function(n){if( !Tt(n,"can")&&!Tt(n,"abort")&&!Tt(n,"run"))throw new Error("EventHandler defined by: "+Et(n,null,2)+" does not have can, abort, or run!");return qt("Extracting event.handler",Nt([ur("can",A(!0)),ur("abort",A(!1)),ur("run",I)]),n)},fr=functi on(t){var e,r,o,i,n=(e=t,r=function(n){return n.can},function(){for(var t=[],n=0 ;n<arguments.length;n++)t[n]=arguments[n];return Sn(e,function(n,e){return n&&r( e).apply(undefined,t)},!0)}),u=(o=t,i=function(n){return n.abort},function(){for (var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Sn(o,function(n,e) {return n||i(e).apply(undefined,t)},!1)});return sr({can:n,abort:u,run:function( ){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];yn(t,function(n){n.r un.apply(undefined,e)})}})},lr=function(n){return xt(n)},dr=function(n,e){return {key:n,value:sr({abort:e})}},mr=function(n,e){return{key:n,value:sr({run:e})}},g r=function(n,e,t){return{key:n,value:sr({run:function(n){e.apply(undefined,[n].c oncat(t))}})}},vr=function(n){return function(r){return{key:n,value:sr({run:func tion(n,e){var t;t=e,Ve(n.element(),t.event().target())&&r(n,e)}})}}},pr=function (n,e,t){var u,r,o=e.partUids()[t];return r=o,mr(u=n,function(n,i){n.getSystem(). getByUid(r).each(function(n){var e,t,r,o;t=(e=n).element(),r=u,o=i,e.getSystem() .triggerEvent(r,t,o.event())})})},hr=function(n){return mr(n,function(n,e){e.cut ()})},br=vr(ee()),yr=vr(te()),wr=vr(Zn()),xr=(a=Yn(),function(n){return mr(a,n)} ),Sr=function(n){return bn(n,function(n){return r=e="/*",o=(t=n).length-e.length ,""!==r&&(t.length<r.length||t.substr(o,o+r.length)!==r)?n:n.substring(0,n.lengt h-"/*".length);var e,t,r,o})},Tr=function(n,e){var t=n.toString(),r=t.indexOf(") ")+1,o=t.indexOf("("),i=t.substring(o+1,r-1).split(/,\s*/);return n.toFunctionAn notation=function(){return{name:e,parameters:Sr(i)}},n},Or=Ce(["tag"],["classes" ,"attributes","styles","value","innerHtml","domChildren","defChildren"]),kr=func tion(n){return{tag:n.tag(),classes:n.classes().getOr([]),attributes:n.attributes ().getOr({}),styles:n.styles().getOr({}),value:n.value().getOr("<none>"),innerHt ml:n.innerHtml().getOr("<none>"),defChildren:n.defChildren().fold(function(){ret urn"<none>"},function(n){return Et(n,null,2)}),domChildren:n.domChildren().fold( function(){return"<none>"},function(n){return 0===n.length?"0 children, but stil l specified":String(n.length)})}},Cr=Ce([],["classes","attributes","styles","val ue","innerHtml","defChildren","domChildren"]),Er=function(e,n,t){return n.fold(f unction(){return t.fold(function(){return{}},function(n){return wt(e,n)})},funct ion(n){return t.fold(function(){return wt(e,n)},function(n){return wt(e,n)})})}, Dr=function(t,r,o){return wr(function(n,e){o(n,t,r)})},Ir=function(n,e,t,r,o,i){ var u,a,c=n,s=or(e,[(u="config",a=n,Lt(u,u,it(),a))]);return Br(c,s,e,t,r,o,i)}, Ar=function(o,i,u){var n,e,t,r,a,c;return n=function(t){for(var n=[],e=1;e<argum ents.length;e++)n[e-1]=arguments[e];var r=[t].concat(n);return t.config({name:A( o)}).fold(function(){throw new Error("We could not find any behaviour configurat ion for: "+o+". Using API: "+u)},function(n){var e=Array.prototype.slice.call(r, 1);return i.apply(undefined,[t,n.config,n.state].concat(e))})},e=u,t=i.toString( ),r=t.indexOf(")")+1,a=t.indexOf("("),c=t.substring(a+1,r-1).split(/,\s*/),n.toF unctionAnnotation=function(){return{name:e,parameters:Sr(c.slice(0,1).concat(c.s lice(3)))}},n},Mr=function(n){return{key:n,value:undefined}},Br=function(t,n,r,o ,e,i,u){var a=function(n){return Tt(n,r)?n[r]():F.none()},c=H(e,function(n,e){re turn Ar(r,n,e)}),s=H(i,function(n,e){return Tr(n,e)}),f=k(s,c,{revoke:l(Mr,r),co nfig:function(n){var e=Yt(r+"-config",t,n);return{key:r,value:{config:e,me:f,con figAsRaw:Z(function(){return qt(r+"-config",t,n)}),initialConfig:n,state:u}}},sc hema:function(){return n},exhibit:function(n,t){return a(n).bind(function(e){ret urn yt(o,"exhibit").map(function(n){return n(t,e.config,e.state)})}).getOr(Cr({} ))},name:function(){return r},handlers:function(n){return a(n).bind(function(e){ return yt(o,"events").map(function(n){return n(e.config,e.state)})}).getOr({})}} );return f},Rr=function(n,e){return Fr(n,e,{validate:w,label:"function"})},Fr=fu nction(r,o,i){if(0===o.length)throw new Error("You must specify at least one req uired field.");return Oe("required",o),ke(o),function(e){var t=N(e);In(o,functio n(n){return hn(t,n)})||Se(o,t),r(o,t);var n=wn(o,function(n){return!i.validate(e [n],n)});return 0<n.length&&function(n,e){throw new Error("All values need to be of type: "+e+". Keys ("+xe(n).join(", ")+") were not.")}(n,i.label),e}},Nr=func tion(e,n){var t=wn(n,function(n){return!hn(e,n)});0<t.length&&Te(t)},Vr=I,Hr=fun ction(n){return Rr(Nr,n)},zr={init:function(){return jr({readState:function(){re turn"No State required"}})}},jr=function(n){return Rr(Vr,["readState"])(n),n},Lr =function(n){return xt(n)},Ur=Nt([Zt("fields"),Zt("name"),ur("active",{}),ur("ap is",{}),ur("state",zr),ur("extra",{})]),Pr=function(n){var e,t,r,o,i,u,a,c,s=qt( "Creating behaviour: "+n.name,Ur,n);return e=s.fields,t=s.name,r=s.active,o=s.ap is,i=s.extra,u=s.state,a=Nt(e),c=or(t,[ir("config",e)]),Br(a,c,t,r,o,i,u)},$r=Nt ([Zt("branchKey"),Zt("branches"),Zt("name"),ur("active",{}),ur("apis",{}),ur("st ate",zr),ur("extra",{})]),Wr=A(undefined),Gr=function(n,e,t){if(!(b(t)||y(t)||x( t)))throw console.error("Invalid call to Attr.set. Key ",e,":: Value ",t,":: Ele ment ",n),new Error("Attribute value was not simple");n.setAttribute(e,t+"")},_r =function(n,e,t){Gr(n.dom(),e,t)},qr=function(n,e){var t=n.dom();V(e,function(n, e){Gr(t,e,n)})},Yr=function(n,e){var t=n.dom().getAttribute(e);return null===t?u ndefined:t},Kr=function(n,e){var t=n.dom();return!(!t||!t.hasAttribute)&&t.hasAt tribute(e)},Xr=function(n,e){n.dom().removeAttribute(e)},Jr=function(n,e){var t= Yr(n,e);return t===undefined||""===t?[]:t.split(" ")},Qr=function(n){return n.do m().classList!==undefined},Zr=function(n){return Jr(n,"class")},no=function(n,e) {return o=e,i=Jr(t=n,r="class").concat([o]),_r(t,r,i.join(" ")),!0;var t,r,o,i}, eo=function(n,e){return o=e,0<(i=wn(Jr(t=n,r="class"),function(n){return n!==o}) ).length?_r(t,r,i.join(" ")):Xr(t,r),!1;var t,r,o,i},to=function(n,e){Qr(n)?n.do m().classList.add(e):no(n,e)},ro=function(n,e){var t;Qr(n)?n.dom().classList.rem ove(e):eo(n,e),0===(Qr(t=n)?t.dom().classList:Zr(t)).length&&Xr(t,"class")},oo=f unction(n,e){return Qr(n)?n.dom().classList.toggle(e):(r=e,hn(Zr(t=n),r)?eo(t,r) :no(t,r));var t,r},io=function(n,e){return Qr(n)&&n.dom().classList.contains(e)} ,uo=function(n,e,t){ro(n,t),to(n,e)},ao=Object.freeze({toAlpha:function(n,e,t){u o(n.element(),e.alpha(),e.omega())},toOmega:function(n,e,t){uo(n.element(),e.ome ga(),e.alpha())},isAlpha:function(n,e,t){return io(n.element(),e.alpha())},isOme ga:function(n,e,t){return io(n.element(),e.omega())},clear:function(n,e,t){ro(n. element(),e.alpha()),ro(n.element(),e.omega())}}),co=[Zt("alpha"),Zt("omega")],s o=Pr({fields:co,name:"swapping",apis:ao}),fo=function(n){var e=n,t=function(){re turn e};return{get:t,set:function(n){e=n},clone:function(){return fo(t())}}};fun ction lo(n,e,t,r,o){return n(t,r)?F.some(t):w(o)&&o(t)?F.none():e(t,r,o)}var mo= function(n,e,t){for(var r=n.dom(),o=w(t)?t:A(!1);r.parentNode;){r=r.parentNode;v ar i=se.fromDom(r);if(e(i))return F.some(i);if(o(i))break}return F.none()},go=fu nction(n,e,t){return lo(function(n){return e(n)},mo,n,e,t)},vo=function(n,r){var o=function(n){for(var e=0;e<n.childNodes.length;e++){if(r(se.fromDom(n.childNod es[e])))return F.some(se.fromDom(n.childNodes[e]));var t=o(n.childNodes[e]);if(t .isSome())return t}return F.none()};return o(n.dom())},po=function(n){n.dom().fo cus()},ho=function(n){n.dom().blur()},bo=function(n){var e=n!==undefined?n.dom() :document;return F.from(e.activeElement).map(se.fromDom)},yo=function(e){return bo(He(e)).filter(function(n){return e.dom().contains(n.dom())})},wo=tinymce.util .Tools.resolve("tinymce.dom.DOMUtils"),xo=tinymce.util.Tools.resolve("tinymce.Th emeManager"),So=function(n){var e=document.createElement("a");e.target="_blank", e.href=n.href,e.rel="noreferrer noopener";var t=document.createEvent("MouseEvent s");t.initMouseEvent("click",!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),document .body.appendChild(e),e.dispatchEvent(t),document.body.removeChild(e)},To={format Changed:A("formatChanged"),orientationChanged:A("orientationChanged"),dropupDism issed:A("dropupDismissed")},Oo=function(n){return n.dom().innerHTML},ko=function (n,e){var t,r,o=He(n).dom(),i=se.fromDom(o.createDocumentFragment()),u=(t=e,(r=( o||document).createElement("div")).innerHTML=t,je(se.fromDom(r)));$e(i,u),We(n), Pe(n,i)},Co=function(n){return e=n,t=!1,se.fromDom(e.dom().cloneNode(t));var e,t },Eo=function(n){var e,t,r,o=Co(n);return e=o,t=se.fromTag("div"),r=se.fromDom(e .dom().cloneNode(!0)),Pe(t,r),Oo(t)},Do=function(n){return Eo(n)},Io=Object.free ze({events:function(a){return lr([mr(qn(),function(o,i){var n,e,u=a.channels(),t =N(u),r=(n=t,(e=i).universal()?n:wn(n,function(n){return hn(e.channels(),n)}));y n(r,function(n){var e=u[n](),t=e.schema(),r=Yt("channel["+n+"] data\nReceiver: " +Do(o.element()),t,i.data());e.onReceive()(o,r)})})])}}),Ao=function(n){for(var e=[],t=function(n){e.push(n)},r=0;r<n.length;r++)n[r].each(t);return e},Mo=funct ion(n,e){for(var t=0;t<n.length;t++){var r=e(n[t],t);if(r.isSome())return r}retu rn F.none()},Bo="unknown",Ro=[],Fo=["alloy/data/Fields","alloy/debugging/Debuggi ng"],No=function(){var n=new Error;if(n.stack!==undefined){var e=n.stack.split(" \n");return Tn(e,function(e){return 0<e.indexOf("alloy")&&!On(Fo,function(n){ret urn-1<e.indexOf(n)}).isSome()}).getOr(Bo)}return Bo},Vo={logEventCut:I,logEventS topped:I,logNoParent:I,logEventNoHandlers:I,logEventResponse:I,write:I},Ho=funct ion(n,e,t){var r,o="*"===Ro||hn(Ro,n)?(r=[],{logEventCut:function(n,e,t){r.push( {outcome:"cut",target:e,purpose:t})},logEventStopped:function(n,e,t){r.push({out come:"stopped",target:e,purpose:t})},logNoParent:function(n,e,t){r.push({outcome :"no-parent",target:e,purpose:t})},logEventNoHandlers:function(n,e){r.push({outc ome:"no-handlers-left",target:e})},logEventResponse:function(n,e,t){r.push({outc ome:"response",purpose:t,target:e})},write:function(){hn(["mousemove","mouseover ","mouseout",Zn()],n)||console.log(n,{event:n,target:e.dom(),sequence:bn(r,funct ion(n){return hn(["cut","stopped","response"],n.outcome)?"{"+n.purpose+"} "+n.ou tcome+" at ("+Do(n.target)+")":n.outcome})})}}):Vo,i=t(o);return o.write(),i},zo =A([Zt("menu"),Zt("selectedMenu")]),jo=A([Zt("item"),Zt("selectedItem")]),Lo=(A( Nt(jo().concat(zo()))),A(Nt(jo()))),Uo=tr("initSize",[Zt("numColumns"),Zt("numRo ws")]),Po=function(n,e,t){var r;return No(),Lt(e,e,t,(r=function(t){return nt.va lue(function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.apply(undefined,n)})},Ft(function(n){return r(n)})))},$o=function(n){return Po (0,n,rt(I))},Wo=function(n){return Po(0,n,rt(F.none))},Go=function(n){return Po( 0,n,ot())},_o=function(n){return Po(0,n,ot())},qo=function(n,e){return cr(n,A(e) )},Yo=function(n){return cr(n,h)},Ko=A(Uo),Xo=[nr("channels",Ht(nt.value,Nt([Go( "onReceive"),ur("schema",Jt())])))],Jo=Pr({fields:Xo,name:"receiving",active:Io} ),Qo=function(n,e){var t=ti(n,e),r=e.aria();r.update()(n,r,t)},Zo=function(n,e,t ){oo(n.element(),e.toggleClass()),Qo(n,e)},ni=function(n,e,t){to(n.element(),e.t oggleClass()),Qo(n,e)},ei=function(n,e,t){ro(n.element(),e.toggleClass()),Qo(n,e )},ti=function(n,e){return io(n.element(),e.toggleClass())},ri=function(n,e,t){( e.selected()?ni:ei)(n,e,t)},oi=Object.freeze({onLoad:ri,toggle:Zo,isOn:ti,on:ni, off:ei}),ii=Object.freeze({exhibit:function(n,e,t){return Cr({})},events:functio n(n,e){var t,r,o,i=(t=n,r=e,o=Zo,xr(function(n){o(n,t,r)})),u=Dr(n,e,ri);return lr(En([n.toggleOnExecute()?[i]:[],[u]]))}}),ui=function(n,e,t){_r(n.element(),"a ria-expanded",t)},ai=[ur("selected",!1),Zt("toggleClass"),ur("toggleOnExecute",! 0),ar("aria",{mode:"none"},Xt("mode",{pressed:[ur("syncWithExpanded",!1),qo("upd ate",function(n,e,t){_r(n.element(),"aria-pressed",t),e.syncWithExpanded()&&ui(n ,e,t)})],checked:[qo("update",function(n,e,t){_r(n.element(),"aria-checked",t)}) ],expanded:[qo("update",ui)],selected:[qo("update",function(n,e,t){_r(n.element( ),"aria-selected",t)})],none:[qo("update",I)]}))],ci=Pr({fields:ai,name:"togglin g",active:ii,apis:oi}),si=function(t,r){return Jo.config({channels:wt(To.formatC hanged(),{onReceive:function(n,e){e.command===t&&r(n,e.state)}})})},fi=function( n){return Jo.config({channels:wt(To.orientationChanged(),{onReceive:n})})},li=fu nction(n,e){return{key:n,value:{onReceive:e}}},di="tinymce-mobile",mi={resolve:f unction(n){return di+"-"+n},prefix:A(di)},gi=function(n,e){e.ignore()||(po(n.ele ment()),e.onFocus()(n))},vi=Object.freeze({focus:gi,blur:function(n,e){e.ignore( )||ho(n.element())},isFocused:function(n){return e=n.element(),t=He(e).dom(),e.d om()===t.activeElement;var e,t}}),pi=Object.freeze({exhibit:function(n,e){return e.ignore()?Cr({}):Cr({attributes:{tabindex:"-1"}})},events:function(t){return l r([mr(Gn(),function(n,e){gi(n,t),e.stop()})])}}),hi=[$o("onFocus"),ur("ignore",! 1)],bi=Pr({fields:hi,name:"focusing",active:pi,apis:vi}),yi=function(n){return n .style!==undefined},wi=function(n,e,t){if(!b(t))throw console.error("Invalid cal l to CSS.set. Property ",e,":: Value ",t,":: Element ",n),new Error("CSS value m ust be a string: "+t);yi(n)&&n.style.setProperty(e,t)},xi=function(n,e,t){var r= n.dom();wi(r,e,t)},Si=function(n,e){var t=n.dom();V(e,function(n,e){wi(t,e,n)})} ,Ti=function(n,e){var t=n.dom(),r=window.getComputedStyle(t).getPropertyValue(e) ,o=""!==r||he(n)?r:Oi(t,e);return null===o?undefined:o},Oi=function(n,e){return yi(n)?n.style.getPropertyValue(e):""},ki=function(n,e){var t=n.dom(),r=Oi(t,e);r eturn F.from(r).filter(function(n){return 0<n.length})},Ci=function(n,e){var t,r ,o=n.dom();r=e,yi(t=o)&&t.style.removeProperty(r),Kr(n,"style")&&""===Yr(n,"styl e").replace(/^\s+|\s+$/g,"")&&Xr(n,"style")},Ei=function(n){return n.dom().offse tWidth};function Di(r,o){var n=function(n){var e=o(n);if(e<=0||null===e){var t=T i(n,r);return parseFloat(t)||0}return e},i=function(o,n){return Sn(n,function(n, e){var t=Ti(o,e),r=t===undefined?0:parseInt(t,10);return isNaN(r)?n:n+r},0)};ret urn{set:function(n,e){if(!x(e)&&!e.match(/^[0-9]+$/))throw r+".set accepts only positive integer values. Value was "+e;var t=n.dom();yi(t)&&(t.style[r]=e+"px")} ,get:n,getOuter:n,aggregate:i,max:function(n,e,t){var r=i(n,t);return r<e?e-r:0} }}var Ii,Ai,Mi=Di("height",function(n){var e=n.dom();return he(n)?e.getBoundingC lientRect().height:e.offsetHeight}),Bi=function(n){return Mi.get(n)},Ri=function (n,e,t){return wn(function(n,e){for(var t=w(e)?e:A(!1),r=n.dom(),o=[];null!==r.p arentNode&&r.parentNode!==undefined;){var i=r.parentNode,u=se.fromDom(i);if(o.pu sh(u),!0===t(u))break;r=i}return o}(n,t),e)},Fi=function(n,e){return wn(ze(t=n). map(je).map(function(n){return wn(n,function(n){return!Ve(t,n)})}).getOr([]),e); var t},Ni=function(n,e){return Fe(e,n)},Vi=function(n){return Ne(n)},Hi=function (n,e,t){return mo(n,function(n){return Be(n,e)},t)},zi=function(n,e){return Ne(e ,n)},ji=function(n,e,t){return lo(Be,Hi,n,e,t)},Li=function(n,e,t){var r=Mn(n.sl ice(0,e)),o=Mn(n.slice(e+1));return Tn(r.concat(o),t)},Ui=function(n,e,t){var r= Mn(n.slice(0,e));return Tn(r,t)},Pi=function(n,e,t){var r=n.slice(0,e),o=n.slice (e+1);return Tn(o.concat(r),t)},$i=function(n,e,t){var r=n.slice(e+1);return Tn( r,t)},Wi=function(t){return function(n){var e=n.raw();return hn(t,e.which)}},Gi= function(n){return function(e){return In(n,function(n){return n(e)})}},_i=functi on(n){return!0===n.raw().shiftKey},qi=function(n){return!0===n.raw().ctrlKey},Yi =S(_i),Ki=function(n,e){return{matches:n,classification:e}},Xi=function(n,e,t,r) {var o=n+e;return r<o?t:o<t?r:o},Ji=function(n,e,t){return n<=e?e:t<=n?t:n},Qi=f unction(e,t,n){var r=Ni(e.element(),"."+t.highlightClass());yn(r,function(n){ro( n,t.highlightClass()),e.getSystem().getByDom(n).each(function(n){t.onDehighlight ()(e,n)})})},Zi=function(n,e,t,r){var o=nu(n,e,t,r);Qi(n,e),to(r.element(),e.hig hlightClass()),o||e.onHighlight()(n,r)},nu=function(n,e,t,r){return io(r.element (),e.highlightClass())},eu=function(n,e,t,r){var o=Ni(n.element(),"."+e.itemClas s());return F.from(o[r]).fold(function(){return nt.error("No element found with index "+r)},n.getSystem().getByDom)},tu=function(e,n,t){return zi(e.element(),". "+n.itemClass()).bind(function(n){return e.getSystem().getByDom(n).toOption()})} ,ru=function(e,n,t){var r=Ni(e.element(),"."+n.itemClass());return(0<r.length?F. some(r[r.length-1]):F.none()).bind(function(n){return e.getSystem().getByDom(n). toOption()})},ou=function(t,e,n,r){var o=Ni(t.element(),"."+e.itemClass());retur n On(o,function(n){return io(n,e.highlightClass())}).bind(function(n){var e=Xi(n ,r,0,o.length-1);return t.getSystem().getByDom(o[e]).toOption()})},iu=Object.fre eze({dehighlightAll:Qi,dehighlight:function(n,e,t,r){var o=nu(n,e,t,r);ro(r.elem ent(),e.highlightClass()),o&&e.onDehighlight()(n,r)},highlight:Zi,highlightFirst :function(e,t,r){tu(e,t,r).each(function(n){Zi(e,t,r,n)})},highlightLast:functio n(e,t,r){ru(e,t,r).each(function(n){Zi(e,t,r,n)})},highlightAt:function(e,t,r,n) {eu(e,t,r,n).fold(function(n){throw new Error(n)},function(n){Zi(e,t,r,n)})},hig hlightBy:function(e,t,r,n){var o=Ni(e.element(),"."+t.itemClass()),i=Ao(bn(o,fun ction(n){return e.getSystem().getByDom(n).toOption()}));Tn(i,n).each(function(n) {Zi(e,t,r,n)})},isHighlighted:nu,getHighlighted:function(e,n,t){return zi(e.elem ent(),"."+n.highlightClass()).bind(function(n){return e.getSystem().getByDom(n). toOption()})},getFirst:tu,getLast:ru,getPrevious:function(n,e,t){return ou(n,e,0 ,-1)},getNext:function(n,e,t){return ou(n,e,0,1)}}),uu=[Zt("highlightClass"),Zt( "itemClass"),$o("onHighlight"),$o("onDehighlight")],au=Pr({fields:uu,name:"highl ighting",apis:iu}),cu=function(){return{get:function(n){return yo(n.element())}, set:function(n,e){n.getSystem().triggerFocus(e,n.element())}}},su=function(n,e,a ,t,r,i){var u=function(e,t,r,o){var n,i,u=a(e,t,r,o);return(n=u,i=t.event(),Tn(n ,function(n){return n.matches(i)}).map(function(n){return n.classification})).bi nd(function(n){return n(e,t,r,o)})},o={schema:function(){return n.concat([ur("fo cusManager",cu()),qo("handler",o),qo("state",e)])},processKey:u,toEvents:functio n(r,o){var n=t(r,o),e=lr(i.map(function(t){return mr(Gn(),function(n,e){t(n,r,o, e),e.stop()})}).toArray().concat([mr(q(),function(n,e){u(n,e,r,o).each(function( n){e.stop()})})]));return k(n,e)},toApis:r};return o},fu=function(n){var e=[rr(" onEscape"),rr("onEnter"),ur("selector",'[data-alloy-tabstop="true"]'),ur("firstT abstop",0),ur("useTabstopAt",A(!0)),rr("visibilitySelector")].concat([n]),u=func tion(n,e){var t=n.visibilitySelector().bind(function(n){return ji(e,n)}).getOr(e );return 0<Bi(t)},a=function(e,n,t,r,o){return o(n,t,function(n){return u(e=r,t= n)&&e.useTabstopAt()(t);var e,t}).fold(function(){return r.cyclic()?F.some(!0):F .none()},function(n){return r.focusManager().set(e,n),F.some(!0)})},i=function(e ,n,t,r){var o,i,u=Ni(e.element(),t.selector());return(o=e,i=t,i.focusManager().g et(o).bind(function(n){return ji(n,i.selector())})).bind(function(n){return On(u ,l(Ve,n)).bind(function(n){return a(e,u,n,t,r)})})},t=A([Ki(Gi([_i,Wi([9])]),fun ction(n,e,t,r){var o=t.cyclic()?Li:Ui;return i(n,0,t,o)}),Ki(Wi([9]),function(n, e,t,r){var o=t.cyclic()?Pi:$i;return i(n,0,t,o)}),Ki(Wi([27]),function(e,t,n,r){ return n.onEscape().bind(function(n){return n(e,t)})}),Ki(Gi([Yi,Wi([13])]),func tion(e,t,n,r){return n.onEnter().bind(function(n){return n(e,t)})})]),r=A({}),o= A({});return su(e,zr.init,t,r,o,F.some(function(e,t){var n,r,o,i;(n=e,r=t,o=Ni(n .element(),r.selector()),i=wn(o,function(n){return u(r,n)}),F.from(i[r.firstTabs top()])).each(function(n){t.focusManager().set(e,n)})}))},lu=fu(cr("cyclic",A(!1 ))),du=fu(cr("cyclic",A(!0))),mu=function(n){return"input"===me(n)&&"radio"!==Yr (n,"type")||"textarea"===me(n)},gu=function(n,e,t){return mu(t)&&Wi([32])(e.even t())?F.none():(ue(n,t,Yn()),F.some(!0))},vu=[ur("execute",gu),ur("useSpace",!1), ur("useEnter",!0),ur("useControlEnter",!1),ur("useDown",!1)],pu=function(n,e,t){ return t.execute()(n,e,n.element())},hu=A({}),bu=A({}),yu=su(vu,zr.init,function (n,e,t,r){var o=t.useSpace()&&!mu(n.element())?[32]:[],i=t.useEnter()?[13]:[],u= t.useDown()?[40]:[],a=o.concat(i).concat(u);return[Ki(Wi(a),pu)].concat(t.useCon trolEnter()?[Ki(Gi([qi,Wi([13])]),pu)]:[])},hu,bu,F.none()),wu=function(n){var t =fo(F.none());return jr({readState:A({}),setGridSize:function(n,e){t.set(F.some( {numRows:A(n),numColumns:A(e)}))},getNumRows:function(){return t.get().map(funct ion(n){return n.numRows()})},getNumColumns:function(){return t.get().map(functio n(n){return n.numColumns()})}})},xu=Object.freeze({flatgrid:wu,init:function(n){ return n.state()(n)}}),Su=function(e,t){return function(n){return"rtl"===Tu(n)?t :e}},Tu=function(n){return"rtl"===Ti(n,"direction")?"rtl":"ltr"},Ou=function(i){ return function(n,e,t,r){var o=i(n.element());return Du(o,n,e,t,r)}},ku=function (n,e){var t=Su(n,e);return Ou(t)},Cu=function(n,e){var t=Su(e,n);return Ou(t)},E u=function(o){return function(n,e,t,r){return Du(o,n,e,t,r)}},Du=function(e,t,n, r,o){return r.focusManager().get(t).bind(function(n){return e(t.element(),n,r,o) }).map(function(n){return r.focusManager().set(t,n),!0})},Iu=Eu,Au=Eu,Mu=Eu,Bu=f unction(n){var e,t=n.dom();return!((e=t).offsetWidth<=0&&e.offsetHeight<=0)},Ru= Ce(["index","candidates"],[]),Fu=function(n,e,t){return Nu(n,e,t,Bu)},Nu=functio n(n,e,t,r){var o,i=l(Ve,e),u=Ni(n,t),a=wn(u,Bu);return On(o=a,i).map(function(n) {return Ru({index:n,candidates:o})})},Vu=function(n,e){return On(n,function(n){r eturn Ve(e,n)})},Hu=function(t,n,r,e){return e(Math.floor(n/r),n%r).bind(functio n(n){var e=n.row()*r+n.column();return 0<=e&&e<t.length?F.some(t[e]):F.none()})} ,zu=function(o,n,i,u,a){return Hu(o,n,u,function(n,e){var t=n===i-1?o.length-n*u :u,r=Xi(e,a,0,t-1);return F.some({row:A(n),column:A(r)})})},ju=function(i,n,u,a, c){return Hu(i,n,a,function(n,e){var t=Xi(n,c,0,u-1),r=t===u-1?i.length-t*a:a,o= Ji(e,0,r-1);return F.some({row:A(t),column:A(o)})})},Lu=[Zt("selector"),ur("exec ute",gu),Wo("onEscape"),ur("captureTab",!1),Ko()],Uu=function(o){return function (n,e,t,r){return Fu(n,e,t.selector()).bind(function(n){return o(n.candidates(),n .index(),r.getNumRows().getOr(t.initSize().numRows()),r.getNumColumns().getOr(t. initSize().numColumns()))})}},Pu=function(n,e,t,r){return t.captureTab()?F.some( !0):F.none()},$u=Uu(function(n,e,t,r){return zu(n,e,t,r,-1)}),Wu=Uu(function(n,e ,t,r){return zu(n,e,t,r,1)}),Gu=Uu(function(n,e,t,r){return ju(n,e,t,r,-1)}),_u= Uu(function(n,e,t,r){return ju(n,e,t,r,1)}),qu=A([Ki(Wi([37]),ku($u,Wu)),Ki(Wi([ 39]),Cu($u,Wu)),Ki(Wi([38]),Iu(Gu)),Ki(Wi([40]),Au(_u)),Ki(Gi([_i,Wi([9])]),Pu), Ki(Gi([Yi,Wi([9])]),Pu),Ki(Wi([27]),function(n,e,t,r){return t.onEscape()(n,e)}) ,Ki(Wi([32].concat([13])),function(e,t,r,n){return(o=e,i=r,i.focusManager().get( o).bind(function(n){return ji(n,i.selector())})).bind(function(n){return r.execu te()(e,t,n)});var o,i})]),Yu=A({}),Ku=su(Lu,wu,qu,Yu,{},F.some(function(e,t,n){z i(e.element(),t.selector()).each(function(n){t.focusManager().set(e,n)})})),Xu=f unction(n,e,t,o){return Fu(n,t,e).bind(function(n){var e=n.index(),t=n.candidate s(),r=Xi(e,o,0,t.length-1);return F.from(t[r])})},Ju=[Zt("selector"),ur("getInit ial",F.none),ur("execute",gu),ur("executeOnMove",!1),ur("allowVertical",!0)],Qu= function(e,t,r){return(n=e,o=r,o.focusManager().get(n).bind(function(n){return j i(n,o.selector())})).bind(function(n){return r.execute()(e,t,n)});var n,o},Zu=fu nction(n,e,t){return Xu(n,t.selector(),e,-1)},na=function(n,e,t){return Xu(n,t.s elector(),e,1)},ea=function(r){return function(n,e,t){return r(n,e,t).bind(funct ion(){return t.executeOnMove()?Qu(n,e,t):F.some(!0)})}},ta=A({}),ra=A({}),oa=su( Ju,zr.init,function(n,e,t,r){var o=[37].concat(t.allowVertical()?[38]:[]),i=[39] .concat(t.allowVertical()?[40]:[]);return[Ki(Wi(o),ea(ku(Zu,na))),Ki(Wi(i),ea(Cu (Zu,na))),Ki(Wi([13]),Qu),Ki(Wi([32]),Qu)]},ta,ra,F.some(function(e,t){t.getInit ial()(e).or(zi(e.element(),t.selector())).each(function(n){t.focusManager().set( e,n)})})),ia=Ce(["rowIndex","columnIndex","cell"],[]),ua=function(n,e,t){return F.from(n[e]).bind(function(n){return F.from(n[t]).map(function(n){return ia({row Index:e,columnIndex:t,cell:n})})})},aa=function(n,e,t,r){var o=n[e].length,i=Xi( t,r,0,o-1);return ua(n,e,i)},ca=function(n,e,t,r){var o=Xi(t,r,0,n.length-1),i=n [o].length,u=Ji(e,0,i-1);return ua(n,o,u)},sa=function(n,e,t,r){var o=n[e].lengt h,i=Ji(t+r,0,o-1);return ua(n,e,i)},fa=function(n,e,t,r){var o=Ji(t+r,0,n.length -1),i=n[o].length,u=Ji(e,0,i-1);return ua(n,o,u)},la=[tr("selectors",[Zt("row"), Zt("cell")]),ur("cycles",!0),ur("previousSelector",F.none),ur("execute",gu)],da= function(n,e){return function(t,r,i){var u=i.cycles()?n:e;return ji(r,i.selector s().row()).bind(function(n){var e=Ni(n,i.selectors().cell());return Vu(e,r).bind (function(r){var o=Ni(t,i.selectors().row());return Vu(o,n).bind(function(n){var e,t=(e=i,bn(o,function(n){return Ni(n,e.selectors().cell())}));return u(t,n,r). map(function(n){return n.cell()})})})})}},ma=da(function(n,e,t){return aa(n,e,t, -1)},function(n,e,t){return sa(n,e,t,-1)}),ga=da(function(n,e,t){return aa(n,e,t ,1)},function(n,e,t){return sa(n,e,t,1)}),va=da(function(n,e,t){return ca(n,t,e, -1)},function(n,e,t){return fa(n,t,e,-1)}),pa=da(function(n,e,t){return ca(n,t,e ,1)},function(n,e,t){return fa(n,t,e,1)}),ha=A([Ki(Wi([37]),ku(ma,ga)),Ki(Wi([39 ]),Cu(ma,ga)),Ki(Wi([38]),Iu(va)),Ki(Wi([40]),Au(pa)),Ki(Wi([32].concat([13])),f unction(e,t,r){return yo(e.element()).bind(function(n){return r.execute()(e,t,n) })})]),ba=A({}),ya=A({}),wa=su(la,zr.init,ha,ba,ya,F.some(function(e,t){t.previo usSelector()(e).orThunk(function(){var n=t.selectors();return zi(e.element(),n.c ell())}).each(function(n){t.focusManager().set(e,n)})})),xa=[Zt("selector"),ur(" execute",gu),ur("moveOnTab",!1)],Sa=function(e,t,r){return r.focusManager().get( e).bind(function(n){return r.execute()(e,t,n)})},Ta=function(n,e,t){return Xu(n, t.selector(),e,-1)},Oa=function(n,e,t){return Xu(n,t.selector(),e,1)},ka=A([Ki(W i([38]),Mu(Ta)),Ki(Wi([40]),Mu(Oa)),Ki(Gi([_i,Wi([9])]),function(n,e,t){return t .moveOnTab()?Mu(Ta)(n,e,t):F.none()}),Ki(Gi([Yi,Wi([9])]),function(n,e,t){return t.moveOnTab()?Mu(Oa)(n,e,t):F.none()}),Ki(Wi([13]),Sa),Ki(Wi([32]),Sa)]),Ca=A({ }),Ea=A({}),Da=su(xa,zr.init,ka,Ca,Ea,F.some(function(e,t){zi(e.element(),t.sele ctor()).each(function(n){t.focusManager().set(e,n)})})),Ia=[Wo("onSpace"),Wo("on Enter"),Wo("onShiftEnter"),Wo("onLeft"),Wo("onRight"),Wo("onTab"),Wo("onShiftTab "),Wo("onUp"),Wo("onDown"),Wo("onEscape"),rr("focusIn")],Aa=su(Ia,zr.init,functi on(n,e,t){return[Ki(Wi([32]),t.onSpace()),Ki(Gi([Yi,Wi([13])]),t.onEnter()),Ki(G i([_i,Wi([13])]),t.onShiftEnter()),Ki(Gi([_i,Wi([9])]),t.onShiftTab()),Ki(Gi([Yi ,Wi([9])]),t.onTab()),Ki(Wi([38]),t.onUp()),Ki(Wi([40]),t.onDown()),Ki(Wi([37]), t.onLeft()),Ki(Wi([39]),t.onRight()),Ki(Wi([32]),t.onSpace()),Ki(Wi([27]),t.onEs cape())]},function(){return{}},function(){return{}},F.some(function(e,t){return t.focusIn().bind(function(n){return n(e,t)})})),Ma=lu.schema(),Ba=du.schema(),Ra =oa.schema(),Fa=Ku.schema(),Na=wa.schema(),Va=yu.schema(),Ha=Da.schema(),za=Aa.s chema(),ja=(Ai=qt("Creating behaviour: "+(Ii={branchKey:"mode",branches:Object.f reeze({acyclic:Ma,cyclic:Ba,flow:Ra,flatgrid:Fa,matrix:Na,execution:Va,menu:Ha,s pecial:za}),name:"keying",active:{events:function(n,e){return n.handler().toEven ts(n,e)}},apis:{focusIn:function(n){n.getSystem().triggerFocus(n.element(),n.ele ment())},setGridSize:function(n,e,t,r,o){Tt(t,"setGridSize")?t.setGridSize(r,o): console.error("Layout does not support setGridSize")}},state:xu}).name,$r,Ii),Ir (Xt(Ai.branchKey,Ai.branches),Ai.name,Ai.active,Ai.apis,Ai.extra,Ai.state)),La=f unction(r,n){return e=r,t={},o=bn(n,function(n){return e=n.name(),t="Cannot conf igure "+n.name()+" for "+r,Lt(e,e,it(),Ft(function(n){return nt.error("The field : "+e+" is forbidden. "+t)}));var e,t}).concat([cr("dump",h)]),Lt(e,e,rt(t),Vt(o ));var e,t,o},Ua=function(n){return n.dump()},Pa="placeholder",$a=et([{single:[" required","valueThunk"]},{multiple:["required","valueThunks"]}]),Wa=function(n,e ,t,r){return t.uiType===Pa?(i=t,u=r,(o=n).exists(function(n){return n!==i.owner} )?$a.single(!0,A(i)):yt(u,i.name).fold(function(){throw new Error("Unknown place holder component: "+i.name+"\nKnown: ["+N(u)+"]\nNamespace: "+o.getOr("none")+"\ nSpec: "+Et(i,null,2))},function(n){return n.replace()})):$a.single(!1,A(t));var o,i,u},Ga=function(i,u,a,c){return Wa(i,0,a,c).fold(function(n,e){var t=e(u,a.c onfig,a.validated),r=yt(t,"components").getOr([]),o=Dn(r,function(n){return Ga(i ,u,n,c)});return[k(t,{components:o})]},function(n,e){return e(u,a.config,a.valid ated)})},_a=function(e,t,n,r){var o,i,u,a=H(r,function(n,e){return r=n,o=!1,{nam e:A(t=e),required:function(){return r.fold(function(n,e){return n},function(n,e) {return n})},used:function(){return o},replace:function(){if(!0===o)throw new Er ror("Trying to use the same placeholder more than once: "+t);return o=!0,r}};var t,r,o}),c=(o=e,i=t,u=a,Dn(n,function(n){return Ga(o,i,n,u)}));return V(a,functi on(n){if(!1===n.used()&&n.required())throw new Error("Placeholder: "+n.name()+" was not found in components list\nNamespace: "+e.getOr("none")+"\nComponents: "+ Et(t.components(),null,2))}),c},qa=$a.single,Ya=$a.multiple,Ka=A(Pa),Xa=0,Ja=fun ction(n){var e=(new Date).getTime();return n+"_"+Math.floor(1e9*Math.random())+ ++Xa+String(e)},Qa=et([{required:["data"]},{external:["data"]},{optional:["data" ]},{group:["data"]}]),Za=ur("factory",{sketch:h}),nc=ur("schema",[]),ec=Zt("name "),tc=Lt("pname","pname",ut(function(n){return"<alloy."+Ja(n.name)+">"}),Jt()),r c=ur("defaults",A({})),oc=ur("overrides",A({})),ic=Vt([Za,nc,ec,tc,rc,oc]),uc=Vt ([Za,nc,ec,tc,rc,oc]),ac=Vt([Za,nc,ec,Zt("unit"),tc,rc,oc]),cc=function(n){var e =function(n){return n.name()};return n.fold(e,e,e,e)},sc=function(t,r){return fu nction(n){var e=Yt("Converting part type",r,n);return t(e)}},fc=sc(Qa.required,i c),lc=sc(Qa.optional,uc),dc=sc(Qa.group,ac),mc=A("entirety"),gc=function(n,e,t,r ){var o=t;return k(e.defaults()(n,t,r),t,{uid:n.partUids()[e.name()]},e.override s()(n,t,r),{"debug.sketcher":wt("part-"+e.name(),o)})},vc=function(o,n){var i={} ;return yn(n,function(n){var e;(e=n,e.fold(F.some,F.none,F.some,F.some)).each(fu nction(t){var r=pc(o,t.pname());i[t.name()]=function(n){var e=qt("Part: "+t.name ()+" in "+o,Vt(t.schema()),n);return k(r,{config:n,validated:e})}})}),i},pc=func tion(n,e){return{uiType:Ka(),owner:n,name:e}},hc=function(n,e,t){return r=e,i={} ,o={},yn(t,function(n){n.fold(function(r){i[r.pname()]=qa(!0,function(n,e,t){ret urn r.factory().sketch(gc(n,r,e,t))})},function(n){var e=r.parts()[n.name()]();o [n.name()]=A(gc(r,n,e[mc()]()))},function(r){i[r.pname()]=qa(!1,function(n,e,t){ return r.factory().sketch(gc(n,r,e,t))})},function(o){i[o.pname()]=Ya(!0,functio n(e,n,t){var r=e[o.name()]();return bn(r,function(n){return o.factory().sketch(k (o.defaults()(e,n),n,o.overrides()(e,n)))})})})}),{internals:A(i),externals:A(o) };var r,i,o},bc=function(n,e,t){return _a(F.some(n),e,e.components(),t)},yc=func tion(n,e,t){var r=e.partUids()[t];return n.getSystem().getByUid(r).toOption()},w c=function(n,e,t){return yc(n,e,t).getOrDie("Could not find part: "+t)},xc=funct ion(e,n){var t=bn(n,cc);return xt(bn(t,function(n){return{key:n,value:e+"-"+n}}) )},Sc=function(e){return Lt("partUids","partUids",at(function(n){return xc(n.uid ,e)}),Jt())},Tc=Ja("alloy-premade"),Oc=Ja("api"),kc=function(n){return wt(Tc,n)} ,Cc=function(o){return n=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t -1]=arguments[t];var r=n.config(Oc);return o.apply(undefined,[r].concat([n].conc at(e)))},e=o.toString(),t=e.indexOf(")")+1,r=e.indexOf("("),i=e.substring(r+1,t- 1).split(/,\s*/),n.toFunctionAnnotation=function(){return{name:"OVERRIDE",parame ters:Sr(i.slice(1))}},n;var n,e,t,r,i},Ec=A(Oc),Dc=A("alloy-id-"),Ic=A("data-all oy-id"),Ac=Dc(),Mc=Ic(),Bc=function(n){var e=ve(n)?Yr(n,Mc):null;return F.from(e )},Rc=function(n){return Ja(n)},Fc=function(n,e,t,r,o){var i,u,a=(u=o,(0<(i=r).l ength?[tr("parts",i)]:[]).concat([Zt("uid"),ur("dom",{}),ur("components",[]),Yo( "originalSpec"),ur("debug.sketcher",{})]).concat(u));return Yt(n+" [SpecSchema]" ,Nt(a.concat(e)),t)},Nc=function(n,e,t,r,o){var i=Vc(o),u=Dn(t,function(n){retur n n.fold(F.none,F.some,F.none,F.none).map(function(n){return tr(n.name(),n.schem a().concat([Yo(mc())]))}).toArray()}),a=Sc(t),c=Fc(n,e,i,u,[a]),s=hc(0,c,t),f=bc (n,c,s.internals());return k(r(c,f,i,s.externals()),{"debug.sketcher":wt(n,o)})} ,Vc=function(n){return k({uid:Rc("uid")},n)},Hc=Nt([Zt("name"),Zt("factory"),Zt( "configFields"),ur("apis",{}),ur("extraApis",{})]),zc=Nt([Zt("name"),Zt("factory "),Zt("configFields"),Zt("partFields"),ur("apis",{}),ur("extraApis",{})]),jc=fun ction(n){var a=qt("Sketcher for "+n.name,Hc,n),e=H(a.apis,Cc),t=H(a.extraApis,fu nction(n,e){return Tr(n,e)});return k({name:A(a.name),partFields:A([]),configFie lds:A(a.configFields),sketch:function(n){return e=a.name,t=a.configFields,r=a.fa ctory,i=Vc(o=n),u=Fc(e,t,i,[],[]),k(r(u,i),{"debug.sketcher":wt(e,o)});var e,t,r ,o,i,u}},e,t)},Lc=function(n){var e=qt("Sketcher for "+n.name,zc,n),t=vc(e.name, e.partFields),r=H(e.apis,Cc),o=H(e.extraApis,function(n,e){return Tr(n,e)});retu rn k({name:A(e.name),partFields:A(e.partFields),configFields:A(e.configFields),s ketch:function(n){return Nc(e.name,e.configFields,e.partFields,e.factory,n)},par ts:A(t)},r,o)},Uc=jc({name:"Button",factory:function(n){var e,t,r,o=(e=n.action( ),t=function(n,e){e.stop(),ie(n)},r=$n.detect().deviceType.isTouch()?[mr(Xn(),t) ]:[mr(X(),t),mr($(),function(n,e){e.cut()})],lr(En([e.map(function(t){return mr( Yn(),function(n,e){t(n),e.stop()})}).toArray(),r]))),i=yt(n.dom(),"attributes"). bind(ht("type")),u=yt(n.dom(),"tag");return{uid:n.uid(),dom:n.dom(),components:n .components(),events:o,behaviours:k(Lr([bi.config({}),ja.config({mode:"execution ",useSpace:!0,useEnter:!0})]),Ua(n.buttonBehaviours())),domModification:{attribu tes:k(i.fold(function(){return u.is("button")?{type:"button"}:{}},function(n){re turn{}}),{role:n.role().getOr("button")})},eventOrder:n.eventOrder()}},configFie lds:[ur("uid",undefined),Zt("dom"),ur("components",[]),La("buttonBehaviours",[bi ,ja]),rr("action"),rr("role"),ur("eventOrder",{})]}),Pc=Pr({fields:[],name:"unse lecting",active:Object.freeze({events:function(n){return lr([dr(Q(),A(!0))])},ex hibit:function(n,e){return Cr({styles:{"-webkit-user-select":"none","user-select ":"none","-ms-user-select":"none","-moz-user-select":"-moz-none"},attributes:{un selectable:"on"}})}})}),$c=function(n){var e,t,r,o=se.fromHtml(n),i=je(o),u=(t=( e=o).dom().attributes!==undefined?e.dom().attributes:[],Sn(t,function(n,e){retur n"class"===e.name?n:k(n,wt(e.name,e.value))},{})),a=(r=o,Array.prototype.slice.c all(r.dom().classList,0)),c=0===i.length?{}:{innerHtml:Oo(o)};return k({tag:me(o ),classes:a,attributes:u},c)},Wc=function(n){var e,o,t=(e=n,o={prefix:mi.prefix( )},e.replace(/\$\{([^{}]*)\}/g,function(n,e){var t,r=o[e];return"string"==(t=typ eof r)||"number"===t?r.toString():n}));return $c(t)},Gc=function(n){return{dom:W c(n)}},_c=function(n){return Lr([ci.config({toggleClass:mi.resolve("toolbar-butt on-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),si(n,function(n,e){(e?c i.on:ci.off)(n)})])},qc=function(n,e,t){return Uc.sketch({dom:Wc('<span class="$ {prefix}-toolbar-button ${prefix}-icon-'+n+' ${prefix}-icon"></span>'),action:e, buttonBehaviours:k(Lr([Pc.config({})]),t)})},Yc={forToolbar:qc,forToolbarCommand :function(n,e){return qc(e,function(){n.execCommand(e)},{})},forToolbarStateActi on:function(n,e,t,r){var o=_c(t);return qc(e,r,o)},forToolbarStateCommand:functi on(n,e){var t=_c(e);return qc(e,function(){n.execCommand(e)},t)}},Kc=function(t, r){return{left:A(t),top:A(r),translate:function(n,e){return Kc(t+n,r+e)}}},Xc=Kc ,Jc=function(n,e,t){return Math.max(e,Math.min(t,n))},Qc=function(n,e,t,r,o,i,u) {var a=t-e;if(r<n.left)return e-1;if(r>n.right)return t+1;var c,s,f,l,d=Math.min (n.right,Math.max(r,n.left))-n.left,m=Jc(d/n.width*a+e,e-1,t+1),g=Math.round(m); return i&&e<=m&&m<=t?(c=m,s=e,f=t,l=o,u.fold(function(){var n=c-s,e=Math.round(n /l)*l;return Jc(s+e,s-1,f+1)},function(n){var e=(c-n)%l,t=Math.round(e/l),r=Math .floor((c-n)/l),o=Math.floor((f-n)/l),i=n+Math.min(o,r+t)*l;return Math.max(n,i) })):g},Zc="slider.change.value",ns=$n.detect().deviceType.isTouch(),es=function( n){return function(n){var e=n.event().raw();if(ns){var t=e;return t.touches!==un defined&&1===t.touches.length?F.some(t.touches[0]).map(function(n){return Xc(n.c lientX,n.clientY)}):F.none()}var r=e;return r.clientX!==undefined?F.some(r).map( function(n){return Xc(n.clientX,n.clientY)}):F.none()}(n).map(function(n){return n.left()})},ts=function(n,e){oe(n,Zc,{value:e})},rs=function(i,u,a,n){return es (n).map(function(n){var e,t,r,o;return e=i,r=n,o=Qc(a,(t=u).min(),t.max(),r,t.st epSize(),t.snapToGrid(),t.snapStart()),ts(e,o),n})},os=function(n,e){var t,r,o,i ,u=(t=e.value().get(),r=e.min(),o=e.max(),i=e.stepSize(),t<r?t:o<t?o:t===r?r-1:M ath.max(r,t-i));ts(n,u)},is=function(n,e){var t,r,o,i,u=(t=e.value().get(),r=e.m in(),o=e.max(),i=e.stepSize(),o<t?t:t<r?r:t===o?o+1:Math.min(o,t+i));ts(n,u)},us =$n.detect().deviceType.isTouch(),as=function(n,r){return lc({name:n+"-edge",ove rrides:function(n){var e=lr([gr(L(),r,[n])]),t=lr([gr($(),r,[n]),gr(W(),function (n,e){e.mouseIsDown().get()&&r(n,e)},[n])]);return{events:us?e:t}}})},cs=[as("le ft",function(n,e){ts(n,e.min()-1)}),as("right",function(n,e){ts(n,e.max()+1)}),f c({name:"thumb",defaults:A({dom:{styles:{position:"absolute"}}}),overrides:funct ion(n){return{events:lr([pr(L(),n,"spectrum"),pr(U(),n,"spectrum"),pr(P(),n,"spe ctrum")])}}}),fc({schema:[cr("mouseIsDown",function(){return fo(!1)})],name:"spe ctrum",overrides:function(r){var t=function(n,e){var t=n.element().dom().getBoun dingClientRect();rs(n,r,t,e)},n=lr([mr(L(),t),mr(U(),t)]),e=lr([mr($(),t),mr(W() ,function(n,e){r.mouseIsDown().get()&&t(n,e)})]);return{behaviours:Lr(us?[]:[ja. config({mode:"special",onLeft:function(n){return os(n,r),F.some(!0)},onRight:fun ction(n){return is(n,r),F.some(!0)}}),bi.config({})]),events:us?n:e}}})],ss=func tion(n,e,t){e.store().manager().onLoad(n,e,t)},fs=function(n,e,t){e.store().mana ger().onUnload(n,e,t)},ls=Object.freeze({onLoad:ss,onUnload:fs,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)}}),ds=Object.freeze({events:function(t,r){v ar n=t.resetOnDom()?[br(function(n,e){ss(n,t,r)}),yr(function(n,e){fs(n,t,r)})]: [Dr(t,r,ss)];return lr(n)}}),ms=function(){var n=fo(null);return jr({set:n.set,g et:n.get,isNotSet:function(){return null===n.get()},clear:function(){n.set(null) },readState:function(){return{mode:"memory",value:n.get()}}})},gs=function(){var n=fo({});return jr({readState:function(){return{mode:"dataset",dataset:n.get()} },set:n.set,get:n.get})},vs=Object.freeze({memory:ms,dataset:gs,manual:function( ){return jr({readState:function(){}})},init:function(n){return n.store().manager ().state(n)}}),ps=function(n,e,t,r){e.store().getDataKey(),t.set({}),e.store().s etData()(n,r),e.onSetValue()(n,r)},hs=[rr("initialValue"),Zt("getFallbackEntry") ,Zt("getDataKey"),Zt("setData"),qo("manager",{setValue:ps,getValue:function(n,e, t){var r=e.store().getDataKey()(n),o=t.get();return yt(o,r).fold(function(){retu rn e.store().getFallbackEntry()(r)},function(n){return n})},onLoad:function(e,t, r){t.store().initialValue().each(function(n){ps(e,t,r,n)})},onUnload:function(n, e,t){t.set({})},state:gs})],bs=[Zt("getValue"),ur("setValue",I),rr("initialValue "),qo("manager",{setValue:function(n,e,t,r){e.store().setValue()(n,r),e.onSetVal ue()(n,r)},getValue:function(n,e,t){return e.store().getValue()(n)},onLoad:funct ion(e,t,n){t.store().initialValue().each(function(n){t.store().setValue()(e,n)}) },onUnload:I,state:zr.init})],ys=[rr("initialValue"),qo("manager",{setValue:func tion(n,e,t,r){t.set(r),e.onSetValue()(n,r)},getValue:function(n,e,t){return t.ge t()},onLoad:function(n,e,t){e.store().initialValue().each(function(n){t.isNotSet ()&&t.set(n)})},onUnload:function(n,e,t){t.clear()},state:ms})],ws=[ar("store",{ mode:"memory"},Xt("mode",{memory:ys,manual:bs,dataset:hs})),$o("onSetValue"),ur( "resetOnDom",!1)],xs=Pr({fields:ws,name:"representing",active:ds,apis:ls,extra:{ setValueFrom:function(n,e){var t=xs.getValue(e);xs.setValue(n,t)}},state:vs}),Ss =$n.detect().deviceType.isTouch(),Ts=[Zt("min"),Zt("max"),ur("stepSize",1),ur("o nChange",I),ur("onInit",I),ur("onDragStart",I),ur("onDragEnd",I),ur("snapToGrid" ,!1),rr("snapStart"),Zt("getInitialValue"),La("sliderBehaviours",[ja,xs]),cr("va lue",function(n){return fo(n.min)})].concat(Ss?[]:[cr("mouseIsDown",function(){r eturn fo(!1)})]),Os=Di("width",function(n){return n.dom().offsetWidth}),ks=funct ion(n,e){Os.set(n,e)},Cs=function(n){return Os.get(n)},Es=$n.detect().deviceType .isTouch(),Ds=Lc({name:"Slider",configFields:Ts,partFields:cs,factory:function(c ,n,e,t){var s=c.max()-c.min(),f=function(n){var e=n.element().dom().getBoundingC lientRect();return(e.left+e.right)/2},o=function(n){return wc(n,c,"thumb")},i=fu nction(n){var e,t,r,o,i=wc(n,c,"spectrum").element().dom().getBoundingClientRect (),u=n.element().dom().getBoundingClientRect(),a=(e=n,t=i,(o=(r=c).value().get() )<r.min()?yc(e,r,"left-edge").fold(function(){return 0},function(n){return f(n)- t.left}):o>r.max()?yc(e,r,"right-edge").fold(function(){return t.width},function (n){return f(n)-t.left}):(r.value().get()-r.min())/s*t.width);return i.left-u.le ft+a},u=function(n){var e=i(n),t=o(n),r=Cs(t.element())/2;xi(t.element(),"left", e-r+"px")},r=function(n,e){var t=c.value().get(),r=o(n);return t!==e||ki(r.eleme nt(),"left").isNone()?(c.value().set(e),u(n),c.onChange()(n,r,e),F.some(!0)):F.n one()},a=Es?[mr(L(),function(n,e){c.onDragStart()(n,o(n))}),mr(P(),function(n,e) {c.onDragEnd()(n,o(n))})]:[mr($(),function(n,e){e.stop(),c.onDragStart()(n,o(n)) ,c.mouseIsDown().set(!0)}),mr(G(),function(n,e){c.onDragEnd()(n,o(n)),c.mouseIsD own().set(!1)})];return{uid:c.uid(),dom:c.dom(),components:n,behaviours:k(Lr(En( [Es?[]:[ja.config({mode:"special",focusIn:function(n){return yc(n,c,"spectrum"). map(ja.focusIn).map(A(!0))}})],[xs.config({store:{mode:"manual",getValue:functio n(n){return c.value().get()}}})]])),Ua(c.sliderBehaviours())),events:lr([mr(Zc,f unction(n,e){r(n,e.event().value())}),br(function(n,e){c.value().set(c.getInitia lValue()());var t=o(n);u(n),c.onInit()(n,t,c.value().get())})].concat(a)),apis:{ resetToMin:function(n){r(n,c.min())},resetToMax:function(n){r(n,c.max())},refres h:u},domModification:{styles:{position:"relative"}}}},apis:{resetToMin:function( n,e){n.resetToMin(e)},resetToMax:function(n,e){n.resetToMax(e)},refresh:function (n,e){n.refresh(e)}}}),Is=function(e,t,r){return Yc.forToolbar(t,function(){var n=r();e.setContextToolbar([{label:t+" group",items:n}])},{})},As=function(n){ret urn[(o=n,i=function(n){return n<0?"black":360<n?"white":"hsl("+n+", 100%, 50%)"} ,Ds.sketch({dom:Wc('<div class="${prefix}-slider ${prefix}-hue-slider-container" ></div>'),components:[Ds.parts()["left-edge"](Gc('<div class="${prefix}-hue-slid er-black"></div>')),Ds.parts().spectrum({dom:Wc('<div class="${prefix}-slider-gr adient-container"></div>'),components:[Gc('<div class="${prefix}-slider-gradient "></div>')],behaviours:Lr([ci.config({toggleClass:mi.resolve("thumb-active")})]) }),Ds.parts()["right-edge"](Gc('<div class="${prefix}-hue-slider-white"></div>') ),Ds.parts().thumb({dom:Wc('<div class="${prefix}-slider-thumb"></div>'),behavio urs:Lr([ci.config({toggleClass:mi.resolve("thumb-active")})])})],onChange:functi on(n,e,t){var r=i(t);xi(e.element(),"background-color",r),o.onChange(n,e,r)},onD ragStart:function(n,e){ci.on(e)},onDragEnd:function(n,e){ci.off(e)},onInit:funct ion(n,e,t){var r=i(t);xi(e.element(),"background-color",r)},stepSize:10,min:0,ma x:360,getInitialValue:o.getInitialValue,sliderBehaviours:Lr([fi(Ds.refresh)])})) ];var o,i},Ms=function(n,r){var e={onChange:function(n,e,t){r.undoManager.transa ct(function(){r.formatter.apply("forecolor",{value:t}),r.nodeChanged()})},getIni tialValue:function(){return-1}};return Is(n,"color",function(){return As(e)})},B s=Nt([Zt("getInitialValue"),Zt("onChange"),Zt("category"),Zt("sizes")]),Rs=funct ion(n){var o=qt("SizeSlider",Bs,n);return Ds.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<o.sizes.le ngth&&o.onChange(t)},onDragStart:function(n,e){ci.on(e)},onDragEnd:function(n,e) {ci.off(e)},min:0,max:o.sizes.length-1,stepSize:1,getInitialValue:o.getInitialVa lue,snapToGrid:!0,sliderBehaviours:Lr([fi(Ds.refresh)]),components:[Ds.parts().s pectrum({dom:Wc('<div class="${prefix}-slider-size-container"></div>'),component s:[Gc('<div class="${prefix}-slider-size-line"></div>')]}),Ds.parts().thumb({dom :Wc('<div class="${prefix}-slider-thumb"></div>'),behaviours:Lr([ci.config({togg leClass:mi.resolve("thumb-active")})])})]})},Fs=["9px","10px","11px","12px","14p x","16px","18px","20px","24px","32px","36px"],Ns=function(n){var e,t,r=n.selecti on.getStart(),o=se.fromDom(r),i=se.fromDom(n.getBody()),u=(e=function(n){return Ve(i,n)},(ve(t=o)?F.some(t):ze(t)).map(function(n){return go(n,function(n){retur n ki(n,"font-size").isSome()},e).bind(function(n){return ki(n,"font-size")}).get OrThunk(function(){return Ti(n,"font-size")})}).getOr(""));return Tn(Fs,function (n){return u===n}).getOr("medium")},Vs={candidates:A(Fs),get:function(n){var e,t =Ns(n);return(e=t,On(Fs,function(n){return n===e})).getOr(2)},apply:function(r,n ){var e;(e=n,F.from(Fs[e])).each(function(n){var e,t;t=n,Ns(e=r)!==t&&e.execComm and("fontSize",!1,t)})}},Hs=Vs.candidates(),zs=function(n){return[Gc('<span clas s="${prefix}-toolbar-button ${prefix}-icon-small-font ${prefix}-icon"></span>'), (e=n,Rs({onChange:e.onChange,sizes:Hs,category:"font",getInitialValue:e.getIniti alValue})),Gc('<span class="${prefix}-toolbar-button ${prefix}-icon-large-font $ {prefix}-icon"></span>')];var e},js=function(n){var e=n.uid!==undefined&&Tt(n,"u id")?n.uid:Rc("memento");return{get:function(n){return n.getSystem().getByUid(e) .getOrDie()},getOpt:function(n){return n.getSystem().getByUid(e).fold(F.none,F.s ome)},asSpec:function(){return k(n,{uid:e})}}};function Ls(n,e){return Ps(docume nt.createElement("canvas"),n,e)}function Us(n){return n.getContext("2d")}functio n Ps(n,e,t){return n.width=e,n.height=t,n}var $s={create:Ls,clone:function(n){va r e;return Us(e=Ls(n.width,n.height)).drawImage(n,0,0),e},resize:Ps,get2dContext :Us,get3dContext:function(n){var e=null;try{e=n.getContext("webgl")||n.getContex t("experimental-webgl")}catch(t){}return e||(e=null),e}},Ws={getWidth:function(n ){return n.naturalWidth||n.width},getHeight:function(n){return n.naturalHeight|| n.height}},Gs=window.Promise?window.Promise:function(){var n=function(n){if("obj ect"!=typeof this)throw new TypeError("Promises must be constructed via new");if ("function"!=typeof n)throw new TypeError("not a function");this._state=null,thi s._value=null,this._deferreds=[],s(n,r(o,this),r(u,this))},e=n.immediateFn||"fun ction"==typeof window.setImmediate&&window.setImmediate||function(n){setTimeout( n,1)};function r(n,e){return function(){n.apply(e,arguments)}}var t=Array.isArra y||function(n){return"[object Array]"===Object.prototype.toString.call(n)};funct ion 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.p ush(r)}function o(n){try{if(n===this)throw new TypeError("A promise cannot be re solved 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._sta te=!0,this._value=n,a.call(this)}catch(t){u.call(this,t)}}function u(n){this._st ate=!1,this._value=n,a.call(this)}function a(){for(var n=0,e=this._deferreds.len gth;n<e;n++)i.call(this,this._deferreds[n]);this._deferreds=null}function c(n,e, t,r){this.onFulfilled="function"==typeof n?n:null,this.onRejected="function"==ty peof e?e:null,this.resolve=t,this.reject=r}function s(n,e,t){var r=!1;try{n(func tion(n){r||(r=!0,e(n))},function(n){r||(r=!0,t(n))})}catch(o){if(r)return;r=!0,t (o)}}return n.prototype["catch"]=function(n){return this.then(null,n)},n.prototy pe.then=function(t,r){var o=this;return new n(function(n,e){i.call(o,new c(t,r,n ,e))})},n.all=function(){var c=Array.prototype.slice.call(1===arguments.length&& t(arguments[0])?arguments[0]:arguments);return new n(function(o,i){if(0===c.leng th)return o([]);var u=c.length;function a(e,n){try{if(n&&("object"==typeof n||"f unction"==typeof n)){var t=n.then;if("function"==typeof t)return void t.call(n,f unction(n){a(e,n)},i)}c[e]=n,0==--u&&o(c)}catch(r){i(r)}}for(var n=0;n<c.length; n++)a(n,c[n])})},n.resolve=function(e){return e&&"object"==typeof e&&e.construct or===n?e:new n(function(n){n(e)})},n.reject=function(t){return new n(function(n, e){e(t)})},n.race=function(o){return new n(function(n,e){for(var t=0,r=o.length; t<r;t++)o[t].then(n,e)})},n}();function _s(){return new(Ie.getOrDie("FileReader" ))}var qs={atob:function(n){return Ie.getOrDie("atob")(n)},requestAnimationFrame :function(n){Ie.getOrDie("requestAnimationFrame")(n)}};function Ys(a){return new Gs(function(n,e){var t=URL.createObjectURL(a),r=new Image,o=function(){r.remove EventListener("load",i),r.removeEventListener("error",u)};function i(){o(),n(r)} function u(){o(),e("Unable to load data of type "+a.type+": "+t)}r.addEventListe ner("load",i),r.addEventListener("error",u),r.src=t,r.complete&&i()})}function K s(r){return new Gs(function(n,t){var e=new XMLHttpRequest;e.open("GET",r,!0),e.r esponseType="blob",e.onload=function(){200==this.status&&n(this.response)},e.one rror=function(){var n,e=this;t(0===this.status?((n=new Error("No access to downl oad image")).code=18,n.name="SecurityError",n):new Error("Error "+e.status+" dow nloading image"))},e.send()})}function Xs(n){var e=n.split(","),t=/data:([^;]+)/ .exec(e[0]);if(!t)return F.none();for(var r,o,i,u=t[1],a=e[1],c=qs.atob(a),s=c.l ength,f=Math.ceil(s/1024),l=new Array(f),d=0;d<f;++d){for(var m=1024*d,g=Math.mi n(m+1024,s),v=new Array(g-m),p=m,h=0;p<g;++h,++p)v[h]=c[p].charCodeAt(0);l[d]=(r =v,new(Ie.getOrDie("Uint8Array"))(r))}return F.some((o=l,i={type:u},new(Ie.getOr Die("Blob"))(o,i)))}function Js(t){return new Gs(function(n,e){Xs(t).fold(functi on(){e("uri is not base64: "+t)},n)})}function Qs(t){return new Gs(function(n){v ar e=_s();e.onloadend=function(){n(e.result)},e.readAsDataURL(t)})}var Zs,nf,ef, tf,rf,of,uf,af,cf={blobToImage:Ys,imageToBlob:function(n){var e=n.src;return 0== =e.indexOf("data:")?Js(e):Ks(e)},blobToArrayBuffer:function(t){return new Gs(fun ction(n){var e=_s();e.onloadend=function(){n(e.result)},e.readAsArrayBuffer(t)}) },blobToDataUri:Qs,blobToBase64:function(n){return Qs(n).then(function(n){return n.split(",")[1]})},dataUriToBlobSync:Xs,canvasToBlob:function(n,t,r){return t=t ||"image/png",HTMLCanvasElement.prototype.toBlob?new Gs(function(e){n.toBlob(fun ction(n){e(n)},t,r)}):Js(n.toDataURL(t,r))},canvasToDataURL:function(n,e,t){retu rn e=e||"image/png",n.then(function(n){return n.toDataURL(e,t)})},blobToCanvas:f unction(n){return Ys(n).then(function(n){var e,t;return e=n,URL.revokeObjectURL( e.src),t=$s.create(Ws.getWidth(n),Ws.getHeight(n)),$s.get2dContext(t).drawImage( n,0,0),t})},uriToBlob:function(n){return 0===n.indexOf("blob:")?Ks(n):0===n.inde xOf("data:")?Js(n):null}},sf=function(n){return cf.blobToBase64(n)},ff=function( u){var e=js({dom:{tag:"input",attributes:{accept:"image/*",type:"file",title:""} ,styles:{visibility:"hidden",position:"absolute"}},events:lr([hr(X()),mr(K(),fun ction(n,e){var t,r,o;(t=e,r=t.event(),o=r.raw().target.files||r.raw().dataTransf er.files,F.from(o[0])).each(function(n){var o,i;o=u,sf(i=n).then(function(r){o.u ndoManager.transact(function(){var n=o.editorUpload.blobCache,e=n.create(Ja("mce u"),i,r);n.add(e);var t=o.dom.createHTML("img",{src:e.blobUri()});o.insertConten t(t)})})})})])});return Uc.sketch({dom:Wc('<span class="${prefix}-toolbar-button ${prefix}-icon-image ${prefix}-icon"></span>'),components:[e.asSpec()],action:f unction(n){e.get(n).element().dom().click()}})},lf=function(n){return n.dom().te xtContent},df=function(n){return 0<n.length},mf=function(n){return n===undefined ||null===n?"":n},gf=function(e,t,n){return n.text.filter(df).fold(function(){ret urn Yr(n=e,"href")===lf(n)?F.some(t):F.none();var n},F.some)},vf=function(n){var e=se.fromDom(n.selection.getStart());return ji(e,"a")},pf={getInfo:function(n){ return vf(n).fold(function(){return{url:"",text:n.selection.getContent({format:" text"}),title:"",target:"",link:F.none()}},function(n){return t=lf(e=n),r=Yr(e," href"),o=Yr(e,"title"),i=Yr(e,"target"),{url:mf(r),text:t!==r?mf(t):"",title:mf( o),target:mf(i),link:F.some(e)};var e,t,r,o,i})},applyInfo:function(o,i){i.url.f ilter(df).fold(function(){var e;e=o,i.link.bind(h).each(function(n){e.execComman d("unlink")})},function(e){var n,t,r=(n=i,(t={}).href=e,n.title.filter(df).each( function(n){t.title=n}),n.target.filter(df).each(function(n){t.target=n}),t);i.l ink.bind(h).fold(function(){var n=i.text.filter(df).getOr(e);o.insertContent(o.d om.createHTML("a",r,o.dom.encode(n)))},function(t){var n=gf(t,e,i);qr(t,r),n.eac h(function(n){var e;e=n,t.dom().textContent=e})})})},query:vf},hf=$n.detect(),bf =function(n,e){var t=e.selection.getRng();n(),e.selection.setRng(t)},yf=function (n,e){(hf.os.isAndroid()?bf:s)(e,n)},wf=function(n,e){var t,r;return{key:n,value :{config:{},me:(t=n,r=lr(e),Pr({fields:[Zt("enabled")],name:t,active:{events:A(r )}})),configAsRaw:A({}),initialConfig:{},state:zr}}},xf=Object.freeze({getCurren t:function(n,e,t){return e.find()(n)}}),Sf=[Zt("find")],Tf=Pr({fields:Sf,name:"c omposing",apis:xf}),Of=jc({name:"Container",factory:function(n){return{uid:n.uid (),dom:k({tag:"div",attributes:{role:"presentation"}},n.dom()),components:n.comp onents(),behaviours:Ua(n.containerBehaviours()),events:n.events(),domModificatio n:n.domModification(),eventOrder:n.eventOrder()}},configFields:[ur("components", []),La("containerBehaviours",[]),ur("events",{}),ur("domModification",{}),ur("ev entOrder",{})]}),kf=jc({name:"DataField",factory:function(t){return{uid:t.uid(), dom:t.dom(),behaviours:k(Lr([xs.config({store:{mode:"memory",initialValue:t.getI nitialValue()()}}),Tf.config({find:F.some})]),Ua(t.dataBehaviours())),events:lr( [br(function(n,e){xs.setValue(n,t.getInitialValue()())})])}},configFields:[Zt("u id"),Zt("dom"),Zt("getInitialValue"),La("dataBehaviours",[xs,Tf])]}),Cf=function (n){return n.dom().value},Ef=function(n,e){if(e===undefined)throw new Error("Val ue.set was undefined");n.dom().value=e},Df=A([rr("data"),ur("inputAttributes",{} ),ur("inputStyles",{}),ur("type","input"),ur("tag","input"),ur("inputClasses",[] ),$o("onSetValue"),ur("styles",{}),rr("placeholder"),ur("eventOrder",{}),La("inp utBehaviours",[xs,bi]),ur("selectOnFocus",!0)]),If=function(n){return k(Lr([xs.c onfig({store:{mode:"manual",initialValue:n.data().getOr(undefined),getValue:func tion(n){return Cf(n.element())},setValue:function(n,e){Cf(n.element())!==e&&Ef(n .element(),e)}},onSetValue:n.onSetValue()})]),(e=n,Lr([bi.config({onFocus:!1===e .selectOnFocus()?I:function(n){var e=n.element(),t=Cf(e);e.dom().setSelectionRan ge(0,t.length)}})])),Ua(n.inputBehaviours()));var e},Af=jc({name:"Input",configF ields:Df(),factory:function(n,e){return{uid:n.uid(),dom:(t=n,{tag:t.tag(),attrib utes:k(xt([{key:"type",value:t.type()}].concat(t.placeholder().map(function(n){r eturn{key:"placeholder",value:n}}).toArray())),t.inputAttributes()),styles:t.inp utStyles(),classes:t.inputClasses()}),components:[],behaviours:If(n),eventOrder: n.eventOrder()};var t}}),Mf=Object.freeze({exhibit:function(n,e){return Cr({attr ibutes:xt([{key:e.tabAttr(),value:"true"}])})}}),Bf=[ur("tabAttr","data-alloy-ta bstop")],Rf=Pr({fields:Bf,name:"tabstopping",active:Mf}),Ff=function(n,e){var t= js(Af.sketch({placeholder:e,onSetValue:function(n,e){re(n,Y())},inputBehaviours: Lr([Tf.config({find:F.some}),Rf.config({}),ja.config({mode:"execution"})]),selec tOnFocus:!1})),r=js(Uc.sketch({dom:Wc('<button class="${prefix}-input-container- x ${prefix}-icon-cancel-circle ${prefix}-icon"></button>'),action:function(n){va r e=t.get(n);xs.setValue(e,"")}}));return{name:n,spec:Of.sketch({dom:Wc('<div cl ass="${prefix}-input-container"></div>'),components:[t.asSpec(),r.asSpec()],cont ainerBehaviours:Lr([ci.config({toggleClass:mi.resolve("input-container-empty")}) ,Tf.config({find:function(n){return F.some(t.get(n))}}),wf("input-clearing",[mr( Y(),function(n){var e=t.get(n);(0<xs.getValue(e).length?ci.off:ci.on)(n)})])])}) }},Nf=["input","button","textarea"],Vf=function(n,e,t){e.disabled()&&Pf(n,e,t)}, Hf=function(n){return hn(Nf,me(n.element()))},zf=function(n){_r(n.element(),"dis abled","disabled")},jf=function(n){Xr(n.element(),"disabled")},Lf=function(n){_r (n.element(),"aria-disabled","true")},Uf=function(n){_r(n.element(),"aria-disabl ed","false")},Pf=function(e,n,t){n.disableClass().each(function(n){to(e.element( ),n)}),(Hf(e)?zf:Lf)(e)},$f=function(n){return Hf(n)?Kr(n.element(),"disabled"): "true"===Yr(n.element(),"aria-disabled")},Wf=Object.freeze({enable:function(e,n, t){n.disableClass().each(function(n){ro(e.element(),n)}),(Hf(e)?jf:Uf)(e)},disab le:Pf,isDisabled:$f,onLoad:Vf}),Gf=Object.freeze({exhibit:function(n,e,t){return Cr({classes:e.disabled()?e.disableClass().map(Bn).getOr([]):[]})},events:functi on(n,e){return lr([dr(Yn(),function(n,e){return $f(n)}),Dr(n,e,Vf)])}}),_f=[ur(" disabled",!1),rr("disableClass")],qf=Pr({fields:_f,name:"disabling",active:Gf,ap is:Wf}),Yf=[La("formBehaviours",[xs])],Kf=function(n){return"<alloy.field."+n+"> "},Xf=function(o,n,e){return k({"debug.sketcher":{Form:e},uid:o.uid(),dom:o.dom( ),components:n,behaviours:k(Lr([xs.config({store:{mode:"manual",getValue:functio n(n){var e,t,r=(e=o,t=n.getSystem(),H(e.partUids(),function(n,e){return A(t.getB yUid(n))}));return H(r,function(n,e){return n().bind(Tf.getCurrent).map(xs.getVa lue)})},setValue:function(t,n){V(n,function(e,n){yc(t,o,n).each(function(n){Tf.g etCurrent(n).each(function(n){xs.setValue(n,e)})})})}}})]),Ua(o.formBehaviours() )),apis:{getField:function(n,e){return yc(n,o,e).bind(Tf.getCurrent)}}})},Jf=(Cc (function(n,e,t){return n.getField(e,t)}),function(n){var i,e=(i=[],{field:funct ion(n,e){return i.push(n),t="form",r=Kf(n),o=e,{uiType:Ka(),owner:t,name:r,confi g:o,validated:{}};var t,r,o},record:function(){return i}}),t=n(e),r=e.record(),o =bn(r,function(n){return fc({name:n,pname:Kf(n)})});return Nc("form",Yf,o,Xf,t)} ),Qf=function(){var e=fo(F.none()),t=function(){e.get().each(function(n){n.destr oy()})};return{clear:function(){t(),e.set(F.none())},isSet:function(){return e.g et().isSome()},set:function(n){t(),e.set(F.some(n))},run:function(n){e.get().eac h(n)}}},Zf=function(){var e=fo(F.none());return{clear:function(){e.set(F.none()) },set:function(n){e.set(F.some(n))},isSet:function(){return e.get().isSome()},on :function(n){e.get().each(n)}}},nl=function(n){return{xValue:n,points:[]}},el=fu nction(n,e){if(e===n.xValue)return n;var t=0<e-n.xValue?1:-1,r={direction:t,xVal ue:e};return{xValue:e,points:(0===n.points.length?[]:n.points[n.points.length-1] .direction===t?n.points.slice(0,n.points.length-1):n.points).concat([r])}},tl=fu nction(n){if(0===n.points.length)return 0;var e=n.points[0].direction,t=n.points [n.points.length-1].direction;return-1===e&&-1===t?-1:1===e&&1===t?1:0},rl=funct ion(n){var r="navigateEvent",e=Vt([Zt("fields"),ur("maxFieldIndex",n.fields.leng th-1),Zt("onExecute"),Zt("getInitialValue"),cr("state",function(){return{dialogS wipeState:Zf(),currentScreen:fo(0)}})]),u=qt("SerialisedDialog",e,n),o=function( e,n,t){return Uc.sketch({dom:Wc('<span class="${prefix}-icon-'+n+' ${prefix}-ico n"></span>'),action:function(n){oe(n,r,{direction:e})},buttonBehaviours:Lr([qf.c onfig({disableClass:mi.resolve("toolbar-navigation-disabled"),disabled:!t})])})} ,i=function(n,o){var i=Ni(n.element(),"."+mi.resolve("serialised-dialog-screen") );zi(n.element(),"."+mi.resolve("serialised-dialog-chain")).each(function(r){0<= u.state.currentScreen.get()+o&&u.state.currentScreen.get()+o<i.length&&(ki(r,"le ft").each(function(n){var e=parseInt(n,10),t=Cs(i[0]);xi(r,"left",e-o*t+"px")}), u.state.currentScreen.set(u.state.currentScreen.get()+o))})},a=function(r){var n =Ni(r.element(),"input");F.from(n[u.state.currentScreen.get()]).each(function(n) {r.getSystem().getByDom(n).each(function(n){var e,t;e=r,t=n.element(),e.getSyste m().triggerFocus(t,e.element())})});var e=s.get(r);au.highlightAt(e,u.state.curr entScreen.get())},c=js(Jf(function(t){return{dom:Wc('<div class="${prefix}-seria lised-dialog"></div>'),components:[Of.sketch({dom:Wc('<div class="${prefix}-seri alised-dialog-chain" style="left: 0px; position: absolute;"></div>'),components: bn(u.fields,function(n,e){return e<=u.maxFieldIndex?Of.sketch({dom:Wc('<div clas s="${prefix}-serialised-dialog-screen"></div>'),components:En([[o(-1,"previous", 0<e)],[t.field(n.name,n.spec)],[o(1,"next",e<u.maxFieldIndex)]])}):t.field(n.nam e,n.spec)})})],formBehaviours:Lr([fi(function(n,e){var t;t=e,zi(n.element(),"."+ mi.resolve("serialised-dialog-chain")).each(function(n){xi(n,"left",-u.state.cur rentScreen.get()*t.width+"px")})}),ja.config({mode:"special",focusIn:function(n) {a(n)},onTab:function(n){return i(n,1),F.some(!0)},onShiftTab:function(n){return i(n,-1),F.some(!0)}}),wf("form-events",[br(function(e,n){u.state.currentScreen. set(0),u.state.dialogSwipeState.clear();var t=s.get(e);au.highlightFirst(t),u.ge tInitialValue(e).each(function(n){xs.setValue(e,n)})}),xr(u.onExecute),mr(J(),fu nction(n,e){"left"===e.event().raw().propertyName&&a(n)}),mr(r,function(n,e){var t=e.event().direction();i(n,t)})])])}})),s=js({dom:Wc('<div class="${prefix}-do t-container"></div>'),behaviours:Lr([au.config({highlightClass:mi.resolve("dot-a ctive"),itemClass:mi.resolve("dot-item")})]),components:Dn(u.fields,function(n,e ){return e<=u.maxFieldIndex?[Gc('<div class="${prefix}-dot-item ${prefix}-icon-f ull-dot ${prefix}-icon"></div>')]:[]})});return{dom:Wc('<div class="${prefix}-se rializer-wrapper"></div>'),components:[c.asSpec(),s.asSpec()],behaviours:Lr([ja. config({mode:"special",focusIn:function(n){var e=c.get(n);ja.focusIn(e)}}),wf("s erializer-wrapper-events",[mr(L(),function(n,e){var t=e.event();u.state.dialogSw ipeState.set(nl(t.touches[0].clientX))}),mr(U(),function(n,e){var t=e.event();u. state.dialogSwipeState.on(function(n){e.event().prevent(),u.state.dialogSwipeSta te.set(el(n,t.raw().touches[0].clientX))})}),mr(P(),function(r){u.state.dialogSw ipeState.on(function(n){var e=c.get(r),t=-1*tl(n);i(e,t)})})])])}},ol=Z(function (t,r){return[{label:"the link group",items:[rl({fields:[Ff("url","Type or paste URL"),Ff("text","Link text"),Ff("title","Link title"),Ff("target","Link target") ,(n="link",{name:n,spec:kf.sketch({dom:{tag:"span",styles:{display:"none"}},getI nitialValue:function(){return F.none()}})})],maxFieldIndex:["url","text","title" ,"target"].length-1,getInitialValue:function(){return F.some(pf.getInfo(r))},onE xecute:function(n){var e=xs.getValue(n);pf.applyInfo(r,e),t.restoreToolbar(),r.f ocus()}})]}];var n}),il=[{title:"Headings",items:[{title:"Heading 1",format:"h1" },{title:"Heading 2",format:"h2"},{title:"Heading 3",format:"h3"},{title:"Headin g 4",format:"h4"},{title:"Heading 5",format:"h5"},{title:"Heading 6",format:"h6" }]},{title:"Inline",items:[{title:"Bold",icon:"bold",format:"bold"},{title:"Ital ic",icon:"italic",format:"italic"},{title:"Underline",icon:"underline",format:"u nderline"},{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:"A lignment",items:[{title:"Left",icon:"alignleft",format:"alignleft"},{title:"Cent er",icon:"aligncenter",format:"aligncenter"},{title:"Right",icon:"alignright",fo rmat:"alignright"},{title:"Justify",icon:"alignjustify",format:"alignjustify"}]} ],ul=lr([(Zs=Gn(),nf=function(n,e){var t,r,o=e.event().originator(),i=e.event(). target();return r=i,!(Ve(t=o,n.element())&&!Ve(t,r)&&(console.warn(Gn()+" did no t get interpreted by the desired target. \nOriginator: "+Do(o)+"\nTarget: "+Do(i )+"\nCheck the "+Gn()+" event handlers"),1))},{key:Zs,value:sr({can:nf})})]),al= Object.freeze({events:ul}),cl=h,sl=Hr(["debugInfo","triggerFocus","triggerEvent" ,"triggerEscape","addToWorld","removeFromWorld","addToGui","removeFromGui","buil d","getByUid","getByDom","broadcast","broadcastOn","isConnected"]),fl=function(e ){var n=function(n){return function(){throw new Error("The component must be in a context to send: "+n+"\n"+Do(e().element())+" is not in context.")}};return sl ({debugInfo:A("fake"),triggerEvent:n("triggerEvent"),triggerFocus:n("triggerFocu s"),triggerEscape:n("triggerEscape"),build:n("build"),addToWorld:n("addToWorld") ,removeFromWorld:n("removeFromWorld"),addToGui:n("addToGui"),removeFromGui:n("re moveFromGui"),getByUid:n("getByUid"),getByDom:n("getByDom"),broadcast:n("broadca st"),broadcastOn:n("broadcastOn"),isConnected:A(!1)})},ll=function(n,o){var i={} ;return V(n,function(n,r){V(n,function(n,e){var t=bt(e,[])(i);i[e]=t.concat([o(r ,n)])})}),i},dl=function(n,e){return 1<n.length?nt.error('Multiple behaviours ha ve tried to change DOM "'+e+'". The guilty behaviours are: '+Et(bn(n,function(n) {return n.name()}))+". At this stage, this is not supported. Future releases mig ht provide strategies for resolving this."):0===n.length?nt.value({}):nt.value(n [0].modification().fold(function(){return{}},function(n){return wt(e,n)}))},ml=f unction(u,a){return Sn(u,function(n,e){var t=e.modification().getOr({});return n .bind(function(i){var n=j(t,function(n,e){return i[e]!==undefined?(t=a,r=e,o=u,n t.error("Mulitple behaviours have tried to change the _"+r+'_ "'+t+'". The guilt y behaviours are: '+Et(Dn(o,function(n){return n.modification().getOr({})[r]!==u ndefined?[n.name()]:[]}),null,2)+". This is not currently supported.")):nt.value (wt(e,n));var t,r,o});return St(n,i)})},nt.value({})).map(function(n){return wt( a,n)})},gl={classes:function(n,e){var t=Dn(n,function(n){return n.modification() .getOr([])});return nt.value(wt(e,t))},attributes:ml,styles:ml,domChildren:dl,de fChildren:dl,innerHtml:dl,value:dl},vl=function(n,e){return t=l.apply(undefined, [n.handler].concat(e)),r=n.purpose(),{cHandler:t,purpose:A(r)};var t,r},pl=funct ion(n){return n.cHandler},hl=function(n,e){return{name:A(n),handler:A(e)}},bl=fu nction(n,e,t){var r,o,i=k(t,(r=n,o={},yn(e,function(n){o[n.name()]=n.handlers(r) }),o));return ll(i,hl)},yl=function(n){var e,i=w(e=n)?{can:A(!0),abort:A(!1),run :e}:e;return function(n,e){for(var t=[],r=2;r<arguments.length;r++)t[r-2]=argume nts[r];var o=[n,e].concat(t);i.abort.apply(undefined,o)?e.stop():i.can.apply(und efined,o)&&i.run.apply(undefined,o)}},wl=function(n,e,t){var r,o,i=e[t];return i ?function(u,a,n,c){var e=n.slice(0);try{var t=e.sort(function(n,e){var t=n[a](), r=e[a](),o=c.indexOf(t),i=c.indexOf(r);if(-1===o)throw new Error("The ordering f or "+u+" does not have an entry for "+t+".\nOrder specified: "+Et(c,null,2));if( -1===i)throw new Error("The ordering for "+u+" does not have an entry for "+r+". \nOrder specified: "+Et(c,null,2));return o<i?-1:i<o?1:0});return nt.value(t)}ca tch(r){return nt.error([r])}}("Event: "+t,"name",n,i).map(function(n){var e=bn(n ,function(n){return n.handler()});return fr(e)}):(r=t,o=n,nt.error(["The event ( "+r+') has more than one behaviour that listens to it.\nWhen this occurs, you mu st specify an event ordering for the behaviours in your spec (e.g. [ "listing", "toggling" ]).\nThe behaviours that can trigger it are: '+Et(bn(o,function(n){re turn n.name()}),null,2)]))},xl=function(n,i){var e=j(n,function(r,o){return(1=== r.length?nt.value(r[0].handler()):wl(r,i,o)).map(function(n){var e=yl(n),t=1<r.l ength?wn(i,function(e){return hn(r,function(n){return n.name()===e})}).join(" > "):r[0].name();return wt(o,{handler:e,purpose:A(t)})})});return St(e,{})},Sl=fun ction(n){return Gt("custom.definition",Nt([Lt("dom","dom",ot(),Nt([Zt("tag"),ur( "styles",{}),ur("classes",[]),ur("attributes",{}),rr("value"),rr("innerHtml")])) ,Zt("components"),Zt("uid"),ur("events",{}),ur("apis",A({})),Lt("eventOrder","ev entOrder",(e={"alloy.execute":["disabling","alloy.base.behaviour","toggling"],"a lloy.focus":["alloy.base.behaviour","focusing","keying"],"alloy.system.init":["a lloy.base.behaviour","disabling","toggling","representing"],input:["alloy.base.b ehaviour","representing","streaming","invalidating"],"alloy.system.detached":["a lloy.base.behaviour","representing"]},tt.mergeWithThunk(A(e))),Jt()),rr("domModi fication"),Yo("originalSpec"),ur("debug.sketcher","unknown")]),n);var e},Tl=func tion(n){var e,t={tag:n.dom().tag(),classes:n.dom().classes(),attributes:k((e=n,w t(Ic(),e.uid())),n.dom().attributes()),styles:n.dom().styles(),domChildren:bn(n. components(),function(n){return n.element()})};return Or(k(t,n.dom().innerHtml() .map(function(n){return wt("innerHtml",n)}).getOr({}),n.dom().value().map(functi on(n){return wt("value",n)}).getOr({})))},Ol=function(e,n){yn(n,function(n){to(e ,n)})},kl=function(e,n){yn(n,function(n){ro(e,n)})},Cl=function(e){if(e.domChild ren().isSome()&&e.defChildren().isSome())throw new Error("Cannot specify childre n and child specs! Must be one or the other.\nDef: "+(n=kr(e),Et(n,null,2)));ret urn e.domChildren().fold(function(){var n=e.defChildren().getOr([]);return bn(n, Dl)},function(n){return n});var n},El=function(n){var e=se.fromTag(n.tag());qr(e ,n.attributes().getOr({})),Ol(e,n.classes().getOr([])),Si(e,n.styles().getOr({}) ),ko(e,n.innerHtml().getOr(""));var t=Cl(n);return $e(e,t),n.value().each(functi on(n){Ef(e,n)}),e},Dl=function(n){var e=Or(n);return El(e)},Il=function(n,e){ret urn t=n,o=bn(r=e,function(n){return or(n.name(),[Zt("config"),ur("state",zr)])}) ,i=Gt("component.behaviours",Vt(o),t.behaviours).fold(function(n){throw new Erro r(Kt(n)+"\nComplete spec:\n"+Et(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},Al=function(n ){var e,t,r=(e=yt(n,"behaviours").getOr({}),t=wn(N(e),function(n){return e[n]!== undefined}),bn(t,function(n){return e[n].me}));return Il(n,r)},Ml=Hr(["getSystem ","config","hasConfigured","spec","connect","disconnect","element","syncComponen ts","readState","components","events"]),Bl=function(n,e,t){var r,o,i,u,a=Tl(n),c =function(e,n,t,r){var o=k({},n);yn(t,function(n){o[n.name()]=n.exhibit(e,r)});v ar i=ll(o,function(n,e){return{name:function(){return n},modification:e}}),u=H(i ,function(n,e){return Dn(n,function(e){return e.modification().fold(function(){r eturn[]},function(n){return[e]})})}),a=j(u,function(e,t){return yt(gl,t).fold(fu nction(){return nt.error("Unknown field type: "+t)},function(n){return n(e,t)})} );return St(a,{}).map(Cr)}(t,{"alloy.base.modification":(r=n,r.domModification() .fold(function(){return Cr({})},Cr))},e,a).getOrDie();return i=c,u=k({tag:(o=a). tag(),classes:i.classes().getOr([]).concat(o.classes().getOr([])),attributes:C(o .attributes().getOr({}),i.attributes().getOr({})),styles:C(o.styles().getOr({}), i.styles().getOr({}))},i.innerHtml().or(o.innerHtml()).map(function(n){return wt ("innerHtml",n)}).getOr({}),Er("domChildren",i.domChildren(),o.domChildren()),Er ("defChildren",i.defChildren(),o.defChildren()),i.value().or(o.value()).map(func tion(n){return wt("value",n)}).getOr({})),Or(u)},Rl=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=bl(o,u,a),xl(c,i)).getOrDie()},Fl=function(n){var e,t,r,o,i,u,a,c,s,f,l,d, m,g,v=cl(n),p=(e=v,t=bt("components",[])(e),bn(t,Hl)),h=k(al,v,wt("components",p ));return nt.value((r=h,i=fo(fl(o=function(){return g})),u=_t(Sl(k(r,{behaviours :undefined}))),a=Al(r),c=a.list,s=a.data,f=Bl(u,c,s),l=El(f),d=Rl(u,c,s),m=fo(u. components()),g=Ml({getSystem:i.get,config:function(n){if(n===Ec())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 "+Et(r,null,2))})()},hasConfigured:function(n){return w(s[n.name( )])},spec:A(r),readState:function(n){return s[n]().map(function(n){return n.stat e.readState()}).getOr("not enabled")},connect:function(n){i.set(n)},disconnect:f unction(){i.set(fl(o))},element:A(l),syncComponents:function(){var n=je(l),e=Dn( n,function(n){return i.get().getByDom(n).fold(function(){return[]},function(n){r eturn[n]})});m.set(e)},components:m.get,events:A(d)})))},Nl=function(n){var e=se .fromText(n);return Vl({element:e})},Vl=function(n){var t=Yt("external.component ",Nt([Zt("element"),rr("uid")]),n),e=fo(fl());t.uid().each(function(n){var e;e=t .element(),_r(e,Mc,n)});var r=Ml({getSystem:e.get,config:F.none,hasConfigured:A( !1),connect:function(n){e.set(n)},disconnect:function(){e.set(fl(function(){retu rn r}))},element:A(t.element()),spec:A(n),readState:A("No state"),syncComponents :I,components:A([]),events:A({})});return kc(r)},Hl=function(e){return(n=e,yt(n, Tc)).fold(function(){var n=k({uid:Rc("")},e);return Fl(n).getOrDie()},function(n ){return n});var n},zl=kc,jl="alloy.item-hover",Ll="alloy.item-focus",Ul=functio n(n){(yo(n.element()).isNone()||bi.isFocused(n))&&(bi.isFocused(n)||bi.focus(n), oe(n,jl,{item:n}))},Pl=function(n){oe(n,Ll,{item:n})},$l=A(jl),Wl=A(Ll),Gl=[Zt(" data"),Zt("components"),Zt("dom"),rr("toggling"),ur("itemBehaviours",{}),ur("ign oreFocus",!1),ur("domModification",{}),qo("builder",function(n){return{dom:k(n.d om(),{attributes:{role:n.toggling().isSome()?"menuitemcheckbox":"menuitem"}}),be haviours:k(Lr([n.toggling().fold(ci.revoke,function(n){return ci.config(k({aria: {mode:"checked"}},n))}),bi.config({ignore:n.ignoreFocus(),onFocus:function(n){Pl (n)}}),ja.config({mode:"execution"}),xs.config({store:{mode:"memory",initialValu e:n.data()}})]),n.itemBehaviours()),events:lr([(e=Jn(),r=ie,mr(e,function(e,t){v ar n=t.event();e.getSystem().getByDom(n.target()).each(function(n){r(e,n,t)})})) ,hr($()),mr(_(),Ul),mr(Kn(),bi.focus)]),components:n.components(),domModificatio n:n.domModification(),eventOrder:n.eventOrder()};var e,r}),ur("eventOrder",{})], _l=[Zt("dom"),Zt("components"),qo("builder",function(n){return{dom:n.dom(),compo nents:n.components(),events:lr([(e=Kn(),mr(e,function(n,e){e.stop()}))])};var e} )],ql=A([fc({name:"widget",overrides:function(e){return{behaviours:Lr([xs.config ({store:{mode:"manual",getValue:function(n){return e.data()},setValue:function() {}}})])}}})]),Yl=[Zt("uid"),Zt("data"),Zt("components"),Zt("dom"),ur("autofocus" ,!1),ur("domModification",{}),Sc(ql()),qo("builder",function(t){var n=hc(0,t,ql( )),e=bc("item-widget",t,n.internals()),r=function(n){return yc(n,t,"widget").map (function(n){return ja.focusIn(n),n})},o=function(n,e){return mu(e.event().targe t())||t.autofocus()&&e.setSource(n.element()),F.none()};return k({dom:t.dom(),co mponents:e,domModification:t.domModification(),events:lr([xr(function(n,e){r(n). each(function(n){e.stop()})}),mr(_(),Ul),mr(Kn(),function(n,e){t.autofocus()?r(n ):bi.focus(n)})]),behaviours:Lr([xs.config({store:{mode:"memory",initialValue:t. data()}}),bi.config({onFocus:function(n){Pl(n)}}),ja.config({mode:"special",focu sIn:t.autofocus()?function(n){r(n)}:Wr(),onLeft:o,onRight:o,onEscape:function(n, e){return bi.isFocused(n)||t.autofocus()?(t.autofocus()&&e.setSource(n.element() ),F.none()):(bi.focus(n),F.some(!0))}})])})})],Kl=Xt("type",{widget:Yl,item:Gl,s eparator:_l}),Xl=A([dc({factory:{sketch:function(n){var e=Yt("menu.spec item",Kl ,n);return e.builder()(e)}},name:"items",unit:"item",defaults:function(n,e){var t=Rc("");return k({uid:t},e)},overrides:function(n,e){return{type:e.type,ignoreF ocus:n.fakeFocus(),domModification:{classes:[n.markers().item()]}}}})]),Jl=A([Zt ("value"),Zt("items"),Zt("dom"),Zt("components"),ur("eventOrder",{}),La("menuBeh aviours",[au,xs,Tf,ja]),ar("movement",{mode:"menu",moveOnTab:!0},Xt("mode",{grid :[Ko(),qo("config",function(n,e){return{mode:"flatgrid",selector:"."+n.markers() .item(),initSize:{numColumns:e.initSize().numColumns(),numRows:e.initSize().numR ows()},focusManager:n.focusManager()}})],menu:[ur("moveOnTab",!0),qo("config",fu nction(n,e){return{mode:"menu",selector:"."+n.markers().item(),moveOnTab:e.moveO nTab(),focusManager:n.focusManager()}})]})),nr("markers",Lo()),ur("fakeFocus",!1 ),ur("focusManager",cu()),$o("onHighlight")]),Ql=A("alloy.menu-focus"),Zl=Lc({na me:"Menu",configFields:Jl(),partFields:Xl(),factory:function(n,e,t,r){return k({ dom:k(n.dom(),{attributes:{role:"menu"}}),uid:n.uid(),behaviours:k(Lr([au.config ({highlightClass:n.markers().selectedItem(),itemClass:n.markers().item(),onHighl ight:n.onHighlight()}),xs.config({store:{mode:"memory",initialValue:n.value()}}) ,Tf.config({find:F.some}),ja.config(n.movement().config()(n,n.movement()))]),Ua( n.menuBehaviours())),events:lr([mr(Wl(),function(e,t){var n=t.event();e.getSyste m().getByDom(n.target()).each(function(n){au.highlight(e,n),t.stop(),oe(e,Ql(),{ menu:e,item:n})})}),mr($l(),function(n,e){var t=e.event().item();au.highlight(n, t)})]),components:e,eventOrder:n.eventOrder()})}}),nd=function(n,e,t,r){var o=n. getSystem().build(r);Ke(n,o,t)},ed=function(n,e){return n.components()},td=Pr({f ields:[],name:"replacing",apis:Object.freeze({append:function(n,e,t,r){nd(n,0,Pe ,r)},prepend:function(n,e,t,r){nd(n,0,Ue,r)},remove:function(n,e,t,r){var o=ed(n ,e);Tn(o,function(n){return Ve(r.element(),n.element())}).each(Je)},set:function (e,n,t,r){var o,i,u,a,c,s;i=(o=e).components(),yn(i,Xe),We(o.element()),o.syncCo mponents(),u=function(){var n=bn(r,e.getSystem().build);yn(n,function(n){Ye(e,n) })},a=e.element(),c=He(a),s=bo(c).bind(function(e){var n=function(n){return Ve(e ,n)};return n(a)?F.some(a):vo(a,n)}),u(a),s.each(function(e){bo(c).filter(functi on(n){return Ve(n,e)}).fold(function(){po(e)},I)})},contents:ed})}),rd=function( t,r,o,n){return yt(o,n).bind(function(n){return yt(t,n).bind(function(n){var e=r d(t,r,o,n);return F.some([n].concat(e))})}).getOr([])},od=function(n,e){var t={} ;V(n,function(n,e){yn(n,function(n){t[n]=e})});var r=e,o=z(e,function(n,e){retur n{k:n,v:e}}),i=H(o,function(n,e){return[e].concat(rd(t,r,o,e))});return H(t,func tion(n){return yt(i,n).getOr([n])})},id=function(){var i=fo({}),u=fo({}),a=fo({} ),c=fo(F.none()),s=fo({}),n=function(n){return yt(u.get(),n)};return{setContents :function(n,e,t,r){c.set(F.some(n)),i.set(t),u.set(e),s.set(r);var o=od(r,t);a.s et(o)},expand:function(t){return yt(i.get(),t).map(function(n){var e=yt(a.get(), t).getOr([]);return[n].concat(e)})},refresh:function(n){return yt(a.get(),n)},co llapse:function(n){return yt(a.get(),n).bind(function(n){return 1<n.length?F.som e(n.slice(1)):F.none()})},lookupMenu:n,otherMenus:function(n){var e,t,r=s.get(); return e=N(r),t=n,wn(e,function(n){return!hn(t,n)})},getPrimary:function(){retur n c.get().bind(n)},getMenus:function(){return u.get()},clear:function(){i.set({} ),u.set({}),a.set({}),c.set(F.none())},isClear:function(){return c.get().isNone( )}}},ud=A("collapse-item"),ad=jc({name:"TieredMenu",configFields:[_o("onExecute" ),_o("onEscape"),Go("onOpenMenu"),Go("onOpenSubmenu"),$o("onCollapseMenu"),ur("o penImmediately",!0),tr("data",[Zt("primary"),Zt("menus"),Zt("expansions")]),ur(" fakeFocus",!1),$o("onHighlight"),$o("onHover"),tr("markers",[Zt("backgroundMenu" )].concat(zo()).concat(jo())),Zt("dom"),ur("navigateOnHover",!0),ur("stayInDom", !1),La("tmenuBehaviours",[ja,au,Tf,td]),ur("eventOrder",{})],apis:{collapseMenu: function(n,e){n.collapseMenu(e)}},factory:function(u,o){var i=function(r,n){retu rn H(n,function(n,e){var t=Zl.sketch(k(n,{value:e,items:n.items,markers:vt(o.mar kers,["item","selectedItem"]),fakeFocus:u.fakeFocus(),onHighlight:u.onHighlight( ),focusManager:u.fakeFocus()?{get:function(n){return au.getHighlighted(n).map(fu nction(n){return n.element()})},set:function(e,n){e.getSystem().getByDom(n).fold (I,function(n){au.highlight(e,n)})}}:cu()}));return r.getSystem().build(t)})},a= id(),c=function(n){return xs.getValue(n).value},s=function(n){return H(u.data(). menus(),function(n,e){return Dn(n.items,function(n){return"separator"===n.type?[ ]:[n.data.value]})})},f=function(e,n){au.highlight(e,n),au.getHighlighted(n).orT hunk(function(){return au.getFirst(n)}).each(function(n){ue(e,n.element(),Kn())} )},l=function(n,e){return Ao(bn(e,n.lookupMenu))},d=function(r,o,i){return F.fro m(i[0]).bind(o.lookupMenu).map(function(n){var e=l(o,i.slice(1));yn(e,function(n ){to(n.element(),u.markers().backgroundMenu())}),he(n.element())||td.append(r,zl (n)),kl(n.element(),[u.markers().backgroundMenu()]),f(r,n);var t=l(o,o.otherMenu s(i));return yn(t,function(n){kl(n.element(),[u.markers().backgroundMenu()]),u.s tayInDom()||td.remove(r,n)}),n})},m=function(e,t){var n=c(t);return a.expand(n). bind(function(n){return F.from(n[0]).bind(a.lookupMenu).each(function(n){he(n.el ement())||td.append(e,zl(n)),u.onOpenSubmenu()(e,t,n),au.highlightFirst(n)}),d(e ,a,n)})},r=function(e,t){var n=c(t);return a.collapse(n).bind(function(n){return d(e,a,n).map(function(n){return u.onCollapseMenu()(e,t,n),n})})},n=function(t){ return function(e,n){return ji(n.getSource(),"."+u.markers().item()).bind(functi on(n){return e.getSystem().getByDom(n).toOption().bind(function(n){return t(e,n) .map(function(){return!0})})})}},e=lr([mr(Ql(),function(n,e){var t=e.event().men u();au.highlight(n,t)}),xr(function(e,n){var t=n.event().target();e.getSystem(). getByDom(t).each(function(n){0===c(n).indexOf("collapse-item")&&r(e,n),m(e,n).fo ld(function(){u.onExecute()(e,n)},function(){})})}),br(function(e,n){var t,r,o;( t=e,r=i(t,u.data().menus()),o=s(t),a.setContents(u.data().primary(),r,u.data().e xpansions(),o),a.getPrimary()).each(function(n){td.append(e,zl(n)),u.openImmedia tely()&&(f(e,n),u.onOpenMenu()(e,n))})})].concat(u.navigateOnHover()?[mr($l(),fu nction(n,e){var t,r,o=e.event().item();t=n,r=c(o),a.refresh(r).bind(function(n){ return d(t,a,n)}),m(n,o),u.onHover()(n,o)})]:[]));return{uid:u.uid(),dom:u.dom() ,behaviours:k(Lr([ja.config({mode:"special",onRight:n(function(n,e){return mu(e. element())?F.none():m(n,e)}),onLeft:n(function(n,e){return mu(e.element())?F.non e():r(n,e)}),onEscape:n(function(n,e){return r(n,e).orThunk(function(){return u. onEscape()(n,e).map(function(){return n})})}),focusIn:function(e,n){a.getPrimary ().each(function(n){ue(e,n.element(),Kn())})}}),au.config({highlightClass:u.mark ers().selectedMenu(),itemClass:u.markers().menu()}),Tf.config({find:function(n){ return au.getHighlighted(n)}}),td.config({})]),Ua(u.tmenuBehaviours())),eventOrd er:u.eventOrder(),apis:{collapseMenu:function(e){au.getHighlighted(e).each(funct ion(n){au.getHighlighted(n).each(function(n){r(e,n)})})}},events:e}},extraApis:{ tieredData:function(n,e,t){return{primary:n,menus:e,expansions:t}},singleData:fu nction(n,e){return{primary:n,menus:wt(n,e),expansions:{}}},collapseItem:function (n){return{value:Ja(ud()),text:n}}}}),cd=function(n,e,t,r){return yt(e.routes(), r.start()).map(s).bind(function(n){return yt(n,r.destination()).map(s)})},sd=fun ction(n,e,t,r){return cd(0,e,0,r).bind(function(e){return e.transition().map(fun ction(n){return{transition:A(n),route:A(e)}})})},fd=function(t,r,n){var e,o,i;(e =t,o=r,i=n,ld(e,o,i).bind(function(n){return sd(e,o,i,n)})).each(function(n){var e=n.transition();ro(t.element(),e.transitionClass()),Xr(t.element(),r.destinati onAttr())})},ld=function(n,e,t){var r=n.element();return Kr(r,e.destinationAttr( ))?F.some({start:A(Yr(n.element(),e.stateAttr())),destination:A(Yr(n.element(),e .destinationAttr()))}):F.none()},dd=function(n,e,t,r){fd(n,e,t),Kr(n.element(),e .stateAttr())&&Yr(n.element(),e.stateAttr())!==r&&e.onFinish()(n,r),_r(n.element (),e.stateAttr(),r)},md=Object.freeze({findRoute:cd,disableTransition:fd,getCurr entRoute:ld,jumpTo:dd,progressTo:function(t,r,o,i){var n,e;e=r,Kr((n=t).element( ),e.destinationAttr())&&(_r(n.element(),e.stateAttr(),Yr(n.element(),e.destinati onAttr())),Xr(n.element(),e.destinationAttr()));var u,a,c=(u=r,a=i,{start:A(Yr(t .element(),u.stateAttr())),destination:A(a)});sd(t,r,o,c).fold(function(){dd(t,r ,o,i)},function(n){fd(t,r,o);var e=n.transition();to(t.element(),e.transitionCla ss()),_r(t.element(),r.destinationAttr(),i)})},getState:function(n,e,t){var r=n. element();return Kr(r,e.stateAttr())?F.some(Yr(r,e.stateAttr())):F.none()}}),gd= Object.freeze({events:function(o,i){return lr([mr(J(),function(t,n){var r=n.even t().raw();ld(t,o,i).each(function(e){cd(0,o,0,e).each(function(n){n.transition() .each(function(n){r.propertyName===n.property()&&(dd(t,o,i,e.destination()),o.on Transition()(t,e))})})})}),br(function(n,e){dd(n,o,i,o.initialState())})])}}),vd =[ur("destinationAttr","data-transitioning-destination"),ur("stateAttr","data-tr ansitioning-state"),Zt("initialState"),$o("onTransition"),$o("onFinish"),nr("rou tes",Ht(nt.value,Ht(nt.value,Nt([ir("transition",[Zt("property"),Zt("transitionC lass")])]))))],pd=Pr({fields:vd,name:"transitioning",active:gd,apis:md,extra:{cr eateRoutes:function(n){var r={};return V(n,function(n,e){var t=e.split("<->");r[ t[0]]=wt(t[1],n),r[t[1]]=wt(t[0],n)}),r},createBistate:function(n,e,t){return xt ([{key:n,value:wt(e,t)},{key:e,value:wt(n,t)}])},createTristate:function(n,e,t,r ){return xt([{key:n,value:xt([{key:e,value:r},{key:t,value:r}])},{key:e,value:xt ([{key:n,value:r},{key:t,value:r}])},{key:t,value:xt([{key:n,value:r},{key:e,val ue:r}])}])}}}),hd=mi.resolve("scrollable"),bd={register:function(n){to(n,hd)},de register:function(n){ro(n,hd)},scrollable:A(hd)},yd=function(n){return yt(n,"for mat").getOr(n.title)},wd=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},itemBeh aviours:Lr(o?[]:[si(n,function(n,e){(e?ci.on:ci.off)(n)})]),components:[{dom:{ta g:"div",attributes:{style:r},innerHtml:e}}]}},xd=function(n,e,t,r){return{value: n,dom:{tag:"div"},components:[Uc.sketch({dom:{tag:"div",classes:[mi.resolve("sty les-collapser")]},components:r?[{dom:{tag:"span",classes:[mi.resolve("styles-col lapse-icon")]}},Nl(n)]:[Nl(n)],action:function(n){if(r){var e=t().get(n);ad.coll apseMenu(e)}}}),{dom:{tag:"div",classes:[mi.resolve("styles-menu-items-container ")]},components:[Zl.parts().items({})],behaviours:Lr([wf("adhoc-scrollable-menu" ,[br(function(n,e){xi(n.element(),"overflow-y","auto"),xi(n.element(),"-webkit-o verflow-scrolling","touch"),bd.register(n.element())}),yr(function(n){Ci(n.eleme nt(),"overflow-y"),Ci(n.element(),"-webkit-overflow-scrolling"),bd.deregister(n. element())})])])}],items:e,menuBehaviours:Lr([pd.config({initialState:"after",ro utes:pd.createTristate("before","current","after",{transition:{property:"transfo rm",transitionClass:"transitioning"}})})])}},Sd=function(r){var o,i,n,e,t,u=(o=r .formats,i=function(){return a},n=xd("Styles",[].concat(bn(o.items,function(n){r eturn wd(yd(n),n.title,n.isSelected(),n.getPreview(),Tt(o.expansions,yd(n)))})), i,!1),e=H(o.menus,function(n,e){var t=bn(n,function(n){return wd(yd(n),n.title,n .isSelected!==undefined&&n.isSelected(),n.getPreview!==undefined?n.getPreview(): "",Tt(o.expansions,yd(n)))});return xd(e,t,i,!0)}),t=k(e,wt("styles",n)),{tmenu: ad.tieredData("styles",t,o.expansions)}),a=js(ad.sketch({dom:{tag:"div",classes: [mi.resolve("styles-menu")]},components:[],fakeFocus:!0,stayInDom:!0,onExecute:f unction(n,e){var t=xs.getValue(e);return r.handle(e,t.value),F.none()},onEscape: function(){return F.none()},onOpenMenu:function(n,e){var t=Cs(n.element());ks(e. element(),t),pd.jumpTo(e,"current")},onOpenSubmenu:function(n,e,t){var r=Cs(n.el ement()),o=Hi(e.element(),'[role="menu"]').getOrDie("hacky"),i=n.getSystem().get ByDom(o).getOrDie();ks(t.element(),r),pd.progressTo(i,"before"),pd.jumpTo(t,"aft er"),pd.progressTo(t,"current")},onCollapseMenu:function(n,e,t){var r=Hi(e.eleme nt(),'[role="menu"]').getOrDie("hacky"),o=n.getSystem().getByDom(r).getOrDie();p d.progressTo(o,"after"),pd.progressTo(t,"current")},navigateOnHover:!1,openImmed iately:!0,data:u.tmenu,markers:{backgroundMenu:mi.resolve("styles-background-men u"),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()},Td=function(n){return Tt(n,"items")?(t=k(pt(e=n,["items "]),{menu:!0}),r=Od(e.items),{item:t,menus:k(r.menus,wt(e.title,r.items)),expans ions:k(r.expansions,wt(e.title,e.title))}):{item:n,menus:{},expansions:{}};var e ,t,r},Od=function(n){return xn(n,function(n,e){var t=Td(e);return{menus:k(n.menu s,t.menus),items:[t.item].concat(n.items),expansions:k(n.expansions,t.expansions )}},{menus:{},expansions:{},items:[]})},kd={expand:Od},Cd=function(u,n){var a=fu nction(n){return function(){return u.formatter.match(n)}},c=function(n){return f unction(){return u.formatter.getCssText(n)}},e=yt(n,"style_formats").getOr(il),s =function(n){return bn(n,function(n){if(Tt(n,"items")){var e=s(n.items);return k (k(n,{isSelected:A(!1),getPreview:A("")}),{items:e})}return Tt(n,"format")?k(i=n ,{isSelected:a(i.format),getPreview:c(i.format)}):(r=Ja((t=n).title),o=k(t,{form at:r,isSelected:a(r),getPreview:c(r)}),u.formatter.register(r,o),o);var t,r,o,i} )};return s(e)},Ed=function(t,n,r){var e,o,i,u=(e=t,i=(o=function(n){return Dn(n ,function(n){return n.items!==undefined?0<o(n.items).length?[n]:[]:!Tt(n,"format ")||e.formatter.canApply(n.format)?[n]:[]})})(n),kd.expand(i));return Sd({format s:u,handle:function(n,e){t.undoManager.transact(function(){ci.isOn(n)?t.formatte r.remove(e):t.formatter.apply(e)}),r()}})},Dd=["undo","bold","italic","link","im age","bullist","styleselect"],Id=function(n){var e=n.replace(/\|/g," ").trim();r eturn 0<e.length?e.split(/\s+/):[]},Ad=function(n){return Dn(n,function(n){retur n p(n)?Ad(n):Id(n)})},Md=function(n){var e=n.toolbar!==undefined?n.toolbar:Dd;re turn p(e)?Ad(e):Id(e)},Bd=function(r,o){var n=function(n){return function(){retu rn Yc.forToolbarCommand(o,n)}},e=function(n){return function(){return Yc.forTool barStateCommand(o,n)}},t=function(n,e,t){return function(){return Yc.forToolbarS tateAction(o,n,e,t)}},i=n("undo"),u=n("redo"),a=e("bold"),c=e("italic"),s=e("und erline"),f=n("removeformat"),l=t("unlink","link",function(){o.execCommand("unlin k",null,!1)}),d=t("unordered-list","ul",function(){o.execCommand("InsertUnordere dList",null,!1)}),m=t("ordered-list","ol",function(){o.execCommand("InsertOrdere dList",null,!1)}),g=Cd(o,o.settings),v=function(){return Ed(o,g,function(){o.fir e("scrollIntoView")})},p=function(n,e){return{isSupported:function(){return n.fo rall(function(n){return Tt(o.buttons,n)})},sketch:e}};return{undo:p(F.none(),i), redo:p(F.none(),u),bold:p(F.none(),a),italic:p(F.none(),c),underline:p(F.none(), s),removeformat:p(F.none(),f),link:p(F.none(),function(){return e=r,t=o,Yc.forTo olbarStateAction(t,"link","link",function(){var n=ol(e,t);e.setContextToolbar(n) ,yf(t,function(){e.focusToolbar()}),pf.query(t).each(function(n){t.selection.sel ect(n.dom())})});var e,t}),unlink:p(F.none(),l),image:p(F.none(),function(){retu rn ff(o)}),bullist:p(F.some("bullist"),d),numlist:p(F.some("numlist"),m),fontsiz eselect:p(F.none(),function(){return e=o,n={onChange:function(n){Vs.apply(e,n)}, getInitialValue:function(){return Vs.get(e)}},Is(r,"font-size",function(){return zs(n)});var e,n}),forecolor:p(F.none(),function(){return Ms(r,o)}),styleselect: p(F.none(),function(){return Yc.forToolbar("style-formats",function(n){o.fire("t oReading"),r.dropup().appear(v,ci.on,n)},Lr([ci.config({toggleClass:mi.resolve(" toolbar-button-selected"),toggleOnExecute:!1,aria:{mode:"pressed"}}),Jo.config({ channels:xt([li(To.orientationChanged(),ci.off),li(To.dropupDismissed(),ci.off)] )})]))})}},Rd=function(n,t){var e=Md(n),r={};return Dn(e,function(n){var e=!Tt(r ,n)&&Tt(t,n)&&t[n].isSupported()?[t[n].sketch()]:[];return r[n]=!0,e})},Fd=funct ion(m,g){return function(n){if(m(n)){var e,t,r,o,i,u,a,c=se.fromDom(n.target),s= function(){n.stopPropagation()},f=function(){n.preventDefault()},l=v(f,s),d=(e=c ,t=n.clientX,r=n.clientY,o=s,i=f,u=l,a=n,{target:A(e),x:A(t),y:A(r),stop:o,preve nt:i,kill:u,raw:A(a)});g(d)}}},Nd=function(n,e,t,r,o){var i=Fd(t,r);return n.dom ().addEventListener(e,i,o),{unbind:l(Vd,n,e,i,o)}},Vd=function(n,e,t,r){n.dom(). removeEventListener(e,t,r)},Hd=A(!0),zd=function(n,e,t){return Nd(n,e,Hd,t,!1)}, jd=function(n,e,t){return Nd(n,e,Hd,t,!0)},Ld=function(n){var e=n.matchMedia("(o rientation: portrait)").matches;return{isPortrait:A(e)}},Ud=Ld,Pd=function(r,e){ var n=se.fromDom(r),o=null,t=zd(n,"orientationchange",function(){clearInterval(o );var n=Ld(r);e.onChange(n),i(function(){e.onReady(n)})}),i=function(n){clearInt erval(o);var e=r.innerHeight,t=0;o=setInterval(function(){e!==r.innerHeight?(cle arInterval(o),n(F.some(r.innerHeight))):20<t&&(clearInterval(o),n(F.none())),t++ },50)};return{onAdjustment:i,destroy:function(){t.unbind()}}},$d=function(n){var e=$n.detect().os.isiOS(),t=Ld(n).isPortrait();return e&&!t?n.screen.height:n.sc reen.width},Wd=function(n){var e=n.raw();return e.touches===undefined||1!==e.tou ches.length?F.none():F.some(e.touches[0])},Gd=function(t){var r,o,i,u=fo(F.none( )),a=(r=function(n){u.set(F.none()),t.triggerEvent(Qn(),n)},o=400,i=null,{cancel :function(){null!==i&&(clearTimeout(i),i=null)},schedule:function(){for(var n=[] ,e=0;e<arguments.length;e++)n[e]=arguments[e];i=setTimeout(function(){r.apply(nu ll,n),i=null},o)}}),c=xt([{key:L(),value:function(t){return Wd(t).each(function( n){a.cancel();var e={x:A(n.clientX),y:A(n.clientY),target:t.target};a.schedule(t ),u.set(F.some(e))}),F.none()}},{key:U(),value:function(n){return a.cancel(),Wd( n).each(function(i){u.get().each(function(n){var e,t,r,o;e=i,t=n,r=Math.abs(e.cl ientX-t.x()),o=Math.abs(e.clientY-t.y()),(5<r||5<o)&&u.set(F.none())})}),F.none( )}},{key:P(),value:function(e){return a.cancel(),u.get().filter(function(n){retu rn Ve(n.target(),e.target())}).map(function(n){return t.triggerEvent(Xn(),e)})}} ]);return{fireIfReady:function(e,n){return yt(c,n).bind(function(n){return n(e)} )}}},_d=function(t){var e=Gd({triggerEvent:function(n,e){t.onTapContent(e)}});re turn{fireTouchstart:function(n){e.fireIfReady(n,"touchstart")},onTouchend:functi on(){return zd(t.body(),"touchend",function(n){e.fireIfReady(n,"touchend")})},on Touchmove:function(){return zd(t.body(),"touchmove",function(n){e.fireIfReady(n, "touchmove")})}}},qd=6<=$n.detect().os.version.major,Yd=function(r,e,t){var o=_d (r),i=He(e),u=function(n){return!Ve(n.start(),n.finish())||n.soffset()!==n.foffs et()},n=function(){var n=r.doc().dom().hasFocus()&&r.getSelection().exists(u);t. getByDom(e).each(!0===(n||bo(i).filter(function(n){return"input"===me(n)}).exist s(function(n){return n.dom().selectionStart!==n.dom().selectionEnd}))?ci.on:ci.o ff)},a=[zd(r.body(),"touchstart",function(n){r.onTouchContent(),o.fireTouchstart (n)}),o.onTouchmove(),o.onTouchend(),zd(e,"touchstart",function(n){r.onTouchTool strip()}),r.onToReading(function(){ho(r.body())}),r.onToEditing(I),r.onScrollToC ursor(function(n){n.preventDefault(),r.getCursorBox().each(function(n){var e=r.w in(),t=n.top()>e.innerHeight||n.bottom()>e.innerHeight?n.bottom()-e.innerHeight+ 50:0;0!==t&&e.scrollTo(e.pageXOffset,e.pageYOffset+t)})})].concat(!0===qd?[]:[zd (se.fromDom(r.win()),"blur",function(){t.getByDom(e).each(ci.off)}),zd(i,"select ",n),zd(r.doc(),"selectionchange",n)]);return{destroy:function(){yn(a,function(n ){n.unbind()})}}},Kd=function(n,e){var t=parseInt(Yr(n,e),10);return isNaN(t)?0: t},Xd=(ef=pe,tf="text",rf=function(n){return ef(n)?F.from(n.dom().nodeValue):F.n one()},of=$n.detect().browser,{get:function(n){if(!ef(n))throw new Error("Can on ly get "+tf+" value of a "+tf+" node");return uf(n).getOr("")},getOption:uf=of.i sIE()&&10===of.version.major?function(n){try{return rf(n)}catch(e){return F.none ()}}:rf,set:function(n,e){if(!ef(n))throw new Error("Can only set raw "+tf+" val ue of a "+tf+" node");n.dom().nodeValue=e}}),Jd=function(n){return Xd.getOption( n)},Qd=et([{before:["element"]},{on:["element","offset"]},{after:["element"]}]), Zd={before:Qd.before,on:Qd.on,after:Qd.after,cata:function(n,e,t,r){return n.fol d(e,t,r)},getStart:function(n){return n.fold(h,h,h)}},nm=et([{domRange:["rng"]}, {relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffse t"]}]),em=we("start","soffset","finish","foffset"),tm=nm.relative,rm=nm.exact,om =function(n,e,t,r){var o,i,u,a,c,s=(i=e,u=t,a=r,(c=He(o=n).dom().createRange()). setStart(o.dom(),i),c.setEnd(u.dom(),a),c),f=Ve(n,t)&&e===r;return s.collapsed&& !f},im=function(n,e,t){var r,o,i=n.document.createRange();return r=i,e.fold(func tion(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())},f unction(n,e){o.setEnd(n.dom(),e)},function(n){o.setEndAfter(n.dom())}),i},um=fun ction(n,e,t,r,o){var i=n.document.createRange();return i.setStart(e.dom(),t),i.s etEnd(r.dom(),o),i},am=function(n){return{left:A(n.left),top:A(n.top),right:A(n. right),bottom:A(n.bottom),width:A(n.width),height:A(n.height)}},cm=et([{ltr:["st art","soffset","finish","foffset"]},{rtl:["start","soffset","finish","foffset"]} ]),sm=function(n,e,t){return e(se.fromDom(t.startContainer),t.startOffset,se.fro mDom(t.endContainer),t.endOffset)},fm=function(n,e){var o,t,r,i=(o=n,e.match({do mRange:function(n){return{ltr:A(n),rtl:F.none}},relative:function(n,e){return{lt r:Z(function(){return im(o,n,e)}),rtl:Z(function(){return F.some(im(o,e,n))})}}, exact:function(n,e,t,r){return{ltr:Z(function(){return um(o,n,e,t,r)}),rtl:Z(fun ction(){return F.some(um(o,t,r,n,e))})}}}));return(r=(t=i).ltr()).collapsed?t.rt l().filter(function(n){return!1===n.collapsed}).map(function(n){return cm.rtl(se .fromDom(n.endContainer),n.endOffset,se.fromDom(n.startContainer),n.startOffset) }).getOrThunk(function(){return sm(0,cm.ltr,r)}):sm(0,cm.ltr,r)},lm=(document.ca retPositionFromPoint||document.caretRangeFromPoint,function(n,e){var t=me(n);ret urn"input"===t?Zd.after(n):hn(["br","img"],t)?0===e?Zd.before(n):Zd.after(n):Zd. on(n,e)}),dm=function(n,e,t,r,o){var i,u,a=um(n,e,t,r,o);i=n,u=a,F.from(i.getSel ection()).each(function(n){n.removeAllRanges(),n.addRange(u)})},mm=function(n,e, t,r,o){var i,u,a,c,l,s=(i=r,u=o,a=lm(e,t),c=lm(i,u),tm(a,c));fm(l=n,s).match({lt r:function(n,e,t,r){dm(l,n,e,t,r)},rtl:function(n,e,t,r){var o,i,u,a,c,s=l.getSe lection();if(s.setBaseAndExtent)s.setBaseAndExtent(n.dom(),e,t.dom(),r);else if( s.extend)try{i=n,u=e,a=t,c=r,(o=s).collapse(i.dom(),u),o.extend(a.dom(),c)}catch (f){dm(l,t,r,n,e)}else dm(l,t,r,n,e)}})},gm=function(n){var e=se.fromDom(n.ancho rNode),t=se.fromDom(n.focusNode);return om(e,n.anchorOffset,t,n.focusOffset)?F.s ome(em(se.fromDom(n.anchorNode),n.anchorOffset,se.fromDom(n.focusNode),n.focusOf fset)):function(n){if(0<n.rangeCount){var e=n.getRangeAt(0),t=n.getRangeAt(n.ran geCount-1);return F.some(em(se.fromDom(e.startContainer),e.startOffset,se.fromDo m(t.endContainer),t.endOffset))}return F.none()}(n)},vm=function(n){return F.fro m(n.getSelection()).filter(function(n){return 0<n.rangeCount}).bind(gm)},pm=func tion(n,e){var i,t,r,o,u=fm(i=n,e).match({ltr:function(n,e,t,r){var o=i.document. createRange();return o.setStart(n.dom(),e),o.setEnd(t.dom(),r),o},rtl:function(n ,e,t,r){var o=i.document.createRange();return o.setStart(t.dom(),r),o.setEnd(n.d om(),e),o}});return r=(t=u).getClientRects(),0<(o=0<r.length?r[0]:t.getBoundingC lientRect()).width||0<o.height?F.some(o).map(am):F.none()},hm=function(n){return {left:n.left,top:n.top,right:n.right,bottom:n.bottom,width:A(2),height:n.height} },bm=function(n){return{left:A(n.left),top:A(n.top),right:A(n.right),bottom:A(n. bottom),width:A(n.width),height:A(n.height)}},ym=function(r){if(r.collapsed){var o=se.fromDom(r.startContainer);return ze(o).bind(function(n){var e,t=rm(o,r.sta rtOffset,n,"img"===me(e=n)?1:Jd(e).fold(function(){return je(e).length},function (n){return n.length}));return pm(r.startContainer.ownerDocument.defaultView,t).m ap(hm).map(Bn)}).getOr([])}return bn(r.getClientRects(),bm)},wm=function(n){var e=n.getSelection();return e!==undefined&&0<e.rangeCount?ym(e.getRangeAt(0)):[]}, xm=function(n){n.focus();var e=se.fromDom(n.document.body);(bo().exists(function (n){return hn(["input","textarea"],me(n))})?function(n){setTimeout(function(){n( )},0)}:s)(function(){bo().each(ho),po(e)})},Sm="data-"+mi.resolve("last-outer-he ight"),Tm=function(n,e){_r(n,Sm,e)},Om=function(n){return{top:A(n.top()),bottom: A(n.top()+n.height())}},km=function(n,e){var t=Kd(e,Sm),r=n.innerHeight;return r <t?F.some(t-r):F.none()},Cm=function(n,u){var e=se.fromDom(u.document.body),t=zd (se.fromDom(n),"resize",function(){km(n,e).each(function(i){var n,e;(n=u,e=wm(n) ,0<e.length?F.some(e[0]).map(Om):F.none()).each(function(n){var e,t,r,o=(e=u,r=i ,(t=n).top()>e.innerHeight||t.bottom()>e.innerHeight?Math.min(r,t.bottom()-e.inn erHeight+50):0);0!==o&&u.scrollTo(u.pageXOffset,u.pageYOffset+o)})}),Tm(e,n.inne rHeight)});return Tm(e,n.innerHeight),{toEditing:function(){xm(u)},destroy:funct ion(){t.unbind()}}},Em=function(n){return F.some(se.fromDom(n.dom().contentWindo w.document.body))},Dm=function(n){return F.some(se.fromDom(n.dom().contentWindow .document))},Im=function(n){return F.from(n.dom().contentWindow)},Am=function(n) {return Im(n).bind(vm)},Mm=function(n){return n.getFrame()},Bm=function(n,t){ret urn function(e){return e[n].getOrThunk(function(){var n=Mm(e);return function(){ return t(n)}})()}},Rm=function(n,e,t,r){return n[t].getOrThunk(function(){return function(n){return zd(e,r,n)}})},Fm=function(n){return{left:A(n.left),top:A(n.t op),right:A(n.right),bottom:A(n.bottom),width:A(n.width),height:A(n.height)}},Nm ={getBody:Bm("getBody",Em),getDoc:Bm("getDoc",Dm),getWin:Bm("getWin",Im),getSele ction:Bm("getSelection",Am),getFrame:Mm,getActiveApi:function(a){var c=Mm(a);ret urn Em(c).bind(function(u){return Dm(c).bind(function(i){return Im(c).map(functi on(o){var n=se.fromDom(i.dom().documentElement),e=a.getCursorBox.getOrThunk(func tion(){return function(){return(n=o,vm(n).map(function(n){return rm(n.start(),n. soffset(),n.finish(),n.foffset())})).bind(function(n){return pm(o,n).orThunk(fun ction(){return vm(o).filter(function(n){return Ve(n.start(),n.finish())&&n.soffs et()===n.foffset()}).bind(function(n){var e=n.start().dom().getBoundingClientRec t();return 0<e.width||0<e.height?F.some(e).map(Fm):F.none()})})});var n}}),t=a.s etSelection.getOrThunk(function(){return function(n,e,t,r){mm(o,n,e,t,r)}}),r=a. clearSelection.getOrThunk(function(){return function(){o.getSelection().removeAl lRanges()}});return{body:A(u),doc:A(i),win:A(o),html:A(n),getSelection:l(Am,c),s etSelection:t,clearSelection:r,frame:A(c),onKeyup:Rm(a,i,"onKeyup","keyup"),onNo deChanged:Rm(a,i,"onNodeChanged","selectionchange"),onDomChanged:a.onDomChanged, onScrollToCursor:a.onScrollToCursor,onScrollToElement:a.onScrollToElement,onToRe ading:a.onToReading,onToEditing:a.onToEditing,onToolbarScrollStart:a.onToolbarSc rollStart,onTouchContent:a.onTouchContent,onTapContent:a.onTapContent,onTouchToo lstrip:a.onTouchToolstrip,getCursorBox:e}})})})}},Vm="data-ephox-mobile-fullscre en-style",Hm="position:absolute!important;",zm="top:0!important;left:0!important ;margin:0!important;padding:0!important;width:100%!important;",jm=$n.detect().os .isAndroid(),Lm=function(n,e){var t,r,o,i=function(r){return function(n){var e=Y r(n,"style"),t=e===undefined?"no-styles":e.trim();t!==r&&(_r(n,Vm,t),_r(n,"style ",r))}},u=(t="*",Ri(n,function(n){return Be(n,t)},r)),a=Dn(u,function(n){var e;r eturn e="*",Fi(n,function(n){return Be(n,e)})}),c=(o=Ti(e,"background-color"))!= =undefined&&""!==o?"background-color:"+o+"!important":"background-color:rgb(255, 255,255)!important;";yn(a,i("display:none!important;")),yn(u,i(Hm+zm+c)),i((!0== =jm?"":Hm)+zm+c)(n)},Um=function(){var n=Fe("["+Vm+"]");yn(n,function(n){var e=Y r(n,Vm);"no-styles"!==e?_r(n,"style",e):Xr(n,"style"),Xr(n,Vm)})},Pm=function(){ var e=Vi("head").getOrDie(),n=Vi('meta[name="viewport"]').getOrThunk(function(){ var n=se.fromTag("meta");return _r(n,"name","viewport"),Pe(e,n),n}),t=Yr(n,"cont ent");return{maximize:function(){_r(n,"content","width=device-width, initial-sca le=1.0, user-scalable=no, maximum-scale=1.0")},restore:function(){t!==undefined& &null!==t&&0<t.length?_r(n,"content",t):_r(n,"content","user-scalable=yes")}}},$ m=function(e,n){var t=Pm(),r=Qf(),o=Qf();return{enter:function(){n.hide(),to(e.c ontainer,mi.resolve("fullscreen-maximized")),to(e.container,mi.resolve("android- maximized")),t.maximize(),to(e.body,mi.resolve("android-scroll-reload")),r.set(C m(e.win,Nm.getWin(e.editor).getOrDie("no"))),Nm.getActiveApi(e.editor).each(func tion(n){Lm(e.container,n.body()),o.set(Yd(n,e.toolstrip,e.alloy))})},exit:functi on(){t.restore(),n.show(),ro(e.container,mi.resolve("fullscreen-maximized")),ro( e.container,mi.resolve("android-maximized")),Um(),ro(e.body,mi.resolve("android- scroll-reload")),o.clear(),r.clear()}}},Wm=function(t,r){var o=null;return{cance l:function(){null!==o&&(clearTimeout(o),o=null)},throttle:function(){for(var n=[ ],e=0;e<arguments.length;e++)n[e]=arguments[e];null!==o&&clearTimeout(o),o=setTi meout(function(){t.apply(null,n),o=null},r)}}},Gm=function(n,e){var t,r,o,i=js(O f.sketch({dom:Wc('<div aria-hidden="true" class="${prefix}-mask-tap-icon"></div> '),containerBehaviours:Lr([ci.config({toggleClass:mi.resolve("mask-tap-icon-sele cted"),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<arguments.len gth;e++)n[e]=arguments[e];null===o&&(o=setTimeout(function(){t.apply(null,n),o=n ull},r))}});return Of.sketch({dom:Wc('<div class="${prefix}-disabled-mask"></div >'),components:[Of.sketch({dom:Wc('<div class="${prefix}-content-container"></di v>'),components:[Uc.sketch({dom:Wc('<div class="${prefix}-content-tap-section">< /div>'),components:[i.asSpec()],action:function(n){u.throttle()},buttonBehaviour s:Lr([ci.config({toggleClass:mi.resolve("mask-tap-icon-selected")})])})]})]})},_ m=Vt([tr("editor",[Zt("getFrame"),rr("getBody"),rr("getDoc"),rr("getWin"),rr("ge tSelection"),rr("setSelection"),rr("clearSelection"),rr("cursorSaver"),rr("onKey up"),rr("onNodeChanged"),rr("getCursorBox"),Zt("onDomChanged"),ur("onTouchConten t",I),ur("onTapContent",I),ur("onTouchToolstrip",I),ur("onScrollToCursor",A({unb ind:I})),ur("onScrollToElement",A({unbind:I})),ur("onToEditing",A({unbind:I})),u r("onToReading",A({unbind:I})),ur("onToolbarScrollStart",h)]),Zt("socket"),Zt("t oolstrip"),Zt("dropup"),Zt("toolbar"),Zt("container"),Zt("alloy"),cr("win",funct ion(n){return He(n.socket).dom().defaultView}),cr("body",function(n){return se.f romDom(n.socket.dom().ownerDocument.body)}),ur("translate",h),ur("setReadOnly",I ),ur("readOnlyOnInit",A(!0))]),qm=function(n){var e=qt("Getting AndroidWebapp sc hema",_m,n);xi(e.toolstrip,"width","100%");var t=Hl(Gm(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)}};Pe(e.container,t.element( ));var o=$m(e,r);return{setReadOnly:e.setReadOnly,refreshStructure:I,enter:o.ent er,exit:o.exit,destroy:I}},Ym=A([ur("shell",!0),La("toolbarBehaviours",[td])]),K m=A([lc({name:"groups",overrides:function(n){return{behaviours:Lr([td.config({}) ])}}})]),Xm=Lc({name:"Toolbar",configFields:Ym(),partFields:Km(),factory:functio n(e,n,t,r){var o=function(n){return e.shell()?F.some(n):yc(n,e,"groups")},i=e.sh ell()?{behaviours:[td.config({})],components:[]}:{behaviours:[],components:n};re turn{uid:e.uid(),dom:e.dom(),components:i.components,behaviours:k(Lr(i.behaviour s),Ua(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 conta iner was specified in components"),new Error("Toolbar was defined to not be a sh ell, but no groups container was specified in components")},function(n){td.set(n ,e)})}},domModification:{attributes:{role:"group"}}}},apis:{setGroups:function(n ,e,t){n.setGroups(e,t)}}}),Jm=A([Zt("items"),(af=["itemClass"],tr("markers",bn(a f,Zt))),La("tgroupBehaviours",[ja])]),Qm=A([dc({name:"items",unit:"item",overrid es:function(n){return{domModification:{classes:[n.markers().itemClass()]}}}})]), Zm=Lc({name:"ToolbarGroup",configFields:Jm(),partFields:Qm(),factory:function(n, e,t,r){return k({dom:{attributes:{role:"toolbar"}}},{uid:n.uid(),dom:n.dom(),com ponents:e,behaviours:k(Lr([ja.config({mode:"flow",selector:"."+n.markers().itemC lass()})]),Ua(n.tgroupBehaviours())),"debug.sketcher":t["debug.sketcher"]})}}),n g="data-"+mi.resolve("horizontal-scroll"),eg=function(n){return"true"===Yr(n,ng) ?0<(t=n).dom().scrollLeft||function(n){n.dom().scrollLeft=1;var e=0!==n.dom().sc rollLeft;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},tg={exclusive:function(n,e){return zd(n,"touchmove",function(n){ji(n.t arget(),e).filter(eg).fold(function(){n.raw().preventDefault()},I)})},markAsHori zontal:function(n){_r(n,ng,"true")}};function rg(){var e=function(n){var e=!0=== n.scrollable?"${prefix}-toolbar-scrollable-group":"";return{dom:Wc('<div aria-la bel="'+n.label+'" class="${prefix}-toolbar-group '+e+'"></div>'),tgroupBehaviour s:Lr([wf("adhoc-scrollable-toolbar",!0===n.scrollable?[wr(function(n,e){xi(n.ele ment(),"overflow-x","auto"),tg.markAsHorizontal(n.element()),bd.register(n.eleme nt())})]:[])]),components:[Of.sketch({components:[Zm.parts().items({})]})],marke rs:{itemClass:mi.resolve("toolbar-group-item")},items:n.items}},t=Hl(Xm.sketch({ dom:Wc('<div class="${prefix}-toolbar"></div>'),components:[Xm.parts().groups({} )],toolbarBehaviours:Lr([ci.config({toggleClass:mi.resolve("context-toolbar"),to ggleOnExecute:!1,aria:{mode:"none"}}),ja.config({mode:"cyclic"})]),shell:!0})),n =Hl(Of.sketch({dom:{classes:[mi.resolve("toolstrip")]},components:[zl(t)],contai nerBehaviours:Lr([ci.config({toggleClass:mi.resolve("android-selection-context-t oolbar"),toggleOnExecute:!1})])})),r=function(){Xm.setGroups(t,o.get()),ci.off(t )},o=fo([]);return{wrapper:A(n),toolbar:A(t),createGroups:function(n){return bn( n,v(Zm.sketch,e))},setGroups:function(n){o.set(n),r()},setContextToolbar:functio n(n){ci.on(t),Xm.setGroups(t,n)},restoreToolbar:function(){ci.isOn(t)&&r()},refr esh:function(){},focus:function(){ja.focusIn(t)}}}var og=function(n,e){td.append (n,zl(e))},ig=function(n,e){td.remove(n,e)},ug=function(n){return Hl(Uc.sketch({ dom:Wc('<div class="${prefix}-mask-edit-icon ${prefix}-icon"></div>'),action:fun ction(){n.run(function(n){n.setReadOnly(!1)})}}))},ag=function(){return Hl(Of.sk etch({dom:Wc('<div class="${prefix}-editor-socket"></div>'),components:[],contai nerBehaviours:Lr([td.config({})])}))},cg=function(n,e,t,r){(!0===t?so.toAlpha:so .toOmega)(r),(t?og:ig)(n,e)},sg=function(e,n){return n.getAnimationRoot().fold(f unction(){return e.element()},function(n){return n(e)})},fg=function(n){return n .dimension().property()},lg=function(n,e){return n.dimension().getDimension()(e) },dg=function(n,e){var t=sg(n,e);kl(t,[e.shrinkingClass(),e.growingClass()])},mg =function(n,e){ro(n.element(),e.openClass()),to(n.element(),e.closedClass()),xi( n.element(),fg(e),"0px"),Ei(n.element())},gg=function(n,e){ro(n.element(),e.clos edClass()),to(n.element(),e.openClass()),Ci(n.element(),fg(e))},vg=function(n,e, t){t.setCollapsed(),xi(n.element(),fg(e),lg(e,n.element())),Ei(n.element());var r=sg(n,e);to(r,e.shrinkingClass()),mg(n,e),e.onStartShrink()(n)},pg=function(n,e ,t){var r=function(n,e){gg(n,e);var t=lg(e,n.element());return mg(n,e),t}(n,e),o =sg(n,e);to(o,e.growingClass()),gg(n,e),xi(n.element(),fg(e),r),t.setExpanded(), e.onStartGrow()(n)},hg=function(n,e,t){var r=sg(n,e);return!0===io(r,e.growingCl ass())},bg=function(n,e,t){var r=sg(n,e);return!0===io(r,e.shrinkingClass())},yg =Object.freeze({grow:function(n,e,t){t.isExpanded()||pg(n,e,t)},shrink:function( n,e,t){t.isExpanded()&&vg(n,e,t)},immediateShrink:function(n,e,t){var r,o;t.isEx panded()&&(r=n,o=e,t.setCollapsed(),xi(r.element(),fg(o),lg(o,r.element())),Ei(r .element()),dg(r,o),mg(r,o),o.onStartShrink()(r),o.onShrunk()(r))},hasGrown:func tion(n,e,t){return t.isExpanded()},hasShrunk:function(n,e,t){return t.isCollapse d()},isGrowing:hg,isShrinking:bg,isTransitioning:function(n,e,t){return!0===hg(n ,e)||!0===bg(n,e)},toggleGrow:function(n,e,t){(t.isExpanded()?vg:pg)(n,e,t)},dis ableTransitions:dg}),wg=Object.freeze({exhibit:function(n,e){var t=e.expanded(); return Cr(t?{classes:[e.openClass()],styles:{}}:{classes:[e.closedClass()],style s:wt(e.dimension().property(),"0px")})},events:function(t,r){return lr([mr(J(),f unction(n,e){e.event().raw().propertyName===t.dimension().property()&&(dg(n,t),r .isExpanded()&&Ci(n.element(),t.dimension().property()),(r.isExpanded()?t.onGrow n():t.onShrunk())(n))})])}}),xg=[Zt("closedClass"),Zt("openClass"),Zt("shrinking Class"),Zt("growingClass"),rr("getAnimationRoot"),$o("onShrunk"),$o("onStartShri nk"),$o("onGrown"),$o("onStartGrow"),ur("expanded",!1),nr("dimension",Xt("proper ty",{width:[qo("property","width"),qo("getDimension",function(n){return Cs(n)+"p x"})],height:[qo("property","height"),qo("getDimension",function(n){return Bi(n) +"px"})]}))],Sg=Pr({fields:xg,name:"sliding",active:wg,apis:yg,state:Object.free ze({init:function(n){var e=fo(n.expanded());return jr({isExpanded:function(){ret urn!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()}})} })}),Tg=function(e,t){var r=Hl(Of.sketch({dom:{tag:"div",classes:[mi.resolve("dr opup")]},components:[],containerBehaviours:Lr([td.config({}),Sg.config({closedCl ass:mi.resolve("dropup-closed"),openClass:mi.resolve("dropup-open"),shrinkingCla ss:mi.resolve("dropup-shrinking"),growingClass:mi.resolve("dropup-growing"),dime nsion:{property:"height"},onShrunk:function(n){e(),t(),td.set(n,[])},onGrown:fun ction(n){e(),t()}}),fi(function(n,e){o(I)})])})),o=function(n){window.requestAni mationFrame(function(){n(),Sg.shrink(r)})};return{appear:function(n,e,t){!0===Sg .hasShrunk(r)&&!1===Sg.isTransitioning(r)&&window.requestAnimationFrame(function (){e(t),td.set(r,[n()]),Sg.grow(r)})},disappear:o,component:A(r),element:r.eleme nt}},Og=$n.detect().browser.isFirefox(),kg=Nt([er("triggerEvent"),er("broadcastE vent"),ur("stopBackspace",!0)]),Cg=function(e,n){var t,r,o,i,u,a=qt("Getting GUI events settings",kg,n),c=$n.detect().deviceType.isTouch()?["touchstart","touchm ove","touchend","gesturestart"]:["mousedown","mouseup","mouseover","mousemove"," mouseout","click"],s=Gd(a),f=bn(c.concat(["selectstart","input","contextmenu","c hange","transitionend","drag","dragstart","dragend","dragenter","dragleave","dra gover","drop"]),function(n){return zd(e,n,function(e){s.fireIfReady(e,n).each(fu nction(n){n&&e.kill()}),a.triggerEvent(n,e)&&e.kill()})}),l=zd(e,"keydown",funct ion(n){var e;a.triggerEvent("keydown",n)?n.kill():!0!==a.stopBackspace||8!==(e=n ).raw().which||hn(["input","textarea"],me(e.target()))||n.prevent()}),d=(t=e,r=f unction(n){a.triggerEvent("focusin",n)&&n.kill()},Og?jd(t,"focus",r):zd(t,"focus in",r)),m=(o=e,i=function(n){a.triggerEvent("focusout",n)&&n.kill(),setTimeout(f unction(){a.triggerEvent(_n(),n)},0)},Og?jd(o,"blur",i):zd(o,"focusout",i)),g=(u =e.dom().ownerDocument.defaultView,se.fromDom(u)),v=zd(g,"scroll",function(n){a. broadcastEvent(ne(),n)&&n.kill()});return{unbind:function(){yn(f,function(n){n.u nbind()}),l.unbind(),d.unbind(),m.unbind(),v.unbind()}}},Eg=function(n,e){var t= yt(n,"target").map(function(n){return n()}).getOr(e);return fo(t)},Dg=et([{stopp ed:[]},{resume:["element"]},{complete:[]}]),Ig=function(n,r,e,t,o,i){var u,a,c,s ,f=n(r,t),l=(u=e,a=o,c=fo(!1),s=fo(!1),{stop:function(){c.set(!0)},cut:function( ){s.set(!0)},isStopped:c.get,isCut:s.get,event:A(u),setSource:a.set,getSource:a. get});return f.fold(function(){return i.logEventNoHandlers(r,t),Dg.complete()},f unction(e){var t=e.descHandler();return pl(t)(l),l.isStopped()?(i.logEventStoppe d(r,e.element(),t.purpose()),Dg.stopped()):l.isCut()?(i.logEventCut(r,e.element( ),t.purpose()),Dg.complete()):ze(e.element()).fold(function(){return i.logNoPare nt(r,e.element(),t.purpose()),Dg.complete()},function(n){return i.logEventRespon se(r,e.element(),t.purpose()),Dg.resume(n)})})},Ag=function(e,t,r,n,o,i){return Ig(e,t,r,n,o,i).fold(function(){return!0},function(n){return Ag(e,t,r,n,o,i)},fu nction(){return!1})},Mg=function(n,e,t){var r,o,i=(r=e,o=fo(!1),{stop:function() {o.set(!0)},cut:I,isStopped:o.get,isCut:A(!1),event:A(r),setSource:c("Cannot set source of a broadcasted event"),getSource:c("Cannot get source of a broadcasted event")});return yn(n,function(n){var e=n.descHandler();pl(e)(i)}),i.isStopped( )},Bg=function(n,e,t,r,o){var i=Eg(t,r);return Ag(n,e,t,r,i,o)},Rg=function(n,e, t){return go(n,function(n){return e(n).isSome()},t).bind(e)},Fg=we("element","de scHandler"),Ng=function(n,e){return{id:A(n),descHandler:A(e)}};function Vg(){var i={};return{registerId:function(r,o,n){V(n,function(n,e){var t=i[e]!==undefined ?i[e]:{};t[o]=vl(n,r),i[e]=t})},unregisterId:function(t){V(i,function(n,e){n.has OwnProperty(t)&&delete n[t]})},filterByType:function(n){return yt(i,n).map(funct ion(n){return j(n,function(n,e){return Ng(e,n)})}).getOr([])},find:function(n,e, t){var o=ht(e)(i);return Rg(t,function(n){return t=o,Bc(r=n).fold(function(){ret urn F.none()},function(n){var e=ht(n);return t.bind(e).map(function(n){return Fg (r,n)})});var t,r},n)}}}function Hg(){var r=Vg(),o={},i=function(r){var n=r.elem ent();return Bc(n).fold(function(){return n="uid-",e=r.element(),t=Ja(Ac+n),_r(e ,Mc,t),t;var n,e,t},function(n){return n})},u=function(n){Bc(n.element()).each(f unction(n){o[n]=undefined,r.unregisterId(n)})};return{find:function(n,e,t){retur n r.find(n,e,t)},filter:function(n){return r.filterByType(n)},register:function( n){var e=i(n);Tt(o,e)&&function(n,e){var t=o[e];if(t!==n)throw new Error('The ta gId "'+e+'" is already used by: '+Do(t.element())+"\nCannot use it for: "+Do(n.e lement())+"\nThe conflicting element is"+(he(t.element())?" ":" not ")+"already in the DOM");u(n)}(n,e);var t=[n];r.registerId(t,e,n.events()),o[e]=n},unregiste r:u,getById:function(n){return ht(n)(o)}}}var zg=function(t){var r=function(e){r eturn ze(t.element()).fold(function(){return!0},function(n){return Ve(e,n)})},o= Hg(),s=function(n,e){return o.find(r,n,e)},n=Cg(t.element(),{triggerEvent:functi on(u,a){return Ho(u,a.target(),function(n){return e=s,t=u,o=n,i=(r=a).target(),B g(e,t,r,i,o);var e,t,r,o,i})},broadcastEvent:function(n,e){var t=o.filter(n);ret urn Mg(t,e)}}),i=sl({debugInfo:A("real"),triggerEvent:function(e,t,r){Ho(e,t,fun ction(n){Bg(s,e,r,t,n)})},triggerFocus:function(a,c){Bc(a).fold(function(){po(a) },function(n){Ho(Gn(),a,function(n){var e,t,r,o,i,u;e=s,t=Gn(),r={originator:A(c ),kill:I,prevent:I,target:A(a)},i=n,u=Eg(r,o=a),Ig(e,t,r,o,u,i)})})},triggerEsca pe:function(n,e){i.triggerEvent("keydown",n.element(),e.event())},getByUid:funct ion(n){return m(n)},getByDom:function(n){return g(n)},build:Hl,addToGui:function (n){a(n)},removeFromGui:function(n){c(n)},addToWorld:function(n){e(n)},removeFro mWorld:function(n){u(n)},broadcast:function(n){l(n)},broadcastOn:function(n,e){d (n,e)},isConnected:A(!0)}),e=function(n){n.connect(i),pe(n.element())||(o.regist er(n),yn(n.components(),e),i.triggerEvent(Zn(),n.element(),{target:A(n.element() )}))},u=function(n){pe(n.element())||(yn(n.components(),u),o.unregister(n)),n.di sconnect()},a=function(n){Ye(t,n)},c=function(n){Je(n)},f=function(t){var n=o.fi lter(qn());yn(n,function(n){var e=n.descHandler();pl(e)(t)})},l=function(n){f({u niversal:A(!0),data:A(n)})},d=function(n,e){f({universal:A(!1),channels:A(n),dat a:A(e)})},m=function(n){return o.getById(n).fold(function(){return nt.error(new Error('Could not find component with uid: "'+n+'" in system.'))},nt.value)},g=fu nction(n){var e=Bc(n).getOr("not found");return m(e)};return e(t),{root:A(t),ele ment:t.element,destroy:function(){n.unbind(),Ge(t.element())},add:a,remove:c,get ByUid:m,getByDom:g,addToWorld:e,removeFromWorld:u,broadcast:l,broadcastOn:d}},jg =A(mi.resolve("readonly-mode")),Lg=A(mi.resolve("edit-mode"));function Ug(n){var e=Hl(Of.sketch({dom:{classes:[mi.resolve("outer-container")].concat(n.classes)} ,containerBehaviours:Lr([so.config({alpha:jg(),omega:Lg()})])}));return zg(e)}va r Pg=function(n,e){var t=se.fromTag("input");Si(t,{opacity:"0",position:"absolut e",top:"-1000px",left:"-1000px"}),Pe(n,t),po(t),e(t),Ge(t)},$g=function(n){var e =n.getSelection();if(0<e.rangeCount){var t=e.getRangeAt(0),r=n.document.createRa nge();r.setStart(t.startContainer,t.startOffset),r.setEnd(t.endContainer,t.endOf fset),e.removeAllRanges(),e.addRange(r)}},Wg=function(n,e){bo().each(function(n) {Ve(n,e)||ho(n)}),n.focus(),po(se.fromDom(n.document.body)),$g(n)},Gg={stubborn: function(n,e,t,r){var o=function(){Wg(e,r)},i=zd(t,"keydown",function(n){hn(["in put","textarea"],me(n.target()))||o()});return{toReading:function(){Pg(n,ho)},to Editing:o,onToolbarTouch:function(){},destroy:function(){i.unbind()}}},timid:fun ction(n,e,t,r){var o=function(){ho(r)};return{toReading:function(){o()},toEditin g:function(){Wg(e,r)},onToolbarTouch:function(){o()},destroy:I}}},_g=function(t, r,o,i,n){var u=function(){r.run(function(n){n.refreshSelection()})},e=function(n ,e){var t=n-i.dom().scrollTop;r.run(function(n){n.scrollIntoView(t,t+e)})},a=fun ction(){r.run(function(n){n.clearSelection()})},c=function(){t.getCursorBox().ea ch(function(n){e(n.top(),n.height())}),r.run(function(n){n.syncHeight()})},s=_d( t),f=Wm(c,300),l=[t.onKeyup(function(){a(),f.throttle()}),t.onNodeChanged(u),t.o nDomChanged(f.throttle),t.onDomChanged(u),t.onScrollToCursor(function(n){n.preve ntDefault(),f.throttle()}),t.onScrollToElement(function(n){n.element(),e(r,i)}), t.onToEditing(function(){r.run(function(n){n.toEditing()})}),t.onToReading(funct ion(){r.run(function(n){n.toReading()})}),zd(t.doc(),"touchend",function(n){Ve(t .html(),n.target())||Ve(t.body(),n.target())}),zd(o,"transitionend",function(n){ var e;"height"===n.raw().propertyName&&(e=Bi(o),r.run(function(n){n.setViewportO ffset(e)}),u(),c())}),jd(o,"touchstart",function(n){var e;r.run(function(n){n.hi ghlightSelection()}),e=n,r.run(function(n){n.onToolbarTouch(e)}),t.onTouchToolst rip()}),zd(t.body(),"touchstart",function(n){a(),t.onTouchContent(),s.fireTouchs tart(n)}),s.onTouchmove(),s.onTouchend(),zd(t.body(),"click",function(n){n.kill( )}),zd(o,"touchmove",function(){t.onToolbarScrollStart()})];return{destroy:funct ion(){yn(l,function(n){n.unbind()})}}},qg=function(n){var t=F.none(),e=[],r=func tion(n){o()?u(n):e.push(n)},o=function(){return t.isSome()},i=function(n){yn(n,u )},u=function(e){t.each(function(n){setTimeout(function(){e(n)},0)})};return n(f unction(n){t=F.some(n),i(e),e=[]}),{get:r,map:function(t){return qg(function(e){ r(function(n){e(t(n))})})},isReady:o}},Yg={nu:qg,pure:function(e){return qg(func tion(n){n(e)})}},Kg=function(e){var n=function(n){var r;e((r=n,function(){for(va r n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];var t=this;setTimeout(functi on(){r.apply(t,n)},0)}))},t=function(){return Yg.nu(n)};return{map:function(r){r eturn Kg(function(t){n(function(n){var e=r(n);t(e)})})},bind:function(t){return Kg(function(e){n(function(n){t(n).get(e)})})},anonBind:function(t){return Kg(fun ction(e){n(function(n){t.get(e)})})},toLazy:t,toCached:function(){var e=null;ret urn Kg(function(n){null===e&&(e=t()),e.get(n)})},get:n}},Xg={nu:Kg,pure:function (e){return Kg(function(n){n(e)})}},Jg=function(n,e,t){return Math.abs(n-e)<=t?F. none():n<e?F.some(n+t):F.some(n-t)},Qg=function(){var s=null;return{animate:func tion(r,o,n,i,e,t){var u=!1,a=function(n){u=!0,e(n)};clearInterval(s);var c=funct ion(n){clearInterval(s),a(n)};s=setInterval(function(){var t=r();Jg(t,o,n).fold( function(){clearInterval(s),a(o)},function(n){if(i(n,c),!u){var e=r();(e!==n||Ma th.abs(e-o)>Math.abs(t-o))&&(clearInterval(s),a(o))}})},t)}}},Zg=function(e,t){r eturn Mo([{width:320,height:480,keyboard:{portrait:300,landscape:240}},{width:32 0,height:568,keyboard:{portrait:300,landscape:240}},{width:375,height:667,keyboa rd:{portrait:305,landscape:240}},{width:414,height:736,keyboard:{portrait:320,la ndscape:240}},{width:768,height:1024,keyboard:{portrait:320,landscape:400}},{wid th:1024,height:1366,keyboard:{portrait:380,landscape:460}}],function(n){return e <=n.width&&t<=n.height?F.some(n.keyboard):F.none()}).getOr({portrait:t/5,landsca pe:e/4})},nv=function(n){var e,t=Ud(n).isPortrait(),r=Zg((e=n).screen.width,e.sc reen.height),o=t?r.portrait:r.landscape;return(t?n.screen.height:n.screen.width) -n.innerHeight>o?0:o},ev=function(n,e){var t=He(n).dom().defaultView;return Bi(n )+Bi(e)-nv(t)},tv=ev,rv=function(n,e,t){var r=ev(e,t),o=Bi(e)+Bi(t)-r;xi(n,"padd ing-bottom",o+"px")},ov=et([{fixed:["element","property","offsetY"]},{scroller:[ "element","offsetY"]}]),iv="data-"+mi.resolve("position-y-fixed"),uv="data-"+mi. resolve("y-property"),av="data-"+mi.resolve("scrolling"),cv="data-"+mi.resolve(" last-window-height"),sv=function(n){return Kd(n,iv)},fv=function(n,e){var t=Yr(n ,uv);return ov.fixed(n,t,e)},lv=function(n,e){return ov.scroller(n,e)},dv=functi on(n){var e=sv(n);return("true"===Yr(n,av)?lv:fv)(n,e)},mv=function(n,e,t){var r =He(n).dom().defaultView.innerHeight;return _r(n,cv,r+"px"),r-e-t},gv=function(n ){var e=Ni(n,"["+iv+"]");return bn(e,dv)},vv=function(r,o,i,u){var n,e,t,a,c,s,f ,l,d=He(r).dom().defaultView,m=(l=Yr(f=i,"style"),Si(f,{position:"absolute",top: "0px"}),_r(f,iv,"0px"),_r(f,uv,"top"),{restore:function(){_r(f,"style",l||""),Xr (f,iv),Xr(f,uv)}}),g=Bi(i),v=Bi(u),p=mv(r,g,v),h=(t=g,a=p,s=Yr(c=r,"style"),bd.r egister(c),Si(c,{position:"absolute",height:a+"px",width:"100%",top:t+"px"}),_r( c,iv,t+"px"),_r(c,av,"true"),_r(c,uv,"top"),{restore:function(){bd.deregister(c) ,_r(c,"style",s||""),Xr(c,iv),Xr(c,av),Xr(c,uv)}}),b=(e=Yr(n=u,"style"),Si(n,{po sition:"absolute",bottom:"0px"}),_r(n,iv,"0px"),_r(n,uv,"bottom"),{restore:funct ion(){_r(n,"style",e||""),Xr(n,iv),Xr(n,uv)}}),y=!0,w=function(){var n=d.innerHe ight;return Kd(r,cv)<n},x=function(){if(y){var n=Bi(i),e=Bi(u),t=mv(r,n,e);_r(r, iv,n+"px"),xi(r,"height",t+"px"),xi(u,"bottom",-(n+t+e)+"px"),rv(o,r,u)}};return rv(o,r,u),{setViewportOffset:function(n){_r(r,iv,n+"px"),x()},isExpanding:w,isS hrinking:S(w),refresh:x,restore:function(){y=!1,m.restore(),h.restore(),b.restor e()}}},pv=sv,hv=Qg(),bv="data-"+mi.resolve("last-scroll-top"),yv=function(n){var e=ki(n,"top").getOr("0");return parseInt(e,10)},wv=function(n){return parseInt( n.dom().scrollTop,10)},xv=function(n,e){var t=e+pv(n)+"px";xi(n,"top",t)},Sv=fun ction(t,r,o){return Xg.nu(function(n){var e=l(wv,t);hv.animate(e,r,15,function(n ){t.dom().scrollTop=n,xi(t,"top",yv(t)+15+"px")},function(){t.dom().scrollTop=r, xi(t,"top",o+"px"),n(r)},10)})},Tv=function(o,i){return Xg.nu(function(n){var e= l(wv,o);_r(o,bv,e());var t=Math.abs(i-e()),r=Math.ceil(t/10);hv.animate(e,i,r,fu nction(n,e){Kd(o,bv)!==o.dom().scrollTop?e(o.dom().scrollTop):(o.dom().scrollTop =n,_r(o,bv,n))},function(){o.dom().scrollTop=i,_r(o,bv,i),n(i)},10)})},Ov=functi on(i,u){return Xg.nu(function(n){var e=l(yv,i),t=function(n){xi(i,"top",n+"px")} ,r=Math.abs(u-e()),o=Math.ceil(r/10);hv.animate(e,u,o,t,function(){t(u),n(u)},10 )})},kv=function(e,t,r){var o=He(e).dom().defaultView;return Xg.nu(function(n){x v(e,r),xv(t,r),o.scrollTo(0,r),n(r)})},Cv=function(n,e,t,r,o){var i=tv(e,t),u=l( $g,n);i<r||i<o?Tv(e,e.dom().scrollTop-i+o).get(u):r<0&&Tv(e,e.dom().scrollTop+r) .get(u)},Ev=function(u,n){return n(function(r){var o=[],i=0;0===u.length?r([]):y n(u,function(n,e){var t;n.get((t=e,function(n){o[t]=n,++i>=u.length&&r(o)}))})}) },Dv=function(n,c){return n.fold(function(n,e,t){return xi(n,e,c+(r=t)+"px"),Xg. pure(r);var r},function(n,e){return o=c+(r=e),i=ki(t=n,"top").getOr(r),u=o-parse Int(i,10),a=t.dom().scrollTop+u,Sv(t,a,o);var t,r,o,i,u,a})},Iv=function(n,e){va r t=gv(n),r=bn(t,function(n){return Dv(n,e)});return Ev(r,Xg.nu)},Av=function(e, t,n,r,o,i){var u,a,c=(u=function(n){return kv(e,t,n)},a=fo(Yg.pure({})),{start:f unction(e){var n=Yg.nu(function(n){return u(e).get(n)});a.set(n)},idle:function( n){a.get().get(function(){n()})}}),s=Wm(function(){c.idle(function(){Iv(n,r.page YOffset).get(function(){var n;(n=wm(i),F.from(n[0]).bind(function(n){var e=n.top ()-t.dom().scrollTop;return e>r.innerHeight+5||e<-5?F.some({top:A(e),bottom:A(e+ n.height())}):F.none()})).each(function(n){t.dom().scrollTop=t.dom().scrollTop+n .top()}),c.start(0),o.refresh()})})},1e3),f=zd(se.fromDom(r),"scroll",function() {r.pageYOffset<0||s.throttle()});return Iv(n,r.pageYOffset).get(h),{unbind:f.unb ind}},Mv=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=vv(r,e,o,s),l=a(n.outerBody(),t,be(),u,o,i),d=Pd(c,{onChange:I,onReady:f.re fresh});d.onAdjustment(function(){f.refresh()});var m=zd(se.fromDom(c),"resize", function(){f.isExpanding()&&f.refresh()}),g=Av(o,r,n.outerBody(),c,f,t),v=functi on(t,e){var n=t.document,r=se.fromTag("div");to(r,mi.resolve("unfocused-selectio ns")),Pe(se.fromDom(n.documentElement),r);var o=zd(r,"touchstart",function(n){n. prevent(),Wg(t,e),u()}),i=function(n){var e=se.fromTag("span");return Ol(e,[mi.r esolve("layer-editor"),mi.resolve("unfocused-selection")]),Si(e,{left:n.left()+" px",top:n.top()+"px",width:n.width()+"px",height:n.height()+"px"}),e},u=function (){We(r)};return{update:function(){u();var n=wm(t),e=bn(n,i);$e(r,e)},isActive:f unction(){return 0<je(r).length},destroy:function(){o.unbind(),Ge(r)},clear:u}}( t,u),p=function(){v.clear()};return{toEditing:function(){l.toEditing(),p()},toRe ading:function(){l.toReading()},onToolbarTouch:function(n){l.onToolbarTouch(n)}, refreshSelection:function(){v.isActive()&&v.update()},clearSelection:p,highlight Selection:function(){v.update()},scrollIntoView:function(n,e){Cv(t,r,s,n,e)},upd ateToolbarPadding:I,setViewportOffset:function(n){f.setViewportOffset(n),Ov(r,n) .get(h)},syncHeight:function(){xi(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(),Pg(be(),ho)}}},Bv=funct ion(r,n){var o=Pm(),i=Zf(),u=Zf(),a=Qf(),c=Qf();return{enter:function(){n.hide() ;var t=se.fromDom(document);Nm.getActiveApi(r.editor).each(function(n){i.set({so cketHeight:ki(r.socket,"height"),iframeHeight:ki(n.frame(),"height"),outerScroll :document.body.scrollTop}),u.set({exclusives:tg.exclusive(t,"."+bd.scrollable()) }),to(r.container,mi.resolve("fullscreen-maximized")),Lm(r.container,n.body()),o .maximize(),xi(r.socket,"overflow","scroll"),xi(r.socket,"-webkit-overflow-scrol ling","touch"),po(n.body());var e=Ce(["cWin","ceBody","socket","toolstrip","tool bar","dropup","contentElement","cursor","keyboardType","isScrolling","outerWindo w","outerBody"],[]);a.set(Mv(e({cWin:n.win(),ceBody:n.body(),socket:r.socket,too lstrip:r.toolstrip,toolbar:r.toolbar,dropup:r.dropup.element(),contentElement:n. frame(),cursor:I,outerBody:r.body,outerWindow:r.win,keyboardType:Gg.stubborn,isS crolling:function(){return u.get().exists(function(n){return n.socket.isScrollin g()})}}))),a.run(function(n){n.syncHeight()}),c.set(_g(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){xi(r.socket,"height",n)}),n.iframeHeight.each(func tion(n){xi(r.editor.getFrame(),"height",n)}),document.body.scrollTop=n.scrollTop }),i.clear(),u.on(function(n){n.exclusives.unbind()}),u.clear(),ro(r.container,m i.resolve("fullscreen-maximized")),Um(),bd.deregister(r.toolbar),Ci(r.socket,"ov erflow"),Ci(r.socket,"-webkit-overflow-scrolling"),ho(r.editor.getFrame()),Nm.ge tActiveApi(r.editor).each(function(n){n.clearSelection()})}}},Rv=function(n){var e=qt("Getting IosWebapp schema",_m,n);xi(e.toolstrip,"width","100%"),xi(e.conta iner,"position","relative");var t=Hl(Gm(function(){e.setReadOnly(e.readOnlyOnIni t()),r.enter()},e.translate));e.alloy.add(t);var r=Bv(e,{show:function(){e.alloy .add(t)},hide:function(){e.alloy.remove(t)}});return{setReadOnly:e.setReadOnly,r efreshStructure:r.refreshStructure,enter:r.enter,exit:r.exit,destroy:I}},Fv=tiny mce.util.Tools.resolve("tinymce.EditorManager"),Nv=function(n){var e=yt(n.settin gs,"skin_url").fold(function(){return Fv.baseURL+"/skins/lightgray"},function(n) {return n});return{content:e+"/content.mobile.min.css",ui:e+"/skin.mobile.min.cs s"}},Vv=function(n,e,t){n.system().broadcastOn([To.formatChanged()],{command:e,s tate:t})},Hv=function(r,n){var e=N(n.formatter.get());yn(e,function(e){n.formatt er.formatChanged(e,function(n){Vv(r,e,n)})}),yn(["ul","ol"],function(t){n.select ion.selectorChanged(t,function(n,e){Vv(r,t,n)})})},zv=(A(["x-small","small","med ium","large","x-large"]),function(n){var e=function(){n._skinLoaded=!0,n.fire("S kinLoaded")};return function(){n.initialized?e():n.on("init",e)}}),jv=A("toReadi ng"),Lv=A("toEditing");xo.add("mobile",function(D){return{getNotificationManager Impl:function(){return{open:h,close:I,reposition:I,getArgs:h}},renderUI:function (n){var e=Nv(D);0==(!1===D.settings.skin)?(D.contentCSS.push(e.content),wo.DOM.s tyleSheetLoader.load(e.ui,zv(D))):zv(D)();var t,r,o,i,u,a,c,s,f,l,d,m,g,v,p,h,b, y=function(){D.fire("scrollIntoView")},w=se.fromTag("div"),x=$n.detect().os.isAn droid()?(s=y,f=Ug({classes:[mi.resolve("android-container")]}),l=rg(),d=Qf(),m=u g(d),g=ag(),v=Tg(I,s),f.add(l.wrapper()),f.add(g),f.add(v.component()),{system:A (f),element:f.element,init:function(n){d.set(qm(n))},exit:function(){d.run(funct ion(n){n.exit(),td.remove(g,m)})},setToolbarGroups:function(n){var e=l.createGro ups(n);l.setGroups(e)},setContextToolbar:function(n){var e=l.createGroups(n);l.s etContextToolbar(e)},focusToolbar:function(){l.focus()},restoreToolbar:function( ){l.restoreToolbar()},updateMode:function(n){cg(g,m,n,f.root())},socket:A(g),dro pup:A(v)}):(t=y,r=Ug({classes:[mi.resolve("ios-container")]}),o=rg(),i=Qf(),u=ug (i),a=ag(),c=Tg(function(){i.run(function(n){n.refreshStructure()})},t),r.add(o. wrapper()),r.add(a),r.add(c.component()),{system:A(r),element:r.element,init:fun ction(n){i.set(Rv(n))},exit:function(){i.run(function(n){td.remove(a,u),n.exit() })},setToolbarGroups:function(n){var e=o.createGroups(n);o.setGroups(e)},setCont extToolbar:function(n){var e=o.createGroups(n);o.setContextToolbar(e)},focusTool bar:function(){o.focus()},restoreToolbar:function(){o.restoreToolbar()},updateMo de:function(n){cg(a,u,n,r.root())},socket:A(a),dropup:A(c)}),S=se.fromDom(n.targ etNode);we("element","offset"),h=w,(b=(p=S).dom(),F.from(b.nextSibling).map(se.f romDom)).fold(function(){ze(p).each(function(n){Pe(n,h)})},function(n){var e,t;t =h,ze(e=n).each(function(n){n.dom().insertBefore(t.dom(),e.dom())})}),function(n ,e){Pe(n,e.element());var t=je(e.element());yn(t,function(n){e.getByDom(n).each( qe)})}(w,x.system());var T=n.targetNode.ownerDocument.defaultView,O=Pd(T,{onChan ge:function(){x.system().broadcastOn([To.orientationChanged()],{width:$d(T)})},o nReady:I}),k=function(n,e,t,r){!1===r&&D.selection.collapse();var o=C(n,e,t);x.s etToolbarGroups(!0===r?o.readOnly:o.main),D.setMode(!0===r?"readonly":"design"), D.fire(!0===r?jv():Lv()),x.updateMode(r)},C=function(n,e,t){var r=n.get();return {readOnly:r.backToMask.concat(e.get()),main:r.backToMask.concat(t.get())}},E=fun ction(n,e){return D.on(n,e),{unbind:function(){D.off(n)}}};return D.on("init",fu nction(){x.init({editor:{getFrame:function(){return se.fromDom(D.contentAreaCont ainer.querySelector("iframe"))},onDomChanged:function(){return{unbind:I}},onToRe ading:function(n){return E(jv(),n)},onToEditing:function(n){return E(Lv(),n)},on ScrollToCursor:function(e){return D.on("scrollIntoView",function(n){e(n)}),{unbi nd:function(){D.off("scrollIntoView"),O.destroy()}}},onTouchToolstrip:function() {t()},onTouchContent:function(){var n,e=se.fromDom(D.editorContainer.querySelect or("."+mi.resolve("toolbar")));(n=e,yo(n).bind(function(n){return x.system().get ByDom(n).toOption()})).each(ie),x.restoreToolbar(),t()},onTapContent:function(n) {var e=n.target();"img"===me(e)?(D.selection.select(e.dom()),n.kill()):"a"===me( e)&&x.system().getByDom(se.fromDom(D.editorContainer)).each(function(n){so.isAlp ha(n)&&So(e.dom())})}},container:se.fromDom(D.editorContainer),socket:se.fromDom (D.contentAreaContainer),toolstrip:se.fromDom(D.editorContainer.querySelector(". "+mi.resolve("toolstrip"))),toolbar:se.fromDom(D.editorContainer.querySelector(" ."+mi.resolve("toolbar"))),dropup:x.dropup(),alloy:x.system(),translate:I,setRea dOnly:function(n){k(c,a,u,n)},readOnlyOnInit:function(){return!1}});var t=functi on(){x.dropup().disappear(function(){x.system().broadcastOn([To.dropupDismissed( )],{})})},n={label:"The first group",scrollable:!1,items:[Yc.forToolbar("back",f unction(){D.selection.collapse(),x.exit()},{})]},e={label:"Back to read only",sc rollable:!1,items:[Yc.forToolbar("readonly-back",function(){k(c,a,u,!0)},{})]},r =Bd(x,D),o=Rd(D.settings,r),i={label:"The extra group",scrollable:!1,items:[]},u =fo([{label:"the action group",scrollable:!0,items:o},i]),a=fo([{label:"The read only mode group",scrollable:!0,items:[]},i]),c=fo({backToMask:[n],backToReadOnl y:[e]});Hv(x,D)}),{iframeContainer:x.socket().element().dom(),editorContainer:x. element().dom()}}}})}();
 End of changes. 1 change blocks. 
lines changed or deleted lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)